Repository navigation
SS-611 - storage: write jsonb strings as JSON in new Iceberg sinks - #41065
Draft
martykulma wants to merge 2 commits into
Draft
martykulma wants to merge 2 commits into
martykulma wants to merge 2 commits into
Conversation
Iceberg sinks wrote a jsonb string scalar as its bare contents, so '"hello"'::jsonb landed as hello, which is not valid JSON. Sinks now record the release they were created on in an internal CREATION VERSION option. Iceberg sinks that carry it write JSON text. Sinks that predate it keep the old encoding, because their equality deletes and append-mode retractions are matched by value against rows already in the table. Closes: SS-611 Co-Authored-By: Claude <noreply@anthropic.com>
Uses the form of mz_version_num(), which drops the semver dependency from mz-storage-types and mz-sql. Co-Authored-By: Claude <noreply@anthropic.com>
This branch has not been deployed
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.
Iceberg sinks wrote a jsonb string scalar as its bare contents.
'"hello"'::jsonblanded in the table ashello, which is not valid JSON, and'"123"'::jsonbwas indistinguishable from the number123. Objects, arrays and numbers were unaffected.Approach
An existing sink cannot simply switch encoding. Its equality deletes (jsonb is an allowed key type) and its append-mode retractions are matched by value against rows already in the table, so a switch would leave deleted rows visible.
Sinks now record the release they were created on, in an internal
CREATION VERSIONoption onCREATE SINK. The value is the integer release number thatmz_version_num()reports. It is handled likeVERSION. Purification stamps it on every new sink of any type, users cannot specify it, andSHOW CREATE SINKstrips it. A sink without it predates the recording.Behavior that depends on it goes through a named predicate on
SinkCreationVersion. The one predicate here selects the jsonb string encoding for Iceberg sinks. Any recorded version gets JSON text, since the recording ships with the fix. Sinks without one keep writing bare strings.No Iceberg table metadata is added or read. #41016 tried recording the encoding in the table, which ran into query engines that reject custom table properties and into snapshot expiry removing the marker.
Upgrade impact
None for existing sinks. They stay self-consistent and keep the old encoding. To get valid JSON for string scalars, drop the Iceberg table and recreate the sink.
Notes for the reviewer
CREATION VERSION = <release number>inmz_sinks.create_sql, the same wayVERSIONshows up after anALTER SINK.or CREATION.Tests
Unit tests for both encodings, a parser test for the new option, testdrive coverage in the Iceberg suite, and a platform check that creates sinks on the base version and deletes and updates rows after the upgrade.
Release note
This release will fix Iceberg sinks writing
jsonbstring values without their JSON quotes and escapes. The fix applies to newly created sinks. Existing sinks keep their current output.Closes: SS-611
🤖 Generated with Claude Code