Skip to content

Commit dd8025f

Browse files
committed
Add failing test for partitioned_by_file_group protobuf roundtrip
1 parent c8b784a commit dd8025f

1 file changed

Lines changed: 48 additions & 0 deletions

File tree

datafusion/proto/tests/cases/roundtrip_physical_plan.rs

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3872,3 +3872,51 @@ fn test_sort_topk_with_dynamic_filter_roundtrip() -> Result<()> {
38723872

38733873
Ok(())
38743874
}
3875+
3876+
#[test]
3877+
fn roundtrip_parquet_exec_partitioned_by_file_group() -> Result<()> {
3878+
use datafusion::datasource::physical_plan::FileScanConfig;
3879+
3880+
let file_schema =
3881+
Arc::new(Schema::new(vec![Field::new("col", DataType::Utf8, false)]));
3882+
let file_source = Arc::new(ParquetSource::new(Arc::clone(&file_schema)));
3883+
let scan_config =
3884+
FileScanConfigBuilder::new(ObjectStoreUrl::local_filesystem(), file_source)
3885+
.with_file_groups(vec![FileGroup::new(vec![PartitionedFile::new(
3886+
"/path/to/file.parquet".to_string(),
3887+
1024,
3888+
)])])
3889+
.with_partitioned_by_file_group(true)
3890+
.build();
3891+
3892+
assert!(scan_config.partitioned_by_file_group);
3893+
3894+
let exec_plan: Arc<dyn ExecutionPlan> = DataSourceExec::from_data_source(scan_config);
3895+
3896+
let ctx = SessionContext::new();
3897+
let codec = DefaultPhysicalExtensionCodec {};
3898+
let proto_converter = DefaultPhysicalProtoConverter {};
3899+
let bytes = physical_plan_to_bytes_with_proto_converter(
3900+
Arc::clone(&exec_plan),
3901+
&codec,
3902+
&proto_converter,
3903+
)?;
3904+
let result_plan = physical_plan_from_bytes_with_proto_converter(
3905+
bytes.as_ref(),
3906+
ctx.task_ctx().as_ref(),
3907+
&codec,
3908+
&proto_converter,
3909+
)?;
3910+
3911+
let data_source_exec = result_plan
3912+
.downcast_ref::<DataSourceExec>()
3913+
.expect("Expected DataSourceExec");
3914+
let file_scan_config = data_source_exec
3915+
.data_source()
3916+
.downcast_ref::<FileScanConfig>()
3917+
.expect("Expected FileScanConfig");
3918+
3919+
assert!(file_scan_config.partitioned_by_file_group);
3920+
3921+
Ok(())
3922+
}

0 commit comments

Comments
 (0)