Skip to content

Commit

Permalink
fallback to main branch of source table
Browse files Browse the repository at this point in the history
  • Loading branch information
JanKaul committed Feb 14, 2024
1 parent cf68f27 commit b7d9417
Showing 1 changed file with 19 additions and 8 deletions.
27 changes: 19 additions & 8 deletions datafusion_iceberg/src/materialized_view.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,15 +92,26 @@ pub async fn refresh_materialized_view(
Tabular::Table(table) => Ok(*table
.metadata()
.current_snapshot(branch.as_deref())?
.unwrap()
.snapshot_id()),
Tabular::MaterializedView(mv) => Ok(*mv
.storage_table()
.await?
.table_metadata
.current_snapshot(branch.as_deref())?
.unwrap()
// Fallback to main branch
.or(table.metadata().current_snapshot(None)?)
.ok_or(Error::NotFound(
"Snapshot in source table".to_owned(),
format!("{}", &identifier.table_name()),
))?
.snapshot_id()),
Tabular::MaterializedView(mv) => {
let storage_table = mv.storage_table().await?;
Ok(*storage_table
.table_metadata
.current_snapshot(branch.as_deref())?
// Fallback to main branch
.or(storage_table.table_metadata.current_snapshot(None)?)
.ok_or(Error::NotFound(
"Snapshot in source table".to_owned(),
format!("{}", &identifier.table_name()),
))?
.snapshot_id())
}
_ => Err(Error::InvalidFormat("storage table".to_string())),
}?;

Expand Down

0 comments on commit b7d9417

Please sign in to comment.