@@ -31,7 +31,7 @@ use recursion::RecursionCounter;
31
31
use IsLateral :: * ;
32
32
use IsOptional :: * ;
33
33
34
- use crate :: ast:: helpers:: stmt_create_table:: { BigQueryTableConfiguration , CreateTableBuilder } ;
34
+ use crate :: ast:: helpers:: stmt_create_table:: { CreateTableBuilder , CreateTableConfiguration } ;
35
35
use crate :: ast:: * ;
36
36
use crate :: dialect:: * ;
37
37
use crate :: keywords:: { Keyword , ALL_KEYWORDS } ;
@@ -5416,11 +5416,7 @@ impl<'a> Parser<'a> {
5416
5416
None
5417
5417
} ;
5418
5418
5419
- let big_query_config = if dialect_of ! ( self is BigQueryDialect | GenericDialect ) {
5420
- self . parse_optional_big_query_create_table_config ( ) ?
5421
- } else {
5422
- Default :: default ( )
5423
- } ;
5419
+ let create_table_config = self . parse_optional_create_table_config ( ) ?;
5424
5420
5425
5421
// Parse optional `AS ( query )`
5426
5422
let query = if self . parse_keyword ( Keyword :: AS ) {
@@ -5505,39 +5501,46 @@ impl<'a> Parser<'a> {
5505
5501
. collation ( collation)
5506
5502
. on_commit ( on_commit)
5507
5503
. on_cluster ( on_cluster)
5508
- . partition_by ( big_query_config . partition_by )
5509
- . cluster_by ( big_query_config . cluster_by )
5510
- . options ( big_query_config . options )
5504
+ . partition_by ( create_table_config . partition_by )
5505
+ . cluster_by ( create_table_config . cluster_by )
5506
+ . options ( create_table_config . options )
5511
5507
. primary_key ( primary_key)
5512
5508
. strict ( strict)
5513
5509
. build ( ) )
5514
5510
}
5515
5511
5516
- /// Parse configuration like partitioning, clustering information during big-query table creation.
5517
- /// <https://cloud.google.com/bigquery/docs/reference/standard-sql/data-definition-language#syntax_2>
5518
- fn parse_optional_big_query_create_table_config (
5512
+ /// Parse configuration like partitioning, clustering information during the table creation.
5513
+ ///
5514
+ /// [BigQuery](https://cloud.google.com/bigquery/docs/reference/standard-sql/data-definition-language#syntax_2)
5515
+ /// [PostgreSQL](https://www.postgresql.org/docs/current/ddl-partitioning.html)
5516
+ fn parse_optional_create_table_config (
5519
5517
& mut self ,
5520
- ) -> Result < BigQueryTableConfiguration , ParserError > {
5521
- let mut partition_by = None ;
5522
- if self . parse_keywords ( & [ Keyword :: PARTITION , Keyword :: BY ] ) {
5523
- partition_by = Some ( Box :: new ( self . parse_expr ( ) ?) ) ;
5518
+ ) -> Result < CreateTableConfiguration , ParserError > {
5519
+ let partition_by = if dialect_of ! ( self is BigQueryDialect | PostgreSqlDialect | GenericDialect )
5520
+ && self . parse_keywords ( & [ Keyword :: PARTITION , Keyword :: BY ] )
5521
+ {
5522
+ Some ( Box :: new ( self . parse_expr ( ) ?) )
5523
+ } else {
5524
+ None
5524
5525
} ;
5525
5526
5526
5527
let mut cluster_by = None ;
5527
- if self . parse_keywords ( & [ Keyword :: CLUSTER , Keyword :: BY ] ) {
5528
- cluster_by = Some ( WrappedCollection :: NoWrapping (
5529
- self . parse_comma_separated ( |p| p. parse_identifier ( false ) ) ?,
5530
- ) ) ;
5531
- } ;
5532
-
5533
5528
let mut options = None ;
5534
- if let Token :: Word ( word) = self . peek_token ( ) . token {
5535
- if word. keyword == Keyword :: OPTIONS {
5536
- options = Some ( self . parse_options ( Keyword :: OPTIONS ) ?) ;
5537
- }
5538
- } ;
5529
+ if dialect_of ! ( self is BigQueryDialect | GenericDialect ) {
5530
+ if self . parse_keywords ( & [ Keyword :: CLUSTER , Keyword :: BY ] ) {
5531
+ cluster_by = Some ( WrappedCollection :: NoWrapping (
5532
+ self . parse_comma_separated ( |p| p. parse_identifier ( false ) ) ?,
5533
+ ) ) ;
5534
+ } ;
5535
+
5536
+ if let Token :: Word ( word) = self . peek_token ( ) . token {
5537
+ if word. keyword == Keyword :: OPTIONS {
5538
+ options = Some ( self . parse_options ( Keyword :: OPTIONS ) ?) ;
5539
+ }
5540
+ } ;
5541
+ }
5539
5542
5540
- Ok ( BigQueryTableConfiguration {
5543
+ Ok ( CreateTableConfiguration {
5541
5544
partition_by,
5542
5545
cluster_by,
5543
5546
options,
0 commit comments