Skip to content
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
9 changes: 8 additions & 1 deletion ydb/core/kqp/opt/physical/predicate_collector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,14 @@ bool AbstractTreeCanBePushed(const TExprBase& expr, const TExprNode* ) {

bool CheckExpressionNodeForPushdown(const TExprBase& node, const TExprNode* lambdaArg) {
if constexpr (NKikimr::NSsa::RuntimeVersion >= 5U) {
if (node.Maybe<TCoIf>() || node.Maybe<TCoJust>() || node.Maybe<TCoCoalesce>()) {
if (node.Maybe<TCoJust>() || node.Maybe<TCoCoalesce>()) {
return true;
}
// Temporary fix for https://github.com/ydb-platform/ydb/issues/7967
else if (auto ifPred = node.Maybe<TCoIf>()) {
if (ifPred.ThenValue().Maybe<TCoNothing>() || ifPred.ElseValue().Maybe<TCoNothing>()) {
return false;
}
return true;
}
}
Expand Down
38 changes: 38 additions & 0 deletions ydb/core/kqp/ut/join/data/queries/tpcds34.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
pragma TablePathPrefix = "/Root/test/ds/";

-- NB: Subquerys
-- start query 1 in stream 0 using template query34.tpl and seed 1971067816
select c_last_name
,c_first_name
,c_salutation
,c_preferred_cust_flag
,ss_ticket_number
,cnt from
(select store_sales.ss_ticket_number ss_ticket_number
,store_sales.ss_customer_sk ss_customer_sk
,count(*) cnt
from store_sales as store_sales
cross join date_dim as date_dim
cross join store as store
cross join household_demographics as household_demographics
where store_sales.ss_sold_date_sk = date_dim.d_date_sk
and store_sales.ss_store_sk = store.s_store_sk
and store_sales.ss_hdemo_sk = household_demographics.hd_demo_sk
and (date_dim.d_dom between 1 and 3 or date_dim.d_dom between 25 and 28)
and (household_demographics.hd_buy_potential = '>10000' or
household_demographics.hd_buy_potential = 'Unknown')
and household_demographics.hd_vehicle_count > 0
and (case when household_demographics.hd_vehicle_count > 0
then household_demographics.hd_dep_count/ household_demographics.hd_vehicle_count
else null
end) > 1.2
and date_dim.d_year in (2000,2000+1,2000+2)
and store.s_county in ('Salem County','Terrell County','Arthur County','Oglethorpe County',
'Lunenburg County','Perry County','Halifax County','Sumner County')
group by store_sales.ss_ticket_number,store_sales.ss_customer_sk) dn
cross join customer as customer
where ss_customer_sk = c_customer_sk
and cnt between 15 and 20
order by c_last_name,c_first_name,c_salutation,c_preferred_cust_flag desc, ss_ticket_number;

-- end query 1 in stream 0 using template query34.tpl
4 changes: 4 additions & 0 deletions ydb/core/kqp/ut/join/kqp_join_order_ut.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,10 @@ Y_UNIT_TEST_SUITE(KqpJoinOrder) {
ExecuteJoinOrderTestDataQueryWithStats("queries/tpcds16.sql", "stats/tpcds1000s.json", StreamLookupJoin, ColumnStore);
}

Y_UNIT_TEST_XOR_OR_BOTH_FALSE(TPCDS34, StreamLookupJoin, ColumnStore) {
ExecuteJoinOrderTestDataQueryWithStats("queries/tpcds34.sql", "stats/tpcds1000s.json", StreamLookupJoin, ColumnStore);
}

Y_UNIT_TEST_XOR_OR_BOTH_FALSE(TPCDS61, StreamLookupJoin, ColumnStore) {
ExecuteJoinOrderTestDataQueryWithStats("queries/tpcds61.sql", "stats/tpcds1000s.json", StreamLookupJoin, ColumnStore);
}
Expand Down
30 changes: 30 additions & 0 deletions ydb/core/kqp/ut/olap/kqp_olap_ut.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2054,6 +2054,36 @@ Y_UNIT_TEST_SUITE(KqpOlap) {
}
*/

// Unit test for https://github.com/ydb-platform/ydb/issues/7967
Y_UNIT_TEST(PredicatePushdownNulls) {
auto settings = TKikimrSettings()
.SetWithSampleTables(false);

TKikimrRunner kikimr(settings);

TStreamExecScanQuerySettings scanSettings;
scanSettings.Explain(true);

TLocalHelper(kikimr.GetTestServer()).CreateTestOlapTable();
WriteTestData(kikimr, "/Root/olapStore/olapTable", 10000, 3000000, 10);

auto tableClient = kikimr.GetTableClient();

TString query = R"(
SELECT `timestamp` FROM `/Root/olapStore/olapTable` WHERE
(case when level > 0
then level
else null
end) > 0;
)";

auto it = tableClient.StreamExecuteScanQuery(query).GetValueSync();
// Check for successful execution
auto streamPart = it.ReadNext().GetValueSync();

UNIT_ASSERT(streamPart.IsSuccess());
}

Y_UNIT_TEST(PredicatePushdownCastErrors) {
auto settings = TKikimrSettings()
.SetWithSampleTables(false);
Expand Down