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

morningman pushed a commit to branch branch-1.2-lts
in repository https://gitbox.apache.org/repos/asf/doris.git

commit c8f487339387b80c6dedabb79e0782f1191aaaa0
Author: Ashin Gau <[email protected]>
AuthorDate: Wed May 10 00:58:09 2023 +0800

    [fix](MySQL) the way Doris handles boolean type is consistent with MySQL 
(#19416)
---
 .../src/main/java/org/apache/doris/analysis/BinaryPredicate.java | 4 ++++
 .../src/main/java/org/apache/doris/analysis/StringLiteral.java   | 9 ++++++++-
 2 files changed, 12 insertions(+), 1 deletion(-)

diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/analysis/BinaryPredicate.java 
b/fe/fe-core/src/main/java/org/apache/doris/analysis/BinaryPredicate.java
index 2b01f17319..11504d9571 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/analysis/BinaryPredicate.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/analysis/BinaryPredicate.java
@@ -380,6 +380,10 @@ public class BinaryPredicate extends Predicate implements 
Writable {
                 && (t2 == PrimitiveType.BIGINT || t2 == 
PrimitiveType.LARGEINT)) {
             return Type.LARGEINT;
         }
+        // MySQL will try to parse string as bigint, if failed, will take 
string as 0.
+        if (t1 == PrimitiveType.BIGINT && t2.isCharFamily()) {
+            return Type.BIGINT;
+        }
 
         // Implicit conversion affects query performance.
         // For a common example datekey='20200825' which datekey is int type.
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/analysis/StringLiteral.java 
b/fe/fe-core/src/main/java/org/apache/doris/analysis/StringLiteral.java
index 62038dec27..1804730663 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/analysis/StringLiteral.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/analysis/StringLiteral.java
@@ -226,7 +226,14 @@ public class StringLiteral extends LiteralExpr {
                             throw new AnalysisException(e.getMessage());
                         }
                     }
-                    return new IntLiteral(value, targetType);
+                    // MySQL will try to parse string as bigint, if failed, 
will cast string as 0.
+                    long longValue;
+                    try {
+                        longValue = Long.parseLong(value);
+                    } catch (NumberFormatException e) {
+                        longValue = 0L;
+                    }
+                    return new IntLiteral(longValue, targetType);
                 case LARGEINT:
                     if (VariableVarConverters.hasConverter(beConverted)) {
                         try {


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to