Repository navigation
Conversation
comphead
marked this pull request as draft
October 13, 2026 15:31
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #26266 +/- ##
========================================
Coverage 82.80% 82.80%
========================================
Files 1149 1150 +1
Lines 454480 454761 +281
Branches 454480 454761 +281
========================================
+ Hits 376347 376580 +233
- Misses 55267 55299 +32
- Partials 22866 22882 +16 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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?
datafusion-sparkSpark Compatible Functions #15914Rationale for this change
Spark's
stack(n, expr1, ..., exprk)separates the values intonrows. It is the standard way to unpivot in Spark SQL, and Comet falls back to Spark for it.What changes are included in this PR?
stackindatafusion-spark. A ScalarUDF cannot emit rows, so likejson_tupleit returns thenrows as aList<Struct<col0, col1, ...>>, which is the data type of Spark's Generator. As in Spark, the list is not nullable while its elements and fields are. The caller (Comet, orunnestin SQL) expands it.Stack.checkInputDataTypes, with the same messages.nis coerced toINT. The values of a column must have the same Spark type, and NULLs, Arrow types of one Spark type (such asUtf8andUtf8View) and integer literals that fit are cast to it.concatdoubling. Other types usetakeover the concatenated values. On the newstackbench this is about 3x to 5x faster thaninterleave.What is the testing strategy for this PR?
spark/generator/stack.sltports the cases of Spark'sGeneratorFunctionSuite,GeneratorExpressionSuiteandTypeCoercionSuite, and of thegenerators,table-valued-functionsandjoin-lateralgolden files. It also covers each kernel path. Unit tests cover an empty batch and the list size overflow, which SQL cannot reach.Are there any user-facing changes?
A new Spark-compatible
stackfunction. Unlike Spark,nmust be an integer literal, so a foldable expression such as3 - 1is rejected.