Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions ydb/core/kqp/opt/kqp_query_plan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -244,8 +244,8 @@ class TxPlanSerializer {
planNode.TypeName = "Effect";
Visit(TExprBase(stage), planNode);
} else if (stageBase.Outputs()) { // Sink
AFL_ENSURE(stageBase.Outputs().Cast().Size() == 1);
auto& planNode = AddPlanNode(phaseNode);
planNode.TypeName = "Sink";
Visit(TExprBase(stage), planNode);
}
}
Expand Down Expand Up @@ -960,7 +960,8 @@ class TxPlanSerializer {
if (auto outputs = expr.Cast<TDqStageBase>().Outputs()) {
for (auto output : outputs.Cast()) {
if (auto sink = output.Maybe<TDqSink>()) {
Visit(sink.Cast(), expr.Cast<TDqStageBase>(), stagePlanNode);
AFL_ENSURE(outputs.Cast().Size() == 1);
Visit(sink.Cast(), expr.Cast<TDqStageBase>(), planNode);
}
}
}
Expand Down
27 changes: 22 additions & 5 deletions ydb/core/kqp/ut/federated_query/s3/kqp_s3_plan_ut.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -143,9 +143,12 @@ Y_UNIT_TEST_SUITE(KqpS3PlanTest) {
UNIT_ASSERT(NJson::ReadJsonTree(*queryResult.GetStats()->GetPlan(), &plan));

const auto& writeStagePlan = plan["Plan"]["Plans"][0]["Plans"][0];
UNIT_ASSERT_VALUES_EQUAL(writeStagePlan["Node Type"].GetStringSafe(), "Stage-Sink");
UNIT_ASSERT(writeStagePlan["Operators"].GetArraySafe().size() >= 1);
const auto& sinkOp = writeStagePlan["Operators"].GetArraySafe()[0];
UNIT_ASSERT_VALUES_EQUAL(writeStagePlan["Node Type"].GetStringSafe(), "Stage");

const auto& sinkPlan = plan["Plan"]["Plans"][0];
UNIT_ASSERT_VALUES_EQUAL(sinkPlan["Node Type"].GetStringSafe(), "Sink");
UNIT_ASSERT(sinkPlan["Operators"].GetArraySafe().size() >= 1);
const auto& sinkOp = sinkPlan["Operators"].GetArraySafe()[0];
UNIT_ASSERT_VALUES_EQUAL(sinkOp["ExternalDataSource"].GetStringSafe(), "write_data_source");
UNIT_ASSERT_VALUES_EQUAL(sinkOp["Compression"].GetStringSafe(), "gzip");

Expand Down Expand Up @@ -218,9 +221,16 @@ Y_UNIT_TEST_SUITE(KqpS3PlanTest) {
UNIT_ASSERT(NJson::ReadJsonTree(*queryResult.GetStats()->GetPlan(), &plan));

const auto& writeStagePlan = plan["Plan"]["Plans"][0]["Plans"][0];
UNIT_ASSERT_VALUES_EQUAL(writeStagePlan["Node Type"].GetStringSafe(), "Stage-Sink");
UNIT_ASSERT_VALUES_EQUAL(writeStagePlan["Node Type"].GetStringSafe(), "Stage");
UNIT_ASSERT_VALUES_EQUAL(writeStagePlan["Stats"]["Tasks"], 1);

const auto& sinkPlan = plan["Plan"]["Plans"][0];
UNIT_ASSERT_VALUES_EQUAL(sinkPlan["Node Type"].GetStringSafe(), "Sink");
UNIT_ASSERT(sinkPlan["Operators"].GetArraySafe().size() >= 1);
const auto& sinkOp = sinkPlan["Operators"].GetArraySafe()[0];
UNIT_ASSERT_VALUES_EQUAL(sinkOp["Name"].GetStringSafe(), "FillTable");
UNIT_ASSERT_VALUES_EQUAL(sinkOp["Table"].GetStringSafe(), "result_table");

const auto& readStagePlan = plan["Plan"]["Plans"][0]["Plans"][0]["Plans"][0]["Plans"][0];
UNIT_ASSERT_VALUES_EQUAL(readStagePlan["Node Type"].GetStringSafe(), "Stage");
UNIT_ASSERT_VALUES_EQUAL(readStagePlan["Stats"]["Tasks"], 1);
Expand Down Expand Up @@ -290,9 +300,16 @@ Y_UNIT_TEST_SUITE(KqpS3PlanTest) {
UNIT_ASSERT(NJson::ReadJsonTree(*queryResult.GetStats()->GetPlan(), &plan));

const auto& writeStagePlan = plan["Plan"]["Plans"][0]["Plans"][0];
UNIT_ASSERT_VALUES_EQUAL(writeStagePlan["Node Type"].GetStringSafe(), "Stage-Sink");
UNIT_ASSERT_VALUES_EQUAL(writeStagePlan["Node Type"].GetStringSafe(), "Stage");
UNIT_ASSERT_VALUES_EQUAL(writeStagePlan["Stats"]["Tasks"], 42);

const auto& sinkPlan = plan["Plan"]["Plans"][0];
UNIT_ASSERT_VALUES_EQUAL(sinkPlan["Node Type"].GetStringSafe(), "Sink");
UNIT_ASSERT(sinkPlan["Operators"].GetArraySafe().size() >= 1);
const auto& sinkOp = sinkPlan["Operators"].GetArraySafe()[0];
UNIT_ASSERT_VALUES_EQUAL(sinkOp["ExternalDataSource"].GetStringSafe(), "insert_data_sink");
UNIT_ASSERT_VALUES_EQUAL(sinkOp["Extension"].GetStringSafe(), ".parquet");

const auto& readStagePlan = plan["Plan"]["Plans"][0]["Plans"][0]["Plans"][0]["Plans"][0];
UNIT_ASSERT_VALUES_EQUAL(readStagePlan["Node Type"].GetStringSafe(), "TableFullScan");
UNIT_ASSERT_VALUES_EQUAL(readStagePlan["Stats"]["Tasks"], 42);
Expand Down
2 changes: 1 addition & 1 deletion ydb/core/kqp/ut/query/kqp_stats_ut.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ Y_UNIT_TEST_TWIN(DataQueryWithEffects, UseSink) {
NJson::ReadJsonTree(result.GetQueryPlan(), &plan, true);

if (UseSink) {
auto node = FindPlanNodeByKv(plan, "Node Type", "Stage-Sink");
auto node = FindPlanNodeByKv(plan, "Node Type", "Stage");
UNIT_ASSERT_EQUAL(node.GetMap().at("Stats").GetMapSafe().at("Tasks").GetIntegerSafe(), 1);
} else {
auto node = FindPlanNodeByKv(plan, "Node Type", "Upsert-ConstantExpr");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -520,29 +520,31 @@
"Plans": [
{
"Node Type": "Sink",
"Operators": [
{
"Inputs": [],
"Name": "Replace",
"Path": "/local/base_explain_script_script/ScriptingTest",
"SinkType": "KqpTableSink",
"Table": "base_explain_script_script/ScriptingTest"
}
],
"PlanNodeId": 2,
"Plans": [
{
"Node Type": "ConstantExpr-Sink",
"Node Type": "ConstantExpr",
"Operators": [
{
"Inputs": [],
"Iterator": "[{Key: 3,Value: \"Three\"},{Key: 4,Value: \"Four\"}]",
"Name": "Iterator"
},
{
"Inputs": [],
"Name": "Replace",
"Path": "/local/base_explain_script_script/ScriptingTest",
"SinkType": "KqpTableSink",
"Table": "base_explain_script_script/ScriptingTest"
}
],
"PlanNodeId": 1,
"Tables": [
"base_explain_script_script/ScriptingTest"
]
"PlanNodeId": 1
}
],
"Tables": [
"base_explain_script_script/ScriptingTest"
]
}
],
Expand Down Expand Up @@ -572,29 +574,31 @@
"Plans": [
{
"Node Type": "Sink",
"Operators": [
{
"Inputs": [],
"Name": "Replace",
"Path": "/local/base_explain_script_script/ScriptingTest",
"SinkType": "KqpTableSink",
"Table": "base_explain_script_script/ScriptingTest"
}
],
"PlanNodeId": 2,
"Plans": [
{
"Node Type": "ConstantExpr-Sink",
"Node Type": "ConstantExpr",
"Operators": [
{
"Inputs": [],
"Iterator": "[{Key: 1,Value: \"One\"},{Key: 2,Value: \"Two\"}]",
"Name": "Iterator"
},
{
"Inputs": [],
"Name": "Replace",
"Path": "/local/base_explain_script_script/ScriptingTest",
"SinkType": "KqpTableSink",
"Table": "base_explain_script_script/ScriptingTest"
}
],
"PlanNodeId": 1,
"Tables": [
"base_explain_script_script/ScriptingTest"
]
"PlanNodeId": 1
}
],
"Tables": [
"base_explain_script_script/ScriptingTest"
]
}
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -282,29 +282,31 @@
"Plans": [
{
"Node Type": "Sink",
"Operators": [
{
"Inputs": [],
"Name": "Replace",
"Path": "/local/base_join_group_by_lookup_script_script/Temp",
"SinkType": "KqpTableSink",
"Table": "base_join_group_by_lookup_script_script/Temp"
}
],
"PlanNodeId": 2,
"Plans": [
{
"Node Type": "ConstantExpr-Sink",
"Node Type": "ConstantExpr",
"Operators": [
{
"Inputs": [],
"Iterator": "[{Group: 1,Value: \"One\"},{Group: 3,Value: \"Three\"}]",
"Name": "Iterator"
},
{
"Inputs": [],
"Name": "Replace",
"Path": "/local/base_join_group_by_lookup_script_script/Temp",
"SinkType": "KqpTableSink",
"Table": "base_join_group_by_lookup_script_script/Temp"
}
],
"PlanNodeId": 1,
"Tables": [
"base_join_group_by_lookup_script_script/Temp"
]
"PlanNodeId": 1
}
],
"Tables": [
"base_join_group_by_lookup_script_script/Temp"
]
}
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,29 +11,31 @@
"Plans": [
{
"Node Type": "Sink",
"Operators": [
{
"Inputs": [],
"Name": "Upsert",
"Path": "/local/base_simple_ct_script_script/Questions",
"SinkType": "KqpTableSink",
"Table": "base_simple_ct_script_script/Questions"
}
],
"PlanNodeId": 2,
"Plans": [
{
"Node Type": "ConstantExpr-Sink",
"Node Type": "ConstantExpr",
"Operators": [
{
"Inputs": [],
"Iterator": "[{idx: 1,text: \"to do or not to do\"}]",
"Name": "Iterator"
},
{
"Inputs": [],
"Name": "Upsert",
"Path": "/local/base_simple_ct_script_script/Questions",
"SinkType": "KqpTableSink",
"Table": "base_simple_ct_script_script/Questions"
}
],
"PlanNodeId": 1,
"Tables": [
"base_simple_ct_script_script/Questions"
]
"PlanNodeId": 1
}
],
"Tables": [
"base_simple_ct_script_script/Questions"
]
}
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,29 +136,31 @@
"Plans": [
{
"Node Type": "Sink",
"Operators": [
{
"Inputs": [],
"Name": "Replace",
"Path": "/local/base_table_types_script_script/TableTypes",
"SinkType": "KqpTableSink",
"Table": "base_table_types_script_script/TableTypes"
}
],
"PlanNodeId": 2,
"Plans": [
{
"Node Type": "ConstantExpr-Sink",
"Node Type": "ConstantExpr",
"Operators": [
{
"Inputs": [],
"Iterator": "[{Key: \"Key\",Value01: \"true\",Value02: 1,Value03: -1,Value04: 2,Value05: -2,Value06: 3,Value07: \"4.5\",Value08: Minus,Value09: \"3.14\",Value10: DyNumber,Value21: \"\\u041F\\u0440\\u0438\\u0432\\u0435\\u0442\",Value22: \"{\\\"name\\\": \\\"George\\\", \\\"age\\\": 23}\",Value23: JsonDocument,Value24: \"{a=1; b=2}\",Value31: Apply,Value32: Apply,Value33: Apply,Value34: Apply}]",
"Name": "Iterator"
},
{
"Inputs": [],
"Name": "Replace",
"Path": "/local/base_table_types_script_script/TableTypes",
"SinkType": "KqpTableSink",
"Table": "base_table_types_script_script/TableTypes"
}
],
"PlanNodeId": 1,
"Tables": [
"base_table_types_script_script/TableTypes"
]
"PlanNodeId": 1
}
],
"Tables": [
"base_table_types_script_script/TableTypes"
]
}
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -217,19 +217,19 @@
"Plans": [
{
"Node Type": "Sink",
"Operators": [
{
"Inputs": [],
"Name": "Upsert",
"Path": "/local/base_write_multi_usage_script_script/Temp",
"SinkType": "KqpTableSink",
"Table": "base_write_multi_usage_script_script/Temp"
}
],
"PlanNodeId": 7,
"Plans": [
{
"Node Type": "Stage-Sink",
"Operators": [
{
"Inputs": [],
"Name": "Upsert",
"Path": "/local/base_write_multi_usage_script_script/Temp",
"SinkType": "KqpTableSink",
"Table": "base_write_multi_usage_script_script/Temp"
}
],
"Node Type": "Stage",
"PlanNodeId": 6,
"Plans": [
{
Expand Down Expand Up @@ -268,38 +268,40 @@
}
]
}
],
"Tables": [
"base_write_multi_usage_script_script/Temp"
]
}
],
"Tables": [
"base_write_multi_usage_script_script/Temp"
]
},
{
"Node Type": "Sink",
"Operators": [
{
"Inputs": [],
"Name": "Delete",
"Path": "/local/base_write_multi_usage_script_script/Input1",
"SinkType": "KqpTableSink",
"Table": "base_write_multi_usage_script_script/Input1"
}
],
"PlanNodeId": 2,
"Plans": [
{
"Node Type": "ConstantExpr-Sink",
"Node Type": "ConstantExpr",
"Operators": [
{
"Inputs": [],
"Iterator": "[{Group: 1,Name: ToString}]",
"Name": "Iterator"
},
{
"Inputs": [],
"Name": "Delete",
"Path": "/local/base_write_multi_usage_script_script/Input1",
"SinkType": "KqpTableSink",
"Table": "base_write_multi_usage_script_script/Input1"
}
],
"PlanNodeId": 1,
"Tables": [
"base_write_multi_usage_script_script/Input1"
]
"PlanNodeId": 1
}
],
"Tables": [
"base_write_multi_usage_script_script/Input1"
]
}
],
Expand Down
Loading
Loading