@@ -1344,26 +1344,30 @@ void WaitForZeroSessions(const NKqp::TKqpCounters& counters) {
1344
1344
UNIT_ASSERT_C (count, " Unable to wait for proper active session count, it looks like cancelation doesn`t work" );
1345
1345
}
1346
1346
1347
- NJson::TJsonValue SimplifyPlan (NJson::TJsonValue& opt) {
1347
+ NJson::TJsonValue SimplifyPlan (NJson::TJsonValue& opt, const TGetPlanParams& params ) {
1348
1348
if (auto ops = opt.GetMapSafe ().find (" Operators" ); ops != opt.GetMapSafe ().end ()) {
1349
1349
auto opName = ops->second .GetArraySafe ()[0 ].GetMapSafe ().at (" Name" ).GetStringSafe ();
1350
- if (opName.find (" Join" ) != TString::npos || opName.find (" Union" ) != TString::npos ) {
1350
+ if (
1351
+ opName.find (" Join" ) != TString::npos ||
1352
+ opName.find (" Union" ) != TString::npos ||
1353
+ (opName.find (" Filter" ) != TString::npos && params.IncludeFilters )
1354
+ ) {
1351
1355
NJson::TJsonValue newChildren;
1352
1356
1353
1357
for (auto c : opt.GetMapSafe ().at (" Plans" ).GetArraySafe ()) {
1354
- newChildren.AppendValue (SimplifyPlan (c));
1358
+ newChildren.AppendValue (SimplifyPlan (c, params ));
1355
1359
}
1356
1360
1357
1361
opt[" Plans" ] = newChildren;
1358
1362
return opt;
1359
1363
}
1360
- else if (opName.find (" Table" ) != TString::npos ) {
1364
+ else if (opName.find (" Table" ) != TString::npos) {
1361
1365
return opt;
1362
1366
}
1363
1367
}
1364
1368
1365
1369
auto firstPlan = opt.GetMapSafe ().at (" Plans" ).GetArraySafe ()[0 ];
1366
- return SimplifyPlan (firstPlan);
1370
+ return SimplifyPlan (firstPlan, params );
1367
1371
}
1368
1372
1369
1373
bool JoinOrderAndAlgosMatch (const NJson::TJsonValue& opt, const NJson::TJsonValue& ref) {
@@ -1398,7 +1402,7 @@ bool JoinOrderAndAlgosMatch(const NJson::TJsonValue& opt, const NJson::TJsonValu
1398
1402
bool JoinOrderAndAlgosMatch (const TString& optimized, const TString& reference){
1399
1403
NJson::TJsonValue optRoot;
1400
1404
NJson::ReadJsonTree (optimized, &optRoot, true );
1401
- optRoot = SimplifyPlan (optRoot.GetMapSafe ().at (" SimplifiedPlan" ));
1405
+ optRoot = SimplifyPlan (optRoot.GetMapSafe ().at (" SimplifiedPlan" ), {} );
1402
1406
1403
1407
NJson::TJsonValue refRoot;
1404
1408
NJson::ReadJsonTree (reference, &refRoot, true );
@@ -1407,11 +1411,18 @@ bool JoinOrderAndAlgosMatch(const TString& optimized, const TString& reference){
1407
1411
}
1408
1412
1409
1413
/* Temporary solution to canonize tests */
1410
- NJson::TJsonValue GetDetailedJoinOrderImpl (const NJson::TJsonValue& opt) {
1414
+ NJson::TJsonValue GetDetailedJoinOrderImpl (const NJson::TJsonValue& opt, const TGetPlanParams& params ) {
1411
1415
NJson::TJsonValue res;
1412
1416
1417
+ if (!opt.GetMapSafe ().contains (" Plans" ) && !params.IncludeTables ) {
1418
+ return res;
1419
+ }
1420
+
1413
1421
auto op = opt.GetMapSafe ().at (" Operators" ).GetArraySafe ()[0 ];
1414
1422
res[" op_name" ] = op.GetMapSafe ().at (" Name" ).GetStringSafe ();
1423
+ if (params.IncludeOptimizerEstimation && op.GetMapSafe ().contains (" E-Rows" )) {
1424
+ res[" e-size" ] = op.GetMapSafe ().at (" E-Rows" ).GetStringSafe ();
1425
+ }
1415
1426
1416
1427
1417
1428
if (!opt.GetMapSafe ().contains (" Plans" )) {
@@ -1420,17 +1431,17 @@ NJson::TJsonValue GetDetailedJoinOrderImpl(const NJson::TJsonValue& opt) {
1420
1431
}
1421
1432
1422
1433
auto subplans = opt.GetMapSafe ().at (" Plans" ).GetArraySafe ();
1423
- for (size_t i = 0 ; i< subplans.size (); ++i) {
1424
- res[" args" ].AppendValue (GetDetailedJoinOrderImpl (subplans[i]));
1434
+ for (size_t i = 0 ; i < subplans.size (); ++i) {
1435
+ res[" args" ].AppendValue (GetDetailedJoinOrderImpl (subplans[i], params ));
1425
1436
}
1426
1437
return res;
1427
1438
}
1428
1439
1429
- NJson::TJsonValue GetDetailedJoinOrder (const TString& deserializedPlan) {
1440
+ NJson::TJsonValue GetDetailedJoinOrder (const TString& deserializedPlan, const TGetPlanParams& params ) {
1430
1441
NJson::TJsonValue optRoot;
1431
1442
NJson::ReadJsonTree (deserializedPlan, &optRoot, true );
1432
- optRoot = SimplifyPlan (optRoot.GetMapSafe ().at (" SimplifiedPlan" ));
1433
- return GetDetailedJoinOrderImpl (SimplifyPlan ( optRoot) );
1443
+ optRoot = SimplifyPlan (optRoot.GetMapSafe ().at (" SimplifiedPlan" ), params );
1444
+ return GetDetailedJoinOrderImpl (optRoot, params );
1434
1445
}
1435
1446
1436
1447
NJson::TJsonValue GetJoinOrderImpl (const NJson::TJsonValue& opt) {
@@ -1452,8 +1463,8 @@ NJson::TJsonValue GetJoinOrderImpl(const NJson::TJsonValue& opt) {
1452
1463
NJson::TJsonValue GetJoinOrder (const TString& deserializedPlan) {
1453
1464
NJson::TJsonValue optRoot;
1454
1465
NJson::ReadJsonTree (deserializedPlan, &optRoot, true );
1455
- optRoot = SimplifyPlan (optRoot.GetMapSafe ().at (" SimplifiedPlan" ));
1456
- return GetJoinOrderImpl (SimplifyPlan ( optRoot) );
1466
+ optRoot = SimplifyPlan (optRoot.GetMapSafe ().at (" SimplifiedPlan" ), {} );
1467
+ return GetJoinOrderImpl (optRoot);
1457
1468
}
1458
1469
1459
1470
0 commit comments