Skip to content

Commit dc073ff

Browse files
authored
fix empty projection proto roundtrip (apache#15449)
1 parent 1af1102 commit dc073ff

File tree

3 files changed

+9
-7
lines changed

3 files changed

+9
-7
lines changed

datafusion/proto/src/physical_plan/from_proto.rs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -489,11 +489,6 @@ pub fn parse_protobuf_file_scan_config(
489489
.iter()
490490
.map(|i| *i as usize)
491491
.collect::<Vec<_>>();
492-
let projection = if projection.is_empty() {
493-
None
494-
} else {
495-
Some(projection)
496-
};
497492

498493
let constraints = convert_required!(proto.constraints)?;
499494
let statistics = convert_required!(proto.statistics)?;
@@ -543,7 +538,7 @@ pub fn parse_protobuf_file_scan_config(
543538
.with_file_groups(file_groups)
544539
.with_constraints(constraints)
545540
.with_statistics(statistics)
546-
.with_projection(projection)
541+
.with_projection(Some(projection))
547542
.with_limit(proto.limit.as_ref().map(|sl| sl.limit as usize))
548543
.with_table_partition_cols(table_partition_cols)
549544
.with_output_ordering(output_ordering)

datafusion/proto/src/physical_plan/to_proto.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -512,7 +512,7 @@ pub fn serialize_file_scan_config(
512512
projection: conf
513513
.projection
514514
.as_ref()
515-
.unwrap_or(&vec![])
515+
.unwrap_or(&(0..schema.fields().len()).collect::<Vec<_>>())
516516
.iter()
517517
.map(|n| *n as u32)
518518
.collect(),

datafusion/proto/tests/cases/roundtrip_physical_plan.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1655,3 +1655,10 @@ async fn roundtrip_parquet_select_projection_predicate() -> Result<()> {
16551655
let sql = "select string_col, timestamp_col from alltypes_plain where id > 4";
16561656
roundtrip_test_sql_with_context(sql, &ctx).await
16571657
}
1658+
1659+
#[tokio::test]
1660+
async fn roundtrip_empty_projection() -> Result<()> {
1661+
let ctx = all_types_context().await?;
1662+
let sql = "select 1 from alltypes_plain";
1663+
roundtrip_test_sql_with_context(sql, &ctx).await
1664+
}

0 commit comments

Comments
 (0)