Skip to content

Commit 8ec6921

Browse files
committed
[SPARK-52152] Fix Catalog.databaseExists to handle multi catalogs
### What changes were proposed in this pull request? This PR aims to fix `Catalog.databaseExists` to handle multi-catalogs. ### Why are the changes needed? To handle Iceberg catalog. ### Does this PR introduce _any_ user-facing change? No. ### How was this patch tested? Pass the CIs. Apache Iceberg CI will be added soon. ### Was this patch authored or co-authored using generative AI tooling? No. Closes #150 from dongjoon-hyun/SPARK-52152. Authored-by: Dongjoon Hyun <[email protected]> Signed-off-by: Dongjoon Hyun <[email protected]>
1 parent 89b4b7d commit 8ec6921

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)