Skip to content

Commit

Permalink
Fix delete_sign predicate assigned to join node (#4770)
Browse files Browse the repository at this point in the history
  • Loading branch information
yangzhg authored Oct 22, 2020
1 parent 0c37b42 commit fae5c62
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import org.apache.doris.analysis.CastExpr;
import org.apache.doris.analysis.Expr;
import org.apache.doris.analysis.InPredicate;
import org.apache.doris.analysis.IntLiteral;
import org.apache.doris.analysis.PartitionNames;
import org.apache.doris.analysis.SlotDescriptor;
import org.apache.doris.analysis.SlotRef;
Expand All @@ -48,6 +49,7 @@
import org.apache.doris.common.ErrorCode;
import org.apache.doris.common.ErrorReport;
import org.apache.doris.common.UserException;
import org.apache.doris.common.util.Util;
import org.apache.doris.qe.ConnectContext;
import org.apache.doris.qe.SessionVariable;
import org.apache.doris.service.FrontendOptions;
Expand Down Expand Up @@ -278,6 +280,15 @@ protected String debugString() {
@Override
public void init(Analyzer analyzer) throws UserException {
super.init(analyzer);
if (!Util.showHiddenColumns() && olapTable.hasDeleteSign()) {
SlotRef deleteSignSlot = new SlotRef(desc.getAliasAsName(), Column.DELETE_SIGN);
deleteSignSlot.analyze(analyzer);
deleteSignSlot.getDesc().setIsMaterialized(true);
Expr conjunct = new BinaryPredicate(BinaryPredicate.Operator.EQ, deleteSignSlot, new IntLiteral(0));
conjunct.analyze(analyzer);
conjuncts.add(conjunct);
}

computePartitionInfo();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
import org.apache.doris.analysis.GroupingInfo;
import org.apache.doris.analysis.InPredicate;
import org.apache.doris.analysis.InlineViewRef;
import org.apache.doris.analysis.IntLiteral;
import org.apache.doris.analysis.IsNullPredicate;
import org.apache.doris.analysis.JoinOperator;
import org.apache.doris.analysis.LiteralExpr;
Expand All @@ -54,13 +53,11 @@
import org.apache.doris.catalog.FunctionSet;
import org.apache.doris.catalog.MysqlTable;
import org.apache.doris.catalog.OdbcTable;
import org.apache.doris.catalog.OlapTable;
import org.apache.doris.catalog.Table;
import org.apache.doris.common.AnalysisException;
import org.apache.doris.common.FeConstants;
import org.apache.doris.common.Reference;
import org.apache.doris.common.UserException;
import org.apache.doris.common.util.Util;

import com.google.common.base.Preconditions;
import com.google.common.base.Predicate;
Expand Down Expand Up @@ -1365,14 +1362,6 @@ private PlanNode createScanNode(Analyzer analyzer, TableRef tblRef, SelectStmt s
switch (tblRef.getTable().getType()) {
case OLAP:
OlapScanNode olapNode = new OlapScanNode(ctx_.getNextNodeId(), tblRef.getDesc(), "OlapScanNode");
if (!Util.showHiddenColumns() && ((OlapTable) tblRef.getTable()).hasDeleteSign()) {
SlotRef deleteSignSlot = new SlotRef(tblRef.getAliasAsName(), Column.DELETE_SIGN);
deleteSignSlot.analyze(analyzer);
deleteSignSlot.getDesc().setIsMaterialized(true);
Expr conjunct = new BinaryPredicate(BinaryPredicate.Operator.EQ, deleteSignSlot, new IntLiteral(0));
conjunct.analyze(analyzer);
analyzer.registerConjunct(conjunct, tblRef.getDesc().getId());
}

olapNode.setForceOpenPreAgg(tblRef.isForcePreAggOpened());
scanNode = olapNode;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -476,13 +476,25 @@ public void testImplicitConvertSupport() throws Exception {
@Test
public void testDeleteSign() throws Exception {
String sql1 = "SELECT * FROM db1.table1 LEFT ANTI JOIN db1.table2 ON db1.table1.siteid = db1.table2.siteid;";
Assert.assertTrue(dorisAssert.query(sql1).explainQuery().contains("`table1`.`__DORIS_DELETE_SIGN__` = 0"));
String explain = dorisAssert.query(sql1).explainQuery();
Assert.assertTrue(explain
.contains("PREDICATES: `default_cluster:db1.table1`.`__DORIS_DELETE_SIGN__` = 0"));
Assert.assertTrue(explain
.contains("PREDICATES: `default_cluster:db1.table2`.`__DORIS_DELETE_SIGN__` = 0"));
Assert.assertFalse(explain.contains("other predicates:"));
String sql2 = "SELECT * FROM db1.table1 JOIN db1.table2 ON db1.table1.siteid = db1.table2.siteid;";
Assert.assertTrue(dorisAssert.query(sql2).explainQuery().contains("`table1`.`__DORIS_DELETE_SIGN__` = 0"));
explain = dorisAssert.query(sql2).explainQuery();
Assert.assertTrue(explain
.contains("PREDICATES: `default_cluster:db1.table1`.`__DORIS_DELETE_SIGN__` = 0"));
Assert.assertTrue(explain
.contains("PREDICATES: `default_cluster:db1.table2`.`__DORIS_DELETE_SIGN__` = 0"));
Assert.assertFalse(explain.contains("other predicates:"));
String sql3 = "SELECT * FROM db1.table1";
Assert.assertTrue(dorisAssert.query(sql3).explainQuery().contains("`table1`.`__DORIS_DELETE_SIGN__` = 0"));
Assert.assertTrue(dorisAssert.query(sql3).explainQuery()
.contains("PREDICATES: `default_cluster:db1.table1`.`__DORIS_DELETE_SIGN__` = 0"));
String sql4 = " SELECT * FROM db1.table1 table2";
Assert.assertTrue(dorisAssert.query(sql4).explainQuery().contains("`table2`.`__DORIS_DELETE_SIGN__` = 0"));
Assert.assertTrue(dorisAssert.query(sql4).explainQuery()
.contains("PREDICATES: `table2`.`__DORIS_DELETE_SIGN__` = 0"));
new MockUp<Util>() {
@Mock
public boolean showHiddenColumns() {
Expand Down

0 comments on commit fae5c62

Please sign in to comment.