From 69fc43a5860f508562010c91ba989cde5afe6ca2 Mon Sep 17 00:00:00 2001 From: "R. Tyler Croy" Date: Mon, 4 Dec 2023 23:00:21 -0800 Subject: [PATCH] Remove the get_data_catalog() function This is related to #1713 and #1860 insofar that it removes the `get_data_catalog()` function. This is being done separately from the sub-crates work since it's easy enough to remove and frankly doesn't work properly anyways for Python users, which is the only caller we currently have in our codebase Fixes #1860 --- crates/deltalake-core/src/data_catalog/mod.rs | 33 +------------------ crates/deltalake-core/src/lib.rs | 2 +- python/src/lib.rs | 27 ++------------- 3 files changed, 4 insertions(+), 58 deletions(-) diff --git a/crates/deltalake-core/src/data_catalog/mod.rs b/crates/deltalake-core/src/data_catalog/mod.rs index db05e429bb..6160b78768 100644 --- a/crates/deltalake-core/src/data_catalog/mod.rs +++ b/crates/deltalake-core/src/data_catalog/mod.rs @@ -1,6 +1,6 @@ //! Catalog abstraction for Delta Table -use std::{collections::HashMap, fmt::Debug}; +use std::fmt::Debug; #[cfg(feature = "unity-experimental")] pub use unity::*; @@ -125,34 +125,3 @@ pub trait DataCatalog: Send + Sync + Debug { table_name: &str, ) -> Result; } - -/// Get the Data Catalog -pub fn get_data_catalog( - data_catalog: &str, - #[allow(unused)] options: Option>, -) -> Result, DataCatalogError> { - match data_catalog { - #[cfg(feature = "gcp")] - "gcp" => unimplemented!("GCP Data Catalog is not implemented"), - #[cfg(feature = "azure")] - "azure" => unimplemented!("Azure Data Catalog is not implemented"), - #[cfg(feature = "hdfs")] - "hdfs" => unimplemented!("HDFS Data Catalog is not implemented"), - #[cfg(any(feature = "glue", feature = "glue-native-tls"))] - "glue" => Ok(Box::new(glue::GlueDataCatalog::new()?)), - #[cfg(feature = "unity-experimental")] - "unity" => { - let catalog = if let Some(opts) = options { - unity::UnityCatalogBuilder::default() - .try_with_options(opts)? - .build() - } else { - unity::UnityCatalogBuilder::from_env().build() - }?; - Ok(Box::new(catalog)) - } - _ => Err(DataCatalogError::InvalidDataCatalog { - data_catalog: data_catalog.to_string(), - }), - } -} diff --git a/crates/deltalake-core/src/lib.rs b/crates/deltalake-core/src/lib.rs index 312e4d6429..a9d7a968d7 100644 --- a/crates/deltalake-core/src/lib.rs +++ b/crates/deltalake-core/src/lib.rs @@ -105,7 +105,7 @@ pub mod writer; use std::collections::HashMap; -pub use self::data_catalog::{get_data_catalog, DataCatalog, DataCatalogError}; +pub use self::data_catalog::{DataCatalog, DataCatalogError}; pub use self::errors::*; pub use self::schema::partitions::*; pub use self::schema::*; diff --git a/python/src/lib.rs b/python/src/lib.rs index 5741bd40d2..95957dd32f 100644 --- a/python/src/lib.rs +++ b/python/src/lib.rs @@ -41,9 +41,9 @@ use deltalake::partitions::PartitionFilter; use deltalake::protocol::{ColumnCountStat, ColumnValueStat, DeltaOperation, SaveMode, Stats}; use deltalake::DeltaOps; use deltalake::DeltaTableBuilder; -use pyo3::exceptions::{PyIOError, PyRuntimeError, PyValueError}; +use pyo3::exceptions::{PyRuntimeError, PyValueError}; use pyo3::prelude::*; -use pyo3::types::{PyFrozenSet, PyType}; +use pyo3::types::PyFrozenSet; use serde_json::{Map, Value}; use crate::error::DeltaProtocolError; @@ -123,29 +123,6 @@ impl RawDeltaTable { }) } - #[classmethod] - #[pyo3(signature = (data_catalog, database_name, table_name, data_catalog_id, catalog_options = None))] - fn get_table_uri_from_data_catalog( - _cls: &PyType, - data_catalog: &str, - database_name: &str, - table_name: &str, - data_catalog_id: Option, - catalog_options: Option>, - ) -> PyResult { - let data_catalog = deltalake::data_catalog::get_data_catalog(data_catalog, catalog_options) - .map_err(|e| PyValueError::new_err(format!("{}", e)))?; - let table_uri = rt()? - .block_on(data_catalog.get_table_storage_location( - data_catalog_id, - database_name, - table_name, - )) - .map_err(|err| PyIOError::new_err(err.to_string()))?; - - Ok(table_uri) - } - pub fn table_uri(&self) -> PyResult { Ok(self._table.table_uri()) }