Skip to content

Merge a warehouse catalog into an authored dictionary - #275

Draft
jat255 wants to merge 2 commits into
jat255/xp65-catalog-corefrom
jat255/xp65-catalog-merge
Draft

Merge a warehouse catalog into an authored dictionary#275
jat255 wants to merge 2 commits into
jat255/xp65-catalog-corefrom
jat255/xp65-catalog-merge

Conversation

@jat255

@jat255 jat255 commented Sep 4, 2026

Copy link
Copy Markdown
Collaborator

Second of the catalog import stack (kata xp65). Stacked on #274. Ports catalog.R: selection into labelled relations, exclusion globs and the object cap, the manifest that decides whether a listing belongs in the prompt or behind search, catalog search, and the dictionary merge.

The rules the R side settled and this keeps: authored prose wins, warehouse types and nullability are authoritative, identifier case normalizes per backend, and an ambiguous relative name is an error rather than a guess. Discovered columns come first in the order the warehouse reported them; authored columns with no counterpart follow.

Everything here is a pure function over the rows a listing returns, so none of it needs a warehouse. Running the queries that produce those rows is the next two PRs, which is the split that makes this testable at all.

Departures from R, both because the Python types differ

A selection entry is a Selector rather than a TableId, because a selection may stop at a catalog or a schema and a TableId always names a table. That also lets id_type() be one dialect-independent function instead of an injected per-backend one.

The authored table alias is a declared authored_name field on Table rather than an attribute set on the fly, since the model is pydantic.

Two defects found in review, both worth knowing

An entry naming a table the warehouse did not return was dropped, including from the validation list, so asking for a table that is not there became a quietly smaller selection rather than an error. R keeps an undiscovered stub and validates it.

authored_name was added and then never read. Relationship prose says what the author wrote, and the merge re-keys the table to its warehouse label, so a relationship on orders stopped reaching the entry for ANALYTICS.PUBLIC.ORDERS. Rendering now matches either name. Worth a reviewer's eye, because it is the seam where the authored and warehouse namespaces meet and there are likely other places that only know one of the two names.

Verification: 630 tests, ruff and pyrefly clean. The merge rules were confirmed to bite by letting an authored type win over the warehouse and by leaving glob metacharacters unescaped.

@jat255
jat255 marked this pull request as draft September 4, 2026 05:49
@jat255 jat255 mentioned this pull request Sep 4, 2026
@jat255 jat255 added this to the py-M2: data layer milestone Sep 4, 2026
@jat255 jat255 added needs-manual-review Agent-created work that needs a human review py Affects the Python implementation labels Sep 4, 2026
Second of the catalog import stack (kata xp65). Ports catalog.R: selection
into labelled relations, the exclusion globs and object cap, the manifest
that decides whether a listing is small enough to put in a prompt, catalog
search, and the dictionary merge.

The rules the R side settled and this keeps: authored prose wins, warehouse
types and nullability are authoritative, identifier case normalizes per
backend, and an ambiguous relative name is an error rather than a guess.
Discovered columns come first in the order the warehouse reported them, and
authored columns with no counterpart follow.

Every function here is pure over the rows a listing returns, so none of it
needs a warehouse. Running the queries that produce those rows belongs to
the per-backend readers, which is the next two PRs.

Two departures from R, both because Python's types differ. A selection entry
is a Selector rather than a TableId, because a selection may stop at a
catalog or a schema and a TableId always names a table; that also lets
id_type() be one dialect-independent function rather than an injected
backend one. And the authored table alias is a declared `authored_name`
field on Table rather than an attribute set on the fly, since the model is
pydantic.

The merge rules were confirmed to bite by letting an authored type win over
the warehouse and by leaving glob metacharacters unescaped.
…y both names

Two defects in the catalog core.

An entry naming a table whose relation the warehouse did not return was
dropped, including from the validation list, so asking for a table that is
not there became a quietly smaller selection instead of an error the backend
reports. R keeps an undiscovered stub and validates it; that is restored,
and an excluded entry is still dropped from both.

The authored_name field added in the previous commit was never read.
Relationship prose says what the author wrote, and the merge re-keys a table
to its warehouse label, so a relationship on `orders` stopped reaching the
first-touch entry of ANALYTICS.PUBLIC.ORDERS. Rendering now matches either
name.

Found by roborev job 331.
@jat255
jat255 force-pushed the jat255/xp65-catalog-merge branch from 0fa5884 to 730db47 Compare September 5, 2026 04:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-manual-review Agent-created work that needs a human review py Affects the Python implementation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant