aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoraidarsamer <aidarsamer@ydb.tech>2022-10-24 19:30:30 +0300
committeraidarsamer <aidarsamer@ydb.tech>2022-10-24 19:30:30 +0300
commit41e8dfe1db3b9e32a7d1497494d73fbb9f8aec00 (patch)
tree1c1e1efcce91cfbdf7d87b924f9dd886003f03dd
parenta4b4ed91314a97907ef9a10f2b82768f763fdfe5 (diff)
downloadydb-41e8dfe1db3b9e32a7d1497494d73fbb9f8aec00.tar.gz
Add check for non-empty Handlers in AggregateCombine
Add check for input handlers in AggregateCombine.
-rw-r--r--ydb/core/kqp/opt/physical/kqp_opt_phy_olap_agg.cpp5
-rw-r--r--ydb/core/kqp/ut/kqp_olap_ut.cpp16
2 files changed, 20 insertions, 1 deletions
diff --git a/ydb/core/kqp/opt/physical/kqp_opt_phy_olap_agg.cpp b/ydb/core/kqp/opt/physical/kqp_opt_phy_olap_agg.cpp
index 472930a7f8..7d8af7cc70 100644
--- a/ydb/core/kqp/opt/physical/kqp_opt_phy_olap_agg.cpp
+++ b/ydb/core/kqp/opt/physical/kqp_opt_phy_olap_agg.cpp
@@ -61,6 +61,10 @@ TExprBase KqpPushOlapAggregate(TExprBase node, TExprContext& ctx, const TKqpOpti
}
auto aggCombine = node.Cast<TCoAggregateCombine>();
+ if (aggCombine.Handlers().Size() == 0) {
+ return node;
+ }
+
auto maybeRead = aggCombine.Input().Maybe<TKqpReadOlapTableRanges>();
if (!maybeRead) {
maybeRead = aggCombine.Input().Maybe<TCoExtractMembers>().Input().Maybe<TKqpReadOlapTableRanges>();
@@ -71,7 +75,6 @@ TExprBase KqpPushOlapAggregate(TExprBase node, TExprContext& ctx, const TKqpOpti
}
auto read = maybeRead.Cast();
-
auto aggs = Build<TKqpOlapAggOperationList>(ctx, node.Pos());
// TODO: TMaybeNode<TKqpOlapAggOperation>;
for (auto handler: aggCombine.Handlers()) {
diff --git a/ydb/core/kqp/ut/kqp_olap_ut.cpp b/ydb/core/kqp/ut/kqp_olap_ut.cpp
index 765a7cf107..408f1fad59 100644
--- a/ydb/core/kqp/ut/kqp_olap_ut.cpp
+++ b/ydb/core/kqp/ut/kqp_olap_ut.cpp
@@ -1652,6 +1652,22 @@ Y_UNIT_TEST_SUITE(KqpOlap) {
TestAggregationsInternal(cases);
}
+ Y_UNIT_TEST(Aggregation_ResultDistinctCountRI_GroupByL) {
+ TAggregationTestCase testCase;
+ testCase.SetQuery(R"(
+ SELECT
+ level, COUNT(DISTINCT resource_id)
+ FROM `/Root/olapStore/olapTable`
+ GROUP BY level
+ ORDER BY level
+ )")
+ .AddExpectedPlanOptions("CombineCore")
+ .SetExpectedReply("[[[0];4600u];[[1];4600u];[[2];4600u];[[3];4600u];[[4];4600u]]")
+ ;
+
+ TestAggregations({ testCase });
+ }
+
Y_UNIT_TEST(Aggregation_ResultCountAll_FilterL) {
//https://st.yandex-team.ru/KIKIMR-16073
return;