Skip to content

Commit

Permalink
view metadata builder
Browse files Browse the repository at this point in the history
  • Loading branch information
twuebi committed Jul 5, 2024
1 parent cf3c1f2 commit 1e0d8bc
Show file tree
Hide file tree
Showing 5 changed files with 455 additions and 50 deletions.
60 changes: 59 additions & 1 deletion crates/iceberg/src/catalog/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

use crate::spec::{
FormatVersion, Schema, Snapshot, SnapshotReference, SortOrder, TableMetadataBuilder,
UnboundPartitionSpec, ViewRepresentation,
UnboundPartitionSpec, ViewRepresentation, ViewVersion,
};
use crate::table::Table;
use crate::{Error, ErrorKind, Result};
Expand Down Expand Up @@ -463,6 +463,64 @@ pub struct ViewCreation {
pub summary: HashMap<String, String>,
}

/// ViewUpdate represents an update to a view in the catalog.
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
#[serde(tag = "action", rename_all = "kebab-case")]
pub enum ViewUpdate {
/// Assign a new UUID to the view
#[serde(rename_all = "kebab-case")]
AssignUuid {
/// The new UUID to assign.
uuid: uuid::Uuid,
},
/// Upgrade view's format version
#[serde(rename_all = "kebab-case")]
UpgradeFormatVersion {
/// Target format upgrade to.
format_version: i32,
},
/// Add a new schema to the view
#[serde(rename_all = "kebab-case")]
AddSchema {
/// The schema to add.
schema: Schema,
/// The last column id of the view.
last_column_id: Option<i32>,
},
/// Set view's current schema
#[serde(rename_all = "kebab-case")]
SetLocation {
/// New location for view.
location: String,
},
/// Set view's properties
///
/// Matching keys are updated, and non-matching keys are left unchanged.
#[serde(rename_all = "kebab-case")]
SetProperties {
/// Properties to update for view.
updates: HashMap<String, String>,
},
/// Remove view's properties
#[serde(rename_all = "kebab-case")]
RemoveProperties {
/// Properties to remove
removals: Vec<String>,
},
/// Add a new version to the view
#[serde(rename_all = "kebab-case")]
AddViewVersion {
/// The view version to add.
view_version: ViewVersion,
},
/// Set view's current version
#[serde(rename_all = "kebab-case")]
SetCurrentViewVersion {
/// View version id to set as current, or -1 to set last added version
view_version_id: i32,
},
}

#[cfg(test)]
mod tests {
use crate::spec::{
Expand Down
1 change: 1 addition & 0 deletions crates/iceberg/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ pub use catalog::TableIdent;
pub use catalog::TableRequirement;
pub use catalog::TableUpdate;
pub use catalog::ViewCreation;
pub use catalog::ViewUpdate;

#[allow(dead_code)]
pub mod table;
Expand Down
1 change: 0 additions & 1 deletion crates/iceberg/src/spec/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,3 @@ pub use transform::*;
pub use values::*;
pub use view_metadata::*;
pub use view_version::*;
// pub use view_metadata::*;
Loading

0 comments on commit 1e0d8bc

Please sign in to comment.