JSON parser fails on maps with bool keys
- Dominant language
- Rust
- Stars
- 3.6k
- Forks
- 1.3k
- Avg merge
- 2d 14h
- Merged PRs (30d)
- 167
Description
**Describe the bug**
JSON objects must have string keys. So when parsing to maps with non-string key types, the string must be coerced into the type. For example, using a schema with a Map(Int32, Int32) type parses rows like `{"map_i32_i32": {"1": 2}}` into a RecordBatch with a single column with a Map(Int32, Int32) type.
However, this does not happen for bool key maps. If you try to use a schema with a Map(Boolean, Int32) type, parsing `{"map_bool_i32": {"true": 1}}` raises an error:
```
JsonError("whilst decoding field 'map_bool_i32': expected boolean got \"true\"")
```
**To Reproduce**
Gist https://gist.github.com/jagill/1dd71ff6413002a042089feca89c6eab has a minimal reproduction.
**Expected behavior**
`map_bool_i32` should parse to a Map(Boolean, Int32) array.
**Additional context**
Similar bug report for serde_json, with a link to the fix PR: https://github.com/serde-rs/json/issues/1054
Contributor guide
Research direction
Start with the minimal reproduction in the linked gist and the JSON parser entry point it exercises. Compare parsing of Map(Int32, Int32) with Map(Boolean, Int32), then verify that the boolean-key example produces a Map(Boolean, Int32) array without the reported JsonError.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- data
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100