kosiew commented on code in PR #16696:
URL: https://github.com/apache/datafusion/pull/16696#discussion_r2241482599
##########
datafusion/optimizer/src/optimize_projections/mod.rs:
##########
@@ -826,6 +840,34 @@ pub fn is_projection_unnecessary(
))
}
+fn plan_contains_subquery_alias(plan: &LogicalPlan) -> bool {
+ // ambiguity of aliases can arise if there are
Review Comment:
https://github.com/kosiew/datafusion/blob/7e6ef3a77490a426c3f3416033a3dd3eb288ab59/datafusion/optimizer/src/optimize_projections/mod.rs#L353-L362
caused this slt test to fail
```
External error: 1 errors in file
/Users/kosiew/GitHub/datafusion/datafusion/sqllogictest/test_files/cte.slt
1. query failed: DataFusion error: Optimizer rule 'optimize_projections'
failed
caused by
Schema error: No field named __scalar_sq_1.prices_row_num. Did you mean
'__scalar_sq_3.prices_row_num'?.
[SQL] WITH RECURSIVE "recursive_cte" AS (
...
```
https://github.com/kosiew/datafusion/blob/a289237acc769fb787365780a51d8e8ea5be71e4/datafusion/sqllogictest/test_files/cte.slt#L408-L414
After a lot of investigation, I found that it failed because the recursive
cte has several subquery aliases.
Instead of tweaking subquery aliases for recursive ctes, I added a bypass
for recursive ctes with 2 or more subquery aliases.
https://github.com/kosiew/datafusion/blob/a289237acc769fb787365780a51d8e8ea5be71e4/datafusion/optimizer/src/optimize_projections/mod.rs#L353-L356
which enabled the slt test to pass.
I thought this was an improvement because before this change, recursive
queries were not transformed by optimize_projections at all.
--
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]