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

Function compute_hex

datafusion/spark/src/function/math/hex.rs:230–351  ·  view source on GitHub ↗
(
    args: &[ColumnarValue],
    lowercase: bool,
)

Source from the content-addressed store, hash-verified

228}
229
230pub fn compute_hex(
231 args: &[ColumnarValue],
232 lowercase: bool,
233) -> Result<ColumnarValue, DataFusionError> {
234 let input = match take_function_args("hex", args)? {
235 [ColumnarValue::Scalar(value)] => ColumnarValue::Array(value.to_array()?),
236 [ColumnarValue::Array(arr)] => ColumnarValue::Array(Arc::clone(arr)),
237 };
238
239 match &input {
240 ColumnarValue::Array(array) => match array.data_type() {
241 DataType::Int64 => {
242 let array = as_int64_array(array)?;
243 Ok(ColumnarValue::Array(hex_encode_int64(
244 array.iter(),
245 array.len(),
246 )?))
247 }
248 DataType::Utf8 => {
249 let array = as_string_array(array);
250 Ok(ColumnarValue::Array(hex_encode_bytes(
251 array.iter(),
252 lowercase,
253 array.len(),
254 )?))
255 }
256 DataType::Utf8View => {
257 let array = as_string_view_array(array)?;
258 Ok(ColumnarValue::Array(hex_encode_bytes(
259 array.iter(),
260 lowercase,
261 array.len(),
262 )?))
263 }
264 DataType::LargeUtf8 => {
265 let array = as_largestring_array(array);
266 Ok(ColumnarValue::Array(hex_encode_bytes(
267 array.iter(),
268 lowercase,
269 array.len(),
270 )?))
271 }
272 DataType::Binary => {
273 let array = as_binary_array(array)?;
274 Ok(ColumnarValue::Array(hex_encode_bytes(
275 array.iter(),
276 lowercase,
277 array.len(),
278 )?))
279 }
280 DataType::LargeBinary => {
281 let array = as_large_binary_array(array)?;
282 Ok(ColumnarValue::Array(hex_encode_bytes(
283 array.iter(),
284 lowercase,
285 array.len(),
286 )?))
287 }

Callers 2

spark_hexFunction · 0.85
spark_sha2_hexFunction · 0.85

Calls 15

take_function_argsFunction · 0.85
as_int64_arrayFunction · 0.85
hex_encode_int64Function · 0.85
as_string_arrayFunction · 0.85
hex_encode_bytesFunction · 0.85
as_string_view_arrayFunction · 0.85
as_binary_arrayFunction · 0.85
as_large_binary_arrayFunction · 0.85
newFunction · 0.85
to_arrayMethod · 0.45
data_typeMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…