Skip to content

Commit 1b9034d

Browse files
committed
[SPARK-52152] Fix Catalog.databaseExists to handle multi catalogs
1 parent 89b4b7d commit 1b9034d

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

Sources/SparkConnect/Catalog.swift

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,14 @@ public actor Catalog: Sendable {
197197
/// - Parameter dbName: name of the database to check existence
198198
/// - Returns: Indicating whether the database exists.
199199
public func databaseExists(_ dbName: String) async throws -> Bool {
200-
return try await self.listDatabases(pattern: dbName).count > 0
200+
let df = getDataFrame({
201+
var databaseExists = Spark_Connect_DatabaseExists()
202+
databaseExists.dbName = dbName
203+
var catalog = Spark_Connect_Catalog()
204+
catalog.catType = .databaseExists(databaseExists)
205+
return catalog
206+
})
207+
return try await df.collect().first![0] as! Bool
201208
}
202209

203210
/// Creates a table from the given path and returns the corresponding ``DataFrame``.

0 commit comments

Comments
 (0)