@@ -1344,26 +1344,30 @@ void WaitForZeroSessions(const NKqp::TKqpCounters& counters) {
13441344 UNIT_ASSERT_C (count, " Unable to wait for proper active session count, it looks like cancelation doesn`t work" );
13451345}
13461346
1347- NJson::TJsonValue SimplifyPlan (NJson::TJsonValue& opt) {
1347+ NJson::TJsonValue SimplifyPlan (NJson::TJsonValue& opt, const TGetPlanParams& params ) {
13481348 if (auto ops = opt.GetMapSafe ().find (" Operators" ); ops != opt.GetMapSafe ().end ()) {
13491349 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+ ) {
13511355 NJson::TJsonValue newChildren;
13521356
13531357 for (auto c : opt.GetMapSafe ().at (" Plans" ).GetArraySafe ()) {
1354- newChildren.AppendValue (SimplifyPlan (c));
1358+ newChildren.AppendValue (SimplifyPlan (c, params ));
13551359 }
13561360
13571361 opt[" Plans" ] = newChildren;
13581362 return opt;
13591363 }
1360- else if (opName.find (" Table" ) != TString::npos ) {
1364+ else if (opName.find (" Table" ) != TString::npos) {
13611365 return opt;
13621366 }
13631367 }
13641368
13651369 auto firstPlan = opt.GetMapSafe ().at (" Plans" ).GetArraySafe ()[0 ];
1366- return SimplifyPlan (firstPlan);
1370+ return SimplifyPlan (firstPlan, params );
13671371}
13681372
13691373bool JoinOrderAndAlgosMatch (const NJson::TJsonValue& opt, const NJson::TJsonValue& ref) {
@@ -1398,7 +1402,7 @@ bool JoinOrderAndAlgosMatch(const NJson::TJsonValue& opt, const NJson::TJsonValu
13981402bool JoinOrderAndAlgosMatch (const TString& optimized, const TString& reference){
13991403 NJson::TJsonValue optRoot;
14001404 NJson::ReadJsonTree (optimized, &optRoot, true );
1401- optRoot = SimplifyPlan (optRoot.GetMapSafe ().at (" SimplifiedPlan" ));
1405+ optRoot = SimplifyPlan (optRoot.GetMapSafe ().at (" SimplifiedPlan" ), {} );
14021406
14031407 NJson::TJsonValue refRoot;
14041408 NJson::ReadJsonTree (reference, &refRoot, true );
@@ -1407,11 +1411,18 @@ bool JoinOrderAndAlgosMatch(const TString& optimized, const TString& reference){
14071411}
14081412
14091413/* Temporary solution to canonize tests */
1410- NJson::TJsonValue GetDetailedJoinOrderImpl (const NJson::TJsonValue& opt) {
1414+ NJson::TJsonValue GetDetailedJoinOrderImpl (const NJson::TJsonValue& opt, const TGetPlanParams& params ) {
14111415 NJson::TJsonValue res;
14121416
1417+ if (!opt.GetMapSafe ().contains (" Plans" ) && !params.IncludeTables ) {
1418+ return res;
1419+ }
1420+
14131421 auto op = opt.GetMapSafe ().at (" Operators" ).GetArraySafe ()[0 ];
14141422 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+ }
14151426
14161427
14171428 if (!opt.GetMapSafe ().contains (" Plans" )) {
@@ -1420,17 +1431,17 @@ NJson::TJsonValue GetDetailedJoinOrderImpl(const NJson::TJsonValue& opt) {
14201431 }
14211432
14221433 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 ));
14251436 }
14261437 return res;
14271438}
14281439
1429- NJson::TJsonValue GetDetailedJoinOrder (const TString& deserializedPlan) {
1440+ NJson::TJsonValue GetDetailedJoinOrder (const TString& deserializedPlan, const TGetPlanParams& params ) {
14301441 NJson::TJsonValue optRoot;
14311442 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 );
14341445}
14351446
14361447NJson::TJsonValue GetJoinOrderImpl (const NJson::TJsonValue& opt) {
@@ -1452,8 +1463,8 @@ NJson::TJsonValue GetJoinOrderImpl(const NJson::TJsonValue& opt) {
14521463NJson::TJsonValue GetJoinOrder (const TString& deserializedPlan) {
14531464 NJson::TJsonValue optRoot;
14541465 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);
14571468}
14581469
14591470
0 commit comments