You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by GitBox <gi...@apache.org> on 2021/02/11 12:15:06 UTC

[GitHub] [arrow] alamb opened a new pull request #9468: ARROW-11594: [Rust] Support pretty printing of NullArray

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:
users@infra.apache.org



[GitHub] [arrow] nevi-me edited a comment on pull request #9468: ARROW-11594: [Rust] Support pretty printing of NullArray

Posted by GitBox <gi...@apache.org>.
nevi-me edited a comment on pull request #9468:
URL: https://github.com/apache/arrow/pull/9468#issuecomment-777440219


   heads-up @alamb, the implementation of `NullArray::new_with_type` is not sound, because it's not compliant with the spec.
   A `NullArray` must always have `DataType::Null`.
   
   I was working on a solution for this last night, but didn't finish it; I'll wrap it up tonight. This mainly fixes #9331. [EDIT: I've opened https://github.com/apache/arrow/pull/9469].
   
   This PR will still be necessary, as we'll need to be able to print `NullArray` correctly (but haven't looked at the code)


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [arrow] alamb commented on pull request #9468: ARROW-11594: [Rust] Support pretty printing of NullArray

Posted by GitBox <gi...@apache.org>.
alamb commented on pull request #9468:
URL: https://github.com/apache/arrow/pull/9468#issuecomment-777739023


   Switching back to draft until https://github.com/apache/arrow/pull/9469 gets merged


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [arrow] github-actions[bot] commented on pull request #9468: ARROW-11594: [Rust] Support pretty printing of NullArray

Posted by GitBox <gi...@apache.org>.
github-actions[bot] commented on pull request #9468:
URL: https://github.com/apache/arrow/pull/9468#issuecomment-777410217


   https://issues.apache.org/jira/browse/ARROW-11594


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [arrow] alamb commented on pull request #9468: ARROW-11594: [Rust] Support pretty printing of NullArray

Posted by GitBox <gi...@apache.org>.
alamb commented on pull request #9468:
URL: https://github.com/apache/arrow/pull/9468#issuecomment-778759451


   > I agree with @nevi-me : Array::data_type(&a) == DataType::Null if and only if a.as_ref().downcast_ref() is infalible.
   
   
   Good call @jorgecarleitao  -- I didn't realize that the real bug was  `NullArray` created by `NullArray::new_with_type` claiming to be `DataType::Int32`, etc. Since this has been fixed by @nevi-me  in https://github.com/apache/arrow/pull/9469  I am feeling much better


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [arrow] paddyhoran commented on pull request #9468: ARROW-11594: [Rust] Support pretty printing of NullArray

Posted by GitBox <gi...@apache.org>.
paddyhoran commented on pull request #9468:
URL: https://github.com/apache/arrow/pull/9468#issuecomment-777614507


   Sorry, I didn't scroll and see the comment from @nevi-me.  It only affects your test but I guess we should resolve these items first.


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [arrow] alamb edited a comment on pull request #9468: ARROW-11594: [Rust] Support pretty printing of NullArray

Posted by GitBox <gi...@apache.org>.
alamb edited a comment on pull request #9468:
URL: https://github.com/apache/arrow/pull/9468#issuecomment-778759451


   > I agree with @nevi-me : Array::data_type(&a) == DataType::Null if and only if a.as_ref().downcast_ref() is infalible.
   
   
   Good call @jorgecarleitao  -- I didn't realize that the real bug was  `NullArray` created by `NullArray::new_with_type` claiming to be `DataType::Int32`, etc. Since this has been fixed by @nevi-me  in https://github.com/apache/arrow/pull/9469  I am feeling much better and have updated this PR's description to remove the "Note" section


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [arrow] nevi-me commented on pull request #9468: ARROW-11594: [Rust] Support pretty printing of NullArray

Posted by GitBox <gi...@apache.org>.
nevi-me commented on pull request #9468:
URL: https://github.com/apache/arrow/pull/9468#issuecomment-777440219


   heads-up @alamb, the implementation of `NullArray::new_with_type` is not sound, because it's not compliant with the spec.
   A `NullArray` must always have `DataType::Null`.
   
   I was working on a solution for this last night, but didn't finish it; I'll wrap it up tonight. This mainly fixes #9331.
   
   This PR will still be necessary, as we'll need to be able to print `NullArray` correctly (but haven't looked at the code)


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [arrow] alamb commented on pull request #9468: ARROW-11594: [Rust] Support pretty printing of NullArray

Posted by GitBox <gi...@apache.org>.
alamb commented on pull request #9468:
URL: https://github.com/apache/arrow/pull/9468#issuecomment-777720258


   Thanks @paddyhoran  -- I think the logic in this particular PR is sound (with the possibly exception that `NullArray::new_with_type` is going away) as it just checks for nulls and adds a test :) I am going over to lend a hand with https://github.com/apache/arrow/pull/9469 and hopefully we'll have something good


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [arrow] alamb closed pull request #9468: ARROW-11594: [Rust] Support pretty printing of NullArray

Posted by GitBox <gi...@apache.org>.
alamb closed pull request #9468:
URL: https://github.com/apache/arrow/pull/9468


   


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [arrow] alamb commented on pull request #9468: ARROW-11594: [Rust] Support pretty printing of NullArray

Posted by GitBox <gi...@apache.org>.
alamb commented on pull request #9468:
URL: https://github.com/apache/arrow/pull/9468#issuecomment-778681243


   Rebased to pick up https://github.com/apache/arrow/pull/9469


----------------------------------------------------------------
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:
users@infra.apache.org