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

terrymanu 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 743996c9e75 Support parsing Doris lambda expression, ARRAY type and 
LARGEINT/DATEV2/DATETIMEV2 types (#39523)
743996c9e75 is described below

commit 743996c9e752d3511b9131147e18992a05a38fd6
Author: Liang Zhang <[email protected]>
AuthorDate: Thu Aug 20 00:44:53 2026 +0800

    Support parsing Doris lambda expression, ARRAY type and 
LARGEINT/DATEV2/DATETIMEV2 types (#39523)
    
    Fixes #31489
---
 .../src/main/antlr4/imports/doris/BaseRule.g4      |  25 ++++
 .../src/main/antlr4/imports/doris/DorisKeyword.g4  |  12 ++
 .../src/main/resources/case/ddl/create-table.xml   |  23 ++++
 .../resources/case/dml/select-special-function.xml | 133 +++++++++++++++++++++
 .../resources/sql/supported/ddl/create-table.xml   |   2 +
 .../sql/supported/dml/select-special-function.xml  |   4 +
 6 files changed, 199 insertions(+)

diff --git 
a/parser/sql/engine/dialect/doris/src/main/antlr4/imports/doris/BaseRule.g4 
b/parser/sql/engine/dialect/doris/src/main/antlr4/imports/doris/BaseRule.g4
index e36bb45a36c..9157244f8e7 100644
--- a/parser/sql/engine/dialect/doris/src/main/antlr4/imports/doris/BaseRule.g4
+++ b/parser/sql/engine/dialect/doris/src/main/antlr4/imports/doris/BaseRule.g4
@@ -207,6 +207,10 @@ identifierKeywordsUnambiguous
     | DATA
     | DATETIME
     | DATE
+    // DORIS ADDED BEGIN
+    | DATETIMEV2
+    | DATEV2
+    // DORIS ADDED END
     | DAY
     | DAY_MINUTE
     | DEFAULT_AUTH
@@ -300,6 +304,9 @@ identifierKeywordsUnambiguous
     | KEY_BLOCK_SIZE
     | LABEL
     | LOAD_JOB_ID
+    // DORIS ADDED BEGIN
+    | LARGEINT
+    // DORIS ADDED END
     | LAST
     | LEAVES
     | LESS
@@ -1035,6 +1042,9 @@ simpleExpr
     | caseExpression
     | intervalExpression
     | arrayExpression
+    // DORIS ADDED BEGIN
+    | lambdaExpression
+    // DORIS ADDED END
     ;
 
 arrayExpression
@@ -1042,6 +1052,12 @@ arrayExpression
     | LBT_ RBT_
     ;
 
+// DORIS ADDED BEGIN
+lambdaExpression
+    : (identifier | LP_ identifier (COMMA_ identifier)* RP_) JSON_SEPARATOR 
expr
+    ;
+// DORIS ADDED END
+
 path
     : string_
     ;
@@ -1255,6 +1271,9 @@ castType
     | castTypeName = STRING
     | castTypeName = INT
     | castTypeName = BIGINT
+    | castTypeName = LARGEINT
+    | castTypeName = DATEV2
+    | castTypeName = DATETIMEV2 typeDatetimePrecision?
     // DORIS ADDED END
     ;
 
@@ -1426,6 +1445,12 @@ dataType
     | dataTypeName = STRING
     | dataTypeName = ARRAY
     // DORIS ADDED BEGIN
+    | dataTypeName = ARRAY LT_ dataType GT_
+    | dataTypeName = LARGEINT
+    | dataTypeName = DATEV2
+    | dataTypeName = DATETIMEV2 typeDatetimePrecision?
+    // DORIS ADDED END
+    // DORIS ADDED BEGIN
     | dataTypeName = BITMAP
     // DORIS ADDED END
     ;
diff --git 
a/parser/sql/engine/dialect/doris/src/main/antlr4/imports/doris/DorisKeyword.g4 
b/parser/sql/engine/dialect/doris/src/main/antlr4/imports/doris/DorisKeyword.g4
index d65a309cd48..120f6094333 100644
--- 
a/parser/sql/engine/dialect/doris/src/main/antlr4/imports/doris/DorisKeyword.g4
+++ 
b/parser/sql/engine/dialect/doris/src/main/antlr4/imports/doris/DorisKeyword.g4
@@ -549,6 +549,14 @@ DATETIME
     : D A T E T I M E
     ;
 
+DATETIMEV2
+    : D A T E T I M E V '2'
+    ;
+
+DATEV2
+    : D A T E V '2'
+    ;
+
 DAY
     : D A Y
     ;
@@ -1345,6 +1353,10 @@ LANGUAGE
     : L A N G U A G E
     ;
 
+LARGEINT
+    : L A R G E I N T
+    ;
+
 LAST
     : L A S T
     ;
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 a6e0ebb5a82..bb5bd055b1a 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
@@ -2356,6 +2356,29 @@
         </column-definition>
     </create-table>
 
+    <create-table sql-case-id="create_table_with_array_type_doris" 
db-types="Doris">
+        <table name="t_array_type" start-index="13" stop-index="24" />
+        <column-definition type="INT" start-index="27" stop-index="40">
+            <column name="k" start-index="27" stop-index="27" />
+        </column-definition>
+        <column-definition type="ARRAY" start-index="43" stop-index="73">
+            <column name="array_column" start-index="43" stop-index="54" />
+        </column-definition>
+    </create-table>
+
+    <create-table sql-case-id="create_table_with_doris_types" db-types="Doris">
+        <table name="t_doris_types" start-index="13" stop-index="25" />
+        <column-definition type="LARGEINT" start-index="28" stop-index="44">
+            <column name="order_id" start-index="28" stop-index="35" />
+        </column-definition>
+        <column-definition type="DATEV2" start-index="47" stop-index="63">
+            <column name="order_date" start-index="47" stop-index="56" />
+        </column-definition>
+        <column-definition type="DATETIMEV2" start-index="66" stop-index="86">
+            <column name="order_time" start-index="66" stop-index="75" />
+        </column-definition>
+    </create-table>
+
     <create-table 
sql-case-id="create_table_partition_with_storage_policy_doris" db-types="Doris">
         <table name="create_table_partion_use_created_policy" start-index="13" 
stop-index="51" />
         <column-definition type="DATE" start-index="54" stop-index="60">
diff --git 
a/test/it/parser/src/main/resources/case/dml/select-special-function.xml 
b/test/it/parser/src/main/resources/case/dml/select-special-function.xml
index bcf6156662e..956be6d64b9 100644
--- a/test/it/parser/src/main/resources/case/dml/select-special-function.xml
+++ b/test/it/parser/src/main/resources/case/dml/select-special-function.xml
@@ -5298,6 +5298,139 @@
         </projections>
     </select>
 
+    <select sql-case-id="select_array_first" db-types="Doris">
+        <projections start-index="7" stop-index="57">
+            <expression-projection text="array_first(x -> x >= 3, [1.1, 2.2, 
3.3, 4.4, 5.5])" start-index="7" stop-index="57">
+                <expr>
+                    <function function-name="array_first" text="array_first(x 
-> x >= 3, [1.1, 2.2, 3.3, 4.4, 5.5])" start-index="7" stop-index="57">
+                        <parameter>
+                            <common-expression text="x -> x >= 3" 
start-index="19" stop-index="29" />
+                        </parameter>
+                        <parameter>
+                            <list-expression start-index="32" stop-index="56">
+                                <items>
+                                    <literal-expression value="1.1" 
start-index="33" stop-index="35" />
+                                </items>
+                                <items>
+                                    <literal-expression value="2.2" 
start-index="38" stop-index="40" />
+                                </items>
+                                <items>
+                                    <literal-expression value="3.3" 
start-index="43" stop-index="45" />
+                                </items>
+                                <items>
+                                    <literal-expression value="4.4" 
start-index="48" stop-index="50" />
+                                </items>
+                                <items>
+                                    <literal-expression value="5.5" 
start-index="53" stop-index="55" />
+                                </items>
+                            </list-expression>
+                        </parameter>
+                    </function>
+                </expr>
+            </expression-projection>
+        </projections>
+    </select>
+
+    <select sql-case-id="select_array_first_with_multiple_parameters" 
db-types="Doris">
+        <projections start-index="7" stop-index="78">
+            <expression-projection text="array_first((x, y) -> x > y, [1, 2, 
3, 4, 5], [1.1, 2.2, 3.3, 4.4, 5.5])" start-index="7" stop-index="78">
+                <expr>
+                    <function function-name="array_first" 
text="array_first((x, y) -> x > y, [1, 2, 3, 4, 5], [1.1, 2.2, 3.3, 4.4, 5.5])" 
start-index="7" stop-index="78">
+                        <parameter>
+                            <common-expression text="(x, y) -> x > y" 
start-index="19" stop-index="33" />
+                        </parameter>
+                        <parameter>
+                            <list-expression start-index="36" stop-index="50">
+                                <items>
+                                    <literal-expression value="1" 
start-index="37" stop-index="37" />
+                                </items>
+                                <items>
+                                    <literal-expression value="2" 
start-index="40" stop-index="40" />
+                                </items>
+                                <items>
+                                    <literal-expression value="3" 
start-index="43" stop-index="43" />
+                                </items>
+                                <items>
+                                    <literal-expression value="4" 
start-index="46" stop-index="46" />
+                                </items>
+                                <items>
+                                    <literal-expression value="5" 
start-index="49" stop-index="49" />
+                                </items>
+                            </list-expression>
+                        </parameter>
+                        <parameter>
+                            <list-expression start-index="53" stop-index="77">
+                                <items>
+                                    <literal-expression value="1.1" 
start-index="54" stop-index="56" />
+                                </items>
+                                <items>
+                                    <literal-expression value="2.2" 
start-index="59" stop-index="61" />
+                                </items>
+                                <items>
+                                    <literal-expression value="3.3" 
start-index="64" stop-index="66" />
+                                </items>
+                                <items>
+                                    <literal-expression value="4.4" 
start-index="69" stop-index="71" />
+                                </items>
+                                <items>
+                                    <literal-expression value="5.5" 
start-index="74" stop-index="76" />
+                                </items>
+                            </list-expression>
+                        </parameter>
+                    </function>
+                </expr>
+            </expression-projection>
+        </projections>
+    </select>
+
+    <select sql-case-id="select_array_first_with_empty_array" db-types="Doris">
+        <projections start-index="7" stop-index="33">
+            <expression-projection text="array_first(x -> x > 0, [])" 
start-index="7" stop-index="33">
+                <expr>
+                    <function function-name="array_first" text="array_first(x 
-> x > 0, [])" start-index="7" stop-index="33">
+                        <parameter>
+                            <common-expression text="x -> x > 0" 
start-index="19" stop-index="28" />
+                        </parameter>
+                        <parameter>
+                            <list-expression start-index="31" stop-index="32" 
/>
+                        </parameter>
+                    </function>
+                </expr>
+            </expression-projection>
+        </projections>
+    </select>
+
+    <select sql-case-id="select_cast_to_doris_types" db-types="Doris">
+        <projections start-index="7" stop-index="62">
+            <expression-projection text="CAST(1 AS LARGEINT)" start-index="7" 
stop-index="25">
+                <expr>
+                    <function function-name="CAST" text="CAST(1 AS LARGEINT)" 
start-index="7" stop-index="25">
+                        <parameter>
+                            <literal-expression value="1" start-index="12" 
stop-index="12" />
+                        </parameter>
+                        <parameter>
+                            <data-type value="LARGEINT" start-index="17" 
stop-index="24" />
+                        </parameter>
+                    </function>
+                </expr>
+            </expression-projection>
+            <expression-projection text="CAST('2024-01-01' AS DATETIMEV2(3))" 
start-index="28" stop-index="62">
+                <expr>
+                    <function function-name="CAST" text="CAST('2024-01-01' AS 
DATETIMEV2(3))" start-index="28" stop-index="62">
+                        <parameter>
+                            <literal-expression value="2024-01-01" 
start-index="33" stop-index="44" />
+                        </parameter>
+                        <parameter>
+                            <data-type value="DATETIMEV2" start-index="49" 
stop-index="61">
+                                <data-type-length precision="3" 
start-index="59" stop-index="61" />
+                            </data-type>
+                        </parameter>
+                    </function>
+                </expr>
+            </expression-projection>
+        </projections>
+    </select>
+
     <select sql-case-id="select_last_insert_id">
         <projections start-index="7" stop-index="22">
             <expression-projection start-index="7" stop-index="22" 
text="LAST_INSERT_ID()">
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 0b0936a8842..b97602817f6 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
@@ -397,6 +397,8 @@
         &quot;enable_persistent_index&quot; = &quot;false&quot;,
         &quot;compression&quot; = &quot;LZ4&quot;
             );" db-types="Doris"/>
+    <sql-case id="create_table_with_array_type_doris" value="CREATE TABLE 
t_array_type (k INT NOT NULL, array_column ARRAY&lt;VARCHAR(10)&gt;)" 
db-types="Doris"/>
+    <sql-case id="create_table_with_doris_types" value="CREATE TABLE 
t_doris_types (order_id LARGEINT, order_date DATEV2, order_time DATETIMEV2)" 
db-types="Doris"/>
     <sql-case id="create_table_with_column_default_system_user_function" 
value="CREATE TABLE t (c VARCHAR(288) DEFAULT (SYSTEM_USER()));" 
db-types="MySQL"/>
     <sql-case id="create_table_with_storage_and_lob" value="CREATE TABLE TEST 
(&quot;ID&quot; NUMBER) SEGMENT CREATION IMMEDIATE
     PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255
diff --git 
a/test/it/parser/src/main/resources/sql/supported/dml/select-special-function.xml
 
b/test/it/parser/src/main/resources/sql/supported/dml/select-special-function.xml
index 8c43a42ae0f..0a689e7547f 100644
--- 
a/test/it/parser/src/main/resources/sql/supported/dml/select-special-function.xml
+++ 
b/test/it/parser/src/main/resources/sql/supported/dml/select-special-function.xml
@@ -300,6 +300,10 @@
     <sql-case id="select_cosine_distance_from_table" value="SELECT 
COSINE_DISTANCE([1, 2], [2, 3]) FROM t_order" db-types="Doris" />
     <sql-case id="select_cosine_distance_empty_array" value="SELECT 
COSINE_DISTANCE([], [])" db-types="Doris" />
     <sql-case id="select_cosine_distance_single_element" value="SELECT 
COSINE_DISTANCE([1], [2])" db-types="Doris" />
+    <sql-case id="select_array_first" value="SELECT array_first(x -> x >= 3, 
[1.1, 2.2, 3.3, 4.4, 5.5])" db-types="Doris" />
+    <sql-case id="select_array_first_with_multiple_parameters" value="SELECT 
array_first((x, y) -> x > y, [1, 2, 3, 4, 5], [1.1, 2.2, 3.3, 4.4, 5.5])" 
db-types="Doris" />
+    <sql-case id="select_array_first_with_empty_array" value="SELECT 
array_first(x -> x > 0, [])" db-types="Doris" />
+    <sql-case id="select_cast_to_doris_types" value="SELECT CAST(1 AS 
LARGEINT), CAST('2024-01-01' AS DATETIMEV2(3))" db-types="Doris" />
     <sql-case id="select_last_insert_id" value="SELECT LAST_INSERT_ID()" 
db-types="MySQL" />
     <sql-case id="select_last_value" value="SELECT LAST_VALUE(AGE) OVER 
(PARTITION BY AGE ORDER BY AGE) from TEST" db-types="MySQL" />
     <sql-case id="select_lcase_function" value="SELECT LCASE('QUADRATICALLY')" 
db-types="MySQL" />

Reply via email to