alamb opened a new pull request #9468:
URL: https://github.com/apache/arrow/pull/9468


   As pointed out by @tustvold  on 
https://github.com/influxdata/influxdb_iox/pull/783#discussion_r574414243, it 
would seem the whole point of `NullArray::new_with_type`, is to cheaply 
construct entirely null columns, with a smaller memory footprint.
   
   Currently trying to print them out causes a panic:
   
   ```
       #[test]
       fn test_pretty_format_null() -> Result<()> {
           // define a schema.
           let schema = Arc::new(Schema::new(vec![
               Field::new("a", DataType::Utf8, true),
               Field::new("b", DataType::Int32, true),
           ]));
   
           let num_rows = 4;
   
           // define data (null)
           let batch = RecordBatch::try_new(
               schema,
               vec![
                   Arc::new(NullArray::new_with_type(num_rows, DataType::Utf8)),
                   Arc::new(NullArray::new_with_type(num_rows, 
DataType::Int32)),
               ],
           )?;
   
           let table = pretty_format_batches(&[batch])?;
   }
   
   ```
   
   Panics:
   
   ```
   failures:
   
   ---- util::pretty::tests::test_pretty_format_null stdout ----
   thread 'util::pretty::tests::test_pretty_format_null' panicked at 'called 
`Option::unwrap()` on a `None` value', arrow/src/util/display.rs:201:27
   ```
   
   This PR fixes this issue and will allow printing of NullArray` -- however 
there is a long way to go for proper support of NullArray -- there is code all 
over the codebase that basically looks like
   
   ```
   match col.data_type() {
   ...
      DataType::Int32 => { ///cast col to Int32Array }
      ...
   }
   ```
   
   Which would need to be taught about NullArray


----------------------------------------------------------------
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:
[email protected]


Reply via email to