Skip to content

Commit

Permalink
GH-45362: Fix Identity cast for timestamp
Browse files Browse the repository at this point in the history
  • Loading branch information
mapleFU committed Jan 28, 2025
1 parent 1a01b40 commit 87b149a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion cpp/src/arrow/scalar.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1177,7 +1177,7 @@ enable_if_duration<To, Result<std::shared_ptr<Scalar>>> CastImpl(
}

// time to time
template <typename To, typename From, typename T = typename To::TypeClass>
template <typename To, typename From>
enable_if_time<To, Result<std::shared_ptr<Scalar>>> CastImpl(
const TimeScalar<From>& from, std::shared_ptr<DataType> to_type) {
using ToScalar = typename TypeTraits<To>::ScalarType;
Expand Down
3 changes: 3 additions & 0 deletions cpp/src/arrow/scalar_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -866,6 +866,9 @@ TEST(TestTimeScalars, Basics) {
ASSERT_TRUE(first->Equals(*MakeScalar(ty, 5).ValueOrDie()));
ASSERT_TRUE(last->Equals(*MakeScalar(ty, 42).ValueOrDie()));
ASSERT_FALSE(last->Equals(*MakeScalar("string")));

ASSERT_OK_AND_ASSIGN(auto casted, first->CastTo(ty));
ASSERT_TRUE(casted->Equals(*first));
}
}

Expand Down

0 comments on commit 87b149a

Please sign in to comment.