s5dsn-eqee opened a new issue, #2762:
URL: https://github.com/apache/datafusion-sqlparser-rs/issues/2762

     ### Problem
   
     In the `PARTITION OF` form, PostgreSQL column entries have no data type 
([docs](https://www.postgresql.org/docs/current/sql-createtable.html)):
   
     ```
     PARTITION OF parent_table [ (
       { column_name [ WITH OPTIONS ] [ column_constraint [ ... ] ]
         | table_constraint }
         [, ... ]
     ) ] { FOR VALUES partition_bound_spec | DEFAULT }
     ```
   
     The parser always reads a data type after the column name, so the first 
constraint keyword is taken as the type
   
   ```
     let stmt = pg().verified_stmt("CREATE TABLE part PARTITION OF root (id NOT 
NULL) DEFAULT");
     println!("{stmt:#?}");
   ```
   
   Result: 
   
   ```
       [
            CreateTable(
                CreateTable {
                    or_replace: false,
                    temporary: false,
                    unlogged: false,
                    external: false,
                    dynamic: false,
                    global: None,
                    if_not_exists: false,
                    transient: false,
                    volatile: false,
                    iceberg: false,
                    snapshot: false,
                    name: ObjectName(
                        [
                            Identifier(
                                Ident {
                                    value: "part",
                                    quote_style: None,
                                    span: Span(Location(1,14)..Location(1,18)),
                                },
                            ),
                        ],
                    ),
                    columns: [
                        ColumnDef {
                            name: Ident {
                                value: "id",
                                quote_style: None,
                                span: Span(Location(1,38)..Location(1,40)),
                            },
                            data_type: Custom(
                                ObjectName(
                                    [
                                        Identifier(
                                            Ident {
                                                value: "NOT",
                                                quote_style: None,
                                                span: 
Span(Location(1,41)..Location(1,44)),
                                            },
                                        ),
                                    ],
                                ),
                                [],
                            ),
                            options: [
                                ColumnOptionDef {
                                    name: None,
                                    option: Null,
                                },
                            ],
                        },
                    ],
                    constraints: [],
                    hive_distribution: NONE,
                    hive_formats: None,
                    table_options: None,
                    file_format: None,
                    location: None,
                    query: None,
                    sqlite_table_options: SqliteTableOptions {
                        leading_comma: false,
                        options: [],
                    },
                    like: None,
                    clone: None,
                    version: None,
                    comment: None,
                    on_commit: None,
                    on_cluster: None,
                    primary_key: None,
                    order_by: None,
                    partition_by: None,
                    cluster_by: None,
                    clustered_by: None,
                    inherits: None,
                    partition_of: Some(
                        ObjectName(
                            [
                                Identifier(
                                    Ident {
                                        value: "root",
                                        quote_style: None,
                                        span: 
Span(Location(1,32)..Location(1,36)),
                                    },
                                ),
                            ],
                        ),
                    ),
                    for_values: Some(
                        Default,
                    ),
                    copy_grants: false,
                    enable_schema_evolution: None,
                    change_tracking: None,
                    data_retention_time_in_days: None,
                    max_data_extension_time_in_days: None,
                    default_ddl_collation: None,
                    with_aggregation_policy: None,
                    with_row_access_policy: None,
                    with_storage_lifecycle_policy: None,
                    with_tags: None,
                    external_volume: None,
                    with_connection: None,
                    base_location: None,
                    catalog: None,
                    catalog_sync: None,
                    storage_serialization_policy: None,
                    target_lag: None,
                    warehouse: None,
                    refresh_mode: None,
                    initialize: None,
                    require_user: false,
                    catalog_sync: None,
                    storage_serialization_policy: None,
                    target_lag: None,
                    warehouse: None,
                    refresh_mode: None,
                    initialize: None,
                    require_user: false,
                    diststyle: None,
                    distkey: None,
                    sortkey: None,
                    backup: None,
                    multiset: None,
                    fallback: None,
                    with_data: None,
                },
            ),
        ]
   ```
   


-- 
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]

Reply via email to