apache / datafusion-sqlparser-rs

Extensible SQL Lexer and Parser for Rust
Apache License 2.0
2.81k stars 543 forks source link

Add PostgreSQL specfic "CREATE TYPE t AS ENUM (...)" support. #1460

Closed caldwell closed 1 month ago

caldwell commented 1 month ago

See: https://www.postgresql.org/docs/current/sql-createtype.html

I implemented this as a separate Statement::CreateTypeAsEnum { name, labels } so it wouldn't be as invasive to the existing Statement::CreateType (which I would imagine helps forwards/backwards compatibility for the crate's users).

I used the PostgreSqlDialect's comment as a blueprint but that means that the generic dialect doesn't get this feature (unless I'm missing something). I didn't see parse_statement() implemented in GenericDialect though I suppose it could be (and call out to other dialects' parse_statement()s). I didn't want to set that precedent without asking.

coveralls commented 1 month ago

Pull Request Test Coverage Report for Build 11432831633

Details


Changes Missing Coverage Covered Lines Changed/Added Lines %
src/dialect/postgresql.rs 18 19 94.74%
tests/sqlparser_postgres.rs 15 16 93.75%
<!-- Total: 34 36 94.44% -->
Files with Coverage Reduction New Missed Lines %
src/ast/ddl.rs 1 87.46%
tests/sqlparser_postgres.rs 1 88.57%
<!-- Total: 2 -->
Totals Coverage Status
Change from base Build 11429400839: 0.005%
Covered Lines: 30497
Relevant Lines: 34116

💛 - Coveralls
alamb commented 1 month ago

@caldwell have you had a chance to consider @iffyio 's suggestions above?

caldwell commented 1 month ago

Apologies, not yet. I'll try to look at it today.

caldwell commented 1 month ago

I amended my commit per @iffyio's suggestions. Thanks for taking the time to look at it and apologies again for taking too long to respond.

alamb commented 1 month ago

I amended my commit per @iffyio's suggestions. Thanks for taking the time to look at it and apologies again for taking too long to respond.

no worries -- thank you!

caldwell commented 1 month ago

I pushed a fix for the formatting test failure.

alamb commented 1 month ago

🚀