From 2416d1986a402ce857998ec2fa8905b9fcf91ba5 Mon Sep 17 00:00:00 2001 From: mwish Date: Wed, 4 Sep 2024 23:53:59 +0800 Subject: [PATCH] apply suggestions --- .../arrow/compute/kernels/scalar_cast_string.cc | 12 ++++++------ .../arrow/compute/kernels/scalar_cast_test.cc | 16 +++++----------- 2 files changed, 11 insertions(+), 17 deletions(-) diff --git a/cpp/src/arrow/compute/kernels/scalar_cast_string.cc b/cpp/src/arrow/compute/kernels/scalar_cast_string.cc index fcb8dc35baec9..4edf00225d317 100644 --- a/cpp/src/arrow/compute/kernels/scalar_cast_string.cc +++ b/cpp/src/arrow/compute/kernels/scalar_cast_string.cc @@ -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."); } } } @@ -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."); } } diff --git a/cpp/src/arrow/compute/kernels/scalar_cast_test.cc b/cpp/src/arrow/compute/kernels/scalar_cast_test.cc index a45af55c793e9..6315044a1ba05 100644 --- a/cpp/src/arrow/compute/kernels/scalar_cast_test.cc +++ b/cpp/src/arrow/compute/kernels/scalar_cast_test.cc @@ -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}); } @@ -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)});