Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BugFix]disable dict optimization when having predicate has dictionary column #5914

Merged
merged 1 commit into from
May 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -670,6 +670,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