feat(c/driver/postgresql): Support JSON and JSONB types #2072
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.
This PR adds support for JSON and JSONB types. Before this PR, the raw COPY was returned: for JSON, this would have been the bytes of a the JSON string. For JSONB, this would have been the bytes of the JSON string prefixed by
0x01
, which is the one and only version number of tthe JSONB COPY binary format.This PR routes it through the string type. We could also route this through the JSON canonical extension type by adding some metadata. I don't think an implementation of that type exists anywhere yet (but it might functionally be the same since pyarrow/Arrow C++ would just drop the extension metadata).
The testing here is a bit repetitive...we could definitely improve on reducing duplication in the test cases 😬 .
Closes #2068.
Reproducer in R:
Created on 2024-08-11 with reprex v2.1.0