[fix](MySQL) the way Doris handles boolean type is consistent with MySQL (#19416)

This commit is contained in:
Ashin Gau
2023-05-10 00:58:09 +08:00
committed by GitHub
parent f8eb08252c
commit 68eb420cab
2 changed files with 12 additions and 1 deletions

View File

@ -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.

View File

@ -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 {