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

Function write_leaf_to_string

datafusion/functions-nested/src/string.rs:752–781  ·  view source on GitHub ↗

Appends the string representation of each element in a leaf (non-list) array to `w`, separated by `delimiter`. Null elements are rendered using `null_string` if provided, or skipped otherwise. The `append` closure controls how each non-null element is written.

(
    w: &mut W,
    arr: &'a A,
    delimiter: &str,
    null_string: Option<&str>,
    first: &mut bool,
    append: impl Fn(&mut W, T) -> fmt::Result,
)

Source from the content-addressed store, hash-verified

750/// using `null_string` if provided, or skipped otherwise. The `append`
751/// closure controls how each non-null element is written.
752fn write_leaf_to_string<'a, W: Write, A, T>(
753 w: &mut W,
754 arr: &'a A,
755 delimiter: &str,
756 null_string: Option<&str>,
757 first: &mut bool,
758 append: impl Fn(&mut W, T) -> fmt::Result,
759) -> Result<()>
760where
761 &'a A: IntoIterator<Item = Option<T>>,
762{
763 for x in arr {
764 // Skip nulls when no null_string is provided
765 if x.is_none() && null_string.is_none() {
766 continue;
767 }
768
769 if *first {
770 *first = false;
771 } else {
772 w.write_str(delimiter)?;
773 }
774
775 match x {
776 Some(x) => append(w, x)?,
777 None => w.write_str(null_string.unwrap())?,
778 }
779 }
780 Ok(())
781}
782
783trait StringArrayBuilderType: ArrayBuilder {
784 fn append_value(&mut self, val: &str);

Callers

nothing calls this directly

Calls 2

is_noneMethod · 0.80
write_strMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…