Add premium geo dimension columns to usage events#21
Conversation
Greptile SummaryThis PR adds nine event-only premium geo dimension columns (
Confidence Score: 5/5Purely additive schema change with no gauge or primary-key impact; safe to merge. All nine columns are correctly scoped to event-only paths, the ClickHouse type and codec assignments are consistent with existing patterns, and the idempotent ADD COLUMN IF NOT EXISTS migration path prevents any breakage on existing tables. Tests cover both column-type routing logic and schema-level constraints. No files require special attention. Important Files Changed
Reviews (2): Last reviewed commit: "Add premium geo dimension columns to usa..." | Re-trigger Greptile |
| $stringColumn('continentCode', 2), | ||
| $stringColumn('subdivisions', 256), | ||
| $stringColumn('isp', 256), | ||
| $stringColumn('autonomousSystemNumber', 255), |
There was a problem hiding this comment.
autonomousSystemNumber is defined with size 255 while every other new premium geo string column in the same block uses 256. Given that the other fields in this group (city, subdivisions, isp, etc.) all use 256, this looks like an accidental mismatch rather than a deliberate choice — ASNs are short strings, so the difference has no practical impact, but the inconsistency is worth correcting for schema coherence.
| $stringColumn('autonomousSystemNumber', 255), | |
| $stringColumn('autonomousSystemNumber', 256), |
Prompt To Fix With AI
This is a comment left during a code review.
Path: src/Usage/Metric.php
Line: 643
Comment:
`autonomousSystemNumber` is defined with `size` 255 while every other new premium geo string column in the same block uses 256. Given that the other fields in this group (`city`, `subdivisions`, `isp`, etc.) all use 256, this looks like an accidental mismatch rather than a deliberate choice — ASNs are short strings, so the difference has no practical impact, but the inconsistency is worth correcting for schema coherence.
```suggestion
$stringColumn('autonomousSystemNumber', 256),
```
How can I resolve this? If you propose a fix, please make it concise.Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
Add nine event-only premium geo dimensions (city, continentCode, subdivisions, isp, autonomousSystemNumber, autonomousSystemOrganization, connectionType, connectionUsageType, connectionOrganization) as optional string columns in Metric::EVENT_COLUMNS and Metric::getEventSchema(). In the ClickHouse adapter the lower-cardinality dims (continentCode, subdivisions, connectionType, connectionUsageType, autonomousSystemNumber) map to LowCardinality(Nullable(String)); the high-cardinality dims (city, isp, autonomousSystemOrganization, connectionOrganization) fall through to Nullable(String). Existing tables auto-materialize the columns on setup() via the ADD COLUMN IF NOT EXISTS path; no other DDL change is required. Extends the Metric schema/EVENT_COLUMNS unit tests, adds a pure-unit column-type mapping test, and updates the live ClickHouse schema test.
593c0bd to
5a31e08
Compare
What
Adds nine event-only premium geo dimensions to the usage schema, sourced from the premium geo service (
appwrite/geo-premium)/ips/{ip}response and consumed by cloud'sStatsUsageworker (CLO-4541):city, continentCode, subdivisions, isp, autonomousSystemNumber, autonomousSystemOrganization, connectionType, connectionUsageType, connectionOrganizationChanges
Metric::EVENT_COLUMNS/getEventSchema()— the 9 columns as optional strings (event-only; absent from the gauge schema).Adapter/ClickHouse::getColumnType()— lower-cardinality dims (continentCode, subdivisions, connectionType, connectionUsageType, autonomousSystemNumber) map toLowCardinality(Nullable(String)); the high-cardinality dims (city, isp, autonomousSystemOrganization, connectionOrganization) to plainNullable(String).setup()via theensureDimColumns→ADD COLUMN IF NOT EXISTSpath. Gauges, primary keys, and indexes are unchanged.0.10.0).Compatibility
Purely additive and backward-compatible. Intended release:
0.10.0(cloud pins0.10.*).Notes
A one-off idempotent ClickHouse backfill script for existing production tables is kept out of this PR (ops artifact, run manually).