-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-48128][SQL] For BitwiseCount / bit_count expression, fix codegen syntax error for boolean type inputs #46382
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Conversation
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
dongjoon-hyun
approved these changes
May 4, 2024
Member
dongjoon-hyun
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1, LGTM. Thank you, @JoshRosen .
dongjoon-hyun
pushed a commit
that referenced
this pull request
May 4, 2024
…en syntax error for boolean type inputs ### What changes were proposed in this pull request? This PR fixes an issue where `BitwiseCount` / `bit_count` of boolean inputs would cause codegen to generate syntactically invalid Java code that does not compile, triggering errors like ``` java.util.concurrent.ExecutionException: org.codehaus.commons.compiler.CompileException: File 'generated.java', Line 41, Column 11: Failed to compile: org.codehaus.commons.compiler.CompileException: File 'generated.java', Line 41, Column 11: Unexpected token "if" in primary ``` Even though this code has test cases in `bitwise.sql` via the query test framework, those existing test cases were insufficient to find this problem: I believe that is because the example queries were constant-folded using the interpreted path, leaving the codegen path without test coverage. This PR fixes the codegen issue and adds explicit expression tests to ensure that the same tests run on both the codegen and interpreted paths. ### Why are the changes needed? Fix a rare codegen to interpreted fallback issue, which may harm query performance. ### Does this PR introduce _any_ user-facing change? No. ### How was this patch tested? Added new test cases to BitwiseExpressionsSuite.scala, copied from the existing `bitwise.sql` query test case file. ### Was this patch authored or co-authored using generative AI tooling? No. Closes #46382 from JoshRosen/SPARK-48128-bit_count_codegen. Authored-by: Josh Rosen <[email protected]> Signed-off-by: Dongjoon Hyun <[email protected]> (cherry picked from commit 96f65c9) Signed-off-by: Dongjoon Hyun <[email protected]>
dongjoon-hyun
pushed a commit
that referenced
this pull request
May 4, 2024
…en syntax error for boolean type inputs ### What changes were proposed in this pull request? This PR fixes an issue where `BitwiseCount` / `bit_count` of boolean inputs would cause codegen to generate syntactically invalid Java code that does not compile, triggering errors like ``` java.util.concurrent.ExecutionException: org.codehaus.commons.compiler.CompileException: File 'generated.java', Line 41, Column 11: Failed to compile: org.codehaus.commons.compiler.CompileException: File 'generated.java', Line 41, Column 11: Unexpected token "if" in primary ``` Even though this code has test cases in `bitwise.sql` via the query test framework, those existing test cases were insufficient to find this problem: I believe that is because the example queries were constant-folded using the interpreted path, leaving the codegen path without test coverage. This PR fixes the codegen issue and adds explicit expression tests to ensure that the same tests run on both the codegen and interpreted paths. ### Why are the changes needed? Fix a rare codegen to interpreted fallback issue, which may harm query performance. ### Does this PR introduce _any_ user-facing change? No. ### How was this patch tested? Added new test cases to BitwiseExpressionsSuite.scala, copied from the existing `bitwise.sql` query test case file. ### Was this patch authored or co-authored using generative AI tooling? No. Closes #46382 from JoshRosen/SPARK-48128-bit_count_codegen. Authored-by: Josh Rosen <[email protected]> Signed-off-by: Dongjoon Hyun <[email protected]> (cherry picked from commit 96f65c9) Signed-off-by: Dongjoon Hyun <[email protected]>
Member
|
Merged to master/3.5/3.4. |
sinaiamonkar-sai
pushed a commit
to sinaiamonkar-sai/spark
that referenced
this pull request
May 5, 2024
…en syntax error for boolean type inputs ### What changes were proposed in this pull request? This PR fixes an issue where `BitwiseCount` / `bit_count` of boolean inputs would cause codegen to generate syntactically invalid Java code that does not compile, triggering errors like ``` java.util.concurrent.ExecutionException: org.codehaus.commons.compiler.CompileException: File 'generated.java', Line 41, Column 11: Failed to compile: org.codehaus.commons.compiler.CompileException: File 'generated.java', Line 41, Column 11: Unexpected token "if" in primary ``` Even though this code has test cases in `bitwise.sql` via the query test framework, those existing test cases were insufficient to find this problem: I believe that is because the example queries were constant-folded using the interpreted path, leaving the codegen path without test coverage. This PR fixes the codegen issue and adds explicit expression tests to ensure that the same tests run on both the codegen and interpreted paths. ### Why are the changes needed? Fix a rare codegen to interpreted fallback issue, which may harm query performance. ### Does this PR introduce _any_ user-facing change? No. ### How was this patch tested? Added new test cases to BitwiseExpressionsSuite.scala, copied from the existing `bitwise.sql` query test case file. ### Was this patch authored or co-authored using generative AI tooling? No. Closes apache#46382 from JoshRosen/SPARK-48128-bit_count_codegen. Authored-by: Josh Rosen <[email protected]> Signed-off-by: Dongjoon Hyun <[email protected]>
turboFei
pushed a commit
to turboFei/spark
that referenced
this pull request
Nov 6, 2025
…en syntax error for boolean type inputs (apache#388) ### What changes were proposed in this pull request? This PR fixes an issue where `BitwiseCount` / `bit_count` of boolean inputs would cause codegen to generate syntactically invalid Java code that does not compile, triggering errors like ``` java.util.concurrent.ExecutionException: org.codehaus.commons.compiler.CompileException: File 'generated.java', Line 41, Column 11: Failed to compile: org.codehaus.commons.compiler.CompileException: File 'generated.java', Line 41, Column 11: Unexpected token "if" in primary ``` Even though this code has test cases in `bitwise.sql` via the query test framework, those existing test cases were insufficient to find this problem: I believe that is because the example queries were constant-folded using the interpreted path, leaving the codegen path without test coverage. This PR fixes the codegen issue and adds explicit expression tests to ensure that the same tests run on both the codegen and interpreted paths. ### Why are the changes needed? Fix a rare codegen to interpreted fallback issue, which may harm query performance. ### Does this PR introduce _any_ user-facing change? No. ### How was this patch tested? Added new test cases to BitwiseExpressionsSuite.scala, copied from the existing `bitwise.sql` query test case file. ### Was this patch authored or co-authored using generative AI tooling? No. Closes apache#46382 from JoshRosen/SPARK-48128-bit_count_codegen. Authored-by: Josh Rosen <[email protected]> (cherry picked from commit 96f65c9) Signed-off-by: Dongjoon Hyun <[email protected]> Co-authored-by: Josh Rosen <[email protected]>
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?
This PR fixes an issue where
BitwiseCount/bit_countof boolean inputs would cause codegen to generate syntactically invalid Java code that does not compile, triggering errors likeEven though this code has test cases in
bitwise.sqlvia the query test framework, those existing test cases were insufficient to find this problem: I believe that is because the example queries were constant-folded using the interpreted path, leaving the codegen path without test coverage.This PR fixes the codegen issue and adds explicit expression tests to ensure that the same tests run on both the codegen and interpreted paths.
Why are the changes needed?
Fix a rare codegen to interpreted fallback issue, which may harm query performance.
Does this PR introduce any user-facing change?
No.
How was this patch tested?
Added new test cases to BitwiseExpressionsSuite.scala, copied from the existing
bitwise.sqlquery test case file.Was this patch authored or co-authored using generative AI tooling?
No.