pyspark.sql.Catalog.listViews#

Catalog.listViews(dbName=None, pattern=None)[source]#

Lists views in a namespace.

With no arguments, lists views in the current namespace. With dbName only, lists views in that namespace (may be catalog-qualified). With pattern, filters view names with a SQL LIKE string; if pattern is given without dbName, the current database is used as the namespace.

Added in version 4.2.0.

Parameters:
dbNamestr, optional

Namespace to list views from. May be qualified with catalog name.

patternstr, optional

SQL LIKE pattern for view names.

Returns:
list

A list of Table (same row shape as Catalog.listTables()).

Notes

Raises AnalysisException if dbName names a namespace that does not exist.

Examples

>>> _ = spark.sql("DROP VIEW IF EXISTS view_list_doc")
>>> _ = spark.sql("CREATE VIEW view_list_doc AS SELECT 1 AS c")
>>> "view_list_doc" in [v.name for v in spark.catalog.listViews()]
True
>>> "view_list_doc" in [v.name for v in spark.catalog.listViews(pattern="view_list_*")]
True
>>> _ = spark.sql("DROP VIEW view_list_doc")