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.

Parameter Type
tableName string
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.

Parameter Type
tableName string
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.

Parameter Type
tableName string
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.

Parameter Type
dbName string

Promise<boolean>


dropGlobalTempView(viewName): Promise<boolean>;

Defined in: catalog.ts:103

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

Parameter Type
viewName string

Promise<boolean>


dropTempView(viewName): Promise<boolean>;

Defined in: catalog.ts:97

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

Parameter Type
viewName string

Promise<boolean>


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

Defined in: catalog.ts:85

Check if a function exists.

Parameter Type
functionName string
dbName? string

Promise<boolean>


getDatabase(dbName): DataFrame;

Defined in: catalog.ts:58

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

Parameter Type
dbName string

DataFrame


getFunction(functionName, dbName?): DataFrame;

Defined in: catalog.ts:68

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

Parameter Type
functionName string
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.

Parameter Type
tableName string
dbName? string

DataFrame


isCached(tableName): Promise<boolean>;

Defined in: catalog.ts:91

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

Parameter Type
tableName string

Promise<boolean>


listCatalogs(pattern?): DataFrame;

Defined in: catalog.ts:53

List all catalogs. Returns a DataFrame with catalog metadata.

Parameter Type
pattern? string

DataFrame


listColumns(tableName, dbName?): DataFrame;

Defined in: catalog.ts:43

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

Parameter Type
tableName string
dbName? string

DataFrame


listDatabases(pattern?): DataFrame;

Defined in: catalog.ts:33

List all databases. Returns a DataFrame with database metadata.

Parameter Type
pattern? string

DataFrame


listFunctions(dbName?, pattern?): DataFrame;

Defined in: catalog.ts:48

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

Parameter Type
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.

Parameter Type
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.

Parameter Type
tableName string

Promise<void>


refreshByPath(path): Promise<void>;

Defined in: catalog.ts:151

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

Parameter Type
path string

Promise<void>


refreshTable(tableName): Promise<void>;

Defined in: catalog.ts:146

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

Parameter Type
tableName string

Promise<void>


setCurrentCatalog(catalogName): Promise<void>;

Defined in: catalog.ts:126

Set the current default catalog.

Parameter Type
catalogName string

Promise<void>


setCurrentDatabase(dbName): Promise<void>;

Defined in: catalog.ts:115

Set the current database.

Parameter Type
dbName string

Promise<void>


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

Defined in: catalog.ts:73

Check if a table exists.

Parameter Type
tableName string
dbName? string

Promise<boolean>


uncacheTable(tableName): Promise<void>;

Defined in: catalog.ts:136

Remove the specified table from the in-memory cache.

Parameter Type
tableName string

Promise<void>