This is an automated email from the ASF dual-hosted git repository.

zhonghongsheng pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere.git


The following commit(s) were added to refs/heads/master by this push:
     new 30144ebc53a Add difference comment for doris special parse logic and 
rename test case identifier name (#31285)
30144ebc53a is described below

commit 30144ebc53aa4e07b1bec93c5f2916451f781aca
Author: Zhengqiang Duan <[email protected]>
AuthorDate: Sun May 19 09:03:28 2024 +0800

    Add difference comment for doris special parse logic and rename test case 
identifier name (#31285)
---
 .../src/main/antlr4/imports/doris/BaseRule.g4      |  8 ++++++
 .../src/main/antlr4/imports/doris/DDLStatement.g4  |  6 +++++
 .../src/main/antlr4/imports/doris/DMLStatement.g4  |  2 ++
 .../src/main/antlr4/imports/doris/DorisKeyword.g4  |  6 +++++
 .../visitor/statement/DorisStatementVisitor.java   |  4 +--
 .../statement/type/DorisDDLStatementVisitor.java   |  4 +--
 .../handler/ddl/CreateTableStatementHandler.java   |  8 +++---
 .../src/main/resources/case/ddl/create-table.xml   | 30 +++++++++++-----------
 .../resources/sql/supported/ddl/create-table.xml   | 14 +++++-----
 9 files changed, 52 insertions(+), 30 deletions(-)

diff --git a/parser/sql/dialect/doris/src/main/antlr4/imports/doris/BaseRule.g4 
b/parser/sql/dialect/doris/src/main/antlr4/imports/doris/BaseRule.g4
index 16ce66427d9..50a6dca4053 100644
--- a/parser/sql/dialect/doris/src/main/antlr4/imports/doris/BaseRule.g4
+++ b/parser/sql/dialect/doris/src/main/antlr4/imports/doris/BaseRule.g4
@@ -1104,9 +1104,11 @@ castType
     | castTypeName = REAL
     | castTypeName = DOUBLE PRECISION
     | castTypeName = FLOAT precision?
+    // DORIS ADDED BEGIN
     | castTypeName = STRING
     | castTypeName = INT
     | castTypeName = BIGINT
+    // DORIS ADDED END
     ;
     
 positionFunction
@@ -1157,12 +1159,16 @@ shorthandRegularFunction
     ;
     
 completeRegularFunction
+    // DORIS CHANGED BEGIN
     : regularFunctionName (LP_ (expr (COMMA_ expr)* | ASTERISK_)? RP_) 
indexAlias?
+    // DORIS CHANGED END
     ;
 
+// DORIS ADDED BEGIN
 indexAlias
     : LBT_ (NUMBER_ | columnRef) RBT_ (SEMI_? (AS | EQ_) (identifier | 
columnRef))?
     ;
+// DORIS ADDED END
 
 regularFunctionName
     : IF | LOCALTIME | LOCALTIMESTAMP | REPLACE | INSERT | INTERVAL | MOD
@@ -1231,7 +1237,9 @@ dataType
     | (dataTypeName = REAL | dataTypeName = DOUBLE PRECISION?) precision? 
fieldOptions?
     | dataTypeName = (FLOAT | DECIMAL | DEC | NUMERIC | FIXED) (fieldLength | 
precision)? fieldOptions?
     | dataTypeName = BIT fieldLength?
+    // DORIS ADDED BEGIN
     | dataTypeName = DECIMAL64 precision
+    // DORIS ADDED END
     | dataTypeName = (BOOL | BOOLEAN)
     | dataTypeName = CHAR fieldLength? charsetWithOptBinary?
     | (dataTypeName = NCHAR | dataTypeName = NATIONAL_CHAR) fieldLength? 
BINARY?
diff --git 
a/parser/sql/dialect/doris/src/main/antlr4/imports/doris/DDLStatement.g4 
b/parser/sql/dialect/doris/src/main/antlr4/imports/doris/DDLStatement.g4
index 2922dbe8552..ba5e741be62 100644
--- a/parser/sql/dialect/doris/src/main/antlr4/imports/doris/DDLStatement.g4
+++ b/parser/sql/dialect/doris/src/main/antlr4/imports/doris/DDLStatement.g4
@@ -32,9 +32,12 @@ alterStatement
     ;
 
 createTable
+    // DORIS CHANGED BEGIN
     : CREATE TEMPORARY? TABLE ifNotExists? tableName (createDefinitionClause? 
createTableOptions? partitionClause? duplicateAsQueryExpression? 
startTransaction? duplicatekeyClause? commentClause? distributedbyClause? 
propertiesClause? | createLikeClause)
+    // DORIS CHANGED END
     ;
 
+// DORIS ADDED BEGIN
 duplicatekeyClause
     : DUPLICATE KEY (LP_ columnName RP_)
     ;
@@ -58,6 +61,7 @@ properties
 property
     : (identifier | SINGLE_QUOTED_TEXT) EQ_? literals
     ;
+// DORIS ADDED END
 
 startTransaction
     : START TRANSACTION
@@ -461,7 +465,9 @@ createDefinitionClause
     ;
 
 columnDefinition
+    // DORIS CHANGED BEGIN
     : column_name=identifier fieldDefinition referenceDefinition? | NAME EQ_ 
columnName
+    // DORIS CHANGED END
     ;
 
 fieldDefinition
diff --git 
a/parser/sql/dialect/doris/src/main/antlr4/imports/doris/DMLStatement.g4 
b/parser/sql/dialect/doris/src/main/antlr4/imports/doris/DMLStatement.g4
index d7fe355c595..9b577cb1c38 100644
--- a/parser/sql/dialect/doris/src/main/antlr4/imports/doris/DMLStatement.g4
+++ b/parser/sql/dialect/doris/src/main/antlr4/imports/doris/DMLStatement.g4
@@ -276,7 +276,9 @@ fromClause
     ;
 
 tableReferences
+    // DORIS CHANGED BEGIN
     : tableReference (COMMA_ tableReference)* (COMMA_ regularFunction)?
+    // DORIS CHANGED END
     ;
 
 escapedTableReference
diff --git 
a/parser/sql/dialect/doris/src/main/antlr4/imports/doris/DorisKeyword.g4 
b/parser/sql/dialect/doris/src/main/antlr4/imports/doris/DorisKeyword.g4
index 5de9b8aa396..7c611dc8f5b 100644
--- a/parser/sql/dialect/doris/src/main/antlr4/imports/doris/DorisKeyword.g4
+++ b/parser/sql/dialect/doris/src/main/antlr4/imports/doris/DorisKeyword.g4
@@ -507,9 +507,11 @@ DECIMAL
     : D E C I M A L
     ;
 
+// DORIS ADDED BEGIN
 DECIMAL64
     : D E C I M A L '64'
     ;
+// DORIS ADDED END
 
 DECLARE
     : D E C L A R E
@@ -619,9 +621,11 @@ DUPLICATE
     : D U P L I C A T E
     ;
 
+// DORIS ADDED BEGIN
 DISTRIBUTED
     : D I S T R I B U T E D
     ;
+// DORIS ADDED END
 
 DYNAMIC
     : D Y N A M I C
@@ -1915,9 +1919,11 @@ PROFILES
     : P R O F I L E S
     ;
 
+// DORIS ADDED BEGIN
 PROPERTIES
     : P R O P E R T I E S
     ;
+// DORIS ADDED END
 
 PROXY
     : P R O X Y
diff --git 
a/parser/sql/dialect/doris/src/main/java/org/apache/shardingsphere/sql/parser/doris/visitor/statement/DorisStatementVisitor.java
 
b/parser/sql/dialect/doris/src/main/java/org/apache/shardingsphere/sql/parser/doris/visitor/statement/DorisStatementVisitor.java
index fa1313bdad8..faece8c1038 100644
--- 
a/parser/sql/dialect/doris/src/main/java/org/apache/shardingsphere/sql/parser/doris/visitor/statement/DorisStatementVisitor.java
+++ 
b/parser/sql/dialect/doris/src/main/java/org/apache/shardingsphere/sql/parser/doris/visitor/statement/DorisStatementVisitor.java
@@ -1807,12 +1807,12 @@ public abstract class DorisStatementVisitor extends 
DorisStatementBaseVisitor<AS
             }
             return result;
         }
-        // {Doris} ADDED BEGIN
+        // DORIS ADDED BEGIN
         if (null != ctx.regularFunction()) {
             FunctionSegment functionSegment = (FunctionSegment) 
visit(ctx.regularFunction());
             return new FunctionTableSegment(ctx.start.getStartIndex(), 
ctx.stop.getStopIndex(), functionSegment);
         }
-        // {Doris} ADDED END
+        // DORIS ADDED END
         return result;
     }
     
diff --git 
a/parser/sql/dialect/doris/src/main/java/org/apache/shardingsphere/sql/parser/doris/visitor/statement/type/DorisDDLStatementVisitor.java
 
b/parser/sql/dialect/doris/src/main/java/org/apache/shardingsphere/sql/parser/doris/visitor/statement/type/DorisDDLStatementVisitor.java
index 5f47bbac6c1..1603df4c6fb 100644
--- 
a/parser/sql/dialect/doris/src/main/java/org/apache/shardingsphere/sql/parser/doris/visitor/statement/type/DorisDDLStatementVisitor.java
+++ 
b/parser/sql/dialect/doris/src/main/java/org/apache/shardingsphere/sql/parser/doris/visitor/statement/type/DorisDDLStatementVisitor.java
@@ -269,11 +269,11 @@ public final class DorisDDLStatementVisitor extends 
DorisStatementVisitor implem
         if (null != ctx.createTableOptions()) {
             result.setCreateTableOptionSegment((CreateTableOptionSegment) 
visit(ctx.createTableOptions()));
         }
-        // {Doris} ADDED BEGIN
+        // DORIS ADDED BEGIN
         if (null != ctx.duplicateAsQueryExpression()) {
             result.setSelectStatement((SelectStatement) 
visit(ctx.duplicateAsQueryExpression().select()));
         }
-        // {Doris} ADDED END
+        // DORIS ADDED END
         return result;
     }
     
diff --git 
a/parser/sql/statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/dialect/handler/ddl/CreateTableStatementHandler.java
 
b/parser/sql/statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/dialect/handler/ddl/CreateTableStatementHandler.java
index 58ef54d9d2c..1cb1527b7d7 100644
--- 
a/parser/sql/statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/dialect/handler/ddl/CreateTableStatementHandler.java
+++ 
b/parser/sql/statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/dialect/handler/ddl/CreateTableStatementHandler.java
@@ -75,11 +75,11 @@ public final class CreateTableStatementHandler implements 
SQLStatementHandler {
         if (createTableStatement instanceof SQLServerStatement) {
             return createTableStatement.getSelectStatement();
         }
-        // {Doris} ADDED BEGIN
+        // DORIS ADDED BEGIN
         if (createTableStatement instanceof DorisStatement) {
             return createTableStatement.getSelectStatement();
         }
-        // {Doris} ADDED END
+        // DORIS ADDED END
         return Optional.empty();
     }
     
@@ -119,11 +119,11 @@ public final class CreateTableStatementHandler implements 
SQLStatementHandler {
         if (createTableStatement instanceof MySQLCreateTableStatement) {
             return ((MySQLCreateTableStatement) 
createTableStatement).getCreateTableOptionSegment();
         }
-        // {Doris} ADDED BEGIN
+        // DORIS ADDED BEGIN
         if (createTableStatement instanceof DorisCreateTableStatement) {
             return ((DorisCreateTableStatement) 
createTableStatement).getCreateTableOptionSegment();
         }
-        // {Doris} ADDED END
+        // DORIS ADDED END
         return Optional.empty();
     }
 }
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 2915195b7bc..438a74b8b66 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
@@ -2417,8 +2417,8 @@
     </create-table>
     
     <create-table sql-case-id="create_table_with_cast_function1">
-        <table name="yh_ods_bs_class_all" start-index="13" stop-index="43">
-            <owner name="finance_ods" start-index="13" stop-index="23" />
+        <table name="tb_ods_bs_class_all" start-index="13" stop-index="43">
+            <owner name="test_schema" start-index="13" stop-index="23" />
         </table>
         <select>
             <projections start-index="63" stop-index="137">
@@ -2433,8 +2433,8 @@
                 </column-projection>
             </projections>
             <from>
-                <simple-table name="yh_bs_class" alias="jw" start-index="152" 
stop-index="177">
-                    <owner name="finance_ods" start-index="152" 
stop-index="162"/>
+                <simple-table name="tb_bs_class" alias="jw" start-index="152" 
stop-index="177">
+                    <owner name="test_schema" start-index="152" 
stop-index="162"/>
                 </simple-table>
             </from>
             <combine combine-type="UNION_ALL" start-index="240" 
stop-index="775">
@@ -2451,8 +2451,8 @@
                         </column-projection>
                     </projections>
                     <from>
-                        <simple-table name="yh_bs_class" alias="jw" 
start-index="152" stop-index="177">
-                            <owner name="finance_ods" start-index="152" 
stop-index="162"/>
+                        <simple-table name="tb_bs_class" alias="jw" 
start-index="152" stop-index="177">
+                            <owner name="test_schema" start-index="152" 
stop-index="162"/>
                         </simple-table>
                     </from>
                     <where start-index="187" stop-index="230">
@@ -2516,8 +2516,8 @@
                     <from>
                         <join-table join-type="LEFT">
                             <left>
-                                <simple-table name="yh_archive_bs_class" 
start-index="424" stop-index="458" alias="arc">
-                                    <owner name="finance_ods" 
start-index="424" stop-index="434" />
+                                <simple-table name="tb_archive_bs_class" 
start-index="424" stop-index="458" alias="arc">
+                                    <owner name="test_schema" 
start-index="424" stop-index="434" />
                                 </simple-table>
                             </left>
                             <right>
@@ -2528,8 +2528,8 @@
                                                 <column-projection 
name="mother_class_id" start-index="495" stop-index="509"/>
                                             </projections>
                                             <from>
-                                                <simple-table 
name="yh_bs_class" start-index="516" stop-index="538">
-                                                    <owner name="finance_ods" 
start-index="516" stop-index="526"/>
+                                                <simple-table 
name="tb_bs_class" start-index="516" stop-index="538">
+                                                    <owner name="test_schema" 
start-index="516" stop-index="526"/>
                                                 </simple-table>
                                             </from>
                                             <where start-index="557" 
stop-index="600">
@@ -2665,7 +2665,7 @@
     
     <create-table sql-case-id="create_table_with_split">
         <table name="tmp_classcode_property_new" start-index="13" 
stop-index="50">
-            <owner name="finance_ods" start-index="13" stop-index="23" />
+            <owner name="test_schema" start-index="13" stop-index="23" />
         </table>
         <select>
             <projections start-index="70" stop-index="413">
@@ -2738,8 +2738,8 @@
             <from>
                 <join-table join-type="INNER">
                     <left>
-                        <simple-table name="yh_ods_bs_class_all" alias="a" 
start-index="428" stop-index="460">
-                            <owner name="finance_ods" start-index="428" 
stop-index="438"/>
+                        <simple-table name="tb_ods_bs_class_all" alias="a" 
start-index="428" stop-index="460">
+                            <owner name="test_schema" start-index="428" 
stop-index="438"/>
                         </simple-table>
                     </left>
                     <right>
@@ -2750,8 +2750,8 @@
                                         <shorthand-projection 
start-index="498" stop-index="498"/>
                                     </projections>
                                     <from>
-                                        <simple-table 
name="yh_product_course_product" start-index="505" stop-index="541">
-                                            <owner name="finance_ods" 
start-index="505" stop-index="515" />
+                                        <simple-table 
name="tb_product_course_product" start-index="505" stop-index="541">
+                                            <owner name="test_schema" 
start-index="505" stop-index="515" />
                                         </simple-table>
                                     </from>
                                     <where start-index="543" stop-index="586">
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 ae73bbb83a9..76b1422aebe 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
@@ -326,31 +326,31 @@
     <sql-case id="create_table_with_enclosed" value="CREATE TABLE 
emp_load(first_name CHAR(15), last_name CHAR(20), year_of_birth CHAR(4)) 
ORGANIZATION EXTERNAL (TYPE ORACLE_LOADER DEFAULT DIRECTORY ext_tab_dir ACCESS 
PARAMETERS FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '(' and ')'LRTRIM 
LOCATION (info.dat));" db-types="Oracle"/>
     <sql-case id="create_table_with_builtin_function" value="CREATE TABLE tab 
AS SELECT DBMS_LOB.GETLENGTH@dbs2(clob_col) len FROM tab@dbs2;" 
db-types="Oracle"/>
     <sql-case id="create_table_with_autoextend_size" value="CREATE TABLESPACE 
ts1 AUTOEXTEND_SIZE = 4M" db-types="MySQL"/>
-    <sql-case id="create_table_with_cast_function1" value="create table 
finance_ods.yh_ods_bs_class_all as
+    <sql-case id="create_table_with_cast_function1" value="create table 
test_schema.tb_ods_bs_class_all as
         select jw.id,
                jw.product_level_code,
                jw.product_type
-        from finance_ods.yh_bs_class jw
+        from test_schema.tb_bs_class jw
         where if(op_type is null,'0',op_type) != '1'
         union all
         select arc.id,
                cast(arc.ClassScaleType as bigint),
                jw.mother_class_id, -- mother_class_id&#x000A;
                arc.product_type
-        from finance_ods.yh_archive_bs_class arc
-                 left join (select mother_class_id from finance_ods.yh_bs_class
+        from test_schema.tb_archive_bs_class arc
+                 left join (select mother_class_id from test_schema.tb_bs_class
                  where if(op_type is null,'0',op_type) != '1') jw
                            on arc.nSchoolId = jw.NSCHOOLID and arc.sCode = 
jw.SCODE
         where  if(arc.op_type is null,'0',arc.op_type) != '1' and jw.NSCHOOLID 
is null;" db-types="Doris"/>
-    <sql-case id="create_table_with_split" value="create table 
finance_ods.tmp_classcode_property_new as
+    <sql-case id="create_table_with_split" value="create table 
test_schema.tmp_classcode_property_new as
         select a.scode as classcode,
                c.all_layer_value_name,
                split(c.all_layer_value_name,',')[1] as f_dept_name_update,
                split(c.all_layer_value_name,',')[4] as productlevelname_update,
                c.memo,split(c.memo,',')[1] as f_dept_code_update,
                split(c.memo,',')[4] as productlevelcode_update
-        from finance_ods.yh_ods_bs_class_all a
-                 inner join (select * from 
finance_ods.yh_product_course_product where if(op_type is null,'0',op_type) != 
'1') b on aa.course_code_target = b.code
+        from test_schema.tb_ods_bs_class_all a
+                 inner join (select * from 
test_schema.tb_product_course_product where if(op_type is null,'0',op_type) != 
'1') b on aa.course_code_target = b.code
         where coalesce(a.f_dept_code,'') in ('05','16','31')
           and date(a.dtbegindate) >= date('2018-06-01');" db-types="Doris"/>
     <sql-case id="create_table_with_properties" value="CREATE TABLE 
`dim_ehr_all_dimension_dict1` (

Reply via email to