|
39 | 39 | #include "paimon/core/io/compact_increment.h" |
40 | 40 | #include "paimon/core/io/data_increment.h" |
41 | 41 | #include "paimon/core/operation/file_store_commit_impl.h" |
| 42 | +#include "paimon/core/schema/table_schema.h" |
42 | 43 | #include "paimon/core/table/sink/commit_message_impl.h" |
43 | 44 | #include "paimon/core/utils/snapshot_manager.h" |
44 | 45 | #include "paimon/defs.h" |
45 | 46 | #include "paimon/executor.h" |
46 | 47 | #include "paimon/fs/local/local_file_system.h" |
47 | 48 | #include "paimon/memory/memory_pool.h" |
48 | 49 | #include "paimon/result.h" |
| 50 | +#include "paimon/testing/mock/mock_catalog.h" |
49 | 51 | #include "paimon/testing/utils/binary_row_generator.h" |
50 | 52 | #include "paimon/testing/utils/testharness.h" |
51 | 53 |
|
@@ -103,6 +105,35 @@ TEST(FileStoreCommitTest, TestCreateWithCatalogRequiresIdentifier) { |
103 | 105 | "a catalog commit requires a table identifier"); |
104 | 106 | } |
105 | 107 |
|
| 108 | +TEST(FileStoreCommitTest, TestCatalogCommitUsesPerTableFileSystem) { |
| 109 | + auto dir = UniqueTestDirectory::Create(); |
| 110 | + ASSERT_TRUE(dir); |
| 111 | + const std::string table_path = PathUtil::JoinPath(dir->Str(), "foo.db/bar"); |
| 112 | + const Identifier identifier("foo", "bar"); |
| 113 | + const auto logical_schema = arrow::schema( |
| 114 | + {arrow::field("id", arrow::int64(), false), arrow::field("value", arrow::utf8())}); |
| 115 | + ASSERT_OK_AND_ASSIGN( |
| 116 | + std::shared_ptr<TableSchema> schema, |
| 117 | + TableSchema::Create(0, logical_schema, /*partition_keys=*/{}, |
| 118 | + /*primary_keys=*/{}, {{Options::FILE_FORMAT, "parquet"}})); |
| 119 | + auto catalog = std::make_shared<MockVersionManagedCatalog>(); |
| 120 | + catalog->SetTableSchema(schema); |
| 121 | + // The catalog-wide file system is a different instance, so a commit that reached for it |
| 122 | + // instead of the table's own would not be served the credentials the table needs. |
| 123 | + catalog->SetFileSystem(std::make_shared<LocalFileSystem>()); |
| 124 | + catalog->SetTableFileSystem(dir->GetFileSystem()); |
| 125 | + |
| 126 | + CommitContextBuilder builder(table_path, "commit_user"); |
| 127 | + ASSERT_OK_AND_ASSIGN(std::unique_ptr<CommitContext> ctx, |
| 128 | + builder.WithCatalog(catalog, identifier).Finish()); |
| 129 | + ASSERT_OK_AND_ASSIGN(auto commit, FileStoreCommit::Create(std::move(ctx))); |
| 130 | + |
| 131 | + // The file system was resolved per table, not from the catalog-wide one. |
| 132 | + const std::vector<Identifier>& requests = catalog->TableFileSystemRequests(); |
| 133 | + ASSERT_FALSE(requests.empty()); |
| 134 | + ASSERT_EQ(requests.back().GetFullName(), identifier.GetFullName()); |
| 135 | +} |
| 136 | + |
106 | 137 | TEST(FileStoreCommitTest, TestAppendDvIndexShouldUseOverwriteCommitKind) { |
107 | 138 | auto string_field = arrow::field("f0", arrow::utf8()); |
108 | 139 | auto int_field = arrow::field("f1", arrow::int32()); |
|
0 commit comments