Skip to content

Commit

Permalink
feat: implement prune column for schema (#261)
Browse files Browse the repository at this point in the history
* feat: implement PruneColumn for Schema

* fix: fix bugs for PruneColumn implementation

* test: add test cases for PruneColumn

* fix: fix minor to make more rusty

* fix: fix cargo clippy

* fix: construct expected_type from SchemaBuilder

* fix: more readability

* change return type of prune_column
  • Loading branch information
Dysprosium0626 authored Mar 24, 2024
1 parent 0629ad5 commit 1c2a20b
Show file tree
Hide file tree
Showing 2 changed files with 737 additions and 3 deletions.
17 changes: 16 additions & 1 deletion crates/iceberg/src/spec/datatypes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,21 @@ impl Type {
matches!(self, Type::Struct(_))
}

/// Whether the type is nested type.
#[inline(always)]
pub fn is_nested(&self) -> bool {
matches!(self, Type::Struct(_) | Type::List(_) | Type::Map(_))
}

/// Convert Type to StructType
pub fn as_struct_type(self) -> Option<StructType> {
if let Type::Struct(struct_type) = self {
Some(struct_type)
} else {
None
}
}

/// Return max precision for decimal given [`num_bytes`] bytes.
#[inline(always)]
pub fn decimal_max_precision(num_bytes: u32) -> Result<u32> {
Expand Down Expand Up @@ -334,7 +349,7 @@ impl fmt::Display for PrimitiveType {
}

/// DataType for a specific struct
#[derive(Debug, Serialize, Clone)]
#[derive(Debug, Serialize, Clone, Default)]
#[serde(rename = "struct", tag = "type")]
pub struct StructType {
/// Struct fields
Expand Down
Loading

0 comments on commit 1c2a20b

Please sign in to comment.