fix: Iceberg lookup double-encodes user_meta (0.19.1)#400
Open
drernie wants to merge 3 commits into
Open
Conversation
…#399) json_format(CAST(m.metadata AS JSON)) wraps the already-JSON varchar as a JSON string value instead of parsing it, so every Iceberg-path row warned "Athena metadata JSON was not an object" and degraded result metadata to the {key: value} fallback. Select the column raw like the parquet _packages-view path, and decode a double-encoded string defensively in _parse_user_meta. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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.
Fixes #399.
The bucketless Iceberg lookup projected the metadata column as
json_format(CAST(m.metadata AS JSON)), butm.metadatais a VARCHAR that already contains a JSON document — and Trino's VARCHAR→JSON cast wraps the string as a JSON string value instead of parsing it. Every row returned by the Iceberg path therefore came back double-encoded:json.loadsyielded astr,_parse_user_metalogged "Athena metadata JSON was not an object", and the result's metadata silently degraded to the matched{key: value}fallback. Deterministic on every lookup, first observed during live verification of quiltdata/deployment#2502 ontf-dev-bucketless.Canvas rendering was unaffected (it only consumes bucket + package name), so this is log noise plus a latent trap for future metadata consumers — hence a patch release, not a re-pin of the 0.19.0 deployment.
Changes
_build_iceberg_union_query: projectm.metadata AS user_metaraw, matching the legacy_packages-viewpath (which selectsuser_metadirectly and never had this problem). TheWHERE json_extract_scalar(...)filter was always correct —json_extract_scalardoes parse VARCHAR — which is why matching worked while the projection double-encoded._parse_user_meta: if the first decode yields astr, defensively decode once more before warning, so any double-encoded values still round-trip to the full dict.json_format(CAST(...))form); new test covers double-encodeduser_metaround-tripping to the full metadata dict.Test plan
docker/: 468 Python tests pass, including the new double-encode round-trip test andtest_versions_match'["EXP-1"]') still passes — genuinely non-object metadata keeps the warning + fallback behavior🤖 Generated with Claude Code
Greptile Summary
This PR fixes Iceberg lookup metadata decoding for bucketless package searches. The main changes are:
m.metadataas rawuser_metainstead of wrapping it withjson_format.user_metaarrives double-encoded.0.19.1.0.19.1changelog entry.Confidence Score: 5/5
This looks safe to merge.
Important Files Changed
0.19.1metadata decoding fix.0.19.1.0.19.1.0.19.1.0.19.1.Reviews (1): Last reviewed commit: "docs: changelog for 0.19.1" | Re-trigger Greptile