Interface ViewCatalog
- All Superinterfaces:
CatalogPlugin
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final String
A reserved property to specify the description of the view.static final String
A reserved property to specify the software version used to create the view.static final String
A reserved property to specify the software version used to change the view.static final String
A reserved property to specify the owner of the view.All reserved properties of the view. -
Method Summary
Modifier and TypeMethodDescriptionalterView
(Identifier ident, ViewChange... changes) Applychanges
to a view in the catalog.createView
(ViewInfo viewInfo) Create a view in the catalog.boolean
dropView
(Identifier ident) Drop a view in the catalog.default void
invalidateView
(Identifier ident) Invalidate cached view metadata for anidentifier
.List the views in a namespace from the catalog.loadView
(Identifier ident) Load view metadata byident
from the catalog.void
renameView
(Identifier oldIdent, Identifier newIdent) Rename a view in the catalog.default View
replaceView
(ViewInfo viewInfo, boolean orCreate) Replace a view in the catalog.default boolean
viewExists
(Identifier ident) Test whether a view exists using anidentifier
from the catalog.Methods inherited from interface org.apache.spark.sql.connector.catalog.CatalogPlugin
defaultNamespace, initialize, name
-
Field Details
-
PROP_COMMENT
A reserved property to specify the description of the view.- See Also:
-
PROP_OWNER
A reserved property to specify the owner of the view.- See Also:
-
PROP_CREATE_ENGINE_VERSION
A reserved property to specify the software version used to create the view.- See Also:
-
PROP_ENGINE_VERSION
A reserved property to specify the software version used to change the view.- See Also:
-
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
Load view metadata byident
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
Invalidate cached view metadata for anidentifier
.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
Test whether a view exists using anidentifier
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(ViewInfo viewInfo) throws org.apache.spark.sql.catalyst.analysis.ViewAlreadyExistsException, org.apache.spark.sql.catalyst.analysis.NoSuchNamespaceException Create a view in the catalog.- Parameters:
viewInfo
- the info class holding all view information- Returns:
- the created view. This can be null if getting the metadata for the view is expensive
- Throws:
org.apache.spark.sql.catalyst.analysis.ViewAlreadyExistsException
- If a view or table already exists for the identifierorg.apache.spark.sql.catalyst.analysis.NoSuchNamespaceException
- If the identifier namespace does not exist (optional)
-
replaceView
default View replaceView(ViewInfo viewInfo, boolean orCreate) throws org.apache.spark.sql.catalyst.analysis.NoSuchViewException, org.apache.spark.sql.catalyst.analysis.NoSuchNamespaceException Replace a view in the catalog.The default implementation has a race condition. Catalogs are encouraged to implement this operation atomically.
- Parameters:
viewInfo
- the info class holding all view informationorCreate
- create the view if it doesn't exist- Returns:
- the created/replaced view. This can be null if getting the metadata for the view is expensive
- Throws:
org.apache.spark.sql.catalyst.analysis.NoSuchViewException
- If the view doesn't exist or is a tableorg.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 Applychanges
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 identifierchanges
- 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
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 throwsViewAlreadyExistsException
.If the catalog does not support view renames between namespaces, it throws
UnsupportedOperationException
.- Parameters:
oldIdent
- the view identifier of the existing view to renamenewIdent
- 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 tableorg.apache.spark.sql.catalyst.analysis.ViewAlreadyExistsException
- If the new view name already exists or is a tableUnsupportedOperationException
- If the namespaces of old and new identifiers do not match (optional)
-