feat(query): implement a few missing and useless options + fix query show#89
feat(query): implement a few missing and useless options + fix query show#89redox wants to merge 1 commit into
query show#89Conversation
… show` Extend `query` with lakehouse `QueryRequest` / output options aligned to the OpenAPI spec. ``` altertable query "select * from events LIMIT 10" --catalog whatever --schema main --format parquet > /tmp/events.parquet ``` **New `query` flags** - `--compute-size` (`XS|S|M|L|XL|AUTO`, default `AUTO`; omitted with `--session-id` unless an explicit size is set; reject `AUTO` + `--session-id`) - `--dialect`, `--catalog`, `--schema` (sent only when set) - `--format csv|jsonl|parquet|markdown` — `csv`/`jsonl`/`parquet` request API `format` and stream response bytes; `markdown` stays CLI-rendered from NDJSON - `--output <path>` — write result to a file (stdout by default) **Validation & output** - Reject API-native formats with `--json`/`--agent` or presentation flags (`--layout`, `--columns`, `--max-width`, `--pager`) - Add `executeLakehouseQueryBytes` and `writeQueryDestination` for binary-safe streaming - Add `OutputSink.writeBytes` so parquet/csv/jsonl redirects are not corrupted by `console.log` (UTF-8 decode + trailing newline) Also, fix `query show` so it always requires a query id and hits `GET /query/:query_id`. **`query show` / `query cancel`** - Remove `soleDirectOperands: ["show"]`, so bare `altertable query show` no longer runs SQL `SHOW` (which dumped ducklake metadata). - `query show <query-id>` → `GET /query/:query_id`; `query cancel <query-id> --session-id …` → `DELETE /query/:query_id` (unchanged).
albert20260301
left a comment
There was a problem hiding this comment.
Required
-
Please reconcile the request contract with the tracked Lakehouse spec before merge.
specs/lakehouse/SPEC.mdlists the optionalQueryRequestfields and does not definedialectorformat. Those fields underpin the new flags and raw-response behavior, while the PR body says they are OpenAPI-aligned. Update the spec (or link the spec change) to define the request/response contract, or narrow this PR to the documented fields. -
writeQueryDestinationcurrently consumes the wholeReadableStreamwithnew Response(stream).arrayBuffer()before writing it. That is binary-safe, but it is not streaming and can exhaust memory for the Parquet/large-result use case this PR introduces. Please pipe chunks to the file/stdout sink instead, with a multi-chunk regression test.
@albert20260301 good idea, go open a PR on https://github.com/altertable-ai/altertable-client-specs to reflect our updated https://api.altertable.ai/openapi/lakehouse.json |
|
@redox I opened altertable-ai/altertable-client-specs#39 from the current live Lakehouse OpenAPI contract, covering the The binary-output implementation still needs to write the response stream incrementally (with a multi-chunk regression test) before this CLI PR is ready for re-review. |
Extend
querywith lakehouseQueryRequest/ output options aligned to the OpenAPI spec, resulting in things like:New
queryflags--compute-size(XS|S|M|L|XL|AUTO, defaultAUTO; omitted with--session-idunless an explicit size is set; rejectAUTO+--session-id)--dialect,--catalog,--schema(sent only when set)--format csv|jsonl|parquet|markdown—csv/jsonl/parquetrequest APIformatand stream response bytes;markdownstays CLI-rendered from NDJSON--output <path>— write result to a file (stdout by default)Validation & output
--json/--agentor presentation flags (--layout,--columns,--max-width,--pager)executeLakehouseQueryBytesandwriteQueryDestinationfor binary-safe streamingOutputSink.writeBytesso parquet/csv/jsonl redirects are not corrupted byconsole.log(UTF-8 decode + trailing newline)Also, fix
query showso it always requires a query id and hitsGET /query/:query_id.query show/query cancelsoleDirectOperands: ["show"], so barealtertable query showno longer runs SQLSHOW(which dumped ducklake metadata).query show <query-id>→GET /query/:query_id;query cancel <query-id> --session-id …→DELETE /query/:query_id(unchanged).