haohuaijin commented on code in PR #8833:
URL: https://github.com/apache/arrow-datafusion/pull/8833#discussion_r1448872624
##########
datafusion/optimizer/src/common_subexpr_eliminate.rs:
##########
@@ -614,7 +613,12 @@ impl ExprIdentifierVisitor<'_> {
impl TreeNodeVisitor for ExprIdentifierVisitor<'_> {
type N = Expr;
- fn pre_visit(&mut self, _expr: &Expr) -> Result<VisitRecursion> {
+ fn pre_visit(&mut self, expr: &Expr) -> Result<VisitRecursion> {
+ // related to https://github.com/apache/arrow-datafusion/issues/8814
+ // If the expr contain volatile expression or is a case expression,
skip it.
+ if matches!(expr, Expr::Case(..)) || is_volatile_expression(expr)? {
Review Comment:
Check volatile expression is this place is because the previous method only
can deal with a single `random()` function, the below query wil return true in
main branch
```
SELECT r FROM (SELECT r1 == r2 r, r1, r2 FROM (SELECT random()+1 r1,
random()+1 r2) WHERE r1 > 0 AND r2 > 0)
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]