Skip to content

Commit c061c70

Browse files
nikvas0dorooleg
authored andcommitted
Test for wrong keys for Column Table (#25854)
1 parent 93ba5cf commit c061c70

File tree

1 file changed

+45
-0
lines changed

1 file changed

+45
-0
lines changed

ydb/core/kqp/ut/service/kqp_qs_queries_ut.cpp

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3660,6 +3660,51 @@ Y_UNIT_TEST_SUITE(KqpQueryService) {
36603660
}
36613661
}
36623662

3663+
Y_UNIT_TEST_TWIN(CTAS_BadKey, IsOlap) {
3664+
auto setting = NKikimrKqp::TKqpSetting();
3665+
auto serverSettings = TKikimrSettings()
3666+
.SetKqpSettings({setting})
3667+
.SetWithSampleTables(false)
3668+
.SetEnableTempTables(true);
3669+
serverSettings.AppConfig.MutableTableServiceConfig()->SetEnableOlapSink(true);
3670+
serverSettings.AppConfig.MutableTableServiceConfig()->SetEnableCreateTableAs(true);
3671+
3672+
TKikimrRunner kikimr(serverSettings);
3673+
auto db = kikimr.GetQueryClient();
3674+
3675+
if (IsOlap) {
3676+
return;
3677+
}
3678+
3679+
{
3680+
auto result = db.ExecuteQuery(Sprintf(R"(
3681+
CREATE TABLE Table (
3682+
PRIMARY KEY (Key2, Key)
3683+
) WITH (STORE=%s)
3684+
AS SELECT 1u AS Key, "1" AS Value1, "1" AS Value2;
3685+
)", IsOlap ? "COLUMN" : "ROW"), TTxControl::NoTx(), TExecuteQuerySettings()).ExtractValueSync();
3686+
3687+
UNIT_ASSERT_C(!result.IsSuccess(), result.GetIssues().ToString());
3688+
UNIT_ASSERT_C(
3689+
result.GetIssues().ToString().contains("Unknown column 'Key2' specified in key column list"),
3690+
result.GetIssues().ToString());
3691+
}
3692+
3693+
{
3694+
auto result = db.ExecuteQuery(Sprintf(R"(
3695+
CREATE TABLE Table (
3696+
PRIMARY KEY (Key, Key2)
3697+
) WITH (STORE=%s)
3698+
AS SELECT 1u AS Key, "1" AS Value1, "1" AS Value2;
3699+
)", IsOlap ? "COLUMN" : "ROW"), TTxControl::NoTx(), TExecuteQuerySettings()).ExtractValueSync();
3700+
3701+
UNIT_ASSERT_C(!result.IsSuccess(), result.GetIssues().ToString());
3702+
UNIT_ASSERT_C(
3703+
result.GetIssues().ToString().contains("Unknown column 'Key2' specified in key column list"),
3704+
result.GetIssues().ToString());
3705+
}
3706+
}
3707+
36633708
Y_UNIT_TEST(CheckIsolationLevelFroPerStatementMode) {
36643709
auto setting = NKikimrKqp::TKqpSetting();
36653710
auto serverSettings = TKikimrSettings().SetKqpSettings({setting});

0 commit comments

Comments
 (0)