Skip to content

bug(sdk): default ORDER BY / pagination column hardcoded to received_timestamp 500s on BYOS tables #270

Description

@EricAndrechek

Area: sdk · query — footgun (DX); breaks the zero-config query path on BYOS tables · found via WaveHouse-Stats dogfooding (reproduced live on 71c2dc4)

Expected: wh.from(table).fetch() / .select(…) without an explicit .orderBy() works on any discovered table.

Actual: the SDK query builder injects ORDER BY received_timestamp DESC by default (also the pagination cursor: orderCol = this._state.orderBy[0]?.column ?? "received_timestamp"). On a table without that column it emits invalid SQL → ClickHouse code 47, Unknown expression identifier received_timestamp → HTTP 500. received_timestamp is the WaveHouse-Demo clicks column; for a bring-your-own-schema gateway it shouldn't be a hardcoded default.

Impact (Stats): gh_events uses event_ts (DateTime64), so every default-ordered query 500s naming a column they never referenced — looks like a setup bug. Workaround: always pass .orderBy('event_ts','desc').

Scope (DX): derive the default order/cursor from the table schema (e.g. its ORDER BY key), or make it per-client/per-table configurable; at minimum omit the default ORDER BY when that column isn't present.

Related: SDK epic #194; query-builder restructure #199; the 500-vs-4xx error-semantics issue (filed alongside) masks this as a server error.


From WaveHouse-Stats WAVEHOUSE-FEEDBACK.md dogfooding; reproduced live on dev 71c2dc4, 2026-06-04.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/queryStructured query AST, SQL builderarea/sdkTypeScript SDK (clients/ts/)bugSomething isn't working

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions