fix(imports): preserve link_hub_source_mapping for self-referencing links on JSON round trip - #176
Open
tkirschke wants to merge 3 commits into
Open
fix(imports): preserve link_hub_source_mapping for self-referencing links on JSON round trip#176tkirschke wants to merge 3 commits into
tkirschke wants to merge 3 commits into
Conversation
…ound trip link_source_mapping already survived after the previous commit, but link_hub_source_mapping was still lossy for links that reference the same hub more than once (e.g. customer_duplicate_customer_l): LinkColumnMapping had no per-reference discriminator, so both business-key mappings serialized with the same link_column_name and the importer collapsed them onto the first reference with the wrong source column. Add an optional target_foreign_hashkey to LinkColumnMapping (the hub hashkey alias, else hub hashkey name — uniquely identifies a hub reference), populate it in the export builder for business-key mappings, and have the JSON parser resolve the hub reference by it. Falls back to the previous name-matching when the field is absent, so legacy exports still import. Verified on the full TPCH model: both link_hub_source_mapping (14) and link_source_mapping (14) now round-trip DB -> export -> import with zero diff. Adds a whole-model round-trip regression test and a legacy-export fallback test. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…inks on JSON round trip Adds target_foreign_hashkey to LinkColumnMapping so the JSON export/import can disambiguate hub references when a link points at the same hub more than once, keeping link_hub_source_mapping (and link_source_mapping) intact across a DB -> export -> import round trip. Co-Authored-By: Claude Opus 4.8 (1M context) <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.
Context
Follow-up to #174. That PR made
link_source_mappingsurvive JSON import (dependent-child-key / payload columns were being dropped). This PR closes the remaining gap on the other link mapping table,link_hub_source_mapping.Problem
For a link that references the same hub more than once (e.g.
customer_duplicate_customer_l, which points atCUSTOMER_Htwice with aliasesHK_CUSTOMER_HandHK_CUSTOMER_DUPLICATE_H), the JSON export could not say which source column feeds which reference.LinkColumnMappingcarried only(link_column_name, link_column_type, source_column_name)— both business-key mappings serialized with the identicallink_column_name, so the importer collapsed them onto the first reference with the wrong source column.Verified against the bundled TPCH model:
link_hub_source_mappinground-tripped 14 → 13 with one wrong row.Fix
Add an optional
target_foreign_hashkeytoLinkColumnMapping— the hub hashkey alias (else hub hashkey name), which uniquely identifies a hub reference:None).hub_ref.hub_hashkey_alias_in_link or hub.hub_hashkey_name.target_foreign_hashkey; fall back to the previous column-name match when the field is absent, so legacy exports still import.Verification
link_hub_source_mapping(14 → 14) andlink_source_mapping(14 → 14) now come back with zero diff, including the same-hub-twice link, composite business keys, and a renamed foreign hashkey.target_foreign_hashkey).ruffclean.🤖 Generated with Claude Code