Skip to content

Commit 3a4e01d

Browse files
authored
Merge pull request #157 from JanKaul/glue-catalog-list
create glue catalog list
2 parents b288630 + 8b08bce commit 3a4e01d

File tree

3 files changed

+38
-4
lines changed
  • catalogs
    • iceberg-file-catalog/src
    • iceberg-glue-catalog/src
  • iceberg-rust/src/table

3 files changed

+38
-4
lines changed

catalogs/iceberg-file-catalog/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -556,7 +556,7 @@ impl FileCatalog {
556556
});
557557
files
558558
.into_iter()
559-
.last()
559+
.next_back()
560560
.ok_or(IcebergError::CatalogNotFound)
561561
}
562562

@@ -588,7 +588,7 @@ fn trim_start_path(path: &str) -> &str {
588588

589589
fn parse_version(path: &str) -> Result<u64, IcebergError> {
590590
path.split('/')
591-
.last()
591+
.next_back()
592592
.ok_or(IcebergError::InvalidFormat("Metadata location".to_owned()))?
593593
.trim_start_matches('v')
594594
.trim_end_matches(".metadata.json")

catalogs/iceberg-glue-catalog/src/lib.rs

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ use iceberg_rust::{
2020
identifier::Identifier,
2121
namespace::Namespace,
2222
tabular::Tabular,
23-
Catalog,
23+
Catalog, CatalogList,
2424
},
2525
error::Error as IcebergError,
2626
materialized_view::MaterializedView,
@@ -948,6 +948,40 @@ impl Catalog for GlueCatalog {
948948
}
949949
}
950950

951+
#[derive(Debug, Clone)]
952+
pub struct GlueCatalogList {
953+
name: String,
954+
config: SdkConfig,
955+
object_store_builder: ObjectStoreBuilder,
956+
}
957+
958+
impl GlueCatalogList {
959+
pub fn new(name: &str, config: &SdkConfig, object_store_builder: ObjectStoreBuilder) -> Self {
960+
Self {
961+
name: name.to_owned(),
962+
config: config.to_owned(),
963+
object_store_builder,
964+
}
965+
}
966+
}
967+
968+
#[async_trait]
969+
impl CatalogList for GlueCatalogList {
970+
fn catalog(&self, name: &str) -> Option<Arc<dyn Catalog>> {
971+
if self.name == name {
972+
Some(Arc::new(
973+
GlueCatalog::new(&self.config, &self.name, self.object_store_builder.clone())
974+
.unwrap(),
975+
))
976+
} else {
977+
None
978+
}
979+
}
980+
async fn list_catalogs(&self) -> Vec<String> {
981+
vec![self.name.clone()]
982+
}
983+
}
984+
951985
#[cfg(test)]
952986
pub mod tests {
953987
use aws_config::{BehaviorVersion, Region};

iceberg-rust/src/table/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ impl Table {
192192
///
193193
/// # Returns
194194
/// * `Result<Vec<ManifestListEntry>, Error>` - Vector of manifest entries in the range,
195-
/// or an empty vector if no current snapshot exists
195+
/// or an empty vector if no current snapshot exists
196196
///
197197
/// # Errors
198198
/// Returns an error if:

0 commit comments

Comments
 (0)