This is an automated email from the ASF dual-hosted git repository.
duanzhengqiang 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 0948786d240 I've verified the SQL statements mentioned in issue 31549,
and all of them can be correctly parsed by the parser. Additionally, I have
added the corresponding SQL cases and case assertions. (#32079)
0948786d240 is described below
commit 0948786d2407ddb6d4ee5625801b6e05b5e4dc56
Author: Richard Liu <[email protected]>
AuthorDate: Fri Jul 12 20:12:15 2024 +0800
I've verified the SQL statements mentioned in issue 31549, and all of them
can be correctly parsed by the parser. Additionally, I have added the
corresponding SQL cases and case assertions. (#32079)
Co-authored-by: richardxliu <[email protected]>
---
.../resources/case/dml/select-special-function.xml | 147 +++++++++++++++++++++
.../sql/supported/dml/select-special-function.xml | 11 ++
2 files changed, 158 insertions(+)
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 0334f2a0d25..71d0e2b15b0 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
@@ -1910,4 +1910,151 @@
</expression-projection>
</projections>
</select>
+
+ <select sql-case-id="select_convert_function_using_character_set">
+ <projections start-index="7" stop-index="34">
+ <expression-projection text="CONVERT('abc' USING utf8mb4)"
start-index="7" stop-index="34">
+ <expr>
+ <function function-name="CONVERT" start-index="7"
stop-index="34" text="CONVERT('abc' USING utf8mb4)">
+ <parameter>
+ <literal-expression value="abc" start-index="15"
stop-index="19" />
+ <using-character-set text="USING utf8mb4"
start-index="20" stop-index="34" />
+ </parameter>
+ </function>
+ </expr>
+ </expression-projection>
+ </projections>
+ </select>
+
+ <select sql-case-id="select_convert_tz_function">
+ <projections start-index="7" stop-index="51">
+ <expression-projection text="CONVERT_TZ('2004-01-01
12:00:00','GMT','MET')" start-index="7" stop-index="51">
+ <expr>
+ <function function-name="CONVERT_TZ" start-index="7"
stop-index="51" text="CONVERT_TZ('2004-01-01 12:00:00','GMT','MET')">
+ <parameter>
+ <literal-expression value="2004-01-01 12:00:00"
start-index="18" stop-index="38" />
+ </parameter>
+ <parameter>
+ <literal-expression value="GMT" start-index="40"
stop-index="44" />
+ </parameter>
+ <parameter>
+ <literal-expression value="MET" start-index="46"
stop-index="50" />
+ </parameter>
+ </function>
+ </expr>
+ </expression-projection>
+ </projections>
+ </select>
+
+ <select sql-case-id="select_cos_function">
+ <projections start-index="7" stop-index="15">
+ <expression-projection text="COS(PI())" start-index="7"
stop-index="15">
+ <expr>
+ <function function-name="COS" start-index="7"
stop-index="15" text="COS(PI())">
+ <parameter>
+ <function function-name="PI" start-index="11"
stop-index="14" text="PI()">
+ </function>
+ </parameter>
+ </function>
+ </expr>
+ </expression-projection>
+ </projections>
+ </select>
+
+ <select sql-case-id="select_cot_function">
+ <projections start-index="7" stop-index="13">
+ <expression-projection text="COT(12)" start-index="7"
stop-index="13">
+ <expr>
+ <function function-name="COT" start-index="7"
stop-index="13" text="COT(12)">
+ <parameter>
+ <literal-expression value="12" start-index="11"
stop-index="12" />
+ </parameter>
+ </function>
+ </expr>
+ </expression-projection>
+ </projections>
+ </select>
+
+ <select sql-case-id="select_crc32_function">
+ <projections start-index="7" stop-index="20">
+ <expression-projection text="CRC32('MySQL')" start-index="7"
stop-index="20">
+ <expr>
+ <function function-name="CRC32" start-index="7"
stop-index="20" text="CRC32('MySQL')">
+ <parameter>
+ <literal-expression value="MySQL" start-index="13"
stop-index="19" />
+ </parameter>
+ </function>
+ </expr>
+ </expression-projection>
+ </projections>
+ </select>
+
+ <select sql-case-id="select_window_with_cume_dist_function">
+ <from>
+ <simple-table name="numbers" start-index="36" stop-index="42" />
+ </from>
+ <projections start-index="7" stop-index="29">
+ <column-projection name="val" start-index="7" stop-index="9" />
+ <expression-projection text="CUME_DIST() OVER()" start-index="12"
stop-index="29">
+ <expr>
+ <function function-name="CUME_DIST" start-index="12"
stop-index="29" text="CUME_DIST() OVER()"/>
+ </expr>
+ </expression-projection>
+ </projections>
+ </select>
+
+ <select sql-case-id="select_curdate_function">
+ <projections start-index="7" stop-index="15">
+ <expression-projection text="CURDATE()" start-index="7"
stop-index="15">
+ <expr>
+ <function function-name="CURDATE" start-index="7"
stop-index="15" text="CURDATE()">
+ </function>
+ </expr>
+ </expression-projection>
+ </projections>
+ </select>
+
+ <select sql-case-id="select_current_date_function">
+ <projections start-index="7" stop-index="20">
+ <expression-projection text="CURRENT_DATE()" start-index="7"
stop-index="20">
+ <expr>
+ <function function-name="CURRENT_DATE" start-index="7"
stop-index="20" text="CURRENT_DATE()">
+ </function>
+ </expr>
+ </expression-projection>
+ </projections>
+ </select>
+
+ <select sql-case-id="select_current_time_function">
+ <projections start-index="7" stop-index="20">
+ <expression-projection text="CURRENT_TIME()" start-index="7"
stop-index="20">
+ <expr>
+ <function function-name="CURRENT_TIME" start-index="7"
stop-index="20" text="CURRENT_TIME()">
+ </function>
+ </expr>
+ </expression-projection>
+ </projections>
+ </select>
+
+ <select sql-case-id="select_current_timestamp_function">
+ <projections start-index="7" stop-index="25">
+ <expression-projection text="CURRENT_TIMESTAMP()" start-index="7"
stop-index="25">
+ <expr>
+ <function function-name="CURRENT_TIMESTAMP"
start-index="7" stop-index="25" text="CURRENT_TIMESTAMP()">
+ </function>
+ </expr>
+ </expression-projection>
+ </projections>
+ </select>
+
+ <select sql-case-id="select_curtime_function">
+ <projections start-index="7" stop-index="15">
+ <expression-projection text="CURTIME()" start-index="7"
stop-index="15">
+ <expr>
+ <function function-name="CURTIME" start-index="7"
stop-index="15" text="CURTIME()">
+ </function>
+ </expr>
+ </expression-projection>
+ </projections>
+ </select>
</sql-parser-test-cases>
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 d710f44b5ee..470640d584f 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
@@ -108,4 +108,15 @@
<sql-case id="select_concat_ws" value="SELECT CONCAT_WS(',', 'First name',
'Second name', 'Last Name')" db-types="MySQL" />
<sql-case id="select_connection_id" value="SELECT CONNECTION_ID()"
db-types="MySQL" />
<sql-case id="select_conv" value="SELECT CONV('a',16,2)" db-types="MySQL"
/>
+ <sql-case id="select_convert_function_using_character_set" value="SELECT
CONVERT('abc' USING utf8mb4)" db-types="MySQL" />
+ <sql-case id="select_convert_tz_function" value="SELECT
CONVERT_TZ('2004-01-01 12:00:00','GMT','MET')" db-types="MySQL" />
+ <sql-case id="select_cos_function" value="SELECT COS(PI())"
db-types="MySQL" />
+ <sql-case id="select_cot_function" value="SELECT COT(12)" db-types="MySQL"
/>
+ <sql-case id="select_crc32_function" value="SELECT CRC32('MySQL')"
db-types="MySQL" />
+ <sql-case id="select_window_with_cume_dist_function" value="SELECT val,
CUME_DIST() OVER() FROM numbers" db-types="MySQL" />
+ <sql-case id="select_curdate_function" value="SELECT CURDATE()"
db-types="MySQL" />
+ <sql-case id="select_current_date_function" value="SELECT CURRENT_DATE()"
db-types="MySQL" />
+ <sql-case id="select_current_time_function" value="SELECT CURRENT_TIME()"
db-types="MySQL" />
+ <sql-case id="select_current_timestamp_function" value="SELECT
CURRENT_TIMESTAMP()" db-types="MySQL" />
+ <sql-case id="select_curtime_function" value="SELECT CURTIME()"
db-types="MySQL" />
</sql-cases>