Skip to content

Commit

Permalink
disable dict optimization when having predicate has dictionary column (
Browse files Browse the repository at this point in the history
…#5914)

(cherry picked from commit 0c92d3a)
  • Loading branch information
mchades authored and stdpain committed May 11, 2022
1 parent 4ad057e commit 3d962e9
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -190,15 +190,20 @@ private boolean couldApplyStringDict(CallOperator operator, ColumnRefSet dictSet
public void fillDisableDictOptimizeColumns(ColumnRefSet resultSet, Set<Integer> dictColIds) {
ColumnRefSet dictSet = new ColumnRefSet();
dictColIds.forEach(dictSet::union);
getAggregations().values().forEach((v) -> {
final ScalarOperator predicate = getPredicate();
getAggregations().forEach((k, v) -> {
if (!couldApplyStringDict(v, dictSet)) {
resultSet.union(v.getUsedColumns());
}

// disable DictOptimize when having predicate couldn't push down
if (predicate != null && predicate.getUsedColumns().isIntersect(k.getUsedColumns())) {
resultSet.union(v.getUsedColumns());
}
});
// Now we disable DictOptimize when group by predicate couldn't push down
final ScalarOperator predicate = getPredicate();
if (predicate != null) {
final ColumnRefSet predicateUsedColumns = getPredicate().getUsedColumns();
final ColumnRefSet predicateUsedColumns = predicate.getUsedColumns();
for (Integer dictColId : dictColIds) {
if (predicateUsedColumns.contains(dictColId)) {
resultSet.union(dictColId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -618,6 +618,11 @@ public void testAggHaving() throws Exception {
"having a < b*1.2 or c not like '%open%'";
plan = getFragmentPlan(sql);
Assert.assertFalse(plan.contains("Decode"));

// test couldn't push down having predicate
sql = "SELECT count(*) a FROM supplier having max(S_ADDRESS)='123'";
plan = getFragmentPlan(sql);
Assert.assertFalse(plan.contains("Decode"));
}

@Test
Expand Down

0 comments on commit 3d962e9

Please sign in to comment.