diff --git a/cpp/include/cudf/unary.hpp b/cpp/include/cudf/unary.hpp index 316e031a02d0..7cc352ab14ee 100644 --- a/cpp/include/cudf/unary.hpp +++ b/cpp/include/cudf/unary.hpp @@ -117,7 +117,7 @@ std::unique_ptr is_valid( * @param mr Device memory resource used to allocate the returned column's device memory * * @returns Column of same size as `input` containing result of the cast operation - * @throw cudf::logic_error if `out_type` is not a fixed-width type + * @throw cudf::logic_error if `input` or `out_type` is not a fixed-width type */ std::unique_ptr cast( column_view const& input, diff --git a/cpp/src/unary/cast_ops.cu b/cpp/src/unary/cast_ops.cu index fcee2b368fcc..49fbbf76e663 100644 --- a/cpp/src/unary/cast_ops.cu +++ b/cpp/src/unary/cast_ops.cu @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: Copyright (c) 2019-2026, NVIDIA CORPORATION. + * SPDX-FileCopyrightText: Copyright (c) 2019-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. * SPDX-License-Identifier: Apache-2.0 */ @@ -118,7 +118,7 @@ struct fixed_point_unary_cast { template constexpr inline auto is_supported_non_fixed_point_cast() { - return cudf::is_fixed_width() && + return cudf::is_fixed_width() && cudf::is_fixed_width() && // Disallow fixed_point here (requires different specialization) !(cudf::is_fixed_point() || cudf::is_fixed_point()) && // Disallow conversions between timestamps and numeric diff --git a/cpp/tests/unary/cast_tests.cpp b/cpp/tests/unary/cast_tests.cpp index 5fcec956a8d9..1830422344e7 100644 --- a/cpp/tests/unary/cast_tests.cpp +++ b/cpp/tests/unary/cast_tests.cpp @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: Copyright (c) 2020-2026, NVIDIA CORPORATION. + * SPDX-FileCopyrightText: Copyright (c) 2020-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. * SPDX-License-Identifier: Apache-2.0 */ @@ -201,6 +201,15 @@ inline auto make_data_type() return cudf::data_type{cudf::type_to_id()}; } +TEST(IsSupportedCast, UnsupportedTypes) +{ + auto const to_int32 = cudf::data_type{cudf::type_id::INT32}; + EXPECT_FALSE(cudf::is_supported_cast(cudf::data_type{cudf::type_id::STRING}, to_int32)); + EXPECT_FALSE(cudf::is_supported_cast(cudf::data_type{cudf::type_id::LIST}, to_int32)); + EXPECT_FALSE(cudf::is_supported_cast(cudf::data_type{cudf::type_id::STRUCT}, to_int32)); + EXPECT_FALSE(cudf::is_supported_cast(cudf::data_type{cudf::type_id::DICTIONARY32}, to_int32)); +} + struct CastTimestampsSimple : public cudf::test::BaseFixture {}; TEST_F(CastTimestampsSimple, IsIdempotent)