feat: parse SECURITY LABEL, CREATE USER MAPPING, CREATE TABLESPACE#2312
Closed
fmguerreiro wants to merge 45 commits intoapache:mainfrom
Closed
feat: parse SECURITY LABEL, CREATE USER MAPPING, CREATE TABLESPACE#2312fmguerreiro wants to merge 45 commits intoapache:mainfrom
fmguerreiro wants to merge 45 commits intoapache:mainfrom
Conversation
…R TABLE operations (#1) PostgreSQL supports FORCE ROW LEVEL SECURITY and NO FORCE ROW LEVEL SECURITY as ALTER TABLE operations. Add parsing support for both variants.
feat: parse EXCLUDE constraints for PostgreSQL
…m-main # Conflicts: # Cargo.toml # src/ast/ddl.rs # src/ast/helpers/stmt_create_table.rs # src/ast/mod.rs # src/ast/spans.rs # src/ast/table_constraints.rs # src/parser/mod.rs # tests/sqlparser_postgres.rs
chore: merge upstream apache/datafusion-sqlparser-rs main
- Add HANDLER and VALIDATOR keywords to the keyword list - Add FdwRoutineClause enum for HANDLER/NO HANDLER and VALIDATOR/NO VALIDATOR clauses - Add CreateForeignDataWrapper struct for CREATE FOREIGN DATA WRAPPER - Add CreateForeignTable struct for CREATE FOREIGN TABLE - Export new types from ast::mod and add Statement variants - Add spans.rs coverage returning Span::empty() for the new variants
- Dispatch on FOREIGN keyword in parse_create, branching on DATA WRAPPER or TABLE - parse_create_foreign_data_wrapper: parses optional HANDLER/NO HANDLER, VALIDATOR/NO VALIDATOR, and OPTIONS clauses - parse_create_foreign_table: parses IF NOT EXISTS, column list via parse_columns, required SERVER name, and optional OPTIONS clause
Round-trip tests via pg().verified_stmt for: - FDW: name-only, HANDLER, NO HANDLER, NO VALIDATOR, combined HANDLER+VALIDATOR+OPTIONS - FOREIGN TABLE: basic columns+SERVER, IF NOT EXISTS, table-level OPTIONS
Add Statement::CreateAggregate, CreateAggregate struct, CreateAggregateOption enum, and AggregateModifyKind enum to represent PostgreSQL CREATE AGGREGATE DDL. Options are stored as a typed enum covering all documented parameters (SFUNC, STYPE, FINALFUNC, PARALLEL, moving-aggregate variants, etc.).
Wire AGGREGATE into the CREATE dispatch (before the or_replace error branch so CREATE OR REPLACE AGGREGATE is accepted). parse_create_aggregate parses the name, argument-type list, and the options block. Each recognised option keyword dispatches to parse_create_aggregate_option which produces the typed CreateAggregateOption variant.
Three tests covering: basic old-style aggregate (SFUNC/STYPE/FINALFUNC/INITCOND), CREATE OR REPLACE with PARALLEL = SAFE, and moving-aggregate options (MSFUNC/MINVFUNC/MSTYPE/MFINALFUNC_EXTRA/MFINALFUNC_MODIFY). All use pg().verified_stmt() to assert parse-then-display round-trips identically.
feat: parse CREATE TEXT SEARCH CONFIGURATION/DICTIONARY/PARSER/TEMPLATE
# Conflicts: # src/ast/ddl.rs # src/ast/mod.rs
# Conflicts: # src/ast/ddl.rs # src/ast/mod.rs # src/parser/mod.rs
feat: parse CREATE AGGREGATE
# Conflicts: # src/ast/ddl.rs # src/ast/mod.rs # tests/sqlparser_postgres.rs
feat: parse CREATE FOREIGN DATA WRAPPER and CREATE FOREIGN TABLE
chore: bump version to 0.60.8
PR #7 added the Statement::CreateAggregate variant but omitted the corresponding match arm in the Spanned impl for Statement. Fork CI never ran on the PR so this was not caught before merge.
fix(spans): add Span arm for CreateAggregate
Add PublicationTarget enum (AllTables, Tables, TablesInSchema), CreatePublication struct, and CreateSubscription struct to ddl.rs. Add Statement variants, Display arms, and re-exports in mod.rs. Add Span::empty() arms in spans.rs. Add PUBLICATION and SUBSCRIPTION to keywords.rs.
…rFunctionKind with Procedure, add SetTablespace to AlterTableOperation and AlterIndexOperation Adds AST types and Display impls for: - AlterDomain + AlterDomainOperation (ADD/DROP CONSTRAINT, RENAME, OWNER TO, SET SCHEMA/DEFAULT, DROP DEFAULT, VALIDATE CONSTRAINT) - AlterTrigger + AlterTriggerOperation (RENAME TO) - AlterExtension + AlterExtensionOperation (UPDATE TO, SET SCHEMA, OWNER TO, RENAME TO) - AlterFunctionKind::Procedure variant for ALTER PROCEDURE - AlterTableOperation::SetTablespace - AlterIndexOperation::SetTablespace Updates Spanned impls to remain exhaustive.
feat: parse CREATE PUBLICATION and CREATE SUBSCRIPTION
# Conflicts: # src/ast/ddl.rs # tests/sqlparser_postgres.rs
feat: parse ALTER TABLE/INDEX SET TABLESPACE, ALTER DOMAIN, ALTER TRIGGER, ALTER EXTENSION, ALTER PROCEDURE
chore: bump version to 0.60.9
… nodes Add SecurityLabelObjectKind enum (TABLE/COLUMN/DATABASE/DOMAIN/FUNCTION/ ROLE/SCHEMA/SEQUENCE/TYPE/VIEW/MATERIALIZED VIEW) and SecurityLabel struct, CreateUserMapping struct with UserMappingUser enum, and CreateTablespace struct to ddl.rs with standard derives, Display impls, and From<X> for Statement. Add Statement variants, Display arms, re-exports in mod.rs. Add Span::empty() arms in spans.rs. Add LABEL and MAPPING to keywords.rs. Refs: pgmold-115, pgmold-119, pgmold-120
…SPACE Add parse_security_label to parse_statement dispatch on Keyword::SECURITY. Add parse_create_user_mapping dispatched from CREATE USER MAPPING branch (checked before existing CREATE USER fallthrough). Add parse_create_tablespace dispatched from parse_create on Keyword::TABLESPACE. Refs: pgmold-115, pgmold-119, pgmold-120
…REATE TABLESPACE Add 4 tests for SECURITY LABEL covering TABLE, NULL label, ROLE, and SCHEMA targets. Add 4 tests for CREATE USER MAPPING covering basic, IF NOT EXISTS with OPTIONS, CURRENT_USER, and PUBLIC user specifiers. Add 3 tests for CREATE TABLESPACE covering basic, OWNER, and WITH options. Refs: pgmold-115, pgmold-119, pgmold-120
Contributor
Author
|
Opened on wrong repo; this belongs on the fork fmguerreiro/datafusion-sqlparser-rs. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
SECURITY LABEL [FOR provider] ON object_type name IS {'label' | NULL}. Supported object types: TABLE, COLUMN, DATABASE, DOMAIN, FUNCTION, ROLE, SCHEMA, SEQUENCE, TYPE, VIEW, MATERIALIZED VIEW.CREATE USER MAPPING [IF NOT EXISTS] FOR {role | USER | CURRENT_ROLE | CURRENT_USER | PUBLIC} SERVER name [OPTIONS (...)].CREATE TABLESPACE name [OWNER role] LOCATION 'dir' [WITH (options)].Details
SecurityLabelObjectKindenum,SecurityLabel,CreateUserMapping(withUserMappingUserenum), andCreateTablespacestructs insrc/ast/ddl.rs.Statementvariants andDisplayarms insrc/ast/mod.rs.Span::empty()arms insrc/ast/spans.rs.LABELandMAPPINGkeywords tosrc/keywords.rs.SECURITY LABELdispatches fromparse_statement(top-level, not under CREATE).CREATE USER MAPPINGis checked before the existingCREATE USERbranch.tests/sqlparser_postgres.rs.Note: fork CI does not auto-run on PRs.