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

Function concat_ws

datafusion/functions/src/string/concat_ws.rs:602–675  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

600
601 #[test]
602 fn concat_ws() -> Result<()> {
603 // sep is scalar
604 let c0 = ColumnarValue::Scalar(ScalarValue::Utf8(Some(",".to_string())));
605 let c1 =
606 ColumnarValue::Array(Arc::new(StringArray::from(vec!["foo", "bar", "baz"])));
607 let c2 = ColumnarValue::Array(Arc::new(StringArray::from(vec![
608 Some("x"),
609 None,
610 Some("z"),
611 ])));
612
613 let arg_fields = vec![
614 Field::new("a", Utf8, true).into(),
615 Field::new("a", Utf8, true).into(),
616 Field::new("a", Utf8, true).into(),
617 ];
618 let args = ScalarFunctionArgs {
619 args: vec![c0, c1, c2],
620 arg_fields,
621 number_rows: 3,
622 return_field: Field::new("f", Utf8, true).into(),
623 config_options: Arc::new(ConfigOptions::default()),
624 };
625
626 let result = ConcatWsFunc::new().invoke_with_args(args)?;
627 let expected =
628 Arc::new(StringArray::from(vec!["foo,x", "bar", "baz,z"])) as ArrayRef;
629 match &result {
630 ColumnarValue::Array(array) => {
631 assert_eq!(&expected, array);
632 }
633 _ => panic!(),
634 }
635
636 // sep is nullable array
637 let c0 = ColumnarValue::Array(Arc::new(StringArray::from(vec![
638 Some(","),
639 None,
640 Some("+"),
641 ])));
642 let c1 =
643 ColumnarValue::Array(Arc::new(StringArray::from(vec!["foo", "bar", "baz"])));
644 let c2 = ColumnarValue::Array(Arc::new(StringArray::from(vec![
645 Some("x"),
646 Some("y"),
647 Some("z"),
648 ])));
649
650 let arg_fields = vec![
651 Field::new("a", Utf8, true).into(),
652 Field::new("a", Utf8, true).into(),
653 Field::new("a", Utf8, true).into(),
654 ];
655 let args = ScalarFunctionArgs {
656 args: vec![c0, c1, c2],
657 arg_fields,
658 number_rows: 3,
659 return_field: Field::new("f", Utf8, true).into(),

Callers 1

simplify_concat_wsFunction · 0.70

Calls 4

newFunction · 0.85
to_stringMethod · 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…