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

Add support for STRING_AGG <-> GROUP_CONCAT transpilation #774

Merged
merged 5 commits into from
Nov 28, 2022
Merged

Conversation

georgesittas
Copy link
Collaborator

Fixes #754

This seems to do the trick, although I'll take a look an try to simplify/refactor things in a bit.

@georgesittas
Copy link
Collaborator Author

georgesittas commented Nov 28, 2022

@tobymao
Ok, I'd say this is good to go. Not sure if there's any part that can be greatly simplified. Seems like STRING_AGG is a T-SQL function so I think it makes sense to not move these implementations over to the base parser / generator. Scratch that, it's also supported in postgres, so I moved the parse string agg method to the base parser.

Let me know if I've missed anything.

sqlglot/dialects/tsql.py Outdated Show resolved Hide resolved
@georgesittas
Copy link
Collaborator Author

georgesittas commented Nov 28, 2022

Sources for sqlite/postgres additions:

We may be able to dry up the generator method for group concat / string agg.

Edit: regarding the postgres NULLS FIRST/LAST form, I checked locally for postgres15 and it seems to work too (although I'm not 100% sure about the exact semantics), so I didn't try to change it in order to match the other generator methods.

@tobymao tobymao merged commit d5846b6 into main Nov 28, 2022
@tobymao tobymao deleted the string_agg branch November 28, 2022 23:35
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.

2 participants