andygrove commented on a change in pull request #8102: URL: https://github.com/apache/arrow/pull/8102#discussion_r489808150
########## File path: rust/datafusion/tests/sql.rs ########## @@ -609,6 +609,74 @@ fn execute(ctx: &mut ExecutionContext, sql: &str) -> Vec<String> { result_str(&results) } +fn array_str(array: &Arc<dyn Array>, row_index: usize) -> String { + if array.is_null(row_index) { + return "NULL".to_string(); + } + + match array.data_type() { + DataType::Int8 => { + let array = array.as_any().downcast_ref::<Int8Array>().unwrap(); + format!("{:?}", array.value(row_index)) + } + DataType::Int16 => { + let array = array.as_any().downcast_ref::<Int16Array>().unwrap(); + format!("{:?}", array.value(row_index)) + } + DataType::Int32 => { + let array = array.as_any().downcast_ref::<Int32Array>().unwrap(); + format!("{:?}", array.value(row_index)) + } + DataType::Int64 => { + let array = array.as_any().downcast_ref::<Int64Array>().unwrap(); + format!("{:?}", array.value(row_index)) + } + DataType::UInt8 => { + let array = array.as_any().downcast_ref::<UInt8Array>().unwrap(); + format!("{:?}", array.value(row_index)) + } + DataType::UInt16 => { + let array = array.as_any().downcast_ref::<UInt16Array>().unwrap(); + format!("{:?}", array.value(row_index)) + } + DataType::UInt32 => { + let array = array.as_any().downcast_ref::<UInt32Array>().unwrap(); + format!("{:?}", array.value(row_index)) + } + DataType::UInt64 => { + let array = array.as_any().downcast_ref::<UInt64Array>().unwrap(); + format!("{:?}", array.value(row_index)) + } + DataType::Float32 => { + let array = array.as_any().downcast_ref::<Float32Array>().unwrap(); + format!("{:?}", array.value(row_index)) + } + DataType::Float64 => { + let array = array.as_any().downcast_ref::<Float64Array>().unwrap(); + format!("{:?}", array.value(row_index)) + } + DataType::Utf8 => { + let array = array.as_any().downcast_ref::<StringArray>().unwrap(); + format!("{:?}", array.value(row_index)) + } + DataType::Boolean => { + let array = array.as_any().downcast_ref::<BooleanArray>().unwrap(); + format!("{:?}", array.value(row_index)) + } + DataType::FixedSizeList(_, n) => { + let array = array.as_any().downcast_ref::<FixedSizeListArray>().unwrap(); + + let mut r = Vec::with_capacity(*n as usize); + for i in 0..*n { + let array = array.value(row_index); Review comment: I think this also needs null handling since elements within this array could have null values? ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org