Skip to content

Commit 25a9d01

Browse files
committed
Add context argument to garrow_execute_plan_new
1 parent 175e70c commit 25a9d01

File tree

3 files changed

+28
-5
lines changed

3 files changed

+28
-5
lines changed

c_glib/arrow-glib/compute.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1889,6 +1889,7 @@ garrow_execute_plan_class_init(GArrowExecutePlanClass *klass)
18891889

18901890
/**
18911891
* garrow_execute_plan_new:
1892+
* @context: (nullable): A #GArrowExecuteContext or %NULL.
18921893
* @error: (nullable): Return location for a #GError or %NULL.
18931894
*
18941895
* Returns: (nullable): A newly created #GArrowExecutePlan on success,
@@ -1897,9 +1898,15 @@ garrow_execute_plan_class_init(GArrowExecutePlanClass *klass)
18971898
* Since: 6.0.0
18981899
*/
18991900
GArrowExecutePlan *
1900-
garrow_execute_plan_new(GError **error)
1901+
garrow_execute_plan_new(GArrowExecuteContext *context, GError **error)
19011902
{
1902-
auto arrow_plan_result = arrow::acero::ExecPlan::Make();
1903+
arrow::Result<std::shared_ptr<arrow::acero::ExecPlan>> arrow_plan_result;
1904+
if (context) {
1905+
auto arrow_context = garrow_execute_context_get_raw(context);
1906+
arrow_plan_result = arrow::acero::ExecPlan::Make(*arrow_context);
1907+
} else {
1908+
arrow_plan_result = arrow::acero::ExecPlan::Make();
1909+
}
19031910
if (garrow::check(error, arrow_plan_result, "[execute-plan][new]")) {
19041911
return GARROW_EXECUTE_PLAN(
19051912
g_object_new(GARROW_TYPE_EXECUTE_PLAN, "plan", &(*arrow_plan_result), NULL));

c_glib/arrow-glib/compute.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@ struct _GArrowExecutePlanClass
323323

324324
GARROW_AVAILABLE_IN_6_0
325325
GArrowExecutePlan *
326-
garrow_execute_plan_new(GError **error);
326+
garrow_execute_plan_new(GArrowExecuteContext *context, GError **error);
327327
GARROW_AVAILABLE_IN_6_0
328328
GArrowExecuteNode *
329329
garrow_execute_plan_build_node(GArrowExecutePlan *plan,

c_glib/test/test-execute-plan.rb

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ def execute(plan)
2828
end
2929

3030
sub_test_case("aggregate") do
31-
def build_plan
32-
plan = Arrow::ExecutePlan.new
31+
def build_plan(context = nil)
32+
plan = Arrow::ExecutePlan.new(context)
3333

3434
record_batch =
3535
build_record_batch(number: build_int8_array([1, 2, 3, 4, 5]),
@@ -63,6 +63,22 @@ def test_by_string
6363
reader.read_all)
6464
end
6565
end
66+
67+
def test_hash_first_with_single_thread
68+
thread_pool = Arrow::ThreadPool.new(1)
69+
context = Arrow::ExecuteContext.new(thread_pool)
70+
plan, reader = build_plan(context) do
71+
aggregations = [
72+
Arrow::Aggregation.new("hash_first", nil, "number", "first(number)"),
73+
]
74+
Arrow::AggregateNodeOptions.new(aggregations, ["string"])
75+
end
76+
execute(plan) do
77+
assert_equal(build_table("string" => build_string_array(["a", "b"]),
78+
"first(number)" => build_int8_array([1, 2])),
79+
reader.read_all)
80+
end
81+
end
6682
end
6783

6884
sub_test_case("hash join") do

0 commit comments

Comments
 (0)