diff options
author | Innokentii Mokin <innokentii@ydb.tech> | 2024-10-17 04:01:05 +0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-10-17 04:01:05 +0700 |
commit | a68afa8387bb1606f2888a3e7e9ab26f88f59020 (patch) | |
tree | 8a1e813ec071e9d2fce3f0ed490df01cacf7f1de | |
parent | df4bb7a4e867a0c82c89f29742468566ac878be0 (diff) | |
download | ydb-a68afa8387bb1606f2888a3e7e9ab26f88f59020.tar.gz |
Allow system columns in tables inside backup collections (#10523)
-rw-r--r-- | ydb/core/tx/schemeshard/schemeshard__operation_create_table.cpp | 3 | ||||
-rw-r--r-- | ydb/core/tx/schemeshard/ut_backup_collection/ut_backup_collection.cpp | 43 |
2 files changed, 46 insertions, 0 deletions
diff --git a/ydb/core/tx/schemeshard/schemeshard__operation_create_table.cpp b/ydb/core/tx/schemeshard/schemeshard__operation_create_table.cpp index b41752f6bf..48b1b31eb1 100644 --- a/ydb/core/tx/schemeshard/schemeshard__operation_create_table.cpp +++ b/ydb/core/tx/schemeshard/schemeshard__operation_create_table.cpp @@ -446,6 +446,9 @@ public: .FailOnRestrictedCreateInTempZone(Transaction.GetAllowCreateInTempDir()); if (checks) { + if (parentPathStr.StartsWith(JoinPath({parentPath.GetDomainPathString(), ".backups/collections"}))) { + schema.SetSystemColumnNamesAllowed(true); + } if (parentPath.Base()->IsTableIndex()) { checks.IsInsideTableIndexPath(); // Not build index impl tables can be created only as part of create index diff --git a/ydb/core/tx/schemeshard/ut_backup_collection/ut_backup_collection.cpp b/ydb/core/tx/schemeshard/ut_backup_collection/ut_backup_collection.cpp index 13d65bacb7..fd6d3e7b9d 100644 --- a/ydb/core/tx/schemeshard/ut_backup_collection/ut_backup_collection.cpp +++ b/ydb/core/tx/schemeshard/ut_backup_collection/ut_backup_collection.cpp @@ -245,4 +245,47 @@ Y_UNIT_TEST_SUITE(TBackupCollectionTests) { env.TestWaitNotification(runtime, txId - 1); TestLs(runtime, "/MyRoot/.backups/collections/" DEFAULT_NAME_1, false, NLs::PathNotExist); } + + Y_UNIT_TEST(TableWithSystemColumns) { + TTestBasicRuntime runtime; + TTestEnv env(runtime, TTestEnvOptions().EnableBackupService(true)); + ui64 txId = 100; + + SetupLogging(runtime); + + PrepareDirs(runtime, env, txId); + + TestCreateBackupCollection(runtime, ++txId, "/MyRoot/.backups/collections/", DefaultCollectionSettings()); + + env.TestWaitNotification(runtime, txId); + + TestDescribeResult(DescribePath(runtime, "/MyRoot/.backups/collections/" DEFAULT_NAME_1), { + NLs::PathExist, + NLs::IsBackupCollection, + }); + + TestCreateTable(runtime, ++txId, "/MyRoot/.backups/collections", R"( + Name: "Table1" + Columns { Name: "key" Type: "Utf8" } + Columns { Name: "__ydb_system_column" Type: "Utf8" } + KeyColumnNames: ["key"] + )"); + env.TestWaitNotification(runtime, txId); + + TestCreateTable(runtime, ++txId, "/MyRoot", R"( + Name: ".backups/collections/Table2" + Columns { Name: "key" Type: "Utf8" } + Columns { Name: "__ydb_system_column" Type: "Utf8" } + KeyColumnNames: ["key"] + )"); + env.TestWaitNotification(runtime, txId); + + TestCreateTable(runtime, ++txId, "/MyRoot/.backups/collections", R"( + Name: "somepath/Table3" + Columns { Name: "key" Type: "Utf8" } + Columns { Name: "__ydb_system_column" Type: "Utf8" } + KeyColumnNames: ["key"] + )"); + env.TestWaitNotification(runtime, txId); + } } // TBackupCollectionTests |