Skip to content

feat(warehouse-saved-query): manage warehouse saved queries as code - #99

Open
pl wants to merge 3 commits into
pl/spec-migrationfrom
pl/resource-warehouse-saved-queries
Open

feat(warehouse-saved-query): manage warehouse saved queries as code#99
pl wants to merge 3 commits into
pl/spec-migrationfrom
pl/resource-warehouse-saved-queries

Conversation

@pl

@pl pl commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

Adds warehouse saved queries (projects/{id}/warehouse_saved_queries) as a managed resource — the first Wave 3 (data-warehouse) resource.

Design

  • Identity: natural key name (the unique HogQL table name) + identity/hash marker in description (round-trips unbounded, PATCH-rewritable). tags dropped by the serializer (live-verified). Model = name/query/description/folderId.
  • Novel piece — optimistic-concurrency read-then-write: the server guards query writes with an edit token (query PATCH without it → 400 "The query was modified by someone else"). The update executor refetches the row (also re-asserting the identity marker) and echoes the current latest_history_id as edited_history_id. Description-only writes (pull tag-back) skip the token.
  • Materialization out of scope: sync_frequency is DAG-managed (direct PATCH → 400 "Schedule is managed by the DAG"), and run/cancel/materialize are imperative — none are in the model.
  • Pull: the list endpoint returns a minimal serializer without query, so hydrateForPull refetches the full row before rendering.
  • Real DELETE (204).

Verification (dev project 806)

create → no-op re-apply → edit description → single update (exercises the edited_history_id token path) → no-op → edit query → single update → no-op → orphan left untouched → hand-built row (no marker) invisible to plan/orphans (safety invariant) → scoped prune via direct pruneWarehouseSavedQuery. Pull verified in isolation (seed → pull --all-rows → hydrate + tag-back → dry-run "Nothing to do"). All rows cleaned up. Gates: typecheck / typecheck:examples / lint / test (302) all pass.

Stacking

Stacks on #81 (pl/spec-migration, codegen-only base). Retarget to master when #81 merges. First commit is the codegen regen (skippable in review). docs/resources.md row flipped; #78 carries the full matrix refresh.

🤖 Generated with Claude Code

pl and others added 3 commits July 24, 2026 09:48
Add warehouse_saved_queries list/create/retrieve/partial_update/destroy to the
openapi-filter allowlist and regenerate src/generated/api.d.ts. PUT (update) is
omitted — the client uses PATCH; materialize/run/cancel stay imperative and are
out of scope for the resource.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Manage warehouse saved queries (projects/{id}/warehouse_saved_queries) as code.
Natural key is `name` (the HogQL table name, unique); identity + hash ride a
trailing HTML-comment marker in `description` (round-trips, PATCH-rewritable).
Model = name/query/description/folder_id.

Novel piece — optimistic-concurrency read-then-write: the server guards `query`
writes with an edit token, so an update refetches the row (also re-asserting the
identity marker) and echoes the current `latest_history_id` as
`edited_history_id`, or the PATCH 400s as a conflicting edit. Description-only
writes (tag-back) skip the token. Materialization (`sync_frequency`,
run/cancel/materialize) is DAG-managed and left out of scope (direct
`sync_frequency` PATCH 400s). Real DELETE (204). The list endpoint returns a
minimal serializer without `query`, so pull hydrates the full row before render.

Includes pull codegen (+ hydrateForPull), unit tests, two examples, README
scope (warehouse_view:read/write), resources.md row.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Seed one saved query per smoke run (underscore-safe key/name since the name is
the HogQL table name), add warehouse-saved-queries to SMOKE_KINDS, and wire
--warehouse-saved-query=<key> into smoke-cleanup.ts. Verified in isolation:
seed -> apply -> pull --all-rows (hydrate + tag-back) -> dry-run no-op ->
cleanup. (Full `pnpm smoke` remains blocked upstream by the pre-existing
actions-pull gap on pl/spec-migration.)

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
pl added a commit that referenced this pull request Jul 24, 2026
Logs sampling rules (#97), warehouse saved queries (#99), and batch
exports (#100) complete the buildable surface. Logs alerts/metric rules,
warehouse tables/view links deferred; group types excluded; notebooks
parked. Adds a status section with the post-merge follow-up list.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant