JVM columnar shuffle panics on a struct column with a NullType field
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 72/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Domain
- data-engineering
Research direction
Start in native/shuffle/src/spark_unsafe/row.rs at the two field-major functions, append_struct_fields_field_major and append_nested_struct_fields_field_major, which reach unreachable! for DataType::Null. Compare with the existing Null arm in append_field in the same file to see how a per-row null is appended. Done when the three SQL repros in the issue return Spark's rows, with a regression test covering a top-level and a nested struct with a null field.
Written by the indexing model from the issue text.
Description
Describe the bug
A shuffle that runs on Comet's JVM columnar shuffle fails the query when one of its columns is a struct with a NullType field, such as named_struct('x', a, 'n', null). The row-to-Arrow conversion panics:
org.apache.comet.CometNativeException: internal error: entered unreachable code: Unsupported data type of struct field: Null
at datafusion_comet_shuffle::spark_unsafe::row::append_struct_fields_field_major
at datafusion_comet_shuffle::spark_unsafe::row::append_columns
at datafusion_comet_shuffle::spark_unsafe::row::process_sorted_row_partition
at comet::execution::jni_api::write_sorted_file
at comet::execution::jni_api::Java_org_apache_comet_Native_writeSortedFileNative
Spark returns the rows. Both field-major struct paths in native/shuffle/src/spark_unsafe/row.rs lack a DataType::Null arm and fall through to unreachable!. append_struct_fields_field_major handles a top-level struct column, and append_nested_struct_fields_field_major handles a struct inside a struct:
append_field in the same file already has the arm. The JVM columnar shuffle's type check accepts NullType at any depth, so nothing keeps these schemas away from the converter, and Null is the only type that check accepts that the two functions are missing.
With the default configuration this hits every round-robin repartition of such a column, because native round robin is off by default and those shuffles run on JVM columnar shuffle. It also hits a hash shuffle that runs on JVM columnar shuffle, for example under spark.comet.shuffle.mode=jvm. A hash shuffle over a native child runs on native shuffle and works. Arrays and maps that hold nulls (array(null), map(k, null), array(named_struct('x', a, 'n', null))) also work.
Steps to reproduce
CREATE TABLE t (a INT) USING parquet;
INSERT INTO t SELECT CAST(id AS INT) FROM range(1000);
-- top-level struct column
SELECT /*+ REPARTITION(4) */ a, named_struct('x', a, 'n', null) AS st FROM t;
-- struct inside a struct
SELECT /*+ REPARTITION(4) */ a, named_struct('s', named_struct('x', a, 'n', null)) AS st FROM t;
-- hash partitioning on JVM columnar shuffle
SET spark.comet.shuffle.mode=jvm;
SELECT a, named_struct('x', a, 'n', null) AS st FROM t DISTRIBUTE BY a;
All three fail with the panic above. I reproduced them on c3316fbe39 with the Spark 4.1 profile, and the code involved is unchanged on main at 3a4a159409.
Expected behavior
The queries should return the same rows as Spark. Every value of a NullType field is null, so a DataType::Null arm in both functions that appends one null per row, as append_field does, should be enough. A regression test with a top-level and a nested struct would cover both paths.
Additional context
#6977 proposes merging the two field-major functions, which would make an arm like this one change instead of two.
- Dominant language
- Scala
- Stars
- 1.3k
- Forks
- 391
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 421
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from apache/datafusion-comet
-
area:shuffle enhancement good first issue performance requires-triage
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
apache/datafusion-comet#7072 ·
Maintainers usually reply within 1 day
-
Native hashing of NullType and ANSI interval values fails with "Unsupported data type in hasher"Openarea:expressions area:shuffle bug priority:high requires-triage
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
apache/datafusion-comet#7063 ·
Maintainers usually reply within 1 day
-
requires-triage
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
apache/datafusion-comet#7001 ·
Maintainers usually reply within 1 day
-
Extract shared list-array construction from the split_* functions in split.rsPossibly taken @arminazimi claimed this 1 day ago. Openarea:expressions enhancement good first issue help wanted requires-triage rust tech debt
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
apache/datafusion-comet#6983 ·
Maintainers usually reply within 1 day
-
Deduplicate spark_ceil and spark_floor and port floor's decimal boundary tests to ceilPossibly taken @med9110 claimed this 1 day ago. Openarea:expressions enhancement help wanted requires-triage rust tech debt
Difficulty 2/5 Half a day Newbie friendliness 68/100
apache/datafusion-comet#6974 · 1 comment ·
Maintainers usually reply within 1 day
All issues in apache/datafusion-comet
Similar issues
-
Improve UI text on confirmation page (at registration)Possibly taken @Arghyann claimed this today. Opengood first issue improvement
Difficulty 1/5 Under an hour Newbie friendliness 72/100
lichess-org/lila#22126 · 2 comments ·
Maintainers usually reply within 1 day
-
agent-ready area/dev-tooling kind/docs-only layer/docs size/XS
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
marola-dev/marola#855 ·
Maintainers usually reply within 1 day
-
llm4s-ollama: bind a base-URL variable for chat sections, and align the documented variable nameOpen
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
scylladb/scylla-migrator#413 ·
-
Difficulty 2/5 Under an hour Newbie friendliness 70/100