Skip to content

Commit e34c172

Browse files
committed
Thanks Drake
1 parent 53c1a5d commit e34c172

1 file changed

Lines changed: 11 additions & 16 deletions

File tree

kernel/src/actions/mod.rs

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -747,6 +747,9 @@ pub(crate) struct Add {
747747
pub stats: Option<String>,
748748

749749
/// Map containing metadata about this logical file.
750+
/// Note: map values can be null.
751+
/// We don't use #[allow_null_container_values] here because it drops null values
752+
/// during materialization
750753
#[cfg_attr(test, serde(skip_serializing_if = "Option::is_none"))]
751754
pub tags: Option<HashMap<String, Option<String>>>,
752755

@@ -2054,25 +2057,15 @@ mod tests {
20542057
assert!(!schema_contains_file_actions(&schema));
20552058
}
20562059

2057-
fn test_add_tags_deserialization() {
2058-
// Test different cases for the tags field:
2059-
// 1. tags field is null (entire field is None)
2060-
// 2. tags map contains nullable values (some keys map to null)
2061-
// 3. tags map contains non-null string values only
2062-
2063-
// Note about nullable values inside the tags map:
2064-
// The tags field type is Option<HashMap<String, Option<String>>>, which means:
2065-
// - The outer Option makes the entire field nullable (field can be absent or null)
2066-
// - The inner Option<String> makes individual map values nullable (value can be null)
2067-
// This preserves null values in the map, unlike #[allow_null_container_values]
2068-
// which would drop them during materialization.
2069-
2070-
// Case 1: tags field is null
2060+
#[test]
2061+
fn test_add_tags_deserialization_null_case() {
20712062
let json1 = r#"{"path":"file1.parquet","partitionValues":{},"size":100,"modificationTime":1234567890,"dataChange":true,"tags":null}"#;
20722063
let add1: Add = serde_json::from_str(json1).unwrap();
20732064
assert_eq!(add1.tags, None);
2065+
}
20742066

2075-
// Case 2: tags map contains nullable values (some keys map to null)
2067+
#[test]
2068+
fn test_add_tags_deserialization_nullable_values_case() {
20762069
let json2 = r#"{"path":"file2.parquet","partitionValues":{},"size":200,"modificationTime":1234567890,"dataChange":true,"tags":{"INSERTION_TIME":"1677811178336000","NULLABLE_TAG":null}}"#;
20772070
let add2: Add = serde_json::from_str(json2).unwrap();
20782071
assert!(add2.tags.is_some());
@@ -2083,8 +2076,10 @@ mod tests {
20832076
Some(&Some("1677811178336000".to_string()))
20842077
);
20852078
assert_eq!(tags.get("NULLABLE_TAG"), Some(&None));
2079+
}
20862080

2087-
// Case 3: tags map contains non-null string values only
2081+
#[test]
2082+
fn test_add_tags_deserialization_non_null_values_case() {
20882083
let json3 = r#"{"path":"file3.parquet","partitionValues":{},"size":300,"modificationTime":1234567890,"dataChange":true,"tags":{"INSERTION_TIME":"1677811178336000","MIN_INSERTION_TIME":"1677811178336000"}}"#;
20892084
let add3: Add = serde_json::from_str(json3).unwrap();
20902085
assert!(add3.tags.is_some());

0 commit comments

Comments
 (0)