pyspark.sql.Catalog.listCachedTables#

Catalog.listCachedTables()[source]#

Lists named in-memory cache entries (same as SHOW CACHED TABLES).

Includes caches registered with CACHE TABLE or cacheTable(). Caches from cache() without a name are not listed.

New in version 4.2.0.

Returns
list

A list of CachedTable describing each named cache entry.

Examples

>>> _ = spark.sql("DROP TABLE IF EXISTS tbl_cached_list")
>>> _ = spark.sql("CREATE TABLE tbl_cached_list (id INT) USING parquet")
>>> spark.catalog.clearCache()
>>> spark.catalog.listCachedTables()
[]
>>> spark.catalog.cacheTable("tbl_cached_list")
>>> any("tbl_cached_list" in ct.name for ct in spark.catalog.listCachedTables())
True
>>> spark.catalog.uncacheTable("tbl_cached_list")
>>> _ = spark.sql("DROP TABLE tbl_cached_list")