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

Function spark_url_encode

datafusion/spark/src/function/url/url_encode.rs:103–126  ·  view source on GitHub ↗

Core implementation of URL encoding function. # Arguments `args` - A slice containing exactly one ArrayRef with the strings to encode # Returns `Ok(ArrayRef)` - A new array of the same type containing encoded strings `Err(DataFusionError)` - If invalid arguments are provided

(args: &[ArrayRef])

Source from the content-addressed store, hash-verified

101/// * `Err(DataFusionError)` - If invalid arguments are provided
102///
103fn spark_url_encode(args: &[ArrayRef]) -> Result<ArrayRef> {
104 if args.len() != 1 {
105 return exec_err!("`url_encode` expects 1 argument");
106 }
107
108 match &args[0].data_type() {
109 DataType::Utf8 => as_string_array(&args[0])?
110 .iter()
111 .map(|x| x.map(UrlEncode::encode).transpose())
112 .collect::<Result<StringArray>>()
113 .map(|array| Arc::new(array) as ArrayRef),
114 DataType::LargeUtf8 => as_large_string_array(&args[0])?
115 .iter()
116 .map(|x| x.map(UrlEncode::encode).transpose())
117 .collect::<Result<LargeStringArray>>()
118 .map(|array| Arc::new(array) as ArrayRef),
119 DataType::Utf8View => as_string_view_array(&args[0])?
120 .iter()
121 .map(|x| x.map(UrlEncode::encode).transpose())
122 .collect::<Result<StringViewArray>>()
123 .map(|array| Arc::new(array) as ArrayRef),
124 other => exec_err!("`url_encode`: Expr must be STRING, got {other:?}"),
125 }
126}

Callers

nothing calls this directly

Calls 8

as_string_arrayFunction · 0.85
newFunction · 0.85
as_large_string_arrayFunction · 0.85
as_string_view_arrayFunction · 0.85
lenMethod · 0.45
data_typeMethod · 0.45
mapMethod · 0.45
iterMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…