fix(search): keep select-alias filters working in Event Patterns#2487
fix(search): keep select-alias filters working in Event Patterns#2487alex-fedotyev wants to merge 2 commits into
Conversation
Filtering on a column the source exposes only under an alias (for example a default select of `ServiceName as service`) failed in the Event Patterns view with "Unknown expression or table expression identifier 'service'". The results table works because its own SELECT defines the alias, but Event Patterns rebuilds the SELECT and did not carry the alias definitions. Thread the source's alias WITH clauses (the same `aliasWith` already passed to the results, histogram, and heatmap queries) into the PatternTable config so the rebuilt pattern query defines the alias and the filter resolves. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
🦋 Changeset detectedLatest commit: 3d51707 The changes in this PR will be included in the next version bump. This PR includes changesets to release 3 packages
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 |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
🔵 Tier 2 — Low RiskSmall, isolated change with no API route or data model modifications. Why this tier:
Review process: AI review + quick human skim (target: 5–15 min). Reviewer validates AI assessment and checks for domain-specific concerns. Stats
|
Greptile SummaryThis PR fixes a bug where filtering Event Patterns on a column exposed only via a source-level alias (e.g.
Confidence Score: 4/5Safe to merge; the change is a single-field addition that mirrors a pattern already applied to three other configs on the same page. The core change is minimal and well-tested. The only nearby gap is The Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[DBSearchPage\naliasWith from aliasMapToWithClauses] --> B[histogramTimeChartConfig\nwith: aliasWith ✅]
A --> C[heatmap chartConfig\nwith: aliasWith ✅]
A --> D[results dbSqlRowTableConfig\nwith: aliasWith ✅]
A --> E[PatternTable config\nwith: aliasWith ✅ FIXED]
A --> F[SearchNumRows config\nwith: aliasWith ❌ still missing]
E --> G[useGroupedPatterns\nusePatterns]
G --> H[configWithPrimaryAndPartitionKey\nspreads config incl. with]
H --> I[renderChartConfig\ngenerates WITH clause\nServiceName AS service]
I --> J[ClickHouse query\nfilter resolves ✅]
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
flowchart TD
A[DBSearchPage\naliasWith from aliasMapToWithClauses] --> B[histogramTimeChartConfig\nwith: aliasWith ✅]
A --> C[heatmap chartConfig\nwith: aliasWith ✅]
A --> D[results dbSqlRowTableConfig\nwith: aliasWith ✅]
A --> E[PatternTable config\nwith: aliasWith ✅ FIXED]
A --> F[SearchNumRows config\nwith: aliasWith ❌ still missing]
E --> G[useGroupedPatterns\nusePatterns]
G --> H[configWithPrimaryAndPartitionKey\nspreads config incl. with]
H --> I[renderChartConfig\ngenerates WITH clause\nServiceName AS service]
I --> J[ClickHouse query\nfilter resolves ✅]
|
E2E Test Results✅ All tests passed • 199 passed • 3 skipped • 1389s
Tests ran across 4 shards in parallel. |
Filtering Event Patterns on a column the source exposes only under an alias (for example a default select of
ServiceName as service) failed withUnknown expression or table expression identifier 'service'. The results table works because its own SELECT defines the alias, but Event Patterns rebuilds the SELECT (sampled body and timestamp,ORDER BY rand() LIMIT) and did not carry the alias definitions, so the filter referenced a column that did not exist in the rebuilt query.Summary
The
PatternTableconfig now receives the same aliasWITHclauses (aliasWith) already threaded into the results, histogram, and heatmap configs inDBSearchPage.usePatternsspreads the config into the sampled query, so the rebuilt pattern query defines the alias in aWITHclause and the filter resolves.This is the one-field change at the
PatternTablecall site plus a regression test. It reuses the existinguseAliasMapFromChartConfig->aliasMapToWithClauses->withmechanism, no new code paths.Why this was invisible to the results table
The results table renders the source's own SELECT, which defines
service. ClickHouse resolves aWITH (ServiceName) AS serviceexpression alias insideWHERE, so the filter works there. Event Patterns, histogram, and heatmap all rebuild the SELECT; the other two already passedaliasWith, Event Patterns was the one that did not.Test plan
make ci-lint(eslint + tsc) on@hyperdx/appand@hyperdx/common-utilsmake ci-unitrenderChartConfigtests: a pattern-shaped config (rebuilt select,ORDER BY rand(), filter onservice) renders(ServiceName) AS serviceinWITHand references it in the predicate; the same config without a threaded alias map omits the definition (the bug). The negative case fails before this change.UNKNOWN_IDENTIFIERfor an undefinedserviceand succeeds once the(ServiceName) AS serviceWITHclause is present. Single-node CI with snapshot SQL tests cannot see this class, so I checked it against a running server directly.The diff also drops 4 stray em-dashes from comments in
renderChartConfig.test.ts(repo style; the file was already in the diff).Companion to #2486, which makes the underlying alias map resilient to ClickHouse-specific SQL the parser rejects. The two touch disjoint files and are independent; this change fixes the common
ServiceName as servicecase on its own.