andygrove commented on a change in pull request #8102:
URL: https://github.com/apache/arrow/pull/8102#discussion_r490575680



##########
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();
+    }

Review comment:
       This check is good but no, this is not what I'm referring to. Here is my 
example code again but renaming some variables for clarity.
   
   ```rust
   let array1 = array.as_any().downcast_ref::<FixedSizeListArray>().unwrap();
   if array1.is_null(row_index) {
     // this case isn't handled
   } else {
     let array2 = array1.value(row_index);
     let mut r = Vec::with_capacity(*n as usize);
     for i in 0..*n {
       r.push(array_str(&array2, i as usize));
     }
     format!("[{}]", r.join(","))
   }
   ```
   
   There are two arrays involved here; array1 and array2.
   
   `array1` is the array of columns.
   
   `array2` is one of the columns from the array `array1`.
   
   We call `array_str` with `array2` and that part is all good.
   
   However, when we initialize `array2` with `let array2 = 
array1.value(row_index);` we are not first checking to see if there is a valid 
value at `row_index` in `array1`.
   
   Does that make sense?
   
   




----------------------------------------------------------------
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


Reply via email to