Skip to content

Commit

Permalink
bug: replace into table with default values is not working (#5787)
Browse files Browse the repository at this point in the history
  • Loading branch information
flown4qqqq authored Jun 21, 2024
1 parent 5e3924b commit 1fb6b33
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 1 deletion.
2 changes: 1 addition & 1 deletion ydb/core/kqp/opt/kqp_opt_kql.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ std::pair<TExprBase, TCoAtomList> 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<TKqpWriteConstraint>(ctx, pos)
Expand Down
35 changes: 35 additions & 0 deletions ydb/core/kqp/ut/service/kqp_qs_queries_ut.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3498,6 +3498,41 @@ Y_UNIT_TEST_SUITE(KqpQueryService) {
R"([[8u]])");
}
}

Y_UNIT_TEST(ReplaceIntoWithDefaultValue) {
NKikimrConfig::TAppConfig appConfig;
appConfig.MutableTableServiceConfig()->SetEnableOlapSink(false);
appConfig.MutableTableServiceConfig()->SetEnableOltpSink(false);
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
Expand Down

0 comments on commit 1fb6b33

Please sign in to comment.