[fix](Nereids) lost having when analyze sort-having-agg (#20914)

This commit is contained in:
morrySnow
2023-06-16 22:13:28 +08:00
committed by GitHub
parent 7ee744ff5a
commit bb4f10b457
2 changed files with 9 additions and 1 deletions

View File

@ -115,7 +115,8 @@ public class FillUpMissingSlots implements AnalysisRuleFactory {
if (notChanged && a.equals(agg)) {
return null;
}
return notChanged ? sort.withChildren(a) : new LogicalSort<>(newOrderKeys, a);
return notChanged ? sort.withChildren(sort.child().withChildren(a))
: new LogicalSort<>(newOrderKeys, sort.child().withChildren(a));
});
})
),

View File

@ -538,4 +538,11 @@ public class FillUpMissingSlotsTest extends AnalyzeCheckTestBase implements Memo
.map(Alias::toSlot).collect(Collectors.toList()))
));
}
@Test
void testSortHavingAgg() {
String sql = "SELECT pk FROM t1 GROUP BY pk HAVING SUM(a1) > (SELECT AVG(a1) FROM t1) ORDER BY SUM(a1)";
PlanChecker.from(connectContext).analyze(sql)
.matches(logicalFilter());
}
}