You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "haohuaijin (via GitHub)" <gi...@apache.org> on 2023/10/23 09:48:52 UTC

[PR] fix: don't push down volatile predicates in projection [arrow-datafusion]

haohuaijin opened a new pull request, #7909:
URL: https://github.com/apache/arrow-datafusion/pull/7909

   ## Which issue does this PR close?
   
   <!--
   We generally require a GitHub issue to be filed for all bug fixes and enhancements and this helps us generate change logs for our releases. You can link an issue to this PR using the GitHub syntax. For example `Closes #123` indicates that this PR will close issue #123.
   -->
   
   related to #7876 
   
   ## Rationale for this change
   
   As @jonahgao said, 
   
   > Pushing `random` through the projection can also cause problems.
   > If it can be fixed, then `random` will not be pushed further through the aggregatation in this case.
   
   Previously, projection pushed down all predicates. Now, projection pushes down predicates that do not contain volatile functions or contain volatile functions but are not included in projection.
   
   For example,
   ```sql
   SELECT t.c1, t.r FROM (SELECT c1, random() AS r FROM test GROUP BY c1) as t WHERE t.r > 0.5 AND random() > 0.8 AND t.c1 > 5;
   ```
   initial logical plan
   ```
   +------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------+
   | initial_logical_plan                                       | Projection: t.c1, t.r                                                                                                     |
   |                                                            |   Filter: t.r > Float64(0.5) AND random() > Float64(0.8) AND t.c1 > Int64(5)                                              |
   |                                                            |     SubqueryAlias: t                                                                                                      |
   |                                                            |       Projection: test.csv.c1, random() AS r                                                                              |
   |                                                            |         Aggregate: groupBy=[[test.csv.c1]], aggr=[[]]                                                                     |
   |                                                            |           TableScan: test.csv       
   ```
   
   before this pr
   ```
   | logical_plan  | SubqueryAlias: t                                                                                                                                                 |
   |               |   Projection: aggregate_test_100.c1, random() AS r                                                                                                               |
   |               |     Aggregate: groupBy=[[aggregate_test_100.c1]], aggr=[[]]                                                                                                      |
   |               |       Projection: aggregate_test_100.c1                                                                                                                          |
   |               |         Filter: random() > Float64(0.5) AND random() > Float64(0.8) AND aggregate_test_100.c1 > Utf8("5")                                                        |
   |               |           Projection: random(), aggregate_test_100.c1                                                                                                            |
   |               |             TableScan: aggregate_test_100 projection=[c1], partial_filters=[random() > Float64(0.5), random() > Float64(0.8), aggregate_test_100.c1 > Utf8("5")] |
   ```
   
   after this pr
   ```
   | logical_plan  | SubqueryAlias: t                                                                                                                                      |
   |               |   Filter: r > Float64(0.5)                                                                                                                            |
   |               |     Projection: aggregate_test_100.c1, random() AS r                                                                                                  |
   |               |       Aggregate: groupBy=[[aggregate_test_100.c1]], aggr=[[]]                                                                                         |
   |               |         Filter: random() > Float64(0.8) AND aggregate_test_100.c1 > Utf8("5")                                                                         |
   |               |           TableScan: aggregate_test_100 projection=[c1], partial_filters=[random() > Float64(0.8), aggregate_test_100.c1 > Utf8("5")] 
   ```
   
   ## What changes are included in this PR?
   
   <!--
   There is no need to duplicate the description in the issue here but it is sometimes worth providing a summary of the individual changes in this PR.
   -->
   modify `push_down_filter` to support only push down  predicates that do not contain volatile functions or contain volatile functions but are not included in projection.
   
   ## Are these changes tested?
   
   <!--
   We typically require tests for all PRs in order to:
   1. Prevent the code from being accidentally broken by subsequent changes
   2. Serve as another way to document the expected behavior of the code
   
   If tests are not included in your PR, please explain why (for example, are they covered by existing tests)?
   -->
   Yes, if need, I can add more.
   ## Are there any user-facing changes?
   
   <!--
   If there are user-facing changes then we may require documentation to be updated before approving the PR.
   -->
   
   <!--
   If there are any breaking changes to public APIs, please add the `api change` label.
   -->


-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] fix: don't push down volatile predicates in projection [arrow-datafusion]

Posted by "jonahgao (via GitHub)" <gi...@apache.org>.
jonahgao commented on code in PR #7909:
URL: https://github.com/apache/arrow-datafusion/pull/7909#discussion_r1369777220


##########
datafusion/optimizer/src/push_down_filter.rs:
##########
@@ -652,32 +653,60 @@ impl OptimizerRule for PushDownFilter {
                 child_plan.with_new_inputs(&[new_filter])?
             }
             LogicalPlan::Projection(projection) => {
-                // A projection is filter-commutable, but re-writes all predicate expressions
+                // A projection is filter-commutable if it do not contain volatile predicates or contain volatile
+                // predicates that are not used in the filter. However, we should re-writes all predicate expressions.
                 // collect projection.
-                let replace_map = projection
-                    .schema
-                    .fields()
-                    .iter()
-                    .enumerate()
-                    .map(|(i, field)| {
-                        // strip alias, as they should not be part of filters
-                        let expr = match &projection.expr[i] {
-                            Expr::Alias(Alias { expr, .. }) => expr.as_ref().clone(),
-                            expr => expr.clone(),
-                        };
-
-                        (field.qualified_name(), expr)
-                    })
-                    .collect::<HashMap<_, _>>();
+                let (volatile_map, non_volatile_map): (HashMap<_, _>, HashMap<_, _>) =
+                    projection
+                        .schema
+                        .fields()
+                        .iter()
+                        .enumerate()
+                        .map(|(i, field)| {
+                            // strip alias, as they should not be part of filters
+                            let expr = match &projection.expr[i] {
+                                Expr::Alias(Alias { expr, .. }) => expr.as_ref().clone(),
+                                expr => expr.clone(),
+                            };
+
+                            (field.qualified_name(), expr)
+                        })
+                        .partition(|(_, value)| is_volatile_expression(value.clone()));
 
-                // re-write all filters based on this projection
-                // E.g. in `Filter: b\n  Projection: a > 1 as b`, we can swap them, but the filter must be "a > 1"
-                let new_filter = LogicalPlan::Filter(Filter::try_new(
-                    replace_cols_by_name(filter.predicate.clone(), &replace_map)?,
-                    projection.input.clone(),
-                )?);
+                let mut push_predicates = vec![];
+                let mut keep_predicates = vec![];
+                for expr in split_conjunction_owned(filter.predicate.clone()).into_iter()
+                {
+                    if contain(expr.clone(), &volatile_map) {

Review Comment:
   ```suggestion
                       if contain(&expr, &volatile_map) {
   ```
   Remove `clone`.



-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] fix: don't push down volatile predicates in projection [arrow-datafusion]

Posted by "jonahgao (via GitHub)" <gi...@apache.org>.
jonahgao commented on code in PR #7909:
URL: https://github.com/apache/arrow-datafusion/pull/7909#discussion_r1369762989


##########
datafusion/optimizer/src/push_down_filter.rs:
##########
@@ -881,6 +910,42 @@ pub fn replace_cols_by_name(
     })
 }
 
+/// check whether the expression is volatile predicates
+pub fn is_volatile_expression(e: Expr) -> bool {

Review Comment:
   ```suggestion
   fn is_volatile_expression(e: &Expr) -> bool {
   ```
   - We can pass the argument `e` by reference.
   - I would suggest setting the visibility of this function to `private` since it is only being used within this file.
   



-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] fix: don't push down volatile predicates in projection [arrow-datafusion]

Posted by "jonahgao (via GitHub)" <gi...@apache.org>.
jonahgao commented on PR #7909:
URL: https://github.com/apache/arrow-datafusion/pull/7909#issuecomment-1776749872

   Thank you @haohuaijin. I have suggested some changes about clone. Everything else looks good to me.


-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] fix: don't push down volatile predicates in projection [arrow-datafusion]

Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb commented on code in PR #7909:
URL: https://github.com/apache/arrow-datafusion/pull/7909#discussion_r1369229798


##########
datafusion/optimizer/src/push_down_filter.rs:
##########
@@ -668,16 +670,40 @@ impl OptimizerRule for PushDownFilter {
 
                         (field.qualified_name(), expr)
                     })
-                    .collect::<HashMap<_, _>>();
+                    .partition(|(_, value)| matches!(value, Expr::ScalarFunction(f) if f.fun.volatility() == Volatility::Volatile));
 
-                // re-write all filters based on this projection
-                // E.g. in `Filter: b\n  Projection: a > 1 as b`, we can swap them, but the filter must be "a > 1"
-                let new_filter = LogicalPlan::Filter(Filter::try_new(
-                    replace_cols_by_name(filter.predicate.clone(), &replace_map)?,
-                    projection.input.clone(),
-                )?);
+                let mut push_predicates = vec![];
+                let mut keep_predicates = vec![];
+                for expr in split_conjunction_owned(filter.predicate.clone()).into_iter()
+                {
+                    if contain(expr.clone(), &volatile_map.clone())? {

Review Comment:
   I don't think we need to clone here:
   
   ```suggestion
                       if contain(expr.clone(), volatile_map)? {
   ```



##########
datafusion/optimizer/src/push_down_filter.rs:
##########
@@ -668,16 +670,40 @@ impl OptimizerRule for PushDownFilter {
 
                         (field.qualified_name(), expr)
                     })
-                    .collect::<HashMap<_, _>>();
+                    .partition(|(_, value)| matches!(value, Expr::ScalarFunction(f) if f.fun.volatility() == Volatility::Volatile));
 
-                // re-write all filters based on this projection
-                // E.g. in `Filter: b\n  Projection: a > 1 as b`, we can swap them, but the filter must be "a > 1"
-                let new_filter = LogicalPlan::Filter(Filter::try_new(
-                    replace_cols_by_name(filter.predicate.clone(), &replace_map)?,
-                    projection.input.clone(),
-                )?);
+                let mut push_predicates = vec![];
+                let mut keep_predicates = vec![];
+                for expr in split_conjunction_owned(filter.predicate.clone()).into_iter()
+                {
+                    if contain(expr.clone(), &volatile_map.clone())? {
+                        keep_predicates.push(expr);
+                    } else {
+                        push_predicates.push(expr);
+                    }
+                }
 
-                child_plan.with_new_inputs(&[new_filter])?
+                match conjunction(push_predicates) {
+                    Some(expr) => {
+                        // re-write all filters based on this projection
+                        // E.g. in `Filter: b\n  Projection: a > 1 as b`, we can swap them, but the filter must be "a > 1"
+                        let new_filter = LogicalPlan::Filter(Filter::try_new(
+                            replace_cols_by_name(expr, &non_volatile_map)?,
+                            projection.input.clone(),
+                        )?);
+
+                        if keep_predicates.is_empty() {
+                            child_plan.with_new_inputs(&[new_filter])?
+                        } else {
+                            let child_plan = child_plan.with_new_inputs(&[new_filter])?;
+                            LogicalPlan::Filter(Filter::try_new(
+                                conjunction(keep_predicates).unwrap(),
+                                Arc::new(child_plan),
+                            )?)
+                        }

Review Comment:
   You maybe could avoid the unwrap with something like this instead:
   
   ```suggestion
                           match conjunction(keep_predicates) {
                             None =>  child_plan.with_new_inputs(&[new_filter])?
                             Some(keep_predicate) => {
                               let child_plan = child_plan.with_new_inputs(&[new_filter])?;
                               LogicalPlan::Filter(Filter::try_new(
                                   keep_predicate
                                   Arc::new(child_plan),
                               )?)
                           }
   ```



##########
datafusion/optimizer/src/push_down_filter.rs:
##########
@@ -881,6 +907,25 @@ pub fn replace_cols_by_name(
     })
 }
 
+/// check whether the expression uses the columns in `check_map`.
+pub fn contain(e: Expr, check_map: &HashMap<String, Expr>) -> Result<bool> {
+    let mut is_contain = false;
+    e.apply(&mut |expr| {
+        Ok(if let Expr::Column(c) = &expr {
+            match check_map.get(&c.flat_name()) {
+                Some(_) => {
+                    is_contain = true;
+                    VisitRecursion::Stop
+                }
+                None => VisitRecursion::Continue,
+            }
+        } else {
+            VisitRecursion::Continue
+        })
+    })?;

Review Comment:
   Since the closure always returns `Ok` you could change this to `unwrap()` if you wanted and have `contain` return `bool` instead of `Result<bool>`



##########
datafusion/optimizer/src/push_down_filter.rs:
##########
@@ -2712,4 +2757,75 @@ Projection: a, b
         \n    TableScan: test2";
         assert_optimized_plan_eq(&plan, expected)
     }
+
+    #[test]
+    fn test_push_down_volatile_function_in_aggregate() -> Result<()> {
+        // SELECT t.a, t.r FROM (SELECT a, SUM(b), random() AS r FROM test1 GROUP BY a) AS t WHERE t.a > 5 AND t.r > 0.5;
+        let table_scan = test_table_scan_with_name("test1")?;
+        let plan = LogicalPlanBuilder::from(table_scan)
+            .aggregate(vec![col("a")], vec![sum(col("b"))])?
+            .project(vec![col("a"), sum(col("b")), random().alias("r")])?

Review Comment:
   I think it is important to test the expression like `random() + 1` rather than just `random()` for the reasons I listed above
   ```suggestion
               .project(vec![col("a"), sum(col("b")), random().add(lit(1)).alias("r")])?
   ```



##########
datafusion/optimizer/src/push_down_filter.rs:
##########
@@ -668,16 +670,40 @@ impl OptimizerRule for PushDownFilter {
 
                         (field.qualified_name(), expr)
                     })
-                    .collect::<HashMap<_, _>>();
+                    .partition(|(_, value)| matches!(value, Expr::ScalarFunction(f) if f.fun.volatility() == Volatility::Volatile));

Review Comment:
   I don't think this will work for expressions that have random
   
   It will find expressions like `random()` but not expressions like `random() + 1,`  
   
   To do so I think you need to write a function (perhaps via `expr.apply()` that looks for volatile expressions recursively



-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] fix: don't push down volatile predicates in projection [arrow-datafusion]

Posted by "haohuaijin (via GitHub)" <gi...@apache.org>.
haohuaijin commented on code in PR #7909:
URL: https://github.com/apache/arrow-datafusion/pull/7909#discussion_r1369565622


##########
datafusion/optimizer/src/push_down_filter.rs:
##########
@@ -668,16 +670,40 @@ impl OptimizerRule for PushDownFilter {
 
                         (field.qualified_name(), expr)
                     })
-                    .collect::<HashMap<_, _>>();
+                    .partition(|(_, value)| matches!(value, Expr::ScalarFunction(f) if f.fun.volatility() == Volatility::Volatile));

Review Comment:
   you are right, already fix, thanks!



-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] fix: don't push down volatile predicates in projection [arrow-datafusion]

Posted by "jonahgao (via GitHub)" <gi...@apache.org>.
jonahgao commented on code in PR #7909:
URL: https://github.com/apache/arrow-datafusion/pull/7909#discussion_r1369776116


##########
datafusion/optimizer/src/push_down_filter.rs:
##########
@@ -881,6 +910,42 @@ pub fn replace_cols_by_name(
     })
 }
 
+/// check whether the expression is volatile predicates
+pub fn is_volatile_expression(e: Expr) -> bool {
+    let mut is_volatile = false;
+    e.apply(&mut |expr| {
+        Ok(match expr {
+            Expr::ScalarFunction(f) if f.fun.volatility() == Volatility::Volatile => {
+                is_volatile = true;
+                VisitRecursion::Stop
+            }
+            _ => VisitRecursion::Continue,
+        })
+    })
+    .unwrap();
+    is_volatile
+}
+
+/// check whether the expression uses the columns in `check_map`.
+pub fn contain(e: Expr, check_map: &HashMap<String, Expr>) -> bool {

Review Comment:
   ```suggestion
   fn contain(e: &Expr, check_map: &HashMap<String, Expr>) -> bool {
   ```
   Similar to the function `is_volatile_expression`.



-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] fix: don't push down volatile predicates in projection [arrow-datafusion]

Posted by "haohuaijin (via GitHub)" <gi...@apache.org>.
haohuaijin commented on PR #7909:
URL: https://github.com/apache/arrow-datafusion/pull/7909#issuecomment-1774826765

   cc @jonahgao @alamb 


-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] fix: don't push down volatile predicates in projection [arrow-datafusion]

Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb merged PR #7909:
URL: https://github.com/apache/arrow-datafusion/pull/7909


-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] fix: don't push down volatile predicates in projection [arrow-datafusion]

Posted by "jonahgao (via GitHub)" <gi...@apache.org>.
jonahgao commented on code in PR #7909:
URL: https://github.com/apache/arrow-datafusion/pull/7909#discussion_r1369772035


##########
datafusion/optimizer/src/push_down_filter.rs:
##########
@@ -652,32 +653,60 @@ impl OptimizerRule for PushDownFilter {
                 child_plan.with_new_inputs(&[new_filter])?
             }
             LogicalPlan::Projection(projection) => {
-                // A projection is filter-commutable, but re-writes all predicate expressions
+                // A projection is filter-commutable if it do not contain volatile predicates or contain volatile
+                // predicates that are not used in the filter. However, we should re-writes all predicate expressions.
                 // collect projection.
-                let replace_map = projection
-                    .schema
-                    .fields()
-                    .iter()
-                    .enumerate()
-                    .map(|(i, field)| {
-                        // strip alias, as they should not be part of filters
-                        let expr = match &projection.expr[i] {
-                            Expr::Alias(Alias { expr, .. }) => expr.as_ref().clone(),
-                            expr => expr.clone(),
-                        };
-
-                        (field.qualified_name(), expr)
-                    })
-                    .collect::<HashMap<_, _>>();
+                let (volatile_map, non_volatile_map): (HashMap<_, _>, HashMap<_, _>) =
+                    projection
+                        .schema
+                        .fields()
+                        .iter()
+                        .enumerate()
+                        .map(|(i, field)| {
+                            // strip alias, as they should not be part of filters
+                            let expr = match &projection.expr[i] {
+                                Expr::Alias(Alias { expr, .. }) => expr.as_ref().clone(),
+                                expr => expr.clone(),
+                            };
+
+                            (field.qualified_name(), expr)
+                        })
+                        .partition(|(_, value)| is_volatile_expression(value.clone()));

Review Comment:
   ```suggestion
                           .partition(|(_, value)| is_volatile_expression(value));
   ```
   If the parameter is passed by reference, the `clone` can be removed.



-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] fix: don't push down volatile predicates in projection [arrow-datafusion]

Posted by "jonahgao (via GitHub)" <gi...@apache.org>.
jonahgao commented on code in PR #7909:
URL: https://github.com/apache/arrow-datafusion/pull/7909#discussion_r1369772035


##########
datafusion/optimizer/src/push_down_filter.rs:
##########
@@ -652,32 +653,60 @@ impl OptimizerRule for PushDownFilter {
                 child_plan.with_new_inputs(&[new_filter])?
             }
             LogicalPlan::Projection(projection) => {
-                // A projection is filter-commutable, but re-writes all predicate expressions
+                // A projection is filter-commutable if it do not contain volatile predicates or contain volatile
+                // predicates that are not used in the filter. However, we should re-writes all predicate expressions.
                 // collect projection.
-                let replace_map = projection
-                    .schema
-                    .fields()
-                    .iter()
-                    .enumerate()
-                    .map(|(i, field)| {
-                        // strip alias, as they should not be part of filters
-                        let expr = match &projection.expr[i] {
-                            Expr::Alias(Alias { expr, .. }) => expr.as_ref().clone(),
-                            expr => expr.clone(),
-                        };
-
-                        (field.qualified_name(), expr)
-                    })
-                    .collect::<HashMap<_, _>>();
+                let (volatile_map, non_volatile_map): (HashMap<_, _>, HashMap<_, _>) =
+                    projection
+                        .schema
+                        .fields()
+                        .iter()
+                        .enumerate()
+                        .map(|(i, field)| {
+                            // strip alias, as they should not be part of filters
+                            let expr = match &projection.expr[i] {
+                                Expr::Alias(Alias { expr, .. }) => expr.as_ref().clone(),
+                                expr => expr.clone(),
+                            };
+
+                            (field.qualified_name(), expr)
+                        })
+                        .partition(|(_, value)| is_volatile_expression(value.clone()));

Review Comment:
   ```suggestion
                           .partition(|(_, value)| is_volatile_expression(value));
   ```
   f the parameters is passed by reference, the `clone` can be removed.



##########
datafusion/optimizer/src/push_down_filter.rs:
##########
@@ -652,32 +653,60 @@ impl OptimizerRule for PushDownFilter {
                 child_plan.with_new_inputs(&[new_filter])?
             }
             LogicalPlan::Projection(projection) => {
-                // A projection is filter-commutable, but re-writes all predicate expressions
+                // A projection is filter-commutable if it do not contain volatile predicates or contain volatile
+                // predicates that are not used in the filter. However, we should re-writes all predicate expressions.
                 // collect projection.
-                let replace_map = projection
-                    .schema
-                    .fields()
-                    .iter()
-                    .enumerate()
-                    .map(|(i, field)| {
-                        // strip alias, as they should not be part of filters
-                        let expr = match &projection.expr[i] {
-                            Expr::Alias(Alias { expr, .. }) => expr.as_ref().clone(),
-                            expr => expr.clone(),
-                        };
-
-                        (field.qualified_name(), expr)
-                    })
-                    .collect::<HashMap<_, _>>();
+                let (volatile_map, non_volatile_map): (HashMap<_, _>, HashMap<_, _>) =
+                    projection
+                        .schema
+                        .fields()
+                        .iter()
+                        .enumerate()
+                        .map(|(i, field)| {
+                            // strip alias, as they should not be part of filters
+                            let expr = match &projection.expr[i] {
+                                Expr::Alias(Alias { expr, .. }) => expr.as_ref().clone(),
+                                expr => expr.clone(),
+                            };
+
+                            (field.qualified_name(), expr)
+                        })
+                        .partition(|(_, value)| is_volatile_expression(value.clone()));

Review Comment:
   ```suggestion
                           .partition(|(_, value)| is_volatile_expression(value));
   ```
   If the parameters is passed by reference, the `clone` can be removed.



-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org