Skip to content

Read a Snowflake catalog - #277

Merged
jat255 merged 3 commits into
jat255/xp65-catalog-mergefrom
jat255/xp65-snowflake-reader
Sep 6, 2026
Merged

Read a Snowflake catalog#277
jat255 merged 3 commits into
jat255/xp65-catalog-mergefrom
jat255/xp65-snowflake-reader

Conversation

@jat255

@jat255 jat255 commented Sep 4, 2026

Copy link
Copy Markdown
Collaborator

Third PR 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: 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.

Two behaviors 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 included in this PR. It is a feature rather than a part of catalog import Tracked locally as kata gcgj, which also flags the question of how it relates to commons' own semantic layer.

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
@jat255
jat255 force-pushed the jat255/xp65-snowflake-reader branch from 58b3ef1 to 66796a2 Compare September 5, 2026 04:58
@jat255
jat255 force-pushed the jat255/xp65-snowflake-reader branch from 66796a2 to 475783c Compare September 6, 2026 02:07
@jat255

jat255 commented Sep 6, 2026

Copy link
Copy Markdown
Collaborator Author

Manual review completed 2026-09-05 23:20 MDT by @jat255. Findings: 1 MEDIUM (untested current-namespace fallback in exact_relation) and 1 LOW (unpinned schema-only IN SCHEMA path) — both closed with tests in 1f35c73. 3 INFO, all documented divergences from catalog-snowflake.R, no action needed. Local checks green: ruff, pyrefly, 772 tests. Removing needs-manual-review.

@jat255 jat255 removed the needs-manual-review Agent-created work that needs a human review label Sep 6, 2026
@jat255
jat255 marked this pull request as ready for review September 6, 2026 05:23
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 1f35c73 to d543eb3 Compare September 6, 2026 06:29
@jat255
jat255 merged commit 56d84c8 into main Sep 6, 2026
16 checks passed
@jat255
jat255 deleted the jat255/xp65-snowflake-reader branch September 6, 2026 23:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

py Affects the Python implementation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant