Emit primary-key markers and join keys in OKF export#1
Merged
Conversation
The exporter already knew each mart's primary key (isPrimaryKey) and emitted "FK to [Target]" notes, but it never marked the PK column or put the join key on the relationship line. Downstream OKF consumers (e.g. the Model Canvas ERD) therefore rendered every relationship as a bare line with no join columns, making the model picture incomplete. - render_schema_section: prefix the PK column's description with "PK." (cell order: PK. -> description -> FK note). - _render_joins_section: emit "- [Target](./t.md) — `left = right`" when the key is derivable (this mart's column == the target mart's PK of the same name); OWOX's blend config carries no explicit join columns, so a link with no matching column stays bare. - add --folder and --title to override the bundle subfolder name and display title (default to the slugified / raw project title as before). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…commerce Regenerate the example bundle with the exporter fix so it renders join keys on the canvas. Scope it to a single storage (BigQuery [Common]) so it is a coherent e-commerce model, and rename the folder/title to E-Commerce to leave room for future example models. - 24 marts from one storage instead of a 27-mart mix across storages; drops 3 marts that actually lived in other storages. - every mart now declares its PK; relationships carry join keys. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Obolrus
force-pushed
the
fix/okf-export-emit-join-keys
branch
from
July 19, 2026 03:56
e37dbfe to
0611a57
Compare
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.
Why
The OKF exporter emits relationships without concrete join keys and never marks a mart's primary key, even though it already reads
isPrimaryKeyfrom the OWOX schema and emitsFK to [Target]notes. As a result any OKF consumer that renders the model — e.g. the Model Canvas ERD — draws every relationship as a bare line with no join columns. The picture of the model is incomplete: you can see that two marts are related, but not on what.Measured on the current example bundle, parsed by the Model Canvas OKF parser:
What this PR changes
1. Exporter (
tools/odm-to-okf-export/export.py)render_schema_sectionnow prefixes the PK column's description withPK.(cell order:PK.→ description →FK to […], matching what the canvas serializer produces). The data was already available viaisPrimaryKey; it just wasn't written out.## Joins._render_joins_sectionnow emits- [Target](./target.md) —left = right`` when the key is derivable — i.e. this mart has a column named the same as the target mart's primary key. OWOX'sblendedFieldsConfigcarries no explicit join columns, so a link with no matching column is left bare (unchanged behaviour for those).--folderflag. Optional override for the bundle subfolder name (defaults to the slugified project title, as before).No cardinality is emitted — OWOX Data Marts has no such concept, and the canvas treats its absence gracefully.
2. Example bundle (
bundles/…)Regenerated with the fix so it renders join keys on the canvas, and cleaned up:
demo-project→e-commerce, so adding further example models later doesn't leave a genericdemo-projectsitting next to them.After the fix, the same parser reports:
Keyed relationships now include e.g.
orders → sessions: session_id = session_id,orders → customers: customer_id = customer_id,purchases → products: product_id = product_id,sessions → visitors: visitor_id = visitor_id.How to verify
Import
https://model.owox.com/?okf=https://github.com/OWOX/models/tree/<this-branch>/bundles/e-commerceand confirm the ERD shows join-key fields on the related marts instead of bare lines.