Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[core] Delete useless methods in Catalog #4468

Merged
merged 2 commits into from
Nov 6, 2024

Conversation

JingsongLi
Copy link
Contributor

Purpose

Delete follow methods in Catalog because of useless, We recommend using methods such as getTable directly to avoid errors in implementation.

    /**
     * Get lock factory from catalog. Lock is used to support multiple concurrent writes on the
     * object store.
     */
    Optional<CatalogLockFactory> lockFactory();

    /** Get lock context for lock factory to create a lock. */
    default Optional<CatalogLockContext> lockContext() {
        return Optional.empty();
    }

    /** Get metastore client factory for the table specified by {@code identifier}. */
    default Optional<MetastoreClient.Factory> metastoreClientFactory(Identifier identifier)
            throws TableNotExistException {
        return Optional.empty();
    }

Delete follow methods in Catalog because of repetitive:

    /**
     * Check if a database exists in this catalog.
     *
     * @param databaseName Name of the database
     * @return true if the given database exists in the catalog false otherwise
     */
    default boolean databaseExists(String databaseName) {
        try {
            loadDatabaseProperties(databaseName);
            return true;
        } catch (DatabaseNotExistException e) {
            return false;
        }
    }

    /**
     * Check if a table exists in this catalog.
     *
     * @param identifier Path of the table
     * @return true if the given table exists in the catalog false otherwise
     */
    default boolean tableExists(Identifier identifier) {
        try {
            return getTable(identifier) != null;
        } catch (TableNotExistException e) {
            return false;
        }
    }

    /**
     * Check if a view exists in this catalog.
     *
     * @param identifier Path of the view
     * @return true if the given view exists in the catalog false otherwise
     */
    default boolean viewExists(Identifier identifier) {
        try {
            return getView(identifier) != null;
        } catch (ViewNotExistException e) {
            return false;
        }
    }

Modify loadDatabaseProperties in Catalog because we can have a better naming for getDatabase:

    /**
     * Return a {@link Database} identified by the given name.
     *
     * @param name Database name
     * @return The requested {@link Database}
     * @throws DatabaseNotExistException if the requested database does not exist
     */
    Database getDatabase(String name) throws DatabaseNotExistException;

Tests

Existing tests.

API and Format

Catalog API.

Documentation

Copy link
Contributor

@yuzelin yuzelin left a comment

Choose a reason for hiding this comment

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

+1

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