Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ public BinaryPredicate() {
public BinaryPredicate(Operator op, Expr e1, Expr e2) {
super();
this.op = op;
this.opcode = op.opcode;
Preconditions.checkNotNull(e1);
children.add(e1);
Preconditions.checkNotNull(e2);
Expand Down
4 changes: 3 additions & 1 deletion fe/src/main/java/org/apache/doris/analysis/SelectStmt.java
Original file line number Diff line number Diff line change
Expand Up @@ -437,6 +437,8 @@ public void analyze(Analyzer analyzer) throws AnalysisException, UserException {
}

if (whereClause != null) {
// do this before whereClause.analyze , some expr is not analyzed, this may cause some
// function not work as expected such as equals;
whereClauseRewrite();
if (checkGroupingFn(whereClause)) {
throw new AnalysisException("grouping operations are not allowed in WHERE.");
Expand Down Expand Up @@ -608,7 +610,7 @@ private Expr processDuplicateOrs(List<List<Expr>> exprs) {
if (clearExprs.size() == 1) {
return makeCompound(clearExprs.get(0), CompoundPredicate.Operator.AND);
}
// 2. find duplcate cross the clause
// 2. find duplicate cross the clause
List<Expr> cloneExprs = new ArrayList<>(clearExprs.get(0));
for (int i = 1; i < clearExprs.size(); ++i) {
cloneExprs.retainAll(clearExprs.get(i));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,12 @@ public void testDeduplicateOrs() throws Exception {
stmt8.rewriteExprs(new Analyzer(ctx.getCatalog(), ctx).getExprRewriter());
Assert.assertTrue(stmt8.toSql().contains("((`t2`.`k1` IS NOT NULL) AND (`t1`.`k1` IS NOT NULL))" +
" AND (`t1`.`k1` IS NOT NULL)"));

String sql9 = "select * from db1.tbl1 where (k1='shutdown' and k4<1) or (k1='switchOff' and k4>=1)";
SelectStmt stmt9 = (SelectStmt) UtFrameUtils.parseAndAnalyzeStmt(sql9, ctx);
stmt9.rewriteExprs(new Analyzer(ctx.getCatalog(), ctx).getExprRewriter());
Assert.assertTrue(stmt9.toSql().contains("((`k1` = 'shutdown') AND (`k4` < 1))" +
" OR ((`k1` = 'switchOff') AND (`k4` >= 1))"));
}

@Test
Expand Down