Skip to content

feat(qwp): report the designated timestamp and omit BINARY values of query results - #135

Open
glasstiger wants to merge 2 commits into
mainfrom
ia_ui_qwp
Open

glasstiger wants to merge 2 commits into
mainfrom
ia_ui_qwp

Conversation

@glasstiger

@glasstiger glasstiger commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor

Adds a designated timestamp report and the omission of BINARY values to the Java QWP query client: the client side of questdb/questdb#8693.

New functionality

  • QwpQueryOptions.designatedTimestamp(true) asks the server which column of the result is its designated timestamp, as /exec reports it in timestamp.
  • QwpQueryDetails.getDesignatedTimestampIndex() returns that column's index in the result's schema, or QwpEgressMsgKind.NO_DESIGNATED_TIMESTAMP (-1) when the result has none. hasDesignatedTimestampIndex() tells whether the server reported it at all.
  • It reaches onEnd(requestId, totalRows, details) through QwpQueryClient.execute(...) and the pooled Query.options(...) alike. Statements and errors report none.
  • QwpQueryOptions.omitBinaryValues(true) asks the server to leave the bytes of BINARY values out, as /exec does, which sends every BINARY value as []. Each non-NULL BINARY value then reaches the handler empty, zero bytes long, and a NULL stays NULL; the server neither copies nor sends the bytes.

Compatibility and implementation

  • QUERY_FLAG_DESIGNATED_TIMESTAMP (0x80) asks for a designated_timestamp:i32 trailer at the end of RESULT_END, after the row count and the statistics block.
  • QUERY_FLAG_OMIT_BINARY_VALUES (0x100) adds no request field and no trailer. The BINARY column keeps its layout, so the batch decoder is unchanged: an omitted value decodes as an empty one, which getBinary() and getBinaryA() tell apart from NULL.
  • Like the other details, both options need CAP_QUERY_DETAILS: the client drops them for a server without the capability, including after a failover. Such a server sends the BINARY values in full.
  • Queries without the options remain byte-identical on the wire.
  • A trailer that cannot name a result column, outside -1 to 2047, fails the stream as a decode error, as a truncated trailer does.

The README example shows the new options.

Tandem PRs: questdb/questdb#8693, questdb/nodejs-questdb-client#83.

Add the designatedTimestamp option to QwpQueryOptions. A server that
advertises CAP_QUERY_DETAILS then ends RESULT_END with
designated_timestamp:i32, after the row count and the statistics
block: the index of the result column that is the designated
timestamp, or NO_DESIGNATED_TIMESTAMP (-1) when the result has none,
as the timestamp of the /exec HTTP endpoint reports it.
QwpQueryDetails passes it to onEnd() through
hasDesignatedTimestampIndex() and getDesignatedTimestampIndex().

- QUERY_FLAG_DESIGNATED_TIMESTAMP (0x80) asks for the trailer. Like the
  other reports, the client drops it for a server without
  CAP_QUERY_DETAILS, after a failover too.
- The decoder rejects a designated_timestamp that cannot name a result
  column, outside -1 to 2047, as a broken stream, the way it rejects a
  truncated trailer.
- Statements and errors carry no designated timestamp.
- The README example asks for it.

Server counterpart: questdb/questdb#8693.
@glasstiger glasstiger added enhancement New feature or request tandem QWP labels Dec 1, 2026
glasstiger added a commit to questdb/questdb that referenced this pull request Dec 1, 2026
Bump java-questdb-client to the commit that adds the
designatedTimestamp query option (questdb/java-questdb-client#135),
and check the designated timestamp through it, as changes to the QWP
wire format require.

- QwpEgressQueryDetailsClientTest compares the index the pinned client
  reports with /exec across table scans, projections, a TIMESTAMP_NS
  table, SAMPLE BY, an ASOF JOIN and an empty result, with and without
  a row window, and checks that it names a TIMESTAMP or TIMESTAMP_NS
  column of the schema the client decoded. It also covers the pooled
  Query facade, statements and errors, and that the client and server
  constants match.
- QwpEgressFuzzTest asks for the designated timestamp a third of the
  time, and checks it against /exec in both of its query paths.

The bump also brings in questdb/java-questdb-client#130, which adds
owned_by to the QWP sender.
Add the omitBinaryValues option to QwpQueryOptions. It sets the new
QUERY_FLAG_OMIT_BINARY_VALUES (0x100) bit of query_flags, which asks a
server that advertises CAP_QUERY_DETAILS to send each non-NULL BINARY
value empty, zero bytes long, and a NULL as NULL, in the usual layout
of the column. The /exec HTTP endpoint never sends BINARY content
either: it writes every BINARY value as []. The server neither copies
nor sends the bytes, so a client that does not read them no longer
waits for them.

- The flag adds no request field and no trailer, and the batch decoder
  needs no change: an omitted value decodes as an empty one, which
  getBinary() and getBinaryA() tell apart from NULL.
- Like the query details, the client drops the flag for a server
  without CAP_QUERY_DETAILS, after a failover too. Such a server sends
  the values in full.
- The README example asks for it.

Server counterpart: questdb/questdb#8693.
glasstiger added a commit to questdb/questdb that referenced this pull request Dec 1, 2026
Bump java-questdb-client to the commit that adds the omitBinaryValues
query option (questdb/java-questdb-client#135), and check the omission
of BINARY values through it, as changes to the QWP wire format require.

- QwpEgressQueryDetailsClientTest checks that each value the pinned
  client decodes is NULL where length() reads -1 and empty elsewhere,
  and as long as length() reads without the option. It covers the page
  frames of parquet and native partitions and of a column top, forwards
  and backwards; the RecordCursors of a filter, a sort, LIMIT, a CASE,
  a join, UNION ALL and a CTE; a row window; and the pooled Query
  facade. It also checks the NULLs of rnd_bin(), which length() does
  not see, that a row whose BINARY value overflows the send buffer
  streams with the option and fails the query without it, and that the
  client and server constants match.
- QwpEgressFuzzTest leaves the BINARY values out a third of the time,
  and its BINARY columns now hold NULLs too.
@mtopolnik

Copy link
Copy Markdown
Contributor

[PR Coverage check]

😍 pass : 38 / 38 (100.00%)

file detail

path covered line new line coverage
🔵 io/questdb/client/cutlass/qwp/client/QwpQueryDetails.java 12 12 100.00%
🔵 io/questdb/client/cutlass/qwp/client/QwpQueryOptions.java 14 14 100.00%
🔵 io/questdb/client/cutlass/qwp/client/QueryEvent.java 2 2 100.00%
🔵 io/questdb/client/cutlass/qwp/client/QwpEgressIoThread.java 10 10 100.00%

@glasstiger glasstiger changed the title feat(qwp): report the designated timestamp of query results feat(qwp): report the designated timestamp and omit BINARY values of query results Dec 1, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request QWP tandem

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants