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

Function test_except_nested_struct

datafusion/core/tests/dataframe/mod.rs:2633–2706  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

2631
2632#[tokio::test]
2633async fn test_except_nested_struct() -> Result<()> {
2634 use arrow::array::StructArray;
2635
2636 let nested_schema = Arc::new(Schema::new(vec![
2637 Field::new("id", DataType::Int32, true),
2638 Field::new("lat", DataType::Int32, true),
2639 Field::new("long", DataType::Int32, true),
2640 ]));
2641 let schema = Arc::new(Schema::new(vec![
2642 Field::new("value", DataType::Int32, true),
2643 Field::new(
2644 "nested",
2645 DataType::Struct(nested_schema.fields.clone()),
2646 true,
2647 ),
2648 ]));
2649 let batch = RecordBatch::try_new(
2650 Arc::clone(&schema),
2651 vec![
2652 Arc::new(Int32Array::from(vec![Some(1), Some(2), Some(3)])),
2653 Arc::new(StructArray::from(vec![
2654 (
2655 Arc::new(Field::new("id", DataType::Int32, true)),
2656 Arc::new(Int32Array::from(vec![1, 2, 3])) as ArrayRef,
2657 ),
2658 (
2659 Arc::new(Field::new("lat", DataType::Int32, true)),
2660 Arc::new(Int32Array::from(vec![1, 2, 3])) as ArrayRef,
2661 ),
2662 (
2663 Arc::new(Field::new("long", DataType::Int32, true)),
2664 Arc::new(Int32Array::from(vec![1, 2, 3])) as ArrayRef,
2665 ),
2666 ])),
2667 ],
2668 )
2669 .unwrap();
2670
2671 let updated_batch = RecordBatch::try_new(
2672 Arc::clone(&schema),
2673 vec![
2674 Arc::new(Int32Array::from(vec![Some(1), Some(12), Some(3)])),
2675 Arc::new(StructArray::from(vec![
2676 (
2677 Arc::new(Field::new("id", DataType::Int32, true)),
2678 Arc::new(Int32Array::from(vec![1, 2, 3])) as ArrayRef,
2679 ),
2680 (
2681 Arc::new(Field::new("lat", DataType::Int32, true)),
2682 Arc::new(Int32Array::from(vec![1, 2, 3])) as ArrayRef,
2683 ),
2684 (
2685 Arc::new(Field::new("long", DataType::Int32, true)),
2686 Arc::new(Int32Array::from(vec![1, 2, 3])) as ArrayRef,
2687 ),
2688 ])),
2689 ],
2690 )

Callers

nothing calls this directly

Calls 4

newFunction · 0.85
read_batchMethod · 0.80
collectMethod · 0.80
exceptMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…