You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by yi...@apache.org on 2023/06/14 10:20:57 UTC
[doris] branch branch-1.2-lts updated: [Fix](Planner) Add rewrite of return type in where clause when useing case when (#20810)
This is an automated email from the ASF dual-hosted git repository.
yiguolei pushed a commit to branch branch-1.2-lts
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/branch-1.2-lts by this push:
new f0d369350a [Fix](Planner) Add rewrite of return type in where clause when useing case when (#20810)
f0d369350a is described below
commit f0d369350ac5cf31f1e95e2b6c5cb041c5914a23
Author: LiBinfeng <46...@users.noreply.github.com>
AuthorDate: Wed Jun 14 18:20:48 2023 +0800
[Fix](Planner) Add rewrite of return type in where clause when useing case when (#20810)
Rewrite case when (constant literal) else (constant literal) return type to boolean type forcely, or if we pass this to be, it will core at assert_cast when using debug mode to compile.
---
fe/fe-core/src/main/java/org/apache/doris/analysis/Expr.java | 2 +-
fe/fe-core/src/main/java/org/apache/doris/analysis/SelectStmt.java | 6 ++++++
2 files changed, 7 insertions(+), 1 deletion(-)
diff --git a/fe/fe-core/src/main/java/org/apache/doris/analysis/Expr.java b/fe/fe-core/src/main/java/org/apache/doris/analysis/Expr.java
index c5a4f81bac..abed221866 100755
--- a/fe/fe-core/src/main/java/org/apache/doris/analysis/Expr.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/analysis/Expr.java
@@ -1324,7 +1324,7 @@ public abstract class Expr extends TreeNode<Expr> implements ParseNode, Cloneabl
* The error message only contains this.toSql() if printExpr is true.
*/
public void checkReturnsBool(String name, boolean printExpr) throws AnalysisException {
- if (!type.isBoolean() && !type.isNull() && !type.isTinyint()) {
+ if (!type.isBoolean() && !type.isNull()) {
if (this instanceof BoolLiteral) {
return;
}
diff --git a/fe/fe-core/src/main/java/org/apache/doris/analysis/SelectStmt.java b/fe/fe-core/src/main/java/org/apache/doris/analysis/SelectStmt.java
index acae7147aa..d634b5fb62 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/analysis/SelectStmt.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/analysis/SelectStmt.java
@@ -27,6 +27,7 @@ import org.apache.doris.catalog.DatabaseIf;
import org.apache.doris.catalog.Env;
import org.apache.doris.catalog.FunctionSet;
import org.apache.doris.catalog.OlapTable;
+import org.apache.doris.catalog.PrimitiveType;
import org.apache.doris.catalog.TableIf;
import org.apache.doris.catalog.TableIf.TableType;
import org.apache.doris.catalog.Type;
@@ -650,6 +651,11 @@ public class SelectStmt extends QueryStmt {
} else {
whereClause = new BoolLiteral(true);
}
+ } else if (whereClause instanceof CaseExpr
+ && (((CaseExpr) whereClause).getChild(1) instanceof IntLiteral)
+ && (((CaseExpr) whereClause).getChild(2) instanceof IntLiteral)) {
+ whereClause = new CastExpr(TypeDef.create(PrimitiveType.BOOLEAN), whereClause);
+ whereClause.setType(Type.BOOLEAN);
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org