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])
| 101 | /// * `Err(DataFusionError)` - If invalid arguments are provided |
| 102 | /// |
| 103 | fn 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 | } |
nothing calls this directly
no test coverage detected
searching dependent graphs…