Skip to content

fix: keep backtick-quoted column names with commas intact when toggling columns - #3451

Merged
jordan-simonovski merged 3 commits into
mainfrom
jordansimonovski/hdx-5797-backtick-column-split
Oct 30, 2026
Merged

jordan-simonovski merged 3 commits into
mainfrom
jordansimonovski/hdx-5797-backtick-column-split

Conversation

@jordan-simonovski

Copy link
Copy Markdown
Contributor

Summary

Removing or adding a search column no longer breaks a backtick-quoted name that contains a comma. The shared SELECT splitter used to cut `a,b` in two, so toggling any column from the table header rewrote it as `a, b`, which names a different column and breaks the query.

  • Group by, sorting key, timestamp and other SELECT list parsing use the same splitter, so they get the fix too.
  • The column and sort editors from Add the column and sort editors #3431 had their own backtick workaround. They now use the shared splitter, so every caller splits a SELECT the same way.
  • An unclosed quote or backtick, e.g. a half-typed Timestamp, `a, now keeps its text. Before, the text after the quote was dropped, and the columns editor erased it when you added or removed a column.

Breaking changes

None. Inputs without backticks split as before. The one behaviour change: input ending in an unclosed ', " or ` now returns its last item instead of dropping it. Unclosed brackets still drop it.

Screenshots or video

I tested this locally against the demo server but couldn't attach images from the CLI. The author will add Before and After.

Before After

How to reproduce

Starting point: yarn app:dev:local, onboarding, "Connect to Demo Server", Demo Logs source.

On main:

  1. In the SELECT box, enter Timestamp, Body AS `a,b`, ServiceName and click Run.
  2. Hover the ServiceName column header and click the X.
  3. The SELECT box now reads Timestamp, Body AS `a, b` .

On this branch:

  1. Same steps. The SELECT box reads Timestamp, Body AS `a,b` and the table still loads.

How to test on Vercel preview

Preview routes: /search

Steps:

  1. Select the "Demo Logs" source.
  2. In the SELECT box, enter Timestamp, Body AS `a,b`, ServiceName and click Run.
  3. Hover the "ServiceName" column header and click its "Remove column" button.
  4. Verify the SELECT box reads Timestamp, Body AS `a,b` and the results table shows an a,b column.

References

…ECT lists

splitAndTrimWithBracket now treats backtick-quoted identifiers as opaque, so
toggling a search column no longer rewrites `a,b` as `a, b`. The column and sort
editors drop their own splitClauseList wrapper and use the shared splitter.
Text after an unclosed quote is kept instead of dropped.

HDX-5797
@changeset-bot

changeset-bot Bot commented Oct 23, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 4e44358

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

@vercel

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

Request Review

@github-actions github-actions Bot added the review/tier-2 Low risk — AI review + quick human skim label Oct 23, 2026
@github-actions

Copy link
Copy Markdown
Contributor

🔵 Tier 2 — Low Risk

Small, isolated change with no API route or data model modifications.

Why this tier:

  • Standard feature/fix — introduces new logic or modifies core functionality

Additional context: spans packages but only 57 prod lines — under the 100-line cross-layer bar

Review process: AI review + quick human skim (target: 5–15 min). Reviewer validates AI assessment and checks for domain-specific concerns.
SLA: Resolve within 4 business hours.

Stats
  • Production files changed: 4
  • Production lines changed: 57 (+ 32 in test files, excluded from tier calculation)
  • Branch: jordansimonovski/hdx-5797-backtick-column-split
  • Author: jordan-simonovski

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

@github-actions

github-actions Bot commented Oct 23, 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 114 in total (1.41%).
Run yarn dupes locally to reproduce, or yarn dupes:all for the full picture.

@github-actions

github-actions Bot commented Oct 23, 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.

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

2 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.

@greptile-apps

greptile-apps Bot commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge.

Summary

Keeps commas inside backtick-quoted column names intact when users toggle columns.

  • Quoted names stay intact when search lists are split and edited.

Reviews (3) · Last reviewed commit: "Merge branch 'main' into jordansimonovsk..." · Reviewed by Greptile

@github-actions

github-actions Bot commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

Deep Review

✅ No critical issues found.

The fix is correct for all valid inputs: a comma inside a backtick-quoted identifier (`a,b`) is preserved across the shared splitter, and every caller (columns editor, sort keys, group by, timestamp) now goes through one code path. The remaining findings concern malformed/half-typed input and test coverage, not the happy path.

🟡 P2 — recommended

  • packages/common-utils/src/core/utils.ts:144 — The new backtick toggle's two guards are untested: deleting !isQuoteEscapedByBackslash(input, i) (escaped backtick) or !inSingleQuote && !inDoubleQuote (backtick inside a string literal) leaves the entire suite green, and the inDoubleQuote arm of the trailing-keep block at line 200 is also unexercised.
    • Fix: Add splitAndTrimWithBracket cases for a backslash-escaped backtick, a backtick inside a single/double-quoted string, and an unclosed double-quote tail.
    • testing, correctness, kieran-typescript, adversarial
🔵 P3 nitpicks (3)
  • packages/common-utils/src/core/utils.ts:200 — The trailing-keep block fires on inBacktick || inSingleQuote || inDoubleQuote but ignores parenCount/squareCount, so splitAndTrimWithBracket("func('a,b") keeps the tail while "func(a,b" drops it, contradicting the adjacent comment that unclosed brackets are still dropped.
    • Fix: Either gate the trailing push on parenCount === 0 && squareCount === 0, or correct the comment to state an open quote takes precedence over an unbalanced bracket.
    • correctness, adversarial
  • packages/common-utils/src/core/utils.ts:155 — An unclosed backtick mid-list ("a, \b, c, d") collapses all following items into one segment (["a", "`b, c, d"]`) where the prior splitter produced four, changing group-by/series counts for consumers that count segments.
    • Fix: Add a test pinning the intended behavior for an unterminated backtick mid-list so the count change is documented, not incidental.
    • adversarial
  • packages/common-utils/src/core/utils.ts:201 — cur.slice(0, -1) strips the synthetic , injected by the i <= input.length sentinel, but nothing local ties the slice to that sentinel, making it a trap if the loop's flush mechanism ever changes.
    • Fix: Add a one-line comment linking the slice to the sentinel comma appended at line 142.
    • maintainability, kieran-typescript

Reviewers (7): correctness, testing, maintainability, project-standards, kieran-typescript, adversarial, previous-comments.

Testing gaps:

  • No coverage for the escaped-backtick guard or the backtick-inside-quoted-string guard — either can be removed without failing a test.
  • No test for a doubled-backtick ClickHouse escape ( `ab``), where the new inline splitter diverges from the removedreplaceBacktickedIdentifiers`-based wrapper.
  • ColumnsPopover.tsx is user-visible; confirm before/after screenshots are attached to the PR per contribution guidelines (the body notes they are pending).

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

@github-actions

github-actions Bot commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

E2E Test Results

✅ All tests passed • 457 passed • 1 skipped • 1438s

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

Tests ran across 4 shards in parallel.

View full report →

@pulpdrew pulpdrew left a comment

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.

LGTM

}
// An unclosed quote swallows the closing ','; keep its text so a half-typed
// name survives. Unclosed brackets still drop it, as parseToStartOfFunction expects.
if (inBacktick || inSingleQuote || inDoubleQuote) {

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.

🔵 minor — Keeping the text after an unclosed quote lets the columns editor absorb columns added after it

ColumnsPopover rebuilds the draft with items.join(', ') and then splits it again (packages/app/src/components/SearchResultsToolbar/ColumnsPopover.tsx:86,93,110). Take the draft Timestamp, aand addBody. The draft becomes Timestamp, a, Body, which splits back into ['Timestamp', 'a, Body']. Bodynever shows up as its own row and stays in the options list, so each further click appends, Bodyagain. Dragging ``a `` above Timestamp has the same effect and merges the two into one item. Before this PR the dangling item was dropped instead. Two possible fixes: disable add and reorder while the last item has an open quote, or have the splitter tell callers which item is unterminated so the editor can block structural edits on it. Add a ColumnsPopover test that adds a column after an unclosed backtick.

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

}
// An unclosed quote swallows the closing ','; keep its text so a half-typed
// name survives. Unclosed brackets still drop it, as parseToStartOfFunction expects.
if (inBacktick || inSingleQuote || inDoubleQuote) {

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.

🔵 minor — Unclosed-quote fallback also fires when brackets are unbalanced, which contradicts the comment and the PR description

The fallback only checks the quote flags. Input with an unclosed bracket that also has an open quote, such as Timestamp, count(aorx, f('y, now returns its last item. The same input without the quote, count(a, still drops it. The comment says unclosed brackets still drop the item, as parseToStartOfFunctionexpects, so this case breaks that contract. AddparenCount === 0 && squareCount === 0` to the condition, and add a test for an unclosed quote inside an open paren.

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

This branch was successfully deployed

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

Labels

review/tier-2 Low risk — AI review + quick human skim

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants