in crates/core/src/file_group/reader.rs [298:353]
fn test_create_filtering_mask_for_base_file_records() -> Result<()> {
let base_uri = "file:///non-existent-path/table";
let records = create_test_record_batch()?;
// Test case 1: No meta fields populated
let reader = FileGroupReader::new_with_options(
base_uri,
[
(HudiTableConfig::PopulatesMetaFields.as_ref(), "false"),
(HudiReadConfig::FileGroupStartTimestamp.as_ref(), "2"),
],
)?;
let mask = reader.create_filtering_mask_for_base_file_records(&records)?;
assert_eq!(mask, None, "Commit time filtering should not be needed");
// Test case 2: No commit time filtering options
let reader = FileGroupReader::new_with_options(base_uri, empty_options())?;
let mask = reader.create_filtering_mask_for_base_file_records(&records)?;
assert_eq!(mask, None);
// Test case 3: Filtering commit time > '2'
let reader = FileGroupReader::new_with_options(
base_uri,
[(HudiReadConfig::FileGroupStartTimestamp, "2")],
)?;
let mask = reader.create_filtering_mask_for_base_file_records(&records)?;
assert_eq!(
mask,
Some(BooleanArray::from(vec![false, false, true, true, true])),
"Expected only records with commit_time > '2'"
);
// Test case 4: Filtering commit time <= '4'
let reader = FileGroupReader::new_with_options(
base_uri,
[(HudiReadConfig::FileGroupEndTimestamp, "4")],
)?;
let mask = reader.create_filtering_mask_for_base_file_records(&records)?;
assert_eq!(mask, None, "Commit time filtering should not be needed");
// Test case 5: Filtering commit time > '2' and <= '4'
let reader = FileGroupReader::new_with_options(
base_uri,
[
(HudiReadConfig::FileGroupStartTimestamp, "2"),
(HudiReadConfig::FileGroupEndTimestamp, "4"),
],
)?;
let mask = reader.create_filtering_mask_for_base_file_records(&records)?;
assert_eq!(
mask,
Some(BooleanArray::from(vec![false, false, true, true, false])),
"Expected only records with commit_time > '2' and <= '4'"
);
Ok(())
}