Skip to content

Commit

Permalink
fix rule set
Browse files Browse the repository at this point in the history
  • Loading branch information
murphyatwork committed Nov 11, 2022
1 parent 6dd6c68 commit 830e6f3
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,6 @@ public class RuleSet {
PruneHDFSScanColumnRule.HUDI_SCAN,
PruneScanColumnRule.JDBC_SCAN,
new PruneProjectColumnsRule(),
new PruneProjectRule(),
new PruneFilterColumnsRule(),
new PruneAggregateColumnsRule(),
new PruneTopNColumnsRule(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import com.starrocks.sql.optimizer.operator.scalar.ColumnRefOperator;
import com.starrocks.sql.optimizer.operator.scalar.ScalarOperator;
import com.starrocks.sql.optimizer.rule.RuleType;
import org.apache.commons.collections.CollectionUtils;

import java.util.List;
import java.util.Map;
Expand Down Expand Up @@ -52,11 +53,17 @@ public List<OptExpression> transform(OptExpression input, OptimizerContext conte
}));

if (newMap.isEmpty()) {
ColumnRefOperator smallestColumn = Utils.findSmallestColumnRef(
List<ColumnRefOperator> outputColumns =
projectOperator.getOutputColumns(new ExpressionContext(input.inputAt(0))).getStream().
mapToObj(context.getColumnRefFactory()::getColumnRef).collect(Collectors.toList()));
newMap.put(smallestColumn, smallestColumn);
requiredInputColumns.union(smallestColumn);
mapToObj(context.getColumnRefFactory()::getColumnRef).collect(Collectors.toList());
if (CollectionUtils.isNotEmpty(outputColumns)) {
ColumnRefOperator smallestColumn = Utils.findSmallestColumnRef(outputColumns);
ScalarOperator expr = projectOperator.getColumnRefMap().get(smallestColumn);
if (!smallestColumn.equals(expr)) {
newMap.put(smallestColumn, expr);
requiredInputColumns.union(smallestColumn);
}
}
}

// Change the requiredOutputColumns in context
Expand Down

0 comments on commit 830e6f3

Please sign in to comment.