Skip to content

Commit 0c6b886

Browse files
committed
Add to simplification unit test to catch changes in type for concat
1 parent 8937955 commit 0c6b886

File tree

1 file changed

+19
-5
lines changed

1 file changed

+19
-5
lines changed

datafusion/core/tests/expr_api/simplification.rs

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -483,10 +483,12 @@ fn expr_test_schema() -> DFSchemaRef {
483483
Field::new("c2", DataType::Boolean, true),
484484
Field::new("c3", DataType::Int64, true),
485485
Field::new("c4", DataType::UInt32, true),
486+
Field::new("c5", DataType::Utf8View, true),
486487
Field::new("c1_non_null", DataType::Utf8, false),
487488
Field::new("c2_non_null", DataType::Boolean, false),
488489
Field::new("c3_non_null", DataType::Int64, false),
489490
Field::new("c4_non_null", DataType::UInt32, false),
491+
Field::new("c5_non_null", DataType::Utf8View, false),
490492
])
491493
.to_dfschema_ref()
492494
.unwrap()
@@ -665,20 +667,32 @@ fn test_simplify_concat_ws_with_null() {
665667
}
666668

667669
#[test]
668-
fn test_simplify_concat() {
670+
fn test_simplify_concat() -> Result<()> {
671+
let schema = expr_test_schema();
669672
let null = lit(ScalarValue::Utf8(None));
670673
let expr = concat(vec![
671674
null.clone(),
672-
col("c0"),
675+
col("c1"),
673676
lit("hello "),
674677
null.clone(),
675678
lit("rust"),
676-
col("c1"),
679+
lit(ScalarValue::Utf8View(Some("!".to_string()))),
680+
col("c2"),
677681
lit(""),
678682
null,
683+
col("c5"),
679684
]);
680-
let expected = concat(vec![col("c0"), lit("hello rust"), col("c1")]);
681-
test_simplify(expr, expected)
685+
let expr_datatype = expr.get_type(schema.as_ref())?;
686+
let expected = concat(vec![
687+
col("c1"),
688+
lit(ScalarValue::Utf8View(Some("hello rust!".to_string()))),
689+
col("c2"),
690+
col("c5"),
691+
]);
692+
let expected_datatype = expected.get_type(schema.as_ref())?;
693+
assert_eq!(expr_datatype, expected_datatype);
694+
test_simplify(expr, expected);
695+
Ok(())
682696
}
683697
#[test]
684698
fn test_simplify_cycles() {

0 commit comments

Comments
 (0)