[AURON #2343] Support native flatten for mixed child array nullability#2344
Open
weimingdiit wants to merge 1 commit into
Open
[AURON #2343] Support native flatten for mixed child array nullability#2344weimingdiit wants to merge 1 commit into
weimingdiit wants to merge 1 commit into
Conversation
…ability Signed-off-by: weimingdiit <weimingdiit@gmail.com>
21ea7d0 to
e7be569
Compare
slfan1989
approved these changes
Jun 26, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds native execution support for Spark SQL flatten(array<array<T>>) in Auron, aiming to remove existing Spark expression test exclusions and improve Spark SQL compatibility—especially for cases where nested arrays differ in containsNull metadata.
Changes:
- Adds a new native scalar function
Spark_ArrayFlattenand wires SparkFlattenexpressions to it. - Improves native
Spark_MakeArrayhandling for mixed child array nullability by widening list/struct element types. - Adds an Auron SQL regression test and removes
flatten functionexclusions from Spark 3.1/3.2/3.4/3.5 test settings.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| spark-extension/src/main/scala/org/apache/spark/sql/auron/NativeConverters.scala | Converts Spark Flatten to the new native Spark_ArrayFlatten function. |
| spark-extension-shims-spark/src/test/scala/org/apache/auron/AuronFunctionSuite.scala | Adds SQL coverage for flatten with mixed child array nullability and null/empty edge cases. |
| native-engine/datafusion-ext-functions/src/spark_make_array.rs | Widens list/struct element types and casts to a common element type for non-primitive array(...) creation. |
| native-engine/datafusion-ext-functions/src/spark_array.rs | Implements array_flatten native function and adds a unit test. |
| native-engine/datafusion-ext-functions/src/lib.rs | Registers Spark_ArrayFlatten in the native function factory. |
| auron-spark-tests/spark35/src/test/scala/org/apache/auron/utils/AuronSparkTestSettings.scala | Removes Spark 3.5 flatten function exclusion. |
| auron-spark-tests/spark34/src/test/scala/org/apache/auron/utils/AuronSparkTestSettings.scala | Removes Spark 3.4 flatten function exclusion. |
| auron-spark-tests/spark32/src/test/scala/org/apache/auron/utils/AuronSparkTestSettings.scala | Removes Spark 3.2 flatten function exclusion. |
| auron-spark-tests/spark31/src/test/scala/org/apache/auron/utils/AuronSparkTestSettings.scala | Removes Spark 3.1 flatten function exclusion. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+95
to
+100
| ColumnarValue::Array(array) if matches!(array.data_type(), DataType::Null) => { | ||
| Ok(ListArray::new_null( | ||
| Arc::new(Field::new_list_field(DataType::Null, true)), | ||
| array.len(), | ||
| )) | ||
| } |
Comment on lines
+158
to
+165
| let values = make_array(mutable.freeze()); | ||
| let field = Arc::new(Field::new_list_field(values.data_type().clone(), true)); | ||
| Ok(ColumnarValue::Array(Arc::new(ListArray::try_new( | ||
| field, | ||
| OffsetBuffer::new(ScalarBuffer::from(offsets)), | ||
| values, | ||
| Some(NullBuffer::from(valids)), | ||
| )?))) |
Comment on lines
112
to
+116
| // naive implementation with scalar values | ||
| let num_rows = args[0].len(); | ||
| let data_type = common_array_element_data_type(args)?; | ||
| let args = args | ||
| .iter() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Which issue does this PR close?
Closes #2343
Rationale for this change
Auron currently excludes Spark's
flatten functiontests because native execution can fail when child arrays have differentcontainsNullmetadata.flattenis a built-in Spark array expression, so supporting it in native execution improves Spark SQL compatibility and reduces fallback coverage gaps.What changes are included in this PR?
Spark_ArrayFlattenfunction.Flattenexpressions to the new native function.flatten functionexcludes from Spark 3.1/3.2/3.4/3.5 test settings.Are there any user-facing changes?
No user-facing API changes. More
flattenexpressions can now be executed natively by Auron.How was this patch tested?
UT.