diff --git a/ydb/core/kqp/opt/kqp_query_plan.cpp b/ydb/core/kqp/opt/kqp_query_plan.cpp index 86a1dfa0b1a6..aa8a31c5cd03 100644 --- a/ydb/core/kqp/opt/kqp_query_plan.cpp +++ b/ydb/core/kqp/opt/kqp_query_plan.cpp @@ -16,6 +16,8 @@ #include #include +#include + #include #include #include @@ -1811,6 +1813,217 @@ void SetNonZero(NJson::TJsonValue& node, const TStringBuf& name, T value) { } } +void BuildPlanIndex(NJson::TJsonValue& plan, THashMap& planIndex, THashMap& precomputes) { + if (plan.GetMapSafe().contains("PlanNodeId")){ + auto id = plan.GetMapSafe().at("PlanNodeId").GetIntegerSafe(); + planIndex[id] = plan; + } + + if (plan.GetMapSafe().contains("Subplan Name")) { + const auto& precomputeName = plan.GetMapSafe().at("Subplan Name").GetStringSafe(); + + auto pos = precomputeName.find("precompute"); + if (pos != TString::npos) { + precomputes[precomputeName.substr(pos)] = plan; + } + } + + if (plan.GetMapSafe().contains("Plans")) { + for (auto p : plan.GetMapSafe().at("Plans").GetArraySafe()) { + BuildPlanIndex(p, planIndex, precomputes); + } + } +} + +TVector RemoveRedundantNodes(NJson::TJsonValue& plan, const THashSet& redundantNodes) { + auto& planMap = plan.GetMapSafe(); + + TVector children; + if (planMap.contains("Plans") && planMap.at("Plans").IsArray()) { + for (auto& child : planMap.at("Plans").GetArraySafe()) { + auto newChildren = RemoveRedundantNodes(child, redundantNodes); + children.insert(children.end(), newChildren.begin(), newChildren.end()); + } + } + + planMap.erase("Plans"); + if (!children.empty()) { + auto& plans = planMap["Plans"]; + for (auto& child : children) { + plans.AppendValue(child); + } + } + + const auto typeName = planMap.at("Node Type").GetStringSafe(); + if (redundantNodes.contains(typeName) || typeName.find("Precompute") != TString::npos) { + return children; + } + + return {plan}; +} + +NJson::TJsonValue ReconstructQueryPlanRec(const NJson::TJsonValue& plan, + int operatorIndex, + const THashMap& planIndex, + const THashMap& precomputes, + int& nodeCounter) { + + int currentNodeId = nodeCounter++; + + NJson::TJsonValue result; + result["PlanNodeId"] = currentNodeId; + if (plan.GetMapSafe().contains("PlanNodeType")) { + result["PlanNodeType"] = plan.GetMapSafe().at("PlanNodeType").GetStringSafe(); + } + + if (plan.GetMapSafe().contains("Stats")) { + result["Stats"] = plan.GetMapSafe().at("Stats"); + } + + if (!plan.GetMapSafe().contains("Operators")) { + NJson::TJsonValue planInputs; + + result["Node Type"] = plan.GetMapSafe().at("Node Type").GetStringSafe(); + + if (!plan.GetMapSafe().contains("Plans")) { + return result; + } + + if (plan.GetMapSafe().at("Node Type") == "TableLookup") { + NJson::TJsonValue newOps; + NJson::TJsonValue op; + + op["Name"] = "TableLookup"; + op["Columns"] = plan.GetMapSafe().at("Columns"); + op["LookupKeyColumns"] = plan.GetMapSafe().at("LookupKeyColumns"); + op["Table"] = plan.GetMapSafe().at("Table"); + + newOps.AppendValue(op); + + result["Operators"] = newOps; + return result; + } + + for (auto p : plan.GetMapSafe().at("Plans").GetArraySafe()) { + if (p.GetMapSafe().at("Node Type").GetStringSafe().find("Precompute") == TString::npos) { + planInputs.AppendValue(ReconstructQueryPlanRec(p, 0, planIndex, precomputes, nodeCounter)); + } + } + result["Plans"] = planInputs; + return result; + } + + if (plan.GetMapSafe().contains("CTE Name") && plan.GetMapSafe().at("Node Type") == "ConstantExpr") { + auto precompute = plan.GetMapSafe().at("CTE Name").GetStringSafe(); + if (!precomputes.contains(precompute)) { + result["Node Type"] = "ConstantExpr"; + return result; + } + return ReconstructQueryPlanRec(precomputes.at(precompute), 0, planIndex, precomputes, nodeCounter); + } + + auto ops = plan.GetMapSafe().at("Operators").GetArraySafe(); + auto op = ops[operatorIndex]; + + TVector planInputs; + + auto opName = op.GetMapSafe().at("Name").GetStringSafe(); + + for (auto opInput : op.GetMapSafe().at("Inputs").GetArraySafe()) { + if (opInput.GetMapSafe().contains("ExternalPlanNodeId")) { + auto inputPlanKey = opInput.GetMapSafe().at("ExternalPlanNodeId").GetIntegerSafe(); + auto inputPlan = planIndex.at(inputPlanKey); + planInputs.push_back( ReconstructQueryPlanRec(inputPlan, 0, planIndex, precomputes, nodeCounter)); + } else if (opInput.GetMapSafe().contains("InternalOperatorId")) { + auto inputPlanId = opInput.GetMapSafe().at("InternalOperatorId").GetIntegerSafe(); + planInputs.push_back( ReconstructQueryPlanRec(plan, inputPlanId, planIndex, precomputes, nodeCounter)); + } + // temp hack + if (opName == "Filter") { + break; + } + } + + if (op.GetMapSafe().contains("Inputs")) { + op.GetMapSafe().erase("Inputs"); + } + + if (op.GetMapSafe().contains("Input") || op.GetMapSafe().contains("ToFlow")) { + TString maybePrecompute = ""; + if (op.GetMapSafe().contains("Input")) { + maybePrecompute = op.GetMapSafe().at("Input").GetStringSafe(); + } else if (op.GetMapSafe().contains("ToFlow")) { + maybePrecompute = op.GetMapSafe().at("ToFlow").GetStringSafe(); + } + + if (precomputes.contains(maybePrecompute)) { + planInputs.push_back(ReconstructQueryPlanRec(precomputes.at(maybePrecompute), 0, planIndex, precomputes, nodeCounter)); + } + } + + result["Node Type"] = opName; + NJson::TJsonValue newOps; + newOps.AppendValue(op); + result["Operators"] = newOps; + + if (planInputs.size()){ + NJson::TJsonValue plans; + for( auto i : planInputs) { + plans.AppendValue(i); + } + result["Plans"] = plans; + } + + return result; +} + +NJson::TJsonValue SimplifyQueryPlan(NJson::TJsonValue& plan) { + static const THashSet redundantNodes = { + "UnionAll", + "Broadcast", + "Map", + "HashShuffle", + "Merge", + "Collect", + "Stage", + "Iterator", + "PartitionByKey", + "ToFlow" + }; + + THashMap planIndex; + THashMap precomputes; + + + BuildPlanIndex(plan, planIndex, precomputes); + + int nodeCounter = 0; + plan = ReconstructQueryPlanRec(plan, 0, planIndex, precomputes, nodeCounter); + RemoveRedundantNodes(plan, redundantNodes); + return plan; +} + +TString AddSimplifiedPlan(const TString& planText, bool analyzeMode) { + Y_UNUSED(analyzeMode); + NJson::TJsonValue planJson; + NJson::ReadJsonTree(planText, &planJson, true); + if (!planJson.GetMapSafe().contains("Plan")){ + return planText; + } + + NJson::TJsonValue planCopy; + NJson::ReadJsonTree(planText, &planCopy, true); + + planJson["SimplifiedPlan"] = SimplifyQueryPlan(planCopy.GetMapSafe().at("Plan")); + + // Don't print the OLAP plan yet, there are some non UTF-8 symbols there that need to be fixed + //TTempBufOutput stringStream; + //NYdb::NConsoleClient::TQueryPlanPrinter printer(NYdb::NConsoleClient::EOutputFormat::PrettyTable, analyzeMode, stringStream); + //printer.Print(planJson.GetStringRobust()); + //planJson["OLAPText"] = stringStream.Data(); + return planJson.GetStringRobust(); +} + TString SerializeTxPlans(const TVector& txPlans, const TString commonPlanInfo = "") { NJsonWriter::TBuf writer; writer.SetIndentSpaces(2); @@ -1862,7 +2075,8 @@ TString SerializeTxPlans(const TVector& txPlans, const TString co writer.EndObject(); writer.EndObject(); - return writer.Str(); + auto resultPlan = writer.Str(); + return AddSimplifiedPlan(resultPlan, false); } } // namespace @@ -2250,7 +2464,8 @@ TString AddExecStatsToTxPlan(const TString& txPlanJson, const NYql::NDqProto::TD NJsonWriter::TBuf txWriter; txWriter.WriteJsonValue(&root, true); - return txWriter.Str(); + auto resultPlan = txWriter.Str(); + return AddSimplifiedPlan(resultPlan, true); } TString SerializeAnalyzePlan(const NKqpProto::TKqpStatsQuery& queryStats) { @@ -2294,6 +2509,9 @@ TString SerializeScriptPlan(const TVector& queryPlans) { if (auto dqPlan = planMap.FindPtr("Plan")) { writer.WriteKey("Plan"); writer.WriteJsonValue(dqPlan); + writer.WriteKey("SimplifiedPlan"); + auto simplifiedPlan = SimplifyQueryPlan(*dqPlan); + writer.WriteJsonValue(&simplifiedPlan); } writer.EndObject(); } diff --git a/ydb/core/kqp/ut/common/kqp_ut_common.cpp b/ydb/core/kqp/ut/common/kqp_ut_common.cpp index adea3a31a098..55c5c082aef2 100644 --- a/ydb/core/kqp/ut/common/kqp_ut_common.cpp +++ b/ydb/core/kqp/ut/common/kqp_ut_common.cpp @@ -1169,7 +1169,7 @@ std::vector FindPlanNodes(const NJson::TJsonValue& plan, cons std::vector FindPlanStages(const NJson::TJsonValue& plan) { std::vector stages; - FindPlanStagesImpl(plan, stages); + FindPlanStagesImpl(plan.GetMapSafe().at("Plan"), stages); return stages; } diff --git a/ydb/public/lib/ydb_cli/common/format.cpp b/ydb/public/lib/ydb_cli/common/format.cpp index 63121dab5a27..490a2312d655 100644 --- a/ydb/public/lib/ydb_cli/common/format.cpp +++ b/ydb/public/lib/ydb_cli/common/format.cpp @@ -371,10 +371,8 @@ void TQueryPlanPrinter::PrintPrettyImpl(const NJson::TJsonValue& plan, TVector explainColumnNames = {"Operation", "E-Cost", "E-Rows"}; static const TVector explainAnalyzeColumnNames = {"Operation", "DurationUs", "Rows", "E-Cost", "E-Rows"}; - if (plan.GetMapSafe().contains("Plan")) { - auto queryPlan = plan.GetMapSafe().at("Plan"); - SimplifyQueryPlan(queryPlan); + if (plan.GetMapSafe().contains("SimplifiedPlan")) { + auto queryPlan = plan.GetMapSafe().at("SimplifiedPlan"); TPrettyTable table(AnalyzeMode ? explainAnalyzeColumnNames : explainColumnNames, TPrettyTableConfig().WithoutRowDelimiters()); @@ -506,199 +503,10 @@ void TQueryPlanPrinter::PrintPrettyTableImpl(const NJson::TJsonValue& plan, TStr } } -TVector TQueryPlanPrinter::RemoveRedundantNodes(NJson::TJsonValue& plan, const THashSet& redundantNodes) { - auto& planMap = plan.GetMapSafe(); - - TVector children; - if (planMap.contains("Plans") && planMap.at("Plans").IsArray()) { - for (auto& child : planMap.at("Plans").GetArraySafe()) { - auto newChildren = RemoveRedundantNodes(child, redundantNodes); - children.insert(children.end(), newChildren.begin(), newChildren.end()); - } - } - - planMap.erase("Plans"); - if (!children.empty()) { - auto& plans = planMap["Plans"]; - for (auto& child : children) { - plans.AppendValue(child); - } - } - - const auto typeName = planMap.at("Node Type").GetStringSafe(); - if (redundantNodes.contains(typeName) || typeName.find("Precompute") != TString::npos) { - return children; - } - - return {plan}; -} - -void BuildPlanIndex(NJson::TJsonValue& plan, THashMap& planIndex, THashMap& precomputes) { - if (plan.GetMapSafe().contains("PlanNodeId")){ - auto id = plan.GetMapSafe().at("PlanNodeId").GetIntegerSafe(); - planIndex[id] = plan; - } - - if (plan.GetMapSafe().contains("Subplan Name")) { - const auto& precomputeName = plan.GetMapSafe().at("Subplan Name").GetStringSafe(); - - auto pos = precomputeName.find("precompute"); - if (pos != TString::npos) { - precomputes[precomputeName.substr(pos)] = plan; - } - } - - if (plan.GetMapSafe().contains("Plans")) { - for (auto p : plan.GetMapSafe().at("Plans").GetArraySafe()) { - BuildPlanIndex(p, planIndex, precomputes); - } - } -} - -void TQueryPlanPrinter::SimplifyQueryPlan(NJson::TJsonValue& plan) { - static const THashSet redundantNodes = { - "UnionAll", - "Broadcast", - "Map", - "HashShuffle", - "Merge", - "Collect", - "Stage", - "Iterator", - "PartitionByKey", - "ToFlow" - }; - - //auto precomputes = ExtractPrecomputes(plan); - //ResolvePrecomputeLinks(plan, precomputes); - THashMap planIndex; - THashMap precomputes; - - - BuildPlanIndex(plan, planIndex, precomputes); - - int nodeCounter = 0; - plan = ReconstructQueryPlanRec(plan, 0, planIndex, precomputes, nodeCounter); - RemoveRedundantNodes(plan, redundantNodes); - -} - -NJson::TJsonValue TQueryPlanPrinter::ReconstructQueryPlanRec(const NJson::TJsonValue& plan, - int operatorIndex, - const THashMap& planIndex, - const THashMap& precomputes, - int& nodeCounter) { - - int currentNodeId = nodeCounter++; - - NJson::TJsonValue result; - result["PlanNodeId"] = currentNodeId; - if (plan.GetMapSafe().contains("PlanNodeType")) { - result["PlanNodeType"] = plan.GetMapSafe().at("PlanNodeType").GetStringSafe(); - } - - if (plan.GetMapSafe().contains("Stats")) { - result["Stats"] = plan.GetMapSafe().at("Stats"); - } - - if (!plan.GetMapSafe().contains("Operators")) { - NJson::TJsonValue planInputs; - - result["Node Type"] = plan.GetMapSafe().at("Node Type").GetStringSafe(); - - if (!plan.GetMapSafe().contains("Plans")) { - return result; - } - - if (plan.GetMapSafe().at("Node Type") == "TableLookup") { - NJson::TJsonValue newOps; - NJson::TJsonValue op; - - op["Name"] = "TableLookup"; - op["Columns"] = plan.GetMapSafe().at("Columns"); - op["LookupKeyColumns"] = plan.GetMapSafe().at("LookupKeyColumns"); - op["Table"] = plan.GetMapSafe().at("Table"); - - newOps.AppendValue(op); - - result["Operators"] = newOps; - return result; - } - - for (auto p : plan.GetMapSafe().at("Plans").GetArraySafe()) { - if (p.GetMapSafe().at("Node Type").GetStringSafe().find("Precompute") == TString::npos) { - planInputs.AppendValue(ReconstructQueryPlanRec(p, 0, planIndex, precomputes, nodeCounter)); - } - } - result["Plans"] = planInputs; - return result; - } - - if (plan.GetMapSafe().contains("CTE Name") && plan.GetMapSafe().at("Node Type") == "ConstantExpr") { - auto precompute = plan.GetMapSafe().at("CTE Name").GetStringSafe(); - return ReconstructQueryPlanRec(precomputes.at(precompute), 0, planIndex, precomputes, nodeCounter); - } - - auto ops = plan.GetMapSafe().at("Operators").GetArraySafe(); - auto op = ops[operatorIndex]; - - TVector planInputs; - - auto opName = op.GetMapSafe().at("Name").GetStringSafe(); - - for (auto opInput : op.GetMapSafe().at("Inputs").GetArraySafe()) { - if (opInput.GetMapSafe().contains("ExternalPlanNodeId")) { - auto inputPlanKey = opInput.GetMapSafe().at("ExternalPlanNodeId").GetIntegerSafe(); - auto inputPlan = planIndex.at(inputPlanKey); - planInputs.push_back( ReconstructQueryPlanRec(inputPlan, 0, planIndex, precomputes, nodeCounter)); - } else if (opInput.GetMapSafe().contains("InternalOperatorId")) { - auto inputPlanId = opInput.GetMapSafe().at("InternalOperatorId").GetIntegerSafe(); - planInputs.push_back( ReconstructQueryPlanRec(plan, inputPlanId, planIndex, precomputes, nodeCounter)); - } - // temp hack - if (opName == "Filter") { - break; - } - } - - if (op.GetMapSafe().contains("Inputs")) { - op.GetMapSafe().erase("Inputs"); - } - - if (op.GetMapSafe().contains("Input") || op.GetMapSafe().contains("ToFlow")) { - TString maybePrecompute = ""; - if (op.GetMapSafe().contains("Input")) { - maybePrecompute = op.GetMapSafe().at("Input").GetStringSafe(); - } else if (op.GetMapSafe().contains("ToFlow")) { - maybePrecompute = op.GetMapSafe().at("ToFlow").GetStringSafe(); - } - - if (precomputes.contains(maybePrecompute)) { - planInputs.push_back(ReconstructQueryPlanRec(precomputes.at(maybePrecompute), 0, planIndex, precomputes, nodeCounter)); - } - } - - result["Node Type"] = opName; - NJson::TJsonValue newOps; - newOps.AppendValue(op); - result["Operators"] = newOps; - - if (planInputs.size()){ - NJson::TJsonValue plans; - for( auto i : planInputs) { - plans.AppendValue(i); - } - result["Plans"] = plans; - } - - return result; -} - TString TQueryPlanPrinter::JsonToString(const NJson::TJsonValue& jsonValue) { return jsonValue.GetStringRobust(); } - TResultSetPrinter::TResultSetPrinter(EOutputFormat format, std::function isInterrupted) : Format(format) , IsInterrupted(isInterrupted) diff --git a/ydb/public/lib/ydb_cli/common/format.h b/ydb/public/lib/ydb_cli/common/format.h index 097a61f0c1a8..e7876b060f70 100644 --- a/ydb/public/lib/ydb_cli/common/format.h +++ b/ydb/public/lib/ydb_cli/common/format.h @@ -108,15 +108,6 @@ class TQueryPlanPrinter { void PrintSimplifyJson(const NJson::TJsonValue& plan); TString JsonToString(const NJson::TJsonValue& jsonValue); - void SplitPlanInTree(NJson::TJsonValue& plan); - void SimplifyQueryPlan(NJson::TJsonValue& plan); - NJson::TJsonValue ReconstructQueryPlanRec(const NJson::TJsonValue& plan, int operatorIndex, const THashMap& planIndex, const THashMap& precomputes, int& nodeCounter); - TVector RemoveRedundantNodes(NJson::TJsonValue& plan, const THashSet& redundantNodes); - THashMap ExtractPrecomputes(NJson::TJsonValue& planJson); - void ResolvePrecomputeLinks(NJson::TJsonValue& planJson, const THashMap& precomputes); - void DeleteSplitNodes(NJson::TJsonValue& planJson); - - private: EOutputFormat Format; bool AnalyzeMode; diff --git a/ydb/tests/functional/canonical/canondata/test_sql.TestCanonicalFolder1.test_case_explain.script-script_/explain.script.plan b/ydb/tests/functional/canonical/canondata/test_sql.TestCanonicalFolder1.test_case_explain.script-script_/explain.script.plan index c5dda80ae1a3..282bd9629333 100644 --- a/ydb/tests/functional/canonical/canondata/test_sql.TestCanonicalFolder1.test_case_explain.script-script_/explain.script.plan +++ b/ydb/tests/functional/canonical/canondata/test_sql.TestCanonicalFolder1.test_case_explain.script-script_/explain.script.plan @@ -1,26 +1,29 @@ { "meta": { - "version": "0.2", - "type": "script" + "type": "script", + "version": "0.2" }, "queries": [ { - "tables": [], "Plan": { - "Plans": [], "Node Type": "Query", - "PlanNodeType": "Query" - } + "PlanNodeType": "Query", + "Plans": [] + }, + "tables": [] }, { - "tables": [], "Plan": { + "Node Type": "Query", + "PlanNodeType": "Query", "Plans": [ { + "Node Type": "ResultSet", "PlanNodeId": 2, + "PlanNodeType": "ResultSet", "Plans": [ { - "PlanNodeId": 1, + "Node Type": "ConstantExpr", "Operators": [ { "Inputs": [], @@ -28,47 +31,54 @@ "Name": "Iterator" } ], - "Node Type": "ConstantExpr" + "PlanNodeId": 1 } - ], - "Node Type": "ResultSet", - "PlanNodeType": "ResultSet" + ] } - ], - "Node Type": "Query", - "PlanNodeType": "Query" - } + ] + }, + "tables": [] }, { - "tables": [ - { - "name": "/local/base_explain_script_script/ScriptingTest", - "reads": [ - { - "scan_by": [ - "Key (-\u221e, +\u221e)" - ], - "type": "FullScan" - } - ] - } - ], "Plan": { + "Node Type": "Query", + "PlanNodeType": "Query", "Plans": [ { + "Node Type": "ResultSet", "PlanNodeId": 4, + "PlanNodeType": "ResultSet", "Plans": [ { + "Node Type": "Aggregate-Limit", + "Operators": [ + { + "Inputs": [ + { + "InternalOperatorId": 1 + } + ], + "Name": "Aggregate" + }, + { + "Inputs": [ + { + "ExternalPlanNodeId": 2 + } + ], + "Limit": "1", + "Name": "Limit" + } + ], "PlanNodeId": 3, "Plans": [ { + "Node Type": "UnionAll", "PlanNodeId": 2, + "PlanNodeType": "Connection", "Plans": [ { - "Tables": [ - "base_explain_script_script/ScriptingTest" - ], - "PlanNodeId": 1, + "Node Type": "Aggregate-TableFullScan", "Operators": [ { "Inputs": [ @@ -80,52 +90,27 @@ }, { "Inputs": [], + "Name": "TableFullScan", + "ReadColumns": null, "ReadRanges": [ "Key (-\u221e, +\u221e)" ], - "ReadColumns": null, - "Name": "TableFullScan", "Table": "base_explain_script_script/ScriptingTest" } ], - "Node Type": "Aggregate-TableFullScan" - } - ], - "Node Type": "UnionAll", - "PlanNodeType": "Connection" - } - ], - "Operators": [ - { - "Inputs": [ - { - "InternalOperatorId": 1 - } - ], - "Name": "Aggregate" - }, - { - "Inputs": [ - { - "ExternalPlanNodeId": 2 + "PlanNodeId": 1, + "Tables": [ + "base_explain_script_script/ScriptingTest" + ] } - ], - "Name": "Limit", - "Limit": "1" + ] } - ], - "Node Type": "Aggregate-Limit" + ] } - ], - "Node Type": "ResultSet", - "PlanNodeType": "ResultSet" + ] } - ], - "Node Type": "Query", - "PlanNodeType": "Query" - } - }, - { + ] + }, "tables": [ { "name": "/local/base_explain_script_script/ScriptingTest", @@ -138,14 +123,21 @@ } ] } - ], + ] + }, + { "Plan": { + "Node Type": "Query", + "PlanNodeType": "Query", "Plans": [ { + "Node Type": "ResultSet_1", "PlanNodeId": 7, + "PlanNodeType": "ResultSet", "Plans": [ { - "PlanNodeId": 6, + "CTE Name": "precompute_0_0", + "Node Type": "ConstantExpr", "Operators": [ { "Inputs": [], @@ -153,28 +145,46 @@ "Name": "Iterator" } ], - "Node Type": "ConstantExpr", - "CTE Name": "precompute_0_0" + "PlanNodeId": 6 } - ], - "Node Type": "ResultSet_1", - "PlanNodeType": "ResultSet" + ] }, { + "Node Type": "Precompute_0", + "Parent Relationship": "InitPlan", "PlanNodeId": 4, - "Subplan Name": "CTE precompute_0_0", + "PlanNodeType": "Materialize", "Plans": [ { + "Node Type": "Aggregate-Limit", + "Operators": [ + { + "Inputs": [ + { + "InternalOperatorId": 1 + } + ], + "Name": "Aggregate" + }, + { + "Inputs": [ + { + "ExternalPlanNodeId": 2 + } + ], + "Limit": "1", + "Name": "Limit" + } + ], "PlanNodeId": 3, "Plans": [ { + "Node Type": "UnionAll", "PlanNodeId": 2, + "PlanNodeType": "Connection", "Plans": [ { - "Tables": [ - "base_explain_script_script/ScriptingTest" - ], - "PlanNodeId": 1, + "Node Type": "Aggregate-TableFullScan", "Operators": [ { "Inputs": [ @@ -186,53 +196,28 @@ }, { "Inputs": [], + "Name": "TableFullScan", + "ReadColumns": null, "ReadRanges": [ "Key (-\u221e, +\u221e)" ], - "ReadColumns": null, - "Name": "TableFullScan", "Table": "base_explain_script_script/ScriptingTest" } ], - "Node Type": "Aggregate-TableFullScan" - } - ], - "Node Type": "UnionAll", - "PlanNodeType": "Connection" - } - ], - "Operators": [ - { - "Inputs": [ - { - "InternalOperatorId": 1 - } - ], - "Name": "Aggregate" - }, - { - "Inputs": [ - { - "ExternalPlanNodeId": 2 + "PlanNodeId": 1, + "Tables": [ + "base_explain_script_script/ScriptingTest" + ] } - ], - "Name": "Limit", - "Limit": "1" + ] } - ], - "Node Type": "Aggregate-Limit" + ] } ], - "Node Type": "Precompute_0", - "Parent Relationship": "InitPlan", - "PlanNodeType": "Materialize" + "Subplan Name": "CTE precompute_0_0" } - ], - "Node Type": "Query", - "PlanNodeType": "Query" - } - }, - { + ] + }, "tables": [ { "name": "/local/base_explain_script_script/ScriptingTest", @@ -245,23 +230,48 @@ } ] } - ], + ] + }, + { "Plan": { + "Node Type": "Query", + "PlanNodeType": "Query", "Plans": [ { + "Node Type": "ResultSet", "PlanNodeId": 4, + "PlanNodeType": "ResultSet", "Plans": [ { + "Node Type": "Aggregate-Limit", + "Operators": [ + { + "Inputs": [ + { + "InternalOperatorId": 1 + } + ], + "Name": "Aggregate" + }, + { + "Inputs": [ + { + "ExternalPlanNodeId": 2 + } + ], + "Limit": "1", + "Name": "Limit" + } + ], "PlanNodeId": 3, "Plans": [ { + "Node Type": "UnionAll", "PlanNodeId": 2, + "PlanNodeType": "Connection", "Plans": [ { - "Tables": [ - "base_explain_script_script/ScriptingTest" - ], - "PlanNodeId": 1, + "Node Type": "Aggregate-TableFullScan", "Operators": [ { "Inputs": [ @@ -273,52 +283,27 @@ }, { "Inputs": [], + "Name": "TableFullScan", + "ReadColumns": null, "ReadRanges": [ "Key (-\u221e, +\u221e)" ], - "ReadColumns": null, - "Name": "TableFullScan", "Table": "base_explain_script_script/ScriptingTest" } ], - "Node Type": "Aggregate-TableFullScan" - } - ], - "Node Type": "UnionAll", - "PlanNodeType": "Connection" - } - ], - "Operators": [ - { - "Inputs": [ - { - "InternalOperatorId": 1 - } - ], - "Name": "Aggregate" - }, - { - "Inputs": [ - { - "ExternalPlanNodeId": 2 + "PlanNodeId": 1, + "Tables": [ + "base_explain_script_script/ScriptingTest" + ] } - ], - "Name": "Limit", - "Limit": "1" + ] } - ], - "Node Type": "Aggregate-Limit" + ] } - ], - "Node Type": "ResultSet", - "PlanNodeType": "ResultSet" + ] } - ], - "Node Type": "Query", - "PlanNodeType": "Query" - } - }, - { + ] + }, "tables": [ { "name": "/local/base_explain_script_script/ScriptingTest", @@ -331,14 +316,21 @@ } ] } - ], + ] + }, + { "Plan": { + "Node Type": "Query", + "PlanNodeType": "Query", "Plans": [ { + "Node Type": "ResultSet_1", "PlanNodeId": 7, + "PlanNodeType": "ResultSet", "Plans": [ { - "PlanNodeId": 6, + "CTE Name": "precompute_0_0", + "Node Type": "ConstantExpr", "Operators": [ { "Inputs": [], @@ -346,28 +338,46 @@ "Name": "Iterator" } ], - "Node Type": "ConstantExpr", - "CTE Name": "precompute_0_0" + "PlanNodeId": 6 } - ], - "Node Type": "ResultSet_1", - "PlanNodeType": "ResultSet" + ] }, { + "Node Type": "Precompute_0", + "Parent Relationship": "InitPlan", "PlanNodeId": 4, - "Subplan Name": "CTE precompute_0_0", + "PlanNodeType": "Materialize", "Plans": [ { + "Node Type": "Aggregate-Limit", + "Operators": [ + { + "Inputs": [ + { + "InternalOperatorId": 1 + } + ], + "Name": "Aggregate" + }, + { + "Inputs": [ + { + "ExternalPlanNodeId": 2 + } + ], + "Limit": "1", + "Name": "Limit" + } + ], "PlanNodeId": 3, "Plans": [ { + "Node Type": "UnionAll", "PlanNodeId": 2, + "PlanNodeType": "Connection", "Plans": [ { - "Tables": [ - "base_explain_script_script/ScriptingTest" - ], - "PlanNodeId": 1, + "Node Type": "Aggregate-TableFullScan", "Operators": [ { "Inputs": [ @@ -379,77 +389,54 @@ }, { "Inputs": [], + "Name": "TableFullScan", + "ReadColumns": null, "ReadRanges": [ "Key (-\u221e, +\u221e)" ], - "ReadColumns": null, - "Name": "TableFullScan", "Table": "base_explain_script_script/ScriptingTest" } ], - "Node Type": "Aggregate-TableFullScan" - } - ], - "Node Type": "UnionAll", - "PlanNodeType": "Connection" - } - ], - "Operators": [ - { - "Inputs": [ - { - "InternalOperatorId": 1 - } - ], - "Name": "Aggregate" - }, - { - "Inputs": [ - { - "ExternalPlanNodeId": 2 + "PlanNodeId": 1, + "Tables": [ + "base_explain_script_script/ScriptingTest" + ] } - ], - "Name": "Limit", - "Limit": "1" + ] } - ], - "Node Type": "Aggregate-Limit" + ] } ], - "Node Type": "Precompute_0", - "Parent Relationship": "InitPlan", - "PlanNodeType": "Materialize" + "Subplan Name": "CTE precompute_0_0" } - ], - "Node Type": "Query", - "PlanNodeType": "Query" - } - }, - { + ] + }, "tables": [ { "name": "/local/base_explain_script_script/ScriptingTest", - "writes": [ + "reads": [ { - "columns": [ - "Key", - "Value" + "scan_by": [ + "Key (-\u221e, +\u221e)" ], - "type": "MultiUpsert" + "type": "FullScan" } ] } - ], + ] + }, + { "Plan": { + "Node Type": "Query", + "PlanNodeType": "Query", "Plans": [ { + "Node Type": "Effect", "PlanNodeId": 2, "Plans": [ { - "Tables": [ - "base_explain_script_script/ScriptingTest" - ], - "PlanNodeId": 1, + "CTE Name": "precompute_0_0", + "Node Type": "Upsert-ConstantExpr", "Operators": [ { "Inputs": [ @@ -466,18 +453,15 @@ "Name": "Iterator" } ], - "Node Type": "Upsert-ConstantExpr", - "CTE Name": "precompute_0_0" + "PlanNodeId": 1, + "Tables": [ + "base_explain_script_script/ScriptingTest" + ] } - ], - "Node Type": "Effect" + ] } - ], - "Node Type": "Query", - "PlanNodeType": "Query" - } - }, - { + ] + }, "tables": [ { "name": "/local/base_explain_script_script/ScriptingTest", @@ -491,17 +475,20 @@ } ] } - ], + ] + }, + { "Plan": { + "Node Type": "Query", + "PlanNodeType": "Query", "Plans": [ { + "Node Type": "Effect", "PlanNodeId": 2, "Plans": [ { - "Tables": [ - "base_explain_script_script/ScriptingTest" - ], - "PlanNodeId": 1, + "CTE Name": "precompute_0_0", + "Node Type": "Upsert-ConstantExpr", "Operators": [ { "Inputs": [ @@ -518,16 +505,29 @@ "Name": "Iterator" } ], - "Node Type": "Upsert-ConstantExpr", - "CTE Name": "precompute_0_0" + "PlanNodeId": 1, + "Tables": [ + "base_explain_script_script/ScriptingTest" + ] } - ], - "Node Type": "Effect" + ] } - ], - "Node Type": "Query", - "PlanNodeType": "Query" - } + ] + }, + "tables": [ + { + "name": "/local/base_explain_script_script/ScriptingTest", + "writes": [ + { + "columns": [ + "Key", + "Value" + ], + "type": "MultiUpsert" + } + ] + } + ] } ] } \ No newline at end of file diff --git a/ydb/tests/functional/canonical/canondata/test_sql.TestCanonicalFolder1.test_case_join_group_by_lookup.script-script_/join_group_by_lookup.script.plan b/ydb/tests/functional/canonical/canondata/test_sql.TestCanonicalFolder1.test_case_join_group_by_lookup.script-script_/join_group_by_lookup.script.plan index df47ca5e632f..90e422814a85 100644 --- a/ydb/tests/functional/canonical/canondata/test_sql.TestCanonicalFolder1.test_case_join_group_by_lookup.script-script_/join_group_by_lookup.script.plan +++ b/ydb/tests/functional/canonical/canondata/test_sql.TestCanonicalFolder1.test_case_join_group_by_lookup.script-script_/join_group_by_lookup.script.plan @@ -1,58 +1,75 @@ { "meta": { - "version": "0.2", - "type": "script" + "type": "script", + "version": "0.2" }, "queries": [ { - "tables": [ - { - "name": "/local/base_join_group_by_lookup_script_script/Input1", - "reads": [ - { - "columns": [ - "Group" - ], - "scan_by": [ - "Group (-\u221e, +\u221e)", - "Name (-\u221e, +\u221e)" - ], - "type": "FullScan" - } - ] - }, - { - "name": "/local/base_join_group_by_lookup_script_script/Temp", - "reads": [ - { - "columns": [ - "Group", - "Value" - ], - "type": "Lookup" - } - ] - } - ], "Plan": { + "Node Type": "Query", + "PlanNodeType": "Query", "Plans": [ { + "Node Type": "ResultSet_2", "PlanNodeId": 20, + "PlanNodeType": "ResultSet", "Plans": [ { + "Node Type": "Limit", + "Operators": [ + { + "Inputs": [ + { + "ExternalPlanNodeId": 18 + } + ], + "Limit": "1001", + "Name": "Limit" + } + ], "PlanNodeId": 19, "Plans": [ { + "Node Type": "Merge", "PlanNodeId": 18, + "PlanNodeType": "Connection", "Plans": [ { + "Node Type": "TopSort-LeftJoin (MapJoin)", + "Operators": [ + { + "Inputs": [ + { + "InternalOperatorId": 1 + } + ], + "Limit": "1001", + "Name": "TopSort", + "TopSortBy": "" + }, + { + "Condition": "Group = Group", + "Inputs": [ + { + "ExternalPlanNodeId": 16 + }, + { + "ExternalPlanNodeId": 14 + } + ], + "Name": "LeftJoin (MapJoin)" + } + ], "PlanNodeId": 17, "Plans": [ { + "Node Type": "Map", "PlanNodeId": 16, + "PlanNodeType": "Connection", "Plans": [ { - "PlanNodeId": 15, + "CTE Name": "precompute_0_0", + "Node Type": "ConstantExpr", "Operators": [ { "Inputs": [], @@ -60,27 +77,27 @@ "Name": "Iterator" } ], - "Node Type": "ConstantExpr", - "CTE Name": "precompute_0_0" + "PlanNodeId": 15 } - ], - "Node Type": "Map", - "PlanNodeType": "Connection" + ] }, { + "Node Type": "Broadcast", "PlanNodeId": 14, + "PlanNodeType": "Connection", "Plans": [ { + "Node Type": "Collect", "PlanNodeId": 13, "Plans": [ { + "Node Type": "UnionAll", "PlanNodeId": 12, + "PlanNodeType": "Connection", "Plans": [ { - "Tables": [ - "base_join_group_by_lookup_script_script/Temp" - ], - "PlanNodeId": 11, + "CTE Name": "precompute_1_0", + "Node Type": "Filter-TablePointLookup-ConstantExpr", "Operators": [ { "Inputs": [ @@ -88,8 +105,8 @@ "InternalOperatorId": 1 } ], - "Predicate": "Exist(item.Group)", - "Name": "Filter" + "Name": "Filter", + "Predicate": "Exist(item.Group)" }, { "Inputs": [ @@ -97,11 +114,11 @@ "InternalOperatorId": 2 } ], + "Name": "TablePointLookup", "ReadColumns": [ "Group", "Value" ], - "Name": "TablePointLookup", "Table": "base_join_group_by_lookup_script_script/Temp" }, { @@ -110,194 +127,164 @@ "Name": "Iterator" } ], - "Node Type": "Filter-TablePointLookup-ConstantExpr", - "CTE Name": "precompute_1_0" + "PlanNodeId": 11, + "Tables": [ + "base_join_group_by_lookup_script_script/Temp" + ] } - ], - "Node Type": "UnionAll", - "PlanNodeType": "Connection" + ] } - ], - "Node Type": "Collect" - } - ], - "Node Type": "Broadcast", - "PlanNodeType": "Connection" - } - ], - "Operators": [ - { - "Inputs": [ - { - "InternalOperatorId": 1 + ] } - ], - "Name": "TopSort", - "Limit": "1001", - "TopSortBy": "" - }, - { - "Inputs": [ - { - "ExternalPlanNodeId": 16 - }, - { - "ExternalPlanNodeId": 14 - } - ], - "Condition": "Group = Group", - "Name": "LeftJoin (MapJoin)" + ] } - ], - "Node Type": "TopSort-LeftJoin (MapJoin)" + ] } ], - "Node Type": "Merge", "SortColumns": [ "a.Group (Asc)", "a.Count0 (Asc)", "t.Value (Asc)" - ], - "PlanNodeType": "Connection" - } - ], - "Operators": [ - { - "Inputs": [ - { - "ExternalPlanNodeId": 18 - } - ], - "Name": "Limit", - "Limit": "1001" + ] } - ], - "Node Type": "Limit" + ] } - ], - "Node Type": "ResultSet_2", - "PlanNodeType": "ResultSet" + ] }, { + "Node Type": "Precompute_1", + "Parent Relationship": "InitPlan", "PlanNodeId": 9, - "Subplan Name": "CTE precompute_1_0", + "PlanNodeType": "Materialize", "Plans": [ { - "PlanNodeId": 8, + "CTE Name": "precompute_0_0", + "Node Type": "Aggregate", "Operators": [ { + "Input": "precompute_0_0", "Inputs": [], - "Name": "PartitionByKey", - "Input": "precompute_0_0" + "Name": "PartitionByKey" } ], - "Node Type": "Aggregate", - "CTE Name": "precompute_0_0" + "PlanNodeId": 8 } ], - "Node Type": "Precompute_1", - "Parent Relationship": "InitPlan", - "PlanNodeType": "Materialize" + "Subplan Name": "CTE precompute_1_0" }, { + "Node Type": "Precompute_0", + "Parent Relationship": "InitPlan", "PlanNodeId": 6, - "Subplan Name": "CTE precompute_0_0", + "PlanNodeType": "Materialize", "Plans": [ { + "Node Type": "Collect", "PlanNodeId": 5, "Plans": [ { + "Node Type": "UnionAll", "PlanNodeId": 4, + "PlanNodeType": "Connection", "Plans": [ { + "Node Type": "Stage", "PlanNodeId": 3, "Plans": [ { + "KeyColumns": [ + "Group" + ], + "Node Type": "HashShuffle", "PlanNodeId": 2, + "PlanNodeType": "Connection", "Plans": [ { - "Tables": [ - "base_join_group_by_lookup_script_script/Input1" - ], - "PlanNodeId": 1, + "Node Type": "Aggregate-TableFullScan", "Operators": [ { + "Aggregation": "{_yql_agg_0: SUM(state._yql_agg_0,1)}", + "GroupBy": "item.Group", "Inputs": [ { "InternalOperatorId": 1 } ], - "GroupBy": "item.Group", - "Aggregation": "{_yql_agg_0: SUM(state._yql_agg_0,1)}", "Name": "Aggregate" }, { "Inputs": [], + "Name": "TableFullScan", + "ReadColumns": [ + "Group" + ], "ReadRanges": [ "Group (-\u221e, +\u221e)", "Name (-\u221e, +\u221e)" ], - "ReadColumns": [ - "Group" - ], - "Name": "TableFullScan", "Table": "base_join_group_by_lookup_script_script/Input1" } ], - "Node Type": "Aggregate-TableFullScan" + "PlanNodeId": 1, + "Tables": [ + "base_join_group_by_lookup_script_script/Input1" + ] } - ], - "Node Type": "HashShuffle", - "KeyColumns": [ - "Group" - ], - "PlanNodeType": "Connection" + ] } - ], - "Node Type": "Stage" + ] } - ], - "Node Type": "UnionAll", - "PlanNodeType": "Connection" + ] } - ], - "Node Type": "Collect" + ] } ], - "Node Type": "Precompute_0", - "Parent Relationship": "InitPlan", - "PlanNodeType": "Materialize" + "Subplan Name": "CTE precompute_0_0" } - ], - "Node Type": "Query", - "PlanNodeType": "Query" - } - }, - { + ] + }, "tables": [ + { + "name": "/local/base_join_group_by_lookup_script_script/Input1", + "reads": [ + { + "columns": [ + "Group" + ], + "scan_by": [ + "Group (-\u221e, +\u221e)", + "Name (-\u221e, +\u221e)" + ], + "type": "FullScan" + } + ] + }, { "name": "/local/base_join_group_by_lookup_script_script/Temp", - "writes": [ + "reads": [ { "columns": [ "Group", "Value" ], - "type": "MultiUpsert" + "type": "Lookup" } ] } - ], + ] + }, + { "Plan": { + "Node Type": "Query", + "PlanNodeType": "Query", "Plans": [ { + "Node Type": "Effect", "PlanNodeId": 2, "Plans": [ { - "Tables": [ - "base_join_group_by_lookup_script_script/Temp" - ], - "PlanNodeId": 1, + "CTE Name": "precompute_0_0", + "Node Type": "Upsert-ConstantExpr", "Operators": [ { "Inputs": [ @@ -314,16 +301,29 @@ "Name": "Iterator" } ], - "Node Type": "Upsert-ConstantExpr", - "CTE Name": "precompute_0_0" + "PlanNodeId": 1, + "Tables": [ + "base_join_group_by_lookup_script_script/Temp" + ] } - ], - "Node Type": "Effect" + ] } - ], - "Node Type": "Query", - "PlanNodeType": "Query" - } + ] + }, + "tables": [ + { + "name": "/local/base_join_group_by_lookup_script_script/Temp", + "writes": [ + { + "columns": [ + "Group", + "Value" + ], + "type": "MultiUpsert" + } + ] + } + ] } ] } \ No newline at end of file diff --git a/ydb/tests/functional/canonical/canondata/test_sql.TestCanonicalFolder1.test_case_simple_ct.script-script_/simple_ct.script.plan b/ydb/tests/functional/canonical/canondata/test_sql.TestCanonicalFolder1.test_case_simple_ct.script-script_/simple_ct.script.plan index b09ff151b380..28432a5e0cbf 100644 --- a/ydb/tests/functional/canonical/canondata/test_sql.TestCanonicalFolder1.test_case_simple_ct.script-script_/simple_ct.script.plan +++ b/ydb/tests/functional/canonical/canondata/test_sql.TestCanonicalFolder1.test_case_simple_ct.script-script_/simple_ct.script.plan @@ -1,34 +1,21 @@ { "meta": { - "version": "0.2", - "type": "script" + "type": "script", + "version": "0.2" }, "queries": [ { - "tables": [ - { - "name": "/local/base_simple_ct_script_script/Questions", - "writes": [ - { - "columns": [ - "idx", - "text" - ], - "type": "MultiUpsert" - } - ] - } - ], "Plan": { + "Node Type": "Query", + "PlanNodeType": "Query", "Plans": [ { + "Node Type": "Effect", "PlanNodeId": 2, "Plans": [ { - "Tables": [ - "base_simple_ct_script_script/Questions" - ], - "PlanNodeId": 1, + "CTE Name": "precompute_0_0", + "Node Type": "Upsert-ConstantExpr", "Operators": [ { "Inputs": [ @@ -45,16 +32,29 @@ "Name": "Iterator" } ], - "Node Type": "Upsert-ConstantExpr", - "CTE Name": "precompute_0_0" + "PlanNodeId": 1, + "Tables": [ + "base_simple_ct_script_script/Questions" + ] } - ], - "Node Type": "Effect" + ] } - ], - "Node Type": "Query", - "PlanNodeType": "Query" - } + ] + }, + "tables": [ + { + "name": "/local/base_simple_ct_script_script/Questions", + "writes": [ + { + "columns": [ + "idx", + "text" + ], + "type": "MultiUpsert" + } + ] + } + ] } ] } \ No newline at end of file diff --git a/ydb/tests/functional/canonical/canondata/test_sql.TestCanonicalFolder1.test_case_simple_script_params.script-script_/simple_script_params.script.plan b/ydb/tests/functional/canonical/canondata/test_sql.TestCanonicalFolder1.test_case_simple_script_params.script-script_/simple_script_params.script.plan index 7dabfadc22a3..8307cd4befe3 100644 --- a/ydb/tests/functional/canonical/canondata/test_sql.TestCanonicalFolder1.test_case_simple_script_params.script-script_/simple_script_params.script.plan +++ b/ydb/tests/functional/canonical/canondata/test_sql.TestCanonicalFolder1.test_case_simple_script_params.script-script_/simple_script_params.script.plan @@ -1,18 +1,21 @@ { "meta": { - "version": "0.2", - "type": "script" + "type": "script", + "version": "0.2" }, "queries": [ { - "tables": [], "Plan": { + "Node Type": "Query", + "PlanNodeType": "Query", "Plans": [ { + "Node Type": "ResultSet", "PlanNodeId": 2, + "PlanNodeType": "ResultSet", "Plans": [ { - "PlanNodeId": 1, + "Node Type": "ConstantExpr", "Operators": [ { "Inputs": [], @@ -20,16 +23,13 @@ "Name": "Iterator" } ], - "Node Type": "ConstantExpr" + "PlanNodeId": 1 } - ], - "Node Type": "ResultSet", - "PlanNodeType": "ResultSet" + ] } - ], - "Node Type": "Query", - "PlanNodeType": "Query" - } + ] + }, + "tables": [] } ] } \ No newline at end of file diff --git a/ydb/tests/functional/canonical/canondata/test_sql.TestCanonicalFolder1.test_case_table_types.script-script_/table_types.script.plan b/ydb/tests/functional/canonical/canondata/test_sql.TestCanonicalFolder1.test_case_table_types.script-script_/table_types.script.plan index fe0c3aa5fd5a..1d35143beca3 100644 --- a/ydb/tests/functional/canonical/canondata/test_sql.TestCanonicalFolder1.test_case_table_types.script-script_/table_types.script.plan +++ b/ydb/tests/functional/canonical/canondata/test_sql.TestCanonicalFolder1.test_case_table_types.script-script_/table_types.script.plan @@ -1,60 +1,41 @@ { "meta": { - "version": "0.2", - "type": "script" + "type": "script", + "version": "0.2" }, "queries": [ { - "tables": [ - { - "name": "/local/base_table_types_script_script/TableTypes", - "reads": [ - { - "columns": [ - "Key", - "Value01", - "Value02", - "Value03", - "Value04", - "Value05", - "Value06", - "Value07", - "Value08", - "Value09", - "Value10", - "Value21", - "Value22", - "Value23", - "Value24", - "Value31", - "Value32", - "Value33", - "Value34" - ], - "scan_by": [ - "Key (-\u221e, +\u221e)" - ], - "type": "FullScan" - } - ] - } - ], "Plan": { + "Node Type": "Query", + "PlanNodeType": "Query", "Plans": [ { + "Node Type": "ResultSet", "PlanNodeId": 4, + "PlanNodeType": "ResultSet", "Plans": [ { + "Node Type": "Limit", + "Operators": [ + { + "Inputs": [ + { + "ExternalPlanNodeId": 2 + } + ], + "Limit": "1001", + "Name": "Limit" + } + ], "PlanNodeId": 3, "Plans": [ { + "Node Type": "UnionAll", "PlanNodeId": 2, + "PlanNodeType": "Connection", "Plans": [ { - "Tables": [ - "base_table_types_script_script/TableTypes" - ], - "PlanNodeId": 1, + "Node Type": "Limit-TableFullScan", "Operators": [ { "Inputs": [ @@ -62,14 +43,12 @@ "InternalOperatorId": 1 } ], - "Name": "Limit", - "Limit": "1001" + "Limit": "1001", + "Name": "Limit" }, { "Inputs": [], - "ReadRanges": [ - "Key (-\u221e, +\u221e)" - ], + "Name": "TableFullScan", "ReadColumns": [ "Key", "Value01", @@ -91,44 +70,29 @@ "Value33", "Value34" ], - "Name": "TableFullScan", + "ReadRanges": [ + "Key (-\u221e, +\u221e)" + ], "Table": "base_table_types_script_script/TableTypes" } ], - "Node Type": "Limit-TableFullScan" - } - ], - "Node Type": "UnionAll", - "PlanNodeType": "Connection" - } - ], - "Operators": [ - { - "Inputs": [ - { - "ExternalPlanNodeId": 2 + "PlanNodeId": 1, + "Tables": [ + "base_table_types_script_script/TableTypes" + ] } - ], - "Name": "Limit", - "Limit": "1001" + ] } - ], - "Node Type": "Limit" + ] } - ], - "Node Type": "ResultSet", - "PlanNodeType": "ResultSet" + ] } - ], - "Node Type": "Query", - "PlanNodeType": "Query" - } - }, - { + ] + }, "tables": [ { "name": "/local/base_table_types_script_script/TableTypes", - "writes": [ + "reads": [ { "columns": [ "Key", @@ -151,21 +115,27 @@ "Value33", "Value34" ], - "type": "MultiUpsert" + "scan_by": [ + "Key (-\u221e, +\u221e)" + ], + "type": "FullScan" } ] } - ], + ] + }, + { "Plan": { + "Node Type": "Query", + "PlanNodeType": "Query", "Plans": [ { + "Node Type": "Effect", "PlanNodeId": 2, "Plans": [ { - "Tables": [ - "base_table_types_script_script/TableTypes" - ], - "PlanNodeId": 1, + "CTE Name": "precompute_0_0", + "Node Type": "Upsert-ConstantExpr", "Operators": [ { "Inputs": [ @@ -182,16 +152,46 @@ "Name": "Iterator" } ], - "Node Type": "Upsert-ConstantExpr", - "CTE Name": "precompute_0_0" + "PlanNodeId": 1, + "Tables": [ + "base_table_types_script_script/TableTypes" + ] } - ], - "Node Type": "Effect" + ] } - ], - "Node Type": "Query", - "PlanNodeType": "Query" - } + ] + }, + "tables": [ + { + "name": "/local/base_table_types_script_script/TableTypes", + "writes": [ + { + "columns": [ + "Key", + "Value01", + "Value02", + "Value03", + "Value04", + "Value05", + "Value06", + "Value07", + "Value08", + "Value09", + "Value10", + "Value21", + "Value22", + "Value23", + "Value24", + "Value31", + "Value32", + "Value33", + "Value34" + ], + "type": "MultiUpsert" + } + ] + } + ] } ] } \ No newline at end of file diff --git a/ydb/tests/functional/canonical/canondata/test_sql.TestCanonicalFolder1.test_case_write_multi_usage.script-script_/write_multi_usage.script.plan b/ydb/tests/functional/canonical/canondata/test_sql.TestCanonicalFolder1.test_case_write_multi_usage.script-script_/write_multi_usage.script.plan index 0189bdb5bd67..f8369f04d7f5 100644 --- a/ydb/tests/functional/canonical/canondata/test_sql.TestCanonicalFolder1.test_case_write_multi_usage.script-script_/write_multi_usage.script.plan +++ b/ydb/tests/functional/canonical/canondata/test_sql.TestCanonicalFolder1.test_case_write_multi_usage.script-script_/write_multi_usage.script.plan @@ -1,63 +1,41 @@ { "meta": { - "version": "0.2", - "type": "script" + "type": "script", + "version": "0.2" }, "queries": [ { - "tables": [ - { - "name": "/local/base_write_multi_usage_script_script/Input1", - "reads": [ - { - "columns": [ - "Amount", - "Comment", - "Group", - "Name" - ], - "scan_by": [ - "Group (-\u221e, +\u221e)", - "Name (-\u221e, +\u221e)" - ], - "limit": "1001", - "type": "FullScan" - } - ] - }, - { - "name": "/local/base_write_multi_usage_script_script/Temp", - "reads": [ - { - "columns": [ - "Name", - "Value" - ], - "scan_by": [ - "Name (-\u221e, +\u221e)" - ], - "limit": "1001", - "type": "FullScan" - } - ] - } - ], "Plan": { + "Node Type": "Query", + "PlanNodeType": "Query", "Plans": [ { + "Node Type": "ResultSet_0", "PlanNodeId": 8, + "PlanNodeType": "ResultSet", "Plans": [ { + "Node Type": "Limit", + "Operators": [ + { + "Inputs": [ + { + "ExternalPlanNodeId": 6 + } + ], + "Limit": "1001", + "Name": "Limit" + } + ], "PlanNodeId": 7, "Plans": [ { + "Node Type": "Merge", "PlanNodeId": 6, + "PlanNodeType": "Connection", "Plans": [ { - "Tables": [ - "base_write_multi_usage_script_script/Temp" - ], - "PlanNodeId": 5, + "Node Type": "Limit-TableFullScan", "Operators": [ { "Inputs": [ @@ -65,64 +43,64 @@ "InternalOperatorId": 1 } ], - "Name": "Limit", - "Limit": "1001" + "Limit": "1001", + "Name": "Limit" }, { "Inputs": [], - "ReadLimit": "1001", - "ReadRanges": [ - "Name (-\u221e, +\u221e)" - ], + "Name": "TableFullScan", "ReadColumns": [ "Name", "Value" ], - "Name": "TableFullScan", + "ReadLimit": "1001", + "ReadRanges": [ + "Name (-\u221e, +\u221e)" + ], "Table": "base_write_multi_usage_script_script/Temp" } ], - "Node Type": "Limit-TableFullScan" + "PlanNodeId": 5, + "Tables": [ + "base_write_multi_usage_script_script/Temp" + ] } ], - "Node Type": "Merge", "SortColumns": [ "Name (Asc)" - ], - "PlanNodeType": "Connection" + ] } - ], + ] + } + ] + }, + { + "Node Type": "ResultSet_1", + "PlanNodeId": 4, + "PlanNodeType": "ResultSet", + "Plans": [ + { + "Node Type": "Limit", "Operators": [ { "Inputs": [ { - "ExternalPlanNodeId": 6 + "ExternalPlanNodeId": 2 } ], - "Name": "Limit", - "Limit": "1001" + "Limit": "1001", + "Name": "Limit" } ], - "Node Type": "Limit" - } - ], - "Node Type": "ResultSet_0", - "PlanNodeType": "ResultSet" - }, - { - "PlanNodeId": 4, - "Plans": [ - { "PlanNodeId": 3, "Plans": [ { + "Node Type": "Merge", "PlanNodeId": 2, + "PlanNodeType": "Connection", "Plans": [ { - "Tables": [ - "base_write_multi_usage_script_script/Input1" - ], - "PlanNodeId": 1, + "Node Type": "Limit-TableFullScan", "Operators": [ { "Inputs": [ @@ -130,106 +108,93 @@ "InternalOperatorId": 1 } ], - "Name": "Limit", - "Limit": "1001" + "Limit": "1001", + "Name": "Limit" }, { "Inputs": [], - "ReadLimit": "1001", - "ReadRanges": [ - "Group (-\u221e, +\u221e)", - "Name (-\u221e, +\u221e)" - ], + "Name": "TableFullScan", "ReadColumns": [ "Amount", "Comment", "Group", "Name" ], - "Name": "TableFullScan", + "ReadLimit": "1001", + "ReadRanges": [ + "Group (-\u221e, +\u221e)", + "Name (-\u221e, +\u221e)" + ], "Table": "base_write_multi_usage_script_script/Input1" } ], - "Node Type": "Limit-TableFullScan" + "PlanNodeId": 1, + "Tables": [ + "base_write_multi_usage_script_script/Input1" + ] } ], - "Node Type": "Merge", "SortColumns": [ "Group (Asc)", "Name (Asc)" - ], - "PlanNodeType": "Connection" - } - ], - "Operators": [ - { - "Inputs": [ - { - "ExternalPlanNodeId": 2 - } - ], - "Name": "Limit", - "Limit": "1001" + ] } - ], - "Node Type": "Limit" + ] } - ], - "Node Type": "ResultSet_1", - "PlanNodeType": "ResultSet" + ] } - ], - "Node Type": "Query", - "PlanNodeType": "Query" - } - }, - { + ] + }, "tables": [ { "name": "/local/base_write_multi_usage_script_script/Input1", "reads": [ { - "lookup_by": [ - "Group (2)" - ], "columns": [ - "Amount" + "Amount", + "Comment", + "Group", + "Name" ], + "limit": "1001", "scan_by": [ + "Group (-\u221e, +\u221e)", "Name (-\u221e, +\u221e)" ], - "type": "Scan" - } - ], - "writes": [ - { - "type": "MultiErase" + "type": "FullScan" } ] }, { "name": "/local/base_write_multi_usage_script_script/Temp", - "writes": [ + "reads": [ { "columns": [ "Name", "Value" ], - "type": "MultiUpsert" + "limit": "1001", + "scan_by": [ + "Name (-\u221e, +\u221e)" + ], + "type": "FullScan" } ] } - ], + ] + }, + { "Plan": { + "Node Type": "Query", + "PlanNodeType": "Query", "Plans": [ { + "Node Type": "Effect", "PlanNodeId": 11, "Plans": [ { - "Tables": [ - "base_write_multi_usage_script_script/Temp" - ], - "PlanNodeId": 10, + "CTE Name": "precompute_0_1", + "Node Type": "Upsert-ConstantExpr", "Operators": [ { "Inputs": [ @@ -246,20 +211,20 @@ "Name": "Iterator" } ], - "Node Type": "Upsert-ConstantExpr", - "CTE Name": "precompute_0_1" + "PlanNodeId": 10, + "Tables": [ + "base_write_multi_usage_script_script/Temp" + ] } - ], - "Node Type": "Effect" + ] }, { + "Node Type": "Effect", "PlanNodeId": 9, "Plans": [ { - "Tables": [ - "base_write_multi_usage_script_script/Input1" - ], - "PlanNodeId": 8, + "CTE Name": "precompute_0_0", + "Node Type": "Delete-ConstantExpr", "Operators": [ { "Inputs": [ @@ -276,72 +241,107 @@ "Name": "Iterator" } ], - "Node Type": "Delete-ConstantExpr", - "CTE Name": "precompute_0_0" + "PlanNodeId": 8, + "Tables": [ + "base_write_multi_usage_script_script/Input1" + ] } - ], - "Node Type": "Effect" + ] }, { + "Node Type": "Precompute_0_0", + "Parent Relationship": "InitPlan", "PlanNodeId": 6, - "Subplan Name": "CTE precompute_0_0", + "PlanNodeType": "Materialize", "Plans": [ { - "PlanNodeId": 5, - "Node Type": "Stage" + "Node Type": "Stage", + "PlanNodeId": 5 } ], - "Node Type": "Precompute_0_0", - "Parent Relationship": "InitPlan", - "PlanNodeType": "Materialize" + "Subplan Name": "CTE precompute_0_0" }, { + "Node Type": "Precompute_0_1", + "Parent Relationship": "InitPlan", "PlanNodeId": 4, - "Subplan Name": "CTE precompute_0_1", + "PlanNodeType": "Materialize", "Plans": [ { + "Node Type": "Collect", "PlanNodeId": 3, "Plans": [ { + "Node Type": "UnionAll", "PlanNodeId": 2, + "PlanNodeType": "Connection", "Plans": [ { - "Tables": [ - "base_write_multi_usage_script_script/Input1" - ], - "PlanNodeId": 1, + "Node Type": "TableRangeScan", "Operators": [ { "Inputs": [], + "Name": "TableRangeScan", + "ReadColumns": [ + "Amount" + ], "ReadRange": [ "Group (2)", "Name (-\u221e, +\u221e)" ], - "ReadColumns": [ - "Amount" - ], - "Name": "TableRangeScan", "Table": "base_write_multi_usage_script_script/Input1" } ], - "Node Type": "TableRangeScan" + "PlanNodeId": 1, + "Tables": [ + "base_write_multi_usage_script_script/Input1" + ] } - ], - "Node Type": "UnionAll", - "PlanNodeType": "Connection" + ] } - ], - "Node Type": "Collect" + ] } ], - "Node Type": "Precompute_0_1", - "Parent Relationship": "InitPlan", - "PlanNodeType": "Materialize" + "Subplan Name": "CTE precompute_0_1" } - ], - "Node Type": "Query", - "PlanNodeType": "Query" - } + ] + }, + "tables": [ + { + "name": "/local/base_write_multi_usage_script_script/Input1", + "reads": [ + { + "columns": [ + "Amount" + ], + "lookup_by": [ + "Group (2)" + ], + "scan_by": [ + "Name (-\u221e, +\u221e)" + ], + "type": "Scan" + } + ], + "writes": [ + { + "type": "MultiErase" + } + ] + }, + { + "name": "/local/base_write_multi_usage_script_script/Temp", + "writes": [ + { + "columns": [ + "Name", + "Value" + ], + "type": "MultiUpsert" + } + ] + } + ] } ] } \ No newline at end of file diff --git a/ydb/tests/functional/canonical/canondata/test_sql.TestCanonicalFolder1.test_case_write_multi_usage_key.script-script_/write_multi_usage_key.script.plan b/ydb/tests/functional/canonical/canondata/test_sql.TestCanonicalFolder1.test_case_write_multi_usage_key.script-script_/write_multi_usage_key.script.plan index eeac971a0bbe..883354e6dc83 100644 --- a/ydb/tests/functional/canonical/canondata/test_sql.TestCanonicalFolder1.test_case_write_multi_usage_key.script-script_/write_multi_usage_key.script.plan +++ b/ydb/tests/functional/canonical/canondata/test_sql.TestCanonicalFolder1.test_case_write_multi_usage_key.script-script_/write_multi_usage_key.script.plan @@ -1,43 +1,41 @@ { "meta": { - "version": "0.2", - "type": "script" + "type": "script", + "version": "0.2" }, "queries": [ { - "tables": [ - { - "name": "/local/base_write_multi_usage_key_script_script/Temp", - "reads": [ - { - "columns": [ - "Name", - "Value" - ], - "scan_by": [ - "Name (-\u221e, +\u221e)" - ], - "type": "FullScan" - } - ] - } - ], "Plan": { + "Node Type": "Query", + "PlanNodeType": "Query", "Plans": [ { + "Node Type": "ResultSet", "PlanNodeId": 4, + "PlanNodeType": "ResultSet", "Plans": [ { + "Node Type": "Limit", + "Operators": [ + { + "Inputs": [ + { + "ExternalPlanNodeId": 2 + } + ], + "Limit": "1001", + "Name": "Limit" + } + ], "PlanNodeId": 3, "Plans": [ { + "Node Type": "Merge", "PlanNodeId": 2, + "PlanNodeType": "Connection", "Plans": [ { - "Tables": [ - "base_write_multi_usage_key_script_script/Temp" - ], - "PlanNodeId": 1, + "Node Type": "Limit-TableFullScan", "Operators": [ { "Inputs": [ @@ -45,95 +43,68 @@ "InternalOperatorId": 1 } ], - "Name": "Limit", - "Limit": "1001" + "Limit": "1001", + "Name": "Limit" }, { "Inputs": [], - "ReadRanges": [ - "Name (-\u221e, +\u221e)" - ], + "Name": "TableFullScan", "ReadColumns": [ "Name", "Value" ], - "Name": "TableFullScan", + "ReadRanges": [ + "Name (-\u221e, +\u221e)" + ], "Table": "base_write_multi_usage_key_script_script/Temp" } ], - "Node Type": "Limit-TableFullScan" + "PlanNodeId": 1, + "Tables": [ + "base_write_multi_usage_key_script_script/Temp" + ] } ], - "Node Type": "Merge", "SortColumns": [ "Name (Asc)" - ], - "PlanNodeType": "Connection" + ] } - ], - "Operators": [ - { - "Inputs": [ - { - "ExternalPlanNodeId": 2 - } - ], - "Name": "Limit", - "Limit": "1001" - } - ], - "Node Type": "Limit" + ] } - ], - "Node Type": "ResultSet", - "PlanNodeType": "ResultSet" + ] } - ], - "Node Type": "Query", - "PlanNodeType": "Query" - } - }, - { + ] + }, "tables": [ { - "name": "/local/base_write_multi_usage_key_script_script/Input1", + "name": "/local/base_write_multi_usage_key_script_script/Temp", "reads": [ { "columns": [ - "Amount", - "Name" + "Name", + "Value" ], "scan_by": [ - "Group (-\u221e, +\u221e)", "Name (-\u221e, +\u221e)" ], "type": "FullScan" } ] - }, - { - "name": "/local/base_write_multi_usage_key_script_script/Temp", - "writes": [ - { - "columns": [ - "Name", - "Value" - ], - "type": "MultiUpsert" - } - ] } - ], + ] + }, + { "Plan": { + "Node Type": "Query", + "PlanNodeType": "Query", "Plans": [ { + "Node Type": "Effect", "PlanNodeId": 7, "Plans": [ { - "Tables": [ - "base_write_multi_usage_key_script_script/Temp" - ], - "PlanNodeId": 6, + "CTE Name": "precompute_0_0", + "Node Type": "Upsert-ConstantExpr", "Operators": [ { "Inputs": [ @@ -150,27 +121,30 @@ "Name": "Iterator" } ], - "Node Type": "Upsert-ConstantExpr", - "CTE Name": "precompute_0_0" + "PlanNodeId": 6, + "Tables": [ + "base_write_multi_usage_key_script_script/Temp" + ] } - ], - "Node Type": "Effect" + ] }, { + "Node Type": "Precompute_0", + "Parent Relationship": "InitPlan", "PlanNodeId": 4, - "Subplan Name": "CTE precompute_0_0", + "PlanNodeType": "Materialize", "Plans": [ { + "Node Type": "Collect", "PlanNodeId": 3, "Plans": [ { + "Node Type": "UnionAll", "PlanNodeId": 2, + "PlanNodeType": "Connection", "Plans": [ { - "Tables": [ - "base_write_multi_usage_key_script_script/Input1" - ], - "PlanNodeId": 1, + "Node Type": "Filter-TableFullScan", "Operators": [ { "Inputs": [ @@ -178,41 +152,67 @@ "InternalOperatorId": 1 } ], - "Predicate": "item.Name == Concat", - "Name": "Filter" + "Name": "Filter", + "Predicate": "item.Name == Concat" }, { "Inputs": [], - "ReadRanges": [ - "Group (-\u221e, +\u221e)", - "Name (-\u221e, +\u221e)" - ], + "Name": "TableFullScan", "ReadColumns": [ "Amount", "Name" ], - "Name": "TableFullScan", + "ReadRanges": [ + "Group (-\u221e, +\u221e)", + "Name (-\u221e, +\u221e)" + ], "Table": "base_write_multi_usage_key_script_script/Input1" } ], - "Node Type": "Filter-TableFullScan" + "PlanNodeId": 1, + "Tables": [ + "base_write_multi_usage_key_script_script/Input1" + ] } - ], - "Node Type": "UnionAll", - "PlanNodeType": "Connection" + ] } - ], - "Node Type": "Collect" + ] } ], - "Node Type": "Precompute_0", - "Parent Relationship": "InitPlan", - "PlanNodeType": "Materialize" + "Subplan Name": "CTE precompute_0_0" } - ], - "Node Type": "Query", - "PlanNodeType": "Query" - } + ] + }, + "tables": [ + { + "name": "/local/base_write_multi_usage_key_script_script/Input1", + "reads": [ + { + "columns": [ + "Amount", + "Name" + ], + "scan_by": [ + "Group (-\u221e, +\u221e)", + "Name (-\u221e, +\u221e)" + ], + "type": "FullScan" + } + ] + }, + { + "name": "/local/base_write_multi_usage_key_script_script/Temp", + "writes": [ + { + "columns": [ + "Name", + "Value" + ], + "type": "MultiUpsert" + } + ] + } + ] } ] } \ No newline at end of file diff --git a/ydb/tests/functional/canonical/canondata/test_sql.TestCanonicalFolder1.test_case_write_write_group_by.script-script_/write_write_group_by.script.plan b/ydb/tests/functional/canonical/canondata/test_sql.TestCanonicalFolder1.test_case_write_write_group_by.script-script_/write_write_group_by.script.plan index f46411dc8419..572af3528a7c 100644 --- a/ydb/tests/functional/canonical/canondata/test_sql.TestCanonicalFolder1.test_case_write_write_group_by.script-script_/write_write_group_by.script.plan +++ b/ydb/tests/functional/canonical/canondata/test_sql.TestCanonicalFolder1.test_case_write_write_group_by.script-script_/write_write_group_by.script.plan @@ -1,44 +1,41 @@ { "meta": { - "version": "0.2", - "type": "script" + "type": "script", + "version": "0.2" }, "queries": [ { - "tables": [ - { - "name": "/local/base_write_write_group_by_script_script/Temp", - "reads": [ - { - "columns": [ - "Group", - "MinAmount", - "Value" - ], - "scan_by": [ - "Group (-\u221e, +\u221e)" - ], - "type": "FullScan" - } - ] - } - ], "Plan": { + "Node Type": "Query", + "PlanNodeType": "Query", "Plans": [ { + "Node Type": "ResultSet", "PlanNodeId": 4, + "PlanNodeType": "ResultSet", "Plans": [ { + "Node Type": "Limit", + "Operators": [ + { + "Inputs": [ + { + "ExternalPlanNodeId": 2 + } + ], + "Limit": "1001", + "Name": "Limit" + } + ], "PlanNodeId": 3, "Plans": [ { + "Node Type": "Merge", "PlanNodeId": 2, + "PlanNodeType": "Connection", "Plans": [ { - "Tables": [ - "base_write_write_group_by_script_script/Temp" - ], - "PlanNodeId": 1, + "Node Type": "Limit-TableFullScan", "Operators": [ { "Inputs": [ @@ -46,97 +43,70 @@ "InternalOperatorId": 1 } ], - "Name": "Limit", - "Limit": "1001" + "Limit": "1001", + "Name": "Limit" }, { "Inputs": [], - "ReadRanges": [ - "Group (-\u221e, +\u221e)" - ], + "Name": "TableFullScan", "ReadColumns": [ "Group", "MinAmount", "Value" ], - "Name": "TableFullScan", + "ReadRanges": [ + "Group (-\u221e, +\u221e)" + ], "Table": "base_write_write_group_by_script_script/Temp" } ], - "Node Type": "Limit-TableFullScan" + "PlanNodeId": 1, + "Tables": [ + "base_write_write_group_by_script_script/Temp" + ] } ], - "Node Type": "Merge", "SortColumns": [ "Group (Asc)" - ], - "PlanNodeType": "Connection" + ] } - ], - "Operators": [ - { - "Inputs": [ - { - "ExternalPlanNodeId": 2 - } - ], - "Name": "Limit", - "Limit": "1001" - } - ], - "Node Type": "Limit" + ] } - ], - "Node Type": "ResultSet", - "PlanNodeType": "ResultSet" + ] } - ], - "Node Type": "Query", - "PlanNodeType": "Query" - } - }, - { + ] + }, "tables": [ - { - "name": "/local/base_write_write_group_by_script_script/Input1", - "reads": [ - { - "columns": [ - "Amount", - "Group" - ], - "scan_by": [ - "Group (-\u221e, +\u221e)", - "Name (-\u221e, +\u221e)" - ], - "type": "FullScan" - } - ] - }, { "name": "/local/base_write_write_group_by_script_script/Temp", - "writes": [ + "reads": [ { "columns": [ "Group", "MinAmount", "Value" ], - "type": "MultiUpsert" + "scan_by": [ + "Group (-\u221e, +\u221e)" + ], + "type": "FullScan" } ] } - ], + ] + }, + { "Plan": { + "Node Type": "Query", + "PlanNodeType": "Query", "Plans": [ { + "Node Type": "Effect", "PlanNodeId": 9, "Plans": [ { - "Tables": [ - "base_write_write_group_by_script_script/Temp" - ], - "PlanNodeId": 8, + "CTE Name": "precompute_0_0", + "Node Type": "Upsert-ConstantExpr", "Operators": [ { "Inputs": [ @@ -153,86 +123,116 @@ "Name": "Iterator" } ], - "Node Type": "Upsert-ConstantExpr", - "CTE Name": "precompute_0_0" + "PlanNodeId": 8, + "Tables": [ + "base_write_write_group_by_script_script/Temp" + ] } - ], - "Node Type": "Effect" + ] }, { + "Node Type": "Precompute_0", + "Parent Relationship": "InitPlan", "PlanNodeId": 6, - "Subplan Name": "CTE precompute_0_0", + "PlanNodeType": "Materialize", "Plans": [ { + "Node Type": "Collect", "PlanNodeId": 5, "Plans": [ { + "Node Type": "UnionAll", "PlanNodeId": 4, + "PlanNodeType": "Connection", "Plans": [ { + "Node Type": "Stage", "PlanNodeId": 3, "Plans": [ { + "KeyColumns": [ + "Group" + ], + "Node Type": "HashShuffle", "PlanNodeId": 2, + "PlanNodeType": "Connection", "Plans": [ { - "Tables": [ - "base_write_write_group_by_script_script/Input1" - ], - "PlanNodeId": 1, + "Node Type": "Aggregate-TableFullScan", "Operators": [ { + "Aggregation": "{_yql_agg_0: MIN(item.Amount,state._yql_agg_0)}", + "GroupBy": "item.Group", "Inputs": [ { "InternalOperatorId": 1 } ], - "GroupBy": "item.Group", - "Aggregation": "{_yql_agg_0: MIN(item.Amount,state._yql_agg_0)}", "Name": "Aggregate" }, { "Inputs": [], - "ReadRanges": [ - "Group (-\u221e, +\u221e)", - "Name (-\u221e, +\u221e)" - ], + "Name": "TableFullScan", "ReadColumns": [ "Amount", "Group" ], - "Name": "TableFullScan", + "ReadRanges": [ + "Group (-\u221e, +\u221e)", + "Name (-\u221e, +\u221e)" + ], "Table": "base_write_write_group_by_script_script/Input1" } ], - "Node Type": "Aggregate-TableFullScan" + "PlanNodeId": 1, + "Tables": [ + "base_write_write_group_by_script_script/Input1" + ] } - ], - "Node Type": "HashShuffle", - "KeyColumns": [ - "Group" - ], - "PlanNodeType": "Connection" + ] } - ], - "Node Type": "Stage" + ] } - ], - "Node Type": "UnionAll", - "PlanNodeType": "Connection" + ] } - ], - "Node Type": "Collect" + ] } ], - "Node Type": "Precompute_0", - "Parent Relationship": "InitPlan", - "PlanNodeType": "Materialize" + "Subplan Name": "CTE precompute_0_0" } - ], - "Node Type": "Query", - "PlanNodeType": "Query" - } + ] + }, + "tables": [ + { + "name": "/local/base_write_write_group_by_script_script/Input1", + "reads": [ + { + "columns": [ + "Amount", + "Group" + ], + "scan_by": [ + "Group (-\u221e, +\u221e)", + "Name (-\u221e, +\u221e)" + ], + "type": "FullScan" + } + ] + }, + { + "name": "/local/base_write_write_group_by_script_script/Temp", + "writes": [ + { + "columns": [ + "Group", + "MinAmount", + "Value" + ], + "type": "MultiUpsert" + } + ] + } + ] } ] } \ No newline at end of file diff --git a/ydb/tests/functional/canonical/test_sql.py b/ydb/tests/functional/canonical/test_sql.py index 938364b20d0b..7863bdfe3e26 100644 --- a/ydb/tests/functional/canonical/test_sql.py +++ b/ydb/tests/functional/canonical/test_sql.py @@ -460,12 +460,19 @@ def run_test_case(self, query_name, kind): pt = config.get('parameters_types', {}) result_sets = self.script_query(query, pv, pt) canons['script'] = self.canonical_results(query_name, self.pretty_json(result_sets)) - canons['script_plan'] = self.canonical_plan(query_name, self.script_explain(query)) + plan = json.loads(self.script_explain(query)) + if 'queries' in plan: + for q in plan['queries']: + if 'SimplifiedPlan' in q: + del q['SimplifiedPlan'] + canons['script_plan'] = self.canonical_plan(query_name, self.pretty_json(plan)) self.compare_tables_test(canons, config, query_name) elif kind == 'plan': plan = json.loads(self.explain(query)) if 'Plan' in plan: del plan['Plan'] + if 'SimplifiedPlan' in plan: + del plan['SimplifiedPlan'] canons['plan'] = self.canonical_plan(query_name, self.pretty_json(plan)) elif kind == 'result_sets': result_sets = self.serializable_execute(query, config.get('parameters', {})) diff --git a/ydb/tests/functional/suite_tests/test_base.py b/ydb/tests/functional/suite_tests/test_base.py index 30da38597530..4a662fdaca12 100644 --- a/ydb/tests/functional/suite_tests/test_base.py +++ b/ydb/tests/functional/suite_tests/test_base.py @@ -354,6 +354,8 @@ def get_actual_and_expected(): query_name = "query_%d" % query_id if self.plan: query_plan = json.loads(self.explain(statement.text)) + if 'SimplifiedPlan' in query_plan: + del query_plan['SimplifiedPlan'] self.files[query_name + '.plan'] = write_canonical_response( query_plan, query_name + '.plan',