Interface ViewCatalog

All Superinterfaces:
CatalogPlugin

@DeveloperApi public interface ViewCatalog extends CatalogPlugin
Catalog methods for working with views.
  • Field Details

    • PROP_COMMENT

      static final String PROP_COMMENT
      A reserved property to specify the description of the view.
      See Also:
    • PROP_OWNER

      static final String PROP_OWNER
      A reserved property to specify the owner of the view.
      See Also:
    • PROP_CREATE_ENGINE_VERSION

      static final String PROP_CREATE_ENGINE_VERSION
      A reserved property to specify the software version used to create the view.
      See Also:
    • PROP_ENGINE_VERSION

      static final String PROP_ENGINE_VERSION
      A reserved property to specify the software version used to change the view.
      See Also:
    • RESERVED_PROPERTIES

      static final List<String> RESERVED_PROPERTIES
      All reserved properties of the view.
  • Method Details

    • listViews

      Identifier[] listViews(String... namespace) throws org.apache.spark.sql.catalyst.analysis.NoSuchNamespaceException
      List the views in a namespace from the catalog.

      If the catalog supports tables, this must return identifiers for only views and not tables.

      Parameters:
      namespace - a multi-part namespace
      Returns:
      an array of Identifiers for views
      Throws:
      org.apache.spark.sql.catalyst.analysis.NoSuchNamespaceException - If the namespace does not exist (optional).
    • loadView

      View loadView(Identifier ident) throws org.apache.spark.sql.catalyst.analysis.NoSuchViewException
      Load view metadata by ident from the catalog.

      If the catalog supports tables and contains a table for the identifier and not a view, this must throw NoSuchViewException.

      Parameters:
      ident - a view identifier
      Returns:
      the view description
      Throws:
      org.apache.spark.sql.catalyst.analysis.NoSuchViewException - If the view doesn't exist or is a table
    • invalidateView

      default void invalidateView(Identifier ident)
      Invalidate cached view metadata for an identifier.

      If the view is already loaded or cached, drop cached data. If the view does not exist or is not cached, do nothing. Calling this method should not query remote services.

      Parameters:
      ident - a view identifier
    • viewExists

      default boolean viewExists(Identifier ident)
      Test whether a view exists using an identifier from the catalog.

      If the catalog supports views and contains a view for the identifier and not a table, this must return false.

      Parameters:
      ident - a view identifier
      Returns:
      true if the view exists, false otherwise
    • createView

      View createView(Identifier ident, String sql, String currentCatalog, String[] currentNamespace, StructType schema, String[] queryColumnNames, String[] columnAliases, String[] columnComments, Map<String,String> properties) throws org.apache.spark.sql.catalyst.analysis.ViewAlreadyExistsException, org.apache.spark.sql.catalyst.analysis.NoSuchNamespaceException
      Create a view in the catalog.
      Parameters:
      ident - a view identifier
      sql - the SQL text that defines the view
      currentCatalog - the current catalog
      currentNamespace - the current namespace
      schema - the view query output schema
      queryColumnNames - the query column names
      columnAliases - the column aliases
      columnComments - the column comments
      properties - the view properties
      Returns:
      the view created
      Throws:
      org.apache.spark.sql.catalyst.analysis.ViewAlreadyExistsException - If a view or table already exists for the identifier
      org.apache.spark.sql.catalyst.analysis.NoSuchNamespaceException - If the identifier namespace does not exist (optional)
    • alterView

      View alterView(Identifier ident, ViewChange... changes) throws org.apache.spark.sql.catalyst.analysis.NoSuchViewException, IllegalArgumentException
      Apply changes to a view in the catalog.

      Implementations may reject the requested changes. If any change is rejected, none of the changes should be applied to the view.

      Parameters:
      ident - a view identifier
      changes - an array of changes to apply to the view
      Returns:
      the view altered
      Throws:
      org.apache.spark.sql.catalyst.analysis.NoSuchViewException - If the view doesn't exist or is a table.
      IllegalArgumentException - If any change is rejected by the implementation.
    • dropView

      boolean dropView(Identifier ident)
      Drop a view in the catalog.

      If the catalog supports tables and contains a table for the identifier and not a view, this must not drop the table and must return false.

      Parameters:
      ident - a view identifier
      Returns:
      true if a view was deleted, false if no view exists for the identifier
    • renameView

      void renameView(Identifier oldIdent, Identifier newIdent) throws org.apache.spark.sql.catalyst.analysis.NoSuchViewException, org.apache.spark.sql.catalyst.analysis.ViewAlreadyExistsException
      Rename a view in the catalog.

      If the catalog supports tables and contains a table with the old identifier, this throws NoSuchViewException. Additionally, if it contains a table with the new identifier, this throws ViewAlreadyExistsException.

      If the catalog does not support view renames between namespaces, it throws UnsupportedOperationException.

      Parameters:
      oldIdent - the view identifier of the existing view to rename
      newIdent - the new view identifier of the view
      Throws:
      org.apache.spark.sql.catalyst.analysis.NoSuchViewException - If the view to rename doesn't exist or is a table
      org.apache.spark.sql.catalyst.analysis.ViewAlreadyExistsException - If the new view name already exists or is a table
      UnsupportedOperationException - If the namespaces of old and new identifiers do not match (optional)