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
dbNameonly, lists views in that namespace (may be catalog-qualified). Withpattern, filters view names with a SQLLIKEstring; ifpatternis given withoutdbName, the current database is used as the namespace.New in version 4.2.0.
- Parameters
- dbNamestr, optional
Namespace to list views from. May be qualified with catalog name.
- patternstr, optional
SQL
LIKEpattern for view names.
- Returns
- list
A list of
Table(same row shape asCatalog.listTables()).
Notes
Raises
AnalysisExceptionifdbNamenames 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")