Skip to content

fix: Fix side panel for backticked aliases, hyphenated columns - #3115

Open
pulpdrew wants to merge 1 commit into
mainfrom
drew/fix-dashed-backticked-aliases
Open

fix: Fix side panel for backticked aliases, hyphenated columns#3115
pulpdrew wants to merge 1 commit into
mainfrom
drew/fix-dashed-backticked-aliases

Conversation

@pulpdrew

Copy link
Copy Markdown
Contributor

Summary

This PR fixes a few bugs causing failures when opening the row side panel, when not using the _block_number/ _block_offset based lookup.

To reproduce, disable _block_number/ _block_offset based lookup with ALTER TABLE <source_table> MODIFY SETTING enable_block_offset_column = 0, enable_block_number_column = 0;

Screenshots or video

Select containing hyphenated column:

Before

Screenshot 2026-09-11 at 2 34 39 PM Screenshot 2026-09-11 at 2 35 05 PM

After

Screenshot 2026-09-11 at 2 30 30 PM

Select containing a backtick-quoted alias, with other aliases

Before

Screenshot 2026-09-11 at 2 33 55 PM

After

Screenshot 2026-09-11 at 2 32 11 PM

How to test locally

Add a hyphenated column to your logs table

alter table otel_logs add column `test-hyphen` String

Disable the block_number filtering:

alter table otel_logs modify setting enable_block_offset_column = 0, enable_block_number_column = 0;

References

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

@changeset-bot

changeset-bot Bot commented Sep 11, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: a1f17fd

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

This PR includes changesets to release 4 packages
Name Type
@hyperdx/app Patch
@hyperdx/common-utils 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

@vercel

vercel Bot commented Sep 11, 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 Sep 11, 2026 7:11pm UTC
hyperdx-storybook Ready Ready Preview Sep 11, 2026 7:11pm UTC

Request Review

@github-actions github-actions Bot added the review/tier-3 Standard — full human review required label Sep 11, 2026
@github-actions

github-actions Bot commented Sep 11, 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:

  • Cross-layer change: touches frontend (packages/app) + shared utils (packages/common-utils)

Additional context: touches the query rendering engine lightly (37 lines, under the 150-line bar for Tier 4)

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

Stats
  • Production files changed: 5
  • Production lines changed: 177 (+ 291 in test files, excluded from tier calculation)
  • Branch: drew/fix-dashed-backticked-aliases
  • 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.

@github-actions

github-actions Bot commented Sep 11, 2026

Copy link
Copy Markdown
Contributor

Deep Review

✅ No critical issues found. The two prior Greptile P1s are resolved or non-blocking: the CLI Dynamic-null path now inserts SqlString.raw(valueExpr) (packages/cli/src/shared/useRowWhere.ts:100) matching the app, and the placeholder-collision and dotted-literal-name findings were withdrawn (reserved sentinel prefix + length-sorted restore; dotted names are pre-existing and unchanged by this diff).

🟡 P2 -- recommended

  • packages/common-utils/src/core/utils.ts:441 -- replaceBacktickedIdentifiers scans string literals but not -- / /* */ comments, so an apostrophe inside a comment (e.g. -- don't include Body) opens a phantom string literal that swallows a following backtick-quoted alias; tokenization aborts, the parse fails, and chSqlToAliasMap returns {}, silently reverting to the un-fixed alias behavior for that query.
    • Fix: Add -- and /* */ comment-skip branches before the quote branch, mirroring the comment handling already present in extractOuterSelectProjection at packages/common-utils/src/clickhouse/index.ts:889.
    • previous-comments, orchestrator-verification
🔵 P3 nitpicks (1)
  • packages/common-utils/src/core/utils.ts:405 -- The __hdx_quoted_identifier_ sentinel prefix is a reserved namespace whose safety depends on user SQL/column names never containing it, but that invariant is undocumented at the QUOTED_IDENTIFIER_REPLACEMENT_PREFIX declaration.
    • Fix: Add a comment noting the prefix is reserved and that unambiguous restoration assumes user identifiers never collide with __hdx_quoted_identifier_NNN.

Reviewers (6): correctness, adversarial, kieran-typescript, testing, maintainability, previous-comments.

Coverage note: Findings reflect the completed previous-comments reviewer plus direct orchestrator verification of the tokenizer, quoting helpers, both useRowWhere copies, and the CLI Dynamic-null fix; the other dispatched reviewers had not returned when the report was finalized, so additional low-severity nits may exist.

Testing gaps:

  • No test exercises replaceBacktickedIdentifiers / chSqlToAliasMap on a SELECT containing a SQL comment with an apostrophe alongside a backtick-quoted alias.
  • No test covers a user column/alias colliding with the __hdx_quoted_identifier_NNN sentinel prefix.

@greptile-apps

greptile-apps Bot commented Sep 11, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR fixes row-detail predicates for hyphenated result columns and preserves aliases containing backtick-quoted identifiers.

  • Quotes non-expression result column names before using them in row predicates.
  • Tokenizes and restores backtick-quoted identifiers during alias-map parsing.
  • Corrects null handling for Dynamic expressions in both the app and CLI.
  • Adds focused app, CLI, and common-utils regression coverage.

Confidence Score: 5/5

The PR appears safe to merge; the previously reported CLI Dynamic-null failure is fixed and no new actionable regressions remain.

The CLI now renders both quoted identifiers and alias expressions directly inside isNull(...), with regression coverage for each case. The earlier literal-name finding was conceded, the placeholder concern was withdrawn after the repository assumption was clarified, and the remaining previous thread was manually resolved without explanation after its underlying code path was corrected.

Important Files Changed

Filename Overview
packages/cli/src/shared/useRowWhere.ts Uses raw column expressions for Dynamic null predicates, resolving the previous double-quoting failure.
packages/app/src/hooks/useRowWhere.tsx Quotes non-bare result column names while preserving alias expressions.
packages/common-utils/src/clickhouse/index.ts Integrates quoted-identifier tokenization and restoration into alias-map parsing.
packages/common-utils/src/core/metadata.ts Adds shared helpers for safely quoting identifiers and result column names.
packages/common-utils/src/core/utils.ts Adds string-aware backtick tokenization and deterministic placeholder restoration.

Reviews (3): Last reviewed commit: "fix: Fix side panel for backticked alias..." | Re-trigger Greptile

Comment thread packages/common-utils/src/core/metadata.ts
Comment thread packages/common-utils/src/core/utils.ts
@github-actions

github-actions Bot commented Sep 11, 2026

Copy link
Copy Markdown
Contributor

PR Review

3 finding(s): 🔴 0 critical · 🟠 1 major · 🔵 2 minor

2 posted as inline comment(s) on the changed lines. 1 listed below.

Findings outside the changed lines

  • 🟠 packages/common-utils/src/clickhouse/index.ts:824JSON-token restoration keeps only the last token per alias, leaving __hdx_json_replacement_N in the alias expression → The loop reassigns aliasMap[alias] = aliasExpression.replaceAll(...) from the loop-bound aliasExpression on every iteration, so with two JSON/dotted references in one aliased expression only the last matching token survives. SELECT concat(Body.a, Body.b) AS x yields aliasMap.x = "concat(__hdx_json_replacement_0, Body.b)" (or the mirror), which then flows into buildColumnMap/aliasMapToWithClauses as the row WHERE expression and fails in ClickHouse with Unknown identifier __hdx_json_replacement_0 — the side panel this PR is fixing stays broken for such a select. The diff already adds the correct fix: replace lines 823-830 with restoreReplacements(aliasExpression, jsonReplacements) (chained + longest-token-first, so it also removes the _1 vs _10 prefix hazard). The new test restores quoted identifiers alongside a JSON path looks like it covers this but has only one JSON expression (j.p0); add a case with two dotted paths inside one aliased expression.

Severity is the reviewer's own estimate and is used for ordering, not filtering.

@github-actions

github-actions Bot commented Sep 11, 2026

Copy link
Copy Markdown
Contributor

E2E Test Results

All tests passed • 356 passed • 1 skipped • 1512s

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

Tests ran across 4 shards in parallel.

View full report →

@pulpdrew
pulpdrew force-pushed the drew/fix-dashed-backticked-aliases branch from d6bedd8 to aecd61c Compare September 11, 2026 18:59
Comment thread packages/cli/src/shared/useRowWhere.ts
@pulpdrew
pulpdrew force-pushed the drew/fix-dashed-backticked-aliases branch 2 times, most recently from aecd61c to a1f17fd Compare September 11, 2026 19:07
Comment thread packages/common-utils/src/core/utils.ts
Comment thread packages/common-utils/src/clickhouse/index.ts
Comment thread packages/common-utils/src/core/metadata.ts
@pulpdrew
pulpdrew requested a review from wrn14897 September 11, 2026 19:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

review/tier-3 Standard — full human review required

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant