-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Closed
Labels
enhancementNew feature or requestNew feature or request
Description
Is your feature request related to a problem or challenge?
Consider the following case:
let ctx = SessionContext::new();
ctx.sql("create table t1 (a int, b int)").await?;
ctx.sql("insert into t1 values (1, 2), (3, 4)").await?;
let plan = ctx.sql(r#"select s1.a from (select s1.a, s1.b from (select a, b from t1) s1) s1"#).await?.into_optimized_plan()?;
println!("optimized plan: {plan}");
let unparse = plan_to_sql(&plan)?.to_string();
println!("{}", format!("Unparsed SQL: {}", unparse));The output result is
Optimized plan: SubqueryAlias: s1
SubqueryAlias: s1
TableScan: t1 projection=[a]
Unparsed SQL: SELECT * FROM t1 AS s1
The unparsing isn't equal to the original SQL. I think it should be
select s1.a from t1 as s1
Describe the solution you'd like
Handle the pushdown projection at Unparser:select_to_sql_recursively
datafusion/datafusion/sql/src/unparser/plan.rs
Lines 240 to 243 in 23ccca9
| LogicalPlan::TableScan(scan) => { | |
| let mut builder = TableRelationBuilder::default(); | |
| let mut table_parts = vec![]; | |
| if let Some(catalog_name) = scan.table_name.catalog() { |
Describe alternatives you've considered
No response
Additional context
No response
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request