-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-33861][SQL][FOLLOWUP] Simplify conditional in predicate should consider deterministic #31067
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
Conversation
| CaseWhen(Seq((UnresolvedAttribute("i") > Rand(0), FalseLiteral))) | ||
| val expectedCond = And(UnresolvedAttribute("i") > Rand(0), FalseLiteral) | ||
| // nondeterministic expressions are only allowed in Project, Filter, Aggregate or Window, | ||
| testFilter(originalCond, expectedCond = FalseLiteral) |
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.
expectedCond = FalseLiteral cause by
spark/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/optimizer/expressions.scala
Lines 295 to 298 in 26d8df3
| case FalseLiteral And _ => FalseLiteral | |
| case _ And FalseLiteral => FalseLiteral | |
| case TrueLiteral Or _ => TrueLiteral | |
| case _ Or TrueLiteral => TrueLiteral |
| Or(Not(cond), trueValue) | ||
| case CaseWhen(Seq((_, FalseLiteral)), Some(FalseLiteral) | None) => | ||
| FalseLiteral | ||
| case CaseWhen(Seq((cond, FalseLiteral)), Some(elseValue)) => |
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.
This case has handled by
Lines 62 to 64 in 3ceffeb
| case CaseWhen(Seq((cond, trueValue)), | |
| Some(FalseLiteral) | Some(Literal(null, BooleanType)) | None) => | |
| And(cond, trueValue) |
| case CaseWhen(Seq((cond, TrueLiteral)), Some(FalseLiteral) | None) => | ||
| cond |
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.
This case has handled by
Lines 62 to 64 in 3ceffeb
| case CaseWhen(Seq((cond, trueValue)), | |
| Some(FalseLiteral) | Some(Literal(null, BooleanType)) | None) => | |
| And(cond, trueValue) |
| And(cond, trueValue) | ||
| case CaseWhen(Seq((cond, trueValue)), Some(TrueLiteral)) => | ||
| Or(Not(cond), trueValue) | ||
| case CaseWhen(Seq((_, FalseLiteral)), Some(FalseLiteral) | None) => |
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.
can we update the classdoc of this rule?
|
Kubernetes integration test starting |
|
Kubernetes integration test status success |
|
Kubernetes integration test starting |
|
Test build #133749 has finished for PR 31067 at commit
|
|
Kubernetes integration test status success |
|
Test build #133740 has finished for PR 31067 at commit
|
HyukjinKwon
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.
LGTM thanks for handling this
|
Merged to master. |
What changes were proposed in this pull request?
This pr address #30865 (review) to fix simplify conditional in predicate should consider deterministic.
Why are the changes needed?
Fix bug.
Does this PR introduce any user-facing change?
No.
How was this patch tested?
Unit test.