diff options
author | Nikolay Shumkov <shumkovnd@ydb.tech> | 2025-04-22 16:46:19 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-04-22 16:46:19 +0300 |
commit | a8d75678316f1e1c454160f76b3a626e63aebb5d (patch) | |
tree | 73e0bf2b2b7f65f9743cc5a8961dd429d700a2a6 | |
parent | 0c2eebe2fac8b653a1f9a3057308c1463977de6f (diff) | |
download | ydb-a8d75678316f1e1c454160f76b3a626e63aebb5d.tar.gz |
Support sequences in SHOW CREATE TABLE (#17488)
-rw-r--r-- | ydb/core/sys_view/show_create/create_table_formatter.cpp | 55 | ||||
-rw-r--r-- | ydb/core/sys_view/show_create/create_table_formatter.h | 12 | ||||
-rw-r--r-- | ydb/core/sys_view/show_create/show_create.cpp | 84 | ||||
-rw-r--r-- | ydb/core/sys_view/show_create/ya.make | 3 | ||||
-rw-r--r-- | ydb/core/sys_view/ut_kqp.cpp | 212 |
5 files changed, 351 insertions, 15 deletions
diff --git a/ydb/core/sys_view/show_create/create_table_formatter.cpp b/ydb/core/sys_view/show_create/create_table_formatter.cpp index 0c31db94c60..57faa5ac764 100644 --- a/ydb/core/sys_view/show_create/create_table_formatter.cpp +++ b/ydb/core/sys_view/show_create/create_table_formatter.cpp @@ -245,8 +245,9 @@ private: TStringStream& Stream; }; -TFormatResult TCreateTableFormatter::Format(const TString& tablePath, const NKikimrSchemeOp::TTableDescription& tableDesc, - bool temporary, const THashMap<TString, THolder<NKikimrSchemeOp::TPersQueueGroupDescription>>& persQueues) { +TFormatResult TCreateTableFormatter::Format(const TString& tablePath, const TString& fullPath, const NKikimrSchemeOp::TTableDescription& tableDesc, + bool temporary, const THashMap<TString, THolder<NKikimrSchemeOp::TPersQueueGroupDescription>>& persQueues, + const THashMap<TPathId, THolder<NSequenceProxy::TEvSequenceProxy::TEvGetSequenceResult>>& sequences) { Stream.Clear(); TStringStreamWrapper wrapper(Stream); @@ -411,8 +412,7 @@ TFormatResult TCreateTableFormatter::Format(const TString& tablePath, const NKik Y_ENSURE((ui32)tableDesc.GetCdcStreams().size() == persQueues.size()); auto firstColumnTypeId = columns[tableDesc.GetKeyColumnIds(0)]->GetTypeId(); try { - Format(tablePath, tableDesc.GetCdcStreams(0), persQueues, firstColumnTypeId); - for (int i = 1; i < tableDesc.GetCdcStreams().size(); i++) { + for (int i = 0; i < tableDesc.GetCdcStreams().size(); i++) { Format(tablePath, tableDesc.GetCdcStreams(i), persQueues, firstColumnTypeId); } } catch (const TFormatFail& ex) { @@ -422,6 +422,18 @@ TFormatResult TCreateTableFormatter::Format(const TString& tablePath, const NKik } } + if (!tableDesc.GetSequences().empty()) { + try { + for (int i = 0; i < tableDesc.GetSequences().size(); i++) { + Format(fullPath, tableDesc.GetSequences(i), sequences); + } + } catch (const TFormatFail& ex) { + return TFormatResult(ex.Status, ex.Error); + } catch (const yexception& e) { + return TFormatResult(Ydb::StatusIds::INTERNAL_ERROR, e.what()); + } + } + TString statement = Stream.Str(); TString formattedStatement; NYql::TIssues issues; @@ -1001,6 +1013,41 @@ void TCreateTableFormatter::Format(const TString& tablePath, const NKikimrScheme Stream << ");"; } +void TCreateTableFormatter::Format(const TString& tablePath, const NKikimrSchemeOp::TSequenceDescription& sequence, const THashMap<TPathId, THolder<NSequenceProxy::TEvSequenceProxy::TEvGetSequenceResult>>& sequences) { + auto it = sequences.find(TPathId::FromProto(sequence.GetPathId())); + if (it == sequences.end() || !it->second) { + ythrow TFormatFail(Ydb::StatusIds::INTERNAL_ERROR, "Unexpected sequence path id"); + } + const auto& getSequenceResult = *it->second; + + if (getSequenceResult.StartValue == 1 && getSequenceResult.Increment == 1 + && getSequenceResult.NextValue == 1) { + return; + } + + Stream << "ALTER SEQUENCE "; + auto sequencePath = JoinPath({tablePath, sequence.GetName()}); + EscapeName(sequencePath, Stream); + + if (getSequenceResult.StartValue != 1) { + Stream << " START WITH " << getSequenceResult.StartValue; + } + + if (getSequenceResult.Increment != 1) { + Stream << " INCREMENT BY " << getSequenceResult.Increment; + } + + if (getSequenceResult.NextValue != 1) { + if (getSequenceResult.NextValue == getSequenceResult.StartValue) { + Stream << " RESTART"; + } else { + Stream << " RESTART WITH " << getSequenceResult.NextValue; + } + } + + Stream << ";"; +} + TFormatResult TCreateTableFormatter::Format(const TString& tablePath, const TColumnTableDescription& tableDesc, bool temporary) { Stream.Clear(); diff --git a/ydb/core/sys_view/show_create/create_table_formatter.h b/ydb/core/sys_view/show_create/create_table_formatter.h index a6923514d30..e6b26a89871 100644 --- a/ydb/core/sys_view/show_create/create_table_formatter.h +++ b/ydb/core/sys_view/show_create/create_table_formatter.h @@ -2,13 +2,13 @@ #include "formatters_common.h" -#include <ydb/public/sdk/cpp/include/ydb-cpp-sdk/client/value/value.h> - #include <ydb/core/protos/flat_scheme_op.pb.h> - +#include <ydb/core/scheme/scheme_pathid.h> #include <ydb/core/tx/columnshard/engines/scheme/defaults/protos/data.pb.h> +#include <ydb/core/tx/sequenceproxy/public/events.h> #include <ydb/public/api/protos/ydb_table.pb.h> +#include <ydb/public/sdk/cpp/include/ydb-cpp-sdk/client/value/value.h> #include <yql/essentials/minikql/mkql_alloc.h> @@ -30,8 +30,9 @@ public: Alloc.Acquire(); } - TFormatResult Format(const TString& tablePath, const NKikimrSchemeOp::TTableDescription& tableDesc, bool temporary, - const THashMap<TString, THolder<NKikimrSchemeOp::TPersQueueGroupDescription>>& persQueues); + TFormatResult Format(const TString& tablePath, const TString& fullPath, const NKikimrSchemeOp::TTableDescription& tableDesc, bool temporary, + const THashMap<TString, THolder<NKikimrSchemeOp::TPersQueueGroupDescription>>& persQueues, + const THashMap<TPathId, THolder<NSequenceProxy::TEvSequenceProxy::TEvGetSequenceResult>>& sequences); TFormatResult Format(const TString& tablePath, const NKikimrSchemeOp::TColumnTableDescription& tableDesc, bool temporary); private: @@ -41,6 +42,7 @@ private: void Format(const TString& tablePath, const NKikimrSchemeOp::TCdcStreamDescription& cdcStream, const THashMap<TString, THolder<NKikimrSchemeOp::TPersQueueGroupDescription>>& persQueues, ui32 firstColumnTypeId); + void Format(const TString& fullTablePath, const NKikimrSchemeOp::TSequenceDescription& sequence, const THashMap<TPathId, THolder<NSequenceProxy::TEvSequenceProxy::TEvGetSequenceResult>>& sequences); void Format(const Ydb::Table::TableIndex& index); bool Format(const Ydb::Table::ExplicitPartitions& explicitPartitions, TString& del, bool needWith); diff --git a/ydb/core/sys_view/show_create/show_create.cpp b/ydb/core/sys_view/show_create/show_create.cpp index 9496ceb2ee5..06f70a86671 100644 --- a/ydb/core/sys_view/show_create/show_create.cpp +++ b/ydb/core/sys_view/show_create/show_create.cpp @@ -3,11 +3,12 @@ #include "show_create.h" #include <ydb/core/base/tablet_pipe.h> -#include <ydb/core/base/tablet_pipe.h> +#include <ydb/core/scheme/scheme_pathid.h> #include <ydb/core/sys_view/common/scan_actor_base_impl.h> #include <ydb/core/sys_view/common/schema.h> #include <ydb/core/tx/scheme_cache/scheme_cache.h> #include <ydb/core/tx/schemeshard/schemeshard.h> +#include <ydb/core/tx/sequenceproxy/public/events.h> #include <ydb/core/tx/tx_proxy/proxy.h> #include <ydb/library/actors/core/hfunc.h> @@ -79,6 +80,7 @@ public: STFUNC(StateCollectTableSettings) { switch (ev->GetTypeRewrite()) { hFunc(NSchemeShard::TEvSchemeShard::TEvDescribeSchemeResult, HandleCollectTableSettings); + hFunc(NSequenceProxy::TEvSequenceProxy::TEvGetSequenceResult, Handle); default: LOG_CRIT(*TlsActivationContext, NKikimrServices::SYSTEM_VIEWS, "NSysView::TScanActorBase: unexpected event 0x%08" PRIx32, ev->GetTypeRewrite()); @@ -169,6 +171,10 @@ private: } } + bool NeedToCollectTableSettings(const NKikimrSchemeOp::TTableDescription& tableDesc) { + return !tableDesc.GetCdcStreams().empty() || !tableDesc.GetSequences().empty(); + } + void StartCollectTableSettings(const TString& tablePath, const NKikimrSchemeOp::TTableDescription& tableDesc, bool temporary) { CollectTableSettingsState = MakeHolder<TCollectTableSettingsState>(); CollectTableSettingsState->TablePath = tablePath; @@ -196,6 +202,15 @@ private: Send(MakeTxProxyID(), navigateRequest.release()); } + + for (const auto& sequence: tableDesc.GetSequences()) { + auto sequencePathId = TPathId::FromProto(sequence.GetPathId()); + CollectTableSettingsState->Sequences[sequencePathId] = nullptr; + + Send(NSequenceProxy::MakeSequenceProxyServiceID(), + new NSequenceProxy::TEvSequenceProxy::TEvGetSequence(Database, sequencePathId) + ); + } } void FillBatch(NKqp::TEvKqpCompute::TEvScanData& batch, const TString& path, const TString& statement) { @@ -263,14 +278,14 @@ private: temporary = true; } - if (!tableDesc.GetCdcStreams().empty()) { + if (NeedToCollectTableSettings(tableDesc)) { StartCollectTableSettings(tablePath, tableDesc, temporary); Become(&TShowCreate::StateCollectTableSettings); return; } TCreateTableFormatter formatter; - auto formatterResult = formatter.Format(tablePath, tableDesc, temporary, {}); + auto formatterResult = formatter.Format(tablePath, Path, tableDesc, temporary, {}, {}); if (formatterResult.IsSuccess()) { path = tablePath; statement = formatterResult.ExtractOut(); @@ -385,16 +400,18 @@ private: it->second = MakeHolder<NKikimrSchemeOp::TPersQueueGroupDescription>(description); CollectTableSettingsState->CurrentPersQueuesNumber++; - if (CollectTableSettingsState->CurrentPersQueuesNumber != CollectTableSettingsState->PersQueues.size()) { + if (!CollectTableSettingsState->IsReady()) { return; } TCreateTableFormatter formatter; auto formatterResult = formatter.Format( CollectTableSettingsState->TablePath, + Path, CollectTableSettingsState->TableDescription, CollectTableSettingsState->Temporary, - CollectTableSettingsState->PersQueues + CollectTableSettingsState->PersQueues, + CollectTableSettingsState->Sequences ); if (formatterResult.IsSuccess()) { path = CollectTableSettingsState->TablePath; @@ -441,6 +458,57 @@ private: SendBatch(std::move(batch)); } + void Handle(NSequenceProxy::TEvSequenceProxy::TEvGetSequenceResult::TPtr& ev) { + if (ev->Get()->Status != Ydb::StatusIds::SUCCESS) { + ReplyErrorAndDie(ev->Get()->Status, ev->Get()->Issues.ToString()); + return; + } + + auto* msg = ev->Get(); + + auto it = CollectTableSettingsState->Sequences.find(msg->PathId); + if (it == CollectTableSettingsState->Sequences.end()) { + return ReplyErrorAndDie(Ydb::StatusIds::INTERNAL_ERROR, TStringBuilder() << "Unknown sequence path id: " << msg->PathId); + } + if (it->second) { + return ReplyErrorAndDie(Ydb::StatusIds::INTERNAL_ERROR, TStringBuilder() << "Found duplicate sequence path id: " << msg->PathId); + } + it->second = MakeHolder<NSequenceProxy::TEvSequenceProxy::TEvGetSequenceResult>(*msg); + CollectTableSettingsState->CurrentSequencesNumber++; + + if (!CollectTableSettingsState->IsReady()) { + return; + } + + TCreateTableFormatter formatter; + auto formatterResult = formatter.Format( + CollectTableSettingsState->TablePath, + Path, + CollectTableSettingsState->TableDescription, + CollectTableSettingsState->Temporary, + CollectTableSettingsState->PersQueues, + CollectTableSettingsState->Sequences + ); + std::optional<TString> path; + std::optional<TString> statement; + if (formatterResult.IsSuccess()) { + path = CollectTableSettingsState->TablePath; + statement = formatterResult.ExtractOut(); + } else { + ReplyErrorAndDie(formatterResult.GetStatus(), formatterResult.GetError()); + return; + } + + Y_ENSURE(path.has_value()); + Y_ENSURE(statement.has_value()); + + auto batch = MakeHolder<NKqp::TEvKqpCompute::TEvScanData>(ScanId); + + FillBatch(*batch, path.value(), statement.value()); + + SendBatch(std::move(batch)); + } + private: TString Database; TIntrusiveConstPtr<NACLib::TUserToken> UserToken; @@ -453,6 +521,12 @@ private: bool Temporary; THashMap<TString, THolder<NKikimrSchemeOp::TPersQueueGroupDescription>> PersQueues; ui32 CurrentPersQueuesNumber = 0; + THashMap<TPathId, THolder<NSequenceProxy::TEvSequenceProxy::TEvGetSequenceResult>> Sequences; + ui32 CurrentSequencesNumber = 0; + + bool IsReady() const { + return CurrentPersQueuesNumber == PersQueues.size() && CurrentSequencesNumber == Sequences.size(); + } }; THolder<TCollectTableSettingsState> CollectTableSettingsState; }; diff --git a/ydb/core/sys_view/show_create/ya.make b/ydb/core/sys_view/show_create/ya.make index 6cfe39634f2..44447775ada 100644 --- a/ydb/core/sys_view/show_create/ya.make +++ b/ydb/core/sys_view/show_create/ya.make @@ -11,9 +11,10 @@ PEERDIR( ydb/core/base ydb/core/kqp/runtime ydb/core/protos - ydb/core/tx/columnshard/engines/scheme/defaults/protos ydb/core/sys_view/common + ydb/core/tx/columnshard/engines/scheme/defaults/protos ydb/core/tx/schemeshard + ydb/core/tx/sequenceproxy ydb/core/tx/tx_proxy ydb/core/ydb_convert ydb/library/actors/core diff --git a/ydb/core/sys_view/ut_kqp.cpp b/ydb/core/sys_view/ut_kqp.cpp index 39bd52c7359..fbabed4bbdd 100644 --- a/ydb/core/sys_view/ut_kqp.cpp +++ b/ydb/core/sys_view/ut_kqp.cpp @@ -278,6 +278,7 @@ NKikimrSchemeOp::TPathDescription DescribePath(TTestActorRuntime& runtime, TStri request->Record.MutableDescribePath()->SetPath(path); request->Record.MutableDescribePath()->MutableOptions()->SetShowPrivateTable(true); request->Record.MutableDescribePath()->MutableOptions()->SetReturnBoundaries(true); + request->Record.MutableDescribePath()->MutableOptions()->SetReturnSetVal(true); runtime.Send(new IEventHandle(MakeTxProxyID(), sender, request.Release())); return runtime.GrabEdgeEventRethrow<NSchemeShard::TEvSchemeShard::TEvDescribeSchemeResult>(handle)->GetRecord().GetPathDescription(); } @@ -1539,6 +1540,121 @@ WITH ( ); )" ); + + checker.CheckShowCreateTable(R"( + CREATE TABLE test_show_create ( + Key1 Uint32, + Key2 BigSerial, + Key3 SmallSerial, + Value1 Serial, + Value2 String, + PRIMARY KEY (Key1, Key2, Key3) + ); + ALTER TABLE test_show_create + ADD CHANGEFEED `feed_1` WITH (MODE = 'OLD_IMAGE', FORMAT = 'DEBEZIUM_JSON', RETENTION_PERIOD = Interval("PT1H")); + ALTER TABLE test_show_create + ADD CHANGEFEED `feed_2` WITH (MODE = 'NEW_IMAGE', FORMAT = 'JSON', TOPIC_MIN_ACTIVE_PARTITIONS = 10, RETENTION_PERIOD = Interval("PT3H"), VIRTUAL_TIMESTAMPS = TRUE); + ALTER TABLE test_show_create + ADD CHANGEFEED `feed_3` WITH (MODE = 'KEYS_ONLY', TOPIC_MIN_ACTIVE_PARTITIONS = 3, FORMAT = 'JSON', RETENTION_PERIOD = Interval("PT30M")); + ALTER SEQUENCE IF EXISTS `/Root/test_show_create/_serial_column_Key2` + START WITH 150 + INCREMENT BY 300; + ALTER SEQUENCE IF EXISTS `/Root/test_show_create/_serial_column_Key2` + INCREMENT 1; + ALTER SEQUENCE IF EXISTS `/Root/test_show_create/_serial_column_Key3` + RESTART WITH 5; + ALTER SEQUENCE IF EXISTS `/Root/test_show_create/_serial_column_Value1` + START WITH 101; + ALTER SEQUENCE IF EXISTS `/Root/test_show_create/_serial_column_Value1` + INCREMENT 404 + RESTART; + )", "test_show_create", +R"(CREATE TABLE `test_show_create` ( + `Key1` Uint32, + `Key2` Serial8 NOT NULL, + `Key3` Serial2 NOT NULL, + `Value1` Serial4 NOT NULL, + `Value2` String, + PRIMARY KEY (`Key1`, `Key2`, `Key3`) +); + +ALTER TABLE `test_show_create` + ADD CHANGEFEED `feed_1` WITH (MODE = 'OLD_IMAGE', FORMAT = 'DEBEZIUM_JSON', RETENTION_PERIOD = INTERVAL('PT1H'), TOPIC_MIN_ACTIVE_PARTITIONS = 1) +; + +ALTER TABLE `test_show_create` + ADD CHANGEFEED `feed_2` WITH (MODE = 'NEW_IMAGE', FORMAT = 'JSON', VIRTUAL_TIMESTAMPS = TRUE, RETENTION_PERIOD = INTERVAL('PT3H'), TOPIC_MIN_ACTIVE_PARTITIONS = 10) +; + +ALTER TABLE `test_show_create` + ADD CHANGEFEED `feed_3` WITH (MODE = 'KEYS_ONLY', FORMAT = 'JSON', RETENTION_PERIOD = INTERVAL('PT30M'), TOPIC_MIN_ACTIVE_PARTITIONS = 3) +; + +ALTER SEQUENCE `/Root/test_show_create/_serial_column_Key2` START WITH 150; + +ALTER SEQUENCE `/Root/test_show_create/_serial_column_Key3` RESTART WITH 5; + +ALTER SEQUENCE `/Root/test_show_create/_serial_column_Value1` START WITH 101 INCREMENT BY 404 RESTART; +)" + ); + + checker.CheckShowCreateTable(R"( + CREATE TABLE test_show_create ( + Key1 BigSerial, + Key2 SmallSerial, + Value1 Serial, + Value2 String, + PRIMARY KEY (Key1, Key2) + ) WITH ( + AUTO_PARTITIONING_BY_LOAD = ENABLED, + PARTITION_AT_KEYS = ((10), (100, 1000), (1000, 20)) + ); + ALTER TABLE test_show_create ADD CHANGEFEED `feed1` WITH ( + MODE = 'KEYS_ONLY', FORMAT = 'JSON', RETENTION_PERIOD = Interval("PT1H") + ); + ALTER TABLE test_show_create ADD CHANGEFEED `feed2` WITH ( + MODE = 'KEYS_ONLY', FORMAT = 'JSON', RETENTION_PERIOD = Interval("PT2H") + ); + ALTER SEQUENCE IF EXISTS `/Root/test_show_create/_serial_column_Key1` + START WITH 150 + INCREMENT BY 300; + ALTER SEQUENCE IF EXISTS `/Root/test_show_create/_serial_column_Key1` + INCREMENT 1; + ALTER SEQUENCE IF EXISTS `/Root/test_show_create/_serial_column_Key2` + RESTART WITH 5; + ALTER SEQUENCE IF EXISTS `/Root/test_show_create/_serial_column_Value1` + START WITH 101; + ALTER SEQUENCE IF EXISTS `/Root/test_show_create/_serial_column_Value1` + INCREMENT 404 + RESTART; + )", "test_show_create", +R"(CREATE TABLE `test_show_create` ( + `Key1` Serial8 NOT NULL, + `Key2` Serial2 NOT NULL, + `Value1` Serial4 NOT NULL, + `Value2` String, + PRIMARY KEY (`Key1`, `Key2`) +) +WITH ( + AUTO_PARTITIONING_BY_LOAD = ENABLED, + PARTITION_AT_KEYS = ((10), (100, 1000), (1000, 20)) +); + +ALTER TABLE `test_show_create` + ADD CHANGEFEED `feed1` WITH (MODE = 'KEYS_ONLY', FORMAT = 'JSON', RETENTION_PERIOD = INTERVAL('PT1H')) +; + +ALTER TABLE `test_show_create` + ADD CHANGEFEED `feed2` WITH (MODE = 'KEYS_ONLY', FORMAT = 'JSON', RETENTION_PERIOD = INTERVAL('PT2H')) +; + +ALTER SEQUENCE `/Root/test_show_create/_serial_column_Key1` START WITH 150; + +ALTER SEQUENCE `/Root/test_show_create/_serial_column_Key2` RESTART WITH 5; + +ALTER SEQUENCE `/Root/test_show_create/_serial_column_Value1` START WITH 101 INCREMENT BY 404 RESTART; +)" + ); } Y_UNIT_TEST(ShowCreateTableChangefeeds) { @@ -1656,6 +1772,102 @@ ALTER TABLE `test_show_create` ); } + Y_UNIT_TEST(ShowCreateTableSequences) { + TTestEnv env(1, 4, {.StoragePools = 3, .ShowCreateTable = true}); + + env.GetServer().GetRuntime()->SetLogPriority(NKikimrServices::KQP_EXECUTER, NActors::NLog::PRI_DEBUG); + env.GetServer().GetRuntime()->SetLogPriority(NKikimrServices::KQP_COMPILE_SERVICE, NActors::NLog::PRI_DEBUG); + env.GetServer().GetRuntime()->SetLogPriority(NKikimrServices::KQP_YQL, NActors::NLog::PRI_TRACE); + env.GetServer().GetRuntime()->SetLogPriority(NKikimrServices::SYSTEM_VIEWS, NActors::NLog::PRI_DEBUG); + + TShowCreateChecker checker(env); + + checker.CheckShowCreateTable(R"( + CREATE TABLE test_show_create ( + Key Serial, + Value String, + PRIMARY KEY (Key) + ); + ALTER SEQUENCE IF EXISTS `/Root/test_show_create/_serial_column_Key` + START 50 + INCREMENT BY 11; + ALTER SEQUENCE IF EXISTS `/Root/test_show_create/_serial_column_Key` + RESTART; + )", "test_show_create", +R"(CREATE TABLE `test_show_create` ( + `Key` Serial4 NOT NULL, + `Value` String, + PRIMARY KEY (`Key`) +); + +ALTER SEQUENCE `/Root/test_show_create/_serial_column_Key` START WITH 50 INCREMENT BY 11 RESTART; +)" + ); + + checker.CheckShowCreateTable(R"( + CREATE TABLE test_show_create ( + Key1 BigSerial, + Key2 SmallSerial, + Value String, + PRIMARY KEY (Key1, Key2) + ); + ALTER SEQUENCE IF EXISTS `/Root/test_show_create/_serial_column_Key1` + START WITH 50 + INCREMENT BY 11; + ALTER SEQUENCE IF EXISTS `/Root/test_show_create/_serial_column_Key2` + RESTART WITH 5; + )", "test_show_create", +R"(CREATE TABLE `test_show_create` ( + `Key1` Serial8 NOT NULL, + `Key2` Serial2 NOT NULL, + `Value` String, + PRIMARY KEY (`Key1`, `Key2`) +); + +ALTER SEQUENCE `/Root/test_show_create/_serial_column_Key1` START WITH 50 INCREMENT BY 11; + +ALTER SEQUENCE `/Root/test_show_create/_serial_column_Key2` RESTART WITH 5; +)" + ); + + checker.CheckShowCreateTable(R"( + CREATE TABLE test_show_create ( + Key1 BigSerial, + Key2 SmallSerial, + Value1 Serial, + Value2 String, + PRIMARY KEY (Key1, Key2) + ); + ALTER SEQUENCE IF EXISTS `/Root/test_show_create/_serial_column_Key1` + START WITH 150 + INCREMENT BY 300; + ALTER SEQUENCE IF EXISTS `/Root/test_show_create/_serial_column_Key1` + INCREMENT 1; + ALTER SEQUENCE IF EXISTS `/Root/test_show_create/_serial_column_Key2` + RESTART WITH 5; + ALTER SEQUENCE IF EXISTS `/Root/test_show_create/_serial_column_Value1` + START WITH 101; + ALTER SEQUENCE IF EXISTS `/Root/test_show_create/_serial_column_Value1` + INCREMENT 404 + RESTART; + )", "test_show_create", +R"(CREATE TABLE `test_show_create` ( + `Key1` Serial8 NOT NULL, + `Key2` Serial2 NOT NULL, + `Value1` Serial4 NOT NULL, + `Value2` String, + PRIMARY KEY (`Key1`, `Key2`) +); + +ALTER SEQUENCE `/Root/test_show_create/_serial_column_Key1` START WITH 150; + +ALTER SEQUENCE `/Root/test_show_create/_serial_column_Key2` RESTART WITH 5; + +ALTER SEQUENCE `/Root/test_show_create/_serial_column_Value1` START WITH 101 INCREMENT BY 404 RESTART; +)" + ); + } + Y_UNIT_TEST(Nodes) { TTestEnv env; CreateTenantsAndTables(env, false); |