feat(web): repartition BigQuery tables from the table detail UI#470
feat(web): repartition BigQuery tables from the table detail UI#470yustme wants to merge 3 commits into
Conversation
Add a Repartition tab to the serve --ui table detail for BigQuery tables.
The user picks a time or integer-range partitioning layout plus optional
clustering fields; the UI runs the supported repartition flow:
create-table --source-table-id (copy rows into new layout) then swap-tables
(atomic flip into place), and finally offers to delete the leftover old
table. Runs in the branch selected in the top bar; with no dev branch it
repartitions production behind an explicit confirm.
Server: POST /storage/tables/{project} now forwards the source-copy +
BigQuery partition/clustering fields and makes columns optional, matching
the CLI. Table detail responses expose the owning bucket's backend so the
UI can gate the BigQuery-only tab.
Bump to 0.67.0 with changelog.
Code ReviewCelkově solidní PR — architektura (create → swap → optional delete) je čistá, testy pokrývají nové router kwargs i service-level 1. Partial failure: create OK → swap FAIL → retry nefunguje (important)
Uživatel zůstane zaseknutý bez jasné cesty ven (musel by ručně smazat Návrhy řešení (pick one):
// Storage.tsx, line ~362
const createBody: Record<string, unknown> = {
// ...
if_not_exists: true, // safe retry after partial failure
};2.
|
- Idempotent copy + partial-failure recovery: create-table now uses if_not_exists, so retrying after a failed swap re-runs just the swap instead of erroring; a failed swap surfaces a 'delete leftover copy' cleanup action. - CreateTable request model enforces the columns/source XOR via a model_validator -> clean 422 instead of a 500 from the service. - Cap clustering at BigQuery's max of 4 fields in the picker. - Disable partitioning/clustering form controls while the create+swap mutation is in flight. - Restore uv.lock revision 3 (sync_version downgraded it under old uv).
Lets the user repartition to no partitioning at all (de-partition a table), with clustering still optional. 'None' mode sends no time/range partitioning fields and is always valid on its own.
What
Adds a Repartition tab to the
kbagent serve --uitable detail for BigQuery tables — the UI counterpart to the CLI repartition flow shipped in #468. The user picks a partition/clustering layout and the UI runs the supported repartition path end to end.How it works
The Repartition tab only appears for BigQuery, non-alias tables (gated on the bucket backend). On submit it runs the same two-step flow as the CLI:
create-table --source-table-id— copies the table into a sibling<name>_repartitionwith the chosen layout (rows copied).swap-tables— atomically flips the new-layout copy into the original's place.After the swap the old data/layout lives under the sibling id; the UI then asks whether to delete it (per the chosen behavior — keep as a backup or delete).
Branch behavior: runs in the branch selected in the top bar. With no dev branch selected it resolves the project's default (production) branch and runs there behind an explicit confirm — a dev-branch swap never merges back, so production is the only branch that actually repartitions the live table.
Changes
web/frontend/src/pages/Storage.tsx): newRepartitionTab(time vs integer-range partitioning + clustering field picker), BigQuery gating, branch resolution + production confirm, create→swap orchestration with progress, post-swap delete prompt.server/routers/storage.py):POST /storage/tables/{project}now forwardssource_table_id/source_branch_id,time_partitioning_*,range_partitioning_*,clustering_fields;columnsis now optional (source mode). Mirrors the CLI.services/storage_service.py): table-detail response now includes the owning bucket'sbackendso the UI can gate BigQuery-only features.Tests
create_table+columnsoptional (no 422 on source-only body).backendsurfaced from the bucket (+ empty-string fallback).make changelog-checkgreen; ruff/format/ty clean; frontendtsc -b && vite buildclean; existing storage/server suites pass.Not covered here
Full BigQuery E2E of the actual repartition action needs a live BigQuery project; verified at the unit/integration + build level. The bundled
_ui_distis generated at wheel-build time (gitignored), so only frontend source is committed.