Package org.apache.polaris.spark
Class SparkCatalog
java.lang.Object
org.apache.polaris.spark.SparkCatalog
- All Implemented Interfaces:
org.apache.iceberg.spark.SupportsReplaceView,org.apache.spark.sql.connector.catalog.CatalogPlugin,org.apache.spark.sql.connector.catalog.StagingTableCatalog,org.apache.spark.sql.connector.catalog.SupportsNamespaces,org.apache.spark.sql.connector.catalog.TableCatalog,org.apache.spark.sql.connector.catalog.ViewCatalog
public class SparkCatalog
extends Object
implements org.apache.spark.sql.connector.catalog.StagingTableCatalog, org.apache.spark.sql.connector.catalog.TableCatalog, org.apache.spark.sql.connector.catalog.SupportsNamespaces, org.apache.spark.sql.connector.catalog.ViewCatalog, org.apache.iceberg.spark.SupportsReplaceView
SparkCatalog Implementation that is able to interact with both Iceberg SparkCatalog and Polaris
SparkCatalog. All namespaces and view related operations continue goes through the Iceberg
SparkCatalog. For table operations, depends on the table format, the operation can be achieved
with interaction with both Iceberg and Polaris SparkCatalog.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected Stringprotected DeltaHelperprotected org.apache.iceberg.spark.SparkCatalogprotected PolarisSparkCatalogFields inherited from interface org.apache.spark.sql.connector.catalog.SupportsNamespaces
PROP_COMMENT, PROP_LOCATION, PROP_OWNERFields inherited from interface org.apache.spark.sql.connector.catalog.TableCatalog
OPTION_PREFIX, PROP_COMMENT, PROP_EXTERNAL, PROP_IS_MANAGED_LOCATION, PROP_LOCATION, PROP_OWNER, PROP_PROVIDERFields inherited from interface org.apache.spark.sql.connector.catalog.ViewCatalog
PROP_COMMENT, PROP_CREATE_ENGINE_VERSION, PROP_ENGINE_VERSION, PROP_OWNER, RESERVED_PROPERTIES -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidalterNamespace(String[] namespace, org.apache.spark.sql.connector.catalog.NamespaceChange... changes) org.apache.spark.sql.connector.catalog.TablealterTable(org.apache.spark.sql.connector.catalog.Identifier ident, org.apache.spark.sql.connector.catalog.TableChange... changes) org.apache.spark.sql.connector.catalog.ViewalterView(org.apache.spark.sql.connector.catalog.Identifier ident, org.apache.spark.sql.connector.catalog.ViewChange... changes) voidcreateNamespace(String[] namespace, Map<String, String> metadata) org.apache.spark.sql.connector.catalog.TablecreateTable(org.apache.spark.sql.connector.catalog.Identifier ident, org.apache.spark.sql.types.StructType schema, org.apache.spark.sql.connector.expressions.Transform[] transforms, Map<String, String> properties) org.apache.spark.sql.connector.catalog.ViewcreateView(org.apache.spark.sql.connector.catalog.Identifier ident, String sql, String currentCatalog, String[] currentNamespace, org.apache.spark.sql.types.StructType schema, String[] queryColumnNames, String[] columnAliases, String[] columnComments, Map<String, String> properties) String[]booleandropNamespace(String[] namespace, boolean cascade) booleandropTable(org.apache.spark.sql.connector.catalog.Identifier ident) booleandropView(org.apache.spark.sql.connector.catalog.Identifier ident) voidinitialize(String name, org.apache.spark.sql.util.CaseInsensitiveStringMap options) voidinvalidateTable(org.apache.spark.sql.connector.catalog.Identifier ident) String[][]String[][]listNamespaces(String[] namespace) org.apache.spark.sql.connector.catalog.Identifier[]listTables(String[] namespace) org.apache.spark.sql.connector.catalog.Identifier[]loadNamespaceMetadata(String[] namespace) org.apache.spark.sql.connector.catalog.TableloadTable(org.apache.spark.sql.connector.catalog.Identifier ident) org.apache.spark.sql.connector.catalog.ViewloadView(org.apache.spark.sql.connector.catalog.Identifier ident) name()booleanpurgeTable(org.apache.spark.sql.connector.catalog.Identifier ident) voidrenameTable(org.apache.spark.sql.connector.catalog.Identifier from, org.apache.spark.sql.connector.catalog.Identifier to) voidrenameView(org.apache.spark.sql.connector.catalog.Identifier fromIdentifier, org.apache.spark.sql.connector.catalog.Identifier toIdentifier) org.apache.spark.sql.connector.catalog.ViewreplaceView(org.apache.spark.sql.connector.catalog.Identifier ident, String sql, String currentCatalog, String[] currentNamespace, org.apache.spark.sql.types.StructType schema, String[] queryColumnNames, String[] columnAliases, String[] columnComments, Map<String, String> properties) org.apache.spark.sql.connector.catalog.StagedTablestageCreate(org.apache.spark.sql.connector.catalog.Identifier ident, org.apache.spark.sql.types.StructType schema, org.apache.spark.sql.connector.expressions.Transform[] transforms, Map<String, String> properties) org.apache.spark.sql.connector.catalog.StagedTablestageCreateOrReplace(org.apache.spark.sql.connector.catalog.Identifier ident, org.apache.spark.sql.types.StructType schema, org.apache.spark.sql.connector.expressions.Transform[] transforms, Map<String, String> properties) org.apache.spark.sql.connector.catalog.StagedTablestageReplace(org.apache.spark.sql.connector.catalog.Identifier ident, org.apache.spark.sql.types.StructType schema, org.apache.spark.sql.connector.expressions.Transform[] transforms, Map<String, String> properties) org.apache.spark.sql.util.CaseInsensitiveStringMapvalidateAndResolveCatalogOptions(org.apache.spark.sql.util.CaseInsensitiveStringMap options) Check whether invalid catalog configuration is provided, and return an option map with catalog type configured correctly.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.apache.spark.sql.connector.catalog.StagingTableCatalog
stageCreate, stageCreateOrReplace, stageReplaceMethods inherited from interface org.apache.spark.sql.connector.catalog.SupportsNamespaces
namespaceExistsMethods inherited from interface org.apache.spark.sql.connector.catalog.TableCatalog
capabilities, createTable, loadTable, loadTable, loadTable, tableExists, useNullableQuerySchemaMethods inherited from interface org.apache.spark.sql.connector.catalog.ViewCatalog
invalidateView, viewExists
-
Field Details
-
catalogName
-
icebergsSparkCatalog
protected org.apache.iceberg.spark.SparkCatalog icebergsSparkCatalog -
polarisSparkCatalog
-
deltaHelper
-
-
Constructor Details
-
SparkCatalog
public SparkCatalog()
-
-
Method Details
-
name
- Specified by:
namein interfaceorg.apache.spark.sql.connector.catalog.CatalogPlugin
-
validateAndResolveCatalogOptions
public org.apache.spark.sql.util.CaseInsensitiveStringMap validateAndResolveCatalogOptions(org.apache.spark.sql.util.CaseInsensitiveStringMap options) Check whether invalid catalog configuration is provided, and return an option map with catalog type configured correctly. This function mainly validates two parts: 1) No customized catalog implementation is provided. 2) No non-rest catalog type is configured. -
initialize
- Specified by:
initializein interfaceorg.apache.spark.sql.connector.catalog.CatalogPlugin
-
loadTable
public org.apache.spark.sql.connector.catalog.Table loadTable(org.apache.spark.sql.connector.catalog.Identifier ident) throws org.apache.spark.sql.catalyst.analysis.NoSuchTableException - Specified by:
loadTablein interfaceorg.apache.spark.sql.connector.catalog.TableCatalog- Throws:
org.apache.spark.sql.catalyst.analysis.NoSuchTableException
-
createTable
public org.apache.spark.sql.connector.catalog.Table createTable(org.apache.spark.sql.connector.catalog.Identifier ident, org.apache.spark.sql.types.StructType schema, org.apache.spark.sql.connector.expressions.Transform[] transforms, Map<String, String> properties) throws org.apache.spark.sql.catalyst.analysis.TableAlreadyExistsException, org.apache.spark.sql.catalyst.analysis.NoSuchNamespaceException- Specified by:
createTablein interfaceorg.apache.spark.sql.connector.catalog.TableCatalog- Throws:
org.apache.spark.sql.catalyst.analysis.TableAlreadyExistsExceptionorg.apache.spark.sql.catalyst.analysis.NoSuchNamespaceException
-
alterTable
public org.apache.spark.sql.connector.catalog.Table alterTable(org.apache.spark.sql.connector.catalog.Identifier ident, org.apache.spark.sql.connector.catalog.TableChange... changes) throws org.apache.spark.sql.catalyst.analysis.NoSuchTableException - Specified by:
alterTablein interfaceorg.apache.spark.sql.connector.catalog.TableCatalog- Throws:
org.apache.spark.sql.catalyst.analysis.NoSuchTableException
-
dropTable
public boolean dropTable(org.apache.spark.sql.connector.catalog.Identifier ident) - Specified by:
dropTablein interfaceorg.apache.spark.sql.connector.catalog.TableCatalog
-
renameTable
public void renameTable(org.apache.spark.sql.connector.catalog.Identifier from, org.apache.spark.sql.connector.catalog.Identifier to) throws org.apache.spark.sql.catalyst.analysis.NoSuchTableException, org.apache.spark.sql.catalyst.analysis.TableAlreadyExistsException - Specified by:
renameTablein interfaceorg.apache.spark.sql.connector.catalog.TableCatalog- Throws:
org.apache.spark.sql.catalyst.analysis.NoSuchTableExceptionorg.apache.spark.sql.catalyst.analysis.TableAlreadyExistsException
-
invalidateTable
public void invalidateTable(org.apache.spark.sql.connector.catalog.Identifier ident) - Specified by:
invalidateTablein interfaceorg.apache.spark.sql.connector.catalog.TableCatalog
-
purgeTable
public boolean purgeTable(org.apache.spark.sql.connector.catalog.Identifier ident) - Specified by:
purgeTablein interfaceorg.apache.spark.sql.connector.catalog.TableCatalog
-
listTables
- Specified by:
listTablesin interfaceorg.apache.spark.sql.connector.catalog.TableCatalog
-
stageCreate
public org.apache.spark.sql.connector.catalog.StagedTable stageCreate(org.apache.spark.sql.connector.catalog.Identifier ident, org.apache.spark.sql.types.StructType schema, org.apache.spark.sql.connector.expressions.Transform[] transforms, Map<String, String> properties) throws org.apache.spark.sql.catalyst.analysis.TableAlreadyExistsException- Specified by:
stageCreatein interfaceorg.apache.spark.sql.connector.catalog.StagingTableCatalog- Throws:
org.apache.spark.sql.catalyst.analysis.TableAlreadyExistsException
-
stageReplace
public org.apache.spark.sql.connector.catalog.StagedTable stageReplace(org.apache.spark.sql.connector.catalog.Identifier ident, org.apache.spark.sql.types.StructType schema, org.apache.spark.sql.connector.expressions.Transform[] transforms, Map<String, String> properties) throws org.apache.spark.sql.catalyst.analysis.NoSuchTableException- Specified by:
stageReplacein interfaceorg.apache.spark.sql.connector.catalog.StagingTableCatalog- Throws:
org.apache.spark.sql.catalyst.analysis.NoSuchTableException
-
stageCreateOrReplace
public org.apache.spark.sql.connector.catalog.StagedTable stageCreateOrReplace(org.apache.spark.sql.connector.catalog.Identifier ident, org.apache.spark.sql.types.StructType schema, org.apache.spark.sql.connector.expressions.Transform[] transforms, Map<String, String> properties) - Specified by:
stageCreateOrReplacein interfaceorg.apache.spark.sql.connector.catalog.StagingTableCatalog
-
defaultNamespace
- Specified by:
defaultNamespacein interfaceorg.apache.spark.sql.connector.catalog.CatalogPlugin
-
listNamespaces
- Specified by:
listNamespacesin interfaceorg.apache.spark.sql.connector.catalog.SupportsNamespaces
-
listNamespaces
public String[][] listNamespaces(String[] namespace) throws org.apache.spark.sql.catalyst.analysis.NoSuchNamespaceException - Specified by:
listNamespacesin interfaceorg.apache.spark.sql.connector.catalog.SupportsNamespaces- Throws:
org.apache.spark.sql.catalyst.analysis.NoSuchNamespaceException
-
loadNamespaceMetadata
public Map<String,String> loadNamespaceMetadata(String[] namespace) throws org.apache.spark.sql.catalyst.analysis.NoSuchNamespaceException - Specified by:
loadNamespaceMetadatain interfaceorg.apache.spark.sql.connector.catalog.SupportsNamespaces- Throws:
org.apache.spark.sql.catalyst.analysis.NoSuchNamespaceException
-
createNamespace
public void createNamespace(String[] namespace, Map<String, String> metadata) throws org.apache.spark.sql.catalyst.analysis.NamespaceAlreadyExistsException- Specified by:
createNamespacein interfaceorg.apache.spark.sql.connector.catalog.SupportsNamespaces- Throws:
org.apache.spark.sql.catalyst.analysis.NamespaceAlreadyExistsException
-
alterNamespace
public void alterNamespace(String[] namespace, org.apache.spark.sql.connector.catalog.NamespaceChange... changes) throws org.apache.spark.sql.catalyst.analysis.NoSuchNamespaceException - Specified by:
alterNamespacein interfaceorg.apache.spark.sql.connector.catalog.SupportsNamespaces- Throws:
org.apache.spark.sql.catalyst.analysis.NoSuchNamespaceException
-
dropNamespace
public boolean dropNamespace(String[] namespace, boolean cascade) throws org.apache.spark.sql.catalyst.analysis.NoSuchNamespaceException - Specified by:
dropNamespacein interfaceorg.apache.spark.sql.connector.catalog.SupportsNamespaces- Throws:
org.apache.spark.sql.catalyst.analysis.NoSuchNamespaceException
-
listViews
- Specified by:
listViewsin interfaceorg.apache.spark.sql.connector.catalog.ViewCatalog
-
loadView
public org.apache.spark.sql.connector.catalog.View loadView(org.apache.spark.sql.connector.catalog.Identifier ident) throws org.apache.spark.sql.catalyst.analysis.NoSuchViewException - Specified by:
loadViewin interfaceorg.apache.spark.sql.connector.catalog.ViewCatalog- Throws:
org.apache.spark.sql.catalyst.analysis.NoSuchViewException
-
createView
public org.apache.spark.sql.connector.catalog.View createView(org.apache.spark.sql.connector.catalog.Identifier ident, String sql, String currentCatalog, String[] currentNamespace, org.apache.spark.sql.types.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- Specified by:
createViewin interfaceorg.apache.spark.sql.connector.catalog.ViewCatalog- Throws:
org.apache.spark.sql.catalyst.analysis.ViewAlreadyExistsExceptionorg.apache.spark.sql.catalyst.analysis.NoSuchNamespaceException
-
alterView
public org.apache.spark.sql.connector.catalog.View alterView(org.apache.spark.sql.connector.catalog.Identifier ident, org.apache.spark.sql.connector.catalog.ViewChange... changes) throws org.apache.spark.sql.catalyst.analysis.NoSuchViewException, IllegalArgumentException - Specified by:
alterViewin interfaceorg.apache.spark.sql.connector.catalog.ViewCatalog- Throws:
org.apache.spark.sql.catalyst.analysis.NoSuchViewExceptionIllegalArgumentException
-
dropView
public boolean dropView(org.apache.spark.sql.connector.catalog.Identifier ident) - Specified by:
dropViewin interfaceorg.apache.spark.sql.connector.catalog.ViewCatalog
-
renameView
public void renameView(org.apache.spark.sql.connector.catalog.Identifier fromIdentifier, org.apache.spark.sql.connector.catalog.Identifier toIdentifier) throws org.apache.spark.sql.catalyst.analysis.NoSuchViewException, org.apache.spark.sql.catalyst.analysis.ViewAlreadyExistsException - Specified by:
renameViewin interfaceorg.apache.spark.sql.connector.catalog.ViewCatalog- Throws:
org.apache.spark.sql.catalyst.analysis.NoSuchViewExceptionorg.apache.spark.sql.catalyst.analysis.ViewAlreadyExistsException
-
replaceView
public org.apache.spark.sql.connector.catalog.View replaceView(org.apache.spark.sql.connector.catalog.Identifier ident, String sql, String currentCatalog, String[] currentNamespace, org.apache.spark.sql.types.StructType schema, String[] queryColumnNames, String[] columnAliases, String[] columnComments, Map<String, String> properties) throws org.apache.spark.sql.catalyst.analysis.NoSuchNamespaceException, org.apache.spark.sql.catalyst.analysis.NoSuchViewException- Specified by:
replaceViewin interfaceorg.apache.iceberg.spark.SupportsReplaceView- Throws:
org.apache.spark.sql.catalyst.analysis.NoSuchNamespaceExceptionorg.apache.spark.sql.catalyst.analysis.NoSuchViewException
-