feat: opt sort_array into codegen dispatch under strict floating-point mode#4637
Open
andygrove wants to merge 1 commit into
Open
feat: opt sort_array into codegen dispatch under strict floating-point mode#4637andygrove wants to merge 1 commit into
andygrove wants to merge 1 commit into
Conversation
…t mode CometSortArray reports Incompatible only when spark.comet.exec.strictFloatingPoint is enabled and the array contains floats. Mixing in CodegenDispatchFallback routes that case through the JVM codegen dispatcher (Spark's own doGenCode) so it stays native and matches Spark instead of falling back. SortArray has a real doGenCode (not CodegenFallback), so the dispatcher accepts it. Part of apache#4596.
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?
Part of #4596 (the
sort_arraycandidate).Rationale for this change
CometSortArrayreportsIncompatiblein exactly one situation: whenspark.comet.exec.strictFloatingPoint=trueand the array element type contains a float or double (strict mode flags float ordering, for example NaN and signed zero, as not bit-identical to Spark). WithallowIncompatibleunset, that case falls the whole projection back to Spark.The issue flagged
sort_arrayas needing an eligibility check because it might beCodegenFallback. It is not: Spark'sSortArrayhas a realdoGenCode, so the JVM codegen dispatcher accepts it. (And the dispatcher admitsCodegenFallbackexpressions anyway.)What changes are included in this PR?
CometSortArraymixes inCodegenDispatchFallback, so its strict-floating-pointIncompatiblecase routes through the JVM codegen dispatcher (Spark's owndoGenCodeinside the Comet pipeline) and matches Spark exactly instead of falling back. TheUnsupportednested-struct/null element-type case is unchanged (still falls back), and default (non-strict) behavior is unchanged.How are these changes tested?
New
sort_array_strict_fp.sqlruns withspark.comet.exec.strictFloatingPoint=trueover double and float arrays containing NaN, +/-Infinity, +/-0.0, and nulls, asserting native execution that matches Spark via the dispatcher. The existing comprehensivesort_array.sql(default mode, all element types, including the nested-structexpect_fallbackcases) still passes. Both run withCometSqlFileTestSuiteon Spark 3.5.