pyspark.sql.Catalog.listTables#
- Catalog.listTables(dbName=None, pattern=None)[source]#
Returns a list of tables/views in the current database (namespace), or in the database given by
dbNamewhen provided (the name may be qualified with catalog).With
pattern, returns only tables and views whose name matches the pattern. This includes all temporary views.New in version 2.0.0.
- Parameters
- dbNamestr, optional
Database (namespace) to list tables from. If omitted, the current database is used.
Changed in version 3.4.0: Allow
dbNameto be qualified with catalog name.- patternstr, optional
Pattern that table names must match.
New in version 3.5.0.
- Returns
- list
A list of
Table.
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() []