Skip to content

ARROW-11149: [Rust] DF Support List/LargeList/FixedSizeList in create_batch_empty - #9114

Closed
ovr wants to merge 1 commit into
apache:masterfrom
ovr:issue-11149
Closed

ARROW-11149: [Rust] DF Support List/LargeList/FixedSizeList in create_batch_empty#9114
ovr wants to merge 1 commit into
apache:masterfrom
ovr:issue-11149

Conversation

@ovr

@ovrovr commented Jan 6, 2021

Copy link
Copy Markdown
Contributor

Previously build_empty_list_array was declared inside Parquet (array_reader), but I will use this function inside DataFushion's create_batch_empty (it's used inside hash_aggregate to make an empty batch from the provided schema that contains type for columns). I moved it to Arrow (because it's common and useful) and made build_empty_large_list_array (for large lists) on top of macros with different implementation than build_empty_list_array.

Comment threadrust/arrow/src/array/array_list.rs Outdated

@ovrovrJan 6, 2021

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What ArrowError should I throw on unimplemented? todo!? Or let's declare this one?

Thanks

@github-actions

Copy link
Copy Markdown

@jorgecarleitao

Copy link
Copy Markdown
Member

I believe that we can make this with generics, now that we have GenericListBuilder::<Offset>(). It would make the code simpler to read, and a consistent function signature.

@ovr

ovr commented Jan 7, 2021

Copy link
Copy Markdown
ContributorAuthor

@jorgecarleitao You are right, but I was thinking about modifying make_empty_list_fn macros to support FixedSizeListBuilder, which is not GenericListBuilder.

Something like:

make_empty_list_fn!(build_empty_fixed_size_list_array, FixedSizeListBuilder);

But I am having a problem with constructing it, FixedSizeListBuilder requires 2 arguments in new method instead of one like GenericListBuilder.

pub fn new(values_builder: T, length: i32) -> Self {

Do you have any solutions how is it possible to do by Marcos? And is it a good idea?

Thanks!

@jorgecarleitao

Copy link
Copy Markdown
Member

Last time I tried something similar, I had to implement the FixedSizeList differently. A fixed sized will always need to receive an extra parameter.

@nevi-me

Copy link
Copy Markdown
Contributor

Yes, better to implement it differently

@ovrovr changed the title ARROW-11149: [Rust] DF Support List/LargeList in create_batch_emptyARROW-11149: [Rust] DF Support List/LargeList/FixedSizeList in create_batch_emptyJan 7, 2021
@ovr

ovr commented Jan 7, 2021

Copy link
Copy Markdown
ContributorAuthor

@jorgecarleitao and @nevi-me 👍

I've moved build_empty_list_array to function build_empty_list_array<OffsetSize: OffsetSizeTrait>, and introduce build_empty_fixed_size_list_array by different implementation as suggested above.

Thanks

ovr added a commit to ovr/arrow that referenced this pull request Jan 10, 2021
In apache#9114, I've prepared support for List/LargeList/FixedSizeList, but will be great to support more types
@ovr

ovr commented Jan 11, 2021

Copy link
Copy Markdown
ContributorAuthor

@andygrove Can you take a look? Thanks

@ovr
ovrforce-pushed the issue-11149 branch 2 times, most recently from 3da157f to f0251d7CompareJanuary 13, 2021 21:52

@jorgecarleitaojorgecarleitao left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I went through this, and it looks good and really useful.

I would just prefer that we have at least 1 test for this, for verification. I left some other minor comments, all optional.

Great work, @ovr

Comment threadrust/arrow/src/array/array_list.rs Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that for an empty list, we know that the offset buffer will be a single entry, 0, and the values buffer will be an empty buffer (len = 0). Therefore, this code could be simplified by just passing the buffers directly instead of using builders.

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Arrow API is a Complex, I still dont know how to do it pretty simple as you suggested with Buffer. I think it's not a big performance impact to use builder in this place.

Comment threadrust/arrow/src/array/array_list.rs Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add a test just to verify?

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, added.

Comment threadrust/arrow/src/error.rs Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you think of Unimplemented instead of Unsupported? Just to be consistent with the unimplemented! macro that rust already offers.

@ovrovrJan 16, 2021

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I found a better name from reading parquet sources, It's called NYI (Not yet implemented), I think it's better to use similar names accross packages.

Renamed.

Thanks

@ovr
ovrforce-pushed the issue-11149 branch 2 times, most recently from 849d8d3 to c898107CompareJanuary 16, 2021 14:03
@codecov-io

Copy link
Copy Markdown

Codecov Report

Merging #9114 (849d8d3) into master (1393188) will decrease coverage by 0.01%.
The diff coverage is 39.79%.

Impacted file tree graph

@@ Coverage Diff @@## master #9114 +/- ##
==========================================
- Coverage 81.61% 81.59% -0.02% 
==========================================
Files 215 215 Lines 51867 51928 +61 ==========================================
+ Hits 42329 42370 +41 - Misses 9538 9558 +20 
Impacted FilesCoverage Δ
rust/datafusion/src/physical_plan/common.rs74.28% <0.00%> (-4.51%)⬇️
rust/parquet/src/arrow/array_reader.rs73.65% <0.00%> (+2.25%)⬆️
rust/arrow/src/array/array_list.rs83.33% <43.67%> (-9.78%)⬇️
rust/arrow/src/error.rs9.52% <50.00%> (-0.48%)⬇️
rust/parquet/src/encodings/encoding.rs94.86% <0.00%> (-0.20%)⬇️
rust/arrow/src/array/builder.rs86.30% <0.00%> (+0.40%)⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update eaa7b7a...c898107. Read the comment docs.

Comment threadrust/arrow/src/error.rs Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that the error name should be explicit, like all others. I can't understand what NYI means without having to go to the docs, and in an error message, the person often has no access to the docs (at least not in a 1 click thing).

NotYetImplemented?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree that NotYetImplemented is a better name

@alambalamb left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @ovr -- I think this PR is looking good to go.

Ideally we would could get the rename of NYI to NotYetImplemented but I also think we could merge this PR and rename the enum in a follow on PR

However, since this this PR needs a rebase, sadly, perhaps we can do the rename as part of the rebase.

Comment threadrust/arrow/src/error.rs Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree that NotYetImplemented is a better name

@alambalamb added the needs-rebase A PR that needs to be rebased by the author label Jan 20, 2021
@ovr

ovr commented Jan 20, 2021

Copy link
Copy Markdown
ContributorAuthor

@alamb Rebased + renamed NYI -> NotYetImplemented in Arrow. Thanks

@alamb

Copy link
Copy Markdown
Contributor

Awesome -- thanks @ovr !

@alamb

alamb commented Jan 20, 2021

Copy link
Copy Markdown
Contributor

The travis CI run is backed up -- https://github.com/apache/arrow/pull/9114/checks?check_run_id=1735587739 hasn't finished -- and this PR has no non-rust changes. I think it is good to go

@alambalamb closed this in 23550c2Jan 20, 2021
@ovr
ovr deleted the issue-11149 branch January 20, 2021 18:26
kszucs pushed a commit that referenced this pull request Jan 25, 2021
…_batch_empty
Previously `build_empty_list_array` was declared inside Parquet (`array_reader`), but I will use this function inside DataFushion's `create_batch_empty` (it's used inside hash_aggregate to make an empty batch from the provided schema that contains type for columns). I moved it to Arrow (because it's common and useful) and made `build_empty_large_list_array` (for large lists) on top of macros with different implementation than build_empty_list_array.
Closes#9114 from ovr/issue-11149
Authored-by: Dmitry Patsura <zaets28rus@gmail.com>
Signed-off-by: Andrew Lamb <andrew@nerdnetworks.org>
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants

@ovr@jorgecarleitao@nevi-me@codecov-io@alamb