: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
chore(clickhouse): gate the ingestion nodes and the single-node stack (#84082)
Paweł Szczur3147dedcd7fa
diff --git a/.github/workflows/ci-clickhouse-multinode-migrations.yml b/.github/workflows/ci-clickhouse-multinode-migrations.ymlindex 9ba6cadf1de2..dfb79cd75011 100644--- a/.github/workflows/ci-clickhouse-multinode-migrations.yml+++ b/.github/workflows/ci-clickhouse-multinode-migrations.yml@@ -68,7 +68,7 @@ jobs:- name: Add multinode hostnames to /etc/hostsrun: |- echo "127.0.0.1 clickhouse-data clickhouse-ai-events clickhouse-aux clickhouse-ops clickhouse-sessions clickhouse-logs kafka zookeeper" | sudo tee -a /etc/hosts+ echo "127.0.0.1 clickhouse-data clickhouse-ai-events clickhouse-aux clickhouse-ops clickhouse-sessions clickhouse-logs clickhouse-ingestion-events clickhouse-ingestion-small clickhouse-ingestion-medium kafka zookeeper" | sudo tee -a /etc/hosts- name: Set up Pythonuses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0diff --git a/docker-compose.multinode-clickhouse.yml b/docker-compose.multinode-clickhouse.ymlindex 64f2c8ff1f8e..93414f1f427a 100644--- a/docker-compose.multinode-clickhouse.yml+++ b/docker-compose.multinode-clickhouse.yml@@ -155,5 +155,52 @@ services:- '8128:8123'- '9500:9000'+ clickhouse-ingestion-events:+ <<: *clickhouse-multinode+ hostname: clickhouse-ingestion-events+ volumes:+ - ./posthog/idl:/idl+ - ./docker/clickhouse/docker-entrypoint-initdb.d:/docker-entrypoint-initdb.d+ - ./docker/clickhouse/config.xml:/etc/clickhouse-server/config.xml+ - ./docker/clickhouse/config.d/multinode/ingestion_events_node.xml:/etc/clickhouse-server/config.d/default.xml+ - ./docker/clickhouse/config.d/dev-memory.xml:/etc/clickhouse-server/config.d/dev-memory.xml+ - ./docker/clickhouse/users-dev.xml:/etc/clickhouse-server/users.xml+ - ./docker/clickhouse/user_defined_function.xml:/etc/clickhouse-server/user_defined_function.xml+ - ./posthog/user_scripts:/var/lib/clickhouse/user_scripts+ ports:+ - '8129:8123'+ - '9600:9000'++ clickhouse-ingestion-small:+ <<: *clickhouse-multinode+ hostname: clickhouse-ingestion-small+ volumes:+ - ./posthog/idl:/idl+ - ./docker/clickhouse/docker-entrypoint-initdb.d:/docker-entrypoint-initdb.d+ - ./docker/clickhouse/config.xml:/etc/clickhouse-server/config.xml+ - ./docker/clickhouse/config.d/multinode/ingestion_small_node.xml:/etc/clickhouse-server/config.d/default.xml+ - ./docker/clickhouse/config.d/dev-memory.xml:/etc/clickhouse-server/config.d/dev-memory.xml+ - ./docker/clickhouse/users-dev.xml:/etc/clickhouse-server/users.xml+ - ./docker/clickhouse/user_defined_function.xml:/etc/clickhouse-server/user_defined_function.xml+ - ./posthog/user_scripts:/var/lib/clickhouse/user_scripts+ ports:+ - '8130:8123'+ - '9700:9000'++ clickhouse-ingestion-medium:+ <<: *clickhouse-multinode+ hostname: clickhouse-ingestion-medium+ volumes:+ - ./posthog/idl:/idl+ - ./docker/clickhouse/docker-entrypoint-initdb.d:/docker-entrypoint-initdb.d+ - ./docker/clickhouse/config.xml:/etc/clickhouse-server/config.xml+ - ./docker/clickhouse/config.d/multinode/ingestion_medium_node.xml:/etc/clickhouse-server/config.d/default.xml+ - ./docker/clickhouse/config.d/dev-memory.xml:/etc/clickhouse-server/config.d/dev-memory.xml+ - ./docker/clickhouse/users-dev.xml:/etc/clickhouse-server/users.xml+ - ./docker/clickhouse/user_defined_function.xml:/etc/clickhouse-server/user_defined_function.xml+ - ./posthog/user_scripts:/var/lib/clickhouse/user_scripts+ ports:+ - '8131:8123'+ - '9800:9000'volumes:redpanda-data:diff --git a/docker/clickhouse/config.d/multinode/ai_events_node.xml b/docker/clickhouse/config.d/multinode/ai_events_node.xmlindex 3dc79aa1e343..05191ee5791e 100644--- a/docker/clickhouse/config.d/multinode/ai_events_node.xml+++ b/docker/clickhouse/config.d/multinode/ai_events_node.xml@@ -72,6 +72,24 @@<port>9000</port></replica></shard>+ <shard>+ <replica>+ <host>clickhouse-ingestion-events</host>+ <port>9000</port>+ </replica>+ </shard>+ <shard>+ <replica>+ <host>clickhouse-ingestion-small</host>+ <port>9000</port>+ </replica>+ </shard>+ <shard>+ <replica>+ <host>clickhouse-ingestion-medium</host>+ <port>9000</port>+ </replica>+ </shard></posthog_migrations><ai_events>diff --git a/docker/clickhouse/config.d/multinode/aux_node.xml b/docker/clickhouse/config.d/multinode/aux_node.xmlindex c92a3f9230e3..a8730d6b20b1 100644--- a/docker/clickhouse/config.d/multinode/aux_node.xml+++ b/docker/clickhouse/config.d/multinode/aux_node.xml@@ -72,6 +72,24 @@<port>9000</port></replica></shard>+ <shard>+ <replica>+ <host>clickhouse-ingestion-events</host>+ <port>9000</port>+ </replica>+ </shard>+ <shard>+ <replica>+ <host>clickhouse-ingestion-small</host>+ <port>9000</port>+ </replica>+ </shard>+ <shard>+ <replica>+ <host>clickhouse-ingestion-medium</host>+ <port>9000</port>+ </replica>+ </shard></posthog_migrations><ai_events>diff --git a/docker/clickhouse/config.d/multinode/data_node.xml b/docker/clickhouse/config.d/multinode/data_node.xmlindex 51f0fbfaa55d..5024b6333fda 100644--- a/docker/clickhouse/config.d/multinode/data_node.xml+++ b/docker/clickhouse/config.d/multinode/data_node.xml@@ -72,6 +72,24 @@<port>9000</port></replica></shard>+ <shard>+ <replica>+ <host>clickhouse-ingestion-events</host>+ <port>9000</port>+ </replica>+ </shard>+ <shard>+ <replica>+ <host>clickhouse-ingestion-small</host>+ <port>9000</port>+ </replica>+ </shard>+ <shard>+ <replica>+ <host>clickhouse-ingestion-medium</host>+ <port>9000</port>+ </replica>+ </shard></posthog_migrations><ai_events>diff --git a/docker/clickhouse/config.d/multinode/ingestion_events_node.xml b/docker/clickhouse/config.d/multinode/ingestion_events_node.xmlnew file mode 100644index 000000000000..9ef53cbc34da--- /dev/null+++ b/docker/clickhouse/config.d/multinode/ingestion_events_node.xml@@ -0,0 +1,170 @@+<clickhouse>+ <tcp_port>9000</tcp_port>++ <remote_servers>+ <posthog>+ <shard>+ <replica>+ <host>clickhouse-data</host>+ <port>9000</port>+ </replica>+ </shard>+ </posthog>+ <posthog_single_shard>+ <shard>+ <replica>+ <host>clickhouse-data</host>+ <port>9000</port>+ </replica>+ </shard>+ </posthog_single_shard>+ <posthog_writable>+ <shard>+ <replica>+ <host>clickhouse-data</host>+ <port>9000</port>+ </replica>+ </shard>+ </posthog_writable>+ <posthog_primary_replica>+ <shard>+ <replica>+ <host>clickhouse-data</host>+ <port>9000</port>+ </replica>+ </shard>+ </posthog_primary_replica>++ <posthog_migrations>+ <shard>+ <replica>+ <host>clickhouse-data</host>+ <port>9000</port>+ </replica>+ </shard>+ <shard>+ <replica>+ <host>clickhouse-ai-events</host>+ <port>9000</port>+ </replica>+ </shard>+ <shard>+ <replica>+ <host>clickhouse-aux</host>+ <port>9000</port>+ </replica>+ </shard>+ <shard>+ <replica>+ <host>clickhouse-ops</host>+ <port>9000</port>+ </replica>+ </shard>+ <shard>+ <replica>+ <host>clickhouse-sessions</host>+ <port>9000</port>+ </replica>+ </shard>+ <shard>+ <replica>+ <host>clickhouse-logs</host>+ <port>9000</port>+ </replica>+ </shard>+ <shard>+ <replica>+ <host>clickhouse-ingestion-events</host>+ <port>9000</port>+ </replica>+ </shard>+ <shard>+ <replica>+ <host>clickhouse-ingestion-small</host>+ <port>9000</port>+ </replica>+ </shard>+ <shard>+ <replica>+ <host>clickhouse-ingestion-medium</host>+ <port>9000</port>+ </replica>+ </shard>+ </posthog_migrations>++ <ai_events>+ <shard>+ <replica>+ <host>clickhouse-ai-events</host>+ <port>9000</port>+ </replica>+ </shard>+ </ai_events>+ <aux>+ <shard>+ <replica>+ <host>clickhouse-aux</host>+ <port>9000</port>+ </replica>+ </shard>+ </aux>+ <ops>+ <shard>+ <replica>+ <host>clickhouse-ops</host>+ <port>9000</port>+ </replica>+ </shard>+ </ops>+ <sessions>+ <shard>+ <replica>+ <host>clickhouse-sessions</host>+ <port>9000</port>+ </replica>+ </shard>+ </sessions>+ <logs>+ <shard>+ <replica>+ <host>clickhouse-logs</host>+ <port>9000</port>+ </replica>+ </shard>+ </logs>+ </remote_servers>++ <named_collections>+ <msk_cluster>+ <kafka_broker_list from_env="KAFKA_HOSTS"/>+ </msk_cluster>+ <warpstream_ingestion>+ <kafka_broker_list from_env="KAFKA_HOSTS"/>+ </warpstream_ingestion>+ <warpstream_calculated_events>+ <kafka_broker_list from_env="KAFKA_HOSTS"/>+ </warpstream_calculated_events>+ <warpstream_replay>+ <kafka_broker_list from_env="KAFKA_HOSTS"/>+ </warpstream_replay>+ <warpstream_shared>+ <kafka_broker_list from_env="KAFKA_HOSTS"/>+ </warpstream_shared>+ <warpstream_cyclotron>+ <kafka_broker_list from_env="KAFKA_HOSTS"/>+ </warpstream_cyclotron>+ <warpstream_logs>+ <kafka_broker_list from_env="KAFKA_HOSTS"/>+ </warpstream_logs>+ <warpstream_traces>+ <kafka_broker_list from_env="KAFKA_HOSTS"/>+ </warpstream_traces>+ </named_collections>++ <macros>+ <shard>01</shard>+ <replica>events</replica>+ <hostClusterType>online</hostClusterType>+ <hostClusterRole>events</hostClusterRole>+ </macros>+</clickhouse>diff --git a/docker/clickhouse/config.d/multinode/ingestion_medium_node.xml b/docker/clickhouse/config.d/multinode/ingestion_medium_node.xmlnew file mode 100644index 000000000000..ec7592466603--- /dev/null+++ b/docker/clickhouse/config.d/multinode/ingestion_medium_node.xml@@ -0,0 +1,170 @@+<clickhouse>+ <tcp_port>9000</tcp_port>++ <remote_servers>+ <posthog>+ <shard>+ <replica>+ <host>clickhouse-data</host>+ <port>9000</port>+ </replica>+ </shard>+ </posthog>+ <posthog_single_shard>+ <shard>+ <replica>+ <host>clickhouse-data</host>+ <port>9000</port>+ </replica>+ </shard>+ </posthog_single_shard>+ <posthog_writable>+ <shard>+ <replica>+ <host>clickhouse-data</host>+ <port>9000</port>+ </replica>+ </shard>+ </posthog_writable>+ <posthog_primary_replica>+ <shard>+ <replica>+ <host>clickhouse-data</host>+ <port>9000</port>+ </replica>+ </shard>+ </posthog_primary_replica>++ <posthog_migrations>+ <shard>+ <replica>+ <host>clickhouse-data</host>+ <port>9000</port>+ </replica>+ </shard>+ <shard>+ <replica>+ <host>clickhouse-ai-events</host>+ <port>9000</port>+ </replica>+ </shard>+ <shard>+ <replica>+ <host>clickhouse-aux</host>+ <port>9000</port>+ </replica>+ </shard>+ <shard>+ <replica>+ <host>clickhouse-ops</host>+ <port>9000</port>+ </replica>+ </shard>+ <shard>+ <replica>+ <host>clickhouse-sessions</host>+ <port>9000</port>+ </replica>+ </shard>+ <shard>+ <replica>+ <host>clickhouse-logs</host>+ <port>9000</port>+ </replica>+ </shard>+ <shard>+ <replica>+ <host>clickhouse-ingestion-events</host>+ <port>9000</port>+ </replica>+ </shard>+ <shard>+ <replica>+ <host>clickhouse-ingestion-small</host>+ <port>9000</port>+ </replica>+ </shard>+ <shard>+ <replica>+ <host>clickhouse-ingestion-medium</host>+ <port>9000</port>+ </replica>+ </shard>+ </posthog_migrations>++ <ai_events>+ <shard>+ <replica>+ <host>clickhouse-ai-events</host>+ <port>9000</port>+ </replica>+ </shard>+ </ai_events>+ <aux>+ <shard>+ <replica>+ <host>clickhouse-aux</host>+ <port>9000</port>+ </replica>+ </shard>+ </aux>+ <ops>+ <shard>+ <replica>+ <host>clickhouse-ops</host>+ <port>9000</port>+ </replica>+ </shard>+ </ops>+ <sessions>+ <shard>+ <replica>+ <host>clickhouse-sessions</host>+ <port>9000</port>+ </replica>+ </shard>+ </sessions>+ <logs>+ <shard>+ <replica>+ <host>clickhouse-logs</host>+ <port>9000</port>+ </replica>+ </shard>+ </logs>+ </remote_servers>++ <named_collections>+ <msk_cluster>+ <kafka_broker_list from_env="KAFKA_HOSTS"/>+ </msk_cluster>+ <warpstream_ingestion>+ <kafka_broker_list from_env="KAFKA_HOSTS"/>+ </warpstream_ingestion>+ <warpstream_calculated_events>+ <kafka_broker_list from_env="KAFKA_HOSTS"/>+ </warpstream_calculated_events>+ <warpstream_replay>+ <kafka_broker_list from_env="KAFKA_HOSTS"/>+ </warpstream_replay>+ <warpstream_shared>+ <kafka_broker_list from_env="KAFKA_HOSTS"/>+ </warpstream_shared>+ <warpstream_cyclotron>+ <kafka_broker_list from_env="KAFKA_HOSTS"/>+ </warpstream_cyclotron>+ <warpstream_logs>+ <kafka_broker_list from_env="KAFKA_HOSTS"/>+ </warpstream_logs>+ <warpstream_traces>+ <kafka_broker_list from_env="KAFKA_HOSTS"/>+ </warpstream_traces>+ </named_collections>++ <macros>+ <shard>01</shard>+ <replica>medium</replica>+ <hostClusterType>online</hostClusterType>+ <hostClusterRole>medium</hostClusterRole>+ </macros>+</clickhouse>diff --git a/docker/clickhouse/config.d/multinode/ingestion_small_node.xml b/docker/clickhouse/config.d/multinode/ingestion_small_node.xmlnew file mode 100644index 000000000000..dc051256f618--- /dev/null+++ b/docker/clickhouse/config.d/multinode/ingestion_small_node.xml@@ -0,0 +1,170 @@+<clickhouse>+ <tcp_port>9000</tcp_port>++ <remote_servers>+ <posthog>+ <shard>+ <replica>+ <host>clickhouse-data</host>+ <port>9000</port>+ </replica>+ </shard>+ </posthog>+ <posthog_single_shard>+ <shard>+ <replica>+ <host>clickhouse-data</host>+ <port>9000</port>+ </replica>+ </shard>+ </posthog_single_shard>+ <posthog_writable>+ <shard>+ <replica>+ <host>clickhouse-data</host>+ <port>9000</port>+ </replica>+ </shard>+ </posthog_writable>+ <posthog_primary_replica>+ <shard>+ <replica>+ <host>clickhouse-data</host>+ <port>9000</port>+ </replica>+ </shard>+ </posthog_primary_replica>++ <posthog_migrations>+ <shard>+ <replica>+ <host>clickhouse-data</host>+ <port>9000</port>+ </replica>+ </shard>+ <shard>+ <replica>+ <host>clickhouse-ai-events</host>+ <port>9000</port>+ </replica>+ </shard>+ <shard>+ <replica>+ <host>clickhouse-aux</host>+ <port>9000</port>+ </replica>+ </shard>+ <shard>+ <replica>+ <host>clickhouse-ops</host>+ <port>9000</port>+ </replica>+ </shard>+ <shard>+ <replica>+ <host>clickhouse-sessions</host>+ <port>9000</port>+ </replica>+ </shard>+ <shard>+ <replica>+ <host>clickhouse-logs</host>+ <port>9000</port>+ </replica>+ </shard>+ <shard>+ <replica>+ <host>clickhouse-ingestion-events</host>+ <port>9000</port>+ </replica>+ </shard>+ <shard>+ <replica>+ <host>clickhouse-ingestion-small</host>+ <port>9000</port>+ </replica>+ </shard>+ <shard>+ <replica>+ <host>clickhouse-ingestion-medium</host>+ <port>9000</port>+ </replica>+ </shard>+ </posthog_migrations>++ <ai_events>+ <shard>+ <replica>+ <host>clickhouse-ai-events</host>+ <port>9000</port>+ </replica>+ </shard>+ </ai_events>+ <aux>+ <shard>+ <replica>+ <host>clickhouse-aux</host>+ <port>9000</port>+ </replica>+ </shard>+ </aux>+ <ops>+ <shard>+ <replica>+ <host>clickhouse-ops</host>+ <port>9000</port>+ </replica>+ </shard>+ </ops>+ <sessions>+ <shard>+ <replica>+ <host>clickhouse-sessions</host>+ <port>9000</port>+ </replica>+ </shard>+ </sessions>+ <logs>+ <shard>+ <replica>+ <host>clickhouse-logs</host>+ <port>9000</port>+ </replica>+ </shard>+ </logs>+ </remote_servers>++ <named_collections>+ <msk_cluster>+ <kafka_broker_list from_env="KAFKA_HOSTS"/>+ </msk_cluster>+ <warpstream_ingestion>+ <kafka_broker_list from_env="KAFKA_HOSTS"/>+ </warpstream_ingestion>+ <warpstream_calculated_events>+ <kafka_broker_list from_env="KAFKA_HOSTS"/>+ </warpstream_calculated_events>+ <warpstream_replay>+ <kafka_broker_list from_env="KAFKA_HOSTS"/>+ </warpstream_replay>+ <warpstream_shared>+ <kafka_broker_list from_env="KAFKA_HOSTS"/>+ </warpstream_shared>+ <warpstream_cyclotron>+ <kafka_broker_list from_env="KAFKA_HOSTS"/>+ </warpstream_cyclotron>+ <warpstream_logs>+ <kafka_broker_list from_env="KAFKA_HOSTS"/>+ </warpstream_logs>+ <warpstream_traces>+ <kafka_broker_list from_env="KAFKA_HOSTS"/>+ </warpstream_traces>+ </named_collections>++ <macros>+ <shard>01</shard>+ <replica>small</replica>+ <hostClusterType>online</hostClusterType>+ <hostClusterRole>small</hostClusterRole>+ </macros>+</clickhouse>diff --git a/docker/clickhouse/config.d/multinode/logs_node.xml b/docker/clickhouse/config.d/multinode/logs_node.xmlindex 210f1638c4f7..34a81ffbb6e0 100644--- a/docker/clickhouse/config.d/multinode/logs_node.xml+++ b/docker/clickhouse/config.d/multinode/logs_node.xml@@ -72,6 +72,24 @@<port>9000</port></replica></shard>+ <shard>+ <replica>+ <host>clickhouse-ingestion-events</host>+ <port>9000</port>+ </replica>+ </shard>+ <shard>+ <replica>+ <host>clickhouse-ingestion-small</host>+ <port>9000</port>+ </replica>+ </shard>+ <shard>+ <replica>+ <host>clickhouse-ingestion-medium</host>+ <port>9000</port>+ </replica>+ </shard></posthog_migrations><ai_events>diff --git a/docker/clickhouse/config.d/multinode/ops_node.xml b/docker/clickhouse/config.d/multinode/ops_node.xmlindex 6c2c1ae6e4c5..fb22cf292f6f 100644--- a/docker/clickhouse/config.d/multinode/ops_node.xml+++ b/docker/clickhouse/config.d/multinode/ops_node.xml@@ -72,6 +72,24 @@<port>9000</port></replica></shard>+ <shard>+ <replica>+ <host>clickhouse-ingestion-events</host>+ <port>9000</port>+ </replica>+ </shard>+ <shard>+ <replica>+ <host>clickhouse-ingestion-small</host>+ <port>9000</port>+ </replica>+ </shard>+ <shard>+ <replica>+ <host>clickhouse-ingestion-medium</host>+ <port>9000</port>+ </replica>+ </shard></posthog_migrations><ai_events>diff --git a/docker/clickhouse/config.d/multinode/sessions_node.xml b/docker/clickhouse/config.d/multinode/sessions_node.xmlindex 3fe620f04ad2..7edd307022b7 100644--- a/docker/clickhouse/config.d/multinode/sessions_node.xml+++ b/docker/clickhouse/config.d/multinode/sessions_node.xml@@ -72,6 +72,24 @@<port>9000</port></replica></shard>+ <shard>+ <replica>+ <host>clickhouse-ingestion-events</host>+ <port>9000</port>+ </replica>+ </shard>+ <shard>+ <replica>+ <host>clickhouse-ingestion-small</host>+ <port>9000</port>+ </replica>+ </shard>+ <shard>+ <replica>+ <host>clickhouse-ingestion-medium</host>+ <port>9000</port>+ </replica>+ </shard></posthog_migrations><ai_events>diff --git a/posthog/clickhouse/cluster.py b/posthog/clickhouse/cluster.pyindex 6be3f3a61c39..91eca8c61fc4 100644--- a/posthog/clickhouse/cluster.py+++ b/posthog/clickhouse/cluster.py@@ -71,6 +71,9 @@ _MULTINODE_HOST_PORT_OVERRIDES: dict[str, tuple[str, int]] = {"clickhouse-ops": ("localhost", 9300),"clickhouse-sessions": ("localhost", 9400),"clickhouse-logs": ("localhost", 9500),+ "clickhouse-ingestion-events": ("localhost", 9600),+ "clickhouse-ingestion-small": ("localhost", 9700),+ "clickhouse-ingestion-medium": ("localhost", 9800),}diff --git a/posthog/clickhouse/hcl/README.md b/posthog/clickhouse/hcl/README.mdindex 8800e495bc70..b3fae93e9da1 100644--- a/posthog/clickhouse/hcl/README.md+++ b/posthog/clickhouse/hcl/README.md@@ -5,7 +5,8 @@ Source of truth for satellite ClickHouse clusters, managed declaratively withSchemas are written in HCL, **composed per node** `(env, role)`, verified againstcaptured cluster dumps, and used to generate the migration that applies a change.-Covers the satellite roles (ops, logs, aux, `ai_events`, sessions, sessionsv3, `batch_exports`) in the cloud envs (dev, prod-us, prod-eu) where each exists, plus the local `data` node.+Covers the satellite roles (ops, logs, aux, `ai_events`, sessions, sessionsv3, `batch_exports`) in the cloud envs (dev, prod-us, prod-eu) where each exists, plus the local `data` node and the three ingestion roles (`events`, `small`, `medium`) the multinode stack runs.+The `local-single` env models the plain dev stack, where one server hosts every role's objects under the role `all`, composed as the union of the roles the multinode stack splits across nodes.The prod data clusters carry per-env `mat_` columns, so their goldens and per-env override layers live in posthog-cloud-infra (see [The cloud side](#the-cloud-side-posthog-cloud-infra)).## Model: per-node compositiondiff --git a/posthog/clickhouse/hcl/check-live.sh b/posthog/clickhouse/hcl/check-live.shindex 539e2a0cef5d..ecdc098e2146 100755--- a/posthog/clickhouse/hcl/check-live.sh+++ b/posthog/clickhouse/hcl/check-live.sh@@ -20,8 +20,11 @@ set -euo pipefailHCL=posthog/clickhouse/hclHCLEXP="$HCL/bin/hclexp" # offline wrapper (no cluster network needed)GOLDEN="$HCL/golden"-EXCLUDE="$HCL/exclude.hcl"ENV="${VERIFY_LIVE_ENV:-local-multi}"+# The same exclude dump-live.sh introspected with, so the gate ignores exactly what+# the dump dropped.+EXCLUDE="$HCL/exclude.hcl"+[ -f "$HCL/exclude-$ENV.hcl" ] && EXCLUDE="$HCL/exclude-$ENV.hcl"WARN="${VERIFY_LIVE_WARN:-0}"DUMPDIR="${1:-${LIVE_DUMP_DIR:?dump dir required (pass as arg1 or set LIVE_DUMP_DIR); run dump-live.sh first}}"diff --git a/posthog/clickhouse/hcl/check.sh b/posthog/clickhouse/hcl/check.shindex b4e62abf0f6b..f442cc69ca56 100755--- a/posthog/clickhouse/hcl/check.sh+++ b/posthog/clickhouse/hcl/check.sh@@ -25,6 +25,10 @@ GOLDEN="$HCL/golden"known_drift_skip() {case "$1" inprod-us) echo "query_log_archive_old_ops" ;;+ # writable_error_tracking_issue_fingerprint_embeddings proxies a storage table+ # migration 0155 dropped on DATA; the ingestion-side objects survived because+ # 0155 targeted the wrong role, and 0253's cleanup is cloud-only.+ local-multi|local-single) echo "writable_error_tracking_issue_fingerprint_embeddings" ;;*) echo "" ;;esac}diff --git a/posthog/clickhouse/hcl/codegen/gen_migration.py b/posthog/clickhouse/hcl/codegen/gen_migration.pyindex 90880beb6360..fd20c210b582 100644--- a/posthog/clickhouse/hcl/codegen/gen_migration.py+++ b/posthog/clickhouse/hcl/codegen/gen_migration.py@@ -53,7 +53,31 @@ HCLEXP = os.path.join(HCL_DIR, "bin", "hclexp")# Canonical role order for emitted node_roles (mirrors ALL_ROLES in migration 0273).# Only roles present in the manifest appear; the rest are listed for stable ordering# if/when they are uncommented there.-ROLE_ORDER = ["data", "endpoints", "aux", "ai_events", "sessions", "logs", "ops"]+ROLE_ORDER = ["data", "endpoints", "aux", "ai_events", "sessions", "logs", "ops", "events", "small", "medium"]++# Manifest roles are named after the hostClusterRole macro, which is the NodeRole *value*.+# For most roles the member name is that value uppercased; the ingestion members are not.+NODE_ROLE_MEMBERS = {+ "events": "INGESTION_EVENTS",+ "small": "INGESTION_SMALL",+ "medium": "INGESTION_MEDIUM",+}++# Manifest roles that are modeled for drift detection but are NOT migration targets:+# they have no NodeRole member, so run_sql_with_exceptions cannot address them. A+# statement that also lands on one of these nodes is emitted without it (as it always+# was) and annotated, rather than silently losing the role.+NON_TARGET_ROLES = {+ "batch_exports": "dump-baselined; no NodeRole member",+ "sessionsv3": "dump-baselined; no NodeRole member",+ "all": "the local-single dev node; mirrors what migrations produce",+}++# Envs that mirror what the migrations produce rather than declaring intent, so they+# must not drive codegen. `local-single` is the one-node dev stack: it hosts every+# role's objects under the synthetic role `all`, so planning against it would emit each+# statement a second time, targeted at a role that is not a deploy target.+CODEGEN_SKIP_ENVS = {"local-single"}def run(cmd: list[str]) -> str:@@ -83,12 +107,19 @@ def manifest_roles(env: str) -> list[str]:def golden_name(role: str) -> str:- """Windows-safe on-disk basename for a role's golden/sql files (mirrors lib.sh).+ """On-disk basename for a role's golden/sql files (mirrors lib.sh).`aux` is a reserved DOS device name that can't be a path component on Windows, so- its files are stored as `auxiliary`. The role identity itself is unchanged.+ its files are stored as `auxiliary`. The ingestion roles are named after their+ hostClusterRole macro, which is too terse to read as a filename. The role identity+ itself is unchanged in both cases."""- return {"aux": "auxiliary"}.get(role, role)+ return {+ "aux": "auxiliary",+ "events": "ingestion_events",+ "small": "ingestion_small",+ "medium": "ingestion_medium",+ }.get(role, role)def golden_at_ref(ref: str, env: str, role: str) -> str:@@ -142,6 +173,8 @@ def main() -> None:envs_for_role: dict[str, set[str]] = {}env_roles: OrderedDict[str, list[str]] = OrderedDict() # env -> roles, in manifest orderfor env in manifest_envs():+ if env in CODEGEN_SKIP_ENVS:+ continueenv_roles[env] = manifest_roles(env)for role in env_roles[env]:envs_for_role.setdefault(role, set()).add(env)@@ -188,18 +221,26 @@ def main() -> None:raise SystemExit("No DDL generated — the HCL has no changes vs the goldens.")notes = [f"# UNSAFE (review/recreate by hand): {obj} — {reason}" for obj, reason in sorted(unsafe_notes.items())]+ untargetable_notes: dict[str, str] = {} # object -> roles the migration cannot addressoperations = []for sql in sorted(merged, key=lambda s: order_key[s]):entry = merged[sql]op, roles, envs = entry["op"], entry["roles"], entry["envs"]+ if unknown := sorted(set(roles) - set(ROLE_ORDER) - set(NON_TARGET_ROLES)):+ raise SystemExit(+ f"role(s) {unknown} surfaced by plan but absent from ROLE_ORDER — "+ "add them there (they are migration targets) or to NON_TARGET_ROLES"+ )node_roles = [r for r in ROLE_ORDER if r in roles]+ if untargetable := sorted(set(roles) & set(NON_TARGET_ROLES)):+ untargetable_notes.setdefault(op["object"], ", ".join(f"{r} ({NON_TARGET_ROLES[r]})" for r in untargetable))replicated = op["replicated"]is_alter_repl = op["kind"] == "ALTER" and replicatedsharded = replicated and "data" in roles# Env-specific if the statement is absent from some env that hosts these roles.- full_envs = set().union(*(envs_for_role[r] for r in roles))+ full_envs = set().union(*(envs_for_role.get(r, set()) for r in roles))gate = "" if envs >= full_envs else f" # NOTE: only {sorted(envs)} — gate with settings.CLOUD_DEPLOYMENT"- roles_src = "[" + ", ".join(f"NodeRole.{r.upper()}" for r in node_roles) + "]"+ roles_src = "[" + ", ".join(f"NodeRole.{NODE_ROLE_MEMBERS.get(r, r.upper())}" for r in node_roles) + "]"operations.append(" run_sql_with_exceptions(\n"f" {sql!r},\n"@@ -217,6 +258,10 @@ def main() -> None:"from posthog.clickhouse.client.connection import NodeRole\n""from posthog.clickhouse.client.migration_tools import run_sql_with_exceptions\n\n")+ notes += [+ f"# NOTE: {obj} also lives on non-targetable node(s): {who} — this migration cannot create it there"+ for obj, who in sorted(untargetable_notes.items())+ ]if notes:body += "\n".join(notes) + "\n\n"body += "operations = [\n" + "\n".join(operations) + "\n]\n"diff --git a/posthog/clickhouse/hcl/dump-live.sh b/posthog/clickhouse/hcl/dump-live.shindex 0d882a751342..c0b194f96111 100755--- a/posthog/clickhouse/hcl/dump-live.sh+++ b/posthog/clickhouse/hcl/dump-live.sh@@ -1,12 +1,18 @@#!/usr/bin/env bash-# Convergence gate, step 1 of 2: introspect every node the booted multinode stack-# runs (see tools/infra-scripts/clickhouse-multinode/) into one HCL dump per-# <env>-<role> — the roles listed in ROLES below, one per published port. Step 2-# (check-live.sh) diffs those dumps against the committed golden — offline.-# Splitting keeps the cluster/network-dependent capture separate from the-# deterministic comparison.+# Convergence gate, step 1 of 2: introspect the live nodes of a booted dev stack into+# one HCL dump per <env>-<role>. Step 2 (check-live.sh) diffs those dumps against the+# committed golden — offline. Splitting keeps the cluster/network-dependent capture+# separate from the deterministic comparison.#-# Transient / unmanaged objects are dropped at introspect time via exclude.hcl.+# Two dev stacks, selected by VERIFY_LIVE_ENV:+# local-multi the multinode stack (tools/infra-scripts/clickhouse-multinode/) — one+# server per role, on the published ports below.+# local-single the ordinary docker-compose.dev.yml stack — ONE server, role `all`,+# hosting every role's objects on :9000.+#+# Transient / unmanaged objects are dropped at introspect time via exclude.hcl, or+# exclude-<env>.hcl when that env needs a different set (local-single does: its one+# node legitimately owns objects the satellite nodes only proxy).## Usage: dump-live.sh [outdir]# outdir defaults to $LIVE_DUMP_DIR, else a fresh temp dir. The dir is printed@@ -14,7 +20,7 @@# Keep it under $TMPDIR or the repo so the containerized hclexp can see it.## Env knobs:-# VERIFY_LIVE_ENV=<env> names the dump files (default: local-multi).+# VERIFY_LIVE_ENV=<env> which stack to dump + how the files are named (default: local-multi).# HCLEXP_BIN=<path> local hclexp binary (host network); otherwise a# `--network host` container reaches the published ports.# <ROLE>_HOST/_PORT/_DB override a role's connection (e.g. OPS_PORT=9300).@@ -22,8 +28,9 @@set -euo pipefailHCL=posthog/clickhouse/hcl-EXCLUDE="$HCL/exclude.hcl"ENV="${VERIFY_LIVE_ENV:-local-multi}"+EXCLUDE="$HCL/exclude.hcl"+[ -f "$HCL/exclude-$ENV.hcl" ] && EXCLUDE="$HCL/exclude-$ENV.hcl"CH_USER="${CLICKHOUSE_USER:-default}"CH_PASSWORD="${CLICKHOUSE_PASSWORD:-}"OUTDIR="${1:-${LIVE_DUMP_DIR:-$(mktemp -d "${TMPDIR:-/tmp}/ch-live-dump.XXXXXX")}}"@@ -33,16 +40,27 @@ mkdir -p "$OUTDIR"# Make it world-traversable so the container can read what the host wrote.chmod 0755 "$OUTDIR" 2>/dev/null || true-# Match the published ports in docker-compose.multinode-clickhouse.yml.+# Where each role's node listens.# role default-host default-port default-db-ROLES=(- "data localhost 9000 posthog"- "ops localhost 9300 posthog"- "logs localhost 9500 posthog"- "ai_events localhost 9100 posthog"- "aux localhost 9200 posthog"- "sessions localhost 9400 posthog"-)+if [ "$ENV" = "local-single" ]; then+ # docker-compose.dev.yml: one server, every role's objects on it.+ ROLES=(+ "all localhost 9000 posthog"+ )+else+ # Match the published ports in docker-compose.multinode-clickhouse.yml.+ ROLES=(+ "data localhost 9000 posthog"+ "ops localhost 9300 posthog"+ "logs localhost 9500 posthog"+ "ai_events localhost 9100 posthog"+ "aux localhost 9200 posthog"+ "sessions localhost 9400 posthog"+ "events localhost 9600 posthog"+ "small localhost 9700 posthog"+ "medium localhost 9800 posthog"+ )+fi# Same pin as bin/hclexp; override for a single run via $HCLEXP_IMAGE.HCLEXP_IMAGE="${HCLEXP_IMAGE:-$(cat "$HCL/bin/image.txt")}"diff --git a/posthog/clickhouse/hcl/exclude-local-single.hcl b/posthog/clickhouse/hcl/exclude-local-single.hclnew file mode 100644index 000000000000..c7c05d2987d5--- /dev/null+++ b/posthog/clickhouse/hcl/exclude-local-single.hcl@@ -0,0 +1,46 @@+# Objects the convergence gate skips on the single-node dev ClickHouse (env local-single).+# Same two consumers as exclude.hcl — `hclexp introspect -exclude` in dump-live.sh and+# `hclexp diff -exclude` in check-live.sh — but its cross-cluster proxy class is wrong+# here: on a one-node stack every cluster resolves to this node, so events_main and+# events_recent are real Distributed objects, and `events_batch_export_recent` reads from+# events_recent, so dropping it makes the schema fail validation.+#+# exclude.hcl's `*_staging` / `*_backfill` globs are also too broad for this node — they+# match real objects (web_pre_aggregated_*_staging tables, *_batch_export_backfill views)+# — so this file spells the transient patterns out rather than reusing them wholesale.++exclude {+ # Secret Kafka broker/credential config; never modeled in the goldens.+ object_types = ["named_collection"]++ patterns = [+ # --- transient (ClickHouse atomic CREATE-OR-REPLACE / EXCHANGE) ---+ "_tmp_replace_*",++ # --- migration / ORM scratch ---+ "tmp_*",+ "*_tmp",+ # infi.clickhouse_orm's applied-migration bookkeeping, not schema.+ "infi_clickhouse_orm_migrations",+ "infi_clickhouse_orm_migrations_distributed",++ # --- backups ---+ "*_backup",+ "*_backup_*",++ # --- dropped here, but not on the multinode ingestion node ---+ # Migration 0155 dropped the error-tracking embeddings suite on DATA while the+ # objects were created on INGESTION_SMALL. On one node those are the same node, so+ # the drop landed and roles/ingestion_small declares three objects this node lacks.+ # 0253 cleans them up on the ingestion nodes too, but only on cloud.+ "*error_tracking_issue_fingerprint_embeddings*",++ # --- out-of-band managed, same call as the multinode gate ---+ # Created out-of-band on cloud; what this node ends up with is an accident of DEBUG+ # routing every migration to one node, not declared intent.+ "custom_metrics*",+ # Orphan: no migration or code creates it; roles/coshared/custom_metrics models it+ # for the ops nodes, which do carry it.+ "events_team_daily_stats",+ ]+}diff --git a/posthog/clickhouse/hcl/golden/local-multi/data.hcl b/posthog/clickhouse/hcl/golden/local-multi/data.hclindex 9347ba413bdf..afb8ea713e0c 100644--- a/posthog/clickhouse/hcl/golden/local-multi/data.hcl+++ b/posthog/clickhouse/hcl/golden/local-multi/data.hcl@@ -9796,6 +9796,9 @@ database "posthog" {column "_timestamp" {type = "SimpleAggregateFunction(max, DateTime)"}+ column "retention_period_days" {+ type = "SimpleAggregateFunction(max, Nullable(Int64))"+ }column "is_deleted" {type = "SimpleAggregateFunction(max, UInt8)"default = "0"@@ -9813,9 +9816,6 @@ database "posthog" {column "surfacing_score" {type = "SimpleAggregateFunction(max, Nullable(Float32))"}- column "retention_period_days" {- type = "SimpleAggregateFunction(max, Nullable(Int64))"- }engine "distributed" {cluster_name = "posthog"remote_database = "posthog"diff --git a/posthog/clickhouse/hcl/golden/local-multi/ingestion_events.hcl b/posthog/clickhouse/hcl/golden/local-multi/ingestion_events.hclnew file mode 100644index 000000000000..dbbb9e27d43e--- /dev/null+++ b/posthog/clickhouse/hcl/golden/local-multi/ingestion_events.hcl@@ -0,0 +1,705 @@+node "events" {+ macros = {+ hostClusterRole = "events"+ hostClusterType = "online"+ replica = "events"+ shard = "01"+ }+}++database "posthog" {+ table "kafka_events_json_native_json" {+ column "uuid" {+ type = "UUID"+ }+ column "event" {+ type = "String"+ }+ column "properties" {+ type = "String"+ codec = "ZSTD(3)"+ }+ column "timestamp" {+ type = "DateTime64(6, 'UTC')"+ }+ column "team_id" {+ type = "Int64"+ }+ column "distinct_id" {+ type = "String"+ }+ column "elements_chain" {+ type = "String"+ }+ column "created_at" {+ type = "DateTime64(6, 'UTC')"+ }+ column "person_id" {+ type = "UUID"+ }+ column "person_created_at" {+ type = "DateTime64(3)"+ }+ column "person_properties" {+ type = "String"+ codec = "ZSTD(3)"+ }+ column "group0_properties" {+ type = "String"+ codec = "ZSTD(3)"+ }+ column "group1_properties" {+ type = "String"+ codec = "ZSTD(3)"+ }+ column "group2_properties" {+ type = "String"+ codec = "ZSTD(3)"+ }+ column "group3_properties" {+ type = "String"+ codec = "ZSTD(3)"+ }+ column "group4_properties" {+ type = "String"+ codec = "ZSTD(3)"+ }+ column "group0_created_at" {+ type = "DateTime64(3)"+ }+ column "group1_created_at" {+ type = "DateTime64(3)"+ }+ column "group2_created_at" {+ type = "DateTime64(3)"+ }+ column "group3_created_at" {+ type = "DateTime64(3)"+ }+ column "group4_created_at" {+ type = "DateTime64(3)"+ }+ column "person_mode" {+ type = "Enum8('full'=0, 'propertyless'=1, 'force_upgrade'=2)"+ }+ column "historical_migration" {+ type = "Bool"+ }+ column "dmat_string_0" {+ type = "Nullable(String)"+ }+ column "dmat_string_1" {+ type = "Nullable(String)"+ }+ column "dmat_string_2" {+ type = "Nullable(String)"+ }+ column "dmat_string_3" {+ type = "Nullable(String)"+ }+ column "dmat_string_4" {+ type = "Nullable(String)"+ }+ column "dmat_string_5" {+ type = "Nullable(String)"+ }+ column "dmat_string_6" {+ type = "Nullable(String)"+ }+ column "dmat_string_7" {+ type = "Nullable(String)"+ }+ column "dmat_string_8" {+ type = "Nullable(String)"+ }+ column "dmat_string_9" {+ type = "Nullable(String)"+ }+ engine "kafka" {+ broker_list = "msk_cluster"+ topic_list = "kafka_topic_list = 'clickhouse_events_json'"+ group_name = "kafka_group_name = 'clickhouse_events_json_native_json'"+ format = "kafka_format = 'JSONEachRow'"+ skip_broken_messages = 100+ }+ }++ table "query_log_archive" {+ column "hostname" {+ type = "LowCardinality(String)"+ }+ column "user" {+ type = "LowCardinality(String)"+ }+ column "query_id" {+ type = "String"+ }+ column "initial_query_id" {+ type = "String"+ }+ column "is_initial_query" {+ type = "UInt8"+ }+ column "type" {+ type = "Enum8('QueryStart'=1, 'QueryFinish'=2, 'ExceptionBeforeStart'=3, 'ExceptionWhileProcessing'=4)"+ }+ column "event_date" {+ type = "Date"+ }+ column "event_time" {+ type = "DateTime"+ }+ column "event_time_microseconds" {+ type = "DateTime64(6)"+ }+ column "query_start_time" {+ type = "DateTime"+ }+ column "query_start_time_microseconds" {+ type = "DateTime64(6)"+ }+ column "query_duration_ms" {+ type = "UInt64"+ }+ column "read_rows" {+ type = "UInt64"+ }+ column "read_bytes" {+ type = "UInt64"+ }+ column "written_rows" {+ type = "UInt64"+ }+ column "written_bytes" {+ type = "UInt64"+ }+ column "result_rows" {+ type = "UInt64"+ }+ column "result_bytes" {+ type = "UInt64"+ }+ column "memory_usage" {+ type = "UInt64"+ }+ column "peak_threads_usage" {+ type = "UInt64"+ }+ column "current_database" {+ type = "LowCardinality(String)"+ }+ column "query" {+ type = "String"+ }+ column "formatted_query" {+ type = "String"+ }+ column "normalized_query_hash" {+ type = "UInt64"+ }+ column "query_kind" {+ type = "LowCardinality(String)"+ }+ column "exception_code" {+ type = "Int32"+ }+ column "exception" {+ type = "String"+ }+ column "stack_trace" {+ type = "String"+ }+ column "team_id" {+ type = "Int64"+ }+ column "log_comment" {+ type = "JSON(max_dynamic_paths=256, access_method LowCardinality(String), alert_config_id String, api_key_label String, api_key_mask String, batch_export_id String, chargeable Bool, client_query_id String, cohort_id Int64, `dagster.job_name` String, `dagster.run_id` String, `dagster.tags.owner` String, dashboard_id Int64, experiment_feature_flag_key String, experiment_id Int64, feature LowCardinality(String), id String, insight_id Int64, is_impersonated Bool, kind LowCardinality(String), name String, org_id String, person_on_events_mode LowCardinality(String), product LowCardinality(String), query_type LowCardinality(String), request_name String, route_id String, service_name String, session_id String, table_id String, team_id Int64, `temporal.activity_id` String, `temporal.activity_type` String, `temporal.attempt` Int64, `temporal.workflow_id` String, `temporal.workflow_namespace` String, `temporal.workflow_run_id` String, `temporal.workflow_type` String, user_id Int64, warehouse_query Bool, workflow LowCardinality(String), workload LowCardinality(String), SKIP cache_key, SKIP filter, SKIP hogql_features, SKIP http_referer, SKIP http_request_id, SKIP http_user_agent, SKIP query_settings, SKIP timings, SKIP user_email)"+ }+ column "ProfileEvents" {+ type = "Map(String, UInt64)"+ }+ column "exception_name" {+ type = "String"+ alias = "errorCodeToName(exception_code)"+ }+ column "ProfileEvents_RealTimeMicroseconds" {+ type = "Int64"+ alias = "ProfileEvents['RealTimeMicroseconds']"+ }+ column "ProfileEvents_OSCPUVirtualTimeMicroseconds" {+ type = "Int64"+ alias = "ProfileEvents['OSCPUVirtualTimeMicroseconds']"+ }+ column "ProfileEvents_S3Clients" {+ type = "Int64"+ alias = "ProfileEvents['S3Clients']"+ }+ column "ProfileEvents_S3DeleteObjects" {+ type = "Int64"+ alias = "ProfileEvents['S3DeleteObjects']"+ }+ column "ProfileEvents_S3CopyObject" {+ type = "Int64"+ alias = "ProfileEvents['S3CopyObject']"+ }+ column "ProfileEvents_S3ListObjects" {+ type = "Int64"+ alias = "ProfileEvents['S3ListObjects']"+ }+ column "ProfileEvents_S3HeadObject" {+ type = "Int64"+ alias = "ProfileEvents['S3HeadObject']"+ }+ column "ProfileEvents_S3GetObjectAttributes" {+ type = "Int64"+ alias = "ProfileEvents['S3GetObjectAttributes']"+ }+ column "ProfileEvents_S3CreateMultipartUpload" {+ type = "Int64"+ alias = "ProfileEvents['S3CreateMultipartUpload']"+ }+ column "ProfileEvents_S3UploadPartCopy" {+ type = "Int64"+ alias = "ProfileEvents['S3UploadPartCopy']"+ }+ column "ProfileEvents_S3UploadPart" {+ type = "Int64"+ alias = "ProfileEvents['S3UploadPart']"+ }+ column "ProfileEvents_S3AbortMultipartUpload" {+ type = "Int64"+ alias = "ProfileEvents['S3AbortMultipartUpload']"+ }+ column "ProfileEvents_S3CompleteMultipartUpload" {+ type = "Int64"+ alias = "ProfileEvents['S3CompleteMultipartUpload']"+ }+ column "ProfileEvents_S3PutObject" {+ type = "Int64"+ alias = "ProfileEvents['S3PutObject']"+ }+ column "ProfileEvents_S3GetObject" {+ type = "Int64"+ alias = "ProfileEvents['S3GetObject']"+ }+ column "ProfileEvents_ReadBufferFromS3Bytes" {+ type = "Int64"+ alias = "ProfileEvents['ReadBufferFromS3Bytes']"+ }+ column "ProfileEvents_WriteBufferFromS3Bytes" {+ type = "Int64"+ alias = "ProfileEvents['WriteBufferFromS3Bytes']"+ }+ column "lc_workflow" {+ type = "LowCardinality(String)"+ alias = "log_comment.workflow"+ }+ column "lc_kind" {+ type = "LowCardinality(String)"+ alias = "log_comment.kind"+ }+ column "lc_id" {+ type = "String"+ alias = "CAST(log_comment.id, 'String')"+ }+ column "lc_route_id" {+ type = "String"+ alias = "CAST(log_comment.route_id, 'String')"+ }+ column "lc_access_method" {+ type = "LowCardinality(String)"+ alias = "log_comment.access_method"+ }+ column "lc_api_key_label" {+ type = "String"+ alias = "CAST(log_comment.api_key_label, 'String')"+ }+ column "lc_api_key_mask" {+ type = "String"+ alias = "CAST(log_comment.api_key_mask, 'String')"+ }+ column "lc_query_type" {+ type = "LowCardinality(String)"+ alias = "log_comment.query_type"+ }+ column "lc_product" {+ type = "LowCardinality(String)"+ alias = "log_comment.product"+ }+ column "lc_chargeable" {+ type = "Bool"+ alias = "log_comment.chargeable"+ }+ column "lc_name" {+ type = "String"+ alias = "CAST(log_comment.name, 'String')"+ }+ column "lc_request_name" {+ type = "String"+ alias = "CAST(log_comment.request_name, 'String')"+ }+ column "lc_client_query_id" {+ type = "String"+ alias = "CAST(log_comment.client_query_id, 'String')"+ }+ column "lc_org_id" {+ type = "String"+ alias = "CAST(log_comment.org_id, 'String')"+ }+ column "lc_user_id" {+ type = "Int64"+ alias = "log_comment.user_id"+ }+ column "lc_is_impersonated" {+ type = "Bool"+ alias = "log_comment.is_impersonated"+ }+ column "lc_session_id" {+ type = "String"+ alias = "CAST(log_comment.session_id, 'String')"+ }+ column "lc_dashboard_id" {+ type = "Int64"+ alias = "log_comment.dashboard_id"+ }+ column "lc_insight_id" {+ type = "Int64"+ alias = "log_comment.insight_id"+ }+ column "lc_cohort_id" {+ type = "Int64"+ alias = "log_comment.cohort_id"+ }+ column "lc_batch_export_id" {+ type = "String"+ alias = "CAST(log_comment.batch_export_id, 'String')"+ }+ column "lc_experiment_id" {+ type = "Int64"+ alias = "log_comment.experiment_id"+ }+ column "lc_experiment_feature_flag_key" {+ type = "String"+ alias = "CAST(log_comment.experiment_feature_flag_key, 'String')"+ }+ column "lc_alert_config_id" {+ type = "String"+ alias = "CAST(log_comment.alert_config_id, 'String')"+ }+ column "lc_feature" {+ type = "LowCardinality(String)"+ alias = "log_comment.feature"+ }+ column "lc_table_id" {+ type = "String"+ alias = "CAST(log_comment.table_id, 'String')"+ }+ column "lc_warehouse_query" {+ type = "Bool"+ alias = "log_comment.warehouse_query"+ }+ column "lc_person_on_events_mode" {+ type = "LowCardinality(String)"+ alias = "log_comment.person_on_events_mode"+ }+ column "lc_service_name" {+ type = "String"+ alias = "CAST(log_comment.service_name, 'String')"+ }+ column "lc_workload" {+ type = "LowCardinality(String)"+ alias = "log_comment.workload"+ }+ column "lc_query__kind" {+ type = "LowCardinality(String)"+ alias = "if(JSONHas(toString(log_comment), 'query', 'source'), JSONExtractString(toString(log_comment), 'query', 'source', 'kind'), JSONExtractString(toString(log_comment), 'query', 'kind'))"+ }+ column "lc_query__query" {+ type = "String"+ alias = "multiIf(NOT is_initial_query, '', JSONHas(toString(log_comment), 'query', 'source'), JSONExtractString(toString(log_comment), 'query', 'source', 'query'), JSONExtractString(toString(log_comment), 'query', 'query'))"+ }+ column "lc_query" {+ type = "String"+ alias = "if(is_initial_query, JSONExtractRaw(toString(log_comment), 'query'), '')"+ }+ column "lc_temporal__workflow_namespace" {+ type = "String"+ alias = "CAST(log_comment.`temporal.workflow_namespace`, 'String')"+ }+ column "lc_temporal__workflow_type" {+ type = "String"+ alias = "CAST(log_comment.`temporal.workflow_type`, 'String')"+ }+ column "lc_temporal__workflow_id" {+ type = "String"+ alias = "CAST(log_comment.`temporal.workflow_id`, 'String')"+ }+ column "lc_temporal__workflow_run_id" {+ type = "String"+ alias = "CAST(log_comment.`temporal.workflow_run_id`, 'String')"+ }+ column "lc_temporal__activity_type" {+ type = "String"+ alias = "CAST(log_comment.`temporal.activity_type`, 'String')"+ }+ column "lc_temporal__activity_id" {+ type = "String"+ alias = "CAST(log_comment.`temporal.activity_id`, 'String')"+ }+ column "lc_temporal__attempt" {+ type = "Int64"+ alias = "log_comment.`temporal.attempt`"+ }+ column "lc_dagster__job_name" {+ type = "String"+ alias = "CAST(log_comment.`dagster.job_name`, 'String')"+ }+ column "lc_dagster__run_id" {+ type = "String"+ alias = "CAST(log_comment.`dagster.run_id`, 'String')"+ }+ column "lc_dagster__owner" {+ type = "String"+ alias = "CAST(log_comment.`dagster.tags.owner`, 'String')"+ }+ column "lc_modifiers" {+ type = "String"+ alias = "if(is_initial_query, JSONExtractRaw(toString(log_comment), 'modifiers'), '')"+ }+ engine "distributed" {+ cluster_name = "ops"+ remote_database = "posthog"+ remote_table = "sharded_query_log_archive"+ }+ }++ table "writable_events_json" {+ column "uuid" {+ type = "UUID"+ }+ column "event" {+ type = "String"+ }+ column "properties" {+ type = "JSON(max_dynamic_types=8, max_dynamic_paths=256, `$active_feature_flags` Array(String), `$ai_experiment_id` Nullable(String), `$ai_http_status` Nullable(String), `$ai_is_error` Nullable(String), `$ai_model` Nullable(String), `$ai_parent_id` Nullable(String), `$ai_prompt_name` Nullable(String), `$ai_provider` Nullable(String), `$ai_session_id` Nullable(String), `$ai_span_id` Nullable(String), `$ai_total_cost_usd` Nullable(String), `$ai_trace_id` Nullable(String), `$anon_distinct_id` Nullable(String), `$app_build` Nullable(String), `$app_namespace` Nullable(String), `$app_version` Nullable(String), `$browser` Nullable(String), `$browser_version` Nullable(String), `$current_url` Nullable(String), `$device` Nullable(String), `$device_id` Nullable(String), `$device_model` Nullable(String), `$device_type` Nullable(String), `$el_text` Nullable(String), `$event_type` Nullable(String), `$exception_fingerprint` Nullable(String), `$exception_functions` Array(String), `$exception_issue_id` Nullable(String), `$exception_sources` Array(String), `$exception_types` Array(String), `$exception_values` Array(String), `$feature_flag` Nullable(String), `$feature_flag_payloads` Nullable(String), `$feature_flag_response` Nullable(String), `$geoip_city_name` Nullable(String), `$geoip_country_code` Nullable(String), `$geoip_country_name` Nullable(String), `$geoip_subdivision_1_code` Nullable(String), `$group_0` Nullable(String), `$group_1` Nullable(String), `$group_2` Nullable(String), `$group_3` Nullable(String), `$group_4` Nullable(String), `$groups` Nullable(String), `$host` Nullable(String), `$initial_pathname` Nullable(String), `$initial_referrer` Nullable(String), `$initial_referring_domain` Nullable(String), `$ip` Nullable(String), `$is_identified` Nullable(String), `$lib` Nullable(String), `$lib_custom_api_host` Nullable(String), `$lib_version` Nullable(String), `$lib_version__minor` Nullable(String), `$os` Nullable(String), `$os_name` Nullable(String), `$os_version` Nullable(String), `$pathname` Nullable(String), `$prev_pageview_max_content_percentage` Nullable(String), `$prev_pageview_max_scroll_percentage` Nullable(String), `$prev_pageview_pathname` Nullable(String), `$process_person_profile` Nullable(String), `$referrer` Nullable(String), `$referring_domain` Nullable(String), `$screen_height` Nullable(String), `$screen_name` Nullable(String), `$screen_width` Nullable(String), `$sent_at` Nullable(String), `$session_id` Nullable(String), `$survey_id` Nullable(String), `$survey_response` Nullable(String), `$survey_response_1` Nullable(String), `$time` Nullable(String), `$user_id` Nullable(String), `$viewport_height` Nullable(String), `$viewport_width` Nullable(String), `$web_vitals_CLS_value` Nullable(String), `$web_vitals_FCP_value` Nullable(String), `$web_vitals_INP_value` Nullable(String), `$web_vitals_LCP_value` Nullable(String), `$window_id` Nullable(String))"+ }+ column "timestamp" {+ type = "DateTime64(6, 'UTC')"+ }+ column "team_id" {+ type = "Int64"+ }+ column "distinct_id" {+ type = "String"+ }+ column "elements_hash" {+ type = "String"+ default = "''"+ }+ column "created_at" {+ type = "DateTime64(6, 'UTC')"+ }+ column "_timestamp" {+ type = "DateTime"+ }+ column "_offset" {+ type = "UInt64"+ }+ column "elements_chain" {+ type = "String"+ }+ column "person_id" {+ type = "UUID"+ }+ column "person_properties" {+ type = "JSON(max_dynamic_types=6, max_dynamic_paths=32, `$app_version` Nullable(String), `$browser` Nullable(String), `$current_url` Nullable(String), `$geoip_continent_name` Nullable(String), `$geoip_country_code` Nullable(String), `$geoip_country_name` Nullable(String), `$initial_current_url` Nullable(String), `$initial_fbclid` Nullable(String), `$initial_gad_source` Nullable(String), `$initial_gbraid` Nullable(String), `$initial_gclid` Nullable(String), `$initial_msclkid` Nullable(String), `$initial_pathname` Nullable(String), `$initial_referring_domain` Nullable(String), `$initial_utm_campaign` Nullable(String), `$initial_utm_content` Nullable(String), `$initial_utm_medium` Nullable(String), `$initial_utm_source` Nullable(String), `$initial_utm_term` Nullable(String), `$initial_wbraid` Nullable(String), `$os_name` Nullable(String), `$referring_domain` Nullable(String))"+ }+ column "group0_properties" {+ type = "String"+ codec = "ZSTD(3)"+ }+ column "group1_properties" {+ type = "String"+ codec = "ZSTD(3)"+ }+ column "group2_properties" {+ type = "String"+ codec = "ZSTD(3)"+ }+ column "group3_properties" {+ type = "String"+ codec = "ZSTD(3)"+ }+ column "group4_properties" {+ type = "String"+ codec = "ZSTD(3)"+ }+ column "person_created_at" {+ type = "DateTime64(3)"+ }+ column "group0_created_at" {+ type = "DateTime64(3)"+ }+ column "group1_created_at" {+ type = "DateTime64(3)"+ }+ column "group2_created_at" {+ type = "DateTime64(3)"+ }+ column "group3_created_at" {+ type = "DateTime64(3)"+ }+ column "group4_created_at" {+ type = "DateTime64(3)"+ }+ column "inserted_at" {+ type = "Nullable(DateTime64(6, 'UTC'))"+ default = "now64()"+ }+ column "person_mode" {+ type = "Enum8('full'=0, 'propertyless'=1, 'force_upgrade'=2)"+ }+ column "is_deleted" {+ type = "Bool"+ default = "false"+ }+ column "consumer_breadcrumbs" {+ type = "Array(String)"+ }+ column "historical_migration" {+ type = "Bool"+ default = "false"+ }+ engine "distributed" {+ cluster_name = "posthog"+ remote_database = "posthog"+ remote_table = "sharded_events_json"+ sharding_key = "sipHash64(distinct_id)"+ }+ }++ materialized_view "events_json_table_mv" {+ to_table = "posthog.writable_events_json"+ query = <<SQL+SELECT+ uuid,+ event,+ ifNull(+ accurateCastOrNull(properties, 'JSON'),+ CAST(concat('{"$unparseable_properties":', toJSONString(properties), '}'), 'JSON')+ ) AS properties,+ timestamp,+ team_id,+ distinct_id,+ elements_chain,+ created_at,+ person_id,+ person_created_at,+ ifNull(+ accurateCastOrNull(person_properties, 'JSON'),+ CAST(concat('{"$unparseable_properties":', toJSONString(person_properties), '}'), 'JSON')+ ) AS person_properties,+ group0_properties,+ group1_properties,+ group2_properties,+ group3_properties,+ group4_properties,+ group0_created_at,+ group1_created_at,+ group2_created_at,+ group3_created_at,+ group4_created_at,+ person_mode,+ historical_migration,+ _timestamp,+ _offset,+ arrayMap(+ i -> (_headers.value[i]),+ arrayFilter(+ i -> ((_headers.name[i]) = 'kafka-consumer-breadcrumbs'),+ arrayEnumerate(_headers.name)+ )+ ) AS consumer_breadcrumbs+FROM posthog.kafka_events_json_native_json+SQL++ column "uuid" {+ type = "UUID"+ }+ column "event" {+ type = "String"+ }+ column "properties" {+ type = "JSON"+ }+ column "timestamp" {+ type = "DateTime64(6, 'UTC')"+ }+ column "team_id" {+ type = "Int64"+ }+ column "distinct_id" {+ type = "String"+ }+ column "elements_chain" {+ type = "String"+ }+ column "created_at" {+ type = "DateTime64(6, 'UTC')"+ }+ column "person_id" {+ type = "UUID"+ }+ column "person_created_at" {+ type = "DateTime64(3)"+ }+ column "person_properties" {+ type = "JSON"+ }+ column "group0_properties" {+ type = "String"+ }+ column "group1_properties" {+ type = "String"+ }+ column "group2_properties" {+ type = "String"+ }+ column "group3_properties" {+ type = "String"+ }+ column "group4_properties" {+ type = "String"+ }+ column "group0_created_at" {+ type = "DateTime64(3)"+ }+ column "group1_created_at" {+ type = "DateTime64(3)"+ }+ column "group2_created_at" {+ type = "DateTime64(3)"+ }+ column "group3_created_at" {+ type = "DateTime64(3)"+ }+ column "group4_created_at" {+ type = "DateTime64(3)"+ }+ column "person_mode" {+ type = "Enum8('full'=0, 'propertyless'=1, 'force_upgrade'=2)"+ }+ column "historical_migration" {+ type = "Bool"+ }+ column "_timestamp" {+ type = "Nullable(DateTime)"+ }+ column "_offset" {+ type = "UInt64"+ }+ column "consumer_breadcrumbs" {+ type = "Array(String)"+ }+ }+}diff --git a/posthog/clickhouse/hcl/golden/local-multi/ingestion_medium.hcl b/posthog/clickhouse/hcl/golden/local-multi/ingestion_medium.hclnew file mode 100644index 000000000000..9fa68e5c3f17--- /dev/null+++ b/posthog/clickhouse/hcl/golden/local-multi/ingestion_medium.hcl@@ -0,0 +1,2305 @@+node "medium" {+ macros = {+ hostClusterRole = "medium"+ hostClusterType = "online"+ replica = "medium"+ shard = "01"+ }+}++database "posthog" {+ table "kafka_app_metrics2" {+ column "team_id" {+ type = "Int64"+ }+ column "timestamp" {+ type = "DateTime64(6, 'UTC')"+ }+ column "app_source" {+ type = "LowCardinality(String)"+ }+ column "app_source_id" {+ type = "String"+ }+ column "instance_id" {+ type = "String"+ }+ column "metric_kind" {+ type = "String"+ }+ column "metric_name" {+ type = "String"+ }+ column "count" {+ type = "Int64"+ }+ engine "kafka" {+ broker_list = "msk_cluster"+ topic_list = "kafka_topic_list = 'clickhouse_app_metrics2'"+ group_name = "kafka_group_name = 'group1'"+ format = "kafka_format = 'JSONEachRow'"+ }+ }++ table "kafka_app_metrics2_ws" {+ column "team_id" {+ type = "Int64"+ }+ column "timestamp" {+ type = "DateTime64(6, 'UTC')"+ }+ column "app_source" {+ type = "LowCardinality(String)"+ }+ column "app_source_id" {+ type = "String"+ }+ column "instance_id" {+ type = "String"+ }+ column "metric_kind" {+ type = "String"+ }+ column "metric_name" {+ type = "String"+ }+ column "count" {+ type = "Int64"+ }+ engine "kafka" {+ broker_list = "warpstream_ingestion"+ topic_list = "kafka_topic_list = 'clickhouse_app_metrics2'"+ group_name = "kafka_group_name = 'clickhouse_app_metrics2_ws'"+ format = "kafka_format = 'JSONEachRow'"+ }+ }++ table "kafka_cohort_membership" {+ column "team_id" {+ type = "Int64"+ }+ column "cohort_id" {+ type = "Int64"+ }+ column "person_id" {+ type = "UUID"+ }+ column "status" {+ type = "Enum8('entered'=1, 'left'=2, 'member'=3, 'not_member'=4)"+ }+ column "last_updated" {+ type = "DateTime64(6)"+ }+ engine "kafka" {+ broker_list = "msk_cluster"+ topic_list = "kafka_topic_list = 'cohort_membership_changed'"+ group_name = "kafka_group_name = 'clickhouse_cohort_membership_changed'"+ format = "kafka_format = 'JSONEachRow'"+ }+ }++ table "kafka_distinct_id_usage" {+ column "team_id" {+ type = "Int64"+ }+ column "distinct_id" {+ type = "String"+ }+ column "timestamp" {+ type = "DateTime64(6, 'UTC')"+ }+ engine "kafka" {+ broker_list = "warpstream_ingestion"+ topic_list = "kafka_topic_list = 'distinct_id_usage_events_json'"+ group_name = "kafka_group_name = 'clickhouse_distinct_id_usage'"+ format = "kafka_format = 'JSONEachRow'"+ skip_broken_messages = 100+ }+ }++ table "kafka_flag_evaluations" {+ column "uuid" {+ type = "UUID"+ }+ column "event" {+ type = "LowCardinality(String)"+ }+ column "properties" {+ type = "String"+ }+ column "timestamp" {+ type = "DateTime64(6, 'UTC')"+ }+ column "team_id" {+ type = "Int64"+ }+ column "distinct_id" {+ type = "String"+ }+ column "created_at" {+ type = "DateTime64(6, 'UTC')"+ }+ column "person_id" {+ type = "UUID"+ }+ column "person_properties" {+ type = "String"+ }+ column "group0_properties" {+ type = "String"+ }+ column "group1_properties" {+ type = "String"+ }+ column "group2_properties" {+ type = "String"+ }+ column "group3_properties" {+ type = "String"+ }+ column "group4_properties" {+ type = "String"+ }+ column "inserted_at" {+ type = "DateTime64(6, 'UTC')"+ }+ engine "kafka" {+ broker_list = "warpstream_ingestion"+ topic_list = "kafka_topic_list = 'clickhouse_flag_evaluations'"+ group_name = "kafka_group_name = 'clickhouse_flag_evaluations'"+ format = "kafka_format = 'JSONEachRow'"+ skip_broken_messages = 100+ }+ }++ table "kafka_heatmaps" {+ column "session_id" {+ type = "String"+ }+ column "team_id" {+ type = "Int64"+ }+ column "distinct_id" {+ type = "String"+ }+ column "timestamp" {+ type = "DateTime64(6, 'UTC')"+ }+ column "x" {+ type = "Int16"+ }+ column "y" {+ type = "Int16"+ }+ column "scale_factor" {+ type = "Int16"+ }+ column "viewport_width" {+ type = "Int16"+ }+ column "viewport_height" {+ type = "Int16"+ }+ column "pointer_target_fixed" {+ type = "Bool"+ }+ column "current_url" {+ type = "String"+ }+ column "type" {+ type = "LowCardinality(String)"+ }+ engine "kafka" {+ broker_list = "msk_cluster"+ topic_list = "kafka_topic_list = 'clickhouse_heatmap_events'"+ group_name = "kafka_group_name = 'group1'"+ format = "kafka_format = 'JSONEachRow'"+ }+ }++ table "kafka_precalculated_events" {+ column "team_id" {+ type = "Int64"+ }+ column "date" {+ type = "Nullable(Date)"+ }+ column "distinct_id" {+ type = "String"+ }+ column "person_id" {+ type = "UUID"+ }+ column "condition" {+ type = "String"+ }+ column "uuid" {+ type = "UUID"+ }+ column "source" {+ type = "String"+ }+ engine "kafka" {+ broker_list = "msk_cluster"+ topic_list = "kafka_topic_list = 'clickhouse_prefiltered_events'"+ group_name = "kafka_group_name = 'clickhouse_prefiltered_events'"+ format = "kafka_format = 'JSONEachRow'"+ num_consumers = 1+ max_block_size = 1000000+ skip_broken_messages = 100+ poll_timeout_ms = 1000+ poll_max_batch_size = 100000+ flush_interval_ms = 7500+ }+ }++ table "kafka_precalculated_person_properties" {+ column "team_id" {+ type = "Int64"+ }+ column "distinct_id" {+ type = "String"+ }+ column "person_id" {+ type = "UUID"+ }+ column "condition" {+ type = "String"+ }+ column "matches" {+ type = "Bool"+ }+ column "source" {+ type = "String"+ }+ engine "kafka" {+ broker_list = "msk_cluster"+ topic_list = "kafka_topic_list = 'clickhouse_precalculated_person_properties'"+ group_name = "kafka_group_name = 'clickhouse_precalculated_person_properties'"+ format = "kafka_format = 'JSONEachRow'"+ num_consumers = 1+ max_block_size = 1000000+ skip_broken_messages = 100+ poll_timeout_ms = 1000+ poll_max_batch_size = 100000+ flush_interval_ms = 7500+ }+ }++ table "kafka_precalculated_person_properties_ws" {+ column "team_id" {+ type = "Int64"+ }+ column "distinct_id" {+ type = "String"+ }+ column "person_id" {+ type = "UUID"+ }+ column "condition" {+ type = "String"+ }+ column "matches" {+ type = "Bool"+ }+ column "source" {+ type = "String"+ }+ engine "kafka" {+ broker_list = "warpstream_calculated_events"+ topic_list = "kafka_topic_list = 'clickhouse_precalculated_person_properties'"+ group_name = "kafka_group_name = 'clickhouse_precalculated_person_properties_ws'"+ format = "kafka_format = 'JSONEachRow'"+ num_consumers = 1+ max_block_size = 1000000+ skip_broken_messages = 100+ poll_timeout_ms = 1000+ poll_max_batch_size = 100000+ flush_interval_ms = 7500+ }+ }++ table "kafka_session_replay_features" {+ column "session_id" {+ type = "String"+ }+ column "team_id" {+ type = "Int64"+ }+ column "distinct_id" {+ type = "String"+ }+ column "batch_id" {+ type = "String"+ }+ column "first_timestamp" {+ type = "DateTime64(6, 'UTC')"+ }+ column "last_timestamp" {+ type = "DateTime64(6, 'UTC')"+ }+ column "event_count" {+ type = "Int64"+ }+ column "mouse_position_count" {+ type = "Int64"+ }+ column "mouse_sum_x" {+ type = "Float64"+ }+ column "mouse_sum_x_squared" {+ type = "Float64"+ }+ column "mouse_sum_y" {+ type = "Float64"+ }+ column "mouse_sum_y_squared" {+ type = "Float64"+ }+ column "mouse_distance_traveled" {+ type = "Float64"+ }+ column "mouse_direction_change_count" {+ type = "Int64"+ }+ column "mouse_velocity_sum" {+ type = "Float64"+ }+ column "mouse_velocity_sum_of_squares" {+ type = "Float64"+ }+ column "mouse_velocity_count" {+ type = "Int64"+ }+ column "scroll_event_count" {+ type = "Int64"+ }+ column "total_scroll_magnitude" {+ type = "Float64"+ }+ column "scroll_direction_reversal_count" {+ type = "Int64"+ }+ column "rapid_scroll_reversal_count" {+ type = "Int64"+ }+ column "scroll_to_top_count" {+ type = "Int64"+ }+ column "click_count" {+ type = "Int64"+ }+ column "keypress_count" {+ type = "Int64"+ }+ column "mouse_activity_count" {+ type = "Int64"+ }+ column "rage_click_count" {+ type = "Int64"+ }+ column "dead_click_count" {+ type = "Int64"+ }+ column "backspace_count" {+ type = "Int64"+ }+ column "inter_action_gap_count" {+ type = "Int64"+ }+ column "inter_action_gap_sum_ms" {+ type = "Float64"+ }+ column "inter_action_gap_sum_of_squares_ms" {+ type = "Float64"+ }+ column "max_idle_gap_ms" {+ type = "Float64"+ }+ column "long_idle_gap_count" {+ type = "Int64"+ }+ column "quick_back_count" {+ type = "Int64"+ }+ column "page_visit_count" {+ type = "Int64"+ }+ column "visited_urls" {+ type = "Array(String)"+ }+ column "login_path_visit_count" {+ type = "Int64"+ }+ column "signup_path_visit_count" {+ type = "Int64"+ }+ column "checkout_path_visit_count" {+ type = "Int64"+ }+ column "cart_path_visit_count" {+ type = "Int64"+ }+ column "billing_path_visit_count" {+ type = "Int64"+ }+ column "settings_path_visit_count" {+ type = "Int64"+ }+ column "account_path_visit_count" {+ type = "Int64"+ }+ column "error_path_visit_count" {+ type = "Int64"+ }+ column "not_found_path_visit_count" {+ type = "Int64"+ }+ column "admin_path_visit_count" {+ type = "Int64"+ }+ column "dashboard_path_visit_count" {+ type = "Int64"+ }+ column "onboarding_path_visit_count" {+ type = "Int64"+ }+ column "cancel_path_visit_count" {+ type = "Int64"+ }+ column "refund_path_visit_count" {+ type = "Int64"+ }+ column "console_error_count" {+ type = "Int64"+ }+ column "console_error_after_click_count" {+ type = "Int64"+ }+ column "console_warn_count" {+ type = "Int64"+ }+ column "network_request_count" {+ type = "Int64"+ }+ column "network_failed_request_count" {+ type = "Int64"+ }+ column "network_4xx_count" {+ type = "Int64"+ }+ column "network_5xx_count" {+ type = "Int64"+ }+ column "network_request_duration_sum" {+ type = "Float64"+ }+ column "network_request_duration_sum_of_squares" {+ type = "Float64"+ }+ column "network_request_duration_count" {+ type = "Int64"+ }+ column "mutation_count" {+ type = "Int64"+ }+ column "viewport_resize_count" {+ type = "Int64"+ }+ column "touch_event_count" {+ type = "Int64"+ }+ column "max_scroll_y" {+ type = "Float64"+ }+ column "click_target_ids" {+ type = "Array(Int64)"+ }+ column "form_field_ids" {+ type = "Array(Int64)"+ }+ column "text_selection_count" {+ type = "Int64"+ }+ column "selection_copy_count" {+ type = "Int64"+ }+ column "is_deleted" {+ type = "UInt8"+ }+ engine "kafka" {+ broker_list = "msk_cluster"+ topic_list = "kafka_topic_list = 'clickhouse_session_replay_features'"+ group_name = "kafka_group_name = 'group1'"+ format = "kafka_format = 'JSONEachRow'"+ }+ }++ table "kafka_tophog" {+ settings = {+ date_time_input_format = "best_effort"+ }+ column "timestamp" {+ type = "DateTime64(6, 'UTC')"+ }+ column "metric" {+ type = "LowCardinality(String)"+ }+ column "type" {+ type = "LowCardinality(String)"+ }+ column "key" {+ type = "Map(LowCardinality(String), String)"+ }+ column "value" {+ type = "Float64"+ }+ column "count" {+ type = "UInt64"+ }+ column "pipeline" {+ type = "LowCardinality(String)"+ }+ column "lane" {+ type = "LowCardinality(String)"+ }+ column "labels" {+ type = "Map(LowCardinality(String), String)"+ }+ engine "kafka" {+ broker_list = "msk_cluster"+ topic_list = "kafka_topic_list = 'clickhouse_tophog'"+ group_name = "kafka_group_name = 'clickhouse_tophog'"+ format = "kafka_format = 'JSONEachRow'"+ skip_broken_messages = 100+ }+ }++ table "kafka_tophog_ws" {+ settings = {+ date_time_input_format = "best_effort"+ }+ column "timestamp" {+ type = "DateTime64(6, 'UTC')"+ }+ column "metric" {+ type = "LowCardinality(String)"+ }+ column "type" {+ type = "LowCardinality(String)"+ }+ column "key" {+ type = "Map(LowCardinality(String), String)"+ }+ column "value" {+ type = "Float64"+ }+ column "count" {+ type = "UInt64"+ }+ column "pipeline" {+ type = "LowCardinality(String)"+ }+ column "lane" {+ type = "LowCardinality(String)"+ }+ column "labels" {+ type = "Map(LowCardinality(String), String)"+ }+ engine "kafka" {+ broker_list = "warpstream_ingestion"+ topic_list = "kafka_topic_list = 'clickhouse_tophog'"+ group_name = "kafka_group_name = 'clickhouse_tophog_ws'"+ format = "kafka_format = 'JSONEachRow'"+ skip_broken_messages = 100+ }+ }++ table "query_log_archive" {+ column "hostname" {+ type = "LowCardinality(String)"+ }+ column "user" {+ type = "LowCardinality(String)"+ }+ column "query_id" {+ type = "String"+ }+ column "initial_query_id" {+ type = "String"+ }+ column "is_initial_query" {+ type = "UInt8"+ }+ column "type" {+ type = "Enum8('QueryStart'=1, 'QueryFinish'=2, 'ExceptionBeforeStart'=3, 'ExceptionWhileProcessing'=4)"+ }+ column "event_date" {+ type = "Date"+ }+ column "event_time" {+ type = "DateTime"+ }+ column "event_time_microseconds" {+ type = "DateTime64(6)"+ }+ column "query_start_time" {+ type = "DateTime"+ }+ column "query_start_time_microseconds" {+ type = "DateTime64(6)"+ }+ column "query_duration_ms" {+ type = "UInt64"+ }+ column "read_rows" {+ type = "UInt64"+ }+ column "read_bytes" {+ type = "UInt64"+ }+ column "written_rows" {+ type = "UInt64"+ }+ column "written_bytes" {+ type = "UInt64"+ }+ column "result_rows" {+ type = "UInt64"+ }+ column "result_bytes" {+ type = "UInt64"+ }+ column "memory_usage" {+ type = "UInt64"+ }+ column "peak_threads_usage" {+ type = "UInt64"+ }+ column "current_database" {+ type = "LowCardinality(String)"+ }+ column "query" {+ type = "String"+ }+ column "formatted_query" {+ type = "String"+ }+ column "normalized_query_hash" {+ type = "UInt64"+ }+ column "query_kind" {+ type = "LowCardinality(String)"+ }+ column "exception_code" {+ type = "Int32"+ }+ column "exception" {+ type = "String"+ }+ column "stack_trace" {+ type = "String"+ }+ column "team_id" {+ type = "Int64"+ }+ column "log_comment" {+ type = "JSON(max_dynamic_paths=256, access_method LowCardinality(String), alert_config_id String, api_key_label String, api_key_mask String, batch_export_id String, chargeable Bool, client_query_id String, cohort_id Int64, `dagster.job_name` String, `dagster.run_id` String, `dagster.tags.owner` String, dashboard_id Int64, experiment_feature_flag_key String, experiment_id Int64, feature LowCardinality(String), id String, insight_id Int64, is_impersonated Bool, kind LowCardinality(String), name String, org_id String, person_on_events_mode LowCardinality(String), product LowCardinality(String), query_type LowCardinality(String), request_name String, route_id String, service_name String, session_id String, table_id String, team_id Int64, `temporal.activity_id` String, `temporal.activity_type` String, `temporal.attempt` Int64, `temporal.workflow_id` String, `temporal.workflow_namespace` String, `temporal.workflow_run_id` String, `temporal.workflow_type` String, user_id Int64, warehouse_query Bool, workflow LowCardinality(String), workload LowCardinality(String), SKIP cache_key, SKIP filter, SKIP hogql_features, SKIP http_referer, SKIP http_request_id, SKIP http_user_agent, SKIP query_settings, SKIP timings, SKIP user_email)"+ }+ column "ProfileEvents" {+ type = "Map(String, UInt64)"+ }+ column "exception_name" {+ type = "String"+ alias = "errorCodeToName(exception_code)"+ }+ column "ProfileEvents_RealTimeMicroseconds" {+ type = "Int64"+ alias = "ProfileEvents['RealTimeMicroseconds']"+ }+ column "ProfileEvents_OSCPUVirtualTimeMicroseconds" {+ type = "Int64"+ alias = "ProfileEvents['OSCPUVirtualTimeMicroseconds']"+ }+ column "ProfileEvents_S3Clients" {+ type = "Int64"+ alias = "ProfileEvents['S3Clients']"+ }+ column "ProfileEvents_S3DeleteObjects" {+ type = "Int64"+ alias = "ProfileEvents['S3DeleteObjects']"+ }+ column "ProfileEvents_S3CopyObject" {+ type = "Int64"+ alias = "ProfileEvents['S3CopyObject']"+ }+ column "ProfileEvents_S3ListObjects" {+ type = "Int64"+ alias = "ProfileEvents['S3ListObjects']"+ }+ column "ProfileEvents_S3HeadObject" {+ type = "Int64"+ alias = "ProfileEvents['S3HeadObject']"+ }+ column "ProfileEvents_S3GetObjectAttributes" {+ type = "Int64"+ alias = "ProfileEvents['S3GetObjectAttributes']"+ }+ column "ProfileEvents_S3CreateMultipartUpload" {+ type = "Int64"+ alias = "ProfileEvents['S3CreateMultipartUpload']"+ }+ column "ProfileEvents_S3UploadPartCopy" {+ type = "Int64"+ alias = "ProfileEvents['S3UploadPartCopy']"+ }+ column "ProfileEvents_S3UploadPart" {+ type = "Int64"+ alias = "ProfileEvents['S3UploadPart']"+ }+ column "ProfileEvents_S3AbortMultipartUpload" {+ type = "Int64"+ alias = "ProfileEvents['S3AbortMultipartUpload']"+ }+ column "ProfileEvents_S3CompleteMultipartUpload" {+ type = "Int64"+ alias = "ProfileEvents['S3CompleteMultipartUpload']"+ }+ column "ProfileEvents_S3PutObject" {+ type = "Int64"+ alias = "ProfileEvents['S3PutObject']"+ }+ column "ProfileEvents_S3GetObject" {+ type = "Int64"+ alias = "ProfileEvents['S3GetObject']"+ }+ column "ProfileEvents_ReadBufferFromS3Bytes" {+ type = "Int64"+ alias = "ProfileEvents['ReadBufferFromS3Bytes']"+ }+ column "ProfileEvents_WriteBufferFromS3Bytes" {+ type = "Int64"+ alias = "ProfileEvents['WriteBufferFromS3Bytes']"+ }+ column "lc_workflow" {+ type = "LowCardinality(String)"+ alias = "log_comment.workflow"+ }+ column "lc_kind" {+ type = "LowCardinality(String)"+ alias = "log_comment.kind"+ }+ column "lc_id" {+ type = "String"+ alias = "CAST(log_comment.id, 'String')"+ }+ column "lc_route_id" {+ type = "String"+ alias = "CAST(log_comment.route_id, 'String')"+ }+ column "lc_access_method" {+ type = "LowCardinality(String)"+ alias = "log_comment.access_method"+ }+ column "lc_api_key_label" {+ type = "String"+ alias = "CAST(log_comment.api_key_label, 'String')"+ }+ column "lc_api_key_mask" {+ type = "String"+ alias = "CAST(log_comment.api_key_mask, 'String')"+ }+ column "lc_query_type" {+ type = "LowCardinality(String)"+ alias = "log_comment.query_type"+ }+ column "lc_product" {+ type = "LowCardinality(String)"+ alias = "log_comment.product"+ }+ column "lc_chargeable" {+ type = "Bool"+ alias = "log_comment.chargeable"+ }+ column "lc_name" {+ type = "String"+ alias = "CAST(log_comment.name, 'String')"+ }+ column "lc_request_name" {+ type = "String"+ alias = "CAST(log_comment.request_name, 'String')"+ }+ column "lc_client_query_id" {+ type = "String"+ alias = "CAST(log_comment.client_query_id, 'String')"+ }+ column "lc_org_id" {+ type = "String"+ alias = "CAST(log_comment.org_id, 'String')"+ }+ column "lc_user_id" {+ type = "Int64"+ alias = "log_comment.user_id"+ }+ column "lc_is_impersonated" {+ type = "Bool"+ alias = "log_comment.is_impersonated"+ }+ column "lc_session_id" {+ type = "String"+ alias = "CAST(log_comment.session_id, 'String')"+ }+ column "lc_dashboard_id" {+ type = "Int64"+ alias = "log_comment.dashboard_id"+ }+ column "lc_insight_id" {+ type = "Int64"+ alias = "log_comment.insight_id"+ }+ column "lc_cohort_id" {+ type = "Int64"+ alias = "log_comment.cohort_id"+ }+ column "lc_batch_export_id" {+ type = "String"+ alias = "CAST(log_comment.batch_export_id, 'String')"+ }+ column "lc_experiment_id" {+ type = "Int64"+ alias = "log_comment.experiment_id"+ }+ column "lc_experiment_feature_flag_key" {+ type = "String"+ alias = "CAST(log_comment.experiment_feature_flag_key, 'String')"+ }+ column "lc_alert_config_id" {+ type = "String"+ alias = "CAST(log_comment.alert_config_id, 'String')"+ }+ column "lc_feature" {+ type = "LowCardinality(String)"+ alias = "log_comment.feature"+ }+ column "lc_table_id" {+ type = "String"+ alias = "CAST(log_comment.table_id, 'String')"+ }+ column "lc_warehouse_query" {+ type = "Bool"+ alias = "log_comment.warehouse_query"+ }+ column "lc_person_on_events_mode" {+ type = "LowCardinality(String)"+ alias = "log_comment.person_on_events_mode"+ }+ column "lc_service_name" {+ type = "String"+ alias = "CAST(log_comment.service_name, 'String')"+ }+ column "lc_workload" {+ type = "LowCardinality(String)"+ alias = "log_comment.workload"+ }+ column "lc_query__kind" {+ type = "LowCardinality(String)"+ alias = "if(JSONHas(toString(log_comment), 'query', 'source'), JSONExtractString(toString(log_comment), 'query', 'source', 'kind'), JSONExtractString(toString(log_comment), 'query', 'kind'))"+ }+ column "lc_query__query" {+ type = "String"+ alias = "multiIf(NOT is_initial_query, '', JSONHas(toString(log_comment), 'query', 'source'), JSONExtractString(toString(log_comment), 'query', 'source', 'query'), JSONExtractString(toString(log_comment), 'query', 'query'))"+ }+ column "lc_query" {+ type = "String"+ alias = "if(is_initial_query, JSONExtractRaw(toString(log_comment), 'query'), '')"+ }+ column "lc_temporal__workflow_namespace" {+ type = "String"+ alias = "CAST(log_comment.`temporal.workflow_namespace`, 'String')"+ }+ column "lc_temporal__workflow_type" {+ type = "String"+ alias = "CAST(log_comment.`temporal.workflow_type`, 'String')"+ }+ column "lc_temporal__workflow_id" {+ type = "String"+ alias = "CAST(log_comment.`temporal.workflow_id`, 'String')"+ }+ column "lc_temporal__workflow_run_id" {+ type = "String"+ alias = "CAST(log_comment.`temporal.workflow_run_id`, 'String')"+ }+ column "lc_temporal__activity_type" {+ type = "String"+ alias = "CAST(log_comment.`temporal.activity_type`, 'String')"+ }+ column "lc_temporal__activity_id" {+ type = "String"+ alias = "CAST(log_comment.`temporal.activity_id`, 'String')"+ }+ column "lc_temporal__attempt" {+ type = "Int64"+ alias = "log_comment.`temporal.attempt`"+ }+ column "lc_dagster__job_name" {+ type = "String"+ alias = "CAST(log_comment.`dagster.job_name`, 'String')"+ }+ column "lc_dagster__run_id" {+ type = "String"+ alias = "CAST(log_comment.`dagster.run_id`, 'String')"+ }+ column "lc_dagster__owner" {+ type = "String"+ alias = "CAST(log_comment.`dagster.tags.owner`, 'String')"+ }+ column "lc_modifiers" {+ type = "String"+ alias = "if(is_initial_query, JSONExtractRaw(toString(log_comment), 'modifiers'), '')"+ }+ engine "distributed" {+ cluster_name = "ops"+ remote_database = "posthog"+ remote_table = "sharded_query_log_archive"+ }+ }++ table "writable_app_metrics2" {+ column "team_id" {+ type = "Int64"+ }+ column "timestamp" {+ type = "DateTime64(6, 'UTC')"+ }+ column "app_source" {+ type = "LowCardinality(String)"+ }+ column "app_source_id" {+ type = "String"+ }+ column "instance_id" {+ type = "String"+ }+ column "metric_kind" {+ type = "LowCardinality(String)"+ }+ column "metric_name" {+ type = "LowCardinality(String)"+ }+ column "count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "_timestamp" {+ type = "DateTime"+ }+ column "_offset" {+ type = "UInt64"+ }+ column "_partition" {+ type = "UInt64"+ }+ engine "distributed" {+ cluster_name = "posthog"+ remote_database = "posthog"+ remote_table = "sharded_app_metrics2"+ sharding_key = "rand()"+ }+ }++ table "writable_cohort_membership" {+ column "team_id" {+ type = "Int64"+ }+ column "cohort_id" {+ type = "Int64"+ }+ column "person_id" {+ type = "UUID"+ }+ column "status" {+ type = "Enum8('entered'=1, 'left'=2)"+ }+ column "last_updated" {+ type = "DateTime64(6)"+ default = "now64()"+ }+ engine "distributed" {+ cluster_name = "posthog_single_shard"+ remote_database = "posthog"+ remote_table = "cohort_membership"+ }+ }++ table "writable_distinct_id_usage" {+ column "team_id" {+ type = "Int64"+ }+ column "distinct_id" {+ type = "String"+ }+ column "minute" {+ type = "DateTime"+ }+ column "event_count" {+ type = "UInt64"+ }+ engine "distributed" {+ cluster_name = "posthog"+ remote_database = "posthog"+ remote_table = "sharded_distinct_id_usage"+ sharding_key = "sipHash64(distinct_id)"+ }+ }++ table "writable_flag_evaluations" {+ column "uuid" {+ type = "UUID"+ }+ column "event" {+ type = "LowCardinality(String)"+ }+ column "properties" {+ type = "String"+ }+ column "timestamp" {+ type = "DateTime64(6, 'UTC')"+ }+ column "team_id" {+ type = "Int64"+ }+ column "distinct_id" {+ type = "String"+ }+ column "created_at" {+ type = "DateTime64(6, 'UTC')"+ }+ column "person_id" {+ type = "UUID"+ }+ column "person_properties" {+ type = "String"+ }+ column "group0_properties" {+ type = "String"+ }+ column "group1_properties" {+ type = "String"+ }+ column "group2_properties" {+ type = "String"+ }+ column "group3_properties" {+ type = "String"+ }+ column "group4_properties" {+ type = "String"+ }+ column "inserted_at" {+ type = "DateTime64(6, 'UTC')"+ default = "timestamp"+ }+ column "_timestamp" {+ type = "DateTime"+ }+ column "_offset" {+ type = "UInt64"+ }+ column "_partition" {+ type = "UInt64"+ }+ engine "distributed" {+ cluster_name = "posthog"+ remote_database = "posthog"+ remote_table = "sharded_flag_evaluations"+ sharding_key = "sipHash64(distinct_id)"+ }+ }++ table "writable_heatmaps" {+ column "session_id" {+ type = "String"+ }+ column "team_id" {+ type = "Int64"+ }+ column "distinct_id" {+ type = "String"+ }+ column "timestamp" {+ type = "DateTime64(6, 'UTC')"+ }+ column "x" {+ type = "Int16"+ }+ column "y" {+ type = "Int16"+ }+ column "scale_factor" {+ type = "Int16"+ }+ column "viewport_width" {+ type = "Int16"+ }+ column "viewport_height" {+ type = "Int16"+ }+ column "pointer_target_fixed" {+ type = "Bool"+ }+ column "current_url" {+ type = "String"+ }+ column "type" {+ type = "LowCardinality(String)"+ }+ column "_timestamp" {+ type = "DateTime"+ }+ column "_offset" {+ type = "UInt64"+ }+ column "_partition" {+ type = "UInt64"+ }+ engine "distributed" {+ cluster_name = "posthog"+ remote_database = "posthog"+ remote_table = "sharded_heatmaps"+ sharding_key = "cityHash64(concat(toString(team_id), '-', session_id, '-', toString(toDate(timestamp))))"+ }+ }++ table "writable_precalculated_events" {+ column "team_id" {+ type = "Int64"+ }+ column "date" {+ type = "Date"+ }+ column "distinct_id" {+ type = "String"+ }+ column "person_id" {+ type = "UUID"+ }+ column "condition" {+ type = "String"+ }+ column "uuid" {+ type = "UUID"+ }+ column "source" {+ type = "String"+ }+ column "_timestamp" {+ type = "DateTime64(6)"+ }+ column "_partition" {+ type = "UInt64"+ }+ column "_offset" {+ type = "UInt64"+ }+ engine "distributed" {+ cluster_name = "posthog"+ remote_database = "posthog"+ remote_table = "sharded_precalculated_events"+ sharding_key = "sipHash64(distinct_id)"+ }+ }++ table "writable_precalculated_person_properties" {+ column "team_id" {+ type = "Int64"+ }+ column "distinct_id" {+ type = "String"+ }+ column "person_id" {+ type = "UUID"+ }+ column "condition" {+ type = "String"+ }+ column "matches" {+ type = "Bool"+ }+ column "source" {+ type = "String"+ }+ column "_timestamp" {+ type = "DateTime64(6)"+ }+ column "_offset" {+ type = "UInt64"+ }+ engine "distributed" {+ cluster_name = "posthog"+ remote_database = "posthog"+ remote_table = "sharded_precalculated_person_properties"+ sharding_key = "sipHash64(distinct_id)"+ }+ }++ table "writable_session_replay_features" {+ column "session_id" {+ type = "String"+ }+ column "team_id" {+ type = "Int64"+ }+ column "distinct_id" {+ type = "String"+ }+ column "min_first_timestamp" {+ type = "SimpleAggregateFunction(min, DateTime64(6, 'UTC'))"+ }+ column "max_last_timestamp" {+ type = "SimpleAggregateFunction(max, DateTime64(6, 'UTC'))"+ }+ column "event_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "mouse_position_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "mouse_sum_x" {+ type = "SimpleAggregateFunction(sum, Float64)"+ }+ column "mouse_sum_x_squared" {+ type = "SimpleAggregateFunction(sum, Float64)"+ }+ column "mouse_sum_y" {+ type = "SimpleAggregateFunction(sum, Float64)"+ }+ column "mouse_sum_y_squared" {+ type = "SimpleAggregateFunction(sum, Float64)"+ }+ column "mouse_distance_traveled" {+ type = "SimpleAggregateFunction(sum, Float64)"+ }+ column "mouse_direction_change_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "mouse_velocity_sum" {+ type = "SimpleAggregateFunction(sum, Float64)"+ }+ column "mouse_velocity_sum_of_squares" {+ type = "SimpleAggregateFunction(sum, Float64)"+ }+ column "mouse_velocity_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "scroll_event_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "total_scroll_magnitude" {+ type = "SimpleAggregateFunction(sum, Float64)"+ }+ column "scroll_direction_reversal_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "rapid_scroll_reversal_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "scroll_to_top_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "click_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "keypress_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "mouse_activity_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "rage_click_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "dead_click_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "backspace_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "inter_action_gap_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "inter_action_gap_sum_ms" {+ type = "SimpleAggregateFunction(sum, Float64)"+ }+ column "inter_action_gap_sum_of_squares_ms" {+ type = "SimpleAggregateFunction(sum, Float64)"+ }+ column "max_idle_gap_ms" {+ type = "SimpleAggregateFunction(max, Float64)"+ }+ column "long_idle_gap_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "quick_back_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "page_visit_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "unique_url_count" {+ type = "AggregateFunction(uniqCombined(12), String)"+ }+ column "login_path_visit_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "signup_path_visit_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "checkout_path_visit_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "cart_path_visit_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "billing_path_visit_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "settings_path_visit_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "account_path_visit_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "error_path_visit_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "not_found_path_visit_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "admin_path_visit_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "dashboard_path_visit_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "onboarding_path_visit_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "cancel_path_visit_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "refund_path_visit_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "console_error_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "console_error_after_click_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "console_warn_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "network_request_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "network_failed_request_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "network_4xx_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "network_5xx_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "network_request_duration_sum" {+ type = "SimpleAggregateFunction(sum, Float64)"+ }+ column "network_request_duration_sum_of_squares" {+ type = "SimpleAggregateFunction(sum, Float64)"+ }+ column "network_request_duration_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "mutation_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "viewport_resize_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "touch_event_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "max_scroll_y" {+ type = "SimpleAggregateFunction(max, Float64)"+ }+ column "unique_click_target_count" {+ type = "AggregateFunction(uniqCombined(12), Int64)"+ }+ column "unique_form_field_count" {+ type = "AggregateFunction(uniqCombined(12), Int64)"+ }+ column "text_selection_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "selection_copy_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "is_deleted" {+ type = "SimpleAggregateFunction(max, UInt8)"+ default = "0"+ }+ engine "distributed" {+ cluster_name = "aux"+ remote_database = "posthog"+ remote_table = "sharded_session_replay_features"+ sharding_key = "sipHash64(session_id)"+ }+ }++ table "writable_tophog" {+ column "timestamp" {+ type = "DateTime64(6, 'UTC')"+ }+ column "metric" {+ type = "LowCardinality(String)"+ }+ column "type" {+ type = "LowCardinality(String)"+ default = "'sum'"+ }+ column "key" {+ type = "Map(LowCardinality(String), String)"+ }+ column "value" {+ type = "Float64"+ }+ column "count" {+ type = "UInt64"+ default = "0"+ }+ column "pipeline" {+ type = "LowCardinality(String)"+ }+ column "lane" {+ type = "LowCardinality(String)"+ }+ column "labels" {+ type = "Map(LowCardinality(String), String)"+ }+ engine "distributed" {+ cluster_name = "posthog"+ remote_database = "posthog"+ remote_table = "sharded_tophog"+ sharding_key = "cityHash64(toString(key))"+ }+ }++ materialized_view "app_metrics2_mv" {+ to_table = "posthog.writable_app_metrics2"+ query = <<SQL+SELECT+ team_id,+ timestamp,+ app_source,+ app_source_id,+ instance_id,+ metric_kind,+ metric_name,+ count,+ _timestamp,+ _offset,+ _partition+FROM posthog.kafka_app_metrics2+SQL++ column "team_id" {+ type = "Int64"+ }+ column "timestamp" {+ type = "DateTime64(6, 'UTC')"+ }+ column "app_source" {+ type = "LowCardinality(String)"+ }+ column "app_source_id" {+ type = "String"+ }+ column "instance_id" {+ type = "String"+ }+ column "metric_kind" {+ type = "String"+ }+ column "metric_name" {+ type = "String"+ }+ column "count" {+ type = "Int64"+ }+ column "_timestamp" {+ type = "Nullable(DateTime)"+ }+ column "_offset" {+ type = "UInt64"+ }+ column "_partition" {+ type = "UInt64"+ }+ }++ materialized_view "app_metrics2_ws_mv" {+ to_table = "posthog.writable_app_metrics2"+ query = <<SQL+SELECT+ team_id,+ timestamp,+ app_source,+ app_source_id,+ instance_id,+ metric_kind,+ metric_name,+ count,+ _timestamp,+ _offset,+ _partition+FROM posthog.kafka_app_metrics2_ws+SQL++ column "team_id" {+ type = "Int64"+ }+ column "timestamp" {+ type = "DateTime64(6, 'UTC')"+ }+ column "app_source" {+ type = "LowCardinality(String)"+ }+ column "app_source_id" {+ type = "String"+ }+ column "instance_id" {+ type = "String"+ }+ column "metric_kind" {+ type = "String"+ }+ column "metric_name" {+ type = "String"+ }+ column "count" {+ type = "Int64"+ }+ column "_timestamp" {+ type = "Nullable(DateTime)"+ }+ column "_offset" {+ type = "UInt64"+ }+ column "_partition" {+ type = "UInt64"+ }+ }++ materialized_view "cohort_membership_mv" {+ to_table = "posthog.writable_cohort_membership"+ query = <<SQL+SELECT+ team_id,+ cohort_id,+ person_id,+ multiIf(status = 'member', 'entered', status = 'not_member', 'left', status) AS status,+ last_updated+FROM posthog.kafka_cohort_membership+SQL++ column "team_id" {+ type = "Int64"+ }+ column "cohort_id" {+ type = "Int64"+ }+ column "person_id" {+ type = "UUID"+ }+ column "status" {+ type = "String"+ }+ column "last_updated" {+ type = "DateTime64(6)"+ }+ }++ materialized_view "distinct_id_usage_mv" {+ to_table = "posthog.writable_distinct_id_usage"+ query = <<SQL+SELECT team_id, distinct_id, toStartOfMinute(timestamp) AS minute, 1 AS event_count+FROM posthog.kafka_distinct_id_usage+SQL++ column "team_id" {+ type = "Int64"+ }+ column "distinct_id" {+ type = "String"+ }+ column "minute" {+ type = "DateTime('UTC')"+ }+ column "event_count" {+ type = "UInt8"+ }+ }++ materialized_view "flag_evaluations_mv" {+ to_table = "posthog.writable_flag_evaluations"+ query = <<SQL+SELECT+ uuid,+ event,+ properties,+ timestamp,+ team_id,+ distinct_id,+ created_at,+ person_id,+ person_properties,+ group0_properties,+ group1_properties,+ group2_properties,+ group3_properties,+ group4_properties,+ if(inserted_at = toDateTime64('1970-01-01 00:00:00', 6, 'UTC'), _timestamp, inserted_at) AS inserted_at,+ _timestamp,+ _offset,+ _partition+FROM posthog.kafka_flag_evaluations+SQL++ column "uuid" {+ type = "UUID"+ }+ column "event" {+ type = "LowCardinality(String)"+ }+ column "properties" {+ type = "String"+ }+ column "timestamp" {+ type = "DateTime64(6, 'UTC')"+ }+ column "team_id" {+ type = "Int64"+ }+ column "distinct_id" {+ type = "String"+ }+ column "created_at" {+ type = "DateTime64(6, 'UTC')"+ }+ column "person_id" {+ type = "UUID"+ }+ column "person_properties" {+ type = "String"+ }+ column "group0_properties" {+ type = "String"+ }+ column "group1_properties" {+ type = "String"+ }+ column "group2_properties" {+ type = "String"+ }+ column "group3_properties" {+ type = "String"+ }+ column "group4_properties" {+ type = "String"+ }+ column "inserted_at" {+ type = "Nullable(DateTime64(6, 'UTC'))"+ }+ column "_timestamp" {+ type = "Nullable(DateTime)"+ }+ column "_offset" {+ type = "UInt64"+ }+ column "_partition" {+ type = "UInt64"+ }+ }++ materialized_view "heatmaps_mv" {+ to_table = "posthog.writable_heatmaps"+ query = <<SQL+SELECT+ session_id,+ team_id,+ distinct_id,+ timestamp,+ x,+ y,+ scale_factor,+ viewport_width,+ viewport_height,+ pointer_target_fixed,+ current_url,+ type,+ _timestamp,+ _offset,+ _partition+FROM posthog.kafka_heatmaps+SQL++ column "session_id" {+ type = "String"+ }+ column "team_id" {+ type = "Int64"+ }+ column "distinct_id" {+ type = "String"+ }+ column "timestamp" {+ type = "DateTime64(6, 'UTC')"+ }+ column "x" {+ type = "Int16"+ }+ column "y" {+ type = "Int16"+ }+ column "scale_factor" {+ type = "Int16"+ }+ column "viewport_width" {+ type = "Int16"+ }+ column "viewport_height" {+ type = "Int16"+ }+ column "pointer_target_fixed" {+ type = "Bool"+ }+ column "current_url" {+ type = "String"+ }+ column "type" {+ type = "LowCardinality(String)"+ }+ column "_timestamp" {+ type = "Nullable(DateTime)"+ }+ column "_offset" {+ type = "UInt64"+ }+ column "_partition" {+ type = "UInt64"+ }+ }++ materialized_view "precalculated_events_mv" {+ to_table = "posthog.writable_precalculated_events"+ query = <<SQL+SELECT+ team_id,+ ifNull(date, toDate(_timestamp)) AS date,+ distinct_id,+ person_id,+ condition,+ uuid,+ source,+ _timestamp,+ _offset,+ _partition+FROM posthog.kafka_precalculated_events+SQL++ column "team_id" {+ type = "Int64"+ }+ column "date" {+ type = "Nullable(Date)"+ }+ column "distinct_id" {+ type = "String"+ }+ column "person_id" {+ type = "UUID"+ }+ column "condition" {+ type = "String"+ }+ column "uuid" {+ type = "UUID"+ }+ column "source" {+ type = "String"+ }+ column "_timestamp" {+ type = "Nullable(DateTime)"+ }+ column "_offset" {+ type = "UInt64"+ }+ column "_partition" {+ type = "UInt64"+ }+ }++ materialized_view "precalculated_person_properties_mv" {+ to_table = "posthog.writable_precalculated_person_properties"+ query = <<SQL+SELECT+ team_id,+ distinct_id,+ person_id,+ condition,+ matches,+ source,+ _timestamp,+ _offset+FROM posthog.kafka_precalculated_person_properties+SQL++ column "team_id" {+ type = "Int64"+ }+ column "distinct_id" {+ type = "String"+ }+ column "person_id" {+ type = "UUID"+ }+ column "condition" {+ type = "String"+ }+ column "matches" {+ type = "Bool"+ }+ column "source" {+ type = "String"+ }+ column "_timestamp" {+ type = "Nullable(DateTime)"+ }+ column "_offset" {+ type = "UInt64"+ }+ }++ materialized_view "precalculated_person_properties_ws_mv" {+ to_table = "posthog.writable_precalculated_person_properties"+ query = <<SQL+SELECT+ team_id,+ distinct_id,+ person_id,+ condition,+ matches,+ source,+ _timestamp,+ _offset+FROM posthog.kafka_precalculated_person_properties_ws+SQL++ column "team_id" {+ type = "Int64"+ }+ column "distinct_id" {+ type = "String"+ }+ column "person_id" {+ type = "UUID"+ }+ column "condition" {+ type = "String"+ }+ column "matches" {+ type = "Bool"+ }+ column "source" {+ type = "String"+ }+ column "_timestamp" {+ type = "Nullable(DateTime)"+ }+ column "_offset" {+ type = "UInt64"+ }+ }++ materialized_view "session_replay_features_mv" {+ to_table = "posthog.writable_session_replay_features"+ query = <<SQL+SELECT+ session_id,+ team_id,+ any(distinct_id) AS distinct_id,+ min(first_timestamp) AS min_first_timestamp,+ max(last_timestamp) AS max_last_timestamp,+ sum(event_count) AS event_count,+ sum(mouse_position_count) AS mouse_position_count,+ sum(mouse_sum_x) AS mouse_sum_x,+ sum(mouse_sum_x_squared) AS mouse_sum_x_squared,+ sum(mouse_sum_y) AS mouse_sum_y,+ sum(mouse_sum_y_squared) AS mouse_sum_y_squared,+ sum(mouse_distance_traveled) AS mouse_distance_traveled,+ sum(mouse_direction_change_count) AS mouse_direction_change_count,+ sum(mouse_velocity_sum) AS mouse_velocity_sum,+ sum(mouse_velocity_sum_of_squares) AS mouse_velocity_sum_of_squares,+ sum(mouse_velocity_count) AS mouse_velocity_count,+ sum(scroll_event_count) AS scroll_event_count,+ sum(total_scroll_magnitude) AS total_scroll_magnitude,+ sum(scroll_direction_reversal_count) AS scroll_direction_reversal_count,+ sum(rapid_scroll_reversal_count) AS rapid_scroll_reversal_count,+ sum(scroll_to_top_count) AS scroll_to_top_count,+ sum(click_count) AS click_count,+ sum(keypress_count) AS keypress_count,+ sum(mouse_activity_count) AS mouse_activity_count,+ sum(rage_click_count) AS rage_click_count,+ sum(dead_click_count) AS dead_click_count,+ sum(backspace_count) AS backspace_count,+ sum(inter_action_gap_count) AS inter_action_gap_count,+ sum(inter_action_gap_sum_ms) AS inter_action_gap_sum_ms,+ sum(inter_action_gap_sum_of_squares_ms) AS inter_action_gap_sum_of_squares_ms,+ max(max_idle_gap_ms) AS max_idle_gap_ms,+ sum(long_idle_gap_count) AS long_idle_gap_count,+ sum(quick_back_count) AS quick_back_count,+ sum(page_visit_count) AS page_visit_count,+ uniqCombinedArrayState(12)(visited_urls) AS unique_url_count,+ sum(login_path_visit_count) AS login_path_visit_count,+ sum(signup_path_visit_count) AS signup_path_visit_count,+ sum(checkout_path_visit_count) AS checkout_path_visit_count,+ sum(cart_path_visit_count) AS cart_path_visit_count,+ sum(billing_path_visit_count) AS billing_path_visit_count,+ sum(settings_path_visit_count) AS settings_path_visit_count,+ sum(account_path_visit_count) AS account_path_visit_count,+ sum(error_path_visit_count) AS error_path_visit_count,+ sum(not_found_path_visit_count) AS not_found_path_visit_count,+ sum(admin_path_visit_count) AS admin_path_visit_count,+ sum(dashboard_path_visit_count) AS dashboard_path_visit_count,+ sum(onboarding_path_visit_count) AS onboarding_path_visit_count,+ sum(cancel_path_visit_count) AS cancel_path_visit_count,+ sum(refund_path_visit_count) AS refund_path_visit_count,+ sum(console_error_count) AS console_error_count,+ sum(console_error_after_click_count) AS console_error_after_click_count,+ sum(console_warn_count) AS console_warn_count,+ sum(network_request_count) AS network_request_count,+ sum(network_failed_request_count) AS network_failed_request_count,+ sum(network_4xx_count) AS network_4xx_count,+ sum(network_5xx_count) AS network_5xx_count,+ sum(network_request_duration_sum) AS network_request_duration_sum,+ sum(network_request_duration_sum_of_squares) AS network_request_duration_sum_of_squares,+ sum(network_request_duration_count) AS network_request_duration_count,+ sum(mutation_count) AS mutation_count,+ sum(viewport_resize_count) AS viewport_resize_count,+ sum(touch_event_count) AS touch_event_count,+ max(max_scroll_y) AS max_scroll_y,+ uniqCombinedArrayState(12)(click_target_ids) AS unique_click_target_count,+ uniqCombinedArrayState(12)(form_field_ids) AS unique_form_field_count,+ sum(text_selection_count) AS text_selection_count,+ sum(selection_copy_count) AS selection_copy_count,+ max(is_deleted) AS is_deleted+FROM posthog.kafka_session_replay_features+GROUP BY+ session_id, team_id+SQL++ column "session_id" {+ type = "String"+ }+ column "team_id" {+ type = "Int64"+ }+ column "distinct_id" {+ type = "String"+ }+ column "min_first_timestamp" {+ type = "DateTime64(6, 'UTC')"+ }+ column "max_last_timestamp" {+ type = "DateTime64(6, 'UTC')"+ }+ column "event_count" {+ type = "Int64"+ }+ column "mouse_position_count" {+ type = "Int64"+ }+ column "mouse_sum_x" {+ type = "Float64"+ }+ column "mouse_sum_x_squared" {+ type = "Float64"+ }+ column "mouse_sum_y" {+ type = "Float64"+ }+ column "mouse_sum_y_squared" {+ type = "Float64"+ }+ column "mouse_distance_traveled" {+ type = "Float64"+ }+ column "mouse_direction_change_count" {+ type = "Int64"+ }+ column "mouse_velocity_sum" {+ type = "Float64"+ }+ column "mouse_velocity_sum_of_squares" {+ type = "Float64"+ }+ column "mouse_velocity_count" {+ type = "Int64"+ }+ column "scroll_event_count" {+ type = "Int64"+ }+ column "total_scroll_magnitude" {+ type = "Float64"+ }+ column "scroll_direction_reversal_count" {+ type = "Int64"+ }+ column "rapid_scroll_reversal_count" {+ type = "Int64"+ }+ column "scroll_to_top_count" {+ type = "Int64"+ }+ column "click_count" {+ type = "Int64"+ }+ column "keypress_count" {+ type = "Int64"+ }+ column "mouse_activity_count" {+ type = "Int64"+ }+ column "rage_click_count" {+ type = "Int64"+ }+ column "dead_click_count" {+ type = "Int64"+ }+ column "backspace_count" {+ type = "Int64"+ }+ column "inter_action_gap_count" {+ type = "Int64"+ }+ column "inter_action_gap_sum_ms" {+ type = "Float64"+ }+ column "inter_action_gap_sum_of_squares_ms" {+ type = "Float64"+ }+ column "max_idle_gap_ms" {+ type = "Float64"+ }+ column "long_idle_gap_count" {+ type = "Int64"+ }+ column "quick_back_count" {+ type = "Int64"+ }+ column "page_visit_count" {+ type = "Int64"+ }+ column "unique_url_count" {+ type = "AggregateFunction(uniqCombinedArray(12), Array(String))"+ }+ column "login_path_visit_count" {+ type = "Int64"+ }+ column "signup_path_visit_count" {+ type = "Int64"+ }+ column "checkout_path_visit_count" {+ type = "Int64"+ }+ column "cart_path_visit_count" {+ type = "Int64"+ }+ column "billing_path_visit_count" {+ type = "Int64"+ }+ column "settings_path_visit_count" {+ type = "Int64"+ }+ column "account_path_visit_count" {+ type = "Int64"+ }+ column "error_path_visit_count" {+ type = "Int64"+ }+ column "not_found_path_visit_count" {+ type = "Int64"+ }+ column "admin_path_visit_count" {+ type = "Int64"+ }+ column "dashboard_path_visit_count" {+ type = "Int64"+ }+ column "onboarding_path_visit_count" {+ type = "Int64"+ }+ column "cancel_path_visit_count" {+ type = "Int64"+ }+ column "refund_path_visit_count" {+ type = "Int64"+ }+ column "console_error_count" {+ type = "Int64"+ }+ column "console_error_after_click_count" {+ type = "Int64"+ }+ column "console_warn_count" {+ type = "Int64"+ }+ column "network_request_count" {+ type = "Int64"+ }+ column "network_failed_request_count" {+ type = "Int64"+ }+ column "network_4xx_count" {+ type = "Int64"+ }+ column "network_5xx_count" {+ type = "Int64"+ }+ column "network_request_duration_sum" {+ type = "Float64"+ }+ column "network_request_duration_sum_of_squares" {+ type = "Float64"+ }+ column "network_request_duration_count" {+ type = "Int64"+ }+ column "mutation_count" {+ type = "Int64"+ }+ column "viewport_resize_count" {+ type = "Int64"+ }+ column "touch_event_count" {+ type = "Int64"+ }+ column "max_scroll_y" {+ type = "Float64"+ }+ column "unique_click_target_count" {+ type = "AggregateFunction(uniqCombinedArray(12), Array(Int64))"+ }+ column "unique_form_field_count" {+ type = "AggregateFunction(uniqCombinedArray(12), Array(Int64))"+ }+ column "text_selection_count" {+ type = "Int64"+ }+ column "selection_copy_count" {+ type = "Int64"+ }+ column "is_deleted" {+ type = "UInt8"+ }+ }++ materialized_view "tophog_mv" {+ to_table = "posthog.writable_tophog"+ query = <<SQL+SELECT+ timestamp,+ metric,+ type,+ key,+ value,+ count,+ pipeline,+ lane,+ labels+FROM posthog.kafka_tophog+SQL++ column "timestamp" {+ type = "DateTime64(6, 'UTC')"+ }+ column "metric" {+ type = "LowCardinality(String)"+ }+ column "type" {+ type = "LowCardinality(String)"+ }+ column "key" {+ type = "Map(LowCardinality(String), String)"+ }+ column "value" {+ type = "Float64"+ }+ column "count" {+ type = "UInt64"+ }+ column "pipeline" {+ type = "LowCardinality(String)"+ }+ column "lane" {+ type = "LowCardinality(String)"+ }+ column "labels" {+ type = "Map(LowCardinality(String), String)"+ }+ }++ materialized_view "tophog_ws_mv" {+ to_table = "posthog.writable_tophog"+ query = <<SQL+SELECT+ timestamp,+ metric,+ type,+ key,+ value,+ count,+ pipeline,+ lane,+ labels+FROM posthog.kafka_tophog_ws+SQL++ column "timestamp" {+ type = "DateTime64(6, 'UTC')"+ }+ column "metric" {+ type = "LowCardinality(String)"+ }+ column "type" {+ type = "LowCardinality(String)"+ }+ column "key" {+ type = "Map(LowCardinality(String), String)"+ }+ column "value" {+ type = "Float64"+ }+ column "count" {+ type = "UInt64"+ }+ column "pipeline" {+ type = "LowCardinality(String)"+ }+ column "lane" {+ type = "LowCardinality(String)"+ }+ column "labels" {+ type = "Map(LowCardinality(String), String)"+ }+ }+}diff --git a/posthog/clickhouse/hcl/golden/local-multi/ingestion_small.hcl b/posthog/clickhouse/hcl/golden/local-multi/ingestion_small.hclnew file mode 100644index 000000000000..c4df7bbad469--- /dev/null+++ b/posthog/clickhouse/hcl/golden/local-multi/ingestion_small.hcl@@ -0,0 +1,2588 @@+node "small" {+ macros = {+ hostClusterRole = "small"+ hostClusterType = "online"+ replica = "small"+ shard = "01"+ }+}++database "posthog" {+ table "kafka_app_metrics" {+ column "team_id" {+ type = "Int64"+ }+ column "timestamp" {+ type = "DateTime64(6, 'UTC')"+ }+ column "plugin_config_id" {+ type = "Int64"+ }+ column "category" {+ type = "LowCardinality(String)"+ }+ column "job_id" {+ type = "String"+ }+ column "successes" {+ type = "Int64"+ }+ column "successes_on_retry" {+ type = "Int64"+ }+ column "failures" {+ type = "Int64"+ }+ column "error_uuid" {+ type = "UUID"+ }+ column "error_type" {+ type = "String"+ }+ column "error_details" {+ type = "String"+ codec = "ZSTD(3)"+ }+ engine "kafka" {+ broker_list = "msk_cluster"+ topic_list = "kafka_topic_list = 'clickhouse_app_metrics'"+ group_name = "kafka_group_name = 'group1'"+ format = "kafka_format = 'JSONEachRow'"+ }+ }++ table "kafka_duplicate_events" {+ column "team_id" {+ type = "Int64"+ }+ column "distinct_id" {+ type = "String"+ }+ column "event" {+ type = "String"+ }+ column "source_uuid" {+ type = "UUID"+ }+ column "duplicate_uuid" {+ type = "UUID"+ }+ column "similarity_score" {+ type = "Float64"+ }+ column "dedup_type" {+ type = "LowCardinality(String)"+ }+ column "is_confirmed" {+ type = "UInt8"+ }+ column "reason" {+ type = "Nullable(String)"+ }+ column "version" {+ type = "String"+ }+ column "different_property_count" {+ type = "UInt32"+ }+ column "properties_similarity" {+ type = "Float64"+ }+ column "source_message" {+ type = "String"+ }+ column "duplicate_message" {+ type = "String"+ }+ column "distinct_fields" {+ type = "String"+ }+ column "inserted_at" {+ type = "DateTime64(3, 'UTC')"+ }+ engine "kafka" {+ broker_list = "msk_cluster"+ topic_list = "kafka_topic_list = 'clickhouse_ingestion_events_duplicates'"+ group_name = "kafka_group_name = 'clickhouse_duplicate_events'"+ format = "kafka_format = 'JSONEachRow'"+ }+ }++ table "kafka_error_tracking_issue_fingerprint_embeddings" {+ column "team_id" {+ type = "Int64"+ }+ column "model_name" {+ type = "LowCardinality(String)"+ }+ column "embedding_version" {+ type = "Int64"+ }+ column "fingerprint" {+ type = "String"+ }+ column "inserted_at" {+ type = "DateTime64(3, 'UTC')"+ }+ column "embeddings" {+ type = "Array(Float64)"+ }+ engine "kafka" {+ broker_list = "msk_cluster"+ topic_list = "kafka_topic_list = 'clickhouse_error_tracking_issue_fingerprint_embeddings'"+ group_name = "kafka_group_name = 'clickhouse_error_tracking_fingerprint_embeddings'"+ format = "kafka_format = 'JSONEachRow'"+ }+ }++ table "kafka_error_tracking_issue_fingerprint_overrides" {+ column "team_id" {+ type = "Int64"+ }+ column "fingerprint" {+ type = "String"+ }+ column "issue_id" {+ type = "UUID"+ }+ column "is_deleted" {+ type = "Int8"+ }+ column "version" {+ type = "Int64"+ }+ engine "kafka" {+ broker_list = "msk_cluster"+ topic_list = "kafka_topic_list = 'clickhouse_error_tracking_issue_fingerprint'"+ group_name = "kafka_group_name = 'clickhouse-error-tracking-issue-fingerprint-overrides'"+ format = "kafka_format = 'JSONEachRow'"+ }+ }++ table "kafka_events_dead_letter_queue" {+ column "id" {+ type = "UUID"+ }+ column "event_uuid" {+ type = "UUID"+ }+ column "event" {+ type = "String"+ }+ column "properties" {+ type = "String"+ }+ column "distinct_id" {+ type = "String"+ }+ column "team_id" {+ type = "Int64"+ }+ column "elements_chain" {+ type = "String"+ }+ column "created_at" {+ type = "DateTime64(6, 'UTC')"+ }+ column "ip" {+ type = "String"+ }+ column "site_url" {+ type = "String"+ }+ column "now" {+ type = "DateTime64(6, 'UTC')"+ }+ column "raw_payload" {+ type = "String"+ }+ column "error_timestamp" {+ type = "DateTime64(6, 'UTC')"+ }+ column "error_location" {+ type = "String"+ }+ column "error" {+ type = "String"+ }+ column "tags" {+ type = "Array(String)"+ }+ engine "kafka" {+ broker_list = "msk_cluster"+ topic_list = "kafka_topic_list = 'events_dead_letter_queue'"+ group_name = "kafka_group_name = 'group1'"+ format = "kafka_format = 'JSONEachRow'"+ skip_broken_messages = 1000+ }+ }++ table "kafka_groups" {+ column "group_type_index" {+ type = "UInt8"+ }+ column "group_key" {+ type = "String"+ }+ column "created_at" {+ type = "DateTime64(3)"+ }+ column "team_id" {+ type = "Int64"+ }+ column "group_properties" {+ type = "String"+ }+ engine "kafka" {+ broker_list = "msk_cluster"+ topic_list = "kafka_topic_list = 'clickhouse_groups'"+ group_name = "kafka_group_name = 'group1'"+ format = "kafka_format = 'JSONEachRow'"+ }+ }++ table "kafka_ingestion_warnings" {+ column "team_id" {+ type = "Int64"+ }+ column "source" {+ type = "LowCardinality(String)"+ }+ column "type" {+ type = "String"+ }+ column "details" {+ type = "String"+ codec = "ZSTD(3)"+ }+ column "timestamp" {+ type = "DateTime64(6, 'UTC')"+ }+ engine "kafka" {+ broker_list = "msk_cluster"+ topic_list = "kafka_topic_list = 'clickhouse_ingestion_warnings'"+ group_name = "kafka_group_name = 'group1'"+ format = "kafka_format = 'JSONEachRow'"+ }+ }++ table "kafka_log_entries_v3" {+ column "team_id" {+ type = "UInt64"+ }+ column "log_source" {+ type = "LowCardinality(String)"+ }+ column "log_source_id" {+ type = "String"+ }+ column "instance_id" {+ type = "String"+ }+ column "timestamp" {+ type = "DateTime64(6, 'UTC')"+ }+ column "level" {+ type = "LowCardinality(String)"+ }+ column "message" {+ type = "String"+ }+ engine "kafka" {+ broker_list = "msk_cluster"+ topic_list = "kafka_topic_list = 'log_entries'"+ group_name = "kafka_group_name = 'clickhouse_log_entries'"+ format = "kafka_format = 'JSONEachRow'"+ skip_broken_messages = 100+ }+ }++ table "kafka_log_entries_ws" {+ column "team_id" {+ type = "UInt64"+ }+ column "log_source" {+ type = "LowCardinality(String)"+ }+ column "log_source_id" {+ type = "String"+ }+ column "instance_id" {+ type = "String"+ }+ column "timestamp" {+ type = "DateTime64(6, 'UTC')"+ }+ column "level" {+ type = "LowCardinality(String)"+ }+ column "message" {+ type = "String"+ }+ engine "kafka" {+ broker_list = "warpstream_ingestion"+ topic_list = "kafka_topic_list = 'log_entries'"+ group_name = "kafka_group_name = 'clickhouse_log_entries_ws'"+ format = "kafka_format = 'JSONEachRow'"+ skip_broken_messages = 100+ }+ }++ table "kafka_person" {+ column "id" {+ type = "UUID"+ }+ column "created_at" {+ type = "DateTime64(3)"+ }+ column "team_id" {+ type = "Int64"+ }+ column "properties" {+ type = "String"+ }+ column "is_identified" {+ type = "Int8"+ }+ column "is_deleted" {+ type = "Int8"+ }+ column "version" {+ type = "UInt64"+ }+ column "last_seen_at" {+ type = "Nullable(DateTime64(3))"+ }+ engine "kafka" {+ broker_list = "msk_cluster"+ topic_list = "kafka_topic_list = 'clickhouse_person'"+ group_name = "kafka_group_name = 'group1'"+ format = "kafka_format = 'JSONEachRow'"+ }+ }++ table "kafka_person_distinct_id2" {+ column "team_id" {+ type = "Int64"+ }+ column "distinct_id" {+ type = "String"+ }+ column "person_id" {+ type = "UUID"+ }+ column "is_deleted" {+ type = "Int8"+ }+ column "version" {+ type = "Int64"+ }+ engine "kafka" {+ broker_list = "msk_cluster"+ topic_list = "kafka_topic_list = 'clickhouse_person_distinct_id'"+ group_name = "kafka_group_name = 'group1'"+ format = "kafka_format = 'JSONEachRow'"+ }+ }++ table "kafka_person_distinct_id_overrides" {+ column "team_id" {+ type = "Int64"+ }+ column "distinct_id" {+ type = "String"+ }+ column "person_id" {+ type = "UUID"+ }+ column "is_deleted" {+ type = "Int8"+ }+ column "version" {+ type = "Int64"+ }+ engine "kafka" {+ broker_list = "msk_cluster"+ topic_list = "kafka_topic_list = 'clickhouse_person_distinct_id'"+ group_name = "kafka_group_name = 'clickhouse-person-distinct-id-overrides'"+ format = "kafka_format = 'JSONEachRow'"+ }+ }++ table "kafka_plugin_log_entries" {+ column "id" {+ type = "UUID"+ }+ column "team_id" {+ type = "Int64"+ }+ column "plugin_id" {+ type = "Int64"+ }+ column "plugin_config_id" {+ type = "Int64"+ }+ column "timestamp" {+ type = "DateTime64(6, 'UTC')"+ }+ column "source" {+ type = "String"+ }+ column "type" {+ type = "String"+ }+ column "message" {+ type = "String"+ }+ column "instance_id" {+ type = "UUID"+ }+ engine "kafka" {+ broker_list = "msk_cluster"+ topic_list = "kafka_topic_list = 'plugin_log_entries'"+ group_name = "kafka_group_name = 'group1'"+ format = "kafka_format = 'JSONEachRow'"+ }+ }++ table "kafka_posthog_document_embeddings" {+ column "team_id" {+ type = "Int64"+ }+ column "product" {+ type = "LowCardinality(String)"+ }+ column "document_type" {+ type = "LowCardinality(String)"+ }+ column "model_name" {+ type = "LowCardinality(String)"+ }+ column "rendering" {+ type = "LowCardinality(String)"+ }+ column "document_id" {+ type = "String"+ }+ column "timestamp" {+ type = "DateTime64(3, 'UTC')"+ }+ column "inserted_at" {+ type = "DateTime64(3, 'UTC')"+ }+ column "content" {+ type = "String"+ }+ column "metadata" {+ type = "String"+ }+ column "embedding" {+ type = "Array(Float64)"+ }+ engine "kafka" {+ broker_list = "msk_cluster"+ topic_list = "kafka_topic_list = 'clickhouse_document_embeddings'"+ group_name = "kafka_group_name = 'clickhouse_document_embeddings'"+ format = "kafka_format = 'JSONEachRow'"+ }+ }++ table "kafka_session_replay_events" {+ column "session_id" {+ type = "String"+ }+ column "team_id" {+ type = "Int64"+ }+ column "distinct_id" {+ type = "String"+ }+ column "first_timestamp" {+ type = "DateTime64(6, 'UTC')"+ }+ column "last_timestamp" {+ type = "DateTime64(6, 'UTC')"+ }+ column "block_url" {+ type = "Nullable(String)"+ }+ column "first_url" {+ type = "Nullable(String)"+ }+ column "urls" {+ type = "Array(String)"+ }+ column "click_count" {+ type = "Int64"+ }+ column "keypress_count" {+ type = "Int64"+ }+ column "mouse_activity_count" {+ type = "Int64"+ }+ column "active_milliseconds" {+ type = "Int64"+ }+ column "console_log_count" {+ type = "Int64"+ }+ column "console_warn_count" {+ type = "Int64"+ }+ column "console_error_count" {+ type = "Int64"+ }+ column "size" {+ type = "Int64"+ }+ column "event_count" {+ type = "Int64"+ }+ column "message_count" {+ type = "Int64"+ }+ column "snapshot_source" {+ type = "LowCardinality(Nullable(String))"+ }+ column "snapshot_library" {+ type = "Nullable(String)"+ }+ column "retention_period_days" {+ type = "Nullable(Int64)"+ }+ column "is_deleted" {+ type = "UInt8"+ }+ column "ai_tags_fixed" {+ type = "Array(String)"+ }+ column "ai_tags_freeform" {+ type = "Array(String)"+ }+ column "ai_highlighted" {+ type = "UInt8"+ }+ column "surfacing_score" {+ type = "Nullable(Float32)"+ }+ engine "kafka" {+ broker_list = "msk_cluster"+ topic_list = "kafka_topic_list = 'clickhouse_session_replay_events'"+ group_name = "kafka_group_name = 'group1'"+ format = "kafka_format = 'JSONEachRow'"+ }+ }++ table "kafka_usage_report_events_preagg" {+ column "uuid" {+ type = "UUID"+ }+ column "event" {+ type = "String"+ }+ column "properties" {+ type = "String"+ codec = "ZSTD(3)"+ }+ column "timestamp" {+ type = "DateTime64(6, 'UTC')"+ }+ column "team_id" {+ type = "Int64"+ }+ column "distinct_id" {+ type = "String"+ }+ column "person_mode" {+ type = "Enum8('full'=0, 'propertyless'=1, 'force_upgrade'=2)"+ }+ engine "kafka" {+ broker_list = "warpstream_ingestion"+ topic_list = "kafka_topic_list = 'clickhouse_events_json'"+ group_name = "kafka_group_name = 'clickhouse_usage_report_events_preagg'"+ format = "kafka_format = 'JSONEachRow'"+ num_consumers = 1+ skip_broken_messages = 100+ thread_per_consumer = true+ }+ }++ table "query_log_archive" {+ column "hostname" {+ type = "LowCardinality(String)"+ }+ column "user" {+ type = "LowCardinality(String)"+ }+ column "query_id" {+ type = "String"+ }+ column "initial_query_id" {+ type = "String"+ }+ column "is_initial_query" {+ type = "UInt8"+ }+ column "type" {+ type = "Enum8('QueryStart'=1, 'QueryFinish'=2, 'ExceptionBeforeStart'=3, 'ExceptionWhileProcessing'=4)"+ }+ column "event_date" {+ type = "Date"+ }+ column "event_time" {+ type = "DateTime"+ }+ column "event_time_microseconds" {+ type = "DateTime64(6)"+ }+ column "query_start_time" {+ type = "DateTime"+ }+ column "query_start_time_microseconds" {+ type = "DateTime64(6)"+ }+ column "query_duration_ms" {+ type = "UInt64"+ }+ column "read_rows" {+ type = "UInt64"+ }+ column "read_bytes" {+ type = "UInt64"+ }+ column "written_rows" {+ type = "UInt64"+ }+ column "written_bytes" {+ type = "UInt64"+ }+ column "result_rows" {+ type = "UInt64"+ }+ column "result_bytes" {+ type = "UInt64"+ }+ column "memory_usage" {+ type = "UInt64"+ }+ column "peak_threads_usage" {+ type = "UInt64"+ }+ column "current_database" {+ type = "LowCardinality(String)"+ }+ column "query" {+ type = "String"+ }+ column "formatted_query" {+ type = "String"+ }+ column "normalized_query_hash" {+ type = "UInt64"+ }+ column "query_kind" {+ type = "LowCardinality(String)"+ }+ column "exception_code" {+ type = "Int32"+ }+ column "exception" {+ type = "String"+ }+ column "stack_trace" {+ type = "String"+ }+ column "team_id" {+ type = "Int64"+ }+ column "log_comment" {+ type = "JSON(max_dynamic_paths=256, access_method LowCardinality(String), alert_config_id String, api_key_label String, api_key_mask String, batch_export_id String, chargeable Bool, client_query_id String, cohort_id Int64, `dagster.job_name` String, `dagster.run_id` String, `dagster.tags.owner` String, dashboard_id Int64, experiment_feature_flag_key String, experiment_id Int64, feature LowCardinality(String), id String, insight_id Int64, is_impersonated Bool, kind LowCardinality(String), name String, org_id String, person_on_events_mode LowCardinality(String), product LowCardinality(String), query_type LowCardinality(String), request_name String, route_id String, service_name String, session_id String, table_id String, team_id Int64, `temporal.activity_id` String, `temporal.activity_type` String, `temporal.attempt` Int64, `temporal.workflow_id` String, `temporal.workflow_namespace` String, `temporal.workflow_run_id` String, `temporal.workflow_type` String, user_id Int64, warehouse_query Bool, workflow LowCardinality(String), workload LowCardinality(String), SKIP cache_key, SKIP filter, SKIP hogql_features, SKIP http_referer, SKIP http_request_id, SKIP http_user_agent, SKIP query_settings, SKIP timings, SKIP user_email)"+ }+ column "ProfileEvents" {+ type = "Map(String, UInt64)"+ }+ column "exception_name" {+ type = "String"+ alias = "errorCodeToName(exception_code)"+ }+ column "ProfileEvents_RealTimeMicroseconds" {+ type = "Int64"+ alias = "ProfileEvents['RealTimeMicroseconds']"+ }+ column "ProfileEvents_OSCPUVirtualTimeMicroseconds" {+ type = "Int64"+ alias = "ProfileEvents['OSCPUVirtualTimeMicroseconds']"+ }+ column "ProfileEvents_S3Clients" {+ type = "Int64"+ alias = "ProfileEvents['S3Clients']"+ }+ column "ProfileEvents_S3DeleteObjects" {+ type = "Int64"+ alias = "ProfileEvents['S3DeleteObjects']"+ }+ column "ProfileEvents_S3CopyObject" {+ type = "Int64"+ alias = "ProfileEvents['S3CopyObject']"+ }+ column "ProfileEvents_S3ListObjects" {+ type = "Int64"+ alias = "ProfileEvents['S3ListObjects']"+ }+ column "ProfileEvents_S3HeadObject" {+ type = "Int64"+ alias = "ProfileEvents['S3HeadObject']"+ }+ column "ProfileEvents_S3GetObjectAttributes" {+ type = "Int64"+ alias = "ProfileEvents['S3GetObjectAttributes']"+ }+ column "ProfileEvents_S3CreateMultipartUpload" {+ type = "Int64"+ alias = "ProfileEvents['S3CreateMultipartUpload']"+ }+ column "ProfileEvents_S3UploadPartCopy" {+ type = "Int64"+ alias = "ProfileEvents['S3UploadPartCopy']"+ }+ column "ProfileEvents_S3UploadPart" {+ type = "Int64"+ alias = "ProfileEvents['S3UploadPart']"+ }+ column "ProfileEvents_S3AbortMultipartUpload" {+ type = "Int64"+ alias = "ProfileEvents['S3AbortMultipartUpload']"+ }+ column "ProfileEvents_S3CompleteMultipartUpload" {+ type = "Int64"+ alias = "ProfileEvents['S3CompleteMultipartUpload']"+ }+ column "ProfileEvents_S3PutObject" {+ type = "Int64"+ alias = "ProfileEvents['S3PutObject']"+ }+ column "ProfileEvents_S3GetObject" {+ type = "Int64"+ alias = "ProfileEvents['S3GetObject']"+ }+ column "ProfileEvents_ReadBufferFromS3Bytes" {+ type = "Int64"+ alias = "ProfileEvents['ReadBufferFromS3Bytes']"+ }+ column "ProfileEvents_WriteBufferFromS3Bytes" {+ type = "Int64"+ alias = "ProfileEvents['WriteBufferFromS3Bytes']"+ }+ column "lc_workflow" {+ type = "LowCardinality(String)"+ alias = "log_comment.workflow"+ }+ column "lc_kind" {+ type = "LowCardinality(String)"+ alias = "log_comment.kind"+ }+ column "lc_id" {+ type = "String"+ alias = "CAST(log_comment.id, 'String')"+ }+ column "lc_route_id" {+ type = "String"+ alias = "CAST(log_comment.route_id, 'String')"+ }+ column "lc_access_method" {+ type = "LowCardinality(String)"+ alias = "log_comment.access_method"+ }+ column "lc_api_key_label" {+ type = "String"+ alias = "CAST(log_comment.api_key_label, 'String')"+ }+ column "lc_api_key_mask" {+ type = "String"+ alias = "CAST(log_comment.api_key_mask, 'String')"+ }+ column "lc_query_type" {+ type = "LowCardinality(String)"+ alias = "log_comment.query_type"+ }+ column "lc_product" {+ type = "LowCardinality(String)"+ alias = "log_comment.product"+ }+ column "lc_chargeable" {+ type = "Bool"+ alias = "log_comment.chargeable"+ }+ column "lc_name" {+ type = "String"+ alias = "CAST(log_comment.name, 'String')"+ }+ column "lc_request_name" {+ type = "String"+ alias = "CAST(log_comment.request_name, 'String')"+ }+ column "lc_client_query_id" {+ type = "String"+ alias = "CAST(log_comment.client_query_id, 'String')"+ }+ column "lc_org_id" {+ type = "String"+ alias = "CAST(log_comment.org_id, 'String')"+ }+ column "lc_user_id" {+ type = "Int64"+ alias = "log_comment.user_id"+ }+ column "lc_is_impersonated" {+ type = "Bool"+ alias = "log_comment.is_impersonated"+ }+ column "lc_session_id" {+ type = "String"+ alias = "CAST(log_comment.session_id, 'String')"+ }+ column "lc_dashboard_id" {+ type = "Int64"+ alias = "log_comment.dashboard_id"+ }+ column "lc_insight_id" {+ type = "Int64"+ alias = "log_comment.insight_id"+ }+ column "lc_cohort_id" {+ type = "Int64"+ alias = "log_comment.cohort_id"+ }+ column "lc_batch_export_id" {+ type = "String"+ alias = "CAST(log_comment.batch_export_id, 'String')"+ }+ column "lc_experiment_id" {+ type = "Int64"+ alias = "log_comment.experiment_id"+ }+ column "lc_experiment_feature_flag_key" {+ type = "String"+ alias = "CAST(log_comment.experiment_feature_flag_key, 'String')"+ }+ column "lc_alert_config_id" {+ type = "String"+ alias = "CAST(log_comment.alert_config_id, 'String')"+ }+ column "lc_feature" {+ type = "LowCardinality(String)"+ alias = "log_comment.feature"+ }+ column "lc_table_id" {+ type = "String"+ alias = "CAST(log_comment.table_id, 'String')"+ }+ column "lc_warehouse_query" {+ type = "Bool"+ alias = "log_comment.warehouse_query"+ }+ column "lc_person_on_events_mode" {+ type = "LowCardinality(String)"+ alias = "log_comment.person_on_events_mode"+ }+ column "lc_service_name" {+ type = "String"+ alias = "CAST(log_comment.service_name, 'String')"+ }+ column "lc_workload" {+ type = "LowCardinality(String)"+ alias = "log_comment.workload"+ }+ column "lc_query__kind" {+ type = "LowCardinality(String)"+ alias = "if(JSONHas(toString(log_comment), 'query', 'source'), JSONExtractString(toString(log_comment), 'query', 'source', 'kind'), JSONExtractString(toString(log_comment), 'query', 'kind'))"+ }+ column "lc_query__query" {+ type = "String"+ alias = "multiIf(NOT is_initial_query, '', JSONHas(toString(log_comment), 'query', 'source'), JSONExtractString(toString(log_comment), 'query', 'source', 'query'), JSONExtractString(toString(log_comment), 'query', 'query'))"+ }+ column "lc_query" {+ type = "String"+ alias = "if(is_initial_query, JSONExtractRaw(toString(log_comment), 'query'), '')"+ }+ column "lc_temporal__workflow_namespace" {+ type = "String"+ alias = "CAST(log_comment.`temporal.workflow_namespace`, 'String')"+ }+ column "lc_temporal__workflow_type" {+ type = "String"+ alias = "CAST(log_comment.`temporal.workflow_type`, 'String')"+ }+ column "lc_temporal__workflow_id" {+ type = "String"+ alias = "CAST(log_comment.`temporal.workflow_id`, 'String')"+ }+ column "lc_temporal__workflow_run_id" {+ type = "String"+ alias = "CAST(log_comment.`temporal.workflow_run_id`, 'String')"+ }+ column "lc_temporal__activity_type" {+ type = "String"+ alias = "CAST(log_comment.`temporal.activity_type`, 'String')"+ }+ column "lc_temporal__activity_id" {+ type = "String"+ alias = "CAST(log_comment.`temporal.activity_id`, 'String')"+ }+ column "lc_temporal__attempt" {+ type = "Int64"+ alias = "log_comment.`temporal.attempt`"+ }+ column "lc_dagster__job_name" {+ type = "String"+ alias = "CAST(log_comment.`dagster.job_name`, 'String')"+ }+ column "lc_dagster__run_id" {+ type = "String"+ alias = "CAST(log_comment.`dagster.run_id`, 'String')"+ }+ column "lc_dagster__owner" {+ type = "String"+ alias = "CAST(log_comment.`dagster.tags.owner`, 'String')"+ }+ column "lc_modifiers" {+ type = "String"+ alias = "if(is_initial_query, JSONExtractRaw(toString(log_comment), 'modifiers'), '')"+ }+ engine "distributed" {+ cluster_name = "ops"+ remote_database = "posthog"+ remote_table = "sharded_query_log_archive"+ }+ }++ table "writable_app_metrics" {+ column "team_id" {+ type = "Int64"+ }+ column "timestamp" {+ type = "DateTime64(6, 'UTC')"+ }+ column "plugin_config_id" {+ type = "Int64"+ }+ column "category" {+ type = "LowCardinality(String)"+ }+ column "job_id" {+ type = "String"+ }+ column "successes" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "successes_on_retry" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "failures" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "error_uuid" {+ type = "UUID"+ }+ column "error_type" {+ type = "String"+ }+ column "error_details" {+ type = "String"+ codec = "ZSTD(3)"+ }+ column "_timestamp" {+ type = "DateTime"+ }+ column "_offset" {+ type = "UInt64"+ }+ column "_partition" {+ type = "UInt64"+ }+ engine "distributed" {+ cluster_name = "posthog"+ remote_database = "posthog"+ remote_table = "sharded_app_metrics"+ sharding_key = "rand()"+ }+ }++ table "writable_duplicate_events" {+ column "team_id" {+ type = "Int64"+ }+ column "distinct_id" {+ type = "String"+ }+ column "event" {+ type = "String"+ }+ column "source_uuid" {+ type = "UUID"+ }+ column "duplicate_uuid" {+ type = "UUID"+ }+ column "similarity_score" {+ type = "Float64"+ }+ column "dedup_type" {+ type = "LowCardinality(String)"+ }+ column "is_confirmed" {+ type = "UInt8"+ }+ column "reason" {+ type = "Nullable(String)"+ }+ column "version" {+ type = "String"+ }+ column "different_property_count" {+ type = "UInt32"+ }+ column "properties_similarity" {+ type = "Float64"+ }+ column "source_message" {+ type = "String"+ }+ column "duplicate_message" {+ type = "String"+ }+ column "distinct_fields" {+ type = "Array(Tuple(field_name String, original_value String, new_value String))"+ }+ column "inserted_at" {+ type = "DateTime64(3, 'UTC')"+ }+ column "_timestamp" {+ type = "DateTime"+ }+ column "_offset" {+ type = "UInt64"+ }+ column "_partition" {+ type = "UInt64"+ }+ engine "distributed" {+ cluster_name = "posthog_single_shard"+ remote_database = "posthog"+ remote_table = "duplicate_events"+ }+ }++ table "writable_error_tracking_issue_fingerprint_embeddings" {+ column "team_id" {+ type = "Int64"+ }+ column "model_name" {+ type = "LowCardinality(String)"+ }+ column "embedding_version" {+ type = "Int64"+ }+ column "fingerprint" {+ type = "String"+ }+ column "inserted_at" {+ type = "DateTime64(3, 'UTC')"+ }+ column "embeddings" {+ type = "Array(Float64)"+ }+ column "_timestamp" {+ type = "DateTime"+ }+ column "_offset" {+ type = "UInt64"+ }+ column "_partition" {+ type = "UInt64"+ }+ engine "distributed" {+ cluster_name = "posthog_single_shard"+ remote_database = "posthog"+ remote_table = "error_tracking_issue_fingerprint_embeddings"+ }+ }++ table "writable_error_tracking_issue_fingerprint_overrides" {+ column "team_id" {+ type = "Int64"+ }+ column "fingerprint" {+ type = "String"+ }+ column "issue_id" {+ type = "UUID"+ }+ column "is_deleted" {+ type = "Int8"+ }+ column "version" {+ type = "Int64"+ }+ column "_timestamp" {+ type = "DateTime"+ }+ column "_offset" {+ type = "UInt64"+ }+ column "_partition" {+ type = "UInt64"+ }+ engine "distributed" {+ cluster_name = "posthog_single_shard"+ remote_database = "posthog"+ remote_table = "error_tracking_issue_fingerprint_overrides"+ }+ }++ table "writable_events_dead_letter_queue" {+ column "id" {+ type = "UUID"+ }+ column "event_uuid" {+ type = "UUID"+ }+ column "event" {+ type = "String"+ }+ column "properties" {+ type = "String"+ }+ column "distinct_id" {+ type = "String"+ }+ column "team_id" {+ type = "Int64"+ }+ column "elements_chain" {+ type = "String"+ }+ column "created_at" {+ type = "DateTime64(6, 'UTC')"+ }+ column "ip" {+ type = "String"+ }+ column "site_url" {+ type = "String"+ }+ column "now" {+ type = "DateTime64(6, 'UTC')"+ }+ column "raw_payload" {+ type = "String"+ }+ column "error_timestamp" {+ type = "DateTime64(6, 'UTC')"+ }+ column "error_location" {+ type = "String"+ }+ column "error" {+ type = "String"+ }+ column "tags" {+ type = "Array(String)"+ }+ column "_timestamp" {+ type = "DateTime"+ }+ column "_offset" {+ type = "UInt64"+ }+ engine "distributed" {+ cluster_name = "posthog_single_shard"+ remote_database = "posthog"+ remote_table = "events_dead_letter_queue"+ }+ }++ table "writable_groups" {+ column "group_type_index" {+ type = "UInt8"+ }+ column "group_key" {+ type = "String"+ }+ column "created_at" {+ type = "DateTime64(3)"+ }+ column "team_id" {+ type = "Int64"+ }+ column "group_properties" {+ type = "String"+ }+ column "_timestamp" {+ type = "DateTime"+ }+ column "_offset" {+ type = "UInt64"+ }+ engine "distributed" {+ cluster_name = "posthog_single_shard"+ remote_database = "posthog"+ remote_table = "groups"+ }+ }++ table "writable_ingestion_warnings" {+ column "team_id" {+ type = "Int64"+ }+ column "source" {+ type = "LowCardinality(String)"+ }+ column "type" {+ type = "String"+ }+ column "details" {+ type = "String"+ codec = "ZSTD(3)"+ }+ column "timestamp" {+ type = "DateTime64(6, 'UTC')"+ }+ column "_timestamp" {+ type = "DateTime"+ }+ column "_offset" {+ type = "UInt64"+ }+ column "_partition" {+ type = "UInt64"+ }+ engine "distributed" {+ cluster_name = "posthog"+ remote_database = "posthog"+ remote_table = "sharded_ingestion_warnings"+ sharding_key = "rand()"+ }+ }++ table "writable_log_entries" {+ column "team_id" {+ type = "UInt64"+ }+ column "log_source" {+ type = "LowCardinality(String)"+ }+ column "log_source_id" {+ type = "String"+ }+ column "instance_id" {+ type = "String"+ }+ column "timestamp" {+ type = "DateTime64(6, 'UTC')"+ }+ column "level" {+ type = "LowCardinality(String)"+ }+ column "message" {+ type = "String"+ }+ column "_timestamp" {+ type = "DateTime"+ }+ column "_offset" {+ type = "UInt64"+ }+ engine "distributed" {+ cluster_name = "posthog"+ remote_database = "posthog"+ remote_table = "sharded_log_entries"+ sharding_key = "rand()"+ }+ }++ table "writable_person" {+ column "id" {+ type = "UUID"+ }+ column "created_at" {+ type = "DateTime64(3)"+ }+ column "team_id" {+ type = "Int64"+ }+ column "properties" {+ type = "String"+ }+ column "is_identified" {+ type = "Int8"+ }+ column "is_deleted" {+ type = "Int8"+ }+ column "version" {+ type = "UInt64"+ }+ column "last_seen_at" {+ type = "Nullable(DateTime64(3))"+ }+ column "_timestamp" {+ type = "DateTime"+ }+ column "_offset" {+ type = "UInt64"+ }+ engine "distributed" {+ cluster_name = "posthog_single_shard"+ remote_database = "posthog"+ remote_table = "person"+ }+ }++ table "writable_person_distinct_id2" {+ column "team_id" {+ type = "Int64"+ }+ column "distinct_id" {+ type = "String"+ }+ column "person_id" {+ type = "UUID"+ }+ column "is_deleted" {+ type = "Int8"+ }+ column "version" {+ type = "Int64"+ }+ column "_timestamp" {+ type = "DateTime"+ }+ column "_offset" {+ type = "UInt64"+ }+ column "_partition" {+ type = "UInt64"+ }+ engine "distributed" {+ cluster_name = "posthog_single_shard"+ remote_database = "posthog"+ remote_table = "person_distinct_id2"+ }+ }++ table "writable_person_distinct_id_overrides" {+ column "team_id" {+ type = "Int64"+ }+ column "distinct_id" {+ type = "String"+ }+ column "person_id" {+ type = "UUID"+ }+ column "is_deleted" {+ type = "Int8"+ }+ column "version" {+ type = "Int64"+ }+ column "_timestamp" {+ type = "DateTime"+ }+ column "_offset" {+ type = "UInt64"+ }+ column "_partition" {+ type = "UInt64"+ }+ engine "distributed" {+ cluster_name = "posthog_single_shard"+ remote_database = "posthog"+ remote_table = "person_distinct_id_overrides"+ }+ }++ table "writable_plugin_log_entries" {+ column "id" {+ type = "UUID"+ }+ column "team_id" {+ type = "Int64"+ }+ column "plugin_id" {+ type = "Int64"+ }+ column "plugin_config_id" {+ type = "Int64"+ }+ column "timestamp" {+ type = "DateTime64(6, 'UTC')"+ }+ column "source" {+ type = "String"+ }+ column "type" {+ type = "String"+ }+ column "message" {+ type = "String"+ }+ column "instance_id" {+ type = "UUID"+ }+ column "_timestamp" {+ type = "DateTime"+ }+ column "_offset" {+ type = "UInt64"+ }+ engine "distributed" {+ cluster_name = "posthog_single_shard"+ remote_database = "posthog"+ remote_table = "plugin_log_entries"+ }+ }++ table "writable_posthog_document_embeddings" {+ column "team_id" {+ type = "Int64"+ }+ column "product" {+ type = "LowCardinality(String)"+ }+ column "document_type" {+ type = "LowCardinality(String)"+ }+ column "model_name" {+ type = "LowCardinality(String)"+ }+ column "rendering" {+ type = "LowCardinality(String)"+ }+ column "document_id" {+ type = "String"+ }+ column "timestamp" {+ type = "DateTime64(3, 'UTC')"+ }+ column "inserted_at" {+ type = "DateTime64(3, 'UTC')"+ }+ column "content" {+ type = "String"+ default = "''"+ }+ column "metadata" {+ type = "String"+ default = "'{}'"+ }+ column "embedding" {+ type = "Array(Float64)"+ }+ column "_timestamp" {+ type = "DateTime"+ }+ column "_offset" {+ type = "UInt64"+ }+ column "_partition" {+ type = "UInt64"+ }+ engine "distributed" {+ cluster_name = "posthog"+ remote_database = "posthog"+ remote_table = "partitioned_sharded_posthog_document_embeddings"+ sharding_key = "cityHash64(document_id)"+ }+ }++ table "writable_posthog_document_embeddings_buffer" {+ column "team_id" {+ type = "Int64"+ }+ column "product" {+ type = "LowCardinality(String)"+ }+ column "document_type" {+ type = "LowCardinality(String)"+ }+ column "model_name" {+ type = "LowCardinality(String)"+ }+ column "rendering" {+ type = "LowCardinality(String)"+ }+ column "document_id" {+ type = "String"+ }+ column "timestamp" {+ type = "DateTime64(3, 'UTC')"+ }+ column "inserted_at" {+ type = "DateTime64(3, 'UTC')"+ }+ column "content" {+ type = "String"+ default = "''"+ }+ column "metadata" {+ type = "String"+ default = "'{}'"+ }+ column "embedding" {+ type = "Array(Float64)"+ }+ column "_timestamp" {+ type = "DateTime"+ }+ column "_offset" {+ type = "UInt64"+ }+ column "_partition" {+ type = "UInt64"+ }+ engine "distributed" {+ cluster_name = "posthog"+ remote_database = "posthog"+ remote_table = "sharded_posthog_document_embeddings_buffer"+ sharding_key = "cityHash64(document_id)"+ }+ }++ table "writable_session_replay_events" {+ column "session_id" {+ type = "String"+ }+ column "team_id" {+ type = "Int64"+ }+ column "distinct_id" {+ type = "String"+ }+ column "min_first_timestamp" {+ type = "SimpleAggregateFunction(min, DateTime64(6, 'UTC'))"+ }+ 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)"+ }+ column "keypress_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "mouse_activity_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "active_milliseconds" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "console_log_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "console_warn_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "console_error_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "size" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "message_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "event_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "snapshot_source" {+ type = "AggregateFunction(argMin, LowCardinality(Nullable(String)), DateTime64(6, 'UTC'))"+ }+ column "snapshot_library" {+ type = "AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC'))"+ }+ column "_timestamp" {+ type = "SimpleAggregateFunction(max, DateTime)"+ }+ column "retention_period_days" {+ type = "SimpleAggregateFunction(max, Nullable(Int64))"+ }+ column "is_deleted" {+ type = "SimpleAggregateFunction(max, UInt8)"+ default = "0"+ }+ column "ai_tags_fixed" {+ type = "SimpleAggregateFunction(groupUniqArrayArray, Array(String))"+ }+ column "ai_tags_freeform" {+ type = "SimpleAggregateFunction(groupUniqArrayArray, Array(String))"+ }+ column "ai_highlighted" {+ type = "SimpleAggregateFunction(max, UInt8)"+ default = "0"+ }+ column "surfacing_score" {+ type = "SimpleAggregateFunction(max, Nullable(Float32))"+ }+ engine "distributed" {+ cluster_name = "posthog"+ remote_database = "posthog"+ remote_table = "sharded_session_replay_events"+ sharding_key = "sipHash64(distinct_id)"+ }+ }++ table "writable_usage_report_events_preagg" {+ column "date" {+ type = "Date"+ }+ column "team_id" {+ type = "Int64"+ }+ column "person_mode" {+ type = "LowCardinality(String)"+ }+ column "lib" {+ type = "LowCardinality(String)"+ }+ column "event" {+ type = "String"+ }+ column "distinct_events_unique" {+ type = "AggregateFunction(uniqExact, Tuple(UInt64, UInt64, UInt64))"+ }+ column "event_count" {+ type = "AggregateFunction(sum, UInt64)"+ }+ engine "distributed" {+ cluster_name = "aux"+ remote_database = "posthog"+ remote_table = "sharded_usage_report_events_preagg"+ sharding_key = "sipHash64(date)"+ }+ }++ materialized_view "app_metrics_mv" {+ to_table = "posthog.writable_app_metrics"+ query = <<SQL+SELECT+ team_id,+ timestamp,+ plugin_config_id,+ category,+ job_id,+ successes,+ successes_on_retry,+ failures,+ error_uuid,+ error_type,+ error_details,+ _timestamp,+ _offset,+ _partition+FROM posthog.kafka_app_metrics+SQL++ column "team_id" {+ type = "Int64"+ }+ column "timestamp" {+ type = "DateTime64(6, 'UTC')"+ }+ column "plugin_config_id" {+ type = "Int64"+ }+ column "category" {+ type = "LowCardinality(String)"+ }+ column "job_id" {+ type = "String"+ }+ column "successes" {+ type = "Int64"+ }+ column "successes_on_retry" {+ type = "Int64"+ }+ column "failures" {+ type = "Int64"+ }+ column "error_uuid" {+ type = "UUID"+ }+ column "error_type" {+ type = "String"+ }+ column "error_details" {+ type = "String"+ }+ column "_timestamp" {+ type = "Nullable(DateTime)"+ }+ column "_offset" {+ type = "UInt64"+ }+ column "_partition" {+ type = "UInt64"+ }+ }++ materialized_view "duplicate_events_mv" {+ to_table = "posthog.writable_duplicate_events"+ query = <<SQL+SELECT+ team_id,+ distinct_id,+ event,+ source_uuid,+ duplicate_uuid,+ similarity_score,+ dedup_type,+ is_confirmed,+ reason,+ version,+ different_property_count,+ properties_similarity,+ source_message,+ duplicate_message,+ JSONExtract(+ distinct_fields,+ 'Array(Tuple(field_name String, original_value String, new_value String))'+ ) AS distinct_fields,+ inserted_at,+ _timestamp,+ _offset,+ _partition+FROM posthog.kafka_duplicate_events+SQL++ column "team_id" {+ type = "Int64"+ }+ column "distinct_id" {+ type = "String"+ }+ column "event" {+ type = "String"+ }+ column "source_uuid" {+ type = "UUID"+ }+ column "duplicate_uuid" {+ type = "UUID"+ }+ column "similarity_score" {+ type = "Float64"+ }+ column "dedup_type" {+ type = "LowCardinality(String)"+ }+ column "is_confirmed" {+ type = "UInt8"+ }+ column "reason" {+ type = "Nullable(String)"+ }+ column "version" {+ type = "String"+ }+ column "different_property_count" {+ type = "UInt32"+ }+ column "properties_similarity" {+ type = "Float64"+ }+ column "source_message" {+ type = "String"+ }+ column "duplicate_message" {+ type = "String"+ }+ column "distinct_fields" {+ type = "Array(Tuple(field_name String, original_value String, new_value String))"+ }+ column "inserted_at" {+ type = "DateTime64(3, 'UTC')"+ }+ column "_timestamp" {+ type = "Nullable(DateTime)"+ }+ column "_offset" {+ type = "UInt64"+ }+ column "_partition" {+ type = "UInt64"+ }+ }++ materialized_view "error_tracking_issue_fingerprint_embeddings_mv" {+ to_table = "posthog.writable_error_tracking_issue_fingerprint_embeddings"+ query = <<SQL+SELECT+ team_id,+ model_name,+ embedding_version,+ fingerprint,+ _timestamp AS inserted_at,+ embeddings,+ _timestamp,+ _offset,+ _partition+FROM posthog.kafka_error_tracking_issue_fingerprint_embeddings+SQL++ column "team_id" {+ type = "Int64"+ }+ column "model_name" {+ type = "LowCardinality(String)"+ }+ column "embedding_version" {+ type = "Int64"+ }+ column "fingerprint" {+ type = "String"+ }+ column "inserted_at" {+ type = "Nullable(DateTime)"+ }+ column "embeddings" {+ type = "Array(Float64)"+ }+ column "_timestamp" {+ type = "Nullable(DateTime)"+ }+ column "_offset" {+ type = "UInt64"+ }+ column "_partition" {+ type = "UInt64"+ }+ }++ materialized_view "error_tracking_issue_fingerprint_overrides_mv" {+ to_table = "posthog.writable_error_tracking_issue_fingerprint_overrides"+ query = <<SQL+SELECT+ team_id,+ fingerprint,+ issue_id,+ is_deleted,+ version,+ _timestamp,+ _offset,+ _partition+FROM posthog.kafka_error_tracking_issue_fingerprint_overrides+WHERE version > 0+SQL++ column "team_id" {+ type = "Int64"+ }+ column "fingerprint" {+ type = "String"+ }+ column "issue_id" {+ type = "UUID"+ }+ column "is_deleted" {+ type = "Int8"+ }+ column "version" {+ type = "Int64"+ }+ column "_timestamp" {+ type = "Nullable(DateTime)"+ }+ column "_offset" {+ type = "UInt64"+ }+ column "_partition" {+ type = "UInt64"+ }+ }++ materialized_view "events_dead_letter_queue_mv" {+ to_table = "posthog.writable_events_dead_letter_queue"+ query = <<SQL+SELECT+ id,+ event_uuid,+ event,+ properties,+ distinct_id,+ team_id,+ elements_chain,+ created_at,+ ip,+ site_url,+ now,+ raw_payload,+ error_timestamp,+ error_location,+ error,+ tags,+ _timestamp,+ _offset+FROM posthog.kafka_events_dead_letter_queue+SQL++ column "id" {+ type = "UUID"+ }+ column "event_uuid" {+ type = "UUID"+ }+ column "event" {+ type = "String"+ }+ column "properties" {+ type = "String"+ }+ column "distinct_id" {+ type = "String"+ }+ column "team_id" {+ type = "Int64"+ }+ column "elements_chain" {+ type = "String"+ }+ column "created_at" {+ type = "DateTime64(6, 'UTC')"+ }+ column "ip" {+ type = "String"+ }+ column "site_url" {+ type = "String"+ }+ column "now" {+ type = "DateTime64(6, 'UTC')"+ }+ column "raw_payload" {+ type = "String"+ }+ column "error_timestamp" {+ type = "DateTime64(6, 'UTC')"+ }+ column "error_location" {+ type = "String"+ }+ column "error" {+ type = "String"+ }+ column "tags" {+ type = "Array(String)"+ }+ column "_timestamp" {+ type = "Nullable(DateTime)"+ }+ column "_offset" {+ type = "UInt64"+ }+ }++ materialized_view "groups_mv" {+ to_table = "posthog.writable_groups"+ query = <<SQL+SELECT+ group_type_index,+ group_key,+ created_at,+ team_id,+ group_properties,+ _timestamp,+ _offset+FROM posthog.kafka_groups+SQL++ column "group_type_index" {+ type = "UInt8"+ }+ column "group_key" {+ type = "String"+ }+ column "created_at" {+ type = "DateTime64(3)"+ }+ column "team_id" {+ type = "Int64"+ }+ column "group_properties" {+ type = "String"+ }+ column "_timestamp" {+ type = "Nullable(DateTime)"+ }+ column "_offset" {+ type = "UInt64"+ }+ }++ materialized_view "ingestion_warnings_mv" {+ to_table = "posthog.writable_ingestion_warnings"+ query = <<SQL+SELECT+ team_id,+ source,+ type,+ details,+ timestamp,+ _timestamp,+ _offset,+ _partition+FROM posthog.kafka_ingestion_warnings+SQL++ column "team_id" {+ type = "Int64"+ }+ column "source" {+ type = "LowCardinality(String)"+ }+ column "type" {+ type = "String"+ }+ column "details" {+ type = "String"+ }+ column "timestamp" {+ type = "DateTime64(6, 'UTC')"+ }+ column "_timestamp" {+ type = "Nullable(DateTime)"+ }+ column "_offset" {+ type = "UInt64"+ }+ column "_partition" {+ type = "UInt64"+ }+ }++ materialized_view "log_entries_v3_mv" {+ to_table = "posthog.writable_log_entries"+ query = <<SQL+SELECT+ team_id,+ log_source,+ log_source_id,+ instance_id,+ timestamp,+ level,+ message,+ _timestamp,+ _offset+FROM posthog.kafka_log_entries_v3+WHERE toDate(timestamp) <= today()+SQL++ column "team_id" {+ type = "UInt64"+ }+ column "log_source" {+ type = "LowCardinality(String)"+ }+ column "log_source_id" {+ type = "String"+ }+ column "instance_id" {+ type = "String"+ }+ column "timestamp" {+ type = "DateTime64(6, 'UTC')"+ }+ column "level" {+ type = "LowCardinality(String)"+ }+ column "message" {+ type = "String"+ }+ column "_timestamp" {+ type = "Nullable(DateTime)"+ }+ column "_offset" {+ type = "UInt64"+ }+ }++ materialized_view "log_entries_ws_mv" {+ to_table = "posthog.writable_log_entries"+ query = <<SQL+SELECT+ team_id,+ log_source,+ log_source_id,+ instance_id,+ timestamp,+ level,+ message,+ _timestamp,+ _offset+FROM posthog.kafka_log_entries_ws+WHERE toDate(timestamp) <= today()+SQL++ column "team_id" {+ type = "UInt64"+ }+ column "log_source" {+ type = "LowCardinality(String)"+ }+ column "log_source_id" {+ type = "String"+ }+ column "instance_id" {+ type = "String"+ }+ column "timestamp" {+ type = "DateTime64(6, 'UTC')"+ }+ column "level" {+ type = "LowCardinality(String)"+ }+ column "message" {+ type = "String"+ }+ column "_timestamp" {+ type = "Nullable(DateTime)"+ }+ column "_offset" {+ type = "UInt64"+ }+ }++ materialized_view "person_distinct_id2_mv" {+ to_table = "posthog.writable_person_distinct_id2"+ query = <<SQL+SELECT+ team_id,+ distinct_id,+ person_id,+ is_deleted,+ version,+ _timestamp,+ _offset,+ _partition+FROM posthog.kafka_person_distinct_id2+SQL++ column "team_id" {+ type = "Int64"+ }+ column "distinct_id" {+ type = "String"+ }+ column "person_id" {+ type = "UUID"+ }+ column "is_deleted" {+ type = "Int8"+ }+ column "version" {+ type = "Int64"+ }+ column "_timestamp" {+ type = "Nullable(DateTime)"+ }+ column "_offset" {+ type = "UInt64"+ }+ column "_partition" {+ type = "UInt64"+ }+ }++ materialized_view "person_distinct_id_overrides_mv" {+ to_table = "posthog.writable_person_distinct_id_overrides"+ query = <<SQL+SELECT+ team_id,+ distinct_id,+ person_id,+ is_deleted,+ version,+ _timestamp,+ _offset,+ _partition+FROM posthog.kafka_person_distinct_id_overrides+WHERE version > 0+SQL++ column "team_id" {+ type = "Int64"+ }+ column "distinct_id" {+ type = "String"+ }+ column "person_id" {+ type = "UUID"+ }+ column "is_deleted" {+ type = "Int8"+ }+ column "version" {+ type = "Int64"+ }+ column "_timestamp" {+ type = "Nullable(DateTime)"+ }+ column "_offset" {+ type = "UInt64"+ }+ column "_partition" {+ type = "UInt64"+ }+ }++ materialized_view "person_mv" {+ to_table = "posthog.writable_person"+ query = <<SQL+SELECT+ id,+ created_at,+ team_id,+ properties,+ is_identified,+ is_deleted,+ version,+ last_seen_at,+ _timestamp,+ _offset+FROM posthog.kafka_person+SQL++ column "id" {+ type = "UUID"+ }+ column "created_at" {+ type = "DateTime64(3)"+ }+ column "team_id" {+ type = "Int64"+ }+ column "properties" {+ type = "String"+ }+ column "is_identified" {+ type = "Int8"+ }+ column "is_deleted" {+ type = "Int8"+ }+ column "version" {+ type = "UInt64"+ }+ column "last_seen_at" {+ type = "Nullable(DateTime64(3))"+ }+ column "_timestamp" {+ type = "Nullable(DateTime)"+ }+ column "_offset" {+ type = "UInt64"+ }+ }++ materialized_view "plugin_log_entries_mv" {+ to_table = "posthog.writable_plugin_log_entries"+ query = <<SQL+SELECT+ id,+ team_id,+ plugin_id,+ plugin_config_id,+ timestamp,+ source,+ type,+ message,+ instance_id,+ _timestamp,+ _offset+FROM posthog.kafka_plugin_log_entries+SQL++ column "id" {+ type = "UUID"+ }+ column "team_id" {+ type = "Int64"+ }+ column "plugin_id" {+ type = "Int64"+ }+ column "plugin_config_id" {+ type = "Int64"+ }+ column "timestamp" {+ type = "DateTime64(6, 'UTC')"+ }+ column "source" {+ type = "String"+ }+ column "type" {+ type = "String"+ }+ column "message" {+ type = "String"+ }+ column "instance_id" {+ type = "UUID"+ }+ column "_timestamp" {+ type = "Nullable(DateTime)"+ }+ column "_offset" {+ type = "UInt64"+ }+ }++ materialized_view "posthog_document_embeddings_kafka_to_buffer_mv" {+ to_table = "posthog.writable_posthog_document_embeddings_buffer"+ query = <<SQL+SELECT+ team_id,+ product,+ document_type,+ model_name,+ rendering,+ document_id,+ timestamp,+ _timestamp AS inserted_at,+ coalesce(content, '') AS content,+ coalesce(metadata, '{}') AS metadata,+ embedding,+ _timestamp,+ _offset,+ _partition+FROM posthog.kafka_posthog_document_embeddings+SQL++ column "team_id" {+ type = "Int64"+ }+ column "product" {+ type = "LowCardinality(String)"+ }+ column "document_type" {+ type = "LowCardinality(String)"+ }+ column "model_name" {+ type = "LowCardinality(String)"+ }+ column "rendering" {+ type = "LowCardinality(String)"+ }+ column "document_id" {+ type = "String"+ }+ column "timestamp" {+ type = "DateTime64(3, 'UTC')"+ }+ column "inserted_at" {+ type = "Nullable(DateTime)"+ }+ column "content" {+ type = "String"+ }+ column "metadata" {+ type = "String"+ }+ column "embedding" {+ type = "Array(Float64)"+ }+ column "_timestamp" {+ type = "Nullable(DateTime)"+ }+ column "_offset" {+ type = "UInt64"+ }+ column "_partition" {+ type = "UInt64"+ }+ }++ materialized_view "session_replay_events_mv" {+ to_table = "posthog.writable_session_replay_events"+ query = <<SQL+SELECT+ session_id,+ team_id,+ any(distinct_id) AS distinct_id,+ min(first_timestamp) AS min_first_timestamp,+ max(last_timestamp) AS max_last_timestamp,+ groupArray(if(block_url != '', first_timestamp, NULL)) AS block_first_timestamps,+ groupArray(if(block_url != '', last_timestamp, NULL)) AS block_last_timestamps,+ groupArray(block_url) AS block_urls,+ argMinState(first_url, first_timestamp) AS first_url,+ groupUniqArrayArray(urls) AS all_urls,+ sum(click_count) AS click_count,+ sum(keypress_count) AS keypress_count,+ sum(mouse_activity_count) AS mouse_activity_count,+ sum(active_milliseconds) AS active_milliseconds,+ sum(console_log_count) AS console_log_count,+ sum(console_warn_count) AS console_warn_count,+ sum(console_error_count) AS console_error_count,+ sum(size) AS size,+ sum(message_count) AS message_count,+ sum(event_count) AS event_count,+ argMinState(snapshot_source, first_timestamp) AS snapshot_source,+ argMinState(snapshot_library, first_timestamp) AS snapshot_library,+ max(_timestamp) AS _timestamp,+ max(retention_period_days) AS retention_period_days,+ max(is_deleted) AS is_deleted,+ groupUniqArrayArray(ai_tags_fixed) AS ai_tags_fixed,+ groupUniqArrayArray(ai_tags_freeform) AS ai_tags_freeform,+ max(ai_highlighted) AS ai_highlighted,+ max(surfacing_score) AS surfacing_score+FROM posthog.kafka_session_replay_events+GROUP BY+ session_id, team_id+SQL++ column "session_id" {+ type = "String"+ }+ column "team_id" {+ type = "Int64"+ }+ column "distinct_id" {+ type = "String"+ }+ column "min_first_timestamp" {+ type = "DateTime64(6, 'UTC')"+ }+ column "max_last_timestamp" {+ type = "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 = "Int64"+ }+ column "keypress_count" {+ type = "Int64"+ }+ column "mouse_activity_count" {+ type = "Int64"+ }+ column "active_milliseconds" {+ type = "Int64"+ }+ column "console_log_count" {+ type = "Int64"+ }+ column "console_warn_count" {+ type = "Int64"+ }+ column "console_error_count" {+ type = "Int64"+ }+ column "size" {+ type = "Int64"+ }+ column "message_count" {+ type = "Int64"+ }+ column "event_count" {+ type = "Int64"+ }+ column "snapshot_source" {+ type = "AggregateFunction(argMin, LowCardinality(Nullable(String)), DateTime64(6, 'UTC'))"+ }+ column "snapshot_library" {+ type = "AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC'))"+ }+ column "_timestamp" {+ type = "Nullable(DateTime)"+ }+ column "retention_period_days" {+ type = "SimpleAggregateFunction(max, Nullable(Int64))"+ }+ column "is_deleted" {+ type = "SimpleAggregateFunction(max, UInt8)"+ }+ column "ai_tags_fixed" {+ type = "SimpleAggregateFunction(groupUniqArrayArray, Array(String))"+ }+ column "ai_tags_freeform" {+ type = "SimpleAggregateFunction(groupUniqArrayArray, Array(String))"+ }+ column "ai_highlighted" {+ type = "SimpleAggregateFunction(max, UInt8)"+ }+ column "surfacing_score" {+ type = "SimpleAggregateFunction(max, Nullable(Float32))"+ }+ }++ materialized_view "usage_report_events_preagg_mv" {+ to_table = "posthog.writable_usage_report_events_preagg"+ query = <<SQL+SELECT+ toDate(timestamp) AS date,+ team_id,+ person_mode,+ JSONExtractString(properties, '$lib') AS lib,+ event,+ uniqExactState((cityHash64(distinct_id), cityHash64(toString(uuid)), cityHash64(event))) AS distinct_events_unique,+ sumState(toUInt64(1)) AS event_count+FROM posthog.kafka_usage_report_events_preagg+GROUP BY+ date, team_id, person_mode, lib, event+SQL++ column "date" {+ type = "Date"+ }+ column "team_id" {+ type = "Int64"+ }+ column "person_mode" {+ type = "Enum8('full'=0, 'propertyless'=1, 'force_upgrade'=2)"+ }+ column "lib" {+ type = "String"+ }+ column "event" {+ type = "String"+ }+ column "distinct_events_unique" {+ type = "AggregateFunction(uniqExact, Tuple(UInt64, UInt64, UInt64))"+ }+ column "event_count" {+ type = "AggregateFunction(sum, UInt64)"+ }+ }+}diff --git a/posthog/clickhouse/hcl/golden/local-single/all.hcl b/posthog/clickhouse/hcl/golden/local-single/all.hclnew file mode 100644index 000000000000..8953a5bd0169--- /dev/null+++ b/posthog/clickhouse/hcl/golden/local-single/all.hcl@@ -0,0 +1,22482 @@+node "events" {+ macros = {+ hostClusterRole = "events"+ hostClusterType = "online"+ replica = "events"+ shard = "01"+ }+}++node "medium" {+ macros = {+ hostClusterRole = "medium"+ hostClusterType = "online"+ replica = "medium"+ shard = "01"+ }+}++node "small" {+ macros = {+ hostClusterRole = "small"+ hostClusterType = "online"+ replica = "small"+ shard = "01"+ }+}++database "posthog" {+ table "adhoc_events_deletion" {+ order_by = ["team_id", "uuid"]+ ttl = "deleted_at + toIntervalMonth(3) WHERE is_deleted = 1"+ settings = {+ index_granularity = "8192"+ }+ column "team_id" {+ type = "Int64"+ }+ column "uuid" {+ type = "UUID"+ }+ column "created_at" {+ type = "DateTime64(6, 'UTC')"+ default = "now64()"+ }+ column "deleted_at" {+ type = "DateTime"+ }+ column "is_deleted" {+ type = "UInt8"+ default = "0"+ }+ engine "replicated_replacing_merge_tree" {+ zoo_path = "/clickhouse/tables/noshard/posthog.adhoc_events_deletion"+ replica_name = "{replica}-{shard}"+ version_column = "deleted_at"+ is_deleted_column = "is_deleted"+ }+ }++ table "ai_events" {+ column "uuid" {+ type = "UUID"+ }+ column "event" {+ type = "LowCardinality(String)"+ }+ column "timestamp" {+ type = "DateTime64(6, 'UTC')"+ }+ column "team_id" {+ type = "Int64"+ }+ column "distinct_id" {+ type = "String"+ }+ column "person_id" {+ type = "UUID"+ }+ column "properties" {+ type = "String"+ }+ column "retention_days" {+ type = "Int16"+ default = "30"+ }+ column "drop_date" {+ type = "Date"+ materialized = "toDate(timestamp) + toIntervalDay(retention_days)"+ }+ column "trace_id" {+ type = "String"+ }+ column "session_id" {+ type = "Nullable(String)"+ }+ column "parent_id" {+ type = "Nullable(String)"+ }+ column "span_id" {+ type = "Nullable(String)"+ }+ column "span_type" {+ type = "LowCardinality(Nullable(String))"+ }+ column "generation_id" {+ type = "Nullable(String)"+ }+ column "experiment_id" {+ type = "Nullable(String)"+ }+ column "span_name" {+ type = "Nullable(String)"+ }+ column "trace_name" {+ type = "Nullable(String)"+ }+ column "prompt_name" {+ type = "Nullable(String)"+ }+ column "model" {+ type = "LowCardinality(Nullable(String))"+ }+ column "provider" {+ type = "LowCardinality(Nullable(String))"+ }+ column "framework" {+ type = "LowCardinality(Nullable(String))"+ }+ column "total_tokens" {+ type = "Nullable(Int64)"+ }+ column "input_tokens" {+ type = "Nullable(Int64)"+ }+ column "output_tokens" {+ type = "Nullable(Int64)"+ }+ column "text_input_tokens" {+ type = "Nullable(Int64)"+ }+ column "text_output_tokens" {+ type = "Nullable(Int64)"+ }+ column "image_input_tokens" {+ type = "Nullable(Int64)"+ }+ column "image_output_tokens" {+ type = "Nullable(Int64)"+ }+ column "audio_input_tokens" {+ type = "Nullable(Int64)"+ }+ column "audio_output_tokens" {+ type = "Nullable(Int64)"+ }+ column "video_input_tokens" {+ type = "Nullable(Int64)"+ }+ column "video_output_tokens" {+ type = "Nullable(Int64)"+ }+ column "reasoning_tokens" {+ type = "Nullable(Int64)"+ }+ column "cache_read_input_tokens" {+ type = "Nullable(Int64)"+ }+ column "cache_creation_input_tokens" {+ type = "Nullable(Int64)"+ }+ column "web_search_count" {+ type = "Nullable(Int64)"+ }+ column "input_cost_usd" {+ type = "Nullable(Float64)"+ }+ column "output_cost_usd" {+ type = "Nullable(Float64)"+ }+ column "total_cost_usd" {+ type = "Nullable(Float64)"+ }+ column "request_cost_usd" {+ type = "Nullable(Float64)"+ }+ column "web_search_cost_usd" {+ type = "Nullable(Float64)"+ }+ column "audio_cost_usd" {+ type = "Nullable(Float64)"+ }+ column "image_cost_usd" {+ type = "Nullable(Float64)"+ }+ column "video_cost_usd" {+ type = "Nullable(Float64)"+ }+ column "latency" {+ type = "Nullable(Float64)"+ }+ column "time_to_first_token" {+ type = "Nullable(Float64)"+ }+ column "is_error" {+ type = "UInt8"+ }+ column "error" {+ type = "Nullable(String)"+ }+ column "error_type" {+ type = "LowCardinality(Nullable(String))"+ }+ column "error_normalized" {+ type = "Nullable(String)"+ }+ column "input" {+ type = "Nullable(String)"+ }+ column "output" {+ type = "Nullable(String)"+ }+ column "output_choices" {+ type = "Nullable(String)"+ }+ column "input_state" {+ type = "Nullable(String)"+ }+ column "output_state" {+ type = "Nullable(String)"+ }+ column "tools" {+ type = "Nullable(String)"+ }+ column "_timestamp" {+ type = "DateTime"+ }+ column "_offset" {+ type = "UInt64"+ }+ column "_partition" {+ type = "UInt64"+ }+ engine "distributed" {+ cluster_name = "ai_events"+ remote_database = "posthog"+ remote_table = "sharded_ai_events"+ sharding_key = "cityHash64(concat(toString(team_id), '-', trace_id, '-', toString(toDate(timestamp))))"+ }+ }++ table "app_metrics" {+ column "team_id" {+ type = "Int64"+ }+ column "timestamp" {+ type = "DateTime64(6, 'UTC')"+ }+ column "plugin_config_id" {+ type = "Int64"+ }+ column "category" {+ type = "LowCardinality(String)"+ }+ column "job_id" {+ type = "String"+ }+ column "successes" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "successes_on_retry" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "failures" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "error_uuid" {+ type = "UUID"+ }+ column "error_type" {+ type = "String"+ }+ column "error_details" {+ type = "String"+ codec = "ZSTD(3)"+ }+ column "_timestamp" {+ type = "DateTime"+ }+ column "_offset" {+ type = "UInt64"+ }+ column "_partition" {+ type = "UInt64"+ }+ engine "distributed" {+ cluster_name = "posthog"+ remote_database = "posthog"+ remote_table = "sharded_app_metrics"+ sharding_key = "rand()"+ }+ }++ table "app_metrics2" {+ column "team_id" {+ type = "Int64"+ }+ column "timestamp" {+ type = "DateTime64(6, 'UTC')"+ }+ column "app_source" {+ type = "LowCardinality(String)"+ }+ column "app_source_id" {+ type = "String"+ }+ column "instance_id" {+ type = "String"+ }+ column "metric_kind" {+ type = "LowCardinality(String)"+ }+ column "metric_name" {+ type = "LowCardinality(String)"+ }+ column "count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "_timestamp" {+ type = "DateTime"+ }+ column "_offset" {+ type = "UInt64"+ }+ column "_partition" {+ type = "UInt64"+ }+ engine "distributed" {+ cluster_name = "posthog"+ remote_database = "posthog"+ remote_table = "sharded_app_metrics2"+ sharding_key = "rand()"+ }+ }++ table "channel_definition" {+ order_by = ["domain", "kind"]+ settings = {+ index_granularity = "8192"+ }+ column "domain" {+ type = "String"+ }+ column "kind" {+ type = "String"+ }+ column "domain_type" {+ type = "Nullable(String)"+ }+ column "type_if_paid" {+ type = "Nullable(String)"+ }+ column "type_if_organic" {+ type = "Nullable(String)"+ }+ engine "replicated_merge_tree" {+ zoo_path = "/clickhouse/tables/noshard/posthog.channel_definition"+ replica_name = "{replica}-{shard}"+ }+ }++ table "cohort_membership" {+ order_by = ["team_id", "cohort_id", "person_id"]+ settings = {+ index_granularity = "8192"+ }+ column "team_id" {+ type = "Int64"+ }+ column "cohort_id" {+ type = "Int64"+ }+ column "person_id" {+ type = "UUID"+ }+ column "status" {+ type = "Enum8('entered'=1, 'left'=2)"+ }+ column "last_updated" {+ type = "DateTime64(6)"+ default = "now64()"+ }+ engine "replicated_replacing_merge_tree" {+ zoo_path = "/clickhouse/tables/noshard/posthog.cohort_membership"+ replica_name = "{replica}-{shard}"+ version_column = "last_updated"+ }+ }++ table "cohortpeople" {+ order_by = ["team_id", "cohort_id", "person_id", "version"]+ settings = {+ index_granularity = "8192"+ }+ column "person_id" {+ type = "UUID"+ }+ column "cohort_id" {+ type = "Int64"+ }+ column "team_id" {+ type = "Int64"+ }+ column "sign" {+ type = "Int8"+ }+ column "version" {+ type = "UInt64"+ }+ engine "replicated_collapsing_merge_tree" {+ zoo_path = "/clickhouse/tables/noshard/posthog.cohortpeople"+ replica_name = "{replica}-{shard}"+ sign_column = "sign"+ }+ }++ table "conversion_goal_attributed_preaggregated" {+ column "team_id" {+ type = "Int64"+ }+ column "job_id" {+ type = "UUID"+ }+ column "person_id" {+ type = "UUID"+ }+ column "conversion_timestamp" {+ type = "DateTime64(6, 'UTC')"+ }+ column "conversion_value" {+ type = "Float64"+ }+ column "touchpoint_timestamp" {+ type = "DateTime64(6, 'UTC')"+ }+ column "touchpoint_weight" {+ type = "Float64"+ }+ column "campaign_name" {+ type = "String"+ }+ column "source_name" {+ type = "String"+ }+ column "medium_name" {+ type = "String"+ }+ column "content_name" {+ type = "String"+ }+ column "term_name" {+ type = "String"+ }+ column "referring_domain_name" {+ type = "String"+ }+ column "gclid_name" {+ type = "String"+ }+ column "fbclid_name" {+ type = "String"+ }+ column "gad_source_name" {+ type = "String"+ }+ column "computed_at" {+ type = "DateTime64(6, 'UTC')"+ default = "now()"+ }+ column "expires_at" {+ type = "Date"+ default = "today() + toIntervalDay(7)"+ }+ engine "distributed" {+ cluster_name = "aux"+ remote_database = "posthog"+ remote_table = "sharded_conversion_goal_attributed_preaggregated"+ sharding_key = "cityHash64(person_id)"+ }+ }++ table "distinct_id_usage" {+ column "team_id" {+ type = "Int64"+ }+ column "distinct_id" {+ type = "String"+ }+ column "minute" {+ type = "DateTime"+ }+ column "event_count" {+ type = "UInt64"+ }+ engine "distributed" {+ cluster_name = "posthog"+ remote_database = "posthog"+ remote_table = "sharded_distinct_id_usage"+ sharding_key = "sipHash64(distinct_id)"+ }+ }++ table "distributed_events_recent" {+ column "uuid" {+ type = "UUID"+ }+ column "event" {+ type = "String"+ }+ column "properties" {+ type = "String"+ codec = "ZSTD(3)"+ }+ column "timestamp" {+ type = "DateTime64(6, 'UTC')"+ }+ column "team_id" {+ type = "Int64"+ }+ column "distinct_id" {+ type = "String"+ }+ column "elements_chain" {+ type = "String"+ }+ column "created_at" {+ type = "DateTime64(6, 'UTC')"+ }+ column "person_id" {+ type = "UUID"+ }+ column "person_created_at" {+ type = "DateTime64(3)"+ }+ column "person_properties" {+ type = "String"+ codec = "ZSTD(3)"+ }+ column "group0_properties" {+ type = "String"+ codec = "ZSTD(3)"+ }+ column "group1_properties" {+ type = "String"+ codec = "ZSTD(3)"+ }+ column "group2_properties" {+ type = "String"+ codec = "ZSTD(3)"+ }+ column "group3_properties" {+ type = "String"+ codec = "ZSTD(3)"+ }+ column "group4_properties" {+ type = "String"+ codec = "ZSTD(3)"+ }+ column "group0_created_at" {+ type = "DateTime64(3)"+ }+ column "group1_created_at" {+ type = "DateTime64(3)"+ }+ column "group2_created_at" {+ type = "DateTime64(3)"+ }+ column "group3_created_at" {+ type = "DateTime64(3)"+ }+ column "group4_created_at" {+ type = "DateTime64(3)"+ }+ column "person_mode" {+ type = "Enum8('full'=0, 'propertyless'=1, 'force_upgrade'=2)"+ }+ column "historical_migration" {+ type = "Bool"+ }+ column "_timestamp" {+ type = "DateTime"+ }+ column "_offset" {+ type = "UInt64"+ }+ column "inserted_at" {+ type = "DateTime64(6, 'UTC')"+ default = "now64()"+ }+ engine "distributed" {+ cluster_name = "posthog_primary_replica"+ remote_database = "posthog"+ remote_table = "sharded_events_recent"+ sharding_key = "sipHash64(distinct_id)"+ }+ }++ table "distributed_posthog_document_embeddings" {+ column "team_id" {+ type = "Int64"+ }+ column "product" {+ type = "LowCardinality(String)"+ }+ column "document_type" {+ type = "LowCardinality(String)"+ }+ column "model_name" {+ type = "LowCardinality(String)"+ }+ column "rendering" {+ type = "LowCardinality(String)"+ }+ column "document_id" {+ type = "String"+ }+ column "timestamp" {+ type = "DateTime64(3, 'UTC')"+ }+ column "inserted_at" {+ type = "DateTime64(3, 'UTC')"+ }+ column "content" {+ type = "String"+ default = "''"+ }+ column "metadata" {+ type = "String"+ default = "'{}'"+ }+ column "embedding" {+ type = "Array(Float64)"+ }+ column "_timestamp" {+ type = "DateTime"+ }+ column "_offset" {+ type = "UInt64"+ }+ column "_partition" {+ type = "UInt64"+ }+ engine "distributed" {+ cluster_name = "posthog"+ remote_database = "posthog"+ remote_table = "partitioned_sharded_posthog_document_embeddings"+ sharding_key = "cityHash64(document_id)"+ }+ }++ table "distributed_posthog_document_embeddings_text_embedding_3_large_3072" {+ column "team_id" {+ type = "Int64"+ }+ column "product" {+ type = "LowCardinality(String)"+ }+ column "document_type" {+ type = "LowCardinality(String)"+ }+ column "rendering" {+ type = "LowCardinality(String)"+ }+ column "document_id" {+ type = "String"+ }+ column "timestamp" {+ type = "DateTime64(3, 'UTC')"+ }+ column "inserted_at" {+ type = "DateTime64(3, 'UTC')"+ }+ column "content" {+ type = "String"+ default = "''"+ }+ column "metadata" {+ type = "String"+ default = "'{}'"+ }+ column "embedding" {+ type = "Array(Float64)"+ }+ column "_timestamp" {+ type = "DateTime"+ }+ column "_offset" {+ type = "UInt64"+ }+ column "_partition" {+ type = "UInt64"+ }+ engine "distributed" {+ cluster_name = "posthog"+ remote_database = "posthog"+ remote_table = "sharded_posthog_document_embeddings_text_embedding_3_large_3072"+ sharding_key = "cityHash64(document_id)"+ }+ }++ table "distributed_posthog_document_embeddings_text_embedding_3_small_1536" {+ column "team_id" {+ type = "Int64"+ }+ column "product" {+ type = "LowCardinality(String)"+ }+ column "document_type" {+ type = "LowCardinality(String)"+ }+ column "rendering" {+ type = "LowCardinality(String)"+ }+ column "document_id" {+ type = "String"+ }+ column "timestamp" {+ type = "DateTime64(3, 'UTC')"+ }+ column "inserted_at" {+ type = "DateTime64(3, 'UTC')"+ }+ column "content" {+ type = "String"+ default = "''"+ }+ column "metadata" {+ type = "String"+ default = "'{}'"+ }+ column "embedding" {+ type = "Array(Float64)"+ }+ column "_timestamp" {+ type = "DateTime"+ }+ column "_offset" {+ type = "UInt64"+ }+ column "_partition" {+ type = "UInt64"+ }+ engine "distributed" {+ cluster_name = "posthog"+ remote_database = "posthog"+ remote_table = "sharded_posthog_document_embeddings_text_embedding_3_small_1536"+ sharding_key = "cityHash64(document_id)"+ }+ }++ table "distributed_system_processes" {+ settings = {+ skip_unavailable_shards = "1"+ }+ column "is_initial_query" {+ type = "UInt8"+ }+ column "user" {+ type = "String"+ }+ column "query_id" {+ type = "String"+ }+ column "address" {+ type = "IPv6"+ }+ column "port" {+ type = "UInt16"+ }+ column "initial_user" {+ type = "String"+ }+ column "initial_query_id" {+ type = "String"+ }+ column "initial_address" {+ type = "IPv6"+ }+ column "initial_port" {+ type = "UInt16"+ }+ column "interface" {+ type = "UInt8"+ }+ column "os_user" {+ type = "String"+ }+ column "client_hostname" {+ type = "String"+ }+ column "client_name" {+ type = "String"+ }+ column "client_agent" {+ type = "LowCardinality(String)"+ }+ column "client_revision" {+ type = "UInt64"+ }+ column "client_version_major" {+ type = "UInt64"+ }+ column "client_version_minor" {+ type = "UInt64"+ }+ column "client_version_patch" {+ type = "UInt64"+ }+ column "client_agent" {+ type = "LowCardinality(String)"+ }+ column "http_method" {+ type = "UInt8"+ }+ column "http_user_agent" {+ type = "String"+ }+ column "http_referer" {+ type = "String"+ }+ column "forwarded_for" {+ type = "String"+ }+ column "quota_key" {+ type = "String"+ }+ column "distributed_depth" {+ type = "UInt64"+ }+ column "elapsed" {+ type = "Float64"+ }+ column "is_cancelled" {+ type = "UInt8"+ }+ column "is_all_data_sent" {+ type = "UInt8"+ }+ column "read_rows" {+ type = "UInt64"+ }+ column "read_bytes" {+ type = "UInt64"+ }+ column "total_rows_approx" {+ type = "UInt64"+ }+ column "written_rows" {+ type = "UInt64"+ }+ column "written_bytes" {+ type = "UInt64"+ }+ column "memory_usage" {+ type = "Int64"+ }+ column "peak_memory_usage" {+ type = "Int64"+ }+ column "query" {+ type = "String"+ }+ column "normalized_query_hash" {+ type = "UInt64"+ }+ column "query_kind" {+ type = "String"+ }+ column "thread_ids" {+ type = "Array(UInt64)"+ }+ column "peak_threads_usage" {+ type = "UInt64"+ }+ column "ProfileEvents" {+ type = "Map(LowCardinality(String), UInt64)"+ }+ column "Settings" {+ type = "Map(LowCardinality(String), LowCardinality(String))"+ }+ column "current_database" {+ type = "String"+ }+ column "is_internal" {+ type = "UInt8"+ }+ column "ProfileEvents.Names" {+ type = "Array(String)"+ alias = "mapKeys(ProfileEvents)"+ }+ column "ProfileEvents.Values" {+ type = "Array(UInt64)"+ alias = "mapValues(ProfileEvents)"+ }+ column "Settings.Names" {+ type = "Array(String)"+ alias = "mapKeys(Settings)"+ }+ column "Settings.Values" {+ type = "Array(String)"+ alias = "mapValues(Settings)"+ }+ engine "distributed" {+ cluster_name = "posthog"+ remote_database = "system"+ remote_table = "processes"+ }+ }++ table "duplicate_events" {+ order_by = ["team_id", "distinct_id", "event", "inserted_at"]+ partition_by = "toYYYYMMDD(inserted_at)"+ ttl = "inserted_at + toIntervalDay(7)"+ settings = {+ index_granularity = "512"+ }+ column "team_id" {+ type = "Int64"+ }+ column "distinct_id" {+ type = "String"+ }+ column "event" {+ type = "String"+ }+ column "source_uuid" {+ type = "UUID"+ }+ column "duplicate_uuid" {+ type = "UUID"+ }+ column "similarity_score" {+ type = "Float64"+ }+ column "dedup_type" {+ type = "LowCardinality(String)"+ }+ column "is_confirmed" {+ type = "UInt8"+ }+ column "reason" {+ type = "Nullable(String)"+ }+ column "version" {+ type = "String"+ }+ column "different_property_count" {+ type = "UInt32"+ }+ column "properties_similarity" {+ type = "Float64"+ }+ column "source_message" {+ type = "String"+ }+ column "duplicate_message" {+ type = "String"+ }+ column "distinct_fields" {+ type = "Array(Tuple(field_name String, original_value String, new_value String))"+ }+ column "inserted_at" {+ type = "DateTime64(3, 'UTC')"+ }+ column "_timestamp" {+ type = "DateTime"+ }+ column "_offset" {+ type = "UInt64"+ }+ column "_partition" {+ type = "UInt64"+ }+ index "kafka_timestamp_minmax_duplicate_events" {+ expr = "_timestamp"+ type = "minmax"+ granularity = 3+ }+ engine "replicated_merge_tree" {+ zoo_path = "/clickhouse/tables/noshard/posthog.duplicate_events"+ replica_name = "{replica}-{shard}"+ }+ }++ table "error_tracking_fingerprint_issue_state" {+ column "team_id" {+ type = "Int64"+ }+ column "fingerprint" {+ type = "String"+ }+ column "issue_id" {+ type = "UUID"+ }+ column "issue_name" {+ type = "Nullable(String)"+ }+ column "issue_description" {+ type = "Nullable(String)"+ }+ column "issue_status" {+ type = "String"+ }+ column "issue_severity" {+ type = "Nullable(String)"+ }+ column "assigned_user_id" {+ type = "Nullable(Int64)"+ }+ column "assigned_role_id" {+ type = "Nullable(UUID)"+ }+ column "first_seen" {+ type = "DateTime64(3, 'UTC')"+ }+ column "is_deleted" {+ type = "Int8"+ }+ column "version" {+ type = "Int64"+ }+ column "_timestamp" {+ type = "DateTime"+ }+ column "_offset" {+ type = "UInt64"+ }+ column "_partition" {+ type = "UInt64"+ }+ engine "distributed" {+ cluster_name = "aux"+ remote_database = "posthog"+ remote_table = "raw_error_tracking_fingerprint_issue_state"+ }+ }++ table "error_tracking_issue_fingerprint_overrides" {+ order_by = ["team_id", "fingerprint"]+ settings = {+ index_granularity = "512"+ }+ column "team_id" {+ type = "Int64"+ }+ column "fingerprint" {+ type = "String"+ }+ column "issue_id" {+ type = "UUID"+ }+ column "is_deleted" {+ type = "Int8"+ }+ column "version" {+ type = "Int64"+ }+ column "_timestamp" {+ type = "DateTime"+ }+ column "_offset" {+ type = "UInt64"+ }+ column "_partition" {+ type = "UInt64"+ }+ index "kafka_timestamp_minmax_error_tracking_issue_fingerprint_overrides" {+ expr = "_timestamp"+ type = "minmax"+ granularity = 3+ }+ engine "replicated_replacing_merge_tree" {+ zoo_path = "/clickhouse/tables/noshard/posthog.error_tracking_issue_fingerprint_overrides"+ replica_name = "{replica}-{shard}"+ version_column = "version"+ }+ }++ table "events" {+ column "uuid" {+ type = "UUID"+ }+ column "event" {+ type = "String"+ }+ column "properties" {+ type = "String"+ codec = "ZSTD(3)"+ }+ column "timestamp" {+ type = "DateTime64(6, 'UTC')"+ }+ column "team_id" {+ type = "Int64"+ }+ column "distinct_id" {+ type = "String"+ }+ column "created_at" {+ type = "DateTime64(6, 'UTC')"+ }+ column "$group_0" {+ type = "String"+ comment = "column_materializer::$group_0"+ }+ column "$group_1" {+ type = "String"+ comment = "column_materializer::$group_1"+ }+ column "$group_2" {+ type = "String"+ comment = "column_materializer::$group_2"+ }+ column "$group_3" {+ type = "String"+ comment = "column_materializer::$group_3"+ }+ column "$group_4" {+ type = "String"+ comment = "column_materializer::$group_4"+ }+ column "$window_id" {+ type = "String"+ comment = "column_materializer::$window_id"+ }+ column "$session_id" {+ type = "String"+ comment = "column_materializer::$session_id"+ }+ column "inserted_at" {+ type = "Nullable(DateTime64(6, 'UTC'))"+ default = "now64()"+ }+ column "person_mode" {+ type = "Enum8('full'=0, 'propertyless'=1, 'force_upgrade'=2)"+ }+ column "elements_chain_href" {+ type = "String"+ comment = "column_materializer::elements_chain::href"+ }+ column "elements_chain_texts" {+ type = "Array(String)"+ comment = "column_materializer::elements_chain::texts"+ }+ column "elements_chain_ids" {+ type = "Array(String)"+ comment = "column_materializer::elements_chain::ids"+ }+ column "elements_chain_elements" {+ type = "Array(Enum8('a'=1, 'button'=2, 'form'=3, 'input'=4, 'select'=5, 'textarea'=6, 'label'=7))"+ comment = "column_materializer::elements_chain::elements"+ }+ column "properties_group_custom" {+ type = "Map(String, String)"+ }+ column "properties_group_feature_flags" {+ type = "Map(String, String)"+ }+ column "is_deleted" {+ type = "Bool"+ }+ column "person_properties_map_custom" {+ type = "Map(String, String)"+ }+ column "$session_id_uuid" {+ type = "Nullable(UInt128)"+ }+ column "consumer_breadcrumbs" {+ type = "Array(String)"+ }+ column "properties_group_ai" {+ type = "Map(String, String)"+ }+ column "mat_$ai_session_id" {+ type = "Nullable(String)"+ comment = "column_materializer::properties::$ai_session_id"+ }+ column "mat_$ai_is_error" {+ type = "Nullable(String)"+ comment = "column_materializer::properties::$ai_is_error"+ }+ column "dmat_string_0" {+ type = "Nullable(String)"+ }+ column "dmat_string_1" {+ type = "Nullable(String)"+ }+ column "dmat_string_2" {+ type = "Nullable(String)"+ }+ column "dmat_string_3" {+ type = "Nullable(String)"+ }+ column "dmat_string_4" {+ type = "Nullable(String)"+ }+ column "dmat_string_5" {+ type = "Nullable(String)"+ }+ column "dmat_string_6" {+ type = "Nullable(String)"+ }+ column "dmat_string_7" {+ type = "Nullable(String)"+ }+ column "dmat_string_8" {+ type = "Nullable(String)"+ }+ column "dmat_string_9" {+ type = "Nullable(String)"+ }+ column "historical_migration" {+ type = "Bool"+ }+ column "mat_$ai_prompt_name" {+ type = "Nullable(String)"+ comment = "column_materializer::properties::$ai_prompt_name"+ }+ column "elements_chain" {+ type = "String"+ }+ column "person_id" {+ type = "UUID"+ }+ column "person_created_at" {+ type = "DateTime64(3)"+ }+ column "person_properties" {+ type = "String"+ codec = "ZSTD(3)"+ }+ column "group0_properties" {+ type = "String"+ codec = "ZSTD(3)"+ }+ column "group1_properties" {+ type = "String"+ codec = "ZSTD(3)"+ }+ column "group2_properties" {+ type = "String"+ codec = "ZSTD(3)"+ }+ column "group3_properties" {+ type = "String"+ codec = "ZSTD(3)"+ }+ column "group4_properties" {+ type = "String"+ codec = "ZSTD(3)"+ }+ column "group0_created_at" {+ type = "DateTime64(3)"+ }+ column "group1_created_at" {+ type = "DateTime64(3)"+ }+ column "group2_created_at" {+ type = "DateTime64(3)"+ }+ column "group3_created_at" {+ type = "DateTime64(3)"+ }+ column "group4_created_at" {+ type = "DateTime64(3)"+ }+ column "_timestamp" {+ type = "DateTime"+ }+ column "_offset" {+ type = "UInt64"+ }+ column "mat_$ai_trace_id" {+ type = "Nullable(String)"+ comment = "column_materializer::properties::$ai_trace_id"+ }+ column "mat_$ai_experiment_id" {+ type = "Nullable(String)"+ comment = "column_materializer::properties::$ai_experiment_id"+ }+ engine "distributed" {+ cluster_name = "posthog"+ remote_database = "posthog"+ remote_table = "sharded_events"+ sharding_key = "sipHash64(distinct_id)"+ }+ }++ table "events_dead_letter_queue" {+ order_by = ["id", "event_uuid", "distinct_id", "team_id"]+ ttl = "toDate(_timestamp) + toIntervalWeek(4)"+ settings = {+ index_granularity = "512"+ }+ column "id" {+ type = "UUID"+ }+ column "event_uuid" {+ type = "UUID"+ }+ column "event" {+ type = "String"+ }+ column "properties" {+ type = "String"+ }+ column "distinct_id" {+ type = "String"+ }+ column "team_id" {+ type = "Int64"+ }+ column "elements_chain" {+ type = "String"+ }+ column "created_at" {+ type = "DateTime64(6, 'UTC')"+ }+ column "ip" {+ type = "String"+ }+ column "site_url" {+ type = "String"+ }+ column "now" {+ type = "DateTime64(6, 'UTC')"+ }+ column "raw_payload" {+ type = "String"+ }+ column "error_timestamp" {+ type = "DateTime64(6, 'UTC')"+ }+ column "error_location" {+ type = "String"+ }+ column "error" {+ type = "String"+ }+ column "tags" {+ type = "Array(String)"+ }+ column "_timestamp" {+ type = "DateTime"+ }+ column "_offset" {+ type = "UInt64"+ }+ index "kafka_timestamp_minmax_events_dead_letter_queue" {+ expr = "_timestamp"+ type = "minmax"+ granularity = 3+ }+ engine "replicated_replacing_merge_tree" {+ zoo_path = "/clickhouse/tables/noshard/posthog.events_dead_letter_queue"+ replica_name = "{replica}-{shard}"+ version_column = "_timestamp"+ }+ }++ table "events_json" {+ column "uuid" {+ type = "UUID"+ }+ column "event" {+ type = "String"+ }+ column "properties" {+ type = "JSON(max_dynamic_types=8, max_dynamic_paths=256, `$active_feature_flags` Array(String), `$ai_experiment_id` Nullable(String), `$ai_http_status` Nullable(String), `$ai_is_error` Nullable(String), `$ai_model` Nullable(String), `$ai_parent_id` Nullable(String), `$ai_prompt_name` Nullable(String), `$ai_provider` Nullable(String), `$ai_session_id` Nullable(String), `$ai_span_id` Nullable(String), `$ai_total_cost_usd` Nullable(String), `$ai_trace_id` Nullable(String), `$anon_distinct_id` Nullable(String), `$app_build` Nullable(String), `$app_namespace` Nullable(String), `$app_version` Nullable(String), `$browser` Nullable(String), `$browser_version` Nullable(String), `$current_url` Nullable(String), `$device` Nullable(String), `$device_id` Nullable(String), `$device_model` Nullable(String), `$device_type` Nullable(String), `$el_text` Nullable(String), `$event_type` Nullable(String), `$exception_fingerprint` Nullable(String), `$exception_functions` Array(String), `$exception_issue_id` Nullable(String), `$exception_sources` Array(String), `$exception_types` Array(String), `$exception_values` Array(String), `$feature_flag` Nullable(String), `$feature_flag_payloads` Nullable(String), `$feature_flag_response` Nullable(String), `$geoip_city_name` Nullable(String), `$geoip_country_code` Nullable(String), `$geoip_country_name` Nullable(String), `$geoip_subdivision_1_code` Nullable(String), `$group_0` Nullable(String), `$group_1` Nullable(String), `$group_2` Nullable(String), `$group_3` Nullable(String), `$group_4` Nullable(String), `$groups` Nullable(String), `$host` Nullable(String), `$initial_pathname` Nullable(String), `$initial_referrer` Nullable(String), `$initial_referring_domain` Nullable(String), `$ip` Nullable(String), `$is_identified` Nullable(String), `$lib` Nullable(String), `$lib_custom_api_host` Nullable(String), `$lib_version` Nullable(String), `$lib_version__minor` Nullable(String), `$os` Nullable(String), `$os_name` Nullable(String), `$os_version` Nullable(String), `$pathname` Nullable(String), `$prev_pageview_max_content_percentage` Nullable(String), `$prev_pageview_max_scroll_percentage` Nullable(String), `$prev_pageview_pathname` Nullable(String), `$process_person_profile` Nullable(String), `$referrer` Nullable(String), `$referring_domain` Nullable(String), `$screen_height` Nullable(String), `$screen_name` Nullable(String), `$screen_width` Nullable(String), `$sent_at` Nullable(String), `$session_id` Nullable(String), `$survey_id` Nullable(String), `$survey_response` Nullable(String), `$survey_response_1` Nullable(String), `$time` Nullable(String), `$user_id` Nullable(String), `$viewport_height` Nullable(String), `$viewport_width` Nullable(String), `$web_vitals_CLS_value` Nullable(String), `$web_vitals_FCP_value` Nullable(String), `$web_vitals_INP_value` Nullable(String), `$web_vitals_LCP_value` Nullable(String), `$window_id` Nullable(String))"+ }+ column "timestamp" {+ type = "DateTime64(6, 'UTC')"+ }+ column "team_id" {+ type = "Int64"+ }+ column "distinct_id" {+ type = "String"+ }+ column "elements_hash" {+ type = "String"+ default = "''"+ }+ column "created_at" {+ type = "DateTime64(6, 'UTC')"+ }+ column "_timestamp" {+ type = "DateTime"+ }+ column "_offset" {+ type = "UInt64"+ }+ column "elements_chain" {+ type = "String"+ }+ column "person_id" {+ type = "UUID"+ }+ column "person_properties" {+ type = "JSON(max_dynamic_types=6, max_dynamic_paths=32, `$app_version` Nullable(String), `$browser` Nullable(String), `$current_url` Nullable(String), `$geoip_continent_name` Nullable(String), `$geoip_country_code` Nullable(String), `$geoip_country_name` Nullable(String), `$initial_current_url` Nullable(String), `$initial_fbclid` Nullable(String), `$initial_gad_source` Nullable(String), `$initial_gbraid` Nullable(String), `$initial_gclid` Nullable(String), `$initial_msclkid` Nullable(String), `$initial_pathname` Nullable(String), `$initial_referring_domain` Nullable(String), `$initial_utm_campaign` Nullable(String), `$initial_utm_content` Nullable(String), `$initial_utm_medium` Nullable(String), `$initial_utm_source` Nullable(String), `$initial_utm_term` Nullable(String), `$initial_wbraid` Nullable(String), `$os_name` Nullable(String), `$referring_domain` Nullable(String))"+ }+ column "group0_properties" {+ type = "String"+ codec = "ZSTD(3)"+ }+ column "group1_properties" {+ type = "String"+ codec = "ZSTD(3)"+ }+ column "group2_properties" {+ type = "String"+ codec = "ZSTD(3)"+ }+ column "group3_properties" {+ type = "String"+ codec = "ZSTD(3)"+ }+ column "group4_properties" {+ type = "String"+ codec = "ZSTD(3)"+ }+ column "person_created_at" {+ type = "DateTime64(3)"+ }+ column "group0_created_at" {+ type = "DateTime64(3)"+ }+ column "group1_created_at" {+ type = "DateTime64(3)"+ }+ column "group2_created_at" {+ type = "DateTime64(3)"+ }+ column "group3_created_at" {+ type = "DateTime64(3)"+ }+ column "group4_created_at" {+ type = "DateTime64(3)"+ }+ column "inserted_at" {+ type = "Nullable(DateTime64(6, 'UTC'))"+ default = "now64()"+ }+ column "person_mode" {+ type = "Enum8('full'=0, 'propertyless'=1, 'force_upgrade'=2)"+ }+ column "is_deleted" {+ type = "Bool"+ default = "false"+ }+ column "consumer_breadcrumbs" {+ type = "Array(String)"+ }+ column "historical_migration" {+ type = "Bool"+ default = "false"+ }+ column "$group_0" {+ type = "String"+ }+ column "$group_1" {+ type = "String"+ }+ column "$group_2" {+ type = "String"+ }+ column "$group_3" {+ type = "String"+ }+ column "$group_4" {+ type = "String"+ }+ column "$window_id" {+ type = "String"+ }+ column "$session_id" {+ type = "String"+ }+ column "$session_id_uuid" {+ type = "Nullable(UInt128)"+ }+ column "elements_chain_href" {+ type = "String"+ }+ column "elements_chain_texts" {+ type = "Array(String)"+ }+ column "elements_chain_ids" {+ type = "Array(String)"+ }+ column "elements_chain_elements" {+ type = "Array(Enum8('a'=1, 'button'=2, 'form'=3, 'input'=4, 'select'=5, 'textarea'=6, 'label'=7))"+ }+ engine "distributed" {+ cluster_name = "posthog"+ remote_database = "posthog"+ remote_table = "sharded_events_json"+ sharding_key = "sipHash64(distinct_id)"+ }+ }++ table "events_recent" {+ column "uuid" {+ type = "UUID"+ }+ column "event" {+ type = "String"+ }+ column "properties" {+ type = "String"+ codec = "ZSTD(3)"+ }+ column "timestamp" {+ type = "DateTime64(6, 'UTC')"+ }+ column "team_id" {+ type = "Int64"+ }+ column "distinct_id" {+ type = "String"+ }+ column "elements_chain" {+ type = "String"+ }+ column "created_at" {+ type = "DateTime64(6, 'UTC')"+ }+ column "person_id" {+ type = "UUID"+ }+ column "person_created_at" {+ type = "DateTime64(3)"+ }+ column "person_properties" {+ type = "String"+ codec = "ZSTD(3)"+ }+ column "group0_properties" {+ type = "String"+ codec = "ZSTD(3)"+ }+ column "group1_properties" {+ type = "String"+ codec = "ZSTD(3)"+ }+ column "group2_properties" {+ type = "String"+ codec = "ZSTD(3)"+ }+ column "group3_properties" {+ type = "String"+ codec = "ZSTD(3)"+ }+ column "group4_properties" {+ type = "String"+ codec = "ZSTD(3)"+ }+ column "group0_created_at" {+ type = "DateTime64(3)"+ }+ column "group1_created_at" {+ type = "DateTime64(3)"+ }+ column "group2_created_at" {+ type = "DateTime64(3)"+ }+ column "group3_created_at" {+ type = "DateTime64(3)"+ }+ column "group4_created_at" {+ type = "DateTime64(3)"+ }+ column "person_mode" {+ type = "Enum8('full'=0, 'propertyless'=1, 'force_upgrade'=2)"+ }+ column "historical_migration" {+ type = "Bool"+ }+ column "_timestamp" {+ type = "DateTime"+ }+ column "_offset" {+ type = "UInt64"+ }+ column "inserted_at" {+ type = "DateTime64(6, 'UTC')"+ default = "now64()"+ }+ engine "distributed" {+ cluster_name = "posthog_primary_replica"+ remote_database = "posthog"+ remote_table = "sharded_events_recent"+ sharding_key = "sipHash64(distinct_id)"+ }+ }++ table "events_team_daily_stats" {+ order_by = ["analysis_date", "team_id", "event"]+ settings = {+ index_granularity = "8192"+ }+ column "analysis_date" {+ type = "Date"+ }+ column "team_id" {+ type = "Int64"+ }+ column "event" {+ type = "String"+ }+ column "event_count" {+ type = "UInt64"+ }+ column "total_event_bytes" {+ type = "UInt64"+ }+ column "min_event_bytes" {+ type = "UInt64"+ }+ column "max_event_bytes" {+ type = "UInt64"+ }+ column "avg_event_bytes" {+ type = "Float64"+ }+ column "p50_event_bytes" {+ type = "Float64"+ }+ column "p90_event_bytes" {+ type = "Float64"+ }+ column "p95_event_bytes" {+ type = "Float64"+ }+ column "p99_event_bytes" {+ type = "Float64"+ }+ column "event_size_histogram" {+ type = "Array(Tuple(Float64, Float64, UInt64))"+ }+ column "computed_at" {+ type = "DateTime"+ }+ engine "replicated_merge_tree" {+ zoo_path = "/clickhouse/ops/tables/{shard}/posthog.events_team_daily_stats"+ replica_name = "{replica}"+ }+ }++ table "exchange_rate" {+ order_by = ["date", "currency"]+ settings = {+ index_granularity = "8192"+ }+ column "currency" {+ type = "String"+ }+ column "date" {+ type = "Date"+ }+ column "rate" {+ type = "Decimal(18, 10)"+ }+ column "version" {+ type = "UInt32"+ default = "toUnixTimestamp(now())"+ }+ engine "replicated_replacing_merge_tree" {+ zoo_path = "/clickhouse/tables/noshard/posthog.exchange_rate"+ replica_name = "{replica}-{shard}"+ version_column = "version"+ }+ }++ table "experiment_exposures_preaggregated" {+ column "team_id" {+ type = "Int64"+ }+ column "job_id" {+ type = "UUID"+ }+ column "entity_id" {+ type = "String"+ }+ column "variant" {+ type = "String"+ }+ column "first_exposure_time" {+ type = "DateTime64(6, 'UTC')"+ }+ column "last_exposure_time" {+ type = "DateTime64(6, 'UTC')"+ }+ column "exposure_event_uuid" {+ type = "UUID"+ }+ column "exposure_session_id" {+ type = "String"+ }+ column "breakdown_value" {+ type = "Array(String)"+ }+ column "computed_at" {+ type = "DateTime64(6, 'UTC')"+ default = "now()"+ }+ column "expires_at" {+ type = "Date"+ default = "today() + toIntervalDay(7)"+ }+ engine "distributed" {+ cluster_name = "posthog"+ remote_database = "posthog"+ remote_table = "sharded_experiment_exposures_preaggregated"+ sharding_key = "cityHash64(entity_id)"+ }+ }++ table "experiment_metric_events_preaggregated" {+ column "team_id" {+ type = "Int64"+ }+ column "job_id" {+ type = "UUID"+ }+ column "entity_id" {+ type = "String"+ }+ column "timestamp" {+ type = "DateTime64(6, 'UTC')"+ }+ column "event_uuid" {+ type = "UUID"+ }+ column "session_id" {+ type = "String"+ }+ column "numeric_value" {+ type = "Float64"+ default = "0"+ }+ column "steps" {+ type = "Array(UInt8)"+ default = "[]"+ }+ column "computed_at" {+ type = "DateTime64(6, 'UTC')"+ default = "now()"+ }+ column "expires_at" {+ type = "Date"+ default = "today() + toIntervalDay(7)"+ }+ engine "distributed" {+ cluster_name = "aux"+ remote_database = "posthog"+ remote_table = "sharded_experiment_metric_events_preaggregated"+ sharding_key = "cityHash64(entity_id)"+ }+ }++ table "flag_evaluations" {+ column "uuid" {+ type = "UUID"+ }+ column "event" {+ type = "LowCardinality(String)"+ }+ column "properties" {+ type = "String"+ }+ column "timestamp" {+ type = "DateTime64(6, 'UTC')"+ }+ column "team_id" {+ type = "Int64"+ }+ column "distinct_id" {+ type = "String"+ }+ column "created_at" {+ type = "DateTime64(6, 'UTC')"+ }+ column "person_id" {+ type = "UUID"+ }+ column "person_properties" {+ type = "String"+ }+ column "group0_properties" {+ type = "String"+ }+ column "group1_properties" {+ type = "String"+ }+ column "group2_properties" {+ type = "String"+ }+ column "group3_properties" {+ type = "String"+ }+ column "group4_properties" {+ type = "String"+ }+ column "inserted_at" {+ type = "DateTime64(6, 'UTC')"+ default = "timestamp"+ }+ column "$group_0" {+ type = "String"+ comment = "column_materializer::$group_0"+ }+ column "$group_1" {+ type = "String"+ comment = "column_materializer::$group_1"+ }+ column "$group_2" {+ type = "String"+ comment = "column_materializer::$group_2"+ }+ column "$group_3" {+ type = "String"+ comment = "column_materializer::$group_3"+ }+ column "$group_4" {+ type = "String"+ comment = "column_materializer::$group_4"+ }+ column "flag_key" {+ type = "String"+ comment = "column_materializer::properties::$feature_flag"+ }+ column "response" {+ type = "LowCardinality(String)"+ comment = "column_materializer::properties::$feature_flag_response"+ }+ column "session_id" {+ type = "String"+ comment = "column_materializer::properties::$session_id"+ }+ column "request_id" {+ type = "String"+ comment = "column_materializer::properties::$feature_flag_request_id"+ }+ column "_timestamp" {+ type = "DateTime"+ }+ column "_offset" {+ type = "UInt64"+ }+ column "_partition" {+ type = "UInt64"+ }+ engine "distributed" {+ cluster_name = "posthog"+ remote_database = "posthog"+ remote_table = "sharded_flag_evaluations"+ sharding_key = "sipHash64(distinct_id)"+ }+ }++ table "groups" {+ order_by = ["team_id", "group_type_index", "group_key"]+ settings = {+ index_granularity = "8192"+ }+ column "group_type_index" {+ type = "UInt8"+ }+ column "group_key" {+ type = "String"+ }+ column "created_at" {+ type = "DateTime64(3)"+ }+ column "team_id" {+ type = "Int64"+ }+ column "group_properties" {+ type = "String"+ }+ column "_timestamp" {+ type = "DateTime"+ }+ column "_offset" {+ type = "UInt64"+ }+ column "is_deleted" {+ type = "Bool"+ }+ index "is_deleted_idx" {+ expr = "is_deleted"+ type = "minmax"+ granularity = 1+ }+ engine "replicated_replacing_merge_tree" {+ zoo_path = "/clickhouse/tables/noshard/posthog.groups"+ replica_name = "{replica}-{shard}"+ version_column = "_timestamp"+ }+ }++ table "heatmaps" {+ column "session_id" {+ type = "String"+ }+ column "team_id" {+ type = "Int64"+ }+ column "distinct_id" {+ type = "String"+ }+ column "timestamp" {+ type = "DateTime64(6, 'UTC')"+ }+ column "x" {+ type = "Int16"+ }+ column "y" {+ type = "Int16"+ }+ column "scale_factor" {+ type = "Int16"+ }+ column "viewport_width" {+ type = "Int16"+ }+ column "viewport_height" {+ type = "Int16"+ }+ column "pointer_target_fixed" {+ type = "Bool"+ }+ column "current_url" {+ type = "String"+ }+ column "type" {+ type = "LowCardinality(String)"+ }+ column "_timestamp" {+ type = "DateTime"+ }+ column "_offset" {+ type = "UInt64"+ }+ column "_partition" {+ type = "UInt64"+ }+ engine "distributed" {+ cluster_name = "posthog"+ remote_database = "posthog"+ remote_table = "sharded_heatmaps"+ sharding_key = "cityHash64(concat(toString(team_id), '-', session_id, '-', toString(toDate(timestamp))))"+ }+ }++ table "hog_invocation_results" {+ column "team_id" {+ type = "Int64"+ }+ column "function_kind" {+ type = "LowCardinality(String)"+ }+ column "function_id" {+ type = "String"+ }+ column "invocation_id" {+ type = "String"+ }+ column "parent_run_id" {+ type = "String"+ }+ column "status" {+ type = "LowCardinality(String)"+ }+ column "attempts" {+ type = "UInt8"+ }+ column "is_retry" {+ type = "UInt8"+ }+ column "scheduled_at" {+ type = "DateTime64(6, 'UTC')"+ }+ column "first_scheduled_at" {+ type = "DateTime64(6, 'UTC')"+ }+ column "started_at" {+ type = "Nullable(DateTime64(6, 'UTC'))"+ }+ column "finished_at" {+ type = "Nullable(DateTime64(6, 'UTC'))"+ }+ column "duration_ms" {+ type = "Nullable(UInt32)"+ }+ column "error_kind" {+ type = "LowCardinality(String)"+ }+ column "error_message" {+ type = "String"+ }+ column "event_uuid" {+ type = "String"+ }+ column "distinct_id" {+ type = "String"+ }+ column "person_id" {+ type = "String"+ }+ column "invocation_globals" {+ type = "String"+ }+ column "version" {+ type = "UInt64"+ }+ column "is_deleted" {+ type = "UInt8"+ }+ column "_timestamp" {+ type = "DateTime"+ }+ column "_offset" {+ type = "UInt64"+ }+ column "_partition" {+ type = "UInt64"+ }+ engine "distributed" {+ cluster_name = "aux"+ remote_database = "posthog"+ remote_table = "hog_invocation_results_data"+ }+ }++ table "hog_invocation_results_data" {+ order_by = ["team_id", "function_kind", "function_id", "invocation_id"]+ partition_by = "toYYYYMMDD(scheduled_at)"+ ttl = "toDate(scheduled_at) + toIntervalDay(30)"+ settings = {+ index_granularity = "1024"+ ttl_only_drop_parts = "1"+ }+ column "team_id" {+ type = "Int64"+ }+ column "function_kind" {+ type = "LowCardinality(String)"+ }+ column "function_id" {+ type = "String"+ }+ column "invocation_id" {+ type = "String"+ }+ column "parent_run_id" {+ type = "String"+ }+ column "status" {+ type = "LowCardinality(String)"+ }+ column "attempts" {+ type = "UInt8"+ }+ column "is_retry" {+ type = "UInt8"+ }+ column "scheduled_at" {+ type = "DateTime64(6, 'UTC')"+ }+ column "first_scheduled_at" {+ type = "DateTime64(6, 'UTC')"+ default = "scheduled_at"+ }+ column "started_at" {+ type = "Nullable(DateTime64(6, 'UTC'))"+ }+ column "finished_at" {+ type = "Nullable(DateTime64(6, 'UTC'))"+ }+ column "duration_ms" {+ type = "Nullable(UInt32)"+ }+ column "error_kind" {+ type = "LowCardinality(String)"+ }+ column "error_message" {+ type = "String"+ }+ column "event_uuid" {+ type = "String"+ }+ column "distinct_id" {+ type = "String"+ }+ column "person_id" {+ type = "String"+ }+ column "invocation_globals" {+ type = "String"+ }+ column "version" {+ type = "UInt64"+ }+ column "is_deleted" {+ type = "UInt8"+ default = "0"+ }+ column "_timestamp" {+ type = "DateTime"+ }+ column "_offset" {+ type = "UInt64"+ }+ column "_partition" {+ type = "UInt64"+ }+ index "status_idx" {+ expr = "status"+ type = "set(8)"+ granularity = 1+ }+ index "function_idx" {+ expr = "function_id"+ type = "bloom_filter(0.01)"+ granularity = 1+ }+ index "event_uuid_idx" {+ expr = "event_uuid"+ type = "bloom_filter(0.01)"+ granularity = 1+ }+ index "is_retry_idx" {+ expr = "is_retry"+ type = "set(2)"+ granularity = 1+ }+ engine "replicated_replacing_merge_tree" {+ zoo_path = "/clickhouse/tables/noshard/posthog.hog_invocation_results_data"+ replica_name = "{replica}-{shard}"+ version_column = "version"+ }+ }++ table "ingestion_warnings" {+ column "team_id" {+ type = "Int64"+ }+ column "source" {+ type = "LowCardinality(String)"+ }+ column "type" {+ type = "String"+ }+ column "details" {+ type = "String"+ codec = "ZSTD(3)"+ }+ column "timestamp" {+ type = "DateTime64(6, 'UTC')"+ }+ column "_timestamp" {+ type = "DateTime"+ }+ column "_offset" {+ type = "UInt64"+ }+ column "_partition" {+ type = "UInt64"+ }+ engine "distributed" {+ cluster_name = "posthog"+ remote_database = "posthog"+ remote_table = "sharded_ingestion_warnings"+ sharding_key = "rand()"+ }+ }++ table "ingestion_warnings_v2" {+ order_by = ["team_id", "type", "timestamp"]+ partition_by = "toYYYYMM(timestamp)"+ ttl = "toDateTime(timestamp) + toIntervalDay(90)"+ settings = {+ index_granularity = "8192"+ }+ column "team_id" {+ type = "Int64"+ }+ column "source" {+ type = "LowCardinality(String)"+ }+ column "type" {+ type = "LowCardinality(String)"+ }+ column "details" {+ type = "String"+ }+ column "timestamp" {+ type = "DateTime64(6, 'UTC')"+ }+ column "category" {+ type = "LowCardinality(String)"+ default = "coalesce(nullIf(JSONExtractString(details, 'category'), ''), 'unknown')"+ }+ column "severity" {+ type = "LowCardinality(String)"+ default = "coalesce(nullIf(JSONExtractString(details, 'severity'), ''), 'warning')"+ }+ column "pipeline_step" {+ type = "LowCardinality(String)"+ default = "coalesce(nullIf(JSONExtractString(details, 'pipelineStep'), ''), 'unknown')"+ }+ column "event_uuid" {+ type = "Nullable(UUID)"+ default = "toUUIDOrNull(JSONExtractString(details, 'eventUuid'))"+ }+ column "distinct_id" {+ type = "Nullable(String)"+ default = "nullIf(JSONExtractString(details, 'distinctId'), '')"+ }+ column "group_key" {+ type = "Nullable(String)"+ default = "nullIf(JSONExtractString(details, 'groupKey'), '')"+ }+ column "person_id" {+ type = "Nullable(UUID)"+ default = "toUUIDOrNull(JSONExtractString(details, 'personId'))"+ }+ column "_timestamp" {+ type = "DateTime"+ }+ column "_offset" {+ type = "UInt64"+ }+ column "_partition" {+ type = "UInt64"+ }+ engine "replicated_merge_tree" {+ zoo_path = "/clickhouse/tables/noshard/posthog.ingestion_warnings_v2"+ replica_name = "{replica}-{shard}"+ }+ }++ table "ingestion_warnings_v2_distributed" {+ column "team_id" {+ type = "Int64"+ }+ column "source" {+ type = "LowCardinality(String)"+ }+ column "type" {+ type = "LowCardinality(String)"+ }+ column "details" {+ type = "String"+ }+ column "timestamp" {+ type = "DateTime64(6, 'UTC')"+ }+ column "category" {+ type = "LowCardinality(String)"+ default = "coalesce(nullIf(JSONExtractString(details, 'category'), ''), 'unknown')"+ }+ column "severity" {+ type = "LowCardinality(String)"+ default = "coalesce(nullIf(JSONExtractString(details, 'severity'), ''), 'warning')"+ }+ column "pipeline_step" {+ type = "LowCardinality(String)"+ default = "coalesce(nullIf(JSONExtractString(details, 'pipelineStep'), ''), 'unknown')"+ }+ column "event_uuid" {+ type = "Nullable(UUID)"+ default = "toUUIDOrNull(JSONExtractString(details, 'eventUuid'))"+ }+ column "distinct_id" {+ type = "Nullable(String)"+ default = "nullIf(JSONExtractString(details, 'distinctId'), '')"+ }+ column "group_key" {+ type = "Nullable(String)"+ default = "nullIf(JSONExtractString(details, 'groupKey'), '')"+ }+ column "person_id" {+ type = "Nullable(UUID)"+ default = "toUUIDOrNull(JSONExtractString(details, 'personId'))"+ }+ column "_timestamp" {+ type = "DateTime"+ }+ column "_offset" {+ type = "UInt64"+ }+ column "_partition" {+ type = "UInt64"+ }+ engine "distributed" {+ cluster_name = "aux"+ remote_database = "posthog"+ remote_table = "ingestion_warnings_v2"+ }+ }++ table "kafka_ai_events_json" {+ column "uuid" {+ type = "UUID"+ }+ column "event" {+ type = "String"+ }+ column "properties" {+ type = "String"+ }+ column "timestamp" {+ type = "DateTime64(6, 'UTC')"+ }+ column "team_id" {+ type = "Int64"+ }+ column "distinct_id" {+ type = "String"+ }+ column "elements_chain" {+ type = "String"+ }+ column "created_at" {+ type = "DateTime64(6, 'UTC')"+ }+ column "person_id" {+ type = "UUID"+ }+ column "person_properties" {+ type = "String"+ }+ column "person_created_at" {+ type = "DateTime64(3)"+ }+ column "person_mode" {+ type = "Enum8('full'=0, 'propertyless'=1, 'force_upgrade'=2)"+ }+ engine "kafka" {+ broker_list = "msk_cluster"+ topic_list = "kafka_topic_list = 'clickhouse_ai_events_json'"+ group_name = "kafka_group_name = 'group1'"+ format = "kafka_format = 'JSONEachRow'"+ }+ }++ table "kafka_app_metrics" {+ column "team_id" {+ type = "Int64"+ }+ column "timestamp" {+ type = "DateTime64(6, 'UTC')"+ }+ column "plugin_config_id" {+ type = "Int64"+ }+ column "category" {+ type = "LowCardinality(String)"+ }+ column "job_id" {+ type = "String"+ }+ column "successes" {+ type = "Int64"+ }+ column "successes_on_retry" {+ type = "Int64"+ }+ column "failures" {+ type = "Int64"+ }+ column "error_uuid" {+ type = "UUID"+ }+ column "error_type" {+ type = "String"+ }+ column "error_details" {+ type = "String"+ codec = "ZSTD(3)"+ }+ engine "kafka" {+ broker_list = "msk_cluster"+ topic_list = "kafka_topic_list = 'clickhouse_app_metrics'"+ group_name = "kafka_group_name = 'group1'"+ format = "kafka_format = 'JSONEachRow'"+ }+ }++ table "kafka_app_metrics2" {+ column "team_id" {+ type = "Int64"+ }+ column "timestamp" {+ type = "DateTime64(6, 'UTC')"+ }+ column "app_source" {+ type = "LowCardinality(String)"+ }+ column "app_source_id" {+ type = "String"+ }+ column "instance_id" {+ type = "String"+ }+ column "metric_kind" {+ type = "String"+ }+ column "metric_name" {+ type = "String"+ }+ column "count" {+ type = "Int64"+ }+ engine "kafka" {+ broker_list = "msk_cluster"+ topic_list = "kafka_topic_list = 'clickhouse_app_metrics2'"+ group_name = "kafka_group_name = 'group1'"+ format = "kafka_format = 'JSONEachRow'"+ }+ }++ table "kafka_app_metrics2_ws" {+ column "team_id" {+ type = "Int64"+ }+ column "timestamp" {+ type = "DateTime64(6, 'UTC')"+ }+ column "app_source" {+ type = "LowCardinality(String)"+ }+ column "app_source_id" {+ type = "String"+ }+ column "instance_id" {+ type = "String"+ }+ column "metric_kind" {+ type = "String"+ }+ column "metric_name" {+ type = "String"+ }+ column "count" {+ type = "Int64"+ }+ engine "kafka" {+ broker_list = "warpstream_ingestion"+ topic_list = "kafka_topic_list = 'clickhouse_app_metrics2'"+ group_name = "kafka_group_name = 'clickhouse_app_metrics2_ws'"+ format = "kafka_format = 'JSONEachRow'"+ }+ }++ table "kafka_cohort_membership" {+ column "team_id" {+ type = "Int64"+ }+ column "cohort_id" {+ type = "Int64"+ }+ column "person_id" {+ type = "UUID"+ }+ column "status" {+ type = "Enum8('entered'=1, 'left'=2, 'member'=3, 'not_member'=4)"+ }+ column "last_updated" {+ type = "DateTime64(6)"+ }+ engine "kafka" {+ broker_list = "msk_cluster"+ topic_list = "kafka_topic_list = 'cohort_membership_changed'"+ group_name = "kafka_group_name = 'clickhouse_cohort_membership_changed'"+ format = "kafka_format = 'JSONEachRow'"+ }+ }++ table "kafka_distinct_id_usage" {+ column "team_id" {+ type = "Int64"+ }+ column "distinct_id" {+ type = "String"+ }+ column "timestamp" {+ type = "DateTime64(6, 'UTC')"+ }+ engine "kafka" {+ broker_list = "warpstream_ingestion"+ topic_list = "kafka_topic_list = 'distinct_id_usage_events_json'"+ group_name = "kafka_group_name = 'clickhouse_distinct_id_usage'"+ format = "kafka_format = 'JSONEachRow'"+ skip_broken_messages = 100+ }+ }++ table "kafka_duplicate_events" {+ column "team_id" {+ type = "Int64"+ }+ column "distinct_id" {+ type = "String"+ }+ column "event" {+ type = "String"+ }+ column "source_uuid" {+ type = "UUID"+ }+ column "duplicate_uuid" {+ type = "UUID"+ }+ column "similarity_score" {+ type = "Float64"+ }+ column "dedup_type" {+ type = "LowCardinality(String)"+ }+ column "is_confirmed" {+ type = "UInt8"+ }+ column "reason" {+ type = "Nullable(String)"+ }+ column "version" {+ type = "String"+ }+ column "different_property_count" {+ type = "UInt32"+ }+ column "properties_similarity" {+ type = "Float64"+ }+ column "source_message" {+ type = "String"+ }+ column "duplicate_message" {+ type = "String"+ }+ column "distinct_fields" {+ type = "String"+ }+ column "inserted_at" {+ type = "DateTime64(3, 'UTC')"+ }+ engine "kafka" {+ broker_list = "msk_cluster"+ topic_list = "kafka_topic_list = 'clickhouse_ingestion_events_duplicates'"+ group_name = "kafka_group_name = 'clickhouse_duplicate_events'"+ format = "kafka_format = 'JSONEachRow'"+ }+ }++ table "kafka_error_tracking_fingerprint_issue_state" {+ column "team_id" {+ type = "Int64"+ }+ column "fingerprint" {+ type = "String"+ }+ column "issue_id" {+ type = "UUID"+ }+ column "issue_name" {+ type = "Nullable(String)"+ }+ column "issue_description" {+ type = "Nullable(String)"+ }+ column "issue_status" {+ type = "String"+ }+ column "issue_severity" {+ type = "Nullable(String)"+ }+ column "assigned_user_id" {+ type = "Nullable(Int64)"+ }+ column "assigned_role_id" {+ type = "Nullable(UUID)"+ }+ column "first_seen" {+ type = "DateTime64(3, 'UTC')"+ }+ column "is_deleted" {+ type = "Int8"+ }+ column "version" {+ type = "Int64"+ }+ engine "kafka" {+ broker_list = "msk_cluster"+ topic_list = "kafka_topic_list = 'clickhouse_error_tracking_fingerprint_issue_state'"+ group_name = "kafka_group_name = 'clickhouse-error-tracking-fingerprint-issue-state'"+ format = "kafka_format = 'JSONEachRow'"+ }+ }++ table "kafka_error_tracking_issue_fingerprint_embeddings" {+ column "team_id" {+ type = "Int64"+ }+ column "model_name" {+ type = "LowCardinality(String)"+ }+ column "embedding_version" {+ type = "Int64"+ }+ column "fingerprint" {+ type = "String"+ }+ column "inserted_at" {+ type = "DateTime64(3, 'UTC')"+ }+ column "embeddings" {+ type = "Array(Float64)"+ }+ engine "kafka" {+ broker_list = "msk_cluster"+ topic_list = "kafka_topic_list = 'clickhouse_error_tracking_issue_fingerprint_embeddings'"+ group_name = "kafka_group_name = 'clickhouse_error_tracking_fingerprint_embeddings'"+ format = "kafka_format = 'JSONEachRow'"+ }+ }++ table "kafka_error_tracking_issue_fingerprint_overrides" {+ column "team_id" {+ type = "Int64"+ }+ column "fingerprint" {+ type = "String"+ }+ column "issue_id" {+ type = "UUID"+ }+ column "is_deleted" {+ type = "Int8"+ }+ column "version" {+ type = "Int64"+ }+ engine "kafka" {+ broker_list = "msk_cluster"+ topic_list = "kafka_topic_list = 'clickhouse_error_tracking_issue_fingerprint'"+ group_name = "kafka_group_name = 'clickhouse-error-tracking-issue-fingerprint-overrides'"+ format = "kafka_format = 'JSONEachRow'"+ }+ }++ table "kafka_events_dead_letter_queue" {+ column "id" {+ type = "UUID"+ }+ column "event_uuid" {+ type = "UUID"+ }+ column "event" {+ type = "String"+ }+ column "properties" {+ type = "String"+ }+ column "distinct_id" {+ type = "String"+ }+ column "team_id" {+ type = "Int64"+ }+ column "elements_chain" {+ type = "String"+ }+ column "created_at" {+ type = "DateTime64(6, 'UTC')"+ }+ column "ip" {+ type = "String"+ }+ column "site_url" {+ type = "String"+ }+ column "now" {+ type = "DateTime64(6, 'UTC')"+ }+ column "raw_payload" {+ type = "String"+ }+ column "error_timestamp" {+ type = "DateTime64(6, 'UTC')"+ }+ column "error_location" {+ type = "String"+ }+ column "error" {+ type = "String"+ }+ column "tags" {+ type = "Array(String)"+ }+ engine "kafka" {+ broker_list = "msk_cluster"+ topic_list = "kafka_topic_list = 'events_dead_letter_queue'"+ group_name = "kafka_group_name = 'group1'"+ format = "kafka_format = 'JSONEachRow'"+ skip_broken_messages = 1000+ }+ }++ table "kafka_events_json" {+ column "uuid" {+ type = "UUID"+ }+ column "event" {+ type = "String"+ }+ column "properties" {+ type = "String"+ codec = "ZSTD(3)"+ }+ column "timestamp" {+ type = "DateTime64(6, 'UTC')"+ }+ column "team_id" {+ type = "Int64"+ }+ column "distinct_id" {+ type = "String"+ }+ column "elements_chain" {+ type = "String"+ }+ column "created_at" {+ type = "DateTime64(6, 'UTC')"+ }+ column "person_id" {+ type = "UUID"+ }+ column "person_created_at" {+ type = "DateTime64(3)"+ }+ column "person_properties" {+ type = "String"+ codec = "ZSTD(3)"+ }+ column "group0_properties" {+ type = "String"+ codec = "ZSTD(3)"+ }+ column "group1_properties" {+ type = "String"+ codec = "ZSTD(3)"+ }+ column "group2_properties" {+ type = "String"+ codec = "ZSTD(3)"+ }+ column "group3_properties" {+ type = "String"+ codec = "ZSTD(3)"+ }+ column "group4_properties" {+ type = "String"+ codec = "ZSTD(3)"+ }+ column "group0_created_at" {+ type = "DateTime64(3)"+ }+ column "group1_created_at" {+ type = "DateTime64(3)"+ }+ column "group2_created_at" {+ type = "DateTime64(3)"+ }+ column "group3_created_at" {+ type = "DateTime64(3)"+ }+ column "group4_created_at" {+ type = "DateTime64(3)"+ }+ column "person_mode" {+ type = "Enum8('full'=0, 'propertyless'=1, 'force_upgrade'=2)"+ }+ column "historical_migration" {+ type = "Bool"+ }+ column "dmat_string_0" {+ type = "Nullable(String)"+ }+ column "dmat_string_1" {+ type = "Nullable(String)"+ }+ column "dmat_string_2" {+ type = "Nullable(String)"+ }+ column "dmat_string_3" {+ type = "Nullable(String)"+ }+ column "dmat_string_4" {+ type = "Nullable(String)"+ }+ column "dmat_string_5" {+ type = "Nullable(String)"+ }+ column "dmat_string_6" {+ type = "Nullable(String)"+ }+ column "dmat_string_7" {+ type = "Nullable(String)"+ }+ column "dmat_string_8" {+ type = "Nullable(String)"+ }+ column "dmat_string_9" {+ type = "Nullable(String)"+ }+ engine "kafka" {+ broker_list = "msk_cluster"+ topic_list = "kafka_topic_list = 'clickhouse_events_json'"+ group_name = "kafka_group_name = 'group1'"+ format = "kafka_format = 'JSONEachRow'"+ skip_broken_messages = 100+ }+ }++ table "kafka_events_json_native_json" {+ column "uuid" {+ type = "UUID"+ }+ column "event" {+ type = "String"+ }+ column "properties" {+ type = "String"+ codec = "ZSTD(3)"+ }+ column "timestamp" {+ type = "DateTime64(6, 'UTC')"+ }+ column "team_id" {+ type = "Int64"+ }+ column "distinct_id" {+ type = "String"+ }+ column "elements_chain" {+ type = "String"+ }+ column "created_at" {+ type = "DateTime64(6, 'UTC')"+ }+ column "person_id" {+ type = "UUID"+ }+ column "person_created_at" {+ type = "DateTime64(3)"+ }+ column "person_properties" {+ type = "String"+ codec = "ZSTD(3)"+ }+ column "group0_properties" {+ type = "String"+ codec = "ZSTD(3)"+ }+ column "group1_properties" {+ type = "String"+ codec = "ZSTD(3)"+ }+ column "group2_properties" {+ type = "String"+ codec = "ZSTD(3)"+ }+ column "group3_properties" {+ type = "String"+ codec = "ZSTD(3)"+ }+ column "group4_properties" {+ type = "String"+ codec = "ZSTD(3)"+ }+ column "group0_created_at" {+ type = "DateTime64(3)"+ }+ column "group1_created_at" {+ type = "DateTime64(3)"+ }+ column "group2_created_at" {+ type = "DateTime64(3)"+ }+ column "group3_created_at" {+ type = "DateTime64(3)"+ }+ column "group4_created_at" {+ type = "DateTime64(3)"+ }+ column "person_mode" {+ type = "Enum8('full'=0, 'propertyless'=1, 'force_upgrade'=2)"+ }+ column "historical_migration" {+ type = "Bool"+ }+ column "dmat_string_0" {+ type = "Nullable(String)"+ }+ column "dmat_string_1" {+ type = "Nullable(String)"+ }+ column "dmat_string_2" {+ type = "Nullable(String)"+ }+ column "dmat_string_3" {+ type = "Nullable(String)"+ }+ column "dmat_string_4" {+ type = "Nullable(String)"+ }+ column "dmat_string_5" {+ type = "Nullable(String)"+ }+ column "dmat_string_6" {+ type = "Nullable(String)"+ }+ column "dmat_string_7" {+ type = "Nullable(String)"+ }+ column "dmat_string_8" {+ type = "Nullable(String)"+ }+ column "dmat_string_9" {+ type = "Nullable(String)"+ }+ engine "kafka" {+ broker_list = "msk_cluster"+ topic_list = "kafka_topic_list = 'clickhouse_events_json'"+ group_name = "kafka_group_name = 'clickhouse_events_json_native_json'"+ format = "kafka_format = 'JSONEachRow'"+ skip_broken_messages = 100+ }+ }++ table "kafka_flag_evaluations" {+ column "uuid" {+ type = "UUID"+ }+ column "event" {+ type = "LowCardinality(String)"+ }+ column "properties" {+ type = "String"+ }+ column "timestamp" {+ type = "DateTime64(6, 'UTC')"+ }+ column "team_id" {+ type = "Int64"+ }+ column "distinct_id" {+ type = "String"+ }+ column "created_at" {+ type = "DateTime64(6, 'UTC')"+ }+ column "person_id" {+ type = "UUID"+ }+ column "person_properties" {+ type = "String"+ }+ column "group0_properties" {+ type = "String"+ }+ column "group1_properties" {+ type = "String"+ }+ column "group2_properties" {+ type = "String"+ }+ column "group3_properties" {+ type = "String"+ }+ column "group4_properties" {+ type = "String"+ }+ column "inserted_at" {+ type = "DateTime64(6, 'UTC')"+ }+ engine "kafka" {+ broker_list = "warpstream_ingestion"+ topic_list = "kafka_topic_list = 'clickhouse_flag_evaluations'"+ group_name = "kafka_group_name = 'clickhouse_flag_evaluations'"+ format = "kafka_format = 'JSONEachRow'"+ skip_broken_messages = 100+ }+ }++ table "kafka_groups" {+ column "group_type_index" {+ type = "UInt8"+ }+ column "group_key" {+ type = "String"+ }+ column "created_at" {+ type = "DateTime64(3)"+ }+ column "team_id" {+ type = "Int64"+ }+ column "group_properties" {+ type = "String"+ }+ engine "kafka" {+ broker_list = "msk_cluster"+ topic_list = "kafka_topic_list = 'clickhouse_groups'"+ group_name = "kafka_group_name = 'group1'"+ format = "kafka_format = 'JSONEachRow'"+ }+ }++ table "kafka_heatmaps" {+ column "session_id" {+ type = "String"+ }+ column "team_id" {+ type = "Int64"+ }+ column "distinct_id" {+ type = "String"+ }+ column "timestamp" {+ type = "DateTime64(6, 'UTC')"+ }+ column "x" {+ type = "Int16"+ }+ column "y" {+ type = "Int16"+ }+ column "scale_factor" {+ type = "Int16"+ }+ column "viewport_width" {+ type = "Int16"+ }+ column "viewport_height" {+ type = "Int16"+ }+ column "pointer_target_fixed" {+ type = "Bool"+ }+ column "current_url" {+ type = "String"+ }+ column "type" {+ type = "LowCardinality(String)"+ }+ engine "kafka" {+ broker_list = "msk_cluster"+ topic_list = "kafka_topic_list = 'clickhouse_heatmap_events'"+ group_name = "kafka_group_name = 'group1'"+ format = "kafka_format = 'JSONEachRow'"+ }+ }++ table "kafka_hog_invocation_results" {+ column "team_id" {+ type = "Int64"+ }+ column "function_kind" {+ type = "LowCardinality(String)"+ }+ column "function_id" {+ type = "String"+ }+ column "invocation_id" {+ type = "String"+ }+ column "parent_run_id" {+ type = "String"+ }+ column "status" {+ type = "LowCardinality(String)"+ }+ column "attempts" {+ type = "UInt8"+ }+ column "is_retry" {+ type = "UInt8"+ }+ column "scheduled_at" {+ type = "DateTime64(6, 'UTC')"+ }+ column "first_scheduled_at" {+ type = "DateTime64(6, 'UTC')"+ }+ column "started_at" {+ type = "Nullable(DateTime64(6, 'UTC'))"+ }+ column "finished_at" {+ type = "Nullable(DateTime64(6, 'UTC'))"+ }+ column "duration_ms" {+ type = "Nullable(UInt32)"+ }+ column "error_kind" {+ type = "LowCardinality(String)"+ }+ column "error_message" {+ type = "String"+ }+ column "event_uuid" {+ type = "String"+ }+ column "distinct_id" {+ type = "String"+ }+ column "person_id" {+ type = "String"+ }+ column "invocation_globals" {+ type = "String"+ }+ column "version" {+ type = "UInt64"+ }+ column "is_deleted" {+ type = "UInt8"+ }+ engine "kafka" {+ broker_list = "warpstream_cyclotron"+ topic_list = "kafka_topic_list = 'clickhouse_hog_invocation_results'"+ group_name = "kafka_group_name = 'clickhouse_hog_invocation_results'"+ format = "kafka_format = 'JSONEachRow'"+ skip_broken_messages = 100+ }+ }++ table "kafka_ingestion_warnings" {+ column "team_id" {+ type = "Int64"+ }+ column "source" {+ type = "LowCardinality(String)"+ }+ column "type" {+ type = "String"+ }+ column "details" {+ type = "String"+ codec = "ZSTD(3)"+ }+ column "timestamp" {+ type = "DateTime64(6, 'UTC')"+ }+ engine "kafka" {+ broker_list = "msk_cluster"+ topic_list = "kafka_topic_list = 'clickhouse_ingestion_warnings'"+ group_name = "kafka_group_name = 'group1'"+ format = "kafka_format = 'JSONEachRow'"+ }+ }++ table "kafka_ingestion_warnings_v2" {+ column "team_id" {+ type = "Int64"+ }+ column "source" {+ type = "LowCardinality(String)"+ }+ column "type" {+ type = "String"+ }+ column "details" {+ type = "String"+ }+ column "timestamp" {+ type = "DateTime64(6, 'UTC')"+ }+ engine "kafka" {+ broker_list = "warpstream_ingestion"+ topic_list = "kafka_topic_list = 'clickhouse_ingestion_warnings'"+ group_name = "kafka_group_name = 'clickhouse_ingestion_warnings_v2'"+ format = "kafka_format = 'JSONEachRow'"+ }+ }++ table "kafka_log_entries_v3" {+ column "team_id" {+ type = "UInt64"+ }+ column "log_source" {+ type = "LowCardinality(String)"+ }+ column "log_source_id" {+ type = "String"+ }+ column "instance_id" {+ type = "String"+ }+ column "timestamp" {+ type = "DateTime64(6, 'UTC')"+ }+ column "level" {+ type = "LowCardinality(String)"+ }+ column "message" {+ type = "String"+ }+ engine "kafka" {+ broker_list = "msk_cluster"+ topic_list = "kafka_topic_list = 'log_entries'"+ group_name = "kafka_group_name = 'clickhouse_log_entries'"+ format = "kafka_format = 'JSONEachRow'"+ skip_broken_messages = 100+ }+ }++ table "kafka_log_entries_ws" {+ column "team_id" {+ type = "UInt64"+ }+ column "log_source" {+ type = "LowCardinality(String)"+ }+ column "log_source_id" {+ type = "String"+ }+ column "instance_id" {+ type = "String"+ }+ column "timestamp" {+ type = "DateTime64(6, 'UTC')"+ }+ column "level" {+ type = "LowCardinality(String)"+ }+ column "message" {+ type = "String"+ }+ engine "kafka" {+ broker_list = "warpstream_ingestion"+ topic_list = "kafka_topic_list = 'log_entries'"+ group_name = "kafka_group_name = 'clickhouse_log_entries_ws'"+ format = "kafka_format = 'JSONEachRow'"+ skip_broken_messages = 100+ }+ }++ table "kafka_logs_avro" {+ column "uuid" {+ type = "String"+ }+ column "trace_id" {+ type = "String"+ }+ column "span_id" {+ type = "String"+ }+ column "trace_flags" {+ type = "Int32"+ }+ column "timestamp" {+ type = "DateTime64(6)"+ }+ column "observed_timestamp" {+ type = "DateTime64(6)"+ }+ column "body" {+ type = "String"+ }+ column "severity_text" {+ type = "String"+ }+ column "severity_number" {+ type = "Int32"+ }+ column "service_name" {+ type = "String"+ }+ column "resource_attributes" {+ type = "Map(LowCardinality(String), String)"+ }+ column "instrumentation_scope" {+ type = "String"+ }+ column "event_name" {+ type = "String"+ }+ column "attributes" {+ type = "Map(LowCardinality(String), String)"+ }+ engine "kafka" {+ broker_list = "warpstream_logs"+ topic_list = "kafka_topic_list = 'clickhouse_logs'"+ group_name = "kafka_group_name = 'clickhouse-logs-avro-new'"+ format = "kafka_format = 'Avro'"+ num_consumers = 8+ skip_broken_messages = 100+ poll_timeout_ms = 3000+ poll_max_batch_size = 1000+ thread_per_consumer = true+ }+ }++ table "kafka_message_assets" {+ column "team_id" {+ type = "Int64"+ }+ column "function_kind" {+ type = "LowCardinality(String)"+ }+ column "function_id" {+ type = "String"+ }+ column "parent_run_id" {+ type = "String"+ }+ column "invocation_id" {+ type = "String"+ }+ column "action_id" {+ type = "String"+ }+ column "kind" {+ type = "LowCardinality(String)"+ }+ column "distinct_id" {+ type = "String"+ }+ column "person_id" {+ type = "String"+ }+ column "recipient" {+ type = "String"+ }+ column "subject" {+ type = "String"+ }+ column "status" {+ type = "LowCardinality(String)"+ }+ column "sent_at" {+ type = "DateTime64(6, 'UTC')"+ }+ column "version" {+ type = "UInt64"+ }+ column "is_deleted" {+ type = "UInt8"+ }+ column "html" {+ type = "String"+ }+ engine "kafka" {+ broker_list = "warpstream_cyclotron"+ topic_list = "kafka_topic_list = 'clickhouse_message_assets'"+ group_name = "kafka_group_name = 'clickhouse_message_assets'"+ format = "kafka_format = 'JSONEachRow'"+ skip_broken_messages = 100+ }+ }++ table "kafka_performance_events" {+ column "uuid" {+ type = "UUID"+ }+ column "session_id" {+ type = "String"+ }+ column "window_id" {+ type = "String"+ }+ column "pageview_id" {+ type = "String"+ }+ column "distinct_id" {+ type = "String"+ }+ column "timestamp" {+ type = "DateTime64(3)"+ }+ column "time_origin" {+ type = "DateTime64(3, 'UTC')"+ }+ column "entry_type" {+ type = "LowCardinality(String)"+ }+ column "name" {+ type = "String"+ }+ column "team_id" {+ type = "Int64"+ }+ column "current_url" {+ type = "String"+ }+ column "start_time" {+ type = "Float64"+ }+ column "duration" {+ type = "Float64"+ }+ column "redirect_start" {+ type = "Float64"+ }+ column "redirect_end" {+ type = "Float64"+ }+ column "worker_start" {+ type = "Float64"+ }+ column "fetch_start" {+ type = "Float64"+ }+ column "domain_lookup_start" {+ type = "Float64"+ }+ column "domain_lookup_end" {+ type = "Float64"+ }+ column "connect_start" {+ type = "Float64"+ }+ column "secure_connection_start" {+ type = "Float64"+ }+ column "connect_end" {+ type = "Float64"+ }+ column "request_start" {+ type = "Float64"+ }+ column "response_start" {+ type = "Float64"+ }+ column "response_end" {+ type = "Float64"+ }+ column "decoded_body_size" {+ type = "Int64"+ }+ column "encoded_body_size" {+ type = "Int64"+ }+ column "initiator_type" {+ type = "LowCardinality(String)"+ }+ column "next_hop_protocol" {+ type = "LowCardinality(String)"+ }+ column "render_blocking_status" {+ type = "LowCardinality(String)"+ }+ column "response_status" {+ type = "Int64"+ }+ column "transfer_size" {+ type = "Int64"+ }+ column "largest_contentful_paint_element" {+ type = "String"+ }+ column "largest_contentful_paint_render_time" {+ type = "Float64"+ }+ column "largest_contentful_paint_load_time" {+ type = "Float64"+ }+ column "largest_contentful_paint_size" {+ type = "Float64"+ }+ column "largest_contentful_paint_id" {+ type = "String"+ }+ column "largest_contentful_paint_url" {+ type = "String"+ }+ column "dom_complete" {+ type = "Float64"+ }+ column "dom_content_loaded_event" {+ type = "Float64"+ }+ column "dom_interactive" {+ type = "Float64"+ }+ column "load_event_end" {+ type = "Float64"+ }+ column "load_event_start" {+ type = "Float64"+ }+ column "redirect_count" {+ type = "Int64"+ }+ column "navigation_type" {+ type = "LowCardinality(String)"+ }+ column "unload_event_end" {+ type = "Float64"+ }+ column "unload_event_start" {+ type = "Float64"+ }+ engine "kafka" {+ broker_list = "msk_cluster"+ topic_list = "kafka_topic_list = 'clickhouse_performance_events'"+ group_name = "kafka_group_name = 'group1'"+ format = "kafka_format = 'JSONEachRow'"+ }+ }++ table "kafka_person" {+ column "id" {+ type = "UUID"+ }+ column "created_at" {+ type = "DateTime64(3)"+ }+ column "team_id" {+ type = "Int64"+ }+ column "properties" {+ type = "String"+ }+ column "is_identified" {+ type = "Int8"+ }+ column "is_deleted" {+ type = "Int8"+ }+ column "version" {+ type = "UInt64"+ }+ column "last_seen_at" {+ type = "Nullable(DateTime64(3))"+ }+ engine "kafka" {+ broker_list = "msk_cluster"+ topic_list = "kafka_topic_list = 'clickhouse_person'"+ group_name = "kafka_group_name = 'group1'"+ format = "kafka_format = 'JSONEachRow'"+ }+ }++ table "kafka_person_distinct_id" {+ column "distinct_id" {+ type = "String"+ }+ column "person_id" {+ type = "UUID"+ }+ column "team_id" {+ type = "Int64"+ }+ column "_sign" {+ type = "Nullable(Int8)"+ }+ column "is_deleted" {+ type = "Nullable(Int8)"+ }+ engine "kafka" {+ broker_list = "msk_cluster"+ topic_list = "kafka_topic_list = 'clickhouse_person_unique_id'"+ group_name = "kafka_group_name = 'group1'"+ format = "kafka_format = 'JSONEachRow'"+ }+ }++ table "kafka_person_distinct_id2" {+ column "team_id" {+ type = "Int64"+ }+ column "distinct_id" {+ type = "String"+ }+ column "person_id" {+ type = "UUID"+ }+ column "is_deleted" {+ type = "Int8"+ }+ column "version" {+ type = "Int64"+ }+ engine "kafka" {+ broker_list = "msk_cluster"+ topic_list = "kafka_topic_list = 'clickhouse_person_distinct_id'"+ group_name = "kafka_group_name = 'group1'"+ format = "kafka_format = 'JSONEachRow'"+ }+ }++ table "kafka_person_distinct_id_overrides" {+ column "team_id" {+ type = "Int64"+ }+ column "distinct_id" {+ type = "String"+ }+ column "person_id" {+ type = "UUID"+ }+ column "is_deleted" {+ type = "Int8"+ }+ column "version" {+ type = "Int64"+ }+ engine "kafka" {+ broker_list = "msk_cluster"+ topic_list = "kafka_topic_list = 'clickhouse_person_distinct_id'"+ group_name = "kafka_group_name = 'clickhouse-person-distinct-id-overrides'"+ format = "kafka_format = 'JSONEachRow'"+ }+ }++ table "kafka_person_overrides" {+ column "team_id" {+ type = "Int32"+ }+ column "old_person_id" {+ type = "UUID"+ }+ column "override_person_id" {+ type = "UUID"+ }+ column "merged_at" {+ type = "DateTime64(6, 'UTC')"+ }+ column "oldest_event" {+ type = "DateTime64(6, 'UTC')"+ }+ column "version" {+ type = "Int32"+ }+ engine "kafka" {+ broker_list = "kafka:9092"+ topic_list = "clickhouse_person_override"+ group_name = "clickhouse-person-overrides"+ format = "JSONEachRow"+ }+ }++ table "kafka_plugin_log_entries" {+ column "id" {+ type = "UUID"+ }+ column "team_id" {+ type = "Int64"+ }+ column "plugin_id" {+ type = "Int64"+ }+ column "plugin_config_id" {+ type = "Int64"+ }+ column "timestamp" {+ type = "DateTime64(6, 'UTC')"+ }+ column "source" {+ type = "String"+ }+ column "type" {+ type = "String"+ }+ column "message" {+ type = "String"+ }+ column "instance_id" {+ type = "UUID"+ }+ engine "kafka" {+ broker_list = "msk_cluster"+ topic_list = "kafka_topic_list = 'plugin_log_entries'"+ group_name = "kafka_group_name = 'group1'"+ format = "kafka_format = 'JSONEachRow'"+ }+ }++ table "kafka_posthog_document_embeddings" {+ column "team_id" {+ type = "Int64"+ }+ column "product" {+ type = "LowCardinality(String)"+ }+ column "document_type" {+ type = "LowCardinality(String)"+ }+ column "model_name" {+ type = "LowCardinality(String)"+ }+ column "rendering" {+ type = "LowCardinality(String)"+ }+ column "document_id" {+ type = "String"+ }+ column "timestamp" {+ type = "DateTime64(3, 'UTC')"+ }+ column "inserted_at" {+ type = "DateTime64(3, 'UTC')"+ }+ column "content" {+ type = "String"+ }+ column "metadata" {+ type = "String"+ }+ column "embedding" {+ type = "Array(Float64)"+ }+ engine "kafka" {+ broker_list = "msk_cluster"+ topic_list = "kafka_topic_list = 'clickhouse_document_embeddings'"+ group_name = "kafka_group_name = 'clickhouse_document_embeddings'"+ format = "kafka_format = 'JSONEachRow'"+ }+ }++ table "kafka_precalculated_events" {+ column "team_id" {+ type = "Int64"+ }+ column "date" {+ type = "Nullable(Date)"+ }+ column "distinct_id" {+ type = "String"+ }+ column "person_id" {+ type = "UUID"+ }+ column "condition" {+ type = "String"+ }+ column "uuid" {+ type = "UUID"+ }+ column "source" {+ type = "String"+ }+ engine "kafka" {+ broker_list = "msk_cluster"+ topic_list = "kafka_topic_list = 'clickhouse_prefiltered_events'"+ group_name = "kafka_group_name = 'clickhouse_prefiltered_events'"+ format = "kafka_format = 'JSONEachRow'"+ num_consumers = 1+ max_block_size = 1000000+ skip_broken_messages = 100+ poll_timeout_ms = 1000+ poll_max_batch_size = 100000+ flush_interval_ms = 7500+ }+ }++ table "kafka_precalculated_person_properties" {+ column "team_id" {+ type = "Int64"+ }+ column "distinct_id" {+ type = "String"+ }+ column "person_id" {+ type = "UUID"+ }+ column "condition" {+ type = "String"+ }+ column "matches" {+ type = "Bool"+ }+ column "source" {+ type = "String"+ }+ engine "kafka" {+ broker_list = "msk_cluster"+ topic_list = "kafka_topic_list = 'clickhouse_precalculated_person_properties'"+ group_name = "kafka_group_name = 'clickhouse_precalculated_person_properties'"+ format = "kafka_format = 'JSONEachRow'"+ num_consumers = 1+ max_block_size = 1000000+ skip_broken_messages = 100+ poll_timeout_ms = 1000+ poll_max_batch_size = 100000+ flush_interval_ms = 7500+ }+ }++ table "kafka_precalculated_person_properties_ws" {+ column "team_id" {+ type = "Int64"+ }+ column "distinct_id" {+ type = "String"+ }+ column "person_id" {+ type = "UUID"+ }+ column "condition" {+ type = "String"+ }+ column "matches" {+ type = "Bool"+ }+ column "source" {+ type = "String"+ }+ engine "kafka" {+ broker_list = "warpstream_calculated_events"+ topic_list = "kafka_topic_list = 'clickhouse_precalculated_person_properties'"+ group_name = "kafka_group_name = 'clickhouse_precalculated_person_properties_ws'"+ format = "kafka_format = 'JSONEachRow'"+ num_consumers = 1+ max_block_size = 1000000+ skip_broken_messages = 100+ poll_timeout_ms = 1000+ poll_max_batch_size = 100000+ flush_interval_ms = 7500+ }+ }++ table "kafka_property_values" {+ column "team_id" {+ type = "Int64"+ }+ column "property_type" {+ type = "LowCardinality(String)"+ }+ column "property_key" {+ type = "String"+ }+ column "property_value" {+ type = "String"+ }+ column "property_count" {+ type = "UInt64"+ }+ engine "kafka" {+ broker_list = "warpstream_ingestion"+ topic_list = "kafka_topic_list = 'clickhouse_property_values'"+ group_name = "kafka_group_name = 'clickhouse_property_values'"+ format = "kafka_format = 'JSONEachRow'"+ num_consumers = 8+ thread_per_consumer = true+ }+ }++ table "kafka_session_replay_events" {+ column "session_id" {+ type = "String"+ }+ column "team_id" {+ type = "Int64"+ }+ column "distinct_id" {+ type = "String"+ }+ column "first_timestamp" {+ type = "DateTime64(6, 'UTC')"+ }+ column "last_timestamp" {+ type = "DateTime64(6, 'UTC')"+ }+ column "block_url" {+ type = "Nullable(String)"+ }+ column "first_url" {+ type = "Nullable(String)"+ }+ column "urls" {+ type = "Array(String)"+ }+ column "click_count" {+ type = "Int64"+ }+ column "keypress_count" {+ type = "Int64"+ }+ column "mouse_activity_count" {+ type = "Int64"+ }+ column "active_milliseconds" {+ type = "Int64"+ }+ column "console_log_count" {+ type = "Int64"+ }+ column "console_warn_count" {+ type = "Int64"+ }+ column "console_error_count" {+ type = "Int64"+ }+ column "size" {+ type = "Int64"+ }+ column "event_count" {+ type = "Int64"+ }+ column "message_count" {+ type = "Int64"+ }+ column "snapshot_source" {+ type = "LowCardinality(Nullable(String))"+ }+ column "snapshot_library" {+ type = "Nullable(String)"+ }+ column "retention_period_days" {+ type = "Nullable(Int64)"+ }+ column "is_deleted" {+ type = "UInt8"+ }+ column "ai_tags_fixed" {+ type = "Array(String)"+ }+ column "ai_tags_freeform" {+ type = "Array(String)"+ }+ column "ai_highlighted" {+ type = "UInt8"+ }+ column "surfacing_score" {+ type = "Nullable(Float32)"+ }+ engine "kafka" {+ broker_list = "msk_cluster"+ topic_list = "kafka_topic_list = 'clickhouse_session_replay_events'"+ group_name = "kafka_group_name = 'group1'"+ format = "kafka_format = 'JSONEachRow'"+ }+ }++ table "kafka_session_replay_features" {+ column "session_id" {+ type = "String"+ }+ column "team_id" {+ type = "Int64"+ }+ column "distinct_id" {+ type = "String"+ }+ column "batch_id" {+ type = "String"+ }+ column "first_timestamp" {+ type = "DateTime64(6, 'UTC')"+ }+ column "last_timestamp" {+ type = "DateTime64(6, 'UTC')"+ }+ column "event_count" {+ type = "Int64"+ }+ column "mouse_position_count" {+ type = "Int64"+ }+ column "mouse_sum_x" {+ type = "Float64"+ }+ column "mouse_sum_x_squared" {+ type = "Float64"+ }+ column "mouse_sum_y" {+ type = "Float64"+ }+ column "mouse_sum_y_squared" {+ type = "Float64"+ }+ column "mouse_distance_traveled" {+ type = "Float64"+ }+ column "mouse_direction_change_count" {+ type = "Int64"+ }+ column "mouse_velocity_sum" {+ type = "Float64"+ }+ column "mouse_velocity_sum_of_squares" {+ type = "Float64"+ }+ column "mouse_velocity_count" {+ type = "Int64"+ }+ column "scroll_event_count" {+ type = "Int64"+ }+ column "total_scroll_magnitude" {+ type = "Float64"+ }+ column "scroll_direction_reversal_count" {+ type = "Int64"+ }+ column "rapid_scroll_reversal_count" {+ type = "Int64"+ }+ column "scroll_to_top_count" {+ type = "Int64"+ }+ column "click_count" {+ type = "Int64"+ }+ column "keypress_count" {+ type = "Int64"+ }+ column "mouse_activity_count" {+ type = "Int64"+ }+ column "rage_click_count" {+ type = "Int64"+ }+ column "dead_click_count" {+ type = "Int64"+ }+ column "backspace_count" {+ type = "Int64"+ }+ column "inter_action_gap_count" {+ type = "Int64"+ }+ column "inter_action_gap_sum_ms" {+ type = "Float64"+ }+ column "inter_action_gap_sum_of_squares_ms" {+ type = "Float64"+ }+ column "max_idle_gap_ms" {+ type = "Float64"+ }+ column "long_idle_gap_count" {+ type = "Int64"+ }+ column "quick_back_count" {+ type = "Int64"+ }+ column "page_visit_count" {+ type = "Int64"+ }+ column "visited_urls" {+ type = "Array(String)"+ }+ column "login_path_visit_count" {+ type = "Int64"+ }+ column "signup_path_visit_count" {+ type = "Int64"+ }+ column "checkout_path_visit_count" {+ type = "Int64"+ }+ column "cart_path_visit_count" {+ type = "Int64"+ }+ column "billing_path_visit_count" {+ type = "Int64"+ }+ column "settings_path_visit_count" {+ type = "Int64"+ }+ column "account_path_visit_count" {+ type = "Int64"+ }+ column "error_path_visit_count" {+ type = "Int64"+ }+ column "not_found_path_visit_count" {+ type = "Int64"+ }+ column "admin_path_visit_count" {+ type = "Int64"+ }+ column "dashboard_path_visit_count" {+ type = "Int64"+ }+ column "onboarding_path_visit_count" {+ type = "Int64"+ }+ column "cancel_path_visit_count" {+ type = "Int64"+ }+ column "refund_path_visit_count" {+ type = "Int64"+ }+ column "console_error_count" {+ type = "Int64"+ }+ column "console_error_after_click_count" {+ type = "Int64"+ }+ column "console_warn_count" {+ type = "Int64"+ }+ column "network_request_count" {+ type = "Int64"+ }+ column "network_failed_request_count" {+ type = "Int64"+ }+ column "network_4xx_count" {+ type = "Int64"+ }+ column "network_5xx_count" {+ type = "Int64"+ }+ column "network_request_duration_sum" {+ type = "Float64"+ }+ column "network_request_duration_sum_of_squares" {+ type = "Float64"+ }+ column "network_request_duration_count" {+ type = "Int64"+ }+ column "mutation_count" {+ type = "Int64"+ }+ column "viewport_resize_count" {+ type = "Int64"+ }+ column "touch_event_count" {+ type = "Int64"+ }+ column "max_scroll_y" {+ type = "Float64"+ }+ column "click_target_ids" {+ type = "Array(Int64)"+ }+ column "form_field_ids" {+ type = "Array(Int64)"+ }+ column "text_selection_count" {+ type = "Int64"+ }+ column "selection_copy_count" {+ type = "Int64"+ }+ column "is_deleted" {+ type = "UInt8"+ }+ engine "kafka" {+ broker_list = "msk_cluster"+ topic_list = "kafka_topic_list = 'clickhouse_session_replay_features'"+ group_name = "kafka_group_name = 'group1'"+ format = "kafka_format = 'JSONEachRow'"+ }+ }++ table "kafka_tophog" {+ settings = {+ date_time_input_format = "best_effort"+ }+ column "timestamp" {+ type = "DateTime64(6, 'UTC')"+ }+ column "metric" {+ type = "LowCardinality(String)"+ }+ column "type" {+ type = "LowCardinality(String)"+ }+ column "key" {+ type = "Map(LowCardinality(String), String)"+ }+ column "value" {+ type = "Float64"+ }+ column "count" {+ type = "UInt64"+ }+ column "pipeline" {+ type = "LowCardinality(String)"+ }+ column "lane" {+ type = "LowCardinality(String)"+ }+ column "labels" {+ type = "Map(LowCardinality(String), String)"+ }+ engine "kafka" {+ broker_list = "msk_cluster"+ topic_list = "kafka_topic_list = 'clickhouse_tophog'"+ group_name = "kafka_group_name = 'clickhouse_tophog'"+ format = "kafka_format = 'JSONEachRow'"+ skip_broken_messages = 100+ }+ }++ table "kafka_tophog_ws" {+ settings = {+ date_time_input_format = "best_effort"+ }+ column "timestamp" {+ type = "DateTime64(6, 'UTC')"+ }+ column "metric" {+ type = "LowCardinality(String)"+ }+ column "type" {+ type = "LowCardinality(String)"+ }+ column "key" {+ type = "Map(LowCardinality(String), String)"+ }+ column "value" {+ type = "Float64"+ }+ column "count" {+ type = "UInt64"+ }+ column "pipeline" {+ type = "LowCardinality(String)"+ }+ column "lane" {+ type = "LowCardinality(String)"+ }+ column "labels" {+ type = "Map(LowCardinality(String), String)"+ }+ engine "kafka" {+ broker_list = "warpstream_ingestion"+ topic_list = "kafka_topic_list = 'clickhouse_tophog'"+ group_name = "kafka_group_name = 'clickhouse_tophog_ws'"+ format = "kafka_format = 'JSONEachRow'"+ skip_broken_messages = 100+ }+ }++ table "kafka_trace_spans_avro" {+ column "uuid" {+ type = "String"+ }+ column "trace_id" {+ type = "String"+ }+ column "span_id" {+ type = "String"+ }+ column "parent_span_id" {+ type = "String"+ }+ column "trace_state" {+ type = "String"+ }+ column "name" {+ type = "String"+ }+ column "kind" {+ type = "Int32"+ }+ column "flags" {+ type = "Int32"+ }+ column "timestamp" {+ type = "DateTime64(6)"+ }+ column "end_time" {+ type = "DateTime64(6)"+ }+ column "observed_timestamp" {+ type = "DateTime64(6)"+ }+ column "service_name" {+ type = "String"+ }+ column "resource_attributes" {+ type = "Map(LowCardinality(String), String)"+ }+ column "instrumentation_scope" {+ type = "String"+ }+ column "attributes" {+ type = "Map(LowCardinality(String), String)"+ }+ column "dropped_attributes_count" {+ type = "Int32"+ }+ column "events" {+ type = "Array(String)"+ }+ column "dropped_events_count" {+ type = "Int32"+ }+ column "links" {+ type = "Array(String)"+ }+ column "dropped_links_count" {+ type = "Int32"+ }+ column "status_code" {+ type = "Int32"+ }+ engine "kafka" {+ broker_list = "warpstream_traces"+ topic_list = "kafka_topic_list = 'clickhouse_traces'"+ group_name = "kafka_group_name = 'clickhouse-traces-avro'"+ format = "kafka_format = 'Avro'"+ num_consumers = 8+ skip_broken_messages = 100+ poll_timeout_ms = 3000+ poll_max_batch_size = 1000+ thread_per_consumer = true+ }+ }++ table "kafka_usage_report_events_preagg" {+ column "uuid" {+ type = "UUID"+ }+ column "event" {+ type = "String"+ }+ column "properties" {+ type = "String"+ codec = "ZSTD(3)"+ }+ column "timestamp" {+ type = "DateTime64(6, 'UTC')"+ }+ column "team_id" {+ type = "Int64"+ }+ column "distinct_id" {+ type = "String"+ }+ column "person_mode" {+ type = "Enum8('full'=0, 'propertyless'=1, 'force_upgrade'=2)"+ }+ engine "kafka" {+ broker_list = "warpstream_ingestion"+ topic_list = "kafka_topic_list = 'clickhouse_events_json'"+ group_name = "kafka_group_name = 'clickhouse_usage_report_events_preagg'"+ format = "kafka_format = 'JSONEachRow'"+ num_consumers = 1+ skip_broken_messages = 100+ thread_per_consumer = true+ }+ }++ table "llma_metrics_daily" {+ order_by = ["team_id", "date", "metric_name"]+ partition_by = "toYYYYMM(date)"+ settings = {+ index_granularity = "8192"+ }+ column "date" {+ type = "Date"+ }+ column "team_id" {+ type = "UInt64"+ }+ column "metric_name" {+ type = "String"+ }+ column "metric_value" {+ type = "Float64"+ }+ engine "replicated_merge_tree" {+ zoo_path = "/clickhouse/tables/noshard/posthog.llma_metrics_daily"+ replica_name = "{replica}-{shard}"+ }+ }++ table "log_attributes" {+ order_by = ["team_id", "attribute_type", "time_bucket", "resource_fingerprint", "attribute_key", "attribute_value"]+ partition_by = "toDate(original_expiry_time_bucket)"+ settings = {+ deduplicate_merge_projection_mode = "drop"+ index_granularity = "8192"+ storage_policy = "default"+ }+ column "team_id" {+ type = "Int32"+ codec = "DoubleDelta, ZSTD(1)"+ }+ column "time_bucket" {+ type = "DateTime64(0)"+ codec = "DoubleDelta, ZSTD(1)"+ }+ column "original_expiry_time_bucket" {+ type = "DateTime64(0)"+ codec = "DoubleDelta, ZSTD(1)"+ }+ column "service_name" {+ type = "LowCardinality(String)"+ codec = "ZSTD(1)"+ }+ column "resource_fingerprint" {+ type = "UInt64"+ default = "0"+ codec = "DoubleDelta, ZSTD(1)"+ }+ column "attribute_key" {+ type = "LowCardinality(String)"+ codec = "ZSTD(1)"+ }+ column "attribute_value" {+ type = "String"+ codec = "ZSTD(1)"+ }+ column "attribute_count" {+ type = "SimpleAggregateFunction(sum, UInt64)"+ }+ column "attribute_type" {+ type = "LowCardinality(String)"+ }+ index "idx_attribute_key" {+ expr = "attribute_key"+ type = "bloom_filter(0.01)"+ granularity = 1+ }+ index "idx_attribute_value" {+ expr = "attribute_value"+ type = "bloom_filter(0.01)"+ granularity = 1+ }+ index "idx_attribute_key_n3" {+ expr = "attribute_key"+ type = "ngrambf_v1(3, 32768, 3, 0)"+ granularity = 1+ }+ index "idx_attribute_value_n3" {+ expr = "attribute_value"+ type = "ngrambf_v1(3, 32768, 3, 0)"+ granularity = 1+ }+ engine "replicated_aggregating_merge_tree" {+ zoo_path = "/clickhouse/tables/noshard/posthog.log_attributes"+ replica_name = "{replica}-{shard}"+ }+ }++ table "log_attributes2" {+ order_by = ["team_id", "attribute_type", "time_bucket", "resource_fingerprint", "attribute_key", "attribute_value"]+ partition_by = "toDate(original_expiry_time_bucket)"+ ttl = "original_expiry_time_bucket"+ settings = {+ deduplicate_merge_projection_mode = "drop"+ index_granularity = "8192"+ }+ column "team_id" {+ type = "Int32"+ }+ column "time_bucket" {+ type = "DateTime64(0)"+ }+ column "service_name" {+ type = "LowCardinality(String)"+ }+ column "resource_fingerprint" {+ type = "UInt64"+ default = "0"+ }+ column "attribute_key" {+ type = "LowCardinality(String)"+ }+ column "attribute_value" {+ type = "String"+ codec = "ZSTD(5)"+ }+ column "attribute_count" {+ type = "SimpleAggregateFunction(sum, UInt64)"+ }+ column "attribute_type" {+ type = "LowCardinality(String)"+ default = "'log'"+ }+ column "original_expiry_time_bucket" {+ type = "DateTime"+ default = "now()"+ }+ index "idx_attribute_key" {+ expr = "attribute_key"+ type = "bloom_filter(0.01)"+ granularity = 1+ }+ index "idx_attribute_value" {+ expr = "attribute_value"+ type = "bloom_filter(0.01)"+ granularity = 1+ }+ index "idx_attribute_key_n3" {+ expr = "attribute_key"+ type = "ngrambf_v1(3, 32768, 3, 0)"+ granularity = 1+ }+ index "idx_attribute_value_n3" {+ expr = "attribute_value"+ type = "ngrambf_v1(3, 32768, 3, 0)"+ granularity = 1+ }+ engine "replicated_aggregating_merge_tree" {+ zoo_path = "/clickhouse/tables/noshard/posthog.log_attributes2"+ replica_name = "{replica}-{shard}"+ }+ }++ table "log_attributes3" {+ order_by = ["team_id", "attribute_type", "time_bucket", "resource_fingerprint", "attribute_key", "attribute_value", "severity_text"]+ partition_by = "toDate(original_expiry_time_bucket)"+ ttl = "original_expiry_time_bucket"+ settings = {+ deduplicate_merge_projection_mode = "drop"+ index_granularity = "8192"+ }+ column "team_id" {+ type = "Int32"+ }+ column "time_bucket" {+ type = "DateTime64(0)"+ }+ column "service_name" {+ type = "LowCardinality(String)"+ }+ column "resource_fingerprint" {+ type = "UInt64"+ default = "0"+ }+ column "attribute_key" {+ type = "LowCardinality(String)"+ }+ column "attribute_value" {+ type = "String"+ codec = "ZSTD(5)"+ }+ column "attribute_count" {+ type = "SimpleAggregateFunction(sum, UInt64)"+ }+ column "attribute_type" {+ type = "LowCardinality(String)"+ default = "'log'"+ }+ column "original_expiry_time_bucket" {+ type = "DateTime"+ default = "now()"+ }+ column "severity_text" {+ type = "LowCardinality(String)"+ }+ index "idx_attribute_key" {+ expr = "attribute_key"+ type = "bloom_filter(0.01)"+ granularity = 1+ }+ index "idx_attribute_value" {+ expr = "attribute_value"+ type = "bloom_filter(0.01)"+ granularity = 1+ }+ index "idx_attribute_key_n3" {+ expr = "attribute_key"+ type = "ngrambf_v1(3, 32768, 3, 0)"+ granularity = 1+ }+ index "idx_attribute_value_n3" {+ expr = "attribute_value"+ type = "ngrambf_v1(3, 32768, 3, 0)"+ granularity = 1+ }+ engine "replicated_aggregating_merge_tree" {+ zoo_path = "/clickhouse/tables/noshard/posthog.log_attributes3"+ replica_name = "{replica}-{shard}"+ }+ }++ table "log_attributes_distributed" {+ column "team_id" {+ type = "Int32"+ }+ column "time_bucket" {+ type = "DateTime64(0)"+ }+ column "service_name" {+ type = "LowCardinality(String)"+ }+ column "resource_fingerprint" {+ type = "UInt64"+ default = "0"+ }+ column "attribute_key" {+ type = "LowCardinality(String)"+ }+ column "attribute_value" {+ type = "String"+ codec = "ZSTD(5)"+ }+ column "attribute_count" {+ type = "SimpleAggregateFunction(sum, UInt64)"+ }+ column "attribute_type" {+ type = "LowCardinality(String)"+ default = "'log'"+ }+ column "original_expiry_time_bucket" {+ type = "DateTime"+ default = "now()"+ }+ column "severity_text" {+ type = "LowCardinality(String)"+ }+ engine "distributed" {+ cluster_name = "posthog_single_shard"+ remote_database = "posthog"+ remote_table = "log_attributes3"+ }+ }++ table "log_entries" {+ column "team_id" {+ type = "UInt64"+ }+ column "log_source" {+ type = "LowCardinality(String)"+ }+ column "log_source_id" {+ type = "String"+ }+ column "instance_id" {+ type = "String"+ }+ column "timestamp" {+ type = "DateTime64(6, 'UTC')"+ }+ column "level" {+ type = "LowCardinality(String)"+ }+ column "message" {+ type = "String"+ }+ column "_timestamp" {+ type = "DateTime"+ }+ column "_offset" {+ type = "UInt64"+ }+ engine "distributed" {+ cluster_name = "posthog"+ remote_database = "posthog"+ remote_table = "sharded_log_entries"+ sharding_key = "rand()"+ }+ }++ table "logs" {+ column "time_bucket" {+ type = "DateTime"+ materialized = "toStartOfDay(timestamp)"+ codec = "DoubleDelta, ZSTD(1)"+ }+ column "original_expiry_timestamp" {+ type = "DateTime64(6)"+ codec = "DoubleDelta, ZSTD(1)"+ }+ column "uuid" {+ type = "String"+ codec = "ZSTD(1)"+ }+ column "team_id" {+ type = "Int32"+ codec = "ZSTD(1)"+ }+ column "trace_id" {+ type = "String"+ codec = "ZSTD(1)"+ }+ column "span_id" {+ type = "String"+ codec = "ZSTD(1)"+ }+ column "trace_flags" {+ type = "Int32"+ codec = "ZSTD(1)"+ }+ column "timestamp" {+ type = "DateTime64(6)"+ codec = "DoubleDelta, ZSTD(1)"+ }+ column "observed_timestamp" {+ type = "DateTime64(6)"+ codec = "DoubleDelta, ZSTD(1)"+ }+ column "created_at" {+ type = "DateTime64(6)"+ materialized = "now()"+ codec = "DoubleDelta, ZSTD(1)"+ }+ column "body" {+ type = "String"+ codec = "ZSTD(1)"+ }+ column "severity_text" {+ type = "LowCardinality(String)"+ codec = "ZSTD(1)"+ }+ column "severity_number" {+ type = "Int32"+ codec = "ZSTD(1)"+ }+ column "service_name" {+ type = "LowCardinality(String)"+ codec = "ZSTD(1)"+ }+ column "resource_attributes" {+ type = "Map(LowCardinality(String), String)"+ codec = "ZSTD(1)"+ }+ column "resource_fingerprint" {+ type = "UInt64"+ materialized = "cityHash64(resource_attributes)"+ codec = "DoubleDelta, ZSTD(1)"+ }+ column "instrumentation_scope" {+ type = "String"+ codec = "ZSTD(1)"+ }+ column "event_name" {+ type = "String"+ codec = "ZSTD(1)"+ }+ column "attributes_map_str" {+ type = "Map(LowCardinality(String), String)"+ codec = "ZSTD(1)"+ }+ column "level" {+ type = "String"+ alias = "severity_text"+ }+ column "mat_body_ipv4_matches" {+ type = "Array(String)"+ alias = "extractAll(body, '(\\\\d\\\\.((25[0-5]|(2[0-4]|1(0, 1)[0-9])(0, 1)[0-9])\\\\.)(2, 2)([0-9]))')"+ }+ column "time_minute" {+ type = "DateTime"+ alias = "toStartOfMinute(timestamp)"+ }+ column "attributes" {+ type = "Map(LowCardinality(String), String)"+ alias = "mapApply((k, v) -> (left(k, -5), v), attributes_map_str)"+ }+ column "attributes_map_float" {+ type = "Map(LowCardinality(String), Float64)"+ materialized = "mapFilter((k, v) -> (v IS NOT NULL), mapApply((k, v) -> (concat(left(k, -5), '__float'), toFloat64OrNull(v)), attributes_map_str))"+ codec = "ZSTD(1)"+ }+ column "attributes_map_datetime" {+ type = "Map(LowCardinality(String), DateTime64(6))"+ materialized = "mapFilter((k, v) -> (v IS NOT NULL), mapApply((k, v) -> (concat(left(k, -5), '__datetime'), parseDateTimeBestEffortOrNull(v, 6)), attributes_map_str))"+ codec = "ZSTD(1)"+ }+ column "_partition" {+ type = "UInt32"+ codec = "DoubleDelta, ZSTD(1)"+ }+ column "_topic" {+ type = "String"+ }+ column "_offset" {+ type = "UInt64"+ codec = "DoubleDelta, ZSTD(1)"+ }+ column "_bytes_uncompressed" {+ type = "UInt64"+ codec = "DoubleDelta, ZSTD(1)"+ }+ column "_bytes_compressed" {+ type = "UInt64"+ codec = "DoubleDelta, ZSTD(1)"+ }+ column "_record_count" {+ type = "UInt64"+ codec = "DoubleDelta, ZSTD(1)"+ }+ engine "distributed" {+ cluster_name = "posthog_single_shard"+ remote_database = "posthog"+ remote_table = "logs32"+ }+ }++ table "logs32" {+ order_by = ["team_id", "time_bucket", "service_name", "resource_fingerprint", "severity_text", "timestamp"]+ partition_by = "toDate(original_expiry_timestamp)"+ settings = {+ add_minmax_index_for_numeric_columns = "1"+ allow_experimental_reverse_key = "1"+ allow_remote_fs_zero_copy_replication = "1"+ index_granularity = "8192"+ index_granularity_bytes = "104857600"+ storage_policy = "default"+ ttl_only_drop_parts = "1"+ }+ column "time_bucket" {+ type = "DateTime"+ materialized = "toStartOfDay(timestamp)"+ codec = "DoubleDelta, ZSTD(1)"+ }+ column "original_expiry_timestamp" {+ type = "DateTime64(6)"+ codec = "DoubleDelta, ZSTD(1)"+ }+ column "uuid" {+ type = "String"+ codec = "ZSTD(1)"+ }+ column "team_id" {+ type = "Int32"+ codec = "ZSTD(1)"+ }+ column "trace_id" {+ type = "String"+ codec = "ZSTD(1)"+ }+ column "span_id" {+ type = "String"+ codec = "ZSTD(1)"+ }+ column "trace_flags" {+ type = "Int32"+ codec = "ZSTD(1)"+ }+ column "timestamp" {+ type = "DateTime64(6)"+ codec = "DoubleDelta, ZSTD(1)"+ }+ column "observed_timestamp" {+ type = "DateTime64(6)"+ codec = "DoubleDelta, ZSTD(1)"+ }+ column "created_at" {+ type = "DateTime64(6)"+ materialized = "now()"+ codec = "DoubleDelta, ZSTD(1)"+ }+ column "body" {+ type = "String"+ codec = "ZSTD(1)"+ }+ column "severity_text" {+ type = "LowCardinality(String)"+ codec = "ZSTD(1)"+ }+ column "severity_number" {+ type = "Int32"+ codec = "ZSTD(1)"+ }+ column "service_name" {+ type = "LowCardinality(String)"+ codec = "ZSTD(1)"+ }+ column "resource_attributes" {+ type = "Map(LowCardinality(String), String)"+ codec = "ZSTD(1)"+ }+ column "resource_fingerprint" {+ type = "UInt64"+ materialized = "cityHash64(resource_attributes)"+ codec = "DoubleDelta, ZSTD(1)"+ }+ column "instrumentation_scope" {+ type = "String"+ codec = "ZSTD(1)"+ }+ column "event_name" {+ type = "String"+ codec = "ZSTD(1)"+ }+ column "attributes_map_str" {+ type = "Map(LowCardinality(String), String)"+ codec = "ZSTD(1)"+ }+ column "level" {+ type = "String"+ alias = "severity_text"+ }+ column "mat_body_ipv4_matches" {+ type = "Array(String)"+ alias = "extractAll(body, '(\\\\d\\\\.((25[0-5]|(2[0-4]|1(0, 1)[0-9])(0, 1)[0-9])\\\\.)(2, 2)([0-9]))')"+ }+ column "time_minute" {+ type = "DateTime"+ alias = "toStartOfMinute(timestamp)"+ }+ column "attributes" {+ type = "Map(LowCardinality(String), String)"+ alias = "mapApply((k, v) -> (left(k, -5), v), attributes_map_str)"+ }+ column "attributes_map_float" {+ type = "Map(LowCardinality(String), Float64)"+ materialized = "mapFilter((k, v) -> (v IS NOT NULL), mapApply((k, v) -> (concat(left(k, -5), '__float'), toFloat64OrNull(v)), attributes_map_str))"+ codec = "ZSTD(1)"+ }+ column "attributes_map_datetime" {+ type = "Map(LowCardinality(String), DateTime64(6))"+ materialized = "mapFilter((k, v) -> (v IS NOT NULL), mapApply((k, v) -> (concat(left(k, -5), '__datetime'), parseDateTimeBestEffortOrNull(v, 6)), attributes_map_str))"+ codec = "ZSTD(1)"+ }+ column "_partition" {+ type = "UInt32"+ codec = "DoubleDelta, ZSTD(1)"+ }+ column "_topic" {+ type = "String"+ }+ column "_offset" {+ type = "UInt64"+ codec = "DoubleDelta, ZSTD(1)"+ }+ column "_bytes_uncompressed" {+ type = "UInt64"+ codec = "DoubleDelta, ZSTD(1)"+ }+ column "_bytes_compressed" {+ type = "UInt64"+ codec = "DoubleDelta, ZSTD(1)"+ }+ column "_record_count" {+ type = "UInt64"+ codec = "DoubleDelta, ZSTD(1)"+ }+ index "idx_severity_text_set" {+ expr = "severity_text"+ type = "set(10)"+ granularity = 1+ }+ index "idx_attributes_str_keys" {+ expr = "mapKeys(attributes_map_str)"+ type = "bloom_filter(0.01)"+ granularity = 1+ }+ index "idx_attributes_str_values" {+ expr = "mapValues(attributes_map_str)"+ type = "bloom_filter(0.001)"+ granularity = 1+ }+ index "idx_mat_body_ipv4_matches" {+ expr = "mat_body_ipv4_matches"+ type = "bloom_filter(0.01)"+ granularity = 1+ }+ index "idx_body_ngram3" {+ expr = "lower(body)"+ type = "ngrambf_v1(3, 25000, 2, 0)"+ granularity = 1+ }+ index "idx_uuid_bloom" {+ expr = "uuid"+ type = "bloom_filter(0.01)"+ granularity = 1+ }+ index "idx_observed_minmax" {+ expr = "observed_timestamp"+ type = "minmax"+ granularity = 1+ }+ index "idx_timestamp_minmax" {+ expr = "timestamp"+ type = "minmax"+ granularity = 1+ }+ projection "projection_aggregate_counts" {+ query = <<SQL+SELECT+ team_id,+ time_bucket,+ toStartOfMinute(timestamp),+ service_name,+ severity_text,+ resource_fingerprint,+ count() AS event_count+GROUP BY+ team_id, time_bucket, toStartOfMinute(timestamp), service_name, severity_text, resource_fingerprint+SQL++ }+ engine "replicated_merge_tree" {+ zoo_path = "/clickhouse/tables/noshard/posthog.logs32"+ replica_name = "{replica}-{shard}"+ }+ }++ table "logs34" {+ order_by = ["team_id", "time_bucket", "service_name", "resource_fingerprint", "severity_text", "timestamp"]+ partition_by = "toDate(original_expiry_timestamp)"+ ttl = "original_expiry_timestamp"+ settings = {+ add_minmax_index_for_numeric_columns = "1"+ allow_experimental_reverse_key = "1"+ index_granularity = "8192"+ index_granularity_bytes = "104857600"+ map_serialization_version = "with_buckets"+ ttl_only_drop_parts = "1"+ }+ column "time_bucket" {+ type = "DateTime"+ materialized = "toStartOfDay(timestamp)"+ }+ column "original_expiry_timestamp" {+ type = "DateTime64(6)"+ }+ column "uuid" {+ type = "String"+ }+ column "team_id" {+ type = "Int32"+ }+ column "trace_id" {+ type = "String"+ }+ column "span_id" {+ type = "String"+ }+ column "trace_flags" {+ type = "Int32"+ }+ column "timestamp" {+ type = "DateTime64(6)"+ codec = "DoubleDelta"+ }+ column "observed_timestamp" {+ type = "DateTime64(6)"+ }+ column "created_at" {+ type = "DateTime64(6)"+ materialized = "now()"+ }+ column "body" {+ type = "String"+ }+ column "severity_text" {+ type = "LowCardinality(String)"+ }+ column "severity_number" {+ type = "Int32"+ }+ column "service_name" {+ type = "LowCardinality(String)"+ }+ column "resource_attributes" {+ type = "Map(LowCardinality(String), String)"+ }+ column "resource_fingerprint" {+ type = "UInt64"+ materialized = "cityHash64(resource_attributes)"+ }+ column "instrumentation_scope" {+ type = "String"+ }+ column "event_name" {+ type = "String"+ }+ column "attributes_map_str" {+ type = "Map(LowCardinality(String), String)"+ }+ column "level" {+ type = "String"+ alias = "severity_text"+ }+ column "mat_body_ipv4_matches" {+ type = "Array(String)"+ alias = "extractAll(body, '(\\\\d\\\\.((25[0-5]|(2[0-4]|1(0, 1)[0-9])(0, 1)[0-9])\\\\.)(2, 2)([0-9]))')"+ }+ column "time_minute" {+ type = "DateTime"+ alias = "toStartOfMinute(timestamp)"+ }+ column "attributes" {+ type = "Map(LowCardinality(String), String)"+ alias = "mapApply((k, v) -> (left(k, -5), v), attributes_map_str)"+ }+ column "attributes_map_float" {+ type = "Map(LowCardinality(String), Float64)"+ materialized = "mapFilter((k, v) -> (v IS NOT NULL), mapApply((k, v) -> (concat(left(k, -5), '__float'), toFloat64OrNull(v)), attributes_map_str))"+ }+ column "attributes_map_datetime" {+ type = "Map(LowCardinality(String), DateTime64(6))"+ materialized = "mapFilter((k, v) -> (v IS NOT NULL), mapApply((k, v) -> (concat(left(k, -5), '__datetime'), parseDateTimeBestEffortOrNull(v, 6)), attributes_map_str))"+ }+ column "_partition" {+ type = "UInt32"+ }+ column "_topic" {+ type = "String"+ }+ column "_offset" {+ type = "UInt64"+ }+ column "_bytes_uncompressed" {+ type = "UInt64"+ }+ column "_bytes_compressed" {+ type = "UInt64"+ }+ column "_record_count" {+ type = "UInt64"+ }+ index "idx_severity_text_set" {+ expr = "severity_text"+ type = "set(10)"+ granularity = 1+ }+ index "idx_attributes_str_keys" {+ expr = "mapKeys(attributes_map_str)"+ type = "bloom_filter(0.01)"+ granularity = 1+ }+ index "idx_attributes_str_values" {+ expr = "mapValues(attributes_map_str)"+ type = "bloom_filter(0.001)"+ granularity = 1+ }+ index "idx_mat_body_ipv4_matches" {+ expr = "mat_body_ipv4_matches"+ type = "bloom_filter(0.01)"+ granularity = 1+ }+ index "idx_body_ngram3" {+ expr = "lower(body)"+ type = "ngrambf_v1(3, 25000, 2, 0)"+ granularity = 1+ }+ index "idx_uuid_bloom" {+ expr = "uuid"+ type = "bloom_filter(0.01)"+ granularity = 1+ }+ index "idx_observed_minmax" {+ expr = "observed_timestamp"+ type = "minmax"+ granularity = 1+ }+ index "idx_timestamp_minmax" {+ expr = "timestamp"+ type = "minmax"+ granularity = 1+ }+ projection "projection_aggregate_counts" {+ query = <<SQL+SELECT+ team_id,+ time_bucket,+ toStartOfMinute(timestamp),+ service_name,+ severity_text,+ resource_fingerprint,+ count() AS event_count+GROUP BY+ team_id, time_bucket, toStartOfMinute(timestamp), service_name, severity_text, resource_fingerprint+SQL++ }+ engine "replicated_merge_tree" {+ zoo_path = "/clickhouse/tables/noshard/posthog.logs34"+ replica_name = "{replica}-{shard}"+ }+ }++ table "logs_billing_metrics" {+ order_by = ["team_id", "time_bucket", "service_name"]+ partition_by = "toYYYYMM(time_bucket)"+ settings = {+ deduplicate_merge_projection_mode = "rebuild"+ index_granularity = "8192"+ }+ column "team_id" {+ type = "Int32"+ }+ column "time_bucket" {+ type = "DateTime64(0)"+ }+ column "service_name" {+ type = "LowCardinality(String)"+ }+ column "bytes_uncompressed" {+ type = "SimpleAggregateFunction(sum, UInt64)"+ }+ column "bytes_compressed" {+ type = "SimpleAggregateFunction(sum, UInt64)"+ }+ column "record_count" {+ type = "SimpleAggregateFunction(sum, UInt64)"+ }+ engine "replicated_aggregating_merge_tree" {+ zoo_path = "/clickhouse/tables/noshard/posthog.logs_billing_metrics"+ replica_name = "{replica}-{shard}"+ }+ }++ table "logs_billing_metrics_distributed" {+ column "team_id" {+ type = "Int32"+ }+ column "time_bucket" {+ type = "DateTime64(0)"+ }+ column "service_name" {+ type = "LowCardinality(String)"+ }+ column "bytes_uncompressed" {+ type = "SimpleAggregateFunction(sum, UInt64)"+ }+ column "bytes_compressed" {+ type = "SimpleAggregateFunction(sum, UInt64)"+ }+ column "record_count" {+ type = "SimpleAggregateFunction(sum, UInt64)"+ }+ engine "distributed" {+ cluster_name = "posthog_single_shard"+ remote_database = "posthog"+ remote_table = "logs_billing_metrics"+ }+ }++ table "logs_distributed" {+ column "time_bucket" {+ type = "DateTime"+ materialized = "toStartOfDay(timestamp)"+ }+ column "original_expiry_timestamp" {+ type = "DateTime64(6)"+ }+ column "uuid" {+ type = "String"+ }+ column "team_id" {+ type = "Int32"+ }+ column "trace_id" {+ type = "String"+ }+ column "span_id" {+ type = "String"+ }+ column "trace_flags" {+ type = "Int32"+ }+ column "timestamp" {+ type = "DateTime64(6)"+ codec = "DoubleDelta"+ }+ column "observed_timestamp" {+ type = "DateTime64(6)"+ }+ column "created_at" {+ type = "DateTime64(6)"+ materialized = "now()"+ }+ column "body" {+ type = "String"+ }+ column "severity_text" {+ type = "LowCardinality(String)"+ }+ column "severity_number" {+ type = "Int32"+ }+ column "service_name" {+ type = "LowCardinality(String)"+ }+ column "resource_attributes" {+ type = "Map(LowCardinality(String), String)"+ }+ column "resource_fingerprint" {+ type = "UInt64"+ materialized = "cityHash64(resource_attributes)"+ }+ column "instrumentation_scope" {+ type = "String"+ }+ column "event_name" {+ type = "String"+ }+ column "attributes_map_str" {+ type = "Map(LowCardinality(String), String)"+ }+ column "level" {+ type = "String"+ alias = "severity_text"+ }+ column "mat_body_ipv4_matches" {+ type = "Array(String)"+ alias = "extractAll(body, '(\\\\d\\\\.((25[0-5]|(2[0-4]|1(0, 1)[0-9])(0, 1)[0-9])\\\\.)(2, 2)([0-9]))')"+ }+ column "time_minute" {+ type = "DateTime"+ alias = "toStartOfMinute(timestamp)"+ }+ column "attributes" {+ type = "Map(LowCardinality(String), String)"+ alias = "mapApply((k, v) -> (left(k, -5), v), attributes_map_str)"+ }+ column "attributes_map_float" {+ type = "Map(LowCardinality(String), Float64)"+ materialized = "mapFilter((k, v) -> (v IS NOT NULL), mapApply((k, v) -> (concat(left(k, -5), '__float'), toFloat64OrNull(v)), attributes_map_str))"+ }+ column "attributes_map_datetime" {+ type = "Map(LowCardinality(String), DateTime64(6))"+ materialized = "mapFilter((k, v) -> (v IS NOT NULL), mapApply((k, v) -> (concat(left(k, -5), '__datetime'), parseDateTimeBestEffortOrNull(v, 6)), attributes_map_str))"+ }+ column "_partition" {+ type = "UInt32"+ }+ column "_topic" {+ type = "String"+ }+ column "_offset" {+ type = "UInt64"+ }+ column "_bytes_uncompressed" {+ type = "UInt64"+ }+ column "_bytes_compressed" {+ type = "UInt64"+ }+ column "_record_count" {+ type = "UInt64"+ }+ engine "distributed" {+ cluster_name = "posthog_single_shard"+ remote_database = "posthog"+ remote_table = "logs34"+ }+ }++ table "logs_kafka_metrics" {+ order_by = ["_topic", "_partition"]+ settings = {+ index_granularity = "8192"+ }+ column "_partition" {+ type = "UInt32"+ }+ column "_topic" {+ type = "String"+ }+ column "max_offset" {+ type = "SimpleAggregateFunction(max, UInt64)"+ }+ column "max_observed_timestamp" {+ type = "SimpleAggregateFunction(max, DateTime64(9))"+ }+ column "max_timestamp" {+ type = "SimpleAggregateFunction(max, DateTime64(9))"+ }+ column "max_created_at" {+ type = "SimpleAggregateFunction(max, DateTime64(9))"+ }+ column "max_lag" {+ type = "SimpleAggregateFunction(max, UInt64)"+ }+ engine "replicated_aggregating_merge_tree" {+ zoo_path = "/clickhouse/tables/noshard/posthog.logs_kafka_metrics"+ replica_name = "{replica}-{shard}"+ }+ }++ table "logs_kafka_metrics_distributed" {+ column "_partition" {+ type = "UInt32"+ }+ column "_topic" {+ type = "String"+ }+ column "max_offset" {+ type = "SimpleAggregateFunction(max, UInt64)"+ }+ column "max_observed_timestamp" {+ type = "SimpleAggregateFunction(max, DateTime64(9))"+ }+ column "max_timestamp" {+ type = "SimpleAggregateFunction(max, DateTime64(9))"+ }+ column "max_created_at" {+ type = "SimpleAggregateFunction(max, DateTime64(9))"+ }+ column "max_lag" {+ type = "SimpleAggregateFunction(max, UInt64)"+ }+ engine "distributed" {+ cluster_name = "posthog_single_shard"+ remote_database = "posthog"+ remote_table = "logs_kafka_metrics"+ }+ }++ table "marketing_conversions_preaggregated" {+ column "team_id" {+ type = "Int64"+ }+ column "job_id" {+ type = "UUID"+ }+ column "person_id" {+ type = "UUID"+ }+ column "conversion_timestamp" {+ type = "DateTime64(6, 'UTC')"+ }+ column "conversion_math_value" {+ type = "Float64"+ }+ column "session_id" {+ type = "String"+ }+ column "campaign_name" {+ type = "String"+ }+ column "source_name" {+ type = "String"+ }+ column "medium_name" {+ type = "String"+ }+ column "content_name" {+ type = "String"+ }+ column "term_name" {+ type = "String"+ }+ column "referring_domain_name" {+ type = "String"+ }+ column "gclid_name" {+ type = "String"+ }+ column "fbclid_name" {+ type = "String"+ }+ column "gad_source_name" {+ type = "String"+ }+ column "computed_at" {+ type = "DateTime64(6, 'UTC')"+ default = "now()"+ }+ column "expires_at" {+ type = "Date"+ default = "today() + toIntervalDay(7)"+ }+ engine "distributed" {+ cluster_name = "aux"+ remote_database = "posthog"+ remote_table = "sharded_marketing_conversions_preaggregated"+ sharding_key = "cityHash64(person_id)"+ }+ }++ table "marketing_costs_preaggregated" {+ column "team_id" {+ type = "Int64"+ }+ column "job_id" {+ type = "UUID"+ }+ column "source_id" {+ type = "String"+ }+ column "source_name" {+ type = "String"+ }+ column "grain" {+ type = "LowCardinality(String)"+ }+ column "match_key" {+ type = "String"+ }+ column "campaign_id" {+ type = "String"+ }+ column "campaign_name" {+ type = "String"+ }+ column "ad_group_id" {+ type = "String"+ }+ column "ad_group_name" {+ type = "String"+ }+ column "ad_id" {+ type = "String"+ }+ column "ad_name" {+ type = "String"+ }+ column "cost_date" {+ type = "Date"+ }+ column "cost" {+ type = "Float64"+ }+ column "clicks" {+ type = "Float64"+ }+ column "impressions" {+ type = "Float64"+ }+ column "reported_conversions" {+ type = "Float64"+ }+ column "reported_conversion_value" {+ type = "Float64"+ }+ column "computed_at" {+ type = "DateTime64(6, 'UTC')"+ default = "now()"+ }+ column "expires_at" {+ type = "Date"+ default = "today() + toIntervalDay(7)"+ }+ engine "distributed" {+ cluster_name = "aux"+ remote_database = "posthog"+ remote_table = "sharded_marketing_costs_preaggregated"+ sharding_key = "cityHash64(source_name, campaign_id)"+ }+ }++ table "marketing_touchpoints_preaggregated" {+ column "team_id" {+ type = "Int64"+ }+ column "job_id" {+ type = "UUID"+ }+ column "person_id" {+ type = "UUID"+ }+ column "touchpoint_timestamp" {+ type = "DateTime64(6, 'UTC')"+ }+ column "campaign_name" {+ type = "String"+ }+ column "source_name" {+ type = "String"+ }+ column "medium_name" {+ type = "String"+ }+ column "content_name" {+ type = "String"+ }+ column "term_name" {+ type = "String"+ }+ column "referring_domain_name" {+ type = "String"+ }+ column "gclid_name" {+ type = "String"+ }+ column "fbclid_name" {+ type = "String"+ }+ column "gad_source_name" {+ type = "String"+ }+ column "computed_at" {+ type = "DateTime64(6, 'UTC')"+ default = "now()"+ }+ column "expires_at" {+ type = "Date"+ default = "today() + toIntervalDay(7)"+ }+ engine "distributed" {+ cluster_name = "aux"+ remote_database = "posthog"+ remote_table = "sharded_marketing_touchpoints_preaggregated"+ sharding_key = "cityHash64(person_id)"+ }+ }++ table "message_assets" {+ column "team_id" {+ type = "Int64"+ }+ column "function_kind" {+ type = "LowCardinality(String)"+ }+ column "function_id" {+ type = "String"+ }+ column "parent_run_id" {+ type = "String"+ }+ column "invocation_id" {+ type = "String"+ }+ column "action_id" {+ type = "String"+ }+ column "kind" {+ type = "LowCardinality(String)"+ }+ column "distinct_id" {+ type = "String"+ }+ column "person_id" {+ type = "String"+ }+ column "recipient" {+ type = "String"+ }+ column "subject" {+ type = "String"+ }+ column "status" {+ type = "LowCardinality(String)"+ }+ column "sent_at" {+ type = "DateTime64(6, 'UTC')"+ }+ column "version" {+ type = "UInt64"+ }+ column "is_deleted" {+ type = "UInt8"+ }+ column "html" {+ type = "String"+ }+ column "_timestamp" {+ type = "DateTime"+ }+ column "_offset" {+ type = "UInt64"+ }+ column "_partition" {+ type = "UInt64"+ }+ engine "distributed" {+ cluster_name = "aux"+ remote_database = "posthog"+ remote_table = "message_assets_data"+ }+ }++ table "message_assets_data" {+ order_by = ["team_id", "function_kind", "function_id", "invocation_id", "action_id"]+ partition_by = "toYYYYMMDD(sent_at)"+ ttl = "toDate(sent_at) + toIntervalDay(30)"+ settings = {+ index_granularity = "1024"+ ttl_only_drop_parts = "1"+ }+ column "team_id" {+ type = "Int64"+ }+ column "function_kind" {+ type = "LowCardinality(String)"+ }+ column "function_id" {+ type = "String"+ }+ column "parent_run_id" {+ type = "String"+ }+ column "invocation_id" {+ type = "String"+ }+ column "action_id" {+ type = "String"+ }+ column "kind" {+ type = "LowCardinality(String)"+ }+ column "distinct_id" {+ type = "String"+ }+ column "person_id" {+ type = "String"+ }+ column "recipient" {+ type = "String"+ }+ column "subject" {+ type = "String"+ }+ column "status" {+ type = "LowCardinality(String)"+ }+ column "sent_at" {+ type = "DateTime64(6, 'UTC')"+ }+ column "version" {+ type = "UInt64"+ }+ column "is_deleted" {+ type = "UInt8"+ default = "0"+ }+ column "html" {+ type = "String"+ codec = "ZSTD(3)"+ }+ column "_timestamp" {+ type = "DateTime"+ }+ column "_offset" {+ type = "UInt64"+ }+ column "_partition" {+ type = "UInt64"+ }+ index "parent_run_idx" {+ expr = "parent_run_id"+ type = "bloom_filter(0.01)"+ granularity = 1+ }+ index "distinct_id_idx" {+ expr = "distinct_id"+ type = "bloom_filter(0.01)"+ granularity = 1+ }+ index "person_id_idx" {+ expr = "person_id"+ type = "bloom_filter(0.01)"+ granularity = 1+ }+ index "recipient_idx" {+ expr = "recipient"+ type = "bloom_filter(0.01)"+ granularity = 1+ }+ engine "replicated_replacing_merge_tree" {+ zoo_path = "/clickhouse/tables/noshard/posthog.message_assets_data"+ replica_name = "{replica}-{shard}"+ version_column = "version"+ }+ }++ table "metric_samples" {+ column "team_id" {+ type = "Int32"+ }+ column "metric_name" {+ type = "LowCardinality(String)"+ }+ column "series_fingerprint" {+ type = "UInt64"+ codec = "DoubleDelta"+ }+ column "timestamp" {+ type = "DateTime64(6)"+ codec = "DoubleDelta"+ }+ column "value" {+ type = "Float64"+ codec = "Gorilla(8)"+ }+ column "count" {+ type = "UInt64"+ default = "1"+ }+ column "histogram_bounds" {+ type = "Array(Float64)"+ }+ column "histogram_counts" {+ type = "Array(UInt64)"+ }+ column "trace_id" {+ type = "String"+ }+ column "span_id" {+ type = "String"+ }+ column "trace_flags" {+ type = "Int32"+ }+ engine "distributed" {+ cluster_name = "posthog_single_shard"+ remote_database = "posthog"+ remote_table = "metric_samples1"+ }+ }++ table "metric_samples1" {+ order_by = ["team_id", "metric_name", "series_fingerprint", "timestamp"]+ partition_by = "toDate(timestamp)"+ ttl = "toDateTime(timestamp) + toIntervalDay(30)"+ settings = {+ index_granularity = "8192"+ ttl_only_drop_parts = "1"+ }+ column "team_id" {+ type = "Int32"+ }+ column "metric_name" {+ type = "LowCardinality(String)"+ }+ column "series_fingerprint" {+ type = "UInt64"+ codec = "DoubleDelta"+ }+ column "timestamp" {+ type = "DateTime64(6)"+ codec = "DoubleDelta"+ }+ column "value" {+ type = "Float64"+ codec = "Gorilla(8)"+ }+ column "count" {+ type = "UInt64"+ default = "1"+ }+ column "histogram_bounds" {+ type = "Array(Float64)"+ }+ column "histogram_counts" {+ type = "Array(UInt64)"+ }+ column "trace_id" {+ type = "String"+ }+ column "span_id" {+ type = "String"+ }+ column "trace_flags" {+ type = "Int32"+ }+ index "idx_trace_id_bf" {+ expr = "trace_id"+ type = "bloom_filter(0.01)"+ granularity = 1+ }+ engine "replicated_merge_tree" {+ zoo_path = "/clickhouse/tables/noshard/posthog.metric_samples1"+ replica_name = "{replica}-{shard}"+ }+ }++ table "metric_series" {+ column "team_id" {+ type = "Int32"+ }+ column "metric_name" {+ type = "LowCardinality(String)"+ }+ column "series_fingerprint" {+ type = "UInt64"+ codec = "DoubleDelta"+ }+ column "metric_type" {+ type = "LowCardinality(String)"+ }+ column "unit" {+ type = "LowCardinality(String)"+ }+ column "aggregation_temporality" {+ type = "LowCardinality(String)"+ }+ column "is_monotonic" {+ type = "Bool"+ default = "false"+ }+ column "service_name" {+ type = "LowCardinality(String)"+ }+ column "resource_attributes" {+ type = "Map(LowCardinality(String), String)"+ }+ column "attributes" {+ type = "Map(LowCardinality(String), String)"+ }+ column "last_seen" {+ type = "DateTime64(6)"+ codec = "DoubleDelta"+ }+ engine "distributed" {+ cluster_name = "posthog_single_shard"+ remote_database = "posthog"+ remote_table = "metric_series1"+ }+ }++ table "metric_series1" {+ order_by = ["team_id", "metric_name", "series_fingerprint"]+ ttl = "toDateTime(last_seen) + toIntervalDay(90)"+ settings = {+ index_granularity = "8192"+ }+ column "team_id" {+ type = "Int32"+ }+ column "metric_name" {+ type = "LowCardinality(String)"+ }+ column "series_fingerprint" {+ type = "UInt64"+ codec = "DoubleDelta"+ }+ column "metric_type" {+ type = "LowCardinality(String)"+ }+ column "unit" {+ type = "LowCardinality(String)"+ }+ column "aggregation_temporality" {+ type = "LowCardinality(String)"+ }+ column "is_monotonic" {+ type = "Bool"+ default = "false"+ }+ column "service_name" {+ type = "LowCardinality(String)"+ }+ column "resource_attributes" {+ type = "Map(LowCardinality(String), String)"+ }+ column "attributes" {+ type = "Map(LowCardinality(String), String)"+ }+ column "last_seen" {+ type = "DateTime64(6)"+ codec = "DoubleDelta"+ }+ index "idx_service_set" {+ expr = "service_name"+ type = "set(1000)"+ granularity = 1+ }+ index "idx_attr_keys" {+ expr = "mapKeys(attributes)"+ type = "bloom_filter(0.01)"+ granularity = 1+ }+ index "idx_attr_values" {+ expr = "mapValues(attributes)"+ type = "bloom_filter(0.01)"+ granularity = 1+ }+ engine "replicated_replacing_merge_tree" {+ zoo_path = "/clickhouse/tables/noshard/posthog.metric_series1"+ replica_name = "{replica}-{shard}"+ version_column = "last_seen"+ }+ }++ table "partitioned_sharded_posthog_document_embeddings" {+ order_by = ["team_id", "toDate(timestamp)", "product", "document_type", "model_name", "rendering", "cityHash64(document_id)"]+ partition_by = "toMonday(timestamp)"+ ttl = "timestamp + toIntervalMonth(3)"+ settings = {+ index_granularity = "512"+ ttl_only_drop_parts = "1"+ }+ column "team_id" {+ type = "Int64"+ }+ column "product" {+ type = "LowCardinality(String)"+ }+ column "document_type" {+ type = "LowCardinality(String)"+ }+ column "model_name" {+ type = "LowCardinality(String)"+ }+ column "rendering" {+ type = "LowCardinality(String)"+ }+ column "document_id" {+ type = "String"+ }+ column "timestamp" {+ type = "DateTime64(3, 'UTC')"+ }+ column "inserted_at" {+ type = "DateTime64(3, 'UTC')"+ }+ column "content" {+ type = "String"+ default = "''"+ }+ column "metadata" {+ type = "String"+ default = "'{}'"+ }+ column "embedding" {+ type = "Array(Float64)"+ }+ column "_timestamp" {+ type = "DateTime"+ }+ column "_offset" {+ type = "UInt64"+ }+ column "_partition" {+ type = "UInt64"+ }+ index "kafka_timestamp_minmax_partitioned_sharded_posthog_document_embeddings" {+ expr = "_timestamp"+ type = "minmax"+ granularity = 3+ }+ engine "replicated_replacing_merge_tree" {+ zoo_path = "/clickhouse/tables/{shard}/posthog.partitioned_sharded_posthog_document_embeddings"+ replica_name = "{replica}"+ version_column = "inserted_at"+ }+ }++ table "performance_events" {+ column "uuid" {+ type = "UUID"+ }+ column "session_id" {+ type = "String"+ }+ column "window_id" {+ type = "String"+ }+ column "pageview_id" {+ type = "String"+ }+ column "distinct_id" {+ type = "String"+ }+ column "timestamp" {+ type = "DateTime64(3)"+ }+ column "time_origin" {+ type = "DateTime64(3, 'UTC')"+ }+ column "entry_type" {+ type = "LowCardinality(String)"+ }+ column "name" {+ type = "String"+ }+ column "team_id" {+ type = "Int64"+ }+ column "current_url" {+ type = "String"+ }+ column "start_time" {+ type = "Float64"+ }+ column "duration" {+ type = "Float64"+ }+ column "redirect_start" {+ type = "Float64"+ }+ column "redirect_end" {+ type = "Float64"+ }+ column "worker_start" {+ type = "Float64"+ }+ column "fetch_start" {+ type = "Float64"+ }+ column "domain_lookup_start" {+ type = "Float64"+ }+ column "domain_lookup_end" {+ type = "Float64"+ }+ column "connect_start" {+ type = "Float64"+ }+ column "secure_connection_start" {+ type = "Float64"+ }+ column "connect_end" {+ type = "Float64"+ }+ column "request_start" {+ type = "Float64"+ }+ column "response_start" {+ type = "Float64"+ }+ column "response_end" {+ type = "Float64"+ }+ column "decoded_body_size" {+ type = "Int64"+ }+ column "encoded_body_size" {+ type = "Int64"+ }+ column "initiator_type" {+ type = "LowCardinality(String)"+ }+ column "next_hop_protocol" {+ type = "LowCardinality(String)"+ }+ column "render_blocking_status" {+ type = "LowCardinality(String)"+ }+ column "response_status" {+ type = "Int64"+ }+ column "transfer_size" {+ type = "Int64"+ }+ column "largest_contentful_paint_element" {+ type = "String"+ }+ column "largest_contentful_paint_render_time" {+ type = "Float64"+ }+ column "largest_contentful_paint_load_time" {+ type = "Float64"+ }+ column "largest_contentful_paint_size" {+ type = "Float64"+ }+ column "largest_contentful_paint_id" {+ type = "String"+ }+ column "largest_contentful_paint_url" {+ type = "String"+ }+ column "dom_complete" {+ type = "Float64"+ }+ column "dom_content_loaded_event" {+ type = "Float64"+ }+ column "dom_interactive" {+ type = "Float64"+ }+ column "load_event_end" {+ type = "Float64"+ }+ column "load_event_start" {+ type = "Float64"+ }+ column "redirect_count" {+ type = "Int64"+ }+ column "navigation_type" {+ type = "LowCardinality(String)"+ }+ column "unload_event_end" {+ type = "Float64"+ }+ column "unload_event_start" {+ type = "Float64"+ }+ column "_timestamp" {+ type = "DateTime"+ }+ column "_offset" {+ type = "UInt64"+ }+ column "_partition" {+ type = "UInt64"+ }+ engine "distributed" {+ cluster_name = "posthog"+ remote_database = "posthog"+ remote_table = "sharded_performance_events"+ sharding_key = "sipHash64(session_id)"+ }+ }++ table "person" {+ order_by = ["team_id", "id"]+ settings = {+ index_granularity = "8192"+ }+ column "id" {+ type = "UUID"+ }+ column "created_at" {+ type = "DateTime64(3)"+ }+ column "team_id" {+ type = "Int64"+ }+ column "properties" {+ type = "String"+ }+ column "is_identified" {+ type = "Int8"+ }+ column "is_deleted" {+ type = "Int8"+ }+ column "version" {+ type = "UInt64"+ }+ column "last_seen_at" {+ type = "Nullable(DateTime64(3))"+ }+ column "_timestamp" {+ type = "DateTime"+ }+ column "_offset" {+ type = "UInt64"+ }+ index "kafka_timestamp_minmax_person" {+ expr = "_timestamp"+ type = "minmax"+ granularity = 3+ }+ engine "replicated_replacing_merge_tree" {+ zoo_path = "/clickhouse/tables/noshard/posthog.person"+ replica_name = "{replica}-{shard}"+ version_column = "version"+ }+ }++ table "person_distinct_id" {+ order_by = ["team_id", "distinct_id", "person_id"]+ settings = {+ index_granularity = "8192"+ }+ column "distinct_id" {+ type = "String"+ comment = "skip_0003_fill_person_distinct_id2"+ }+ column "person_id" {+ type = "UUID"+ }+ column "team_id" {+ type = "Int64"+ }+ column "_sign" {+ type = "Int8"+ default = "1"+ }+ column "is_deleted" {+ type = "Int8"+ alias = "if(_sign = -1, 1, 0)"+ }+ column "_timestamp" {+ type = "DateTime"+ }+ column "_offset" {+ type = "UInt64"+ }+ engine "replicated_collapsing_merge_tree" {+ zoo_path = "/clickhouse/tables/noshard/posthog.person_distinct_id"+ replica_name = "{replica}-{shard}"+ sign_column = "_sign"+ }+ }++ table "person_distinct_id2" {+ order_by = ["team_id", "distinct_id"]+ settings = {+ index_granularity = "512"+ }+ column "team_id" {+ type = "Int64"+ }+ column "distinct_id" {+ type = "String"+ }+ column "person_id" {+ type = "UUID"+ }+ column "is_deleted" {+ type = "Int8"+ }+ column "version" {+ type = "Int64"+ }+ column "_timestamp" {+ type = "DateTime"+ }+ column "_offset" {+ type = "UInt64"+ }+ column "_partition" {+ type = "UInt64"+ }+ index "kafka_timestamp_minmax_person_distinct_id2" {+ expr = "_timestamp"+ type = "minmax"+ granularity = 3+ }+ engine "replicated_replacing_merge_tree" {+ zoo_path = "/clickhouse/tables/noshard/posthog.person_distinct_id2"+ replica_name = "{replica}-{shard}"+ version_column = "version"+ }+ }++ table "person_distinct_id_overrides" {+ order_by = ["team_id", "distinct_id"]+ settings = {+ index_granularity = "512"+ }+ column "team_id" {+ type = "Int64"+ }+ column "distinct_id" {+ type = "String"+ }+ column "person_id" {+ type = "UUID"+ }+ column "is_deleted" {+ type = "Int8"+ }+ column "version" {+ type = "Int64"+ }+ column "_timestamp" {+ type = "DateTime"+ }+ column "_offset" {+ type = "UInt64"+ }+ column "_partition" {+ type = "UInt64"+ }+ index "kafka_timestamp_minmax_person_distinct_id_overrides" {+ expr = "_timestamp"+ type = "minmax"+ granularity = 3+ }+ engine "replicated_replacing_merge_tree" {+ zoo_path = "/clickhouse/tables/noshard/posthog.person_distinct_id_overrides"+ replica_name = "{replica}-{shard}"+ version_column = "version"+ }+ }++ table "person_overrides" {+ order_by = ["team_id", "old_person_id"]+ partition_by = "toYYYYMM(oldest_event)"+ settings = {+ index_granularity = "8192"+ }+ column "team_id" {+ type = "Int32"+ }+ column "old_person_id" {+ type = "UUID"+ }+ column "override_person_id" {+ type = "UUID"+ }+ column "merged_at" {+ type = "DateTime64(6, 'UTC')"+ }+ column "oldest_event" {+ type = "DateTime64(6, 'UTC')"+ }+ column "created_at" {+ type = "DateTime64(6, 'UTC')"+ default = "now()"+ }+ column "version" {+ type = "Int32"+ }+ engine "replicated_replacing_merge_tree" {+ zoo_path = "/clickhouse/tables/noshard/posthog.person_overrides"+ replica_name = "{replica}-{shard}"+ version_column = "version"+ }+ }++ table "person_static_cohort" {+ order_by = ["team_id", "cohort_id", "person_id", "id"]+ settings = {+ index_granularity = "8192"+ }+ column "id" {+ type = "UUID"+ }+ column "person_id" {+ type = "UUID"+ }+ column "cohort_id" {+ type = "Int64"+ }+ column "team_id" {+ type = "Int64"+ }+ column "_timestamp" {+ type = "DateTime"+ }+ column "_offset" {+ type = "UInt64"+ }+ engine "replicated_replacing_merge_tree" {+ zoo_path = "/clickhouse/tables/noshard/posthog.person_static_cohort"+ replica_name = "{replica}-{shard}"+ version_column = "_timestamp"+ }+ }++ table "pg_embeddings" {+ order_by = ["team_id", "domain", "id"]+ settings = {+ index_granularity = "512"+ }+ column "domain" {+ type = "String"+ }+ column "team_id" {+ type = "Int64"+ }+ column "id" {+ type = "String"+ }+ column "vector" {+ type = "Array(Float32)"+ }+ column "text" {+ type = "String"+ }+ column "properties" {+ type = "String"+ codec = "ZSTD(3)"+ }+ column "timestamp" {+ type = "DateTime64(6, 'UTC')"+ default = "now('UTC')"+ }+ column "is_deleted" {+ type = "UInt8"+ }+ engine "replicated_replacing_merge_tree" {+ zoo_path = "/clickhouse/tables/noshard/posthog.pg_embeddings"+ replica_name = "{replica}-{shard}"+ version_column = "timestamp"+ is_deleted_column = "is_deleted"+ }+ }++ table "plugin_log_entries" {+ order_by = ["team_id", "plugin_id", "plugin_config_id", "timestamp"]+ partition_by = "toYYYYMMDD(timestamp)"+ ttl = "toDate(timestamp) + toIntervalWeek(1)"+ settings = {+ index_granularity = "512"+ }+ column "id" {+ type = "UUID"+ }+ column "team_id" {+ type = "Int64"+ }+ column "plugin_id" {+ type = "Int64"+ }+ column "plugin_config_id" {+ type = "Int64"+ }+ column "timestamp" {+ type = "DateTime64(6, 'UTC')"+ }+ column "source" {+ type = "String"+ }+ column "type" {+ type = "String"+ }+ column "message" {+ type = "String"+ }+ column "instance_id" {+ type = "UUID"+ }+ column "_timestamp" {+ type = "DateTime"+ }+ column "_offset" {+ type = "UInt64"+ }+ engine "replicated_replacing_merge_tree" {+ zoo_path = "/clickhouse/tables/noshard/posthog.plugin_log_entries"+ replica_name = "{replica}-{shard}"+ version_column = "_timestamp"+ }+ }++ table "preaggregation_results" {+ column "team_id" {+ type = "Int64"+ }+ column "job_id" {+ type = "UUID"+ }+ column "time_window_start" {+ type = "DateTime64(6, 'UTC')"+ }+ column "expires_at" {+ type = "DateTime64(6, 'UTC')"+ default = "now() + toIntervalDay(7)"+ }+ column "breakdown_value" {+ type = "Array(String)"+ }+ column "uniq_exact_state" {+ type = "AggregateFunction(uniqExact, UUID)"+ }+ engine "distributed" {+ cluster_name = "posthog"+ remote_database = "posthog"+ remote_table = "sharded_preaggregation_results"+ sharding_key = "sipHash64(job_id)"+ }+ }++ table "precalculated_events" {+ column "team_id" {+ type = "Int64"+ }+ column "date" {+ type = "Date"+ }+ column "distinct_id" {+ type = "String"+ }+ column "person_id" {+ type = "UUID"+ }+ column "condition" {+ type = "String"+ }+ column "uuid" {+ type = "UUID"+ }+ column "source" {+ type = "String"+ }+ column "_timestamp" {+ type = "DateTime64(6)"+ }+ column "_partition" {+ type = "UInt64"+ }+ column "_offset" {+ type = "UInt64"+ }+ engine "distributed" {+ cluster_name = "posthog"+ remote_database = "posthog"+ remote_table = "sharded_precalculated_events"+ sharding_key = "sipHash64(distinct_id)"+ }+ }++ table "precalculated_person_properties" {+ column "team_id" {+ type = "Int64"+ }+ column "distinct_id" {+ type = "String"+ }+ column "person_id" {+ type = "UUID"+ }+ column "condition" {+ type = "String"+ }+ column "matches" {+ type = "Bool"+ }+ column "source" {+ type = "String"+ }+ column "_timestamp" {+ type = "DateTime64(6)"+ }+ column "_offset" {+ type = "UInt64"+ }+ engine "distributed" {+ cluster_name = "posthog"+ remote_database = "posthog"+ remote_table = "sharded_precalculated_person_properties"+ sharding_key = "sipHash64(distinct_id)"+ }+ }++ table "property_definitions" {+ order_by = ["team_id", "type", "coalesce(event, '')", "name", "coalesce(group_type_index, 255)"]+ settings = {+ index_granularity = "8192"+ }+ column "team_id" {+ type = "UInt32"+ }+ column "project_id" {+ type = "Nullable(UInt32)"+ }+ column "name" {+ type = "String"+ }+ column "property_type" {+ type = "Nullable(String)"+ }+ column "event" {+ type = "Nullable(String)"+ }+ column "group_type_index" {+ type = "Nullable(UInt8)"+ }+ column "type" {+ type = "UInt8"+ default = "1"+ }+ column "last_seen_at" {+ type = "DateTime"+ }+ column "version" {+ type = "UInt64"+ materialized = "bitShiftLeft(toUInt64(NOT isNull(property_type)), 48) + toUInt64(toUnixTimestamp(last_seen_at))"+ }+ engine "replicated_replacing_merge_tree" {+ zoo_path = "/clickhouse/tables/noshard/posthog.property_definitions"+ replica_name = "{replica}-{shard}"+ version_column = "version"+ }+ }++ table "property_values" {+ order_by = ["team_id", "property_type", "property_key", "property_value"]+ ttl = "last_seen + toIntervalDay(30)"+ settings = {+ index_granularity = "8192"+ }+ column "team_id" {+ type = "Int64"+ codec = "DoubleDelta, ZSTD(1)"+ }+ column "property_type" {+ type = "LowCardinality(String)"+ }+ column "property_key" {+ type = "LowCardinality(String)"+ }+ column "property_value" {+ type = "String"+ }+ column "property_count" {+ type = "SimpleAggregateFunction(sum, UInt64)"+ }+ column "last_seen" {+ type = "SimpleAggregateFunction(max, DateTime)"+ default = "now()"+ }+ index "idx_property_value_ngrambf" {+ expr = "lower(property_value)"+ type = "ngrambf_v1(3, 32768, 3, 0)"+ granularity = 1+ }+ engine "replicated_aggregating_merge_tree" {+ zoo_path = "/clickhouse/tables/noshard/posthog.property_values"+ replica_name = "{replica}-{shard}"+ }+ }++ table "property_values_distributed" {+ column "team_id" {+ type = "Int64"+ codec = "DoubleDelta, ZSTD(1)"+ }+ column "property_type" {+ type = "LowCardinality(String)"+ }+ column "property_key" {+ type = "LowCardinality(String)"+ }+ column "property_value" {+ type = "String"+ }+ column "property_count" {+ type = "SimpleAggregateFunction(sum, UInt64)"+ }+ column "last_seen" {+ type = "SimpleAggregateFunction(max, DateTime)"+ default = "now()"+ }+ engine "distributed" {+ cluster_name = "aux"+ remote_database = "posthog"+ remote_table = "property_values"+ }+ }++ table "query_log_archive" {+ column "hostname" {+ type = "LowCardinality(String)"+ }+ column "user" {+ type = "LowCardinality(String)"+ }+ column "query_id" {+ type = "String"+ }+ column "initial_query_id" {+ type = "String"+ }+ column "is_initial_query" {+ type = "UInt8"+ }+ column "type" {+ type = "Enum8('QueryStart'=1, 'QueryFinish'=2, 'ExceptionBeforeStart'=3, 'ExceptionWhileProcessing'=4)"+ }+ column "event_date" {+ type = "Date"+ }+ column "event_time" {+ type = "DateTime"+ }+ column "event_time_microseconds" {+ type = "DateTime64(6)"+ }+ column "query_start_time" {+ type = "DateTime"+ }+ column "query_start_time_microseconds" {+ type = "DateTime64(6)"+ }+ column "query_duration_ms" {+ type = "UInt64"+ }+ column "read_rows" {+ type = "UInt64"+ }+ column "read_bytes" {+ type = "UInt64"+ }+ column "written_rows" {+ type = "UInt64"+ }+ column "written_bytes" {+ type = "UInt64"+ }+ column "result_rows" {+ type = "UInt64"+ }+ column "result_bytes" {+ type = "UInt64"+ }+ column "memory_usage" {+ type = "UInt64"+ }+ column "peak_threads_usage" {+ type = "UInt64"+ }+ column "current_database" {+ type = "LowCardinality(String)"+ }+ column "query" {+ type = "String"+ }+ column "formatted_query" {+ type = "String"+ }+ column "normalized_query_hash" {+ type = "UInt64"+ }+ column "query_kind" {+ type = "LowCardinality(String)"+ }+ column "exception_code" {+ type = "Int32"+ }+ column "exception" {+ type = "String"+ }+ column "stack_trace" {+ type = "String"+ }+ column "team_id" {+ type = "Int64"+ }+ column "log_comment" {+ type = "JSON(max_dynamic_paths=256, access_method LowCardinality(String), alert_config_id String, api_key_label String, api_key_mask String, batch_export_id String, chargeable Bool, client_query_id String, cohort_id Int64, `dagster.job_name` String, `dagster.run_id` String, `dagster.tags.owner` String, dashboard_id Int64, experiment_feature_flag_key String, experiment_id Int64, feature LowCardinality(String), id String, insight_id Int64, is_impersonated Bool, kind LowCardinality(String), name String, org_id String, person_on_events_mode LowCardinality(String), product LowCardinality(String), query_type LowCardinality(String), request_name String, route_id String, service_name String, session_id String, table_id String, team_id Int64, `temporal.activity_id` String, `temporal.activity_type` String, `temporal.attempt` Int64, `temporal.workflow_id` String, `temporal.workflow_namespace` String, `temporal.workflow_run_id` String, `temporal.workflow_type` String, user_id Int64, warehouse_query Bool, workflow LowCardinality(String), workload LowCardinality(String), SKIP cache_key, SKIP filter, SKIP hogql_features, SKIP http_referer, SKIP http_request_id, SKIP http_user_agent, SKIP query_settings, SKIP timings, SKIP user_email)"+ }+ column "ProfileEvents" {+ type = "Map(String, UInt64)"+ }+ column "exception_name" {+ type = "String"+ alias = "errorCodeToName(exception_code)"+ }+ column "ProfileEvents_RealTimeMicroseconds" {+ type = "Int64"+ alias = "ProfileEvents['RealTimeMicroseconds']"+ }+ column "ProfileEvents_OSCPUVirtualTimeMicroseconds" {+ type = "Int64"+ alias = "ProfileEvents['OSCPUVirtualTimeMicroseconds']"+ }+ column "ProfileEvents_S3Clients" {+ type = "Int64"+ alias = "ProfileEvents['S3Clients']"+ }+ column "ProfileEvents_S3DeleteObjects" {+ type = "Int64"+ alias = "ProfileEvents['S3DeleteObjects']"+ }+ column "ProfileEvents_S3CopyObject" {+ type = "Int64"+ alias = "ProfileEvents['S3CopyObject']"+ }+ column "ProfileEvents_S3ListObjects" {+ type = "Int64"+ alias = "ProfileEvents['S3ListObjects']"+ }+ column "ProfileEvents_S3HeadObject" {+ type = "Int64"+ alias = "ProfileEvents['S3HeadObject']"+ }+ column "ProfileEvents_S3GetObjectAttributes" {+ type = "Int64"+ alias = "ProfileEvents['S3GetObjectAttributes']"+ }+ column "ProfileEvents_S3CreateMultipartUpload" {+ type = "Int64"+ alias = "ProfileEvents['S3CreateMultipartUpload']"+ }+ column "ProfileEvents_S3UploadPartCopy" {+ type = "Int64"+ alias = "ProfileEvents['S3UploadPartCopy']"+ }+ column "ProfileEvents_S3UploadPart" {+ type = "Int64"+ alias = "ProfileEvents['S3UploadPart']"+ }+ column "ProfileEvents_S3AbortMultipartUpload" {+ type = "Int64"+ alias = "ProfileEvents['S3AbortMultipartUpload']"+ }+ column "ProfileEvents_S3CompleteMultipartUpload" {+ type = "Int64"+ alias = "ProfileEvents['S3CompleteMultipartUpload']"+ }+ column "ProfileEvents_S3PutObject" {+ type = "Int64"+ alias = "ProfileEvents['S3PutObject']"+ }+ column "ProfileEvents_S3GetObject" {+ type = "Int64"+ alias = "ProfileEvents['S3GetObject']"+ }+ column "ProfileEvents_ReadBufferFromS3Bytes" {+ type = "Int64"+ alias = "ProfileEvents['ReadBufferFromS3Bytes']"+ }+ column "ProfileEvents_WriteBufferFromS3Bytes" {+ type = "Int64"+ alias = "ProfileEvents['WriteBufferFromS3Bytes']"+ }+ column "lc_workflow" {+ type = "LowCardinality(String)"+ alias = "log_comment.workflow"+ }+ column "lc_kind" {+ type = "LowCardinality(String)"+ alias = "log_comment.kind"+ }+ column "lc_id" {+ type = "String"+ alias = "CAST(log_comment.id, 'String')"+ }+ column "lc_route_id" {+ type = "String"+ alias = "CAST(log_comment.route_id, 'String')"+ }+ column "lc_access_method" {+ type = "LowCardinality(String)"+ alias = "log_comment.access_method"+ }+ column "lc_api_key_label" {+ type = "String"+ alias = "CAST(log_comment.api_key_label, 'String')"+ }+ column "lc_api_key_mask" {+ type = "String"+ alias = "CAST(log_comment.api_key_mask, 'String')"+ }+ column "lc_query_type" {+ type = "LowCardinality(String)"+ alias = "log_comment.query_type"+ }+ column "lc_product" {+ type = "LowCardinality(String)"+ alias = "log_comment.product"+ }+ column "lc_chargeable" {+ type = "Bool"+ alias = "log_comment.chargeable"+ }+ column "lc_name" {+ type = "String"+ alias = "CAST(log_comment.name, 'String')"+ }+ column "lc_request_name" {+ type = "String"+ alias = "CAST(log_comment.request_name, 'String')"+ }+ column "lc_client_query_id" {+ type = "String"+ alias = "CAST(log_comment.client_query_id, 'String')"+ }+ column "lc_org_id" {+ type = "String"+ alias = "CAST(log_comment.org_id, 'String')"+ }+ column "lc_user_id" {+ type = "Int64"+ alias = "log_comment.user_id"+ }+ column "lc_is_impersonated" {+ type = "Bool"+ alias = "log_comment.is_impersonated"+ }+ column "lc_session_id" {+ type = "String"+ alias = "CAST(log_comment.session_id, 'String')"+ }+ column "lc_dashboard_id" {+ type = "Int64"+ alias = "log_comment.dashboard_id"+ }+ column "lc_insight_id" {+ type = "Int64"+ alias = "log_comment.insight_id"+ }+ column "lc_cohort_id" {+ type = "Int64"+ alias = "log_comment.cohort_id"+ }+ column "lc_batch_export_id" {+ type = "String"+ alias = "CAST(log_comment.batch_export_id, 'String')"+ }+ column "lc_experiment_id" {+ type = "Int64"+ alias = "log_comment.experiment_id"+ }+ column "lc_experiment_feature_flag_key" {+ type = "String"+ alias = "CAST(log_comment.experiment_feature_flag_key, 'String')"+ }+ column "lc_alert_config_id" {+ type = "String"+ alias = "CAST(log_comment.alert_config_id, 'String')"+ }+ column "lc_feature" {+ type = "LowCardinality(String)"+ alias = "log_comment.feature"+ }+ column "lc_table_id" {+ type = "String"+ alias = "CAST(log_comment.table_id, 'String')"+ }+ column "lc_warehouse_query" {+ type = "Bool"+ alias = "log_comment.warehouse_query"+ }+ column "lc_person_on_events_mode" {+ type = "LowCardinality(String)"+ alias = "log_comment.person_on_events_mode"+ }+ column "lc_service_name" {+ type = "String"+ alias = "CAST(log_comment.service_name, 'String')"+ }+ column "lc_workload" {+ type = "LowCardinality(String)"+ alias = "log_comment.workload"+ }+ column "lc_query__kind" {+ type = "LowCardinality(String)"+ alias = "if(JSONHas(toString(log_comment), 'query', 'source'), JSONExtractString(toString(log_comment), 'query', 'source', 'kind'), JSONExtractString(toString(log_comment), 'query', 'kind'))"+ }+ column "lc_query__query" {+ type = "String"+ alias = "multiIf(NOT is_initial_query, '', JSONHas(toString(log_comment), 'query', 'source'), JSONExtractString(toString(log_comment), 'query', 'source', 'query'), JSONExtractString(toString(log_comment), 'query', 'query'))"+ }+ column "lc_query" {+ type = "String"+ alias = "if(is_initial_query, JSONExtractRaw(toString(log_comment), 'query'), '')"+ }+ column "lc_temporal__workflow_namespace" {+ type = "String"+ alias = "CAST(log_comment.`temporal.workflow_namespace`, 'String')"+ }+ column "lc_temporal__workflow_type" {+ type = "String"+ alias = "CAST(log_comment.`temporal.workflow_type`, 'String')"+ }+ column "lc_temporal__workflow_id" {+ type = "String"+ alias = "CAST(log_comment.`temporal.workflow_id`, 'String')"+ }+ column "lc_temporal__workflow_run_id" {+ type = "String"+ alias = "CAST(log_comment.`temporal.workflow_run_id`, 'String')"+ }+ column "lc_temporal__activity_type" {+ type = "String"+ alias = "CAST(log_comment.`temporal.activity_type`, 'String')"+ }+ column "lc_temporal__activity_id" {+ type = "String"+ alias = "CAST(log_comment.`temporal.activity_id`, 'String')"+ }+ column "lc_temporal__attempt" {+ type = "Int64"+ alias = "log_comment.`temporal.attempt`"+ }+ column "lc_dagster__job_name" {+ type = "String"+ alias = "CAST(log_comment.`dagster.job_name`, 'String')"+ }+ column "lc_dagster__run_id" {+ type = "String"+ alias = "CAST(log_comment.`dagster.run_id`, 'String')"+ }+ column "lc_dagster__owner" {+ type = "String"+ alias = "CAST(log_comment.`dagster.tags.owner`, 'String')"+ }+ column "lc_modifiers" {+ type = "String"+ alias = "if(is_initial_query, JSONExtractRaw(toString(log_comment), 'modifiers'), '')"+ }+ engine "distributed" {+ cluster_name = "ops"+ remote_database = "posthog"+ remote_table = "sharded_query_log_archive"+ }+ }++ table "query_log_archive_buffer" {+ column "hostname" {+ type = "LowCardinality(String)"+ }+ column "user" {+ type = "LowCardinality(String)"+ }+ column "query_id" {+ type = "String"+ }+ column "initial_query_id" {+ type = "String"+ }+ column "is_initial_query" {+ type = "UInt8"+ }+ column "type" {+ type = "Enum8('QueryStart'=1, 'QueryFinish'=2, 'ExceptionBeforeStart'=3, 'ExceptionWhileProcessing'=4)"+ }+ column "event_date" {+ type = "Date"+ }+ column "event_time" {+ type = "DateTime"+ }+ column "event_time_microseconds" {+ type = "DateTime64(6)"+ }+ column "query_start_time" {+ type = "DateTime"+ }+ column "query_start_time_microseconds" {+ type = "DateTime64(6)"+ }+ column "query_duration_ms" {+ type = "UInt64"+ }+ column "read_rows" {+ type = "UInt64"+ }+ column "read_bytes" {+ type = "UInt64"+ }+ column "written_rows" {+ type = "UInt64"+ }+ column "written_bytes" {+ type = "UInt64"+ }+ column "result_rows" {+ type = "UInt64"+ }+ column "result_bytes" {+ type = "UInt64"+ }+ column "memory_usage" {+ type = "UInt64"+ }+ column "peak_threads_usage" {+ type = "UInt64"+ }+ column "current_database" {+ type = "LowCardinality(String)"+ }+ column "query" {+ type = "String"+ }+ column "formatted_query" {+ type = "String"+ }+ column "normalized_query_hash" {+ type = "UInt64"+ }+ column "query_kind" {+ type = "LowCardinality(String)"+ }+ column "exception_code" {+ type = "Int32"+ }+ column "exception" {+ type = "String"+ }+ column "stack_trace" {+ type = "String"+ }+ column "team_id" {+ type = "Int64"+ }+ column "log_comment" {+ type = "JSON(max_dynamic_paths=256, access_method LowCardinality(String), alert_config_id String, api_key_label String, api_key_mask String, batch_export_id String, chargeable Bool, client_query_id String, cohort_id Int64, `dagster.job_name` String, `dagster.run_id` String, `dagster.tags.owner` String, dashboard_id Int64, experiment_feature_flag_key String, experiment_id Int64, feature LowCardinality(String), id String, insight_id Int64, is_impersonated Bool, kind LowCardinality(String), name String, org_id String, person_on_events_mode LowCardinality(String), product LowCardinality(String), query_type LowCardinality(String), request_name String, route_id String, service_name String, session_id String, table_id String, team_id Int64, `temporal.activity_id` String, `temporal.activity_type` String, `temporal.attempt` Int64, `temporal.workflow_id` String, `temporal.workflow_namespace` String, `temporal.workflow_run_id` String, `temporal.workflow_type` String, user_id Int64, warehouse_query Bool, workflow LowCardinality(String), workload LowCardinality(String), SKIP cache_key, SKIP filter, SKIP hogql_features, SKIP http_referer, SKIP http_request_id, SKIP http_user_agent, SKIP query_settings, SKIP timings, SKIP user_email)"+ }+ column "ProfileEvents" {+ type = "Map(String, UInt64)"+ }+ engine "buffer" {+ database = "posthog"+ table = "sharded_query_log_archive"+ num_layers = 16+ min_time = 10+ max_time = 60+ min_rows = 10000+ max_rows = 1000000+ min_bytes = 10000000+ max_bytes = 100000000+ }+ }++ table "query_log_archive_v2" {+ order_by = ["team_id", "event_date", "event_time", "query_id"]+ partition_by = "toYYYYMM(event_date)"+ settings = {+ index_granularity = "8192"+ }+ column "hostname" {+ type = "LowCardinality(String)"+ }+ column "user" {+ type = "LowCardinality(String)"+ }+ column "query_id" {+ type = "String"+ }+ column "initial_query_id" {+ type = "String"+ }+ column "is_initial_query" {+ type = "UInt8"+ }+ column "type" {+ type = "Enum8('QueryStart'=1, 'QueryFinish'=2, 'ExceptionBeforeStart'=3, 'ExceptionWhileProcessing'=4)"+ }+ column "event_date" {+ type = "Date"+ }+ column "event_time" {+ type = "DateTime"+ }+ column "event_time_microseconds" {+ type = "DateTime64(6)"+ }+ column "query_start_time" {+ type = "DateTime"+ }+ column "query_start_time_microseconds" {+ type = "DateTime64(6)"+ }+ column "query_duration_ms" {+ type = "UInt64"+ }+ column "read_rows" {+ type = "UInt64"+ }+ column "read_bytes" {+ type = "UInt64"+ }+ column "written_rows" {+ type = "UInt64"+ }+ column "written_bytes" {+ type = "UInt64"+ }+ column "result_rows" {+ type = "UInt64"+ }+ column "result_bytes" {+ type = "UInt64"+ }+ column "memory_usage" {+ type = "UInt64"+ }+ column "peak_threads_usage" {+ type = "UInt64"+ }+ column "current_database" {+ type = "LowCardinality(String)"+ }+ column "query" {+ type = "String"+ }+ column "formatted_query" {+ type = "String"+ }+ column "normalized_query_hash" {+ type = "UInt64"+ }+ column "query_kind" {+ type = "LowCardinality(String)"+ }+ column "exception_code" {+ type = "Int32"+ }+ column "exception_name" {+ type = "String"+ alias = "errorCodeToName(exception_code)"+ }+ column "exception" {+ type = "String"+ }+ column "stack_trace" {+ type = "String"+ }+ column "ProfileEvents_RealTimeMicroseconds" {+ type = "Int64"+ }+ column "ProfileEvents_OSCPUVirtualTimeMicroseconds" {+ type = "Int64"+ }+ column "ProfileEvents_S3Clients" {+ type = "Int64"+ }+ column "ProfileEvents_S3DeleteObjects" {+ type = "Int64"+ }+ column "ProfileEvents_S3CopyObject" {+ type = "Int64"+ }+ column "ProfileEvents_S3ListObjects" {+ type = "Int64"+ }+ column "ProfileEvents_S3HeadObject" {+ type = "Int64"+ }+ column "ProfileEvents_S3GetObjectAttributes" {+ type = "Int64"+ }+ column "ProfileEvents_S3CreateMultipartUpload" {+ type = "Int64"+ }+ column "ProfileEvents_S3UploadPartCopy" {+ type = "Int64"+ }+ column "ProfileEvents_S3UploadPart" {+ type = "Int64"+ }+ column "ProfileEvents_S3AbortMultipartUpload" {+ type = "Int64"+ }+ column "ProfileEvents_S3CompleteMultipartUpload" {+ type = "Int64"+ }+ column "ProfileEvents_S3PutObject" {+ type = "Int64"+ }+ column "ProfileEvents_S3GetObject" {+ type = "Int64"+ }+ column "ProfileEvents_ReadBufferFromS3Bytes" {+ type = "Int64"+ }+ column "ProfileEvents_WriteBufferFromS3Bytes" {+ type = "Int64"+ }+ column "ProfileEvents" {+ type = "Map(String, UInt64)"+ }+ column "lc_workflow" {+ type = "LowCardinality(String)"+ }+ column "lc_kind" {+ type = "LowCardinality(String)"+ }+ column "lc_id" {+ type = "String"+ }+ column "lc_route_id" {+ type = "String"+ }+ column "lc_access_method" {+ type = "LowCardinality(String)"+ }+ column "lc_api_key_label" {+ type = "String"+ }+ column "lc_api_key_mask" {+ type = "String"+ }+ column "lc_query_type" {+ type = "LowCardinality(String)"+ }+ column "lc_product" {+ type = "LowCardinality(String)"+ }+ column "lc_chargeable" {+ type = "Bool"+ }+ column "lc_name" {+ type = "String"+ }+ column "lc_request_name" {+ type = "String"+ }+ column "lc_client_query_id" {+ type = "String"+ }+ column "lc_org_id" {+ type = "String"+ }+ column "team_id" {+ type = "Int64"+ }+ column "lc_user_id" {+ type = "Int64"+ }+ column "lc_is_impersonated" {+ type = "Bool"+ }+ column "lc_session_id" {+ type = "String"+ }+ column "lc_dashboard_id" {+ type = "Int64"+ }+ column "lc_insight_id" {+ type = "Int64"+ }+ column "lc_cohort_id" {+ type = "Int64"+ }+ column "lc_batch_export_id" {+ type = "String"+ }+ column "lc_experiment_id" {+ type = "Int64"+ }+ column "lc_experiment_feature_flag_key" {+ type = "String"+ }+ column "lc_alert_config_id" {+ type = "String"+ }+ column "lc_feature" {+ type = "LowCardinality(String)"+ }+ column "lc_table_id" {+ type = "String"+ }+ column "lc_warehouse_query" {+ type = "Bool"+ }+ column "lc_person_on_events_mode" {+ type = "LowCardinality(String)"+ }+ column "lc_service_name" {+ type = "String"+ }+ column "lc_workload" {+ type = "LowCardinality(String)"+ }+ column "lc_query__kind" {+ type = "LowCardinality(String)"+ }+ column "lc_query__query" {+ type = "String"+ }+ column "lc_query" {+ type = "String"+ }+ column "lc_temporal__workflow_namespace" {+ type = "String"+ }+ column "lc_temporal__workflow_type" {+ type = "String"+ }+ column "lc_temporal__workflow_id" {+ type = "String"+ }+ column "lc_temporal__workflow_run_id" {+ type = "String"+ }+ column "lc_temporal__activity_type" {+ type = "String"+ }+ column "lc_temporal__activity_id" {+ type = "String"+ }+ column "lc_temporal__attempt" {+ type = "Int64"+ }+ column "lc_dagster__job_name" {+ type = "String"+ }+ column "lc_dagster__run_id" {+ type = "String"+ }+ column "lc_dagster__owner" {+ type = "String"+ }+ column "lc_modifiers" {+ type = "String"+ }+ engine "replicated_merge_tree" {+ zoo_path = "/clickhouse/tables/noshard/posthog.query_log_archive_new"+ replica_name = "{replica}-{shard}"+ }+ }++ table "raw_error_tracking_fingerprint_issue_state" {+ order_by = ["team_id", "fingerprint"]+ settings = {+ index_granularity = "512"+ }+ column "team_id" {+ type = "Int64"+ }+ column "fingerprint" {+ type = "String"+ }+ column "issue_id" {+ type = "UUID"+ }+ column "issue_name" {+ type = "Nullable(String)"+ }+ column "issue_description" {+ type = "Nullable(String)"+ }+ column "issue_status" {+ type = "String"+ }+ column "issue_severity" {+ type = "Nullable(String)"+ }+ column "assigned_user_id" {+ type = "Nullable(Int64)"+ }+ column "assigned_role_id" {+ type = "Nullable(UUID)"+ }+ column "first_seen" {+ type = "DateTime64(3, 'UTC')"+ }+ column "is_deleted" {+ type = "Int8"+ }+ column "version" {+ type = "Int64"+ }+ column "_timestamp" {+ type = "DateTime"+ }+ column "_offset" {+ type = "UInt64"+ }+ column "_partition" {+ type = "UInt64"+ }+ index "kafka_timestamp_minmax_raw_error_tracking_fingerprint_issue_state" {+ expr = "_timestamp"+ type = "minmax"+ granularity = 3+ }+ engine "replicated_replacing_merge_tree" {+ zoo_path = "/clickhouse/tables/noshard/posthog.raw_error_tracking_fingerprint_issue_state"+ replica_name = "{replica}-{shard}"+ version_column = "version"+ }+ }++ table "raw_sessions" {+ column "team_id" {+ type = "Int64"+ }+ column "session_id_v7" {+ type = "UInt128"+ }+ column "distinct_id" {+ type = "AggregateFunction(argMax, String, DateTime64(6, 'UTC'))"+ }+ column "min_timestamp" {+ type = "SimpleAggregateFunction(min, DateTime64(6, 'UTC'))"+ }+ column "max_timestamp" {+ type = "SimpleAggregateFunction(max, DateTime64(6, 'UTC'))"+ }+ column "max_inserted_at" {+ type = "SimpleAggregateFunction(max, DateTime64(6, 'UTC'))"+ }+ column "urls" {+ type = "SimpleAggregateFunction(groupUniqArrayArray, Array(String))"+ }+ column "entry_url" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "end_url" {+ type = "AggregateFunction(argMax, String, DateTime64(6, 'UTC'))"+ }+ column "last_external_click_url" {+ type = "AggregateFunction(argMax, String, DateTime64(6, 'UTC'))"+ }+ column "initial_browser" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_browser_version" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_os" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_os_version" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_device_type" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_viewport_width" {+ type = "AggregateFunction(argMin, Int64, DateTime64(6, 'UTC'))"+ }+ column "initial_viewport_height" {+ type = "AggregateFunction(argMin, Int64, DateTime64(6, 'UTC'))"+ }+ column "initial_geoip_country_code" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_geoip_subdivision_1_code" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_geoip_subdivision_1_name" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_geoip_subdivision_city_name" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_geoip_time_zone" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_referring_domain" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_utm_source" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_utm_campaign" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_utm_medium" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_utm_term" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_utm_content" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_gclid" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_gad_source" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_gclsrc" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_dclid" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_gbraid" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_wbraid" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_fbclid" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_msclkid" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_twclid" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_li_fat_id" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_mc_cid" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_igshid" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_ttclid" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_epik" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_qclid" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_sccid" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial__kx" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_irclid" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "pageview_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "pageview_uniq" {+ type = "AggregateFunction(uniq, Nullable(UUID))"+ }+ column "autocapture_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "autocapture_uniq" {+ type = "AggregateFunction(uniq, Nullable(UUID))"+ }+ column "screen_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "screen_uniq" {+ type = "AggregateFunction(uniq, Nullable(UUID))"+ }+ column "maybe_has_session_replay" {+ type = "SimpleAggregateFunction(max, Bool)"+ }+ column "page_screen_autocapture_uniq_up_to" {+ type = "AggregateFunction(uniqUpTo(1), Nullable(UUID))"+ }+ column "vitals_lcp" {+ type = "AggregateFunction(argMin, Nullable(Float64), DateTime64(6, 'UTC'))"+ }+ engine "distributed" {+ cluster_name = "posthog"+ remote_database = "posthog"+ remote_table = "sharded_raw_sessions"+ sharding_key = "cityHash64(session_id_v7)"+ }+ }++ table "raw_sessions_v3" {+ column "team_id" {+ type = "Int64"+ }+ column "session_id_v7" {+ type = "UInt128"+ }+ column "session_timestamp" {+ type = "DateTime64(3)"+ materialized = "fromUnixTimestamp64Milli(toUInt64(bitShiftRight(session_id_v7, 80)))"+ }+ column "distinct_id" {+ type = "AggregateFunction(argMax, String, DateTime64(6, 'UTC'))"+ }+ column "distinct_ids" {+ type = "AggregateFunction(groupUniqArray, String)"+ }+ column "min_timestamp" {+ type = "SimpleAggregateFunction(min, DateTime64(6, 'UTC'))"+ }+ column "max_timestamp" {+ type = "SimpleAggregateFunction(max, DateTime64(6, 'UTC'))"+ }+ column "max_inserted_at" {+ type = "SimpleAggregateFunction(max, DateTime64(6, 'UTC'))"+ }+ column "urls" {+ type = "SimpleAggregateFunction(groupUniqArrayArray(2000), Array(String))"+ }+ column "entry_url" {+ type = "AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC'))"+ }+ column "end_url" {+ type = "AggregateFunction(argMax, Nullable(String), DateTime64(6, 'UTC'))"+ }+ column "last_external_click_url" {+ type = "AggregateFunction(argMax, Nullable(String), DateTime64(6, 'UTC'))"+ }+ column "browser" {+ type = "AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC'))"+ }+ column "browser_version" {+ type = "AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC'))"+ }+ column "os" {+ type = "AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC'))"+ }+ column "os_version" {+ type = "AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC'))"+ }+ column "device_type" {+ type = "AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC'))"+ }+ column "viewport_width" {+ type = "AggregateFunction(argMin, Nullable(Int64), DateTime64(6, 'UTC'))"+ }+ column "viewport_height" {+ type = "AggregateFunction(argMin, Nullable(Int64), DateTime64(6, 'UTC'))"+ }+ column "geoip_country_code" {+ type = "AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC'))"+ }+ column "geoip_subdivision_1_code" {+ type = "AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC'))"+ }+ column "geoip_subdivision_1_name" {+ type = "AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC'))"+ }+ column "geoip_subdivision_city_name" {+ type = "AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC'))"+ }+ column "geoip_time_zone" {+ type = "AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC'))"+ }+ column "entry_referring_domain" {+ type = "AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC'))"+ }+ column "entry_utm_source" {+ type = "AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC'))"+ }+ column "entry_utm_campaign" {+ type = "AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC'))"+ }+ column "entry_utm_medium" {+ type = "AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC'))"+ }+ column "entry_utm_term" {+ type = "AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC'))"+ }+ column "entry_utm_content" {+ type = "AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC'))"+ }+ column "entry_gclid" {+ type = "AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC'))"+ }+ column "entry_gad_source" {+ type = "AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC'))"+ }+ column "entry_fbclid" {+ type = "AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC'))"+ }+ column "entry_has_gclid" {+ type = "AggregateFunction(argMin, Bool, DateTime64(6, 'UTC'))"+ }+ column "entry_has_fbclid" {+ type = "AggregateFunction(argMin, Bool, DateTime64(6, 'UTC'))"+ }+ column "entry_ad_ids_map" {+ type = "AggregateFunction(argMin, Map(String, String), DateTime64(6, 'UTC'))"+ }+ column "entry_ad_ids_set" {+ type = "AggregateFunction(argMin, Array(String), DateTime64(6, 'UTC'))"+ }+ column "entry_channel_type_properties" {+ type = "AggregateFunction(argMin, Tuple(Nullable(String), Nullable(String), Nullable(String), Nullable(String), Bool, Bool, Nullable(String)), DateTime64(6, 'UTC'))"+ }+ column "pageview_uniq" {+ type = "AggregateFunction(uniqExact, Nullable(UUID))"+ }+ column "autocapture_uniq" {+ type = "AggregateFunction(uniqExact, Nullable(UUID))"+ }+ column "screen_uniq" {+ type = "AggregateFunction(uniqExact, Nullable(UUID))"+ }+ column "page_screen_uniq_up_to" {+ type = "AggregateFunction(uniqUpTo(1), Nullable(UUID))"+ }+ column "has_autocapture" {+ type = "SimpleAggregateFunction(max, Bool)"+ }+ column "flag_values" {+ type = "AggregateFunction(groupUniqArrayMap, Map(String, String))"+ }+ column "flag_keys" {+ type = "SimpleAggregateFunction(groupUniqArrayArray, Array(String))"+ }+ column "event_names" {+ type = "SimpleAggregateFunction(groupUniqArrayArray(2000), Array(String))"+ }+ column "hosts" {+ type = "SimpleAggregateFunction(groupUniqArrayArray(100), Array(String))"+ }+ column "emails" {+ type = "SimpleAggregateFunction(groupUniqArrayArray(10), Array(String))"+ }+ column "has_replay_events" {+ type = "SimpleAggregateFunction(max, Bool)"+ }+ engine "distributed" {+ cluster_name = "posthog"+ remote_database = "posthog"+ remote_table = "sharded_raw_sessions_v3"+ sharding_key = "cityHash64(session_id_v7)"+ }+ }++ table "session_replay_embeddings" {+ column "session_id" {+ type = "String"+ }+ column "team_id" {+ type = "Int64"+ }+ column "embeddings" {+ type = "Array(Float32)"+ }+ column "generation_timestamp" {+ type = "DateTime64(6, 'UTC')"+ default = "now('UTC')"+ }+ column "source_type" {+ type = "LowCardinality(String)"+ }+ column "input" {+ type = "String"+ }+ engine "distributed" {+ cluster_name = "posthog"+ remote_database = "posthog"+ remote_table = "sharded_session_replay_embeddings"+ sharding_key = "sipHash64(session_id)"+ }+ }++ table "session_replay_events" {+ column "session_id" {+ type = "String"+ }+ column "team_id" {+ type = "Int64"+ }+ column "distinct_id" {+ type = "String"+ }+ column "min_first_timestamp" {+ type = "SimpleAggregateFunction(min, DateTime64(6, 'UTC'))"+ }+ 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)"+ }+ column "keypress_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "mouse_activity_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "active_milliseconds" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "console_log_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "console_warn_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "console_error_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "size" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "message_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "event_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "snapshot_source" {+ type = "AggregateFunction(argMin, LowCardinality(Nullable(String)), DateTime64(6, 'UTC'))"+ }+ column "snapshot_library" {+ type = "AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC'))"+ }+ column "_timestamp" {+ type = "SimpleAggregateFunction(max, DateTime)"+ }+ column "is_deleted" {+ type = "SimpleAggregateFunction(max, UInt8)"+ default = "0"+ }+ column "ai_tags_fixed" {+ type = "SimpleAggregateFunction(groupUniqArrayArray, Array(String))"+ }+ column "ai_tags_freeform" {+ type = "SimpleAggregateFunction(groupUniqArrayArray, Array(String))"+ }+ column "ai_highlighted" {+ type = "SimpleAggregateFunction(max, UInt8)"+ default = "0"+ }+ column "surfacing_score" {+ type = "SimpleAggregateFunction(max, Nullable(Float32))"+ }+ column "retention_period_days" {+ type = "SimpleAggregateFunction(max, Nullable(Int64))"+ }+ engine "distributed" {+ cluster_name = "posthog"+ remote_database = "posthog"+ remote_table = "sharded_session_replay_events"+ sharding_key = "sipHash64(distinct_id)"+ }+ }++ table "session_replay_features" {+ column "session_id" {+ type = "String"+ }+ column "team_id" {+ type = "Int64"+ }+ column "distinct_id" {+ type = "String"+ }+ column "min_first_timestamp" {+ type = "SimpleAggregateFunction(min, DateTime64(6, 'UTC'))"+ }+ column "max_last_timestamp" {+ type = "SimpleAggregateFunction(max, DateTime64(6, 'UTC'))"+ }+ column "event_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "mouse_position_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "mouse_sum_x" {+ type = "SimpleAggregateFunction(sum, Float64)"+ }+ column "mouse_sum_x_squared" {+ type = "SimpleAggregateFunction(sum, Float64)"+ }+ column "mouse_sum_y" {+ type = "SimpleAggregateFunction(sum, Float64)"+ }+ column "mouse_sum_y_squared" {+ type = "SimpleAggregateFunction(sum, Float64)"+ }+ column "mouse_distance_traveled" {+ type = "SimpleAggregateFunction(sum, Float64)"+ }+ column "mouse_direction_change_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "mouse_velocity_sum" {+ type = "SimpleAggregateFunction(sum, Float64)"+ }+ column "mouse_velocity_sum_of_squares" {+ type = "SimpleAggregateFunction(sum, Float64)"+ }+ column "mouse_velocity_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "scroll_event_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "total_scroll_magnitude" {+ type = "SimpleAggregateFunction(sum, Float64)"+ }+ column "scroll_direction_reversal_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "rapid_scroll_reversal_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "scroll_to_top_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "click_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "keypress_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "mouse_activity_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "rage_click_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "dead_click_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "backspace_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "inter_action_gap_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "inter_action_gap_sum_ms" {+ type = "SimpleAggregateFunction(sum, Float64)"+ }+ column "inter_action_gap_sum_of_squares_ms" {+ type = "SimpleAggregateFunction(sum, Float64)"+ }+ column "max_idle_gap_ms" {+ type = "SimpleAggregateFunction(max, Float64)"+ }+ column "long_idle_gap_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "quick_back_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "page_visit_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "unique_url_count" {+ type = "AggregateFunction(uniqCombined(12), String)"+ }+ column "login_path_visit_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "signup_path_visit_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "checkout_path_visit_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "cart_path_visit_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "billing_path_visit_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "settings_path_visit_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "account_path_visit_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "error_path_visit_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "not_found_path_visit_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "admin_path_visit_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "dashboard_path_visit_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "onboarding_path_visit_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "cancel_path_visit_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "refund_path_visit_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "console_error_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "console_error_after_click_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "console_warn_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "network_request_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "network_failed_request_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "network_4xx_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "network_5xx_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "network_request_duration_sum" {+ type = "SimpleAggregateFunction(sum, Float64)"+ }+ column "network_request_duration_sum_of_squares" {+ type = "SimpleAggregateFunction(sum, Float64)"+ }+ column "network_request_duration_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "mutation_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "viewport_resize_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "touch_event_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "max_scroll_y" {+ type = "SimpleAggregateFunction(max, Float64)"+ }+ column "unique_click_target_count" {+ type = "AggregateFunction(uniqCombined(12), Int64)"+ }+ column "unique_form_field_count" {+ type = "AggregateFunction(uniqCombined(12), Int64)"+ }+ column "text_selection_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "selection_copy_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "is_deleted" {+ type = "SimpleAggregateFunction(max, UInt8)"+ default = "0"+ }+ engine "distributed" {+ cluster_name = "aux"+ remote_database = "posthog"+ remote_table = "sharded_session_replay_features"+ sharding_key = "sipHash64(session_id)"+ }+ }++ table "sessions" {+ column "session_id" {+ type = "String"+ }+ column "team_id" {+ type = "Int64"+ }+ column "distinct_id" {+ type = "SimpleAggregateFunction(any, String)"+ }+ column "min_timestamp" {+ type = "SimpleAggregateFunction(min, DateTime64(6, 'UTC'))"+ }+ column "max_timestamp" {+ type = "SimpleAggregateFunction(max, DateTime64(6, 'UTC'))"+ }+ column "urls" {+ type = "SimpleAggregateFunction(groupUniqArrayArray, Array(String))"+ }+ column "entry_url" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "exit_url" {+ type = "AggregateFunction(argMax, String, DateTime64(6, 'UTC'))"+ }+ column "initial_referring_domain" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_utm_source" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_utm_campaign" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_utm_medium" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_utm_term" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_utm_content" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_gclid" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_gad_source" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_gclsrc" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_dclid" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_gbraid" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_wbraid" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_fbclid" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_msclkid" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_twclid" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_li_fat_id" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_mc_cid" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_igshid" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_ttclid" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_epik" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_qclid" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_sccid" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "event_count_map" {+ type = "SimpleAggregateFunction(sumMap, Map(String, Int64))"+ }+ column "pageview_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "autocapture_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ engine "distributed" {+ cluster_name = "posthog"+ remote_database = "posthog"+ remote_table = "sharded_sessions"+ sharding_key = "sipHash64(session_id)"+ }+ }++ table "sharded_ai_events" {+ order_by = ["team_id", "trace_id", "timestamp"]+ partition_by = "toYYYYMM(drop_date)"+ ttl = "drop_date"+ settings = {+ index_granularity = "8192"+ ttl_only_drop_parts = "1"+ }+ column "uuid" {+ type = "UUID"+ }+ column "event" {+ type = "LowCardinality(String)"+ }+ column "timestamp" {+ type = "DateTime64(6, 'UTC')"+ }+ column "team_id" {+ type = "Int64"+ }+ column "distinct_id" {+ type = "String"+ }+ column "person_id" {+ type = "UUID"+ }+ column "properties" {+ type = "String"+ }+ column "retention_days" {+ type = "Int16"+ default = "30"+ }+ column "drop_date" {+ type = "Date"+ materialized = "toDate(timestamp) + toIntervalDay(retention_days)"+ }+ column "trace_id" {+ type = "String"+ }+ column "session_id" {+ type = "Nullable(String)"+ }+ column "parent_id" {+ type = "Nullable(String)"+ }+ column "span_id" {+ type = "Nullable(String)"+ }+ column "span_type" {+ type = "LowCardinality(Nullable(String))"+ }+ column "generation_id" {+ type = "Nullable(String)"+ }+ column "experiment_id" {+ type = "Nullable(String)"+ }+ column "span_name" {+ type = "Nullable(String)"+ }+ column "trace_name" {+ type = "Nullable(String)"+ }+ column "prompt_name" {+ type = "Nullable(String)"+ }+ column "model" {+ type = "LowCardinality(Nullable(String))"+ }+ column "provider" {+ type = "LowCardinality(Nullable(String))"+ }+ column "framework" {+ type = "LowCardinality(Nullable(String))"+ }+ column "total_tokens" {+ type = "Nullable(Int64)"+ }+ column "input_tokens" {+ type = "Nullable(Int64)"+ }+ column "output_tokens" {+ type = "Nullable(Int64)"+ }+ column "text_input_tokens" {+ type = "Nullable(Int64)"+ }+ column "text_output_tokens" {+ type = "Nullable(Int64)"+ }+ column "image_input_tokens" {+ type = "Nullable(Int64)"+ }+ column "image_output_tokens" {+ type = "Nullable(Int64)"+ }+ column "audio_input_tokens" {+ type = "Nullable(Int64)"+ }+ column "audio_output_tokens" {+ type = "Nullable(Int64)"+ }+ column "video_input_tokens" {+ type = "Nullable(Int64)"+ }+ column "video_output_tokens" {+ type = "Nullable(Int64)"+ }+ column "reasoning_tokens" {+ type = "Nullable(Int64)"+ }+ column "cache_read_input_tokens" {+ type = "Nullable(Int64)"+ }+ column "cache_creation_input_tokens" {+ type = "Nullable(Int64)"+ }+ column "web_search_count" {+ type = "Nullable(Int64)"+ }+ column "input_cost_usd" {+ type = "Nullable(Float64)"+ }+ column "output_cost_usd" {+ type = "Nullable(Float64)"+ }+ column "total_cost_usd" {+ type = "Nullable(Float64)"+ }+ column "request_cost_usd" {+ type = "Nullable(Float64)"+ }+ column "web_search_cost_usd" {+ type = "Nullable(Float64)"+ }+ column "audio_cost_usd" {+ type = "Nullable(Float64)"+ }+ column "image_cost_usd" {+ type = "Nullable(Float64)"+ }+ column "video_cost_usd" {+ type = "Nullable(Float64)"+ }+ column "latency" {+ type = "Nullable(Float64)"+ }+ column "time_to_first_token" {+ type = "Nullable(Float64)"+ }+ column "is_error" {+ type = "UInt8"+ }+ column "error" {+ type = "Nullable(String)"+ }+ column "error_type" {+ type = "LowCardinality(Nullable(String))"+ }+ column "error_normalized" {+ type = "Nullable(String)"+ }+ column "input" {+ type = "Nullable(String)"+ }+ column "output" {+ type = "Nullable(String)"+ }+ column "output_choices" {+ type = "Nullable(String)"+ }+ column "input_state" {+ type = "Nullable(String)"+ }+ column "output_state" {+ type = "Nullable(String)"+ }+ column "tools" {+ type = "Nullable(String)"+ }+ column "_timestamp" {+ type = "DateTime"+ }+ column "_offset" {+ type = "UInt64"+ }+ column "_partition" {+ type = "UInt64"+ }+ index "idx_trace_id" {+ expr = "trace_id"+ type = "bloom_filter(0.001)"+ granularity = 1+ }+ index "idx_session_id" {+ expr = "session_id"+ type = "bloom_filter(0.01)"+ granularity = 1+ }+ index "idx_parent_id" {+ expr = "parent_id"+ type = "bloom_filter(0.01)"+ granularity = 1+ }+ index "idx_span_id" {+ expr = "span_id"+ type = "bloom_filter(0.01)"+ granularity = 1+ }+ index "idx_prompt_name" {+ expr = "prompt_name"+ type = "bloom_filter(0.01)"+ granularity = 1+ }+ index "idx_model" {+ expr = "model"+ type = "bloom_filter(0.01)"+ granularity = 1+ }+ index "idx_experiment_id" {+ expr = "experiment_id"+ type = "bloom_filter(0.01)"+ granularity = 1+ }+ index "idx_event" {+ expr = "event"+ type = "set(20)"+ granularity = 1+ }+ index "idx_is_error" {+ expr = "is_error"+ type = "set(2)"+ granularity = 1+ }+ index "idx_provider" {+ expr = "provider"+ type = "set(50)"+ granularity = 1+ }+ engine "replicated_merge_tree" {+ zoo_path = "/clickhouse/tables/{shard}/posthog.ai_events"+ replica_name = "{replica}"+ }+ }++ table "sharded_app_metrics" {+ order_by = ["team_id", "plugin_config_id", "job_id", "category", "toStartOfHour(timestamp)", "error_type", "error_uuid"]+ partition_by = "toYYYYMM(timestamp)"+ settings = {+ index_granularity = "8192"+ }+ column "team_id" {+ type = "Int64"+ }+ column "timestamp" {+ type = "DateTime64(6, 'UTC')"+ }+ column "plugin_config_id" {+ type = "Int64"+ }+ column "category" {+ type = "LowCardinality(String)"+ }+ column "job_id" {+ type = "String"+ }+ column "successes" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "successes_on_retry" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "failures" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "error_uuid" {+ type = "UUID"+ }+ column "error_type" {+ type = "String"+ }+ column "error_details" {+ type = "String"+ codec = "ZSTD(3)"+ }+ column "_timestamp" {+ type = "DateTime"+ }+ column "_offset" {+ type = "UInt64"+ }+ column "_partition" {+ type = "UInt64"+ }+ engine "replicated_aggregating_merge_tree" {+ zoo_path = "/clickhouse/tables/{shard}/posthog.sharded_app_metrics"+ replica_name = "{replica}"+ }+ }++ table "sharded_app_metrics2" {+ order_by = ["team_id", "app_source", "app_source_id", "instance_id", "toStartOfHour(timestamp)", "metric_kind", "metric_name"]+ partition_by = "toYYYYMM(timestamp)"+ ttl = "toDate(timestamp) + toIntervalDay(90)"+ settings = {+ index_granularity = "8192"+ }+ column "team_id" {+ type = "Int64"+ }+ column "timestamp" {+ type = "DateTime64(6, 'UTC')"+ }+ column "app_source" {+ type = "LowCardinality(String)"+ }+ column "app_source_id" {+ type = "String"+ }+ column "instance_id" {+ type = "String"+ }+ column "metric_kind" {+ type = "LowCardinality(String)"+ }+ column "metric_name" {+ type = "LowCardinality(String)"+ }+ column "count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "_timestamp" {+ type = "DateTime"+ }+ column "_offset" {+ type = "UInt64"+ }+ column "_partition" {+ type = "UInt64"+ }+ engine "replicated_aggregating_merge_tree" {+ zoo_path = "/clickhouse/tables/{shard}/posthog.sharded_app_metrics2"+ replica_name = "{replica}"+ }+ }++ table "sharded_conversion_goal_attributed_preaggregated" {+ order_by = ["team_id", "job_id", "person_id", "conversion_timestamp", "touchpoint_timestamp"]+ partition_by = "toYYYYMMDD(expires_at)"+ ttl = "expires_at"+ settings = {+ index_granularity = "8192"+ ttl_only_drop_parts = "1"+ }+ column "team_id" {+ type = "Int64"+ }+ column "job_id" {+ type = "UUID"+ }+ column "person_id" {+ type = "UUID"+ }+ column "conversion_timestamp" {+ type = "DateTime64(6, 'UTC')"+ }+ column "conversion_value" {+ type = "Float64"+ }+ column "touchpoint_timestamp" {+ type = "DateTime64(6, 'UTC')"+ }+ column "touchpoint_weight" {+ type = "Float64"+ }+ column "campaign_name" {+ type = "String"+ }+ column "source_name" {+ type = "String"+ }+ column "medium_name" {+ type = "String"+ }+ column "content_name" {+ type = "String"+ }+ column "term_name" {+ type = "String"+ }+ column "referring_domain_name" {+ type = "String"+ }+ column "gclid_name" {+ type = "String"+ }+ column "fbclid_name" {+ type = "String"+ }+ column "gad_source_name" {+ type = "String"+ }+ column "computed_at" {+ type = "DateTime64(6, 'UTC')"+ default = "now()"+ }+ column "expires_at" {+ type = "Date"+ default = "today() + toIntervalDay(7)"+ }+ engine "replicated_replacing_merge_tree" {+ zoo_path = "/clickhouse/tables/noshard/posthog.conversion_goal_attributed_preaggregated"+ replica_name = "{replica}-{shard}"+ version_column = "computed_at"+ }+ }++ table "sharded_distinct_id_usage" {+ order_by = ["team_id", "minute", "distinct_id"]+ partition_by = "toYYYYMMDD(minute)"+ ttl = "toDate(minute) + toIntervalDay(7)"+ settings = {+ index_granularity = "8192"+ ttl_only_drop_parts = "1"+ }+ column "team_id" {+ type = "Int64"+ }+ column "distinct_id" {+ type = "String"+ }+ column "minute" {+ type = "DateTime"+ }+ column "event_count" {+ type = "UInt64"+ }+ engine "replicated_summing_merge_tree" {+ zoo_path = "/clickhouse/tables/{shard}/posthog.distinct_id_usage"+ replica_name = "{replica}"+ sum_columns = ["event_count"]+ }+ }++ table "sharded_events" {+ order_by = ["team_id", "toDate(timestamp)", "event", "cityHash64(distinct_id)", "cityHash64(uuid)"]+ partition_by = "toYYYYMM(timestamp)"+ sample_by = "cityHash64(distinct_id)"+ settings = {+ index_granularity = "8192"+ }+ column "uuid" {+ type = "UUID"+ }+ column "event" {+ type = "String"+ }+ column "properties" {+ type = "String"+ codec = "ZSTD(3)"+ }+ column "timestamp" {+ type = "DateTime64(6, 'UTC')"+ }+ column "team_id" {+ type = "Int64"+ }+ column "distinct_id" {+ type = "String"+ }+ column "created_at" {+ type = "DateTime64(6, 'UTC')"+ }+ column "$group_0" {+ type = "String"+ materialized = "replaceRegexpAll(JSONExtractRaw(properties, '$group_0'), '^\"|\"$', '')"+ comment = "column_materializer::$group_0"+ }+ column "$group_1" {+ type = "String"+ materialized = "replaceRegexpAll(JSONExtractRaw(properties, '$group_1'), '^\"|\"$', '')"+ comment = "column_materializer::$group_1"+ }+ column "$group_2" {+ type = "String"+ materialized = "replaceRegexpAll(JSONExtractRaw(properties, '$group_2'), '^\"|\"$', '')"+ comment = "column_materializer::$group_2"+ }+ column "$group_3" {+ type = "String"+ materialized = "replaceRegexpAll(JSONExtractRaw(properties, '$group_3'), '^\"|\"$', '')"+ comment = "column_materializer::$group_3"+ }+ column "$group_4" {+ type = "String"+ materialized = "replaceRegexpAll(JSONExtractRaw(properties, '$group_4'), '^\"|\"$', '')"+ comment = "column_materializer::$group_4"+ }+ column "$window_id" {+ type = "String"+ materialized = "replaceRegexpAll(JSONExtractRaw(properties, '$window_id'), '^\"|\"$', '')"+ comment = "column_materializer::$window_id"+ }+ column "$session_id" {+ type = "String"+ materialized = "replaceRegexpAll(JSONExtractRaw(properties, '$session_id'), '^\"|\"$', '')"+ comment = "column_materializer::$session_id"+ }+ column "inserted_at" {+ type = "Nullable(DateTime64(6, 'UTC'))"+ default = "now64()"+ }+ column "person_mode" {+ type = "Enum8('full'=0, 'propertyless'=1, 'force_upgrade'=2)"+ }+ column "elements_chain_href" {+ type = "String"+ materialized = "EXTRACT(elements_chain, '(?::|\")href=\"(.*?)\"')"+ }+ column "elements_chain_texts" {+ type = "Array(String)"+ materialized = "arrayDistinct(extractAll(elements_chain, '(?::|\")text=\"(.*?)\"'))"+ }+ column "elements_chain_ids" {+ type = "Array(String)"+ materialized = "arrayDistinct(extractAll(elements_chain, '(?::|\")attr_id=\"(.*?)\"'))"+ }+ column "elements_chain_elements" {+ type = "Array(Enum8('a'=1, 'button'=2, 'form'=3, 'input'=4, 'select'=5, 'textarea'=6, 'label'=7))"+ materialized = "arrayDistinct(extractAll(elements_chain, '(?:^|;)(a|button|form|input|select|textarea|label)(?:\\\\.|$|:)'))"+ }+ column "properties_group_custom" {+ type = "Map(String, String)"+ materialized = "mapSort(mapFilter((key, _) -> ((key NOT LIKE '$%') AND (key NOT IN ('token', 'distinct_id', 'utm_source', 'utm_medium', 'utm_campaign', 'utm_content', 'utm_term', 'gclid', 'gad_source', 'gclsrc', 'dclid', 'gbraid', 'wbraid', 'fbclid', 'msclkid', 'twclid', 'li_fat_id', 'mc_cid', 'igshid', 'ttclid', 'rdt_cid', 'epik', 'qclid', 'sccid', 'irclid', '_kx'))), CAST(JSONExtractKeysAndValues(properties, 'String'), 'Map(String, String)')))"+ codec = "ZSTD(1)"+ }+ column "properties_group_feature_flags" {+ type = "Map(String, String)"+ materialized = "mapSort(mapFilter((key, _) -> (key LIKE '$feature/%'), CAST(JSONExtractKeysAndValues(properties, 'String'), 'Map(String, String)')))"+ codec = "ZSTD(1)"+ }+ column "is_deleted" {+ type = "Bool"+ }+ column "person_properties_map_custom" {+ type = "Map(String, String)"+ materialized = "mapSort(mapFilter((key, _) -> (key NOT LIKE '$%'), CAST(JSONExtractKeysAndValues(person_properties, 'String'), 'Map(String, String)')))"+ codec = "ZSTD(1)"+ }+ column "$session_id_uuid" {+ type = "Nullable(UInt128)"+ materialized = "toUInt128(JSONExtract(properties, '$session_id', 'Nullable(UUID)'))"+ }+ column "consumer_breadcrumbs" {+ type = "Array(String)"+ }+ column "properties_group_ai" {+ type = "Map(String, String)"+ materialized = "mapSort(mapFilter((key, _) -> ((key LIKE '$ai_%') AND (key NOT IN ('$ai_input', '$ai_input_state', '$ai_output', '$ai_output_choices', '$ai_output_state', '$ai_tools'))), CAST(JSONExtractKeysAndValues(properties, 'String'), 'Map(String, String)')))"+ codec = "ZSTD(1)"+ }+ column "mat_$ai_session_id" {+ type = "Nullable(String)"+ materialized = "JSONExtract(properties, '$ai_session_id', 'Nullable(String)')"+ }+ column "mat_$ai_is_error" {+ type = "Nullable(String)"+ materialized = "JSONExtract(properties, '$ai_is_error', 'Nullable(String)')"+ }+ column "dmat_string_0" {+ type = "Nullable(String)"+ }+ column "dmat_string_1" {+ type = "Nullable(String)"+ }+ column "dmat_string_2" {+ type = "Nullable(String)"+ }+ column "dmat_string_3" {+ type = "Nullable(String)"+ }+ column "dmat_string_4" {+ type = "Nullable(String)"+ }+ column "dmat_string_5" {+ type = "Nullable(String)"+ }+ column "dmat_string_6" {+ type = "Nullable(String)"+ }+ column "dmat_string_7" {+ type = "Nullable(String)"+ }+ column "dmat_string_8" {+ type = "Nullable(String)"+ }+ column "dmat_string_9" {+ type = "Nullable(String)"+ }+ column "historical_migration" {+ type = "Bool"+ }+ column "mat_$ai_prompt_name" {+ type = "Nullable(String)"+ materialized = "JSONExtract(properties, '$ai_prompt_name', 'Nullable(String)')"+ }+ column "properties_map_ephemeral" {+ type = "Map(String, String)"+ }+ column "person_properties_map_ephemeral" {+ type = "Map(String, String)"+ }+ column "mat_$ai_experiment_id" {+ type = "Nullable(String)"+ default = "JSONExtract(properties, '$ai_experiment_id', 'Nullable(String)')"+ }+ column "elements_chain" {+ type = "String"+ }+ column "person_id" {+ type = "UUID"+ }+ column "person_created_at" {+ type = "DateTime64(3)"+ }+ column "person_properties" {+ type = "String"+ codec = "ZSTD(3)"+ }+ column "group0_properties" {+ type = "String"+ codec = "ZSTD(3)"+ }+ column "group1_properties" {+ type = "String"+ codec = "ZSTD(3)"+ }+ column "group2_properties" {+ type = "String"+ codec = "ZSTD(3)"+ }+ column "group3_properties" {+ type = "String"+ codec = "ZSTD(3)"+ }+ column "group4_properties" {+ type = "String"+ codec = "ZSTD(3)"+ }+ column "group0_created_at" {+ type = "DateTime64(3)"+ }+ column "group1_created_at" {+ type = "DateTime64(3)"+ }+ column "group2_created_at" {+ type = "DateTime64(3)"+ }+ column "group3_created_at" {+ type = "DateTime64(3)"+ }+ column "group4_created_at" {+ type = "DateTime64(3)"+ }+ column "_timestamp" {+ type = "DateTime"+ }+ column "_offset" {+ type = "UInt64"+ }+ column "mat_$ai_trace_id" {+ type = "Nullable(String)"+ materialized = "JSONExtract(properties, '$ai_trace_id', 'Nullable(String)')"+ }+ index "minmax_inserted_at" {+ expr = "coalesce(inserted_at, _timestamp)"+ type = "minmax"+ granularity = 1+ }+ index "properties_group_custom_keys_bf" {+ expr = "mapKeys(properties_group_custom)"+ type = "bloom_filter"+ granularity = 1+ }+ index "properties_group_custom_values_bf" {+ expr = "mapValues(properties_group_custom)"+ type = "bloom_filter"+ granularity = 1+ }+ index "properties_group_feature_flags_keys_bf" {+ expr = "mapKeys(properties_group_feature_flags)"+ type = "bloom_filter"+ granularity = 1+ }+ index "properties_group_feature_flags_values_bf" {+ expr = "mapValues(properties_group_feature_flags)"+ type = "bloom_filter"+ granularity = 1+ }+ index "person_properties_map_custom_keys_bf" {+ expr = "mapKeys(person_properties_map_custom)"+ type = "bloom_filter"+ granularity = 1+ }+ index "person_properties_map_custom_values_bf" {+ expr = "mapValues(person_properties_map_custom)"+ type = "bloom_filter"+ granularity = 1+ }+ index "properties_group_ai_keys_bf" {+ expr = "mapKeys(properties_group_ai)"+ type = "bloom_filter"+ granularity = 1+ }+ index "properties_group_ai_values_bf" {+ expr = "mapValues(properties_group_ai)"+ type = "bloom_filter"+ granularity = 1+ }+ index "bloom_filter_$ai_trace_id" {+ expr = "`mat_$ai_trace_id`"+ type = "bloom_filter(0.001)"+ granularity = 2+ }+ index "bloom_filter_$ai_session_id" {+ expr = "`mat_$ai_session_id`"+ type = "bloom_filter"+ granularity = 1+ }+ index "minmax_$ai_session_id" {+ expr = "`mat_$ai_session_id`"+ type = "minmax"+ granularity = 1+ }+ index "set_$ai_is_error" {+ expr = "`mat_$ai_is_error`"+ type = "set(7)"+ granularity = 1+ }+ index "bloom_filter_distinct_id" {+ expr = "distinct_id"+ type = "bloom_filter"+ granularity = 1+ }+ index "minmax_sharded_events_timestamp" {+ expr = "timestamp"+ type = "minmax"+ granularity = 1+ }+ index "bloom_filter_$ai_prompt_name" {+ expr = "`mat_$ai_prompt_name`"+ type = "bloom_filter"+ granularity = 1+ }+ index "minmax_$ai_prompt_name" {+ expr = "`mat_$ai_prompt_name`"+ type = "minmax"+ granularity = 1+ }+ index "bloom_filter_$ai_experiment_id" {+ expr = "`mat_$ai_experiment_id`"+ type = "bloom_filter"+ granularity = 1+ }+ index "minmax_$ai_experiment_id" {+ expr = "`mat_$ai_experiment_id`"+ type = "minmax"+ granularity = 1+ }+ index "minmax_$session_id_uuid" {+ expr = "`$session_id_uuid`"+ type = "minmax"+ granularity = 1+ }+ index "bloom_filter_$session_id" {+ expr = "nullIf(nullIf(`$session_id`, ''), 'null')"+ type = "bloom_filter"+ granularity = 1+ }+ index "minmax_$group_0" {+ expr = "`$group_0`"+ type = "minmax"+ granularity = 1+ }+ index "minmax_$group_1" {+ expr = "`$group_1`"+ type = "minmax"+ granularity = 1+ }+ index "minmax_$group_2" {+ expr = "`$group_2`"+ type = "minmax"+ granularity = 1+ }+ index "minmax_$group_3" {+ expr = "`$group_3`"+ type = "minmax"+ granularity = 1+ }+ index "minmax_$group_4" {+ expr = "`$group_4`"+ type = "minmax"+ granularity = 1+ }+ index "minmax_$window_id" {+ expr = "`$window_id`"+ type = "minmax"+ granularity = 1+ }+ index "minmax_$session_id" {+ expr = "`$session_id`"+ type = "minmax"+ granularity = 1+ }+ index "kafka_timestamp_minmax_sharded_events" {+ expr = "_timestamp"+ type = "minmax"+ granularity = 3+ }+ index "is_deleted_idx" {+ expr = "is_deleted"+ type = "minmax"+ granularity = 1+ }+ index "minmax_historical_migration" {+ expr = "historical_migration"+ type = "minmax"+ granularity = 1+ }+ engine "replicated_replacing_merge_tree" {+ zoo_path = "/clickhouse/tables/{shard}/posthog.events"+ replica_name = "{replica}"+ version_column = "_timestamp"+ }+ }++ table "sharded_events_json" {+ primary_key = ["team_id", "toDate(timestamp)", "event", "timestamp", "cityHash64(distinct_id)"]+ order_by = ["team_id", "toDate(timestamp)", "event", "timestamp", "cityHash64(distinct_id)", "distinct_id", "uuid"]+ partition_by = "toYYYYMM(timestamp)"+ sample_by = "cityHash64(distinct_id)"+ settings = {+ index_granularity = "8192"+ merge_max_block_size = "131072"+ merge_max_block_size_bytes = "67108864"+ object_serialization_version = "v3"+ object_shared_data_serialization_version = "map_with_buckets"+ object_shared_data_serialization_version_for_zero_level_parts = "map"+ vertical_merge_algorithm_min_rows_to_activate = "0"+ }+ column "uuid" {+ type = "UUID"+ }+ column "event" {+ type = "String"+ }+ column "properties" {+ type = "JSON(max_dynamic_types=8, max_dynamic_paths=256, `$active_feature_flags` Array(String), `$ai_experiment_id` Nullable(String), `$ai_http_status` Nullable(String), `$ai_is_error` Nullable(String), `$ai_model` Nullable(String), `$ai_parent_id` Nullable(String), `$ai_prompt_name` Nullable(String), `$ai_provider` Nullable(String), `$ai_session_id` Nullable(String), `$ai_span_id` Nullable(String), `$ai_total_cost_usd` Nullable(String), `$ai_trace_id` Nullable(String), `$anon_distinct_id` Nullable(String), `$app_build` Nullable(String), `$app_namespace` Nullable(String), `$app_version` Nullable(String), `$browser` Nullable(String), `$browser_version` Nullable(String), `$current_url` Nullable(String), `$device` Nullable(String), `$device_id` Nullable(String), `$device_model` Nullable(String), `$device_type` Nullable(String), `$el_text` Nullable(String), `$event_type` Nullable(String), `$exception_fingerprint` Nullable(String), `$exception_functions` Array(String), `$exception_issue_id` Nullable(String), `$exception_sources` Array(String), `$exception_types` Array(String), `$exception_values` Array(String), `$feature_flag` Nullable(String), `$feature_flag_payloads` Nullable(String), `$feature_flag_response` Nullable(String), `$geoip_city_name` Nullable(String), `$geoip_country_code` Nullable(String), `$geoip_country_name` Nullable(String), `$geoip_subdivision_1_code` Nullable(String), `$group_0` Nullable(String), `$group_1` Nullable(String), `$group_2` Nullable(String), `$group_3` Nullable(String), `$group_4` Nullable(String), `$groups` Nullable(String), `$host` Nullable(String), `$initial_pathname` Nullable(String), `$initial_referrer` Nullable(String), `$initial_referring_domain` Nullable(String), `$ip` Nullable(String), `$is_identified` Nullable(String), `$lib` Nullable(String), `$lib_custom_api_host` Nullable(String), `$lib_version` Nullable(String), `$lib_version__minor` Nullable(String), `$os` Nullable(String), `$os_name` Nullable(String), `$os_version` Nullable(String), `$pathname` Nullable(String), `$prev_pageview_max_content_percentage` Nullable(String), `$prev_pageview_max_scroll_percentage` Nullable(String), `$prev_pageview_pathname` Nullable(String), `$process_person_profile` Nullable(String), `$referrer` Nullable(String), `$referring_domain` Nullable(String), `$screen_height` Nullable(String), `$screen_name` Nullable(String), `$screen_width` Nullable(String), `$sent_at` Nullable(String), `$session_id` Nullable(String), `$survey_id` Nullable(String), `$survey_response` Nullable(String), `$survey_response_1` Nullable(String), `$time` Nullable(String), `$user_id` Nullable(String), `$viewport_height` Nullable(String), `$viewport_width` Nullable(String), `$web_vitals_CLS_value` Nullable(String), `$web_vitals_FCP_value` Nullable(String), `$web_vitals_INP_value` Nullable(String), `$web_vitals_LCP_value` Nullable(String), `$window_id` Nullable(String))"+ }+ column "timestamp" {+ type = "DateTime64(6, 'UTC')"+ }+ column "team_id" {+ type = "Int64"+ }+ column "distinct_id" {+ type = "String"+ }+ column "elements_hash" {+ type = "String"+ default = "''"+ }+ column "created_at" {+ type = "DateTime64(6, 'UTC')"+ }+ column "_timestamp" {+ type = "DateTime"+ }+ column "_offset" {+ type = "UInt64"+ }+ column "elements_chain" {+ type = "String"+ }+ column "person_id" {+ type = "UUID"+ }+ column "person_properties" {+ type = "JSON(max_dynamic_types=6, max_dynamic_paths=32, `$app_version` Nullable(String), `$browser` Nullable(String), `$current_url` Nullable(String), `$geoip_continent_name` Nullable(String), `$geoip_country_code` Nullable(String), `$geoip_country_name` Nullable(String), `$initial_current_url` Nullable(String), `$initial_fbclid` Nullable(String), `$initial_gad_source` Nullable(String), `$initial_gbraid` Nullable(String), `$initial_gclid` Nullable(String), `$initial_msclkid` Nullable(String), `$initial_pathname` Nullable(String), `$initial_referring_domain` Nullable(String), `$initial_utm_campaign` Nullable(String), `$initial_utm_content` Nullable(String), `$initial_utm_medium` Nullable(String), `$initial_utm_source` Nullable(String), `$initial_utm_term` Nullable(String), `$initial_wbraid` Nullable(String), `$os_name` Nullable(String), `$referring_domain` Nullable(String))"+ }+ column "group0_properties" {+ type = "String"+ codec = "ZSTD(3)"+ }+ column "group1_properties" {+ type = "String"+ codec = "ZSTD(3)"+ }+ column "group2_properties" {+ type = "String"+ codec = "ZSTD(3)"+ }+ column "group3_properties" {+ type = "String"+ codec = "ZSTD(3)"+ }+ column "group4_properties" {+ type = "String"+ codec = "ZSTD(3)"+ }+ column "person_created_at" {+ type = "DateTime64(3)"+ }+ column "group0_created_at" {+ type = "DateTime64(3)"+ }+ column "group1_created_at" {+ type = "DateTime64(3)"+ }+ column "group2_created_at" {+ type = "DateTime64(3)"+ }+ column "group3_created_at" {+ type = "DateTime64(3)"+ }+ column "group4_created_at" {+ type = "DateTime64(3)"+ }+ column "inserted_at" {+ type = "Nullable(DateTime64(6, 'UTC'))"+ default = "now64()"+ }+ column "person_mode" {+ type = "Enum8('full'=0, 'propertyless'=1, 'force_upgrade'=2)"+ }+ column "is_deleted" {+ type = "Bool"+ default = "false"+ }+ column "consumer_breadcrumbs" {+ type = "Array(String)"+ }+ column "historical_migration" {+ type = "Bool"+ default = "false"+ }+ column "$group_0" {+ type = "String"+ alias = "ifNull(properties.`$group_0`, '')"+ }+ column "$group_1" {+ type = "String"+ alias = "ifNull(properties.`$group_1`, '')"+ }+ column "$group_2" {+ type = "String"+ alias = "ifNull(properties.`$group_2`, '')"+ }+ column "$group_3" {+ type = "String"+ alias = "ifNull(properties.`$group_3`, '')"+ }+ column "$group_4" {+ type = "String"+ alias = "ifNull(properties.`$group_4`, '')"+ }+ column "$window_id" {+ type = "String"+ alias = "ifNull(properties.`$window_id`, '')"+ }+ column "$session_id" {+ type = "String"+ alias = "ifNull(properties.`$session_id`, '')"+ }+ column "$session_id_uuid" {+ type = "Nullable(UInt128)"+ alias = "toUInt128(toUUIDOrNull(properties.`$session_id`))"+ }+ column "elements_chain_href" {+ type = "String"+ materialized = "EXTRACT(elements_chain, '(?::|\")href=\"(.*?)\"')"+ }+ column "elements_chain_texts" {+ type = "Array(String)"+ materialized = "arrayDistinct(extractAll(elements_chain, '(?::|\")text=\"(.*?)\"'))"+ }+ column "elements_chain_ids" {+ type = "Array(String)"+ materialized = "arrayDistinct(extractAll(elements_chain, '(?::|\")attr_id=\"(.*?)\"'))"+ }+ column "elements_chain_elements" {+ type = "Array(Enum8('a'=1, 'button'=2, 'form'=3, 'input'=4, 'select'=5, 'textarea'=6, 'label'=7))"+ materialized = "arrayDistinct(extractAll(elements_chain, '(?:^|;)(a|button|form|input|select|textarea|label)(?:\\\\.|$|:)'))"+ }+ index "kafka_timestamp_minmax_sharded_events" {+ expr = "_timestamp"+ type = "minmax"+ granularity = 3+ }+ index "minmax_$group_0" {+ expr = "properties.`$group_0`"+ type = "minmax"+ granularity = 1+ }+ index "minmax_$group_1" {+ expr = "properties.`$group_1`"+ type = "minmax"+ granularity = 1+ }+ index "minmax_$group_2" {+ expr = "properties.`$group_2`"+ type = "minmax"+ granularity = 1+ }+ index "minmax_$group_3" {+ expr = "properties.`$group_3`"+ type = "minmax"+ granularity = 1+ }+ index "minmax_$group_4" {+ expr = "properties.`$group_4`"+ type = "minmax"+ granularity = 1+ }+ index "minmax_$window_id" {+ expr = "properties.`$window_id`"+ type = "minmax"+ granularity = 1+ }+ index "minmax_$session_id" {+ expr = "properties.`$session_id`"+ type = "minmax"+ granularity = 1+ }+ index "minmax_mat_$sent_at" {+ expr = "properties.`$sent_at`"+ type = "minmax"+ granularity = 1+ }+ index "minmax_mat_$initial_pathname" {+ expr = "properties.`$initial_pathname`"+ type = "minmax"+ granularity = 1+ }+ index "minmax_mat_$lib_version" {+ expr = "properties.`$lib_version`"+ type = "minmax"+ granularity = 1+ }+ index "minmax_mat_pp_$initial_utm_campaign" {+ expr = "person_properties.`$initial_utm_campaign`"+ type = "minmax"+ granularity = 1+ }+ index "minmax_mat_pp_$initial_utm_medium" {+ expr = "person_properties.`$initial_utm_medium`"+ type = "minmax"+ granularity = 1+ }+ index "minmax_mat_pp_$initial_gclid" {+ expr = "person_properties.`$initial_gclid`"+ type = "minmax"+ granularity = 1+ }+ index "minmax_mat_pp_$initial_gad_source" {+ expr = "person_properties.`$initial_gad_source`"+ type = "minmax"+ granularity = 1+ }+ index "minmax_mat_pp_$initial_utm_source" {+ expr = "person_properties.`$initial_utm_source`"+ type = "minmax"+ granularity = 1+ }+ index "minmax_mat_pp_$initial_referring_domain" {+ expr = "person_properties.`$initial_referring_domain`"+ type = "minmax"+ granularity = 1+ }+ index "minmax_mat_pp_$initial_utm_term" {+ expr = "person_properties.`$initial_utm_term`"+ type = "minmax"+ granularity = 1+ }+ index "minmax_mat_pp_$initial_utm_content" {+ expr = "person_properties.`$initial_utm_content`"+ type = "minmax"+ granularity = 1+ }+ index "minmax_mat_pp_$initial_gbraid" {+ expr = "person_properties.`$initial_gbraid`"+ type = "minmax"+ granularity = 1+ }+ index "minmax_mat_pp_$initial_wbraid" {+ expr = "person_properties.`$initial_wbraid`"+ type = "minmax"+ granularity = 1+ }+ index "minmax_mat_pp_$initial_msclkid" {+ expr = "person_properties.`$initial_msclkid`"+ type = "minmax"+ granularity = 1+ }+ index "minmax_mat_pp_$initial_fbclid" {+ expr = "person_properties.`$initial_fbclid`"+ type = "minmax"+ granularity = 1+ }+ index "minmax_mat_$geoip_subdivision_1_code" {+ expr = "properties.`$geoip_subdivision_1_code`"+ type = "minmax"+ granularity = 1+ }+ index "minmax_mat_$prev_pageview_max_scroll_percentage" {+ expr = "properties.`$prev_pageview_max_scroll_percentage`"+ type = "minmax"+ granularity = 1+ }+ index "minmax_mat_$prev_pageview_max_content_percentage" {+ expr = "properties.`$prev_pageview_max_content_percentage`"+ type = "minmax"+ granularity = 1+ }+ index "minmax_mat_$prev_pageview_pathname" {+ expr = "properties.`$prev_pageview_pathname`"+ type = "minmax"+ granularity = 1+ }+ index "minmax_mat_pp_$initial_pathname" {+ expr = "person_properties.`$initial_pathname`"+ type = "minmax"+ granularity = 1+ }+ index "minmax_mat_pp_$geoip_country_code" {+ expr = "person_properties.`$geoip_country_code`"+ type = "minmax"+ granularity = 1+ }+ index "minmax_mat_$browser_version" {+ expr = "properties.`$browser_version`"+ type = "minmax"+ granularity = 1+ }+ index "minmax_mat_pp_$initial_current_url" {+ expr = "person_properties.`$initial_current_url`"+ type = "minmax"+ granularity = 1+ }+ index "minmax_mat_pp_$current_url" {+ expr = "person_properties.`$current_url`"+ type = "minmax"+ granularity = 1+ }+ index "minmax_mat_$app_namespace" {+ expr = "properties.`$app_namespace`"+ type = "minmax"+ granularity = 1+ }+ index "minmax_mat_$os_name" {+ expr = "properties.`$os_name`"+ type = "minmax"+ granularity = 1+ }+ index "minmax_mat_pp_$os_name" {+ expr = "person_properties.`$os_name`"+ type = "minmax"+ granularity = 1+ }+ index "minmax_mat_pp_$app_version" {+ expr = "person_properties.`$app_version`"+ type = "minmax"+ granularity = 1+ }+ index "minmax_mat_$screen_height" {+ expr = "properties.`$screen_height`"+ type = "minmax"+ granularity = 1+ }+ index "minmax_mat_$screen_width" {+ expr = "properties.`$screen_width`"+ type = "minmax"+ granularity = 1+ }+ index "minmax_mat_$app_build" {+ expr = "properties.`$app_build`"+ type = "minmax"+ granularity = 1+ }+ index "minmax_mat_$geoip_country_code" {+ expr = "properties.`$geoip_country_code`"+ type = "minmax"+ granularity = 1+ }+ index "minmax_mat_$survey_id" {+ expr = "properties.`$survey_id`"+ type = "minmax"+ granularity = 1+ }+ index "minmax_mat_$survey_response_1" {+ expr = "properties.`$survey_response_1`"+ type = "minmax"+ granularity = 1+ }+ index "minmax_mat_$survey_response" {+ expr = "properties.`$survey_response`"+ type = "minmax"+ granularity = 1+ }+ index "minmax_mat_$el_text" {+ expr = "properties.`$el_text`"+ type = "minmax"+ granularity = 1+ }+ index "minmax_mat_$os_version" {+ expr = "properties.`$os_version`"+ type = "minmax"+ granularity = 1+ }+ index "minmax_mat_$feature_flag_payloads" {+ expr = "properties.`$feature_flag_payloads`"+ type = "minmax"+ granularity = 1+ }+ index "minmax_mat_$groups" {+ expr = "properties.`$groups`"+ type = "minmax"+ granularity = 1+ }+ index "minmax_mat_$feature_flag" {+ expr = "properties.`$feature_flag`"+ type = "minmax"+ granularity = 1+ }+ index "bf_active_feature_flags" {+ expr = "properties.`$active_feature_flags`"+ type = "bloom_filter(0.01)"+ granularity = 1+ }+ index "minmax_mat_$device_id" {+ expr = "properties.`$device_id`"+ type = "minmax"+ granularity = 1+ }+ index "minmax_mat_pp_$geoip_continent_name" {+ expr = "person_properties.`$geoip_continent_name`"+ type = "minmax"+ granularity = 1+ }+ index "minmax_mat_$feature_flag_response" {+ expr = "properties.`$feature_flag_response`"+ type = "minmax"+ granularity = 1+ }+ index "minmax_mat_pp_$referring_domain" {+ expr = "person_properties.`$referring_domain`"+ type = "minmax"+ granularity = 1+ }+ index "minmax_mat_$lib_version__minor" {+ expr = "properties.`$lib_version__minor`"+ type = "minmax"+ granularity = 1+ }+ index "minmax_inserted_at" {+ expr = "coalesce(inserted_at, _timestamp)"+ type = "minmax"+ granularity = 1+ }+ index "minmax_mat_$lib_custom_api_host" {+ expr = "properties.`$lib_custom_api_host`"+ type = "minmax"+ granularity = 1+ }+ index "minmax_mat_pp_$geoip_country_name" {+ expr = "person_properties.`$geoip_country_name`"+ type = "minmax"+ granularity = 1+ }+ index "is_deleted_idx" {+ expr = "is_deleted"+ type = "minmax"+ granularity = 1+ }+ index "minmax_mat_$device" {+ expr = "properties.`$device`"+ type = "minmax"+ granularity = 1+ }+ index "minmax_mat_$exception_issue_id" {+ expr = "properties.`$exception_issue_id`"+ type = "minmax"+ granularity = 1+ }+ index "minmax_mat_$exception_fingerprint" {+ expr = "properties.`$exception_fingerprint`"+ type = "minmax"+ granularity = 1+ }+ index "minmax_mat_$web_vitals_LCP_value" {+ expr = "properties.`$web_vitals_LCP_value`"+ type = "minmax"+ granularity = 1+ }+ index "minmax_mat_$web_vitals_FCP_value" {+ expr = "properties.`$web_vitals_FCP_value`"+ type = "minmax"+ granularity = 1+ }+ index "minmax_mat_$web_vitals_CLS_value" {+ expr = "properties.`$web_vitals_CLS_value`"+ type = "minmax"+ granularity = 1+ }+ index "minmax_mat_$web_vitals_INP_value" {+ expr = "properties.`$web_vitals_INP_value`"+ type = "minmax"+ granularity = 1+ }+ index "minmax_mat_$viewport_width" {+ expr = "properties.`$viewport_width`"+ type = "minmax"+ granularity = 1+ }+ index "minmax_mat_$viewport_height" {+ expr = "properties.`$viewport_height`"+ type = "minmax"+ granularity = 1+ }+ index "minmax_mat_$anon_distinct_id" {+ expr = "properties.`$anon_distinct_id`"+ type = "minmax"+ granularity = 1+ }+ index "minmax_mat_$ai_trace_id" {+ expr = "properties.`$ai_trace_id`"+ type = "minmax"+ granularity = 1+ }+ index "minmax_mat_$ai_model" {+ expr = "properties.`$ai_model`"+ type = "minmax"+ granularity = 1+ }+ index "minmax_mat_$ai_provider" {+ expr = "properties.`$ai_provider`"+ type = "minmax"+ granularity = 1+ }+ index "minmax_mat_$ai_parent_id" {+ expr = "properties.`$ai_parent_id`"+ type = "minmax"+ granularity = 1+ }+ index "minmax_mat_$ai_span_id" {+ expr = "properties.`$ai_span_id`"+ type = "minmax"+ granularity = 1+ }+ index "minmax_mat_$ai_http_status" {+ expr = "properties.`$ai_http_status`"+ type = "minmax"+ granularity = 1+ }+ index "minmax_mat_$process_person_profile" {+ expr = "properties.`$process_person_profile`"+ type = "minmax"+ granularity = 1+ }+ index "minmax_mat_$app_version" {+ expr = "properties.`$app_version`"+ type = "minmax"+ granularity = 1+ }+ index "bloom_mat_$is_identified" {+ expr = "properties.`$is_identified`"+ type = "bloom_filter"+ granularity = 1+ }+ index "minmax_$session_id_uuid" {+ expr = "toUInt128(toUUIDOrNull(properties.`$session_id`))"+ type = "minmax"+ granularity = 1+ }+ index "bloom_filter_$ai_trace_id" {+ expr = "properties.`$ai_trace_id`"+ type = "bloom_filter(0.001)"+ granularity = 2+ }+ index "bloom_filter_$ai_session_id" {+ expr = "properties.`$ai_session_id`"+ type = "bloom_filter"+ granularity = 1+ }+ index "minmax_$ai_session_id" {+ expr = "properties.`$ai_session_id`"+ type = "minmax"+ granularity = 1+ }+ index "set_$ai_is_error" {+ expr = "properties.`$ai_is_error`"+ type = "set(7)"+ granularity = 1+ }+ index "minmax_mat_$ai_total_cost_usd" {+ expr = "properties.`$ai_total_cost_usd`"+ type = "minmax"+ granularity = 1+ }+ index "bloom_filter_distinct_id" {+ expr = "distinct_id"+ type = "bloom_filter"+ granularity = 1+ }+ index "minmax_sharded_events_timestamp" {+ expr = "timestamp"+ type = "minmax"+ granularity = 1+ }+ index "minmax_historical_migration" {+ expr = "historical_migration"+ type = "minmax"+ granularity = 1+ }+ index "bloom_mat_$feature_flag" {+ expr = "properties.`$feature_flag`"+ type = "bloom_filter"+ granularity = 1+ }+ index "bloom_filter_$ai_prompt_name" {+ expr = "properties.`$ai_prompt_name`"+ type = "bloom_filter"+ granularity = 1+ }+ index "minmax_$ai_prompt_name" {+ expr = "properties.`$ai_prompt_name`"+ type = "minmax"+ granularity = 1+ }+ index "bloom_filter_$ai_experiment_id" {+ expr = "properties.`$ai_experiment_id`"+ type = "bloom_filter"+ granularity = 1+ }+ index "minmax_$ai_experiment_id" {+ expr = "properties.`$ai_experiment_id`"+ type = "minmax"+ granularity = 1+ }+ engine "replicated_replacing_merge_tree" {+ zoo_path = "/clickhouse/tables/{shard}/posthog.events_json"+ replica_name = "{replica}"+ version_column = "_timestamp"+ }+ }++ table "sharded_events_recent" {+ order_by = ["team_id", "toStartOfHour(inserted_at)", "event", "cityHash64(distinct_id)", "cityHash64(uuid)"]+ partition_by = "toStartOfDay(inserted_at)"+ ttl = "toDateTime(inserted_at) + toIntervalDay(7)"+ settings = {+ index_granularity = "8192"+ ttl_only_drop_parts = "1"+ }+ column "uuid" {+ type = "UUID"+ }+ column "event" {+ type = "String"+ }+ column "properties" {+ type = "String"+ codec = "ZSTD(3)"+ }+ column "timestamp" {+ type = "DateTime64(6, 'UTC')"+ }+ column "team_id" {+ type = "Int64"+ }+ column "distinct_id" {+ type = "String"+ }+ column "elements_chain" {+ type = "String"+ }+ column "created_at" {+ type = "DateTime64(6, 'UTC')"+ }+ column "person_id" {+ type = "UUID"+ }+ column "person_created_at" {+ type = "DateTime64(3)"+ }+ column "person_properties" {+ type = "String"+ codec = "ZSTD(3)"+ }+ column "group0_properties" {+ type = "String"+ codec = "ZSTD(3)"+ }+ column "group1_properties" {+ type = "String"+ codec = "ZSTD(3)"+ }+ column "group2_properties" {+ type = "String"+ codec = "ZSTD(3)"+ }+ column "group3_properties" {+ type = "String"+ codec = "ZSTD(3)"+ }+ column "group4_properties" {+ type = "String"+ codec = "ZSTD(3)"+ }+ column "group0_created_at" {+ type = "DateTime64(3)"+ }+ column "group1_created_at" {+ type = "DateTime64(3)"+ }+ column "group2_created_at" {+ type = "DateTime64(3)"+ }+ column "group3_created_at" {+ type = "DateTime64(3)"+ }+ column "group4_created_at" {+ type = "DateTime64(3)"+ }+ column "person_mode" {+ type = "Enum8('full'=0, 'propertyless'=1, 'force_upgrade'=2)"+ }+ column "historical_migration" {+ type = "Bool"+ }+ column "_timestamp" {+ type = "DateTime"+ }+ column "_offset" {+ type = "UInt64"+ }+ column "inserted_at" {+ type = "DateTime64(6, 'UTC')"+ default = "now64()"+ }+ engine "replicated_replacing_merge_tree" {+ zoo_path = "/clickhouse/tables/{shard}/posthog.sharded_events_recent"+ replica_name = "{replica}"+ version_column = "_timestamp"+ }+ }++ table "sharded_experiment_exposures_preaggregated" {+ order_by = ["team_id", "job_id", "entity_id", "breakdown_value"]+ partition_by = "toYYYYMMDD(expires_at)"+ ttl = "expires_at"+ settings = {+ index_granularity = "8192"+ ttl_only_drop_parts = "1"+ }+ column "team_id" {+ type = "Int64"+ }+ column "job_id" {+ type = "UUID"+ }+ column "entity_id" {+ type = "String"+ }+ column "variant" {+ type = "String"+ }+ column "first_exposure_time" {+ type = "DateTime64(6, 'UTC')"+ }+ column "last_exposure_time" {+ type = "DateTime64(6, 'UTC')"+ }+ column "exposure_event_uuid" {+ type = "UUID"+ }+ column "exposure_session_id" {+ type = "String"+ }+ column "breakdown_value" {+ type = "Array(String)"+ }+ column "computed_at" {+ type = "DateTime64(6, 'UTC')"+ default = "now()"+ }+ column "expires_at" {+ type = "Date"+ default = "today() + toIntervalDay(7)"+ }+ engine "replicated_replacing_merge_tree" {+ zoo_path = "/clickhouse/tables/{shard}/posthog.experiment_exposures_preaggregated"+ replica_name = "{replica}"+ version_column = "computed_at"+ }+ }++ table "sharded_experiment_metric_events_preaggregated" {+ order_by = ["team_id", "job_id", "entity_id", "timestamp", "event_uuid"]+ partition_by = "toYYYYMMDD(expires_at)"+ ttl = "expires_at"+ settings = {+ index_granularity = "8192"+ ttl_only_drop_parts = "1"+ }+ column "team_id" {+ type = "Int64"+ }+ column "job_id" {+ type = "UUID"+ }+ column "entity_id" {+ type = "String"+ }+ column "timestamp" {+ type = "DateTime64(6, 'UTC')"+ }+ column "event_uuid" {+ type = "UUID"+ }+ column "session_id" {+ type = "String"+ }+ column "numeric_value" {+ type = "Float64"+ default = "0"+ }+ column "steps" {+ type = "Array(UInt8)"+ default = "[]"+ }+ column "computed_at" {+ type = "DateTime64(6, 'UTC')"+ default = "now()"+ }+ column "expires_at" {+ type = "Date"+ default = "today() + toIntervalDay(7)"+ }+ engine "replicated_replacing_merge_tree" {+ zoo_path = "/clickhouse/tables/noshard/posthog.experiment_metric_events_preaggregated"+ replica_name = "{replica}-{shard}"+ version_column = "computed_at"+ }+ }++ table "sharded_flag_evaluations" {+ order_by = ["team_id", "flag_key", "toDate(timestamp)", "cityHash64(distinct_id)"]+ partition_by = "toYYYYMM(timestamp)"+ ttl = "toDate(timestamp) + toIntervalDay(90)"+ settings = {+ index_granularity = "8192"+ ttl_only_drop_parts = "1"+ }+ column "uuid" {+ type = "UUID"+ }+ column "event" {+ type = "LowCardinality(String)"+ }+ column "properties" {+ type = "String"+ }+ column "timestamp" {+ type = "DateTime64(6, 'UTC')"+ }+ column "team_id" {+ type = "Int64"+ }+ column "distinct_id" {+ type = "String"+ }+ column "created_at" {+ type = "DateTime64(6, 'UTC')"+ }+ column "person_id" {+ type = "UUID"+ }+ column "person_properties" {+ type = "String"+ }+ column "group0_properties" {+ type = "String"+ }+ column "group1_properties" {+ type = "String"+ }+ column "group2_properties" {+ type = "String"+ }+ column "group3_properties" {+ type = "String"+ }+ column "group4_properties" {+ type = "String"+ }+ column "inserted_at" {+ type = "DateTime64(6, 'UTC')"+ default = "timestamp"+ }+ column "$group_0" {+ type = "String"+ materialized = "replaceRegexpAll(JSONExtractRaw(properties, '$group_0'), '^\"|\"$', '')"+ comment = "column_materializer::$group_0"+ }+ column "$group_1" {+ type = "String"+ materialized = "replaceRegexpAll(JSONExtractRaw(properties, '$group_1'), '^\"|\"$', '')"+ comment = "column_materializer::$group_1"+ }+ column "$group_2" {+ type = "String"+ materialized = "replaceRegexpAll(JSONExtractRaw(properties, '$group_2'), '^\"|\"$', '')"+ comment = "column_materializer::$group_2"+ }+ column "$group_3" {+ type = "String"+ materialized = "replaceRegexpAll(JSONExtractRaw(properties, '$group_3'), '^\"|\"$', '')"+ comment = "column_materializer::$group_3"+ }+ column "$group_4" {+ type = "String"+ materialized = "replaceRegexpAll(JSONExtractRaw(properties, '$group_4'), '^\"|\"$', '')"+ comment = "column_materializer::$group_4"+ }+ column "flag_key" {+ type = "String"+ materialized = "replaceRegexpAll(JSONExtractRaw(properties, '$feature_flag'), '^\"|\"$', '')"+ comment = "column_materializer::properties::$feature_flag"+ }+ column "response" {+ type = "LowCardinality(String)"+ materialized = "replaceRegexpAll(JSONExtractRaw(properties, '$feature_flag_response'), '^\"|\"$', '')"+ comment = "column_materializer::properties::$feature_flag_response"+ }+ column "session_id" {+ type = "String"+ materialized = "replaceRegexpAll(JSONExtractRaw(properties, '$session_id'), '^\"|\"$', '')"+ comment = "column_materializer::properties::$session_id"+ }+ column "request_id" {+ type = "String"+ materialized = "replaceRegexpAll(JSONExtractRaw(properties, '$feature_flag_request_id'), '^\"|\"$', '')"+ comment = "column_materializer::properties::$feature_flag_request_id"+ }+ column "_timestamp" {+ type = "DateTime"+ }+ column "_offset" {+ type = "UInt64"+ }+ column "_partition" {+ type = "UInt64"+ }+ index "distinct_id_idx" {+ expr = "distinct_id"+ type = "bloom_filter(0.01)"+ granularity = 1+ }+ index "person_id_idx" {+ expr = "person_id"+ type = "bloom_filter(0.01)"+ granularity = 1+ }+ index "session_id_idx" {+ expr = "session_id"+ type = "bloom_filter(0.01)"+ granularity = 1+ }+ index "request_id_idx" {+ expr = "request_id"+ type = "bloom_filter(0.01)"+ granularity = 1+ }+ index "inserted_at_idx" {+ expr = "inserted_at"+ type = "minmax"+ granularity = 1+ }+ engine "replicated_merge_tree" {+ zoo_path = "/clickhouse/tables/{shard}/posthog.flag_evaluations"+ replica_name = "{replica}"+ }+ }++ table "sharded_heatmaps" {+ order_by = ["type", "team_id", "toDate(timestamp)", "current_url", "viewport_width"]+ partition_by = "toYYYYMM(timestamp)"+ ttl = "toDate(timestamp) + toIntervalDay(90)"+ settings = {+ index_granularity = "8192"+ }+ column "session_id" {+ type = "String"+ }+ column "team_id" {+ type = "Int64"+ }+ column "distinct_id" {+ type = "String"+ }+ column "timestamp" {+ type = "DateTime64(6, 'UTC')"+ }+ column "x" {+ type = "Int16"+ }+ column "y" {+ type = "Int16"+ }+ column "scale_factor" {+ type = "Int16"+ }+ column "viewport_width" {+ type = "Int16"+ }+ column "viewport_height" {+ type = "Int16"+ }+ column "pointer_target_fixed" {+ type = "Bool"+ }+ column "current_url" {+ type = "String"+ }+ column "type" {+ type = "LowCardinality(String)"+ }+ column "_timestamp" {+ type = "DateTime"+ }+ column "_offset" {+ type = "UInt64"+ }+ column "_partition" {+ type = "UInt64"+ }+ engine "replicated_merge_tree" {+ zoo_path = "/clickhouse/tables/{shard}/posthog.heatmaps"+ replica_name = "{replica}"+ }+ }++ table "sharded_ingestion_warnings" {+ order_by = ["team_id", "toHour(timestamp)", "type", "source", "timestamp"]+ partition_by = "toYYYYMMDD(timestamp)"+ settings = {+ index_granularity = "8192"+ }+ column "team_id" {+ type = "Int64"+ }+ column "source" {+ type = "LowCardinality(String)"+ }+ column "type" {+ type = "String"+ }+ column "details" {+ type = "String"+ codec = "ZSTD(3)"+ }+ column "timestamp" {+ type = "DateTime64(6, 'UTC')"+ }+ column "_timestamp" {+ type = "DateTime"+ }+ column "_offset" {+ type = "UInt64"+ }+ column "_partition" {+ type = "UInt64"+ }+ engine "replicated_merge_tree" {+ zoo_path = "/clickhouse/tables/{shard}/posthog.sharded_ingestion_warnings"+ replica_name = "{replica}"+ }+ }++ table "sharded_log_entries" {+ order_by = ["team_id", "log_source", "log_source_id", "instance_id", "timestamp"]+ partition_by = "toYYYYMMDD(timestamp)"+ ttl = "toDate(timestamp) + toIntervalDay(90)"+ settings = {+ index_granularity = "1024"+ ttl_only_drop_parts = "1"+ }+ column "team_id" {+ type = "UInt64"+ }+ column "log_source" {+ type = "LowCardinality(String)"+ }+ column "log_source_id" {+ type = "String"+ }+ column "instance_id" {+ type = "String"+ }+ column "timestamp" {+ type = "DateTime64(6, 'UTC')"+ }+ column "level" {+ type = "LowCardinality(String)"+ }+ column "message" {+ type = "String"+ }+ column "_timestamp" {+ type = "DateTime"+ }+ column "_offset" {+ type = "UInt64"+ }+ engine "replicated_replacing_merge_tree" {+ zoo_path = "/clickhouse/tables/{shard}/posthog.sharded_log_entries"+ replica_name = "{replica}"+ version_column = "_timestamp"+ }+ }++ table "sharded_marketing_conversions_preaggregated" {+ order_by = ["team_id", "job_id", "person_id", "conversion_timestamp"]+ partition_by = "toYYYYMMDD(expires_at)"+ ttl = "expires_at"+ settings = {+ index_granularity = "8192"+ ttl_only_drop_parts = "1"+ }+ column "team_id" {+ type = "Int64"+ }+ column "job_id" {+ type = "UUID"+ }+ column "person_id" {+ type = "UUID"+ }+ column "conversion_timestamp" {+ type = "DateTime64(6, 'UTC')"+ }+ column "conversion_math_value" {+ type = "Float64"+ }+ column "session_id" {+ type = "String"+ }+ column "campaign_name" {+ type = "String"+ }+ column "source_name" {+ type = "String"+ }+ column "medium_name" {+ type = "String"+ }+ column "content_name" {+ type = "String"+ }+ column "term_name" {+ type = "String"+ }+ column "referring_domain_name" {+ type = "String"+ }+ column "gclid_name" {+ type = "String"+ }+ column "fbclid_name" {+ type = "String"+ }+ column "gad_source_name" {+ type = "String"+ }+ column "computed_at" {+ type = "DateTime64(6, 'UTC')"+ default = "now()"+ }+ column "expires_at" {+ type = "Date"+ default = "today() + toIntervalDay(7)"+ }+ engine "replicated_replacing_merge_tree" {+ zoo_path = "/clickhouse/tables/noshard/posthog.marketing_conversions_preaggregated"+ replica_name = "{replica}-{shard}"+ version_column = "computed_at"+ }+ }++ table "sharded_marketing_costs_preaggregated" {+ order_by = ["team_id", "job_id", "source_name", "grain", "campaign_id", "ad_group_id", "ad_id", "cost_date"]+ partition_by = "toYYYYMMDD(expires_at)"+ ttl = "expires_at"+ settings = {+ index_granularity = "8192"+ ttl_only_drop_parts = "1"+ }+ column "team_id" {+ type = "Int64"+ }+ column "job_id" {+ type = "UUID"+ }+ column "source_id" {+ type = "String"+ }+ column "source_name" {+ type = "String"+ }+ column "grain" {+ type = "LowCardinality(String)"+ }+ column "match_key" {+ type = "String"+ }+ column "campaign_id" {+ type = "String"+ }+ column "campaign_name" {+ type = "String"+ }+ column "ad_group_id" {+ type = "String"+ }+ column "ad_group_name" {+ type = "String"+ }+ column "ad_id" {+ type = "String"+ }+ column "ad_name" {+ type = "String"+ }+ column "cost_date" {+ type = "Date"+ }+ column "cost" {+ type = "Float64"+ }+ column "clicks" {+ type = "Float64"+ }+ column "impressions" {+ type = "Float64"+ }+ column "reported_conversions" {+ type = "Float64"+ }+ column "reported_conversion_value" {+ type = "Float64"+ }+ column "computed_at" {+ type = "DateTime64(6, 'UTC')"+ default = "now()"+ }+ column "expires_at" {+ type = "Date"+ default = "today() + toIntervalDay(7)"+ }+ engine "replicated_replacing_merge_tree" {+ zoo_path = "/clickhouse/tables/noshard/posthog.marketing_costs_preaggregated"+ replica_name = "{replica}-{shard}"+ version_column = "computed_at"+ }+ }++ table "sharded_marketing_touchpoints_preaggregated" {+ order_by = ["team_id", "job_id", "person_id", "touchpoint_timestamp"]+ partition_by = "toYYYYMMDD(expires_at)"+ ttl = "expires_at"+ settings = {+ index_granularity = "8192"+ ttl_only_drop_parts = "1"+ }+ column "team_id" {+ type = "Int64"+ }+ column "job_id" {+ type = "UUID"+ }+ column "person_id" {+ type = "UUID"+ }+ column "touchpoint_timestamp" {+ type = "DateTime64(6, 'UTC')"+ }+ column "campaign_name" {+ type = "String"+ }+ column "source_name" {+ type = "String"+ }+ column "medium_name" {+ type = "String"+ }+ column "content_name" {+ type = "String"+ }+ column "term_name" {+ type = "String"+ }+ column "referring_domain_name" {+ type = "String"+ }+ column "gclid_name" {+ type = "String"+ }+ column "fbclid_name" {+ type = "String"+ }+ column "gad_source_name" {+ type = "String"+ }+ column "computed_at" {+ type = "DateTime64(6, 'UTC')"+ default = "now()"+ }+ column "expires_at" {+ type = "Date"+ default = "today() + toIntervalDay(7)"+ }+ engine "replicated_replacing_merge_tree" {+ zoo_path = "/clickhouse/tables/noshard/posthog.marketing_touchpoints_preaggregated"+ replica_name = "{replica}-{shard}"+ version_column = "computed_at"+ }+ }++ table "sharded_performance_events" {+ order_by = ["team_id", "toDate(timestamp)", "session_id", "pageview_id", "timestamp"]+ partition_by = "toYYYYMM(timestamp)"+ ttl = "toDate(timestamp) + toIntervalWeek(3)"+ settings = {+ index_granularity = "8192"+ }+ column "uuid" {+ type = "UUID"+ }+ column "session_id" {+ type = "String"+ }+ column "window_id" {+ type = "String"+ }+ column "pageview_id" {+ type = "String"+ }+ column "distinct_id" {+ type = "String"+ }+ column "timestamp" {+ type = "DateTime64(3)"+ }+ column "time_origin" {+ type = "DateTime64(3, 'UTC')"+ }+ column "entry_type" {+ type = "LowCardinality(String)"+ }+ column "name" {+ type = "String"+ }+ column "team_id" {+ type = "Int64"+ }+ column "current_url" {+ type = "String"+ }+ column "start_time" {+ type = "Float64"+ }+ column "duration" {+ type = "Float64"+ }+ column "redirect_start" {+ type = "Float64"+ }+ column "redirect_end" {+ type = "Float64"+ }+ column "worker_start" {+ type = "Float64"+ }+ column "fetch_start" {+ type = "Float64"+ }+ column "domain_lookup_start" {+ type = "Float64"+ }+ column "domain_lookup_end" {+ type = "Float64"+ }+ column "connect_start" {+ type = "Float64"+ }+ column "secure_connection_start" {+ type = "Float64"+ }+ column "connect_end" {+ type = "Float64"+ }+ column "request_start" {+ type = "Float64"+ }+ column "response_start" {+ type = "Float64"+ }+ column "response_end" {+ type = "Float64"+ }+ column "decoded_body_size" {+ type = "Int64"+ }+ column "encoded_body_size" {+ type = "Int64"+ }+ column "initiator_type" {+ type = "LowCardinality(String)"+ }+ column "next_hop_protocol" {+ type = "LowCardinality(String)"+ }+ column "render_blocking_status" {+ type = "LowCardinality(String)"+ }+ column "response_status" {+ type = "Int64"+ }+ column "transfer_size" {+ type = "Int64"+ }+ column "largest_contentful_paint_element" {+ type = "String"+ }+ column "largest_contentful_paint_render_time" {+ type = "Float64"+ }+ column "largest_contentful_paint_load_time" {+ type = "Float64"+ }+ column "largest_contentful_paint_size" {+ type = "Float64"+ }+ column "largest_contentful_paint_id" {+ type = "String"+ }+ column "largest_contentful_paint_url" {+ type = "String"+ }+ column "dom_complete" {+ type = "Float64"+ }+ column "dom_content_loaded_event" {+ type = "Float64"+ }+ column "dom_interactive" {+ type = "Float64"+ }+ column "load_event_end" {+ type = "Float64"+ }+ column "load_event_start" {+ type = "Float64"+ }+ column "redirect_count" {+ type = "Int64"+ }+ column "navigation_type" {+ type = "LowCardinality(String)"+ }+ column "unload_event_end" {+ type = "Float64"+ }+ column "unload_event_start" {+ type = "Float64"+ }+ column "_timestamp" {+ type = "DateTime"+ }+ column "_offset" {+ type = "UInt64"+ }+ column "_partition" {+ type = "UInt64"+ }+ engine "replicated_merge_tree" {+ zoo_path = "/clickhouse/tables/{shard}/posthog.performance_events"+ replica_name = "{replica}"+ }+ }++ table "sharded_posthog_document_embeddings_buffer" {+ order_by = ["inserted_at", "model_name", "cityHash64(document_id)"]+ partition_by = "toDate(inserted_at)"+ ttl = "inserted_at + toIntervalDay(1)"+ settings = {+ index_granularity = "8192"+ ttl_only_drop_parts = "1"+ }+ column "team_id" {+ type = "Int64"+ }+ column "product" {+ type = "LowCardinality(String)"+ }+ column "document_type" {+ type = "LowCardinality(String)"+ }+ column "model_name" {+ type = "LowCardinality(String)"+ }+ column "rendering" {+ type = "LowCardinality(String)"+ }+ column "document_id" {+ type = "String"+ }+ column "timestamp" {+ type = "DateTime64(3, 'UTC')"+ }+ column "inserted_at" {+ type = "DateTime64(3, 'UTC')"+ }+ column "content" {+ type = "String"+ default = "''"+ }+ column "metadata" {+ type = "String"+ default = "'{}'"+ }+ column "embedding" {+ type = "Array(Float64)"+ }+ column "_timestamp" {+ type = "DateTime"+ }+ column "_offset" {+ type = "UInt64"+ }+ column "_partition" {+ type = "UInt64"+ }+ engine "replicated_replacing_merge_tree" {+ zoo_path = "/clickhouse/tables/{shard}/posthog.sharded_posthog_document_embeddings_buffer"+ replica_name = "{replica}"+ version_column = "inserted_at"+ }+ }++ table "sharded_posthog_document_embeddings_text_embedding_3_large_3072" {+ order_by = ["team_id", "toDate(timestamp)", "product", "document_type", "rendering", "cityHash64(document_id)"]+ partition_by = "toMonday(timestamp)"+ ttl = "timestamp + toIntervalMonth(3)"+ settings = {+ index_granularity = "512"+ ttl_only_drop_parts = "1"+ }+ column "team_id" {+ type = "Int64"+ }+ column "product" {+ type = "LowCardinality(String)"+ }+ column "document_type" {+ type = "LowCardinality(String)"+ }+ column "rendering" {+ type = "LowCardinality(String)"+ }+ column "document_id" {+ type = "String"+ }+ column "timestamp" {+ type = "DateTime64(3, 'UTC')"+ }+ column "inserted_at" {+ type = "DateTime64(3, 'UTC')"+ }+ column "content" {+ type = "String"+ default = "''"+ }+ column "metadata" {+ type = "String"+ default = "'{}'"+ }+ column "embedding" {+ type = "Array(Float64)"+ }+ column "_timestamp" {+ type = "DateTime"+ }+ column "_offset" {+ type = "UInt64"+ }+ column "_partition" {+ type = "UInt64"+ }+ index "kafka_timestamp_minmax_sharded_posthog_document_embeddings_text_embedding_3_large_3072" {+ expr = "_timestamp"+ type = "minmax"+ granularity = 3+ }+ index "embedding_idx_l2" {+ expr = "embedding"+ type = "vector_similarity('hnsw', 'L2Distance', 3072)"+ granularity = 100000000+ }+ index "embedding_idx_cosine" {+ expr = "embedding"+ type = "vector_similarity('hnsw', 'cosineDistance', 3072)"+ granularity = 100000000+ }+ constraint "embedding_dimension_check" {+ check = "length(embedding) = 3072"+ }+ engine "replicated_replacing_merge_tree" {+ zoo_path = "/clickhouse/tables/{shard}/posthog.sharded_posthog_document_embeddings_text_embedding_3_large_3072"+ replica_name = "{replica}"+ version_column = "inserted_at"+ }+ }++ table "sharded_posthog_document_embeddings_text_embedding_3_small_1536" {+ order_by = ["team_id", "toDate(timestamp)", "product", "document_type", "rendering", "cityHash64(document_id)"]+ partition_by = "toMonday(timestamp)"+ ttl = "timestamp + toIntervalMonth(3)"+ settings = {+ index_granularity = "512"+ ttl_only_drop_parts = "1"+ }+ column "team_id" {+ type = "Int64"+ }+ column "product" {+ type = "LowCardinality(String)"+ }+ column "document_type" {+ type = "LowCardinality(String)"+ }+ column "rendering" {+ type = "LowCardinality(String)"+ }+ column "document_id" {+ type = "String"+ }+ column "timestamp" {+ type = "DateTime64(3, 'UTC')"+ }+ column "inserted_at" {+ type = "DateTime64(3, 'UTC')"+ }+ column "content" {+ type = "String"+ default = "''"+ }+ column "metadata" {+ type = "String"+ default = "'{}'"+ }+ column "embedding" {+ type = "Array(Float64)"+ }+ column "_timestamp" {+ type = "DateTime"+ }+ column "_offset" {+ type = "UInt64"+ }+ column "_partition" {+ type = "UInt64"+ }+ index "kafka_timestamp_minmax_sharded_posthog_document_embeddings_text_embedding_3_small_1536" {+ expr = "_timestamp"+ type = "minmax"+ granularity = 3+ }+ index "embedding_idx_l2" {+ expr = "embedding"+ type = "vector_similarity('hnsw', 'L2Distance', 1536)"+ granularity = 100000000+ }+ index "embedding_idx_cosine" {+ expr = "embedding"+ type = "vector_similarity('hnsw', 'cosineDistance', 1536)"+ granularity = 100000000+ }+ constraint "embedding_dimension_check" {+ check = "length(embedding) = 1536"+ }+ engine "replicated_replacing_merge_tree" {+ zoo_path = "/clickhouse/tables/{shard}/posthog.sharded_posthog_document_embeddings_text_embedding_3_small_1536"+ replica_name = "{replica}"+ version_column = "inserted_at"+ }+ }++ table "sharded_preaggregation_results" {+ order_by = ["team_id", "job_id", "time_window_start", "breakdown_value"]+ partition_by = "toYYYYMM(time_window_start)"+ ttl = "expires_at"+ settings = {+ index_granularity = "8192"+ }+ column "team_id" {+ type = "Int64"+ }+ column "job_id" {+ type = "UUID"+ }+ column "time_window_start" {+ type = "DateTime64(6, 'UTC')"+ }+ column "expires_at" {+ type = "DateTime64(6, 'UTC')"+ default = "now() + toIntervalDay(7)"+ }+ column "breakdown_value" {+ type = "Array(String)"+ }+ column "uniq_exact_state" {+ type = "AggregateFunction(uniqExact, UUID)"+ }+ engine "replicated_aggregating_merge_tree" {+ zoo_path = "/clickhouse/tables/{shard}/posthog.preaggregation_results"+ replica_name = "{replica}"+ }+ }++ table "sharded_precalculated_events" {+ order_by = ["team_id", "condition", "date", "distinct_id", "uuid"]+ partition_by = "toYYYYMM(date)"+ settings = {+ index_granularity = "8192"+ }+ column "team_id" {+ type = "Int64"+ }+ column "date" {+ type = "Date"+ }+ column "distinct_id" {+ type = "String"+ }+ column "person_id" {+ type = "UUID"+ }+ column "condition" {+ type = "String"+ }+ column "uuid" {+ type = "UUID"+ }+ column "source" {+ type = "String"+ }+ column "_timestamp" {+ type = "DateTime64(6)"+ }+ column "_partition" {+ type = "UInt64"+ }+ column "_offset" {+ type = "UInt64"+ }+ engine "replicated_replacing_merge_tree" {+ zoo_path = "/clickhouse/tables/{shard}/posthog.sharded_precalculated_events"+ replica_name = "{replica}"+ version_column = "_timestamp"+ }+ }++ table "sharded_precalculated_person_properties" {+ order_by = ["team_id", "condition", "distinct_id"]+ settings = {+ index_granularity = "8192"+ }+ column "team_id" {+ type = "Int64"+ }+ column "distinct_id" {+ type = "String"+ }+ column "person_id" {+ type = "UUID"+ }+ column "condition" {+ type = "String"+ }+ column "matches" {+ type = "Bool"+ }+ column "source" {+ type = "String"+ }+ column "_timestamp" {+ type = "DateTime64(6)"+ }+ column "_offset" {+ type = "UInt64"+ }+ engine "replicated_replacing_merge_tree" {+ zoo_path = "/clickhouse/tables/{shard}/posthog.sharded_precalculated_person_properties"+ replica_name = "{replica}"+ version_column = "_timestamp"+ }+ }++ table "sharded_query_log_archive" {+ order_by = ["team_id", "event_date", "event_time", "query_id"]+ partition_by = "toYYYYMM(event_date)"+ settings = {+ index_granularity = "8192"+ object_serialization_version = "v3"+ object_shared_data_serialization_version = "map_with_buckets"+ }+ column "hostname" {+ type = "LowCardinality(String)"+ }+ column "user" {+ type = "LowCardinality(String)"+ }+ column "query_id" {+ type = "String"+ }+ column "initial_query_id" {+ type = "String"+ }+ column "is_initial_query" {+ type = "UInt8"+ }+ column "type" {+ type = "Enum8('QueryStart'=1, 'QueryFinish'=2, 'ExceptionBeforeStart'=3, 'ExceptionWhileProcessing'=4)"+ }+ column "event_date" {+ type = "Date"+ }+ column "event_time" {+ type = "DateTime"+ }+ column "event_time_microseconds" {+ type = "DateTime64(6)"+ }+ column "query_start_time" {+ type = "DateTime"+ }+ column "query_start_time_microseconds" {+ type = "DateTime64(6)"+ }+ column "query_duration_ms" {+ type = "UInt64"+ }+ column "read_rows" {+ type = "UInt64"+ }+ column "read_bytes" {+ type = "UInt64"+ }+ column "written_rows" {+ type = "UInt64"+ }+ column "written_bytes" {+ type = "UInt64"+ }+ column "result_rows" {+ type = "UInt64"+ }+ column "result_bytes" {+ type = "UInt64"+ }+ column "memory_usage" {+ type = "UInt64"+ }+ column "peak_threads_usage" {+ type = "UInt64"+ }+ column "current_database" {+ type = "LowCardinality(String)"+ }+ column "query" {+ type = "String"+ }+ column "formatted_query" {+ type = "String"+ }+ column "normalized_query_hash" {+ type = "UInt64"+ }+ column "query_kind" {+ type = "LowCardinality(String)"+ }+ column "exception_code" {+ type = "Int32"+ }+ column "exception" {+ type = "String"+ }+ column "stack_trace" {+ type = "String"+ }+ column "team_id" {+ type = "Int64"+ }+ column "log_comment" {+ type = "JSON(max_dynamic_paths=256, access_method LowCardinality(String), alert_config_id String, api_key_label String, api_key_mask String, batch_export_id String, chargeable Bool, client_query_id String, cohort_id Int64, `dagster.job_name` String, `dagster.run_id` String, `dagster.tags.owner` String, dashboard_id Int64, experiment_feature_flag_key String, experiment_id Int64, feature LowCardinality(String), id String, insight_id Int64, is_impersonated Bool, kind LowCardinality(String), name String, org_id String, person_on_events_mode LowCardinality(String), product LowCardinality(String), query_type LowCardinality(String), request_name String, route_id String, service_name String, session_id String, table_id String, team_id Int64, `temporal.activity_id` String, `temporal.activity_type` String, `temporal.attempt` Int64, `temporal.workflow_id` String, `temporal.workflow_namespace` String, `temporal.workflow_run_id` String, `temporal.workflow_type` String, user_id Int64, warehouse_query Bool, workflow LowCardinality(String), workload LowCardinality(String), SKIP cache_key, SKIP filter, SKIP hogql_features, SKIP http_referer, SKIP http_request_id, SKIP http_user_agent, SKIP query_settings, SKIP timings, SKIP user_email)"+ }+ column "ProfileEvents" {+ type = "Map(String, UInt64)"+ }+ column "exception_name" {+ type = "String"+ alias = "errorCodeToName(exception_code)"+ }+ column "ProfileEvents_RealTimeMicroseconds" {+ type = "Int64"+ alias = "ProfileEvents['RealTimeMicroseconds']"+ }+ column "ProfileEvents_OSCPUVirtualTimeMicroseconds" {+ type = "Int64"+ alias = "ProfileEvents['OSCPUVirtualTimeMicroseconds']"+ }+ column "ProfileEvents_S3Clients" {+ type = "Int64"+ alias = "ProfileEvents['S3Clients']"+ }+ column "ProfileEvents_S3DeleteObjects" {+ type = "Int64"+ alias = "ProfileEvents['S3DeleteObjects']"+ }+ column "ProfileEvents_S3CopyObject" {+ type = "Int64"+ alias = "ProfileEvents['S3CopyObject']"+ }+ column "ProfileEvents_S3ListObjects" {+ type = "Int64"+ alias = "ProfileEvents['S3ListObjects']"+ }+ column "ProfileEvents_S3HeadObject" {+ type = "Int64"+ alias = "ProfileEvents['S3HeadObject']"+ }+ column "ProfileEvents_S3GetObjectAttributes" {+ type = "Int64"+ alias = "ProfileEvents['S3GetObjectAttributes']"+ }+ column "ProfileEvents_S3CreateMultipartUpload" {+ type = "Int64"+ alias = "ProfileEvents['S3CreateMultipartUpload']"+ }+ column "ProfileEvents_S3UploadPartCopy" {+ type = "Int64"+ alias = "ProfileEvents['S3UploadPartCopy']"+ }+ column "ProfileEvents_S3UploadPart" {+ type = "Int64"+ alias = "ProfileEvents['S3UploadPart']"+ }+ column "ProfileEvents_S3AbortMultipartUpload" {+ type = "Int64"+ alias = "ProfileEvents['S3AbortMultipartUpload']"+ }+ column "ProfileEvents_S3CompleteMultipartUpload" {+ type = "Int64"+ alias = "ProfileEvents['S3CompleteMultipartUpload']"+ }+ column "ProfileEvents_S3PutObject" {+ type = "Int64"+ alias = "ProfileEvents['S3PutObject']"+ }+ column "ProfileEvents_S3GetObject" {+ type = "Int64"+ alias = "ProfileEvents['S3GetObject']"+ }+ column "ProfileEvents_ReadBufferFromS3Bytes" {+ type = "Int64"+ alias = "ProfileEvents['ReadBufferFromS3Bytes']"+ }+ column "ProfileEvents_WriteBufferFromS3Bytes" {+ type = "Int64"+ alias = "ProfileEvents['WriteBufferFromS3Bytes']"+ }+ column "lc_workflow" {+ type = "LowCardinality(String)"+ alias = "log_comment.workflow"+ }+ column "lc_kind" {+ type = "LowCardinality(String)"+ alias = "log_comment.kind"+ }+ column "lc_id" {+ type = "String"+ alias = "CAST(log_comment.id, 'String')"+ }+ column "lc_route_id" {+ type = "String"+ alias = "CAST(log_comment.route_id, 'String')"+ }+ column "lc_access_method" {+ type = "LowCardinality(String)"+ alias = "log_comment.access_method"+ }+ column "lc_api_key_label" {+ type = "String"+ alias = "CAST(log_comment.api_key_label, 'String')"+ }+ column "lc_api_key_mask" {+ type = "String"+ alias = "CAST(log_comment.api_key_mask, 'String')"+ }+ column "lc_query_type" {+ type = "LowCardinality(String)"+ alias = "log_comment.query_type"+ }+ column "lc_product" {+ type = "LowCardinality(String)"+ alias = "log_comment.product"+ }+ column "lc_chargeable" {+ type = "Bool"+ alias = "log_comment.chargeable"+ }+ column "lc_name" {+ type = "String"+ alias = "CAST(log_comment.name, 'String')"+ }+ column "lc_request_name" {+ type = "String"+ alias = "CAST(log_comment.request_name, 'String')"+ }+ column "lc_client_query_id" {+ type = "String"+ alias = "CAST(log_comment.client_query_id, 'String')"+ }+ column "lc_org_id" {+ type = "String"+ alias = "CAST(log_comment.org_id, 'String')"+ }+ column "lc_user_id" {+ type = "Int64"+ alias = "log_comment.user_id"+ }+ column "lc_is_impersonated" {+ type = "Bool"+ alias = "log_comment.is_impersonated"+ }+ column "lc_session_id" {+ type = "String"+ alias = "CAST(log_comment.session_id, 'String')"+ }+ column "lc_dashboard_id" {+ type = "Int64"+ alias = "log_comment.dashboard_id"+ }+ column "lc_insight_id" {+ type = "Int64"+ alias = "log_comment.insight_id"+ }+ column "lc_cohort_id" {+ type = "Int64"+ alias = "log_comment.cohort_id"+ }+ column "lc_batch_export_id" {+ type = "String"+ alias = "CAST(log_comment.batch_export_id, 'String')"+ }+ column "lc_experiment_id" {+ type = "Int64"+ alias = "log_comment.experiment_id"+ }+ column "lc_experiment_feature_flag_key" {+ type = "String"+ alias = "CAST(log_comment.experiment_feature_flag_key, 'String')"+ }+ column "lc_alert_config_id" {+ type = "String"+ alias = "CAST(log_comment.alert_config_id, 'String')"+ }+ column "lc_feature" {+ type = "LowCardinality(String)"+ alias = "log_comment.feature"+ }+ column "lc_table_id" {+ type = "String"+ alias = "CAST(log_comment.table_id, 'String')"+ }+ column "lc_warehouse_query" {+ type = "Bool"+ alias = "log_comment.warehouse_query"+ }+ column "lc_person_on_events_mode" {+ type = "LowCardinality(String)"+ alias = "log_comment.person_on_events_mode"+ }+ column "lc_service_name" {+ type = "String"+ alias = "CAST(log_comment.service_name, 'String')"+ }+ column "lc_workload" {+ type = "LowCardinality(String)"+ alias = "log_comment.workload"+ }+ column "lc_query__kind" {+ type = "LowCardinality(String)"+ alias = "if(JSONHas(toString(log_comment), 'query', 'source'), JSONExtractString(toString(log_comment), 'query', 'source', 'kind'), JSONExtractString(toString(log_comment), 'query', 'kind'))"+ }+ column "lc_query__query" {+ type = "String"+ alias = "multiIf(NOT is_initial_query, '', JSONHas(toString(log_comment), 'query', 'source'), JSONExtractString(toString(log_comment), 'query', 'source', 'query'), JSONExtractString(toString(log_comment), 'query', 'query'))"+ }+ column "lc_query" {+ type = "String"+ alias = "if(is_initial_query, JSONExtractRaw(toString(log_comment), 'query'), '')"+ }+ column "lc_temporal__workflow_namespace" {+ type = "String"+ alias = "CAST(log_comment.`temporal.workflow_namespace`, 'String')"+ }+ column "lc_temporal__workflow_type" {+ type = "String"+ alias = "CAST(log_comment.`temporal.workflow_type`, 'String')"+ }+ column "lc_temporal__workflow_id" {+ type = "String"+ alias = "CAST(log_comment.`temporal.workflow_id`, 'String')"+ }+ column "lc_temporal__workflow_run_id" {+ type = "String"+ alias = "CAST(log_comment.`temporal.workflow_run_id`, 'String')"+ }+ column "lc_temporal__activity_type" {+ type = "String"+ alias = "CAST(log_comment.`temporal.activity_type`, 'String')"+ }+ column "lc_temporal__activity_id" {+ type = "String"+ alias = "CAST(log_comment.`temporal.activity_id`, 'String')"+ }+ column "lc_temporal__attempt" {+ type = "Int64"+ alias = "log_comment.`temporal.attempt`"+ }+ column "lc_dagster__job_name" {+ type = "String"+ alias = "CAST(log_comment.`dagster.job_name`, 'String')"+ }+ column "lc_dagster__run_id" {+ type = "String"+ alias = "CAST(log_comment.`dagster.run_id`, 'String')"+ }+ column "lc_dagster__owner" {+ type = "String"+ alias = "CAST(log_comment.`dagster.tags.owner`, 'String')"+ }+ column "lc_modifiers" {+ type = "String"+ alias = "if(is_initial_query, JSONExtractRaw(toString(log_comment), 'modifiers'), '')"+ }+ engine "replicated_merge_tree" {+ zoo_path = "/clickhouse/tables/noshard/posthog.sharded_query_log_archive"+ replica_name = "{replica}-{shard}"+ }+ }++ table "sharded_query_log_archive_old" {+ order_by = ["team_id", "event_date", "event_time", "query_id"]+ partition_by = "toYYYYMM(event_date)"+ settings = {+ index_granularity = "8192"+ }+ column "hostname" {+ type = "LowCardinality(String)"+ }+ column "user" {+ type = "LowCardinality(String)"+ }+ column "query_id" {+ type = "String"+ }+ column "initial_query_id" {+ type = "String"+ }+ column "is_initial_query" {+ type = "UInt8"+ }+ column "type" {+ type = "Enum8('QueryStart'=1, 'QueryFinish'=2, 'ExceptionBeforeStart'=3, 'ExceptionWhileProcessing'=4)"+ }+ column "event_date" {+ type = "Date"+ }+ column "event_time" {+ type = "DateTime"+ }+ column "event_time_microseconds" {+ type = "DateTime64(6)"+ }+ column "query_start_time" {+ type = "DateTime"+ }+ column "query_start_time_microseconds" {+ type = "DateTime64(6)"+ }+ column "query_duration_ms" {+ type = "UInt64"+ }+ column "read_rows" {+ type = "UInt64"+ }+ column "read_bytes" {+ type = "UInt64"+ }+ column "written_rows" {+ type = "UInt64"+ }+ column "written_bytes" {+ type = "UInt64"+ }+ column "result_rows" {+ type = "UInt64"+ }+ column "result_bytes" {+ type = "UInt64"+ }+ column "memory_usage" {+ type = "UInt64"+ }+ column "peak_threads_usage" {+ type = "UInt64"+ }+ column "current_database" {+ type = "LowCardinality(String)"+ }+ column "query" {+ type = "String"+ }+ column "formatted_query" {+ type = "String"+ }+ column "normalized_query_hash" {+ type = "UInt64"+ }+ column "query_kind" {+ type = "LowCardinality(String)"+ }+ column "exception_code" {+ type = "Int32"+ }+ column "exception_name" {+ type = "String"+ alias = "errorCodeToName(exception_code)"+ }+ column "exception" {+ type = "String"+ }+ column "stack_trace" {+ type = "String"+ }+ column "ProfileEvents_RealTimeMicroseconds" {+ type = "Int64"+ }+ column "ProfileEvents_OSCPUVirtualTimeMicroseconds" {+ type = "Int64"+ }+ column "ProfileEvents_S3Clients" {+ type = "Int64"+ }+ column "ProfileEvents_S3DeleteObjects" {+ type = "Int64"+ }+ column "ProfileEvents_S3CopyObject" {+ type = "Int64"+ }+ column "ProfileEvents_S3ListObjects" {+ type = "Int64"+ }+ column "ProfileEvents_S3HeadObject" {+ type = "Int64"+ }+ column "ProfileEvents_S3GetObjectAttributes" {+ type = "Int64"+ }+ column "ProfileEvents_S3CreateMultipartUpload" {+ type = "Int64"+ }+ column "ProfileEvents_S3UploadPartCopy" {+ type = "Int64"+ }+ column "ProfileEvents_S3UploadPart" {+ type = "Int64"+ }+ column "ProfileEvents_S3AbortMultipartUpload" {+ type = "Int64"+ }+ column "ProfileEvents_S3CompleteMultipartUpload" {+ type = "Int64"+ }+ column "ProfileEvents_S3PutObject" {+ type = "Int64"+ }+ column "ProfileEvents_S3GetObject" {+ type = "Int64"+ }+ column "ProfileEvents_ReadBufferFromS3Bytes" {+ type = "Int64"+ }+ column "ProfileEvents_WriteBufferFromS3Bytes" {+ type = "Int64"+ }+ column "ProfileEvents" {+ type = "Map(String, UInt64)"+ }+ column "lc_workflow" {+ type = "LowCardinality(String)"+ }+ column "lc_kind" {+ type = "LowCardinality(String)"+ }+ column "lc_id" {+ type = "String"+ }+ column "lc_route_id" {+ type = "String"+ }+ column "lc_access_method" {+ type = "LowCardinality(String)"+ }+ column "lc_api_key_label" {+ type = "String"+ }+ column "lc_api_key_mask" {+ type = "String"+ }+ column "lc_query_type" {+ type = "LowCardinality(String)"+ }+ column "lc_product" {+ type = "LowCardinality(String)"+ }+ column "lc_chargeable" {+ type = "Bool"+ }+ column "lc_name" {+ type = "String"+ }+ column "lc_request_name" {+ type = "String"+ }+ column "lc_client_query_id" {+ type = "String"+ }+ column "lc_org_id" {+ type = "String"+ }+ column "team_id" {+ type = "Int64"+ }+ column "lc_user_id" {+ type = "Int64"+ }+ column "lc_is_impersonated" {+ type = "Bool"+ }+ column "lc_session_id" {+ type = "String"+ }+ column "lc_dashboard_id" {+ type = "Int64"+ }+ column "lc_insight_id" {+ type = "Int64"+ }+ column "lc_cohort_id" {+ type = "Int64"+ }+ column "lc_batch_export_id" {+ type = "String"+ }+ column "lc_experiment_id" {+ type = "Int64"+ }+ column "lc_experiment_feature_flag_key" {+ type = "String"+ }+ column "lc_alert_config_id" {+ type = "String"+ }+ column "lc_feature" {+ type = "LowCardinality(String)"+ }+ column "lc_table_id" {+ type = "String"+ }+ column "lc_warehouse_query" {+ type = "Bool"+ }+ column "lc_person_on_events_mode" {+ type = "LowCardinality(String)"+ }+ column "lc_service_name" {+ type = "String"+ }+ column "lc_workload" {+ type = "LowCardinality(String)"+ }+ column "lc_query__kind" {+ type = "LowCardinality(String)"+ }+ column "lc_query__query" {+ type = "String"+ }+ column "lc_query" {+ type = "String"+ }+ column "lc_temporal__workflow_namespace" {+ type = "String"+ }+ column "lc_temporal__workflow_type" {+ type = "String"+ }+ column "lc_temporal__workflow_id" {+ type = "String"+ }+ column "lc_temporal__workflow_run_id" {+ type = "String"+ }+ column "lc_temporal__activity_type" {+ type = "String"+ }+ column "lc_temporal__activity_id" {+ type = "String"+ }+ column "lc_temporal__attempt" {+ type = "Int64"+ }+ column "lc_dagster__job_name" {+ type = "String"+ }+ column "lc_dagster__run_id" {+ type = "String"+ }+ column "lc_dagster__owner" {+ type = "String"+ }+ column "lc_modifiers" {+ type = "String"+ }+ engine "replicated_merge_tree" {+ zoo_path = "/clickhouse/tables/{shard}/posthog.sharded_query_log_archive"+ replica_name = "{replica}"+ }+ }++ table "sharded_raw_sessions" {+ 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"+ }+ column "session_id_v7" {+ type = "UInt128"+ }+ column "distinct_id" {+ type = "AggregateFunction(argMax, String, DateTime64(6, 'UTC'))"+ }+ column "min_timestamp" {+ type = "SimpleAggregateFunction(min, DateTime64(6, 'UTC'))"+ }+ column "max_timestamp" {+ type = "SimpleAggregateFunction(max, DateTime64(6, 'UTC'))"+ }+ column "max_inserted_at" {+ type = "SimpleAggregateFunction(max, DateTime64(6, 'UTC'))"+ }+ column "urls" {+ type = "SimpleAggregateFunction(groupUniqArrayArray, Array(String))"+ }+ column "entry_url" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "end_url" {+ type = "AggregateFunction(argMax, String, DateTime64(6, 'UTC'))"+ }+ column "last_external_click_url" {+ type = "AggregateFunction(argMax, String, DateTime64(6, 'UTC'))"+ }+ column "initial_browser" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_browser_version" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_os" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_os_version" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_device_type" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_viewport_width" {+ type = "AggregateFunction(argMin, Int64, DateTime64(6, 'UTC'))"+ }+ column "initial_viewport_height" {+ type = "AggregateFunction(argMin, Int64, DateTime64(6, 'UTC'))"+ }+ column "initial_geoip_country_code" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_geoip_subdivision_1_code" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_geoip_subdivision_1_name" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_geoip_subdivision_city_name" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_geoip_time_zone" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_referring_domain" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_utm_source" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_utm_campaign" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_utm_medium" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_utm_term" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_utm_content" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_gclid" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_gad_source" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_gclsrc" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_dclid" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_gbraid" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_wbraid" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_fbclid" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_msclkid" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_twclid" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_li_fat_id" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_mc_cid" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_igshid" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_ttclid" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_epik" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_qclid" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_sccid" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial__kx" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_irclid" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "pageview_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "pageview_uniq" {+ type = "AggregateFunction(uniq, Nullable(UUID))"+ }+ column "autocapture_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "autocapture_uniq" {+ type = "AggregateFunction(uniq, Nullable(UUID))"+ }+ column "screen_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "screen_uniq" {+ type = "AggregateFunction(uniq, Nullable(UUID))"+ }+ column "maybe_has_session_replay" {+ type = "SimpleAggregateFunction(max, Bool)"+ }+ column "page_screen_autocapture_uniq_up_to" {+ type = "AggregateFunction(uniqUpTo(1), Nullable(UUID))"+ }+ column "vitals_lcp" {+ type = "AggregateFunction(argMin, Nullable(Float64), DateTime64(6, 'UTC'))"+ }+ engine "replicated_aggregating_merge_tree" {+ zoo_path = "/clickhouse/tables/{shard}/posthog.raw_sessions"+ replica_name = "{replica}"+ }+ }++ table "sharded_raw_sessions_v3" {+ order_by = ["team_id", "session_timestamp", "session_id_v7"]+ partition_by = "toYYYYMM(session_timestamp)"+ settings = {+ index_granularity = "8192"+ max_delay_to_insert = "10"+ parts_to_delay_insert = "250"+ parts_to_throw_insert = "1000"+ }+ column "team_id" {+ type = "Int64"+ }+ column "session_id_v7" {+ type = "UInt128"+ }+ column "session_timestamp" {+ type = "DateTime64(3)"+ default = "fromUnixTimestamp64Milli(toUInt64(bitShiftRight(session_id_v7, 80)))"+ }+ column "distinct_id" {+ type = "AggregateFunction(argMax, String, DateTime64(6, 'UTC'))"+ }+ column "distinct_ids" {+ type = "AggregateFunction(groupUniqArray, String)"+ }+ column "min_timestamp" {+ type = "SimpleAggregateFunction(min, DateTime64(6, 'UTC'))"+ }+ column "max_timestamp" {+ type = "SimpleAggregateFunction(max, DateTime64(6, 'UTC'))"+ }+ column "max_inserted_at" {+ type = "SimpleAggregateFunction(max, DateTime64(6, 'UTC'))"+ }+ column "urls" {+ type = "SimpleAggregateFunction(groupUniqArrayArray(2000), Array(String))"+ }+ column "entry_url" {+ type = "AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC'))"+ }+ column "end_url" {+ type = "AggregateFunction(argMax, Nullable(String), DateTime64(6, 'UTC'))"+ }+ column "last_external_click_url" {+ type = "AggregateFunction(argMax, Nullable(String), DateTime64(6, 'UTC'))"+ }+ column "browser" {+ type = "AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC'))"+ }+ column "browser_version" {+ type = "AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC'))"+ }+ column "os" {+ type = "AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC'))"+ }+ column "os_version" {+ type = "AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC'))"+ }+ column "device_type" {+ type = "AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC'))"+ }+ column "viewport_width" {+ type = "AggregateFunction(argMin, Nullable(Int64), DateTime64(6, 'UTC'))"+ }+ column "viewport_height" {+ type = "AggregateFunction(argMin, Nullable(Int64), DateTime64(6, 'UTC'))"+ }+ column "geoip_country_code" {+ type = "AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC'))"+ }+ column "geoip_subdivision_1_code" {+ type = "AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC'))"+ }+ column "geoip_subdivision_1_name" {+ type = "AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC'))"+ }+ column "geoip_subdivision_city_name" {+ type = "AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC'))"+ }+ column "geoip_time_zone" {+ type = "AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC'))"+ }+ column "entry_referring_domain" {+ type = "AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC'))"+ }+ column "entry_utm_source" {+ type = "AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC'))"+ }+ column "entry_utm_campaign" {+ type = "AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC'))"+ }+ column "entry_utm_medium" {+ type = "AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC'))"+ }+ column "entry_utm_term" {+ type = "AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC'))"+ }+ column "entry_utm_content" {+ type = "AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC'))"+ }+ column "entry_gclid" {+ type = "AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC'))"+ }+ column "entry_gad_source" {+ type = "AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC'))"+ }+ column "entry_fbclid" {+ type = "AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC'))"+ }+ column "entry_has_gclid" {+ type = "AggregateFunction(argMin, Bool, DateTime64(6, 'UTC'))"+ }+ column "entry_has_fbclid" {+ type = "AggregateFunction(argMin, Bool, DateTime64(6, 'UTC'))"+ }+ column "entry_ad_ids_map" {+ type = "AggregateFunction(argMin, Map(String, String), DateTime64(6, 'UTC'))"+ }+ column "entry_ad_ids_set" {+ type = "AggregateFunction(argMin, Array(String), DateTime64(6, 'UTC'))"+ }+ column "entry_channel_type_properties" {+ type = "AggregateFunction(argMin, Tuple(Nullable(String), Nullable(String), Nullable(String), Nullable(String), Bool, Bool, Nullable(String)), DateTime64(6, 'UTC'))"+ }+ column "pageview_uniq" {+ type = "AggregateFunction(uniqExact, Nullable(UUID))"+ }+ column "autocapture_uniq" {+ type = "AggregateFunction(uniqExact, Nullable(UUID))"+ }+ column "screen_uniq" {+ type = "AggregateFunction(uniqExact, Nullable(UUID))"+ }+ column "page_screen_uniq_up_to" {+ type = "AggregateFunction(uniqUpTo(1), Nullable(UUID))"+ }+ column "has_autocapture" {+ type = "SimpleAggregateFunction(max, Bool)"+ }+ column "flag_values" {+ type = "AggregateFunction(groupUniqArrayMap, Map(String, String))"+ }+ column "flag_keys" {+ type = "SimpleAggregateFunction(groupUniqArrayArray, Array(String))"+ }+ column "event_names" {+ type = "SimpleAggregateFunction(groupUniqArrayArray(2000), Array(String))"+ }+ column "hosts" {+ type = "SimpleAggregateFunction(groupUniqArrayArray(100), Array(String))"+ }+ column "emails" {+ type = "SimpleAggregateFunction(groupUniqArrayArray(10), Array(String))"+ }+ column "has_replay_events" {+ type = "SimpleAggregateFunction(max, Bool)"+ }+ index "event_names_bloom_filter" {+ expr = "event_names"+ type = "bloom_filter()"+ granularity = 1+ }+ index "flag_keys_bloom_filter" {+ expr = "flag_keys"+ type = "bloom_filter()"+ granularity = 1+ }+ index "hosts_bloom_filter" {+ expr = "hosts"+ type = "bloom_filter()"+ granularity = 1+ }+ index "emails_bloom_filter" {+ expr = "emails"+ type = "bloom_filter()"+ granularity = 1+ }+ engine "replicated_aggregating_merge_tree" {+ zoo_path = "/clickhouse/tables/{shard}/posthog.raw_sessions_v3"+ replica_name = "{replica}"+ }+ }++ table "sharded_session_replay_embeddings" {+ order_by = ["toDate(generation_timestamp)", "team_id", "session_id"]+ partition_by = "toYYYYMM(generation_timestamp)"+ ttl = "toDate(generation_timestamp) + toIntervalYear(1)"+ settings = {+ index_granularity = "512"+ }+ column "session_id" {+ type = "String"+ }+ column "team_id" {+ type = "Int64"+ }+ column "embeddings" {+ type = "Array(Float32)"+ }+ column "generation_timestamp" {+ type = "DateTime64(6, 'UTC')"+ default = "now('UTC')"+ }+ column "source_type" {+ type = "LowCardinality(String)"+ }+ column "input" {+ type = "String"+ }+ engine "replicated_merge_tree" {+ zoo_path = "/clickhouse/tables/{shard}/posthog.session_replay_embeddings"+ replica_name = "{replica}"+ }+ }++ 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"+ }+ column "team_id" {+ type = "Int64"+ }+ column "distinct_id" {+ type = "String"+ }+ column "min_first_timestamp" {+ type = "SimpleAggregateFunction(min, DateTime64(6, 'UTC'))"+ }+ 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)"+ }+ column "keypress_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "mouse_activity_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "active_milliseconds" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "console_log_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "console_warn_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "console_error_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "size" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "message_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "event_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "snapshot_source" {+ type = "AggregateFunction(argMin, LowCardinality(Nullable(String)), DateTime64(6, 'UTC'))"+ }+ column "snapshot_library" {+ type = "AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC'))"+ }+ column "_timestamp" {+ type = "SimpleAggregateFunction(max, DateTime)"+ }+ column "is_deleted" {+ type = "SimpleAggregateFunction(max, UInt8)"+ default = "0"+ }+ column "ai_tags_fixed" {+ type = "SimpleAggregateFunction(groupUniqArrayArray, Array(String))"+ }+ column "ai_tags_freeform" {+ type = "SimpleAggregateFunction(groupUniqArrayArray, Array(String))"+ }+ column "ai_highlighted" {+ type = "SimpleAggregateFunction(max, UInt8)"+ default = "0"+ }+ column "surfacing_score" {+ type = "SimpleAggregateFunction(max, Nullable(Float32))"+ }+ column "retention_period_days" {+ type = "SimpleAggregateFunction(max, Nullable(Int64))"+ }+ engine "replicated_aggregating_merge_tree" {+ zoo_path = "/clickhouse/tables/{shard}/posthog.session_replay_events"+ replica_name = "{replica}"+ }+ }++ table "sharded_session_replay_features" {+ order_by = ["team_id", "session_id"]+ partition_by = "toYYYYMM(min_first_timestamp)"+ settings = {+ index_granularity = "512"+ }+ column "session_id" {+ type = "String"+ }+ column "team_id" {+ type = "Int64"+ }+ column "distinct_id" {+ type = "String"+ }+ column "min_first_timestamp" {+ type = "SimpleAggregateFunction(min, DateTime64(6, 'UTC'))"+ }+ column "max_last_timestamp" {+ type = "SimpleAggregateFunction(max, DateTime64(6, 'UTC'))"+ }+ column "event_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "mouse_position_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "mouse_sum_x" {+ type = "SimpleAggregateFunction(sum, Float64)"+ }+ column "mouse_sum_x_squared" {+ type = "SimpleAggregateFunction(sum, Float64)"+ }+ column "mouse_sum_y" {+ type = "SimpleAggregateFunction(sum, Float64)"+ }+ column "mouse_sum_y_squared" {+ type = "SimpleAggregateFunction(sum, Float64)"+ }+ column "mouse_distance_traveled" {+ type = "SimpleAggregateFunction(sum, Float64)"+ }+ column "mouse_direction_change_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "mouse_velocity_sum" {+ type = "SimpleAggregateFunction(sum, Float64)"+ }+ column "mouse_velocity_sum_of_squares" {+ type = "SimpleAggregateFunction(sum, Float64)"+ }+ column "mouse_velocity_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "scroll_event_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "total_scroll_magnitude" {+ type = "SimpleAggregateFunction(sum, Float64)"+ }+ column "scroll_direction_reversal_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "rapid_scroll_reversal_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "scroll_to_top_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "click_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "keypress_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "mouse_activity_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "rage_click_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "dead_click_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "backspace_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "inter_action_gap_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "inter_action_gap_sum_ms" {+ type = "SimpleAggregateFunction(sum, Float64)"+ }+ column "inter_action_gap_sum_of_squares_ms" {+ type = "SimpleAggregateFunction(sum, Float64)"+ }+ column "max_idle_gap_ms" {+ type = "SimpleAggregateFunction(max, Float64)"+ }+ column "long_idle_gap_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "quick_back_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "page_visit_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "unique_url_count" {+ type = "AggregateFunction(uniqCombined(12), String)"+ }+ column "login_path_visit_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "signup_path_visit_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "checkout_path_visit_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "cart_path_visit_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "billing_path_visit_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "settings_path_visit_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "account_path_visit_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "error_path_visit_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "not_found_path_visit_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "admin_path_visit_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "dashboard_path_visit_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "onboarding_path_visit_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "cancel_path_visit_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "refund_path_visit_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "console_error_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "console_error_after_click_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "console_warn_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "network_request_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "network_failed_request_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "network_4xx_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "network_5xx_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "network_request_duration_sum" {+ type = "SimpleAggregateFunction(sum, Float64)"+ }+ column "network_request_duration_sum_of_squares" {+ type = "SimpleAggregateFunction(sum, Float64)"+ }+ column "network_request_duration_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "mutation_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "viewport_resize_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "touch_event_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "max_scroll_y" {+ type = "SimpleAggregateFunction(max, Float64)"+ }+ column "unique_click_target_count" {+ type = "AggregateFunction(uniqCombined(12), Int64)"+ }+ column "unique_form_field_count" {+ type = "AggregateFunction(uniqCombined(12), Int64)"+ }+ column "text_selection_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "selection_copy_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "is_deleted" {+ type = "SimpleAggregateFunction(max, UInt8)"+ default = "0"+ }+ engine "replicated_aggregating_merge_tree" {+ zoo_path = "/clickhouse/tables/{shard}/posthog.session_replay_features"+ replica_name = "{replica}"+ }+ }++ table "sharded_sessions" {+ order_by = ["toStartOfDay(min_timestamp)", "team_id", "session_id"]+ partition_by = "toYYYYMM(min_timestamp)"+ settings = {+ index_granularity = "512"+ }+ column "session_id" {+ type = "String"+ }+ column "team_id" {+ type = "Int64"+ }+ column "distinct_id" {+ type = "SimpleAggregateFunction(any, String)"+ }+ column "min_timestamp" {+ type = "SimpleAggregateFunction(min, DateTime64(6, 'UTC'))"+ }+ column "max_timestamp" {+ type = "SimpleAggregateFunction(max, DateTime64(6, 'UTC'))"+ }+ column "urls" {+ type = "SimpleAggregateFunction(groupUniqArrayArray, Array(String))"+ }+ column "entry_url" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "exit_url" {+ type = "AggregateFunction(argMax, String, DateTime64(6, 'UTC'))"+ }+ column "initial_referring_domain" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_utm_source" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_utm_campaign" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_utm_medium" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_utm_term" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_utm_content" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_gclid" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_gad_source" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_gclsrc" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_dclid" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_gbraid" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_wbraid" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_fbclid" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_msclkid" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_twclid" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_li_fat_id" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_mc_cid" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_igshid" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_ttclid" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_epik" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_qclid" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_sccid" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "event_count_map" {+ type = "SimpleAggregateFunction(sumMap, Map(String, Int64))"+ }+ column "pageview_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "autocapture_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ engine "replicated_aggregating_merge_tree" {+ zoo_path = "/clickhouse/tables/{shard}/posthog.sessions"+ replica_name = "{replica}"+ }+ }++ table "sharded_tophog" {+ order_by = ["pipeline", "lane", "metric", "timestamp", "key"]+ partition_by = "toYYYYMMDD(timestamp)"+ ttl = "toDate(timestamp) + toIntervalDay(30)"+ settings = {+ index_granularity = "8192"+ ttl_only_drop_parts = "1"+ }+ column "timestamp" {+ type = "DateTime64(6, 'UTC')"+ }+ column "metric" {+ type = "LowCardinality(String)"+ }+ column "type" {+ type = "LowCardinality(String)"+ default = "'sum'"+ }+ column "key" {+ type = "Map(LowCardinality(String), String)"+ }+ column "value" {+ type = "Float64"+ }+ column "count" {+ type = "UInt64"+ default = "0"+ }+ column "pipeline" {+ type = "LowCardinality(String)"+ }+ column "lane" {+ type = "LowCardinality(String)"+ }+ column "labels" {+ type = "Map(LowCardinality(String), String)"+ }+ engine "replicated_merge_tree" {+ zoo_path = "/clickhouse/tables/{shard}/posthog.tophog"+ replica_name = "{replica}"+ }+ }++ table "sharded_usage_report_events_preagg" {+ order_by = ["date", "team_id", "person_mode", "lib", "event"]+ partition_by = "date"+ ttl = "date + toIntervalDay(14)"+ settings = {+ index_granularity = "8192"+ ttl_only_drop_parts = "1"+ }+ column "date" {+ type = "Date"+ }+ column "team_id" {+ type = "Int64"+ }+ column "person_mode" {+ type = "LowCardinality(String)"+ }+ column "lib" {+ type = "LowCardinality(String)"+ }+ column "event" {+ type = "String"+ }+ column "distinct_events_unique" {+ type = "AggregateFunction(uniqExact, Tuple(UInt64, UInt64, UInt64))"+ }+ column "event_count" {+ type = "AggregateFunction(sum, UInt64)"+ }+ engine "replicated_aggregating_merge_tree" {+ zoo_path = "/clickhouse/tables/{shard}/posthog.sharded_usage_report_events_preagg"+ replica_name = "{replica}"+ }+ }++ table "sharded_web_bot_definition" {+ order_by = ["id"]+ settings = {+ index_granularity = "8192"+ }+ column "id" {+ type = "UInt64"+ }+ column "parent_id" {+ type = "UInt64"+ }+ column "regexp" {+ type = "String"+ }+ column "keys" {+ type = "Array(String)"+ }+ column "values" {+ type = "Array(String)"+ }+ engine "replicated_merge_tree" {+ zoo_path = "/clickhouse/tables/{shard}/posthog.sharded_web_bot_definition"+ replica_name = "{replica}"+ }+ }++ table "sharded_web_bounces_dimensional_preaggregated" {+ order_by = ["team_id", "job_id", "period_bucket", "host", "device_type", "entry_pathname", "end_pathname", "browser", "os", "viewport_width", "viewport_height", "referring_domain", "utm_source", "utm_medium", "utm_campaign", "utm_term", "utm_content", "country_code", "city_name", "region_code", "region_name", "has_gclid", "has_gad_source_paid_search", "has_fbclid", "mat_metadata_backend", "mat_metadata_loggedIn"]+ partition_by = "toYYYYMMDD(expires_at)"+ ttl = "toDateTime(expires_at)"+ settings = {+ allow_nullable_key = "1"+ index_granularity = "8192"+ ttl_only_drop_parts = "1"+ }+ column "team_id" {+ type = "Int64"+ }+ column "job_id" {+ type = "UUID"+ }+ column "period_bucket" {+ type = "DateTime"+ }+ column "host" {+ type = "String"+ }+ column "device_type" {+ type = "String"+ }+ column "entry_pathname" {+ type = "String"+ }+ column "end_pathname" {+ type = "String"+ }+ column "browser" {+ type = "String"+ }+ column "os" {+ type = "String"+ }+ column "viewport_width" {+ type = "Int64"+ }+ column "viewport_height" {+ type = "Int64"+ }+ column "referring_domain" {+ type = "String"+ }+ column "utm_source" {+ type = "String"+ }+ column "utm_medium" {+ type = "String"+ }+ column "utm_campaign" {+ type = "String"+ }+ column "utm_term" {+ type = "String"+ }+ column "utm_content" {+ type = "String"+ }+ column "country_code" {+ type = "String"+ }+ column "city_name" {+ type = "String"+ }+ column "region_code" {+ type = "String"+ }+ column "region_name" {+ type = "String"+ }+ column "has_gclid" {+ type = "Bool"+ }+ column "has_gad_source_paid_search" {+ type = "Bool"+ }+ column "has_fbclid" {+ type = "Bool"+ }+ column "mat_metadata_backend" {+ type = "Nullable(String)"+ }+ column "mat_metadata_loggedIn" {+ type = "Nullable(Bool)"+ }+ column "persons_uniq_state" {+ type = "AggregateFunction(uniq, UUID)"+ }+ column "sessions_uniq_state" {+ type = "AggregateFunction(uniq, String)"+ }+ column "pageviews_count_state" {+ type = "AggregateFunction(sum, Int64)"+ }+ column "bounces_count_state" {+ type = "AggregateFunction(sum, Int64)"+ }+ column "total_session_duration_state" {+ type = "AggregateFunction(sum, Int64)"+ }+ column "total_session_count_state" {+ type = "AggregateFunction(sum, Int64)"+ }+ column "computed_at" {+ type = "DateTime64(6, 'UTC')"+ default = "now()"+ }+ column "expires_at" {+ type = "DateTime64(6, 'UTC')"+ default = "now() + toIntervalDay(7)"+ }+ engine "replicated_replacing_merge_tree" {+ zoo_path = "/clickhouse/tables/{shard}/posthog.web_bounces_dimensional_preaggregated"+ replica_name = "{replica}"+ version_column = "computed_at"+ }+ }++ table "sharded_web_goals_preaggregated" {+ order_by = ["team_id", "job_id", "action_id", "time_window_start"]+ partition_by = "toYYYYMMDD(expires_at)"+ ttl = "toDateTime(expires_at)"+ settings = {+ index_granularity = "8192"+ ttl_only_drop_parts = "1"+ }+ column "team_id" {+ type = "Int64"+ }+ column "job_id" {+ type = "UUID"+ }+ column "time_window_start" {+ type = "DateTime64(6, 'UTC')"+ }+ column "action_id" {+ type = "Int64"+ }+ column "count_state" {+ type = "AggregateFunction(sum, Int64)"+ }+ column "unique_persons_state" {+ type = "AggregateFunction(uniq, UUID)"+ }+ column "computed_at" {+ type = "DateTime64(6, 'UTC')"+ default = "now()"+ }+ column "expires_at" {+ type = "DateTime64(6, 'UTC')"+ default = "now() + toIntervalDay(7)"+ }+ engine "replicated_replacing_merge_tree" {+ zoo_path = "/clickhouse/tables/{shard}/posthog.web_goals_preaggregated"+ replica_name = "{replica}"+ version_column = "computed_at"+ }+ }++ table "sharded_web_overview_preaggregated" {+ order_by = ["team_id", "job_id", "time_window_start"]+ partition_by = "toYYYYMMDD(expires_at)"+ ttl = "toDateTime(expires_at)"+ settings = {+ index_granularity = "8192"+ ttl_only_drop_parts = "1"+ }+ column "team_id" {+ type = "Int64"+ }+ column "job_id" {+ type = "UUID"+ }+ column "time_window_start" {+ type = "DateTime64(6, 'UTC')"+ }+ column "uniq_users_state" {+ type = "AggregateFunction(uniq, UUID)"+ }+ column "uniq_sessions_state" {+ type = "AggregateFunction(uniq, String)"+ }+ column "sum_pageviews_state" {+ type = "AggregateFunction(sum, Int64)"+ }+ column "avg_duration_state" {+ type = "AggregateFunction(avg, Float64)"+ }+ column "avg_bounce_state" {+ type = "AggregateFunction(avg, Int64)"+ }+ column "computed_at" {+ type = "DateTime64(6, 'UTC')"+ default = "now()"+ }+ column "expires_at" {+ type = "DateTime64(6, 'UTC')"+ default = "now() + toIntervalDay(7)"+ }+ engine "replicated_replacing_merge_tree" {+ zoo_path = "/clickhouse/tables/{shard}/posthog.web_overview_preaggregated"+ replica_name = "{replica}"+ version_column = "computed_at"+ }+ }++ table "sharded_web_stats_dimensional_preaggregated" {+ order_by = ["team_id", "job_id", "period_bucket", "host", "device_type", "pathname", "entry_pathname", "end_pathname", "browser", "os", "viewport_width", "viewport_height", "referring_domain", "utm_source", "utm_medium", "utm_campaign", "utm_term", "utm_content", "country_code", "city_name", "region_code", "region_name", "has_gclid", "has_gad_source_paid_search", "has_fbclid", "mat_metadata_backend", "mat_metadata_loggedIn"]+ partition_by = "toYYYYMMDD(expires_at)"+ ttl = "toDateTime(expires_at)"+ settings = {+ allow_nullable_key = "1"+ index_granularity = "8192"+ ttl_only_drop_parts = "1"+ }+ column "team_id" {+ type = "Int64"+ }+ column "job_id" {+ type = "UUID"+ }+ column "period_bucket" {+ type = "DateTime"+ }+ column "host" {+ type = "String"+ }+ column "device_type" {+ type = "String"+ }+ column "pathname" {+ type = "String"+ }+ column "entry_pathname" {+ type = "String"+ }+ column "end_pathname" {+ type = "String"+ }+ column "browser" {+ type = "String"+ }+ column "os" {+ type = "String"+ }+ column "viewport_width" {+ type = "Int64"+ }+ column "viewport_height" {+ type = "Int64"+ }+ column "referring_domain" {+ type = "String"+ }+ column "utm_source" {+ type = "String"+ }+ column "utm_medium" {+ type = "String"+ }+ column "utm_campaign" {+ type = "String"+ }+ column "utm_term" {+ type = "String"+ }+ column "utm_content" {+ type = "String"+ }+ column "country_code" {+ type = "String"+ }+ column "city_name" {+ type = "String"+ }+ column "region_code" {+ type = "String"+ }+ column "region_name" {+ type = "String"+ }+ column "has_gclid" {+ type = "Bool"+ }+ column "has_gad_source_paid_search" {+ type = "Bool"+ }+ column "has_fbclid" {+ type = "Bool"+ }+ column "mat_metadata_backend" {+ type = "Nullable(String)"+ }+ column "mat_metadata_loggedIn" {+ type = "Nullable(Bool)"+ }+ column "persons_uniq_state" {+ type = "AggregateFunction(uniq, UUID)"+ }+ column "sessions_uniq_state" {+ type = "AggregateFunction(uniq, String)"+ }+ column "pageviews_count_state" {+ type = "AggregateFunction(sum, Int64)"+ }+ column "computed_at" {+ type = "DateTime64(6, 'UTC')"+ default = "now()"+ }+ column "expires_at" {+ type = "DateTime64(6, 'UTC')"+ default = "now() + toIntervalDay(7)"+ }+ engine "replicated_replacing_merge_tree" {+ zoo_path = "/clickhouse/tables/{shard}/posthog.web_stats_dimensional_preaggregated"+ replica_name = "{replica}"+ version_column = "computed_at"+ }+ }++ table "sharded_web_stats_frustration_preaggregated" {+ order_by = ["team_id", "job_id", "breakdown_value", "time_window_start"]+ partition_by = "toYYYYMMDD(expires_at)"+ ttl = "toDateTime(expires_at)"+ settings = {+ index_granularity = "8192"+ ttl_only_drop_parts = "1"+ }+ column "team_id" {+ type = "Int64"+ }+ column "job_id" {+ type = "UUID"+ }+ column "time_window_start" {+ type = "DateTime64(6, 'UTC')"+ }+ column "breakdown_value" {+ type = "String"+ }+ column "sum_rage_clicks_state" {+ type = "AggregateFunction(sum, Int64)"+ }+ column "sum_dead_clicks_state" {+ type = "AggregateFunction(sum, Int64)"+ }+ column "sum_errors_state" {+ type = "AggregateFunction(sum, Int64)"+ }+ column "computed_at" {+ type = "DateTime64(6, 'UTC')"+ default = "now()"+ }+ column "expires_at" {+ type = "DateTime64(6, 'UTC')"+ default = "now() + toIntervalDay(7)"+ }+ engine "replicated_replacing_merge_tree" {+ zoo_path = "/clickhouse/tables/{shard}/posthog.web_stats_frustration_preaggregated"+ replica_name = "{replica}"+ version_column = "computed_at"+ }+ }++ table "sharded_web_stats_paths_preaggregated" {+ order_by = ["team_id", "job_id", "breakdown_value", "time_window_start"]+ partition_by = "toYYYYMMDD(expires_at)"+ ttl = "toDateTime(expires_at)"+ settings = {+ index_granularity = "8192"+ ttl_only_drop_parts = "1"+ }+ column "team_id" {+ type = "Int64"+ }+ column "job_id" {+ type = "UUID"+ }+ column "time_window_start" {+ type = "DateTime64(6, 'UTC')"+ }+ column "breakdown_value" {+ type = "String"+ }+ column "uniq_users_state" {+ type = "AggregateFunction(uniq, UUID)"+ }+ column "sum_pageviews_state" {+ type = "AggregateFunction(sum, Int64)"+ }+ column "avg_bounce_state" {+ type = "AggregateFunction(avg, Nullable(Float64))"+ }+ column "computed_at" {+ type = "DateTime64(6, 'UTC')"+ default = "now()"+ }+ column "expires_at" {+ type = "DateTime64(6, 'UTC')"+ default = "now() + toIntervalDay(7)"+ }+ engine "replicated_replacing_merge_tree" {+ zoo_path = "/clickhouse/tables/{shard}/posthog.web_stats_paths_preaggregated"+ replica_name = "{replica}"+ version_column = "computed_at"+ }+ }++ table "sharded_web_stats_paths_preaggregated_pathkey" {+ order_by = ["team_id", "time_window_start", "breakdown_value", "job_id"]+ partition_by = "toYYYYMMDD(expires_at)"+ ttl = "toDateTime(expires_at)"+ settings = {+ index_granularity = "8192"+ ttl_only_drop_parts = "1"+ }+ column "team_id" {+ type = "Int64"+ }+ column "job_id" {+ type = "UUID"+ }+ column "time_window_start" {+ type = "DateTime64(6, 'UTC')"+ }+ column "breakdown_value" {+ type = "String"+ }+ column "uniq_users_state" {+ type = "AggregateFunction(uniq, UUID)"+ }+ column "sum_pageviews_state" {+ type = "AggregateFunction(sum, Int64)"+ }+ column "avg_bounce_state" {+ type = "AggregateFunction(avg, Nullable(Float64))"+ }+ column "computed_at" {+ type = "DateTime64(6, 'UTC')"+ default = "now()"+ }+ column "expires_at" {+ type = "DateTime64(6, 'UTC')"+ default = "now() + toIntervalDay(7)"+ }+ engine "replicated_replacing_merge_tree" {+ zoo_path = "/clickhouse/tables/{shard}/posthog.web_stats_paths_preaggregated_pathkey"+ replica_name = "{replica}"+ version_column = "computed_at"+ }+ }++ table "sharded_web_stats_preaggregated" {+ order_by = ["team_id", "job_id", "breakdown_by", "time_window_start", "breakdown_value"]+ partition_by = "toYYYYMMDD(expires_at)"+ ttl = "toDateTime(expires_at)"+ settings = {+ index_granularity = "8192"+ ttl_only_drop_parts = "1"+ }+ column "team_id" {+ type = "Int64"+ }+ column "job_id" {+ type = "UUID"+ }+ column "time_window_start" {+ type = "DateTime64(6, 'UTC')"+ }+ column "breakdown_by" {+ type = "String"+ }+ column "breakdown_value" {+ type = "String"+ }+ column "uniq_users_state" {+ type = "AggregateFunction(uniq, UUID)"+ }+ column "sum_pageviews_state" {+ type = "AggregateFunction(sum, Int64)"+ }+ column "computed_at" {+ type = "DateTime64(6, 'UTC')"+ default = "now()"+ }+ column "expires_at" {+ type = "DateTime64(6, 'UTC')"+ default = "now() + toIntervalDay(7)"+ }+ engine "replicated_replacing_merge_tree" {+ zoo_path = "/clickhouse/tables/{shard}/posthog.web_stats_preaggregated"+ replica_name = "{replica}"+ version_column = "computed_at"+ }+ }++ table "sharded_web_vitals_paths_preaggregated" {+ order_by = ["team_id", "job_id", "time_window_start", "path"]+ partition_by = "toYYYYMMDD(expires_at)"+ ttl = "toDateTime(expires_at)"+ settings = {+ index_granularity = "8192"+ ttl_only_drop_parts = "1"+ }+ column "team_id" {+ type = "Int64"+ }+ column "job_id" {+ type = "UUID"+ }+ column "time_window_start" {+ type = "DateTime64(6, 'UTC')"+ }+ column "path" {+ type = "String"+ }+ column "inp_quantiles_state" {+ type = "AggregateFunction(quantiles(0.75, 0.9, 0.99), Float64)"+ }+ column "lcp_quantiles_state" {+ type = "AggregateFunction(quantiles(0.75, 0.9, 0.99), Float64)"+ }+ column "cls_quantiles_state" {+ type = "AggregateFunction(quantiles(0.75, 0.9, 0.99), Float64)"+ }+ column "fcp_quantiles_state" {+ type = "AggregateFunction(quantiles(0.75, 0.9, 0.99), Float64)"+ }+ column "computed_at" {+ type = "DateTime64(6, 'UTC')"+ default = "now()"+ }+ column "expires_at" {+ type = "DateTime64(6, 'UTC')"+ default = "now() + toIntervalDay(7)"+ }+ engine "replicated_replacing_merge_tree" {+ zoo_path = "/clickhouse/tables/{shard}/posthog.web_vitals_paths_preaggregated"+ replica_name = "{replica}"+ version_column = "computed_at"+ }+ }++ table "tophog" {+ column "timestamp" {+ type = "DateTime64(6, 'UTC')"+ }+ column "metric" {+ type = "LowCardinality(String)"+ }+ column "type" {+ type = "LowCardinality(String)"+ default = "'sum'"+ }+ column "key" {+ type = "Map(LowCardinality(String), String)"+ }+ column "value" {+ type = "Float64"+ }+ column "count" {+ type = "UInt64"+ default = "0"+ }+ column "pipeline" {+ type = "LowCardinality(String)"+ }+ column "lane" {+ type = "LowCardinality(String)"+ }+ column "labels" {+ type = "Map(LowCardinality(String), String)"+ }+ engine "distributed" {+ cluster_name = "posthog"+ remote_database = "posthog"+ remote_table = "sharded_tophog"+ sharding_key = "cityHash64(toString(key))"+ }+ }++ table "trace_attributes" {+ order_by = ["team_id", "attribute_type", "time_bucket", "resource_fingerprint", "attribute_key", "attribute_value"]+ partition_by = "toDate(original_expiry_time_bucket)"+ ttl = "original_expiry_time_bucket"+ settings = {+ index_granularity = "8192"+ }+ column "team_id" {+ type = "Int32"+ }+ column "original_expiry_time_bucket" {+ type = "DateTime64(0)"+ }+ column "time_bucket" {+ type = "DateTime64(0)"+ }+ column "service_name" {+ type = "LowCardinality(String)"+ }+ column "resource_fingerprint" {+ type = "UInt64"+ default = "0"+ }+ column "attribute_key" {+ type = "LowCardinality(String)"+ }+ column "attribute_value" {+ type = "String"+ }+ column "attribute_type" {+ type = "LowCardinality(String)"+ }+ column "attribute_count" {+ type = "SimpleAggregateFunction(sum, UInt64)"+ }+ index "idx_attribute_key" {+ expr = "attribute_key"+ type = "bloom_filter(0.01)"+ granularity = 4+ }+ index "idx_attribute_value" {+ expr = "attribute_value"+ type = "bloom_filter(0.01)"+ granularity = 4+ }+ index "idx_attribute_key_n3" {+ expr = "attribute_key"+ type = "ngrambf_v1(3, 32768, 3, 0)"+ granularity = 4+ }+ index "idx_attribute_value_n3" {+ expr = "attribute_value"+ type = "ngrambf_v1(3, 32768, 3, 0)"+ granularity = 4+ }+ engine "replicated_merge_tree" {+ zoo_path = "/clickhouse/tables/noshard/posthog.trace_attributes"+ replica_name = "{replica}-{shard}"+ }+ }++ table "trace_attributes2" {+ order_by = ["team_id", "attribute_type", "time_bucket", "resource_fingerprint", "attribute_key", "attribute_value"]+ partition_by = "toDate(original_expiry_time_bucket)"+ ttl = "original_expiry_time_bucket"+ settings = {+ index_granularity = "8192"+ }+ column "team_id" {+ type = "Int32"+ }+ column "original_expiry_time_bucket" {+ type = "DateTime64(0)"+ }+ column "time_bucket" {+ type = "DateTime64(0)"+ }+ column "service_name" {+ type = "LowCardinality(String)"+ }+ column "resource_fingerprint" {+ type = "UInt64"+ default = "0"+ }+ column "attribute_key" {+ type = "LowCardinality(String)"+ }+ column "attribute_value" {+ type = "String"+ }+ column "attribute_type" {+ type = "LowCardinality(String)"+ }+ column "attribute_count" {+ type = "SimpleAggregateFunction(sum, UInt64)"+ }+ index "idx_attribute_key" {+ expr = "attribute_key"+ type = "bloom_filter(0.01)"+ granularity = 4+ }+ index "idx_attribute_value" {+ expr = "attribute_value"+ type = "bloom_filter(0.01)"+ granularity = 4+ }+ index "idx_attribute_key_n3" {+ expr = "attribute_key"+ type = "ngrambf_v1(3, 32768, 3, 0)"+ granularity = 4+ }+ index "idx_attribute_value_n3" {+ expr = "attribute_value"+ type = "ngrambf_v1(3, 32768, 3, 0)"+ granularity = 4+ }+ engine "replicated_aggregating_merge_tree" {+ zoo_path = "/clickhouse/tables/noshard/posthog.trace_attributes2"+ replica_name = "{replica}-{shard}"+ }+ }++ table "trace_attributes_distributed" {+ column "team_id" {+ type = "Int32"+ }+ column "original_expiry_time_bucket" {+ type = "DateTime64(0)"+ }+ column "time_bucket" {+ type = "DateTime64(0)"+ }+ column "service_name" {+ type = "LowCardinality(String)"+ }+ column "resource_fingerprint" {+ type = "UInt64"+ default = "0"+ }+ column "attribute_key" {+ type = "LowCardinality(String)"+ }+ column "attribute_value" {+ type = "String"+ }+ column "attribute_type" {+ type = "LowCardinality(String)"+ }+ column "attribute_count" {+ type = "SimpleAggregateFunction(sum, UInt64)"+ }+ engine "distributed" {+ cluster_name = "posthog_single_shard"+ remote_database = "posthog"+ remote_table = "trace_attributes"+ }+ }++ table "trace_spans" {+ order_by = ["team_id", "time_bucket", "service_name", "resource_fingerprint", "status_code", "name", "timestamp"]+ partition_by = "toDate(original_expiry_timestamp)"+ ttl = "original_expiry_timestamp"+ settings = {+ allow_part_offset_column_in_projections = "1"+ index_granularity = "8192"+ index_granularity_bytes = "104857600"+ map_serialization_version = "with_buckets"+ ttl_only_drop_parts = "1"+ }+ column "time_bucket" {+ type = "DateTime"+ materialized = "toStartOfInterval(timestamp, toIntervalHour(4))"+ }+ column "original_expiry_timestamp" {+ type = "DateTime64(6)"+ }+ column "uuid" {+ type = "String"+ }+ column "team_id" {+ type = "Int32"+ }+ column "trace_id" {+ type = "String"+ }+ column "span_id" {+ type = "String"+ }+ column "parent_span_id" {+ type = "String"+ }+ column "is_root_span" {+ type = "Bool"+ materialized = "replaceAll(trimRight(parent_span_id, '='), 'A', '') = ''"+ }+ column "trace_state" {+ type = "String"+ }+ column "name" {+ type = "LowCardinality(String)"+ }+ column "kind" {+ type = "Int8"+ }+ column "flags" {+ type = "UInt32"+ }+ column "timestamp" {+ type = "DateTime64(6)"+ }+ column "end_time" {+ type = "DateTime64(6)"+ }+ column "observed_timestamp" {+ type = "DateTime64(6)"+ }+ column "created_at" {+ type = "DateTime64(6)"+ materialized = "now()"+ }+ column "duration_nano" {+ type = "UInt64"+ materialized = "toUInt64(dateDiff('microsecond', timestamp, end_time)) * 1000"+ }+ column "status_code" {+ type = "Int16"+ }+ column "service_name" {+ type = "LowCardinality(String)"+ }+ column "resource_attributes" {+ type = "Map(LowCardinality(String), String)"+ }+ column "resource_fingerprint" {+ type = "UInt64"+ materialized = "cityHash64(resource_attributes)"+ }+ column "instrumentation_scope" {+ type = "String"+ }+ column "attributes_map_str" {+ type = "Map(LowCardinality(String), String)"+ }+ column "attributes" {+ type = "Map(LowCardinality(String), String)"+ alias = "mapApply((k, v) -> (left(k, -5), v), attributes_map_str)"+ }+ column "attributes_map_float" {+ type = "Map(LowCardinality(String), Float64)"+ materialized = "mapFilter((k, v) -> (v IS NOT NULL), mapApply((k, v) -> (concat(left(k, -5), '__float'), toFloat64OrNull(v)), attributes_map_str))"+ }+ column "attributes_map_datetime" {+ type = "Map(LowCardinality(String), DateTime64(6))"+ materialized = "mapFilter((k, v) -> (v IS NOT NULL), mapApply((k, v) -> (concat(left(k, -5), '__datetime'), parseDateTimeBestEffortOrNull(v, 6)), attributes_map_str))"+ }+ column "dropped_attributes_count" {+ type = "UInt32"+ }+ column "dropped_events_count" {+ type = "UInt32"+ }+ column "dropped_links_count" {+ type = "UInt32"+ }+ column "events" {+ type = "Array(String)"+ }+ column "links" {+ type = "Array(String)"+ }+ column "_partition" {+ type = "UInt32"+ }+ column "_topic" {+ type = "String"+ }+ column "_offset" {+ type = "UInt64"+ }+ column "_bytes_uncompressed" {+ type = "UInt64"+ }+ column "_bytes_compressed" {+ type = "UInt64"+ }+ column "_record_count" {+ type = "UInt64"+ }+ index "idx_name" {+ expr = "name"+ type = "ngrambf_v1(4, 5000, 2, 0)"+ granularity = 16+ }+ index "idx_kind" {+ expr = "kind"+ type = "minmax"+ granularity = 4+ }+ index "idx_duration" {+ expr = "duration_nano"+ type = "minmax"+ granularity = 1+ }+ index "idx_status_code" {+ expr = "status_code"+ type = "minmax"+ granularity = 1+ }+ index "idx_timestamp_minmax" {+ expr = "timestamp"+ type = "minmax"+ granularity = 1+ }+ index "idx_observed_minmax" {+ expr = "observed_timestamp"+ type = "minmax"+ granularity = 1+ }+ index "idx_attributes_str_keys" {+ expr = "mapKeys(attributes_map_str)"+ type = "bloom_filter(0.01)"+ granularity = 16+ }+ index "idx_attributes_str_values" {+ expr = "mapValues(attributes_map_str)"+ type = "bloom_filter(0.001)"+ granularity = 16+ }+ index "idx_trace_bloom_part" {+ expr = "trace_id"+ type = "bloom_filter(0.00001)"+ granularity = 99999+ }+ index "idx_span_id_bloom_part" {+ expr = "span_id"+ type = "bloom_filter(0.00001)"+ granularity = 99999+ }+ projection "projection_aggregate_counts" {+ query = <<SQL+SELECT+ team_id,+ time_bucket,+ toStartOfMinute(timestamp),+ service_name,+ resource_fingerprint,+ is_root_span,+ count() AS event_count+GROUP BY+ team_id, time_bucket, toStartOfMinute(timestamp), service_name, resource_fingerprint, is_root_span+SQL++ }+ projection "projection_index_span_id" {+ query = <<SQL+SELECT _part_offset+ORDER BY span_id+SQL++ }+ projection "projection_index_trace_id" {+ query = <<SQL+SELECT _part_offset+ORDER BY trace_id+SQL++ }+ engine "replicated_merge_tree" {+ zoo_path = "/clickhouse/tables/noshard/posthog.trace_spans"+ replica_name = "{replica}-{shard}"+ }+ }++ table "trace_spans_distributed" {+ column "time_bucket" {+ type = "DateTime"+ materialized = "toStartOfInterval(timestamp, toIntervalHour(4))"+ }+ column "original_expiry_timestamp" {+ type = "DateTime64(6)"+ }+ column "uuid" {+ type = "String"+ }+ column "team_id" {+ type = "Int32"+ }+ column "trace_id" {+ type = "String"+ }+ column "span_id" {+ type = "String"+ }+ column "parent_span_id" {+ type = "String"+ }+ column "is_root_span" {+ type = "Bool"+ materialized = "replaceAll(trimRight(parent_span_id, '='), 'A', '') = ''"+ }+ column "trace_state" {+ type = "String"+ }+ column "name" {+ type = "LowCardinality(String)"+ }+ column "kind" {+ type = "Int8"+ }+ column "flags" {+ type = "UInt32"+ }+ column "timestamp" {+ type = "DateTime64(6)"+ }+ column "end_time" {+ type = "DateTime64(6)"+ }+ column "observed_timestamp" {+ type = "DateTime64(6)"+ }+ column "created_at" {+ type = "DateTime64(6)"+ materialized = "now()"+ }+ column "duration_nano" {+ type = "UInt64"+ materialized = "toUInt64(dateDiff('microsecond', timestamp, end_time)) * 1000"+ }+ column "status_code" {+ type = "Int16"+ }+ column "service_name" {+ type = "LowCardinality(String)"+ }+ column "resource_attributes" {+ type = "Map(LowCardinality(String), String)"+ }+ column "resource_fingerprint" {+ type = "UInt64"+ materialized = "cityHash64(resource_attributes)"+ }+ column "instrumentation_scope" {+ type = "String"+ }+ column "attributes_map_str" {+ type = "Map(LowCardinality(String), String)"+ }+ column "attributes" {+ type = "Map(LowCardinality(String), String)"+ alias = "mapApply((k, v) -> (left(k, -5), v), attributes_map_str)"+ }+ column "attributes_map_float" {+ type = "Map(LowCardinality(String), Float64)"+ materialized = "mapFilter((k, v) -> (v IS NOT NULL), mapApply((k, v) -> (concat(left(k, -5), '__float'), toFloat64OrNull(v)), attributes_map_str))"+ }+ column "attributes_map_datetime" {+ type = "Map(LowCardinality(String), DateTime64(6))"+ materialized = "mapFilter((k, v) -> (v IS NOT NULL), mapApply((k, v) -> (concat(left(k, -5), '__datetime'), parseDateTimeBestEffortOrNull(v, 6)), attributes_map_str))"+ }+ column "dropped_attributes_count" {+ type = "UInt32"+ }+ column "dropped_events_count" {+ type = "UInt32"+ }+ column "dropped_links_count" {+ type = "UInt32"+ }+ column "events" {+ type = "Array(String)"+ }+ column "links" {+ type = "Array(String)"+ }+ column "_partition" {+ type = "UInt32"+ }+ column "_topic" {+ type = "String"+ }+ column "_offset" {+ type = "UInt64"+ }+ column "_bytes_uncompressed" {+ type = "UInt64"+ }+ column "_bytes_compressed" {+ type = "UInt64"+ }+ column "_record_count" {+ type = "UInt64"+ }+ engine "distributed" {+ cluster_name = "posthog_single_shard"+ remote_database = "posthog"+ remote_table = "trace_spans"+ }+ }++ table "trace_spans_kafka_metrics" {+ order_by = ["_topic", "_partition"]+ settings = {+ index_granularity = "8192"+ }+ column "_partition" {+ type = "UInt32"+ }+ column "_topic" {+ type = "String"+ }+ column "max_offset" {+ type = "SimpleAggregateFunction(max, UInt64)"+ }+ column "max_observed_timestamp" {+ type = "SimpleAggregateFunction(max, DateTime64(9))"+ }+ column "max_timestamp" {+ type = "SimpleAggregateFunction(max, DateTime64(9))"+ }+ column "max_created_at" {+ type = "SimpleAggregateFunction(max, DateTime64(9))"+ }+ column "max_lag" {+ type = "SimpleAggregateFunction(max, UInt64)"+ }+ engine "replicated_merge_tree" {+ zoo_path = "/clickhouse/tables/noshard/posthog.trace_spans_kafka_metrics"+ replica_name = "{replica}-{shard}"+ }+ }++ table "usage_report_events_preagg" {+ column "date" {+ type = "Date"+ }+ column "team_id" {+ type = "Int64"+ }+ column "person_mode" {+ type = "LowCardinality(String)"+ }+ column "lib" {+ type = "LowCardinality(String)"+ }+ column "event" {+ type = "String"+ }+ column "distinct_events_unique" {+ type = "AggregateFunction(uniqExact, Tuple(UInt64, UInt64, UInt64))"+ }+ column "event_count" {+ type = "AggregateFunction(sum, UInt64)"+ }+ engine "distributed" {+ cluster_name = "aux"+ remote_database = "posthog"+ remote_table = "sharded_usage_report_events_preagg"+ sharding_key = "sipHash64(date)"+ }+ }++ table "web_bot_definition" {+ column "id" {+ type = "UInt64"+ }+ column "parent_id" {+ type = "UInt64"+ }+ column "regexp" {+ type = "String"+ }+ column "keys" {+ type = "Array(String)"+ }+ column "values" {+ type = "Array(String)"+ }+ engine "distributed" {+ cluster_name = "aux"+ remote_database = "posthog"+ remote_table = "sharded_web_bot_definition"+ sharding_key = "sipHash64(id)"+ }+ }++ table "web_bounces_dimensional_preaggregated" {+ column "team_id" {+ type = "Int64"+ }+ column "job_id" {+ type = "UUID"+ }+ column "period_bucket" {+ type = "DateTime"+ }+ column "host" {+ type = "String"+ }+ column "device_type" {+ type = "String"+ }+ column "entry_pathname" {+ type = "String"+ }+ column "end_pathname" {+ type = "String"+ }+ column "browser" {+ type = "String"+ }+ column "os" {+ type = "String"+ }+ column "viewport_width" {+ type = "Int64"+ }+ column "viewport_height" {+ type = "Int64"+ }+ column "referring_domain" {+ type = "String"+ }+ column "utm_source" {+ type = "String"+ }+ column "utm_medium" {+ type = "String"+ }+ column "utm_campaign" {+ type = "String"+ }+ column "utm_term" {+ type = "String"+ }+ column "utm_content" {+ type = "String"+ }+ column "country_code" {+ type = "String"+ }+ column "city_name" {+ type = "String"+ }+ column "region_code" {+ type = "String"+ }+ column "region_name" {+ type = "String"+ }+ column "has_gclid" {+ type = "Bool"+ }+ column "has_gad_source_paid_search" {+ type = "Bool"+ }+ column "has_fbclid" {+ type = "Bool"+ }+ column "mat_metadata_backend" {+ type = "Nullable(String)"+ }+ column "mat_metadata_loggedIn" {+ type = "Nullable(Bool)"+ }+ column "persons_uniq_state" {+ type = "AggregateFunction(uniq, UUID)"+ }+ column "sessions_uniq_state" {+ type = "AggregateFunction(uniq, String)"+ }+ column "pageviews_count_state" {+ type = "AggregateFunction(sum, Int64)"+ }+ column "bounces_count_state" {+ type = "AggregateFunction(sum, Int64)"+ }+ column "total_session_duration_state" {+ type = "AggregateFunction(sum, Int64)"+ }+ column "total_session_count_state" {+ type = "AggregateFunction(sum, Int64)"+ }+ column "computed_at" {+ type = "DateTime64(6, 'UTC')"+ default = "now()"+ }+ column "expires_at" {+ type = "DateTime64(6, 'UTC')"+ default = "now() + toIntervalDay(7)"+ }+ engine "distributed" {+ cluster_name = "aux"+ remote_database = "posthog"+ remote_table = "sharded_web_bounces_dimensional_preaggregated"+ sharding_key = "sipHash64(job_id)"+ }+ }++ table "web_goals_preaggregated" {+ column "team_id" {+ type = "Int64"+ }+ column "job_id" {+ type = "UUID"+ }+ column "time_window_start" {+ type = "DateTime64(6, 'UTC')"+ }+ column "action_id" {+ type = "Int64"+ }+ column "count_state" {+ type = "AggregateFunction(sum, Int64)"+ }+ column "unique_persons_state" {+ type = "AggregateFunction(uniq, UUID)"+ }+ column "computed_at" {+ type = "DateTime64(6, 'UTC')"+ default = "now()"+ }+ column "expires_at" {+ type = "DateTime64(6, 'UTC')"+ default = "now() + toIntervalDay(7)"+ }+ engine "distributed" {+ cluster_name = "aux"+ remote_database = "posthog"+ remote_table = "sharded_web_goals_preaggregated"+ sharding_key = "sipHash64(job_id)"+ }+ }++ table "web_overview_preaggregated" {+ column "team_id" {+ type = "Int64"+ }+ column "job_id" {+ type = "UUID"+ }+ column "time_window_start" {+ type = "DateTime64(6, 'UTC')"+ }+ column "uniq_users_state" {+ type = "AggregateFunction(uniq, UUID)"+ }+ column "uniq_sessions_state" {+ type = "AggregateFunction(uniq, String)"+ }+ column "sum_pageviews_state" {+ type = "AggregateFunction(sum, Int64)"+ }+ column "avg_duration_state" {+ type = "AggregateFunction(avg, Float64)"+ }+ column "avg_bounce_state" {+ type = "AggregateFunction(avg, Int64)"+ }+ column "computed_at" {+ type = "DateTime64(6, 'UTC')"+ default = "now()"+ }+ column "expires_at" {+ type = "DateTime64(6, 'UTC')"+ default = "now() + toIntervalDay(7)"+ }+ engine "distributed" {+ cluster_name = "aux"+ remote_database = "posthog"+ remote_table = "sharded_web_overview_preaggregated"+ sharding_key = "sipHash64(job_id)"+ }+ }++ table "web_pre_aggregated_bounces" {+ order_by = ["team_id", "period_bucket", "host", "device_type", "entry_pathname", "end_pathname", "browser", "os", "viewport_width", "viewport_height", "referring_domain", "utm_source", "utm_medium", "utm_campaign", "utm_term", "utm_content", "country_code", "city_name", "region_code", "region_name", "has_gclid", "has_gad_source_paid_search", "has_fbclid", "mat_metadata_loggedIn", "mat_metadata_backend"]+ partition_by = "toYYYYMMDD(period_bucket)"+ settings = {+ index_granularity = "8192"+ }+ column "period_bucket" {+ type = "DateTime"+ }+ column "team_id" {+ type = "UInt64"+ }+ column "host" {+ type = "String"+ }+ column "device_type" {+ type = "String"+ }+ column "entry_pathname" {+ type = "String"+ }+ column "end_pathname" {+ type = "String"+ }+ column "browser" {+ type = "String"+ }+ column "os" {+ type = "String"+ }+ column "viewport_width" {+ type = "Int64"+ }+ column "viewport_height" {+ type = "Int64"+ }+ column "referring_domain" {+ type = "String"+ }+ column "utm_source" {+ type = "String"+ }+ column "utm_medium" {+ type = "String"+ }+ column "utm_campaign" {+ type = "String"+ }+ column "utm_term" {+ type = "String"+ }+ column "utm_content" {+ type = "String"+ }+ column "country_code" {+ type = "String"+ }+ column "city_name" {+ type = "String"+ }+ column "region_code" {+ type = "String"+ }+ column "region_name" {+ type = "String"+ }+ column "has_gclid" {+ type = "Bool"+ }+ column "has_gad_source_paid_search" {+ type = "Bool"+ }+ column "has_fbclid" {+ type = "Bool"+ }+ column "mat_metadata_loggedIn" {+ type = "Bool"+ }+ column "mat_metadata_backend" {+ type = "String"+ }+ column "persons_uniq_state" {+ type = "AggregateFunction(uniq, UUID)"+ }+ column "sessions_uniq_state" {+ type = "AggregateFunction(uniq, String)"+ }+ column "pageviews_count_state" {+ type = "AggregateFunction(sum, UInt64)"+ }+ column "bounces_count_state" {+ type = "AggregateFunction(sum, UInt64)"+ }+ column "total_session_duration_state" {+ type = "AggregateFunction(sum, Int64)"+ }+ column "total_session_count_state" {+ type = "AggregateFunction(sum, UInt64)"+ }+ engine "replicated_merge_tree" {+ zoo_path = "/clickhouse/tables/noshard/posthog.web_pre_aggregated_bounces"+ replica_name = "{replica}-{shard}"+ }+ }++ table "web_pre_aggregated_bounces_staging" {+ order_by = ["team_id", "period_bucket", "host", "device_type", "entry_pathname", "end_pathname", "browser", "os", "viewport_width", "viewport_height", "referring_domain", "utm_source", "utm_medium", "utm_campaign", "utm_term", "utm_content", "country_code", "city_name", "region_code", "region_name", "has_gclid", "has_gad_source_paid_search", "has_fbclid", "mat_metadata_loggedIn", "mat_metadata_backend"]+ partition_by = "toYYYYMMDD(period_bucket)"+ settings = {+ index_granularity = "8192"+ }+ column "period_bucket" {+ type = "DateTime"+ }+ column "team_id" {+ type = "UInt64"+ }+ column "host" {+ type = "String"+ }+ column "device_type" {+ type = "String"+ }+ column "entry_pathname" {+ type = "String"+ }+ column "end_pathname" {+ type = "String"+ }+ column "browser" {+ type = "String"+ }+ column "os" {+ type = "String"+ }+ column "viewport_width" {+ type = "Int64"+ }+ column "viewport_height" {+ type = "Int64"+ }+ column "referring_domain" {+ type = "String"+ }+ column "utm_source" {+ type = "String"+ }+ column "utm_medium" {+ type = "String"+ }+ column "utm_campaign" {+ type = "String"+ }+ column "utm_term" {+ type = "String"+ }+ column "utm_content" {+ type = "String"+ }+ column "country_code" {+ type = "String"+ }+ column "city_name" {+ type = "String"+ }+ column "region_code" {+ type = "String"+ }+ column "region_name" {+ type = "String"+ }+ column "has_gclid" {+ type = "Bool"+ }+ column "has_gad_source_paid_search" {+ type = "Bool"+ }+ column "has_fbclid" {+ type = "Bool"+ }+ column "mat_metadata_loggedIn" {+ type = "Bool"+ }+ column "mat_metadata_backend" {+ type = "String"+ }+ column "persons_uniq_state" {+ type = "AggregateFunction(uniq, UUID)"+ }+ column "sessions_uniq_state" {+ type = "AggregateFunction(uniq, String)"+ }+ column "pageviews_count_state" {+ type = "AggregateFunction(sum, UInt64)"+ }+ column "bounces_count_state" {+ type = "AggregateFunction(sum, UInt64)"+ }+ column "total_session_duration_state" {+ type = "AggregateFunction(sum, Int64)"+ }+ column "total_session_count_state" {+ type = "AggregateFunction(sum, UInt64)"+ }+ engine "replicated_merge_tree" {+ zoo_path = "/clickhouse/tables/noshard/posthog.web_pre_aggregated_bounces_staging"+ replica_name = "{replica}-{shard}"+ }+ }++ table "web_pre_aggregated_stats" {+ order_by = ["team_id", "period_bucket", "host", "device_type", "pathname", "entry_pathname", "end_pathname", "browser", "os", "viewport_width", "viewport_height", "referring_domain", "utm_source", "utm_medium", "utm_campaign", "utm_term", "utm_content", "country_code", "city_name", "region_code", "region_name", "has_gclid", "has_gad_source_paid_search", "has_fbclid", "mat_metadata_loggedIn", "mat_metadata_backend"]+ partition_by = "toYYYYMMDD(period_bucket)"+ settings = {+ index_granularity = "8192"+ }+ column "period_bucket" {+ type = "DateTime"+ }+ column "team_id" {+ type = "UInt64"+ }+ column "host" {+ type = "String"+ }+ column "device_type" {+ type = "String"+ }+ column "pathname" {+ type = "String"+ }+ column "entry_pathname" {+ type = "String"+ }+ column "end_pathname" {+ type = "String"+ }+ column "browser" {+ type = "String"+ }+ column "os" {+ type = "String"+ }+ column "viewport_width" {+ type = "Int64"+ }+ column "viewport_height" {+ type = "Int64"+ }+ column "referring_domain" {+ type = "String"+ }+ column "utm_source" {+ type = "String"+ }+ column "utm_medium" {+ type = "String"+ }+ column "utm_campaign" {+ type = "String"+ }+ column "utm_term" {+ type = "String"+ }+ column "utm_content" {+ type = "String"+ }+ column "country_code" {+ type = "String"+ }+ column "city_name" {+ type = "String"+ }+ column "region_code" {+ type = "String"+ }+ column "region_name" {+ type = "String"+ }+ column "has_gclid" {+ type = "Bool"+ }+ column "has_gad_source_paid_search" {+ type = "Bool"+ }+ column "has_fbclid" {+ type = "Bool"+ }+ column "mat_metadata_loggedIn" {+ type = "Bool"+ }+ column "mat_metadata_backend" {+ type = "String"+ }+ column "persons_uniq_state" {+ type = "AggregateFunction(uniq, UUID)"+ }+ column "sessions_uniq_state" {+ type = "AggregateFunction(uniq, String)"+ }+ column "pageviews_count_state" {+ type = "AggregateFunction(sum, UInt64)"+ }+ engine "replicated_merge_tree" {+ zoo_path = "/clickhouse/tables/noshard/posthog.web_pre_aggregated_stats"+ replica_name = "{replica}-{shard}"+ }+ }++ table "web_pre_aggregated_stats_staging" {+ order_by = ["team_id", "period_bucket", "host", "device_type", "pathname", "entry_pathname", "end_pathname", "browser", "os", "viewport_width", "viewport_height", "referring_domain", "utm_source", "utm_medium", "utm_campaign", "utm_term", "utm_content", "country_code", "city_name", "region_code", "region_name", "has_gclid", "has_gad_source_paid_search", "has_fbclid", "mat_metadata_loggedIn", "mat_metadata_backend"]+ partition_by = "toYYYYMMDD(period_bucket)"+ settings = {+ index_granularity = "8192"+ }+ column "period_bucket" {+ type = "DateTime"+ }+ column "team_id" {+ type = "UInt64"+ }+ column "host" {+ type = "String"+ }+ column "device_type" {+ type = "String"+ }+ column "pathname" {+ type = "String"+ }+ column "entry_pathname" {+ type = "String"+ }+ column "end_pathname" {+ type = "String"+ }+ column "browser" {+ type = "String"+ }+ column "os" {+ type = "String"+ }+ column "viewport_width" {+ type = "Int64"+ }+ column "viewport_height" {+ type = "Int64"+ }+ column "referring_domain" {+ type = "String"+ }+ column "utm_source" {+ type = "String"+ }+ column "utm_medium" {+ type = "String"+ }+ column "utm_campaign" {+ type = "String"+ }+ column "utm_term" {+ type = "String"+ }+ column "utm_content" {+ type = "String"+ }+ column "country_code" {+ type = "String"+ }+ column "city_name" {+ type = "String"+ }+ column "region_code" {+ type = "String"+ }+ column "region_name" {+ type = "String"+ }+ column "has_gclid" {+ type = "Bool"+ }+ column "has_gad_source_paid_search" {+ type = "Bool"+ }+ column "has_fbclid" {+ type = "Bool"+ }+ column "mat_metadata_loggedIn" {+ type = "Bool"+ }+ column "mat_metadata_backend" {+ type = "String"+ }+ column "persons_uniq_state" {+ type = "AggregateFunction(uniq, UUID)"+ }+ column "sessions_uniq_state" {+ type = "AggregateFunction(uniq, String)"+ }+ column "pageviews_count_state" {+ type = "AggregateFunction(sum, UInt64)"+ }+ engine "replicated_merge_tree" {+ zoo_path = "/clickhouse/tables/noshard/posthog.web_pre_aggregated_stats_staging"+ replica_name = "{replica}-{shard}"+ }+ }++ table "web_pre_aggregated_teams" {+ order_by = ["team_id"]+ settings = {+ index_granularity = "8192"+ }+ column "team_id" {+ type = "UInt64"+ }+ column "enabled_by" {+ type = "String"+ default = "'system'"+ }+ column "version" {+ type = "UInt32"+ default = "toUnixTimestamp(now())"+ }+ engine "replicated_replacing_merge_tree" {+ zoo_path = "/clickhouse/tables/noshard/posthog.web_analytics_team_selection"+ replica_name = "{replica}-{shard}"+ version_column = "version"+ }+ }++ table "web_stats_dimensional_preaggregated" {+ column "team_id" {+ type = "Int64"+ }+ column "job_id" {+ type = "UUID"+ }+ column "period_bucket" {+ type = "DateTime"+ }+ column "host" {+ type = "String"+ }+ column "device_type" {+ type = "String"+ }+ column "pathname" {+ type = "String"+ }+ column "entry_pathname" {+ type = "String"+ }+ column "end_pathname" {+ type = "String"+ }+ column "browser" {+ type = "String"+ }+ column "os" {+ type = "String"+ }+ column "viewport_width" {+ type = "Int64"+ }+ column "viewport_height" {+ type = "Int64"+ }+ column "referring_domain" {+ type = "String"+ }+ column "utm_source" {+ type = "String"+ }+ column "utm_medium" {+ type = "String"+ }+ column "utm_campaign" {+ type = "String"+ }+ column "utm_term" {+ type = "String"+ }+ column "utm_content" {+ type = "String"+ }+ column "country_code" {+ type = "String"+ }+ column "city_name" {+ type = "String"+ }+ column "region_code" {+ type = "String"+ }+ column "region_name" {+ type = "String"+ }+ column "has_gclid" {+ type = "Bool"+ }+ column "has_gad_source_paid_search" {+ type = "Bool"+ }+ column "has_fbclid" {+ type = "Bool"+ }+ column "mat_metadata_backend" {+ type = "Nullable(String)"+ }+ column "mat_metadata_loggedIn" {+ type = "Nullable(Bool)"+ }+ column "persons_uniq_state" {+ type = "AggregateFunction(uniq, UUID)"+ }+ column "sessions_uniq_state" {+ type = "AggregateFunction(uniq, String)"+ }+ column "pageviews_count_state" {+ type = "AggregateFunction(sum, Int64)"+ }+ column "computed_at" {+ type = "DateTime64(6, 'UTC')"+ default = "now()"+ }+ column "expires_at" {+ type = "DateTime64(6, 'UTC')"+ default = "now() + toIntervalDay(7)"+ }+ engine "distributed" {+ cluster_name = "aux"+ remote_database = "posthog"+ remote_table = "sharded_web_stats_dimensional_preaggregated"+ sharding_key = "sipHash64(job_id)"+ }+ }++ table "web_stats_frustration_preaggregated" {+ column "team_id" {+ type = "Int64"+ }+ column "job_id" {+ type = "UUID"+ }+ column "time_window_start" {+ type = "DateTime64(6, 'UTC')"+ }+ column "breakdown_value" {+ type = "String"+ }+ column "sum_rage_clicks_state" {+ type = "AggregateFunction(sum, Int64)"+ }+ column "sum_dead_clicks_state" {+ type = "AggregateFunction(sum, Int64)"+ }+ column "sum_errors_state" {+ type = "AggregateFunction(sum, Int64)"+ }+ column "computed_at" {+ type = "DateTime64(6, 'UTC')"+ default = "now()"+ }+ column "expires_at" {+ type = "DateTime64(6, 'UTC')"+ default = "now() + toIntervalDay(7)"+ }+ engine "distributed" {+ cluster_name = "aux"+ remote_database = "posthog"+ remote_table = "sharded_web_stats_frustration_preaggregated"+ sharding_key = "sipHash64(job_id)"+ }+ }++ table "web_stats_paths_preaggregated" {+ column "team_id" {+ type = "Int64"+ }+ column "job_id" {+ type = "UUID"+ }+ column "time_window_start" {+ type = "DateTime64(6, 'UTC')"+ }+ column "breakdown_value" {+ type = "String"+ }+ column "uniq_users_state" {+ type = "AggregateFunction(uniq, UUID)"+ }+ column "sum_pageviews_state" {+ type = "AggregateFunction(sum, Int64)"+ }+ column "avg_bounce_state" {+ type = "AggregateFunction(avg, Nullable(Float64))"+ }+ column "computed_at" {+ type = "DateTime64(6, 'UTC')"+ default = "now()"+ }+ column "expires_at" {+ type = "DateTime64(6, 'UTC')"+ default = "now() + toIntervalDay(7)"+ }+ engine "distributed" {+ cluster_name = "aux"+ remote_database = "posthog"+ remote_table = "sharded_web_stats_paths_preaggregated"+ sharding_key = "sipHash64(job_id)"+ }+ }++ table "web_stats_paths_preaggregated_pathkey" {+ column "team_id" {+ type = "Int64"+ }+ column "job_id" {+ type = "UUID"+ }+ column "time_window_start" {+ type = "DateTime64(6, 'UTC')"+ }+ column "breakdown_value" {+ type = "String"+ }+ column "uniq_users_state" {+ type = "AggregateFunction(uniq, UUID)"+ }+ column "sum_pageviews_state" {+ type = "AggregateFunction(sum, Int64)"+ }+ column "avg_bounce_state" {+ type = "AggregateFunction(avg, Nullable(Float64))"+ }+ column "computed_at" {+ type = "DateTime64(6, 'UTC')"+ default = "now()"+ }+ column "expires_at" {+ type = "DateTime64(6, 'UTC')"+ default = "now() + toIntervalDay(7)"+ }+ engine "distributed" {+ cluster_name = "aux"+ remote_database = "posthog"+ remote_table = "sharded_web_stats_paths_preaggregated_pathkey"+ sharding_key = "sipHash64(breakdown_value)"+ }+ }++ table "web_stats_preaggregated" {+ column "team_id" {+ type = "Int64"+ }+ column "job_id" {+ type = "UUID"+ }+ column "time_window_start" {+ type = "DateTime64(6, 'UTC')"+ }+ column "breakdown_by" {+ type = "String"+ }+ column "breakdown_value" {+ type = "String"+ }+ column "uniq_users_state" {+ type = "AggregateFunction(uniq, UUID)"+ }+ column "sum_pageviews_state" {+ type = "AggregateFunction(sum, Int64)"+ }+ column "computed_at" {+ type = "DateTime64(6, 'UTC')"+ default = "now()"+ }+ column "expires_at" {+ type = "DateTime64(6, 'UTC')"+ default = "now() + toIntervalDay(7)"+ }+ engine "distributed" {+ cluster_name = "aux"+ remote_database = "posthog"+ remote_table = "sharded_web_stats_preaggregated"+ sharding_key = "sipHash64(job_id)"+ }+ }++ table "web_vitals_paths_preaggregated" {+ column "team_id" {+ type = "Int64"+ }+ column "job_id" {+ type = "UUID"+ }+ column "time_window_start" {+ type = "DateTime64(6, 'UTC')"+ }+ column "path" {+ type = "String"+ }+ column "inp_quantiles_state" {+ type = "AggregateFunction(quantiles(0.75, 0.9, 0.99), Float64)"+ }+ column "lcp_quantiles_state" {+ type = "AggregateFunction(quantiles(0.75, 0.9, 0.99), Float64)"+ }+ column "cls_quantiles_state" {+ type = "AggregateFunction(quantiles(0.75, 0.9, 0.99), Float64)"+ }+ column "fcp_quantiles_state" {+ type = "AggregateFunction(quantiles(0.75, 0.9, 0.99), Float64)"+ }+ column "computed_at" {+ type = "DateTime64(6, 'UTC')"+ default = "now()"+ }+ column "expires_at" {+ type = "DateTime64(6, 'UTC')"+ default = "now() + toIntervalDay(7)"+ }+ engine "distributed" {+ cluster_name = "aux"+ remote_database = "posthog"+ remote_table = "sharded_web_vitals_paths_preaggregated"+ sharding_key = "sipHash64(job_id)"+ }+ }++ table "writable_app_metrics" {+ column "team_id" {+ type = "Int64"+ }+ column "timestamp" {+ type = "DateTime64(6, 'UTC')"+ }+ column "plugin_config_id" {+ type = "Int64"+ }+ column "category" {+ type = "LowCardinality(String)"+ }+ column "job_id" {+ type = "String"+ }+ column "successes" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "successes_on_retry" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "failures" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "error_uuid" {+ type = "UUID"+ }+ column "error_type" {+ type = "String"+ }+ column "error_details" {+ type = "String"+ codec = "ZSTD(3)"+ }+ column "_timestamp" {+ type = "DateTime"+ }+ column "_offset" {+ type = "UInt64"+ }+ column "_partition" {+ type = "UInt64"+ }+ engine "distributed" {+ cluster_name = "posthog"+ remote_database = "posthog"+ remote_table = "sharded_app_metrics"+ sharding_key = "rand()"+ }+ }++ table "writable_app_metrics2" {+ column "team_id" {+ type = "Int64"+ }+ column "timestamp" {+ type = "DateTime64(6, 'UTC')"+ }+ column "app_source" {+ type = "LowCardinality(String)"+ }+ column "app_source_id" {+ type = "String"+ }+ column "instance_id" {+ type = "String"+ }+ column "metric_kind" {+ type = "LowCardinality(String)"+ }+ column "metric_name" {+ type = "LowCardinality(String)"+ }+ column "count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "_timestamp" {+ type = "DateTime"+ }+ column "_offset" {+ type = "UInt64"+ }+ column "_partition" {+ type = "UInt64"+ }+ engine "distributed" {+ cluster_name = "posthog"+ remote_database = "posthog"+ remote_table = "sharded_app_metrics2"+ sharding_key = "rand()"+ }+ }++ table "writable_cohort_membership" {+ column "team_id" {+ type = "Int64"+ }+ column "cohort_id" {+ type = "Int64"+ }+ column "person_id" {+ type = "UUID"+ }+ column "status" {+ type = "Enum8('entered'=1, 'left'=2)"+ }+ column "last_updated" {+ type = "DateTime64(6)"+ default = "now64()"+ }+ engine "distributed" {+ cluster_name = "posthog_single_shard"+ remote_database = "posthog"+ remote_table = "cohort_membership"+ }+ }++ table "writable_distinct_id_usage" {+ column "team_id" {+ type = "Int64"+ }+ column "distinct_id" {+ type = "String"+ }+ column "minute" {+ type = "DateTime"+ }+ column "event_count" {+ type = "UInt64"+ }+ engine "distributed" {+ cluster_name = "posthog"+ remote_database = "posthog"+ remote_table = "sharded_distinct_id_usage"+ sharding_key = "sipHash64(distinct_id)"+ }+ }++ table "writable_duplicate_events" {+ column "team_id" {+ type = "Int64"+ }+ column "distinct_id" {+ type = "String"+ }+ column "event" {+ type = "String"+ }+ column "source_uuid" {+ type = "UUID"+ }+ column "duplicate_uuid" {+ type = "UUID"+ }+ column "similarity_score" {+ type = "Float64"+ }+ column "dedup_type" {+ type = "LowCardinality(String)"+ }+ column "is_confirmed" {+ type = "UInt8"+ }+ column "reason" {+ type = "Nullable(String)"+ }+ column "version" {+ type = "String"+ }+ column "different_property_count" {+ type = "UInt32"+ }+ column "properties_similarity" {+ type = "Float64"+ }+ column "source_message" {+ type = "String"+ }+ column "duplicate_message" {+ type = "String"+ }+ column "distinct_fields" {+ type = "Array(Tuple(field_name String, original_value String, new_value String))"+ }+ column "inserted_at" {+ type = "DateTime64(3, 'UTC')"+ }+ column "_timestamp" {+ type = "DateTime"+ }+ column "_offset" {+ type = "UInt64"+ }+ column "_partition" {+ type = "UInt64"+ }+ engine "distributed" {+ cluster_name = "posthog_single_shard"+ remote_database = "posthog"+ remote_table = "duplicate_events"+ }+ }++ table "writable_error_tracking_fingerprint_issue_state" {+ column "team_id" {+ type = "Int64"+ }+ column "fingerprint" {+ type = "String"+ }+ column "issue_id" {+ type = "UUID"+ }+ column "issue_name" {+ type = "Nullable(String)"+ }+ column "issue_description" {+ type = "Nullable(String)"+ }+ column "issue_status" {+ type = "String"+ }+ column "issue_severity" {+ type = "Nullable(String)"+ }+ column "assigned_user_id" {+ type = "Nullable(Int64)"+ }+ column "assigned_role_id" {+ type = "Nullable(UUID)"+ }+ column "first_seen" {+ type = "DateTime64(3, 'UTC')"+ }+ column "is_deleted" {+ type = "Int8"+ }+ column "version" {+ type = "Int64"+ }+ column "_timestamp" {+ type = "DateTime"+ }+ column "_offset" {+ type = "UInt64"+ }+ column "_partition" {+ type = "UInt64"+ }+ engine "distributed" {+ cluster_name = "aux"+ remote_database = "posthog"+ remote_table = "raw_error_tracking_fingerprint_issue_state"+ }+ }++ table "writable_error_tracking_issue_fingerprint_embeddings" {+ column "team_id" {+ type = "Int64"+ }+ column "model_name" {+ type = "LowCardinality(String)"+ }+ column "embedding_version" {+ type = "Int64"+ }+ column "fingerprint" {+ type = "String"+ }+ column "inserted_at" {+ type = "DateTime64(3, 'UTC')"+ }+ column "embeddings" {+ type = "Array(Float64)"+ }+ column "_timestamp" {+ type = "DateTime"+ }+ column "_offset" {+ type = "UInt64"+ }+ column "_partition" {+ type = "UInt64"+ }+ engine "distributed" {+ cluster_name = "posthog_single_shard"+ remote_database = "posthog"+ remote_table = "error_tracking_issue_fingerprint_embeddings"+ }+ }++ table "writable_error_tracking_issue_fingerprint_overrides" {+ column "team_id" {+ type = "Int64"+ }+ column "fingerprint" {+ type = "String"+ }+ column "issue_id" {+ type = "UUID"+ }+ column "is_deleted" {+ type = "Int8"+ }+ column "version" {+ type = "Int64"+ }+ column "_timestamp" {+ type = "DateTime"+ }+ column "_offset" {+ type = "UInt64"+ }+ column "_partition" {+ type = "UInt64"+ }+ engine "distributed" {+ cluster_name = "posthog_single_shard"+ remote_database = "posthog"+ remote_table = "error_tracking_issue_fingerprint_overrides"+ }+ }++ table "writable_events" {+ column "uuid" {+ type = "UUID"+ }+ column "event" {+ type = "String"+ }+ column "properties" {+ type = "String"+ codec = "ZSTD(3)"+ }+ column "timestamp" {+ type = "DateTime64(6, 'UTC')"+ }+ column "team_id" {+ type = "Int64"+ }+ column "distinct_id" {+ type = "String"+ }+ column "elements_chain" {+ type = "String"+ }+ column "created_at" {+ type = "DateTime64(6, 'UTC')"+ }+ column "person_id" {+ type = "UUID"+ }+ column "person_created_at" {+ type = "DateTime64(3)"+ }+ column "person_properties" {+ type = "String"+ codec = "ZSTD(3)"+ }+ column "group0_properties" {+ type = "String"+ codec = "ZSTD(3)"+ }+ column "group1_properties" {+ type = "String"+ codec = "ZSTD(3)"+ }+ column "group2_properties" {+ type = "String"+ codec = "ZSTD(3)"+ }+ column "group3_properties" {+ type = "String"+ codec = "ZSTD(3)"+ }+ column "group4_properties" {+ type = "String"+ codec = "ZSTD(3)"+ }+ column "group0_created_at" {+ type = "DateTime64(3)"+ }+ column "group1_created_at" {+ type = "DateTime64(3)"+ }+ column "group2_created_at" {+ type = "DateTime64(3)"+ }+ column "group3_created_at" {+ type = "DateTime64(3)"+ }+ column "group4_created_at" {+ type = "DateTime64(3)"+ }+ column "person_mode" {+ type = "Enum8('full'=0, 'propertyless'=1, 'force_upgrade'=2)"+ }+ column "historical_migration" {+ type = "Bool"+ }+ column "dmat_string_0" {+ type = "Nullable(String)"+ }+ column "dmat_string_1" {+ type = "Nullable(String)"+ }+ column "dmat_string_2" {+ type = "Nullable(String)"+ }+ column "dmat_string_3" {+ type = "Nullable(String)"+ }+ column "dmat_string_4" {+ type = "Nullable(String)"+ }+ column "dmat_string_5" {+ type = "Nullable(String)"+ }+ column "dmat_string_6" {+ type = "Nullable(String)"+ }+ column "dmat_string_7" {+ type = "Nullable(String)"+ }+ column "dmat_string_8" {+ type = "Nullable(String)"+ }+ column "dmat_string_9" {+ type = "Nullable(String)"+ }+ column "_timestamp" {+ type = "DateTime"+ }+ column "_offset" {+ type = "UInt64"+ }+ column "consumer_breadcrumbs" {+ type = "Array(String)"+ }+ engine "distributed" {+ cluster_name = "posthog"+ remote_database = "posthog"+ remote_table = "sharded_events"+ sharding_key = "sipHash64(distinct_id)"+ }+ }++ table "writable_events_dead_letter_queue" {+ column "id" {+ type = "UUID"+ }+ column "event_uuid" {+ type = "UUID"+ }+ column "event" {+ type = "String"+ }+ column "properties" {+ type = "String"+ }+ column "distinct_id" {+ type = "String"+ }+ column "team_id" {+ type = "Int64"+ }+ column "elements_chain" {+ type = "String"+ }+ column "created_at" {+ type = "DateTime64(6, 'UTC')"+ }+ column "ip" {+ type = "String"+ }+ column "site_url" {+ type = "String"+ }+ column "now" {+ type = "DateTime64(6, 'UTC')"+ }+ column "raw_payload" {+ type = "String"+ }+ column "error_timestamp" {+ type = "DateTime64(6, 'UTC')"+ }+ column "error_location" {+ type = "String"+ }+ column "error" {+ type = "String"+ }+ column "tags" {+ type = "Array(String)"+ }+ column "_timestamp" {+ type = "DateTime"+ }+ column "_offset" {+ type = "UInt64"+ }+ engine "distributed" {+ cluster_name = "posthog_single_shard"+ remote_database = "posthog"+ remote_table = "events_dead_letter_queue"+ }+ }++ table "writable_events_json" {+ column "uuid" {+ type = "UUID"+ }+ column "event" {+ type = "String"+ }+ column "properties" {+ type = "JSON(max_dynamic_types=8, max_dynamic_paths=256, `$active_feature_flags` Array(String), `$ai_experiment_id` Nullable(String), `$ai_http_status` Nullable(String), `$ai_is_error` Nullable(String), `$ai_model` Nullable(String), `$ai_parent_id` Nullable(String), `$ai_prompt_name` Nullable(String), `$ai_provider` Nullable(String), `$ai_session_id` Nullable(String), `$ai_span_id` Nullable(String), `$ai_total_cost_usd` Nullable(String), `$ai_trace_id` Nullable(String), `$anon_distinct_id` Nullable(String), `$app_build` Nullable(String), `$app_namespace` Nullable(String), `$app_version` Nullable(String), `$browser` Nullable(String), `$browser_version` Nullable(String), `$current_url` Nullable(String), `$device` Nullable(String), `$device_id` Nullable(String), `$device_model` Nullable(String), `$device_type` Nullable(String), `$el_text` Nullable(String), `$event_type` Nullable(String), `$exception_fingerprint` Nullable(String), `$exception_functions` Array(String), `$exception_issue_id` Nullable(String), `$exception_sources` Array(String), `$exception_types` Array(String), `$exception_values` Array(String), `$feature_flag` Nullable(String), `$feature_flag_payloads` Nullable(String), `$feature_flag_response` Nullable(String), `$geoip_city_name` Nullable(String), `$geoip_country_code` Nullable(String), `$geoip_country_name` Nullable(String), `$geoip_subdivision_1_code` Nullable(String), `$group_0` Nullable(String), `$group_1` Nullable(String), `$group_2` Nullable(String), `$group_3` Nullable(String), `$group_4` Nullable(String), `$groups` Nullable(String), `$host` Nullable(String), `$initial_pathname` Nullable(String), `$initial_referrer` Nullable(String), `$initial_referring_domain` Nullable(String), `$ip` Nullable(String), `$is_identified` Nullable(String), `$lib` Nullable(String), `$lib_custom_api_host` Nullable(String), `$lib_version` Nullable(String), `$lib_version__minor` Nullable(String), `$os` Nullable(String), `$os_name` Nullable(String), `$os_version` Nullable(String), `$pathname` Nullable(String), `$prev_pageview_max_content_percentage` Nullable(String), `$prev_pageview_max_scroll_percentage` Nullable(String), `$prev_pageview_pathname` Nullable(String), `$process_person_profile` Nullable(String), `$referrer` Nullable(String), `$referring_domain` Nullable(String), `$screen_height` Nullable(String), `$screen_name` Nullable(String), `$screen_width` Nullable(String), `$sent_at` Nullable(String), `$session_id` Nullable(String), `$survey_id` Nullable(String), `$survey_response` Nullable(String), `$survey_response_1` Nullable(String), `$time` Nullable(String), `$user_id` Nullable(String), `$viewport_height` Nullable(String), `$viewport_width` Nullable(String), `$web_vitals_CLS_value` Nullable(String), `$web_vitals_FCP_value` Nullable(String), `$web_vitals_INP_value` Nullable(String), `$web_vitals_LCP_value` Nullable(String), `$window_id` Nullable(String))"+ }+ column "timestamp" {+ type = "DateTime64(6, 'UTC')"+ }+ column "team_id" {+ type = "Int64"+ }+ column "distinct_id" {+ type = "String"+ }+ column "elements_hash" {+ type = "String"+ default = "''"+ }+ column "created_at" {+ type = "DateTime64(6, 'UTC')"+ }+ column "_timestamp" {+ type = "DateTime"+ }+ column "_offset" {+ type = "UInt64"+ }+ column "elements_chain" {+ type = "String"+ }+ column "person_id" {+ type = "UUID"+ }+ column "person_properties" {+ type = "JSON(max_dynamic_types=6, max_dynamic_paths=32, `$app_version` Nullable(String), `$browser` Nullable(String), `$current_url` Nullable(String), `$geoip_continent_name` Nullable(String), `$geoip_country_code` Nullable(String), `$geoip_country_name` Nullable(String), `$initial_current_url` Nullable(String), `$initial_fbclid` Nullable(String), `$initial_gad_source` Nullable(String), `$initial_gbraid` Nullable(String), `$initial_gclid` Nullable(String), `$initial_msclkid` Nullable(String), `$initial_pathname` Nullable(String), `$initial_referring_domain` Nullable(String), `$initial_utm_campaign` Nullable(String), `$initial_utm_content` Nullable(String), `$initial_utm_medium` Nullable(String), `$initial_utm_source` Nullable(String), `$initial_utm_term` Nullable(String), `$initial_wbraid` Nullable(String), `$os_name` Nullable(String), `$referring_domain` Nullable(String))"+ }+ column "group0_properties" {+ type = "String"+ codec = "ZSTD(3)"+ }+ column "group1_properties" {+ type = "String"+ codec = "ZSTD(3)"+ }+ column "group2_properties" {+ type = "String"+ codec = "ZSTD(3)"+ }+ column "group3_properties" {+ type = "String"+ codec = "ZSTD(3)"+ }+ column "group4_properties" {+ type = "String"+ codec = "ZSTD(3)"+ }+ column "person_created_at" {+ type = "DateTime64(3)"+ }+ column "group0_created_at" {+ type = "DateTime64(3)"+ }+ column "group1_created_at" {+ type = "DateTime64(3)"+ }+ column "group2_created_at" {+ type = "DateTime64(3)"+ }+ column "group3_created_at" {+ type = "DateTime64(3)"+ }+ column "group4_created_at" {+ type = "DateTime64(3)"+ }+ column "inserted_at" {+ type = "Nullable(DateTime64(6, 'UTC'))"+ default = "now64()"+ }+ column "person_mode" {+ type = "Enum8('full'=0, 'propertyless'=1, 'force_upgrade'=2)"+ }+ column "is_deleted" {+ type = "Bool"+ default = "false"+ }+ column "consumer_breadcrumbs" {+ type = "Array(String)"+ }+ column "historical_migration" {+ type = "Bool"+ default = "false"+ }+ engine "distributed" {+ cluster_name = "posthog"+ remote_database = "posthog"+ remote_table = "sharded_events_json"+ sharding_key = "sipHash64(distinct_id)"+ }+ }++ table "writable_events_recent" {+ column "uuid" {+ type = "UUID"+ }+ column "event" {+ type = "String"+ }+ column "properties" {+ type = "String"+ codec = "ZSTD(3)"+ }+ column "timestamp" {+ type = "DateTime64(6, 'UTC')"+ }+ column "team_id" {+ type = "Int64"+ }+ column "distinct_id" {+ type = "String"+ }+ column "elements_chain" {+ type = "String"+ }+ column "created_at" {+ type = "DateTime64(6, 'UTC')"+ }+ column "person_id" {+ type = "UUID"+ }+ column "person_created_at" {+ type = "DateTime64(3)"+ }+ column "person_properties" {+ type = "String"+ codec = "ZSTD(3)"+ }+ column "group0_properties" {+ type = "String"+ codec = "ZSTD(3)"+ }+ column "group1_properties" {+ type = "String"+ codec = "ZSTD(3)"+ }+ column "group2_properties" {+ type = "String"+ codec = "ZSTD(3)"+ }+ column "group3_properties" {+ type = "String"+ codec = "ZSTD(3)"+ }+ column "group4_properties" {+ type = "String"+ codec = "ZSTD(3)"+ }+ column "group0_created_at" {+ type = "DateTime64(3)"+ }+ column "group1_created_at" {+ type = "DateTime64(3)"+ }+ column "group2_created_at" {+ type = "DateTime64(3)"+ }+ column "group3_created_at" {+ type = "DateTime64(3)"+ }+ column "group4_created_at" {+ type = "DateTime64(3)"+ }+ column "person_mode" {+ type = "Enum8('full'=0, 'propertyless'=1, 'force_upgrade'=2)"+ }+ column "historical_migration" {+ type = "Bool"+ }+ column "_timestamp" {+ type = "DateTime"+ }+ column "_offset" {+ type = "UInt64"+ }+ engine "distributed" {+ cluster_name = "posthog_writable"+ remote_database = "posthog"+ remote_table = "sharded_events_recent"+ sharding_key = "sipHash64(distinct_id)"+ }+ }++ table "writable_flag_evaluations" {+ column "uuid" {+ type = "UUID"+ }+ column "event" {+ type = "LowCardinality(String)"+ }+ column "properties" {+ type = "String"+ }+ column "timestamp" {+ type = "DateTime64(6, 'UTC')"+ }+ column "team_id" {+ type = "Int64"+ }+ column "distinct_id" {+ type = "String"+ }+ column "created_at" {+ type = "DateTime64(6, 'UTC')"+ }+ column "person_id" {+ type = "UUID"+ }+ column "person_properties" {+ type = "String"+ }+ column "group0_properties" {+ type = "String"+ }+ column "group1_properties" {+ type = "String"+ }+ column "group2_properties" {+ type = "String"+ }+ column "group3_properties" {+ type = "String"+ }+ column "group4_properties" {+ type = "String"+ }+ column "inserted_at" {+ type = "DateTime64(6, 'UTC')"+ default = "timestamp"+ }+ column "_timestamp" {+ type = "DateTime"+ }+ column "_offset" {+ type = "UInt64"+ }+ column "_partition" {+ type = "UInt64"+ }+ engine "distributed" {+ cluster_name = "posthog"+ remote_database = "posthog"+ remote_table = "sharded_flag_evaluations"+ sharding_key = "sipHash64(distinct_id)"+ }+ }++ table "writable_groups" {+ column "group_type_index" {+ type = "UInt8"+ }+ column "group_key" {+ type = "String"+ }+ column "created_at" {+ type = "DateTime64(3)"+ }+ column "team_id" {+ type = "Int64"+ }+ column "group_properties" {+ type = "String"+ }+ column "_timestamp" {+ type = "DateTime"+ }+ column "_offset" {+ type = "UInt64"+ }+ engine "distributed" {+ cluster_name = "posthog_single_shard"+ remote_database = "posthog"+ remote_table = "groups"+ }+ }++ table "writable_heatmaps" {+ column "session_id" {+ type = "String"+ }+ column "team_id" {+ type = "Int64"+ }+ column "distinct_id" {+ type = "String"+ }+ column "timestamp" {+ type = "DateTime64(6, 'UTC')"+ }+ column "x" {+ type = "Int16"+ }+ column "y" {+ type = "Int16"+ }+ column "scale_factor" {+ type = "Int16"+ }+ column "viewport_width" {+ type = "Int16"+ }+ column "viewport_height" {+ type = "Int16"+ }+ column "pointer_target_fixed" {+ type = "Bool"+ }+ column "current_url" {+ type = "String"+ }+ column "type" {+ type = "LowCardinality(String)"+ }+ column "_timestamp" {+ type = "DateTime"+ }+ column "_offset" {+ type = "UInt64"+ }+ column "_partition" {+ type = "UInt64"+ }+ engine "distributed" {+ cluster_name = "posthog"+ remote_database = "posthog"+ remote_table = "sharded_heatmaps"+ sharding_key = "cityHash64(concat(toString(team_id), '-', session_id, '-', toString(toDate(timestamp))))"+ }+ }++ table "writable_ingestion_warnings" {+ column "team_id" {+ type = "Int64"+ }+ column "source" {+ type = "LowCardinality(String)"+ }+ column "type" {+ type = "String"+ }+ column "details" {+ type = "String"+ codec = "ZSTD(3)"+ }+ column "timestamp" {+ type = "DateTime64(6, 'UTC')"+ }+ column "_timestamp" {+ type = "DateTime"+ }+ column "_offset" {+ type = "UInt64"+ }+ column "_partition" {+ type = "UInt64"+ }+ engine "distributed" {+ cluster_name = "posthog"+ remote_database = "posthog"+ remote_table = "sharded_ingestion_warnings"+ sharding_key = "rand()"+ }+ }++ table "writable_log_entries" {+ column "team_id" {+ type = "UInt64"+ }+ column "log_source" {+ type = "LowCardinality(String)"+ }+ column "log_source_id" {+ type = "String"+ }+ column "instance_id" {+ type = "String"+ }+ column "timestamp" {+ type = "DateTime64(6, 'UTC')"+ }+ column "level" {+ type = "LowCardinality(String)"+ }+ column "message" {+ type = "String"+ }+ column "_timestamp" {+ type = "DateTime"+ }+ column "_offset" {+ type = "UInt64"+ }+ engine "distributed" {+ cluster_name = "posthog"+ remote_database = "posthog"+ remote_table = "sharded_log_entries"+ sharding_key = "rand()"+ }+ }++ table "writable_person" {+ column "id" {+ type = "UUID"+ }+ column "created_at" {+ type = "DateTime64(3)"+ }+ column "team_id" {+ type = "Int64"+ }+ column "properties" {+ type = "String"+ }+ column "is_identified" {+ type = "Int8"+ }+ column "is_deleted" {+ type = "Int8"+ }+ column "version" {+ type = "UInt64"+ }+ column "last_seen_at" {+ type = "Nullable(DateTime64(3))"+ }+ column "_timestamp" {+ type = "DateTime"+ }+ column "_offset" {+ type = "UInt64"+ }+ engine "distributed" {+ cluster_name = "posthog_single_shard"+ remote_database = "posthog"+ remote_table = "person"+ }+ }++ table "writable_person_distinct_id2" {+ column "team_id" {+ type = "Int64"+ }+ column "distinct_id" {+ type = "String"+ }+ column "person_id" {+ type = "UUID"+ }+ column "is_deleted" {+ type = "Int8"+ }+ column "version" {+ type = "Int64"+ }+ column "_timestamp" {+ type = "DateTime"+ }+ column "_offset" {+ type = "UInt64"+ }+ column "_partition" {+ type = "UInt64"+ }+ engine "distributed" {+ cluster_name = "posthog_single_shard"+ remote_database = "posthog"+ remote_table = "person_distinct_id2"+ }+ }++ table "writable_person_distinct_id_overrides" {+ column "team_id" {+ type = "Int64"+ }+ column "distinct_id" {+ type = "String"+ }+ column "person_id" {+ type = "UUID"+ }+ column "is_deleted" {+ type = "Int8"+ }+ column "version" {+ type = "Int64"+ }+ column "_timestamp" {+ type = "DateTime"+ }+ column "_offset" {+ type = "UInt64"+ }+ column "_partition" {+ type = "UInt64"+ }+ engine "distributed" {+ cluster_name = "posthog_single_shard"+ remote_database = "posthog"+ remote_table = "person_distinct_id_overrides"+ }+ }++ table "writable_plugin_log_entries" {+ column "id" {+ type = "UUID"+ }+ column "team_id" {+ type = "Int64"+ }+ column "plugin_id" {+ type = "Int64"+ }+ column "plugin_config_id" {+ type = "Int64"+ }+ column "timestamp" {+ type = "DateTime64(6, 'UTC')"+ }+ column "source" {+ type = "String"+ }+ column "type" {+ type = "String"+ }+ column "message" {+ type = "String"+ }+ column "instance_id" {+ type = "UUID"+ }+ column "_timestamp" {+ type = "DateTime"+ }+ column "_offset" {+ type = "UInt64"+ }+ engine "distributed" {+ cluster_name = "posthog_single_shard"+ remote_database = "posthog"+ remote_table = "plugin_log_entries"+ }+ }++ table "writable_posthog_document_embeddings" {+ column "team_id" {+ type = "Int64"+ }+ column "product" {+ type = "LowCardinality(String)"+ }+ column "document_type" {+ type = "LowCardinality(String)"+ }+ column "model_name" {+ type = "LowCardinality(String)"+ }+ column "rendering" {+ type = "LowCardinality(String)"+ }+ column "document_id" {+ type = "String"+ }+ column "timestamp" {+ type = "DateTime64(3, 'UTC')"+ }+ column "inserted_at" {+ type = "DateTime64(3, 'UTC')"+ }+ column "content" {+ type = "String"+ default = "''"+ }+ column "metadata" {+ type = "String"+ default = "'{}'"+ }+ column "embedding" {+ type = "Array(Float64)"+ }+ column "_timestamp" {+ type = "DateTime"+ }+ column "_offset" {+ type = "UInt64"+ }+ column "_partition" {+ type = "UInt64"+ }+ engine "distributed" {+ cluster_name = "posthog"+ remote_database = "posthog"+ remote_table = "partitioned_sharded_posthog_document_embeddings"+ sharding_key = "cityHash64(document_id)"+ }+ }++ table "writable_posthog_document_embeddings_buffer" {+ column "team_id" {+ type = "Int64"+ }+ column "product" {+ type = "LowCardinality(String)"+ }+ column "document_type" {+ type = "LowCardinality(String)"+ }+ column "model_name" {+ type = "LowCardinality(String)"+ }+ column "rendering" {+ type = "LowCardinality(String)"+ }+ column "document_id" {+ type = "String"+ }+ column "timestamp" {+ type = "DateTime64(3, 'UTC')"+ }+ column "inserted_at" {+ type = "DateTime64(3, 'UTC')"+ }+ column "content" {+ type = "String"+ default = "''"+ }+ column "metadata" {+ type = "String"+ default = "'{}'"+ }+ column "embedding" {+ type = "Array(Float64)"+ }+ column "_timestamp" {+ type = "DateTime"+ }+ column "_offset" {+ type = "UInt64"+ }+ column "_partition" {+ type = "UInt64"+ }+ engine "distributed" {+ cluster_name = "posthog"+ remote_database = "posthog"+ remote_table = "sharded_posthog_document_embeddings_buffer"+ sharding_key = "cityHash64(document_id)"+ }+ }++ table "writable_posthog_document_embeddings_text_embedding_3_large_3072" {+ column "team_id" {+ type = "Int64"+ }+ column "product" {+ type = "LowCardinality(String)"+ }+ column "document_type" {+ type = "LowCardinality(String)"+ }+ column "rendering" {+ type = "LowCardinality(String)"+ }+ column "document_id" {+ type = "String"+ }+ column "timestamp" {+ type = "DateTime64(3, 'UTC')"+ }+ column "inserted_at" {+ type = "DateTime64(3, 'UTC')"+ }+ column "content" {+ type = "String"+ default = "''"+ }+ column "metadata" {+ type = "String"+ default = "'{}'"+ }+ column "embedding" {+ type = "Array(Float64)"+ }+ column "_timestamp" {+ type = "DateTime"+ }+ column "_offset" {+ type = "UInt64"+ }+ column "_partition" {+ type = "UInt64"+ }+ engine "distributed" {+ cluster_name = "posthog"+ remote_database = "posthog"+ remote_table = "sharded_posthog_document_embeddings_text_embedding_3_large_3072"+ sharding_key = "cityHash64(document_id)"+ }+ }++ table "writable_posthog_document_embeddings_text_embedding_3_small_1536" {+ column "team_id" {+ type = "Int64"+ }+ column "product" {+ type = "LowCardinality(String)"+ }+ column "document_type" {+ type = "LowCardinality(String)"+ }+ column "rendering" {+ type = "LowCardinality(String)"+ }+ column "document_id" {+ type = "String"+ }+ column "timestamp" {+ type = "DateTime64(3, 'UTC')"+ }+ column "inserted_at" {+ type = "DateTime64(3, 'UTC')"+ }+ column "content" {+ type = "String"+ default = "''"+ }+ column "metadata" {+ type = "String"+ default = "'{}'"+ }+ column "embedding" {+ type = "Array(Float64)"+ }+ column "_timestamp" {+ type = "DateTime"+ }+ column "_offset" {+ type = "UInt64"+ }+ column "_partition" {+ type = "UInt64"+ }+ engine "distributed" {+ cluster_name = "posthog"+ remote_database = "posthog"+ remote_table = "sharded_posthog_document_embeddings_text_embedding_3_small_1536"+ sharding_key = "cityHash64(document_id)"+ }+ }++ table "writable_precalculated_events" {+ column "team_id" {+ type = "Int64"+ }+ column "date" {+ type = "Date"+ }+ column "distinct_id" {+ type = "String"+ }+ column "person_id" {+ type = "UUID"+ }+ column "condition" {+ type = "String"+ }+ column "uuid" {+ type = "UUID"+ }+ column "source" {+ type = "String"+ }+ column "_timestamp" {+ type = "DateTime64(6)"+ }+ column "_partition" {+ type = "UInt64"+ }+ column "_offset" {+ type = "UInt64"+ }+ engine "distributed" {+ cluster_name = "posthog"+ remote_database = "posthog"+ remote_table = "sharded_precalculated_events"+ sharding_key = "sipHash64(distinct_id)"+ }+ }++ table "writable_precalculated_person_properties" {+ column "team_id" {+ type = "Int64"+ }+ column "distinct_id" {+ type = "String"+ }+ column "person_id" {+ type = "UUID"+ }+ column "condition" {+ type = "String"+ }+ column "matches" {+ type = "Bool"+ }+ column "source" {+ type = "String"+ }+ column "_timestamp" {+ type = "DateTime64(6)"+ }+ column "_offset" {+ type = "UInt64"+ }+ engine "distributed" {+ cluster_name = "posthog"+ remote_database = "posthog"+ remote_table = "sharded_precalculated_person_properties"+ sharding_key = "sipHash64(distinct_id)"+ }+ }++ table "writable_query_log_archive" {+ column "hostname" {+ type = "LowCardinality(String)"+ }+ column "user" {+ type = "LowCardinality(String)"+ }+ column "query_id" {+ type = "String"+ }+ column "initial_query_id" {+ type = "String"+ }+ column "is_initial_query" {+ type = "UInt8"+ }+ column "type" {+ type = "Enum8('QueryStart'=1, 'QueryFinish'=2, 'ExceptionBeforeStart'=3, 'ExceptionWhileProcessing'=4)"+ }+ column "event_date" {+ type = "Date"+ }+ column "event_time" {+ type = "DateTime"+ }+ column "event_time_microseconds" {+ type = "DateTime64(6)"+ }+ column "query_start_time" {+ type = "DateTime"+ }+ column "query_start_time_microseconds" {+ type = "DateTime64(6)"+ }+ column "query_duration_ms" {+ type = "UInt64"+ }+ column "read_rows" {+ type = "UInt64"+ }+ column "read_bytes" {+ type = "UInt64"+ }+ column "written_rows" {+ type = "UInt64"+ }+ column "written_bytes" {+ type = "UInt64"+ }+ column "result_rows" {+ type = "UInt64"+ }+ column "result_bytes" {+ type = "UInt64"+ }+ column "memory_usage" {+ type = "UInt64"+ }+ column "peak_threads_usage" {+ type = "UInt64"+ }+ column "current_database" {+ type = "LowCardinality(String)"+ }+ column "query" {+ type = "String"+ }+ column "formatted_query" {+ type = "String"+ }+ column "normalized_query_hash" {+ type = "UInt64"+ }+ column "query_kind" {+ type = "LowCardinality(String)"+ }+ column "exception_code" {+ type = "Int32"+ }+ column "exception" {+ type = "String"+ }+ column "stack_trace" {+ type = "String"+ }+ column "team_id" {+ type = "Int64"+ }+ column "log_comment" {+ type = "JSON(max_dynamic_paths=256, access_method LowCardinality(String), alert_config_id String, api_key_label String, api_key_mask String, batch_export_id String, chargeable Bool, client_query_id String, cohort_id Int64, `dagster.job_name` String, `dagster.run_id` String, `dagster.tags.owner` String, dashboard_id Int64, experiment_feature_flag_key String, experiment_id Int64, feature LowCardinality(String), id String, insight_id Int64, is_impersonated Bool, kind LowCardinality(String), name String, org_id String, person_on_events_mode LowCardinality(String), product LowCardinality(String), query_type LowCardinality(String), request_name String, route_id String, service_name String, session_id String, table_id String, team_id Int64, `temporal.activity_id` String, `temporal.activity_type` String, `temporal.attempt` Int64, `temporal.workflow_id` String, `temporal.workflow_namespace` String, `temporal.workflow_run_id` String, `temporal.workflow_type` String, user_id Int64, warehouse_query Bool, workflow LowCardinality(String), workload LowCardinality(String), SKIP cache_key, SKIP filter, SKIP hogql_features, SKIP http_referer, SKIP http_request_id, SKIP http_user_agent, SKIP query_settings, SKIP timings, SKIP user_email)"+ }+ column "ProfileEvents" {+ type = "Map(String, UInt64)"+ }+ engine "distributed" {+ cluster_name = "ops"+ remote_database = "posthog"+ remote_table = "query_log_archive_buffer"+ }+ }++ table "writable_raw_sessions" {+ column "team_id" {+ type = "Int64"+ }+ column "session_id_v7" {+ type = "UInt128"+ }+ column "distinct_id" {+ type = "AggregateFunction(argMax, String, DateTime64(6, 'UTC'))"+ }+ column "min_timestamp" {+ type = "SimpleAggregateFunction(min, DateTime64(6, 'UTC'))"+ }+ column "max_timestamp" {+ type = "SimpleAggregateFunction(max, DateTime64(6, 'UTC'))"+ }+ column "max_inserted_at" {+ type = "SimpleAggregateFunction(max, DateTime64(6, 'UTC'))"+ }+ column "urls" {+ type = "SimpleAggregateFunction(groupUniqArrayArray, Array(String))"+ }+ column "entry_url" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "end_url" {+ type = "AggregateFunction(argMax, String, DateTime64(6, 'UTC'))"+ }+ column "last_external_click_url" {+ type = "AggregateFunction(argMax, String, DateTime64(6, 'UTC'))"+ }+ column "initial_browser" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_browser_version" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_os" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_os_version" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_device_type" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_viewport_width" {+ type = "AggregateFunction(argMin, Int64, DateTime64(6, 'UTC'))"+ }+ column "initial_viewport_height" {+ type = "AggregateFunction(argMin, Int64, DateTime64(6, 'UTC'))"+ }+ column "initial_geoip_country_code" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_geoip_subdivision_1_code" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_geoip_subdivision_1_name" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_geoip_subdivision_city_name" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_geoip_time_zone" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_referring_domain" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_utm_source" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_utm_campaign" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_utm_medium" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_utm_term" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_utm_content" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_gclid" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_gad_source" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_gclsrc" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_dclid" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_gbraid" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_wbraid" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_fbclid" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_msclkid" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_twclid" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_li_fat_id" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_mc_cid" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_igshid" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_ttclid" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_epik" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_qclid" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_sccid" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial__kx" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_irclid" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "pageview_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "pageview_uniq" {+ type = "AggregateFunction(uniq, Nullable(UUID))"+ }+ column "autocapture_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "autocapture_uniq" {+ type = "AggregateFunction(uniq, Nullable(UUID))"+ }+ column "screen_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "screen_uniq" {+ type = "AggregateFunction(uniq, Nullable(UUID))"+ }+ column "maybe_has_session_replay" {+ type = "SimpleAggregateFunction(max, Bool)"+ }+ column "page_screen_autocapture_uniq_up_to" {+ type = "AggregateFunction(uniqUpTo(1), Nullable(UUID))"+ }+ column "vitals_lcp" {+ type = "AggregateFunction(argMin, Nullable(Float64), DateTime64(6, 'UTC'))"+ }+ engine "distributed" {+ cluster_name = "posthog"+ remote_database = "posthog"+ remote_table = "sharded_raw_sessions"+ sharding_key = "cityHash64(session_id_v7)"+ }+ }++ table "writable_raw_sessions_v3" {+ column "team_id" {+ type = "Int64"+ }+ column "session_id_v7" {+ type = "UInt128"+ }+ column "session_timestamp" {+ type = "DateTime64(3)"+ default = "fromUnixTimestamp64Milli(toUInt64(bitShiftRight(session_id_v7, 80)))"+ }+ column "distinct_id" {+ type = "AggregateFunction(argMax, String, DateTime64(6, 'UTC'))"+ }+ column "distinct_ids" {+ type = "AggregateFunction(groupUniqArray, String)"+ }+ column "min_timestamp" {+ type = "SimpleAggregateFunction(min, DateTime64(6, 'UTC'))"+ }+ column "max_timestamp" {+ type = "SimpleAggregateFunction(max, DateTime64(6, 'UTC'))"+ }+ column "max_inserted_at" {+ type = "SimpleAggregateFunction(max, DateTime64(6, 'UTC'))"+ }+ column "urls" {+ type = "SimpleAggregateFunction(groupUniqArrayArray(2000), Array(String))"+ }+ column "entry_url" {+ type = "AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC'))"+ }+ column "end_url" {+ type = "AggregateFunction(argMax, Nullable(String), DateTime64(6, 'UTC'))"+ }+ column "last_external_click_url" {+ type = "AggregateFunction(argMax, Nullable(String), DateTime64(6, 'UTC'))"+ }+ column "browser" {+ type = "AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC'))"+ }+ column "browser_version" {+ type = "AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC'))"+ }+ column "os" {+ type = "AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC'))"+ }+ column "os_version" {+ type = "AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC'))"+ }+ column "device_type" {+ type = "AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC'))"+ }+ column "viewport_width" {+ type = "AggregateFunction(argMin, Nullable(Int64), DateTime64(6, 'UTC'))"+ }+ column "viewport_height" {+ type = "AggregateFunction(argMin, Nullable(Int64), DateTime64(6, 'UTC'))"+ }+ column "geoip_country_code" {+ type = "AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC'))"+ }+ column "geoip_subdivision_1_code" {+ type = "AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC'))"+ }+ column "geoip_subdivision_1_name" {+ type = "AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC'))"+ }+ column "geoip_subdivision_city_name" {+ type = "AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC'))"+ }+ column "geoip_time_zone" {+ type = "AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC'))"+ }+ column "entry_referring_domain" {+ type = "AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC'))"+ }+ column "entry_utm_source" {+ type = "AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC'))"+ }+ column "entry_utm_campaign" {+ type = "AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC'))"+ }+ column "entry_utm_medium" {+ type = "AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC'))"+ }+ column "entry_utm_term" {+ type = "AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC'))"+ }+ column "entry_utm_content" {+ type = "AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC'))"+ }+ column "entry_gclid" {+ type = "AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC'))"+ }+ column "entry_gad_source" {+ type = "AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC'))"+ }+ column "entry_fbclid" {+ type = "AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC'))"+ }+ column "entry_has_gclid" {+ type = "AggregateFunction(argMin, Bool, DateTime64(6, 'UTC'))"+ }+ column "entry_has_fbclid" {+ type = "AggregateFunction(argMin, Bool, DateTime64(6, 'UTC'))"+ }+ column "entry_ad_ids_map" {+ type = "AggregateFunction(argMin, Map(String, String), DateTime64(6, 'UTC'))"+ }+ column "entry_ad_ids_set" {+ type = "AggregateFunction(argMin, Array(String), DateTime64(6, 'UTC'))"+ }+ column "entry_channel_type_properties" {+ type = "AggregateFunction(argMin, Tuple(Nullable(String), Nullable(String), Nullable(String), Nullable(String), Bool, Bool, Nullable(String)), DateTime64(6, 'UTC'))"+ }+ column "pageview_uniq" {+ type = "AggregateFunction(uniqExact, Nullable(UUID))"+ }+ column "autocapture_uniq" {+ type = "AggregateFunction(uniqExact, Nullable(UUID))"+ }+ column "screen_uniq" {+ type = "AggregateFunction(uniqExact, Nullable(UUID))"+ }+ column "page_screen_uniq_up_to" {+ type = "AggregateFunction(uniqUpTo(1), Nullable(UUID))"+ }+ column "has_autocapture" {+ type = "SimpleAggregateFunction(max, Bool)"+ }+ column "flag_values" {+ type = "AggregateFunction(groupUniqArrayMap, Map(String, String))"+ }+ column "flag_keys" {+ type = "SimpleAggregateFunction(groupUniqArrayArray, Array(String))"+ }+ column "event_names" {+ type = "SimpleAggregateFunction(groupUniqArrayArray(2000), Array(String))"+ }+ column "hosts" {+ type = "SimpleAggregateFunction(groupUniqArrayArray(100), Array(String))"+ }+ column "emails" {+ type = "SimpleAggregateFunction(groupUniqArrayArray(10), Array(String))"+ }+ column "has_replay_events" {+ type = "SimpleAggregateFunction(max, Bool)"+ }+ engine "distributed" {+ cluster_name = "posthog"+ remote_database = "posthog"+ remote_table = "sharded_raw_sessions_v3"+ sharding_key = "cityHash64(session_id_v7)"+ }+ }++ table "writable_session_replay_embeddings" {+ column "session_id" {+ type = "String"+ }+ column "team_id" {+ type = "Int64"+ }+ column "embeddings" {+ type = "Array(Float32)"+ }+ column "generation_timestamp" {+ type = "DateTime64(6, 'UTC')"+ default = "now('UTC')"+ }+ column "source_type" {+ type = "LowCardinality(String)"+ }+ column "input" {+ type = "String"+ }+ engine "distributed" {+ cluster_name = "posthog"+ remote_database = "posthog"+ remote_table = "sharded_session_replay_embeddings"+ sharding_key = "sipHash64(session_id)"+ }+ }++ table "writable_session_replay_events" {+ column "session_id" {+ type = "String"+ }+ column "team_id" {+ type = "Int64"+ }+ column "distinct_id" {+ type = "String"+ }+ column "min_first_timestamp" {+ type = "SimpleAggregateFunction(min, DateTime64(6, 'UTC'))"+ }+ 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)"+ }+ column "keypress_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "mouse_activity_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "active_milliseconds" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "console_log_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "console_warn_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "console_error_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "size" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "message_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "event_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "snapshot_source" {+ type = "AggregateFunction(argMin, LowCardinality(Nullable(String)), DateTime64(6, 'UTC'))"+ }+ column "snapshot_library" {+ type = "AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC'))"+ }+ column "_timestamp" {+ type = "SimpleAggregateFunction(max, DateTime)"+ }+ column "retention_period_days" {+ type = "SimpleAggregateFunction(max, Nullable(Int64))"+ }+ column "is_deleted" {+ type = "SimpleAggregateFunction(max, UInt8)"+ default = "0"+ }+ column "ai_tags_fixed" {+ type = "SimpleAggregateFunction(groupUniqArrayArray, Array(String))"+ }+ column "ai_tags_freeform" {+ type = "SimpleAggregateFunction(groupUniqArrayArray, Array(String))"+ }+ column "ai_highlighted" {+ type = "SimpleAggregateFunction(max, UInt8)"+ default = "0"+ }+ column "surfacing_score" {+ type = "SimpleAggregateFunction(max, Nullable(Float32))"+ }+ engine "distributed" {+ cluster_name = "posthog"+ remote_database = "posthog"+ remote_table = "sharded_session_replay_events"+ sharding_key = "sipHash64(distinct_id)"+ }+ }++ table "writable_session_replay_features" {+ column "session_id" {+ type = "String"+ }+ column "team_id" {+ type = "Int64"+ }+ column "distinct_id" {+ type = "String"+ }+ column "min_first_timestamp" {+ type = "SimpleAggregateFunction(min, DateTime64(6, 'UTC'))"+ }+ column "max_last_timestamp" {+ type = "SimpleAggregateFunction(max, DateTime64(6, 'UTC'))"+ }+ column "event_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "mouse_position_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "mouse_sum_x" {+ type = "SimpleAggregateFunction(sum, Float64)"+ }+ column "mouse_sum_x_squared" {+ type = "SimpleAggregateFunction(sum, Float64)"+ }+ column "mouse_sum_y" {+ type = "SimpleAggregateFunction(sum, Float64)"+ }+ column "mouse_sum_y_squared" {+ type = "SimpleAggregateFunction(sum, Float64)"+ }+ column "mouse_distance_traveled" {+ type = "SimpleAggregateFunction(sum, Float64)"+ }+ column "mouse_direction_change_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "mouse_velocity_sum" {+ type = "SimpleAggregateFunction(sum, Float64)"+ }+ column "mouse_velocity_sum_of_squares" {+ type = "SimpleAggregateFunction(sum, Float64)"+ }+ column "mouse_velocity_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "scroll_event_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "total_scroll_magnitude" {+ type = "SimpleAggregateFunction(sum, Float64)"+ }+ column "scroll_direction_reversal_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "rapid_scroll_reversal_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "scroll_to_top_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "click_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "keypress_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "mouse_activity_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "rage_click_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "dead_click_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "backspace_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "inter_action_gap_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "inter_action_gap_sum_ms" {+ type = "SimpleAggregateFunction(sum, Float64)"+ }+ column "inter_action_gap_sum_of_squares_ms" {+ type = "SimpleAggregateFunction(sum, Float64)"+ }+ column "max_idle_gap_ms" {+ type = "SimpleAggregateFunction(max, Float64)"+ }+ column "long_idle_gap_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "quick_back_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "page_visit_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "unique_url_count" {+ type = "AggregateFunction(uniqCombined(12), String)"+ }+ column "login_path_visit_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "signup_path_visit_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "checkout_path_visit_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "cart_path_visit_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "billing_path_visit_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "settings_path_visit_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "account_path_visit_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "error_path_visit_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "not_found_path_visit_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "admin_path_visit_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "dashboard_path_visit_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "onboarding_path_visit_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "cancel_path_visit_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "refund_path_visit_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "console_error_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "console_error_after_click_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "console_warn_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "network_request_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "network_failed_request_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "network_4xx_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "network_5xx_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "network_request_duration_sum" {+ type = "SimpleAggregateFunction(sum, Float64)"+ }+ column "network_request_duration_sum_of_squares" {+ type = "SimpleAggregateFunction(sum, Float64)"+ }+ column "network_request_duration_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "mutation_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "viewport_resize_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "touch_event_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "max_scroll_y" {+ type = "SimpleAggregateFunction(max, Float64)"+ }+ column "unique_click_target_count" {+ type = "AggregateFunction(uniqCombined(12), Int64)"+ }+ column "unique_form_field_count" {+ type = "AggregateFunction(uniqCombined(12), Int64)"+ }+ column "text_selection_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "selection_copy_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "is_deleted" {+ type = "SimpleAggregateFunction(max, UInt8)"+ default = "0"+ }+ engine "distributed" {+ cluster_name = "aux"+ remote_database = "posthog"+ remote_table = "sharded_session_replay_features"+ sharding_key = "sipHash64(session_id)"+ }+ }++ table "writable_sessions" {+ column "session_id" {+ type = "String"+ }+ column "team_id" {+ type = "Int64"+ }+ column "distinct_id" {+ type = "SimpleAggregateFunction(any, String)"+ }+ column "min_timestamp" {+ type = "SimpleAggregateFunction(min, DateTime64(6, 'UTC'))"+ }+ column "max_timestamp" {+ type = "SimpleAggregateFunction(max, DateTime64(6, 'UTC'))"+ }+ column "urls" {+ type = "SimpleAggregateFunction(groupUniqArrayArray, Array(String))"+ }+ column "entry_url" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "exit_url" {+ type = "AggregateFunction(argMax, String, DateTime64(6, 'UTC'))"+ }+ column "initial_referring_domain" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_utm_source" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_utm_campaign" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_utm_medium" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_utm_term" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_utm_content" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_gclid" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_gad_source" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_gclsrc" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_dclid" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_gbraid" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_wbraid" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_fbclid" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_msclkid" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_twclid" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_li_fat_id" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_mc_cid" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_igshid" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_ttclid" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_epik" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_qclid" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_sccid" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "event_count_map" {+ type = "SimpleAggregateFunction(sumMap, Map(String, Int64))"+ }+ column "pageview_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "autocapture_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ engine "distributed" {+ cluster_name = "posthog"+ remote_database = "posthog"+ remote_table = "sharded_sessions"+ sharding_key = "sipHash64(session_id)"+ }+ }++ table "writable_tophog" {+ column "timestamp" {+ type = "DateTime64(6, 'UTC')"+ }+ column "metric" {+ type = "LowCardinality(String)"+ }+ column "type" {+ type = "LowCardinality(String)"+ default = "'sum'"+ }+ column "key" {+ type = "Map(LowCardinality(String), String)"+ }+ column "value" {+ type = "Float64"+ }+ column "count" {+ type = "UInt64"+ default = "0"+ }+ column "pipeline" {+ type = "LowCardinality(String)"+ }+ column "lane" {+ type = "LowCardinality(String)"+ }+ column "labels" {+ type = "Map(LowCardinality(String), String)"+ }+ engine "distributed" {+ cluster_name = "posthog"+ remote_database = "posthog"+ remote_table = "sharded_tophog"+ sharding_key = "cityHash64(toString(key))"+ }+ }++ table "writable_usage_report_events_preagg" {+ column "date" {+ type = "Date"+ }+ column "team_id" {+ type = "Int64"+ }+ column "person_mode" {+ type = "LowCardinality(String)"+ }+ column "lib" {+ type = "LowCardinality(String)"+ }+ column "event" {+ type = "String"+ }+ column "distinct_events_unique" {+ type = "AggregateFunction(uniqExact, Tuple(UInt64, UInt64, UInt64))"+ }+ column "event_count" {+ type = "AggregateFunction(sum, UInt64)"+ }+ engine "distributed" {+ cluster_name = "aux"+ remote_database = "posthog"+ remote_table = "sharded_usage_report_events_preagg"+ sharding_key = "sipHash64(date)"+ }+ }++ table "writeable_performance_events" {+ column "uuid" {+ type = "UUID"+ }+ column "session_id" {+ type = "String"+ }+ column "window_id" {+ type = "String"+ }+ column "pageview_id" {+ type = "String"+ }+ column "distinct_id" {+ type = "String"+ }+ column "timestamp" {+ type = "DateTime64(3)"+ }+ column "time_origin" {+ type = "DateTime64(3, 'UTC')"+ }+ column "entry_type" {+ type = "LowCardinality(String)"+ }+ column "name" {+ type = "String"+ }+ column "team_id" {+ type = "Int64"+ }+ column "current_url" {+ type = "String"+ }+ column "start_time" {+ type = "Float64"+ }+ column "duration" {+ type = "Float64"+ }+ column "redirect_start" {+ type = "Float64"+ }+ column "redirect_end" {+ type = "Float64"+ }+ column "worker_start" {+ type = "Float64"+ }+ column "fetch_start" {+ type = "Float64"+ }+ column "domain_lookup_start" {+ type = "Float64"+ }+ column "domain_lookup_end" {+ type = "Float64"+ }+ column "connect_start" {+ type = "Float64"+ }+ column "secure_connection_start" {+ type = "Float64"+ }+ column "connect_end" {+ type = "Float64"+ }+ column "request_start" {+ type = "Float64"+ }+ column "response_start" {+ type = "Float64"+ }+ column "response_end" {+ type = "Float64"+ }+ column "decoded_body_size" {+ type = "Int64"+ }+ column "encoded_body_size" {+ type = "Int64"+ }+ column "initiator_type" {+ type = "LowCardinality(String)"+ }+ column "next_hop_protocol" {+ type = "LowCardinality(String)"+ }+ column "render_blocking_status" {+ type = "LowCardinality(String)"+ }+ column "response_status" {+ type = "Int64"+ }+ column "transfer_size" {+ type = "Int64"+ }+ column "largest_contentful_paint_element" {+ type = "String"+ }+ column "largest_contentful_paint_render_time" {+ type = "Float64"+ }+ column "largest_contentful_paint_load_time" {+ type = "Float64"+ }+ column "largest_contentful_paint_size" {+ type = "Float64"+ }+ column "largest_contentful_paint_id" {+ type = "String"+ }+ column "largest_contentful_paint_url" {+ type = "String"+ }+ column "dom_complete" {+ type = "Float64"+ }+ column "dom_content_loaded_event" {+ type = "Float64"+ }+ column "dom_interactive" {+ type = "Float64"+ }+ column "load_event_end" {+ type = "Float64"+ }+ column "load_event_start" {+ type = "Float64"+ }+ column "redirect_count" {+ type = "Int64"+ }+ column "navigation_type" {+ type = "LowCardinality(String)"+ }+ column "unload_event_end" {+ type = "Float64"+ }+ column "unload_event_start" {+ type = "Float64"+ }+ column "_timestamp" {+ type = "DateTime"+ }+ column "_offset" {+ type = "UInt64"+ }+ column "_partition" {+ type = "UInt64"+ }+ engine "distributed" {+ cluster_name = "posthog"+ remote_database = "posthog"+ remote_table = "sharded_performance_events"+ sharding_key = "sipHash64(session_id)"+ }+ }++ materialized_view "ai_events_json_mv" {+ to_table = "posthog.ai_events"+ query = <<SQL+SELECT+ uuid,+ event,+ timestamp,+ team_id,+ distinct_id,+ person_id,+ concat(+ '{',+ arrayStringConcat(+ arrayMap(+ x -> concat('"', x.1, '":', x.2),+ arrayFilter(+ x -> ((x.1) NOT IN ('$ai_input', '$ai_output', '$ai_output_choices', '$ai_input_state', '$ai_output_state', '$ai_tools')),+ JSONExtractKeysAndValuesRaw(src.properties)+ )+ ),+ ','+ ),+ '}'+ ) AS properties,+ JSONExtractString(src.properties, '$ai_trace_id') AS trace_id,+ JSONExtract(src.properties, '$ai_session_id', 'Nullable(String)') AS session_id,+ JSONExtract(src.properties, '$ai_parent_id', 'Nullable(String)') AS parent_id,+ JSONExtract(src.properties, '$ai_span_id', 'Nullable(String)') AS span_id,+ JSONExtract(src.properties, '$ai_span_type', 'Nullable(String)') AS span_type,+ JSONExtract(src.properties, '$ai_generation_id', 'Nullable(String)') AS generation_id,+ JSONExtract(src.properties, '$ai_experiment_id', 'Nullable(String)') AS experiment_id,+ JSONExtract(src.properties, '$ai_span_name', 'Nullable(String)') AS span_name,+ JSONExtract(src.properties, '$ai_trace_name', 'Nullable(String)') AS trace_name,+ JSONExtract(src.properties, '$ai_prompt_name', 'Nullable(String)') AS prompt_name,+ JSONExtract(src.properties, '$ai_model', 'Nullable(String)') AS model,+ JSONExtract(src.properties, '$ai_provider', 'Nullable(String)') AS provider,+ JSONExtract(src.properties, '$ai_framework', 'Nullable(String)') AS framework,+ JSONExtract(src.properties, '$ai_total_tokens', 'Nullable(Int64)') AS total_tokens,+ JSONExtract(src.properties, '$ai_input_tokens', 'Nullable(Int64)') AS input_tokens,+ JSONExtract(src.properties, '$ai_output_tokens', 'Nullable(Int64)') AS output_tokens,+ JSONExtract(src.properties, '$ai_text_input_tokens', 'Nullable(Int64)') AS text_input_tokens,+ JSONExtract(src.properties, '$ai_text_output_tokens', 'Nullable(Int64)') AS text_output_tokens,+ JSONExtract(src.properties, '$ai_image_input_tokens', 'Nullable(Int64)') AS image_input_tokens,+ JSONExtract(src.properties, '$ai_image_output_tokens', 'Nullable(Int64)') AS image_output_tokens,+ JSONExtract(src.properties, '$ai_audio_input_tokens', 'Nullable(Int64)') AS audio_input_tokens,+ JSONExtract(src.properties, '$ai_audio_output_tokens', 'Nullable(Int64)') AS audio_output_tokens,+ JSONExtract(src.properties, '$ai_video_input_tokens', 'Nullable(Int64)') AS video_input_tokens,+ JSONExtract(src.properties, '$ai_video_output_tokens', 'Nullable(Int64)') AS video_output_tokens,+ JSONExtract(src.properties, '$ai_reasoning_tokens', 'Nullable(Int64)') AS reasoning_tokens,+ JSONExtract(src.properties, '$ai_cache_read_input_tokens', 'Nullable(Int64)') AS cache_read_input_tokens,+ JSONExtract(src.properties, '$ai_cache_creation_input_tokens', 'Nullable(Int64)') AS cache_creation_input_tokens,+ JSONExtract(src.properties, '$ai_web_search_count', 'Nullable(Int64)') AS web_search_count,+ JSONExtract(src.properties, '$ai_input_cost_usd', 'Nullable(Float64)') AS input_cost_usd,+ JSONExtract(src.properties, '$ai_output_cost_usd', 'Nullable(Float64)') AS output_cost_usd,+ JSONExtract(src.properties, '$ai_total_cost_usd', 'Nullable(Float64)') AS total_cost_usd,+ JSONExtract(src.properties, '$ai_request_cost_usd', 'Nullable(Float64)') AS request_cost_usd,+ JSONExtract(src.properties, '$ai_web_search_cost_usd', 'Nullable(Float64)') AS web_search_cost_usd,+ JSONExtract(src.properties, '$ai_audio_cost_usd', 'Nullable(Float64)') AS audio_cost_usd,+ JSONExtract(src.properties, '$ai_image_cost_usd', 'Nullable(Float64)') AS image_cost_usd,+ JSONExtract(src.properties, '$ai_video_cost_usd', 'Nullable(Float64)') AS video_cost_usd,+ JSONExtract(src.properties, '$ai_latency', 'Nullable(Float64)') AS latency,+ JSONExtract(src.properties, '$ai_time_to_first_token', 'Nullable(Float64)') AS time_to_first_token,+ if((JSONExtractRaw(src.properties, '$ai_is_error') IN ('true', '"true"')), 1, 0) AS is_error,+ JSONExtract(src.properties, '$ai_error', 'Nullable(String)') AS error,+ JSONExtract(src.properties, '$ai_error_type', 'Nullable(String)') AS error_type,+ JSONExtract(src.properties, '$ai_error_normalized', 'Nullable(String)') AS error_normalized,+ nullIf(JSONExtractRaw(src.properties, '$ai_input'), '') AS input,+ nullIf(JSONExtractRaw(src.properties, '$ai_output'), '') AS output,+ nullIf(JSONExtractRaw(src.properties, '$ai_output_choices'), '') AS output_choices,+ nullIf(JSONExtractRaw(src.properties, '$ai_input_state'), '') AS input_state,+ nullIf(JSONExtractRaw(src.properties, '$ai_output_state'), '') AS output_state,+ nullIf(JSONExtractRaw(src.properties, '$ai_tools'), '') AS tools,+ _timestamp,+ _offset,+ _partition+FROM posthog.kafka_ai_events_json AS src+SQL++ column "uuid" {+ type = "UUID"+ }+ column "event" {+ type = "String"+ }+ column "timestamp" {+ type = "DateTime64(6, 'UTC')"+ }+ column "team_id" {+ type = "Int64"+ }+ column "distinct_id" {+ type = "String"+ }+ column "person_id" {+ type = "UUID"+ }+ column "properties" {+ type = "String"+ }+ column "trace_id" {+ type = "String"+ }+ column "session_id" {+ type = "Nullable(String)"+ }+ column "parent_id" {+ type = "Nullable(String)"+ }+ column "span_id" {+ type = "Nullable(String)"+ }+ column "span_type" {+ type = "Nullable(String)"+ }+ column "generation_id" {+ type = "Nullable(String)"+ }+ column "experiment_id" {+ type = "Nullable(String)"+ }+ column "span_name" {+ type = "Nullable(String)"+ }+ column "trace_name" {+ type = "Nullable(String)"+ }+ column "prompt_name" {+ type = "Nullable(String)"+ }+ column "model" {+ type = "Nullable(String)"+ }+ column "provider" {+ type = "Nullable(String)"+ }+ column "framework" {+ type = "Nullable(String)"+ }+ column "total_tokens" {+ type = "Nullable(Int64)"+ }+ column "input_tokens" {+ type = "Nullable(Int64)"+ }+ column "output_tokens" {+ type = "Nullable(Int64)"+ }+ column "text_input_tokens" {+ type = "Nullable(Int64)"+ }+ column "text_output_tokens" {+ type = "Nullable(Int64)"+ }+ column "image_input_tokens" {+ type = "Nullable(Int64)"+ }+ column "image_output_tokens" {+ type = "Nullable(Int64)"+ }+ column "audio_input_tokens" {+ type = "Nullable(Int64)"+ }+ column "audio_output_tokens" {+ type = "Nullable(Int64)"+ }+ column "video_input_tokens" {+ type = "Nullable(Int64)"+ }+ column "video_output_tokens" {+ type = "Nullable(Int64)"+ }+ column "reasoning_tokens" {+ type = "Nullable(Int64)"+ }+ column "cache_read_input_tokens" {+ type = "Nullable(Int64)"+ }+ column "cache_creation_input_tokens" {+ type = "Nullable(Int64)"+ }+ column "web_search_count" {+ type = "Nullable(Int64)"+ }+ column "input_cost_usd" {+ type = "Nullable(Float64)"+ }+ column "output_cost_usd" {+ type = "Nullable(Float64)"+ }+ column "total_cost_usd" {+ type = "Nullable(Float64)"+ }+ column "request_cost_usd" {+ type = "Nullable(Float64)"+ }+ column "web_search_cost_usd" {+ type = "Nullable(Float64)"+ }+ column "audio_cost_usd" {+ type = "Nullable(Float64)"+ }+ column "image_cost_usd" {+ type = "Nullable(Float64)"+ }+ column "video_cost_usd" {+ type = "Nullable(Float64)"+ }+ column "latency" {+ type = "Nullable(Float64)"+ }+ column "time_to_first_token" {+ type = "Nullable(Float64)"+ }+ column "is_error" {+ type = "UInt8"+ }+ column "error" {+ type = "Nullable(String)"+ }+ column "error_type" {+ type = "Nullable(String)"+ }+ column "error_normalized" {+ type = "Nullable(String)"+ }+ column "input" {+ type = "Nullable(String)"+ }+ column "output" {+ type = "Nullable(String)"+ }+ column "output_choices" {+ type = "Nullable(String)"+ }+ column "input_state" {+ type = "Nullable(String)"+ }+ column "output_state" {+ type = "Nullable(String)"+ }+ column "tools" {+ type = "Nullable(String)"+ }+ column "_timestamp" {+ type = "Nullable(DateTime)"+ }+ column "_offset" {+ type = "UInt64"+ }+ column "_partition" {+ type = "UInt64"+ }+ }++ materialized_view "app_metrics2_mv" {+ to_table = "posthog.writable_app_metrics2"+ query = <<SQL+SELECT+ team_id,+ timestamp,+ app_source,+ app_source_id,+ instance_id,+ metric_kind,+ metric_name,+ count,+ _timestamp,+ _offset,+ _partition+FROM posthog.kafka_app_metrics2+SQL++ column "team_id" {+ type = "Int64"+ }+ column "timestamp" {+ type = "DateTime64(6, 'UTC')"+ }+ column "app_source" {+ type = "LowCardinality(String)"+ }+ column "app_source_id" {+ type = "String"+ }+ column "instance_id" {+ type = "String"+ }+ column "metric_kind" {+ type = "String"+ }+ column "metric_name" {+ type = "String"+ }+ column "count" {+ type = "Int64"+ }+ column "_timestamp" {+ type = "Nullable(DateTime)"+ }+ column "_offset" {+ type = "UInt64"+ }+ column "_partition" {+ type = "UInt64"+ }+ }++ materialized_view "app_metrics2_ws_mv" {+ to_table = "posthog.writable_app_metrics2"+ query = <<SQL+SELECT+ team_id,+ timestamp,+ app_source,+ app_source_id,+ instance_id,+ metric_kind,+ metric_name,+ count,+ _timestamp,+ _offset,+ _partition+FROM posthog.kafka_app_metrics2_ws+SQL++ column "team_id" {+ type = "Int64"+ }+ column "timestamp" {+ type = "DateTime64(6, 'UTC')"+ }+ column "app_source" {+ type = "LowCardinality(String)"+ }+ column "app_source_id" {+ type = "String"+ }+ column "instance_id" {+ type = "String"+ }+ column "metric_kind" {+ type = "String"+ }+ column "metric_name" {+ type = "String"+ }+ column "count" {+ type = "Int64"+ }+ column "_timestamp" {+ type = "Nullable(DateTime)"+ }+ column "_offset" {+ type = "UInt64"+ }+ column "_partition" {+ type = "UInt64"+ }+ }++ materialized_view "app_metrics_mv" {+ to_table = "posthog.writable_app_metrics"+ query = <<SQL+SELECT+ team_id,+ timestamp,+ plugin_config_id,+ category,+ job_id,+ successes,+ successes_on_retry,+ failures,+ error_uuid,+ error_type,+ error_details,+ _timestamp,+ _offset,+ _partition+FROM posthog.kafka_app_metrics+SQL++ column "team_id" {+ type = "Int64"+ }+ column "timestamp" {+ type = "DateTime64(6, 'UTC')"+ }+ column "plugin_config_id" {+ type = "Int64"+ }+ column "category" {+ type = "LowCardinality(String)"+ }+ column "job_id" {+ type = "String"+ }+ column "successes" {+ type = "Int64"+ }+ column "successes_on_retry" {+ type = "Int64"+ }+ column "failures" {+ type = "Int64"+ }+ column "error_uuid" {+ type = "UUID"+ }+ column "error_type" {+ type = "String"+ }+ column "error_details" {+ type = "String"+ }+ column "_timestamp" {+ type = "Nullable(DateTime)"+ }+ column "_offset" {+ type = "UInt64"+ }+ column "_partition" {+ type = "UInt64"+ }+ }++ materialized_view "cohort_membership_mv" {+ to_table = "posthog.writable_cohort_membership"+ query = <<SQL+SELECT+ team_id,+ cohort_id,+ person_id,+ multiIf(status = 'member', 'entered', status = 'not_member', 'left', status) AS status,+ last_updated+FROM posthog.kafka_cohort_membership+SQL++ column "team_id" {+ type = "Int64"+ }+ column "cohort_id" {+ type = "Int64"+ }+ column "person_id" {+ type = "UUID"+ }+ column "status" {+ type = "String"+ }+ column "last_updated" {+ type = "DateTime64(6)"+ }+ }++ materialized_view "distinct_id_usage_mv" {+ to_table = "posthog.writable_distinct_id_usage"+ query = <<SQL+SELECT team_id, distinct_id, toStartOfMinute(timestamp) AS minute, 1 AS event_count+FROM posthog.kafka_distinct_id_usage+SQL++ column "team_id" {+ type = "Int64"+ }+ column "distinct_id" {+ type = "String"+ }+ column "minute" {+ type = "DateTime('UTC')"+ }+ column "event_count" {+ type = "UInt8"+ }+ }++ materialized_view "duplicate_events_mv" {+ to_table = "posthog.writable_duplicate_events"+ query = <<SQL+SELECT+ team_id,+ distinct_id,+ event,+ source_uuid,+ duplicate_uuid,+ similarity_score,+ dedup_type,+ is_confirmed,+ reason,+ version,+ different_property_count,+ properties_similarity,+ source_message,+ duplicate_message,+ JSONExtract(+ distinct_fields,+ 'Array(Tuple(field_name String, original_value String, new_value String))'+ ) AS distinct_fields,+ inserted_at,+ _timestamp,+ _offset,+ _partition+FROM posthog.kafka_duplicate_events+SQL++ column "team_id" {+ type = "Int64"+ }+ column "distinct_id" {+ type = "String"+ }+ column "event" {+ type = "String"+ }+ column "source_uuid" {+ type = "UUID"+ }+ column "duplicate_uuid" {+ type = "UUID"+ }+ column "similarity_score" {+ type = "Float64"+ }+ column "dedup_type" {+ type = "LowCardinality(String)"+ }+ column "is_confirmed" {+ type = "UInt8"+ }+ column "reason" {+ type = "Nullable(String)"+ }+ column "version" {+ type = "String"+ }+ column "different_property_count" {+ type = "UInt32"+ }+ column "properties_similarity" {+ type = "Float64"+ }+ column "source_message" {+ type = "String"+ }+ column "duplicate_message" {+ type = "String"+ }+ column "distinct_fields" {+ type = "Array(Tuple(field_name String, original_value String, new_value String))"+ }+ column "inserted_at" {+ type = "DateTime64(3, 'UTC')"+ }+ column "_timestamp" {+ type = "Nullable(DateTime)"+ }+ column "_offset" {+ type = "UInt64"+ }+ column "_partition" {+ type = "UInt64"+ }+ }++ materialized_view "error_tracking_fingerprint_issue_state_mv" {+ to_table = "posthog.writable_error_tracking_fingerprint_issue_state"+ query = <<SQL+SELECT+ team_id,+ fingerprint,+ issue_id,+ issue_name,+ issue_description,+ issue_status,+ issue_severity,+ assigned_user_id,+ assigned_role_id,+ first_seen,+ is_deleted,+ version,+ _timestamp,+ _offset,+ _partition+FROM posthog.kafka_error_tracking_fingerprint_issue_state+SQL++ column "team_id" {+ type = "Int64"+ }+ column "fingerprint" {+ type = "String"+ }+ column "issue_id" {+ type = "UUID"+ }+ column "issue_name" {+ type = "Nullable(String)"+ }+ column "issue_description" {+ type = "Nullable(String)"+ }+ column "issue_status" {+ type = "String"+ }+ column "issue_severity" {+ type = "Nullable(String)"+ }+ column "assigned_user_id" {+ type = "Nullable(Int64)"+ }+ column "assigned_role_id" {+ type = "Nullable(UUID)"+ }+ column "first_seen" {+ type = "DateTime64(3, 'UTC')"+ }+ column "is_deleted" {+ type = "Int8"+ }+ column "version" {+ type = "Int64"+ }+ column "_timestamp" {+ type = "Nullable(DateTime)"+ }+ column "_offset" {+ type = "UInt64"+ }+ column "_partition" {+ type = "UInt64"+ }+ }++ materialized_view "error_tracking_issue_fingerprint_embeddings_mv" {+ to_table = "posthog.writable_error_tracking_issue_fingerprint_embeddings"+ query = <<SQL+SELECT+ team_id,+ model_name,+ embedding_version,+ fingerprint,+ _timestamp AS inserted_at,+ embeddings,+ _timestamp,+ _offset,+ _partition+FROM posthog.kafka_error_tracking_issue_fingerprint_embeddings+SQL++ column "team_id" {+ type = "Int64"+ }+ column "model_name" {+ type = "LowCardinality(String)"+ }+ column "embedding_version" {+ type = "Int64"+ }+ column "fingerprint" {+ type = "String"+ }+ column "inserted_at" {+ type = "Nullable(DateTime)"+ }+ column "embeddings" {+ type = "Array(Float64)"+ }+ column "_timestamp" {+ type = "Nullable(DateTime)"+ }+ column "_offset" {+ type = "UInt64"+ }+ column "_partition" {+ type = "UInt64"+ }+ }++ materialized_view "error_tracking_issue_fingerprint_overrides_mv" {+ to_table = "posthog.writable_error_tracking_issue_fingerprint_overrides"+ query = <<SQL+SELECT+ team_id,+ fingerprint,+ issue_id,+ is_deleted,+ version,+ _timestamp,+ _offset,+ _partition+FROM posthog.kafka_error_tracking_issue_fingerprint_overrides+WHERE version > 0+SQL++ column "team_id" {+ type = "Int64"+ }+ column "fingerprint" {+ type = "String"+ }+ column "issue_id" {+ type = "UUID"+ }+ column "is_deleted" {+ type = "Int8"+ }+ column "version" {+ type = "Int64"+ }+ column "_timestamp" {+ type = "Nullable(DateTime)"+ }+ column "_offset" {+ type = "UInt64"+ }+ column "_partition" {+ type = "UInt64"+ }+ }++ materialized_view "events_dead_letter_queue_mv" {+ to_table = "posthog.writable_events_dead_letter_queue"+ query = <<SQL+SELECT+ id,+ event_uuid,+ event,+ properties,+ distinct_id,+ team_id,+ elements_chain,+ created_at,+ ip,+ site_url,+ now,+ raw_payload,+ error_timestamp,+ error_location,+ error,+ tags,+ _timestamp,+ _offset+FROM posthog.kafka_events_dead_letter_queue+SQL++ column "id" {+ type = "UUID"+ }+ column "event_uuid" {+ type = "UUID"+ }+ column "event" {+ type = "String"+ }+ column "properties" {+ type = "String"+ }+ column "distinct_id" {+ type = "String"+ }+ column "team_id" {+ type = "Int64"+ }+ column "elements_chain" {+ type = "String"+ }+ column "created_at" {+ type = "DateTime64(6, 'UTC')"+ }+ column "ip" {+ type = "String"+ }+ column "site_url" {+ type = "String"+ }+ column "now" {+ type = "DateTime64(6, 'UTC')"+ }+ column "raw_payload" {+ type = "String"+ }+ column "error_timestamp" {+ type = "DateTime64(6, 'UTC')"+ }+ column "error_location" {+ type = "String"+ }+ column "error" {+ type = "String"+ }+ column "tags" {+ type = "Array(String)"+ }+ column "_timestamp" {+ type = "Nullable(DateTime)"+ }+ column "_offset" {+ type = "UInt64"+ }+ }++ materialized_view "events_json_mv" {+ to_table = "posthog.writable_events"+ query = <<SQL+SELECT+ uuid,+ event,+ properties,+ timestamp,+ team_id,+ distinct_id,+ elements_chain,+ created_at,+ person_id,+ person_created_at,+ person_properties,+ group0_properties,+ group1_properties,+ group2_properties,+ group3_properties,+ group4_properties,+ group0_created_at,+ group1_created_at,+ group2_created_at,+ group3_created_at,+ group4_created_at,+ person_mode,+ historical_migration,+ dmat_string_0,+ dmat_string_1,+ dmat_string_2,+ dmat_string_3,+ dmat_string_4,+ dmat_string_5,+ dmat_string_6,+ dmat_string_7,+ dmat_string_8,+ dmat_string_9,+ _timestamp,+ _offset,+ arrayMap(+ i -> (_headers.value[i]),+ arrayFilter(+ i -> ((_headers.name[i]) = 'kafka-consumer-breadcrumbs'),+ arrayEnumerate(_headers.name)+ )+ ) AS consumer_breadcrumbs+FROM posthog.kafka_events_json+SQL++ column "uuid" {+ type = "UUID"+ }+ column "event" {+ type = "String"+ }+ column "properties" {+ type = "String"+ }+ column "timestamp" {+ type = "DateTime64(6, 'UTC')"+ }+ column "team_id" {+ type = "Int64"+ }+ column "distinct_id" {+ type = "String"+ }+ column "elements_chain" {+ type = "String"+ }+ column "created_at" {+ type = "DateTime64(6, 'UTC')"+ }+ column "person_id" {+ type = "UUID"+ }+ column "person_created_at" {+ type = "DateTime64(3)"+ }+ column "person_properties" {+ type = "String"+ }+ column "group0_properties" {+ type = "String"+ }+ column "group1_properties" {+ type = "String"+ }+ column "group2_properties" {+ type = "String"+ }+ column "group3_properties" {+ type = "String"+ }+ column "group4_properties" {+ type = "String"+ }+ column "group0_created_at" {+ type = "DateTime64(3)"+ }+ column "group1_created_at" {+ type = "DateTime64(3)"+ }+ column "group2_created_at" {+ type = "DateTime64(3)"+ }+ column "group3_created_at" {+ type = "DateTime64(3)"+ }+ column "group4_created_at" {+ type = "DateTime64(3)"+ }+ column "person_mode" {+ type = "Enum8('full'=0, 'propertyless'=1, 'force_upgrade'=2)"+ }+ column "historical_migration" {+ type = "Bool"+ }+ column "dmat_string_0" {+ type = "Nullable(String)"+ }+ column "dmat_string_1" {+ type = "Nullable(String)"+ }+ column "dmat_string_2" {+ type = "Nullable(String)"+ }+ column "dmat_string_3" {+ type = "Nullable(String)"+ }+ column "dmat_string_4" {+ type = "Nullable(String)"+ }+ column "dmat_string_5" {+ type = "Nullable(String)"+ }+ column "dmat_string_6" {+ type = "Nullable(String)"+ }+ column "dmat_string_7" {+ type = "Nullable(String)"+ }+ column "dmat_string_8" {+ type = "Nullable(String)"+ }+ column "dmat_string_9" {+ type = "Nullable(String)"+ }+ column "_timestamp" {+ type = "Nullable(DateTime)"+ }+ column "_offset" {+ type = "UInt64"+ }+ column "consumer_breadcrumbs" {+ type = "Array(String)"+ }+ }++ materialized_view "events_json_table_mv" {+ to_table = "posthog.writable_events_json"+ query = <<SQL+SELECT+ uuid,+ event,+ ifNull(+ accurateCastOrNull(properties, 'JSON'),+ CAST(concat('{"$unparseable_properties":', toJSONString(properties), '}'), 'JSON')+ ) AS properties,+ timestamp,+ team_id,+ distinct_id,+ elements_chain,+ created_at,+ person_id,+ person_created_at,+ ifNull(+ accurateCastOrNull(person_properties, 'JSON'),+ CAST(concat('{"$unparseable_properties":', toJSONString(person_properties), '}'), 'JSON')+ ) AS person_properties,+ group0_properties,+ group1_properties,+ group2_properties,+ group3_properties,+ group4_properties,+ group0_created_at,+ group1_created_at,+ group2_created_at,+ group3_created_at,+ group4_created_at,+ person_mode,+ historical_migration,+ _timestamp,+ _offset,+ arrayMap(+ i -> (_headers.value[i]),+ arrayFilter(+ i -> ((_headers.name[i]) = 'kafka-consumer-breadcrumbs'),+ arrayEnumerate(_headers.name)+ )+ ) AS consumer_breadcrumbs+FROM posthog.kafka_events_json_native_json+SQL++ column "uuid" {+ type = "UUID"+ }+ column "event" {+ type = "String"+ }+ column "properties" {+ type = "JSON"+ }+ column "timestamp" {+ type = "DateTime64(6, 'UTC')"+ }+ column "team_id" {+ type = "Int64"+ }+ column "distinct_id" {+ type = "String"+ }+ column "elements_chain" {+ type = "String"+ }+ column "created_at" {+ type = "DateTime64(6, 'UTC')"+ }+ column "person_id" {+ type = "UUID"+ }+ column "person_created_at" {+ type = "DateTime64(3)"+ }+ column "person_properties" {+ type = "JSON"+ }+ column "group0_properties" {+ type = "String"+ }+ column "group1_properties" {+ type = "String"+ }+ column "group2_properties" {+ type = "String"+ }+ column "group3_properties" {+ type = "String"+ }+ column "group4_properties" {+ type = "String"+ }+ column "group0_created_at" {+ type = "DateTime64(3)"+ }+ column "group1_created_at" {+ type = "DateTime64(3)"+ }+ column "group2_created_at" {+ type = "DateTime64(3)"+ }+ column "group3_created_at" {+ type = "DateTime64(3)"+ }+ column "group4_created_at" {+ type = "DateTime64(3)"+ }+ column "person_mode" {+ type = "Enum8('full'=0, 'propertyless'=1, 'force_upgrade'=2)"+ }+ column "historical_migration" {+ type = "Bool"+ }+ column "_timestamp" {+ type = "Nullable(DateTime)"+ }+ column "_offset" {+ type = "UInt64"+ }+ column "consumer_breadcrumbs" {+ type = "Array(String)"+ }+ }++ materialized_view "events_recent_json_mv" {+ to_table = "posthog.writable_events_recent"+ query = <<SQL+SELECT+ uuid,+ event,+ properties,+ timestamp,+ team_id,+ distinct_id,+ elements_chain,+ created_at,+ person_id,+ person_created_at,+ person_properties,+ group0_properties,+ group1_properties,+ group2_properties,+ group3_properties,+ group4_properties,+ group0_created_at,+ group1_created_at,+ group2_created_at,+ group3_created_at,+ group4_created_at,+ person_mode,+ _timestamp,+ _offset+FROM posthog.sharded_events+SQL++ column "uuid" {+ type = "UUID"+ }+ column "event" {+ type = "String"+ }+ column "properties" {+ type = "String"+ }+ column "timestamp" {+ type = "DateTime64(6, 'UTC')"+ }+ column "team_id" {+ type = "Int64"+ }+ column "distinct_id" {+ type = "String"+ }+ column "elements_chain" {+ type = "String"+ }+ column "created_at" {+ type = "DateTime64(6, 'UTC')"+ }+ column "person_id" {+ type = "UUID"+ }+ column "person_created_at" {+ type = "DateTime64(3)"+ }+ column "person_properties" {+ type = "String"+ }+ column "group0_properties" {+ type = "String"+ }+ column "group1_properties" {+ type = "String"+ }+ column "group2_properties" {+ type = "String"+ }+ column "group3_properties" {+ type = "String"+ }+ column "group4_properties" {+ type = "String"+ }+ column "group0_created_at" {+ type = "DateTime64(3)"+ }+ column "group1_created_at" {+ type = "DateTime64(3)"+ }+ column "group2_created_at" {+ type = "DateTime64(3)"+ }+ column "group3_created_at" {+ type = "DateTime64(3)"+ }+ column "group4_created_at" {+ type = "DateTime64(3)"+ }+ column "person_mode" {+ type = "Enum8('full'=0, 'propertyless'=1, 'force_upgrade'=2)"+ }+ column "_timestamp" {+ type = "DateTime"+ }+ column "_offset" {+ type = "UInt64"+ }+ }++ materialized_view "flag_evaluations_mv" {+ to_table = "posthog.writable_flag_evaluations"+ query = <<SQL+SELECT+ uuid,+ event,+ properties,+ timestamp,+ team_id,+ distinct_id,+ created_at,+ person_id,+ person_properties,+ group0_properties,+ group1_properties,+ group2_properties,+ group3_properties,+ group4_properties,+ if(inserted_at = toDateTime64('1970-01-01 00:00:00', 6, 'UTC'), _timestamp, inserted_at) AS inserted_at,+ _timestamp,+ _offset,+ _partition+FROM posthog.kafka_flag_evaluations+SQL++ column "uuid" {+ type = "UUID"+ }+ column "event" {+ type = "LowCardinality(String)"+ }+ column "properties" {+ type = "String"+ }+ column "timestamp" {+ type = "DateTime64(6, 'UTC')"+ }+ column "team_id" {+ type = "Int64"+ }+ column "distinct_id" {+ type = "String"+ }+ column "created_at" {+ type = "DateTime64(6, 'UTC')"+ }+ column "person_id" {+ type = "UUID"+ }+ column "person_properties" {+ type = "String"+ }+ column "group0_properties" {+ type = "String"+ }+ column "group1_properties" {+ type = "String"+ }+ column "group2_properties" {+ type = "String"+ }+ column "group3_properties" {+ type = "String"+ }+ column "group4_properties" {+ type = "String"+ }+ column "inserted_at" {+ type = "Nullable(DateTime64(6, 'UTC'))"+ }+ column "_timestamp" {+ type = "Nullable(DateTime)"+ }+ column "_offset" {+ type = "UInt64"+ }+ column "_partition" {+ type = "UInt64"+ }+ }++ materialized_view "groups_mv" {+ to_table = "posthog.writable_groups"+ query = <<SQL+SELECT+ group_type_index,+ group_key,+ created_at,+ team_id,+ group_properties,+ _timestamp,+ _offset+FROM posthog.kafka_groups+SQL++ column "group_type_index" {+ type = "UInt8"+ }+ column "group_key" {+ type = "String"+ }+ column "created_at" {+ type = "DateTime64(3)"+ }+ column "team_id" {+ type = "Int64"+ }+ column "group_properties" {+ type = "String"+ }+ column "_timestamp" {+ type = "Nullable(DateTime)"+ }+ column "_offset" {+ type = "UInt64"+ }+ }++ materialized_view "heatmaps_mv" {+ to_table = "posthog.writable_heatmaps"+ query = <<SQL+SELECT+ session_id,+ team_id,+ distinct_id,+ timestamp,+ x,+ y,+ scale_factor,+ viewport_width,+ viewport_height,+ pointer_target_fixed,+ current_url,+ type,+ _timestamp,+ _offset,+ _partition+FROM posthog.kafka_heatmaps+SQL++ column "session_id" {+ type = "String"+ }+ column "team_id" {+ type = "Int64"+ }+ column "distinct_id" {+ type = "String"+ }+ column "timestamp" {+ type = "DateTime64(6, 'UTC')"+ }+ column "x" {+ type = "Int16"+ }+ column "y" {+ type = "Int16"+ }+ column "scale_factor" {+ type = "Int16"+ }+ column "viewport_width" {+ type = "Int16"+ }+ column "viewport_height" {+ type = "Int16"+ }+ column "pointer_target_fixed" {+ type = "Bool"+ }+ column "current_url" {+ type = "String"+ }+ column "type" {+ type = "LowCardinality(String)"+ }+ column "_timestamp" {+ type = "Nullable(DateTime)"+ }+ column "_offset" {+ type = "UInt64"+ }+ column "_partition" {+ type = "UInt64"+ }+ }++ materialized_view "hog_invocation_results_mv" {+ to_table = "posthog.hog_invocation_results_data"+ query = <<SQL+SELECT+ team_id,+ function_kind,+ function_id,+ invocation_id,+ parent_run_id,+ status,+ attempts,+ is_retry,+ scheduled_at,+ if(+ first_scheduled_at = toDateTime64('1970-01-01 00:00:00', 6, 'UTC'),+ scheduled_at,+ first_scheduled_at+ ) AS first_scheduled_at,+ started_at,+ finished_at,+ duration_ms,+ error_kind,+ error_message,+ event_uuid,+ distinct_id,+ person_id,+ invocation_globals,+ version,+ is_deleted,+ _timestamp,+ _offset,+ _partition+FROM posthog.kafka_hog_invocation_results+SQL++ column "team_id" {+ type = "Int64"+ }+ column "function_kind" {+ type = "LowCardinality(String)"+ }+ column "function_id" {+ type = "String"+ }+ column "invocation_id" {+ type = "String"+ }+ column "parent_run_id" {+ type = "String"+ }+ column "status" {+ type = "LowCardinality(String)"+ }+ column "attempts" {+ type = "UInt8"+ }+ column "is_retry" {+ type = "UInt8"+ }+ column "scheduled_at" {+ type = "DateTime64(6, 'UTC')"+ }+ column "first_scheduled_at" {+ type = "DateTime64(6, 'UTC')"+ }+ column "started_at" {+ type = "Nullable(DateTime64(6, 'UTC'))"+ }+ column "finished_at" {+ type = "Nullable(DateTime64(6, 'UTC'))"+ }+ column "duration_ms" {+ type = "Nullable(UInt32)"+ }+ column "error_kind" {+ type = "LowCardinality(String)"+ }+ column "error_message" {+ type = "String"+ }+ column "event_uuid" {+ type = "String"+ }+ column "distinct_id" {+ type = "String"+ }+ column "person_id" {+ type = "String"+ }+ column "invocation_globals" {+ type = "String"+ }+ column "version" {+ type = "UInt64"+ }+ column "is_deleted" {+ type = "UInt8"+ }+ column "_timestamp" {+ type = "Nullable(DateTime)"+ }+ column "_offset" {+ type = "UInt64"+ }+ column "_partition" {+ type = "UInt64"+ }+ }++ materialized_view "ingestion_warnings_mv" {+ to_table = "posthog.writable_ingestion_warnings"+ query = <<SQL+SELECT+ team_id,+ source,+ type,+ details,+ timestamp,+ _timestamp,+ _offset,+ _partition+FROM posthog.kafka_ingestion_warnings+SQL++ column "team_id" {+ type = "Int64"+ }+ column "source" {+ type = "LowCardinality(String)"+ }+ column "type" {+ type = "String"+ }+ column "details" {+ type = "String"+ }+ column "timestamp" {+ type = "DateTime64(6, 'UTC')"+ }+ column "_timestamp" {+ type = "Nullable(DateTime)"+ }+ column "_offset" {+ type = "UInt64"+ }+ column "_partition" {+ type = "UInt64"+ }+ }++ materialized_view "ingestion_warnings_v2_mv" {+ to_table = "posthog.ingestion_warnings_v2"+ query = <<SQL+SELECT+ team_id,+ source,+ type,+ details,+ timestamp,+ _timestamp,+ _offset,+ _partition+FROM posthog.kafka_ingestion_warnings_v2+SQL++ column "team_id" {+ type = "Int64"+ }+ column "source" {+ type = "LowCardinality(String)"+ }+ column "type" {+ type = "String"+ }+ column "details" {+ type = "String"+ }+ column "timestamp" {+ type = "DateTime64(6, 'UTC')"+ }+ column "_timestamp" {+ type = "Nullable(DateTime)"+ }+ column "_offset" {+ type = "UInt64"+ }+ column "_partition" {+ type = "UInt64"+ }+ }++ materialized_view "kafka_logs34_avro_mv" {+ to_table = "posthog.logs34"+ query = <<SQL+SELECT+ uuid,+ trace_id,+ span_id,+ trace_flags,+ timestamp,+ observed_timestamp,+ body,+ severity_text,+ severity_number,+ service_name,+ instrumentation_scope,+ event_name,+ mapSort(mapApply((k, v) -> (concat(k, '__str'), JSONExtractString(v)), attributes)) AS attributes_map_str,+ mapSort(mapApply((k, v) -> (k, JSONExtractString(v)), resource_attributes)) AS resource_attributes,+ toInt32OrZero(_headers.value[indexOf(_headers.name, 'team_id')]) AS team_id,+ observed_timestamp+ + toIntervalDay(+ toInt32OrDefault(_headers.value[indexOf(_headers.name, 'retention-days')], toInt32(15))+ ) AS original_expiry_timestamp,+ _partition,+ _topic,+ _offset,+ toInt64OrDefault(_headers.value[indexOf(_headers.name, 'record_count')], toInt64(1)) AS _record_count,+ toInt64OrNull(_headers.value[indexOf(_headers.name, 'bytes_uncompressed')]) / _record_count AS _bytes_uncompressed,+ toInt64OrNull(_headers.value[indexOf(_headers.name, 'bytes_compressed')]) / _record_count AS _bytes_compressed+FROM posthog.kafka_logs_avro+SQL++ column "uuid" {+ type = "String"+ }+ column "trace_id" {+ type = "String"+ }+ column "span_id" {+ type = "String"+ }+ column "trace_flags" {+ type = "Int32"+ }+ column "timestamp" {+ type = "DateTime64(6)"+ }+ column "observed_timestamp" {+ type = "DateTime64(6)"+ }+ column "body" {+ type = "String"+ }+ column "severity_text" {+ type = "String"+ }+ column "severity_number" {+ type = "Int32"+ }+ column "service_name" {+ type = "String"+ }+ column "instrumentation_scope" {+ type = "String"+ }+ column "event_name" {+ type = "String"+ }+ column "attributes_map_str" {+ type = "Map(String, String)"+ }+ column "resource_attributes" {+ type = "Map(String, String)"+ }+ column "team_id" {+ type = "Int32"+ }+ column "original_expiry_timestamp" {+ type = "DateTime64(6)"+ }+ column "_partition" {+ type = "UInt64"+ }+ column "_topic" {+ type = "LowCardinality(String)"+ }+ column "_offset" {+ type = "UInt64"+ }+ column "_record_count" {+ type = "Int64"+ }+ column "_bytes_uncompressed" {+ type = "Nullable(Int64)"+ }+ column "_bytes_compressed" {+ type = "Nullable(Int64)"+ }+ }++ materialized_view "kafka_logs_avro_billing_metrics_mv" {+ to_table = "posthog.logs_billing_metrics"+ query = <<SQL+SELECT+ team_id,+ time_bucket,+ service_name,+ sumSimpleState(_bytes_uncompressed) AS bytes_uncompressed,+ sumSimpleState(_bytes_compressed) AS bytes_compressed,+ sumSimpleState(1) AS record_count+FROM+ (+ SELECT+ team_id,+ toStartOfInterval(timestamp, toIntervalMinute(1)) AS time_bucket,+ service_name AS service_name,+ _bytes_uncompressed,+ _bytes_compressed+ FROM posthog.logs34+ )+GROUP BY+ team_id, time_bucket, service_name+SQL++ column "team_id" {+ type = "Int32"+ }+ column "time_bucket" {+ type = "DateTime"+ }+ column "service_name" {+ type = "LowCardinality(String)"+ }+ column "bytes_uncompressed" {+ type = "SimpleAggregateFunction(sum, Float64)"+ }+ column "bytes_compressed" {+ type = "SimpleAggregateFunction(sum, Float64)"+ }+ column "record_count" {+ type = "SimpleAggregateFunction(sum, UInt64)"+ }+ }++ materialized_view "kafka_logs_avro_kafka_metrics_mv" {+ to_table = "posthog.logs_kafka_metrics"+ query = <<SQL+SELECT+ _partition,+ _topic,+ maxSimpleState(_offset) AS max_offset,+ maxSimpleState(observed_timestamp) AS max_observed_timestamp,+ maxSimpleState(timestamp) AS max_timestamp,+ maxSimpleState(now()) AS max_created_at,+ maxSimpleState(now() - observed_timestamp) AS max_lag+FROM posthog.logs34+GROUP BY+ _partition, _topic+SQL++ column "_partition" {+ type = "UInt32"+ }+ column "_topic" {+ type = "String"+ }+ column "max_offset" {+ type = "SimpleAggregateFunction(max, UInt64)"+ }+ column "max_observed_timestamp" {+ type = "SimpleAggregateFunction(max, DateTime64(6))"+ }+ column "max_timestamp" {+ type = "SimpleAggregateFunction(max, DateTime64(6))"+ }+ column "max_created_at" {+ type = "SimpleAggregateFunction(max, DateTime)"+ }+ column "max_lag" {+ type = "SimpleAggregateFunction(max, Decimal(18, 6))"+ }+ }++ materialized_view "kafka_trace_spans_avro_mv" {+ to_table = "posthog.trace_spans"+ query = <<SQL+SELECT+ * EXCEPT(attributes, resource_attributes, kind, flags, dropped_attributes_count, dropped_events_count, dropped_links_count, status_code),+ toInt8(kind) AS kind,+ toUInt32(flags) AS flags,+ toUInt32(dropped_attributes_count) AS dropped_attributes_count,+ toUInt32(dropped_events_count) AS dropped_events_count,+ toUInt32(dropped_links_count) AS dropped_links_count,+ toInt16(status_code) AS status_code,+ mapSort(mapApply((k, v) -> (concat(k, '__str'), JSONExtractString(v)), attributes)) AS attributes_map_str,+ mapSort(mapApply((k, v) -> (k, JSONExtractString(v)), resource_attributes)) AS resource_attributes,+ toInt32OrZero(_headers.value[indexOf(_headers.name, 'team_id')]) AS team_id,+ observed_timestamp+ + toIntervalDay(+ toInt32OrDefault(_headers.value[indexOf(_headers.name, 'retention-days')], toInt32(15))+ ) AS original_expiry_timestamp,+ _partition,+ _topic,+ _offset,+ toInt64OrDefault(_headers.value[indexOf(_headers.name, 'record_count')], toInt64(1)) AS _record_count,+ toInt64OrDefault(_headers.value[indexOf(_headers.name, 'bytes_uncompressed')], toInt64(0)) AS _bytes_uncompressed,+ toInt64OrDefault(_headers.value[indexOf(_headers.name, 'bytes_compressed')], toInt64(0)) AS _bytes_compressed+FROM posthog.kafka_trace_spans_avro+SQL++ column "uuid" {+ type = "String"+ }+ column "trace_id" {+ type = "String"+ }+ column "span_id" {+ type = "String"+ }+ column "parent_span_id" {+ type = "String"+ }+ column "trace_state" {+ type = "String"+ }+ column "name" {+ type = "String"+ }+ column "kind" {+ type = "Int8"+ }+ column "flags" {+ type = "UInt32"+ }+ column "timestamp" {+ type = "DateTime64(6)"+ }+ column "end_time" {+ type = "DateTime64(6)"+ }+ column "observed_timestamp" {+ type = "DateTime64(6)"+ }+ column "service_name" {+ type = "String"+ }+ column "resource_attributes" {+ type = "Map(LowCardinality(String), String)"+ }+ column "instrumentation_scope" {+ type = "String"+ }+ column "attributes_map_str" {+ type = "Map(LowCardinality(String), String)"+ }+ column "dropped_attributes_count" {+ type = "UInt32"+ }+ column "events" {+ type = "Array(String)"+ }+ column "dropped_events_count" {+ type = "UInt32"+ }+ column "links" {+ type = "Array(String)"+ }+ column "dropped_links_count" {+ type = "UInt32"+ }+ column "status_code" {+ type = "Int16"+ }+ column "team_id" {+ type = "Int32"+ }+ column "original_expiry_timestamp" {+ type = "DateTime64(6)"+ }+ }++ materialized_view "log_entries_v3_mv" {+ to_table = "posthog.writable_log_entries"+ query = <<SQL+SELECT+ team_id,+ log_source,+ log_source_id,+ instance_id,+ timestamp,+ level,+ message,+ _timestamp,+ _offset+FROM posthog.kafka_log_entries_v3+WHERE toDate(timestamp) <= today()+SQL++ column "team_id" {+ type = "UInt64"+ }+ column "log_source" {+ type = "LowCardinality(String)"+ }+ column "log_source_id" {+ type = "String"+ }+ column "instance_id" {+ type = "String"+ }+ column "timestamp" {+ type = "DateTime64(6, 'UTC')"+ }+ column "level" {+ type = "LowCardinality(String)"+ }+ column "message" {+ type = "String"+ }+ column "_timestamp" {+ type = "Nullable(DateTime)"+ }+ column "_offset" {+ type = "UInt64"+ }+ }++ materialized_view "log_entries_ws_mv" {+ to_table = "posthog.writable_log_entries"+ query = <<SQL+SELECT+ team_id,+ log_source,+ log_source_id,+ instance_id,+ timestamp,+ level,+ message,+ _timestamp,+ _offset+FROM posthog.kafka_log_entries_ws+WHERE toDate(timestamp) <= today()+SQL++ column "team_id" {+ type = "UInt64"+ }+ column "log_source" {+ type = "LowCardinality(String)"+ }+ column "log_source_id" {+ type = "String"+ }+ column "instance_id" {+ type = "String"+ }+ column "timestamp" {+ type = "DateTime64(6, 'UTC')"+ }+ column "level" {+ type = "LowCardinality(String)"+ }+ column "message" {+ type = "String"+ }+ column "_timestamp" {+ type = "Nullable(DateTime)"+ }+ column "_offset" {+ type = "UInt64"+ }+ }++ materialized_view "logs32_to_log_attributes" {+ to_table = "posthog.log_attributes"+ query = <<SQL+SELECT+ team_id,+ time_bucket,+ original_expiry_time_bucket,+ service_name,+ resource_fingerprint,+ attribute_key,+ attribute_value,+ attribute_type,+ attribute_count+FROM+ (+ SELECT+ team_id AS team_id,+ toStartOfInterval(timestamp, toIntervalMinute(10)) AS time_bucket,+ toStartOfInterval(original_expiry_timestamp, toIntervalMinute(10)) AS original_expiry_time_bucket,+ service_name AS service_name,+ resource_fingerprint,+ mapFilter((k, v) -> ((length(k) < 256) AND (length(v) < 256)), attributes) AS attributes,+ arrayJoin(attributes) AS attribute,+ 'log' AS attribute_type,+ attribute.1 AS attribute_key,+ attribute.2 AS attribute_value,+ sumSimpleState(1) AS attribute_count+ FROM posthog.logs32+ GROUP BY+ team_id, time_bucket, original_expiry_time_bucket, service_name, resource_fingerprint, attributes+ )+SQL++ column "team_id" {+ type = "Int32"+ }+ column "time_bucket" {+ type = "DateTime64(0)"+ }+ column "original_expiry_time_bucket" {+ type = "DateTime64(0)"+ }+ column "service_name" {+ type = "LowCardinality(String)"+ }+ column "resource_fingerprint" {+ type = "UInt64"+ }+ column "attribute_key" {+ type = "LowCardinality(String)"+ }+ column "attribute_value" {+ type = "String"+ }+ column "attribute_type" {+ type = "LowCardinality(String)"+ }+ column "attribute_count" {+ type = "SimpleAggregateFunction(sum, UInt64)"+ }+ }++ materialized_view "logs32_to_resource_attributes" {+ to_table = "posthog.log_attributes"+ query = <<SQL+SELECT+ team_id,+ time_bucket,+ original_expiry_time_bucket,+ service_name,+ resource_fingerprint,+ attribute_key,+ attribute_value,+ attribute_type,+ attribute_count+FROM+ (+ SELECT+ team_id AS team_id,+ toStartOfInterval(timestamp, toIntervalMinute(10)) AS time_bucket,+ toStartOfInterval(original_expiry_timestamp, toIntervalMinute(10)) AS original_expiry_time_bucket,+ service_name AS service_name,+ resource_fingerprint,+ arrayJoin(resource_attributes) AS attribute,+ 'resource' AS attribute_type,+ attribute.1 AS attribute_key,+ attribute.2 AS attribute_value,+ sumSimpleState(1) AS attribute_count+ FROM posthog.logs32+ GROUP BY+ team_id, time_bucket, original_expiry_time_bucket, service_name, resource_fingerprint, resource_attributes+ )+SQL++ column "team_id" {+ type = "Int32"+ }+ column "time_bucket" {+ type = "DateTime64(0)"+ }+ column "original_expiry_time_bucket" {+ type = "DateTime64(0)"+ }+ column "service_name" {+ type = "LowCardinality(String)"+ }+ column "resource_fingerprint" {+ type = "UInt64"+ }+ column "attribute_key" {+ type = "LowCardinality(String)"+ }+ column "attribute_value" {+ type = "String"+ }+ column "attribute_type" {+ type = "LowCardinality(String)"+ }+ column "attribute_count" {+ type = "SimpleAggregateFunction(sum, UInt64)"+ }+ }++ materialized_view "logs34_to_log_attributes" {+ to_table = "posthog.log_attributes2"+ query = <<SQL+SELECT+ team_id,+ time_bucket,+ original_expiry_time_bucket,+ service_name,+ resource_fingerprint,+ attribute_key,+ attribute_value,+ attribute_type,+ attribute_count+FROM+ (+ SELECT+ team_id AS team_id,+ toStartOfInterval(timestamp, toIntervalMinute(10)) AS time_bucket,+ toStartOfInterval(original_expiry_timestamp, toIntervalMinute(10)) AS original_expiry_time_bucket,+ service_name AS service_name,+ resource_fingerprint,+ mapFilter((k, v) -> ((length(k) < 256) AND (length(v) < 256)), attributes) AS attributes,+ arrayJoin(attributes) AS attribute,+ 'log' AS attribute_type,+ attribute.1 AS attribute_key,+ attribute.2 AS attribute_value,+ sumSimpleState(1) AS attribute_count+ FROM posthog.logs34+ GROUP BY+ team_id, time_bucket, original_expiry_time_bucket, service_name, resource_fingerprint, attributes+ )+SQL++ column "team_id" {+ type = "Int32"+ }+ column "time_bucket" {+ type = "DateTime64(0)"+ }+ column "original_expiry_time_bucket" {+ type = "DateTime64(0)"+ }+ column "service_name" {+ type = "LowCardinality(String)"+ }+ column "resource_fingerprint" {+ type = "UInt64"+ }+ column "attribute_key" {+ type = "LowCardinality(String)"+ }+ column "attribute_value" {+ type = "String"+ }+ column "attribute_type" {+ type = "LowCardinality(String)"+ }+ column "attribute_count" {+ type = "SimpleAggregateFunction(sum, UInt64)"+ }+ }++ materialized_view "logs34_to_log_attributes3" {+ to_table = "posthog.log_attributes3"+ query = <<SQL+SELECT+ team_id,+ time_bucket,+ original_expiry_time_bucket,+ service_name,+ resource_fingerprint,+ attribute_key,+ attribute_value,+ attribute_type,+ severity_text,+ attribute_count+FROM+ (+ SELECT+ team_id AS team_id,+ toStartOfInterval(timestamp, toIntervalMinute(10)) AS time_bucket,+ toStartOfInterval(original_expiry_timestamp, toIntervalMinute(10)) AS original_expiry_time_bucket,+ service_name AS service_name,+ resource_fingerprint,+ severity_text AS severity_text,+ mapFilter((k, v) -> ((length(k) < 256) AND (length(v) < 256)), attributes) AS attributes,+ arrayJoin(attributes) AS attribute,+ 'log' AS attribute_type,+ attribute.1 AS attribute_key,+ attribute.2 AS attribute_value,+ sumSimpleState(1) AS attribute_count+ FROM posthog.logs34+ GROUP BY+ team_id, time_bucket, original_expiry_time_bucket, service_name, resource_fingerprint, severity_text, attributes+ )+SQL++ column "team_id" {+ type = "Int32"+ }+ column "time_bucket" {+ type = "DateTime64(0)"+ }+ column "original_expiry_time_bucket" {+ type = "DateTime64(0)"+ }+ column "service_name" {+ type = "LowCardinality(String)"+ }+ column "resource_fingerprint" {+ type = "UInt64"+ }+ column "attribute_key" {+ type = "LowCardinality(String)"+ }+ column "attribute_value" {+ type = "String"+ }+ column "attribute_type" {+ type = "LowCardinality(String)"+ }+ column "severity_text" {+ type = "LowCardinality(String)"+ }+ column "attribute_count" {+ type = "SimpleAggregateFunction(sum, UInt64)"+ }+ }++ materialized_view "logs34_to_resource_attributes" {+ to_table = "posthog.log_attributes2"+ query = <<SQL+SELECT+ team_id,+ time_bucket,+ original_expiry_time_bucket,+ service_name,+ resource_fingerprint,+ attribute_key,+ attribute_value,+ attribute_type,+ attribute_count+FROM+ (+ SELECT+ team_id AS team_id,+ toStartOfInterval(timestamp, toIntervalMinute(10)) AS time_bucket,+ toStartOfInterval(original_expiry_timestamp, toIntervalMinute(10)) AS original_expiry_time_bucket,+ service_name AS service_name,+ resource_fingerprint,+ arrayJoin(resource_attributes) AS attribute,+ 'resource' AS attribute_type,+ attribute.1 AS attribute_key,+ attribute.2 AS attribute_value,+ sumSimpleState(1) AS attribute_count+ FROM posthog.logs34+ GROUP BY+ team_id, time_bucket, original_expiry_time_bucket, service_name, resource_fingerprint, resource_attributes+ )+SQL++ column "team_id" {+ type = "Int32"+ }+ column "time_bucket" {+ type = "DateTime64(0)"+ }+ column "original_expiry_time_bucket" {+ type = "DateTime64(0)"+ }+ column "service_name" {+ type = "LowCardinality(String)"+ }+ column "resource_fingerprint" {+ type = "UInt64"+ }+ column "attribute_key" {+ type = "LowCardinality(String)"+ }+ column "attribute_value" {+ type = "String"+ }+ column "attribute_type" {+ type = "LowCardinality(String)"+ }+ column "attribute_count" {+ type = "SimpleAggregateFunction(sum, UInt64)"+ }+ }++ materialized_view "logs34_to_resource_attributes3" {+ to_table = "posthog.log_attributes3"+ query = <<SQL+SELECT+ team_id,+ time_bucket,+ original_expiry_time_bucket,+ service_name,+ resource_fingerprint,+ attribute_key,+ attribute_value,+ attribute_type,+ severity_text,+ attribute_count+FROM+ (+ SELECT+ team_id AS team_id,+ toStartOfInterval(timestamp, toIntervalMinute(10)) AS time_bucket,+ toStartOfInterval(original_expiry_timestamp, toIntervalMinute(10)) AS original_expiry_time_bucket,+ service_name AS service_name,+ resource_fingerprint,+ severity_text AS severity_text,+ arrayJoin(resource_attributes) AS attribute,+ 'resource' AS attribute_type,+ attribute.1 AS attribute_key,+ attribute.2 AS attribute_value,+ sumSimpleState(1) AS attribute_count+ FROM posthog.logs34+ GROUP BY+ team_id, time_bucket, original_expiry_time_bucket, service_name, resource_fingerprint, severity_text, resource_attributes+ )+SQL++ column "team_id" {+ type = "Int32"+ }+ column "time_bucket" {+ type = "DateTime64(0)"+ }+ column "original_expiry_time_bucket" {+ type = "DateTime64(0)"+ }+ column "service_name" {+ type = "LowCardinality(String)"+ }+ column "resource_fingerprint" {+ type = "UInt64"+ }+ column "attribute_key" {+ type = "LowCardinality(String)"+ }+ column "attribute_value" {+ type = "String"+ }+ column "attribute_type" {+ type = "LowCardinality(String)"+ }+ column "severity_text" {+ type = "LowCardinality(String)"+ }+ column "attribute_count" {+ type = "SimpleAggregateFunction(sum, UInt64)"+ }+ }++ materialized_view "message_assets_mv" {+ to_table = "posthog.message_assets_data"+ query = <<SQL+SELECT+ team_id,+ function_kind,+ function_id,+ parent_run_id,+ invocation_id,+ action_id,+ kind,+ distinct_id,+ person_id,+ recipient,+ subject,+ status,+ sent_at,+ version,+ is_deleted,+ html,+ _timestamp,+ _offset,+ _partition+FROM posthog.kafka_message_assets+SQL++ column "team_id" {+ type = "Int64"+ }+ column "function_kind" {+ type = "LowCardinality(String)"+ }+ column "function_id" {+ type = "String"+ }+ column "parent_run_id" {+ type = "String"+ }+ column "invocation_id" {+ type = "String"+ }+ column "action_id" {+ type = "String"+ }+ column "kind" {+ type = "LowCardinality(String)"+ }+ column "distinct_id" {+ type = "String"+ }+ column "person_id" {+ type = "String"+ }+ column "recipient" {+ type = "String"+ }+ column "subject" {+ type = "String"+ }+ column "status" {+ type = "LowCardinality(String)"+ }+ column "sent_at" {+ type = "DateTime64(6, 'UTC')"+ }+ column "version" {+ type = "UInt64"+ }+ column "is_deleted" {+ type = "UInt8"+ }+ column "html" {+ type = "String"+ }+ column "_timestamp" {+ type = "Nullable(DateTime)"+ }+ column "_offset" {+ type = "UInt64"+ }+ column "_partition" {+ type = "UInt64"+ }+ }++ materialized_view "ops_query_log_archive_mv" {+ to_table = "posthog.writable_query_log_archive"+ query = <<SQL+SELECT+ hostname,+ user,+ query_id,+ initial_query_id,+ is_initial_query,+ type,+ event_date,+ event_time,+ event_time_microseconds,+ query_start_time,+ query_start_time_microseconds,+ query_duration_ms,+ read_rows,+ read_bytes,+ written_rows,+ written_bytes,+ result_rows,+ result_bytes,+ memory_usage,+ peak_threads_usage,+ current_database,+ query,+ formatted_query,+ normalized_query_hash,+ query_kind,+ exception_code,+ exception,+ stack_trace,+ JSONExtractInt(log_comment, 'team_id') AS team_id,+ if(isValidJSON(log_comment), log_comment, '{}') AS log_comment,+ ProfileEvents+FROM system.query_log+WHERE type != 'QueryStart'+SQL++ column "hostname" {+ type = "LowCardinality(String)"+ }+ column "user" {+ type = "LowCardinality(String)"+ }+ column "query_id" {+ type = "String"+ }+ column "initial_query_id" {+ type = "String"+ }+ column "is_initial_query" {+ type = "UInt8"+ }+ column "type" {+ type = "Enum8('QueryStart'=1, 'QueryFinish'=2, 'ExceptionBeforeStart'=3, 'ExceptionWhileProcessing'=4)"+ }+ column "event_date" {+ type = "Date"+ }+ column "event_time" {+ type = "DateTime"+ }+ column "event_time_microseconds" {+ type = "DateTime64(6)"+ }+ column "query_start_time" {+ type = "DateTime"+ }+ column "query_start_time_microseconds" {+ type = "DateTime64(6)"+ }+ column "query_duration_ms" {+ type = "UInt64"+ }+ column "read_rows" {+ type = "UInt64"+ }+ column "read_bytes" {+ type = "UInt64"+ }+ column "written_rows" {+ type = "UInt64"+ }+ column "written_bytes" {+ type = "UInt64"+ }+ column "result_rows" {+ type = "UInt64"+ }+ column "result_bytes" {+ type = "UInt64"+ }+ column "memory_usage" {+ type = "UInt64"+ }+ column "peak_threads_usage" {+ type = "UInt64"+ }+ column "current_database" {+ type = "LowCardinality(String)"+ }+ column "query" {+ type = "String"+ }+ column "formatted_query" {+ type = "String"+ }+ column "normalized_query_hash" {+ type = "UInt64"+ }+ column "query_kind" {+ type = "LowCardinality(String)"+ }+ column "exception_code" {+ type = "Int32"+ }+ column "exception" {+ type = "String"+ }+ column "stack_trace" {+ type = "String"+ }+ column "team_id" {+ type = "Int64"+ }+ column "log_comment" {+ type = "String"+ }+ column "ProfileEvents" {+ type = "Map(LowCardinality(String), UInt64)"+ }+ }++ materialized_view "performance_events_mv" {+ to_table = "posthog.writeable_performance_events"+ query = <<SQL+SELECT+ uuid,+ session_id,+ window_id,+ pageview_id,+ distinct_id,+ timestamp,+ time_origin,+ entry_type,+ name,+ team_id,+ current_url,+ start_time,+ duration,+ redirect_start,+ redirect_end,+ worker_start,+ fetch_start,+ domain_lookup_start,+ domain_lookup_end,+ connect_start,+ secure_connection_start,+ connect_end,+ request_start,+ response_start,+ response_end,+ decoded_body_size,+ encoded_body_size,+ initiator_type,+ next_hop_protocol,+ render_blocking_status,+ response_status,+ transfer_size,+ largest_contentful_paint_element,+ largest_contentful_paint_render_time,+ largest_contentful_paint_load_time,+ largest_contentful_paint_size,+ largest_contentful_paint_id,+ largest_contentful_paint_url,+ dom_complete,+ dom_content_loaded_event,+ dom_interactive,+ load_event_end,+ load_event_start,+ redirect_count,+ navigation_type,+ unload_event_end,+ unload_event_start,+ _timestamp,+ _offset,+ _partition+FROM posthog.kafka_performance_events+SQL++ column "uuid" {+ type = "UUID"+ }+ column "session_id" {+ type = "String"+ }+ column "window_id" {+ type = "String"+ }+ column "pageview_id" {+ type = "String"+ }+ column "distinct_id" {+ type = "String"+ }+ column "timestamp" {+ type = "DateTime64(3)"+ }+ column "time_origin" {+ type = "DateTime64(3, 'UTC')"+ }+ column "entry_type" {+ type = "LowCardinality(String)"+ }+ column "name" {+ type = "String"+ }+ column "team_id" {+ type = "Int64"+ }+ column "current_url" {+ type = "String"+ }+ column "start_time" {+ type = "Float64"+ }+ column "duration" {+ type = "Float64"+ }+ column "redirect_start" {+ type = "Float64"+ }+ column "redirect_end" {+ type = "Float64"+ }+ column "worker_start" {+ type = "Float64"+ }+ column "fetch_start" {+ type = "Float64"+ }+ column "domain_lookup_start" {+ type = "Float64"+ }+ column "domain_lookup_end" {+ type = "Float64"+ }+ column "connect_start" {+ type = "Float64"+ }+ column "secure_connection_start" {+ type = "Float64"+ }+ column "connect_end" {+ type = "Float64"+ }+ column "request_start" {+ type = "Float64"+ }+ column "response_start" {+ type = "Float64"+ }+ column "response_end" {+ type = "Float64"+ }+ column "decoded_body_size" {+ type = "Int64"+ }+ column "encoded_body_size" {+ type = "Int64"+ }+ column "initiator_type" {+ type = "LowCardinality(String)"+ }+ column "next_hop_protocol" {+ type = "LowCardinality(String)"+ }+ column "render_blocking_status" {+ type = "LowCardinality(String)"+ }+ column "response_status" {+ type = "Int64"+ }+ column "transfer_size" {+ type = "Int64"+ }+ column "largest_contentful_paint_element" {+ type = "String"+ }+ column "largest_contentful_paint_render_time" {+ type = "Float64"+ }+ column "largest_contentful_paint_load_time" {+ type = "Float64"+ }+ column "largest_contentful_paint_size" {+ type = "Float64"+ }+ column "largest_contentful_paint_id" {+ type = "String"+ }+ column "largest_contentful_paint_url" {+ type = "String"+ }+ column "dom_complete" {+ type = "Float64"+ }+ column "dom_content_loaded_event" {+ type = "Float64"+ }+ column "dom_interactive" {+ type = "Float64"+ }+ column "load_event_end" {+ type = "Float64"+ }+ column "load_event_start" {+ type = "Float64"+ }+ column "redirect_count" {+ type = "Int64"+ }+ column "navigation_type" {+ type = "LowCardinality(String)"+ }+ column "unload_event_end" {+ type = "Float64"+ }+ column "unload_event_start" {+ type = "Float64"+ }+ column "_timestamp" {+ type = "Nullable(DateTime)"+ }+ column "_offset" {+ type = "UInt64"+ }+ column "_partition" {+ type = "UInt64"+ }+ }++ materialized_view "person_distinct_id2_mv" {+ to_table = "posthog.writable_person_distinct_id2"+ query = <<SQL+SELECT+ team_id,+ distinct_id,+ person_id,+ is_deleted,+ version,+ _timestamp,+ _offset,+ _partition+FROM posthog.kafka_person_distinct_id2+SQL++ column "team_id" {+ type = "Int64"+ }+ column "distinct_id" {+ type = "String"+ }+ column "person_id" {+ type = "UUID"+ }+ column "is_deleted" {+ type = "Int8"+ }+ column "version" {+ type = "Int64"+ }+ column "_timestamp" {+ type = "Nullable(DateTime)"+ }+ column "_offset" {+ type = "UInt64"+ }+ column "_partition" {+ type = "UInt64"+ }+ }++ materialized_view "person_distinct_id_mv" {+ to_table = "posthog.person_distinct_id"+ query = <<SQL+SELECT+ distinct_id,+ person_id,+ team_id,+ coalesce(_sign, if(is_deleted = 0, 1, -1)) AS _sign,+ _timestamp,+ _offset+FROM posthog.kafka_person_distinct_id+SQL++ column "distinct_id" {+ type = "String"+ }+ column "person_id" {+ type = "UUID"+ }+ column "team_id" {+ type = "Int64"+ }+ column "_sign" {+ type = "Int16"+ }+ column "_timestamp" {+ type = "Nullable(DateTime)"+ }+ column "_offset" {+ type = "UInt64"+ }+ }++ materialized_view "person_distinct_id_overrides_mv" {+ to_table = "posthog.writable_person_distinct_id_overrides"+ query = <<SQL+SELECT+ team_id,+ distinct_id,+ person_id,+ is_deleted,+ version,+ _timestamp,+ _offset,+ _partition+FROM posthog.kafka_person_distinct_id_overrides+WHERE version > 0+SQL++ column "team_id" {+ type = "Int64"+ }+ column "distinct_id" {+ type = "String"+ }+ column "person_id" {+ type = "UUID"+ }+ column "is_deleted" {+ type = "Int8"+ }+ column "version" {+ type = "Int64"+ }+ column "_timestamp" {+ type = "Nullable(DateTime)"+ }+ column "_offset" {+ type = "UInt64"+ }+ column "_partition" {+ type = "UInt64"+ }+ }++ materialized_view "person_mv" {+ to_table = "posthog.writable_person"+ query = <<SQL+SELECT+ id,+ created_at,+ team_id,+ properties,+ is_identified,+ is_deleted,+ version,+ last_seen_at,+ _timestamp,+ _offset+FROM posthog.kafka_person+SQL++ column "id" {+ type = "UUID"+ }+ column "created_at" {+ type = "DateTime64(3)"+ }+ column "team_id" {+ type = "Int64"+ }+ column "properties" {+ type = "String"+ }+ column "is_identified" {+ type = "Int8"+ }+ column "is_deleted" {+ type = "Int8"+ }+ column "version" {+ type = "UInt64"+ }+ column "last_seen_at" {+ type = "Nullable(DateTime64(3))"+ }+ column "_timestamp" {+ type = "Nullable(DateTime)"+ }+ column "_offset" {+ type = "UInt64"+ }+ }++ materialized_view "person_overrides_mv" {+ to_table = "posthog.person_overrides"+ query = <<SQL+SELECT team_id, old_person_id, override_person_id, merged_at, oldest_event, version+FROM posthog.kafka_person_overrides+SQL++ column "team_id" {+ type = "Int32"+ }+ column "old_person_id" {+ type = "UUID"+ }+ column "override_person_id" {+ type = "UUID"+ }+ column "merged_at" {+ type = "DateTime64(6, 'UTC')"+ }+ column "oldest_event" {+ type = "DateTime64(6, 'UTC')"+ }+ column "version" {+ type = "Int32"+ }+ }++ materialized_view "plugin_log_entries_mv" {+ to_table = "posthog.writable_plugin_log_entries"+ query = <<SQL+SELECT+ id,+ team_id,+ plugin_id,+ plugin_config_id,+ timestamp,+ source,+ type,+ message,+ instance_id,+ _timestamp,+ _offset+FROM posthog.kafka_plugin_log_entries+SQL++ column "id" {+ type = "UUID"+ }+ column "team_id" {+ type = "Int64"+ }+ column "plugin_id" {+ type = "Int64"+ }+ column "plugin_config_id" {+ type = "Int64"+ }+ column "timestamp" {+ type = "DateTime64(6, 'UTC')"+ }+ column "source" {+ type = "String"+ }+ column "type" {+ type = "String"+ }+ column "message" {+ type = "String"+ }+ column "instance_id" {+ type = "UUID"+ }+ column "_timestamp" {+ type = "Nullable(DateTime)"+ }+ column "_offset" {+ type = "UInt64"+ }+ }++ materialized_view "posthog_document_embeddings_kafka_to_buffer_mv" {+ to_table = "posthog.writable_posthog_document_embeddings_buffer"+ query = <<SQL+SELECT+ team_id,+ product,+ document_type,+ model_name,+ rendering,+ document_id,+ timestamp,+ _timestamp AS inserted_at,+ coalesce(content, '') AS content,+ coalesce(metadata, '{}') AS metadata,+ embedding,+ _timestamp,+ _offset,+ _partition+FROM posthog.kafka_posthog_document_embeddings+SQL++ column "team_id" {+ type = "Int64"+ }+ column "product" {+ type = "LowCardinality(String)"+ }+ column "document_type" {+ type = "LowCardinality(String)"+ }+ column "model_name" {+ type = "LowCardinality(String)"+ }+ column "rendering" {+ type = "LowCardinality(String)"+ }+ column "document_id" {+ type = "String"+ }+ column "timestamp" {+ type = "DateTime64(3, 'UTC')"+ }+ column "inserted_at" {+ type = "Nullable(DateTime)"+ }+ column "content" {+ type = "String"+ }+ column "metadata" {+ type = "String"+ }+ column "embedding" {+ type = "Array(Float64)"+ }+ column "_timestamp" {+ type = "Nullable(DateTime)"+ }+ column "_offset" {+ type = "UInt64"+ }+ column "_partition" {+ type = "UInt64"+ }+ }++ materialized_view "posthog_document_embeddings_text_embedding_3_large_3072_mv" {+ to_table = "posthog.writable_posthog_document_embeddings_text_embedding_3_large_3072"+ query = <<SQL+SELECT+ team_id,+ product,+ document_type,+ rendering,+ document_id,+ timestamp,+ inserted_at,+ content,+ metadata,+ embedding,+ _timestamp,+ _offset,+ _partition+FROM posthog.sharded_posthog_document_embeddings_buffer+WHERE model_name = 'text-embedding-3-large-3072'+SQL++ column "team_id" {+ type = "Int64"+ }+ column "product" {+ type = "LowCardinality(String)"+ }+ column "document_type" {+ type = "LowCardinality(String)"+ }+ column "rendering" {+ type = "LowCardinality(String)"+ }+ column "document_id" {+ type = "String"+ }+ column "timestamp" {+ type = "DateTime64(3, 'UTC')"+ }+ column "inserted_at" {+ type = "DateTime64(3, 'UTC')"+ }+ column "content" {+ type = "String"+ }+ column "metadata" {+ type = "String"+ }+ column "embedding" {+ type = "Array(Float64)"+ }+ column "_timestamp" {+ type = "DateTime"+ }+ column "_offset" {+ type = "UInt64"+ }+ column "_partition" {+ type = "UInt64"+ }+ }++ materialized_view "posthog_document_embeddings_text_embedding_3_small_1536_mv" {+ to_table = "posthog.writable_posthog_document_embeddings_text_embedding_3_small_1536"+ query = <<SQL+SELECT+ team_id,+ product,+ document_type,+ rendering,+ document_id,+ timestamp,+ inserted_at,+ content,+ metadata,+ embedding,+ _timestamp,+ _offset,+ _partition+FROM posthog.sharded_posthog_document_embeddings_buffer+WHERE model_name = 'text-embedding-3-small-1536'+SQL++ column "team_id" {+ type = "Int64"+ }+ column "product" {+ type = "LowCardinality(String)"+ }+ column "document_type" {+ type = "LowCardinality(String)"+ }+ column "rendering" {+ type = "LowCardinality(String)"+ }+ column "document_id" {+ type = "String"+ }+ column "timestamp" {+ type = "DateTime64(3, 'UTC')"+ }+ column "inserted_at" {+ type = "DateTime64(3, 'UTC')"+ }+ column "content" {+ type = "String"+ }+ column "metadata" {+ type = "String"+ }+ column "embedding" {+ type = "Array(Float64)"+ }+ column "_timestamp" {+ type = "DateTime"+ }+ column "_offset" {+ type = "UInt64"+ }+ column "_partition" {+ type = "UInt64"+ }+ }++ materialized_view "precalculated_events_mv" {+ to_table = "posthog.writable_precalculated_events"+ query = <<SQL+SELECT+ team_id,+ ifNull(date, toDate(_timestamp)) AS date,+ distinct_id,+ person_id,+ condition,+ uuid,+ source,+ _timestamp,+ _offset,+ _partition+FROM posthog.kafka_precalculated_events+SQL++ column "team_id" {+ type = "Int64"+ }+ column "date" {+ type = "Nullable(Date)"+ }+ column "distinct_id" {+ type = "String"+ }+ column "person_id" {+ type = "UUID"+ }+ column "condition" {+ type = "String"+ }+ column "uuid" {+ type = "UUID"+ }+ column "source" {+ type = "String"+ }+ column "_timestamp" {+ type = "Nullable(DateTime)"+ }+ column "_offset" {+ type = "UInt64"+ }+ column "_partition" {+ type = "UInt64"+ }+ }++ materialized_view "precalculated_person_properties_mv" {+ to_table = "posthog.writable_precalculated_person_properties"+ query = <<SQL+SELECT+ team_id,+ distinct_id,+ person_id,+ condition,+ matches,+ source,+ _timestamp,+ _offset+FROM posthog.kafka_precalculated_person_properties+SQL++ column "team_id" {+ type = "Int64"+ }+ column "distinct_id" {+ type = "String"+ }+ column "person_id" {+ type = "UUID"+ }+ column "condition" {+ type = "String"+ }+ column "matches" {+ type = "Bool"+ }+ column "source" {+ type = "String"+ }+ column "_timestamp" {+ type = "Nullable(DateTime)"+ }+ column "_offset" {+ type = "UInt64"+ }+ }++ materialized_view "precalculated_person_properties_ws_mv" {+ to_table = "posthog.writable_precalculated_person_properties"+ query = <<SQL+SELECT+ team_id,+ distinct_id,+ person_id,+ condition,+ matches,+ source,+ _timestamp,+ _offset+FROM posthog.kafka_precalculated_person_properties_ws+SQL++ column "team_id" {+ type = "Int64"+ }+ column "distinct_id" {+ type = "String"+ }+ column "person_id" {+ type = "UUID"+ }+ column "condition" {+ type = "String"+ }+ column "matches" {+ type = "Bool"+ }+ column "source" {+ type = "String"+ }+ column "_timestamp" {+ type = "Nullable(DateTime)"+ }+ column "_offset" {+ type = "UInt64"+ }+ }++ materialized_view "property_values_mv" {+ to_table = "posthog.property_values"+ query = <<SQL+SELECT+ team_id,+ property_type,+ property_key,+ property_value,+ property_count,+ coalesce(_timestamp, now()) AS last_seen+FROM posthog.kafka_property_values+SQL++ column "team_id" {+ type = "Int64"+ }+ column "property_type" {+ type = "LowCardinality(String)"+ }+ column "property_key" {+ type = "String"+ }+ column "property_value" {+ type = "String"+ }+ column "property_count" {+ type = "UInt64"+ }+ column "last_seen" {+ type = "DateTime"+ }+ }++ materialized_view "raw_sessions_mv" {+ to_table = "posthog.writable_raw_sessions"+ query = <<SQL+SELECT+ team_id,+ toUInt128(toUUID(`$session_id`)) AS session_id_v7,+ argMaxState(distinct_id, timestamp) AS distinct_id,+ min(timestamp) AS min_timestamp,+ max(timestamp) AS max_timestamp,+ max(coalesce(inserted_at, now64())) AS max_inserted_at,+ groupUniqArray(nullIf(JSONExtractString(properties, '$current_url'), '')) AS urls,+ argMinState(JSONExtractString(properties, '$current_url'), timestamp) AS entry_url,+ argMaxState(JSONExtractString(properties, '$current_url'), timestamp) AS end_url,+ argMaxState(JSONExtractString(properties, '$external_click_url'), timestamp) AS last_external_click_url,+ argMinState(JSONExtractString(properties, '$browser'), timestamp) AS initial_browser,+ argMinState(JSONExtractString(properties, '$browser_version'), timestamp) AS initial_browser_version,+ argMinState(JSONExtractString(properties, '$os'), timestamp) AS initial_os,+ argMinState(JSONExtractString(properties, '$os_version'), timestamp) AS initial_os_version,+ argMinState(JSONExtractString(properties, '$device_type'), timestamp) AS initial_device_type,+ argMinState(JSONExtractInt(properties, '$viewport_width'), timestamp) AS initial_viewport_width,+ argMinState(JSONExtractInt(properties, '$viewport_height'), timestamp) AS initial_viewport_height,+ argMinState(JSONExtractString(properties, '$geoip_country_code'), timestamp) AS initial_geoip_country_code,+ argMinState(JSONExtractString(properties, '$geoip_subdivision_1_code'), timestamp) AS initial_geoip_subdivision_1_code,+ argMinState(JSONExtractString(properties, '$geoip_subdivision_1_name'), timestamp) AS initial_geoip_subdivision_1_name,+ argMinState(JSONExtractString(properties, '$geoip_subdivision_city_name'), timestamp) AS initial_geoip_subdivision_city_name,+ argMinState(JSONExtractString(properties, '$geoip_time_zone'), timestamp) AS initial_geoip_time_zone,+ argMinState(JSONExtractString(properties, '$referring_domain'), timestamp) AS initial_referring_domain,+ argMinState(JSONExtractString(properties, 'utm_source'), timestamp) AS initial_utm_source,+ argMinState(JSONExtractString(properties, 'utm_campaign'), timestamp) AS initial_utm_campaign,+ argMinState(JSONExtractString(properties, 'utm_medium'), timestamp) AS initial_utm_medium,+ argMinState(JSONExtractString(properties, 'utm_term'), timestamp) AS initial_utm_term,+ argMinState(JSONExtractString(properties, 'utm_content'), timestamp) AS initial_utm_content,+ argMinState(JSONExtractString(properties, 'gclid'), timestamp) AS initial_gclid,+ argMinState(JSONExtractString(properties, 'gad_source'), timestamp) AS initial_gad_source,+ argMinState(JSONExtractString(properties, 'gclsrc'), timestamp) AS initial_gclsrc,+ argMinState(JSONExtractString(properties, 'dclid'), timestamp) AS initial_dclid,+ argMinState(JSONExtractString(properties, 'gbraid'), timestamp) AS initial_gbraid,+ argMinState(JSONExtractString(properties, 'wbraid'), timestamp) AS initial_wbraid,+ argMinState(JSONExtractString(properties, 'fbclid'), timestamp) AS initial_fbclid,+ argMinState(JSONExtractString(properties, 'msclkid'), timestamp) AS initial_msclkid,+ argMinState(JSONExtractString(properties, 'twclid'), timestamp) AS initial_twclid,+ argMinState(JSONExtractString(properties, 'li_fat_id'), timestamp) AS initial_li_fat_id,+ argMinState(JSONExtractString(properties, 'mc_cid'), timestamp) AS initial_mc_cid,+ argMinState(JSONExtractString(properties, 'igshid'), timestamp) AS initial_igshid,+ argMinState(JSONExtractString(properties, 'ttclid'), timestamp) AS initial_ttclid,+ argMinState(JSONExtractString(properties, 'epik'), timestamp) AS initial_epik,+ argMinState(JSONExtractString(properties, 'qclid'), timestamp) AS initial_qclid,+ argMinState(JSONExtractString(properties, 'sccid'), timestamp) AS initial_sccid,+ argMinState(JSONExtractString(properties, '_kx'), timestamp) AS initial__kx,+ argMinState(JSONExtractString(properties, 'irclid'), timestamp) AS initial_irclid,+ sumIf(1, event = '$pageview') AS pageview_count,+ uniqState(CAST(if(event = '$pageview', uuid, NULL), 'Nullable(UUID)')) AS pageview_uniq,+ sumIf(1, event = '$autocapture') AS autocapture_count,+ uniqState(CAST(if(event = '$autocapture', uuid, NULL), 'Nullable(UUID)')) AS autocapture_uniq,+ sumIf(1, event = '$screen') AS screen_count,+ uniqState(CAST(if(event = '$screen', uuid, NULL), 'Nullable(UUID)')) AS screen_uniq,+ false AS maybe_has_session_replay,+ uniqUpToState(+ 1+ )(CAST(if((event = '$pageview') OR (event = '$screen') OR (event = '$autocapture'), uuid, NULL), 'Nullable(UUID)')) AS page_screen_autocapture_uniq_up_to,+ argMinState(+ accurateCastOrNull(+ replaceRegexpAll(+ nullIf(nullIf(JSONExtractRaw(properties, '$web_vitals_LCP_value'), ''), 'null'),+ '^"|"$',+ ''+ ),+ 'Float64'+ ),+ timestamp+ ) AS vitals_lcp+FROM posthog.sharded_events+WHERE+ bitAnd(bitShiftRight(toUInt128(accurateCastOrNull(`$session_id`, 'UUID')), 76), 15) = 7+GROUP BY+ team_id, toStartOfHour(fromUnixTimestamp(intDiv(toUInt64(bitShiftRight(session_id_v7, 80)), 1000))), cityHash64(session_id_v7), session_id_v7+SQL++ column "team_id" {+ type = "Int64"+ }+ column "session_id_v7" {+ type = "UInt128"+ }+ column "distinct_id" {+ type = "AggregateFunction(argMax, String, DateTime64(6, 'UTC'))"+ }+ column "min_timestamp" {+ type = "DateTime64(6, 'UTC')"+ }+ column "max_timestamp" {+ type = "DateTime64(6, 'UTC')"+ }+ column "max_inserted_at" {+ type = "DateTime64(6, 'UTC')"+ }+ column "urls" {+ type = "Array(String)"+ }+ column "entry_url" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "end_url" {+ type = "AggregateFunction(argMax, String, DateTime64(6, 'UTC'))"+ }+ column "last_external_click_url" {+ type = "AggregateFunction(argMax, String, DateTime64(6, 'UTC'))"+ }+ column "initial_browser" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_browser_version" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_os" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_os_version" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_device_type" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_viewport_width" {+ type = "AggregateFunction(argMin, Int64, DateTime64(6, 'UTC'))"+ }+ column "initial_viewport_height" {+ type = "AggregateFunction(argMin, Int64, DateTime64(6, 'UTC'))"+ }+ column "initial_geoip_country_code" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_geoip_subdivision_1_code" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_geoip_subdivision_1_name" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_geoip_subdivision_city_name" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_geoip_time_zone" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_referring_domain" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_utm_source" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_utm_campaign" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_utm_medium" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_utm_term" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_utm_content" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_gclid" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_gad_source" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_gclsrc" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_dclid" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_gbraid" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_wbraid" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_fbclid" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_msclkid" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_twclid" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_li_fat_id" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_mc_cid" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_igshid" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_ttclid" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_epik" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_qclid" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_sccid" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial__kx" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_irclid" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "pageview_count" {+ type = "UInt64"+ }+ column "pageview_uniq" {+ type = "AggregateFunction(uniq, Nullable(UUID))"+ }+ column "autocapture_count" {+ type = "UInt64"+ }+ column "autocapture_uniq" {+ type = "AggregateFunction(uniq, Nullable(UUID))"+ }+ column "screen_count" {+ type = "UInt64"+ }+ column "screen_uniq" {+ type = "AggregateFunction(uniq, Nullable(UUID))"+ }+ column "maybe_has_session_replay" {+ type = "Bool"+ }+ column "page_screen_autocapture_uniq_up_to" {+ type = "AggregateFunction(uniqUpTo(1), Nullable(UUID))"+ }+ column "vitals_lcp" {+ type = "AggregateFunction(argMin, Nullable(Float64), DateTime64(6, 'UTC'))"+ }+ }++ materialized_view "session_replay_events_mv" {+ to_table = "posthog.writable_session_replay_events"+ query = <<SQL+SELECT+ session_id,+ team_id,+ any(distinct_id) AS distinct_id,+ min(first_timestamp) AS min_first_timestamp,+ max(last_timestamp) AS max_last_timestamp,+ groupArray(if(block_url != '', first_timestamp, NULL)) AS block_first_timestamps,+ groupArray(if(block_url != '', last_timestamp, NULL)) AS block_last_timestamps,+ groupArray(block_url) AS block_urls,+ argMinState(first_url, first_timestamp) AS first_url,+ groupUniqArrayArray(urls) AS all_urls,+ sum(click_count) AS click_count,+ sum(keypress_count) AS keypress_count,+ sum(mouse_activity_count) AS mouse_activity_count,+ sum(active_milliseconds) AS active_milliseconds,+ sum(console_log_count) AS console_log_count,+ sum(console_warn_count) AS console_warn_count,+ sum(console_error_count) AS console_error_count,+ sum(size) AS size,+ sum(message_count) AS message_count,+ sum(event_count) AS event_count,+ argMinState(snapshot_source, first_timestamp) AS snapshot_source,+ argMinState(snapshot_library, first_timestamp) AS snapshot_library,+ max(_timestamp) AS _timestamp,+ max(retention_period_days) AS retention_period_days,+ max(is_deleted) AS is_deleted,+ groupUniqArrayArray(ai_tags_fixed) AS ai_tags_fixed,+ groupUniqArrayArray(ai_tags_freeform) AS ai_tags_freeform,+ max(ai_highlighted) AS ai_highlighted,+ max(surfacing_score) AS surfacing_score+FROM posthog.kafka_session_replay_events+GROUP BY+ session_id, team_id+SQL++ column "session_id" {+ type = "String"+ }+ column "team_id" {+ type = "Int64"+ }+ column "distinct_id" {+ type = "String"+ }+ column "min_first_timestamp" {+ type = "DateTime64(6, 'UTC')"+ }+ column "max_last_timestamp" {+ type = "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 = "Int64"+ }+ column "keypress_count" {+ type = "Int64"+ }+ column "mouse_activity_count" {+ type = "Int64"+ }+ column "active_milliseconds" {+ type = "Int64"+ }+ column "console_log_count" {+ type = "Int64"+ }+ column "console_warn_count" {+ type = "Int64"+ }+ column "console_error_count" {+ type = "Int64"+ }+ column "size" {+ type = "Int64"+ }+ column "message_count" {+ type = "Int64"+ }+ column "event_count" {+ type = "Int64"+ }+ column "snapshot_source" {+ type = "AggregateFunction(argMin, LowCardinality(Nullable(String)), DateTime64(6, 'UTC'))"+ }+ column "snapshot_library" {+ type = "AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC'))"+ }+ column "_timestamp" {+ type = "Nullable(DateTime)"+ }+ column "retention_period_days" {+ type = "SimpleAggregateFunction(max, Nullable(Int64))"+ }+ column "is_deleted" {+ type = "SimpleAggregateFunction(max, UInt8)"+ }+ column "ai_tags_fixed" {+ type = "SimpleAggregateFunction(groupUniqArrayArray, Array(String))"+ }+ column "ai_tags_freeform" {+ type = "SimpleAggregateFunction(groupUniqArrayArray, Array(String))"+ }+ column "ai_highlighted" {+ type = "SimpleAggregateFunction(max, UInt8)"+ }+ column "surfacing_score" {+ type = "SimpleAggregateFunction(max, Nullable(Float32))"+ }+ }++ materialized_view "session_replay_features_mv" {+ to_table = "posthog.writable_session_replay_features"+ query = <<SQL+SELECT+ session_id,+ team_id,+ any(distinct_id) AS distinct_id,+ min(first_timestamp) AS min_first_timestamp,+ max(last_timestamp) AS max_last_timestamp,+ sum(event_count) AS event_count,+ sum(mouse_position_count) AS mouse_position_count,+ sum(mouse_sum_x) AS mouse_sum_x,+ sum(mouse_sum_x_squared) AS mouse_sum_x_squared,+ sum(mouse_sum_y) AS mouse_sum_y,+ sum(mouse_sum_y_squared) AS mouse_sum_y_squared,+ sum(mouse_distance_traveled) AS mouse_distance_traveled,+ sum(mouse_direction_change_count) AS mouse_direction_change_count,+ sum(mouse_velocity_sum) AS mouse_velocity_sum,+ sum(mouse_velocity_sum_of_squares) AS mouse_velocity_sum_of_squares,+ sum(mouse_velocity_count) AS mouse_velocity_count,+ sum(scroll_event_count) AS scroll_event_count,+ sum(total_scroll_magnitude) AS total_scroll_magnitude,+ sum(scroll_direction_reversal_count) AS scroll_direction_reversal_count,+ sum(rapid_scroll_reversal_count) AS rapid_scroll_reversal_count,+ sum(scroll_to_top_count) AS scroll_to_top_count,+ sum(click_count) AS click_count,+ sum(keypress_count) AS keypress_count,+ sum(mouse_activity_count) AS mouse_activity_count,+ sum(rage_click_count) AS rage_click_count,+ sum(dead_click_count) AS dead_click_count,+ sum(backspace_count) AS backspace_count,+ sum(inter_action_gap_count) AS inter_action_gap_count,+ sum(inter_action_gap_sum_ms) AS inter_action_gap_sum_ms,+ sum(inter_action_gap_sum_of_squares_ms) AS inter_action_gap_sum_of_squares_ms,+ max(max_idle_gap_ms) AS max_idle_gap_ms,+ sum(long_idle_gap_count) AS long_idle_gap_count,+ sum(quick_back_count) AS quick_back_count,+ sum(page_visit_count) AS page_visit_count,+ uniqCombinedArrayState(12)(visited_urls) AS unique_url_count,+ sum(login_path_visit_count) AS login_path_visit_count,+ sum(signup_path_visit_count) AS signup_path_visit_count,+ sum(checkout_path_visit_count) AS checkout_path_visit_count,+ sum(cart_path_visit_count) AS cart_path_visit_count,+ sum(billing_path_visit_count) AS billing_path_visit_count,+ sum(settings_path_visit_count) AS settings_path_visit_count,+ sum(account_path_visit_count) AS account_path_visit_count,+ sum(error_path_visit_count) AS error_path_visit_count,+ sum(not_found_path_visit_count) AS not_found_path_visit_count,+ sum(admin_path_visit_count) AS admin_path_visit_count,+ sum(dashboard_path_visit_count) AS dashboard_path_visit_count,+ sum(onboarding_path_visit_count) AS onboarding_path_visit_count,+ sum(cancel_path_visit_count) AS cancel_path_visit_count,+ sum(refund_path_visit_count) AS refund_path_visit_count,+ sum(console_error_count) AS console_error_count,+ sum(console_error_after_click_count) AS console_error_after_click_count,+ sum(console_warn_count) AS console_warn_count,+ sum(network_request_count) AS network_request_count,+ sum(network_failed_request_count) AS network_failed_request_count,+ sum(network_4xx_count) AS network_4xx_count,+ sum(network_5xx_count) AS network_5xx_count,+ sum(network_request_duration_sum) AS network_request_duration_sum,+ sum(network_request_duration_sum_of_squares) AS network_request_duration_sum_of_squares,+ sum(network_request_duration_count) AS network_request_duration_count,+ sum(mutation_count) AS mutation_count,+ sum(viewport_resize_count) AS viewport_resize_count,+ sum(touch_event_count) AS touch_event_count,+ max(max_scroll_y) AS max_scroll_y,+ uniqCombinedArrayState(12)(click_target_ids) AS unique_click_target_count,+ uniqCombinedArrayState(12)(form_field_ids) AS unique_form_field_count,+ sum(text_selection_count) AS text_selection_count,+ sum(selection_copy_count) AS selection_copy_count,+ max(is_deleted) AS is_deleted+FROM posthog.kafka_session_replay_features+GROUP BY+ session_id, team_id+SQL++ column "session_id" {+ type = "String"+ }+ column "team_id" {+ type = "Int64"+ }+ column "distinct_id" {+ type = "String"+ }+ column "min_first_timestamp" {+ type = "DateTime64(6, 'UTC')"+ }+ column "max_last_timestamp" {+ type = "DateTime64(6, 'UTC')"+ }+ column "event_count" {+ type = "Int64"+ }+ column "mouse_position_count" {+ type = "Int64"+ }+ column "mouse_sum_x" {+ type = "Float64"+ }+ column "mouse_sum_x_squared" {+ type = "Float64"+ }+ column "mouse_sum_y" {+ type = "Float64"+ }+ column "mouse_sum_y_squared" {+ type = "Float64"+ }+ column "mouse_distance_traveled" {+ type = "Float64"+ }+ column "mouse_direction_change_count" {+ type = "Int64"+ }+ column "mouse_velocity_sum" {+ type = "Float64"+ }+ column "mouse_velocity_sum_of_squares" {+ type = "Float64"+ }+ column "mouse_velocity_count" {+ type = "Int64"+ }+ column "scroll_event_count" {+ type = "Int64"+ }+ column "total_scroll_magnitude" {+ type = "Float64"+ }+ column "scroll_direction_reversal_count" {+ type = "Int64"+ }+ column "rapid_scroll_reversal_count" {+ type = "Int64"+ }+ column "scroll_to_top_count" {+ type = "Int64"+ }+ column "click_count" {+ type = "Int64"+ }+ column "keypress_count" {+ type = "Int64"+ }+ column "mouse_activity_count" {+ type = "Int64"+ }+ column "rage_click_count" {+ type = "Int64"+ }+ column "dead_click_count" {+ type = "Int64"+ }+ column "backspace_count" {+ type = "Int64"+ }+ column "inter_action_gap_count" {+ type = "Int64"+ }+ column "inter_action_gap_sum_ms" {+ type = "Float64"+ }+ column "inter_action_gap_sum_of_squares_ms" {+ type = "Float64"+ }+ column "max_idle_gap_ms" {+ type = "Float64"+ }+ column "long_idle_gap_count" {+ type = "Int64"+ }+ column "quick_back_count" {+ type = "Int64"+ }+ column "page_visit_count" {+ type = "Int64"+ }+ column "unique_url_count" {+ type = "AggregateFunction(uniqCombinedArray(12), Array(String))"+ }+ column "login_path_visit_count" {+ type = "Int64"+ }+ column "signup_path_visit_count" {+ type = "Int64"+ }+ column "checkout_path_visit_count" {+ type = "Int64"+ }+ column "cart_path_visit_count" {+ type = "Int64"+ }+ column "billing_path_visit_count" {+ type = "Int64"+ }+ column "settings_path_visit_count" {+ type = "Int64"+ }+ column "account_path_visit_count" {+ type = "Int64"+ }+ column "error_path_visit_count" {+ type = "Int64"+ }+ column "not_found_path_visit_count" {+ type = "Int64"+ }+ column "admin_path_visit_count" {+ type = "Int64"+ }+ column "dashboard_path_visit_count" {+ type = "Int64"+ }+ column "onboarding_path_visit_count" {+ type = "Int64"+ }+ column "cancel_path_visit_count" {+ type = "Int64"+ }+ column "refund_path_visit_count" {+ type = "Int64"+ }+ column "console_error_count" {+ type = "Int64"+ }+ column "console_error_after_click_count" {+ type = "Int64"+ }+ column "console_warn_count" {+ type = "Int64"+ }+ column "network_request_count" {+ type = "Int64"+ }+ column "network_failed_request_count" {+ type = "Int64"+ }+ column "network_4xx_count" {+ type = "Int64"+ }+ column "network_5xx_count" {+ type = "Int64"+ }+ column "network_request_duration_sum" {+ type = "Float64"+ }+ column "network_request_duration_sum_of_squares" {+ type = "Float64"+ }+ column "network_request_duration_count" {+ type = "Int64"+ }+ column "mutation_count" {+ type = "Int64"+ }+ column "viewport_resize_count" {+ type = "Int64"+ }+ column "touch_event_count" {+ type = "Int64"+ }+ column "max_scroll_y" {+ type = "Float64"+ }+ column "unique_click_target_count" {+ type = "AggregateFunction(uniqCombinedArray(12), Array(Int64))"+ }+ column "unique_form_field_count" {+ type = "AggregateFunction(uniqCombinedArray(12), Array(Int64))"+ }+ column "text_selection_count" {+ type = "Int64"+ }+ column "selection_copy_count" {+ type = "Int64"+ }+ column "is_deleted" {+ type = "UInt8"+ }+ }++ materialized_view "sessions_mv" {+ to_table = "posthog.writable_sessions"+ query = <<SQL+SELECT+ `$session_id` AS session_id,+ team_id,+ any(distinct_id) AS distinct_id,+ min(timestamp) AS min_timestamp,+ max(timestamp) AS max_timestamp,+ groupUniqArray(replaceRegexpAll(JSONExtractRaw(properties, '$current_url'), '^"|"$', '')) AS urls,+ argMinState(replaceRegexpAll(JSONExtractRaw(properties, '$current_url'), '^"|"$', ''), timestamp) AS entry_url,+ argMaxState(replaceRegexpAll(JSONExtractRaw(properties, '$current_url'), '^"|"$', ''), timestamp) AS exit_url,+ argMinState(+ replaceRegexpAll(JSONExtractRaw(properties, '$referring_domain'), '^"|"$', ''),+ timestamp+ ) AS initial_referring_domain,+ argMinState(replaceRegexpAll(JSONExtractRaw(properties, 'utm_source'), '^"|"$', ''), timestamp) AS initial_utm_source,+ argMinState(replaceRegexpAll(JSONExtractRaw(properties, 'utm_campaign'), '^"|"$', ''), timestamp) AS initial_utm_campaign,+ argMinState(replaceRegexpAll(JSONExtractRaw(properties, 'utm_medium'), '^"|"$', ''), timestamp) AS initial_utm_medium,+ argMinState(replaceRegexpAll(JSONExtractRaw(properties, 'utm_term'), '^"|"$', ''), timestamp) AS initial_utm_term,+ argMinState(replaceRegexpAll(JSONExtractRaw(properties, 'utm_content'), '^"|"$', ''), timestamp) AS initial_utm_content,+ argMinState(replaceRegexpAll(JSONExtractRaw(properties, 'gclid'), '^"|"$', ''), timestamp) AS initial_gclid,+ argMinState(replaceRegexpAll(JSONExtractRaw(properties, 'gad_source'), '^"|"$', ''), timestamp) AS initial_gad_source,+ argMinState(replaceRegexpAll(JSONExtractRaw(properties, 'gclsrc'), '^"|"$', ''), timestamp) AS initial_gclsrc,+ argMinState(replaceRegexpAll(JSONExtractRaw(properties, 'dclid'), '^"|"$', ''), timestamp) AS initial_dclid,+ argMinState(replaceRegexpAll(JSONExtractRaw(properties, 'gbraid'), '^"|"$', ''), timestamp) AS initial_gbraid,+ argMinState(replaceRegexpAll(JSONExtractRaw(properties, 'wbraid'), '^"|"$', ''), timestamp) AS initial_wbraid,+ argMinState(replaceRegexpAll(JSONExtractRaw(properties, 'fbclid'), '^"|"$', ''), timestamp) AS initial_fbclid,+ argMinState(replaceRegexpAll(JSONExtractRaw(properties, 'msclkid'), '^"|"$', ''), timestamp) AS initial_msclkid,+ argMinState(replaceRegexpAll(JSONExtractRaw(properties, 'twclid'), '^"|"$', ''), timestamp) AS initial_twclid,+ argMinState(replaceRegexpAll(JSONExtractRaw(properties, 'li_fat_id'), '^"|"$', ''), timestamp) AS initial_li_fat_id,+ argMinState(replaceRegexpAll(JSONExtractRaw(properties, 'mc_cid'), '^"|"$', ''), timestamp) AS initial_mc_cid,+ argMinState(replaceRegexpAll(JSONExtractRaw(properties, 'igshid'), '^"|"$', ''), timestamp) AS initial_igshid,+ argMinState(replaceRegexpAll(JSONExtractRaw(properties, 'ttclid'), '^"|"$', ''), timestamp) AS initial_ttclid,+ argMinState(replaceRegexpAll(JSONExtractRaw(properties, 'epik'), '^"|"$', ''), timestamp) AS initial_epik,+ argMinState(replaceRegexpAll(JSONExtractRaw(properties, 'qclid'), '^"|"$', ''), timestamp) AS initial_qclid,+ argMinState(replaceRegexpAll(JSONExtractRaw(properties, 'sccid'), '^"|"$', ''), timestamp) AS initial_sccid,+ sumMap(CAST(([event], [1]), 'Map(String, UInt64)')) AS event_count_map,+ sumIf(1, event = '$pageview') AS pageview_count,+ sumIf(1, event = '$autocapture') AS autocapture_count+FROM posthog.sharded_events+WHERE+ (`$session_id` IS NOT NULL)+AND+ (`$session_id` != '')+AND+ (team_id IN (1, 2, 13610, 19279, 21173, 29929, 32050, 9910, 11775, 21129, 31490))+GROUP BY+ `$session_id`, team_id+SQL++ column "session_id" {+ type = "String"+ }+ column "team_id" {+ type = "Int64"+ }+ column "distinct_id" {+ type = "String"+ }+ column "min_timestamp" {+ type = "DateTime64(6, 'UTC')"+ }+ column "max_timestamp" {+ type = "DateTime64(6, 'UTC')"+ }+ column "urls" {+ type = "Array(String)"+ }+ column "entry_url" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "exit_url" {+ type = "AggregateFunction(argMax, String, DateTime64(6, 'UTC'))"+ }+ column "initial_referring_domain" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_utm_source" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_utm_campaign" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_utm_medium" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_utm_term" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_utm_content" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_gclid" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_gad_source" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_gclsrc" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_dclid" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_gbraid" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_wbraid" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_fbclid" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_msclkid" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_twclid" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_li_fat_id" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_mc_cid" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_igshid" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_ttclid" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_epik" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_qclid" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_sccid" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "event_count_map" {+ type = "Map(String, UInt64)"+ }+ column "pageview_count" {+ type = "UInt64"+ }+ column "autocapture_count" {+ type = "UInt64"+ }+ }++ materialized_view "tophog_mv" {+ to_table = "posthog.writable_tophog"+ query = <<SQL+SELECT+ timestamp,+ metric,+ type,+ key,+ value,+ count,+ pipeline,+ lane,+ labels+FROM posthog.kafka_tophog+SQL++ column "timestamp" {+ type = "DateTime64(6, 'UTC')"+ }+ column "metric" {+ type = "LowCardinality(String)"+ }+ column "type" {+ type = "LowCardinality(String)"+ }+ column "key" {+ type = "Map(LowCardinality(String), String)"+ }+ column "value" {+ type = "Float64"+ }+ column "count" {+ type = "UInt64"+ }+ column "pipeline" {+ type = "LowCardinality(String)"+ }+ column "lane" {+ type = "LowCardinality(String)"+ }+ column "labels" {+ type = "Map(LowCardinality(String), String)"+ }+ }++ materialized_view "tophog_ws_mv" {+ to_table = "posthog.writable_tophog"+ query = <<SQL+SELECT+ timestamp,+ metric,+ type,+ key,+ value,+ count,+ pipeline,+ lane,+ labels+FROM posthog.kafka_tophog_ws+SQL++ column "timestamp" {+ type = "DateTime64(6, 'UTC')"+ }+ column "metric" {+ type = "LowCardinality(String)"+ }+ column "type" {+ type = "LowCardinality(String)"+ }+ column "key" {+ type = "Map(LowCardinality(String), String)"+ }+ column "value" {+ type = "Float64"+ }+ column "count" {+ type = "UInt64"+ }+ column "pipeline" {+ type = "LowCardinality(String)"+ }+ column "lane" {+ type = "LowCardinality(String)"+ }+ column "labels" {+ type = "Map(LowCardinality(String), String)"+ }+ }++ materialized_view "trace_span_to_attributes" {+ to_table = "posthog.trace_attributes"+ query = <<SQL+SELECT+ team_id,+ original_expiry_time_bucket,+ time_bucket,+ service_name,+ resource_fingerprint,+ attribute_key,+ attribute_value,+ 'span_attribute' AS attribute_type,+ attribute_count+FROM+ (+ SELECT+ team_id AS team_id,+ toStartOfInterval(original_expiry_timestamp, toIntervalMinute(10)) AS original_expiry_time_bucket,+ toStartOfInterval(timestamp, toIntervalMinute(10)) AS time_bucket,+ service_name AS service_name,+ resource_fingerprint,+ arrayJoin(mapFilter((k, v) -> ((length(k) < 256) AND (length(v) < 256)), attributes)) AS attribute,+ attribute.1 AS attribute_key,+ attribute.2 AS attribute_value,+ sumSimpleState(1) AS attribute_count+ FROM posthog.trace_spans+ GROUP BY+ team_id, original_expiry_time_bucket, time_bucket, service_name, resource_fingerprint, attribute+ )+SQL++ column "team_id" {+ type = "Int32"+ }+ column "original_expiry_time_bucket" {+ type = "DateTime64(0)"+ }+ column "time_bucket" {+ type = "DateTime64(0)"+ }+ column "service_name" {+ type = "LowCardinality(String)"+ }+ column "resource_fingerprint" {+ type = "UInt64"+ }+ column "attribute_key" {+ type = "LowCardinality(String)"+ }+ column "attribute_value" {+ type = "String"+ }+ column "attribute_type" {+ type = "LowCardinality(String)"+ }+ column "attribute_count" {+ type = "SimpleAggregateFunction(sum, UInt64)"+ }+ }++ materialized_view "trace_span_to_attributes2" {+ to_table = "posthog.trace_attributes2"+ query = <<SQL+SELECT+ team_id,+ original_expiry_time_bucket,+ time_bucket,+ service_name,+ resource_fingerprint,+ attribute_key,+ attribute_value,+ 'span_attribute' AS attribute_type,+ attribute_count+FROM+ (+ SELECT+ team_id AS team_id,+ toStartOfInterval(original_expiry_timestamp, toIntervalMinute(10)) AS original_expiry_time_bucket,+ toStartOfInterval(timestamp, toIntervalMinute(10)) AS time_bucket,+ service_name AS service_name,+ resource_fingerprint,+ arrayJoin(mapFilter((k, v) -> ((length(k) < 256) AND (length(v) < 256)), attributes)) AS attribute,+ attribute.1 AS attribute_key,+ attribute.2 AS attribute_value,+ sumSimpleState(1) AS attribute_count+ FROM posthog.trace_spans+ GROUP BY+ team_id, original_expiry_time_bucket, time_bucket, service_name, resource_fingerprint, attribute+ )+SQL++ column "team_id" {+ type = "Int32"+ }+ column "original_expiry_time_bucket" {+ type = "DateTime64(0)"+ }+ column "time_bucket" {+ type = "DateTime64(0)"+ }+ column "service_name" {+ type = "LowCardinality(String)"+ }+ column "resource_fingerprint" {+ type = "UInt64"+ }+ column "attribute_key" {+ type = "LowCardinality(String)"+ }+ column "attribute_value" {+ type = "String"+ }+ column "attribute_type" {+ type = "LowCardinality(String)"+ }+ column "attribute_count" {+ type = "SimpleAggregateFunction(sum, UInt64)"+ }+ }++ materialized_view "trace_span_to_resource_attributes" {+ to_table = "posthog.trace_attributes"+ query = <<SQL+SELECT+ team_id,+ original_expiry_time_bucket,+ time_bucket,+ service_name,+ resource_fingerprint,+ attribute_key,+ attribute_value,+ 'span_resource_attribute' AS attribute_type,+ attribute_count+FROM+ (+ SELECT+ team_id AS team_id,+ toStartOfInterval(original_expiry_timestamp, toIntervalMinute(10)) AS original_expiry_time_bucket,+ toStartOfInterval(timestamp, toIntervalMinute(10)) AS time_bucket,+ service_name AS service_name,+ resource_fingerprint,+ arrayJoin(resource_attributes) AS attribute,+ attribute.1 AS attribute_key,+ attribute.2 AS attribute_value,+ sumSimpleState(1) AS attribute_count+ FROM posthog.trace_spans+ GROUP BY+ team_id, original_expiry_time_bucket, time_bucket, service_name, resource_fingerprint, attribute+ )+SQL++ column "team_id" {+ type = "Int32"+ }+ column "original_expiry_time_bucket" {+ type = "DateTime64(0)"+ }+ column "time_bucket" {+ type = "DateTime64(0)"+ }+ column "service_name" {+ type = "LowCardinality(String)"+ }+ column "resource_fingerprint" {+ type = "UInt64"+ }+ column "attribute_key" {+ type = "LowCardinality(String)"+ }+ column "attribute_value" {+ type = "String"+ }+ column "attribute_type" {+ type = "LowCardinality(String)"+ }+ column "attribute_count" {+ type = "SimpleAggregateFunction(sum, UInt64)"+ }+ }++ materialized_view "trace_span_to_resource_attributes2" {+ to_table = "posthog.trace_attributes2"+ query = <<SQL+SELECT+ team_id,+ original_expiry_time_bucket,+ time_bucket,+ service_name,+ resource_fingerprint,+ attribute_key,+ attribute_value,+ 'span_resource_attribute' AS attribute_type,+ attribute_count+FROM+ (+ SELECT+ team_id AS team_id,+ toStartOfInterval(original_expiry_timestamp, toIntervalMinute(10)) AS original_expiry_time_bucket,+ toStartOfInterval(timestamp, toIntervalMinute(10)) AS time_bucket,+ service_name AS service_name,+ resource_fingerprint,+ arrayJoin(resource_attributes) AS attribute,+ attribute.1 AS attribute_key,+ attribute.2 AS attribute_value,+ sumSimpleState(1) AS attribute_count+ FROM posthog.trace_spans+ GROUP BY+ team_id, original_expiry_time_bucket, time_bucket, service_name, resource_fingerprint, attribute+ )+SQL++ column "team_id" {+ type = "Int32"+ }+ column "original_expiry_time_bucket" {+ type = "DateTime64(0)"+ }+ column "time_bucket" {+ type = "DateTime64(0)"+ }+ column "service_name" {+ type = "LowCardinality(String)"+ }+ column "resource_fingerprint" {+ type = "UInt64"+ }+ column "attribute_key" {+ type = "LowCardinality(String)"+ }+ column "attribute_value" {+ type = "String"+ }+ column "attribute_type" {+ type = "LowCardinality(String)"+ }+ column "attribute_count" {+ type = "SimpleAggregateFunction(sum, UInt64)"+ }+ }++ materialized_view "trace_span_to_span_attributes" {+ to_table = "posthog.trace_attributes"+ query = <<SQL+SELECT+ team_id,+ original_expiry_time_bucket,+ time_bucket,+ service_name,+ resource_fingerprint,+ attribute_key,+ attribute_value,+ 'span' AS attribute_type,+ attribute_count+FROM+ (+ SELECT+ team_id AS team_id,+ toStartOfInterval(original_expiry_timestamp, toIntervalMinute(10)) AS original_expiry_time_bucket,+ toStartOfInterval(timestamp, toIntervalMinute(10)) AS time_bucket,+ service_name AS service_name,+ resource_fingerprint,+ 'name' AS attribute_key,+ name AS attribute_value,+ sumSimpleState(1) AS attribute_count+ FROM posthog.trace_spans+ GROUP BY+ team_id, original_expiry_time_bucket, time_bucket, service_name, resource_fingerprint, name+ )+SQL++ column "team_id" {+ type = "Int32"+ }+ column "original_expiry_time_bucket" {+ type = "DateTime64(0)"+ }+ column "time_bucket" {+ type = "DateTime64(0)"+ }+ column "service_name" {+ type = "LowCardinality(String)"+ }+ column "resource_fingerprint" {+ type = "UInt64"+ }+ column "attribute_key" {+ type = "LowCardinality(String)"+ }+ column "attribute_value" {+ type = "String"+ }+ column "attribute_type" {+ type = "LowCardinality(String)"+ }+ column "attribute_count" {+ type = "SimpleAggregateFunction(sum, UInt64)"+ }+ }++ materialized_view "trace_span_to_span_attributes2" {+ to_table = "posthog.trace_attributes2"+ query = <<SQL+SELECT+ team_id,+ original_expiry_time_bucket,+ time_bucket,+ service_name,+ resource_fingerprint,+ attribute_key,+ attribute_value,+ 'span' AS attribute_type,+ attribute_count+FROM+ (+ SELECT+ team_id AS team_id,+ toStartOfInterval(original_expiry_timestamp, toIntervalMinute(10)) AS original_expiry_time_bucket,+ toStartOfInterval(timestamp, toIntervalMinute(10)) AS time_bucket,+ service_name AS service_name,+ resource_fingerprint,+ 'name' AS attribute_key,+ name AS attribute_value,+ sumSimpleState(1) AS attribute_count+ FROM posthog.trace_spans+ GROUP BY+ team_id, original_expiry_time_bucket, time_bucket, service_name, resource_fingerprint, name+ )+SQL++ column "team_id" {+ type = "Int32"+ }+ column "original_expiry_time_bucket" {+ type = "DateTime64(0)"+ }+ column "time_bucket" {+ type = "DateTime64(0)"+ }+ column "service_name" {+ type = "LowCardinality(String)"+ }+ column "resource_fingerprint" {+ type = "UInt64"+ }+ column "attribute_key" {+ type = "LowCardinality(String)"+ }+ column "attribute_value" {+ type = "String"+ }+ column "attribute_type" {+ type = "LowCardinality(String)"+ }+ column "attribute_count" {+ type = "SimpleAggregateFunction(sum, UInt64)"+ }+ }++ materialized_view "trace_spans_to_kafka_metrics_mv" {+ to_table = "posthog.trace_spans_kafka_metrics"+ query = <<SQL+SELECT+ _partition,+ _topic,+ maxSimpleState(_offset) AS max_offset,+ maxSimpleState(observed_timestamp) AS max_observed_timestamp,+ maxSimpleState(timestamp) AS max_timestamp,+ maxSimpleState(now()) AS max_created_at,+ maxSimpleState(now() - observed_timestamp) AS max_lag+FROM posthog.trace_spans+GROUP BY+ _partition, _topic+SQL++ column "_partition" {+ type = "UInt64"+ }+ column "_topic" {+ type = "LowCardinality(String)"+ }+ column "max_offset" {+ type = "SimpleAggregateFunction(max, UInt64)"+ }+ column "max_observed_timestamp" {+ type = "SimpleAggregateFunction(max, DateTime64(6))"+ }+ column "max_timestamp" {+ type = "SimpleAggregateFunction(max, DateTime64(6))"+ }+ column "max_created_at" {+ type = "SimpleAggregateFunction(max, DateTime)"+ }+ column "max_lag" {+ type = "SimpleAggregateFunction(max, Decimal(18, 6))"+ }+ }++ materialized_view "usage_report_events_preagg_mv" {+ to_table = "posthog.writable_usage_report_events_preagg"+ query = <<SQL+SELECT+ toDate(timestamp) AS date,+ team_id,+ person_mode,+ JSONExtractString(properties, '$lib') AS lib,+ event,+ uniqExactState((cityHash64(distinct_id), cityHash64(toString(uuid)), cityHash64(event))) AS distinct_events_unique,+ sumState(toUInt64(1)) AS event_count+FROM posthog.kafka_usage_report_events_preagg+GROUP BY+ date, team_id, person_mode, lib, event+SQL++ column "date" {+ type = "Date"+ }+ column "team_id" {+ type = "Int64"+ }+ column "person_mode" {+ type = "Enum8('full'=0, 'propertyless'=1, 'force_upgrade'=2)"+ }+ column "lib" {+ type = "String"+ }+ column "event" {+ type = "String"+ }+ column "distinct_events_unique" {+ type = "AggregateFunction(uniqExact, Tuple(UInt64, UInt64, UInt64))"+ }+ column "event_count" {+ type = "AggregateFunction(sum, UInt64)"+ }+ }++ view "custom_metrics" {+ query = <<SQL+SELECT * REPLACE(toFloat64(value) AS value)+FROM posthog.custom_metrics_test+UNION ALL+SELECT * REPLACE(toFloat64(value) AS value)+FROM posthog.custom_metrics_replication_queue+UNION ALL+SELECT * REPLACE(toFloat64(value) AS value)+FROM posthog.custom_metrics_server_crash+UNION ALL+SELECT *+FROM posthog.custom_metrics_table_sizes+UNION ALL+SELECT * REPLACE(toFloat64(value) AS value)+FROM posthog.custom_metrics_part_counts+UNION ALL+SELECT * REPLACE(toFloat64(value) AS value)+FROM posthog.custom_metrics_dictionaries+UNION ALL+SELECT+ 'ClickHouseCustomMetric_S3DiskBytesUsed' AS name,+ map('instance', hostname(), 'disk', disk_name) AS labels,+ toFloat64(sum(bytes_on_disk)) AS value,+ 'Bytes currently used by ClickHouse parts on S3-backed disks on this node' AS help,+ 'gauge' AS type+FROM system.parts+WHERE disk_name IN ('s3disk', 'cache')+GROUP BY+ disk_name+UNION ALL+SELECT+ 'ClickHouseCustomMetric_MergeFailures15m' AS name,+ map('instance', hostname()) AS labels,+ toFloat64(count()) AS value,+ 'Number of failed merge operations in the last 15 minutes' AS help,+ 'gauge' AS type+FROM system.part_log+WHERE+ (event_time >= (now() - toIntervalMinute(15)))+AND+ (event_type = 'MergeParts')+AND+ (error > 0)+AND+ (merge_reason != 'NotAMerge')+AND+ (error != 40)+UNION ALL+SELECT+ 'ClickHouseCustomMetric_MergeRetriesMaxPerTable15m' AS name,+ map('instance', hostname()) AS labels,+ toFloat64(max(cnt)) AS value,+ 'Max failed merge retries for any single table in the last 15 minutes' AS help,+ 'gauge' AS type+FROM+ (+ SELECT count() AS cnt+ FROM system.part_log+ WHERE+ (event_time >= (now() - toIntervalMinute(15)))+ AND+ (event_type = 'MergeParts')+ AND+ (error > 0)+ AND+ (merge_reason != 'NotAMerge')+ AND+ (error != 40)+ GROUP BY+ database, `table`, partition_id+ )+SQL++ }++ view "custom_metrics_backups" {+ query = <<SQL+WITH+ ['ClickHouseCustomMetric_BackupFailed', 'ClickHouseCustomMetric_BackupSuccess', 'ClickHouseCustomMetric_BackupCancelled', 'ClickHouseCustomMetric_BackupAttempts'] AS names,+ [toInt64(countIf(status = 'BACKUP_FAILED')), toInt64(countIf(status = 'BACKUP_CREATED')), toInt64(countIf(status = 'BACKUP_CANCELLED')), toInt64(countIf(status = 'CREATING_BACKUP'))] AS values,+ ['Number of failed backups', 'Number of successful backups', 'Number of cancelled backups', 'Number of backup attempts'] AS descriptions,+ ['gauge', 'gauge', 'gauge', 'gauge'] AS types,+ arrayJoin(arrayZip(names, values, descriptions, types)) AS tpl+SELECT+ tpl.1 AS name,+ map('instance', hostname()) AS labels,+ tpl.2 AS value,+ tpl.3 AS help,+ tpl.4 AS type+FROM system.backup_log+WHERE event_date = today()+GROUP BY+ event_date+SQL++ }++ view "custom_metrics_dictionaries" {+ query = <<SQL+SELECT+ 'ClickHouseCustomMetric_DictionariesFailed' AS name,+ map(+ 'instance',+ hostname(),+ 'database',+ d.database,+ 'dictionary',+ d.dict_name,+ 'uuid',+ toString(d.uuid),+ 'status',+ toString(d.status)+ ) AS labels,+ toUInt64(1) AS value,+ 'Dictionary is in FAILED or FAILED_AND_RELOADING status' AS help,+ 'gauge' AS type+FROM+ (+ SELECT name AS dict_name, database, uuid, status+ FROM system.dictionaries+ WHERE status IN ('FAILED', 'FAILED_AND_RELOADING')+ ) AS d+SQL++ }++ view "custom_metrics_part_counts" {+ query = <<SQL+SELECT+ 'ClickHouseCustomMetric_MaxPartCountPerPartition' AS name,+ map('instance', hostname(), 'database', database, 'table', `table`, 'partition', partition) AS labels,+ part_count AS value,+ 'Maximum number of active parts for any partition in a PostHog table' AS help,+ 'gauge' AS type+FROM+ (+ SELECT database, `table`, partition, count() AS part_count+ FROM system.parts+ WHERE+ active+ AND+ (database = 'posthog')+ GROUP BY+ database, `table`, partition+ ORDER BY database ASC, `table` ASC, part_count DESC, partition ASC+ LIMIT 1 BY database, `table`+ )+SQL++ }++ view "custom_metrics_replication_queue" {+ query = <<SQL+WITH+ ['ClickHouseCustomMetric_ReplicationQueueStuckEntries', 'ClickHouseCustomMetric_ReplicationQueueMaxPostponedEntrySeconds', 'ClickHouseCustomMetric_ReplicationQueueMaxErrorEntrySeconds'] AS names,+ [toInt64(countIf(create_time < (now() - toIntervalDay(15)))), maxIf(dateDiff('seconds', create_time, last_postpone_time), last_postpone_time != '1970-01-01'), maxIf(dateDiff('seconds', create_time, last_exception_time), (last_exception_time != '1970-01-01') AND (last_exception_time > (now() - toIntervalMinute(5))))] AS values,+ ['Number of entries that have been in the replication queue for more than 15 days', 'Maximum number of seconds that an entry has been postponed', 'Maximum number of seconds that an entry has been in error'] AS descriptions,+ ['gauge', 'gauge', 'gauge'] AS types,+ arrayJoin(arrayZip(names, values, descriptions, types)) AS tpl+SELECT+ tpl.1 AS name,+ map('table', `table`, 'instance', hostname()) AS labels,+ tpl.2 AS value,+ tpl.3 AS help,+ tpl.4 AS type+FROM system.replication_queue+GROUP BY+ `table`+HAVING+ value > 0+SQL++ }++ view "custom_metrics_server_crash" {+ query = <<SQL+SELECT+ 'ClickHouseCustomMetric_ServerCrash' AS name,+ map('instance', hostname()) AS labels,+ count() AS value,+ 'Number of server crashes for current date' AS help,+ 'gauge' AS type+FROM system.crash_log+WHERE event_date = today()+GROUP BY+ hostname()+SQL++ }++ view "custom_metrics_table_sizes" {+ query = <<SQL+SELECT+ 'ClickHouseCustomMetric_TableTotalBytes' AS name,+ map('instance', hostname(), 'database', database, 'table', `table`) AS labels,+ CAST(total_bytes, 'Float64') AS value,+ 'Size of a database table on a given node (need a sum for sharded)' AS help,+ 'gauge' AS type+FROM system.tables+WHERE+ (database NOT IN ('INFORMATION_SCHEMA', 'information_schema'))+AND+ (total_bytes IS NOT NULL)+SQL++ }++ view "custom_metrics_test" {+ query = <<SQL+SELECT+ 'ClickHouseCustomMetric_Test' AS name,+ map('instance', hostname()) AS labels,+ 1 AS value,+ 'Test to check that the metric endpoint is working' AS help,+ 'gauge' AS type+SQL++ }++ view "events_batch_export" {+ query = <<SQL+SELECT+ team_id AS team_id,+ timestamp AS timestamp,+ event AS event,+ distinct_id AS distinct_id,+ toString(uuid) AS uuid,+ coalesce(inserted_at, _timestamp) AS _inserted_at,+ created_at AS created_at,+ elements_chain AS elements_chain,+ toString(person_id) AS person_id,+ nullIf(properties, '') AS properties,+ nullIf(person_properties, '') AS person_properties,+ nullIf(JSONExtractString(properties, '$set'), '') AS set,+ nullIf(JSONExtractString(properties, '$set_once'), '') AS set_once+FROM posthog.events+PREWHERE+ (coalesce(events.inserted_at, events._timestamp) >= {interval_start: DateTime64}) AND (coalesce(events.inserted_at, events._timestamp) < {interval_end: DateTime64})+WHERE+ (team_id = {team_id: Int64})+AND+ (events.timestamp >= ({interval_start: DateTime64} - toIntervalDay({lookback_days: Int32})))+AND+ (events.timestamp < ({interval_end: DateTime64} + toIntervalDay(1)))+AND+ ((length({include_events: Array(String)}) = 0) OR (event IN ({include_events: Array(String)})))+AND+ ((length({exclude_events: Array(String)}) = 0) OR (event NOT IN ({exclude_events: Array(String)})))+ORDER BY _inserted_at ASC, event ASC+LIMIT 1 BY team_id, event, cityHash64(events.distinct_id), cityHash64(events.uuid)+SETTINGS+ optimize_aggregation_in_order = 1+SQL++ }++ view "events_batch_export_backfill" {+ query = <<SQL+SELECT+ team_id AS team_id,+ timestamp AS timestamp,+ event AS event,+ distinct_id AS distinct_id,+ toString(uuid) AS uuid,+ timestamp AS _inserted_at,+ created_at AS created_at,+ elements_chain AS elements_chain,+ toString(person_id) AS person_id,+ nullIf(properties, '') AS properties,+ nullIf(person_properties, '') AS person_properties,+ nullIf(JSONExtractString(properties, '$set'), '') AS set,+ nullIf(JSONExtractString(properties, '$set_once'), '') AS set_once+FROM posthog.events+WHERE+ (team_id = {team_id: Int64})+AND+ (events.timestamp >= {interval_start: DateTime64})+AND+ (events.timestamp < {interval_end: DateTime64})+AND+ ((length({include_events: Array(String)}) = 0) OR (event IN ({include_events: Array(String)})))+AND+ ((length({exclude_events: Array(String)}) = 0) OR (event NOT IN ({exclude_events: Array(String)})))+ORDER BY _inserted_at ASC, event ASC+LIMIT 1 BY team_id, event, cityHash64(events.distinct_id), cityHash64(events.uuid)+SETTINGS+ optimize_aggregation_in_order = 1+SQL++ }++ view "events_batch_export_recent" {+ query = <<SQL+SELECT+ team_id AS team_id,+ timestamp AS timestamp,+ event AS event,+ distinct_id AS distinct_id,+ toString(uuid) AS uuid,+ inserted_at AS _inserted_at,+ created_at AS created_at,+ elements_chain AS elements_chain,+ toString(person_id) AS person_id,+ nullIf(properties, '') AS properties,+ nullIf(person_properties, '') AS person_properties,+ nullIf(JSONExtractString(properties, '$set'), '') AS set,+ nullIf(JSONExtractString(properties, '$set_once'), '') AS set_once+FROM posthog.events_recent+PREWHERE+ (events_recent.inserted_at >= {interval_start: DateTime64}) AND (events_recent.inserted_at < {interval_end: DateTime64})+WHERE+ (team_id = {team_id: Int64})+AND+ ((length({include_events: Array(String)}) = 0) OR (event IN ({include_events: Array(String)})))+AND+ ((length({exclude_events: Array(String)}) = 0) OR (event NOT IN ({exclude_events: Array(String)})))+ORDER BY _inserted_at ASC, event ASC+LIMIT 1 BY team_id, event, cityHash64(events_recent.distinct_id), cityHash64(events_recent.uuid)+SETTINGS+ optimize_aggregation_in_order = 1+SQL++ }++ view "events_batch_export_unbounded" {+ query = <<SQL+SELECT+ team_id AS team_id,+ timestamp AS timestamp,+ event AS event,+ distinct_id AS distinct_id,+ toString(uuid) AS uuid,+ coalesce(inserted_at, _timestamp) AS _inserted_at,+ created_at AS created_at,+ elements_chain AS elements_chain,+ toString(person_id) AS person_id,+ nullIf(properties, '') AS properties,+ nullIf(person_properties, '') AS person_properties,+ nullIf(JSONExtractString(properties, '$set'), '') AS set,+ nullIf(JSONExtractString(properties, '$set_once'), '') AS set_once+FROM posthog.events+PREWHERE+ (coalesce(events.inserted_at, events._timestamp) >= {interval_start: DateTime64}) AND (coalesce(events.inserted_at, events._timestamp) < {interval_end: DateTime64})+WHERE+ (team_id = {team_id: Int64})+AND+ ((length({include_events: Array(String)}) = 0) OR (event IN ({include_events: Array(String)})))+AND+ ((length({exclude_events: Array(String)}) = 0) OR (event NOT IN ({exclude_events: Array(String)})))+ORDER BY _inserted_at ASC, event ASC+LIMIT 1 BY team_id, event, cityHash64(events.distinct_id), cityHash64(events.uuid)+SETTINGS+ optimize_aggregation_in_order = 1+SQL++ }++ view "persons_batch_export" {+ query = <<SQL+WITH+ new_persons AS (SELECT id, max(version) AS version, argMax(_timestamp, person.version) AS _timestamp2 FROM posthog.person WHERE (team_id = {team_id: Int64}) AND (id IN (SELECT id FROM posthog.person WHERE (team_id = {team_id: Int64}) AND (_timestamp >= {interval_start: DateTime64}) AND (_timestamp < {interval_end: DateTime64}))) GROUP BY id HAVING (_timestamp2 >= {interval_start: DateTime64}) AND (_timestamp2 < {interval_end: DateTime64})),+ new_distinct_ids AS (SELECT argMax(person_id, person_distinct_id2.version) AS person_id FROM posthog.person_distinct_id2 WHERE (team_id = {team_id: Int64}) AND (distinct_id IN (SELECT distinct_id FROM posthog.person_distinct_id2 WHERE (team_id = {team_id: Int64}) AND (_timestamp >= {interval_start: DateTime64}) AND (_timestamp < {interval_end: DateTime64}))) GROUP BY distinct_id HAVING (argMax(_timestamp, person_distinct_id2.version) >= {interval_start: DateTime64}) AND (argMax(_timestamp, person_distinct_id2.version) < {interval_end: DateTime64})),+ all_new_persons AS (SELECT id, version FROM new_persons UNION ALL SELECT id, max(version) FROM posthog.person WHERE (team_id = {team_id: Int64}) AND (id IN (new_distinct_ids)) GROUP BY id)+SELECT+ p.team_id AS team_id,+ pd.distinct_id AS distinct_id,+ toString(p.id) AS person_id,+ p.properties AS properties,+ pd.version AS person_distinct_id_version,+ p.version AS person_version,+ p.created_at AS created_at,+ multiIf(+ ((pd._timestamp >= {interval_start: DateTime64}) AND (pd._timestamp < {interval_end: DateTime64}))+ AND (NOT ((p._timestamp >= {interval_start: DateTime64}) AND (p._timestamp < {interval_end: DateTime64}))),+ pd._timestamp,+ ((p._timestamp >= {interval_start: DateTime64}) AND (p._timestamp < {interval_end: DateTime64}))+ AND (NOT ((pd._timestamp >= {interval_start: DateTime64}) AND (pd._timestamp < {interval_end: DateTime64}))),+ p._timestamp,+ least(p._timestamp, pd._timestamp)+ ) AS _inserted_at+FROM+ posthog.person AS p INNER JOIN (SELECT distinct_id, max(version) AS version, argMax(person_id, person_distinct_id2.version) AS person_id2, argMax(_timestamp, person_distinct_id2.version) AS _timestamp FROM posthog.person_distinct_id2 WHERE (team_id = {team_id: Int64}) AND (person_id IN (SELECT id FROM all_new_persons)) GROUP BY distinct_id) AS pd ON p.id = pd.person_id2+WHERE+ (team_id = {team_id: Int64})+AND+ ((id, version) IN (all_new_persons))+ORDER BY _inserted_at ASC+SQL++ }++ view "persons_batch_export_backfill" {+ query = <<SQL+SELECT+ pd.team_id AS team_id,+ pd.distinct_id AS distinct_id,+ toString(p.id) AS person_id,+ p.properties AS properties,+ pd.version AS person_distinct_id_version,+ p.version AS person_version,+ p.created_at AS created_at,+ multiIf(+ (pd._timestamp < {interval_end: DateTime64})+ AND (NOT (p._timestamp < {interval_end: DateTime64})),+ pd._timestamp,+ (p._timestamp < {interval_end: DateTime64})+ AND (NOT (pd._timestamp < {interval_end: DateTime64})),+ p._timestamp,+ least(p._timestamp, pd._timestamp)+ ) AS _inserted_at+FROM+ (SELECT team_id, distinct_id, max(version) AS version, argMax(person_id, person_distinct_id2.version) AS person_id, argMax(_timestamp, person_distinct_id2.version) AS _timestamp FROM posthog.person_distinct_id2 PREWHERE team_id = {team_id: Int64} GROUP BY team_id, distinct_id) AS pd INNER JOIN (SELECT team_id, id, max(version) AS version, argMax(properties, person.version) AS properties, argMax(created_at, person.version) AS created_at, argMax(_timestamp, person.version) AS _timestamp FROM posthog.person PREWHERE team_id = {team_id: Int64} GROUP BY team_id, id) AS p ON (p.id = pd.person_id) AND (p.team_id = pd.team_id)+WHERE+ (pd.team_id = {team_id: Int64})+AND+ (p.team_id = {team_id: Int64})+AND+ ((pd._timestamp < {interval_end: DateTime64}) OR (p._timestamp < {interval_end: DateTime64}))+ORDER BY _inserted_at ASC+SQL++ }++ view "posthog_document_embeddings_union_view" {+ query = <<SQL+SELECT+ team_id,+ product,+ document_type,+ rendering,+ document_id,+ timestamp,+ inserted_at,+ content,+ metadata,+ embedding,+ _timestamp,+ _offset,+ _partition,+ 'text-embedding-3-small-1536' AS model_name+FROM posthog.distributed_posthog_document_embeddings_text_embedding_3_small_1536+UNION ALL+SELECT+ team_id,+ product,+ document_type,+ rendering,+ document_id,+ timestamp,+ inserted_at,+ content,+ metadata,+ embedding,+ _timestamp,+ _offset,+ _partition,+ 'text-embedding-3-large-3072' AS model_name+FROM posthog.distributed_posthog_document_embeddings_text_embedding_3_large_3072+SQL++ }++ view "raw_sessions_v" {+ query = <<SQL+SELECT+ session_id_v7,+ fromUnixTimestamp(intDiv(toUInt64(bitShiftRight(session_id_v7, 80)), 1000)) AS session_timestamp,+ team_id,+ argMaxMerge(distinct_id) AS distinct_id,+ min(min_timestamp) AS min_timestamp,+ max(max_timestamp) AS max_timestamp,+ max(max_inserted_at) AS max_inserted_at,+ arrayDistinct(arrayFlatten(groupArray(urls))) AS urls,+ argMinMerge(entry_url) AS entry_url,+ argMaxMerge(end_url) AS end_url,+ argMaxMerge(last_external_click_url) AS last_external_click_url,+ argMinMerge(initial_browser) AS initial_browser,+ argMinMerge(initial_browser_version) AS initial_browser_version,+ argMinMerge(initial_os) AS initial_os,+ argMinMerge(initial_os_version) AS initial_os_version,+ argMinMerge(initial_device_type) AS initial_device_type,+ argMinMerge(initial_viewport_width) AS initial_viewport_width,+ argMinMerge(initial_viewport_height) AS initial_viewport_height,+ argMinMerge(initial_geoip_country_code) AS initial_geoip_country_code,+ argMinMerge(initial_geoip_subdivision_1_code) AS initial_geoip_subdivision_1_code,+ argMinMerge(initial_geoip_subdivision_1_name) AS initial_geoip_subdivision_1_name,+ argMinMerge(initial_geoip_subdivision_city_name) AS initial_geoip_subdivision_city_name,+ argMinMerge(initial_geoip_time_zone) AS initial_geoip_time_zone,+ argMinMerge(initial_utm_source) AS initial_utm_source,+ argMinMerge(initial_utm_campaign) AS initial_utm_campaign,+ argMinMerge(initial_utm_medium) AS initial_utm_medium,+ argMinMerge(initial_utm_term) AS initial_utm_term,+ argMinMerge(initial_utm_content) AS initial_utm_content,+ argMinMerge(initial_referring_domain) AS initial_referring_domain,+ argMinMerge(initial_gclid) AS initial_gclid,+ argMinMerge(initial_gad_source) AS initial_gad_source,+ argMinMerge(initial_gclsrc) AS initial_gclsrc,+ argMinMerge(initial_dclid) AS initial_dclid,+ argMinMerge(initial_gbraid) AS initial_gbraid,+ argMinMerge(initial_wbraid) AS initial_wbraid,+ argMinMerge(initial_fbclid) AS initial_fbclid,+ argMinMerge(initial_msclkid) AS initial_msclkid,+ argMinMerge(initial_twclid) AS initial_twclid,+ argMinMerge(initial_li_fat_id) AS initial_li_fat_id,+ argMinMerge(initial_mc_cid) AS initial_mc_cid,+ argMinMerge(initial_igshid) AS initial_igshid,+ argMinMerge(initial_ttclid) AS initial_ttclid,+ argMinMerge(initial__kx) AS initial__kx,+ argMinMerge(initial_irclid) AS initial_irclid,+ sum(pageview_count) AS pageview_count,+ uniqMerge(pageview_uniq) AS pageview_uniq,+ sum(autocapture_count) AS autocapture_count,+ uniqMerge(autocapture_uniq) AS autocapture_uniq,+ sum(screen_count) AS screen_count,+ uniqMerge(screen_uniq) AS screen_uniq,+ max(maybe_has_session_replay) AS maybe_has_session_replay,+ uniqUpToMerge(1)(page_screen_autocapture_uniq_up_to) AS page_screen_autocapture_uniq_up_to,+ argMinMerge(vitals_lcp) AS vitals_lcp+FROM posthog.raw_sessions+GROUP BY+ session_id_v7, team_id+SQL++ }++ view "raw_sessions_v3_v" {+ query = <<SQL+SELECT+ session_id_v7,+ session_timestamp,+ team_id,+ argMaxMerge(distinct_id) AS distinct_id,+ groupUniqArrayMerge(distinct_ids) AS distinct_ids,+ min(min_timestamp) AS min_timestamp,+ max(max_timestamp) AS max_timestamp,+ max(max_inserted_at) AS max_inserted_at,+ groupUniqArrayArray(2000)(urls) AS urls,+ argMinMerge(entry_url) AS entry_url,+ argMaxMerge(end_url) AS end_url,+ argMaxMerge(last_external_click_url) AS last_external_click_url,+ argMinMerge(browser) AS browser,+ argMinMerge(browser_version) AS browser_version,+ argMinMerge(os) AS os,+ argMinMerge(os_version) AS os_version,+ argMinMerge(device_type) AS device_type,+ argMinMerge(viewport_width) AS viewport_width,+ argMinMerge(viewport_height) AS viewport_height,+ argMinMerge(geoip_country_code) AS geoip_country_code,+ argMinMerge(geoip_subdivision_1_code) AS geoip_subdivision_1_code,+ argMinMerge(geoip_subdivision_1_name) AS geoip_subdivision_1_name,+ argMinMerge(geoip_subdivision_city_name) AS geoip_subdivision_city_name,+ argMinMerge(geoip_time_zone) AS geoip_time_zone,+ argMinMerge(entry_utm_source) AS entry_utm_source,+ argMinMerge(entry_utm_campaign) AS entry_utm_campaign,+ argMinMerge(entry_utm_medium) AS entry_utm_medium,+ argMinMerge(entry_utm_term) AS entry_utm_term,+ argMinMerge(entry_utm_content) AS entry_utm_content,+ argMinMerge(entry_referring_domain) AS entry_referring_domain,+ argMinMerge(entry_gclid) AS entry_gclid,+ argMinMerge(entry_gad_source) AS entry_gad_source,+ argMinMerge(entry_fbclid) AS entry_fbclid,+ argMinMerge(entry_has_gclid) AS entry_has_gclid,+ argMinMerge(entry_has_fbclid) AS entry_has_fbclid,+ argMinMerge(entry_ad_ids_map) AS entry_ad_ids_map,+ argMinMerge(entry_ad_ids_set) AS entry_ad_ids_set,+ argMinMerge(entry_channel_type_properties) AS entry_channel_type_properties,+ uniqExactMerge(pageview_uniq) AS pageview_uniq,+ uniqExactMerge(autocapture_uniq) AS autocapture_uniq,+ uniqExactMerge(screen_uniq) AS screen_uniq,+ uniqUpToMerge(1)(page_screen_uniq_up_to) AS page_screen_uniq_up_to,+ max(has_autocapture) AS has_autocapture,+ groupUniqArrayMapMerge(flag_values) AS flag_values,+ groupUniqArrayArray(flag_keys) AS flag_keys,+ groupUniqArrayArray(2000)(event_names) AS event_names,+ groupUniqArrayArray(100)(hosts) AS hosts,+ groupUniqArrayArray(10)(emails) AS emails,+ max(has_replay_events) AS has_replay_events+FROM posthog.raw_sessions_v3+GROUP BY+ session_id_v7, session_timestamp, team_id+SQL++ }++ view "sessions_v" {+ query = <<SQL+SELECT+ session_id,+ team_id,+ any(distinct_id) AS distinct_id,+ min(min_timestamp) AS min_timestamp,+ max(max_timestamp) AS max_timestamp,+ arrayDistinct(arrayFlatten(groupArray(urls))) AS urls,+ argMinMerge(entry_url) AS entry_url,+ argMaxMerge(exit_url) AS exit_url,+ argMinMerge(initial_utm_source) AS initial_utm_source,+ argMinMerge(initial_utm_campaign) AS initial_utm_campaign,+ argMinMerge(initial_utm_medium) AS initial_utm_medium,+ argMinMerge(initial_utm_term) AS initial_utm_term,+ argMinMerge(initial_utm_content) AS initial_utm_content,+ argMinMerge(initial_referring_domain) AS initial_referring_domain,+ argMinMerge(initial_gclid) AS initial_gclid,+ argMinMerge(initial_gad_source) AS initial_gad_source,+ argMinMerge(initial_gclsrc) AS initial_gclsrc,+ argMinMerge(initial_dclid) AS initial_dclid,+ argMinMerge(initial_gbraid) AS initial_gbraid,+ argMinMerge(initial_wbraid) AS initial_wbraid,+ argMinMerge(initial_fbclid) AS initial_fbclid,+ argMinMerge(initial_msclkid) AS initial_msclkid,+ argMinMerge(initial_twclid) AS initial_twclid,+ argMinMerge(initial_li_fat_id) AS initial_li_fat_id,+ argMinMerge(initial_mc_cid) AS initial_mc_cid,+ argMinMerge(initial_igshid) AS initial_igshid,+ argMinMerge(initial_ttclid) AS initial_ttclid,+ argMinMerge(initial_epik) AS initial_epik,+ argMinMerge(initial_qclid) AS initial_qclid,+ argMinMerge(initial_sccid) AS initial_sccid,+ sumMap(event_count_map) AS event_count_map,+ sum(pageview_count) AS pageview_count,+ sum(autocapture_count) AS autocapture_count+FROM posthog.sessions+GROUP BY+ session_id, team_id+SQL++ }++ dictionary "channel_definition_dict" {+ primary_key = ["domain", "kind"]+ lifetime {+ min = 3000+ max = 3600+ }+ attribute "domain" {+ type = "String"+ }+ attribute "kind" {+ type = "String"+ }+ attribute "domain_type" {+ type = "Nullable(String)"+ }+ attribute "type_if_paid" {+ type = "Nullable(String)"+ }+ attribute "type_if_organic" {+ type = "Nullable(String)"+ }+ source "clickhouse" {+ user = "default"+ table = "channel_definition"+ }+ layout "complex_key_hashed" {+ }+ }++ dictionary "exchange_rate_dict" {+ primary_key = ["currency"]+ lifetime {+ min = 3000+ max = 3600+ }+ range {+ min = "start_date"+ max = "end_date"+ }+ attribute "currency" {+ type = "String"+ }+ attribute "start_date" {+ type = "Date"+ }+ attribute "end_date" {+ type = "Nullable(Date)"+ }+ attribute "rate" {+ type = "Decimal64(10)"+ }+ source "clickhouse" {+ user = "default"+ query = "SELECT currency, date AS start_date, leadInFrame(date::Nullable(Date), 1, NULL::Nullable(Date)) OVER w AS end_date, argMax(rate, version) AS rate FROM `posthog`.`exchange_rate` GROUP BY date, currency WINDOW w AS ( PARTITION BY currency ORDER BY date ASC ROWS BETWEEN 1 FOLLOWING AND 1 FOLLOWING )"+ }+ layout "complex_key_range_hashed" {+ range_lookup_strategy = "max"+ }+ }++ dictionary "person_distinct_id_overrides_dict" {+ primary_key = ["team_id", "distinct_id"]+ lifetime {+ min = 3600+ max = 18000+ }+ attribute "team_id" {+ type = "Int64"+ }+ attribute "distinct_id" {+ type = "String"+ }+ attribute "person_id" {+ type = "UUID"+ }+ source "clickhouse" {+ user = "default"+ query = "SELECT team_id, distinct_id, argMax(person_id, version) AS person_id FROM posthog.person_distinct_id_overrides GROUP BY team_id, distinct_id"+ }+ layout "complex_key_hashed" {+ }+ }++ dictionary "person_overrides_dict" {+ primary_key = ["team_id", "old_person_id"]+ lifetime {+ min = 5+ max = 10+ }+ attribute "team_id" {+ type = "INT"+ }+ attribute "old_person_id" {+ type = "UUID"+ }+ attribute "override_person_id" {+ type = "UUID"+ }+ source "clickhouse" {+ user = "default"+ query = "\\nSELECT\\n team_id,\\n old_person_id,\\n argMax(override_person_id, version)\\nFROM\\n `posthog`.`person_overrides` AS overrides\\nGROUP BY\\n team_id,\\n old_person_id\\n"+ }+ layout "complex_key_hashed" {+ preallocate = 1+ }+ }++ dictionary "web_bot_definition_dict" {+ primary_key = ["regexp"]+ lifetime {+ min = 3000+ max = 3600+ }+ attribute "regexp" {+ type = "String"+ }+ attribute "name" {+ type = "String"+ }+ attribute "category" {+ type = "String"+ }+ attribute "traffic_type" {+ type = "String"+ }+ attribute "operator" {+ type = "String"+ }+ source "clickhouse" {+ user = "default"+ db = "posthog"+ table = "web_bot_definition"+ }+ layout "regexp_tree" {+ }+ }++ dictionary "web_pre_aggregated_teams_dict" {+ primary_key = ["team_id"]+ lifetime {+ min = 3000+ max = 3600+ }+ attribute "team_id" {+ type = "UInt64"+ }+ source "clickhouse" {+ user = "default"+ query = "SELECT team_id FROM `posthog`.`web_pre_aggregated_teams` FINAL WHERE version > 0"+ }+ layout "hashed" {+ }+ }+}diff --git a/posthog/clickhouse/hcl/lib.sh b/posthog/clickhouse/hcl/lib.shindex b1af575c69a0..2e8620036ad2 100644--- a/posthog/clickhouse/hcl/lib.sh+++ b/posthog/clickhouse/hcl/lib.sh@@ -56,8 +56,11 @@ manifest_stack() {# unchanged; only the generated filename differs.golden_name() {case "$1" in- aux) echo "auxiliary" ;;- *) echo "$1" ;;+ aux) echo "auxiliary" ;;+ events) echo "ingestion_events" ;;+ small) echo "ingestion_small" ;;+ medium) echo "ingestion_medium" ;;+ *) echo "$1" ;;esac}diff --git a/posthog/clickhouse/hcl/manifest.hcl b/posthog/clickhouse/hcl/manifest.hclindex 314e006ed6ce..18577e73d81a 100644--- a/posthog/clickhouse/hcl/manifest.hcl+++ b/posthog/clickhouse/hcl/manifest.hcl@@ -101,7 +101,32 @@ role "batch_exports" {# columns per env that are added out-of-band and churn constantly, so their goldens# live in PostHog/posthog-cloud-infra (clickhouse/hcl/), not the OSS gate.role "data" {- env "local-multi" { layers = ["roles/shared", "roles/coshared/aux_data", "roles/coshared/sessions_data", "roles/coshared/ai_events_data", "roles/coshared/tophog", "roles/coshared/events_recent", "roles/coshared/events_recent_write", "roles/coshared/batch_exports_data", "roles/coshared/ingestion_warnings_store", "roles/data/shared", "roles/data/local"] }+ env "local-multi" { layers = ["roles/shared", "roles/coshared/aux_data", "roles/coshared/sessions_data", "roles/coshared/ai_events_data", "roles/coshared/tophog", "roles/coshared/events_recent", "roles/coshared/events_recent_write", "roles/coshared/batch_exports_data", "roles/coshared/ingestion_warnings_store", "roles/coshared/events_json_write", "roles/coshared/log_entries_write", "roles/coshared/session_replay_write", "roles/data/shared", "roles/data/local"] }+}++# INGESTION satellites: the Kafka consumer layer. Each node carries the kafka_* engine+# tables for its topic class, the MV that reads them, and the writable_* Distributed+# proxies that write into the data cluster (migration 0157 moved this off the data node).+# Beyond that they carry only the shared query_log_archive path. Role names are the+# hostClusterRole macros migrations target: events, small, medium.+role "events" {+ env "local-multi" { layers = ["roles/shared/qla.hcl", "roles/coshared/events_json_write", "roles/ingestion_events/local"] }+}++role "small" {+ env "local-multi" { layers = ["roles/shared/qla.hcl", "roles/coshared/log_entries_write", "roles/coshared/session_replay_write", "roles/ingestion_small/local"] }+}++role "medium" {+ env "local-multi" { layers = ["roles/shared/qla.hcl", "roles/ingestion_medium/local"] }+}++# The plain dev/hobby stack (docker-compose.dev.yml): ONE ClickHouse server hosting every+# role's objects, because migration_tools routes every migration to NodeRole.ALL when DEBUG+# and not MULTINODE_CLICKHOUSE. Composed as the deduped union of the local-multi stacks it+# hosts, so any name two of those roles declare fails this load instead of drifting.+role "all" {+ env "local-single" { layers = ["roles/shared", "roles/coshared/custom_metrics", "roles/ops/shared", "roles/ops/local", "roles/logs/base", "roles/logs/traces", "roles/logs/traces_kafka_metrics", "roles/logs/local", "roles/coshared/ai_events_data", "roles/ai_events/shared", "roles/ai_events/local", "roles/coshared/aux_data", "roles/auxiliary/shared", "roles/auxiliary/local", "roles/coshared/sessions_data", "roles/coshared/tophog", "roles/coshared/events_recent", "roles/coshared/events_recent_write", "roles/coshared/batch_exports_data", "roles/coshared/ingestion_warnings_store", "roles/coshared/events_json_write", "roles/coshared/log_entries_write", "roles/coshared/session_replay_write", "roles/data/shared", "roles/data/local", "roles/ingestion_events/local", "roles/ingestion_small/local", "roles/ingestion_medium/local"] }}# role "endpoints" {diff --git a/posthog/clickhouse/hcl/migration.md b/posthog/clickhouse/hcl/migration.mdindex f6195c667e15..2984ecb62699 100644--- a/posthog/clickhouse/hcl/migration.md+++ b/posthog/clickhouse/hcl/migration.md@@ -57,7 +57,7 @@ We want to achieve a state of full schema of each env and cluster to be represenEnd state: we have 5 environments schemas as HCL, a golden per cluster, something like:- local-single (in PostHog/posthog)- - schema.hcl+ - all.hcl (one node hosts every role, so one golden)- local-multi (in PostHog/posthog):- ops.hcl- posthog.hcldiff --git a/posthog/clickhouse/hcl/roles/coshared/events_json_write/tables.hcl b/posthog/clickhouse/hcl/roles/coshared/events_json_write/tables.hclnew file mode 100644index 000000000000..72dc0e9a3b30--- /dev/null+++ b/posthog/clickhouse/hcl/roles/coshared/events_json_write/tables.hcl@@ -0,0 +1,106 @@+database "posthog" {+ table "writable_events_json" {+ column "uuid" {+ type = "UUID"+ }+ column "event" {+ type = "String"+ }+ column "properties" {+ type = "JSON(max_dynamic_types=8, max_dynamic_paths=256, `$active_feature_flags` Array(String), `$ai_experiment_id` Nullable(String), `$ai_http_status` Nullable(String), `$ai_is_error` Nullable(String), `$ai_model` Nullable(String), `$ai_parent_id` Nullable(String), `$ai_prompt_name` Nullable(String), `$ai_provider` Nullable(String), `$ai_session_id` Nullable(String), `$ai_span_id` Nullable(String), `$ai_total_cost_usd` Nullable(String), `$ai_trace_id` Nullable(String), `$anon_distinct_id` Nullable(String), `$app_build` Nullable(String), `$app_namespace` Nullable(String), `$app_version` Nullable(String), `$browser` Nullable(String), `$browser_version` Nullable(String), `$current_url` Nullable(String), `$device` Nullable(String), `$device_id` Nullable(String), `$device_model` Nullable(String), `$device_type` Nullable(String), `$el_text` Nullable(String), `$event_type` Nullable(String), `$exception_fingerprint` Nullable(String), `$exception_functions` Array(String), `$exception_issue_id` Nullable(String), `$exception_sources` Array(String), `$exception_types` Array(String), `$exception_values` Array(String), `$feature_flag` Nullable(String), `$feature_flag_payloads` Nullable(String), `$feature_flag_response` Nullable(String), `$geoip_city_name` Nullable(String), `$geoip_country_code` Nullable(String), `$geoip_country_name` Nullable(String), `$geoip_subdivision_1_code` Nullable(String), `$group_0` Nullable(String), `$group_1` Nullable(String), `$group_2` Nullable(String), `$group_3` Nullable(String), `$group_4` Nullable(String), `$groups` Nullable(String), `$host` Nullable(String), `$initial_pathname` Nullable(String), `$initial_referrer` Nullable(String), `$initial_referring_domain` Nullable(String), `$ip` Nullable(String), `$is_identified` Nullable(String), `$lib` Nullable(String), `$lib_custom_api_host` Nullable(String), `$lib_version` Nullable(String), `$lib_version__minor` Nullable(String), `$os` Nullable(String), `$os_name` Nullable(String), `$os_version` Nullable(String), `$pathname` Nullable(String), `$prev_pageview_max_content_percentage` Nullable(String), `$prev_pageview_max_scroll_percentage` Nullable(String), `$prev_pageview_pathname` Nullable(String), `$process_person_profile` Nullable(String), `$referrer` Nullable(String), `$referring_domain` Nullable(String), `$screen_height` Nullable(String), `$screen_name` Nullable(String), `$screen_width` Nullable(String), `$sent_at` Nullable(String), `$session_id` Nullable(String), `$survey_id` Nullable(String), `$survey_response` Nullable(String), `$survey_response_1` Nullable(String), `$time` Nullable(String), `$user_id` Nullable(String), `$viewport_height` Nullable(String), `$viewport_width` Nullable(String), `$web_vitals_CLS_value` Nullable(String), `$web_vitals_FCP_value` Nullable(String), `$web_vitals_INP_value` Nullable(String), `$web_vitals_LCP_value` Nullable(String), `$window_id` Nullable(String))"+ }+ column "timestamp" {+ type = "DateTime64(6, 'UTC')"+ }+ column "team_id" {+ type = "Int64"+ }+ column "distinct_id" {+ type = "String"+ }+ column "elements_hash" {+ type = "String"+ default = "''"+ }+ column "created_at" {+ type = "DateTime64(6, 'UTC')"+ }+ column "_timestamp" {+ type = "DateTime"+ }+ column "_offset" {+ type = "UInt64"+ }+ column "elements_chain" {+ type = "String"+ }+ column "person_id" {+ type = "UUID"+ }+ column "person_properties" {+ type = "JSON(max_dynamic_types=6, max_dynamic_paths=32, `$app_version` Nullable(String), `$browser` Nullable(String), `$current_url` Nullable(String), `$geoip_continent_name` Nullable(String), `$geoip_country_code` Nullable(String), `$geoip_country_name` Nullable(String), `$initial_current_url` Nullable(String), `$initial_fbclid` Nullable(String), `$initial_gad_source` Nullable(String), `$initial_gbraid` Nullable(String), `$initial_gclid` Nullable(String), `$initial_msclkid` Nullable(String), `$initial_pathname` Nullable(String), `$initial_referring_domain` Nullable(String), `$initial_utm_campaign` Nullable(String), `$initial_utm_content` Nullable(String), `$initial_utm_medium` Nullable(String), `$initial_utm_source` Nullable(String), `$initial_utm_term` Nullable(String), `$initial_wbraid` Nullable(String), `$os_name` Nullable(String), `$referring_domain` Nullable(String))"+ }+ column "group0_properties" {+ type = "String"+ codec = "ZSTD(3)"+ }+ column "group1_properties" {+ type = "String"+ codec = "ZSTD(3)"+ }+ column "group2_properties" {+ type = "String"+ codec = "ZSTD(3)"+ }+ column "group3_properties" {+ type = "String"+ codec = "ZSTD(3)"+ }+ column "group4_properties" {+ type = "String"+ codec = "ZSTD(3)"+ }+ column "person_created_at" {+ type = "DateTime64(3)"+ }+ column "group0_created_at" {+ type = "DateTime64(3)"+ }+ column "group1_created_at" {+ type = "DateTime64(3)"+ }+ column "group2_created_at" {+ type = "DateTime64(3)"+ }+ column "group3_created_at" {+ type = "DateTime64(3)"+ }+ column "group4_created_at" {+ type = "DateTime64(3)"+ }+ column "inserted_at" {+ type = "Nullable(DateTime64(6, 'UTC'))"+ default = "now64()"+ }+ column "person_mode" {+ type = "Enum8('full'=0, 'propertyless'=1, 'force_upgrade'=2)"+ }+ column "is_deleted" {+ type = "Bool"+ default = "false"+ }+ column "consumer_breadcrumbs" {+ type = "Array(String)"+ }+ column "historical_migration" {+ type = "Bool"+ default = "false"+ }+ engine "distributed" {+ cluster_name = "posthog"+ remote_database = "posthog"+ remote_table = "sharded_events_json"+ sharding_key = "sipHash64(distinct_id)"+ }+ }+}diff --git a/posthog/clickhouse/hcl/roles/coshared/log_entries_write/tables.hcl b/posthog/clickhouse/hcl/roles/coshared/log_entries_write/tables.hclnew file mode 100644index 000000000000..75d7aa204ab4--- /dev/null+++ b/posthog/clickhouse/hcl/roles/coshared/log_entries_write/tables.hcl@@ -0,0 +1,37 @@+database "posthog" {+ table "writable_log_entries" {+ column "team_id" {+ type = "UInt64"+ }+ column "log_source" {+ type = "LowCardinality(String)"+ }+ column "log_source_id" {+ type = "String"+ }+ column "instance_id" {+ type = "String"+ }+ column "timestamp" {+ type = "DateTime64(6, 'UTC')"+ }+ column "level" {+ type = "LowCardinality(String)"+ }+ column "message" {+ type = "String"+ }+ column "_timestamp" {+ type = "DateTime"+ }+ column "_offset" {+ type = "UInt64"+ }+ engine "distributed" {+ cluster_name = "posthog"+ remote_database = "posthog"+ remote_table = "sharded_log_entries"+ sharding_key = "rand()"+ }+ }+}diff --git a/posthog/clickhouse/hcl/roles/coshared/session_replay_write/tables.hcl b/posthog/clickhouse/hcl/roles/coshared/session_replay_write/tables.hclnew file mode 100644index 000000000000..d802e33d97d4--- /dev/null+++ b/posthog/clickhouse/hcl/roles/coshared/session_replay_write/tables.hcl@@ -0,0 +1,99 @@+database "posthog" {+ table "writable_session_replay_events" {+ column "session_id" {+ type = "String"+ }+ column "team_id" {+ type = "Int64"+ }+ column "distinct_id" {+ type = "String"+ }+ column "min_first_timestamp" {+ type = "SimpleAggregateFunction(min, DateTime64(6, 'UTC'))"+ }+ 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)"+ }+ column "keypress_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "mouse_activity_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "active_milliseconds" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "console_log_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "console_warn_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "console_error_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "size" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "message_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "event_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "snapshot_source" {+ type = "AggregateFunction(argMin, LowCardinality(Nullable(String)), DateTime64(6, 'UTC'))"+ }+ column "snapshot_library" {+ type = "AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC'))"+ }+ column "_timestamp" {+ type = "SimpleAggregateFunction(max, DateTime)"+ }+ column "retention_period_days" {+ type = "SimpleAggregateFunction(max, Nullable(Int64))"+ }+ column "is_deleted" {+ type = "SimpleAggregateFunction(max, UInt8)"+ default = "0"+ }+ column "ai_tags_fixed" {+ type = "SimpleAggregateFunction(groupUniqArrayArray, Array(String))"+ }+ column "ai_tags_freeform" {+ type = "SimpleAggregateFunction(groupUniqArrayArray, Array(String))"+ }+ column "ai_highlighted" {+ type = "SimpleAggregateFunction(max, UInt8)"+ default = "0"+ }+ column "surfacing_score" {+ type = "SimpleAggregateFunction(max, Nullable(Float32))"+ }+ engine "distributed" {+ cluster_name = "posthog"+ remote_database = "posthog"+ remote_table = "sharded_session_replay_events"+ sharding_key = "sipHash64(distinct_id)"+ }+ }+}diff --git a/posthog/clickhouse/hcl/roles/data/local/tables.hcl b/posthog/clickhouse/hcl/roles/data/local/tables.hclindex 0288b9be12e3..72c4523bc04b 100644--- a/posthog/clickhouse/hcl/roles/data/local/tables.hcl+++ b/posthog/clickhouse/hcl/roles/data/local/tables.hcl@@ -1566,110 +1566,6 @@ database "posthog" {version_column = "_timestamp"}}- table "writable_events_json" {- column "uuid" {- type = "UUID"- }- column "event" {- type = "String"- }- column "properties" {- type = "JSON(max_dynamic_types=8, max_dynamic_paths=256, `$active_feature_flags` Array(String), `$ai_experiment_id` Nullable(String), `$ai_http_status` Nullable(String), `$ai_is_error` Nullable(String), `$ai_model` Nullable(String), `$ai_parent_id` Nullable(String), `$ai_prompt_name` Nullable(String), `$ai_provider` Nullable(String), `$ai_session_id` Nullable(String), `$ai_span_id` Nullable(String), `$ai_total_cost_usd` Nullable(String), `$ai_trace_id` Nullable(String), `$anon_distinct_id` Nullable(String), `$app_build` Nullable(String), `$app_namespace` Nullable(String), `$app_version` Nullable(String), `$browser` Nullable(String), `$browser_version` Nullable(String), `$current_url` Nullable(String), `$device` Nullable(String), `$device_id` Nullable(String), `$device_model` Nullable(String), `$device_type` Nullable(String), `$el_text` Nullable(String), `$event_type` Nullable(String), `$exception_fingerprint` Nullable(String), `$exception_functions` Array(String), `$exception_issue_id` Nullable(String), `$exception_sources` Array(String), `$exception_types` Array(String), `$exception_values` Array(String), `$feature_flag` Nullable(String), `$feature_flag_payloads` Nullable(String), `$feature_flag_response` Nullable(String), `$geoip_city_name` Nullable(String), `$geoip_country_code` Nullable(String), `$geoip_country_name` Nullable(String), `$geoip_subdivision_1_code` Nullable(String), `$group_0` Nullable(String), `$group_1` Nullable(String), `$group_2` Nullable(String), `$group_3` Nullable(String), `$group_4` Nullable(String), `$groups` Nullable(String), `$host` Nullable(String), `$initial_pathname` Nullable(String), `$initial_referrer` Nullable(String), `$initial_referring_domain` Nullable(String), `$ip` Nullable(String), `$is_identified` Nullable(String), `$lib` Nullable(String), `$lib_custom_api_host` Nullable(String), `$lib_version` Nullable(String), `$lib_version__minor` Nullable(String), `$os` Nullable(String), `$os_name` Nullable(String), `$os_version` Nullable(String), `$pathname` Nullable(String), `$prev_pageview_max_content_percentage` Nullable(String), `$prev_pageview_max_scroll_percentage` Nullable(String), `$prev_pageview_pathname` Nullable(String), `$process_person_profile` Nullable(String), `$referrer` Nullable(String), `$referring_domain` Nullable(String), `$screen_height` Nullable(String), `$screen_name` Nullable(String), `$screen_width` Nullable(String), `$sent_at` Nullable(String), `$session_id` Nullable(String), `$survey_id` Nullable(String), `$survey_response` Nullable(String), `$survey_response_1` Nullable(String), `$time` Nullable(String), `$user_id` Nullable(String), `$viewport_height` Nullable(String), `$viewport_width` Nullable(String), `$web_vitals_CLS_value` Nullable(String), `$web_vitals_FCP_value` Nullable(String), `$web_vitals_INP_value` Nullable(String), `$web_vitals_LCP_value` Nullable(String), `$window_id` Nullable(String))"- }- column "timestamp" {- type = "DateTime64(6, 'UTC')"- }- column "team_id" {- type = "Int64"- }- column "distinct_id" {- type = "String"- }- column "elements_hash" {- type = "String"- default = "''"- }- column "created_at" {- type = "DateTime64(6, 'UTC')"- }- column "_timestamp" {- type = "DateTime"- }- column "_offset" {- type = "UInt64"- }- column "elements_chain" {- type = "String"- }- column "person_id" {- type = "UUID"- }- column "person_properties" {- type = "JSON(max_dynamic_types=6, max_dynamic_paths=32, `$app_version` Nullable(String), `$browser` Nullable(String), `$current_url` Nullable(String), `$geoip_continent_name` Nullable(String), `$geoip_country_code` Nullable(String), `$geoip_country_name` Nullable(String), `$initial_current_url` Nullable(String), `$initial_fbclid` Nullable(String), `$initial_gad_source` Nullable(String), `$initial_gbraid` Nullable(String), `$initial_gclid` Nullable(String), `$initial_msclkid` Nullable(String), `$initial_pathname` Nullable(String), `$initial_referring_domain` Nullable(String), `$initial_utm_campaign` Nullable(String), `$initial_utm_content` Nullable(String), `$initial_utm_medium` Nullable(String), `$initial_utm_source` Nullable(String), `$initial_utm_term` Nullable(String), `$initial_wbraid` Nullable(String), `$os_name` Nullable(String), `$referring_domain` Nullable(String))"- }- column "group0_properties" {- type = "String"- codec = "ZSTD(3)"- }- column "group1_properties" {- type = "String"- codec = "ZSTD(3)"- }- column "group2_properties" {- type = "String"- codec = "ZSTD(3)"- }- column "group3_properties" {- type = "String"- codec = "ZSTD(3)"- }- column "group4_properties" {- type = "String"- codec = "ZSTD(3)"- }- column "person_created_at" {- type = "DateTime64(3)"- }- column "group0_created_at" {- type = "DateTime64(3)"- }- column "group1_created_at" {- type = "DateTime64(3)"- }- column "group2_created_at" {- type = "DateTime64(3)"- }- column "group3_created_at" {- type = "DateTime64(3)"- }- column "group4_created_at" {- type = "DateTime64(3)"- }- column "inserted_at" {- type = "Nullable(DateTime64(6, 'UTC'))"- default = "now64()"- }- column "person_mode" {- type = "Enum8('full'=0, 'propertyless'=1, 'force_upgrade'=2)"- }- column "is_deleted" {- type = "Bool"- default = "false"- }- column "consumer_breadcrumbs" {- type = "Array(String)"- }- column "historical_migration" {- type = "Bool"- default = "false"- }- engine "distributed" {- cluster_name = "posthog"- remote_database = "posthog"- remote_table = "sharded_events_json"- sharding_key = "sipHash64(distinct_id)"- }- }table "events_dead_letter_queue" {order_by = ["id", "event_uuid", "distinct_id", "team_id"]@@ -5801,41 +5697,6 @@ database "posthog" {sharding_key = "sipHash64(distinct_id)"}}- table "writable_log_entries" {- column "team_id" {- type = "UInt64"- }- column "log_source" {- type = "LowCardinality(String)"- }- column "log_source_id" {- type = "String"- }- column "instance_id" {- type = "String"- }- column "timestamp" {- type = "DateTime64(6, 'UTC')"- }- column "level" {- type = "LowCardinality(String)"- }- column "message" {- type = "String"- }- column "_timestamp" {- type = "DateTime"- }- column "_offset" {- type = "UInt64"- }- engine "distributed" {- cluster_name = "posthog"- remote_database = "posthog"- remote_table = "sharded_log_entries"- sharding_key = "rand()"- }- }table "writable_posthog_document_embeddings_text_embedding_3_large_3072" {column "team_id" {type = "Int64"@@ -6290,103 +6151,6 @@ database "posthog" {sharding_key = "sipHash64(session_id)"}}- table "writable_session_replay_events" {- column "session_id" {- type = "String"- }- column "team_id" {- type = "Int64"- }- column "distinct_id" {- type = "String"- }- column "min_first_timestamp" {- type = "SimpleAggregateFunction(min, DateTime64(6, 'UTC'))"- }- 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)"- }- column "keypress_count" {- type = "SimpleAggregateFunction(sum, Int64)"- }- column "mouse_activity_count" {- type = "SimpleAggregateFunction(sum, Int64)"- }- column "active_milliseconds" {- type = "SimpleAggregateFunction(sum, Int64)"- }- column "console_log_count" {- type = "SimpleAggregateFunction(sum, Int64)"- }- column "console_warn_count" {- type = "SimpleAggregateFunction(sum, Int64)"- }- column "console_error_count" {- type = "SimpleAggregateFunction(sum, Int64)"- }- column "size" {- type = "SimpleAggregateFunction(sum, Int64)"- }- column "message_count" {- type = "SimpleAggregateFunction(sum, Int64)"- }- column "event_count" {- type = "SimpleAggregateFunction(sum, Int64)"- }- column "snapshot_source" {- type = "AggregateFunction(argMin, LowCardinality(Nullable(String)), DateTime64(6, 'UTC'))"- }- column "snapshot_library" {- type = "AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC'))"- }- column "_timestamp" {- type = "SimpleAggregateFunction(max, DateTime)"- }- column "is_deleted" {- type = "SimpleAggregateFunction(max, UInt8)"- default = "0"- }- column "ai_tags_fixed" {- type = "SimpleAggregateFunction(groupUniqArrayArray, Array(String))"- }- column "ai_tags_freeform" {- type = "SimpleAggregateFunction(groupUniqArrayArray, Array(String))"- }- column "ai_highlighted" {- type = "SimpleAggregateFunction(max, UInt8)"- default = "0"- }- column "surfacing_score" {- type = "SimpleAggregateFunction(max, Nullable(Float32))"- }- column "retention_period_days" {- type = "SimpleAggregateFunction(max, Nullable(Int64))"- }- engine "distributed" {- cluster_name = "posthog"- remote_database = "posthog"- remote_table = "sharded_session_replay_events"- sharding_key = "sipHash64(distinct_id)"- }- }table "writable_sessions" {column "session_id" {type = "String"diff --git a/posthog/clickhouse/hcl/roles/ingestion_events/local/tables.hcl b/posthog/clickhouse/hcl/roles/ingestion_events/local/tables.hclnew file mode 100644index 000000000000..1b8411b3f58d--- /dev/null+++ b/posthog/clickhouse/hcl/roles/ingestion_events/local/tables.hcl@@ -0,0 +1,252 @@+node "events" {+ macros = {+ hostClusterRole = "events"+ hostClusterType = "online"+ replica = "events"+ shard = "01"+ }+}++database "posthog" {+ table "kafka_events_json_native_json" {+ column "uuid" {+ type = "UUID"+ }+ column "event" {+ type = "String"+ }+ column "properties" {+ type = "String"+ codec = "ZSTD(3)"+ }+ column "timestamp" {+ type = "DateTime64(6, 'UTC')"+ }+ column "team_id" {+ type = "Int64"+ }+ column "distinct_id" {+ type = "String"+ }+ column "elements_chain" {+ type = "String"+ }+ column "created_at" {+ type = "DateTime64(6, 'UTC')"+ }+ column "person_id" {+ type = "UUID"+ }+ column "person_created_at" {+ type = "DateTime64(3)"+ }+ column "person_properties" {+ type = "String"+ codec = "ZSTD(3)"+ }+ column "group0_properties" {+ type = "String"+ codec = "ZSTD(3)"+ }+ column "group1_properties" {+ type = "String"+ codec = "ZSTD(3)"+ }+ column "group2_properties" {+ type = "String"+ codec = "ZSTD(3)"+ }+ column "group3_properties" {+ type = "String"+ codec = "ZSTD(3)"+ }+ column "group4_properties" {+ type = "String"+ codec = "ZSTD(3)"+ }+ column "group0_created_at" {+ type = "DateTime64(3)"+ }+ column "group1_created_at" {+ type = "DateTime64(3)"+ }+ column "group2_created_at" {+ type = "DateTime64(3)"+ }+ column "group3_created_at" {+ type = "DateTime64(3)"+ }+ column "group4_created_at" {+ type = "DateTime64(3)"+ }+ column "person_mode" {+ type = "Enum8('full'=0, 'propertyless'=1, 'force_upgrade'=2)"+ }+ column "historical_migration" {+ type = "Bool"+ }+ column "dmat_string_0" {+ type = "Nullable(String)"+ }+ column "dmat_string_1" {+ type = "Nullable(String)"+ }+ column "dmat_string_2" {+ type = "Nullable(String)"+ }+ column "dmat_string_3" {+ type = "Nullable(String)"+ }+ column "dmat_string_4" {+ type = "Nullable(String)"+ }+ column "dmat_string_5" {+ type = "Nullable(String)"+ }+ column "dmat_string_6" {+ type = "Nullable(String)"+ }+ column "dmat_string_7" {+ type = "Nullable(String)"+ }+ column "dmat_string_8" {+ type = "Nullable(String)"+ }+ column "dmat_string_9" {+ type = "Nullable(String)"+ }+ engine "kafka" {+ broker_list = "msk_cluster"+ topic_list = "kafka_topic_list = 'clickhouse_events_json'"+ group_name = "kafka_group_name = 'clickhouse_events_json_native_json'"+ format = "kafka_format = 'JSONEachRow'"+ skip_broken_messages = 100+ }+ }+++ materialized_view "events_json_table_mv" {+ to_table = "posthog.writable_events_json"+ query = <<SQL+SELECT+ uuid,+ event,+ ifNull(+ accurateCastOrNull(properties, 'JSON'),+ CAST(concat('{"$unparseable_properties":', toJSONString(properties), '}'), 'JSON')+ ) AS properties,+ timestamp,+ team_id,+ distinct_id,+ elements_chain,+ created_at,+ person_id,+ person_created_at,+ ifNull(+ accurateCastOrNull(person_properties, 'JSON'),+ CAST(concat('{"$unparseable_properties":', toJSONString(person_properties), '}'), 'JSON')+ ) AS person_properties,+ group0_properties,+ group1_properties,+ group2_properties,+ group3_properties,+ group4_properties,+ group0_created_at,+ group1_created_at,+ group2_created_at,+ group3_created_at,+ group4_created_at,+ person_mode,+ historical_migration,+ _timestamp,+ _offset,+ arrayMap(+ i -> (_headers.value[i]),+ arrayFilter(+ i -> ((_headers.name[i]) = 'kafka-consumer-breadcrumbs'),+ arrayEnumerate(_headers.name)+ )+ ) AS consumer_breadcrumbs+FROM posthog.kafka_events_json_native_json+SQL++ column "uuid" {+ type = "UUID"+ }+ column "event" {+ type = "String"+ }+ column "properties" {+ type = "JSON"+ }+ column "timestamp" {+ type = "DateTime64(6, 'UTC')"+ }+ column "team_id" {+ type = "Int64"+ }+ column "distinct_id" {+ type = "String"+ }+ column "elements_chain" {+ type = "String"+ }+ column "created_at" {+ type = "DateTime64(6, 'UTC')"+ }+ column "person_id" {+ type = "UUID"+ }+ column "person_created_at" {+ type = "DateTime64(3)"+ }+ column "person_properties" {+ type = "JSON"+ }+ column "group0_properties" {+ type = "String"+ }+ column "group1_properties" {+ type = "String"+ }+ column "group2_properties" {+ type = "String"+ }+ column "group3_properties" {+ type = "String"+ }+ column "group4_properties" {+ type = "String"+ }+ column "group0_created_at" {+ type = "DateTime64(3)"+ }+ column "group1_created_at" {+ type = "DateTime64(3)"+ }+ column "group2_created_at" {+ type = "DateTime64(3)"+ }+ column "group3_created_at" {+ type = "DateTime64(3)"+ }+ column "group4_created_at" {+ type = "DateTime64(3)"+ }+ column "person_mode" {+ type = "Enum8('full'=0, 'propertyless'=1, 'force_upgrade'=2)"+ }+ column "historical_migration" {+ type = "Bool"+ }+ column "_timestamp" {+ type = "Nullable(DateTime)"+ }+ column "_offset" {+ type = "UInt64"+ }+ column "consumer_breadcrumbs" {+ type = "Array(String)"+ }+ }+}diff --git a/posthog/clickhouse/hcl/roles/ingestion_medium/local/tables.hcl b/posthog/clickhouse/hcl/roles/ingestion_medium/local/tables.hclnew file mode 100644index 000000000000..5258fe6d7810--- /dev/null+++ b/posthog/clickhouse/hcl/roles/ingestion_medium/local/tables.hcl@@ -0,0 +1,1956 @@+node "medium" {+ macros = {+ hostClusterRole = "medium"+ hostClusterType = "online"+ replica = "medium"+ shard = "01"+ }+}++database "posthog" {+ table "kafka_app_metrics2" {+ column "team_id" {+ type = "Int64"+ }+ column "timestamp" {+ type = "DateTime64(6, 'UTC')"+ }+ column "app_source" {+ type = "LowCardinality(String)"+ }+ column "app_source_id" {+ type = "String"+ }+ column "instance_id" {+ type = "String"+ }+ column "metric_kind" {+ type = "String"+ }+ column "metric_name" {+ type = "String"+ }+ column "count" {+ type = "Int64"+ }+ engine "kafka" {+ broker_list = "msk_cluster"+ topic_list = "kafka_topic_list = 'clickhouse_app_metrics2'"+ group_name = "kafka_group_name = 'group1'"+ format = "kafka_format = 'JSONEachRow'"+ }+ }++ table "kafka_app_metrics2_ws" {+ column "team_id" {+ type = "Int64"+ }+ column "timestamp" {+ type = "DateTime64(6, 'UTC')"+ }+ column "app_source" {+ type = "LowCardinality(String)"+ }+ column "app_source_id" {+ type = "String"+ }+ column "instance_id" {+ type = "String"+ }+ column "metric_kind" {+ type = "String"+ }+ column "metric_name" {+ type = "String"+ }+ column "count" {+ type = "Int64"+ }+ engine "kafka" {+ broker_list = "warpstream_ingestion"+ topic_list = "kafka_topic_list = 'clickhouse_app_metrics2'"+ group_name = "kafka_group_name = 'clickhouse_app_metrics2_ws'"+ format = "kafka_format = 'JSONEachRow'"+ }+ }++ table "kafka_cohort_membership" {+ column "team_id" {+ type = "Int64"+ }+ column "cohort_id" {+ type = "Int64"+ }+ column "person_id" {+ type = "UUID"+ }+ column "status" {+ type = "Enum8('entered'=1, 'left'=2, 'member'=3, 'not_member'=4)"+ }+ column "last_updated" {+ type = "DateTime64(6)"+ }+ engine "kafka" {+ broker_list = "msk_cluster"+ topic_list = "kafka_topic_list = 'cohort_membership_changed'"+ group_name = "kafka_group_name = 'clickhouse_cohort_membership_changed'"+ format = "kafka_format = 'JSONEachRow'"+ }+ }++ table "kafka_distinct_id_usage" {+ column "team_id" {+ type = "Int64"+ }+ column "distinct_id" {+ type = "String"+ }+ column "timestamp" {+ type = "DateTime64(6, 'UTC')"+ }+ engine "kafka" {+ broker_list = "warpstream_ingestion"+ topic_list = "kafka_topic_list = 'distinct_id_usage_events_json'"+ group_name = "kafka_group_name = 'clickhouse_distinct_id_usage'"+ format = "kafka_format = 'JSONEachRow'"+ skip_broken_messages = 100+ }+ }++ table "kafka_flag_evaluations" {+ column "uuid" {+ type = "UUID"+ }+ column "event" {+ type = "LowCardinality(String)"+ }+ column "properties" {+ type = "String"+ }+ column "timestamp" {+ type = "DateTime64(6, 'UTC')"+ }+ column "team_id" {+ type = "Int64"+ }+ column "distinct_id" {+ type = "String"+ }+ column "created_at" {+ type = "DateTime64(6, 'UTC')"+ }+ column "person_id" {+ type = "UUID"+ }+ column "person_properties" {+ type = "String"+ }+ column "group0_properties" {+ type = "String"+ }+ column "group1_properties" {+ type = "String"+ }+ column "group2_properties" {+ type = "String"+ }+ column "group3_properties" {+ type = "String"+ }+ column "group4_properties" {+ type = "String"+ }+ column "inserted_at" {+ type = "DateTime64(6, 'UTC')"+ }+ engine "kafka" {+ broker_list = "warpstream_ingestion"+ topic_list = "kafka_topic_list = 'clickhouse_flag_evaluations'"+ group_name = "kafka_group_name = 'clickhouse_flag_evaluations'"+ format = "kafka_format = 'JSONEachRow'"+ skip_broken_messages = 100+ }+ }++ table "kafka_heatmaps" {+ column "session_id" {+ type = "String"+ }+ column "team_id" {+ type = "Int64"+ }+ column "distinct_id" {+ type = "String"+ }+ column "timestamp" {+ type = "DateTime64(6, 'UTC')"+ }+ column "x" {+ type = "Int16"+ }+ column "y" {+ type = "Int16"+ }+ column "scale_factor" {+ type = "Int16"+ }+ column "viewport_width" {+ type = "Int16"+ }+ column "viewport_height" {+ type = "Int16"+ }+ column "pointer_target_fixed" {+ type = "Bool"+ }+ column "current_url" {+ type = "String"+ }+ column "type" {+ type = "LowCardinality(String)"+ }+ engine "kafka" {+ broker_list = "msk_cluster"+ topic_list = "kafka_topic_list = 'clickhouse_heatmap_events'"+ group_name = "kafka_group_name = 'group1'"+ format = "kafka_format = 'JSONEachRow'"+ }+ }++ table "kafka_precalculated_events" {+ column "team_id" {+ type = "Int64"+ }+ column "date" {+ type = "Nullable(Date)"+ }+ column "distinct_id" {+ type = "String"+ }+ column "person_id" {+ type = "UUID"+ }+ column "condition" {+ type = "String"+ }+ column "uuid" {+ type = "UUID"+ }+ column "source" {+ type = "String"+ }+ engine "kafka" {+ broker_list = "msk_cluster"+ topic_list = "kafka_topic_list = 'clickhouse_prefiltered_events'"+ group_name = "kafka_group_name = 'clickhouse_prefiltered_events'"+ format = "kafka_format = 'JSONEachRow'"+ num_consumers = 1+ max_block_size = 1000000+ skip_broken_messages = 100+ poll_timeout_ms = 1000+ poll_max_batch_size = 100000+ flush_interval_ms = 7500+ }+ }++ table "kafka_precalculated_person_properties" {+ column "team_id" {+ type = "Int64"+ }+ column "distinct_id" {+ type = "String"+ }+ column "person_id" {+ type = "UUID"+ }+ column "condition" {+ type = "String"+ }+ column "matches" {+ type = "Bool"+ }+ column "source" {+ type = "String"+ }+ engine "kafka" {+ broker_list = "msk_cluster"+ topic_list = "kafka_topic_list = 'clickhouse_precalculated_person_properties'"+ group_name = "kafka_group_name = 'clickhouse_precalculated_person_properties'"+ format = "kafka_format = 'JSONEachRow'"+ num_consumers = 1+ max_block_size = 1000000+ skip_broken_messages = 100+ poll_timeout_ms = 1000+ poll_max_batch_size = 100000+ flush_interval_ms = 7500+ }+ }++ table "kafka_precalculated_person_properties_ws" {+ column "team_id" {+ type = "Int64"+ }+ column "distinct_id" {+ type = "String"+ }+ column "person_id" {+ type = "UUID"+ }+ column "condition" {+ type = "String"+ }+ column "matches" {+ type = "Bool"+ }+ column "source" {+ type = "String"+ }+ engine "kafka" {+ broker_list = "warpstream_calculated_events"+ topic_list = "kafka_topic_list = 'clickhouse_precalculated_person_properties'"+ group_name = "kafka_group_name = 'clickhouse_precalculated_person_properties_ws'"+ format = "kafka_format = 'JSONEachRow'"+ num_consumers = 1+ max_block_size = 1000000+ skip_broken_messages = 100+ poll_timeout_ms = 1000+ poll_max_batch_size = 100000+ flush_interval_ms = 7500+ }+ }++ table "kafka_session_replay_features" {+ column "session_id" {+ type = "String"+ }+ column "team_id" {+ type = "Int64"+ }+ column "distinct_id" {+ type = "String"+ }+ column "batch_id" {+ type = "String"+ }+ column "first_timestamp" {+ type = "DateTime64(6, 'UTC')"+ }+ column "last_timestamp" {+ type = "DateTime64(6, 'UTC')"+ }+ column "event_count" {+ type = "Int64"+ }+ column "mouse_position_count" {+ type = "Int64"+ }+ column "mouse_sum_x" {+ type = "Float64"+ }+ column "mouse_sum_x_squared" {+ type = "Float64"+ }+ column "mouse_sum_y" {+ type = "Float64"+ }+ column "mouse_sum_y_squared" {+ type = "Float64"+ }+ column "mouse_distance_traveled" {+ type = "Float64"+ }+ column "mouse_direction_change_count" {+ type = "Int64"+ }+ column "mouse_velocity_sum" {+ type = "Float64"+ }+ column "mouse_velocity_sum_of_squares" {+ type = "Float64"+ }+ column "mouse_velocity_count" {+ type = "Int64"+ }+ column "scroll_event_count" {+ type = "Int64"+ }+ column "total_scroll_magnitude" {+ type = "Float64"+ }+ column "scroll_direction_reversal_count" {+ type = "Int64"+ }+ column "rapid_scroll_reversal_count" {+ type = "Int64"+ }+ column "scroll_to_top_count" {+ type = "Int64"+ }+ column "click_count" {+ type = "Int64"+ }+ column "keypress_count" {+ type = "Int64"+ }+ column "mouse_activity_count" {+ type = "Int64"+ }+ column "rage_click_count" {+ type = "Int64"+ }+ column "dead_click_count" {+ type = "Int64"+ }+ column "backspace_count" {+ type = "Int64"+ }+ column "inter_action_gap_count" {+ type = "Int64"+ }+ column "inter_action_gap_sum_ms" {+ type = "Float64"+ }+ column "inter_action_gap_sum_of_squares_ms" {+ type = "Float64"+ }+ column "max_idle_gap_ms" {+ type = "Float64"+ }+ column "long_idle_gap_count" {+ type = "Int64"+ }+ column "quick_back_count" {+ type = "Int64"+ }+ column "page_visit_count" {+ type = "Int64"+ }+ column "visited_urls" {+ type = "Array(String)"+ }+ column "login_path_visit_count" {+ type = "Int64"+ }+ column "signup_path_visit_count" {+ type = "Int64"+ }+ column "checkout_path_visit_count" {+ type = "Int64"+ }+ column "cart_path_visit_count" {+ type = "Int64"+ }+ column "billing_path_visit_count" {+ type = "Int64"+ }+ column "settings_path_visit_count" {+ type = "Int64"+ }+ column "account_path_visit_count" {+ type = "Int64"+ }+ column "error_path_visit_count" {+ type = "Int64"+ }+ column "not_found_path_visit_count" {+ type = "Int64"+ }+ column "admin_path_visit_count" {+ type = "Int64"+ }+ column "dashboard_path_visit_count" {+ type = "Int64"+ }+ column "onboarding_path_visit_count" {+ type = "Int64"+ }+ column "cancel_path_visit_count" {+ type = "Int64"+ }+ column "refund_path_visit_count" {+ type = "Int64"+ }+ column "console_error_count" {+ type = "Int64"+ }+ column "console_error_after_click_count" {+ type = "Int64"+ }+ column "console_warn_count" {+ type = "Int64"+ }+ column "network_request_count" {+ type = "Int64"+ }+ column "network_failed_request_count" {+ type = "Int64"+ }+ column "network_4xx_count" {+ type = "Int64"+ }+ column "network_5xx_count" {+ type = "Int64"+ }+ column "network_request_duration_sum" {+ type = "Float64"+ }+ column "network_request_duration_sum_of_squares" {+ type = "Float64"+ }+ column "network_request_duration_count" {+ type = "Int64"+ }+ column "mutation_count" {+ type = "Int64"+ }+ column "viewport_resize_count" {+ type = "Int64"+ }+ column "touch_event_count" {+ type = "Int64"+ }+ column "max_scroll_y" {+ type = "Float64"+ }+ column "click_target_ids" {+ type = "Array(Int64)"+ }+ column "form_field_ids" {+ type = "Array(Int64)"+ }+ column "text_selection_count" {+ type = "Int64"+ }+ column "selection_copy_count" {+ type = "Int64"+ }+ column "is_deleted" {+ type = "UInt8"+ }+ engine "kafka" {+ broker_list = "msk_cluster"+ topic_list = "kafka_topic_list = 'clickhouse_session_replay_features'"+ group_name = "kafka_group_name = 'group1'"+ format = "kafka_format = 'JSONEachRow'"+ }+ }++ table "kafka_tophog" {+ settings = {+ date_time_input_format = "best_effort"+ }+ column "timestamp" {+ type = "DateTime64(6, 'UTC')"+ }+ column "metric" {+ type = "LowCardinality(String)"+ }+ column "type" {+ type = "LowCardinality(String)"+ }+ column "key" {+ type = "Map(LowCardinality(String), String)"+ }+ column "value" {+ type = "Float64"+ }+ column "count" {+ type = "UInt64"+ }+ column "pipeline" {+ type = "LowCardinality(String)"+ }+ column "lane" {+ type = "LowCardinality(String)"+ }+ column "labels" {+ type = "Map(LowCardinality(String), String)"+ }+ engine "kafka" {+ broker_list = "msk_cluster"+ topic_list = "kafka_topic_list = 'clickhouse_tophog'"+ group_name = "kafka_group_name = 'clickhouse_tophog'"+ format = "kafka_format = 'JSONEachRow'"+ skip_broken_messages = 100+ }+ }++ table "kafka_tophog_ws" {+ settings = {+ date_time_input_format = "best_effort"+ }+ column "timestamp" {+ type = "DateTime64(6, 'UTC')"+ }+ column "metric" {+ type = "LowCardinality(String)"+ }+ column "type" {+ type = "LowCardinality(String)"+ }+ column "key" {+ type = "Map(LowCardinality(String), String)"+ }+ column "value" {+ type = "Float64"+ }+ column "count" {+ type = "UInt64"+ }+ column "pipeline" {+ type = "LowCardinality(String)"+ }+ column "lane" {+ type = "LowCardinality(String)"+ }+ column "labels" {+ type = "Map(LowCardinality(String), String)"+ }+ engine "kafka" {+ broker_list = "warpstream_ingestion"+ topic_list = "kafka_topic_list = 'clickhouse_tophog'"+ group_name = "kafka_group_name = 'clickhouse_tophog_ws'"+ format = "kafka_format = 'JSONEachRow'"+ skip_broken_messages = 100+ }+ }++ table "writable_app_metrics2" {+ column "team_id" {+ type = "Int64"+ }+ column "timestamp" {+ type = "DateTime64(6, 'UTC')"+ }+ column "app_source" {+ type = "LowCardinality(String)"+ }+ column "app_source_id" {+ type = "String"+ }+ column "instance_id" {+ type = "String"+ }+ column "metric_kind" {+ type = "LowCardinality(String)"+ }+ column "metric_name" {+ type = "LowCardinality(String)"+ }+ column "count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "_timestamp" {+ type = "DateTime"+ }+ column "_offset" {+ type = "UInt64"+ }+ column "_partition" {+ type = "UInt64"+ }+ engine "distributed" {+ cluster_name = "posthog"+ remote_database = "posthog"+ remote_table = "sharded_app_metrics2"+ sharding_key = "rand()"+ }+ }++ table "writable_cohort_membership" {+ column "team_id" {+ type = "Int64"+ }+ column "cohort_id" {+ type = "Int64"+ }+ column "person_id" {+ type = "UUID"+ }+ column "status" {+ type = "Enum8('entered'=1, 'left'=2)"+ }+ column "last_updated" {+ type = "DateTime64(6)"+ default = "now64()"+ }+ engine "distributed" {+ cluster_name = "posthog_single_shard"+ remote_database = "posthog"+ remote_table = "cohort_membership"+ }+ }++ table "writable_distinct_id_usage" {+ column "team_id" {+ type = "Int64"+ }+ column "distinct_id" {+ type = "String"+ }+ column "minute" {+ type = "DateTime"+ }+ column "event_count" {+ type = "UInt64"+ }+ engine "distributed" {+ cluster_name = "posthog"+ remote_database = "posthog"+ remote_table = "sharded_distinct_id_usage"+ sharding_key = "sipHash64(distinct_id)"+ }+ }++ table "writable_flag_evaluations" {+ column "uuid" {+ type = "UUID"+ }+ column "event" {+ type = "LowCardinality(String)"+ }+ column "properties" {+ type = "String"+ }+ column "timestamp" {+ type = "DateTime64(6, 'UTC')"+ }+ column "team_id" {+ type = "Int64"+ }+ column "distinct_id" {+ type = "String"+ }+ column "created_at" {+ type = "DateTime64(6, 'UTC')"+ }+ column "person_id" {+ type = "UUID"+ }+ column "person_properties" {+ type = "String"+ }+ column "group0_properties" {+ type = "String"+ }+ column "group1_properties" {+ type = "String"+ }+ column "group2_properties" {+ type = "String"+ }+ column "group3_properties" {+ type = "String"+ }+ column "group4_properties" {+ type = "String"+ }+ column "inserted_at" {+ type = "DateTime64(6, 'UTC')"+ default = "timestamp"+ }+ column "_timestamp" {+ type = "DateTime"+ }+ column "_offset" {+ type = "UInt64"+ }+ column "_partition" {+ type = "UInt64"+ }+ engine "distributed" {+ cluster_name = "posthog"+ remote_database = "posthog"+ remote_table = "sharded_flag_evaluations"+ sharding_key = "sipHash64(distinct_id)"+ }+ }++ table "writable_heatmaps" {+ column "session_id" {+ type = "String"+ }+ column "team_id" {+ type = "Int64"+ }+ column "distinct_id" {+ type = "String"+ }+ column "timestamp" {+ type = "DateTime64(6, 'UTC')"+ }+ column "x" {+ type = "Int16"+ }+ column "y" {+ type = "Int16"+ }+ column "scale_factor" {+ type = "Int16"+ }+ column "viewport_width" {+ type = "Int16"+ }+ column "viewport_height" {+ type = "Int16"+ }+ column "pointer_target_fixed" {+ type = "Bool"+ }+ column "current_url" {+ type = "String"+ }+ column "type" {+ type = "LowCardinality(String)"+ }+ column "_timestamp" {+ type = "DateTime"+ }+ column "_offset" {+ type = "UInt64"+ }+ column "_partition" {+ type = "UInt64"+ }+ engine "distributed" {+ cluster_name = "posthog"+ remote_database = "posthog"+ remote_table = "sharded_heatmaps"+ sharding_key = "cityHash64(concat(toString(team_id), '-', session_id, '-', toString(toDate(timestamp))))"+ }+ }++ table "writable_precalculated_events" {+ column "team_id" {+ type = "Int64"+ }+ column "date" {+ type = "Date"+ }+ column "distinct_id" {+ type = "String"+ }+ column "person_id" {+ type = "UUID"+ }+ column "condition" {+ type = "String"+ }+ column "uuid" {+ type = "UUID"+ }+ column "source" {+ type = "String"+ }+ column "_timestamp" {+ type = "DateTime64(6)"+ }+ column "_partition" {+ type = "UInt64"+ }+ column "_offset" {+ type = "UInt64"+ }+ engine "distributed" {+ cluster_name = "posthog"+ remote_database = "posthog"+ remote_table = "sharded_precalculated_events"+ sharding_key = "sipHash64(distinct_id)"+ }+ }++ table "writable_precalculated_person_properties" {+ column "team_id" {+ type = "Int64"+ }+ column "distinct_id" {+ type = "String"+ }+ column "person_id" {+ type = "UUID"+ }+ column "condition" {+ type = "String"+ }+ column "matches" {+ type = "Bool"+ }+ column "source" {+ type = "String"+ }+ column "_timestamp" {+ type = "DateTime64(6)"+ }+ column "_offset" {+ type = "UInt64"+ }+ engine "distributed" {+ cluster_name = "posthog"+ remote_database = "posthog"+ remote_table = "sharded_precalculated_person_properties"+ sharding_key = "sipHash64(distinct_id)"+ }+ }++ table "writable_session_replay_features" {+ column "session_id" {+ type = "String"+ }+ column "team_id" {+ type = "Int64"+ }+ column "distinct_id" {+ type = "String"+ }+ column "min_first_timestamp" {+ type = "SimpleAggregateFunction(min, DateTime64(6, 'UTC'))"+ }+ column "max_last_timestamp" {+ type = "SimpleAggregateFunction(max, DateTime64(6, 'UTC'))"+ }+ column "event_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "mouse_position_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "mouse_sum_x" {+ type = "SimpleAggregateFunction(sum, Float64)"+ }+ column "mouse_sum_x_squared" {+ type = "SimpleAggregateFunction(sum, Float64)"+ }+ column "mouse_sum_y" {+ type = "SimpleAggregateFunction(sum, Float64)"+ }+ column "mouse_sum_y_squared" {+ type = "SimpleAggregateFunction(sum, Float64)"+ }+ column "mouse_distance_traveled" {+ type = "SimpleAggregateFunction(sum, Float64)"+ }+ column "mouse_direction_change_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "mouse_velocity_sum" {+ type = "SimpleAggregateFunction(sum, Float64)"+ }+ column "mouse_velocity_sum_of_squares" {+ type = "SimpleAggregateFunction(sum, Float64)"+ }+ column "mouse_velocity_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "scroll_event_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "total_scroll_magnitude" {+ type = "SimpleAggregateFunction(sum, Float64)"+ }+ column "scroll_direction_reversal_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "rapid_scroll_reversal_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "scroll_to_top_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "click_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "keypress_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "mouse_activity_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "rage_click_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "dead_click_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "backspace_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "inter_action_gap_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "inter_action_gap_sum_ms" {+ type = "SimpleAggregateFunction(sum, Float64)"+ }+ column "inter_action_gap_sum_of_squares_ms" {+ type = "SimpleAggregateFunction(sum, Float64)"+ }+ column "max_idle_gap_ms" {+ type = "SimpleAggregateFunction(max, Float64)"+ }+ column "long_idle_gap_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "quick_back_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "page_visit_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "unique_url_count" {+ type = "AggregateFunction(uniqCombined(12), String)"+ }+ column "login_path_visit_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "signup_path_visit_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "checkout_path_visit_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "cart_path_visit_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "billing_path_visit_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "settings_path_visit_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "account_path_visit_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "error_path_visit_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "not_found_path_visit_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "admin_path_visit_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "dashboard_path_visit_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "onboarding_path_visit_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "cancel_path_visit_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "refund_path_visit_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "console_error_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "console_error_after_click_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "console_warn_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "network_request_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "network_failed_request_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "network_4xx_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "network_5xx_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "network_request_duration_sum" {+ type = "SimpleAggregateFunction(sum, Float64)"+ }+ column "network_request_duration_sum_of_squares" {+ type = "SimpleAggregateFunction(sum, Float64)"+ }+ column "network_request_duration_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "mutation_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "viewport_resize_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "touch_event_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "max_scroll_y" {+ type = "SimpleAggregateFunction(max, Float64)"+ }+ column "unique_click_target_count" {+ type = "AggregateFunction(uniqCombined(12), Int64)"+ }+ column "unique_form_field_count" {+ type = "AggregateFunction(uniqCombined(12), Int64)"+ }+ column "text_selection_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "selection_copy_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "is_deleted" {+ type = "SimpleAggregateFunction(max, UInt8)"+ default = "0"+ }+ engine "distributed" {+ cluster_name = "aux"+ remote_database = "posthog"+ remote_table = "sharded_session_replay_features"+ sharding_key = "sipHash64(session_id)"+ }+ }++ table "writable_tophog" {+ column "timestamp" {+ type = "DateTime64(6, 'UTC')"+ }+ column "metric" {+ type = "LowCardinality(String)"+ }+ column "type" {+ type = "LowCardinality(String)"+ default = "'sum'"+ }+ column "key" {+ type = "Map(LowCardinality(String), String)"+ }+ column "value" {+ type = "Float64"+ }+ column "count" {+ type = "UInt64"+ default = "0"+ }+ column "pipeline" {+ type = "LowCardinality(String)"+ }+ column "lane" {+ type = "LowCardinality(String)"+ }+ column "labels" {+ type = "Map(LowCardinality(String), String)"+ }+ engine "distributed" {+ cluster_name = "posthog"+ remote_database = "posthog"+ remote_table = "sharded_tophog"+ sharding_key = "cityHash64(toString(key))"+ }+ }++ materialized_view "app_metrics2_mv" {+ to_table = "posthog.writable_app_metrics2"+ query = <<SQL+SELECT+ team_id,+ timestamp,+ app_source,+ app_source_id,+ instance_id,+ metric_kind,+ metric_name,+ count,+ _timestamp,+ _offset,+ _partition+FROM posthog.kafka_app_metrics2+SQL++ column "team_id" {+ type = "Int64"+ }+ column "timestamp" {+ type = "DateTime64(6, 'UTC')"+ }+ column "app_source" {+ type = "LowCardinality(String)"+ }+ column "app_source_id" {+ type = "String"+ }+ column "instance_id" {+ type = "String"+ }+ column "metric_kind" {+ type = "String"+ }+ column "metric_name" {+ type = "String"+ }+ column "count" {+ type = "Int64"+ }+ column "_timestamp" {+ type = "Nullable(DateTime)"+ }+ column "_offset" {+ type = "UInt64"+ }+ column "_partition" {+ type = "UInt64"+ }+ }++ materialized_view "app_metrics2_ws_mv" {+ to_table = "posthog.writable_app_metrics2"+ query = <<SQL+SELECT+ team_id,+ timestamp,+ app_source,+ app_source_id,+ instance_id,+ metric_kind,+ metric_name,+ count,+ _timestamp,+ _offset,+ _partition+FROM posthog.kafka_app_metrics2_ws+SQL++ column "team_id" {+ type = "Int64"+ }+ column "timestamp" {+ type = "DateTime64(6, 'UTC')"+ }+ column "app_source" {+ type = "LowCardinality(String)"+ }+ column "app_source_id" {+ type = "String"+ }+ column "instance_id" {+ type = "String"+ }+ column "metric_kind" {+ type = "String"+ }+ column "metric_name" {+ type = "String"+ }+ column "count" {+ type = "Int64"+ }+ column "_timestamp" {+ type = "Nullable(DateTime)"+ }+ column "_offset" {+ type = "UInt64"+ }+ column "_partition" {+ type = "UInt64"+ }+ }++ materialized_view "cohort_membership_mv" {+ to_table = "posthog.writable_cohort_membership"+ query = <<SQL+SELECT+ team_id,+ cohort_id,+ person_id,+ multiIf(status = 'member', 'entered', status = 'not_member', 'left', status) AS status,+ last_updated+FROM posthog.kafka_cohort_membership+SQL++ column "team_id" {+ type = "Int64"+ }+ column "cohort_id" {+ type = "Int64"+ }+ column "person_id" {+ type = "UUID"+ }+ column "status" {+ type = "String"+ }+ column "last_updated" {+ type = "DateTime64(6)"+ }+ }++ materialized_view "distinct_id_usage_mv" {+ to_table = "posthog.writable_distinct_id_usage"+ query = <<SQL+SELECT team_id, distinct_id, toStartOfMinute(timestamp) AS minute, 1 AS event_count+FROM posthog.kafka_distinct_id_usage+SQL++ column "team_id" {+ type = "Int64"+ }+ column "distinct_id" {+ type = "String"+ }+ column "minute" {+ type = "DateTime('UTC')"+ }+ column "event_count" {+ type = "UInt8"+ }+ }++ materialized_view "flag_evaluations_mv" {+ to_table = "posthog.writable_flag_evaluations"+ query = <<SQL+SELECT+ uuid,+ event,+ properties,+ timestamp,+ team_id,+ distinct_id,+ created_at,+ person_id,+ person_properties,+ group0_properties,+ group1_properties,+ group2_properties,+ group3_properties,+ group4_properties,+ if(inserted_at = toDateTime64('1970-01-01 00:00:00', 6, 'UTC'), _timestamp, inserted_at) AS inserted_at,+ _timestamp,+ _offset,+ _partition+FROM posthog.kafka_flag_evaluations+SQL++ column "uuid" {+ type = "UUID"+ }+ column "event" {+ type = "LowCardinality(String)"+ }+ column "properties" {+ type = "String"+ }+ column "timestamp" {+ type = "DateTime64(6, 'UTC')"+ }+ column "team_id" {+ type = "Int64"+ }+ column "distinct_id" {+ type = "String"+ }+ column "created_at" {+ type = "DateTime64(6, 'UTC')"+ }+ column "person_id" {+ type = "UUID"+ }+ column "person_properties" {+ type = "String"+ }+ column "group0_properties" {+ type = "String"+ }+ column "group1_properties" {+ type = "String"+ }+ column "group2_properties" {+ type = "String"+ }+ column "group3_properties" {+ type = "String"+ }+ column "group4_properties" {+ type = "String"+ }+ column "inserted_at" {+ type = "Nullable(DateTime64(6, 'UTC'))"+ }+ column "_timestamp" {+ type = "Nullable(DateTime)"+ }+ column "_offset" {+ type = "UInt64"+ }+ column "_partition" {+ type = "UInt64"+ }+ }++ materialized_view "heatmaps_mv" {+ to_table = "posthog.writable_heatmaps"+ query = <<SQL+SELECT+ session_id,+ team_id,+ distinct_id,+ timestamp,+ x,+ y,+ scale_factor,+ viewport_width,+ viewport_height,+ pointer_target_fixed,+ current_url,+ type,+ _timestamp,+ _offset,+ _partition+FROM posthog.kafka_heatmaps+SQL++ column "session_id" {+ type = "String"+ }+ column "team_id" {+ type = "Int64"+ }+ column "distinct_id" {+ type = "String"+ }+ column "timestamp" {+ type = "DateTime64(6, 'UTC')"+ }+ column "x" {+ type = "Int16"+ }+ column "y" {+ type = "Int16"+ }+ column "scale_factor" {+ type = "Int16"+ }+ column "viewport_width" {+ type = "Int16"+ }+ column "viewport_height" {+ type = "Int16"+ }+ column "pointer_target_fixed" {+ type = "Bool"+ }+ column "current_url" {+ type = "String"+ }+ column "type" {+ type = "LowCardinality(String)"+ }+ column "_timestamp" {+ type = "Nullable(DateTime)"+ }+ column "_offset" {+ type = "UInt64"+ }+ column "_partition" {+ type = "UInt64"+ }+ }++ materialized_view "precalculated_events_mv" {+ to_table = "posthog.writable_precalculated_events"+ query = <<SQL+SELECT+ team_id,+ ifNull(date, toDate(_timestamp)) AS date,+ distinct_id,+ person_id,+ condition,+ uuid,+ source,+ _timestamp,+ _offset,+ _partition+FROM posthog.kafka_precalculated_events+SQL++ column "team_id" {+ type = "Int64"+ }+ column "date" {+ type = "Nullable(Date)"+ }+ column "distinct_id" {+ type = "String"+ }+ column "person_id" {+ type = "UUID"+ }+ column "condition" {+ type = "String"+ }+ column "uuid" {+ type = "UUID"+ }+ column "source" {+ type = "String"+ }+ column "_timestamp" {+ type = "Nullable(DateTime)"+ }+ column "_offset" {+ type = "UInt64"+ }+ column "_partition" {+ type = "UInt64"+ }+ }++ materialized_view "precalculated_person_properties_mv" {+ to_table = "posthog.writable_precalculated_person_properties"+ query = <<SQL+SELECT+ team_id,+ distinct_id,+ person_id,+ condition,+ matches,+ source,+ _timestamp,+ _offset+FROM posthog.kafka_precalculated_person_properties+SQL++ column "team_id" {+ type = "Int64"+ }+ column "distinct_id" {+ type = "String"+ }+ column "person_id" {+ type = "UUID"+ }+ column "condition" {+ type = "String"+ }+ column "matches" {+ type = "Bool"+ }+ column "source" {+ type = "String"+ }+ column "_timestamp" {+ type = "Nullable(DateTime)"+ }+ column "_offset" {+ type = "UInt64"+ }+ }++ materialized_view "precalculated_person_properties_ws_mv" {+ to_table = "posthog.writable_precalculated_person_properties"+ query = <<SQL+SELECT+ team_id,+ distinct_id,+ person_id,+ condition,+ matches,+ source,+ _timestamp,+ _offset+FROM posthog.kafka_precalculated_person_properties_ws+SQL++ column "team_id" {+ type = "Int64"+ }+ column "distinct_id" {+ type = "String"+ }+ column "person_id" {+ type = "UUID"+ }+ column "condition" {+ type = "String"+ }+ column "matches" {+ type = "Bool"+ }+ column "source" {+ type = "String"+ }+ column "_timestamp" {+ type = "Nullable(DateTime)"+ }+ column "_offset" {+ type = "UInt64"+ }+ }++ materialized_view "session_replay_features_mv" {+ to_table = "posthog.writable_session_replay_features"+ query = <<SQL+SELECT+ session_id,+ team_id,+ any(distinct_id) AS distinct_id,+ min(first_timestamp) AS min_first_timestamp,+ max(last_timestamp) AS max_last_timestamp,+ sum(event_count) AS event_count,+ sum(mouse_position_count) AS mouse_position_count,+ sum(mouse_sum_x) AS mouse_sum_x,+ sum(mouse_sum_x_squared) AS mouse_sum_x_squared,+ sum(mouse_sum_y) AS mouse_sum_y,+ sum(mouse_sum_y_squared) AS mouse_sum_y_squared,+ sum(mouse_distance_traveled) AS mouse_distance_traveled,+ sum(mouse_direction_change_count) AS mouse_direction_change_count,+ sum(mouse_velocity_sum) AS mouse_velocity_sum,+ sum(mouse_velocity_sum_of_squares) AS mouse_velocity_sum_of_squares,+ sum(mouse_velocity_count) AS mouse_velocity_count,+ sum(scroll_event_count) AS scroll_event_count,+ sum(total_scroll_magnitude) AS total_scroll_magnitude,+ sum(scroll_direction_reversal_count) AS scroll_direction_reversal_count,+ sum(rapid_scroll_reversal_count) AS rapid_scroll_reversal_count,+ sum(scroll_to_top_count) AS scroll_to_top_count,+ sum(click_count) AS click_count,+ sum(keypress_count) AS keypress_count,+ sum(mouse_activity_count) AS mouse_activity_count,+ sum(rage_click_count) AS rage_click_count,+ sum(dead_click_count) AS dead_click_count,+ sum(backspace_count) AS backspace_count,+ sum(inter_action_gap_count) AS inter_action_gap_count,+ sum(inter_action_gap_sum_ms) AS inter_action_gap_sum_ms,+ sum(inter_action_gap_sum_of_squares_ms) AS inter_action_gap_sum_of_squares_ms,+ max(max_idle_gap_ms) AS max_idle_gap_ms,+ sum(long_idle_gap_count) AS long_idle_gap_count,+ sum(quick_back_count) AS quick_back_count,+ sum(page_visit_count) AS page_visit_count,+ uniqCombinedArrayState(12)(visited_urls) AS unique_url_count,+ sum(login_path_visit_count) AS login_path_visit_count,+ sum(signup_path_visit_count) AS signup_path_visit_count,+ sum(checkout_path_visit_count) AS checkout_path_visit_count,+ sum(cart_path_visit_count) AS cart_path_visit_count,+ sum(billing_path_visit_count) AS billing_path_visit_count,+ sum(settings_path_visit_count) AS settings_path_visit_count,+ sum(account_path_visit_count) AS account_path_visit_count,+ sum(error_path_visit_count) AS error_path_visit_count,+ sum(not_found_path_visit_count) AS not_found_path_visit_count,+ sum(admin_path_visit_count) AS admin_path_visit_count,+ sum(dashboard_path_visit_count) AS dashboard_path_visit_count,+ sum(onboarding_path_visit_count) AS onboarding_path_visit_count,+ sum(cancel_path_visit_count) AS cancel_path_visit_count,+ sum(refund_path_visit_count) AS refund_path_visit_count,+ sum(console_error_count) AS console_error_count,+ sum(console_error_after_click_count) AS console_error_after_click_count,+ sum(console_warn_count) AS console_warn_count,+ sum(network_request_count) AS network_request_count,+ sum(network_failed_request_count) AS network_failed_request_count,+ sum(network_4xx_count) AS network_4xx_count,+ sum(network_5xx_count) AS network_5xx_count,+ sum(network_request_duration_sum) AS network_request_duration_sum,+ sum(network_request_duration_sum_of_squares) AS network_request_duration_sum_of_squares,+ sum(network_request_duration_count) AS network_request_duration_count,+ sum(mutation_count) AS mutation_count,+ sum(viewport_resize_count) AS viewport_resize_count,+ sum(touch_event_count) AS touch_event_count,+ max(max_scroll_y) AS max_scroll_y,+ uniqCombinedArrayState(12)(click_target_ids) AS unique_click_target_count,+ uniqCombinedArrayState(12)(form_field_ids) AS unique_form_field_count,+ sum(text_selection_count) AS text_selection_count,+ sum(selection_copy_count) AS selection_copy_count,+ max(is_deleted) AS is_deleted+FROM posthog.kafka_session_replay_features+GROUP BY+ session_id, team_id+SQL++ column "session_id" {+ type = "String"+ }+ column "team_id" {+ type = "Int64"+ }+ column "distinct_id" {+ type = "String"+ }+ column "min_first_timestamp" {+ type = "DateTime64(6, 'UTC')"+ }+ column "max_last_timestamp" {+ type = "DateTime64(6, 'UTC')"+ }+ column "event_count" {+ type = "Int64"+ }+ column "mouse_position_count" {+ type = "Int64"+ }+ column "mouse_sum_x" {+ type = "Float64"+ }+ column "mouse_sum_x_squared" {+ type = "Float64"+ }+ column "mouse_sum_y" {+ type = "Float64"+ }+ column "mouse_sum_y_squared" {+ type = "Float64"+ }+ column "mouse_distance_traveled" {+ type = "Float64"+ }+ column "mouse_direction_change_count" {+ type = "Int64"+ }+ column "mouse_velocity_sum" {+ type = "Float64"+ }+ column "mouse_velocity_sum_of_squares" {+ type = "Float64"+ }+ column "mouse_velocity_count" {+ type = "Int64"+ }+ column "scroll_event_count" {+ type = "Int64"+ }+ column "total_scroll_magnitude" {+ type = "Float64"+ }+ column "scroll_direction_reversal_count" {+ type = "Int64"+ }+ column "rapid_scroll_reversal_count" {+ type = "Int64"+ }+ column "scroll_to_top_count" {+ type = "Int64"+ }+ column "click_count" {+ type = "Int64"+ }+ column "keypress_count" {+ type = "Int64"+ }+ column "mouse_activity_count" {+ type = "Int64"+ }+ column "rage_click_count" {+ type = "Int64"+ }+ column "dead_click_count" {+ type = "Int64"+ }+ column "backspace_count" {+ type = "Int64"+ }+ column "inter_action_gap_count" {+ type = "Int64"+ }+ column "inter_action_gap_sum_ms" {+ type = "Float64"+ }+ column "inter_action_gap_sum_of_squares_ms" {+ type = "Float64"+ }+ column "max_idle_gap_ms" {+ type = "Float64"+ }+ column "long_idle_gap_count" {+ type = "Int64"+ }+ column "quick_back_count" {+ type = "Int64"+ }+ column "page_visit_count" {+ type = "Int64"+ }+ column "unique_url_count" {+ type = "AggregateFunction(uniqCombinedArray(12), Array(String))"+ }+ column "login_path_visit_count" {+ type = "Int64"+ }+ column "signup_path_visit_count" {+ type = "Int64"+ }+ column "checkout_path_visit_count" {+ type = "Int64"+ }+ column "cart_path_visit_count" {+ type = "Int64"+ }+ column "billing_path_visit_count" {+ type = "Int64"+ }+ column "settings_path_visit_count" {+ type = "Int64"+ }+ column "account_path_visit_count" {+ type = "Int64"+ }+ column "error_path_visit_count" {+ type = "Int64"+ }+ column "not_found_path_visit_count" {+ type = "Int64"+ }+ column "admin_path_visit_count" {+ type = "Int64"+ }+ column "dashboard_path_visit_count" {+ type = "Int64"+ }+ column "onboarding_path_visit_count" {+ type = "Int64"+ }+ column "cancel_path_visit_count" {+ type = "Int64"+ }+ column "refund_path_visit_count" {+ type = "Int64"+ }+ column "console_error_count" {+ type = "Int64"+ }+ column "console_error_after_click_count" {+ type = "Int64"+ }+ column "console_warn_count" {+ type = "Int64"+ }+ column "network_request_count" {+ type = "Int64"+ }+ column "network_failed_request_count" {+ type = "Int64"+ }+ column "network_4xx_count" {+ type = "Int64"+ }+ column "network_5xx_count" {+ type = "Int64"+ }+ column "network_request_duration_sum" {+ type = "Float64"+ }+ column "network_request_duration_sum_of_squares" {+ type = "Float64"+ }+ column "network_request_duration_count" {+ type = "Int64"+ }+ column "mutation_count" {+ type = "Int64"+ }+ column "viewport_resize_count" {+ type = "Int64"+ }+ column "touch_event_count" {+ type = "Int64"+ }+ column "max_scroll_y" {+ type = "Float64"+ }+ column "unique_click_target_count" {+ type = "AggregateFunction(uniqCombinedArray(12), Array(Int64))"+ }+ column "unique_form_field_count" {+ type = "AggregateFunction(uniqCombinedArray(12), Array(Int64))"+ }+ column "text_selection_count" {+ type = "Int64"+ }+ column "selection_copy_count" {+ type = "Int64"+ }+ column "is_deleted" {+ type = "UInt8"+ }+ }++ materialized_view "tophog_mv" {+ to_table = "posthog.writable_tophog"+ query = <<SQL+SELECT+ timestamp,+ metric,+ type,+ key,+ value,+ count,+ pipeline,+ lane,+ labels+FROM posthog.kafka_tophog+SQL++ column "timestamp" {+ type = "DateTime64(6, 'UTC')"+ }+ column "metric" {+ type = "LowCardinality(String)"+ }+ column "type" {+ type = "LowCardinality(String)"+ }+ column "key" {+ type = "Map(LowCardinality(String), String)"+ }+ column "value" {+ type = "Float64"+ }+ column "count" {+ type = "UInt64"+ }+ column "pipeline" {+ type = "LowCardinality(String)"+ }+ column "lane" {+ type = "LowCardinality(String)"+ }+ column "labels" {+ type = "Map(LowCardinality(String), String)"+ }+ }++ materialized_view "tophog_ws_mv" {+ to_table = "posthog.writable_tophog"+ query = <<SQL+SELECT+ timestamp,+ metric,+ type,+ key,+ value,+ count,+ pipeline,+ lane,+ labels+FROM posthog.kafka_tophog_ws+SQL++ column "timestamp" {+ type = "DateTime64(6, 'UTC')"+ }+ column "metric" {+ type = "LowCardinality(String)"+ }+ column "type" {+ type = "LowCardinality(String)"+ }+ column "key" {+ type = "Map(LowCardinality(String), String)"+ }+ column "value" {+ type = "Float64"+ }+ column "count" {+ type = "UInt64"+ }+ column "pipeline" {+ type = "LowCardinality(String)"+ }+ column "lane" {+ type = "LowCardinality(String)"+ }+ column "labels" {+ type = "Map(LowCardinality(String), String)"+ }+ }+}diff --git a/posthog/clickhouse/hcl/roles/ingestion_small/local/tables.hcl b/posthog/clickhouse/hcl/roles/ingestion_small/local/tables.hclnew file mode 100644index 000000000000..ffd7ff26ca57--- /dev/null+++ b/posthog/clickhouse/hcl/roles/ingestion_small/local/tables.hcl@@ -0,0 +1,2107 @@+node "small" {+ macros = {+ hostClusterRole = "small"+ hostClusterType = "online"+ replica = "small"+ shard = "01"+ }+}++database "posthog" {+ table "kafka_app_metrics" {+ column "team_id" {+ type = "Int64"+ }+ column "timestamp" {+ type = "DateTime64(6, 'UTC')"+ }+ column "plugin_config_id" {+ type = "Int64"+ }+ column "category" {+ type = "LowCardinality(String)"+ }+ column "job_id" {+ type = "String"+ }+ column "successes" {+ type = "Int64"+ }+ column "successes_on_retry" {+ type = "Int64"+ }+ column "failures" {+ type = "Int64"+ }+ column "error_uuid" {+ type = "UUID"+ }+ column "error_type" {+ type = "String"+ }+ column "error_details" {+ type = "String"+ codec = "ZSTD(3)"+ }+ engine "kafka" {+ broker_list = "msk_cluster"+ topic_list = "kafka_topic_list = 'clickhouse_app_metrics'"+ group_name = "kafka_group_name = 'group1'"+ format = "kafka_format = 'JSONEachRow'"+ }+ }++ table "kafka_duplicate_events" {+ column "team_id" {+ type = "Int64"+ }+ column "distinct_id" {+ type = "String"+ }+ column "event" {+ type = "String"+ }+ column "source_uuid" {+ type = "UUID"+ }+ column "duplicate_uuid" {+ type = "UUID"+ }+ column "similarity_score" {+ type = "Float64"+ }+ column "dedup_type" {+ type = "LowCardinality(String)"+ }+ column "is_confirmed" {+ type = "UInt8"+ }+ column "reason" {+ type = "Nullable(String)"+ }+ column "version" {+ type = "String"+ }+ column "different_property_count" {+ type = "UInt32"+ }+ column "properties_similarity" {+ type = "Float64"+ }+ column "source_message" {+ type = "String"+ }+ column "duplicate_message" {+ type = "String"+ }+ column "distinct_fields" {+ type = "String"+ }+ column "inserted_at" {+ type = "DateTime64(3, 'UTC')"+ }+ engine "kafka" {+ broker_list = "msk_cluster"+ topic_list = "kafka_topic_list = 'clickhouse_ingestion_events_duplicates'"+ group_name = "kafka_group_name = 'clickhouse_duplicate_events'"+ format = "kafka_format = 'JSONEachRow'"+ }+ }++ table "kafka_error_tracking_issue_fingerprint_embeddings" {+ column "team_id" {+ type = "Int64"+ }+ column "model_name" {+ type = "LowCardinality(String)"+ }+ column "embedding_version" {+ type = "Int64"+ }+ column "fingerprint" {+ type = "String"+ }+ column "inserted_at" {+ type = "DateTime64(3, 'UTC')"+ }+ column "embeddings" {+ type = "Array(Float64)"+ }+ engine "kafka" {+ broker_list = "msk_cluster"+ topic_list = "kafka_topic_list = 'clickhouse_error_tracking_issue_fingerprint_embeddings'"+ group_name = "kafka_group_name = 'clickhouse_error_tracking_fingerprint_embeddings'"+ format = "kafka_format = 'JSONEachRow'"+ }+ }++ table "kafka_error_tracking_issue_fingerprint_overrides" {+ column "team_id" {+ type = "Int64"+ }+ column "fingerprint" {+ type = "String"+ }+ column "issue_id" {+ type = "UUID"+ }+ column "is_deleted" {+ type = "Int8"+ }+ column "version" {+ type = "Int64"+ }+ engine "kafka" {+ broker_list = "msk_cluster"+ topic_list = "kafka_topic_list = 'clickhouse_error_tracking_issue_fingerprint'"+ group_name = "kafka_group_name = 'clickhouse-error-tracking-issue-fingerprint-overrides'"+ format = "kafka_format = 'JSONEachRow'"+ }+ }++ table "kafka_events_dead_letter_queue" {+ column "id" {+ type = "UUID"+ }+ column "event_uuid" {+ type = "UUID"+ }+ column "event" {+ type = "String"+ }+ column "properties" {+ type = "String"+ }+ column "distinct_id" {+ type = "String"+ }+ column "team_id" {+ type = "Int64"+ }+ column "elements_chain" {+ type = "String"+ }+ column "created_at" {+ type = "DateTime64(6, 'UTC')"+ }+ column "ip" {+ type = "String"+ }+ column "site_url" {+ type = "String"+ }+ column "now" {+ type = "DateTime64(6, 'UTC')"+ }+ column "raw_payload" {+ type = "String"+ }+ column "error_timestamp" {+ type = "DateTime64(6, 'UTC')"+ }+ column "error_location" {+ type = "String"+ }+ column "error" {+ type = "String"+ }+ column "tags" {+ type = "Array(String)"+ }+ engine "kafka" {+ broker_list = "msk_cluster"+ topic_list = "kafka_topic_list = 'events_dead_letter_queue'"+ group_name = "kafka_group_name = 'group1'"+ format = "kafka_format = 'JSONEachRow'"+ skip_broken_messages = 1000+ }+ }++ table "kafka_groups" {+ column "group_type_index" {+ type = "UInt8"+ }+ column "group_key" {+ type = "String"+ }+ column "created_at" {+ type = "DateTime64(3)"+ }+ column "team_id" {+ type = "Int64"+ }+ column "group_properties" {+ type = "String"+ }+ engine "kafka" {+ broker_list = "msk_cluster"+ topic_list = "kafka_topic_list = 'clickhouse_groups'"+ group_name = "kafka_group_name = 'group1'"+ format = "kafka_format = 'JSONEachRow'"+ }+ }++ table "kafka_ingestion_warnings" {+ column "team_id" {+ type = "Int64"+ }+ column "source" {+ type = "LowCardinality(String)"+ }+ column "type" {+ type = "String"+ }+ column "details" {+ type = "String"+ codec = "ZSTD(3)"+ }+ column "timestamp" {+ type = "DateTime64(6, 'UTC')"+ }+ engine "kafka" {+ broker_list = "msk_cluster"+ topic_list = "kafka_topic_list = 'clickhouse_ingestion_warnings'"+ group_name = "kafka_group_name = 'group1'"+ format = "kafka_format = 'JSONEachRow'"+ }+ }++ table "kafka_log_entries_v3" {+ column "team_id" {+ type = "UInt64"+ }+ column "log_source" {+ type = "LowCardinality(String)"+ }+ column "log_source_id" {+ type = "String"+ }+ column "instance_id" {+ type = "String"+ }+ column "timestamp" {+ type = "DateTime64(6, 'UTC')"+ }+ column "level" {+ type = "LowCardinality(String)"+ }+ column "message" {+ type = "String"+ }+ engine "kafka" {+ broker_list = "msk_cluster"+ topic_list = "kafka_topic_list = 'log_entries'"+ group_name = "kafka_group_name = 'clickhouse_log_entries'"+ format = "kafka_format = 'JSONEachRow'"+ skip_broken_messages = 100+ }+ }++ table "kafka_log_entries_ws" {+ column "team_id" {+ type = "UInt64"+ }+ column "log_source" {+ type = "LowCardinality(String)"+ }+ column "log_source_id" {+ type = "String"+ }+ column "instance_id" {+ type = "String"+ }+ column "timestamp" {+ type = "DateTime64(6, 'UTC')"+ }+ column "level" {+ type = "LowCardinality(String)"+ }+ column "message" {+ type = "String"+ }+ engine "kafka" {+ broker_list = "warpstream_ingestion"+ topic_list = "kafka_topic_list = 'log_entries'"+ group_name = "kafka_group_name = 'clickhouse_log_entries_ws'"+ format = "kafka_format = 'JSONEachRow'"+ skip_broken_messages = 100+ }+ }++ table "kafka_person" {+ column "id" {+ type = "UUID"+ }+ column "created_at" {+ type = "DateTime64(3)"+ }+ column "team_id" {+ type = "Int64"+ }+ column "properties" {+ type = "String"+ }+ column "is_identified" {+ type = "Int8"+ }+ column "is_deleted" {+ type = "Int8"+ }+ column "version" {+ type = "UInt64"+ }+ column "last_seen_at" {+ type = "Nullable(DateTime64(3))"+ }+ engine "kafka" {+ broker_list = "msk_cluster"+ topic_list = "kafka_topic_list = 'clickhouse_person'"+ group_name = "kafka_group_name = 'group1'"+ format = "kafka_format = 'JSONEachRow'"+ }+ }++ table "kafka_person_distinct_id2" {+ column "team_id" {+ type = "Int64"+ }+ column "distinct_id" {+ type = "String"+ }+ column "person_id" {+ type = "UUID"+ }+ column "is_deleted" {+ type = "Int8"+ }+ column "version" {+ type = "Int64"+ }+ engine "kafka" {+ broker_list = "msk_cluster"+ topic_list = "kafka_topic_list = 'clickhouse_person_distinct_id'"+ group_name = "kafka_group_name = 'group1'"+ format = "kafka_format = 'JSONEachRow'"+ }+ }++ table "kafka_person_distinct_id_overrides" {+ column "team_id" {+ type = "Int64"+ }+ column "distinct_id" {+ type = "String"+ }+ column "person_id" {+ type = "UUID"+ }+ column "is_deleted" {+ type = "Int8"+ }+ column "version" {+ type = "Int64"+ }+ engine "kafka" {+ broker_list = "msk_cluster"+ topic_list = "kafka_topic_list = 'clickhouse_person_distinct_id'"+ group_name = "kafka_group_name = 'clickhouse-person-distinct-id-overrides'"+ format = "kafka_format = 'JSONEachRow'"+ }+ }++ table "kafka_plugin_log_entries" {+ column "id" {+ type = "UUID"+ }+ column "team_id" {+ type = "Int64"+ }+ column "plugin_id" {+ type = "Int64"+ }+ column "plugin_config_id" {+ type = "Int64"+ }+ column "timestamp" {+ type = "DateTime64(6, 'UTC')"+ }+ column "source" {+ type = "String"+ }+ column "type" {+ type = "String"+ }+ column "message" {+ type = "String"+ }+ column "instance_id" {+ type = "UUID"+ }+ engine "kafka" {+ broker_list = "msk_cluster"+ topic_list = "kafka_topic_list = 'plugin_log_entries'"+ group_name = "kafka_group_name = 'group1'"+ format = "kafka_format = 'JSONEachRow'"+ }+ }++ table "kafka_posthog_document_embeddings" {+ column "team_id" {+ type = "Int64"+ }+ column "product" {+ type = "LowCardinality(String)"+ }+ column "document_type" {+ type = "LowCardinality(String)"+ }+ column "model_name" {+ type = "LowCardinality(String)"+ }+ column "rendering" {+ type = "LowCardinality(String)"+ }+ column "document_id" {+ type = "String"+ }+ column "timestamp" {+ type = "DateTime64(3, 'UTC')"+ }+ column "inserted_at" {+ type = "DateTime64(3, 'UTC')"+ }+ column "content" {+ type = "String"+ }+ column "metadata" {+ type = "String"+ }+ column "embedding" {+ type = "Array(Float64)"+ }+ engine "kafka" {+ broker_list = "msk_cluster"+ topic_list = "kafka_topic_list = 'clickhouse_document_embeddings'"+ group_name = "kafka_group_name = 'clickhouse_document_embeddings'"+ format = "kafka_format = 'JSONEachRow'"+ }+ }++ table "kafka_session_replay_events" {+ column "session_id" {+ type = "String"+ }+ column "team_id" {+ type = "Int64"+ }+ column "distinct_id" {+ type = "String"+ }+ column "first_timestamp" {+ type = "DateTime64(6, 'UTC')"+ }+ column "last_timestamp" {+ type = "DateTime64(6, 'UTC')"+ }+ column "block_url" {+ type = "Nullable(String)"+ }+ column "first_url" {+ type = "Nullable(String)"+ }+ column "urls" {+ type = "Array(String)"+ }+ column "click_count" {+ type = "Int64"+ }+ column "keypress_count" {+ type = "Int64"+ }+ column "mouse_activity_count" {+ type = "Int64"+ }+ column "active_milliseconds" {+ type = "Int64"+ }+ column "console_log_count" {+ type = "Int64"+ }+ column "console_warn_count" {+ type = "Int64"+ }+ column "console_error_count" {+ type = "Int64"+ }+ column "size" {+ type = "Int64"+ }+ column "event_count" {+ type = "Int64"+ }+ column "message_count" {+ type = "Int64"+ }+ column "snapshot_source" {+ type = "LowCardinality(Nullable(String))"+ }+ column "snapshot_library" {+ type = "Nullable(String)"+ }+ column "retention_period_days" {+ type = "Nullable(Int64)"+ }+ column "is_deleted" {+ type = "UInt8"+ }+ column "ai_tags_fixed" {+ type = "Array(String)"+ }+ column "ai_tags_freeform" {+ type = "Array(String)"+ }+ column "ai_highlighted" {+ type = "UInt8"+ }+ column "surfacing_score" {+ type = "Nullable(Float32)"+ }+ engine "kafka" {+ broker_list = "msk_cluster"+ topic_list = "kafka_topic_list = 'clickhouse_session_replay_events'"+ group_name = "kafka_group_name = 'group1'"+ format = "kafka_format = 'JSONEachRow'"+ }+ }++ table "kafka_usage_report_events_preagg" {+ column "uuid" {+ type = "UUID"+ }+ column "event" {+ type = "String"+ }+ column "properties" {+ type = "String"+ codec = "ZSTD(3)"+ }+ column "timestamp" {+ type = "DateTime64(6, 'UTC')"+ }+ column "team_id" {+ type = "Int64"+ }+ column "distinct_id" {+ type = "String"+ }+ column "person_mode" {+ type = "Enum8('full'=0, 'propertyless'=1, 'force_upgrade'=2)"+ }+ engine "kafka" {+ broker_list = "warpstream_ingestion"+ topic_list = "kafka_topic_list = 'clickhouse_events_json'"+ group_name = "kafka_group_name = 'clickhouse_usage_report_events_preagg'"+ format = "kafka_format = 'JSONEachRow'"+ num_consumers = 1+ skip_broken_messages = 100+ thread_per_consumer = true+ }+ }++ table "writable_app_metrics" {+ column "team_id" {+ type = "Int64"+ }+ column "timestamp" {+ type = "DateTime64(6, 'UTC')"+ }+ column "plugin_config_id" {+ type = "Int64"+ }+ column "category" {+ type = "LowCardinality(String)"+ }+ column "job_id" {+ type = "String"+ }+ column "successes" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "successes_on_retry" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "failures" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "error_uuid" {+ type = "UUID"+ }+ column "error_type" {+ type = "String"+ }+ column "error_details" {+ type = "String"+ codec = "ZSTD(3)"+ }+ column "_timestamp" {+ type = "DateTime"+ }+ column "_offset" {+ type = "UInt64"+ }+ column "_partition" {+ type = "UInt64"+ }+ engine "distributed" {+ cluster_name = "posthog"+ remote_database = "posthog"+ remote_table = "sharded_app_metrics"+ sharding_key = "rand()"+ }+ }++ table "writable_duplicate_events" {+ column "team_id" {+ type = "Int64"+ }+ column "distinct_id" {+ type = "String"+ }+ column "event" {+ type = "String"+ }+ column "source_uuid" {+ type = "UUID"+ }+ column "duplicate_uuid" {+ type = "UUID"+ }+ column "similarity_score" {+ type = "Float64"+ }+ column "dedup_type" {+ type = "LowCardinality(String)"+ }+ column "is_confirmed" {+ type = "UInt8"+ }+ column "reason" {+ type = "Nullable(String)"+ }+ column "version" {+ type = "String"+ }+ column "different_property_count" {+ type = "UInt32"+ }+ column "properties_similarity" {+ type = "Float64"+ }+ column "source_message" {+ type = "String"+ }+ column "duplicate_message" {+ type = "String"+ }+ column "distinct_fields" {+ type = "Array(Tuple(field_name String, original_value String, new_value String))"+ }+ column "inserted_at" {+ type = "DateTime64(3, 'UTC')"+ }+ column "_timestamp" {+ type = "DateTime"+ }+ column "_offset" {+ type = "UInt64"+ }+ column "_partition" {+ type = "UInt64"+ }+ engine "distributed" {+ cluster_name = "posthog_single_shard"+ remote_database = "posthog"+ remote_table = "duplicate_events"+ }+ }++ table "writable_error_tracking_issue_fingerprint_embeddings" {+ column "team_id" {+ type = "Int64"+ }+ column "model_name" {+ type = "LowCardinality(String)"+ }+ column "embedding_version" {+ type = "Int64"+ }+ column "fingerprint" {+ type = "String"+ }+ column "inserted_at" {+ type = "DateTime64(3, 'UTC')"+ }+ column "embeddings" {+ type = "Array(Float64)"+ }+ column "_timestamp" {+ type = "DateTime"+ }+ column "_offset" {+ type = "UInt64"+ }+ column "_partition" {+ type = "UInt64"+ }+ engine "distributed" {+ cluster_name = "posthog_single_shard"+ remote_database = "posthog"+ remote_table = "error_tracking_issue_fingerprint_embeddings"+ }+ }++ table "writable_error_tracking_issue_fingerprint_overrides" {+ column "team_id" {+ type = "Int64"+ }+ column "fingerprint" {+ type = "String"+ }+ column "issue_id" {+ type = "UUID"+ }+ column "is_deleted" {+ type = "Int8"+ }+ column "version" {+ type = "Int64"+ }+ column "_timestamp" {+ type = "DateTime"+ }+ column "_offset" {+ type = "UInt64"+ }+ column "_partition" {+ type = "UInt64"+ }+ engine "distributed" {+ cluster_name = "posthog_single_shard"+ remote_database = "posthog"+ remote_table = "error_tracking_issue_fingerprint_overrides"+ }+ }++ table "writable_events_dead_letter_queue" {+ column "id" {+ type = "UUID"+ }+ column "event_uuid" {+ type = "UUID"+ }+ column "event" {+ type = "String"+ }+ column "properties" {+ type = "String"+ }+ column "distinct_id" {+ type = "String"+ }+ column "team_id" {+ type = "Int64"+ }+ column "elements_chain" {+ type = "String"+ }+ column "created_at" {+ type = "DateTime64(6, 'UTC')"+ }+ column "ip" {+ type = "String"+ }+ column "site_url" {+ type = "String"+ }+ column "now" {+ type = "DateTime64(6, 'UTC')"+ }+ column "raw_payload" {+ type = "String"+ }+ column "error_timestamp" {+ type = "DateTime64(6, 'UTC')"+ }+ column "error_location" {+ type = "String"+ }+ column "error" {+ type = "String"+ }+ column "tags" {+ type = "Array(String)"+ }+ column "_timestamp" {+ type = "DateTime"+ }+ column "_offset" {+ type = "UInt64"+ }+ engine "distributed" {+ cluster_name = "posthog_single_shard"+ remote_database = "posthog"+ remote_table = "events_dead_letter_queue"+ }+ }++ table "writable_groups" {+ column "group_type_index" {+ type = "UInt8"+ }+ column "group_key" {+ type = "String"+ }+ column "created_at" {+ type = "DateTime64(3)"+ }+ column "team_id" {+ type = "Int64"+ }+ column "group_properties" {+ type = "String"+ }+ column "_timestamp" {+ type = "DateTime"+ }+ column "_offset" {+ type = "UInt64"+ }+ engine "distributed" {+ cluster_name = "posthog_single_shard"+ remote_database = "posthog"+ remote_table = "groups"+ }+ }++ table "writable_ingestion_warnings" {+ column "team_id" {+ type = "Int64"+ }+ column "source" {+ type = "LowCardinality(String)"+ }+ column "type" {+ type = "String"+ }+ column "details" {+ type = "String"+ codec = "ZSTD(3)"+ }+ column "timestamp" {+ type = "DateTime64(6, 'UTC')"+ }+ column "_timestamp" {+ type = "DateTime"+ }+ column "_offset" {+ type = "UInt64"+ }+ column "_partition" {+ type = "UInt64"+ }+ engine "distributed" {+ cluster_name = "posthog"+ remote_database = "posthog"+ remote_table = "sharded_ingestion_warnings"+ sharding_key = "rand()"+ }+ }+++ table "writable_person" {+ column "id" {+ type = "UUID"+ }+ column "created_at" {+ type = "DateTime64(3)"+ }+ column "team_id" {+ type = "Int64"+ }+ column "properties" {+ type = "String"+ }+ column "is_identified" {+ type = "Int8"+ }+ column "is_deleted" {+ type = "Int8"+ }+ column "version" {+ type = "UInt64"+ }+ column "last_seen_at" {+ type = "Nullable(DateTime64(3))"+ }+ column "_timestamp" {+ type = "DateTime"+ }+ column "_offset" {+ type = "UInt64"+ }+ engine "distributed" {+ cluster_name = "posthog_single_shard"+ remote_database = "posthog"+ remote_table = "person"+ }+ }++ table "writable_person_distinct_id2" {+ column "team_id" {+ type = "Int64"+ }+ column "distinct_id" {+ type = "String"+ }+ column "person_id" {+ type = "UUID"+ }+ column "is_deleted" {+ type = "Int8"+ }+ column "version" {+ type = "Int64"+ }+ column "_timestamp" {+ type = "DateTime"+ }+ column "_offset" {+ type = "UInt64"+ }+ column "_partition" {+ type = "UInt64"+ }+ engine "distributed" {+ cluster_name = "posthog_single_shard"+ remote_database = "posthog"+ remote_table = "person_distinct_id2"+ }+ }++ table "writable_person_distinct_id_overrides" {+ column "team_id" {+ type = "Int64"+ }+ column "distinct_id" {+ type = "String"+ }+ column "person_id" {+ type = "UUID"+ }+ column "is_deleted" {+ type = "Int8"+ }+ column "version" {+ type = "Int64"+ }+ column "_timestamp" {+ type = "DateTime"+ }+ column "_offset" {+ type = "UInt64"+ }+ column "_partition" {+ type = "UInt64"+ }+ engine "distributed" {+ cluster_name = "posthog_single_shard"+ remote_database = "posthog"+ remote_table = "person_distinct_id_overrides"+ }+ }++ table "writable_plugin_log_entries" {+ column "id" {+ type = "UUID"+ }+ column "team_id" {+ type = "Int64"+ }+ column "plugin_id" {+ type = "Int64"+ }+ column "plugin_config_id" {+ type = "Int64"+ }+ column "timestamp" {+ type = "DateTime64(6, 'UTC')"+ }+ column "source" {+ type = "String"+ }+ column "type" {+ type = "String"+ }+ column "message" {+ type = "String"+ }+ column "instance_id" {+ type = "UUID"+ }+ column "_timestamp" {+ type = "DateTime"+ }+ column "_offset" {+ type = "UInt64"+ }+ engine "distributed" {+ cluster_name = "posthog_single_shard"+ remote_database = "posthog"+ remote_table = "plugin_log_entries"+ }+ }++ table "writable_posthog_document_embeddings" {+ column "team_id" {+ type = "Int64"+ }+ column "product" {+ type = "LowCardinality(String)"+ }+ column "document_type" {+ type = "LowCardinality(String)"+ }+ column "model_name" {+ type = "LowCardinality(String)"+ }+ column "rendering" {+ type = "LowCardinality(String)"+ }+ column "document_id" {+ type = "String"+ }+ column "timestamp" {+ type = "DateTime64(3, 'UTC')"+ }+ column "inserted_at" {+ type = "DateTime64(3, 'UTC')"+ }+ column "content" {+ type = "String"+ default = "''"+ }+ column "metadata" {+ type = "String"+ default = "'{}'"+ }+ column "embedding" {+ type = "Array(Float64)"+ }+ column "_timestamp" {+ type = "DateTime"+ }+ column "_offset" {+ type = "UInt64"+ }+ column "_partition" {+ type = "UInt64"+ }+ engine "distributed" {+ cluster_name = "posthog"+ remote_database = "posthog"+ remote_table = "partitioned_sharded_posthog_document_embeddings"+ sharding_key = "cityHash64(document_id)"+ }+ }++ table "writable_posthog_document_embeddings_buffer" {+ column "team_id" {+ type = "Int64"+ }+ column "product" {+ type = "LowCardinality(String)"+ }+ column "document_type" {+ type = "LowCardinality(String)"+ }+ column "model_name" {+ type = "LowCardinality(String)"+ }+ column "rendering" {+ type = "LowCardinality(String)"+ }+ column "document_id" {+ type = "String"+ }+ column "timestamp" {+ type = "DateTime64(3, 'UTC')"+ }+ column "inserted_at" {+ type = "DateTime64(3, 'UTC')"+ }+ column "content" {+ type = "String"+ default = "''"+ }+ column "metadata" {+ type = "String"+ default = "'{}'"+ }+ column "embedding" {+ type = "Array(Float64)"+ }+ column "_timestamp" {+ type = "DateTime"+ }+ column "_offset" {+ type = "UInt64"+ }+ column "_partition" {+ type = "UInt64"+ }+ engine "distributed" {+ cluster_name = "posthog"+ remote_database = "posthog"+ remote_table = "sharded_posthog_document_embeddings_buffer"+ sharding_key = "cityHash64(document_id)"+ }+ }+++ table "writable_usage_report_events_preagg" {+ column "date" {+ type = "Date"+ }+ column "team_id" {+ type = "Int64"+ }+ column "person_mode" {+ type = "LowCardinality(String)"+ }+ column "lib" {+ type = "LowCardinality(String)"+ }+ column "event" {+ type = "String"+ }+ column "distinct_events_unique" {+ type = "AggregateFunction(uniqExact, Tuple(UInt64, UInt64, UInt64))"+ }+ column "event_count" {+ type = "AggregateFunction(sum, UInt64)"+ }+ engine "distributed" {+ cluster_name = "aux"+ remote_database = "posthog"+ remote_table = "sharded_usage_report_events_preagg"+ sharding_key = "sipHash64(date)"+ }+ }++ materialized_view "app_metrics_mv" {+ to_table = "posthog.writable_app_metrics"+ query = <<SQL+SELECT+ team_id,+ timestamp,+ plugin_config_id,+ category,+ job_id,+ successes,+ successes_on_retry,+ failures,+ error_uuid,+ error_type,+ error_details,+ _timestamp,+ _offset,+ _partition+FROM posthog.kafka_app_metrics+SQL++ column "team_id" {+ type = "Int64"+ }+ column "timestamp" {+ type = "DateTime64(6, 'UTC')"+ }+ column "plugin_config_id" {+ type = "Int64"+ }+ column "category" {+ type = "LowCardinality(String)"+ }+ column "job_id" {+ type = "String"+ }+ column "successes" {+ type = "Int64"+ }+ column "successes_on_retry" {+ type = "Int64"+ }+ column "failures" {+ type = "Int64"+ }+ column "error_uuid" {+ type = "UUID"+ }+ column "error_type" {+ type = "String"+ }+ column "error_details" {+ type = "String"+ }+ column "_timestamp" {+ type = "Nullable(DateTime)"+ }+ column "_offset" {+ type = "UInt64"+ }+ column "_partition" {+ type = "UInt64"+ }+ }++ materialized_view "duplicate_events_mv" {+ to_table = "posthog.writable_duplicate_events"+ query = <<SQL+SELECT+ team_id,+ distinct_id,+ event,+ source_uuid,+ duplicate_uuid,+ similarity_score,+ dedup_type,+ is_confirmed,+ reason,+ version,+ different_property_count,+ properties_similarity,+ source_message,+ duplicate_message,+ JSONExtract(+ distinct_fields,+ 'Array(Tuple(field_name String, original_value String, new_value String))'+ ) AS distinct_fields,+ inserted_at,+ _timestamp,+ _offset,+ _partition+FROM posthog.kafka_duplicate_events+SQL++ column "team_id" {+ type = "Int64"+ }+ column "distinct_id" {+ type = "String"+ }+ column "event" {+ type = "String"+ }+ column "source_uuid" {+ type = "UUID"+ }+ column "duplicate_uuid" {+ type = "UUID"+ }+ column "similarity_score" {+ type = "Float64"+ }+ column "dedup_type" {+ type = "LowCardinality(String)"+ }+ column "is_confirmed" {+ type = "UInt8"+ }+ column "reason" {+ type = "Nullable(String)"+ }+ column "version" {+ type = "String"+ }+ column "different_property_count" {+ type = "UInt32"+ }+ column "properties_similarity" {+ type = "Float64"+ }+ column "source_message" {+ type = "String"+ }+ column "duplicate_message" {+ type = "String"+ }+ column "distinct_fields" {+ type = "Array(Tuple(field_name String, original_value String, new_value String))"+ }+ column "inserted_at" {+ type = "DateTime64(3, 'UTC')"+ }+ column "_timestamp" {+ type = "Nullable(DateTime)"+ }+ column "_offset" {+ type = "UInt64"+ }+ column "_partition" {+ type = "UInt64"+ }+ }++ materialized_view "error_tracking_issue_fingerprint_embeddings_mv" {+ to_table = "posthog.writable_error_tracking_issue_fingerprint_embeddings"+ query = <<SQL+SELECT+ team_id,+ model_name,+ embedding_version,+ fingerprint,+ _timestamp AS inserted_at,+ embeddings,+ _timestamp,+ _offset,+ _partition+FROM posthog.kafka_error_tracking_issue_fingerprint_embeddings+SQL++ column "team_id" {+ type = "Int64"+ }+ column "model_name" {+ type = "LowCardinality(String)"+ }+ column "embedding_version" {+ type = "Int64"+ }+ column "fingerprint" {+ type = "String"+ }+ column "inserted_at" {+ type = "Nullable(DateTime)"+ }+ column "embeddings" {+ type = "Array(Float64)"+ }+ column "_timestamp" {+ type = "Nullable(DateTime)"+ }+ column "_offset" {+ type = "UInt64"+ }+ column "_partition" {+ type = "UInt64"+ }+ }++ materialized_view "error_tracking_issue_fingerprint_overrides_mv" {+ to_table = "posthog.writable_error_tracking_issue_fingerprint_overrides"+ query = <<SQL+SELECT+ team_id,+ fingerprint,+ issue_id,+ is_deleted,+ version,+ _timestamp,+ _offset,+ _partition+FROM posthog.kafka_error_tracking_issue_fingerprint_overrides+WHERE version > 0+SQL++ column "team_id" {+ type = "Int64"+ }+ column "fingerprint" {+ type = "String"+ }+ column "issue_id" {+ type = "UUID"+ }+ column "is_deleted" {+ type = "Int8"+ }+ column "version" {+ type = "Int64"+ }+ column "_timestamp" {+ type = "Nullable(DateTime)"+ }+ column "_offset" {+ type = "UInt64"+ }+ column "_partition" {+ type = "UInt64"+ }+ }++ materialized_view "events_dead_letter_queue_mv" {+ to_table = "posthog.writable_events_dead_letter_queue"+ query = <<SQL+SELECT+ id,+ event_uuid,+ event,+ properties,+ distinct_id,+ team_id,+ elements_chain,+ created_at,+ ip,+ site_url,+ now,+ raw_payload,+ error_timestamp,+ error_location,+ error,+ tags,+ _timestamp,+ _offset+FROM posthog.kafka_events_dead_letter_queue+SQL++ column "id" {+ type = "UUID"+ }+ column "event_uuid" {+ type = "UUID"+ }+ column "event" {+ type = "String"+ }+ column "properties" {+ type = "String"+ }+ column "distinct_id" {+ type = "String"+ }+ column "team_id" {+ type = "Int64"+ }+ column "elements_chain" {+ type = "String"+ }+ column "created_at" {+ type = "DateTime64(6, 'UTC')"+ }+ column "ip" {+ type = "String"+ }+ column "site_url" {+ type = "String"+ }+ column "now" {+ type = "DateTime64(6, 'UTC')"+ }+ column "raw_payload" {+ type = "String"+ }+ column "error_timestamp" {+ type = "DateTime64(6, 'UTC')"+ }+ column "error_location" {+ type = "String"+ }+ column "error" {+ type = "String"+ }+ column "tags" {+ type = "Array(String)"+ }+ column "_timestamp" {+ type = "Nullable(DateTime)"+ }+ column "_offset" {+ type = "UInt64"+ }+ }++ materialized_view "groups_mv" {+ to_table = "posthog.writable_groups"+ query = <<SQL+SELECT+ group_type_index,+ group_key,+ created_at,+ team_id,+ group_properties,+ _timestamp,+ _offset+FROM posthog.kafka_groups+SQL++ column "group_type_index" {+ type = "UInt8"+ }+ column "group_key" {+ type = "String"+ }+ column "created_at" {+ type = "DateTime64(3)"+ }+ column "team_id" {+ type = "Int64"+ }+ column "group_properties" {+ type = "String"+ }+ column "_timestamp" {+ type = "Nullable(DateTime)"+ }+ column "_offset" {+ type = "UInt64"+ }+ }++ materialized_view "ingestion_warnings_mv" {+ to_table = "posthog.writable_ingestion_warnings"+ query = <<SQL+SELECT+ team_id,+ source,+ type,+ details,+ timestamp,+ _timestamp,+ _offset,+ _partition+FROM posthog.kafka_ingestion_warnings+SQL++ column "team_id" {+ type = "Int64"+ }+ column "source" {+ type = "LowCardinality(String)"+ }+ column "type" {+ type = "String"+ }+ column "details" {+ type = "String"+ }+ column "timestamp" {+ type = "DateTime64(6, 'UTC')"+ }+ column "_timestamp" {+ type = "Nullable(DateTime)"+ }+ column "_offset" {+ type = "UInt64"+ }+ column "_partition" {+ type = "UInt64"+ }+ }++ materialized_view "log_entries_v3_mv" {+ to_table = "posthog.writable_log_entries"+ query = <<SQL+SELECT+ team_id,+ log_source,+ log_source_id,+ instance_id,+ timestamp,+ level,+ message,+ _timestamp,+ _offset+FROM posthog.kafka_log_entries_v3+WHERE toDate(timestamp) <= today()+SQL++ column "team_id" {+ type = "UInt64"+ }+ column "log_source" {+ type = "LowCardinality(String)"+ }+ column "log_source_id" {+ type = "String"+ }+ column "instance_id" {+ type = "String"+ }+ column "timestamp" {+ type = "DateTime64(6, 'UTC')"+ }+ column "level" {+ type = "LowCardinality(String)"+ }+ column "message" {+ type = "String"+ }+ column "_timestamp" {+ type = "Nullable(DateTime)"+ }+ column "_offset" {+ type = "UInt64"+ }+ }++ materialized_view "log_entries_ws_mv" {+ to_table = "posthog.writable_log_entries"+ query = <<SQL+SELECT+ team_id,+ log_source,+ log_source_id,+ instance_id,+ timestamp,+ level,+ message,+ _timestamp,+ _offset+FROM posthog.kafka_log_entries_ws+WHERE toDate(timestamp) <= today()+SQL++ column "team_id" {+ type = "UInt64"+ }+ column "log_source" {+ type = "LowCardinality(String)"+ }+ column "log_source_id" {+ type = "String"+ }+ column "instance_id" {+ type = "String"+ }+ column "timestamp" {+ type = "DateTime64(6, 'UTC')"+ }+ column "level" {+ type = "LowCardinality(String)"+ }+ column "message" {+ type = "String"+ }+ column "_timestamp" {+ type = "Nullable(DateTime)"+ }+ column "_offset" {+ type = "UInt64"+ }+ }++ materialized_view "person_distinct_id2_mv" {+ to_table = "posthog.writable_person_distinct_id2"+ query = <<SQL+SELECT+ team_id,+ distinct_id,+ person_id,+ is_deleted,+ version,+ _timestamp,+ _offset,+ _partition+FROM posthog.kafka_person_distinct_id2+SQL++ column "team_id" {+ type = "Int64"+ }+ column "distinct_id" {+ type = "String"+ }+ column "person_id" {+ type = "UUID"+ }+ column "is_deleted" {+ type = "Int8"+ }+ column "version" {+ type = "Int64"+ }+ column "_timestamp" {+ type = "Nullable(DateTime)"+ }+ column "_offset" {+ type = "UInt64"+ }+ column "_partition" {+ type = "UInt64"+ }+ }++ materialized_view "person_distinct_id_overrides_mv" {+ to_table = "posthog.writable_person_distinct_id_overrides"+ query = <<SQL+SELECT+ team_id,+ distinct_id,+ person_id,+ is_deleted,+ version,+ _timestamp,+ _offset,+ _partition+FROM posthog.kafka_person_distinct_id_overrides+WHERE version > 0+SQL++ column "team_id" {+ type = "Int64"+ }+ column "distinct_id" {+ type = "String"+ }+ column "person_id" {+ type = "UUID"+ }+ column "is_deleted" {+ type = "Int8"+ }+ column "version" {+ type = "Int64"+ }+ column "_timestamp" {+ type = "Nullable(DateTime)"+ }+ column "_offset" {+ type = "UInt64"+ }+ column "_partition" {+ type = "UInt64"+ }+ }++ materialized_view "person_mv" {+ to_table = "posthog.writable_person"+ query = <<SQL+SELECT+ id,+ created_at,+ team_id,+ properties,+ is_identified,+ is_deleted,+ version,+ last_seen_at,+ _timestamp,+ _offset+FROM posthog.kafka_person+SQL++ column "id" {+ type = "UUID"+ }+ column "created_at" {+ type = "DateTime64(3)"+ }+ column "team_id" {+ type = "Int64"+ }+ column "properties" {+ type = "String"+ }+ column "is_identified" {+ type = "Int8"+ }+ column "is_deleted" {+ type = "Int8"+ }+ column "version" {+ type = "UInt64"+ }+ column "last_seen_at" {+ type = "Nullable(DateTime64(3))"+ }+ column "_timestamp" {+ type = "Nullable(DateTime)"+ }+ column "_offset" {+ type = "UInt64"+ }+ }++ materialized_view "plugin_log_entries_mv" {+ to_table = "posthog.writable_plugin_log_entries"+ query = <<SQL+SELECT+ id,+ team_id,+ plugin_id,+ plugin_config_id,+ timestamp,+ source,+ type,+ message,+ instance_id,+ _timestamp,+ _offset+FROM posthog.kafka_plugin_log_entries+SQL++ column "id" {+ type = "UUID"+ }+ column "team_id" {+ type = "Int64"+ }+ column "plugin_id" {+ type = "Int64"+ }+ column "plugin_config_id" {+ type = "Int64"+ }+ column "timestamp" {+ type = "DateTime64(6, 'UTC')"+ }+ column "source" {+ type = "String"+ }+ column "type" {+ type = "String"+ }+ column "message" {+ type = "String"+ }+ column "instance_id" {+ type = "UUID"+ }+ column "_timestamp" {+ type = "Nullable(DateTime)"+ }+ column "_offset" {+ type = "UInt64"+ }+ }++ materialized_view "posthog_document_embeddings_kafka_to_buffer_mv" {+ to_table = "posthog.writable_posthog_document_embeddings_buffer"+ query = <<SQL+SELECT+ team_id,+ product,+ document_type,+ model_name,+ rendering,+ document_id,+ timestamp,+ _timestamp AS inserted_at,+ coalesce(content, '') AS content,+ coalesce(metadata, '{}') AS metadata,+ embedding,+ _timestamp,+ _offset,+ _partition+FROM posthog.kafka_posthog_document_embeddings+SQL++ column "team_id" {+ type = "Int64"+ }+ column "product" {+ type = "LowCardinality(String)"+ }+ column "document_type" {+ type = "LowCardinality(String)"+ }+ column "model_name" {+ type = "LowCardinality(String)"+ }+ column "rendering" {+ type = "LowCardinality(String)"+ }+ column "document_id" {+ type = "String"+ }+ column "timestamp" {+ type = "DateTime64(3, 'UTC')"+ }+ column "inserted_at" {+ type = "Nullable(DateTime)"+ }+ column "content" {+ type = "String"+ }+ column "metadata" {+ type = "String"+ }+ column "embedding" {+ type = "Array(Float64)"+ }+ column "_timestamp" {+ type = "Nullable(DateTime)"+ }+ column "_offset" {+ type = "UInt64"+ }+ column "_partition" {+ type = "UInt64"+ }+ }++ materialized_view "session_replay_events_mv" {+ to_table = "posthog.writable_session_replay_events"+ query = <<SQL+SELECT+ session_id,+ team_id,+ any(distinct_id) AS distinct_id,+ min(first_timestamp) AS min_first_timestamp,+ max(last_timestamp) AS max_last_timestamp,+ groupArray(if(block_url != '', first_timestamp, NULL)) AS block_first_timestamps,+ groupArray(if(block_url != '', last_timestamp, NULL)) AS block_last_timestamps,+ groupArray(block_url) AS block_urls,+ argMinState(first_url, first_timestamp) AS first_url,+ groupUniqArrayArray(urls) AS all_urls,+ sum(click_count) AS click_count,+ sum(keypress_count) AS keypress_count,+ sum(mouse_activity_count) AS mouse_activity_count,+ sum(active_milliseconds) AS active_milliseconds,+ sum(console_log_count) AS console_log_count,+ sum(console_warn_count) AS console_warn_count,+ sum(console_error_count) AS console_error_count,+ sum(size) AS size,+ sum(message_count) AS message_count,+ sum(event_count) AS event_count,+ argMinState(snapshot_source, first_timestamp) AS snapshot_source,+ argMinState(snapshot_library, first_timestamp) AS snapshot_library,+ max(_timestamp) AS _timestamp,+ max(retention_period_days) AS retention_period_days,+ max(is_deleted) AS is_deleted,+ groupUniqArrayArray(ai_tags_fixed) AS ai_tags_fixed,+ groupUniqArrayArray(ai_tags_freeform) AS ai_tags_freeform,+ max(ai_highlighted) AS ai_highlighted,+ max(surfacing_score) AS surfacing_score+FROM posthog.kafka_session_replay_events+GROUP BY+ session_id, team_id+SQL++ column "session_id" {+ type = "String"+ }+ column "team_id" {+ type = "Int64"+ }+ column "distinct_id" {+ type = "String"+ }+ column "min_first_timestamp" {+ type = "DateTime64(6, 'UTC')"+ }+ column "max_last_timestamp" {+ type = "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 = "Int64"+ }+ column "keypress_count" {+ type = "Int64"+ }+ column "mouse_activity_count" {+ type = "Int64"+ }+ column "active_milliseconds" {+ type = "Int64"+ }+ column "console_log_count" {+ type = "Int64"+ }+ column "console_warn_count" {+ type = "Int64"+ }+ column "console_error_count" {+ type = "Int64"+ }+ column "size" {+ type = "Int64"+ }+ column "message_count" {+ type = "Int64"+ }+ column "event_count" {+ type = "Int64"+ }+ column "snapshot_source" {+ type = "AggregateFunction(argMin, LowCardinality(Nullable(String)), DateTime64(6, 'UTC'))"+ }+ column "snapshot_library" {+ type = "AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC'))"+ }+ column "_timestamp" {+ type = "Nullable(DateTime)"+ }+ column "retention_period_days" {+ type = "SimpleAggregateFunction(max, Nullable(Int64))"+ }+ column "is_deleted" {+ type = "SimpleAggregateFunction(max, UInt8)"+ }+ column "ai_tags_fixed" {+ type = "SimpleAggregateFunction(groupUniqArrayArray, Array(String))"+ }+ column "ai_tags_freeform" {+ type = "SimpleAggregateFunction(groupUniqArrayArray, Array(String))"+ }+ column "ai_highlighted" {+ type = "SimpleAggregateFunction(max, UInt8)"+ }+ column "surfacing_score" {+ type = "SimpleAggregateFunction(max, Nullable(Float32))"+ }+ }++ materialized_view "usage_report_events_preagg_mv" {+ to_table = "posthog.writable_usage_report_events_preagg"+ query = <<SQL+SELECT+ toDate(timestamp) AS date,+ team_id,+ person_mode,+ JSONExtractString(properties, '$lib') AS lib,+ event,+ uniqExactState((cityHash64(distinct_id), cityHash64(toString(uuid)), cityHash64(event))) AS distinct_events_unique,+ sumState(toUInt64(1)) AS event_count+FROM posthog.kafka_usage_report_events_preagg+GROUP BY+ date, team_id, person_mode, lib, event+SQL++ column "date" {+ type = "Date"+ }+ column "team_id" {+ type = "Int64"+ }+ column "person_mode" {+ type = "Enum8('full'=0, 'propertyless'=1, 'force_upgrade'=2)"+ }+ column "lib" {+ type = "String"+ }+ column "event" {+ type = "String"+ }+ column "distinct_events_unique" {+ type = "AggregateFunction(uniqExact, Tuple(UInt64, UInt64, UInt64))"+ }+ column "event_count" {+ type = "AggregateFunction(sum, UInt64)"+ }+ }+}diff --git a/posthog/clickhouse/hcl/sql/local-multi/data.sql b/posthog/clickhouse/hcl/sql/local-multi/data.sqlindex 5d74dd07abef..c8ddce4966aa 100644--- a/posthog/clickhouse/hcl/sql/local-multi/data.sql+++ b/posthog/clickhouse/hcl/sql/local-multi/data.sql@@ -2288,12 +2288,12 @@ CREATE TABLE posthog.writable_session_replay_events (snapshot_source AggregateFunction(argMin, LowCardinality(Nullable(String)), DateTime64(6, 'UTC')),snapshot_library AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC')),_timestamp SimpleAggregateFunction(max, DateTime),+ 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))+ surfacing_score SimpleAggregateFunction(max, Nullable(Float32))) ENGINE = Distributed('posthog', 'posthog', 'sharded_session_replay_events', sipHash64(distinct_id));CREATE TABLE posthog.writable_sessions (session_id String,diff --git a/posthog/clickhouse/hcl/sql/local-multi/ingestion_events.sql b/posthog/clickhouse/hcl/sql/local-multi/ingestion_events.sqlnew file mode 100644index 000000000000..c67fca683e3b--- /dev/null+++ b/posthog/clickhouse/hcl/sql/local-multi/ingestion_events.sql@@ -0,0 +1,204 @@+-- AUTO-GENERATED from the declarative HCL by ops/gen-sql.sh — do not edit.+-- Full CREATE schema for the local-multi/events node. Apply to a fresh ClickHouse to build it.++CREATE TABLE posthog.kafka_events_json_native_json (+ uuid UUID,+ event String,+ properties String CODEC(ZSTD(3)),+ timestamp DateTime64(6, 'UTC'),+ team_id Int64,+ distinct_id String,+ elements_chain String,+ created_at DateTime64(6, 'UTC'),+ person_id UUID,+ person_created_at DateTime64(3),+ person_properties String CODEC(ZSTD(3)),+ group0_properties String CODEC(ZSTD(3)),+ group1_properties String CODEC(ZSTD(3)),+ group2_properties String CODEC(ZSTD(3)),+ group3_properties String CODEC(ZSTD(3)),+ group4_properties String CODEC(ZSTD(3)),+ group0_created_at DateTime64(3),+ group1_created_at DateTime64(3),+ group2_created_at DateTime64(3),+ group3_created_at DateTime64(3),+ group4_created_at DateTime64(3),+ person_mode Enum8('full'=0, 'propertyless'=1, 'force_upgrade'=2),+ historical_migration Bool,+ dmat_string_0 Nullable(String),+ dmat_string_1 Nullable(String),+ dmat_string_2 Nullable(String),+ dmat_string_3 Nullable(String),+ dmat_string_4 Nullable(String),+ dmat_string_5 Nullable(String),+ dmat_string_6 Nullable(String),+ dmat_string_7 Nullable(String),+ dmat_string_8 Nullable(String),+ dmat_string_9 Nullable(String)+) ENGINE = Kafka() SETTINGS kafka_broker_list = 'msk_cluster', kafka_format = 'kafka_format = \'JSONEachRow\'', kafka_group_name = 'kafka_group_name = \'clickhouse_events_json_native_json\'', kafka_skip_broken_messages = 100, kafka_topic_list = 'kafka_topic_list = \'clickhouse_events_json\'';+CREATE TABLE posthog.query_log_archive (+ hostname LowCardinality(String),+ user LowCardinality(String),+ query_id String,+ initial_query_id String,+ is_initial_query UInt8,+ type Enum8('QueryStart'=1, 'QueryFinish'=2, 'ExceptionBeforeStart'=3, 'ExceptionWhileProcessing'=4),+ event_date Date,+ event_time DateTime,+ event_time_microseconds DateTime64(6),+ query_start_time DateTime,+ query_start_time_microseconds DateTime64(6),+ query_duration_ms UInt64,+ read_rows UInt64,+ read_bytes UInt64,+ written_rows UInt64,+ written_bytes UInt64,+ result_rows UInt64,+ result_bytes UInt64,+ memory_usage UInt64,+ peak_threads_usage UInt64,+ current_database LowCardinality(String),+ query String,+ formatted_query String,+ normalized_query_hash UInt64,+ query_kind LowCardinality(String),+ exception_code Int32,+ exception String,+ stack_trace String,+ team_id Int64,+ log_comment JSON(max_dynamic_paths=256, access_method LowCardinality(String), alert_config_id String, api_key_label String, api_key_mask String, batch_export_id String, chargeable Bool, client_query_id String, cohort_id Int64, `dagster.job_name` String, `dagster.run_id` String, `dagster.tags.owner` String, dashboard_id Int64, experiment_feature_flag_key String, experiment_id Int64, feature LowCardinality(String), id String, insight_id Int64, is_impersonated Bool, kind LowCardinality(String), name String, org_id String, person_on_events_mode LowCardinality(String), product LowCardinality(String), query_type LowCardinality(String), request_name String, route_id String, service_name String, session_id String, table_id String, team_id Int64, `temporal.activity_id` String, `temporal.activity_type` String, `temporal.attempt` Int64, `temporal.workflow_id` String, `temporal.workflow_namespace` String, `temporal.workflow_run_id` String, `temporal.workflow_type` String, user_id Int64, warehouse_query Bool, workflow LowCardinality(String), workload LowCardinality(String), SKIP cache_key, SKIP filter, SKIP hogql_features, SKIP http_referer, SKIP http_request_id, SKIP http_user_agent, SKIP query_settings, SKIP timings, SKIP user_email),+ ProfileEvents Map(String, UInt64),+ exception_name String ALIAS errorCodeToName(exception_code),+ ProfileEvents_RealTimeMicroseconds Int64 ALIAS ProfileEvents['RealTimeMicroseconds'],+ ProfileEvents_OSCPUVirtualTimeMicroseconds Int64 ALIAS ProfileEvents['OSCPUVirtualTimeMicroseconds'],+ ProfileEvents_S3Clients Int64 ALIAS ProfileEvents['S3Clients'],+ ProfileEvents_S3DeleteObjects Int64 ALIAS ProfileEvents['S3DeleteObjects'],+ ProfileEvents_S3CopyObject Int64 ALIAS ProfileEvents['S3CopyObject'],+ ProfileEvents_S3ListObjects Int64 ALIAS ProfileEvents['S3ListObjects'],+ ProfileEvents_S3HeadObject Int64 ALIAS ProfileEvents['S3HeadObject'],+ ProfileEvents_S3GetObjectAttributes Int64 ALIAS ProfileEvents['S3GetObjectAttributes'],+ ProfileEvents_S3CreateMultipartUpload Int64 ALIAS ProfileEvents['S3CreateMultipartUpload'],+ ProfileEvents_S3UploadPartCopy Int64 ALIAS ProfileEvents['S3UploadPartCopy'],+ ProfileEvents_S3UploadPart Int64 ALIAS ProfileEvents['S3UploadPart'],+ ProfileEvents_S3AbortMultipartUpload Int64 ALIAS ProfileEvents['S3AbortMultipartUpload'],+ ProfileEvents_S3CompleteMultipartUpload Int64 ALIAS ProfileEvents['S3CompleteMultipartUpload'],+ ProfileEvents_S3PutObject Int64 ALIAS ProfileEvents['S3PutObject'],+ ProfileEvents_S3GetObject Int64 ALIAS ProfileEvents['S3GetObject'],+ ProfileEvents_ReadBufferFromS3Bytes Int64 ALIAS ProfileEvents['ReadBufferFromS3Bytes'],+ ProfileEvents_WriteBufferFromS3Bytes Int64 ALIAS ProfileEvents['WriteBufferFromS3Bytes'],+ lc_workflow LowCardinality(String) ALIAS log_comment.workflow,+ lc_kind LowCardinality(String) ALIAS log_comment.kind,+ lc_id String ALIAS CAST(log_comment.id, 'String'),+ lc_route_id String ALIAS CAST(log_comment.route_id, 'String'),+ lc_access_method LowCardinality(String) ALIAS log_comment.access_method,+ lc_api_key_label String ALIAS CAST(log_comment.api_key_label, 'String'),+ lc_api_key_mask String ALIAS CAST(log_comment.api_key_mask, 'String'),+ lc_query_type LowCardinality(String) ALIAS log_comment.query_type,+ lc_product LowCardinality(String) ALIAS log_comment.product,+ lc_chargeable Bool ALIAS log_comment.chargeable,+ lc_name String ALIAS CAST(log_comment.name, 'String'),+ lc_request_name String ALIAS CAST(log_comment.request_name, 'String'),+ lc_client_query_id String ALIAS CAST(log_comment.client_query_id, 'String'),+ lc_org_id String ALIAS CAST(log_comment.org_id, 'String'),+ lc_user_id Int64 ALIAS log_comment.user_id,+ lc_is_impersonated Bool ALIAS log_comment.is_impersonated,+ lc_session_id String ALIAS CAST(log_comment.session_id, 'String'),+ lc_dashboard_id Int64 ALIAS log_comment.dashboard_id,+ lc_insight_id Int64 ALIAS log_comment.insight_id,+ lc_cohort_id Int64 ALIAS log_comment.cohort_id,+ lc_batch_export_id String ALIAS CAST(log_comment.batch_export_id, 'String'),+ lc_experiment_id Int64 ALIAS log_comment.experiment_id,+ lc_experiment_feature_flag_key String ALIAS CAST(log_comment.experiment_feature_flag_key, 'String'),+ lc_alert_config_id String ALIAS CAST(log_comment.alert_config_id, 'String'),+ lc_feature LowCardinality(String) ALIAS log_comment.feature,+ lc_table_id String ALIAS CAST(log_comment.table_id, 'String'),+ lc_warehouse_query Bool ALIAS log_comment.warehouse_query,+ lc_person_on_events_mode LowCardinality(String) ALIAS log_comment.person_on_events_mode,+ lc_service_name String ALIAS CAST(log_comment.service_name, 'String'),+ lc_workload LowCardinality(String) ALIAS log_comment.workload,+ lc_query__kind LowCardinality(String) ALIAS if(JSONHas(toString(log_comment), 'query', 'source'), JSONExtractString(toString(log_comment), 'query', 'source', 'kind'), JSONExtractString(toString(log_comment), 'query', 'kind')),+ lc_query__query String ALIAS multiIf(NOT is_initial_query, '', JSONHas(toString(log_comment), 'query', 'source'), JSONExtractString(toString(log_comment), 'query', 'source', 'query'), JSONExtractString(toString(log_comment), 'query', 'query')),+ lc_query String ALIAS if(is_initial_query, JSONExtractRaw(toString(log_comment), 'query'), ''),+ lc_temporal__workflow_namespace String ALIAS CAST(log_comment.`temporal.workflow_namespace`, 'String'),+ lc_temporal__workflow_type String ALIAS CAST(log_comment.`temporal.workflow_type`, 'String'),+ lc_temporal__workflow_id String ALIAS CAST(log_comment.`temporal.workflow_id`, 'String'),+ lc_temporal__workflow_run_id String ALIAS CAST(log_comment.`temporal.workflow_run_id`, 'String'),+ lc_temporal__activity_type String ALIAS CAST(log_comment.`temporal.activity_type`, 'String'),+ lc_temporal__activity_id String ALIAS CAST(log_comment.`temporal.activity_id`, 'String'),+ lc_temporal__attempt Int64 ALIAS log_comment.`temporal.attempt`,+ lc_dagster__job_name String ALIAS CAST(log_comment.`dagster.job_name`, 'String'),+ lc_dagster__run_id String ALIAS CAST(log_comment.`dagster.run_id`, 'String'),+ 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.writable_events_json (+ uuid UUID,+ event String,+ properties JSON(max_dynamic_types=8, max_dynamic_paths=256, `$active_feature_flags` Array(String), `$ai_experiment_id` Nullable(String), `$ai_http_status` Nullable(String), `$ai_is_error` Nullable(String), `$ai_model` Nullable(String), `$ai_parent_id` Nullable(String), `$ai_prompt_name` Nullable(String), `$ai_provider` Nullable(String), `$ai_session_id` Nullable(String), `$ai_span_id` Nullable(String), `$ai_total_cost_usd` Nullable(String), `$ai_trace_id` Nullable(String), `$anon_distinct_id` Nullable(String), `$app_build` Nullable(String), `$app_namespace` Nullable(String), `$app_version` Nullable(String), `$browser` Nullable(String), `$browser_version` Nullable(String), `$current_url` Nullable(String), `$device` Nullable(String), `$device_id` Nullable(String), `$device_model` Nullable(String), `$device_type` Nullable(String), `$el_text` Nullable(String), `$event_type` Nullable(String), `$exception_fingerprint` Nullable(String), `$exception_functions` Array(String), `$exception_issue_id` Nullable(String), `$exception_sources` Array(String), `$exception_types` Array(String), `$exception_values` Array(String), `$feature_flag` Nullable(String), `$feature_flag_payloads` Nullable(String), `$feature_flag_response` Nullable(String), `$geoip_city_name` Nullable(String), `$geoip_country_code` Nullable(String), `$geoip_country_name` Nullable(String), `$geoip_subdivision_1_code` Nullable(String), `$group_0` Nullable(String), `$group_1` Nullable(String), `$group_2` Nullable(String), `$group_3` Nullable(String), `$group_4` Nullable(String), `$groups` Nullable(String), `$host` Nullable(String), `$initial_pathname` Nullable(String), `$initial_referrer` Nullable(String), `$initial_referring_domain` Nullable(String), `$ip` Nullable(String), `$is_identified` Nullable(String), `$lib` Nullable(String), `$lib_custom_api_host` Nullable(String), `$lib_version` Nullable(String), `$lib_version__minor` Nullable(String), `$os` Nullable(String), `$os_name` Nullable(String), `$os_version` Nullable(String), `$pathname` Nullable(String), `$prev_pageview_max_content_percentage` Nullable(String), `$prev_pageview_max_scroll_percentage` Nullable(String), `$prev_pageview_pathname` Nullable(String), `$process_person_profile` Nullable(String), `$referrer` Nullable(String), `$referring_domain` Nullable(String), `$screen_height` Nullable(String), `$screen_name` Nullable(String), `$screen_width` Nullable(String), `$sent_at` Nullable(String), `$session_id` Nullable(String), `$survey_id` Nullable(String), `$survey_response` Nullable(String), `$survey_response_1` Nullable(String), `$time` Nullable(String), `$user_id` Nullable(String), `$viewport_height` Nullable(String), `$viewport_width` Nullable(String), `$web_vitals_CLS_value` Nullable(String), `$web_vitals_FCP_value` Nullable(String), `$web_vitals_INP_value` Nullable(String), `$web_vitals_LCP_value` Nullable(String), `$window_id` Nullable(String)),+ timestamp DateTime64(6, 'UTC'),+ team_id Int64,+ distinct_id String,+ elements_hash String DEFAULT '',+ created_at DateTime64(6, 'UTC'),+ _timestamp DateTime,+ _offset UInt64,+ elements_chain String,+ person_id UUID,+ person_properties JSON(max_dynamic_types=6, max_dynamic_paths=32, `$app_version` Nullable(String), `$browser` Nullable(String), `$current_url` Nullable(String), `$geoip_continent_name` Nullable(String), `$geoip_country_code` Nullable(String), `$geoip_country_name` Nullable(String), `$initial_current_url` Nullable(String), `$initial_fbclid` Nullable(String), `$initial_gad_source` Nullable(String), `$initial_gbraid` Nullable(String), `$initial_gclid` Nullable(String), `$initial_msclkid` Nullable(String), `$initial_pathname` Nullable(String), `$initial_referring_domain` Nullable(String), `$initial_utm_campaign` Nullable(String), `$initial_utm_content` Nullable(String), `$initial_utm_medium` Nullable(String), `$initial_utm_source` Nullable(String), `$initial_utm_term` Nullable(String), `$initial_wbraid` Nullable(String), `$os_name` Nullable(String), `$referring_domain` Nullable(String)),+ group0_properties String CODEC(ZSTD(3)),+ group1_properties String CODEC(ZSTD(3)),+ group2_properties String CODEC(ZSTD(3)),+ group3_properties String CODEC(ZSTD(3)),+ group4_properties String CODEC(ZSTD(3)),+ person_created_at DateTime64(3),+ group0_created_at DateTime64(3),+ group1_created_at DateTime64(3),+ group2_created_at DateTime64(3),+ group3_created_at DateTime64(3),+ group4_created_at DateTime64(3),+ inserted_at Nullable(DateTime64(6, 'UTC')) DEFAULT now64(),+ person_mode Enum8('full'=0, 'propertyless'=1, 'force_upgrade'=2),+ is_deleted Bool DEFAULT false,+ consumer_breadcrumbs Array(String),+ historical_migration Bool DEFAULT false+) ENGINE = Distributed('posthog', 'posthog', 'sharded_events_json', sipHash64(distinct_id));+CREATE MATERIALIZED VIEW posthog.events_json_table_mv TO posthog.writable_events_json (uuid UUID, event String, properties JSON, timestamp DateTime64(6, 'UTC'), team_id Int64, distinct_id String, elements_chain String, created_at DateTime64(6, 'UTC'), person_id UUID, person_created_at DateTime64(3), person_properties JSON, group0_properties String, group1_properties String, group2_properties String, group3_properties String, group4_properties String, group0_created_at DateTime64(3), group1_created_at DateTime64(3), group2_created_at DateTime64(3), group3_created_at DateTime64(3), group4_created_at DateTime64(3), person_mode Enum8('full'=0, 'propertyless'=1, 'force_upgrade'=2), historical_migration Bool, _timestamp Nullable(DateTime), _offset UInt64, consumer_breadcrumbs Array(String)) AS SELECT+ uuid,+ event,+ ifNull(+ accurateCastOrNull(properties, 'JSON'),+ CAST(concat('{"$unparseable_properties":', toJSONString(properties), '}'), 'JSON')+ ) AS properties,+ timestamp,+ team_id,+ distinct_id,+ elements_chain,+ created_at,+ person_id,+ person_created_at,+ ifNull(+ accurateCastOrNull(person_properties, 'JSON'),+ CAST(concat('{"$unparseable_properties":', toJSONString(person_properties), '}'), 'JSON')+ ) AS person_properties,+ group0_properties,+ group1_properties,+ group2_properties,+ group3_properties,+ group4_properties,+ group0_created_at,+ group1_created_at,+ group2_created_at,+ group3_created_at,+ group4_created_at,+ person_mode,+ historical_migration,+ _timestamp,+ _offset,+ arrayMap(+ i -> (_headers.value[i]),+ arrayFilter(+ i -> ((_headers.name[i]) = 'kafka-consumer-breadcrumbs'),+ arrayEnumerate(_headers.name)+ )+ ) AS consumer_breadcrumbs+FROM posthog.kafka_events_json_native_json;diff --git a/posthog/clickhouse/hcl/sql/local-multi/ingestion_medium.sql b/posthog/clickhouse/hcl/sql/local-multi/ingestion_medium.sqlnew file mode 100644index 000000000000..e000c9753c4d--- /dev/null+++ b/posthog/clickhouse/hcl/sql/local-multi/ingestion_medium.sql@@ -0,0 +1,643 @@+-- AUTO-GENERATED from the declarative HCL by ops/gen-sql.sh — do not edit.+-- Full CREATE schema for the local-multi/medium node. Apply to a fresh ClickHouse to build it.++CREATE TABLE posthog.kafka_app_metrics2 (+ team_id Int64,+ timestamp DateTime64(6, 'UTC'),+ app_source LowCardinality(String),+ app_source_id String,+ instance_id String,+ metric_kind String,+ metric_name String,+ count Int64+) ENGINE = Kafka() SETTINGS kafka_broker_list = 'msk_cluster', kafka_format = 'kafka_format = \'JSONEachRow\'', kafka_group_name = 'kafka_group_name = \'group1\'', kafka_topic_list = 'kafka_topic_list = \'clickhouse_app_metrics2\'';+CREATE TABLE posthog.kafka_app_metrics2_ws (+ team_id Int64,+ timestamp DateTime64(6, 'UTC'),+ app_source LowCardinality(String),+ app_source_id String,+ instance_id String,+ metric_kind String,+ metric_name String,+ count Int64+) ENGINE = Kafka() SETTINGS kafka_broker_list = 'warpstream_ingestion', kafka_format = 'kafka_format = \'JSONEachRow\'', kafka_group_name = 'kafka_group_name = \'clickhouse_app_metrics2_ws\'', kafka_topic_list = 'kafka_topic_list = \'clickhouse_app_metrics2\'';+CREATE TABLE posthog.kafka_cohort_membership (+ team_id Int64,+ cohort_id Int64,+ person_id UUID,+ status Enum8('entered'=1, 'left'=2, 'member'=3, 'not_member'=4),+ last_updated DateTime64(6)+) ENGINE = Kafka() SETTINGS kafka_broker_list = 'msk_cluster', kafka_format = 'kafka_format = \'JSONEachRow\'', kafka_group_name = 'kafka_group_name = \'clickhouse_cohort_membership_changed\'', kafka_topic_list = 'kafka_topic_list = \'cohort_membership_changed\'';+CREATE TABLE posthog.kafka_distinct_id_usage (+ team_id Int64,+ distinct_id String,+ timestamp DateTime64(6, 'UTC')+) ENGINE = Kafka() SETTINGS kafka_broker_list = 'warpstream_ingestion', kafka_format = 'kafka_format = \'JSONEachRow\'', kafka_group_name = 'kafka_group_name = \'clickhouse_distinct_id_usage\'', kafka_skip_broken_messages = 100, kafka_topic_list = 'kafka_topic_list = \'distinct_id_usage_events_json\'';+CREATE TABLE posthog.kafka_flag_evaluations (+ uuid UUID,+ event LowCardinality(String),+ properties String,+ timestamp DateTime64(6, 'UTC'),+ team_id Int64,+ distinct_id String,+ created_at DateTime64(6, 'UTC'),+ person_id UUID,+ person_properties String,+ group0_properties String,+ group1_properties String,+ group2_properties String,+ group3_properties String,+ group4_properties String,+ inserted_at DateTime64(6, 'UTC')+) ENGINE = Kafka() SETTINGS kafka_broker_list = 'warpstream_ingestion', kafka_format = 'kafka_format = \'JSONEachRow\'', kafka_group_name = 'kafka_group_name = \'clickhouse_flag_evaluations\'', kafka_skip_broken_messages = 100, kafka_topic_list = 'kafka_topic_list = \'clickhouse_flag_evaluations\'';+CREATE TABLE posthog.kafka_heatmaps (+ session_id String,+ team_id Int64,+ distinct_id String,+ timestamp DateTime64(6, 'UTC'),+ x Int16,+ y Int16,+ scale_factor Int16,+ viewport_width Int16,+ viewport_height Int16,+ pointer_target_fixed Bool,+ current_url String,+ type LowCardinality(String)+) ENGINE = Kafka() SETTINGS kafka_broker_list = 'msk_cluster', kafka_format = 'kafka_format = \'JSONEachRow\'', kafka_group_name = 'kafka_group_name = \'group1\'', kafka_topic_list = 'kafka_topic_list = \'clickhouse_heatmap_events\'';+CREATE TABLE posthog.kafka_precalculated_events (+ team_id Int64,+ date Nullable(Date),+ distinct_id String,+ person_id UUID,+ condition String,+ uuid UUID,+ source String+) ENGINE = Kafka() SETTINGS kafka_broker_list = 'msk_cluster', kafka_flush_interval_ms = 7500, kafka_format = 'kafka_format = \'JSONEachRow\'', kafka_group_name = 'kafka_group_name = \'clickhouse_prefiltered_events\'', kafka_max_block_size = 1000000, kafka_num_consumers = 1, kafka_poll_max_batch_size = 100000, kafka_poll_timeout_ms = 1000, kafka_skip_broken_messages = 100, kafka_topic_list = 'kafka_topic_list = \'clickhouse_prefiltered_events\'';+CREATE TABLE posthog.kafka_precalculated_person_properties (+ team_id Int64,+ distinct_id String,+ person_id UUID,+ condition String,+ matches Bool,+ source String+) ENGINE = Kafka() SETTINGS kafka_broker_list = 'msk_cluster', kafka_flush_interval_ms = 7500, kafka_format = 'kafka_format = \'JSONEachRow\'', kafka_group_name = 'kafka_group_name = \'clickhouse_precalculated_person_properties\'', kafka_max_block_size = 1000000, kafka_num_consumers = 1, kafka_poll_max_batch_size = 100000, kafka_poll_timeout_ms = 1000, kafka_skip_broken_messages = 100, kafka_topic_list = 'kafka_topic_list = \'clickhouse_precalculated_person_properties\'';+CREATE TABLE posthog.kafka_precalculated_person_properties_ws (+ team_id Int64,+ distinct_id String,+ person_id UUID,+ condition String,+ matches Bool,+ source String+) ENGINE = Kafka() SETTINGS kafka_broker_list = 'warpstream_calculated_events', kafka_flush_interval_ms = 7500, kafka_format = 'kafka_format = \'JSONEachRow\'', kafka_group_name = 'kafka_group_name = \'clickhouse_precalculated_person_properties_ws\'', kafka_max_block_size = 1000000, kafka_num_consumers = 1, kafka_poll_max_batch_size = 100000, kafka_poll_timeout_ms = 1000, kafka_skip_broken_messages = 100, kafka_topic_list = 'kafka_topic_list = \'clickhouse_precalculated_person_properties\'';+CREATE TABLE posthog.kafka_session_replay_features (+ session_id String,+ team_id Int64,+ distinct_id String,+ batch_id String,+ first_timestamp DateTime64(6, 'UTC'),+ last_timestamp DateTime64(6, 'UTC'),+ event_count Int64,+ mouse_position_count Int64,+ mouse_sum_x Float64,+ mouse_sum_x_squared Float64,+ mouse_sum_y Float64,+ mouse_sum_y_squared Float64,+ mouse_distance_traveled Float64,+ mouse_direction_change_count Int64,+ mouse_velocity_sum Float64,+ mouse_velocity_sum_of_squares Float64,+ mouse_velocity_count Int64,+ scroll_event_count Int64,+ total_scroll_magnitude Float64,+ scroll_direction_reversal_count Int64,+ rapid_scroll_reversal_count Int64,+ scroll_to_top_count Int64,+ click_count Int64,+ keypress_count Int64,+ mouse_activity_count Int64,+ rage_click_count Int64,+ dead_click_count Int64,+ backspace_count Int64,+ inter_action_gap_count Int64,+ inter_action_gap_sum_ms Float64,+ inter_action_gap_sum_of_squares_ms Float64,+ max_idle_gap_ms Float64,+ long_idle_gap_count Int64,+ quick_back_count Int64,+ page_visit_count Int64,+ visited_urls Array(String),+ login_path_visit_count Int64,+ signup_path_visit_count Int64,+ checkout_path_visit_count Int64,+ cart_path_visit_count Int64,+ billing_path_visit_count Int64,+ settings_path_visit_count Int64,+ account_path_visit_count Int64,+ error_path_visit_count Int64,+ not_found_path_visit_count Int64,+ admin_path_visit_count Int64,+ dashboard_path_visit_count Int64,+ onboarding_path_visit_count Int64,+ cancel_path_visit_count Int64,+ refund_path_visit_count Int64,+ console_error_count Int64,+ console_error_after_click_count Int64,+ console_warn_count Int64,+ network_request_count Int64,+ network_failed_request_count Int64,+ network_4xx_count Int64,+ network_5xx_count Int64,+ network_request_duration_sum Float64,+ network_request_duration_sum_of_squares Float64,+ network_request_duration_count Int64,+ mutation_count Int64,+ viewport_resize_count Int64,+ touch_event_count Int64,+ max_scroll_y Float64,+ click_target_ids Array(Int64),+ form_field_ids Array(Int64),+ text_selection_count Int64,+ selection_copy_count Int64,+ is_deleted UInt8+) ENGINE = Kafka() SETTINGS kafka_broker_list = 'msk_cluster', kafka_format = 'kafka_format = \'JSONEachRow\'', kafka_group_name = 'kafka_group_name = \'group1\'', kafka_topic_list = 'kafka_topic_list = \'clickhouse_session_replay_features\'';+CREATE TABLE posthog.kafka_tophog (+ timestamp DateTime64(6, 'UTC'),+ metric LowCardinality(String),+ type LowCardinality(String),+ key Map(LowCardinality(String), String),+ value Float64,+ count UInt64,+ pipeline LowCardinality(String),+ lane LowCardinality(String),+ labels Map(LowCardinality(String), String)+) ENGINE = Kafka() SETTINGS date_time_input_format = 'best_effort', kafka_broker_list = 'msk_cluster', kafka_format = 'kafka_format = \'JSONEachRow\'', kafka_group_name = 'kafka_group_name = \'clickhouse_tophog\'', kafka_skip_broken_messages = 100, kafka_topic_list = 'kafka_topic_list = \'clickhouse_tophog\'';+CREATE TABLE posthog.kafka_tophog_ws (+ timestamp DateTime64(6, 'UTC'),+ metric LowCardinality(String),+ type LowCardinality(String),+ key Map(LowCardinality(String), String),+ value Float64,+ count UInt64,+ pipeline LowCardinality(String),+ lane LowCardinality(String),+ labels Map(LowCardinality(String), String)+) ENGINE = Kafka() SETTINGS date_time_input_format = 'best_effort', kafka_broker_list = 'warpstream_ingestion', kafka_format = 'kafka_format = \'JSONEachRow\'', kafka_group_name = 'kafka_group_name = \'clickhouse_tophog_ws\'', kafka_skip_broken_messages = 100, kafka_topic_list = 'kafka_topic_list = \'clickhouse_tophog\'';+CREATE TABLE posthog.query_log_archive (+ hostname LowCardinality(String),+ user LowCardinality(String),+ query_id String,+ initial_query_id String,+ is_initial_query UInt8,+ type Enum8('QueryStart'=1, 'QueryFinish'=2, 'ExceptionBeforeStart'=3, 'ExceptionWhileProcessing'=4),+ event_date Date,+ event_time DateTime,+ event_time_microseconds DateTime64(6),+ query_start_time DateTime,+ query_start_time_microseconds DateTime64(6),+ query_duration_ms UInt64,+ read_rows UInt64,+ read_bytes UInt64,+ written_rows UInt64,+ written_bytes UInt64,+ result_rows UInt64,+ result_bytes UInt64,+ memory_usage UInt64,+ peak_threads_usage UInt64,+ current_database LowCardinality(String),+ query String,+ formatted_query String,+ normalized_query_hash UInt64,+ query_kind LowCardinality(String),+ exception_code Int32,+ exception String,+ stack_trace String,+ team_id Int64,+ log_comment JSON(max_dynamic_paths=256, access_method LowCardinality(String), alert_config_id String, api_key_label String, api_key_mask String, batch_export_id String, chargeable Bool, client_query_id String, cohort_id Int64, `dagster.job_name` String, `dagster.run_id` String, `dagster.tags.owner` String, dashboard_id Int64, experiment_feature_flag_key String, experiment_id Int64, feature LowCardinality(String), id String, insight_id Int64, is_impersonated Bool, kind LowCardinality(String), name String, org_id String, person_on_events_mode LowCardinality(String), product LowCardinality(String), query_type LowCardinality(String), request_name String, route_id String, service_name String, session_id String, table_id String, team_id Int64, `temporal.activity_id` String, `temporal.activity_type` String, `temporal.attempt` Int64, `temporal.workflow_id` String, `temporal.workflow_namespace` String, `temporal.workflow_run_id` String, `temporal.workflow_type` String, user_id Int64, warehouse_query Bool, workflow LowCardinality(String), workload LowCardinality(String), SKIP cache_key, SKIP filter, SKIP hogql_features, SKIP http_referer, SKIP http_request_id, SKIP http_user_agent, SKIP query_settings, SKIP timings, SKIP user_email),+ ProfileEvents Map(String, UInt64),+ exception_name String ALIAS errorCodeToName(exception_code),+ ProfileEvents_RealTimeMicroseconds Int64 ALIAS ProfileEvents['RealTimeMicroseconds'],+ ProfileEvents_OSCPUVirtualTimeMicroseconds Int64 ALIAS ProfileEvents['OSCPUVirtualTimeMicroseconds'],+ ProfileEvents_S3Clients Int64 ALIAS ProfileEvents['S3Clients'],+ ProfileEvents_S3DeleteObjects Int64 ALIAS ProfileEvents['S3DeleteObjects'],+ ProfileEvents_S3CopyObject Int64 ALIAS ProfileEvents['S3CopyObject'],+ ProfileEvents_S3ListObjects Int64 ALIAS ProfileEvents['S3ListObjects'],+ ProfileEvents_S3HeadObject Int64 ALIAS ProfileEvents['S3HeadObject'],+ ProfileEvents_S3GetObjectAttributes Int64 ALIAS ProfileEvents['S3GetObjectAttributes'],+ ProfileEvents_S3CreateMultipartUpload Int64 ALIAS ProfileEvents['S3CreateMultipartUpload'],+ ProfileEvents_S3UploadPartCopy Int64 ALIAS ProfileEvents['S3UploadPartCopy'],+ ProfileEvents_S3UploadPart Int64 ALIAS ProfileEvents['S3UploadPart'],+ ProfileEvents_S3AbortMultipartUpload Int64 ALIAS ProfileEvents['S3AbortMultipartUpload'],+ ProfileEvents_S3CompleteMultipartUpload Int64 ALIAS ProfileEvents['S3CompleteMultipartUpload'],+ ProfileEvents_S3PutObject Int64 ALIAS ProfileEvents['S3PutObject'],+ ProfileEvents_S3GetObject Int64 ALIAS ProfileEvents['S3GetObject'],+ ProfileEvents_ReadBufferFromS3Bytes Int64 ALIAS ProfileEvents['ReadBufferFromS3Bytes'],+ ProfileEvents_WriteBufferFromS3Bytes Int64 ALIAS ProfileEvents['WriteBufferFromS3Bytes'],+ lc_workflow LowCardinality(String) ALIAS log_comment.workflow,+ lc_kind LowCardinality(String) ALIAS log_comment.kind,+ lc_id String ALIAS CAST(log_comment.id, 'String'),+ lc_route_id String ALIAS CAST(log_comment.route_id, 'String'),+ lc_access_method LowCardinality(String) ALIAS log_comment.access_method,+ lc_api_key_label String ALIAS CAST(log_comment.api_key_label, 'String'),+ lc_api_key_mask String ALIAS CAST(log_comment.api_key_mask, 'String'),+ lc_query_type LowCardinality(String) ALIAS log_comment.query_type,+ lc_product LowCardinality(String) ALIAS log_comment.product,+ lc_chargeable Bool ALIAS log_comment.chargeable,+ lc_name String ALIAS CAST(log_comment.name, 'String'),+ lc_request_name String ALIAS CAST(log_comment.request_name, 'String'),+ lc_client_query_id String ALIAS CAST(log_comment.client_query_id, 'String'),+ lc_org_id String ALIAS CAST(log_comment.org_id, 'String'),+ lc_user_id Int64 ALIAS log_comment.user_id,+ lc_is_impersonated Bool ALIAS log_comment.is_impersonated,+ lc_session_id String ALIAS CAST(log_comment.session_id, 'String'),+ lc_dashboard_id Int64 ALIAS log_comment.dashboard_id,+ lc_insight_id Int64 ALIAS log_comment.insight_id,+ lc_cohort_id Int64 ALIAS log_comment.cohort_id,+ lc_batch_export_id String ALIAS CAST(log_comment.batch_export_id, 'String'),+ lc_experiment_id Int64 ALIAS log_comment.experiment_id,+ lc_experiment_feature_flag_key String ALIAS CAST(log_comment.experiment_feature_flag_key, 'String'),+ lc_alert_config_id String ALIAS CAST(log_comment.alert_config_id, 'String'),+ lc_feature LowCardinality(String) ALIAS log_comment.feature,+ lc_table_id String ALIAS CAST(log_comment.table_id, 'String'),+ lc_warehouse_query Bool ALIAS log_comment.warehouse_query,+ lc_person_on_events_mode LowCardinality(String) ALIAS log_comment.person_on_events_mode,+ lc_service_name String ALIAS CAST(log_comment.service_name, 'String'),+ lc_workload LowCardinality(String) ALIAS log_comment.workload,+ lc_query__kind LowCardinality(String) ALIAS if(JSONHas(toString(log_comment), 'query', 'source'), JSONExtractString(toString(log_comment), 'query', 'source', 'kind'), JSONExtractString(toString(log_comment), 'query', 'kind')),+ lc_query__query String ALIAS multiIf(NOT is_initial_query, '', JSONHas(toString(log_comment), 'query', 'source'), JSONExtractString(toString(log_comment), 'query', 'source', 'query'), JSONExtractString(toString(log_comment), 'query', 'query')),+ lc_query String ALIAS if(is_initial_query, JSONExtractRaw(toString(log_comment), 'query'), ''),+ lc_temporal__workflow_namespace String ALIAS CAST(log_comment.`temporal.workflow_namespace`, 'String'),+ lc_temporal__workflow_type String ALIAS CAST(log_comment.`temporal.workflow_type`, 'String'),+ lc_temporal__workflow_id String ALIAS CAST(log_comment.`temporal.workflow_id`, 'String'),+ lc_temporal__workflow_run_id String ALIAS CAST(log_comment.`temporal.workflow_run_id`, 'String'),+ lc_temporal__activity_type String ALIAS CAST(log_comment.`temporal.activity_type`, 'String'),+ lc_temporal__activity_id String ALIAS CAST(log_comment.`temporal.activity_id`, 'String'),+ lc_temporal__attempt Int64 ALIAS log_comment.`temporal.attempt`,+ lc_dagster__job_name String ALIAS CAST(log_comment.`dagster.job_name`, 'String'),+ lc_dagster__run_id String ALIAS CAST(log_comment.`dagster.run_id`, 'String'),+ 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.writable_app_metrics2 (+ team_id Int64,+ timestamp DateTime64(6, 'UTC'),+ app_source LowCardinality(String),+ app_source_id String,+ instance_id String,+ metric_kind LowCardinality(String),+ metric_name LowCardinality(String),+ count SimpleAggregateFunction(sum, Int64),+ _timestamp DateTime,+ _offset UInt64,+ _partition UInt64+) ENGINE = Distributed('posthog', 'posthog', 'sharded_app_metrics2', rand());+CREATE TABLE posthog.writable_cohort_membership (+ team_id Int64,+ cohort_id Int64,+ person_id UUID,+ status Enum8('entered'=1, 'left'=2),+ last_updated DateTime64(6) DEFAULT now64()+) ENGINE = Distributed('posthog_single_shard', 'posthog', 'cohort_membership');+CREATE TABLE posthog.writable_distinct_id_usage (+ team_id Int64,+ distinct_id String,+ minute DateTime,+ event_count UInt64+) ENGINE = Distributed('posthog', 'posthog', 'sharded_distinct_id_usage', sipHash64(distinct_id));+CREATE TABLE posthog.writable_flag_evaluations (+ uuid UUID,+ event LowCardinality(String),+ properties String,+ timestamp DateTime64(6, 'UTC'),+ team_id Int64,+ distinct_id String,+ created_at DateTime64(6, 'UTC'),+ person_id UUID,+ person_properties String,+ group0_properties String,+ group1_properties String,+ group2_properties String,+ group3_properties String,+ group4_properties String,+ inserted_at DateTime64(6, 'UTC') DEFAULT timestamp,+ _timestamp DateTime,+ _offset UInt64,+ _partition UInt64+) ENGINE = Distributed('posthog', 'posthog', 'sharded_flag_evaluations', sipHash64(distinct_id));+CREATE TABLE posthog.writable_heatmaps (+ session_id String,+ team_id Int64,+ distinct_id String,+ timestamp DateTime64(6, 'UTC'),+ x Int16,+ y Int16,+ scale_factor Int16,+ viewport_width Int16,+ viewport_height Int16,+ pointer_target_fixed Bool,+ current_url String,+ type LowCardinality(String),+ _timestamp DateTime,+ _offset UInt64,+ _partition UInt64+) ENGINE = Distributed('posthog', 'posthog', 'sharded_heatmaps', cityHash64(concat(toString(team_id), '-', session_id, '-', toString(toDate(timestamp)))));+CREATE TABLE posthog.writable_precalculated_events (+ team_id Int64,+ date Date,+ distinct_id String,+ person_id UUID,+ condition String,+ uuid UUID,+ source String,+ _timestamp DateTime64(6),+ _partition UInt64,+ _offset UInt64+) ENGINE = Distributed('posthog', 'posthog', 'sharded_precalculated_events', sipHash64(distinct_id));+CREATE TABLE posthog.writable_precalculated_person_properties (+ team_id Int64,+ distinct_id String,+ person_id UUID,+ condition String,+ matches Bool,+ source String,+ _timestamp DateTime64(6),+ _offset UInt64+) ENGINE = Distributed('posthog', 'posthog', 'sharded_precalculated_person_properties', sipHash64(distinct_id));+CREATE TABLE posthog.writable_session_replay_features (+ session_id String,+ team_id Int64,+ distinct_id String,+ min_first_timestamp SimpleAggregateFunction(min, DateTime64(6, 'UTC')),+ max_last_timestamp SimpleAggregateFunction(max, DateTime64(6, 'UTC')),+ event_count SimpleAggregateFunction(sum, Int64),+ mouse_position_count SimpleAggregateFunction(sum, Int64),+ mouse_sum_x SimpleAggregateFunction(sum, Float64),+ mouse_sum_x_squared SimpleAggregateFunction(sum, Float64),+ mouse_sum_y SimpleAggregateFunction(sum, Float64),+ mouse_sum_y_squared SimpleAggregateFunction(sum, Float64),+ mouse_distance_traveled SimpleAggregateFunction(sum, Float64),+ mouse_direction_change_count SimpleAggregateFunction(sum, Int64),+ mouse_velocity_sum SimpleAggregateFunction(sum, Float64),+ mouse_velocity_sum_of_squares SimpleAggregateFunction(sum, Float64),+ mouse_velocity_count SimpleAggregateFunction(sum, Int64),+ scroll_event_count SimpleAggregateFunction(sum, Int64),+ total_scroll_magnitude SimpleAggregateFunction(sum, Float64),+ scroll_direction_reversal_count SimpleAggregateFunction(sum, Int64),+ rapid_scroll_reversal_count SimpleAggregateFunction(sum, Int64),+ scroll_to_top_count SimpleAggregateFunction(sum, Int64),+ click_count SimpleAggregateFunction(sum, Int64),+ keypress_count SimpleAggregateFunction(sum, Int64),+ mouse_activity_count SimpleAggregateFunction(sum, Int64),+ rage_click_count SimpleAggregateFunction(sum, Int64),+ dead_click_count SimpleAggregateFunction(sum, Int64),+ backspace_count SimpleAggregateFunction(sum, Int64),+ inter_action_gap_count SimpleAggregateFunction(sum, Int64),+ inter_action_gap_sum_ms SimpleAggregateFunction(sum, Float64),+ inter_action_gap_sum_of_squares_ms SimpleAggregateFunction(sum, Float64),+ max_idle_gap_ms SimpleAggregateFunction(max, Float64),+ long_idle_gap_count SimpleAggregateFunction(sum, Int64),+ quick_back_count SimpleAggregateFunction(sum, Int64),+ page_visit_count SimpleAggregateFunction(sum, Int64),+ unique_url_count AggregateFunction(uniqCombined(12), String),+ login_path_visit_count SimpleAggregateFunction(sum, Int64),+ signup_path_visit_count SimpleAggregateFunction(sum, Int64),+ checkout_path_visit_count SimpleAggregateFunction(sum, Int64),+ cart_path_visit_count SimpleAggregateFunction(sum, Int64),+ billing_path_visit_count SimpleAggregateFunction(sum, Int64),+ settings_path_visit_count SimpleAggregateFunction(sum, Int64),+ account_path_visit_count SimpleAggregateFunction(sum, Int64),+ error_path_visit_count SimpleAggregateFunction(sum, Int64),+ not_found_path_visit_count SimpleAggregateFunction(sum, Int64),+ admin_path_visit_count SimpleAggregateFunction(sum, Int64),+ dashboard_path_visit_count SimpleAggregateFunction(sum, Int64),+ onboarding_path_visit_count SimpleAggregateFunction(sum, Int64),+ cancel_path_visit_count SimpleAggregateFunction(sum, Int64),+ refund_path_visit_count SimpleAggregateFunction(sum, Int64),+ console_error_count SimpleAggregateFunction(sum, Int64),+ console_error_after_click_count SimpleAggregateFunction(sum, Int64),+ console_warn_count SimpleAggregateFunction(sum, Int64),+ network_request_count SimpleAggregateFunction(sum, Int64),+ network_failed_request_count SimpleAggregateFunction(sum, Int64),+ network_4xx_count SimpleAggregateFunction(sum, Int64),+ network_5xx_count SimpleAggregateFunction(sum, Int64),+ network_request_duration_sum SimpleAggregateFunction(sum, Float64),+ network_request_duration_sum_of_squares SimpleAggregateFunction(sum, Float64),+ network_request_duration_count SimpleAggregateFunction(sum, Int64),+ mutation_count SimpleAggregateFunction(sum, Int64),+ viewport_resize_count SimpleAggregateFunction(sum, Int64),+ touch_event_count SimpleAggregateFunction(sum, Int64),+ max_scroll_y SimpleAggregateFunction(max, Float64),+ unique_click_target_count AggregateFunction(uniqCombined(12), Int64),+ unique_form_field_count AggregateFunction(uniqCombined(12), Int64),+ text_selection_count SimpleAggregateFunction(sum, Int64),+ selection_copy_count SimpleAggregateFunction(sum, Int64),+ is_deleted SimpleAggregateFunction(max, UInt8) DEFAULT 0+) ENGINE = Distributed('aux', 'posthog', 'sharded_session_replay_features', sipHash64(session_id));+CREATE TABLE posthog.writable_tophog (+ timestamp DateTime64(6, 'UTC'),+ metric LowCardinality(String),+ type LowCardinality(String) DEFAULT 'sum',+ key Map(LowCardinality(String), String),+ value Float64,+ count UInt64 DEFAULT 0,+ pipeline LowCardinality(String),+ lane LowCardinality(String),+ labels Map(LowCardinality(String), String)+) ENGINE = Distributed('posthog', 'posthog', 'sharded_tophog', cityHash64(toString(key)));+CREATE MATERIALIZED VIEW posthog.app_metrics2_mv TO posthog.writable_app_metrics2 (team_id Int64, timestamp DateTime64(6, 'UTC'), app_source LowCardinality(String), app_source_id String, instance_id String, metric_kind String, metric_name String, count Int64, _timestamp Nullable(DateTime), _offset UInt64, _partition UInt64) AS SELECT+ team_id,+ timestamp,+ app_source,+ app_source_id,+ instance_id,+ metric_kind,+ metric_name,+ count,+ _timestamp,+ _offset,+ _partition+FROM posthog.kafka_app_metrics2;+CREATE MATERIALIZED VIEW posthog.app_metrics2_ws_mv TO posthog.writable_app_metrics2 (team_id Int64, timestamp DateTime64(6, 'UTC'), app_source LowCardinality(String), app_source_id String, instance_id String, metric_kind String, metric_name String, count Int64, _timestamp Nullable(DateTime), _offset UInt64, _partition UInt64) AS SELECT+ team_id,+ timestamp,+ app_source,+ app_source_id,+ instance_id,+ metric_kind,+ metric_name,+ count,+ _timestamp,+ _offset,+ _partition+FROM posthog.kafka_app_metrics2_ws;+CREATE MATERIALIZED VIEW posthog.cohort_membership_mv TO posthog.writable_cohort_membership (team_id Int64, cohort_id Int64, person_id UUID, status String, last_updated DateTime64(6)) AS SELECT+ team_id,+ cohort_id,+ person_id,+ multiIf(status = 'member', 'entered', status = 'not_member', 'left', status) AS status,+ last_updated+FROM posthog.kafka_cohort_membership;+CREATE MATERIALIZED VIEW posthog.distinct_id_usage_mv TO posthog.writable_distinct_id_usage (team_id Int64, distinct_id String, minute DateTime('UTC'), event_count UInt8) AS SELECT team_id, distinct_id, toStartOfMinute(timestamp) AS minute, 1 AS event_count+FROM posthog.kafka_distinct_id_usage;+CREATE MATERIALIZED VIEW posthog.flag_evaluations_mv TO posthog.writable_flag_evaluations (uuid UUID, event LowCardinality(String), properties String, timestamp DateTime64(6, 'UTC'), team_id Int64, distinct_id String, created_at DateTime64(6, 'UTC'), person_id UUID, person_properties String, group0_properties String, group1_properties String, group2_properties String, group3_properties String, group4_properties String, inserted_at Nullable(DateTime64(6, 'UTC')), _timestamp Nullable(DateTime), _offset UInt64, _partition UInt64) AS SELECT+ uuid,+ event,+ properties,+ timestamp,+ team_id,+ distinct_id,+ created_at,+ person_id,+ person_properties,+ group0_properties,+ group1_properties,+ group2_properties,+ group3_properties,+ group4_properties,+ if(inserted_at = toDateTime64('1970-01-01 00:00:00', 6, 'UTC'), _timestamp, inserted_at) AS inserted_at,+ _timestamp,+ _offset,+ _partition+FROM posthog.kafka_flag_evaluations;+CREATE MATERIALIZED VIEW posthog.heatmaps_mv TO posthog.writable_heatmaps (session_id String, team_id Int64, distinct_id String, timestamp DateTime64(6, 'UTC'), x Int16, y Int16, scale_factor Int16, viewport_width Int16, viewport_height Int16, pointer_target_fixed Bool, current_url String, type LowCardinality(String), _timestamp Nullable(DateTime), _offset UInt64, _partition UInt64) AS SELECT+ session_id,+ team_id,+ distinct_id,+ timestamp,+ x,+ y,+ scale_factor,+ viewport_width,+ viewport_height,+ pointer_target_fixed,+ current_url,+ type,+ _timestamp,+ _offset,+ _partition+FROM posthog.kafka_heatmaps;+CREATE MATERIALIZED VIEW posthog.precalculated_events_mv TO posthog.writable_precalculated_events (team_id Int64, date Nullable(Date), distinct_id String, person_id UUID, condition String, uuid UUID, source String, _timestamp Nullable(DateTime), _offset UInt64, _partition UInt64) AS SELECT+ team_id,+ ifNull(date, toDate(_timestamp)) AS date,+ distinct_id,+ person_id,+ condition,+ uuid,+ source,+ _timestamp,+ _offset,+ _partition+FROM posthog.kafka_precalculated_events;+CREATE MATERIALIZED VIEW posthog.precalculated_person_properties_mv TO posthog.writable_precalculated_person_properties (team_id Int64, distinct_id String, person_id UUID, condition String, matches Bool, source String, _timestamp Nullable(DateTime), _offset UInt64) AS SELECT+ team_id,+ distinct_id,+ person_id,+ condition,+ matches,+ source,+ _timestamp,+ _offset+FROM posthog.kafka_precalculated_person_properties;+CREATE MATERIALIZED VIEW posthog.precalculated_person_properties_ws_mv TO posthog.writable_precalculated_person_properties (team_id Int64, distinct_id String, person_id UUID, condition String, matches Bool, source String, _timestamp Nullable(DateTime), _offset UInt64) AS SELECT+ team_id,+ distinct_id,+ person_id,+ condition,+ matches,+ source,+ _timestamp,+ _offset+FROM posthog.kafka_precalculated_person_properties_ws;+CREATE MATERIALIZED VIEW posthog.session_replay_features_mv TO posthog.writable_session_replay_features (session_id String, team_id Int64, distinct_id String, min_first_timestamp DateTime64(6, 'UTC'), max_last_timestamp DateTime64(6, 'UTC'), event_count Int64, mouse_position_count Int64, mouse_sum_x Float64, mouse_sum_x_squared Float64, mouse_sum_y Float64, mouse_sum_y_squared Float64, mouse_distance_traveled Float64, mouse_direction_change_count Int64, mouse_velocity_sum Float64, mouse_velocity_sum_of_squares Float64, mouse_velocity_count Int64, scroll_event_count Int64, total_scroll_magnitude Float64, scroll_direction_reversal_count Int64, rapid_scroll_reversal_count Int64, scroll_to_top_count Int64, click_count Int64, keypress_count Int64, mouse_activity_count Int64, rage_click_count Int64, dead_click_count Int64, backspace_count Int64, inter_action_gap_count Int64, inter_action_gap_sum_ms Float64, inter_action_gap_sum_of_squares_ms Float64, max_idle_gap_ms Float64, long_idle_gap_count Int64, quick_back_count Int64, page_visit_count Int64, unique_url_count AggregateFunction(uniqCombinedArray(12), Array(String)), login_path_visit_count Int64, signup_path_visit_count Int64, checkout_path_visit_count Int64, cart_path_visit_count Int64, billing_path_visit_count Int64, settings_path_visit_count Int64, account_path_visit_count Int64, error_path_visit_count Int64, not_found_path_visit_count Int64, admin_path_visit_count Int64, dashboard_path_visit_count Int64, onboarding_path_visit_count Int64, cancel_path_visit_count Int64, refund_path_visit_count Int64, console_error_count Int64, console_error_after_click_count Int64, console_warn_count Int64, network_request_count Int64, network_failed_request_count Int64, network_4xx_count Int64, network_5xx_count Int64, network_request_duration_sum Float64, network_request_duration_sum_of_squares Float64, network_request_duration_count Int64, mutation_count Int64, viewport_resize_count Int64, touch_event_count Int64, max_scroll_y Float64, unique_click_target_count AggregateFunction(uniqCombinedArray(12), Array(Int64)), unique_form_field_count AggregateFunction(uniqCombinedArray(12), Array(Int64)), text_selection_count Int64, selection_copy_count Int64, is_deleted UInt8) AS SELECT+ session_id,+ team_id,+ any(distinct_id) AS distinct_id,+ min(first_timestamp) AS min_first_timestamp,+ max(last_timestamp) AS max_last_timestamp,+ sum(event_count) AS event_count,+ sum(mouse_position_count) AS mouse_position_count,+ sum(mouse_sum_x) AS mouse_sum_x,+ sum(mouse_sum_x_squared) AS mouse_sum_x_squared,+ sum(mouse_sum_y) AS mouse_sum_y,+ sum(mouse_sum_y_squared) AS mouse_sum_y_squared,+ sum(mouse_distance_traveled) AS mouse_distance_traveled,+ sum(mouse_direction_change_count) AS mouse_direction_change_count,+ sum(mouse_velocity_sum) AS mouse_velocity_sum,+ sum(mouse_velocity_sum_of_squares) AS mouse_velocity_sum_of_squares,+ sum(mouse_velocity_count) AS mouse_velocity_count,+ sum(scroll_event_count) AS scroll_event_count,+ sum(total_scroll_magnitude) AS total_scroll_magnitude,+ sum(scroll_direction_reversal_count) AS scroll_direction_reversal_count,+ sum(rapid_scroll_reversal_count) AS rapid_scroll_reversal_count,+ sum(scroll_to_top_count) AS scroll_to_top_count,+ sum(click_count) AS click_count,+ sum(keypress_count) AS keypress_count,+ sum(mouse_activity_count) AS mouse_activity_count,+ sum(rage_click_count) AS rage_click_count,+ sum(dead_click_count) AS dead_click_count,+ sum(backspace_count) AS backspace_count,+ sum(inter_action_gap_count) AS inter_action_gap_count,+ sum(inter_action_gap_sum_ms) AS inter_action_gap_sum_ms,+ sum(inter_action_gap_sum_of_squares_ms) AS inter_action_gap_sum_of_squares_ms,+ max(max_idle_gap_ms) AS max_idle_gap_ms,+ sum(long_idle_gap_count) AS long_idle_gap_count,+ sum(quick_back_count) AS quick_back_count,+ sum(page_visit_count) AS page_visit_count,+ uniqCombinedArrayState(12)(visited_urls) AS unique_url_count,+ sum(login_path_visit_count) AS login_path_visit_count,+ sum(signup_path_visit_count) AS signup_path_visit_count,+ sum(checkout_path_visit_count) AS checkout_path_visit_count,+ sum(cart_path_visit_count) AS cart_path_visit_count,+ sum(billing_path_visit_count) AS billing_path_visit_count,+ sum(settings_path_visit_count) AS settings_path_visit_count,+ sum(account_path_visit_count) AS account_path_visit_count,+ sum(error_path_visit_count) AS error_path_visit_count,+ sum(not_found_path_visit_count) AS not_found_path_visit_count,+ sum(admin_path_visit_count) AS admin_path_visit_count,+ sum(dashboard_path_visit_count) AS dashboard_path_visit_count,+ sum(onboarding_path_visit_count) AS onboarding_path_visit_count,+ sum(cancel_path_visit_count) AS cancel_path_visit_count,+ sum(refund_path_visit_count) AS refund_path_visit_count,+ sum(console_error_count) AS console_error_count,+ sum(console_error_after_click_count) AS console_error_after_click_count,+ sum(console_warn_count) AS console_warn_count,+ sum(network_request_count) AS network_request_count,+ sum(network_failed_request_count) AS network_failed_request_count,+ sum(network_4xx_count) AS network_4xx_count,+ sum(network_5xx_count) AS network_5xx_count,+ sum(network_request_duration_sum) AS network_request_duration_sum,+ sum(network_request_duration_sum_of_squares) AS network_request_duration_sum_of_squares,+ sum(network_request_duration_count) AS network_request_duration_count,+ sum(mutation_count) AS mutation_count,+ sum(viewport_resize_count) AS viewport_resize_count,+ sum(touch_event_count) AS touch_event_count,+ max(max_scroll_y) AS max_scroll_y,+ uniqCombinedArrayState(12)(click_target_ids) AS unique_click_target_count,+ uniqCombinedArrayState(12)(form_field_ids) AS unique_form_field_count,+ sum(text_selection_count) AS text_selection_count,+ sum(selection_copy_count) AS selection_copy_count,+ max(is_deleted) AS is_deleted+FROM posthog.kafka_session_replay_features+GROUP BY+ session_id, team_id;+CREATE MATERIALIZED VIEW posthog.tophog_mv TO posthog.writable_tophog (timestamp DateTime64(6, 'UTC'), metric LowCardinality(String), type LowCardinality(String), key Map(LowCardinality(String), String), value Float64, count UInt64, pipeline LowCardinality(String), lane LowCardinality(String), labels Map(LowCardinality(String), String)) AS SELECT+ timestamp,+ metric,+ type,+ key,+ value,+ count,+ pipeline,+ lane,+ labels+FROM posthog.kafka_tophog;+CREATE MATERIALIZED VIEW posthog.tophog_ws_mv TO posthog.writable_tophog (timestamp DateTime64(6, 'UTC'), metric LowCardinality(String), type LowCardinality(String), key Map(LowCardinality(String), String), value Float64, count UInt64, pipeline LowCardinality(String), lane LowCardinality(String), labels Map(LowCardinality(String), String)) AS SELECT+ timestamp,+ metric,+ type,+ key,+ value,+ count,+ pipeline,+ lane,+ labels+FROM posthog.kafka_tophog_ws;diff --git a/posthog/clickhouse/hcl/sql/local-multi/ingestion_small.sql b/posthog/clickhouse/hcl/sql/local-multi/ingestion_small.sqlnew file mode 100644index 000000000000..a040739b82aa--- /dev/null+++ b/posthog/clickhouse/hcl/sql/local-multi/ingestion_small.sql@@ -0,0 +1,735 @@+-- AUTO-GENERATED from the declarative HCL by ops/gen-sql.sh — do not edit.+-- Full CREATE schema for the local-multi/small node. Apply to a fresh ClickHouse to build it.++CREATE TABLE posthog.kafka_app_metrics (+ team_id Int64,+ timestamp DateTime64(6, 'UTC'),+ plugin_config_id Int64,+ category LowCardinality(String),+ job_id String,+ successes Int64,+ successes_on_retry Int64,+ failures Int64,+ error_uuid UUID,+ error_type String,+ error_details String CODEC(ZSTD(3))+) ENGINE = Kafka() SETTINGS kafka_broker_list = 'msk_cluster', kafka_format = 'kafka_format = \'JSONEachRow\'', kafka_group_name = 'kafka_group_name = \'group1\'', kafka_topic_list = 'kafka_topic_list = \'clickhouse_app_metrics\'';+CREATE TABLE posthog.kafka_duplicate_events (+ team_id Int64,+ distinct_id String,+ event String,+ source_uuid UUID,+ duplicate_uuid UUID,+ similarity_score Float64,+ dedup_type LowCardinality(String),+ is_confirmed UInt8,+ reason Nullable(String),+ version String,+ different_property_count UInt32,+ properties_similarity Float64,+ source_message String,+ duplicate_message String,+ distinct_fields String,+ inserted_at DateTime64(3, 'UTC')+) ENGINE = Kafka() SETTINGS kafka_broker_list = 'msk_cluster', kafka_format = 'kafka_format = \'JSONEachRow\'', kafka_group_name = 'kafka_group_name = \'clickhouse_duplicate_events\'', kafka_topic_list = 'kafka_topic_list = \'clickhouse_ingestion_events_duplicates\'';+CREATE TABLE posthog.kafka_error_tracking_issue_fingerprint_embeddings (+ team_id Int64,+ model_name LowCardinality(String),+ embedding_version Int64,+ fingerprint String,+ inserted_at DateTime64(3, 'UTC'),+ embeddings Array(Float64)+) ENGINE = Kafka() SETTINGS kafka_broker_list = 'msk_cluster', kafka_format = 'kafka_format = \'JSONEachRow\'', kafka_group_name = 'kafka_group_name = \'clickhouse_error_tracking_fingerprint_embeddings\'', kafka_topic_list = 'kafka_topic_list = \'clickhouse_error_tracking_issue_fingerprint_embeddings\'';+CREATE TABLE posthog.kafka_error_tracking_issue_fingerprint_overrides (+ team_id Int64,+ fingerprint String,+ issue_id UUID,+ is_deleted Int8,+ version Int64+) ENGINE = Kafka() SETTINGS kafka_broker_list = 'msk_cluster', kafka_format = 'kafka_format = \'JSONEachRow\'', kafka_group_name = 'kafka_group_name = \'clickhouse-error-tracking-issue-fingerprint-overrides\'', kafka_topic_list = 'kafka_topic_list = \'clickhouse_error_tracking_issue_fingerprint\'';+CREATE TABLE posthog.kafka_events_dead_letter_queue (+ id UUID,+ event_uuid UUID,+ event String,+ properties String,+ distinct_id String,+ team_id Int64,+ elements_chain String,+ created_at DateTime64(6, 'UTC'),+ ip String,+ site_url String,+ now DateTime64(6, 'UTC'),+ raw_payload String,+ error_timestamp DateTime64(6, 'UTC'),+ error_location String,+ error String,+ tags Array(String)+) ENGINE = Kafka() SETTINGS kafka_broker_list = 'msk_cluster', kafka_format = 'kafka_format = \'JSONEachRow\'', kafka_group_name = 'kafka_group_name = \'group1\'', kafka_skip_broken_messages = 1000, kafka_topic_list = 'kafka_topic_list = \'events_dead_letter_queue\'';+CREATE TABLE posthog.kafka_groups (+ group_type_index UInt8,+ group_key String,+ created_at DateTime64(3),+ team_id Int64,+ group_properties String+) ENGINE = Kafka() SETTINGS kafka_broker_list = 'msk_cluster', kafka_format = 'kafka_format = \'JSONEachRow\'', kafka_group_name = 'kafka_group_name = \'group1\'', kafka_topic_list = 'kafka_topic_list = \'clickhouse_groups\'';+CREATE TABLE posthog.kafka_ingestion_warnings (+ team_id Int64,+ source LowCardinality(String),+ type String,+ details String CODEC(ZSTD(3)),+ timestamp DateTime64(6, 'UTC')+) ENGINE = Kafka() SETTINGS kafka_broker_list = 'msk_cluster', kafka_format = 'kafka_format = \'JSONEachRow\'', kafka_group_name = 'kafka_group_name = \'group1\'', kafka_topic_list = 'kafka_topic_list = \'clickhouse_ingestion_warnings\'';+CREATE TABLE posthog.kafka_log_entries_v3 (+ team_id UInt64,+ log_source LowCardinality(String),+ log_source_id String,+ instance_id String,+ timestamp DateTime64(6, 'UTC'),+ level LowCardinality(String),+ message String+) ENGINE = Kafka() SETTINGS kafka_broker_list = 'msk_cluster', kafka_format = 'kafka_format = \'JSONEachRow\'', kafka_group_name = 'kafka_group_name = \'clickhouse_log_entries\'', kafka_skip_broken_messages = 100, kafka_topic_list = 'kafka_topic_list = \'log_entries\'';+CREATE TABLE posthog.kafka_log_entries_ws (+ team_id UInt64,+ log_source LowCardinality(String),+ log_source_id String,+ instance_id String,+ timestamp DateTime64(6, 'UTC'),+ level LowCardinality(String),+ message String+) ENGINE = Kafka() SETTINGS kafka_broker_list = 'warpstream_ingestion', kafka_format = 'kafka_format = \'JSONEachRow\'', kafka_group_name = 'kafka_group_name = \'clickhouse_log_entries_ws\'', kafka_skip_broken_messages = 100, kafka_topic_list = 'kafka_topic_list = \'log_entries\'';+CREATE TABLE posthog.kafka_person (+ id UUID,+ created_at DateTime64(3),+ team_id Int64,+ properties String,+ is_identified Int8,+ is_deleted Int8,+ version UInt64,+ last_seen_at Nullable(DateTime64(3))+) ENGINE = Kafka() SETTINGS kafka_broker_list = 'msk_cluster', kafka_format = 'kafka_format = \'JSONEachRow\'', kafka_group_name = 'kafka_group_name = \'group1\'', kafka_topic_list = 'kafka_topic_list = \'clickhouse_person\'';+CREATE TABLE posthog.kafka_person_distinct_id2 (+ team_id Int64,+ distinct_id String,+ person_id UUID,+ is_deleted Int8,+ version Int64+) ENGINE = Kafka() SETTINGS kafka_broker_list = 'msk_cluster', kafka_format = 'kafka_format = \'JSONEachRow\'', kafka_group_name = 'kafka_group_name = \'group1\'', kafka_topic_list = 'kafka_topic_list = \'clickhouse_person_distinct_id\'';+CREATE TABLE posthog.kafka_person_distinct_id_overrides (+ team_id Int64,+ distinct_id String,+ person_id UUID,+ is_deleted Int8,+ version Int64+) ENGINE = Kafka() SETTINGS kafka_broker_list = 'msk_cluster', kafka_format = 'kafka_format = \'JSONEachRow\'', kafka_group_name = 'kafka_group_name = \'clickhouse-person-distinct-id-overrides\'', kafka_topic_list = 'kafka_topic_list = \'clickhouse_person_distinct_id\'';+CREATE TABLE posthog.kafka_plugin_log_entries (+ id UUID,+ team_id Int64,+ plugin_id Int64,+ plugin_config_id Int64,+ timestamp DateTime64(6, 'UTC'),+ source String,+ type String,+ message String,+ instance_id UUID+) ENGINE = Kafka() SETTINGS kafka_broker_list = 'msk_cluster', kafka_format = 'kafka_format = \'JSONEachRow\'', kafka_group_name = 'kafka_group_name = \'group1\'', kafka_topic_list = 'kafka_topic_list = \'plugin_log_entries\'';+CREATE TABLE posthog.kafka_posthog_document_embeddings (+ team_id Int64,+ product LowCardinality(String),+ document_type LowCardinality(String),+ model_name LowCardinality(String),+ rendering LowCardinality(String),+ document_id String,+ timestamp DateTime64(3, 'UTC'),+ inserted_at DateTime64(3, 'UTC'),+ content String,+ metadata String,+ embedding Array(Float64)+) ENGINE = Kafka() SETTINGS kafka_broker_list = 'msk_cluster', kafka_format = 'kafka_format = \'JSONEachRow\'', kafka_group_name = 'kafka_group_name = \'clickhouse_document_embeddings\'', kafka_topic_list = 'kafka_topic_list = \'clickhouse_document_embeddings\'';+CREATE TABLE posthog.kafka_session_replay_events (+ session_id String,+ team_id Int64,+ distinct_id String,+ first_timestamp DateTime64(6, 'UTC'),+ last_timestamp DateTime64(6, 'UTC'),+ block_url Nullable(String),+ first_url Nullable(String),+ urls Array(String),+ click_count Int64,+ keypress_count Int64,+ mouse_activity_count Int64,+ active_milliseconds Int64,+ console_log_count Int64,+ console_warn_count Int64,+ console_error_count Int64,+ size Int64,+ event_count Int64,+ message_count Int64,+ snapshot_source LowCardinality(Nullable(String)),+ snapshot_library Nullable(String),+ retention_period_days Nullable(Int64),+ is_deleted UInt8,+ ai_tags_fixed Array(String),+ ai_tags_freeform Array(String),+ ai_highlighted UInt8,+ surfacing_score Nullable(Float32)+) ENGINE = Kafka() SETTINGS kafka_broker_list = 'msk_cluster', kafka_format = 'kafka_format = \'JSONEachRow\'', kafka_group_name = 'kafka_group_name = \'group1\'', kafka_topic_list = 'kafka_topic_list = \'clickhouse_session_replay_events\'';+CREATE TABLE posthog.kafka_usage_report_events_preagg (+ uuid UUID,+ event String,+ properties String CODEC(ZSTD(3)),+ timestamp DateTime64(6, 'UTC'),+ team_id Int64,+ distinct_id String,+ person_mode Enum8('full'=0, 'propertyless'=1, 'force_upgrade'=2)+) ENGINE = Kafka() SETTINGS kafka_broker_list = 'warpstream_ingestion', kafka_format = 'kafka_format = \'JSONEachRow\'', kafka_group_name = 'kafka_group_name = \'clickhouse_usage_report_events_preagg\'', kafka_num_consumers = 1, kafka_skip_broken_messages = 100, kafka_thread_per_consumer = 1, kafka_topic_list = 'kafka_topic_list = \'clickhouse_events_json\'';+CREATE TABLE posthog.query_log_archive (+ hostname LowCardinality(String),+ user LowCardinality(String),+ query_id String,+ initial_query_id String,+ is_initial_query UInt8,+ type Enum8('QueryStart'=1, 'QueryFinish'=2, 'ExceptionBeforeStart'=3, 'ExceptionWhileProcessing'=4),+ event_date Date,+ event_time DateTime,+ event_time_microseconds DateTime64(6),+ query_start_time DateTime,+ query_start_time_microseconds DateTime64(6),+ query_duration_ms UInt64,+ read_rows UInt64,+ read_bytes UInt64,+ written_rows UInt64,+ written_bytes UInt64,+ result_rows UInt64,+ result_bytes UInt64,+ memory_usage UInt64,+ peak_threads_usage UInt64,+ current_database LowCardinality(String),+ query String,+ formatted_query String,+ normalized_query_hash UInt64,+ query_kind LowCardinality(String),+ exception_code Int32,+ exception String,+ stack_trace String,+ team_id Int64,+ log_comment JSON(max_dynamic_paths=256, access_method LowCardinality(String), alert_config_id String, api_key_label String, api_key_mask String, batch_export_id String, chargeable Bool, client_query_id String, cohort_id Int64, `dagster.job_name` String, `dagster.run_id` String, `dagster.tags.owner` String, dashboard_id Int64, experiment_feature_flag_key String, experiment_id Int64, feature LowCardinality(String), id String, insight_id Int64, is_impersonated Bool, kind LowCardinality(String), name String, org_id String, person_on_events_mode LowCardinality(String), product LowCardinality(String), query_type LowCardinality(String), request_name String, route_id String, service_name String, session_id String, table_id String, team_id Int64, `temporal.activity_id` String, `temporal.activity_type` String, `temporal.attempt` Int64, `temporal.workflow_id` String, `temporal.workflow_namespace` String, `temporal.workflow_run_id` String, `temporal.workflow_type` String, user_id Int64, warehouse_query Bool, workflow LowCardinality(String), workload LowCardinality(String), SKIP cache_key, SKIP filter, SKIP hogql_features, SKIP http_referer, SKIP http_request_id, SKIP http_user_agent, SKIP query_settings, SKIP timings, SKIP user_email),+ ProfileEvents Map(String, UInt64),+ exception_name String ALIAS errorCodeToName(exception_code),+ ProfileEvents_RealTimeMicroseconds Int64 ALIAS ProfileEvents['RealTimeMicroseconds'],+ ProfileEvents_OSCPUVirtualTimeMicroseconds Int64 ALIAS ProfileEvents['OSCPUVirtualTimeMicroseconds'],+ ProfileEvents_S3Clients Int64 ALIAS ProfileEvents['S3Clients'],+ ProfileEvents_S3DeleteObjects Int64 ALIAS ProfileEvents['S3DeleteObjects'],+ ProfileEvents_S3CopyObject Int64 ALIAS ProfileEvents['S3CopyObject'],+ ProfileEvents_S3ListObjects Int64 ALIAS ProfileEvents['S3ListObjects'],+ ProfileEvents_S3HeadObject Int64 ALIAS ProfileEvents['S3HeadObject'],+ ProfileEvents_S3GetObjectAttributes Int64 ALIAS ProfileEvents['S3GetObjectAttributes'],+ ProfileEvents_S3CreateMultipartUpload Int64 ALIAS ProfileEvents['S3CreateMultipartUpload'],+ ProfileEvents_S3UploadPartCopy Int64 ALIAS ProfileEvents['S3UploadPartCopy'],+ ProfileEvents_S3UploadPart Int64 ALIAS ProfileEvents['S3UploadPart'],+ ProfileEvents_S3AbortMultipartUpload Int64 ALIAS ProfileEvents['S3AbortMultipartUpload'],+ ProfileEvents_S3CompleteMultipartUpload Int64 ALIAS ProfileEvents['S3CompleteMultipartUpload'],+ ProfileEvents_S3PutObject Int64 ALIAS ProfileEvents['S3PutObject'],+ ProfileEvents_S3GetObject Int64 ALIAS ProfileEvents['S3GetObject'],+ ProfileEvents_ReadBufferFromS3Bytes Int64 ALIAS ProfileEvents['ReadBufferFromS3Bytes'],+ ProfileEvents_WriteBufferFromS3Bytes Int64 ALIAS ProfileEvents['WriteBufferFromS3Bytes'],+ lc_workflow LowCardinality(String) ALIAS log_comment.workflow,+ lc_kind LowCardinality(String) ALIAS log_comment.kind,+ lc_id String ALIAS CAST(log_comment.id, 'String'),+ lc_route_id String ALIAS CAST(log_comment.route_id, 'String'),+ lc_access_method LowCardinality(String) ALIAS log_comment.access_method,+ lc_api_key_label String ALIAS CAST(log_comment.api_key_label, 'String'),+ lc_api_key_mask String ALIAS CAST(log_comment.api_key_mask, 'String'),+ lc_query_type LowCardinality(String) ALIAS log_comment.query_type,+ lc_product LowCardinality(String) ALIAS log_comment.product,+ lc_chargeable Bool ALIAS log_comment.chargeable,+ lc_name String ALIAS CAST(log_comment.name, 'String'),+ lc_request_name String ALIAS CAST(log_comment.request_name, 'String'),+ lc_client_query_id String ALIAS CAST(log_comment.client_query_id, 'String'),+ lc_org_id String ALIAS CAST(log_comment.org_id, 'String'),+ lc_user_id Int64 ALIAS log_comment.user_id,+ lc_is_impersonated Bool ALIAS log_comment.is_impersonated,+ lc_session_id String ALIAS CAST(log_comment.session_id, 'String'),+ lc_dashboard_id Int64 ALIAS log_comment.dashboard_id,+ lc_insight_id Int64 ALIAS log_comment.insight_id,+ lc_cohort_id Int64 ALIAS log_comment.cohort_id,+ lc_batch_export_id String ALIAS CAST(log_comment.batch_export_id, 'String'),+ lc_experiment_id Int64 ALIAS log_comment.experiment_id,+ lc_experiment_feature_flag_key String ALIAS CAST(log_comment.experiment_feature_flag_key, 'String'),+ lc_alert_config_id String ALIAS CAST(log_comment.alert_config_id, 'String'),+ lc_feature LowCardinality(String) ALIAS log_comment.feature,+ lc_table_id String ALIAS CAST(log_comment.table_id, 'String'),+ lc_warehouse_query Bool ALIAS log_comment.warehouse_query,+ lc_person_on_events_mode LowCardinality(String) ALIAS log_comment.person_on_events_mode,+ lc_service_name String ALIAS CAST(log_comment.service_name, 'String'),+ lc_workload LowCardinality(String) ALIAS log_comment.workload,+ lc_query__kind LowCardinality(String) ALIAS if(JSONHas(toString(log_comment), 'query', 'source'), JSONExtractString(toString(log_comment), 'query', 'source', 'kind'), JSONExtractString(toString(log_comment), 'query', 'kind')),+ lc_query__query String ALIAS multiIf(NOT is_initial_query, '', JSONHas(toString(log_comment), 'query', 'source'), JSONExtractString(toString(log_comment), 'query', 'source', 'query'), JSONExtractString(toString(log_comment), 'query', 'query')),+ lc_query String ALIAS if(is_initial_query, JSONExtractRaw(toString(log_comment), 'query'), ''),+ lc_temporal__workflow_namespace String ALIAS CAST(log_comment.`temporal.workflow_namespace`, 'String'),+ lc_temporal__workflow_type String ALIAS CAST(log_comment.`temporal.workflow_type`, 'String'),+ lc_temporal__workflow_id String ALIAS CAST(log_comment.`temporal.workflow_id`, 'String'),+ lc_temporal__workflow_run_id String ALIAS CAST(log_comment.`temporal.workflow_run_id`, 'String'),+ lc_temporal__activity_type String ALIAS CAST(log_comment.`temporal.activity_type`, 'String'),+ lc_temporal__activity_id String ALIAS CAST(log_comment.`temporal.activity_id`, 'String'),+ lc_temporal__attempt Int64 ALIAS log_comment.`temporal.attempt`,+ lc_dagster__job_name String ALIAS CAST(log_comment.`dagster.job_name`, 'String'),+ lc_dagster__run_id String ALIAS CAST(log_comment.`dagster.run_id`, 'String'),+ 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.writable_app_metrics (+ team_id Int64,+ timestamp DateTime64(6, 'UTC'),+ plugin_config_id Int64,+ category LowCardinality(String),+ job_id String,+ successes SimpleAggregateFunction(sum, Int64),+ successes_on_retry SimpleAggregateFunction(sum, Int64),+ failures SimpleAggregateFunction(sum, Int64),+ error_uuid UUID,+ error_type String,+ error_details String CODEC(ZSTD(3)),+ _timestamp DateTime,+ _offset UInt64,+ _partition UInt64+) ENGINE = Distributed('posthog', 'posthog', 'sharded_app_metrics', rand());+CREATE TABLE posthog.writable_duplicate_events (+ team_id Int64,+ distinct_id String,+ event String,+ source_uuid UUID,+ duplicate_uuid UUID,+ similarity_score Float64,+ dedup_type LowCardinality(String),+ is_confirmed UInt8,+ reason Nullable(String),+ version String,+ different_property_count UInt32,+ properties_similarity Float64,+ source_message String,+ duplicate_message String,+ distinct_fields Array(Tuple(field_name String, original_value String, new_value String)),+ inserted_at DateTime64(3, 'UTC'),+ _timestamp DateTime,+ _offset UInt64,+ _partition UInt64+) ENGINE = Distributed('posthog_single_shard', 'posthog', 'duplicate_events');+CREATE TABLE posthog.writable_error_tracking_issue_fingerprint_embeddings (+ team_id Int64,+ model_name LowCardinality(String),+ embedding_version Int64,+ fingerprint String,+ inserted_at DateTime64(3, 'UTC'),+ embeddings Array(Float64),+ _timestamp DateTime,+ _offset UInt64,+ _partition UInt64+) ENGINE = Distributed('posthog_single_shard', 'posthog', 'error_tracking_issue_fingerprint_embeddings');+CREATE TABLE posthog.writable_error_tracking_issue_fingerprint_overrides (+ team_id Int64,+ fingerprint String,+ issue_id UUID,+ is_deleted Int8,+ version Int64,+ _timestamp DateTime,+ _offset UInt64,+ _partition UInt64+) ENGINE = Distributed('posthog_single_shard', 'posthog', 'error_tracking_issue_fingerprint_overrides');+CREATE TABLE posthog.writable_events_dead_letter_queue (+ id UUID,+ event_uuid UUID,+ event String,+ properties String,+ distinct_id String,+ team_id Int64,+ elements_chain String,+ created_at DateTime64(6, 'UTC'),+ ip String,+ site_url String,+ now DateTime64(6, 'UTC'),+ raw_payload String,+ error_timestamp DateTime64(6, 'UTC'),+ error_location String,+ error String,+ tags Array(String),+ _timestamp DateTime,+ _offset UInt64+) ENGINE = Distributed('posthog_single_shard', 'posthog', 'events_dead_letter_queue');+CREATE TABLE posthog.writable_groups (+ group_type_index UInt8,+ group_key String,+ created_at DateTime64(3),+ team_id Int64,+ group_properties String,+ _timestamp DateTime,+ _offset UInt64+) ENGINE = Distributed('posthog_single_shard', 'posthog', 'groups');+CREATE TABLE posthog.writable_ingestion_warnings (+ team_id Int64,+ source LowCardinality(String),+ type String,+ details String CODEC(ZSTD(3)),+ timestamp DateTime64(6, 'UTC'),+ _timestamp DateTime,+ _offset UInt64,+ _partition UInt64+) ENGINE = Distributed('posthog', 'posthog', 'sharded_ingestion_warnings', rand());+CREATE TABLE posthog.writable_log_entries (+ team_id UInt64,+ log_source LowCardinality(String),+ log_source_id String,+ instance_id String,+ timestamp DateTime64(6, 'UTC'),+ level LowCardinality(String),+ message String,+ _timestamp DateTime,+ _offset UInt64+) ENGINE = Distributed('posthog', 'posthog', 'sharded_log_entries', rand());+CREATE TABLE posthog.writable_person (+ id UUID,+ created_at DateTime64(3),+ team_id Int64,+ properties String,+ is_identified Int8,+ is_deleted Int8,+ version UInt64,+ last_seen_at Nullable(DateTime64(3)),+ _timestamp DateTime,+ _offset UInt64+) ENGINE = Distributed('posthog_single_shard', 'posthog', 'person');+CREATE TABLE posthog.writable_person_distinct_id2 (+ team_id Int64,+ distinct_id String,+ person_id UUID,+ is_deleted Int8,+ version Int64,+ _timestamp DateTime,+ _offset UInt64,+ _partition UInt64+) ENGINE = Distributed('posthog_single_shard', 'posthog', 'person_distinct_id2');+CREATE TABLE posthog.writable_person_distinct_id_overrides (+ team_id Int64,+ distinct_id String,+ person_id UUID,+ is_deleted Int8,+ version Int64,+ _timestamp DateTime,+ _offset UInt64,+ _partition UInt64+) ENGINE = Distributed('posthog_single_shard', 'posthog', 'person_distinct_id_overrides');+CREATE TABLE posthog.writable_plugin_log_entries (+ id UUID,+ team_id Int64,+ plugin_id Int64,+ plugin_config_id Int64,+ timestamp DateTime64(6, 'UTC'),+ source String,+ type String,+ message String,+ instance_id UUID,+ _timestamp DateTime,+ _offset UInt64+) ENGINE = Distributed('posthog_single_shard', 'posthog', 'plugin_log_entries');+CREATE TABLE posthog.writable_posthog_document_embeddings (+ team_id Int64,+ product LowCardinality(String),+ document_type LowCardinality(String),+ model_name LowCardinality(String),+ rendering LowCardinality(String),+ document_id String,+ timestamp DateTime64(3, 'UTC'),+ inserted_at DateTime64(3, 'UTC'),+ content String DEFAULT '',+ metadata String DEFAULT '{}',+ embedding Array(Float64),+ _timestamp DateTime,+ _offset UInt64,+ _partition UInt64+) ENGINE = Distributed('posthog', 'posthog', 'partitioned_sharded_posthog_document_embeddings', cityHash64(document_id));+CREATE TABLE posthog.writable_posthog_document_embeddings_buffer (+ team_id Int64,+ product LowCardinality(String),+ document_type LowCardinality(String),+ model_name LowCardinality(String),+ rendering LowCardinality(String),+ document_id String,+ timestamp DateTime64(3, 'UTC'),+ inserted_at DateTime64(3, 'UTC'),+ content String DEFAULT '',+ metadata String DEFAULT '{}',+ embedding Array(Float64),+ _timestamp DateTime,+ _offset UInt64,+ _partition UInt64+) ENGINE = Distributed('posthog', 'posthog', 'sharded_posthog_document_embeddings_buffer', cityHash64(document_id));+CREATE TABLE posthog.writable_session_replay_events (+ session_id String,+ team_id Int64,+ 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),+ active_milliseconds SimpleAggregateFunction(sum, Int64),+ console_log_count SimpleAggregateFunction(sum, Int64),+ console_warn_count SimpleAggregateFunction(sum, Int64),+ console_error_count SimpleAggregateFunction(sum, Int64),+ size SimpleAggregateFunction(sum, Int64),+ message_count SimpleAggregateFunction(sum, Int64),+ event_count SimpleAggregateFunction(sum, Int64),+ snapshot_source AggregateFunction(argMin, LowCardinality(Nullable(String)), DateTime64(6, 'UTC')),+ snapshot_library AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC')),+ _timestamp SimpleAggregateFunction(max, DateTime),+ 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))+) ENGINE = Distributed('posthog', 'posthog', 'sharded_session_replay_events', sipHash64(distinct_id));+CREATE TABLE posthog.writable_usage_report_events_preagg (+ date Date,+ team_id Int64,+ person_mode LowCardinality(String),+ lib LowCardinality(String),+ event String,+ distinct_events_unique AggregateFunction(uniqExact, Tuple(UInt64, UInt64, UInt64)),+ event_count AggregateFunction(sum, UInt64)+) ENGINE = Distributed('aux', 'posthog', 'sharded_usage_report_events_preagg', sipHash64(date));+CREATE MATERIALIZED VIEW posthog.app_metrics_mv TO posthog.writable_app_metrics (team_id Int64, timestamp DateTime64(6, 'UTC'), plugin_config_id Int64, category LowCardinality(String), job_id String, successes Int64, successes_on_retry Int64, failures Int64, error_uuid UUID, error_type String, error_details String, _timestamp Nullable(DateTime), _offset UInt64, _partition UInt64) AS SELECT+ team_id,+ timestamp,+ plugin_config_id,+ category,+ job_id,+ successes,+ successes_on_retry,+ failures,+ error_uuid,+ error_type,+ error_details,+ _timestamp,+ _offset,+ _partition+FROM posthog.kafka_app_metrics;+CREATE MATERIALIZED VIEW posthog.duplicate_events_mv TO posthog.writable_duplicate_events (team_id Int64, distinct_id String, event String, source_uuid UUID, duplicate_uuid UUID, similarity_score Float64, dedup_type LowCardinality(String), is_confirmed UInt8, reason Nullable(String), version String, different_property_count UInt32, properties_similarity Float64, source_message String, duplicate_message String, distinct_fields Array(Tuple(field_name String, original_value String, new_value String)), inserted_at DateTime64(3, 'UTC'), _timestamp Nullable(DateTime), _offset UInt64, _partition UInt64) AS SELECT+ team_id,+ distinct_id,+ event,+ source_uuid,+ duplicate_uuid,+ similarity_score,+ dedup_type,+ is_confirmed,+ reason,+ version,+ different_property_count,+ properties_similarity,+ source_message,+ duplicate_message,+ JSONExtract(+ distinct_fields,+ 'Array(Tuple(field_name String, original_value String, new_value String))'+ ) AS distinct_fields,+ inserted_at,+ _timestamp,+ _offset,+ _partition+FROM posthog.kafka_duplicate_events;+CREATE MATERIALIZED VIEW posthog.error_tracking_issue_fingerprint_embeddings_mv TO posthog.writable_error_tracking_issue_fingerprint_embeddings (team_id Int64, model_name LowCardinality(String), embedding_version Int64, fingerprint String, inserted_at Nullable(DateTime), embeddings Array(Float64), _timestamp Nullable(DateTime), _offset UInt64, _partition UInt64) AS SELECT+ team_id,+ model_name,+ embedding_version,+ fingerprint,+ _timestamp AS inserted_at,+ embeddings,+ _timestamp,+ _offset,+ _partition+FROM posthog.kafka_error_tracking_issue_fingerprint_embeddings;+CREATE MATERIALIZED VIEW posthog.error_tracking_issue_fingerprint_overrides_mv TO posthog.writable_error_tracking_issue_fingerprint_overrides (team_id Int64, fingerprint String, issue_id UUID, is_deleted Int8, version Int64, _timestamp Nullable(DateTime), _offset UInt64, _partition UInt64) AS SELECT+ team_id,+ fingerprint,+ issue_id,+ is_deleted,+ version,+ _timestamp,+ _offset,+ _partition+FROM posthog.kafka_error_tracking_issue_fingerprint_overrides+WHERE version > 0;+CREATE MATERIALIZED VIEW posthog.events_dead_letter_queue_mv TO posthog.writable_events_dead_letter_queue (id UUID, event_uuid UUID, event String, properties String, distinct_id String, team_id Int64, elements_chain String, created_at DateTime64(6, 'UTC'), ip String, site_url String, now DateTime64(6, 'UTC'), raw_payload String, error_timestamp DateTime64(6, 'UTC'), error_location String, error String, tags Array(String), _timestamp Nullable(DateTime), _offset UInt64) AS SELECT+ id,+ event_uuid,+ event,+ properties,+ distinct_id,+ team_id,+ elements_chain,+ created_at,+ ip,+ site_url,+ now,+ raw_payload,+ error_timestamp,+ error_location,+ error,+ tags,+ _timestamp,+ _offset+FROM posthog.kafka_events_dead_letter_queue;+CREATE MATERIALIZED VIEW posthog.groups_mv TO posthog.writable_groups (group_type_index UInt8, group_key String, created_at DateTime64(3), team_id Int64, group_properties String, _timestamp Nullable(DateTime), _offset UInt64) AS SELECT+ group_type_index,+ group_key,+ created_at,+ team_id,+ group_properties,+ _timestamp,+ _offset+FROM posthog.kafka_groups;+CREATE MATERIALIZED VIEW posthog.ingestion_warnings_mv TO posthog.writable_ingestion_warnings (team_id Int64, source LowCardinality(String), type String, details String, timestamp DateTime64(6, 'UTC'), _timestamp Nullable(DateTime), _offset UInt64, _partition UInt64) AS SELECT+ team_id,+ source,+ type,+ details,+ timestamp,+ _timestamp,+ _offset,+ _partition+FROM posthog.kafka_ingestion_warnings;+CREATE MATERIALIZED VIEW posthog.log_entries_v3_mv TO posthog.writable_log_entries (team_id UInt64, log_source LowCardinality(String), log_source_id String, instance_id String, timestamp DateTime64(6, 'UTC'), level LowCardinality(String), message String, _timestamp Nullable(DateTime), _offset UInt64) AS SELECT+ team_id,+ log_source,+ log_source_id,+ instance_id,+ timestamp,+ level,+ message,+ _timestamp,+ _offset+FROM posthog.kafka_log_entries_v3+WHERE toDate(timestamp) <= today();+CREATE MATERIALIZED VIEW posthog.log_entries_ws_mv TO posthog.writable_log_entries (team_id UInt64, log_source LowCardinality(String), log_source_id String, instance_id String, timestamp DateTime64(6, 'UTC'), level LowCardinality(String), message String, _timestamp Nullable(DateTime), _offset UInt64) AS SELECT+ team_id,+ log_source,+ log_source_id,+ instance_id,+ timestamp,+ level,+ message,+ _timestamp,+ _offset+FROM posthog.kafka_log_entries_ws+WHERE toDate(timestamp) <= today();+CREATE MATERIALIZED VIEW posthog.person_distinct_id2_mv TO posthog.writable_person_distinct_id2 (team_id Int64, distinct_id String, person_id UUID, is_deleted Int8, version Int64, _timestamp Nullable(DateTime), _offset UInt64, _partition UInt64) AS SELECT+ team_id,+ distinct_id,+ person_id,+ is_deleted,+ version,+ _timestamp,+ _offset,+ _partition+FROM posthog.kafka_person_distinct_id2;+CREATE MATERIALIZED VIEW posthog.person_distinct_id_overrides_mv TO posthog.writable_person_distinct_id_overrides (team_id Int64, distinct_id String, person_id UUID, is_deleted Int8, version Int64, _timestamp Nullable(DateTime), _offset UInt64, _partition UInt64) AS SELECT+ team_id,+ distinct_id,+ person_id,+ is_deleted,+ version,+ _timestamp,+ _offset,+ _partition+FROM posthog.kafka_person_distinct_id_overrides+WHERE version > 0;+CREATE MATERIALIZED VIEW posthog.person_mv TO posthog.writable_person (id UUID, created_at DateTime64(3), team_id Int64, properties String, is_identified Int8, is_deleted Int8, version UInt64, last_seen_at Nullable(DateTime64(3)), _timestamp Nullable(DateTime), _offset UInt64) AS SELECT+ id,+ created_at,+ team_id,+ properties,+ is_identified,+ is_deleted,+ version,+ last_seen_at,+ _timestamp,+ _offset+FROM posthog.kafka_person;+CREATE MATERIALIZED VIEW posthog.plugin_log_entries_mv TO posthog.writable_plugin_log_entries (id UUID, team_id Int64, plugin_id Int64, plugin_config_id Int64, timestamp DateTime64(6, 'UTC'), source String, type String, message String, instance_id UUID, _timestamp Nullable(DateTime), _offset UInt64) AS SELECT+ id,+ team_id,+ plugin_id,+ plugin_config_id,+ timestamp,+ source,+ type,+ message,+ instance_id,+ _timestamp,+ _offset+FROM posthog.kafka_plugin_log_entries;+CREATE MATERIALIZED VIEW posthog.posthog_document_embeddings_kafka_to_buffer_mv TO posthog.writable_posthog_document_embeddings_buffer (team_id Int64, product LowCardinality(String), document_type LowCardinality(String), model_name LowCardinality(String), rendering LowCardinality(String), document_id String, timestamp DateTime64(3, 'UTC'), inserted_at Nullable(DateTime), content String, metadata String, embedding Array(Float64), _timestamp Nullable(DateTime), _offset UInt64, _partition UInt64) AS SELECT+ team_id,+ product,+ document_type,+ model_name,+ rendering,+ document_id,+ timestamp,+ _timestamp AS inserted_at,+ coalesce(content, '') AS content,+ coalesce(metadata, '{}') AS metadata,+ embedding,+ _timestamp,+ _offset,+ _partition+FROM posthog.kafka_posthog_document_embeddings;+CREATE MATERIALIZED VIEW posthog.session_replay_events_mv TO posthog.writable_session_replay_events (session_id String, team_id Int64, distinct_id String, min_first_timestamp DateTime64(6, 'UTC'), max_last_timestamp 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 Int64, keypress_count Int64, mouse_activity_count Int64, active_milliseconds Int64, console_log_count Int64, console_warn_count Int64, console_error_count Int64, size Int64, message_count Int64, event_count Int64, snapshot_source AggregateFunction(argMin, LowCardinality(Nullable(String)), DateTime64(6, 'UTC')), snapshot_library AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC')), _timestamp Nullable(DateTime), retention_period_days SimpleAggregateFunction(max, Nullable(Int64)), is_deleted SimpleAggregateFunction(max, UInt8), ai_tags_fixed SimpleAggregateFunction(groupUniqArrayArray, Array(String)), ai_tags_freeform SimpleAggregateFunction(groupUniqArrayArray, Array(String)), ai_highlighted SimpleAggregateFunction(max, UInt8), surfacing_score SimpleAggregateFunction(max, Nullable(Float32))) AS SELECT+ session_id,+ team_id,+ any(distinct_id) AS distinct_id,+ min(first_timestamp) AS min_first_timestamp,+ max(last_timestamp) AS max_last_timestamp,+ groupArray(if(block_url != '', first_timestamp, NULL)) AS block_first_timestamps,+ groupArray(if(block_url != '', last_timestamp, NULL)) AS block_last_timestamps,+ groupArray(block_url) AS block_urls,+ argMinState(first_url, first_timestamp) AS first_url,+ groupUniqArrayArray(urls) AS all_urls,+ sum(click_count) AS click_count,+ sum(keypress_count) AS keypress_count,+ sum(mouse_activity_count) AS mouse_activity_count,+ sum(active_milliseconds) AS active_milliseconds,+ sum(console_log_count) AS console_log_count,+ sum(console_warn_count) AS console_warn_count,+ sum(console_error_count) AS console_error_count,+ sum(size) AS size,+ sum(message_count) AS message_count,+ sum(event_count) AS event_count,+ argMinState(snapshot_source, first_timestamp) AS snapshot_source,+ argMinState(snapshot_library, first_timestamp) AS snapshot_library,+ max(_timestamp) AS _timestamp,+ max(retention_period_days) AS retention_period_days,+ max(is_deleted) AS is_deleted,+ groupUniqArrayArray(ai_tags_fixed) AS ai_tags_fixed,+ groupUniqArrayArray(ai_tags_freeform) AS ai_tags_freeform,+ max(ai_highlighted) AS ai_highlighted,+ max(surfacing_score) AS surfacing_score+FROM posthog.kafka_session_replay_events+GROUP BY+ session_id, team_id;+CREATE MATERIALIZED VIEW posthog.usage_report_events_preagg_mv TO posthog.writable_usage_report_events_preagg (date Date, team_id Int64, person_mode Enum8('full'=0, 'propertyless'=1, 'force_upgrade'=2), lib String, event String, distinct_events_unique AggregateFunction(uniqExact, Tuple(UInt64, UInt64, UInt64)), event_count AggregateFunction(sum, UInt64)) AS SELECT+ toDate(timestamp) AS date,+ team_id,+ person_mode,+ JSONExtractString(properties, '$lib') AS lib,+ event,+ uniqExactState((cityHash64(distinct_id), cityHash64(toString(uuid)), cityHash64(event))) AS distinct_events_unique,+ sumState(toUInt64(1)) AS event_count+FROM posthog.kafka_usage_report_events_preagg+GROUP BY+ date, team_id, person_mode, lib, event;diff --git a/posthog/clickhouse/hcl/sql/local-single/all.sql b/posthog/clickhouse/hcl/sql/local-single/all.sqlnew file mode 100644index 000000000000..2c4a6d4b7452--- /dev/null+++ b/posthog/clickhouse/hcl/sql/local-single/all.sql@@ -0,0 +1,6845 @@+-- AUTO-GENERATED from the declarative HCL by ops/gen-sql.sh — do not edit.+-- Full CREATE schema for the local-single/all node. Apply to a fresh ClickHouse to build it.++CREATE TABLE posthog.adhoc_events_deletion (+ team_id Int64,+ uuid UUID,+ created_at DateTime64(6, 'UTC') DEFAULT now64(),+ deleted_at DateTime,+ is_deleted UInt8 DEFAULT 0+) ENGINE = ReplicatedReplacingMergeTree('/clickhouse/tables/noshard/posthog.adhoc_events_deletion', '{replica}-{shard}', deleted_at, is_deleted) ORDER BY (team_id, uuid) TTL deleted_at + toIntervalMonth(3) WHERE is_deleted = 1 SETTINGS index_granularity = 8192;+CREATE TABLE posthog.channel_definition (+ domain String,+ kind String,+ domain_type Nullable(String),+ type_if_paid Nullable(String),+ type_if_organic Nullable(String)+) ENGINE = ReplicatedMergeTree('/clickhouse/tables/noshard/posthog.channel_definition', '{replica}-{shard}') ORDER BY (domain, kind) SETTINGS index_granularity = 8192;+CREATE TABLE posthog.cohort_membership (+ team_id Int64,+ cohort_id Int64,+ person_id UUID,+ status Enum8('entered'=1, 'left'=2),+ last_updated DateTime64(6) DEFAULT now64()+) ENGINE = ReplicatedReplacingMergeTree('/clickhouse/tables/noshard/posthog.cohort_membership', '{replica}-{shard}', last_updated) ORDER BY (team_id, cohort_id, person_id) SETTINGS index_granularity = 8192;+CREATE TABLE posthog.cohortpeople (+ person_id UUID,+ cohort_id Int64,+ team_id Int64,+ sign Int8,+ version UInt64+) ENGINE = ReplicatedCollapsingMergeTree('/clickhouse/tables/noshard/posthog.cohortpeople', '{replica}-{shard}', sign) ORDER BY (team_id, cohort_id, person_id, version) SETTINGS index_granularity = 8192;+CREATE TABLE posthog.distributed_system_processes (+ is_initial_query UInt8,+ user String,+ query_id String,+ address IPv6,+ port UInt16,+ initial_user String,+ initial_query_id String,+ initial_address IPv6,+ initial_port UInt16,+ interface UInt8,+ os_user String,+ client_hostname String,+ client_name String,+ client_agent LowCardinality(String),+ client_revision UInt64,+ client_version_major UInt64,+ client_version_minor UInt64,+ client_version_patch UInt64,+ client_agent LowCardinality(String),+ http_method UInt8,+ http_user_agent String,+ http_referer String,+ forwarded_for String,+ quota_key String,+ distributed_depth UInt64,+ elapsed Float64,+ is_cancelled UInt8,+ is_all_data_sent UInt8,+ read_rows UInt64,+ read_bytes UInt64,+ total_rows_approx UInt64,+ written_rows UInt64,+ written_bytes UInt64,+ memory_usage Int64,+ peak_memory_usage Int64,+ query String,+ normalized_query_hash UInt64,+ query_kind String,+ thread_ids Array(UInt64),+ peak_threads_usage UInt64,+ ProfileEvents Map(LowCardinality(String), UInt64),+ Settings Map(LowCardinality(String), LowCardinality(String)),+ current_database String,+ is_internal UInt8,+ ProfileEvents.Names Array(String) ALIAS mapKeys(ProfileEvents),+ ProfileEvents.Values Array(UInt64) ALIAS mapValues(ProfileEvents),+ Settings.Names Array(String) ALIAS mapKeys(Settings),+ Settings.Values Array(String) ALIAS mapValues(Settings)+) ENGINE = Distributed('posthog', 'system', 'processes') SETTINGS skip_unavailable_shards = 1;+CREATE TABLE posthog.duplicate_events (+ team_id Int64,+ distinct_id String,+ event String,+ source_uuid UUID,+ duplicate_uuid UUID,+ similarity_score Float64,+ dedup_type LowCardinality(String),+ is_confirmed UInt8,+ reason Nullable(String),+ version String,+ different_property_count UInt32,+ properties_similarity Float64,+ source_message String,+ duplicate_message String,+ distinct_fields Array(Tuple(field_name String, original_value String, new_value String)),+ inserted_at DateTime64(3, 'UTC'),+ _timestamp DateTime,+ _offset UInt64,+ _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.error_tracking_issue_fingerprint_overrides (+ team_id Int64,+ fingerprint String,+ issue_id UUID,+ is_deleted Int8,+ version Int64,+ _timestamp DateTime,+ _offset UInt64,+ _partition UInt64,+ INDEX kafka_timestamp_minmax_error_tracking_issue_fingerprint_overrides _timestamp TYPE minmax GRANULARITY 3+) ENGINE = ReplicatedReplacingMergeTree('/clickhouse/tables/noshard/posthog.error_tracking_issue_fingerprint_overrides', '{replica}-{shard}', version) ORDER BY (team_id, fingerprint) SETTINGS index_granularity = 512;+CREATE TABLE posthog.events_dead_letter_queue (+ id UUID,+ event_uuid UUID,+ event String,+ properties String,+ distinct_id String,+ team_id Int64,+ elements_chain String,+ created_at DateTime64(6, 'UTC'),+ ip String,+ site_url String,+ now DateTime64(6, 'UTC'),+ raw_payload String,+ error_timestamp DateTime64(6, 'UTC'),+ error_location String,+ error String,+ tags Array(String),+ _timestamp DateTime,+ _offset UInt64,+ INDEX kafka_timestamp_minmax_events_dead_letter_queue _timestamp TYPE minmax GRANULARITY 3+) ENGINE = ReplicatedReplacingMergeTree('/clickhouse/tables/noshard/posthog.events_dead_letter_queue', '{replica}-{shard}', _timestamp) ORDER BY (id, event_uuid, distinct_id, team_id) TTL toDate(_timestamp) + toIntervalWeek(4) SETTINGS index_granularity = 512;+CREATE TABLE posthog.events_team_daily_stats (+ analysis_date Date,+ team_id Int64,+ event String,+ event_count UInt64,+ total_event_bytes UInt64,+ min_event_bytes UInt64,+ max_event_bytes UInt64,+ avg_event_bytes Float64,+ p50_event_bytes Float64,+ p90_event_bytes Float64,+ p95_event_bytes Float64,+ p99_event_bytes Float64,+ event_size_histogram Array(Tuple(Float64, Float64, UInt64)),+ computed_at DateTime+) ENGINE = ReplicatedMergeTree('/clickhouse/ops/tables/{shard}/posthog.events_team_daily_stats', '{replica}') ORDER BY (analysis_date, team_id, event) SETTINGS index_granularity = 8192;+CREATE TABLE posthog.exchange_rate (+ currency String,+ date Date,+ rate Decimal(18, 10),+ version UInt32 DEFAULT toUnixTimestamp(now())+) ENGINE = ReplicatedReplacingMergeTree('/clickhouse/tables/noshard/posthog.exchange_rate', '{replica}-{shard}', version) ORDER BY (date, currency) SETTINGS index_granularity = 8192;+CREATE TABLE posthog.groups (+ group_type_index UInt8,+ group_key String,+ created_at DateTime64(3),+ team_id Int64,+ group_properties String,+ _timestamp DateTime,+ _offset UInt64,+ is_deleted Bool,+ INDEX is_deleted_idx is_deleted TYPE minmax GRANULARITY 1+) ENGINE = ReplicatedReplacingMergeTree('/clickhouse/tables/noshard/posthog.groups', '{replica}-{shard}', _timestamp) ORDER BY (team_id, group_type_index, group_key) SETTINGS index_granularity = 8192;+CREATE TABLE posthog.hog_invocation_results_data (+ team_id Int64,+ function_kind LowCardinality(String),+ function_id String,+ invocation_id String,+ parent_run_id String,+ status LowCardinality(String),+ attempts UInt8,+ is_retry UInt8,+ scheduled_at DateTime64(6, 'UTC'),+ first_scheduled_at DateTime64(6, 'UTC') DEFAULT scheduled_at,+ started_at Nullable(DateTime64(6, 'UTC')),+ finished_at Nullable(DateTime64(6, 'UTC')),+ duration_ms Nullable(UInt32),+ error_kind LowCardinality(String),+ error_message String,+ event_uuid String,+ distinct_id String,+ person_id String,+ invocation_globals String,+ version UInt64,+ is_deleted UInt8 DEFAULT 0,+ _timestamp DateTime,+ _offset UInt64,+ _partition UInt64,+ INDEX status_idx status TYPE set(8) GRANULARITY 1,+ INDEX function_idx function_id TYPE bloom_filter(0.01) GRANULARITY 1,+ INDEX event_uuid_idx event_uuid TYPE bloom_filter(0.01) GRANULARITY 1,+ INDEX is_retry_idx is_retry TYPE set(2) GRANULARITY 1+) ENGINE = ReplicatedReplacingMergeTree('/clickhouse/tables/noshard/posthog.hog_invocation_results_data', '{replica}-{shard}', version) ORDER BY (team_id, function_kind, function_id, invocation_id) PARTITION BY toYYYYMMDD(scheduled_at) TTL toDate(scheduled_at) + toIntervalDay(30) SETTINGS index_granularity = 1024, ttl_only_drop_parts = 1;+CREATE TABLE posthog.ingestion_warnings_v2 (+ team_id Int64,+ source LowCardinality(String),+ type LowCardinality(String),+ details String,+ timestamp DateTime64(6, 'UTC'),+ category LowCardinality(String) DEFAULT coalesce(nullIf(JSONExtractString(details, 'category'), ''), 'unknown'),+ severity LowCardinality(String) DEFAULT coalesce(nullIf(JSONExtractString(details, 'severity'), ''), 'warning'),+ pipeline_step LowCardinality(String) DEFAULT coalesce(nullIf(JSONExtractString(details, 'pipelineStep'), ''), 'unknown'),+ event_uuid Nullable(UUID) DEFAULT toUUIDOrNull(JSONExtractString(details, 'eventUuid')),+ distinct_id Nullable(String) DEFAULT nullIf(JSONExtractString(details, 'distinctId'), ''),+ group_key Nullable(String) DEFAULT nullIf(JSONExtractString(details, 'groupKey'), ''),+ person_id Nullable(UUID) DEFAULT toUUIDOrNull(JSONExtractString(details, 'personId')),+ _timestamp DateTime,+ _offset UInt64,+ _partition UInt64+) ENGINE = ReplicatedMergeTree('/clickhouse/tables/noshard/posthog.ingestion_warnings_v2', '{replica}-{shard}') ORDER BY (team_id, type, timestamp) PARTITION BY toYYYYMM(timestamp) TTL toDateTime(timestamp) + toIntervalDay(90) SETTINGS index_granularity = 8192;+CREATE TABLE posthog.ingestion_warnings_v2_distributed (+ team_id Int64,+ source LowCardinality(String),+ type LowCardinality(String),+ details String,+ timestamp DateTime64(6, 'UTC'),+ category LowCardinality(String) DEFAULT coalesce(nullIf(JSONExtractString(details, 'category'), ''), 'unknown'),+ severity LowCardinality(String) DEFAULT coalesce(nullIf(JSONExtractString(details, 'severity'), ''), 'warning'),+ pipeline_step LowCardinality(String) DEFAULT coalesce(nullIf(JSONExtractString(details, 'pipelineStep'), ''), 'unknown'),+ event_uuid Nullable(UUID) DEFAULT toUUIDOrNull(JSONExtractString(details, 'eventUuid')),+ distinct_id Nullable(String) DEFAULT nullIf(JSONExtractString(details, 'distinctId'), ''),+ group_key Nullable(String) DEFAULT nullIf(JSONExtractString(details, 'groupKey'), ''),+ person_id Nullable(UUID) DEFAULT toUUIDOrNull(JSONExtractString(details, 'personId')),+ _timestamp DateTime,+ _offset UInt64,+ _partition UInt64+) ENGINE = Distributed('aux', 'posthog', 'ingestion_warnings_v2');+CREATE TABLE posthog.kafka_ai_events_json (+ uuid UUID,+ event String,+ properties String,+ timestamp DateTime64(6, 'UTC'),+ team_id Int64,+ distinct_id String,+ elements_chain String,+ created_at DateTime64(6, 'UTC'),+ person_id UUID,+ person_properties String,+ person_created_at DateTime64(3),+ person_mode Enum8('full'=0, 'propertyless'=1, 'force_upgrade'=2)+) ENGINE = Kafka() SETTINGS kafka_broker_list = 'msk_cluster', kafka_format = 'kafka_format = \'JSONEachRow\'', kafka_group_name = 'kafka_group_name = \'group1\'', kafka_topic_list = 'kafka_topic_list = \'clickhouse_ai_events_json\'';+CREATE TABLE posthog.kafka_app_metrics (+ team_id Int64,+ timestamp DateTime64(6, 'UTC'),+ plugin_config_id Int64,+ category LowCardinality(String),+ job_id String,+ successes Int64,+ successes_on_retry Int64,+ failures Int64,+ error_uuid UUID,+ error_type String,+ error_details String CODEC(ZSTD(3))+) ENGINE = Kafka() SETTINGS kafka_broker_list = 'msk_cluster', kafka_format = 'kafka_format = \'JSONEachRow\'', kafka_group_name = 'kafka_group_name = \'group1\'', kafka_topic_list = 'kafka_topic_list = \'clickhouse_app_metrics\'';+CREATE TABLE posthog.kafka_app_metrics2 (+ team_id Int64,+ timestamp DateTime64(6, 'UTC'),+ app_source LowCardinality(String),+ app_source_id String,+ instance_id String,+ metric_kind String,+ metric_name String,+ count Int64+) ENGINE = Kafka() SETTINGS kafka_broker_list = 'msk_cluster', kafka_format = 'kafka_format = \'JSONEachRow\'', kafka_group_name = 'kafka_group_name = \'group1\'', kafka_topic_list = 'kafka_topic_list = \'clickhouse_app_metrics2\'';+CREATE TABLE posthog.kafka_app_metrics2_ws (+ team_id Int64,+ timestamp DateTime64(6, 'UTC'),+ app_source LowCardinality(String),+ app_source_id String,+ instance_id String,+ metric_kind String,+ metric_name String,+ count Int64+) ENGINE = Kafka() SETTINGS kafka_broker_list = 'warpstream_ingestion', kafka_format = 'kafka_format = \'JSONEachRow\'', kafka_group_name = 'kafka_group_name = \'clickhouse_app_metrics2_ws\'', kafka_topic_list = 'kafka_topic_list = \'clickhouse_app_metrics2\'';+CREATE TABLE posthog.kafka_cohort_membership (+ team_id Int64,+ cohort_id Int64,+ person_id UUID,+ status Enum8('entered'=1, 'left'=2, 'member'=3, 'not_member'=4),+ last_updated DateTime64(6)+) ENGINE = Kafka() SETTINGS kafka_broker_list = 'msk_cluster', kafka_format = 'kafka_format = \'JSONEachRow\'', kafka_group_name = 'kafka_group_name = \'clickhouse_cohort_membership_changed\'', kafka_topic_list = 'kafka_topic_list = \'cohort_membership_changed\'';+CREATE TABLE posthog.kafka_distinct_id_usage (+ team_id Int64,+ distinct_id String,+ timestamp DateTime64(6, 'UTC')+) ENGINE = Kafka() SETTINGS kafka_broker_list = 'warpstream_ingestion', kafka_format = 'kafka_format = \'JSONEachRow\'', kafka_group_name = 'kafka_group_name = \'clickhouse_distinct_id_usage\'', kafka_skip_broken_messages = 100, kafka_topic_list = 'kafka_topic_list = \'distinct_id_usage_events_json\'';+CREATE TABLE posthog.kafka_duplicate_events (+ team_id Int64,+ distinct_id String,+ event String,+ source_uuid UUID,+ duplicate_uuid UUID,+ similarity_score Float64,+ dedup_type LowCardinality(String),+ is_confirmed UInt8,+ reason Nullable(String),+ version String,+ different_property_count UInt32,+ properties_similarity Float64,+ source_message String,+ duplicate_message String,+ distinct_fields String,+ inserted_at DateTime64(3, 'UTC')+) ENGINE = Kafka() SETTINGS kafka_broker_list = 'msk_cluster', kafka_format = 'kafka_format = \'JSONEachRow\'', kafka_group_name = 'kafka_group_name = \'clickhouse_duplicate_events\'', kafka_topic_list = 'kafka_topic_list = \'clickhouse_ingestion_events_duplicates\'';+CREATE TABLE posthog.kafka_error_tracking_fingerprint_issue_state (+ team_id Int64,+ fingerprint String,+ issue_id UUID,+ issue_name Nullable(String),+ issue_description Nullable(String),+ issue_status String,+ issue_severity Nullable(String),+ assigned_user_id Nullable(Int64),+ assigned_role_id Nullable(UUID),+ first_seen DateTime64(3, 'UTC'),+ is_deleted Int8,+ version Int64+) ENGINE = Kafka() SETTINGS kafka_broker_list = 'msk_cluster', kafka_format = 'kafka_format = \'JSONEachRow\'', kafka_group_name = 'kafka_group_name = \'clickhouse-error-tracking-fingerprint-issue-state\'', kafka_topic_list = 'kafka_topic_list = \'clickhouse_error_tracking_fingerprint_issue_state\'';+CREATE TABLE posthog.kafka_error_tracking_issue_fingerprint_embeddings (+ team_id Int64,+ model_name LowCardinality(String),+ embedding_version Int64,+ fingerprint String,+ inserted_at DateTime64(3, 'UTC'),+ embeddings Array(Float64)+) ENGINE = Kafka() SETTINGS kafka_broker_list = 'msk_cluster', kafka_format = 'kafka_format = \'JSONEachRow\'', kafka_group_name = 'kafka_group_name = \'clickhouse_error_tracking_fingerprint_embeddings\'', kafka_topic_list = 'kafka_topic_list = \'clickhouse_error_tracking_issue_fingerprint_embeddings\'';+CREATE TABLE posthog.kafka_error_tracking_issue_fingerprint_overrides (+ team_id Int64,+ fingerprint String,+ issue_id UUID,+ is_deleted Int8,+ version Int64+) ENGINE = Kafka() SETTINGS kafka_broker_list = 'msk_cluster', kafka_format = 'kafka_format = \'JSONEachRow\'', kafka_group_name = 'kafka_group_name = \'clickhouse-error-tracking-issue-fingerprint-overrides\'', kafka_topic_list = 'kafka_topic_list = \'clickhouse_error_tracking_issue_fingerprint\'';+CREATE TABLE posthog.kafka_events_dead_letter_queue (+ id UUID,+ event_uuid UUID,+ event String,+ properties String,+ distinct_id String,+ team_id Int64,+ elements_chain String,+ created_at DateTime64(6, 'UTC'),+ ip String,+ site_url String,+ now DateTime64(6, 'UTC'),+ raw_payload String,+ error_timestamp DateTime64(6, 'UTC'),+ error_location String,+ error String,+ tags Array(String)+) ENGINE = Kafka() SETTINGS kafka_broker_list = 'msk_cluster', kafka_format = 'kafka_format = \'JSONEachRow\'', kafka_group_name = 'kafka_group_name = \'group1\'', kafka_skip_broken_messages = 1000, kafka_topic_list = 'kafka_topic_list = \'events_dead_letter_queue\'';+CREATE TABLE posthog.kafka_events_json (+ uuid UUID,+ event String,+ properties String CODEC(ZSTD(3)),+ timestamp DateTime64(6, 'UTC'),+ team_id Int64,+ distinct_id String,+ elements_chain String,+ created_at DateTime64(6, 'UTC'),+ person_id UUID,+ person_created_at DateTime64(3),+ person_properties String CODEC(ZSTD(3)),+ group0_properties String CODEC(ZSTD(3)),+ group1_properties String CODEC(ZSTD(3)),+ group2_properties String CODEC(ZSTD(3)),+ group3_properties String CODEC(ZSTD(3)),+ group4_properties String CODEC(ZSTD(3)),+ group0_created_at DateTime64(3),+ group1_created_at DateTime64(3),+ group2_created_at DateTime64(3),+ group3_created_at DateTime64(3),+ group4_created_at DateTime64(3),+ person_mode Enum8('full'=0, 'propertyless'=1, 'force_upgrade'=2),+ historical_migration Bool,+ dmat_string_0 Nullable(String),+ dmat_string_1 Nullable(String),+ dmat_string_2 Nullable(String),+ dmat_string_3 Nullable(String),+ dmat_string_4 Nullable(String),+ dmat_string_5 Nullable(String),+ dmat_string_6 Nullable(String),+ dmat_string_7 Nullable(String),+ dmat_string_8 Nullable(String),+ dmat_string_9 Nullable(String)+) ENGINE = Kafka() SETTINGS kafka_broker_list = 'msk_cluster', kafka_format = 'kafka_format = \'JSONEachRow\'', kafka_group_name = 'kafka_group_name = \'group1\'', kafka_skip_broken_messages = 100, kafka_topic_list = 'kafka_topic_list = \'clickhouse_events_json\'';+CREATE TABLE posthog.kafka_events_json_native_json (+ uuid UUID,+ event String,+ properties String CODEC(ZSTD(3)),+ timestamp DateTime64(6, 'UTC'),+ team_id Int64,+ distinct_id String,+ elements_chain String,+ created_at DateTime64(6, 'UTC'),+ person_id UUID,+ person_created_at DateTime64(3),+ person_properties String CODEC(ZSTD(3)),+ group0_properties String CODEC(ZSTD(3)),+ group1_properties String CODEC(ZSTD(3)),+ group2_properties String CODEC(ZSTD(3)),+ group3_properties String CODEC(ZSTD(3)),+ group4_properties String CODEC(ZSTD(3)),+ group0_created_at DateTime64(3),+ group1_created_at DateTime64(3),+ group2_created_at DateTime64(3),+ group3_created_at DateTime64(3),+ group4_created_at DateTime64(3),+ person_mode Enum8('full'=0, 'propertyless'=1, 'force_upgrade'=2),+ historical_migration Bool,+ dmat_string_0 Nullable(String),+ dmat_string_1 Nullable(String),+ dmat_string_2 Nullable(String),+ dmat_string_3 Nullable(String),+ dmat_string_4 Nullable(String),+ dmat_string_5 Nullable(String),+ dmat_string_6 Nullable(String),+ dmat_string_7 Nullable(String),+ dmat_string_8 Nullable(String),+ dmat_string_9 Nullable(String)+) ENGINE = Kafka() SETTINGS kafka_broker_list = 'msk_cluster', kafka_format = 'kafka_format = \'JSONEachRow\'', kafka_group_name = 'kafka_group_name = \'clickhouse_events_json_native_json\'', kafka_skip_broken_messages = 100, kafka_topic_list = 'kafka_topic_list = \'clickhouse_events_json\'';+CREATE TABLE posthog.kafka_flag_evaluations (+ uuid UUID,+ event LowCardinality(String),+ properties String,+ timestamp DateTime64(6, 'UTC'),+ team_id Int64,+ distinct_id String,+ created_at DateTime64(6, 'UTC'),+ person_id UUID,+ person_properties String,+ group0_properties String,+ group1_properties String,+ group2_properties String,+ group3_properties String,+ group4_properties String,+ inserted_at DateTime64(6, 'UTC')+) ENGINE = Kafka() SETTINGS kafka_broker_list = 'warpstream_ingestion', kafka_format = 'kafka_format = \'JSONEachRow\'', kafka_group_name = 'kafka_group_name = \'clickhouse_flag_evaluations\'', kafka_skip_broken_messages = 100, kafka_topic_list = 'kafka_topic_list = \'clickhouse_flag_evaluations\'';+CREATE TABLE posthog.kafka_groups (+ group_type_index UInt8,+ group_key String,+ created_at DateTime64(3),+ team_id Int64,+ group_properties String+) ENGINE = Kafka() SETTINGS kafka_broker_list = 'msk_cluster', kafka_format = 'kafka_format = \'JSONEachRow\'', kafka_group_name = 'kafka_group_name = \'group1\'', kafka_topic_list = 'kafka_topic_list = \'clickhouse_groups\'';+CREATE TABLE posthog.kafka_heatmaps (+ session_id String,+ team_id Int64,+ distinct_id String,+ timestamp DateTime64(6, 'UTC'),+ x Int16,+ y Int16,+ scale_factor Int16,+ viewport_width Int16,+ viewport_height Int16,+ pointer_target_fixed Bool,+ current_url String,+ type LowCardinality(String)+) ENGINE = Kafka() SETTINGS kafka_broker_list = 'msk_cluster', kafka_format = 'kafka_format = \'JSONEachRow\'', kafka_group_name = 'kafka_group_name = \'group1\'', kafka_topic_list = 'kafka_topic_list = \'clickhouse_heatmap_events\'';+CREATE TABLE posthog.kafka_hog_invocation_results (+ team_id Int64,+ function_kind LowCardinality(String),+ function_id String,+ invocation_id String,+ parent_run_id String,+ status LowCardinality(String),+ attempts UInt8,+ is_retry UInt8,+ scheduled_at DateTime64(6, 'UTC'),+ first_scheduled_at DateTime64(6, 'UTC'),+ started_at Nullable(DateTime64(6, 'UTC')),+ finished_at Nullable(DateTime64(6, 'UTC')),+ duration_ms Nullable(UInt32),+ error_kind LowCardinality(String),+ error_message String,+ event_uuid String,+ distinct_id String,+ person_id String,+ invocation_globals String,+ version UInt64,+ is_deleted UInt8+) ENGINE = Kafka() SETTINGS kafka_broker_list = 'warpstream_cyclotron', kafka_format = 'kafka_format = \'JSONEachRow\'', kafka_group_name = 'kafka_group_name = \'clickhouse_hog_invocation_results\'', kafka_skip_broken_messages = 100, kafka_topic_list = 'kafka_topic_list = \'clickhouse_hog_invocation_results\'';+CREATE TABLE posthog.kafka_ingestion_warnings (+ team_id Int64,+ source LowCardinality(String),+ type String,+ details String CODEC(ZSTD(3)),+ timestamp DateTime64(6, 'UTC')+) ENGINE = Kafka() SETTINGS kafka_broker_list = 'msk_cluster', kafka_format = 'kafka_format = \'JSONEachRow\'', kafka_group_name = 'kafka_group_name = \'group1\'', kafka_topic_list = 'kafka_topic_list = \'clickhouse_ingestion_warnings\'';+CREATE TABLE posthog.kafka_ingestion_warnings_v2 (+ team_id Int64,+ source LowCardinality(String),+ type String,+ details String,+ timestamp DateTime64(6, 'UTC')+) ENGINE = Kafka() SETTINGS kafka_broker_list = 'warpstream_ingestion', kafka_format = 'kafka_format = \'JSONEachRow\'', kafka_group_name = 'kafka_group_name = \'clickhouse_ingestion_warnings_v2\'', kafka_topic_list = 'kafka_topic_list = \'clickhouse_ingestion_warnings\'';+CREATE TABLE posthog.kafka_log_entries_v3 (+ team_id UInt64,+ log_source LowCardinality(String),+ log_source_id String,+ instance_id String,+ timestamp DateTime64(6, 'UTC'),+ level LowCardinality(String),+ message String+) ENGINE = Kafka() SETTINGS kafka_broker_list = 'msk_cluster', kafka_format = 'kafka_format = \'JSONEachRow\'', kafka_group_name = 'kafka_group_name = \'clickhouse_log_entries\'', kafka_skip_broken_messages = 100, kafka_topic_list = 'kafka_topic_list = \'log_entries\'';+CREATE TABLE posthog.kafka_log_entries_ws (+ team_id UInt64,+ log_source LowCardinality(String),+ log_source_id String,+ instance_id String,+ timestamp DateTime64(6, 'UTC'),+ level LowCardinality(String),+ message String+) ENGINE = Kafka() SETTINGS kafka_broker_list = 'warpstream_ingestion', kafka_format = 'kafka_format = \'JSONEachRow\'', kafka_group_name = 'kafka_group_name = \'clickhouse_log_entries_ws\'', kafka_skip_broken_messages = 100, kafka_topic_list = 'kafka_topic_list = \'log_entries\'';+CREATE TABLE posthog.kafka_logs_avro (+ uuid String,+ trace_id String,+ span_id String,+ trace_flags Int32,+ timestamp DateTime64(6),+ observed_timestamp DateTime64(6),+ body String,+ severity_text String,+ severity_number Int32,+ service_name String,+ resource_attributes Map(LowCardinality(String), String),+ instrumentation_scope String,+ event_name String,+ attributes Map(LowCardinality(String), String)+) ENGINE = Kafka() SETTINGS kafka_broker_list = 'warpstream_logs', kafka_format = 'kafka_format = \'Avro\'', kafka_group_name = 'kafka_group_name = \'clickhouse-logs-avro-new\'', kafka_num_consumers = 8, kafka_poll_max_batch_size = 1000, kafka_poll_timeout_ms = 3000, kafka_skip_broken_messages = 100, kafka_thread_per_consumer = 1, kafka_topic_list = 'kafka_topic_list = \'clickhouse_logs\'';+CREATE TABLE posthog.kafka_message_assets (+ team_id Int64,+ function_kind LowCardinality(String),+ function_id String,+ parent_run_id String,+ invocation_id String,+ action_id String,+ kind LowCardinality(String),+ distinct_id String,+ person_id String,+ recipient String,+ subject String,+ status LowCardinality(String),+ sent_at DateTime64(6, 'UTC'),+ version UInt64,+ is_deleted UInt8,+ html String+) ENGINE = Kafka() SETTINGS kafka_broker_list = 'warpstream_cyclotron', kafka_format = 'kafka_format = \'JSONEachRow\'', kafka_group_name = 'kafka_group_name = \'clickhouse_message_assets\'', kafka_skip_broken_messages = 100, kafka_topic_list = 'kafka_topic_list = \'clickhouse_message_assets\'';+CREATE TABLE posthog.kafka_performance_events (+ uuid UUID,+ session_id String,+ window_id String,+ pageview_id String,+ distinct_id String,+ timestamp DateTime64(3),+ time_origin DateTime64(3, 'UTC'),+ entry_type LowCardinality(String),+ name String,+ team_id Int64,+ current_url String,+ start_time Float64,+ duration Float64,+ redirect_start Float64,+ redirect_end Float64,+ worker_start Float64,+ fetch_start Float64,+ domain_lookup_start Float64,+ domain_lookup_end Float64,+ connect_start Float64,+ secure_connection_start Float64,+ connect_end Float64,+ request_start Float64,+ response_start Float64,+ response_end Float64,+ decoded_body_size Int64,+ encoded_body_size Int64,+ initiator_type LowCardinality(String),+ next_hop_protocol LowCardinality(String),+ render_blocking_status LowCardinality(String),+ response_status Int64,+ transfer_size Int64,+ largest_contentful_paint_element String,+ largest_contentful_paint_render_time Float64,+ largest_contentful_paint_load_time Float64,+ largest_contentful_paint_size Float64,+ largest_contentful_paint_id String,+ largest_contentful_paint_url String,+ dom_complete Float64,+ dom_content_loaded_event Float64,+ dom_interactive Float64,+ load_event_end Float64,+ load_event_start Float64,+ redirect_count Int64,+ navigation_type LowCardinality(String),+ unload_event_end Float64,+ unload_event_start Float64+) ENGINE = Kafka() SETTINGS kafka_broker_list = 'msk_cluster', kafka_format = 'kafka_format = \'JSONEachRow\'', kafka_group_name = 'kafka_group_name = \'group1\'', kafka_topic_list = 'kafka_topic_list = \'clickhouse_performance_events\'';+CREATE TABLE posthog.kafka_person (+ id UUID,+ created_at DateTime64(3),+ team_id Int64,+ properties String,+ is_identified Int8,+ is_deleted Int8,+ version UInt64,+ last_seen_at Nullable(DateTime64(3))+) ENGINE = Kafka() SETTINGS kafka_broker_list = 'msk_cluster', kafka_format = 'kafka_format = \'JSONEachRow\'', kafka_group_name = 'kafka_group_name = \'group1\'', kafka_topic_list = 'kafka_topic_list = \'clickhouse_person\'';+CREATE TABLE posthog.kafka_person_distinct_id (+ distinct_id String,+ person_id UUID,+ team_id Int64,+ _sign Nullable(Int8),+ is_deleted Nullable(Int8)+) ENGINE = Kafka() SETTINGS kafka_broker_list = 'msk_cluster', kafka_format = 'kafka_format = \'JSONEachRow\'', kafka_group_name = 'kafka_group_name = \'group1\'', kafka_topic_list = 'kafka_topic_list = \'clickhouse_person_unique_id\'';+CREATE TABLE posthog.kafka_person_distinct_id2 (+ team_id Int64,+ distinct_id String,+ person_id UUID,+ is_deleted Int8,+ version Int64+) ENGINE = Kafka() SETTINGS kafka_broker_list = 'msk_cluster', kafka_format = 'kafka_format = \'JSONEachRow\'', kafka_group_name = 'kafka_group_name = \'group1\'', kafka_topic_list = 'kafka_topic_list = \'clickhouse_person_distinct_id\'';+CREATE TABLE posthog.kafka_person_distinct_id_overrides (+ team_id Int64,+ distinct_id String,+ person_id UUID,+ is_deleted Int8,+ version Int64+) ENGINE = Kafka() SETTINGS kafka_broker_list = 'msk_cluster', kafka_format = 'kafka_format = \'JSONEachRow\'', kafka_group_name = 'kafka_group_name = \'clickhouse-person-distinct-id-overrides\'', kafka_topic_list = 'kafka_topic_list = \'clickhouse_person_distinct_id\'';+CREATE TABLE posthog.kafka_person_overrides (+ team_id Int32,+ old_person_id UUID,+ override_person_id UUID,+ merged_at DateTime64(6, 'UTC'),+ oldest_event DateTime64(6, 'UTC'),+ version Int32+) ENGINE = Kafka() SETTINGS kafka_broker_list = 'kafka:9092', kafka_format = 'JSONEachRow', kafka_group_name = 'clickhouse-person-overrides', kafka_topic_list = 'clickhouse_person_override';+CREATE TABLE posthog.kafka_plugin_log_entries (+ id UUID,+ team_id Int64,+ plugin_id Int64,+ plugin_config_id Int64,+ timestamp DateTime64(6, 'UTC'),+ source String,+ type String,+ message String,+ instance_id UUID+) ENGINE = Kafka() SETTINGS kafka_broker_list = 'msk_cluster', kafka_format = 'kafka_format = \'JSONEachRow\'', kafka_group_name = 'kafka_group_name = \'group1\'', kafka_topic_list = 'kafka_topic_list = \'plugin_log_entries\'';+CREATE TABLE posthog.kafka_posthog_document_embeddings (+ team_id Int64,+ product LowCardinality(String),+ document_type LowCardinality(String),+ model_name LowCardinality(String),+ rendering LowCardinality(String),+ document_id String,+ timestamp DateTime64(3, 'UTC'),+ inserted_at DateTime64(3, 'UTC'),+ content String,+ metadata String,+ embedding Array(Float64)+) ENGINE = Kafka() SETTINGS kafka_broker_list = 'msk_cluster', kafka_format = 'kafka_format = \'JSONEachRow\'', kafka_group_name = 'kafka_group_name = \'clickhouse_document_embeddings\'', kafka_topic_list = 'kafka_topic_list = \'clickhouse_document_embeddings\'';+CREATE TABLE posthog.kafka_precalculated_events (+ team_id Int64,+ date Nullable(Date),+ distinct_id String,+ person_id UUID,+ condition String,+ uuid UUID,+ source String+) ENGINE = Kafka() SETTINGS kafka_broker_list = 'msk_cluster', kafka_flush_interval_ms = 7500, kafka_format = 'kafka_format = \'JSONEachRow\'', kafka_group_name = 'kafka_group_name = \'clickhouse_prefiltered_events\'', kafka_max_block_size = 1000000, kafka_num_consumers = 1, kafka_poll_max_batch_size = 100000, kafka_poll_timeout_ms = 1000, kafka_skip_broken_messages = 100, kafka_topic_list = 'kafka_topic_list = \'clickhouse_prefiltered_events\'';+CREATE TABLE posthog.kafka_precalculated_person_properties (+ team_id Int64,+ distinct_id String,+ person_id UUID,+ condition String,+ matches Bool,+ source String+) ENGINE = Kafka() SETTINGS kafka_broker_list = 'msk_cluster', kafka_flush_interval_ms = 7500, kafka_format = 'kafka_format = \'JSONEachRow\'', kafka_group_name = 'kafka_group_name = \'clickhouse_precalculated_person_properties\'', kafka_max_block_size = 1000000, kafka_num_consumers = 1, kafka_poll_max_batch_size = 100000, kafka_poll_timeout_ms = 1000, kafka_skip_broken_messages = 100, kafka_topic_list = 'kafka_topic_list = \'clickhouse_precalculated_person_properties\'';+CREATE TABLE posthog.kafka_precalculated_person_properties_ws (+ team_id Int64,+ distinct_id String,+ person_id UUID,+ condition String,+ matches Bool,+ source String+) ENGINE = Kafka() SETTINGS kafka_broker_list = 'warpstream_calculated_events', kafka_flush_interval_ms = 7500, kafka_format = 'kafka_format = \'JSONEachRow\'', kafka_group_name = 'kafka_group_name = \'clickhouse_precalculated_person_properties_ws\'', kafka_max_block_size = 1000000, kafka_num_consumers = 1, kafka_poll_max_batch_size = 100000, kafka_poll_timeout_ms = 1000, kafka_skip_broken_messages = 100, kafka_topic_list = 'kafka_topic_list = \'clickhouse_precalculated_person_properties\'';+CREATE TABLE posthog.kafka_property_values (+ team_id Int64,+ property_type LowCardinality(String),+ property_key String,+ property_value String,+ property_count UInt64+) ENGINE = Kafka() SETTINGS kafka_broker_list = 'warpstream_ingestion', kafka_format = 'kafka_format = \'JSONEachRow\'', kafka_group_name = 'kafka_group_name = \'clickhouse_property_values\'', kafka_num_consumers = 8, kafka_thread_per_consumer = 1, kafka_topic_list = 'kafka_topic_list = \'clickhouse_property_values\'';+CREATE TABLE posthog.kafka_session_replay_events (+ session_id String,+ team_id Int64,+ distinct_id String,+ first_timestamp DateTime64(6, 'UTC'),+ last_timestamp DateTime64(6, 'UTC'),+ block_url Nullable(String),+ first_url Nullable(String),+ urls Array(String),+ click_count Int64,+ keypress_count Int64,+ mouse_activity_count Int64,+ active_milliseconds Int64,+ console_log_count Int64,+ console_warn_count Int64,+ console_error_count Int64,+ size Int64,+ event_count Int64,+ message_count Int64,+ snapshot_source LowCardinality(Nullable(String)),+ snapshot_library Nullable(String),+ retention_period_days Nullable(Int64),+ is_deleted UInt8,+ ai_tags_fixed Array(String),+ ai_tags_freeform Array(String),+ ai_highlighted UInt8,+ surfacing_score Nullable(Float32)+) ENGINE = Kafka() SETTINGS kafka_broker_list = 'msk_cluster', kafka_format = 'kafka_format = \'JSONEachRow\'', kafka_group_name = 'kafka_group_name = \'group1\'', kafka_topic_list = 'kafka_topic_list = \'clickhouse_session_replay_events\'';+CREATE TABLE posthog.kafka_session_replay_features (+ session_id String,+ team_id Int64,+ distinct_id String,+ batch_id String,+ first_timestamp DateTime64(6, 'UTC'),+ last_timestamp DateTime64(6, 'UTC'),+ event_count Int64,+ mouse_position_count Int64,+ mouse_sum_x Float64,+ mouse_sum_x_squared Float64,+ mouse_sum_y Float64,+ mouse_sum_y_squared Float64,+ mouse_distance_traveled Float64,+ mouse_direction_change_count Int64,+ mouse_velocity_sum Float64,+ mouse_velocity_sum_of_squares Float64,+ mouse_velocity_count Int64,+ scroll_event_count Int64,+ total_scroll_magnitude Float64,+ scroll_direction_reversal_count Int64,+ rapid_scroll_reversal_count Int64,+ scroll_to_top_count Int64,+ click_count Int64,+ keypress_count Int64,+ mouse_activity_count Int64,+ rage_click_count Int64,+ dead_click_count Int64,+ backspace_count Int64,+ inter_action_gap_count Int64,+ inter_action_gap_sum_ms Float64,+ inter_action_gap_sum_of_squares_ms Float64,+ max_idle_gap_ms Float64,+ long_idle_gap_count Int64,+ quick_back_count Int64,+ page_visit_count Int64,+ visited_urls Array(String),+ login_path_visit_count Int64,+ signup_path_visit_count Int64,+ checkout_path_visit_count Int64,+ cart_path_visit_count Int64,+ billing_path_visit_count Int64,+ settings_path_visit_count Int64,+ account_path_visit_count Int64,+ error_path_visit_count Int64,+ not_found_path_visit_count Int64,+ admin_path_visit_count Int64,+ dashboard_path_visit_count Int64,+ onboarding_path_visit_count Int64,+ cancel_path_visit_count Int64,+ refund_path_visit_count Int64,+ console_error_count Int64,+ console_error_after_click_count Int64,+ console_warn_count Int64,+ network_request_count Int64,+ network_failed_request_count Int64,+ network_4xx_count Int64,+ network_5xx_count Int64,+ network_request_duration_sum Float64,+ network_request_duration_sum_of_squares Float64,+ network_request_duration_count Int64,+ mutation_count Int64,+ viewport_resize_count Int64,+ touch_event_count Int64,+ max_scroll_y Float64,+ click_target_ids Array(Int64),+ form_field_ids Array(Int64),+ text_selection_count Int64,+ selection_copy_count Int64,+ is_deleted UInt8+) ENGINE = Kafka() SETTINGS kafka_broker_list = 'msk_cluster', kafka_format = 'kafka_format = \'JSONEachRow\'', kafka_group_name = 'kafka_group_name = \'group1\'', kafka_topic_list = 'kafka_topic_list = \'clickhouse_session_replay_features\'';+CREATE TABLE posthog.kafka_tophog (+ timestamp DateTime64(6, 'UTC'),+ metric LowCardinality(String),+ type LowCardinality(String),+ key Map(LowCardinality(String), String),+ value Float64,+ count UInt64,+ pipeline LowCardinality(String),+ lane LowCardinality(String),+ labels Map(LowCardinality(String), String)+) ENGINE = Kafka() SETTINGS date_time_input_format = 'best_effort', kafka_broker_list = 'msk_cluster', kafka_format = 'kafka_format = \'JSONEachRow\'', kafka_group_name = 'kafka_group_name = \'clickhouse_tophog\'', kafka_skip_broken_messages = 100, kafka_topic_list = 'kafka_topic_list = \'clickhouse_tophog\'';+CREATE TABLE posthog.kafka_tophog_ws (+ timestamp DateTime64(6, 'UTC'),+ metric LowCardinality(String),+ type LowCardinality(String),+ key Map(LowCardinality(String), String),+ value Float64,+ count UInt64,+ pipeline LowCardinality(String),+ lane LowCardinality(String),+ labels Map(LowCardinality(String), String)+) ENGINE = Kafka() SETTINGS date_time_input_format = 'best_effort', kafka_broker_list = 'warpstream_ingestion', kafka_format = 'kafka_format = \'JSONEachRow\'', kafka_group_name = 'kafka_group_name = \'clickhouse_tophog_ws\'', kafka_skip_broken_messages = 100, kafka_topic_list = 'kafka_topic_list = \'clickhouse_tophog\'';+CREATE TABLE posthog.kafka_trace_spans_avro (+ uuid String,+ trace_id String,+ span_id String,+ parent_span_id String,+ trace_state String,+ name String,+ kind Int32,+ flags Int32,+ timestamp DateTime64(6),+ end_time DateTime64(6),+ observed_timestamp DateTime64(6),+ service_name String,+ resource_attributes Map(LowCardinality(String), String),+ instrumentation_scope String,+ attributes Map(LowCardinality(String), String),+ dropped_attributes_count Int32,+ events Array(String),+ dropped_events_count Int32,+ links Array(String),+ dropped_links_count Int32,+ status_code Int32+) ENGINE = Kafka() SETTINGS kafka_broker_list = 'warpstream_traces', kafka_format = 'kafka_format = \'Avro\'', kafka_group_name = 'kafka_group_name = \'clickhouse-traces-avro\'', kafka_num_consumers = 8, kafka_poll_max_batch_size = 1000, kafka_poll_timeout_ms = 3000, kafka_skip_broken_messages = 100, kafka_thread_per_consumer = 1, kafka_topic_list = 'kafka_topic_list = \'clickhouse_traces\'';+CREATE TABLE posthog.kafka_usage_report_events_preagg (+ uuid UUID,+ event String,+ properties String CODEC(ZSTD(3)),+ timestamp DateTime64(6, 'UTC'),+ team_id Int64,+ distinct_id String,+ person_mode Enum8('full'=0, 'propertyless'=1, 'force_upgrade'=2)+) ENGINE = Kafka() SETTINGS kafka_broker_list = 'warpstream_ingestion', kafka_format = 'kafka_format = \'JSONEachRow\'', kafka_group_name = 'kafka_group_name = \'clickhouse_usage_report_events_preagg\'', kafka_num_consumers = 1, kafka_skip_broken_messages = 100, kafka_thread_per_consumer = 1, kafka_topic_list = 'kafka_topic_list = \'clickhouse_events_json\'';+CREATE TABLE posthog.llma_metrics_daily (+ date Date,+ team_id UInt64,+ metric_name String,+ metric_value Float64+) ENGINE = ReplicatedMergeTree('/clickhouse/tables/noshard/posthog.llma_metrics_daily', '{replica}-{shard}') ORDER BY (team_id, date, metric_name) PARTITION BY toYYYYMM(date) SETTINGS index_granularity = 8192;+CREATE TABLE posthog.log_attributes (+ team_id Int32 CODEC(DoubleDelta, ZSTD(1)),+ time_bucket DateTime64(0) CODEC(DoubleDelta, ZSTD(1)),+ original_expiry_time_bucket DateTime64(0) CODEC(DoubleDelta, ZSTD(1)),+ service_name LowCardinality(String) CODEC(ZSTD(1)),+ resource_fingerprint UInt64 DEFAULT 0 CODEC(DoubleDelta, ZSTD(1)),+ attribute_key LowCardinality(String) CODEC(ZSTD(1)),+ attribute_value String CODEC(ZSTD(1)),+ attribute_count SimpleAggregateFunction(sum, UInt64),+ attribute_type LowCardinality(String),+ INDEX idx_attribute_key attribute_key TYPE bloom_filter(0.01) GRANULARITY 1,+ INDEX idx_attribute_value attribute_value TYPE bloom_filter(0.01) GRANULARITY 1,+ INDEX idx_attribute_key_n3 attribute_key TYPE ngrambf_v1(3, 32768, 3, 0) GRANULARITY 1,+ INDEX idx_attribute_value_n3 attribute_value TYPE ngrambf_v1(3, 32768, 3, 0) GRANULARITY 1+) ENGINE = ReplicatedAggregatingMergeTree('/clickhouse/tables/noshard/posthog.log_attributes', '{replica}-{shard}') ORDER BY (team_id, attribute_type, time_bucket, resource_fingerprint, attribute_key, attribute_value) PARTITION BY toDate(original_expiry_time_bucket) SETTINGS deduplicate_merge_projection_mode = 'drop', index_granularity = 8192, storage_policy = 'default';+CREATE TABLE posthog.log_attributes2 (+ team_id Int32,+ time_bucket DateTime64(0),+ service_name LowCardinality(String),+ resource_fingerprint UInt64 DEFAULT 0,+ attribute_key LowCardinality(String),+ attribute_value String CODEC(ZSTD(5)),+ attribute_count SimpleAggregateFunction(sum, UInt64),+ attribute_type LowCardinality(String) DEFAULT 'log',+ original_expiry_time_bucket DateTime DEFAULT now(),+ INDEX idx_attribute_key attribute_key TYPE bloom_filter(0.01) GRANULARITY 1,+ INDEX idx_attribute_value attribute_value TYPE bloom_filter(0.01) GRANULARITY 1,+ INDEX idx_attribute_key_n3 attribute_key TYPE ngrambf_v1(3, 32768, 3, 0) GRANULARITY 1,+ INDEX idx_attribute_value_n3 attribute_value TYPE ngrambf_v1(3, 32768, 3, 0) GRANULARITY 1+) ENGINE = ReplicatedAggregatingMergeTree('/clickhouse/tables/noshard/posthog.log_attributes2', '{replica}-{shard}') ORDER BY (team_id, attribute_type, time_bucket, resource_fingerprint, attribute_key, attribute_value) PARTITION BY toDate(original_expiry_time_bucket) TTL original_expiry_time_bucket SETTINGS deduplicate_merge_projection_mode = 'drop', index_granularity = 8192;+CREATE TABLE posthog.log_attributes3 (+ team_id Int32,+ time_bucket DateTime64(0),+ service_name LowCardinality(String),+ resource_fingerprint UInt64 DEFAULT 0,+ attribute_key LowCardinality(String),+ attribute_value String CODEC(ZSTD(5)),+ attribute_count SimpleAggregateFunction(sum, UInt64),+ attribute_type LowCardinality(String) DEFAULT 'log',+ original_expiry_time_bucket DateTime DEFAULT now(),+ severity_text LowCardinality(String),+ INDEX idx_attribute_key attribute_key TYPE bloom_filter(0.01) GRANULARITY 1,+ INDEX idx_attribute_value attribute_value TYPE bloom_filter(0.01) GRANULARITY 1,+ INDEX idx_attribute_key_n3 attribute_key TYPE ngrambf_v1(3, 32768, 3, 0) GRANULARITY 1,+ INDEX idx_attribute_value_n3 attribute_value TYPE ngrambf_v1(3, 32768, 3, 0) GRANULARITY 1+) ENGINE = ReplicatedAggregatingMergeTree('/clickhouse/tables/noshard/posthog.log_attributes3', '{replica}-{shard}') ORDER BY (team_id, attribute_type, time_bucket, resource_fingerprint, attribute_key, attribute_value, severity_text) PARTITION BY toDate(original_expiry_time_bucket) TTL original_expiry_time_bucket SETTINGS deduplicate_merge_projection_mode = 'drop', index_granularity = 8192;+CREATE TABLE posthog.log_attributes_distributed (+ team_id Int32,+ time_bucket DateTime64(0),+ service_name LowCardinality(String),+ resource_fingerprint UInt64 DEFAULT 0,+ attribute_key LowCardinality(String),+ attribute_value String CODEC(ZSTD(5)),+ attribute_count SimpleAggregateFunction(sum, UInt64),+ attribute_type LowCardinality(String) DEFAULT 'log',+ original_expiry_time_bucket DateTime DEFAULT now(),+ severity_text LowCardinality(String)+) ENGINE = Distributed('posthog_single_shard', 'posthog', 'log_attributes3');+CREATE TABLE posthog.logs32 (+ time_bucket DateTime MATERIALIZED toStartOfDay(timestamp) CODEC(DoubleDelta, ZSTD(1)),+ original_expiry_timestamp DateTime64(6) CODEC(DoubleDelta, ZSTD(1)),+ uuid String CODEC(ZSTD(1)),+ team_id Int32 CODEC(ZSTD(1)),+ trace_id String CODEC(ZSTD(1)),+ span_id String CODEC(ZSTD(1)),+ trace_flags Int32 CODEC(ZSTD(1)),+ timestamp DateTime64(6) CODEC(DoubleDelta, ZSTD(1)),+ observed_timestamp DateTime64(6) CODEC(DoubleDelta, ZSTD(1)),+ created_at DateTime64(6) MATERIALIZED now() CODEC(DoubleDelta, ZSTD(1)),+ body String CODEC(ZSTD(1)),+ severity_text LowCardinality(String) CODEC(ZSTD(1)),+ severity_number Int32 CODEC(ZSTD(1)),+ service_name LowCardinality(String) CODEC(ZSTD(1)),+ resource_attributes Map(LowCardinality(String), String) CODEC(ZSTD(1)),+ resource_fingerprint UInt64 MATERIALIZED cityHash64(resource_attributes) CODEC(DoubleDelta, ZSTD(1)),+ instrumentation_scope String CODEC(ZSTD(1)),+ event_name String CODEC(ZSTD(1)),+ attributes_map_str Map(LowCardinality(String), String) CODEC(ZSTD(1)),+ level String ALIAS severity_text,+ mat_body_ipv4_matches Array(String) ALIAS extractAll(body, '(\\d\\.((25[0-5]|(2[0-4]|1(0, 1)[0-9])(0, 1)[0-9])\\.)(2, 2)([0-9]))'),+ time_minute DateTime ALIAS toStartOfMinute(timestamp),+ attributes Map(LowCardinality(String), String) ALIAS mapApply((k, v) -> (left(k, -5), v), attributes_map_str),+ attributes_map_float Map(LowCardinality(String), Float64) MATERIALIZED mapFilter((k, v) -> (v IS NOT NULL), mapApply((k, v) -> (concat(left(k, -5), '__float'), toFloat64OrNull(v)), attributes_map_str)) CODEC(ZSTD(1)),+ attributes_map_datetime Map(LowCardinality(String), DateTime64(6)) MATERIALIZED mapFilter((k, v) -> (v IS NOT NULL), mapApply((k, v) -> (concat(left(k, -5), '__datetime'), parseDateTimeBestEffortOrNull(v, 6)), attributes_map_str)) CODEC(ZSTD(1)),+ _partition UInt32 CODEC(DoubleDelta, ZSTD(1)),+ _topic String,+ _offset UInt64 CODEC(DoubleDelta, ZSTD(1)),+ _bytes_uncompressed UInt64 CODEC(DoubleDelta, ZSTD(1)),+ _bytes_compressed UInt64 CODEC(DoubleDelta, ZSTD(1)),+ _record_count UInt64 CODEC(DoubleDelta, ZSTD(1)),+ INDEX idx_severity_text_set severity_text TYPE set(10) GRANULARITY 1,+ INDEX idx_attributes_str_keys mapKeys(attributes_map_str) TYPE bloom_filter(0.01) GRANULARITY 1,+ INDEX idx_attributes_str_values mapValues(attributes_map_str) TYPE bloom_filter(0.001) GRANULARITY 1,+ INDEX idx_mat_body_ipv4_matches mat_body_ipv4_matches TYPE bloom_filter(0.01) GRANULARITY 1,+ INDEX idx_body_ngram3 lower(body) TYPE ngrambf_v1(3, 25000, 2, 0) GRANULARITY 1,+ INDEX idx_uuid_bloom uuid TYPE bloom_filter(0.01) GRANULARITY 1,+ INDEX idx_observed_minmax observed_timestamp TYPE minmax GRANULARITY 1,+ INDEX idx_timestamp_minmax timestamp TYPE minmax GRANULARITY 1,+ PROJECTION projection_aggregate_counts (SELECT+ team_id,+ time_bucket,+ toStartOfMinute(timestamp),+ service_name,+ severity_text,+ resource_fingerprint,+ count() AS event_count+GROUP BY+ team_id, time_bucket, toStartOfMinute(timestamp), service_name, severity_text, resource_fingerprint)+) ENGINE = ReplicatedMergeTree('/clickhouse/tables/noshard/posthog.logs32', '{replica}-{shard}') ORDER BY (team_id, time_bucket, service_name, resource_fingerprint, severity_text, timestamp) PARTITION BY toDate(original_expiry_timestamp) SETTINGS add_minmax_index_for_numeric_columns = 1, allow_experimental_reverse_key = 1, allow_remote_fs_zero_copy_replication = 1, index_granularity = 8192, index_granularity_bytes = 104857600, storage_policy = 'default', ttl_only_drop_parts = 1;+CREATE TABLE posthog.logs34 (+ time_bucket DateTime MATERIALIZED toStartOfDay(timestamp),+ original_expiry_timestamp DateTime64(6),+ uuid String,+ team_id Int32,+ trace_id String,+ span_id String,+ trace_flags Int32,+ timestamp DateTime64(6) CODEC(DoubleDelta),+ observed_timestamp DateTime64(6),+ created_at DateTime64(6) MATERIALIZED now(),+ body String,+ severity_text LowCardinality(String),+ severity_number Int32,+ service_name LowCardinality(String),+ resource_attributes Map(LowCardinality(String), String),+ resource_fingerprint UInt64 MATERIALIZED cityHash64(resource_attributes),+ instrumentation_scope String,+ event_name String,+ attributes_map_str Map(LowCardinality(String), String),+ level String ALIAS severity_text,+ mat_body_ipv4_matches Array(String) ALIAS extractAll(body, '(\\d\\.((25[0-5]|(2[0-4]|1(0, 1)[0-9])(0, 1)[0-9])\\.)(2, 2)([0-9]))'),+ time_minute DateTime ALIAS toStartOfMinute(timestamp),+ attributes Map(LowCardinality(String), String) ALIAS mapApply((k, v) -> (left(k, -5), v), attributes_map_str),+ attributes_map_float Map(LowCardinality(String), Float64) MATERIALIZED mapFilter((k, v) -> (v IS NOT NULL), mapApply((k, v) -> (concat(left(k, -5), '__float'), toFloat64OrNull(v)), attributes_map_str)),+ attributes_map_datetime Map(LowCardinality(String), DateTime64(6)) MATERIALIZED mapFilter((k, v) -> (v IS NOT NULL), mapApply((k, v) -> (concat(left(k, -5), '__datetime'), parseDateTimeBestEffortOrNull(v, 6)), attributes_map_str)),+ _partition UInt32,+ _topic String,+ _offset UInt64,+ _bytes_uncompressed UInt64,+ _bytes_compressed UInt64,+ _record_count UInt64,+ INDEX idx_severity_text_set severity_text TYPE set(10) GRANULARITY 1,+ INDEX idx_attributes_str_keys mapKeys(attributes_map_str) TYPE bloom_filter(0.01) GRANULARITY 1,+ INDEX idx_attributes_str_values mapValues(attributes_map_str) TYPE bloom_filter(0.001) GRANULARITY 1,+ INDEX idx_mat_body_ipv4_matches mat_body_ipv4_matches TYPE bloom_filter(0.01) GRANULARITY 1,+ INDEX idx_body_ngram3 lower(body) TYPE ngrambf_v1(3, 25000, 2, 0) GRANULARITY 1,+ INDEX idx_uuid_bloom uuid TYPE bloom_filter(0.01) GRANULARITY 1,+ INDEX idx_observed_minmax observed_timestamp TYPE minmax GRANULARITY 1,+ INDEX idx_timestamp_minmax timestamp TYPE minmax GRANULARITY 1,+ PROJECTION projection_aggregate_counts (SELECT+ team_id,+ time_bucket,+ toStartOfMinute(timestamp),+ service_name,+ severity_text,+ resource_fingerprint,+ count() AS event_count+GROUP BY+ team_id, time_bucket, toStartOfMinute(timestamp), service_name, severity_text, resource_fingerprint)+) ENGINE = ReplicatedMergeTree('/clickhouse/tables/noshard/posthog.logs34', '{replica}-{shard}') ORDER BY (team_id, time_bucket, service_name, resource_fingerprint, severity_text, timestamp) PARTITION BY toDate(original_expiry_timestamp) TTL original_expiry_timestamp SETTINGS add_minmax_index_for_numeric_columns = 1, allow_experimental_reverse_key = 1, index_granularity = 8192, index_granularity_bytes = 104857600, map_serialization_version = 'with_buckets', ttl_only_drop_parts = 1;+CREATE TABLE posthog.logs_billing_metrics (+ team_id Int32,+ time_bucket DateTime64(0),+ service_name LowCardinality(String),+ bytes_uncompressed SimpleAggregateFunction(sum, UInt64),+ bytes_compressed SimpleAggregateFunction(sum, UInt64),+ record_count SimpleAggregateFunction(sum, UInt64)+) ENGINE = ReplicatedAggregatingMergeTree('/clickhouse/tables/noshard/posthog.logs_billing_metrics', '{replica}-{shard}') ORDER BY (team_id, time_bucket, service_name) PARTITION BY toYYYYMM(time_bucket) SETTINGS deduplicate_merge_projection_mode = 'rebuild', index_granularity = 8192;+CREATE TABLE posthog.logs_billing_metrics_distributed (+ team_id Int32,+ time_bucket DateTime64(0),+ service_name LowCardinality(String),+ bytes_uncompressed SimpleAggregateFunction(sum, UInt64),+ bytes_compressed SimpleAggregateFunction(sum, UInt64),+ record_count SimpleAggregateFunction(sum, UInt64)+) ENGINE = Distributed('posthog_single_shard', 'posthog', 'logs_billing_metrics');+CREATE TABLE posthog.logs_distributed (+ time_bucket DateTime MATERIALIZED toStartOfDay(timestamp),+ original_expiry_timestamp DateTime64(6),+ uuid String,+ team_id Int32,+ trace_id String,+ span_id String,+ trace_flags Int32,+ timestamp DateTime64(6) CODEC(DoubleDelta),+ observed_timestamp DateTime64(6),+ created_at DateTime64(6) MATERIALIZED now(),+ body String,+ severity_text LowCardinality(String),+ severity_number Int32,+ service_name LowCardinality(String),+ resource_attributes Map(LowCardinality(String), String),+ resource_fingerprint UInt64 MATERIALIZED cityHash64(resource_attributes),+ instrumentation_scope String,+ event_name String,+ attributes_map_str Map(LowCardinality(String), String),+ level String ALIAS severity_text,+ mat_body_ipv4_matches Array(String) ALIAS extractAll(body, '(\\d\\.((25[0-5]|(2[0-4]|1(0, 1)[0-9])(0, 1)[0-9])\\.)(2, 2)([0-9]))'),+ time_minute DateTime ALIAS toStartOfMinute(timestamp),+ attributes Map(LowCardinality(String), String) ALIAS mapApply((k, v) -> (left(k, -5), v), attributes_map_str),+ attributes_map_float Map(LowCardinality(String), Float64) MATERIALIZED mapFilter((k, v) -> (v IS NOT NULL), mapApply((k, v) -> (concat(left(k, -5), '__float'), toFloat64OrNull(v)), attributes_map_str)),+ attributes_map_datetime Map(LowCardinality(String), DateTime64(6)) MATERIALIZED mapFilter((k, v) -> (v IS NOT NULL), mapApply((k, v) -> (concat(left(k, -5), '__datetime'), parseDateTimeBestEffortOrNull(v, 6)), attributes_map_str)),+ _partition UInt32,+ _topic String,+ _offset UInt64,+ _bytes_uncompressed UInt64,+ _bytes_compressed UInt64,+ _record_count UInt64+) ENGINE = Distributed('posthog_single_shard', 'posthog', 'logs34');+CREATE TABLE posthog.logs_kafka_metrics (+ _partition UInt32,+ _topic String,+ max_offset SimpleAggregateFunction(max, UInt64),+ max_observed_timestamp SimpleAggregateFunction(max, DateTime64(9)),+ max_timestamp SimpleAggregateFunction(max, DateTime64(9)),+ max_created_at SimpleAggregateFunction(max, DateTime64(9)),+ max_lag SimpleAggregateFunction(max, UInt64)+) ENGINE = ReplicatedAggregatingMergeTree('/clickhouse/tables/noshard/posthog.logs_kafka_metrics', '{replica}-{shard}') ORDER BY (_topic, _partition) SETTINGS index_granularity = 8192;+CREATE TABLE posthog.logs_kafka_metrics_distributed (+ _partition UInt32,+ _topic String,+ max_offset SimpleAggregateFunction(max, UInt64),+ max_observed_timestamp SimpleAggregateFunction(max, DateTime64(9)),+ max_timestamp SimpleAggregateFunction(max, DateTime64(9)),+ max_created_at SimpleAggregateFunction(max, DateTime64(9)),+ max_lag SimpleAggregateFunction(max, UInt64)+) ENGINE = Distributed('posthog_single_shard', 'posthog', 'logs_kafka_metrics');+CREATE TABLE posthog.message_assets_data (+ team_id Int64,+ function_kind LowCardinality(String),+ function_id String,+ parent_run_id String,+ invocation_id String,+ action_id String,+ kind LowCardinality(String),+ distinct_id String,+ person_id String,+ recipient String,+ subject String,+ status LowCardinality(String),+ sent_at DateTime64(6, 'UTC'),+ version UInt64,+ is_deleted UInt8 DEFAULT 0,+ html String CODEC(ZSTD(3)),+ _timestamp DateTime,+ _offset UInt64,+ _partition UInt64,+ INDEX parent_run_idx parent_run_id TYPE bloom_filter(0.01) GRANULARITY 1,+ INDEX distinct_id_idx distinct_id TYPE bloom_filter(0.01) GRANULARITY 1,+ INDEX person_id_idx person_id TYPE bloom_filter(0.01) GRANULARITY 1,+ INDEX recipient_idx recipient TYPE bloom_filter(0.01) GRANULARITY 1+) ENGINE = ReplicatedReplacingMergeTree('/clickhouse/tables/noshard/posthog.message_assets_data', '{replica}-{shard}', version) ORDER BY (team_id, function_kind, function_id, invocation_id, action_id) PARTITION BY toYYYYMMDD(sent_at) TTL toDate(sent_at) + toIntervalDay(30) SETTINGS index_granularity = 1024, ttl_only_drop_parts = 1;+CREATE TABLE posthog.metric_samples1 (+ team_id Int32,+ metric_name LowCardinality(String),+ series_fingerprint UInt64 CODEC(DoubleDelta),+ timestamp DateTime64(6) CODEC(DoubleDelta),+ value Float64 CODEC(Gorilla(8)),+ count UInt64 DEFAULT 1,+ histogram_bounds Array(Float64),+ histogram_counts Array(UInt64),+ trace_id String,+ span_id String,+ trace_flags Int32,+ INDEX idx_trace_id_bf trace_id TYPE bloom_filter(0.01) GRANULARITY 1+) ENGINE = ReplicatedMergeTree('/clickhouse/tables/noshard/posthog.metric_samples1', '{replica}-{shard}') ORDER BY (team_id, metric_name, series_fingerprint, timestamp) PARTITION BY toDate(timestamp) TTL toDateTime(timestamp) + toIntervalDay(30) SETTINGS index_granularity = 8192, ttl_only_drop_parts = 1;+CREATE TABLE posthog.metric_series1 (+ team_id Int32,+ metric_name LowCardinality(String),+ series_fingerprint UInt64 CODEC(DoubleDelta),+ metric_type LowCardinality(String),+ unit LowCardinality(String),+ aggregation_temporality LowCardinality(String),+ is_monotonic Bool DEFAULT false,+ service_name LowCardinality(String),+ resource_attributes Map(LowCardinality(String), String),+ attributes Map(LowCardinality(String), String),+ last_seen DateTime64(6) CODEC(DoubleDelta),+ INDEX idx_service_set service_name TYPE set(1000) GRANULARITY 1,+ INDEX idx_attr_keys mapKeys(attributes) TYPE bloom_filter(0.01) GRANULARITY 1,+ INDEX idx_attr_values mapValues(attributes) TYPE bloom_filter(0.01) GRANULARITY 1+) ENGINE = ReplicatedReplacingMergeTree('/clickhouse/tables/noshard/posthog.metric_series1', '{replica}-{shard}', last_seen) ORDER BY (team_id, metric_name, series_fingerprint) TTL toDateTime(last_seen) + toIntervalDay(90) SETTINGS index_granularity = 8192;+CREATE TABLE posthog.partitioned_sharded_posthog_document_embeddings (+ team_id Int64,+ product LowCardinality(String),+ document_type LowCardinality(String),+ model_name LowCardinality(String),+ rendering LowCardinality(String),+ document_id String,+ timestamp DateTime64(3, 'UTC'),+ inserted_at DateTime64(3, 'UTC'),+ content String DEFAULT '',+ metadata String DEFAULT '{}',+ embedding Array(Float64),+ _timestamp DateTime,+ _offset UInt64,+ _partition UInt64,+ INDEX kafka_timestamp_minmax_partitioned_sharded_posthog_document_embeddings _timestamp TYPE minmax GRANULARITY 3+) ENGINE = ReplicatedReplacingMergeTree('/clickhouse/tables/{shard}/posthog.partitioned_sharded_posthog_document_embeddings', '{replica}', inserted_at) ORDER BY (team_id, toDate(timestamp), product, document_type, model_name, rendering, cityHash64(document_id)) PARTITION BY toMonday(timestamp) TTL timestamp + toIntervalMonth(3) SETTINGS index_granularity = 512, ttl_only_drop_parts = 1;+CREATE TABLE posthog.person (+ id UUID,+ created_at DateTime64(3),+ team_id Int64,+ properties String,+ is_identified Int8,+ is_deleted Int8,+ version UInt64,+ last_seen_at Nullable(DateTime64(3)),+ _timestamp DateTime,+ _offset UInt64,+ INDEX kafka_timestamp_minmax_person _timestamp TYPE minmax GRANULARITY 3+) ENGINE = ReplicatedReplacingMergeTree('/clickhouse/tables/noshard/posthog.person', '{replica}-{shard}', version) ORDER BY (team_id, id) SETTINGS index_granularity = 8192;+CREATE TABLE posthog.person_distinct_id (+ distinct_id String COMMENT 'skip_0003_fill_person_distinct_id2',+ person_id UUID,+ team_id Int64,+ _sign Int8 DEFAULT 1,+ is_deleted Int8 ALIAS if(_sign = -1, 1, 0),+ _timestamp DateTime,+ _offset UInt64+) ENGINE = ReplicatedCollapsingMergeTree('/clickhouse/tables/noshard/posthog.person_distinct_id', '{replica}-{shard}', _sign) ORDER BY (team_id, distinct_id, person_id) SETTINGS index_granularity = 8192;+CREATE TABLE posthog.person_distinct_id2 (+ team_id Int64,+ distinct_id String,+ person_id UUID,+ is_deleted Int8,+ version Int64,+ _timestamp DateTime,+ _offset UInt64,+ _partition UInt64,+ INDEX kafka_timestamp_minmax_person_distinct_id2 _timestamp TYPE minmax GRANULARITY 3+) ENGINE = ReplicatedReplacingMergeTree('/clickhouse/tables/noshard/posthog.person_distinct_id2', '{replica}-{shard}', version) ORDER BY (team_id, distinct_id) SETTINGS index_granularity = 512;+CREATE TABLE posthog.person_distinct_id_overrides (+ team_id Int64,+ distinct_id String,+ person_id UUID,+ is_deleted Int8,+ version Int64,+ _timestamp DateTime,+ _offset UInt64,+ _partition UInt64,+ INDEX kafka_timestamp_minmax_person_distinct_id_overrides _timestamp TYPE minmax GRANULARITY 3+) ENGINE = ReplicatedReplacingMergeTree('/clickhouse/tables/noshard/posthog.person_distinct_id_overrides', '{replica}-{shard}', version) ORDER BY (team_id, distinct_id) SETTINGS index_granularity = 512;+CREATE TABLE posthog.person_overrides (+ team_id Int32,+ old_person_id UUID,+ override_person_id UUID,+ merged_at DateTime64(6, 'UTC'),+ oldest_event DateTime64(6, 'UTC'),+ created_at DateTime64(6, 'UTC') DEFAULT now(),+ version Int32+) ENGINE = ReplicatedReplacingMergeTree('/clickhouse/tables/noshard/posthog.person_overrides', '{replica}-{shard}', version) ORDER BY (team_id, old_person_id) PARTITION BY toYYYYMM(oldest_event) SETTINGS index_granularity = 8192;+CREATE TABLE posthog.person_static_cohort (+ id UUID,+ person_id UUID,+ cohort_id Int64,+ team_id Int64,+ _timestamp DateTime,+ _offset UInt64+) ENGINE = ReplicatedReplacingMergeTree('/clickhouse/tables/noshard/posthog.person_static_cohort', '{replica}-{shard}', _timestamp) ORDER BY (team_id, cohort_id, person_id, id) SETTINGS index_granularity = 8192;+CREATE TABLE posthog.pg_embeddings (+ domain String,+ team_id Int64,+ id String,+ vector Array(Float32),+ text String,+ properties String CODEC(ZSTD(3)),+ timestamp DateTime64(6, 'UTC') DEFAULT now('UTC'),+ is_deleted UInt8+) ENGINE = ReplicatedReplacingMergeTree('/clickhouse/tables/noshard/posthog.pg_embeddings', '{replica}-{shard}', timestamp, is_deleted) ORDER BY (team_id, domain, id) SETTINGS index_granularity = 512;+CREATE TABLE posthog.plugin_log_entries (+ id UUID,+ team_id Int64,+ plugin_id Int64,+ plugin_config_id Int64,+ timestamp DateTime64(6, 'UTC'),+ source String,+ type String,+ message String,+ instance_id UUID,+ _timestamp DateTime,+ _offset UInt64+) ENGINE = ReplicatedReplacingMergeTree('/clickhouse/tables/noshard/posthog.plugin_log_entries', '{replica}-{shard}', _timestamp) ORDER BY (team_id, plugin_id, plugin_config_id, timestamp) PARTITION BY toYYYYMMDD(timestamp) TTL toDate(timestamp) + toIntervalWeek(1) SETTINGS index_granularity = 512;+CREATE TABLE posthog.property_definitions (+ team_id UInt32,+ project_id Nullable(UInt32),+ name String,+ property_type Nullable(String),+ event Nullable(String),+ group_type_index Nullable(UInt8),+ type UInt8 DEFAULT 1,+ last_seen_at DateTime,+ version UInt64 MATERIALIZED bitShiftLeft(toUInt64(NOT isNull(property_type)), 48) + toUInt64(toUnixTimestamp(last_seen_at))+) ENGINE = ReplicatedReplacingMergeTree('/clickhouse/tables/noshard/posthog.property_definitions', '{replica}-{shard}', version) ORDER BY (team_id, type, coalesce(event, ''), name, coalesce(group_type_index, 255)) SETTINGS index_granularity = 8192;+CREATE TABLE posthog.property_values (+ team_id Int64 CODEC(DoubleDelta, ZSTD(1)),+ property_type LowCardinality(String),+ property_key LowCardinality(String),+ property_value String,+ property_count SimpleAggregateFunction(sum, UInt64),+ last_seen SimpleAggregateFunction(max, DateTime) DEFAULT now(),+ INDEX idx_property_value_ngrambf lower(property_value) TYPE ngrambf_v1(3, 32768, 3, 0) GRANULARITY 1+) ENGINE = ReplicatedAggregatingMergeTree('/clickhouse/tables/noshard/posthog.property_values', '{replica}-{shard}') ORDER BY (team_id, property_type, property_key, property_value) TTL last_seen + toIntervalDay(30) SETTINGS index_granularity = 8192;+CREATE TABLE posthog.property_values_distributed (+ team_id Int64 CODEC(DoubleDelta, ZSTD(1)),+ property_type LowCardinality(String),+ property_key LowCardinality(String),+ property_value String,+ property_count SimpleAggregateFunction(sum, UInt64),+ last_seen SimpleAggregateFunction(max, DateTime) DEFAULT now()+) ENGINE = Distributed('aux', 'posthog', 'property_values');+CREATE TABLE posthog.query_log_archive_v2 (+ hostname LowCardinality(String),+ user LowCardinality(String),+ query_id String,+ initial_query_id String,+ is_initial_query UInt8,+ type Enum8('QueryStart'=1, 'QueryFinish'=2, 'ExceptionBeforeStart'=3, 'ExceptionWhileProcessing'=4),+ event_date Date,+ event_time DateTime,+ event_time_microseconds DateTime64(6),+ query_start_time DateTime,+ query_start_time_microseconds DateTime64(6),+ query_duration_ms UInt64,+ read_rows UInt64,+ read_bytes UInt64,+ written_rows UInt64,+ written_bytes UInt64,+ result_rows UInt64,+ result_bytes UInt64,+ memory_usage UInt64,+ peak_threads_usage UInt64,+ current_database LowCardinality(String),+ query String,+ formatted_query String,+ normalized_query_hash UInt64,+ query_kind LowCardinality(String),+ exception_code Int32,+ exception_name String ALIAS errorCodeToName(exception_code),+ exception String,+ stack_trace String,+ ProfileEvents_RealTimeMicroseconds Int64,+ ProfileEvents_OSCPUVirtualTimeMicroseconds Int64,+ ProfileEvents_S3Clients Int64,+ ProfileEvents_S3DeleteObjects Int64,+ ProfileEvents_S3CopyObject Int64,+ ProfileEvents_S3ListObjects Int64,+ ProfileEvents_S3HeadObject Int64,+ ProfileEvents_S3GetObjectAttributes Int64,+ ProfileEvents_S3CreateMultipartUpload Int64,+ ProfileEvents_S3UploadPartCopy Int64,+ ProfileEvents_S3UploadPart Int64,+ ProfileEvents_S3AbortMultipartUpload Int64,+ ProfileEvents_S3CompleteMultipartUpload Int64,+ ProfileEvents_S3PutObject Int64,+ ProfileEvents_S3GetObject Int64,+ ProfileEvents_ReadBufferFromS3Bytes Int64,+ ProfileEvents_WriteBufferFromS3Bytes Int64,+ ProfileEvents Map(String, UInt64),+ lc_workflow LowCardinality(String),+ lc_kind LowCardinality(String),+ lc_id String,+ lc_route_id String,+ lc_access_method LowCardinality(String),+ lc_api_key_label String,+ lc_api_key_mask String,+ lc_query_type LowCardinality(String),+ lc_product LowCardinality(String),+ lc_chargeable Bool,+ lc_name String,+ lc_request_name String,+ lc_client_query_id String,+ lc_org_id String,+ team_id Int64,+ lc_user_id Int64,+ lc_is_impersonated Bool,+ lc_session_id String,+ lc_dashboard_id Int64,+ lc_insight_id Int64,+ lc_cohort_id Int64,+ lc_batch_export_id String,+ lc_experiment_id Int64,+ lc_experiment_feature_flag_key String,+ lc_alert_config_id String,+ lc_feature LowCardinality(String),+ lc_table_id String,+ lc_warehouse_query Bool,+ lc_person_on_events_mode LowCardinality(String),+ lc_service_name String,+ lc_workload LowCardinality(String),+ lc_query__kind LowCardinality(String),+ lc_query__query String,+ lc_query String,+ lc_temporal__workflow_namespace String,+ lc_temporal__workflow_type String,+ lc_temporal__workflow_id String,+ lc_temporal__workflow_run_id String,+ lc_temporal__activity_type String,+ lc_temporal__activity_id String,+ lc_temporal__attempt Int64,+ lc_dagster__job_name String,+ lc_dagster__run_id String,+ lc_dagster__owner String,+ lc_modifiers String+) ENGINE = ReplicatedMergeTree('/clickhouse/tables/noshard/posthog.query_log_archive_new', '{replica}-{shard}') ORDER BY (team_id, event_date, event_time, query_id) PARTITION BY toYYYYMM(event_date) SETTINGS index_granularity = 8192;+CREATE TABLE posthog.raw_error_tracking_fingerprint_issue_state (+ team_id Int64,+ fingerprint String,+ issue_id UUID,+ issue_name Nullable(String),+ issue_description Nullable(String),+ issue_status String,+ issue_severity Nullable(String),+ assigned_user_id Nullable(Int64),+ assigned_role_id Nullable(UUID),+ first_seen DateTime64(3, 'UTC'),+ is_deleted Int8,+ version Int64,+ _timestamp DateTime,+ _offset UInt64,+ _partition UInt64,+ INDEX kafka_timestamp_minmax_raw_error_tracking_fingerprint_issue_state _timestamp TYPE minmax GRANULARITY 3+) ENGINE = ReplicatedReplacingMergeTree('/clickhouse/tables/noshard/posthog.raw_error_tracking_fingerprint_issue_state', '{replica}-{shard}', version) ORDER BY (team_id, fingerprint) SETTINGS index_granularity = 512;+CREATE TABLE posthog.sharded_ai_events (+ uuid UUID,+ event LowCardinality(String),+ timestamp DateTime64(6, 'UTC'),+ team_id Int64,+ distinct_id String,+ person_id UUID,+ properties String,+ retention_days Int16 DEFAULT 30,+ drop_date Date MATERIALIZED toDate(timestamp) + toIntervalDay(retention_days),+ trace_id String,+ session_id Nullable(String),+ parent_id Nullable(String),+ span_id Nullable(String),+ span_type LowCardinality(Nullable(String)),+ generation_id Nullable(String),+ experiment_id Nullable(String),+ span_name Nullable(String),+ trace_name Nullable(String),+ prompt_name Nullable(String),+ model LowCardinality(Nullable(String)),+ provider LowCardinality(Nullable(String)),+ framework LowCardinality(Nullable(String)),+ total_tokens Nullable(Int64),+ input_tokens Nullable(Int64),+ output_tokens Nullable(Int64),+ text_input_tokens Nullable(Int64),+ text_output_tokens Nullable(Int64),+ image_input_tokens Nullable(Int64),+ image_output_tokens Nullable(Int64),+ audio_input_tokens Nullable(Int64),+ audio_output_tokens Nullable(Int64),+ video_input_tokens Nullable(Int64),+ video_output_tokens Nullable(Int64),+ reasoning_tokens Nullable(Int64),+ cache_read_input_tokens Nullable(Int64),+ cache_creation_input_tokens Nullable(Int64),+ web_search_count Nullable(Int64),+ input_cost_usd Nullable(Float64),+ output_cost_usd Nullable(Float64),+ total_cost_usd Nullable(Float64),+ request_cost_usd Nullable(Float64),+ web_search_cost_usd Nullable(Float64),+ audio_cost_usd Nullable(Float64),+ image_cost_usd Nullable(Float64),+ video_cost_usd Nullable(Float64),+ latency Nullable(Float64),+ time_to_first_token Nullable(Float64),+ is_error UInt8,+ error Nullable(String),+ error_type LowCardinality(Nullable(String)),+ error_normalized Nullable(String),+ input Nullable(String),+ output Nullable(String),+ output_choices Nullable(String),+ input_state Nullable(String),+ output_state Nullable(String),+ tools Nullable(String),+ _timestamp DateTime,+ _offset UInt64,+ _partition UInt64,+ INDEX idx_trace_id trace_id TYPE bloom_filter(0.001) GRANULARITY 1,+ INDEX idx_session_id session_id TYPE bloom_filter(0.01) GRANULARITY 1,+ INDEX idx_parent_id parent_id TYPE bloom_filter(0.01) GRANULARITY 1,+ INDEX idx_span_id span_id TYPE bloom_filter(0.01) GRANULARITY 1,+ INDEX idx_prompt_name prompt_name TYPE bloom_filter(0.01) GRANULARITY 1,+ INDEX idx_model model TYPE bloom_filter(0.01) GRANULARITY 1,+ INDEX idx_experiment_id experiment_id TYPE bloom_filter(0.01) GRANULARITY 1,+ INDEX idx_event event TYPE set(20) GRANULARITY 1,+ INDEX idx_is_error is_error TYPE set(2) GRANULARITY 1,+ INDEX idx_provider provider TYPE set(50) GRANULARITY 1+) ENGINE = ReplicatedMergeTree('/clickhouse/tables/{shard}/posthog.ai_events', '{replica}') ORDER BY (team_id, trace_id, timestamp) PARTITION BY toYYYYMM(drop_date) TTL drop_date SETTINGS index_granularity = 8192, ttl_only_drop_parts = 1;+CREATE TABLE posthog.sharded_app_metrics (+ team_id Int64,+ timestamp DateTime64(6, 'UTC'),+ plugin_config_id Int64,+ category LowCardinality(String),+ job_id String,+ successes SimpleAggregateFunction(sum, Int64),+ successes_on_retry SimpleAggregateFunction(sum, Int64),+ failures SimpleAggregateFunction(sum, Int64),+ error_uuid UUID,+ error_type String,+ error_details String CODEC(ZSTD(3)),+ _timestamp DateTime,+ _offset UInt64,+ _partition UInt64+) ENGINE = ReplicatedAggregatingMergeTree('/clickhouse/tables/{shard}/posthog.sharded_app_metrics', '{replica}') ORDER BY (team_id, plugin_config_id, job_id, category, toStartOfHour(timestamp), error_type, error_uuid) PARTITION BY toYYYYMM(timestamp) SETTINGS index_granularity = 8192;+CREATE TABLE posthog.sharded_app_metrics2 (+ team_id Int64,+ timestamp DateTime64(6, 'UTC'),+ app_source LowCardinality(String),+ app_source_id String,+ instance_id String,+ metric_kind LowCardinality(String),+ metric_name LowCardinality(String),+ count SimpleAggregateFunction(sum, Int64),+ _timestamp DateTime,+ _offset UInt64,+ _partition UInt64+) ENGINE = ReplicatedAggregatingMergeTree('/clickhouse/tables/{shard}/posthog.sharded_app_metrics2', '{replica}') ORDER BY (team_id, app_source, app_source_id, instance_id, toStartOfHour(timestamp), metric_kind, metric_name) PARTITION BY toYYYYMM(timestamp) TTL toDate(timestamp) + toIntervalDay(90) SETTINGS index_granularity = 8192;+CREATE TABLE posthog.sharded_conversion_goal_attributed_preaggregated (+ team_id Int64,+ job_id UUID,+ person_id UUID,+ conversion_timestamp DateTime64(6, 'UTC'),+ conversion_value Float64,+ touchpoint_timestamp DateTime64(6, 'UTC'),+ touchpoint_weight Float64,+ campaign_name String,+ source_name String,+ medium_name String,+ content_name String,+ term_name String,+ referring_domain_name String,+ gclid_name String,+ fbclid_name String,+ gad_source_name String,+ computed_at DateTime64(6, 'UTC') DEFAULT now(),+ expires_at Date DEFAULT today() + toIntervalDay(7)+) ENGINE = ReplicatedReplacingMergeTree('/clickhouse/tables/noshard/posthog.conversion_goal_attributed_preaggregated', '{replica}-{shard}', computed_at) ORDER BY (team_id, job_id, person_id, conversion_timestamp, touchpoint_timestamp) PARTITION BY toYYYYMMDD(expires_at) TTL expires_at SETTINGS index_granularity = 8192, ttl_only_drop_parts = 1;+CREATE TABLE posthog.sharded_distinct_id_usage (+ team_id Int64,+ distinct_id String,+ minute DateTime,+ event_count UInt64+) ENGINE = ReplicatedSummingMergeTree('/clickhouse/tables/{shard}/posthog.distinct_id_usage', '{replica}', (event_count)) ORDER BY (team_id, minute, distinct_id) PARTITION BY toYYYYMMDD(minute) TTL toDate(minute) + toIntervalDay(7) SETTINGS index_granularity = 8192, ttl_only_drop_parts = 1;+CREATE TABLE posthog.sharded_events (+ uuid UUID,+ event String,+ properties String CODEC(ZSTD(3)),+ timestamp DateTime64(6, 'UTC'),+ team_id Int64,+ distinct_id String,+ created_at DateTime64(6, 'UTC'),+ $group_0 String MATERIALIZED replaceRegexpAll(JSONExtractRaw(properties, '$group_0'), '^"|"$', '') COMMENT 'column_materializer::$group_0',+ $group_1 String MATERIALIZED replaceRegexpAll(JSONExtractRaw(properties, '$group_1'), '^"|"$', '') COMMENT 'column_materializer::$group_1',+ $group_2 String MATERIALIZED replaceRegexpAll(JSONExtractRaw(properties, '$group_2'), '^"|"$', '') COMMENT 'column_materializer::$group_2',+ $group_3 String MATERIALIZED replaceRegexpAll(JSONExtractRaw(properties, '$group_3'), '^"|"$', '') COMMENT 'column_materializer::$group_3',+ $group_4 String MATERIALIZED replaceRegexpAll(JSONExtractRaw(properties, '$group_4'), '^"|"$', '') COMMENT 'column_materializer::$group_4',+ $window_id String MATERIALIZED replaceRegexpAll(JSONExtractRaw(properties, '$window_id'), '^"|"$', '') COMMENT 'column_materializer::$window_id',+ $session_id String MATERIALIZED replaceRegexpAll(JSONExtractRaw(properties, '$session_id'), '^"|"$', '') COMMENT 'column_materializer::$session_id',+ inserted_at Nullable(DateTime64(6, 'UTC')) DEFAULT now64(),+ person_mode Enum8('full'=0, 'propertyless'=1, 'force_upgrade'=2),+ elements_chain_href String MATERIALIZED EXTRACT(elements_chain, '(?::|")href="(.*?)"'),+ elements_chain_texts Array(String) MATERIALIZED arrayDistinct(extractAll(elements_chain, '(?::|")text="(.*?)"')),+ elements_chain_ids Array(String) MATERIALIZED arrayDistinct(extractAll(elements_chain, '(?::|")attr_id="(.*?)"')),+ elements_chain_elements Array(Enum8('a'=1, 'button'=2, 'form'=3, 'input'=4, 'select'=5, 'textarea'=6, 'label'=7)) MATERIALIZED arrayDistinct(extractAll(elements_chain, '(?:^|;)(a|button|form|input|select|textarea|label)(?:\\.|$|:)')),+ properties_group_custom Map(String, String) MATERIALIZED mapSort(mapFilter((key, _) -> ((key NOT LIKE '$%') AND (key NOT IN ('token', 'distinct_id', 'utm_source', 'utm_medium', 'utm_campaign', 'utm_content', 'utm_term', 'gclid', 'gad_source', 'gclsrc', 'dclid', 'gbraid', 'wbraid', 'fbclid', 'msclkid', 'twclid', 'li_fat_id', 'mc_cid', 'igshid', 'ttclid', 'rdt_cid', 'epik', 'qclid', 'sccid', 'irclid', '_kx'))), CAST(JSONExtractKeysAndValues(properties, 'String'), 'Map(String, String)'))) CODEC(ZSTD(1)),+ properties_group_feature_flags Map(String, String) MATERIALIZED mapSort(mapFilter((key, _) -> (key LIKE '$feature/%'), CAST(JSONExtractKeysAndValues(properties, 'String'), 'Map(String, String)'))) CODEC(ZSTD(1)),+ is_deleted Bool,+ person_properties_map_custom Map(String, String) MATERIALIZED mapSort(mapFilter((key, _) -> (key NOT LIKE '$%'), CAST(JSONExtractKeysAndValues(person_properties, 'String'), 'Map(String, String)'))) CODEC(ZSTD(1)),+ $session_id_uuid Nullable(UInt128) MATERIALIZED toUInt128(JSONExtract(properties, '$session_id', 'Nullable(UUID)')),+ consumer_breadcrumbs Array(String),+ properties_group_ai Map(String, String) MATERIALIZED mapSort(mapFilter((key, _) -> ((key LIKE '$ai_%') AND (key NOT IN ('$ai_input', '$ai_input_state', '$ai_output', '$ai_output_choices', '$ai_output_state', '$ai_tools'))), CAST(JSONExtractKeysAndValues(properties, 'String'), 'Map(String, String)'))) CODEC(ZSTD(1)),+ mat_$ai_session_id Nullable(String) MATERIALIZED JSONExtract(properties, '$ai_session_id', 'Nullable(String)'),+ mat_$ai_is_error Nullable(String) MATERIALIZED JSONExtract(properties, '$ai_is_error', 'Nullable(String)'),+ dmat_string_0 Nullable(String),+ dmat_string_1 Nullable(String),+ dmat_string_2 Nullable(String),+ dmat_string_3 Nullable(String),+ dmat_string_4 Nullable(String),+ dmat_string_5 Nullable(String),+ dmat_string_6 Nullable(String),+ dmat_string_7 Nullable(String),+ dmat_string_8 Nullable(String),+ dmat_string_9 Nullable(String),+ historical_migration Bool,+ mat_$ai_prompt_name Nullable(String) MATERIALIZED JSONExtract(properties, '$ai_prompt_name', 'Nullable(String)'),+ properties_map_ephemeral Map(String, String),+ person_properties_map_ephemeral Map(String, String),+ mat_$ai_experiment_id Nullable(String) DEFAULT JSONExtract(properties, '$ai_experiment_id', 'Nullable(String)'),+ elements_chain String,+ person_id UUID,+ person_created_at DateTime64(3),+ person_properties String CODEC(ZSTD(3)),+ group0_properties String CODEC(ZSTD(3)),+ group1_properties String CODEC(ZSTD(3)),+ group2_properties String CODEC(ZSTD(3)),+ group3_properties String CODEC(ZSTD(3)),+ group4_properties String CODEC(ZSTD(3)),+ group0_created_at DateTime64(3),+ group1_created_at DateTime64(3),+ group2_created_at DateTime64(3),+ group3_created_at DateTime64(3),+ group4_created_at DateTime64(3),+ _timestamp DateTime,+ _offset UInt64,+ mat_$ai_trace_id Nullable(String) MATERIALIZED JSONExtract(properties, '$ai_trace_id', 'Nullable(String)'),+ INDEX minmax_inserted_at coalesce(inserted_at, _timestamp) TYPE minmax GRANULARITY 1,+ INDEX properties_group_custom_keys_bf mapKeys(properties_group_custom) TYPE bloom_filter GRANULARITY 1,+ INDEX properties_group_custom_values_bf mapValues(properties_group_custom) TYPE bloom_filter GRANULARITY 1,+ INDEX properties_group_feature_flags_keys_bf mapKeys(properties_group_feature_flags) TYPE bloom_filter GRANULARITY 1,+ INDEX properties_group_feature_flags_values_bf mapValues(properties_group_feature_flags) TYPE bloom_filter GRANULARITY 1,+ INDEX person_properties_map_custom_keys_bf mapKeys(person_properties_map_custom) TYPE bloom_filter GRANULARITY 1,+ INDEX person_properties_map_custom_values_bf mapValues(person_properties_map_custom) TYPE bloom_filter GRANULARITY 1,+ INDEX properties_group_ai_keys_bf mapKeys(properties_group_ai) TYPE bloom_filter GRANULARITY 1,+ INDEX properties_group_ai_values_bf mapValues(properties_group_ai) TYPE bloom_filter GRANULARITY 1,+ INDEX bloom_filter_$ai_trace_id `mat_$ai_trace_id` TYPE bloom_filter(0.001) GRANULARITY 2,+ INDEX bloom_filter_$ai_session_id `mat_$ai_session_id` TYPE bloom_filter GRANULARITY 1,+ INDEX minmax_$ai_session_id `mat_$ai_session_id` TYPE minmax GRANULARITY 1,+ INDEX set_$ai_is_error `mat_$ai_is_error` TYPE set(7) GRANULARITY 1,+ INDEX bloom_filter_distinct_id distinct_id TYPE bloom_filter GRANULARITY 1,+ INDEX minmax_sharded_events_timestamp timestamp TYPE minmax GRANULARITY 1,+ INDEX bloom_filter_$ai_prompt_name `mat_$ai_prompt_name` TYPE bloom_filter GRANULARITY 1,+ INDEX minmax_$ai_prompt_name `mat_$ai_prompt_name` TYPE minmax GRANULARITY 1,+ INDEX bloom_filter_$ai_experiment_id `mat_$ai_experiment_id` TYPE bloom_filter GRANULARITY 1,+ INDEX minmax_$ai_experiment_id `mat_$ai_experiment_id` TYPE minmax GRANULARITY 1,+ INDEX minmax_$session_id_uuid `$session_id_uuid` TYPE minmax GRANULARITY 1,+ INDEX bloom_filter_$session_id nullIf(nullIf(`$session_id`, ''), 'null') TYPE bloom_filter GRANULARITY 1,+ INDEX minmax_$group_0 `$group_0` TYPE minmax GRANULARITY 1,+ INDEX minmax_$group_1 `$group_1` TYPE minmax GRANULARITY 1,+ INDEX minmax_$group_2 `$group_2` TYPE minmax GRANULARITY 1,+ INDEX minmax_$group_3 `$group_3` TYPE minmax GRANULARITY 1,+ INDEX minmax_$group_4 `$group_4` TYPE minmax GRANULARITY 1,+ INDEX minmax_$window_id `$window_id` TYPE minmax GRANULARITY 1,+ INDEX minmax_$session_id `$session_id` TYPE minmax GRANULARITY 1,+ INDEX kafka_timestamp_minmax_sharded_events _timestamp TYPE minmax GRANULARITY 3,+ INDEX is_deleted_idx is_deleted TYPE minmax GRANULARITY 1,+ INDEX minmax_historical_migration historical_migration TYPE minmax GRANULARITY 1+) ENGINE = ReplicatedReplacingMergeTree('/clickhouse/tables/{shard}/posthog.events', '{replica}', _timestamp) ORDER BY (team_id, toDate(timestamp), event, cityHash64(distinct_id), cityHash64(uuid)) PARTITION BY toYYYYMM(timestamp) SAMPLE BY cityHash64(distinct_id) SETTINGS index_granularity = 8192;+CREATE TABLE posthog.sharded_events_json (+ uuid UUID,+ event String,+ properties JSON(max_dynamic_types=8, max_dynamic_paths=256, `$active_feature_flags` Array(String), `$ai_experiment_id` Nullable(String), `$ai_http_status` Nullable(String), `$ai_is_error` Nullable(String), `$ai_model` Nullable(String), `$ai_parent_id` Nullable(String), `$ai_prompt_name` Nullable(String), `$ai_provider` Nullable(String), `$ai_session_id` Nullable(String), `$ai_span_id` Nullable(String), `$ai_total_cost_usd` Nullable(String), `$ai_trace_id` Nullable(String), `$anon_distinct_id` Nullable(String), `$app_build` Nullable(String), `$app_namespace` Nullable(String), `$app_version` Nullable(String), `$browser` Nullable(String), `$browser_version` Nullable(String), `$current_url` Nullable(String), `$device` Nullable(String), `$device_id` Nullable(String), `$device_model` Nullable(String), `$device_type` Nullable(String), `$el_text` Nullable(String), `$event_type` Nullable(String), `$exception_fingerprint` Nullable(String), `$exception_functions` Array(String), `$exception_issue_id` Nullable(String), `$exception_sources` Array(String), `$exception_types` Array(String), `$exception_values` Array(String), `$feature_flag` Nullable(String), `$feature_flag_payloads` Nullable(String), `$feature_flag_response` Nullable(String), `$geoip_city_name` Nullable(String), `$geoip_country_code` Nullable(String), `$geoip_country_name` Nullable(String), `$geoip_subdivision_1_code` Nullable(String), `$group_0` Nullable(String), `$group_1` Nullable(String), `$group_2` Nullable(String), `$group_3` Nullable(String), `$group_4` Nullable(String), `$groups` Nullable(String), `$host` Nullable(String), `$initial_pathname` Nullable(String), `$initial_referrer` Nullable(String), `$initial_referring_domain` Nullable(String), `$ip` Nullable(String), `$is_identified` Nullable(String), `$lib` Nullable(String), `$lib_custom_api_host` Nullable(String), `$lib_version` Nullable(String), `$lib_version__minor` Nullable(String), `$os` Nullable(String), `$os_name` Nullable(String), `$os_version` Nullable(String), `$pathname` Nullable(String), `$prev_pageview_max_content_percentage` Nullable(String), `$prev_pageview_max_scroll_percentage` Nullable(String), `$prev_pageview_pathname` Nullable(String), `$process_person_profile` Nullable(String), `$referrer` Nullable(String), `$referring_domain` Nullable(String), `$screen_height` Nullable(String), `$screen_name` Nullable(String), `$screen_width` Nullable(String), `$sent_at` Nullable(String), `$session_id` Nullable(String), `$survey_id` Nullable(String), `$survey_response` Nullable(String), `$survey_response_1` Nullable(String), `$time` Nullable(String), `$user_id` Nullable(String), `$viewport_height` Nullable(String), `$viewport_width` Nullable(String), `$web_vitals_CLS_value` Nullable(String), `$web_vitals_FCP_value` Nullable(String), `$web_vitals_INP_value` Nullable(String), `$web_vitals_LCP_value` Nullable(String), `$window_id` Nullable(String)),+ timestamp DateTime64(6, 'UTC'),+ team_id Int64,+ distinct_id String,+ elements_hash String DEFAULT '',+ created_at DateTime64(6, 'UTC'),+ _timestamp DateTime,+ _offset UInt64,+ elements_chain String,+ person_id UUID,+ person_properties JSON(max_dynamic_types=6, max_dynamic_paths=32, `$app_version` Nullable(String), `$browser` Nullable(String), `$current_url` Nullable(String), `$geoip_continent_name` Nullable(String), `$geoip_country_code` Nullable(String), `$geoip_country_name` Nullable(String), `$initial_current_url` Nullable(String), `$initial_fbclid` Nullable(String), `$initial_gad_source` Nullable(String), `$initial_gbraid` Nullable(String), `$initial_gclid` Nullable(String), `$initial_msclkid` Nullable(String), `$initial_pathname` Nullable(String), `$initial_referring_domain` Nullable(String), `$initial_utm_campaign` Nullable(String), `$initial_utm_content` Nullable(String), `$initial_utm_medium` Nullable(String), `$initial_utm_source` Nullable(String), `$initial_utm_term` Nullable(String), `$initial_wbraid` Nullable(String), `$os_name` Nullable(String), `$referring_domain` Nullable(String)),+ group0_properties String CODEC(ZSTD(3)),+ group1_properties String CODEC(ZSTD(3)),+ group2_properties String CODEC(ZSTD(3)),+ group3_properties String CODEC(ZSTD(3)),+ group4_properties String CODEC(ZSTD(3)),+ person_created_at DateTime64(3),+ group0_created_at DateTime64(3),+ group1_created_at DateTime64(3),+ group2_created_at DateTime64(3),+ group3_created_at DateTime64(3),+ group4_created_at DateTime64(3),+ inserted_at Nullable(DateTime64(6, 'UTC')) DEFAULT now64(),+ person_mode Enum8('full'=0, 'propertyless'=1, 'force_upgrade'=2),+ is_deleted Bool DEFAULT false,+ consumer_breadcrumbs Array(String),+ historical_migration Bool DEFAULT false,+ $group_0 String ALIAS ifNull(properties.`$group_0`, ''),+ $group_1 String ALIAS ifNull(properties.`$group_1`, ''),+ $group_2 String ALIAS ifNull(properties.`$group_2`, ''),+ $group_3 String ALIAS ifNull(properties.`$group_3`, ''),+ $group_4 String ALIAS ifNull(properties.`$group_4`, ''),+ $window_id String ALIAS ifNull(properties.`$window_id`, ''),+ $session_id String ALIAS ifNull(properties.`$session_id`, ''),+ $session_id_uuid Nullable(UInt128) ALIAS toUInt128(toUUIDOrNull(properties.`$session_id`)),+ elements_chain_href String MATERIALIZED EXTRACT(elements_chain, '(?::|")href="(.*?)"'),+ elements_chain_texts Array(String) MATERIALIZED arrayDistinct(extractAll(elements_chain, '(?::|")text="(.*?)"')),+ elements_chain_ids Array(String) MATERIALIZED arrayDistinct(extractAll(elements_chain, '(?::|")attr_id="(.*?)"')),+ elements_chain_elements Array(Enum8('a'=1, 'button'=2, 'form'=3, 'input'=4, 'select'=5, 'textarea'=6, 'label'=7)) MATERIALIZED arrayDistinct(extractAll(elements_chain, '(?:^|;)(a|button|form|input|select|textarea|label)(?:\\.|$|:)')),+ INDEX kafka_timestamp_minmax_sharded_events _timestamp TYPE minmax GRANULARITY 3,+ INDEX minmax_$group_0 properties.`$group_0` TYPE minmax GRANULARITY 1,+ INDEX minmax_$group_1 properties.`$group_1` TYPE minmax GRANULARITY 1,+ INDEX minmax_$group_2 properties.`$group_2` TYPE minmax GRANULARITY 1,+ INDEX minmax_$group_3 properties.`$group_3` TYPE minmax GRANULARITY 1,+ INDEX minmax_$group_4 properties.`$group_4` TYPE minmax GRANULARITY 1,+ INDEX minmax_$window_id properties.`$window_id` TYPE minmax GRANULARITY 1,+ INDEX minmax_$session_id properties.`$session_id` TYPE minmax GRANULARITY 1,+ INDEX minmax_mat_$sent_at properties.`$sent_at` TYPE minmax GRANULARITY 1,+ INDEX minmax_mat_$initial_pathname properties.`$initial_pathname` TYPE minmax GRANULARITY 1,+ INDEX minmax_mat_$lib_version properties.`$lib_version` TYPE minmax GRANULARITY 1,+ INDEX minmax_mat_pp_$initial_utm_campaign person_properties.`$initial_utm_campaign` TYPE minmax GRANULARITY 1,+ INDEX minmax_mat_pp_$initial_utm_medium person_properties.`$initial_utm_medium` TYPE minmax GRANULARITY 1,+ INDEX minmax_mat_pp_$initial_gclid person_properties.`$initial_gclid` TYPE minmax GRANULARITY 1,+ INDEX minmax_mat_pp_$initial_gad_source person_properties.`$initial_gad_source` TYPE minmax GRANULARITY 1,+ INDEX minmax_mat_pp_$initial_utm_source person_properties.`$initial_utm_source` TYPE minmax GRANULARITY 1,+ INDEX minmax_mat_pp_$initial_referring_domain person_properties.`$initial_referring_domain` TYPE minmax GRANULARITY 1,+ INDEX minmax_mat_pp_$initial_utm_term person_properties.`$initial_utm_term` TYPE minmax GRANULARITY 1,+ INDEX minmax_mat_pp_$initial_utm_content person_properties.`$initial_utm_content` TYPE minmax GRANULARITY 1,+ INDEX minmax_mat_pp_$initial_gbraid person_properties.`$initial_gbraid` TYPE minmax GRANULARITY 1,+ INDEX minmax_mat_pp_$initial_wbraid person_properties.`$initial_wbraid` TYPE minmax GRANULARITY 1,+ INDEX minmax_mat_pp_$initial_msclkid person_properties.`$initial_msclkid` TYPE minmax GRANULARITY 1,+ INDEX minmax_mat_pp_$initial_fbclid person_properties.`$initial_fbclid` TYPE minmax GRANULARITY 1,+ INDEX minmax_mat_$geoip_subdivision_1_code properties.`$geoip_subdivision_1_code` TYPE minmax GRANULARITY 1,+ INDEX minmax_mat_$prev_pageview_max_scroll_percentage properties.`$prev_pageview_max_scroll_percentage` TYPE minmax GRANULARITY 1,+ INDEX minmax_mat_$prev_pageview_max_content_percentage properties.`$prev_pageview_max_content_percentage` TYPE minmax GRANULARITY 1,+ INDEX minmax_mat_$prev_pageview_pathname properties.`$prev_pageview_pathname` TYPE minmax GRANULARITY 1,+ INDEX minmax_mat_pp_$initial_pathname person_properties.`$initial_pathname` TYPE minmax GRANULARITY 1,+ INDEX minmax_mat_pp_$geoip_country_code person_properties.`$geoip_country_code` TYPE minmax GRANULARITY 1,+ INDEX minmax_mat_$browser_version properties.`$browser_version` TYPE minmax GRANULARITY 1,+ INDEX minmax_mat_pp_$initial_current_url person_properties.`$initial_current_url` TYPE minmax GRANULARITY 1,+ INDEX minmax_mat_pp_$current_url person_properties.`$current_url` TYPE minmax GRANULARITY 1,+ INDEX minmax_mat_$app_namespace properties.`$app_namespace` TYPE minmax GRANULARITY 1,+ INDEX minmax_mat_$os_name properties.`$os_name` TYPE minmax GRANULARITY 1,+ INDEX minmax_mat_pp_$os_name person_properties.`$os_name` TYPE minmax GRANULARITY 1,+ INDEX minmax_mat_pp_$app_version person_properties.`$app_version` TYPE minmax GRANULARITY 1,+ INDEX minmax_mat_$screen_height properties.`$screen_height` TYPE minmax GRANULARITY 1,+ INDEX minmax_mat_$screen_width properties.`$screen_width` TYPE minmax GRANULARITY 1,+ INDEX minmax_mat_$app_build properties.`$app_build` TYPE minmax GRANULARITY 1,+ INDEX minmax_mat_$geoip_country_code properties.`$geoip_country_code` TYPE minmax GRANULARITY 1,+ INDEX minmax_mat_$survey_id properties.`$survey_id` TYPE minmax GRANULARITY 1,+ INDEX minmax_mat_$survey_response_1 properties.`$survey_response_1` TYPE minmax GRANULARITY 1,+ INDEX minmax_mat_$survey_response properties.`$survey_response` TYPE minmax GRANULARITY 1,+ INDEX minmax_mat_$el_text properties.`$el_text` TYPE minmax GRANULARITY 1,+ INDEX minmax_mat_$os_version properties.`$os_version` TYPE minmax GRANULARITY 1,+ INDEX minmax_mat_$feature_flag_payloads properties.`$feature_flag_payloads` TYPE minmax GRANULARITY 1,+ INDEX minmax_mat_$groups properties.`$groups` TYPE minmax GRANULARITY 1,+ INDEX minmax_mat_$feature_flag properties.`$feature_flag` TYPE minmax GRANULARITY 1,+ INDEX bf_active_feature_flags properties.`$active_feature_flags` TYPE bloom_filter(0.01) GRANULARITY 1,+ INDEX minmax_mat_$device_id properties.`$device_id` TYPE minmax GRANULARITY 1,+ INDEX minmax_mat_pp_$geoip_continent_name person_properties.`$geoip_continent_name` TYPE minmax GRANULARITY 1,+ INDEX minmax_mat_$feature_flag_response properties.`$feature_flag_response` TYPE minmax GRANULARITY 1,+ INDEX minmax_mat_pp_$referring_domain person_properties.`$referring_domain` TYPE minmax GRANULARITY 1,+ INDEX minmax_mat_$lib_version__minor properties.`$lib_version__minor` TYPE minmax GRANULARITY 1,+ INDEX minmax_inserted_at coalesce(inserted_at, _timestamp) TYPE minmax GRANULARITY 1,+ INDEX minmax_mat_$lib_custom_api_host properties.`$lib_custom_api_host` TYPE minmax GRANULARITY 1,+ INDEX minmax_mat_pp_$geoip_country_name person_properties.`$geoip_country_name` TYPE minmax GRANULARITY 1,+ INDEX is_deleted_idx is_deleted TYPE minmax GRANULARITY 1,+ INDEX minmax_mat_$device properties.`$device` TYPE minmax GRANULARITY 1,+ INDEX minmax_mat_$exception_issue_id properties.`$exception_issue_id` TYPE minmax GRANULARITY 1,+ INDEX minmax_mat_$exception_fingerprint properties.`$exception_fingerprint` TYPE minmax GRANULARITY 1,+ INDEX minmax_mat_$web_vitals_LCP_value properties.`$web_vitals_LCP_value` TYPE minmax GRANULARITY 1,+ INDEX minmax_mat_$web_vitals_FCP_value properties.`$web_vitals_FCP_value` TYPE minmax GRANULARITY 1,+ INDEX minmax_mat_$web_vitals_CLS_value properties.`$web_vitals_CLS_value` TYPE minmax GRANULARITY 1,+ INDEX minmax_mat_$web_vitals_INP_value properties.`$web_vitals_INP_value` TYPE minmax GRANULARITY 1,+ INDEX minmax_mat_$viewport_width properties.`$viewport_width` TYPE minmax GRANULARITY 1,+ INDEX minmax_mat_$viewport_height properties.`$viewport_height` TYPE minmax GRANULARITY 1,+ INDEX minmax_mat_$anon_distinct_id properties.`$anon_distinct_id` TYPE minmax GRANULARITY 1,+ INDEX minmax_mat_$ai_trace_id properties.`$ai_trace_id` TYPE minmax GRANULARITY 1,+ INDEX minmax_mat_$ai_model properties.`$ai_model` TYPE minmax GRANULARITY 1,+ INDEX minmax_mat_$ai_provider properties.`$ai_provider` TYPE minmax GRANULARITY 1,+ INDEX minmax_mat_$ai_parent_id properties.`$ai_parent_id` TYPE minmax GRANULARITY 1,+ INDEX minmax_mat_$ai_span_id properties.`$ai_span_id` TYPE minmax GRANULARITY 1,+ INDEX minmax_mat_$ai_http_status properties.`$ai_http_status` TYPE minmax GRANULARITY 1,+ INDEX minmax_mat_$process_person_profile properties.`$process_person_profile` TYPE minmax GRANULARITY 1,+ INDEX minmax_mat_$app_version properties.`$app_version` TYPE minmax GRANULARITY 1,+ INDEX bloom_mat_$is_identified properties.`$is_identified` TYPE bloom_filter GRANULARITY 1,+ INDEX minmax_$session_id_uuid toUInt128(toUUIDOrNull(properties.`$session_id`)) TYPE minmax GRANULARITY 1,+ INDEX bloom_filter_$ai_trace_id properties.`$ai_trace_id` TYPE bloom_filter(0.001) GRANULARITY 2,+ INDEX bloom_filter_$ai_session_id properties.`$ai_session_id` TYPE bloom_filter GRANULARITY 1,+ INDEX minmax_$ai_session_id properties.`$ai_session_id` TYPE minmax GRANULARITY 1,+ INDEX set_$ai_is_error properties.`$ai_is_error` TYPE set(7) GRANULARITY 1,+ INDEX minmax_mat_$ai_total_cost_usd properties.`$ai_total_cost_usd` TYPE minmax GRANULARITY 1,+ INDEX bloom_filter_distinct_id distinct_id TYPE bloom_filter GRANULARITY 1,+ INDEX minmax_sharded_events_timestamp timestamp TYPE minmax GRANULARITY 1,+ INDEX minmax_historical_migration historical_migration TYPE minmax GRANULARITY 1,+ INDEX bloom_mat_$feature_flag properties.`$feature_flag` TYPE bloom_filter GRANULARITY 1,+ INDEX bloom_filter_$ai_prompt_name properties.`$ai_prompt_name` TYPE bloom_filter GRANULARITY 1,+ INDEX minmax_$ai_prompt_name properties.`$ai_prompt_name` TYPE minmax GRANULARITY 1,+ INDEX bloom_filter_$ai_experiment_id properties.`$ai_experiment_id` TYPE bloom_filter GRANULARITY 1,+ INDEX minmax_$ai_experiment_id properties.`$ai_experiment_id` TYPE minmax GRANULARITY 1+) ENGINE = ReplicatedReplacingMergeTree('/clickhouse/tables/{shard}/posthog.events_json', '{replica}', _timestamp) PRIMARY KEY (team_id, toDate(timestamp), event, timestamp, cityHash64(distinct_id)) ORDER BY (team_id, toDate(timestamp), event, timestamp, cityHash64(distinct_id), distinct_id, uuid) PARTITION BY toYYYYMM(timestamp) SAMPLE BY cityHash64(distinct_id) SETTINGS index_granularity = 8192, merge_max_block_size = 131072, merge_max_block_size_bytes = 67108864, object_serialization_version = 'v3', object_shared_data_serialization_version = 'map_with_buckets', object_shared_data_serialization_version_for_zero_level_parts = 'map', vertical_merge_algorithm_min_rows_to_activate = 0;+CREATE TABLE posthog.sharded_events_recent (+ uuid UUID,+ event String,+ properties String CODEC(ZSTD(3)),+ timestamp DateTime64(6, 'UTC'),+ team_id Int64,+ distinct_id String,+ elements_chain String,+ created_at DateTime64(6, 'UTC'),+ person_id UUID,+ person_created_at DateTime64(3),+ person_properties String CODEC(ZSTD(3)),+ group0_properties String CODEC(ZSTD(3)),+ group1_properties String CODEC(ZSTD(3)),+ group2_properties String CODEC(ZSTD(3)),+ group3_properties String CODEC(ZSTD(3)),+ group4_properties String CODEC(ZSTD(3)),+ group0_created_at DateTime64(3),+ group1_created_at DateTime64(3),+ group2_created_at DateTime64(3),+ group3_created_at DateTime64(3),+ group4_created_at DateTime64(3),+ person_mode Enum8('full'=0, 'propertyless'=1, 'force_upgrade'=2),+ historical_migration Bool,+ _timestamp DateTime,+ _offset UInt64,+ inserted_at DateTime64(6, 'UTC') DEFAULT now64()+) ENGINE = ReplicatedReplacingMergeTree('/clickhouse/tables/{shard}/posthog.sharded_events_recent', '{replica}', _timestamp) ORDER BY (team_id, toStartOfHour(inserted_at), event, cityHash64(distinct_id), cityHash64(uuid)) PARTITION BY toStartOfDay(inserted_at) TTL toDateTime(inserted_at) + toIntervalDay(7) SETTINGS index_granularity = 8192, ttl_only_drop_parts = 1;+CREATE TABLE posthog.sharded_experiment_exposures_preaggregated (+ team_id Int64,+ job_id UUID,+ entity_id String,+ variant String,+ first_exposure_time DateTime64(6, 'UTC'),+ last_exposure_time DateTime64(6, 'UTC'),+ exposure_event_uuid UUID,+ exposure_session_id String,+ breakdown_value Array(String),+ computed_at DateTime64(6, 'UTC') DEFAULT now(),+ expires_at Date DEFAULT today() + toIntervalDay(7)+) ENGINE = ReplicatedReplacingMergeTree('/clickhouse/tables/{shard}/posthog.experiment_exposures_preaggregated', '{replica}', computed_at) ORDER BY (team_id, job_id, entity_id, breakdown_value) PARTITION BY toYYYYMMDD(expires_at) TTL expires_at SETTINGS index_granularity = 8192, ttl_only_drop_parts = 1;+CREATE TABLE posthog.sharded_experiment_metric_events_preaggregated (+ team_id Int64,+ job_id UUID,+ entity_id String,+ timestamp DateTime64(6, 'UTC'),+ event_uuid UUID,+ session_id String,+ numeric_value Float64 DEFAULT 0,+ steps Array(UInt8) DEFAULT [],+ computed_at DateTime64(6, 'UTC') DEFAULT now(),+ expires_at Date DEFAULT today() + toIntervalDay(7)+) ENGINE = ReplicatedReplacingMergeTree('/clickhouse/tables/noshard/posthog.experiment_metric_events_preaggregated', '{replica}-{shard}', computed_at) ORDER BY (team_id, job_id, entity_id, timestamp, event_uuid) PARTITION BY toYYYYMMDD(expires_at) TTL expires_at SETTINGS index_granularity = 8192, ttl_only_drop_parts = 1;+CREATE TABLE posthog.sharded_flag_evaluations (+ uuid UUID,+ event LowCardinality(String),+ properties String,+ timestamp DateTime64(6, 'UTC'),+ team_id Int64,+ distinct_id String,+ created_at DateTime64(6, 'UTC'),+ person_id UUID,+ person_properties String,+ group0_properties String,+ group1_properties String,+ group2_properties String,+ group3_properties String,+ group4_properties String,+ inserted_at DateTime64(6, 'UTC') DEFAULT timestamp,+ $group_0 String MATERIALIZED replaceRegexpAll(JSONExtractRaw(properties, '$group_0'), '^"|"$', '') COMMENT 'column_materializer::$group_0',+ $group_1 String MATERIALIZED replaceRegexpAll(JSONExtractRaw(properties, '$group_1'), '^"|"$', '') COMMENT 'column_materializer::$group_1',+ $group_2 String MATERIALIZED replaceRegexpAll(JSONExtractRaw(properties, '$group_2'), '^"|"$', '') COMMENT 'column_materializer::$group_2',+ $group_3 String MATERIALIZED replaceRegexpAll(JSONExtractRaw(properties, '$group_3'), '^"|"$', '') COMMENT 'column_materializer::$group_3',+ $group_4 String MATERIALIZED replaceRegexpAll(JSONExtractRaw(properties, '$group_4'), '^"|"$', '') COMMENT 'column_materializer::$group_4',+ flag_key String MATERIALIZED replaceRegexpAll(JSONExtractRaw(properties, '$feature_flag'), '^"|"$', '') COMMENT 'column_materializer::properties::$feature_flag',+ response LowCardinality(String) MATERIALIZED replaceRegexpAll(JSONExtractRaw(properties, '$feature_flag_response'), '^"|"$', '') COMMENT 'column_materializer::properties::$feature_flag_response',+ session_id String MATERIALIZED replaceRegexpAll(JSONExtractRaw(properties, '$session_id'), '^"|"$', '') COMMENT 'column_materializer::properties::$session_id',+ request_id String MATERIALIZED replaceRegexpAll(JSONExtractRaw(properties, '$feature_flag_request_id'), '^"|"$', '') COMMENT 'column_materializer::properties::$feature_flag_request_id',+ _timestamp DateTime,+ _offset UInt64,+ _partition UInt64,+ INDEX distinct_id_idx distinct_id TYPE bloom_filter(0.01) GRANULARITY 1,+ INDEX person_id_idx person_id TYPE bloom_filter(0.01) GRANULARITY 1,+ INDEX session_id_idx session_id TYPE bloom_filter(0.01) GRANULARITY 1,+ INDEX request_id_idx request_id TYPE bloom_filter(0.01) GRANULARITY 1,+ INDEX inserted_at_idx inserted_at TYPE minmax GRANULARITY 1+) ENGINE = ReplicatedMergeTree('/clickhouse/tables/{shard}/posthog.flag_evaluations', '{replica}') ORDER BY (team_id, flag_key, toDate(timestamp), cityHash64(distinct_id)) PARTITION BY toYYYYMM(timestamp) TTL toDate(timestamp) + toIntervalDay(90) SETTINGS index_granularity = 8192, ttl_only_drop_parts = 1;+CREATE TABLE posthog.sharded_heatmaps (+ session_id String,+ team_id Int64,+ distinct_id String,+ timestamp DateTime64(6, 'UTC'),+ x Int16,+ y Int16,+ scale_factor Int16,+ viewport_width Int16,+ viewport_height Int16,+ pointer_target_fixed Bool,+ current_url String,+ type LowCardinality(String),+ _timestamp DateTime,+ _offset UInt64,+ _partition UInt64+) ENGINE = ReplicatedMergeTree('/clickhouse/tables/{shard}/posthog.heatmaps', '{replica}') ORDER BY (type, team_id, toDate(timestamp), current_url, viewport_width) PARTITION BY toYYYYMM(timestamp) TTL toDate(timestamp) + toIntervalDay(90) SETTINGS index_granularity = 8192;+CREATE TABLE posthog.sharded_ingestion_warnings (+ team_id Int64,+ source LowCardinality(String),+ type String,+ details String CODEC(ZSTD(3)),+ timestamp DateTime64(6, 'UTC'),+ _timestamp DateTime,+ _offset UInt64,+ _partition UInt64+) ENGINE = ReplicatedMergeTree('/clickhouse/tables/{shard}/posthog.sharded_ingestion_warnings', '{replica}') ORDER BY (team_id, toHour(timestamp), type, source, timestamp) PARTITION BY toYYYYMMDD(timestamp) SETTINGS index_granularity = 8192;+CREATE TABLE posthog.sharded_log_entries (+ team_id UInt64,+ log_source LowCardinality(String),+ log_source_id String,+ instance_id String,+ timestamp DateTime64(6, 'UTC'),+ level LowCardinality(String),+ message String,+ _timestamp DateTime,+ _offset UInt64+) ENGINE = ReplicatedReplacingMergeTree('/clickhouse/tables/{shard}/posthog.sharded_log_entries', '{replica}', _timestamp) ORDER BY (team_id, log_source, log_source_id, instance_id, timestamp) PARTITION BY toYYYYMMDD(timestamp) TTL toDate(timestamp) + toIntervalDay(90) SETTINGS index_granularity = 1024, ttl_only_drop_parts = 1;+CREATE TABLE posthog.sharded_marketing_conversions_preaggregated (+ team_id Int64,+ job_id UUID,+ person_id UUID,+ conversion_timestamp DateTime64(6, 'UTC'),+ conversion_math_value Float64,+ session_id String,+ campaign_name String,+ source_name String,+ medium_name String,+ content_name String,+ term_name String,+ referring_domain_name String,+ gclid_name String,+ fbclid_name String,+ gad_source_name String,+ computed_at DateTime64(6, 'UTC') DEFAULT now(),+ expires_at Date DEFAULT today() + toIntervalDay(7)+) ENGINE = ReplicatedReplacingMergeTree('/clickhouse/tables/noshard/posthog.marketing_conversions_preaggregated', '{replica}-{shard}', computed_at) ORDER BY (team_id, job_id, person_id, conversion_timestamp) PARTITION BY toYYYYMMDD(expires_at) TTL expires_at SETTINGS index_granularity = 8192, ttl_only_drop_parts = 1;+CREATE TABLE posthog.sharded_marketing_costs_preaggregated (+ team_id Int64,+ job_id UUID,+ source_id String,+ source_name String,+ grain LowCardinality(String),+ match_key String,+ campaign_id String,+ campaign_name String,+ ad_group_id String,+ ad_group_name String,+ ad_id String,+ ad_name String,+ cost_date Date,+ cost Float64,+ clicks Float64,+ impressions Float64,+ reported_conversions Float64,+ reported_conversion_value Float64,+ computed_at DateTime64(6, 'UTC') DEFAULT now(),+ expires_at Date DEFAULT today() + toIntervalDay(7)+) ENGINE = ReplicatedReplacingMergeTree('/clickhouse/tables/noshard/posthog.marketing_costs_preaggregated', '{replica}-{shard}', computed_at) ORDER BY (team_id, job_id, source_name, grain, campaign_id, ad_group_id, ad_id, cost_date) PARTITION BY toYYYYMMDD(expires_at) TTL expires_at SETTINGS index_granularity = 8192, ttl_only_drop_parts = 1;+CREATE TABLE posthog.sharded_marketing_touchpoints_preaggregated (+ team_id Int64,+ job_id UUID,+ person_id UUID,+ touchpoint_timestamp DateTime64(6, 'UTC'),+ campaign_name String,+ source_name String,+ medium_name String,+ content_name String,+ term_name String,+ referring_domain_name String,+ gclid_name String,+ fbclid_name String,+ gad_source_name String,+ computed_at DateTime64(6, 'UTC') DEFAULT now(),+ expires_at Date DEFAULT today() + toIntervalDay(7)+) ENGINE = ReplicatedReplacingMergeTree('/clickhouse/tables/noshard/posthog.marketing_touchpoints_preaggregated', '{replica}-{shard}', computed_at) ORDER BY (team_id, job_id, person_id, touchpoint_timestamp) PARTITION BY toYYYYMMDD(expires_at) TTL expires_at SETTINGS index_granularity = 8192, ttl_only_drop_parts = 1;+CREATE TABLE posthog.sharded_performance_events (+ uuid UUID,+ session_id String,+ window_id String,+ pageview_id String,+ distinct_id String,+ timestamp DateTime64(3),+ time_origin DateTime64(3, 'UTC'),+ entry_type LowCardinality(String),+ name String,+ team_id Int64,+ current_url String,+ start_time Float64,+ duration Float64,+ redirect_start Float64,+ redirect_end Float64,+ worker_start Float64,+ fetch_start Float64,+ domain_lookup_start Float64,+ domain_lookup_end Float64,+ connect_start Float64,+ secure_connection_start Float64,+ connect_end Float64,+ request_start Float64,+ response_start Float64,+ response_end Float64,+ decoded_body_size Int64,+ encoded_body_size Int64,+ initiator_type LowCardinality(String),+ next_hop_protocol LowCardinality(String),+ render_blocking_status LowCardinality(String),+ response_status Int64,+ transfer_size Int64,+ largest_contentful_paint_element String,+ largest_contentful_paint_render_time Float64,+ largest_contentful_paint_load_time Float64,+ largest_contentful_paint_size Float64,+ largest_contentful_paint_id String,+ largest_contentful_paint_url String,+ dom_complete Float64,+ dom_content_loaded_event Float64,+ dom_interactive Float64,+ load_event_end Float64,+ load_event_start Float64,+ redirect_count Int64,+ navigation_type LowCardinality(String),+ unload_event_end Float64,+ unload_event_start Float64,+ _timestamp DateTime,+ _offset UInt64,+ _partition UInt64+) ENGINE = ReplicatedMergeTree('/clickhouse/tables/{shard}/posthog.performance_events', '{replica}') ORDER BY (team_id, toDate(timestamp), session_id, pageview_id, timestamp) PARTITION BY toYYYYMM(timestamp) TTL toDate(timestamp) + toIntervalWeek(3) SETTINGS index_granularity = 8192;+CREATE TABLE posthog.sharded_posthog_document_embeddings_buffer (+ team_id Int64,+ product LowCardinality(String),+ document_type LowCardinality(String),+ model_name LowCardinality(String),+ rendering LowCardinality(String),+ document_id String,+ timestamp DateTime64(3, 'UTC'),+ inserted_at DateTime64(3, 'UTC'),+ content String DEFAULT '',+ metadata String DEFAULT '{}',+ embedding Array(Float64),+ _timestamp DateTime,+ _offset UInt64,+ _partition UInt64+) ENGINE = ReplicatedReplacingMergeTree('/clickhouse/tables/{shard}/posthog.sharded_posthog_document_embeddings_buffer', '{replica}', inserted_at) ORDER BY (inserted_at, model_name, cityHash64(document_id)) PARTITION BY toDate(inserted_at) TTL inserted_at + toIntervalDay(1) SETTINGS index_granularity = 8192, ttl_only_drop_parts = 1;+CREATE TABLE posthog.sharded_posthog_document_embeddings_text_embedding_3_large_3072 (+ team_id Int64,+ product LowCardinality(String),+ document_type LowCardinality(String),+ rendering LowCardinality(String),+ document_id String,+ timestamp DateTime64(3, 'UTC'),+ inserted_at DateTime64(3, 'UTC'),+ content String DEFAULT '',+ metadata String DEFAULT '{}',+ embedding Array(Float64),+ _timestamp DateTime,+ _offset UInt64,+ _partition UInt64,+ CONSTRAINT embedding_dimension_check CHECK length(embedding) = 3072,+ INDEX kafka_timestamp_minmax_sharded_posthog_document_embeddings_text_embedding_3_large_3072 _timestamp TYPE minmax GRANULARITY 3,+ INDEX embedding_idx_l2 embedding TYPE vector_similarity('hnsw', 'L2Distance', 3072) GRANULARITY 100000000,+ INDEX embedding_idx_cosine embedding TYPE vector_similarity('hnsw', 'cosineDistance', 3072) GRANULARITY 100000000+) ENGINE = ReplicatedReplacingMergeTree('/clickhouse/tables/{shard}/posthog.sharded_posthog_document_embeddings_text_embedding_3_large_3072', '{replica}', inserted_at) ORDER BY (team_id, toDate(timestamp), product, document_type, rendering, cityHash64(document_id)) PARTITION BY toMonday(timestamp) TTL timestamp + toIntervalMonth(3) SETTINGS index_granularity = 512, ttl_only_drop_parts = 1;+CREATE TABLE posthog.sharded_posthog_document_embeddings_text_embedding_3_small_1536 (+ team_id Int64,+ product LowCardinality(String),+ document_type LowCardinality(String),+ rendering LowCardinality(String),+ document_id String,+ timestamp DateTime64(3, 'UTC'),+ inserted_at DateTime64(3, 'UTC'),+ content String DEFAULT '',+ metadata String DEFAULT '{}',+ embedding Array(Float64),+ _timestamp DateTime,+ _offset UInt64,+ _partition UInt64,+ CONSTRAINT embedding_dimension_check CHECK length(embedding) = 1536,+ INDEX kafka_timestamp_minmax_sharded_posthog_document_embeddings_text_embedding_3_small_1536 _timestamp TYPE minmax GRANULARITY 3,+ INDEX embedding_idx_l2 embedding TYPE vector_similarity('hnsw', 'L2Distance', 1536) GRANULARITY 100000000,+ INDEX embedding_idx_cosine embedding TYPE vector_similarity('hnsw', 'cosineDistance', 1536) GRANULARITY 100000000+) ENGINE = ReplicatedReplacingMergeTree('/clickhouse/tables/{shard}/posthog.sharded_posthog_document_embeddings_text_embedding_3_small_1536', '{replica}', inserted_at) ORDER BY (team_id, toDate(timestamp), product, document_type, rendering, cityHash64(document_id)) PARTITION BY toMonday(timestamp) TTL timestamp + toIntervalMonth(3) SETTINGS index_granularity = 512, ttl_only_drop_parts = 1;+CREATE TABLE posthog.sharded_preaggregation_results (+ team_id Int64,+ job_id UUID,+ time_window_start DateTime64(6, 'UTC'),+ expires_at DateTime64(6, 'UTC') DEFAULT now() + toIntervalDay(7),+ breakdown_value Array(String),+ uniq_exact_state AggregateFunction(uniqExact, UUID)+) ENGINE = ReplicatedAggregatingMergeTree('/clickhouse/tables/{shard}/posthog.preaggregation_results', '{replica}') ORDER BY (team_id, job_id, time_window_start, breakdown_value) PARTITION BY toYYYYMM(time_window_start) TTL expires_at SETTINGS index_granularity = 8192;+CREATE TABLE posthog.sharded_precalculated_events (+ team_id Int64,+ date Date,+ distinct_id String,+ person_id UUID,+ condition String,+ uuid UUID,+ source String,+ _timestamp DateTime64(6),+ _partition UInt64,+ _offset UInt64+) ENGINE = ReplicatedReplacingMergeTree('/clickhouse/tables/{shard}/posthog.sharded_precalculated_events', '{replica}', _timestamp) ORDER BY (team_id, condition, date, distinct_id, uuid) PARTITION BY toYYYYMM(date) SETTINGS index_granularity = 8192;+CREATE TABLE posthog.sharded_precalculated_person_properties (+ team_id Int64,+ distinct_id String,+ person_id UUID,+ condition String,+ matches Bool,+ source String,+ _timestamp DateTime64(6),+ _offset UInt64+) ENGINE = ReplicatedReplacingMergeTree('/clickhouse/tables/{shard}/posthog.sharded_precalculated_person_properties', '{replica}', _timestamp) ORDER BY (team_id, condition, distinct_id) SETTINGS index_granularity = 8192;+CREATE TABLE posthog.sharded_query_log_archive (+ hostname LowCardinality(String),+ user LowCardinality(String),+ query_id String,+ initial_query_id String,+ is_initial_query UInt8,+ type Enum8('QueryStart'=1, 'QueryFinish'=2, 'ExceptionBeforeStart'=3, 'ExceptionWhileProcessing'=4),+ event_date Date,+ event_time DateTime,+ event_time_microseconds DateTime64(6),+ query_start_time DateTime,+ query_start_time_microseconds DateTime64(6),+ query_duration_ms UInt64,+ read_rows UInt64,+ read_bytes UInt64,+ written_rows UInt64,+ written_bytes UInt64,+ result_rows UInt64,+ result_bytes UInt64,+ memory_usage UInt64,+ peak_threads_usage UInt64,+ current_database LowCardinality(String),+ query String,+ formatted_query String,+ normalized_query_hash UInt64,+ query_kind LowCardinality(String),+ exception_code Int32,+ exception String,+ stack_trace String,+ team_id Int64,+ log_comment JSON(max_dynamic_paths=256, access_method LowCardinality(String), alert_config_id String, api_key_label String, api_key_mask String, batch_export_id String, chargeable Bool, client_query_id String, cohort_id Int64, `dagster.job_name` String, `dagster.run_id` String, `dagster.tags.owner` String, dashboard_id Int64, experiment_feature_flag_key String, experiment_id Int64, feature LowCardinality(String), id String, insight_id Int64, is_impersonated Bool, kind LowCardinality(String), name String, org_id String, person_on_events_mode LowCardinality(String), product LowCardinality(String), query_type LowCardinality(String), request_name String, route_id String, service_name String, session_id String, table_id String, team_id Int64, `temporal.activity_id` String, `temporal.activity_type` String, `temporal.attempt` Int64, `temporal.workflow_id` String, `temporal.workflow_namespace` String, `temporal.workflow_run_id` String, `temporal.workflow_type` String, user_id Int64, warehouse_query Bool, workflow LowCardinality(String), workload LowCardinality(String), SKIP cache_key, SKIP filter, SKIP hogql_features, SKIP http_referer, SKIP http_request_id, SKIP http_user_agent, SKIP query_settings, SKIP timings, SKIP user_email),+ ProfileEvents Map(String, UInt64),+ exception_name String ALIAS errorCodeToName(exception_code),+ ProfileEvents_RealTimeMicroseconds Int64 ALIAS ProfileEvents['RealTimeMicroseconds'],+ ProfileEvents_OSCPUVirtualTimeMicroseconds Int64 ALIAS ProfileEvents['OSCPUVirtualTimeMicroseconds'],+ ProfileEvents_S3Clients Int64 ALIAS ProfileEvents['S3Clients'],+ ProfileEvents_S3DeleteObjects Int64 ALIAS ProfileEvents['S3DeleteObjects'],+ ProfileEvents_S3CopyObject Int64 ALIAS ProfileEvents['S3CopyObject'],+ ProfileEvents_S3ListObjects Int64 ALIAS ProfileEvents['S3ListObjects'],+ ProfileEvents_S3HeadObject Int64 ALIAS ProfileEvents['S3HeadObject'],+ ProfileEvents_S3GetObjectAttributes Int64 ALIAS ProfileEvents['S3GetObjectAttributes'],+ ProfileEvents_S3CreateMultipartUpload Int64 ALIAS ProfileEvents['S3CreateMultipartUpload'],+ ProfileEvents_S3UploadPartCopy Int64 ALIAS ProfileEvents['S3UploadPartCopy'],+ ProfileEvents_S3UploadPart Int64 ALIAS ProfileEvents['S3UploadPart'],+ ProfileEvents_S3AbortMultipartUpload Int64 ALIAS ProfileEvents['S3AbortMultipartUpload'],+ ProfileEvents_S3CompleteMultipartUpload Int64 ALIAS ProfileEvents['S3CompleteMultipartUpload'],+ ProfileEvents_S3PutObject Int64 ALIAS ProfileEvents['S3PutObject'],+ ProfileEvents_S3GetObject Int64 ALIAS ProfileEvents['S3GetObject'],+ ProfileEvents_ReadBufferFromS3Bytes Int64 ALIAS ProfileEvents['ReadBufferFromS3Bytes'],+ ProfileEvents_WriteBufferFromS3Bytes Int64 ALIAS ProfileEvents['WriteBufferFromS3Bytes'],+ lc_workflow LowCardinality(String) ALIAS log_comment.workflow,+ lc_kind LowCardinality(String) ALIAS log_comment.kind,+ lc_id String ALIAS CAST(log_comment.id, 'String'),+ lc_route_id String ALIAS CAST(log_comment.route_id, 'String'),+ lc_access_method LowCardinality(String) ALIAS log_comment.access_method,+ lc_api_key_label String ALIAS CAST(log_comment.api_key_label, 'String'),+ lc_api_key_mask String ALIAS CAST(log_comment.api_key_mask, 'String'),+ lc_query_type LowCardinality(String) ALIAS log_comment.query_type,+ lc_product LowCardinality(String) ALIAS log_comment.product,+ lc_chargeable Bool ALIAS log_comment.chargeable,+ lc_name String ALIAS CAST(log_comment.name, 'String'),+ lc_request_name String ALIAS CAST(log_comment.request_name, 'String'),+ lc_client_query_id String ALIAS CAST(log_comment.client_query_id, 'String'),+ lc_org_id String ALIAS CAST(log_comment.org_id, 'String'),+ lc_user_id Int64 ALIAS log_comment.user_id,+ lc_is_impersonated Bool ALIAS log_comment.is_impersonated,+ lc_session_id String ALIAS CAST(log_comment.session_id, 'String'),+ lc_dashboard_id Int64 ALIAS log_comment.dashboard_id,+ lc_insight_id Int64 ALIAS log_comment.insight_id,+ lc_cohort_id Int64 ALIAS log_comment.cohort_id,+ lc_batch_export_id String ALIAS CAST(log_comment.batch_export_id, 'String'),+ lc_experiment_id Int64 ALIAS log_comment.experiment_id,+ lc_experiment_feature_flag_key String ALIAS CAST(log_comment.experiment_feature_flag_key, 'String'),+ lc_alert_config_id String ALIAS CAST(log_comment.alert_config_id, 'String'),+ lc_feature LowCardinality(String) ALIAS log_comment.feature,+ lc_table_id String ALIAS CAST(log_comment.table_id, 'String'),+ lc_warehouse_query Bool ALIAS log_comment.warehouse_query,+ lc_person_on_events_mode LowCardinality(String) ALIAS log_comment.person_on_events_mode,+ lc_service_name String ALIAS CAST(log_comment.service_name, 'String'),+ lc_workload LowCardinality(String) ALIAS log_comment.workload,+ lc_query__kind LowCardinality(String) ALIAS if(JSONHas(toString(log_comment), 'query', 'source'), JSONExtractString(toString(log_comment), 'query', 'source', 'kind'), JSONExtractString(toString(log_comment), 'query', 'kind')),+ lc_query__query String ALIAS multiIf(NOT is_initial_query, '', JSONHas(toString(log_comment), 'query', 'source'), JSONExtractString(toString(log_comment), 'query', 'source', 'query'), JSONExtractString(toString(log_comment), 'query', 'query')),+ lc_query String ALIAS if(is_initial_query, JSONExtractRaw(toString(log_comment), 'query'), ''),+ lc_temporal__workflow_namespace String ALIAS CAST(log_comment.`temporal.workflow_namespace`, 'String'),+ lc_temporal__workflow_type String ALIAS CAST(log_comment.`temporal.workflow_type`, 'String'),+ lc_temporal__workflow_id String ALIAS CAST(log_comment.`temporal.workflow_id`, 'String'),+ lc_temporal__workflow_run_id String ALIAS CAST(log_comment.`temporal.workflow_run_id`, 'String'),+ lc_temporal__activity_type String ALIAS CAST(log_comment.`temporal.activity_type`, 'String'),+ lc_temporal__activity_id String ALIAS CAST(log_comment.`temporal.activity_id`, 'String'),+ lc_temporal__attempt Int64 ALIAS log_comment.`temporal.attempt`,+ lc_dagster__job_name String ALIAS CAST(log_comment.`dagster.job_name`, 'String'),+ lc_dagster__run_id String ALIAS CAST(log_comment.`dagster.run_id`, 'String'),+ 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 = ReplicatedMergeTree('/clickhouse/tables/noshard/posthog.sharded_query_log_archive', '{replica}-{shard}') ORDER BY (team_id, event_date, event_time, query_id) PARTITION BY toYYYYMM(event_date) SETTINGS index_granularity = 8192, object_serialization_version = 'v3', object_shared_data_serialization_version = 'map_with_buckets';+CREATE TABLE posthog.sharded_query_log_archive_old (+ hostname LowCardinality(String),+ user LowCardinality(String),+ query_id String,+ initial_query_id String,+ is_initial_query UInt8,+ type Enum8('QueryStart'=1, 'QueryFinish'=2, 'ExceptionBeforeStart'=3, 'ExceptionWhileProcessing'=4),+ event_date Date,+ event_time DateTime,+ event_time_microseconds DateTime64(6),+ query_start_time DateTime,+ query_start_time_microseconds DateTime64(6),+ query_duration_ms UInt64,+ read_rows UInt64,+ read_bytes UInt64,+ written_rows UInt64,+ written_bytes UInt64,+ result_rows UInt64,+ result_bytes UInt64,+ memory_usage UInt64,+ peak_threads_usage UInt64,+ current_database LowCardinality(String),+ query String,+ formatted_query String,+ normalized_query_hash UInt64,+ query_kind LowCardinality(String),+ exception_code Int32,+ exception_name String ALIAS errorCodeToName(exception_code),+ exception String,+ stack_trace String,+ ProfileEvents_RealTimeMicroseconds Int64,+ ProfileEvents_OSCPUVirtualTimeMicroseconds Int64,+ ProfileEvents_S3Clients Int64,+ ProfileEvents_S3DeleteObjects Int64,+ ProfileEvents_S3CopyObject Int64,+ ProfileEvents_S3ListObjects Int64,+ ProfileEvents_S3HeadObject Int64,+ ProfileEvents_S3GetObjectAttributes Int64,+ ProfileEvents_S3CreateMultipartUpload Int64,+ ProfileEvents_S3UploadPartCopy Int64,+ ProfileEvents_S3UploadPart Int64,+ ProfileEvents_S3AbortMultipartUpload Int64,+ ProfileEvents_S3CompleteMultipartUpload Int64,+ ProfileEvents_S3PutObject Int64,+ ProfileEvents_S3GetObject Int64,+ ProfileEvents_ReadBufferFromS3Bytes Int64,+ ProfileEvents_WriteBufferFromS3Bytes Int64,+ ProfileEvents Map(String, UInt64),+ lc_workflow LowCardinality(String),+ lc_kind LowCardinality(String),+ lc_id String,+ lc_route_id String,+ lc_access_method LowCardinality(String),+ lc_api_key_label String,+ lc_api_key_mask String,+ lc_query_type LowCardinality(String),+ lc_product LowCardinality(String),+ lc_chargeable Bool,+ lc_name String,+ lc_request_name String,+ lc_client_query_id String,+ lc_org_id String,+ team_id Int64,+ lc_user_id Int64,+ lc_is_impersonated Bool,+ lc_session_id String,+ lc_dashboard_id Int64,+ lc_insight_id Int64,+ lc_cohort_id Int64,+ lc_batch_export_id String,+ lc_experiment_id Int64,+ lc_experiment_feature_flag_key String,+ lc_alert_config_id String,+ lc_feature LowCardinality(String),+ lc_table_id String,+ lc_warehouse_query Bool,+ lc_person_on_events_mode LowCardinality(String),+ lc_service_name String,+ lc_workload LowCardinality(String),+ lc_query__kind LowCardinality(String),+ lc_query__query String,+ lc_query String,+ lc_temporal__workflow_namespace String,+ lc_temporal__workflow_type String,+ lc_temporal__workflow_id String,+ lc_temporal__workflow_run_id String,+ lc_temporal__activity_type String,+ lc_temporal__activity_id String,+ lc_temporal__attempt Int64,+ lc_dagster__job_name String,+ lc_dagster__run_id String,+ lc_dagster__owner String,+ lc_modifiers String+) ENGINE = ReplicatedMergeTree('/clickhouse/tables/{shard}/posthog.sharded_query_log_archive', '{replica}') ORDER BY (team_id, event_date, event_time, query_id) PARTITION BY toYYYYMM(event_date) SETTINGS index_granularity = 8192;+CREATE TABLE posthog.sharded_raw_sessions (+ team_id Int64,+ session_id_v7 UInt128,+ distinct_id AggregateFunction(argMax, String, DateTime64(6, 'UTC')),+ min_timestamp SimpleAggregateFunction(min, DateTime64(6, 'UTC')),+ max_timestamp SimpleAggregateFunction(max, DateTime64(6, 'UTC')),+ max_inserted_at SimpleAggregateFunction(max, DateTime64(6, 'UTC')),+ urls SimpleAggregateFunction(groupUniqArrayArray, Array(String)),+ entry_url AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ end_url AggregateFunction(argMax, String, DateTime64(6, 'UTC')),+ last_external_click_url AggregateFunction(argMax, String, DateTime64(6, 'UTC')),+ initial_browser AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_browser_version AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_os AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_os_version AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_device_type AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_viewport_width AggregateFunction(argMin, Int64, DateTime64(6, 'UTC')),+ initial_viewport_height AggregateFunction(argMin, Int64, DateTime64(6, 'UTC')),+ initial_geoip_country_code AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_geoip_subdivision_1_code AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_geoip_subdivision_1_name AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_geoip_subdivision_city_name AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_geoip_time_zone AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_referring_domain AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_utm_source AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_utm_campaign AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_utm_medium AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_utm_term AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_utm_content AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_gclid AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_gad_source AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_gclsrc AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_dclid AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_gbraid AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_wbraid AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_fbclid AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_msclkid AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_twclid AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_li_fat_id AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_mc_cid AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_igshid AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_ttclid AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_epik AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_qclid AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_sccid AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial__kx AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_irclid AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ pageview_count SimpleAggregateFunction(sum, Int64),+ pageview_uniq AggregateFunction(uniq, Nullable(UUID)),+ autocapture_count SimpleAggregateFunction(sum, Int64),+ autocapture_uniq AggregateFunction(uniq, Nullable(UUID)),+ screen_count SimpleAggregateFunction(sum, Int64),+ screen_uniq AggregateFunction(uniq, Nullable(UUID)),+ maybe_has_session_replay SimpleAggregateFunction(max, Bool),+ page_screen_autocapture_uniq_up_to AggregateFunction(uniqUpTo(1), Nullable(UUID)),+ vitals_lcp AggregateFunction(argMin, Nullable(Float64), DateTime64(6, 'UTC'))+) ENGINE = ReplicatedAggregatingMergeTree('/clickhouse/tables/{shard}/posthog.raw_sessions', '{replica}') 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;+CREATE TABLE posthog.sharded_raw_sessions_v3 (+ team_id Int64,+ session_id_v7 UInt128,+ session_timestamp DateTime64(3) DEFAULT fromUnixTimestamp64Milli(toUInt64(bitShiftRight(session_id_v7, 80))),+ distinct_id AggregateFunction(argMax, String, DateTime64(6, 'UTC')),+ distinct_ids AggregateFunction(groupUniqArray, String),+ min_timestamp SimpleAggregateFunction(min, DateTime64(6, 'UTC')),+ max_timestamp SimpleAggregateFunction(max, DateTime64(6, 'UTC')),+ max_inserted_at SimpleAggregateFunction(max, DateTime64(6, 'UTC')),+ urls SimpleAggregateFunction(groupUniqArrayArray(2000), Array(String)),+ entry_url AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC')),+ end_url AggregateFunction(argMax, Nullable(String), DateTime64(6, 'UTC')),+ last_external_click_url AggregateFunction(argMax, Nullable(String), DateTime64(6, 'UTC')),+ browser AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC')),+ browser_version AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC')),+ os AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC')),+ os_version AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC')),+ device_type AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC')),+ viewport_width AggregateFunction(argMin, Nullable(Int64), DateTime64(6, 'UTC')),+ viewport_height AggregateFunction(argMin, Nullable(Int64), DateTime64(6, 'UTC')),+ geoip_country_code AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC')),+ geoip_subdivision_1_code AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC')),+ geoip_subdivision_1_name AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC')),+ geoip_subdivision_city_name AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC')),+ geoip_time_zone AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC')),+ entry_referring_domain AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC')),+ entry_utm_source AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC')),+ entry_utm_campaign AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC')),+ entry_utm_medium AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC')),+ entry_utm_term AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC')),+ entry_utm_content AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC')),+ entry_gclid AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC')),+ entry_gad_source AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC')),+ entry_fbclid AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC')),+ entry_has_gclid AggregateFunction(argMin, Bool, DateTime64(6, 'UTC')),+ entry_has_fbclid AggregateFunction(argMin, Bool, DateTime64(6, 'UTC')),+ entry_ad_ids_map AggregateFunction(argMin, Map(String, String), DateTime64(6, 'UTC')),+ entry_ad_ids_set AggregateFunction(argMin, Array(String), DateTime64(6, 'UTC')),+ entry_channel_type_properties AggregateFunction(argMin, Tuple(Nullable(String), Nullable(String), Nullable(String), Nullable(String), Bool, Bool, Nullable(String)), DateTime64(6, 'UTC')),+ pageview_uniq AggregateFunction(uniqExact, Nullable(UUID)),+ autocapture_uniq AggregateFunction(uniqExact, Nullable(UUID)),+ screen_uniq AggregateFunction(uniqExact, Nullable(UUID)),+ page_screen_uniq_up_to AggregateFunction(uniqUpTo(1), Nullable(UUID)),+ has_autocapture SimpleAggregateFunction(max, Bool),+ flag_values AggregateFunction(groupUniqArrayMap, Map(String, String)),+ flag_keys SimpleAggregateFunction(groupUniqArrayArray, Array(String)),+ event_names SimpleAggregateFunction(groupUniqArrayArray(2000), Array(String)),+ hosts SimpleAggregateFunction(groupUniqArrayArray(100), Array(String)),+ emails SimpleAggregateFunction(groupUniqArrayArray(10), Array(String)),+ has_replay_events SimpleAggregateFunction(max, Bool),+ INDEX event_names_bloom_filter event_names TYPE bloom_filter() GRANULARITY 1,+ INDEX flag_keys_bloom_filter flag_keys TYPE bloom_filter() GRANULARITY 1,+ INDEX hosts_bloom_filter hosts TYPE bloom_filter() GRANULARITY 1,+ INDEX emails_bloom_filter emails TYPE bloom_filter() GRANULARITY 1+) ENGINE = ReplicatedAggregatingMergeTree('/clickhouse/tables/{shard}/posthog.raw_sessions_v3', '{replica}') ORDER BY (team_id, session_timestamp, session_id_v7) PARTITION BY toYYYYMM(session_timestamp) SETTINGS index_granularity = 8192, max_delay_to_insert = 10, parts_to_delay_insert = 250, parts_to_throw_insert = 1000;+CREATE TABLE posthog.sharded_session_replay_embeddings (+ session_id String,+ team_id Int64,+ embeddings Array(Float32),+ generation_timestamp DateTime64(6, 'UTC') DEFAULT now('UTC'),+ source_type LowCardinality(String),+ input String+) ENGINE = ReplicatedMergeTree('/clickhouse/tables/{shard}/posthog.session_replay_embeddings', '{replica}') ORDER BY (toDate(generation_timestamp), team_id, session_id) PARTITION BY toYYYYMM(generation_timestamp) TTL toDate(generation_timestamp) + toIntervalYear(1) SETTINGS index_granularity = 512;+CREATE TABLE posthog.sharded_session_replay_events (+ session_id String,+ team_id Int64,+ 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),+ active_milliseconds SimpleAggregateFunction(sum, Int64),+ console_log_count SimpleAggregateFunction(sum, Int64),+ console_warn_count SimpleAggregateFunction(sum, Int64),+ console_error_count SimpleAggregateFunction(sum, Int64),+ size SimpleAggregateFunction(sum, Int64),+ message_count SimpleAggregateFunction(sum, Int64),+ event_count SimpleAggregateFunction(sum, Int64),+ snapshot_source AggregateFunction(argMin, LowCardinality(Nullable(String)), DateTime64(6, 'UTC')),+ snapshot_library AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC')),+ _timestamp SimpleAggregateFunction(max, DateTime),+ 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))+) 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 (+ session_id String,+ team_id Int64,+ distinct_id String,+ min_first_timestamp SimpleAggregateFunction(min, DateTime64(6, 'UTC')),+ max_last_timestamp SimpleAggregateFunction(max, DateTime64(6, 'UTC')),+ event_count SimpleAggregateFunction(sum, Int64),+ mouse_position_count SimpleAggregateFunction(sum, Int64),+ mouse_sum_x SimpleAggregateFunction(sum, Float64),+ mouse_sum_x_squared SimpleAggregateFunction(sum, Float64),+ mouse_sum_y SimpleAggregateFunction(sum, Float64),+ mouse_sum_y_squared SimpleAggregateFunction(sum, Float64),+ mouse_distance_traveled SimpleAggregateFunction(sum, Float64),+ mouse_direction_change_count SimpleAggregateFunction(sum, Int64),+ mouse_velocity_sum SimpleAggregateFunction(sum, Float64),+ mouse_velocity_sum_of_squares SimpleAggregateFunction(sum, Float64),+ mouse_velocity_count SimpleAggregateFunction(sum, Int64),+ scroll_event_count SimpleAggregateFunction(sum, Int64),+ total_scroll_magnitude SimpleAggregateFunction(sum, Float64),+ scroll_direction_reversal_count SimpleAggregateFunction(sum, Int64),+ rapid_scroll_reversal_count SimpleAggregateFunction(sum, Int64),+ scroll_to_top_count SimpleAggregateFunction(sum, Int64),+ click_count SimpleAggregateFunction(sum, Int64),+ keypress_count SimpleAggregateFunction(sum, Int64),+ mouse_activity_count SimpleAggregateFunction(sum, Int64),+ rage_click_count SimpleAggregateFunction(sum, Int64),+ dead_click_count SimpleAggregateFunction(sum, Int64),+ backspace_count SimpleAggregateFunction(sum, Int64),+ inter_action_gap_count SimpleAggregateFunction(sum, Int64),+ inter_action_gap_sum_ms SimpleAggregateFunction(sum, Float64),+ inter_action_gap_sum_of_squares_ms SimpleAggregateFunction(sum, Float64),+ max_idle_gap_ms SimpleAggregateFunction(max, Float64),+ long_idle_gap_count SimpleAggregateFunction(sum, Int64),+ quick_back_count SimpleAggregateFunction(sum, Int64),+ page_visit_count SimpleAggregateFunction(sum, Int64),+ unique_url_count AggregateFunction(uniqCombined(12), String),+ login_path_visit_count SimpleAggregateFunction(sum, Int64),+ signup_path_visit_count SimpleAggregateFunction(sum, Int64),+ checkout_path_visit_count SimpleAggregateFunction(sum, Int64),+ cart_path_visit_count SimpleAggregateFunction(sum, Int64),+ billing_path_visit_count SimpleAggregateFunction(sum, Int64),+ settings_path_visit_count SimpleAggregateFunction(sum, Int64),+ account_path_visit_count SimpleAggregateFunction(sum, Int64),+ error_path_visit_count SimpleAggregateFunction(sum, Int64),+ not_found_path_visit_count SimpleAggregateFunction(sum, Int64),+ admin_path_visit_count SimpleAggregateFunction(sum, Int64),+ dashboard_path_visit_count SimpleAggregateFunction(sum, Int64),+ onboarding_path_visit_count SimpleAggregateFunction(sum, Int64),+ cancel_path_visit_count SimpleAggregateFunction(sum, Int64),+ refund_path_visit_count SimpleAggregateFunction(sum, Int64),+ console_error_count SimpleAggregateFunction(sum, Int64),+ console_error_after_click_count SimpleAggregateFunction(sum, Int64),+ console_warn_count SimpleAggregateFunction(sum, Int64),+ network_request_count SimpleAggregateFunction(sum, Int64),+ network_failed_request_count SimpleAggregateFunction(sum, Int64),+ network_4xx_count SimpleAggregateFunction(sum, Int64),+ network_5xx_count SimpleAggregateFunction(sum, Int64),+ network_request_duration_sum SimpleAggregateFunction(sum, Float64),+ network_request_duration_sum_of_squares SimpleAggregateFunction(sum, Float64),+ network_request_duration_count SimpleAggregateFunction(sum, Int64),+ mutation_count SimpleAggregateFunction(sum, Int64),+ viewport_resize_count SimpleAggregateFunction(sum, Int64),+ touch_event_count SimpleAggregateFunction(sum, Int64),+ max_scroll_y SimpleAggregateFunction(max, Float64),+ unique_click_target_count AggregateFunction(uniqCombined(12), Int64),+ unique_form_field_count AggregateFunction(uniqCombined(12), Int64),+ text_selection_count SimpleAggregateFunction(sum, Int64),+ selection_copy_count SimpleAggregateFunction(sum, Int64),+ is_deleted SimpleAggregateFunction(max, UInt8) DEFAULT 0+) ENGINE = ReplicatedAggregatingMergeTree('/clickhouse/tables/{shard}/posthog.session_replay_features', '{replica}') ORDER BY (team_id, session_id) PARTITION BY toYYYYMM(min_first_timestamp) SETTINGS index_granularity = 512;+CREATE TABLE posthog.sharded_sessions (+ session_id String,+ team_id Int64,+ distinct_id SimpleAggregateFunction(any, String),+ min_timestamp SimpleAggregateFunction(min, DateTime64(6, 'UTC')),+ max_timestamp SimpleAggregateFunction(max, DateTime64(6, 'UTC')),+ urls SimpleAggregateFunction(groupUniqArrayArray, Array(String)),+ entry_url AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ exit_url AggregateFunction(argMax, String, DateTime64(6, 'UTC')),+ initial_referring_domain AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_utm_source AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_utm_campaign AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_utm_medium AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_utm_term AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_utm_content AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_gclid AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_gad_source AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_gclsrc AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_dclid AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_gbraid AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_wbraid AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_fbclid AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_msclkid AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_twclid AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_li_fat_id AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_mc_cid AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_igshid AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_ttclid AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_epik AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_qclid AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_sccid AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ event_count_map SimpleAggregateFunction(sumMap, Map(String, Int64)),+ pageview_count SimpleAggregateFunction(sum, Int64),+ autocapture_count SimpleAggregateFunction(sum, Int64)+) ENGINE = ReplicatedAggregatingMergeTree('/clickhouse/tables/{shard}/posthog.sessions', '{replica}') ORDER BY (toStartOfDay(min_timestamp), team_id, session_id) PARTITION BY toYYYYMM(min_timestamp) SETTINGS index_granularity = 512;+CREATE TABLE posthog.sharded_tophog (+ timestamp DateTime64(6, 'UTC'),+ metric LowCardinality(String),+ type LowCardinality(String) DEFAULT 'sum',+ key Map(LowCardinality(String), String),+ value Float64,+ count UInt64 DEFAULT 0,+ pipeline LowCardinality(String),+ lane LowCardinality(String),+ labels Map(LowCardinality(String), String)+) ENGINE = ReplicatedMergeTree('/clickhouse/tables/{shard}/posthog.tophog', '{replica}') ORDER BY (pipeline, lane, metric, timestamp, key) PARTITION BY toYYYYMMDD(timestamp) TTL toDate(timestamp) + toIntervalDay(30) SETTINGS index_granularity = 8192, ttl_only_drop_parts = 1;+CREATE TABLE posthog.sharded_usage_report_events_preagg (+ date Date,+ team_id Int64,+ person_mode LowCardinality(String),+ lib LowCardinality(String),+ event String,+ distinct_events_unique AggregateFunction(uniqExact, Tuple(UInt64, UInt64, UInt64)),+ event_count AggregateFunction(sum, UInt64)+) ENGINE = ReplicatedAggregatingMergeTree('/clickhouse/tables/{shard}/posthog.sharded_usage_report_events_preagg', '{replica}') ORDER BY (date, team_id, person_mode, lib, event) PARTITION BY date TTL date + toIntervalDay(14) SETTINGS index_granularity = 8192, ttl_only_drop_parts = 1;+CREATE TABLE posthog.sharded_web_bot_definition (+ id UInt64,+ parent_id UInt64,+ regexp String,+ keys Array(String),+ values Array(String)+) ENGINE = ReplicatedMergeTree('/clickhouse/tables/{shard}/posthog.sharded_web_bot_definition', '{replica}') ORDER BY (id) SETTINGS index_granularity = 8192;+CREATE TABLE posthog.sharded_web_bounces_dimensional_preaggregated (+ team_id Int64,+ job_id UUID,+ period_bucket DateTime,+ host String,+ device_type String,+ entry_pathname String,+ end_pathname String,+ browser String,+ os String,+ viewport_width Int64,+ viewport_height Int64,+ referring_domain String,+ utm_source String,+ utm_medium String,+ utm_campaign String,+ utm_term String,+ utm_content String,+ country_code String,+ city_name String,+ region_code String,+ region_name String,+ has_gclid Bool,+ has_gad_source_paid_search Bool,+ has_fbclid Bool,+ mat_metadata_backend Nullable(String),+ mat_metadata_loggedIn Nullable(Bool),+ persons_uniq_state AggregateFunction(uniq, UUID),+ sessions_uniq_state AggregateFunction(uniq, String),+ pageviews_count_state AggregateFunction(sum, Int64),+ bounces_count_state AggregateFunction(sum, Int64),+ total_session_duration_state AggregateFunction(sum, Int64),+ total_session_count_state AggregateFunction(sum, Int64),+ computed_at DateTime64(6, 'UTC') DEFAULT now(),+ expires_at DateTime64(6, 'UTC') DEFAULT now() + toIntervalDay(7)+) ENGINE = ReplicatedReplacingMergeTree('/clickhouse/tables/{shard}/posthog.web_bounces_dimensional_preaggregated', '{replica}', computed_at) ORDER BY (team_id, job_id, period_bucket, host, device_type, entry_pathname, end_pathname, browser, os, viewport_width, viewport_height, referring_domain, utm_source, utm_medium, utm_campaign, utm_term, utm_content, country_code, city_name, region_code, region_name, has_gclid, has_gad_source_paid_search, has_fbclid, mat_metadata_backend, mat_metadata_loggedIn) PARTITION BY toYYYYMMDD(expires_at) TTL toDateTime(expires_at) SETTINGS allow_nullable_key = 1, index_granularity = 8192, ttl_only_drop_parts = 1;+CREATE TABLE posthog.sharded_web_goals_preaggregated (+ team_id Int64,+ job_id UUID,+ time_window_start DateTime64(6, 'UTC'),+ action_id Int64,+ count_state AggregateFunction(sum, Int64),+ unique_persons_state AggregateFunction(uniq, UUID),+ computed_at DateTime64(6, 'UTC') DEFAULT now(),+ expires_at DateTime64(6, 'UTC') DEFAULT now() + toIntervalDay(7)+) ENGINE = ReplicatedReplacingMergeTree('/clickhouse/tables/{shard}/posthog.web_goals_preaggregated', '{replica}', computed_at) ORDER BY (team_id, job_id, action_id, time_window_start) PARTITION BY toYYYYMMDD(expires_at) TTL toDateTime(expires_at) SETTINGS index_granularity = 8192, ttl_only_drop_parts = 1;+CREATE TABLE posthog.sharded_web_overview_preaggregated (+ team_id Int64,+ job_id UUID,+ time_window_start DateTime64(6, 'UTC'),+ uniq_users_state AggregateFunction(uniq, UUID),+ uniq_sessions_state AggregateFunction(uniq, String),+ sum_pageviews_state AggregateFunction(sum, Int64),+ avg_duration_state AggregateFunction(avg, Float64),+ avg_bounce_state AggregateFunction(avg, Int64),+ computed_at DateTime64(6, 'UTC') DEFAULT now(),+ expires_at DateTime64(6, 'UTC') DEFAULT now() + toIntervalDay(7)+) ENGINE = ReplicatedReplacingMergeTree('/clickhouse/tables/{shard}/posthog.web_overview_preaggregated', '{replica}', computed_at) ORDER BY (team_id, job_id, time_window_start) PARTITION BY toYYYYMMDD(expires_at) TTL toDateTime(expires_at) SETTINGS index_granularity = 8192, ttl_only_drop_parts = 1;+CREATE TABLE posthog.sharded_web_stats_dimensional_preaggregated (+ team_id Int64,+ job_id UUID,+ period_bucket DateTime,+ host String,+ device_type String,+ pathname String,+ entry_pathname String,+ end_pathname String,+ browser String,+ os String,+ viewport_width Int64,+ viewport_height Int64,+ referring_domain String,+ utm_source String,+ utm_medium String,+ utm_campaign String,+ utm_term String,+ utm_content String,+ country_code String,+ city_name String,+ region_code String,+ region_name String,+ has_gclid Bool,+ has_gad_source_paid_search Bool,+ has_fbclid Bool,+ mat_metadata_backend Nullable(String),+ mat_metadata_loggedIn Nullable(Bool),+ persons_uniq_state AggregateFunction(uniq, UUID),+ sessions_uniq_state AggregateFunction(uniq, String),+ pageviews_count_state AggregateFunction(sum, Int64),+ computed_at DateTime64(6, 'UTC') DEFAULT now(),+ expires_at DateTime64(6, 'UTC') DEFAULT now() + toIntervalDay(7)+) ENGINE = ReplicatedReplacingMergeTree('/clickhouse/tables/{shard}/posthog.web_stats_dimensional_preaggregated', '{replica}', computed_at) ORDER BY (team_id, job_id, period_bucket, host, device_type, pathname, entry_pathname, end_pathname, browser, os, viewport_width, viewport_height, referring_domain, utm_source, utm_medium, utm_campaign, utm_term, utm_content, country_code, city_name, region_code, region_name, has_gclid, has_gad_source_paid_search, has_fbclid, mat_metadata_backend, mat_metadata_loggedIn) PARTITION BY toYYYYMMDD(expires_at) TTL toDateTime(expires_at) SETTINGS allow_nullable_key = 1, index_granularity = 8192, ttl_only_drop_parts = 1;+CREATE TABLE posthog.sharded_web_stats_frustration_preaggregated (+ team_id Int64,+ job_id UUID,+ time_window_start DateTime64(6, 'UTC'),+ breakdown_value String,+ sum_rage_clicks_state AggregateFunction(sum, Int64),+ sum_dead_clicks_state AggregateFunction(sum, Int64),+ sum_errors_state AggregateFunction(sum, Int64),+ computed_at DateTime64(6, 'UTC') DEFAULT now(),+ expires_at DateTime64(6, 'UTC') DEFAULT now() + toIntervalDay(7)+) ENGINE = ReplicatedReplacingMergeTree('/clickhouse/tables/{shard}/posthog.web_stats_frustration_preaggregated', '{replica}', computed_at) ORDER BY (team_id, job_id, breakdown_value, time_window_start) PARTITION BY toYYYYMMDD(expires_at) TTL toDateTime(expires_at) SETTINGS index_granularity = 8192, ttl_only_drop_parts = 1;+CREATE TABLE posthog.sharded_web_stats_paths_preaggregated (+ team_id Int64,+ job_id UUID,+ time_window_start DateTime64(6, 'UTC'),+ breakdown_value String,+ uniq_users_state AggregateFunction(uniq, UUID),+ sum_pageviews_state AggregateFunction(sum, Int64),+ avg_bounce_state AggregateFunction(avg, Nullable(Float64)),+ computed_at DateTime64(6, 'UTC') DEFAULT now(),+ expires_at DateTime64(6, 'UTC') DEFAULT now() + toIntervalDay(7)+) ENGINE = ReplicatedReplacingMergeTree('/clickhouse/tables/{shard}/posthog.web_stats_paths_preaggregated', '{replica}', computed_at) ORDER BY (team_id, job_id, breakdown_value, time_window_start) PARTITION BY toYYYYMMDD(expires_at) TTL toDateTime(expires_at) SETTINGS index_granularity = 8192, ttl_only_drop_parts = 1;+CREATE TABLE posthog.sharded_web_stats_paths_preaggregated_pathkey (+ team_id Int64,+ job_id UUID,+ time_window_start DateTime64(6, 'UTC'),+ breakdown_value String,+ uniq_users_state AggregateFunction(uniq, UUID),+ sum_pageviews_state AggregateFunction(sum, Int64),+ avg_bounce_state AggregateFunction(avg, Nullable(Float64)),+ computed_at DateTime64(6, 'UTC') DEFAULT now(),+ expires_at DateTime64(6, 'UTC') DEFAULT now() + toIntervalDay(7)+) ENGINE = ReplicatedReplacingMergeTree('/clickhouse/tables/{shard}/posthog.web_stats_paths_preaggregated_pathkey', '{replica}', computed_at) ORDER BY (team_id, time_window_start, breakdown_value, job_id) PARTITION BY toYYYYMMDD(expires_at) TTL toDateTime(expires_at) SETTINGS index_granularity = 8192, ttl_only_drop_parts = 1;+CREATE TABLE posthog.sharded_web_stats_preaggregated (+ team_id Int64,+ job_id UUID,+ time_window_start DateTime64(6, 'UTC'),+ breakdown_by String,+ breakdown_value String,+ uniq_users_state AggregateFunction(uniq, UUID),+ sum_pageviews_state AggregateFunction(sum, Int64),+ computed_at DateTime64(6, 'UTC') DEFAULT now(),+ expires_at DateTime64(6, 'UTC') DEFAULT now() + toIntervalDay(7)+) ENGINE = ReplicatedReplacingMergeTree('/clickhouse/tables/{shard}/posthog.web_stats_preaggregated', '{replica}', computed_at) ORDER BY (team_id, job_id, breakdown_by, time_window_start, breakdown_value) PARTITION BY toYYYYMMDD(expires_at) TTL toDateTime(expires_at) SETTINGS index_granularity = 8192, ttl_only_drop_parts = 1;+CREATE TABLE posthog.sharded_web_vitals_paths_preaggregated (+ team_id Int64,+ job_id UUID,+ time_window_start DateTime64(6, 'UTC'),+ path String,+ inp_quantiles_state AggregateFunction(quantiles(0.75, 0.9, 0.99), Float64),+ lcp_quantiles_state AggregateFunction(quantiles(0.75, 0.9, 0.99), Float64),+ cls_quantiles_state AggregateFunction(quantiles(0.75, 0.9, 0.99), Float64),+ fcp_quantiles_state AggregateFunction(quantiles(0.75, 0.9, 0.99), Float64),+ computed_at DateTime64(6, 'UTC') DEFAULT now(),+ expires_at DateTime64(6, 'UTC') DEFAULT now() + toIntervalDay(7)+) ENGINE = ReplicatedReplacingMergeTree('/clickhouse/tables/{shard}/posthog.web_vitals_paths_preaggregated', '{replica}', computed_at) ORDER BY (team_id, job_id, time_window_start, path) PARTITION BY toYYYYMMDD(expires_at) TTL toDateTime(expires_at) SETTINGS index_granularity = 8192, ttl_only_drop_parts = 1;+CREATE TABLE posthog.tophog (+ timestamp DateTime64(6, 'UTC'),+ metric LowCardinality(String),+ type LowCardinality(String) DEFAULT 'sum',+ key Map(LowCardinality(String), String),+ value Float64,+ count UInt64 DEFAULT 0,+ pipeline LowCardinality(String),+ lane LowCardinality(String),+ labels Map(LowCardinality(String), String)+) ENGINE = Distributed('posthog', 'posthog', 'sharded_tophog', cityHash64(toString(key)));+CREATE TABLE posthog.trace_attributes (+ team_id Int32,+ original_expiry_time_bucket DateTime64(0),+ time_bucket DateTime64(0),+ service_name LowCardinality(String),+ resource_fingerprint UInt64 DEFAULT 0,+ attribute_key LowCardinality(String),+ attribute_value String,+ attribute_type LowCardinality(String),+ attribute_count SimpleAggregateFunction(sum, UInt64),+ INDEX idx_attribute_key attribute_key TYPE bloom_filter(0.01) GRANULARITY 4,+ INDEX idx_attribute_value attribute_value TYPE bloom_filter(0.01) GRANULARITY 4,+ INDEX idx_attribute_key_n3 attribute_key TYPE ngrambf_v1(3, 32768, 3, 0) GRANULARITY 4,+ INDEX idx_attribute_value_n3 attribute_value TYPE ngrambf_v1(3, 32768, 3, 0) GRANULARITY 4+) ENGINE = ReplicatedMergeTree('/clickhouse/tables/noshard/posthog.trace_attributes', '{replica}-{shard}') ORDER BY (team_id, attribute_type, time_bucket, resource_fingerprint, attribute_key, attribute_value) PARTITION BY toDate(original_expiry_time_bucket) TTL original_expiry_time_bucket SETTINGS index_granularity = 8192;+CREATE TABLE posthog.trace_attributes2 (+ team_id Int32,+ original_expiry_time_bucket DateTime64(0),+ time_bucket DateTime64(0),+ service_name LowCardinality(String),+ resource_fingerprint UInt64 DEFAULT 0,+ attribute_key LowCardinality(String),+ attribute_value String,+ attribute_type LowCardinality(String),+ attribute_count SimpleAggregateFunction(sum, UInt64),+ INDEX idx_attribute_key attribute_key TYPE bloom_filter(0.01) GRANULARITY 4,+ INDEX idx_attribute_value attribute_value TYPE bloom_filter(0.01) GRANULARITY 4,+ INDEX idx_attribute_key_n3 attribute_key TYPE ngrambf_v1(3, 32768, 3, 0) GRANULARITY 4,+ INDEX idx_attribute_value_n3 attribute_value TYPE ngrambf_v1(3, 32768, 3, 0) GRANULARITY 4+) ENGINE = ReplicatedAggregatingMergeTree('/clickhouse/tables/noshard/posthog.trace_attributes2', '{replica}-{shard}') ORDER BY (team_id, attribute_type, time_bucket, resource_fingerprint, attribute_key, attribute_value) PARTITION BY toDate(original_expiry_time_bucket) TTL original_expiry_time_bucket SETTINGS index_granularity = 8192;+CREATE TABLE posthog.trace_attributes_distributed (+ team_id Int32,+ original_expiry_time_bucket DateTime64(0),+ time_bucket DateTime64(0),+ service_name LowCardinality(String),+ resource_fingerprint UInt64 DEFAULT 0,+ attribute_key LowCardinality(String),+ attribute_value String,+ attribute_type LowCardinality(String),+ attribute_count SimpleAggregateFunction(sum, UInt64)+) ENGINE = Distributed('posthog_single_shard', 'posthog', 'trace_attributes');+CREATE TABLE posthog.trace_spans (+ time_bucket DateTime MATERIALIZED toStartOfInterval(timestamp, toIntervalHour(4)),+ original_expiry_timestamp DateTime64(6),+ uuid String,+ team_id Int32,+ trace_id String,+ span_id String,+ parent_span_id String,+ is_root_span Bool MATERIALIZED replaceAll(trimRight(parent_span_id, '='), 'A', '') = '',+ trace_state String,+ name LowCardinality(String),+ kind Int8,+ flags UInt32,+ timestamp DateTime64(6),+ end_time DateTime64(6),+ observed_timestamp DateTime64(6),+ created_at DateTime64(6) MATERIALIZED now(),+ duration_nano UInt64 MATERIALIZED toUInt64(dateDiff('microsecond', timestamp, end_time)) * 1000,+ status_code Int16,+ service_name LowCardinality(String),+ resource_attributes Map(LowCardinality(String), String),+ resource_fingerprint UInt64 MATERIALIZED cityHash64(resource_attributes),+ instrumentation_scope String,+ attributes_map_str Map(LowCardinality(String), String),+ attributes Map(LowCardinality(String), String) ALIAS mapApply((k, v) -> (left(k, -5), v), attributes_map_str),+ attributes_map_float Map(LowCardinality(String), Float64) MATERIALIZED mapFilter((k, v) -> (v IS NOT NULL), mapApply((k, v) -> (concat(left(k, -5), '__float'), toFloat64OrNull(v)), attributes_map_str)),+ attributes_map_datetime Map(LowCardinality(String), DateTime64(6)) MATERIALIZED mapFilter((k, v) -> (v IS NOT NULL), mapApply((k, v) -> (concat(left(k, -5), '__datetime'), parseDateTimeBestEffortOrNull(v, 6)), attributes_map_str)),+ dropped_attributes_count UInt32,+ dropped_events_count UInt32,+ dropped_links_count UInt32,+ events Array(String),+ links Array(String),+ _partition UInt32,+ _topic String,+ _offset UInt64,+ _bytes_uncompressed UInt64,+ _bytes_compressed UInt64,+ _record_count UInt64,+ INDEX idx_name name TYPE ngrambf_v1(4, 5000, 2, 0) GRANULARITY 16,+ INDEX idx_kind kind TYPE minmax GRANULARITY 4,+ INDEX idx_duration duration_nano TYPE minmax GRANULARITY 1,+ INDEX idx_status_code status_code TYPE minmax GRANULARITY 1,+ INDEX idx_timestamp_minmax timestamp TYPE minmax GRANULARITY 1,+ INDEX idx_observed_minmax observed_timestamp TYPE minmax GRANULARITY 1,+ INDEX idx_attributes_str_keys mapKeys(attributes_map_str) TYPE bloom_filter(0.01) GRANULARITY 16,+ INDEX idx_attributes_str_values mapValues(attributes_map_str) TYPE bloom_filter(0.001) GRANULARITY 16,+ INDEX idx_trace_bloom_part trace_id TYPE bloom_filter(0.00001) GRANULARITY 99999,+ INDEX idx_span_id_bloom_part span_id TYPE bloom_filter(0.00001) GRANULARITY 99999,+ PROJECTION projection_aggregate_counts (SELECT+ team_id,+ time_bucket,+ toStartOfMinute(timestamp),+ service_name,+ resource_fingerprint,+ is_root_span,+ count() AS event_count+GROUP BY+ team_id, time_bucket, toStartOfMinute(timestamp), service_name, resource_fingerprint, is_root_span),+ PROJECTION projection_index_span_id (SELECT _part_offset+ORDER BY span_id),+ PROJECTION projection_index_trace_id (SELECT _part_offset+ORDER BY trace_id)+) ENGINE = ReplicatedMergeTree('/clickhouse/tables/noshard/posthog.trace_spans', '{replica}-{shard}') ORDER BY (team_id, time_bucket, service_name, resource_fingerprint, status_code, name, timestamp) PARTITION BY toDate(original_expiry_timestamp) TTL original_expiry_timestamp SETTINGS allow_part_offset_column_in_projections = 1, index_granularity = 8192, index_granularity_bytes = 104857600, map_serialization_version = 'with_buckets', ttl_only_drop_parts = 1;+CREATE TABLE posthog.trace_spans_distributed (+ time_bucket DateTime MATERIALIZED toStartOfInterval(timestamp, toIntervalHour(4)),+ original_expiry_timestamp DateTime64(6),+ uuid String,+ team_id Int32,+ trace_id String,+ span_id String,+ parent_span_id String,+ is_root_span Bool MATERIALIZED replaceAll(trimRight(parent_span_id, '='), 'A', '') = '',+ trace_state String,+ name LowCardinality(String),+ kind Int8,+ flags UInt32,+ timestamp DateTime64(6),+ end_time DateTime64(6),+ observed_timestamp DateTime64(6),+ created_at DateTime64(6) MATERIALIZED now(),+ duration_nano UInt64 MATERIALIZED toUInt64(dateDiff('microsecond', timestamp, end_time)) * 1000,+ status_code Int16,+ service_name LowCardinality(String),+ resource_attributes Map(LowCardinality(String), String),+ resource_fingerprint UInt64 MATERIALIZED cityHash64(resource_attributes),+ instrumentation_scope String,+ attributes_map_str Map(LowCardinality(String), String),+ attributes Map(LowCardinality(String), String) ALIAS mapApply((k, v) -> (left(k, -5), v), attributes_map_str),+ attributes_map_float Map(LowCardinality(String), Float64) MATERIALIZED mapFilter((k, v) -> (v IS NOT NULL), mapApply((k, v) -> (concat(left(k, -5), '__float'), toFloat64OrNull(v)), attributes_map_str)),+ attributes_map_datetime Map(LowCardinality(String), DateTime64(6)) MATERIALIZED mapFilter((k, v) -> (v IS NOT NULL), mapApply((k, v) -> (concat(left(k, -5), '__datetime'), parseDateTimeBestEffortOrNull(v, 6)), attributes_map_str)),+ dropped_attributes_count UInt32,+ dropped_events_count UInt32,+ dropped_links_count UInt32,+ events Array(String),+ links Array(String),+ _partition UInt32,+ _topic String,+ _offset UInt64,+ _bytes_uncompressed UInt64,+ _bytes_compressed UInt64,+ _record_count UInt64+) ENGINE = Distributed('posthog_single_shard', 'posthog', 'trace_spans');+CREATE TABLE posthog.trace_spans_kafka_metrics (+ _partition UInt32,+ _topic String,+ max_offset SimpleAggregateFunction(max, UInt64),+ max_observed_timestamp SimpleAggregateFunction(max, DateTime64(9)),+ max_timestamp SimpleAggregateFunction(max, DateTime64(9)),+ max_created_at SimpleAggregateFunction(max, DateTime64(9)),+ max_lag SimpleAggregateFunction(max, UInt64)+) ENGINE = ReplicatedMergeTree('/clickhouse/tables/noshard/posthog.trace_spans_kafka_metrics', '{replica}-{shard}') ORDER BY (_topic, _partition) SETTINGS index_granularity = 8192;+CREATE TABLE posthog.usage_report_events_preagg (+ date Date,+ team_id Int64,+ person_mode LowCardinality(String),+ lib LowCardinality(String),+ event String,+ distinct_events_unique AggregateFunction(uniqExact, Tuple(UInt64, UInt64, UInt64)),+ event_count AggregateFunction(sum, UInt64)+) ENGINE = Distributed('aux', 'posthog', 'sharded_usage_report_events_preagg', sipHash64(date));+CREATE TABLE posthog.web_bot_definition (+ id UInt64,+ parent_id UInt64,+ regexp String,+ keys Array(String),+ values Array(String)+) ENGINE = Distributed('aux', 'posthog', 'sharded_web_bot_definition', sipHash64(id));+CREATE TABLE posthog.web_bounces_dimensional_preaggregated (+ team_id Int64,+ job_id UUID,+ period_bucket DateTime,+ host String,+ device_type String,+ entry_pathname String,+ end_pathname String,+ browser String,+ os String,+ viewport_width Int64,+ viewport_height Int64,+ referring_domain String,+ utm_source String,+ utm_medium String,+ utm_campaign String,+ utm_term String,+ utm_content String,+ country_code String,+ city_name String,+ region_code String,+ region_name String,+ has_gclid Bool,+ has_gad_source_paid_search Bool,+ has_fbclid Bool,+ mat_metadata_backend Nullable(String),+ mat_metadata_loggedIn Nullable(Bool),+ persons_uniq_state AggregateFunction(uniq, UUID),+ sessions_uniq_state AggregateFunction(uniq, String),+ pageviews_count_state AggregateFunction(sum, Int64),+ bounces_count_state AggregateFunction(sum, Int64),+ total_session_duration_state AggregateFunction(sum, Int64),+ total_session_count_state AggregateFunction(sum, Int64),+ computed_at DateTime64(6, 'UTC') DEFAULT now(),+ expires_at DateTime64(6, 'UTC') DEFAULT now() + toIntervalDay(7)+) ENGINE = Distributed('aux', 'posthog', 'sharded_web_bounces_dimensional_preaggregated', sipHash64(job_id));+CREATE TABLE posthog.web_goals_preaggregated (+ team_id Int64,+ job_id UUID,+ time_window_start DateTime64(6, 'UTC'),+ action_id Int64,+ count_state AggregateFunction(sum, Int64),+ unique_persons_state AggregateFunction(uniq, UUID),+ computed_at DateTime64(6, 'UTC') DEFAULT now(),+ expires_at DateTime64(6, 'UTC') DEFAULT now() + toIntervalDay(7)+) ENGINE = Distributed('aux', 'posthog', 'sharded_web_goals_preaggregated', sipHash64(job_id));+CREATE TABLE posthog.web_overview_preaggregated (+ team_id Int64,+ job_id UUID,+ time_window_start DateTime64(6, 'UTC'),+ uniq_users_state AggregateFunction(uniq, UUID),+ uniq_sessions_state AggregateFunction(uniq, String),+ sum_pageviews_state AggregateFunction(sum, Int64),+ avg_duration_state AggregateFunction(avg, Float64),+ avg_bounce_state AggregateFunction(avg, Int64),+ computed_at DateTime64(6, 'UTC') DEFAULT now(),+ expires_at DateTime64(6, 'UTC') DEFAULT now() + toIntervalDay(7)+) ENGINE = Distributed('aux', 'posthog', 'sharded_web_overview_preaggregated', sipHash64(job_id));+CREATE TABLE posthog.web_pre_aggregated_bounces (+ period_bucket DateTime,+ team_id UInt64,+ host String,+ device_type String,+ entry_pathname String,+ end_pathname String,+ browser String,+ os String,+ viewport_width Int64,+ viewport_height Int64,+ referring_domain String,+ utm_source String,+ utm_medium String,+ utm_campaign String,+ utm_term String,+ utm_content String,+ country_code String,+ city_name String,+ region_code String,+ region_name String,+ has_gclid Bool,+ has_gad_source_paid_search Bool,+ has_fbclid Bool,+ mat_metadata_loggedIn Bool,+ mat_metadata_backend String,+ persons_uniq_state AggregateFunction(uniq, UUID),+ sessions_uniq_state AggregateFunction(uniq, String),+ pageviews_count_state AggregateFunction(sum, UInt64),+ bounces_count_state AggregateFunction(sum, UInt64),+ total_session_duration_state AggregateFunction(sum, Int64),+ total_session_count_state AggregateFunction(sum, UInt64)+) ENGINE = ReplicatedMergeTree('/clickhouse/tables/noshard/posthog.web_pre_aggregated_bounces', '{replica}-{shard}') ORDER BY (team_id, period_bucket, host, device_type, entry_pathname, end_pathname, browser, os, viewport_width, viewport_height, referring_domain, utm_source, utm_medium, utm_campaign, utm_term, utm_content, country_code, city_name, region_code, region_name, has_gclid, has_gad_source_paid_search, has_fbclid, mat_metadata_loggedIn, mat_metadata_backend) PARTITION BY toYYYYMMDD(period_bucket) SETTINGS index_granularity = 8192;+CREATE TABLE posthog.web_pre_aggregated_bounces_staging (+ period_bucket DateTime,+ team_id UInt64,+ host String,+ device_type String,+ entry_pathname String,+ end_pathname String,+ browser String,+ os String,+ viewport_width Int64,+ viewport_height Int64,+ referring_domain String,+ utm_source String,+ utm_medium String,+ utm_campaign String,+ utm_term String,+ utm_content String,+ country_code String,+ city_name String,+ region_code String,+ region_name String,+ has_gclid Bool,+ has_gad_source_paid_search Bool,+ has_fbclid Bool,+ mat_metadata_loggedIn Bool,+ mat_metadata_backend String,+ persons_uniq_state AggregateFunction(uniq, UUID),+ sessions_uniq_state AggregateFunction(uniq, String),+ pageviews_count_state AggregateFunction(sum, UInt64),+ bounces_count_state AggregateFunction(sum, UInt64),+ total_session_duration_state AggregateFunction(sum, Int64),+ total_session_count_state AggregateFunction(sum, UInt64)+) ENGINE = ReplicatedMergeTree('/clickhouse/tables/noshard/posthog.web_pre_aggregated_bounces_staging', '{replica}-{shard}') ORDER BY (team_id, period_bucket, host, device_type, entry_pathname, end_pathname, browser, os, viewport_width, viewport_height, referring_domain, utm_source, utm_medium, utm_campaign, utm_term, utm_content, country_code, city_name, region_code, region_name, has_gclid, has_gad_source_paid_search, has_fbclid, mat_metadata_loggedIn, mat_metadata_backend) PARTITION BY toYYYYMMDD(period_bucket) SETTINGS index_granularity = 8192;+CREATE TABLE posthog.web_pre_aggregated_stats (+ period_bucket DateTime,+ team_id UInt64,+ host String,+ device_type String,+ pathname String,+ entry_pathname String,+ end_pathname String,+ browser String,+ os String,+ viewport_width Int64,+ viewport_height Int64,+ referring_domain String,+ utm_source String,+ utm_medium String,+ utm_campaign String,+ utm_term String,+ utm_content String,+ country_code String,+ city_name String,+ region_code String,+ region_name String,+ has_gclid Bool,+ has_gad_source_paid_search Bool,+ has_fbclid Bool,+ mat_metadata_loggedIn Bool,+ mat_metadata_backend String,+ persons_uniq_state AggregateFunction(uniq, UUID),+ sessions_uniq_state AggregateFunction(uniq, String),+ pageviews_count_state AggregateFunction(sum, UInt64)+) ENGINE = ReplicatedMergeTree('/clickhouse/tables/noshard/posthog.web_pre_aggregated_stats', '{replica}-{shard}') ORDER BY (team_id, period_bucket, host, device_type, pathname, entry_pathname, end_pathname, browser, os, viewport_width, viewport_height, referring_domain, utm_source, utm_medium, utm_campaign, utm_term, utm_content, country_code, city_name, region_code, region_name, has_gclid, has_gad_source_paid_search, has_fbclid, mat_metadata_loggedIn, mat_metadata_backend) PARTITION BY toYYYYMMDD(period_bucket) SETTINGS index_granularity = 8192;+CREATE TABLE posthog.web_pre_aggregated_stats_staging (+ period_bucket DateTime,+ team_id UInt64,+ host String,+ device_type String,+ pathname String,+ entry_pathname String,+ end_pathname String,+ browser String,+ os String,+ viewport_width Int64,+ viewport_height Int64,+ referring_domain String,+ utm_source String,+ utm_medium String,+ utm_campaign String,+ utm_term String,+ utm_content String,+ country_code String,+ city_name String,+ region_code String,+ region_name String,+ has_gclid Bool,+ has_gad_source_paid_search Bool,+ has_fbclid Bool,+ mat_metadata_loggedIn Bool,+ mat_metadata_backend String,+ persons_uniq_state AggregateFunction(uniq, UUID),+ sessions_uniq_state AggregateFunction(uniq, String),+ pageviews_count_state AggregateFunction(sum, UInt64)+) ENGINE = ReplicatedMergeTree('/clickhouse/tables/noshard/posthog.web_pre_aggregated_stats_staging', '{replica}-{shard}') ORDER BY (team_id, period_bucket, host, device_type, pathname, entry_pathname, end_pathname, browser, os, viewport_width, viewport_height, referring_domain, utm_source, utm_medium, utm_campaign, utm_term, utm_content, country_code, city_name, region_code, region_name, has_gclid, has_gad_source_paid_search, has_fbclid, mat_metadata_loggedIn, mat_metadata_backend) PARTITION BY toYYYYMMDD(period_bucket) SETTINGS index_granularity = 8192;+CREATE TABLE posthog.web_pre_aggregated_teams (+ team_id UInt64,+ enabled_by String DEFAULT 'system',+ version UInt32 DEFAULT toUnixTimestamp(now())+) ENGINE = ReplicatedReplacingMergeTree('/clickhouse/tables/noshard/posthog.web_analytics_team_selection', '{replica}-{shard}', version) ORDER BY (team_id) SETTINGS index_granularity = 8192;+CREATE TABLE posthog.web_stats_dimensional_preaggregated (+ team_id Int64,+ job_id UUID,+ period_bucket DateTime,+ host String,+ device_type String,+ pathname String,+ entry_pathname String,+ end_pathname String,+ browser String,+ os String,+ viewport_width Int64,+ viewport_height Int64,+ referring_domain String,+ utm_source String,+ utm_medium String,+ utm_campaign String,+ utm_term String,+ utm_content String,+ country_code String,+ city_name String,+ region_code String,+ region_name String,+ has_gclid Bool,+ has_gad_source_paid_search Bool,+ has_fbclid Bool,+ mat_metadata_backend Nullable(String),+ mat_metadata_loggedIn Nullable(Bool),+ persons_uniq_state AggregateFunction(uniq, UUID),+ sessions_uniq_state AggregateFunction(uniq, String),+ pageviews_count_state AggregateFunction(sum, Int64),+ computed_at DateTime64(6, 'UTC') DEFAULT now(),+ expires_at DateTime64(6, 'UTC') DEFAULT now() + toIntervalDay(7)+) ENGINE = Distributed('aux', 'posthog', 'sharded_web_stats_dimensional_preaggregated', sipHash64(job_id));+CREATE TABLE posthog.web_stats_frustration_preaggregated (+ team_id Int64,+ job_id UUID,+ time_window_start DateTime64(6, 'UTC'),+ breakdown_value String,+ sum_rage_clicks_state AggregateFunction(sum, Int64),+ sum_dead_clicks_state AggregateFunction(sum, Int64),+ sum_errors_state AggregateFunction(sum, Int64),+ computed_at DateTime64(6, 'UTC') DEFAULT now(),+ expires_at DateTime64(6, 'UTC') DEFAULT now() + toIntervalDay(7)+) ENGINE = Distributed('aux', 'posthog', 'sharded_web_stats_frustration_preaggregated', sipHash64(job_id));+CREATE TABLE posthog.web_stats_paths_preaggregated (+ team_id Int64,+ job_id UUID,+ time_window_start DateTime64(6, 'UTC'),+ breakdown_value String,+ uniq_users_state AggregateFunction(uniq, UUID),+ sum_pageviews_state AggregateFunction(sum, Int64),+ avg_bounce_state AggregateFunction(avg, Nullable(Float64)),+ computed_at DateTime64(6, 'UTC') DEFAULT now(),+ expires_at DateTime64(6, 'UTC') DEFAULT now() + toIntervalDay(7)+) ENGINE = Distributed('aux', 'posthog', 'sharded_web_stats_paths_preaggregated', sipHash64(job_id));+CREATE TABLE posthog.web_stats_paths_preaggregated_pathkey (+ team_id Int64,+ job_id UUID,+ time_window_start DateTime64(6, 'UTC'),+ breakdown_value String,+ uniq_users_state AggregateFunction(uniq, UUID),+ sum_pageviews_state AggregateFunction(sum, Int64),+ avg_bounce_state AggregateFunction(avg, Nullable(Float64)),+ computed_at DateTime64(6, 'UTC') DEFAULT now(),+ expires_at DateTime64(6, 'UTC') DEFAULT now() + toIntervalDay(7)+) ENGINE = Distributed('aux', 'posthog', 'sharded_web_stats_paths_preaggregated_pathkey', sipHash64(breakdown_value));+CREATE TABLE posthog.web_stats_preaggregated (+ team_id Int64,+ job_id UUID,+ time_window_start DateTime64(6, 'UTC'),+ breakdown_by String,+ breakdown_value String,+ uniq_users_state AggregateFunction(uniq, UUID),+ sum_pageviews_state AggregateFunction(sum, Int64),+ computed_at DateTime64(6, 'UTC') DEFAULT now(),+ expires_at DateTime64(6, 'UTC') DEFAULT now() + toIntervalDay(7)+) ENGINE = Distributed('aux', 'posthog', 'sharded_web_stats_preaggregated', sipHash64(job_id));+CREATE TABLE posthog.web_vitals_paths_preaggregated (+ team_id Int64,+ job_id UUID,+ time_window_start DateTime64(6, 'UTC'),+ path String,+ inp_quantiles_state AggregateFunction(quantiles(0.75, 0.9, 0.99), Float64),+ lcp_quantiles_state AggregateFunction(quantiles(0.75, 0.9, 0.99), Float64),+ cls_quantiles_state AggregateFunction(quantiles(0.75, 0.9, 0.99), Float64),+ fcp_quantiles_state AggregateFunction(quantiles(0.75, 0.9, 0.99), Float64),+ computed_at DateTime64(6, 'UTC') DEFAULT now(),+ expires_at DateTime64(6, 'UTC') DEFAULT now() + toIntervalDay(7)+) ENGINE = Distributed('aux', 'posthog', 'sharded_web_vitals_paths_preaggregated', sipHash64(job_id));+CREATE TABLE posthog.writable_app_metrics (+ team_id Int64,+ timestamp DateTime64(6, 'UTC'),+ plugin_config_id Int64,+ category LowCardinality(String),+ job_id String,+ successes SimpleAggregateFunction(sum, Int64),+ successes_on_retry SimpleAggregateFunction(sum, Int64),+ failures SimpleAggregateFunction(sum, Int64),+ error_uuid UUID,+ error_type String,+ error_details String CODEC(ZSTD(3)),+ _timestamp DateTime,+ _offset UInt64,+ _partition UInt64+) ENGINE = Distributed('posthog', 'posthog', 'sharded_app_metrics', rand());+CREATE TABLE posthog.writable_app_metrics2 (+ team_id Int64,+ timestamp DateTime64(6, 'UTC'),+ app_source LowCardinality(String),+ app_source_id String,+ instance_id String,+ metric_kind LowCardinality(String),+ metric_name LowCardinality(String),+ count SimpleAggregateFunction(sum, Int64),+ _timestamp DateTime,+ _offset UInt64,+ _partition UInt64+) ENGINE = Distributed('posthog', 'posthog', 'sharded_app_metrics2', rand());+CREATE TABLE posthog.writable_cohort_membership (+ team_id Int64,+ cohort_id Int64,+ person_id UUID,+ status Enum8('entered'=1, 'left'=2),+ last_updated DateTime64(6) DEFAULT now64()+) ENGINE = Distributed('posthog_single_shard', 'posthog', 'cohort_membership');+CREATE TABLE posthog.writable_distinct_id_usage (+ team_id Int64,+ distinct_id String,+ minute DateTime,+ event_count UInt64+) ENGINE = Distributed('posthog', 'posthog', 'sharded_distinct_id_usage', sipHash64(distinct_id));+CREATE TABLE posthog.writable_duplicate_events (+ team_id Int64,+ distinct_id String,+ event String,+ source_uuid UUID,+ duplicate_uuid UUID,+ similarity_score Float64,+ dedup_type LowCardinality(String),+ is_confirmed UInt8,+ reason Nullable(String),+ version String,+ different_property_count UInt32,+ properties_similarity Float64,+ source_message String,+ duplicate_message String,+ distinct_fields Array(Tuple(field_name String, original_value String, new_value String)),+ inserted_at DateTime64(3, 'UTC'),+ _timestamp DateTime,+ _offset UInt64,+ _partition UInt64+) ENGINE = Distributed('posthog_single_shard', 'posthog', 'duplicate_events');+CREATE TABLE posthog.writable_error_tracking_fingerprint_issue_state (+ team_id Int64,+ fingerprint String,+ issue_id UUID,+ issue_name Nullable(String),+ issue_description Nullable(String),+ issue_status String,+ issue_severity Nullable(String),+ assigned_user_id Nullable(Int64),+ assigned_role_id Nullable(UUID),+ first_seen DateTime64(3, 'UTC'),+ is_deleted Int8,+ version Int64,+ _timestamp DateTime,+ _offset UInt64,+ _partition UInt64+) ENGINE = Distributed('aux', 'posthog', 'raw_error_tracking_fingerprint_issue_state');+CREATE TABLE posthog.writable_error_tracking_issue_fingerprint_embeddings (+ team_id Int64,+ model_name LowCardinality(String),+ embedding_version Int64,+ fingerprint String,+ inserted_at DateTime64(3, 'UTC'),+ embeddings Array(Float64),+ _timestamp DateTime,+ _offset UInt64,+ _partition UInt64+) ENGINE = Distributed('posthog_single_shard', 'posthog', 'error_tracking_issue_fingerprint_embeddings');+CREATE TABLE posthog.writable_error_tracking_issue_fingerprint_overrides (+ team_id Int64,+ fingerprint String,+ issue_id UUID,+ is_deleted Int8,+ version Int64,+ _timestamp DateTime,+ _offset UInt64,+ _partition UInt64+) ENGINE = Distributed('posthog_single_shard', 'posthog', 'error_tracking_issue_fingerprint_overrides');+CREATE TABLE posthog.writable_events (+ uuid UUID,+ event String,+ properties String CODEC(ZSTD(3)),+ timestamp DateTime64(6, 'UTC'),+ team_id Int64,+ distinct_id String,+ elements_chain String,+ created_at DateTime64(6, 'UTC'),+ person_id UUID,+ person_created_at DateTime64(3),+ person_properties String CODEC(ZSTD(3)),+ group0_properties String CODEC(ZSTD(3)),+ group1_properties String CODEC(ZSTD(3)),+ group2_properties String CODEC(ZSTD(3)),+ group3_properties String CODEC(ZSTD(3)),+ group4_properties String CODEC(ZSTD(3)),+ group0_created_at DateTime64(3),+ group1_created_at DateTime64(3),+ group2_created_at DateTime64(3),+ group3_created_at DateTime64(3),+ group4_created_at DateTime64(3),+ person_mode Enum8('full'=0, 'propertyless'=1, 'force_upgrade'=2),+ historical_migration Bool,+ dmat_string_0 Nullable(String),+ dmat_string_1 Nullable(String),+ dmat_string_2 Nullable(String),+ dmat_string_3 Nullable(String),+ dmat_string_4 Nullable(String),+ dmat_string_5 Nullable(String),+ dmat_string_6 Nullable(String),+ dmat_string_7 Nullable(String),+ dmat_string_8 Nullable(String),+ dmat_string_9 Nullable(String),+ _timestamp DateTime,+ _offset UInt64,+ consumer_breadcrumbs Array(String)+) ENGINE = Distributed('posthog', 'posthog', 'sharded_events', sipHash64(distinct_id));+CREATE TABLE posthog.writable_events_dead_letter_queue (+ id UUID,+ event_uuid UUID,+ event String,+ properties String,+ distinct_id String,+ team_id Int64,+ elements_chain String,+ created_at DateTime64(6, 'UTC'),+ ip String,+ site_url String,+ now DateTime64(6, 'UTC'),+ raw_payload String,+ error_timestamp DateTime64(6, 'UTC'),+ error_location String,+ error String,+ tags Array(String),+ _timestamp DateTime,+ _offset UInt64+) ENGINE = Distributed('posthog_single_shard', 'posthog', 'events_dead_letter_queue');+CREATE TABLE posthog.writable_events_json (+ uuid UUID,+ event String,+ properties JSON(max_dynamic_types=8, max_dynamic_paths=256, `$active_feature_flags` Array(String), `$ai_experiment_id` Nullable(String), `$ai_http_status` Nullable(String), `$ai_is_error` Nullable(String), `$ai_model` Nullable(String), `$ai_parent_id` Nullable(String), `$ai_prompt_name` Nullable(String), `$ai_provider` Nullable(String), `$ai_session_id` Nullable(String), `$ai_span_id` Nullable(String), `$ai_total_cost_usd` Nullable(String), `$ai_trace_id` Nullable(String), `$anon_distinct_id` Nullable(String), `$app_build` Nullable(String), `$app_namespace` Nullable(String), `$app_version` Nullable(String), `$browser` Nullable(String), `$browser_version` Nullable(String), `$current_url` Nullable(String), `$device` Nullable(String), `$device_id` Nullable(String), `$device_model` Nullable(String), `$device_type` Nullable(String), `$el_text` Nullable(String), `$event_type` Nullable(String), `$exception_fingerprint` Nullable(String), `$exception_functions` Array(String), `$exception_issue_id` Nullable(String), `$exception_sources` Array(String), `$exception_types` Array(String), `$exception_values` Array(String), `$feature_flag` Nullable(String), `$feature_flag_payloads` Nullable(String), `$feature_flag_response` Nullable(String), `$geoip_city_name` Nullable(String), `$geoip_country_code` Nullable(String), `$geoip_country_name` Nullable(String), `$geoip_subdivision_1_code` Nullable(String), `$group_0` Nullable(String), `$group_1` Nullable(String), `$group_2` Nullable(String), `$group_3` Nullable(String), `$group_4` Nullable(String), `$groups` Nullable(String), `$host` Nullable(String), `$initial_pathname` Nullable(String), `$initial_referrer` Nullable(String), `$initial_referring_domain` Nullable(String), `$ip` Nullable(String), `$is_identified` Nullable(String), `$lib` Nullable(String), `$lib_custom_api_host` Nullable(String), `$lib_version` Nullable(String), `$lib_version__minor` Nullable(String), `$os` Nullable(String), `$os_name` Nullable(String), `$os_version` Nullable(String), `$pathname` Nullable(String), `$prev_pageview_max_content_percentage` Nullable(String), `$prev_pageview_max_scroll_percentage` Nullable(String), `$prev_pageview_pathname` Nullable(String), `$process_person_profile` Nullable(String), `$referrer` Nullable(String), `$referring_domain` Nullable(String), `$screen_height` Nullable(String), `$screen_name` Nullable(String), `$screen_width` Nullable(String), `$sent_at` Nullable(String), `$session_id` Nullable(String), `$survey_id` Nullable(String), `$survey_response` Nullable(String), `$survey_response_1` Nullable(String), `$time` Nullable(String), `$user_id` Nullable(String), `$viewport_height` Nullable(String), `$viewport_width` Nullable(String), `$web_vitals_CLS_value` Nullable(String), `$web_vitals_FCP_value` Nullable(String), `$web_vitals_INP_value` Nullable(String), `$web_vitals_LCP_value` Nullable(String), `$window_id` Nullable(String)),+ timestamp DateTime64(6, 'UTC'),+ team_id Int64,+ distinct_id String,+ elements_hash String DEFAULT '',+ created_at DateTime64(6, 'UTC'),+ _timestamp DateTime,+ _offset UInt64,+ elements_chain String,+ person_id UUID,+ person_properties JSON(max_dynamic_types=6, max_dynamic_paths=32, `$app_version` Nullable(String), `$browser` Nullable(String), `$current_url` Nullable(String), `$geoip_continent_name` Nullable(String), `$geoip_country_code` Nullable(String), `$geoip_country_name` Nullable(String), `$initial_current_url` Nullable(String), `$initial_fbclid` Nullable(String), `$initial_gad_source` Nullable(String), `$initial_gbraid` Nullable(String), `$initial_gclid` Nullable(String), `$initial_msclkid` Nullable(String), `$initial_pathname` Nullable(String), `$initial_referring_domain` Nullable(String), `$initial_utm_campaign` Nullable(String), `$initial_utm_content` Nullable(String), `$initial_utm_medium` Nullable(String), `$initial_utm_source` Nullable(String), `$initial_utm_term` Nullable(String), `$initial_wbraid` Nullable(String), `$os_name` Nullable(String), `$referring_domain` Nullable(String)),+ group0_properties String CODEC(ZSTD(3)),+ group1_properties String CODEC(ZSTD(3)),+ group2_properties String CODEC(ZSTD(3)),+ group3_properties String CODEC(ZSTD(3)),+ group4_properties String CODEC(ZSTD(3)),+ person_created_at DateTime64(3),+ group0_created_at DateTime64(3),+ group1_created_at DateTime64(3),+ group2_created_at DateTime64(3),+ group3_created_at DateTime64(3),+ group4_created_at DateTime64(3),+ inserted_at Nullable(DateTime64(6, 'UTC')) DEFAULT now64(),+ person_mode Enum8('full'=0, 'propertyless'=1, 'force_upgrade'=2),+ is_deleted Bool DEFAULT false,+ consumer_breadcrumbs Array(String),+ historical_migration Bool DEFAULT false+) ENGINE = Distributed('posthog', 'posthog', 'sharded_events_json', sipHash64(distinct_id));+CREATE TABLE posthog.writable_events_recent (+ uuid UUID,+ event String,+ properties String CODEC(ZSTD(3)),+ timestamp DateTime64(6, 'UTC'),+ team_id Int64,+ distinct_id String,+ elements_chain String,+ created_at DateTime64(6, 'UTC'),+ person_id UUID,+ person_created_at DateTime64(3),+ person_properties String CODEC(ZSTD(3)),+ group0_properties String CODEC(ZSTD(3)),+ group1_properties String CODEC(ZSTD(3)),+ group2_properties String CODEC(ZSTD(3)),+ group3_properties String CODEC(ZSTD(3)),+ group4_properties String CODEC(ZSTD(3)),+ group0_created_at DateTime64(3),+ group1_created_at DateTime64(3),+ group2_created_at DateTime64(3),+ group3_created_at DateTime64(3),+ group4_created_at DateTime64(3),+ person_mode Enum8('full'=0, 'propertyless'=1, 'force_upgrade'=2),+ historical_migration Bool,+ _timestamp DateTime,+ _offset UInt64+) ENGINE = Distributed('posthog_writable', 'posthog', 'sharded_events_recent', sipHash64(distinct_id));+CREATE TABLE posthog.writable_flag_evaluations (+ uuid UUID,+ event LowCardinality(String),+ properties String,+ timestamp DateTime64(6, 'UTC'),+ team_id Int64,+ distinct_id String,+ created_at DateTime64(6, 'UTC'),+ person_id UUID,+ person_properties String,+ group0_properties String,+ group1_properties String,+ group2_properties String,+ group3_properties String,+ group4_properties String,+ inserted_at DateTime64(6, 'UTC') DEFAULT timestamp,+ _timestamp DateTime,+ _offset UInt64,+ _partition UInt64+) ENGINE = Distributed('posthog', 'posthog', 'sharded_flag_evaluations', sipHash64(distinct_id));+CREATE TABLE posthog.writable_groups (+ group_type_index UInt8,+ group_key String,+ created_at DateTime64(3),+ team_id Int64,+ group_properties String,+ _timestamp DateTime,+ _offset UInt64+) ENGINE = Distributed('posthog_single_shard', 'posthog', 'groups');+CREATE TABLE posthog.writable_heatmaps (+ session_id String,+ team_id Int64,+ distinct_id String,+ timestamp DateTime64(6, 'UTC'),+ x Int16,+ y Int16,+ scale_factor Int16,+ viewport_width Int16,+ viewport_height Int16,+ pointer_target_fixed Bool,+ current_url String,+ type LowCardinality(String),+ _timestamp DateTime,+ _offset UInt64,+ _partition UInt64+) ENGINE = Distributed('posthog', 'posthog', 'sharded_heatmaps', cityHash64(concat(toString(team_id), '-', session_id, '-', toString(toDate(timestamp)))));+CREATE TABLE posthog.writable_ingestion_warnings (+ team_id Int64,+ source LowCardinality(String),+ type String,+ details String CODEC(ZSTD(3)),+ timestamp DateTime64(6, 'UTC'),+ _timestamp DateTime,+ _offset UInt64,+ _partition UInt64+) ENGINE = Distributed('posthog', 'posthog', 'sharded_ingestion_warnings', rand());+CREATE TABLE posthog.writable_log_entries (+ team_id UInt64,+ log_source LowCardinality(String),+ log_source_id String,+ instance_id String,+ timestamp DateTime64(6, 'UTC'),+ level LowCardinality(String),+ message String,+ _timestamp DateTime,+ _offset UInt64+) ENGINE = Distributed('posthog', 'posthog', 'sharded_log_entries', rand());+CREATE TABLE posthog.writable_person (+ id UUID,+ created_at DateTime64(3),+ team_id Int64,+ properties String,+ is_identified Int8,+ is_deleted Int8,+ version UInt64,+ last_seen_at Nullable(DateTime64(3)),+ _timestamp DateTime,+ _offset UInt64+) ENGINE = Distributed('posthog_single_shard', 'posthog', 'person');+CREATE TABLE posthog.writable_person_distinct_id2 (+ team_id Int64,+ distinct_id String,+ person_id UUID,+ is_deleted Int8,+ version Int64,+ _timestamp DateTime,+ _offset UInt64,+ _partition UInt64+) ENGINE = Distributed('posthog_single_shard', 'posthog', 'person_distinct_id2');+CREATE TABLE posthog.writable_person_distinct_id_overrides (+ team_id Int64,+ distinct_id String,+ person_id UUID,+ is_deleted Int8,+ version Int64,+ _timestamp DateTime,+ _offset UInt64,+ _partition UInt64+) ENGINE = Distributed('posthog_single_shard', 'posthog', 'person_distinct_id_overrides');+CREATE TABLE posthog.writable_plugin_log_entries (+ id UUID,+ team_id Int64,+ plugin_id Int64,+ plugin_config_id Int64,+ timestamp DateTime64(6, 'UTC'),+ source String,+ type String,+ message String,+ instance_id UUID,+ _timestamp DateTime,+ _offset UInt64+) ENGINE = Distributed('posthog_single_shard', 'posthog', 'plugin_log_entries');+CREATE TABLE posthog.writable_posthog_document_embeddings (+ team_id Int64,+ product LowCardinality(String),+ document_type LowCardinality(String),+ model_name LowCardinality(String),+ rendering LowCardinality(String),+ document_id String,+ timestamp DateTime64(3, 'UTC'),+ inserted_at DateTime64(3, 'UTC'),+ content String DEFAULT '',+ metadata String DEFAULT '{}',+ embedding Array(Float64),+ _timestamp DateTime,+ _offset UInt64,+ _partition UInt64+) ENGINE = Distributed('posthog', 'posthog', 'partitioned_sharded_posthog_document_embeddings', cityHash64(document_id));+CREATE TABLE posthog.writable_posthog_document_embeddings_buffer (+ team_id Int64,+ product LowCardinality(String),+ document_type LowCardinality(String),+ model_name LowCardinality(String),+ rendering LowCardinality(String),+ document_id String,+ timestamp DateTime64(3, 'UTC'),+ inserted_at DateTime64(3, 'UTC'),+ content String DEFAULT '',+ metadata String DEFAULT '{}',+ embedding Array(Float64),+ _timestamp DateTime,+ _offset UInt64,+ _partition UInt64+) ENGINE = Distributed('posthog', 'posthog', 'sharded_posthog_document_embeddings_buffer', cityHash64(document_id));+CREATE TABLE posthog.writable_posthog_document_embeddings_text_embedding_3_large_3072 (+ team_id Int64,+ product LowCardinality(String),+ document_type LowCardinality(String),+ rendering LowCardinality(String),+ document_id String,+ timestamp DateTime64(3, 'UTC'),+ inserted_at DateTime64(3, 'UTC'),+ content String DEFAULT '',+ metadata String DEFAULT '{}',+ embedding Array(Float64),+ _timestamp DateTime,+ _offset UInt64,+ _partition UInt64+) ENGINE = Distributed('posthog', 'posthog', 'sharded_posthog_document_embeddings_text_embedding_3_large_3072', cityHash64(document_id));+CREATE TABLE posthog.writable_posthog_document_embeddings_text_embedding_3_small_1536 (+ team_id Int64,+ product LowCardinality(String),+ document_type LowCardinality(String),+ rendering LowCardinality(String),+ document_id String,+ timestamp DateTime64(3, 'UTC'),+ inserted_at DateTime64(3, 'UTC'),+ content String DEFAULT '',+ metadata String DEFAULT '{}',+ embedding Array(Float64),+ _timestamp DateTime,+ _offset UInt64,+ _partition UInt64+) ENGINE = Distributed('posthog', 'posthog', 'sharded_posthog_document_embeddings_text_embedding_3_small_1536', cityHash64(document_id));+CREATE TABLE posthog.writable_precalculated_events (+ team_id Int64,+ date Date,+ distinct_id String,+ person_id UUID,+ condition String,+ uuid UUID,+ source String,+ _timestamp DateTime64(6),+ _partition UInt64,+ _offset UInt64+) ENGINE = Distributed('posthog', 'posthog', 'sharded_precalculated_events', sipHash64(distinct_id));+CREATE TABLE posthog.writable_precalculated_person_properties (+ team_id Int64,+ distinct_id String,+ person_id UUID,+ condition String,+ matches Bool,+ source String,+ _timestamp DateTime64(6),+ _offset UInt64+) ENGINE = Distributed('posthog', 'posthog', 'sharded_precalculated_person_properties', sipHash64(distinct_id));+CREATE TABLE posthog.writable_raw_sessions (+ team_id Int64,+ session_id_v7 UInt128,+ distinct_id AggregateFunction(argMax, String, DateTime64(6, 'UTC')),+ min_timestamp SimpleAggregateFunction(min, DateTime64(6, 'UTC')),+ max_timestamp SimpleAggregateFunction(max, DateTime64(6, 'UTC')),+ max_inserted_at SimpleAggregateFunction(max, DateTime64(6, 'UTC')),+ urls SimpleAggregateFunction(groupUniqArrayArray, Array(String)),+ entry_url AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ end_url AggregateFunction(argMax, String, DateTime64(6, 'UTC')),+ last_external_click_url AggregateFunction(argMax, String, DateTime64(6, 'UTC')),+ initial_browser AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_browser_version AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_os AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_os_version AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_device_type AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_viewport_width AggregateFunction(argMin, Int64, DateTime64(6, 'UTC')),+ initial_viewport_height AggregateFunction(argMin, Int64, DateTime64(6, 'UTC')),+ initial_geoip_country_code AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_geoip_subdivision_1_code AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_geoip_subdivision_1_name AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_geoip_subdivision_city_name AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_geoip_time_zone AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_referring_domain AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_utm_source AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_utm_campaign AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_utm_medium AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_utm_term AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_utm_content AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_gclid AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_gad_source AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_gclsrc AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_dclid AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_gbraid AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_wbraid AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_fbclid AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_msclkid AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_twclid AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_li_fat_id AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_mc_cid AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_igshid AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_ttclid AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_epik AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_qclid AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_sccid AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial__kx AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_irclid AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ pageview_count SimpleAggregateFunction(sum, Int64),+ pageview_uniq AggregateFunction(uniq, Nullable(UUID)),+ autocapture_count SimpleAggregateFunction(sum, Int64),+ autocapture_uniq AggregateFunction(uniq, Nullable(UUID)),+ screen_count SimpleAggregateFunction(sum, Int64),+ screen_uniq AggregateFunction(uniq, Nullable(UUID)),+ maybe_has_session_replay SimpleAggregateFunction(max, Bool),+ page_screen_autocapture_uniq_up_to AggregateFunction(uniqUpTo(1), Nullable(UUID)),+ vitals_lcp AggregateFunction(argMin, Nullable(Float64), DateTime64(6, 'UTC'))+) ENGINE = Distributed('posthog', 'posthog', 'sharded_raw_sessions', cityHash64(session_id_v7));+CREATE TABLE posthog.writable_raw_sessions_v3 (+ team_id Int64,+ session_id_v7 UInt128,+ session_timestamp DateTime64(3) DEFAULT fromUnixTimestamp64Milli(toUInt64(bitShiftRight(session_id_v7, 80))),+ distinct_id AggregateFunction(argMax, String, DateTime64(6, 'UTC')),+ distinct_ids AggregateFunction(groupUniqArray, String),+ min_timestamp SimpleAggregateFunction(min, DateTime64(6, 'UTC')),+ max_timestamp SimpleAggregateFunction(max, DateTime64(6, 'UTC')),+ max_inserted_at SimpleAggregateFunction(max, DateTime64(6, 'UTC')),+ urls SimpleAggregateFunction(groupUniqArrayArray(2000), Array(String)),+ entry_url AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC')),+ end_url AggregateFunction(argMax, Nullable(String), DateTime64(6, 'UTC')),+ last_external_click_url AggregateFunction(argMax, Nullable(String), DateTime64(6, 'UTC')),+ browser AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC')),+ browser_version AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC')),+ os AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC')),+ os_version AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC')),+ device_type AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC')),+ viewport_width AggregateFunction(argMin, Nullable(Int64), DateTime64(6, 'UTC')),+ viewport_height AggregateFunction(argMin, Nullable(Int64), DateTime64(6, 'UTC')),+ geoip_country_code AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC')),+ geoip_subdivision_1_code AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC')),+ geoip_subdivision_1_name AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC')),+ geoip_subdivision_city_name AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC')),+ geoip_time_zone AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC')),+ entry_referring_domain AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC')),+ entry_utm_source AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC')),+ entry_utm_campaign AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC')),+ entry_utm_medium AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC')),+ entry_utm_term AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC')),+ entry_utm_content AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC')),+ entry_gclid AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC')),+ entry_gad_source AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC')),+ entry_fbclid AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC')),+ entry_has_gclid AggregateFunction(argMin, Bool, DateTime64(6, 'UTC')),+ entry_has_fbclid AggregateFunction(argMin, Bool, DateTime64(6, 'UTC')),+ entry_ad_ids_map AggregateFunction(argMin, Map(String, String), DateTime64(6, 'UTC')),+ entry_ad_ids_set AggregateFunction(argMin, Array(String), DateTime64(6, 'UTC')),+ entry_channel_type_properties AggregateFunction(argMin, Tuple(Nullable(String), Nullable(String), Nullable(String), Nullable(String), Bool, Bool, Nullable(String)), DateTime64(6, 'UTC')),+ pageview_uniq AggregateFunction(uniqExact, Nullable(UUID)),+ autocapture_uniq AggregateFunction(uniqExact, Nullable(UUID)),+ screen_uniq AggregateFunction(uniqExact, Nullable(UUID)),+ page_screen_uniq_up_to AggregateFunction(uniqUpTo(1), Nullable(UUID)),+ has_autocapture SimpleAggregateFunction(max, Bool),+ flag_values AggregateFunction(groupUniqArrayMap, Map(String, String)),+ flag_keys SimpleAggregateFunction(groupUniqArrayArray, Array(String)),+ event_names SimpleAggregateFunction(groupUniqArrayArray(2000), Array(String)),+ hosts SimpleAggregateFunction(groupUniqArrayArray(100), Array(String)),+ emails SimpleAggregateFunction(groupUniqArrayArray(10), Array(String)),+ has_replay_events SimpleAggregateFunction(max, Bool)+) ENGINE = Distributed('posthog', 'posthog', 'sharded_raw_sessions_v3', cityHash64(session_id_v7));+CREATE TABLE posthog.writable_session_replay_embeddings (+ session_id String,+ team_id Int64,+ embeddings Array(Float32),+ generation_timestamp DateTime64(6, 'UTC') DEFAULT now('UTC'),+ source_type LowCardinality(String),+ input String+) ENGINE = Distributed('posthog', 'posthog', 'sharded_session_replay_embeddings', sipHash64(session_id));+CREATE TABLE posthog.writable_session_replay_events (+ session_id String,+ team_id Int64,+ 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),+ active_milliseconds SimpleAggregateFunction(sum, Int64),+ console_log_count SimpleAggregateFunction(sum, Int64),+ console_warn_count SimpleAggregateFunction(sum, Int64),+ console_error_count SimpleAggregateFunction(sum, Int64),+ size SimpleAggregateFunction(sum, Int64),+ message_count SimpleAggregateFunction(sum, Int64),+ event_count SimpleAggregateFunction(sum, Int64),+ snapshot_source AggregateFunction(argMin, LowCardinality(Nullable(String)), DateTime64(6, 'UTC')),+ snapshot_library AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC')),+ _timestamp SimpleAggregateFunction(max, DateTime),+ 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))+) ENGINE = Distributed('posthog', 'posthog', 'sharded_session_replay_events', sipHash64(distinct_id));+CREATE TABLE posthog.writable_session_replay_features (+ session_id String,+ team_id Int64,+ distinct_id String,+ min_first_timestamp SimpleAggregateFunction(min, DateTime64(6, 'UTC')),+ max_last_timestamp SimpleAggregateFunction(max, DateTime64(6, 'UTC')),+ event_count SimpleAggregateFunction(sum, Int64),+ mouse_position_count SimpleAggregateFunction(sum, Int64),+ mouse_sum_x SimpleAggregateFunction(sum, Float64),+ mouse_sum_x_squared SimpleAggregateFunction(sum, Float64),+ mouse_sum_y SimpleAggregateFunction(sum, Float64),+ mouse_sum_y_squared SimpleAggregateFunction(sum, Float64),+ mouse_distance_traveled SimpleAggregateFunction(sum, Float64),+ mouse_direction_change_count SimpleAggregateFunction(sum, Int64),+ mouse_velocity_sum SimpleAggregateFunction(sum, Float64),+ mouse_velocity_sum_of_squares SimpleAggregateFunction(sum, Float64),+ mouse_velocity_count SimpleAggregateFunction(sum, Int64),+ scroll_event_count SimpleAggregateFunction(sum, Int64),+ total_scroll_magnitude SimpleAggregateFunction(sum, Float64),+ scroll_direction_reversal_count SimpleAggregateFunction(sum, Int64),+ rapid_scroll_reversal_count SimpleAggregateFunction(sum, Int64),+ scroll_to_top_count SimpleAggregateFunction(sum, Int64),+ click_count SimpleAggregateFunction(sum, Int64),+ keypress_count SimpleAggregateFunction(sum, Int64),+ mouse_activity_count SimpleAggregateFunction(sum, Int64),+ rage_click_count SimpleAggregateFunction(sum, Int64),+ dead_click_count SimpleAggregateFunction(sum, Int64),+ backspace_count SimpleAggregateFunction(sum, Int64),+ inter_action_gap_count SimpleAggregateFunction(sum, Int64),+ inter_action_gap_sum_ms SimpleAggregateFunction(sum, Float64),+ inter_action_gap_sum_of_squares_ms SimpleAggregateFunction(sum, Float64),+ max_idle_gap_ms SimpleAggregateFunction(max, Float64),+ long_idle_gap_count SimpleAggregateFunction(sum, Int64),+ quick_back_count SimpleAggregateFunction(sum, Int64),+ page_visit_count SimpleAggregateFunction(sum, Int64),+ unique_url_count AggregateFunction(uniqCombined(12), String),+ login_path_visit_count SimpleAggregateFunction(sum, Int64),+ signup_path_visit_count SimpleAggregateFunction(sum, Int64),+ checkout_path_visit_count SimpleAggregateFunction(sum, Int64),+ cart_path_visit_count SimpleAggregateFunction(sum, Int64),+ billing_path_visit_count SimpleAggregateFunction(sum, Int64),+ settings_path_visit_count SimpleAggregateFunction(sum, Int64),+ account_path_visit_count SimpleAggregateFunction(sum, Int64),+ error_path_visit_count SimpleAggregateFunction(sum, Int64),+ not_found_path_visit_count SimpleAggregateFunction(sum, Int64),+ admin_path_visit_count SimpleAggregateFunction(sum, Int64),+ dashboard_path_visit_count SimpleAggregateFunction(sum, Int64),+ onboarding_path_visit_count SimpleAggregateFunction(sum, Int64),+ cancel_path_visit_count SimpleAggregateFunction(sum, Int64),+ refund_path_visit_count SimpleAggregateFunction(sum, Int64),+ console_error_count SimpleAggregateFunction(sum, Int64),+ console_error_after_click_count SimpleAggregateFunction(sum, Int64),+ console_warn_count SimpleAggregateFunction(sum, Int64),+ network_request_count SimpleAggregateFunction(sum, Int64),+ network_failed_request_count SimpleAggregateFunction(sum, Int64),+ network_4xx_count SimpleAggregateFunction(sum, Int64),+ network_5xx_count SimpleAggregateFunction(sum, Int64),+ network_request_duration_sum SimpleAggregateFunction(sum, Float64),+ network_request_duration_sum_of_squares SimpleAggregateFunction(sum, Float64),+ network_request_duration_count SimpleAggregateFunction(sum, Int64),+ mutation_count SimpleAggregateFunction(sum, Int64),+ viewport_resize_count SimpleAggregateFunction(sum, Int64),+ touch_event_count SimpleAggregateFunction(sum, Int64),+ max_scroll_y SimpleAggregateFunction(max, Float64),+ unique_click_target_count AggregateFunction(uniqCombined(12), Int64),+ unique_form_field_count AggregateFunction(uniqCombined(12), Int64),+ text_selection_count SimpleAggregateFunction(sum, Int64),+ selection_copy_count SimpleAggregateFunction(sum, Int64),+ is_deleted SimpleAggregateFunction(max, UInt8) DEFAULT 0+) ENGINE = Distributed('aux', 'posthog', 'sharded_session_replay_features', sipHash64(session_id));+CREATE TABLE posthog.writable_sessions (+ session_id String,+ team_id Int64,+ distinct_id SimpleAggregateFunction(any, String),+ min_timestamp SimpleAggregateFunction(min, DateTime64(6, 'UTC')),+ max_timestamp SimpleAggregateFunction(max, DateTime64(6, 'UTC')),+ urls SimpleAggregateFunction(groupUniqArrayArray, Array(String)),+ entry_url AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ exit_url AggregateFunction(argMax, String, DateTime64(6, 'UTC')),+ initial_referring_domain AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_utm_source AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_utm_campaign AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_utm_medium AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_utm_term AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_utm_content AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_gclid AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_gad_source AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_gclsrc AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_dclid AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_gbraid AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_wbraid AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_fbclid AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_msclkid AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_twclid AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_li_fat_id AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_mc_cid AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_igshid AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_ttclid AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_epik AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_qclid AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_sccid AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ event_count_map SimpleAggregateFunction(sumMap, Map(String, Int64)),+ pageview_count SimpleAggregateFunction(sum, Int64),+ autocapture_count SimpleAggregateFunction(sum, Int64)+) ENGINE = Distributed('posthog', 'posthog', 'sharded_sessions', sipHash64(session_id));+CREATE TABLE posthog.writable_tophog (+ timestamp DateTime64(6, 'UTC'),+ metric LowCardinality(String),+ type LowCardinality(String) DEFAULT 'sum',+ key Map(LowCardinality(String), String),+ value Float64,+ count UInt64 DEFAULT 0,+ pipeline LowCardinality(String),+ lane LowCardinality(String),+ labels Map(LowCardinality(String), String)+) ENGINE = Distributed('posthog', 'posthog', 'sharded_tophog', cityHash64(toString(key)));+CREATE TABLE posthog.writable_usage_report_events_preagg (+ date Date,+ team_id Int64,+ person_mode LowCardinality(String),+ lib LowCardinality(String),+ event String,+ distinct_events_unique AggregateFunction(uniqExact, Tuple(UInt64, UInt64, UInt64)),+ event_count AggregateFunction(sum, UInt64)+) ENGINE = Distributed('aux', 'posthog', 'sharded_usage_report_events_preagg', sipHash64(date));+CREATE TABLE posthog.writeable_performance_events (+ uuid UUID,+ session_id String,+ window_id String,+ pageview_id String,+ distinct_id String,+ timestamp DateTime64(3),+ time_origin DateTime64(3, 'UTC'),+ entry_type LowCardinality(String),+ name String,+ team_id Int64,+ current_url String,+ start_time Float64,+ duration Float64,+ redirect_start Float64,+ redirect_end Float64,+ worker_start Float64,+ fetch_start Float64,+ domain_lookup_start Float64,+ domain_lookup_end Float64,+ connect_start Float64,+ secure_connection_start Float64,+ connect_end Float64,+ request_start Float64,+ response_start Float64,+ response_end Float64,+ decoded_body_size Int64,+ encoded_body_size Int64,+ initiator_type LowCardinality(String),+ next_hop_protocol LowCardinality(String),+ render_blocking_status LowCardinality(String),+ response_status Int64,+ transfer_size Int64,+ largest_contentful_paint_element String,+ largest_contentful_paint_render_time Float64,+ largest_contentful_paint_load_time Float64,+ largest_contentful_paint_size Float64,+ largest_contentful_paint_id String,+ largest_contentful_paint_url String,+ dom_complete Float64,+ dom_content_loaded_event Float64,+ dom_interactive Float64,+ load_event_end Float64,+ load_event_start Float64,+ redirect_count Int64,+ navigation_type LowCardinality(String),+ unload_event_end Float64,+ unload_event_start Float64,+ _timestamp DateTime,+ _offset UInt64,+ _partition UInt64+) ENGINE = Distributed('posthog', 'posthog', 'sharded_performance_events', sipHash64(session_id));+CREATE MATERIALIZED VIEW posthog.app_metrics2_mv TO posthog.writable_app_metrics2 (team_id Int64, timestamp DateTime64(6, 'UTC'), app_source LowCardinality(String), app_source_id String, instance_id String, metric_kind String, metric_name String, count Int64, _timestamp Nullable(DateTime), _offset UInt64, _partition UInt64) AS SELECT+ team_id,+ timestamp,+ app_source,+ app_source_id,+ instance_id,+ metric_kind,+ metric_name,+ count,+ _timestamp,+ _offset,+ _partition+FROM posthog.kafka_app_metrics2;+CREATE MATERIALIZED VIEW posthog.app_metrics2_ws_mv TO posthog.writable_app_metrics2 (team_id Int64, timestamp DateTime64(6, 'UTC'), app_source LowCardinality(String), app_source_id String, instance_id String, metric_kind String, metric_name String, count Int64, _timestamp Nullable(DateTime), _offset UInt64, _partition UInt64) AS SELECT+ team_id,+ timestamp,+ app_source,+ app_source_id,+ instance_id,+ metric_kind,+ metric_name,+ count,+ _timestamp,+ _offset,+ _partition+FROM posthog.kafka_app_metrics2_ws;+CREATE MATERIALIZED VIEW posthog.app_metrics_mv TO posthog.writable_app_metrics (team_id Int64, timestamp DateTime64(6, 'UTC'), plugin_config_id Int64, category LowCardinality(String), job_id String, successes Int64, successes_on_retry Int64, failures Int64, error_uuid UUID, error_type String, error_details String, _timestamp Nullable(DateTime), _offset UInt64, _partition UInt64) AS SELECT+ team_id,+ timestamp,+ plugin_config_id,+ category,+ job_id,+ successes,+ successes_on_retry,+ failures,+ error_uuid,+ error_type,+ error_details,+ _timestamp,+ _offset,+ _partition+FROM posthog.kafka_app_metrics;+CREATE MATERIALIZED VIEW posthog.cohort_membership_mv TO posthog.writable_cohort_membership (team_id Int64, cohort_id Int64, person_id UUID, status String, last_updated DateTime64(6)) AS SELECT+ team_id,+ cohort_id,+ person_id,+ multiIf(status = 'member', 'entered', status = 'not_member', 'left', status) AS status,+ last_updated+FROM posthog.kafka_cohort_membership;+CREATE MATERIALIZED VIEW posthog.distinct_id_usage_mv TO posthog.writable_distinct_id_usage (team_id Int64, distinct_id String, minute DateTime('UTC'), event_count UInt8) AS SELECT team_id, distinct_id, toStartOfMinute(timestamp) AS minute, 1 AS event_count+FROM posthog.kafka_distinct_id_usage;+CREATE MATERIALIZED VIEW posthog.duplicate_events_mv TO posthog.writable_duplicate_events (team_id Int64, distinct_id String, event String, source_uuid UUID, duplicate_uuid UUID, similarity_score Float64, dedup_type LowCardinality(String), is_confirmed UInt8, reason Nullable(String), version String, different_property_count UInt32, properties_similarity Float64, source_message String, duplicate_message String, distinct_fields Array(Tuple(field_name String, original_value String, new_value String)), inserted_at DateTime64(3, 'UTC'), _timestamp Nullable(DateTime), _offset UInt64, _partition UInt64) AS SELECT+ team_id,+ distinct_id,+ event,+ source_uuid,+ duplicate_uuid,+ similarity_score,+ dedup_type,+ is_confirmed,+ reason,+ version,+ different_property_count,+ properties_similarity,+ source_message,+ duplicate_message,+ JSONExtract(+ distinct_fields,+ 'Array(Tuple(field_name String, original_value String, new_value String))'+ ) AS distinct_fields,+ inserted_at,+ _timestamp,+ _offset,+ _partition+FROM posthog.kafka_duplicate_events;+CREATE MATERIALIZED VIEW posthog.error_tracking_fingerprint_issue_state_mv TO posthog.writable_error_tracking_fingerprint_issue_state (team_id Int64, fingerprint String, issue_id UUID, issue_name Nullable(String), issue_description Nullable(String), issue_status String, issue_severity Nullable(String), assigned_user_id Nullable(Int64), assigned_role_id Nullable(UUID), first_seen DateTime64(3, 'UTC'), is_deleted Int8, version Int64, _timestamp Nullable(DateTime), _offset UInt64, _partition UInt64) AS SELECT+ team_id,+ fingerprint,+ issue_id,+ issue_name,+ issue_description,+ issue_status,+ issue_severity,+ assigned_user_id,+ assigned_role_id,+ first_seen,+ is_deleted,+ version,+ _timestamp,+ _offset,+ _partition+FROM posthog.kafka_error_tracking_fingerprint_issue_state;+CREATE MATERIALIZED VIEW posthog.error_tracking_issue_fingerprint_embeddings_mv TO posthog.writable_error_tracking_issue_fingerprint_embeddings (team_id Int64, model_name LowCardinality(String), embedding_version Int64, fingerprint String, inserted_at Nullable(DateTime), embeddings Array(Float64), _timestamp Nullable(DateTime), _offset UInt64, _partition UInt64) AS SELECT+ team_id,+ model_name,+ embedding_version,+ fingerprint,+ _timestamp AS inserted_at,+ embeddings,+ _timestamp,+ _offset,+ _partition+FROM posthog.kafka_error_tracking_issue_fingerprint_embeddings;+CREATE MATERIALIZED VIEW posthog.error_tracking_issue_fingerprint_overrides_mv TO posthog.writable_error_tracking_issue_fingerprint_overrides (team_id Int64, fingerprint String, issue_id UUID, is_deleted Int8, version Int64, _timestamp Nullable(DateTime), _offset UInt64, _partition UInt64) AS SELECT+ team_id,+ fingerprint,+ issue_id,+ is_deleted,+ version,+ _timestamp,+ _offset,+ _partition+FROM posthog.kafka_error_tracking_issue_fingerprint_overrides+WHERE version > 0;+CREATE MATERIALIZED VIEW posthog.events_dead_letter_queue_mv TO posthog.writable_events_dead_letter_queue (id UUID, event_uuid UUID, event String, properties String, distinct_id String, team_id Int64, elements_chain String, created_at DateTime64(6, 'UTC'), ip String, site_url String, now DateTime64(6, 'UTC'), raw_payload String, error_timestamp DateTime64(6, 'UTC'), error_location String, error String, tags Array(String), _timestamp Nullable(DateTime), _offset UInt64) AS SELECT+ id,+ event_uuid,+ event,+ properties,+ distinct_id,+ team_id,+ elements_chain,+ created_at,+ ip,+ site_url,+ now,+ raw_payload,+ error_timestamp,+ error_location,+ error,+ tags,+ _timestamp,+ _offset+FROM posthog.kafka_events_dead_letter_queue;+CREATE MATERIALIZED VIEW posthog.events_json_mv TO posthog.writable_events (uuid UUID, event String, properties String, timestamp DateTime64(6, 'UTC'), team_id Int64, distinct_id String, elements_chain String, created_at DateTime64(6, 'UTC'), person_id UUID, person_created_at DateTime64(3), person_properties String, group0_properties String, group1_properties String, group2_properties String, group3_properties String, group4_properties String, group0_created_at DateTime64(3), group1_created_at DateTime64(3), group2_created_at DateTime64(3), group3_created_at DateTime64(3), group4_created_at DateTime64(3), person_mode Enum8('full'=0, 'propertyless'=1, 'force_upgrade'=2), historical_migration Bool, dmat_string_0 Nullable(String), dmat_string_1 Nullable(String), dmat_string_2 Nullable(String), dmat_string_3 Nullable(String), dmat_string_4 Nullable(String), dmat_string_5 Nullable(String), dmat_string_6 Nullable(String), dmat_string_7 Nullable(String), dmat_string_8 Nullable(String), dmat_string_9 Nullable(String), _timestamp Nullable(DateTime), _offset UInt64, consumer_breadcrumbs Array(String)) AS SELECT+ uuid,+ event,+ properties,+ timestamp,+ team_id,+ distinct_id,+ elements_chain,+ created_at,+ person_id,+ person_created_at,+ person_properties,+ group0_properties,+ group1_properties,+ group2_properties,+ group3_properties,+ group4_properties,+ group0_created_at,+ group1_created_at,+ group2_created_at,+ group3_created_at,+ group4_created_at,+ person_mode,+ historical_migration,+ dmat_string_0,+ dmat_string_1,+ dmat_string_2,+ dmat_string_3,+ dmat_string_4,+ dmat_string_5,+ dmat_string_6,+ dmat_string_7,+ dmat_string_8,+ dmat_string_9,+ _timestamp,+ _offset,+ arrayMap(+ i -> (_headers.value[i]),+ arrayFilter(+ i -> ((_headers.name[i]) = 'kafka-consumer-breadcrumbs'),+ arrayEnumerate(_headers.name)+ )+ ) AS consumer_breadcrumbs+FROM posthog.kafka_events_json;+CREATE MATERIALIZED VIEW posthog.events_json_table_mv TO posthog.writable_events_json (uuid UUID, event String, properties JSON, timestamp DateTime64(6, 'UTC'), team_id Int64, distinct_id String, elements_chain String, created_at DateTime64(6, 'UTC'), person_id UUID, person_created_at DateTime64(3), person_properties JSON, group0_properties String, group1_properties String, group2_properties String, group3_properties String, group4_properties String, group0_created_at DateTime64(3), group1_created_at DateTime64(3), group2_created_at DateTime64(3), group3_created_at DateTime64(3), group4_created_at DateTime64(3), person_mode Enum8('full'=0, 'propertyless'=1, 'force_upgrade'=2), historical_migration Bool, _timestamp Nullable(DateTime), _offset UInt64, consumer_breadcrumbs Array(String)) AS SELECT+ uuid,+ event,+ ifNull(+ accurateCastOrNull(properties, 'JSON'),+ CAST(concat('{"$unparseable_properties":', toJSONString(properties), '}'), 'JSON')+ ) AS properties,+ timestamp,+ team_id,+ distinct_id,+ elements_chain,+ created_at,+ person_id,+ person_created_at,+ ifNull(+ accurateCastOrNull(person_properties, 'JSON'),+ CAST(concat('{"$unparseable_properties":', toJSONString(person_properties), '}'), 'JSON')+ ) AS person_properties,+ group0_properties,+ group1_properties,+ group2_properties,+ group3_properties,+ group4_properties,+ group0_created_at,+ group1_created_at,+ group2_created_at,+ group3_created_at,+ group4_created_at,+ person_mode,+ historical_migration,+ _timestamp,+ _offset,+ arrayMap(+ i -> (_headers.value[i]),+ arrayFilter(+ i -> ((_headers.name[i]) = 'kafka-consumer-breadcrumbs'),+ arrayEnumerate(_headers.name)+ )+ ) AS consumer_breadcrumbs+FROM posthog.kafka_events_json_native_json;+CREATE MATERIALIZED VIEW posthog.events_recent_json_mv TO posthog.writable_events_recent (uuid UUID, event String, properties String, timestamp DateTime64(6, 'UTC'), team_id Int64, distinct_id String, elements_chain String, created_at DateTime64(6, 'UTC'), person_id UUID, person_created_at DateTime64(3), person_properties String, group0_properties String, group1_properties String, group2_properties String, group3_properties String, group4_properties String, group0_created_at DateTime64(3), group1_created_at DateTime64(3), group2_created_at DateTime64(3), group3_created_at DateTime64(3), group4_created_at DateTime64(3), person_mode Enum8('full'=0, 'propertyless'=1, 'force_upgrade'=2), _timestamp DateTime, _offset UInt64) AS SELECT+ uuid,+ event,+ properties,+ timestamp,+ team_id,+ distinct_id,+ elements_chain,+ created_at,+ person_id,+ person_created_at,+ person_properties,+ group0_properties,+ group1_properties,+ group2_properties,+ group3_properties,+ group4_properties,+ group0_created_at,+ group1_created_at,+ group2_created_at,+ group3_created_at,+ group4_created_at,+ person_mode,+ _timestamp,+ _offset+FROM posthog.sharded_events;+CREATE MATERIALIZED VIEW posthog.flag_evaluations_mv TO posthog.writable_flag_evaluations (uuid UUID, event LowCardinality(String), properties String, timestamp DateTime64(6, 'UTC'), team_id Int64, distinct_id String, created_at DateTime64(6, 'UTC'), person_id UUID, person_properties String, group0_properties String, group1_properties String, group2_properties String, group3_properties String, group4_properties String, inserted_at Nullable(DateTime64(6, 'UTC')), _timestamp Nullable(DateTime), _offset UInt64, _partition UInt64) AS SELECT+ uuid,+ event,+ properties,+ timestamp,+ team_id,+ distinct_id,+ created_at,+ person_id,+ person_properties,+ group0_properties,+ group1_properties,+ group2_properties,+ group3_properties,+ group4_properties,+ if(inserted_at = toDateTime64('1970-01-01 00:00:00', 6, 'UTC'), _timestamp, inserted_at) AS inserted_at,+ _timestamp,+ _offset,+ _partition+FROM posthog.kafka_flag_evaluations;+CREATE MATERIALIZED VIEW posthog.groups_mv TO posthog.writable_groups (group_type_index UInt8, group_key String, created_at DateTime64(3), team_id Int64, group_properties String, _timestamp Nullable(DateTime), _offset UInt64) AS SELECT+ group_type_index,+ group_key,+ created_at,+ team_id,+ group_properties,+ _timestamp,+ _offset+FROM posthog.kafka_groups;+CREATE MATERIALIZED VIEW posthog.heatmaps_mv TO posthog.writable_heatmaps (session_id String, team_id Int64, distinct_id String, timestamp DateTime64(6, 'UTC'), x Int16, y Int16, scale_factor Int16, viewport_width Int16, viewport_height Int16, pointer_target_fixed Bool, current_url String, type LowCardinality(String), _timestamp Nullable(DateTime), _offset UInt64, _partition UInt64) AS SELECT+ session_id,+ team_id,+ distinct_id,+ timestamp,+ x,+ y,+ scale_factor,+ viewport_width,+ viewport_height,+ pointer_target_fixed,+ current_url,+ type,+ _timestamp,+ _offset,+ _partition+FROM posthog.kafka_heatmaps;+CREATE MATERIALIZED VIEW posthog.hog_invocation_results_mv TO posthog.hog_invocation_results_data (team_id Int64, function_kind LowCardinality(String), function_id String, invocation_id String, parent_run_id String, status LowCardinality(String), attempts UInt8, is_retry UInt8, scheduled_at DateTime64(6, 'UTC'), first_scheduled_at DateTime64(6, 'UTC'), started_at Nullable(DateTime64(6, 'UTC')), finished_at Nullable(DateTime64(6, 'UTC')), duration_ms Nullable(UInt32), error_kind LowCardinality(String), error_message String, event_uuid String, distinct_id String, person_id String, invocation_globals String, version UInt64, is_deleted UInt8, _timestamp Nullable(DateTime), _offset UInt64, _partition UInt64) AS SELECT+ team_id,+ function_kind,+ function_id,+ invocation_id,+ parent_run_id,+ status,+ attempts,+ is_retry,+ scheduled_at,+ if(+ first_scheduled_at = toDateTime64('1970-01-01 00:00:00', 6, 'UTC'),+ scheduled_at,+ first_scheduled_at+ ) AS first_scheduled_at,+ started_at,+ finished_at,+ duration_ms,+ error_kind,+ error_message,+ event_uuid,+ distinct_id,+ person_id,+ invocation_globals,+ version,+ is_deleted,+ _timestamp,+ _offset,+ _partition+FROM posthog.kafka_hog_invocation_results;+CREATE MATERIALIZED VIEW posthog.ingestion_warnings_mv TO posthog.writable_ingestion_warnings (team_id Int64, source LowCardinality(String), type String, details String, timestamp DateTime64(6, 'UTC'), _timestamp Nullable(DateTime), _offset UInt64, _partition UInt64) AS SELECT+ team_id,+ source,+ type,+ details,+ timestamp,+ _timestamp,+ _offset,+ _partition+FROM posthog.kafka_ingestion_warnings;+CREATE MATERIALIZED VIEW posthog.ingestion_warnings_v2_mv TO posthog.ingestion_warnings_v2 (team_id Int64, source LowCardinality(String), type String, details String, timestamp DateTime64(6, 'UTC'), _timestamp Nullable(DateTime), _offset UInt64, _partition UInt64) AS SELECT+ team_id,+ source,+ type,+ details,+ timestamp,+ _timestamp,+ _offset,+ _partition+FROM posthog.kafka_ingestion_warnings_v2;+CREATE MATERIALIZED VIEW posthog.kafka_logs34_avro_mv TO posthog.logs34 (uuid String, trace_id String, span_id String, trace_flags Int32, timestamp DateTime64(6), observed_timestamp DateTime64(6), body String, severity_text String, severity_number Int32, service_name String, instrumentation_scope String, event_name String, attributes_map_str Map(String, String), resource_attributes Map(String, String), team_id Int32, original_expiry_timestamp DateTime64(6), _partition UInt64, _topic LowCardinality(String), _offset UInt64, _record_count Int64, _bytes_uncompressed Nullable(Int64), _bytes_compressed Nullable(Int64)) AS SELECT+ uuid,+ trace_id,+ span_id,+ trace_flags,+ timestamp,+ observed_timestamp,+ body,+ severity_text,+ severity_number,+ service_name,+ instrumentation_scope,+ event_name,+ mapSort(mapApply((k, v) -> (concat(k, '__str'), JSONExtractString(v)), attributes)) AS attributes_map_str,+ mapSort(mapApply((k, v) -> (k, JSONExtractString(v)), resource_attributes)) AS resource_attributes,+ toInt32OrZero(_headers.value[indexOf(_headers.name, 'team_id')]) AS team_id,+ observed_timestamp+ + toIntervalDay(+ toInt32OrDefault(_headers.value[indexOf(_headers.name, 'retention-days')], toInt32(15))+ ) AS original_expiry_timestamp,+ _partition,+ _topic,+ _offset,+ toInt64OrDefault(_headers.value[indexOf(_headers.name, 'record_count')], toInt64(1)) AS _record_count,+ toInt64OrNull(_headers.value[indexOf(_headers.name, 'bytes_uncompressed')]) / _record_count AS _bytes_uncompressed,+ toInt64OrNull(_headers.value[indexOf(_headers.name, 'bytes_compressed')]) / _record_count AS _bytes_compressed+FROM posthog.kafka_logs_avro;+CREATE MATERIALIZED VIEW posthog.kafka_logs_avro_billing_metrics_mv TO posthog.logs_billing_metrics (team_id Int32, time_bucket DateTime, service_name LowCardinality(String), bytes_uncompressed SimpleAggregateFunction(sum, Float64), bytes_compressed SimpleAggregateFunction(sum, Float64), record_count SimpleAggregateFunction(sum, UInt64)) AS SELECT+ team_id,+ time_bucket,+ service_name,+ sumSimpleState(_bytes_uncompressed) AS bytes_uncompressed,+ sumSimpleState(_bytes_compressed) AS bytes_compressed,+ sumSimpleState(1) AS record_count+FROM+ (+ SELECT+ team_id,+ toStartOfInterval(timestamp, toIntervalMinute(1)) AS time_bucket,+ service_name AS service_name,+ _bytes_uncompressed,+ _bytes_compressed+ FROM posthog.logs34+ )+GROUP BY+ team_id, time_bucket, service_name;+CREATE MATERIALIZED VIEW posthog.kafka_logs_avro_kafka_metrics_mv TO posthog.logs_kafka_metrics (_partition UInt32, _topic String, max_offset SimpleAggregateFunction(max, UInt64), max_observed_timestamp SimpleAggregateFunction(max, DateTime64(6)), max_timestamp SimpleAggregateFunction(max, DateTime64(6)), max_created_at SimpleAggregateFunction(max, DateTime), max_lag SimpleAggregateFunction(max, Decimal(18, 6))) AS SELECT+ _partition,+ _topic,+ maxSimpleState(_offset) AS max_offset,+ maxSimpleState(observed_timestamp) AS max_observed_timestamp,+ maxSimpleState(timestamp) AS max_timestamp,+ maxSimpleState(now()) AS max_created_at,+ maxSimpleState(now() - observed_timestamp) AS max_lag+FROM posthog.logs34+GROUP BY+ _partition, _topic;+CREATE MATERIALIZED VIEW posthog.kafka_trace_spans_avro_mv TO posthog.trace_spans (uuid String, trace_id String, span_id String, parent_span_id String, trace_state String, name String, kind Int8, flags UInt32, timestamp DateTime64(6), end_time DateTime64(6), observed_timestamp DateTime64(6), service_name String, resource_attributes Map(LowCardinality(String), String), instrumentation_scope String, attributes_map_str Map(LowCardinality(String), String), dropped_attributes_count UInt32, events Array(String), dropped_events_count UInt32, links Array(String), dropped_links_count UInt32, status_code Int16, team_id Int32, original_expiry_timestamp DateTime64(6)) AS SELECT+ * EXCEPT(attributes, resource_attributes, kind, flags, dropped_attributes_count, dropped_events_count, dropped_links_count, status_code),+ toInt8(kind) AS kind,+ toUInt32(flags) AS flags,+ toUInt32(dropped_attributes_count) AS dropped_attributes_count,+ toUInt32(dropped_events_count) AS dropped_events_count,+ toUInt32(dropped_links_count) AS dropped_links_count,+ toInt16(status_code) AS status_code,+ mapSort(mapApply((k, v) -> (concat(k, '__str'), JSONExtractString(v)), attributes)) AS attributes_map_str,+ mapSort(mapApply((k, v) -> (k, JSONExtractString(v)), resource_attributes)) AS resource_attributes,+ toInt32OrZero(_headers.value[indexOf(_headers.name, 'team_id')]) AS team_id,+ observed_timestamp+ + toIntervalDay(+ toInt32OrDefault(_headers.value[indexOf(_headers.name, 'retention-days')], toInt32(15))+ ) AS original_expiry_timestamp,+ _partition,+ _topic,+ _offset,+ toInt64OrDefault(_headers.value[indexOf(_headers.name, 'record_count')], toInt64(1)) AS _record_count,+ toInt64OrDefault(_headers.value[indexOf(_headers.name, 'bytes_uncompressed')], toInt64(0)) AS _bytes_uncompressed,+ toInt64OrDefault(_headers.value[indexOf(_headers.name, 'bytes_compressed')], toInt64(0)) AS _bytes_compressed+FROM posthog.kafka_trace_spans_avro;+CREATE MATERIALIZED VIEW posthog.log_entries_v3_mv TO posthog.writable_log_entries (team_id UInt64, log_source LowCardinality(String), log_source_id String, instance_id String, timestamp DateTime64(6, 'UTC'), level LowCardinality(String), message String, _timestamp Nullable(DateTime), _offset UInt64) AS SELECT+ team_id,+ log_source,+ log_source_id,+ instance_id,+ timestamp,+ level,+ message,+ _timestamp,+ _offset+FROM posthog.kafka_log_entries_v3+WHERE toDate(timestamp) <= today();+CREATE MATERIALIZED VIEW posthog.log_entries_ws_mv TO posthog.writable_log_entries (team_id UInt64, log_source LowCardinality(String), log_source_id String, instance_id String, timestamp DateTime64(6, 'UTC'), level LowCardinality(String), message String, _timestamp Nullable(DateTime), _offset UInt64) AS SELECT+ team_id,+ log_source,+ log_source_id,+ instance_id,+ timestamp,+ level,+ message,+ _timestamp,+ _offset+FROM posthog.kafka_log_entries_ws+WHERE toDate(timestamp) <= today();+CREATE MATERIALIZED VIEW posthog.logs32_to_log_attributes TO posthog.log_attributes (team_id Int32, time_bucket DateTime64(0), original_expiry_time_bucket DateTime64(0), service_name LowCardinality(String), resource_fingerprint UInt64, attribute_key LowCardinality(String), attribute_value String, attribute_type LowCardinality(String), attribute_count SimpleAggregateFunction(sum, UInt64)) AS SELECT+ team_id,+ time_bucket,+ original_expiry_time_bucket,+ service_name,+ resource_fingerprint,+ attribute_key,+ attribute_value,+ attribute_type,+ attribute_count+FROM+ (+ SELECT+ team_id AS team_id,+ toStartOfInterval(timestamp, toIntervalMinute(10)) AS time_bucket,+ toStartOfInterval(original_expiry_timestamp, toIntervalMinute(10)) AS original_expiry_time_bucket,+ service_name AS service_name,+ resource_fingerprint,+ mapFilter((k, v) -> ((length(k) < 256) AND (length(v) < 256)), attributes) AS attributes,+ arrayJoin(attributes) AS attribute,+ 'log' AS attribute_type,+ attribute.1 AS attribute_key,+ attribute.2 AS attribute_value,+ sumSimpleState(1) AS attribute_count+ FROM posthog.logs32+ GROUP BY+ team_id, time_bucket, original_expiry_time_bucket, service_name, resource_fingerprint, attributes+ );+CREATE MATERIALIZED VIEW posthog.logs32_to_resource_attributes TO posthog.log_attributes (team_id Int32, time_bucket DateTime64(0), original_expiry_time_bucket DateTime64(0), service_name LowCardinality(String), resource_fingerprint UInt64, attribute_key LowCardinality(String), attribute_value String, attribute_type LowCardinality(String), attribute_count SimpleAggregateFunction(sum, UInt64)) AS SELECT+ team_id,+ time_bucket,+ original_expiry_time_bucket,+ service_name,+ resource_fingerprint,+ attribute_key,+ attribute_value,+ attribute_type,+ attribute_count+FROM+ (+ SELECT+ team_id AS team_id,+ toStartOfInterval(timestamp, toIntervalMinute(10)) AS time_bucket,+ toStartOfInterval(original_expiry_timestamp, toIntervalMinute(10)) AS original_expiry_time_bucket,+ service_name AS service_name,+ resource_fingerprint,+ arrayJoin(resource_attributes) AS attribute,+ 'resource' AS attribute_type,+ attribute.1 AS attribute_key,+ attribute.2 AS attribute_value,+ sumSimpleState(1) AS attribute_count+ FROM posthog.logs32+ GROUP BY+ team_id, time_bucket, original_expiry_time_bucket, service_name, resource_fingerprint, resource_attributes+ );+CREATE MATERIALIZED VIEW posthog.logs34_to_log_attributes TO posthog.log_attributes2 (team_id Int32, time_bucket DateTime64(0), original_expiry_time_bucket DateTime64(0), service_name LowCardinality(String), resource_fingerprint UInt64, attribute_key LowCardinality(String), attribute_value String, attribute_type LowCardinality(String), attribute_count SimpleAggregateFunction(sum, UInt64)) AS SELECT+ team_id,+ time_bucket,+ original_expiry_time_bucket,+ service_name,+ resource_fingerprint,+ attribute_key,+ attribute_value,+ attribute_type,+ attribute_count+FROM+ (+ SELECT+ team_id AS team_id,+ toStartOfInterval(timestamp, toIntervalMinute(10)) AS time_bucket,+ toStartOfInterval(original_expiry_timestamp, toIntervalMinute(10)) AS original_expiry_time_bucket,+ service_name AS service_name,+ resource_fingerprint,+ mapFilter((k, v) -> ((length(k) < 256) AND (length(v) < 256)), attributes) AS attributes,+ arrayJoin(attributes) AS attribute,+ 'log' AS attribute_type,+ attribute.1 AS attribute_key,+ attribute.2 AS attribute_value,+ sumSimpleState(1) AS attribute_count+ FROM posthog.logs34+ GROUP BY+ team_id, time_bucket, original_expiry_time_bucket, service_name, resource_fingerprint, attributes+ );+CREATE MATERIALIZED VIEW posthog.logs34_to_log_attributes3 TO posthog.log_attributes3 (team_id Int32, time_bucket DateTime64(0), original_expiry_time_bucket DateTime64(0), service_name LowCardinality(String), resource_fingerprint UInt64, attribute_key LowCardinality(String), attribute_value String, attribute_type LowCardinality(String), severity_text LowCardinality(String), attribute_count SimpleAggregateFunction(sum, UInt64)) AS SELECT+ team_id,+ time_bucket,+ original_expiry_time_bucket,+ service_name,+ resource_fingerprint,+ attribute_key,+ attribute_value,+ attribute_type,+ severity_text,+ attribute_count+FROM+ (+ SELECT+ team_id AS team_id,+ toStartOfInterval(timestamp, toIntervalMinute(10)) AS time_bucket,+ toStartOfInterval(original_expiry_timestamp, toIntervalMinute(10)) AS original_expiry_time_bucket,+ service_name AS service_name,+ resource_fingerprint,+ severity_text AS severity_text,+ mapFilter((k, v) -> ((length(k) < 256) AND (length(v) < 256)), attributes) AS attributes,+ arrayJoin(attributes) AS attribute,+ 'log' AS attribute_type,+ attribute.1 AS attribute_key,+ attribute.2 AS attribute_value,+ sumSimpleState(1) AS attribute_count+ FROM posthog.logs34+ GROUP BY+ team_id, time_bucket, original_expiry_time_bucket, service_name, resource_fingerprint, severity_text, attributes+ );+CREATE MATERIALIZED VIEW posthog.logs34_to_resource_attributes TO posthog.log_attributes2 (team_id Int32, time_bucket DateTime64(0), original_expiry_time_bucket DateTime64(0), service_name LowCardinality(String), resource_fingerprint UInt64, attribute_key LowCardinality(String), attribute_value String, attribute_type LowCardinality(String), attribute_count SimpleAggregateFunction(sum, UInt64)) AS SELECT+ team_id,+ time_bucket,+ original_expiry_time_bucket,+ service_name,+ resource_fingerprint,+ attribute_key,+ attribute_value,+ attribute_type,+ attribute_count+FROM+ (+ SELECT+ team_id AS team_id,+ toStartOfInterval(timestamp, toIntervalMinute(10)) AS time_bucket,+ toStartOfInterval(original_expiry_timestamp, toIntervalMinute(10)) AS original_expiry_time_bucket,+ service_name AS service_name,+ resource_fingerprint,+ arrayJoin(resource_attributes) AS attribute,+ 'resource' AS attribute_type,+ attribute.1 AS attribute_key,+ attribute.2 AS attribute_value,+ sumSimpleState(1) AS attribute_count+ FROM posthog.logs34+ GROUP BY+ team_id, time_bucket, original_expiry_time_bucket, service_name, resource_fingerprint, resource_attributes+ );+CREATE MATERIALIZED VIEW posthog.logs34_to_resource_attributes3 TO posthog.log_attributes3 (team_id Int32, time_bucket DateTime64(0), original_expiry_time_bucket DateTime64(0), service_name LowCardinality(String), resource_fingerprint UInt64, attribute_key LowCardinality(String), attribute_value String, attribute_type LowCardinality(String), severity_text LowCardinality(String), attribute_count SimpleAggregateFunction(sum, UInt64)) AS SELECT+ team_id,+ time_bucket,+ original_expiry_time_bucket,+ service_name,+ resource_fingerprint,+ attribute_key,+ attribute_value,+ attribute_type,+ severity_text,+ attribute_count+FROM+ (+ SELECT+ team_id AS team_id,+ toStartOfInterval(timestamp, toIntervalMinute(10)) AS time_bucket,+ toStartOfInterval(original_expiry_timestamp, toIntervalMinute(10)) AS original_expiry_time_bucket,+ service_name AS service_name,+ resource_fingerprint,+ severity_text AS severity_text,+ arrayJoin(resource_attributes) AS attribute,+ 'resource' AS attribute_type,+ attribute.1 AS attribute_key,+ attribute.2 AS attribute_value,+ sumSimpleState(1) AS attribute_count+ FROM posthog.logs34+ GROUP BY+ team_id, time_bucket, original_expiry_time_bucket, service_name, resource_fingerprint, severity_text, resource_attributes+ );+CREATE MATERIALIZED VIEW posthog.message_assets_mv TO posthog.message_assets_data (team_id Int64, function_kind LowCardinality(String), function_id String, parent_run_id String, invocation_id String, action_id String, kind LowCardinality(String), distinct_id String, person_id String, recipient String, subject String, status LowCardinality(String), sent_at DateTime64(6, 'UTC'), version UInt64, is_deleted UInt8, html String, _timestamp Nullable(DateTime), _offset UInt64, _partition UInt64) AS SELECT+ team_id,+ function_kind,+ function_id,+ parent_run_id,+ invocation_id,+ action_id,+ kind,+ distinct_id,+ person_id,+ recipient,+ subject,+ status,+ sent_at,+ version,+ is_deleted,+ html,+ _timestamp,+ _offset,+ _partition+FROM posthog.kafka_message_assets;+CREATE MATERIALIZED VIEW posthog.performance_events_mv TO posthog.writeable_performance_events (uuid UUID, session_id String, window_id String, pageview_id String, distinct_id String, timestamp DateTime64(3), time_origin DateTime64(3, 'UTC'), entry_type LowCardinality(String), name String, team_id Int64, current_url String, start_time Float64, duration Float64, redirect_start Float64, redirect_end Float64, worker_start Float64, fetch_start Float64, domain_lookup_start Float64, domain_lookup_end Float64, connect_start Float64, secure_connection_start Float64, connect_end Float64, request_start Float64, response_start Float64, response_end Float64, decoded_body_size Int64, encoded_body_size Int64, initiator_type LowCardinality(String), next_hop_protocol LowCardinality(String), render_blocking_status LowCardinality(String), response_status Int64, transfer_size Int64, largest_contentful_paint_element String, largest_contentful_paint_render_time Float64, largest_contentful_paint_load_time Float64, largest_contentful_paint_size Float64, largest_contentful_paint_id String, largest_contentful_paint_url String, dom_complete Float64, dom_content_loaded_event Float64, dom_interactive Float64, load_event_end Float64, load_event_start Float64, redirect_count Int64, navigation_type LowCardinality(String), unload_event_end Float64, unload_event_start Float64, _timestamp Nullable(DateTime), _offset UInt64, _partition UInt64) AS SELECT+ uuid,+ session_id,+ window_id,+ pageview_id,+ distinct_id,+ timestamp,+ time_origin,+ entry_type,+ name,+ team_id,+ current_url,+ start_time,+ duration,+ redirect_start,+ redirect_end,+ worker_start,+ fetch_start,+ domain_lookup_start,+ domain_lookup_end,+ connect_start,+ secure_connection_start,+ connect_end,+ request_start,+ response_start,+ response_end,+ decoded_body_size,+ encoded_body_size,+ initiator_type,+ next_hop_protocol,+ render_blocking_status,+ response_status,+ transfer_size,+ largest_contentful_paint_element,+ largest_contentful_paint_render_time,+ largest_contentful_paint_load_time,+ largest_contentful_paint_size,+ largest_contentful_paint_id,+ largest_contentful_paint_url,+ dom_complete,+ dom_content_loaded_event,+ dom_interactive,+ load_event_end,+ load_event_start,+ redirect_count,+ navigation_type,+ unload_event_end,+ unload_event_start,+ _timestamp,+ _offset,+ _partition+FROM posthog.kafka_performance_events;+CREATE MATERIALIZED VIEW posthog.person_distinct_id2_mv TO posthog.writable_person_distinct_id2 (team_id Int64, distinct_id String, person_id UUID, is_deleted Int8, version Int64, _timestamp Nullable(DateTime), _offset UInt64, _partition UInt64) AS SELECT+ team_id,+ distinct_id,+ person_id,+ is_deleted,+ version,+ _timestamp,+ _offset,+ _partition+FROM posthog.kafka_person_distinct_id2;+CREATE MATERIALIZED VIEW posthog.person_distinct_id_mv TO posthog.person_distinct_id (distinct_id String, person_id UUID, team_id Int64, _sign Int16, _timestamp Nullable(DateTime), _offset UInt64) AS SELECT+ distinct_id,+ person_id,+ team_id,+ coalesce(_sign, if(is_deleted = 0, 1, -1)) AS _sign,+ _timestamp,+ _offset+FROM posthog.kafka_person_distinct_id;+CREATE MATERIALIZED VIEW posthog.person_distinct_id_overrides_mv TO posthog.writable_person_distinct_id_overrides (team_id Int64, distinct_id String, person_id UUID, is_deleted Int8, version Int64, _timestamp Nullable(DateTime), _offset UInt64, _partition UInt64) AS SELECT+ team_id,+ distinct_id,+ person_id,+ is_deleted,+ version,+ _timestamp,+ _offset,+ _partition+FROM posthog.kafka_person_distinct_id_overrides+WHERE version > 0;+CREATE MATERIALIZED VIEW posthog.person_mv TO posthog.writable_person (id UUID, created_at DateTime64(3), team_id Int64, properties String, is_identified Int8, is_deleted Int8, version UInt64, last_seen_at Nullable(DateTime64(3)), _timestamp Nullable(DateTime), _offset UInt64) AS SELECT+ id,+ created_at,+ team_id,+ properties,+ is_identified,+ is_deleted,+ version,+ last_seen_at,+ _timestamp,+ _offset+FROM posthog.kafka_person;+CREATE MATERIALIZED VIEW posthog.person_overrides_mv TO posthog.person_overrides (team_id Int32, old_person_id UUID, override_person_id UUID, merged_at DateTime64(6, 'UTC'), oldest_event DateTime64(6, 'UTC'), version Int32) AS SELECT team_id, old_person_id, override_person_id, merged_at, oldest_event, version+FROM posthog.kafka_person_overrides;+CREATE MATERIALIZED VIEW posthog.plugin_log_entries_mv TO posthog.writable_plugin_log_entries (id UUID, team_id Int64, plugin_id Int64, plugin_config_id Int64, timestamp DateTime64(6, 'UTC'), source String, type String, message String, instance_id UUID, _timestamp Nullable(DateTime), _offset UInt64) AS SELECT+ id,+ team_id,+ plugin_id,+ plugin_config_id,+ timestamp,+ source,+ type,+ message,+ instance_id,+ _timestamp,+ _offset+FROM posthog.kafka_plugin_log_entries;+CREATE MATERIALIZED VIEW posthog.posthog_document_embeddings_kafka_to_buffer_mv TO posthog.writable_posthog_document_embeddings_buffer (team_id Int64, product LowCardinality(String), document_type LowCardinality(String), model_name LowCardinality(String), rendering LowCardinality(String), document_id String, timestamp DateTime64(3, 'UTC'), inserted_at Nullable(DateTime), content String, metadata String, embedding Array(Float64), _timestamp Nullable(DateTime), _offset UInt64, _partition UInt64) AS SELECT+ team_id,+ product,+ document_type,+ model_name,+ rendering,+ document_id,+ timestamp,+ _timestamp AS inserted_at,+ coalesce(content, '') AS content,+ coalesce(metadata, '{}') AS metadata,+ embedding,+ _timestamp,+ _offset,+ _partition+FROM posthog.kafka_posthog_document_embeddings;+CREATE MATERIALIZED VIEW posthog.posthog_document_embeddings_text_embedding_3_large_3072_mv TO posthog.writable_posthog_document_embeddings_text_embedding_3_large_3072 (team_id Int64, product LowCardinality(String), document_type LowCardinality(String), rendering LowCardinality(String), document_id String, timestamp DateTime64(3, 'UTC'), inserted_at DateTime64(3, 'UTC'), content String, metadata String, embedding Array(Float64), _timestamp DateTime, _offset UInt64, _partition UInt64) AS SELECT+ team_id,+ product,+ document_type,+ rendering,+ document_id,+ timestamp,+ inserted_at,+ content,+ metadata,+ embedding,+ _timestamp,+ _offset,+ _partition+FROM posthog.sharded_posthog_document_embeddings_buffer+WHERE model_name = 'text-embedding-3-large-3072';+CREATE MATERIALIZED VIEW posthog.posthog_document_embeddings_text_embedding_3_small_1536_mv TO posthog.writable_posthog_document_embeddings_text_embedding_3_small_1536 (team_id Int64, product LowCardinality(String), document_type LowCardinality(String), rendering LowCardinality(String), document_id String, timestamp DateTime64(3, 'UTC'), inserted_at DateTime64(3, 'UTC'), content String, metadata String, embedding Array(Float64), _timestamp DateTime, _offset UInt64, _partition UInt64) AS SELECT+ team_id,+ product,+ document_type,+ rendering,+ document_id,+ timestamp,+ inserted_at,+ content,+ metadata,+ embedding,+ _timestamp,+ _offset,+ _partition+FROM posthog.sharded_posthog_document_embeddings_buffer+WHERE model_name = 'text-embedding-3-small-1536';+CREATE MATERIALIZED VIEW posthog.precalculated_events_mv TO posthog.writable_precalculated_events (team_id Int64, date Nullable(Date), distinct_id String, person_id UUID, condition String, uuid UUID, source String, _timestamp Nullable(DateTime), _offset UInt64, _partition UInt64) AS SELECT+ team_id,+ ifNull(date, toDate(_timestamp)) AS date,+ distinct_id,+ person_id,+ condition,+ uuid,+ source,+ _timestamp,+ _offset,+ _partition+FROM posthog.kafka_precalculated_events;+CREATE MATERIALIZED VIEW posthog.precalculated_person_properties_mv TO posthog.writable_precalculated_person_properties (team_id Int64, distinct_id String, person_id UUID, condition String, matches Bool, source String, _timestamp Nullable(DateTime), _offset UInt64) AS SELECT+ team_id,+ distinct_id,+ person_id,+ condition,+ matches,+ source,+ _timestamp,+ _offset+FROM posthog.kafka_precalculated_person_properties;+CREATE MATERIALIZED VIEW posthog.precalculated_person_properties_ws_mv TO posthog.writable_precalculated_person_properties (team_id Int64, distinct_id String, person_id UUID, condition String, matches Bool, source String, _timestamp Nullable(DateTime), _offset UInt64) AS SELECT+ team_id,+ distinct_id,+ person_id,+ condition,+ matches,+ source,+ _timestamp,+ _offset+FROM posthog.kafka_precalculated_person_properties_ws;+CREATE MATERIALIZED VIEW posthog.property_values_mv TO posthog.property_values (team_id Int64, property_type LowCardinality(String), property_key String, property_value String, property_count UInt64, last_seen DateTime) AS SELECT+ team_id,+ property_type,+ property_key,+ property_value,+ property_count,+ coalesce(_timestamp, now()) AS last_seen+FROM posthog.kafka_property_values;+CREATE MATERIALIZED VIEW posthog.raw_sessions_mv TO posthog.writable_raw_sessions (team_id Int64, session_id_v7 UInt128, distinct_id AggregateFunction(argMax, String, DateTime64(6, 'UTC')), min_timestamp DateTime64(6, 'UTC'), max_timestamp DateTime64(6, 'UTC'), max_inserted_at DateTime64(6, 'UTC'), urls Array(String), entry_url AggregateFunction(argMin, String, DateTime64(6, 'UTC')), end_url AggregateFunction(argMax, String, DateTime64(6, 'UTC')), last_external_click_url AggregateFunction(argMax, String, DateTime64(6, 'UTC')), initial_browser AggregateFunction(argMin, String, DateTime64(6, 'UTC')), initial_browser_version AggregateFunction(argMin, String, DateTime64(6, 'UTC')), initial_os AggregateFunction(argMin, String, DateTime64(6, 'UTC')), initial_os_version AggregateFunction(argMin, String, DateTime64(6, 'UTC')), initial_device_type AggregateFunction(argMin, String, DateTime64(6, 'UTC')), initial_viewport_width AggregateFunction(argMin, Int64, DateTime64(6, 'UTC')), initial_viewport_height AggregateFunction(argMin, Int64, DateTime64(6, 'UTC')), initial_geoip_country_code AggregateFunction(argMin, String, DateTime64(6, 'UTC')), initial_geoip_subdivision_1_code AggregateFunction(argMin, String, DateTime64(6, 'UTC')), initial_geoip_subdivision_1_name AggregateFunction(argMin, String, DateTime64(6, 'UTC')), initial_geoip_subdivision_city_name AggregateFunction(argMin, String, DateTime64(6, 'UTC')), initial_geoip_time_zone AggregateFunction(argMin, String, DateTime64(6, 'UTC')), initial_referring_domain AggregateFunction(argMin, String, DateTime64(6, 'UTC')), initial_utm_source AggregateFunction(argMin, String, DateTime64(6, 'UTC')), initial_utm_campaign AggregateFunction(argMin, String, DateTime64(6, 'UTC')), initial_utm_medium AggregateFunction(argMin, String, DateTime64(6, 'UTC')), initial_utm_term AggregateFunction(argMin, String, DateTime64(6, 'UTC')), initial_utm_content AggregateFunction(argMin, String, DateTime64(6, 'UTC')), initial_gclid AggregateFunction(argMin, String, DateTime64(6, 'UTC')), initial_gad_source AggregateFunction(argMin, String, DateTime64(6, 'UTC')), initial_gclsrc AggregateFunction(argMin, String, DateTime64(6, 'UTC')), initial_dclid AggregateFunction(argMin, String, DateTime64(6, 'UTC')), initial_gbraid AggregateFunction(argMin, String, DateTime64(6, 'UTC')), initial_wbraid AggregateFunction(argMin, String, DateTime64(6, 'UTC')), initial_fbclid AggregateFunction(argMin, String, DateTime64(6, 'UTC')), initial_msclkid AggregateFunction(argMin, String, DateTime64(6, 'UTC')), initial_twclid AggregateFunction(argMin, String, DateTime64(6, 'UTC')), initial_li_fat_id AggregateFunction(argMin, String, DateTime64(6, 'UTC')), initial_mc_cid AggregateFunction(argMin, String, DateTime64(6, 'UTC')), initial_igshid AggregateFunction(argMin, String, DateTime64(6, 'UTC')), initial_ttclid AggregateFunction(argMin, String, DateTime64(6, 'UTC')), initial_epik AggregateFunction(argMin, String, DateTime64(6, 'UTC')), initial_qclid AggregateFunction(argMin, String, DateTime64(6, 'UTC')), initial_sccid AggregateFunction(argMin, String, DateTime64(6, 'UTC')), initial__kx AggregateFunction(argMin, String, DateTime64(6, 'UTC')), initial_irclid AggregateFunction(argMin, String, DateTime64(6, 'UTC')), pageview_count UInt64, pageview_uniq AggregateFunction(uniq, Nullable(UUID)), autocapture_count UInt64, autocapture_uniq AggregateFunction(uniq, Nullable(UUID)), screen_count UInt64, screen_uniq AggregateFunction(uniq, Nullable(UUID)), maybe_has_session_replay Bool, page_screen_autocapture_uniq_up_to AggregateFunction(uniqUpTo(1), Nullable(UUID)), vitals_lcp AggregateFunction(argMin, Nullable(Float64), DateTime64(6, 'UTC'))) AS SELECT+ team_id,+ toUInt128(toUUID(`$session_id`)) AS session_id_v7,+ argMaxState(distinct_id, timestamp) AS distinct_id,+ min(timestamp) AS min_timestamp,+ max(timestamp) AS max_timestamp,+ max(coalesce(inserted_at, now64())) AS max_inserted_at,+ groupUniqArray(nullIf(JSONExtractString(properties, '$current_url'), '')) AS urls,+ argMinState(JSONExtractString(properties, '$current_url'), timestamp) AS entry_url,+ argMaxState(JSONExtractString(properties, '$current_url'), timestamp) AS end_url,+ argMaxState(JSONExtractString(properties, '$external_click_url'), timestamp) AS last_external_click_url,+ argMinState(JSONExtractString(properties, '$browser'), timestamp) AS initial_browser,+ argMinState(JSONExtractString(properties, '$browser_version'), timestamp) AS initial_browser_version,+ argMinState(JSONExtractString(properties, '$os'), timestamp) AS initial_os,+ argMinState(JSONExtractString(properties, '$os_version'), timestamp) AS initial_os_version,+ argMinState(JSONExtractString(properties, '$device_type'), timestamp) AS initial_device_type,+ argMinState(JSONExtractInt(properties, '$viewport_width'), timestamp) AS initial_viewport_width,+ argMinState(JSONExtractInt(properties, '$viewport_height'), timestamp) AS initial_viewport_height,+ argMinState(JSONExtractString(properties, '$geoip_country_code'), timestamp) AS initial_geoip_country_code,+ argMinState(JSONExtractString(properties, '$geoip_subdivision_1_code'), timestamp) AS initial_geoip_subdivision_1_code,+ argMinState(JSONExtractString(properties, '$geoip_subdivision_1_name'), timestamp) AS initial_geoip_subdivision_1_name,+ argMinState(JSONExtractString(properties, '$geoip_subdivision_city_name'), timestamp) AS initial_geoip_subdivision_city_name,+ argMinState(JSONExtractString(properties, '$geoip_time_zone'), timestamp) AS initial_geoip_time_zone,+ argMinState(JSONExtractString(properties, '$referring_domain'), timestamp) AS initial_referring_domain,+ argMinState(JSONExtractString(properties, 'utm_source'), timestamp) AS initial_utm_source,+ argMinState(JSONExtractString(properties, 'utm_campaign'), timestamp) AS initial_utm_campaign,+ argMinState(JSONExtractString(properties, 'utm_medium'), timestamp) AS initial_utm_medium,+ argMinState(JSONExtractString(properties, 'utm_term'), timestamp) AS initial_utm_term,+ argMinState(JSONExtractString(properties, 'utm_content'), timestamp) AS initial_utm_content,+ argMinState(JSONExtractString(properties, 'gclid'), timestamp) AS initial_gclid,+ argMinState(JSONExtractString(properties, 'gad_source'), timestamp) AS initial_gad_source,+ argMinState(JSONExtractString(properties, 'gclsrc'), timestamp) AS initial_gclsrc,+ argMinState(JSONExtractString(properties, 'dclid'), timestamp) AS initial_dclid,+ argMinState(JSONExtractString(properties, 'gbraid'), timestamp) AS initial_gbraid,+ argMinState(JSONExtractString(properties, 'wbraid'), timestamp) AS initial_wbraid,+ argMinState(JSONExtractString(properties, 'fbclid'), timestamp) AS initial_fbclid,+ argMinState(JSONExtractString(properties, 'msclkid'), timestamp) AS initial_msclkid,+ argMinState(JSONExtractString(properties, 'twclid'), timestamp) AS initial_twclid,+ argMinState(JSONExtractString(properties, 'li_fat_id'), timestamp) AS initial_li_fat_id,+ argMinState(JSONExtractString(properties, 'mc_cid'), timestamp) AS initial_mc_cid,+ argMinState(JSONExtractString(properties, 'igshid'), timestamp) AS initial_igshid,+ argMinState(JSONExtractString(properties, 'ttclid'), timestamp) AS initial_ttclid,+ argMinState(JSONExtractString(properties, 'epik'), timestamp) AS initial_epik,+ argMinState(JSONExtractString(properties, 'qclid'), timestamp) AS initial_qclid,+ argMinState(JSONExtractString(properties, 'sccid'), timestamp) AS initial_sccid,+ argMinState(JSONExtractString(properties, '_kx'), timestamp) AS initial__kx,+ argMinState(JSONExtractString(properties, 'irclid'), timestamp) AS initial_irclid,+ sumIf(1, event = '$pageview') AS pageview_count,+ uniqState(CAST(if(event = '$pageview', uuid, NULL), 'Nullable(UUID)')) AS pageview_uniq,+ sumIf(1, event = '$autocapture') AS autocapture_count,+ uniqState(CAST(if(event = '$autocapture', uuid, NULL), 'Nullable(UUID)')) AS autocapture_uniq,+ sumIf(1, event = '$screen') AS screen_count,+ uniqState(CAST(if(event = '$screen', uuid, NULL), 'Nullable(UUID)')) AS screen_uniq,+ false AS maybe_has_session_replay,+ uniqUpToState(+ 1+ )(CAST(if((event = '$pageview') OR (event = '$screen') OR (event = '$autocapture'), uuid, NULL), 'Nullable(UUID)')) AS page_screen_autocapture_uniq_up_to,+ argMinState(+ accurateCastOrNull(+ replaceRegexpAll(+ nullIf(nullIf(JSONExtractRaw(properties, '$web_vitals_LCP_value'), ''), 'null'),+ '^"|"$',+ ''+ ),+ 'Float64'+ ),+ timestamp+ ) AS vitals_lcp+FROM posthog.sharded_events+WHERE+ bitAnd(bitShiftRight(toUInt128(accurateCastOrNull(`$session_id`, 'UUID')), 76), 15) = 7+GROUP BY+ team_id, toStartOfHour(fromUnixTimestamp(intDiv(toUInt64(bitShiftRight(session_id_v7, 80)), 1000))), cityHash64(session_id_v7), session_id_v7;+CREATE MATERIALIZED VIEW posthog.session_replay_events_mv TO posthog.writable_session_replay_events (session_id String, team_id Int64, distinct_id String, min_first_timestamp DateTime64(6, 'UTC'), max_last_timestamp 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 Int64, keypress_count Int64, mouse_activity_count Int64, active_milliseconds Int64, console_log_count Int64, console_warn_count Int64, console_error_count Int64, size Int64, message_count Int64, event_count Int64, snapshot_source AggregateFunction(argMin, LowCardinality(Nullable(String)), DateTime64(6, 'UTC')), snapshot_library AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC')), _timestamp Nullable(DateTime), retention_period_days SimpleAggregateFunction(max, Nullable(Int64)), is_deleted SimpleAggregateFunction(max, UInt8), ai_tags_fixed SimpleAggregateFunction(groupUniqArrayArray, Array(String)), ai_tags_freeform SimpleAggregateFunction(groupUniqArrayArray, Array(String)), ai_highlighted SimpleAggregateFunction(max, UInt8), surfacing_score SimpleAggregateFunction(max, Nullable(Float32))) AS SELECT+ session_id,+ team_id,+ any(distinct_id) AS distinct_id,+ min(first_timestamp) AS min_first_timestamp,+ max(last_timestamp) AS max_last_timestamp,+ groupArray(if(block_url != '', first_timestamp, NULL)) AS block_first_timestamps,+ groupArray(if(block_url != '', last_timestamp, NULL)) AS block_last_timestamps,+ groupArray(block_url) AS block_urls,+ argMinState(first_url, first_timestamp) AS first_url,+ groupUniqArrayArray(urls) AS all_urls,+ sum(click_count) AS click_count,+ sum(keypress_count) AS keypress_count,+ sum(mouse_activity_count) AS mouse_activity_count,+ sum(active_milliseconds) AS active_milliseconds,+ sum(console_log_count) AS console_log_count,+ sum(console_warn_count) AS console_warn_count,+ sum(console_error_count) AS console_error_count,+ sum(size) AS size,+ sum(message_count) AS message_count,+ sum(event_count) AS event_count,+ argMinState(snapshot_source, first_timestamp) AS snapshot_source,+ argMinState(snapshot_library, first_timestamp) AS snapshot_library,+ max(_timestamp) AS _timestamp,+ max(retention_period_days) AS retention_period_days,+ max(is_deleted) AS is_deleted,+ groupUniqArrayArray(ai_tags_fixed) AS ai_tags_fixed,+ groupUniqArrayArray(ai_tags_freeform) AS ai_tags_freeform,+ max(ai_highlighted) AS ai_highlighted,+ max(surfacing_score) AS surfacing_score+FROM posthog.kafka_session_replay_events+GROUP BY+ session_id, team_id;+CREATE MATERIALIZED VIEW posthog.session_replay_features_mv TO posthog.writable_session_replay_features (session_id String, team_id Int64, distinct_id String, min_first_timestamp DateTime64(6, 'UTC'), max_last_timestamp DateTime64(6, 'UTC'), event_count Int64, mouse_position_count Int64, mouse_sum_x Float64, mouse_sum_x_squared Float64, mouse_sum_y Float64, mouse_sum_y_squared Float64, mouse_distance_traveled Float64, mouse_direction_change_count Int64, mouse_velocity_sum Float64, mouse_velocity_sum_of_squares Float64, mouse_velocity_count Int64, scroll_event_count Int64, total_scroll_magnitude Float64, scroll_direction_reversal_count Int64, rapid_scroll_reversal_count Int64, scroll_to_top_count Int64, click_count Int64, keypress_count Int64, mouse_activity_count Int64, rage_click_count Int64, dead_click_count Int64, backspace_count Int64, inter_action_gap_count Int64, inter_action_gap_sum_ms Float64, inter_action_gap_sum_of_squares_ms Float64, max_idle_gap_ms Float64, long_idle_gap_count Int64, quick_back_count Int64, page_visit_count Int64, unique_url_count AggregateFunction(uniqCombinedArray(12), Array(String)), login_path_visit_count Int64, signup_path_visit_count Int64, checkout_path_visit_count Int64, cart_path_visit_count Int64, billing_path_visit_count Int64, settings_path_visit_count Int64, account_path_visit_count Int64, error_path_visit_count Int64, not_found_path_visit_count Int64, admin_path_visit_count Int64, dashboard_path_visit_count Int64, onboarding_path_visit_count Int64, cancel_path_visit_count Int64, refund_path_visit_count Int64, console_error_count Int64, console_error_after_click_count Int64, console_warn_count Int64, network_request_count Int64, network_failed_request_count Int64, network_4xx_count Int64, network_5xx_count Int64, network_request_duration_sum Float64, network_request_duration_sum_of_squares Float64, network_request_duration_count Int64, mutation_count Int64, viewport_resize_count Int64, touch_event_count Int64, max_scroll_y Float64, unique_click_target_count AggregateFunction(uniqCombinedArray(12), Array(Int64)), unique_form_field_count AggregateFunction(uniqCombinedArray(12), Array(Int64)), text_selection_count Int64, selection_copy_count Int64, is_deleted UInt8) AS SELECT+ session_id,+ team_id,+ any(distinct_id) AS distinct_id,+ min(first_timestamp) AS min_first_timestamp,+ max(last_timestamp) AS max_last_timestamp,+ sum(event_count) AS event_count,+ sum(mouse_position_count) AS mouse_position_count,+ sum(mouse_sum_x) AS mouse_sum_x,+ sum(mouse_sum_x_squared) AS mouse_sum_x_squared,+ sum(mouse_sum_y) AS mouse_sum_y,+ sum(mouse_sum_y_squared) AS mouse_sum_y_squared,+ sum(mouse_distance_traveled) AS mouse_distance_traveled,+ sum(mouse_direction_change_count) AS mouse_direction_change_count,+ sum(mouse_velocity_sum) AS mouse_velocity_sum,+ sum(mouse_velocity_sum_of_squares) AS mouse_velocity_sum_of_squares,+ sum(mouse_velocity_count) AS mouse_velocity_count,+ sum(scroll_event_count) AS scroll_event_count,+ sum(total_scroll_magnitude) AS total_scroll_magnitude,+ sum(scroll_direction_reversal_count) AS scroll_direction_reversal_count,+ sum(rapid_scroll_reversal_count) AS rapid_scroll_reversal_count,+ sum(scroll_to_top_count) AS scroll_to_top_count,+ sum(click_count) AS click_count,+ sum(keypress_count) AS keypress_count,+ sum(mouse_activity_count) AS mouse_activity_count,+ sum(rage_click_count) AS rage_click_count,+ sum(dead_click_count) AS dead_click_count,+ sum(backspace_count) AS backspace_count,+ sum(inter_action_gap_count) AS inter_action_gap_count,+ sum(inter_action_gap_sum_ms) AS inter_action_gap_sum_ms,+ sum(inter_action_gap_sum_of_squares_ms) AS inter_action_gap_sum_of_squares_ms,+ max(max_idle_gap_ms) AS max_idle_gap_ms,+ sum(long_idle_gap_count) AS long_idle_gap_count,+ sum(quick_back_count) AS quick_back_count,+ sum(page_visit_count) AS page_visit_count,+ uniqCombinedArrayState(12)(visited_urls) AS unique_url_count,+ sum(login_path_visit_count) AS login_path_visit_count,+ sum(signup_path_visit_count) AS signup_path_visit_count,+ sum(checkout_path_visit_count) AS checkout_path_visit_count,+ sum(cart_path_visit_count) AS cart_path_visit_count,+ sum(billing_path_visit_count) AS billing_path_visit_count,+ sum(settings_path_visit_count) AS settings_path_visit_count,+ sum(account_path_visit_count) AS account_path_visit_count,+ sum(error_path_visit_count) AS error_path_visit_count,+ sum(not_found_path_visit_count) AS not_found_path_visit_count,+ sum(admin_path_visit_count) AS admin_path_visit_count,+ sum(dashboard_path_visit_count) AS dashboard_path_visit_count,+ sum(onboarding_path_visit_count) AS onboarding_path_visit_count,+ sum(cancel_path_visit_count) AS cancel_path_visit_count,+ sum(refund_path_visit_count) AS refund_path_visit_count,+ sum(console_error_count) AS console_error_count,+ sum(console_error_after_click_count) AS console_error_after_click_count,+ sum(console_warn_count) AS console_warn_count,+ sum(network_request_count) AS network_request_count,+ sum(network_failed_request_count) AS network_failed_request_count,+ sum(network_4xx_count) AS network_4xx_count,+ sum(network_5xx_count) AS network_5xx_count,+ sum(network_request_duration_sum) AS network_request_duration_sum,+ sum(network_request_duration_sum_of_squares) AS network_request_duration_sum_of_squares,+ sum(network_request_duration_count) AS network_request_duration_count,+ sum(mutation_count) AS mutation_count,+ sum(viewport_resize_count) AS viewport_resize_count,+ sum(touch_event_count) AS touch_event_count,+ max(max_scroll_y) AS max_scroll_y,+ uniqCombinedArrayState(12)(click_target_ids) AS unique_click_target_count,+ uniqCombinedArrayState(12)(form_field_ids) AS unique_form_field_count,+ sum(text_selection_count) AS text_selection_count,+ sum(selection_copy_count) AS selection_copy_count,+ max(is_deleted) AS is_deleted+FROM posthog.kafka_session_replay_features+GROUP BY+ session_id, team_id;+CREATE MATERIALIZED VIEW posthog.sessions_mv TO posthog.writable_sessions (session_id String, team_id Int64, distinct_id String, min_timestamp DateTime64(6, 'UTC'), max_timestamp DateTime64(6, 'UTC'), urls Array(String), entry_url AggregateFunction(argMin, String, DateTime64(6, 'UTC')), exit_url AggregateFunction(argMax, String, DateTime64(6, 'UTC')), initial_referring_domain AggregateFunction(argMin, String, DateTime64(6, 'UTC')), initial_utm_source AggregateFunction(argMin, String, DateTime64(6, 'UTC')), initial_utm_campaign AggregateFunction(argMin, String, DateTime64(6, 'UTC')), initial_utm_medium AggregateFunction(argMin, String, DateTime64(6, 'UTC')), initial_utm_term AggregateFunction(argMin, String, DateTime64(6, 'UTC')), initial_utm_content AggregateFunction(argMin, String, DateTime64(6, 'UTC')), initial_gclid AggregateFunction(argMin, String, DateTime64(6, 'UTC')), initial_gad_source AggregateFunction(argMin, String, DateTime64(6, 'UTC')), initial_gclsrc AggregateFunction(argMin, String, DateTime64(6, 'UTC')), initial_dclid AggregateFunction(argMin, String, DateTime64(6, 'UTC')), initial_gbraid AggregateFunction(argMin, String, DateTime64(6, 'UTC')), initial_wbraid AggregateFunction(argMin, String, DateTime64(6, 'UTC')), initial_fbclid AggregateFunction(argMin, String, DateTime64(6, 'UTC')), initial_msclkid AggregateFunction(argMin, String, DateTime64(6, 'UTC')), initial_twclid AggregateFunction(argMin, String, DateTime64(6, 'UTC')), initial_li_fat_id AggregateFunction(argMin, String, DateTime64(6, 'UTC')), initial_mc_cid AggregateFunction(argMin, String, DateTime64(6, 'UTC')), initial_igshid AggregateFunction(argMin, String, DateTime64(6, 'UTC')), initial_ttclid AggregateFunction(argMin, String, DateTime64(6, 'UTC')), initial_epik AggregateFunction(argMin, String, DateTime64(6, 'UTC')), initial_qclid AggregateFunction(argMin, String, DateTime64(6, 'UTC')), initial_sccid AggregateFunction(argMin, String, DateTime64(6, 'UTC')), event_count_map Map(String, UInt64), pageview_count UInt64, autocapture_count UInt64) AS SELECT+ `$session_id` AS session_id,+ team_id,+ any(distinct_id) AS distinct_id,+ min(timestamp) AS min_timestamp,+ max(timestamp) AS max_timestamp,+ groupUniqArray(replaceRegexpAll(JSONExtractRaw(properties, '$current_url'), '^"|"$', '')) AS urls,+ argMinState(replaceRegexpAll(JSONExtractRaw(properties, '$current_url'), '^"|"$', ''), timestamp) AS entry_url,+ argMaxState(replaceRegexpAll(JSONExtractRaw(properties, '$current_url'), '^"|"$', ''), timestamp) AS exit_url,+ argMinState(+ replaceRegexpAll(JSONExtractRaw(properties, '$referring_domain'), '^"|"$', ''),+ timestamp+ ) AS initial_referring_domain,+ argMinState(replaceRegexpAll(JSONExtractRaw(properties, 'utm_source'), '^"|"$', ''), timestamp) AS initial_utm_source,+ argMinState(replaceRegexpAll(JSONExtractRaw(properties, 'utm_campaign'), '^"|"$', ''), timestamp) AS initial_utm_campaign,+ argMinState(replaceRegexpAll(JSONExtractRaw(properties, 'utm_medium'), '^"|"$', ''), timestamp) AS initial_utm_medium,+ argMinState(replaceRegexpAll(JSONExtractRaw(properties, 'utm_term'), '^"|"$', ''), timestamp) AS initial_utm_term,+ argMinState(replaceRegexpAll(JSONExtractRaw(properties, 'utm_content'), '^"|"$', ''), timestamp) AS initial_utm_content,+ argMinState(replaceRegexpAll(JSONExtractRaw(properties, 'gclid'), '^"|"$', ''), timestamp) AS initial_gclid,+ argMinState(replaceRegexpAll(JSONExtractRaw(properties, 'gad_source'), '^"|"$', ''), timestamp) AS initial_gad_source,+ argMinState(replaceRegexpAll(JSONExtractRaw(properties, 'gclsrc'), '^"|"$', ''), timestamp) AS initial_gclsrc,+ argMinState(replaceRegexpAll(JSONExtractRaw(properties, 'dclid'), '^"|"$', ''), timestamp) AS initial_dclid,+ argMinState(replaceRegexpAll(JSONExtractRaw(properties, 'gbraid'), '^"|"$', ''), timestamp) AS initial_gbraid,+ argMinState(replaceRegexpAll(JSONExtractRaw(properties, 'wbraid'), '^"|"$', ''), timestamp) AS initial_wbraid,+ argMinState(replaceRegexpAll(JSONExtractRaw(properties, 'fbclid'), '^"|"$', ''), timestamp) AS initial_fbclid,+ argMinState(replaceRegexpAll(JSONExtractRaw(properties, 'msclkid'), '^"|"$', ''), timestamp) AS initial_msclkid,+ argMinState(replaceRegexpAll(JSONExtractRaw(properties, 'twclid'), '^"|"$', ''), timestamp) AS initial_twclid,+ argMinState(replaceRegexpAll(JSONExtractRaw(properties, 'li_fat_id'), '^"|"$', ''), timestamp) AS initial_li_fat_id,+ argMinState(replaceRegexpAll(JSONExtractRaw(properties, 'mc_cid'), '^"|"$', ''), timestamp) AS initial_mc_cid,+ argMinState(replaceRegexpAll(JSONExtractRaw(properties, 'igshid'), '^"|"$', ''), timestamp) AS initial_igshid,+ argMinState(replaceRegexpAll(JSONExtractRaw(properties, 'ttclid'), '^"|"$', ''), timestamp) AS initial_ttclid,+ argMinState(replaceRegexpAll(JSONExtractRaw(properties, 'epik'), '^"|"$', ''), timestamp) AS initial_epik,+ argMinState(replaceRegexpAll(JSONExtractRaw(properties, 'qclid'), '^"|"$', ''), timestamp) AS initial_qclid,+ argMinState(replaceRegexpAll(JSONExtractRaw(properties, 'sccid'), '^"|"$', ''), timestamp) AS initial_sccid,+ sumMap(CAST(([event], [1]), 'Map(String, UInt64)')) AS event_count_map,+ sumIf(1, event = '$pageview') AS pageview_count,+ sumIf(1, event = '$autocapture') AS autocapture_count+FROM posthog.sharded_events+WHERE+ (`$session_id` IS NOT NULL)+AND+ (`$session_id` != '')+AND+ (team_id IN (1, 2, 13610, 19279, 21173, 29929, 32050, 9910, 11775, 21129, 31490))+GROUP BY+ `$session_id`, team_id;+CREATE MATERIALIZED VIEW posthog.tophog_mv TO posthog.writable_tophog (timestamp DateTime64(6, 'UTC'), metric LowCardinality(String), type LowCardinality(String), key Map(LowCardinality(String), String), value Float64, count UInt64, pipeline LowCardinality(String), lane LowCardinality(String), labels Map(LowCardinality(String), String)) AS SELECT+ timestamp,+ metric,+ type,+ key,+ value,+ count,+ pipeline,+ lane,+ labels+FROM posthog.kafka_tophog;+CREATE MATERIALIZED VIEW posthog.tophog_ws_mv TO posthog.writable_tophog (timestamp DateTime64(6, 'UTC'), metric LowCardinality(String), type LowCardinality(String), key Map(LowCardinality(String), String), value Float64, count UInt64, pipeline LowCardinality(String), lane LowCardinality(String), labels Map(LowCardinality(String), String)) AS SELECT+ timestamp,+ metric,+ type,+ key,+ value,+ count,+ pipeline,+ lane,+ labels+FROM posthog.kafka_tophog_ws;+CREATE MATERIALIZED VIEW posthog.trace_span_to_attributes TO posthog.trace_attributes (team_id Int32, original_expiry_time_bucket DateTime64(0), time_bucket DateTime64(0), service_name LowCardinality(String), resource_fingerprint UInt64, attribute_key LowCardinality(String), attribute_value String, attribute_type LowCardinality(String), attribute_count SimpleAggregateFunction(sum, UInt64)) AS SELECT+ team_id,+ original_expiry_time_bucket,+ time_bucket,+ service_name,+ resource_fingerprint,+ attribute_key,+ attribute_value,+ 'span_attribute' AS attribute_type,+ attribute_count+FROM+ (+ SELECT+ team_id AS team_id,+ toStartOfInterval(original_expiry_timestamp, toIntervalMinute(10)) AS original_expiry_time_bucket,+ toStartOfInterval(timestamp, toIntervalMinute(10)) AS time_bucket,+ service_name AS service_name,+ resource_fingerprint,+ arrayJoin(mapFilter((k, v) -> ((length(k) < 256) AND (length(v) < 256)), attributes)) AS attribute,+ attribute.1 AS attribute_key,+ attribute.2 AS attribute_value,+ sumSimpleState(1) AS attribute_count+ FROM posthog.trace_spans+ GROUP BY+ team_id, original_expiry_time_bucket, time_bucket, service_name, resource_fingerprint, attribute+ );+CREATE MATERIALIZED VIEW posthog.trace_span_to_attributes2 TO posthog.trace_attributes2 (team_id Int32, original_expiry_time_bucket DateTime64(0), time_bucket DateTime64(0), service_name LowCardinality(String), resource_fingerprint UInt64, attribute_key LowCardinality(String), attribute_value String, attribute_type LowCardinality(String), attribute_count SimpleAggregateFunction(sum, UInt64)) AS SELECT+ team_id,+ original_expiry_time_bucket,+ time_bucket,+ service_name,+ resource_fingerprint,+ attribute_key,+ attribute_value,+ 'span_attribute' AS attribute_type,+ attribute_count+FROM+ (+ SELECT+ team_id AS team_id,+ toStartOfInterval(original_expiry_timestamp, toIntervalMinute(10)) AS original_expiry_time_bucket,+ toStartOfInterval(timestamp, toIntervalMinute(10)) AS time_bucket,+ service_name AS service_name,+ resource_fingerprint,+ arrayJoin(mapFilter((k, v) -> ((length(k) < 256) AND (length(v) < 256)), attributes)) AS attribute,+ attribute.1 AS attribute_key,+ attribute.2 AS attribute_value,+ sumSimpleState(1) AS attribute_count+ FROM posthog.trace_spans+ GROUP BY+ team_id, original_expiry_time_bucket, time_bucket, service_name, resource_fingerprint, attribute+ );+CREATE MATERIALIZED VIEW posthog.trace_span_to_resource_attributes TO posthog.trace_attributes (team_id Int32, original_expiry_time_bucket DateTime64(0), time_bucket DateTime64(0), service_name LowCardinality(String), resource_fingerprint UInt64, attribute_key LowCardinality(String), attribute_value String, attribute_type LowCardinality(String), attribute_count SimpleAggregateFunction(sum, UInt64)) AS SELECT+ team_id,+ original_expiry_time_bucket,+ time_bucket,+ service_name,+ resource_fingerprint,+ attribute_key,+ attribute_value,+ 'span_resource_attribute' AS attribute_type,+ attribute_count+FROM+ (+ SELECT+ team_id AS team_id,+ toStartOfInterval(original_expiry_timestamp, toIntervalMinute(10)) AS original_expiry_time_bucket,+ toStartOfInterval(timestamp, toIntervalMinute(10)) AS time_bucket,+ service_name AS service_name,+ resource_fingerprint,+ arrayJoin(resource_attributes) AS attribute,+ attribute.1 AS attribute_key,+ attribute.2 AS attribute_value,+ sumSimpleState(1) AS attribute_count+ FROM posthog.trace_spans+ GROUP BY+ team_id, original_expiry_time_bucket, time_bucket, service_name, resource_fingerprint, attribute+ );+CREATE MATERIALIZED VIEW posthog.trace_span_to_resource_attributes2 TO posthog.trace_attributes2 (team_id Int32, original_expiry_time_bucket DateTime64(0), time_bucket DateTime64(0), service_name LowCardinality(String), resource_fingerprint UInt64, attribute_key LowCardinality(String), attribute_value String, attribute_type LowCardinality(String), attribute_count SimpleAggregateFunction(sum, UInt64)) AS SELECT+ team_id,+ original_expiry_time_bucket,+ time_bucket,+ service_name,+ resource_fingerprint,+ attribute_key,+ attribute_value,+ 'span_resource_attribute' AS attribute_type,+ attribute_count+FROM+ (+ SELECT+ team_id AS team_id,+ toStartOfInterval(original_expiry_timestamp, toIntervalMinute(10)) AS original_expiry_time_bucket,+ toStartOfInterval(timestamp, toIntervalMinute(10)) AS time_bucket,+ service_name AS service_name,+ resource_fingerprint,+ arrayJoin(resource_attributes) AS attribute,+ attribute.1 AS attribute_key,+ attribute.2 AS attribute_value,+ sumSimpleState(1) AS attribute_count+ FROM posthog.trace_spans+ GROUP BY+ team_id, original_expiry_time_bucket, time_bucket, service_name, resource_fingerprint, attribute+ );+CREATE MATERIALIZED VIEW posthog.trace_span_to_span_attributes TO posthog.trace_attributes (team_id Int32, original_expiry_time_bucket DateTime64(0), time_bucket DateTime64(0), service_name LowCardinality(String), resource_fingerprint UInt64, attribute_key LowCardinality(String), attribute_value String, attribute_type LowCardinality(String), attribute_count SimpleAggregateFunction(sum, UInt64)) AS SELECT+ team_id,+ original_expiry_time_bucket,+ time_bucket,+ service_name,+ resource_fingerprint,+ attribute_key,+ attribute_value,+ 'span' AS attribute_type,+ attribute_count+FROM+ (+ SELECT+ team_id AS team_id,+ toStartOfInterval(original_expiry_timestamp, toIntervalMinute(10)) AS original_expiry_time_bucket,+ toStartOfInterval(timestamp, toIntervalMinute(10)) AS time_bucket,+ service_name AS service_name,+ resource_fingerprint,+ 'name' AS attribute_key,+ name AS attribute_value,+ sumSimpleState(1) AS attribute_count+ FROM posthog.trace_spans+ GROUP BY+ team_id, original_expiry_time_bucket, time_bucket, service_name, resource_fingerprint, name+ );+CREATE MATERIALIZED VIEW posthog.trace_span_to_span_attributes2 TO posthog.trace_attributes2 (team_id Int32, original_expiry_time_bucket DateTime64(0), time_bucket DateTime64(0), service_name LowCardinality(String), resource_fingerprint UInt64, attribute_key LowCardinality(String), attribute_value String, attribute_type LowCardinality(String), attribute_count SimpleAggregateFunction(sum, UInt64)) AS SELECT+ team_id,+ original_expiry_time_bucket,+ time_bucket,+ service_name,+ resource_fingerprint,+ attribute_key,+ attribute_value,+ 'span' AS attribute_type,+ attribute_count+FROM+ (+ SELECT+ team_id AS team_id,+ toStartOfInterval(original_expiry_timestamp, toIntervalMinute(10)) AS original_expiry_time_bucket,+ toStartOfInterval(timestamp, toIntervalMinute(10)) AS time_bucket,+ service_name AS service_name,+ resource_fingerprint,+ 'name' AS attribute_key,+ name AS attribute_value,+ sumSimpleState(1) AS attribute_count+ FROM posthog.trace_spans+ GROUP BY+ team_id, original_expiry_time_bucket, time_bucket, service_name, resource_fingerprint, name+ );+CREATE MATERIALIZED VIEW posthog.trace_spans_to_kafka_metrics_mv TO posthog.trace_spans_kafka_metrics (_partition UInt64, _topic LowCardinality(String), max_offset SimpleAggregateFunction(max, UInt64), max_observed_timestamp SimpleAggregateFunction(max, DateTime64(6)), max_timestamp SimpleAggregateFunction(max, DateTime64(6)), max_created_at SimpleAggregateFunction(max, DateTime), max_lag SimpleAggregateFunction(max, Decimal(18, 6))) AS SELECT+ _partition,+ _topic,+ maxSimpleState(_offset) AS max_offset,+ maxSimpleState(observed_timestamp) AS max_observed_timestamp,+ maxSimpleState(timestamp) AS max_timestamp,+ maxSimpleState(now()) AS max_created_at,+ maxSimpleState(now() - observed_timestamp) AS max_lag+FROM posthog.trace_spans+GROUP BY+ _partition, _topic;+CREATE MATERIALIZED VIEW posthog.usage_report_events_preagg_mv TO posthog.writable_usage_report_events_preagg (date Date, team_id Int64, person_mode Enum8('full'=0, 'propertyless'=1, 'force_upgrade'=2), lib String, event String, distinct_events_unique AggregateFunction(uniqExact, Tuple(UInt64, UInt64, UInt64)), event_count AggregateFunction(sum, UInt64)) AS SELECT+ toDate(timestamp) AS date,+ team_id,+ person_mode,+ JSONExtractString(properties, '$lib') AS lib,+ event,+ uniqExactState((cityHash64(distinct_id), cityHash64(toString(uuid)), cityHash64(event))) AS distinct_events_unique,+ sumState(toUInt64(1)) AS event_count+FROM posthog.kafka_usage_report_events_preagg+GROUP BY+ date, team_id, person_mode, lib, event;+CREATE VIEW posthog.custom_metrics_backups AS WITH+ ['ClickHouseCustomMetric_BackupFailed', 'ClickHouseCustomMetric_BackupSuccess', 'ClickHouseCustomMetric_BackupCancelled', 'ClickHouseCustomMetric_BackupAttempts'] AS names,+ [toInt64(countIf(status = 'BACKUP_FAILED')), toInt64(countIf(status = 'BACKUP_CREATED')), toInt64(countIf(status = 'BACKUP_CANCELLED')), toInt64(countIf(status = 'CREATING_BACKUP'))] AS values,+ ['Number of failed backups', 'Number of successful backups', 'Number of cancelled backups', 'Number of backup attempts'] AS descriptions,+ ['gauge', 'gauge', 'gauge', 'gauge'] AS types,+ arrayJoin(arrayZip(names, values, descriptions, types)) AS tpl+SELECT+ tpl.1 AS name,+ map('instance', hostname()) AS labels,+ tpl.2 AS value,+ tpl.3 AS help,+ tpl.4 AS type+FROM system.backup_log+WHERE event_date = today()+GROUP BY+ event_date;+CREATE VIEW posthog.custom_metrics_dictionaries AS SELECT+ 'ClickHouseCustomMetric_DictionariesFailed' AS name,+ map(+ 'instance',+ hostname(),+ 'database',+ d.database,+ 'dictionary',+ d.dict_name,+ 'uuid',+ toString(d.uuid),+ 'status',+ toString(d.status)+ ) AS labels,+ toUInt64(1) AS value,+ 'Dictionary is in FAILED or FAILED_AND_RELOADING status' AS help,+ 'gauge' AS type+FROM+ (+ SELECT name AS dict_name, database, uuid, status+ FROM system.dictionaries+ WHERE status IN ('FAILED', 'FAILED_AND_RELOADING')+ ) AS d;+CREATE VIEW posthog.custom_metrics_part_counts AS SELECT+ 'ClickHouseCustomMetric_MaxPartCountPerPartition' AS name,+ map('instance', hostname(), 'database', database, 'table', `table`, 'partition', partition) AS labels,+ part_count AS value,+ 'Maximum number of active parts for any partition in a PostHog table' AS help,+ 'gauge' AS type+FROM+ (+ SELECT database, `table`, partition, count() AS part_count+ FROM system.parts+ WHERE+ active+ AND+ (database = 'posthog')+ GROUP BY+ database, `table`, partition+ ORDER BY database ASC, `table` ASC, part_count DESC, partition ASC+ LIMIT 1 BY database, `table`+ );+CREATE VIEW posthog.custom_metrics_replication_queue AS WITH+ ['ClickHouseCustomMetric_ReplicationQueueStuckEntries', 'ClickHouseCustomMetric_ReplicationQueueMaxPostponedEntrySeconds', 'ClickHouseCustomMetric_ReplicationQueueMaxErrorEntrySeconds'] AS names,+ [toInt64(countIf(create_time < (now() - toIntervalDay(15)))), maxIf(dateDiff('seconds', create_time, last_postpone_time), last_postpone_time != '1970-01-01'), maxIf(dateDiff('seconds', create_time, last_exception_time), (last_exception_time != '1970-01-01') AND (last_exception_time > (now() - toIntervalMinute(5))))] AS values,+ ['Number of entries that have been in the replication queue for more than 15 days', 'Maximum number of seconds that an entry has been postponed', 'Maximum number of seconds that an entry has been in error'] AS descriptions,+ ['gauge', 'gauge', 'gauge'] AS types,+ arrayJoin(arrayZip(names, values, descriptions, types)) AS tpl+SELECT+ tpl.1 AS name,+ map('table', `table`, 'instance', hostname()) AS labels,+ tpl.2 AS value,+ tpl.3 AS help,+ tpl.4 AS type+FROM system.replication_queue+GROUP BY+ `table`+HAVING+ value > 0;+CREATE VIEW posthog.custom_metrics_server_crash AS SELECT+ 'ClickHouseCustomMetric_ServerCrash' AS name,+ map('instance', hostname()) AS labels,+ count() AS value,+ 'Number of server crashes for current date' AS help,+ 'gauge' AS type+FROM system.crash_log+WHERE event_date = today()+GROUP BY+ hostname();+CREATE VIEW posthog.custom_metrics_table_sizes AS SELECT+ 'ClickHouseCustomMetric_TableTotalBytes' AS name,+ map('instance', hostname(), 'database', database, 'table', `table`) AS labels,+ CAST(total_bytes, 'Float64') AS value,+ 'Size of a database table on a given node (need a sum for sharded)' AS help,+ 'gauge' AS type+FROM system.tables+WHERE+ (database NOT IN ('INFORMATION_SCHEMA', 'information_schema'))+AND+ (total_bytes IS NOT NULL);+CREATE VIEW posthog.custom_metrics_test AS SELECT+ 'ClickHouseCustomMetric_Test' AS name,+ map('instance', hostname()) AS labels,+ 1 AS value,+ 'Test to check that the metric endpoint is working' AS help,+ 'gauge' AS type;+CREATE VIEW posthog.persons_batch_export AS WITH+ new_persons AS (SELECT id, max(version) AS version, argMax(_timestamp, person.version) AS _timestamp2 FROM posthog.person WHERE (team_id = {team_id: Int64}) AND (id IN (SELECT id FROM posthog.person WHERE (team_id = {team_id: Int64}) AND (_timestamp >= {interval_start: DateTime64}) AND (_timestamp < {interval_end: DateTime64}))) GROUP BY id HAVING (_timestamp2 >= {interval_start: DateTime64}) AND (_timestamp2 < {interval_end: DateTime64})),+ new_distinct_ids AS (SELECT argMax(person_id, person_distinct_id2.version) AS person_id FROM posthog.person_distinct_id2 WHERE (team_id = {team_id: Int64}) AND (distinct_id IN (SELECT distinct_id FROM posthog.person_distinct_id2 WHERE (team_id = {team_id: Int64}) AND (_timestamp >= {interval_start: DateTime64}) AND (_timestamp < {interval_end: DateTime64}))) GROUP BY distinct_id HAVING (argMax(_timestamp, person_distinct_id2.version) >= {interval_start: DateTime64}) AND (argMax(_timestamp, person_distinct_id2.version) < {interval_end: DateTime64})),+ all_new_persons AS (SELECT id, version FROM new_persons UNION ALL SELECT id, max(version) FROM posthog.person WHERE (team_id = {team_id: Int64}) AND (id IN (new_distinct_ids)) GROUP BY id)+SELECT+ p.team_id AS team_id,+ pd.distinct_id AS distinct_id,+ toString(p.id) AS person_id,+ p.properties AS properties,+ pd.version AS person_distinct_id_version,+ p.version AS person_version,+ p.created_at AS created_at,+ multiIf(+ ((pd._timestamp >= {interval_start: DateTime64}) AND (pd._timestamp < {interval_end: DateTime64}))+ AND (NOT ((p._timestamp >= {interval_start: DateTime64}) AND (p._timestamp < {interval_end: DateTime64}))),+ pd._timestamp,+ ((p._timestamp >= {interval_start: DateTime64}) AND (p._timestamp < {interval_end: DateTime64}))+ AND (NOT ((pd._timestamp >= {interval_start: DateTime64}) AND (pd._timestamp < {interval_end: DateTime64}))),+ p._timestamp,+ least(p._timestamp, pd._timestamp)+ ) AS _inserted_at+FROM+ posthog.person AS p INNER JOIN (SELECT distinct_id, max(version) AS version, argMax(person_id, person_distinct_id2.version) AS person_id2, argMax(_timestamp, person_distinct_id2.version) AS _timestamp FROM posthog.person_distinct_id2 WHERE (team_id = {team_id: Int64}) AND (person_id IN (SELECT id FROM all_new_persons)) GROUP BY distinct_id) AS pd ON p.id = pd.person_id2+WHERE+ (team_id = {team_id: Int64})+AND+ ((id, version) IN (all_new_persons))+ORDER BY _inserted_at ASC;+CREATE VIEW posthog.persons_batch_export_backfill AS SELECT+ pd.team_id AS team_id,+ pd.distinct_id AS distinct_id,+ toString(p.id) AS person_id,+ p.properties AS properties,+ pd.version AS person_distinct_id_version,+ p.version AS person_version,+ p.created_at AS created_at,+ multiIf(+ (pd._timestamp < {interval_end: DateTime64})+ AND (NOT (p._timestamp < {interval_end: DateTime64})),+ pd._timestamp,+ (p._timestamp < {interval_end: DateTime64})+ AND (NOT (pd._timestamp < {interval_end: DateTime64})),+ p._timestamp,+ least(p._timestamp, pd._timestamp)+ ) AS _inserted_at+FROM+ (SELECT team_id, distinct_id, max(version) AS version, argMax(person_id, person_distinct_id2.version) AS person_id, argMax(_timestamp, person_distinct_id2.version) AS _timestamp FROM posthog.person_distinct_id2 PREWHERE team_id = {team_id: Int64} GROUP BY team_id, distinct_id) AS pd INNER JOIN (SELECT team_id, id, max(version) AS version, argMax(properties, person.version) AS properties, argMax(created_at, person.version) AS created_at, argMax(_timestamp, person.version) AS _timestamp FROM posthog.person PREWHERE team_id = {team_id: Int64} GROUP BY team_id, id) AS p ON (p.id = pd.person_id) AND (p.team_id = pd.team_id)+WHERE+ (pd.team_id = {team_id: Int64})+AND+ (p.team_id = {team_id: Int64})+AND+ ((pd._timestamp < {interval_end: DateTime64}) OR (p._timestamp < {interval_end: DateTime64}))+ORDER BY _inserted_at ASC;+CREATE OR REPLACE DICTIONARY posthog.channel_definition_dict (`domain` String, `kind` String, `domain_type` Nullable(String), `type_if_paid` Nullable(String), `type_if_organic` Nullable(String)) PRIMARY KEY domain, kind SOURCE(CLICKHOUSE(USER 'default' TABLE 'channel_definition')) LAYOUT(COMPLEX_KEY_HASHED()) LIFETIME(MIN 3000 MAX 3600);+CREATE OR REPLACE DICTIONARY posthog.exchange_rate_dict (`currency` String, `start_date` Date, `end_date` Nullable(Date), `rate` Decimal64(10)) PRIMARY KEY currency SOURCE(CLICKHOUSE(USER 'default' QUERY 'SELECT currency, date AS start_date, leadInFrame(date::Nullable(Date), 1, NULL::Nullable(Date)) OVER w AS end_date, argMax(rate, version) AS rate FROM `posthog`.`exchange_rate` GROUP BY date, currency WINDOW w AS ( PARTITION BY currency ORDER BY date ASC ROWS BETWEEN 1 FOLLOWING AND 1 FOLLOWING )')) LAYOUT(COMPLEX_KEY_RANGE_HASHED(RANGE_LOOKUP_STRATEGY 'max')) LIFETIME(MIN 3000 MAX 3600) RANGE(MIN start_date MAX end_date);+CREATE OR REPLACE DICTIONARY posthog.person_distinct_id_overrides_dict (`team_id` Int64, `distinct_id` String, `person_id` UUID) PRIMARY KEY team_id, distinct_id SOURCE(CLICKHOUSE(USER 'default' QUERY 'SELECT team_id, distinct_id, argMax(person_id, version) AS person_id FROM posthog.person_distinct_id_overrides GROUP BY team_id, distinct_id')) LAYOUT(COMPLEX_KEY_HASHED()) LIFETIME(MIN 3600 MAX 18000);+CREATE OR REPLACE DICTIONARY posthog.person_overrides_dict (`team_id` INT, `old_person_id` UUID, `override_person_id` UUID) PRIMARY KEY team_id, old_person_id SOURCE(CLICKHOUSE(USER 'default' QUERY '\nSELECT\n team_id,\n old_person_id,\n argMax(override_person_id, version)\nFROM\n `posthog`.`person_overrides` AS overrides\nGROUP BY\n team_id,\n old_person_id\n')) LAYOUT(COMPLEX_KEY_HASHED(PREALLOCATE 1)) LIFETIME(MIN 5 MAX 10);+CREATE OR REPLACE DICTIONARY posthog.web_bot_definition_dict (`regexp` String, `name` String, `category` String, `traffic_type` String, `operator` String) PRIMARY KEY regexp SOURCE(CLICKHOUSE(USER 'default' DB 'posthog' TABLE 'web_bot_definition')) LAYOUT(REGEXP_TREE()) LIFETIME(MIN 3000 MAX 3600);+CREATE OR REPLACE DICTIONARY posthog.web_pre_aggregated_teams_dict (`team_id` UInt64) PRIMARY KEY team_id SOURCE(CLICKHOUSE(USER 'default' QUERY 'SELECT team_id FROM `posthog`.`web_pre_aggregated_teams` FINAL WHERE version > 0')) LAYOUT(HASHED()) LIFETIME(MIN 3000 MAX 3600);+CREATE TABLE posthog.ai_events (+ uuid UUID,+ event LowCardinality(String),+ timestamp DateTime64(6, 'UTC'),+ team_id Int64,+ distinct_id String,+ person_id UUID,+ properties String,+ retention_days Int16 DEFAULT 30,+ drop_date Date MATERIALIZED toDate(timestamp) + toIntervalDay(retention_days),+ trace_id String,+ session_id Nullable(String),+ parent_id Nullable(String),+ span_id Nullable(String),+ span_type LowCardinality(Nullable(String)),+ generation_id Nullable(String),+ experiment_id Nullable(String),+ span_name Nullable(String),+ trace_name Nullable(String),+ prompt_name Nullable(String),+ model LowCardinality(Nullable(String)),+ provider LowCardinality(Nullable(String)),+ framework LowCardinality(Nullable(String)),+ total_tokens Nullable(Int64),+ input_tokens Nullable(Int64),+ output_tokens Nullable(Int64),+ text_input_tokens Nullable(Int64),+ text_output_tokens Nullable(Int64),+ image_input_tokens Nullable(Int64),+ image_output_tokens Nullable(Int64),+ audio_input_tokens Nullable(Int64),+ audio_output_tokens Nullable(Int64),+ video_input_tokens Nullable(Int64),+ video_output_tokens Nullable(Int64),+ reasoning_tokens Nullable(Int64),+ cache_read_input_tokens Nullable(Int64),+ cache_creation_input_tokens Nullable(Int64),+ web_search_count Nullable(Int64),+ input_cost_usd Nullable(Float64),+ output_cost_usd Nullable(Float64),+ total_cost_usd Nullable(Float64),+ request_cost_usd Nullable(Float64),+ web_search_cost_usd Nullable(Float64),+ audio_cost_usd Nullable(Float64),+ image_cost_usd Nullable(Float64),+ video_cost_usd Nullable(Float64),+ latency Nullable(Float64),+ time_to_first_token Nullable(Float64),+ is_error UInt8,+ error Nullable(String),+ error_type LowCardinality(Nullable(String)),+ error_normalized Nullable(String),+ input Nullable(String),+ output Nullable(String),+ output_choices Nullable(String),+ input_state Nullable(String),+ output_state Nullable(String),+ tools Nullable(String),+ _timestamp DateTime,+ _offset UInt64,+ _partition UInt64+) ENGINE = Distributed('ai_events', 'posthog', 'sharded_ai_events', cityHash64(concat(toString(team_id), '-', trace_id, '-', toString(toDate(timestamp)))));+CREATE TABLE posthog.app_metrics (+ team_id Int64,+ timestamp DateTime64(6, 'UTC'),+ plugin_config_id Int64,+ category LowCardinality(String),+ job_id String,+ successes SimpleAggregateFunction(sum, Int64),+ successes_on_retry SimpleAggregateFunction(sum, Int64),+ failures SimpleAggregateFunction(sum, Int64),+ error_uuid UUID,+ error_type String,+ error_details String CODEC(ZSTD(3)),+ _timestamp DateTime,+ _offset UInt64,+ _partition UInt64+) ENGINE = Distributed('posthog', 'posthog', 'sharded_app_metrics', rand());+CREATE TABLE posthog.app_metrics2 (+ team_id Int64,+ timestamp DateTime64(6, 'UTC'),+ app_source LowCardinality(String),+ app_source_id String,+ instance_id String,+ metric_kind LowCardinality(String),+ metric_name LowCardinality(String),+ count SimpleAggregateFunction(sum, Int64),+ _timestamp DateTime,+ _offset UInt64,+ _partition UInt64+) ENGINE = Distributed('posthog', 'posthog', 'sharded_app_metrics2', rand());+CREATE TABLE posthog.conversion_goal_attributed_preaggregated (+ team_id Int64,+ job_id UUID,+ person_id UUID,+ conversion_timestamp DateTime64(6, 'UTC'),+ conversion_value Float64,+ touchpoint_timestamp DateTime64(6, 'UTC'),+ touchpoint_weight Float64,+ campaign_name String,+ source_name String,+ medium_name String,+ content_name String,+ term_name String,+ referring_domain_name String,+ gclid_name String,+ fbclid_name String,+ gad_source_name String,+ computed_at DateTime64(6, 'UTC') DEFAULT now(),+ expires_at Date DEFAULT today() + toIntervalDay(7)+) ENGINE = Distributed('aux', 'posthog', 'sharded_conversion_goal_attributed_preaggregated', cityHash64(person_id));+CREATE TABLE posthog.distinct_id_usage (+ team_id Int64,+ distinct_id String,+ minute DateTime,+ event_count UInt64+) ENGINE = Distributed('posthog', 'posthog', 'sharded_distinct_id_usage', sipHash64(distinct_id));+CREATE TABLE posthog.distributed_events_recent (+ uuid UUID,+ event String,+ properties String CODEC(ZSTD(3)),+ timestamp DateTime64(6, 'UTC'),+ team_id Int64,+ distinct_id String,+ elements_chain String,+ created_at DateTime64(6, 'UTC'),+ person_id UUID,+ person_created_at DateTime64(3),+ person_properties String CODEC(ZSTD(3)),+ group0_properties String CODEC(ZSTD(3)),+ group1_properties String CODEC(ZSTD(3)),+ group2_properties String CODEC(ZSTD(3)),+ group3_properties String CODEC(ZSTD(3)),+ group4_properties String CODEC(ZSTD(3)),+ group0_created_at DateTime64(3),+ group1_created_at DateTime64(3),+ group2_created_at DateTime64(3),+ group3_created_at DateTime64(3),+ group4_created_at DateTime64(3),+ person_mode Enum8('full'=0, 'propertyless'=1, 'force_upgrade'=2),+ historical_migration Bool,+ _timestamp DateTime,+ _offset UInt64,+ inserted_at DateTime64(6, 'UTC') DEFAULT now64()+) ENGINE = Distributed('posthog_primary_replica', 'posthog', 'sharded_events_recent', sipHash64(distinct_id));+CREATE TABLE posthog.distributed_posthog_document_embeddings (+ team_id Int64,+ product LowCardinality(String),+ document_type LowCardinality(String),+ model_name LowCardinality(String),+ rendering LowCardinality(String),+ document_id String,+ timestamp DateTime64(3, 'UTC'),+ inserted_at DateTime64(3, 'UTC'),+ content String DEFAULT '',+ metadata String DEFAULT '{}',+ embedding Array(Float64),+ _timestamp DateTime,+ _offset UInt64,+ _partition UInt64+) ENGINE = Distributed('posthog', 'posthog', 'partitioned_sharded_posthog_document_embeddings', cityHash64(document_id));+CREATE TABLE posthog.distributed_posthog_document_embeddings_text_embedding_3_large_3072 (+ team_id Int64,+ product LowCardinality(String),+ document_type LowCardinality(String),+ rendering LowCardinality(String),+ document_id String,+ timestamp DateTime64(3, 'UTC'),+ inserted_at DateTime64(3, 'UTC'),+ content String DEFAULT '',+ metadata String DEFAULT '{}',+ embedding Array(Float64),+ _timestamp DateTime,+ _offset UInt64,+ _partition UInt64+) ENGINE = Distributed('posthog', 'posthog', 'sharded_posthog_document_embeddings_text_embedding_3_large_3072', cityHash64(document_id));+CREATE TABLE posthog.distributed_posthog_document_embeddings_text_embedding_3_small_1536 (+ team_id Int64,+ product LowCardinality(String),+ document_type LowCardinality(String),+ rendering LowCardinality(String),+ document_id String,+ timestamp DateTime64(3, 'UTC'),+ inserted_at DateTime64(3, 'UTC'),+ content String DEFAULT '',+ metadata String DEFAULT '{}',+ embedding Array(Float64),+ _timestamp DateTime,+ _offset UInt64,+ _partition UInt64+) ENGINE = Distributed('posthog', 'posthog', 'sharded_posthog_document_embeddings_text_embedding_3_small_1536', cityHash64(document_id));+CREATE TABLE posthog.error_tracking_fingerprint_issue_state (+ team_id Int64,+ fingerprint String,+ issue_id UUID,+ issue_name Nullable(String),+ issue_description Nullable(String),+ issue_status String,+ issue_severity Nullable(String),+ assigned_user_id Nullable(Int64),+ assigned_role_id Nullable(UUID),+ first_seen DateTime64(3, 'UTC'),+ is_deleted Int8,+ version Int64,+ _timestamp DateTime,+ _offset UInt64,+ _partition UInt64+) ENGINE = Distributed('aux', 'posthog', 'raw_error_tracking_fingerprint_issue_state');+CREATE TABLE posthog.events (+ uuid UUID,+ event String,+ properties String CODEC(ZSTD(3)),+ timestamp DateTime64(6, 'UTC'),+ team_id Int64,+ distinct_id String,+ created_at DateTime64(6, 'UTC'),+ $group_0 String COMMENT 'column_materializer::$group_0',+ $group_1 String COMMENT 'column_materializer::$group_1',+ $group_2 String COMMENT 'column_materializer::$group_2',+ $group_3 String COMMENT 'column_materializer::$group_3',+ $group_4 String COMMENT 'column_materializer::$group_4',+ $window_id String COMMENT 'column_materializer::$window_id',+ $session_id String COMMENT 'column_materializer::$session_id',+ inserted_at Nullable(DateTime64(6, 'UTC')) DEFAULT now64(),+ person_mode Enum8('full'=0, 'propertyless'=1, 'force_upgrade'=2),+ elements_chain_href String COMMENT 'column_materializer::elements_chain::href',+ elements_chain_texts Array(String) COMMENT 'column_materializer::elements_chain::texts',+ elements_chain_ids Array(String) COMMENT 'column_materializer::elements_chain::ids',+ elements_chain_elements Array(Enum8('a'=1, 'button'=2, 'form'=3, 'input'=4, 'select'=5, 'textarea'=6, 'label'=7)) COMMENT 'column_materializer::elements_chain::elements',+ properties_group_custom Map(String, String),+ properties_group_feature_flags Map(String, String),+ is_deleted Bool,+ person_properties_map_custom Map(String, String),+ $session_id_uuid Nullable(UInt128),+ consumer_breadcrumbs Array(String),+ properties_group_ai Map(String, String),+ mat_$ai_session_id Nullable(String) COMMENT 'column_materializer::properties::$ai_session_id',+ mat_$ai_is_error Nullable(String) COMMENT 'column_materializer::properties::$ai_is_error',+ dmat_string_0 Nullable(String),+ dmat_string_1 Nullable(String),+ dmat_string_2 Nullable(String),+ dmat_string_3 Nullable(String),+ dmat_string_4 Nullable(String),+ dmat_string_5 Nullable(String),+ dmat_string_6 Nullable(String),+ dmat_string_7 Nullable(String),+ dmat_string_8 Nullable(String),+ dmat_string_9 Nullable(String),+ historical_migration Bool,+ mat_$ai_prompt_name Nullable(String) COMMENT 'column_materializer::properties::$ai_prompt_name',+ elements_chain String,+ person_id UUID,+ person_created_at DateTime64(3),+ person_properties String CODEC(ZSTD(3)),+ group0_properties String CODEC(ZSTD(3)),+ group1_properties String CODEC(ZSTD(3)),+ group2_properties String CODEC(ZSTD(3)),+ group3_properties String CODEC(ZSTD(3)),+ group4_properties String CODEC(ZSTD(3)),+ group0_created_at DateTime64(3),+ group1_created_at DateTime64(3),+ group2_created_at DateTime64(3),+ group3_created_at DateTime64(3),+ group4_created_at DateTime64(3),+ _timestamp DateTime,+ _offset UInt64,+ mat_$ai_trace_id Nullable(String) COMMENT 'column_materializer::properties::$ai_trace_id',+ mat_$ai_experiment_id Nullable(String) COMMENT 'column_materializer::properties::$ai_experiment_id'+) ENGINE = Distributed('posthog', 'posthog', 'sharded_events', sipHash64(distinct_id));+CREATE TABLE posthog.events_json (+ uuid UUID,+ event String,+ properties JSON(max_dynamic_types=8, max_dynamic_paths=256, `$active_feature_flags` Array(String), `$ai_experiment_id` Nullable(String), `$ai_http_status` Nullable(String), `$ai_is_error` Nullable(String), `$ai_model` Nullable(String), `$ai_parent_id` Nullable(String), `$ai_prompt_name` Nullable(String), `$ai_provider` Nullable(String), `$ai_session_id` Nullable(String), `$ai_span_id` Nullable(String), `$ai_total_cost_usd` Nullable(String), `$ai_trace_id` Nullable(String), `$anon_distinct_id` Nullable(String), `$app_build` Nullable(String), `$app_namespace` Nullable(String), `$app_version` Nullable(String), `$browser` Nullable(String), `$browser_version` Nullable(String), `$current_url` Nullable(String), `$device` Nullable(String), `$device_id` Nullable(String), `$device_model` Nullable(String), `$device_type` Nullable(String), `$el_text` Nullable(String), `$event_type` Nullable(String), `$exception_fingerprint` Nullable(String), `$exception_functions` Array(String), `$exception_issue_id` Nullable(String), `$exception_sources` Array(String), `$exception_types` Array(String), `$exception_values` Array(String), `$feature_flag` Nullable(String), `$feature_flag_payloads` Nullable(String), `$feature_flag_response` Nullable(String), `$geoip_city_name` Nullable(String), `$geoip_country_code` Nullable(String), `$geoip_country_name` Nullable(String), `$geoip_subdivision_1_code` Nullable(String), `$group_0` Nullable(String), `$group_1` Nullable(String), `$group_2` Nullable(String), `$group_3` Nullable(String), `$group_4` Nullable(String), `$groups` Nullable(String), `$host` Nullable(String), `$initial_pathname` Nullable(String), `$initial_referrer` Nullable(String), `$initial_referring_domain` Nullable(String), `$ip` Nullable(String), `$is_identified` Nullable(String), `$lib` Nullable(String), `$lib_custom_api_host` Nullable(String), `$lib_version` Nullable(String), `$lib_version__minor` Nullable(String), `$os` Nullable(String), `$os_name` Nullable(String), `$os_version` Nullable(String), `$pathname` Nullable(String), `$prev_pageview_max_content_percentage` Nullable(String), `$prev_pageview_max_scroll_percentage` Nullable(String), `$prev_pageview_pathname` Nullable(String), `$process_person_profile` Nullable(String), `$referrer` Nullable(String), `$referring_domain` Nullable(String), `$screen_height` Nullable(String), `$screen_name` Nullable(String), `$screen_width` Nullable(String), `$sent_at` Nullable(String), `$session_id` Nullable(String), `$survey_id` Nullable(String), `$survey_response` Nullable(String), `$survey_response_1` Nullable(String), `$time` Nullable(String), `$user_id` Nullable(String), `$viewport_height` Nullable(String), `$viewport_width` Nullable(String), `$web_vitals_CLS_value` Nullable(String), `$web_vitals_FCP_value` Nullable(String), `$web_vitals_INP_value` Nullable(String), `$web_vitals_LCP_value` Nullable(String), `$window_id` Nullable(String)),+ timestamp DateTime64(6, 'UTC'),+ team_id Int64,+ distinct_id String,+ elements_hash String DEFAULT '',+ created_at DateTime64(6, 'UTC'),+ _timestamp DateTime,+ _offset UInt64,+ elements_chain String,+ person_id UUID,+ person_properties JSON(max_dynamic_types=6, max_dynamic_paths=32, `$app_version` Nullable(String), `$browser` Nullable(String), `$current_url` Nullable(String), `$geoip_continent_name` Nullable(String), `$geoip_country_code` Nullable(String), `$geoip_country_name` Nullable(String), `$initial_current_url` Nullable(String), `$initial_fbclid` Nullable(String), `$initial_gad_source` Nullable(String), `$initial_gbraid` Nullable(String), `$initial_gclid` Nullable(String), `$initial_msclkid` Nullable(String), `$initial_pathname` Nullable(String), `$initial_referring_domain` Nullable(String), `$initial_utm_campaign` Nullable(String), `$initial_utm_content` Nullable(String), `$initial_utm_medium` Nullable(String), `$initial_utm_source` Nullable(String), `$initial_utm_term` Nullable(String), `$initial_wbraid` Nullable(String), `$os_name` Nullable(String), `$referring_domain` Nullable(String)),+ group0_properties String CODEC(ZSTD(3)),+ group1_properties String CODEC(ZSTD(3)),+ group2_properties String CODEC(ZSTD(3)),+ group3_properties String CODEC(ZSTD(3)),+ group4_properties String CODEC(ZSTD(3)),+ person_created_at DateTime64(3),+ group0_created_at DateTime64(3),+ group1_created_at DateTime64(3),+ group2_created_at DateTime64(3),+ group3_created_at DateTime64(3),+ group4_created_at DateTime64(3),+ inserted_at Nullable(DateTime64(6, 'UTC')) DEFAULT now64(),+ person_mode Enum8('full'=0, 'propertyless'=1, 'force_upgrade'=2),+ is_deleted Bool DEFAULT false,+ consumer_breadcrumbs Array(String),+ historical_migration Bool DEFAULT false,+ $group_0 String,+ $group_1 String,+ $group_2 String,+ $group_3 String,+ $group_4 String,+ $window_id String,+ $session_id String,+ $session_id_uuid Nullable(UInt128),+ elements_chain_href String,+ elements_chain_texts Array(String),+ elements_chain_ids Array(String),+ elements_chain_elements Array(Enum8('a'=1, 'button'=2, 'form'=3, 'input'=4, 'select'=5, 'textarea'=6, 'label'=7))+) ENGINE = Distributed('posthog', 'posthog', 'sharded_events_json', sipHash64(distinct_id));+CREATE TABLE posthog.events_recent (+ uuid UUID,+ event String,+ properties String CODEC(ZSTD(3)),+ timestamp DateTime64(6, 'UTC'),+ team_id Int64,+ distinct_id String,+ elements_chain String,+ created_at DateTime64(6, 'UTC'),+ person_id UUID,+ person_created_at DateTime64(3),+ person_properties String CODEC(ZSTD(3)),+ group0_properties String CODEC(ZSTD(3)),+ group1_properties String CODEC(ZSTD(3)),+ group2_properties String CODEC(ZSTD(3)),+ group3_properties String CODEC(ZSTD(3)),+ group4_properties String CODEC(ZSTD(3)),+ group0_created_at DateTime64(3),+ group1_created_at DateTime64(3),+ group2_created_at DateTime64(3),+ group3_created_at DateTime64(3),+ group4_created_at DateTime64(3),+ person_mode Enum8('full'=0, 'propertyless'=1, 'force_upgrade'=2),+ historical_migration Bool,+ _timestamp DateTime,+ _offset UInt64,+ inserted_at DateTime64(6, 'UTC') DEFAULT now64()+) ENGINE = Distributed('posthog_primary_replica', 'posthog', 'sharded_events_recent', sipHash64(distinct_id));+CREATE TABLE posthog.experiment_exposures_preaggregated (+ team_id Int64,+ job_id UUID,+ entity_id String,+ variant String,+ first_exposure_time DateTime64(6, 'UTC'),+ last_exposure_time DateTime64(6, 'UTC'),+ exposure_event_uuid UUID,+ exposure_session_id String,+ breakdown_value Array(String),+ computed_at DateTime64(6, 'UTC') DEFAULT now(),+ expires_at Date DEFAULT today() + toIntervalDay(7)+) ENGINE = Distributed('posthog', 'posthog', 'sharded_experiment_exposures_preaggregated', cityHash64(entity_id));+CREATE TABLE posthog.experiment_metric_events_preaggregated (+ team_id Int64,+ job_id UUID,+ entity_id String,+ timestamp DateTime64(6, 'UTC'),+ event_uuid UUID,+ session_id String,+ numeric_value Float64 DEFAULT 0,+ steps Array(UInt8) DEFAULT [],+ 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.flag_evaluations (+ uuid UUID,+ event LowCardinality(String),+ properties String,+ timestamp DateTime64(6, 'UTC'),+ team_id Int64,+ distinct_id String,+ created_at DateTime64(6, 'UTC'),+ person_id UUID,+ person_properties String,+ group0_properties String,+ group1_properties String,+ group2_properties String,+ group3_properties String,+ group4_properties String,+ inserted_at DateTime64(6, 'UTC') DEFAULT timestamp,+ $group_0 String COMMENT 'column_materializer::$group_0',+ $group_1 String COMMENT 'column_materializer::$group_1',+ $group_2 String COMMENT 'column_materializer::$group_2',+ $group_3 String COMMENT 'column_materializer::$group_3',+ $group_4 String COMMENT 'column_materializer::$group_4',+ flag_key String COMMENT 'column_materializer::properties::$feature_flag',+ response LowCardinality(String) COMMENT 'column_materializer::properties::$feature_flag_response',+ session_id String COMMENT 'column_materializer::properties::$session_id',+ request_id String COMMENT 'column_materializer::properties::$feature_flag_request_id',+ _timestamp DateTime,+ _offset UInt64,+ _partition UInt64+) ENGINE = Distributed('posthog', 'posthog', 'sharded_flag_evaluations', sipHash64(distinct_id));+CREATE TABLE posthog.heatmaps (+ session_id String,+ team_id Int64,+ distinct_id String,+ timestamp DateTime64(6, 'UTC'),+ x Int16,+ y Int16,+ scale_factor Int16,+ viewport_width Int16,+ viewport_height Int16,+ pointer_target_fixed Bool,+ current_url String,+ type LowCardinality(String),+ _timestamp DateTime,+ _offset UInt64,+ _partition UInt64+) ENGINE = Distributed('posthog', 'posthog', 'sharded_heatmaps', cityHash64(concat(toString(team_id), '-', session_id, '-', toString(toDate(timestamp)))));+CREATE TABLE posthog.hog_invocation_results (+ team_id Int64,+ function_kind LowCardinality(String),+ function_id String,+ invocation_id String,+ parent_run_id String,+ status LowCardinality(String),+ attempts UInt8,+ is_retry UInt8,+ scheduled_at DateTime64(6, 'UTC'),+ first_scheduled_at DateTime64(6, 'UTC'),+ started_at Nullable(DateTime64(6, 'UTC')),+ finished_at Nullable(DateTime64(6, 'UTC')),+ duration_ms Nullable(UInt32),+ error_kind LowCardinality(String),+ error_message String,+ event_uuid String,+ distinct_id String,+ person_id String,+ invocation_globals String,+ version UInt64,+ is_deleted UInt8,+ _timestamp DateTime,+ _offset UInt64,+ _partition UInt64+) ENGINE = Distributed('aux', 'posthog', 'hog_invocation_results_data');+CREATE TABLE posthog.ingestion_warnings (+ team_id Int64,+ source LowCardinality(String),+ type String,+ details String CODEC(ZSTD(3)),+ timestamp DateTime64(6, 'UTC'),+ _timestamp DateTime,+ _offset UInt64,+ _partition UInt64+) ENGINE = Distributed('posthog', 'posthog', 'sharded_ingestion_warnings', rand());+CREATE TABLE posthog.log_entries (+ team_id UInt64,+ log_source LowCardinality(String),+ log_source_id String,+ instance_id String,+ timestamp DateTime64(6, 'UTC'),+ level LowCardinality(String),+ message String,+ _timestamp DateTime,+ _offset UInt64+) ENGINE = Distributed('posthog', 'posthog', 'sharded_log_entries', rand());+CREATE TABLE posthog.logs (+ time_bucket DateTime MATERIALIZED toStartOfDay(timestamp) CODEC(DoubleDelta, ZSTD(1)),+ original_expiry_timestamp DateTime64(6) CODEC(DoubleDelta, ZSTD(1)),+ uuid String CODEC(ZSTD(1)),+ team_id Int32 CODEC(ZSTD(1)),+ trace_id String CODEC(ZSTD(1)),+ span_id String CODEC(ZSTD(1)),+ trace_flags Int32 CODEC(ZSTD(1)),+ timestamp DateTime64(6) CODEC(DoubleDelta, ZSTD(1)),+ observed_timestamp DateTime64(6) CODEC(DoubleDelta, ZSTD(1)),+ created_at DateTime64(6) MATERIALIZED now() CODEC(DoubleDelta, ZSTD(1)),+ body String CODEC(ZSTD(1)),+ severity_text LowCardinality(String) CODEC(ZSTD(1)),+ severity_number Int32 CODEC(ZSTD(1)),+ service_name LowCardinality(String) CODEC(ZSTD(1)),+ resource_attributes Map(LowCardinality(String), String) CODEC(ZSTD(1)),+ resource_fingerprint UInt64 MATERIALIZED cityHash64(resource_attributes) CODEC(DoubleDelta, ZSTD(1)),+ instrumentation_scope String CODEC(ZSTD(1)),+ event_name String CODEC(ZSTD(1)),+ attributes_map_str Map(LowCardinality(String), String) CODEC(ZSTD(1)),+ level String ALIAS severity_text,+ mat_body_ipv4_matches Array(String) ALIAS extractAll(body, '(\\d\\.((25[0-5]|(2[0-4]|1(0, 1)[0-9])(0, 1)[0-9])\\.)(2, 2)([0-9]))'),+ time_minute DateTime ALIAS toStartOfMinute(timestamp),+ attributes Map(LowCardinality(String), String) ALIAS mapApply((k, v) -> (left(k, -5), v), attributes_map_str),+ attributes_map_float Map(LowCardinality(String), Float64) MATERIALIZED mapFilter((k, v) -> (v IS NOT NULL), mapApply((k, v) -> (concat(left(k, -5), '__float'), toFloat64OrNull(v)), attributes_map_str)) CODEC(ZSTD(1)),+ attributes_map_datetime Map(LowCardinality(String), DateTime64(6)) MATERIALIZED mapFilter((k, v) -> (v IS NOT NULL), mapApply((k, v) -> (concat(left(k, -5), '__datetime'), parseDateTimeBestEffortOrNull(v, 6)), attributes_map_str)) CODEC(ZSTD(1)),+ _partition UInt32 CODEC(DoubleDelta, ZSTD(1)),+ _topic String,+ _offset UInt64 CODEC(DoubleDelta, ZSTD(1)),+ _bytes_uncompressed UInt64 CODEC(DoubleDelta, ZSTD(1)),+ _bytes_compressed UInt64 CODEC(DoubleDelta, ZSTD(1)),+ _record_count UInt64 CODEC(DoubleDelta, ZSTD(1))+) ENGINE = Distributed('posthog_single_shard', 'posthog', 'logs32');+CREATE TABLE posthog.marketing_conversions_preaggregated (+ team_id Int64,+ job_id UUID,+ person_id UUID,+ conversion_timestamp DateTime64(6, 'UTC'),+ conversion_math_value Float64,+ session_id String,+ campaign_name String,+ source_name String,+ medium_name String,+ content_name String,+ term_name String,+ referring_domain_name String,+ gclid_name String,+ fbclid_name String,+ gad_source_name String,+ computed_at DateTime64(6, 'UTC') DEFAULT now(),+ expires_at Date DEFAULT today() + toIntervalDay(7)+) ENGINE = Distributed('aux', 'posthog', 'sharded_marketing_conversions_preaggregated', cityHash64(person_id));+CREATE TABLE posthog.marketing_costs_preaggregated (+ team_id Int64,+ job_id UUID,+ source_id String,+ source_name String,+ grain LowCardinality(String),+ match_key String,+ campaign_id String,+ campaign_name String,+ ad_group_id String,+ ad_group_name String,+ ad_id String,+ ad_name String,+ cost_date Date,+ cost Float64,+ clicks Float64,+ impressions Float64,+ reported_conversions Float64,+ reported_conversion_value Float64,+ computed_at DateTime64(6, 'UTC') DEFAULT now(),+ expires_at Date DEFAULT today() + toIntervalDay(7)+) ENGINE = Distributed('aux', 'posthog', 'sharded_marketing_costs_preaggregated', cityHash64(source_name, campaign_id));+CREATE TABLE posthog.marketing_touchpoints_preaggregated (+ team_id Int64,+ job_id UUID,+ person_id UUID,+ touchpoint_timestamp DateTime64(6, 'UTC'),+ campaign_name String,+ source_name String,+ medium_name String,+ content_name String,+ term_name String,+ referring_domain_name String,+ gclid_name String,+ fbclid_name String,+ gad_source_name String,+ computed_at DateTime64(6, 'UTC') DEFAULT now(),+ expires_at Date DEFAULT today() + toIntervalDay(7)+) ENGINE = Distributed('aux', 'posthog', 'sharded_marketing_touchpoints_preaggregated', cityHash64(person_id));+CREATE TABLE posthog.message_assets (+ team_id Int64,+ function_kind LowCardinality(String),+ function_id String,+ parent_run_id String,+ invocation_id String,+ action_id String,+ kind LowCardinality(String),+ distinct_id String,+ person_id String,+ recipient String,+ subject String,+ status LowCardinality(String),+ sent_at DateTime64(6, 'UTC'),+ version UInt64,+ is_deleted UInt8,+ html String,+ _timestamp DateTime,+ _offset UInt64,+ _partition UInt64+) ENGINE = Distributed('aux', 'posthog', 'message_assets_data');+CREATE TABLE posthog.metric_samples (+ team_id Int32,+ metric_name LowCardinality(String),+ series_fingerprint UInt64 CODEC(DoubleDelta),+ timestamp DateTime64(6) CODEC(DoubleDelta),+ value Float64 CODEC(Gorilla(8)),+ count UInt64 DEFAULT 1,+ histogram_bounds Array(Float64),+ histogram_counts Array(UInt64),+ trace_id String,+ span_id String,+ trace_flags Int32+) ENGINE = Distributed('posthog_single_shard', 'posthog', 'metric_samples1');+CREATE TABLE posthog.metric_series (+ team_id Int32,+ metric_name LowCardinality(String),+ series_fingerprint UInt64 CODEC(DoubleDelta),+ metric_type LowCardinality(String),+ unit LowCardinality(String),+ aggregation_temporality LowCardinality(String),+ is_monotonic Bool DEFAULT false,+ service_name LowCardinality(String),+ resource_attributes Map(LowCardinality(String), String),+ attributes Map(LowCardinality(String), String),+ last_seen DateTime64(6) CODEC(DoubleDelta)+) ENGINE = Distributed('posthog_single_shard', 'posthog', 'metric_series1');+CREATE TABLE posthog.performance_events (+ uuid UUID,+ session_id String,+ window_id String,+ pageview_id String,+ distinct_id String,+ timestamp DateTime64(3),+ time_origin DateTime64(3, 'UTC'),+ entry_type LowCardinality(String),+ name String,+ team_id Int64,+ current_url String,+ start_time Float64,+ duration Float64,+ redirect_start Float64,+ redirect_end Float64,+ worker_start Float64,+ fetch_start Float64,+ domain_lookup_start Float64,+ domain_lookup_end Float64,+ connect_start Float64,+ secure_connection_start Float64,+ connect_end Float64,+ request_start Float64,+ response_start Float64,+ response_end Float64,+ decoded_body_size Int64,+ encoded_body_size Int64,+ initiator_type LowCardinality(String),+ next_hop_protocol LowCardinality(String),+ render_blocking_status LowCardinality(String),+ response_status Int64,+ transfer_size Int64,+ largest_contentful_paint_element String,+ largest_contentful_paint_render_time Float64,+ largest_contentful_paint_load_time Float64,+ largest_contentful_paint_size Float64,+ largest_contentful_paint_id String,+ largest_contentful_paint_url String,+ dom_complete Float64,+ dom_content_loaded_event Float64,+ dom_interactive Float64,+ load_event_end Float64,+ load_event_start Float64,+ redirect_count Int64,+ navigation_type LowCardinality(String),+ unload_event_end Float64,+ unload_event_start Float64,+ _timestamp DateTime,+ _offset UInt64,+ _partition UInt64+) ENGINE = Distributed('posthog', 'posthog', 'sharded_performance_events', sipHash64(session_id));+CREATE TABLE posthog.preaggregation_results (+ team_id Int64,+ job_id UUID,+ time_window_start DateTime64(6, 'UTC'),+ expires_at DateTime64(6, 'UTC') DEFAULT now() + toIntervalDay(7),+ breakdown_value Array(String),+ uniq_exact_state AggregateFunction(uniqExact, UUID)+) ENGINE = Distributed('posthog', 'posthog', 'sharded_preaggregation_results', sipHash64(job_id));+CREATE TABLE posthog.precalculated_events (+ team_id Int64,+ date Date,+ distinct_id String,+ person_id UUID,+ condition String,+ uuid UUID,+ source String,+ _timestamp DateTime64(6),+ _partition UInt64,+ _offset UInt64+) ENGINE = Distributed('posthog', 'posthog', 'sharded_precalculated_events', sipHash64(distinct_id));+CREATE TABLE posthog.precalculated_person_properties (+ team_id Int64,+ distinct_id String,+ person_id UUID,+ condition String,+ matches Bool,+ source String,+ _timestamp DateTime64(6),+ _offset UInt64+) ENGINE = Distributed('posthog', 'posthog', 'sharded_precalculated_person_properties', sipHash64(distinct_id));+CREATE TABLE posthog.query_log_archive (+ hostname LowCardinality(String),+ user LowCardinality(String),+ query_id String,+ initial_query_id String,+ is_initial_query UInt8,+ type Enum8('QueryStart'=1, 'QueryFinish'=2, 'ExceptionBeforeStart'=3, 'ExceptionWhileProcessing'=4),+ event_date Date,+ event_time DateTime,+ event_time_microseconds DateTime64(6),+ query_start_time DateTime,+ query_start_time_microseconds DateTime64(6),+ query_duration_ms UInt64,+ read_rows UInt64,+ read_bytes UInt64,+ written_rows UInt64,+ written_bytes UInt64,+ result_rows UInt64,+ result_bytes UInt64,+ memory_usage UInt64,+ peak_threads_usage UInt64,+ current_database LowCardinality(String),+ query String,+ formatted_query String,+ normalized_query_hash UInt64,+ query_kind LowCardinality(String),+ exception_code Int32,+ exception String,+ stack_trace String,+ team_id Int64,+ log_comment JSON(max_dynamic_paths=256, access_method LowCardinality(String), alert_config_id String, api_key_label String, api_key_mask String, batch_export_id String, chargeable Bool, client_query_id String, cohort_id Int64, `dagster.job_name` String, `dagster.run_id` String, `dagster.tags.owner` String, dashboard_id Int64, experiment_feature_flag_key String, experiment_id Int64, feature LowCardinality(String), id String, insight_id Int64, is_impersonated Bool, kind LowCardinality(String), name String, org_id String, person_on_events_mode LowCardinality(String), product LowCardinality(String), query_type LowCardinality(String), request_name String, route_id String, service_name String, session_id String, table_id String, team_id Int64, `temporal.activity_id` String, `temporal.activity_type` String, `temporal.attempt` Int64, `temporal.workflow_id` String, `temporal.workflow_namespace` String, `temporal.workflow_run_id` String, `temporal.workflow_type` String, user_id Int64, warehouse_query Bool, workflow LowCardinality(String), workload LowCardinality(String), SKIP cache_key, SKIP filter, SKIP hogql_features, SKIP http_referer, SKIP http_request_id, SKIP http_user_agent, SKIP query_settings, SKIP timings, SKIP user_email),+ ProfileEvents Map(String, UInt64),+ exception_name String ALIAS errorCodeToName(exception_code),+ ProfileEvents_RealTimeMicroseconds Int64 ALIAS ProfileEvents['RealTimeMicroseconds'],+ ProfileEvents_OSCPUVirtualTimeMicroseconds Int64 ALIAS ProfileEvents['OSCPUVirtualTimeMicroseconds'],+ ProfileEvents_S3Clients Int64 ALIAS ProfileEvents['S3Clients'],+ ProfileEvents_S3DeleteObjects Int64 ALIAS ProfileEvents['S3DeleteObjects'],+ ProfileEvents_S3CopyObject Int64 ALIAS ProfileEvents['S3CopyObject'],+ ProfileEvents_S3ListObjects Int64 ALIAS ProfileEvents['S3ListObjects'],+ ProfileEvents_S3HeadObject Int64 ALIAS ProfileEvents['S3HeadObject'],+ ProfileEvents_S3GetObjectAttributes Int64 ALIAS ProfileEvents['S3GetObjectAttributes'],+ ProfileEvents_S3CreateMultipartUpload Int64 ALIAS ProfileEvents['S3CreateMultipartUpload'],+ ProfileEvents_S3UploadPartCopy Int64 ALIAS ProfileEvents['S3UploadPartCopy'],+ ProfileEvents_S3UploadPart Int64 ALIAS ProfileEvents['S3UploadPart'],+ ProfileEvents_S3AbortMultipartUpload Int64 ALIAS ProfileEvents['S3AbortMultipartUpload'],+ ProfileEvents_S3CompleteMultipartUpload Int64 ALIAS ProfileEvents['S3CompleteMultipartUpload'],+ ProfileEvents_S3PutObject Int64 ALIAS ProfileEvents['S3PutObject'],+ ProfileEvents_S3GetObject Int64 ALIAS ProfileEvents['S3GetObject'],+ ProfileEvents_ReadBufferFromS3Bytes Int64 ALIAS ProfileEvents['ReadBufferFromS3Bytes'],+ ProfileEvents_WriteBufferFromS3Bytes Int64 ALIAS ProfileEvents['WriteBufferFromS3Bytes'],+ lc_workflow LowCardinality(String) ALIAS log_comment.workflow,+ lc_kind LowCardinality(String) ALIAS log_comment.kind,+ lc_id String ALIAS CAST(log_comment.id, 'String'),+ lc_route_id String ALIAS CAST(log_comment.route_id, 'String'),+ lc_access_method LowCardinality(String) ALIAS log_comment.access_method,+ lc_api_key_label String ALIAS CAST(log_comment.api_key_label, 'String'),+ lc_api_key_mask String ALIAS CAST(log_comment.api_key_mask, 'String'),+ lc_query_type LowCardinality(String) ALIAS log_comment.query_type,+ lc_product LowCardinality(String) ALIAS log_comment.product,+ lc_chargeable Bool ALIAS log_comment.chargeable,+ lc_name String ALIAS CAST(log_comment.name, 'String'),+ lc_request_name String ALIAS CAST(log_comment.request_name, 'String'),+ lc_client_query_id String ALIAS CAST(log_comment.client_query_id, 'String'),+ lc_org_id String ALIAS CAST(log_comment.org_id, 'String'),+ lc_user_id Int64 ALIAS log_comment.user_id,+ lc_is_impersonated Bool ALIAS log_comment.is_impersonated,+ lc_session_id String ALIAS CAST(log_comment.session_id, 'String'),+ lc_dashboard_id Int64 ALIAS log_comment.dashboard_id,+ lc_insight_id Int64 ALIAS log_comment.insight_id,+ lc_cohort_id Int64 ALIAS log_comment.cohort_id,+ lc_batch_export_id String ALIAS CAST(log_comment.batch_export_id, 'String'),+ lc_experiment_id Int64 ALIAS log_comment.experiment_id,+ lc_experiment_feature_flag_key String ALIAS CAST(log_comment.experiment_feature_flag_key, 'String'),+ lc_alert_config_id String ALIAS CAST(log_comment.alert_config_id, 'String'),+ lc_feature LowCardinality(String) ALIAS log_comment.feature,+ lc_table_id String ALIAS CAST(log_comment.table_id, 'String'),+ lc_warehouse_query Bool ALIAS log_comment.warehouse_query,+ lc_person_on_events_mode LowCardinality(String) ALIAS log_comment.person_on_events_mode,+ lc_service_name String ALIAS CAST(log_comment.service_name, 'String'),+ lc_workload LowCardinality(String) ALIAS log_comment.workload,+ lc_query__kind LowCardinality(String) ALIAS if(JSONHas(toString(log_comment), 'query', 'source'), JSONExtractString(toString(log_comment), 'query', 'source', 'kind'), JSONExtractString(toString(log_comment), 'query', 'kind')),+ lc_query__query String ALIAS multiIf(NOT is_initial_query, '', JSONHas(toString(log_comment), 'query', 'source'), JSONExtractString(toString(log_comment), 'query', 'source', 'query'), JSONExtractString(toString(log_comment), 'query', 'query')),+ lc_query String ALIAS if(is_initial_query, JSONExtractRaw(toString(log_comment), 'query'), ''),+ lc_temporal__workflow_namespace String ALIAS CAST(log_comment.`temporal.workflow_namespace`, 'String'),+ lc_temporal__workflow_type String ALIAS CAST(log_comment.`temporal.workflow_type`, 'String'),+ lc_temporal__workflow_id String ALIAS CAST(log_comment.`temporal.workflow_id`, 'String'),+ lc_temporal__workflow_run_id String ALIAS CAST(log_comment.`temporal.workflow_run_id`, 'String'),+ lc_temporal__activity_type String ALIAS CAST(log_comment.`temporal.activity_type`, 'String'),+ lc_temporal__activity_id String ALIAS CAST(log_comment.`temporal.activity_id`, 'String'),+ lc_temporal__attempt Int64 ALIAS log_comment.`temporal.attempt`,+ lc_dagster__job_name String ALIAS CAST(log_comment.`dagster.job_name`, 'String'),+ lc_dagster__run_id String ALIAS CAST(log_comment.`dagster.run_id`, 'String'),+ 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.query_log_archive_buffer (+ hostname LowCardinality(String),+ user LowCardinality(String),+ query_id String,+ initial_query_id String,+ is_initial_query UInt8,+ type Enum8('QueryStart'=1, 'QueryFinish'=2, 'ExceptionBeforeStart'=3, 'ExceptionWhileProcessing'=4),+ event_date Date,+ event_time DateTime,+ event_time_microseconds DateTime64(6),+ query_start_time DateTime,+ query_start_time_microseconds DateTime64(6),+ query_duration_ms UInt64,+ read_rows UInt64,+ read_bytes UInt64,+ written_rows UInt64,+ written_bytes UInt64,+ result_rows UInt64,+ result_bytes UInt64,+ memory_usage UInt64,+ peak_threads_usage UInt64,+ current_database LowCardinality(String),+ query String,+ formatted_query String,+ normalized_query_hash UInt64,+ query_kind LowCardinality(String),+ exception_code Int32,+ exception String,+ stack_trace String,+ team_id Int64,+ log_comment JSON(max_dynamic_paths=256, access_method LowCardinality(String), alert_config_id String, api_key_label String, api_key_mask String, batch_export_id String, chargeable Bool, client_query_id String, cohort_id Int64, `dagster.job_name` String, `dagster.run_id` String, `dagster.tags.owner` String, dashboard_id Int64, experiment_feature_flag_key String, experiment_id Int64, feature LowCardinality(String), id String, insight_id Int64, is_impersonated Bool, kind LowCardinality(String), name String, org_id String, person_on_events_mode LowCardinality(String), product LowCardinality(String), query_type LowCardinality(String), request_name String, route_id String, service_name String, session_id String, table_id String, team_id Int64, `temporal.activity_id` String, `temporal.activity_type` String, `temporal.attempt` Int64, `temporal.workflow_id` String, `temporal.workflow_namespace` String, `temporal.workflow_run_id` String, `temporal.workflow_type` String, user_id Int64, warehouse_query Bool, workflow LowCardinality(String), workload LowCardinality(String), SKIP cache_key, SKIP filter, SKIP hogql_features, SKIP http_referer, SKIP http_request_id, SKIP http_user_agent, SKIP query_settings, SKIP timings, SKIP user_email),+ ProfileEvents Map(String, UInt64)+) ENGINE = Buffer('posthog', 'sharded_query_log_archive', 16, 10, 60, 10000, 1000000, 10000000, 100000000);+CREATE TABLE posthog.raw_sessions (+ team_id Int64,+ session_id_v7 UInt128,+ distinct_id AggregateFunction(argMax, String, DateTime64(6, 'UTC')),+ min_timestamp SimpleAggregateFunction(min, DateTime64(6, 'UTC')),+ max_timestamp SimpleAggregateFunction(max, DateTime64(6, 'UTC')),+ max_inserted_at SimpleAggregateFunction(max, DateTime64(6, 'UTC')),+ urls SimpleAggregateFunction(groupUniqArrayArray, Array(String)),+ entry_url AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ end_url AggregateFunction(argMax, String, DateTime64(6, 'UTC')),+ last_external_click_url AggregateFunction(argMax, String, DateTime64(6, 'UTC')),+ initial_browser AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_browser_version AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_os AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_os_version AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_device_type AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_viewport_width AggregateFunction(argMin, Int64, DateTime64(6, 'UTC')),+ initial_viewport_height AggregateFunction(argMin, Int64, DateTime64(6, 'UTC')),+ initial_geoip_country_code AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_geoip_subdivision_1_code AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_geoip_subdivision_1_name AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_geoip_subdivision_city_name AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_geoip_time_zone AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_referring_domain AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_utm_source AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_utm_campaign AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_utm_medium AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_utm_term AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_utm_content AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_gclid AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_gad_source AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_gclsrc AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_dclid AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_gbraid AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_wbraid AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_fbclid AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_msclkid AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_twclid AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_li_fat_id AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_mc_cid AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_igshid AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_ttclid AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_epik AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_qclid AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_sccid AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial__kx AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_irclid AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ pageview_count SimpleAggregateFunction(sum, Int64),+ pageview_uniq AggregateFunction(uniq, Nullable(UUID)),+ autocapture_count SimpleAggregateFunction(sum, Int64),+ autocapture_uniq AggregateFunction(uniq, Nullable(UUID)),+ screen_count SimpleAggregateFunction(sum, Int64),+ screen_uniq AggregateFunction(uniq, Nullable(UUID)),+ maybe_has_session_replay SimpleAggregateFunction(max, Bool),+ page_screen_autocapture_uniq_up_to AggregateFunction(uniqUpTo(1), Nullable(UUID)),+ vitals_lcp AggregateFunction(argMin, Nullable(Float64), DateTime64(6, 'UTC'))+) ENGINE = Distributed('posthog', 'posthog', 'sharded_raw_sessions', cityHash64(session_id_v7));+CREATE TABLE posthog.raw_sessions_v3 (+ team_id Int64,+ session_id_v7 UInt128,+ session_timestamp DateTime64(3) MATERIALIZED fromUnixTimestamp64Milli(toUInt64(bitShiftRight(session_id_v7, 80))),+ distinct_id AggregateFunction(argMax, String, DateTime64(6, 'UTC')),+ distinct_ids AggregateFunction(groupUniqArray, String),+ min_timestamp SimpleAggregateFunction(min, DateTime64(6, 'UTC')),+ max_timestamp SimpleAggregateFunction(max, DateTime64(6, 'UTC')),+ max_inserted_at SimpleAggregateFunction(max, DateTime64(6, 'UTC')),+ urls SimpleAggregateFunction(groupUniqArrayArray(2000), Array(String)),+ entry_url AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC')),+ end_url AggregateFunction(argMax, Nullable(String), DateTime64(6, 'UTC')),+ last_external_click_url AggregateFunction(argMax, Nullable(String), DateTime64(6, 'UTC')),+ browser AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC')),+ browser_version AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC')),+ os AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC')),+ os_version AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC')),+ device_type AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC')),+ viewport_width AggregateFunction(argMin, Nullable(Int64), DateTime64(6, 'UTC')),+ viewport_height AggregateFunction(argMin, Nullable(Int64), DateTime64(6, 'UTC')),+ geoip_country_code AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC')),+ geoip_subdivision_1_code AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC')),+ geoip_subdivision_1_name AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC')),+ geoip_subdivision_city_name AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC')),+ geoip_time_zone AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC')),+ entry_referring_domain AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC')),+ entry_utm_source AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC')),+ entry_utm_campaign AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC')),+ entry_utm_medium AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC')),+ entry_utm_term AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC')),+ entry_utm_content AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC')),+ entry_gclid AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC')),+ entry_gad_source AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC')),+ entry_fbclid AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC')),+ entry_has_gclid AggregateFunction(argMin, Bool, DateTime64(6, 'UTC')),+ entry_has_fbclid AggregateFunction(argMin, Bool, DateTime64(6, 'UTC')),+ entry_ad_ids_map AggregateFunction(argMin, Map(String, String), DateTime64(6, 'UTC')),+ entry_ad_ids_set AggregateFunction(argMin, Array(String), DateTime64(6, 'UTC')),+ entry_channel_type_properties AggregateFunction(argMin, Tuple(Nullable(String), Nullable(String), Nullable(String), Nullable(String), Bool, Bool, Nullable(String)), DateTime64(6, 'UTC')),+ pageview_uniq AggregateFunction(uniqExact, Nullable(UUID)),+ autocapture_uniq AggregateFunction(uniqExact, Nullable(UUID)),+ screen_uniq AggregateFunction(uniqExact, Nullable(UUID)),+ page_screen_uniq_up_to AggregateFunction(uniqUpTo(1), Nullable(UUID)),+ has_autocapture SimpleAggregateFunction(max, Bool),+ flag_values AggregateFunction(groupUniqArrayMap, Map(String, String)),+ flag_keys SimpleAggregateFunction(groupUniqArrayArray, Array(String)),+ event_names SimpleAggregateFunction(groupUniqArrayArray(2000), Array(String)),+ hosts SimpleAggregateFunction(groupUniqArrayArray(100), Array(String)),+ emails SimpleAggregateFunction(groupUniqArrayArray(10), Array(String)),+ has_replay_events SimpleAggregateFunction(max, Bool)+) ENGINE = Distributed('posthog', 'posthog', 'sharded_raw_sessions_v3', cityHash64(session_id_v7));+CREATE TABLE posthog.session_replay_embeddings (+ session_id String,+ team_id Int64,+ embeddings Array(Float32),+ generation_timestamp DateTime64(6, 'UTC') DEFAULT now('UTC'),+ source_type LowCardinality(String),+ input String+) ENGINE = Distributed('posthog', 'posthog', 'sharded_session_replay_embeddings', sipHash64(session_id));+CREATE TABLE posthog.session_replay_events (+ session_id String,+ team_id Int64,+ 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),+ active_milliseconds SimpleAggregateFunction(sum, Int64),+ console_log_count SimpleAggregateFunction(sum, Int64),+ console_warn_count SimpleAggregateFunction(sum, Int64),+ console_error_count SimpleAggregateFunction(sum, Int64),+ size SimpleAggregateFunction(sum, Int64),+ message_count SimpleAggregateFunction(sum, Int64),+ event_count SimpleAggregateFunction(sum, Int64),+ snapshot_source AggregateFunction(argMin, LowCardinality(Nullable(String)), DateTime64(6, 'UTC')),+ snapshot_library AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC')),+ _timestamp SimpleAggregateFunction(max, DateTime),+ 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))+) ENGINE = Distributed('posthog', 'posthog', 'sharded_session_replay_events', sipHash64(distinct_id));+CREATE TABLE posthog.session_replay_features (+ session_id String,+ team_id Int64,+ distinct_id String,+ min_first_timestamp SimpleAggregateFunction(min, DateTime64(6, 'UTC')),+ max_last_timestamp SimpleAggregateFunction(max, DateTime64(6, 'UTC')),+ event_count SimpleAggregateFunction(sum, Int64),+ mouse_position_count SimpleAggregateFunction(sum, Int64),+ mouse_sum_x SimpleAggregateFunction(sum, Float64),+ mouse_sum_x_squared SimpleAggregateFunction(sum, Float64),+ mouse_sum_y SimpleAggregateFunction(sum, Float64),+ mouse_sum_y_squared SimpleAggregateFunction(sum, Float64),+ mouse_distance_traveled SimpleAggregateFunction(sum, Float64),+ mouse_direction_change_count SimpleAggregateFunction(sum, Int64),+ mouse_velocity_sum SimpleAggregateFunction(sum, Float64),+ mouse_velocity_sum_of_squares SimpleAggregateFunction(sum, Float64),+ mouse_velocity_count SimpleAggregateFunction(sum, Int64),+ scroll_event_count SimpleAggregateFunction(sum, Int64),+ total_scroll_magnitude SimpleAggregateFunction(sum, Float64),+ scroll_direction_reversal_count SimpleAggregateFunction(sum, Int64),+ rapid_scroll_reversal_count SimpleAggregateFunction(sum, Int64),+ scroll_to_top_count SimpleAggregateFunction(sum, Int64),+ click_count SimpleAggregateFunction(sum, Int64),+ keypress_count SimpleAggregateFunction(sum, Int64),+ mouse_activity_count SimpleAggregateFunction(sum, Int64),+ rage_click_count SimpleAggregateFunction(sum, Int64),+ dead_click_count SimpleAggregateFunction(sum, Int64),+ backspace_count SimpleAggregateFunction(sum, Int64),+ inter_action_gap_count SimpleAggregateFunction(sum, Int64),+ inter_action_gap_sum_ms SimpleAggregateFunction(sum, Float64),+ inter_action_gap_sum_of_squares_ms SimpleAggregateFunction(sum, Float64),+ max_idle_gap_ms SimpleAggregateFunction(max, Float64),+ long_idle_gap_count SimpleAggregateFunction(sum, Int64),+ quick_back_count SimpleAggregateFunction(sum, Int64),+ page_visit_count SimpleAggregateFunction(sum, Int64),+ unique_url_count AggregateFunction(uniqCombined(12), String),+ login_path_visit_count SimpleAggregateFunction(sum, Int64),+ signup_path_visit_count SimpleAggregateFunction(sum, Int64),+ checkout_path_visit_count SimpleAggregateFunction(sum, Int64),+ cart_path_visit_count SimpleAggregateFunction(sum, Int64),+ billing_path_visit_count SimpleAggregateFunction(sum, Int64),+ settings_path_visit_count SimpleAggregateFunction(sum, Int64),+ account_path_visit_count SimpleAggregateFunction(sum, Int64),+ error_path_visit_count SimpleAggregateFunction(sum, Int64),+ not_found_path_visit_count SimpleAggregateFunction(sum, Int64),+ admin_path_visit_count SimpleAggregateFunction(sum, Int64),+ dashboard_path_visit_count SimpleAggregateFunction(sum, Int64),+ onboarding_path_visit_count SimpleAggregateFunction(sum, Int64),+ cancel_path_visit_count SimpleAggregateFunction(sum, Int64),+ refund_path_visit_count SimpleAggregateFunction(sum, Int64),+ console_error_count SimpleAggregateFunction(sum, Int64),+ console_error_after_click_count SimpleAggregateFunction(sum, Int64),+ console_warn_count SimpleAggregateFunction(sum, Int64),+ network_request_count SimpleAggregateFunction(sum, Int64),+ network_failed_request_count SimpleAggregateFunction(sum, Int64),+ network_4xx_count SimpleAggregateFunction(sum, Int64),+ network_5xx_count SimpleAggregateFunction(sum, Int64),+ network_request_duration_sum SimpleAggregateFunction(sum, Float64),+ network_request_duration_sum_of_squares SimpleAggregateFunction(sum, Float64),+ network_request_duration_count SimpleAggregateFunction(sum, Int64),+ mutation_count SimpleAggregateFunction(sum, Int64),+ viewport_resize_count SimpleAggregateFunction(sum, Int64),+ touch_event_count SimpleAggregateFunction(sum, Int64),+ max_scroll_y SimpleAggregateFunction(max, Float64),+ unique_click_target_count AggregateFunction(uniqCombined(12), Int64),+ unique_form_field_count AggregateFunction(uniqCombined(12), Int64),+ text_selection_count SimpleAggregateFunction(sum, Int64),+ selection_copy_count SimpleAggregateFunction(sum, Int64),+ is_deleted SimpleAggregateFunction(max, UInt8) DEFAULT 0+) ENGINE = Distributed('aux', 'posthog', 'sharded_session_replay_features', sipHash64(session_id));+CREATE TABLE posthog.sessions (+ session_id String,+ team_id Int64,+ distinct_id SimpleAggregateFunction(any, String),+ min_timestamp SimpleAggregateFunction(min, DateTime64(6, 'UTC')),+ max_timestamp SimpleAggregateFunction(max, DateTime64(6, 'UTC')),+ urls SimpleAggregateFunction(groupUniqArrayArray, Array(String)),+ entry_url AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ exit_url AggregateFunction(argMax, String, DateTime64(6, 'UTC')),+ initial_referring_domain AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_utm_source AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_utm_campaign AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_utm_medium AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_utm_term AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_utm_content AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_gclid AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_gad_source AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_gclsrc AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_dclid AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_gbraid AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_wbraid AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_fbclid AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_msclkid AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_twclid AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_li_fat_id AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_mc_cid AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_igshid AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_ttclid AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_epik AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_qclid AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_sccid AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ event_count_map SimpleAggregateFunction(sumMap, Map(String, Int64)),+ pageview_count SimpleAggregateFunction(sum, Int64),+ autocapture_count SimpleAggregateFunction(sum, Int64)+) ENGINE = Distributed('posthog', 'posthog', 'sharded_sessions', sipHash64(session_id));+CREATE TABLE posthog.writable_query_log_archive (+ hostname LowCardinality(String),+ user LowCardinality(String),+ query_id String,+ initial_query_id String,+ is_initial_query UInt8,+ type Enum8('QueryStart'=1, 'QueryFinish'=2, 'ExceptionBeforeStart'=3, 'ExceptionWhileProcessing'=4),+ event_date Date,+ event_time DateTime,+ event_time_microseconds DateTime64(6),+ query_start_time DateTime,+ query_start_time_microseconds DateTime64(6),+ query_duration_ms UInt64,+ read_rows UInt64,+ read_bytes UInt64,+ written_rows UInt64,+ written_bytes UInt64,+ result_rows UInt64,+ result_bytes UInt64,+ memory_usage UInt64,+ peak_threads_usage UInt64,+ current_database LowCardinality(String),+ query String,+ formatted_query String,+ normalized_query_hash UInt64,+ query_kind LowCardinality(String),+ exception_code Int32,+ exception String,+ stack_trace String,+ team_id Int64,+ log_comment JSON(max_dynamic_paths=256, access_method LowCardinality(String), alert_config_id String, api_key_label String, api_key_mask String, batch_export_id String, chargeable Bool, client_query_id String, cohort_id Int64, `dagster.job_name` String, `dagster.run_id` String, `dagster.tags.owner` String, dashboard_id Int64, experiment_feature_flag_key String, experiment_id Int64, feature LowCardinality(String), id String, insight_id Int64, is_impersonated Bool, kind LowCardinality(String), name String, org_id String, person_on_events_mode LowCardinality(String), product LowCardinality(String), query_type LowCardinality(String), request_name String, route_id String, service_name String, session_id String, table_id String, team_id Int64, `temporal.activity_id` String, `temporal.activity_type` String, `temporal.attempt` Int64, `temporal.workflow_id` String, `temporal.workflow_namespace` String, `temporal.workflow_run_id` String, `temporal.workflow_type` String, user_id Int64, warehouse_query Bool, workflow LowCardinality(String), workload LowCardinality(String), SKIP cache_key, SKIP filter, SKIP hogql_features, SKIP http_referer, SKIP http_request_id, SKIP http_user_agent, SKIP query_settings, SKIP timings, SKIP user_email),+ ProfileEvents Map(String, UInt64)+) ENGINE = Distributed('ops', 'posthog', 'query_log_archive_buffer');+CREATE MATERIALIZED VIEW posthog.ai_events_json_mv TO posthog.ai_events (uuid UUID, event String, timestamp DateTime64(6, 'UTC'), team_id Int64, distinct_id String, person_id UUID, properties String, trace_id String, session_id Nullable(String), parent_id Nullable(String), span_id Nullable(String), span_type Nullable(String), generation_id Nullable(String), experiment_id Nullable(String), span_name Nullable(String), trace_name Nullable(String), prompt_name Nullable(String), model Nullable(String), provider Nullable(String), framework Nullable(String), total_tokens Nullable(Int64), input_tokens Nullable(Int64), output_tokens Nullable(Int64), text_input_tokens Nullable(Int64), text_output_tokens Nullable(Int64), image_input_tokens Nullable(Int64), image_output_tokens Nullable(Int64), audio_input_tokens Nullable(Int64), audio_output_tokens Nullable(Int64), video_input_tokens Nullable(Int64), video_output_tokens Nullable(Int64), reasoning_tokens Nullable(Int64), cache_read_input_tokens Nullable(Int64), cache_creation_input_tokens Nullable(Int64), web_search_count Nullable(Int64), input_cost_usd Nullable(Float64), output_cost_usd Nullable(Float64), total_cost_usd Nullable(Float64), request_cost_usd Nullable(Float64), web_search_cost_usd Nullable(Float64), audio_cost_usd Nullable(Float64), image_cost_usd Nullable(Float64), video_cost_usd Nullable(Float64), latency Nullable(Float64), time_to_first_token Nullable(Float64), is_error UInt8, error Nullable(String), error_type Nullable(String), error_normalized Nullable(String), input Nullable(String), output Nullable(String), output_choices Nullable(String), input_state Nullable(String), output_state Nullable(String), tools Nullable(String), _timestamp Nullable(DateTime), _offset UInt64, _partition UInt64) AS SELECT+ uuid,+ event,+ timestamp,+ team_id,+ distinct_id,+ person_id,+ concat(+ '{',+ arrayStringConcat(+ arrayMap(+ x -> concat('"', x.1, '":', x.2),+ arrayFilter(+ x -> ((x.1) NOT IN ('$ai_input', '$ai_output', '$ai_output_choices', '$ai_input_state', '$ai_output_state', '$ai_tools')),+ JSONExtractKeysAndValuesRaw(src.properties)+ )+ ),+ ','+ ),+ '}'+ ) AS properties,+ JSONExtractString(src.properties, '$ai_trace_id') AS trace_id,+ JSONExtract(src.properties, '$ai_session_id', 'Nullable(String)') AS session_id,+ JSONExtract(src.properties, '$ai_parent_id', 'Nullable(String)') AS parent_id,+ JSONExtract(src.properties, '$ai_span_id', 'Nullable(String)') AS span_id,+ JSONExtract(src.properties, '$ai_span_type', 'Nullable(String)') AS span_type,+ JSONExtract(src.properties, '$ai_generation_id', 'Nullable(String)') AS generation_id,+ JSONExtract(src.properties, '$ai_experiment_id', 'Nullable(String)') AS experiment_id,+ JSONExtract(src.properties, '$ai_span_name', 'Nullable(String)') AS span_name,+ JSONExtract(src.properties, '$ai_trace_name', 'Nullable(String)') AS trace_name,+ JSONExtract(src.properties, '$ai_prompt_name', 'Nullable(String)') AS prompt_name,+ JSONExtract(src.properties, '$ai_model', 'Nullable(String)') AS model,+ JSONExtract(src.properties, '$ai_provider', 'Nullable(String)') AS provider,+ JSONExtract(src.properties, '$ai_framework', 'Nullable(String)') AS framework,+ JSONExtract(src.properties, '$ai_total_tokens', 'Nullable(Int64)') AS total_tokens,+ JSONExtract(src.properties, '$ai_input_tokens', 'Nullable(Int64)') AS input_tokens,+ JSONExtract(src.properties, '$ai_output_tokens', 'Nullable(Int64)') AS output_tokens,+ JSONExtract(src.properties, '$ai_text_input_tokens', 'Nullable(Int64)') AS text_input_tokens,+ JSONExtract(src.properties, '$ai_text_output_tokens', 'Nullable(Int64)') AS text_output_tokens,+ JSONExtract(src.properties, '$ai_image_input_tokens', 'Nullable(Int64)') AS image_input_tokens,+ JSONExtract(src.properties, '$ai_image_output_tokens', 'Nullable(Int64)') AS image_output_tokens,+ JSONExtract(src.properties, '$ai_audio_input_tokens', 'Nullable(Int64)') AS audio_input_tokens,+ JSONExtract(src.properties, '$ai_audio_output_tokens', 'Nullable(Int64)') AS audio_output_tokens,+ JSONExtract(src.properties, '$ai_video_input_tokens', 'Nullable(Int64)') AS video_input_tokens,+ JSONExtract(src.properties, '$ai_video_output_tokens', 'Nullable(Int64)') AS video_output_tokens,+ JSONExtract(src.properties, '$ai_reasoning_tokens', 'Nullable(Int64)') AS reasoning_tokens,+ JSONExtract(src.properties, '$ai_cache_read_input_tokens', 'Nullable(Int64)') AS cache_read_input_tokens,+ JSONExtract(src.properties, '$ai_cache_creation_input_tokens', 'Nullable(Int64)') AS cache_creation_input_tokens,+ JSONExtract(src.properties, '$ai_web_search_count', 'Nullable(Int64)') AS web_search_count,+ JSONExtract(src.properties, '$ai_input_cost_usd', 'Nullable(Float64)') AS input_cost_usd,+ JSONExtract(src.properties, '$ai_output_cost_usd', 'Nullable(Float64)') AS output_cost_usd,+ JSONExtract(src.properties, '$ai_total_cost_usd', 'Nullable(Float64)') AS total_cost_usd,+ JSONExtract(src.properties, '$ai_request_cost_usd', 'Nullable(Float64)') AS request_cost_usd,+ JSONExtract(src.properties, '$ai_web_search_cost_usd', 'Nullable(Float64)') AS web_search_cost_usd,+ JSONExtract(src.properties, '$ai_audio_cost_usd', 'Nullable(Float64)') AS audio_cost_usd,+ JSONExtract(src.properties, '$ai_image_cost_usd', 'Nullable(Float64)') AS image_cost_usd,+ JSONExtract(src.properties, '$ai_video_cost_usd', 'Nullable(Float64)') AS video_cost_usd,+ JSONExtract(src.properties, '$ai_latency', 'Nullable(Float64)') AS latency,+ JSONExtract(src.properties, '$ai_time_to_first_token', 'Nullable(Float64)') AS time_to_first_token,+ if((JSONExtractRaw(src.properties, '$ai_is_error') IN ('true', '"true"')), 1, 0) AS is_error,+ JSONExtract(src.properties, '$ai_error', 'Nullable(String)') AS error,+ JSONExtract(src.properties, '$ai_error_type', 'Nullable(String)') AS error_type,+ JSONExtract(src.properties, '$ai_error_normalized', 'Nullable(String)') AS error_normalized,+ nullIf(JSONExtractRaw(src.properties, '$ai_input'), '') AS input,+ nullIf(JSONExtractRaw(src.properties, '$ai_output'), '') AS output,+ nullIf(JSONExtractRaw(src.properties, '$ai_output_choices'), '') AS output_choices,+ nullIf(JSONExtractRaw(src.properties, '$ai_input_state'), '') AS input_state,+ nullIf(JSONExtractRaw(src.properties, '$ai_output_state'), '') AS output_state,+ nullIf(JSONExtractRaw(src.properties, '$ai_tools'), '') AS tools,+ _timestamp,+ _offset,+ _partition+FROM posthog.kafka_ai_events_json AS src;+CREATE MATERIALIZED VIEW posthog.ops_query_log_archive_mv TO posthog.writable_query_log_archive (hostname LowCardinality(String), user LowCardinality(String), query_id String, initial_query_id String, is_initial_query UInt8, type Enum8('QueryStart'=1, 'QueryFinish'=2, 'ExceptionBeforeStart'=3, 'ExceptionWhileProcessing'=4), event_date Date, event_time DateTime, event_time_microseconds DateTime64(6), query_start_time DateTime, query_start_time_microseconds DateTime64(6), query_duration_ms UInt64, read_rows UInt64, read_bytes UInt64, written_rows UInt64, written_bytes UInt64, result_rows UInt64, result_bytes UInt64, memory_usage UInt64, peak_threads_usage UInt64, current_database LowCardinality(String), query String, formatted_query String, normalized_query_hash UInt64, query_kind LowCardinality(String), exception_code Int32, exception String, stack_trace String, team_id Int64, log_comment String, ProfileEvents Map(LowCardinality(String), UInt64)) AS SELECT+ hostname,+ user,+ query_id,+ initial_query_id,+ is_initial_query,+ type,+ event_date,+ event_time,+ event_time_microseconds,+ query_start_time,+ query_start_time_microseconds,+ query_duration_ms,+ read_rows,+ read_bytes,+ written_rows,+ written_bytes,+ result_rows,+ result_bytes,+ memory_usage,+ peak_threads_usage,+ current_database,+ query,+ formatted_query,+ normalized_query_hash,+ query_kind,+ exception_code,+ exception,+ stack_trace,+ JSONExtractInt(log_comment, 'team_id') AS team_id,+ if(isValidJSON(log_comment), log_comment, '{}') AS log_comment,+ ProfileEvents+FROM system.query_log+WHERE type != 'QueryStart';+CREATE VIEW posthog.custom_metrics AS SELECT * REPLACE(toFloat64(value) AS value)+FROM posthog.custom_metrics_test+UNION ALL+SELECT * REPLACE(toFloat64(value) AS value)+FROM posthog.custom_metrics_replication_queue+UNION ALL+SELECT * REPLACE(toFloat64(value) AS value)+FROM posthog.custom_metrics_server_crash+UNION ALL+SELECT *+FROM posthog.custom_metrics_table_sizes+UNION ALL+SELECT * REPLACE(toFloat64(value) AS value)+FROM posthog.custom_metrics_part_counts+UNION ALL+SELECT * REPLACE(toFloat64(value) AS value)+FROM posthog.custom_metrics_dictionaries+UNION ALL+SELECT+ 'ClickHouseCustomMetric_S3DiskBytesUsed' AS name,+ map('instance', hostname(), 'disk', disk_name) AS labels,+ toFloat64(sum(bytes_on_disk)) AS value,+ 'Bytes currently used by ClickHouse parts on S3-backed disks on this node' AS help,+ 'gauge' AS type+FROM system.parts+WHERE disk_name IN ('s3disk', 'cache')+GROUP BY+ disk_name+UNION ALL+SELECT+ 'ClickHouseCustomMetric_MergeFailures15m' AS name,+ map('instance', hostname()) AS labels,+ toFloat64(count()) AS value,+ 'Number of failed merge operations in the last 15 minutes' AS help,+ 'gauge' AS type+FROM system.part_log+WHERE+ (event_time >= (now() - toIntervalMinute(15)))+AND+ (event_type = 'MergeParts')+AND+ (error > 0)+AND+ (merge_reason != 'NotAMerge')+AND+ (error != 40)+UNION ALL+SELECT+ 'ClickHouseCustomMetric_MergeRetriesMaxPerTable15m' AS name,+ map('instance', hostname()) AS labels,+ toFloat64(max(cnt)) AS value,+ 'Max failed merge retries for any single table in the last 15 minutes' AS help,+ 'gauge' AS type+FROM+ (+ SELECT count() AS cnt+ FROM system.part_log+ WHERE+ (event_time >= (now() - toIntervalMinute(15)))+ AND+ (event_type = 'MergeParts')+ AND+ (error > 0)+ AND+ (merge_reason != 'NotAMerge')+ AND+ (error != 40)+ GROUP BY+ database, `table`, partition_id+ );+CREATE VIEW posthog.events_batch_export AS SELECT+ team_id AS team_id,+ timestamp AS timestamp,+ event AS event,+ distinct_id AS distinct_id,+ toString(uuid) AS uuid,+ coalesce(inserted_at, _timestamp) AS _inserted_at,+ created_at AS created_at,+ elements_chain AS elements_chain,+ toString(person_id) AS person_id,+ nullIf(properties, '') AS properties,+ nullIf(person_properties, '') AS person_properties,+ nullIf(JSONExtractString(properties, '$set'), '') AS set,+ nullIf(JSONExtractString(properties, '$set_once'), '') AS set_once+FROM posthog.events+PREWHERE+ (coalesce(events.inserted_at, events._timestamp) >= {interval_start: DateTime64}) AND (coalesce(events.inserted_at, events._timestamp) < {interval_end: DateTime64})+WHERE+ (team_id = {team_id: Int64})+AND+ (events.timestamp >= ({interval_start: DateTime64} - toIntervalDay({lookback_days: Int32})))+AND+ (events.timestamp < ({interval_end: DateTime64} + toIntervalDay(1)))+AND+ ((length({include_events: Array(String)}) = 0) OR (event IN ({include_events: Array(String)})))+AND+ ((length({exclude_events: Array(String)}) = 0) OR (event NOT IN ({exclude_events: Array(String)})))+ORDER BY _inserted_at ASC, event ASC+LIMIT 1 BY team_id, event, cityHash64(events.distinct_id), cityHash64(events.uuid)+SETTINGS+ optimize_aggregation_in_order = 1;+CREATE VIEW posthog.events_batch_export_backfill AS SELECT+ team_id AS team_id,+ timestamp AS timestamp,+ event AS event,+ distinct_id AS distinct_id,+ toString(uuid) AS uuid,+ timestamp AS _inserted_at,+ created_at AS created_at,+ elements_chain AS elements_chain,+ toString(person_id) AS person_id,+ nullIf(properties, '') AS properties,+ nullIf(person_properties, '') AS person_properties,+ nullIf(JSONExtractString(properties, '$set'), '') AS set,+ nullIf(JSONExtractString(properties, '$set_once'), '') AS set_once+FROM posthog.events+WHERE+ (team_id = {team_id: Int64})+AND+ (events.timestamp >= {interval_start: DateTime64})+AND+ (events.timestamp < {interval_end: DateTime64})+AND+ ((length({include_events: Array(String)}) = 0) OR (event IN ({include_events: Array(String)})))+AND+ ((length({exclude_events: Array(String)}) = 0) OR (event NOT IN ({exclude_events: Array(String)})))+ORDER BY _inserted_at ASC, event ASC+LIMIT 1 BY team_id, event, cityHash64(events.distinct_id), cityHash64(events.uuid)+SETTINGS+ optimize_aggregation_in_order = 1;+CREATE VIEW posthog.events_batch_export_recent AS SELECT+ team_id AS team_id,+ timestamp AS timestamp,+ event AS event,+ distinct_id AS distinct_id,+ toString(uuid) AS uuid,+ inserted_at AS _inserted_at,+ created_at AS created_at,+ elements_chain AS elements_chain,+ toString(person_id) AS person_id,+ nullIf(properties, '') AS properties,+ nullIf(person_properties, '') AS person_properties,+ nullIf(JSONExtractString(properties, '$set'), '') AS set,+ nullIf(JSONExtractString(properties, '$set_once'), '') AS set_once+FROM posthog.events_recent+PREWHERE+ (events_recent.inserted_at >= {interval_start: DateTime64}) AND (events_recent.inserted_at < {interval_end: DateTime64})+WHERE+ (team_id = {team_id: Int64})+AND+ ((length({include_events: Array(String)}) = 0) OR (event IN ({include_events: Array(String)})))+AND+ ((length({exclude_events: Array(String)}) = 0) OR (event NOT IN ({exclude_events: Array(String)})))+ORDER BY _inserted_at ASC, event ASC+LIMIT 1 BY team_id, event, cityHash64(events_recent.distinct_id), cityHash64(events_recent.uuid)+SETTINGS+ optimize_aggregation_in_order = 1;+CREATE VIEW posthog.events_batch_export_unbounded AS SELECT+ team_id AS team_id,+ timestamp AS timestamp,+ event AS event,+ distinct_id AS distinct_id,+ toString(uuid) AS uuid,+ coalesce(inserted_at, _timestamp) AS _inserted_at,+ created_at AS created_at,+ elements_chain AS elements_chain,+ toString(person_id) AS person_id,+ nullIf(properties, '') AS properties,+ nullIf(person_properties, '') AS person_properties,+ nullIf(JSONExtractString(properties, '$set'), '') AS set,+ nullIf(JSONExtractString(properties, '$set_once'), '') AS set_once+FROM posthog.events+PREWHERE+ (coalesce(events.inserted_at, events._timestamp) >= {interval_start: DateTime64}) AND (coalesce(events.inserted_at, events._timestamp) < {interval_end: DateTime64})+WHERE+ (team_id = {team_id: Int64})+AND+ ((length({include_events: Array(String)}) = 0) OR (event IN ({include_events: Array(String)})))+AND+ ((length({exclude_events: Array(String)}) = 0) OR (event NOT IN ({exclude_events: Array(String)})))+ORDER BY _inserted_at ASC, event ASC+LIMIT 1 BY team_id, event, cityHash64(events.distinct_id), cityHash64(events.uuid)+SETTINGS+ optimize_aggregation_in_order = 1;+CREATE VIEW posthog.posthog_document_embeddings_union_view AS SELECT+ team_id,+ product,+ document_type,+ rendering,+ document_id,+ timestamp,+ inserted_at,+ content,+ metadata,+ embedding,+ _timestamp,+ _offset,+ _partition,+ 'text-embedding-3-small-1536' AS model_name+FROM posthog.distributed_posthog_document_embeddings_text_embedding_3_small_1536+UNION ALL+SELECT+ team_id,+ product,+ document_type,+ rendering,+ document_id,+ timestamp,+ inserted_at,+ content,+ metadata,+ embedding,+ _timestamp,+ _offset,+ _partition,+ 'text-embedding-3-large-3072' AS model_name+FROM posthog.distributed_posthog_document_embeddings_text_embedding_3_large_3072;+CREATE VIEW posthog.raw_sessions_v AS SELECT+ session_id_v7,+ fromUnixTimestamp(intDiv(toUInt64(bitShiftRight(session_id_v7, 80)), 1000)) AS session_timestamp,+ team_id,+ argMaxMerge(distinct_id) AS distinct_id,+ min(min_timestamp) AS min_timestamp,+ max(max_timestamp) AS max_timestamp,+ max(max_inserted_at) AS max_inserted_at,+ arrayDistinct(arrayFlatten(groupArray(urls))) AS urls,+ argMinMerge(entry_url) AS entry_url,+ argMaxMerge(end_url) AS end_url,+ argMaxMerge(last_external_click_url) AS last_external_click_url,+ argMinMerge(initial_browser) AS initial_browser,+ argMinMerge(initial_browser_version) AS initial_browser_version,+ argMinMerge(initial_os) AS initial_os,+ argMinMerge(initial_os_version) AS initial_os_version,+ argMinMerge(initial_device_type) AS initial_device_type,+ argMinMerge(initial_viewport_width) AS initial_viewport_width,+ argMinMerge(initial_viewport_height) AS initial_viewport_height,+ argMinMerge(initial_geoip_country_code) AS initial_geoip_country_code,+ argMinMerge(initial_geoip_subdivision_1_code) AS initial_geoip_subdivision_1_code,+ argMinMerge(initial_geoip_subdivision_1_name) AS initial_geoip_subdivision_1_name,+ argMinMerge(initial_geoip_subdivision_city_name) AS initial_geoip_subdivision_city_name,+ argMinMerge(initial_geoip_time_zone) AS initial_geoip_time_zone,+ argMinMerge(initial_utm_source) AS initial_utm_source,+ argMinMerge(initial_utm_campaign) AS initial_utm_campaign,+ argMinMerge(initial_utm_medium) AS initial_utm_medium,+ argMinMerge(initial_utm_term) AS initial_utm_term,+ argMinMerge(initial_utm_content) AS initial_utm_content,+ argMinMerge(initial_referring_domain) AS initial_referring_domain,+ argMinMerge(initial_gclid) AS initial_gclid,+ argMinMerge(initial_gad_source) AS initial_gad_source,+ argMinMerge(initial_gclsrc) AS initial_gclsrc,+ argMinMerge(initial_dclid) AS initial_dclid,+ argMinMerge(initial_gbraid) AS initial_gbraid,+ argMinMerge(initial_wbraid) AS initial_wbraid,+ argMinMerge(initial_fbclid) AS initial_fbclid,+ argMinMerge(initial_msclkid) AS initial_msclkid,+ argMinMerge(initial_twclid) AS initial_twclid,+ argMinMerge(initial_li_fat_id) AS initial_li_fat_id,+ argMinMerge(initial_mc_cid) AS initial_mc_cid,+ argMinMerge(initial_igshid) AS initial_igshid,+ argMinMerge(initial_ttclid) AS initial_ttclid,+ argMinMerge(initial__kx) AS initial__kx,+ argMinMerge(initial_irclid) AS initial_irclid,+ sum(pageview_count) AS pageview_count,+ uniqMerge(pageview_uniq) AS pageview_uniq,+ sum(autocapture_count) AS autocapture_count,+ uniqMerge(autocapture_uniq) AS autocapture_uniq,+ sum(screen_count) AS screen_count,+ uniqMerge(screen_uniq) AS screen_uniq,+ max(maybe_has_session_replay) AS maybe_has_session_replay,+ uniqUpToMerge(1)(page_screen_autocapture_uniq_up_to) AS page_screen_autocapture_uniq_up_to,+ argMinMerge(vitals_lcp) AS vitals_lcp+FROM posthog.raw_sessions+GROUP BY+ session_id_v7, team_id;+CREATE VIEW posthog.raw_sessions_v3_v AS SELECT+ session_id_v7,+ session_timestamp,+ team_id,+ argMaxMerge(distinct_id) AS distinct_id,+ groupUniqArrayMerge(distinct_ids) AS distinct_ids,+ min(min_timestamp) AS min_timestamp,+ max(max_timestamp) AS max_timestamp,+ max(max_inserted_at) AS max_inserted_at,+ groupUniqArrayArray(2000)(urls) AS urls,+ argMinMerge(entry_url) AS entry_url,+ argMaxMerge(end_url) AS end_url,+ argMaxMerge(last_external_click_url) AS last_external_click_url,+ argMinMerge(browser) AS browser,+ argMinMerge(browser_version) AS browser_version,+ argMinMerge(os) AS os,+ argMinMerge(os_version) AS os_version,+ argMinMerge(device_type) AS device_type,+ argMinMerge(viewport_width) AS viewport_width,+ argMinMerge(viewport_height) AS viewport_height,+ argMinMerge(geoip_country_code) AS geoip_country_code,+ argMinMerge(geoip_subdivision_1_code) AS geoip_subdivision_1_code,+ argMinMerge(geoip_subdivision_1_name) AS geoip_subdivision_1_name,+ argMinMerge(geoip_subdivision_city_name) AS geoip_subdivision_city_name,+ argMinMerge(geoip_time_zone) AS geoip_time_zone,+ argMinMerge(entry_utm_source) AS entry_utm_source,+ argMinMerge(entry_utm_campaign) AS entry_utm_campaign,+ argMinMerge(entry_utm_medium) AS entry_utm_medium,+ argMinMerge(entry_utm_term) AS entry_utm_term,+ argMinMerge(entry_utm_content) AS entry_utm_content,+ argMinMerge(entry_referring_domain) AS entry_referring_domain,+ argMinMerge(entry_gclid) AS entry_gclid,+ argMinMerge(entry_gad_source) AS entry_gad_source,+ argMinMerge(entry_fbclid) AS entry_fbclid,+ argMinMerge(entry_has_gclid) AS entry_has_gclid,+ argMinMerge(entry_has_fbclid) AS entry_has_fbclid,+ argMinMerge(entry_ad_ids_map) AS entry_ad_ids_map,+ argMinMerge(entry_ad_ids_set) AS entry_ad_ids_set,+ argMinMerge(entry_channel_type_properties) AS entry_channel_type_properties,+ uniqExactMerge(pageview_uniq) AS pageview_uniq,+ uniqExactMerge(autocapture_uniq) AS autocapture_uniq,+ uniqExactMerge(screen_uniq) AS screen_uniq,+ uniqUpToMerge(1)(page_screen_uniq_up_to) AS page_screen_uniq_up_to,+ max(has_autocapture) AS has_autocapture,+ groupUniqArrayMapMerge(flag_values) AS flag_values,+ groupUniqArrayArray(flag_keys) AS flag_keys,+ groupUniqArrayArray(2000)(event_names) AS event_names,+ groupUniqArrayArray(100)(hosts) AS hosts,+ groupUniqArrayArray(10)(emails) AS emails,+ max(has_replay_events) AS has_replay_events+FROM posthog.raw_sessions_v3+GROUP BY+ session_id_v7, session_timestamp, team_id;+CREATE VIEW posthog.sessions_v AS SELECT+ session_id,+ team_id,+ any(distinct_id) AS distinct_id,+ min(min_timestamp) AS min_timestamp,+ max(max_timestamp) AS max_timestamp,+ arrayDistinct(arrayFlatten(groupArray(urls))) AS urls,+ argMinMerge(entry_url) AS entry_url,+ argMaxMerge(exit_url) AS exit_url,+ argMinMerge(initial_utm_source) AS initial_utm_source,+ argMinMerge(initial_utm_campaign) AS initial_utm_campaign,+ argMinMerge(initial_utm_medium) AS initial_utm_medium,+ argMinMerge(initial_utm_term) AS initial_utm_term,+ argMinMerge(initial_utm_content) AS initial_utm_content,+ argMinMerge(initial_referring_domain) AS initial_referring_domain,+ argMinMerge(initial_gclid) AS initial_gclid,+ argMinMerge(initial_gad_source) AS initial_gad_source,+ argMinMerge(initial_gclsrc) AS initial_gclsrc,+ argMinMerge(initial_dclid) AS initial_dclid,+ argMinMerge(initial_gbraid) AS initial_gbraid,+ argMinMerge(initial_wbraid) AS initial_wbraid,+ argMinMerge(initial_fbclid) AS initial_fbclid,+ argMinMerge(initial_msclkid) AS initial_msclkid,+ argMinMerge(initial_twclid) AS initial_twclid,+ argMinMerge(initial_li_fat_id) AS initial_li_fat_id,+ argMinMerge(initial_mc_cid) AS initial_mc_cid,+ argMinMerge(initial_igshid) AS initial_igshid,+ argMinMerge(initial_ttclid) AS initial_ttclid,+ argMinMerge(initial_epik) AS initial_epik,+ argMinMerge(initial_qclid) AS initial_qclid,+ argMinMerge(initial_sccid) AS initial_sccid,+ sumMap(event_count_map) AS event_count_map,+ sum(pageview_count) AS pageview_count,+ sum(autocapture_count) AS autocapture_count+FROM posthog.sessions+GROUP BY+ session_id, team_id;diff --git a/tools/infra-scripts/clickhouse-multinode/multinode-migration-smoke b/tools/infra-scripts/clickhouse-multinode/multinode-migration-smokeindex 8dcb33372986..58685ad93bdf 100755--- a/tools/infra-scripts/clickhouse-multinode/multinode-migration-smoke+++ b/tools/infra-scripts/clickhouse-multinode/multinode-migration-smoke@@ -24,7 +24,8 @@ SCRIPT_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &>/dev/null && pwd)cd "$SCRIPT_DIR/../../.."COMPOSE_FILE="docker-compose.multinode-clickhouse.yml"-CH_SERVICES=(clickhouse-data clickhouse-ai-events clickhouse-aux clickhouse-ops clickhouse-sessions clickhouse-logs)+CH_SERVICES=(clickhouse-data clickhouse-ai-events clickhouse-aux clickhouse-ops clickhouse-sessions clickhouse-logs+ clickhouse-ingestion-events clickhouse-ingestion-small clickhouse-ingestion-medium)INFRA_SERVICES=(zookeeper kafka db redis7)ALL_SERVICES=("${INFRA_SERVICES[@]}" "${CH_SERVICES[@]}")HEALTH_TIMEOUT="${HEALTH_TIMEOUT:-180}"diff --git a/tools/infra-scripts/clickhouse-multinode/start-multinode-clickhouse b/tools/infra-scripts/clickhouse-multinode/start-multinode-clickhouseindex 9afcf9bf9529..6b454ecdf991 100755--- a/tools/infra-scripts/clickhouse-multinode/start-multinode-clickhouse+++ b/tools/infra-scripts/clickhouse-multinode/start-multinode-clickhouse@@ -12,19 +12,29 @@ SCRIPT_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &>/dev/null && pwd)cd "$SCRIPT_DIR/../../.."COMPOSE_FILE="docker-compose.multinode-clickhouse.yml"-SERVICES=(zookeeper kafka db redis7 clickhouse-data clickhouse-ai-events clickhouse-aux clickhouse-ops clickhouse-sessions clickhouse-logs)+CH_SERVICES=(clickhouse-data clickhouse-ai-events clickhouse-aux clickhouse-ops clickhouse-sessions clickhouse-logs+ clickhouse-ingestion-events clickhouse-ingestion-small clickhouse-ingestion-medium)+SERVICES=(zookeeper kafka db redis7 "${CH_SERVICES[@]}")case "${1:-up}" inup)docker compose -f "$COMPOSE_FILE" up -d "${SERVICES[@]}"echoecho "Multinode ClickHouse stack starting. Published ports:"- echo " clickhouse-data localhost:9000 (HTTP 8123)"- echo " clickhouse-ai-events localhost:9100 (HTTP 8124)"- echo " clickhouse-aux localhost:9200 (HTTP 8125)"- echo " clickhouse-ops localhost:9300 (HTTP 8126)"- echo " clickhouse-sessions localhost:9400 (HTTP 8127)"- echo " clickhouse-logs localhost:9500 (HTTP 8128)"+ echo " clickhouse-data localhost:9000 (HTTP 8123)"+ echo " clickhouse-ai-events localhost:9100 (HTTP 8124)"+ echo " clickhouse-aux localhost:9200 (HTTP 8125)"+ echo " clickhouse-ops localhost:9300 (HTTP 8126)"+ echo " clickhouse-sessions localhost:9400 (HTTP 8127)"+ echo " clickhouse-logs localhost:9500 (HTTP 8128)"+ echo " clickhouse-ingestion-events localhost:9600 (HTTP 8129)"+ echo " clickhouse-ingestion-small localhost:9700 (HTTP 8130)"+ echo " clickhouse-ingestion-medium localhost:9800 (HTTP 8131)"+ echo+ # Migrations run from the host shell but route by the hostnames in+ # system.clusters, so the host has to resolve every node.+ echo "Each node name must resolve on this host:"+ echo " echo '127.0.0.1 ${CH_SERVICES[*]}' | sudo tee -a /etc/hosts"echoecho "To run migrations against this stack, set:"echo " export MULTINODE_CLICKHOUSE=1"diff --git a/tools/infra-scripts/clickhouse-multinode/verify-multinode-clickhouse.py b/tools/infra-scripts/clickhouse-multinode/verify-multinode-clickhouse.pyindex fe2526a53532..4583d1b3231f 100755--- a/tools/infra-scripts/clickhouse-multinode/verify-multinode-clickhouse.py+++ b/tools/infra-scripts/clickhouse-multinode/verify-multinode-clickhouse.py@@ -43,6 +43,9 @@ NODES: list[Node] = [Node("clickhouse-ops", "localhost", 9300, "ops"),Node("clickhouse-sessions", "localhost", 9400, "sessions"),Node("clickhouse-logs", "localhost", 9500, "logs"),+ Node("clickhouse-ingestion-events", "localhost", 9600, "events"),+ Node("clickhouse-ingestion-small", "localhost", 9700, "small"),+ Node("clickhouse-ingestion-medium", "localhost", 9800, "medium"),]# Logical cluster -> expected member hosts (sorted). Each multinode XML file@@ -56,6 +59,9 @@ EXPECTED_CLUSTERS: dict[str, list[str]] = {"clickhouse-ai-events","clickhouse-aux","clickhouse-data",+ "clickhouse-ingestion-events",+ "clickhouse-ingestion-medium",+ "clickhouse-ingestion-small","clickhouse-logs","clickhouse-ops","clickhouse-sessions",