fix(c/driver/postgresql): encode Arrow JSON for JSONB COPY - #4505
Merged
lidavidm merged 1 commit intoJul 14, 2026
Merged
Conversation
lidavidm
approved these changes
Jul 14, 2026
lidavidm
left a comment
Member
There was a problem hiding this comment.
Thanks, looks pretty straightforward.
Member
BOKJUNSOO
force-pushed
the
fix-postgresql-copy-arrow-json-to-jsonb
branch
from
July 14, 2026 04:33
8f48924 to
f6eda15
Compare
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
PostgreSQL binary COPY represents a
jsonbfield as a version byte followed bythe JSON text. The PostgreSQL driver currently sends the physical string storage
of
extension<arrow.json>unchanged, so PostgreSQL interprets the first JSON byteas the version (for example,
{becomes version 123) and rejects the row.This adds a target-aware JSONB COPY field writer. When the Arrow source is
extension<arrow.json>and the existing PostgreSQL target column isjsonb, thewriter prefixes the JSON bytes with version
0x01and includes that byte in thefield length. Other string inputs and PostgreSQL
jsontargets continue to usethe existing writer.
The existing JSONB ingest regression test now verifies a successful round-trip,
including a SQL NULL value.
Testing
pre-commit run --files c/driver/postgresql/copy/writer.h c/driver/postgresql/postgresql_test.cc(all applicable C/C++ checks passed)adbc-driver-postgresql-test(242 passed, 6 skipped)adbc-driver-postgresql-copy-test(73 passed)extension<arrow.json>values from the reported sample Parquet file through the locally built driver into a PostgreSQLjsonbcolumn without a compatibility shim (100 inserted and validated)Depends on #4499 for resolving existing PostgreSQL target column types during
COPY writer selection.
Closes #3293