Skip to content

feat(common-utils): canonical SELECT builder for cross-source search - #2882

Draft
teeohhem wants to merge 1 commit into
tom/n1-null-aliasfrom
tom/n2-select-builder
Draft

feat(common-utils): canonical SELECT builder for cross-source search#2882
teeohhem wants to merge 1 commit into
tom/n1-null-aliasfrom
tom/n2-select-builder

Conversation

@teeohhem

Copy link
Copy Markdown
Contributor

Stacked on #2881.

Searching several sources at once requires their rows to share a shape, but each source names its own columns. This adds a builder that, given a source, emits a SELECT projecting that source's semantic expressions under shared aliases (timestamp, service, severity/status, body/span name, duration), padding anything a source lacks with NULL so every source returns the same columns. Caller-requested extra columns resolve the same way.

Pure and fully unit-tested; no caller yet — the search page starts using it later in the stack.


Compound Engineering
Claude Code

@vercel

vercel Bot commented Aug 12, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
hyperdx-oss Ready Ready Preview Aug 12, 2026 7:18pm
hyperdx-storybook Ready Ready Preview Aug 12, 2026 7:18pm

Request Review

@changeset-bot

changeset-bot Bot commented Aug 12, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: a390bf2

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 Minor
@hyperdx/api Patch
@hyperdx/app 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

@greptile-apps

greptile-apps Bot commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

The PR adds shared builders that project log and trace sources into a canonical result shape for future cross-source searches.

  • Maps source-specific timestamp, service, severity/status, body/span, and duration expressions to stable aliases.
  • Pads unavailable semantic and caller-requested columns with NULL.
  • Adds focused unit tests and a common-utils changeset.

Confidence Score: 4/5

The PR should not merge until the outstanding ClickHouse alias escaping defect is fixed.

The builder still emits backslash-escaped double quotes for extra-column aliases, while ClickHouse identifier aliases require embedded quotes to be doubled; valid names containing quotes can therefore generate malformed SQL or the wrong result-column name.

Files Needing Attention: packages/common-utils/src/core/searchChartConfig.ts, packages/common-utils/src/core/tests/searchChartConfig.test.ts

Important Files Changed

Filename Overview
packages/common-utils/src/core/searchChartConfig.ts Adds the canonical SELECT and search-config builders, but the previously reported quoted-alias defect remains.
packages/common-utils/src/core/tests/searchChartConfig.test.ts Covers canonical projections, missing semantics, duration conversion, extra columns, and config assembly, but not the outstanding embedded-quote case.
.changeset/multi-source-select-builder.md Accurately records the new canonical cross-source SELECT builder as a common-utils minor release.

Reviews (2): Last reviewed commit: "feat(common-utils): canonical SELECT bui..." | Re-trigger Greptile

expression: string | null;
};

const quoteAlias = (name: string) => `"${name.replace(/"/g, '\\"')}"`;

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.

P2 Incorrect ClickHouse alias escaping

quoteAlias escapes embedded double quotes as \", while ClickHouse quoted identifiers require doubled quotes (""). An extra-column name such as Request "Count" therefore produces malformed SQL or an unexpected result-column name; use the repository's existing doubled-quote convention here.

Knowledge Base Used: common-utils

Fix in Claude Code Fix in Conductor Fix in Cursor Fix in Codex

Searching several sources at once needs their rows to share a shape, but
each source names its own columns. This builds a SELECT per source that
projects that source's semantic expressions under shared aliases —
timestamp, service, severity (status for traces), body (span name for
traces), duration — and pads anything a source lacks with NULL so every
source returns the same columns.

Callers can also request extra columns; each resolves to the column where
the source has it and NULL where it doesn't. Nothing calls this yet.
@github-actions

Copy link
Copy Markdown
Contributor

E2E Test Results

All tests passed • 279 passed • 1 skipped • 1064s

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

Tests ran across 4 shards in parallel.

View full report →

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant