Skip to content

Commit 7680649

Browse files
authored
add ut for stream index lookup join (#20729)
1 parent 704a4ec commit 7680649

File tree

1 file changed

+73
-0
lines changed

1 file changed

+73
-0
lines changed

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

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -991,6 +991,79 @@ Y_UNIT_TEST_TWIN(JoinByComplexKeyWithNullComponents, StreamLookupJoin) {
991991
}
992992
}
993993

994+
Y_UNIT_TEST_TWIN(JoinInclusionTest, StreamLookupJoin) {
995+
996+
if (StreamLookupJoin) {
997+
return;
998+
}
999+
1000+
NKikimrConfig::TAppConfig appConfig;
1001+
appConfig.MutableTableServiceConfig()->SetEnableKqpDataQueryStreamIdxLookupJoin(StreamLookupJoin);
1002+
1003+
TKikimrSettings serverSettings = TKikimrSettings().SetAppConfig(appConfig);;
1004+
1005+
TKikimrRunner kikimr(serverSettings);
1006+
auto db = kikimr.GetTableClient();
1007+
auto session = db.CreateSession().GetValueSync().GetSession();
1008+
1009+
{ // create tables
1010+
const TString query = R"(
1011+
create table A (
1012+
a int32, b int32,
1013+
primary key(a)
1014+
);
1015+
1016+
create table B (
1017+
a int32, b int32,
1018+
primary key(a, b),
1019+
index BView global on(b)
1020+
);
1021+
)";
1022+
UNIT_ASSERT(session.ExecuteSchemeQuery(query).GetValueSync().IsSuccess());
1023+
}
1024+
1025+
{ // fill tables
1026+
const TString query = R"(
1027+
$a = AsList(
1028+
AsStruct(1 as a, 2 as b),
1029+
AsStruct(2 as a, 2 as b),
1030+
AsStruct(3 as a, 2 as b),
1031+
AsStruct(4 as a, 2 as b),
1032+
);
1033+
1034+
$b = AsList(
1035+
AsStruct(1 as a, 2 as b),
1036+
AsStruct(2 as a, 2 as b),
1037+
AsStruct(3 as a, 2 as b),
1038+
AsStruct(4 as a, 2 as b),
1039+
1040+
);
1041+
1042+
insert into B select * from AS_TABLE($b);
1043+
insert into A select * from AS_TABLE($a);
1044+
insert into B (a, b) values (5, null);
1045+
1046+
)";
1047+
UNIT_ASSERT(session.ExecuteDataQuery(query, TTxControl::BeginTx().CommitTx()).GetValueSync().IsSuccess());
1048+
}
1049+
1050+
{
1051+
TExecDataQuerySettings execSettings;
1052+
execSettings.CollectQueryStats(ECollectQueryStatsMode::Profile);
1053+
1054+
const TString query = R"(
1055+
select A.a, A.b, B.a, B.b from A
1056+
left join (select * from B where b is null) as B
1057+
on A.a = B.a and A.b = B.b
1058+
)";
1059+
1060+
auto result = session.ExecuteDataQuery(query, TTxControl::BeginTx().CommitTx(), execSettings).ExtractValueSync();
1061+
CompareYson(R"([
1062+
[[1];[2];#;#];[[2];[2];#;#];[[3];[2];#;#];[[4];[2];#;#]
1063+
])", FormatResultSetYson(result.GetResultSet(0)));
1064+
}
1065+
}
1066+
9941067
Y_UNIT_TEST_TWIN(JoinWithComplexCondition, StreamLookupJoin) {
9951068
NKikimrConfig::TAppConfig appConfig;
9961069
appConfig.MutableTableServiceConfig()->SetEnableKqpDataQueryStreamIdxLookupJoin(StreamLookupJoin);

0 commit comments

Comments
 (0)