Skip to content

Commit 11641f7

Browse files
committed
add failing ut for FilterPushdownOverJoinOptionalSide feature flag (#27562)
1 parent d428e61 commit 11641f7

File tree

1 file changed

+71
-0
lines changed

1 file changed

+71
-0
lines changed

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

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,26 @@ void PrepareTables(TSession session) {
8585
INDEX idx GLOBAL ON (idx_a, idx_b)
8686
);
8787
88+
CREATE TABLE `Level1` ( `Id` Int32 NOT NULL, `Name` Utf8, `Date` Timestamp NOT NULL, `Level2_Name` Utf8, `OneToOne_Required_PK_Date` Timestamp, `Level1_Required_Id` Int32, `Level1_Optional_Id` Int32, `Level3_Name` Utf8,
89+
`Level2_Required_Id` Int32, `Level2_Optional_Id` Int32, `Level4_Name` Utf8, `Level3_Required_Id` Int32, `Level3_Optional_Id` Int32, `OneToOne_Optional_PK_Inverse4Id` Int32, `OneToMany_Required_Inverse4Id` Int32,
90+
`OneToMany_Optional_Inverse4Id` Int32, `OneToOne_Optional_PK_Inverse3Id` Int32, `OneToMany_Required_Inverse3Id` Int32, `OneToMany_Optional_Inverse3Id` Int32, `OneToOne_Optional_PK_Inverse2Id` Int32, `OneToMany_Required_Inverse2Id` Int32, `OneToMany_Optional_Inverse2Id` Int32,
91+
INDEX `IX_Level1_Level1_Optional_Id` GLOBAL SYNC ON (`Level1_Optional_Id`),
92+
INDEX `IX_Level1_Level1_Required_Id` GLOBAL SYNC ON (`Level1_Required_Id`),
93+
INDEX `IX_Level1_Level2_Optional_Id` GLOBAL SYNC ON (`Level2_Optional_Id`),
94+
INDEX `IX_Level1_Level2_Required_Id` GLOBAL SYNC ON (`Level2_Required_Id`),
95+
INDEX `IX_Level1_Level3_Optional_Id` GLOBAL SYNC ON (`Level3_Optional_Id`),
96+
INDEX `IX_Level1_Level3_Required_Id` GLOBAL SYNC ON (`Level3_Required_Id`),
97+
INDEX `IX_Level1_OneToMany_Optional_Inverse2Id` GLOBAL SYNC ON (`OneToMany_Optional_Inverse2Id`),
98+
INDEX `IX_Level1_OneToMany_Optional_Inverse3Id` GLOBAL SYNC ON (`OneToMany_Optional_Inverse3Id`),
99+
INDEX `IX_Level1_OneToMany_Optional_Inverse4Id` GLOBAL SYNC ON (`OneToMany_Optional_Inverse4Id`),
100+
INDEX `IX_Level1_OneToMany_Required_Inverse2Id` GLOBAL SYNC ON (`OneToMany_Required_Inverse2Id`),
101+
INDEX `IX_Level1_OneToMany_Required_Inverse3Id` GLOBAL SYNC ON (`OneToMany_Required_Inverse3Id`),
102+
INDEX `IX_Level1_OneToMany_Required_Inverse4Id` GLOBAL SYNC ON (`OneToMany_Required_Inverse4Id`),
103+
INDEX `IX_Level1_OneToOne_Optional_PK_Inverse2Id` GLOBAL SYNC ON (`OneToOne_Optional_PK_Inverse2Id`),
104+
INDEX `IX_Level1_OneToOne_Optional_PK_Inverse3Id` GLOBAL SYNC ON (`OneToOne_Optional_PK_Inverse3Id`),
105+
INDEX `IX_Level1_OneToOne_Optional_PK_Inverse4Id` GLOBAL SYNC ON (`OneToOne_Optional_PK_Inverse4Id`),
106+
PRIMARY KEY (`Id`)
107+
);
88108
CREATE TABLE X (x_id Int32, a Int32, b Int32, PRIMARY KEY(x_id));
89109
CREATE TABLE Y (y_id Int32, a Int32, b Int32, c Int32, PRIMARY KEY(y_id), INDEX ix_a GLOBAL ON (a));
90110
@@ -220,10 +240,12 @@ class TTester {
220240
bool OnlineReadOnly = false;
221241
NYdb::TParamsBuilder ParamsBuilder;
222242
bool NeedParams = false;
243+
bool FilterOptionalSide = true;
223244

224245
TTester& Run() {
225246
auto settings = TKikimrSettings();
226247
settings.AppConfig.MutableTableServiceConfig()->SetEnableKqpDataQueryStreamIdxLookupJoin(StreamLookup);
248+
settings.AppConfig.MutableTableServiceConfig()->SetFilterPushdownOverJoinOptionalSide(FilterOptionalSide);
227249

228250
TKikimrRunner kikimr(settings);
229251
auto db = kikimr.GetTableClient();
@@ -1117,6 +1139,55 @@ Y_UNIT_TEST_TWIN(LeftJoinOnRightTableOverIndex, StreamLookupJoin) {
11171139
tester.Run();
11181140
}
11191141

1142+
Y_UNIT_TEST_TWIN(TestEntityFramework, StreamLookupJoin) {
1143+
auto tester = TTester{
1144+
.Query=R"(
1145+
SELECT
1146+
`l1`.`Id`,
1147+
`l1`.`OneToOne_Required_PK_Date`,
1148+
`l1`.`Level1_Optional_Id`,
1149+
`l1`.`Level1_Required_Id`,
1150+
`l1`.`Level2_Name`,
1151+
`l1`.`OneToMany_Optional_Inverse2Id`,
1152+
`l1`.`OneToMany_Required_Inverse2Id`,
1153+
`l1`.`OneToOne_Optional_PK_Inverse2Id`
1154+
FROM `Level1` AS `l`
1155+
LEFT JOIN (
1156+
SELECT
1157+
`l0`.`Id` AS `Id`,
1158+
`l0`.`OneToOne_Required_PK_Date` AS `OneToOne_Required_PK_Date`,
1159+
`l0`.`Level1_Optional_Id` AS `Level1_Optional_Id`,
1160+
`l0`.`Level1_Required_Id` AS `Level1_Required_Id`,
1161+
`l0`.`Level2_Name` AS `Level2_Name`,
1162+
`l0`.`OneToMany_Optional_Inverse2Id` AS `OneToMany_Optional_Inverse2Id`,
1163+
`l0`.`OneToMany_Required_Inverse2Id` AS `OneToMany_Required_Inverse2Id`,
1164+
`l0`.`OneToOne_Optional_PK_Inverse2Id` AS `OneToOne_Optional_PK_Inverse2Id`
1165+
FROM `Level1` AS `l0`
1166+
WHERE
1167+
`l0`.`OneToOne_Required_PK_Date` IS NOT NULL AND
1168+
`l0`.`Level1_Required_Id` IS NOT NULL AND
1169+
`l0`.`OneToMany_Required_Inverse2Id` IS NOT NULL
1170+
) AS `l1`
1171+
ON
1172+
`l`.`Id` = CASE
1173+
WHEN `l1`.`OneToOne_Required_PK_Date` IS NOT NULL AND `l1`.`Level1_Required_Id` IS NOT NULL AND `l1`.`OneToMany_Required_Inverse2Id` IS NOT NULL THEN `l1`.`Id`
1174+
ELSE NULL
1175+
END
1176+
LEFT JOIN `Level1` AS `l2` ON `l1`.`Level1_Required_Id` = `l2`.`Id`
1177+
WHERE
1178+
`l1`.`OneToOne_Required_PK_Date` IS NOT NULL AND
1179+
`l1`.`Level1_Required_Id` IS NOT NULL AND
1180+
`l1`.`OneToMany_Required_Inverse2Id` IS NOT NULL AND `l2`.`Id` IN (1, 2)
1181+
)",
1182+
.Answer=R"([
1183+
])",
1184+
.StreamLookup=StreamLookupJoin,
1185+
.DoValidateStats=false,
1186+
.FilterOptionalSide=false // remove this to get failure
1187+
};
1188+
tester.Run();
1189+
}
1190+
11201191
Y_UNIT_TEST_TWIN(JoinLeftJoinPostJoinFilterTest, StreamLookupJoin) {
11211192
auto tester = TTester{
11221193
.Query=R"(

0 commit comments

Comments
 (0)