Skip to content

Commit

Permalink
ARROW-16796: [C++] Fix bad defaulting of ExecContext argument (#13355)
Browse files Browse the repository at this point in the history
See https://issues.apache.org/jira/browse/ARROW-16796

Authored-by: Yaron Gvili <[email protected]>
Signed-off-by: Weston Pace <[email protected]>
  • Loading branch information
rtpsw authored Jun 10, 2022
1 parent fd6a3ab commit 44eb260
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 8 deletions.
3 changes: 2 additions & 1 deletion cpp/src/arrow/compute/exec/filter_node.cc
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ class FilterNode : public MapNode {

auto filter_expression = filter_options.filter_expression;
if (!filter_expression.IsBound()) {
ARROW_ASSIGN_OR_RAISE(filter_expression, filter_expression.Bind(*schema));
ARROW_ASSIGN_OR_RAISE(filter_expression,
filter_expression.Bind(*schema, plan->exec_context()));
}

if (filter_expression.type()->id() != Type::BOOL) {
Expand Down
2 changes: 1 addition & 1 deletion cpp/src/arrow/compute/exec/hash_join.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class ARROW_EXPORT HashJoinSchema {
const std::string& right_field_name_prefix);

Result<Expression> BindFilter(Expression filter, const Schema& left_schema,
const Schema& right_schema);
const Schema& right_schema, ExecContext* exec_context);
std::shared_ptr<Schema> MakeOutputSchema(const std::string& left_field_name_suffix,
const std::string& right_field_name_suffix);

Expand Down
11 changes: 6 additions & 5 deletions cpp/src/arrow/compute/exec/hash_join_node.cc
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,8 @@ std::shared_ptr<Schema> HashJoinSchema::MakeOutputSchema(

Result<Expression> HashJoinSchema::BindFilter(Expression filter,
const Schema& left_schema,
const Schema& right_schema) {
const Schema& right_schema,
ExecContext* exec_context) {
if (filter.IsBound() || filter == literal(true)) {
return std::move(filter);
}
Expand Down Expand Up @@ -367,7 +368,7 @@ Result<Expression> HashJoinSchema::BindFilter(Expression filter,
filter);

// Step 3: Bind
ARROW_ASSIGN_OR_RAISE(filter, filter.Bind(filter_schema));
ARROW_ASSIGN_OR_RAISE(filter, filter.Bind(filter_schema, exec_context));
if (filter.type()->id() != Type::BOOL) {
return Status::TypeError("Filter expression must evaluate to bool, but ",
filter.ToString(), " evaluates to ",
Expand Down Expand Up @@ -514,9 +515,9 @@ class HashJoinNode : public ExecNode {
join_options.output_suffix_for_left, join_options.output_suffix_for_right));
}

ARROW_ASSIGN_OR_RAISE(
Expression filter,
schema_mgr->BindFilter(join_options.filter, left_schema, right_schema));
ARROW_ASSIGN_OR_RAISE(Expression filter,
schema_mgr->BindFilter(join_options.filter, left_schema,
right_schema, plan->exec_context()));

// Generate output schema
std::shared_ptr<Schema> output_schema = schema_mgr->MakeOutputSchema(
Expand Down
3 changes: 2 additions & 1 deletion cpp/src/arrow/compute/exec/project_node.cc
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ class ProjectNode : public MapNode {
int i = 0;
for (auto& expr : exprs) {
if (!expr.IsBound()) {
ARROW_ASSIGN_OR_RAISE(expr, expr.Bind(*inputs[0]->output_schema()));
ARROW_ASSIGN_OR_RAISE(
expr, expr.Bind(*inputs[0]->output_schema(), plan->exec_context()));
}
fields[i] = field(std::move(names[i]), expr.type());
++i;
Expand Down

0 comments on commit 44eb260

Please sign in to comment.