: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): bring the data node under the live convergence gate (#68185)
Paweł Szczur1e5a8d9a5a98
diff --git a/.github/workflows/ci-clickhouse-hcl-schema.yml b/.github/workflows/ci-clickhouse-hcl-schema.ymlindex 8d24602253bf..4368da275061 100644--- a/.github/workflows/ci-clickhouse-hcl-schema.yml+++ b/.github/workflows/ci-clickhouse-hcl-schema.yml@@ -28,12 +28,12 @@ permissions:packages: readenv:- # Pin to a concrete chschema build (not :latest) for reproducibility. sha-deff440+ # Pin to a concrete chschema build (not :latest) for reproducibility. sha-bf84186# has `introspect -exclude` (#79) for the live gate, retains file()/heredoc query# refs (#68/#69) so a query authored as file("sql/x.sql") compares equal to its# golden and the modifier-aware diff (#59), and fixes the layer-order drop of# dictionaries/views (#80). Override via repo variable.- HCLEXP_IMAGE: ${{ vars.HCLEXP_IMAGE || 'ghcr.io/posthog/chschema:sha-deff440' }}+ HCLEXP_IMAGE: ${{ vars.HCLEXP_IMAGE || 'ghcr.io/posthog/chschema:sha-bf84186' }}jobs:ops-hcl-guard:diff --git a/.github/workflows/ci-clickhouse-multinode-migrations.yml b/.github/workflows/ci-clickhouse-multinode-migrations.ymlindex 7e238898843e..b74a58a7a2b1 100644--- a/.github/workflows/ci-clickhouse-multinode-migrations.yml+++ b/.github/workflows/ci-clickhouse-multinode-migrations.yml@@ -57,7 +57,7 @@ jobs:PRIME_POSTGRES_FROM: schema.sql.gz# Pinned chschema build used by the live-schema convergence gate# (verify-live.sh). Keep in sync with posthog/clickhouse/hcl/bin/hclexp.- HCLEXP_IMAGE: ${{ vars.HCLEXP_IMAGE || 'ghcr.io/posthog/chschema:sha-deff440' }}+ HCLEXP_IMAGE: ${{ vars.HCLEXP_IMAGE || 'ghcr.io/posthog/chschema:sha-bf84186' }}steps:- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2with:diff --git a/posthog/clickhouse/hcl/README.md b/posthog/clickhouse/hcl/README.mdindex ccdad2867de8..ffb136a58d26 100644--- a/posthog/clickhouse/hcl/README.md+++ b/posthog/clickhouse/hcl/README.md@@ -90,7 +90,7 @@ HCL=posthog/clickhouse/hcl$HCL/bin/hclexp -help# it is equivalent to:docker run --rm -v "$PWD:/work" -v "${TMPDIR:-/tmp}:${TMPDIR:-/tmp}" -w /work \- ghcr.io/posthog/chschema:sha-deff440 -help+ ghcr.io/posthog/chschema:sha-bf84186 -help```(For faster local iteration you can build the binary — `go build -o hclexp ./cmd/hclexp` indiff --git a/posthog/clickhouse/hcl/bin/hclexp b/posthog/clickhouse/hcl/bin/hclexpindex 649ea590b9b3..79cf4644d7dd 100755--- a/posthog/clickhouse/hcl/bin/hclexp+++ b/posthog/clickhouse/hcl/bin/hclexp@@ -10,13 +10,13 @@# (`go build -o hclexp ./cmd/hclexp` in the sibling repo) for faster iteration.set -euo pipefail-# Pinned to a concrete build (not :latest) for reproducibility. sha-deff440 has+# Pinned to a concrete build (not :latest) for reproducibility. sha-bf84186 has# `introspect -exclude` (chschema #79), which the live convergence gate# (dump-live.sh) requires; it retains file()/heredoc query refs (#68/#69),# structured JSON diff (#66), and the modifier-aware diff (#59), and fixes the-# layer-order drop of dictionaries/views (#80).+# layer-order drop of dictionaries/views (#80) and captures the ReplacingMergeTree is_deleted column (#108).# Override via $HCLEXP_IMAGE; bump when intentionally upgrading hclexp.-HCLEXP_IMAGE="${HCLEXP_IMAGE:-ghcr.io/posthog/chschema:sha-deff440}"+HCLEXP_IMAGE="${HCLEXP_IMAGE:-ghcr.io/posthog/chschema:sha-bf84186}"if [[ -n "${HCLEXP_BIN:-}" ]]; thenexec "$HCLEXP_BIN" "$@"diff --git a/posthog/clickhouse/hcl/check-live.sh b/posthog/clickhouse/hcl/check-live.shindex 654113905341..6e94a53a913b 100755--- a/posthog/clickhouse/hcl/check-live.sh+++ b/posthog/clickhouse/hcl/check-live.sh@@ -26,7 +26,7 @@ ENV="${VERIFY_LIVE_ENV:-local}"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}}"-ROLES=(ops logs ai_events aux sessions)+ROLES=(data ops logs ai_events aux sessions)# Object-name globs the gate ignores, parsed from exclude.hcl (the quoted glob# strings) — the same list dump-live.sh feeds hclexp -exclude, applied here todiff --git a/posthog/clickhouse/hcl/check.sh b/posthog/clickhouse/hcl/check.shindex e7d3ac7366fe..86fe1e0f4908 100755--- a/posthog/clickhouse/hcl/check.sh+++ b/posthog/clickhouse/hcl/check.sh@@ -20,13 +20,32 @@ HCLEXP="$HCL/bin/hclexp"GOLDEN="$HCL/golden"MANIFEST="$HCL/nodes"-# Objects whose source/target lives outside a composed set by design:-# - custom_metrics* read the `system` database-# - ops_query_log_archive_mv reads system.query_log-# - events_main / events_recent are Distributed proxies to the main events cluster-# - query_log_archive / writable_query_log_archive are Distributed over the OPS-only-# sharded_query_log_archive, which is absent from non-OPS (shared-only) compositions-SKIP='custom_metrics,custom_metrics_backups,custom_metrics_dictionaries,custom_metrics_part_counts,custom_metrics_replication_queue,custom_metrics_server_crash,custom_metrics_table_sizes,custom_metrics_test,ops_query_log_archive_mv,events,events_main,events_recent,writable_events_recent,query_log_archive,query_log_archive_old_ops,writable_query_log_archive,person,person_distinct_id2'+# Per-role validate skips. A Distributed table whose remote lives on another cluster+# can't be resolved from a role's own composition — skip validation for exactly those+# objects, PER ROLE, so one role never masks a proxy that should resolve locally (a+# global list would, and would grow unbounded). Each list is the minimal set `hclexp+# validate` flags for that role across all its envs; add to a role only what that role+# actually proxies cross-cluster. Building blocks:+# _shared : out-of-band objects roles/shared models — the custom_metrics_* views and+# ops_query_log_archive_mv, whose sources are system.* / the OPS cluster.+# _qla : the query_log_archive read proxies over OPS's sharded_query_log_archive.+_shared='custom_metrics_backups,custom_metrics_dictionaries,custom_metrics_part_counts,custom_metrics_replication_queue,custom_metrics_server_crash,custom_metrics_table_sizes,ops_query_log_archive_mv'+_qla='query_log_archive,writable_query_log_archive'++skip_for() {+ case "$1" in+ ops) echo "custom_metrics,${_shared},events_main,events_recent" ;;+ logs) echo "custom_metrics,${_shared},${_qla}" ;;+ ai_events|aux|batch_exports) echo "${_shared},${_qla}" ;;+ sessions) echo "${_shared},${_qla},events,writable_events_recent" ;;+ sessionsv3) echo "${_shared},${_qla},events,query_log_archive_old_ops" ;;+ # DATA is the hub: it hosts Distributed read proxies into every satellite cluster+ # (aux web/marketing preaggregated, ai_events, sessions), none of whose sharded+ # remotes live on the data node.+ data) echo "${_shared},${_qla},ai_events,conversion_goal_attributed_preaggregated,distributed_system_processes,error_tracking_fingerprint_issue_state,experiment_metric_events_preaggregated,hog_invocation_results,marketing_conversions_preaggregated,marketing_costs_preaggregated,marketing_touchpoints_preaggregated,message_assets,property_values_distributed,session_replay_features,usage_report_events_preagg,web_bot_definition,web_bounces_dimensional_preaggregated,web_goals_preaggregated,web_overview_preaggregated,web_stats_dimensional_preaggregated,web_stats_frustration_preaggregated,web_stats_paths_preaggregated,web_stats_paths_preaggregated_pathkey,web_stats_preaggregated,web_vitals_paths_preaggregated" ;;+ *) echo "" ;;+ esac+}rc=0while read -r env role layers; do@@ -38,7 +57,7 @@ while read -r env role layers; dofor l in $layers; do stack="${stack:+$stack,}$HCL/$l"; doneecho "== $env/$role: validate =="- if ! "$HCLEXP" validate -layer "$stack" -skip-validation "$SKIP" >/dev/null; then+ if ! "$HCLEXP" validate -layer "$stack" -skip-validation "$(skip_for "$role")" >/dev/null; thenecho "FAIL: validate $env/$role"; rc=1fidiff --git a/posthog/clickhouse/hcl/dump-live.sh b/posthog/clickhouse/hcl/dump-live.shindex c1c94557b36b..09f1cb6245e3 100755--- a/posthog/clickhouse/hcl/dump-live.sh+++ b/posthog/clickhouse/hcl/dump-live.sh@@ -35,6 +35,7 @@ chmod 0755 "$OUTDIR" 2>/dev/null || true# Match the published ports in docker-compose.multinode-clickhouse.yml.# role default-host default-port default-dbROLES=(+ "data localhost 9000 posthog""ops localhost 9300 posthog""logs localhost 9500 posthog""ai_events localhost 9100 posthog"@@ -43,7 +44,7 @@ ROLES=()# Pin to the same chschema build as bin/hclexp; override via repo variable.-HCLEXP_IMAGE="${HCLEXP_IMAGE:-ghcr.io/posthog/chschema:sha-deff440}"+HCLEXP_IMAGE="${HCLEXP_IMAGE:-ghcr.io/posthog/chschema:sha-bf84186}"# hclexp that can reach ClickHouse on the host's published ports. Prefer a local# binary; otherwise a container sharing the host network namespace so localhostdiff --git a/posthog/clickhouse/hcl/golden/local-data.hcl b/posthog/clickhouse/hcl/golden/local-data.hclnew file mode 100644index 000000000000..e3d7d1524671--- /dev/null+++ b/posthog/clickhouse/hcl/golden/local-data.hcl@@ -0,0 +1,10808 @@+database "posthog" {+ table "adhoc_events_deletion" {+ order_by = ["team_id", "uuid"]+ ttl = "deleted_at + toIntervalMonth(3)"+ 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 = "Nullable(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_revision" {+ type = "UInt64"+ }+ column "client_version_major" {+ type = "UInt64"+ }+ column "client_version_minor" {+ type = "UInt64"+ }+ column "client_version_patch" {+ type = "UInt64"+ }+ 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 "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 "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 "$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 "$session_id_uuid" {+ type = "Nullable(UInt128)"+ }+ 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_ai" {+ type = "Map(String, String)"+ }+ column "properties_group_feature_flags" {+ type = "Map(String, String)"+ }+ column "person_properties_map_custom" {+ type = "Map(String, String)"+ }+ column "_timestamp" {+ type = "DateTime"+ }+ column "_offset" {+ type = "UInt64"+ }+ column "inserted_at" {+ type = "Nullable(DateTime64(6, 'UTC'))"+ default = "now64()"+ }+ column "consumer_breadcrumbs" {+ type = "Array(String)"+ }+ column "is_deleted" {+ type = "Bool"+ }+ column "mat_$ai_trace_id" {+ type = "Nullable(String)"+ comment = "column_materializer::properties::$ai_trace_id"+ }+ 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 "mat_$ai_prompt_name" {+ type = "Nullable(String)"+ comment = "column_materializer::properties::$ai_prompt_name"+ }+ column "mat_$ai_experiment_id" {+ type = "Nullable(String)"+ comment = "column_materializer::properties::$ai_experiment_id"+ }+ engine "distributed" {+ cluster_name = "posthog"+ remote_database = "posthog"+ 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_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 = "Nullable(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 "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 "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 "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 "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_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_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_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 "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_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 "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 "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_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_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_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_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_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 "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 "$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 "$session_id_uuid" {+ type = "Nullable(UInt128)"+ materialized = "toUInt128(JSONExtract(properties, '$session_id', 'Nullable(UUID)'))"+ }+ 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_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_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 "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 "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 "_timestamp" {+ type = "DateTime"+ }+ column "_offset" {+ type = "UInt64"+ }+ column "inserted_at" {+ type = "Nullable(DateTime64(6, 'UTC'))"+ default = "now64()"+ }+ column "consumer_breadcrumbs" {+ type = "Array(String)"+ }+ column "elements_chain_ids" {+ type = "Array(String)"+ materialized = "arrayDistinct(extractAll(elements_chain, '(?::|\")attr_id=\"(.*?)\"'))"+ }+ column "is_deleted" {+ type = "Bool"+ }+ column "properties_map_ephemeral" {+ type = "Map(String, String)"+ }+ column "person_properties_map_ephemeral" {+ type = "Map(String, String)"+ }+ column "mat_$ai_trace_id" {+ type = "Nullable(String)"+ materialized = "JSONExtract(properties, '$ai_trace_id', 'Nullable(String)')"+ }+ 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 "mat_$ai_prompt_name" {+ type = "Nullable(String)"+ materialized = "JSONExtract(properties, '$ai_prompt_name', 'Nullable(String)')"+ }+ column "mat_$ai_experiment_id" {+ type = "Nullable(String)"+ default = "JSONExtract(properties, '$ai_experiment_id', 'Nullable(String)')"+ }+ 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 "minmax_$session_id_uuid" {+ expr = "`$session_id_uuid`"+ 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_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 "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 "kafka_timestamp_minmax_sharded_events" {+ expr = "_timestamp"+ type = "minmax"+ granularity = 3+ }+ index "minmax_inserted_at" {+ expr = "coalesce(inserted_at, _timestamp)"+ type = "minmax"+ granularity = 1+ }+ index "is_deleted_idx" {+ expr = "is_deleted"+ type = "minmax"+ 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 "minmax_historical_migration" {+ expr = "historical_migration"+ 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+ }+ engine "replicated_replacing_merge_tree" {+ zoo_path = "/clickhouse/tables/{shard}/posthog.events"+ 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_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_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_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_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 "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 "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_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_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_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"+ }+ 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_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 "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"+ }+ 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 "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 "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_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 "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_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_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 "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 "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 "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"+ }+ }++ 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/nodes b/posthog/clickhouse/hcl/nodesindex f87dea6304a8..d182689a1c80 100644--- a/posthog/clickhouse/hcl/nodes+++ b/posthog/clickhouse/hcl/nodes@@ -77,4 +77,12 @@ prod-us sessionsv3 roles/shared roles/sessionsv3/prod-usprod-us batch_exports roles/shared roles/batch_exports/prod-usprod-eu batch_exports roles/shared roles/batch_exports/prod-eu-# prod-us data roles/shared roles/data/shared roles/data/prod-us+# DATA cluster: the main sharded cluster (events family, persons/groups, sessions,+# preaggregated + analytics tables). Only the local node is modeled here — it runs the+# base schema migrations produce (MSK events_json_mv, ~135 objects, no per-env mat_+# columns). The prod data clusters carry 200-300 env-specific materialized (mat_)+# 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.+local data roles/shared roles/data/local++# prod-us endpoints roles/shareddiff --git a/posthog/clickhouse/hcl/roles/data/local/sql/events_json_mv.sql b/posthog/clickhouse/hcl/roles/data/local/sql/events_json_mv.sqlnew file mode 100644index 000000000000..d139770d6291--- /dev/null+++ b/posthog/clickhouse/hcl/roles/data/local/sql/events_json_mv.sql@@ -0,0 +1,44 @@+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_jsondiff --git a/posthog/clickhouse/hcl/roles/data/local/sql/events_recent_json_mv.sql b/posthog/clickhouse/hcl/roles/data/local/sql/events_recent_json_mv.sqlnew file mode 100644index 000000000000..62b463efea4c--- /dev/null+++ b/posthog/clickhouse/hcl/roles/data/local/sql/events_recent_json_mv.sql@@ -0,0 +1,26 @@+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_eventsdiff --git a/posthog/clickhouse/hcl/roles/data/local/sql/performance_events_mv.sql b/posthog/clickhouse/hcl/roles/data/local/sql/performance_events_mv.sqlnew file mode 100644index 000000000000..8bd17d8bf4d1--- /dev/null+++ b/posthog/clickhouse/hcl/roles/data/local/sql/performance_events_mv.sql@@ -0,0 +1,52 @@+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_eventsdiff --git a/posthog/clickhouse/hcl/roles/data/local/sql/person_distinct_id_mv.sql b/posthog/clickhouse/hcl/roles/data/local/sql/person_distinct_id_mv.sqlnew file mode 100644index 000000000000..a8451ca8204a--- /dev/null+++ b/posthog/clickhouse/hcl/roles/data/local/sql/person_distinct_id_mv.sql@@ -0,0 +1,8 @@+SELECT+ distinct_id,+ person_id,+ team_id,+ coalesce(_sign, if(is_deleted = 0, 1, -1)) AS _sign,+ _timestamp,+ _offset+FROM posthog.kafka_person_distinct_iddiff --git a/posthog/clickhouse/hcl/roles/data/local/sql/person_overrides_mv.sql b/posthog/clickhouse/hcl/roles/data/local/sql/person_overrides_mv.sqlnew file mode 100644index 000000000000..1ec7aed4455e--- /dev/null+++ b/posthog/clickhouse/hcl/roles/data/local/sql/person_overrides_mv.sql@@ -0,0 +1,2 @@+SELECT team_id, old_person_id, override_person_id, merged_at, oldest_event, version+FROM posthog.kafka_person_overridesdiff --git a/posthog/clickhouse/hcl/roles/data/local/sql/posthog_document_embeddings_text_embedding_3_large_3072_mv.sql b/posthog/clickhouse/hcl/roles/data/local/sql/posthog_document_embeddings_text_embedding_3_large_3072_mv.sqlnew file mode 100644index 000000000000..5fcd7cc9848f--- /dev/null+++ b/posthog/clickhouse/hcl/roles/data/local/sql/posthog_document_embeddings_text_embedding_3_large_3072_mv.sql@@ -0,0 +1,16 @@+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'diff --git a/posthog/clickhouse/hcl/roles/data/local/sql/posthog_document_embeddings_text_embedding_3_small_1536_mv.sql b/posthog/clickhouse/hcl/roles/data/local/sql/posthog_document_embeddings_text_embedding_3_small_1536_mv.sqlnew file mode 100644index 000000000000..99701c11b419--- /dev/null+++ b/posthog/clickhouse/hcl/roles/data/local/sql/posthog_document_embeddings_text_embedding_3_small_1536_mv.sql@@ -0,0 +1,16 @@+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'diff --git a/posthog/clickhouse/hcl/roles/data/local/sql/raw_sessions_mv.sql b/posthog/clickhouse/hcl/roles/data/local/sql/raw_sessions_mv.sqlnew file mode 100644index 000000000000..d037114af636--- /dev/null+++ b/posthog/clickhouse/hcl/roles/data/local/sql/raw_sessions_mv.sql@@ -0,0 +1,73 @@+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_v7diff --git a/posthog/clickhouse/hcl/roles/data/local/sql/sessions_mv.sql b/posthog/clickhouse/hcl/roles/data/local/sql/sessions_mv.sqlnew file mode 100644index 000000000000..edef4bc36df1--- /dev/null+++ b/posthog/clickhouse/hcl/roles/data/local/sql/sessions_mv.sql@@ -0,0 +1,46 @@+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_iddiff --git a/posthog/clickhouse/hcl/roles/data/local/tables.hcl b/posthog/clickhouse/hcl/roles/data/local/tables.hclnew file mode 100644index 000000000000..51cd845196e0--- /dev/null+++ b/posthog/clickhouse/hcl/roles/data/local/tables.hcl@@ -0,0 +1,9654 @@+database "posthog" {+ table "adhoc_events_deletion" {+ order_by = ["team_id", "uuid"]+ ttl = "deleted_at + toIntervalMonth(3)"+ 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 = "Nullable(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_revision" {+ type = "UInt64"+ }+ column "client_version_major" {+ type = "UInt64"+ }+ column "client_version_minor" {+ type = "UInt64"+ }+ column "client_version_patch" {+ type = "UInt64"+ }+ 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 "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 "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 "$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 "$session_id_uuid" {+ type = "Nullable(UInt128)"+ }+ 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_ai" {+ type = "Map(String, String)"+ }+ column "properties_group_feature_flags" {+ type = "Map(String, String)"+ }+ column "person_properties_map_custom" {+ type = "Map(String, String)"+ }+ column "_timestamp" {+ type = "DateTime"+ }+ column "_offset" {+ type = "UInt64"+ }+ column "inserted_at" {+ type = "Nullable(DateTime64(6, 'UTC'))"+ default = "now64()"+ }+ column "consumer_breadcrumbs" {+ type = "Array(String)"+ }+ column "is_deleted" {+ type = "Bool"+ }+ column "mat_$ai_trace_id" {+ type = "Nullable(String)"+ comment = "column_materializer::properties::$ai_trace_id"+ }+ 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 "mat_$ai_prompt_name" {+ type = "Nullable(String)"+ comment = "column_materializer::properties::$ai_prompt_name"+ }+ column "mat_$ai_experiment_id" {+ type = "Nullable(String)"+ comment = "column_materializer::properties::$ai_experiment_id"+ }+ engine "distributed" {+ cluster_name = "posthog"+ remote_database = "posthog"+ 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_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 = "Nullable(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 "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 "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 "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 "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_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_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_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 "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_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 "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 "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_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_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_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_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_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 "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 "$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 "$session_id_uuid" {+ type = "Nullable(UInt128)"+ materialized = "toUInt128(JSONExtract(properties, '$session_id', 'Nullable(UUID)'))"+ }+ 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_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_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 "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 "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 "_timestamp" {+ type = "DateTime"+ }+ column "_offset" {+ type = "UInt64"+ }+ column "inserted_at" {+ type = "Nullable(DateTime64(6, 'UTC'))"+ default = "now64()"+ }+ column "consumer_breadcrumbs" {+ type = "Array(String)"+ }+ column "elements_chain_ids" {+ type = "Array(String)"+ materialized = "arrayDistinct(extractAll(elements_chain, '(?::|\")attr_id=\"(.*?)\"'))"+ }+ column "is_deleted" {+ type = "Bool"+ }+ column "properties_map_ephemeral" {+ type = "Map(String, String)"+ }+ column "person_properties_map_ephemeral" {+ type = "Map(String, String)"+ }+ column "mat_$ai_trace_id" {+ type = "Nullable(String)"+ materialized = "JSONExtract(properties, '$ai_trace_id', 'Nullable(String)')"+ }+ 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 "mat_$ai_prompt_name" {+ type = "Nullable(String)"+ materialized = "JSONExtract(properties, '$ai_prompt_name', 'Nullable(String)')"+ }+ column "mat_$ai_experiment_id" {+ type = "Nullable(String)"+ default = "JSONExtract(properties, '$ai_experiment_id', 'Nullable(String)')"+ }+ 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 "minmax_$session_id_uuid" {+ expr = "`$session_id_uuid`"+ 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_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 "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 "kafka_timestamp_minmax_sharded_events" {+ expr = "_timestamp"+ type = "minmax"+ granularity = 3+ }+ index "minmax_inserted_at" {+ expr = "coalesce(inserted_at, _timestamp)"+ type = "minmax"+ granularity = 1+ }+ index "is_deleted_idx" {+ expr = "is_deleted"+ type = "minmax"+ 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 "minmax_historical_migration" {+ expr = "historical_migration"+ 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+ }+ engine "replicated_replacing_merge_tree" {+ zoo_path = "/clickhouse/tables/{shard}/posthog.events"+ 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_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_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_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_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 "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 "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_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_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_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"+ }+ 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_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 "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"+ }+ 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 "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 "events_json_mv" {+ to_table = "posthog.writable_events"+ query = file("sql/events_json_mv.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_recent_json_mv" {+ to_table = "posthog.writable_events_recent"+ query = file("sql/events_recent_json_mv.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 "performance_events_mv" {+ to_table = "posthog.writeable_performance_events"+ query = file("sql/performance_events_mv.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_id_mv" {+ to_table = "posthog.person_distinct_id"+ query = file("sql/person_distinct_id_mv.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_overrides_mv" {+ to_table = "posthog.person_overrides"+ query = file("sql/person_overrides_mv.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 "posthog_document_embeddings_text_embedding_3_large_3072_mv" {+ to_table = "posthog.writable_posthog_document_embeddings_text_embedding_3_large_3072"+ query = file("sql/posthog_document_embeddings_text_embedding_3_large_3072_mv.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 = file("sql/posthog_document_embeddings_text_embedding_3_small_1536_mv.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 "raw_sessions_mv" {+ to_table = "posthog.writable_raw_sessions"+ query = file("sql/raw_sessions_mv.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 "sessions_mv" {+ to_table = "posthog.writable_sessions"+ query = file("sql/sessions_mv.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"+ }+ }+ 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/sql/local-data.sql b/posthog/clickhouse/hcl/sql/local-data.sqlnew file mode 100644index 000000000000..72ab1619ee75--- /dev/null+++ b/posthog/clickhouse/hcl/sql/local-data.sql@@ -0,0 +1,3450 @@+-- AUTO-GENERATED from the declarative HCL by ops/gen-sql.sh — do not edit.+-- Full CREATE schema for the local/data 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) SETTINGS index_granularity = 8192;+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.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.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.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_revision UInt64,+ client_version_major UInt64,+ client_version_minor UInt64,+ client_version_patch UInt64,+ 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_fingerprint_issue_state (+ team_id Int64,+ fingerprint String,+ issue_id UUID,+ issue_name Nullable(String),+ issue_description Nullable(String),+ issue_status 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.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.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.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.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 (+ 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.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_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_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_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.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.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.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_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 (+ 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_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.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.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_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,+ 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),+ $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',+ $session_id_uuid Nullable(UInt128) MATERIALIZED toUInt128(JSONExtract(properties, '$session_id', 'Nullable(UUID)')),+ elements_chain_href String MATERIALIZED EXTRACT(elements_chain, '(?::|")href="(.*?)"'),+ elements_chain_texts Array(String) MATERIALIZED arrayDistinct(extractAll(elements_chain, '(?::|")text="(.*?)"')),+ 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_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)),+ properties_group_feature_flags Map(String, String) MATERIALIZED mapSort(mapFilter((key, _) -> (key LIKE '$feature/%'), CAST(JSONExtractKeysAndValues(properties, 'String'), 'Map(String, String)'))) CODEC(ZSTD(1)),+ 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)),+ _timestamp DateTime,+ _offset UInt64,+ inserted_at Nullable(DateTime64(6, 'UTC')) DEFAULT now64(),+ consumer_breadcrumbs Array(String),+ elements_chain_ids Array(String) MATERIALIZED arrayDistinct(extractAll(elements_chain, '(?::|")attr_id="(.*?)"')),+ is_deleted Bool,+ properties_map_ephemeral Map(String, String),+ person_properties_map_ephemeral Map(String, String),+ mat_$ai_trace_id Nullable(String) MATERIALIZED JSONExtract(properties, '$ai_trace_id', 'Nullable(String)'),+ 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)'),+ mat_$ai_prompt_name Nullable(String) MATERIALIZED JSONExtract(properties, '$ai_prompt_name', 'Nullable(String)'),+ mat_$ai_experiment_id Nullable(String) DEFAULT JSONExtract(properties, '$ai_experiment_id', 'Nullable(String)'),+ 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 minmax_$session_id_uuid `$session_id_uuid` 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_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 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 kafka_timestamp_minmax_sharded_events _timestamp TYPE minmax GRANULARITY 3,+ INDEX minmax_inserted_at coalesce(inserted_at, _timestamp) TYPE minmax GRANULARITY 1,+ INDEX is_deleted_idx is_deleted TYPE minmax 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 minmax_historical_migration historical_migration 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+) 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_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_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_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_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_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.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.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_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_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_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_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_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 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),+ 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.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.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.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_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.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 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_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_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.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.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.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 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.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.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 Nullable(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.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),+ $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',+ $session_id_uuid Nullable(UInt128),+ 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_ai Map(String, String),+ properties_group_feature_flags Map(String, String),+ person_properties_map_custom Map(String, String),+ _timestamp DateTime,+ _offset UInt64,+ inserted_at Nullable(DateTime64(6, 'UTC')) DEFAULT now64(),+ consumer_breadcrumbs Array(String),+ is_deleted Bool,+ mat_$ai_trace_id Nullable(String) COMMENT 'column_materializer::properties::$ai_trace_id',+ 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',+ mat_$ai_prompt_name Nullable(String) COMMENT 'column_materializer::properties::$ai_prompt_name',+ mat_$ai_experiment_id Nullable(String) COMMENT 'column_materializer::properties::$ai_experiment_id'+) ENGINE = Distributed('posthog', 'posthog', 'sharded_events', 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 Nullable(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.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.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.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.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.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 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;