Skip to content

Commit

Permalink
apply suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
mapleFU authored and pitrou committed Sep 12, 2024
1 parent b17e170 commit 2416d19
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 17 deletions.
12 changes: 6 additions & 6 deletions cpp/src/arrow/compute/kernels/scalar_cast_string.cc
Original file line number Diff line number Diff line change
Expand Up @@ -396,9 +396,9 @@ BinaryToBinaryCastExec(KernelContext* ctx, const ExecSpan& batch, ExecResult* ou
// A more complicated loop could work by slicing the data buffer into
// more than one variadic buffer, but this is probably overkill for now
// before someone hits this problem in practice.
return Status::Invalid("Failed casting from ", input.type->ToString(), " to ",
output->type->ToString(),
": input array too large for efficient conversion.");
return Status::CapacityError("Failed casting from ", input.type->ToString(),
" to ", output->type->ToString(),
": input array too large for efficient conversion.");
}
}
}
Expand Down Expand Up @@ -499,9 +499,9 @@ BinaryToBinaryCastExec(KernelContext* ctx, const ExecSpan& batch, ExecResult* ou
// A more complicated loop could work by slicing the data buffer into
// more than one variadic buffer, but this is probably overkill for now
// before someone hits this problem in practice.
return Status::Invalid("Failed casting from ", input.type->ToString(), " to ",
output->type->ToString(),
": input array too large for efficient conversion.");
return Status::CapacityError("Failed casting from ", input.type->ToString(), " to ",
output->type->ToString(),
": input array too large for efficient conversion.");
}
}

Expand Down
16 changes: 5 additions & 11 deletions cpp/src/arrow/compute/kernels/scalar_cast_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -205,8 +205,8 @@ TEST(Cast, CanCast) {
ExpectCanCast(from_base_binary, {boolean()});
ExpectCanCast(from_base_binary, kNumericTypes);
ExpectCanCast(from_base_binary, kBaseBinaryTypes);
/// TODO(GH-43010): include is_binary_view_like() types here once array_take
/// can handle string-views
// TODO(GH-43010): include is_binary_view_like() types here once array_take
// can handle string-views
if (!is_binary_view_like(*from_base_binary)) {
ExpectCanCast(dictionary(int64(), from_base_binary), {from_base_binary});
}
Expand All @@ -223,15 +223,9 @@ TEST(Cast, CanCast) {
ExpectCannotCast(timestamp(TimeUnit::MICRO),
{binary(), large_binary()}); // no formatting supported

ExpectCanCast(fixed_size_binary(3), {
utf8(),
large_utf8(),
utf8_view(),
binary(),
large_binary(),
binary_view(),
fixed_size_binary(3),
});
ExpectCanCast(fixed_size_binary(3), kBaseBinaryAndViewTypes);
// Identity cast
ExpectCanCast(fixed_size_binary(3), {fixed_size_binary(3)});
// Doesn't fail since a kernel exists (but it will return an error when executed)
// ExpectCannotCast(fixed_size_binary(3), {fixed_size_binary(5)});

Expand Down

0 comments on commit 2416d19

Please sign in to comment.