Code review comment: Question: If I wrote an always false condition like `WHERE TIMESTAMP = x AND TIMESTAMP = y` where the x != y, will the query run correctly? Another case is `WHERE TIMESTAMP > x AND TIMESTAMP >y` where x != y, will the query run correctly?

Code before review:
public PlanFragment visitPhysicalSchemaScan(OptExpression optExpression, ExecPlan context) {
PhysicalSchemaScanOperator node = (PhysicalSchemaScanOperator) optExpression.getOp();
context.getDescTbl().addReferencedTable(node.getTable());
TupleDescriptor tupleDescriptor = context.getDescTbl().createTupleDescriptor();
tupleDescriptor.setTable(node.getTable());
for (Map.Entry<ColumnRefOperator, Column> entry : node.getColRefToColumnMetaMap().entrySet()) {
SlotDescriptor slotDescriptor =
context.getDescTbl().addSlotDescriptor(tupleDescriptor, new SlotId(entry.getKey().getId()));
slotDescriptor.setColumn(entry.getValue());
slotDescriptor.setIsNullable(entry.getValue().isAllowNull());
slotDescriptor.setIsMaterialized(true);
context.getColRefToExpr().put(entry.getKey(), new SlotRef(entry.getKey().toString(), slotDescriptor));
}
tupleDescriptor.computeMemLayout();
SchemaScanNode scanNode = new SchemaScanNode(context.getNextNodeId(), tupleDescriptor);
scanNode.setFrontendIP(FrontendOptions.getLocalHostAddress());
scanNode.setFrontendPort(Config.rpc_port);
scanNode.setUser(context.getConnectContext().getQualifiedUser());
scanNode.setUserIp(context.getConnectContext().getRemoteIP());
scanNode.setLimit(node.getLimit());
List<ScalarOperator> predicates = Utils.extractConjuncts(node.getPredicate());
ScalarOperatorToExpr.FormatterContext formatterContext =
new ScalarOperatorToExpr.FormatterContext(context.getColRefToExpr());
for (ScalarOperator predicate : predicates) {
scanNode.getConjuncts().add(ScalarOperatorToExpr.buildExecExpression(predicate, formatterContext));
if (!(predicate.getChildren().size() == 2 && predicate.getChildren().get(0) instanceof ColumnRefOperator &&
predicate.getChildren().get(1) instanceof ConstantOperator)) {
continue;
}
ColumnRefOperator columnRefOperator = (ColumnRefOperator) predicate.getChildren().get(0);
ConstantOperator constantOperator = (ConstantOperator) predicate.getChildren().get(1);
if (predicate instanceof BinaryPredicateOperator) {
BinaryPredicateOperator binaryPredicateOperator = (BinaryPredicateOperator) predicate;
if (binaryPredicateOperator.getBinaryType() == BinaryPredicateOperator.BinaryType.EQ) {
switch (columnRefOperator.getName()) {
case "TABLE_SCHEMA":
case "DATABASE_NAME":
scanNode.setSchemaDb(constantOperator.getVarchar());
break;
case "TABLE_NAME":
scanNode.setSchemaTable(constantOperator.getVarchar());
break;
case "BE_ID":
scanNode.setBeId(constantOperator.getBigint());
break;
case "TABLE_ID":
scanNode.setTableId(constantOperator.getBigint());
break;
case "PARTITION_ID":
scanNode.setPartitionId(constantOperator.getBigint());
break;
case "TABLET_ID":
scanNode.setTabletId(constantOperator.getBigint());
break;
case "TXN_ID":
scanNode.setTxnId(constantOperator.getBigint());
break;
case "LABEL":
scanNode.setLabel(constantOperator.getVarchar());
break;
case "JOB_ID":
scanNode.setJobId(constantOperator.getBigint());
break;
case "TYPE":
scanNode.setType(constantOperator.getVarchar());
break;
case "STATE":
scanNode.setState(constantOperator.getVarchar());
break;
case "LOG":
scanNode.setLogPattern("^" + constantOperator.getVarchar() + "$");
break;
case "LEVEL":
scanNode.setLogLevel(constantOperator.getVarchar());
break;
default:
break;
}
}
if (columnRefOperator.getName().equals("TIMESTAMP")) {
BinaryPredicateOperator.BinaryType opType = binaryPredicateOperator.getBinaryType();
if (opType == BinaryPredicateOperator.BinaryType.EQ) {
scanNode.setLogStartTs(constantOperator.getBigint());
scanNode.setLogEndTs(constantOperator.getBigint() + 1);
} else if (opType == BinaryPredicateOperator.BinaryType.GT) {
scanNode.setLogStartTs(constantOperator.getBigint() + 1);
} else if (opType == BinaryPredicateOperator.BinaryType.GE) {
scanNode.setLogStartTs(constantOperator.getBigint());
} else if (opType == BinaryPredicateOperator.BinaryType.LT) {
scanNode.setLogEndTs(constantOperator.getBigint());
} else if (opType == BinaryPredicateOperator.BinaryType.LE) {
scanNode.setLogEndTs(constantOperator.getBigint() + 1);
}
}
} else if (predicate instanceof LikePredicateOperator) {
LikePredicateOperator like = (LikePredicateOperator) predicate;
if (columnRefOperator.getName().equals("LOG")) {
if (like.getLikeType() == LikePredicateOperator.LikeType.REGEXP) {
scanNode.setLogPattern(((ConstantOperator) like.getChildren().get(1)).getVarchar());
} else {
throw UnsupportedException.unsupportedException("only support `regexp` or `rlike` for log grep");
}
}
}
}
if (scanNode.isBeSchemaTable()) {
scanNode.computeBeScanRanges();
}
if (scanNode.getLimit() > 0) {
scanNode.setLogLimit(Math.min(scanNode.getLimit(), Config.max_per_node_grep_log_limit));
} else {
scanNode.setLogLimit(Config.max_per_node_grep_log_limit);
}
context.getScanNodes().add(scanNode);
PlanFragment fragment = new PlanFragment(context.getNextFragmentId(), scanNode,
scanNode.isBeSchemaTable() ? DataPartition.RANDOM : DataPartition.UNPARTITIONED);
context.getFragments().add(fragment);
return fragment;
}

Line under review: if (columnRefOperator.getName().equals("TIMESTAMP")) {

Code after addressing the review:
public PlanFragment visitPhysicalSchemaScan(OptExpression optExpression, ExecPlan context) {
PhysicalSchemaScanOperator node = (PhysicalSchemaScanOperator) optExpression.getOp();
context.getDescTbl().addReferencedTable(node.getTable());
TupleDescriptor tupleDescriptor = context.getDescTbl().createTupleDescriptor();
tupleDescriptor.setTable(node.getTable());
for (Map.Entry<ColumnRefOperator, Column> entry : node.getColRefToColumnMetaMap().entrySet()) {
SlotDescriptor slotDescriptor =
context.getDescTbl().addSlotDescriptor(tupleDescriptor, new SlotId(entry.getKey().getId()));
slotDescriptor.setColumn(entry.getValue());
slotDescriptor.setIsNullable(entry.getValue().isAllowNull());
slotDescriptor.setIsMaterialized(true);
context.getColRefToExpr().put(entry.getKey(), new SlotRef(entry.getKey().toString(), slotDescriptor));
}
tupleDescriptor.computeMemLayout();
SchemaScanNode scanNode = new SchemaScanNode(context.getNextNodeId(), tupleDescriptor);
scanNode.setFrontendIP(FrontendOptions.getLocalHostAddress());
scanNode.setFrontendPort(Config.rpc_port);
scanNode.setUser(context.getConnectContext().getQualifiedUser());
scanNode.setUserIp(context.getConnectContext().getRemoteIP());
scanNode.setLimit(node.getLimit());
List<ScalarOperator> predicates = Utils.extractConjuncts(node.getPredicate());
ScalarOperatorToExpr.FormatterContext formatterContext =
new ScalarOperatorToExpr.FormatterContext(context.getColRefToExpr());
for (ScalarOperator predicate : predicates) {
scanNode.getConjuncts().add(ScalarOperatorToExpr.buildExecExpression(predicate, formatterContext));
if (!(predicate.getChildren().size() == 2 && predicate.getChildren().get(0) instanceof ColumnRefOperator &&
predicate.getChildren().get(1) instanceof ConstantOperator)) {
continue;
}
ColumnRefOperator columnRefOperator = (ColumnRefOperator) predicate.getChildren().get(0);
ConstantOperator constantOperator = (ConstantOperator) predicate.getChildren().get(1);
if (predicate instanceof BinaryPredicateOperator) {
BinaryPredicateOperator binaryPredicateOperator = (BinaryPredicateOperator) predicate;
if (binaryPredicateOperator.getBinaryType() == BinaryPredicateOperator.BinaryType.EQ) {
switch (columnRefOperator.getName()) {
case "TABLE_SCHEMA":
case "DATABASE_NAME":
scanNode.setSchemaDb(constantOperator.getVarchar());
break;
case "TABLE_NAME":
scanNode.setSchemaTable(constantOperator.getVarchar());
break;
case "BE_ID":
scanNode.setBeId(constantOperator.getBigint());
break;
case "TABLE_ID":
scanNode.setTableId(constantOperator.getBigint());
break;
case "PARTITION_ID":
scanNode.setPartitionId(constantOperator.getBigint());
break;
case "TABLET_ID":
scanNode.setTabletId(constantOperator.getBigint());
break;
case "TXN_ID":
scanNode.setTxnId(constantOperator.getBigint());
break;
case "LABEL":
scanNode.setLabel(constantOperator.getVarchar());
break;
case "JOB_ID":
scanNode.setJobId(constantOperator.getBigint());
break;
case "TYPE":
scanNode.setType(constantOperator.getVarchar());
break;
case "STATE":
scanNode.setState(constantOperator.getVarchar());
break;
case "LOG":
scanNode.setLogPattern("^" + constantOperator.getVarchar() + "$");
break;
case "LEVEL":
scanNode.setLogLevel(constantOperator.getVarchar());
break;
default:
break;
}
}
if (columnRefOperator.getName().equals("TIMESTAMP")) {
BinaryPredicateOperator.BinaryType opType = binaryPredicateOperator.getBinaryType();
if (opType == BinaryPredicateOperator.BinaryType.EQ) {
scanNode.setLogStartTs(constantOperator.getBigint());
scanNode.setLogEndTs(constantOperator.getBigint() + 1);
} else if (opType == BinaryPredicateOperator.BinaryType.GT) {
scanNode.setLogStartTs(constantOperator.getBigint() + 1);
} else if (opType == BinaryPredicateOperator.BinaryType.GE) {
scanNode.setLogStartTs(constantOperator.getBigint());
} else if (opType == BinaryPredicateOperator.BinaryType.LT) {
scanNode.setLogEndTs(constantOperator.getBigint());
} else if (opType == BinaryPredicateOperator.BinaryType.LE) {
scanNode.setLogEndTs(constantOperator.getBigint() + 1);
}
}
} else if (predicate instanceof LikePredicateOperator) {
LikePredicateOperator like = (LikePredicateOperator) predicate;
if (columnRefOperator.getName().equals("LOG")) {
if (like.getLikeType() == LikePredicateOperator.LikeType.REGEXP) {
scanNode.setLogPattern(((ConstantOperator) like.getChildren().get(1)).getVarchar());
} else {
throw UnsupportedException.unsupportedException("only support `regexp` or `rlike` for log grep");
}
}
}
}
if (scanNode.isBeSchemaTable()) {
scanNode.computeBeScanRanges();
}
if (scanNode.getLimit() > 0) {
scanNode.setLogLimit(Math.min(scanNode.getLimit(), Config.max_per_node_grep_log_limit));
} else {
scanNode.setLogLimit(Config.max_per_node_grep_log_limit);
}
context.getScanNodes().add(scanNode);
PlanFragment fragment = new PlanFragment(context.getNextFragmentId(), scanNode,
scanNode.isBeSchemaTable() ? DataPartition.RANDOM : DataPartition.UNPARTITIONED);
context.getFragments().add(fragment);
return fragment;
}