Skip to main content

uncacheTable

Removes the specified table from the in-memory cache.

Syntax

uncacheTable(tableName: str)

Parameters

Parameter

Type

Description

tableName

str

Name of the table to get. Can be qualified with catalog name.

Notes

Cached data is shared across all Spark sessions on the cluster, so uncaching it affects all sessions.

Examples

Python
_ = spark.sql("DROP TABLE IF EXISTS tbl1")
_ = spark.sql("CREATE TABLE tbl1 (name STRING, age INT) USING parquet")
spark.catalog.cacheTable("tbl1")
spark.catalog.uncacheTable("tbl1")
spark.catalog.isCached("tbl1")
# False

# Throw an analysis exception when the table does not exist.
spark.catalog.uncacheTable("not_existing_table")
# Traceback (most recent call last):
# ...
# AnalysisException: ...

# Using the fully qualified name for the table.
spark.catalog.uncacheTable("spark_catalog.default.tbl1")
spark.catalog.isCached("tbl1")
# False
_ = spark.sql("DROP TABLE tbl1")