| 1138 | } |
| 1139 | |
| 1140 | Result<std::shared_ptr<Scalar>> DictScalarFromJSONString( |
| 1141 | const std::shared_ptr<DataType>& type, std::string_view index_json, |
| 1142 | std::string_view dictionary_json) { |
| 1143 | if (type->id() != Type::DICTIONARY) { |
| 1144 | return Status::TypeError("DictScalarFromJSONString requires dictionary type, got ", |
| 1145 | *type); |
| 1146 | } |
| 1147 | |
| 1148 | const auto& dictionary_type = checked_cast<const DictionaryType&>(*type); |
| 1149 | |
| 1150 | std::shared_ptr<Array> dictionary; |
| 1151 | ARROW_ASSIGN_OR_RAISE(auto index, |
| 1152 | ScalarFromJSONString(dictionary_type.index_type(), index_json)); |
| 1153 | ARROW_ASSIGN_OR_RAISE( |
| 1154 | dictionary, ArrayFromJSONString(dictionary_type.value_type(), dictionary_json)); |
| 1155 | |
| 1156 | return DictionaryScalar::Make(std::move(index), std::move(dictionary)); |
| 1157 | } |
| 1158 | |
| 1159 | } // namespace json |
| 1160 | } // namespace arrow |
no test coverage detected