|
34 | 34 | import org.apache.doris.analysis.TupleId;
|
35 | 35 | import org.apache.doris.catalog.Column;
|
36 | 36 | import org.apache.doris.catalog.OlapTable;
|
| 37 | +import org.apache.doris.catalog.Type; |
37 | 38 | import org.apache.doris.common.AnalysisException;
|
38 | 39 | import org.apache.doris.common.Id;
|
39 | 40 | import org.apache.doris.common.NotImplementedException;
|
|
59 | 60 | import com.google.common.collect.Maps;
|
60 | 61 | import com.google.common.collect.Sets;
|
61 | 62 | import org.apache.commons.collections.CollectionUtils;
|
| 63 | +import org.apache.logging.log4j.LogManager; |
| 64 | +import org.apache.logging.log4j.Logger; |
62 | 65 |
|
63 | 66 | import java.util.ArrayList;
|
64 | 67 | import java.util.Collection;
|
|
89 | 92 | * its children (= are bound by tupleIds).
|
90 | 93 | */
|
91 | 94 | public abstract class PlanNode extends TreeNode<PlanNode> implements PlanStats {
|
| 95 | + private static final Logger LOG = LogManager.getLogger(PlanNode.class); |
92 | 96 |
|
93 | 97 | protected String planNodeName;
|
94 | 98 |
|
@@ -207,6 +211,7 @@ protected PlanNode(PlanNodeId id, PlanNode node, String planNodeName, Statistica
|
207 | 211 | this.tblRefIds = Lists.newArrayList(node.tblRefIds);
|
208 | 212 | this.nullableTupleIds = Sets.newHashSet(node.nullableTupleIds);
|
209 | 213 | this.conjuncts = Expr.cloneList(node.conjuncts, null);
|
| 214 | + |
210 | 215 | this.cardinality = -1;
|
211 | 216 | this.compactData = node.compactData;
|
212 | 217 | this.planNodeName = "V" + planNodeName;
|
@@ -806,6 +811,21 @@ public void init() throws UserException {}
|
806 | 811 | public void init(Analyzer analyzer) throws UserException {
|
807 | 812 | assignConjuncts(analyzer);
|
808 | 813 | createDefaultSmap(analyzer);
|
| 814 | + castConjuncts(); |
| 815 | + } |
| 816 | + |
| 817 | + private void castConjuncts() throws AnalysisException { |
| 818 | + for (int i = 0; i < conjuncts.size(); ++i) { |
| 819 | + Expr expr = conjuncts.get(i); |
| 820 | + if (!expr.getType().isBoolean()) { |
| 821 | + try { |
| 822 | + conjuncts.set(i, expr.castTo(Type.BOOLEAN)); |
| 823 | + } catch (AnalysisException e) { |
| 824 | + LOG.warn("{} is not boolean and can not be cast to boolean", expr.toSql(), e); |
| 825 | + throw new AnalysisException("conjuncts " + expr.toSql() + " is not boolean"); |
| 826 | + } |
| 827 | + } |
| 828 | + } |
809 | 829 | }
|
810 | 830 |
|
811 | 831 | /**
|
|
0 commit comments