Skip to content

feat: Add click-to-adhoc-filter to table charts - #3389

Draft
pulpdrew wants to merge 1 commit into
drew/adhoc-filters-click-searchfrom
drew/adhoc-filters-click-table
Draft

pulpdrew wants to merge 1 commit into
drew/adhoc-filters-click-searchfrom
drew/adhoc-filters-click-table

Conversation

@pulpdrew

@pulpdrew pulpdrew commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

Summary

This PR adds click-to-adhoc-filter functionality to tables, across builder, raw SQL, and PromQL tables.

Most of the complexity comes from determining (a) which columns should be filterable and (b) what expression to filter on when a column / cell is clicked. In general, (a) group-by columns should be filterable while aggregate columns should not be (since other visualizations are unlikely to have the same aggregations) and (b) we try to filter on the underlying expression instead of the alias, since other visualizations may not have the same alias.

This determination is made as follows:

  • Builder tables: The group-by columns are the result columns that come right after the value columns (see renderSelect). They're matched by position, not by name, because ClickHouse canonicalizes unaliased expressions.
  • Raw SQL tables: The query is rendered (macros and variables replaced) and parsed with node-sql-parser (chSqlToSelectColumns in common-utils). Each outer SELECT item lines up with a result column by position. An item is filterable if the GROUP BY lists it by alias, by name, by normalized expression, or by position (GROUP BY 2). If the query can't be read that way (no GROUP BY, GROUP BY ALL, SELECT *, a parse failure, or a column count that doesn't match the result), we fall back to type-based determination (any String type column is filterable).
  • PromQL tables: Every non-numeric column other than the time column is a label and filters on its label name.

For all table types, DateTime columns aren't filterable, because cells hold ISO UTC timestamps that never equal toString() of the column. Map and Array cells aren't filterable either, because they render as JSON that wouldn't match the value in a filter condition.

Screenshots or video

How to test on Vercel preview

References

  • Linear Issue: Closes HDX-5653
  • Related PRs:

@vercel

vercel Bot commented Oct 16, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
hyperdx-oss Ready Ready Preview Oct 16, 2026 6:45pm UTC
hyperdx-storybook Ready Ready Preview Oct 16, 2026 6:45pm UTC

Request Review

@changeset-bot

changeset-bot Bot commented Oct 16, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 2aa0cdf

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 4 packages
Name Type
@hyperdx/common-utils Patch
@hyperdx/app Patch
@hyperdx/api Patch
@hyperdx/otel-collector Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@greptile-apps

greptile-apps Bot commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 4/5

[Medium impact] Adds click-to-filter actions to table chart cells.

The aggregate-filter fallback still needs fixing before this PR is safe to merge.

Fix All in Claude CodeFindings

  1. P1 Aggregate clicks break queries ▶

Summary

Adds include and exclude actions to table cells on dashboards.

  • Table results map eligible columns to the expressions their filters use.
  • Table cells offer include and exclude actions for eligible values.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart LR
  A[Table query and result columns] --> B[Choose filter keys]
  B --> C[Cell include or exclude action]
  C --> D[Update matching dashboard filters]
  D --> E[Refresh affected tiles]
Loading

Reviews (5) · Last reviewed commit: "feat: Add click-to-adhoc-filter to table..." · Reviewed by Greptile

Comment on lines +105 to +107
const aliasMap = chSqlToAliasMap(chSql);
for (const { name } of inferGroupColumns(meta) ?? []) {
keys.set(name, aliasMap[name] ?? quoteResultColumnNameIfNeeded(name));

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.

P1 Aggregate clicks break queries

getRawSqlFilterKeys treats every string column as filterable when chSqlToSelectColumns returns nothing. For SELECT any(Body) AS body, count() FROM logs WHERE $__filters, clicking body stores any(Body) as the filter key. This inserts toString(any(Body)) = '…' into WHERE, where aggregate functions are forbidden, and the tile fails. The same problem affects GROUP BY ALL.

Keep aggregate columns out of the fallback, or omit actions when their source expression cannot be checked.

Fix in Claude Code Fix in Conductor Fix in Cursor Fix in Codex

Comment thread packages/app/src/hooks/useResultColumnFilterKeys.ts
Comment thread packages/app/src/HDXMultiSeriesTableChart.tsx
@github-actions

Copy link
Copy Markdown
Contributor

Duplicate code analysis

No new duplicate code introduced by this PR.


jscpd compared this branch against origin/main
across app, api and common-utils. Only new clones are listed; the codebase
currently holds 125 in total (1.69%).
Run yarn dupes locally to reproduce, or yarn dupes:all for the full picture.

@github-actions

github-actions Bot commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

E2E Test Results

✅ All tests passed • 439 passed • 1 skipped • 1484s

Status Count
✅ Passed 439
❌ Failed 0
⚠️ Flaky 1
⏭️ Skipped 1

Tests ran across 4 shards in parallel.

View full report →

Comment thread packages/common-utils/src/clickhouse/index.ts Outdated
Comment thread packages/app/src/hooks/useResultColumnFilterKeys.ts Outdated

This branch was successfully deployed

2 active deployments
Preview – hyperdx-storybook — 2aa0cdfc Deployed Oct 16, 2026 by vercel[bot]
Preview – hyperdx-oss — 2aa0cdfc Deployed Oct 16, 2026 by vercel[bot]
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.

1 participant