Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added EXTRACT_URL_PARAMETER to Doris parsing support (#31508) #33571

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions RELEASE-NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
1. SQL Parser: Support parsing Doris STRRIGHT - [#33393](https://github.com/apache/shardingsphere/pull/33393)
1. SQL Federation: Upgrade calcite version to 1.38.0 and update all license info in LICENSE file - [#33279](https://github.com/apache/shardingsphere/pull/33279)
1. JDBC: Add show database name for JDBC when execute SHOW COMPUTE NODES - [#33437](https://github.com/apache/shardingsphere/pull/33437)
1. Kernel: Add binding to owner table - [#33533](https://github.com/apache/shardingsphere/pull/33533)
1. SQL Parser: Support parsing Doris EXTRACT\_URL\_PARAMETER - [#33571](https://github.com/apache/shardingsphere/pull/33571)
1. JDBC: Support ZonedDateTime on ResultSet - [#33660](https://github.com/apache/shardingsphere/issues/33660)
1. Proxy Native: Change the Base Docker Image of ShardingSphere Proxy Native - [#33263](https://github.com/apache/shardingsphere/issues/33263)
1. Proxy: Add query parameters and check for mysql kill processId - [#33274](https://github.com/apache/shardingsphere/pull/33274)
Expand Down
12 changes: 12 additions & 0 deletions parser/sql/dialect/doris/src/main/antlr4/imports/doris/BaseRule.g4
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,9 @@ identifierKeywordsUnambiguous
| EXPORT
| EXTENDED
| EXTENT_SIZE
// DORIS ADDED BEGIN
| EXTRACT_URL_PARAMETER
// DORIS ADDED END
| FAILED_LOGIN_ATTEMPTS
| FAST
| FAULTS
Expand Down Expand Up @@ -1051,6 +1054,9 @@ specialFunction
| currentUserFunction
| charFunction
| extractFunction
// DORIS ADDED BEGIN
| extractUrlParameterFunction
// DORIS ADDED END
| groupConcatFunction
// DORIS ADDED BEGIN
| instrFunction
Expand Down Expand Up @@ -1159,6 +1165,12 @@ extractFunction
: EXTRACT LP_ intervalUnit FROM expr RP_
;

// DORIS ADDED BEGIN
extractUrlParameterFunction
: EXTRACT_URL_PARAMETER LP_ expr COMMA_ expr RP_
;
// DORIS ADDED END

charFunction
: CHAR LP_ expr (COMMA_ expr)* (USING charsetName)? RP_
;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -765,6 +765,12 @@ EXTENDED
: E X T E N D E D
;

// DORIS ADDED BEGIN
EXTRACT_URL_PARAMETER
: E X T R A C T UL_ U R L UL_ P A R A M E T E R
;
// DORIS ADDED END

EXTENT_SIZE
: E X T E N T UL_ S I Z E
;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
import org.apache.shardingsphere.sql.parser.autogen.DorisStatementParser.EscapedTableReferenceContext;
import org.apache.shardingsphere.sql.parser.autogen.DorisStatementParser.ExprContext;
import org.apache.shardingsphere.sql.parser.autogen.DorisStatementParser.ExtractFunctionContext;
import org.apache.shardingsphere.sql.parser.autogen.DorisStatementParser.ExtractUrlParameterFunctionContext;
import org.apache.shardingsphere.sql.parser.autogen.DorisStatementParser.FieldLengthContext;
import org.apache.shardingsphere.sql.parser.autogen.DorisStatementParser.FieldsContext;
import org.apache.shardingsphere.sql.parser.autogen.DorisStatementParser.FromClauseContext;
Expand Down Expand Up @@ -1008,6 +1009,11 @@ public final ASTNode visitSpecialFunction(final SpecialFunctionContext ctx) {
return visit(ctx.convertFunction());
}
// DORIS ADDED BEGIN
if (null != ctx.extractUrlParameterFunction()) {
return visit(ctx.extractUrlParameterFunction());
}
// DORIS ADDED END
// DORIS ADDED BEGIN
if (null != ctx.instrFunction()) {
return visit(ctx.instrFunction());
}
Expand Down Expand Up @@ -1063,6 +1069,16 @@ public final ASTNode visitBitwiseFunction(final BitwiseFunctionContext ctx) {
}
// DORIS ADDED END

// DORIS ADDED BEGIN
@Override
public final ASTNode visitExtractUrlParameterFunction(final ExtractUrlParameterFunctionContext ctx) {
FunctionSegment result = new FunctionSegment(ctx.getStart().getStartIndex(), ctx.getStop().getStopIndex(), ctx.EXTRACT_URL_PARAMETER().getText(), getOriginalText(ctx));
result.getParameters().add(new LiteralExpressionSegment(ctx.expr(0).getStart().getStartIndex(), ctx.expr(0).getStop().getStopIndex(), ctx.expr(0).getText()));
result.getParameters().add(new LiteralExpressionSegment(ctx.expr(1).getStart().getStartIndex(), ctx.expr(1).getStop().getStopIndex(), ctx.expr(1).getText()));
return result;
}
// DORIS ADDED END

// DORIS ADDED BEGIN
@Override
public final ASTNode visitInstrFunction(final InstrFunctionContext ctx) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4764,7 +4764,22 @@
</expression-projection>
</projections>
</select>

<select sql-case-id="select_extract_url_parameter" db-types="Doris">
<projections start-index="7" stop-index="60">
<expression-projection start-index="7" stop-index="60" text="EXTRACT_URL_PARAMETER('http://foo.com/?bar=baz','bar')">
<expr>
<function function-name="EXTRACT_URL_PARAMETER" text="EXTRACT_URL_PARAMETER('http://foo.com/?bar=baz','bar')" start-index="7" stop-index="60">
<parameter>
<literal-expression value="'http://foo.com/?bar=baz'" start-index="29" stop-index="53" />
</parameter>
<parameter>
<literal-expression value="'bar'" start-index="55" stop-index="59" />
</parameter>
</function>
</expr>
</expression-projection>
</projections>
</select>
<select sql-case-id="select_lcase_function">
<projections start-index="7" stop-index="28">
<expression-projection start-index="7" stop-index="28" text="LCASE('QUADRATICALLY')">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,7 @@
<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-case id="select_extract_url_parameter" value="SELECT EXTRACT_URL_PARAMETER('http://foo.com/?bar=baz','bar')" db-types="Doris" />
<sql-case id="select_lcase_function" value="SELECT LCASE('QUADRATICALLY')" db-types="MySQL" />
<sql-case id="select_lower_function" value="SELECT LOWER('QUADRATICALLY')" db-types="MySQL" />
<sql-case id="select_length" value="SELECT LENGTH('TEXT')" db-types="MySQL" />
Expand Down