use std::collections::HashSet;
use lance_namespace::NamespaceError;
pub mod connect;
pub mod context;
pub mod credentials;
pub mod dir;
#[cfg(feature = "rest")]
pub mod rest;
#[cfg(feature = "rest-adapter")]
pub mod rest_adapter;
pub use connect::ConnectBuilder;
pub use context::{DynamicContextProvider, OperationInfo};
pub use dir::{
DirectoryNamespace, DirectoryNamespaceBuilder, OpsMetrics, manifest::ManifestNamespace,
};
pub use credentials::{
CredentialVendor, DEFAULT_CREDENTIAL_DURATION_MILLIS, VendedCredentials,
create_credential_vendor_for_location, detect_provider_from_uri, has_credential_vendor_config,
redact_credential,
};
#[cfg(feature = "credential-vendor-aws")]
pub use credentials::aws::{AwsCredentialVendor, AwsCredentialVendorConfig};
#[cfg(feature = "credential-vendor-aws")]
pub use credentials::aws_props;
#[cfg(feature = "credential-vendor-gcp")]
pub use credentials::gcp::{GcpCredentialVendor, GcpCredentialVendorConfig};
#[cfg(feature = "credential-vendor-gcp")]
pub use credentials::gcp_props;
#[cfg(feature = "credential-vendor-azure")]
pub use credentials::azure::{AzureCredentialVendor, AzureCredentialVendorConfig};
#[cfg(feature = "credential-vendor-azure")]
pub use credentials::azure_props;
#[cfg(feature = "rest")]
pub use rest::{RestNamespace, RestNamespaceBuilder};
#[cfg(feature = "rest-adapter")]
pub use rest_adapter::{RestAdapter, RestAdapterConfig, RestAdapterHandle};
pub(crate) fn merge_insert_on_columns<'a>(
on: Option<&'a [String]>,
operation: &str,
) -> lance_core::Result<&'a [String]> {
let on = on.ok_or_else(|| {
lance_core::Error::from(NamespaceError::InvalidInput {
message: format!("'on' field is required for {}", operation),
})
})?;
if on.is_empty() {
return Err(NamespaceError::InvalidInput {
message: format!("'on' field must name at least one column for {}", operation),
}
.into());
}
let mut seen = HashSet::with_capacity(on.len());
if let Some(duplicate) = on.iter().find(|column| !seen.insert(*column)) {
return Err(NamespaceError::InvalidInput {
message: format!(
"'on' field for {} names column '{}' more than once: {:?}",
operation, duplicate, on
),
}
.into());
}
Ok(on)
}