Skip to content

Commit

Permalink
check supported store types (ydb-platform#12568)
Browse files Browse the repository at this point in the history
  • Loading branch information
zverevgeny committed Jan 5, 2025
1 parent bb5f349 commit b0e9d36
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 3 deletions.
14 changes: 11 additions & 3 deletions ydb/core/kqp/provider/yql_kikimr_type_ann.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1199,9 +1199,17 @@ virtual TStatus HandleCreateTable(TKiCreateTable create, TExprContext& ctx) over
"Can't reset TTL settings"));
return TStatus::Error;
} else if (name == "storeType") {
TMaybe<TString> storeType = TString(setting.Value().Cast<TCoAtom>().Value());
if (storeType && to_lower(storeType.GetRef()) == "column") {
meta->StoreType = EStoreType::Column;
if (const TMaybe<TString> storeType = TString(setting.Value().Cast<TCoAtom>().Value())) {
const auto& val = to_lower(storeType.GetRef());
if (val == "column") {
meta->StoreType = EStoreType::Column;
} else if (val == "row") {
//pass
} else {
ctx.AddError(TIssue(ctx.GetPosition(setting.Name().Pos()),
TStringBuilder() << "Unsupported table store type: " << storeType.GetRef()));
return TStatus::Error;
}
}
} else if (name == "partitionByHashFunction") {
meta->TableSettings.PartitionByHashFunction = TString(
Expand Down
24 changes: 24 additions & 0 deletions ydb/core/kqp/ut/scheme/kqp_scheme_ut.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4304,6 +4304,30 @@ Y_UNIT_TEST_SUITE(KqpScheme) {
}
}

Y_UNIT_TEST(NEG_CreateTableWithUnsupportedStoreType) {
TKikimrSettings runnerSettings;
runnerSettings.WithSampleTables = false;
TKikimrRunner kikimr(runnerSettings);
auto db = kikimr.GetTableClient();
auto session = db.CreateSession().GetValueSync().GetSession();
TString tableStoreName = "/Root/TableStoreTest";
auto query = TStringBuilder() << R"(
--!syntax_v1
CREATE TABLE SomeTable (
Key Timestamp NOT NULL,
Value1 String,
Value2 Int64 NOT NULL,
PRIMARY KEY (Key)
)
WITH (
STORE = UNSUPPORTED
);
)";
auto result = session.ExecuteSchemeQuery(query).GetValueSync();
UNIT_ASSERT_VALUES_EQUAL_C(result.GetStatus(), EStatus::GENERIC_ERROR, result.GetIssues().ToString());
}


Y_UNIT_TEST(CreateAlterDropTableStore) {
TKikimrSettings runnerSettings;
runnerSettings.WithSampleTables = false;
Expand Down

0 comments on commit b0e9d36

Please sign in to comment.