Skip to content

fix(snowflake): read relation statistics with SHOW OBJECTS - #1417

Merged
kvlonge merged 2 commits into
mainfrom
fix/snowflake-statistics-show
Nov 11, 2026
Merged

kvlonge merged 2 commits into
mainfrom
fix/snowflake-statistics-show

Conversation

@kvlonge

@kvlonge kvlonge commented Nov 11, 2026

Copy link
Copy Markdown
Contributor

Why

Snowflake metadata row counts ran one information_schema.tables query per relation, and each one needs a running warehouse. A code location sampling statistics therefore kept the warehouse busy for about a second per relation. SHOW OBJECTS returns the same rows and bytes from metadata alone, so no warehouse has to run.

Changes

  • estimate_relation_row_count on Snowflake reads SHOW OBJECTS LIKE '<name>' IN SCHEMA <database>.<schema> and matches the stored name exactly. Kind TABLE reports rows and bytes, with basis show_objects_bytes. Views report no count, as before.
  • Two cases keep the bound-parameter information-schema query, matching the adapter's other SHOW lookups: a relation without a schema, and a name containing a backslash.
  • The unit tests cover tables, views, a neighbour matched by the LIKE wildcard, the backslash name and the schema-less read.

DuckShop edge case: not applicable. This changes how one adapter reads metadata, not a project shape, data value or lifecycle.

Verification

  • pytest tests/unit/src/sqlbuild/adapters/test_relation_row_count_estimate.py tests/unit/src/sqlbuild/adapters/snowflake: passes. The statistics publication integration tests pass.
  • Live Snowflake check, X-Small warehouse, 63 relations: SHOW OBJECTS matched information_schema.tables exactly for every relation (28 tables with rows and bytes, 35 views with no count).
  • A code location sync with all 63 statistics due completed in 44 s. It ran no per-table warehouse queries: 63 SHOW calls at about 0.1 s each, where each per-table query used to take about 1 s.
  • make check-ci: passes.

Metadata row counts ran one information_schema.tables query per relation,
which needs a running warehouse: a code location sampling statistics kept
the warehouse busy for about a second per relation. SHOW OBJECTS returns the
same rows and bytes from metadata alone. Views and other non-table objects
still report no row count; a relation without a schema keeps the information
schema read.
@kvlonge
kvlonge enabled auto-merge (squash) November 11, 2026 12:34
@kvlonge kvlonge added the full-verify Run the full Verify matrix on this pull request label Nov 11, 2026 — with Amp for GitHub
@kvlonge
kvlonge merged commit 1428b5e into main Nov 11, 2026
30 checks passed
@kvlonge
kvlonge deleted the fix/snowflake-statistics-show branch November 11, 2026 15:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

full-verify Run the full Verify matrix on this pull request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant