[fix](Nereids) lost having when analyze sort-having-agg (#20914)
This commit is contained in:
@ -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));
|
||||
});
|
||||
})
|
||||
),
|
||||
|
||||
@ -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());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user