edponce commented on a change in pull request #10721:
URL: https://github.com/apache/arrow/pull/10721#discussion_r672448128
##########
File path: cpp/src/arrow/compute/kernels/scalar_cast_test.cc
##########
@@ -1930,29 +1930,23 @@ TEST(Cast, DictTypeToAnotherDict) {
check_cast(dictionary(int32(), utf8()), dictionary(int8(), utf8()),
R"(["a", "b", "a", null])");
+ // check float types (NOTE: ArrayFromJSON doesnt work for float value
dictionary types)
Review comment:
The error is from `ArrayFromJSON(dictionary(..., floatXX()), ...)` is:
```
NotImplemented: JSON conversion to dictionary<values=float, indices=int8,
ordered=0> not implemented
```
Nevertheless, you can `Cast` successfully to `float` values with
```
auto arr = ArrayFromJSON(dictionary(int8(), int32()), "[1, 2, 3, 1, null,
3]");
ASSERT_OK_AND_ASSIGN(auto casted, Cast(arr, dictionary(int8(), float32()),
CastOptions::Safe()));
```
##########
File path: cpp/src/arrow/compute/kernels/scalar_cast_test.cc
##########
@@ -1930,29 +1930,23 @@ TEST(Cast, DictTypeToAnotherDict) {
check_cast(dictionary(int32(), utf8()), dictionary(int8(), utf8()),
R"(["a", "b", "a", null])");
+ // check float types (NOTE: ArrayFromJSON doesnt work for float value
dictionary types)
Review comment:
The error is from `ArrayFromJSON(dictionary(..., floatXX()), ...)` is:
```
NotImplemented: JSON conversion to dictionary<values=float, indices=int8,
ordered=0> not implemented
```
Nevertheless, you can `Cast` successfully to `float` values with
```
auto arr = ArrayFromJSON(dictionary(int8(), int32()), "[1, 2, 3, 1, null,
3]");
ASSERT_OK_AND_ASSIGN(auto casted, Cast(arr, dictionary(int8(), float32()),
CastOptions::Safe()));
```
There is also a `DictArrayFromJSON` but this requires explicit index values:
```
auto arr = DictArrayFromJSON(dictionary(int8(), float32()), "[0, 1, 2, 3, 4,
5]", "[1, 2, 3, 1, null, 3]");
```
##########
File path: cpp/src/arrow/compute/kernels/scalar_cast_test.cc
##########
@@ -1930,29 +1930,23 @@ TEST(Cast, DictTypeToAnotherDict) {
check_cast(dictionary(int32(), utf8()), dictionary(int8(), utf8()),
R"(["a", "b", "a", null])");
+ // check float types (NOTE: ArrayFromJSON doesnt work for float value
dictionary types)
Review comment:
@nirandaperera I submitted [this
PR](https://github.com/apache/arrow/pull/10746) that enables using
`ArrayFromJSON` for dictionaries with floating-point values. If PR passes and
gets merged, you can change test accordingly and remove error comment.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]