Skip to content

fix(common-utils): map NULL-literal SELECT aliases - #2881

Draft
teeohhem wants to merge 1 commit into
mainfrom
tom/n1-null-alias
Draft

fix(common-utils): map NULL-literal SELECT aliases#2881
teeohhem wants to merge 1 commit into
mainfrom
tom/n1-null-alias

Conversation

@teeohhem

Copy link
Copy Markdown
Contributor

A column projected as NULL AS "alias" was dropped from the SELECT alias map, because a NULL literal parses without a source location and fell through every branch. Callers that resolve a result column back to its source expression then treated the alias as a real table column — the row-identity WHERE builder emitted a predicate against a column that doesn't exist instead of isNull(NULL).

Found while building multi-source search, where a source that lacks a field projects it as NULL, but the bug is independent of that work and this fixes it on its own.


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:19pm
hyperdx-storybook Ready Ready Preview Aug 12, 2026 7:19pm

Request Review

@changeset-bot

changeset-bot Bot commented Aug 12, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 56d0557

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

This PR includes changesets to release 1 package
Name Type
@hyperdx/common-utils 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 preserves NULL AS "alias" projections in ClickHouse SELECT alias maps so downstream expression resolution treats them as NULL literals rather than nonexistent table columns.

  • Adds explicit handling for parser NULL-expression nodes that lack source locations.
  • Adds unit coverage for a multi-source padding-column projection.
  • Adds a patch changeset for @hyperdx/common-utils.

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failure remains.

Important Files Changed

Filename Overview
packages/common-utils/src/clickhouse/index.ts Maps aliased NULL-literal AST expressions to the SQL literal NULL, covering both normal and fallback parsing through the shared helper.
packages/common-utils/src/tests/clickhouse.test.ts Verifies that a NULL padding column and a normal column alias are both preserved in the alias map.
.changeset/null-literal-select-alias.md Correctly records the common-utils behavior fix as a patch release.

Reviews (2): Last reviewed commit: "fix(common-utils): map NULL-literal SELE..." | Re-trigger Greptile

@github-actions

github-actions Bot commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

E2E Test Results

All tests passed • 281 passed • 1 skipped • 1129s

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

Tests ran across 4 shards in parallel.

View full report →

`chSqlToAliasMap` walks the parsed SELECT and records each alias against the
expression behind it. A NULL literal (`NULL AS "x"`) parses without a source
location, so it fell through every branch and was dropped from the map.

Callers then treated the alias as a real column: the row-identity WHERE
builder, for instance, emitted `x = ...` against a column that does not
exist rather than `isNull(NULL)`.
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