| 1051 | } |
| 1052 | |
| 1053 | Result<std::shared_ptr<Scalar>> DictScalarFromJSONString( |
| 1054 | const std::shared_ptr<DataType>& type, std::string_view index_json, |
| 1055 | std::string_view dictionary_json) { |
| 1056 | if (type->id() != Type::DICTIONARY) { |
| 1057 | return Status::TypeError("DictScalarFromJSONString requires dictionary type, got ", |
| 1058 | *type); |
| 1059 | } |
| 1060 | |
| 1061 | const auto& dictionary_type = checked_cast<const DictionaryType&>(*type); |
| 1062 | |
| 1063 | std::shared_ptr<Array> dictionary; |
| 1064 | ARROW_ASSIGN_OR_RAISE(auto index, |
| 1065 | ScalarFromJSONString(dictionary_type.index_type(), index_json)); |
| 1066 | ARROW_ASSIGN_OR_RAISE( |
| 1067 | dictionary, ArrayFromJSONString(dictionary_type.value_type(), dictionary_json)); |
| 1068 | |
| 1069 | return DictionaryScalar::Make(std::move(index), std::move(dictionary)); |
| 1070 | } |
| 1071 | |
| 1072 | } // namespace json |
| 1073 | } // namespace arrow |
no test coverage detected