Skip to content

feat(catalog): add pluggable CatalogFactory - #617

Draft
Joob1n wants to merge 1 commit into
apache:mainfrom
Joob1n:feat/catalog-factory
Draft

Joob1n wants to merge 1 commit into
apache:mainfrom
Joob1n:feat/catalog-factory

Conversation

@Joob1n

@Joob1n Joob1n commented Dec 4, 2026

Copy link
Copy Markdown
Member

Purpose

Make paimon::Catalog::Create extensible via a pluggable CatalogFactory registered with FactoryCreator / REGISTER_PAIMON_FACTORY, matching the existing factory extension pattern used for FileSystemFactory, FileFormatFactory, and CredentialProviderFactory.

Previously, Catalog::Create hardcoded dispatch only for "filesystem" and "rest" metastores and rejected any other CatalogOptions::METASTORE value. External distributed engines (such as StarRocks, where the frontend manages HMS/external catalog metadata and workers receive resolved table locations) can now register a custom CatalogFactory and select it via CatalogOptions::METASTORE.

Summary of changes:

  • Add public paimon::CatalogFactory (include/paimon/catalog/catalog_factory.h) deriving from paimon::Factory, with virtual Create(...) and static Get(...) lookup through FactoryCreator.
  • Register built-in "filesystem" (FileSystemCatalogFactory) and "rest" (RestCatalogFactory under PAIMON_ENABLE_REST) factories in src/paimon/core/catalog/catalog_factory.cpp, preserving "PAIMON_ENABLE_REST=ON" and "unsupported metastore" errors.
  • Refactor Catalog::Create in src/paimon/core/catalog/catalog.cpp to dispatch normalized (lowercased) metastore identifiers via CatalogFactory::Get.

Tests

Added src/paimon/core/catalog/catalog_factory_test.cpp:

  • Built-in "filesystem" catalog resolution via CatalogFactory::Get and Catalog::Create (default, "filesystem", and case-insensitive "FileSystem").
  • Custom CatalogFactory registration and dispatch (exact identifier via CatalogFactory::Get and case-normalized CatalogOptions::METASTORE via Catalog::Create), verifying forwarding of root_path, options, file_system, and fs_scheme_to_identifier_map.
  • Error handling for unregistered metastore identifiers, cross-factory identifier collisions (dynamic_cast<CatalogFactory*>), factory creation failures, null Catalog returns, and metastore=rest when PAIMON_ENABLE_REST is disabled.
  • Dependency catalog propagation through InternalReadContext::CreateDependencyCatalogContext(), verifying that custom metastore and options dispatch back to the custom CatalogFactory via Catalog::Create.

Existing CatalogTest and RestCatalogTest (including RestCatalogTest.CatalogFactoryMetastoreDispatch) remain covered.

API and Format

  • Public C++ API addition: include/paimon/catalog/catalog_factory.h (PAIMON_EXPORT class CatalogFactory : public Factory).
  • Updated Catalog::Create docstring in include/paimon/catalog/catalog.h to document CatalogFactory dispatch.
  • No storage format or wire protocol changes.

Documentation

  • Added paimon::CatalogFactory to docs/source/api/catalog.rst.
  • Documented custom catalog registration and FactoryCreator identifier-space rules in docs/source/user_guide/catalog.rst.

Signed-off-by: Yunpei Zhou <Joob1n@outlook.com>
@lxy-9602
lxy-9602 requested a review from lucasfang December 4, 2026 06:14
const std::map<std::string, std::string>& options,
const std::shared_ptr<FileSystem>& file_system = nullptr,
const std::map<std::string, std::string>& fs_scheme_to_identifier_map = {});
};

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have a suggestion: if it doesn’t affect interface compatibility, could we remove the default parameters?

{CatalogOptions::METASTORE, TestCatalogFactory::IDENTIFIER}, {"test.fail", "boom"}};
ASSERT_NOK_WITH_MSG(Catalog::Create("/tmp/wh", options).status(),
"custom catalog failure: boom");
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just use ASSERT_NOK_WITH_MSG(Func(), "error msg"); there’s no need to write Func().status().

@lxy-9602
lxy-9602 marked this pull request as draft December 4, 2026 13:21

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants