3131#include " paimon/common/utils/string_utils.h"
3232#include " paimon/core/core_options.h"
3333#include " paimon/core/snapshot.h"
34+ #include " paimon/core/table/system/global_system_tables.h"
3435#include " paimon/core/table/system/system_table.h"
3536#include " paimon/core/table/system/system_table_schema.h"
3637#include " paimon/core/utils/branch_manager.h"
@@ -47,8 +48,12 @@ struct ArrowSchema;
4748
4849namespace paimon {
4950FileSystemCatalog::FileSystemCatalog (const std::shared_ptr<FileSystem>& fs,
50- const std::string& warehouse)
51- : fs_(fs), warehouse_(warehouse), logger_(Logger::GetLogger(" FileSystemCatalog" )) {}
51+ const std::string& warehouse,
52+ const std::map<std::string, std::string>& catalog_options)
53+ : fs_(fs),
54+ warehouse_ (warehouse),
55+ catalog_options_(catalog_options),
56+ logger_(Logger::GetLogger(" FileSystemCatalog" )) {}
5257
5358Status FileSystemCatalog::CreateDatabase (const std::string& db_name,
5459 const std::map<std::string, std::string>& options,
@@ -88,13 +93,16 @@ Status FileSystemCatalog::CreateDatabaseImpl(const std::string& db_name,
8893
8994Result<bool > FileSystemCatalog::DatabaseExists (const std::string& db_name) const {
9095 if (IsSystemDatabase (db_name)) {
91- return Status::NotImplemented (
92- " do not support checking DatabaseExists for system database." );
96+ return true ;
9397 }
9498 return fs_->Exists (NewDatabasePath (warehouse_, db_name));
9599}
96100
97101Result<bool > FileSystemCatalog::TableExists (const Identifier& identifier) const {
102+ // Handle sys database global tables
103+ if (IsSystemDatabase (identifier.GetDatabaseName ())) {
104+ return GlobalSystemTableLoader::IsSupported (identifier.GetTableName ());
105+ }
98106 PAIMON_ASSIGN_OR_RAISE (bool is_system_table, identifier.IsSystemTable ());
99107 if (is_system_table) {
100108 PAIMON_ASSIGN_OR_RAISE (std::optional<std::string> system_table_name,
@@ -184,6 +192,10 @@ std::shared_ptr<FileSystem> FileSystemCatalog::GetFileSystem() const {
184192 return fs_;
185193}
186194
195+ const std::map<std::string, std::string>& FileSystemCatalog::GetOptions () const {
196+ return catalog_options_;
197+ }
198+
187199bool FileSystemCatalog::IsSystemDatabase (const std::string& db_name) {
188200 return db_name == SYSTEM_DATABASE_NAME ;
189201}
@@ -228,7 +240,7 @@ Result<std::vector<std::string>> FileSystemCatalog::ListDatabases() const {
228240
229241Result<std::vector<std::string>> FileSystemCatalog::ListTables (const std::string& db_name) const {
230242 if (IsSystemDatabase (db_name)) {
231- return Status::NotImplemented ( " do not support listing tables for system database. " );
243+ return GlobalSystemTableLoader::GetSupportedTableNames ( );
232244 }
233245 std::string database_path = NewDatabasePath (warehouse_, db_name);
234246 std::vector<std::unique_ptr<BasicFileStatus>> file_status_list;
@@ -261,6 +273,23 @@ Result<bool> FileSystemCatalog::TableExistsInFileSystem(const std::string& table
261273
262274Result<std::shared_ptr<Schema>> FileSystemCatalog::LoadTableSchema (
263275 const Identifier& identifier) const {
276+ // Handle sys database global tables
277+ if (IsSystemDatabase (identifier.GetDatabaseName ())) {
278+ if (!GlobalSystemTableLoader::IsSupported (identifier.GetTableName ())) {
279+ return Status::NotExist (fmt::format (" {} not exist" , identifier.ToString ()));
280+ }
281+ GlobalSystemTableContext context;
282+ context.catalog = const_cast <FileSystemCatalog*>(this );
283+ context.fs = fs_;
284+ context.warehouse = warehouse_;
285+ context.catalog_options = catalog_options_;
286+ PAIMON_ASSIGN_OR_RAISE (
287+ std::shared_ptr<SystemTable> system_table,
288+ GlobalSystemTableLoader::Load (identifier.GetTableName (), context));
289+ PAIMON_ASSIGN_OR_RAISE (std::shared_ptr<arrow::Schema> arrow_schema,
290+ system_table->ArrowSchema ());
291+ return std::make_shared<SystemTableSchema>(std::move (arrow_schema));
292+ }
264293 PAIMON_ASSIGN_OR_RAISE (bool is_system_table, identifier.IsSystemTable ());
265294 if (is_system_table) {
266295 PAIMON_ASSIGN_OR_RAISE (std::optional<std::string> system_table_name,
0 commit comments