fn assert_rb_column_equals(rb: &RecordBatch, col_name: &str, exp: &Values<'_>) {
        use arrow::datatypes::DataType;

        let got_column = rb.column(rb.schema().index_of(col_name).unwrap());

        match exp {
            Values::Dictionary(keys, values) => match got_column.data_type() {
                DataType::Dictionary(key, value)
                    if key.as_ref() == &DataType::Int32 && value.as_ref() == &DataType::Utf8 =>
                {
                    // Record batch stores keys as i32
                    let keys = keys
                        .iter()
                        .map(|&x| i32::try_from(x).unwrap())
                        .collect::<Vec<_>>();

                    let dictionary = got_column
                        .as_any()
                        .downcast_ref::<DictionaryArray<Int32Type>>()
                        .unwrap();
                    let rb_values = dictionary.values();
                    let rb_values = rb_values.as_any().downcast_ref::<StringArray>().unwrap();

                    // Ensure string values are same
                    assert!(rb_values.iter().zip(values.iter()).all(|(a, b)| &a == b));

                    let rb_keys = dictionary.keys().values();
                    assert_eq!(rb_keys, keys.as_slice());
                }
                d => panic!("Unexpected type {:?}", d),
            },
            Values::String(exp_data) => match got_column.data_type() {
                DataType::Utf8 => {
                    let arr = got_column.as_any().downcast_ref::<StringArray>().unwrap();
                    assert_eq!(&arr.iter().collect::<Vec<_>>(), exp_data);
                }
                d => panic!("Unexpected type {:?}", d),
            },
            Values::I64(exp_data) => {
                if let Some(arr) = got_column.as_any().downcast_ref::<Int64Array>() {
                    assert_eq!(arr.values(), exp_data);
                } else if let Some(arr) = got_column
                    .as_any()
                    .downcast_ref::<TimestampNanosecondArray>()
                {
                    assert_eq!(arr.values(), exp_data);
                } else {
                    panic!("Unexpected type");
                }
            }
            Values::U64(exp_data) => {
                let arr: &UInt64Array = got_column.as_any().downcast_ref::<UInt64Array>().unwrap();
                assert_eq!(arr.values(), exp_data);
            }
            Values::F64(exp_data) => {
                let arr: &Float64Array =
                    got_column.as_any().downcast_ref::<Float64Array>().unwrap();
                assert_eq!(arr.values(), exp_data);
            }
            Values::I64N(exp_data) => {
                let arr: &Int64Array = got_column.as_any().downcast_ref::<Int64Array>().unwrap();
                let got_data = (0..got_column.len())
                    .map(|i| {
                        if got_column.is_null(i) {
                            None
                        } else {
                            Some(arr.value(i))
                        }
                    })
                    .collect::<Vec<_>>();
                assert_eq!(&got_data, exp_data);
            }
            Values::U64N(exp_data) => {
                let arr: &UInt64Array = got_column.as_any().downcast_ref::<UInt64Array>().unwrap();
                let got_data = (0..got_column.len())
                    .map(|i| {
                        if got_column.is_null(i) {
                            None
                        } else {
                            Some(arr.value(i))
                        }
                    })
                    .collect::<Vec<_>>();
                assert_eq!(&got_data, exp_data);
            }
            Values::F64N(exp_data) => {
                let arr: &Float64Array =
                    got_column.as_any().downcast_ref::<Float64Array>().unwrap();
                let got_data = (0..got_column.len())
                    .map(|i| {
                        if got_column.is_null(i) {
                            None
                        } else {
                            Some(arr.value(i))
                        }
                    })
                    .collect::<Vec<_>>();
                assert_eq!(&got_data, exp_data);
            }
            Values::Bool(exp_data) => {
                let arr: &BooleanArray =
                    got_column.as_any().downcast_ref::<BooleanArray>().unwrap();
                let got_data = (0..got_column.len())
                    .map(|i| {
                        if got_column.is_null(i) {
                            None
                        } else {
                            Some(arr.value(i))
                        }
                    })
                    .collect::<Vec<_>>();
                assert_eq!(&got_data, exp_data);
            }
            Values::ByteArray(exp_data) => {
                let arr: &BinaryArray = got_column.as_any().downcast_ref::<BinaryArray>().unwrap();
                let got_data = (0..got_column.len())
                    .map(|i| {
                        if got_column.is_null(i) {
                            None
                        } else {
                            Some(arr.value(i))
                        }
                    })
                    .collect::<Vec<_>>();
                assert_eq!(&got_data, exp_data);
            }
        }
    }
// Helper function to assert the contents of a column on a record batch.
Helper function to assert the contents of a column on a record batch.
Helper function to assert the contents of a column on a record batch .
fn assert_rb_column_equals(rb: &RecordBatch, col_name: &str, exp: &Values<'_>) {
        use arrow::datatypes::DataType;
        let got_column = rb.column(rb.schema().index_of(col_name).unwrap());
        match exp {
            Values::Dictionary(keys, values) => match got_column.data_type() {
                DataType::Dictionary(key, value)
                    if key.as_ref() == &DataType::Int32 && value.as_ref() == &DataType::Utf8 =>
                {
                    // Record batch stores keys as i32
                    let keys = keys
                        .iter()
                        .map(|&x| i32::try_from(x).unwrap())
                        .collect::<Vec<_>>();
                    let dictionary = got_column
                        .as_any()
                        .downcast_ref::<DictionaryArray<Int32Type>>()
                        .unwrap();
                    let rb_values = dictionary.values();
                    let rb_values = rb_values.as_any().downcast_ref::<StringArray>().unwrap();
                    // Ensure string values are same
                    assert!(rb_values.iter().zip(values.iter()).all(|(a, b)| &a == b));
                    let rb_keys = dictionary.keys().values();
                    assert_eq!(rb_keys, keys.as_slice());
                }
                d => panic!("Unexpected type {:?}", d),
            },
            Values::String(exp_data) => match got_column.data_type() {
                DataType::Utf8 => {
                    let arr = got_column.as_any().downcast_ref::<StringArray>().unwrap();
                    assert_eq!(&arr.iter().collect::<Vec<_>>(), exp_data);
                }
                d => panic!("Unexpected type {:?}", d),
            },
            Values::I64(exp_data) => {
                if let Some(arr) = got_column.as_any().downcast_ref::<Int64Array>() {
                    assert_eq!(arr.values(), exp_data);
                } else if let Some(arr) = got_column
                    .as_any()
                    .downcast_ref::<TimestampNanosecondArray>()
                {
                    assert_eq!(arr.values(), exp_data);
                } else {
                    panic!("Unexpected type");
                }
            }
            Values::U64(exp_data) => {
                let arr: &UInt64Array = got_column.as_any().downcast_ref::<UInt64Array>().unwrap();
                assert_eq!(arr.values(), exp_data);
            }
            Values::F64(exp_data) => {
                let arr: &Float64Array =
                    got_column.as_any().downcast_ref::<Float64Array>().unwrap();
                assert_eq!(arr.values(), exp_data);
            }
            Values::I64N(exp_data) => {
                let arr: &Int64Array = got_column.as_any().downcast_ref::<Int64Array>().unwrap();
                let got_data = (0..got_column.len())
                    .map(|i| {
                        if got_column.is_null(i) {
                            None
                        } else {
                            Some(arr.value(i))
                        }
                    })
                    .collect::<Vec<_>>();
                assert_eq!(&got_data, exp_data);
            }
            Values::U64N(exp_data) => {
                let arr: &UInt64Array = got_column.as_any().downcast_ref::<UInt64Array>().unwrap();
                let got_data = (0..got_column.len())
                    .map(|i| {
                        if got_column.is_null(i) {
                            None
                        } else {
                            Some(arr.value(i))
                        }
                    })
                    .collect::<Vec<_>>();
                assert_eq!(&got_data, exp_data);
            }
            Values::F64N(exp_data) => {
                let arr: &Float64Array =
                    got_column.as_any().downcast_ref::<Float64Array>().unwrap();
                let got_data = (0..got_column.len())
                    .map(|i| {
                        if got_column.is_null(i) {
                            None
                        } else {
                            Some(arr.value(i))
                        }
                    })
                    .collect::<Vec<_>>();
                assert_eq!(&got_data, exp_data);
            }
            Values::Bool(exp_data) => {
                let arr: &BooleanArray =
                    got_column.as_any().downcast_ref::<BooleanArray>().unwrap();
                let got_data = (0..got_column.len())
                    .map(|i| {
                        if got_column.is_null(i) {
                            None
                        } else {
                            Some(arr.value(i))
                        }
                    })
                    .collect::<Vec<_>>();
                assert_eq!(&got_data, exp_data);
            }
            Values::ByteArray(exp_data) => {
                let arr: &BinaryArray = got_column.as_any().downcast_ref::<BinaryArray>().unwrap();
                let got_data = (0..got_column.len())
                    .map(|i| {
                        if got_column.is_null(i) {
                            None
                        } else {
                            Some(arr.value(i))
                        }
                    })
                    .collect::<Vec<_>>();
                assert_eq!(&got_data, exp_data);
            }
        }
    }
fn assert_rb_column_equals ( rb : & RecordBatch , col_name : & str , exp : & Values < ' _ > ) { use arrow :: datatypes :: DataType ; let got_column = rb . column ( rb . schema ( ) . index_of ( col_name ) . unwrap ( ) ) ; match exp { Values :: Dictionary ( keys , values ) => match got_column . data_type ( ) { DataType :: Dictionary ( key , value ) if key . as_ref ( ) == & DataType :: Int32 && value . as_ref ( ) == & DataType :: Utf8 => { // Record batch stores keys as i32 let keys = keys . iter ( ) . map ( | & x | i32 :: try_from ( x ) . unwrap ( ) ) . collect :: < Vec < _ > > ( ) ; let dictionary = got_column . as_any ( ) . downcast_ref :: < DictionaryArray < Int32Type > > ( ) . unwrap ( ) ; let rb_values = dictionary . values ( ) ; let rb_values = rb_values . as_any ( ) . downcast_ref :: < StringArray > ( ) . unwrap ( ) ; // Ensure string values are same assert ! ( rb_values iter ( ) zip ( values iter ( ) ) all ( ( a b ) a b ) ) ; let rb_keys = dictionary . keys ( ) . values ( ) ; assert_eq ! ( rb_keys keys as_slice ( ) ) ; } d => panic ! ( " " d ) , } , Values :: String ( exp_data ) => match got_column . data_type ( ) { DataType :: Utf8 => { let arr = got_column . as_any ( ) . downcast_ref :: < StringArray > ( ) . unwrap ( ) ; assert_eq ! ( arr iter ( ) collect Vec ( ) exp_data ) ; } d => panic ! ( " " d ) , } , Values :: I64 ( exp_data ) => { if let Some ( arr ) = got_column . as_any ( ) . downcast_ref :: < Int64Array > ( ) { assert_eq ! ( arr values ( ) exp_data ) ; } else if let Some ( arr ) = got_column . as_any ( ) . downcast_ref :: < TimestampNanosecondArray > ( ) { assert_eq ! ( arr values ( ) exp_data ) ; } else { panic ! ( " " ) ; } } Values :: U64 ( exp_data ) => { let arr : & UInt64Array = got_column . as_any ( ) . downcast_ref :: < UInt64Array > ( ) . unwrap ( ) ; assert_eq ! ( arr values ( ) exp_data ) ; } Values :: F64 ( exp_data ) => { let arr : & Float64Array = got_column . as_any ( ) . downcast_ref :: < Float64Array > ( ) . unwrap ( ) ; assert_eq ! ( arr values ( ) exp_data ) ; } Values :: I64N ( exp_data ) => { let arr : & Int64Array = got_column . as_any ( ) . downcast_ref :: < Int64Array > ( ) . unwrap ( ) ; let got_data = ( 0 .. got_column . len ( ) ) . map ( | i | { if got_column . is_null ( i ) { None } else { Some ( arr . value ( i ) ) } } ) . collect :: < Vec < _ > > ( ) ; assert_eq ! ( got_data exp_data ) ; } Values :: U64N ( exp_data ) => { let arr : & UInt64Array = got_column . as_any ( ) . downcast_ref :: < UInt64Array > ( ) . unwrap ( ) ; let got_data = ( 0 .. got_column . len ( ) ) . map ( | i | { if got_column . is_null ( i ) { None } else { Some ( arr . value ( i ) ) } } ) . collect :: < Vec < _ > > ( ) ; assert_eq ! ( got_data exp_data ) ; } Values :: F64N ( exp_data ) => { let arr : & Float64Array = got_column . as_any ( ) . downcast_ref :: < Float64Array > ( ) . unwrap ( ) ; let got_data = ( 0 .. got_column . len ( ) ) . map ( | i | { if got_column . is_null ( i ) { None } else { Some ( arr . value ( i ) ) } } ) . collect :: < Vec < _ > > ( ) ; assert_eq ! ( got_data exp_data ) ; } Values :: Bool ( exp_data ) => { let arr : & BooleanArray = got_column . as_any ( ) . downcast_ref :: < BooleanArray > ( ) . unwrap ( ) ; let got_data = ( 0 .. got_column . len ( ) ) . map ( | i | { if got_column . is_null ( i ) { None } else { Some ( arr . value ( i ) ) } } ) . collect :: < Vec < _ > > ( ) ; assert_eq ! ( got_data exp_data ) ; } Values :: ByteArray ( exp_data ) => { let arr : & BinaryArray = got_column . as_any ( ) . downcast_ref :: < BinaryArray > ( ) . unwrap ( ) ; let got_data = ( 0 .. got_column . len ( ) ) . map ( | i | { if got_column . is_null ( i ) { None } else { Some ( arr . value ( i ) ) } } ) . collect :: < Vec < _ > > ( ) ; assert_eq ! ( got_data exp_data ) ; } } }
Helper function to assert the contents of a column on a record batch.
Helper function to assert the contents of a column on a record batch .
rb
&RecordBatch
col_name
&str
exp
&Values<'_>
rb
&RecordBatch
col_name
&str
exp
&Values<'_>