pyspark.sql.Catalog.listTables¶
-
Catalog.
listTables
(dbName: Optional[str] = None, pattern: Optional[str] = None) → List[pyspark.sql.catalog.Table][source]¶ Returns a list of tables/views in the specified database.
New in version 2.0.0.
- Parameters
- dbNamestr
name of the database to list the tables.
Changed in version 3.4.0: Allow
dbName
to be qualified with catalog name.- patternstr
The pattern that the database name needs to match.
- Returns
- list
A list of
Table
.
Notes
If no database is specified, the current database and catalog are used. This API includes all temporary views.
Examples
>>> spark.range(1).createTempView("test_view") >>> spark.catalog.listTables() [Table(name='test_view', catalog=None, namespace=[], description=None, ...
>>> spark.catalog.listTables(pattern="test*") [Table(name='test_view', catalog=None, namespace=[], description=None, ...
>>> spark.catalog.listTables(pattern="table*") []
>>> _ = spark.catalog.dropTempView("test_view") >>> spark.catalog.listTables() []