Skip to content

Commit

Permalink
Remove the get_data_catalog() function
Browse files Browse the repository at this point in the history
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
  • Loading branch information
rtyler committed Dec 5, 2023
1 parent bca00ae commit 69fc43a
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 58 deletions.
33 changes: 1 addition & 32 deletions crates/deltalake-core/src/data_catalog/mod.rs
Original file line number Diff line number Diff line change
@@ -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::*;
Expand Down Expand Up @@ -125,34 +125,3 @@ pub trait DataCatalog: Send + Sync + Debug {
table_name: &str,
) -> Result<String, DataCatalogError>;
}

/// Get the Data Catalog
pub fn get_data_catalog(
data_catalog: &str,
#[allow(unused)] options: Option<HashMap<String, String>>,
) -> Result<Box<dyn DataCatalog>, 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(),
}),
}
}
2 changes: 1 addition & 1 deletion crates/deltalake-core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::*;
Expand Down
27 changes: 2 additions & 25 deletions python/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<String>,
catalog_options: Option<HashMap<String, String>>,
) -> PyResult<String> {
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<String> {
Ok(self._table.table_uri())
}
Expand Down

0 comments on commit 69fc43a

Please sign in to comment.