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 e2f95974739 Added support for STRRIGHT alias in Doris (#31508) (#33393)
e2f95974739 is described below
commit e2f95974739e798b5ce7ea95b5b8d7835e0badab
Author: Daniel Giribet <[email protected]>
AuthorDate: Sun Oct 27 08:01:24 2024 +0100
Added support for STRRIGHT alias in Doris (#31508) (#33393)
* Adding parse support for STRRIGHT alias
RIGHT is already implemented and supported by both MySQL and Doris
- Added parsing suppor t for the `STRRIGHT` alias in Doris
- Updated existing tests to reflect that `RIGHT` is also supported by Doris
- Added STRRIGHT tests
- Marked `// DORIS ADDED BEGIN|END` Doris-specific changes
- Added as a `regularFunctionName` which is where `RIGHT` is
* fixed test for STRRIGHT
* updated release notes
* fixed tests (x2)
also removed MySQL as target for the alias
* double checked test results
---
RELEASE-NOTES.md | 1 +
.../doris/src/main/antlr4/imports/doris/BaseRule.g4 | 9 ++++++++-
.../src/main/antlr4/imports/doris/DorisKeyword.g4 | 8 +++++++-
.../resources/case/dml/select-special-function.xml | 18 +++++++++++++++++-
.../sql/supported/dml/select-special-function.xml | 3 ++-
5 files changed, 35 insertions(+), 4 deletions(-)
diff --git a/RELEASE-NOTES.md b/RELEASE-NOTES.md
index 86d5931cfa7..fb2694f3e56 100644
--- a/RELEASE-NOTES.md
+++ b/RELEASE-NOTES.md
@@ -14,6 +14,7 @@
1. Agent: Simplify the use of Agent's Docker Image -
[#33356](https://github.com/apache/shardingsphere/pull/33356)
1. Add arguments not null check when creating RouteUnit -
[#33382](https://github.com/apache/shardingsphere/pull/33382)
1. Add index columns not empty judgement for IndexColumnTokenGenerator -
[#33384](https://github.com/apache/shardingsphere/pull/33384)
+1. SQL Parser: Support parsing Doris STRRIGHT -
[#33393](https://github.com/apache/shardingsphere/pull/33393)
### Bug Fixes
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 48dd6589235..8cf25e65a63 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
@@ -471,6 +471,9 @@ identifierKeywordsUnambiguous
| STORAGE
| STREAM
| STRING
+ // DORIS ADDED BEGIN
+ | STRRIGHT
+ // DORIS ADDED END
| SUBCLASS_ORIGIN
// | SUBDATE
| SUBJECT
@@ -1207,7 +1210,11 @@ regularFunctionName
| DATABASE | SCHEMA | LEFT | RIGHT | DATE | DAY | GEOMETRYCOLLECTION |
REPEAT
| LINESTRING | MULTILINESTRING | MULTIPOINT | MULTIPOLYGON | POINT |
POLYGON
| TIME | TIMESTAMP | TIMESTAMP_ADD | TIMESTAMP_DIFF | DATE |
CURRENT_TIMESTAMP
- | CURRENT_DATE | CURRENT_TIME | UTC_TIMESTAMP | identifier
+ | CURRENT_DATE | CURRENT_TIME | UTC_TIMESTAMP
+ // DORIS ADDED BEGIN
+ | STRRIGHT
+ // DORIS ADDED END
+ | identifier
;
matchExpression
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 ea4003474cc..57e5d9facf9 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
@@ -1073,7 +1073,7 @@ INSTANCE
: I N S T A N C E
;
-// DORIS ADDED BEOIM
+// DORIS ADDED BEGIN
INSTR
: I N S T R
;
@@ -2558,6 +2558,12 @@ STRING
: S T R I N G
;
+// DORIS ADDED BEGIN
+STRRIGHT
+ : S T R R I G H T
+ ;
+// DORIS ADDED END
+
SUBCLASS_ORIGIN
: S U B C L A S S UL_ O R I G I N
;
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 f04eef1ed2c..696568f2e08 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
@@ -2967,7 +2967,7 @@
</projections>
</select>
- <select sql-case-id="select_right">
+ <select sql-case-id="select_right" db-types="MySQL, Doris">
<projections start-index="7" stop-index="27">
<expression-projection start-index="7" stop-index="27"
text="RIGHT('foobarbar', 4)">
<expr>
@@ -4247,4 +4247,20 @@
</expression-projection>
</projections>
</select>
+ <select sql-case-id="select_strright" db-types="Doris">
+ <projections start-index="7" stop-index="29">
+ <expression-projection start-index="7" stop-index="29"
text="STRRIGHT('foobarbar',4)">
+ <expr>
+ <function function-name="STRRIGHT"
text="STRRIGHT('foobarbar',4)" start-index="7" stop-index="29">
+ <parameter>
+ <literal-expression value="foobarbar"
start-index="16" stop-index="26" />
+ </parameter>
+ <parameter>
+ <literal-expression value="4" start-index="28"
stop-index="28" />
+ </parameter>
+ </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 5bbc93a7a18..69b82813984 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
@@ -176,7 +176,7 @@
<sql-case id="select_repeat" value="SELECT REPEAT('MySQL', 3)"
db-types="MySQL" />
<sql-case id="select_replace" value="SELECT REPLACE('www.mysql.com', 'w',
'Ww')" db-types="MySQL" />
<sql-case id="select_reverse" value="SELECT REVERSE('abc')"
db-types="MySQL" />
- <sql-case id="select_right" value="SELECT RIGHT('foobarbar', 4)"
db-types="MySQL" />
+ <sql-case id="select_right" value="SELECT RIGHT('foobarbar', 4)"
db-types="MySQL, Doris" />
<sql-case id="select_roles_graphml" value="SELECT ROLES_GRAPHML()"
db-types="MySQL" />
<sql-case id="select_round" value="SELECT ROUND(1.58)" db-types="MySQL" />
<sql-case id="select_row_count" value="SELECT ROW_COUNT()"
db-types="MySQL" />
@@ -246,4 +246,5 @@
<sql-case id="select_st_crosses" value="SELECT
ST_Crosses(ST_GeomFromText('POINT(1 1)'), ST_GeomFromText('POINT(2 2)'))"
db-types="MySQL,Doris" />
<sql-case id="select_bitxor" value="SELECT BITXOR(3,5)" db-types="Doris" />
<sql-case id="select_instr" value="SELECT INSTR('foobar','bar')"
db-types="Doris" />
+ <sql-case id="select_strright" value="SELECT STRRIGHT('foobarbar',4)"
db-types="Doris" />
</sql-cases>