Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 18 additions & 3 deletions datafusion/proto/src/physical_plan/from_proto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -660,7 +660,7 @@ impl TryFromProto<&protobuf::PartitionedFile> for PartitionedFile {
pf = pf.with_range(file_range.start, file_range.end);
}
if let Some(proto_stats) = val.statistics.as_ref() {
pf = pf.with_statistics(Arc::new(proto_stats.try_into()?));
pf.statistics = Some(Arc::new(proto_stats.try_into()?));
Comment thread
buraksenn marked this conversation as resolved.
}
Ok(pf)
}
Expand Down Expand Up @@ -807,8 +807,8 @@ impl datafusion_physical_expr_common::physical_expr::proto_decode::PhysicalExprD

#[cfg(test)]
mod tests {

use super::*;
use arrow::datatypes::{DataType, Field, Schema};

#[test]
fn partitioned_file_path_roundtrip_percent_encoded() {
Expand All @@ -833,7 +833,6 @@ mod tests {

#[test]
fn partitioned_file_arrow_schema_roundtrip() {
use arrow::datatypes::{DataType, Field, Schema};
use std::collections::HashMap;

let arrow_schema = Arc::new(Schema::new_with_metadata(
Expand All @@ -858,6 +857,22 @@ mod tests {
);
}

#[test]
fn partitioned_file_statistics_roundtrip_with_partition_values() {
use datafusion_common::Statistics;

let file_schema = Schema::new(vec![Field::new("a", DataType::Int32, true)]);
let pf = PartitionedFile::new("foo/bar.parquet", 1234)
.with_partition_values(vec![ScalarValue::from("2024-01-01")])
.with_statistics(Arc::new(Statistics::new_unknown(&file_schema)));
assert_eq!(pf.statistics.as_ref().unwrap().column_statistics.len(), 2);
Comment thread
buraksenn marked this conversation as resolved.
Outdated

let proto = protobuf::PartitionedFile::try_from_proto(&pf).unwrap();
let decoded = PartitionedFile::try_from_proto(&proto).unwrap();

assert_eq!(decoded.statistics, pf.statistics);
}

#[test]
fn partitioned_file_from_proto_invalid_path() {
let proto = protobuf::PartitionedFile {
Expand Down
Loading