fix: Serialize MAP columns as {key: value} in REST JSON (#89)#91
Open
jrosskopf wants to merge 1 commit into
Open
fix: Serialize MAP columns as {key: value} in REST JSON (#89)#91jrosskopf wants to merge 1 commit into
jrosskopf wants to merge 1 commit into
Conversation
Follow-up to the LIST/STRUCT/ARRAY/UNION fix. MAP columns were aliased onto the struct serializer, but a DuckDB MAP is physically LIST(STRUCT(key, value)), so they did not round-trip (serialized to null / wrong type) — reported on #89 after v26.06.25. - Add convertVectorMapToJson: slice the row's duckdb_list_entry, read key/value from the list child struct, emit {key: value} matching DuckDB's to_json. Empty map -> {}, NULL map -> null. - Add vectorEntryToMapKey: raw string for VARCHAR keys (escape-safe), JSON rendering for scalar keys (e.g. 10 -> "10"). - Fix a pre-existing logical-type leak in convertVectorDecimalToJson (now reachable via decimal map keys). - Add MAP regression tests: string keys, integer keys, empty, and NULL. Found via user follow-up + codex review.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Follow-up to #90. After v26.06.25 shipped the
LIST/STRUCT/ARRAY/UNIONfix, the reporter found that a nativeMAPcolumn still serializes incorrectly (null/ wrong type) — e.g.map_from_entries(...)→"reasons": null.A DuckDB
MAPis physicallyLIST(STRUCT(key, value)), but it was aliased onto the struct serializer, so it never round-tripped.Fix
convertVectorMapToJson— slice the row'sduckdb_list_entry, read key/value from the list child's struct, and emit a JSON object{key: value}matching DuckDB's ownto_json. Empty map →{}, NULL map →null.vectorEntryToMapKey— raw string for VARCHAR keys (escape-safe), JSON rendering for scalar keys (e.g.10→"10").convertVectorDecimalToJson(now reachable via decimal map keys), surfaced by codex review.Test plan
{}), NULL map (null).Relates to #89