Repository navigation
feat: add coerce_primitive in json - #26561
Open
ion-elgreco wants to merge 1 commit into
Open
ion-elgreco wants to merge 1 commit into
ion-elgreco wants to merge 1 commit into
Conversation
ion-elgreco
force-pushed
the
feat/json-coerce-primitive
branch
from
October 21, 2026 12:27
fc6e6e4 to
2ded6ca
Compare
ion-elgreco
force-pushed
the
feat/json-coerce-primitive
branch
from
October 24, 2026 09:58
2ded6ca to
67d16ec
Compare
ion-elgreco
force-pushed
the
feat/json-coerce-primitive
branch
from
November 10, 2026 23:17
67d16ec to
503e0c3
Compare
Contributor
|
🚀 Can you amend the PR description as per .github/pull_request_template.md? |
ion-elgreco
force-pushed
the
feat/json-coerce-primitive
branch
from
November 12, 2026 09:57
503e0c3 to
1513988
Compare
Author
|
@kosiew done! |
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.
Which issue does this PR close?
JsonSource#26560.Rationale for this change
When a JSON file has a number or a boolean in a column that the schema declares as a string, the scan fails with an error such as
expected string got false.arrow-jsoncan keep these values as text withReaderBuilder::with_coerce_primitive, butJsonSourcedoes not expose that option. We now have to write a custom JSON source.What changes are included in this PR?
JsonSource::with_coerce_primitiveand the getterJsonSource::coerce_primitive. The default isfalse, so current behavior does not change.JsonOpener::with_coerce_primitive. The opener passes the value toReaderBuilder::with_coerce_primitiveon every read path: byte range, local file, and stream, for newline-delimited JSON and JSON arrays.optional bool coerce_primitive = 3to theJsonScanExecNodeprotobuf messageWhat is the testing strategy for this PR?
test_coerce_primitiveindatafusion/datasource-json/src/source.rscovers each read pathjson_exec_coerce_primitiveindatafusion/core/src/datasource/physical_plan/json.rse2e test throughDataSourceExec.roundtrip_json_scan_preserves_format_optionsindatafusion/proto/tests/cases/plans/sources.rsnow checks that the option survives a protobuf round tripAre there any user-facing changes?
Yes. New public API:
JsonSource::with_coerce_primitiveJsonSource::coerce_primitiveJsonOpener::with_coerce_primitiveJsonScanExecNode::coerce_primitive(new optional protobuf field)The default behavior does not change. Code that builds or destructures
JsonScanExecNodewith all fields named must add the new field.