refactor: column identifiers to their own type#2425
Conversation
|
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Greptile SummaryThis PR refactors
Confidence Score: 4/5Safe to merge — all call-site changes are semantically equivalent to the old join('.') pattern, and the new type structure correctly discriminates native vs. map columns throughout. The refactoring is correct across all changed call sites. The only gap is that MapColumnKeySchema does not reject an empty string for the packages/common-utils/src/types.ts — the MapColumnKeySchema column field validation. Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A["Raw key string\ne.g. SpanAttributes['k8s.pod.name']"] --> B["parseKeyPath(key)"]
B --> C{Bracket notation\ndetected?}
C -- Yes --> D["ColumnKey\n{ column: 'SpanAttributes', key: 'k8s.pod.name' }"]
C -- No --> E["ColumnKey\n{ column: NATIVE_COLUMN, key: 'ServiceName' }"]
D --> F["isMapColumn(col) → true"]
E --> G["isMapColumn(col) → false"]
F --> H["columnKeyToDotPath(col)\n→ 'SpanAttributes.k8s.pod.name'"]
G --> I["columnKeyToDotPath(col)\n→ 'ServiceName'"]
F --> J["SQL path\nmapContains(col.column, col.key)"]
H --> K["FilterState key / Lucene field"]
I --> K
Reviews (1): Last reviewed commit: "WIP" | Re-trigger Greptile |
| export const MapColumnKeySchema = z.object({ | ||
| column: z.string().refine(s => s !== NATIVE_COLUMN, { | ||
| message: `column must not equal "${NATIVE_COLUMN}"; use NativeColumnKeySchema for native columns`, | ||
| }), | ||
| key: z.string(), | ||
| }); |
There was a problem hiding this comment.
MapColumnKeySchema only rejects NATIVE_COLUMN for column but does not reject an empty string. parseKeyPath("['service.name']") (bracket starting at index 0) produces { column: '', key: 'service.name' }, which passes this schema as a MapColumnKey. Downstream callers like buildMapContains would then emit mapContains(\`, 'service.name')— invalid SQL. Addingmin(1)` closes the gap and makes the schema's invariant explicit.
| export const MapColumnKeySchema = z.object({ | |
| column: z.string().refine(s => s !== NATIVE_COLUMN, { | |
| message: `column must not equal "${NATIVE_COLUMN}"; use NativeColumnKeySchema for native columns`, | |
| }), | |
| key: z.string(), | |
| }); | |
| export const MapColumnKeySchema = z.object({ | |
| column: z | |
| .string() | |
| .min(1, { message: 'column must be a non-empty string' }) | |
| .refine(s => s !== NATIVE_COLUMN, { | |
| message: `column must not equal "${NATIVE_COLUMN}"; use NativeColumnKeySchema for native columns`, | |
| }), | |
| key: z.string(), | |
| }); |
Summary
Screenshots or video
How to test on Vercel preview
Preview routes:
Steps:
References