-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unparse SubqueryAlias
without projections to SQL
#12896
Changes from 5 commits
813326b
5073d55
d6c7f70
7ec80c2
86f2c91
692239c
5a178aa
8f727cd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -666,6 +666,48 @@ where | |
assert_eq!(roundtrip_statement.to_string(), expect); | ||
} | ||
|
||
#[test] | ||
fn test_table_scan_alias() -> Result<()> { | ||
let schema = Schema::new(vec![ | ||
Field::new("id", DataType::Utf8, false), | ||
Field::new("age", DataType::Utf8, false), | ||
]); | ||
|
||
let plan = table_scan(Some("t1"), &schema, None)? | ||
.project(vec![col("id")])? | ||
.alias("a")? | ||
.build()?; | ||
let sql = plan_to_sql(&plan)?; | ||
assert_eq!( | ||
format!("{}", sql), | ||
"SELECT * FROM (SELECT t1.id FROM t1) AS a" | ||
); | ||
|
||
let plan = table_scan(Some("t1"), &schema, None)? | ||
.project(vec![col("id")])? | ||
.alias("a")? | ||
.build()?; | ||
|
||
let sql = plan_to_sql(&plan)?; | ||
assert_eq!( | ||
format!("{}", sql), | ||
"SELECT * FROM (SELECT t1.id FROM t1) AS a" | ||
); | ||
|
||
let plan = table_scan(Some("t1"), &schema, None)? | ||
.filter(col("id").gt(lit(5)))? | ||
.project(vec![col("id")])? | ||
.alias("a")? | ||
.build()?; | ||
println!("{}", plan.display_indent()); | ||
let sql = plan_to_sql(&plan)?; | ||
assert_eq!( | ||
format!("{}", sql), | ||
"SELECT * FROM (SELECT t1.id FROM t1 WHERE (t1.id > 5)) AS a" | ||
); | ||
Ok(()) | ||
} | ||
|
||
#[test] | ||
fn test_table_scan_pushdown() -> Result<()> { | ||
let schema = Schema::new(vec![ | ||
|
@@ -697,7 +739,7 @@ fn test_table_scan_pushdown() -> Result<()> { | |
plan_to_sql(&table_scan_with_projection_alias)?; | ||
assert_eq!( | ||
format!("{}", table_scan_with_projection_alias), | ||
"SELECT ta.id, ta.age FROM t1 AS ta" | ||
"SELECT * FROM (SELECT ta.id, ta.age FROM t1 AS ta) AS ta" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That's not an improvement, right? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks @findepi. Sorry for replying so late 🙇 |
||
); | ||
|
||
let table_scan_with_projection_alias = | ||
|
@@ -708,7 +750,7 @@ fn test_table_scan_pushdown() -> Result<()> { | |
plan_to_sql(&table_scan_with_projection_alias)?; | ||
assert_eq!( | ||
format!("{}", table_scan_with_projection_alias), | ||
"SELECT ta.age FROM t1 AS ta" | ||
"SELECT * FROM (SELECT ta.age FROM t1 AS ta) AS ta" | ||
); | ||
|
||
let table_scan_with_no_projection_alias = table_scan(Some("t1"), &schema, None)? | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
left over?