feat(common-utils): canonical SELECT builder for cross-source search - #2882
feat(common-utils): canonical SELECT builder for cross-source search#2882teeohhem wants to merge 1 commit into
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
🦋 Changeset detectedLatest commit: a390bf2 The changes in this PR will be included in the next version bump. This PR includes changesets to release 4 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 |
Greptile SummaryThe PR adds shared builders that project log and trace sources into a canonical result shape for future cross-source searches.
Confidence Score: 4/5The 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
|
| 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, '\\"')}"`; |
There was a problem hiding this comment.
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
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.
e00bda7 to
a390bf2
Compare
E2E Test Results✅ All tests passed • 279 passed • 1 skipped • 1064s
Tests ran across 4 shards in parallel. |
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.