This is an automated email from the ASF dual-hosted git repository.
morningman 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 68eb420cab [fix](MySQL) the way Doris handles boolean type is
consistent with MySQL (#19416)
68eb420cab is described below
commit 68eb420cabe5b26b09d6d4a2724ae12699bdee87
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 0d4e4d2d61..112460564e 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
@@ -422,6 +422,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 59c34c4a7b..90c17ee8f1 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
@@ -227,7 +227,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]