Description
Reported from: https://issues.apache.org/jira/browse/DRILL-7722
// Updated based on Julian's comment.
If write the following test in Calcite,
@Test void testUnnestWithoutLateral() { final String sql1 = "" + "SELECT\n" + " item.name,\n" + " relations.*\n" + "FROM dfs.tmp item\n" + "JOIN (\n" + " SELECT * FROM UNNEST(item.related) i(rels)\n" + ") relations\n" + "ON TRUE"; final String expected = "SELECT `ITEM`.`NAME`, `RELATIONS`.*\n" + "FROM `DFS`.`TMP` AS `ITEM`\n" + "INNER JOIN (SELECT *\n" + "FROM (UNNEST(`ITEM`.`RELATED`)) AS `I` (`RELS`)) AS `RELATIONS` ON TRUE"; sql(sql1).ok(expected); }
The expected SQL query (thus the unparsed one) is
SELECT `ITEM`.`NAME`, `RELATIONS`.* FROM `DFS`.`TMP` AS `ITEM` INNER JOIN (SELECT * FROM (UNNEST(`ITEM`.`RELATED`)) AS `I` (`RELS`)) AS `RELATIONS` ON TRUE");
Note that there are extra parentheses around the UNNEST. And then the generated query won't pass Calcite's parser because the parentheses around the UNNEST.
Attachments
Issue Links
- relates to
-
DRILL-7722 CREATE VIEW with LATERAL UNNEST creates an invalid view
- Resolved
- links to