This is an automated email from the ASF dual-hosted git repository.

panxiaolei pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/doris.git


The following commit(s) were added to refs/heads/master by this push:
     new cfb40ac93be [fix](function) fix extract_url_parameter's bug then get 
the last key (#30929)
cfb40ac93be is described below

commit cfb40ac93bedb7ce20b0245a99cec68a57cea120
Author: lsy3993 <110876560+lsy3...@users.noreply.github.com>
AuthorDate: Sun Feb 18 13:22:24 2024 +0800

    [fix](function) fix extract_url_parameter's bug then get the last key 
(#30929)
    
    fix extract_url_parameter's bug then get the last key
---
 be/src/util/url_parser.cpp                         |  2 +-
 .../function_p0/test_extract_url_parameter.out     |  7 +++
 .../function_p0/test_extract_url_parameter.groovy  | 55 ++++++++++++++++++++++
 3 files changed, 63 insertions(+), 1 deletion(-)

diff --git a/be/src/util/url_parser.cpp b/be/src/util/url_parser.cpp
index ddf09b65cbc..a0bdd153e6b 100644
--- a/be/src/util/url_parser.cpp
+++ b/be/src/util/url_parser.cpp
@@ -389,7 +389,7 @@ StringRef UrlParser::extract_url(StringRef url, StringRef 
name) {
         and_pod = sub_url.find_first_of('&');
         if (and_pod != -1) {
             key_url = sub_url.substring(0, and_pod);
-            sub_url = sub_url.substring(and_pod + 1, len - and_pod);
+            sub_url = sub_url.substring(and_pod + 1, len - and_pod - 1);
         } else {
             auto end_pos = sub_url.find_first_of('#');
             key_url = end_pos == -1 ? sub_url : sub_url.substring(0, end_pos);
diff --git a/regression-test/data/function_p0/test_extract_url_parameter.out 
b/regression-test/data/function_p0/test_extract_url_parameter.out
new file mode 100644
index 00000000000..f240b3d0a6a
--- /dev/null
+++ b/regression-test/data/function_p0/test_extract_url_parameter.out
@@ -0,0 +1,7 @@
+-- This file is automatically generated. You should know what you did if you 
want to edit this
+-- !sql --
+1234   4       123     3       112     3
+
+-- !sql --
+1234   4       123     3       112     3
+
diff --git 
a/regression-test/suites/function_p0/test_extract_url_parameter.groovy 
b/regression-test/suites/function_p0/test_extract_url_parameter.groovy
new file mode 100644
index 00000000000..f8f4435de1e
--- /dev/null
+++ b/regression-test/suites/function_p0/test_extract_url_parameter.groovy
@@ -0,0 +1,55 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+suite("extract_url_parameter") {
+
+    sql """
+        drop table if exists extract_table;
+    """
+    sql """
+    create table extract_table (
+            name varchar(30)
+    ) ENGINE=OLAP
+    UNIQUE KEY(`name`)
+    DISTRIBUTED BY HASH(`name`) BUCKETS 1
+    PROPERTIES (
+            "replication_allocation" = "tag.location.default: 1"
+    );
+    """
+    sql """
+        insert into extract_table values ('?ada=123&bbb=112&ccc=1234')
+    """
+
+    qt_sql """ 
+        select extract_url_parameter(name, 'ccc'), 
length(extract_url_parameter(name, 'ccc')),
+        extract_url_parameter(name, 'ada'), length(extract_url_parameter(name, 
'ada')),
+        extract_url_parameter(name, 'bbb'), length(extract_url_parameter(name, 
'bbb'))
+        from extract_table
+    """
+
+    qt_sql """
+        select 
+        extract_url_parameter('?ada=123&bbb=112&ccc=1234', "ccc"), 
length(extract_url_parameter('?ada=123&bbb=112&ccc=1234', "ccc")),
+        extract_url_parameter('?ada=123&bbb=112&ccc=1234', "ada"), 
length(extract_url_parameter('?ada=123&bbb=112&ccc=1234', "ada")),
+        extract_url_parameter('?ada=123&bbb=112&ccc=1234', "bbb"), 
length(extract_url_parameter('?ada=123&bbb=112&ccc=1234', "bbb"))
+    """
+
+    sql """
+        drop table if exists extract_table;
+    """
+
+}


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org

Reply via email to