Skip to content

ARROW-13540: [C++] Add order by sink node - #10863

Closed
lidavidm wants to merge 6 commits into
apache:masterfrom
lidavidm:arrow-13540
Closed

ARROW-13540: [C++] Add order by sink node#10863
lidavidm wants to merge 6 commits into
apache:masterfrom
lidavidm:arrow-13540

Conversation

@lidavidm

@lidavidmlidavidm commented Aug 3, 2021

Copy link
Copy Markdown
Member

Adds a sink node that accumulates, sorts, and emits sorted batches. This is a sink node as currently we don't have a good design for handling order-dependent operations in the rest of the pipeline.

@github-actions

Copy link
Copy Markdown

@lidavidm

Copy link
Copy Markdown
MemberAuthor

Draft for now since it'll require rebasing on top of #10793/ARROW-13482

@lidavidm

Copy link
Copy Markdown
MemberAuthor

Now reworked to tag batches instead of being a sink node. Next, I can try to implement a simple order-dependent aggregate kernel and see how far that takes us.

@lidavidm

Copy link
Copy Markdown
MemberAuthor

Added a hash_arg_min_max kernel that makes use of the OrderByNode's tag. See ARROW-12873.

@lidavidm

Copy link
Copy Markdown
MemberAuthor

Rebased on top of the registry PR.

@lidavidm
lidavidm marked this pull request as ready for review August 10, 2021 13:58
@lidavidmlidavidm changed the title ARROW-13540: [C++] Add order by sink nodeARROW-13540: [C++] Add order by nodeAug 10, 2021
@lidavidm

lidavidm commented Aug 10, 2021

Copy link
Copy Markdown
MemberAuthor

TODO: revert back to making OrderBy a SinkNode and split arg_min_max and related things into a separate JIRA

@lidavidmlidavidm changed the title ARROW-13540: [C++] Add order by nodeARROW-13540: [C++] Add order by sink nodeAug 11, 2021
@lidavidm

Copy link
Copy Markdown
MemberAuthor

Converted back to a sink node.

@bkietz
bkietz self-requested a review August 11, 2021 15:59

@bkietzbkietz 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.

Some minor comments, overall this looks solid

Comment threadcpp/src/arrow/compute/exec/options.h Outdated
Comment on lines 115 to 119

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 this comment needs to be refactored

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.

👍

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.

Nit: using this above please

Suggested change
Finishes(ResultWith(::testing::ElementsAreArray(expected))));
Finishes(ResultWith(ElementsAreArray(expected))));

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 it'd be worthwhile to extract TableFromExecBatches into exec/util.h

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.

Nit: this would be more readable as

Suggested change
auto maybe_sorted = SortData();
Status st = DoFinish();
if (ErrorIfNotOk(st)) {
producer_.Push(std::move(st));
}
SinkNode::Finish();
}
Status DoFinish() {
ARROW_ASSIGN_OR_RAISE(auto sorted, SortData());
//...

.AddToPlan(plan.get()));

ASSERT_THAT(StartAndCollect(plan.get(), sink_gen),
Finishes(ResultWith(::testing::ElementsAreArray({ExecBatchFromJSON(

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.

Suggested change
Finishes(ResultWith(::testing::ElementsAreArray({ExecBatchFromJSON(
Finishes(ResultWith(ElementsAreArray({ExecBatchFromJSON(

#include "arrow/compute/exec/exec_plan.h"

#include <mutex>
#include <unordered_map>

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.

Suggested change
#include <unordered_map>

@bkietzbkietz 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.

LGTM, thanks!

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

@lidavidm@bkietz