Skip to content

Commit f3d0287

Browse files
committed
add test
1 parent db3e969 commit f3d0287

2 files changed

Lines changed: 50 additions & 3 deletions

File tree

kernel/src/actions/deletion_vector.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use crate::utils::require;
1515
use crate::{DeltaResult, Error, StorageHandler};
1616

1717
#[derive(Debug, PartialEq, Eq, Clone, Copy)]
18-
#[cfg_attr(test, derive(serde::Serialize))]
18+
#[cfg_attr(test, derive(serde::Serialize, serde::Deserialize))]
1919
pub enum DeletionVectorStorageType {
2020
#[cfg_attr(test, serde(rename = "u"))]
2121
PersistedRelative,
@@ -58,7 +58,7 @@ impl ToDataType for DeletionVectorStorageType {
5858
}
5959

6060
#[derive(Debug, Clone, PartialEq, Eq, ToSchema)]
61-
#[cfg_attr(test, derive(serde::Serialize), serde(rename_all = "camelCase"))]
61+
#[cfg_attr(test, derive(serde::Serialize, serde::Deserialize), serde(rename_all = "camelCase"))]
6262
pub struct DeletionVectorDescriptor {
6363
/// A single character to indicate how to access the DV. Legal options are: ['u', 'i', 'p'].
6464
pub storage_type: DeletionVectorStorageType,

kernel/src/actions/mod.rs

Lines changed: 48 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -683,7 +683,7 @@ impl IntoEngineData for CommitInfo {
683683
}
684684

685685
#[derive(Debug, Clone, PartialEq, Eq, ToSchema)]
686-
#[cfg_attr(test, derive(Serialize, Default), serde(rename_all = "camelCase"))]
686+
#[cfg_attr(test, derive(Serialize, Deserialize, Default), serde(rename_all = "camelCase"))]
687687
#[internal_api]
688688
pub(crate) struct Add {
689689
/// A relative path to a data file from the root of the table or an absolute path to a file
@@ -1974,4 +1974,51 @@ mod tests {
19741974
assert!(record_batch.column(2).is_null(0));
19751975
assert!(record_batch.column(3).is_null(0));
19761976
}
1977+
1978+
#[test]
1979+
fn test_add_tags_deserialization() {
1980+
// Test different cases for the tags field:
1981+
// 1. tags field is null (entire field is None)
1982+
// 2. tags map contains nullable values (some keys map to null)
1983+
// 3. tags map contains non-null string values only
1984+
1985+
// Note about nullable values inside the tags map:
1986+
// The tags field type is Option<HashMap<String, Option<String>>>, which means:
1987+
// - The outer Option makes the entire field nullable (field can be absent or null)
1988+
// - The inner Option<String> makes individual map values nullable (value can be null)
1989+
// This preserves null values in the map, unlike #[allow_null_container_values]
1990+
// which would drop them during materialization.
1991+
1992+
// Case 1: tags field is null
1993+
let json1 = r#"{"path":"file1.parquet","partitionValues":{},"size":100,"modificationTime":1234567890,"dataChange":true,"tags":null}"#;
1994+
let add1: Add = serde_json::from_str(json1).unwrap();
1995+
assert_eq!(add1.tags, None);
1996+
1997+
// Case 2: tags map contains nullable values (some keys map to null)
1998+
let json2 = r#"{"path":"file2.parquet","partitionValues":{},"size":200,"modificationTime":1234567890,"dataChange":true,"tags":{"INSERTION_TIME":"1677811178336000","NULLABLE_TAG":null}}"#;
1999+
let add2: Add = serde_json::from_str(json2).unwrap();
2000+
assert!(add2.tags.is_some());
2001+
let tags = add2.tags.unwrap();
2002+
assert_eq!(tags.len(), 2);
2003+
assert_eq!(
2004+
tags.get("INSERTION_TIME"),
2005+
Some(&Some("1677811178336000".to_string()))
2006+
);
2007+
assert_eq!(tags.get("NULLABLE_TAG"), Some(&None));
2008+
2009+
// Case 3: tags map contains non-null string values only
2010+
let json3 = r#"{"path":"file3.parquet","partitionValues":{},"size":300,"modificationTime":1234567890,"dataChange":true,"tags":{"INSERTION_TIME":"1677811178336000","MIN_INSERTION_TIME":"1677811178336000"}}"#;
2011+
let add3: Add = serde_json::from_str(json3).unwrap();
2012+
assert!(add3.tags.is_some());
2013+
let tags = add3.tags.unwrap();
2014+
assert_eq!(tags.len(), 2);
2015+
assert_eq!(
2016+
tags.get("INSERTION_TIME"),
2017+
Some(&Some("1677811178336000".to_string()))
2018+
);
2019+
assert_eq!(
2020+
tags.get("MIN_INSERTION_TIME"),
2021+
Some(&Some("1677811178336000".to_string()))
2022+
);
2023+
}
19772024
}

0 commit comments

Comments
 (0)