:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
fix(ci): compose gate composes the PR merge ref, not its head (#98288)
Paweł Szczur9e4c0b61ad37
diff --git a/.github/workflows/ci-clickhouse-hcl-schema.yml b/.github/workflows/ci-clickhouse-hcl-schema.ymlindex 91b87ea6cafd..f4801df976fe 100644--- a/.github/workflows/ci-clickhouse-hcl-schema.yml+++ b/.github/workflows/ci-clickhouse-hcl-schema.yml@@ -58,7 +58,7 @@ jobs:# Cross-repo compose gate: posthog-cloud-infra composes vendored base layers# from this repo (roles/shared, roles/data/shared, growing per role). This- # job asks cloud-infra to compose against the PR head and fails if a patch+ # job asks cloud-infra to compose against the PR merge commit and fails if a patch# no longer resolves there. It cannot catch golden movement — a legitimate# shared-layer change shifts cloud goldens at the next base-ref bump, and# that bump PR owns the regen.@@ -98,7 +98,16 @@ jobs:if: steps.app-token.outcome == 'success'env:GH_TOKEN: ${{ steps.app-token.outputs.token }}- POSTHOG_REF: ${{ github.event.pull_request.head.sha }}+ # On a pull_request event github.sha is the merge commit, not+ # the head. cloud-infra vendors layers from this ref while its own+ # layers track posthog master, so a head that predates a+ # master-side layer change composes against a cloud-infra that+ # already expects it, and every unrebased PR goes red for a change+ # it does not contain. The merge commit is what the PR lands as.+ #+ # A sha, not refs/pull/N/merge: cloud-infra's gate rejects any+ # posthog_ref that is not 40 hex chars.+ POSTHOG_REF: ${{ github.sha }}PR_NUMBER: ${{ github.event.pull_request.number }}run: |set -euo pipefaildiff --git a/posthog/clickhouse/hcl/README.md b/posthog/clickhouse/hcl/README.mdindex ac29efbb0dcc..abb656e4e9c9 100644--- a/posthog/clickhouse/hcl/README.md+++ b/posthog/clickhouse/hcl/README.md@@ -106,7 +106,7 @@ posthog-cloud-infra composes its cloud envs (dev, prod-us, prod-eu) from base laEditing a vendored layer therefore changes compositions in another repo.Two consequences:-- The **Cloud compose gate** job (in `ci-clickhouse-hcl-schema.yml`) dispatches to posthog-cloud-infra and composes the cloud envs against your PR head; it fails when a change breaks composition there (a patch that no longer resolves, a redeclaration, a validation error).+- The **Cloud compose gate** job (in `ci-clickhouse-hcl-schema.yml`) dispatches to posthog-cloud-infra and composes the cloud envs against your PR's merge commit, which is what the PR lands as; it fails when a change breaks composition there (a patch that no longer resolves, a redeclaration, a validation error).- A change that composes cleanly may still legitimately _shift_ cloud goldens (say, a new column on `_event_base`) — that regen happens in cloud-infra's next `base-ref` bump PR, not here, and is expected.The events family is the canonical example: `roles/shared/event_base.hcl` declares `_event_base` once, `roles/data/shared/` declares the `sharded_events` and `events` extenders, `roles/sessions/shared/` the sessions replica of the proxy; cloud env deltas (mat\_ columns, env specs) live as patches in cloud-infra's `overrides/`.diff --git a/posthog/clickhouse/hcl/codegen/gen_migration.py b/posthog/clickhouse/hcl/codegen/gen_migration.pyindex 976e639c1f1e..e876c49530c7 100644--- a/posthog/clickhouse/hcl/codegen/gen_migration.py+++ b/posthog/clickhouse/hcl/codegen/gen_migration.py@@ -70,6 +70,7 @@ NODE_ROLE_MEMBERS = {NON_TARGET_ROLES = {"batch_exports": "dump-baselined; no NodeRole member","all": "the local-single dev node; mirrors what migrations produce",+ "apm": "modeled for drift detection; no NodeRole member, so migrations cannot address it",}# Envs that mirror what the migrations produce rather than declaring intent, so they@@ -121,6 +122,14 @@ def golden_name(role: str) -> str:}.get(role, role)+def ensure_ref(ref: str) -> None:+ """Fail on a ref git cannot resolve, before any golden lookup treats it as new."""+ try:+ run(["git", "rev-parse", "--verify", "--quiet", f"{ref}^{{commit}}"])+ except subprocess.CalledProcessError:+ raise SystemExit(f"--ref {ref} does not resolve to a commit")++def golden_at_ref(ref: str, env: str, role: str) -> str:"""Read the composed golden for (env, role) at `ref`.@@ -141,7 +150,13 @@ def golden_at_ref(ref: str, env: str, role: str) -> str:return run(["git", "show", f"{ref}:{path}"])except subprocess.CalledProcessError:continue- raise SystemExit(f"no golden for {env}/{role} at {ref} (tried current, pre-rename, and legacy layouts)")+ # main() verified the ref, so reaching here means the ref resolves and the path+ # does not: a role this PR introduces, whose baseline is an empty schema.+ sys.stderr.write(+ f"warning: no golden for {env}/{role} at {ref}; treating the role as new "+ f"(empty baseline, so every object plans as a CREATE)\n"+ )+ return ""def write_dump(env: str, roles: list[str], ref: str, dump_dir: str) -> None:@@ -168,6 +183,7 @@ def main() -> None:help="write the next numbered migration into posthog/clickhouse/migrations/ and bump max_migration.txt",)args = ap.parse_args()+ ensure_ref(args.ref)envs_for_role: dict[str, set[str]] = {}env_roles: OrderedDict[str, list[str]] = OrderedDict() # env -> roles, in manifest orderdiff --git a/posthog/clickhouse/hcl/exclude.hcl b/posthog/clickhouse/hcl/exclude.hclindex 43992d3c8d76..7ab1746285fd 100644--- a/posthog/clickhouse/hcl/exclude.hcl+++ b/posthog/clickhouse/hcl/exclude.hcl@@ -38,11 +38,6 @@ exclude {"*_staging","*_backfill",- # --- cross-cluster proxies carried by the node but owned elsewhere ---- # Distributed proxies into the main event cluster; owned by the data role.- "events_main",- "events_recent",-# --- per-customer and adhoc tables on the cloud data clusters ---# A team-numbered table belongs to one customer and is not part of the cluster's# schema. The bare [0-9]* glob catches the numeric-prefixed scratch tables that@@ -81,5 +76,11 @@ exclude {"custom_metrics*",# Orphan: present on prod OPS but no migration or code creates it anywhere."events_team_daily_stats",+ # Cloud infra inventory, created outside this repo and present on a single+ # dev node. Declaring them would put one node's inventory in every dev role.+ "eni_inventory",+ "flow_logs_local",+ "k8s_node_inventory",+ "rds_inventory",]}diff --git a/posthog/clickhouse/hcl/golden/dev/data.hcl b/posthog/clickhouse/hcl/golden/dev/data.hclindex bd46e1e9a6fa..6d65e191933c 100644--- a/posthog/clickhouse/hcl/golden/dev/data.hcl+++ b/posthog/clickhouse/hcl/golden/dev/data.hcl@@ -1190,47 +1190,6 @@ database "posthog" {}}- table "eni_inventory" {- order_by = ["eni_id", "ip_address"]- partition_by = "toYYYYMMDD(collected_at)"- settings = {- index_granularity = "8192"- }- column "collected_at" {- type = "DateTime"- }- column "eni_id" {- type = "String"- }- column "ip_address" {- type = "String"- }- column "owner_account" {- type = "String"- }- column "subnet_id" {- type = "String"- }- column "security_groups" {- type = "Array(JSON)"- }- column "instance_id" {- type = "String"- }- column "node_name" {- type = "String"- }- column "karpenter_nodeclaim" {- type = "String"- }- column "karpenter_ec2nodeclass" {- type = "String"- }- engine "replacing_merge_tree" {- version_column = "collected_at"- }- }-table "error_tracking_fingerprint_issue_state" {column "team_id" {type = "Int64"@@ -1873,52 +1832,6 @@ database "posthog" {}}- table "flow_logs_local" {- order_by = ["ts_start", "dstport", "dstaddr", "interface_id"]- partition_by = "toYYYYMMDD(ts_start)"- settings = {- index_granularity = "8192"- }- column "interface_id" {- type = "String"- }- column "srcaddr" {- type = "String"- }- column "dstaddr" {- type = "String"- }- column "srcport" {- type = "UInt16"- }- column "dstport" {- type = "UInt16"- }- column "protocol" {- type = "UInt8"- }- column "packets" {- type = "UInt32"- }- column "bytes" {- type = "UInt64"- }- column "ts_start" {- type = "DateTime"- }- column "ts_end" {- type = "DateTime"- }- column "action" {- type = "LowCardinality(String)"- }- column "log_status" {- type = "LowCardinality(String)"- }- engine "merge_tree" {- }- }-table "groups" {order_by = ["team_id", "group_type_index", "group_key"]settings = {@@ -2204,44 +2117,6 @@ database "posthog" {}}- table "k8s_node_inventory" {- order_by = ["nodepool", "instance_id"]- partition_by = "toYYYYMMDD(collected_at)"- settings = {- index_granularity = "8192"- }- column "collected_at" {- type = "DateTime"- }- column "node_name" {- type = "String"- }- column "instance_id" {- type = "String"- }- column "region" {- type = "String"- }- column "nodeclaim" {- type = "String"- }- column "nodepool" {- type = "String"- }- column "ec2nodeclass" {- type = "String"- }- column "labels" {- type = "JSON"- }- column "enis" {- type = "Array(JSON)"- }- engine "replacing_merge_tree" {- version_column = "collected_at"- }- }-table "kafka_error_tracking_issue_fingerprint_overrides_ws" {column "team_id" {type = "Int64"@@ -3995,35 +3870,6 @@ database "posthog" {}}- table "rds_inventory" {- order_by = ["region", "instance_name"]- partition_by = "toYYYYMMDD(collected_at)"- settings = {- index_granularity = "8192"- }- column "collected_at" {- type = "DateTime"- }- column "region" {- type = "String"- }- column "instance_name" {- type = "String"- }- column "cluster_name" {- type = "String"- }- column "endpoint" {- type = "String"- }- column "ip_address" {- type = "String"- }- engine "replacing_merge_tree" {- version_column = "collected_at"- }- }-table "session_recording_events" {column "uuid" {type = "UUID"@@ -4139,21 +3985,9 @@ database "posthog" {column "max_last_timestamp" {type = "SimpleAggregateFunction(max, DateTime64(6, 'UTC'))"}- column "block_first_timestamps" {- type = "SimpleAggregateFunction(groupArrayArray, Array(DateTime64(6, 'UTC')))"- }- column "block_last_timestamps" {- type = "SimpleAggregateFunction(groupArrayArray, Array(DateTime64(6, 'UTC')))"- }- column "block_urls" {- type = "SimpleAggregateFunction(groupArrayArray, Array(String))"- }column "first_url" {type = "AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC'))"}- column "all_urls" {- type = "SimpleAggregateFunction(groupUniqArrayArray, Array(String))"- }column "click_count" {type = "SimpleAggregateFunction(sum, Int64)"}@@ -4184,14 +4018,29 @@ database "posthog" {column "event_count" {type = "SimpleAggregateFunction(sum, Int64)"}+ column "_timestamp" {+ type = "SimpleAggregateFunction(max, DateTime)"+ }column "snapshot_source" {type = "AggregateFunction(argMin, LowCardinality(Nullable(String)), DateTime64(6, 'UTC'))"}+ column "all_urls" {+ type = "SimpleAggregateFunction(groupUniqArrayArray, Array(String))"+ }column "snapshot_library" {type = "AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC'))"}- column "_timestamp" {- type = "SimpleAggregateFunction(max, DateTime)"+ column "block_first_timestamps" {+ type = "SimpleAggregateFunction(groupArrayArray, Array(DateTime64(6, 'UTC')))"+ }+ column "block_last_timestamps" {+ type = "SimpleAggregateFunction(groupArrayArray, Array(DateTime64(6, 'UTC')))"+ }+ column "block_urls" {+ type = "SimpleAggregateFunction(groupArrayArray, Array(String))"+ }+ column "retention_period_days" {+ type = "SimpleAggregateFunction(max, Nullable(Int64))"}column "is_deleted" {type = "SimpleAggregateFunction(max, UInt8)"@@ -4210,9 +4059,6 @@ database "posthog" {column "surfacing_score" {type = "SimpleAggregateFunction(max, Nullable(Float32))"}- column "retention_period_days" {- type = "SimpleAggregateFunction(max, Nullable(Int64))"- }column "snapshot_mode" {type = "AggregateFunction(argMin, LowCardinality(Nullable(String)), DateTime64(6, 'UTC'))"}@@ -6646,21 +6492,9 @@ database "posthog" {column "max_last_timestamp" {type = "SimpleAggregateFunction(max, DateTime64(6, 'UTC'))"}- column "block_first_timestamps" {- type = "SimpleAggregateFunction(groupArrayArray, Array(DateTime64(6, 'UTC')))"- }- column "block_last_timestamps" {- type = "SimpleAggregateFunction(groupArrayArray, Array(DateTime64(6, 'UTC')))"- }- column "block_urls" {- type = "SimpleAggregateFunction(groupArrayArray, Array(String))"- }column "first_url" {type = "AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC'))"}- column "all_urls" {- type = "SimpleAggregateFunction(groupUniqArrayArray, Array(String))"- }column "click_count" {type = "SimpleAggregateFunction(sum, Int64)"}@@ -6691,14 +6525,29 @@ database "posthog" {column "event_count" {type = "SimpleAggregateFunction(sum, Int64)"}+ column "_timestamp" {+ type = "SimpleAggregateFunction(max, DateTime)"+ }column "snapshot_source" {type = "AggregateFunction(argMin, LowCardinality(Nullable(String)), DateTime64(6, 'UTC'))"}+ column "all_urls" {+ type = "SimpleAggregateFunction(groupUniqArrayArray, Array(String))"+ }column "snapshot_library" {type = "AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC'))"}- column "_timestamp" {- type = "SimpleAggregateFunction(max, DateTime)"+ column "block_first_timestamps" {+ type = "SimpleAggregateFunction(groupArrayArray, Array(DateTime64(6, 'UTC')))"+ }+ column "block_last_timestamps" {+ type = "SimpleAggregateFunction(groupArrayArray, Array(DateTime64(6, 'UTC')))"+ }+ column "block_urls" {+ type = "SimpleAggregateFunction(groupArrayArray, Array(String))"+ }+ column "retention_period_days" {+ type = "SimpleAggregateFunction(max, Nullable(Int64))"}column "is_deleted" {type = "SimpleAggregateFunction(max, UInt8)"@@ -6717,9 +6566,6 @@ database "posthog" {column "surfacing_score" {type = "SimpleAggregateFunction(max, Nullable(Float32))"}- column "retention_period_days" {- type = "SimpleAggregateFunction(max, Nullable(Int64))"- }column "snapshot_mode" {type = "AggregateFunction(argMin, LowCardinality(Nullable(String)), DateTime64(6, 'UTC'))"}diff --git a/posthog/clickhouse/hcl/golden/local-multi/data.hcl b/posthog/clickhouse/hcl/golden/local-multi/data.hclindex 3f26bd3fd997..5ccd7ef04d29 100644--- a/posthog/clickhouse/hcl/golden/local-multi/data.hcl+++ b/posthog/clickhouse/hcl/golden/local-multi/data.hcl@@ -4583,21 +4583,9 @@ database "posthog" {column "max_last_timestamp" {type = "SimpleAggregateFunction(max, DateTime64(6, 'UTC'))"}- column "block_first_timestamps" {- type = "SimpleAggregateFunction(groupArrayArray, Array(DateTime64(6, 'UTC')))"- }- column "block_last_timestamps" {- type = "SimpleAggregateFunction(groupArrayArray, Array(DateTime64(6, 'UTC')))"- }- column "block_urls" {- type = "SimpleAggregateFunction(groupArrayArray, Array(String))"- }column "first_url" {type = "AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC'))"}- column "all_urls" {- type = "SimpleAggregateFunction(groupUniqArrayArray, Array(String))"- }column "click_count" {type = "SimpleAggregateFunction(sum, Int64)"}@@ -4628,14 +4616,29 @@ database "posthog" {column "event_count" {type = "SimpleAggregateFunction(sum, Int64)"}+ column "_timestamp" {+ type = "SimpleAggregateFunction(max, DateTime)"+ }column "snapshot_source" {type = "AggregateFunction(argMin, LowCardinality(Nullable(String)), DateTime64(6, 'UTC'))"}+ column "all_urls" {+ type = "SimpleAggregateFunction(groupUniqArrayArray, Array(String))"+ }column "snapshot_library" {type = "AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC'))"}- column "_timestamp" {- type = "SimpleAggregateFunction(max, DateTime)"+ column "block_first_timestamps" {+ type = "SimpleAggregateFunction(groupArrayArray, Array(DateTime64(6, 'UTC')))"+ }+ column "block_last_timestamps" {+ type = "SimpleAggregateFunction(groupArrayArray, Array(DateTime64(6, 'UTC')))"+ }+ column "block_urls" {+ type = "SimpleAggregateFunction(groupArrayArray, Array(String))"+ }+ column "retention_period_days" {+ type = "SimpleAggregateFunction(max, Nullable(Int64))"}column "is_deleted" {type = "SimpleAggregateFunction(max, UInt8)"@@ -4654,9 +4657,6 @@ database "posthog" {column "surfacing_score" {type = "SimpleAggregateFunction(max, Nullable(Float32))"}- column "retention_period_days" {- type = "SimpleAggregateFunction(max, Nullable(Int64))"- }column "snapshot_mode" {type = "AggregateFunction(argMin, LowCardinality(Nullable(String)), DateTime64(6, 'UTC'))"}@@ -7723,21 +7723,9 @@ database "posthog" {column "max_last_timestamp" {type = "SimpleAggregateFunction(max, DateTime64(6, 'UTC'))"}- column "block_first_timestamps" {- type = "SimpleAggregateFunction(groupArrayArray, Array(DateTime64(6, 'UTC')))"- }- column "block_last_timestamps" {- type = "SimpleAggregateFunction(groupArrayArray, Array(DateTime64(6, 'UTC')))"- }- column "block_urls" {- type = "SimpleAggregateFunction(groupArrayArray, Array(String))"- }column "first_url" {type = "AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC'))"}- column "all_urls" {- type = "SimpleAggregateFunction(groupUniqArrayArray, Array(String))"- }column "click_count" {type = "SimpleAggregateFunction(sum, Int64)"}@@ -7768,14 +7756,29 @@ database "posthog" {column "event_count" {type = "SimpleAggregateFunction(sum, Int64)"}+ column "_timestamp" {+ type = "SimpleAggregateFunction(max, DateTime)"+ }column "snapshot_source" {type = "AggregateFunction(argMin, LowCardinality(Nullable(String)), DateTime64(6, 'UTC'))"}+ column "all_urls" {+ type = "SimpleAggregateFunction(groupUniqArrayArray, Array(String))"+ }column "snapshot_library" {type = "AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC'))"}- column "_timestamp" {- type = "SimpleAggregateFunction(max, DateTime)"+ column "block_first_timestamps" {+ type = "SimpleAggregateFunction(groupArrayArray, Array(DateTime64(6, 'UTC')))"+ }+ column "block_last_timestamps" {+ type = "SimpleAggregateFunction(groupArrayArray, Array(DateTime64(6, 'UTC')))"+ }+ column "block_urls" {+ type = "SimpleAggregateFunction(groupArrayArray, Array(String))"+ }+ column "retention_period_days" {+ type = "SimpleAggregateFunction(max, Nullable(Int64))"}column "is_deleted" {type = "SimpleAggregateFunction(max, UInt8)"@@ -7794,9 +7797,6 @@ database "posthog" {column "surfacing_score" {type = "SimpleAggregateFunction(max, Nullable(Float32))"}- column "retention_period_days" {- type = "SimpleAggregateFunction(max, Nullable(Int64))"- }column "snapshot_mode" {type = "AggregateFunction(argMin, LowCardinality(Nullable(String)), DateTime64(6, 'UTC'))"}diff --git a/posthog/clickhouse/hcl/golden/local-single/all.hcl b/posthog/clickhouse/hcl/golden/local-single/all.hclindex e8ce34b15585..8b09318c7d28 100644--- a/posthog/clickhouse/hcl/golden/local-single/all.hcl+++ b/posthog/clickhouse/hcl/golden/local-single/all.hcl@@ -9315,21 +9315,9 @@ SQLcolumn "max_last_timestamp" {type = "SimpleAggregateFunction(max, DateTime64(6, 'UTC'))"}- column "block_first_timestamps" {- type = "SimpleAggregateFunction(groupArrayArray, Array(DateTime64(6, 'UTC')))"- }- column "block_last_timestamps" {- type = "SimpleAggregateFunction(groupArrayArray, Array(DateTime64(6, 'UTC')))"- }- column "block_urls" {- type = "SimpleAggregateFunction(groupArrayArray, Array(String))"- }column "first_url" {type = "AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC'))"}- column "all_urls" {- type = "SimpleAggregateFunction(groupUniqArrayArray, Array(String))"- }column "click_count" {type = "SimpleAggregateFunction(sum, Int64)"}@@ -9360,14 +9348,29 @@ SQLcolumn "event_count" {type = "SimpleAggregateFunction(sum, Int64)"}+ column "_timestamp" {+ type = "SimpleAggregateFunction(max, DateTime)"+ }column "snapshot_source" {type = "AggregateFunction(argMin, LowCardinality(Nullable(String)), DateTime64(6, 'UTC'))"}+ column "all_urls" {+ type = "SimpleAggregateFunction(groupUniqArrayArray, Array(String))"+ }column "snapshot_library" {type = "AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC'))"}- column "_timestamp" {- type = "SimpleAggregateFunction(max, DateTime)"+ column "block_first_timestamps" {+ type = "SimpleAggregateFunction(groupArrayArray, Array(DateTime64(6, 'UTC')))"+ }+ column "block_last_timestamps" {+ type = "SimpleAggregateFunction(groupArrayArray, Array(DateTime64(6, 'UTC')))"+ }+ column "block_urls" {+ type = "SimpleAggregateFunction(groupArrayArray, Array(String))"+ }+ column "retention_period_days" {+ type = "SimpleAggregateFunction(max, Nullable(Int64))"}column "is_deleted" {type = "SimpleAggregateFunction(max, UInt8)"@@ -9386,9 +9389,6 @@ SQLcolumn "surfacing_score" {type = "SimpleAggregateFunction(max, Nullable(Float32))"}- column "retention_period_days" {- type = "SimpleAggregateFunction(max, Nullable(Int64))"- }column "snapshot_mode" {type = "AggregateFunction(argMin, LowCardinality(Nullable(String)), DateTime64(6, 'UTC'))"}@@ -13435,21 +13435,9 @@ SQLcolumn "max_last_timestamp" {type = "SimpleAggregateFunction(max, DateTime64(6, 'UTC'))"}- column "block_first_timestamps" {- type = "SimpleAggregateFunction(groupArrayArray, Array(DateTime64(6, 'UTC')))"- }- column "block_last_timestamps" {- type = "SimpleAggregateFunction(groupArrayArray, Array(DateTime64(6, 'UTC')))"- }- column "block_urls" {- type = "SimpleAggregateFunction(groupArrayArray, Array(String))"- }column "first_url" {type = "AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC'))"}- column "all_urls" {- type = "SimpleAggregateFunction(groupUniqArrayArray, Array(String))"- }column "click_count" {type = "SimpleAggregateFunction(sum, Int64)"}@@ -13480,14 +13468,29 @@ SQLcolumn "event_count" {type = "SimpleAggregateFunction(sum, Int64)"}+ column "_timestamp" {+ type = "SimpleAggregateFunction(max, DateTime)"+ }column "snapshot_source" {type = "AggregateFunction(argMin, LowCardinality(Nullable(String)), DateTime64(6, 'UTC'))"}+ column "all_urls" {+ type = "SimpleAggregateFunction(groupUniqArrayArray, Array(String))"+ }column "snapshot_library" {type = "AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC'))"}- column "_timestamp" {- type = "SimpleAggregateFunction(max, DateTime)"+ column "block_first_timestamps" {+ type = "SimpleAggregateFunction(groupArrayArray, Array(DateTime64(6, 'UTC')))"+ }+ column "block_last_timestamps" {+ type = "SimpleAggregateFunction(groupArrayArray, Array(DateTime64(6, 'UTC')))"+ }+ column "block_urls" {+ type = "SimpleAggregateFunction(groupArrayArray, Array(String))"+ }+ column "retention_period_days" {+ type = "SimpleAggregateFunction(max, Nullable(Int64))"}column "is_deleted" {type = "SimpleAggregateFunction(max, UInt8)"@@ -13506,9 +13509,6 @@ SQLcolumn "surfacing_score" {type = "SimpleAggregateFunction(max, Nullable(Float32))"}- column "retention_period_days" {- type = "SimpleAggregateFunction(max, Nullable(Int64))"- }column "snapshot_mode" {type = "AggregateFunction(argMin, LowCardinality(Nullable(String)), DateTime64(6, 'UTC'))"}diff --git a/posthog/clickhouse/hcl/golden/prod-eu/data.hcl b/posthog/clickhouse/hcl/golden/prod-eu/data.hclindex abef8c2c5af3..28fb1402a540 100644--- a/posthog/clickhouse/hcl/golden/prod-eu/data.hcl+++ b/posthog/clickhouse/hcl/golden/prod-eu/data.hcl@@ -4630,21 +4630,9 @@ database "posthog" {column "max_last_timestamp" {type = "SimpleAggregateFunction(max, DateTime64(6, 'UTC'))"}- column "block_first_timestamps" {- type = "SimpleAggregateFunction(groupArrayArray, Array(DateTime64(6, 'UTC')))"- }- column "block_last_timestamps" {- type = "SimpleAggregateFunction(groupArrayArray, Array(DateTime64(6, 'UTC')))"- }- column "block_urls" {- type = "SimpleAggregateFunction(groupArrayArray, Array(String))"- }column "first_url" {type = "AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC'))"}- column "all_urls" {- type = "SimpleAggregateFunction(groupUniqArrayArray, Array(String))"- }column "click_count" {type = "SimpleAggregateFunction(sum, Int64)"}@@ -4675,14 +4663,29 @@ database "posthog" {column "event_count" {type = "SimpleAggregateFunction(sum, Int64)"}+ column "_timestamp" {+ type = "SimpleAggregateFunction(max, DateTime)"+ }column "snapshot_source" {type = "AggregateFunction(argMin, LowCardinality(Nullable(String)), DateTime64(6, 'UTC'))"}+ column "all_urls" {+ type = "SimpleAggregateFunction(groupUniqArrayArray, Array(String))"+ }column "snapshot_library" {type = "AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC'))"}- column "_timestamp" {- type = "SimpleAggregateFunction(max, DateTime)"+ column "block_first_timestamps" {+ type = "SimpleAggregateFunction(groupArrayArray, Array(DateTime64(6, 'UTC')))"+ }+ column "block_last_timestamps" {+ type = "SimpleAggregateFunction(groupArrayArray, Array(DateTime64(6, 'UTC')))"+ }+ column "block_urls" {+ type = "SimpleAggregateFunction(groupArrayArray, Array(String))"+ }+ column "retention_period_days" {+ type = "SimpleAggregateFunction(max, Nullable(Int64))"}column "is_deleted" {type = "SimpleAggregateFunction(max, UInt8)"@@ -4701,9 +4704,6 @@ database "posthog" {column "surfacing_score" {type = "SimpleAggregateFunction(max, Nullable(Float32))"}- column "retention_period_days" {- type = "SimpleAggregateFunction(max, Nullable(Int64))"- }column "snapshot_mode" {type = "AggregateFunction(argMin, LowCardinality(Nullable(String)), DateTime64(6, 'UTC'))"}@@ -6490,21 +6490,9 @@ database "posthog" {column "max_last_timestamp" {type = "SimpleAggregateFunction(max, DateTime64(6, 'UTC'))"}- column "block_first_timestamps" {- type = "SimpleAggregateFunction(groupArrayArray, Array(DateTime64(6, 'UTC')))"- }- column "block_last_timestamps" {- type = "SimpleAggregateFunction(groupArrayArray, Array(DateTime64(6, 'UTC')))"- }- column "block_urls" {- type = "SimpleAggregateFunction(groupArrayArray, Array(String))"- }column "first_url" {type = "AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC'))"}- column "all_urls" {- type = "SimpleAggregateFunction(groupUniqArrayArray, Array(String))"- }column "click_count" {type = "SimpleAggregateFunction(sum, Int64)"}@@ -6535,14 +6523,29 @@ database "posthog" {column "event_count" {type = "SimpleAggregateFunction(sum, Int64)"}+ column "_timestamp" {+ type = "SimpleAggregateFunction(max, DateTime)"+ }column "snapshot_source" {type = "AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC'))"}+ column "all_urls" {+ type = "SimpleAggregateFunction(groupUniqArrayArray, Array(String))"+ }column "snapshot_library" {type = "AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC'))"}- column "_timestamp" {- type = "SimpleAggregateFunction(max, DateTime)"+ column "block_first_timestamps" {+ type = "SimpleAggregateFunction(groupArrayArray, Array(DateTime64(6, 'UTC')))"+ }+ column "block_last_timestamps" {+ type = "SimpleAggregateFunction(groupArrayArray, Array(DateTime64(6, 'UTC')))"+ }+ column "block_urls" {+ type = "SimpleAggregateFunction(groupArrayArray, Array(String))"+ }+ column "retention_period_days" {+ type = "SimpleAggregateFunction(max, Nullable(Int64))"}column "is_deleted" {type = "SimpleAggregateFunction(max, UInt8)"@@ -6561,9 +6564,6 @@ database "posthog" {column "surfacing_score" {type = "SimpleAggregateFunction(max, Nullable(Float32))"}- column "retention_period_days" {- type = "SimpleAggregateFunction(max, Nullable(Int64))"- }column "snapshot_mode" {type = "AggregateFunction(argMin, LowCardinality(Nullable(String)), DateTime64(6, 'UTC'))"}diff --git a/posthog/clickhouse/hcl/golden/prod-eu/sessions.hcl b/posthog/clickhouse/hcl/golden/prod-eu/sessions.hclindex 5f476c0f91de..51bb00c74530 100644--- a/posthog/clickhouse/hcl/golden/prod-eu/sessions.hcl+++ b/posthog/clickhouse/hcl/golden/prod-eu/sessions.hcl@@ -267,10 +267,6 @@ database "posthog" {type = "Nullable(String)"comment = "column_materializer::properties::$ai_prompt_name"}- column "mat_$ai_experiment_id" {- type = "Nullable(String)"- comment = "column_materializer::properties::$ai_experiment_id"- }engine "distributed" {cluster_name = "posthog"remote_database = "posthog"diff --git a/posthog/clickhouse/hcl/golden/prod-us/data.hcl b/posthog/clickhouse/hcl/golden/prod-us/data.hclindex 2186f2572cf6..21fae7729254 100644--- a/posthog/clickhouse/hcl/golden/prod-us/data.hcl+++ b/posthog/clickhouse/hcl/golden/prod-us/data.hcl@@ -4425,21 +4425,9 @@ database "posthog" {column "max_last_timestamp" {type = "SimpleAggregateFunction(max, DateTime64(6, 'UTC'))"}- column "block_first_timestamps" {- type = "SimpleAggregateFunction(groupArrayArray, Array(DateTime64(6, 'UTC')))"- }- column "block_last_timestamps" {- type = "SimpleAggregateFunction(groupArrayArray, Array(DateTime64(6, 'UTC')))"- }- column "block_urls" {- type = "SimpleAggregateFunction(groupArrayArray, Array(String))"- }column "first_url" {type = "AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC'))"}- column "all_urls" {- type = "SimpleAggregateFunction(groupUniqArrayArray, Array(String))"- }column "click_count" {type = "SimpleAggregateFunction(sum, Int64)"}@@ -4470,14 +4458,29 @@ database "posthog" {column "event_count" {type = "SimpleAggregateFunction(sum, Int64)"}+ column "_timestamp" {+ type = "SimpleAggregateFunction(max, DateTime)"+ }column "snapshot_source" {type = "AggregateFunction(argMin, LowCardinality(Nullable(String)), DateTime64(6, 'UTC'))"}+ column "all_urls" {+ type = "SimpleAggregateFunction(groupUniqArrayArray, Array(String))"+ }column "snapshot_library" {type = "AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC'))"}- column "_timestamp" {- type = "SimpleAggregateFunction(max, DateTime)"+ column "block_first_timestamps" {+ type = "SimpleAggregateFunction(groupArrayArray, Array(DateTime64(6, 'UTC')))"+ }+ column "block_last_timestamps" {+ type = "SimpleAggregateFunction(groupArrayArray, Array(DateTime64(6, 'UTC')))"+ }+ column "block_urls" {+ type = "SimpleAggregateFunction(groupArrayArray, Array(String))"+ }+ column "retention_period_days" {+ type = "SimpleAggregateFunction(max, Nullable(Int64))"}column "is_deleted" {type = "SimpleAggregateFunction(max, UInt8)"@@ -4496,9 +4499,6 @@ database "posthog" {column "surfacing_score" {type = "SimpleAggregateFunction(max, Nullable(Float32))"}- column "retention_period_days" {- type = "SimpleAggregateFunction(max, Nullable(Int64))"- }column "snapshot_mode" {type = "AggregateFunction(argMin, LowCardinality(Nullable(String)), DateTime64(6, 'UTC'))"}@@ -6252,21 +6252,9 @@ database "posthog" {column "max_last_timestamp" {type = "SimpleAggregateFunction(max, DateTime64(6, 'UTC'))"}- column "block_first_timestamps" {- type = "SimpleAggregateFunction(groupArrayArray, Array(DateTime64(6, 'UTC')))"- }- column "block_last_timestamps" {- type = "SimpleAggregateFunction(groupArrayArray, Array(DateTime64(6, 'UTC')))"- }- column "block_urls" {- type = "SimpleAggregateFunction(groupArrayArray, Array(String))"- }column "first_url" {type = "AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC'))"}- column "all_urls" {- type = "SimpleAggregateFunction(groupUniqArrayArray, Array(String))"- }column "click_count" {type = "SimpleAggregateFunction(sum, Int64)"}@@ -6297,14 +6285,29 @@ database "posthog" {column "event_count" {type = "SimpleAggregateFunction(sum, Int64)"}+ column "_timestamp" {+ type = "SimpleAggregateFunction(max, DateTime)"+ }column "snapshot_source" {type = "AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC'))"}+ column "all_urls" {+ type = "SimpleAggregateFunction(groupUniqArrayArray, Array(String))"+ }column "snapshot_library" {type = "AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC'))"}- column "_timestamp" {- type = "SimpleAggregateFunction(max, DateTime)"+ column "block_first_timestamps" {+ type = "SimpleAggregateFunction(groupArrayArray, Array(DateTime64(6, 'UTC')))"+ }+ column "block_last_timestamps" {+ type = "SimpleAggregateFunction(groupArrayArray, Array(DateTime64(6, 'UTC')))"+ }+ column "block_urls" {+ type = "SimpleAggregateFunction(groupArrayArray, Array(String))"+ }+ column "retention_period_days" {+ type = "SimpleAggregateFunction(max, Nullable(Int64))"}column "is_deleted" {type = "SimpleAggregateFunction(max, UInt8)"@@ -6323,9 +6326,6 @@ database "posthog" {column "surfacing_score" {type = "SimpleAggregateFunction(max, Nullable(Float32))"}- column "retention_period_days" {- type = "SimpleAggregateFunction(max, Nullable(Int64))"- }column "snapshot_mode" {type = "AggregateFunction(argMin, LowCardinality(Nullable(String)), DateTime64(6, 'UTC'))"}diff --git a/posthog/clickhouse/hcl/migration.md b/posthog/clickhouse/hcl/migration.mdindex d8b696cc756d..7e0f1d53d720 100644--- a/posthog/clickhouse/hcl/migration.md+++ b/posthog/clickhouse/hcl/migration.md@@ -150,7 +150,7 @@ Full implementation plan: `docs/plans/2026-07-14-hcl-recreate.md`.## Deployment1. local and schema changes to base are done in PostHog/posthog, this is also what all tests run against-2. a PR in PostHog/posthog triggers a compose check in posthog-cloud-infra validating the changes still compose under the prod overrides — the `cloud-compose-gate` job in `ci-clickhouse-hcl-schema.yml` dispatches cloud-infra's `ci-clickhouse-hcl-compose-gate.yaml` against the PR head; it asserts composability, not cloud goldens+2. a PR in PostHog/posthog triggers a compose check in posthog-cloud-infra validating the changes still compose under the prod overrides — the `cloud-compose-gate` job in `ci-clickhouse-hcl-schema.yml` dispatches cloud-infra's `ci-clickhouse-hcl-compose-gate.yaml` against the PR's merge commit; it asserts composability, not cloud goldens3. the cloud schema is composed as base + customizations in posthog-cloud-infra4. when a PR is merged in PostHog/posthog, a base-ref bump PR in posthog-cloud-infra advances the pinned base sha, regenerates the cloud goldens, and generates the full ordered list of SQL queries that will be executed as part of migration (creation of that PR is to be automated)5. after approval, the PR is merged and a migrator executes a migrationdiff --git a/posthog/clickhouse/hcl/roles/data/common/shared_declarations.hcl b/posthog/clickhouse/hcl/roles/data/common/shared_declarations.hclindex a5bfa1587dfb..f8f8b36390c7 100644--- a/posthog/clickhouse/hcl/roles/data/common/shared_declarations.hcl+++ b/posthog/clickhouse/hcl/roles/data/common/shared_declarations.hcl@@ -1095,21 +1095,9 @@ SQLcolumn "max_last_timestamp" {type = "SimpleAggregateFunction(max, DateTime64(6, 'UTC'))"}- column "block_first_timestamps" {- type = "SimpleAggregateFunction(groupArrayArray, Array(DateTime64(6, 'UTC')))"- }- column "block_last_timestamps" {- type = "SimpleAggregateFunction(groupArrayArray, Array(DateTime64(6, 'UTC')))"- }- column "block_urls" {- type = "SimpleAggregateFunction(groupArrayArray, Array(String))"- }column "first_url" {type = "AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC'))"}- column "all_urls" {- type = "SimpleAggregateFunction(groupUniqArrayArray, Array(String))"- }column "click_count" {type = "SimpleAggregateFunction(sum, Int64)"}@@ -1140,14 +1128,29 @@ SQLcolumn "event_count" {type = "SimpleAggregateFunction(sum, Int64)"}+ column "_timestamp" {+ type = "SimpleAggregateFunction(max, DateTime)"+ }column "snapshot_source" {type = "AggregateFunction(argMin, LowCardinality(Nullable(String)), DateTime64(6, 'UTC'))"}+ column "all_urls" {+ type = "SimpleAggregateFunction(groupUniqArrayArray, Array(String))"+ }column "snapshot_library" {type = "AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC'))"}- column "_timestamp" {- type = "SimpleAggregateFunction(max, DateTime)"+ column "block_first_timestamps" {+ type = "SimpleAggregateFunction(groupArrayArray, Array(DateTime64(6, 'UTC')))"+ }+ column "block_last_timestamps" {+ type = "SimpleAggregateFunction(groupArrayArray, Array(DateTime64(6, 'UTC')))"+ }+ column "block_urls" {+ type = "SimpleAggregateFunction(groupArrayArray, Array(String))"+ }+ column "retention_period_days" {+ type = "SimpleAggregateFunction(max, Nullable(Int64))"}column "is_deleted" {type = "SimpleAggregateFunction(max, UInt8)"@@ -1166,9 +1169,6 @@ SQLcolumn "surfacing_score" {type = "SimpleAggregateFunction(max, Nullable(Float32))"}- column "retention_period_days" {- type = "SimpleAggregateFunction(max, Nullable(Int64))"- }column "snapshot_mode" {type = "AggregateFunction(argMin, LowCardinality(Nullable(String)), DateTime64(6, 'UTC'))"}@@ -1407,11 +1407,6 @@ SQL}table "sharded_session_replay_events" {- order_by = ["toDate(min_first_timestamp)", "team_id", "session_id"]- partition_by = "toYYYYMM(min_first_timestamp)"- settings = {- index_granularity = "512"- }column "session_id" {type = "String"}@@ -1427,21 +1422,9 @@ SQLcolumn "max_last_timestamp" {type = "SimpleAggregateFunction(max, DateTime64(6, 'UTC'))"}- column "block_first_timestamps" {- type = "SimpleAggregateFunction(groupArrayArray, Array(DateTime64(6, 'UTC')))"- }- column "block_last_timestamps" {- type = "SimpleAggregateFunction(groupArrayArray, Array(DateTime64(6, 'UTC')))"- }- column "block_urls" {- type = "SimpleAggregateFunction(groupArrayArray, Array(String))"- }column "first_url" {type = "AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC'))"}- column "all_urls" {- type = "SimpleAggregateFunction(groupUniqArrayArray, Array(String))"- }column "click_count" {type = "SimpleAggregateFunction(sum, Int64)"}@@ -1472,14 +1455,29 @@ SQLcolumn "event_count" {type = "SimpleAggregateFunction(sum, Int64)"}+ column "_timestamp" {+ type = "SimpleAggregateFunction(max, DateTime)"+ }column "snapshot_source" {type = "AggregateFunction(argMin, LowCardinality(Nullable(String)), DateTime64(6, 'UTC'))"}+ column "all_urls" {+ type = "SimpleAggregateFunction(groupUniqArrayArray, Array(String))"+ }column "snapshot_library" {type = "AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC'))"}- column "_timestamp" {- type = "SimpleAggregateFunction(max, DateTime)"+ column "block_first_timestamps" {+ type = "SimpleAggregateFunction(groupArrayArray, Array(DateTime64(6, 'UTC')))"+ }+ column "block_last_timestamps" {+ type = "SimpleAggregateFunction(groupArrayArray, Array(DateTime64(6, 'UTC')))"+ }+ column "block_urls" {+ type = "SimpleAggregateFunction(groupArrayArray, Array(String))"+ }+ column "retention_period_days" {+ type = "SimpleAggregateFunction(max, Nullable(Int64))"}column "is_deleted" {type = "SimpleAggregateFunction(max, UInt8)"@@ -1498,12 +1496,14 @@ SQLcolumn "surfacing_score" {type = "SimpleAggregateFunction(max, Nullable(Float32))"}- column "retention_period_days" {- type = "SimpleAggregateFunction(max, Nullable(Int64))"- }column "snapshot_mode" {type = "AggregateFunction(argMin, LowCardinality(Nullable(String)), DateTime64(6, 'UTC'))"}+ order_by = ["toDate(min_first_timestamp)", "team_id", "session_id"]+ partition_by = "toYYYYMM(min_first_timestamp)"+ settings = {+ index_granularity = "512"+ }engine "replicated_aggregating_merge_tree" {zoo_path = "/clickhouse/tables/{shard}/posthog.session_replay_events"replica_name = "{replica}"diff --git a/posthog/clickhouse/hcl/roles/data/dev/tables.hcl b/posthog/clickhouse/hcl/roles/data/dev/tables.hclindex 7d5a6ecfe1cf..6e5bc9b63dda 100644--- a/posthog/clickhouse/hcl/roles/data/dev/tables.hcl+++ b/posthog/clickhouse/hcl/roles/data/dev/tables.hcl@@ -100,93 +100,6 @@ database "posthog" {}}- table "eni_inventory" {- order_by = ["eni_id", "ip_address"]- partition_by = "toYYYYMMDD(collected_at)"- settings = {- index_granularity = "8192"- }- column "collected_at" {- type = "DateTime"- }- column "eni_id" {- type = "String"- }- column "ip_address" {- type = "String"- }- column "owner_account" {- type = "String"- }- column "subnet_id" {- type = "String"- }- column "security_groups" {- type = "Array(JSON)"- }- column "instance_id" {- type = "String"- }- column "node_name" {- type = "String"- }- column "karpenter_nodeclaim" {- type = "String"- }- column "karpenter_ec2nodeclass" {- type = "String"- }- engine "replacing_merge_tree" {- version_column = "collected_at"- }- }-- table "flow_logs_local" {- order_by = ["ts_start", "dstport", "dstaddr", "interface_id"]- partition_by = "toYYYYMMDD(ts_start)"- settings = {- index_granularity = "8192"- }- column "interface_id" {- type = "String"- }- column "srcaddr" {- type = "String"- }- column "dstaddr" {- type = "String"- }- column "srcport" {- type = "UInt16"- }- column "dstport" {- type = "UInt16"- }- column "protocol" {- type = "UInt8"- }- column "packets" {- type = "UInt32"- }- column "bytes" {- type = "UInt64"- }- column "ts_start" {- type = "DateTime"- }- column "ts_end" {- type = "DateTime"- }- column "action" {- type = "LowCardinality(String)"- }- column "log_status" {- type = "LowCardinality(String)"- }- engine "merge_tree" {- }- }-table "groups2" {order_by = ["group_key"]settings = {@@ -204,44 +117,6 @@ database "posthog" {}}- table "k8s_node_inventory" {- order_by = ["nodepool", "instance_id"]- partition_by = "toYYYYMMDD(collected_at)"- settings = {- index_granularity = "8192"- }- column "collected_at" {- type = "DateTime"- }- column "node_name" {- type = "String"- }- column "instance_id" {- type = "String"- }- column "region" {- type = "String"- }- column "nodeclaim" {- type = "String"- }- column "nodepool" {- type = "String"- }- column "ec2nodeclass" {- type = "String"- }- column "labels" {- type = "JSON"- }- column "enis" {- type = "Array(JSON)"- }- engine "replacing_merge_tree" {- version_column = "collected_at"- }- }-table "kafka_error_tracking_issue_fingerprint_overrides_ws" {column "team_id" {type = "Int64"@@ -478,35 +353,6 @@ database "posthog" {}}- table "rds_inventory" {- order_by = ["region", "instance_name"]- partition_by = "toYYYYMMDD(collected_at)"- settings = {- index_granularity = "8192"- }- column "collected_at" {- type = "DateTime"- }- column "region" {- type = "String"- }- column "instance_name" {- type = "String"- }- column "cluster_name" {- type = "String"- }- column "endpoint" {- type = "String"- }- column "ip_address" {- type = "String"- }- engine "replacing_merge_tree" {- version_column = "collected_at"- }- }-table "sharded_app_metrics" {override = trueorder_by = ["team_id", "plugin_config_id", "job_id", "category", "toStartOfHour(timestamp)", "error_type", "error_uuid"]diff --git a/posthog/clickhouse/hcl/roles/sessions/prod-eu/tables.hcl b/posthog/clickhouse/hcl/roles/sessions/prod-eu/tables.hclindex 99ab55ffd13b..833c2c97e68d 100644--- a/posthog/clickhouse/hcl/roles/sessions/prod-eu/tables.hcl+++ b/posthog/clickhouse/hcl/roles/sessions/prod-eu/tables.hcl@@ -22,12 +22,4 @@ database "posthog" {remote_table = "channel_definition"}}- # prod-eu materializes eight properties prod-us does not.- patch_table "events" {- column "mat_$ai_experiment_id" {- type = "Nullable(String)"- comment = "column_materializer::properties::$ai_experiment_id"- after = "mat_$ai_prompt_name"- }- }}diff --git a/posthog/clickhouse/hcl/roles/sessions/shared/tables.hcl b/posthog/clickhouse/hcl/roles/sessions/shared/tables.hclindex f009bbe506b3..c75cba8f6963 100644--- a/posthog/clickhouse/hcl/roles/sessions/shared/tables.hcl+++ b/posthog/clickhouse/hcl/roles/sessions/shared/tables.hcl@@ -1,12 +1,5 @@database "posthog" {table "raw_sessions" {- override = true- order_by = ["team_id", "toStartOfHour(fromUnixTimestamp(intDiv(toUInt64(bitShiftRight(session_id_v7, 80)), 1000)))", "cityHash64(session_id_v7)", "session_id_v7"]- partition_by = "toYYYYMM(fromUnixTimestamp(intDiv(toUInt64(bitShiftRight(session_id_v7, 80)), 1000)))"- sample_by = "cityHash64(session_id_v7)"- settings = {- index_granularity = "8192"- }column "team_id" {type = "Int64"}@@ -163,6 +156,13 @@ database "posthog" {column "initial__kx" {type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"}+ override = true+ order_by = ["team_id", "toStartOfHour(fromUnixTimestamp(intDiv(toUInt64(bitShiftRight(session_id_v7, 80)), 1000)))", "cityHash64(session_id_v7)", "session_id_v7"]+ partition_by = "toYYYYMM(fromUnixTimestamp(intDiv(toUInt64(bitShiftRight(session_id_v7, 80)), 1000)))"+ sample_by = "cityHash64(session_id_v7)"+ settings = {+ index_granularity = "8192"+ }engine "replicated_aggregating_merge_tree" {zoo_path = "/clickhouse/tables/sessions/noshard/posthog.raw_sessions"replica_name = "{shard}-{replica}"diff --git a/posthog/clickhouse/hcl/sql/dev/data.sql b/posthog/clickhouse/hcl/sql/dev/data.sqlindex 30c19e921b08..476b2ba89d35 100644--- a/posthog/clickhouse/hcl/sql/dev/data.sql+++ b/posthog/clickhouse/hcl/sql/dev/data.sql@@ -269,18 +269,6 @@ CREATE TABLE posthog.duplicate_events (_partition UInt64,INDEX kafka_timestamp_minmax_duplicate_events _timestamp TYPE minmax GRANULARITY 3) ENGINE = ReplicatedMergeTree('/clickhouse/tables/noshard/posthog.duplicate_events', '{replica}-{shard}') ORDER BY (team_id, distinct_id, event, inserted_at) PARTITION BY toYYYYMMDD(inserted_at) TTL inserted_at + toIntervalDay(7) SETTINGS index_granularity = 512;-CREATE TABLE posthog.eni_inventory (- collected_at DateTime,- eni_id String,- ip_address String,- owner_account String,- subnet_id String,- security_groups Array(JSON),- instance_id String,- node_name String,- karpenter_nodeclaim String,- karpenter_ec2nodeclass String-) ENGINE = ReplacingMergeTree(collected_at) ORDER BY (eni_id, ip_address) PARTITION BY toYYYYMMDD(collected_at) SETTINGS index_granularity = 8192;CREATE TABLE posthog.error_tracking_fingerprint_issue_state (team_id Int64,fingerprint String,@@ -374,20 +362,6 @@ CREATE TABLE posthog.experiment_metric_events_preaggregated (computed_at DateTime64(6, 'UTC') DEFAULT now(),expires_at Date DEFAULT today() + toIntervalDay(7)) ENGINE = Distributed('aux', 'posthog', 'sharded_experiment_metric_events_preaggregated', cityHash64(entity_id));-CREATE TABLE posthog.flow_logs_local (- interface_id String,- srcaddr String,- dstaddr String,- srcport UInt16,- dstport UInt16,- protocol UInt8,- packets UInt32,- bytes UInt64,- ts_start DateTime,- ts_end DateTime,- action LowCardinality(String),- log_status LowCardinality(String)-) ENGINE = MergeTree() ORDER BY (ts_start, dstport, dstaddr, interface_id) PARTITION BY toYYYYMMDD(ts_start) SETTINGS index_granularity = 8192;CREATE TABLE posthog.groups (group_type_index UInt8,group_key String,@@ -456,17 +430,6 @@ CREATE TABLE posthog.ingestion_warnings_v2_distributed (_offset UInt64,_partition UInt64) ENGINE = Distributed('aux', 'posthog', 'ingestion_warnings_v2');-CREATE TABLE posthog.k8s_node_inventory (- collected_at DateTime,- node_name String,- instance_id String,- region String,- nodeclaim String,- nodepool String,- ec2nodeclass String,- labels JSON,- enis Array(JSON)-) ENGINE = ReplacingMergeTree(collected_at) ORDER BY (nodepool, instance_id) PARTITION BY toYYYYMMDD(collected_at) SETTINGS index_granularity = 8192;CREATE TABLE posthog.kafka_error_tracking_issue_fingerprint_overrides_ws (team_id Int64,fingerprint String,@@ -787,14 +750,6 @@ CREATE TABLE posthog.query_log_archive (lc_dagster__owner String ALIAS CAST(log_comment.`dagster.tags.owner`, 'String'),lc_modifiers String ALIAS if(is_initial_query, JSONExtractRaw(toString(log_comment), 'modifiers'), '')) ENGINE = Distributed('ops', 'posthog', 'sharded_query_log_archive');-CREATE TABLE posthog.rds_inventory (- collected_at DateTime,- region String,- instance_name String,- cluster_name String,- endpoint String,- ip_address String-) ENGINE = ReplacingMergeTree(collected_at) ORDER BY (region, instance_name) PARTITION BY toYYYYMMDD(collected_at) SETTINGS index_granularity = 8192;CREATE TABLE posthog.session_replay_features (session_id String,team_id Int64,@@ -1433,11 +1388,7 @@ CREATE TABLE posthog.sharded_session_replay_events (distinct_id String,min_first_timestamp SimpleAggregateFunction(min, DateTime64(6, 'UTC')),max_last_timestamp SimpleAggregateFunction(max, DateTime64(6, 'UTC')),- block_first_timestamps SimpleAggregateFunction(groupArrayArray, Array(DateTime64(6, 'UTC'))),- block_last_timestamps SimpleAggregateFunction(groupArrayArray, Array(DateTime64(6, 'UTC'))),- block_urls SimpleAggregateFunction(groupArrayArray, Array(String)),first_url AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC')),- all_urls SimpleAggregateFunction(groupUniqArrayArray, Array(String)),click_count SimpleAggregateFunction(sum, Int64),keypress_count SimpleAggregateFunction(sum, Int64),mouse_activity_count SimpleAggregateFunction(sum, Int64),@@ -1448,15 +1399,19 @@ CREATE TABLE posthog.sharded_session_replay_events (size SimpleAggregateFunction(sum, Int64),message_count SimpleAggregateFunction(sum, Int64),event_count SimpleAggregateFunction(sum, Int64),+ _timestamp SimpleAggregateFunction(max, DateTime),snapshot_source AggregateFunction(argMin, LowCardinality(Nullable(String)), DateTime64(6, 'UTC')),+ all_urls SimpleAggregateFunction(groupUniqArrayArray, Array(String)),snapshot_library AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC')),- _timestamp SimpleAggregateFunction(max, DateTime),+ block_first_timestamps SimpleAggregateFunction(groupArrayArray, Array(DateTime64(6, 'UTC'))),+ block_last_timestamps SimpleAggregateFunction(groupArrayArray, Array(DateTime64(6, 'UTC'))),+ block_urls SimpleAggregateFunction(groupArrayArray, Array(String)),+ retention_period_days SimpleAggregateFunction(max, Nullable(Int64)),is_deleted SimpleAggregateFunction(max, UInt8) DEFAULT 0,ai_tags_fixed SimpleAggregateFunction(groupUniqArrayArray, Array(String)),ai_tags_freeform SimpleAggregateFunction(groupUniqArrayArray, Array(String)),ai_highlighted SimpleAggregateFunction(max, UInt8) DEFAULT 0,surfacing_score SimpleAggregateFunction(max, Nullable(Float32)),- retention_period_days SimpleAggregateFunction(max, Nullable(Int64)),snapshot_mode AggregateFunction(argMin, LowCardinality(Nullable(String)), DateTime64(6, 'UTC'))) ENGINE = ReplicatedAggregatingMergeTree('/clickhouse/tables/{shard}/posthog.session_replay_events', '{replica}') ORDER BY (toDate(min_first_timestamp), team_id, session_id) PARTITION BY toYYYYMM(min_first_timestamp) SETTINGS index_granularity = 512, ttl_only_drop_parts = 1;CREATE TABLE posthog.sharded_sessions (@@ -2794,11 +2749,7 @@ CREATE TABLE posthog.session_replay_events (distinct_id String,min_first_timestamp SimpleAggregateFunction(min, DateTime64(6, 'UTC')),max_last_timestamp SimpleAggregateFunction(max, DateTime64(6, 'UTC')),- block_first_timestamps SimpleAggregateFunction(groupArrayArray, Array(DateTime64(6, 'UTC'))),- block_last_timestamps SimpleAggregateFunction(groupArrayArray, Array(DateTime64(6, 'UTC'))),- block_urls SimpleAggregateFunction(groupArrayArray, Array(String)),first_url AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC')),- all_urls SimpleAggregateFunction(groupUniqArrayArray, Array(String)),click_count SimpleAggregateFunction(sum, Int64),keypress_count SimpleAggregateFunction(sum, Int64),mouse_activity_count SimpleAggregateFunction(sum, Int64),@@ -2809,15 +2760,19 @@ CREATE TABLE posthog.session_replay_events (size SimpleAggregateFunction(sum, Int64),message_count SimpleAggregateFunction(sum, Int64),event_count SimpleAggregateFunction(sum, Int64),+ _timestamp SimpleAggregateFunction(max, DateTime),snapshot_source AggregateFunction(argMin, LowCardinality(Nullable(String)), DateTime64(6, 'UTC')),+ all_urls SimpleAggregateFunction(groupUniqArrayArray, Array(String)),snapshot_library AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC')),- _timestamp SimpleAggregateFunction(max, DateTime),+ block_first_timestamps SimpleAggregateFunction(groupArrayArray, Array(DateTime64(6, 'UTC'))),+ block_last_timestamps SimpleAggregateFunction(groupArrayArray, Array(DateTime64(6, 'UTC'))),+ block_urls SimpleAggregateFunction(groupArrayArray, Array(String)),+ retention_period_days SimpleAggregateFunction(max, Nullable(Int64)),is_deleted SimpleAggregateFunction(max, UInt8) DEFAULT 0,ai_tags_fixed SimpleAggregateFunction(groupUniqArrayArray, Array(String)),ai_tags_freeform SimpleAggregateFunction(groupUniqArrayArray, Array(String)),ai_highlighted SimpleAggregateFunction(max, UInt8) DEFAULT 0,surfacing_score SimpleAggregateFunction(max, Nullable(Float32)),- retention_period_days SimpleAggregateFunction(max, Nullable(Int64)),snapshot_mode AggregateFunction(argMin, LowCardinality(Nullable(String)), DateTime64(6, 'UTC'))) ENGINE = Distributed('posthog', 'posthog', 'sharded_session_replay_events', sipHash64(distinct_id));CREATE TABLE posthog.sessions (diff --git a/posthog/clickhouse/hcl/sql/local-multi/data.sql b/posthog/clickhouse/hcl/sql/local-multi/data.sqlindex 0157afdaf127..6c036b4593b7 100644--- a/posthog/clickhouse/hcl/sql/local-multi/data.sql+++ b/posthog/clickhouse/hcl/sql/local-multi/data.sql@@ -1642,11 +1642,7 @@ CREATE TABLE posthog.sharded_session_replay_events (distinct_id String,min_first_timestamp SimpleAggregateFunction(min, DateTime64(6, 'UTC')),max_last_timestamp SimpleAggregateFunction(max, DateTime64(6, 'UTC')),- block_first_timestamps SimpleAggregateFunction(groupArrayArray, Array(DateTime64(6, 'UTC'))),- block_last_timestamps SimpleAggregateFunction(groupArrayArray, Array(DateTime64(6, 'UTC'))),- block_urls SimpleAggregateFunction(groupArrayArray, Array(String)),first_url AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC')),- all_urls SimpleAggregateFunction(groupUniqArrayArray, Array(String)),click_count SimpleAggregateFunction(sum, Int64),keypress_count SimpleAggregateFunction(sum, Int64),mouse_activity_count SimpleAggregateFunction(sum, Int64),@@ -1657,15 +1653,19 @@ CREATE TABLE posthog.sharded_session_replay_events (size SimpleAggregateFunction(sum, Int64),message_count SimpleAggregateFunction(sum, Int64),event_count SimpleAggregateFunction(sum, Int64),+ _timestamp SimpleAggregateFunction(max, DateTime),snapshot_source AggregateFunction(argMin, LowCardinality(Nullable(String)), DateTime64(6, 'UTC')),+ all_urls SimpleAggregateFunction(groupUniqArrayArray, Array(String)),snapshot_library AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC')),- _timestamp SimpleAggregateFunction(max, DateTime),+ block_first_timestamps SimpleAggregateFunction(groupArrayArray, Array(DateTime64(6, 'UTC'))),+ block_last_timestamps SimpleAggregateFunction(groupArrayArray, Array(DateTime64(6, 'UTC'))),+ block_urls SimpleAggregateFunction(groupArrayArray, Array(String)),+ retention_period_days SimpleAggregateFunction(max, Nullable(Int64)),is_deleted SimpleAggregateFunction(max, UInt8) DEFAULT 0,ai_tags_fixed SimpleAggregateFunction(groupUniqArrayArray, Array(String)),ai_tags_freeform SimpleAggregateFunction(groupUniqArrayArray, Array(String)),ai_highlighted SimpleAggregateFunction(max, UInt8) DEFAULT 0,surfacing_score SimpleAggregateFunction(max, Nullable(Float32)),- retention_period_days SimpleAggregateFunction(max, Nullable(Int64)),snapshot_mode AggregateFunction(argMin, LowCardinality(Nullable(String)), DateTime64(6, 'UTC'))) ENGINE = ReplicatedAggregatingMergeTree('/clickhouse/tables/{shard}/posthog.session_replay_events', '{replica}') ORDER BY (toDate(min_first_timestamp), team_id, session_id) PARTITION BY toYYYYMM(min_first_timestamp) SETTINGS index_granularity = 512;CREATE TABLE posthog.sharded_sessions (@@ -3425,11 +3425,7 @@ CREATE TABLE posthog.session_replay_events (distinct_id String,min_first_timestamp SimpleAggregateFunction(min, DateTime64(6, 'UTC')),max_last_timestamp SimpleAggregateFunction(max, DateTime64(6, 'UTC')),- block_first_timestamps SimpleAggregateFunction(groupArrayArray, Array(DateTime64(6, 'UTC'))),- block_last_timestamps SimpleAggregateFunction(groupArrayArray, Array(DateTime64(6, 'UTC'))),- block_urls SimpleAggregateFunction(groupArrayArray, Array(String)),first_url AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC')),- all_urls SimpleAggregateFunction(groupUniqArrayArray, Array(String)),click_count SimpleAggregateFunction(sum, Int64),keypress_count SimpleAggregateFunction(sum, Int64),mouse_activity_count SimpleAggregateFunction(sum, Int64),@@ -3440,15 +3436,19 @@ CREATE TABLE posthog.session_replay_events (size SimpleAggregateFunction(sum, Int64),message_count SimpleAggregateFunction(sum, Int64),event_count SimpleAggregateFunction(sum, Int64),+ _timestamp SimpleAggregateFunction(max, DateTime),snapshot_source AggregateFunction(argMin, LowCardinality(Nullable(String)), DateTime64(6, 'UTC')),+ all_urls SimpleAggregateFunction(groupUniqArrayArray, Array(String)),snapshot_library AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC')),- _timestamp SimpleAggregateFunction(max, DateTime),+ block_first_timestamps SimpleAggregateFunction(groupArrayArray, Array(DateTime64(6, 'UTC'))),+ block_last_timestamps SimpleAggregateFunction(groupArrayArray, Array(DateTime64(6, 'UTC'))),+ block_urls SimpleAggregateFunction(groupArrayArray, Array(String)),+ retention_period_days SimpleAggregateFunction(max, Nullable(Int64)),is_deleted SimpleAggregateFunction(max, UInt8) DEFAULT 0,ai_tags_fixed SimpleAggregateFunction(groupUniqArrayArray, Array(String)),ai_tags_freeform SimpleAggregateFunction(groupUniqArrayArray, Array(String)),ai_highlighted SimpleAggregateFunction(max, UInt8) DEFAULT 0,surfacing_score SimpleAggregateFunction(max, Nullable(Float32)),- retention_period_days SimpleAggregateFunction(max, Nullable(Int64)),snapshot_mode AggregateFunction(argMin, LowCardinality(Nullable(String)), DateTime64(6, 'UTC'))) ENGINE = Distributed('posthog', 'posthog', 'sharded_session_replay_events', sipHash64(distinct_id));CREATE TABLE posthog.sessions (diff --git a/posthog/clickhouse/hcl/sql/local-single/all.sql b/posthog/clickhouse/hcl/sql/local-single/all.sqlindex 671d14da1dd6..b820e98bd186 100644--- a/posthog/clickhouse/hcl/sql/local-single/all.sql+++ b/posthog/clickhouse/hcl/sql/local-single/all.sql@@ -2740,11 +2740,7 @@ CREATE TABLE posthog.sharded_session_replay_events (distinct_id String,min_first_timestamp SimpleAggregateFunction(min, DateTime64(6, 'UTC')),max_last_timestamp SimpleAggregateFunction(max, DateTime64(6, 'UTC')),- block_first_timestamps SimpleAggregateFunction(groupArrayArray, Array(DateTime64(6, 'UTC'))),- block_last_timestamps SimpleAggregateFunction(groupArrayArray, Array(DateTime64(6, 'UTC'))),- block_urls SimpleAggregateFunction(groupArrayArray, Array(String)),first_url AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC')),- all_urls SimpleAggregateFunction(groupUniqArrayArray, Array(String)),click_count SimpleAggregateFunction(sum, Int64),keypress_count SimpleAggregateFunction(sum, Int64),mouse_activity_count SimpleAggregateFunction(sum, Int64),@@ -2755,15 +2751,19 @@ CREATE TABLE posthog.sharded_session_replay_events (size SimpleAggregateFunction(sum, Int64),message_count SimpleAggregateFunction(sum, Int64),event_count SimpleAggregateFunction(sum, Int64),+ _timestamp SimpleAggregateFunction(max, DateTime),snapshot_source AggregateFunction(argMin, LowCardinality(Nullable(String)), DateTime64(6, 'UTC')),+ all_urls SimpleAggregateFunction(groupUniqArrayArray, Array(String)),snapshot_library AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC')),- _timestamp SimpleAggregateFunction(max, DateTime),+ block_first_timestamps SimpleAggregateFunction(groupArrayArray, Array(DateTime64(6, 'UTC'))),+ block_last_timestamps SimpleAggregateFunction(groupArrayArray, Array(DateTime64(6, 'UTC'))),+ block_urls SimpleAggregateFunction(groupArrayArray, Array(String)),+ retention_period_days SimpleAggregateFunction(max, Nullable(Int64)),is_deleted SimpleAggregateFunction(max, UInt8) DEFAULT 0,ai_tags_fixed SimpleAggregateFunction(groupUniqArrayArray, Array(String)),ai_tags_freeform SimpleAggregateFunction(groupUniqArrayArray, Array(String)),ai_highlighted SimpleAggregateFunction(max, UInt8) DEFAULT 0,surfacing_score SimpleAggregateFunction(max, Nullable(Float32)),- retention_period_days SimpleAggregateFunction(max, Nullable(Int64)),snapshot_mode AggregateFunction(argMin, LowCardinality(Nullable(String)), DateTime64(6, 'UTC'))) ENGINE = ReplicatedAggregatingMergeTree('/clickhouse/tables/{shard}/posthog.session_replay_events', '{replica}') ORDER BY (toDate(min_first_timestamp), team_id, session_id) PARTITION BY toYYYYMM(min_first_timestamp) SETTINGS index_granularity = 512;CREATE TABLE posthog.sharded_session_replay_features (@@ -6934,11 +6934,7 @@ CREATE TABLE posthog.session_replay_events (distinct_id String,min_first_timestamp SimpleAggregateFunction(min, DateTime64(6, 'UTC')),max_last_timestamp SimpleAggregateFunction(max, DateTime64(6, 'UTC')),- block_first_timestamps SimpleAggregateFunction(groupArrayArray, Array(DateTime64(6, 'UTC'))),- block_last_timestamps SimpleAggregateFunction(groupArrayArray, Array(DateTime64(6, 'UTC'))),- block_urls SimpleAggregateFunction(groupArrayArray, Array(String)),first_url AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC')),- all_urls SimpleAggregateFunction(groupUniqArrayArray, Array(String)),click_count SimpleAggregateFunction(sum, Int64),keypress_count SimpleAggregateFunction(sum, Int64),mouse_activity_count SimpleAggregateFunction(sum, Int64),@@ -6949,15 +6945,19 @@ CREATE TABLE posthog.session_replay_events (size SimpleAggregateFunction(sum, Int64),message_count SimpleAggregateFunction(sum, Int64),event_count SimpleAggregateFunction(sum, Int64),+ _timestamp SimpleAggregateFunction(max, DateTime),snapshot_source AggregateFunction(argMin, LowCardinality(Nullable(String)), DateTime64(6, 'UTC')),+ all_urls SimpleAggregateFunction(groupUniqArrayArray, Array(String)),snapshot_library AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC')),- _timestamp SimpleAggregateFunction(max, DateTime),+ block_first_timestamps SimpleAggregateFunction(groupArrayArray, Array(DateTime64(6, 'UTC'))),+ block_last_timestamps SimpleAggregateFunction(groupArrayArray, Array(DateTime64(6, 'UTC'))),+ block_urls SimpleAggregateFunction(groupArrayArray, Array(String)),+ retention_period_days SimpleAggregateFunction(max, Nullable(Int64)),is_deleted SimpleAggregateFunction(max, UInt8) DEFAULT 0,ai_tags_fixed SimpleAggregateFunction(groupUniqArrayArray, Array(String)),ai_tags_freeform SimpleAggregateFunction(groupUniqArrayArray, Array(String)),ai_highlighted SimpleAggregateFunction(max, UInt8) DEFAULT 0,surfacing_score SimpleAggregateFunction(max, Nullable(Float32)),- retention_period_days SimpleAggregateFunction(max, Nullable(Int64)),snapshot_mode AggregateFunction(argMin, LowCardinality(Nullable(String)), DateTime64(6, 'UTC'))) ENGINE = Distributed('posthog', 'posthog', 'sharded_session_replay_events', sipHash64(distinct_id));CREATE TABLE posthog.session_replay_features (diff --git a/posthog/clickhouse/hcl/sql/prod-eu/data.sql b/posthog/clickhouse/hcl/sql/prod-eu/data.sqlindex 60c7537bbf12..7944a16c7867 100644--- a/posthog/clickhouse/hcl/sql/prod-eu/data.sql+++ b/posthog/clickhouse/hcl/sql/prod-eu/data.sql@@ -1607,11 +1607,7 @@ CREATE TABLE posthog.sharded_session_replay_events (distinct_id String,min_first_timestamp SimpleAggregateFunction(min, DateTime64(6, 'UTC')),max_last_timestamp SimpleAggregateFunction(max, DateTime64(6, 'UTC')),- block_first_timestamps SimpleAggregateFunction(groupArrayArray, Array(DateTime64(6, 'UTC'))),- block_last_timestamps SimpleAggregateFunction(groupArrayArray, Array(DateTime64(6, 'UTC'))),- block_urls SimpleAggregateFunction(groupArrayArray, Array(String)),first_url AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC')),- all_urls SimpleAggregateFunction(groupUniqArrayArray, Array(String)),click_count SimpleAggregateFunction(sum, Int64),keypress_count SimpleAggregateFunction(sum, Int64),mouse_activity_count SimpleAggregateFunction(sum, Int64),@@ -1622,15 +1618,19 @@ CREATE TABLE posthog.sharded_session_replay_events (size SimpleAggregateFunction(sum, Int64),message_count SimpleAggregateFunction(sum, Int64),event_count SimpleAggregateFunction(sum, Int64),+ _timestamp SimpleAggregateFunction(max, DateTime),snapshot_source AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC')),+ all_urls SimpleAggregateFunction(groupUniqArrayArray, Array(String)),snapshot_library AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC')),- _timestamp SimpleAggregateFunction(max, DateTime),+ block_first_timestamps SimpleAggregateFunction(groupArrayArray, Array(DateTime64(6, 'UTC'))),+ block_last_timestamps SimpleAggregateFunction(groupArrayArray, Array(DateTime64(6, 'UTC'))),+ block_urls SimpleAggregateFunction(groupArrayArray, Array(String)),+ retention_period_days SimpleAggregateFunction(max, Nullable(Int64)),is_deleted SimpleAggregateFunction(max, UInt8) DEFAULT 0,ai_tags_fixed SimpleAggregateFunction(groupUniqArrayArray, Array(String)),ai_tags_freeform SimpleAggregateFunction(groupUniqArrayArray, Array(String)),ai_highlighted SimpleAggregateFunction(max, UInt8) DEFAULT 0,surfacing_score SimpleAggregateFunction(max, Nullable(Float32)),- retention_period_days SimpleAggregateFunction(max, Nullable(Int64)),snapshot_mode AggregateFunction(argMin, LowCardinality(Nullable(String)), DateTime64(6, 'UTC'))) ENGINE = ReplicatedAggregatingMergeTree('/clickhouse/tables/{shard}/posthog.session_replay_events', '{replica}') ORDER BY (toDate(min_first_timestamp), team_id, session_id) PARTITION BY toYYYYMM(min_first_timestamp) SETTINGS index_granularity = 512, ttl_only_drop_parts = 1;CREATE TABLE posthog.swap_person_distinct_id (@@ -3076,11 +3076,7 @@ CREATE TABLE posthog.session_replay_events (distinct_id String,min_first_timestamp SimpleAggregateFunction(min, DateTime64(6, 'UTC')),max_last_timestamp SimpleAggregateFunction(max, DateTime64(6, 'UTC')),- block_first_timestamps SimpleAggregateFunction(groupArrayArray, Array(DateTime64(6, 'UTC'))),- block_last_timestamps SimpleAggregateFunction(groupArrayArray, Array(DateTime64(6, 'UTC'))),- block_urls SimpleAggregateFunction(groupArrayArray, Array(String)),first_url AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC')),- all_urls SimpleAggregateFunction(groupUniqArrayArray, Array(String)),click_count SimpleAggregateFunction(sum, Int64),keypress_count SimpleAggregateFunction(sum, Int64),mouse_activity_count SimpleAggregateFunction(sum, Int64),@@ -3091,15 +3087,19 @@ CREATE TABLE posthog.session_replay_events (size SimpleAggregateFunction(sum, Int64),message_count SimpleAggregateFunction(sum, Int64),event_count SimpleAggregateFunction(sum, Int64),+ _timestamp SimpleAggregateFunction(max, DateTime),snapshot_source AggregateFunction(argMin, LowCardinality(Nullable(String)), DateTime64(6, 'UTC')),+ all_urls SimpleAggregateFunction(groupUniqArrayArray, Array(String)),snapshot_library AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC')),- _timestamp SimpleAggregateFunction(max, DateTime),+ block_first_timestamps SimpleAggregateFunction(groupArrayArray, Array(DateTime64(6, 'UTC'))),+ block_last_timestamps SimpleAggregateFunction(groupArrayArray, Array(DateTime64(6, 'UTC'))),+ block_urls SimpleAggregateFunction(groupArrayArray, Array(String)),+ retention_period_days SimpleAggregateFunction(max, Nullable(Int64)),is_deleted SimpleAggregateFunction(max, UInt8) DEFAULT 0,ai_tags_fixed SimpleAggregateFunction(groupUniqArrayArray, Array(String)),ai_tags_freeform SimpleAggregateFunction(groupUniqArrayArray, Array(String)),ai_highlighted SimpleAggregateFunction(max, UInt8) DEFAULT 0,surfacing_score SimpleAggregateFunction(max, Nullable(Float32)),- retention_period_days SimpleAggregateFunction(max, Nullable(Int64)),snapshot_mode AggregateFunction(argMin, LowCardinality(Nullable(String)), DateTime64(6, 'UTC'))) ENGINE = Distributed('posthog', 'posthog', 'sharded_session_replay_events', sipHash64(distinct_id));CREATE VIEW posthog.custom_metrics AS SELECT * REPLACE(toFloat64(value) AS value)diff --git a/posthog/clickhouse/hcl/sql/prod-eu/sessions.sql b/posthog/clickhouse/hcl/sql/prod-eu/sessions.sqlindex 77d8b66eb183..da2471276e7a 100644--- a/posthog/clickhouse/hcl/sql/prod-eu/sessions.sql+++ b/posthog/clickhouse/hcl/sql/prod-eu/sessions.sql@@ -81,8 +81,7 @@ CREATE TABLE posthog.events (dmat_string_9 Nullable(String),historical_migration Bool,properties_group_ai_large Map(String, String),- mat_$ai_prompt_name Nullable(String) COMMENT 'column_materializer::properties::$ai_prompt_name',- mat_$ai_experiment_id Nullable(String) COMMENT 'column_materializer::properties::$ai_experiment_id'+ mat_$ai_prompt_name Nullable(String) COMMENT 'column_materializer::properties::$ai_prompt_name') ENGINE = Distributed('posthog', 'posthog', 'sharded_events', sipHash64(distinct_id));CREATE TABLE posthog.person_distinct_id_overrides (team_id Int64,diff --git a/posthog/clickhouse/hcl/sql/prod-us/data.sql b/posthog/clickhouse/hcl/sql/prod-us/data.sqlindex fcac2a02dd20..0c97ac61aaa7 100644--- a/posthog/clickhouse/hcl/sql/prod-us/data.sql+++ b/posthog/clickhouse/hcl/sql/prod-us/data.sql@@ -1439,11 +1439,7 @@ CREATE TABLE posthog.sharded_session_replay_events (distinct_id String,min_first_timestamp SimpleAggregateFunction(min, DateTime64(6, 'UTC')),max_last_timestamp SimpleAggregateFunction(max, DateTime64(6, 'UTC')),- block_first_timestamps SimpleAggregateFunction(groupArrayArray, Array(DateTime64(6, 'UTC'))),- block_last_timestamps SimpleAggregateFunction(groupArrayArray, Array(DateTime64(6, 'UTC'))),- block_urls SimpleAggregateFunction(groupArrayArray, Array(String)),first_url AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC')),- all_urls SimpleAggregateFunction(groupUniqArrayArray, Array(String)),click_count SimpleAggregateFunction(sum, Int64),keypress_count SimpleAggregateFunction(sum, Int64),mouse_activity_count SimpleAggregateFunction(sum, Int64),@@ -1454,15 +1450,19 @@ CREATE TABLE posthog.sharded_session_replay_events (size SimpleAggregateFunction(sum, Int64),message_count SimpleAggregateFunction(sum, Int64),event_count SimpleAggregateFunction(sum, Int64),+ _timestamp SimpleAggregateFunction(max, DateTime),snapshot_source AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC')),+ all_urls SimpleAggregateFunction(groupUniqArrayArray, Array(String)),snapshot_library AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC')),- _timestamp SimpleAggregateFunction(max, DateTime),+ block_first_timestamps SimpleAggregateFunction(groupArrayArray, Array(DateTime64(6, 'UTC'))),+ block_last_timestamps SimpleAggregateFunction(groupArrayArray, Array(DateTime64(6, 'UTC'))),+ block_urls SimpleAggregateFunction(groupArrayArray, Array(String)),+ retention_period_days SimpleAggregateFunction(max, Nullable(Int64)),is_deleted SimpleAggregateFunction(max, UInt8) DEFAULT 0,ai_tags_fixed SimpleAggregateFunction(groupUniqArrayArray, Array(String)),ai_tags_freeform SimpleAggregateFunction(groupUniqArrayArray, Array(String)),ai_highlighted SimpleAggregateFunction(max, UInt8) DEFAULT 0,surfacing_score SimpleAggregateFunction(max, Nullable(Float32)),- retention_period_days SimpleAggregateFunction(max, Nullable(Int64)),snapshot_mode AggregateFunction(argMin, LowCardinality(Nullable(String)), DateTime64(6, 'UTC'))) ENGINE = ReplicatedAggregatingMergeTree('/clickhouse/tables/reshard/{shard}/posthog.session_replay_events', '{replica}') ORDER BY (toDate(min_first_timestamp), team_id, session_id) PARTITION BY toYYYYMM(min_first_timestamp) SETTINGS index_granularity = 512;CREATE TABLE posthog.swap_person_distinct_id (@@ -2913,11 +2913,7 @@ CREATE TABLE posthog.session_replay_events (distinct_id String,min_first_timestamp SimpleAggregateFunction(min, DateTime64(6, 'UTC')),max_last_timestamp SimpleAggregateFunction(max, DateTime64(6, 'UTC')),- block_first_timestamps SimpleAggregateFunction(groupArrayArray, Array(DateTime64(6, 'UTC'))),- block_last_timestamps SimpleAggregateFunction(groupArrayArray, Array(DateTime64(6, 'UTC'))),- block_urls SimpleAggregateFunction(groupArrayArray, Array(String)),first_url AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC')),- all_urls SimpleAggregateFunction(groupUniqArrayArray, Array(String)),click_count SimpleAggregateFunction(sum, Int64),keypress_count SimpleAggregateFunction(sum, Int64),mouse_activity_count SimpleAggregateFunction(sum, Int64),@@ -2928,15 +2924,19 @@ CREATE TABLE posthog.session_replay_events (size SimpleAggregateFunction(sum, Int64),message_count SimpleAggregateFunction(sum, Int64),event_count SimpleAggregateFunction(sum, Int64),+ _timestamp SimpleAggregateFunction(max, DateTime),snapshot_source AggregateFunction(argMin, LowCardinality(Nullable(String)), DateTime64(6, 'UTC')),+ all_urls SimpleAggregateFunction(groupUniqArrayArray, Array(String)),snapshot_library AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC')),- _timestamp SimpleAggregateFunction(max, DateTime),+ block_first_timestamps SimpleAggregateFunction(groupArrayArray, Array(DateTime64(6, 'UTC'))),+ block_last_timestamps SimpleAggregateFunction(groupArrayArray, Array(DateTime64(6, 'UTC'))),+ block_urls SimpleAggregateFunction(groupArrayArray, Array(String)),+ retention_period_days SimpleAggregateFunction(max, Nullable(Int64)),is_deleted SimpleAggregateFunction(max, UInt8) DEFAULT 0,ai_tags_fixed SimpleAggregateFunction(groupUniqArrayArray, Array(String)),ai_tags_freeform SimpleAggregateFunction(groupUniqArrayArray, Array(String)),ai_highlighted SimpleAggregateFunction(max, UInt8) DEFAULT 0,surfacing_score SimpleAggregateFunction(max, Nullable(Float32)),- retention_period_days SimpleAggregateFunction(max, Nullable(Int64)),snapshot_mode AggregateFunction(argMin, LowCardinality(Nullable(String)), DateTime64(6, 'UTC'))) ENGINE = Distributed('posthog', 'posthog', 'sharded_session_replay_events', sipHash64(distinct_id));CREATE TABLE posthog.writable_raw_sessions_v3 (