Repository navigation
Conversation
🦋 Changeset detectedLatest commit: eeb05a5 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 |
|
@ralaruri is attempting to deploy a commit to the HyperDX Team on Vercel. A member of the Team first needs to authorize it. |
|
Hi @ralaruri, thanks for the pull request! Before we review code from a first-time contributor, a maintainer vouches for them, and you're not on our list yet. There's nothing else to file and this PR stays open — a maintainer will look at it, usually within a day or two, and vouch for you right here if it's a genuine attempt at the problem. To make that quick, check the PR description has:
More detail in our contributing guide. |
| inputSourceColumns | ||
| ? new Set( | ||
| inputSourceColumns | ||
| .filter(c => c.type === 'JSON' || c.type.startsWith('JSON(')) |
There was a problem hiding this comment.
🔵 minor — JSON column detection re-implements an existing type helper
This hand-written c.type === 'JSON' || c.type.startsWith('JSON(') predicate repeats DBRowDataPanel.tsx:414 and the existing helpers filterColumnMetaByType(columns, [JSDataType.JSON]) and convertCHDataTypeToJSType in common-utils (core/metadata, clickhouse/index.ts:119), which useJsonColumns already uses. Use filterColumnMetaByType(inputSourceColumns, [JSDataType.JSON]) so JSON detection has one source of truth.
Advisory. Fix if it is a small defect in code this PR changes; otherwise reply in the thread. Do not widen the PR or touch files it did not already change. How to respond
PR Review
2 finding(s): 🔴 0 critical · 🟠 1 major · 🔵 1 minor 1 posted as inline comment(s) on the changed lines. 1 listed below. Findings outside 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. |
…re-escaped Adding a second filter re-escaped every key in the filter state. toClickHouseKeyExpression treated a dotted key under a native JSON column as a Map key and rewrote it to col['key'], which ClickHouse rejects: 'First argument for function arrayElement must be array, got JSON'. Pass the table's JSON column names into escapeFilterStateKeys and toQuotedClickHouseKeyExpression, so keys under a JSON column are written as toString(`col`.`a`.`b`), the form the row panel already produces. Array subscripts in a path (`col`.`a`[1]) stay subscripts. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
ed19bbb to
eeb05a5
Compare
Deep ReviewThe change is a well-scoped, well-tested fix: it threads a ✅ No critical issues found. 🟡 P2 — recommended
🔵 P3 nitpicks (2)
Reviewers (6): correctness, kieran-typescript, maintainability, testing, security, project-standards. Testing gaps: No coverage for the facets-panel 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 |
Summary
With a native
JSONcolumn as the source's attributes column, adding a second filter breaks the first one. The table fails withCode 43: First argument for function 'arrayElement' must be array, got 'JSON'.Every filter change re-escapes all keys in the filter state.
toClickHouseKeyExpressionsees a dotted key likemessage.email, assumes a Map column, and writesmessage['email']. It only receives column names, not types. The newest filter is still in its original JSON form, so only the earlier one breaks.This passes the table's JSON column names (taken from the column types the search page already loads) into
escapeFilterStateKeysandtoQuotedClickHouseKeyExpression. Keys under a JSON column are now written astoString(`message`.`email`), the form the row panel already produces. Map columns are unchanged. Array subscripts in a path (`events`[1]) stay subscripts. The facets panel builds its keys the same way, through the existinguseJsonColumnshook.Tests: unit tests for the key function, plus a hook test where a JSON-key filter exists and another filter is added. They fail on
mainand pass here.tscand the related jest suites pass.Screenshots or video
How to reproduce
Starting point: ClickStack Local (
docker run -p 8080:8080 -p 8000:8000 -p 8123:8123 docker.clickhouse.com/clickhouse/clickstack-local) with this fake table, created withclickhouse-clientin the container:Add a Logs source: table
demo.events_json, Timestamp Columnoccurred_at, Log Attributes Expressionmessage, Default Selectingested_at, organization_id, message.On
main:message, hoveremail, click the filter icon. Rows still show.owner→profile→contact→email.</>, the WHERE clause hasmessage['email'].On this branch:
</>, both are written astoString(`message`.`…`).How to test on Vercel preview
N/A. It needs a source with a native JSON column, which the demo server probably doesn't have.
References