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

TSQL: computed column not parsed #2104

Closed
dmoore247 opened this issue Aug 22, 2023 · 4 comments
Closed

TSQL: computed column not parsed #2104

dmoore247 opened this issue Aug 22, 2023 · 4 comments

Comments

@dmoore247
Copy link
Contributor

TSQL computed column example:

CREATE TABLE [dbo].[mytable](
	[zip_cd] [varchar](5) NULL,
	[safe_harbor_zip_cd]  AS (case when left([zip_cd],(3))='893' 
                              then left([zip_cd],(3))+'XX' 
                              else [zip_cd] end) PERSISTED,
 )

doesn't parse
image

Fully reproducible code snippet

tsql = """CREATE TABLE [dbo].[mytable](
[zip_cd] [varchar](5) NULL,
[safe_harbor_zip_cd]  AS (case when left([zip_cd],(3))='893' 
                            then left([zip_cd],(3))+'XX' 
                            else [zip_cd] end) PERSISTED,
)
"""
sqlglot.parse(sql=tsql, read="tsql")

Official Documentation
TSQL computed_column_expression:
image

sqlfiddle:
image

@dmoore247
Copy link
Contributor Author

Thanks!

@eliotgerson
Copy link

eliotgerson commented Feb 21, 2024

@tobymao Did this break at some point? The example from the test that was added in the fix fails with "Unsupported Column Type: None" in a large tsql file that otherwise parses fine.

@tobymao
Copy link
Owner

tobymao commented Feb 21, 2024

the test is still in the code base, so it must be still working

@eliotgerson
Copy link

@tobymao nvm, I was being silly. thanks for confirming!!

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