Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: remove the get_data_catalog() function #1941

Merged
merged 2 commits into from
Dec 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading