aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorivanmorozov <ivanmorozov@yandex-team.com>2023-05-18 20:15:59 +0300
committerivanmorozov <ivanmorozov@yandex-team.com>2023-05-18 20:15:59 +0300
commitbdfcb0ca2201b52b66cc45d813d287f09a9f9ff3 (patch)
tree03218d63619be1f79fc962f7c62092685dd09181
parente0c1710b48e53c8c3ed210d7f5895a5a7ff1fbcb (diff)
downloadydb-bdfcb0ca2201b52b66cc45d813d287f09a9f9ff3.tar.gz
split files before alter table class implementation
-rw-r--r--ydb/core/kqp/gateway/behaviour/tablestore/CMakeLists.darwin-x86_64.txt3
-rw-r--r--ydb/core/kqp/gateway/behaviour/tablestore/CMakeLists.linux-aarch64.txt3
-rw-r--r--ydb/core/kqp/gateway/behaviour/tablestore/CMakeLists.linux-x86_64.txt3
-rw-r--r--ydb/core/kqp/gateway/behaviour/tablestore/CMakeLists.windows-x86_64.txt3
-rw-r--r--ydb/core/kqp/gateway/behaviour/tablestore/manager.cpp90
-rw-r--r--ydb/core/kqp/gateway/behaviour/tablestore/operations/CMakeLists.darwin-x86_64.txt36
-rw-r--r--ydb/core/kqp/gateway/behaviour/tablestore/operations/CMakeLists.linux-aarch64.txt38
-rw-r--r--ydb/core/kqp/gateway/behaviour/tablestore/operations/CMakeLists.linux-x86_64.txt38
-rw-r--r--ydb/core/kqp/gateway/behaviour/tablestore/operations/CMakeLists.txt17
-rw-r--r--ydb/core/kqp/gateway/behaviour/tablestore/operations/CMakeLists.windows-x86_64.txt36
-rw-r--r--ydb/core/kqp/gateway/behaviour/tablestore/operations/abstract.cpp36
-rw-r--r--ydb/core/kqp/gateway/behaviour/tablestore/operations/abstract.h26
-rw-r--r--ydb/core/kqp/gateway/behaviour/tablestore/operations/add_column.cpp38
-rw-r--r--ydb/core/kqp/gateway/behaviour/tablestore/operations/add_column.h22
14 files changed, 300 insertions, 89 deletions
diff --git a/ydb/core/kqp/gateway/behaviour/tablestore/CMakeLists.darwin-x86_64.txt b/ydb/core/kqp/gateway/behaviour/tablestore/CMakeLists.darwin-x86_64.txt
index a862f0f2eb8..d0b25045422 100644
--- a/ydb/core/kqp/gateway/behaviour/tablestore/CMakeLists.darwin-x86_64.txt
+++ b/ydb/core/kqp/gateway/behaviour/tablestore/CMakeLists.darwin-x86_64.txt
@@ -6,6 +6,7 @@
# original buildsystem will not be accepted.
+add_subdirectory(operations)
add_library(gateway-behaviour-tablestore)
target_compile_options(gateway-behaviour-tablestore PRIVATE
@@ -17,6 +18,7 @@ target_link_libraries(gateway-behaviour-tablestore PUBLIC
services-metadata-initializer
services-metadata-abstract
kqp-gateway-actors
+ behaviour-tablestore-operations
)
target_sources(gateway-behaviour-tablestore PRIVATE
${CMAKE_SOURCE_DIR}/ydb/core/kqp/gateway/behaviour/tablestore/manager.cpp
@@ -33,6 +35,7 @@ target_link_libraries(gateway-behaviour-tablestore.global PUBLIC
services-metadata-initializer
services-metadata-abstract
kqp-gateway-actors
+ behaviour-tablestore-operations
)
target_sources(gateway-behaviour-tablestore.global PRIVATE
${CMAKE_SOURCE_DIR}/ydb/core/kqp/gateway/behaviour/tablestore/behaviour.cpp
diff --git a/ydb/core/kqp/gateway/behaviour/tablestore/CMakeLists.linux-aarch64.txt b/ydb/core/kqp/gateway/behaviour/tablestore/CMakeLists.linux-aarch64.txt
index fc9dbc33c78..a9b44237faf 100644
--- a/ydb/core/kqp/gateway/behaviour/tablestore/CMakeLists.linux-aarch64.txt
+++ b/ydb/core/kqp/gateway/behaviour/tablestore/CMakeLists.linux-aarch64.txt
@@ -6,6 +6,7 @@
# original buildsystem will not be accepted.
+add_subdirectory(operations)
add_library(gateway-behaviour-tablestore)
target_compile_options(gateway-behaviour-tablestore PRIVATE
@@ -18,6 +19,7 @@ target_link_libraries(gateway-behaviour-tablestore PUBLIC
services-metadata-initializer
services-metadata-abstract
kqp-gateway-actors
+ behaviour-tablestore-operations
)
target_sources(gateway-behaviour-tablestore PRIVATE
${CMAKE_SOURCE_DIR}/ydb/core/kqp/gateway/behaviour/tablestore/manager.cpp
@@ -35,6 +37,7 @@ target_link_libraries(gateway-behaviour-tablestore.global PUBLIC
services-metadata-initializer
services-metadata-abstract
kqp-gateway-actors
+ behaviour-tablestore-operations
)
target_sources(gateway-behaviour-tablestore.global PRIVATE
${CMAKE_SOURCE_DIR}/ydb/core/kqp/gateway/behaviour/tablestore/behaviour.cpp
diff --git a/ydb/core/kqp/gateway/behaviour/tablestore/CMakeLists.linux-x86_64.txt b/ydb/core/kqp/gateway/behaviour/tablestore/CMakeLists.linux-x86_64.txt
index fc9dbc33c78..a9b44237faf 100644
--- a/ydb/core/kqp/gateway/behaviour/tablestore/CMakeLists.linux-x86_64.txt
+++ b/ydb/core/kqp/gateway/behaviour/tablestore/CMakeLists.linux-x86_64.txt
@@ -6,6 +6,7 @@
# original buildsystem will not be accepted.
+add_subdirectory(operations)
add_library(gateway-behaviour-tablestore)
target_compile_options(gateway-behaviour-tablestore PRIVATE
@@ -18,6 +19,7 @@ target_link_libraries(gateway-behaviour-tablestore PUBLIC
services-metadata-initializer
services-metadata-abstract
kqp-gateway-actors
+ behaviour-tablestore-operations
)
target_sources(gateway-behaviour-tablestore PRIVATE
${CMAKE_SOURCE_DIR}/ydb/core/kqp/gateway/behaviour/tablestore/manager.cpp
@@ -35,6 +37,7 @@ target_link_libraries(gateway-behaviour-tablestore.global PUBLIC
services-metadata-initializer
services-metadata-abstract
kqp-gateway-actors
+ behaviour-tablestore-operations
)
target_sources(gateway-behaviour-tablestore.global PRIVATE
${CMAKE_SOURCE_DIR}/ydb/core/kqp/gateway/behaviour/tablestore/behaviour.cpp
diff --git a/ydb/core/kqp/gateway/behaviour/tablestore/CMakeLists.windows-x86_64.txt b/ydb/core/kqp/gateway/behaviour/tablestore/CMakeLists.windows-x86_64.txt
index a862f0f2eb8..d0b25045422 100644
--- a/ydb/core/kqp/gateway/behaviour/tablestore/CMakeLists.windows-x86_64.txt
+++ b/ydb/core/kqp/gateway/behaviour/tablestore/CMakeLists.windows-x86_64.txt
@@ -6,6 +6,7 @@
# original buildsystem will not be accepted.
+add_subdirectory(operations)
add_library(gateway-behaviour-tablestore)
target_compile_options(gateway-behaviour-tablestore PRIVATE
@@ -17,6 +18,7 @@ target_link_libraries(gateway-behaviour-tablestore PUBLIC
services-metadata-initializer
services-metadata-abstract
kqp-gateway-actors
+ behaviour-tablestore-operations
)
target_sources(gateway-behaviour-tablestore PRIVATE
${CMAKE_SOURCE_DIR}/ydb/core/kqp/gateway/behaviour/tablestore/manager.cpp
@@ -33,6 +35,7 @@ target_link_libraries(gateway-behaviour-tablestore.global PUBLIC
services-metadata-initializer
services-metadata-abstract
kqp-gateway-actors
+ behaviour-tablestore-operations
)
target_sources(gateway-behaviour-tablestore.global PRIVATE
${CMAKE_SOURCE_DIR}/ydb/core/kqp/gateway/behaviour/tablestore/behaviour.cpp
diff --git a/ydb/core/kqp/gateway/behaviour/tablestore/manager.cpp b/ydb/core/kqp/gateway/behaviour/tablestore/manager.cpp
index 564ea5d584a..600d85e7a0c 100644
--- a/ydb/core/kqp/gateway/behaviour/tablestore/manager.cpp
+++ b/ydb/core/kqp/gateway/behaviour/tablestore/manager.cpp
@@ -1,5 +1,6 @@
#include "behaviour.h"
#include "manager.h"
+#include "operations/abstract.h"
#include <ydb/core/tx/tx_proxy/proxy.h>
#include <ydb/core/kqp/gateway/actors/scheme.h>
@@ -10,95 +11,6 @@
namespace NKikimr::NKqp {
-class ITableStoreOperation {
-public:
- using TFactory = NObjectFactory::TObjectFactory<ITableStoreOperation, TString>;
- using TPtr = std::shared_ptr<ITableStoreOperation>;
-private:
- TString PresetName = "default";
- TString WorkingDir;
- TString StoreName;
-public:
- virtual ~ITableStoreOperation() {};
-
- NMetadata::NModifications::TObjectOperatorResult Deserialize(const NYql::TObjectSettingsImpl& settings) {
- std::pair<TString, TString> pathPair;
- {
- TString error;
- if (!NYql::IKikimrGateway::TrySplitTablePath(settings.GetObjectId(), pathPair, error)) {
- return NMetadata::NModifications::TObjectOperatorResult(error);
- }
- WorkingDir = pathPair.first;
- StoreName = pathPair.second;
- }
- {
- auto it = settings.GetFeatures().find("PRESET_NAME");
- if (it != settings.GetFeatures().end()) {
- PresetName = it->second;
- }
- }
- return DoDeserialize(settings.GetFeatures());
- }
-
- void SerializeScheme(NKikimrSchemeOp::TModifyScheme& scheme) const {
- scheme.SetWorkingDir(WorkingDir);
- scheme.SetOperationType(NKikimrSchemeOp::ESchemeOpAlterColumnStore);
-
- NKikimrSchemeOp::TAlterColumnStore* alter = scheme.MutableAlterColumnStore();
- alter->SetName(StoreName);
- auto schemaPresetObject = alter->AddAlterSchemaPresets();
- schemaPresetObject->SetName(PresetName);
- return DoSerializeScheme(*schemaPresetObject);
- }
-private:
- virtual NMetadata::NModifications::TObjectOperatorResult DoDeserialize(const NYql::TObjectSettingsImpl::TFeatures& features) = 0;
- virtual void DoSerializeScheme(NKikimrSchemeOp::TAlterColumnTableSchemaPreset& scheme) const = 0;
-};
-
-class TAddColumnOperation : public ITableStoreOperation {
- static TString GetTypeName() {
- return "NEW_COLUMN";
- }
-
- static inline auto Registrator = TFactory::TRegistrator<TAddColumnOperation>(GetTypeName());
-private:
- TString ColumnName;
- TString ColumnType;
- bool NotNull = false;
-public:
- NMetadata::NModifications::TObjectOperatorResult DoDeserialize(const NYql::TObjectSettingsImpl::TFeatures& features) override {
- {
- auto it = features.find("NAME");
- if (it == features.end()) {
- return NMetadata::NModifications::TObjectOperatorResult("can't find alter parameter NAME");
- }
- ColumnName = it->second;
- }
- {
- auto it = features.find("TYPE");
- if (it == features.end()) {
- return NMetadata::NModifications::TObjectOperatorResult("can't find alter parameter TYPE");
- }
- ColumnType = it->second;
- }
- {
- auto it = features.find("NOT_NULL");
- if (it != features.end()) {
- NotNull = IsTrue(it->second);
- }
- }
- return NMetadata::NModifications::TObjectOperatorResult(true);
- }
-
- void DoSerializeScheme(NKikimrSchemeOp::TAlterColumnTableSchemaPreset& presetProto) const override {
- auto schemaData = presetProto.MutableAlterSchema();
- auto column = schemaData->AddColumns();
- column->SetName(ColumnName);
- column->SetType(ColumnType);
- column->SetNotNull(NotNull);
- }
-};
-
NThreading::TFuture<NMetadata::NModifications::TObjectOperatorResult> TTableStoreManager::DoModify(const NYql::TObjectSettingsImpl& settings, const ui32 nodeId,
NMetadata::IClassBehaviour::TPtr manager, TInternalModificationContext& context) const {
Y_UNUSED(nodeId);
diff --git a/ydb/core/kqp/gateway/behaviour/tablestore/operations/CMakeLists.darwin-x86_64.txt b/ydb/core/kqp/gateway/behaviour/tablestore/operations/CMakeLists.darwin-x86_64.txt
new file mode 100644
index 00000000000..d725083cc3b
--- /dev/null
+++ b/ydb/core/kqp/gateway/behaviour/tablestore/operations/CMakeLists.darwin-x86_64.txt
@@ -0,0 +1,36 @@
+
+# This file was generated by the build system used internally in the Yandex monorepo.
+# Only simple modifications are allowed (adding source-files to targets, adding simple properties
+# like target_include_directories). These modifications will be ported to original
+# ya.make files by maintainers. Any complex modifications which can't be ported back to the
+# original buildsystem will not be accepted.
+
+
+
+add_library(behaviour-tablestore-operations)
+target_compile_options(behaviour-tablestore-operations PRIVATE
+ -DUSE_CURRENT_UDF_ABI_VERSION
+)
+target_link_libraries(behaviour-tablestore-operations PUBLIC
+ contrib-libs-cxxsupp
+ yutil
+ services-metadata-manager
+ ydb-core-protos
+)
+target_sources(behaviour-tablestore-operations PRIVATE
+ ${CMAKE_SOURCE_DIR}/ydb/core/kqp/gateway/behaviour/tablestore/operations/abstract.cpp
+)
+
+add_global_library_for(behaviour-tablestore-operations.global behaviour-tablestore-operations)
+target_compile_options(behaviour-tablestore-operations.global PRIVATE
+ -DUSE_CURRENT_UDF_ABI_VERSION
+)
+target_link_libraries(behaviour-tablestore-operations.global PUBLIC
+ contrib-libs-cxxsupp
+ yutil
+ services-metadata-manager
+ ydb-core-protos
+)
+target_sources(behaviour-tablestore-operations.global PRIVATE
+ ${CMAKE_SOURCE_DIR}/ydb/core/kqp/gateway/behaviour/tablestore/operations/add_column.cpp
+)
diff --git a/ydb/core/kqp/gateway/behaviour/tablestore/operations/CMakeLists.linux-aarch64.txt b/ydb/core/kqp/gateway/behaviour/tablestore/operations/CMakeLists.linux-aarch64.txt
new file mode 100644
index 00000000000..773b452e339
--- /dev/null
+++ b/ydb/core/kqp/gateway/behaviour/tablestore/operations/CMakeLists.linux-aarch64.txt
@@ -0,0 +1,38 @@
+
+# This file was generated by the build system used internally in the Yandex monorepo.
+# Only simple modifications are allowed (adding source-files to targets, adding simple properties
+# like target_include_directories). These modifications will be ported to original
+# ya.make files by maintainers. Any complex modifications which can't be ported back to the
+# original buildsystem will not be accepted.
+
+
+
+add_library(behaviour-tablestore-operations)
+target_compile_options(behaviour-tablestore-operations PRIVATE
+ -DUSE_CURRENT_UDF_ABI_VERSION
+)
+target_link_libraries(behaviour-tablestore-operations PUBLIC
+ contrib-libs-linux-headers
+ contrib-libs-cxxsupp
+ yutil
+ services-metadata-manager
+ ydb-core-protos
+)
+target_sources(behaviour-tablestore-operations PRIVATE
+ ${CMAKE_SOURCE_DIR}/ydb/core/kqp/gateway/behaviour/tablestore/operations/abstract.cpp
+)
+
+add_global_library_for(behaviour-tablestore-operations.global behaviour-tablestore-operations)
+target_compile_options(behaviour-tablestore-operations.global PRIVATE
+ -DUSE_CURRENT_UDF_ABI_VERSION
+)
+target_link_libraries(behaviour-tablestore-operations.global PUBLIC
+ contrib-libs-linux-headers
+ contrib-libs-cxxsupp
+ yutil
+ services-metadata-manager
+ ydb-core-protos
+)
+target_sources(behaviour-tablestore-operations.global PRIVATE
+ ${CMAKE_SOURCE_DIR}/ydb/core/kqp/gateway/behaviour/tablestore/operations/add_column.cpp
+)
diff --git a/ydb/core/kqp/gateway/behaviour/tablestore/operations/CMakeLists.linux-x86_64.txt b/ydb/core/kqp/gateway/behaviour/tablestore/operations/CMakeLists.linux-x86_64.txt
new file mode 100644
index 00000000000..773b452e339
--- /dev/null
+++ b/ydb/core/kqp/gateway/behaviour/tablestore/operations/CMakeLists.linux-x86_64.txt
@@ -0,0 +1,38 @@
+
+# This file was generated by the build system used internally in the Yandex monorepo.
+# Only simple modifications are allowed (adding source-files to targets, adding simple properties
+# like target_include_directories). These modifications will be ported to original
+# ya.make files by maintainers. Any complex modifications which can't be ported back to the
+# original buildsystem will not be accepted.
+
+
+
+add_library(behaviour-tablestore-operations)
+target_compile_options(behaviour-tablestore-operations PRIVATE
+ -DUSE_CURRENT_UDF_ABI_VERSION
+)
+target_link_libraries(behaviour-tablestore-operations PUBLIC
+ contrib-libs-linux-headers
+ contrib-libs-cxxsupp
+ yutil
+ services-metadata-manager
+ ydb-core-protos
+)
+target_sources(behaviour-tablestore-operations PRIVATE
+ ${CMAKE_SOURCE_DIR}/ydb/core/kqp/gateway/behaviour/tablestore/operations/abstract.cpp
+)
+
+add_global_library_for(behaviour-tablestore-operations.global behaviour-tablestore-operations)
+target_compile_options(behaviour-tablestore-operations.global PRIVATE
+ -DUSE_CURRENT_UDF_ABI_VERSION
+)
+target_link_libraries(behaviour-tablestore-operations.global PUBLIC
+ contrib-libs-linux-headers
+ contrib-libs-cxxsupp
+ yutil
+ services-metadata-manager
+ ydb-core-protos
+)
+target_sources(behaviour-tablestore-operations.global PRIVATE
+ ${CMAKE_SOURCE_DIR}/ydb/core/kqp/gateway/behaviour/tablestore/operations/add_column.cpp
+)
diff --git a/ydb/core/kqp/gateway/behaviour/tablestore/operations/CMakeLists.txt b/ydb/core/kqp/gateway/behaviour/tablestore/operations/CMakeLists.txt
new file mode 100644
index 00000000000..f8b31df0c11
--- /dev/null
+++ b/ydb/core/kqp/gateway/behaviour/tablestore/operations/CMakeLists.txt
@@ -0,0 +1,17 @@
+
+# This file was generated by the build system used internally in the Yandex monorepo.
+# Only simple modifications are allowed (adding source-files to targets, adding simple properties
+# like target_include_directories). These modifications will be ported to original
+# ya.make files by maintainers. Any complex modifications which can't be ported back to the
+# original buildsystem will not be accepted.
+
+
+if (CMAKE_SYSTEM_NAME STREQUAL "Linux" AND CMAKE_SYSTEM_PROCESSOR STREQUAL "aarch64" AND NOT HAVE_CUDA)
+ include(CMakeLists.linux-aarch64.txt)
+elseif (CMAKE_SYSTEM_NAME STREQUAL "Darwin" AND CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64")
+ include(CMakeLists.darwin-x86_64.txt)
+elseif (WIN32 AND CMAKE_SYSTEM_PROCESSOR STREQUAL "AMD64" AND NOT HAVE_CUDA)
+ include(CMakeLists.windows-x86_64.txt)
+elseif (CMAKE_SYSTEM_NAME STREQUAL "Linux" AND CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64" AND NOT HAVE_CUDA)
+ include(CMakeLists.linux-x86_64.txt)
+endif()
diff --git a/ydb/core/kqp/gateway/behaviour/tablestore/operations/CMakeLists.windows-x86_64.txt b/ydb/core/kqp/gateway/behaviour/tablestore/operations/CMakeLists.windows-x86_64.txt
new file mode 100644
index 00000000000..d725083cc3b
--- /dev/null
+++ b/ydb/core/kqp/gateway/behaviour/tablestore/operations/CMakeLists.windows-x86_64.txt
@@ -0,0 +1,36 @@
+
+# This file was generated by the build system used internally in the Yandex monorepo.
+# Only simple modifications are allowed (adding source-files to targets, adding simple properties
+# like target_include_directories). These modifications will be ported to original
+# ya.make files by maintainers. Any complex modifications which can't be ported back to the
+# original buildsystem will not be accepted.
+
+
+
+add_library(behaviour-tablestore-operations)
+target_compile_options(behaviour-tablestore-operations PRIVATE
+ -DUSE_CURRENT_UDF_ABI_VERSION
+)
+target_link_libraries(behaviour-tablestore-operations PUBLIC
+ contrib-libs-cxxsupp
+ yutil
+ services-metadata-manager
+ ydb-core-protos
+)
+target_sources(behaviour-tablestore-operations PRIVATE
+ ${CMAKE_SOURCE_DIR}/ydb/core/kqp/gateway/behaviour/tablestore/operations/abstract.cpp
+)
+
+add_global_library_for(behaviour-tablestore-operations.global behaviour-tablestore-operations)
+target_compile_options(behaviour-tablestore-operations.global PRIVATE
+ -DUSE_CURRENT_UDF_ABI_VERSION
+)
+target_link_libraries(behaviour-tablestore-operations.global PUBLIC
+ contrib-libs-cxxsupp
+ yutil
+ services-metadata-manager
+ ydb-core-protos
+)
+target_sources(behaviour-tablestore-operations.global PRIVATE
+ ${CMAKE_SOURCE_DIR}/ydb/core/kqp/gateway/behaviour/tablestore/operations/add_column.cpp
+)
diff --git a/ydb/core/kqp/gateway/behaviour/tablestore/operations/abstract.cpp b/ydb/core/kqp/gateway/behaviour/tablestore/operations/abstract.cpp
new file mode 100644
index 00000000000..e57de2e38a3
--- /dev/null
+++ b/ydb/core/kqp/gateway/behaviour/tablestore/operations/abstract.cpp
@@ -0,0 +1,36 @@
+#include "abstract.h"
+#include <ydb/core/kqp/provider/yql_kikimr_gateway.h>
+
+namespace NKikimr::NKqp {
+
+NKikimr::NMetadata::NModifications::TObjectOperatorResult ITableStoreOperation::Deserialize(const NYql::TObjectSettingsImpl& settings) {
+ std::pair<TString, TString> pathPair;
+ {
+ TString error;
+ if (!NYql::IKikimrGateway::TrySplitTablePath(settings.GetObjectId(), pathPair, error)) {
+ return NMetadata::NModifications::TObjectOperatorResult(error);
+ }
+ WorkingDir = pathPair.first;
+ StoreName = pathPair.second;
+ }
+ {
+ auto it = settings.GetFeatures().find("PRESET_NAME");
+ if (it != settings.GetFeatures().end()) {
+ PresetName = it->second;
+ }
+ }
+ return DoDeserialize(settings.GetFeatures());
+}
+
+void ITableStoreOperation::SerializeScheme(NKikimrSchemeOp::TModifyScheme& scheme) const {
+ scheme.SetWorkingDir(WorkingDir);
+ scheme.SetOperationType(NKikimrSchemeOp::ESchemeOpAlterColumnStore);
+
+ NKikimrSchemeOp::TAlterColumnStore* alter = scheme.MutableAlterColumnStore();
+ alter->SetName(StoreName);
+ auto schemaPresetObject = alter->AddAlterSchemaPresets();
+ schemaPresetObject->SetName(PresetName);
+ return DoSerializeScheme(*schemaPresetObject);
+}
+
+}
diff --git a/ydb/core/kqp/gateway/behaviour/tablestore/operations/abstract.h b/ydb/core/kqp/gateway/behaviour/tablestore/operations/abstract.h
new file mode 100644
index 00000000000..c0ee04c1fee
--- /dev/null
+++ b/ydb/core/kqp/gateway/behaviour/tablestore/operations/abstract.h
@@ -0,0 +1,26 @@
+#include <library/cpp/object_factory/object_factory.h>
+#include <ydb/services/metadata/manager/abstract.h>
+#include <ydb/core/protos/flat_scheme_op.pb.h>
+namespace NKikimr::NKqp {
+
+class ITableStoreOperation {
+public:
+ using TFactory = NObjectFactory::TObjectFactory<ITableStoreOperation, TString>;
+ using TPtr = std::shared_ptr<ITableStoreOperation>;
+private:
+ TString PresetName = "default";
+ TString WorkingDir;
+ TString StoreName;
+public:
+ virtual ~ITableStoreOperation() {};
+
+ NMetadata::NModifications::TObjectOperatorResult Deserialize(const NYql::TObjectSettingsImpl& settings);
+
+ void SerializeScheme(NKikimrSchemeOp::TModifyScheme& scheme) const;
+private:
+ virtual NMetadata::NModifications::TObjectOperatorResult DoDeserialize(const NYql::TObjectSettingsImpl::TFeatures& features) = 0;
+ virtual void DoSerializeScheme(NKikimrSchemeOp::TAlterColumnTableSchemaPreset& scheme) const = 0;
+};
+
+}
+
diff --git a/ydb/core/kqp/gateway/behaviour/tablestore/operations/add_column.cpp b/ydb/core/kqp/gateway/behaviour/tablestore/operations/add_column.cpp
new file mode 100644
index 00000000000..b7d7b3a1d87
--- /dev/null
+++ b/ydb/core/kqp/gateway/behaviour/tablestore/operations/add_column.cpp
@@ -0,0 +1,38 @@
+#include "add_column.h"
+#include <util/string/type.h>
+
+namespace NKikimr::NKqp {
+
+NMetadata::NModifications::TObjectOperatorResult TAddColumnOperation::DoDeserialize(const NYql::TObjectSettingsImpl::TFeatures& features) {
+ {
+ auto it = features.find("NAME");
+ if (it == features.end()) {
+ return NMetadata::NModifications::TObjectOperatorResult("can't find alter parameter NAME");
+ }
+ ColumnName = it->second;
+ }
+ {
+ auto it = features.find("TYPE");
+ if (it == features.end()) {
+ return NMetadata::NModifications::TObjectOperatorResult("can't find alter parameter TYPE");
+ }
+ ColumnType = it->second;
+ }
+ {
+ auto it = features.find("NOT_NULL");
+ if (it != features.end()) {
+ NotNull = IsTrue(it->second);
+ }
+ }
+ return NMetadata::NModifications::TObjectOperatorResult(true);
+}
+
+void TAddColumnOperation::DoSerializeScheme(NKikimrSchemeOp::TAlterColumnTableSchemaPreset& presetProto) const {
+ auto schemaData = presetProto.MutableAlterSchema();
+ auto column = schemaData->AddColumns();
+ column->SetName(ColumnName);
+ column->SetType(ColumnType);
+ column->SetNotNull(NotNull);
+}
+
+}
diff --git a/ydb/core/kqp/gateway/behaviour/tablestore/operations/add_column.h b/ydb/core/kqp/gateway/behaviour/tablestore/operations/add_column.h
new file mode 100644
index 00000000000..d5f8677e231
--- /dev/null
+++ b/ydb/core/kqp/gateway/behaviour/tablestore/operations/add_column.h
@@ -0,0 +1,22 @@
+#include "abstract.h"
+
+namespace NKikimr::NKqp {
+
+class TAddColumnOperation : public ITableStoreOperation {
+ static TString GetTypeName() {
+ return "NEW_COLUMN";
+ }
+
+ static inline auto Registrator = TFactory::TRegistrator<TAddColumnOperation>(GetTypeName());
+private:
+ TString ColumnName;
+ TString ColumnType;
+ bool NotNull = false;
+public:
+ NMetadata::NModifications::TObjectOperatorResult DoDeserialize(const NYql::TObjectSettingsImpl::TFeatures& features) override;
+
+ void DoSerializeScheme(NKikimrSchemeOp::TAlterColumnTableSchemaPreset& presetProto) const override;
+};
+
+}
+