Skip to content

Catalog

Defined in: catalog.ts:23

Access to Spark’s catalog for inspecting and managing databases, tables, functions, views, and cached tables.

Obtained via SparkSession.catalog.

const dbs = await spark.catalog.listDatabases();
const tables = await spark.catalog.listTables("analytics");
await spark.catalog.cacheTable("analytics.events");

Spark source: Catalog.scala

cacheTable(tableName, storageLevel?): Promise<void>;

Defined in: catalog.ts:131

Cache the specified table in-memory with an optional storage level.

ParameterType
tableNamestring
storageLevel?StorageLevel

Promise<void>


clearCache(): Promise<void>;

Defined in: catalog.ts:141

Remove all cached tables from the in-memory cache.

Promise<void>


createExternalTable(tableName, options?): DataFrame;

Defined in: catalog.ts:198

Create an external table based on the dataset in a data source.

Returns a DataFrame associated with the external table.

ParameterType
tableNamestring
options?{ options?: Record<string, string>; path?: string; schema?: StructType; source?: string; }
options.options?Record<string, string>
options.path?string
options.schema?StructType
options.source?string

DataFrame


createTable(tableName, options?): DataFrame;

Defined in: catalog.ts:168

Create a table based on the dataset in a data source.

When path is specified, an external table is created from the data at the given path. Otherwise a managed table is created.

Returns a DataFrame associated with the new table.

ParameterType
tableNamestring
options?{ description?: string; options?: Record<string, string>; path?: string; schema?: StructType; source?: string; }
options.description?string
options.options?Record<string, string>
options.path?string
options.schema?StructType
options.source?string

DataFrame


currentCatalog(): Promise<string>;

Defined in: catalog.ts:120

Get the current default catalog name.

Promise<string>


currentDatabase(): Promise<string>;

Defined in: catalog.ts:109

Get the current database name.

Promise<string>


databaseExists(dbName): Promise<boolean>;

Defined in: catalog.ts:79

Check if a database exists.

ParameterType
dbNamestring

Promise<boolean>


dropGlobalTempView(viewName): Promise<boolean>;

Defined in: catalog.ts:103

Drops the global temporary view. Returns true if the view existed.

ParameterType
viewNamestring

Promise<boolean>


dropTempView(viewName): Promise<boolean>;

Defined in: catalog.ts:97

Drops the local temporary view. Returns true if the view existed.

ParameterType
viewNamestring

Promise<boolean>


functionExists(functionName, dbName?): Promise<boolean>;

Defined in: catalog.ts:85

Check if a function exists.

ParameterType
functionNamestring
dbName?string

Promise<boolean>


getDatabase(dbName): DataFrame;

Defined in: catalog.ts:58

Get the database with the specified name. Returns a single-row DataFrame.

ParameterType
dbNamestring

DataFrame


getFunction(functionName, dbName?): DataFrame;

Defined in: catalog.ts:68

Get the function with the specified name. Returns a single-row DataFrame.

ParameterType
functionNamestring
dbName?string

DataFrame


getTable(tableName, dbName?): DataFrame;

Defined in: catalog.ts:63

Get the table or view with the specified name. Returns a single-row DataFrame.

ParameterType
tableNamestring
dbName?string

DataFrame


isCached(tableName): Promise<boolean>;

Defined in: catalog.ts:91

Returns true if the table is currently cached in-memory.

ParameterType
tableNamestring

Promise<boolean>


listCatalogs(pattern?): DataFrame;

Defined in: catalog.ts:53

List all catalogs. Returns a DataFrame with catalog metadata.

ParameterType
pattern?string

DataFrame


listColumns(tableName, dbName?): DataFrame;

Defined in: catalog.ts:43

List all columns of a table. Returns a DataFrame with column metadata.

ParameterType
tableNamestring
dbName?string

DataFrame


listDatabases(pattern?): DataFrame;

Defined in: catalog.ts:33

List all databases. Returns a DataFrame with database metadata.

ParameterType
pattern?string

DataFrame


listFunctions(dbName?, pattern?): DataFrame;

Defined in: catalog.ts:48

List all functions in a database. Returns a DataFrame with function metadata.

ParameterType
dbName?string
pattern?string

DataFrame


listTables(dbName?, pattern?): DataFrame;

Defined in: catalog.ts:38

List all tables in a database. Returns a DataFrame with table metadata.

ParameterType
dbName?string
pattern?string

DataFrame


recoverPartitions(tableName): Promise<void>;

Defined in: catalog.ts:156

Recover all partitions of the given table and update the catalog.

ParameterType
tableNamestring

Promise<void>


refreshByPath(path): Promise<void>;

Defined in: catalog.ts:151

Invalidate and refresh cached data for any DataFrame containing the given path.

ParameterType
pathstring

Promise<void>


refreshTable(tableName): Promise<void>;

Defined in: catalog.ts:146

Invalidate and refresh all cached data and metadata for the given table.

ParameterType
tableNamestring

Promise<void>


setCurrentCatalog(catalogName): Promise<void>;

Defined in: catalog.ts:126

Set the current default catalog.

ParameterType
catalogNamestring

Promise<void>


setCurrentDatabase(dbName): Promise<void>;

Defined in: catalog.ts:115

Set the current database.

ParameterType
dbNamestring

Promise<void>


tableExists(tableName, dbName?): Promise<boolean>;

Defined in: catalog.ts:73

Check if a table exists.

ParameterType
tableNamestring
dbName?string

Promise<boolean>


uncacheTable(tableName): Promise<void>;

Defined in: catalog.ts:136

Remove the specified table from the in-memory cache.

ParameterType
tableNamestring

Promise<void>