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

fix(tsql, postgres)!: Improve UUID support #4718

Merged

Conversation

amachanic
Copy link
Contributor

This PR addresses some UUID support issues with T-SQL and Postgres. A small example of what I wanted to get working:

Input: sqlglot.transpile('create table x (i uniqueidentifier not null default(newid()))', read='tsql', write='postgres')
Output: ['CREATE TABLE x (i UNIQUEIDENTIFIER NOT NULL DEFAULT (NEWID()))']
Expected: ['CREATE TABLE x (i uuid NOT NULL DEFAULT (gen_random_uuid()))']

  • Removed unnecessary UNIQUEIDENTIFER token (standardized on UUID)
  • Added NEWID() support to T-SQL
  • Cleaned up Spark UUID support, which I noticed was also broken. (I think Hive might be, too, but I don't know for a fact so I didn't touch that one.)

Copy link
Collaborator

@georgesittas georgesittas left a comment

Choose a reason for hiding this comment

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

Thanks for the contribution! FYI, this is breaking, so the PR title needs to reflect that. I'll make the change, just something to keep in mind for future PRs.

Looks good 👍

@georgesittas georgesittas changed the title fix(tsql, postgres): Improve UUID support fix(tsql, postgres)!: Improve UUID support Feb 7, 2025
@georgesittas georgesittas merged commit b12aba9 into tobymao:main Feb 7, 2025
7 checks passed
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