Skip to content

CNS-138: console: distinct query history empty state when statement logging sampling is off - #38408

Draft
jubrad wants to merge 2 commits into
MaterializeInc:mainfrom
jubrad:justin/cns-138-console-distinct-empty-state-when-the-statement-logging
Draft

CNS-138: console: distinct query history empty state when statement logging sampling is off#38408
jubrad wants to merge 2 commits into
MaterializeInc:mainfrom
jubrad:justin/cns-138-console-distinct-empty-state-when-the-statement-logging

Conversation

@jubrad

@jubrad jubrad commented Aug 21, 2026

Copy link
Copy Markdown
Member

https://linear.app/materializeinc/issue/CNS-138/console-distinct-empty-state-when-the-statement-logging-sample-rate-is

Problem

Query history is backed by statement logging, which an operator can turn off by setting the sample rate to 0. When that happens the console showed the generic filter-oriented "No results found." empty state, so the user could not tell that sampling is off from their filters being too narrow.

Solution

  • New API module console/src/api/materialize/query-history/statementLoggingMaxSampleRate.ts reads SHOW statement_logging_max_sample_rate, following the existing maxReplicasPerCluster.ts pattern. The effective rate is min(session statement_logging_sample_rate, system statement_logging_max_sample_rate), so a zero cap is a hard opt-out and reading the cap alone is enough to detect it.
  • QueryHistoryList renders a distinct SamplingDisabledState when the result set is empty and the cap is 0. The copy names both ways to raise it: ALTER SYSTEM SET statement_logging_max_sample_rate, and the Materialize operator's Helm chart values for self-managed. The filter-oriented empty state is unchanged for a non-zero rate.

The new query is gated on enabled: isEmpty, so it never runs (and never delays) the path that renders rows.

Testing

console/src/api/materialize/query-history/statementLoggingMaxSampleRate.test.ts snapshots the compiled query. Two new cases in QueryHistoryList.test.tsx cover both empty-state branches. While adding them I found DEFAULT_FETCH_QUERY_LIST_HANDLER never matched anything: the schema defaults dateRange to a window ending at new Date(), so its separate queryHistoryListSchema.parse(...) produced different filters than the PARSED_DEFAULT_SCHEMA_VALUES the component is rendered with. The handler now reuses the same parsed value.

Notes for the reviewer

🤖 Generated with Claude Code

jubrad added 2 commits August 21, 2026 13:36
Query history is backed by statement logging, which an operator can turn
off by setting the sample rate to zero. Until now that produced the
generic filter-oriented "No results found." state, giving the user no way
to distinguish "sampling is off" from "my filters are too narrow".

Read `statement_logging_max_sample_rate` alongside the list query and, when
the result set is empty and the cap is zero, render a state that names both
ways to raise it. The effective rate is the min of the session rate and this
cap, so a zero cap is a hard opt-out.
Gate the sample rate read on an empty result set so it never sits in front
of a populated table, make the API module's null contract match its
behaviour, reword the remediation copy to cover both deployment modes, and
collapse the duplicate list handler in the tests.
@leedqin

leedqin commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

Also have a PR for this : #36533

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.

2 participants