[Bug](materialized-view) fix isDisableTuplesMVRewriter rreturn true when expr is literal (#18246)
fix isDisableTuplesMVRewriter rreturn true when expr is literal
This commit is contained in:
@ -2201,6 +2201,12 @@ public abstract class Expr extends TreeNode<Expr> implements ParseNode, Cloneabl
|
||||
|
||||
public boolean matchExprs(List<Expr> exprs, SelectStmt stmt, boolean ignoreAlias, String tableName)
|
||||
throws AnalysisException {
|
||||
List<SlotRef> slots = new ArrayList<>();
|
||||
collect(SlotRef.class, slots);
|
||||
if (slots.size() == 0) {
|
||||
return true;
|
||||
}
|
||||
|
||||
String name = MaterializedIndexMeta.normalizeName(toSqlWithoutTbl());
|
||||
for (Expr expr : exprs) {
|
||||
if (CreateMaterializedViewStmt.isMVColumnNormal(name)
|
||||
|
||||
@ -272,6 +272,9 @@ public abstract class QueryStmt extends StatementBase implements Queriable {
|
||||
}
|
||||
|
||||
public boolean isDisableTuplesMVRewriter(Expr expr) {
|
||||
if (disableTuplesMVRewriter.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
return expr.isBoundByTupleIds(disableTuplesMVRewriter.stream().collect(Collectors.toList()));
|
||||
}
|
||||
|
||||
|
||||
@ -1327,6 +1327,7 @@ public class SingleNodePlanner {
|
||||
String errorMsg = "select fail reason: ";
|
||||
if (queryStmt instanceof SelectStmt) {
|
||||
SelectStmt selectStmt = (SelectStmt) queryStmt;
|
||||
Set<TupleId> disableTuplesMVRewriter = Sets.newHashSet();
|
||||
for (TableRef tableRef : selectStmt.getTableRefs()) {
|
||||
if (tableRef instanceof InlineViewRef) {
|
||||
selectFailed |= selectMaterializedView(((InlineViewRef) tableRef).getViewStmt(),
|
||||
@ -1386,9 +1387,10 @@ public class SingleNodePlanner {
|
||||
}
|
||||
if (tupleSelectFailed) {
|
||||
selectFailed = true;
|
||||
selectStmt.updateDisableTuplesMVRewriter(olapScanNode.getTupleId());
|
||||
disableTuplesMVRewriter.add(olapScanNode.getTupleId());
|
||||
}
|
||||
}
|
||||
selectStmt.updateDisableTuplesMVRewriter(disableTuplesMVRewriter);
|
||||
} else {
|
||||
Preconditions.checkState(queryStmt instanceof SetOperationStmt);
|
||||
SetOperationStmt unionStmt = (SetOperationStmt) queryStmt;
|
||||
|
||||
Reference in New Issue
Block a user