Skip to content

Commit 3675769

Browse files
Stopped pushing null as arguments to TCoIf in column shards (#8536)
1 parent 86bff9d commit 3675769

File tree

4 files changed

+80
-1
lines changed

4 files changed

+80
-1
lines changed

ydb/core/kqp/opt/physical/predicate_collector.cpp

+8-1
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,14 @@ bool AbstractTreeCanBePushed(const TExprBase& expr, const TExprNode* ) {
143143

144144
bool CheckExpressionNodeForPushdown(const TExprBase& node, const TExprNode* lambdaArg) {
145145
if constexpr (NKikimr::NSsa::RuntimeVersion >= 5U) {
146-
if (node.Maybe<TCoIf>() || node.Maybe<TCoJust>() || node.Maybe<TCoCoalesce>()) {
146+
if (node.Maybe<TCoJust>() || node.Maybe<TCoCoalesce>()) {
147+
return true;
148+
}
149+
// Temporary fix for https://github.com/ydb-platform/ydb/issues/7967
150+
else if (auto ifPred = node.Maybe<TCoIf>()) {
151+
if (ifPred.ThenValue().Maybe<TCoNothing>() || ifPred.ElseValue().Maybe<TCoNothing>()) {
152+
return false;
153+
}
147154
return true;
148155
}
149156
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
pragma TablePathPrefix = "/Root/test/ds/";
2+
3+
-- NB: Subquerys
4+
-- start query 1 in stream 0 using template query34.tpl and seed 1971067816
5+
select c_last_name
6+
,c_first_name
7+
,c_salutation
8+
,c_preferred_cust_flag
9+
,ss_ticket_number
10+
,cnt from
11+
(select store_sales.ss_ticket_number ss_ticket_number
12+
,store_sales.ss_customer_sk ss_customer_sk
13+
,count(*) cnt
14+
from store_sales as store_sales
15+
cross join date_dim as date_dim
16+
cross join store as store
17+
cross join household_demographics as household_demographics
18+
where store_sales.ss_sold_date_sk = date_dim.d_date_sk
19+
and store_sales.ss_store_sk = store.s_store_sk
20+
and store_sales.ss_hdemo_sk = household_demographics.hd_demo_sk
21+
and (date_dim.d_dom between 1 and 3 or date_dim.d_dom between 25 and 28)
22+
and (household_demographics.hd_buy_potential = '>10000' or
23+
household_demographics.hd_buy_potential = 'Unknown')
24+
and household_demographics.hd_vehicle_count > 0
25+
and (case when household_demographics.hd_vehicle_count > 0
26+
then household_demographics.hd_dep_count/ household_demographics.hd_vehicle_count
27+
else null
28+
end) > 1.2
29+
and date_dim.d_year in (2000,2000+1,2000+2)
30+
and store.s_county in ('Salem County','Terrell County','Arthur County','Oglethorpe County',
31+
'Lunenburg County','Perry County','Halifax County','Sumner County')
32+
group by store_sales.ss_ticket_number,store_sales.ss_customer_sk) dn
33+
cross join customer as customer
34+
where ss_customer_sk = c_customer_sk
35+
and cnt between 15 and 20
36+
order by c_last_name,c_first_name,c_salutation,c_preferred_cust_flag desc, ss_ticket_number;
37+
38+
-- end query 1 in stream 0 using template query34.tpl

ydb/core/kqp/ut/join/kqp_join_order_ut.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -331,6 +331,10 @@ Y_UNIT_TEST_SUITE(KqpJoinOrder) {
331331
ExecuteJoinOrderTestDataQueryWithStats("queries/tpcds16.sql", "stats/tpcds1000s.json", StreamLookupJoin, ColumnStore);
332332
}
333333

334+
Y_UNIT_TEST_XOR_OR_BOTH_FALSE(TPCDS34, StreamLookupJoin, ColumnStore) {
335+
ExecuteJoinOrderTestDataQueryWithStats("queries/tpcds34.sql", "stats/tpcds1000s.json", StreamLookupJoin, ColumnStore);
336+
}
337+
334338
Y_UNIT_TEST_XOR_OR_BOTH_FALSE(TPCDS61, StreamLookupJoin, ColumnStore) {
335339
ExecuteJoinOrderTestDataQueryWithStats("queries/tpcds61.sql", "stats/tpcds1000s.json", StreamLookupJoin, ColumnStore);
336340
}

ydb/core/kqp/ut/olap/kqp_olap_ut.cpp

+30
Original file line numberDiff line numberDiff line change
@@ -2054,6 +2054,36 @@ Y_UNIT_TEST_SUITE(KqpOlap) {
20542054
}
20552055
*/
20562056

2057+
// Unit test for https://github.com/ydb-platform/ydb/issues/7967
2058+
Y_UNIT_TEST(PredicatePushdownNulls) {
2059+
auto settings = TKikimrSettings()
2060+
.SetWithSampleTables(false);
2061+
2062+
TKikimrRunner kikimr(settings);
2063+
2064+
TStreamExecScanQuerySettings scanSettings;
2065+
scanSettings.Explain(true);
2066+
2067+
TLocalHelper(kikimr.GetTestServer()).CreateTestOlapTable();
2068+
WriteTestData(kikimr, "/Root/olapStore/olapTable", 10000, 3000000, 10);
2069+
2070+
auto tableClient = kikimr.GetTableClient();
2071+
2072+
TString query = R"(
2073+
SELECT `timestamp` FROM `/Root/olapStore/olapTable` WHERE
2074+
(case when level > 0
2075+
then level
2076+
else null
2077+
end) > 0;
2078+
)";
2079+
2080+
auto it = tableClient.StreamExecuteScanQuery(query).GetValueSync();
2081+
// Check for successful execution
2082+
auto streamPart = it.ReadNext().GetValueSync();
2083+
2084+
UNIT_ASSERT(streamPart.IsSuccess());
2085+
}
2086+
20572087
Y_UNIT_TEST(PredicatePushdownCastErrors) {
20582088
auto settings = TKikimrSettings()
20592089
.SetWithSampleTables(false);

0 commit comments

Comments
 (0)