Skip to content

Commit 4213f58

Browse files
committed
Add unit test
1 parent 479aa6a commit 4213f58

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

datafusion/core/src/physical_planner.rs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2695,6 +2695,30 @@ mod tests {
26952695
}
26962696
}
26972697

2698+
#[tokio::test]
2699+
async fn test_maybe_fix_colon_in_physical_name() {
2700+
// The physical schema has a field name with a colon
2701+
let schema = Schema::new(vec![Field::new("metric:avg", DataType::Int32, false)]);
2702+
let schema_ref: SchemaRef = Arc::new(schema);
2703+
2704+
// What might happen after deduplication
2705+
let logical_col_name = "metric:avg:1";
2706+
let expr_with_suffix =
2707+
Arc::new(Column::new(logical_col_name, 0)) as Arc<dyn PhysicalExpr>;
2708+
let expr_result = Ok(expr_with_suffix);
2709+
2710+
// Call function under test
2711+
let fixed_expr =
2712+
maybe_fix_physical_column_name(expr_result, &schema_ref).unwrap();
2713+
2714+
// Downcast back to Column so we can check the name
2715+
let col = fixed_expr
2716+
.as_any()
2717+
.downcast_ref::<Column>()
2718+
.expect("Column");
2719+
2720+
assert_eq!(col.name(), "metric:avg");
2721+
}
26982722
struct ErrorExtensionPlanner {}
26992723

27002724
#[async_trait]

0 commit comments

Comments
 (0)