Catalog.
databaseExists
Check if the database with the specified name exists.
New in version 3.3.0.
name of the database to check existence
Changed in version 3.4.0: Allow dbName to be qualified with catalog name.
dbName
Indicating whether the database exists
Examples
Check if ‘test_new_database’ database exists
>>> spark.catalog.databaseExists("test_new_database") False >>> _ = spark.sql("CREATE DATABASE test_new_database") >>> spark.catalog.databaseExists("test_new_database") True
Using the fully qualified name with the catalog name.
>>> spark.catalog.databaseExists("spark_catalog.test_new_database") True >>> _ = spark.sql("DROP DATABASE test_new_database")