Skip to content

Read a Snowflake catalog - #277

Draft
jat255 wants to merge 2 commits into
jat255/xp65-catalog-mergefrom
jat255/xp65-snowflake-reader
Draft

Read a Snowflake catalog#277
jat255 wants to merge 2 commits into
jat255/xp65-catalog-mergefrom
jat255/xp65-snowflake-reader

Conversation

@jat255

@jat255 jat255 commented Sep 4, 2026

Copy link
Copy Markdown
Collaborator

Third of the catalog import stack (kata xp65). Stacked on #275. Ports the catalog-import half of catalog-snowflake.R: the current namespace, SHOW OBJECTS listing and exact lookup, DESC TABLE column description, and the identifier quoting each needs.

The queries are kept apart from the interpretation of their rows, following the R structure. That is what makes this testable without a warehouse: the row readers are pure and run against real SHOW OBJECTS and DESC TABLE shapes, and the query builders are checked by recording the SQL they send. That recorder is the one test double here, and it stands in for a network rather than for Snowflake's semantics.

Two behaviours worth naming. SHOW caps its output and a full page cannot be told apart from a page that happened to fill, so a full page is refused rather than silently truncated. And SHOW OBJECTS LIKE ignores case, so its reply is filtered by exact name: asking for ORDERS and getting back orders means a differently-cased table exists, not the one that was named.

Deliberately out of scope: semantic views

About half of catalog-snowflake.R is Snowflake semantic views, and none of it is here. It is a feature rather than a part of catalog import, and pkg-py has no surface for it: grep -rl semantic_model pkg-py/src returns nothing, while R threads semantic models through ten files including commons.R, context-layer.R and pool.R. A reader alone would produce records nothing consumes. Tracked as kata gcgj, which also flags the question of how it relates to commons' own semantic layer.

One deliberate divergence from R

exact_relation() checks for a capped reply; R checks only when listing a namespace. Without it a capped reply reports an existing table as absent, which is a wrong answer rather than a loud one. The case needs a schema holding a page-full of case-variant names, so it is vanishingly rare, and the reasoning is recorded next to the check.

Verification

653 tests, ruff and pyrefly clean. Worth knowing: the exact-name filter was originally uncovered. Perturbing it failed nothing, because the only test reaching that path supplied an empty reply. A near-match case covers it now, and that is why the perturbation pass is worth doing rather than trusting a green suite.

@jat255
jat255 marked this pull request as draft September 4, 2026 05:56
@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
Third of the catalog import stack (kata xp65). Ports the catalog-import half
of catalog-snowflake.R: the current namespace, SHOW OBJECTS listing and
exact lookup, DESC TABLE column description, and the identifier quoting each
needs.

The queries are kept apart from the interpretation of their rows, following
the R structure, which is what makes this testable without a warehouse: the
row readers are pure and run against real SHOW OBJECTS and DESC TABLE
shapes. The query builders are checked by recording the SQL they send, which
is the one test double here and stands in for a network rather than for
Snowflake's semantics.

SHOW caps its output and a full page cannot be told apart from a page that
happened to fill, so a full page is refused rather than silently truncated.
SHOW OBJECTS LIKE ignores case, so its reply is filtered by exact name:
asking for ORDERS and getting `orders` means a differently-cased table
exists, not the one that was named.

The semantic-view half of the R file is not ported and is now kata gcgj.
It is a feature rather than part of catalog import, and pkg-py has no
surface for it at all: R threads semantic models through ten files
including commons.R, context-layer.R and pool.R, so a reader alone would
produce records nothing consumes.

The name filter was found to be uncovered by perturbing it and watching
nothing fail; the empty-reply test could not reach it. A near-match case
covers it now.
SHOW OBJECTS LIKE is capped like any other SHOW, and a full page may have
dropped the match, which reported an existing table as absent.

A deliberate divergence from R, which checks only when listing a namespace.
The case needs a schema holding a page-full of case-variant names so it is
vanishingly rare, but when it happens Python now fails loudly instead of
answering wrongly, and the reason is recorded next to the check and in the
test.

Found by roborev job 333.
@jat255
jat255 force-pushed the jat255/xp65-snowflake-reader branch from 58b3ef1 to 66796a2 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