Skip to content

Commit 708609c

Browse files
committed
Make tags' values optional
1 parent 5058bce commit 708609c

2 files changed

Lines changed: 9 additions & 2 deletions

File tree

kernel/src/actions/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -744,7 +744,7 @@ pub(crate) struct Add {
744744

745745
/// Map containing metadata about this logical file.
746746
#[cfg_attr(test, serde(skip_serializing_if = "Option::is_none"))]
747-
pub tags: Option<HashMap<String, String>>,
747+
pub tags: Option<HashMap<String, Option<String>>>,
748748

749749
/// Information about deletion vector (DV) associated with this add action
750750
#[cfg_attr(test, serde(skip_serializing_if = "Option::is_none"))]
@@ -1111,7 +1111,7 @@ mod tests {
11111111
StructField::nullable("stats", DataType::STRING),
11121112
StructField::nullable(
11131113
"tags",
1114-
MapType::new(DataType::STRING, DataType::STRING, false),
1114+
MapType::new(DataType::STRING, DataType::STRING, true),
11151115
),
11161116
deletion_vector_field(),
11171117
StructField::nullable("baseRowId", DataType::LONG),

kernel/src/schema/derive_macro_utils.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,13 @@ impl<K: ToDataType, V: ToDataType> ToDataType for HashMap<K, V> {
6666
}
6767
}
6868

69+
// ToDataType impl for maps with nullable values
70+
impl<K: ToDataType, V: ToDataType> ToDataType for HashMap<K, Option<V>> {
71+
fn to_data_type() -> DataType {
72+
MapType::new(K::to_data_type(), V::to_data_type(), true).into()
73+
}
74+
}
75+
6976
/// The [`delta_kernel_derive::ToSchema`] macro uses this to convert a struct field's name + type
7077
/// into a `StructField` definition. A blanket impl for `Option<T: ToDataType>` supports nullable
7178
/// struct fields, which otherwise default to non-nullable.

0 commit comments

Comments
 (0)