Skip to content

Comments

fix: TopK operator should return correct results on dictionary column with nulls#1033

Merged
andygrove merged 1 commit intoapache:mainfrom
viirya:fix_topk_dictionary
Oct 24, 2024
Merged

fix: TopK operator should return correct results on dictionary column with nulls#1033
andygrove merged 1 commit intoapache:mainfrom
viirya:fix_topk_dictionary

Conversation

@viirya
Copy link
Member

@viirya viirya commented Oct 23, 2024

Which issue does this PR close?

Closes #1030.

Rationale for this change

What changes are included in this PR?

How are these changes tested?

@viirya viirya force-pushed the fix_topk_dictionary branch from 297c242 to 574fc34 Compare October 23, 2024 19:18
@viirya
Copy link
Member Author

viirya commented Oct 23, 2024

cc @huaxingao With this patch, the failed Iceberg test can pass now.

@viirya viirya requested a review from andygrove October 23, 2024 19:21
cast_with_options(array, value_type.as_ref(), &options)
// We need to copy the array after `cast` because arrow-rs `take` kernel which is used
// to unpack dictionary array might reuse the input array's null buffer.
Ok(copy_array(&cast_with_options(
Copy link
Member Author

@viirya viirya Oct 23, 2024

Choose a reason for hiding this comment

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

If apache/arrow-rs#6616 can merge, we don't need this extra copy.

This will do extra copy on data buffer too, although the issue happens on null buffer only.

Actually we can have custom unpack dictionary and take implementation to only copy null buffer, but I put this simply for now with the expectation that the fix at arrow-rs could be merged eventually.

If the arrow-rs patch is blocked on merging eventually, I will open another PR to have custom unpack dictionary and take implementation to reduce the copy cost here.

Copy link
Contributor

@huaxingao huaxingao left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks for the fix @viirya

Copy link
Member

@andygrove andygrove left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks @viirya

@andygrove andygrove merged commit 0e9349f into apache:main Oct 24, 2024
@andygrove
Copy link
Member

I ran TPC-H benchmarks comparing this PR to main and did not see any regression

@viirya
Copy link
Member Author

viirya commented Oct 24, 2024

Thanks @huaxingao @andygrove

@viirya viirya deleted the fix_topk_dictionary branch October 24, 2024 07:13
coderfender pushed a commit to coderfender/datafusion-comet that referenced this pull request Dec 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

TopK operator (i.e. CometTakeOrderedAndProjectExec) may return incorrect result

3 participants