Skip to content

Import a warehouse catalog when a data source is built - #282

Draft
jat255 wants to merge 1 commit into
jat255/xp65-catalog-securityfrom
jat255/xp65-source-wiring
Draft

Import a warehouse catalog when a data source is built#282
jat255 wants to merge 1 commit into
jat255/xp65-catalog-securityfrom
jat255/xp65-source-wiring

Conversation

@jat255

@jat255 jat255 commented Sep 4, 2026

Copy link
Copy Markdown
Collaborator

Sixth of the catalog import stack (kata xp65). Stacked on #281. Python only.

Everything the stack has landed so far is a library nothing calls. This wires it in: a Snowflake or Databricks engine now imports its catalog when the source is built. The session identity is read first, since every access answer that follows was decided for it; relations named in tables are access-checked before anything is described, so a name the caller got wrong fails at construction rather than mid-conversation; the listing is folded into the authored dictionary; and the session is read again at the end, because a role that moved during discovery invalidates what was just learned.

A selection defaults to the namespace the connection already points at. A namespace has to be named with a Selector, because ANALYTICS.PUBLIC on its own does not say whether PUBLIC is a schema or a table; a plain string is read as a relation, the way it is everywhere else. exclude is accepted only for a warehouse, since nothing else has a listing to drop from.

The merge re-keys the dictionary to the warehouse's labels, so a table's definitions are now looked up under the name the author gave it. Definitions over a column the warehouse spells differently are refused for now: the compiler cannot yet bind an authored name to the discovered one, and lowering them as written would emit SQL against columns that do not exist. The next PR in the stack replaces that refusal with real binding.

dictionary is taken by from_engine() and from_board() because the merge needs it during construction, but definitions are lowered once, in data_source(). Both docstrings say so.

Verification

725 Python tests, ruff and pyrefly clean. A fake backend stands in for the network; the fixture-pinned row interpretation and the real dispatch from data_source() through from_engine() are both exercised. The definitions lookup was confirmed to bite by reverting it and watching the end-to-end test fail.

@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
A Snowflake or Databricks engine now resolves its selection against the
warehouse rather than leaving the readers unused: the session identity is
read first, explicitly named relations are access-checked before anything
is described, the listing is folded into the authored dictionary, and the
session is read again at the end. A selection defaults to the namespace
the connection already points at, and exclude drops relations from it.

The merge re-keys the dictionary to the warehouse's labels, so a table's
definitions are now looked up under the name the author gave it rather
than the label it ended up with. Definitions over a column the warehouse
spells differently are refused for now, because the compiler cannot yet
bind an authored name to the discovered one.
@jat255
jat255 force-pushed the jat255/xp65-source-wiring branch from 63dfbf7 to 01c9608 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