(
column: &str,
input_field: Field,
target_field: Field,
input_array: StructArray,
)
| 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 |
searching dependent graphs…