feat(clickhouse): add premium geo columns to audit schema#131
Conversation
Add 9 optional geo attributes (city, continentCode, subdivisions, isp, autonomousSystemNumber, autonomousSystemOrganization, connectionType, connectionUsageType, connectionOrganization) to the ClickHouse audit adapter so audit rows can carry premium geo data. Low-cardinality dimensions (continentCode, subdivisions, connectionType, connectionUsageType, autonomousSystemNumber) are added to LOW_CARDINALITY_COLUMNS so they map to LowCardinality(Nullable(String)); the high-cardinality ones stay plain Nullable(String). createTable() and getColumnDefinition() pick them up automatically from getAttributes(); no index/sort-key changes. Extend adapter tests to cover the new attributes and their LowCardinality vs String/Nullable column-type classification.
Greptile SummaryThis PR adds 9 optional premium geo columns (
Confidence Score: 5/5Purely additive schema extension with no changes to existing query, insert, or selection logic. All new columns are optional, default-null strings that slot into the existing dynamic attribute pipeline without touching any conditional logic. The four LowCardinality choices are intentional and commented. Three new tests — attribute shape, column-type classification, and a live round-trip — give good confidence the columns are correctly defined, typed, and persisted. No files require special attention. Important Files Changed
Reviews (2): Last reviewed commit: "test(clickhouse): geo round-trip test; m..." | Re-trigger Greptile |
…lumns # Conflicts: # src/Audit/Adapter/ClickHouse.php # tests/Audit/Adapter/ClickHouseTest.php
- autonomousSystemNumber: plain Nullable(String) instead of LowCardinality (~100k ASNs globally can exceed ClickHouse's LowCardinality sweet spot; the remaining low-card geo dims have tight cardinality). Addresses review. - Add testPremiumGeoRoundTrip: writes a log with all 9 geo fields and reads them back unchanged, proving the columns are created/written/selected.
What
Adds 9 premium geo columns to the ClickHouse audit schema (CLO-4575), so cloud can store the same premium geo attributes on audit logs that it already stores on usage events:
city, continentCode, subdivisions, isp, autonomousSystemNumber, autonomousSystemOrganization, connectionType, connectionUsageType, connectionOrganizationChanges
Adapter/ClickHouse.php— 9 optional string attributes ingetAttributes()(mirroringcountry); the 5 lower-cardinality dims (continentCode, subdivisions, connectionType, connectionUsageType, autonomousSystemNumber) added toLOW_CARDINALITY_COLUMNS. Picked up automatically byCREATE TABLE/getColumnDefinition(); no index/sort-key change.Compatibility
Purely additive. Suggested release:
2.7.0(minor). Consumers pinning^2.4auto-resolve.Notes
The adapter only does
CREATE TABLE IF NOT EXISTS(no ADD COLUMN path), so existing deployments need a one-offALTER … ADD COLUMN. An idempotent ops script is kept out of this PR (untracked, credential-free, run manually).