Skip to content

feat: Add group-by to the search page histogram - #3407

Merged
kodiakhq[bot] merged 2 commits into
mainfrom
drew/search-histogram-group-by
Oct 21, 2026
Merged

kodiakhq[bot] merged 2 commits into
mainfrom
drew/search-histogram-group-by

Conversation

@pulpdrew

@pulpdrew pulpdrew commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

Summary

This PR adds a custom group-by input to the search page histogram.

  • The user can specify the group by using a multi-select listing the available keys (shared with the filter side panel) or write SQL directly, following @elizabetdev's group by input design
  • When switching sources, custom group-bys are preserved when compatible with the new source, based on the existing logic for preserving compatible filters when switching sources.

Screenshots or video

Screen.Recording.2026-10-19.at.6.21.33.PM.mov

How to test on Vercel preview

Visit the search page and try it out!

References

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

@vercel

vercel Bot commented Oct 19, 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 21, 2026 10:07am UTC
hyperdx-storybook Ready Ready Preview Oct 21, 2026 10:07am UTC

Request Review

@changeset-bot

changeset-bot Bot commented Oct 19, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 0e48d28

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

This PR includes changesets to release 3 packages
Name Type
@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

@github-actions

github-actions Bot commented Oct 19, 2026 •

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 123 in total (1.62%).
Run yarn dupes locally to reproduce, or yarn dupes:all for the full picture.

@greptile-apps

greptile-apps Bot commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; no new actionable issues were established.

Summary

Adds a histogram group-by picker with Fields and SQL tabs, URL state, and source-switch compatibility checks.

  • The search page lets people choose histogram grouping by fields or SQL.
  • Compatible group-by fields stay selected when the source changes.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart LR
  A[Fields or SQL selection] --> B[groupBy URL value]
  B --> C[Histogram query]
  S[Source default] --> D[Result total query]
  B --> E{Source changes}
  E --> F[Keep compatible fields]
  F --> B
Loading

Reviews (6) · Last reviewed commit: "fix: Filter out non-string group by fiel..." · Reviewed by Greptile

Comment thread packages/app/src/DBSearchPage.tsx Resolved
@github-actions

github-actions Bot commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

E2E Test Results

✅ All tests passed • 456 passed • 1 skipped • 1262s

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

Tests ran across 4 shards in parallel.

View full report →

@pulpdrew
pulpdrew force-pushed the drew/search-histogram-group-by branch from f882d26 to eac5098 Compare October 19, 2026 22:25
@pulpdrew
pulpdrew marked this pull request as ready for review October 19, 2026 22:25
@github-actions github-actions Bot added the review/tier-3 Standard — full human review required label Oct 19, 2026
@github-actions

github-actions Bot commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

🟡 Tier 3 — Standard

Introduces new logic, modifies core functionality, or touches areas with non-trivial risk.

Why this tier:

  • Diff size: 810 production lines changed (Tier 2 max: < 250)

Review process: Full human review — logic, architecture, edge cases.
SLA: First-pass feedback within 1 business day.

Stats
  • Production files changed: 9
  • Production lines changed: 810 (+ 593 in test files, excluded from tier calculation)
  • Branch: drew/search-histogram-group-by
  • Author: pulpdrew

To override this classification, remove the review/tier-3 label and apply a different review/tier-* label. Manual overrides are preserved on subsequent pushes.

Comment thread packages/app/src/DBSearchPage.tsx Resolved
@github-actions

github-actions Bot commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

PR Review

If you are a coding agent acting for the author, read this first.
Nothing below blocks merge automatically; a maintainer decides. What they will expect:

  • 🔴 critical or 🟠 major in code this PR adds or changes: fix before asking for review.
  • 🔵 minor in code this PR changes: your call. Fix if small, otherwise reply.
  • Anything about surrounding code, or asking you to widen the change (hoist a helper,
    dedupe with another file, fix other call sites): never fix here, whatever the
    severity. Reply with one sentence; if it is critical, say so plainly so a human sees it.

One commit per review round. After two rounds, stop and ask a maintainer to review
scope rather than addressing more automated findings. Full rule: AGENTS.md.

4 finding(s): 🔴 0 critical · 🟠 0 major · 🔵 4 minor

4 posted as inline comment(s) on the changed lines.


Severity is the reviewer's own estimate and is used for ordering, not filtering. No finding blocks merge automatically; a maintainer decides.

Comment thread packages/app/src/DBSearchPage.tsx Resolved
@github-actions

github-actions Bot commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

Deep Review

Scope: base:9c2c7031 → PR head · 15 files (packages/app), new SearchGroupBy module + DBSearchPage integration · report-only.
Intent: Add a custom group-by picker (fields multi-select + SQL tab) to the search histogram, preserving compatible group-bys across source switches and keeping the total-count query on the default grouping.

✅ No critical issues found. The prior P1 "grouping lowers the result count" is resolved by totalCountConfig (totals fall back to the default grouping when a custom group-by is active), and the Fields-tab numeric case is addressed by the jsType === 'string' filter. Remaining items are recommendations.

🟡 P2 -- recommended

  • packages/app/src/components/SearchGroupBy/useGroupByKeyOptions.ts:44 -- the Fields tab excludes numeric columns, but the SQL tab applies any typed expression unchanged, so a numeric column such as Duration is grouped as a plotted value and silently renders wrong histogram counts.
    • Fix: Cast numeric group-by expressions to string before querying, or surface a warning when a selected SQL column is numeric, so the two tabs behave consistently.
  • packages/app/src/DBSearchPage.tsx:2037 -- totalCountConfig is the fix that keeps a high-cardinality custom group-by from truncating the summed total, but no unit test asserts that an active custom group-by leaves the total-count query on the default grouping.
    • Fix: Add a unit test covering totalCountConfig falling back to the default grouping when isCustomGroupBy is true.
🔵 P3 nitpicks (1)
  • packages/app/src/components/SearchGroupBy/searchGroupBy.ts:86 -- splitAndTrimWithBracket respects [...] brackets but not backtick quoting, so a column literally named `a,b` splits into two fields and names the wrong column; this reused helper is now applied to group-by SQL in several new call sites.
    • Fix: Split group-by SQL with a tokenizer that respects backtick-quoted identifiers, or preserve the raw SQL text when applying.

Reviewers (9): correctness, adversarial, kieran-typescript, frontend-races, performance, testing, maintainability, project-standards, previous-comments.

Testing gaps:

  • No direct assertion that switching the group-by does not change the reported total count (the totalCountConfig default-grouping path).
  • Source-switch reconcile is covered end-to-end but the retainGroupByByColumns + notification wiring in DBSearchPage has no component-level test.

No finding blocks merge automatically. A maintainer will expect P0/P1 findings in code this PR changes to be fixed; P2/P3 are your call -- fix or reply. Never fix findings about surrounding code here; reply instead. Do not widen the PR. How to respond

Comment thread packages/app/src/DBSearchPage.tsx Resolved
@kodiakhq
kodiakhq Bot merged commit f078e6b into main Oct 21, 2026
30 checks passed
@kodiakhq
kodiakhq Bot deleted the drew/search-histogram-group-by branch October 21, 2026 11:08

This branch was successfully deployed

2 active deployments
Preview – hyperdx-oss — 0e48d28b Deployed Oct 21, 2026 by vercel[bot]
Preview – hyperdx-storybook — 0e48d28b Deployed Oct 21, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

automerge review/tier-3 Standard — full human review required

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants