Skip to content

Commit

Permalink
skip choose
Browse files Browse the repository at this point in the history
  • Loading branch information
ZhangHuiGui committed Apr 28, 2024
1 parent ca6dde5 commit f8b7ecf
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 30 deletions.
26 changes: 0 additions & 26 deletions cpp/src/arrow/compute/expression_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -992,32 +992,6 @@ TEST(Expression, ExecuteCallWithDecimalIfElseOps) {
{"a1": "45.3", "a2": -30, "a3": "0.00"}
])"));
}

// choose
{
// decimal128(3,3), decimal256(2,1) --> output_type: decimal256(5, 3)
ExpectExecute(
call("coalesce", {field_ref("idx"), field_ref("a1"), field_ref("a2")}),
ArrayFromJSON(struct_({field("idx", int64()), field("a1", decimal128(3, 3)),
field("a2", decimal128(2, 1))}),
R"([
{"idx": 0, "a1": "1.123", "a2": "2.3"},
{"idx": 1, "a1": null, "a2": "-3.3"},
{"idx": 0, "a1": "-1.230", "a2": "0.0"},
{"idx": null, "a1": "-1.230", "a2": "0.0"}
])"));

// decimal128(3,3), float32() --> output_type: decimal128(3, 3)
ExpectExecute(
call("coalesce", {field_ref("idx"), field_ref("a1"), field_ref("a2")}),
ArrayFromJSON(struct_({field("idx", int64()), field("a1", decimal128(3, 3)),
field("a2", float32())}),
R"([
{"idx": null, "a1": "1.123", "a2": 2.3},
{"idx": 1, "a1": null, "a2": -3.3},
{"idx": 0, "a1": "-1.230", "a2": 0.0}
])"));
}
}

TEST(Expression, ExecuteCallWithNoArguments) {
Expand Down
7 changes: 3 additions & 4 deletions cpp/src/arrow/compute/kernels/scalar_if_else.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2773,10 +2773,9 @@ void AddPrimitiveCoalesceKernels(const std::shared_ptr<ScalarFunction>& scalar_f

void AddChooseKernel(const std::shared_ptr<ScalarFunction>& scalar_function,
detail::GetTypeId get_id, ArrayKernelExec exec) {
ScalarKernel kernel(
KernelSignature::Make({Type::INT64, InputType(get_id.id)}, ResolveOutputType,
/*is_varargs=*/true),
exec);
ScalarKernel kernel(KernelSignature::Make({Type::INT64, InputType(get_id.id)}, LastType,
/*is_varargs=*/true),
exec);
kernel.null_handling = NullHandling::COMPUTED_PREALLOCATE;
kernel.mem_allocation = MemAllocation::PREALLOCATE;
kernel.can_write_into_slices = is_fixed_width(get_id.id);
Expand Down

0 comments on commit f8b7ecf

Please sign in to comment.