aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorchertus <azuikov@ydb.tech>2023-01-14 12:42:47 +0300
committerchertus <azuikov@ydb.tech>2023-01-14 12:42:47 +0300
commit380ce27d41b76ca1640e48b7271681b3719d6be0 (patch)
tree53a5078a678deed309390fb95933c6d7b914921f
parent8282110d4614b266f126a483959c2369ded6d738 (diff)
downloadydb-380ce27d41b76ca1640e48b7271681b3719d6be0.tar.gz
CREATE/ALTER table with tiering
-rw-r--r--ydb/core/grpc_services/rpc_alter_table.cpp1
-rw-r--r--ydb/core/grpc_services/rpc_log_store.cpp6
-rw-r--r--ydb/core/kqp/gateway/kqp_ic_gateway.cpp10
-rw-r--r--ydb/core/kqp/provider/yql_kikimr_exec.cpp7
-rw-r--r--ydb/core/kqp/provider/yql_kikimr_gateway.h1
-rw-r--r--ydb/core/kqp/provider/yql_kikimr_type_ann.cpp8
-rw-r--r--ydb/core/kqp/ut/scheme/kqp_scheme_ut.cpp50
-rw-r--r--ydb/core/ydb_convert/table_settings.cpp6
-rw-r--r--ydb/public/api/protos/draft/ydb_logstore.proto1
-rw-r--r--ydb/public/api/protos/ydb_table.proto7
10 files changed, 97 insertions, 0 deletions
diff --git a/ydb/core/grpc_services/rpc_alter_table.cpp b/ydb/core/grpc_services/rpc_alter_table.cpp
index 26aca5ef3b..e11ea224d3 100644
--- a/ydb/core/grpc_services/rpc_alter_table.cpp
+++ b/ydb/core/grpc_services/rpc_alter_table.cpp
@@ -105,6 +105,7 @@ class TAlterTableRPC : public TRpcSchemeRequestActor<TAlterTableRPC, TEvAlterTab
if (req->add_columns_size() || req->drop_columns_size() || req->alter_columns_size()
|| req->ttl_action_case() != Ydb::Table::AlterTableRequest::TTL_ACTION_NOT_SET
+ || req->tiering_action_case() != Ydb::Table::AlterTableRequest::TIERING_ACTION_NOT_SET
|| req->has_alter_storage_settings()
|| req->add_column_families_size() || req->alter_column_families_size()
|| req->set_compaction_policy() || req->has_alter_partitioning_settings()
diff --git a/ydb/core/grpc_services/rpc_log_store.cpp b/ydb/core/grpc_services/rpc_log_store.cpp
index b219497422..432a74c9dd 100644
--- a/ydb/core/grpc_services/rpc_log_store.cpp
+++ b/ydb/core/grpc_services/rpc_log_store.cpp
@@ -623,6 +623,12 @@ private:
alter->MutableAlterTtlSettings()->MutableDisabled();
}
+ if (req->has_set_tiering_settings()) {
+ alter->MutableAlterTtlSettings()->SetUseTiering(req->set_tiering_settings().tiering_id());
+ } else if (req->has_drop_tiering_settings()) {
+ alter->MutableAlterTtlSettings()->SetUseTiering("");
+ }
+
ctx.Send(MakeTxProxyID(), proposeRequest.release());
}
};
diff --git a/ydb/core/kqp/gateway/kqp_ic_gateway.cpp b/ydb/core/kqp/gateway/kqp_ic_gateway.cpp
index 2e77082c25..1618da995e 100644
--- a/ydb/core/kqp/gateway/kqp_ic_gateway.cpp
+++ b/ydb/core/kqp/gateway/kqp_ic_gateway.cpp
@@ -2424,6 +2424,16 @@ private:
}
}
+ if (const auto& tiering = metadata->TableSettings.Tiering) {
+ if (tiering.IsSet()) {
+ proto.set_tiering(tiering.GetValueSet());
+ } else {
+ code = Ydb::StatusIds::BAD_REQUEST;
+ error = "Can't reset TIERING";
+ return false;
+ }
+ }
+
return true;
}
diff --git a/ydb/core/kqp/provider/yql_kikimr_exec.cpp b/ydb/core/kqp/provider/yql_kikimr_exec.cpp
index 5af17cfddb..c2d37a9412 100644
--- a/ydb/core/kqp/provider/yql_kikimr_exec.cpp
+++ b/ydb/core/kqp/provider/yql_kikimr_exec.cpp
@@ -864,6 +864,13 @@ public:
ConvertTtlSettingsToProto(ttlSettings, *alterTableRequest.mutable_set_ttl_settings());
} else if (name == "resetTtlSettings") {
alterTableRequest.mutable_drop_ttl_settings();
+ } else if (name == "setTiering") {
+ const auto tieringName = TString(
+ setting.Value().Cast<TCoDataCtor>().Literal().Cast<TCoAtom>().Value()
+ );
+ alterTableRequest.set_set_tiering(tieringName);
+ } else if (name == "resetTiering") {
+ alterTableRequest.mutable_drop_tiering();
} else {
ctx.AddError(TIssue(ctx.GetPosition(setting.Name().Pos()),
TStringBuilder() << "Unknown table profile setting: " << name));
diff --git a/ydb/core/kqp/provider/yql_kikimr_gateway.h b/ydb/core/kqp/provider/yql_kikimr_gateway.h
index f09b2479a3..35010a5a51 100644
--- a/ydb/core/kqp/provider/yql_kikimr_gateway.h
+++ b/ydb/core/kqp/provider/yql_kikimr_gateway.h
@@ -170,6 +170,7 @@ struct TTableSettings {
TMaybe<TString> KeyBloomFilter;
TMaybe<TString> ReadReplicasSettings;
TResetableSetting<TTtlSettings, void> TtlSettings;
+ TResetableSetting<TString, void> Tiering;
TMaybe<TString> PartitionByHashFunction;
bool IsSet() const;
diff --git a/ydb/core/kqp/provider/yql_kikimr_type_ann.cpp b/ydb/core/kqp/provider/yql_kikimr_type_ann.cpp
index d6671caf7d..8b9750b16a 100644
--- a/ydb/core/kqp/provider/yql_kikimr_type_ann.cpp
+++ b/ydb/core/kqp/provider/yql_kikimr_type_ann.cpp
@@ -796,6 +796,14 @@ private:
ctx.AddError(TIssue(ctx.GetPosition(setting.Name().Pos()),
"Can't reset TTL settings"));
return TStatus::Error;
+ } else if (name == "setTiering") {
+ meta->TableSettings.Tiering.Set(TString(
+ setting.Value().Cast<TCoDataCtor>().Literal().Cast<TCoAtom>().Value()
+ ));
+ } else if (name == "resetTiering") {
+ ctx.AddError(TIssue(ctx.GetPosition(setting.Name().Pos()),
+ "Can't reset TIERING"));
+ return TStatus::Error;
} else if (name == "storeType") {
TMaybe<TString> storeType = TString(setting.Value().Cast<TCoAtom>().Value());
if (storeType && to_lower(storeType.GetRef()) == "column") {
diff --git a/ydb/core/kqp/ut/scheme/kqp_scheme_ut.cpp b/ydb/core/kqp/ut/scheme/kqp_scheme_ut.cpp
index 1360463231..ba5dc5ad54 100644
--- a/ydb/core/kqp/ut/scheme/kqp_scheme_ut.cpp
+++ b/ydb/core/kqp/ut/scheme/kqp_scheme_ut.cpp
@@ -3371,6 +3371,56 @@ Y_UNIT_TEST_SUITE(KqpScheme) {
UNIT_ASSERT_VALUES_EQUAL_C(result.GetStatus(), EStatus::SUCCESS, result.GetIssues().ToString());
}
+ Y_UNIT_TEST(AlterColumnTableTiering) {
+ TKikimrSettings runnerSettings;
+ runnerSettings.WithSampleTables = false;
+ TKikimrRunner kikimr(runnerSettings);
+ auto db = kikimr.GetTableClient();
+ auto session = db.CreateSession().GetValueSync().GetSession();
+ TString tableName = "/Root/ColumnTableTest";
+
+ auto query = TStringBuilder() << R"(
+ --!syntax_v1
+ CREATE TABLE `)" << tableName << R"(` (
+ Key Uint64 NOT NULL,
+ Value1 String,
+ Value2 Int64 NOT NULL,
+ PRIMARY KEY (Key)
+ )
+ PARTITION BY HASH(Value1, Value2)
+ WITH (
+ STORE = COLUMN,
+ AUTO_PARTITIONING_MIN_PARTITIONS_COUNT = 10,
+ TIERING = 'tiering1'
+ );)";
+ auto result = session.ExecuteSchemeQuery(query).GetValueSync();
+ UNIT_ASSERT_VALUES_EQUAL_C(result.GetStatus(), EStatus::SUCCESS, result.GetIssues().ToString());
+
+ auto query2 = TStringBuilder() << R"(
+ --!syntax_v1
+ ALTER TABLE `)" << tableName << R"(` SET(TIERING = 'tiering2');)";
+ result = session.ExecuteSchemeQuery(query2).GetValueSync();
+ UNIT_ASSERT_VALUES_EQUAL_C(result.GetStatus(), EStatus::SUCCESS, result.GetIssues().ToString());
+
+ auto query3 = TStringBuilder() << R"(
+ --!syntax_v1
+ ALTER TABLE `)" << tableName << R"(` RESET (TIERING);)";
+ result = session.ExecuteSchemeQuery(query3).GetValueSync();
+ UNIT_ASSERT_VALUES_EQUAL_C(result.GetStatus(), EStatus::SUCCESS, result.GetIssues().ToString());
+
+ auto query4 = TStringBuilder() << R"(
+ --!syntax_v1
+ ALTER TABLE `)" << tableName << R"(` SET (TIERING = 'tiering1');)";
+ result = session.ExecuteSchemeQuery(query4).GetValueSync();
+ UNIT_ASSERT_VALUES_EQUAL_C(result.GetStatus(), EStatus::SUCCESS, result.GetIssues().ToString());
+
+ auto query5 = TStringBuilder() << R"(
+ --!syntax_v1
+ DROP TABLE `)" << tableName << R"(`;)";
+ result = session.ExecuteSchemeQuery(query5).GetValueSync();
+ UNIT_ASSERT_VALUES_EQUAL_C(result.GetStatus(), EStatus::SUCCESS, result.GetIssues().ToString());
+ }
+
Y_UNIT_TEST(Int8Int16) {
TKikimrRunner kikimr;
diff --git a/ydb/core/ydb_convert/table_settings.cpp b/ydb/core/ydb_convert/table_settings.cpp
index 3f3547f1f5..0e5b56d85f 100644
--- a/ydb/core/ydb_convert/table_settings.cpp
+++ b/ydb/core/ydb_convert/table_settings.cpp
@@ -346,6 +346,12 @@ bool FillAlterTableSettingsDesc(NKikimrSchemeOp::TTableDescription& tableDesc,
tableDesc.MutableTTLSettings()->MutableDisabled();
}
+ if (proto.has_set_tiering()) {
+ tableDesc.MutableTTLSettings()->SetUseTiering(proto.set_tiering());
+ } else if (proto.has_drop_tiering()) {
+ tableDesc.MutableTTLSettings()->SetUseTiering("");
+ }
+
if (!changed && !hadPartitionConfig) {
tableDesc.ClearPartitionConfig();
}
diff --git a/ydb/public/api/protos/draft/ydb_logstore.proto b/ydb/public/api/protos/draft/ydb_logstore.proto
index fafa42c361..8ad652f4c5 100644
--- a/ydb/public/api/protos/draft/ydb_logstore.proto
+++ b/ydb/public/api/protos/draft/ydb_logstore.proto
@@ -195,6 +195,7 @@ message AlterLogTableRequest {
google.protobuf.Empty drop_ttl_settings = 3;
Ydb.Table.TtlSettings set_ttl_settings = 4;
TieringSettings set_tiering_settings = 5;
+ google.protobuf.Empty drop_tiering_settings = 6;
}
}
diff --git a/ydb/public/api/protos/ydb_table.proto b/ydb/public/api/protos/ydb_table.proto
index 1d3c16daba..12e0c8918d 100644
--- a/ydb/public/api/protos/ydb_table.proto
+++ b/ydb/public/api/protos/ydb_table.proto
@@ -487,6 +487,8 @@ message CreateTableRequest {
Ydb.FeatureFlag.Status key_bloom_filter = 16;
// Read replicas settings for table
ReadReplicasSettings read_replicas_settings = 17;
+ // Tiering name for table
+ string tiering = 18;
}
message CreateTableResponse {
@@ -561,6 +563,11 @@ message AlterTableRequest {
repeated string drop_changefeeds = 20;
// Rename existed index
repeated RenameIndexItem rename_indexes = 21;
+ // Setup or remove tiering
+ oneof tiering_action {
+ string set_tiering = 22;
+ google.protobuf.Empty drop_tiering = 23;
+ }
}
message AlterTableResponse {