diff --git a/cpp/src/arrow/scalar_test.cc b/cpp/src/arrow/scalar_test.cc index cba817f67b1..a7ba5980feb 100644 --- a/cpp/src/arrow/scalar_test.cc +++ b/cpp/src/arrow/scalar_test.cc @@ -30,6 +30,7 @@ #include "arrow/array.h" #include "arrow/array/util.h" #include "arrow/buffer.h" +#include "arrow/compute/cast.h" #include "arrow/memory_pool.h" #include "arrow/scalar.h" #include "arrow/status.h" @@ -40,6 +41,9 @@ namespace arrow { +using compute::Cast; +using compute::CastOptions; + using internal::checked_cast; using internal::checked_pointer_cast; @@ -862,9 +866,9 @@ TEST(TestTimestampScalars, MakeScalar) { TEST(TestTimestampScalars, Cast) { auto convert = [](TimeUnit::type in, TimeUnit::type out, int64_t value) -> int64_t { - auto scalar = - TimestampScalar(value, timestamp(in)).CastTo(timestamp(out)).ValueOrDie(); - return internal::checked_pointer_cast(scalar)->value; + EXPECT_OK_AND_ASSIGN(auto casted, Cast(TimestampScalar(value, timestamp(in)), + timestamp(out), CastOptions::Unsafe())); + return internal::checked_pointer_cast(casted.scalar())->value; }; EXPECT_EQ(convert(TimeUnit::SECOND, TimeUnit::MILLI, 1), 1000);