From 7bfc3d49bb718fd014e6fc187243fe52ef7393b7 Mon Sep 17 00:00:00 2001 From: niu niu Date: Tue, 28 Nov 2023 08:07:14 +0800 Subject: [PATCH] Fix oracle create table listPartitionDesc and subpartitionTemplate syntax (#29222) --- .../antlr4/imports/oracle/DDLStatement.g4 | 10 ++-- .../main/resources/case/ddl/create-table.xml | 56 +++++++++++++++++++ .../sql/supported/ddl/create-table.xml | 38 +++++++++++++ 3 files changed, 99 insertions(+), 5 deletions(-) diff --git a/parser/sql/dialect/oracle/src/main/antlr4/imports/oracle/DDLStatement.g4 b/parser/sql/dialect/oracle/src/main/antlr4/imports/oracle/DDLStatement.g4 index d1dcc2d7cda69..12dc0eb85507c 100644 --- a/parser/sql/dialect/oracle/src/main/antlr4/imports/oracle/DDLStatement.g4 +++ b/parser/sql/dialect/oracle/src/main/antlr4/imports/oracle/DDLStatement.g4 @@ -1094,13 +1094,12 @@ subpartitionByList ; subpartitionByHash - : SUBPARTITION BY HASH columnNames (SUBPARTITIONS NUMBER_ (STORE IN LP_ tablespaceName (COMMA_ tablespaceName)? RP_)? | subpartitionTemplate)? + : SUBPARTITION BY HASH columnNames (SUBPARTITIONS INTEGER_ (STORE IN LP_ tablespaceName (COMMA_ tablespaceName)? RP_)? | subpartitionTemplate)? ; subpartitionTemplate - : SUBPARTITION TEMPLATE - (LP_? rangeSubpartitionDesc (COMMA_ rangeSubpartitionDesc)* | listSubpartitionDesc (COMMA_ listSubpartitionDesc)* | individualHashSubparts (COMMA_ individualHashSubparts)* RP_?) - | hashSubpartitionQuantity + : SUBPARTITION TEMPLATE (LP_ (rangeSubpartitionDesc (COMMA_ rangeSubpartitionDesc)* + | listSubpartitionDesc (COMMA_ listSubpartitionDesc)* | individualHashSubparts (COMMA_ individualHashSubparts)*) RP_) | hashSubpartitionQuantity ; rangeSubpartitionDesc @@ -1129,7 +1128,8 @@ compositeListPartitions ; listPartitionDesc - : PARTITIONSET partitionSetName listValuesClause (TABLESPACE SET tablespaceSetName)? lobStorageClause? (SUBPARTITIONS STORE IN LP_? tablespaceSetName (COMMA_ tablespaceSetName)* RP_?)? + : PARTITION partitionName? listValuesClause tablePartitionDescription (LP_ (rangeSubpartitionDesc (COMMA_ rangeSubpartitionDesc)* + | listSubpartitionDesc (COMMA_ listSubpartitionDesc)* | individualHashSubparts (COMMA_ individualHashSubparts)*) RP_ | hashSubpartsByQuantity)? ; compositeHashPartitions diff --git a/test/it/parser/src/main/resources/case/ddl/create-table.xml b/test/it/parser/src/main/resources/case/ddl/create-table.xml index 02d5c30eb6116..5b4c2b5bba841 100644 --- a/test/it/parser/src/main/resources/case/ddl/create-table.xml +++ b/test/it/parser/src/main/resources/case/ddl/create-table.xml @@ -2081,4 +2081,60 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + diff --git a/test/it/parser/src/main/resources/sql/supported/ddl/create-table.xml b/test/it/parser/src/main/resources/sql/supported/ddl/create-table.xml index c2dbb1f21ac04..8ebd8c69d22ed 100644 --- a/test/it/parser/src/main/resources/sql/supported/ddl/create-table.xml +++ b/test/it/parser/src/main/resources/sql/supported/ddl/create-table.xml @@ -157,4 +157,42 @@ PARTITION costs_q2_2003 VALUES LESS THAN (TO_DATE('01-JUN-2003', 'DD-MON-YYYY')), PARTITION costs_recent VALUES LESS THAN (MAXVALUE))" db-types="Oracle" /> + +