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 3624015aeb3 Added EXTRACT_URL_PARAMETER to Doris parsing support 
(#31508) (#33571)
3624015aeb3 is described below

commit 3624015aeb3a2caadcfddc31e7315ba699c35ad7
Author: Daniel Giribet <[email protected]>
AuthorDate: Wed Dec 11 03:33:46 2024 +0100

    Added EXTRACT_URL_PARAMETER to Doris parsing support (#31508) (#33571)
    
    * added extract_url_parameter as extra
    
    - added test
    - added parser g4 in  `extractUrlParameterFunction`
    - added visitor logic
    - ran spotless
    - ran (though will check again once committed and do a full test)
    ```
    cd test/it/parser/
    mvn -DskipTests=true generate-sources compile install -q
    cd parser/sql/dialect/doris/
    mvn test -Dit.test=InternalDorisParserIT
    ```
    
     Question
    - do we collapse two consecutive changes?
    So
    ```
    // DORIS ADDED END
    // DORIS ADDED BEGIN
    ```
    
    would be
    ```
    ```
    
    * fixed test index
    
    * fixed all test indexes
    
    * updated release notes
---
 RELEASE-NOTES.md                                        |  2 ++
 .../doris/src/main/antlr4/imports/doris/BaseRule.g4     | 12 ++++++++++++
 .../doris/src/main/antlr4/imports/doris/DorisKeyword.g4 |  6 ++++++
 .../doris/visitor/statement/DorisStatementVisitor.java  | 16 ++++++++++++++++
 .../main/resources/case/dml/select-special-function.xml | 17 ++++++++++++++++-
 .../sql/supported/dml/select-special-function.xml       |  1 +
 6 files changed, 53 insertions(+), 1 deletion(-)

diff --git a/RELEASE-NOTES.md b/RELEASE-NOTES.md
index a80e8f1c66f..cf068e87abc 100644
--- a/RELEASE-NOTES.md
+++ b/RELEASE-NOTES.md
@@ -22,6 +22,8 @@
 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. Transaction: Bump the minimum Seata Client version for Seata AT integration 
to 2.2.0 - [#33872](https://github.com/apache/shardingsphere/pull/33872)
 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: Add query parameters and check for MySQL kill processId - 
[#33274](https://github.com/apache/shardingsphere/pull/33274)
 1. Proxy: Support table not exist exception for PostgreSQL proxy - 
[#33885](https://github.com/apache/shardingsphere/pull/33274)
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 6a560ccbc42..81e18359d07 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
@@ -231,6 +231,9 @@ identifierKeywordsUnambiguous
     | EXPORT
     | EXTENDED
     | EXTENT_SIZE
+    // DORIS ADDED BEGIN
+    | EXTRACT_URL_PARAMETER
+    // DORIS ADDED END
     | FAILED_LOGIN_ATTEMPTS
     | FAST
     | FAULTS
@@ -1059,6 +1062,9 @@ specialFunction
     | currentUserFunction
     | charFunction
     | extractFunction
+    // DORIS ADDED BEGIN
+    | extractUrlParameterFunction
+    // DORIS ADDED END
     | groupConcatFunction
     // DORIS ADDED BEGIN
     | instrFunction
@@ -1167,6 +1173,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_
     ;
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 57e5d9facf9..447ea9bfdd5 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
@@ -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
     ;
diff --git 
a/parser/sql/dialect/doris/src/main/java/org/apache/shardingsphere/sql/parser/doris/visitor/statement/DorisStatementVisitor.java
 
b/parser/sql/dialect/doris/src/main/java/org/apache/shardingsphere/sql/parser/doris/visitor/statement/DorisStatementVisitor.java
index ef186494f82..ee182a80fcf 100644
--- 
a/parser/sql/dialect/doris/src/main/java/org/apache/shardingsphere/sql/parser/doris/visitor/statement/DorisStatementVisitor.java
+++ 
b/parser/sql/dialect/doris/src/main/java/org/apache/shardingsphere/sql/parser/doris/visitor/statement/DorisStatementVisitor.java
@@ -60,6 +60,7 @@ import 
org.apache.shardingsphere.sql.parser.autogen.DorisStatementParser.EngineR
 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;
@@ -1009,6 +1010,11 @@ public abstract class DorisStatementVisitor extends 
DorisStatementBaseVisitor<AS
             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());
         }
@@ -1077,6 +1083,16 @@ public abstract class DorisStatementVisitor extends 
DorisStatementBaseVisitor<AS
     }
     // 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) {
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 2a297614d7e..dfdcd27b896 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
@@ -4767,7 +4767,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')">
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 178b5e7ef9c..5ade74ba8ce 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
@@ -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" />

Reply via email to