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

Function cast_struct_array

datafusion/physical-expr/src/expressions/cast.rs:402–421  ·  view source on GitHub ↗
(
        column: &str,
        input_field: Field,
        target_field: Field,
        input_array: StructArray,
    )

Source from the content-addressed store, hash-verified

400 }
401
402 fn cast_struct_array(
403 column: &str,
404 input_field: Field,
405 target_field: Field,
406 input_array: StructArray,
407 ) -> Result<StructArray> {
408 let schema = Arc::new(Schema::new(vec![input_field]));
409 let batch = RecordBatch::try_new(
410 Arc::clone(&schema),
411 vec![Arc::new(input_array) as ArrayRef],
412 )?;
413 let expr = CastExpr::new_with_target_field(
414 col(column, schema.as_ref())?,
415 Arc::new(target_field),
416 None,
417 );
418
419 let result = expr.evaluate(&batch)?.into_array(batch.num_rows())?;
420 Ok(as_struct_array(result.as_ref())?.clone())
421 }
422
423 // runs an end-to-end test of physical type cast
424 // 1. construct a record batch with a column "a" of type A

Calls 7

newFunction · 0.85
as_struct_arrayFunction · 0.85
colFunction · 0.70
as_refMethod · 0.45
into_arrayMethod · 0.45
evaluateMethod · 0.45
cloneMethod · 0.45

Used in the wild real call sites across dependent graphs

searching dependent graphs…