[SPARK-59091][SQL] Emit the NaN guard in transpiled equality only for floating-point columns - #58901
Open
jzhan-2026 wants to merge 1 commit into
Open
jzhan-2026 wants to merge 1 commit into
jzhan-2026 wants to merge 1 commit into
Conversation
jzhan-2026
marked this pull request as ready for review
September 17, 2026 23:11
Author
|
@holdenk PTAL when you get a chance! Thanks in advance! |
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.
What changes were proposed in this pull request?
Split the transpiler's
"numeric"category into"integer"(IntegralType) and"float"(FractionalType, excluding DecimalType). The NaN guard in
_lower_eqis now only emittedwhen at least one operand has category
"float".transpile.py:_categoryreturns"integer"/"float"instead of"numeric"forliterals and parameters;
_param_category_combostries["integer", "float", "string"]per parameter;
_lower_eqgates the guard onlc == "float" or rc == "float";_convert_chunkBinOp dispatch uses_is_numeric_cat()for all three sub-categories.ResolveTranspiledPythonUDFOptions.scala: adds"integer"→ IntegralType and"float"→ FractionalType (excluding Decimal) cases to
optionMatchesTypes.Why are the changes needed?
For integer columns (e.g.
BIGINT), the old plan forx == yincludedisnan(cast(x AS DOUBLE)), which is always false—integers can't be NaN. The NaN guard only makes sense for floating-point types.Does this PR introduce any user-facing change?
No. The generated Catalyst plan for integer-column equality no longer contains dead
isnanguards, but the query results are identical.How was this patch tested?
New Python tests in
test_udf_transpile_unit:test_udf_transpile_integer_eq_no_nan_guard— noisnanin plan forBIGINT ==test_udf_transpile_float_eq_nan_semantics—isnanpresent forDOUBLE ==; NaN and null semantics verified end-to-endtest_udf_transpile_int_float_annotation_categories— unit tests for new category namesNew Scala tests in
ResolveTranspiledPythonUDFOptionsSuite:"integer"/"float"matching, cross-type rejection, DecimalType exclusion, FloatType matching.Was this patch authored or co-authored using generative AI tooling?
Co-authored by: Claude Sonnet 4.6