-
Notifications
You must be signed in to change notification settings - Fork 4k
Closed
Description
Describe the enhancement requested
This is a sub-issue of the issue mentioned below.
As we can see in the parent issue, we can find tables organizing the related functions.
| file name | code snippet |
|---|---|
| partition_test.cc | ASSERT_OK_AND_ASSIGN(auto dict_hello, MakeScalar("hello")->CastTo(DictStr("")->type())); |
| partition_test.cc | ASSERT_OK_AND_ASSIGN(auto dict_hello, MakeScalar("hello")->CastTo(dict_type)); |
| scalar_test.cc | ASSERT_OK_AND_ASSIGN(auto cast_alpha, alpha->CastTo(ty)); |
The functions result in "Unsupported cast from string to dictionary using function cast_dictionary" error.
We need to implement casting from String to Dictionary.
partition_test.cc
Snippet to reproduce
TEST_F(TestPartitioning, DirectoryPartitioningFormatDictionary) {
...
- ASSERT_OK_AND_ASSIGN(auto dict_hello, MakeScalar("hello")->CastTo(DictStr("")->type()));
+ ASSERT_OK_AND_ASSIGN(auto dict_hello, Cast(MakeScalar("hello"), DictStr("")->type()));
}
TEST_F(TestPartitioning, DirectoryPartitioningFormatDictionaryCustomIndex) {
...
- ASSERT_OK_AND_ASSIGN(auto dict_hello, MakeScalar("hello")->CastTo(dict_type));
+ ASSERT_OK_AND_ASSIGN(auto dict_hello, Cast(MakeScalar("hello"), dict_type));scalar_test.cc
Snippet to reproduce
TEST(TestDictionaryScalar, Cast) {
...
// Cast string to dict(..., string)
- ASSERT_OK_AND_ASSIGN(auto cast_alpha, alpha->CastTo(ty));
- ASSERT_OK(cast_alpha->ValidateFull());
+ ASSERT_OK_AND_ASSIGN(auto cast_alpha, Cast(alpha, ty));
+ const auto& scalar = cast_alpha.scalar();
+ ASSERT_OK(scalar->ValidateFull());
ASSERT_OK_AND_ASSIGN(
auto roundtripped_alpha,
- checked_cast<const DictionaryScalar&>(*cast_alpha).GetEncodedValue());
+ checked_cast<const DictionaryScalar&>(*scalar).GetEncodedValue());
...
// dictionaries differ, though encoded values are identical
- ASSERT_FALSE(alpha_dict.Equals(*cast_alpha));
+ ASSERT_FALSE(alpha_dict.Equals(*scalar));Component(s)
C++