关注 spark技术分享,
撸spark源码 玩spark最佳实践

ExternalCatalog Contract — External Catalog (Metastore) of Permanent Relational Entities

ExternalCatalog Contract — External Catalog (Metastore) of Permanent Relational Entities

ExternalCatalog is the contract of an external system catalog (aka metadata registry or metastore) of permanent relational entities, i.e. databases, tables, partitions, and functions.

Table 1. ExternalCatalog’s Features per Relational Entity
Feature Database Function Partition Table

Alter

alterDatabase

alterFunction

alterPartitions

alterTable, alterTableDataSchema, alterTableStats

Create

createDatabase

createFunction

createPartitions

createTable

Drop

dropDatabase

dropFunction

dropPartitions

dropTable

Get

getDatabase

getFunction

getPartition, getPartitionOption

getTable

List

listDatabases

listFunctions

listPartitionNames, listPartitions, listPartitionsByFilter

listTables

Load

loadDynamicPartitions, loadPartition

loadTable

Rename

renameFunction

renamePartitions

renameTable

Check Existence

databaseExists

functionExists

tableExists

Set

setCurrentDatabase

Table 2. ExternalCatalog Contract (incl. Protected Methods)
Method Description

alterPartitions

createPartitions

databaseExists

doAlterDatabase

doAlterFunction

doAlterTable

doAlterTableDataSchema

doAlterTableStats

doCreateDatabase

doCreateFunction

doCreateTable

doDropDatabase

doDropFunction

doDropTable

doRenameFunction

doRenameTable

dropPartitions

functionExists

getDatabase

getFunction

getPartition

getPartitionOption

getTable

listDatabases

listFunctions

listPartitionNames

listPartitions

listPartitionsByFilter

listTables

loadDynamicPartitions

loadPartition

loadTable

renamePartitions

setCurrentDatabase

tableExists

ExternalCatalog is available as externalCatalog of SharedState (in SparkSession).

ExternalCatalog is available as ephemeral in-memory or persistent hive-aware.

Table 3. ExternalCatalogs
ExternalCatalog Alias Description

HiveExternalCatalog

hive

A persistent system catalog using a Hive metastore.

InMemoryCatalog

in-memory

An in-memory (ephemeral) system catalog that does not require setting up external systems (like a Hive metastore).

It is intended for testing or exploration purposes only and therefore should not be used in production.

The concrete ExternalCatalog is chosen using Builder.enableHiveSupport that enables the Hive support (and sets spark.sql.catalogImplementation configuration property to hive when the Hive classes are available).

Tip

Set spark.sql.catalogImplementation to in-memory when starting spark-shell to use InMemoryCatalog external catalog.

Important

You cannot change ExternalCatalog after SparkSession has been created using spark.sql.catalogImplementation configuration property as it is a static configuration.

ExternalCatalog is a ListenerBus of ExternalCatalogEventListener listeners that handle ExternalCatalogEvent events.

Tip

Use addListener and removeListener to register and de-register ExternalCatalogEventListener listeners, accordingly.

Read ListenerBus Event Bus Contract in Mastering Apache Spark 2 gitbook to learn more about Spark Core’s ListenerBus interface.

Altering Table Statistics — alterTableStats Method

alterTableStats…​FIXME

Note
alterTableStats is used exclusively when SessionCatalog is requested for altering the statistics of a table in a metastore (that can happen when any logical command is executed that could change the table statistics).

Altering Table — alterTable Method

alterTable…​FIXME

Note
alterTable is used exclusively when SessionCatalog is requested for altering the statistics of a table in a metastore.

createTable Method

createTable…​FIXME

Note
createTable is used when…​FIXME

alterTableDataSchema Method

alterTableDataSchema…​FIXME

Note
alterTableDataSchema is used exclusively when SessionCatalog is requested to alterTableDataSchema.
赞(0) 打赏
未经允许不得转载:spark技术分享 » ExternalCatalog Contract — External Catalog (Metastore) of Permanent Relational Entities
分享到: 更多 (0)

关注公众号:spark技术分享

联系我们联系我们

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏