ivan-kiselev commented on issue #27946:
URL: https://github.com/apache/datafusion/issues/27946#issuecomment-7349919992

   > We should check if this also impacts CSE and other optimizers.
   
   @adriangb yep.
   ```sql
   SET datafusion.execution.target_partitions = 1;
   CREATE TABLE t AS SELECT column1 AS id, column2 AS s, column3 AS x
   FROM VALUES (1, {value: 100}, 'ab'), (2, {value: 200}, 'Cd');
   
   -- CSE: adding a repeated expression changes the observed name.
   SET datafusion.optimizer.enable_leaf_expression_pushdown = false;
   SELECT arrow_field(upper(x))['name'] AS seen FROM t;
   SELECT arrow_field(upper(x))['name'] AS seen, upper(x) AS computed FROM t;
   
   -- Logical extraction: toggling the rule changes which rows survive.
   SET datafusion.optimizer.enable_leaf_expression_pushdown = true;
   SELECT id FROM t WHERE arrow_field(s['value'])['name'] = 'value';
   SET datafusion.optimizer.enable_leaf_expression_pushdown = false;
   SELECT id FROM t WHERE arrow_field(s['value'])['name'] = 'value';
   
   ```
   ```bash
   cargo run --locked --profile ci -p datafusion-cli -- \
     --data-path "$(mktemp -d)" \
     --file "repro.sql"
   
   
   +-------+
   | seen  |
   +-------+
   | upper |
   | upper |
   +-------+
   
   +-----------------+----------+
   | seen            | computed |
   +-----------------+----------+
   | __common_expr_1 | AB       |
   | __common_expr_1 | CD       |
   +-----------------+----------+
   
   +----+
   | id |
   +----+
   
   +----+
   | id |
   +----+
   | 1  |
   | 2  |
   +----+
   ```
   


-- 
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