Skip to content

Commit

Permalink
Allow system columns in tables inside backup collections (#10523)
Browse files Browse the repository at this point in the history
  • Loading branch information
Enjection authored Oct 16, 2024
1 parent df4bb7a commit a68afa8
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -446,6 +446,9 @@ class TCreateTable: public TSubOperation {
.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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit a68afa8

Please sign in to comment.