pyspark.sql.Catalog.dropTable#

Catalog.dropTable(tableName, ifExists=False, purge=False)[source]#

Drops a persistent table.

This does not remove temp views; use Catalog.dropTempView().

New in version 4.2.0.

Parameters
tableNamestr

Name of the table to drop. May be qualified with catalog and database (namespace).

ifExistsbool, optional

If True, do not fail when the table does not exist.

purgebool, optional

If True, skip moving data to a trash directory when the catalog supports it.

Examples

>>> _ = spark.sql("DROP TABLE IF EXISTS tbl_drop_doc")
>>> _ = spark.sql("CREATE TABLE tbl_drop_doc (id INT) USING parquet")
>>> spark.catalog.dropTable("tbl_drop_doc")
>>> spark.catalog.tableExists("tbl_drop_doc")
False