This is an automated email from the ASF dual-hosted git repository.

yihua pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/hudi-rs.git


The following commit(s) were added to refs/heads/main by this push:
     new a5bee299 test(core): pin the merge order of column stats lookups 
(#1078)
a5bee299 is described below

commit a5bee2995694d45152080e88849a30dfe612cd51
Author: Y Ethan Guo <[email protected]>
AuthorDate: Sat Dec 5 12:33:14 2026 -0800

    test(core): pin the merge order of column stats lookups (#1078)
    
    Both column stats lookup paths merge every base before any log block. A
    tight-bound log record replaces a base value rather than widening it, so
    the order decides the result; a test now covers both paths. Also puts a
    test's doc comment back on its test.
---
 crates/core/src/table/mod.rs      |  4 +--
 crates/core/src/write/metadata.rs | 59 +++++++++++++++++++++++++++------------
 2 files changed, 43 insertions(+), 20 deletions(-)

diff --git a/crates/core/src/table/mod.rs b/crates/core/src/table/mod.rs
index c5db302a..28871cce 100644
--- a/crates/core/src/table/mod.rs
+++ b/crates/core/src/table/mod.rs
@@ -5834,8 +5834,6 @@ mod tests {
         Ok(())
     }
 
-    /// A plan that fails on its filters returns once the schema is read, 
rather
-    /// than after the metadata table opens alongside it.
     /// A table whose schema history the reader refuses stops planning once the
     /// refusal is known, rather than finishing the plan it would discard.
     #[tokio::test]
@@ -5866,6 +5864,8 @@ mod tests {
         Ok(())
     }
 
+    /// A plan that fails on its filters returns once the schema is read, 
rather
+    /// than after the metadata table opens alongside it.
     #[tokio::test]
     async fn 
a_plan_with_an_invalid_filter_fails_without_waiting_for_the_metadata_table()
     -> Result<()> {
diff --git a/crates/core/src/write/metadata.rs 
b/crates/core/src/write/metadata.rs
index 0fdbaad0..1c9bc22d 100644
--- a/crates/core/src/write/metadata.rs
+++ b/crates/core/src/write/metadata.rs
@@ -2312,11 +2312,12 @@ mod tests {
     }
 
     /// Keys with records in a base and in several logs merge in slice order,
-    /// whatever order the files are fetched in: a tombstone wins over the
-    /// records before it and yields to the ones after it, and non-tight ranges
-    /// union.
+    /// whatever order the files are fetched in, through both the streaming
+    /// load and a [`ColumnStatsSource`]: every base before any log, a
+    /// tombstone wins over the records before it and yields to the ones after
+    /// it, a tight-bound log replaces a wider base, and non-tight ranges 
union.
     #[tokio::test]
-    async fn test_load_column_stats_records_merges_in_slice_order() {
+    async fn test_column_stats_lookups_merge_in_slice_order() {
         fn stats(range: Option<(i64, i64)>, tight: bool) -> 
ColumnStatsMetadata {
             ColumnStatsMetadata {
                 file_name: "f.parquet".to_string(),
@@ -2376,6 +2377,7 @@ mod tests {
                 hfile(&[
                     ("key0", stats(Some((1, 5)), false)),
                     ("key1", stats(Some((1, 5)), false)),
+                    ("key3", stats(Some((1, 9)), false)),
                 ]),
             ),
             (
@@ -2385,6 +2387,7 @@ mod tests {
                     &[
                         ("key0", stats(Some((8, 9)), false)),
                         ("key1", stats(None, false)),
+                        ("key3", stats(Some((3, 4)), true)),
                     ],
                 ),
             ),
@@ -2422,7 +2425,7 @@ mod tests {
         }
         let storage =
             
Storage::new_with_base_url(url::Url::from_directory_path(dir.path()).unwrap()).unwrap();
-        let wanted: HashMap<String, (String, String)> = ["key0", "key1", 
"key2"]
+        let wanted: HashMap<String, (String, String)> = ["key0", "key1", 
"key2", "key3"]
             .into_iter()
             .map(|key| (key.to_string(), (String::new(), String::new())))
             .collect();
@@ -2431,7 +2434,7 @@ mod tests {
 
         let configs = std::sync::Arc::new(crate::config::HudiConfigs::empty());
         for concurrency in [1, 4] {
-            let merged = load_column_stats_records(
+            let loaded = load_column_stats_records(
                 storage.clone(),
                 configs.clone(),
                 &wanted,
@@ -2441,18 +2444,38 @@ mod tests {
             )
             .await
             .unwrap();
-            let range = |key: &str| {
-                let stats = &merged[key];
-                (
-                    stats.is_deleted,
-                    stats.min_value.clone(),
-                    stats.max_value.clone(),
-                )
-            };
-            let long = |v: i64| Some(ColumnStatValue::Long(v));
-            assert_eq!(range("key0"), (false, long(0), long(9)), 
"{concurrency}");
-            assert_eq!(range("key1"), (false, long(7), long(8)), 
"{concurrency}");
-            assert!(range("key2").0, "{concurrency}: the later tombstone 
wins");
+            let looked_up = ColumnStatsSource::read(
+                storage.clone(),
+                configs.clone(),
+                &valid_instants,
+                None,
+                concurrency,
+                None,
+            )
+            .await
+            .unwrap()
+            .lookup(&wanted)
+            .unwrap();
+            for (path, merged) in [("load", &loaded), ("source", &looked_up)] {
+                let range = |key: &str| {
+                    let stats = &merged[key];
+                    (
+                        stats.is_deleted,
+                        stats.min_value.clone(),
+                        stats.max_value.clone(),
+                    )
+                };
+                let long = |v: i64| Some(ColumnStatValue::Long(v));
+                let case = format!("{path}, concurrency {concurrency}");
+                assert_eq!(range("key0"), (false, long(0), long(9)), "{case}");
+                assert_eq!(range("key1"), (false, long(7), long(8)), "{case}");
+                assert!(range("key2").0, "{case}: the later tombstone wins");
+                assert_eq!(
+                    range("key3"),
+                    (false, long(3), long(4)),
+                    "{case}: the tight-bound log replaces the wider base"
+                );
+            }
         }
     }
 

Reply via email to