Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
englefly committed Jun 26, 2024
1 parent 44ac33f commit a9b6b52
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,8 @@ public class StatementContext implements Closeable {

private ShortCircuitQueryContext shortCircuitQueryContext;

private boolean hasMvCandidates = false;

public StatementContext() {
this(ConnectContext.get(), null, 0);
}
Expand Down Expand Up @@ -535,4 +537,12 @@ public TableId getTableId(TableIf tableIf) {
this.tableIdMapping.put(tableIdentifier, tableId);
return tableId;
}

public boolean isHasMvCandidates() {
return hasMvCandidates;
}

public void setHasMvCandidates(boolean hasMvCandidates) {
this.hasMvCandidates = hasMvCandidates;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,10 @@ private Set<Column> getColumnForRangePredicate(Set<Expression> expressions) {

@Override
public Cost visitPhysicalFilter(PhysicalFilter<? extends Plan> filter, PlanContext context) {
double exprCost = expressionTreeCost(filter.getExpressions());
double exprCost = 0;
if (context.getStatementContext().isHasMvCandidates()) {
exprCost = expressionTreeCost(filter.getExpressions());
}
double filterCostFactor = 0.0001;
if (ConnectContext.get() != null) {
filterCostFactor = ConnectContext.get().getSessionVariable().filterCostFactor;
Expand Down Expand Up @@ -349,7 +352,7 @@ public Cost visitPhysicalHashJoin(

double leftRowCount = probeStats.getRowCount();
double rightRowCount = buildStats.getRowCount();
if (leftRowCount == rightRowCount) {
if ((long) leftRowCount == (long) rightRowCount) {
// reorder by connectivity to be friendly to runtime filter.
if (physicalHashJoin.getGroupExpression().isPresent()
&& physicalHashJoin.getGroupExpression().get().getOwnerGroup() != null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ public void initMaterializationContext(CascadesContext cascadesContext) {
mtmvCache.getLogicalPlan(), mtmvCache.getOriginalPlan(), ImmutableList.of(),
ImmutableList.of(), cascadesContext,
mtmvCache.getStructInfo().withTableBitSet(tableBitSetInCurrentCascadesContext)));
cascadesContext.getStatementContext().setHasMvCandidates(true);
} catch (Exception e) {
LOG.warn(String.format("MaterializationContext init mv cache generate fail, current queryId is %s",
cascadesContext.getConnectContext().getQueryIdentifier()), e);
Expand Down

0 comments on commit a9b6b52

Please sign in to comment.