Skip to content

Commit 1c2a20b

Browse files
feat: implement prune column for schema (#261)
* 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
1 parent 0629ad5 commit 1c2a20b

File tree

2 files changed

+737
-3
lines changed

2 files changed

+737
-3
lines changed

crates/iceberg/src/spec/datatypes.rs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,21 @@ impl Type {
112112
matches!(self, Type::Struct(_))
113113
}
114114

115+
/// Whether the type is nested type.
116+
#[inline(always)]
117+
pub fn is_nested(&self) -> bool {
118+
matches!(self, Type::Struct(_) | Type::List(_) | Type::Map(_))
119+
}
120+
121+
/// Convert Type to StructType
122+
pub fn as_struct_type(self) -> Option<StructType> {
123+
if let Type::Struct(struct_type) = self {
124+
Some(struct_type)
125+
} else {
126+
None
127+
}
128+
}
129+
115130
/// Return max precision for decimal given [`num_bytes`] bytes.
116131
#[inline(always)]
117132
pub fn decimal_max_precision(num_bytes: u32) -> Result<u32> {
@@ -334,7 +349,7 @@ impl fmt::Display for PrimitiveType {
334349
}
335350

336351
/// DataType for a specific struct
337-
#[derive(Debug, Serialize, Clone)]
352+
#[derive(Debug, Serialize, Clone, Default)]
338353
#[serde(rename = "struct", tag = "type")]
339354
pub struct StructType {
340355
/// Struct fields

0 commit comments

Comments
 (0)