jayzhan211 commented on code in PR #15090:
URL: https://github.com/apache/datafusion/pull/15090#discussion_r1990311682
##########
datafusion/sql/tests/cases/plan_to_sql.rs:
##########
@@ -526,85 +526,79 @@ fn roundtrip_statement_with_dialect() -> Result<()> {
},
TestStatementWithDialect {
sql: "SELECT * FROM (SELECT j1_id + 1 FROM j1) AS temp_j(id2)",
- expected: r#"SELECT * FROM (SELECT (`j1`.`j1_id` + 1) AS `id2`
FROM `j1`) AS `temp_j`"#,
+ expected: r#"SELECT `temp_j`.`id2` FROM (SELECT (`j1`.`j1_id` + 1)
AS `id2` FROM `j1`) AS `temp_j`"#,
parser_dialect: Box::new(GenericDialect {}),
unparser_dialect: Box::new(SqliteDialect {}),
},
TestStatementWithDialect {
sql: "SELECT * FROM (SELECT j1_id FROM j1 LIMIT 1) AS temp_j(id2)",
- expected: r#"SELECT * FROM (SELECT `j1`.`j1_id` AS `id2` FROM `j1`
LIMIT 1) AS `temp_j`"#,
+ expected: r#"SELECT `temp_j`.`id2` FROM (SELECT `j1`.`j1_id` AS
`id2` FROM `j1` LIMIT 1) AS `temp_j`"#,
parser_dialect: Box::new(GenericDialect {}),
unparser_dialect: Box::new(SqliteDialect {}),
},
TestStatementWithDialect {
sql: "SELECT * FROM UNNEST([1,2,3])",
- expected: r#"SELECT * FROM (SELECT UNNEST([1, 2, 3]) AS
"UNNEST(make_array(Int64(1),Int64(2),Int64(3)))")"#,
+ expected: r#"SELECT
"UNNEST(make_array(Int64(1),Int64(2),Int64(3)))" FROM (SELECT UNNEST([1, 2, 3])
AS "UNNEST(make_array(Int64(1),Int64(2),Int64(3)))")"#,
parser_dialect: Box::new(GenericDialect {}),
unparser_dialect: Box::new(UnparserDefaultDialect {}),
},
TestStatementWithDialect {
sql: "SELECT * FROM UNNEST([1,2,3]) AS t1 (c1)",
- expected: r#"SELECT * FROM (SELECT UNNEST([1, 2, 3]) AS
"UNNEST(make_array(Int64(1),Int64(2),Int64(3)))") AS t1 (c1)"#,
- parser_dialect: Box::new(GenericDialect {}),
- unparser_dialect: Box::new(UnparserDefaultDialect {}),
- },
- TestStatementWithDialect {
- sql: "SELECT * FROM UNNEST([1,2,3]) AS t1 (c1)",
- expected: r#"SELECT * FROM (SELECT UNNEST([1, 2, 3]) AS
"UNNEST(make_array(Int64(1),Int64(2),Int64(3)))") AS t1 (c1)"#,
+ expected: r#"SELECT t1.c1 FROM (SELECT UNNEST([1, 2, 3]) AS
"UNNEST(make_array(Int64(1),Int64(2),Int64(3)))") AS t1 (c1)"#,
parser_dialect: Box::new(GenericDialect {}),
unparser_dialect: Box::new(UnparserDefaultDialect {}),
},
TestStatementWithDialect {
sql: "SELECT * FROM UNNEST([1,2,3]), j1",
- expected: r#"SELECT * FROM (SELECT UNNEST([1, 2, 3]) AS
"UNNEST(make_array(Int64(1),Int64(2),Int64(3)))") CROSS JOIN j1"#,
+ expected: r#"SELECT
"UNNEST(make_array(Int64(1),Int64(2),Int64(3)))", j1.j1_id, j1.j1_string FROM
(SELECT UNNEST([1, 2, 3]) AS "UNNEST(make_array(Int64(1),Int64(2),Int64(3)))")
CROSS JOIN j1"#,
parser_dialect: Box::new(GenericDialect {}),
unparser_dialect: Box::new(UnparserDefaultDialect {}),
},
TestStatementWithDialect {
sql: "SELECT * FROM UNNEST([1,2,3]) u(c1) JOIN j1 ON u.c1 =
j1.j1_id",
- expected: r#"SELECT * FROM (SELECT UNNEST([1, 2, 3]) AS
"UNNEST(make_array(Int64(1),Int64(2),Int64(3)))") AS u (c1) JOIN j1 ON (u.c1 =
j1.j1_id)"#,
+ expected: r#"SELECT u.c1, j1.j1_id, j1.j1_string FROM (SELECT
UNNEST([1, 2, 3]) AS "UNNEST(make_array(Int64(1),Int64(2),Int64(3)))") AS u
(c1) JOIN j1 ON (u.c1 = j1.j1_id)"#,
parser_dialect: Box::new(GenericDialect {}),
unparser_dialect: Box::new(UnparserDefaultDialect {}),
},
TestStatementWithDialect {
sql: "SELECT * FROM UNNEST([1,2,3]) u(c1) UNION ALL SELECT * FROM
UNNEST([4,5,6]) u(c1)",
- expected: r#"SELECT * FROM (SELECT UNNEST([1, 2, 3]) AS
"UNNEST(make_array(Int64(1),Int64(2),Int64(3)))") AS u (c1) UNION ALL SELECT *
FROM (SELECT UNNEST([4, 5, 6]) AS
"UNNEST(make_array(Int64(4),Int64(5),Int64(6)))") AS u (c1)"#,
+ expected: r#"SELECT u.c1 FROM (SELECT UNNEST([1, 2, 3]) AS
"UNNEST(make_array(Int64(1),Int64(2),Int64(3)))") AS u (c1) UNION ALL SELECT
u.c1 FROM (SELECT UNNEST([4, 5, 6]) AS
"UNNEST(make_array(Int64(4),Int64(5),Int64(6)))") AS u (c1)"#,
parser_dialect: Box::new(GenericDialect {}),
unparser_dialect: Box::new(UnparserDefaultDialect {}),
},
TestStatementWithDialect {
sql: "SELECT * FROM UNNEST([1,2,3])",
- expected: r#"SELECT * FROM UNNEST([1, 2, 3])"#,
+ expected: r#"SELECT UNNEST(make_array(Int64(1),Int64(2),Int64(3)))
FROM UNNEST([1, 2, 3])"#,
Review Comment:
I think we can change the name display for unnest array to `unnest([..])`
--
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]