From 9194419e891c2f3a7f18b4031c212a56ae396675 Mon Sep 17 00:00:00 2001 From: Rafael Fernandez Date: Sun, 29 Mar 2026 11:52:37 +0200 Subject: [PATCH] [SPARK-52428] Add ergonomic convenience methods for catalog and config APIs --- crates/connect/src/catalog.rs | 28 ++++++++++++++++++++++++++++ crates/connect/src/conf.rs | 7 +++++++ 2 files changed, 35 insertions(+) diff --git a/crates/connect/src/catalog.rs b/crates/connect/src/catalog.rs index 22ae1fe..b3605a6 100644 --- a/crates/connect/src/catalog.rs +++ b/crates/connect/src/catalog.rs @@ -78,6 +78,13 @@ impl Catalog { self.spark_session.client().execute_command(plan).await } + /// Returns a list of all catalogs in this session. + /// + /// Convenience method equivalent to `list_catalogs(None)`. + pub async fn list_all_catalogs(self) -> Result { + self.list_catalogs(None).await + } + /// Returns a list of catalogs in this session pub async fn list_catalogs(self, pattern: Option<&str>) -> Result { let pattern = pattern.map(|val| val.to_owned()); @@ -121,6 +128,13 @@ impl Catalog { self.spark_session.client().execute_command(plan).await } + /// Returns a list of all databases in this session. + /// + /// Convenience method equivalent to `list_databases(None)`. + pub async fn list_all_databases(self) -> Result { + self.list_databases(None).await + } + /// Returns a list of databases in this session pub async fn list_databases(self, pattern: Option<&str>) -> Result { let pattern = pattern.map(|val| val.to_owned()); @@ -166,6 +180,13 @@ impl Catalog { Catalog::arrow_to_bool(record) } + /// Returns a list of all tables/views in the current database. + /// + /// Convenience method equivalent to `list_tables(None, None)`. + pub async fn list_all_tables(self) -> Result { + self.list_tables(None, None).await + } + /// Returns a list of tables/views in the specific database pub async fn list_tables( self, @@ -198,6 +219,13 @@ impl Catalog { self.spark_session.client().to_arrow(plan).await } + /// Returns a list of all functions registered in the current database. + /// + /// Convenience method equivalent to `list_functions(None, None)`. + pub async fn list_all_functions(self) -> Result { + self.list_functions(None, None).await + } + /// Returns a list of functions registered in the specified database. pub async fn list_functions( self, diff --git a/crates/connect/src/conf.rs b/crates/connect/src/conf.rs index 7baa1bd..d0c02fa 100644 --- a/crates/connect/src/conf.rs +++ b/crates/connect/src/conf.rs @@ -123,6 +123,13 @@ impl RunTimeConfig { Ok(val) } + /// Get a configuration value by key, returning an error if not set. + /// + /// This is a convenience method equivalent to `get(key, None)`. + pub async fn get_value(&mut self, key: &str) -> Result { + self.get(key, None).await + } + /// Indicates whether the configuration property with the given key is modifiable in the current session. pub async fn is_modifable(&mut self, key: &str) -> Result { let op_type = spark::config_request::operation::OpType::IsModifiable(