Skip to content

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

Merged
jubrad merged 2 commits into
MaterializeInc:mainfrom
jubrad:justin/cns-138-console-distinct-empty-state-when-the-statement-logging
Aug 24, 2026
Merged

CNS-138: console: distinct query history empty state when statement logging sampling is off#38408
jubrad merged 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." state, so the user could not tell sampling was 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 the cap alone detects a hard opt-out.
  • QueryHistoryList renders a distinct SamplingDisabledState when the result set is empty and the cap is 0, naming 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 state is unchanged for a non-zero rate.

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

Testing

Snapshot test for the compiled query, plus two cases in QueryHistoryList.test.tsx covering 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 renders with. The handler now reuses the same parsed value.

Notes for the reviewer

🤖 Generated with Claude Code

@leedqin

leedqin commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

Also have a PR for this : #36533

@jubrad jubrad changed the title CNS-138: console: distinct query history empty state when statement logging sampling is off CNS-138: console: enable query history for self-managed, with a distinct empty state when sampling is off Aug 24, 2026
@jubrad
jubrad marked this pull request as ready for review August 24, 2026 19:10
@jubrad
jubrad requested a review from a team as a code owner August 24, 2026 19:10
@jubrad
jubrad requested a review from Alphadelta14 August 24, 2026 19:10

@leedqin leedqin left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

jubrad added 2 commits August 24, 2026 14:12
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.
@jubrad
jubrad force-pushed the justin/cns-138-console-distinct-empty-state-when-the-statement-logging branch from 90cceac to 8ab2944 Compare August 24, 2026 19:16
@jubrad jubrad changed the title CNS-138: console: enable query history for self-managed, with a distinct empty state when sampling is off CNS-138: console: distinct query history empty state when statement logging sampling is off Aug 24, 2026
@jubrad
jubrad enabled auto-merge (squash) August 24, 2026 19:22
@jubrad
jubrad merged commit 419a610 into MaterializeInc:main Aug 24, 2026
82 checks passed
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.

3 participants