Skip to content

Commit

Permalink
Added support for STRRIGHT alias in Doris (#31508) (#33393)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
danigiri authored Oct 27, 2024
1 parent 2aff226 commit e2f9597
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 4 deletions.
1 change: 1 addition & 0 deletions RELEASE-NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -471,6 +471,9 @@ identifierKeywordsUnambiguous
| STORAGE
| STREAM
| STRING
// DORIS ADDED BEGIN
| STRRIGHT
// DORIS ADDED END
| SUBCLASS_ORIGIN
// | SUBDATE
| SUBJECT
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
;
Expand Down Expand Up @@ -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
;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down Expand Up @@ -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>
Original file line number Diff line number Diff line change
Expand Up @@ -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" />
Expand Down Expand Up @@ -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>

0 comments on commit e2f9597

Please sign in to comment.