diff --git a/ydb/core/kqp/opt/kqp_opt_kql.cpp b/ydb/core/kqp/opt/kqp_opt_kql.cpp index 4aee267bfe23..9f69554e2b2c 100644 --- a/ydb/core/kqp/opt/kqp_opt_kql.cpp +++ b/ydb/core/kqp/opt/kqp_opt_kql.cpp @@ -268,7 +268,7 @@ std::pair BuildWriteInput(const TKiWriteTable& write, co } if (isWriteReplace) { - std::tie(input, inputCols) = CreateRowsToReplace(input, inputColumns, table, write.Pos(), ctx); + std::tie(input, inputCols) = CreateRowsToReplace(input, inputCols, table, write.Pos(), ctx); } auto baseInput = Build(ctx, pos) diff --git a/ydb/core/kqp/ut/service/kqp_qs_queries_ut.cpp b/ydb/core/kqp/ut/service/kqp_qs_queries_ut.cpp index aa8009bcacab..c5e7b0e0e0c8 100644 --- a/ydb/core/kqp/ut/service/kqp_qs_queries_ut.cpp +++ b/ydb/core/kqp/ut/service/kqp_qs_queries_ut.cpp @@ -1816,6 +1816,40 @@ Y_UNIT_TEST_SUITE(KqpQueryService) { UNIT_ASSERT(!service->IsUnsafeToShutdown()); } } + + Y_UNIT_TEST(ReplaceIntoWithDefaultValue) { + NKikimrConfig::TAppConfig appConfig; + appConfig.MutableTableServiceConfig()->SetEnableColumnsWithDefault(true); + auto settings = TKikimrSettings() + .SetAppConfig(appConfig) + .SetWithSampleTables(false); + + TKikimrRunner kikimr(settings); + Tests::NCommon::TLoggerInit(kikimr).Initialize(); + + // auto session = kikimr.GetTableClient().CreateSession().GetValueSync().GetSession(); + auto client = kikimr.GetQueryClient(); + + { + auto createTable = client.ExecuteQuery(R"sql( + CREATE TABLE `/Root/test/tb` ( + id UInt32, + val UInt32 NOT NULL DEFAULT(100), + PRIMARY KEY(id) + ); + )sql", NYdb::NQuery::TTxControl::NoTx()).ExtractValueSync(); + UNIT_ASSERT_C(createTable.IsSuccess(), createTable.GetIssues().ToString()); + } + + { + auto replaceValues = client.ExecuteQuery(R"sql( + REPLACE INTO `/Root/test/tb` (id) VALUES + ( 1 ) + ; + )sql", NYdb::NQuery::TTxControl::BeginTx().CommitTx()).ExtractValueSync(); + UNIT_ASSERT_C(replaceValues.IsSuccess(), replaceValues.GetIssues().ToString()); + } + } } } // namespace NKqp