This is an automated email from the ASF dual-hosted git repository.
morrysnow 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 c87a9a5949 [fix](Nereids) Add varchar literal compare (#15672)
c87a9a5949 is described below
commit c87a9a59496cb763c1bccc8db287e7b0efe599b1
Author: 谢健 <[email protected]>
AuthorDate: Wed Jan 11 02:41:50 2023 +0800
[fix](Nereids) Add varchar literal compare (#15672)
support "1" = "123"
---
.../org/apache/doris/nereids/trees/expressions/literal/Literal.java | 6 +++++-
regression-test/suites/nereids_syntax_p0/function.groovy | 5 +++++
2 files changed, 10 insertions(+), 1 deletion(-)
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/literal/Literal.java
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/literal/Literal.java
index 1236087f39..7f5fad5af6 100644
---
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/literal/Literal.java
+++
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/literal/Literal.java
@@ -139,7 +139,11 @@ public abstract class Literal extends Expression
implements LeafExpression, Comp
DataType oType = other.getDataType();
DataType type = getDataType();
- if (!type.equals(oType)) {
+
+ if (type.isVarcharType() && oType.isVarcharType()) {
+ // VarChar type can be different, e.g., VarChar(1) = VarChar(2)
+ return StringUtils.compare((String) getValue(), (String)
other.getValue());
+ } else if (!type.equals(oType)) {
throw new RuntimeException("data type not equal!");
} else if (type.isBooleanType()) {
return Boolean.compare((boolean) getValue(), (boolean)
other.getValue());
diff --git a/regression-test/suites/nereids_syntax_p0/function.groovy
b/regression-test/suites/nereids_syntax_p0/function.groovy
index b3cbb9f09e..c8ca608078 100644
--- a/regression-test/suites/nereids_syntax_p0/function.groovy
+++ b/regression-test/suites/nereids_syntax_p0/function.groovy
@@ -103,5 +103,10 @@ suite("nereids_function") {
sql "select convert_to('abc', cast(number as varchar)) from
numbers('number'='1')"
exception "must be a constant"
}
+
+ test {
+ sql """select "1" == "123", "%%" == "%%" """
+ result([[false, true]])
+ }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]