This is an automated email from the ASF dual-hosted git repository.
lijibing 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 5d97d3a15ed [fix](nereids)Fix dlog1, trim, extract_url_parameter and
parse_url FE constant calculate bug. (#49074)
5d97d3a15ed is described below
commit 5d97d3a15eda37923f62675b504ddd3e653bf405
Author: James <[email protected]>
AuthorDate: Tue Mar 18 21:52:54 2025 +0800
[fix](nereids)Fix dlog1, trim, extract_url_parameter and parse_url FE
constant calculate bug. (#49074)
### What problem does this PR solve?
1. dlog1 should use Math.log
2. trim/ltrim/rtrim shouldn't use regex
3. extract_url_parameter shouldn't fetch ref part.
4. parse_url need to return NULL instream of literal 'null' when we
couldn't get the requested part.
---
.../doris/catalog/BuiltinScalarFunctions.java | 4 +-
.../functions/executable/NumericArithmetic.java | 11 -
.../functions/executable/StringArithmetic.java | 67 ++-
.../trees/expressions/functions/scalar/Dlog1.java | 68 ---
.../expressions/visitor/ScalarFunctionVisitor.java | 5 -
.../fold_constant_numeric_arithmatic.groovy | 47 +-
.../fold_constant_string_arithmatic.groovy | 657 +++++++++++++++++++--
7 files changed, 706 insertions(+), 153 deletions(-)
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/catalog/BuiltinScalarFunctions.java
b/fe/fe-core/src/main/java/org/apache/doris/catalog/BuiltinScalarFunctions.java
index ae638bded38..466503ee47d 100644
---
a/fe/fe-core/src/main/java/org/apache/doris/catalog/BuiltinScalarFunctions.java
+++
b/fe/fe-core/src/main/java/org/apache/doris/catalog/BuiltinScalarFunctions.java
@@ -163,7 +163,6 @@ import
org.apache.doris.nereids.trees.expressions.functions.scalar.Degrees;
import org.apache.doris.nereids.trees.expressions.functions.scalar.Dexp;
import org.apache.doris.nereids.trees.expressions.functions.scalar.Dfloor;
import
org.apache.doris.nereids.trees.expressions.functions.scalar.DigitalMasking;
-import org.apache.doris.nereids.trees.expressions.functions.scalar.Dlog1;
import org.apache.doris.nereids.trees.expressions.functions.scalar.Dlog10;
import org.apache.doris.nereids.trees.expressions.functions.scalar.Domain;
import
org.apache.doris.nereids.trees.expressions.functions.scalar.DomainWithoutWww;
@@ -639,7 +638,6 @@ public class BuiltinScalarFunctions implements
FunctionHelper {
scalar(Dexp.class, "dexp"),
scalar(Dfloor.class, "dfloor"),
scalar(DigitalMasking.class, "digital_masking"),
- scalar(Dlog1.class, "dlog1"),
scalar(Dlog10.class, "dlog10"),
scalar(Domain.class, "domain"),
scalar(DomainWithoutWww.class, "domain_without_www"),
@@ -773,7 +771,7 @@ public class BuiltinScalarFunctions implements
FunctionHelper {
scalar(Length.class, "length"),
scalar(Crc32.class, "crc32"),
scalar(Like.class, "like"),
- scalar(Ln.class, "ln"),
+ scalar(Ln.class, "ln", "dlog1"),
scalar(Locate.class, "locate"),
scalar(Log.class, "log"),
scalar(Log10.class, "log10"),
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/executable/NumericArithmetic.java
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/executable/NumericArithmetic.java
index 50faecf694d..57eda59ee7d 100644
---
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/executable/NumericArithmetic.java
+++
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/executable/NumericArithmetic.java
@@ -1064,17 +1064,6 @@ public class NumericArithmetic {
return checkOutputBoundary(new DoubleLiteral(exp));
}
- /**
- * dlog1
- */
- @ExecFunction(name = "dlog1")
- public static Expression dlog1(DoubleLiteral first) {
- if (inputOutOfBound(first, 0.0d, Double.MAX_VALUE, false, true)) {
- return new NullLiteral(DoubleType.INSTANCE);
- }
- return checkOutputBoundary(new
DoubleLiteral(Math.log1p(first.getValue())));
- }
-
/**
* dlog10
*/
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/executable/StringArithmetic.java
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/executable/StringArithmetic.java
index 85dbb4b273f..06cee19345e 100644
---
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/executable/StringArithmetic.java
+++
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/executable/StringArithmetic.java
@@ -144,13 +144,17 @@ public class StringArithmetic {
if (left) {
do {
result = afterReplace;
- afterReplace = result.replaceFirst("^" + second, "");
+ if (result.startsWith(second)) {
+ afterReplace = result.substring(second.length());
+ }
} while (!afterReplace.equals(result));
}
if (right) {
do {
result = afterReplace;
- afterReplace = result.replaceFirst(second + "$", "");
+ if (result.endsWith(second)) {
+ afterReplace = result.substring(0, result.length() -
second.length());
+ }
} while (!afterReplace.equals(result));
}
return result;
@@ -840,39 +844,71 @@ public class StringArithmetic {
StringBuilder sb = new StringBuilder();
switch (second.getValue().toUpperCase()) {
case "PROTOCOL":
- sb.append(uri.getScheme()); // e.g., http, https
+ String scheme = uri.getScheme();
+ if (scheme == null) {
+ return new NullLiteral(first.getDataType());
+ }
+ sb.append(scheme); // e.g., http, https
break;
case "HOST":
- sb.append(uri.getHost()); // e.g., www.example.com
+ String host = uri.getHost();
+ if (host == null) {
+ return new NullLiteral(first.getDataType());
+ }
+ sb.append(host); // e.g., www.example.com
break;
case "PATH":
- sb.append(uri.getPath()); // e.g., /page
+ String path = uri.getPath();
+ if (path == null) {
+ return new NullLiteral(first.getDataType());
+ }
+ sb.append(path); // e.g., /page
break;
case "REF":
try {
- sb.append(uri.toURL().getRef()); // e.g., /page
+ String ref = uri.toURL().getRef();
+ if (ref == null) {
+ return new NullLiteral(first.getDataType());
+ }
+ sb.append(ref); // e.g., /page
} catch (MalformedURLException e) {
throw new RuntimeException(e);
}
break;
case "AUTHORITY":
- sb.append(uri.getAuthority()); // e.g.,
param1=value1¶m2=value2
+ String authority = uri.getAuthority();
+ if (authority == null) {
+ return new NullLiteral(first.getDataType());
+ }
+ sb.append(authority); // e.g., param1=value1¶m2=value2
break;
case "FILE":
try {
- sb.append(uri.toURL().getFile()); // e.g.,
param1=value1¶m2=value2
+ String file = uri.toURL().getFile();
+ if (file == null) {
+ return new NullLiteral(first.getDataType());
+ }
+ sb.append(file); // e.g., param1=value1¶m2=value2
} catch (MalformedURLException e) {
throw new RuntimeException(e);
}
break;
case "QUERY":
- sb.append(uri.getQuery()); // e.g.,
param1=value1¶m2=value2
+ String query = uri.getQuery();
+ if (query == null) {
+ return new NullLiteral(first.getDataType());
+ }
+ sb.append(query); // e.g., param1=value1¶m2=value2
break;
case "PORT":
sb.append(uri.getPort());
break;
case "USERINFO":
- sb.append(uri.getUserInfo()); // e.g., user:pass
+ String userInfo = uri.getUserInfo();
+ if (userInfo == null) {
+ return new NullLiteral(first.getDataType());
+ }
+ sb.append(userInfo); // e.g., user:pass
break;
default:
throw new RuntimeException("Valid URL parts are 'PROTOCOL',
'HOST', "
@@ -940,10 +976,15 @@ public class StringArithmetic {
if (first.getValue() == null || first.getValue().indexOf('?') == -1) {
return castStringLikeLiteral(first, "");
}
+ URI uri;
+ try {
+ uri = new URI(first.getValue());
+ } catch (URISyntaxException e) {
+ throw new RuntimeException(e);
+ }
- String[] urlParts = first.getValue().split("\\?", -1);
- if (urlParts.length > 1) {
- String query = urlParts[1];
+ String query = uri.getQuery();
+ if (query != null) {
String[] pairs = query.split("&", -1);
for (String pair : pairs) {
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Dlog1.java
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Dlog1.java
deleted file mode 100644
index 399c7dc58de..00000000000
---
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Dlog1.java
+++ /dev/null
@@ -1,68 +0,0 @@
-// 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.
-
-package org.apache.doris.nereids.trees.expressions.functions.scalar;
-
-import org.apache.doris.catalog.FunctionSignature;
-import org.apache.doris.nereids.trees.expressions.Expression;
-import org.apache.doris.nereids.trees.expressions.functions.AlwaysNullable;
-import
org.apache.doris.nereids.trees.expressions.functions.ExplicitlyCastableSignature;
-import org.apache.doris.nereids.trees.expressions.shape.UnaryExpression;
-import org.apache.doris.nereids.trees.expressions.visitor.ExpressionVisitor;
-import org.apache.doris.nereids.types.DoubleType;
-
-import com.google.common.base.Preconditions;
-import com.google.common.collect.ImmutableList;
-
-import java.util.List;
-
-/**
- * ScalarFunction 'dlog1'. This class is generated by GenerateFunction.
- */
-public class Dlog1 extends ScalarFunction
- implements UnaryExpression, ExplicitlyCastableSignature,
AlwaysNullable {
-
- public static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
-
FunctionSignature.ret(DoubleType.INSTANCE).args(DoubleType.INSTANCE)
- );
-
- /**
- * constructor with 1 argument.
- */
- public Dlog1(Expression arg) {
- super("dlog1", arg);
- }
-
- /**
- * withChildren.
- */
- @Override
- public Dlog1 withChildren(List<Expression> children) {
- Preconditions.checkArgument(children.size() == 1);
- return new Dlog1(children.get(0));
- }
-
- @Override
- public List<FunctionSignature> getSignatures() {
- return SIGNATURES;
- }
-
- @Override
- public <R, C> R accept(ExpressionVisitor<R, C> visitor, C context) {
- return visitor.visitDlog1(this, context);
- }
-}
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/visitor/ScalarFunctionVisitor.java
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/visitor/ScalarFunctionVisitor.java
index 9c194434199..d763087d163 100644
---
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/visitor/ScalarFunctionVisitor.java
+++
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/visitor/ScalarFunctionVisitor.java
@@ -170,7 +170,6 @@ import
org.apache.doris.nereids.trees.expressions.functions.scalar.Degrees;
import org.apache.doris.nereids.trees.expressions.functions.scalar.Dexp;
import org.apache.doris.nereids.trees.expressions.functions.scalar.Dfloor;
import
org.apache.doris.nereids.trees.expressions.functions.scalar.DigitalMasking;
-import org.apache.doris.nereids.trees.expressions.functions.scalar.Dlog1;
import org.apache.doris.nereids.trees.expressions.functions.scalar.Dlog10;
import org.apache.doris.nereids.trees.expressions.functions.scalar.Domain;
import
org.apache.doris.nereids.trees.expressions.functions.scalar.DomainWithoutWww;
@@ -1138,10 +1137,6 @@ public interface ScalarFunctionVisitor<R, C> {
return visitScalarFunction(dfloor, context);
}
- default R visitDlog1(Dlog1 dlog1, C context) {
- return visitScalarFunction(dlog1, context);
- }
-
default R visitDlog10(Dlog10 dlog10, C context) {
return visitScalarFunction(dlog10, context);
}
diff --git
a/regression-test/suites/nereids_p0/expression/fold_constant/fold_constant_numeric_arithmatic.groovy
b/regression-test/suites/nereids_p0/expression/fold_constant/fold_constant_numeric_arithmatic.groovy
index f95e28e049a..bc1cb91ca9d 100644
---
a/regression-test/suites/nereids_p0/expression/fold_constant/fold_constant_numeric_arithmatic.groovy
+++
b/regression-test/suites/nereids_p0/expression/fold_constant/fold_constant_numeric_arithmatic.groovy
@@ -24,12 +24,12 @@ suite("fold_constant_numeric_arithmatic") {
sql "set enable_fold_constant_by_be=false"
//Abs function cases
- testFoldConst("SELECT ABS(1)")
- testFoldConst("SELECT ABS(0)")
- testFoldConst("SELECT ABS(-1)")
- testFoldConst("SELECT ABS(1.5)")
- testFoldConst("SELECT ABS(-1.5)")
- testFoldConst("SELECT ABS(1E308)")
+ testFoldConst("SELECT ABS(1)")
+ testFoldConst("SELECT ABS(0)")
+ testFoldConst("SELECT ABS(-1)")
+ testFoldConst("SELECT ABS(1.5)")
+ testFoldConst("SELECT ABS(-1.5)")
+ testFoldConst("SELECT ABS(1E308)")
testFoldConst("SELECT ABS(-1E308)")
testFoldConst("SELECT ABS(NULL)") // NULL handling
testFoldConst("SELECT ABS('')") // Empty string handling
@@ -69,9 +69,9 @@ suite("fold_constant_numeric_arithmatic") {
testFoldConst("SELECT ATAN(1) AS atan_case_1") //atan(1) = π/4
testFoldConst("SELECT ATAN(0) AS atan_case_2") //atan(0) = 0
testFoldConst("SELECT ATAN(-1) AS atan_case_3") //atan(-1)
- testFoldConst("SELECT ATAN(1.5)")
- testFoldConst("SELECT ATAN(-1.5)")
- testFoldConst("SELECT ATAN(1E308)")
+ testFoldConst("SELECT ATAN(1.5)")
+ testFoldConst("SELECT ATAN(-1.5)")
+ testFoldConst("SELECT ATAN(1E308)")
testFoldConst("SELECT ATAN(-1E308)")
testFoldConst("SELECT ATAN(NULL)") // NULL handling
testFoldConst("SELECT ATAN(PI())") // PI input
@@ -84,9 +84,9 @@ suite("fold_constant_numeric_arithmatic") {
testFoldConst("SELECT ATAN2(0, 1) AS atan2_case_2") //atan2(0, 1) = 0
testFoldConst("SELECT ATAN2(1, 0) AS atan2_case_3") //atan2(1, 0) = π/2
testFoldConst("SELECT ATAN2(0, 0) AS atan2_case_exception") //undefined
(returns NULL or error)
- testFoldConst("SELECT ATAN2(1.5, 1.5)")
- testFoldConst("SELECT ATAN2(-1.5, 1.5)")
- testFoldConst("SELECT ATAN2(1E308, 1E308)")
+ testFoldConst("SELECT ATAN2(1.5, 1.5)")
+ testFoldConst("SELECT ATAN2(-1.5, 1.5)")
+ testFoldConst("SELECT ATAN2(1E308, 1E308)")
testFoldConst("SELECT ATAN2(-1E308, 1E308)")
testFoldConst("SELECT ATAN2(NULL, 1)") // NULL y
testFoldConst("SELECT ATAN2(1, NULL)") // NULL x
@@ -98,7 +98,7 @@ suite("fold_constant_numeric_arithmatic") {
testFoldConst("SELECT BIN(16) AS bin_case_2") //bin(16) = 10000
testFoldConst("SELECT BIN(255) AS bin_case_3") //bin(255)
testFoldConst("SELECT BIN(-1) AS bin_case_exception") //returns NULL or
error in some databases
- testFoldConst("SELECT BIN(1E308)")
+ testFoldConst("SELECT BIN(1E308)")
testFoldConst("SELECT BIN(-1E308)")
testFoldConst("SELECT BIN(0)") // Zero case
testFoldConst("SELECT BIN(NULL)") // NULL handling
@@ -112,7 +112,7 @@ suite("fold_constant_numeric_arithmatic") {
testFoldConst("SELECT BIT_COUNT(16) AS bitcount_case_2") //bitcount(16) = 1
testFoldConst("SELECT BIT_COUNT(255) AS bitcount_case_3") //bitcount(255)
= 8
testFoldConst("SELECT BIT_COUNT(-1) AS bitcount_case_exception")
- testFoldConst("SELECT BIT_COUNT(1E308)")
+ testFoldConst("SELECT BIT_COUNT(1E308)")
testFoldConst("SELECT BIT_COUNT(-1E308)")
testFoldConst("SELECT BIT_COUNT(0)") // Zero case
testFoldConst("SELECT BIT_COUNT(NULL)") // NULL handling
@@ -138,7 +138,7 @@ suite("fold_constant_numeric_arithmatic") {
testFoldConst("SELECT CEIL(-3.4) AS ceil_case_2")
testFoldConst("SELECT CEIL(5.0) AS ceil_case_3")
testFoldConst("SELECT CEIL(1E308) AS ceil_case_overflow")
- testFoldConst("SELECT CEIL(1E308)")
+ testFoldConst("SELECT CEIL(1E308)")
testFoldConst("SELECT CEIL(-1E308)")
testFoldConst("SELECT CEIL(NULL)") // NULL handling
testFoldConst("SELECT CEIL(0)") // Zero case
@@ -157,7 +157,7 @@ suite("fold_constant_numeric_arithmatic") {
testFoldConst("SELECT COALESCE(NULL, NULL, 7) AS coalesce_case_2")
testFoldConst("SELECT COALESCE(3, 5) AS coalesce_case_3")
testFoldConst("SELECT COALESCE(NULL, NULL) AS coalesce_case_4")
- testFoldConst("SELECT COALESCE(1E308)")
+ testFoldConst("SELECT COALESCE(1E308)")
testFoldConst("SELECT COALESCE(-1E308)")
testFoldConst("SELECT COALESCE(NULL, NULL, NULL)") // All NULL
testFoldConst("SELECT COALESCE('', NULL, 'test')") // Empty string
@@ -316,6 +316,21 @@ suite("fold_constant_numeric_arithmatic") {
testFoldConst("SELECT LN(0.1)") // Small decimal
testFoldConst("SELECT LN(100)") // Larger number
+//dlog1 function cases
+ testFoldConst("SELECT dlog1(1)")
+ testFoldConst("SELECT dlog1(2.71828)")
+ testFoldConst("SELECT dlog1(10)")
+ testFoldConst("SELECT dlog1(1e10)")
+ testFoldConst("SELECT dlog1(0.1)")
+ testFoldConst("SELECT dlog1(0.001)")
+ testFoldConst("SELECT dlog1(1e-10)")
+ testFoldConst("SELECT dlog1(1e308)")
+ testFoldConst("SELECT dlog1(1e-308)")
+ testFoldConst("SELECT dlog1(0)")
+ testFoldConst("SELECT dlog1(-1)")
+ testFoldConst("SELECT dlog1(-10)")
+ testFoldConst("SELECT dlog1(NULL)")
+
//Log function cases
testFoldConst("SELECT log(100, 10), log(8, 2), log(1000, 10)")
testFoldConst("SELECT LOG(NULL, 10)") // NULL number
diff --git
a/regression-test/suites/nereids_p0/expression/fold_constant/fold_constant_string_arithmatic.groovy
b/regression-test/suites/nereids_p0/expression/fold_constant/fold_constant_string_arithmatic.groovy
index e2dc9bf279b..626d8e87fab 100644
---
a/regression-test/suites/nereids_p0/expression/fold_constant/fold_constant_string_arithmatic.groovy
+++
b/regression-test/suites/nereids_p0/expression/fold_constant/fold_constant_string_arithmatic.groovy
@@ -19,7 +19,7 @@ suite("fold_constant_string_arithmatic") {
sql "set enable_nereids_planner=true"
sql "set enable_fallback_to_original_planner=false"
sql "set enable_fold_constant_by_be=false"
-
+
// append_trailing_char_if_absent
testFoldConst("select append_trailing_char_if_absent('', '!')")
testFoldConst("select append_trailing_char_if_absent(12345, '!')")
@@ -50,7 +50,7 @@ suite("fold_constant_string_arithmatic") {
testFoldConst("select append_trailing_char_if_absent('こんにちは', '!')")
testFoldConst("select append_trailing_char_if_absent('\n\t', '\n')")
testFoldConst("select append_trailing_char_if_absent('こんにちは', 'ちは')")
-
+
// ascii
testFoldConst("select ascii('!')")
testFoldConst("select ascii('1')")
@@ -61,26 +61,26 @@ suite("fold_constant_string_arithmatic") {
testFoldConst("select ascii('안こ')")
testFoldConst("select ascii('')")
testFoldConst("select ascii('中')")
-
+
// bin
testFoldConst("select bin(5)")
testFoldConst("select bin(-5)")
testFoldConst("select bin(9223372036854775807)")
testFoldConst("select bin(9223372036854775808)")
testFoldConst("select bin(-9223372036854775809)")
-
+
// bit_length
testFoldConst("select bit_length('abc')")
testFoldConst("select bit_length(cast('abc' as string))")
testFoldConst("select bit_length('こんにちは世界')")
testFoldConst("select bit_length('안녕하세요 세계!')")
testFoldConst("select bit_length('')")
-
+
// char
testFoldConst("select char(65)")
testFoldConst("select char(-1)")
testFoldConst("select char(65535)")
-
+
// character_length
testFoldConst("select character_length(cast('Hello World' as string))")
testFoldConst("select character_length('Hello World')")
@@ -105,7 +105,7 @@ suite("fold_constant_string_arithmatic") {
testFoldConst("select concat('你好', ' ', '世界')")
testFoldConst("select concat('', '你好', ' ', '世界')")
testFoldConst("select concat('你好', ' ', '世界', '')")
-
+
// concat_ws
testFoldConst("select concat_ws('-', '2024', '09', '02')")
testFoldConst("select concat_ws('', '2024', '09', '02')")
@@ -119,7 +119,7 @@ suite("fold_constant_string_arithmatic") {
testFoldConst("select concat_ws('or', 'd', NULL,'is')")
testFoldConst("select concat_ws(' ', '你好', '世界')")
testFoldConst("select concat_ws(' ', [])")
-
+
// elt
testFoldConst("select elt(0, cast('hello' as string), cast('doris' as
string))")
testFoldConst("select elt(0, 'hello', 'doris')")
@@ -154,7 +154,7 @@ suite("fold_constant_string_arithmatic") {
testFoldConst("select field('=', '+', '=', '=', 'こ')")
testFoldConst("select field('==', '+', '=', '==', 'こ')")
testFoldConst("select field('=', '+', '==', '==', 'こ')")
-
+
// find_in_set
testFoldConst("select find_in_set('a', null)")
testFoldConst("select find_in_set('b', 'a,b,c')")
@@ -179,7 +179,7 @@ suite("fold_constant_string_arithmatic") {
testFoldConst("SELECT find_in_set('','哈哈哈AAA')")
testFoldConst("SELECT find_in_set(',','a,')")
testFoldConst("SELECT find_in_set(',','哈哈哈AAA')")
-
+
// hex
testFoldConst("select hex('@')")
testFoldConst("select hex('1')")
@@ -199,12 +199,12 @@ suite("fold_constant_string_arithmatic") {
testFoldConst("select hex(cast('@' as string))")
testFoldConst("select hex(cast('hello,doris' as string))")
testFoldConst("select hex('hello,doris')")
-
+
// ifnull
testFoldConst("select ifnull(null,3)")
testFoldConst("select ifnull(3,null)")
testFoldConst("select ifnull(null,null)")
-
+
// initcap
testFoldConst("select initcap('AbC123abc abc.abc,?|abc')")
testFoldConst("select initcap(cast('AbC123abc abc.abc,?|abc' as string))")
@@ -352,7 +352,6 @@ suite("fold_constant_string_arithmatic") {
testFoldConst("select initcap('⏩ fast')")
testFoldConst("select initcap('<d83d><dd11>key')")
-
// instr
testFoldConst("select instr('上海天津北京杭州', '北京')")
testFoldConst("select instr('abc', 'b')")
@@ -367,13 +366,13 @@ suite("fold_constant_string_arithmatic") {
testFoldConst("select instr(null, 'a')")
testFoldConst("select instr(NULL, cast('a' as string))")
testFoldConst("select instr('', 'World')")
-
+
// lcase
testFoldConst("select lcase('AbC123')")
testFoldConst("select lcase(cast('AbC123' as string))")
testFoldConst("select lcase('上海天津北京杭州')")
testFoldConst("select lcase('こんにちは')")
-
+
// left
testFoldConst("select left(CAST('good morning' AS STRING), 120)")
testFoldConst("select left(CAST('good morning' AS STRING), -5)")
@@ -396,7 +395,7 @@ suite("fold_constant_string_arithmatic") {
testFoldConst("select left('上海天津北京杭州', 5)")
testFoldConst("select left('上海天津北京杭州', -5)")
testFoldConst("select left('上海天津北京杭州', 0)")
-
+
// length
testFoldConst("select length('你')")
testFoldConst("select length('abc')")
@@ -426,13 +425,13 @@ suite("fold_constant_string_arithmatic") {
testFoldConst("select locate('北京', '上海天津北京杭州', -4)")
testFoldConst("select locate('北京', '上海天津北京杭州', -5)")
testFoldConst("select locate('2', ' 123 ', 1)")
-
+
// lower
testFoldConst("select lower('AbC123')")
testFoldConst("select lower(cast('AbC123' as string))")
testFoldConst("select lower(cast('Hello World' as string))")
testFoldConst("select lower('Hello World')")
-
+
// lpad
testFoldConst("select lpad(cast('hi' as string), 1, cast('xy' as string))")
testFoldConst("select lpad(cast('hi' as string), 5, cast('xy' as string))")
@@ -444,7 +443,7 @@ suite("fold_constant_string_arithmatic") {
testFoldConst("select lpad(' ', 1, 'xy')")
testFoldConst("select lpad(cast('北京' as string), 1, cast('杭州' as string))")
testFoldConst("select lpad(cast('北京' as string), 5, cast('杭州' as string))")
-
+
// ltrim
testFoldConst("select ltrim(' 11111', 11)")
testFoldConst("select ltrim('11111 ', 11)")
@@ -457,7 +456,7 @@ suite("fold_constant_string_arithmatic") {
testFoldConst("select ltrim('Hello')")
testFoldConst("select ltrim(' Hello World ')")
testFoldConst("select ltrim(' 上海天津北京杭州 ')")
-
+
// md5
testFoldConst("select md5(cast('Hello World' as string))")
testFoldConst("select md5('Hello World')")
@@ -478,7 +477,7 @@ suite("fold_constant_string_arithmatic") {
testFoldConst("select money_format(-1123.456)")
testFoldConst("select money_format(-17014116)")
testFoldConst("select money_format(-truncate(1000,10))")
-
+
// not_null_or_empty
testFoldConst("select not_null_or_empty('')")
testFoldConst("select not_null_or_empty('a')")
@@ -489,7 +488,7 @@ suite("fold_constant_string_arithmatic") {
testFoldConst("select not_null_or_empty(NULL)")
testFoldConst("select not_null_or_empty('\b')")
testFoldConst("select not_null_or_empty(' \b')")
-
+
// null_or_empty
testFoldConst("select null_or_empty('')")
testFoldConst("select null_or_empty('a')")
@@ -499,7 +498,7 @@ suite("fold_constant_string_arithmatic") {
testFoldConst("select null_or_empty(NULL)")
testFoldConst("select null_or_empty('\b')")
testFoldConst("select null_or_empty(' \b')")
-
+
// overlay
testFoldConst("select overlay('abcdef', 3, 2, '123')")
testFoldConst("select overlay('abcdef', 10, 20, '123')")
@@ -512,8 +511,7 @@ suite("fold_constant_string_arithmatic") {
testFoldConst("select overlay('עברית', 1, 1, '😀')")
testFoldConst("select overlay('a😀bc', 2, 1, 'x')")
testFoldConst("select overlay('日本語', 2, 2, 'xyz')")
-
-
+
// parse_url
testFoldConst("select
parse_url(cast('http://www.example.com/path?query=abc' as string), cast('HOST'
as string))")
testFoldConst("select parse_url('http://www.example.com/path?query=abc',
'HOST')")
@@ -521,6 +519,122 @@ suite("fold_constant_string_arithmatic") {
testFoldConst("select parse_url('http://www.example.com/path?query=こんにちは',
'QUERY')")
testFoldConst("select
parse_url(\"http://www.example.com/path?query=a\b\'\", 'QUERY')")
testFoldConst("select
parse_url(\"http://www.example.com/path.query=a\b\'\", 'QUERY')")
+ testFoldConst("select PARSE_URL('http://example.com', 'PROTOCOL')")
+ testFoldConst("select PARSE_URL('http://example.com', 'protocol')")
+ testFoldConst("select PARSE_URL('http://example.com', 'Protocol')")
+ testFoldConst("select PARSE_URL('http://example.com', 'HOST')")
+ testFoldConst("select PARSE_URL('http://example.com', 'host')")
+ testFoldConst("select PARSE_URL('http://example.com', 'Host')")
+ testFoldConst("select PARSE_URL('http://example.com', 'PATH')")
+ testFoldConst("select PARSE_URL('http://example.com/path/to/resource',
'path')")
+ testFoldConst("select PARSE_URL('http://example.com/path/to/resource',
'Path')")
+ testFoldConst("select PARSE_URL('http://example.com/path/to/resource',
'PATH')")
+ testFoldConst("select
PARSE_URL('http://example.com/path/to/resource?query=string', 'QUERY')")
+ testFoldConst("select
PARSE_URL('http://example.com/path/to/resource?query=string', 'query')")
+ testFoldConst("select
PARSE_URL('http://example.com/path/to/resource?query=string', 'Query')")
+ testFoldConst("select PARSE_URL('http://user:[email protected]',
'AUTHORITY')")
+ testFoldConst("select PARSE_URL('http://user:[email protected]',
'authority')")
+ testFoldConst("select PARSE_URL('http://user:[email protected]',
'Authority')")
+ testFoldConst("select
PARSE_URL('http://user:[email protected]/path/to/resource', 'FILE')")
+ testFoldConst("select
PARSE_URL('http://user:[email protected]/path/to/resource', 'file')")
+ testFoldConst("select
PARSE_URL('http://user:[email protected]/path/to/resource', 'File')")
+ testFoldConst("select
PARSE_URL('http://user:[email protected]/path/to/resource', 'USERINFO')")
+ testFoldConst("select
PARSE_URL('http://user:[email protected]/path/to/resource', 'userinfo')")
+ testFoldConst("select
PARSE_URL('http://user:[email protected]/path/to/resource', 'UserInfo')")
+ testFoldConst("select
PARSE_URL('http://user:[email protected]:8080/path/to/resource', 'PORT')")
+ testFoldConst("select
PARSE_URL('http://user:[email protected]:8080/path/to/resource', 'port')")
+ testFoldConst("select
PARSE_URL('http://user:[email protected]:8080/path/to/resource', 'Port')")
+ testFoldConst("select PARSE_URL('invalid-url', 'PROTOCOL')")
+ testFoldConst("select PARSE_URL('invalid-url', 'HOST')")
+ testFoldConst("select PARSE_URL('invalid-url', 'PATH')")
+ testFoldConst("select PARSE_URL('', 'PROTOCOL')")
+ testFoldConst("select PARSE_URL(null, 'PROTOCOL')")
+ testFoldConst("select PARSE_URL('https://example.com', 'PROTOCOL')")
+ testFoldConst("select PARSE_URL('ftp://example.com', 'PROTOCOL')")
+ testFoldConst("select
PARSE_URL('http://example.com/path?query=1#fragment', 'QUERY')")
+ testFoldConst("select
PARSE_URL('http://user:[email protected]/path/to/resource', 'AUTHORITY')")
+ testFoldConst("select
PARSE_URL('http://user:[email protected]/path/to/resource', 'FILE')")
+ testFoldConst("select
PARSE_URL('http://user:[email protected]/path/to/resource', 'USERINFO')")
+ testFoldConst("select
PARSE_URL('http://user:[email protected]:8080/path/to/resource', 'PORT')")
+ testFoldConst("select
PARSE_URL('http://example.com/path/to/resource?query=string&another=param',
'QUERY')")
+ testFoldConst("select
PARSE_URL('http://example.com/path/to/resource?query=string&another=param',
'QUERY')")
+ testFoldConst("select
PARSE_URL('http://example.com/path/to/resource?query=string&another=param',
'QUERY')")
+ testFoldConst("select PARSE_URL('http://user:[email protected]',
'USERINFO')")
+ testFoldConst("select PARSE_URL('http://user:[email protected]',
'userinfo')")
+ testFoldConst("select PARSE_URL('http://user:[email protected]',
'UserInfo')")
+ testFoldConst("select
PARSE_URL('http://user:[email protected]/path/to/resource', 'PATH')")
+ testFoldConst("select
PARSE_URL('http://user:[email protected]/path/to/resource', 'path')")
+ testFoldConst("select
PARSE_URL('http://user:[email protected]/path/to/resource', 'Path')")
+ testFoldConst("select
PARSE_URL('http://user:[email protected]/path/to/resource?query=string',
'QUERY')")
+ testFoldConst("select
PARSE_URL('http://user:[email protected]/path/to/resource?query=string',
'query')")
+ testFoldConst("select
PARSE_URL('http://user:[email protected]/path/to/resource?query=string',
'Query')")
+ testFoldConst("select
PARSE_URL('http://user:[email protected]:8080/path/to/resource', 'PORT')")
+ testFoldConst("select
PARSE_URL('http://user:[email protected]:8080/path/to/resource', 'port')")
+ testFoldConst("select
PARSE_URL('http://user:[email protected]:8080/path/to/resource', 'Port')")
+ testFoldConst("select
PARSE_URL('http://example.com/path/to/resource#fragment', 'PATH')")
+ testFoldConst("select
PARSE_URL('http://example.com/path/to/resource#fragment', 'path')")
+ testFoldConst("select
PARSE_URL('http://example.com/path/to/resource#fragment', 'Path')")
+ testFoldConst("select
PARSE_URL('http://example.com/path/to/resource#fragment', 'QUERY')")
+ testFoldConst("select
PARSE_URL('http://example.com/path/to/resource#fragment', 'query')")
+ testFoldConst("select
PARSE_URL('http://example.com/path/to/resource#fragment', 'Query')")
+ testFoldConst("select
PARSE_URL('http://example.com/path/to/resource#fragment', 'AUTHORITY')")
+ testFoldConst("select
PARSE_URL('http://example.com/path/to/resource#fragment', 'authority')")
+ testFoldConst("select
PARSE_URL('http://example.com/path/to/resource#fragment', 'Authority')")
+ testFoldConst("select
PARSE_URL('http://example.com/path/to/resource#fragment', 'FILE')")
+ testFoldConst("select
PARSE_URL('http://example.com/path/to/resource#fragment', 'file')")
+ testFoldConst("select
PARSE_URL('http://example.com/path/to/resource#fragment', 'File')")
+ testFoldConst("select
PARSE_URL('http://user:[email protected]/path/to/resource?query=string&another=param#fragment',
'QUERY')")
+ testFoldConst("select
PARSE_URL('http://user:[email protected]/path/to/resource?query=string&another=param#fragment',
'query')")
+ testFoldConst("select
PARSE_URL('http://user:[email protected]/path/to/resource?query=string&another=param#fragment',
'Query')")
+ testFoldConst("select PARSE_URL('http://user:[email protected]?a=b',
'USERINFO')")
+ testFoldConst("select
PARSE_URL('https://www.example.com/path/to/file?query=string#fragment',
'protocol')")
+ testFoldConst("select
PARSE_URL('ftp://username:password@hostname:21/path/to/file', 'Host')")
+ testFoldConst("select
PARSE_URL('http://example.com:8080/path?query=string#frag', 'path')")
+ testFoldConst("select
PARSE_URL('http://user:[email protected]/path?query=string#frag', 'ref')")
+ testFoldConst("select
PARSE_URL('http://user:[email protected]/path?query=string#frag', 'AUTHORITY')")
+ testFoldConst("select
PARSE_URL('http://user:[email protected]/path?query=string#frag', 'file')")
+ testFoldConst("select
PARSE_URL('http://user:[email protected]/path?query=string#frag', 'USERINFO')")
+ testFoldConst("select
PARSE_URL('http://user:[email protected]:8080/path?query=string#frag', 'port')")
+ testFoldConst("select
PARSE_URL('http://user:[email protected]/path?query=string#frag', 'QUERY')")
+ testFoldConst("select
PARSE_URL('http://user:[email protected]/path?query=string#frag', 'Protocol')")
+ testFoldConst("select
PARSE_URL('http://user:[email protected]/path?query=string#frag', 'host')")
+ testFoldConst("select
PARSE_URL('http://user:[email protected]/path?query=string#frag', 'Path')")
+ testFoldConst("select
PARSE_URL('http://user:[email protected]/path?query=string#frag', 'Ref')")
+ testFoldConst("select
PARSE_URL('http://user:[email protected]/path?query=string#frag', 'Authority')")
+ testFoldConst("select
PARSE_URL('http://user:[email protected]/path?query=string#frag', 'File')")
+ testFoldConst("select
PARSE_URL('http://user:[email protected]/path?query=string#frag', 'Userinfo')")
+ testFoldConst("select
PARSE_URL('http://user:[email protected]/path?query=string#frag', 'Port')")
+ testFoldConst("select
PARSE_URL('http://user:[email protected]/path?query=string#frag', 'Query')")
+ testFoldConst("select PARSE_URL('', 'HOST')")
+ testFoldConst("select PARSE_URL(null, 'HOST')")
+ testFoldConst("select PARSE_URL('not a url', 'HOST')")
+ testFoldConst("select PARSE_URL('http://www.test.com', 'HOST')")
+ testFoldConst("select PARSE_URL('https://www.test.com', 'protocol')")
+ testFoldConst("select
PARSE_URL('ftp://username:password@hostname/path/to/file', 'userinfo')")
+ testFoldConst("select
PARSE_URL('http://user:[email protected]:8080/path/to/file', 'port')")
+ testFoldConst("select
PARSE_URL('http://www.test.com/path/to/file?query=string', 'query')")
+ testFoldConst("select
PARSE_URL('http://www.test.com/path/to/file#fragment', 'ref')")
+ testFoldConst("select
PARSE_URL('http://user:[email protected]/path/to/file', 'authority')")
+ testFoldConst("select PARSE_URL('http://www.test.com/path/to/file',
'file')")
+ testFoldConst("select PARSE_URL('http://www.test.com/', 'path')")
+ testFoldConst("select
PARSE_URL('http://user:[email protected]:8080/path/to/file?query=string#fragment',
'protocol')")
+ testFoldConst("select
PARSE_URL('http://user:[email protected]:8080/path/to/file?query=string#fragment',
'host')")
+ testFoldConst("select
PARSE_URL('http://user:[email protected]:8080/path/to/file?query=string#fragment',
'path')")
+ testFoldConst("select
PARSE_URL('http://user:[email protected]:8080/path/to/file?query=string#fragment',
'ref')")
+ testFoldConst("select
PARSE_URL('http://user:[email protected]:8080/path/to/file?query=string#fragment',
'authority')")
+ testFoldConst("select
PARSE_URL('http://user:[email protected]:8080/path/to/file?query=string#fragment',
'file')")
+ testFoldConst("select
PARSE_URL('http://user:[email protected]:8080/path/to/file?query=string#fragment',
'userinfo')")
+ testFoldConst("select
PARSE_URL('http://user:[email protected]:8080/path/to/file?query=string#fragment',
'port')")
+ testFoldConst("select
PARSE_URL('http://user:[email protected]:8080/path/to/file?query=string#fragment',
'query')")
+ testFoldConst("select
PARSE_URL('http://user:[email protected]:8080/path/to/file?query=string#fragment',
'PROTOcol')")
+ testFoldConst("select
PARSE_URL('http://user:[email protected]:8080/path/to/file?query=string#fragment',
'HOST')")
+ testFoldConst("select
PARSE_URL('http://user:[email protected]:8080/path/to/file?query=string#fragment',
'PATH')")
+ testFoldConst("select
PARSE_URL('http://user:[email protected]:8080/path/to/file?query=string#fragment',
'REF')")
+ testFoldConst("select
PARSE_URL('http://user:[email protected]:8080/path/to/file?query=string#fragment',
'AUTHORITY')")
+ testFoldConst("select
PARSE_URL('http://user:[email protected]:8080/path/to/file?query=string#fragment',
'FILE')")
+ testFoldConst("select
PARSE_URL('http://user:[email protected]:8080/path/to/file?query=string#fragment',
'USERINFO')")
+ testFoldConst("select
PARSE_URL('http://user:[email protected]:8080/path/to/file?query=string#fragment',
'PORT')")
+ testFoldConst("select
PARSE_URL('http://user:[email protected]:8080/path/to/file?query=string#fragment',
'QUERY')")
// repeat
testFoldConst("select repeat('a', 0)")
@@ -538,7 +652,7 @@ suite("fold_constant_string_arithmatic") {
testFoldConst("select repeat('', 3)")
testFoldConst("select repeat(' ', 3)")
testFoldConst("select repeat('前进',4)")
-
+
// replace
testFoldConst("select replace(cast('Hello World' as string), '',
cast('Everyone' as string))")
testFoldConst("select replace(cast('Hello World' as string), cast('World'
as string), '')")
@@ -551,12 +665,12 @@ suite("fold_constant_string_arithmatic") {
testFoldConst("select replace('https://doris.apache.org:9090', ':9090',
'')")
testFoldConst("select replace('https://doris.apache.org:9090', '',
'new_str')")
testFoldConst("select replace('https://doris.apache.org:9090', './*',
'new_str')")
-
+
// reverse
testFoldConst("select reverse('Hello')")
testFoldConst("select reverse('')")
testFoldConst("select reverse('こんにちは')")
-
+
// right
testFoldConst("select right(CAST('good morning' AS STRING), NULL)")
testFoldConst("select right(cast('Hello' as string), 10)")
@@ -575,13 +689,13 @@ suite("fold_constant_string_arithmatic") {
testFoldConst("select right('Hello World', 5)")
testFoldConst("select right('Hello World', 0)")
testFoldConst("select right(NULL, 1)")
-
+
// rpad
testFoldConst("select rpad(cast('hi' as string), 1, cast('xy' as string))")
testFoldConst("select rpad(cast('hi' as string), 5, cast('xy' as string))")
testFoldConst("select rpad('hi', 1, 'xy')")
testFoldConst("select rpad('hi', 5, 'xy')")
-
+
// rtrim
testFoldConst("select rtrim(' 11111', 11)")
testFoldConst("select rtrim('11111 ', 11)")
@@ -591,7 +705,70 @@ suite("fold_constant_string_arithmatic") {
testFoldConst("select rtrim(cast(' Hello World ' as string))")
testFoldConst("select rtrim('Hello')")
testFoldConst("select rtrim(' Hello World ')")
-
+ testFoldConst("select rtrim('abc ')")
+ testFoldConst("select rtrim('abc,,,', ',')")
+ testFoldConst("select rtrim('Aaabc', 'A')")
+ testFoldConst("select rtrim('Aaabc', 'c')")
+ testFoldConst("select rtrim('abc;;;', ';')")
+ testFoldConst("select rtrim('abc, ', ' ,')")
+ testFoldConst("select rtrim(null)")
+ testFoldConst("select rtrim('abc', null)")
+ testFoldConst("select rtrim(null, null)")
+ testFoldConst("select rtrim('abcxyz', 'xyz')")
+ testFoldConst("select rtrim('abcxyxzy', 'xyz')")
+ testFoldConst("select rtrim('')")
+ testFoldConst("select rtrim('', 'a')")
+ testFoldConst("select rtrim(123)")
+ testFoldConst("select rtrim(0)")
+ testFoldConst("select rtrim(true)")
+ testFoldConst("select rtrim('aaaa', 'a')")
+ testFoldConst("select rtrim(' ', ' ')")
+ testFoldConst("select rtrim(substring('abcxx', 1, 4), 'x')")
+ testFoldConst("select rtrim(concat('abc', ' '), ' ')")
+ testFoldConst("select rtrim('中文中', '中')")
+ testFoldConst("select rtrim('中文 ', ' ')")
+ testFoldConst("select rtrim('abc<d83d><dc3c>', '<d83d><dc3c>')")
+ testFoldConst("select rtrim('abc!!!', '!')")
+ testFoldConst("select rtrim('abc123', '123')")
+ testFoldConst("select rtrim('abxyd', 'xy')")
+ testFoldConst("select rtrim('abcabc', 'abc')")
+ testFoldConst("select rtrim(' abc ')")
+ testFoldConst("select rtrim('a bc ', 'c')")
+ testFoldConst("select rtrim('a bc ', ' c')")
+ testFoldConst("select rtrim('abcabab', 'ab')")
+ testFoldConst("select rtrim('abc', 'x')")
+ testFoldConst("select rtrim('abc', 'c')")
+ testFoldConst("select rtrim('a1!B2@c3#', '3#')")
+ testFoldConst("select rtrim(' test ')")
+ testFoldConst("select rtrim('xyzzyxxyz', 'xyz')")
+ testFoldConst("select rtrim('123456123', '123')")
+ testFoldConst("select rtrim('abc,.,', '.,')")
+ testFoldConst("select rtrim('abc[][]', '[]')")
+ testFoldConst("select rtrim('aAaaA', 'A')")
+ testFoldConst("select rtrim('abc', '')")
+ testFoldConst("select rtrim('abc', 'bc')")
+ testFoldConst("select rtrim('abcxyx', 'xy')")
+ testFoldConst("select rtrim('abbaexampleabba', 'ab')")
+ testFoldConst("select rtrim('aBcAb', 'Ab')")
+ testFoldConst("select rtrim('12123412', '12')")
+ testFoldConst("select rtrim('abc', 'abc')")
+ testFoldConst("select rtrim('aaaa', 'a')")
+ testFoldConst("select rtrim('a', 'a')")
+ testFoldConst("select rtrim('aaaa', 'aa')")
+ testFoldConst("select rtrim(';;abc;;', ';')")
+ testFoldConst("select rtrim(' test ')")
+ testFoldConst("select rtrim('xyzzyxxyz', 'xyz')")
+ testFoldConst("select rtrim('123456123', '123')")
+ testFoldConst("select rtrim('.,abc,.,', '.,')")
+ testFoldConst("select rtrim('[][abc][]', '[]')")
+ testFoldConst("select rtrim('<d83d><dc3c>abc<d83d><dc3c>',
'<d83d><dc3c>')")
+ testFoldConst("select rtrim('aAaaA', 'a')")
+ testFoldConst("SELECT RTRIM('こんにちは!😊😊', '😊')")
+ testFoldConst("SELECT RTRIM('안녕하세요.ㅎㅎ', 'ㅎ')")
+ testFoldConst("SELECT RTRIM('¡Hola!😎😎', '😎')")
+ testFoldConst("SELECT RTRIM('Bonjour.ée', 'é')")
+ testFoldConst("SELECT RTRIM('こんにちは! Hello! 😀😀 你好呀~呀', '呀😀')")
+
// space
testFoldConst("select space(-5)")
testFoldConst("select space(5)")
@@ -636,7 +813,7 @@ suite("fold_constant_string_arithmatic") {
testFoldConst("SELECT
split_by_string('a..b\$\$c||d((e))f[[g{{h^^i??j**k++l\\\\m','**')")
testFoldConst("SELECT
split_by_string('a..b\$\$c||d((e))f[[g{{h^^i??j**k++l\\\\m','++')")
testFoldConst("SELECT
split_by_string('a..b\$\$c||d((e))f[[g{{h^^i??j**k++l\\\\m','\\\\')")
-
+
// split_part
testFoldConst("select split_part('a,b,c', '', -2)")
testFoldConst("select split_part('a,b,c', '', -1)")
@@ -746,7 +923,7 @@ suite("fold_constant_string_arithmatic") {
testFoldConst("select starts_with(' hello world','world')")
testFoldConst("select starts_with('上海天津北京杭州','上海')")
testFoldConst("select starts_with('上海天津北京杭州','北京')")
-
+
// strcmp
testFoldConst("select strcmp('a', 'abc')")
testFoldConst("select strcmp('abc', 'abc')")
@@ -760,7 +937,7 @@ suite("fold_constant_string_arithmatic") {
testFoldConst("select strcmp(cast('abc' as string), cast('abd' as
string))")
testFoldConst("select strcmp(cast('abc' as string), NULL)")
testFoldConst("select strcmp(CAST('abcd' AS STRING), CAST('abc' AS
STRING))")
-
+
// strleft
testFoldConst("select strleft('good morning', 120)")
testFoldConst("select strleft('good morning', -5)")
@@ -770,7 +947,7 @@ suite("fold_constant_string_arithmatic") {
testFoldConst("select strleft(' Hello World', 5)")
testFoldConst("select strleft('Hello World ', 50)")
testFoldConst("select strleft(NULL, 1)")
-
+
// strright
testFoldConst("select strright('good morning', NULL)")
testFoldConst("select strright('Hello doris', 120)")
@@ -780,7 +957,7 @@ suite("fold_constant_string_arithmatic") {
testFoldConst("select strright(' Hello World', 5)")
testFoldConst("select strright('Hello World ', 5)")
testFoldConst("select strright(NULL, 1)")
-
+
// sub_replace
testFoldConst("select sub_replace(CAST('doris' AS STRING), CAST('***' AS
STRING), 1, 2)")
testFoldConst("select sub_replace(CAST('doris' AS STRING), CAST('***' AS
STRING), 1, 2)")
@@ -793,7 +970,7 @@ suite("fold_constant_string_arithmatic") {
testFoldConst("select sub_replace(CAST('doris' AS STRING), CAST('***' AS
STRING), -1, 2)")
testFoldConst("select sub_replace('上海天津北京杭州', '天津', 3, 4)")
testFoldConst("select sub_replace('上海天津北京杭州', '天津', 30, 4)")
-
+
// substr
testFoldConst("select substr('a',0,1)")
testFoldConst("select substr('a',-1,1)")
@@ -947,4 +1124,410 @@ suite("fold_constant_string_arithmatic") {
testFoldConst("select
url_encode('http://www.apache.org/licenses/LICENSE-2.0')")
testFoldConst("select url_encode('
http://www.apache.org/licenses/LICENSE-2.0 ')")
+ // extract_url_parameter
+ testFoldConst("select
extract_url_parameter('http://user:[email protected]?a=b', 'a')")
+ testFoldConst("select
extract_url_parameter('http://user:[email protected]?a=b', 'A')")
+ testFoldConst("select
extract_url_parameter('http://user:[email protected]?a=b', 'b')")
+ testFoldConst("select
extract_url_parameter('http://user:[email protected]?a=b', 'B')")
+ testFoldConst("select
extract_url_parameter('http://user:[email protected]?a=b', 'c')")
+ testFoldConst("select
extract_url_parameter('http://user:[email protected]?a=b', 'C')")
+ testFoldConst("select
extract_url_parameter('http://user:[email protected]?a=b', '')")
+ testFoldConst("select
extract_url_parameter('http://user:[email protected]?a=b', null)")
+ testFoldConst("select extract_url_parameter(null, 'a')")
+ testFoldConst("select
extract_url_parameter('http://user:[email protected]?a=b', 'a&b')")
+ testFoldConst("select
extract_url_parameter('http://user:[email protected]?a=b&c=d', 'c')")
+ testFoldConst("select
extract_url_parameter('http://user:[email protected]?a=b&c=d', 'C')")
+ testFoldConst("select
extract_url_parameter('http://user:[email protected]?a=b&c=d', 'd')")
+ testFoldConst("select
extract_url_parameter('http://user:[email protected]?a=b&c=d', 'D')")
+ testFoldConst("select
extract_url_parameter('http://user:[email protected]?a=b&c=d', 'e')")
+ testFoldConst("select
extract_url_parameter('http://user:[email protected]?a=b&c=d', 'E')")
+ testFoldConst("select
extract_url_parameter('http://user:[email protected]?a=b&c=d', '')")
+ testFoldConst("select
extract_url_parameter('http://user:[email protected]?a=b&c=d', null)")
+ testFoldConst("select
extract_url_parameter('http://user:[email protected]?a=b&c=d&e=f', 'e')")
+ testFoldConst("select
extract_url_parameter('http://user:[email protected]?a=b&c=d&e=f', 'E')")
+ testFoldConst("select
extract_url_parameter('http://user:[email protected]?a=b&c=d&e=f', 'f')")
+ testFoldConst("select
extract_url_parameter('http://user:[email protected]?a=b&c=d&e=f', 'F')")
+ testFoldConst("select
extract_url_parameter('http://user:[email protected]?a=b&c=d&e=f', 'g')")
+ testFoldConst("select
extract_url_parameter('http://user:[email protected]?a=b&c=d&e=f', 'G')")
+ testFoldConst("select
extract_url_parameter('http://user:[email protected]?a=b&c=d&e=f', '')")
+ testFoldConst("select
extract_url_parameter('http://user:[email protected]?a=b&c=d&e=f', null)")
+ testFoldConst("select
extract_url_parameter('http://user:[email protected]?a=b&c=d&e=f&g=h', 'g')")
+ testFoldConst("select
extract_url_parameter('http://user:[email protected]?a=b&c=d&e=f&g=h', 'G')")
+ testFoldConst("select
extract_url_parameter('http://user:[email protected]?a=b&c=d&e=f&g=h', 'h')")
+ testFoldConst("select
extract_url_parameter('http://user:[email protected]?a=b&c=d&e=f&g=h', 'H')")
+ testFoldConst("select
extract_url_parameter('http://user:[email protected]?a=b&c=d&e=f&g=h', 'i')")
+ testFoldConst("select
extract_url_parameter('http://user:[email protected]?a=b&c=d&e=f&g=h', 'I')")
+ testFoldConst("select
extract_url_parameter('http://user:[email protected]?a=b&c=d&e=f&g=h', '')")
+ testFoldConst("select
extract_url_parameter('http://user:[email protected]?a=b&c=d&e=f&g=h', null)")
+ testFoldConst("select
extract_url_parameter('http://user:[email protected]?a=b&c=d&e=f&g=h&i=j',
'i')")
+ testFoldConst("select
extract_url_parameter('http://user:[email protected]?a=b&c=d&e=f&g=h&i=j',
'I')")
+ testFoldConst("select
extract_url_parameter('http://user:[email protected]?a=b&c=d&e=f&g=h&i=j',
'j')")
+ testFoldConst("select
extract_url_parameter('http://user:[email protected]?a=b&c=d&e=f&g=h&i=j',
'J')")
+ testFoldConst("select
extract_url_parameter('http://user:[email protected]?a=b&c=d&e=f&g=h&i=j',
'k')")
+ testFoldConst("select
extract_url_parameter('http://user:[email protected]?a=b&c=d&e=f&g=h&i=j',
'K')")
+ testFoldConst("select
extract_url_parameter('http://user:[email protected]?a=b&c=d&e=f&g=h&i=j',
'')")
+ testFoldConst("select
extract_url_parameter('http://user:[email protected]?a=b&c=d&e=f&g=h&i=j',
null)")
+ testFoldConst("select
extract_url_parameter('http://user:[email protected]?a=b&c=d&e=f&g=h&i=j&k=l',
'k')")
+ testFoldConst("select
extract_url_parameter('http://user:[email protected]?a=b&c=d&e=f&g=h&i=j&k=l',
'K')")
+ testFoldConst("select
extract_url_parameter('http://user:[email protected]?a=b&c=d&e=f&g=h&i=j&k=l',
'l')")
+ testFoldConst("select
extract_url_parameter('http://user:[email protected]?a=b&c=d&e=f&g=h&i=j&k=l',
'L')")
+ testFoldConst("select
extract_url_parameter('http://user:[email protected]?a=b&c=d&e=f&g=h&i=j&k=l',
'm')")
+ testFoldConst("select
extract_url_parameter('http://user:[email protected]?a=b&c=d&e=f&g=h&i=j&k=l',
'M')")
+ testFoldConst("select
extract_url_parameter('http://user:[email protected]?a=b&c=d&e=f&g=h&i=j&k=l',
'')")
+ testFoldConst("select
extract_url_parameter('http://user:[email protected]?a=b&c=d&e=f&g=h&i=j&k=l',
null)")
+ testFoldConst("select extract_url_parameter('http://www.example.com?a=b',
'a')")
+ testFoldConst("select extract_url_parameter('http://www.example.com?A=B',
'a')")
+ testFoldConst("select
extract_url_parameter('http://www.example.com?param=value&another=example',
'param')")
+ testFoldConst("select
extract_url_parameter('http://www.example.com?PARAM=value&ANOTHER=example',
'param')")
+ testFoldConst("select
extract_url_parameter('http://www.example.com/path/to/file?query=string',
'query')")
+ testFoldConst("select
extract_url_parameter('http://www.example.com/path/to/file?QUERY=string',
'Query')")
+ testFoldConst("select
extract_url_parameter('http://user:[email protected]/path?query=string#frag',
'query')")
+ testFoldConst("select
extract_url_parameter('http://user:[email protected]/path?QUERY=string#frag',
'Query')")
+ testFoldConst("select
extract_url_parameter('http://www.test.com/?key=value', 'key')")
+ testFoldConst("select
extract_url_parameter('http://www.test.com/?KEY=value', 'Key')")
+ testFoldConst("select extract_url_parameter('http://www.test.com/',
'key')")
+ testFoldConst("select
extract_url_parameter('http://www.test.com/?key1=value1&key2=value2', 'key1')")
+ testFoldConst("select
extract_url_parameter('http://www.test.com/?KEY1=value1&KEY2=value2', 'Key1')")
+ testFoldConst("select extract_url_parameter('', 'key')")
+ testFoldConst("select extract_url_parameter(null, 'key')")
+ testFoldConst("select extract_url_parameter('not a url', 'key')")
+ testFoldConst("select extract_url_parameter('http://www.test.com/?key=',
'key')")
+ testFoldConst("select extract_url_parameter('http://www.test.com/?key',
'key')")
+ testFoldConst("select
extract_url_parameter('http://www.test.com/?key=value&key=value2', 'key')")
+ testFoldConst("select
extract_url_parameter('http://www.test.com/?KEY=value&KEY=value2', 'Key')")
+ testFoldConst("select
extract_url_parameter('http://www.test.com/?key1=value1&key2=value2&key3=value3',
'key2')")
+ testFoldConst("select
extract_url_parameter('http://www.test.com/?KEY1=value1&KEY2=value2&KEY3=value3',
'Key2')")
+ testFoldConst("select
extract_url_parameter('http://www.test.com/path/to/resource?param1=value1¶m2=value2',
'param1')")
+ testFoldConst("select
extract_url_parameter('http://www.test.com/path/to/resource?PARAM1=value1&PARAM2=value2',
'Param1')")
+ testFoldConst("select
extract_url_parameter('http://www.test.com/path/to/resource?param=value&another=example',
'param')")
+ testFoldConst("select
extract_url_parameter('http://www.test.com/path/to/resource?PARAM=value&ANOTHER=example',
'Param')")
+ testFoldConst("select
extract_url_parameter('http://www.test.com/path/to/resource?query=string#fragment',
'query')")
+ testFoldConst("select
extract_url_parameter('http://www.test.com/path/to/resource?QUERY=string#fragment',
'Query')")
+ testFoldConst("select
extract_url_parameter('http://www.test.com/path/to/resource?param1=value1¶m2=value2#fragment',
'param2')")
+ testFoldConst("select
extract_url_parameter('http://www.test.com/path/to/resource?PARAM1=value1&PARAM2=value2#fragment',
'Param2')")
+ testFoldConst("select
extract_url_parameter('http://user:[email protected]:8080/path/to/file?query=string#frag',
'query')")
+ testFoldConst("select
extract_url_parameter('http://user:[email protected]:8080/path/to/file?QUERY=string#frag',
'Query')")
+ testFoldConst("select
extract_url_parameter('http://www.test.com/?key=value&key=value2', 'key')")
+ testFoldConst("select
extract_url_parameter('http://www.test.com/?KEY=value&KEY=value2', 'Key')")
+ testFoldConst("select
extract_url_parameter('http://www.test.com/?key=value&another=value2',
'another')")
+ testFoldConst("select
extract_url_parameter('http://www.test.com/?KEY=value&ANOTHER=value2',
'Another')")
+ testFoldConst("select
extract_url_parameter('http://www.test.com/path/to/file?query=string&query=string2',
'query')")
+ testFoldConst("select
extract_url_parameter('http://www.test.com/path/to/file?QUERY=string&QUERY=string2',
'Query')")
+ testFoldConst("select
extract_url_parameter('http://www.test.com/path/to/file?param=value&another=example&another=example2',
'another')")
+ testFoldConst("select
extract_url_parameter('http://www.test.com/path/to/file?PARAM=value&ANOTHER=example&ANOTHER=example2',
'Another')")
+ testFoldConst("select
extract_url_parameter('http://www.test.com/path/to/file?param=value&another=example&another=example2¶m=value2',
'param')")
+ testFoldConst("select
extract_url_parameter('http://www.test.com/path/to/file?PARAM=value&ANOTHER=example&ANOTHER=example2&PARAM=value2',
'Param')")
+ testFoldConst("select
extract_url_parameter('http://www.test.com/path/to/file?param=value&another=example&another=example2¶m=value2',
'missing')")
+ testFoldConst("select
extract_url_parameter('http://www.test.com/path/to/file?PARAM=value&ANOTHER=example&ANOTHER=example2&PARAM=value2',
'Missing')")
+ testFoldConst("select extract_url_parameter('http://example.com?a=b',
'a')")
+ testFoldConst("select extract_url_parameter('http://example.com?a=b',
'A')")
+ testFoldConst("select extract_url_parameter('http://example.com?a=b',
'Aa')")
+ testFoldConst("select extract_url_parameter('http://example.com?a=b&c=d',
'c')")
+ testFoldConst("select extract_url_parameter('http://example.com?a=b&c=d',
'C')")
+ testFoldConst("select extract_url_parameter('http://example.com?a=b&c=D',
'd')")
+ testFoldConst("select
extract_url_parameter('http://example.com/path/to/resource?a=b', 'a')")
+ testFoldConst("select
extract_url_parameter('http://example.com/path/to/resource?a=b', 'A')")
+ testFoldConst("select
extract_url_parameter('http://example.com/path/to/resource?a=b&c=d', 'c')")
+ testFoldConst("select
extract_url_parameter('http://example.com/path/to/resource?a=b&c=d', 'C')")
+ testFoldConst("select
extract_url_parameter('http://example.com/path/to/resource?a=b&c=D', 'd')")
+ testFoldConst("select
extract_url_parameter('http://user:[email protected]?a=b', 'a')")
+ testFoldConst("select
extract_url_parameter('http://user:[email protected]?a=b', 'A')")
+ testFoldConst("select
extract_url_parameter('http://user:[email protected]?a=b&c=d', 'c')")
+ testFoldConst("select
extract_url_parameter('http://user:[email protected]?a=b&c=d', 'C')")
+ testFoldConst("select
extract_url_parameter('http://user:[email protected]?a=b&c=D', 'd')")
+ testFoldConst("select
extract_url_parameter('http://example.com:8080/path/to/resource?a=b', 'a')")
+ testFoldConst("select
extract_url_parameter('http://example.com:8080/path/to/resource?a=b', 'A')")
+ testFoldConst("select
extract_url_parameter('http://example.com:8080/path/to/resource?a=b&c=d', 'c')")
+ testFoldConst("select
extract_url_parameter('http://example.com:8080/path/to/resource?a=b&c=d', 'C')")
+ testFoldConst("select
extract_url_parameter('http://example.com:8080/path/to/resource?a=b&c=D', 'd')")
+ testFoldConst("select extract_url_parameter('invalid-url', 'a')")
+ testFoldConst("select extract_url_parameter('invalid-url', 'A')")
+ testFoldConst("select extract_url_parameter('', 'a')")
+ testFoldConst("select extract_url_parameter(null, 'a')")
+ testFoldConst("select extract_url_parameter('http://example.com', 'a')")
+ testFoldConst("select extract_url_parameter('http://example.com', 'A')")
+ testFoldConst("select extract_url_parameter('http://example.com/?a=b',
'a')")
+ testFoldConst("select extract_url_parameter('http://example.com/?a=b',
'A')")
+ testFoldConst("select extract_url_parameter('http://example.com/?a=b&c=d',
'c')")
+ testFoldConst("select extract_url_parameter('http://example.com/?a=b&c=d',
'C')")
+ testFoldConst("select extract_url_parameter('http://example.com/?a=b&c=D',
'd')")
+ testFoldConst("select
extract_url_parameter('http://example.com/path/to/resource', 'a')")
+ testFoldConst("select
extract_url_parameter('http://example.com/path/to/resource', 'A')")
+ testFoldConst("select
extract_url_parameter('http://example.com/path/to/resource?a=b', 'b')")
+ testFoldConst("select
extract_url_parameter('http://example.com/path/to/resource?a=b', 'B')")
+ testFoldConst("select
extract_url_parameter('http://example.com/path/to/resource?a=b&c=d', 'b')")
+ testFoldConst("select
extract_url_parameter('http://example.com/path/to/resource?a=b&c=d', 'B')")
+ testFoldConst("select
extract_url_parameter('http://example.com/path/to/resource?a=b&c=D', 'd')")
+ testFoldConst("select
extract_url_parameter('http://user:[email protected]/path/to/resource', 'a')")
+ testFoldConst("select
extract_url_parameter('http://user:[email protected]/path/to/resource', 'A')")
+ testFoldConst("select
extract_url_parameter('http://user:[email protected]/path/to/resource?a=b',
'b')")
+ testFoldConst("select
extract_url_parameter('http://user:[email protected]/path/to/resource?a=b',
'B')")
+ testFoldConst("select
extract_url_parameter('http://user:[email protected]/path/to/resource?a=b&c=d',
'b')")
+ testFoldConst("select
extract_url_parameter('http://user:[email protected]/path/to/resource?a=b&c=d',
'B')")
+ testFoldConst("select
extract_url_parameter('http://user:[email protected]/path/to/resource?a=b&c=D',
'd')")
+ testFoldConst("select
extract_url_parameter('http://example.com:8080/path/to/resource', 'a')")
+ testFoldConst("select
extract_url_parameter('http://example.com:8080/path/to/resource', 'A')")
+ testFoldConst("select
extract_url_parameter('http://example.com:8080/path/to/resource?a=b', 'b')")
+ testFoldConst("select
extract_url_parameter('http://example.com:8080/path/to/resource?a=b', 'B')")
+ testFoldConst("select
extract_url_parameter('http://example.com:8080/path/to/resource?a=b&c=d', 'b')")
+ testFoldConst("select
extract_url_parameter('http://example.com:8080/path/to/resource?a=b&c=d', 'B')")
+ testFoldConst("select
extract_url_parameter('http://example.com:8080/path/to/resource?a=b&c=D', 'd')")
+ testFoldConst("select extract_url_parameter('invalid-url', 'b')")
+ testFoldConst("select extract_url_parameter('invalid-url', 'B')")
+ testFoldConst("select extract_url_parameter('', 'b')")
+ testFoldConst("select extract_url_parameter(null, 'b')")
+ testFoldConst("select extract_url_parameter('http://example.com', 'b')")
+ testFoldConst("select extract_url_parameter('http://example.com', 'B')")
+ testFoldConst("select
extract_url_parameter('http://example.com/?a=b&c=d&e=f', 'e')")
+ testFoldConst("select
extract_url_parameter('http://example.com/?a=b&c=d&e=f', 'E')")
+ testFoldConst("select
extract_url_parameter('http://example.com/path/to/resource?a=b&c=d&e=f', 'e')")
+ testFoldConst("select
extract_url_parameter('http://example.com/path/to/resource?a=b&c=d&e=f', 'E')")
+ testFoldConst("select
extract_url_parameter('http://user:[email protected]/path/to/resource?a=b&c=d&e=f',
'e')")
+ testFoldConst("select
extract_url_parameter('http://user:[email protected]/path/to/resource?a=b&c=d&e=f',
'E')")
+ testFoldConst("select
extract_url_parameter('http://example.com:8080/path/to/resource?a=b&c=d&e=f',
'e')")
+ testFoldConst("select
extract_url_parameter('http://example.com:8080/path/to/resource?a=b&c=d&e=f',
'E')")
+ testFoldConst("select extract_url_parameter('http://example.com?a=b',
'a')")
+ testFoldConst("select extract_url_parameter('http://example.com?a=b',
'A')")
+ testFoldConst("select extract_url_parameter('http://example.com?a=b',
'α')")
+ testFoldConst("select extract_url_parameter('http://example.com?a=b',
'β')")
+ testFoldConst("select extract_url_parameter('http://example.com?a=b',
'中文')")
+ testFoldConst("select extract_url_parameter('http://example.com?a=b',
'日本語')")
+ testFoldConst("select extract_url_parameter('http://example.com?a=b',
'한국어')")
+ testFoldConst("select extract_url_parameter('http://example.com?a=b',
'русский')")
+ testFoldConst("select extract_url_parameter('http://example.com?a=b',
'עברית')")
+ testFoldConst("select extract_url_parameter('http://example.com?a=b',
'😀')")
+ testFoldConst("select extract_url_parameter('http://example.com?a=b',
'a😀b')")
+ testFoldConst("select extract_url_parameter('http://example.com?a=b&c=d',
'c')")
+ testFoldConst("select extract_url_parameter('http://example.com?a=b&c=d',
'C')")
+ testFoldConst("select extract_url_parameter('http://example.com?a=b&c=D',
'd')")
+ testFoldConst("select
extract_url_parameter('http://example.com/path/to/resource?a=b', 'a')")
+ testFoldConst("select
extract_url_parameter('http://example.com/path/to/resource?a=b', 'A')")
+ testFoldConst("select
extract_url_parameter('http://example.com/path/to/resource?a=b&c=d', 'c')")
+ testFoldConst("select
extract_url_parameter('http://example.com/path/to/resource?a=b&c=d', 'C')")
+ testFoldConst("select
extract_url_parameter('http://example.com/path/to/resource?a=b&c=D', 'd')")
+ testFoldConst("select
extract_url_parameter('http://user:[email protected]?a=b', 'a')")
+ testFoldConst("select
extract_url_parameter('http://user:[email protected]?a=b', 'A')")
+ testFoldConst("select
extract_url_parameter('http://user:[email protected]?a=b&c=d', 'c')")
+ testFoldConst("select
extract_url_parameter('http://user:[email protected]?a=b&c=d', 'C')")
+ testFoldConst("select
extract_url_parameter('http://user:[email protected]?a=b&c=D', 'd')")
+ testFoldConst("select
extract_url_parameter('http://example.com:8080/path/to/resource?a=b', 'a')")
+ testFoldConst("select
extract_url_parameter('http://example.com:8080/path/to/resource?a=b', 'A')")
+ testFoldConst("select
extract_url_parameter('http://example.com:8080/path/to/resource?a=b&c=d', 'c')")
+ testFoldConst("select
extract_url_parameter('http://example.com:8080/path/to/resource?a=b&c=d', 'C')")
+ testFoldConst("select
extract_url_parameter('http://example.com:8080/path/to/resource?a=b&c=D', 'd')")
+ testFoldConst("select extract_url_parameter('invalid-url', 'a')")
+ testFoldConst("select extract_url_parameter('invalid-url', 'A')")
+ testFoldConst("select extract_url_parameter('', 'a')")
+ testFoldConst("select extract_url_parameter(null, 'a')")
+ testFoldConst("select extract_url_parameter('http://example.com', 'a')")
+ testFoldConst("select extract_url_parameter('http://example.com', 'A')")
+ testFoldConst("select extract_url_parameter('http://example.com/?a=b',
'a')")
+ testFoldConst("select extract_url_parameter('http://example.com/?a=b',
'A')")
+ testFoldConst("select extract_url_parameter('http://example.com/?a=b&c=d',
'c')")
+ testFoldConst("select extract_url_parameter('http://example.com/?a=b&c=d',
'C')")
+ testFoldConst("select extract_url_parameter('http://example.com/?a=b&c=D',
'd')")
+ testFoldConst("select
extract_url_parameter('http://example.com/path/to/resource', 'a')")
+ testFoldConst("select
extract_url_parameter('http://example.com/path/to/resource', 'A')")
+ testFoldConst("select
extract_url_parameter('http://example.com/path/to/resource?a=b', 'b')")
+ testFoldConst("select
extract_url_parameter('http://example.com/path/to/resource?a=b', 'B')")
+ testFoldConst("select
extract_url_parameter('http://example.com/path/to/resource?a=b&c=d', 'b')")
+ testFoldConst("select
extract_url_parameter('http://example.com/path/to/resource?a=b&c=d', 'B')")
+ testFoldConst("select
extract_url_parameter('http://example.com/path/to/resource?a=b&c=D', 'd')")
+ testFoldConst("select
extract_url_parameter('http://user:[email protected]/path/to/resource', 'a')")
+ testFoldConst("select
extract_url_parameter('http://user:[email protected]/path/to/resource', 'A')")
+ testFoldConst("select
extract_url_parameter('http://user:[email protected]/path/to/resource?a=b',
'b')")
+ testFoldConst("select
extract_url_parameter('http://user:[email protected]/path/to/resource?a=b',
'B')")
+ testFoldConst("select
extract_url_parameter('http://user:[email protected]/path/to/resource?a=b&c=d',
'b')")
+ testFoldConst("select
extract_url_parameter('http://user:[email protected]/path/to/resource?a=b&c=d',
'B')")
+ testFoldConst("select
extract_url_parameter('http://user:[email protected]/path/to/resource?a=b&c=D',
'd')")
+ testFoldConst("select
extract_url_parameter('http://example.com:8080/path/to/resource', 'a')")
+ testFoldConst("select
extract_url_parameter('http://example.com:8080/path/to/resource', 'A')")
+ testFoldConst("select
extract_url_parameter('http://example.com:8080/path/to/resource?a=b', 'b')")
+ testFoldConst("select
extract_url_parameter('http://example.com:8080/path/to/resource?a=b', 'B')")
+ testFoldConst("select
extract_url_parameter('http://example.com:8080/path/to/resource?a=b&c=d', 'b')")
+ testFoldConst("select
extract_url_parameter('http://example.com:8080/path/to/resource?a=b&c=d', 'B')")
+ testFoldConst("select
extract_url_parameter('http://example.com:8080/path/to/resource?a=b&c=D', 'd')")
+ testFoldConst("select extract_url_parameter('invalid-url', 'b')")
+ testFoldConst("select extract_url_parameter('invalid-url', 'B')")
+ testFoldConst("select extract_url_parameter('', 'b')")
+ testFoldConst("select extract_url_parameter(null, 'b')")
+ testFoldConst("select extract_url_parameter('http://example.com', 'b')")
+ testFoldConst("select extract_url_parameter('http://example.com', 'B')")
+ testFoldConst("select
extract_url_parameter('http://example.com/?a=b&c=d&e=f', 'e')")
+ testFoldConst("select
extract_url_parameter('http://example.com/?a=b&c=d&e=f', 'E')")
+ testFoldConst("select
extract_url_parameter('http://example.com/path/to/resource?a=b&c=d&e=f', 'e')")
+ testFoldConst("select
extract_url_parameter('http://example.com/path/to/resource?a=b&c=d&e=f', 'E')")
+ testFoldConst("select
extract_url_parameter('http://user:[email protected]/path/to/resource?a=b&c=d&e=f',
'e')")
+ testFoldConst("select
extract_url_parameter('http://user:[email protected]/path/to/resource?a=b&c=d&e=f',
'E')")
+ testFoldConst("select
extract_url_parameter('http://example.com:8080/path/to/resource?a=b&c=d&e=f',
'e')")
+ testFoldConst("select
extract_url_parameter('http://example.com:8080/path/to/resource?a=b&c=d&e=f',
'E')")
+ testFoldConst("select
extract_url_parameter('http://example.com/path/to/resource?a=😀b', '😀b')")
+ testFoldConst("select
extract_url_parameter('http://example.com/path/to/resource?a=😀b', '😀B')")
+ testFoldConst("select
extract_url_parameter('http://example.com/path/to/resource?a=αβγ', 'αβγ')")
+ testFoldConst("select
extract_url_parameter('http://example.com/path/to/resource?a=αβγ', 'ΑΒΓ')")
+ testFoldConst("select
extract_url_parameter('http://example.com/path/to/resource?a=中文', '中文')")
+ testFoldConst("select
extract_url_parameter('http://example.com/path/to/resource?a=中文', '中文')")
+ testFoldConst("select
extract_url_parameter('http://example.com/path/to/resource?a=日本語', '日本語')")
+ testFoldConst("select
extract_url_parameter('http://example.com/path/to/resource?a=日本語', '日本語')")
+ testFoldConst("select
extract_url_parameter('http://example.com/path/to/resource?a=한국어', '한국어')")
+ testFoldConst("select
extract_url_parameter('http://example.com/path/to/resource?a=한국어', '한국어')")
+ testFoldConst("select
extract_url_parameter('http://example.com/path/to/resource?a=русский',
'русский')")
+ testFoldConst("select
extract_url_parameter('http://example.com/path/to/resource?a=русский',
'русский')")
+ testFoldConst("select
extract_url_parameter('http://example.com/path/to/resource?a=עברית', 'עברית')")
+ testFoldConst("select
extract_url_parameter('http://example.com/path/to/resource?a=עברית', 'עברית')")
+ testFoldConst("select extract_url_parameter('http://www.example.com?a=b',
'a')")
+ testFoldConst("select extract_url_parameter('http://www.example.com?A=B',
'a')")
+ testFoldConst("select extract_url_parameter('http://www.example.com?α=β',
'α')")
+ testFoldConst("select extract_url_parameter('http://www.example.com?你=好',
'你')")
+ testFoldConst("select
extract_url_parameter('http://www.example.com?こ=んにちは', 'こ')")
+ testFoldConst("select
extract_url_parameter('http://www.example.com?안녕=하세요', '안녕')")
+ testFoldConst("select
extract_url_parameter('http://www.example.com?привет=мир', 'привет')")
+ testFoldConst("select
extract_url_parameter('http://www.example.com?שָׁלוֹם=עֲלֵיכֶם', 'שָׁלוֹם')")
+ testFoldConst("select extract_url_parameter('http://www.example.com?😊=👍',
'😊')")
+ testFoldConst("select
extract_url_parameter('http://www.example.com?%20key=value', '%20key')")
+ testFoldConst("select extract_url_parameter('http://www.test.com/',
'key')")
+ testFoldConst("select extract_url_parameter('', 'key')")
+ testFoldConst("select extract_url_parameter(null, 'key')")
+ testFoldConst("select extract_url_parameter('not a url', 'key')")
+ testFoldConst("select extract_url_parameter('http://www.test.com/?key=',
'key')")
+ testFoldConst("select extract_url_parameter('http://www.test.com/?key',
'key')")
+ testFoldConst("select
extract_url_parameter('http://www.test.com/?key=value&key=value2', 'key')")
+ testFoldConst("select
extract_url_parameter('http://www.test.com/?α=β&α=γ', 'α')")
+ testFoldConst("select
extract_url_parameter('http://www.test.com/?你=好&你=世界', '你')")
+ testFoldConst("select
extract_url_parameter('http://www.test.com/?こ=んにちは&こ=さようなら', 'こ')")
+ testFoldConst("select
extract_url_parameter('http://www.test.com/?안녕=하세요&안녕=감사합니다', '안녕')")
+ testFoldConst("select
extract_url_parameter('http://www.test.com/?привет=мир&привет=мир2', 'привет')")
+ testFoldConst("select
extract_url_parameter('http://www.test.com/?שָׁלוֹם=עֲלֵיכֶם&שָׁלוֹם=שלום',
'שָׁלוֹם')")
+ testFoldConst("select
extract_url_parameter('http://www.test.com/?😊=👍&😊=😊', '😊')")
+ testFoldConst("select
extract_url_parameter('http://www.test.com/?%20key=value&%20key=value2',
'%20key')")
+ testFoldConst("select
extract_url_parameter('http://www.test.com/?key1=value1&key2=value2', 'key1')")
+ testFoldConst("select
extract_url_parameter('http://www.test.com/?α=value1&β=value2', 'α')")
+ testFoldConst("select
extract_url_parameter('http://www.test.com/?你=value1&好=value2', '你')")
+ testFoldConst("select
extract_url_parameter('http://www.test.com/?こ=value1&んにちは=value2', 'こ')")
+ testFoldConst("select
extract_url_parameter('http://www.test.com/?안녕=value1&하세요=value2', '안녕')")
+ testFoldConst("select
extract_url_parameter('http://www.test.com/?привет=value1&мир=value2',
'привет')")
+ testFoldConst("select
extract_url_parameter('http://www.test.com/?שָׁלוֹם=value1&עֲלֵיכֶם=value2',
'שָׁלוֹם')")
+ testFoldConst("select
extract_url_parameter('http://www.test.com/?😊=value1&👍=value2', '😊')")
+ testFoldConst("select
extract_url_parameter('http://www.test.com/?%20key=value1&key=value2',
'%20key')")
+ testFoldConst("select
extract_url_parameter('http://www.test.com/path/to/resource?param=value&another=example',
'param')")
+ testFoldConst("select
extract_url_parameter('http://www.test.com/path/to/resource?PARAM=value&ANOTHER=example',
'Param')")
+ testFoldConst("select
extract_url_parameter('http://www.test.com/path/to/resource?α=value&β=example',
'α')")
+ testFoldConst("select
extract_url_parameter('http://www.test.com/path/to/resource?你=value&好=example',
'你')")
+ testFoldConst("select
extract_url_parameter('http://www.test.com/path/to/resource?こ=value&んにちは=example',
'こ')")
+ testFoldConst("select
extract_url_parameter('http://www.test.com/path/to/resource?안녕=value&하세요=example',
'안녕')")
+ testFoldConst("select
extract_url_parameter('http://www.test.com/path/to/resource?привет=value&мир=example',
'привет')")
+ testFoldConst("select
extract_url_parameter('http://www.test.com/path/to/resource?שָׁלוֹם=value&עֲלֵיכֶם=example',
'שָׁלוֹם')")
+ testFoldConst("select
extract_url_parameter('http://www.test.com/path/to/resource?😊=value&👍=example',
'😊')")
+ testFoldConst("select
extract_url_parameter('http://www.test.com/path/to/resource?%20key=value&query=string',
'%20key')")
+ testFoldConst("select
extract_url_parameter('http://user:[email protected]:8080/path/to/file?query=string#frag',
'query')")
+ testFoldConst("select
extract_url_parameter('http://user:[email protected]:8080/path/to/file?QUERY=string#frag',
'Query')")
+ testFoldConst("select
extract_url_parameter('http://user:[email protected]:8080/path/to/file?α=value#frag',
'α')")
+ testFoldConst("select
extract_url_parameter('http://user:[email protected]:8080/path/to/file?你=value#frag',
'你')")
+ testFoldConst("select
extract_url_parameter('http://user:[email protected]:8080/path/to/file?こ=value#frag',
'こ')")
+ testFoldConst("select
extract_url_parameter('http://user:[email protected]:8080/path/to/file?안녕=value#frag',
'안녕')")
+ testFoldConst("select
extract_url_parameter('http://user:[email protected]:8080/path/to/file?привет=value#frag',
'привет')")
+ testFoldConst("select
extract_url_parameter('http://user:[email protected]:8080/path/to/file?שָׁלוֹם=value#frag',
'שָׁלוֹם')")
+ testFoldConst("select
extract_url_parameter('http://user:[email protected]:8080/path/to/file?😊=value#frag',
'😊')")
+ testFoldConst("select
extract_url_parameter('http://user:[email protected]?a=b', 'a')")
+ testFoldConst("select
extract_url_parameter('http://user:[email protected]?a=b', 'A')")
+ testFoldConst("select
extract_url_parameter('http://user:[email protected]?a=b', 'b')")
+ testFoldConst("select
extract_url_parameter('http://user:[email protected]?a=b', 'B')")
+ testFoldConst("select
extract_url_parameter('http://user:[email protected]?a=b', 'c')")
+ testFoldConst("select
extract_url_parameter('http://user:[email protected]?a=b', 'C')")
+ testFoldConst("select
extract_url_parameter('http://user:[email protected]?a=b', '')")
+ testFoldConst("select
extract_url_parameter('http://user:[email protected]?a=b', null)")
+ testFoldConst("select extract_url_parameter(null, 'a')")
+ testFoldConst("select
extract_url_parameter('http://user:[email protected]?a=b', 'a&b')")
+ testFoldConst("select
extract_url_parameter('http://user:[email protected]?a=b&c=d', 'c')")
+ testFoldConst("select
extract_url_parameter('http://user:[email protected]?a=b&c=d', 'C')")
+ testFoldConst("select
extract_url_parameter('http://user:[email protected]?a=b&c=d', 'd')")
+ testFoldConst("select
extract_url_parameter('http://user:[email protected]?a=b&c=d', 'D')")
+ testFoldConst("select
extract_url_parameter('http://user:[email protected]?a=b&c=d', 'e')")
+ testFoldConst("select
extract_url_parameter('http://user:[email protected]?a=b&c=d', 'E')")
+ testFoldConst("select
extract_url_parameter('http://user:[email protected]?a=b&c=d', '')")
+ testFoldConst("select
extract_url_parameter('http://user:[email protected]?a=b&c=d', null)")
+ testFoldConst("select
extract_url_parameter('http://user:[email protected]?a=b&c=d&e=f', 'e')")
+ testFoldConst("select
extract_url_parameter('http://user:[email protected]?a=b&c=d&e=f', 'E')")
+ testFoldConst("select
extract_url_parameter('http://user:[email protected]?a=b&c=d&e=f', 'f')")
+ testFoldConst("select
extract_url_parameter('http://user:[email protected]?a=b&c=d&e=f', 'F')")
+ testFoldConst("select
extract_url_parameter('http://user:[email protected]?a=b&c=d&e=f', 'g')")
+ testFoldConst("select
extract_url_parameter('http://user:[email protected]?a=b&c=d&e=f', 'G')")
+ testFoldConst("select
extract_url_parameter('http://user:[email protected]?a=b&c=d&e=f', '')")
+ testFoldConst("select
extract_url_parameter('http://user:[email protected]?a=b&c=d&e=f', null)")
+ testFoldConst("select
extract_url_parameter('http://user:[email protected]?a=b&c=d&e=f&g=h', 'g')")
+ testFoldConst("select
extract_url_parameter('http://user:[email protected]?a=b&c=d&e=f&g=h', 'G')")
+ testFoldConst("select
extract_url_parameter('http://user:[email protected]?a=b&c=d&e=f&g=h', 'h')")
+ testFoldConst("select
extract_url_parameter('http://user:[email protected]?a=b&c=d&e=f&g=h', 'H')")
+ testFoldConst("select
extract_url_parameter('http://user:[email protected]?a=b&c=d&e=f&g=h', 'i')")
+ testFoldConst("select
extract_url_parameter('http://user:[email protected]?a=b&c=d&e=f&g=h', 'I')")
+ testFoldConst("select
extract_url_parameter('http://user:[email protected]?a=b&c=d&e=f&g=h', '')")
+ testFoldConst("select
extract_url_parameter('http://user:[email protected]?a=b&c=d&e=f&g=h', null)")
+ testFoldConst("select
extract_url_parameter('http://user:[email protected]?a=b&c=d&e=f&g=h&i=j',
'i')")
+ testFoldConst("select
extract_url_parameter('http://user:[email protected]?a=b&c=d&e=f&g=h&i=j',
'I')")
+ testFoldConst("select
extract_url_parameter('http://user:[email protected]?a=b&c=d&e=f&g=h&i=j',
'j')")
+ testFoldConst("select
extract_url_parameter('http://user:[email protected]?a=b&c=d&e=f&g=h&i=j',
'J')")
+ testFoldConst("select
extract_url_parameter('http://user:[email protected]?a=b&c=d&e=f&g=h&i=j',
'k')")
+ testFoldConst("select
extract_url_parameter('http://user:[email protected]?a=b&c=d&e=f&g=h&i=j',
'K')")
+ testFoldConst("select
extract_url_parameter('http://user:[email protected]?a=b&c=d&e=f&g=h&i=j',
'')")
+ testFoldConst("select
extract_url_parameter('http://user:[email protected]?a=b&c=d&e=f&g=h&i=j',
null)")
+ testFoldConst("select
extract_url_parameter('http://user:[email protected]?a=b&c=d&e=f&g=h&i=j&k=l',
'k')")
+ testFoldConst("select
extract_url_parameter('http://user:[email protected]?a=b&c=d&e=f&g=h&i=j&k=l',
'K')")
+ testFoldConst("select
extract_url_parameter('http://user:[email protected]?a=b&c=d&e=f&g=h&i=j&k=l',
'l')")
+ testFoldConst("select
extract_url_parameter('http://user:[email protected]?a=b&c=d&e=f&g=h&i=j&k=l',
'L')")
+ testFoldConst("select
extract_url_parameter('http://user:[email protected]?a=b&c=d&e=f&g=h&i=j&k=l',
'm')")
+ testFoldConst("select
extract_url_parameter('http://user:[email protected]?a=b&c=d&e=f&g=h&i=j&k=l',
'M')")
+ testFoldConst("select
extract_url_parameter('http://user:[email protected]?a=b&c=d&e=f&g=h&i=j&k=l',
'')")
+ testFoldConst("select
extract_url_parameter('http://user:[email protected]?a=b&c=d&e=f&g=h&i=j&k=l',
null)")
+ testFoldConst("select
extract_url_parameter('http://user:[email protected]?🌍=b', '🌍')")
+ testFoldConst("select
extract_url_parameter('http://user:[email protected]?🌍=b', '🌎')")
+ testFoldConst("select
extract_url_parameter('http://user:[email protected]?α=b', 'α')")
+ testFoldConst("select
extract_url_parameter('http://user:[email protected]?α=b', 'Α')")
+ testFoldConst("select
extract_url_parameter('http://user:[email protected]?中文=b', '中文')")
+ testFoldConst("select
extract_url_parameter('http://user:[email protected]?日本語=b', '日本語')")
+ testFoldConst("select
extract_url_parameter('http://user:[email protected]?한글=b', '한글')")
+ testFoldConst("select
extract_url_parameter('http://user:[email protected]?русский=b', 'русский')")
+ testFoldConst("select
extract_url_parameter('http://user:[email protected]?עברית=b', 'עברית')")
+ testFoldConst("select
extract_url_parameter('http://user:[email protected]?🌍=b&c=d', '🌍')")
+ testFoldConst("select
extract_url_parameter('http://user:[email protected]?🌍=b&c=d', 'c')")
+ testFoldConst("select
extract_url_parameter('http://user:[email protected]?🌍=b&c=d', 'C')")
+ testFoldConst("select
extract_url_parameter('http://user:[email protected]?🌍=b&c=d', 'd')")
+ testFoldConst("select
extract_url_parameter('http://user:[email protected]?🌍=b&c=d', 'D')")
+ testFoldConst("select
extract_url_parameter('http://user:[email protected]?🌍=b&c=d', 'e')")
+ testFoldConst("select
extract_url_parameter('http://user:[email protected]?🌍=b&c=d', 'E')")
+ testFoldConst("select
extract_url_parameter('http://user:[email protected]?🌍=b&c=d', '')")
+ testFoldConst("select
extract_url_parameter('http://user:[email protected]?🌍=b&c=d', null)")
+ testFoldConst("select
extract_url_parameter('http://user:[email protected]?🌍=b&c=d&e=f', 'e')")
+ testFoldConst("select
extract_url_parameter('http://user:[email protected]?🌍=b&c=d&e=f', 'E')")
+ testFoldConst("select
extract_url_parameter('http://user:[email protected]?🌍=b&c=d&e=f', 'f')")
+ testFoldConst("select
extract_url_parameter('http://user:[email protected]?🌍=b&c=d&e=f', 'F')")
+ testFoldConst("select
extract_url_parameter('http://user:[email protected]?🌍=b&c=d&e=f', 'g')")
+ testFoldConst("select
extract_url_parameter('http://user:[email protected]?🌍=b&c=d&e=f', 'G')")
+ testFoldConst("select
extract_url_parameter('http://user:[email protected]?🌍=b&c=d&e=f', '')")
+ testFoldConst("select
extract_url_parameter('http://user:[email protected]?🌍=b&c=d&e=f', null)")
+ testFoldConst("select
extract_url_parameter('http://user:[email protected]?🌍=b&c=d&e=f&g=h', 'g')")
+ testFoldConst("select
extract_url_parameter('http://user:[email protected]?🌍=b&c=d&e=f&g=h', 'G')")
+ testFoldConst("select
extract_url_parameter('http://user:[email protected]?🌍=b&c=d&e=f&g=h', 'h')")
+ testFoldConst("select
extract_url_parameter('http://user:[email protected]?🌍=b&c=d&e=f&g=h', 'H')")
+ testFoldConst("select
extract_url_parameter('http://user:[email protected]?🌍=b&c=d&e=f&g=h', 'i')")
+ testFoldConst("select
extract_url_parameter('http://user:[email protected]?🌍=b&c=d&e=f&g=h', 'I')")
+ testFoldConst("select
extract_url_parameter('http://user:[email protected]?🌍=b&c=d&e=f&g=h', '')")
+ testFoldConst("select
extract_url_parameter('http://user:[email protected]?🌍=b&c=d&e=f&g=h', null)")
+ testFoldConst("select
extract_url_parameter('http://user:[email protected]?🌍=b&c=d&e=f&g=h&i=j',
'i')")
+ testFoldConst("select
extract_url_parameter('http://user:[email protected]?🌍=b&c=d&e=f&g=h&i=j',
'I')")
+ testFoldConst("select
extract_url_parameter('http://user:[email protected]?🌍=b&c=d&e=f&g=h&i=j',
'j')")
+ testFoldConst("select
extract_url_parameter('http://user:[email protected]?🌍=b&c=d&e=f&g=h&i=j',
'J')")
+ testFoldConst("select
extract_url_parameter('http://user:[email protected]?🌍=b&c=d&e=f&g=h&i=j',
'k')")
+ testFoldConst("select
extract_url_parameter('http://user:[email protected]?🌍=b&c=d&e=f&g=h&i=j',
'K')")
+ testFoldConst("select
extract_url_parameter('http://user:[email protected]?🌍=b&c=d&e=f&g=h&i=j',
'')")
+ testFoldConst("select
extract_url_parameter('http://user:[email protected]?🌍=b&c=d&e=f&g=h&i=j',
null)")
+ testFoldConst("select
extract_url_parameter('http://user:[email protected]?🌍=b&c=d&e=f&g=h&i=j&k=l',
'k')")
+ testFoldConst("select
extract_url_parameter('http://user:[email protected]?🌍=b&c=d&e=f&g=h&i=j&k=l',
'K')")
+ testFoldConst("select
extract_url_parameter('http://user:[email protected]?🌍=b&c=d&e=f&g=h&i=j&k=l',
'l')")
+ testFoldConst("select
extract_url_parameter('http://user:[email protected]?🌍=b&c=d&e=f&g=h&i=j&k=l',
'L')")
+ testFoldConst("select
extract_url_parameter('http://user:[email protected]?🌍=b&c=d&e=f&g=h&i=j&k=l',
'm')")
+ testFoldConst("select
extract_url_parameter('http://user:[email protected]?🌍=b&c=d&e=f&g=h&i=j&k=l',
'M')")
+ testFoldConst("select
extract_url_parameter('http://user:[email protected]?🌍=b&c=d&e=f&g=h&i=j&k=l',
'')")
+ testFoldConst("select
extract_url_parameter('http://user:[email protected]?🌍=b&c=d&e=f&g=h&i=j&k=l',
null)")
+
}
+
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]