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] Introduce View Support to HiveCatalog #4340

Merged
merged 1 commit into from
Oct 28, 2024

Conversation

JingsongLi
Copy link
Contributor

@JingsongLi JingsongLi commented Oct 16, 2024

Purpose

This PR aims to support View in Catalog, our metastore behind us, such as Hive metastore, supports views, but our catalog has not done this conversion well. This PR aims to support the definition of views and bridge with HiveCatalog.

Definition of view

/** Interface for view definition. */
public interface View {

    /** A name to identify this view. */
    String name();

    /** Full name (including database) to identify this view. */
    String fullName();

    /** Returns the row type of this view. */
    RowType rowType();

    /** Returns the view representation. */
    String query();

    /** Optional comment of this view. */
    Optional<String> comment();

    /** Options of this view. */
    Map<String, String> options();

    /** Copy this view with adding dynamic options. */
    View copy(Map<String, String> dynamicOptions);
}

Catalog interfaces

/**
     * Return a {@link View} identified by the given {@link Identifier}.
     *
     * @param identifier Path of the view
     * @return The requested view
     * @throws ViewNotExistException if the target does not exist
     */
    default View getView(Identifier identifier) throws ViewNotExistException {
        throw new ViewNotExistException(identifier);
    }

    /**
     * Drop a view.
     *
     * @param identifier Path of the view to be dropped
     * @param ignoreIfNotExists Flag to specify behavior when the view does not exist: if set to
     *     false, throw an exception, if set to true, do nothing.
     * @throws ViewNotExistException if the view does not exist
     */
    default void dropView(Identifier identifier, boolean ignoreIfNotExists)
            throws ViewNotExistException {
        throw new UnsupportedOperationException();
    }

    /**
     * Create a new view.
     *
     * @param identifier path of the view to be created
     * @param view the view definition
     * @param ignoreIfExists flag to specify behavior when a view already exists at the given path:
     *     if set to false, it throws a ViewAlreadyExistException, if set to true, do nothing.
     * @throws ViewAlreadyExistException if view already exists and ignoreIfExists is false
     * @throws DatabaseNotExistException if the database in identifier doesn't exist
     */
    default void createView(Identifier identifier, View view, boolean ignoreIfExists)
            throws ViewAlreadyExistException, DatabaseNotExistException {
        throw new UnsupportedOperationException();
    }

    /**
     * Get names of all views under this database. An empty list is returned if none exists.
     *
     * @return a list of the names of all views in this database
     * @throws DatabaseNotExistException if the database does not exist
     */
    default List<String> listViews(String databaseName) throws DatabaseNotExistException {
        throw new UnsupportedOperationException();
    }

Implemented these methods in HiveCatalog.

Flink Integration

Integrate to Flink Catalog.

Tests

API and Format

Documentation

@adrian-wang
Copy link
Contributor

maybe also support listViews and alterView?

@JingsongLi
Copy link
Contributor Author

maybe also support listViews and alterView?

Alter view looks invalid to me, it just modify properties, I cannot see the case.

@LinMingQiang
Copy link
Contributor

Is there any problem with this PR? I am looking forward to this feature.

@adrian-wang
Copy link
Contributor

LGTM

@JingsongLi
Copy link
Contributor Author

Is there any problem with this PR? I am looking forward to this feature.

Let's merge this.

@JingsongLi JingsongLi merged commit 3b08450 into apache:master Oct 28, 2024
11 of 12 checks passed
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.

4 participants