-
Notifications
You must be signed in to change notification settings - Fork 4k
ARROW-11594: [Rust] Support pretty printing of NullArray #9468
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
heads-up @alamb, the implementation of 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//pull/9469]. This PR will still be necessary, as we'll need to be able to print |
|
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. |
|
Thanks @paddyhoran -- I think the logic in this particular PR is sound (with the possibly exception that |
|
Switching back to draft until #9469 gets merged |
29b95cf to
12e73b3
Compare
|
Rebased to pick up #9469 |
jorgecarleitao
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm. Thanks @alamb !
I agree with @nevi-me : Array::data_type(&a) == DataType::Null if and only if a.as_ref().downcast_ref() is infalible.
@alamb , the general solution here is to have a new entry in match data_type for DataType::Null. In general, every missing branch on these matches is either an unimplemented feature or unreachable. :)
Good call @jorgecarleitao -- I didn't realize that the real bug was |
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 ``` # Note _Update: the issue with `NullArray` claiming to be types such as `Int32` has been fixed by @nevi-me in apache#9469 _ Closes apache#9468 from alamb/alamb/support-null-printing Authored-by: Andrew Lamb <andrew@nerdnetworks.org> Signed-off-by: Andrew Lamb <andrew@nerdnetworks.org>
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:
Panics:
Note
_Update: the issue with
NullArrayclaiming to be types such asInt32has been fixed by @nevi-me in #9469 _