Repository navigation
fix: [branch-1.2] evaluate the right operand of AND, OR and IN only for rows the left side has not decided (#7326) - #7648
Merged
Conversation
…eft side has not decided (apache#7326) * fix: evaluate the right operand of AND, OR and IN only for rows the left side has not decided * refactor: share masked evaluation with NullShortCircuit and build AND/OR in spark_comparison * bench: add micro-benchmarks for lazy AND, OR and IN * perf: try the right operand over the whole batch when most rows need it, and keep runs of IN candidates as one IN * fix: keep an expensive IN value out of the lazy rewrite and build the OR tree balanced (cherry picked from commit 7deeba2)
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?
Backport of #7326 to
branch-1.2. Closes #6823 on this branch.Rationale for this change
Spark evaluates
AND,ORand the candidates ofINlazily: a later operand runs only for the rows that the earlier ones have not decided. Comet evaluates every operand over the whole batch, so under ANSI mode an operand that can raise throws on a row Spark never evaluates, for examplev != 0 AND 100 / v > 1,v = 0 OR 100 / v > 1andv IN (0, 100 / v)raiseDIVIDE_BY_ZEROin Comet and return rows in Spark.branch-1.2has the same eager native evaluation. See #7326 and #6823 for the full analysis.What changes are included in this PR?
Cherry-pick of 7deeba2 (
git cherry-pick -x) with no conflicts and no adaptations. It addsLazyLogicalandlazy_in_listinnative/spark-expr, the small changes tocase_when.rs,null_short_circuit.rsandnested_comparison.rsthat they share, thelazy_logicalbenchmark, and theexpressions/conditional/logical_lazy_ansi.sqlfile test.Other release branches:
branch-1.2is the newest release branch, so there is no newer one to port to. Whetherbranch-1.1needs a backport is not part of this PR.How are these changes tested?
On this branch, with JDK 17 and the default Spark profile (4.1):
cargo check --all-targetsandcargo clippy --all-targets -D warningspass fordatafusion-comet-spark-expr,cargo fmt --checkis clean, and thedatafusion-comet-spark-exprlib tests pass (1310 tests, 0 failures, including the 11 newlazy_logicaltests).CometSqlFileTestSuitepasses forexpressions/conditional/logical_lazy_ansi.sqlagainst a native library built from this branch. Against a native library built frombranch-1.2without the fix, the same file test fails withDIVIDE_BY_ZERO, so the branch has the bug and the test catches it. I ran the default Spark profile only.