MCPcopy Create free account
hub / github.com/apache/datafusion / concat

Function concat

datafusion/functions/src/string/concat.rs:505–550  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

503
504 #[test]
505 fn concat() -> Result<()> {
506 let c0 =
507 ColumnarValue::Array(Arc::new(StringArray::from(vec!["foo", "bar", "baz"])));
508 let c1 = ColumnarValue::Scalar(ScalarValue::Utf8(Some(",".to_string())));
509 let c2 = ColumnarValue::Array(Arc::new(StringArray::from(vec![
510 Some("x"),
511 None,
512 Some("z"),
513 ])));
514 let c3 = ColumnarValue::Scalar(ScalarValue::Utf8View(Some(",".to_string())));
515 let c4 = ColumnarValue::Array(Arc::new(StringViewArray::from(vec![
516 Some("a"),
517 None,
518 Some("b"),
519 ])));
520 let arg_fields = vec![
521 Field::new("a", Utf8, true),
522 Field::new("a", Utf8, true),
523 Field::new("a", Utf8, true),
524 Field::new("a", Utf8View, true),
525 Field::new("a", Utf8View, true),
526 ]
527 .into_iter()
528 .map(Arc::new)
529 .collect::<Vec<_>>();
530
531 let args = ScalarFunctionArgs {
532 args: vec![c0, c1, c2, c3, c4],
533 arg_fields,
534 number_rows: 3,
535 return_field: Field::new("f", Utf8, true).into(),
536 config_options: Arc::new(ConfigOptions::default()),
537 };
538
539 let result = ConcatFunc::new().invoke_with_args(args)?;
540 let expected =
541 Arc::new(StringViewArray::from(vec!["foo,x,a", "bar,,", "baz,z,b"]))
542 as ArrayRef;
543 match &result {
544 ColumnarValue::Array(array) => {
545 assert_eq!(&expected, array);
546 }
547 _ => panic!(),
548 }
549 Ok(())
550 }
551}

Callers 15

simplify_concat_wsFunction · 0.70
simplify_concatFunction · 0.70
invoke_with_argsMethod · 0.50
updateMethod · 0.50
generic_set_listsFunction · 0.50
build_map_arrayFunction · 0.50
mock_session_stateFunction · 0.50
do_queryFunction · 0.50
append_null_groupMethod · 0.50
calculate_out_columnsMethod · 0.50

Calls 6

newFunction · 0.85
to_stringMethod · 0.45
mapMethod · 0.45
into_iterMethod · 0.45
intoMethod · 0.45
invoke_with_argsMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…