Copilot commented on code in PR #49635:
URL: https://github.com/apache/arrow/pull/49635#discussion_r3020962805
##########
ruby/red-arrow-format/lib/arrow-format/integration/json-reader.rb:
##########
@@ -384,7 +384,8 @@ def read_array(column, type)
when DictionaryType
validity_buffer = read_bitmap(column["VALIDITY"])
indices_buffer = read_values(column["DATA"], type.index_type)
- dictionary = read_dictionary(type.id, type.value_type)
+ dictionary_array = read_dictionary(type.id, type.value_type)
Review Comment:
`read_dictionary` can return `nil` when the dictionary id isn't present in
the JSON. Wrapping that in `Dictionary.new(type.id, dictionary_array)` will
defer the failure to a later `NoMethodError` (e.g., when `DictionaryArray#to_a`
calls `dictionary.array`). Consider raising a clear exception here if
`dictionary_array` is `nil` (include the dictionary id and value type) to fail
fast with an actionable error.
```suggestion
dictionary_array = read_dictionary(type.id, type.value_type)
if dictionary_array.nil?
raise "Dictionary with id #{type.id} and value type " \
"#{type.value_type.inspect} is missing from JSON
dictionaries"
end
```
--
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]