Skip to content

Commit

Permalink
scalar_cast_test.cc: Include string and binary-views types in cast-ch…
Browse files Browse the repository at this point in the history
…ecking loop
  • Loading branch information
felipecrv committed Jul 17, 2024
1 parent 423a10f commit a5181b5
Showing 1 changed file with 3 additions and 16 deletions.
19 changes: 3 additions & 16 deletions cpp/src/arrow/compute/kernels/scalar_cast_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -201,10 +201,12 @@ TEST(Cast, CanCast) {
ExpectCannotCast(from_numeric, {null()});
}

for (auto from_base_binary : kBaseBinaryTypes) {
for (auto from_base_binary : kBaseBinaryAndViewTypes) {
ExpectCanCast(from_base_binary, {boolean()});
ExpectCanCast(from_base_binary, kNumericTypes);
ExpectCanCast(from_base_binary, kBaseBinaryTypes);
// XXX: add float16 to kNumericTypes
ExpectCanCast(from_base_binary, {float16()});
ExpectCanCast(dictionary(int64(), from_base_binary), {from_base_binary});

// any cast which is valid for the dictionary is valid for the DictionaryArray
Expand All @@ -213,21 +215,6 @@ TEST(Cast, CanCast) {

ExpectCannotCast(from_base_binary, {null()});
}
// XXX: include utf8_view() on the list above once all of these pass
for (auto view_ty : {utf8_view(), binary_view()}) {
ExpectCanCast(view_ty, {boolean()});
ExpectCanCast(view_ty, kNumericTypes);
ExpectCanCast(view_ty, kBaseBinaryTypes);
// XXX: add float16 to kNumericTypes
ExpectCanCast(view_ty, {float16()});
ExpectCanCast(dictionary(int64(), view_ty), {view_ty});

// any cast which is valid for the dictionary is valid for the DictionaryArray
ExpectCanCast(dictionary(uint32(), view_ty), kBaseBinaryTypes);
ExpectCanCast(dictionary(int16(), view_ty), kNumericTypes);

ExpectCannotCast(view_ty, {null()});
}

ExpectCanCast(utf8(), {timestamp(TimeUnit::MILLI), date32(), date64()});
ExpectCanCast(large_utf8(), {timestamp(TimeUnit::NANO), date32(), date64()});
Expand Down

0 comments on commit a5181b5

Please sign in to comment.