Skip to content

Support more forms of generated columns for SQLite dialect #1050

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

Closed
takluyver opened this issue Nov 19, 2023 · 1 comment · Fixed by #1058
Closed

Support more forms of generated columns for SQLite dialect #1050

takluyver opened this issue Nov 19, 2023 · 1 comment · Fixed by #1058

Comments

@takluyver
Copy link
Contributor

takluyver commented Nov 19, 2023

SQLite allows some ways of defining a generated column which sqlparser currently rejects.

First, the GENERATED ALWAYS keywords are optional:

Parser::parse_sql(&SQLiteDialect {},
    "CREATE TABLE t1(a INT, b INT AS (a * 2) STORED);")?;
Error: sql parser error: Expected ',' or ')' after column definition, found: AS at Line: 1, Column 30

Second, the clause can have a VIRTUAL keyword stuck on the end (instead of STORED). This is the default behaviour anyway, just made explicit.

Parser::parse_sql(&SQLiteDialect {},
    "CREATE TABLE t1(a INT, b INT GENERATED ALWAYS AS (a * 2) VIRTUAL);")?;
Error: sql parser error: Expected ',' or ')' after column definition, found: VIRTUAL at Line: 1, Column 58

I think the distinction of stored-or-not is also not exposed in the AST at present.

I can have a go at fixing one or both of these, but I wanted to record the issue clearly first.

@takluyver
Copy link
Contributor Author

#1051 fixed VIRTUAL. I'll work on making GENERATED ALWAYS optional, but probably not until next week.

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 a pull request may close this issue.

1 participant