Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

View metadata builder #2

Open
wants to merge 4 commits into
base: release/iceberg-rest-server
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion crates/iceberg/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ lazy_static = { workspace = true }
log = { workspace = true }
murmur3 = { workspace = true }
once_cell = { workspace = true }
opendal = { workspace = true, features = ["services-s3"] }
opendal = { workspace = true, features = ["services-s3", "services-fs"] }
ordered-float = { workspace = true }
parquet = { workspace = true, features = ["async"] }
reqwest = { workspace = true }
Expand Down
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::*;
3 changes: 2 additions & 1 deletion crates/iceberg/src/spec/table_metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ pub static DEFAULT_SPEC_ID: i32 = 0;
pub static DEFAULT_SORT_ORDER_ID: i64 = 0;

pub(crate) static EMPTY_SNAPSHOT_ID: i64 = -1;
pub(crate) static INITIAL_SEQUENCE_NUMBER: i64 = 0;
// TODO: spark numbers from one and so does tabular
pub(crate) static INITIAL_SEQUENCE_NUMBER: i64 = 1;

/// Reference to [`TableMetadata`].
pub type TableMetadataRef = Arc<TableMetadata>;
Expand Down
Loading