-
Notifications
You must be signed in to change notification settings - Fork 769
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
Incorrect translation in table function unnest syntax #3962
Comments
I'm interested in trying to solve this issue, tks I want to modify the sqlglot.transforms.unnest_to_explode function. After referring to the unnest syntax of starrocks and bigquery, I think:
Parsing SQL 1: Parsed SQL 1:
The modification should include laterals, where alias is set to the default value of unnest:
|
@georgesittas PTAL |
@hellozepp please provide a clear example of how exactly you're using sqlglot, what's the expected output vs what you got & why the latter is incorrect. I can't understand what the issue at hand is based on the description, e.g. you mentioned BigQuery but the queries you provided are not valid in it. |
@georgesittas
The original SQL I transpile:
The output I expected:
The actual output:
At the end of the sql, the simplified unnest is missing. Sorry, I just tried bigquery's |
Another type of unnest problem, the following starrocks sql transpile to spark will also have problems:
Expected output:
Actual:
CROSS JOIN LATERAL and UNNEST should not appear at the same time. I tried to figure out the reason, and I found that |
@georgesittas It seems that only starrocks has the problem. |
Thanks a lot @georgesittas @VaggelisD |
fix some comment
fix some comment
fix some comment
fix some comment
fix some comment
Re-run github action
fix some comment Fixes tobymao#3962 Re-run github action
* fix(starrocks): exp.Unnest transpilation * fix(starrocks): exp.Unnest transpilation use `arrays_zip` to merge multiple `Lateral view explode` * Fixes #3962 fix some comment * Fixes #3962 fix some comment * Update sqlglot/transforms.py Co-authored-by: Jo <46752250+georgesittas@users.noreply.github.com> * Fixes #3962 fix some comment * Fixes #3962 fix some comment Fixes #3962 Re-run github action --------- Co-authored-by: lin.zhang <lin.zhang@clickzetta.com> Co-authored-by: Jo <46752250+georgesittas@users.noreply.github.com>
* fix(starrocks): exp.Unnest transpilation * fix(starrocks): exp.Unnest transpilation use `arrays_zip` to merge multiple `Lateral view explode` * Fixes tobymao#3962 fix some comment * Fixes tobymao#3962 fix some comment * Update sqlglot/transforms.py Co-authored-by: Jo <46752250+georgesittas@users.noreply.github.com> * Fixes tobymao#3962 fix some comment * Fixes tobymao#3962 fix some comment Fixes tobymao#3962 Re-run github action --------- Co-authored-by: lin.zhang <lin.zhang@clickzetta.com> Co-authored-by: Jo <46752250+georgesittas@users.noreply.github.com>
Fully reproducible code snippet
The
unnest
syntax cannot be converted correctly, related to starrocks and bigquery.In my case, I need to convert
cross join unnest
toLATERAL VIEW EXPLODE
.The following sql:
When we
transpile
in case sql1 and sql2, we will get a result that loses the unnest function (all dialects):Expected value:
Official Documentation
Please include links to official SQL documentation related to your issue.
The text was updated successfully, but these errors were encountered: