fix: map alias with filters#2393
Conversation
🦋 Changeset detectedLatest commit: 8035128 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 |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
🟡 Tier 3 — StandardIntroduces new logic, modifies core functionality, or touches areas with non-trivial risk. Why this tier:
Review process: Full human review — logic, architecture, edge cases. Stats
|
E2E Test Results✅ All tests passed • 190 passed • 3 skipped • 1342s
Tests ran across 4 shards in parallel. |
Deep Review🟡 P2 — recommended
🔵 P3 nitpicks (3)
Reviewers (8): correctness, testing, maintainability, project-standards, agent-native, learnings-researcher, kieran-typescript, previous-comments. Testing gaps:
|
Conflict in `packages/common-utils/src/core/metadata.ts`: Main (PR #2393, "map alias with filters") extended the inline `parseKeyPath` with the ClickHouse `arrayElement(map, 'key')` function-call form (the shape ClickHouse renders Map subscript expressions as in result column names) plus the double-quoted bracket form. This branch had moved `parseKeyPath` out of `core/metadata.ts` into its own leaf module at `core/keyPath.ts` so `types.ts` can normalize dashboard-filter expressions with the same rules without forming a circular import through `metadata.ts -> clickhouse -> guards.ts -> types.ts`. Resolution: keep the leaf module + re-export structure from this branch, fold main's `arrayElement` handling AND the double-quoted form into `core/keyPath.ts`, and let the re-export in `core/metadata.ts` surface the merged implementation to call sites that still import from there. The four new `arrayElement` test cases in `packages/common-utils/src/__tests__/metadata.test.ts` exercise the re-exported function unchanged. Verified: - common-utils: 1195 / 1195 tests pass (was 1191 + 4 new arrayElement tests from main). - common-utils lint clean. - app lint clean (after prettier auto-fix on the helpers test). - app: 131 / 131 tests pass across dashboardFilter / useDashboardFilters / DashboardFiltersModal.helpers / DBRowTable.
## Summary If you try and add a filter for an existing column that is a map access column, (ex: `ResourceAttributes['service.name']`), ClickHouse will return the column as `arrayElement(ResourceAttributes, 'service.name')`. Previously filters were defined in SQL, but now they are lucene, which means it doesn't automatically translate anymore. We could either make the filters aware of how to parse and translate that statement, or add an alias to the SELECT if a map is accessed. This PR adds both. ### Screenshots or video https://github.com/user-attachments/assets/d278962c-c33c-4c5e-a00e-90f8bee16f1b ### How to test on Vercel preview **Preview routes:** **Steps:** 1. Add a `ResourceAttributes['service.name'] 2. Hover over the column titled `ResourceAttributes['service.name']` on any row 3. Click "toggle filter" 4. Observe that the behavior is handled correctly ### References - Linear Issue: Closes HDX-4411
Summary
If you try and add a filter for an existing column that is a map access column, (ex:
ResourceAttributes['service.name']), ClickHouse will return the column asarrayElement(ResourceAttributes, 'service.name'). Previously filters were defined in SQL, but now they are lucene, which means it doesn't automatically translate anymore.We could either make the filters aware of how to parse and translate that statement, or add an alias to the SELECT if a map is accessed. This PR adds both.
Screenshots or video
export-1780324637704.mp4
How to test on Vercel preview
Preview routes:
Steps:
ResourceAttributes['service.name']on any rowReferences