Skip to content
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

Feat(presto): transpile explode/posexplode into (cross join) unnest #1501

Merged
merged 3 commits into from
Apr 30, 2023

Conversation

georgesittas
Copy link
Collaborator

@georgesittas georgesittas commented Apr 28, 2023

Fixes #1495

cc: @vegarsti I included the test cases you've added to the harmonizer repo, adapted appropriately.

@vegarsti
Copy link
Contributor

Ah you're fast, I was hoping to get some open source points here 😄

Copy link
Contributor

@vegarsti vegarsti left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Really nice! Thanks for adding this. Honestly a bit bummed to not get this PR myself, but guess I was too slow. The code looks better than what I did in harmonize though!

sqlglot/transforms.py Outdated Show resolved Hide resolved
sqlglot/transforms.py Outdated Show resolved Hide resolved
sqlglot/transforms.py Outdated Show resolved Hide resolved
sqlglot/transforms.py Outdated Show resolved Hide resolved
sqlglot/transforms.py Outdated Show resolved Hide resolved
sqlglot/transforms.py Outdated Show resolved Hide resolved
@@ -4713,6 +4713,8 @@ def alias_(

if table:
table_alias = TableAlias(this=alias)

exp = exp.copy()
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

only copy if expression is an expression, if it's a string, you don't need this

@tobymao tobymao merged commit 80287dd into main Apr 30, 2023
@tobymao tobymao deleted the jo/explode_to_unnest branch April 30, 2023 05:51
vegarsti added a commit to duneanalytics/harmonizer that referenced this pull request May 3, 2023
After tobymao/sqlglot#1501 was merged and
released, the transform we're doing is almost redundant. For some
reason, it still fails on Postgres, so we can't remove our transform
just yet, will make sure that's fixed upstream.
vegarsti added a commit to duneanalytics/harmonizer that referenced this pull request May 3, 2023
Follow up to #43. After
tobymao/sqlglot#1501, we can now fully remove
our version of the explode to unnest transform! 🎉

The previous PR didn't really do anything, I just didn't realize we had
to import the preprocess functions that the Presto dialect uses, and put
these in our DuneSQL dialect's preprocess functions.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Transform exp.Explode and exp.Posexplode into exp.Unnest
3 participants