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

SQL Server to Postgres CREATE TABLE transpilation issues #4715

Closed
amachanic opened this issue Feb 6, 2025 · 2 comments
Closed

SQL Server to Postgres CREATE TABLE transpilation issues #4715

amachanic opened this issue Feb 6, 2025 · 2 comments

Comments

@amachanic
Copy link
Contributor

amachanic commented Feb 6, 2025

sqlglot 26.4.1

Input: sqlglot.transpile('create table x (i int identity(1,1) not null)', read='tsql', write='postgres')
Output: ['CREATE TABLE x (i INT GENERATED AS IDENTITY (START WITH 1 INCREMENT BY 1) NOT NULL)']
Expected: ['CREATE TABLE x (i INT GENERATED ALWAYS AS IDENTITY (START WITH 1 INCREMENT BY 1) NOT NULL)']


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()))']


Input: sqlglot.transpile('create table x (i int not null) on primary', read='tsql', write='postgres')
Output: ['CREATE TABLE x (i INT NOT NULL) ON primary']
Expected: Couple of options here. Simplest, just strip the "ON primary" as (AFAIK) there's no equivalent in Postgres. But maybe it would be nice to give the user an error in this sort of situation, and have a flag that ignores unconvertable syntax?


I'm happy to personally help work on any/all of these if you agree that they're good enhancements.

@tobymao
Copy link
Owner

tobymao commented Feb 6, 2025

@amachanic would love these contributions from you. we look forward to working with you on the pr's. going to close for now as we close issues that aren't being actively worked on by core team.

feel free to join us on slack if you want to ask us direct questions tobikodata.com/slack

thank you!

@tobymao tobymao closed this as not planned Won't fix, can't repro, duplicate, stale Feb 6, 2025
@georgesittas
Copy link
Collaborator

Fixed by #4719

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

No branches or pull requests

3 participants