Skip to content

Commit e7cfbdc

Browse files
authored
Fix MODE_UPSERT for update queries (#17002)
1 parent 6ef9631 commit e7cfbdc

File tree

3 files changed

+11
-3
lines changed

3 files changed

+11
-3
lines changed

ydb/core/kqp/opt/kqp_opt_kql.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,10 @@ TExprNode::TPtr GetPgNotNullColumns(
204204

205205
TExprNode::TPtr IsUpdateSetting(TExprContext& ctx, const TPositionHandle& pos) {
206206
return Build<TCoNameValueTupleList>(ctx, pos)
207+
.Add()
208+
.Name().Build("Mode")
209+
.Value<TCoAtom>().Build("update")
210+
.Build()
207211
.Add()
208212
.Name().Build("IsUpdate")
209213
.Build()
@@ -212,6 +216,10 @@ TExprNode::TPtr IsUpdateSetting(TExprContext& ctx, const TPositionHandle& pos) {
212216

213217
TExprNode::TPtr IsConditionalUpdateSetting(TExprContext& ctx, const TPositionHandle& pos) {
214218
return Build<TCoNameValueTupleList>(ctx, pos)
219+
.Add()
220+
.Name().Build("Mode")
221+
.Value<TCoAtom>().Build("update")
222+
.Build()
215223
.Add()
216224
.Name().Build("IsUpdate")
217225
.Build()

ydb/core/kqp/ut/query/kqp_explain_ut.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -523,7 +523,7 @@ Y_UNIT_TEST_SUITE(KqpExplain) {
523523
auto deletesConstCount = CountPlanNodesByKv(plan, "Node Type", "Delete-ConstantExpr");
524524
UNIT_ASSERT_VALUES_EQUAL(deletesConstCount, UseSink ? 0 : 1);
525525

526-
auto upsertsCount = CountPlanNodesByKv(plan, "Name", "Upsert");
526+
auto upsertsCount = CountPlanNodesByKv(plan, "Name", UseSink ? "Update" : "Upsert");
527527
UNIT_ASSERT_VALUES_EQUAL(upsertsCount, UseSink ? 2 : 2);
528528

529529
auto deletesCount = CountPlanNodesByKv(plan, "Name", "Delete");
@@ -549,7 +549,7 @@ Y_UNIT_TEST_SUITE(KqpExplain) {
549549
countOperationsByType("reads");
550550
countOperationsByType("writes");
551551

552-
UNIT_ASSERT_VALUES_EQUAL(counter["MultiUpsert"], UseSink ? upsertsCount : upsertsConstCount);
552+
UNIT_ASSERT_VALUES_EQUAL(counter[UseSink ? "MultiUpdate" : "MultiUpsert"], UseSink ? upsertsCount : upsertsConstCount);
553553
UNIT_ASSERT_VALUES_EQUAL(counter["MultiErase"], UseSink ? deletesCount : deletesConstCount);
554554
UNIT_ASSERT_VALUES_EQUAL(counter["FullScan"], fullScansCount);
555555
UNIT_ASSERT_VALUES_EQUAL(counter["Scan"], rangeScansCount);

ydb/tests/functional/canonical/canondata/test_sql.TestCanonicalFolder1.test_case_write_update.sql-plan_/write_update.sql.plan

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
"Group",
3030
"Name"
3131
],
32-
"type": "MultiUpsert"
32+
"type": "MultiUpdate"
3333
}
3434
]
3535
}

0 commit comments

Comments
 (0)