[spark] Support JSON format in COPY INTO#7993
Open
JunRuiLee wants to merge 1 commit into
Open
Conversation
Add JSON format support for COPY INTO import and export, alongside existing CSV support. JSON uses column-name matching (not positional), with options for MULTI_LINE, DATE_FORMAT, TIMESTAMP_FORMAT, NULL_IF, EMPTY_FIELD_AS_NULL, and COMPRESSION. CSV-only options are rejected for JSON format. Includes 9 new tests and documentation updates.
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
COPY INTOimport and export, alongside existing CSV supportMULTI_LINE,NULL_IF,EMPTY_FIELD_AS_NULL, andCOMPRESSIONFIELD_DELIMITER,SKIP_HEADER) are rejected for JSON format with clear error messagesMotivation
JSON is a common format for semi-structured data in data lake scenarios. Some users have requested JSON support for
COPY INTOto complement the existing CSV capability.Part of #8005
Changes
JSONlexer token toPaimonSqlExtensions.g4FileFormatType.JSON, format-specific option validation and Spark reader/writer option mapping_c0/_c1), dispatch.json()/.csv()by format typesql-write.mdwith JSON syntax, options, and column mapping semanticsTests
Added 16 JSON test cases covering: basic import, column-name matching, multi-line, explicit column list, NULL_IF, export, option validation, round-trip (export then import), extra/missing fields handling, malformed data abort, bad cast abort, GZIP compression, and date/timestamp column casting.