Fix JSON field support in merge_insert operations#5112
Draft
wjones127 wants to merge 1 commit intolance-format:mainfrom
Draft
Fix JSON field support in merge_insert operations#5112wjones127 wants to merge 1 commit intolance-format:mainfrom
wjones127 wants to merge 1 commit intolance-format:mainfrom
Conversation
Previously, merge_insert operations with JSON columns would fail with "Attempt to project field by different types: LargeBinary and Utf8" because field metadata was not preserved when creating the output schema. This fix uses the dataset schema as the source of truth for JSON metadata, allowing users to provide plain JSON strings (without pa.json() metadata) that are automatically converted based on the dataset schema. Changes: - Add lance_json_to_arrow_json utility in lance-arrow for field conversion - Update prepare_stream_schema to use dataset schema metadata for JSON fields - Add schema enrichment logic to handle plain string inputs for JSON fields - Simplify wrap_json_stream_for_reading using the new utility - Add tests for merge_insert with JSON columns Fixes lance-format#4831 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Contributor
|
ACTION NEEDED The PR title and description are used as the merge commit message. Please update your PR title and description to match the specification. For details on the error please inspect the "PR Title Check" action. |
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.
Previously, merge_insert operations with JSON columns would fail with the error:
This happened because field metadata was not preserved when creating the output schema in
prepare_stream_schema, causing the JSON conversion to fail.Changes
Core Fix
prepare_stream_schemato use dataset schema metadata instead of input schema metadata for JSON fieldscheck_compatible_schemato add arrow.json metadata to plain string inputs when the dataset has JSON fieldsNew Utility Function
lance_json_to_arrow_jsoninlance-arrow/src/json.rs- the inverse ofarrow_json_to_lance_jsonCode Cleanup
wrap_json_stream_for_readingto use the new utilityTests
Result
Users can now:
pa.json()or arrow.json extension metadata)merge_insertwith plain JSON strings (without any metadata)The dataset/table schema is now the source of truth for JSON conversion, not the input data schema.
Fixes #4831
🤖 Generated with Claude Code