Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add conflict ut #13211

Merged
merged 2 commits into from
Jan 9, 2025
Merged
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
58 changes: 58 additions & 0 deletions ydb/core/kqp/ut/opt/kqp_returning_ut.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,64 @@ Y_UNIT_TEST(ReturningTwice) {
}
}

Y_UNIT_TEST(ReplaceSerial) {
NKikimrConfig::TAppConfig appConfig;
appConfig.MutableTableServiceConfig()->SetEnableSequences(true);
appConfig.MutableTableServiceConfig()->SetEnableColumnsWithDefault(true);
auto serverSettings = TKikimrSettings().SetAppConfig(appConfig);
TKikimrRunner kikimr(serverSettings);

auto client = kikimr.GetTableClient();
auto session = client.CreateSession().GetValueSync().GetSession();

const auto queryCreate = Q_(R"(
--!syntax_v1
CREATE TABLE ReturningTable (
key Serial,
value Int32,
PRIMARY KEY (key));
)");

auto resultCreate = session.ExecuteSchemeQuery(queryCreate).GetValueSync();
UNIT_ASSERT_C(resultCreate.IsSuccess(), resultCreate.GetIssues().ToString());

{
const auto query = Q_(R"(
--!syntax_v1
REPLACE INTO ReturningTable (key, value) VALUES (2, 10) RETURNING key, value;
)");

auto result = session.ExecuteDataQuery(query, TTxControl::BeginTx().CommitTx()).GetValueSync();
UNIT_ASSERT(result.IsSuccess());

CompareYson(R"([[2;[10]]])", FormatResultSetYson(result.GetResultSet(0)));
}

{
const auto query = Q_(R"(
--!syntax_v1
REPLACE INTO ReturningTable (value) VALUES(1), (2), (3) RETURNING key, value;
)");

auto result = session.ExecuteDataQuery(query, TTxControl::BeginTx().CommitTx()).GetValueSync();
UNIT_ASSERT(result.IsSuccess());

CompareYson(R"([[1;[1]];[2;[2]];[3;[3]]])", FormatResultSetYson(result.GetResultSet(0)));
}

{
const auto query = Q_(R"(
--!syntax_v1
select key, value from ReturningTable order by key asc;
)");

auto result = session.ExecuteDataQuery(query, TTxControl::BeginTx().CommitTx()).GetValueSync();
UNIT_ASSERT(result.IsSuccess());

CompareYson(R"([[1;[1]];[2;[2]];[3;[3]]])", FormatResultSetYson(result.GetResultSet(0)));
}
}

Y_UNIT_TEST(ReturningSerial) {
NKikimrConfig::TAppConfig appConfig;
appConfig.MutableTableServiceConfig()->SetEnableSequences(true);
Expand Down
Loading