LucaCappelletti94 opened a new pull request, #2798: URL: https://github.com/apache/datafusion-sqlparser-rs/pull/2798
`CREATE DOMAIN d AS INT NOT NULL` fails with `Expected: end of statement, found: NOT`, and `CREATE DOMAIN d AS INT NULL` the same way, because `parse_create_domain` reads its constraints with `parse_optional_table_constraint`, which knows `CHECK` but not the nullability spellings of a domain. `CREATE DOMAIN d AS INT DEFAULT 0 NOT NULL` does parse, but the default expression swallows the `NOT NULL` and prints back as `DEFAULT 0 IS NOT NULL`. `CreateDomain.constraints` now holds the `DomainConstraint` enum that `ALTER DOMAIN ... ADD` uses, with an added `NULL` variant, so `[ CONSTRAINT name ] NOT NULL`, `NULL` and `CHECK (...)` parse in any order and number, and table-only constraints such as `PRIMARY KEY` are refused. `ALTER DOMAIN ... ADD NULL` stays refused, as in PostgreSQL. The default expression is parsed in the column definition state that column defaults already use, so a trailing `NOT NULL` stays a constraint. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
