kosiew commented on code in PR #26969:
URL: https://github.com/apache/datafusion/pull/26969#discussion_r4731650050


##########
datafusion/optimizer/src/extract_leaf_expressions.rs:
##########
@@ -1049,8 +1141,23 @@ fn split_and_push_projection(
             recovery_exprs.push(expr.clone());
             proj_exprs_captured += 1;
         } else if let Expr::Alias(alias) = expr
-            && alias.name.starts_with(EXTRACTED_EXPR_PREFIX)
+            && is_extracted_alias(alias)
         {
+            if input_schema.has_column_with_unqualified_name(&alias.name) {
+                let transformed = routing_extract(

Review Comment:
   eg this fails:
   ```
   SET datafusion.optimizer.enable_leaf_expression_pushdown = true;
   
   CREATE TABLE review_wrap_input AS
   SELECT column1 AS __datafusion_extracted_manual, column2 AS s,
          column3 AS "__datafusion_extracted_18446744073709551615"
   FROM VALUES (0, {a: 1}, 1), (1, {a: 2}, 1), (2, {a: 3}, 0);
   
   SELECT q.s['a'] AS __datafusion_extracted_manual,
          1 AS "__datafusion_extracted_18446744073709551614"
   FROM (
       SELECT __datafusion_extracted_manual, s
       FROM review_wrap_input
       WHERE "__datafusion_extracted_18446744073709551615" > 0
       LIMIT 100
   ) AS q
   WHERE q.__datafusion_extracted_manual > 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]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to