Skip to content

Commit

Permalink
strip prefix
Browse files Browse the repository at this point in the history
  • Loading branch information
JanKaul committed Jan 24, 2024
1 parent 182bf8b commit 72981eb
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 18 deletions.
16 changes: 11 additions & 5 deletions iceberg-rust/src/materialized_view/storage_table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,13 @@ use std::{
};

use futures::{stream, StreamExt, TryStreamExt};
use iceberg_rust_spec::spec::{
manifest::DataFile,
materialized_view_metadata::{BaseTable, VersionId},
table_metadata::{new_metadata_location, TableMetadataBuilder},
use iceberg_rust_spec::{
spec::{
manifest::DataFile,
materialized_view_metadata::{BaseTable, VersionId},
table_metadata::{new_metadata_location, TableMetadataBuilder},
},
util::strip_prefix,
};
use itertools::intersperse;

Expand Down Expand Up @@ -159,7 +162,10 @@ impl StorageTable {
let bytes = serde_json::to_vec(&table_metadata)?;

object_store
.put(&metadata_location.clone().into(), bytes.into())
.put(
&strip_prefix(&metadata_location.clone()).into(),
bytes.into(),
)
.await?;
let mut table = if let Tabular::Table(table) = table_catalog
.update_table(
Expand Down
16 changes: 9 additions & 7 deletions iceberg-rust/src/materialized_view/transaction/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
*/

use futures::{StreamExt, TryStreamExt};
use iceberg_rust_spec::spec::{
materialized_view_metadata::MaterializedViewRepresentation, types::StructType,
use iceberg_rust_spec::{
spec::{materialized_view_metadata::MaterializedViewRepresentation, types::StructType},
util::strip_prefix,
};
use object_store::path::Path;
use uuid::Uuid;

use crate::{
Expand Down Expand Up @@ -70,15 +70,17 @@ impl<'view> Transaction<'view> {
let transaction_uuid = Uuid::new_v4();
let version = &&materialized_view.metadata().current_version_id;
let metadata_json = serde_json::to_string(&materialized_view.metadata())?;
let metadata_file_location: Path = (location.to_string()
let metadata_file_location = location.to_string()
+ "/metadata/"
+ &version.to_string()
+ "-"
+ &transaction_uuid.to_string()
+ ".metadata.json")
.into();
+ ".metadata.json";
object_store
.put(&metadata_file_location, metadata_json.into())
.put(
&strip_prefix(&metadata_file_location).into(),
metadata_json.into(),
)
.await?;
let previous_metadata_file_location = materialized_view.metadata_location();
if let Tabular::MaterializedView(new_mv) = catalog
Expand Down
16 changes: 10 additions & 6 deletions iceberg-rust/src/view/transaction/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@
*/

use futures::{StreamExt, TryStreamExt};
use object_store::path::Path;
use uuid::Uuid;

pub mod operation;
use iceberg_rust_spec::spec::{types::StructType, view_metadata::ViewRepresentation};
use iceberg_rust_spec::{
spec::{types::StructType, view_metadata::ViewRepresentation},
util::strip_prefix,
};

use crate::{
catalog::{bucket::parse_bucket, tabular::Tabular},
Expand Down Expand Up @@ -72,15 +74,17 @@ impl<'view> Transaction<'view> {
let transaction_uuid = Uuid::new_v4();
let version = &&view.metadata().current_version_id;
let metadata_json = serde_json::to_string(&view.metadata())?;
let metadata_file_location: Path = (location.to_string()
let metadata_file_location = location.to_string()
+ "/metadata/"
+ &version.to_string()
+ "-"
+ &transaction_uuid.to_string()
+ ".metadata.json")
.into();
+ ".metadata.json";
object_store
.put(&metadata_file_location, metadata_json.into())
.put(
&strip_prefix(&metadata_file_location).into(),
metadata_json.into(),
)
.await?;
let previous_metadata_file_location = view.metadata_location();
if let Tabular::View(new_view) = catalog
Expand Down

0 comments on commit 72981eb

Please sign in to comment.