Skip to content

: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.

chore(clickhouse): bring aux + sessions satellites under the live gate (#67730)

Paweł Szczurcbe5bbbafef6
diff --git a/posthog/clickhouse/hcl/check-live.sh b/posthog/clickhouse/hcl/check-live.sh
index a7d0e4c08db9..654113905341 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)
+ROLES=(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 to
diff --git a/posthog/clickhouse/hcl/check.sh b/posthog/clickhouse/hcl/check.sh
index e57800cf1571..e7d3ac7366fe 100755
--- a/posthog/clickhouse/hcl/check.sh
+++ b/posthog/clickhouse/hcl/check.sh
@@ -26,7 +26,7 @@ MANIFEST="$HCL/nodes"
# - 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_main,events_recent,query_log_archive,writable_query_log_archive,person,person_distinct_id2'
+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'
rc=0
while read -r env role layers; do
diff --git a/posthog/clickhouse/hcl/dump-live.sh b/posthog/clickhouse/hcl/dump-live.sh
index 5a3a171423c5..c1c94557b36b 100755
--- a/posthog/clickhouse/hcl/dump-live.sh
+++ b/posthog/clickhouse/hcl/dump-live.sh
@@ -38,6 +38,8 @@ ROLES=(
"ops localhost 9300 posthog"
"logs localhost 9500 posthog"
"ai_events localhost 9100 posthog"
+ "aux localhost 9200 posthog"
+ "sessions localhost 9400 posthog"
)
# Pin to the same chschema build as bin/hclexp; override via repo variable.
diff --git a/posthog/clickhouse/hcl/golden/local-aux.hcl b/posthog/clickhouse/hcl/golden/local-aux.hcl
new file mode 100644
index 000000000000..4baa66734de5
--- /dev/null
+++ b/posthog/clickhouse/hcl/golden/local-aux.hcl
@@ -0,0 +1,3879 @@
+database "posthog" {
+ 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 "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 "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 "hog_invocation_results" {
+ column "team_id" {
+ type = "Int64"
+ }
+ column "function_kind" {
+ type = "LowCardinality(String)"
+ }
+ column "function_id" {
+ type = "String"
+ }
+ column "invocation_id" {
+ type = "String"
+ }
+ column "parent_run_id" {
+ type = "String"
+ }
+ column "status" {
+ type = "LowCardinality(String)"
+ }
+ column "attempts" {
+ type = "UInt8"
+ }
+ column "is_retry" {
+ type = "UInt8"
+ }
+ column "scheduled_at" {
+ type = "DateTime64(6, 'UTC')"
+ }
+ column "first_scheduled_at" {
+ type = "DateTime64(6, 'UTC')"
+ }
+ column "started_at" {
+ type = "Nullable(DateTime64(6, 'UTC'))"
+ }
+ column "finished_at" {
+ type = "Nullable(DateTime64(6, 'UTC'))"
+ }
+ column "duration_ms" {
+ type = "Nullable(UInt32)"
+ }
+ column "error_kind" {
+ type = "LowCardinality(String)"
+ }
+ column "error_message" {
+ type = "String"
+ }
+ column "event_uuid" {
+ type = "String"
+ }
+ column "distinct_id" {
+ type = "String"
+ }
+ column "person_id" {
+ type = "String"
+ }
+ column "invocation_globals" {
+ type = "String"
+ }
+ column "version" {
+ type = "UInt64"
+ }
+ column "is_deleted" {
+ type = "UInt8"
+ }
+ column "_timestamp" {
+ type = "DateTime"
+ }
+ column "_offset" {
+ type = "UInt64"
+ }
+ column "_partition" {
+ type = "UInt64"
+ }
+ engine "distributed" {
+ cluster_name = "aux"
+ remote_database = "posthog"
+ remote_table = "hog_invocation_results_data"
+ }
+ }
+
+ table "hog_invocation_results_data" {
+ order_by = ["team_id", "function_kind", "function_id", "invocation_id"]
+ partition_by = "toYYYYMMDD(scheduled_at)"
+ ttl = "toDate(scheduled_at) + toIntervalDay(30)"
+ settings = {
+ index_granularity = "1024"
+ ttl_only_drop_parts = "1"
+ }
+ column "team_id" {
+ type = "Int64"
+ }
+ column "function_kind" {
+ type = "LowCardinality(String)"
+ }
+ column "function_id" {
+ type = "String"
+ }
+ column "invocation_id" {
+ type = "String"
+ }
+ column "parent_run_id" {
+ type = "String"
+ }
+ column "status" {
+ type = "LowCardinality(String)"
+ }
+ column "attempts" {
+ type = "UInt8"
+ }
+ column "is_retry" {
+ type = "UInt8"
+ }
+ column "scheduled_at" {
+ type = "DateTime64(6, 'UTC')"
+ }
+ column "first_scheduled_at" {
+ type = "DateTime64(6, 'UTC')"
+ default = "scheduled_at"
+ }
+ column "started_at" {
+ type = "Nullable(DateTime64(6, 'UTC'))"
+ }
+ column "finished_at" {
+ type = "Nullable(DateTime64(6, 'UTC'))"
+ }
+ column "duration_ms" {
+ type = "Nullable(UInt32)"
+ }
+ column "error_kind" {
+ type = "LowCardinality(String)"
+ }
+ column "error_message" {
+ type = "String"
+ }
+ column "event_uuid" {
+ type = "String"
+ }
+ column "distinct_id" {
+ type = "String"
+ }
+ column "person_id" {
+ type = "String"
+ }
+ column "invocation_globals" {
+ type = "String"
+ }
+ column "version" {
+ type = "UInt64"
+ }
+ column "is_deleted" {
+ type = "UInt8"
+ default = "0"
+ }
+ column "_timestamp" {
+ type = "DateTime"
+ }
+ column "_offset" {
+ type = "UInt64"
+ }
+ column "_partition" {
+ type = "UInt64"
+ }
+ index "status_idx" {
+ expr = "status"
+ type = "set(8)"
+ granularity = 1
+ }
+ index "function_idx" {
+ expr = "function_id"
+ type = "bloom_filter(0.01)"
+ granularity = 1
+ }
+ index "event_uuid_idx" {
+ expr = "event_uuid"
+ type = "bloom_filter(0.01)"
+ granularity = 1
+ }
+ index "is_retry_idx" {
+ expr = "is_retry"
+ type = "set(2)"
+ granularity = 1
+ }
+ engine "replicated_replacing_merge_tree" {
+ zoo_path = "/clickhouse/tables/noshard/posthog.hog_invocation_results_data"
+ replica_name = "{replica}-{shard}"
+ version_column = "version"
+ }
+ }
+
+ table "kafka_error_tracking_fingerprint_issue_state" {
+ column "team_id" {
+ type = "Int64"
+ }
+ column "fingerprint" {
+ type = "String"
+ }
+ column "issue_id" {
+ type = "UUID"
+ }
+ column "issue_name" {
+ type = "Nullable(String)"
+ }
+ column "issue_description" {
+ type = "Nullable(String)"
+ }
+ column "issue_status" {
+ type = "String"
+ }
+ column "assigned_user_id" {
+ type = "Nullable(Int64)"
+ }
+ column "assigned_role_id" {
+ type = "Nullable(UUID)"
+ }
+ column "first_seen" {
+ type = "DateTime64(3, 'UTC')"
+ }
+ column "is_deleted" {
+ type = "Int8"
+ }
+ column "version" {
+ type = "Int64"
+ }
+ engine "kafka" {
+ broker_list = "msk_cluster"
+ topic_list = "kafka_topic_list = 'clickhouse_error_tracking_fingerprint_issue_state'"
+ group_name = "kafka_group_name = 'clickhouse-error-tracking-fingerprint-issue-state'"
+ format = "kafka_format = 'JSONEachRow'"
+ }
+ }
+
+ table "kafka_hog_invocation_results" {
+ column "team_id" {
+ type = "Int64"
+ }
+ column "function_kind" {
+ type = "LowCardinality(String)"
+ }
+ column "function_id" {
+ type = "String"
+ }
+ column "invocation_id" {
+ type = "String"
+ }
+ column "parent_run_id" {
+ type = "String"
+ }
+ column "status" {
+ type = "LowCardinality(String)"
+ }
+ column "attempts" {
+ type = "UInt8"
+ }
+ column "is_retry" {
+ type = "UInt8"
+ }
+ column "scheduled_at" {
+ type = "DateTime64(6, 'UTC')"
+ }
+ column "first_scheduled_at" {
+ type = "DateTime64(6, 'UTC')"
+ }
+ column "started_at" {
+ type = "Nullable(DateTime64(6, 'UTC'))"
+ }
+ column "finished_at" {
+ type = "Nullable(DateTime64(6, 'UTC'))"
+ }
+ column "duration_ms" {
+ type = "Nullable(UInt32)"
+ }
+ column "error_kind" {
+ type = "LowCardinality(String)"
+ }
+ column "error_message" {
+ type = "String"
+ }
+ column "event_uuid" {
+ type = "String"
+ }
+ column "distinct_id" {
+ type = "String"
+ }
+ column "person_id" {
+ type = "String"
+ }
+ column "invocation_globals" {
+ type = "String"
+ }
+ column "version" {
+ type = "UInt64"
+ }
+ column "is_deleted" {
+ type = "UInt8"
+ }
+ engine "kafka" {
+ broker_list = "warpstream_cyclotron"
+ topic_list = "kafka_topic_list = 'clickhouse_hog_invocation_results'"
+ group_name = "kafka_group_name = 'clickhouse_hog_invocation_results'"
+ format = "kafka_format = 'JSONEachRow'"
+ skip_broken_messages = 100
+ }
+ }
+
+ table "kafka_message_assets" {
+ column "team_id" {
+ type = "Int64"
+ }
+ column "function_kind" {
+ type = "LowCardinality(String)"
+ }
+ column "function_id" {
+ type = "String"
+ }
+ column "parent_run_id" {
+ type = "String"
+ }
+ column "invocation_id" {
+ type = "String"
+ }
+ column "action_id" {
+ type = "String"
+ }
+ column "kind" {
+ type = "LowCardinality(String)"
+ }
+ column "distinct_id" {
+ type = "String"
+ }
+ column "person_id" {
+ type = "String"
+ }
+ column "recipient" {
+ type = "String"
+ }
+ column "subject" {
+ type = "String"
+ }
+ column "status" {
+ type = "LowCardinality(String)"
+ }
+ column "sent_at" {
+ type = "DateTime64(6, 'UTC')"
+ }
+ column "version" {
+ type = "UInt64"
+ }
+ column "is_deleted" {
+ type = "UInt8"
+ }
+ column "html" {
+ type = "String"
+ }
+ engine "kafka" {
+ broker_list = "warpstream_cyclotron"
+ topic_list = "kafka_topic_list = 'clickhouse_message_assets'"
+ group_name = "kafka_group_name = 'clickhouse_message_assets'"
+ format = "kafka_format = 'JSONEachRow'"
+ skip_broken_messages = 100
+ }
+ }
+
+ table "kafka_property_values" {
+ column "team_id" {
+ type = "Int64"
+ }
+ column "property_type" {
+ type = "LowCardinality(String)"
+ }
+ column "property_key" {
+ type = "String"
+ }
+ column "property_value" {
+ type = "String"
+ }
+ column "property_count" {
+ type = "UInt64"
+ }
+ engine "kafka" {
+ broker_list = "warpstream_ingestion"
+ topic_list = "kafka_topic_list = 'clickhouse_property_values'"
+ group_name = "kafka_group_name = 'clickhouse_property_values'"
+ format = "kafka_format = 'JSONEachRow'"
+ num_consumers = 8
+ thread_per_consumer = true
+ }
+ }
+
+ table "marketing_conversions_preaggregated" {
+ column "team_id" {
+ type = "Int64"
+ }
+ column "job_id" {
+ type = "UUID"
+ }
+ column "person_id" {
+ type = "UUID"
+ }
+ column "conversion_timestamp" {
+ type = "DateTime64(6, 'UTC')"
+ }
+ column "conversion_math_value" {
+ type = "Float64"
+ }
+ column "session_id" {
+ type = "String"
+ }
+ column "campaign_name" {
+ type = "String"
+ }
+ column "source_name" {
+ type = "String"
+ }
+ column "medium_name" {
+ type = "String"
+ }
+ column "content_name" {
+ type = "String"
+ }
+ column "term_name" {
+ type = "String"
+ }
+ column "referring_domain_name" {
+ type = "String"
+ }
+ column "gclid_name" {
+ type = "String"
+ }
+ column "fbclid_name" {
+ type = "String"
+ }
+ column "gad_source_name" {
+ type = "String"
+ }
+ column "computed_at" {
+ type = "DateTime64(6, 'UTC')"
+ default = "now()"
+ }
+ column "expires_at" {
+ type = "Date"
+ default = "today() + toIntervalDay(7)"
+ }
+ engine "distributed" {
+ cluster_name = "aux"
+ remote_database = "posthog"
+ remote_table = "sharded_marketing_conversions_preaggregated"
+ sharding_key = "cityHash64(person_id)"
+ }
+ }
+
+ table "marketing_costs_preaggregated" {
+ column "team_id" {
+ type = "Int64"
+ }
+ column "job_id" {
+ type = "UUID"
+ }
+ column "source_id" {
+ type = "String"
+ }
+ column "source_name" {
+ type = "String"
+ }
+ column "grain" {
+ type = "LowCardinality(String)"
+ }
+ column "match_key" {
+ type = "String"
+ }
+ column "campaign_id" {
+ type = "String"
+ }
+ column "campaign_name" {
+ type = "String"
+ }
+ column "ad_group_id" {
+ type = "String"
+ }
+ column "ad_group_name" {
+ type = "String"
+ }
+ column "ad_id" {
+ type = "String"
+ }
+ column "ad_name" {
+ type = "String"
+ }
+ column "cost_date" {
+ type = "Date"
+ }
+ column "cost" {
+ type = "Float64"
+ }
+ column "clicks" {
+ type = "Float64"
+ }
+ column "impressions" {
+ type = "Float64"
+ }
+ column "reported_conversions" {
+ type = "Float64"
+ }
+ column "reported_conversion_value" {
+ type = "Float64"
+ }
+ column "computed_at" {
+ type = "DateTime64(6, 'UTC')"
+ default = "now()"
+ }
+ column "expires_at" {
+ type = "Date"
+ default = "today() + toIntervalDay(7)"
+ }
+ engine "distributed" {
+ cluster_name = "aux"
+ remote_database = "posthog"
+ remote_table = "sharded_marketing_costs_preaggregated"
+ sharding_key = "cityHash64(source_name, campaign_id)"
+ }
+ }
+
+ table "marketing_touchpoints_preaggregated" {
+ column "team_id" {
+ type = "Int64"
+ }
+ column "job_id" {
+ type = "UUID"
+ }
+ column "person_id" {
+ type = "UUID"
+ }
+ column "touchpoint_timestamp" {
+ type = "DateTime64(6, 'UTC')"
+ }
+ column "campaign_name" {
+ type = "String"
+ }
+ column "source_name" {
+ type = "String"
+ }
+ column "medium_name" {
+ type = "String"
+ }
+ column "content_name" {
+ type = "String"
+ }
+ column "term_name" {
+ type = "String"
+ }
+ column "referring_domain_name" {
+ type = "String"
+ }
+ column "gclid_name" {
+ type = "String"
+ }
+ column "fbclid_name" {
+ type = "String"
+ }
+ column "gad_source_name" {
+ type = "String"
+ }
+ column "computed_at" {
+ type = "DateTime64(6, 'UTC')"
+ default = "now()"
+ }
+ column "expires_at" {
+ type = "Date"
+ default = "today() + toIntervalDay(7)"
+ }
+ engine "distributed" {
+ cluster_name = "aux"
+ remote_database = "posthog"
+ remote_table = "sharded_marketing_touchpoints_preaggregated"
+ sharding_key = "cityHash64(person_id)"
+ }
+ }
+
+ table "message_assets" {
+ column "team_id" {
+ type = "Int64"
+ }
+ column "function_kind" {
+ type = "LowCardinality(String)"
+ }
+ column "function_id" {
+ type = "String"
+ }
+ column "parent_run_id" {
+ type = "String"
+ }
+ column "invocation_id" {
+ type = "String"
+ }
+ column "action_id" {
+ type = "String"
+ }
+ column "kind" {
+ type = "LowCardinality(String)"
+ }
+ column "distinct_id" {
+ type = "String"
+ }
+ column "person_id" {
+ type = "String"
+ }
+ column "recipient" {
+ type = "String"
+ }
+ column "subject" {
+ type = "String"
+ }
+ column "status" {
+ type = "LowCardinality(String)"
+ }
+ column "sent_at" {
+ type = "DateTime64(6, 'UTC')"
+ }
+ column "version" {
+ type = "UInt64"
+ }
+ column "is_deleted" {
+ type = "UInt8"
+ }
+ column "html" {
+ type = "String"
+ }
+ column "_timestamp" {
+ type = "DateTime"
+ }
+ column "_offset" {
+ type = "UInt64"
+ }
+ column "_partition" {
+ type = "UInt64"
+ }
+ engine "distributed" {
+ cluster_name = "aux"
+ remote_database = "posthog"
+ remote_table = "message_assets_data"
+ }
+ }
+
+ table "message_assets_data" {
+ order_by = ["team_id", "function_kind", "function_id", "invocation_id", "action_id"]
+ partition_by = "toYYYYMMDD(sent_at)"
+ ttl = "toDate(sent_at) + toIntervalDay(30)"
+ settings = {
+ index_granularity = "1024"
+ ttl_only_drop_parts = "1"
+ }
+ column "team_id" {
+ type = "Int64"
+ }
+ column "function_kind" {
+ type = "LowCardinality(String)"
+ }
+ column "function_id" {
+ type = "String"
+ }
+ column "parent_run_id" {
+ type = "String"
+ }
+ column "invocation_id" {
+ type = "String"
+ }
+ column "action_id" {
+ type = "String"
+ }
+ column "kind" {
+ type = "LowCardinality(String)"
+ }
+ column "distinct_id" {
+ type = "String"
+ }
+ column "person_id" {
+ type = "String"
+ }
+ column "recipient" {
+ type = "String"
+ }
+ column "subject" {
+ type = "String"
+ }
+ column "status" {
+ type = "LowCardinality(String)"
+ }
+ column "sent_at" {
+ type = "DateTime64(6, 'UTC')"
+ }
+ column "version" {
+ type = "UInt64"
+ }
+ column "is_deleted" {
+ type = "UInt8"
+ default = "0"
+ }
+ column "html" {
+ type = "String"
+ codec = "ZSTD(3)"
+ }
+ column "_timestamp" {
+ type = "DateTime"
+ }
+ column "_offset" {
+ type = "UInt64"
+ }
+ column "_partition" {
+ type = "UInt64"
+ }
+ index "parent_run_idx" {
+ expr = "parent_run_id"
+ type = "bloom_filter(0.01)"
+ granularity = 1
+ }
+ index "distinct_id_idx" {
+ expr = "distinct_id"
+ type = "bloom_filter(0.01)"
+ granularity = 1
+ }
+ index "person_id_idx" {
+ expr = "person_id"
+ type = "bloom_filter(0.01)"
+ granularity = 1
+ }
+ index "recipient_idx" {
+ expr = "recipient"
+ type = "bloom_filter(0.01)"
+ granularity = 1
+ }
+ engine "replicated_replacing_merge_tree" {
+ zoo_path = "/clickhouse/tables/noshard/posthog.message_assets_data"
+ replica_name = "{replica}-{shard}"
+ version_column = "version"
+ }
+ }
+
+ table "property_values" {
+ order_by = ["team_id", "property_type", "property_key", "property_value"]
+ ttl = "last_seen + toIntervalDay(30)"
+ settings = {
+ index_granularity = "8192"
+ }
+ column "team_id" {
+ type = "Int64"
+ codec = "DoubleDelta, ZSTD(1)"
+ }
+ column "property_type" {
+ type = "LowCardinality(String)"
+ }
+ column "property_key" {
+ type = "LowCardinality(String)"
+ }
+ column "property_value" {
+ type = "String"
+ }
+ column "property_count" {
+ type = "SimpleAggregateFunction(sum, UInt64)"
+ }
+ column "last_seen" {
+ type = "SimpleAggregateFunction(max, DateTime)"
+ default = "now()"
+ }
+ index "idx_property_value_ngrambf" {
+ expr = "lower(property_value)"
+ type = "ngrambf_v1(3, 32768, 3, 0)"
+ granularity = 1
+ }
+ engine "replicated_aggregating_merge_tree" {
+ zoo_path = "/clickhouse/tables/noshard/posthog.property_values"
+ replica_name = "{replica}-{shard}"
+ }
+ }
+
+ table "property_values_distributed" {
+ column "team_id" {
+ type = "Int64"
+ codec = "DoubleDelta, ZSTD(1)"
+ }
+ column "property_type" {
+ type = "LowCardinality(String)"
+ }
+ column "property_key" {
+ type = "LowCardinality(String)"
+ }
+ column "property_value" {
+ type = "String"
+ }
+ column "property_count" {
+ type = "SimpleAggregateFunction(sum, UInt64)"
+ }
+ column "last_seen" {
+ type = "SimpleAggregateFunction(max, DateTime)"
+ default = "now()"
+ }
+ engine "distributed" {
+ cluster_name = "aux"
+ remote_database = "posthog"
+ remote_table = "property_values"
+ }
+ }
+
+ table "query_log_archive" {
+ column "hostname" {
+ type = "LowCardinality(String)"
+ }
+ column "user" {
+ type = "LowCardinality(String)"
+ }
+ column "query_id" {
+ type = "String"
+ }
+ column "initial_query_id" {
+ type = "String"
+ }
+ column "is_initial_query" {
+ type = "UInt8"
+ }
+ column "type" {
+ type = "Enum8('QueryStart'=1, 'QueryFinish'=2, 'ExceptionBeforeStart'=3, 'ExceptionWhileProcessing'=4)"
+ }
+ column "event_date" {
+ type = "Date"
+ }
+ column "event_time" {
+ type = "DateTime"
+ }
+ column "event_time_microseconds" {
+ type = "DateTime64(6)"
+ }
+ column "query_start_time" {
+ type = "DateTime"
+ }
+ column "query_start_time_microseconds" {
+ type = "DateTime64(6)"
+ }
+ column "query_duration_ms" {
+ type = "UInt64"
+ }
+ column "read_rows" {
+ type = "UInt64"
+ }
+ column "read_bytes" {
+ type = "UInt64"
+ }
+ column "written_rows" {
+ type = "UInt64"
+ }
+ column "written_bytes" {
+ type = "UInt64"
+ }
+ column "result_rows" {
+ type = "UInt64"
+ }
+ column "result_bytes" {
+ type = "UInt64"
+ }
+ column "memory_usage" {
+ type = "UInt64"
+ }
+ column "peak_threads_usage" {
+ type = "UInt64"
+ }
+ column "current_database" {
+ type = "LowCardinality(String)"
+ }
+ column "query" {
+ type = "String"
+ }
+ column "formatted_query" {
+ type = "String"
+ }
+ column "normalized_query_hash" {
+ type = "UInt64"
+ }
+ column "query_kind" {
+ type = "LowCardinality(String)"
+ }
+ column "exception_code" {
+ type = "Int32"
+ }
+ column "exception" {
+ type = "String"
+ }
+ column "stack_trace" {
+ type = "String"
+ }
+ column "team_id" {
+ type = "Int64"
+ }
+ column "log_comment" {
+ type = "JSON(max_dynamic_paths=256, access_method LowCardinality(String), alert_config_id String, api_key_label String, api_key_mask String, batch_export_id String, chargeable Bool, client_query_id String, cohort_id Int64, `dagster.job_name` String, `dagster.run_id` String, `dagster.tags.owner` String, dashboard_id Int64, experiment_feature_flag_key String, experiment_id Int64, feature LowCardinality(String), id String, insight_id Int64, is_impersonated Bool, kind LowCardinality(String), name String, org_id String, person_on_events_mode LowCardinality(String), product LowCardinality(String), query_type LowCardinality(String), request_name String, route_id String, service_name String, session_id String, table_id String, team_id Int64, `temporal.activity_id` String, `temporal.activity_type` String, `temporal.attempt` Int64, `temporal.workflow_id` String, `temporal.workflow_namespace` String, `temporal.workflow_run_id` String, `temporal.workflow_type` String, user_id Int64, warehouse_query Bool, workflow LowCardinality(String), workload LowCardinality(String), SKIP cache_key, SKIP filter, SKIP hogql_features, SKIP http_referer, SKIP http_request_id, SKIP http_user_agent, SKIP query_settings, SKIP timings, SKIP user_email)"
+ }
+ column "ProfileEvents" {
+ type = "Map(String, UInt64)"
+ }
+ column "exception_name" {
+ type = "String"
+ alias = "errorCodeToName(exception_code)"
+ }
+ column "ProfileEvents_RealTimeMicroseconds" {
+ type = "Int64"
+ alias = "ProfileEvents['RealTimeMicroseconds']"
+ }
+ column "ProfileEvents_OSCPUVirtualTimeMicroseconds" {
+ type = "Int64"
+ alias = "ProfileEvents['OSCPUVirtualTimeMicroseconds']"
+ }
+ column "ProfileEvents_S3Clients" {
+ type = "Int64"
+ alias = "ProfileEvents['S3Clients']"
+ }
+ column "ProfileEvents_S3DeleteObjects" {
+ type = "Int64"
+ alias = "ProfileEvents['S3DeleteObjects']"
+ }
+ column "ProfileEvents_S3CopyObject" {
+ type = "Int64"
+ alias = "ProfileEvents['S3CopyObject']"
+ }
+ column "ProfileEvents_S3ListObjects" {
+ type = "Int64"
+ alias = "ProfileEvents['S3ListObjects']"
+ }
+ column "ProfileEvents_S3HeadObject" {
+ type = "Int64"
+ alias = "ProfileEvents['S3HeadObject']"
+ }
+ column "ProfileEvents_S3GetObjectAttributes" {
+ type = "Int64"
+ alias = "ProfileEvents['S3GetObjectAttributes']"
+ }
+ column "ProfileEvents_S3CreateMultipartUpload" {
+ type = "Int64"
+ alias = "ProfileEvents['S3CreateMultipartUpload']"
+ }
+ column "ProfileEvents_S3UploadPartCopy" {
+ type = "Int64"
+ alias = "ProfileEvents['S3UploadPartCopy']"
+ }
+ column "ProfileEvents_S3UploadPart" {
+ type = "Int64"
+ alias = "ProfileEvents['S3UploadPart']"
+ }
+ column "ProfileEvents_S3AbortMultipartUpload" {
+ type = "Int64"
+ alias = "ProfileEvents['S3AbortMultipartUpload']"
+ }
+ column "ProfileEvents_S3CompleteMultipartUpload" {
+ type = "Int64"
+ alias = "ProfileEvents['S3CompleteMultipartUpload']"
+ }
+ column "ProfileEvents_S3PutObject" {
+ type = "Int64"
+ alias = "ProfileEvents['S3PutObject']"
+ }
+ column "ProfileEvents_S3GetObject" {
+ type = "Int64"
+ alias = "ProfileEvents['S3GetObject']"
+ }
+ column "ProfileEvents_ReadBufferFromS3Bytes" {
+ type = "Int64"
+ alias = "ProfileEvents['ReadBufferFromS3Bytes']"
+ }
+ column "ProfileEvents_WriteBufferFromS3Bytes" {
+ type = "Int64"
+ alias = "ProfileEvents['WriteBufferFromS3Bytes']"
+ }
+ column "lc_workflow" {
+ type = "LowCardinality(String)"
+ alias = "log_comment.workflow"
+ }
+ column "lc_kind" {
+ type = "LowCardinality(String)"
+ alias = "log_comment.kind"
+ }
+ column "lc_id" {
+ type = "String"
+ alias = "CAST(log_comment.id, 'String')"
+ }
+ column "lc_route_id" {
+ type = "String"
+ alias = "CAST(log_comment.route_id, 'String')"
+ }
+ column "lc_access_method" {
+ type = "LowCardinality(String)"
+ alias = "log_comment.access_method"
+ }
+ column "lc_api_key_label" {
+ type = "String"
+ alias = "CAST(log_comment.api_key_label, 'String')"
+ }
+ column "lc_api_key_mask" {
+ type = "String"
+ alias = "CAST(log_comment.api_key_mask, 'String')"
+ }
+ column "lc_query_type" {
+ type = "LowCardinality(String)"
+ alias = "log_comment.query_type"
+ }
+ column "lc_product" {
+ type = "LowCardinality(String)"
+ alias = "log_comment.product"
+ }
+ column "lc_chargeable" {
+ type = "Bool"
+ alias = "log_comment.chargeable"
+ }
+ column "lc_name" {
+ type = "String"
+ alias = "CAST(log_comment.name, 'String')"
+ }
+ column "lc_request_name" {
+ type = "String"
+ alias = "CAST(log_comment.request_name, 'String')"
+ }
+ column "lc_client_query_id" {
+ type = "String"
+ alias = "CAST(log_comment.client_query_id, 'String')"
+ }
+ column "lc_org_id" {
+ type = "String"
+ alias = "CAST(log_comment.org_id, 'String')"
+ }
+ column "lc_user_id" {
+ type = "Int64"
+ alias = "log_comment.user_id"
+ }
+ column "lc_is_impersonated" {
+ type = "Bool"
+ alias = "log_comment.is_impersonated"
+ }
+ column "lc_session_id" {
+ type = "String"
+ alias = "CAST(log_comment.session_id, 'String')"
+ }
+ column "lc_dashboard_id" {
+ type = "Int64"
+ alias = "log_comment.dashboard_id"
+ }
+ column "lc_insight_id" {
+ type = "Int64"
+ alias = "log_comment.insight_id"
+ }
+ column "lc_cohort_id" {
+ type = "Int64"
+ alias = "log_comment.cohort_id"
+ }
+ column "lc_batch_export_id" {
+ type = "String"
+ alias = "CAST(log_comment.batch_export_id, 'String')"
+ }
+ column "lc_experiment_id" {
+ type = "Int64"
+ alias = "log_comment.experiment_id"
+ }
+ column "lc_experiment_feature_flag_key" {
+ type = "String"
+ alias = "CAST(log_comment.experiment_feature_flag_key, 'String')"
+ }
+ column "lc_alert_config_id" {
+ type = "String"
+ alias = "CAST(log_comment.alert_config_id, 'String')"
+ }
+ column "lc_feature" {
+ type = "LowCardinality(String)"
+ alias = "log_comment.feature"
+ }
+ column "lc_table_id" {
+ type = "String"
+ alias = "CAST(log_comment.table_id, 'String')"
+ }
+ column "lc_warehouse_query" {
+ type = "Bool"
+ alias = "log_comment.warehouse_query"
+ }
+ column "lc_person_on_events_mode" {
+ type = "LowCardinality(String)"
+ alias = "log_comment.person_on_events_mode"
+ }
+ column "lc_service_name" {
+ type = "String"
+ alias = "CAST(log_comment.service_name, 'String')"
+ }
+ column "lc_workload" {
+ type = "LowCardinality(String)"
+ alias = "log_comment.workload"
+ }
+ column "lc_query__kind" {
+ type = "LowCardinality(String)"
+ alias = "if(JSONHas(toString(log_comment), 'query', 'source'), JSONExtractString(toString(log_comment), 'query', 'source', 'kind'), JSONExtractString(toString(log_comment), 'query', 'kind'))"
+ }
+ column "lc_query__query" {
+ type = "String"
+ alias = "multiIf(NOT is_initial_query, '', JSONHas(toString(log_comment), 'query', 'source'), JSONExtractString(toString(log_comment), 'query', 'source', 'query'), JSONExtractString(toString(log_comment), 'query', 'query'))"
+ }
+ column "lc_query" {
+ type = "String"
+ alias = "if(is_initial_query, JSONExtractRaw(toString(log_comment), 'query'), '')"
+ }
+ column "lc_temporal__workflow_namespace" {
+ type = "String"
+ alias = "CAST(log_comment.`temporal.workflow_namespace`, 'String')"
+ }
+ column "lc_temporal__workflow_type" {
+ type = "String"
+ alias = "CAST(log_comment.`temporal.workflow_type`, 'String')"
+ }
+ column "lc_temporal__workflow_id" {
+ type = "String"
+ alias = "CAST(log_comment.`temporal.workflow_id`, 'String')"
+ }
+ column "lc_temporal__workflow_run_id" {
+ type = "String"
+ alias = "CAST(log_comment.`temporal.workflow_run_id`, 'String')"
+ }
+ column "lc_temporal__activity_type" {
+ type = "String"
+ alias = "CAST(log_comment.`temporal.activity_type`, 'String')"
+ }
+ column "lc_temporal__activity_id" {
+ type = "String"
+ alias = "CAST(log_comment.`temporal.activity_id`, 'String')"
+ }
+ column "lc_temporal__attempt" {
+ type = "Int64"
+ alias = "log_comment.`temporal.attempt`"
+ }
+ column "lc_dagster__job_name" {
+ type = "String"
+ alias = "CAST(log_comment.`dagster.job_name`, 'String')"
+ }
+ column "lc_dagster__run_id" {
+ type = "String"
+ alias = "CAST(log_comment.`dagster.run_id`, 'String')"
+ }
+ column "lc_dagster__owner" {
+ type = "String"
+ alias = "CAST(log_comment.`dagster.tags.owner`, 'String')"
+ }
+ column "lc_modifiers" {
+ type = "String"
+ alias = "if(is_initial_query, JSONExtractRaw(toString(log_comment), 'modifiers'), '')"
+ }
+ engine "distributed" {
+ cluster_name = "ops"
+ remote_database = "posthog"
+ remote_table = "sharded_query_log_archive"
+ }
+ }
+
+ table "raw_error_tracking_fingerprint_issue_state" {
+ order_by = ["team_id", "fingerprint"]
+ settings = {
+ index_granularity = "512"
+ }
+ column "team_id" {
+ type = "Int64"
+ }
+ column "fingerprint" {
+ type = "String"
+ }
+ column "issue_id" {
+ type = "UUID"
+ }
+ column "issue_name" {
+ type = "Nullable(String)"
+ }
+ column "issue_description" {
+ type = "Nullable(String)"
+ }
+ column "issue_status" {
+ type = "String"
+ }
+ column "assigned_user_id" {
+ type = "Nullable(Int64)"
+ }
+ column "assigned_role_id" {
+ type = "Nullable(UUID)"
+ }
+ column "first_seen" {
+ type = "DateTime64(3, 'UTC')"
+ }
+ column "is_deleted" {
+ type = "Int8"
+ }
+ column "version" {
+ type = "Int64"
+ }
+ column "_timestamp" {
+ type = "DateTime"
+ }
+ column "_offset" {
+ type = "UInt64"
+ }
+ column "_partition" {
+ type = "UInt64"
+ }
+ index "kafka_timestamp_minmax_raw_error_tracking_fingerprint_issue_state" {
+ expr = "_timestamp"
+ type = "minmax"
+ granularity = 3
+ }
+ engine "replicated_replacing_merge_tree" {
+ zoo_path = "/clickhouse/tables/noshard/posthog.raw_error_tracking_fingerprint_issue_state"
+ replica_name = "{replica}-{shard}"
+ version_column = "version"
+ }
+ }
+
+ table "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 "sharded_conversion_goal_attributed_preaggregated" {
+ order_by = ["team_id", "job_id", "person_id", "conversion_timestamp", "touchpoint_timestamp"]
+ partition_by = "toYYYYMMDD(expires_at)"
+ ttl = "expires_at"
+ settings = {
+ index_granularity = "8192"
+ ttl_only_drop_parts = "1"
+ }
+ column "team_id" {
+ type = "Int64"
+ }
+ column "job_id" {
+ type = "UUID"
+ }
+ column "person_id" {
+ type = "UUID"
+ }
+ column "conversion_timestamp" {
+ type = "DateTime64(6, 'UTC')"
+ }
+ column "conversion_value" {
+ type = "Float64"
+ }
+ column "touchpoint_timestamp" {
+ type = "DateTime64(6, 'UTC')"
+ }
+ column "touchpoint_weight" {
+ type = "Float64"
+ }
+ column "campaign_name" {
+ type = "String"
+ }
+ column "source_name" {
+ type = "String"
+ }
+ column "medium_name" {
+ type = "String"
+ }
+ column "content_name" {
+ type = "String"
+ }
+ column "term_name" {
+ type = "String"
+ }
+ column "referring_domain_name" {
+ type = "String"
+ }
+ column "gclid_name" {
+ type = "String"
+ }
+ column "fbclid_name" {
+ type = "String"
+ }
+ column "gad_source_name" {
+ type = "String"
+ }
+ column "computed_at" {
+ type = "DateTime64(6, 'UTC')"
+ default = "now()"
+ }
+ column "expires_at" {
+ type = "Date"
+ default = "today() + toIntervalDay(7)"
+ }
+ engine "replicated_replacing_merge_tree" {
+ zoo_path = "/clickhouse/tables/noshard/posthog.conversion_goal_attributed_preaggregated"
+ replica_name = "{replica}-{shard}"
+ version_column = "computed_at"
+ }
+ }
+
+ table "sharded_experiment_metric_events_preaggregated" {
+ order_by = ["team_id", "job_id", "entity_id", "timestamp", "event_uuid"]
+ partition_by = "toYYYYMMDD(expires_at)"
+ ttl = "expires_at"
+ settings = {
+ index_granularity = "8192"
+ ttl_only_drop_parts = "1"
+ }
+ column "team_id" {
+ type = "Int64"
+ }
+ column "job_id" {
+ type = "UUID"
+ }
+ column "entity_id" {
+ type = "String"
+ }
+ column "timestamp" {
+ type = "DateTime64(6, 'UTC')"
+ }
+ column "event_uuid" {
+ type = "UUID"
+ }
+ column "session_id" {
+ type = "String"
+ }
+ column "numeric_value" {
+ type = "Float64"
+ default = "0"
+ }
+ column "steps" {
+ type = "Array(UInt8)"
+ default = "[]"
+ }
+ column "computed_at" {
+ type = "DateTime64(6, 'UTC')"
+ default = "now()"
+ }
+ column "expires_at" {
+ type = "Date"
+ default = "today() + toIntervalDay(7)"
+ }
+ engine "replicated_replacing_merge_tree" {
+ zoo_path = "/clickhouse/tables/noshard/posthog.experiment_metric_events_preaggregated"
+ replica_name = "{replica}-{shard}"
+ version_column = "computed_at"
+ }
+ }
+
+ table "sharded_marketing_conversions_preaggregated" {
+ order_by = ["team_id", "job_id", "person_id", "conversion_timestamp"]
+ partition_by = "toYYYYMMDD(expires_at)"
+ ttl = "expires_at"
+ settings = {
+ index_granularity = "8192"
+ ttl_only_drop_parts = "1"
+ }
+ column "team_id" {
+ type = "Int64"
+ }
+ column "job_id" {
+ type = "UUID"
+ }
+ column "person_id" {
+ type = "UUID"
+ }
+ column "conversion_timestamp" {
+ type = "DateTime64(6, 'UTC')"
+ }
+ column "conversion_math_value" {
+ type = "Float64"
+ }
+ column "session_id" {
+ type = "String"
+ }
+ column "campaign_name" {
+ type = "String"
+ }
+ column "source_name" {
+ type = "String"
+ }
+ column "medium_name" {
+ type = "String"
+ }
+ column "content_name" {
+ type = "String"
+ }
+ column "term_name" {
+ type = "String"
+ }
+ column "referring_domain_name" {
+ type = "String"
+ }
+ column "gclid_name" {
+ type = "String"
+ }
+ column "fbclid_name" {
+ type = "String"
+ }
+ column "gad_source_name" {
+ type = "String"
+ }
+ column "computed_at" {
+ type = "DateTime64(6, 'UTC')"
+ default = "now()"
+ }
+ column "expires_at" {
+ type = "Date"
+ default = "today() + toIntervalDay(7)"
+ }
+ engine "replicated_replacing_merge_tree" {
+ zoo_path = "/clickhouse/tables/noshard/posthog.marketing_conversions_preaggregated"
+ replica_name = "{replica}-{shard}"
+ version_column = "computed_at"
+ }
+ }
+
+ table "sharded_marketing_costs_preaggregated" {
+ order_by = ["team_id", "job_id", "source_name", "grain", "campaign_id", "ad_group_id", "ad_id", "cost_date"]
+ partition_by = "toYYYYMMDD(expires_at)"
+ ttl = "expires_at"
+ settings = {
+ index_granularity = "8192"
+ ttl_only_drop_parts = "1"
+ }
+ column "team_id" {
+ type = "Int64"
+ }
+ column "job_id" {
+ type = "UUID"
+ }
+ column "source_id" {
+ type = "String"
+ }
+ column "source_name" {
+ type = "String"
+ }
+ column "grain" {
+ type = "LowCardinality(String)"
+ }
+ column "match_key" {
+ type = "String"
+ }
+ column "campaign_id" {
+ type = "String"
+ }
+ column "campaign_name" {
+ type = "String"
+ }
+ column "ad_group_id" {
+ type = "String"
+ }
+ column "ad_group_name" {
+ type = "String"
+ }
+ column "ad_id" {
+ type = "String"
+ }
+ column "ad_name" {
+ type = "String"
+ }
+ column "cost_date" {
+ type = "Date"
+ }
+ column "cost" {
+ type = "Float64"
+ }
+ column "clicks" {
+ type = "Float64"
+ }
+ column "impressions" {
+ type = "Float64"
+ }
+ column "reported_conversions" {
+ type = "Float64"
+ }
+ column "reported_conversion_value" {
+ type = "Float64"
+ }
+ column "computed_at" {
+ type = "DateTime64(6, 'UTC')"
+ default = "now()"
+ }
+ column "expires_at" {
+ type = "Date"
+ default = "today() + toIntervalDay(7)"
+ }
+ engine "replicated_replacing_merge_tree" {
+ zoo_path = "/clickhouse/tables/noshard/posthog.marketing_costs_preaggregated"
+ replica_name = "{replica}-{shard}"
+ version_column = "computed_at"
+ }
+ }
+
+ table "sharded_marketing_touchpoints_preaggregated" {
+ order_by = ["team_id", "job_id", "person_id", "touchpoint_timestamp"]
+ partition_by = "toYYYYMMDD(expires_at)"
+ ttl = "expires_at"
+ settings = {
+ index_granularity = "8192"
+ ttl_only_drop_parts = "1"
+ }
+ column "team_id" {
+ type = "Int64"
+ }
+ column "job_id" {
+ type = "UUID"
+ }
+ column "person_id" {
+ type = "UUID"
+ }
+ column "touchpoint_timestamp" {
+ type = "DateTime64(6, 'UTC')"
+ }
+ column "campaign_name" {
+ type = "String"
+ }
+ column "source_name" {
+ type = "String"
+ }
+ column "medium_name" {
+ type = "String"
+ }
+ column "content_name" {
+ type = "String"
+ }
+ column "term_name" {
+ type = "String"
+ }
+ column "referring_domain_name" {
+ type = "String"
+ }
+ column "gclid_name" {
+ type = "String"
+ }
+ column "fbclid_name" {
+ type = "String"
+ }
+ column "gad_source_name" {
+ type = "String"
+ }
+ column "computed_at" {
+ type = "DateTime64(6, 'UTC')"
+ default = "now()"
+ }
+ column "expires_at" {
+ type = "Date"
+ default = "today() + toIntervalDay(7)"
+ }
+ engine "replicated_replacing_merge_tree" {
+ zoo_path = "/clickhouse/tables/noshard/posthog.marketing_touchpoints_preaggregated"
+ replica_name = "{replica}-{shard}"
+ version_column = "computed_at"
+ }
+ }
+
+ table "sharded_session_replay_features" {
+ order_by = ["team_id", "session_id"]
+ partition_by = "toYYYYMM(min_first_timestamp)"
+ settings = {
+ index_granularity = "512"
+ }
+ column "session_id" {
+ type = "String"
+ }
+ column "team_id" {
+ type = "Int64"
+ }
+ column "distinct_id" {
+ type = "String"
+ }
+ column "min_first_timestamp" {
+ type = "SimpleAggregateFunction(min, DateTime64(6, 'UTC'))"
+ }
+ column "max_last_timestamp" {
+ type = "SimpleAggregateFunction(max, DateTime64(6, 'UTC'))"
+ }
+ column "event_count" {
+ type = "SimpleAggregateFunction(sum, Int64)"
+ }
+ column "mouse_position_count" {
+ type = "SimpleAggregateFunction(sum, Int64)"
+ }
+ column "mouse_sum_x" {
+ type = "SimpleAggregateFunction(sum, Float64)"
+ }
+ column "mouse_sum_x_squared" {
+ type = "SimpleAggregateFunction(sum, Float64)"
+ }
+ column "mouse_sum_y" {
+ type = "SimpleAggregateFunction(sum, Float64)"
+ }
+ column "mouse_sum_y_squared" {
+ type = "SimpleAggregateFunction(sum, Float64)"
+ }
+ column "mouse_distance_traveled" {
+ type = "SimpleAggregateFunction(sum, Float64)"
+ }
+ column "mouse_direction_change_count" {
+ type = "SimpleAggregateFunction(sum, Int64)"
+ }
+ column "mouse_velocity_sum" {
+ type = "SimpleAggregateFunction(sum, Float64)"
+ }
+ column "mouse_velocity_sum_of_squares" {
+ type = "SimpleAggregateFunction(sum, Float64)"
+ }
+ column "mouse_velocity_count" {
+ type = "SimpleAggregateFunction(sum, Int64)"
+ }
+ column "scroll_event_count" {
+ type = "SimpleAggregateFunction(sum, Int64)"
+ }
+ column "total_scroll_magnitude" {
+ type = "SimpleAggregateFunction(sum, Float64)"
+ }
+ column "scroll_direction_reversal_count" {
+ type = "SimpleAggregateFunction(sum, Int64)"
+ }
+ column "rapid_scroll_reversal_count" {
+ type = "SimpleAggregateFunction(sum, Int64)"
+ }
+ column "scroll_to_top_count" {
+ type = "SimpleAggregateFunction(sum, Int64)"
+ }
+ column "click_count" {
+ type = "SimpleAggregateFunction(sum, Int64)"
+ }
+ column "keypress_count" {
+ type = "SimpleAggregateFunction(sum, Int64)"
+ }
+ column "mouse_activity_count" {
+ type = "SimpleAggregateFunction(sum, Int64)"
+ }
+ column "rage_click_count" {
+ type = "SimpleAggregateFunction(sum, Int64)"
+ }
+ column "dead_click_count" {
+ type = "SimpleAggregateFunction(sum, Int64)"
+ }
+ column "backspace_count" {
+ type = "SimpleAggregateFunction(sum, Int64)"
+ }
+ column "inter_action_gap_count" {
+ type = "SimpleAggregateFunction(sum, Int64)"
+ }
+ column "inter_action_gap_sum_ms" {
+ type = "SimpleAggregateFunction(sum, Float64)"
+ }
+ column "inter_action_gap_sum_of_squares_ms" {
+ type = "SimpleAggregateFunction(sum, Float64)"
+ }
+ column "max_idle_gap_ms" {
+ type = "SimpleAggregateFunction(max, Float64)"
+ }
+ column "long_idle_gap_count" {
+ type = "SimpleAggregateFunction(sum, Int64)"
+ }
+ column "quick_back_count" {
+ type = "SimpleAggregateFunction(sum, Int64)"
+ }
+ column "page_visit_count" {
+ type = "SimpleAggregateFunction(sum, Int64)"
+ }
+ column "unique_url_count" {
+ type = "AggregateFunction(uniqCombined(12), String)"
+ }
+ column "login_path_visit_count" {
+ type = "SimpleAggregateFunction(sum, Int64)"
+ }
+ column "signup_path_visit_count" {
+ type = "SimpleAggregateFunction(sum, Int64)"
+ }
+ column "checkout_path_visit_count" {
+ type = "SimpleAggregateFunction(sum, Int64)"
+ }
+ column "cart_path_visit_count" {
+ type = "SimpleAggregateFunction(sum, Int64)"
+ }
+ column "billing_path_visit_count" {
+ type = "SimpleAggregateFunction(sum, Int64)"
+ }
+ column "settings_path_visit_count" {
+ type = "SimpleAggregateFunction(sum, Int64)"
+ }
+ column "account_path_visit_count" {
+ type = "SimpleAggregateFunction(sum, Int64)"
+ }
+ column "error_path_visit_count" {
+ type = "SimpleAggregateFunction(sum, Int64)"
+ }
+ column "not_found_path_visit_count" {
+ type = "SimpleAggregateFunction(sum, Int64)"
+ }
+ column "admin_path_visit_count" {
+ type = "SimpleAggregateFunction(sum, Int64)"
+ }
+ column "dashboard_path_visit_count" {
+ type = "SimpleAggregateFunction(sum, Int64)"
+ }
+ column "onboarding_path_visit_count" {
+ type = "SimpleAggregateFunction(sum, Int64)"
+ }
+ column "cancel_path_visit_count" {
+ type = "SimpleAggregateFunction(sum, Int64)"
+ }
+ column "refund_path_visit_count" {
+ type = "SimpleAggregateFunction(sum, Int64)"
+ }
+ column "console_error_count" {
+ type = "SimpleAggregateFunction(sum, Int64)"
+ }
+ column "console_error_after_click_count" {
+ type = "SimpleAggregateFunction(sum, Int64)"
+ }
+ column "console_warn_count" {
+ type = "SimpleAggregateFunction(sum, Int64)"
+ }
+ column "network_request_count" {
+ type = "SimpleAggregateFunction(sum, Int64)"
+ }
+ column "network_failed_request_count" {
+ type = "SimpleAggregateFunction(sum, Int64)"
+ }
+ column "network_4xx_count" {
+ type = "SimpleAggregateFunction(sum, Int64)"
+ }
+ column "network_5xx_count" {
+ type = "SimpleAggregateFunction(sum, Int64)"
+ }
+ column "network_request_duration_sum" {
+ type = "SimpleAggregateFunction(sum, Float64)"
+ }
+ column "network_request_duration_sum_of_squares" {
+ type = "SimpleAggregateFunction(sum, Float64)"
+ }
+ column "network_request_duration_count" {
+ type = "SimpleAggregateFunction(sum, Int64)"
+ }
+ column "mutation_count" {
+ type = "SimpleAggregateFunction(sum, Int64)"
+ }
+ column "viewport_resize_count" {
+ type = "SimpleAggregateFunction(sum, Int64)"
+ }
+ column "touch_event_count" {
+ type = "SimpleAggregateFunction(sum, Int64)"
+ }
+ column "max_scroll_y" {
+ type = "SimpleAggregateFunction(max, Float64)"
+ }
+ column "unique_click_target_count" {
+ type = "AggregateFunction(uniqCombined(12), Int64)"
+ }
+ column "unique_form_field_count" {
+ type = "AggregateFunction(uniqCombined(12), Int64)"
+ }
+ column "text_selection_count" {
+ type = "SimpleAggregateFunction(sum, Int64)"
+ }
+ column "selection_copy_count" {
+ type = "SimpleAggregateFunction(sum, Int64)"
+ }
+ column "is_deleted" {
+ type = "SimpleAggregateFunction(max, UInt8)"
+ default = "0"
+ }
+ engine "replicated_aggregating_merge_tree" {
+ zoo_path = "/clickhouse/tables/{shard}/posthog.session_replay_features"
+ replica_name = "{replica}"
+ }
+ }
+
+ table "sharded_usage_report_events_preagg" {
+ order_by = ["date", "team_id", "person_mode", "lib", "event"]
+ partition_by = "date"
+ ttl = "date + toIntervalDay(14)"
+ settings = {
+ index_granularity = "8192"
+ ttl_only_drop_parts = "1"
+ }
+ column "date" {
+ type = "Date"
+ }
+ column "team_id" {
+ type = "Int64"
+ }
+ column "person_mode" {
+ type = "LowCardinality(String)"
+ }
+ column "lib" {
+ type = "LowCardinality(String)"
+ }
+ column "event" {
+ type = "String"
+ }
+ column "distinct_events_unique" {
+ type = "AggregateFunction(uniqExact, Tuple(UInt64, UInt64, UInt64))"
+ }
+ column "event_count" {
+ type = "AggregateFunction(sum, UInt64)"
+ }
+ engine "replicated_aggregating_merge_tree" {
+ zoo_path = "/clickhouse/tables/{shard}/posthog.sharded_usage_report_events_preagg"
+ replica_name = "{replica}"
+ }
+ }
+
+ table "sharded_web_bot_definition" {
+ order_by = ["id"]
+ settings = {
+ index_granularity = "8192"
+ }
+ column "id" {
+ type = "UInt64"
+ }
+ column "parent_id" {
+ type = "UInt64"
+ }
+ column "regexp" {
+ type = "String"
+ }
+ column "keys" {
+ type = "Array(String)"
+ }
+ column "values" {
+ type = "Array(String)"
+ }
+ engine "replicated_merge_tree" {
+ zoo_path = "/clickhouse/tables/{shard}/posthog.sharded_web_bot_definition"
+ replica_name = "{replica}"
+ }
+ }
+
+ table "sharded_web_bounces_dimensional_preaggregated" {
+ order_by = ["team_id", "job_id", "period_bucket", "host", "device_type", "entry_pathname", "end_pathname", "browser", "os", "viewport_width", "viewport_height", "referring_domain", "utm_source", "utm_medium", "utm_campaign", "utm_term", "utm_content", "country_code", "city_name", "region_code", "region_name", "has_gclid", "has_gad_source_paid_search", "has_fbclid", "mat_metadata_backend", "mat_metadata_loggedIn"]
+ partition_by = "toYYYYMMDD(expires_at)"
+ ttl = "toDateTime(expires_at)"
+ settings = {
+ allow_nullable_key = "1"
+ index_granularity = "8192"
+ ttl_only_drop_parts = "1"
+ }
+ column "team_id" {
+ type = "Int64"
+ }
+ column "job_id" {
+ type = "UUID"
+ }
+ column "period_bucket" {
+ type = "DateTime"
+ }
+ column "host" {
+ type = "String"
+ }
+ column "device_type" {
+ type = "String"
+ }
+ column "entry_pathname" {
+ type = "String"
+ }
+ column "end_pathname" {
+ type = "String"
+ }
+ column "browser" {
+ type = "String"
+ }
+ column "os" {
+ type = "String"
+ }
+ column "viewport_width" {
+ type = "Int64"
+ }
+ column "viewport_height" {
+ type = "Int64"
+ }
+ column "referring_domain" {
+ type = "String"
+ }
+ column "utm_source" {
+ type = "String"
+ }
+ column "utm_medium" {
+ type = "String"
+ }
+ column "utm_campaign" {
+ type = "String"
+ }
+ column "utm_term" {
+ type = "String"
+ }
+ column "utm_content" {
+ type = "String"
+ }
+ column "country_code" {
+ type = "String"
+ }
+ column "city_name" {
+ type = "String"
+ }
+ column "region_code" {
+ type = "String"
+ }
+ column "region_name" {
+ type = "String"
+ }
+ column "has_gclid" {
+ type = "Bool"
+ }
+ column "has_gad_source_paid_search" {
+ type = "Bool"
+ }
+ column "has_fbclid" {
+ type = "Bool"
+ }
+ column "mat_metadata_backend" {
+ type = "Nullable(String)"
+ }
+ column "mat_metadata_loggedIn" {
+ type = "Nullable(Bool)"
+ }
+ column "persons_uniq_state" {
+ type = "AggregateFunction(uniq, UUID)"
+ }
+ column "sessions_uniq_state" {
+ type = "AggregateFunction(uniq, String)"
+ }
+ column "pageviews_count_state" {
+ type = "AggregateFunction(sum, Int64)"
+ }
+ column "bounces_count_state" {
+ type = "AggregateFunction(sum, Int64)"
+ }
+ column "total_session_duration_state" {
+ type = "AggregateFunction(sum, Int64)"
+ }
+ column "total_session_count_state" {
+ type = "AggregateFunction(sum, Int64)"
+ }
+ column "computed_at" {
+ type = "DateTime64(6, 'UTC')"
+ default = "now()"
+ }
+ column "expires_at" {
+ type = "DateTime64(6, 'UTC')"
+ default = "now() + toIntervalDay(7)"
+ }
+ engine "replicated_replacing_merge_tree" {
+ zoo_path = "/clickhouse/tables/{shard}/posthog.web_bounces_dimensional_preaggregated"
+ replica_name = "{replica}"
+ version_column = "computed_at"
+ }
+ }
+
+ table "sharded_web_goals_preaggregated" {
+ order_by = ["team_id", "job_id", "action_id", "time_window_start"]
+ partition_by = "toYYYYMMDD(expires_at)"
+ ttl = "toDateTime(expires_at)"
+ settings = {
+ index_granularity = "8192"
+ ttl_only_drop_parts = "1"
+ }
+ column "team_id" {
+ type = "Int64"
+ }
+ column "job_id" {
+ type = "UUID"
+ }
+ column "time_window_start" {
+ type = "DateTime64(6, 'UTC')"
+ }
+ column "action_id" {
+ type = "Int64"
+ }
+ column "count_state" {
+ type = "AggregateFunction(sum, Int64)"
+ }
+ column "unique_persons_state" {
+ type = "AggregateFunction(uniq, UUID)"
+ }
+ column "computed_at" {
+ type = "DateTime64(6, 'UTC')"
+ default = "now()"
+ }
+ column "expires_at" {
+ type = "DateTime64(6, 'UTC')"
+ default = "now() + toIntervalDay(7)"
+ }
+ engine "replicated_replacing_merge_tree" {
+ zoo_path = "/clickhouse/tables/{shard}/posthog.web_goals_preaggregated"
+ replica_name = "{replica}"
+ version_column = "computed_at"
+ }
+ }
+
+ table "sharded_web_overview_preaggregated" {
+ order_by = ["team_id", "job_id", "time_window_start"]
+ partition_by = "toYYYYMMDD(expires_at)"
+ ttl = "toDateTime(expires_at)"
+ settings = {
+ index_granularity = "8192"
+ ttl_only_drop_parts = "1"
+ }
+ column "team_id" {
+ type = "Int64"
+ }
+ column "job_id" {
+ type = "UUID"
+ }
+ column "time_window_start" {
+ type = "DateTime64(6, 'UTC')"
+ }
+ column "uniq_users_state" {
+ type = "AggregateFunction(uniq, UUID)"
+ }
+ column "uniq_sessions_state" {
+ type = "AggregateFunction(uniq, String)"
+ }
+ column "sum_pageviews_state" {
+ type = "AggregateFunction(sum, Int64)"
+ }
+ column "avg_duration_state" {
+ type = "AggregateFunction(avg, Float64)"
+ }
+ column "avg_bounce_state" {
+ type = "AggregateFunction(avg, Int64)"
+ }
+ column "computed_at" {
+ type = "DateTime64(6, 'UTC')"
+ default = "now()"
+ }
+ column "expires_at" {
+ type = "DateTime64(6, 'UTC')"
+ default = "now() + toIntervalDay(7)"
+ }
+ engine "replicated_replacing_merge_tree" {
+ zoo_path = "/clickhouse/tables/{shard}/posthog.web_overview_preaggregated"
+ replica_name = "{replica}"
+ version_column = "computed_at"
+ }
+ }
+
+ table "sharded_web_stats_dimensional_preaggregated" {
+ order_by = ["team_id", "job_id", "period_bucket", "host", "device_type", "pathname", "entry_pathname", "end_pathname", "browser", "os", "viewport_width", "viewport_height", "referring_domain", "utm_source", "utm_medium", "utm_campaign", "utm_term", "utm_content", "country_code", "city_name", "region_code", "region_name", "has_gclid", "has_gad_source_paid_search", "has_fbclid", "mat_metadata_backend", "mat_metadata_loggedIn"]
+ partition_by = "toYYYYMMDD(expires_at)"
+ ttl = "toDateTime(expires_at)"
+ settings = {
+ allow_nullable_key = "1"
+ index_granularity = "8192"
+ ttl_only_drop_parts = "1"
+ }
+ column "team_id" {
+ type = "Int64"
+ }
+ column "job_id" {
+ type = "UUID"
+ }
+ column "period_bucket" {
+ type = "DateTime"
+ }
+ column "host" {
+ type = "String"
+ }
+ column "device_type" {
+ type = "String"
+ }
+ column "pathname" {
+ type = "String"
+ }
+ column "entry_pathname" {
+ type = "String"
+ }
+ column "end_pathname" {
+ type = "String"
+ }
+ column "browser" {
+ type = "String"
+ }
+ column "os" {
+ type = "String"
+ }
+ column "viewport_width" {
+ type = "Int64"
+ }
+ column "viewport_height" {
+ type = "Int64"
+ }
+ column "referring_domain" {
+ type = "String"
+ }
+ column "utm_source" {
+ type = "String"
+ }
+ column "utm_medium" {
+ type = "String"
+ }
+ column "utm_campaign" {
+ type = "String"
+ }
+ column "utm_term" {
+ type = "String"
+ }
+ column "utm_content" {
+ type = "String"
+ }
+ column "country_code" {
+ type = "String"
+ }
+ column "city_name" {
+ type = "String"
+ }
+ column "region_code" {
+ type = "String"
+ }
+ column "region_name" {
+ type = "String"
+ }
+ column "has_gclid" {
+ type = "Bool"
+ }
+ column "has_gad_source_paid_search" {
+ type = "Bool"
+ }
+ column "has_fbclid" {
+ type = "Bool"
+ }
+ column "mat_metadata_backend" {
+ type = "Nullable(String)"
+ }
+ column "mat_metadata_loggedIn" {
+ type = "Nullable(Bool)"
+ }
+ column "persons_uniq_state" {
+ type = "AggregateFunction(uniq, UUID)"
+ }
+ column "sessions_uniq_state" {
+ type = "AggregateFunction(uniq, String)"
+ }
+ column "pageviews_count_state" {
+ type = "AggregateFunction(sum, Int64)"
+ }
+ column "computed_at" {
+ type = "DateTime64(6, 'UTC')"
+ default = "now()"
+ }
+ column "expires_at" {
+ type = "DateTime64(6, 'UTC')"
+ default = "now() + toIntervalDay(7)"
+ }
+ engine "replicated_replacing_merge_tree" {
+ zoo_path = "/clickhouse/tables/{shard}/posthog.web_stats_dimensional_preaggregated"
+ replica_name = "{replica}"
+ version_column = "computed_at"
+ }
+ }
+
+ table "sharded_web_stats_frustration_preaggregated" {
+ order_by = ["team_id", "job_id", "breakdown_value", "time_window_start"]
+ partition_by = "toYYYYMMDD(expires_at)"
+ ttl = "toDateTime(expires_at)"
+ settings = {
+ index_granularity = "8192"
+ ttl_only_drop_parts = "1"
+ }
+ column "team_id" {
+ type = "Int64"
+ }
+ column "job_id" {
+ type = "UUID"
+ }
+ column "time_window_start" {
+ type = "DateTime64(6, 'UTC')"
+ }
+ column "breakdown_value" {
+ type = "String"
+ }
+ column "sum_rage_clicks_state" {
+ type = "AggregateFunction(sum, Int64)"
+ }
+ column "sum_dead_clicks_state" {
+ type = "AggregateFunction(sum, Int64)"
+ }
+ column "sum_errors_state" {
+ type = "AggregateFunction(sum, Int64)"
+ }
+ column "computed_at" {
+ type = "DateTime64(6, 'UTC')"
+ default = "now()"
+ }
+ column "expires_at" {
+ type = "DateTime64(6, 'UTC')"
+ default = "now() + toIntervalDay(7)"
+ }
+ engine "replicated_replacing_merge_tree" {
+ zoo_path = "/clickhouse/tables/{shard}/posthog.web_stats_frustration_preaggregated"
+ replica_name = "{replica}"
+ version_column = "computed_at"
+ }
+ }
+
+ table "sharded_web_stats_paths_preaggregated" {
+ order_by = ["team_id", "job_id", "breakdown_value", "time_window_start"]
+ partition_by = "toYYYYMMDD(expires_at)"
+ ttl = "toDateTime(expires_at)"
+ settings = {
+ index_granularity = "8192"
+ ttl_only_drop_parts = "1"
+ }
+ column "team_id" {
+ type = "Int64"
+ }
+ column "job_id" {
+ type = "UUID"
+ }
+ column "time_window_start" {
+ type = "DateTime64(6, 'UTC')"
+ }
+ column "breakdown_value" {
+ type = "String"
+ }
+ column "uniq_users_state" {
+ type = "AggregateFunction(uniq, UUID)"
+ }
+ column "sum_pageviews_state" {
+ type = "AggregateFunction(sum, Int64)"
+ }
+ column "avg_bounce_state" {
+ type = "AggregateFunction(avg, Nullable(Float64))"
+ }
+ column "computed_at" {
+ type = "DateTime64(6, 'UTC')"
+ default = "now()"
+ }
+ column "expires_at" {
+ type = "DateTime64(6, 'UTC')"
+ default = "now() + toIntervalDay(7)"
+ }
+ engine "replicated_replacing_merge_tree" {
+ zoo_path = "/clickhouse/tables/{shard}/posthog.web_stats_paths_preaggregated"
+ replica_name = "{replica}"
+ version_column = "computed_at"
+ }
+ }
+
+ table "sharded_web_stats_paths_preaggregated_pathkey" {
+ order_by = ["team_id", "time_window_start", "breakdown_value", "job_id"]
+ partition_by = "toYYYYMMDD(expires_at)"
+ ttl = "toDateTime(expires_at)"
+ settings = {
+ index_granularity = "8192"
+ ttl_only_drop_parts = "1"
+ }
+ column "team_id" {
+ type = "Int64"
+ }
+ column "job_id" {
+ type = "UUID"
+ }
+ column "time_window_start" {
+ type = "DateTime64(6, 'UTC')"
+ }
+ column "breakdown_value" {
+ type = "String"
+ }
+ column "uniq_users_state" {
+ type = "AggregateFunction(uniq, UUID)"
+ }
+ column "sum_pageviews_state" {
+ type = "AggregateFunction(sum, Int64)"
+ }
+ column "avg_bounce_state" {
+ type = "AggregateFunction(avg, Nullable(Float64))"
+ }
+ column "computed_at" {
+ type = "DateTime64(6, 'UTC')"
+ default = "now()"
+ }
+ column "expires_at" {
+ type = "DateTime64(6, 'UTC')"
+ default = "now() + toIntervalDay(7)"
+ }
+ engine "replicated_replacing_merge_tree" {
+ zoo_path = "/clickhouse/tables/{shard}/posthog.web_stats_paths_preaggregated_pathkey"
+ replica_name = "{replica}"
+ version_column = "computed_at"
+ }
+ }
+
+ table "sharded_web_stats_preaggregated" {
+ order_by = ["team_id", "job_id", "breakdown_by", "time_window_start", "breakdown_value"]
+ partition_by = "toYYYYMMDD(expires_at)"
+ ttl = "toDateTime(expires_at)"
+ settings = {
+ index_granularity = "8192"
+ ttl_only_drop_parts = "1"
+ }
+ column "team_id" {
+ type = "Int64"
+ }
+ column "job_id" {
+ type = "UUID"
+ }
+ column "time_window_start" {
+ type = "DateTime64(6, 'UTC')"
+ }
+ column "breakdown_by" {
+ type = "String"
+ }
+ column "breakdown_value" {
+ type = "String"
+ }
+ column "uniq_users_state" {
+ type = "AggregateFunction(uniq, UUID)"
+ }
+ column "sum_pageviews_state" {
+ type = "AggregateFunction(sum, Int64)"
+ }
+ column "computed_at" {
+ type = "DateTime64(6, 'UTC')"
+ default = "now()"
+ }
+ column "expires_at" {
+ type = "DateTime64(6, 'UTC')"
+ default = "now() + toIntervalDay(7)"
+ }
+ engine "replicated_replacing_merge_tree" {
+ zoo_path = "/clickhouse/tables/{shard}/posthog.web_stats_preaggregated"
+ replica_name = "{replica}"
+ version_column = "computed_at"
+ }
+ }
+
+ table "sharded_web_vitals_paths_preaggregated" {
+ order_by = ["team_id", "job_id", "time_window_start", "path"]
+ partition_by = "toYYYYMMDD(expires_at)"
+ ttl = "toDateTime(expires_at)"
+ settings = {
+ index_granularity = "8192"
+ ttl_only_drop_parts = "1"
+ }
+ column "team_id" {
+ type = "Int64"
+ }
+ column "job_id" {
+ type = "UUID"
+ }
+ column "time_window_start" {
+ type = "DateTime64(6, 'UTC')"
+ }
+ column "path" {
+ type = "String"
+ }
+ column "inp_quantiles_state" {
+ type = "AggregateFunction(quantiles(0.75, 0.9, 0.99), Float64)"
+ }
+ column "lcp_quantiles_state" {
+ type = "AggregateFunction(quantiles(0.75, 0.9, 0.99), Float64)"
+ }
+ column "cls_quantiles_state" {
+ type = "AggregateFunction(quantiles(0.75, 0.9, 0.99), Float64)"
+ }
+ column "fcp_quantiles_state" {
+ type = "AggregateFunction(quantiles(0.75, 0.9, 0.99), Float64)"
+ }
+ column "computed_at" {
+ type = "DateTime64(6, 'UTC')"
+ default = "now()"
+ }
+ column "expires_at" {
+ type = "DateTime64(6, 'UTC')"
+ default = "now() + toIntervalDay(7)"
+ }
+ engine "replicated_replacing_merge_tree" {
+ zoo_path = "/clickhouse/tables/{shard}/posthog.web_vitals_paths_preaggregated"
+ replica_name = "{replica}"
+ version_column = "computed_at"
+ }
+ }
+
+ table "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_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_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_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 "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"
+ }
+ }
+
+ materialized_view "error_tracking_fingerprint_issue_state_mv" {
+ to_table = "posthog.writable_error_tracking_fingerprint_issue_state"
+ query = <<SQL
+SELECT
+ team_id,
+ fingerprint,
+ issue_id,
+ issue_name,
+ issue_description,
+ issue_status,
+ assigned_user_id,
+ assigned_role_id,
+ first_seen,
+ is_deleted,
+ version,
+ _timestamp,
+ _offset,
+ _partition
+FROM posthog.kafka_error_tracking_fingerprint_issue_state
+SQL
+
+ column "team_id" {
+ type = "Int64"
+ }
+ column "fingerprint" {
+ type = "String"
+ }
+ column "issue_id" {
+ type = "UUID"
+ }
+ column "issue_name" {
+ type = "Nullable(String)"
+ }
+ column "issue_description" {
+ type = "Nullable(String)"
+ }
+ column "issue_status" {
+ type = "String"
+ }
+ column "assigned_user_id" {
+ type = "Nullable(Int64)"
+ }
+ column "assigned_role_id" {
+ type = "Nullable(UUID)"
+ }
+ column "first_seen" {
+ type = "DateTime64(3, 'UTC')"
+ }
+ column "is_deleted" {
+ type = "Int8"
+ }
+ column "version" {
+ type = "Int64"
+ }
+ column "_timestamp" {
+ type = "Nullable(DateTime)"
+ }
+ column "_offset" {
+ type = "UInt64"
+ }
+ column "_partition" {
+ type = "UInt64"
+ }
+ }
+
+ materialized_view "hog_invocation_results_mv" {
+ to_table = "posthog.hog_invocation_results_data"
+ query = <<SQL
+SELECT
+ team_id,
+ function_kind,
+ function_id,
+ invocation_id,
+ parent_run_id,
+ status,
+ attempts,
+ is_retry,
+ scheduled_at,
+ if(
+ first_scheduled_at = toDateTime64('1970-01-01 00:00:00', 6, 'UTC'),
+ scheduled_at,
+ first_scheduled_at
+ ) AS first_scheduled_at,
+ started_at,
+ finished_at,
+ duration_ms,
+ error_kind,
+ error_message,
+ event_uuid,
+ distinct_id,
+ person_id,
+ invocation_globals,
+ version,
+ is_deleted,
+ _timestamp,
+ _offset,
+ _partition
+FROM posthog.kafka_hog_invocation_results
+SQL
+
+ column "team_id" {
+ type = "Int64"
+ }
+ column "function_kind" {
+ type = "LowCardinality(String)"
+ }
+ column "function_id" {
+ type = "String"
+ }
+ column "invocation_id" {
+ type = "String"
+ }
+ column "parent_run_id" {
+ type = "String"
+ }
+ column "status" {
+ type = "LowCardinality(String)"
+ }
+ column "attempts" {
+ type = "UInt8"
+ }
+ column "is_retry" {
+ type = "UInt8"
+ }
+ column "scheduled_at" {
+ type = "DateTime64(6, 'UTC')"
+ }
+ column "first_scheduled_at" {
+ type = "DateTime64(6, 'UTC')"
+ }
+ column "started_at" {
+ type = "Nullable(DateTime64(6, 'UTC'))"
+ }
+ column "finished_at" {
+ type = "Nullable(DateTime64(6, 'UTC'))"
+ }
+ column "duration_ms" {
+ type = "Nullable(UInt32)"
+ }
+ column "error_kind" {
+ type = "LowCardinality(String)"
+ }
+ column "error_message" {
+ type = "String"
+ }
+ column "event_uuid" {
+ type = "String"
+ }
+ column "distinct_id" {
+ type = "String"
+ }
+ column "person_id" {
+ type = "String"
+ }
+ column "invocation_globals" {
+ type = "String"
+ }
+ column "version" {
+ type = "UInt64"
+ }
+ column "is_deleted" {
+ type = "UInt8"
+ }
+ column "_timestamp" {
+ type = "Nullable(DateTime)"
+ }
+ column "_offset" {
+ type = "UInt64"
+ }
+ column "_partition" {
+ type = "UInt64"
+ }
+ }
+
+ materialized_view "message_assets_mv" {
+ to_table = "posthog.message_assets_data"
+ query = <<SQL
+SELECT
+ team_id,
+ function_kind,
+ function_id,
+ parent_run_id,
+ invocation_id,
+ action_id,
+ kind,
+ distinct_id,
+ person_id,
+ recipient,
+ subject,
+ status,
+ sent_at,
+ version,
+ is_deleted,
+ html,
+ _timestamp,
+ _offset,
+ _partition
+FROM posthog.kafka_message_assets
+SQL
+
+ column "team_id" {
+ type = "Int64"
+ }
+ column "function_kind" {
+ type = "LowCardinality(String)"
+ }
+ column "function_id" {
+ type = "String"
+ }
+ column "parent_run_id" {
+ type = "String"
+ }
+ column "invocation_id" {
+ type = "String"
+ }
+ column "action_id" {
+ type = "String"
+ }
+ column "kind" {
+ type = "LowCardinality(String)"
+ }
+ column "distinct_id" {
+ type = "String"
+ }
+ column "person_id" {
+ type = "String"
+ }
+ column "recipient" {
+ type = "String"
+ }
+ column "subject" {
+ type = "String"
+ }
+ column "status" {
+ type = "LowCardinality(String)"
+ }
+ column "sent_at" {
+ type = "DateTime64(6, 'UTC')"
+ }
+ column "version" {
+ type = "UInt64"
+ }
+ column "is_deleted" {
+ type = "UInt8"
+ }
+ column "html" {
+ type = "String"
+ }
+ column "_timestamp" {
+ type = "Nullable(DateTime)"
+ }
+ column "_offset" {
+ type = "UInt64"
+ }
+ column "_partition" {
+ type = "UInt64"
+ }
+ }
+
+ materialized_view "ops_query_log_archive_mv" {
+ to_table = "posthog.writable_query_log_archive"
+ query = <<SQL
+SELECT
+ hostname,
+ user,
+ query_id,
+ initial_query_id,
+ is_initial_query,
+ type,
+ event_date,
+ event_time,
+ event_time_microseconds,
+ query_start_time,
+ query_start_time_microseconds,
+ query_duration_ms,
+ read_rows,
+ read_bytes,
+ written_rows,
+ written_bytes,
+ result_rows,
+ result_bytes,
+ memory_usage,
+ peak_threads_usage,
+ current_database,
+ query,
+ formatted_query,
+ normalized_query_hash,
+ query_kind,
+ exception_code,
+ exception,
+ stack_trace,
+ JSONExtractInt(log_comment, 'team_id') AS team_id,
+ if(isValidJSON(log_comment), log_comment, '{}') AS log_comment,
+ ProfileEvents
+FROM system.query_log
+WHERE type != 'QueryStart'
+SQL
+
+ column "hostname" {
+ type = "LowCardinality(String)"
+ }
+ column "user" {
+ type = "LowCardinality(String)"
+ }
+ column "query_id" {
+ type = "String"
+ }
+ column "initial_query_id" {
+ type = "String"
+ }
+ column "is_initial_query" {
+ type = "UInt8"
+ }
+ column "type" {
+ type = "Enum8('QueryStart'=1, 'QueryFinish'=2, 'ExceptionBeforeStart'=3, 'ExceptionWhileProcessing'=4)"
+ }
+ column "event_date" {
+ type = "Date"
+ }
+ column "event_time" {
+ type = "DateTime"
+ }
+ column "event_time_microseconds" {
+ type = "DateTime64(6)"
+ }
+ column "query_start_time" {
+ type = "DateTime"
+ }
+ column "query_start_time_microseconds" {
+ type = "DateTime64(6)"
+ }
+ column "query_duration_ms" {
+ type = "UInt64"
+ }
+ column "read_rows" {
+ type = "UInt64"
+ }
+ column "read_bytes" {
+ type = "UInt64"
+ }
+ column "written_rows" {
+ type = "UInt64"
+ }
+ column "written_bytes" {
+ type = "UInt64"
+ }
+ column "result_rows" {
+ type = "UInt64"
+ }
+ column "result_bytes" {
+ type = "UInt64"
+ }
+ column "memory_usage" {
+ type = "UInt64"
+ }
+ column "peak_threads_usage" {
+ type = "UInt64"
+ }
+ column "current_database" {
+ type = "LowCardinality(String)"
+ }
+ column "query" {
+ type = "String"
+ }
+ column "formatted_query" {
+ type = "String"
+ }
+ column "normalized_query_hash" {
+ type = "UInt64"
+ }
+ column "query_kind" {
+ type = "LowCardinality(String)"
+ }
+ column "exception_code" {
+ type = "Int32"
+ }
+ column "exception" {
+ type = "String"
+ }
+ column "stack_trace" {
+ type = "String"
+ }
+ column "team_id" {
+ type = "Int64"
+ }
+ column "log_comment" {
+ type = "String"
+ }
+ column "ProfileEvents" {
+ type = "Map(LowCardinality(String), UInt64)"
+ }
+ }
+
+ materialized_view "property_values_mv" {
+ to_table = "posthog.property_values"
+ query = <<SQL
+SELECT
+ team_id,
+ property_type,
+ property_key,
+ property_value,
+ property_count,
+ coalesce(_timestamp, now()) AS last_seen
+FROM posthog.kafka_property_values
+SQL
+
+ column "team_id" {
+ type = "Int64"
+ }
+ column "property_type" {
+ type = "LowCardinality(String)"
+ }
+ column "property_key" {
+ type = "String"
+ }
+ column "property_value" {
+ type = "String"
+ }
+ column "property_count" {
+ type = "UInt64"
+ }
+ column "last_seen" {
+ type = "DateTime"
+ }
+ }
+
+ 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
+
+ }
+
+ 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" {
+ }
+ }
+}
diff --git a/posthog/clickhouse/hcl/golden/local-sessions.hcl b/posthog/clickhouse/hcl/golden/local-sessions.hcl
new file mode 100644
index 000000000000..659228d54d89
--- /dev/null
+++ b/posthog/clickhouse/hcl/golden/local-sessions.hcl
@@ -0,0 +1,729 @@
+database "posthog" {
+ table "query_log_archive" {
+ column "hostname" {
+ type = "LowCardinality(String)"
+ }
+ column "user" {
+ type = "LowCardinality(String)"
+ }
+ column "query_id" {
+ type = "String"
+ }
+ column "initial_query_id" {
+ type = "String"
+ }
+ column "is_initial_query" {
+ type = "UInt8"
+ }
+ column "type" {
+ type = "Enum8('QueryStart'=1, 'QueryFinish'=2, 'ExceptionBeforeStart'=3, 'ExceptionWhileProcessing'=4)"
+ }
+ column "event_date" {
+ type = "Date"
+ }
+ column "event_time" {
+ type = "DateTime"
+ }
+ column "event_time_microseconds" {
+ type = "DateTime64(6)"
+ }
+ column "query_start_time" {
+ type = "DateTime"
+ }
+ column "query_start_time_microseconds" {
+ type = "DateTime64(6)"
+ }
+ column "query_duration_ms" {
+ type = "UInt64"
+ }
+ column "read_rows" {
+ type = "UInt64"
+ }
+ column "read_bytes" {
+ type = "UInt64"
+ }
+ column "written_rows" {
+ type = "UInt64"
+ }
+ column "written_bytes" {
+ type = "UInt64"
+ }
+ column "result_rows" {
+ type = "UInt64"
+ }
+ column "result_bytes" {
+ type = "UInt64"
+ }
+ column "memory_usage" {
+ type = "UInt64"
+ }
+ column "peak_threads_usage" {
+ type = "UInt64"
+ }
+ column "current_database" {
+ type = "LowCardinality(String)"
+ }
+ column "query" {
+ type = "String"
+ }
+ column "formatted_query" {
+ type = "String"
+ }
+ column "normalized_query_hash" {
+ type = "UInt64"
+ }
+ column "query_kind" {
+ type = "LowCardinality(String)"
+ }
+ column "exception_code" {
+ type = "Int32"
+ }
+ column "exception" {
+ type = "String"
+ }
+ column "stack_trace" {
+ type = "String"
+ }
+ column "team_id" {
+ type = "Int64"
+ }
+ column "log_comment" {
+ type = "JSON(max_dynamic_paths=256, access_method LowCardinality(String), alert_config_id String, api_key_label String, api_key_mask String, batch_export_id String, chargeable Bool, client_query_id String, cohort_id Int64, `dagster.job_name` String, `dagster.run_id` String, `dagster.tags.owner` String, dashboard_id Int64, experiment_feature_flag_key String, experiment_id Int64, feature LowCardinality(String), id String, insight_id Int64, is_impersonated Bool, kind LowCardinality(String), name String, org_id String, person_on_events_mode LowCardinality(String), product LowCardinality(String), query_type LowCardinality(String), request_name String, route_id String, service_name String, session_id String, table_id String, team_id Int64, `temporal.activity_id` String, `temporal.activity_type` String, `temporal.attempt` Int64, `temporal.workflow_id` String, `temporal.workflow_namespace` String, `temporal.workflow_run_id` String, `temporal.workflow_type` String, user_id Int64, warehouse_query Bool, workflow LowCardinality(String), workload LowCardinality(String), SKIP cache_key, SKIP filter, SKIP hogql_features, SKIP http_referer, SKIP http_request_id, SKIP http_user_agent, SKIP query_settings, SKIP timings, SKIP user_email)"
+ }
+ column "ProfileEvents" {
+ type = "Map(String, UInt64)"
+ }
+ column "exception_name" {
+ type = "String"
+ alias = "errorCodeToName(exception_code)"
+ }
+ column "ProfileEvents_RealTimeMicroseconds" {
+ type = "Int64"
+ alias = "ProfileEvents['RealTimeMicroseconds']"
+ }
+ column "ProfileEvents_OSCPUVirtualTimeMicroseconds" {
+ type = "Int64"
+ alias = "ProfileEvents['OSCPUVirtualTimeMicroseconds']"
+ }
+ column "ProfileEvents_S3Clients" {
+ type = "Int64"
+ alias = "ProfileEvents['S3Clients']"
+ }
+ column "ProfileEvents_S3DeleteObjects" {
+ type = "Int64"
+ alias = "ProfileEvents['S3DeleteObjects']"
+ }
+ column "ProfileEvents_S3CopyObject" {
+ type = "Int64"
+ alias = "ProfileEvents['S3CopyObject']"
+ }
+ column "ProfileEvents_S3ListObjects" {
+ type = "Int64"
+ alias = "ProfileEvents['S3ListObjects']"
+ }
+ column "ProfileEvents_S3HeadObject" {
+ type = "Int64"
+ alias = "ProfileEvents['S3HeadObject']"
+ }
+ column "ProfileEvents_S3GetObjectAttributes" {
+ type = "Int64"
+ alias = "ProfileEvents['S3GetObjectAttributes']"
+ }
+ column "ProfileEvents_S3CreateMultipartUpload" {
+ type = "Int64"
+ alias = "ProfileEvents['S3CreateMultipartUpload']"
+ }
+ column "ProfileEvents_S3UploadPartCopy" {
+ type = "Int64"
+ alias = "ProfileEvents['S3UploadPartCopy']"
+ }
+ column "ProfileEvents_S3UploadPart" {
+ type = "Int64"
+ alias = "ProfileEvents['S3UploadPart']"
+ }
+ column "ProfileEvents_S3AbortMultipartUpload" {
+ type = "Int64"
+ alias = "ProfileEvents['S3AbortMultipartUpload']"
+ }
+ column "ProfileEvents_S3CompleteMultipartUpload" {
+ type = "Int64"
+ alias = "ProfileEvents['S3CompleteMultipartUpload']"
+ }
+ column "ProfileEvents_S3PutObject" {
+ type = "Int64"
+ alias = "ProfileEvents['S3PutObject']"
+ }
+ column "ProfileEvents_S3GetObject" {
+ type = "Int64"
+ alias = "ProfileEvents['S3GetObject']"
+ }
+ column "ProfileEvents_ReadBufferFromS3Bytes" {
+ type = "Int64"
+ alias = "ProfileEvents['ReadBufferFromS3Bytes']"
+ }
+ column "ProfileEvents_WriteBufferFromS3Bytes" {
+ type = "Int64"
+ alias = "ProfileEvents['WriteBufferFromS3Bytes']"
+ }
+ column "lc_workflow" {
+ type = "LowCardinality(String)"
+ alias = "log_comment.workflow"
+ }
+ column "lc_kind" {
+ type = "LowCardinality(String)"
+ alias = "log_comment.kind"
+ }
+ column "lc_id" {
+ type = "String"
+ alias = "CAST(log_comment.id, 'String')"
+ }
+ column "lc_route_id" {
+ type = "String"
+ alias = "CAST(log_comment.route_id, 'String')"
+ }
+ column "lc_access_method" {
+ type = "LowCardinality(String)"
+ alias = "log_comment.access_method"
+ }
+ column "lc_api_key_label" {
+ type = "String"
+ alias = "CAST(log_comment.api_key_label, 'String')"
+ }
+ column "lc_api_key_mask" {
+ type = "String"
+ alias = "CAST(log_comment.api_key_mask, 'String')"
+ }
+ column "lc_query_type" {
+ type = "LowCardinality(String)"
+ alias = "log_comment.query_type"
+ }
+ column "lc_product" {
+ type = "LowCardinality(String)"
+ alias = "log_comment.product"
+ }
+ column "lc_chargeable" {
+ type = "Bool"
+ alias = "log_comment.chargeable"
+ }
+ column "lc_name" {
+ type = "String"
+ alias = "CAST(log_comment.name, 'String')"
+ }
+ column "lc_request_name" {
+ type = "String"
+ alias = "CAST(log_comment.request_name, 'String')"
+ }
+ column "lc_client_query_id" {
+ type = "String"
+ alias = "CAST(log_comment.client_query_id, 'String')"
+ }
+ column "lc_org_id" {
+ type = "String"
+ alias = "CAST(log_comment.org_id, 'String')"
+ }
+ column "lc_user_id" {
+ type = "Int64"
+ alias = "log_comment.user_id"
+ }
+ column "lc_is_impersonated" {
+ type = "Bool"
+ alias = "log_comment.is_impersonated"
+ }
+ column "lc_session_id" {
+ type = "String"
+ alias = "CAST(log_comment.session_id, 'String')"
+ }
+ column "lc_dashboard_id" {
+ type = "Int64"
+ alias = "log_comment.dashboard_id"
+ }
+ column "lc_insight_id" {
+ type = "Int64"
+ alias = "log_comment.insight_id"
+ }
+ column "lc_cohort_id" {
+ type = "Int64"
+ alias = "log_comment.cohort_id"
+ }
+ column "lc_batch_export_id" {
+ type = "String"
+ alias = "CAST(log_comment.batch_export_id, 'String')"
+ }
+ column "lc_experiment_id" {
+ type = "Int64"
+ alias = "log_comment.experiment_id"
+ }
+ column "lc_experiment_feature_flag_key" {
+ type = "String"
+ alias = "CAST(log_comment.experiment_feature_flag_key, 'String')"
+ }
+ column "lc_alert_config_id" {
+ type = "String"
+ alias = "CAST(log_comment.alert_config_id, 'String')"
+ }
+ column "lc_feature" {
+ type = "LowCardinality(String)"
+ alias = "log_comment.feature"
+ }
+ column "lc_table_id" {
+ type = "String"
+ alias = "CAST(log_comment.table_id, 'String')"
+ }
+ column "lc_warehouse_query" {
+ type = "Bool"
+ alias = "log_comment.warehouse_query"
+ }
+ column "lc_person_on_events_mode" {
+ type = "LowCardinality(String)"
+ alias = "log_comment.person_on_events_mode"
+ }
+ column "lc_service_name" {
+ type = "String"
+ alias = "CAST(log_comment.service_name, 'String')"
+ }
+ column "lc_workload" {
+ type = "LowCardinality(String)"
+ alias = "log_comment.workload"
+ }
+ column "lc_query__kind" {
+ type = "LowCardinality(String)"
+ alias = "if(JSONHas(toString(log_comment), 'query', 'source'), JSONExtractString(toString(log_comment), 'query', 'source', 'kind'), JSONExtractString(toString(log_comment), 'query', 'kind'))"
+ }
+ column "lc_query__query" {
+ type = "String"
+ alias = "multiIf(NOT is_initial_query, '', JSONHas(toString(log_comment), 'query', 'source'), JSONExtractString(toString(log_comment), 'query', 'source', 'query'), JSONExtractString(toString(log_comment), 'query', 'query'))"
+ }
+ column "lc_query" {
+ type = "String"
+ alias = "if(is_initial_query, JSONExtractRaw(toString(log_comment), 'query'), '')"
+ }
+ column "lc_temporal__workflow_namespace" {
+ type = "String"
+ alias = "CAST(log_comment.`temporal.workflow_namespace`, 'String')"
+ }
+ column "lc_temporal__workflow_type" {
+ type = "String"
+ alias = "CAST(log_comment.`temporal.workflow_type`, 'String')"
+ }
+ column "lc_temporal__workflow_id" {
+ type = "String"
+ alias = "CAST(log_comment.`temporal.workflow_id`, 'String')"
+ }
+ column "lc_temporal__workflow_run_id" {
+ type = "String"
+ alias = "CAST(log_comment.`temporal.workflow_run_id`, 'String')"
+ }
+ column "lc_temporal__activity_type" {
+ type = "String"
+ alias = "CAST(log_comment.`temporal.activity_type`, 'String')"
+ }
+ column "lc_temporal__activity_id" {
+ type = "String"
+ alias = "CAST(log_comment.`temporal.activity_id`, 'String')"
+ }
+ column "lc_temporal__attempt" {
+ type = "Int64"
+ alias = "log_comment.`temporal.attempt`"
+ }
+ column "lc_dagster__job_name" {
+ type = "String"
+ alias = "CAST(log_comment.`dagster.job_name`, 'String')"
+ }
+ column "lc_dagster__run_id" {
+ type = "String"
+ alias = "CAST(log_comment.`dagster.run_id`, 'String')"
+ }
+ column "lc_dagster__owner" {
+ type = "String"
+ alias = "CAST(log_comment.`dagster.tags.owner`, 'String')"
+ }
+ column "lc_modifiers" {
+ type = "String"
+ alias = "if(is_initial_query, JSONExtractRaw(toString(log_comment), 'modifiers'), '')"
+ }
+ engine "distributed" {
+ cluster_name = "ops"
+ remote_database = "posthog"
+ remote_table = "sharded_query_log_archive"
+ }
+ }
+
+ table "writable_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"
+ }
+ }
+
+ 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)"
+ }
+ }
+
+ 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
+
+ }
+}
diff --git a/posthog/clickhouse/hcl/golden/prod-eu-aux.hcl b/posthog/clickhouse/hcl/golden/prod-eu-aux.hcl
new file mode 100644
index 000000000000..7f4363aa69b3
--- /dev/null
+++ b/posthog/clickhouse/hcl/golden/prod-eu-aux.hcl
@@ -0,0 +1,3773 @@
+database "posthog" {
+ 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 "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 "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 "hog_invocation_results" {
+ column "team_id" {
+ type = "Int64"
+ }
+ column "function_kind" {
+ type = "LowCardinality(String)"
+ }
+ column "function_id" {
+ type = "String"
+ }
+ column "invocation_id" {
+ type = "String"
+ }
+ column "parent_run_id" {
+ type = "String"
+ }
+ column "status" {
+ type = "LowCardinality(String)"
+ }
+ column "attempts" {
+ type = "UInt8"
+ }
+ column "is_retry" {
+ type = "UInt8"
+ }
+ column "scheduled_at" {
+ type = "DateTime64(6, 'UTC')"
+ }
+ column "first_scheduled_at" {
+ type = "DateTime64(6, 'UTC')"
+ }
+ column "started_at" {
+ type = "Nullable(DateTime64(6, 'UTC'))"
+ }
+ column "finished_at" {
+ type = "Nullable(DateTime64(6, 'UTC'))"
+ }
+ column "duration_ms" {
+ type = "Nullable(UInt32)"
+ }
+ column "error_kind" {
+ type = "LowCardinality(String)"
+ }
+ column "error_message" {
+ type = "String"
+ }
+ column "event_uuid" {
+ type = "String"
+ }
+ column "distinct_id" {
+ type = "String"
+ }
+ column "person_id" {
+ type = "String"
+ }
+ column "invocation_globals" {
+ type = "String"
+ }
+ column "version" {
+ type = "UInt64"
+ }
+ column "is_deleted" {
+ type = "UInt8"
+ }
+ column "_timestamp" {
+ type = "DateTime"
+ }
+ column "_offset" {
+ type = "UInt64"
+ }
+ column "_partition" {
+ type = "UInt64"
+ }
+ engine "distributed" {
+ cluster_name = "aux"
+ remote_database = "posthog"
+ remote_table = "hog_invocation_results_data"
+ }
+ }
+
+ table "hog_invocation_results_data" {
+ order_by = ["team_id", "function_kind", "function_id", "invocation_id"]
+ partition_by = "toYYYYMMDD(scheduled_at)"
+ ttl = "toDate(scheduled_at) + toIntervalDay(30)"
+ settings = {
+ index_granularity = "1024"
+ storage_policy = "s3_tiered"
+ ttl_only_drop_parts = "1"
+ }
+ column "team_id" {
+ type = "Int64"
+ }
+ column "function_kind" {
+ type = "LowCardinality(String)"
+ }
+ column "function_id" {
+ type = "String"
+ }
+ column "invocation_id" {
+ type = "String"
+ }
+ column "parent_run_id" {
+ type = "String"
+ }
+ column "status" {
+ type = "LowCardinality(String)"
+ }
+ column "attempts" {
+ type = "UInt8"
+ }
+ column "is_retry" {
+ type = "UInt8"
+ }
+ column "scheduled_at" {
+ type = "DateTime64(6, 'UTC')"
+ }
+ column "first_scheduled_at" {
+ type = "DateTime64(6, 'UTC')"
+ default = "scheduled_at"
+ }
+ column "started_at" {
+ type = "Nullable(DateTime64(6, 'UTC'))"
+ }
+ column "finished_at" {
+ type = "Nullable(DateTime64(6, 'UTC'))"
+ }
+ column "duration_ms" {
+ type = "Nullable(UInt32)"
+ }
+ column "error_kind" {
+ type = "LowCardinality(String)"
+ }
+ column "error_message" {
+ type = "String"
+ }
+ column "event_uuid" {
+ type = "String"
+ }
+ column "distinct_id" {
+ type = "String"
+ }
+ column "person_id" {
+ type = "String"
+ }
+ column "invocation_globals" {
+ type = "String"
+ }
+ column "version" {
+ type = "UInt64"
+ }
+ column "is_deleted" {
+ type = "UInt8"
+ default = "0"
+ }
+ column "_timestamp" {
+ type = "DateTime"
+ }
+ column "_offset" {
+ type = "UInt64"
+ }
+ column "_partition" {
+ type = "UInt64"
+ }
+ index "status_idx" {
+ expr = "status"
+ type = "set(8)"
+ granularity = 1
+ }
+ index "function_idx" {
+ expr = "function_id"
+ type = "bloom_filter(0.01)"
+ granularity = 1
+ }
+ index "event_uuid_idx" {
+ expr = "event_uuid"
+ type = "bloom_filter(0.01)"
+ granularity = 1
+ }
+ index "is_retry_idx" {
+ expr = "is_retry"
+ type = "set(2)"
+ granularity = 1
+ }
+ engine "replicated_replacing_merge_tree" {
+ zoo_path = "/clickhouse/tables/noshard/posthog.hog_invocation_results_data"
+ replica_name = "{replica}-{shard}"
+ version_column = "version"
+ }
+ }
+
+ table "kafka_hog_invocation_results" {
+ column "team_id" {
+ type = "Int64"
+ }
+ column "function_kind" {
+ type = "LowCardinality(String)"
+ }
+ column "function_id" {
+ type = "String"
+ }
+ column "invocation_id" {
+ type = "String"
+ }
+ column "parent_run_id" {
+ type = "String"
+ }
+ column "status" {
+ type = "LowCardinality(String)"
+ }
+ column "attempts" {
+ type = "UInt8"
+ }
+ column "is_retry" {
+ type = "UInt8"
+ }
+ column "scheduled_at" {
+ type = "DateTime64(6, 'UTC')"
+ }
+ column "first_scheduled_at" {
+ type = "DateTime64(6, 'UTC')"
+ }
+ column "started_at" {
+ type = "Nullable(DateTime64(6, 'UTC'))"
+ }
+ column "finished_at" {
+ type = "Nullable(DateTime64(6, 'UTC'))"
+ }
+ column "duration_ms" {
+ type = "Nullable(UInt32)"
+ }
+ column "error_kind" {
+ type = "LowCardinality(String)"
+ }
+ column "error_message" {
+ type = "String"
+ }
+ column "event_uuid" {
+ type = "String"
+ }
+ column "distinct_id" {
+ type = "String"
+ }
+ column "person_id" {
+ type = "String"
+ }
+ column "invocation_globals" {
+ type = "String"
+ }
+ column "version" {
+ type = "UInt64"
+ }
+ column "is_deleted" {
+ type = "UInt8"
+ }
+ engine "kafka" {
+ broker_list = "warpstream_cyclotron"
+ topic_list = "kafka_topic_list = 'clickhouse_hog_invocation_results'"
+ group_name = "kafka_group_name = 'clickhouse_hog_invocation_results'"
+ format = "kafka_format = 'JSONEachRow'"
+ skip_broken_messages = 100
+ }
+ }
+
+ table "kafka_message_assets" {
+ column "team_id" {
+ type = "Int64"
+ }
+ column "function_kind" {
+ type = "LowCardinality(String)"
+ }
+ column "function_id" {
+ type = "String"
+ }
+ column "parent_run_id" {
+ type = "String"
+ }
+ column "invocation_id" {
+ type = "String"
+ }
+ column "action_id" {
+ type = "String"
+ }
+ column "kind" {
+ type = "LowCardinality(String)"
+ }
+ column "distinct_id" {
+ type = "String"
+ }
+ column "person_id" {
+ type = "String"
+ }
+ column "recipient" {
+ type = "String"
+ }
+ column "subject" {
+ type = "String"
+ }
+ column "status" {
+ type = "LowCardinality(String)"
+ }
+ column "sent_at" {
+ type = "DateTime64(6, 'UTC')"
+ }
+ column "version" {
+ type = "UInt64"
+ }
+ column "is_deleted" {
+ type = "UInt8"
+ }
+ column "html" {
+ type = "String"
+ }
+ engine "kafka" {
+ broker_list = "warpstream_cyclotron"
+ topic_list = "kafka_topic_list = 'clickhouse_message_assets'"
+ group_name = "kafka_group_name = 'clickhouse_message_assets'"
+ format = "kafka_format = 'JSONEachRow'"
+ skip_broken_messages = 100
+ }
+ }
+
+ table "kafka_property_values" {
+ column "team_id" {
+ type = "Int64"
+ }
+ column "property_type" {
+ type = "LowCardinality(String)"
+ }
+ column "property_key" {
+ type = "String"
+ }
+ column "property_value" {
+ type = "String"
+ }
+ column "property_count" {
+ type = "UInt64"
+ }
+ engine "kafka" {
+ broker_list = "warpstream_ingestion"
+ topic_list = "kafka_topic_list = 'clickhouse_property_values'"
+ group_name = "kafka_group_name = 'clickhouse_property_values'"
+ format = "kafka_format = 'JSONEachRow'"
+ num_consumers = 8
+ thread_per_consumer = true
+ }
+ }
+
+ table "marketing_conversions_preaggregated" {
+ column "team_id" {
+ type = "Int64"
+ }
+ column "job_id" {
+ type = "UUID"
+ }
+ column "person_id" {
+ type = "UUID"
+ }
+ column "conversion_timestamp" {
+ type = "DateTime64(6, 'UTC')"
+ }
+ column "conversion_math_value" {
+ type = "Float64"
+ }
+ column "session_id" {
+ type = "String"
+ }
+ column "campaign_name" {
+ type = "String"
+ }
+ column "source_name" {
+ type = "String"
+ }
+ column "medium_name" {
+ type = "String"
+ }
+ column "content_name" {
+ type = "String"
+ }
+ column "term_name" {
+ type = "String"
+ }
+ column "referring_domain_name" {
+ type = "String"
+ }
+ column "gclid_name" {
+ type = "String"
+ }
+ column "fbclid_name" {
+ type = "String"
+ }
+ column "gad_source_name" {
+ type = "String"
+ }
+ column "computed_at" {
+ type = "DateTime64(6, 'UTC')"
+ default = "now()"
+ }
+ column "expires_at" {
+ type = "Date"
+ default = "today() + toIntervalDay(7)"
+ }
+ engine "distributed" {
+ cluster_name = "aux"
+ remote_database = "posthog"
+ remote_table = "sharded_marketing_conversions_preaggregated"
+ sharding_key = "cityHash64(person_id)"
+ }
+ }
+
+ table "marketing_costs_preaggregated" {
+ column "team_id" {
+ type = "Int64"
+ }
+ column "job_id" {
+ type = "UUID"
+ }
+ column "source_id" {
+ type = "String"
+ }
+ column "source_name" {
+ type = "String"
+ }
+ column "grain" {
+ type = "LowCardinality(String)"
+ }
+ column "match_key" {
+ type = "String"
+ }
+ column "campaign_id" {
+ type = "String"
+ }
+ column "campaign_name" {
+ type = "String"
+ }
+ column "ad_group_id" {
+ type = "String"
+ }
+ column "ad_group_name" {
+ type = "String"
+ }
+ column "ad_id" {
+ type = "String"
+ }
+ column "ad_name" {
+ type = "String"
+ }
+ column "cost_date" {
+ type = "Date"
+ }
+ column "cost" {
+ type = "Float64"
+ }
+ column "clicks" {
+ type = "Float64"
+ }
+ column "impressions" {
+ type = "Float64"
+ }
+ column "reported_conversions" {
+ type = "Float64"
+ }
+ column "reported_conversion_value" {
+ type = "Float64"
+ }
+ column "computed_at" {
+ type = "DateTime64(6, 'UTC')"
+ default = "now()"
+ }
+ column "expires_at" {
+ type = "Date"
+ default = "today() + toIntervalDay(7)"
+ }
+ engine "distributed" {
+ cluster_name = "aux"
+ remote_database = "posthog"
+ remote_table = "sharded_marketing_costs_preaggregated"
+ sharding_key = "cityHash64(source_name, campaign_id)"
+ }
+ }
+
+ table "marketing_touchpoints_preaggregated" {
+ column "team_id" {
+ type = "Int64"
+ }
+ column "job_id" {
+ type = "UUID"
+ }
+ column "person_id" {
+ type = "UUID"
+ }
+ column "touchpoint_timestamp" {
+ type = "DateTime64(6, 'UTC')"
+ }
+ column "campaign_name" {
+ type = "String"
+ }
+ column "source_name" {
+ type = "String"
+ }
+ column "medium_name" {
+ type = "String"
+ }
+ column "content_name" {
+ type = "String"
+ }
+ column "term_name" {
+ type = "String"
+ }
+ column "referring_domain_name" {
+ type = "String"
+ }
+ column "gclid_name" {
+ type = "String"
+ }
+ column "fbclid_name" {
+ type = "String"
+ }
+ column "gad_source_name" {
+ type = "String"
+ }
+ column "computed_at" {
+ type = "DateTime64(6, 'UTC')"
+ default = "now()"
+ }
+ column "expires_at" {
+ type = "Date"
+ default = "today() + toIntervalDay(7)"
+ }
+ engine "distributed" {
+ cluster_name = "aux"
+ remote_database = "posthog"
+ remote_table = "sharded_marketing_touchpoints_preaggregated"
+ sharding_key = "cityHash64(person_id)"
+ }
+ }
+
+ table "message_assets" {
+ column "team_id" {
+ type = "Int64"
+ }
+ column "function_kind" {
+ type = "LowCardinality(String)"
+ }
+ column "function_id" {
+ type = "String"
+ }
+ column "parent_run_id" {
+ type = "String"
+ }
+ column "invocation_id" {
+ type = "String"
+ }
+ column "action_id" {
+ type = "String"
+ }
+ column "kind" {
+ type = "LowCardinality(String)"
+ }
+ column "distinct_id" {
+ type = "String"
+ }
+ column "person_id" {
+ type = "String"
+ }
+ column "recipient" {
+ type = "String"
+ }
+ column "subject" {
+ type = "String"
+ }
+ column "status" {
+ type = "LowCardinality(String)"
+ }
+ column "sent_at" {
+ type = "DateTime64(6, 'UTC')"
+ }
+ column "version" {
+ type = "UInt64"
+ }
+ column "is_deleted" {
+ type = "UInt8"
+ }
+ column "html" {
+ type = "String"
+ }
+ column "_timestamp" {
+ type = "DateTime"
+ }
+ column "_offset" {
+ type = "UInt64"
+ }
+ column "_partition" {
+ type = "UInt64"
+ }
+ engine "distributed" {
+ cluster_name = "aux"
+ remote_database = "posthog"
+ remote_table = "message_assets_data"
+ }
+ }
+
+ table "message_assets_data" {
+ order_by = ["team_id", "function_kind", "function_id", "invocation_id", "action_id"]
+ partition_by = "toYYYYMMDD(sent_at)"
+ ttl = "toDate(sent_at) + toIntervalDay(30)"
+ settings = {
+ index_granularity = "1024"
+ ttl_only_drop_parts = "1"
+ }
+ column "team_id" {
+ type = "Int64"
+ }
+ column "function_kind" {
+ type = "LowCardinality(String)"
+ }
+ column "function_id" {
+ type = "String"
+ }
+ column "parent_run_id" {
+ type = "String"
+ }
+ column "invocation_id" {
+ type = "String"
+ }
+ column "action_id" {
+ type = "String"
+ }
+ column "kind" {
+ type = "LowCardinality(String)"
+ }
+ column "distinct_id" {
+ type = "String"
+ }
+ column "person_id" {
+ type = "String"
+ }
+ column "recipient" {
+ type = "String"
+ }
+ column "subject" {
+ type = "String"
+ }
+ column "status" {
+ type = "LowCardinality(String)"
+ }
+ column "sent_at" {
+ type = "DateTime64(6, 'UTC')"
+ }
+ column "version" {
+ type = "UInt64"
+ }
+ column "is_deleted" {
+ type = "UInt8"
+ default = "0"
+ }
+ column "html" {
+ type = "String"
+ codec = "ZSTD(3)"
+ }
+ column "_timestamp" {
+ type = "DateTime"
+ }
+ column "_offset" {
+ type = "UInt64"
+ }
+ column "_partition" {
+ type = "UInt64"
+ }
+ index "parent_run_idx" {
+ expr = "parent_run_id"
+ type = "bloom_filter(0.01)"
+ granularity = 1
+ }
+ index "distinct_id_idx" {
+ expr = "distinct_id"
+ type = "bloom_filter(0.01)"
+ granularity = 1
+ }
+ index "person_id_idx" {
+ expr = "person_id"
+ type = "bloom_filter(0.01)"
+ granularity = 1
+ }
+ index "recipient_idx" {
+ expr = "recipient"
+ type = "bloom_filter(0.01)"
+ granularity = 1
+ }
+ engine "replicated_replacing_merge_tree" {
+ zoo_path = "/clickhouse/tables/noshard/posthog.message_assets_data"
+ replica_name = "{replica}-{shard}"
+ version_column = "version"
+ }
+ }
+
+ table "property_values" {
+ order_by = ["team_id", "property_type", "property_key", "property_value"]
+ ttl = "last_seen + toIntervalDay(30)"
+ settings = {
+ index_granularity = "8192"
+ }
+ column "team_id" {
+ type = "Int64"
+ codec = "DoubleDelta, ZSTD(1)"
+ }
+ column "property_type" {
+ type = "LowCardinality(String)"
+ }
+ column "property_key" {
+ type = "LowCardinality(String)"
+ }
+ column "property_value" {
+ type = "String"
+ }
+ column "property_count" {
+ type = "SimpleAggregateFunction(sum, UInt64)"
+ }
+ column "last_seen" {
+ type = "SimpleAggregateFunction(max, DateTime)"
+ default = "now()"
+ }
+ index "idx_property_value_ngrambf" {
+ expr = "lower(property_value)"
+ type = "ngrambf_v1(3, 32768, 3, 0)"
+ granularity = 1
+ }
+ engine "replicated_aggregating_merge_tree" {
+ zoo_path = "/clickhouse/tables/noshard/posthog.property_values"
+ replica_name = "{replica}-{shard}"
+ }
+ }
+
+ table "property_values_distributed" {
+ column "team_id" {
+ type = "Int64"
+ codec = "DoubleDelta, ZSTD(1)"
+ }
+ column "property_type" {
+ type = "LowCardinality(String)"
+ }
+ column "property_key" {
+ type = "LowCardinality(String)"
+ }
+ column "property_value" {
+ type = "String"
+ }
+ column "property_count" {
+ type = "SimpleAggregateFunction(sum, UInt64)"
+ }
+ column "last_seen" {
+ type = "SimpleAggregateFunction(max, DateTime)"
+ default = "now()"
+ }
+ engine "distributed" {
+ cluster_name = "aux"
+ remote_database = "posthog"
+ remote_table = "property_values"
+ }
+ }
+
+ table "query_log_archive" {
+ column "hostname" {
+ type = "LowCardinality(String)"
+ }
+ column "user" {
+ type = "LowCardinality(String)"
+ }
+ column "query_id" {
+ type = "String"
+ }
+ column "initial_query_id" {
+ type = "String"
+ }
+ column "is_initial_query" {
+ type = "UInt8"
+ }
+ column "type" {
+ type = "Enum8('QueryStart'=1, 'QueryFinish'=2, 'ExceptionBeforeStart'=3, 'ExceptionWhileProcessing'=4)"
+ }
+ column "event_date" {
+ type = "Date"
+ }
+ column "event_time" {
+ type = "DateTime"
+ }
+ column "event_time_microseconds" {
+ type = "DateTime64(6)"
+ }
+ column "query_start_time" {
+ type = "DateTime"
+ }
+ column "query_start_time_microseconds" {
+ type = "DateTime64(6)"
+ }
+ column "query_duration_ms" {
+ type = "UInt64"
+ }
+ column "read_rows" {
+ type = "UInt64"
+ }
+ column "read_bytes" {
+ type = "UInt64"
+ }
+ column "written_rows" {
+ type = "UInt64"
+ }
+ column "written_bytes" {
+ type = "UInt64"
+ }
+ column "result_rows" {
+ type = "UInt64"
+ }
+ column "result_bytes" {
+ type = "UInt64"
+ }
+ column "memory_usage" {
+ type = "UInt64"
+ }
+ column "peak_threads_usage" {
+ type = "UInt64"
+ }
+ column "current_database" {
+ type = "LowCardinality(String)"
+ }
+ column "query" {
+ type = "String"
+ }
+ column "formatted_query" {
+ type = "String"
+ }
+ column "normalized_query_hash" {
+ type = "UInt64"
+ }
+ column "query_kind" {
+ type = "LowCardinality(String)"
+ }
+ column "exception_code" {
+ type = "Int32"
+ }
+ column "exception" {
+ type = "String"
+ }
+ column "stack_trace" {
+ type = "String"
+ }
+ column "team_id" {
+ type = "Int64"
+ }
+ column "log_comment" {
+ type = "JSON(max_dynamic_paths=256, access_method LowCardinality(String), alert_config_id String, api_key_label String, api_key_mask String, batch_export_id String, chargeable Bool, client_query_id String, cohort_id Int64, `dagster.job_name` String, `dagster.run_id` String, `dagster.tags.owner` String, dashboard_id Int64, experiment_feature_flag_key String, experiment_id Int64, feature LowCardinality(String), id String, insight_id Int64, is_impersonated Bool, kind LowCardinality(String), name String, org_id String, person_on_events_mode LowCardinality(String), product LowCardinality(String), query_type LowCardinality(String), request_name String, route_id String, service_name String, session_id String, table_id String, team_id Int64, `temporal.activity_id` String, `temporal.activity_type` String, `temporal.attempt` Int64, `temporal.workflow_id` String, `temporal.workflow_namespace` String, `temporal.workflow_run_id` String, `temporal.workflow_type` String, user_id Int64, warehouse_query Bool, workflow LowCardinality(String), workload LowCardinality(String), SKIP cache_key, SKIP filter, SKIP hogql_features, SKIP http_referer, SKIP http_request_id, SKIP http_user_agent, SKIP query_settings, SKIP timings, SKIP user_email)"
+ }
+ column "ProfileEvents" {
+ type = "Map(String, UInt64)"
+ }
+ column "exception_name" {
+ type = "String"
+ alias = "errorCodeToName(exception_code)"
+ }
+ column "ProfileEvents_RealTimeMicroseconds" {
+ type = "Int64"
+ alias = "ProfileEvents['RealTimeMicroseconds']"
+ }
+ column "ProfileEvents_OSCPUVirtualTimeMicroseconds" {
+ type = "Int64"
+ alias = "ProfileEvents['OSCPUVirtualTimeMicroseconds']"
+ }
+ column "ProfileEvents_S3Clients" {
+ type = "Int64"
+ alias = "ProfileEvents['S3Clients']"
+ }
+ column "ProfileEvents_S3DeleteObjects" {
+ type = "Int64"
+ alias = "ProfileEvents['S3DeleteObjects']"
+ }
+ column "ProfileEvents_S3CopyObject" {
+ type = "Int64"
+ alias = "ProfileEvents['S3CopyObject']"
+ }
+ column "ProfileEvents_S3ListObjects" {
+ type = "Int64"
+ alias = "ProfileEvents['S3ListObjects']"
+ }
+ column "ProfileEvents_S3HeadObject" {
+ type = "Int64"
+ alias = "ProfileEvents['S3HeadObject']"
+ }
+ column "ProfileEvents_S3GetObjectAttributes" {
+ type = "Int64"
+ alias = "ProfileEvents['S3GetObjectAttributes']"
+ }
+ column "ProfileEvents_S3CreateMultipartUpload" {
+ type = "Int64"
+ alias = "ProfileEvents['S3CreateMultipartUpload']"
+ }
+ column "ProfileEvents_S3UploadPartCopy" {
+ type = "Int64"
+ alias = "ProfileEvents['S3UploadPartCopy']"
+ }
+ column "ProfileEvents_S3UploadPart" {
+ type = "Int64"
+ alias = "ProfileEvents['S3UploadPart']"
+ }
+ column "ProfileEvents_S3AbortMultipartUpload" {
+ type = "Int64"
+ alias = "ProfileEvents['S3AbortMultipartUpload']"
+ }
+ column "ProfileEvents_S3CompleteMultipartUpload" {
+ type = "Int64"
+ alias = "ProfileEvents['S3CompleteMultipartUpload']"
+ }
+ column "ProfileEvents_S3PutObject" {
+ type = "Int64"
+ alias = "ProfileEvents['S3PutObject']"
+ }
+ column "ProfileEvents_S3GetObject" {
+ type = "Int64"
+ alias = "ProfileEvents['S3GetObject']"
+ }
+ column "ProfileEvents_ReadBufferFromS3Bytes" {
+ type = "Int64"
+ alias = "ProfileEvents['ReadBufferFromS3Bytes']"
+ }
+ column "ProfileEvents_WriteBufferFromS3Bytes" {
+ type = "Int64"
+ alias = "ProfileEvents['WriteBufferFromS3Bytes']"
+ }
+ column "lc_workflow" {
+ type = "LowCardinality(String)"
+ alias = "log_comment.workflow"
+ }
+ column "lc_kind" {
+ type = "LowCardinality(String)"
+ alias = "log_comment.kind"
+ }
+ column "lc_id" {
+ type = "String"
+ alias = "CAST(log_comment.id, 'String')"
+ }
+ column "lc_route_id" {
+ type = "String"
+ alias = "CAST(log_comment.route_id, 'String')"
+ }
+ column "lc_access_method" {
+ type = "LowCardinality(String)"
+ alias = "log_comment.access_method"
+ }
+ column "lc_api_key_label" {
+ type = "String"
+ alias = "CAST(log_comment.api_key_label, 'String')"
+ }
+ column "lc_api_key_mask" {
+ type = "String"
+ alias = "CAST(log_comment.api_key_mask, 'String')"
+ }
+ column "lc_query_type" {
+ type = "LowCardinality(String)"
+ alias = "log_comment.query_type"
+ }
+ column "lc_product" {
+ type = "LowCardinality(String)"
+ alias = "log_comment.product"
+ }
+ column "lc_chargeable" {
+ type = "Bool"
+ alias = "log_comment.chargeable"
+ }
+ column "lc_name" {
+ type = "String"
+ alias = "CAST(log_comment.name, 'String')"
+ }
+ column "lc_request_name" {
+ type = "String"
+ alias = "CAST(log_comment.request_name, 'String')"
+ }
+ column "lc_client_query_id" {
+ type = "String"
+ alias = "CAST(log_comment.client_query_id, 'String')"
+ }
+ column "lc_org_id" {
+ type = "String"
+ alias = "CAST(log_comment.org_id, 'String')"
+ }
+ column "lc_user_id" {
+ type = "Int64"
+ alias = "log_comment.user_id"
+ }
+ column "lc_is_impersonated" {
+ type = "Bool"
+ alias = "log_comment.is_impersonated"
+ }
+ column "lc_session_id" {
+ type = "String"
+ alias = "CAST(log_comment.session_id, 'String')"
+ }
+ column "lc_dashboard_id" {
+ type = "Int64"
+ alias = "log_comment.dashboard_id"
+ }
+ column "lc_insight_id" {
+ type = "Int64"
+ alias = "log_comment.insight_id"
+ }
+ column "lc_cohort_id" {
+ type = "Int64"
+ alias = "log_comment.cohort_id"
+ }
+ column "lc_batch_export_id" {
+ type = "String"
+ alias = "CAST(log_comment.batch_export_id, 'String')"
+ }
+ column "lc_experiment_id" {
+ type = "Int64"
+ alias = "log_comment.experiment_id"
+ }
+ column "lc_experiment_feature_flag_key" {
+ type = "String"
+ alias = "CAST(log_comment.experiment_feature_flag_key, 'String')"
+ }
+ column "lc_alert_config_id" {
+ type = "String"
+ alias = "CAST(log_comment.alert_config_id, 'String')"
+ }
+ column "lc_feature" {
+ type = "LowCardinality(String)"
+ alias = "log_comment.feature"
+ }
+ column "lc_table_id" {
+ type = "String"
+ alias = "CAST(log_comment.table_id, 'String')"
+ }
+ column "lc_warehouse_query" {
+ type = "Bool"
+ alias = "log_comment.warehouse_query"
+ }
+ column "lc_person_on_events_mode" {
+ type = "LowCardinality(String)"
+ alias = "log_comment.person_on_events_mode"
+ }
+ column "lc_service_name" {
+ type = "String"
+ alias = "CAST(log_comment.service_name, 'String')"
+ }
+ column "lc_workload" {
+ type = "LowCardinality(String)"
+ alias = "log_comment.workload"
+ }
+ column "lc_query__kind" {
+ type = "LowCardinality(String)"
+ alias = "if(JSONHas(toString(log_comment), 'query', 'source'), JSONExtractString(toString(log_comment), 'query', 'source', 'kind'), JSONExtractString(toString(log_comment), 'query', 'kind'))"
+ }
+ column "lc_query__query" {
+ type = "String"
+ alias = "multiIf(NOT is_initial_query, '', JSONHas(toString(log_comment), 'query', 'source'), JSONExtractString(toString(log_comment), 'query', 'source', 'query'), JSONExtractString(toString(log_comment), 'query', 'query'))"
+ }
+ column "lc_query" {
+ type = "String"
+ alias = "if(is_initial_query, JSONExtractRaw(toString(log_comment), 'query'), '')"
+ }
+ column "lc_temporal__workflow_namespace" {
+ type = "String"
+ alias = "CAST(log_comment.`temporal.workflow_namespace`, 'String')"
+ }
+ column "lc_temporal__workflow_type" {
+ type = "String"
+ alias = "CAST(log_comment.`temporal.workflow_type`, 'String')"
+ }
+ column "lc_temporal__workflow_id" {
+ type = "String"
+ alias = "CAST(log_comment.`temporal.workflow_id`, 'String')"
+ }
+ column "lc_temporal__workflow_run_id" {
+ type = "String"
+ alias = "CAST(log_comment.`temporal.workflow_run_id`, 'String')"
+ }
+ column "lc_temporal__activity_type" {
+ type = "String"
+ alias = "CAST(log_comment.`temporal.activity_type`, 'String')"
+ }
+ column "lc_temporal__activity_id" {
+ type = "String"
+ alias = "CAST(log_comment.`temporal.activity_id`, 'String')"
+ }
+ column "lc_temporal__attempt" {
+ type = "Int64"
+ alias = "log_comment.`temporal.attempt`"
+ }
+ column "lc_dagster__job_name" {
+ type = "String"
+ alias = "CAST(log_comment.`dagster.job_name`, 'String')"
+ }
+ column "lc_dagster__run_id" {
+ type = "String"
+ alias = "CAST(log_comment.`dagster.run_id`, 'String')"
+ }
+ column "lc_dagster__owner" {
+ type = "String"
+ alias = "CAST(log_comment.`dagster.tags.owner`, 'String')"
+ }
+ column "lc_modifiers" {
+ type = "String"
+ alias = "if(is_initial_query, JSONExtractRaw(toString(log_comment), 'modifiers'), '')"
+ }
+ engine "distributed" {
+ cluster_name = "ops"
+ remote_database = "posthog"
+ remote_table = "sharded_query_log_archive"
+ }
+ }
+
+ table "raw_error_tracking_fingerprint_issue_state" {
+ order_by = ["team_id", "fingerprint"]
+ settings = {
+ index_granularity = "512"
+ }
+ column "team_id" {
+ type = "Int64"
+ }
+ column "fingerprint" {
+ type = "String"
+ }
+ column "issue_id" {
+ type = "UUID"
+ }
+ column "issue_name" {
+ type = "Nullable(String)"
+ }
+ column "issue_description" {
+ type = "Nullable(String)"
+ }
+ column "issue_status" {
+ type = "String"
+ }
+ column "assigned_user_id" {
+ type = "Nullable(Int64)"
+ }
+ column "assigned_role_id" {
+ type = "Nullable(UUID)"
+ }
+ column "first_seen" {
+ type = "DateTime64(3, 'UTC')"
+ }
+ column "is_deleted" {
+ type = "Int8"
+ }
+ column "version" {
+ type = "Int64"
+ }
+ column "_timestamp" {
+ type = "DateTime"
+ }
+ column "_offset" {
+ type = "UInt64"
+ }
+ column "_partition" {
+ type = "UInt64"
+ }
+ index "kafka_timestamp_minmax_raw_error_tracking_fingerprint_issue_state" {
+ expr = "_timestamp"
+ type = "minmax"
+ granularity = 3
+ }
+ engine "replicated_replacing_merge_tree" {
+ zoo_path = "/clickhouse/tables/noshard/posthog.raw_error_tracking_fingerprint_issue_state"
+ replica_name = "{replica}-{shard}"
+ version_column = "version"
+ }
+ }
+
+ table "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 "sharded_conversion_goal_attributed_preaggregated" {
+ order_by = ["team_id", "job_id", "person_id", "conversion_timestamp", "touchpoint_timestamp"]
+ partition_by = "toYYYYMMDD(expires_at)"
+ ttl = "expires_at"
+ settings = {
+ index_granularity = "8192"
+ ttl_only_drop_parts = "1"
+ }
+ column "team_id" {
+ type = "Int64"
+ }
+ column "job_id" {
+ type = "UUID"
+ }
+ column "person_id" {
+ type = "UUID"
+ }
+ column "conversion_timestamp" {
+ type = "DateTime64(6, 'UTC')"
+ }
+ column "conversion_value" {
+ type = "Float64"
+ }
+ column "touchpoint_timestamp" {
+ type = "DateTime64(6, 'UTC')"
+ }
+ column "touchpoint_weight" {
+ type = "Float64"
+ }
+ column "campaign_name" {
+ type = "String"
+ }
+ column "source_name" {
+ type = "String"
+ }
+ column "medium_name" {
+ type = "String"
+ }
+ column "content_name" {
+ type = "String"
+ }
+ column "term_name" {
+ type = "String"
+ }
+ column "referring_domain_name" {
+ type = "String"
+ }
+ column "gclid_name" {
+ type = "String"
+ }
+ column "fbclid_name" {
+ type = "String"
+ }
+ column "gad_source_name" {
+ type = "String"
+ }
+ column "computed_at" {
+ type = "DateTime64(6, 'UTC')"
+ default = "now()"
+ }
+ column "expires_at" {
+ type = "Date"
+ default = "today() + toIntervalDay(7)"
+ }
+ engine "replicated_replacing_merge_tree" {
+ zoo_path = "/clickhouse/tables/noshard/posthog.conversion_goal_attributed_preaggregated"
+ replica_name = "{replica}-{shard}"
+ version_column = "computed_at"
+ }
+ }
+
+ table "sharded_experiment_metric_events_preaggregated" {
+ order_by = ["team_id", "job_id", "entity_id", "timestamp", "event_uuid"]
+ partition_by = "toYYYYMMDD(expires_at)"
+ ttl = "expires_at"
+ settings = {
+ index_granularity = "8192"
+ ttl_only_drop_parts = "1"
+ }
+ column "team_id" {
+ type = "Int64"
+ }
+ column "job_id" {
+ type = "UUID"
+ }
+ column "entity_id" {
+ type = "String"
+ }
+ column "timestamp" {
+ type = "DateTime64(6, 'UTC')"
+ }
+ column "event_uuid" {
+ type = "UUID"
+ }
+ column "session_id" {
+ type = "String"
+ }
+ column "numeric_value" {
+ type = "Float64"
+ default = "0"
+ }
+ column "steps" {
+ type = "Array(UInt8)"
+ default = "[]"
+ }
+ column "computed_at" {
+ type = "DateTime64(6, 'UTC')"
+ default = "now()"
+ }
+ column "expires_at" {
+ type = "Date"
+ default = "today() + toIntervalDay(7)"
+ }
+ engine "replicated_replacing_merge_tree" {
+ zoo_path = "/clickhouse/tables/noshard/posthog.experiment_metric_events_preaggregated"
+ replica_name = "{replica}-{shard}"
+ version_column = "computed_at"
+ }
+ }
+
+ table "sharded_marketing_conversions_preaggregated" {
+ order_by = ["team_id", "job_id", "person_id", "conversion_timestamp"]
+ partition_by = "toYYYYMMDD(expires_at)"
+ ttl = "expires_at"
+ settings = {
+ index_granularity = "8192"
+ ttl_only_drop_parts = "1"
+ }
+ column "team_id" {
+ type = "Int64"
+ }
+ column "job_id" {
+ type = "UUID"
+ }
+ column "person_id" {
+ type = "UUID"
+ }
+ column "conversion_timestamp" {
+ type = "DateTime64(6, 'UTC')"
+ }
+ column "conversion_math_value" {
+ type = "Float64"
+ }
+ column "session_id" {
+ type = "String"
+ }
+ column "campaign_name" {
+ type = "String"
+ }
+ column "source_name" {
+ type = "String"
+ }
+ column "medium_name" {
+ type = "String"
+ }
+ column "content_name" {
+ type = "String"
+ }
+ column "term_name" {
+ type = "String"
+ }
+ column "referring_domain_name" {
+ type = "String"
+ }
+ column "gclid_name" {
+ type = "String"
+ }
+ column "fbclid_name" {
+ type = "String"
+ }
+ column "gad_source_name" {
+ type = "String"
+ }
+ column "computed_at" {
+ type = "DateTime64(6, 'UTC')"
+ default = "now()"
+ }
+ column "expires_at" {
+ type = "Date"
+ default = "today() + toIntervalDay(7)"
+ }
+ engine "replicated_replacing_merge_tree" {
+ zoo_path = "/clickhouse/tables/noshard/posthog.marketing_conversions_preaggregated"
+ replica_name = "{replica}-{shard}"
+ version_column = "computed_at"
+ }
+ }
+
+ table "sharded_marketing_costs_preaggregated" {
+ order_by = ["team_id", "job_id", "source_name", "grain", "campaign_id", "ad_group_id", "ad_id", "cost_date"]
+ partition_by = "toYYYYMMDD(expires_at)"
+ ttl = "expires_at"
+ settings = {
+ index_granularity = "8192"
+ ttl_only_drop_parts = "1"
+ }
+ column "team_id" {
+ type = "Int64"
+ }
+ column "job_id" {
+ type = "UUID"
+ }
+ column "source_id" {
+ type = "String"
+ }
+ column "source_name" {
+ type = "String"
+ }
+ column "grain" {
+ type = "LowCardinality(String)"
+ }
+ column "match_key" {
+ type = "String"
+ }
+ column "campaign_id" {
+ type = "String"
+ }
+ column "campaign_name" {
+ type = "String"
+ }
+ column "ad_group_id" {
+ type = "String"
+ }
+ column "ad_group_name" {
+ type = "String"
+ }
+ column "ad_id" {
+ type = "String"
+ }
+ column "ad_name" {
+ type = "String"
+ }
+ column "cost_date" {
+ type = "Date"
+ }
+ column "cost" {
+ type = "Float64"
+ }
+ column "clicks" {
+ type = "Float64"
+ }
+ column "impressions" {
+ type = "Float64"
+ }
+ column "reported_conversions" {
+ type = "Float64"
+ }
+ column "reported_conversion_value" {
+ type = "Float64"
+ }
+ column "computed_at" {
+ type = "DateTime64(6, 'UTC')"
+ default = "now()"
+ }
+ column "expires_at" {
+ type = "Date"
+ default = "today() + toIntervalDay(7)"
+ }
+ engine "replicated_replacing_merge_tree" {
+ zoo_path = "/clickhouse/tables/noshard/posthog.marketing_costs_preaggregated"
+ replica_name = "{replica}-{shard}"
+ version_column = "computed_at"
+ }
+ }
+
+ table "sharded_marketing_touchpoints_preaggregated" {
+ order_by = ["team_id", "job_id", "person_id", "touchpoint_timestamp"]
+ partition_by = "toYYYYMMDD(expires_at)"
+ ttl = "expires_at"
+ settings = {
+ index_granularity = "8192"
+ ttl_only_drop_parts = "1"
+ }
+ column "team_id" {
+ type = "Int64"
+ }
+ column "job_id" {
+ type = "UUID"
+ }
+ column "person_id" {
+ type = "UUID"
+ }
+ column "touchpoint_timestamp" {
+ type = "DateTime64(6, 'UTC')"
+ }
+ column "campaign_name" {
+ type = "String"
+ }
+ column "source_name" {
+ type = "String"
+ }
+ column "medium_name" {
+ type = "String"
+ }
+ column "content_name" {
+ type = "String"
+ }
+ column "term_name" {
+ type = "String"
+ }
+ column "referring_domain_name" {
+ type = "String"
+ }
+ column "gclid_name" {
+ type = "String"
+ }
+ column "fbclid_name" {
+ type = "String"
+ }
+ column "gad_source_name" {
+ type = "String"
+ }
+ column "computed_at" {
+ type = "DateTime64(6, 'UTC')"
+ default = "now()"
+ }
+ column "expires_at" {
+ type = "Date"
+ default = "today() + toIntervalDay(7)"
+ }
+ engine "replicated_replacing_merge_tree" {
+ zoo_path = "/clickhouse/tables/noshard/posthog.marketing_touchpoints_preaggregated"
+ replica_name = "{replica}-{shard}"
+ version_column = "computed_at"
+ }
+ }
+
+ table "sharded_session_replay_features" {
+ order_by = ["team_id", "session_id"]
+ partition_by = "toYYYYMM(min_first_timestamp)"
+ settings = {
+ index_granularity = "512"
+ }
+ column "session_id" {
+ type = "String"
+ }
+ column "team_id" {
+ type = "Int64"
+ }
+ column "distinct_id" {
+ type = "String"
+ }
+ column "min_first_timestamp" {
+ type = "SimpleAggregateFunction(min, DateTime64(6, 'UTC'))"
+ }
+ column "max_last_timestamp" {
+ type = "SimpleAggregateFunction(max, DateTime64(6, 'UTC'))"
+ }
+ column "event_count" {
+ type = "SimpleAggregateFunction(sum, Int64)"
+ }
+ column "mouse_position_count" {
+ type = "SimpleAggregateFunction(sum, Int64)"
+ }
+ column "mouse_sum_x" {
+ type = "SimpleAggregateFunction(sum, Float64)"
+ }
+ column "mouse_sum_x_squared" {
+ type = "SimpleAggregateFunction(sum, Float64)"
+ }
+ column "mouse_sum_y" {
+ type = "SimpleAggregateFunction(sum, Float64)"
+ }
+ column "mouse_sum_y_squared" {
+ type = "SimpleAggregateFunction(sum, Float64)"
+ }
+ column "mouse_distance_traveled" {
+ type = "SimpleAggregateFunction(sum, Float64)"
+ }
+ column "mouse_direction_change_count" {
+ type = "SimpleAggregateFunction(sum, Int64)"
+ }
+ column "mouse_velocity_sum" {
+ type = "SimpleAggregateFunction(sum, Float64)"
+ }
+ column "mouse_velocity_sum_of_squares" {
+ type = "SimpleAggregateFunction(sum, Float64)"
+ }
+ column "mouse_velocity_count" {
+ type = "SimpleAggregateFunction(sum, Int64)"
+ }
+ column "scroll_event_count" {
+ type = "SimpleAggregateFunction(sum, Int64)"
+ }
+ column "total_scroll_magnitude" {
+ type = "SimpleAggregateFunction(sum, Float64)"
+ }
+ column "scroll_direction_reversal_count" {
+ type = "SimpleAggregateFunction(sum, Int64)"
+ }
+ column "rapid_scroll_reversal_count" {
+ type = "SimpleAggregateFunction(sum, Int64)"
+ }
+ column "scroll_to_top_count" {
+ type = "SimpleAggregateFunction(sum, Int64)"
+ }
+ column "click_count" {
+ type = "SimpleAggregateFunction(sum, Int64)"
+ }
+ column "keypress_count" {
+ type = "SimpleAggregateFunction(sum, Int64)"
+ }
+ column "mouse_activity_count" {
+ type = "SimpleAggregateFunction(sum, Int64)"
+ }
+ column "rage_click_count" {
+ type = "SimpleAggregateFunction(sum, Int64)"
+ }
+ column "dead_click_count" {
+ type = "SimpleAggregateFunction(sum, Int64)"
+ }
+ column "backspace_count" {
+ type = "SimpleAggregateFunction(sum, Int64)"
+ }
+ column "inter_action_gap_count" {
+ type = "SimpleAggregateFunction(sum, Int64)"
+ }
+ column "inter_action_gap_sum_ms" {
+ type = "SimpleAggregateFunction(sum, Float64)"
+ }
+ column "inter_action_gap_sum_of_squares_ms" {
+ type = "SimpleAggregateFunction(sum, Float64)"
+ }
+ column "max_idle_gap_ms" {
+ type = "SimpleAggregateFunction(max, Float64)"
+ }
+ column "long_idle_gap_count" {
+ type = "SimpleAggregateFunction(sum, Int64)"
+ }
+ column "quick_back_count" {
+ type = "SimpleAggregateFunction(sum, Int64)"
+ }
+ column "page_visit_count" {
+ type = "SimpleAggregateFunction(sum, Int64)"
+ }
+ column "unique_url_count" {
+ type = "AggregateFunction(uniqCombined(12), String)"
+ }
+ column "login_path_visit_count" {
+ type = "SimpleAggregateFunction(sum, Int64)"
+ }
+ column "signup_path_visit_count" {
+ type = "SimpleAggregateFunction(sum, Int64)"
+ }
+ column "checkout_path_visit_count" {
+ type = "SimpleAggregateFunction(sum, Int64)"
+ }
+ column "cart_path_visit_count" {
+ type = "SimpleAggregateFunction(sum, Int64)"
+ }
+ column "billing_path_visit_count" {
+ type = "SimpleAggregateFunction(sum, Int64)"
+ }
+ column "settings_path_visit_count" {
+ type = "SimpleAggregateFunction(sum, Int64)"
+ }
+ column "account_path_visit_count" {
+ type = "SimpleAggregateFunction(sum, Int64)"
+ }
+ column "error_path_visit_count" {
+ type = "SimpleAggregateFunction(sum, Int64)"
+ }
+ column "not_found_path_visit_count" {
+ type = "SimpleAggregateFunction(sum, Int64)"
+ }
+ column "admin_path_visit_count" {
+ type = "SimpleAggregateFunction(sum, Int64)"
+ }
+ column "dashboard_path_visit_count" {
+ type = "SimpleAggregateFunction(sum, Int64)"
+ }
+ column "onboarding_path_visit_count" {
+ type = "SimpleAggregateFunction(sum, Int64)"
+ }
+ column "cancel_path_visit_count" {
+ type = "SimpleAggregateFunction(sum, Int64)"
+ }
+ column "refund_path_visit_count" {
+ type = "SimpleAggregateFunction(sum, Int64)"
+ }
+ column "console_error_count" {
+ type = "SimpleAggregateFunction(sum, Int64)"
+ }
+ column "console_error_after_click_count" {
+ type = "SimpleAggregateFunction(sum, Int64)"
+ }
+ column "console_warn_count" {
+ type = "SimpleAggregateFunction(sum, Int64)"
+ }
+ column "network_request_count" {
+ type = "SimpleAggregateFunction(sum, Int64)"
+ }
+ column "network_failed_request_count" {
+ type = "SimpleAggregateFunction(sum, Int64)"
+ }
+ column "network_4xx_count" {
+ type = "SimpleAggregateFunction(sum, Int64)"
+ }
+ column "network_5xx_count" {
+ type = "SimpleAggregateFunction(sum, Int64)"
+ }
+ column "network_request_duration_sum" {
+ type = "SimpleAggregateFunction(sum, Float64)"
+ }
+ column "network_request_duration_sum_of_squares" {
+ type = "SimpleAggregateFunction(sum, Float64)"
+ }
+ column "network_request_duration_count" {
+ type = "SimpleAggregateFunction(sum, Int64)"
+ }
+ column "mutation_count" {
+ type = "SimpleAggregateFunction(sum, Int64)"
+ }
+ column "viewport_resize_count" {
+ type = "SimpleAggregateFunction(sum, Int64)"
+ }
+ column "touch_event_count" {
+ type = "SimpleAggregateFunction(sum, Int64)"
+ }
+ column "max_scroll_y" {
+ type = "SimpleAggregateFunction(max, Float64)"
+ }
+ column "unique_click_target_count" {
+ type = "AggregateFunction(uniqCombined(12), Int64)"
+ }
+ column "unique_form_field_count" {
+ type = "AggregateFunction(uniqCombined(12), Int64)"
+ }
+ column "text_selection_count" {
+ type = "SimpleAggregateFunction(sum, Int64)"
+ }
+ column "selection_copy_count" {
+ type = "SimpleAggregateFunction(sum, Int64)"
+ }
+ column "is_deleted" {
+ type = "SimpleAggregateFunction(max, UInt8)"
+ default = "0"
+ }
+ engine "replicated_aggregating_merge_tree" {
+ zoo_path = "/clickhouse/tables/{shard}/posthog.session_replay_features"
+ replica_name = "{replica}"
+ }
+ }
+
+ table "sharded_usage_report_events_preagg" {
+ order_by = ["date", "team_id", "person_mode", "lib", "event"]
+ partition_by = "date"
+ ttl = "date + toIntervalDay(14)"
+ settings = {
+ index_granularity = "8192"
+ ttl_only_drop_parts = "1"
+ }
+ column "date" {
+ type = "Date"
+ }
+ column "team_id" {
+ type = "Int64"
+ }
+ column "person_mode" {
+ type = "LowCardinality(String)"
+ }
+ column "lib" {
+ type = "LowCardinality(String)"
+ }
+ column "event" {
+ type = "String"
+ }
+ column "distinct_events_unique" {
+ type = "AggregateFunction(uniqExact, Tuple(UInt64, UInt64, UInt64))"
+ }
+ column "event_count" {
+ type = "AggregateFunction(sum, UInt64)"
+ }
+ engine "replicated_aggregating_merge_tree" {
+ zoo_path = "/clickhouse/tables/{shard}/posthog.sharded_usage_report_events_preagg"
+ replica_name = "{replica}"
+ }
+ }
+
+ table "sharded_web_bot_definition" {
+ order_by = ["id"]
+ settings = {
+ index_granularity = "8192"
+ }
+ column "id" {
+ type = "UInt64"
+ }
+ column "parent_id" {
+ type = "UInt64"
+ }
+ column "regexp" {
+ type = "String"
+ }
+ column "keys" {
+ type = "Array(String)"
+ }
+ column "values" {
+ type = "Array(String)"
+ }
+ engine "replicated_merge_tree" {
+ zoo_path = "/clickhouse/tables/{shard}/posthog.sharded_web_bot_definition"
+ replica_name = "{replica}"
+ }
+ }
+
+ table "sharded_web_bounces_dimensional_preaggregated" {
+ order_by = ["team_id", "job_id", "period_bucket", "host", "device_type", "entry_pathname", "end_pathname", "browser", "os", "viewport_width", "viewport_height", "referring_domain", "utm_source", "utm_medium", "utm_campaign", "utm_term", "utm_content", "country_code", "city_name", "region_code", "region_name", "has_gclid", "has_gad_source_paid_search", "has_fbclid", "mat_metadata_backend", "mat_metadata_loggedIn"]
+ partition_by = "toYYYYMMDD(expires_at)"
+ ttl = "toDateTime(expires_at)"
+ settings = {
+ allow_nullable_key = "1"
+ index_granularity = "8192"
+ ttl_only_drop_parts = "1"
+ }
+ column "team_id" {
+ type = "Int64"
+ }
+ column "job_id" {
+ type = "UUID"
+ }
+ column "period_bucket" {
+ type = "DateTime"
+ }
+ column "host" {
+ type = "String"
+ }
+ column "device_type" {
+ type = "String"
+ }
+ column "entry_pathname" {
+ type = "String"
+ }
+ column "end_pathname" {
+ type = "String"
+ }
+ column "browser" {
+ type = "String"
+ }
+ column "os" {
+ type = "String"
+ }
+ column "viewport_width" {
+ type = "Int64"
+ }
+ column "viewport_height" {
+ type = "Int64"
+ }
+ column "referring_domain" {
+ type = "String"
+ }
+ column "utm_source" {
+ type = "String"
+ }
+ column "utm_medium" {
+ type = "String"
+ }
+ column "utm_campaign" {
+ type = "String"
+ }
+ column "utm_term" {
+ type = "String"
+ }
+ column "utm_content" {
+ type = "String"
+ }
+ column "country_code" {
+ type = "String"
+ }
+ column "city_name" {
+ type = "String"
+ }
+ column "region_code" {
+ type = "String"
+ }
+ column "region_name" {
+ type = "String"
+ }
+ column "has_gclid" {
+ type = "Bool"
+ }
+ column "has_gad_source_paid_search" {
+ type = "Bool"
+ }
+ column "has_fbclid" {
+ type = "Bool"
+ }
+ column "mat_metadata_backend" {
+ type = "Nullable(String)"
+ }
+ column "mat_metadata_loggedIn" {
+ type = "Nullable(Bool)"
+ }
+ column "persons_uniq_state" {
+ type = "AggregateFunction(uniq, UUID)"
+ }
+ column "sessions_uniq_state" {
+ type = "AggregateFunction(uniq, String)"
+ }
+ column "pageviews_count_state" {
+ type = "AggregateFunction(sum, Int64)"
+ }
+ column "bounces_count_state" {
+ type = "AggregateFunction(sum, Int64)"
+ }
+ column "total_session_duration_state" {
+ type = "AggregateFunction(sum, Int64)"
+ }
+ column "total_session_count_state" {
+ type = "AggregateFunction(sum, Int64)"
+ }
+ column "computed_at" {
+ type = "DateTime64(6, 'UTC')"
+ default = "now()"
+ }
+ column "expires_at" {
+ type = "DateTime64(6, 'UTC')"
+ default = "now() + toIntervalDay(7)"
+ }
+ engine "replicated_replacing_merge_tree" {
+ zoo_path = "/clickhouse/tables/{shard}/posthog.web_bounces_dimensional_preaggregated"
+ replica_name = "{replica}"
+ version_column = "computed_at"
+ }
+ }
+
+ table "sharded_web_goals_preaggregated" {
+ order_by = ["team_id", "job_id", "action_id", "time_window_start"]
+ partition_by = "toYYYYMMDD(expires_at)"
+ ttl = "toDateTime(expires_at)"
+ settings = {
+ index_granularity = "8192"
+ ttl_only_drop_parts = "1"
+ }
+ column "team_id" {
+ type = "Int64"
+ }
+ column "job_id" {
+ type = "UUID"
+ }
+ column "time_window_start" {
+ type = "DateTime64(6, 'UTC')"
+ }
+ column "action_id" {
+ type = "Int64"
+ }
+ column "count_state" {
+ type = "AggregateFunction(sum, Int64)"
+ }
+ column "unique_persons_state" {
+ type = "AggregateFunction(uniq, UUID)"
+ }
+ column "computed_at" {
+ type = "DateTime64(6, 'UTC')"
+ default = "now()"
+ }
+ column "expires_at" {
+ type = "DateTime64(6, 'UTC')"
+ default = "now() + toIntervalDay(7)"
+ }
+ engine "replicated_replacing_merge_tree" {
+ zoo_path = "/clickhouse/tables/{shard}/posthog.web_goals_preaggregated"
+ replica_name = "{replica}"
+ version_column = "computed_at"
+ }
+ }
+
+ table "sharded_web_overview_preaggregated" {
+ order_by = ["team_id", "job_id", "time_window_start"]
+ partition_by = "toYYYYMMDD(expires_at)"
+ ttl = "toDateTime(expires_at)"
+ settings = {
+ index_granularity = "8192"
+ ttl_only_drop_parts = "1"
+ }
+ column "team_id" {
+ type = "Int64"
+ }
+ column "job_id" {
+ type = "UUID"
+ }
+ column "time_window_start" {
+ type = "DateTime64(6, 'UTC')"
+ }
+ column "uniq_users_state" {
+ type = "AggregateFunction(uniq, UUID)"
+ }
+ column "uniq_sessions_state" {
+ type = "AggregateFunction(uniq, String)"
+ }
+ column "sum_pageviews_state" {
+ type = "AggregateFunction(sum, Int64)"
+ }
+ column "avg_duration_state" {
+ type = "AggregateFunction(avg, Float64)"
+ }
+ column "avg_bounce_state" {
+ type = "AggregateFunction(avg, Int64)"
+ }
+ column "computed_at" {
+ type = "DateTime64(6, 'UTC')"
+ default = "now()"
+ }
+ column "expires_at" {
+ type = "DateTime64(6, 'UTC')"
+ default = "now() + toIntervalDay(7)"
+ }
+ engine "replicated_replacing_merge_tree" {
+ zoo_path = "/clickhouse/tables/{shard}/posthog.web_overview_preaggregated"
+ replica_name = "{replica}"
+ version_column = "computed_at"
+ }
+ }
+
+ table "sharded_web_stats_dimensional_preaggregated" {
+ order_by = ["team_id", "job_id", "period_bucket", "host", "device_type", "pathname", "entry_pathname", "end_pathname", "browser", "os", "viewport_width", "viewport_height", "referring_domain", "utm_source", "utm_medium", "utm_campaign", "utm_term", "utm_content", "country_code", "city_name", "region_code", "region_name", "has_gclid", "has_gad_source_paid_search", "has_fbclid", "mat_metadata_backend", "mat_metadata_loggedIn"]
+ partition_by = "toYYYYMMDD(expires_at)"
+ ttl = "toDateTime(expires_at)"
+ settings = {
+ allow_nullable_key = "1"
+ index_granularity = "8192"
+ ttl_only_drop_parts = "1"
+ }
+ column "team_id" {
+ type = "Int64"
+ }
+ column "job_id" {
+ type = "UUID"
+ }
+ column "period_bucket" {
+ type = "DateTime"
+ }
+ column "host" {
+ type = "String"
+ }
+ column "device_type" {
+ type = "String"
+ }
+ column "pathname" {
+ type = "String"
+ }
+ column "entry_pathname" {
+ type = "String"
+ }
+ column "end_pathname" {
+ type = "String"
+ }
+ column "browser" {
+ type = "String"
+ }
+ column "os" {
+ type = "String"
+ }
+ column "viewport_width" {
+ type = "Int64"
+ }
+ column "viewport_height" {
+ type = "Int64"
+ }
+ column "referring_domain" {
+ type = "String"
+ }
+ column "utm_source" {
+ type = "String"
+ }
+ column "utm_medium" {
+ type = "String"
+ }
+ column "utm_campaign" {
+ type = "String"
+ }
+ column "utm_term" {
+ type = "String"
+ }
+ column "utm_content" {
+ type = "String"
+ }
+ column "country_code" {
+ type = "String"
+ }
+ column "city_name" {
+ type = "String"
+ }
+ column "region_code" {
+ type = "String"
+ }
+ column "region_name" {
+ type = "String"
+ }
+ column "has_gclid" {
+ type = "Bool"
+ }
+ column "has_gad_source_paid_search" {
+ type = "Bool"
+ }
+ column "has_fbclid" {
+ type = "Bool"
+ }
+ column "mat_metadata_backend" {
+ type = "Nullable(String)"
+ }
+ column "mat_metadata_loggedIn" {
+ type = "Nullable(Bool)"
+ }
+ column "persons_uniq_state" {
+ type = "AggregateFunction(uniq, UUID)"
+ }
+ column "sessions_uniq_state" {
+ type = "AggregateFunction(uniq, String)"
+ }
+ column "pageviews_count_state" {
+ type = "AggregateFunction(sum, Int64)"
+ }
+ column "computed_at" {
+ type = "DateTime64(6, 'UTC')"
+ default = "now()"
+ }
+ column "expires_at" {
+ type = "DateTime64(6, 'UTC')"
+ default = "now() + toIntervalDay(7)"
+ }
+ engine "replicated_replacing_merge_tree" {
+ zoo_path = "/clickhouse/tables/{shard}/posthog.web_stats_dimensional_preaggregated"
+ replica_name = "{replica}"
+ version_column = "computed_at"
+ }
+ }
+
+ table "sharded_web_stats_frustration_preaggregated" {
+ order_by = ["team_id", "job_id", "breakdown_value", "time_window_start"]
+ partition_by = "toYYYYMMDD(expires_at)"
+ ttl = "toDateTime(expires_at)"
+ settings = {
+ index_granularity = "8192"
+ ttl_only_drop_parts = "1"
+ }
+ column "team_id" {
+ type = "Int64"
+ }
+ column "job_id" {
+ type = "UUID"
+ }
+ column "time_window_start" {
+ type = "DateTime64(6, 'UTC')"
+ }
+ column "breakdown_value" {
+ type = "String"
+ }
+ column "sum_rage_clicks_state" {
+ type = "AggregateFunction(sum, Int64)"
+ }
+ column "sum_dead_clicks_state" {
+ type = "AggregateFunction(sum, Int64)"
+ }
+ column "sum_errors_state" {
+ type = "AggregateFunction(sum, Int64)"
+ }
+ column "computed_at" {
+ type = "DateTime64(6, 'UTC')"
+ default = "now()"
+ }
+ column "expires_at" {
+ type = "DateTime64(6, 'UTC')"
+ default = "now() + toIntervalDay(7)"
+ }
+ engine "replicated_replacing_merge_tree" {
+ zoo_path = "/clickhouse/tables/{shard}/posthog.web_stats_frustration_preaggregated"
+ replica_name = "{replica}"
+ version_column = "computed_at"
+ }
+ }
+
+ table "sharded_web_stats_paths_preaggregated" {
+ order_by = ["team_id", "job_id", "breakdown_value", "time_window_start"]
+ partition_by = "toYYYYMMDD(expires_at)"
+ ttl = "toDateTime(expires_at)"
+ settings = {
+ index_granularity = "8192"
+ ttl_only_drop_parts = "1"
+ }
+ column "team_id" {
+ type = "Int64"
+ }
+ column "job_id" {
+ type = "UUID"
+ }
+ column "time_window_start" {
+ type = "DateTime64(6, 'UTC')"
+ }
+ column "breakdown_value" {
+ type = "String"
+ }
+ column "uniq_users_state" {
+ type = "AggregateFunction(uniq, UUID)"
+ }
+ column "sum_pageviews_state" {
+ type = "AggregateFunction(sum, Int64)"
+ }
+ column "avg_bounce_state" {
+ type = "AggregateFunction(avg, Nullable(Float64))"
+ }
+ column "computed_at" {
+ type = "DateTime64(6, 'UTC')"
+ default = "now()"
+ }
+ column "expires_at" {
+ type = "DateTime64(6, 'UTC')"
+ default = "now() + toIntervalDay(7)"
+ }
+ engine "replicated_replacing_merge_tree" {
+ zoo_path = "/clickhouse/tables/{shard}/posthog.web_stats_paths_preaggregated"
+ replica_name = "{replica}"
+ version_column = "computed_at"
+ }
+ }
+
+ table "sharded_web_stats_paths_preaggregated_pathkey" {
+ order_by = ["team_id", "time_window_start", "breakdown_value", "job_id"]
+ partition_by = "toYYYYMMDD(expires_at)"
+ ttl = "toDateTime(expires_at)"
+ settings = {
+ index_granularity = "8192"
+ ttl_only_drop_parts = "1"
+ }
+ column "team_id" {
+ type = "Int64"
+ }
+ column "job_id" {
+ type = "UUID"
+ }
+ column "time_window_start" {
+ type = "DateTime64(6, 'UTC')"
+ }
+ column "breakdown_value" {
+ type = "String"
+ }
+ column "uniq_users_state" {
+ type = "AggregateFunction(uniq, UUID)"
+ }
+ column "sum_pageviews_state" {
+ type = "AggregateFunction(sum, Int64)"
+ }
+ column "avg_bounce_state" {
+ type = "AggregateFunction(avg, Nullable(Float64))"
+ }
+ column "computed_at" {
+ type = "DateTime64(6, 'UTC')"
+ default = "now()"
+ }
+ column "expires_at" {
+ type = "DateTime64(6, 'UTC')"
+ default = "now() + toIntervalDay(7)"
+ }
+ engine "replicated_replacing_merge_tree" {
+ zoo_path = "/clickhouse/tables/{shard}/posthog.web_stats_paths_preaggregated_pathkey"
+ replica_name = "{replica}"
+ version_column = "computed_at"
+ }
+ }
+
+ table "sharded_web_stats_preaggregated" {
+ order_by = ["team_id", "job_id", "breakdown_by", "time_window_start", "breakdown_value"]
+ partition_by = "toYYYYMMDD(expires_at)"
+ ttl = "toDateTime(expires_at)"
+ settings = {
+ index_granularity = "8192"
+ ttl_only_drop_parts = "1"
+ }
+ column "team_id" {
+ type = "Int64"
+ }
+ column "job_id" {
+ type = "UUID"
+ }
+ column "time_window_start" {
+ type = "DateTime64(6, 'UTC')"
+ }
+ column "breakdown_by" {
+ type = "String"
+ }
+ column "breakdown_value" {
+ type = "String"
+ }
+ column "uniq_users_state" {
+ type = "AggregateFunction(uniq, UUID)"
+ }
+ column "sum_pageviews_state" {
+ type = "AggregateFunction(sum, Int64)"
+ }
+ column "computed_at" {
+ type = "DateTime64(6, 'UTC')"
+ default = "now()"
+ }
+ column "expires_at" {
+ type = "DateTime64(6, 'UTC')"
+ default = "now() + toIntervalDay(7)"
+ }
+ engine "replicated_replacing_merge_tree" {
+ zoo_path = "/clickhouse/tables/{shard}/posthog.web_stats_preaggregated"
+ replica_name = "{replica}"
+ version_column = "computed_at"
+ }
+ }
+
+ table "sharded_web_vitals_paths_preaggregated" {
+ order_by = ["team_id", "job_id", "time_window_start", "path"]
+ partition_by = "toYYYYMMDD(expires_at)"
+ ttl = "toDateTime(expires_at)"
+ settings = {
+ index_granularity = "8192"
+ ttl_only_drop_parts = "1"
+ }
+ column "team_id" {
+ type = "Int64"
+ }
+ column "job_id" {
+ type = "UUID"
+ }
+ column "time_window_start" {
+ type = "DateTime64(6, 'UTC')"
+ }
+ column "path" {
+ type = "String"
+ }
+ column "inp_quantiles_state" {
+ type = "AggregateFunction(quantiles(0.75, 0.9, 0.99), Float64)"
+ }
+ column "lcp_quantiles_state" {
+ type = "AggregateFunction(quantiles(0.75, 0.9, 0.99), Float64)"
+ }
+ column "cls_quantiles_state" {
+ type = "AggregateFunction(quantiles(0.75, 0.9, 0.99), Float64)"
+ }
+ column "fcp_quantiles_state" {
+ type = "AggregateFunction(quantiles(0.75, 0.9, 0.99), Float64)"
+ }
+ column "computed_at" {
+ type = "DateTime64(6, 'UTC')"
+ default = "now()"
+ }
+ column "expires_at" {
+ type = "DateTime64(6, 'UTC')"
+ default = "now() + toIntervalDay(7)"
+ }
+ engine "replicated_replacing_merge_tree" {
+ zoo_path = "/clickhouse/tables/{shard}/posthog.web_vitals_paths_preaggregated"
+ replica_name = "{replica}"
+ version_column = "computed_at"
+ }
+ }
+
+ table "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_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_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_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 "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"
+ }
+ }
+
+ materialized_view "hog_invocation_results_mv" {
+ to_table = "posthog.hog_invocation_results_data"
+ query = <<SQL
+SELECT
+ team_id,
+ function_kind,
+ function_id,
+ invocation_id,
+ parent_run_id,
+ status,
+ attempts,
+ is_retry,
+ scheduled_at,
+ if(
+ first_scheduled_at = toDateTime64('1970-01-01 00:00:00', 6, 'UTC'),
+ scheduled_at,
+ first_scheduled_at
+ ) AS first_scheduled_at,
+ started_at,
+ finished_at,
+ duration_ms,
+ error_kind,
+ error_message,
+ event_uuid,
+ distinct_id,
+ person_id,
+ invocation_globals,
+ version,
+ is_deleted,
+ _timestamp,
+ _offset,
+ _partition
+FROM posthog.kafka_hog_invocation_results
+SQL
+
+ column "team_id" {
+ type = "Int64"
+ }
+ column "function_kind" {
+ type = "LowCardinality(String)"
+ }
+ column "function_id" {
+ type = "String"
+ }
+ column "invocation_id" {
+ type = "String"
+ }
+ column "parent_run_id" {
+ type = "String"
+ }
+ column "status" {
+ type = "LowCardinality(String)"
+ }
+ column "attempts" {
+ type = "UInt8"
+ }
+ column "is_retry" {
+ type = "UInt8"
+ }
+ column "scheduled_at" {
+ type = "DateTime64(6, 'UTC')"
+ }
+ column "first_scheduled_at" {
+ type = "DateTime64(6, 'UTC')"
+ }
+ column "started_at" {
+ type = "Nullable(DateTime64(6, 'UTC'))"
+ }
+ column "finished_at" {
+ type = "Nullable(DateTime64(6, 'UTC'))"
+ }
+ column "duration_ms" {
+ type = "Nullable(UInt32)"
+ }
+ column "error_kind" {
+ type = "LowCardinality(String)"
+ }
+ column "error_message" {
+ type = "String"
+ }
+ column "event_uuid" {
+ type = "String"
+ }
+ column "distinct_id" {
+ type = "String"
+ }
+ column "person_id" {
+ type = "String"
+ }
+ column "invocation_globals" {
+ type = "String"
+ }
+ column "version" {
+ type = "UInt64"
+ }
+ column "is_deleted" {
+ type = "UInt8"
+ }
+ column "_timestamp" {
+ type = "Nullable(DateTime)"
+ }
+ column "_offset" {
+ type = "UInt64"
+ }
+ column "_partition" {
+ type = "UInt64"
+ }
+ }
+
+ materialized_view "message_assets_mv" {
+ to_table = "posthog.message_assets_data"
+ query = <<SQL
+SELECT
+ team_id,
+ function_kind,
+ function_id,
+ parent_run_id,
+ invocation_id,
+ action_id,
+ kind,
+ distinct_id,
+ person_id,
+ recipient,
+ subject,
+ status,
+ sent_at,
+ version,
+ is_deleted,
+ html,
+ _timestamp,
+ _offset,
+ _partition
+FROM posthog.kafka_message_assets
+SQL
+
+ column "team_id" {
+ type = "Int64"
+ }
+ column "function_kind" {
+ type = "LowCardinality(String)"
+ }
+ column "function_id" {
+ type = "String"
+ }
+ column "parent_run_id" {
+ type = "String"
+ }
+ column "invocation_id" {
+ type = "String"
+ }
+ column "action_id" {
+ type = "String"
+ }
+ column "kind" {
+ type = "LowCardinality(String)"
+ }
+ column "distinct_id" {
+ type = "String"
+ }
+ column "person_id" {
+ type = "String"
+ }
+ column "recipient" {
+ type = "String"
+ }
+ column "subject" {
+ type = "String"
+ }
+ column "status" {
+ type = "LowCardinality(String)"
+ }
+ column "sent_at" {
+ type = "DateTime64(6, 'UTC')"
+ }
+ column "version" {
+ type = "UInt64"
+ }
+ column "is_deleted" {
+ type = "UInt8"
+ }
+ column "html" {
+ type = "String"
+ }
+ column "_timestamp" {
+ type = "Nullable(DateTime)"
+ }
+ column "_offset" {
+ type = "UInt64"
+ }
+ column "_partition" {
+ type = "UInt64"
+ }
+ }
+
+ materialized_view "ops_query_log_archive_mv" {
+ to_table = "posthog.writable_query_log_archive"
+ query = <<SQL
+SELECT
+ hostname,
+ user,
+ query_id,
+ initial_query_id,
+ is_initial_query,
+ type,
+ event_date,
+ event_time,
+ event_time_microseconds,
+ query_start_time,
+ query_start_time_microseconds,
+ query_duration_ms,
+ read_rows,
+ read_bytes,
+ written_rows,
+ written_bytes,
+ result_rows,
+ result_bytes,
+ memory_usage,
+ peak_threads_usage,
+ current_database,
+ query,
+ formatted_query,
+ normalized_query_hash,
+ query_kind,
+ exception_code,
+ exception,
+ stack_trace,
+ JSONExtractInt(log_comment, 'team_id') AS team_id,
+ if(isValidJSON(log_comment), log_comment, '{}') AS log_comment,
+ ProfileEvents
+FROM system.query_log
+WHERE type != 'QueryStart'
+SQL
+
+ column "hostname" {
+ type = "LowCardinality(String)"
+ }
+ column "user" {
+ type = "LowCardinality(String)"
+ }
+ column "query_id" {
+ type = "String"
+ }
+ column "initial_query_id" {
+ type = "String"
+ }
+ column "is_initial_query" {
+ type = "UInt8"
+ }
+ column "type" {
+ type = "Enum8('QueryStart'=1, 'QueryFinish'=2, 'ExceptionBeforeStart'=3, 'ExceptionWhileProcessing'=4)"
+ }
+ column "event_date" {
+ type = "Date"
+ }
+ column "event_time" {
+ type = "DateTime"
+ }
+ column "event_time_microseconds" {
+ type = "DateTime64(6)"
+ }
+ column "query_start_time" {
+ type = "DateTime"
+ }
+ column "query_start_time_microseconds" {
+ type = "DateTime64(6)"
+ }
+ column "query_duration_ms" {
+ type = "UInt64"
+ }
+ column "read_rows" {
+ type = "UInt64"
+ }
+ column "read_bytes" {
+ type = "UInt64"
+ }
+ column "written_rows" {
+ type = "UInt64"
+ }
+ column "written_bytes" {
+ type = "UInt64"
+ }
+ column "result_rows" {
+ type = "UInt64"
+ }
+ column "result_bytes" {
+ type = "UInt64"
+ }
+ column "memory_usage" {
+ type = "UInt64"
+ }
+ column "peak_threads_usage" {
+ type = "UInt64"
+ }
+ column "current_database" {
+ type = "LowCardinality(String)"
+ }
+ column "query" {
+ type = "String"
+ }
+ column "formatted_query" {
+ type = "String"
+ }
+ column "normalized_query_hash" {
+ type = "UInt64"
+ }
+ column "query_kind" {
+ type = "LowCardinality(String)"
+ }
+ column "exception_code" {
+ type = "Int32"
+ }
+ column "exception" {
+ type = "String"
+ }
+ column "stack_trace" {
+ type = "String"
+ }
+ column "team_id" {
+ type = "Int64"
+ }
+ column "log_comment" {
+ type = "String"
+ }
+ column "ProfileEvents" {
+ type = "Map(LowCardinality(String), UInt64)"
+ }
+ }
+
+ materialized_view "property_values_mv" {
+ to_table = "posthog.property_values"
+ query = <<SQL
+SELECT
+ team_id,
+ property_type,
+ property_key,
+ property_value,
+ property_count,
+ coalesce(_timestamp, now()) AS last_seen
+FROM posthog.kafka_property_values
+SQL
+
+ column "team_id" {
+ type = "Int64"
+ }
+ column "property_type" {
+ type = "LowCardinality(String)"
+ }
+ column "property_key" {
+ type = "String"
+ }
+ column "property_value" {
+ type = "String"
+ }
+ column "property_count" {
+ type = "UInt64"
+ }
+ column "last_seen" {
+ type = "DateTime"
+ }
+ }
+
+ 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
+
+ }
+
+ 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" {
+ }
+ }
+}
diff --git a/posthog/clickhouse/hcl/golden/prod-eu-sessions.hcl b/posthog/clickhouse/hcl/golden/prod-eu-sessions.hcl
new file mode 100644
index 000000000000..315b891a96c7
--- /dev/null
+++ b/posthog/clickhouse/hcl/golden/prod-eu-sessions.hcl
@@ -0,0 +1,2837 @@
+database "posthog" {
+ table "channel_definition" {
+ 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 "distributed" {
+ cluster_name = "posthog_single_shard"
+ remote_database = "posthog"
+ remote_table = "channel_definition"
+ }
+ }
+
+ table "cohortpeople" {
+ column "person_id" {
+ type = "UUID"
+ }
+ column "cohort_id" {
+ type = "Int64"
+ }
+ column "team_id" {
+ type = "Int64"
+ }
+ column "sign" {
+ type = "Int8"
+ }
+ column "version" {
+ type = "UInt64"
+ }
+ engine "distributed" {
+ cluster_name = "posthog_single_shard"
+ remote_database = "posthog"
+ remote_table = "cohortpeople"
+ sharding_key = "rand()"
+ }
+ }
+
+ table "events" {
+ 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_hash" {
+ type = "String"
+ }
+ column "created_at" {
+ type = "DateTime64(6, 'UTC')"
+ }
+ column "_timestamp" {
+ type = "DateTime"
+ }
+ column "_offset" {
+ type = "UInt64"
+ }
+ column "elements_chain" {
+ type = "String"
+ }
+ column "mat_$user_id" {
+ type = "String"
+ comment = "column_materializer::$user_id"
+ }
+ column "mat_$browser" {
+ type = "String"
+ comment = "column_materializer::$browser"
+ }
+ column "mat_$host" {
+ type = "String"
+ comment = "column_materializer::$host"
+ }
+ column "mat_$current_url" {
+ type = "String"
+ comment = "column_materializer::$current_url"
+ }
+ column "mat_distinct_id" {
+ type = "String"
+ comment = "column_materializer::distinct_id"
+ }
+ column "mat_action" {
+ type = "String"
+ comment = "column_materializer::action"
+ }
+ column "mat_origin" {
+ type = "String"
+ comment = "column_materializer::origin"
+ }
+ column "mat_email" {
+ type = "String"
+ comment = "column_materializer::email"
+ }
+ column "mat_key" {
+ type = "String"
+ comment = "column_materializer::key"
+ }
+ column "mat_insight" {
+ type = "String"
+ comment = "column_materializer::insight"
+ }
+ column "mat_$event_type" {
+ type = "String"
+ comment = "column_materializer::$event_type"
+ }
+ column "mat_created_by" {
+ type = "String"
+ comment = "column_materializer::created_by"
+ }
+ column "mat_total_event_actions_count" {
+ type = "String"
+ comment = "column_materializer::total_event_actions_count"
+ }
+ column "mat_is_demo_project" {
+ type = "String"
+ comment = "column_materializer::is_demo_project"
+ }
+ column "mat_$active_feature_flags" {
+ type = "String"
+ comment = "column_materializer::$active_feature_flags"
+ }
+ column "mat_filters_count" {
+ type = "String"
+ comment = "column_materializer::filters_count"
+ }
+ column "mat_utm_source" {
+ type = "String"
+ comment = "column_materializer::utm_source"
+ }
+ column "mat_apiErrorMessage" {
+ type = "String"
+ comment = "column_materializer::apiErrorMessage"
+ }
+ column "mat_$referring_domain" {
+ type = "String"
+ comment = "column_materializer::$referring_domain"
+ }
+ column "mat_statusCode" {
+ type = "String"
+ comment = "column_materializer::statusCode"
+ }
+ column "mat_deal_id" {
+ type = "String"
+ comment = "column_materializer::deal_id"
+ }
+ column "mat_realm" {
+ type = "String"
+ comment = "column_materializer::realm"
+ }
+ 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 "mat_$lib" {
+ type = "String"
+ comment = "column_materializer::$lib"
+ }
+ column "mat_$os" {
+ type = "String"
+ comment = "column_materializer::$os"
+ }
+ column "mat_$initial_referrer" {
+ type = "String"
+ comment = "column_materializer::$initial_referrer"
+ }
+ column "mat_$app_version" {
+ type = "String"
+ comment = "column_materializer::$app_version"
+ }
+ column "mat_$initial_referring_domain" {
+ type = "String"
+ comment = "column_materializer::$initial_referring_domain"
+ }
+ column "mat_symbol" {
+ type = "String"
+ comment = "column_materializer::symbol"
+ }
+ column "mat_page" {
+ type = "String"
+ comment = "column_materializer::page"
+ }
+ column "mat_type" {
+ type = "String"
+ comment = "column_materializer::type"
+ }
+ column "mat_currentScreen" {
+ type = "String"
+ comment = "column_materializer::currentScreen"
+ }
+ column "mat_utm_campaign" {
+ type = "String"
+ comment = "column_materializer::utm_campaign"
+ }
+ column "mat_is_organization_first_user" {
+ type = "String"
+ comment = "column_materializer::is_organization_first_user"
+ }
+ column "mat_is_first_component_load" {
+ type = "String"
+ comment = "column_materializer::is_first_component_load"
+ }
+ column "mat_team" {
+ type = "String"
+ comment = "column_materializer::team"
+ }
+ column "mat_context" {
+ type = "String"
+ comment = "column_materializer::context"
+ }
+ column "mat_sdk" {
+ type = "String"
+ comment = "column_materializer::sdk"
+ }
+ column "mat_created_by_system" {
+ type = "String"
+ comment = "column_materializer::created_by_system"
+ }
+ column "mat_item_count" {
+ type = "String"
+ comment = "column_materializer::item_count"
+ }
+ column "mat_$ip" {
+ type = "String"
+ comment = "column_materializer::$ip"
+ }
+ column "mat_$referrer" {
+ type = "String"
+ comment = "column_materializer::$referrer"
+ }
+ column "mat_action_name" {
+ type = "String"
+ comment = "column_materializer::action_name"
+ }
+ column "mat_$geoip_country_name" {
+ type = "String"
+ comment = "column_materializer::$geoip_country_name"
+ }
+ column "mat_$device_model" {
+ type = "String"
+ comment = "column_materializer::$device_model"
+ }
+ column "mat_progress" {
+ type = "String"
+ comment = "column_materializer::progress"
+ }
+ column "mat_chain" {
+ type = "String"
+ comment = "column_materializer::chain"
+ }
+ column "mat_$device_type" {
+ type = "String"
+ comment = "column_materializer::$device_type"
+ }
+ column "mat_usd" {
+ type = "String"
+ comment = "column_materializer::usd"
+ }
+ column "mat_app_name" {
+ type = "String"
+ comment = "column_materializer::app_name"
+ }
+ column "mat_$screen_name" {
+ type = "String"
+ comment = "column_materializer::$screen_name"
+ }
+ column "mat_index" {
+ type = "String"
+ comment = "column_materializer::index"
+ }
+ column "mat_token" {
+ type = "String"
+ comment = "column_materializer::token"
+ }
+ column "mat_method" {
+ type = "String"
+ comment = "column_materializer::method"
+ }
+ column "mat_address" {
+ type = "String"
+ comment = "column_materializer::address"
+ }
+ column "mat_name" {
+ type = "String"
+ comment = "column_materializer::name"
+ }
+ column "mat_inviteCode" {
+ type = "String"
+ comment = "column_materializer::inviteCode"
+ }
+ column "$window_id" {
+ type = "String"
+ comment = "column_materializer::$window_id"
+ }
+ column "$session_id" {
+ type = "String"
+ comment = "column_materializer::$session_id"
+ }
+ column "mat_osName" {
+ type = "String"
+ comment = "column_materializer::osName"
+ }
+ column "mat_nativeBuildVersion" {
+ type = "String"
+ comment = "column_materializer::nativeBuildVersion"
+ }
+ column "mat_revenue" {
+ type = "String"
+ comment = "column_materializer::revenue"
+ }
+ column "group_0" {
+ type = "String"
+ alias = "`$group_0`"
+ }
+ column "group_1" {
+ type = "String"
+ alias = "`$group_1`"
+ }
+ column "group_2" {
+ type = "String"
+ alias = "`$group_2`"
+ }
+ column "group_3" {
+ type = "String"
+ alias = "`$group_3`"
+ }
+ column "group_4" {
+ type = "String"
+ alias = "`$group_4`"
+ }
+ column "alias_mat__user_id" {
+ type = "String"
+ alias = "`mat_$user_id`"
+ }
+ column "alias_mat__browser" {
+ type = "String"
+ alias = "`mat_$browser`"
+ }
+ column "alias_mat__host" {
+ type = "String"
+ alias = "`mat_$host`"
+ }
+ column "alias_mat__current_url" {
+ type = "String"
+ alias = "`mat_$current_url`"
+ }
+ column "alias_mat__event_type" {
+ type = "String"
+ alias = "`mat_$event_type`"
+ }
+ column "alias_mat__active_feature_flags" {
+ type = "String"
+ alias = "`mat_$active_feature_flags`"
+ }
+ column "alias_mat__referring_domain" {
+ type = "String"
+ alias = "`mat_$referring_domain`"
+ }
+ column "alias_mat__lib" {
+ type = "String"
+ alias = "`mat_$lib`"
+ }
+ column "alias_mat__os" {
+ type = "String"
+ alias = "`mat_$os`"
+ }
+ column "alias_mat__initial_referrer" {
+ type = "String"
+ alias = "`mat_$initial_referrer`"
+ }
+ column "alias_mat__app_version" {
+ type = "String"
+ alias = "`mat_$app_version`"
+ }
+ column "alias_mat__initial_referring_domain" {
+ type = "String"
+ alias = "`mat_$initial_referring_domain`"
+ }
+ column "alias_mat__ip" {
+ type = "String"
+ alias = "`mat_$ip`"
+ }
+ column "alias_mat__referrer" {
+ type = "String"
+ alias = "`mat_$referrer`"
+ }
+ column "alias_mat__geoip_country_name" {
+ type = "String"
+ alias = "`mat_$geoip_country_name`"
+ }
+ column "alias_mat__device_model" {
+ type = "String"
+ alias = "`mat_$device_model`"
+ }
+ column "alias_mat__device_type" {
+ type = "String"
+ alias = "`mat_$device_type`"
+ }
+ column "alias_mat__screen_name" {
+ type = "String"
+ alias = "`mat_$screen_name`"
+ }
+ column "person_id" {
+ type = "UUID"
+ }
+ column "person_properties" {
+ type = "String"
+ }
+ column "group0_properties" {
+ type = "String"
+ }
+ column "group1_properties" {
+ type = "String"
+ }
+ column "group2_properties" {
+ type = "String"
+ }
+ column "group3_properties" {
+ type = "String"
+ }
+ column "group4_properties" {
+ type = "String"
+ }
+ column "person_created_at" {
+ type = "DateTime64(3)"
+ }
+ column "group0_created_at" {
+ type = "DateTime64(3)"
+ }
+ column "group1_created_at" {
+ type = "DateTime64(3)"
+ }
+ column "group2_created_at" {
+ type = "DateTime64(3)"
+ }
+ column "group3_created_at" {
+ type = "DateTime64(3)"
+ }
+ column "group4_created_at" {
+ type = "DateTime64(3)"
+ }
+ column "mat_arguments" {
+ type = "String"
+ comment = "column_materializer::properties::arguments"
+ }
+ column "mat_source" {
+ type = "String"
+ comment = "column_materializer::properties::source"
+ }
+ column "mat_pp_email" {
+ type = "String"
+ comment = "column_materializer::person_properties::email"
+ }
+ column "mat_$time" {
+ type = "String"
+ comment = "column_materializer::properties::$time"
+ }
+ column "mat_$pathname" {
+ type = "String"
+ comment = "column_materializer::properties::$pathname"
+ }
+ column "mat_$geoip_city_name" {
+ type = "String"
+ comment = "column_materializer::properties::$geoip_city_name"
+ }
+ column "mat_community_id" {
+ type = "String"
+ comment = "column_materializer::properties::community_id"
+ }
+ column "mat_thread_id" {
+ type = "String"
+ comment = "column_materializer::properties::thread_id"
+ }
+ column "mat_Event_productCode" {
+ type = "String"
+ comment = "column_materializer::properties::Event.productCode"
+ }
+ column "mat_env" {
+ type = "String"
+ comment = "column_materializer::properties::env"
+ }
+ column "mat_target" {
+ type = "String"
+ comment = "column_materializer::properties::target"
+ }
+ column "mat_Subscription_plan_amount" {
+ type = "String"
+ comment = "column_materializer::properties::Subscription.plan.amount"
+ }
+ column "mat_title" {
+ type = "String"
+ comment = "column_materializer::properties::title"
+ }
+ column "mat_Connection_app_name" {
+ type = "String"
+ comment = "column_materializer::properties::Connection.app.name"
+ }
+ column "mat_utm_medium" {
+ type = "String"
+ comment = "column_materializer::properties::utm_medium"
+ }
+ column "mat_Account_client_id" {
+ type = "String"
+ comment = "column_materializer::properties::Account.client_id"
+ }
+ column "mat_HTTP_Method" {
+ type = "String"
+ comment = "column_materializer::properties::HTTP Method"
+ }
+ column "mat_audio_duration" {
+ type = "String"
+ comment = "column_materializer::properties::audio_duration"
+ }
+ column "mat_duration" {
+ type = "String"
+ comment = "column_materializer::properties::duration"
+ }
+ column "mat_url" {
+ type = "String"
+ comment = "column_materializer::properties::url"
+ }
+ column "mat_group_id" {
+ type = "String"
+ comment = "column_materializer::properties::group_id"
+ }
+ column "mat_platform" {
+ type = "String"
+ comment = "column_materializer::properties::platform"
+ }
+ column "mat_pp_$browser" {
+ type = "String"
+ comment = "column_materializer::person_properties::$browser"
+ }
+ column "mat_payment_status" {
+ type = "String"
+ comment = "column_materializer::properties::payment_status"
+ }
+ column "mat_testSessionId" {
+ type = "String"
+ comment = "column_materializer::properties::testSessionId"
+ }
+ column "inserted_at" {
+ type = "Nullable(DateTime64(6, 'UTC'))"
+ default = "now64()"
+ }
+ column "mat_$sent_at" {
+ type = "String"
+ comment = "column_materializer::properties::$sent_at"
+ }
+ column "mat_pp_companyName" {
+ type = "String"
+ comment = "column_materializer::person_properties::companyName"
+ }
+ column "mat_function" {
+ type = "String"
+ comment = "column_materializer::properties::function"
+ }
+ column "mat_store_url" {
+ type = "String"
+ comment = "column_materializer::properties::store_url"
+ }
+ column "mat_email_domain" {
+ type = "String"
+ comment = "column_materializer::properties::email_domain"
+ }
+ column "mat_institution_name" {
+ type = "String"
+ comment = "column_materializer::properties::institution_name"
+ }
+ column "mat_authentication_method" {
+ type = "String"
+ comment = "column_materializer::properties::authentication_method"
+ }
+ column "mat_initial_step" {
+ type = "String"
+ comment = "column_materializer::properties::initial_step"
+ }
+ column "mat_status_message" {
+ type = "String"
+ comment = "column_materializer::properties::status_message"
+ }
+ column "mat_mode" {
+ type = "String"
+ comment = "column_materializer::properties::mode"
+ }
+ column "mat_protocol" {
+ type = "String"
+ comment = "column_materializer::properties::protocol"
+ }
+ column "mat_job_type" {
+ type = "String"
+ comment = "column_materializer::properties::job_type"
+ }
+ column "mat_is_oauth" {
+ type = "String"
+ comment = "column_materializer::properties::is_oauth"
+ }
+ column "mat_is_initial_aggregation" {
+ type = "String"
+ comment = "column_materializer::properties::is_initial_aggregation"
+ }
+ column "mat_search_term" {
+ type = "String"
+ comment = "column_materializer::properties::search_term"
+ }
+ column "mat_valid_ach_accounts" {
+ type = "String"
+ comment = "column_materializer::properties::valid_ach_accounts"
+ }
+ column "mat_gross" {
+ type = "String"
+ comment = "column_materializer::properties::gross"
+ }
+ column "mat_orderType" {
+ type = "String"
+ comment = "column_materializer::properties::orderType"
+ }
+ column "mat_sku" {
+ type = "String"
+ comment = "column_materializer::properties::sku"
+ }
+ column "mat_dual_channel" {
+ type = "String"
+ comment = "column_materializer::properties::dual_channel"
+ }
+ column "mat_channel" {
+ type = "String"
+ comment = "column_materializer::properties::channel"
+ }
+ column "mat_workspaceId" {
+ type = "String"
+ comment = "column_materializer::properties::workspaceId"
+ }
+ column "mat_numberOfSecrets" {
+ type = "String"
+ comment = "column_materializer::properties::numberOfSecrets"
+ }
+ column "mat_organizations" {
+ type = "String"
+ comment = "column_materializer::properties::organizations"
+ }
+ column "mat_organization" {
+ type = "String"
+ comment = "column_materializer::properties::organization"
+ }
+ column "mat_contributionError" {
+ type = "String"
+ comment = "column_materializer::properties::contributionError"
+ }
+ column "mat_phone" {
+ type = "String"
+ comment = "column_materializer::properties::phone"
+ }
+ column "mat_$initial_pathname" {
+ type = "String"
+ comment = "column_materializer::properties::$initial_pathname"
+ }
+ column "mat_organization_name" {
+ type = "String"
+ comment = "column_materializer::properties::organization_name"
+ }
+ column "mat_category" {
+ type = "String"
+ comment = "column_materializer::properties::category"
+ }
+ column "mat_$lib_version" {
+ type = "String"
+ comment = "column_materializer::properties::$lib_version"
+ }
+ column "mat_pp_$initial_utm_campaign" {
+ type = "String"
+ comment = "column_materializer::person_properties::$initial_utm_campaign"
+ }
+ column "mat_pp_$initial_utm_medium" {
+ type = "String"
+ comment = "column_materializer::person_properties::$initial_utm_medium"
+ }
+ column "mat_pp_$initial_gclid" {
+ type = "String"
+ comment = "column_materializer::person_properties::$initial_gclid"
+ }
+ column "mat_pp_$initial_gad_source" {
+ type = "String"
+ comment = "column_materializer::person_properties::$initial_gad_source"
+ }
+ column "mat_pp_$initial_utm_source" {
+ type = "String"
+ comment = "column_materializer::person_properties::$initial_utm_source"
+ }
+ column "mat_pp_$initial_referring_domain" {
+ type = "String"
+ comment = "column_materializer::person_properties::$initial_referring_domain"
+ }
+ column "mat_pp_$initial_utm_term" {
+ type = "String"
+ comment = "column_materializer::person_properties::$initial_utm_term"
+ }
+ column "mat_pp_$initial_utm_content" {
+ type = "String"
+ comment = "column_materializer::person_properties::$initial_utm_content"
+ }
+ column "mat_pp_$initial_gbraid" {
+ type = "String"
+ comment = "column_materializer::person_properties::$initial_gbraid::disabled"
+ }
+ column "mat_pp_$initial_wbraid" {
+ type = "String"
+ comment = "column_materializer::person_properties::$initial_wbraid::disabled"
+ }
+ column "mat_pp_$initial_msclkid" {
+ type = "String"
+ comment = "column_materializer::person_properties::$initial_msclkid"
+ }
+ column "mat_pp_$initial_fbclid" {
+ type = "String"
+ comment = "column_materializer::person_properties::$initial_fbclid"
+ }
+ column "mat_$geoip_subdivision_1_code" {
+ type = "String"
+ comment = "column_materializer::properties::$geoip_subdivision_1_code"
+ }
+ column "mat_wlo_enabled" {
+ type = "String"
+ comment = "column_materializer::properties::wlo_enabled"
+ }
+ column "mat_$prev_pageview_max_scroll_percentage" {
+ type = "String"
+ comment = "column_materializer::properties::$prev_pageview_max_scroll_percentage"
+ }
+ column "mat_$prev_pageview_max_content_percentage" {
+ type = "String"
+ comment = "column_materializer::properties::$prev_pageview_max_content_percentage"
+ }
+ column "mat_$prev_pageview_pathname" {
+ type = "String"
+ comment = "column_materializer::properties::$prev_pageview_pathname"
+ }
+ column "mat_pp_$initial_pathname" {
+ type = "String"
+ comment = "column_materializer::person_properties::$initial_pathname"
+ }
+ column "mat_pp_$geoip_country_code" {
+ type = "String"
+ comment = "column_materializer::person_properties::$geoip_country_code"
+ }
+ column "mat_pp_username" {
+ type = "String"
+ comment = "column_materializer::person_properties::username"
+ }
+ column "mat_pp_serverMasterclass" {
+ type = "String"
+ comment = "column_materializer::person_properties::serverMasterclass"
+ }
+ column "mat_content_length" {
+ type = "String"
+ comment = "column_materializer::properties::content_length"
+ }
+ column "mat_pp_serverMarketing" {
+ type = "String"
+ comment = "column_materializer::person_properties::serverMarketing"
+ }
+ column "mat_$browser_version" {
+ type = "String"
+ comment = "column_materializer::properties::$browser_version"
+ }
+ column "mat_pp_role" {
+ type = "String"
+ comment = "column_materializer::person_properties::role"
+ }
+ column "mat_pp_customer" {
+ type = "String"
+ comment = "column_materializer::person_properties::customer"
+ }
+ column "mat_event" {
+ type = "String"
+ comment = "column_materializer::properties::event"
+ }
+ column "mat_disable_institution_search" {
+ type = "String"
+ comment = "column_materializer::properties::disable_institution_search"
+ }
+ column "mat_is_first_event_for_user" {
+ type = "String"
+ comment = "column_materializer::properties::is_first_event_for_user"
+ }
+ column "mat_current_member_guid" {
+ type = "String"
+ comment = "column_materializer::properties::current_member_guid"
+ }
+ column "mat_user_agent" {
+ type = "String"
+ comment = "column_materializer::properties::user_agent"
+ }
+ column "mat_is_test_user" {
+ type = "String"
+ comment = "column_materializer::properties::is_test_user"
+ }
+ column "mat_referrer" {
+ type = "String"
+ comment = "column_materializer::properties::referrer"
+ }
+ column "mat_pp_$initial_current_url" {
+ type = "String"
+ comment = "column_materializer::person_properties::$initial_current_url"
+ }
+ column "mat_most_recent_app_os" {
+ type = "String"
+ comment = "column_materializer::properties::most_recent_app_os"
+ }
+ column "mat_pp_hubspot_score" {
+ type = "String"
+ comment = "column_materializer::person_properties::hubspot_score"
+ }
+ column "mat_pp_id" {
+ type = "String"
+ comment = "column_materializer::person_properties::id"
+ }
+ column "mat_pp_$current_url" {
+ type = "String"
+ comment = "column_materializer::person_properties::$current_url"
+ }
+ column "mat_product_key" {
+ type = "String"
+ comment = "column_materializer::properties::product_key"
+ }
+ column "mat_Plan_type_and_filter" {
+ type = "String"
+ comment = "column_materializer::properties::Plan type and filter"
+ }
+ column "mat_$app_namespace" {
+ type = "String"
+ comment = "column_materializer::properties::$app_namespace"
+ }
+ column "mat_$os_name" {
+ type = "String"
+ comment = "column_materializer::properties::$os_name"
+ }
+ column "mat_pp_$os_name" {
+ type = "String"
+ comment = "column_materializer::person_properties::$os_name::disabled"
+ }
+ column "mat_pp_$app_version" {
+ type = "String"
+ comment = "column_materializer::person_properties::$app_version"
+ }
+ column "mat_subscriptionStatus" {
+ type = "String"
+ comment = "column_materializer::properties::subscriptionStatus"
+ }
+ column "mat_$screen_height" {
+ type = "String"
+ comment = "column_materializer::properties::$screen_height"
+ }
+ column "mat_$screen_width" {
+ type = "String"
+ comment = "column_materializer::properties::$screen_width"
+ }
+ column "mat_tag" {
+ type = "String"
+ comment = "column_materializer::properties::tag"
+ }
+ column "mat_$app_build" {
+ type = "String"
+ comment = "column_materializer::properties::$app_build"
+ }
+ column "mat_surface_tag" {
+ type = "String"
+ comment = "column_materializer::properties::surface_tag"
+ }
+ column "mat_survey_responses_count_in_period" {
+ type = "String"
+ comment = "column_materializer::properties::survey_responses_count_in_period"
+ }
+ column "mat_event_count_in_month" {
+ type = "String"
+ comment = "column_materializer::properties::event_count_in_month"
+ }
+ column "mat_ramp" {
+ type = "String"
+ comment = "column_materializer::properties::ramp"
+ }
+ column "mat_auto_chapters" {
+ type = "String"
+ comment = "column_materializer::properties::auto_chapters"
+ }
+ column "mat_sentiment_analysis" {
+ type = "String"
+ comment = "column_materializer::properties::sentiment_analysis"
+ }
+ column "mat_redact_pii" {
+ type = "String"
+ comment = "column_materializer::properties::redact_pii"
+ }
+ column "mat_content_safety" {
+ type = "String"
+ comment = "column_materializer::properties::content_safety"
+ }
+ column "mat_iab_categories" {
+ type = "String"
+ comment = "column_materializer::properties::iab_categories"
+ }
+ column "mat_auto_highlights" {
+ type = "String"
+ comment = "column_materializer::properties::auto_highlights"
+ }
+ column "mat_entity_detection" {
+ type = "String"
+ comment = "column_materializer::properties::entity_detection"
+ }
+ column "mat_summarization" {
+ type = "String"
+ comment = "column_materializer::properties::summarization"
+ }
+ column "mat_pp_val_region" {
+ type = "String"
+ comment = "column_materializer::person_properties::val_region"
+ }
+ column "mat_client_id" {
+ type = "String"
+ comment = "column_materializer::properties::client_id"
+ }
+ column "mat_$geoip_country_code" {
+ type = "String"
+ comment = "column_materializer::properties::$geoip_country_code"
+ }
+ column "mat_disfluencies" {
+ type = "String"
+ comment = "column_materializer::properties::disfluencies"
+ }
+ column "mat_filter_profanity" {
+ type = "String"
+ comment = "column_materializer::properties::filter_profanity"
+ }
+ column "mat_speaker_labels" {
+ type = "String"
+ comment = "column_materializer::properties::speaker_labels"
+ }
+ column "mat_language_detection" {
+ type = "String"
+ comment = "column_materializer::properties::language_detection"
+ }
+ column "mat_product_analytics_projected_amount" {
+ type = "String"
+ comment = "column_materializer::properties::product_analytics_projected_amount"
+ }
+ column "mat_recordings_projected_amount" {
+ type = "String"
+ comment = "column_materializer::properties::recordings_projected_amount"
+ }
+ column "mat_events_projected_amount" {
+ type = "String"
+ comment = "column_materializer::properties::events_projected_amount"
+ }
+ column "mat_session_replay_projected_amount" {
+ type = "String"
+ comment = "column_materializer::properties::session_replay_projected_amount"
+ }
+ column "mat_total_usd" {
+ type = "String"
+ comment = "column_materializer::properties::total_usd"
+ }
+ column "mat_stripe_amount_paid" {
+ type = "String"
+ comment = "column_materializer::properties::stripe_amount_paid"
+ }
+ column "mat_workspace" {
+ type = "String"
+ comment = "column_materializer::properties::workspace"
+ }
+ column "mat_created_at" {
+ type = "String"
+ comment = "column_materializer::properties::created_at"
+ }
+ column "mat_kind" {
+ type = "String"
+ comment = "column_materializer::properties::kind"
+ }
+ column "mat_product" {
+ type = "String"
+ comment = "column_materializer::properties::product"
+ }
+ column "mat_message" {
+ type = "String"
+ comment = "column_materializer::properties::message"
+ }
+ column "mat_initiator" {
+ type = "String"
+ comment = "column_materializer::properties::initiator"
+ }
+ column "mat_query" {
+ type = "String"
+ comment = "column_materializer::properties::query"
+ }
+ column "mat_$survey_id" {
+ type = "String"
+ comment = "column_materializer::properties::$survey_id"
+ }
+ column "mat_$survey_response_1" {
+ type = "String"
+ comment = "column_materializer::properties::$survey_response_1"
+ }
+ column "mat_ticketId" {
+ type = "String"
+ comment = "column_materializer::properties::ticketId"
+ }
+ column "mat_$survey_response" {
+ type = "String"
+ comment = "column_materializer::properties::$survey_response"
+ }
+ column "mat_conceptName" {
+ type = "String"
+ comment = "column_materializer::properties::conceptName"
+ }
+ column "mat_apiName" {
+ type = "String"
+ comment = "column_materializer::properties::apiName"
+ }
+ column "mat_workplace_billing_plan" {
+ type = "String"
+ comment = "column_materializer::properties::workplace_billing_plan"
+ }
+ column "mat_$el_text" {
+ type = "String"
+ comment = "column_materializer::properties::$el_text"
+ }
+ column "mat_recording_count_in_period" {
+ type = "String"
+ comment = "column_materializer::properties::recording_count_in_period"
+ }
+ column "mat_$os_version" {
+ type = "String"
+ comment = "column_materializer::properties::$os_version"
+ }
+ column "mat_orderId" {
+ type = "String"
+ comment = "column_materializer::properties::orderId"
+ }
+ column "mat_commit_sha" {
+ type = "String"
+ comment = "column_materializer::properties::commit_sha"
+ }
+ column "mat_$feature_flag_payloads" {
+ type = "String"
+ comment = "column_materializer::properties::$feature_flag_payloads"
+ }
+ column "mat_event_count_in_period" {
+ type = "String"
+ comment = "column_materializer::properties::event_count_in_period"
+ }
+ column "mat_$groups" {
+ type = "String"
+ comment = "column_materializer::properties::$groups"
+ }
+ column "mat_$feature_flag" {
+ type = "String"
+ comment = "column_materializer::properties::$feature_flag"
+ }
+ column "mat_utm_content" {
+ type = "String"
+ comment = "column_materializer::properties::utm_content"
+ }
+ column "mat_gclid" {
+ type = "String"
+ comment = "column_materializer::properties::gclid"
+ }
+ column "mat_gad_source" {
+ type = "String"
+ comment = "column_materializer::properties::gad_source"
+ }
+ column "mat_gbraid" {
+ type = "String"
+ comment = "column_materializer::properties::gbraid"
+ }
+ column "mat_wbraid" {
+ type = "String"
+ comment = "column_materializer::properties::wbraid"
+ }
+ column "mat_fbclid" {
+ type = "String"
+ comment = "column_materializer::properties::fbclid"
+ }
+ column "mat_msclkid" {
+ type = "String"
+ comment = "column_materializer::properties::msclkid"
+ }
+ column "mat_organization_id" {
+ type = "String"
+ comment = "column_materializer::properties::organization_id"
+ }
+ column "mat_owner_type" {
+ type = "String"
+ comment = "column_materializer::properties::owner_type"
+ }
+ column "mat_device_type" {
+ type = "String"
+ comment = "column_materializer::properties::device_type"
+ }
+ column "mat_$device_id" {
+ type = "String"
+ comment = "column_materializer::properties::$device_id"
+ }
+ column "mat_pp_$geoip_continent_name" {
+ type = "String"
+ comment = "column_materializer::person_properties::$geoip_continent_name"
+ }
+ column "mat_$feature_flag_response" {
+ type = "String"
+ comment = "column_materializer::properties::$feature_flag_response"
+ }
+ column "mat_pp_utm_source" {
+ type = "String"
+ comment = "column_materializer::person_properties::utm_source"
+ }
+ column "mat_pp_$referring_domain" {
+ type = "String"
+ comment = "column_materializer::person_properties::$referring_domain"
+ }
+ column "mat_pp_Email_Domain" {
+ type = "String"
+ comment = "column_materializer::person_properties::Email Domain"
+ }
+ column "mat_machine_id" {
+ type = "String"
+ comment = "column_materializer::properties::machine_id"
+ }
+ column "mat_user_email_domain" {
+ type = "String"
+ comment = "column_materializer::properties::user_email_domain"
+ }
+ column "mat_$lib_version__minor" {
+ type = "String"
+ comment = "column_materializer::properties::$lib_version__minor"
+ }
+ column "mat_region" {
+ type = "String"
+ comment = "column_materializer::properties::region"
+ }
+ column "mat_pp_user_email_domain" {
+ type = "String"
+ comment = "column_materializer::person_properties::user_email_domain"
+ }
+ column "mat_url_promotion_id" {
+ type = "String"
+ comment = "column_materializer::properties::url_promotion_id"
+ }
+ column "mat_$lib_custom_api_host" {
+ type = "String"
+ comment = "column_materializer::properties::$lib_custom_api_host"
+ }
+ column "person_mode" {
+ type = "Enum8('full'=0, 'propertyless'=1, 'force_upgrade'=2)"
+ }
+ column "mat_user_platform" {
+ type = "String"
+ comment = "column_materializer::properties::user_platform"
+ }
+ column "mat_pp_$geoip_country_name" {
+ type = "String"
+ comment = "column_materializer::person_properties::$geoip_country_name"
+ }
+ column "mat_environment" {
+ type = "String"
+ comment = "column_materializer::properties::environment"
+ }
+ column "mat_customer_email" {
+ type = "String"
+ comment = "column_materializer::properties::customer_email"
+ }
+ column "mat_client_name" {
+ type = "String"
+ comment = "column_materializer::properties::client_name"
+ }
+ column "mat_screen_name" {
+ type = "String"
+ comment = "column_materializer::properties::screen_name"
+ }
+ column "mat_app_version" {
+ type = "String"
+ comment = "column_materializer::properties::app_version"
+ }
+ column "elements_chain_href" {
+ type = "String"
+ comment = "column_materializer::elements_chain::href"
+ }
+ column "elements_chain_texts" {
+ type = "Array(String)"
+ comment = "column_materializer::elements_chain::texts"
+ }
+ column "elements_chain_ids" {
+ type = "Array(String)"
+ comment = "column_materializer::elements_chain::ids"
+ }
+ column "elements_chain_elements" {
+ type = "Array(Enum8('a'=1, 'button'=2, 'form'=3, 'input'=4, 'select'=5, 'textarea'=6, 'label'=7))"
+ comment = "column_materializer::elements_chain::elements"
+ }
+ column "properties_group_custom" {
+ type = "Map(String, String)"
+ }
+ column "properties_group_feature_flags" {
+ type = "Map(String, String)"
+ }
+ column "is_deleted" {
+ type = "Bool"
+ }
+ column "mat_subdomain" {
+ type = "String"
+ comment = "column_materializer::properties::subdomain"
+ }
+ column "mat_$device" {
+ type = "String"
+ comment = "column_materializer::properties::$device"
+ }
+ column "mat_id" {
+ type = "String"
+ comment = "column_materializer::properties::id"
+ }
+ column "mat_record_id" {
+ type = "String"
+ comment = "column_materializer::properties::record_id"
+ }
+ column "mat_referrer_id" {
+ type = "String"
+ comment = "column_materializer::properties::record_id"
+ }
+ column "mat_$exception_issue_id" {
+ type = "Nullable(String)"
+ comment = "column_materializer::properties::$exception_issue_id"
+ }
+ column "mat_$exception_fingerprint" {
+ type = "Nullable(String)"
+ comment = "column_materializer::properties::$exception_fingerprint"
+ }
+ column "mat_$web_vitals_LCP_value" {
+ type = "Nullable(String)"
+ comment = "column_materializer::properties::$web_vitals_LCP_value"
+ }
+ column "mat_$web_vitals_FCP_value" {
+ type = "Nullable(String)"
+ comment = "column_materializer::properties::$web_vitals_FCP_value"
+ }
+ column "mat_$web_vitals_CLS_value" {
+ type = "Nullable(String)"
+ comment = "column_materializer::properties::$web_vitals_CLS_value"
+ }
+ column "mat_$web_vitals_INP_value" {
+ type = "Nullable(String)"
+ comment = "column_materializer::properties::$web_vitals_INP_value"
+ }
+ column "mat_$viewport_width" {
+ type = "Nullable(String)"
+ comment = "column_materializer::properties::$viewport_width"
+ }
+ column "mat_$viewport_height" {
+ type = "Nullable(String)"
+ comment = "column_materializer::properties::$viewport_height"
+ }
+ column "mat_$anon_distinct_id" {
+ type = "Nullable(String)"
+ comment = "column_materializer::properties::$anon_distinct_id"
+ }
+ column "person_properties_map_custom" {
+ type = "Map(String, String)"
+ }
+ column "mat_$ai_trace_id" {
+ type = "Nullable(String)"
+ comment = "column_materializer::properties::$ai_trace_id"
+ }
+ column "mat_$ai_model" {
+ type = "Nullable(String)"
+ comment = "column_materializer::properties::$ai_model"
+ }
+ column "mat_$ai_provider" {
+ type = "Nullable(String)"
+ comment = "column_materializer::properties::$ai_provider"
+ }
+ column "mat_$ai_parent_id" {
+ type = "Nullable(String)"
+ comment = "column_materializer::properties::$ai_parent_id"
+ }
+ column "mat_$ai_span_id" {
+ type = "Nullable(String)"
+ comment = "column_materializer::properties::$ai_span_id"
+ }
+ column "mat_$ai_http_status" {
+ type = "Nullable(String)"
+ comment = "column_materializer::properties::$ai_http_status"
+ }
+ column "mat_$exception_types" {
+ type = "Nullable(String)"
+ comment = "column_materializer::properties::$exception_types"
+ }
+ column "mat_$exception_values" {
+ type = "Nullable(String)"
+ comment = "column_materializer::properties::$exception_values"
+ }
+ column "mat_$exception_sources" {
+ type = "Nullable(String)"
+ comment = "column_materializer::properties::$exception_sources"
+ }
+ column "mat_$exception_functions" {
+ type = "Nullable(String)"
+ comment = "column_materializer::properties::$exception_functions"
+ }
+ column "$session_id_uuid" {
+ type = "Nullable(UInt128)"
+ }
+ column "mat_$process_person_profile" {
+ type = "Nullable(String)"
+ comment = "column_materializer::properties::$process_person_profile"
+ }
+ column "consumer_breadcrumbs" {
+ type = "Array(String)"
+ }
+ column "properties_group_ai" {
+ type = "Map(String, String)"
+ }
+ column "mat_$is_identified" {
+ type = "Nullable(String)"
+ comment = "column_materializer::properties::$is_identified"
+ }
+ column "mat_historical_migration" {
+ type = "Nullable(String)"
+ comment = "column_materializer::properties::historical_migration"
+ }
+ column "mat_$ai_session_id" {
+ type = "Nullable(String)"
+ comment = "column_materializer::properties::$ai_session_id"
+ }
+ column "mat_$ai_is_error" {
+ type = "Nullable(String)"
+ comment = "column_materializer::properties::$ai_is_error"
+ }
+ column "dmat_string_0" {
+ type = "Nullable(String)"
+ }
+ column "dmat_string_1" {
+ type = "Nullable(String)"
+ }
+ column "dmat_string_2" {
+ type = "Nullable(String)"
+ }
+ column "dmat_string_3" {
+ type = "Nullable(String)"
+ }
+ column "dmat_string_4" {
+ type = "Nullable(String)"
+ }
+ column "dmat_string_5" {
+ type = "Nullable(String)"
+ }
+ column "dmat_string_6" {
+ type = "Nullable(String)"
+ }
+ column "dmat_string_7" {
+ type = "Nullable(String)"
+ }
+ column "dmat_string_8" {
+ type = "Nullable(String)"
+ }
+ column "dmat_string_9" {
+ type = "Nullable(String)"
+ }
+ column "dmat_numeric_0" {
+ type = "Nullable(Float64)"
+ }
+ column "dmat_numeric_1" {
+ type = "Nullable(Float64)"
+ }
+ column "dmat_numeric_2" {
+ type = "Nullable(Float64)"
+ }
+ column "dmat_numeric_3" {
+ type = "Nullable(Float64)"
+ }
+ column "dmat_numeric_4" {
+ type = "Nullable(Float64)"
+ }
+ column "dmat_numeric_5" {
+ type = "Nullable(Float64)"
+ }
+ column "dmat_numeric_6" {
+ type = "Nullable(Float64)"
+ }
+ column "dmat_numeric_7" {
+ type = "Nullable(Float64)"
+ }
+ column "dmat_numeric_8" {
+ type = "Nullable(Float64)"
+ }
+ column "dmat_numeric_9" {
+ type = "Nullable(Float64)"
+ }
+ column "dmat_bool_0" {
+ type = "Nullable(UInt8)"
+ }
+ column "dmat_bool_1" {
+ type = "Nullable(UInt8)"
+ }
+ column "dmat_bool_2" {
+ type = "Nullable(UInt8)"
+ }
+ column "dmat_bool_3" {
+ type = "Nullable(UInt8)"
+ }
+ column "dmat_bool_4" {
+ type = "Nullable(UInt8)"
+ }
+ column "dmat_bool_5" {
+ type = "Nullable(UInt8)"
+ }
+ column "dmat_bool_6" {
+ type = "Nullable(UInt8)"
+ }
+ column "dmat_bool_7" {
+ type = "Nullable(UInt8)"
+ }
+ column "dmat_bool_8" {
+ type = "Nullable(UInt8)"
+ }
+ column "dmat_bool_9" {
+ type = "Nullable(UInt8)"
+ }
+ column "dmat_datetime_0" {
+ type = "Nullable(DateTime64(6, 'UTC'))"
+ }
+ column "dmat_datetime_1" {
+ type = "Nullable(DateTime64(6, 'UTC'))"
+ }
+ column "dmat_datetime_2" {
+ type = "Nullable(DateTime64(6, 'UTC'))"
+ }
+ column "dmat_datetime_3" {
+ type = "Nullable(DateTime64(6, 'UTC'))"
+ }
+ column "dmat_datetime_4" {
+ type = "Nullable(DateTime64(6, 'UTC'))"
+ }
+ column "dmat_datetime_5" {
+ type = "Nullable(DateTime64(6, 'UTC'))"
+ }
+ column "dmat_datetime_6" {
+ type = "Nullable(DateTime64(6, 'UTC'))"
+ }
+ column "dmat_datetime_7" {
+ type = "Nullable(DateTime64(6, 'UTC'))"
+ }
+ column "dmat_datetime_8" {
+ type = "Nullable(DateTime64(6, 'UTC'))"
+ }
+ column "dmat_datetime_9" {
+ type = "Nullable(DateTime64(6, 'UTC'))"
+ }
+ column "historical_migration" {
+ type = "Bool"
+ }
+ column "mat_$ai_total_cost_usd" {
+ type = "Nullable(String)"
+ comment = "column_materializer::properties::$ai_total_cost_usd"
+ }
+ column "properties_group_ai_large" {
+ type = "Map(String, String)"
+ }
+ 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"
+ }
+ column "mat_$survey_submission_id" {
+ type = "Nullable(String)"
+ comment = "column_materializer::properties::$survey_submission_id"
+ }
+ column "mat_$geoip_subdivision_1_name" {
+ type = "Nullable(String)"
+ comment = "column_materializer::properties::$geoip_subdivision_1_name"
+ }
+ column "mat_$raw_user_agent" {
+ type = "Nullable(String)"
+ comment = "column_materializer::properties::$raw_user_agent"
+ }
+ column "mat_$prev_pageview_duration" {
+ type = "Nullable(String)"
+ comment = "column_materializer::properties::$prev_pageview_duration"
+ }
+ column "mat_pp_$initial_host" {
+ type = "Nullable(String)"
+ comment = "column_materializer::person_properties::$initial_host"
+ }
+ column "mat_pp_$initial_url" {
+ type = "Nullable(String)"
+ comment = "column_materializer::person_properties::$initial_url"
+ }
+ column "mat_pp_$initial_geoip_country_name" {
+ type = "Nullable(String)"
+ comment = "column_materializer::person_properties::$initial_geoip_country_name"
+ }
+ engine "distributed" {
+ cluster_name = "posthog"
+ remote_database = "posthog"
+ remote_table = "sharded_events"
+ sharding_key = "sipHash64(distinct_id)"
+ }
+ }
+
+ table "person_distinct_id_overrides" {
+ column "team_id" {
+ type = "Int64"
+ }
+ column "distinct_id" {
+ type = "String"
+ }
+ column "person_id" {
+ type = "UUID"
+ }
+ column "is_deleted" {
+ type = "Int8"
+ }
+ column "version" {
+ type = "Int64"
+ }
+ column "_timestamp" {
+ type = "DateTime"
+ }
+ column "_offset" {
+ type = "UInt64"
+ }
+ column "_partition" {
+ type = "UInt64"
+ }
+ engine "distributed" {
+ cluster_name = "posthog_single_shard"
+ remote_database = "posthog"
+ remote_table = "person_distinct_id_overrides"
+ sharding_key = "sipHash64(distinct_id)"
+ }
+ }
+
+ table "person_static_cohort" {
+ 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 "distributed" {
+ cluster_name = "posthog_single_shard"
+ remote_database = "posthog"
+ remote_table = "person_static_cohort"
+ sharding_key = "rand()"
+ }
+ }
+
+ 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 "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_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'))"
+ }
+ column "initial__kx" {
+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"
+ }
+ engine "replicated_aggregating_merge_tree" {
+ zoo_path = "/clickhouse/tables/sessions/noshard/posthog.raw_sessions"
+ replica_name = "{shard}-{replica}"
+ }
+ }
+
+ table "raw_sessions_v3" {
+ order_by = ["team_id", "session_timestamp", "session_id_v7"]
+ partition_by = "toYYYYMM(session_timestamp)"
+ settings = {
+ index_granularity = "8192"
+ }
+ 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, 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
+ }
+ engine "replicated_aggregating_merge_tree" {
+ zoo_path = "/clickhouse/tables/sessions/noshard/posthog.raw_sessions_v3"
+ replica_name = "{shard}-{replica}"
+ }
+ }
+
+ table "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 "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/sessions/noshard/posthog.sessions"
+ replica_name = "{shard}-{replica}"
+ }
+ }
+
+ table "web_pre_aggregated_teams" {
+ column "team_id" {
+ type = "UInt64"
+ }
+ column "enabled_by" {
+ type = "String"
+ default = "'system'"
+ }
+ column "version" {
+ type = "UInt32"
+ default = "toUnixTimestamp(now())"
+ }
+ engine "distributed" {
+ cluster_name = "posthog_single_shard"
+ remote_database = "posthog"
+ remote_table = "web_pre_aggregated_teams"
+ }
+ }
+
+ 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"
+ }
+ }
+
+ 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)"
+ }
+ }
+
+ 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
+
+ }
+
+ 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 = "dict_reader"
+ table = "channel_definition"
+ }
+ layout "complex_key_hashed" {
+ }
+ }
+
+ dictionary "web_pre_aggregated_teams_dict" {
+ primary_key = ["team_id"]
+ lifetime {
+ min = 3000
+ max = 3600
+ }
+ attribute "team_id" {
+ type = "UInt64"
+ }
+ source "clickhouse" {
+ user = "dict_reader"
+ query = "SELECT team_id FROM `web_pre_aggregated_teams` FINAL WHERE version > 0"
+ }
+ layout "hashed" {
+ }
+ }
+}
diff --git a/posthog/clickhouse/hcl/golden/prod-us-aux.hcl b/posthog/clickhouse/hcl/golden/prod-us-aux.hcl
new file mode 100644
index 000000000000..1f699b6dffef
--- /dev/null
+++ b/posthog/clickhouse/hcl/golden/prod-us-aux.hcl
@@ -0,0 +1,3847 @@
+database "posthog" {
+ 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 "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 "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 "hog_invocation_results" {
+ column "team_id" {
+ type = "Int64"
+ }
+ column "function_kind" {
+ type = "LowCardinality(String)"
+ }
+ column "function_id" {
+ type = "String"
+ }
+ column "invocation_id" {
+ type = "String"
+ }
+ column "parent_run_id" {
+ type = "String"
+ }
+ column "status" {
+ type = "LowCardinality(String)"
+ }
+ column "attempts" {
+ type = "UInt8"
+ }
+ column "is_retry" {
+ type = "UInt8"
+ }
+ column "scheduled_at" {
+ type = "DateTime64(6, 'UTC')"
+ }
+ column "first_scheduled_at" {
+ type = "DateTime64(6, 'UTC')"
+ }
+ column "started_at" {
+ type = "Nullable(DateTime64(6, 'UTC'))"
+ }
+ column "finished_at" {
+ type = "Nullable(DateTime64(6, 'UTC'))"
+ }
+ column "duration_ms" {
+ type = "Nullable(UInt32)"
+ }
+ column "error_kind" {
+ type = "LowCardinality(String)"
+ }
+ column "error_message" {
+ type = "String"
+ }
+ column "event_uuid" {
+ type = "String"
+ }
+ column "distinct_id" {
+ type = "String"
+ }
+ column "person_id" {
+ type = "String"
+ }
+ column "invocation_globals" {
+ type = "String"
+ }
+ column "version" {
+ type = "UInt64"
+ }
+ column "is_deleted" {
+ type = "UInt8"
+ }
+ column "_timestamp" {
+ type = "DateTime"
+ }
+ column "_offset" {
+ type = "UInt64"
+ }
+ column "_partition" {
+ type = "UInt64"
+ }
+ engine "distributed" {
+ cluster_name = "aux"
+ remote_database = "posthog"
+ remote_table = "hog_invocation_results_data"
+ }
+ }
+
+ table "hog_invocation_results_data" {
+ order_by = ["team_id", "function_kind", "function_id", "invocation_id"]
+ partition_by = "toYYYYMMDD(scheduled_at)"
+ ttl = "toDate(scheduled_at) + toIntervalDay(30)"
+ settings = {
+ index_granularity = "1024"
+ storage_policy = "s3_tiered"
+ ttl_only_drop_parts = "1"
+ }
+ column "team_id" {
+ type = "Int64"
+ }
+ column "function_kind" {
+ type = "LowCardinality(String)"
+ }
+ column "function_id" {
+ type = "String"
+ }
+ column "invocation_id" {
+ type = "String"
+ }
+ column "parent_run_id" {
+ type = "String"
+ }
+ column "status" {
+ type = "LowCardinality(String)"
+ }
+ column "attempts" {
+ type = "UInt8"
+ }
+ column "is_retry" {
+ type = "UInt8"
+ }
+ column "scheduled_at" {
+ type = "DateTime64(6, 'UTC')"
+ }
+ column "first_scheduled_at" {
+ type = "DateTime64(6, 'UTC')"
+ default = "scheduled_at"
+ }
+ column "started_at" {
+ type = "Nullable(DateTime64(6, 'UTC'))"
+ }
+ column "finished_at" {
+ type = "Nullable(DateTime64(6, 'UTC'))"
+ }
+ column "duration_ms" {
+ type = "Nullable(UInt32)"
+ }
+ column "error_kind" {
+ type = "LowCardinality(String)"
+ }
+ column "error_message" {
+ type = "String"
+ }
+ column "event_uuid" {
+ type = "String"
+ }
+ column "distinct_id" {
+ type = "String"
+ }
+ column "person_id" {
+ type = "String"
+ }
+ column "invocation_globals" {
+ type = "String"
+ }
+ column "version" {
+ type = "UInt64"
+ }
+ column "is_deleted" {
+ type = "UInt8"
+ default = "0"
+ }
+ column "_timestamp" {
+ type = "DateTime"
+ }
+ column "_offset" {
+ type = "UInt64"
+ }
+ column "_partition" {
+ type = "UInt64"
+ }
+ index "status_idx" {
+ expr = "status"
+ type = "set(8)"
+ granularity = 1
+ }
+ index "function_idx" {
+ expr = "function_id"
+ type = "bloom_filter(0.01)"
+ granularity = 1
+ }
+ index "event_uuid_idx" {
+ expr = "event_uuid"
+ type = "bloom_filter(0.01)"
+ granularity = 1
+ }
+ index "is_retry_idx" {
+ expr = "is_retry"
+ type = "set(2)"
+ granularity = 1
+ }
+ engine "replicated_replacing_merge_tree" {
+ zoo_path = "/clickhouse/tables/noshard/posthog.hog_invocation_results_data"
+ replica_name = "{replica}-{shard}"
+ version_column = "version"
+ }
+ }
+
+ table "ingestion_warnings_main" {
+ 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_hog_invocation_results" {
+ column "team_id" {
+ type = "Int64"
+ }
+ column "function_kind" {
+ type = "LowCardinality(String)"
+ }
+ column "function_id" {
+ type = "String"
+ }
+ column "invocation_id" {
+ type = "String"
+ }
+ column "parent_run_id" {
+ type = "String"
+ }
+ column "status" {
+ type = "LowCardinality(String)"
+ }
+ column "attempts" {
+ type = "UInt8"
+ }
+ column "is_retry" {
+ type = "UInt8"
+ }
+ column "scheduled_at" {
+ type = "DateTime64(6, 'UTC')"
+ }
+ column "first_scheduled_at" {
+ type = "DateTime64(6, 'UTC')"
+ }
+ column "started_at" {
+ type = "Nullable(DateTime64(6, 'UTC'))"
+ }
+ column "finished_at" {
+ type = "Nullable(DateTime64(6, 'UTC'))"
+ }
+ column "duration_ms" {
+ type = "Nullable(UInt32)"
+ }
+ column "error_kind" {
+ type = "LowCardinality(String)"
+ }
+ column "error_message" {
+ type = "String"
+ }
+ column "event_uuid" {
+ type = "String"
+ }
+ column "distinct_id" {
+ type = "String"
+ }
+ column "person_id" {
+ type = "String"
+ }
+ column "invocation_globals" {
+ type = "String"
+ }
+ column "version" {
+ type = "UInt64"
+ }
+ column "is_deleted" {
+ type = "UInt8"
+ }
+ engine "kafka" {
+ broker_list = "warpstream_cyclotron"
+ topic_list = "kafka_topic_list = 'clickhouse_hog_invocation_results'"
+ group_name = "kafka_group_name = 'clickhouse_hog_invocation_results'"
+ format = "kafka_format = 'JSONEachRow'"
+ num_consumers = 1
+ max_block_size = 100000
+ skip_broken_messages = 100
+ poll_timeout_ms = 10000
+ thread_per_consumer = true
+ }
+ }
+
+ table "kafka_message_assets" {
+ column "team_id" {
+ type = "Int64"
+ }
+ column "function_kind" {
+ type = "LowCardinality(String)"
+ }
+ column "function_id" {
+ type = "String"
+ }
+ column "parent_run_id" {
+ type = "String"
+ }
+ column "invocation_id" {
+ type = "String"
+ }
+ column "action_id" {
+ type = "String"
+ }
+ column "kind" {
+ type = "LowCardinality(String)"
+ }
+ column "distinct_id" {
+ type = "String"
+ }
+ column "person_id" {
+ type = "String"
+ }
+ column "recipient" {
+ type = "String"
+ }
+ column "subject" {
+ type = "String"
+ }
+ column "status" {
+ type = "LowCardinality(String)"
+ }
+ column "sent_at" {
+ type = "DateTime64(6, 'UTC')"
+ }
+ column "version" {
+ type = "UInt64"
+ }
+ column "is_deleted" {
+ type = "UInt8"
+ }
+ column "html" {
+ type = "String"
+ }
+ engine "kafka" {
+ broker_list = "warpstream_cyclotron"
+ topic_list = "kafka_topic_list = 'clickhouse_message_assets'"
+ group_name = "kafka_group_name = 'clickhouse_message_assets'"
+ format = "kafka_format = 'JSONEachRow'"
+ skip_broken_messages = 100
+ }
+ }
+
+ table "kafka_property_values" {
+ column "team_id" {
+ type = "Int64"
+ }
+ column "property_type" {
+ type = "LowCardinality(String)"
+ }
+ column "property_key" {
+ type = "String"
+ }
+ column "property_value" {
+ type = "String"
+ }
+ column "property_count" {
+ type = "UInt64"
+ }
+ engine "kafka" {
+ broker_list = "warpstream_ingestion"
+ topic_list = "kafka_topic_list = 'clickhouse_property_values'"
+ group_name = "kafka_group_name = 'clickhouse_property_values'"
+ format = "kafka_format = 'JSONEachRow'"
+ num_consumers = 8
+ thread_per_consumer = true
+ }
+ }
+
+ table "marketing_conversions_preaggregated" {
+ column "team_id" {
+ type = "Int64"
+ }
+ column "job_id" {
+ type = "UUID"
+ }
+ column "person_id" {
+ type = "UUID"
+ }
+ column "conversion_timestamp" {
+ type = "DateTime64(6, 'UTC')"
+ }
+ column "conversion_math_value" {
+ type = "Float64"
+ }
+ column "session_id" {
+ type = "String"
+ }
+ column "campaign_name" {
+ type = "String"
+ }
+ column "source_name" {
+ type = "String"
+ }
+ column "medium_name" {
+ type = "String"
+ }
+ column "content_name" {
+ type = "String"
+ }
+ column "term_name" {
+ type = "String"
+ }
+ column "referring_domain_name" {
+ type = "String"
+ }
+ column "gclid_name" {
+ type = "String"
+ }
+ column "fbclid_name" {
+ type = "String"
+ }
+ column "gad_source_name" {
+ type = "String"
+ }
+ column "computed_at" {
+ type = "DateTime64(6, 'UTC')"
+ default = "now()"
+ }
+ column "expires_at" {
+ type = "Date"
+ default = "today() + toIntervalDay(7)"
+ }
+ engine "distributed" {
+ cluster_name = "aux"
+ remote_database = "posthog"
+ remote_table = "sharded_marketing_conversions_preaggregated"
+ sharding_key = "cityHash64(person_id)"
+ }
+ }
+
+ table "marketing_costs_preaggregated" {
+ column "team_id" {
+ type = "Int64"
+ }
+ column "job_id" {
+ type = "UUID"
+ }
+ column "source_id" {
+ type = "String"
+ }
+ column "source_name" {
+ type = "String"
+ }
+ column "grain" {
+ type = "LowCardinality(String)"
+ }
+ column "match_key" {
+ type = "String"
+ }
+ column "campaign_id" {
+ type = "String"
+ }
+ column "campaign_name" {
+ type = "String"
+ }
+ column "ad_group_id" {
+ type = "String"
+ }
+ column "ad_group_name" {
+ type = "String"
+ }
+ column "ad_id" {
+ type = "String"
+ }
+ column "ad_name" {
+ type = "String"
+ }
+ column "cost_date" {
+ type = "Date"
+ }
+ column "cost" {
+ type = "Float64"
+ }
+ column "clicks" {
+ type = "Float64"
+ }
+ column "impressions" {
+ type = "Float64"
+ }
+ column "reported_conversions" {
+ type = "Float64"
+ }
+ column "reported_conversion_value" {
+ type = "Float64"
+ }
+ column "computed_at" {
+ type = "DateTime64(6, 'UTC')"
+ default = "now()"
+ }
+ column "expires_at" {
+ type = "Date"
+ default = "today() + toIntervalDay(7)"
+ }
+ engine "distributed" {
+ cluster_name = "aux"
+ remote_database = "posthog"
+ remote_table = "sharded_marketing_costs_preaggregated"
+ sharding_key = "cityHash64(source_name, campaign_id)"
+ }
+ }
+
+ table "marketing_touchpoints_preaggregated" {
+ column "team_id" {
+ type = "Int64"
+ }
+ column "job_id" {
+ type = "UUID"
+ }
+ column "person_id" {
+ type = "UUID"
+ }
+ column "touchpoint_timestamp" {
+ type = "DateTime64(6, 'UTC')"
+ }
+ column "campaign_name" {
+ type = "String"
+ }
+ column "source_name" {
+ type = "String"
+ }
+ column "medium_name" {
+ type = "String"
+ }
+ column "content_name" {
+ type = "String"
+ }
+ column "term_name" {
+ type = "String"
+ }
+ column "referring_domain_name" {
+ type = "String"
+ }
+ column "gclid_name" {
+ type = "String"
+ }
+ column "fbclid_name" {
+ type = "String"
+ }
+ column "gad_source_name" {
+ type = "String"
+ }
+ column "computed_at" {
+ type = "DateTime64(6, 'UTC')"
+ default = "now()"
+ }
+ column "expires_at" {
+ type = "Date"
+ default = "today() + toIntervalDay(7)"
+ }
+ engine "distributed" {
+ cluster_name = "aux"
+ remote_database = "posthog"
+ remote_table = "sharded_marketing_touchpoints_preaggregated"
+ sharding_key = "cityHash64(person_id)"
+ }
+ }
+
+ table "message_assets" {
+ column "team_id" {
+ type = "Int64"
+ }
+ column "function_kind" {
+ type = "LowCardinality(String)"
+ }
+ column "function_id" {
+ type = "String"
+ }
+ column "parent_run_id" {
+ type = "String"
+ }
+ column "invocation_id" {
+ type = "String"
+ }
+ column "action_id" {
+ type = "String"
+ }
+ column "kind" {
+ type = "LowCardinality(String)"
+ }
+ column "distinct_id" {
+ type = "String"
+ }
+ column "person_id" {
+ type = "String"
+ }
+ column "recipient" {
+ type = "String"
+ }
+ column "subject" {
+ type = "String"
+ }
+ column "status" {
+ type = "LowCardinality(String)"
+ }
+ column "sent_at" {
+ type = "DateTime64(6, 'UTC')"
+ }
+ column "version" {
+ type = "UInt64"
+ }
+ column "is_deleted" {
+ type = "UInt8"
+ }
+ column "html" {
+ type = "String"
+ }
+ column "_timestamp" {
+ type = "DateTime"
+ }
+ column "_offset" {
+ type = "UInt64"
+ }
+ column "_partition" {
+ type = "UInt64"
+ }
+ engine "distributed" {
+ cluster_name = "aux"
+ remote_database = "posthog"
+ remote_table = "message_assets_data"
+ }
+ }
+
+ table "message_assets_data" {
+ order_by = ["team_id", "function_kind", "function_id", "invocation_id", "action_id"]
+ partition_by = "toYYYYMMDD(sent_at)"
+ ttl = "toDate(sent_at) + toIntervalDay(30)"
+ settings = {
+ index_granularity = "1024"
+ ttl_only_drop_parts = "1"
+ }
+ column "team_id" {
+ type = "Int64"
+ }
+ column "function_kind" {
+ type = "LowCardinality(String)"
+ }
+ column "function_id" {
+ type = "String"
+ }
+ column "parent_run_id" {
+ type = "String"
+ }
+ column "invocation_id" {
+ type = "String"
+ }
+ column "action_id" {
+ type = "String"
+ }
+ column "kind" {
+ type = "LowCardinality(String)"
+ }
+ column "distinct_id" {
+ type = "String"
+ }
+ column "person_id" {
+ type = "String"
+ }
+ column "recipient" {
+ type = "String"
+ }
+ column "subject" {
+ type = "String"
+ }
+ column "status" {
+ type = "LowCardinality(String)"
+ }
+ column "sent_at" {
+ type = "DateTime64(6, 'UTC')"
+ }
+ column "version" {
+ type = "UInt64"
+ }
+ column "is_deleted" {
+ type = "UInt8"
+ default = "0"
+ }
+ column "html" {
+ type = "String"
+ codec = "ZSTD(3)"
+ }
+ column "_timestamp" {
+ type = "DateTime"
+ }
+ column "_offset" {
+ type = "UInt64"
+ }
+ column "_partition" {
+ type = "UInt64"
+ }
+ index "parent_run_idx" {
+ expr = "parent_run_id"
+ type = "bloom_filter(0.01)"
+ granularity = 1
+ }
+ index "distinct_id_idx" {
+ expr = "distinct_id"
+ type = "bloom_filter(0.01)"
+ granularity = 1
+ }
+ index "person_id_idx" {
+ expr = "person_id"
+ type = "bloom_filter(0.01)"
+ granularity = 1
+ }
+ index "recipient_idx" {
+ expr = "recipient"
+ type = "bloom_filter(0.01)"
+ granularity = 1
+ }
+ engine "replicated_replacing_merge_tree" {
+ zoo_path = "/clickhouse/tables/noshard/posthog.message_assets_data"
+ replica_name = "{replica}-{shard}"
+ version_column = "version"
+ }
+ }
+
+ table "property_values" {
+ order_by = ["team_id", "property_type", "property_key", "property_value"]
+ ttl = "last_seen + toIntervalDay(30)"
+ settings = {
+ index_granularity = "8192"
+ }
+ column "team_id" {
+ type = "Int64"
+ codec = "DoubleDelta, ZSTD(1)"
+ }
+ column "property_type" {
+ type = "LowCardinality(String)"
+ }
+ column "property_key" {
+ type = "LowCardinality(String)"
+ }
+ column "property_value" {
+ type = "String"
+ }
+ column "property_count" {
+ type = "SimpleAggregateFunction(sum, UInt64)"
+ }
+ column "last_seen" {
+ type = "SimpleAggregateFunction(max, DateTime)"
+ default = "now()"
+ }
+ index "idx_property_value_ngrambf" {
+ expr = "lower(property_value)"
+ type = "ngrambf_v1(3, 32768, 3, 0)"
+ granularity = 1
+ }
+ engine "replicated_aggregating_merge_tree" {
+ zoo_path = "/clickhouse/tables/noshard/posthog.property_values"
+ replica_name = "{replica}-{shard}"
+ }
+ }
+
+ table "property_values_distributed" {
+ column "team_id" {
+ type = "Int64"
+ codec = "DoubleDelta, ZSTD(1)"
+ }
+ column "property_type" {
+ type = "LowCardinality(String)"
+ }
+ column "property_key" {
+ type = "LowCardinality(String)"
+ }
+ column "property_value" {
+ type = "String"
+ }
+ column "property_count" {
+ type = "SimpleAggregateFunction(sum, UInt64)"
+ }
+ column "last_seen" {
+ type = "SimpleAggregateFunction(max, DateTime)"
+ default = "now()"
+ }
+ engine "distributed" {
+ cluster_name = "aux"
+ remote_database = "posthog"
+ remote_table = "property_values"
+ }
+ }
+
+ table "query_log_archive" {
+ column "hostname" {
+ type = "LowCardinality(String)"
+ }
+ column "user" {
+ type = "LowCardinality(String)"
+ }
+ column "query_id" {
+ type = "String"
+ }
+ column "initial_query_id" {
+ type = "String"
+ }
+ column "is_initial_query" {
+ type = "UInt8"
+ }
+ column "type" {
+ type = "Enum8('QueryStart'=1, 'QueryFinish'=2, 'ExceptionBeforeStart'=3, 'ExceptionWhileProcessing'=4)"
+ }
+ column "event_date" {
+ type = "Date"
+ }
+ column "event_time" {
+ type = "DateTime"
+ }
+ column "event_time_microseconds" {
+ type = "DateTime64(6)"
+ }
+ column "query_start_time" {
+ type = "DateTime"
+ }
+ column "query_start_time_microseconds" {
+ type = "DateTime64(6)"
+ }
+ column "query_duration_ms" {
+ type = "UInt64"
+ }
+ column "read_rows" {
+ type = "UInt64"
+ }
+ column "read_bytes" {
+ type = "UInt64"
+ }
+ column "written_rows" {
+ type = "UInt64"
+ }
+ column "written_bytes" {
+ type = "UInt64"
+ }
+ column "result_rows" {
+ type = "UInt64"
+ }
+ column "result_bytes" {
+ type = "UInt64"
+ }
+ column "memory_usage" {
+ type = "UInt64"
+ }
+ column "peak_threads_usage" {
+ type = "UInt64"
+ }
+ column "current_database" {
+ type = "LowCardinality(String)"
+ }
+ column "query" {
+ type = "String"
+ }
+ column "formatted_query" {
+ type = "String"
+ }
+ column "normalized_query_hash" {
+ type = "UInt64"
+ }
+ column "query_kind" {
+ type = "LowCardinality(String)"
+ }
+ column "exception_code" {
+ type = "Int32"
+ }
+ column "exception" {
+ type = "String"
+ }
+ column "stack_trace" {
+ type = "String"
+ }
+ column "team_id" {
+ type = "Int64"
+ }
+ column "log_comment" {
+ type = "JSON(max_dynamic_paths=256, access_method LowCardinality(String), alert_config_id String, api_key_label String, api_key_mask String, batch_export_id String, chargeable Bool, client_query_id String, cohort_id Int64, `dagster.job_name` String, `dagster.run_id` String, `dagster.tags.owner` String, dashboard_id Int64, experiment_feature_flag_key String, experiment_id Int64, feature LowCardinality(String), id String, insight_id Int64, is_impersonated Bool, kind LowCardinality(String), name String, org_id String, person_on_events_mode LowCardinality(String), product LowCardinality(String), query_type LowCardinality(String), request_name String, route_id String, service_name String, session_id String, table_id String, team_id Int64, `temporal.activity_id` String, `temporal.activity_type` String, `temporal.attempt` Int64, `temporal.workflow_id` String, `temporal.workflow_namespace` String, `temporal.workflow_run_id` String, `temporal.workflow_type` String, user_id Int64, warehouse_query Bool, workflow LowCardinality(String), workload LowCardinality(String), SKIP cache_key, SKIP filter, SKIP hogql_features, SKIP http_referer, SKIP http_request_id, SKIP http_user_agent, SKIP query_settings, SKIP timings, SKIP user_email)"
+ }
+ column "ProfileEvents" {
+ type = "Map(String, UInt64)"
+ }
+ column "exception_name" {
+ type = "String"
+ alias = "errorCodeToName(exception_code)"
+ }
+ column "ProfileEvents_RealTimeMicroseconds" {
+ type = "Int64"
+ alias = "ProfileEvents['RealTimeMicroseconds']"
+ }
+ column "ProfileEvents_OSCPUVirtualTimeMicroseconds" {
+ type = "Int64"
+ alias = "ProfileEvents['OSCPUVirtualTimeMicroseconds']"
+ }
+ column "ProfileEvents_S3Clients" {
+ type = "Int64"
+ alias = "ProfileEvents['S3Clients']"
+ }
+ column "ProfileEvents_S3DeleteObjects" {
+ type = "Int64"
+ alias = "ProfileEvents['S3DeleteObjects']"
+ }
+ column "ProfileEvents_S3CopyObject" {
+ type = "Int64"
+ alias = "ProfileEvents['S3CopyObject']"
+ }
+ column "ProfileEvents_S3ListObjects" {
+ type = "Int64"
+ alias = "ProfileEvents['S3ListObjects']"
+ }
+ column "ProfileEvents_S3HeadObject" {
+ type = "Int64"
+ alias = "ProfileEvents['S3HeadObject']"
+ }
+ column "ProfileEvents_S3GetObjectAttributes" {
+ type = "Int64"
+ alias = "ProfileEvents['S3GetObjectAttributes']"
+ }
+ column "ProfileEvents_S3CreateMultipartUpload" {
+ type = "Int64"
+ alias = "ProfileEvents['S3CreateMultipartUpload']"
+ }
+ column "ProfileEvents_S3UploadPartCopy" {
+ type = "Int64"
+ alias = "ProfileEvents['S3UploadPartCopy']"
+ }
+ column "ProfileEvents_S3UploadPart" {
+ type = "Int64"
+ alias = "ProfileEvents['S3UploadPart']"
+ }
+ column "ProfileEvents_S3AbortMultipartUpload" {
+ type = "Int64"
+ alias = "ProfileEvents['S3AbortMultipartUpload']"
+ }
+ column "ProfileEvents_S3CompleteMultipartUpload" {
+ type = "Int64"
+ alias = "ProfileEvents['S3CompleteMultipartUpload']"
+ }
+ column "ProfileEvents_S3PutObject" {
+ type = "Int64"
+ alias = "ProfileEvents['S3PutObject']"
+ }
+ column "ProfileEvents_S3GetObject" {
+ type = "Int64"
+ alias = "ProfileEvents['S3GetObject']"
+ }
+ column "ProfileEvents_ReadBufferFromS3Bytes" {
+ type = "Int64"
+ alias = "ProfileEvents['ReadBufferFromS3Bytes']"
+ }
+ column "ProfileEvents_WriteBufferFromS3Bytes" {
+ type = "Int64"
+ alias = "ProfileEvents['WriteBufferFromS3Bytes']"
+ }
+ column "lc_workflow" {
+ type = "LowCardinality(String)"
+ alias = "log_comment.workflow"
+ }
+ column "lc_kind" {
+ type = "LowCardinality(String)"
+ alias = "log_comment.kind"
+ }
+ column "lc_id" {
+ type = "String"
+ alias = "CAST(log_comment.id, 'String')"
+ }
+ column "lc_route_id" {
+ type = "String"
+ alias = "CAST(log_comment.route_id, 'String')"
+ }
+ column "lc_access_method" {
+ type = "LowCardinality(String)"
+ alias = "log_comment.access_method"
+ }
+ column "lc_api_key_label" {
+ type = "String"
+ alias = "CAST(log_comment.api_key_label, 'String')"
+ }
+ column "lc_api_key_mask" {
+ type = "String"
+ alias = "CAST(log_comment.api_key_mask, 'String')"
+ }
+ column "lc_query_type" {
+ type = "LowCardinality(String)"
+ alias = "log_comment.query_type"
+ }
+ column "lc_product" {
+ type = "LowCardinality(String)"
+ alias = "log_comment.product"
+ }
+ column "lc_chargeable" {
+ type = "Bool"
+ alias = "log_comment.chargeable"
+ }
+ column "lc_name" {
+ type = "String"
+ alias = "CAST(log_comment.name, 'String')"
+ }
+ column "lc_request_name" {
+ type = "String"
+ alias = "CAST(log_comment.request_name, 'String')"
+ }
+ column "lc_client_query_id" {
+ type = "String"
+ alias = "CAST(log_comment.client_query_id, 'String')"
+ }
+ column "lc_org_id" {
+ type = "String"
+ alias = "CAST(log_comment.org_id, 'String')"
+ }
+ column "lc_user_id" {
+ type = "Int64"
+ alias = "log_comment.user_id"
+ }
+ column "lc_is_impersonated" {
+ type = "Bool"
+ alias = "log_comment.is_impersonated"
+ }
+ column "lc_session_id" {
+ type = "String"
+ alias = "CAST(log_comment.session_id, 'String')"
+ }
+ column "lc_dashboard_id" {
+ type = "Int64"
+ alias = "log_comment.dashboard_id"
+ }
+ column "lc_insight_id" {
+ type = "Int64"
+ alias = "log_comment.insight_id"
+ }
+ column "lc_cohort_id" {
+ type = "Int64"
+ alias = "log_comment.cohort_id"
+ }
+ column "lc_batch_export_id" {
+ type = "String"
+ alias = "CAST(log_comment.batch_export_id, 'String')"
+ }
+ column "lc_experiment_id" {
+ type = "Int64"
+ alias = "log_comment.experiment_id"
+ }
+ column "lc_experiment_feature_flag_key" {
+ type = "String"
+ alias = "CAST(log_comment.experiment_feature_flag_key, 'String')"
+ }
+ column "lc_alert_config_id" {
+ type = "String"
+ alias = "CAST(log_comment.alert_config_id, 'String')"
+ }
+ column "lc_feature" {
+ type = "LowCardinality(String)"
+ alias = "log_comment.feature"
+ }
+ column "lc_table_id" {
+ type = "String"
+ alias = "CAST(log_comment.table_id, 'String')"
+ }
+ column "lc_warehouse_query" {
+ type = "Bool"
+ alias = "log_comment.warehouse_query"
+ }
+ column "lc_person_on_events_mode" {
+ type = "LowCardinality(String)"
+ alias = "log_comment.person_on_events_mode"
+ }
+ column "lc_service_name" {
+ type = "String"
+ alias = "CAST(log_comment.service_name, 'String')"
+ }
+ column "lc_workload" {
+ type = "LowCardinality(String)"
+ alias = "log_comment.workload"
+ }
+ column "lc_query__kind" {
+ type = "LowCardinality(String)"
+ alias = "if(JSONHas(toString(log_comment), 'query', 'source'), JSONExtractString(toString(log_comment), 'query', 'source', 'kind'), JSONExtractString(toString(log_comment), 'query', 'kind'))"
+ }
+ column "lc_query__query" {
+ type = "String"
+ alias = "multiIf(NOT is_initial_query, '', JSONHas(toString(log_comment), 'query', 'source'), JSONExtractString(toString(log_comment), 'query', 'source', 'query'), JSONExtractString(toString(log_comment), 'query', 'query'))"
+ }
+ column "lc_query" {
+ type = "String"
+ alias = "if(is_initial_query, JSONExtractRaw(toString(log_comment), 'query'), '')"
+ }
+ column "lc_temporal__workflow_namespace" {
+ type = "String"
+ alias = "CAST(log_comment.`temporal.workflow_namespace`, 'String')"
+ }
+ column "lc_temporal__workflow_type" {
+ type = "String"
+ alias = "CAST(log_comment.`temporal.workflow_type`, 'String')"
+ }
+ column "lc_temporal__workflow_id" {
+ type = "String"
+ alias = "CAST(log_comment.`temporal.workflow_id`, 'String')"
+ }
+ column "lc_temporal__workflow_run_id" {
+ type = "String"
+ alias = "CAST(log_comment.`temporal.workflow_run_id`, 'String')"
+ }
+ column "lc_temporal__activity_type" {
+ type = "String"
+ alias = "CAST(log_comment.`temporal.activity_type`, 'String')"
+ }
+ column "lc_temporal__activity_id" {
+ type = "String"
+ alias = "CAST(log_comment.`temporal.activity_id`, 'String')"
+ }
+ column "lc_temporal__attempt" {
+ type = "Int64"
+ alias = "log_comment.`temporal.attempt`"
+ }
+ column "lc_dagster__job_name" {
+ type = "String"
+ alias = "CAST(log_comment.`dagster.job_name`, 'String')"
+ }
+ column "lc_dagster__run_id" {
+ type = "String"
+ alias = "CAST(log_comment.`dagster.run_id`, 'String')"
+ }
+ column "lc_dagster__owner" {
+ type = "String"
+ alias = "CAST(log_comment.`dagster.tags.owner`, 'String')"
+ }
+ column "lc_modifiers" {
+ type = "String"
+ alias = "if(is_initial_query, JSONExtractRaw(toString(log_comment), 'modifiers'), '')"
+ }
+ engine "distributed" {
+ cluster_name = "ops"
+ remote_database = "posthog"
+ remote_table = "sharded_query_log_archive"
+ }
+ }
+
+ table "raw_error_tracking_fingerprint_issue_state" {
+ order_by = ["team_id", "fingerprint"]
+ settings = {
+ index_granularity = "512"
+ }
+ column "team_id" {
+ type = "Int64"
+ }
+ column "fingerprint" {
+ type = "String"
+ }
+ column "issue_id" {
+ type = "UUID"
+ }
+ column "issue_name" {
+ type = "Nullable(String)"
+ }
+ column "issue_description" {
+ type = "Nullable(String)"
+ }
+ column "issue_status" {
+ type = "String"
+ }
+ column "assigned_user_id" {
+ type = "Nullable(Int64)"
+ }
+ column "assigned_role_id" {
+ type = "Nullable(UUID)"
+ }
+ column "first_seen" {
+ type = "DateTime64(3, 'UTC')"
+ }
+ column "is_deleted" {
+ type = "Int8"
+ }
+ column "version" {
+ type = "Int64"
+ }
+ column "_timestamp" {
+ type = "DateTime"
+ }
+ column "_offset" {
+ type = "UInt64"
+ }
+ column "_partition" {
+ type = "UInt64"
+ }
+ index "kafka_timestamp_minmax_raw_error_tracking_fingerprint_issue_state" {
+ expr = "_timestamp"
+ type = "minmax"
+ granularity = 3
+ }
+ engine "replicated_replacing_merge_tree" {
+ zoo_path = "/clickhouse/tables/noshard/posthog.raw_error_tracking_fingerprint_issue_state"
+ replica_name = "{replica}-{shard}"
+ version_column = "version"
+ }
+ }
+
+ table "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 "sharded_conversion_goal_attributed_preaggregated" {
+ order_by = ["team_id", "job_id", "person_id", "conversion_timestamp", "touchpoint_timestamp"]
+ partition_by = "toYYYYMMDD(expires_at)"
+ ttl = "expires_at"
+ settings = {
+ index_granularity = "8192"
+ ttl_only_drop_parts = "1"
+ }
+ column "team_id" {
+ type = "Int64"
+ }
+ column "job_id" {
+ type = "UUID"
+ }
+ column "person_id" {
+ type = "UUID"
+ }
+ column "conversion_timestamp" {
+ type = "DateTime64(6, 'UTC')"
+ }
+ column "conversion_value" {
+ type = "Float64"
+ }
+ column "touchpoint_timestamp" {
+ type = "DateTime64(6, 'UTC')"
+ }
+ column "touchpoint_weight" {
+ type = "Float64"
+ }
+ column "campaign_name" {
+ type = "String"
+ }
+ column "source_name" {
+ type = "String"
+ }
+ column "medium_name" {
+ type = "String"
+ }
+ column "content_name" {
+ type = "String"
+ }
+ column "term_name" {
+ type = "String"
+ }
+ column "referring_domain_name" {
+ type = "String"
+ }
+ column "gclid_name" {
+ type = "String"
+ }
+ column "fbclid_name" {
+ type = "String"
+ }
+ column "gad_source_name" {
+ type = "String"
+ }
+ column "computed_at" {
+ type = "DateTime64(6, 'UTC')"
+ default = "now()"
+ }
+ column "expires_at" {
+ type = "Date"
+ default = "today() + toIntervalDay(7)"
+ }
+ engine "replicated_replacing_merge_tree" {
+ zoo_path = "/clickhouse/tables/noshard/posthog.conversion_goal_attributed_preaggregated"
+ replica_name = "{replica}-{shard}"
+ version_column = "computed_at"
+ }
+ }
+
+ table "sharded_experiment_metric_events_preaggregated" {
+ order_by = ["team_id", "job_id", "entity_id", "timestamp", "event_uuid"]
+ partition_by = "toYYYYMMDD(expires_at)"
+ ttl = "expires_at"
+ settings = {
+ index_granularity = "8192"
+ ttl_only_drop_parts = "1"
+ }
+ column "team_id" {
+ type = "Int64"
+ }
+ column "job_id" {
+ type = "UUID"
+ }
+ column "entity_id" {
+ type = "String"
+ }
+ column "timestamp" {
+ type = "DateTime64(6, 'UTC')"
+ }
+ column "event_uuid" {
+ type = "UUID"
+ }
+ column "session_id" {
+ type = "String"
+ }
+ column "numeric_value" {
+ type = "Float64"
+ default = "0"
+ }
+ column "steps" {
+ type = "Array(UInt8)"
+ default = "[]"
+ }
+ column "computed_at" {
+ type = "DateTime64(6, 'UTC')"
+ default = "now()"
+ }
+ column "expires_at" {
+ type = "Date"
+ default = "today() + toIntervalDay(7)"
+ }
+ engine "replicated_replacing_merge_tree" {
+ zoo_path = "/clickhouse/tables/noshard/posthog.experiment_metric_events_preaggregated"
+ replica_name = "{replica}-{shard}"
+ version_column = "computed_at"
+ }
+ }
+
+ table "sharded_ingestion_warnings" {
+ order_by = ["team_id", "toHour(timestamp)", "type", "source", "timestamp"]
+ partition_by = "toYear(timestamp)"
+ settings = {
+ index_granularity = "8192"
+ }
+ column "team_id" {
+ type = "Int64"
+ }
+ column "source" {
+ type = "LowCardinality(String)"
+ }
+ column "type" {
+ type = "String"
+ }
+ column "details" {
+ type = "String"
+ }
+ column "timestamp" {
+ type = "DateTime64(6, 'UTC')"
+ }
+ column "_timestamp" {
+ type = "DateTime"
+ }
+ column "_offset" {
+ type = "UInt64"
+ }
+ column "_partition" {
+ type = "UInt64"
+ }
+ engine "replicated_merge_tree" {
+ zoo_path = "/clickhouse/tables/reshard/{shard}/posthog.sharded_ingestion_warnings"
+ replica_name = "{replica}"
+ }
+ }
+
+ table "sharded_marketing_conversions_preaggregated" {
+ order_by = ["team_id", "job_id", "person_id", "conversion_timestamp"]
+ partition_by = "toYYYYMMDD(expires_at)"
+ ttl = "expires_at"
+ settings = {
+ index_granularity = "8192"
+ ttl_only_drop_parts = "1"
+ }
+ column "team_id" {
+ type = "Int64"
+ }
+ column "job_id" {
+ type = "UUID"
+ }
+ column "person_id" {
+ type = "UUID"
+ }
+ column "conversion_timestamp" {
+ type = "DateTime64(6, 'UTC')"
+ }
+ column "conversion_math_value" {
+ type = "Float64"
+ }
+ column "session_id" {
+ type = "String"
+ }
+ column "campaign_name" {
+ type = "String"
+ }
+ column "source_name" {
+ type = "String"
+ }
+ column "medium_name" {
+ type = "String"
+ }
+ column "content_name" {
+ type = "String"
+ }
+ column "term_name" {
+ type = "String"
+ }
+ column "referring_domain_name" {
+ type = "String"
+ }
+ column "gclid_name" {
+ type = "String"
+ }
+ column "fbclid_name" {
+ type = "String"
+ }
+ column "gad_source_name" {
+ type = "String"
+ }
+ column "computed_at" {
+ type = "DateTime64(6, 'UTC')"
+ default = "now()"
+ }
+ column "expires_at" {
+ type = "Date"
+ default = "today() + toIntervalDay(7)"
+ }
+ engine "replicated_replacing_merge_tree" {
+ zoo_path = "/clickhouse/tables/noshard/posthog.marketing_conversions_preaggregated"
+ replica_name = "{replica}-{shard}"
+ version_column = "computed_at"
+ }
+ }
+
+ table "sharded_marketing_costs_preaggregated" {
+ order_by = ["team_id", "job_id", "source_name", "grain", "campaign_id", "ad_group_id", "ad_id", "cost_date"]
+ partition_by = "toYYYYMMDD(expires_at)"
+ ttl = "expires_at"
+ settings = {
+ index_granularity = "8192"
+ ttl_only_drop_parts = "1"
+ }
+ column "team_id" {
+ type = "Int64"
+ }
+ column "job_id" {
+ type = "UUID"
+ }
+ column "source_id" {
+ type = "String"
+ }
+ column "source_name" {
+ type = "String"
+ }
+ column "grain" {
+ type = "LowCardinality(String)"
+ }
+ column "match_key" {
+ type = "String"
+ }
+ column "campaign_id" {
+ type = "String"
+ }
+ column "campaign_name" {
+ type = "String"
+ }
+ column "ad_group_id" {
+ type = "String"
+ }
+ column "ad_group_name" {
+ type = "String"
+ }
+ column "ad_id" {
+ type = "String"
+ }
+ column "ad_name" {
+ type = "String"
+ }
+ column "cost_date" {
+ type = "Date"
+ }
+ column "cost" {
+ type = "Float64"
+ }
+ column "clicks" {
+ type = "Float64"
+ }
+ column "impressions" {
+ type = "Float64"
+ }
+ column "reported_conversions" {
+ type = "Float64"
+ }
+ column "reported_conversion_value" {
+ type = "Float64"
+ }
+ column "computed_at" {
+ type = "DateTime64(6, 'UTC')"
+ default = "now()"
+ }
+ column "expires_at" {
+ type = "Date"
+ default = "today() + toIntervalDay(7)"
+ }
+ engine "replicated_replacing_merge_tree" {
+ zoo_path = "/clickhouse/tables/noshard/posthog.marketing_costs_preaggregated"
+ replica_name = "{replica}-{shard}"
+ version_column = "computed_at"
+ }
+ }
+
+ table "sharded_marketing_touchpoints_preaggregated" {
+ order_by = ["team_id", "job_id", "person_id", "touchpoint_timestamp"]
+ partition_by = "toYYYYMMDD(expires_at)"
+ ttl = "expires_at"
+ settings = {
+ index_granularity = "8192"
+ ttl_only_drop_parts = "1"
+ }
+ column "team_id" {
+ type = "Int64"
+ }
+ column "job_id" {
+ type = "UUID"
+ }
+ column "person_id" {
+ type = "UUID"
+ }
+ column "touchpoint_timestamp" {
+ type = "DateTime64(6, 'UTC')"
+ }
+ column "campaign_name" {
+ type = "String"
+ }
+ column "source_name" {
+ type = "String"
+ }
+ column "medium_name" {
+ type = "String"
+ }
+ column "content_name" {
+ type = "String"
+ }
+ column "term_name" {
+ type = "String"
+ }
+ column "referring_domain_name" {
+ type = "String"
+ }
+ column "gclid_name" {
+ type = "String"
+ }
+ column "fbclid_name" {
+ type = "String"
+ }
+ column "gad_source_name" {
+ type = "String"
+ }
+ column "computed_at" {
+ type = "DateTime64(6, 'UTC')"
+ default = "now()"
+ }
+ column "expires_at" {
+ type = "Date"
+ default = "today() + toIntervalDay(7)"
+ }
+ engine "replicated_replacing_merge_tree" {
+ zoo_path = "/clickhouse/tables/noshard/posthog.marketing_touchpoints_preaggregated"
+ replica_name = "{replica}-{shard}"
+ version_column = "computed_at"
+ }
+ }
+
+ table "sharded_session_replay_features" {
+ order_by = ["team_id", "session_id"]
+ partition_by = "toYYYYMM(min_first_timestamp)"
+ settings = {
+ index_granularity = "512"
+ }
+ column "session_id" {
+ type = "String"
+ }
+ column "team_id" {
+ type = "Int64"
+ }
+ column "distinct_id" {
+ type = "String"
+ }
+ column "min_first_timestamp" {
+ type = "SimpleAggregateFunction(min, DateTime64(6, 'UTC'))"
+ }
+ column "max_last_timestamp" {
+ type = "SimpleAggregateFunction(max, DateTime64(6, 'UTC'))"
+ }
+ column "event_count" {
+ type = "SimpleAggregateFunction(sum, Int64)"
+ }
+ column "mouse_position_count" {
+ type = "SimpleAggregateFunction(sum, Int64)"
+ }
+ column "mouse_sum_x" {
+ type = "SimpleAggregateFunction(sum, Float64)"
+ }
+ column "mouse_sum_x_squared" {
+ type = "SimpleAggregateFunction(sum, Float64)"
+ }
+ column "mouse_sum_y" {
+ type = "SimpleAggregateFunction(sum, Float64)"
+ }
+ column "mouse_sum_y_squared" {
+ type = "SimpleAggregateFunction(sum, Float64)"
+ }
+ column "mouse_distance_traveled" {
+ type = "SimpleAggregateFunction(sum, Float64)"
+ }
+ column "mouse_direction_change_count" {
+ type = "SimpleAggregateFunction(sum, Int64)"
+ }
+ column "mouse_velocity_sum" {
+ type = "SimpleAggregateFunction(sum, Float64)"
+ }
+ column "mouse_velocity_sum_of_squares" {
+ type = "SimpleAggregateFunction(sum, Float64)"
+ }
+ column "mouse_velocity_count" {
+ type = "SimpleAggregateFunction(sum, Int64)"
+ }
+ column "scroll_event_count" {
+ type = "SimpleAggregateFunction(sum, Int64)"
+ }
+ column "total_scroll_magnitude" {
+ type = "SimpleAggregateFunction(sum, Float64)"
+ }
+ column "scroll_direction_reversal_count" {
+ type = "SimpleAggregateFunction(sum, Int64)"
+ }
+ column "rapid_scroll_reversal_count" {
+ type = "SimpleAggregateFunction(sum, Int64)"
+ }
+ column "scroll_to_top_count" {
+ type = "SimpleAggregateFunction(sum, Int64)"
+ }
+ column "click_count" {
+ type = "SimpleAggregateFunction(sum, Int64)"
+ }
+ column "keypress_count" {
+ type = "SimpleAggregateFunction(sum, Int64)"
+ }
+ column "mouse_activity_count" {
+ type = "SimpleAggregateFunction(sum, Int64)"
+ }
+ column "rage_click_count" {
+ type = "SimpleAggregateFunction(sum, Int64)"
+ }
+ column "dead_click_count" {
+ type = "SimpleAggregateFunction(sum, Int64)"
+ }
+ column "backspace_count" {
+ type = "SimpleAggregateFunction(sum, Int64)"
+ }
+ column "inter_action_gap_count" {
+ type = "SimpleAggregateFunction(sum, Int64)"
+ }
+ column "inter_action_gap_sum_ms" {
+ type = "SimpleAggregateFunction(sum, Float64)"
+ }
+ column "inter_action_gap_sum_of_squares_ms" {
+ type = "SimpleAggregateFunction(sum, Float64)"
+ }
+ column "max_idle_gap_ms" {
+ type = "SimpleAggregateFunction(max, Float64)"
+ }
+ column "long_idle_gap_count" {
+ type = "SimpleAggregateFunction(sum, Int64)"
+ }
+ column "quick_back_count" {
+ type = "SimpleAggregateFunction(sum, Int64)"
+ }
+ column "page_visit_count" {
+ type = "SimpleAggregateFunction(sum, Int64)"
+ }
+ column "unique_url_count" {
+ type = "AggregateFunction(uniqCombined(12), String)"
+ }
+ column "login_path_visit_count" {
+ type = "SimpleAggregateFunction(sum, Int64)"
+ }
+ column "signup_path_visit_count" {
+ type = "SimpleAggregateFunction(sum, Int64)"
+ }
+ column "checkout_path_visit_count" {
+ type = "SimpleAggregateFunction(sum, Int64)"
+ }
+ column "cart_path_visit_count" {
+ type = "SimpleAggregateFunction(sum, Int64)"
+ }
+ column "billing_path_visit_count" {
+ type = "SimpleAggregateFunction(sum, Int64)"
+ }
+ column "settings_path_visit_count" {
+ type = "SimpleAggregateFunction(sum, Int64)"
+ }
+ column "account_path_visit_count" {
+ type = "SimpleAggregateFunction(sum, Int64)"
+ }
+ column "error_path_visit_count" {
+ type = "SimpleAggregateFunction(sum, Int64)"
+ }
+ column "not_found_path_visit_count" {
+ type = "SimpleAggregateFunction(sum, Int64)"
+ }
+ column "admin_path_visit_count" {
+ type = "SimpleAggregateFunction(sum, Int64)"
+ }
+ column "dashboard_path_visit_count" {
+ type = "SimpleAggregateFunction(sum, Int64)"
+ }
+ column "onboarding_path_visit_count" {
+ type = "SimpleAggregateFunction(sum, Int64)"
+ }
+ column "cancel_path_visit_count" {
+ type = "SimpleAggregateFunction(sum, Int64)"
+ }
+ column "refund_path_visit_count" {
+ type = "SimpleAggregateFunction(sum, Int64)"
+ }
+ column "console_error_count" {
+ type = "SimpleAggregateFunction(sum, Int64)"
+ }
+ column "console_error_after_click_count" {
+ type = "SimpleAggregateFunction(sum, Int64)"
+ }
+ column "console_warn_count" {
+ type = "SimpleAggregateFunction(sum, Int64)"
+ }
+ column "network_request_count" {
+ type = "SimpleAggregateFunction(sum, Int64)"
+ }
+ column "network_failed_request_count" {
+ type = "SimpleAggregateFunction(sum, Int64)"
+ }
+ column "network_4xx_count" {
+ type = "SimpleAggregateFunction(sum, Int64)"
+ }
+ column "network_5xx_count" {
+ type = "SimpleAggregateFunction(sum, Int64)"
+ }
+ column "network_request_duration_sum" {
+ type = "SimpleAggregateFunction(sum, Float64)"
+ }
+ column "network_request_duration_sum_of_squares" {
+ type = "SimpleAggregateFunction(sum, Float64)"
+ }
+ column "network_request_duration_count" {
+ type = "SimpleAggregateFunction(sum, Int64)"
+ }
+ column "mutation_count" {
+ type = "SimpleAggregateFunction(sum, Int64)"
+ }
+ column "viewport_resize_count" {
+ type = "SimpleAggregateFunction(sum, Int64)"
+ }
+ column "touch_event_count" {
+ type = "SimpleAggregateFunction(sum, Int64)"
+ }
+ column "max_scroll_y" {
+ type = "SimpleAggregateFunction(max, Float64)"
+ }
+ column "unique_click_target_count" {
+ type = "AggregateFunction(uniqCombined(12), Int64)"
+ }
+ column "unique_form_field_count" {
+ type = "AggregateFunction(uniqCombined(12), Int64)"
+ }
+ column "text_selection_count" {
+ type = "SimpleAggregateFunction(sum, Int64)"
+ }
+ column "selection_copy_count" {
+ type = "SimpleAggregateFunction(sum, Int64)"
+ }
+ column "is_deleted" {
+ type = "SimpleAggregateFunction(max, UInt8)"
+ default = "0"
+ }
+ engine "replicated_aggregating_merge_tree" {
+ zoo_path = "/clickhouse/tables/{shard}/posthog.session_replay_features"
+ replica_name = "{replica}"
+ }
+ }
+
+ table "sharded_usage_report_events_preagg" {
+ order_by = ["date", "team_id", "person_mode", "lib", "event"]
+ partition_by = "date"
+ ttl = "date + toIntervalDay(14)"
+ settings = {
+ index_granularity = "8192"
+ ttl_only_drop_parts = "1"
+ }
+ column "date" {
+ type = "Date"
+ }
+ column "team_id" {
+ type = "Int64"
+ }
+ column "person_mode" {
+ type = "LowCardinality(String)"
+ }
+ column "lib" {
+ type = "LowCardinality(String)"
+ }
+ column "event" {
+ type = "String"
+ }
+ column "distinct_events_unique" {
+ type = "AggregateFunction(uniqExact, Tuple(UInt64, UInt64, UInt64))"
+ }
+ column "event_count" {
+ type = "AggregateFunction(sum, UInt64)"
+ }
+ engine "replicated_aggregating_merge_tree" {
+ zoo_path = "/clickhouse/tables/{shard}/posthog.sharded_usage_report_events_preagg"
+ replica_name = "{replica}"
+ }
+ }
+
+ table "sharded_web_bot_definition" {
+ order_by = ["id"]
+ settings = {
+ index_granularity = "8192"
+ }
+ column "id" {
+ type = "UInt64"
+ }
+ column "parent_id" {
+ type = "UInt64"
+ }
+ column "regexp" {
+ type = "String"
+ }
+ column "keys" {
+ type = "Array(String)"
+ }
+ column "values" {
+ type = "Array(String)"
+ }
+ engine "replicated_merge_tree" {
+ zoo_path = "/clickhouse/tables/{shard}/posthog.sharded_web_bot_definition"
+ replica_name = "{replica}"
+ }
+ }
+
+ table "sharded_web_bounces_dimensional_preaggregated" {
+ order_by = ["team_id", "job_id", "period_bucket", "host", "device_type", "entry_pathname", "end_pathname", "browser", "os", "viewport_width", "viewport_height", "referring_domain", "utm_source", "utm_medium", "utm_campaign", "utm_term", "utm_content", "country_code", "city_name", "region_code", "region_name", "has_gclid", "has_gad_source_paid_search", "has_fbclid", "mat_metadata_backend", "mat_metadata_loggedIn"]
+ partition_by = "toYYYYMMDD(expires_at)"
+ ttl = "toDateTime(expires_at)"
+ settings = {
+ allow_nullable_key = "1"
+ index_granularity = "8192"
+ ttl_only_drop_parts = "1"
+ }
+ column "team_id" {
+ type = "Int64"
+ }
+ column "job_id" {
+ type = "UUID"
+ }
+ column "period_bucket" {
+ type = "DateTime"
+ }
+ column "host" {
+ type = "String"
+ }
+ column "device_type" {
+ type = "String"
+ }
+ column "entry_pathname" {
+ type = "String"
+ }
+ column "end_pathname" {
+ type = "String"
+ }
+ column "browser" {
+ type = "String"
+ }
+ column "os" {
+ type = "String"
+ }
+ column "viewport_width" {
+ type = "Int64"
+ }
+ column "viewport_height" {
+ type = "Int64"
+ }
+ column "referring_domain" {
+ type = "String"
+ }
+ column "utm_source" {
+ type = "String"
+ }
+ column "utm_medium" {
+ type = "String"
+ }
+ column "utm_campaign" {
+ type = "String"
+ }
+ column "utm_term" {
+ type = "String"
+ }
+ column "utm_content" {
+ type = "String"
+ }
+ column "country_code" {
+ type = "String"
+ }
+ column "city_name" {
+ type = "String"
+ }
+ column "region_code" {
+ type = "String"
+ }
+ column "region_name" {
+ type = "String"
+ }
+ column "has_gclid" {
+ type = "Bool"
+ }
+ column "has_gad_source_paid_search" {
+ type = "Bool"
+ }
+ column "has_fbclid" {
+ type = "Bool"
+ }
+ column "mat_metadata_backend" {
+ type = "Nullable(String)"
+ }
+ column "mat_metadata_loggedIn" {
+ type = "Nullable(Bool)"
+ }
+ column "persons_uniq_state" {
+ type = "AggregateFunction(uniq, UUID)"
+ }
+ column "sessions_uniq_state" {
+ type = "AggregateFunction(uniq, String)"
+ }
+ column "pageviews_count_state" {
+ type = "AggregateFunction(sum, Int64)"
+ }
+ column "bounces_count_state" {
+ type = "AggregateFunction(sum, Int64)"
+ }
+ column "total_session_duration_state" {
+ type = "AggregateFunction(sum, Int64)"
+ }
+ column "total_session_count_state" {
+ type = "AggregateFunction(sum, Int64)"
+ }
+ column "computed_at" {
+ type = "DateTime64(6, 'UTC')"
+ default = "now()"
+ }
+ column "expires_at" {
+ type = "DateTime64(6, 'UTC')"
+ default = "now() + toIntervalDay(7)"
+ }
+ engine "replicated_replacing_merge_tree" {
+ zoo_path = "/clickhouse/tables/{shard}/posthog.web_bounces_dimensional_preaggregated"
+ replica_name = "{replica}"
+ version_column = "computed_at"
+ }
+ }
+
+ table "sharded_web_goals_preaggregated" {
+ order_by = ["team_id", "job_id", "action_id", "time_window_start"]
+ partition_by = "toYYYYMMDD(expires_at)"
+ ttl = "toDateTime(expires_at)"
+ settings = {
+ index_granularity = "8192"
+ ttl_only_drop_parts = "1"
+ }
+ column "team_id" {
+ type = "Int64"
+ }
+ column "job_id" {
+ type = "UUID"
+ }
+ column "time_window_start" {
+ type = "DateTime64(6, 'UTC')"
+ }
+ column "action_id" {
+ type = "Int64"
+ }
+ column "count_state" {
+ type = "AggregateFunction(sum, Int64)"
+ }
+ column "unique_persons_state" {
+ type = "AggregateFunction(uniq, UUID)"
+ }
+ column "computed_at" {
+ type = "DateTime64(6, 'UTC')"
+ default = "now()"
+ }
+ column "expires_at" {
+ type = "DateTime64(6, 'UTC')"
+ default = "now() + toIntervalDay(7)"
+ }
+ engine "replicated_replacing_merge_tree" {
+ zoo_path = "/clickhouse/tables/{shard}/posthog.web_goals_preaggregated"
+ replica_name = "{replica}"
+ version_column = "computed_at"
+ }
+ }
+
+ table "sharded_web_overview_preaggregated" {
+ order_by = ["team_id", "job_id", "time_window_start"]
+ partition_by = "toYYYYMMDD(expires_at)"
+ ttl = "toDateTime(expires_at)"
+ settings = {
+ index_granularity = "8192"
+ ttl_only_drop_parts = "1"
+ }
+ column "team_id" {
+ type = "Int64"
+ }
+ column "job_id" {
+ type = "UUID"
+ }
+ column "time_window_start" {
+ type = "DateTime64(6, 'UTC')"
+ }
+ column "uniq_users_state" {
+ type = "AggregateFunction(uniq, UUID)"
+ }
+ column "uniq_sessions_state" {
+ type = "AggregateFunction(uniq, String)"
+ }
+ column "sum_pageviews_state" {
+ type = "AggregateFunction(sum, Int64)"
+ }
+ column "avg_duration_state" {
+ type = "AggregateFunction(avg, Float64)"
+ }
+ column "avg_bounce_state" {
+ type = "AggregateFunction(avg, Int64)"
+ }
+ column "computed_at" {
+ type = "DateTime64(6, 'UTC')"
+ default = "now()"
+ }
+ column "expires_at" {
+ type = "DateTime64(6, 'UTC')"
+ default = "now() + toIntervalDay(7)"
+ }
+ engine "replicated_replacing_merge_tree" {
+ zoo_path = "/clickhouse/tables/{shard}/posthog.web_overview_preaggregated"
+ replica_name = "{replica}"
+ version_column = "computed_at"
+ }
+ }
+
+ table "sharded_web_stats_dimensional_preaggregated" {
+ order_by = ["team_id", "job_id", "period_bucket", "host", "device_type", "pathname", "entry_pathname", "end_pathname", "browser", "os", "viewport_width", "viewport_height", "referring_domain", "utm_source", "utm_medium", "utm_campaign", "utm_term", "utm_content", "country_code", "city_name", "region_code", "region_name", "has_gclid", "has_gad_source_paid_search", "has_fbclid", "mat_metadata_backend", "mat_metadata_loggedIn"]
+ partition_by = "toYYYYMMDD(expires_at)"
+ ttl = "toDateTime(expires_at)"
+ settings = {
+ allow_nullable_key = "1"
+ index_granularity = "8192"
+ ttl_only_drop_parts = "1"
+ }
+ column "team_id" {
+ type = "Int64"
+ }
+ column "job_id" {
+ type = "UUID"
+ }
+ column "period_bucket" {
+ type = "DateTime"
+ }
+ column "host" {
+ type = "String"
+ }
+ column "device_type" {
+ type = "String"
+ }
+ column "pathname" {
+ type = "String"
+ }
+ column "entry_pathname" {
+ type = "String"
+ }
+ column "end_pathname" {
+ type = "String"
+ }
+ column "browser" {
+ type = "String"
+ }
+ column "os" {
+ type = "String"
+ }
+ column "viewport_width" {
+ type = "Int64"
+ }
+ column "viewport_height" {
+ type = "Int64"
+ }
+ column "referring_domain" {
+ type = "String"
+ }
+ column "utm_source" {
+ type = "String"
+ }
+ column "utm_medium" {
+ type = "String"
+ }
+ column "utm_campaign" {
+ type = "String"
+ }
+ column "utm_term" {
+ type = "String"
+ }
+ column "utm_content" {
+ type = "String"
+ }
+ column "country_code" {
+ type = "String"
+ }
+ column "city_name" {
+ type = "String"
+ }
+ column "region_code" {
+ type = "String"
+ }
+ column "region_name" {
+ type = "String"
+ }
+ column "has_gclid" {
+ type = "Bool"
+ }
+ column "has_gad_source_paid_search" {
+ type = "Bool"
+ }
+ column "has_fbclid" {
+ type = "Bool"
+ }
+ column "mat_metadata_backend" {
+ type = "Nullable(String)"
+ }
+ column "mat_metadata_loggedIn" {
+ type = "Nullable(Bool)"
+ }
+ column "persons_uniq_state" {
+ type = "AggregateFunction(uniq, UUID)"
+ }
+ column "sessions_uniq_state" {
+ type = "AggregateFunction(uniq, String)"
+ }
+ column "pageviews_count_state" {
+ type = "AggregateFunction(sum, Int64)"
+ }
+ column "computed_at" {
+ type = "DateTime64(6, 'UTC')"
+ default = "now()"
+ }
+ column "expires_at" {
+ type = "DateTime64(6, 'UTC')"
+ default = "now() + toIntervalDay(7)"
+ }
+ engine "replicated_replacing_merge_tree" {
+ zoo_path = "/clickhouse/tables/{shard}/posthog.web_stats_dimensional_preaggregated"
+ replica_name = "{replica}"
+ version_column = "computed_at"
+ }
+ }
+
+ table "sharded_web_stats_frustration_preaggregated" {
+ order_by = ["team_id", "job_id", "breakdown_value", "time_window_start"]
+ partition_by = "toYYYYMMDD(expires_at)"
+ ttl = "toDateTime(expires_at)"
+ settings = {
+ index_granularity = "8192"
+ ttl_only_drop_parts = "1"
+ }
+ column "team_id" {
+ type = "Int64"
+ }
+ column "job_id" {
+ type = "UUID"
+ }
+ column "time_window_start" {
+ type = "DateTime64(6, 'UTC')"
+ }
+ column "breakdown_value" {
+ type = "String"
+ }
+ column "sum_rage_clicks_state" {
+ type = "AggregateFunction(sum, Int64)"
+ }
+ column "sum_dead_clicks_state" {
+ type = "AggregateFunction(sum, Int64)"
+ }
+ column "sum_errors_state" {
+ type = "AggregateFunction(sum, Int64)"
+ }
+ column "computed_at" {
+ type = "DateTime64(6, 'UTC')"
+ default = "now()"
+ }
+ column "expires_at" {
+ type = "DateTime64(6, 'UTC')"
+ default = "now() + toIntervalDay(7)"
+ }
+ engine "replicated_replacing_merge_tree" {
+ zoo_path = "/clickhouse/tables/{shard}/posthog.web_stats_frustration_preaggregated"
+ replica_name = "{replica}"
+ version_column = "computed_at"
+ }
+ }
+
+ table "sharded_web_stats_paths_preaggregated" {
+ order_by = ["team_id", "job_id", "breakdown_value", "time_window_start"]
+ partition_by = "toYYYYMMDD(expires_at)"
+ ttl = "toDateTime(expires_at)"
+ settings = {
+ index_granularity = "8192"
+ ttl_only_drop_parts = "1"
+ }
+ column "team_id" {
+ type = "Int64"
+ }
+ column "job_id" {
+ type = "UUID"
+ }
+ column "time_window_start" {
+ type = "DateTime64(6, 'UTC')"
+ }
+ column "breakdown_value" {
+ type = "String"
+ }
+ column "uniq_users_state" {
+ type = "AggregateFunction(uniq, UUID)"
+ }
+ column "sum_pageviews_state" {
+ type = "AggregateFunction(sum, Int64)"
+ }
+ column "avg_bounce_state" {
+ type = "AggregateFunction(avg, Nullable(Float64))"
+ }
+ column "computed_at" {
+ type = "DateTime64(6, 'UTC')"
+ default = "now()"
+ }
+ column "expires_at" {
+ type = "DateTime64(6, 'UTC')"
+ default = "now() + toIntervalDay(7)"
+ }
+ engine "replicated_replacing_merge_tree" {
+ zoo_path = "/clickhouse/tables/{shard}/posthog.web_stats_paths_preaggregated"
+ replica_name = "{replica}"
+ version_column = "computed_at"
+ }
+ }
+
+ table "sharded_web_stats_paths_preaggregated_pathkey" {
+ order_by = ["team_id", "time_window_start", "breakdown_value", "job_id"]
+ partition_by = "toYYYYMMDD(expires_at)"
+ ttl = "toDateTime(expires_at)"
+ settings = {
+ index_granularity = "8192"
+ ttl_only_drop_parts = "1"
+ }
+ column "team_id" {
+ type = "Int64"
+ }
+ column "job_id" {
+ type = "UUID"
+ }
+ column "time_window_start" {
+ type = "DateTime64(6, 'UTC')"
+ }
+ column "breakdown_value" {
+ type = "String"
+ }
+ column "uniq_users_state" {
+ type = "AggregateFunction(uniq, UUID)"
+ }
+ column "sum_pageviews_state" {
+ type = "AggregateFunction(sum, Int64)"
+ }
+ column "avg_bounce_state" {
+ type = "AggregateFunction(avg, Nullable(Float64))"
+ }
+ column "computed_at" {
+ type = "DateTime64(6, 'UTC')"
+ default = "now()"
+ }
+ column "expires_at" {
+ type = "DateTime64(6, 'UTC')"
+ default = "now() + toIntervalDay(7)"
+ }
+ engine "replicated_replacing_merge_tree" {
+ zoo_path = "/clickhouse/tables/{shard}/posthog.web_stats_paths_preaggregated_pathkey"
+ replica_name = "{replica}"
+ version_column = "computed_at"
+ }
+ }
+
+ table "sharded_web_stats_preaggregated" {
+ order_by = ["team_id", "job_id", "breakdown_by", "time_window_start", "breakdown_value"]
+ partition_by = "toYYYYMMDD(expires_at)"
+ ttl = "toDateTime(expires_at)"
+ settings = {
+ index_granularity = "8192"
+ ttl_only_drop_parts = "1"
+ }
+ column "team_id" {
+ type = "Int64"
+ }
+ column "job_id" {
+ type = "UUID"
+ }
+ column "time_window_start" {
+ type = "DateTime64(6, 'UTC')"
+ }
+ column "breakdown_by" {
+ type = "String"
+ }
+ column "breakdown_value" {
+ type = "String"
+ }
+ column "uniq_users_state" {
+ type = "AggregateFunction(uniq, UUID)"
+ }
+ column "sum_pageviews_state" {
+ type = "AggregateFunction(sum, Int64)"
+ }
+ column "computed_at" {
+ type = "DateTime64(6, 'UTC')"
+ default = "now()"
+ }
+ column "expires_at" {
+ type = "DateTime64(6, 'UTC')"
+ default = "now() + toIntervalDay(7)"
+ }
+ engine "replicated_replacing_merge_tree" {
+ zoo_path = "/clickhouse/tables/{shard}/posthog.web_stats_preaggregated"
+ replica_name = "{replica}"
+ version_column = "computed_at"
+ }
+ }
+
+ table "sharded_web_vitals_paths_preaggregated" {
+ order_by = ["team_id", "job_id", "time_window_start", "path"]
+ partition_by = "toYYYYMMDD(expires_at)"
+ ttl = "toDateTime(expires_at)"
+ settings = {
+ index_granularity = "8192"
+ ttl_only_drop_parts = "1"
+ }
+ column "team_id" {
+ type = "Int64"
+ }
+ column "job_id" {
+ type = "UUID"
+ }
+ column "time_window_start" {
+ type = "DateTime64(6, 'UTC')"
+ }
+ column "path" {
+ type = "String"
+ }
+ column "inp_quantiles_state" {
+ type = "AggregateFunction(quantiles(0.75, 0.9, 0.99), Float64)"
+ }
+ column "lcp_quantiles_state" {
+ type = "AggregateFunction(quantiles(0.75, 0.9, 0.99), Float64)"
+ }
+ column "cls_quantiles_state" {
+ type = "AggregateFunction(quantiles(0.75, 0.9, 0.99), Float64)"
+ }
+ column "fcp_quantiles_state" {
+ type = "AggregateFunction(quantiles(0.75, 0.9, 0.99), Float64)"
+ }
+ column "computed_at" {
+ type = "DateTime64(6, 'UTC')"
+ default = "now()"
+ }
+ column "expires_at" {
+ type = "DateTime64(6, 'UTC')"
+ default = "now() + toIntervalDay(7)"
+ }
+ engine "replicated_replacing_merge_tree" {
+ zoo_path = "/clickhouse/tables/{shard}/posthog.web_vitals_paths_preaggregated"
+ replica_name = "{replica}"
+ version_column = "computed_at"
+ }
+ }
+
+ table "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_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_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_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 "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"
+ }
+ }
+
+ materialized_view "hog_invocation_results_mv" {
+ to_table = "posthog.hog_invocation_results_data"
+ query = <<SQL
+SELECT
+ team_id,
+ function_kind,
+ function_id,
+ invocation_id,
+ parent_run_id,
+ status,
+ attempts,
+ is_retry,
+ scheduled_at,
+ if(
+ first_scheduled_at = toDateTime64('1970-01-01 00:00:00', 6, 'UTC'),
+ scheduled_at,
+ first_scheduled_at
+ ) AS first_scheduled_at,
+ started_at,
+ finished_at,
+ duration_ms,
+ error_kind,
+ error_message,
+ event_uuid,
+ distinct_id,
+ person_id,
+ invocation_globals,
+ version,
+ is_deleted,
+ _timestamp,
+ _offset,
+ _partition
+FROM posthog.kafka_hog_invocation_results
+SQL
+
+ column "team_id" {
+ type = "Int64"
+ }
+ column "function_kind" {
+ type = "LowCardinality(String)"
+ }
+ column "function_id" {
+ type = "String"
+ }
+ column "invocation_id" {
+ type = "String"
+ }
+ column "parent_run_id" {
+ type = "String"
+ }
+ column "status" {
+ type = "LowCardinality(String)"
+ }
+ column "attempts" {
+ type = "UInt8"
+ }
+ column "is_retry" {
+ type = "UInt8"
+ }
+ column "scheduled_at" {
+ type = "DateTime64(6, 'UTC')"
+ }
+ column "first_scheduled_at" {
+ type = "DateTime64(6, 'UTC')"
+ }
+ column "started_at" {
+ type = "Nullable(DateTime64(6, 'UTC'))"
+ }
+ column "finished_at" {
+ type = "Nullable(DateTime64(6, 'UTC'))"
+ }
+ column "duration_ms" {
+ type = "Nullable(UInt32)"
+ }
+ column "error_kind" {
+ type = "LowCardinality(String)"
+ }
+ column "error_message" {
+ type = "String"
+ }
+ column "event_uuid" {
+ type = "String"
+ }
+ column "distinct_id" {
+ type = "String"
+ }
+ column "person_id" {
+ type = "String"
+ }
+ column "invocation_globals" {
+ type = "String"
+ }
+ column "version" {
+ type = "UInt64"
+ }
+ column "is_deleted" {
+ type = "UInt8"
+ }
+ column "_timestamp" {
+ type = "Nullable(DateTime)"
+ }
+ column "_offset" {
+ type = "UInt64"
+ }
+ column "_partition" {
+ type = "UInt64"
+ }
+ }
+
+ materialized_view "message_assets_mv" {
+ to_table = "posthog.message_assets_data"
+ query = <<SQL
+SELECT
+ team_id,
+ function_kind,
+ function_id,
+ parent_run_id,
+ invocation_id,
+ action_id,
+ kind,
+ distinct_id,
+ person_id,
+ recipient,
+ subject,
+ status,
+ sent_at,
+ version,
+ is_deleted,
+ html,
+ _timestamp,
+ _offset,
+ _partition
+FROM posthog.kafka_message_assets
+SQL
+
+ column "team_id" {
+ type = "Int64"
+ }
+ column "function_kind" {
+ type = "LowCardinality(String)"
+ }
+ column "function_id" {
+ type = "String"
+ }
+ column "parent_run_id" {
+ type = "String"
+ }
+ column "invocation_id" {
+ type = "String"
+ }
+ column "action_id" {
+ type = "String"
+ }
+ column "kind" {
+ type = "LowCardinality(String)"
+ }
+ column "distinct_id" {
+ type = "String"
+ }
+ column "person_id" {
+ type = "String"
+ }
+ column "recipient" {
+ type = "String"
+ }
+ column "subject" {
+ type = "String"
+ }
+ column "status" {
+ type = "LowCardinality(String)"
+ }
+ column "sent_at" {
+ type = "DateTime64(6, 'UTC')"
+ }
+ column "version" {
+ type = "UInt64"
+ }
+ column "is_deleted" {
+ type = "UInt8"
+ }
+ column "html" {
+ type = "String"
+ }
+ column "_timestamp" {
+ type = "Nullable(DateTime)"
+ }
+ column "_offset" {
+ type = "UInt64"
+ }
+ column "_partition" {
+ type = "UInt64"
+ }
+ }
+
+ materialized_view "ops_query_log_archive_mv" {
+ to_table = "posthog.writable_query_log_archive"
+ query = <<SQL
+SELECT
+ hostname,
+ user,
+ query_id,
+ initial_query_id,
+ is_initial_query,
+ type,
+ event_date,
+ event_time,
+ event_time_microseconds,
+ query_start_time,
+ query_start_time_microseconds,
+ query_duration_ms,
+ read_rows,
+ read_bytes,
+ written_rows,
+ written_bytes,
+ result_rows,
+ result_bytes,
+ memory_usage,
+ peak_threads_usage,
+ current_database,
+ query,
+ formatted_query,
+ normalized_query_hash,
+ query_kind,
+ exception_code,
+ exception,
+ stack_trace,
+ JSONExtractInt(log_comment, 'team_id') AS team_id,
+ if(isValidJSON(log_comment), log_comment, '{}') AS log_comment,
+ ProfileEvents
+FROM system.query_log
+WHERE type != 'QueryStart'
+SQL
+
+ column "hostname" {
+ type = "LowCardinality(String)"
+ }
+ column "user" {
+ type = "LowCardinality(String)"
+ }
+ column "query_id" {
+ type = "String"
+ }
+ column "initial_query_id" {
+ type = "String"
+ }
+ column "is_initial_query" {
+ type = "UInt8"
+ }
+ column "type" {
+ type = "Enum8('QueryStart'=1, 'QueryFinish'=2, 'ExceptionBeforeStart'=3, 'ExceptionWhileProcessing'=4)"
+ }
+ column "event_date" {
+ type = "Date"
+ }
+ column "event_time" {
+ type = "DateTime"
+ }
+ column "event_time_microseconds" {
+ type = "DateTime64(6)"
+ }
+ column "query_start_time" {
+ type = "DateTime"
+ }
+ column "query_start_time_microseconds" {
+ type = "DateTime64(6)"
+ }
+ column "query_duration_ms" {
+ type = "UInt64"
+ }
+ column "read_rows" {
+ type = "UInt64"
+ }
+ column "read_bytes" {
+ type = "UInt64"
+ }
+ column "written_rows" {
+ type = "UInt64"
+ }
+ column "written_bytes" {
+ type = "UInt64"
+ }
+ column "result_rows" {
+ type = "UInt64"
+ }
+ column "result_bytes" {
+ type = "UInt64"
+ }
+ column "memory_usage" {
+ type = "UInt64"
+ }
+ column "peak_threads_usage" {
+ type = "UInt64"
+ }
+ column "current_database" {
+ type = "LowCardinality(String)"
+ }
+ column "query" {
+ type = "String"
+ }
+ column "formatted_query" {
+ type = "String"
+ }
+ column "normalized_query_hash" {
+ type = "UInt64"
+ }
+ column "query_kind" {
+ type = "LowCardinality(String)"
+ }
+ column "exception_code" {
+ type = "Int32"
+ }
+ column "exception" {
+ type = "String"
+ }
+ column "stack_trace" {
+ type = "String"
+ }
+ column "team_id" {
+ type = "Int64"
+ }
+ column "log_comment" {
+ type = "String"
+ }
+ column "ProfileEvents" {
+ type = "Map(LowCardinality(String), UInt64)"
+ }
+ }
+
+ materialized_view "property_values_mv" {
+ to_table = "posthog.property_values"
+ query = <<SQL
+SELECT
+ team_id,
+ property_type,
+ property_key,
+ property_value,
+ property_count,
+ coalesce(_timestamp, now()) AS last_seen
+FROM posthog.kafka_property_values
+SQL
+
+ column "team_id" {
+ type = "Int64"
+ }
+ column "property_type" {
+ type = "LowCardinality(String)"
+ }
+ column "property_key" {
+ type = "String"
+ }
+ column "property_value" {
+ type = "String"
+ }
+ column "property_count" {
+ type = "UInt64"
+ }
+ column "last_seen" {
+ type = "DateTime"
+ }
+ }
+
+ 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
+
+ }
+
+ 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" {
+ }
+ }
+}
diff --git a/posthog/clickhouse/hcl/golden/prod-us-sessions.hcl b/posthog/clickhouse/hcl/golden/prod-us-sessions.hcl
new file mode 100644
index 000000000000..b11da14cb38e
--- /dev/null
+++ b/posthog/clickhouse/hcl/golden/prod-us-sessions.hcl
@@ -0,0 +1,2902 @@
+database "posthog" {
+ table "channel_definition" {
+ order_by = ["domain", "kind"]
+ settings = {
+ default_compression_codec = "lz4"
+ 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/sessions/noshard/posthog.channel_definition"
+ replica_name = "{replica}-{shard}"
+ }
+ }
+
+ table "cohortpeople" {
+ column "person_id" {
+ type = "UUID"
+ }
+ column "cohort_id" {
+ type = "Int64"
+ }
+ column "team_id" {
+ type = "Int64"
+ }
+ column "sign" {
+ type = "Int8"
+ }
+ column "version" {
+ type = "UInt64"
+ }
+ engine "distributed" {
+ cluster_name = "posthog_single_shard"
+ remote_database = "posthog"
+ remote_table = "cohortpeople"
+ sharding_key = "rand()"
+ }
+ }
+
+ table "events" {
+ 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_hash" {
+ type = "String"
+ }
+ column "created_at" {
+ type = "DateTime64(6, 'UTC')"
+ }
+ column "_timestamp" {
+ type = "DateTime"
+ }
+ column "_offset" {
+ type = "UInt64"
+ }
+ column "elements_chain" {
+ type = "String"
+ }
+ column "mat_$user_id" {
+ type = "String"
+ comment = "column_materializer::$user_id"
+ }
+ column "mat_$browser" {
+ type = "String"
+ comment = "column_materializer::$browser"
+ }
+ column "mat_$host" {
+ type = "String"
+ comment = "column_materializer::$host"
+ }
+ column "mat_$current_url" {
+ type = "String"
+ comment = "column_materializer::$current_url"
+ }
+ column "mat_distinct_id" {
+ type = "String"
+ comment = "column_materializer::distinct_id"
+ }
+ column "mat_action" {
+ type = "String"
+ comment = "column_materializer::action"
+ }
+ column "mat_origin" {
+ type = "String"
+ comment = "column_materializer::origin"
+ }
+ column "mat_email" {
+ type = "String"
+ comment = "column_materializer::email"
+ }
+ column "mat_key" {
+ type = "String"
+ comment = "column_materializer::key"
+ }
+ column "mat_insight" {
+ type = "String"
+ comment = "column_materializer::insight"
+ }
+ column "mat_$event_type" {
+ type = "String"
+ comment = "column_materializer::$event_type"
+ }
+ column "mat_created_by" {
+ type = "String"
+ comment = "column_materializer::created_by"
+ }
+ column "mat_total_event_actions_count" {
+ type = "String"
+ comment = "column_materializer::total_event_actions_count"
+ }
+ column "mat_is_demo_project" {
+ type = "String"
+ comment = "column_materializer::is_demo_project"
+ }
+ column "mat_$active_feature_flags" {
+ type = "String"
+ comment = "column_materializer::$active_feature_flags"
+ }
+ column "mat_filters_count" {
+ type = "String"
+ comment = "column_materializer::filters_count"
+ }
+ column "mat_utm_source" {
+ type = "String"
+ comment = "column_materializer::utm_source"
+ }
+ column "mat_apiErrorMessage" {
+ type = "String"
+ comment = "column_materializer::apiErrorMessage"
+ }
+ column "mat_$referring_domain" {
+ type = "String"
+ comment = "column_materializer::$referring_domain"
+ }
+ column "mat_statusCode" {
+ type = "String"
+ comment = "column_materializer::statusCode"
+ }
+ column "mat_deal_id" {
+ type = "String"
+ comment = "column_materializer::deal_id"
+ }
+ column "mat_realm" {
+ type = "String"
+ comment = "column_materializer::realm"
+ }
+ 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 "mat_$lib" {
+ type = "String"
+ comment = "column_materializer::$lib"
+ }
+ column "mat_$os" {
+ type = "String"
+ comment = "column_materializer::$os"
+ }
+ column "mat_$initial_referrer" {
+ type = "String"
+ comment = "column_materializer::$initial_referrer"
+ }
+ column "mat_$app_version" {
+ type = "String"
+ comment = "column_materializer::$app_version"
+ }
+ column "mat_$initial_referring_domain" {
+ type = "String"
+ comment = "column_materializer::$initial_referring_domain"
+ }
+ column "mat_symbol" {
+ type = "String"
+ comment = "column_materializer::symbol"
+ }
+ column "mat_page" {
+ type = "String"
+ comment = "column_materializer::page"
+ }
+ column "mat_type" {
+ type = "String"
+ comment = "column_materializer::type"
+ }
+ column "mat_currentScreen" {
+ type = "String"
+ comment = "column_materializer::currentScreen"
+ }
+ column "mat_utm_campaign" {
+ type = "String"
+ comment = "column_materializer::utm_campaign"
+ }
+ column "mat_is_organization_first_user" {
+ type = "String"
+ comment = "column_materializer::is_organization_first_user"
+ }
+ column "mat_is_first_component_load" {
+ type = "String"
+ comment = "column_materializer::is_first_component_load"
+ }
+ column "mat_team" {
+ type = "String"
+ comment = "column_materializer::team"
+ }
+ column "mat_context" {
+ type = "String"
+ comment = "column_materializer::context"
+ }
+ column "mat_sdk" {
+ type = "String"
+ comment = "column_materializer::sdk"
+ }
+ column "mat_created_by_system" {
+ type = "String"
+ comment = "column_materializer::created_by_system"
+ }
+ column "mat_item_count" {
+ type = "String"
+ comment = "column_materializer::item_count"
+ }
+ column "mat_$ip" {
+ type = "String"
+ comment = "column_materializer::$ip"
+ }
+ column "mat_$referrer" {
+ type = "String"
+ comment = "column_materializer::$referrer"
+ }
+ column "mat_action_name" {
+ type = "String"
+ comment = "column_materializer::action_name"
+ }
+ column "mat_$geoip_country_name" {
+ type = "String"
+ comment = "column_materializer::$geoip_country_name"
+ }
+ column "mat_$device_model" {
+ type = "String"
+ comment = "column_materializer::$device_model"
+ }
+ column "mat_progress" {
+ type = "String"
+ comment = "column_materializer::progress"
+ }
+ column "mat_chain" {
+ type = "String"
+ comment = "column_materializer::chain"
+ }
+ column "mat_$device_type" {
+ type = "String"
+ comment = "column_materializer::$device_type"
+ }
+ column "mat_usd" {
+ type = "String"
+ comment = "column_materializer::usd"
+ }
+ column "mat_app_name" {
+ type = "String"
+ comment = "column_materializer::app_name"
+ }
+ column "mat_$screen_name" {
+ type = "String"
+ comment = "column_materializer::$screen_name"
+ }
+ column "mat_index" {
+ type = "String"
+ comment = "column_materializer::index"
+ }
+ column "mat_token" {
+ type = "String"
+ comment = "column_materializer::token"
+ }
+ column "mat_method" {
+ type = "String"
+ comment = "column_materializer::method"
+ }
+ column "mat_address" {
+ type = "String"
+ comment = "column_materializer::address"
+ }
+ column "mat_name" {
+ type = "String"
+ comment = "column_materializer::name"
+ }
+ column "mat_inviteCode" {
+ type = "String"
+ comment = "column_materializer::inviteCode"
+ }
+ column "$window_id" {
+ type = "String"
+ comment = "column_materializer::$window_id"
+ }
+ column "$session_id" {
+ type = "String"
+ comment = "column_materializer::$session_id"
+ }
+ column "mat_osName" {
+ type = "String"
+ comment = "column_materializer::osName"
+ }
+ column "mat_nativeBuildVersion" {
+ type = "String"
+ comment = "column_materializer::nativeBuildVersion"
+ }
+ column "mat_revenue" {
+ type = "String"
+ comment = "column_materializer::revenue"
+ }
+ column "group_0" {
+ type = "String"
+ alias = "`$group_0`"
+ }
+ column "group_1" {
+ type = "String"
+ alias = "`$group_1`"
+ }
+ column "group_2" {
+ type = "String"
+ alias = "`$group_2`"
+ }
+ column "group_3" {
+ type = "String"
+ alias = "`$group_3`"
+ }
+ column "group_4" {
+ type = "String"
+ alias = "`$group_4`"
+ }
+ column "alias_mat__user_id" {
+ type = "String"
+ alias = "`mat_$user_id`"
+ }
+ column "alias_mat__browser" {
+ type = "String"
+ alias = "`mat_$browser`"
+ }
+ column "alias_mat__host" {
+ type = "String"
+ alias = "`mat_$host`"
+ }
+ column "alias_mat__current_url" {
+ type = "String"
+ alias = "`mat_$current_url`"
+ }
+ column "alias_mat__event_type" {
+ type = "String"
+ alias = "`mat_$event_type`"
+ }
+ column "alias_mat__active_feature_flags" {
+ type = "String"
+ alias = "`mat_$active_feature_flags`"
+ }
+ column "alias_mat__referring_domain" {
+ type = "String"
+ alias = "`mat_$referring_domain`"
+ }
+ column "alias_mat__lib" {
+ type = "String"
+ alias = "`mat_$lib`"
+ }
+ column "alias_mat__os" {
+ type = "String"
+ alias = "`mat_$os`"
+ }
+ column "alias_mat__initial_referrer" {
+ type = "String"
+ alias = "`mat_$initial_referrer`"
+ }
+ column "alias_mat__app_version" {
+ type = "String"
+ alias = "`mat_$app_version`"
+ }
+ column "alias_mat__initial_referring_domain" {
+ type = "String"
+ alias = "`mat_$initial_referring_domain`"
+ }
+ column "alias_mat__ip" {
+ type = "String"
+ alias = "`mat_$ip`"
+ }
+ column "alias_mat__referrer" {
+ type = "String"
+ alias = "`mat_$referrer`"
+ }
+ column "alias_mat__geoip_country_name" {
+ type = "String"
+ alias = "`mat_$geoip_country_name`"
+ }
+ column "alias_mat__device_model" {
+ type = "String"
+ alias = "`mat_$device_model`"
+ }
+ column "alias_mat__device_type" {
+ type = "String"
+ alias = "`mat_$device_type`"
+ }
+ column "alias_mat__screen_name" {
+ type = "String"
+ alias = "`mat_$screen_name`"
+ }
+ column "person_id" {
+ type = "UUID"
+ }
+ column "person_properties" {
+ type = "String"
+ }
+ column "group0_properties" {
+ type = "String"
+ }
+ column "group1_properties" {
+ type = "String"
+ }
+ column "group2_properties" {
+ type = "String"
+ }
+ column "group3_properties" {
+ type = "String"
+ }
+ column "group4_properties" {
+ type = "String"
+ }
+ column "person_created_at" {
+ type = "DateTime64(3)"
+ }
+ column "group0_created_at" {
+ type = "DateTime64(3)"
+ }
+ column "group1_created_at" {
+ type = "DateTime64(3)"
+ }
+ column "group2_created_at" {
+ type = "DateTime64(3)"
+ }
+ column "group3_created_at" {
+ type = "DateTime64(3)"
+ }
+ column "group4_created_at" {
+ type = "DateTime64(3)"
+ }
+ column "mat_arguments" {
+ type = "String"
+ comment = "column_materializer::properties::arguments"
+ }
+ column "mat_source" {
+ type = "String"
+ comment = "column_materializer::properties::source"
+ }
+ column "mat_pp_email" {
+ type = "String"
+ comment = "column_materializer::person_properties::email"
+ }
+ column "mat_$time" {
+ type = "String"
+ comment = "column_materializer::properties::$time"
+ }
+ column "mat_$pathname" {
+ type = "String"
+ comment = "column_materializer::properties::$pathname"
+ }
+ column "mat_$geoip_city_name" {
+ type = "String"
+ comment = "column_materializer::properties::$geoip_city_name"
+ }
+ column "mat_community_id" {
+ type = "String"
+ comment = "column_materializer::properties::community_id"
+ }
+ column "mat_thread_id" {
+ type = "String"
+ comment = "column_materializer::properties::thread_id"
+ }
+ column "mat_Event_productCode" {
+ type = "String"
+ comment = "column_materializer::properties::Event.productCode"
+ }
+ column "mat_env" {
+ type = "String"
+ comment = "column_materializer::properties::env"
+ }
+ column "mat_target" {
+ type = "String"
+ comment = "column_materializer::properties::target"
+ }
+ column "mat_Subscription_plan_amount" {
+ type = "String"
+ comment = "column_materializer::properties::Subscription.plan.amount"
+ }
+ column "mat_title" {
+ type = "String"
+ comment = "column_materializer::properties::title"
+ }
+ column "mat_Connection_app_name" {
+ type = "String"
+ comment = "column_materializer::properties::Connection.app.name"
+ }
+ column "mat_utm_medium" {
+ type = "String"
+ comment = "column_materializer::properties::utm_medium"
+ }
+ column "mat_Account_client_id" {
+ type = "String"
+ comment = "column_materializer::properties::Account.client_id"
+ }
+ column "mat_HTTP_Method" {
+ type = "String"
+ comment = "column_materializer::properties::HTTP Method"
+ }
+ column "mat_audio_duration" {
+ type = "String"
+ comment = "column_materializer::properties::audio_duration"
+ }
+ column "mat_duration" {
+ type = "String"
+ comment = "column_materializer::properties::duration"
+ }
+ column "mat_url" {
+ type = "String"
+ comment = "column_materializer::properties::url"
+ }
+ column "mat_group_id" {
+ type = "String"
+ comment = "column_materializer::properties::group_id"
+ }
+ column "mat_platform" {
+ type = "String"
+ comment = "column_materializer::properties::platform"
+ }
+ column "mat_pp_$browser" {
+ type = "String"
+ comment = "column_materializer::person_properties::$browser"
+ }
+ column "mat_payment_status" {
+ type = "String"
+ comment = "column_materializer::properties::payment_status"
+ }
+ column "mat_testSessionId" {
+ type = "String"
+ comment = "column_materializer::properties::testSessionId"
+ }
+ column "inserted_at" {
+ type = "Nullable(DateTime64(6, 'UTC'))"
+ default = "now64()"
+ }
+ column "mat_$sent_at" {
+ type = "String"
+ comment = "column_materializer::properties::$sent_at"
+ }
+ column "mat_pp_companyName" {
+ type = "String"
+ comment = "column_materializer::person_properties::companyName"
+ }
+ column "mat_function" {
+ type = "String"
+ comment = "column_materializer::properties::function"
+ }
+ column "mat_store_url" {
+ type = "String"
+ comment = "column_materializer::properties::store_url"
+ }
+ column "mat_email_domain" {
+ type = "String"
+ comment = "column_materializer::properties::email_domain"
+ }
+ column "mat_institution_name" {
+ type = "String"
+ comment = "column_materializer::properties::institution_name"
+ }
+ column "mat_authentication_method" {
+ type = "String"
+ comment = "column_materializer::properties::authentication_method"
+ }
+ column "mat_initial_step" {
+ type = "String"
+ comment = "column_materializer::properties::initial_step"
+ }
+ column "mat_status_message" {
+ type = "String"
+ comment = "column_materializer::properties::status_message"
+ }
+ column "mat_mode" {
+ type = "String"
+ comment = "column_materializer::properties::mode"
+ }
+ column "mat_protocol" {
+ type = "String"
+ comment = "column_materializer::properties::protocol"
+ }
+ column "mat_job_type" {
+ type = "String"
+ comment = "column_materializer::properties::job_type"
+ }
+ column "mat_is_oauth" {
+ type = "String"
+ comment = "column_materializer::properties::is_oauth"
+ }
+ column "mat_is_initial_aggregation" {
+ type = "String"
+ comment = "column_materializer::properties::is_initial_aggregation"
+ }
+ column "mat_search_term" {
+ type = "String"
+ comment = "column_materializer::properties::search_term"
+ }
+ column "mat_valid_ach_accounts" {
+ type = "String"
+ comment = "column_materializer::properties::valid_ach_accounts"
+ }
+ column "mat_gross" {
+ type = "String"
+ comment = "column_materializer::properties::gross"
+ }
+ column "mat_orderType" {
+ type = "String"
+ comment = "column_materializer::properties::orderType"
+ }
+ column "mat_sku" {
+ type = "String"
+ comment = "column_materializer::properties::sku"
+ }
+ column "mat_dual_channel" {
+ type = "String"
+ comment = "column_materializer::properties::dual_channel"
+ }
+ column "mat_channel" {
+ type = "String"
+ comment = "column_materializer::properties::channel"
+ }
+ column "mat_workspaceId" {
+ type = "String"
+ comment = "column_materializer::properties::workspaceId"
+ }
+ column "mat_numberOfSecrets" {
+ type = "String"
+ comment = "column_materializer::properties::numberOfSecrets"
+ }
+ column "mat_organizations" {
+ type = "String"
+ comment = "column_materializer::properties::organizations"
+ }
+ column "mat_organization" {
+ type = "String"
+ comment = "column_materializer::properties::organization"
+ }
+ column "mat_contributionError" {
+ type = "String"
+ comment = "column_materializer::properties::contributionError"
+ }
+ column "mat_phone" {
+ type = "String"
+ comment = "column_materializer::properties::phone"
+ }
+ column "mat_$initial_pathname" {
+ type = "String"
+ comment = "column_materializer::properties::$initial_pathname"
+ }
+ column "mat_organization_name" {
+ type = "String"
+ comment = "column_materializer::properties::organization_name"
+ }
+ column "mat_category" {
+ type = "String"
+ comment = "column_materializer::properties::category"
+ }
+ column "mat_$lib_version" {
+ type = "String"
+ comment = "column_materializer::properties::$lib_version"
+ }
+ column "mat_pp_$initial_utm_campaign" {
+ type = "String"
+ comment = "column_materializer::person_properties::$initial_utm_campaign"
+ }
+ column "mat_pp_$initial_utm_medium" {
+ type = "String"
+ comment = "column_materializer::person_properties::$initial_utm_medium"
+ }
+ column "mat_pp_$initial_gclid" {
+ type = "String"
+ comment = "column_materializer::person_properties::$initial_gclid"
+ }
+ column "mat_pp_$initial_gad_source" {
+ type = "String"
+ comment = "column_materializer::person_properties::$initial_gad_source"
+ }
+ column "mat_pp_$initial_utm_source" {
+ type = "String"
+ comment = "column_materializer::person_properties::$initial_utm_source"
+ }
+ column "mat_pp_$initial_referring_domain" {
+ type = "String"
+ comment = "column_materializer::person_properties::$initial_referring_domain"
+ }
+ column "mat_pp_$initial_utm_term" {
+ type = "String"
+ comment = "column_materializer::person_properties::$initial_utm_term"
+ }
+ column "mat_pp_$initial_utm_content" {
+ type = "String"
+ comment = "column_materializer::person_properties::$initial_utm_content"
+ }
+ column "mat_pp_$initial_gbraid" {
+ type = "String"
+ comment = "column_materializer::person_properties::$initial_gbraid::disabled"
+ }
+ column "mat_pp_$initial_wbraid" {
+ type = "String"
+ comment = "column_materializer::person_properties::$initial_wbraid::disabled"
+ }
+ column "mat_pp_$initial_msclkid" {
+ type = "String"
+ comment = "column_materializer::person_properties::$initial_msclkid"
+ }
+ column "mat_pp_$initial_fbclid" {
+ type = "String"
+ comment = "column_materializer::person_properties::$initial_fbclid"
+ }
+ column "mat_$geoip_subdivision_1_code" {
+ type = "String"
+ comment = "column_materializer::properties::$geoip_subdivision_1_code"
+ }
+ column "mat_wlo_enabled" {
+ type = "String"
+ comment = "column_materializer::properties::wlo_enabled"
+ }
+ column "mat_$prev_pageview_max_scroll_percentage" {
+ type = "String"
+ comment = "column_materializer::properties::$prev_pageview_max_scroll_percentage"
+ }
+ column "mat_$prev_pageview_max_content_percentage" {
+ type = "String"
+ comment = "column_materializer::properties::$prev_pageview_max_content_percentage"
+ }
+ column "mat_$prev_pageview_pathname" {
+ type = "String"
+ comment = "column_materializer::properties::$prev_pageview_pathname"
+ }
+ column "mat_pp_$initial_pathname" {
+ type = "String"
+ comment = "column_materializer::person_properties::$initial_pathname"
+ }
+ column "mat_pp_$geoip_country_code" {
+ type = "String"
+ comment = "column_materializer::person_properties::$geoip_country_code"
+ }
+ column "mat_pp_username" {
+ type = "String"
+ comment = "column_materializer::person_properties::username"
+ }
+ column "mat_pp_serverMasterclass" {
+ type = "String"
+ comment = "column_materializer::person_properties::serverMasterclass"
+ }
+ column "mat_content_length" {
+ type = "String"
+ comment = "column_materializer::properties::content_length"
+ }
+ column "mat_pp_serverMarketing" {
+ type = "String"
+ comment = "column_materializer::person_properties::serverMarketing"
+ }
+ column "mat_$browser_version" {
+ type = "String"
+ comment = "column_materializer::properties::$browser_version"
+ }
+ column "mat_pp_role" {
+ type = "String"
+ comment = "column_materializer::person_properties::role"
+ }
+ column "mat_pp_customer" {
+ type = "String"
+ comment = "column_materializer::person_properties::customer"
+ }
+ column "mat_event" {
+ type = "String"
+ comment = "column_materializer::properties::event"
+ }
+ column "mat_disable_institution_search" {
+ type = "String"
+ comment = "column_materializer::properties::disable_institution_search"
+ }
+ column "mat_is_first_event_for_user" {
+ type = "String"
+ comment = "column_materializer::properties::is_first_event_for_user"
+ }
+ column "mat_current_member_guid" {
+ type = "String"
+ comment = "column_materializer::properties::current_member_guid"
+ }
+ column "mat_user_agent" {
+ type = "String"
+ comment = "column_materializer::properties::user_agent"
+ }
+ column "mat_is_test_user" {
+ type = "String"
+ comment = "column_materializer::properties::is_test_user"
+ }
+ column "mat_referrer" {
+ type = "String"
+ comment = "column_materializer::properties::referrer"
+ }
+ column "mat_pp_$initial_current_url" {
+ type = "String"
+ comment = "column_materializer::person_properties::$initial_current_url"
+ }
+ column "mat_most_recent_app_os" {
+ type = "String"
+ comment = "column_materializer::properties::most_recent_app_os"
+ }
+ column "mat_pp_hubspot_score" {
+ type = "String"
+ comment = "column_materializer::person_properties::hubspot_score"
+ }
+ column "mat_pp_id" {
+ type = "String"
+ comment = "column_materializer::person_properties::id"
+ }
+ column "mat_pp_$current_url" {
+ type = "String"
+ comment = "column_materializer::person_properties::$current_url"
+ }
+ column "mat_product_key" {
+ type = "String"
+ comment = "column_materializer::properties::product_key"
+ }
+ column "mat_Plan_type_and_filter" {
+ type = "String"
+ comment = "column_materializer::properties::Plan type and filter"
+ }
+ column "mat_$app_namespace" {
+ type = "String"
+ comment = "column_materializer::properties::$app_namespace"
+ }
+ column "mat_$os_name" {
+ type = "String"
+ comment = "column_materializer::properties::$os_name"
+ }
+ column "mat_pp_$os_name" {
+ type = "String"
+ comment = "column_materializer::person_properties::$os_name::disabled"
+ }
+ column "mat_pp_$app_version" {
+ type = "String"
+ comment = "column_materializer::person_properties::$app_version"
+ }
+ column "mat_subscriptionStatus" {
+ type = "String"
+ comment = "column_materializer::properties::subscriptionStatus"
+ }
+ column "mat_$screen_height" {
+ type = "String"
+ comment = "column_materializer::properties::$screen_height"
+ }
+ column "mat_$screen_width" {
+ type = "String"
+ comment = "column_materializer::properties::$screen_width"
+ }
+ column "mat_tag" {
+ type = "String"
+ comment = "column_materializer::properties::tag"
+ }
+ column "mat_$app_build" {
+ type = "String"
+ comment = "column_materializer::properties::$app_build"
+ }
+ column "mat_surface_tag" {
+ type = "String"
+ comment = "column_materializer::properties::surface_tag"
+ }
+ column "mat_survey_responses_count_in_period" {
+ type = "String"
+ comment = "column_materializer::properties::survey_responses_count_in_period"
+ }
+ column "mat_event_count_in_month" {
+ type = "String"
+ comment = "column_materializer::properties::event_count_in_month"
+ }
+ column "mat_ramp" {
+ type = "String"
+ comment = "column_materializer::properties::ramp"
+ }
+ column "mat_auto_chapters" {
+ type = "String"
+ comment = "column_materializer::properties::auto_chapters"
+ }
+ column "mat_sentiment_analysis" {
+ type = "String"
+ comment = "column_materializer::properties::sentiment_analysis"
+ }
+ column "mat_redact_pii" {
+ type = "String"
+ comment = "column_materializer::properties::redact_pii"
+ }
+ column "mat_content_safety" {
+ type = "String"
+ comment = "column_materializer::properties::content_safety"
+ }
+ column "mat_iab_categories" {
+ type = "String"
+ comment = "column_materializer::properties::iab_categories"
+ }
+ column "mat_auto_highlights" {
+ type = "String"
+ comment = "column_materializer::properties::auto_highlights"
+ }
+ column "mat_entity_detection" {
+ type = "String"
+ comment = "column_materializer::properties::entity_detection"
+ }
+ column "mat_summarization" {
+ type = "String"
+ comment = "column_materializer::properties::summarization"
+ }
+ column "mat_pp_val_region" {
+ type = "String"
+ comment = "column_materializer::person_properties::val_region"
+ }
+ column "mat_client_id" {
+ type = "String"
+ comment = "column_materializer::properties::client_id"
+ }
+ column "mat_$geoip_country_code" {
+ type = "String"
+ comment = "column_materializer::properties::$geoip_country_code"
+ }
+ column "mat_disfluencies" {
+ type = "String"
+ comment = "column_materializer::properties::disfluencies"
+ }
+ column "mat_filter_profanity" {
+ type = "String"
+ comment = "column_materializer::properties::filter_profanity"
+ }
+ column "mat_speaker_labels" {
+ type = "String"
+ comment = "column_materializer::properties::speaker_labels"
+ }
+ column "mat_language_detection" {
+ type = "String"
+ comment = "column_materializer::properties::language_detection"
+ }
+ column "mat_product_analytics_projected_amount" {
+ type = "String"
+ comment = "column_materializer::properties::product_analytics_projected_amount"
+ }
+ column "mat_recordings_projected_amount" {
+ type = "String"
+ comment = "column_materializer::properties::recordings_projected_amount"
+ }
+ column "mat_events_projected_amount" {
+ type = "String"
+ comment = "column_materializer::properties::events_projected_amount"
+ }
+ column "mat_session_replay_projected_amount" {
+ type = "String"
+ comment = "column_materializer::properties::session_replay_projected_amount"
+ }
+ column "mat_total_usd" {
+ type = "String"
+ comment = "column_materializer::properties::total_usd"
+ }
+ column "mat_stripe_amount_paid" {
+ type = "String"
+ comment = "column_materializer::properties::stripe_amount_paid"
+ }
+ column "mat_workspace" {
+ type = "String"
+ comment = "column_materializer::properties::workspace"
+ }
+ column "mat_created_at" {
+ type = "String"
+ comment = "column_materializer::properties::created_at"
+ }
+ column "mat_kind" {
+ type = "String"
+ comment = "column_materializer::properties::kind"
+ }
+ column "mat_product" {
+ type = "String"
+ comment = "column_materializer::properties::product"
+ }
+ column "mat_message" {
+ type = "String"
+ comment = "column_materializer::properties::message"
+ }
+ column "mat_initiator" {
+ type = "String"
+ comment = "column_materializer::properties::initiator"
+ }
+ column "mat_query" {
+ type = "String"
+ comment = "column_materializer::properties::query"
+ }
+ column "mat_$survey_id" {
+ type = "String"
+ comment = "column_materializer::properties::$survey_id"
+ }
+ column "mat_$survey_response_1" {
+ type = "String"
+ comment = "column_materializer::properties::$survey_response_1"
+ }
+ column "mat_ticketId" {
+ type = "String"
+ comment = "column_materializer::properties::ticketId"
+ }
+ column "mat_$survey_response" {
+ type = "String"
+ comment = "column_materializer::properties::$survey_response"
+ }
+ column "mat_conceptName" {
+ type = "String"
+ comment = "column_materializer::properties::conceptName"
+ }
+ column "mat_apiName" {
+ type = "String"
+ comment = "column_materializer::properties::apiName"
+ }
+ column "mat_workplace_billing_plan" {
+ type = "String"
+ comment = "column_materializer::properties::workplace_billing_plan"
+ }
+ column "mat_$el_text" {
+ type = "String"
+ comment = "column_materializer::properties::$el_text"
+ }
+ column "mat_recording_count_in_period" {
+ type = "String"
+ comment = "column_materializer::properties::recording_count_in_period"
+ }
+ column "mat_$os_version" {
+ type = "String"
+ comment = "column_materializer::properties::$os_version"
+ }
+ column "mat_orderId" {
+ type = "String"
+ comment = "column_materializer::properties::orderId"
+ }
+ column "mat_commit_sha" {
+ type = "String"
+ comment = "column_materializer::properties::commit_sha"
+ }
+ column "mat_$feature_flag_payloads" {
+ type = "String"
+ comment = "column_materializer::properties::$feature_flag_payloads"
+ }
+ column "mat_event_count_in_period" {
+ type = "String"
+ comment = "column_materializer::properties::event_count_in_period"
+ }
+ column "mat_$groups" {
+ type = "String"
+ comment = "column_materializer::properties::$groups"
+ }
+ column "mat_$feature_flag" {
+ type = "String"
+ comment = "column_materializer::properties::$feature_flag"
+ }
+ column "mat_utm_content" {
+ type = "String"
+ comment = "column_materializer::properties::utm_content"
+ }
+ column "mat_gclid" {
+ type = "String"
+ comment = "column_materializer::properties::gclid"
+ }
+ column "mat_gad_source" {
+ type = "String"
+ comment = "column_materializer::properties::gad_source"
+ }
+ column "mat_gbraid" {
+ type = "String"
+ comment = "column_materializer::properties::gbraid"
+ }
+ column "mat_wbraid" {
+ type = "String"
+ comment = "column_materializer::properties::wbraid"
+ }
+ column "mat_fbclid" {
+ type = "String"
+ comment = "column_materializer::properties::fbclid"
+ }
+ column "mat_msclkid" {
+ type = "String"
+ comment = "column_materializer::properties::msclkid"
+ }
+ column "mat_organization_id" {
+ type = "String"
+ comment = "column_materializer::properties::organization_id"
+ }
+ column "mat_owner_type" {
+ type = "String"
+ comment = "column_materializer::properties::owner_type"
+ }
+ column "mat_device_type" {
+ type = "String"
+ comment = "column_materializer::properties::device_type"
+ }
+ column "mat_$device_id" {
+ type = "String"
+ comment = "column_materializer::properties::$device_id"
+ }
+ column "mat_pp_$geoip_continent_name" {
+ type = "String"
+ comment = "column_materializer::person_properties::$geoip_continent_name"
+ }
+ column "mat_$feature_flag_response" {
+ type = "String"
+ comment = "column_materializer::properties::$feature_flag_response"
+ }
+ column "mat_pp_utm_source" {
+ type = "String"
+ comment = "column_materializer::person_properties::utm_source"
+ }
+ column "mat_pp_$referring_domain" {
+ type = "String"
+ comment = "column_materializer::person_properties::$referring_domain"
+ }
+ column "mat_pp_Email_Domain" {
+ type = "String"
+ comment = "column_materializer::person_properties::Email Domain"
+ }
+ column "mat_machine_id" {
+ type = "String"
+ comment = "column_materializer::properties::machine_id"
+ }
+ column "mat_user_email_domain" {
+ type = "String"
+ comment = "column_materializer::properties::user_email_domain"
+ }
+ column "mat_$lib_version__minor" {
+ type = "String"
+ comment = "column_materializer::properties::$lib_version__minor"
+ }
+ column "mat_region" {
+ type = "String"
+ comment = "column_materializer::properties::region"
+ }
+ column "mat_pp_user_email_domain" {
+ type = "String"
+ comment = "column_materializer::person_properties::user_email_domain"
+ }
+ column "mat_url_promotion_id" {
+ type = "String"
+ comment = "column_materializer::properties::url_promotion_id"
+ }
+ column "mat_$lib_custom_api_host" {
+ type = "String"
+ comment = "column_materializer::properties::$lib_custom_api_host"
+ }
+ column "person_mode" {
+ type = "Enum8('full'=0, 'propertyless'=1, 'force_upgrade'=2)"
+ }
+ column "mat_user_platform" {
+ type = "String"
+ comment = "column_materializer::properties::user_platform"
+ }
+ column "mat_pp_$geoip_country_name" {
+ type = "String"
+ comment = "column_materializer::person_properties::$geoip_country_name"
+ }
+ column "mat_environment" {
+ type = "String"
+ comment = "column_materializer::properties::environment"
+ }
+ column "mat_customer_email" {
+ type = "String"
+ comment = "column_materializer::properties::customer_email"
+ }
+ column "mat_client_name" {
+ type = "String"
+ comment = "column_materializer::properties::client_name"
+ }
+ column "mat_screen_name" {
+ type = "String"
+ comment = "column_materializer::properties::screen_name"
+ }
+ column "mat_app_version" {
+ type = "String"
+ comment = "column_materializer::properties::app_version"
+ }
+ column "elements_chain_href" {
+ type = "String"
+ comment = "column_materializer::elements_chain::href"
+ }
+ column "elements_chain_texts" {
+ type = "Array(String)"
+ comment = "column_materializer::elements_chain::texts"
+ }
+ column "elements_chain_ids" {
+ type = "Array(String)"
+ comment = "column_materializer::elements_chain::ids"
+ }
+ column "elements_chain_elements" {
+ type = "Array(Enum8('a'=1, 'button'=2, 'form'=3, 'input'=4, 'select'=5, 'textarea'=6, 'label'=7))"
+ comment = "column_materializer::elements_chain::elements"
+ }
+ column "properties_group_custom" {
+ type = "Map(String, String)"
+ }
+ column "properties_group_feature_flags" {
+ type = "Map(String, String)"
+ }
+ column "is_deleted" {
+ type = "Bool"
+ }
+ column "mat_subdomain" {
+ type = "String"
+ comment = "column_materializer::properties::subdomain"
+ }
+ column "mat_$device" {
+ type = "String"
+ comment = "column_materializer::properties::$device"
+ }
+ column "mat_id" {
+ type = "String"
+ comment = "column_materializer::properties::id"
+ }
+ column "mat_record_id" {
+ type = "String"
+ comment = "column_materializer::properties::record_id"
+ }
+ column "mat_referrer_id" {
+ type = "String"
+ comment = "column_materializer::properties::record_id"
+ }
+ column "mat_$exception_issue_id" {
+ type = "Nullable(String)"
+ comment = "column_materializer::properties::$exception_issue_id"
+ }
+ column "mat_$exception_fingerprint" {
+ type = "Nullable(String)"
+ comment = "column_materializer::properties::$exception_fingerprint"
+ }
+ column "mat_$web_vitals_LCP_value" {
+ type = "Nullable(String)"
+ comment = "column_materializer::properties::$web_vitals_LCP_value"
+ }
+ column "mat_$web_vitals_FCP_value" {
+ type = "Nullable(String)"
+ comment = "column_materializer::properties::$web_vitals_FCP_value"
+ }
+ column "mat_$web_vitals_CLS_value" {
+ type = "Nullable(String)"
+ comment = "column_materializer::properties::$web_vitals_CLS_value"
+ }
+ column "mat_$web_vitals_INP_value" {
+ type = "Nullable(String)"
+ comment = "column_materializer::properties::$web_vitals_INP_value"
+ }
+ column "mat_$viewport_width" {
+ type = "Nullable(String)"
+ comment = "column_materializer::properties::$viewport_width"
+ }
+ column "mat_$viewport_height" {
+ type = "Nullable(String)"
+ comment = "column_materializer::properties::$viewport_height"
+ }
+ column "mat_$anon_distinct_id" {
+ type = "Nullable(String)"
+ comment = "column_materializer::properties::$anon_distinct_id"
+ }
+ column "person_properties_map_custom" {
+ type = "Map(String, String)"
+ }
+ column "mat_$ai_trace_id" {
+ type = "Nullable(String)"
+ comment = "column_materializer::properties::$ai_trace_id"
+ }
+ column "mat_$ai_model" {
+ type = "Nullable(String)"
+ comment = "column_materializer::properties::$ai_model"
+ }
+ column "mat_$ai_provider" {
+ type = "Nullable(String)"
+ comment = "column_materializer::properties::$ai_provider"
+ }
+ column "mat_$ai_parent_id" {
+ type = "Nullable(String)"
+ comment = "column_materializer::properties::$ai_parent_id"
+ }
+ column "mat_$ai_span_id" {
+ type = "Nullable(String)"
+ comment = "column_materializer::properties::$ai_span_id"
+ }
+ column "mat_$ai_http_status" {
+ type = "Nullable(String)"
+ comment = "column_materializer::properties::$ai_http_status"
+ }
+ column "mat_$exception_types" {
+ type = "Nullable(String)"
+ comment = "column_materializer::properties::$exception_types"
+ }
+ column "mat_$exception_values" {
+ type = "Nullable(String)"
+ comment = "column_materializer::properties::$exception_values"
+ }
+ column "mat_$exception_sources" {
+ type = "Nullable(String)"
+ comment = "column_materializer::properties::$exception_sources"
+ }
+ column "mat_$exception_functions" {
+ type = "Nullable(String)"
+ comment = "column_materializer::properties::$exception_functions"
+ }
+ column "$session_id_uuid" {
+ type = "Nullable(UInt128)"
+ }
+ column "mat_$process_person_profile" {
+ type = "Nullable(String)"
+ comment = "column_materializer::properties::$process_person_profile"
+ }
+ column "consumer_breadcrumbs" {
+ type = "Array(String)"
+ }
+ column "properties_group_ai" {
+ type = "Map(String, String)"
+ }
+ column "mat_$is_identified" {
+ type = "Nullable(String)"
+ comment = "column_materializer::properties::$is_identified"
+ }
+ column "mat_historical_migration" {
+ type = "Nullable(String)"
+ comment = "column_materializer::properties::historical_migration"
+ }
+ column "mat_$ai_session_id" {
+ type = "Nullable(String)"
+ comment = "column_materializer::properties::$ai_session_id"
+ }
+ column "mat_$ai_is_error" {
+ type = "Nullable(String)"
+ comment = "column_materializer::properties::$ai_is_error"
+ }
+ column "dmat_string_0" {
+ type = "Nullable(String)"
+ }
+ column "dmat_string_1" {
+ type = "Nullable(String)"
+ }
+ column "dmat_string_2" {
+ type = "Nullable(String)"
+ }
+ column "dmat_string_3" {
+ type = "Nullable(String)"
+ }
+ column "dmat_string_4" {
+ type = "Nullable(String)"
+ }
+ column "dmat_string_5" {
+ type = "Nullable(String)"
+ }
+ column "dmat_string_6" {
+ type = "Nullable(String)"
+ }
+ column "dmat_string_7" {
+ type = "Nullable(String)"
+ }
+ column "dmat_string_8" {
+ type = "Nullable(String)"
+ }
+ column "dmat_string_9" {
+ type = "Nullable(String)"
+ }
+ column "dmat_numeric_0" {
+ type = "Nullable(Float64)"
+ }
+ column "dmat_numeric_1" {
+ type = "Nullable(Float64)"
+ }
+ column "dmat_numeric_2" {
+ type = "Nullable(Float64)"
+ }
+ column "dmat_numeric_3" {
+ type = "Nullable(Float64)"
+ }
+ column "dmat_numeric_4" {
+ type = "Nullable(Float64)"
+ }
+ column "dmat_numeric_5" {
+ type = "Nullable(Float64)"
+ }
+ column "dmat_numeric_6" {
+ type = "Nullable(Float64)"
+ }
+ column "dmat_numeric_7" {
+ type = "Nullable(Float64)"
+ }
+ column "dmat_numeric_8" {
+ type = "Nullable(Float64)"
+ }
+ column "dmat_numeric_9" {
+ type = "Nullable(Float64)"
+ }
+ column "dmat_bool_0" {
+ type = "Nullable(UInt8)"
+ }
+ column "dmat_bool_1" {
+ type = "Nullable(UInt8)"
+ }
+ column "dmat_bool_2" {
+ type = "Nullable(UInt8)"
+ }
+ column "dmat_bool_3" {
+ type = "Nullable(UInt8)"
+ }
+ column "dmat_bool_4" {
+ type = "Nullable(UInt8)"
+ }
+ column "dmat_bool_5" {
+ type = "Nullable(UInt8)"
+ }
+ column "dmat_bool_6" {
+ type = "Nullable(UInt8)"
+ }
+ column "dmat_bool_7" {
+ type = "Nullable(UInt8)"
+ }
+ column "dmat_bool_8" {
+ type = "Nullable(UInt8)"
+ }
+ column "dmat_bool_9" {
+ type = "Nullable(UInt8)"
+ }
+ column "dmat_datetime_0" {
+ type = "Nullable(DateTime64(6, 'UTC'))"
+ }
+ column "dmat_datetime_1" {
+ type = "Nullable(DateTime64(6, 'UTC'))"
+ }
+ column "dmat_datetime_2" {
+ type = "Nullable(DateTime64(6, 'UTC'))"
+ }
+ column "dmat_datetime_3" {
+ type = "Nullable(DateTime64(6, 'UTC'))"
+ }
+ column "dmat_datetime_4" {
+ type = "Nullable(DateTime64(6, 'UTC'))"
+ }
+ column "dmat_datetime_5" {
+ type = "Nullable(DateTime64(6, 'UTC'))"
+ }
+ column "dmat_datetime_6" {
+ type = "Nullable(DateTime64(6, 'UTC'))"
+ }
+ column "dmat_datetime_7" {
+ type = "Nullable(DateTime64(6, 'UTC'))"
+ }
+ column "dmat_datetime_8" {
+ type = "Nullable(DateTime64(6, 'UTC'))"
+ }
+ column "dmat_datetime_9" {
+ type = "Nullable(DateTime64(6, 'UTC'))"
+ }
+ column "historical_migration" {
+ type = "Bool"
+ }
+ column "mat_$ai_total_cost_usd" {
+ type = "Nullable(String)"
+ comment = "column_materializer::properties::$ai_total_cost_usd"
+ }
+ column "properties_group_ai_large" {
+ type = "Map(String, String)"
+ }
+ column "mat_$ai_prompt_name" {
+ type = "Nullable(String)"
+ comment = "column_materializer::properties::$ai_prompt_name"
+ }
+ engine "distributed" {
+ cluster_name = "posthog"
+ remote_database = "posthog"
+ remote_table = "sharded_events"
+ sharding_key = "sipHash64(distinct_id)"
+ }
+ }
+
+ table "person_distinct_id_overrides" {
+ column "team_id" {
+ type = "Int64"
+ }
+ column "distinct_id" {
+ type = "String"
+ }
+ column "person_id" {
+ type = "UUID"
+ }
+ column "is_deleted" {
+ type = "Int8"
+ }
+ column "version" {
+ type = "Int64"
+ }
+ column "_timestamp" {
+ type = "DateTime"
+ }
+ column "_offset" {
+ type = "UInt64"
+ }
+ column "_partition" {
+ type = "UInt64"
+ }
+ engine "distributed" {
+ cluster_name = "posthog_single_shard"
+ remote_database = "posthog"
+ remote_table = "person_distinct_id_overrides"
+ sharding_key = "sipHash64(distinct_id)"
+ }
+ }
+
+ table "person_static_cohort" {
+ 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 "distributed" {
+ cluster_name = "posthog_single_shard"
+ remote_database = "posthog"
+ remote_table = "person_static_cohort"
+ sharding_key = "rand()"
+ }
+ }
+
+ 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 "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_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'))"
+ }
+ column "initial__kx" {
+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"
+ }
+ engine "replicated_aggregating_merge_tree" {
+ zoo_path = "/clickhouse/tables/sessions/noshard/posthog.raw_sessions"
+ replica_name = "{shard}-{replica}"
+ }
+ }
+
+ table "raw_sessions_v3" {
+ order_by = ["team_id", "session_timestamp", "session_id_v7"]
+ partition_by = "toYYYYMM(session_timestamp)"
+ settings = {
+ index_granularity = "8192"
+ replicated_deduplication_window = "0"
+ replicated_deduplication_window_for_async_inserts = "0"
+ }
+ 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, 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
+ }
+ engine "replicated_aggregating_merge_tree" {
+ zoo_path = "/clickhouse/tables/sessions/noshard/posthog.raw_sessions_v3"
+ replica_name = "{shard}-{replica}"
+ }
+ }
+
+ table "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 "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/sessions/noshard/posthog.sessions"
+ replica_name = "{shard}-{replica}"
+ }
+ }
+
+ table "web_pre_aggregated_teams" {
+ column "team_id" {
+ type = "UInt64"
+ }
+ column "enabled_by" {
+ type = "String"
+ default = "'system'"
+ }
+ column "version" {
+ type = "UInt32"
+ default = "toUnixTimestamp(now())"
+ }
+ engine "distributed" {
+ cluster_name = "posthog_single_shard"
+ remote_database = "posthog"
+ remote_table = "web_pre_aggregated_teams"
+ }
+ }
+
+ 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_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"
+ }
+ }
+
+ 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)"
+ }
+ }
+
+ 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
+
+ }
+
+ 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 = "dict_reader"
+ table = "channel_definition"
+ }
+ layout "complex_key_hashed" {
+ }
+ }
+
+ dictionary "web_pre_aggregated_teams_dict" {
+ primary_key = ["team_id"]
+ lifetime {
+ min = 3000
+ max = 3600
+ }
+ attribute "team_id" {
+ type = "UInt64"
+ }
+ source "clickhouse" {
+ user = "dict_reader"
+ query = "SELECT team_id FROM `web_pre_aggregated_teams` FINAL WHERE version > 0"
+ }
+ layout "hashed" {
+ }
+ }
+}
diff --git a/posthog/clickhouse/hcl/golden/prod-us-sessionsv3.hcl b/posthog/clickhouse/hcl/golden/prod-us-sessionsv3.hcl
new file mode 100644
index 000000000000..2cafbcff0185
--- /dev/null
+++ b/posthog/clickhouse/hcl/golden/prod-us-sessionsv3.hcl
@@ -0,0 +1,2645 @@
+database "posthog" {
+ table "events" {
+ 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_hash" {
+ type = "String"
+ }
+ column "created_at" {
+ type = "DateTime64(6, 'UTC')"
+ }
+ column "_timestamp" {
+ type = "DateTime"
+ }
+ column "_offset" {
+ type = "UInt64"
+ }
+ column "elements_chain" {
+ type = "String"
+ }
+ column "mat_$user_id" {
+ type = "String"
+ comment = "column_materializer::$user_id"
+ }
+ column "mat_$browser" {
+ type = "String"
+ comment = "column_materializer::$browser"
+ }
+ column "mat_$host" {
+ type = "String"
+ comment = "column_materializer::$host"
+ }
+ column "mat_$current_url" {
+ type = "String"
+ comment = "column_materializer::$current_url"
+ }
+ column "mat_distinct_id" {
+ type = "String"
+ comment = "column_materializer::distinct_id"
+ }
+ column "mat_action" {
+ type = "String"
+ comment = "column_materializer::action"
+ }
+ column "mat_origin" {
+ type = "String"
+ comment = "column_materializer::origin"
+ }
+ column "mat_email" {
+ type = "String"
+ comment = "column_materializer::email"
+ }
+ column "mat_key" {
+ type = "String"
+ comment = "column_materializer::key"
+ }
+ column "mat_insight" {
+ type = "String"
+ comment = "column_materializer::insight"
+ }
+ column "mat_$event_type" {
+ type = "String"
+ comment = "column_materializer::$event_type"
+ }
+ column "mat_created_by" {
+ type = "String"
+ comment = "column_materializer::created_by"
+ }
+ column "mat_total_event_actions_count" {
+ type = "String"
+ comment = "column_materializer::total_event_actions_count"
+ }
+ column "mat_is_demo_project" {
+ type = "String"
+ comment = "column_materializer::is_demo_project"
+ }
+ column "mat_$active_feature_flags" {
+ type = "String"
+ comment = "column_materializer::$active_feature_flags"
+ }
+ column "mat_filters_count" {
+ type = "String"
+ comment = "column_materializer::filters_count"
+ }
+ column "mat_utm_source" {
+ type = "String"
+ comment = "column_materializer::utm_source"
+ }
+ column "mat_apiErrorMessage" {
+ type = "String"
+ comment = "column_materializer::apiErrorMessage"
+ }
+ column "mat_$referring_domain" {
+ type = "String"
+ comment = "column_materializer::$referring_domain"
+ }
+ column "mat_statusCode" {
+ type = "String"
+ comment = "column_materializer::statusCode"
+ }
+ column "mat_deal_id" {
+ type = "String"
+ comment = "column_materializer::deal_id"
+ }
+ column "mat_realm" {
+ type = "String"
+ comment = "column_materializer::realm"
+ }
+ 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 "mat_$lib" {
+ type = "String"
+ comment = "column_materializer::$lib"
+ }
+ column "mat_$os" {
+ type = "String"
+ comment = "column_materializer::$os"
+ }
+ column "mat_$initial_referrer" {
+ type = "String"
+ comment = "column_materializer::$initial_referrer"
+ }
+ column "mat_$app_version" {
+ type = "String"
+ comment = "column_materializer::$app_version"
+ }
+ column "mat_$initial_referring_domain" {
+ type = "String"
+ comment = "column_materializer::$initial_referring_domain"
+ }
+ column "mat_symbol" {
+ type = "String"
+ comment = "column_materializer::symbol"
+ }
+ column "mat_page" {
+ type = "String"
+ comment = "column_materializer::page"
+ }
+ column "mat_type" {
+ type = "String"
+ comment = "column_materializer::type"
+ }
+ column "mat_currentScreen" {
+ type = "String"
+ comment = "column_materializer::currentScreen"
+ }
+ column "mat_utm_campaign" {
+ type = "String"
+ comment = "column_materializer::utm_campaign"
+ }
+ column "mat_is_organization_first_user" {
+ type = "String"
+ comment = "column_materializer::is_organization_first_user"
+ }
+ column "mat_is_first_component_load" {
+ type = "String"
+ comment = "column_materializer::is_first_component_load"
+ }
+ column "mat_team" {
+ type = "String"
+ comment = "column_materializer::team"
+ }
+ column "mat_context" {
+ type = "String"
+ comment = "column_materializer::context"
+ }
+ column "mat_sdk" {
+ type = "String"
+ comment = "column_materializer::sdk"
+ }
+ column "mat_created_by_system" {
+ type = "String"
+ comment = "column_materializer::created_by_system"
+ }
+ column "mat_item_count" {
+ type = "String"
+ comment = "column_materializer::item_count"
+ }
+ column "mat_$ip" {
+ type = "String"
+ comment = "column_materializer::$ip"
+ }
+ column "mat_$referrer" {
+ type = "String"
+ comment = "column_materializer::$referrer"
+ }
+ column "mat_action_name" {
+ type = "String"
+ comment = "column_materializer::action_name"
+ }
+ column "mat_$geoip_country_name" {
+ type = "String"
+ comment = "column_materializer::$geoip_country_name"
+ }
+ column "mat_$device_model" {
+ type = "String"
+ comment = "column_materializer::$device_model"
+ }
+ column "mat_progress" {
+ type = "String"
+ comment = "column_materializer::progress"
+ }
+ column "mat_chain" {
+ type = "String"
+ comment = "column_materializer::chain"
+ }
+ column "mat_$device_type" {
+ type = "String"
+ comment = "column_materializer::$device_type"
+ }
+ column "mat_usd" {
+ type = "String"
+ comment = "column_materializer::usd"
+ }
+ column "mat_app_name" {
+ type = "String"
+ comment = "column_materializer::app_name"
+ }
+ column "mat_$screen_name" {
+ type = "String"
+ comment = "column_materializer::$screen_name"
+ }
+ column "mat_index" {
+ type = "String"
+ comment = "column_materializer::index"
+ }
+ column "mat_token" {
+ type = "String"
+ comment = "column_materializer::token"
+ }
+ column "mat_method" {
+ type = "String"
+ comment = "column_materializer::method"
+ }
+ column "mat_address" {
+ type = "String"
+ comment = "column_materializer::address"
+ }
+ column "mat_name" {
+ type = "String"
+ comment = "column_materializer::name"
+ }
+ column "mat_inviteCode" {
+ type = "String"
+ comment = "column_materializer::inviteCode"
+ }
+ column "$window_id" {
+ type = "String"
+ comment = "column_materializer::$window_id"
+ }
+ column "$session_id" {
+ type = "String"
+ comment = "column_materializer::$session_id"
+ }
+ column "mat_osName" {
+ type = "String"
+ comment = "column_materializer::osName"
+ }
+ column "mat_nativeBuildVersion" {
+ type = "String"
+ comment = "column_materializer::nativeBuildVersion"
+ }
+ column "mat_revenue" {
+ type = "String"
+ comment = "column_materializer::revenue"
+ }
+ column "group_0" {
+ type = "String"
+ alias = "`$group_0`"
+ }
+ column "group_1" {
+ type = "String"
+ alias = "`$group_1`"
+ }
+ column "group_2" {
+ type = "String"
+ alias = "`$group_2`"
+ }
+ column "group_3" {
+ type = "String"
+ alias = "`$group_3`"
+ }
+ column "group_4" {
+ type = "String"
+ alias = "`$group_4`"
+ }
+ column "alias_mat__user_id" {
+ type = "String"
+ alias = "`mat_$user_id`"
+ }
+ column "alias_mat__browser" {
+ type = "String"
+ alias = "`mat_$browser`"
+ }
+ column "alias_mat__host" {
+ type = "String"
+ alias = "`mat_$host`"
+ }
+ column "alias_mat__current_url" {
+ type = "String"
+ alias = "`mat_$current_url`"
+ }
+ column "alias_mat__event_type" {
+ type = "String"
+ alias = "`mat_$event_type`"
+ }
+ column "alias_mat__active_feature_flags" {
+ type = "String"
+ alias = "`mat_$active_feature_flags`"
+ }
+ column "alias_mat__referring_domain" {
+ type = "String"
+ alias = "`mat_$referring_domain`"
+ }
+ column "alias_mat__lib" {
+ type = "String"
+ alias = "`mat_$lib`"
+ }
+ column "alias_mat__os" {
+ type = "String"
+ alias = "`mat_$os`"
+ }
+ column "alias_mat__initial_referrer" {
+ type = "String"
+ alias = "`mat_$initial_referrer`"
+ }
+ column "alias_mat__app_version" {
+ type = "String"
+ alias = "`mat_$app_version`"
+ }
+ column "alias_mat__initial_referring_domain" {
+ type = "String"
+ alias = "`mat_$initial_referring_domain`"
+ }
+ column "alias_mat__ip" {
+ type = "String"
+ alias = "`mat_$ip`"
+ }
+ column "alias_mat__referrer" {
+ type = "String"
+ alias = "`mat_$referrer`"
+ }
+ column "alias_mat__geoip_country_name" {
+ type = "String"
+ alias = "`mat_$geoip_country_name`"
+ }
+ column "alias_mat__device_model" {
+ type = "String"
+ alias = "`mat_$device_model`"
+ }
+ column "alias_mat__device_type" {
+ type = "String"
+ alias = "`mat_$device_type`"
+ }
+ column "alias_mat__screen_name" {
+ type = "String"
+ alias = "`mat_$screen_name`"
+ }
+ column "person_id" {
+ type = "UUID"
+ }
+ column "person_properties" {
+ type = "String"
+ }
+ column "group0_properties" {
+ type = "String"
+ }
+ column "group1_properties" {
+ type = "String"
+ }
+ column "group2_properties" {
+ type = "String"
+ }
+ column "group3_properties" {
+ type = "String"
+ }
+ column "group4_properties" {
+ type = "String"
+ }
+ column "person_created_at" {
+ type = "DateTime64(3)"
+ }
+ column "group0_created_at" {
+ type = "DateTime64(3)"
+ }
+ column "group1_created_at" {
+ type = "DateTime64(3)"
+ }
+ column "group2_created_at" {
+ type = "DateTime64(3)"
+ }
+ column "group3_created_at" {
+ type = "DateTime64(3)"
+ }
+ column "group4_created_at" {
+ type = "DateTime64(3)"
+ }
+ column "mat_arguments" {
+ type = "String"
+ comment = "column_materializer::properties::arguments"
+ }
+ column "mat_source" {
+ type = "String"
+ comment = "column_materializer::properties::source"
+ }
+ column "mat_pp_email" {
+ type = "String"
+ comment = "column_materializer::person_properties::email"
+ }
+ column "mat_$time" {
+ type = "String"
+ comment = "column_materializer::properties::$time"
+ }
+ column "mat_$pathname" {
+ type = "String"
+ comment = "column_materializer::properties::$pathname"
+ }
+ column "mat_$geoip_city_name" {
+ type = "String"
+ comment = "column_materializer::properties::$geoip_city_name"
+ }
+ column "mat_community_id" {
+ type = "String"
+ comment = "column_materializer::properties::community_id"
+ }
+ column "mat_thread_id" {
+ type = "String"
+ comment = "column_materializer::properties::thread_id"
+ }
+ column "mat_Event_productCode" {
+ type = "String"
+ comment = "column_materializer::properties::Event.productCode"
+ }
+ column "mat_env" {
+ type = "String"
+ comment = "column_materializer::properties::env"
+ }
+ column "mat_target" {
+ type = "String"
+ comment = "column_materializer::properties::target"
+ }
+ column "mat_Subscription_plan_amount" {
+ type = "String"
+ comment = "column_materializer::properties::Subscription.plan.amount"
+ }
+ column "mat_title" {
+ type = "String"
+ comment = "column_materializer::properties::title"
+ }
+ column "mat_Connection_app_name" {
+ type = "String"
+ comment = "column_materializer::properties::Connection.app.name"
+ }
+ column "mat_utm_medium" {
+ type = "String"
+ comment = "column_materializer::properties::utm_medium"
+ }
+ column "mat_Account_client_id" {
+ type = "String"
+ comment = "column_materializer::properties::Account.client_id"
+ }
+ column "mat_HTTP_Method" {
+ type = "String"
+ comment = "column_materializer::properties::HTTP Method"
+ }
+ column "mat_audio_duration" {
+ type = "String"
+ comment = "column_materializer::properties::audio_duration"
+ }
+ column "mat_duration" {
+ type = "String"
+ comment = "column_materializer::properties::duration"
+ }
+ column "mat_url" {
+ type = "String"
+ comment = "column_materializer::properties::url"
+ }
+ column "mat_group_id" {
+ type = "String"
+ comment = "column_materializer::properties::group_id"
+ }
+ column "mat_platform" {
+ type = "String"
+ comment = "column_materializer::properties::platform"
+ }
+ column "mat_pp_$browser" {
+ type = "String"
+ comment = "column_materializer::person_properties::$browser"
+ }
+ column "mat_payment_status" {
+ type = "String"
+ comment = "column_materializer::properties::payment_status"
+ }
+ column "mat_testSessionId" {
+ type = "String"
+ comment = "column_materializer::properties::testSessionId"
+ }
+ column "inserted_at" {
+ type = "Nullable(DateTime64(6, 'UTC'))"
+ default = "now64()"
+ }
+ column "mat_$sent_at" {
+ type = "String"
+ comment = "column_materializer::properties::$sent_at"
+ }
+ column "mat_pp_companyName" {
+ type = "String"
+ comment = "column_materializer::person_properties::companyName"
+ }
+ column "mat_function" {
+ type = "String"
+ comment = "column_materializer::properties::function"
+ }
+ column "mat_store_url" {
+ type = "String"
+ comment = "column_materializer::properties::store_url"
+ }
+ column "mat_email_domain" {
+ type = "String"
+ comment = "column_materializer::properties::email_domain"
+ }
+ column "mat_institution_name" {
+ type = "String"
+ comment = "column_materializer::properties::institution_name"
+ }
+ column "mat_authentication_method" {
+ type = "String"
+ comment = "column_materializer::properties::authentication_method"
+ }
+ column "mat_initial_step" {
+ type = "String"
+ comment = "column_materializer::properties::initial_step"
+ }
+ column "mat_status_message" {
+ type = "String"
+ comment = "column_materializer::properties::status_message"
+ }
+ column "mat_mode" {
+ type = "String"
+ comment = "column_materializer::properties::mode"
+ }
+ column "mat_protocol" {
+ type = "String"
+ comment = "column_materializer::properties::protocol"
+ }
+ column "mat_job_type" {
+ type = "String"
+ comment = "column_materializer::properties::job_type"
+ }
+ column "mat_is_oauth" {
+ type = "String"
+ comment = "column_materializer::properties::is_oauth"
+ }
+ column "mat_is_initial_aggregation" {
+ type = "String"
+ comment = "column_materializer::properties::is_initial_aggregation"
+ }
+ column "mat_search_term" {
+ type = "String"
+ comment = "column_materializer::properties::search_term"
+ }
+ column "mat_valid_ach_accounts" {
+ type = "String"
+ comment = "column_materializer::properties::valid_ach_accounts"
+ }
+ column "mat_gross" {
+ type = "String"
+ comment = "column_materializer::properties::gross"
+ }
+ column "mat_orderType" {
+ type = "String"
+ comment = "column_materializer::properties::orderType"
+ }
+ column "mat_sku" {
+ type = "String"
+ comment = "column_materializer::properties::sku"
+ }
+ column "mat_dual_channel" {
+ type = "String"
+ comment = "column_materializer::properties::dual_channel"
+ }
+ column "mat_channel" {
+ type = "String"
+ comment = "column_materializer::properties::channel"
+ }
+ column "mat_workspaceId" {
+ type = "String"
+ comment = "column_materializer::properties::workspaceId"
+ }
+ column "mat_numberOfSecrets" {
+ type = "String"
+ comment = "column_materializer::properties::numberOfSecrets"
+ }
+ column "mat_organizations" {
+ type = "String"
+ comment = "column_materializer::properties::organizations"
+ }
+ column "mat_organization" {
+ type = "String"
+ comment = "column_materializer::properties::organization"
+ }
+ column "mat_contributionError" {
+ type = "String"
+ comment = "column_materializer::properties::contributionError"
+ }
+ column "mat_phone" {
+ type = "String"
+ comment = "column_materializer::properties::phone"
+ }
+ column "mat_$initial_pathname" {
+ type = "String"
+ comment = "column_materializer::properties::$initial_pathname"
+ }
+ column "mat_organization_name" {
+ type = "String"
+ comment = "column_materializer::properties::organization_name"
+ }
+ column "mat_category" {
+ type = "String"
+ comment = "column_materializer::properties::category"
+ }
+ column "mat_$lib_version" {
+ type = "String"
+ comment = "column_materializer::properties::$lib_version"
+ }
+ column "mat_pp_$initial_utm_campaign" {
+ type = "String"
+ comment = "column_materializer::person_properties::$initial_utm_campaign"
+ }
+ column "mat_pp_$initial_utm_medium" {
+ type = "String"
+ comment = "column_materializer::person_properties::$initial_utm_medium"
+ }
+ column "mat_pp_$initial_gclid" {
+ type = "String"
+ comment = "column_materializer::person_properties::$initial_gclid"
+ }
+ column "mat_pp_$initial_gad_source" {
+ type = "String"
+ comment = "column_materializer::person_properties::$initial_gad_source"
+ }
+ column "mat_pp_$initial_utm_source" {
+ type = "String"
+ comment = "column_materializer::person_properties::$initial_utm_source"
+ }
+ column "mat_pp_$initial_referring_domain" {
+ type = "String"
+ comment = "column_materializer::person_properties::$initial_referring_domain"
+ }
+ column "mat_pp_$initial_utm_term" {
+ type = "String"
+ comment = "column_materializer::person_properties::$initial_utm_term"
+ }
+ column "mat_pp_$initial_utm_content" {
+ type = "String"
+ comment = "column_materializer::person_properties::$initial_utm_content"
+ }
+ column "mat_pp_$initial_gbraid" {
+ type = "String"
+ comment = "column_materializer::person_properties::$initial_gbraid::disabled"
+ }
+ column "mat_pp_$initial_wbraid" {
+ type = "String"
+ comment = "column_materializer::person_properties::$initial_wbraid::disabled"
+ }
+ column "mat_pp_$initial_msclkid" {
+ type = "String"
+ comment = "column_materializer::person_properties::$initial_msclkid"
+ }
+ column "mat_pp_$initial_fbclid" {
+ type = "String"
+ comment = "column_materializer::person_properties::$initial_fbclid"
+ }
+ column "mat_$geoip_subdivision_1_code" {
+ type = "String"
+ comment = "column_materializer::properties::$geoip_subdivision_1_code"
+ }
+ column "mat_wlo_enabled" {
+ type = "String"
+ comment = "column_materializer::properties::wlo_enabled"
+ }
+ column "mat_$prev_pageview_max_scroll_percentage" {
+ type = "String"
+ comment = "column_materializer::properties::$prev_pageview_max_scroll_percentage"
+ }
+ column "mat_$prev_pageview_max_content_percentage" {
+ type = "String"
+ comment = "column_materializer::properties::$prev_pageview_max_content_percentage"
+ }
+ column "mat_$prev_pageview_pathname" {
+ type = "String"
+ comment = "column_materializer::properties::$prev_pageview_pathname"
+ }
+ column "mat_pp_$initial_pathname" {
+ type = "String"
+ comment = "column_materializer::person_properties::$initial_pathname"
+ }
+ column "mat_pp_$geoip_country_code" {
+ type = "String"
+ comment = "column_materializer::person_properties::$geoip_country_code"
+ }
+ column "mat_pp_username" {
+ type = "String"
+ comment = "column_materializer::person_properties::username"
+ }
+ column "mat_pp_serverMasterclass" {
+ type = "String"
+ comment = "column_materializer::person_properties::serverMasterclass"
+ }
+ column "mat_content_length" {
+ type = "String"
+ comment = "column_materializer::properties::content_length"
+ }
+ column "mat_pp_serverMarketing" {
+ type = "String"
+ comment = "column_materializer::person_properties::serverMarketing"
+ }
+ column "mat_$browser_version" {
+ type = "String"
+ comment = "column_materializer::properties::$browser_version"
+ }
+ column "mat_pp_role" {
+ type = "String"
+ comment = "column_materializer::person_properties::role"
+ }
+ column "mat_pp_customer" {
+ type = "String"
+ comment = "column_materializer::person_properties::customer"
+ }
+ column "mat_event" {
+ type = "String"
+ comment = "column_materializer::properties::event"
+ }
+ column "mat_disable_institution_search" {
+ type = "String"
+ comment = "column_materializer::properties::disable_institution_search"
+ }
+ column "mat_is_first_event_for_user" {
+ type = "String"
+ comment = "column_materializer::properties::is_first_event_for_user"
+ }
+ column "mat_current_member_guid" {
+ type = "String"
+ comment = "column_materializer::properties::current_member_guid"
+ }
+ column "mat_user_agent" {
+ type = "String"
+ comment = "column_materializer::properties::user_agent"
+ }
+ column "mat_is_test_user" {
+ type = "String"
+ comment = "column_materializer::properties::is_test_user"
+ }
+ column "mat_referrer" {
+ type = "String"
+ comment = "column_materializer::properties::referrer"
+ }
+ column "mat_pp_$initial_current_url" {
+ type = "String"
+ comment = "column_materializer::person_properties::$initial_current_url"
+ }
+ column "mat_most_recent_app_os" {
+ type = "String"
+ comment = "column_materializer::properties::most_recent_app_os"
+ }
+ column "mat_pp_hubspot_score" {
+ type = "String"
+ comment = "column_materializer::person_properties::hubspot_score"
+ }
+ column "mat_pp_id" {
+ type = "String"
+ comment = "column_materializer::person_properties::id"
+ }
+ column "mat_pp_$current_url" {
+ type = "String"
+ comment = "column_materializer::person_properties::$current_url"
+ }
+ column "mat_product_key" {
+ type = "String"
+ comment = "column_materializer::properties::product_key"
+ }
+ column "mat_Plan_type_and_filter" {
+ type = "String"
+ comment = "column_materializer::properties::Plan type and filter"
+ }
+ column "mat_$app_namespace" {
+ type = "String"
+ comment = "column_materializer::properties::$app_namespace"
+ }
+ column "mat_$os_name" {
+ type = "String"
+ comment = "column_materializer::properties::$os_name"
+ }
+ column "mat_pp_$os_name" {
+ type = "String"
+ comment = "column_materializer::person_properties::$os_name::disabled"
+ }
+ column "mat_pp_$app_version" {
+ type = "String"
+ comment = "column_materializer::person_properties::$app_version"
+ }
+ column "mat_subscriptionStatus" {
+ type = "String"
+ comment = "column_materializer::properties::subscriptionStatus"
+ }
+ column "mat_$screen_height" {
+ type = "String"
+ comment = "column_materializer::properties::$screen_height"
+ }
+ column "mat_$screen_width" {
+ type = "String"
+ comment = "column_materializer::properties::$screen_width"
+ }
+ column "mat_tag" {
+ type = "String"
+ comment = "column_materializer::properties::tag"
+ }
+ column "mat_$app_build" {
+ type = "String"
+ comment = "column_materializer::properties::$app_build"
+ }
+ column "mat_surface_tag" {
+ type = "String"
+ comment = "column_materializer::properties::surface_tag"
+ }
+ column "mat_survey_responses_count_in_period" {
+ type = "String"
+ comment = "column_materializer::properties::survey_responses_count_in_period"
+ }
+ column "mat_event_count_in_month" {
+ type = "String"
+ comment = "column_materializer::properties::event_count_in_month"
+ }
+ column "mat_ramp" {
+ type = "String"
+ comment = "column_materializer::properties::ramp"
+ }
+ column "mat_auto_chapters" {
+ type = "String"
+ comment = "column_materializer::properties::auto_chapters"
+ }
+ column "mat_sentiment_analysis" {
+ type = "String"
+ comment = "column_materializer::properties::sentiment_analysis"
+ }
+ column "mat_redact_pii" {
+ type = "String"
+ comment = "column_materializer::properties::redact_pii"
+ }
+ column "mat_content_safety" {
+ type = "String"
+ comment = "column_materializer::properties::content_safety"
+ }
+ column "mat_iab_categories" {
+ type = "String"
+ comment = "column_materializer::properties::iab_categories"
+ }
+ column "mat_auto_highlights" {
+ type = "String"
+ comment = "column_materializer::properties::auto_highlights"
+ }
+ column "mat_entity_detection" {
+ type = "String"
+ comment = "column_materializer::properties::entity_detection"
+ }
+ column "mat_summarization" {
+ type = "String"
+ comment = "column_materializer::properties::summarization"
+ }
+ column "mat_pp_val_region" {
+ type = "String"
+ comment = "column_materializer::person_properties::val_region"
+ }
+ column "mat_client_id" {
+ type = "String"
+ comment = "column_materializer::properties::client_id"
+ }
+ column "mat_$geoip_country_code" {
+ type = "String"
+ comment = "column_materializer::properties::$geoip_country_code"
+ }
+ column "mat_disfluencies" {
+ type = "String"
+ comment = "column_materializer::properties::disfluencies"
+ }
+ column "mat_filter_profanity" {
+ type = "String"
+ comment = "column_materializer::properties::filter_profanity"
+ }
+ column "mat_speaker_labels" {
+ type = "String"
+ comment = "column_materializer::properties::speaker_labels"
+ }
+ column "mat_language_detection" {
+ type = "String"
+ comment = "column_materializer::properties::language_detection"
+ }
+ column "mat_product_analytics_projected_amount" {
+ type = "String"
+ comment = "column_materializer::properties::product_analytics_projected_amount"
+ }
+ column "mat_recordings_projected_amount" {
+ type = "String"
+ comment = "column_materializer::properties::recordings_projected_amount"
+ }
+ column "mat_events_projected_amount" {
+ type = "String"
+ comment = "column_materializer::properties::events_projected_amount"
+ }
+ column "mat_session_replay_projected_amount" {
+ type = "String"
+ comment = "column_materializer::properties::session_replay_projected_amount"
+ }
+ column "mat_total_usd" {
+ type = "String"
+ comment = "column_materializer::properties::total_usd"
+ }
+ column "mat_stripe_amount_paid" {
+ type = "String"
+ comment = "column_materializer::properties::stripe_amount_paid"
+ }
+ column "mat_workspace" {
+ type = "String"
+ comment = "column_materializer::properties::workspace"
+ }
+ column "mat_created_at" {
+ type = "String"
+ comment = "column_materializer::properties::created_at"
+ }
+ column "mat_kind" {
+ type = "String"
+ comment = "column_materializer::properties::kind"
+ }
+ column "mat_product" {
+ type = "String"
+ comment = "column_materializer::properties::product"
+ }
+ column "mat_message" {
+ type = "String"
+ comment = "column_materializer::properties::message"
+ }
+ column "mat_initiator" {
+ type = "String"
+ comment = "column_materializer::properties::initiator"
+ }
+ column "mat_query" {
+ type = "String"
+ comment = "column_materializer::properties::query"
+ }
+ column "mat_$survey_id" {
+ type = "String"
+ comment = "column_materializer::properties::$survey_id"
+ }
+ column "mat_$survey_response_1" {
+ type = "String"
+ comment = "column_materializer::properties::$survey_response_1"
+ }
+ column "mat_ticketId" {
+ type = "String"
+ comment = "column_materializer::properties::ticketId"
+ }
+ column "mat_$survey_response" {
+ type = "String"
+ comment = "column_materializer::properties::$survey_response"
+ }
+ column "mat_conceptName" {
+ type = "String"
+ comment = "column_materializer::properties::conceptName"
+ }
+ column "mat_apiName" {
+ type = "String"
+ comment = "column_materializer::properties::apiName"
+ }
+ column "mat_workplace_billing_plan" {
+ type = "String"
+ comment = "column_materializer::properties::workplace_billing_plan"
+ }
+ column "mat_$el_text" {
+ type = "String"
+ comment = "column_materializer::properties::$el_text"
+ }
+ column "mat_recording_count_in_period" {
+ type = "String"
+ comment = "column_materializer::properties::recording_count_in_period"
+ }
+ column "mat_$os_version" {
+ type = "String"
+ comment = "column_materializer::properties::$os_version"
+ }
+ column "mat_orderId" {
+ type = "String"
+ comment = "column_materializer::properties::orderId"
+ }
+ column "mat_commit_sha" {
+ type = "String"
+ comment = "column_materializer::properties::commit_sha"
+ }
+ column "mat_$feature_flag_payloads" {
+ type = "String"
+ comment = "column_materializer::properties::$feature_flag_payloads"
+ }
+ column "mat_event_count_in_period" {
+ type = "String"
+ comment = "column_materializer::properties::event_count_in_period"
+ }
+ column "mat_$groups" {
+ type = "String"
+ comment = "column_materializer::properties::$groups"
+ }
+ column "mat_$feature_flag" {
+ type = "String"
+ comment = "column_materializer::properties::$feature_flag"
+ }
+ column "mat_utm_content" {
+ type = "String"
+ comment = "column_materializer::properties::utm_content"
+ }
+ column "mat_gclid" {
+ type = "String"
+ comment = "column_materializer::properties::gclid"
+ }
+ column "mat_gad_source" {
+ type = "String"
+ comment = "column_materializer::properties::gad_source"
+ }
+ column "mat_gbraid" {
+ type = "String"
+ comment = "column_materializer::properties::gbraid"
+ }
+ column "mat_wbraid" {
+ type = "String"
+ comment = "column_materializer::properties::wbraid"
+ }
+ column "mat_fbclid" {
+ type = "String"
+ comment = "column_materializer::properties::fbclid"
+ }
+ column "mat_msclkid" {
+ type = "String"
+ comment = "column_materializer::properties::msclkid"
+ }
+ column "mat_organization_id" {
+ type = "String"
+ comment = "column_materializer::properties::organization_id"
+ }
+ column "mat_owner_type" {
+ type = "String"
+ comment = "column_materializer::properties::owner_type"
+ }
+ column "mat_device_type" {
+ type = "String"
+ comment = "column_materializer::properties::device_type"
+ }
+ column "mat_$device_id" {
+ type = "String"
+ comment = "column_materializer::properties::$device_id"
+ }
+ column "mat_pp_$geoip_continent_name" {
+ type = "String"
+ comment = "column_materializer::person_properties::$geoip_continent_name"
+ }
+ column "mat_$feature_flag_response" {
+ type = "String"
+ comment = "column_materializer::properties::$feature_flag_response"
+ }
+ column "mat_pp_utm_source" {
+ type = "String"
+ comment = "column_materializer::person_properties::utm_source"
+ }
+ column "mat_pp_$referring_domain" {
+ type = "String"
+ comment = "column_materializer::person_properties::$referring_domain"
+ }
+ column "mat_pp_Email_Domain" {
+ type = "String"
+ comment = "column_materializer::person_properties::Email Domain"
+ }
+ column "mat_machine_id" {
+ type = "String"
+ comment = "column_materializer::properties::machine_id"
+ }
+ column "mat_user_email_domain" {
+ type = "String"
+ comment = "column_materializer::properties::user_email_domain"
+ }
+ column "mat_$lib_version__minor" {
+ type = "String"
+ comment = "column_materializer::properties::$lib_version__minor"
+ }
+ column "mat_region" {
+ type = "String"
+ comment = "column_materializer::properties::region"
+ }
+ column "mat_pp_user_email_domain" {
+ type = "String"
+ comment = "column_materializer::person_properties::user_email_domain"
+ }
+ column "mat_url_promotion_id" {
+ type = "String"
+ comment = "column_materializer::properties::url_promotion_id"
+ }
+ column "mat_$lib_custom_api_host" {
+ type = "String"
+ comment = "column_materializer::properties::$lib_custom_api_host"
+ }
+ column "person_mode" {
+ type = "Enum8('full'=0, 'propertyless'=1, 'force_upgrade'=2)"
+ }
+ column "mat_user_platform" {
+ type = "String"
+ comment = "column_materializer::properties::user_platform"
+ }
+ column "mat_pp_$geoip_country_name" {
+ type = "String"
+ comment = "column_materializer::person_properties::$geoip_country_name"
+ }
+ column "mat_environment" {
+ type = "String"
+ comment = "column_materializer::properties::environment"
+ }
+ column "mat_customer_email" {
+ type = "String"
+ comment = "column_materializer::properties::customer_email"
+ }
+ column "mat_client_name" {
+ type = "String"
+ comment = "column_materializer::properties::client_name"
+ }
+ column "mat_screen_name" {
+ type = "String"
+ comment = "column_materializer::properties::screen_name"
+ }
+ column "mat_app_version" {
+ type = "String"
+ comment = "column_materializer::properties::app_version"
+ }
+ column "elements_chain_href" {
+ type = "String"
+ comment = "column_materializer::elements_chain::href"
+ }
+ column "elements_chain_texts" {
+ type = "Array(String)"
+ comment = "column_materializer::elements_chain::texts"
+ }
+ column "elements_chain_ids" {
+ type = "Array(String)"
+ comment = "column_materializer::elements_chain::ids"
+ }
+ column "elements_chain_elements" {
+ type = "Array(Enum8('a'=1, 'button'=2, 'form'=3, 'input'=4, 'select'=5, 'textarea'=6, 'label'=7))"
+ comment = "column_materializer::elements_chain::elements"
+ }
+ column "properties_group_custom" {
+ type = "Map(String, String)"
+ }
+ column "properties_group_feature_flags" {
+ type = "Map(String, String)"
+ }
+ column "is_deleted" {
+ type = "Bool"
+ }
+ column "mat_subdomain" {
+ type = "String"
+ comment = "column_materializer::properties::subdomain"
+ }
+ column "mat_$device" {
+ type = "String"
+ comment = "column_materializer::properties::$device"
+ }
+ column "mat_id" {
+ type = "String"
+ comment = "column_materializer::properties::id"
+ }
+ column "mat_record_id" {
+ type = "String"
+ comment = "column_materializer::properties::record_id"
+ }
+ column "mat_referrer_id" {
+ type = "String"
+ comment = "column_materializer::properties::record_id"
+ }
+ column "mat_$exception_issue_id" {
+ type = "Nullable(String)"
+ comment = "column_materializer::properties::$exception_issue_id"
+ }
+ column "mat_$exception_fingerprint" {
+ type = "Nullable(String)"
+ comment = "column_materializer::properties::$exception_fingerprint"
+ }
+ column "mat_$web_vitals_LCP_value" {
+ type = "Nullable(String)"
+ comment = "column_materializer::properties::$web_vitals_LCP_value"
+ }
+ column "mat_$web_vitals_FCP_value" {
+ type = "Nullable(String)"
+ comment = "column_materializer::properties::$web_vitals_FCP_value"
+ }
+ column "mat_$web_vitals_CLS_value" {
+ type = "Nullable(String)"
+ comment = "column_materializer::properties::$web_vitals_CLS_value"
+ }
+ column "mat_$web_vitals_INP_value" {
+ type = "Nullable(String)"
+ comment = "column_materializer::properties::$web_vitals_INP_value"
+ }
+ column "mat_$viewport_width" {
+ type = "Nullable(String)"
+ comment = "column_materializer::properties::$viewport_width"
+ }
+ column "mat_$viewport_height" {
+ type = "Nullable(String)"
+ comment = "column_materializer::properties::$viewport_height"
+ }
+ column "mat_$anon_distinct_id" {
+ type = "Nullable(String)"
+ comment = "column_materializer::properties::$anon_distinct_id"
+ }
+ column "person_properties_map_custom" {
+ type = "Map(String, String)"
+ }
+ column "mat_$ai_trace_id" {
+ type = "Nullable(String)"
+ comment = "column_materializer::properties::$ai_trace_id"
+ }
+ column "mat_$ai_model" {
+ type = "Nullable(String)"
+ comment = "column_materializer::properties::$ai_model"
+ }
+ column "mat_$ai_provider" {
+ type = "Nullable(String)"
+ comment = "column_materializer::properties::$ai_provider"
+ }
+ column "mat_$ai_parent_id" {
+ type = "Nullable(String)"
+ comment = "column_materializer::properties::$ai_parent_id"
+ }
+ column "mat_$ai_span_id" {
+ type = "Nullable(String)"
+ comment = "column_materializer::properties::$ai_span_id"
+ }
+ column "mat_$ai_http_status" {
+ type = "Nullable(String)"
+ comment = "column_materializer::properties::$ai_http_status"
+ }
+ column "mat_$exception_types" {
+ type = "Nullable(String)"
+ comment = "column_materializer::properties::$exception_types"
+ }
+ column "mat_$exception_values" {
+ type = "Nullable(String)"
+ comment = "column_materializer::properties::$exception_values"
+ }
+ column "mat_$exception_sources" {
+ type = "Nullable(String)"
+ comment = "column_materializer::properties::$exception_sources"
+ }
+ column "mat_$exception_functions" {
+ type = "Nullable(String)"
+ comment = "column_materializer::properties::$exception_functions"
+ }
+ column "$session_id_uuid" {
+ type = "Nullable(UInt128)"
+ }
+ column "mat_$process_person_profile" {
+ type = "Nullable(String)"
+ comment = "column_materializer::properties::$process_person_profile"
+ }
+ column "consumer_breadcrumbs" {
+ type = "Array(String)"
+ }
+ column "properties_group_ai" {
+ type = "Map(String, String)"
+ }
+ column "mat_$is_identified" {
+ type = "Nullable(String)"
+ comment = "column_materializer::properties::$is_identified"
+ }
+ column "mat_historical_migration" {
+ type = "Nullable(String)"
+ comment = "column_materializer::properties::historical_migration"
+ }
+ column "mat_$ai_session_id" {
+ type = "Nullable(String)"
+ comment = "column_materializer::properties::$ai_session_id"
+ }
+ column "mat_$ai_is_error" {
+ type = "Nullable(String)"
+ comment = "column_materializer::properties::$ai_is_error"
+ }
+ column "dmat_string_0" {
+ type = "Nullable(String)"
+ }
+ column "dmat_string_1" {
+ type = "Nullable(String)"
+ }
+ column "dmat_string_2" {
+ type = "Nullable(String)"
+ }
+ column "dmat_string_3" {
+ type = "Nullable(String)"
+ }
+ column "dmat_string_4" {
+ type = "Nullable(String)"
+ }
+ column "dmat_string_5" {
+ type = "Nullable(String)"
+ }
+ column "dmat_string_6" {
+ type = "Nullable(String)"
+ }
+ column "dmat_string_7" {
+ type = "Nullable(String)"
+ }
+ column "dmat_string_8" {
+ type = "Nullable(String)"
+ }
+ column "dmat_string_9" {
+ type = "Nullable(String)"
+ }
+ column "dmat_numeric_0" {
+ type = "Nullable(Float64)"
+ }
+ column "dmat_numeric_1" {
+ type = "Nullable(Float64)"
+ }
+ column "dmat_numeric_2" {
+ type = "Nullable(Float64)"
+ }
+ column "dmat_numeric_3" {
+ type = "Nullable(Float64)"
+ }
+ column "dmat_numeric_4" {
+ type = "Nullable(Float64)"
+ }
+ column "dmat_numeric_5" {
+ type = "Nullable(Float64)"
+ }
+ column "dmat_numeric_6" {
+ type = "Nullable(Float64)"
+ }
+ column "dmat_numeric_7" {
+ type = "Nullable(Float64)"
+ }
+ column "dmat_numeric_8" {
+ type = "Nullable(Float64)"
+ }
+ column "dmat_numeric_9" {
+ type = "Nullable(Float64)"
+ }
+ column "dmat_bool_0" {
+ type = "Nullable(UInt8)"
+ }
+ column "dmat_bool_1" {
+ type = "Nullable(UInt8)"
+ }
+ column "dmat_bool_2" {
+ type = "Nullable(UInt8)"
+ }
+ column "dmat_bool_3" {
+ type = "Nullable(UInt8)"
+ }
+ column "dmat_bool_4" {
+ type = "Nullable(UInt8)"
+ }
+ column "dmat_bool_5" {
+ type = "Nullable(UInt8)"
+ }
+ column "dmat_bool_6" {
+ type = "Nullable(UInt8)"
+ }
+ column "dmat_bool_7" {
+ type = "Nullable(UInt8)"
+ }
+ column "dmat_bool_8" {
+ type = "Nullable(UInt8)"
+ }
+ column "dmat_bool_9" {
+ type = "Nullable(UInt8)"
+ }
+ column "dmat_datetime_0" {
+ type = "Nullable(DateTime64(6, 'UTC'))"
+ }
+ column "dmat_datetime_1" {
+ type = "Nullable(DateTime64(6, 'UTC'))"
+ }
+ column "dmat_datetime_2" {
+ type = "Nullable(DateTime64(6, 'UTC'))"
+ }
+ column "dmat_datetime_3" {
+ type = "Nullable(DateTime64(6, 'UTC'))"
+ }
+ column "dmat_datetime_4" {
+ type = "Nullable(DateTime64(6, 'UTC'))"
+ }
+ column "dmat_datetime_5" {
+ type = "Nullable(DateTime64(6, 'UTC'))"
+ }
+ column "dmat_datetime_6" {
+ type = "Nullable(DateTime64(6, 'UTC'))"
+ }
+ column "dmat_datetime_7" {
+ type = "Nullable(DateTime64(6, 'UTC'))"
+ }
+ column "dmat_datetime_8" {
+ type = "Nullable(DateTime64(6, 'UTC'))"
+ }
+ column "dmat_datetime_9" {
+ type = "Nullable(DateTime64(6, 'UTC'))"
+ }
+ column "historical_migration" {
+ type = "Bool"
+ }
+ column "mat_$ai_total_cost_usd" {
+ type = "Nullable(String)"
+ comment = "column_materializer::properties::$ai_total_cost_usd"
+ }
+ column "properties_group_ai_large" {
+ type = "Map(String, String)"
+ }
+ column "mat_$ai_prompt_name" {
+ type = "Nullable(String)"
+ comment = "column_materializer::properties::$ai_prompt_name"
+ }
+ engine "distributed" {
+ cluster_name = "posthog"
+ remote_database = "posthog"
+ remote_table = "sharded_events"
+ sharding_key = "sipHash64(distinct_id)"
+ }
+ }
+
+ 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_old_ops" {
+ 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 "distributed" {
+ cluster_name = "ops"
+ remote_database = "posthog"
+ remote_table = "query_log_archive_old"
+ }
+ }
+
+ table "raw_sessions_v3" {
+ order_by = ["team_id", "session_timestamp", "session_id_v7"]
+ partition_by = "toYYYYMM(session_timestamp)"
+ settings = {
+ index_granularity = "8192"
+ }
+ 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, 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
+ }
+ engine "aggregating_merge_tree" {
+ }
+ }
+
+ 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"
+ }
+ }
+
+ 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)"
+ }
+ }
+
+ 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
+
+ }
+}
diff --git a/posthog/clickhouse/hcl/nodes b/posthog/clickhouse/hcl/nodes
index 018f219fb04d..6851d658201b 100644
--- a/posthog/clickhouse/hcl/nodes
+++ b/posthog/clickhouse/hcl/nodes
@@ -46,7 +46,29 @@ dev ai_events roles/shared
prod-us ai_events roles/shared roles/ai_events/shared roles/ai_events/prod
prod-eu ai_events roles/shared roles/ai_events/shared roles/ai_events/prod
+# AUX satellite: auxiliary tables (error tracking, hog invocations, message assets,
+# property values, web/marketing preaggregated). roles/aux/shared holds the env-uniform
+# objects; local carries the MSK ingest variant (kafka_error_tracking + its MV, MSK
+# kafka_hog_invocation_results); prod carries the WarpStream variant. prod-us adds the
+# ingestion_warnings tables. prod goldens are dump-baselined (not live-verifiable here).
+local aux roles/shared roles/aux/shared roles/aux/local
+prod-us aux roles/shared roles/aux/shared roles/aux/prod roles/aux/prod-us
+prod-eu aux roles/shared roles/aux/shared roles/aux/prod roles/aux/prod-eu
+
+# SESSIONS satellite: the local node runs only the shared query_log_archive path
+# (session tables are prod-only), so it composes roles/shared alone. prod nodes host
+# the session tables (sessions, raw_sessions, raw_sessions_v3), the events replica,
+# channel_definition + web_pre_aggregated_teams (+ their dictionaries), and person
+# join tables. roles/sessions/shared holds the env-uniform objects; prod-us/prod-eu
+# carry the env-specific channel_definition / events / raw_sessions_v3 (prod-us also
+# has writable_events_recent). prod goldens are dump-baselined (not live-verifiable here).
+local sessions roles/shared
+prod-us sessions roles/shared roles/sessions/shared roles/sessions/prod-us
+prod-eu sessions roles/shared roles/sessions/shared roles/sessions/prod-eu
+
+# SESSIONSV3 satellite: US-only node hosting the v3 session tables (events replica,
+# raw_sessions_v3) plus the query_log_archive path. Dump-baselined.
+prod-us sessionsv3 roles/shared roles/sessionsv3/prod-us
+
# prod-us data roles/shared roles/data/shared roles/data/prod-us
# prod-us endpoints roles/shared
-# prod-us aux roles/shared
-# prod-us sessions roles/shared
diff --git a/posthog/clickhouse/hcl/roles/aux/local/sql/error_tracking_fingerprint_issue_state_mv.sql b/posthog/clickhouse/hcl/roles/aux/local/sql/error_tracking_fingerprint_issue_state_mv.sql
new file mode 100644
index 000000000000..c6cb1d56fde9
--- /dev/null
+++ b/posthog/clickhouse/hcl/roles/aux/local/sql/error_tracking_fingerprint_issue_state_mv.sql
@@ -0,0 +1,16 @@
+SELECT
+ team_id,
+ fingerprint,
+ issue_id,
+ issue_name,
+ issue_description,
+ issue_status,
+ assigned_user_id,
+ assigned_role_id,
+ first_seen,
+ is_deleted,
+ version,
+ _timestamp,
+ _offset,
+ _partition
+FROM posthog.kafka_error_tracking_fingerprint_issue_state
diff --git a/posthog/clickhouse/hcl/roles/aux/local/tables.hcl b/posthog/clickhouse/hcl/roles/aux/local/tables.hcl
new file mode 100644
index 000000000000..b34f9404d675
--- /dev/null
+++ b/posthog/clickhouse/hcl/roles/aux/local/tables.hcl
@@ -0,0 +1,270 @@
+database "posthog" {
+ table "hog_invocation_results_data" {
+ order_by = ["team_id", "function_kind", "function_id", "invocation_id"]
+ partition_by = "toYYYYMMDD(scheduled_at)"
+ ttl = "toDate(scheduled_at) + toIntervalDay(30)"
+ settings = {
+ index_granularity = "1024"
+ ttl_only_drop_parts = "1"
+ }
+ column "team_id" {
+ type = "Int64"
+ }
+ column "function_kind" {
+ type = "LowCardinality(String)"
+ }
+ column "function_id" {
+ type = "String"
+ }
+ column "invocation_id" {
+ type = "String"
+ }
+ column "parent_run_id" {
+ type = "String"
+ }
+ column "status" {
+ type = "LowCardinality(String)"
+ }
+ column "attempts" {
+ type = "UInt8"
+ }
+ column "is_retry" {
+ type = "UInt8"
+ }
+ column "scheduled_at" {
+ type = "DateTime64(6, 'UTC')"
+ }
+ column "first_scheduled_at" {
+ type = "DateTime64(6, 'UTC')"
+ default = "scheduled_at"
+ }
+ column "started_at" {
+ type = "Nullable(DateTime64(6, 'UTC'))"
+ }
+ column "finished_at" {
+ type = "Nullable(DateTime64(6, 'UTC'))"
+ }
+ column "duration_ms" {
+ type = "Nullable(UInt32)"
+ }
+ column "error_kind" {
+ type = "LowCardinality(String)"
+ }
+ column "error_message" {
+ type = "String"
+ }
+ column "event_uuid" {
+ type = "String"
+ }
+ column "distinct_id" {
+ type = "String"
+ }
+ column "person_id" {
+ type = "String"
+ }
+ column "invocation_globals" {
+ type = "String"
+ }
+ column "version" {
+ type = "UInt64"
+ }
+ column "is_deleted" {
+ type = "UInt8"
+ default = "0"
+ }
+ column "_timestamp" {
+ type = "DateTime"
+ }
+ column "_offset" {
+ type = "UInt64"
+ }
+ column "_partition" {
+ type = "UInt64"
+ }
+ index "status_idx" {
+ expr = "status"
+ type = "set(8)"
+ granularity = 1
+ }
+ index "function_idx" {
+ expr = "function_id"
+ type = "bloom_filter(0.01)"
+ granularity = 1
+ }
+ index "event_uuid_idx" {
+ expr = "event_uuid"
+ type = "bloom_filter(0.01)"
+ granularity = 1
+ }
+ index "is_retry_idx" {
+ expr = "is_retry"
+ type = "set(2)"
+ granularity = 1
+ }
+ engine "replicated_replacing_merge_tree" {
+ zoo_path = "/clickhouse/tables/noshard/posthog.hog_invocation_results_data"
+ replica_name = "{replica}-{shard}"
+ version_column = "version"
+ }
+ }
+ table "kafka_error_tracking_fingerprint_issue_state" {
+ column "team_id" {
+ type = "Int64"
+ }
+ column "fingerprint" {
+ type = "String"
+ }
+ column "issue_id" {
+ type = "UUID"
+ }
+ column "issue_name" {
+ type = "Nullable(String)"
+ }
+ column "issue_description" {
+ type = "Nullable(String)"
+ }
+ column "issue_status" {
+ type = "String"
+ }
+ column "assigned_user_id" {
+ type = "Nullable(Int64)"
+ }
+ column "assigned_role_id" {
+ type = "Nullable(UUID)"
+ }
+ column "first_seen" {
+ type = "DateTime64(3, 'UTC')"
+ }
+ column "is_deleted" {
+ type = "Int8"
+ }
+ column "version" {
+ type = "Int64"
+ }
+ engine "kafka" {
+ broker_list = "msk_cluster"
+ topic_list = "kafka_topic_list = 'clickhouse_error_tracking_fingerprint_issue_state'"
+ group_name = "kafka_group_name = 'clickhouse-error-tracking-fingerprint-issue-state'"
+ format = "kafka_format = 'JSONEachRow'"
+ }
+ }
+ table "kafka_hog_invocation_results" {
+ column "team_id" {
+ type = "Int64"
+ }
+ column "function_kind" {
+ type = "LowCardinality(String)"
+ }
+ column "function_id" {
+ type = "String"
+ }
+ column "invocation_id" {
+ type = "String"
+ }
+ column "parent_run_id" {
+ type = "String"
+ }
+ column "status" {
+ type = "LowCardinality(String)"
+ }
+ column "attempts" {
+ type = "UInt8"
+ }
+ column "is_retry" {
+ type = "UInt8"
+ }
+ column "scheduled_at" {
+ type = "DateTime64(6, 'UTC')"
+ }
+ column "first_scheduled_at" {
+ type = "DateTime64(6, 'UTC')"
+ }
+ column "started_at" {
+ type = "Nullable(DateTime64(6, 'UTC'))"
+ }
+ column "finished_at" {
+ type = "Nullable(DateTime64(6, 'UTC'))"
+ }
+ column "duration_ms" {
+ type = "Nullable(UInt32)"
+ }
+ column "error_kind" {
+ type = "LowCardinality(String)"
+ }
+ column "error_message" {
+ type = "String"
+ }
+ column "event_uuid" {
+ type = "String"
+ }
+ column "distinct_id" {
+ type = "String"
+ }
+ column "person_id" {
+ type = "String"
+ }
+ column "invocation_globals" {
+ type = "String"
+ }
+ column "version" {
+ type = "UInt64"
+ }
+ column "is_deleted" {
+ type = "UInt8"
+ }
+ engine "kafka" {
+ broker_list = "warpstream_cyclotron"
+ topic_list = "kafka_topic_list = 'clickhouse_hog_invocation_results'"
+ group_name = "kafka_group_name = 'clickhouse_hog_invocation_results'"
+ format = "kafka_format = 'JSONEachRow'"
+ skip_broken_messages = 100
+ }
+ }
+ materialized_view "error_tracking_fingerprint_issue_state_mv" {
+ to_table = "posthog.writable_error_tracking_fingerprint_issue_state"
+ query = file("sql/error_tracking_fingerprint_issue_state_mv.sql")
+
+ column "team_id" {
+ type = "Int64"
+ }
+ column "fingerprint" {
+ type = "String"
+ }
+ column "issue_id" {
+ type = "UUID"
+ }
+ column "issue_name" {
+ type = "Nullable(String)"
+ }
+ column "issue_description" {
+ type = "Nullable(String)"
+ }
+ column "issue_status" {
+ type = "String"
+ }
+ column "assigned_user_id" {
+ type = "Nullable(Int64)"
+ }
+ column "assigned_role_id" {
+ type = "Nullable(UUID)"
+ }
+ column "first_seen" {
+ type = "DateTime64(3, 'UTC')"
+ }
+ column "is_deleted" {
+ type = "Int8"
+ }
+ column "version" {
+ type = "Int64"
+ }
+ column "_timestamp" {
+ type = "Nullable(DateTime)"
+ }
+ column "_offset" {
+ type = "UInt64"
+ }
+ column "_partition" {
+ type = "UInt64"
+ }
+ }
+}
diff --git a/posthog/clickhouse/hcl/roles/aux/prod-eu/tables.hcl b/posthog/clickhouse/hcl/roles/aux/prod-eu/tables.hcl
new file mode 100644
index 000000000000..33d91f1ebdf6
--- /dev/null
+++ b/posthog/clickhouse/hcl/roles/aux/prod-eu/tables.hcl
@@ -0,0 +1,74 @@
+database "posthog" {
+ table "kafka_hog_invocation_results" {
+ column "team_id" {
+ type = "Int64"
+ }
+ column "function_kind" {
+ type = "LowCardinality(String)"
+ }
+ column "function_id" {
+ type = "String"
+ }
+ column "invocation_id" {
+ type = "String"
+ }
+ column "parent_run_id" {
+ type = "String"
+ }
+ column "status" {
+ type = "LowCardinality(String)"
+ }
+ column "attempts" {
+ type = "UInt8"
+ }
+ column "is_retry" {
+ type = "UInt8"
+ }
+ column "scheduled_at" {
+ type = "DateTime64(6, 'UTC')"
+ }
+ column "first_scheduled_at" {
+ type = "DateTime64(6, 'UTC')"
+ }
+ column "started_at" {
+ type = "Nullable(DateTime64(6, 'UTC'))"
+ }
+ column "finished_at" {
+ type = "Nullable(DateTime64(6, 'UTC'))"
+ }
+ column "duration_ms" {
+ type = "Nullable(UInt32)"
+ }
+ column "error_kind" {
+ type = "LowCardinality(String)"
+ }
+ column "error_message" {
+ type = "String"
+ }
+ column "event_uuid" {
+ type = "String"
+ }
+ column "distinct_id" {
+ type = "String"
+ }
+ column "person_id" {
+ type = "String"
+ }
+ column "invocation_globals" {
+ type = "String"
+ }
+ column "version" {
+ type = "UInt64"
+ }
+ column "is_deleted" {
+ type = "UInt8"
+ }
+ engine "kafka" {
+ broker_list = "warpstream_cyclotron"
+ topic_list = "kafka_topic_list = 'clickhouse_hog_invocation_results'"
+ group_name = "kafka_group_name = 'clickhouse_hog_invocation_results'"
+ format = "kafka_format = 'JSONEachRow'"
+ skip_broken_messages = 100
+ }
+ }
+}
diff --git a/posthog/clickhouse/hcl/roles/aux/prod-us/tables.hcl b/posthog/clickhouse/hcl/roles/aux/prod-us/tables.hcl
new file mode 100644
index 000000000000..bbd5f5aaebf5
--- /dev/null
+++ b/posthog/clickhouse/hcl/roles/aux/prod-us/tables.hcl
@@ -0,0 +1,146 @@
+database "posthog" {
+ table "kafka_hog_invocation_results" {
+ column "team_id" {
+ type = "Int64"
+ }
+ column "function_kind" {
+ type = "LowCardinality(String)"
+ }
+ column "function_id" {
+ type = "String"
+ }
+ column "invocation_id" {
+ type = "String"
+ }
+ column "parent_run_id" {
+ type = "String"
+ }
+ column "status" {
+ type = "LowCardinality(String)"
+ }
+ column "attempts" {
+ type = "UInt8"
+ }
+ column "is_retry" {
+ type = "UInt8"
+ }
+ column "scheduled_at" {
+ type = "DateTime64(6, 'UTC')"
+ }
+ column "first_scheduled_at" {
+ type = "DateTime64(6, 'UTC')"
+ }
+ column "started_at" {
+ type = "Nullable(DateTime64(6, 'UTC'))"
+ }
+ column "finished_at" {
+ type = "Nullable(DateTime64(6, 'UTC'))"
+ }
+ column "duration_ms" {
+ type = "Nullable(UInt32)"
+ }
+ column "error_kind" {
+ type = "LowCardinality(String)"
+ }
+ column "error_message" {
+ type = "String"
+ }
+ column "event_uuid" {
+ type = "String"
+ }
+ column "distinct_id" {
+ type = "String"
+ }
+ column "person_id" {
+ type = "String"
+ }
+ column "invocation_globals" {
+ type = "String"
+ }
+ column "version" {
+ type = "UInt64"
+ }
+ column "is_deleted" {
+ type = "UInt8"
+ }
+ engine "kafka" {
+ broker_list = "warpstream_cyclotron"
+ topic_list = "kafka_topic_list = 'clickhouse_hog_invocation_results'"
+ group_name = "kafka_group_name = 'clickhouse_hog_invocation_results'"
+ format = "kafka_format = 'JSONEachRow'"
+ num_consumers = 1
+ max_block_size = 100000
+ skip_broken_messages = 100
+ poll_timeout_ms = 10000
+ thread_per_consumer = true
+ }
+ }
+ table "ingestion_warnings_main" {
+ 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 "sharded_ingestion_warnings" {
+ order_by = ["team_id", "toHour(timestamp)", "type", "source", "timestamp"]
+ partition_by = "toYear(timestamp)"
+ settings = {
+ index_granularity = "8192"
+ }
+ column "team_id" {
+ type = "Int64"
+ }
+ column "source" {
+ type = "LowCardinality(String)"
+ }
+ column "type" {
+ type = "String"
+ }
+ column "details" {
+ type = "String"
+ }
+ column "timestamp" {
+ type = "DateTime64(6, 'UTC')"
+ }
+ column "_timestamp" {
+ type = "DateTime"
+ }
+ column "_offset" {
+ type = "UInt64"
+ }
+ column "_partition" {
+ type = "UInt64"
+ }
+ engine "replicated_merge_tree" {
+ zoo_path = "/clickhouse/tables/reshard/{shard}/posthog.sharded_ingestion_warnings"
+ replica_name = "{replica}"
+ }
+ }
+}
diff --git a/posthog/clickhouse/hcl/roles/aux/prod/tables.hcl b/posthog/clickhouse/hcl/roles/aux/prod/tables.hcl
new file mode 100644
index 000000000000..94712c258f90
--- /dev/null
+++ b/posthog/clickhouse/hcl/roles/aux/prod/tables.hcl
@@ -0,0 +1,111 @@
+database "posthog" {
+ table "hog_invocation_results_data" {
+ order_by = ["team_id", "function_kind", "function_id", "invocation_id"]
+ partition_by = "toYYYYMMDD(scheduled_at)"
+ ttl = "toDate(scheduled_at) + toIntervalDay(30)"
+ settings = {
+ index_granularity = "1024"
+ storage_policy = "s3_tiered"
+ ttl_only_drop_parts = "1"
+ }
+ column "team_id" {
+ type = "Int64"
+ }
+ column "function_kind" {
+ type = "LowCardinality(String)"
+ }
+ column "function_id" {
+ type = "String"
+ }
+ column "invocation_id" {
+ type = "String"
+ }
+ column "parent_run_id" {
+ type = "String"
+ }
+ column "status" {
+ type = "LowCardinality(String)"
+ }
+ column "attempts" {
+ type = "UInt8"
+ }
+ column "is_retry" {
+ type = "UInt8"
+ }
+ column "scheduled_at" {
+ type = "DateTime64(6, 'UTC')"
+ }
+ column "first_scheduled_at" {
+ type = "DateTime64(6, 'UTC')"
+ default = "scheduled_at"
+ }
+ column "started_at" {
+ type = "Nullable(DateTime64(6, 'UTC'))"
+ }
+ column "finished_at" {
+ type = "Nullable(DateTime64(6, 'UTC'))"
+ }
+ column "duration_ms" {
+ type = "Nullable(UInt32)"
+ }
+ column "error_kind" {
+ type = "LowCardinality(String)"
+ }
+ column "error_message" {
+ type = "String"
+ }
+ column "event_uuid" {
+ type = "String"
+ }
+ column "distinct_id" {
+ type = "String"
+ }
+ column "person_id" {
+ type = "String"
+ }
+ column "invocation_globals" {
+ type = "String"
+ }
+ column "version" {
+ type = "UInt64"
+ }
+ column "is_deleted" {
+ type = "UInt8"
+ default = "0"
+ }
+ column "_timestamp" {
+ type = "DateTime"
+ }
+ column "_offset" {
+ type = "UInt64"
+ }
+ column "_partition" {
+ type = "UInt64"
+ }
+ index "status_idx" {
+ expr = "status"
+ type = "set(8)"
+ granularity = 1
+ }
+ index "function_idx" {
+ expr = "function_id"
+ type = "bloom_filter(0.01)"
+ granularity = 1
+ }
+ index "event_uuid_idx" {
+ expr = "event_uuid"
+ type = "bloom_filter(0.01)"
+ granularity = 1
+ }
+ index "is_retry_idx" {
+ expr = "is_retry"
+ type = "set(2)"
+ granularity = 1
+ }
+ engine "replicated_replacing_merge_tree" {
+ zoo_path = "/clickhouse/tables/noshard/posthog.hog_invocation_results_data"
+ replica_name = "{replica}-{shard}"
+ version_column = "version"
+ }
+ }
+}
diff --git a/posthog/clickhouse/hcl/roles/aux/shared/sql/hog_invocation_results_mv.sql b/posthog/clickhouse/hcl/roles/aux/shared/sql/hog_invocation_results_mv.sql
new file mode 100644
index 000000000000..83900cfc5ad2
--- /dev/null
+++ b/posthog/clickhouse/hcl/roles/aux/shared/sql/hog_invocation_results_mv.sql
@@ -0,0 +1,30 @@
+SELECT
+ team_id,
+ function_kind,
+ function_id,
+ invocation_id,
+ parent_run_id,
+ status,
+ attempts,
+ is_retry,
+ scheduled_at,
+ if(
+ first_scheduled_at = toDateTime64('1970-01-01 00:00:00', 6, 'UTC'),
+ scheduled_at,
+ first_scheduled_at
+ ) AS first_scheduled_at,
+ started_at,
+ finished_at,
+ duration_ms,
+ error_kind,
+ error_message,
+ event_uuid,
+ distinct_id,
+ person_id,
+ invocation_globals,
+ version,
+ is_deleted,
+ _timestamp,
+ _offset,
+ _partition
+FROM posthog.kafka_hog_invocation_results
diff --git a/posthog/clickhouse/hcl/roles/aux/shared/sql/message_assets_mv.sql b/posthog/clickhouse/hcl/roles/aux/shared/sql/message_assets_mv.sql
new file mode 100644
index 000000000000..0e4fc0c75893
--- /dev/null
+++ b/posthog/clickhouse/hcl/roles/aux/shared/sql/message_assets_mv.sql
@@ -0,0 +1,21 @@
+SELECT
+ team_id,
+ function_kind,
+ function_id,
+ parent_run_id,
+ invocation_id,
+ action_id,
+ kind,
+ distinct_id,
+ person_id,
+ recipient,
+ subject,
+ status,
+ sent_at,
+ version,
+ is_deleted,
+ html,
+ _timestamp,
+ _offset,
+ _partition
+FROM posthog.kafka_message_assets
diff --git a/posthog/clickhouse/hcl/roles/aux/shared/sql/property_values_mv.sql b/posthog/clickhouse/hcl/roles/aux/shared/sql/property_values_mv.sql
new file mode 100644
index 000000000000..37cf38ed7afc
--- /dev/null
+++ b/posthog/clickhouse/hcl/roles/aux/shared/sql/property_values_mv.sql
@@ -0,0 +1,8 @@
+SELECT
+ team_id,
+ property_type,
+ property_key,
+ property_value,
+ property_count,
+ coalesce(_timestamp, now()) AS last_seen
+FROM posthog.kafka_property_values
diff --git a/posthog/clickhouse/hcl/roles/aux/shared/tables.hcl b/posthog/clickhouse/hcl/roles/aux/shared/tables.hcl
new file mode 100644
index 000000000000..ece7b5d0fdf5
--- /dev/null
+++ b/posthog/clickhouse/hcl/roles/aux/shared/tables.hcl
@@ -0,0 +1,2757 @@
+database "posthog" {
+ 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 "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 "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 "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 "kafka_message_assets" {
+ column "team_id" {
+ type = "Int64"
+ }
+ column "function_kind" {
+ type = "LowCardinality(String)"
+ }
+ column "function_id" {
+ type = "String"
+ }
+ column "parent_run_id" {
+ type = "String"
+ }
+ column "invocation_id" {
+ type = "String"
+ }
+ column "action_id" {
+ type = "String"
+ }
+ column "kind" {
+ type = "LowCardinality(String)"
+ }
+ column "distinct_id" {
+ type = "String"
+ }
+ column "person_id" {
+ type = "String"
+ }
+ column "recipient" {
+ type = "String"
+ }
+ column "subject" {
+ type = "String"
+ }
+ column "status" {
+ type = "LowCardinality(String)"
+ }
+ column "sent_at" {
+ type = "DateTime64(6, 'UTC')"
+ }
+ column "version" {
+ type = "UInt64"
+ }
+ column "is_deleted" {
+ type = "UInt8"
+ }
+ column "html" {
+ type = "String"
+ }
+ engine "kafka" {
+ broker_list = "warpstream_cyclotron"
+ topic_list = "kafka_topic_list = 'clickhouse_message_assets'"
+ group_name = "kafka_group_name = 'clickhouse_message_assets'"
+ format = "kafka_format = 'JSONEachRow'"
+ skip_broken_messages = 100
+ }
+ }
+ table "kafka_property_values" {
+ column "team_id" {
+ type = "Int64"
+ }
+ column "property_type" {
+ type = "LowCardinality(String)"
+ }
+ column "property_key" {
+ type = "String"
+ }
+ column "property_value" {
+ type = "String"
+ }
+ column "property_count" {
+ type = "UInt64"
+ }
+ engine "kafka" {
+ broker_list = "warpstream_ingestion"
+ topic_list = "kafka_topic_list = 'clickhouse_property_values'"
+ group_name = "kafka_group_name = 'clickhouse_property_values'"
+ format = "kafka_format = 'JSONEachRow'"
+ num_consumers = 8
+ thread_per_consumer = true
+ }
+ }
+ table "marketing_conversions_preaggregated" {
+ column "team_id" {
+ type = "Int64"
+ }
+ column "job_id" {
+ type = "UUID"
+ }
+ column "person_id" {
+ type = "UUID"
+ }
+ column "conversion_timestamp" {
+ type = "DateTime64(6, 'UTC')"
+ }
+ column "conversion_math_value" {
+ type = "Float64"
+ }
+ column "session_id" {
+ type = "String"
+ }
+ column "campaign_name" {
+ type = "String"
+ }
+ column "source_name" {
+ type = "String"
+ }
+ column "medium_name" {
+ type = "String"
+ }
+ column "content_name" {
+ type = "String"
+ }
+ column "term_name" {
+ type = "String"
+ }
+ column "referring_domain_name" {
+ type = "String"
+ }
+ column "gclid_name" {
+ type = "String"
+ }
+ column "fbclid_name" {
+ type = "String"
+ }
+ column "gad_source_name" {
+ type = "String"
+ }
+ column "computed_at" {
+ type = "DateTime64(6, 'UTC')"
+ default = "now()"
+ }
+ column "expires_at" {
+ type = "Date"
+ default = "today() + toIntervalDay(7)"
+ }
+ engine "distributed" {
+ cluster_name = "aux"
+ remote_database = "posthog"
+ remote_table = "sharded_marketing_conversions_preaggregated"
+ sharding_key = "cityHash64(person_id)"
+ }
+ }
+ table "marketing_costs_preaggregated" {
+ column "team_id" {
+ type = "Int64"
+ }
+ column "job_id" {
+ type = "UUID"
+ }
+ column "source_id" {
+ type = "String"
+ }
+ column "source_name" {
+ type = "String"
+ }
+ column "grain" {
+ type = "LowCardinality(String)"
+ }
+ column "match_key" {
+ type = "String"
+ }
+ column "campaign_id" {
+ type = "String"
+ }
+ column "campaign_name" {
+ type = "String"
+ }
+ column "ad_group_id" {
+ type = "String"
+ }
+ column "ad_group_name" {
+ type = "String"
+ }
+ column "ad_id" {
+ type = "String"
+ }
+ column "ad_name" {
+ type = "String"
+ }
+ column "cost_date" {
+ type = "Date"
+ }
+ column "cost" {
+ type = "Float64"
+ }
+ column "clicks" {
+ type = "Float64"
+ }
+ column "impressions" {
+ type = "Float64"
+ }
+ column "reported_conversions" {
+ type = "Float64"
+ }
+ column "reported_conversion_value" {
+ type = "Float64"
+ }
+ column "computed_at" {
+ type = "DateTime64(6, 'UTC')"
+ default = "now()"
+ }
+ column "expires_at" {
+ type = "Date"
+ default = "today() + toIntervalDay(7)"
+ }
+ engine "distributed" {
+ cluster_name = "aux"
+ remote_database = "posthog"
+ remote_table = "sharded_marketing_costs_preaggregated"
+ sharding_key = "cityHash64(source_name, campaign_id)"
+ }
+ }
+ table "marketing_touchpoints_preaggregated" {
+ column "team_id" {
+ type = "Int64"
+ }
+ column "job_id" {
+ type = "UUID"
+ }
+ column "person_id" {
+ type = "UUID"
+ }
+ column "touchpoint_timestamp" {
+ type = "DateTime64(6, 'UTC')"
+ }
+ column "campaign_name" {
+ type = "String"
+ }
+ column "source_name" {
+ type = "String"
+ }
+ column "medium_name" {
+ type = "String"
+ }
+ column "content_name" {
+ type = "String"
+ }
+ column "term_name" {
+ type = "String"
+ }
+ column "referring_domain_name" {
+ type = "String"
+ }
+ column "gclid_name" {
+ type = "String"
+ }
+ column "fbclid_name" {
+ type = "String"
+ }
+ column "gad_source_name" {
+ type = "String"
+ }
+ column "computed_at" {
+ type = "DateTime64(6, 'UTC')"
+ default = "now()"
+ }
+ column "expires_at" {
+ type = "Date"
+ default = "today() + toIntervalDay(7)"
+ }
+ engine "distributed" {
+ cluster_name = "aux"
+ remote_database = "posthog"
+ remote_table = "sharded_marketing_touchpoints_preaggregated"
+ sharding_key = "cityHash64(person_id)"
+ }
+ }
+ table "message_assets" {
+ column "team_id" {
+ type = "Int64"
+ }
+ column "function_kind" {
+ type = "LowCardinality(String)"
+ }
+ column "function_id" {
+ type = "String"
+ }
+ column "parent_run_id" {
+ type = "String"
+ }
+ column "invocation_id" {
+ type = "String"
+ }
+ column "action_id" {
+ type = "String"
+ }
+ column "kind" {
+ type = "LowCardinality(String)"
+ }
+ column "distinct_id" {
+ type = "String"
+ }
+ column "person_id" {
+ type = "String"
+ }
+ column "recipient" {
+ type = "String"
+ }
+ column "subject" {
+ type = "String"
+ }
+ column "status" {
+ type = "LowCardinality(String)"
+ }
+ column "sent_at" {
+ type = "DateTime64(6, 'UTC')"
+ }
+ column "version" {
+ type = "UInt64"
+ }
+ column "is_deleted" {
+ type = "UInt8"
+ }
+ column "html" {
+ type = "String"
+ }
+ column "_timestamp" {
+ type = "DateTime"
+ }
+ column "_offset" {
+ type = "UInt64"
+ }
+ column "_partition" {
+ type = "UInt64"
+ }
+ engine "distributed" {
+ cluster_name = "aux"
+ remote_database = "posthog"
+ remote_table = "message_assets_data"
+ }
+ }
+ table "message_assets_data" {
+ order_by = ["team_id", "function_kind", "function_id", "invocation_id", "action_id"]
+ partition_by = "toYYYYMMDD(sent_at)"
+ ttl = "toDate(sent_at) + toIntervalDay(30)"
+ settings = {
+ index_granularity = "1024"
+ ttl_only_drop_parts = "1"
+ }
+ column "team_id" {
+ type = "Int64"
+ }
+ column "function_kind" {
+ type = "LowCardinality(String)"
+ }
+ column "function_id" {
+ type = "String"
+ }
+ column "parent_run_id" {
+ type = "String"
+ }
+ column "invocation_id" {
+ type = "String"
+ }
+ column "action_id" {
+ type = "String"
+ }
+ column "kind" {
+ type = "LowCardinality(String)"
+ }
+ column "distinct_id" {
+ type = "String"
+ }
+ column "person_id" {
+ type = "String"
+ }
+ column "recipient" {
+ type = "String"
+ }
+ column "subject" {
+ type = "String"
+ }
+ column "status" {
+ type = "LowCardinality(String)"
+ }
+ column "sent_at" {
+ type = "DateTime64(6, 'UTC')"
+ }
+ column "version" {
+ type = "UInt64"
+ }
+ column "is_deleted" {
+ type = "UInt8"
+ default = "0"
+ }
+ column "html" {
+ type = "String"
+ codec = "ZSTD(3)"
+ }
+ column "_timestamp" {
+ type = "DateTime"
+ }
+ column "_offset" {
+ type = "UInt64"
+ }
+ column "_partition" {
+ type = "UInt64"
+ }
+ index "parent_run_idx" {
+ expr = "parent_run_id"
+ type = "bloom_filter(0.01)"
+ granularity = 1
+ }
+ index "distinct_id_idx" {
+ expr = "distinct_id"
+ type = "bloom_filter(0.01)"
+ granularity = 1
+ }
+ index "person_id_idx" {
+ expr = "person_id"
+ type = "bloom_filter(0.01)"
+ granularity = 1
+ }
+ index "recipient_idx" {
+ expr = "recipient"
+ type = "bloom_filter(0.01)"
+ granularity = 1
+ }
+ engine "replicated_replacing_merge_tree" {
+ zoo_path = "/clickhouse/tables/noshard/posthog.message_assets_data"
+ replica_name = "{replica}-{shard}"
+ version_column = "version"
+ }
+ }
+ table "property_values" {
+ order_by = ["team_id", "property_type", "property_key", "property_value"]
+ ttl = "last_seen + toIntervalDay(30)"
+ settings = {
+ index_granularity = "8192"
+ }
+ column "team_id" {
+ type = "Int64"
+ codec = "DoubleDelta, ZSTD(1)"
+ }
+ column "property_type" {
+ type = "LowCardinality(String)"
+ }
+ column "property_key" {
+ type = "LowCardinality(String)"
+ }
+ column "property_value" {
+ type = "String"
+ }
+ column "property_count" {
+ type = "SimpleAggregateFunction(sum, UInt64)"
+ }
+ column "last_seen" {
+ type = "SimpleAggregateFunction(max, DateTime)"
+ default = "now()"
+ }
+ index "idx_property_value_ngrambf" {
+ expr = "lower(property_value)"
+ type = "ngrambf_v1(3, 32768, 3, 0)"
+ granularity = 1
+ }
+ engine "replicated_aggregating_merge_tree" {
+ zoo_path = "/clickhouse/tables/noshard/posthog.property_values"
+ replica_name = "{replica}-{shard}"
+ }
+ }
+ table "property_values_distributed" {
+ column "team_id" {
+ type = "Int64"
+ codec = "DoubleDelta, ZSTD(1)"
+ }
+ column "property_type" {
+ type = "LowCardinality(String)"
+ }
+ column "property_key" {
+ type = "LowCardinality(String)"
+ }
+ column "property_value" {
+ type = "String"
+ }
+ column "property_count" {
+ type = "SimpleAggregateFunction(sum, UInt64)"
+ }
+ column "last_seen" {
+ type = "SimpleAggregateFunction(max, DateTime)"
+ default = "now()"
+ }
+ engine "distributed" {
+ cluster_name = "aux"
+ remote_database = "posthog"
+ remote_table = "property_values"
+ }
+ }
+ table "raw_error_tracking_fingerprint_issue_state" {
+ order_by = ["team_id", "fingerprint"]
+ settings = {
+ index_granularity = "512"
+ }
+ column "team_id" {
+ type = "Int64"
+ }
+ column "fingerprint" {
+ type = "String"
+ }
+ column "issue_id" {
+ type = "UUID"
+ }
+ column "issue_name" {
+ type = "Nullable(String)"
+ }
+ column "issue_description" {
+ type = "Nullable(String)"
+ }
+ column "issue_status" {
+ type = "String"
+ }
+ column "assigned_user_id" {
+ type = "Nullable(Int64)"
+ }
+ column "assigned_role_id" {
+ type = "Nullable(UUID)"
+ }
+ column "first_seen" {
+ type = "DateTime64(3, 'UTC')"
+ }
+ column "is_deleted" {
+ type = "Int8"
+ }
+ column "version" {
+ type = "Int64"
+ }
+ column "_timestamp" {
+ type = "DateTime"
+ }
+ column "_offset" {
+ type = "UInt64"
+ }
+ column "_partition" {
+ type = "UInt64"
+ }
+ index "kafka_timestamp_minmax_raw_error_tracking_fingerprint_issue_state" {
+ expr = "_timestamp"
+ type = "minmax"
+ granularity = 3
+ }
+ engine "replicated_replacing_merge_tree" {
+ zoo_path = "/clickhouse/tables/noshard/posthog.raw_error_tracking_fingerprint_issue_state"
+ replica_name = "{replica}-{shard}"
+ version_column = "version"
+ }
+ }
+ table "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 "sharded_conversion_goal_attributed_preaggregated" {
+ order_by = ["team_id", "job_id", "person_id", "conversion_timestamp", "touchpoint_timestamp"]
+ partition_by = "toYYYYMMDD(expires_at)"
+ ttl = "expires_at"
+ settings = {
+ index_granularity = "8192"
+ ttl_only_drop_parts = "1"
+ }
+ column "team_id" {
+ type = "Int64"
+ }
+ column "job_id" {
+ type = "UUID"
+ }
+ column "person_id" {
+ type = "UUID"
+ }
+ column "conversion_timestamp" {
+ type = "DateTime64(6, 'UTC')"
+ }
+ column "conversion_value" {
+ type = "Float64"
+ }
+ column "touchpoint_timestamp" {
+ type = "DateTime64(6, 'UTC')"
+ }
+ column "touchpoint_weight" {
+ type = "Float64"
+ }
+ column "campaign_name" {
+ type = "String"
+ }
+ column "source_name" {
+ type = "String"
+ }
+ column "medium_name" {
+ type = "String"
+ }
+ column "content_name" {
+ type = "String"
+ }
+ column "term_name" {
+ type = "String"
+ }
+ column "referring_domain_name" {
+ type = "String"
+ }
+ column "gclid_name" {
+ type = "String"
+ }
+ column "fbclid_name" {
+ type = "String"
+ }
+ column "gad_source_name" {
+ type = "String"
+ }
+ column "computed_at" {
+ type = "DateTime64(6, 'UTC')"
+ default = "now()"
+ }
+ column "expires_at" {
+ type = "Date"
+ default = "today() + toIntervalDay(7)"
+ }
+ engine "replicated_replacing_merge_tree" {
+ zoo_path = "/clickhouse/tables/noshard/posthog.conversion_goal_attributed_preaggregated"
+ replica_name = "{replica}-{shard}"
+ version_column = "computed_at"
+ }
+ }
+ table "sharded_experiment_metric_events_preaggregated" {
+ order_by = ["team_id", "job_id", "entity_id", "timestamp", "event_uuid"]
+ partition_by = "toYYYYMMDD(expires_at)"
+ ttl = "expires_at"
+ settings = {
+ index_granularity = "8192"
+ ttl_only_drop_parts = "1"
+ }
+ column "team_id" {
+ type = "Int64"
+ }
+ column "job_id" {
+ type = "UUID"
+ }
+ column "entity_id" {
+ type = "String"
+ }
+ column "timestamp" {
+ type = "DateTime64(6, 'UTC')"
+ }
+ column "event_uuid" {
+ type = "UUID"
+ }
+ column "session_id" {
+ type = "String"
+ }
+ column "numeric_value" {
+ type = "Float64"
+ default = "0"
+ }
+ column "steps" {
+ type = "Array(UInt8)"
+ default = "[]"
+ }
+ column "computed_at" {
+ type = "DateTime64(6, 'UTC')"
+ default = "now()"
+ }
+ column "expires_at" {
+ type = "Date"
+ default = "today() + toIntervalDay(7)"
+ }
+ engine "replicated_replacing_merge_tree" {
+ zoo_path = "/clickhouse/tables/noshard/posthog.experiment_metric_events_preaggregated"
+ replica_name = "{replica}-{shard}"
+ version_column = "computed_at"
+ }
+ }
+ table "sharded_marketing_conversions_preaggregated" {
+ order_by = ["team_id", "job_id", "person_id", "conversion_timestamp"]
+ partition_by = "toYYYYMMDD(expires_at)"
+ ttl = "expires_at"
+ settings = {
+ index_granularity = "8192"
+ ttl_only_drop_parts = "1"
+ }
+ column "team_id" {
+ type = "Int64"
+ }
+ column "job_id" {
+ type = "UUID"
+ }
+ column "person_id" {
+ type = "UUID"
+ }
+ column "conversion_timestamp" {
+ type = "DateTime64(6, 'UTC')"
+ }
+ column "conversion_math_value" {
+ type = "Float64"
+ }
+ column "session_id" {
+ type = "String"
+ }
+ column "campaign_name" {
+ type = "String"
+ }
+ column "source_name" {
+ type = "String"
+ }
+ column "medium_name" {
+ type = "String"
+ }
+ column "content_name" {
+ type = "String"
+ }
+ column "term_name" {
+ type = "String"
+ }
+ column "referring_domain_name" {
+ type = "String"
+ }
+ column "gclid_name" {
+ type = "String"
+ }
+ column "fbclid_name" {
+ type = "String"
+ }
+ column "gad_source_name" {
+ type = "String"
+ }
+ column "computed_at" {
+ type = "DateTime64(6, 'UTC')"
+ default = "now()"
+ }
+ column "expires_at" {
+ type = "Date"
+ default = "today() + toIntervalDay(7)"
+ }
+ engine "replicated_replacing_merge_tree" {
+ zoo_path = "/clickhouse/tables/noshard/posthog.marketing_conversions_preaggregated"
+ replica_name = "{replica}-{shard}"
+ version_column = "computed_at"
+ }
+ }
+ table "sharded_marketing_costs_preaggregated" {
+ order_by = ["team_id", "job_id", "source_name", "grain", "campaign_id", "ad_group_id", "ad_id", "cost_date"]
+ partition_by = "toYYYYMMDD(expires_at)"
+ ttl = "expires_at"
+ settings = {
+ index_granularity = "8192"
+ ttl_only_drop_parts = "1"
+ }
+ column "team_id" {
+ type = "Int64"
+ }
+ column "job_id" {
+ type = "UUID"
+ }
+ column "source_id" {
+ type = "String"
+ }
+ column "source_name" {
+ type = "String"
+ }
+ column "grain" {
+ type = "LowCardinality(String)"
+ }
+ column "match_key" {
+ type = "String"
+ }
+ column "campaign_id" {
+ type = "String"
+ }
+ column "campaign_name" {
+ type = "String"
+ }
+ column "ad_group_id" {
+ type = "String"
+ }
+ column "ad_group_name" {
+ type = "String"
+ }
+ column "ad_id" {
+ type = "String"
+ }
+ column "ad_name" {
+ type = "String"
+ }
+ column "cost_date" {
+ type = "Date"
+ }
+ column "cost" {
+ type = "Float64"
+ }
+ column "clicks" {
+ type = "Float64"
+ }
+ column "impressions" {
+ type = "Float64"
+ }
+ column "reported_conversions" {
+ type = "Float64"
+ }
+ column "reported_conversion_value" {
+ type = "Float64"
+ }
+ column "computed_at" {
+ type = "DateTime64(6, 'UTC')"
+ default = "now()"
+ }
+ column "expires_at" {
+ type = "Date"
+ default = "today() + toIntervalDay(7)"
+ }
+ engine "replicated_replacing_merge_tree" {
+ zoo_path = "/clickhouse/tables/noshard/posthog.marketing_costs_preaggregated"
+ replica_name = "{replica}-{shard}"
+ version_column = "computed_at"
+ }
+ }
+ table "sharded_marketing_touchpoints_preaggregated" {
+ order_by = ["team_id", "job_id", "person_id", "touchpoint_timestamp"]
+ partition_by = "toYYYYMMDD(expires_at)"
+ ttl = "expires_at"
+ settings = {
+ index_granularity = "8192"
+ ttl_only_drop_parts = "1"
+ }
+ column "team_id" {
+ type = "Int64"
+ }
+ column "job_id" {
+ type = "UUID"
+ }
+ column "person_id" {
+ type = "UUID"
+ }
+ column "touchpoint_timestamp" {
+ type = "DateTime64(6, 'UTC')"
+ }
+ column "campaign_name" {
+ type = "String"
+ }
+ column "source_name" {
+ type = "String"
+ }
+ column "medium_name" {
+ type = "String"
+ }
+ column "content_name" {
+ type = "String"
+ }
+ column "term_name" {
+ type = "String"
+ }
+ column "referring_domain_name" {
+ type = "String"
+ }
+ column "gclid_name" {
+ type = "String"
+ }
+ column "fbclid_name" {
+ type = "String"
+ }
+ column "gad_source_name" {
+ type = "String"
+ }
+ column "computed_at" {
+ type = "DateTime64(6, 'UTC')"
+ default = "now()"
+ }
+ column "expires_at" {
+ type = "Date"
+ default = "today() + toIntervalDay(7)"
+ }
+ engine "replicated_replacing_merge_tree" {
+ zoo_path = "/clickhouse/tables/noshard/posthog.marketing_touchpoints_preaggregated"
+ replica_name = "{replica}-{shard}"
+ version_column = "computed_at"
+ }
+ }
+ table "sharded_session_replay_features" {
+ order_by = ["team_id", "session_id"]
+ partition_by = "toYYYYMM(min_first_timestamp)"
+ settings = {
+ index_granularity = "512"
+ }
+ column "session_id" {
+ type = "String"
+ }
+ column "team_id" {
+ type = "Int64"
+ }
+ column "distinct_id" {
+ type = "String"
+ }
+ column "min_first_timestamp" {
+ type = "SimpleAggregateFunction(min, DateTime64(6, 'UTC'))"
+ }
+ column "max_last_timestamp" {
+ type = "SimpleAggregateFunction(max, DateTime64(6, 'UTC'))"
+ }
+ column "event_count" {
+ type = "SimpleAggregateFunction(sum, Int64)"
+ }
+ column "mouse_position_count" {
+ type = "SimpleAggregateFunction(sum, Int64)"
+ }
+ column "mouse_sum_x" {
+ type = "SimpleAggregateFunction(sum, Float64)"
+ }
+ column "mouse_sum_x_squared" {
+ type = "SimpleAggregateFunction(sum, Float64)"
+ }
+ column "mouse_sum_y" {
+ type = "SimpleAggregateFunction(sum, Float64)"
+ }
+ column "mouse_sum_y_squared" {
+ type = "SimpleAggregateFunction(sum, Float64)"
+ }
+ column "mouse_distance_traveled" {
+ type = "SimpleAggregateFunction(sum, Float64)"
+ }
+ column "mouse_direction_change_count" {
+ type = "SimpleAggregateFunction(sum, Int64)"
+ }
+ column "mouse_velocity_sum" {
+ type = "SimpleAggregateFunction(sum, Float64)"
+ }
+ column "mouse_velocity_sum_of_squares" {
+ type = "SimpleAggregateFunction(sum, Float64)"
+ }
+ column "mouse_velocity_count" {
+ type = "SimpleAggregateFunction(sum, Int64)"
+ }
+ column "scroll_event_count" {
+ type = "SimpleAggregateFunction(sum, Int64)"
+ }
+ column "total_scroll_magnitude" {
+ type = "SimpleAggregateFunction(sum, Float64)"
+ }
+ column "scroll_direction_reversal_count" {
+ type = "SimpleAggregateFunction(sum, Int64)"
+ }
+ column "rapid_scroll_reversal_count" {
+ type = "SimpleAggregateFunction(sum, Int64)"
+ }
+ column "scroll_to_top_count" {
+ type = "SimpleAggregateFunction(sum, Int64)"
+ }
+ column "click_count" {
+ type = "SimpleAggregateFunction(sum, Int64)"
+ }
+ column "keypress_count" {
+ type = "SimpleAggregateFunction(sum, Int64)"
+ }
+ column "mouse_activity_count" {
+ type = "SimpleAggregateFunction(sum, Int64)"
+ }
+ column "rage_click_count" {
+ type = "SimpleAggregateFunction(sum, Int64)"
+ }
+ column "dead_click_count" {
+ type = "SimpleAggregateFunction(sum, Int64)"
+ }
+ column "backspace_count" {
+ type = "SimpleAggregateFunction(sum, Int64)"
+ }
+ column "inter_action_gap_count" {
+ type = "SimpleAggregateFunction(sum, Int64)"
+ }
+ column "inter_action_gap_sum_ms" {
+ type = "SimpleAggregateFunction(sum, Float64)"
+ }
+ column "inter_action_gap_sum_of_squares_ms" {
+ type = "SimpleAggregateFunction(sum, Float64)"
+ }
+ column "max_idle_gap_ms" {
+ type = "SimpleAggregateFunction(max, Float64)"
+ }
+ column "long_idle_gap_count" {
+ type = "SimpleAggregateFunction(sum, Int64)"
+ }
+ column "quick_back_count" {
+ type = "SimpleAggregateFunction(sum, Int64)"
+ }
+ column "page_visit_count" {
+ type = "SimpleAggregateFunction(sum, Int64)"
+ }
+ column "unique_url_count" {
+ type = "AggregateFunction(uniqCombined(12), String)"
+ }
+ column "login_path_visit_count" {
+ type = "SimpleAggregateFunction(sum, Int64)"
+ }
+ column "signup_path_visit_count" {
+ type = "SimpleAggregateFunction(sum, Int64)"
+ }
+ column "checkout_path_visit_count" {
+ type = "SimpleAggregateFunction(sum, Int64)"
+ }
+ column "cart_path_visit_count" {
+ type = "SimpleAggregateFunction(sum, Int64)"
+ }
+ column "billing_path_visit_count" {
+ type = "SimpleAggregateFunction(sum, Int64)"
+ }
+ column "settings_path_visit_count" {
+ type = "SimpleAggregateFunction(sum, Int64)"
+ }
+ column "account_path_visit_count" {
+ type = "SimpleAggregateFunction(sum, Int64)"
+ }
+ column "error_path_visit_count" {
+ type = "SimpleAggregateFunction(sum, Int64)"
+ }
+ column "not_found_path_visit_count" {
+ type = "SimpleAggregateFunction(sum, Int64)"
+ }
+ column "admin_path_visit_count" {
+ type = "SimpleAggregateFunction(sum, Int64)"
+ }
+ column "dashboard_path_visit_count" {
+ type = "SimpleAggregateFunction(sum, Int64)"
+ }
+ column "onboarding_path_visit_count" {
+ type = "SimpleAggregateFunction(sum, Int64)"
+ }
+ column "cancel_path_visit_count" {
+ type = "SimpleAggregateFunction(sum, Int64)"
+ }
+ column "refund_path_visit_count" {
+ type = "SimpleAggregateFunction(sum, Int64)"
+ }
+ column "console_error_count" {
+ type = "SimpleAggregateFunction(sum, Int64)"
+ }
+ column "console_error_after_click_count" {
+ type = "SimpleAggregateFunction(sum, Int64)"
+ }
+ column "console_warn_count" {
+ type = "SimpleAggregateFunction(sum, Int64)"
+ }
+ column "network_request_count" {
+ type = "SimpleAggregateFunction(sum, Int64)"
+ }
+ column "network_failed_request_count" {
+ type = "SimpleAggregateFunction(sum, Int64)"
+ }
+ column "network_4xx_count" {
+ type = "SimpleAggregateFunction(sum, Int64)"
+ }
+ column "network_5xx_count" {
+ type = "SimpleAggregateFunction(sum, Int64)"
+ }
+ column "network_request_duration_sum" {
+ type = "SimpleAggregateFunction(sum, Float64)"
+ }
+ column "network_request_duration_sum_of_squares" {
+ type = "SimpleAggregateFunction(sum, Float64)"
+ }
+ column "network_request_duration_count" {
+ type = "SimpleAggregateFunction(sum, Int64)"
+ }
+ column "mutation_count" {
+ type = "SimpleAggregateFunction(sum, Int64)"
+ }
+ column "viewport_resize_count" {
+ type = "SimpleAggregateFunction(sum, Int64)"
+ }
+ column "touch_event_count" {
+ type = "SimpleAggregateFunction(sum, Int64)"
+ }
+ column "max_scroll_y" {
+ type = "SimpleAggregateFunction(max, Float64)"
+ }
+ column "unique_click_target_count" {
+ type = "AggregateFunction(uniqCombined(12), Int64)"
+ }
+ column "unique_form_field_count" {
+ type = "AggregateFunction(uniqCombined(12), Int64)"
+ }
+ column "text_selection_count" {
+ type = "SimpleAggregateFunction(sum, Int64)"
+ }
+ column "selection_copy_count" {
+ type = "SimpleAggregateFunction(sum, Int64)"
+ }
+ column "is_deleted" {
+ type = "SimpleAggregateFunction(max, UInt8)"
+ default = "0"
+ }
+ engine "replicated_aggregating_merge_tree" {
+ zoo_path = "/clickhouse/tables/{shard}/posthog.session_replay_features"
+ replica_name = "{replica}"
+ }
+ }
+ table "sharded_usage_report_events_preagg" {
+ order_by = ["date", "team_id", "person_mode", "lib", "event"]
+ partition_by = "date"
+ ttl = "date + toIntervalDay(14)"
+ settings = {
+ index_granularity = "8192"
+ ttl_only_drop_parts = "1"
+ }
+ column "date" {
+ type = "Date"
+ }
+ column "team_id" {
+ type = "Int64"
+ }
+ column "person_mode" {
+ type = "LowCardinality(String)"
+ }
+ column "lib" {
+ type = "LowCardinality(String)"
+ }
+ column "event" {
+ type = "String"
+ }
+ column "distinct_events_unique" {
+ type = "AggregateFunction(uniqExact, Tuple(UInt64, UInt64, UInt64))"
+ }
+ column "event_count" {
+ type = "AggregateFunction(sum, UInt64)"
+ }
+ engine "replicated_aggregating_merge_tree" {
+ zoo_path = "/clickhouse/tables/{shard}/posthog.sharded_usage_report_events_preagg"
+ replica_name = "{replica}"
+ }
+ }
+ table "sharded_web_bot_definition" {
+ order_by = ["id"]
+ settings = {
+ index_granularity = "8192"
+ }
+ column "id" {
+ type = "UInt64"
+ }
+ column "parent_id" {
+ type = "UInt64"
+ }
+ column "regexp" {
+ type = "String"
+ }
+ column "keys" {
+ type = "Array(String)"
+ }
+ column "values" {
+ type = "Array(String)"
+ }
+ engine "replicated_merge_tree" {
+ zoo_path = "/clickhouse/tables/{shard}/posthog.sharded_web_bot_definition"
+ replica_name = "{replica}"
+ }
+ }
+ table "sharded_web_bounces_dimensional_preaggregated" {
+ order_by = ["team_id", "job_id", "period_bucket", "host", "device_type", "entry_pathname", "end_pathname", "browser", "os", "viewport_width", "viewport_height", "referring_domain", "utm_source", "utm_medium", "utm_campaign", "utm_term", "utm_content", "country_code", "city_name", "region_code", "region_name", "has_gclid", "has_gad_source_paid_search", "has_fbclid", "mat_metadata_backend", "mat_metadata_loggedIn"]
+ partition_by = "toYYYYMMDD(expires_at)"
+ ttl = "toDateTime(expires_at)"
+ settings = {
+ allow_nullable_key = "1"
+ index_granularity = "8192"
+ ttl_only_drop_parts = "1"
+ }
+ column "team_id" {
+ type = "Int64"
+ }
+ column "job_id" {
+ type = "UUID"
+ }
+ column "period_bucket" {
+ type = "DateTime"
+ }
+ column "host" {
+ type = "String"
+ }
+ column "device_type" {
+ type = "String"
+ }
+ column "entry_pathname" {
+ type = "String"
+ }
+ column "end_pathname" {
+ type = "String"
+ }
+ column "browser" {
+ type = "String"
+ }
+ column "os" {
+ type = "String"
+ }
+ column "viewport_width" {
+ type = "Int64"
+ }
+ column "viewport_height" {
+ type = "Int64"
+ }
+ column "referring_domain" {
+ type = "String"
+ }
+ column "utm_source" {
+ type = "String"
+ }
+ column "utm_medium" {
+ type = "String"
+ }
+ column "utm_campaign" {
+ type = "String"
+ }
+ column "utm_term" {
+ type = "String"
+ }
+ column "utm_content" {
+ type = "String"
+ }
+ column "country_code" {
+ type = "String"
+ }
+ column "city_name" {
+ type = "String"
+ }
+ column "region_code" {
+ type = "String"
+ }
+ column "region_name" {
+ type = "String"
+ }
+ column "has_gclid" {
+ type = "Bool"
+ }
+ column "has_gad_source_paid_search" {
+ type = "Bool"
+ }
+ column "has_fbclid" {
+ type = "Bool"
+ }
+ column "mat_metadata_backend" {
+ type = "Nullable(String)"
+ }
+ column "mat_metadata_loggedIn" {
+ type = "Nullable(Bool)"
+ }
+ column "persons_uniq_state" {
+ type = "AggregateFunction(uniq, UUID)"
+ }
+ column "sessions_uniq_state" {
+ type = "AggregateFunction(uniq, String)"
+ }
+ column "pageviews_count_state" {
+ type = "AggregateFunction(sum, Int64)"
+ }
+ column "bounces_count_state" {
+ type = "AggregateFunction(sum, Int64)"
+ }
+ column "total_session_duration_state" {
+ type = "AggregateFunction(sum, Int64)"
+ }
+ column "total_session_count_state" {
+ type = "AggregateFunction(sum, Int64)"
+ }
+ column "computed_at" {
+ type = "DateTime64(6, 'UTC')"
+ default = "now()"
+ }
+ column "expires_at" {
+ type = "DateTime64(6, 'UTC')"
+ default = "now() + toIntervalDay(7)"
+ }
+ engine "replicated_replacing_merge_tree" {
+ zoo_path = "/clickhouse/tables/{shard}/posthog.web_bounces_dimensional_preaggregated"
+ replica_name = "{replica}"
+ version_column = "computed_at"
+ }
+ }
+ table "sharded_web_goals_preaggregated" {
+ order_by = ["team_id", "job_id", "action_id", "time_window_start"]
+ partition_by = "toYYYYMMDD(expires_at)"
+ ttl = "toDateTime(expires_at)"
+ settings = {
+ index_granularity = "8192"
+ ttl_only_drop_parts = "1"
+ }
+ column "team_id" {
+ type = "Int64"
+ }
+ column "job_id" {
+ type = "UUID"
+ }
+ column "time_window_start" {
+ type = "DateTime64(6, 'UTC')"
+ }
+ column "action_id" {
+ type = "Int64"
+ }
+ column "count_state" {
+ type = "AggregateFunction(sum, Int64)"
+ }
+ column "unique_persons_state" {
+ type = "AggregateFunction(uniq, UUID)"
+ }
+ column "computed_at" {
+ type = "DateTime64(6, 'UTC')"
+ default = "now()"
+ }
+ column "expires_at" {
+ type = "DateTime64(6, 'UTC')"
+ default = "now() + toIntervalDay(7)"
+ }
+ engine "replicated_replacing_merge_tree" {
+ zoo_path = "/clickhouse/tables/{shard}/posthog.web_goals_preaggregated"
+ replica_name = "{replica}"
+ version_column = "computed_at"
+ }
+ }
+ table "sharded_web_overview_preaggregated" {
+ order_by = ["team_id", "job_id", "time_window_start"]
+ partition_by = "toYYYYMMDD(expires_at)"
+ ttl = "toDateTime(expires_at)"
+ settings = {
+ index_granularity = "8192"
+ ttl_only_drop_parts = "1"
+ }
+ column "team_id" {
+ type = "Int64"
+ }
+ column "job_id" {
+ type = "UUID"
+ }
+ column "time_window_start" {
+ type = "DateTime64(6, 'UTC')"
+ }
+ column "uniq_users_state" {
+ type = "AggregateFunction(uniq, UUID)"
+ }
+ column "uniq_sessions_state" {
+ type = "AggregateFunction(uniq, String)"
+ }
+ column "sum_pageviews_state" {
+ type = "AggregateFunction(sum, Int64)"
+ }
+ column "avg_duration_state" {
+ type = "AggregateFunction(avg, Float64)"
+ }
+ column "avg_bounce_state" {
+ type = "AggregateFunction(avg, Int64)"
+ }
+ column "computed_at" {
+ type = "DateTime64(6, 'UTC')"
+ default = "now()"
+ }
+ column "expires_at" {
+ type = "DateTime64(6, 'UTC')"
+ default = "now() + toIntervalDay(7)"
+ }
+ engine "replicated_replacing_merge_tree" {
+ zoo_path = "/clickhouse/tables/{shard}/posthog.web_overview_preaggregated"
+ replica_name = "{replica}"
+ version_column = "computed_at"
+ }
+ }
+ table "sharded_web_stats_dimensional_preaggregated" {
+ order_by = ["team_id", "job_id", "period_bucket", "host", "device_type", "pathname", "entry_pathname", "end_pathname", "browser", "os", "viewport_width", "viewport_height", "referring_domain", "utm_source", "utm_medium", "utm_campaign", "utm_term", "utm_content", "country_code", "city_name", "region_code", "region_name", "has_gclid", "has_gad_source_paid_search", "has_fbclid", "mat_metadata_backend", "mat_metadata_loggedIn"]
+ partition_by = "toYYYYMMDD(expires_at)"
+ ttl = "toDateTime(expires_at)"
+ settings = {
+ allow_nullable_key = "1"
+ index_granularity = "8192"
+ ttl_only_drop_parts = "1"
+ }
+ column "team_id" {
+ type = "Int64"
+ }
+ column "job_id" {
+ type = "UUID"
+ }
+ column "period_bucket" {
+ type = "DateTime"
+ }
+ column "host" {
+ type = "String"
+ }
+ column "device_type" {
+ type = "String"
+ }
+ column "pathname" {
+ type = "String"
+ }
+ column "entry_pathname" {
+ type = "String"
+ }
+ column "end_pathname" {
+ type = "String"
+ }
+ column "browser" {
+ type = "String"
+ }
+ column "os" {
+ type = "String"
+ }
+ column "viewport_width" {
+ type = "Int64"
+ }
+ column "viewport_height" {
+ type = "Int64"
+ }
+ column "referring_domain" {
+ type = "String"
+ }
+ column "utm_source" {
+ type = "String"
+ }
+ column "utm_medium" {
+ type = "String"
+ }
+ column "utm_campaign" {
+ type = "String"
+ }
+ column "utm_term" {
+ type = "String"
+ }
+ column "utm_content" {
+ type = "String"
+ }
+ column "country_code" {
+ type = "String"
+ }
+ column "city_name" {
+ type = "String"
+ }
+ column "region_code" {
+ type = "String"
+ }
+ column "region_name" {
+ type = "String"
+ }
+ column "has_gclid" {
+ type = "Bool"
+ }
+ column "has_gad_source_paid_search" {
+ type = "Bool"
+ }
+ column "has_fbclid" {
+ type = "Bool"
+ }
+ column "mat_metadata_backend" {
+ type = "Nullable(String)"
+ }
+ column "mat_metadata_loggedIn" {
+ type = "Nullable(Bool)"
+ }
+ column "persons_uniq_state" {
+ type = "AggregateFunction(uniq, UUID)"
+ }
+ column "sessions_uniq_state" {
+ type = "AggregateFunction(uniq, String)"
+ }
+ column "pageviews_count_state" {
+ type = "AggregateFunction(sum, Int64)"
+ }
+ column "computed_at" {
+ type = "DateTime64(6, 'UTC')"
+ default = "now()"
+ }
+ column "expires_at" {
+ type = "DateTime64(6, 'UTC')"
+ default = "now() + toIntervalDay(7)"
+ }
+ engine "replicated_replacing_merge_tree" {
+ zoo_path = "/clickhouse/tables/{shard}/posthog.web_stats_dimensional_preaggregated"
+ replica_name = "{replica}"
+ version_column = "computed_at"
+ }
+ }
+ table "sharded_web_stats_frustration_preaggregated" {
+ order_by = ["team_id", "job_id", "breakdown_value", "time_window_start"]
+ partition_by = "toYYYYMMDD(expires_at)"
+ ttl = "toDateTime(expires_at)"
+ settings = {
+ index_granularity = "8192"
+ ttl_only_drop_parts = "1"
+ }
+ column "team_id" {
+ type = "Int64"
+ }
+ column "job_id" {
+ type = "UUID"
+ }
+ column "time_window_start" {
+ type = "DateTime64(6, 'UTC')"
+ }
+ column "breakdown_value" {
+ type = "String"
+ }
+ column "sum_rage_clicks_state" {
+ type = "AggregateFunction(sum, Int64)"
+ }
+ column "sum_dead_clicks_state" {
+ type = "AggregateFunction(sum, Int64)"
+ }
+ column "sum_errors_state" {
+ type = "AggregateFunction(sum, Int64)"
+ }
+ column "computed_at" {
+ type = "DateTime64(6, 'UTC')"
+ default = "now()"
+ }
+ column "expires_at" {
+ type = "DateTime64(6, 'UTC')"
+ default = "now() + toIntervalDay(7)"
+ }
+ engine "replicated_replacing_merge_tree" {
+ zoo_path = "/clickhouse/tables/{shard}/posthog.web_stats_frustration_preaggregated"
+ replica_name = "{replica}"
+ version_column = "computed_at"
+ }
+ }
+ table "sharded_web_stats_paths_preaggregated" {
+ order_by = ["team_id", "job_id", "breakdown_value", "time_window_start"]
+ partition_by = "toYYYYMMDD(expires_at)"
+ ttl = "toDateTime(expires_at)"
+ settings = {
+ index_granularity = "8192"
+ ttl_only_drop_parts = "1"
+ }
+ column "team_id" {
+ type = "Int64"
+ }
+ column "job_id" {
+ type = "UUID"
+ }
+ column "time_window_start" {
+ type = "DateTime64(6, 'UTC')"
+ }
+ column "breakdown_value" {
+ type = "String"
+ }
+ column "uniq_users_state" {
+ type = "AggregateFunction(uniq, UUID)"
+ }
+ column "sum_pageviews_state" {
+ type = "AggregateFunction(sum, Int64)"
+ }
+ column "avg_bounce_state" {
+ type = "AggregateFunction(avg, Nullable(Float64))"
+ }
+ column "computed_at" {
+ type = "DateTime64(6, 'UTC')"
+ default = "now()"
+ }
+ column "expires_at" {
+ type = "DateTime64(6, 'UTC')"
+ default = "now() + toIntervalDay(7)"
+ }
+ engine "replicated_replacing_merge_tree" {
+ zoo_path = "/clickhouse/tables/{shard}/posthog.web_stats_paths_preaggregated"
+ replica_name = "{replica}"
+ version_column = "computed_at"
+ }
+ }
+ table "sharded_web_stats_paths_preaggregated_pathkey" {
+ order_by = ["team_id", "time_window_start", "breakdown_value", "job_id"]
+ partition_by = "toYYYYMMDD(expires_at)"
+ ttl = "toDateTime(expires_at)"
+ settings = {
+ index_granularity = "8192"
+ ttl_only_drop_parts = "1"
+ }
+ column "team_id" {
+ type = "Int64"
+ }
+ column "job_id" {
+ type = "UUID"
+ }
+ column "time_window_start" {
+ type = "DateTime64(6, 'UTC')"
+ }
+ column "breakdown_value" {
+ type = "String"
+ }
+ column "uniq_users_state" {
+ type = "AggregateFunction(uniq, UUID)"
+ }
+ column "sum_pageviews_state" {
+ type = "AggregateFunction(sum, Int64)"
+ }
+ column "avg_bounce_state" {
+ type = "AggregateFunction(avg, Nullable(Float64))"
+ }
+ column "computed_at" {
+ type = "DateTime64(6, 'UTC')"
+ default = "now()"
+ }
+ column "expires_at" {
+ type = "DateTime64(6, 'UTC')"
+ default = "now() + toIntervalDay(7)"
+ }
+ engine "replicated_replacing_merge_tree" {
+ zoo_path = "/clickhouse/tables/{shard}/posthog.web_stats_paths_preaggregated_pathkey"
+ replica_name = "{replica}"
+ version_column = "computed_at"
+ }
+ }
+ table "sharded_web_stats_preaggregated" {
+ order_by = ["team_id", "job_id", "breakdown_by", "time_window_start", "breakdown_value"]
+ partition_by = "toYYYYMMDD(expires_at)"
+ ttl = "toDateTime(expires_at)"
+ settings = {
+ index_granularity = "8192"
+ ttl_only_drop_parts = "1"
+ }
+ column "team_id" {
+ type = "Int64"
+ }
+ column "job_id" {
+ type = "UUID"
+ }
+ column "time_window_start" {
+ type = "DateTime64(6, 'UTC')"
+ }
+ column "breakdown_by" {
+ type = "String"
+ }
+ column "breakdown_value" {
+ type = "String"
+ }
+ column "uniq_users_state" {
+ type = "AggregateFunction(uniq, UUID)"
+ }
+ column "sum_pageviews_state" {
+ type = "AggregateFunction(sum, Int64)"
+ }
+ column "computed_at" {
+ type = "DateTime64(6, 'UTC')"
+ default = "now()"
+ }
+ column "expires_at" {
+ type = "DateTime64(6, 'UTC')"
+ default = "now() + toIntervalDay(7)"
+ }
+ engine "replicated_replacing_merge_tree" {
+ zoo_path = "/clickhouse/tables/{shard}/posthog.web_stats_preaggregated"
+ replica_name = "{replica}"
+ version_column = "computed_at"
+ }
+ }
+ table "sharded_web_vitals_paths_preaggregated" {
+ order_by = ["team_id", "job_id", "time_window_start", "path"]
+ partition_by = "toYYYYMMDD(expires_at)"
+ ttl = "toDateTime(expires_at)"
+ settings = {
+ index_granularity = "8192"
+ ttl_only_drop_parts = "1"
+ }
+ column "team_id" {
+ type = "Int64"
+ }
+ column "job_id" {
+ type = "UUID"
+ }
+ column "time_window_start" {
+ type = "DateTime64(6, 'UTC')"
+ }
+ column "path" {
+ type = "String"
+ }
+ column "inp_quantiles_state" {
+ type = "AggregateFunction(quantiles(0.75, 0.9, 0.99), Float64)"
+ }
+ column "lcp_quantiles_state" {
+ type = "AggregateFunction(quantiles(0.75, 0.9, 0.99), Float64)"
+ }
+ column "cls_quantiles_state" {
+ type = "AggregateFunction(quantiles(0.75, 0.9, 0.99), Float64)"
+ }
+ column "fcp_quantiles_state" {
+ type = "AggregateFunction(quantiles(0.75, 0.9, 0.99), Float64)"
+ }
+ column "computed_at" {
+ type = "DateTime64(6, 'UTC')"
+ default = "now()"
+ }
+ column "expires_at" {
+ type = "DateTime64(6, 'UTC')"
+ default = "now() + toIntervalDay(7)"
+ }
+ engine "replicated_replacing_merge_tree" {
+ zoo_path = "/clickhouse/tables/{shard}/posthog.web_vitals_paths_preaggregated"
+ replica_name = "{replica}"
+ version_column = "computed_at"
+ }
+ }
+ table "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_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_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_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"
+ }
+ }
+ materialized_view "hog_invocation_results_mv" {
+ to_table = "posthog.hog_invocation_results_data"
+ query = file("sql/hog_invocation_results_mv.sql")
+
+ column "team_id" {
+ type = "Int64"
+ }
+ column "function_kind" {
+ type = "LowCardinality(String)"
+ }
+ column "function_id" {
+ type = "String"
+ }
+ column "invocation_id" {
+ type = "String"
+ }
+ column "parent_run_id" {
+ type = "String"
+ }
+ column "status" {
+ type = "LowCardinality(String)"
+ }
+ column "attempts" {
+ type = "UInt8"
+ }
+ column "is_retry" {
+ type = "UInt8"
+ }
+ column "scheduled_at" {
+ type = "DateTime64(6, 'UTC')"
+ }
+ column "first_scheduled_at" {
+ type = "DateTime64(6, 'UTC')"
+ }
+ column "started_at" {
+ type = "Nullable(DateTime64(6, 'UTC'))"
+ }
+ column "finished_at" {
+ type = "Nullable(DateTime64(6, 'UTC'))"
+ }
+ column "duration_ms" {
+ type = "Nullable(UInt32)"
+ }
+ column "error_kind" {
+ type = "LowCardinality(String)"
+ }
+ column "error_message" {
+ type = "String"
+ }
+ column "event_uuid" {
+ type = "String"
+ }
+ column "distinct_id" {
+ type = "String"
+ }
+ column "person_id" {
+ type = "String"
+ }
+ column "invocation_globals" {
+ type = "String"
+ }
+ column "version" {
+ type = "UInt64"
+ }
+ column "is_deleted" {
+ type = "UInt8"
+ }
+ column "_timestamp" {
+ type = "Nullable(DateTime)"
+ }
+ column "_offset" {
+ type = "UInt64"
+ }
+ column "_partition" {
+ type = "UInt64"
+ }
+ }
+ materialized_view "message_assets_mv" {
+ to_table = "posthog.message_assets_data"
+ query = file("sql/message_assets_mv.sql")
+
+ column "team_id" {
+ type = "Int64"
+ }
+ column "function_kind" {
+ type = "LowCardinality(String)"
+ }
+ column "function_id" {
+ type = "String"
+ }
+ column "parent_run_id" {
+ type = "String"
+ }
+ column "invocation_id" {
+ type = "String"
+ }
+ column "action_id" {
+ type = "String"
+ }
+ column "kind" {
+ type = "LowCardinality(String)"
+ }
+ column "distinct_id" {
+ type = "String"
+ }
+ column "person_id" {
+ type = "String"
+ }
+ column "recipient" {
+ type = "String"
+ }
+ column "subject" {
+ type = "String"
+ }
+ column "status" {
+ type = "LowCardinality(String)"
+ }
+ column "sent_at" {
+ type = "DateTime64(6, 'UTC')"
+ }
+ column "version" {
+ type = "UInt64"
+ }
+ column "is_deleted" {
+ type = "UInt8"
+ }
+ column "html" {
+ type = "String"
+ }
+ column "_timestamp" {
+ type = "Nullable(DateTime)"
+ }
+ column "_offset" {
+ type = "UInt64"
+ }
+ column "_partition" {
+ type = "UInt64"
+ }
+ }
+ materialized_view "property_values_mv" {
+ to_table = "posthog.property_values"
+ query = file("sql/property_values_mv.sql")
+
+ column "team_id" {
+ type = "Int64"
+ }
+ column "property_type" {
+ type = "LowCardinality(String)"
+ }
+ column "property_key" {
+ type = "String"
+ }
+ column "property_value" {
+ type = "String"
+ }
+ column "property_count" {
+ type = "UInt64"
+ }
+ column "last_seen" {
+ type = "DateTime"
+ }
+ }
+ 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" {
+ }
+ }
+}
diff --git a/posthog/clickhouse/hcl/roles/sessions/prod-eu/tables.hcl b/posthog/clickhouse/hcl/roles/sessions/prod-eu/tables.hcl
new file mode 100644
index 000000000000..b091fdf95aeb
--- /dev/null
+++ b/posthog/clickhouse/hcl/roles/sessions/prod-eu/tables.hcl
@@ -0,0 +1,1687 @@
+database "posthog" {
+ table "channel_definition" {
+ 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 "distributed" {
+ cluster_name = "posthog_single_shard"
+ remote_database = "posthog"
+ remote_table = "channel_definition"
+ }
+ }
+ table "events" {
+ 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_hash" {
+ type = "String"
+ }
+ column "created_at" {
+ type = "DateTime64(6, 'UTC')"
+ }
+ column "_timestamp" {
+ type = "DateTime"
+ }
+ column "_offset" {
+ type = "UInt64"
+ }
+ column "elements_chain" {
+ type = "String"
+ }
+ column "mat_$user_id" {
+ type = "String"
+ comment = "column_materializer::$user_id"
+ }
+ column "mat_$browser" {
+ type = "String"
+ comment = "column_materializer::$browser"
+ }
+ column "mat_$host" {
+ type = "String"
+ comment = "column_materializer::$host"
+ }
+ column "mat_$current_url" {
+ type = "String"
+ comment = "column_materializer::$current_url"
+ }
+ column "mat_distinct_id" {
+ type = "String"
+ comment = "column_materializer::distinct_id"
+ }
+ column "mat_action" {
+ type = "String"
+ comment = "column_materializer::action"
+ }
+ column "mat_origin" {
+ type = "String"
+ comment = "column_materializer::origin"
+ }
+ column "mat_email" {
+ type = "String"
+ comment = "column_materializer::email"
+ }
+ column "mat_key" {
+ type = "String"
+ comment = "column_materializer::key"
+ }
+ column "mat_insight" {
+ type = "String"
+ comment = "column_materializer::insight"
+ }
+ column "mat_$event_type" {
+ type = "String"
+ comment = "column_materializer::$event_type"
+ }
+ column "mat_created_by" {
+ type = "String"
+ comment = "column_materializer::created_by"
+ }
+ column "mat_total_event_actions_count" {
+ type = "String"
+ comment = "column_materializer::total_event_actions_count"
+ }
+ column "mat_is_demo_project" {
+ type = "String"
+ comment = "column_materializer::is_demo_project"
+ }
+ column "mat_$active_feature_flags" {
+ type = "String"
+ comment = "column_materializer::$active_feature_flags"
+ }
+ column "mat_filters_count" {
+ type = "String"
+ comment = "column_materializer::filters_count"
+ }
+ column "mat_utm_source" {
+ type = "String"
+ comment = "column_materializer::utm_source"
+ }
+ column "mat_apiErrorMessage" {
+ type = "String"
+ comment = "column_materializer::apiErrorMessage"
+ }
+ column "mat_$referring_domain" {
+ type = "String"
+ comment = "column_materializer::$referring_domain"
+ }
+ column "mat_statusCode" {
+ type = "String"
+ comment = "column_materializer::statusCode"
+ }
+ column "mat_deal_id" {
+ type = "String"
+ comment = "column_materializer::deal_id"
+ }
+ column "mat_realm" {
+ type = "String"
+ comment = "column_materializer::realm"
+ }
+ 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 "mat_$lib" {
+ type = "String"
+ comment = "column_materializer::$lib"
+ }
+ column "mat_$os" {
+ type = "String"
+ comment = "column_materializer::$os"
+ }
+ column "mat_$initial_referrer" {
+ type = "String"
+ comment = "column_materializer::$initial_referrer"
+ }
+ column "mat_$app_version" {
+ type = "String"
+ comment = "column_materializer::$app_version"
+ }
+ column "mat_$initial_referring_domain" {
+ type = "String"
+ comment = "column_materializer::$initial_referring_domain"
+ }
+ column "mat_symbol" {
+ type = "String"
+ comment = "column_materializer::symbol"
+ }
+ column "mat_page" {
+ type = "String"
+ comment = "column_materializer::page"
+ }
+ column "mat_type" {
+ type = "String"
+ comment = "column_materializer::type"
+ }
+ column "mat_currentScreen" {
+ type = "String"
+ comment = "column_materializer::currentScreen"
+ }
+ column "mat_utm_campaign" {
+ type = "String"
+ comment = "column_materializer::utm_campaign"
+ }
+ column "mat_is_organization_first_user" {
+ type = "String"
+ comment = "column_materializer::is_organization_first_user"
+ }
+ column "mat_is_first_component_load" {
+ type = "String"
+ comment = "column_materializer::is_first_component_load"
+ }
+ column "mat_team" {
+ type = "String"
+ comment = "column_materializer::team"
+ }
+ column "mat_context" {
+ type = "String"
+ comment = "column_materializer::context"
+ }
+ column "mat_sdk" {
+ type = "String"
+ comment = "column_materializer::sdk"
+ }
+ column "mat_created_by_system" {
+ type = "String"
+ comment = "column_materializer::created_by_system"
+ }
+ column "mat_item_count" {
+ type = "String"
+ comment = "column_materializer::item_count"
+ }
+ column "mat_$ip" {
+ type = "String"
+ comment = "column_materializer::$ip"
+ }
+ column "mat_$referrer" {
+ type = "String"
+ comment = "column_materializer::$referrer"
+ }
+ column "mat_action_name" {
+ type = "String"
+ comment = "column_materializer::action_name"
+ }
+ column "mat_$geoip_country_name" {
+ type = "String"
+ comment = "column_materializer::$geoip_country_name"
+ }
+ column "mat_$device_model" {
+ type = "String"
+ comment = "column_materializer::$device_model"
+ }
+ column "mat_progress" {
+ type = "String"
+ comment = "column_materializer::progress"
+ }
+ column "mat_chain" {
+ type = "String"
+ comment = "column_materializer::chain"
+ }
+ column "mat_$device_type" {
+ type = "String"
+ comment = "column_materializer::$device_type"
+ }
+ column "mat_usd" {
+ type = "String"
+ comment = "column_materializer::usd"
+ }
+ column "mat_app_name" {
+ type = "String"
+ comment = "column_materializer::app_name"
+ }
+ column "mat_$screen_name" {
+ type = "String"
+ comment = "column_materializer::$screen_name"
+ }
+ column "mat_index" {
+ type = "String"
+ comment = "column_materializer::index"
+ }
+ column "mat_token" {
+ type = "String"
+ comment = "column_materializer::token"
+ }
+ column "mat_method" {
+ type = "String"
+ comment = "column_materializer::method"
+ }
+ column "mat_address" {
+ type = "String"
+ comment = "column_materializer::address"
+ }
+ column "mat_name" {
+ type = "String"
+ comment = "column_materializer::name"
+ }
+ column "mat_inviteCode" {
+ type = "String"
+ comment = "column_materializer::inviteCode"
+ }
+ column "$window_id" {
+ type = "String"
+ comment = "column_materializer::$window_id"
+ }
+ column "$session_id" {
+ type = "String"
+ comment = "column_materializer::$session_id"
+ }
+ column "mat_osName" {
+ type = "String"
+ comment = "column_materializer::osName"
+ }
+ column "mat_nativeBuildVersion" {
+ type = "String"
+ comment = "column_materializer::nativeBuildVersion"
+ }
+ column "mat_revenue" {
+ type = "String"
+ comment = "column_materializer::revenue"
+ }
+ column "group_0" {
+ type = "String"
+ alias = "`$group_0`"
+ }
+ column "group_1" {
+ type = "String"
+ alias = "`$group_1`"
+ }
+ column "group_2" {
+ type = "String"
+ alias = "`$group_2`"
+ }
+ column "group_3" {
+ type = "String"
+ alias = "`$group_3`"
+ }
+ column "group_4" {
+ type = "String"
+ alias = "`$group_4`"
+ }
+ column "alias_mat__user_id" {
+ type = "String"
+ alias = "`mat_$user_id`"
+ }
+ column "alias_mat__browser" {
+ type = "String"
+ alias = "`mat_$browser`"
+ }
+ column "alias_mat__host" {
+ type = "String"
+ alias = "`mat_$host`"
+ }
+ column "alias_mat__current_url" {
+ type = "String"
+ alias = "`mat_$current_url`"
+ }
+ column "alias_mat__event_type" {
+ type = "String"
+ alias = "`mat_$event_type`"
+ }
+ column "alias_mat__active_feature_flags" {
+ type = "String"
+ alias = "`mat_$active_feature_flags`"
+ }
+ column "alias_mat__referring_domain" {
+ type = "String"
+ alias = "`mat_$referring_domain`"
+ }
+ column "alias_mat__lib" {
+ type = "String"
+ alias = "`mat_$lib`"
+ }
+ column "alias_mat__os" {
+ type = "String"
+ alias = "`mat_$os`"
+ }
+ column "alias_mat__initial_referrer" {
+ type = "String"
+ alias = "`mat_$initial_referrer`"
+ }
+ column "alias_mat__app_version" {
+ type = "String"
+ alias = "`mat_$app_version`"
+ }
+ column "alias_mat__initial_referring_domain" {
+ type = "String"
+ alias = "`mat_$initial_referring_domain`"
+ }
+ column "alias_mat__ip" {
+ type = "String"
+ alias = "`mat_$ip`"
+ }
+ column "alias_mat__referrer" {
+ type = "String"
+ alias = "`mat_$referrer`"
+ }
+ column "alias_mat__geoip_country_name" {
+ type = "String"
+ alias = "`mat_$geoip_country_name`"
+ }
+ column "alias_mat__device_model" {
+ type = "String"
+ alias = "`mat_$device_model`"
+ }
+ column "alias_mat__device_type" {
+ type = "String"
+ alias = "`mat_$device_type`"
+ }
+ column "alias_mat__screen_name" {
+ type = "String"
+ alias = "`mat_$screen_name`"
+ }
+ column "person_id" {
+ type = "UUID"
+ }
+ column "person_properties" {
+ type = "String"
+ }
+ column "group0_properties" {
+ type = "String"
+ }
+ column "group1_properties" {
+ type = "String"
+ }
+ column "group2_properties" {
+ type = "String"
+ }
+ column "group3_properties" {
+ type = "String"
+ }
+ column "group4_properties" {
+ type = "String"
+ }
+ column "person_created_at" {
+ type = "DateTime64(3)"
+ }
+ column "group0_created_at" {
+ type = "DateTime64(3)"
+ }
+ column "group1_created_at" {
+ type = "DateTime64(3)"
+ }
+ column "group2_created_at" {
+ type = "DateTime64(3)"
+ }
+ column "group3_created_at" {
+ type = "DateTime64(3)"
+ }
+ column "group4_created_at" {
+ type = "DateTime64(3)"
+ }
+ column "mat_arguments" {
+ type = "String"
+ comment = "column_materializer::properties::arguments"
+ }
+ column "mat_source" {
+ type = "String"
+ comment = "column_materializer::properties::source"
+ }
+ column "mat_pp_email" {
+ type = "String"
+ comment = "column_materializer::person_properties::email"
+ }
+ column "mat_$time" {
+ type = "String"
+ comment = "column_materializer::properties::$time"
+ }
+ column "mat_$pathname" {
+ type = "String"
+ comment = "column_materializer::properties::$pathname"
+ }
+ column "mat_$geoip_city_name" {
+ type = "String"
+ comment = "column_materializer::properties::$geoip_city_name"
+ }
+ column "mat_community_id" {
+ type = "String"
+ comment = "column_materializer::properties::community_id"
+ }
+ column "mat_thread_id" {
+ type = "String"
+ comment = "column_materializer::properties::thread_id"
+ }
+ column "mat_Event_productCode" {
+ type = "String"
+ comment = "column_materializer::properties::Event.productCode"
+ }
+ column "mat_env" {
+ type = "String"
+ comment = "column_materializer::properties::env"
+ }
+ column "mat_target" {
+ type = "String"
+ comment = "column_materializer::properties::target"
+ }
+ column "mat_Subscription_plan_amount" {
+ type = "String"
+ comment = "column_materializer::properties::Subscription.plan.amount"
+ }
+ column "mat_title" {
+ type = "String"
+ comment = "column_materializer::properties::title"
+ }
+ column "mat_Connection_app_name" {
+ type = "String"
+ comment = "column_materializer::properties::Connection.app.name"
+ }
+ column "mat_utm_medium" {
+ type = "String"
+ comment = "column_materializer::properties::utm_medium"
+ }
+ column "mat_Account_client_id" {
+ type = "String"
+ comment = "column_materializer::properties::Account.client_id"
+ }
+ column "mat_HTTP_Method" {
+ type = "String"
+ comment = "column_materializer::properties::HTTP Method"
+ }
+ column "mat_audio_duration" {
+ type = "String"
+ comment = "column_materializer::properties::audio_duration"
+ }
+ column "mat_duration" {
+ type = "String"
+ comment = "column_materializer::properties::duration"
+ }
+ column "mat_url" {
+ type = "String"
+ comment = "column_materializer::properties::url"
+ }
+ column "mat_group_id" {
+ type = "String"
+ comment = "column_materializer::properties::group_id"
+ }
+ column "mat_platform" {
+ type = "String"
+ comment = "column_materializer::properties::platform"
+ }
+ column "mat_pp_$browser" {
+ type = "String"
+ comment = "column_materializer::person_properties::$browser"
+ }
+ column "mat_payment_status" {
+ type = "String"
+ comment = "column_materializer::properties::payment_status"
+ }
+ column "mat_testSessionId" {
+ type = "String"
+ comment = "column_materializer::properties::testSessionId"
+ }
+ column "inserted_at" {
+ type = "Nullable(DateTime64(6, 'UTC'))"
+ default = "now64()"
+ }
+ column "mat_$sent_at" {
+ type = "String"
+ comment = "column_materializer::properties::$sent_at"
+ }
+ column "mat_pp_companyName" {
+ type = "String"
+ comment = "column_materializer::person_properties::companyName"
+ }
+ column "mat_function" {
+ type = "String"
+ comment = "column_materializer::properties::function"
+ }
+ column "mat_store_url" {
+ type = "String"
+ comment = "column_materializer::properties::store_url"
+ }
+ column "mat_email_domain" {
+ type = "String"
+ comment = "column_materializer::properties::email_domain"
+ }
+ column "mat_institution_name" {
+ type = "String"
+ comment = "column_materializer::properties::institution_name"
+ }
+ column "mat_authentication_method" {
+ type = "String"
+ comment = "column_materializer::properties::authentication_method"
+ }
+ column "mat_initial_step" {
+ type = "String"
+ comment = "column_materializer::properties::initial_step"
+ }
+ column "mat_status_message" {
+ type = "String"
+ comment = "column_materializer::properties::status_message"
+ }
+ column "mat_mode" {
+ type = "String"
+ comment = "column_materializer::properties::mode"
+ }
+ column "mat_protocol" {
+ type = "String"
+ comment = "column_materializer::properties::protocol"
+ }
+ column "mat_job_type" {
+ type = "String"
+ comment = "column_materializer::properties::job_type"
+ }
+ column "mat_is_oauth" {
+ type = "String"
+ comment = "column_materializer::properties::is_oauth"
+ }
+ column "mat_is_initial_aggregation" {
+ type = "String"
+ comment = "column_materializer::properties::is_initial_aggregation"
+ }
+ column "mat_search_term" {
+ type = "String"
+ comment = "column_materializer::properties::search_term"
+ }
+ column "mat_valid_ach_accounts" {
+ type = "String"
+ comment = "column_materializer::properties::valid_ach_accounts"
+ }
+ column "mat_gross" {
+ type = "String"
+ comment = "column_materializer::properties::gross"
+ }
+ column "mat_orderType" {
+ type = "String"
+ comment = "column_materializer::properties::orderType"
+ }
+ column "mat_sku" {
+ type = "String"
+ comment = "column_materializer::properties::sku"
+ }
+ column "mat_dual_channel" {
+ type = "String"
+ comment = "column_materializer::properties::dual_channel"
+ }
+ column "mat_channel" {
+ type = "String"
+ comment = "column_materializer::properties::channel"
+ }
+ column "mat_workspaceId" {
+ type = "String"
+ comment = "column_materializer::properties::workspaceId"
+ }
+ column "mat_numberOfSecrets" {
+ type = "String"
+ comment = "column_materializer::properties::numberOfSecrets"
+ }
+ column "mat_organizations" {
+ type = "String"
+ comment = "column_materializer::properties::organizations"
+ }
+ column "mat_organization" {
+ type = "String"
+ comment = "column_materializer::properties::organization"
+ }
+ column "mat_contributionError" {
+ type = "String"
+ comment = "column_materializer::properties::contributionError"
+ }
+ column "mat_phone" {
+ type = "String"
+ comment = "column_materializer::properties::phone"
+ }
+ column "mat_$initial_pathname" {
+ type = "String"
+ comment = "column_materializer::properties::$initial_pathname"
+ }
+ column "mat_organization_name" {
+ type = "String"
+ comment = "column_materializer::properties::organization_name"
+ }
+ column "mat_category" {
+ type = "String"
+ comment = "column_materializer::properties::category"
+ }
+ column "mat_$lib_version" {
+ type = "String"
+ comment = "column_materializer::properties::$lib_version"
+ }
+ column "mat_pp_$initial_utm_campaign" {
+ type = "String"
+ comment = "column_materializer::person_properties::$initial_utm_campaign"
+ }
+ column "mat_pp_$initial_utm_medium" {
+ type = "String"
+ comment = "column_materializer::person_properties::$initial_utm_medium"
+ }
+ column "mat_pp_$initial_gclid" {
+ type = "String"
+ comment = "column_materializer::person_properties::$initial_gclid"
+ }
+ column "mat_pp_$initial_gad_source" {
+ type = "String"
+ comment = "column_materializer::person_properties::$initial_gad_source"
+ }
+ column "mat_pp_$initial_utm_source" {
+ type = "String"
+ comment = "column_materializer::person_properties::$initial_utm_source"
+ }
+ column "mat_pp_$initial_referring_domain" {
+ type = "String"
+ comment = "column_materializer::person_properties::$initial_referring_domain"
+ }
+ column "mat_pp_$initial_utm_term" {
+ type = "String"
+ comment = "column_materializer::person_properties::$initial_utm_term"
+ }
+ column "mat_pp_$initial_utm_content" {
+ type = "String"
+ comment = "column_materializer::person_properties::$initial_utm_content"
+ }
+ column "mat_pp_$initial_gbraid" {
+ type = "String"
+ comment = "column_materializer::person_properties::$initial_gbraid::disabled"
+ }
+ column "mat_pp_$initial_wbraid" {
+ type = "String"
+ comment = "column_materializer::person_properties::$initial_wbraid::disabled"
+ }
+ column "mat_pp_$initial_msclkid" {
+ type = "String"
+ comment = "column_materializer::person_properties::$initial_msclkid"
+ }
+ column "mat_pp_$initial_fbclid" {
+ type = "String"
+ comment = "column_materializer::person_properties::$initial_fbclid"
+ }
+ column "mat_$geoip_subdivision_1_code" {
+ type = "String"
+ comment = "column_materializer::properties::$geoip_subdivision_1_code"
+ }
+ column "mat_wlo_enabled" {
+ type = "String"
+ comment = "column_materializer::properties::wlo_enabled"
+ }
+ column "mat_$prev_pageview_max_scroll_percentage" {
+ type = "String"
+ comment = "column_materializer::properties::$prev_pageview_max_scroll_percentage"
+ }
+ column "mat_$prev_pageview_max_content_percentage" {
+ type = "String"
+ comment = "column_materializer::properties::$prev_pageview_max_content_percentage"
+ }
+ column "mat_$prev_pageview_pathname" {
+ type = "String"
+ comment = "column_materializer::properties::$prev_pageview_pathname"
+ }
+ column "mat_pp_$initial_pathname" {
+ type = "String"
+ comment = "column_materializer::person_properties::$initial_pathname"
+ }
+ column "mat_pp_$geoip_country_code" {
+ type = "String"
+ comment = "column_materializer::person_properties::$geoip_country_code"
+ }
+ column "mat_pp_username" {
+ type = "String"
+ comment = "column_materializer::person_properties::username"
+ }
+ column "mat_pp_serverMasterclass" {
+ type = "String"
+ comment = "column_materializer::person_properties::serverMasterclass"
+ }
+ column "mat_content_length" {
+ type = "String"
+ comment = "column_materializer::properties::content_length"
+ }
+ column "mat_pp_serverMarketing" {
+ type = "String"
+ comment = "column_materializer::person_properties::serverMarketing"
+ }
+ column "mat_$browser_version" {
+ type = "String"
+ comment = "column_materializer::properties::$browser_version"
+ }
+ column "mat_pp_role" {
+ type = "String"
+ comment = "column_materializer::person_properties::role"
+ }
+ column "mat_pp_customer" {
+ type = "String"
+ comment = "column_materializer::person_properties::customer"
+ }
+ column "mat_event" {
+ type = "String"
+ comment = "column_materializer::properties::event"
+ }
+ column "mat_disable_institution_search" {
+ type = "String"
+ comment = "column_materializer::properties::disable_institution_search"
+ }
+ column "mat_is_first_event_for_user" {
+ type = "String"
+ comment = "column_materializer::properties::is_first_event_for_user"
+ }
+ column "mat_current_member_guid" {
+ type = "String"
+ comment = "column_materializer::properties::current_member_guid"
+ }
+ column "mat_user_agent" {
+ type = "String"
+ comment = "column_materializer::properties::user_agent"
+ }
+ column "mat_is_test_user" {
+ type = "String"
+ comment = "column_materializer::properties::is_test_user"
+ }
+ column "mat_referrer" {
+ type = "String"
+ comment = "column_materializer::properties::referrer"
+ }
+ column "mat_pp_$initial_current_url" {
+ type = "String"
+ comment = "column_materializer::person_properties::$initial_current_url"
+ }
+ column "mat_most_recent_app_os" {
+ type = "String"
+ comment = "column_materializer::properties::most_recent_app_os"
+ }
+ column "mat_pp_hubspot_score" {
+ type = "String"
+ comment = "column_materializer::person_properties::hubspot_score"
+ }
+ column "mat_pp_id" {
+ type = "String"
+ comment = "column_materializer::person_properties::id"
+ }
+ column "mat_pp_$current_url" {
+ type = "String"
+ comment = "column_materializer::person_properties::$current_url"
+ }
+ column "mat_product_key" {
+ type = "String"
+ comment = "column_materializer::properties::product_key"
+ }
+ column "mat_Plan_type_and_filter" {
+ type = "String"
+ comment = "column_materializer::properties::Plan type and filter"
+ }
+ column "mat_$app_namespace" {
+ type = "String"
+ comment = "column_materializer::properties::$app_namespace"
+ }
+ column "mat_$os_name" {
+ type = "String"
+ comment = "column_materializer::properties::$os_name"
+ }
+ column "mat_pp_$os_name" {
+ type = "String"
+ comment = "column_materializer::person_properties::$os_name::disabled"
+ }
+ column "mat_pp_$app_version" {
+ type = "String"
+ comment = "column_materializer::person_properties::$app_version"
+ }
+ column "mat_subscriptionStatus" {
+ type = "String"
+ comment = "column_materializer::properties::subscriptionStatus"
+ }
+ column "mat_$screen_height" {
+ type = "String"
+ comment = "column_materializer::properties::$screen_height"
+ }
+ column "mat_$screen_width" {
+ type = "String"
+ comment = "column_materializer::properties::$screen_width"
+ }
+ column "mat_tag" {
+ type = "String"
+ comment = "column_materializer::properties::tag"
+ }
+ column "mat_$app_build" {
+ type = "String"
+ comment = "column_materializer::properties::$app_build"
+ }
+ column "mat_surface_tag" {
+ type = "String"
+ comment = "column_materializer::properties::surface_tag"
+ }
+ column "mat_survey_responses_count_in_period" {
+ type = "String"
+ comment = "column_materializer::properties::survey_responses_count_in_period"
+ }
+ column "mat_event_count_in_month" {
+ type = "String"
+ comment = "column_materializer::properties::event_count_in_month"
+ }
+ column "mat_ramp" {
+ type = "String"
+ comment = "column_materializer::properties::ramp"
+ }
+ column "mat_auto_chapters" {
+ type = "String"
+ comment = "column_materializer::properties::auto_chapters"
+ }
+ column "mat_sentiment_analysis" {
+ type = "String"
+ comment = "column_materializer::properties::sentiment_analysis"
+ }
+ column "mat_redact_pii" {
+ type = "String"
+ comment = "column_materializer::properties::redact_pii"
+ }
+ column "mat_content_safety" {
+ type = "String"
+ comment = "column_materializer::properties::content_safety"
+ }
+ column "mat_iab_categories" {
+ type = "String"
+ comment = "column_materializer::properties::iab_categories"
+ }
+ column "mat_auto_highlights" {
+ type = "String"
+ comment = "column_materializer::properties::auto_highlights"
+ }
+ column "mat_entity_detection" {
+ type = "String"
+ comment = "column_materializer::properties::entity_detection"
+ }
+ column "mat_summarization" {
+ type = "String"
+ comment = "column_materializer::properties::summarization"
+ }
+ column "mat_pp_val_region" {
+ type = "String"
+ comment = "column_materializer::person_properties::val_region"
+ }
+ column "mat_client_id" {
+ type = "String"
+ comment = "column_materializer::properties::client_id"
+ }
+ column "mat_$geoip_country_code" {
+ type = "String"
+ comment = "column_materializer::properties::$geoip_country_code"
+ }
+ column "mat_disfluencies" {
+ type = "String"
+ comment = "column_materializer::properties::disfluencies"
+ }
+ column "mat_filter_profanity" {
+ type = "String"
+ comment = "column_materializer::properties::filter_profanity"
+ }
+ column "mat_speaker_labels" {
+ type = "String"
+ comment = "column_materializer::properties::speaker_labels"
+ }
+ column "mat_language_detection" {
+ type = "String"
+ comment = "column_materializer::properties::language_detection"
+ }
+ column "mat_product_analytics_projected_amount" {
+ type = "String"
+ comment = "column_materializer::properties::product_analytics_projected_amount"
+ }
+ column "mat_recordings_projected_amount" {
+ type = "String"
+ comment = "column_materializer::properties::recordings_projected_amount"
+ }
+ column "mat_events_projected_amount" {
+ type = "String"
+ comment = "column_materializer::properties::events_projected_amount"
+ }
+ column "mat_session_replay_projected_amount" {
+ type = "String"
+ comment = "column_materializer::properties::session_replay_projected_amount"
+ }
+ column "mat_total_usd" {
+ type = "String"
+ comment = "column_materializer::properties::total_usd"
+ }
+ column "mat_stripe_amount_paid" {
+ type = "String"
+ comment = "column_materializer::properties::stripe_amount_paid"
+ }
+ column "mat_workspace" {
+ type = "String"
+ comment = "column_materializer::properties::workspace"
+ }
+ column "mat_created_at" {
+ type = "String"
+ comment = "column_materializer::properties::created_at"
+ }
+ column "mat_kind" {
+ type = "String"
+ comment = "column_materializer::properties::kind"
+ }
+ column "mat_product" {
+ type = "String"
+ comment = "column_materializer::properties::product"
+ }
+ column "mat_message" {
+ type = "String"
+ comment = "column_materializer::properties::message"
+ }
+ column "mat_initiator" {
+ type = "String"
+ comment = "column_materializer::properties::initiator"
+ }
+ column "mat_query" {
+ type = "String"
+ comment = "column_materializer::properties::query"
+ }
+ column "mat_$survey_id" {
+ type = "String"
+ comment = "column_materializer::properties::$survey_id"
+ }
+ column "mat_$survey_response_1" {
+ type = "String"
+ comment = "column_materializer::properties::$survey_response_1"
+ }
+ column "mat_ticketId" {
+ type = "String"
+ comment = "column_materializer::properties::ticketId"
+ }
+ column "mat_$survey_response" {
+ type = "String"
+ comment = "column_materializer::properties::$survey_response"
+ }
+ column "mat_conceptName" {
+ type = "String"
+ comment = "column_materializer::properties::conceptName"
+ }
+ column "mat_apiName" {
+ type = "String"
+ comment = "column_materializer::properties::apiName"
+ }
+ column "mat_workplace_billing_plan" {
+ type = "String"
+ comment = "column_materializer::properties::workplace_billing_plan"
+ }
+ column "mat_$el_text" {
+ type = "String"
+ comment = "column_materializer::properties::$el_text"
+ }
+ column "mat_recording_count_in_period" {
+ type = "String"
+ comment = "column_materializer::properties::recording_count_in_period"
+ }
+ column "mat_$os_version" {
+ type = "String"
+ comment = "column_materializer::properties::$os_version"
+ }
+ column "mat_orderId" {
+ type = "String"
+ comment = "column_materializer::properties::orderId"
+ }
+ column "mat_commit_sha" {
+ type = "String"
+ comment = "column_materializer::properties::commit_sha"
+ }
+ column "mat_$feature_flag_payloads" {
+ type = "String"
+ comment = "column_materializer::properties::$feature_flag_payloads"
+ }
+ column "mat_event_count_in_period" {
+ type = "String"
+ comment = "column_materializer::properties::event_count_in_period"
+ }
+ column "mat_$groups" {
+ type = "String"
+ comment = "column_materializer::properties::$groups"
+ }
+ column "mat_$feature_flag" {
+ type = "String"
+ comment = "column_materializer::properties::$feature_flag"
+ }
+ column "mat_utm_content" {
+ type = "String"
+ comment = "column_materializer::properties::utm_content"
+ }
+ column "mat_gclid" {
+ type = "String"
+ comment = "column_materializer::properties::gclid"
+ }
+ column "mat_gad_source" {
+ type = "String"
+ comment = "column_materializer::properties::gad_source"
+ }
+ column "mat_gbraid" {
+ type = "String"
+ comment = "column_materializer::properties::gbraid"
+ }
+ column "mat_wbraid" {
+ type = "String"
+ comment = "column_materializer::properties::wbraid"
+ }
+ column "mat_fbclid" {
+ type = "String"
+ comment = "column_materializer::properties::fbclid"
+ }
+ column "mat_msclkid" {
+ type = "String"
+ comment = "column_materializer::properties::msclkid"
+ }
+ column "mat_organization_id" {
+ type = "String"
+ comment = "column_materializer::properties::organization_id"
+ }
+ column "mat_owner_type" {
+ type = "String"
+ comment = "column_materializer::properties::owner_type"
+ }
+ column "mat_device_type" {
+ type = "String"
+ comment = "column_materializer::properties::device_type"
+ }
+ column "mat_$device_id" {
+ type = "String"
+ comment = "column_materializer::properties::$device_id"
+ }
+ column "mat_pp_$geoip_continent_name" {
+ type = "String"
+ comment = "column_materializer::person_properties::$geoip_continent_name"
+ }
+ column "mat_$feature_flag_response" {
+ type = "String"
+ comment = "column_materializer::properties::$feature_flag_response"
+ }
+ column "mat_pp_utm_source" {
+ type = "String"
+ comment = "column_materializer::person_properties::utm_source"
+ }
+ column "mat_pp_$referring_domain" {
+ type = "String"
+ comment = "column_materializer::person_properties::$referring_domain"
+ }
+ column "mat_pp_Email_Domain" {
+ type = "String"
+ comment = "column_materializer::person_properties::Email Domain"
+ }
+ column "mat_machine_id" {
+ type = "String"
+ comment = "column_materializer::properties::machine_id"
+ }
+ column "mat_user_email_domain" {
+ type = "String"
+ comment = "column_materializer::properties::user_email_domain"
+ }
+ column "mat_$lib_version__minor" {
+ type = "String"
+ comment = "column_materializer::properties::$lib_version__minor"
+ }
+ column "mat_region" {
+ type = "String"
+ comment = "column_materializer::properties::region"
+ }
+ column "mat_pp_user_email_domain" {
+ type = "String"
+ comment = "column_materializer::person_properties::user_email_domain"
+ }
+ column "mat_url_promotion_id" {
+ type = "String"
+ comment = "column_materializer::properties::url_promotion_id"
+ }
+ column "mat_$lib_custom_api_host" {
+ type = "String"
+ comment = "column_materializer::properties::$lib_custom_api_host"
+ }
+ column "person_mode" {
+ type = "Enum8('full'=0, 'propertyless'=1, 'force_upgrade'=2)"
+ }
+ column "mat_user_platform" {
+ type = "String"
+ comment = "column_materializer::properties::user_platform"
+ }
+ column "mat_pp_$geoip_country_name" {
+ type = "String"
+ comment = "column_materializer::person_properties::$geoip_country_name"
+ }
+ column "mat_environment" {
+ type = "String"
+ comment = "column_materializer::properties::environment"
+ }
+ column "mat_customer_email" {
+ type = "String"
+ comment = "column_materializer::properties::customer_email"
+ }
+ column "mat_client_name" {
+ type = "String"
+ comment = "column_materializer::properties::client_name"
+ }
+ column "mat_screen_name" {
+ type = "String"
+ comment = "column_materializer::properties::screen_name"
+ }
+ column "mat_app_version" {
+ type = "String"
+ comment = "column_materializer::properties::app_version"
+ }
+ column "elements_chain_href" {
+ type = "String"
+ comment = "column_materializer::elements_chain::href"
+ }
+ column "elements_chain_texts" {
+ type = "Array(String)"
+ comment = "column_materializer::elements_chain::texts"
+ }
+ column "elements_chain_ids" {
+ type = "Array(String)"
+ comment = "column_materializer::elements_chain::ids"
+ }
+ column "elements_chain_elements" {
+ type = "Array(Enum8('a'=1, 'button'=2, 'form'=3, 'input'=4, 'select'=5, 'textarea'=6, 'label'=7))"
+ comment = "column_materializer::elements_chain::elements"
+ }
+ column "properties_group_custom" {
+ type = "Map(String, String)"
+ }
+ column "properties_group_feature_flags" {
+ type = "Map(String, String)"
+ }
+ column "is_deleted" {
+ type = "Bool"
+ }
+ column "mat_subdomain" {
+ type = "String"
+ comment = "column_materializer::properties::subdomain"
+ }
+ column "mat_$device" {
+ type = "String"
+ comment = "column_materializer::properties::$device"
+ }
+ column "mat_id" {
+ type = "String"
+ comment = "column_materializer::properties::id"
+ }
+ column "mat_record_id" {
+ type = "String"
+ comment = "column_materializer::properties::record_id"
+ }
+ column "mat_referrer_id" {
+ type = "String"
+ comment = "column_materializer::properties::record_id"
+ }
+ column "mat_$exception_issue_id" {
+ type = "Nullable(String)"
+ comment = "column_materializer::properties::$exception_issue_id"
+ }
+ column "mat_$exception_fingerprint" {
+ type = "Nullable(String)"
+ comment = "column_materializer::properties::$exception_fingerprint"
+ }
+ column "mat_$web_vitals_LCP_value" {
+ type = "Nullable(String)"
+ comment = "column_materializer::properties::$web_vitals_LCP_value"
+ }
+ column "mat_$web_vitals_FCP_value" {
+ type = "Nullable(String)"
+ comment = "column_materializer::properties::$web_vitals_FCP_value"
+ }
+ column "mat_$web_vitals_CLS_value" {
+ type = "Nullable(String)"
+ comment = "column_materializer::properties::$web_vitals_CLS_value"
+ }
+ column "mat_$web_vitals_INP_value" {
+ type = "Nullable(String)"
+ comment = "column_materializer::properties::$web_vitals_INP_value"
+ }
+ column "mat_$viewport_width" {
+ type = "Nullable(String)"
+ comment = "column_materializer::properties::$viewport_width"
+ }
+ column "mat_$viewport_height" {
+ type = "Nullable(String)"
+ comment = "column_materializer::properties::$viewport_height"
+ }
+ column "mat_$anon_distinct_id" {
+ type = "Nullable(String)"
+ comment = "column_materializer::properties::$anon_distinct_id"
+ }
+ column "person_properties_map_custom" {
+ type = "Map(String, String)"
+ }
+ column "mat_$ai_trace_id" {
+ type = "Nullable(String)"
+ comment = "column_materializer::properties::$ai_trace_id"
+ }
+ column "mat_$ai_model" {
+ type = "Nullable(String)"
+ comment = "column_materializer::properties::$ai_model"
+ }
+ column "mat_$ai_provider" {
+ type = "Nullable(String)"
+ comment = "column_materializer::properties::$ai_provider"
+ }
+ column "mat_$ai_parent_id" {
+ type = "Nullable(String)"
+ comment = "column_materializer::properties::$ai_parent_id"
+ }
+ column "mat_$ai_span_id" {
+ type = "Nullable(String)"
+ comment = "column_materializer::properties::$ai_span_id"
+ }
+ column "mat_$ai_http_status" {
+ type = "Nullable(String)"
+ comment = "column_materializer::properties::$ai_http_status"
+ }
+ column "mat_$exception_types" {
+ type = "Nullable(String)"
+ comment = "column_materializer::properties::$exception_types"
+ }
+ column "mat_$exception_values" {
+ type = "Nullable(String)"
+ comment = "column_materializer::properties::$exception_values"
+ }
+ column "mat_$exception_sources" {
+ type = "Nullable(String)"
+ comment = "column_materializer::properties::$exception_sources"
+ }
+ column "mat_$exception_functions" {
+ type = "Nullable(String)"
+ comment = "column_materializer::properties::$exception_functions"
+ }
+ column "$session_id_uuid" {
+ type = "Nullable(UInt128)"
+ }
+ column "mat_$process_person_profile" {
+ type = "Nullable(String)"
+ comment = "column_materializer::properties::$process_person_profile"
+ }
+ column "consumer_breadcrumbs" {
+ type = "Array(String)"
+ }
+ column "properties_group_ai" {
+ type = "Map(String, String)"
+ }
+ column "mat_$is_identified" {
+ type = "Nullable(String)"
+ comment = "column_materializer::properties::$is_identified"
+ }
+ column "mat_historical_migration" {
+ type = "Nullable(String)"
+ comment = "column_materializer::properties::historical_migration"
+ }
+ column "mat_$ai_session_id" {
+ type = "Nullable(String)"
+ comment = "column_materializer::properties::$ai_session_id"
+ }
+ column "mat_$ai_is_error" {
+ type = "Nullable(String)"
+ comment = "column_materializer::properties::$ai_is_error"
+ }
+ column "dmat_string_0" {
+ type = "Nullable(String)"
+ }
+ column "dmat_string_1" {
+ type = "Nullable(String)"
+ }
+ column "dmat_string_2" {
+ type = "Nullable(String)"
+ }
+ column "dmat_string_3" {
+ type = "Nullable(String)"
+ }
+ column "dmat_string_4" {
+ type = "Nullable(String)"
+ }
+ column "dmat_string_5" {
+ type = "Nullable(String)"
+ }
+ column "dmat_string_6" {
+ type = "Nullable(String)"
+ }
+ column "dmat_string_7" {
+ type = "Nullable(String)"
+ }
+ column "dmat_string_8" {
+ type = "Nullable(String)"
+ }
+ column "dmat_string_9" {
+ type = "Nullable(String)"
+ }
+ column "dmat_numeric_0" {
+ type = "Nullable(Float64)"
+ }
+ column "dmat_numeric_1" {
+ type = "Nullable(Float64)"
+ }
+ column "dmat_numeric_2" {
+ type = "Nullable(Float64)"
+ }
+ column "dmat_numeric_3" {
+ type = "Nullable(Float64)"
+ }
+ column "dmat_numeric_4" {
+ type = "Nullable(Float64)"
+ }
+ column "dmat_numeric_5" {
+ type = "Nullable(Float64)"
+ }
+ column "dmat_numeric_6" {
+ type = "Nullable(Float64)"
+ }
+ column "dmat_numeric_7" {
+ type = "Nullable(Float64)"
+ }
+ column "dmat_numeric_8" {
+ type = "Nullable(Float64)"
+ }
+ column "dmat_numeric_9" {
+ type = "Nullable(Float64)"
+ }
+ column "dmat_bool_0" {
+ type = "Nullable(UInt8)"
+ }
+ column "dmat_bool_1" {
+ type = "Nullable(UInt8)"
+ }
+ column "dmat_bool_2" {
+ type = "Nullable(UInt8)"
+ }
+ column "dmat_bool_3" {
+ type = "Nullable(UInt8)"
+ }
+ column "dmat_bool_4" {
+ type = "Nullable(UInt8)"
+ }
+ column "dmat_bool_5" {
+ type = "Nullable(UInt8)"
+ }
+ column "dmat_bool_6" {
+ type = "Nullable(UInt8)"
+ }
+ column "dmat_bool_7" {
+ type = "Nullable(UInt8)"
+ }
+ column "dmat_bool_8" {
+ type = "Nullable(UInt8)"
+ }
+ column "dmat_bool_9" {
+ type = "Nullable(UInt8)"
+ }
+ column "dmat_datetime_0" {
+ type = "Nullable(DateTime64(6, 'UTC'))"
+ }
+ column "dmat_datetime_1" {
+ type = "Nullable(DateTime64(6, 'UTC'))"
+ }
+ column "dmat_datetime_2" {
+ type = "Nullable(DateTime64(6, 'UTC'))"
+ }
+ column "dmat_datetime_3" {
+ type = "Nullable(DateTime64(6, 'UTC'))"
+ }
+ column "dmat_datetime_4" {
+ type = "Nullable(DateTime64(6, 'UTC'))"
+ }
+ column "dmat_datetime_5" {
+ type = "Nullable(DateTime64(6, 'UTC'))"
+ }
+ column "dmat_datetime_6" {
+ type = "Nullable(DateTime64(6, 'UTC'))"
+ }
+ column "dmat_datetime_7" {
+ type = "Nullable(DateTime64(6, 'UTC'))"
+ }
+ column "dmat_datetime_8" {
+ type = "Nullable(DateTime64(6, 'UTC'))"
+ }
+ column "dmat_datetime_9" {
+ type = "Nullable(DateTime64(6, 'UTC'))"
+ }
+ column "historical_migration" {
+ type = "Bool"
+ }
+ column "mat_$ai_total_cost_usd" {
+ type = "Nullable(String)"
+ comment = "column_materializer::properties::$ai_total_cost_usd"
+ }
+ column "properties_group_ai_large" {
+ type = "Map(String, String)"
+ }
+ 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"
+ }
+ column "mat_$survey_submission_id" {
+ type = "Nullable(String)"
+ comment = "column_materializer::properties::$survey_submission_id"
+ }
+ column "mat_$geoip_subdivision_1_name" {
+ type = "Nullable(String)"
+ comment = "column_materializer::properties::$geoip_subdivision_1_name"
+ }
+ column "mat_$raw_user_agent" {
+ type = "Nullable(String)"
+ comment = "column_materializer::properties::$raw_user_agent"
+ }
+ column "mat_$prev_pageview_duration" {
+ type = "Nullable(String)"
+ comment = "column_materializer::properties::$prev_pageview_duration"
+ }
+ column "mat_pp_$initial_host" {
+ type = "Nullable(String)"
+ comment = "column_materializer::person_properties::$initial_host"
+ }
+ column "mat_pp_$initial_url" {
+ type = "Nullable(String)"
+ comment = "column_materializer::person_properties::$initial_url"
+ }
+ column "mat_pp_$initial_geoip_country_name" {
+ type = "Nullable(String)"
+ comment = "column_materializer::person_properties::$initial_geoip_country_name"
+ }
+ engine "distributed" {
+ cluster_name = "posthog"
+ remote_database = "posthog"
+ remote_table = "sharded_events"
+ sharding_key = "sipHash64(distinct_id)"
+ }
+ }
+ table "raw_sessions_v3" {
+ order_by = ["team_id", "session_timestamp", "session_id_v7"]
+ partition_by = "toYYYYMM(session_timestamp)"
+ settings = {
+ index_granularity = "8192"
+ }
+ 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, 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
+ }
+ engine "replicated_aggregating_merge_tree" {
+ zoo_path = "/clickhouse/tables/sessions/noshard/posthog.raw_sessions_v3"
+ replica_name = "{shard}-{replica}"
+ }
+ }
+}
diff --git a/posthog/clickhouse/hcl/roles/sessions/prod-us/tables.hcl b/posthog/clickhouse/hcl/roles/sessions/prod-us/tables.hcl
new file mode 100644
index 000000000000..98fa8bafd0af
--- /dev/null
+++ b/posthog/clickhouse/hcl/roles/sessions/prod-us/tables.hcl
@@ -0,0 +1,1751 @@
+database "posthog" {
+ table "channel_definition" {
+ order_by = ["domain", "kind"]
+ settings = {
+ default_compression_codec = "lz4"
+ 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/sessions/noshard/posthog.channel_definition"
+ replica_name = "{replica}-{shard}"
+ }
+ }
+ table "events" {
+ 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_hash" {
+ type = "String"
+ }
+ column "created_at" {
+ type = "DateTime64(6, 'UTC')"
+ }
+ column "_timestamp" {
+ type = "DateTime"
+ }
+ column "_offset" {
+ type = "UInt64"
+ }
+ column "elements_chain" {
+ type = "String"
+ }
+ column "mat_$user_id" {
+ type = "String"
+ comment = "column_materializer::$user_id"
+ }
+ column "mat_$browser" {
+ type = "String"
+ comment = "column_materializer::$browser"
+ }
+ column "mat_$host" {
+ type = "String"
+ comment = "column_materializer::$host"
+ }
+ column "mat_$current_url" {
+ type = "String"
+ comment = "column_materializer::$current_url"
+ }
+ column "mat_distinct_id" {
+ type = "String"
+ comment = "column_materializer::distinct_id"
+ }
+ column "mat_action" {
+ type = "String"
+ comment = "column_materializer::action"
+ }
+ column "mat_origin" {
+ type = "String"
+ comment = "column_materializer::origin"
+ }
+ column "mat_email" {
+ type = "String"
+ comment = "column_materializer::email"
+ }
+ column "mat_key" {
+ type = "String"
+ comment = "column_materializer::key"
+ }
+ column "mat_insight" {
+ type = "String"
+ comment = "column_materializer::insight"
+ }
+ column "mat_$event_type" {
+ type = "String"
+ comment = "column_materializer::$event_type"
+ }
+ column "mat_created_by" {
+ type = "String"
+ comment = "column_materializer::created_by"
+ }
+ column "mat_total_event_actions_count" {
+ type = "String"
+ comment = "column_materializer::total_event_actions_count"
+ }
+ column "mat_is_demo_project" {
+ type = "String"
+ comment = "column_materializer::is_demo_project"
+ }
+ column "mat_$active_feature_flags" {
+ type = "String"
+ comment = "column_materializer::$active_feature_flags"
+ }
+ column "mat_filters_count" {
+ type = "String"
+ comment = "column_materializer::filters_count"
+ }
+ column "mat_utm_source" {
+ type = "String"
+ comment = "column_materializer::utm_source"
+ }
+ column "mat_apiErrorMessage" {
+ type = "String"
+ comment = "column_materializer::apiErrorMessage"
+ }
+ column "mat_$referring_domain" {
+ type = "String"
+ comment = "column_materializer::$referring_domain"
+ }
+ column "mat_statusCode" {
+ type = "String"
+ comment = "column_materializer::statusCode"
+ }
+ column "mat_deal_id" {
+ type = "String"
+ comment = "column_materializer::deal_id"
+ }
+ column "mat_realm" {
+ type = "String"
+ comment = "column_materializer::realm"
+ }
+ 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 "mat_$lib" {
+ type = "String"
+ comment = "column_materializer::$lib"
+ }
+ column "mat_$os" {
+ type = "String"
+ comment = "column_materializer::$os"
+ }
+ column "mat_$initial_referrer" {
+ type = "String"
+ comment = "column_materializer::$initial_referrer"
+ }
+ column "mat_$app_version" {
+ type = "String"
+ comment = "column_materializer::$app_version"
+ }
+ column "mat_$initial_referring_domain" {
+ type = "String"
+ comment = "column_materializer::$initial_referring_domain"
+ }
+ column "mat_symbol" {
+ type = "String"
+ comment = "column_materializer::symbol"
+ }
+ column "mat_page" {
+ type = "String"
+ comment = "column_materializer::page"
+ }
+ column "mat_type" {
+ type = "String"
+ comment = "column_materializer::type"
+ }
+ column "mat_currentScreen" {
+ type = "String"
+ comment = "column_materializer::currentScreen"
+ }
+ column "mat_utm_campaign" {
+ type = "String"
+ comment = "column_materializer::utm_campaign"
+ }
+ column "mat_is_organization_first_user" {
+ type = "String"
+ comment = "column_materializer::is_organization_first_user"
+ }
+ column "mat_is_first_component_load" {
+ type = "String"
+ comment = "column_materializer::is_first_component_load"
+ }
+ column "mat_team" {
+ type = "String"
+ comment = "column_materializer::team"
+ }
+ column "mat_context" {
+ type = "String"
+ comment = "column_materializer::context"
+ }
+ column "mat_sdk" {
+ type = "String"
+ comment = "column_materializer::sdk"
+ }
+ column "mat_created_by_system" {
+ type = "String"
+ comment = "column_materializer::created_by_system"
+ }
+ column "mat_item_count" {
+ type = "String"
+ comment = "column_materializer::item_count"
+ }
+ column "mat_$ip" {
+ type = "String"
+ comment = "column_materializer::$ip"
+ }
+ column "mat_$referrer" {
+ type = "String"
+ comment = "column_materializer::$referrer"
+ }
+ column "mat_action_name" {
+ type = "String"
+ comment = "column_materializer::action_name"
+ }
+ column "mat_$geoip_country_name" {
+ type = "String"
+ comment = "column_materializer::$geoip_country_name"
+ }
+ column "mat_$device_model" {
+ type = "String"
+ comment = "column_materializer::$device_model"
+ }
+ column "mat_progress" {
+ type = "String"
+ comment = "column_materializer::progress"
+ }
+ column "mat_chain" {
+ type = "String"
+ comment = "column_materializer::chain"
+ }
+ column "mat_$device_type" {
+ type = "String"
+ comment = "column_materializer::$device_type"
+ }
+ column "mat_usd" {
+ type = "String"
+ comment = "column_materializer::usd"
+ }
+ column "mat_app_name" {
+ type = "String"
+ comment = "column_materializer::app_name"
+ }
+ column "mat_$screen_name" {
+ type = "String"
+ comment = "column_materializer::$screen_name"
+ }
+ column "mat_index" {
+ type = "String"
+ comment = "column_materializer::index"
+ }
+ column "mat_token" {
+ type = "String"
+ comment = "column_materializer::token"
+ }
+ column "mat_method" {
+ type = "String"
+ comment = "column_materializer::method"
+ }
+ column "mat_address" {
+ type = "String"
+ comment = "column_materializer::address"
+ }
+ column "mat_name" {
+ type = "String"
+ comment = "column_materializer::name"
+ }
+ column "mat_inviteCode" {
+ type = "String"
+ comment = "column_materializer::inviteCode"
+ }
+ column "$window_id" {
+ type = "String"
+ comment = "column_materializer::$window_id"
+ }
+ column "$session_id" {
+ type = "String"
+ comment = "column_materializer::$session_id"
+ }
+ column "mat_osName" {
+ type = "String"
+ comment = "column_materializer::osName"
+ }
+ column "mat_nativeBuildVersion" {
+ type = "String"
+ comment = "column_materializer::nativeBuildVersion"
+ }
+ column "mat_revenue" {
+ type = "String"
+ comment = "column_materializer::revenue"
+ }
+ column "group_0" {
+ type = "String"
+ alias = "`$group_0`"
+ }
+ column "group_1" {
+ type = "String"
+ alias = "`$group_1`"
+ }
+ column "group_2" {
+ type = "String"
+ alias = "`$group_2`"
+ }
+ column "group_3" {
+ type = "String"
+ alias = "`$group_3`"
+ }
+ column "group_4" {
+ type = "String"
+ alias = "`$group_4`"
+ }
+ column "alias_mat__user_id" {
+ type = "String"
+ alias = "`mat_$user_id`"
+ }
+ column "alias_mat__browser" {
+ type = "String"
+ alias = "`mat_$browser`"
+ }
+ column "alias_mat__host" {
+ type = "String"
+ alias = "`mat_$host`"
+ }
+ column "alias_mat__current_url" {
+ type = "String"
+ alias = "`mat_$current_url`"
+ }
+ column "alias_mat__event_type" {
+ type = "String"
+ alias = "`mat_$event_type`"
+ }
+ column "alias_mat__active_feature_flags" {
+ type = "String"
+ alias = "`mat_$active_feature_flags`"
+ }
+ column "alias_mat__referring_domain" {
+ type = "String"
+ alias = "`mat_$referring_domain`"
+ }
+ column "alias_mat__lib" {
+ type = "String"
+ alias = "`mat_$lib`"
+ }
+ column "alias_mat__os" {
+ type = "String"
+ alias = "`mat_$os`"
+ }
+ column "alias_mat__initial_referrer" {
+ type = "String"
+ alias = "`mat_$initial_referrer`"
+ }
+ column "alias_mat__app_version" {
+ type = "String"
+ alias = "`mat_$app_version`"
+ }
+ column "alias_mat__initial_referring_domain" {
+ type = "String"
+ alias = "`mat_$initial_referring_domain`"
+ }
+ column "alias_mat__ip" {
+ type = "String"
+ alias = "`mat_$ip`"
+ }
+ column "alias_mat__referrer" {
+ type = "String"
+ alias = "`mat_$referrer`"
+ }
+ column "alias_mat__geoip_country_name" {
+ type = "String"
+ alias = "`mat_$geoip_country_name`"
+ }
+ column "alias_mat__device_model" {
+ type = "String"
+ alias = "`mat_$device_model`"
+ }
+ column "alias_mat__device_type" {
+ type = "String"
+ alias = "`mat_$device_type`"
+ }
+ column "alias_mat__screen_name" {
+ type = "String"
+ alias = "`mat_$screen_name`"
+ }
+ column "person_id" {
+ type = "UUID"
+ }
+ column "person_properties" {
+ type = "String"
+ }
+ column "group0_properties" {
+ type = "String"
+ }
+ column "group1_properties" {
+ type = "String"
+ }
+ column "group2_properties" {
+ type = "String"
+ }
+ column "group3_properties" {
+ type = "String"
+ }
+ column "group4_properties" {
+ type = "String"
+ }
+ column "person_created_at" {
+ type = "DateTime64(3)"
+ }
+ column "group0_created_at" {
+ type = "DateTime64(3)"
+ }
+ column "group1_created_at" {
+ type = "DateTime64(3)"
+ }
+ column "group2_created_at" {
+ type = "DateTime64(3)"
+ }
+ column "group3_created_at" {
+ type = "DateTime64(3)"
+ }
+ column "group4_created_at" {
+ type = "DateTime64(3)"
+ }
+ column "mat_arguments" {
+ type = "String"
+ comment = "column_materializer::properties::arguments"
+ }
+ column "mat_source" {
+ type = "String"
+ comment = "column_materializer::properties::source"
+ }
+ column "mat_pp_email" {
+ type = "String"
+ comment = "column_materializer::person_properties::email"
+ }
+ column "mat_$time" {
+ type = "String"
+ comment = "column_materializer::properties::$time"
+ }
+ column "mat_$pathname" {
+ type = "String"
+ comment = "column_materializer::properties::$pathname"
+ }
+ column "mat_$geoip_city_name" {
+ type = "String"
+ comment = "column_materializer::properties::$geoip_city_name"
+ }
+ column "mat_community_id" {
+ type = "String"
+ comment = "column_materializer::properties::community_id"
+ }
+ column "mat_thread_id" {
+ type = "String"
+ comment = "column_materializer::properties::thread_id"
+ }
+ column "mat_Event_productCode" {
+ type = "String"
+ comment = "column_materializer::properties::Event.productCode"
+ }
+ column "mat_env" {
+ type = "String"
+ comment = "column_materializer::properties::env"
+ }
+ column "mat_target" {
+ type = "String"
+ comment = "column_materializer::properties::target"
+ }
+ column "mat_Subscription_plan_amount" {
+ type = "String"
+ comment = "column_materializer::properties::Subscription.plan.amount"
+ }
+ column "mat_title" {
+ type = "String"
+ comment = "column_materializer::properties::title"
+ }
+ column "mat_Connection_app_name" {
+ type = "String"
+ comment = "column_materializer::properties::Connection.app.name"
+ }
+ column "mat_utm_medium" {
+ type = "String"
+ comment = "column_materializer::properties::utm_medium"
+ }
+ column "mat_Account_client_id" {
+ type = "String"
+ comment = "column_materializer::properties::Account.client_id"
+ }
+ column "mat_HTTP_Method" {
+ type = "String"
+ comment = "column_materializer::properties::HTTP Method"
+ }
+ column "mat_audio_duration" {
+ type = "String"
+ comment = "column_materializer::properties::audio_duration"
+ }
+ column "mat_duration" {
+ type = "String"
+ comment = "column_materializer::properties::duration"
+ }
+ column "mat_url" {
+ type = "String"
+ comment = "column_materializer::properties::url"
+ }
+ column "mat_group_id" {
+ type = "String"
+ comment = "column_materializer::properties::group_id"
+ }
+ column "mat_platform" {
+ type = "String"
+ comment = "column_materializer::properties::platform"
+ }
+ column "mat_pp_$browser" {
+ type = "String"
+ comment = "column_materializer::person_properties::$browser"
+ }
+ column "mat_payment_status" {
+ type = "String"
+ comment = "column_materializer::properties::payment_status"
+ }
+ column "mat_testSessionId" {
+ type = "String"
+ comment = "column_materializer::properties::testSessionId"
+ }
+ column "inserted_at" {
+ type = "Nullable(DateTime64(6, 'UTC'))"
+ default = "now64()"
+ }
+ column "mat_$sent_at" {
+ type = "String"
+ comment = "column_materializer::properties::$sent_at"
+ }
+ column "mat_pp_companyName" {
+ type = "String"
+ comment = "column_materializer::person_properties::companyName"
+ }
+ column "mat_function" {
+ type = "String"
+ comment = "column_materializer::properties::function"
+ }
+ column "mat_store_url" {
+ type = "String"
+ comment = "column_materializer::properties::store_url"
+ }
+ column "mat_email_domain" {
+ type = "String"
+ comment = "column_materializer::properties::email_domain"
+ }
+ column "mat_institution_name" {
+ type = "String"
+ comment = "column_materializer::properties::institution_name"
+ }
+ column "mat_authentication_method" {
+ type = "String"
+ comment = "column_materializer::properties::authentication_method"
+ }
+ column "mat_initial_step" {
+ type = "String"
+ comment = "column_materializer::properties::initial_step"
+ }
+ column "mat_status_message" {
+ type = "String"
+ comment = "column_materializer::properties::status_message"
+ }
+ column "mat_mode" {
+ type = "String"
+ comment = "column_materializer::properties::mode"
+ }
+ column "mat_protocol" {
+ type = "String"
+ comment = "column_materializer::properties::protocol"
+ }
+ column "mat_job_type" {
+ type = "String"
+ comment = "column_materializer::properties::job_type"
+ }
+ column "mat_is_oauth" {
+ type = "String"
+ comment = "column_materializer::properties::is_oauth"
+ }
+ column "mat_is_initial_aggregation" {
+ type = "String"
+ comment = "column_materializer::properties::is_initial_aggregation"
+ }
+ column "mat_search_term" {
+ type = "String"
+ comment = "column_materializer::properties::search_term"
+ }
+ column "mat_valid_ach_accounts" {
+ type = "String"
+ comment = "column_materializer::properties::valid_ach_accounts"
+ }
+ column "mat_gross" {
+ type = "String"
+ comment = "column_materializer::properties::gross"
+ }
+ column "mat_orderType" {
+ type = "String"
+ comment = "column_materializer::properties::orderType"
+ }
+ column "mat_sku" {
+ type = "String"
+ comment = "column_materializer::properties::sku"
+ }
+ column "mat_dual_channel" {
+ type = "String"
+ comment = "column_materializer::properties::dual_channel"
+ }
+ column "mat_channel" {
+ type = "String"
+ comment = "column_materializer::properties::channel"
+ }
+ column "mat_workspaceId" {
+ type = "String"
+ comment = "column_materializer::properties::workspaceId"
+ }
+ column "mat_numberOfSecrets" {
+ type = "String"
+ comment = "column_materializer::properties::numberOfSecrets"
+ }
+ column "mat_organizations" {
+ type = "String"
+ comment = "column_materializer::properties::organizations"
+ }
+ column "mat_organization" {
+ type = "String"
+ comment = "column_materializer::properties::organization"
+ }
+ column "mat_contributionError" {
+ type = "String"
+ comment = "column_materializer::properties::contributionError"
+ }
+ column "mat_phone" {
+ type = "String"
+ comment = "column_materializer::properties::phone"
+ }
+ column "mat_$initial_pathname" {
+ type = "String"
+ comment = "column_materializer::properties::$initial_pathname"
+ }
+ column "mat_organization_name" {
+ type = "String"
+ comment = "column_materializer::properties::organization_name"
+ }
+ column "mat_category" {
+ type = "String"
+ comment = "column_materializer::properties::category"
+ }
+ column "mat_$lib_version" {
+ type = "String"
+ comment = "column_materializer::properties::$lib_version"
+ }
+ column "mat_pp_$initial_utm_campaign" {
+ type = "String"
+ comment = "column_materializer::person_properties::$initial_utm_campaign"
+ }
+ column "mat_pp_$initial_utm_medium" {
+ type = "String"
+ comment = "column_materializer::person_properties::$initial_utm_medium"
+ }
+ column "mat_pp_$initial_gclid" {
+ type = "String"
+ comment = "column_materializer::person_properties::$initial_gclid"
+ }
+ column "mat_pp_$initial_gad_source" {
+ type = "String"
+ comment = "column_materializer::person_properties::$initial_gad_source"
+ }
+ column "mat_pp_$initial_utm_source" {
+ type = "String"
+ comment = "column_materializer::person_properties::$initial_utm_source"
+ }
+ column "mat_pp_$initial_referring_domain" {
+ type = "String"
+ comment = "column_materializer::person_properties::$initial_referring_domain"
+ }
+ column "mat_pp_$initial_utm_term" {
+ type = "String"
+ comment = "column_materializer::person_properties::$initial_utm_term"
+ }
+ column "mat_pp_$initial_utm_content" {
+ type = "String"
+ comment = "column_materializer::person_properties::$initial_utm_content"
+ }
+ column "mat_pp_$initial_gbraid" {
+ type = "String"
+ comment = "column_materializer::person_properties::$initial_gbraid::disabled"
+ }
+ column "mat_pp_$initial_wbraid" {
+ type = "String"
+ comment = "column_materializer::person_properties::$initial_wbraid::disabled"
+ }
+ column "mat_pp_$initial_msclkid" {
+ type = "String"
+ comment = "column_materializer::person_properties::$initial_msclkid"
+ }
+ column "mat_pp_$initial_fbclid" {
+ type = "String"
+ comment = "column_materializer::person_properties::$initial_fbclid"
+ }
+ column "mat_$geoip_subdivision_1_code" {
+ type = "String"
+ comment = "column_materializer::properties::$geoip_subdivision_1_code"
+ }
+ column "mat_wlo_enabled" {
+ type = "String"
+ comment = "column_materializer::properties::wlo_enabled"
+ }
+ column "mat_$prev_pageview_max_scroll_percentage" {
+ type = "String"
+ comment = "column_materializer::properties::$prev_pageview_max_scroll_percentage"
+ }
+ column "mat_$prev_pageview_max_content_percentage" {
+ type = "String"
+ comment = "column_materializer::properties::$prev_pageview_max_content_percentage"
+ }
+ column "mat_$prev_pageview_pathname" {
+ type = "String"
+ comment = "column_materializer::properties::$prev_pageview_pathname"
+ }
+ column "mat_pp_$initial_pathname" {
+ type = "String"
+ comment = "column_materializer::person_properties::$initial_pathname"
+ }
+ column "mat_pp_$geoip_country_code" {
+ type = "String"
+ comment = "column_materializer::person_properties::$geoip_country_code"
+ }
+ column "mat_pp_username" {
+ type = "String"
+ comment = "column_materializer::person_properties::username"
+ }
+ column "mat_pp_serverMasterclass" {
+ type = "String"
+ comment = "column_materializer::person_properties::serverMasterclass"
+ }
+ column "mat_content_length" {
+ type = "String"
+ comment = "column_materializer::properties::content_length"
+ }
+ column "mat_pp_serverMarketing" {
+ type = "String"
+ comment = "column_materializer::person_properties::serverMarketing"
+ }
+ column "mat_$browser_version" {
+ type = "String"
+ comment = "column_materializer::properties::$browser_version"
+ }
+ column "mat_pp_role" {
+ type = "String"
+ comment = "column_materializer::person_properties::role"
+ }
+ column "mat_pp_customer" {
+ type = "String"
+ comment = "column_materializer::person_properties::customer"
+ }
+ column "mat_event" {
+ type = "String"
+ comment = "column_materializer::properties::event"
+ }
+ column "mat_disable_institution_search" {
+ type = "String"
+ comment = "column_materializer::properties::disable_institution_search"
+ }
+ column "mat_is_first_event_for_user" {
+ type = "String"
+ comment = "column_materializer::properties::is_first_event_for_user"
+ }
+ column "mat_current_member_guid" {
+ type = "String"
+ comment = "column_materializer::properties::current_member_guid"
+ }
+ column "mat_user_agent" {
+ type = "String"
+ comment = "column_materializer::properties::user_agent"
+ }
+ column "mat_is_test_user" {
+ type = "String"
+ comment = "column_materializer::properties::is_test_user"
+ }
+ column "mat_referrer" {
+ type = "String"
+ comment = "column_materializer::properties::referrer"
+ }
+ column "mat_pp_$initial_current_url" {
+ type = "String"
+ comment = "column_materializer::person_properties::$initial_current_url"
+ }
+ column "mat_most_recent_app_os" {
+ type = "String"
+ comment = "column_materializer::properties::most_recent_app_os"
+ }
+ column "mat_pp_hubspot_score" {
+ type = "String"
+ comment = "column_materializer::person_properties::hubspot_score"
+ }
+ column "mat_pp_id" {
+ type = "String"
+ comment = "column_materializer::person_properties::id"
+ }
+ column "mat_pp_$current_url" {
+ type = "String"
+ comment = "column_materializer::person_properties::$current_url"
+ }
+ column "mat_product_key" {
+ type = "String"
+ comment = "column_materializer::properties::product_key"
+ }
+ column "mat_Plan_type_and_filter" {
+ type = "String"
+ comment = "column_materializer::properties::Plan type and filter"
+ }
+ column "mat_$app_namespace" {
+ type = "String"
+ comment = "column_materializer::properties::$app_namespace"
+ }
+ column "mat_$os_name" {
+ type = "String"
+ comment = "column_materializer::properties::$os_name"
+ }
+ column "mat_pp_$os_name" {
+ type = "String"
+ comment = "column_materializer::person_properties::$os_name::disabled"
+ }
+ column "mat_pp_$app_version" {
+ type = "String"
+ comment = "column_materializer::person_properties::$app_version"
+ }
+ column "mat_subscriptionStatus" {
+ type = "String"
+ comment = "column_materializer::properties::subscriptionStatus"
+ }
+ column "mat_$screen_height" {
+ type = "String"
+ comment = "column_materializer::properties::$screen_height"
+ }
+ column "mat_$screen_width" {
+ type = "String"
+ comment = "column_materializer::properties::$screen_width"
+ }
+ column "mat_tag" {
+ type = "String"
+ comment = "column_materializer::properties::tag"
+ }
+ column "mat_$app_build" {
+ type = "String"
+ comment = "column_materializer::properties::$app_build"
+ }
+ column "mat_surface_tag" {
+ type = "String"
+ comment = "column_materializer::properties::surface_tag"
+ }
+ column "mat_survey_responses_count_in_period" {
+ type = "String"
+ comment = "column_materializer::properties::survey_responses_count_in_period"
+ }
+ column "mat_event_count_in_month" {
+ type = "String"
+ comment = "column_materializer::properties::event_count_in_month"
+ }
+ column "mat_ramp" {
+ type = "String"
+ comment = "column_materializer::properties::ramp"
+ }
+ column "mat_auto_chapters" {
+ type = "String"
+ comment = "column_materializer::properties::auto_chapters"
+ }
+ column "mat_sentiment_analysis" {
+ type = "String"
+ comment = "column_materializer::properties::sentiment_analysis"
+ }
+ column "mat_redact_pii" {
+ type = "String"
+ comment = "column_materializer::properties::redact_pii"
+ }
+ column "mat_content_safety" {
+ type = "String"
+ comment = "column_materializer::properties::content_safety"
+ }
+ column "mat_iab_categories" {
+ type = "String"
+ comment = "column_materializer::properties::iab_categories"
+ }
+ column "mat_auto_highlights" {
+ type = "String"
+ comment = "column_materializer::properties::auto_highlights"
+ }
+ column "mat_entity_detection" {
+ type = "String"
+ comment = "column_materializer::properties::entity_detection"
+ }
+ column "mat_summarization" {
+ type = "String"
+ comment = "column_materializer::properties::summarization"
+ }
+ column "mat_pp_val_region" {
+ type = "String"
+ comment = "column_materializer::person_properties::val_region"
+ }
+ column "mat_client_id" {
+ type = "String"
+ comment = "column_materializer::properties::client_id"
+ }
+ column "mat_$geoip_country_code" {
+ type = "String"
+ comment = "column_materializer::properties::$geoip_country_code"
+ }
+ column "mat_disfluencies" {
+ type = "String"
+ comment = "column_materializer::properties::disfluencies"
+ }
+ column "mat_filter_profanity" {
+ type = "String"
+ comment = "column_materializer::properties::filter_profanity"
+ }
+ column "mat_speaker_labels" {
+ type = "String"
+ comment = "column_materializer::properties::speaker_labels"
+ }
+ column "mat_language_detection" {
+ type = "String"
+ comment = "column_materializer::properties::language_detection"
+ }
+ column "mat_product_analytics_projected_amount" {
+ type = "String"
+ comment = "column_materializer::properties::product_analytics_projected_amount"
+ }
+ column "mat_recordings_projected_amount" {
+ type = "String"
+ comment = "column_materializer::properties::recordings_projected_amount"
+ }
+ column "mat_events_projected_amount" {
+ type = "String"
+ comment = "column_materializer::properties::events_projected_amount"
+ }
+ column "mat_session_replay_projected_amount" {
+ type = "String"
+ comment = "column_materializer::properties::session_replay_projected_amount"
+ }
+ column "mat_total_usd" {
+ type = "String"
+ comment = "column_materializer::properties::total_usd"
+ }
+ column "mat_stripe_amount_paid" {
+ type = "String"
+ comment = "column_materializer::properties::stripe_amount_paid"
+ }
+ column "mat_workspace" {
+ type = "String"
+ comment = "column_materializer::properties::workspace"
+ }
+ column "mat_created_at" {
+ type = "String"
+ comment = "column_materializer::properties::created_at"
+ }
+ column "mat_kind" {
+ type = "String"
+ comment = "column_materializer::properties::kind"
+ }
+ column "mat_product" {
+ type = "String"
+ comment = "column_materializer::properties::product"
+ }
+ column "mat_message" {
+ type = "String"
+ comment = "column_materializer::properties::message"
+ }
+ column "mat_initiator" {
+ type = "String"
+ comment = "column_materializer::properties::initiator"
+ }
+ column "mat_query" {
+ type = "String"
+ comment = "column_materializer::properties::query"
+ }
+ column "mat_$survey_id" {
+ type = "String"
+ comment = "column_materializer::properties::$survey_id"
+ }
+ column "mat_$survey_response_1" {
+ type = "String"
+ comment = "column_materializer::properties::$survey_response_1"
+ }
+ column "mat_ticketId" {
+ type = "String"
+ comment = "column_materializer::properties::ticketId"
+ }
+ column "mat_$survey_response" {
+ type = "String"
+ comment = "column_materializer::properties::$survey_response"
+ }
+ column "mat_conceptName" {
+ type = "String"
+ comment = "column_materializer::properties::conceptName"
+ }
+ column "mat_apiName" {
+ type = "String"
+ comment = "column_materializer::properties::apiName"
+ }
+ column "mat_workplace_billing_plan" {
+ type = "String"
+ comment = "column_materializer::properties::workplace_billing_plan"
+ }
+ column "mat_$el_text" {
+ type = "String"
+ comment = "column_materializer::properties::$el_text"
+ }
+ column "mat_recording_count_in_period" {
+ type = "String"
+ comment = "column_materializer::properties::recording_count_in_period"
+ }
+ column "mat_$os_version" {
+ type = "String"
+ comment = "column_materializer::properties::$os_version"
+ }
+ column "mat_orderId" {
+ type = "String"
+ comment = "column_materializer::properties::orderId"
+ }
+ column "mat_commit_sha" {
+ type = "String"
+ comment = "column_materializer::properties::commit_sha"
+ }
+ column "mat_$feature_flag_payloads" {
+ type = "String"
+ comment = "column_materializer::properties::$feature_flag_payloads"
+ }
+ column "mat_event_count_in_period" {
+ type = "String"
+ comment = "column_materializer::properties::event_count_in_period"
+ }
+ column "mat_$groups" {
+ type = "String"
+ comment = "column_materializer::properties::$groups"
+ }
+ column "mat_$feature_flag" {
+ type = "String"
+ comment = "column_materializer::properties::$feature_flag"
+ }
+ column "mat_utm_content" {
+ type = "String"
+ comment = "column_materializer::properties::utm_content"
+ }
+ column "mat_gclid" {
+ type = "String"
+ comment = "column_materializer::properties::gclid"
+ }
+ column "mat_gad_source" {
+ type = "String"
+ comment = "column_materializer::properties::gad_source"
+ }
+ column "mat_gbraid" {
+ type = "String"
+ comment = "column_materializer::properties::gbraid"
+ }
+ column "mat_wbraid" {
+ type = "String"
+ comment = "column_materializer::properties::wbraid"
+ }
+ column "mat_fbclid" {
+ type = "String"
+ comment = "column_materializer::properties::fbclid"
+ }
+ column "mat_msclkid" {
+ type = "String"
+ comment = "column_materializer::properties::msclkid"
+ }
+ column "mat_organization_id" {
+ type = "String"
+ comment = "column_materializer::properties::organization_id"
+ }
+ column "mat_owner_type" {
+ type = "String"
+ comment = "column_materializer::properties::owner_type"
+ }
+ column "mat_device_type" {
+ type = "String"
+ comment = "column_materializer::properties::device_type"
+ }
+ column "mat_$device_id" {
+ type = "String"
+ comment = "column_materializer::properties::$device_id"
+ }
+ column "mat_pp_$geoip_continent_name" {
+ type = "String"
+ comment = "column_materializer::person_properties::$geoip_continent_name"
+ }
+ column "mat_$feature_flag_response" {
+ type = "String"
+ comment = "column_materializer::properties::$feature_flag_response"
+ }
+ column "mat_pp_utm_source" {
+ type = "String"
+ comment = "column_materializer::person_properties::utm_source"
+ }
+ column "mat_pp_$referring_domain" {
+ type = "String"
+ comment = "column_materializer::person_properties::$referring_domain"
+ }
+ column "mat_pp_Email_Domain" {
+ type = "String"
+ comment = "column_materializer::person_properties::Email Domain"
+ }
+ column "mat_machine_id" {
+ type = "String"
+ comment = "column_materializer::properties::machine_id"
+ }
+ column "mat_user_email_domain" {
+ type = "String"
+ comment = "column_materializer::properties::user_email_domain"
+ }
+ column "mat_$lib_version__minor" {
+ type = "String"
+ comment = "column_materializer::properties::$lib_version__minor"
+ }
+ column "mat_region" {
+ type = "String"
+ comment = "column_materializer::properties::region"
+ }
+ column "mat_pp_user_email_domain" {
+ type = "String"
+ comment = "column_materializer::person_properties::user_email_domain"
+ }
+ column "mat_url_promotion_id" {
+ type = "String"
+ comment = "column_materializer::properties::url_promotion_id"
+ }
+ column "mat_$lib_custom_api_host" {
+ type = "String"
+ comment = "column_materializer::properties::$lib_custom_api_host"
+ }
+ column "person_mode" {
+ type = "Enum8('full'=0, 'propertyless'=1, 'force_upgrade'=2)"
+ }
+ column "mat_user_platform" {
+ type = "String"
+ comment = "column_materializer::properties::user_platform"
+ }
+ column "mat_pp_$geoip_country_name" {
+ type = "String"
+ comment = "column_materializer::person_properties::$geoip_country_name"
+ }
+ column "mat_environment" {
+ type = "String"
+ comment = "column_materializer::properties::environment"
+ }
+ column "mat_customer_email" {
+ type = "String"
+ comment = "column_materializer::properties::customer_email"
+ }
+ column "mat_client_name" {
+ type = "String"
+ comment = "column_materializer::properties::client_name"
+ }
+ column "mat_screen_name" {
+ type = "String"
+ comment = "column_materializer::properties::screen_name"
+ }
+ column "mat_app_version" {
+ type = "String"
+ comment = "column_materializer::properties::app_version"
+ }
+ column "elements_chain_href" {
+ type = "String"
+ comment = "column_materializer::elements_chain::href"
+ }
+ column "elements_chain_texts" {
+ type = "Array(String)"
+ comment = "column_materializer::elements_chain::texts"
+ }
+ column "elements_chain_ids" {
+ type = "Array(String)"
+ comment = "column_materializer::elements_chain::ids"
+ }
+ column "elements_chain_elements" {
+ type = "Array(Enum8('a'=1, 'button'=2, 'form'=3, 'input'=4, 'select'=5, 'textarea'=6, 'label'=7))"
+ comment = "column_materializer::elements_chain::elements"
+ }
+ column "properties_group_custom" {
+ type = "Map(String, String)"
+ }
+ column "properties_group_feature_flags" {
+ type = "Map(String, String)"
+ }
+ column "is_deleted" {
+ type = "Bool"
+ }
+ column "mat_subdomain" {
+ type = "String"
+ comment = "column_materializer::properties::subdomain"
+ }
+ column "mat_$device" {
+ type = "String"
+ comment = "column_materializer::properties::$device"
+ }
+ column "mat_id" {
+ type = "String"
+ comment = "column_materializer::properties::id"
+ }
+ column "mat_record_id" {
+ type = "String"
+ comment = "column_materializer::properties::record_id"
+ }
+ column "mat_referrer_id" {
+ type = "String"
+ comment = "column_materializer::properties::record_id"
+ }
+ column "mat_$exception_issue_id" {
+ type = "Nullable(String)"
+ comment = "column_materializer::properties::$exception_issue_id"
+ }
+ column "mat_$exception_fingerprint" {
+ type = "Nullable(String)"
+ comment = "column_materializer::properties::$exception_fingerprint"
+ }
+ column "mat_$web_vitals_LCP_value" {
+ type = "Nullable(String)"
+ comment = "column_materializer::properties::$web_vitals_LCP_value"
+ }
+ column "mat_$web_vitals_FCP_value" {
+ type = "Nullable(String)"
+ comment = "column_materializer::properties::$web_vitals_FCP_value"
+ }
+ column "mat_$web_vitals_CLS_value" {
+ type = "Nullable(String)"
+ comment = "column_materializer::properties::$web_vitals_CLS_value"
+ }
+ column "mat_$web_vitals_INP_value" {
+ type = "Nullable(String)"
+ comment = "column_materializer::properties::$web_vitals_INP_value"
+ }
+ column "mat_$viewport_width" {
+ type = "Nullable(String)"
+ comment = "column_materializer::properties::$viewport_width"
+ }
+ column "mat_$viewport_height" {
+ type = "Nullable(String)"
+ comment = "column_materializer::properties::$viewport_height"
+ }
+ column "mat_$anon_distinct_id" {
+ type = "Nullable(String)"
+ comment = "column_materializer::properties::$anon_distinct_id"
+ }
+ column "person_properties_map_custom" {
+ type = "Map(String, String)"
+ }
+ column "mat_$ai_trace_id" {
+ type = "Nullable(String)"
+ comment = "column_materializer::properties::$ai_trace_id"
+ }
+ column "mat_$ai_model" {
+ type = "Nullable(String)"
+ comment = "column_materializer::properties::$ai_model"
+ }
+ column "mat_$ai_provider" {
+ type = "Nullable(String)"
+ comment = "column_materializer::properties::$ai_provider"
+ }
+ column "mat_$ai_parent_id" {
+ type = "Nullable(String)"
+ comment = "column_materializer::properties::$ai_parent_id"
+ }
+ column "mat_$ai_span_id" {
+ type = "Nullable(String)"
+ comment = "column_materializer::properties::$ai_span_id"
+ }
+ column "mat_$ai_http_status" {
+ type = "Nullable(String)"
+ comment = "column_materializer::properties::$ai_http_status"
+ }
+ column "mat_$exception_types" {
+ type = "Nullable(String)"
+ comment = "column_materializer::properties::$exception_types"
+ }
+ column "mat_$exception_values" {
+ type = "Nullable(String)"
+ comment = "column_materializer::properties::$exception_values"
+ }
+ column "mat_$exception_sources" {
+ type = "Nullable(String)"
+ comment = "column_materializer::properties::$exception_sources"
+ }
+ column "mat_$exception_functions" {
+ type = "Nullable(String)"
+ comment = "column_materializer::properties::$exception_functions"
+ }
+ column "$session_id_uuid" {
+ type = "Nullable(UInt128)"
+ }
+ column "mat_$process_person_profile" {
+ type = "Nullable(String)"
+ comment = "column_materializer::properties::$process_person_profile"
+ }
+ column "consumer_breadcrumbs" {
+ type = "Array(String)"
+ }
+ column "properties_group_ai" {
+ type = "Map(String, String)"
+ }
+ column "mat_$is_identified" {
+ type = "Nullable(String)"
+ comment = "column_materializer::properties::$is_identified"
+ }
+ column "mat_historical_migration" {
+ type = "Nullable(String)"
+ comment = "column_materializer::properties::historical_migration"
+ }
+ column "mat_$ai_session_id" {
+ type = "Nullable(String)"
+ comment = "column_materializer::properties::$ai_session_id"
+ }
+ column "mat_$ai_is_error" {
+ type = "Nullable(String)"
+ comment = "column_materializer::properties::$ai_is_error"
+ }
+ column "dmat_string_0" {
+ type = "Nullable(String)"
+ }
+ column "dmat_string_1" {
+ type = "Nullable(String)"
+ }
+ column "dmat_string_2" {
+ type = "Nullable(String)"
+ }
+ column "dmat_string_3" {
+ type = "Nullable(String)"
+ }
+ column "dmat_string_4" {
+ type = "Nullable(String)"
+ }
+ column "dmat_string_5" {
+ type = "Nullable(String)"
+ }
+ column "dmat_string_6" {
+ type = "Nullable(String)"
+ }
+ column "dmat_string_7" {
+ type = "Nullable(String)"
+ }
+ column "dmat_string_8" {
+ type = "Nullable(String)"
+ }
+ column "dmat_string_9" {
+ type = "Nullable(String)"
+ }
+ column "dmat_numeric_0" {
+ type = "Nullable(Float64)"
+ }
+ column "dmat_numeric_1" {
+ type = "Nullable(Float64)"
+ }
+ column "dmat_numeric_2" {
+ type = "Nullable(Float64)"
+ }
+ column "dmat_numeric_3" {
+ type = "Nullable(Float64)"
+ }
+ column "dmat_numeric_4" {
+ type = "Nullable(Float64)"
+ }
+ column "dmat_numeric_5" {
+ type = "Nullable(Float64)"
+ }
+ column "dmat_numeric_6" {
+ type = "Nullable(Float64)"
+ }
+ column "dmat_numeric_7" {
+ type = "Nullable(Float64)"
+ }
+ column "dmat_numeric_8" {
+ type = "Nullable(Float64)"
+ }
+ column "dmat_numeric_9" {
+ type = "Nullable(Float64)"
+ }
+ column "dmat_bool_0" {
+ type = "Nullable(UInt8)"
+ }
+ column "dmat_bool_1" {
+ type = "Nullable(UInt8)"
+ }
+ column "dmat_bool_2" {
+ type = "Nullable(UInt8)"
+ }
+ column "dmat_bool_3" {
+ type = "Nullable(UInt8)"
+ }
+ column "dmat_bool_4" {
+ type = "Nullable(UInt8)"
+ }
+ column "dmat_bool_5" {
+ type = "Nullable(UInt8)"
+ }
+ column "dmat_bool_6" {
+ type = "Nullable(UInt8)"
+ }
+ column "dmat_bool_7" {
+ type = "Nullable(UInt8)"
+ }
+ column "dmat_bool_8" {
+ type = "Nullable(UInt8)"
+ }
+ column "dmat_bool_9" {
+ type = "Nullable(UInt8)"
+ }
+ column "dmat_datetime_0" {
+ type = "Nullable(DateTime64(6, 'UTC'))"
+ }
+ column "dmat_datetime_1" {
+ type = "Nullable(DateTime64(6, 'UTC'))"
+ }
+ column "dmat_datetime_2" {
+ type = "Nullable(DateTime64(6, 'UTC'))"
+ }
+ column "dmat_datetime_3" {
+ type = "Nullable(DateTime64(6, 'UTC'))"
+ }
+ column "dmat_datetime_4" {
+ type = "Nullable(DateTime64(6, 'UTC'))"
+ }
+ column "dmat_datetime_5" {
+ type = "Nullable(DateTime64(6, 'UTC'))"
+ }
+ column "dmat_datetime_6" {
+ type = "Nullable(DateTime64(6, 'UTC'))"
+ }
+ column "dmat_datetime_7" {
+ type = "Nullable(DateTime64(6, 'UTC'))"
+ }
+ column "dmat_datetime_8" {
+ type = "Nullable(DateTime64(6, 'UTC'))"
+ }
+ column "dmat_datetime_9" {
+ type = "Nullable(DateTime64(6, 'UTC'))"
+ }
+ column "historical_migration" {
+ type = "Bool"
+ }
+ column "mat_$ai_total_cost_usd" {
+ type = "Nullable(String)"
+ comment = "column_materializer::properties::$ai_total_cost_usd"
+ }
+ column "properties_group_ai_large" {
+ type = "Map(String, String)"
+ }
+ column "mat_$ai_prompt_name" {
+ type = "Nullable(String)"
+ comment = "column_materializer::properties::$ai_prompt_name"
+ }
+ engine "distributed" {
+ cluster_name = "posthog"
+ remote_database = "posthog"
+ remote_table = "sharded_events"
+ sharding_key = "sipHash64(distinct_id)"
+ }
+ }
+ table "raw_sessions_v3" {
+ order_by = ["team_id", "session_timestamp", "session_id_v7"]
+ partition_by = "toYYYYMM(session_timestamp)"
+ settings = {
+ index_granularity = "8192"
+ replicated_deduplication_window = "0"
+ replicated_deduplication_window_for_async_inserts = "0"
+ }
+ 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, 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
+ }
+ engine "replicated_aggregating_merge_tree" {
+ zoo_path = "/clickhouse/tables/sessions/noshard/posthog.raw_sessions_v3"
+ replica_name = "{shard}-{replica}"
+ }
+ }
+ 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)"
+ }
+ }
+}
diff --git a/posthog/clickhouse/hcl/roles/sessions/shared/tables.hcl b/posthog/clickhouse/hcl/roles/sessions/shared/tables.hcl
new file mode 100644
index 000000000000..d4d22028e386
--- /dev/null
+++ b/posthog/clickhouse/hcl/roles/sessions/shared/tables.hcl
@@ -0,0 +1,414 @@
+database "posthog" {
+ table "cohortpeople" {
+ column "person_id" {
+ type = "UUID"
+ }
+ column "cohort_id" {
+ type = "Int64"
+ }
+ column "team_id" {
+ type = "Int64"
+ }
+ column "sign" {
+ type = "Int8"
+ }
+ column "version" {
+ type = "UInt64"
+ }
+ engine "distributed" {
+ cluster_name = "posthog_single_shard"
+ remote_database = "posthog"
+ remote_table = "cohortpeople"
+ sharding_key = "rand()"
+ }
+ }
+ table "person_distinct_id_overrides" {
+ column "team_id" {
+ type = "Int64"
+ }
+ column "distinct_id" {
+ type = "String"
+ }
+ column "person_id" {
+ type = "UUID"
+ }
+ column "is_deleted" {
+ type = "Int8"
+ }
+ column "version" {
+ type = "Int64"
+ }
+ column "_timestamp" {
+ type = "DateTime"
+ }
+ column "_offset" {
+ type = "UInt64"
+ }
+ column "_partition" {
+ type = "UInt64"
+ }
+ engine "distributed" {
+ cluster_name = "posthog_single_shard"
+ remote_database = "posthog"
+ remote_table = "person_distinct_id_overrides"
+ sharding_key = "sipHash64(distinct_id)"
+ }
+ }
+ table "person_static_cohort" {
+ 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 "distributed" {
+ cluster_name = "posthog_single_shard"
+ remote_database = "posthog"
+ remote_table = "person_static_cohort"
+ sharding_key = "rand()"
+ }
+ }
+ table "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_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'))"
+ }
+ column "initial__kx" {
+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"
+ }
+ engine "replicated_aggregating_merge_tree" {
+ zoo_path = "/clickhouse/tables/sessions/noshard/posthog.raw_sessions"
+ replica_name = "{shard}-{replica}"
+ }
+ }
+ table "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 "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/sessions/noshard/posthog.sessions"
+ replica_name = "{shard}-{replica}"
+ }
+ }
+ table "web_pre_aggregated_teams" {
+ column "team_id" {
+ type = "UInt64"
+ }
+ column "enabled_by" {
+ type = "String"
+ default = "'system'"
+ }
+ column "version" {
+ type = "UInt32"
+ default = "toUnixTimestamp(now())"
+ }
+ engine "distributed" {
+ cluster_name = "posthog_single_shard"
+ remote_database = "posthog"
+ remote_table = "web_pre_aggregated_teams"
+ }
+ }
+ 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 = "dict_reader"
+ table = "channel_definition"
+ }
+ layout "complex_key_hashed" {
+ }
+ }
+ dictionary "web_pre_aggregated_teams_dict" {
+ primary_key = ["team_id"]
+ lifetime {
+ min = 3000
+ max = 3600
+ }
+ attribute "team_id" {
+ type = "UInt64"
+ }
+ source "clickhouse" {
+ user = "dict_reader"
+ query = "SELECT team_id FROM `web_pre_aggregated_teams` FINAL WHERE version > 0"
+ }
+ layout "hashed" {
+ }
+ }
+}
diff --git a/posthog/clickhouse/hcl/roles/sessionsv3/prod-us/tables.hcl b/posthog/clickhouse/hcl/roles/sessionsv3/prod-us/tables.hcl
new file mode 100644
index 000000000000..846619900890
--- /dev/null
+++ b/posthog/clickhouse/hcl/roles/sessionsv3/prod-us/tables.hcl
@@ -0,0 +1,1915 @@
+database "posthog" {
+ table "events" {
+ 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_hash" {
+ type = "String"
+ }
+ column "created_at" {
+ type = "DateTime64(6, 'UTC')"
+ }
+ column "_timestamp" {
+ type = "DateTime"
+ }
+ column "_offset" {
+ type = "UInt64"
+ }
+ column "elements_chain" {
+ type = "String"
+ }
+ column "mat_$user_id" {
+ type = "String"
+ comment = "column_materializer::$user_id"
+ }
+ column "mat_$browser" {
+ type = "String"
+ comment = "column_materializer::$browser"
+ }
+ column "mat_$host" {
+ type = "String"
+ comment = "column_materializer::$host"
+ }
+ column "mat_$current_url" {
+ type = "String"
+ comment = "column_materializer::$current_url"
+ }
+ column "mat_distinct_id" {
+ type = "String"
+ comment = "column_materializer::distinct_id"
+ }
+ column "mat_action" {
+ type = "String"
+ comment = "column_materializer::action"
+ }
+ column "mat_origin" {
+ type = "String"
+ comment = "column_materializer::origin"
+ }
+ column "mat_email" {
+ type = "String"
+ comment = "column_materializer::email"
+ }
+ column "mat_key" {
+ type = "String"
+ comment = "column_materializer::key"
+ }
+ column "mat_insight" {
+ type = "String"
+ comment = "column_materializer::insight"
+ }
+ column "mat_$event_type" {
+ type = "String"
+ comment = "column_materializer::$event_type"
+ }
+ column "mat_created_by" {
+ type = "String"
+ comment = "column_materializer::created_by"
+ }
+ column "mat_total_event_actions_count" {
+ type = "String"
+ comment = "column_materializer::total_event_actions_count"
+ }
+ column "mat_is_demo_project" {
+ type = "String"
+ comment = "column_materializer::is_demo_project"
+ }
+ column "mat_$active_feature_flags" {
+ type = "String"
+ comment = "column_materializer::$active_feature_flags"
+ }
+ column "mat_filters_count" {
+ type = "String"
+ comment = "column_materializer::filters_count"
+ }
+ column "mat_utm_source" {
+ type = "String"
+ comment = "column_materializer::utm_source"
+ }
+ column "mat_apiErrorMessage" {
+ type = "String"
+ comment = "column_materializer::apiErrorMessage"
+ }
+ column "mat_$referring_domain" {
+ type = "String"
+ comment = "column_materializer::$referring_domain"
+ }
+ column "mat_statusCode" {
+ type = "String"
+ comment = "column_materializer::statusCode"
+ }
+ column "mat_deal_id" {
+ type = "String"
+ comment = "column_materializer::deal_id"
+ }
+ column "mat_realm" {
+ type = "String"
+ comment = "column_materializer::realm"
+ }
+ 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 "mat_$lib" {
+ type = "String"
+ comment = "column_materializer::$lib"
+ }
+ column "mat_$os" {
+ type = "String"
+ comment = "column_materializer::$os"
+ }
+ column "mat_$initial_referrer" {
+ type = "String"
+ comment = "column_materializer::$initial_referrer"
+ }
+ column "mat_$app_version" {
+ type = "String"
+ comment = "column_materializer::$app_version"
+ }
+ column "mat_$initial_referring_domain" {
+ type = "String"
+ comment = "column_materializer::$initial_referring_domain"
+ }
+ column "mat_symbol" {
+ type = "String"
+ comment = "column_materializer::symbol"
+ }
+ column "mat_page" {
+ type = "String"
+ comment = "column_materializer::page"
+ }
+ column "mat_type" {
+ type = "String"
+ comment = "column_materializer::type"
+ }
+ column "mat_currentScreen" {
+ type = "String"
+ comment = "column_materializer::currentScreen"
+ }
+ column "mat_utm_campaign" {
+ type = "String"
+ comment = "column_materializer::utm_campaign"
+ }
+ column "mat_is_organization_first_user" {
+ type = "String"
+ comment = "column_materializer::is_organization_first_user"
+ }
+ column "mat_is_first_component_load" {
+ type = "String"
+ comment = "column_materializer::is_first_component_load"
+ }
+ column "mat_team" {
+ type = "String"
+ comment = "column_materializer::team"
+ }
+ column "mat_context" {
+ type = "String"
+ comment = "column_materializer::context"
+ }
+ column "mat_sdk" {
+ type = "String"
+ comment = "column_materializer::sdk"
+ }
+ column "mat_created_by_system" {
+ type = "String"
+ comment = "column_materializer::created_by_system"
+ }
+ column "mat_item_count" {
+ type = "String"
+ comment = "column_materializer::item_count"
+ }
+ column "mat_$ip" {
+ type = "String"
+ comment = "column_materializer::$ip"
+ }
+ column "mat_$referrer" {
+ type = "String"
+ comment = "column_materializer::$referrer"
+ }
+ column "mat_action_name" {
+ type = "String"
+ comment = "column_materializer::action_name"
+ }
+ column "mat_$geoip_country_name" {
+ type = "String"
+ comment = "column_materializer::$geoip_country_name"
+ }
+ column "mat_$device_model" {
+ type = "String"
+ comment = "column_materializer::$device_model"
+ }
+ column "mat_progress" {
+ type = "String"
+ comment = "column_materializer::progress"
+ }
+ column "mat_chain" {
+ type = "String"
+ comment = "column_materializer::chain"
+ }
+ column "mat_$device_type" {
+ type = "String"
+ comment = "column_materializer::$device_type"
+ }
+ column "mat_usd" {
+ type = "String"
+ comment = "column_materializer::usd"
+ }
+ column "mat_app_name" {
+ type = "String"
+ comment = "column_materializer::app_name"
+ }
+ column "mat_$screen_name" {
+ type = "String"
+ comment = "column_materializer::$screen_name"
+ }
+ column "mat_index" {
+ type = "String"
+ comment = "column_materializer::index"
+ }
+ column "mat_token" {
+ type = "String"
+ comment = "column_materializer::token"
+ }
+ column "mat_method" {
+ type = "String"
+ comment = "column_materializer::method"
+ }
+ column "mat_address" {
+ type = "String"
+ comment = "column_materializer::address"
+ }
+ column "mat_name" {
+ type = "String"
+ comment = "column_materializer::name"
+ }
+ column "mat_inviteCode" {
+ type = "String"
+ comment = "column_materializer::inviteCode"
+ }
+ column "$window_id" {
+ type = "String"
+ comment = "column_materializer::$window_id"
+ }
+ column "$session_id" {
+ type = "String"
+ comment = "column_materializer::$session_id"
+ }
+ column "mat_osName" {
+ type = "String"
+ comment = "column_materializer::osName"
+ }
+ column "mat_nativeBuildVersion" {
+ type = "String"
+ comment = "column_materializer::nativeBuildVersion"
+ }
+ column "mat_revenue" {
+ type = "String"
+ comment = "column_materializer::revenue"
+ }
+ column "group_0" {
+ type = "String"
+ alias = "`$group_0`"
+ }
+ column "group_1" {
+ type = "String"
+ alias = "`$group_1`"
+ }
+ column "group_2" {
+ type = "String"
+ alias = "`$group_2`"
+ }
+ column "group_3" {
+ type = "String"
+ alias = "`$group_3`"
+ }
+ column "group_4" {
+ type = "String"
+ alias = "`$group_4`"
+ }
+ column "alias_mat__user_id" {
+ type = "String"
+ alias = "`mat_$user_id`"
+ }
+ column "alias_mat__browser" {
+ type = "String"
+ alias = "`mat_$browser`"
+ }
+ column "alias_mat__host" {
+ type = "String"
+ alias = "`mat_$host`"
+ }
+ column "alias_mat__current_url" {
+ type = "String"
+ alias = "`mat_$current_url`"
+ }
+ column "alias_mat__event_type" {
+ type = "String"
+ alias = "`mat_$event_type`"
+ }
+ column "alias_mat__active_feature_flags" {
+ type = "String"
+ alias = "`mat_$active_feature_flags`"
+ }
+ column "alias_mat__referring_domain" {
+ type = "String"
+ alias = "`mat_$referring_domain`"
+ }
+ column "alias_mat__lib" {
+ type = "String"
+ alias = "`mat_$lib`"
+ }
+ column "alias_mat__os" {
+ type = "String"
+ alias = "`mat_$os`"
+ }
+ column "alias_mat__initial_referrer" {
+ type = "String"
+ alias = "`mat_$initial_referrer`"
+ }
+ column "alias_mat__app_version" {
+ type = "String"
+ alias = "`mat_$app_version`"
+ }
+ column "alias_mat__initial_referring_domain" {
+ type = "String"
+ alias = "`mat_$initial_referring_domain`"
+ }
+ column "alias_mat__ip" {
+ type = "String"
+ alias = "`mat_$ip`"
+ }
+ column "alias_mat__referrer" {
+ type = "String"
+ alias = "`mat_$referrer`"
+ }
+ column "alias_mat__geoip_country_name" {
+ type = "String"
+ alias = "`mat_$geoip_country_name`"
+ }
+ column "alias_mat__device_model" {
+ type = "String"
+ alias = "`mat_$device_model`"
+ }
+ column "alias_mat__device_type" {
+ type = "String"
+ alias = "`mat_$device_type`"
+ }
+ column "alias_mat__screen_name" {
+ type = "String"
+ alias = "`mat_$screen_name`"
+ }
+ column "person_id" {
+ type = "UUID"
+ }
+ column "person_properties" {
+ type = "String"
+ }
+ column "group0_properties" {
+ type = "String"
+ }
+ column "group1_properties" {
+ type = "String"
+ }
+ column "group2_properties" {
+ type = "String"
+ }
+ column "group3_properties" {
+ type = "String"
+ }
+ column "group4_properties" {
+ type = "String"
+ }
+ column "person_created_at" {
+ type = "DateTime64(3)"
+ }
+ column "group0_created_at" {
+ type = "DateTime64(3)"
+ }
+ column "group1_created_at" {
+ type = "DateTime64(3)"
+ }
+ column "group2_created_at" {
+ type = "DateTime64(3)"
+ }
+ column "group3_created_at" {
+ type = "DateTime64(3)"
+ }
+ column "group4_created_at" {
+ type = "DateTime64(3)"
+ }
+ column "mat_arguments" {
+ type = "String"
+ comment = "column_materializer::properties::arguments"
+ }
+ column "mat_source" {
+ type = "String"
+ comment = "column_materializer::properties::source"
+ }
+ column "mat_pp_email" {
+ type = "String"
+ comment = "column_materializer::person_properties::email"
+ }
+ column "mat_$time" {
+ type = "String"
+ comment = "column_materializer::properties::$time"
+ }
+ column "mat_$pathname" {
+ type = "String"
+ comment = "column_materializer::properties::$pathname"
+ }
+ column "mat_$geoip_city_name" {
+ type = "String"
+ comment = "column_materializer::properties::$geoip_city_name"
+ }
+ column "mat_community_id" {
+ type = "String"
+ comment = "column_materializer::properties::community_id"
+ }
+ column "mat_thread_id" {
+ type = "String"
+ comment = "column_materializer::properties::thread_id"
+ }
+ column "mat_Event_productCode" {
+ type = "String"
+ comment = "column_materializer::properties::Event.productCode"
+ }
+ column "mat_env" {
+ type = "String"
+ comment = "column_materializer::properties::env"
+ }
+ column "mat_target" {
+ type = "String"
+ comment = "column_materializer::properties::target"
+ }
+ column "mat_Subscription_plan_amount" {
+ type = "String"
+ comment = "column_materializer::properties::Subscription.plan.amount"
+ }
+ column "mat_title" {
+ type = "String"
+ comment = "column_materializer::properties::title"
+ }
+ column "mat_Connection_app_name" {
+ type = "String"
+ comment = "column_materializer::properties::Connection.app.name"
+ }
+ column "mat_utm_medium" {
+ type = "String"
+ comment = "column_materializer::properties::utm_medium"
+ }
+ column "mat_Account_client_id" {
+ type = "String"
+ comment = "column_materializer::properties::Account.client_id"
+ }
+ column "mat_HTTP_Method" {
+ type = "String"
+ comment = "column_materializer::properties::HTTP Method"
+ }
+ column "mat_audio_duration" {
+ type = "String"
+ comment = "column_materializer::properties::audio_duration"
+ }
+ column "mat_duration" {
+ type = "String"
+ comment = "column_materializer::properties::duration"
+ }
+ column "mat_url" {
+ type = "String"
+ comment = "column_materializer::properties::url"
+ }
+ column "mat_group_id" {
+ type = "String"
+ comment = "column_materializer::properties::group_id"
+ }
+ column "mat_platform" {
+ type = "String"
+ comment = "column_materializer::properties::platform"
+ }
+ column "mat_pp_$browser" {
+ type = "String"
+ comment = "column_materializer::person_properties::$browser"
+ }
+ column "mat_payment_status" {
+ type = "String"
+ comment = "column_materializer::properties::payment_status"
+ }
+ column "mat_testSessionId" {
+ type = "String"
+ comment = "column_materializer::properties::testSessionId"
+ }
+ column "inserted_at" {
+ type = "Nullable(DateTime64(6, 'UTC'))"
+ default = "now64()"
+ }
+ column "mat_$sent_at" {
+ type = "String"
+ comment = "column_materializer::properties::$sent_at"
+ }
+ column "mat_pp_companyName" {
+ type = "String"
+ comment = "column_materializer::person_properties::companyName"
+ }
+ column "mat_function" {
+ type = "String"
+ comment = "column_materializer::properties::function"
+ }
+ column "mat_store_url" {
+ type = "String"
+ comment = "column_materializer::properties::store_url"
+ }
+ column "mat_email_domain" {
+ type = "String"
+ comment = "column_materializer::properties::email_domain"
+ }
+ column "mat_institution_name" {
+ type = "String"
+ comment = "column_materializer::properties::institution_name"
+ }
+ column "mat_authentication_method" {
+ type = "String"
+ comment = "column_materializer::properties::authentication_method"
+ }
+ column "mat_initial_step" {
+ type = "String"
+ comment = "column_materializer::properties::initial_step"
+ }
+ column "mat_status_message" {
+ type = "String"
+ comment = "column_materializer::properties::status_message"
+ }
+ column "mat_mode" {
+ type = "String"
+ comment = "column_materializer::properties::mode"
+ }
+ column "mat_protocol" {
+ type = "String"
+ comment = "column_materializer::properties::protocol"
+ }
+ column "mat_job_type" {
+ type = "String"
+ comment = "column_materializer::properties::job_type"
+ }
+ column "mat_is_oauth" {
+ type = "String"
+ comment = "column_materializer::properties::is_oauth"
+ }
+ column "mat_is_initial_aggregation" {
+ type = "String"
+ comment = "column_materializer::properties::is_initial_aggregation"
+ }
+ column "mat_search_term" {
+ type = "String"
+ comment = "column_materializer::properties::search_term"
+ }
+ column "mat_valid_ach_accounts" {
+ type = "String"
+ comment = "column_materializer::properties::valid_ach_accounts"
+ }
+ column "mat_gross" {
+ type = "String"
+ comment = "column_materializer::properties::gross"
+ }
+ column "mat_orderType" {
+ type = "String"
+ comment = "column_materializer::properties::orderType"
+ }
+ column "mat_sku" {
+ type = "String"
+ comment = "column_materializer::properties::sku"
+ }
+ column "mat_dual_channel" {
+ type = "String"
+ comment = "column_materializer::properties::dual_channel"
+ }
+ column "mat_channel" {
+ type = "String"
+ comment = "column_materializer::properties::channel"
+ }
+ column "mat_workspaceId" {
+ type = "String"
+ comment = "column_materializer::properties::workspaceId"
+ }
+ column "mat_numberOfSecrets" {
+ type = "String"
+ comment = "column_materializer::properties::numberOfSecrets"
+ }
+ column "mat_organizations" {
+ type = "String"
+ comment = "column_materializer::properties::organizations"
+ }
+ column "mat_organization" {
+ type = "String"
+ comment = "column_materializer::properties::organization"
+ }
+ column "mat_contributionError" {
+ type = "String"
+ comment = "column_materializer::properties::contributionError"
+ }
+ column "mat_phone" {
+ type = "String"
+ comment = "column_materializer::properties::phone"
+ }
+ column "mat_$initial_pathname" {
+ type = "String"
+ comment = "column_materializer::properties::$initial_pathname"
+ }
+ column "mat_organization_name" {
+ type = "String"
+ comment = "column_materializer::properties::organization_name"
+ }
+ column "mat_category" {
+ type = "String"
+ comment = "column_materializer::properties::category"
+ }
+ column "mat_$lib_version" {
+ type = "String"
+ comment = "column_materializer::properties::$lib_version"
+ }
+ column "mat_pp_$initial_utm_campaign" {
+ type = "String"
+ comment = "column_materializer::person_properties::$initial_utm_campaign"
+ }
+ column "mat_pp_$initial_utm_medium" {
+ type = "String"
+ comment = "column_materializer::person_properties::$initial_utm_medium"
+ }
+ column "mat_pp_$initial_gclid" {
+ type = "String"
+ comment = "column_materializer::person_properties::$initial_gclid"
+ }
+ column "mat_pp_$initial_gad_source" {
+ type = "String"
+ comment = "column_materializer::person_properties::$initial_gad_source"
+ }
+ column "mat_pp_$initial_utm_source" {
+ type = "String"
+ comment = "column_materializer::person_properties::$initial_utm_source"
+ }
+ column "mat_pp_$initial_referring_domain" {
+ type = "String"
+ comment = "column_materializer::person_properties::$initial_referring_domain"
+ }
+ column "mat_pp_$initial_utm_term" {
+ type = "String"
+ comment = "column_materializer::person_properties::$initial_utm_term"
+ }
+ column "mat_pp_$initial_utm_content" {
+ type = "String"
+ comment = "column_materializer::person_properties::$initial_utm_content"
+ }
+ column "mat_pp_$initial_gbraid" {
+ type = "String"
+ comment = "column_materializer::person_properties::$initial_gbraid::disabled"
+ }
+ column "mat_pp_$initial_wbraid" {
+ type = "String"
+ comment = "column_materializer::person_properties::$initial_wbraid::disabled"
+ }
+ column "mat_pp_$initial_msclkid" {
+ type = "String"
+ comment = "column_materializer::person_properties::$initial_msclkid"
+ }
+ column "mat_pp_$initial_fbclid" {
+ type = "String"
+ comment = "column_materializer::person_properties::$initial_fbclid"
+ }
+ column "mat_$geoip_subdivision_1_code" {
+ type = "String"
+ comment = "column_materializer::properties::$geoip_subdivision_1_code"
+ }
+ column "mat_wlo_enabled" {
+ type = "String"
+ comment = "column_materializer::properties::wlo_enabled"
+ }
+ column "mat_$prev_pageview_max_scroll_percentage" {
+ type = "String"
+ comment = "column_materializer::properties::$prev_pageview_max_scroll_percentage"
+ }
+ column "mat_$prev_pageview_max_content_percentage" {
+ type = "String"
+ comment = "column_materializer::properties::$prev_pageview_max_content_percentage"
+ }
+ column "mat_$prev_pageview_pathname" {
+ type = "String"
+ comment = "column_materializer::properties::$prev_pageview_pathname"
+ }
+ column "mat_pp_$initial_pathname" {
+ type = "String"
+ comment = "column_materializer::person_properties::$initial_pathname"
+ }
+ column "mat_pp_$geoip_country_code" {
+ type = "String"
+ comment = "column_materializer::person_properties::$geoip_country_code"
+ }
+ column "mat_pp_username" {
+ type = "String"
+ comment = "column_materializer::person_properties::username"
+ }
+ column "mat_pp_serverMasterclass" {
+ type = "String"
+ comment = "column_materializer::person_properties::serverMasterclass"
+ }
+ column "mat_content_length" {
+ type = "String"
+ comment = "column_materializer::properties::content_length"
+ }
+ column "mat_pp_serverMarketing" {
+ type = "String"
+ comment = "column_materializer::person_properties::serverMarketing"
+ }
+ column "mat_$browser_version" {
+ type = "String"
+ comment = "column_materializer::properties::$browser_version"
+ }
+ column "mat_pp_role" {
+ type = "String"
+ comment = "column_materializer::person_properties::role"
+ }
+ column "mat_pp_customer" {
+ type = "String"
+ comment = "column_materializer::person_properties::customer"
+ }
+ column "mat_event" {
+ type = "String"
+ comment = "column_materializer::properties::event"
+ }
+ column "mat_disable_institution_search" {
+ type = "String"
+ comment = "column_materializer::properties::disable_institution_search"
+ }
+ column "mat_is_first_event_for_user" {
+ type = "String"
+ comment = "column_materializer::properties::is_first_event_for_user"
+ }
+ column "mat_current_member_guid" {
+ type = "String"
+ comment = "column_materializer::properties::current_member_guid"
+ }
+ column "mat_user_agent" {
+ type = "String"
+ comment = "column_materializer::properties::user_agent"
+ }
+ column "mat_is_test_user" {
+ type = "String"
+ comment = "column_materializer::properties::is_test_user"
+ }
+ column "mat_referrer" {
+ type = "String"
+ comment = "column_materializer::properties::referrer"
+ }
+ column "mat_pp_$initial_current_url" {
+ type = "String"
+ comment = "column_materializer::person_properties::$initial_current_url"
+ }
+ column "mat_most_recent_app_os" {
+ type = "String"
+ comment = "column_materializer::properties::most_recent_app_os"
+ }
+ column "mat_pp_hubspot_score" {
+ type = "String"
+ comment = "column_materializer::person_properties::hubspot_score"
+ }
+ column "mat_pp_id" {
+ type = "String"
+ comment = "column_materializer::person_properties::id"
+ }
+ column "mat_pp_$current_url" {
+ type = "String"
+ comment = "column_materializer::person_properties::$current_url"
+ }
+ column "mat_product_key" {
+ type = "String"
+ comment = "column_materializer::properties::product_key"
+ }
+ column "mat_Plan_type_and_filter" {
+ type = "String"
+ comment = "column_materializer::properties::Plan type and filter"
+ }
+ column "mat_$app_namespace" {
+ type = "String"
+ comment = "column_materializer::properties::$app_namespace"
+ }
+ column "mat_$os_name" {
+ type = "String"
+ comment = "column_materializer::properties::$os_name"
+ }
+ column "mat_pp_$os_name" {
+ type = "String"
+ comment = "column_materializer::person_properties::$os_name::disabled"
+ }
+ column "mat_pp_$app_version" {
+ type = "String"
+ comment = "column_materializer::person_properties::$app_version"
+ }
+ column "mat_subscriptionStatus" {
+ type = "String"
+ comment = "column_materializer::properties::subscriptionStatus"
+ }
+ column "mat_$screen_height" {
+ type = "String"
+ comment = "column_materializer::properties::$screen_height"
+ }
+ column "mat_$screen_width" {
+ type = "String"
+ comment = "column_materializer::properties::$screen_width"
+ }
+ column "mat_tag" {
+ type = "String"
+ comment = "column_materializer::properties::tag"
+ }
+ column "mat_$app_build" {
+ type = "String"
+ comment = "column_materializer::properties::$app_build"
+ }
+ column "mat_surface_tag" {
+ type = "String"
+ comment = "column_materializer::properties::surface_tag"
+ }
+ column "mat_survey_responses_count_in_period" {
+ type = "String"
+ comment = "column_materializer::properties::survey_responses_count_in_period"
+ }
+ column "mat_event_count_in_month" {
+ type = "String"
+ comment = "column_materializer::properties::event_count_in_month"
+ }
+ column "mat_ramp" {
+ type = "String"
+ comment = "column_materializer::properties::ramp"
+ }
+ column "mat_auto_chapters" {
+ type = "String"
+ comment = "column_materializer::properties::auto_chapters"
+ }
+ column "mat_sentiment_analysis" {
+ type = "String"
+ comment = "column_materializer::properties::sentiment_analysis"
+ }
+ column "mat_redact_pii" {
+ type = "String"
+ comment = "column_materializer::properties::redact_pii"
+ }
+ column "mat_content_safety" {
+ type = "String"
+ comment = "column_materializer::properties::content_safety"
+ }
+ column "mat_iab_categories" {
+ type = "String"
+ comment = "column_materializer::properties::iab_categories"
+ }
+ column "mat_auto_highlights" {
+ type = "String"
+ comment = "column_materializer::properties::auto_highlights"
+ }
+ column "mat_entity_detection" {
+ type = "String"
+ comment = "column_materializer::properties::entity_detection"
+ }
+ column "mat_summarization" {
+ type = "String"
+ comment = "column_materializer::properties::summarization"
+ }
+ column "mat_pp_val_region" {
+ type = "String"
+ comment = "column_materializer::person_properties::val_region"
+ }
+ column "mat_client_id" {
+ type = "String"
+ comment = "column_materializer::properties::client_id"
+ }
+ column "mat_$geoip_country_code" {
+ type = "String"
+ comment = "column_materializer::properties::$geoip_country_code"
+ }
+ column "mat_disfluencies" {
+ type = "String"
+ comment = "column_materializer::properties::disfluencies"
+ }
+ column "mat_filter_profanity" {
+ type = "String"
+ comment = "column_materializer::properties::filter_profanity"
+ }
+ column "mat_speaker_labels" {
+ type = "String"
+ comment = "column_materializer::properties::speaker_labels"
+ }
+ column "mat_language_detection" {
+ type = "String"
+ comment = "column_materializer::properties::language_detection"
+ }
+ column "mat_product_analytics_projected_amount" {
+ type = "String"
+ comment = "column_materializer::properties::product_analytics_projected_amount"
+ }
+ column "mat_recordings_projected_amount" {
+ type = "String"
+ comment = "column_materializer::properties::recordings_projected_amount"
+ }
+ column "mat_events_projected_amount" {
+ type = "String"
+ comment = "column_materializer::properties::events_projected_amount"
+ }
+ column "mat_session_replay_projected_amount" {
+ type = "String"
+ comment = "column_materializer::properties::session_replay_projected_amount"
+ }
+ column "mat_total_usd" {
+ type = "String"
+ comment = "column_materializer::properties::total_usd"
+ }
+ column "mat_stripe_amount_paid" {
+ type = "String"
+ comment = "column_materializer::properties::stripe_amount_paid"
+ }
+ column "mat_workspace" {
+ type = "String"
+ comment = "column_materializer::properties::workspace"
+ }
+ column "mat_created_at" {
+ type = "String"
+ comment = "column_materializer::properties::created_at"
+ }
+ column "mat_kind" {
+ type = "String"
+ comment = "column_materializer::properties::kind"
+ }
+ column "mat_product" {
+ type = "String"
+ comment = "column_materializer::properties::product"
+ }
+ column "mat_message" {
+ type = "String"
+ comment = "column_materializer::properties::message"
+ }
+ column "mat_initiator" {
+ type = "String"
+ comment = "column_materializer::properties::initiator"
+ }
+ column "mat_query" {
+ type = "String"
+ comment = "column_materializer::properties::query"
+ }
+ column "mat_$survey_id" {
+ type = "String"
+ comment = "column_materializer::properties::$survey_id"
+ }
+ column "mat_$survey_response_1" {
+ type = "String"
+ comment = "column_materializer::properties::$survey_response_1"
+ }
+ column "mat_ticketId" {
+ type = "String"
+ comment = "column_materializer::properties::ticketId"
+ }
+ column "mat_$survey_response" {
+ type = "String"
+ comment = "column_materializer::properties::$survey_response"
+ }
+ column "mat_conceptName" {
+ type = "String"
+ comment = "column_materializer::properties::conceptName"
+ }
+ column "mat_apiName" {
+ type = "String"
+ comment = "column_materializer::properties::apiName"
+ }
+ column "mat_workplace_billing_plan" {
+ type = "String"
+ comment = "column_materializer::properties::workplace_billing_plan"
+ }
+ column "mat_$el_text" {
+ type = "String"
+ comment = "column_materializer::properties::$el_text"
+ }
+ column "mat_recording_count_in_period" {
+ type = "String"
+ comment = "column_materializer::properties::recording_count_in_period"
+ }
+ column "mat_$os_version" {
+ type = "String"
+ comment = "column_materializer::properties::$os_version"
+ }
+ column "mat_orderId" {
+ type = "String"
+ comment = "column_materializer::properties::orderId"
+ }
+ column "mat_commit_sha" {
+ type = "String"
+ comment = "column_materializer::properties::commit_sha"
+ }
+ column "mat_$feature_flag_payloads" {
+ type = "String"
+ comment = "column_materializer::properties::$feature_flag_payloads"
+ }
+ column "mat_event_count_in_period" {
+ type = "String"
+ comment = "column_materializer::properties::event_count_in_period"
+ }
+ column "mat_$groups" {
+ type = "String"
+ comment = "column_materializer::properties::$groups"
+ }
+ column "mat_$feature_flag" {
+ type = "String"
+ comment = "column_materializer::properties::$feature_flag"
+ }
+ column "mat_utm_content" {
+ type = "String"
+ comment = "column_materializer::properties::utm_content"
+ }
+ column "mat_gclid" {
+ type = "String"
+ comment = "column_materializer::properties::gclid"
+ }
+ column "mat_gad_source" {
+ type = "String"
+ comment = "column_materializer::properties::gad_source"
+ }
+ column "mat_gbraid" {
+ type = "String"
+ comment = "column_materializer::properties::gbraid"
+ }
+ column "mat_wbraid" {
+ type = "String"
+ comment = "column_materializer::properties::wbraid"
+ }
+ column "mat_fbclid" {
+ type = "String"
+ comment = "column_materializer::properties::fbclid"
+ }
+ column "mat_msclkid" {
+ type = "String"
+ comment = "column_materializer::properties::msclkid"
+ }
+ column "mat_organization_id" {
+ type = "String"
+ comment = "column_materializer::properties::organization_id"
+ }
+ column "mat_owner_type" {
+ type = "String"
+ comment = "column_materializer::properties::owner_type"
+ }
+ column "mat_device_type" {
+ type = "String"
+ comment = "column_materializer::properties::device_type"
+ }
+ column "mat_$device_id" {
+ type = "String"
+ comment = "column_materializer::properties::$device_id"
+ }
+ column "mat_pp_$geoip_continent_name" {
+ type = "String"
+ comment = "column_materializer::person_properties::$geoip_continent_name"
+ }
+ column "mat_$feature_flag_response" {
+ type = "String"
+ comment = "column_materializer::properties::$feature_flag_response"
+ }
+ column "mat_pp_utm_source" {
+ type = "String"
+ comment = "column_materializer::person_properties::utm_source"
+ }
+ column "mat_pp_$referring_domain" {
+ type = "String"
+ comment = "column_materializer::person_properties::$referring_domain"
+ }
+ column "mat_pp_Email_Domain" {
+ type = "String"
+ comment = "column_materializer::person_properties::Email Domain"
+ }
+ column "mat_machine_id" {
+ type = "String"
+ comment = "column_materializer::properties::machine_id"
+ }
+ column "mat_user_email_domain" {
+ type = "String"
+ comment = "column_materializer::properties::user_email_domain"
+ }
+ column "mat_$lib_version__minor" {
+ type = "String"
+ comment = "column_materializer::properties::$lib_version__minor"
+ }
+ column "mat_region" {
+ type = "String"
+ comment = "column_materializer::properties::region"
+ }
+ column "mat_pp_user_email_domain" {
+ type = "String"
+ comment = "column_materializer::person_properties::user_email_domain"
+ }
+ column "mat_url_promotion_id" {
+ type = "String"
+ comment = "column_materializer::properties::url_promotion_id"
+ }
+ column "mat_$lib_custom_api_host" {
+ type = "String"
+ comment = "column_materializer::properties::$lib_custom_api_host"
+ }
+ column "person_mode" {
+ type = "Enum8('full'=0, 'propertyless'=1, 'force_upgrade'=2)"
+ }
+ column "mat_user_platform" {
+ type = "String"
+ comment = "column_materializer::properties::user_platform"
+ }
+ column "mat_pp_$geoip_country_name" {
+ type = "String"
+ comment = "column_materializer::person_properties::$geoip_country_name"
+ }
+ column "mat_environment" {
+ type = "String"
+ comment = "column_materializer::properties::environment"
+ }
+ column "mat_customer_email" {
+ type = "String"
+ comment = "column_materializer::properties::customer_email"
+ }
+ column "mat_client_name" {
+ type = "String"
+ comment = "column_materializer::properties::client_name"
+ }
+ column "mat_screen_name" {
+ type = "String"
+ comment = "column_materializer::properties::screen_name"
+ }
+ column "mat_app_version" {
+ type = "String"
+ comment = "column_materializer::properties::app_version"
+ }
+ column "elements_chain_href" {
+ type = "String"
+ comment = "column_materializer::elements_chain::href"
+ }
+ column "elements_chain_texts" {
+ type = "Array(String)"
+ comment = "column_materializer::elements_chain::texts"
+ }
+ column "elements_chain_ids" {
+ type = "Array(String)"
+ comment = "column_materializer::elements_chain::ids"
+ }
+ column "elements_chain_elements" {
+ type = "Array(Enum8('a'=1, 'button'=2, 'form'=3, 'input'=4, 'select'=5, 'textarea'=6, 'label'=7))"
+ comment = "column_materializer::elements_chain::elements"
+ }
+ column "properties_group_custom" {
+ type = "Map(String, String)"
+ }
+ column "properties_group_feature_flags" {
+ type = "Map(String, String)"
+ }
+ column "is_deleted" {
+ type = "Bool"
+ }
+ column "mat_subdomain" {
+ type = "String"
+ comment = "column_materializer::properties::subdomain"
+ }
+ column "mat_$device" {
+ type = "String"
+ comment = "column_materializer::properties::$device"
+ }
+ column "mat_id" {
+ type = "String"
+ comment = "column_materializer::properties::id"
+ }
+ column "mat_record_id" {
+ type = "String"
+ comment = "column_materializer::properties::record_id"
+ }
+ column "mat_referrer_id" {
+ type = "String"
+ comment = "column_materializer::properties::record_id"
+ }
+ column "mat_$exception_issue_id" {
+ type = "Nullable(String)"
+ comment = "column_materializer::properties::$exception_issue_id"
+ }
+ column "mat_$exception_fingerprint" {
+ type = "Nullable(String)"
+ comment = "column_materializer::properties::$exception_fingerprint"
+ }
+ column "mat_$web_vitals_LCP_value" {
+ type = "Nullable(String)"
+ comment = "column_materializer::properties::$web_vitals_LCP_value"
+ }
+ column "mat_$web_vitals_FCP_value" {
+ type = "Nullable(String)"
+ comment = "column_materializer::properties::$web_vitals_FCP_value"
+ }
+ column "mat_$web_vitals_CLS_value" {
+ type = "Nullable(String)"
+ comment = "column_materializer::properties::$web_vitals_CLS_value"
+ }
+ column "mat_$web_vitals_INP_value" {
+ type = "Nullable(String)"
+ comment = "column_materializer::properties::$web_vitals_INP_value"
+ }
+ column "mat_$viewport_width" {
+ type = "Nullable(String)"
+ comment = "column_materializer::properties::$viewport_width"
+ }
+ column "mat_$viewport_height" {
+ type = "Nullable(String)"
+ comment = "column_materializer::properties::$viewport_height"
+ }
+ column "mat_$anon_distinct_id" {
+ type = "Nullable(String)"
+ comment = "column_materializer::properties::$anon_distinct_id"
+ }
+ column "person_properties_map_custom" {
+ type = "Map(String, String)"
+ }
+ column "mat_$ai_trace_id" {
+ type = "Nullable(String)"
+ comment = "column_materializer::properties::$ai_trace_id"
+ }
+ column "mat_$ai_model" {
+ type = "Nullable(String)"
+ comment = "column_materializer::properties::$ai_model"
+ }
+ column "mat_$ai_provider" {
+ type = "Nullable(String)"
+ comment = "column_materializer::properties::$ai_provider"
+ }
+ column "mat_$ai_parent_id" {
+ type = "Nullable(String)"
+ comment = "column_materializer::properties::$ai_parent_id"
+ }
+ column "mat_$ai_span_id" {
+ type = "Nullable(String)"
+ comment = "column_materializer::properties::$ai_span_id"
+ }
+ column "mat_$ai_http_status" {
+ type = "Nullable(String)"
+ comment = "column_materializer::properties::$ai_http_status"
+ }
+ column "mat_$exception_types" {
+ type = "Nullable(String)"
+ comment = "column_materializer::properties::$exception_types"
+ }
+ column "mat_$exception_values" {
+ type = "Nullable(String)"
+ comment = "column_materializer::properties::$exception_values"
+ }
+ column "mat_$exception_sources" {
+ type = "Nullable(String)"
+ comment = "column_materializer::properties::$exception_sources"
+ }
+ column "mat_$exception_functions" {
+ type = "Nullable(String)"
+ comment = "column_materializer::properties::$exception_functions"
+ }
+ column "$session_id_uuid" {
+ type = "Nullable(UInt128)"
+ }
+ column "mat_$process_person_profile" {
+ type = "Nullable(String)"
+ comment = "column_materializer::properties::$process_person_profile"
+ }
+ column "consumer_breadcrumbs" {
+ type = "Array(String)"
+ }
+ column "properties_group_ai" {
+ type = "Map(String, String)"
+ }
+ column "mat_$is_identified" {
+ type = "Nullable(String)"
+ comment = "column_materializer::properties::$is_identified"
+ }
+ column "mat_historical_migration" {
+ type = "Nullable(String)"
+ comment = "column_materializer::properties::historical_migration"
+ }
+ column "mat_$ai_session_id" {
+ type = "Nullable(String)"
+ comment = "column_materializer::properties::$ai_session_id"
+ }
+ column "mat_$ai_is_error" {
+ type = "Nullable(String)"
+ comment = "column_materializer::properties::$ai_is_error"
+ }
+ column "dmat_string_0" {
+ type = "Nullable(String)"
+ }
+ column "dmat_string_1" {
+ type = "Nullable(String)"
+ }
+ column "dmat_string_2" {
+ type = "Nullable(String)"
+ }
+ column "dmat_string_3" {
+ type = "Nullable(String)"
+ }
+ column "dmat_string_4" {
+ type = "Nullable(String)"
+ }
+ column "dmat_string_5" {
+ type = "Nullable(String)"
+ }
+ column "dmat_string_6" {
+ type = "Nullable(String)"
+ }
+ column "dmat_string_7" {
+ type = "Nullable(String)"
+ }
+ column "dmat_string_8" {
+ type = "Nullable(String)"
+ }
+ column "dmat_string_9" {
+ type = "Nullable(String)"
+ }
+ column "dmat_numeric_0" {
+ type = "Nullable(Float64)"
+ }
+ column "dmat_numeric_1" {
+ type = "Nullable(Float64)"
+ }
+ column "dmat_numeric_2" {
+ type = "Nullable(Float64)"
+ }
+ column "dmat_numeric_3" {
+ type = "Nullable(Float64)"
+ }
+ column "dmat_numeric_4" {
+ type = "Nullable(Float64)"
+ }
+ column "dmat_numeric_5" {
+ type = "Nullable(Float64)"
+ }
+ column "dmat_numeric_6" {
+ type = "Nullable(Float64)"
+ }
+ column "dmat_numeric_7" {
+ type = "Nullable(Float64)"
+ }
+ column "dmat_numeric_8" {
+ type = "Nullable(Float64)"
+ }
+ column "dmat_numeric_9" {
+ type = "Nullable(Float64)"
+ }
+ column "dmat_bool_0" {
+ type = "Nullable(UInt8)"
+ }
+ column "dmat_bool_1" {
+ type = "Nullable(UInt8)"
+ }
+ column "dmat_bool_2" {
+ type = "Nullable(UInt8)"
+ }
+ column "dmat_bool_3" {
+ type = "Nullable(UInt8)"
+ }
+ column "dmat_bool_4" {
+ type = "Nullable(UInt8)"
+ }
+ column "dmat_bool_5" {
+ type = "Nullable(UInt8)"
+ }
+ column "dmat_bool_6" {
+ type = "Nullable(UInt8)"
+ }
+ column "dmat_bool_7" {
+ type = "Nullable(UInt8)"
+ }
+ column "dmat_bool_8" {
+ type = "Nullable(UInt8)"
+ }
+ column "dmat_bool_9" {
+ type = "Nullable(UInt8)"
+ }
+ column "dmat_datetime_0" {
+ type = "Nullable(DateTime64(6, 'UTC'))"
+ }
+ column "dmat_datetime_1" {
+ type = "Nullable(DateTime64(6, 'UTC'))"
+ }
+ column "dmat_datetime_2" {
+ type = "Nullable(DateTime64(6, 'UTC'))"
+ }
+ column "dmat_datetime_3" {
+ type = "Nullable(DateTime64(6, 'UTC'))"
+ }
+ column "dmat_datetime_4" {
+ type = "Nullable(DateTime64(6, 'UTC'))"
+ }
+ column "dmat_datetime_5" {
+ type = "Nullable(DateTime64(6, 'UTC'))"
+ }
+ column "dmat_datetime_6" {
+ type = "Nullable(DateTime64(6, 'UTC'))"
+ }
+ column "dmat_datetime_7" {
+ type = "Nullable(DateTime64(6, 'UTC'))"
+ }
+ column "dmat_datetime_8" {
+ type = "Nullable(DateTime64(6, 'UTC'))"
+ }
+ column "dmat_datetime_9" {
+ type = "Nullable(DateTime64(6, 'UTC'))"
+ }
+ column "historical_migration" {
+ type = "Bool"
+ }
+ column "mat_$ai_total_cost_usd" {
+ type = "Nullable(String)"
+ comment = "column_materializer::properties::$ai_total_cost_usd"
+ }
+ column "properties_group_ai_large" {
+ type = "Map(String, String)"
+ }
+ column "mat_$ai_prompt_name" {
+ type = "Nullable(String)"
+ comment = "column_materializer::properties::$ai_prompt_name"
+ }
+ engine "distributed" {
+ cluster_name = "posthog"
+ remote_database = "posthog"
+ remote_table = "sharded_events"
+ sharding_key = "sipHash64(distinct_id)"
+ }
+ }
+ table "raw_sessions_v3" {
+ order_by = ["team_id", "session_timestamp", "session_id_v7"]
+ partition_by = "toYYYYMM(session_timestamp)"
+ settings = {
+ index_granularity = "8192"
+ }
+ 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, 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
+ }
+ engine "aggregating_merge_tree" {
+ }
+ }
+ table "query_log_archive_old_ops" {
+ 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 "distributed" {
+ cluster_name = "ops"
+ remote_database = "posthog"
+ remote_table = "query_log_archive_old"
+ }
+ }
+}
diff --git a/posthog/clickhouse/hcl/sql/local-aux.sql b/posthog/clickhouse/hcl/sql/local-aux.sql
new file mode 100644
index 000000000000..e61fddea42e0
--- /dev/null
+++ b/posthog/clickhouse/hcl/sql/local-aux.sql
@@ -0,0 +1,1177 @@
+-- AUTO-GENERATED from the declarative HCL by ops/gen-sql.sh — do not edit.
+-- Full CREATE schema for the local/aux node. Apply to a fresh ClickHouse to build it.
+
+CREATE TABLE posthog.hog_invocation_results_data (
+ team_id Int64,
+ function_kind LowCardinality(String),
+ function_id String,
+ invocation_id String,
+ parent_run_id String,
+ status LowCardinality(String),
+ attempts UInt8,
+ is_retry UInt8,
+ scheduled_at DateTime64(6, 'UTC'),
+ first_scheduled_at DateTime64(6, 'UTC') DEFAULT scheduled_at,
+ started_at Nullable(DateTime64(6, 'UTC')),
+ finished_at Nullable(DateTime64(6, 'UTC')),
+ duration_ms Nullable(UInt32),
+ error_kind LowCardinality(String),
+ error_message String,
+ event_uuid String,
+ distinct_id String,
+ person_id String,
+ invocation_globals String,
+ version UInt64,
+ is_deleted UInt8 DEFAULT 0,
+ _timestamp DateTime,
+ _offset UInt64,
+ _partition UInt64,
+ INDEX status_idx status TYPE set(8) GRANULARITY 1,
+ INDEX function_idx function_id TYPE bloom_filter(0.01) GRANULARITY 1,
+ INDEX event_uuid_idx event_uuid TYPE bloom_filter(0.01) GRANULARITY 1,
+ INDEX is_retry_idx is_retry TYPE set(2) GRANULARITY 1
+) ENGINE = ReplicatedReplacingMergeTree('/clickhouse/tables/noshard/posthog.hog_invocation_results_data', '{replica}-{shard}', version) ORDER BY (team_id, function_kind, function_id, invocation_id) PARTITION BY toYYYYMMDD(scheduled_at) TTL toDate(scheduled_at) + toIntervalDay(30) SETTINGS index_granularity = 1024, ttl_only_drop_parts = 1;
+CREATE TABLE posthog.kafka_error_tracking_fingerprint_issue_state (
+ team_id Int64,
+ fingerprint String,
+ issue_id UUID,
+ issue_name Nullable(String),
+ issue_description Nullable(String),
+ issue_status String,
+ assigned_user_id Nullable(Int64),
+ assigned_role_id Nullable(UUID),
+ first_seen DateTime64(3, 'UTC'),
+ is_deleted Int8,
+ version Int64
+) ENGINE = Kafka() SETTINGS kafka_broker_list = 'msk_cluster', kafka_format = 'kafka_format = \'JSONEachRow\'', kafka_group_name = 'kafka_group_name = \'clickhouse-error-tracking-fingerprint-issue-state\'', kafka_topic_list = 'kafka_topic_list = \'clickhouse_error_tracking_fingerprint_issue_state\'';
+CREATE TABLE posthog.kafka_hog_invocation_results (
+ team_id Int64,
+ function_kind LowCardinality(String),
+ function_id String,
+ invocation_id String,
+ parent_run_id String,
+ status LowCardinality(String),
+ attempts UInt8,
+ is_retry UInt8,
+ scheduled_at DateTime64(6, 'UTC'),
+ first_scheduled_at DateTime64(6, 'UTC'),
+ started_at Nullable(DateTime64(6, 'UTC')),
+ finished_at Nullable(DateTime64(6, 'UTC')),
+ duration_ms Nullable(UInt32),
+ error_kind LowCardinality(String),
+ error_message String,
+ event_uuid String,
+ distinct_id String,
+ person_id String,
+ invocation_globals String,
+ version UInt64,
+ is_deleted UInt8
+) ENGINE = Kafka() SETTINGS kafka_broker_list = 'warpstream_cyclotron', kafka_format = 'kafka_format = \'JSONEachRow\'', kafka_group_name = 'kafka_group_name = \'clickhouse_hog_invocation_results\'', kafka_skip_broken_messages = 100, kafka_topic_list = 'kafka_topic_list = \'clickhouse_hog_invocation_results\'';
+CREATE TABLE posthog.kafka_message_assets (
+ team_id Int64,
+ function_kind LowCardinality(String),
+ function_id String,
+ parent_run_id String,
+ invocation_id String,
+ action_id String,
+ kind LowCardinality(String),
+ distinct_id String,
+ person_id String,
+ recipient String,
+ subject String,
+ status LowCardinality(String),
+ sent_at DateTime64(6, 'UTC'),
+ version UInt64,
+ is_deleted UInt8,
+ html String
+) ENGINE = Kafka() SETTINGS kafka_broker_list = 'warpstream_cyclotron', kafka_format = 'kafka_format = \'JSONEachRow\'', kafka_group_name = 'kafka_group_name = \'clickhouse_message_assets\'', kafka_skip_broken_messages = 100, kafka_topic_list = 'kafka_topic_list = \'clickhouse_message_assets\'';
+CREATE TABLE posthog.kafka_property_values (
+ team_id Int64,
+ property_type LowCardinality(String),
+ property_key String,
+ property_value String,
+ property_count UInt64
+) ENGINE = Kafka() SETTINGS kafka_broker_list = 'warpstream_ingestion', kafka_format = 'kafka_format = \'JSONEachRow\'', kafka_group_name = 'kafka_group_name = \'clickhouse_property_values\'', kafka_num_consumers = 8, kafka_thread_per_consumer = 1, kafka_topic_list = 'kafka_topic_list = \'clickhouse_property_values\'';
+CREATE TABLE posthog.message_assets_data (
+ team_id Int64,
+ function_kind LowCardinality(String),
+ function_id String,
+ parent_run_id String,
+ invocation_id String,
+ action_id String,
+ kind LowCardinality(String),
+ distinct_id String,
+ person_id String,
+ recipient String,
+ subject String,
+ status LowCardinality(String),
+ sent_at DateTime64(6, 'UTC'),
+ version UInt64,
+ is_deleted UInt8 DEFAULT 0,
+ html String CODEC(ZSTD(3)),
+ _timestamp DateTime,
+ _offset UInt64,
+ _partition UInt64,
+ INDEX parent_run_idx parent_run_id TYPE bloom_filter(0.01) GRANULARITY 1,
+ INDEX distinct_id_idx distinct_id TYPE bloom_filter(0.01) GRANULARITY 1,
+ INDEX person_id_idx person_id TYPE bloom_filter(0.01) GRANULARITY 1,
+ INDEX recipient_idx recipient TYPE bloom_filter(0.01) GRANULARITY 1
+) ENGINE = ReplicatedReplacingMergeTree('/clickhouse/tables/noshard/posthog.message_assets_data', '{replica}-{shard}', version) ORDER BY (team_id, function_kind, function_id, invocation_id, action_id) PARTITION BY toYYYYMMDD(sent_at) TTL toDate(sent_at) + toIntervalDay(30) SETTINGS index_granularity = 1024, ttl_only_drop_parts = 1;
+CREATE TABLE posthog.property_values (
+ team_id Int64 CODEC(DoubleDelta, ZSTD(1)),
+ property_type LowCardinality(String),
+ property_key LowCardinality(String),
+ property_value String,
+ property_count SimpleAggregateFunction(sum, UInt64),
+ last_seen SimpleAggregateFunction(max, DateTime) DEFAULT now(),
+ INDEX idx_property_value_ngrambf lower(property_value) TYPE ngrambf_v1(3, 32768, 3, 0) GRANULARITY 1
+) ENGINE = ReplicatedAggregatingMergeTree('/clickhouse/tables/noshard/posthog.property_values', '{replica}-{shard}') ORDER BY (team_id, property_type, property_key, property_value) TTL last_seen + toIntervalDay(30) SETTINGS index_granularity = 8192;
+CREATE TABLE posthog.property_values_distributed (
+ team_id Int64 CODEC(DoubleDelta, ZSTD(1)),
+ property_type LowCardinality(String),
+ property_key LowCardinality(String),
+ property_value String,
+ property_count SimpleAggregateFunction(sum, UInt64),
+ last_seen SimpleAggregateFunction(max, DateTime) DEFAULT now()
+) ENGINE = Distributed('aux', 'posthog', 'property_values');
+CREATE TABLE posthog.query_log_archive (
+ 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.raw_error_tracking_fingerprint_issue_state (
+ team_id Int64,
+ fingerprint String,
+ issue_id UUID,
+ issue_name Nullable(String),
+ issue_description Nullable(String),
+ issue_status String,
+ assigned_user_id Nullable(Int64),
+ assigned_role_id Nullable(UUID),
+ first_seen DateTime64(3, 'UTC'),
+ is_deleted Int8,
+ version Int64,
+ _timestamp DateTime,
+ _offset UInt64,
+ _partition UInt64,
+ INDEX kafka_timestamp_minmax_raw_error_tracking_fingerprint_issue_state _timestamp TYPE minmax GRANULARITY 3
+) ENGINE = ReplicatedReplacingMergeTree('/clickhouse/tables/noshard/posthog.raw_error_tracking_fingerprint_issue_state', '{replica}-{shard}', version) ORDER BY (team_id, fingerprint) SETTINGS index_granularity = 512;
+CREATE TABLE posthog.sharded_conversion_goal_attributed_preaggregated (
+ team_id Int64,
+ job_id UUID,
+ person_id UUID,
+ conversion_timestamp DateTime64(6, 'UTC'),
+ conversion_value Float64,
+ touchpoint_timestamp DateTime64(6, 'UTC'),
+ touchpoint_weight Float64,
+ campaign_name String,
+ source_name String,
+ medium_name String,
+ content_name String,
+ term_name String,
+ referring_domain_name String,
+ gclid_name String,
+ fbclid_name String,
+ gad_source_name String,
+ computed_at DateTime64(6, 'UTC') DEFAULT now(),
+ expires_at Date DEFAULT today() + toIntervalDay(7)
+) ENGINE = ReplicatedReplacingMergeTree('/clickhouse/tables/noshard/posthog.conversion_goal_attributed_preaggregated', '{replica}-{shard}', computed_at) ORDER BY (team_id, job_id, person_id, conversion_timestamp, touchpoint_timestamp) PARTITION BY toYYYYMMDD(expires_at) TTL expires_at SETTINGS index_granularity = 8192, ttl_only_drop_parts = 1;
+CREATE TABLE posthog.sharded_experiment_metric_events_preaggregated (
+ team_id Int64,
+ job_id UUID,
+ entity_id String,
+ timestamp DateTime64(6, 'UTC'),
+ event_uuid UUID,
+ session_id String,
+ numeric_value Float64 DEFAULT 0,
+ steps Array(UInt8) DEFAULT [],
+ computed_at DateTime64(6, 'UTC') DEFAULT now(),
+ expires_at Date DEFAULT today() + toIntervalDay(7)
+) ENGINE = ReplicatedReplacingMergeTree('/clickhouse/tables/noshard/posthog.experiment_metric_events_preaggregated', '{replica}-{shard}', computed_at) ORDER BY (team_id, job_id, entity_id, timestamp, event_uuid) PARTITION BY toYYYYMMDD(expires_at) TTL expires_at SETTINGS index_granularity = 8192, ttl_only_drop_parts = 1;
+CREATE TABLE posthog.sharded_marketing_conversions_preaggregated (
+ team_id Int64,
+ job_id UUID,
+ person_id UUID,
+ conversion_timestamp DateTime64(6, 'UTC'),
+ conversion_math_value Float64,
+ session_id String,
+ campaign_name String,
+ source_name String,
+ medium_name String,
+ content_name String,
+ term_name String,
+ referring_domain_name String,
+ gclid_name String,
+ fbclid_name String,
+ gad_source_name String,
+ computed_at DateTime64(6, 'UTC') DEFAULT now(),
+ expires_at Date DEFAULT today() + toIntervalDay(7)
+) ENGINE = ReplicatedReplacingMergeTree('/clickhouse/tables/noshard/posthog.marketing_conversions_preaggregated', '{replica}-{shard}', computed_at) ORDER BY (team_id, job_id, person_id, conversion_timestamp) PARTITION BY toYYYYMMDD(expires_at) TTL expires_at SETTINGS index_granularity = 8192, ttl_only_drop_parts = 1;
+CREATE TABLE posthog.sharded_marketing_costs_preaggregated (
+ team_id Int64,
+ job_id UUID,
+ source_id String,
+ source_name String,
+ grain LowCardinality(String),
+ match_key String,
+ campaign_id String,
+ campaign_name String,
+ ad_group_id String,
+ ad_group_name String,
+ ad_id String,
+ ad_name String,
+ cost_date Date,
+ cost Float64,
+ clicks Float64,
+ impressions Float64,
+ reported_conversions Float64,
+ reported_conversion_value Float64,
+ computed_at DateTime64(6, 'UTC') DEFAULT now(),
+ expires_at Date DEFAULT today() + toIntervalDay(7)
+) ENGINE = ReplicatedReplacingMergeTree('/clickhouse/tables/noshard/posthog.marketing_costs_preaggregated', '{replica}-{shard}', computed_at) ORDER BY (team_id, job_id, source_name, grain, campaign_id, ad_group_id, ad_id, cost_date) PARTITION BY toYYYYMMDD(expires_at) TTL expires_at SETTINGS index_granularity = 8192, ttl_only_drop_parts = 1;
+CREATE TABLE posthog.sharded_marketing_touchpoints_preaggregated (
+ team_id Int64,
+ job_id UUID,
+ person_id UUID,
+ touchpoint_timestamp DateTime64(6, 'UTC'),
+ campaign_name String,
+ source_name String,
+ medium_name String,
+ content_name String,
+ term_name String,
+ referring_domain_name String,
+ gclid_name String,
+ fbclid_name String,
+ gad_source_name String,
+ computed_at DateTime64(6, 'UTC') DEFAULT now(),
+ expires_at Date DEFAULT today() + toIntervalDay(7)
+) ENGINE = ReplicatedReplacingMergeTree('/clickhouse/tables/noshard/posthog.marketing_touchpoints_preaggregated', '{replica}-{shard}', computed_at) ORDER BY (team_id, job_id, person_id, touchpoint_timestamp) PARTITION BY toYYYYMMDD(expires_at) TTL expires_at SETTINGS index_granularity = 8192, ttl_only_drop_parts = 1;
+CREATE TABLE posthog.sharded_session_replay_features (
+ session_id String,
+ team_id Int64,
+ distinct_id String,
+ min_first_timestamp SimpleAggregateFunction(min, DateTime64(6, 'UTC')),
+ max_last_timestamp SimpleAggregateFunction(max, DateTime64(6, 'UTC')),
+ event_count SimpleAggregateFunction(sum, Int64),
+ mouse_position_count SimpleAggregateFunction(sum, Int64),
+ mouse_sum_x SimpleAggregateFunction(sum, Float64),
+ mouse_sum_x_squared SimpleAggregateFunction(sum, Float64),
+ mouse_sum_y SimpleAggregateFunction(sum, Float64),
+ mouse_sum_y_squared SimpleAggregateFunction(sum, Float64),
+ mouse_distance_traveled SimpleAggregateFunction(sum, Float64),
+ mouse_direction_change_count SimpleAggregateFunction(sum, Int64),
+ mouse_velocity_sum SimpleAggregateFunction(sum, Float64),
+ mouse_velocity_sum_of_squares SimpleAggregateFunction(sum, Float64),
+ mouse_velocity_count SimpleAggregateFunction(sum, Int64),
+ scroll_event_count SimpleAggregateFunction(sum, Int64),
+ total_scroll_magnitude SimpleAggregateFunction(sum, Float64),
+ scroll_direction_reversal_count SimpleAggregateFunction(sum, Int64),
+ rapid_scroll_reversal_count SimpleAggregateFunction(sum, Int64),
+ scroll_to_top_count SimpleAggregateFunction(sum, Int64),
+ click_count SimpleAggregateFunction(sum, Int64),
+ keypress_count SimpleAggregateFunction(sum, Int64),
+ mouse_activity_count SimpleAggregateFunction(sum, Int64),
+ rage_click_count SimpleAggregateFunction(sum, Int64),
+ dead_click_count SimpleAggregateFunction(sum, Int64),
+ backspace_count SimpleAggregateFunction(sum, Int64),
+ inter_action_gap_count SimpleAggregateFunction(sum, Int64),
+ inter_action_gap_sum_ms SimpleAggregateFunction(sum, Float64),
+ inter_action_gap_sum_of_squares_ms SimpleAggregateFunction(sum, Float64),
+ max_idle_gap_ms SimpleAggregateFunction(max, Float64),
+ long_idle_gap_count SimpleAggregateFunction(sum, Int64),
+ quick_back_count SimpleAggregateFunction(sum, Int64),
+ page_visit_count SimpleAggregateFunction(sum, Int64),
+ unique_url_count AggregateFunction(uniqCombined(12), String),
+ login_path_visit_count SimpleAggregateFunction(sum, Int64),
+ signup_path_visit_count SimpleAggregateFunction(sum, Int64),
+ checkout_path_visit_count SimpleAggregateFunction(sum, Int64),
+ cart_path_visit_count SimpleAggregateFunction(sum, Int64),
+ billing_path_visit_count SimpleAggregateFunction(sum, Int64),
+ settings_path_visit_count SimpleAggregateFunction(sum, Int64),
+ account_path_visit_count SimpleAggregateFunction(sum, Int64),
+ error_path_visit_count SimpleAggregateFunction(sum, Int64),
+ not_found_path_visit_count SimpleAggregateFunction(sum, Int64),
+ admin_path_visit_count SimpleAggregateFunction(sum, Int64),
+ dashboard_path_visit_count SimpleAggregateFunction(sum, Int64),
+ onboarding_path_visit_count SimpleAggregateFunction(sum, Int64),
+ cancel_path_visit_count SimpleAggregateFunction(sum, Int64),
+ refund_path_visit_count SimpleAggregateFunction(sum, Int64),
+ console_error_count SimpleAggregateFunction(sum, Int64),
+ console_error_after_click_count SimpleAggregateFunction(sum, Int64),
+ console_warn_count SimpleAggregateFunction(sum, Int64),
+ network_request_count SimpleAggregateFunction(sum, Int64),
+ network_failed_request_count SimpleAggregateFunction(sum, Int64),
+ network_4xx_count SimpleAggregateFunction(sum, Int64),
+ network_5xx_count SimpleAggregateFunction(sum, Int64),
+ network_request_duration_sum SimpleAggregateFunction(sum, Float64),
+ network_request_duration_sum_of_squares SimpleAggregateFunction(sum, Float64),
+ network_request_duration_count SimpleAggregateFunction(sum, Int64),
+ mutation_count SimpleAggregateFunction(sum, Int64),
+ viewport_resize_count SimpleAggregateFunction(sum, Int64),
+ touch_event_count SimpleAggregateFunction(sum, Int64),
+ max_scroll_y SimpleAggregateFunction(max, Float64),
+ unique_click_target_count AggregateFunction(uniqCombined(12), Int64),
+ unique_form_field_count AggregateFunction(uniqCombined(12), Int64),
+ text_selection_count SimpleAggregateFunction(sum, Int64),
+ selection_copy_count SimpleAggregateFunction(sum, Int64),
+ is_deleted SimpleAggregateFunction(max, UInt8) DEFAULT 0
+) ENGINE = ReplicatedAggregatingMergeTree('/clickhouse/tables/{shard}/posthog.session_replay_features', '{replica}') ORDER BY (team_id, session_id) PARTITION BY toYYYYMM(min_first_timestamp) SETTINGS index_granularity = 512;
+CREATE TABLE posthog.sharded_usage_report_events_preagg (
+ date Date,
+ team_id Int64,
+ person_mode LowCardinality(String),
+ lib LowCardinality(String),
+ event String,
+ distinct_events_unique AggregateFunction(uniqExact, Tuple(UInt64, UInt64, UInt64)),
+ event_count AggregateFunction(sum, UInt64)
+) ENGINE = ReplicatedAggregatingMergeTree('/clickhouse/tables/{shard}/posthog.sharded_usage_report_events_preagg', '{replica}') ORDER BY (date, team_id, person_mode, lib, event) PARTITION BY date TTL date + toIntervalDay(14) SETTINGS index_granularity = 8192, ttl_only_drop_parts = 1;
+CREATE TABLE posthog.sharded_web_bot_definition (
+ id UInt64,
+ parent_id UInt64,
+ regexp String,
+ keys Array(String),
+ values Array(String)
+) ENGINE = ReplicatedMergeTree('/clickhouse/tables/{shard}/posthog.sharded_web_bot_definition', '{replica}') ORDER BY (id) SETTINGS index_granularity = 8192;
+CREATE TABLE posthog.sharded_web_bounces_dimensional_preaggregated (
+ team_id Int64,
+ job_id UUID,
+ period_bucket DateTime,
+ host String,
+ device_type String,
+ entry_pathname String,
+ end_pathname String,
+ browser String,
+ os String,
+ viewport_width Int64,
+ viewport_height Int64,
+ referring_domain String,
+ utm_source String,
+ utm_medium String,
+ utm_campaign String,
+ utm_term String,
+ utm_content String,
+ country_code String,
+ city_name String,
+ region_code String,
+ region_name String,
+ has_gclid Bool,
+ has_gad_source_paid_search Bool,
+ has_fbclid Bool,
+ mat_metadata_backend Nullable(String),
+ mat_metadata_loggedIn Nullable(Bool),
+ persons_uniq_state AggregateFunction(uniq, UUID),
+ sessions_uniq_state AggregateFunction(uniq, String),
+ pageviews_count_state AggregateFunction(sum, Int64),
+ bounces_count_state AggregateFunction(sum, Int64),
+ total_session_duration_state AggregateFunction(sum, Int64),
+ total_session_count_state AggregateFunction(sum, Int64),
+ computed_at DateTime64(6, 'UTC') DEFAULT now(),
+ expires_at DateTime64(6, 'UTC') DEFAULT now() + toIntervalDay(7)
+) ENGINE = ReplicatedReplacingMergeTree('/clickhouse/tables/{shard}/posthog.web_bounces_dimensional_preaggregated', '{replica}', computed_at) ORDER BY (team_id, job_id, period_bucket, host, device_type, entry_pathname, end_pathname, browser, os, viewport_width, viewport_height, referring_domain, utm_source, utm_medium, utm_campaign, utm_term, utm_content, country_code, city_name, region_code, region_name, has_gclid, has_gad_source_paid_search, has_fbclid, mat_metadata_backend, mat_metadata_loggedIn) PARTITION BY toYYYYMMDD(expires_at) TTL toDateTime(expires_at) SETTINGS allow_nullable_key = 1, index_granularity = 8192, ttl_only_drop_parts = 1;
+CREATE TABLE posthog.sharded_web_goals_preaggregated (
+ team_id Int64,
+ job_id UUID,
+ time_window_start DateTime64(6, 'UTC'),
+ action_id Int64,
+ count_state AggregateFunction(sum, Int64),
+ unique_persons_state AggregateFunction(uniq, UUID),
+ computed_at DateTime64(6, 'UTC') DEFAULT now(),
+ expires_at DateTime64(6, 'UTC') DEFAULT now() + toIntervalDay(7)
+) ENGINE = ReplicatedReplacingMergeTree('/clickhouse/tables/{shard}/posthog.web_goals_preaggregated', '{replica}', computed_at) ORDER BY (team_id, job_id, action_id, time_window_start) PARTITION BY toYYYYMMDD(expires_at) TTL toDateTime(expires_at) SETTINGS index_granularity = 8192, ttl_only_drop_parts = 1;
+CREATE TABLE posthog.sharded_web_overview_preaggregated (
+ team_id Int64,
+ job_id UUID,
+ time_window_start DateTime64(6, 'UTC'),
+ uniq_users_state AggregateFunction(uniq, UUID),
+ uniq_sessions_state AggregateFunction(uniq, String),
+ sum_pageviews_state AggregateFunction(sum, Int64),
+ avg_duration_state AggregateFunction(avg, Float64),
+ avg_bounce_state AggregateFunction(avg, Int64),
+ computed_at DateTime64(6, 'UTC') DEFAULT now(),
+ expires_at DateTime64(6, 'UTC') DEFAULT now() + toIntervalDay(7)
+) ENGINE = ReplicatedReplacingMergeTree('/clickhouse/tables/{shard}/posthog.web_overview_preaggregated', '{replica}', computed_at) ORDER BY (team_id, job_id, time_window_start) PARTITION BY toYYYYMMDD(expires_at) TTL toDateTime(expires_at) SETTINGS index_granularity = 8192, ttl_only_drop_parts = 1;
+CREATE TABLE posthog.sharded_web_stats_dimensional_preaggregated (
+ team_id Int64,
+ job_id UUID,
+ period_bucket DateTime,
+ host String,
+ device_type String,
+ pathname String,
+ entry_pathname String,
+ end_pathname String,
+ browser String,
+ os String,
+ viewport_width Int64,
+ viewport_height Int64,
+ referring_domain String,
+ utm_source String,
+ utm_medium String,
+ utm_campaign String,
+ utm_term String,
+ utm_content String,
+ country_code String,
+ city_name String,
+ region_code String,
+ region_name String,
+ has_gclid Bool,
+ has_gad_source_paid_search Bool,
+ has_fbclid Bool,
+ mat_metadata_backend Nullable(String),
+ mat_metadata_loggedIn Nullable(Bool),
+ persons_uniq_state AggregateFunction(uniq, UUID),
+ sessions_uniq_state AggregateFunction(uniq, String),
+ pageviews_count_state AggregateFunction(sum, Int64),
+ computed_at DateTime64(6, 'UTC') DEFAULT now(),
+ expires_at DateTime64(6, 'UTC') DEFAULT now() + toIntervalDay(7)
+) ENGINE = ReplicatedReplacingMergeTree('/clickhouse/tables/{shard}/posthog.web_stats_dimensional_preaggregated', '{replica}', computed_at) ORDER BY (team_id, job_id, period_bucket, host, device_type, pathname, entry_pathname, end_pathname, browser, os, viewport_width, viewport_height, referring_domain, utm_source, utm_medium, utm_campaign, utm_term, utm_content, country_code, city_name, region_code, region_name, has_gclid, has_gad_source_paid_search, has_fbclid, mat_metadata_backend, mat_metadata_loggedIn) PARTITION BY toYYYYMMDD(expires_at) TTL toDateTime(expires_at) SETTINGS allow_nullable_key = 1, index_granularity = 8192, ttl_only_drop_parts = 1;
+CREATE TABLE posthog.sharded_web_stats_frustration_preaggregated (
+ team_id Int64,
+ job_id UUID,
+ time_window_start DateTime64(6, 'UTC'),
+ breakdown_value String,
+ sum_rage_clicks_state AggregateFunction(sum, Int64),
+ sum_dead_clicks_state AggregateFunction(sum, Int64),
+ sum_errors_state AggregateFunction(sum, Int64),
+ computed_at DateTime64(6, 'UTC') DEFAULT now(),
+ expires_at DateTime64(6, 'UTC') DEFAULT now() + toIntervalDay(7)
+) ENGINE = ReplicatedReplacingMergeTree('/clickhouse/tables/{shard}/posthog.web_stats_frustration_preaggregated', '{replica}', computed_at) ORDER BY (team_id, job_id, breakdown_value, time_window_start) PARTITION BY toYYYYMMDD(expires_at) TTL toDateTime(expires_at) SETTINGS index_granularity = 8192, ttl_only_drop_parts = 1;
+CREATE TABLE posthog.sharded_web_stats_paths_preaggregated (
+ team_id Int64,
+ job_id UUID,
+ time_window_start DateTime64(6, 'UTC'),
+ breakdown_value String,
+ uniq_users_state AggregateFunction(uniq, UUID),
+ sum_pageviews_state AggregateFunction(sum, Int64),
+ avg_bounce_state AggregateFunction(avg, Nullable(Float64)),
+ computed_at DateTime64(6, 'UTC') DEFAULT now(),
+ expires_at DateTime64(6, 'UTC') DEFAULT now() + toIntervalDay(7)
+) ENGINE = ReplicatedReplacingMergeTree('/clickhouse/tables/{shard}/posthog.web_stats_paths_preaggregated', '{replica}', computed_at) ORDER BY (team_id, job_id, breakdown_value, time_window_start) PARTITION BY toYYYYMMDD(expires_at) TTL toDateTime(expires_at) SETTINGS index_granularity = 8192, ttl_only_drop_parts = 1;
+CREATE TABLE posthog.sharded_web_stats_paths_preaggregated_pathkey (
+ team_id Int64,
+ job_id UUID,
+ time_window_start DateTime64(6, 'UTC'),
+ breakdown_value String,
+ uniq_users_state AggregateFunction(uniq, UUID),
+ sum_pageviews_state AggregateFunction(sum, Int64),
+ avg_bounce_state AggregateFunction(avg, Nullable(Float64)),
+ computed_at DateTime64(6, 'UTC') DEFAULT now(),
+ expires_at DateTime64(6, 'UTC') DEFAULT now() + toIntervalDay(7)
+) ENGINE = ReplicatedReplacingMergeTree('/clickhouse/tables/{shard}/posthog.web_stats_paths_preaggregated_pathkey', '{replica}', computed_at) ORDER BY (team_id, time_window_start, breakdown_value, job_id) PARTITION BY toYYYYMMDD(expires_at) TTL toDateTime(expires_at) SETTINGS index_granularity = 8192, ttl_only_drop_parts = 1;
+CREATE TABLE posthog.sharded_web_stats_preaggregated (
+ team_id Int64,
+ job_id UUID,
+ time_window_start DateTime64(6, 'UTC'),
+ breakdown_by String,
+ breakdown_value String,
+ uniq_users_state AggregateFunction(uniq, UUID),
+ sum_pageviews_state AggregateFunction(sum, Int64),
+ computed_at DateTime64(6, 'UTC') DEFAULT now(),
+ expires_at DateTime64(6, 'UTC') DEFAULT now() + toIntervalDay(7)
+) ENGINE = ReplicatedReplacingMergeTree('/clickhouse/tables/{shard}/posthog.web_stats_preaggregated', '{replica}', computed_at) ORDER BY (team_id, job_id, breakdown_by, time_window_start, breakdown_value) PARTITION BY toYYYYMMDD(expires_at) TTL toDateTime(expires_at) SETTINGS index_granularity = 8192, ttl_only_drop_parts = 1;
+CREATE TABLE posthog.sharded_web_vitals_paths_preaggregated (
+ team_id Int64,
+ job_id UUID,
+ time_window_start DateTime64(6, 'UTC'),
+ path String,
+ inp_quantiles_state AggregateFunction(quantiles(0.75, 0.9, 0.99), Float64),
+ lcp_quantiles_state AggregateFunction(quantiles(0.75, 0.9, 0.99), Float64),
+ cls_quantiles_state AggregateFunction(quantiles(0.75, 0.9, 0.99), Float64),
+ fcp_quantiles_state AggregateFunction(quantiles(0.75, 0.9, 0.99), Float64),
+ computed_at DateTime64(6, 'UTC') DEFAULT now(),
+ expires_at DateTime64(6, 'UTC') DEFAULT now() + toIntervalDay(7)
+) ENGINE = ReplicatedReplacingMergeTree('/clickhouse/tables/{shard}/posthog.web_vitals_paths_preaggregated', '{replica}', computed_at) ORDER BY (team_id, job_id, time_window_start, path) PARTITION BY toYYYYMMDD(expires_at) TTL toDateTime(expires_at) SETTINGS index_granularity = 8192, ttl_only_drop_parts = 1;
+CREATE TABLE posthog.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_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_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_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.writable_query_log_archive (
+ hostname LowCardinality(String),
+ user LowCardinality(String),
+ query_id String,
+ initial_query_id String,
+ is_initial_query UInt8,
+ type Enum8('QueryStart'=1, 'QueryFinish'=2, 'ExceptionBeforeStart'=3, 'ExceptionWhileProcessing'=4),
+ event_date Date,
+ event_time DateTime,
+ event_time_microseconds DateTime64(6),
+ query_start_time DateTime,
+ query_start_time_microseconds DateTime64(6),
+ query_duration_ms UInt64,
+ read_rows UInt64,
+ read_bytes UInt64,
+ written_rows UInt64,
+ written_bytes UInt64,
+ result_rows UInt64,
+ result_bytes UInt64,
+ memory_usage UInt64,
+ peak_threads_usage UInt64,
+ current_database LowCardinality(String),
+ query String,
+ formatted_query String,
+ normalized_query_hash UInt64,
+ query_kind LowCardinality(String),
+ exception_code Int32,
+ exception String,
+ stack_trace String,
+ team_id Int64,
+ log_comment JSON(max_dynamic_paths=256, access_method LowCardinality(String), alert_config_id String, api_key_label String, api_key_mask String, batch_export_id String, chargeable Bool, client_query_id String, cohort_id Int64, `dagster.job_name` String, `dagster.run_id` String, `dagster.tags.owner` String, dashboard_id Int64, experiment_feature_flag_key String, experiment_id Int64, feature LowCardinality(String), id String, insight_id Int64, is_impersonated Bool, kind LowCardinality(String), name String, org_id String, person_on_events_mode LowCardinality(String), product LowCardinality(String), query_type LowCardinality(String), request_name String, route_id String, service_name String, session_id String, table_id String, team_id Int64, `temporal.activity_id` String, `temporal.activity_type` String, `temporal.attempt` Int64, `temporal.workflow_id` String, `temporal.workflow_namespace` String, `temporal.workflow_run_id` String, `temporal.workflow_type` String, user_id Int64, warehouse_query Bool, workflow LowCardinality(String), workload LowCardinality(String), SKIP cache_key, SKIP filter, SKIP hogql_features, SKIP http_referer, SKIP http_request_id, SKIP http_user_agent, SKIP query_settings, SKIP timings, SKIP user_email),
+ ProfileEvents Map(String, UInt64)
+) ENGINE = Distributed('ops', 'posthog', 'query_log_archive_buffer');
+CREATE MATERIALIZED VIEW posthog.error_tracking_fingerprint_issue_state_mv TO posthog.writable_error_tracking_fingerprint_issue_state (team_id Int64, fingerprint String, issue_id UUID, issue_name Nullable(String), issue_description Nullable(String), issue_status String, assigned_user_id Nullable(Int64), assigned_role_id Nullable(UUID), first_seen DateTime64(3, 'UTC'), is_deleted Int8, version Int64, _timestamp Nullable(DateTime), _offset UInt64, _partition UInt64) AS SELECT
+ team_id,
+ fingerprint,
+ issue_id,
+ issue_name,
+ issue_description,
+ issue_status,
+ assigned_user_id,
+ assigned_role_id,
+ first_seen,
+ is_deleted,
+ version,
+ _timestamp,
+ _offset,
+ _partition
+FROM posthog.kafka_error_tracking_fingerprint_issue_state;
+CREATE MATERIALIZED VIEW posthog.hog_invocation_results_mv TO posthog.hog_invocation_results_data (team_id Int64, function_kind LowCardinality(String), function_id String, invocation_id String, parent_run_id String, status LowCardinality(String), attempts UInt8, is_retry UInt8, scheduled_at DateTime64(6, 'UTC'), first_scheduled_at DateTime64(6, 'UTC'), started_at Nullable(DateTime64(6, 'UTC')), finished_at Nullable(DateTime64(6, 'UTC')), duration_ms Nullable(UInt32), error_kind LowCardinality(String), error_message String, event_uuid String, distinct_id String, person_id String, invocation_globals String, version UInt64, is_deleted UInt8, _timestamp Nullable(DateTime), _offset UInt64, _partition UInt64) AS SELECT
+ team_id,
+ function_kind,
+ function_id,
+ invocation_id,
+ parent_run_id,
+ status,
+ attempts,
+ is_retry,
+ scheduled_at,
+ if(
+ first_scheduled_at = toDateTime64('1970-01-01 00:00:00', 6, 'UTC'),
+ scheduled_at,
+ first_scheduled_at
+ ) AS first_scheduled_at,
+ started_at,
+ finished_at,
+ duration_ms,
+ error_kind,
+ error_message,
+ event_uuid,
+ distinct_id,
+ person_id,
+ invocation_globals,
+ version,
+ is_deleted,
+ _timestamp,
+ _offset,
+ _partition
+FROM posthog.kafka_hog_invocation_results;
+CREATE MATERIALIZED VIEW posthog.message_assets_mv TO posthog.message_assets_data (team_id Int64, function_kind LowCardinality(String), function_id String, parent_run_id String, invocation_id String, action_id String, kind LowCardinality(String), distinct_id String, person_id String, recipient String, subject String, status LowCardinality(String), sent_at DateTime64(6, 'UTC'), version UInt64, is_deleted UInt8, html String, _timestamp Nullable(DateTime), _offset UInt64, _partition UInt64) AS SELECT
+ team_id,
+ function_kind,
+ function_id,
+ parent_run_id,
+ invocation_id,
+ action_id,
+ kind,
+ distinct_id,
+ person_id,
+ recipient,
+ subject,
+ status,
+ sent_at,
+ version,
+ is_deleted,
+ html,
+ _timestamp,
+ _offset,
+ _partition
+FROM posthog.kafka_message_assets;
+CREATE MATERIALIZED VIEW posthog.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.property_values_mv TO posthog.property_values (team_id Int64, property_type LowCardinality(String), property_key String, property_value String, property_count UInt64, last_seen DateTime) AS SELECT
+ team_id,
+ property_type,
+ property_key,
+ property_value,
+ property_count,
+ coalesce(_timestamp, now()) AS last_seen
+FROM posthog.kafka_property_values;
+CREATE 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 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 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.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.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.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.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.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));
diff --git a/posthog/clickhouse/hcl/sql/local-sessions.sql b/posthog/clickhouse/hcl/sql/local-sessions.sql
new file mode 100644
index 000000000000..251e88f042a9
--- /dev/null
+++ b/posthog/clickhouse/hcl/sql/local-sessions.sql
@@ -0,0 +1,267 @@
+-- AUTO-GENERATED from the declarative HCL by ops/gen-sql.sh — do not edit.
+-- Full CREATE schema for the local/sessions node. Apply to a fresh ClickHouse to build it.
+
+CREATE TABLE posthog.query_log_archive (
+ hostname LowCardinality(String),
+ user LowCardinality(String),
+ query_id String,
+ initial_query_id String,
+ is_initial_query UInt8,
+ type Enum8('QueryStart'=1, 'QueryFinish'=2, 'ExceptionBeforeStart'=3, 'ExceptionWhileProcessing'=4),
+ event_date Date,
+ event_time DateTime,
+ event_time_microseconds DateTime64(6),
+ query_start_time DateTime,
+ query_start_time_microseconds DateTime64(6),
+ query_duration_ms UInt64,
+ read_rows UInt64,
+ read_bytes UInt64,
+ written_rows UInt64,
+ written_bytes UInt64,
+ result_rows UInt64,
+ result_bytes UInt64,
+ memory_usage UInt64,
+ peak_threads_usage UInt64,
+ current_database LowCardinality(String),
+ query String,
+ formatted_query String,
+ normalized_query_hash UInt64,
+ query_kind LowCardinality(String),
+ exception_code Int32,
+ exception String,
+ stack_trace String,
+ team_id Int64,
+ log_comment JSON(max_dynamic_paths=256, access_method LowCardinality(String), alert_config_id String, api_key_label String, api_key_mask String, batch_export_id String, chargeable Bool, client_query_id String, cohort_id Int64, `dagster.job_name` String, `dagster.run_id` String, `dagster.tags.owner` String, dashboard_id Int64, experiment_feature_flag_key String, experiment_id Int64, feature LowCardinality(String), id String, insight_id Int64, is_impersonated Bool, kind LowCardinality(String), name String, org_id String, person_on_events_mode LowCardinality(String), product LowCardinality(String), query_type LowCardinality(String), request_name String, route_id String, service_name String, session_id String, table_id String, team_id Int64, `temporal.activity_id` String, `temporal.activity_type` String, `temporal.attempt` Int64, `temporal.workflow_id` String, `temporal.workflow_namespace` String, `temporal.workflow_run_id` String, `temporal.workflow_type` String, user_id Int64, warehouse_query Bool, workflow LowCardinality(String), workload LowCardinality(String), SKIP cache_key, SKIP filter, SKIP hogql_features, SKIP http_referer, SKIP http_request_id, SKIP http_user_agent, SKIP query_settings, SKIP timings, SKIP user_email),
+ ProfileEvents Map(String, UInt64),
+ exception_name String ALIAS errorCodeToName(exception_code),
+ ProfileEvents_RealTimeMicroseconds Int64 ALIAS ProfileEvents['RealTimeMicroseconds'],
+ ProfileEvents_OSCPUVirtualTimeMicroseconds Int64 ALIAS ProfileEvents['OSCPUVirtualTimeMicroseconds'],
+ ProfileEvents_S3Clients Int64 ALIAS ProfileEvents['S3Clients'],
+ ProfileEvents_S3DeleteObjects Int64 ALIAS ProfileEvents['S3DeleteObjects'],
+ ProfileEvents_S3CopyObject Int64 ALIAS ProfileEvents['S3CopyObject'],
+ ProfileEvents_S3ListObjects Int64 ALIAS ProfileEvents['S3ListObjects'],
+ ProfileEvents_S3HeadObject Int64 ALIAS ProfileEvents['S3HeadObject'],
+ ProfileEvents_S3GetObjectAttributes Int64 ALIAS ProfileEvents['S3GetObjectAttributes'],
+ ProfileEvents_S3CreateMultipartUpload Int64 ALIAS ProfileEvents['S3CreateMultipartUpload'],
+ ProfileEvents_S3UploadPartCopy Int64 ALIAS ProfileEvents['S3UploadPartCopy'],
+ ProfileEvents_S3UploadPart Int64 ALIAS ProfileEvents['S3UploadPart'],
+ ProfileEvents_S3AbortMultipartUpload Int64 ALIAS ProfileEvents['S3AbortMultipartUpload'],
+ ProfileEvents_S3CompleteMultipartUpload Int64 ALIAS ProfileEvents['S3CompleteMultipartUpload'],
+ ProfileEvents_S3PutObject Int64 ALIAS ProfileEvents['S3PutObject'],
+ ProfileEvents_S3GetObject Int64 ALIAS ProfileEvents['S3GetObject'],
+ ProfileEvents_ReadBufferFromS3Bytes Int64 ALIAS ProfileEvents['ReadBufferFromS3Bytes'],
+ ProfileEvents_WriteBufferFromS3Bytes Int64 ALIAS ProfileEvents['WriteBufferFromS3Bytes'],
+ lc_workflow LowCardinality(String) ALIAS log_comment.workflow,
+ lc_kind LowCardinality(String) ALIAS log_comment.kind,
+ lc_id String ALIAS CAST(log_comment.id, 'String'),
+ lc_route_id String ALIAS CAST(log_comment.route_id, 'String'),
+ lc_access_method LowCardinality(String) ALIAS log_comment.access_method,
+ lc_api_key_label String ALIAS CAST(log_comment.api_key_label, 'String'),
+ lc_api_key_mask String ALIAS CAST(log_comment.api_key_mask, 'String'),
+ lc_query_type LowCardinality(String) ALIAS log_comment.query_type,
+ lc_product LowCardinality(String) ALIAS log_comment.product,
+ lc_chargeable Bool ALIAS log_comment.chargeable,
+ lc_name String ALIAS CAST(log_comment.name, 'String'),
+ lc_request_name String ALIAS CAST(log_comment.request_name, 'String'),
+ lc_client_query_id String ALIAS CAST(log_comment.client_query_id, 'String'),
+ lc_org_id String ALIAS CAST(log_comment.org_id, 'String'),
+ lc_user_id Int64 ALIAS log_comment.user_id,
+ lc_is_impersonated Bool ALIAS log_comment.is_impersonated,
+ lc_session_id String ALIAS CAST(log_comment.session_id, 'String'),
+ lc_dashboard_id Int64 ALIAS log_comment.dashboard_id,
+ lc_insight_id Int64 ALIAS log_comment.insight_id,
+ lc_cohort_id Int64 ALIAS log_comment.cohort_id,
+ lc_batch_export_id String ALIAS CAST(log_comment.batch_export_id, 'String'),
+ lc_experiment_id Int64 ALIAS log_comment.experiment_id,
+ lc_experiment_feature_flag_key String ALIAS CAST(log_comment.experiment_feature_flag_key, 'String'),
+ lc_alert_config_id String ALIAS CAST(log_comment.alert_config_id, 'String'),
+ lc_feature LowCardinality(String) ALIAS log_comment.feature,
+ lc_table_id String ALIAS CAST(log_comment.table_id, 'String'),
+ lc_warehouse_query Bool ALIAS log_comment.warehouse_query,
+ lc_person_on_events_mode LowCardinality(String) ALIAS log_comment.person_on_events_mode,
+ lc_service_name String ALIAS CAST(log_comment.service_name, 'String'),
+ lc_workload LowCardinality(String) ALIAS log_comment.workload,
+ lc_query__kind LowCardinality(String) ALIAS if(JSONHas(toString(log_comment), 'query', 'source'), JSONExtractString(toString(log_comment), 'query', 'source', 'kind'), JSONExtractString(toString(log_comment), 'query', 'kind')),
+ lc_query__query String ALIAS multiIf(NOT is_initial_query, '', JSONHas(toString(log_comment), 'query', 'source'), JSONExtractString(toString(log_comment), 'query', 'source', 'query'), JSONExtractString(toString(log_comment), 'query', 'query')),
+ lc_query String ALIAS if(is_initial_query, JSONExtractRaw(toString(log_comment), 'query'), ''),
+ lc_temporal__workflow_namespace String ALIAS CAST(log_comment.`temporal.workflow_namespace`, 'String'),
+ lc_temporal__workflow_type String ALIAS CAST(log_comment.`temporal.workflow_type`, 'String'),
+ lc_temporal__workflow_id String ALIAS CAST(log_comment.`temporal.workflow_id`, 'String'),
+ lc_temporal__workflow_run_id String ALIAS CAST(log_comment.`temporal.workflow_run_id`, 'String'),
+ lc_temporal__activity_type String ALIAS CAST(log_comment.`temporal.activity_type`, 'String'),
+ lc_temporal__activity_id String ALIAS CAST(log_comment.`temporal.activity_id`, 'String'),
+ lc_temporal__attempt Int64 ALIAS log_comment.`temporal.attempt`,
+ lc_dagster__job_name String ALIAS CAST(log_comment.`dagster.job_name`, 'String'),
+ lc_dagster__run_id String ALIAS CAST(log_comment.`dagster.run_id`, 'String'),
+ lc_dagster__owner String ALIAS CAST(log_comment.`dagster.tags.owner`, 'String'),
+ lc_modifiers String ALIAS if(is_initial_query, JSONExtractRaw(toString(log_comment), 'modifiers'), '')
+) ENGINE = Distributed('ops', 'posthog', 'sharded_query_log_archive');
+CREATE TABLE posthog.writable_query_log_archive (
+ hostname LowCardinality(String),
+ user LowCardinality(String),
+ query_id String,
+ initial_query_id String,
+ is_initial_query UInt8,
+ type Enum8('QueryStart'=1, 'QueryFinish'=2, 'ExceptionBeforeStart'=3, 'ExceptionWhileProcessing'=4),
+ event_date Date,
+ event_time DateTime,
+ event_time_microseconds DateTime64(6),
+ query_start_time DateTime,
+ query_start_time_microseconds DateTime64(6),
+ query_duration_ms UInt64,
+ read_rows UInt64,
+ read_bytes UInt64,
+ written_rows UInt64,
+ written_bytes UInt64,
+ result_rows UInt64,
+ result_bytes UInt64,
+ memory_usage UInt64,
+ peak_threads_usage UInt64,
+ current_database LowCardinality(String),
+ query String,
+ formatted_query String,
+ normalized_query_hash UInt64,
+ query_kind LowCardinality(String),
+ exception_code Int32,
+ exception String,
+ stack_trace String,
+ team_id Int64,
+ log_comment JSON(max_dynamic_paths=256, access_method LowCardinality(String), alert_config_id String, api_key_label String, api_key_mask String, batch_export_id String, chargeable Bool, client_query_id String, cohort_id Int64, `dagster.job_name` String, `dagster.run_id` String, `dagster.tags.owner` String, dashboard_id Int64, experiment_feature_flag_key String, experiment_id Int64, feature LowCardinality(String), id String, insight_id Int64, is_impersonated Bool, kind LowCardinality(String), name String, org_id String, person_on_events_mode LowCardinality(String), product LowCardinality(String), query_type LowCardinality(String), request_name String, route_id String, service_name String, session_id String, table_id String, team_id Int64, `temporal.activity_id` String, `temporal.activity_type` String, `temporal.attempt` Int64, `temporal.workflow_id` String, `temporal.workflow_namespace` String, `temporal.workflow_run_id` String, `temporal.workflow_type` String, user_id Int64, warehouse_query Bool, workflow LowCardinality(String), workload LowCardinality(String), SKIP cache_key, SKIP filter, SKIP hogql_features, SKIP http_referer, SKIP http_request_id, SKIP http_user_agent, SKIP query_settings, SKIP timings, SKIP user_email),
+ ProfileEvents Map(String, UInt64)
+) ENGINE = Distributed('ops', 'posthog', 'query_log_archive_buffer');
+CREATE MATERIALIZED VIEW posthog.ops_query_log_archive_mv TO posthog.writable_query_log_archive (hostname LowCardinality(String), user LowCardinality(String), query_id String, initial_query_id String, is_initial_query UInt8, type Enum8('QueryStart'=1, 'QueryFinish'=2, 'ExceptionBeforeStart'=3, 'ExceptionWhileProcessing'=4), event_date Date, event_time DateTime, event_time_microseconds DateTime64(6), query_start_time DateTime, query_start_time_microseconds DateTime64(6), query_duration_ms UInt64, read_rows UInt64, read_bytes UInt64, written_rows UInt64, written_bytes UInt64, result_rows UInt64, result_bytes UInt64, memory_usage UInt64, peak_threads_usage UInt64, current_database LowCardinality(String), query String, formatted_query String, normalized_query_hash UInt64, query_kind LowCardinality(String), exception_code Int32, exception String, stack_trace String, team_id Int64, log_comment String, ProfileEvents Map(LowCardinality(String), UInt64)) AS SELECT
+ hostname,
+ user,
+ query_id,
+ initial_query_id,
+ is_initial_query,
+ type,
+ event_date,
+ event_time,
+ event_time_microseconds,
+ query_start_time,
+ query_start_time_microseconds,
+ query_duration_ms,
+ read_rows,
+ read_bytes,
+ written_rows,
+ written_bytes,
+ result_rows,
+ result_bytes,
+ memory_usage,
+ peak_threads_usage,
+ current_database,
+ query,
+ formatted_query,
+ normalized_query_hash,
+ query_kind,
+ exception_code,
+ exception,
+ stack_trace,
+ JSONExtractInt(log_comment, 'team_id') AS team_id,
+ if(isValidJSON(log_comment), log_comment, '{}') AS log_comment,
+ ProfileEvents
+FROM system.query_log
+WHERE type != 'QueryStart';
+CREATE VIEW posthog.custom_metrics_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;
diff --git a/posthog/clickhouse/hcl/sql/prod-eu-aux.sql b/posthog/clickhouse/hcl/sql/prod-eu-aux.sql
new file mode 100644
index 000000000000..e17174061bd9
--- /dev/null
+++ b/posthog/clickhouse/hcl/sql/prod-eu-aux.sql
@@ -0,0 +1,1148 @@
+-- AUTO-GENERATED from the declarative HCL by ops/gen-sql.sh — do not edit.
+-- Full CREATE schema for the prod-eu/aux node. Apply to a fresh ClickHouse to build it.
+
+CREATE TABLE posthog.hog_invocation_results_data (
+ team_id Int64,
+ function_kind LowCardinality(String),
+ function_id String,
+ invocation_id String,
+ parent_run_id String,
+ status LowCardinality(String),
+ attempts UInt8,
+ is_retry UInt8,
+ scheduled_at DateTime64(6, 'UTC'),
+ first_scheduled_at DateTime64(6, 'UTC') DEFAULT scheduled_at,
+ started_at Nullable(DateTime64(6, 'UTC')),
+ finished_at Nullable(DateTime64(6, 'UTC')),
+ duration_ms Nullable(UInt32),
+ error_kind LowCardinality(String),
+ error_message String,
+ event_uuid String,
+ distinct_id String,
+ person_id String,
+ invocation_globals String,
+ version UInt64,
+ is_deleted UInt8 DEFAULT 0,
+ _timestamp DateTime,
+ _offset UInt64,
+ _partition UInt64,
+ INDEX status_idx status TYPE set(8) GRANULARITY 1,
+ INDEX function_idx function_id TYPE bloom_filter(0.01) GRANULARITY 1,
+ INDEX event_uuid_idx event_uuid TYPE bloom_filter(0.01) GRANULARITY 1,
+ INDEX is_retry_idx is_retry TYPE set(2) GRANULARITY 1
+) ENGINE = ReplicatedReplacingMergeTree('/clickhouse/tables/noshard/posthog.hog_invocation_results_data', '{replica}-{shard}', version) ORDER BY (team_id, function_kind, function_id, invocation_id) PARTITION BY toYYYYMMDD(scheduled_at) TTL toDate(scheduled_at) + toIntervalDay(30) SETTINGS index_granularity = 1024, storage_policy = 's3_tiered', ttl_only_drop_parts = 1;
+CREATE TABLE posthog.kafka_hog_invocation_results (
+ team_id Int64,
+ function_kind LowCardinality(String),
+ function_id String,
+ invocation_id String,
+ parent_run_id String,
+ status LowCardinality(String),
+ attempts UInt8,
+ is_retry UInt8,
+ scheduled_at DateTime64(6, 'UTC'),
+ first_scheduled_at DateTime64(6, 'UTC'),
+ started_at Nullable(DateTime64(6, 'UTC')),
+ finished_at Nullable(DateTime64(6, 'UTC')),
+ duration_ms Nullable(UInt32),
+ error_kind LowCardinality(String),
+ error_message String,
+ event_uuid String,
+ distinct_id String,
+ person_id String,
+ invocation_globals String,
+ version UInt64,
+ is_deleted UInt8
+) ENGINE = Kafka() SETTINGS kafka_broker_list = 'warpstream_cyclotron', kafka_format = 'kafka_format = \'JSONEachRow\'', kafka_group_name = 'kafka_group_name = \'clickhouse_hog_invocation_results\'', kafka_skip_broken_messages = 100, kafka_topic_list = 'kafka_topic_list = \'clickhouse_hog_invocation_results\'';
+CREATE TABLE posthog.kafka_message_assets (
+ team_id Int64,
+ function_kind LowCardinality(String),
+ function_id String,
+ parent_run_id String,
+ invocation_id String,
+ action_id String,
+ kind LowCardinality(String),
+ distinct_id String,
+ person_id String,
+ recipient String,
+ subject String,
+ status LowCardinality(String),
+ sent_at DateTime64(6, 'UTC'),
+ version UInt64,
+ is_deleted UInt8,
+ html String
+) ENGINE = Kafka() SETTINGS kafka_broker_list = 'warpstream_cyclotron', kafka_format = 'kafka_format = \'JSONEachRow\'', kafka_group_name = 'kafka_group_name = \'clickhouse_message_assets\'', kafka_skip_broken_messages = 100, kafka_topic_list = 'kafka_topic_list = \'clickhouse_message_assets\'';
+CREATE TABLE posthog.kafka_property_values (
+ team_id Int64,
+ property_type LowCardinality(String),
+ property_key String,
+ property_value String,
+ property_count UInt64
+) ENGINE = Kafka() SETTINGS kafka_broker_list = 'warpstream_ingestion', kafka_format = 'kafka_format = \'JSONEachRow\'', kafka_group_name = 'kafka_group_name = \'clickhouse_property_values\'', kafka_num_consumers = 8, kafka_thread_per_consumer = 1, kafka_topic_list = 'kafka_topic_list = \'clickhouse_property_values\'';
+CREATE TABLE posthog.message_assets_data (
+ team_id Int64,
+ function_kind LowCardinality(String),
+ function_id String,
+ parent_run_id String,
+ invocation_id String,
+ action_id String,
+ kind LowCardinality(String),
+ distinct_id String,
+ person_id String,
+ recipient String,
+ subject String,
+ status LowCardinality(String),
+ sent_at DateTime64(6, 'UTC'),
+ version UInt64,
+ is_deleted UInt8 DEFAULT 0,
+ html String CODEC(ZSTD(3)),
+ _timestamp DateTime,
+ _offset UInt64,
+ _partition UInt64,
+ INDEX parent_run_idx parent_run_id TYPE bloom_filter(0.01) GRANULARITY 1,
+ INDEX distinct_id_idx distinct_id TYPE bloom_filter(0.01) GRANULARITY 1,
+ INDEX person_id_idx person_id TYPE bloom_filter(0.01) GRANULARITY 1,
+ INDEX recipient_idx recipient TYPE bloom_filter(0.01) GRANULARITY 1
+) ENGINE = ReplicatedReplacingMergeTree('/clickhouse/tables/noshard/posthog.message_assets_data', '{replica}-{shard}', version) ORDER BY (team_id, function_kind, function_id, invocation_id, action_id) PARTITION BY toYYYYMMDD(sent_at) TTL toDate(sent_at) + toIntervalDay(30) SETTINGS index_granularity = 1024, ttl_only_drop_parts = 1;
+CREATE TABLE posthog.property_values (
+ team_id Int64 CODEC(DoubleDelta, ZSTD(1)),
+ property_type LowCardinality(String),
+ property_key LowCardinality(String),
+ property_value String,
+ property_count SimpleAggregateFunction(sum, UInt64),
+ last_seen SimpleAggregateFunction(max, DateTime) DEFAULT now(),
+ INDEX idx_property_value_ngrambf lower(property_value) TYPE ngrambf_v1(3, 32768, 3, 0) GRANULARITY 1
+) ENGINE = ReplicatedAggregatingMergeTree('/clickhouse/tables/noshard/posthog.property_values', '{replica}-{shard}') ORDER BY (team_id, property_type, property_key, property_value) TTL last_seen + toIntervalDay(30) SETTINGS index_granularity = 8192;
+CREATE TABLE posthog.property_values_distributed (
+ team_id Int64 CODEC(DoubleDelta, ZSTD(1)),
+ property_type LowCardinality(String),
+ property_key LowCardinality(String),
+ property_value String,
+ property_count SimpleAggregateFunction(sum, UInt64),
+ last_seen SimpleAggregateFunction(max, DateTime) DEFAULT now()
+) ENGINE = Distributed('aux', 'posthog', 'property_values');
+CREATE TABLE posthog.query_log_archive (
+ 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.raw_error_tracking_fingerprint_issue_state (
+ team_id Int64,
+ fingerprint String,
+ issue_id UUID,
+ issue_name Nullable(String),
+ issue_description Nullable(String),
+ issue_status String,
+ assigned_user_id Nullable(Int64),
+ assigned_role_id Nullable(UUID),
+ first_seen DateTime64(3, 'UTC'),
+ is_deleted Int8,
+ version Int64,
+ _timestamp DateTime,
+ _offset UInt64,
+ _partition UInt64,
+ INDEX kafka_timestamp_minmax_raw_error_tracking_fingerprint_issue_state _timestamp TYPE minmax GRANULARITY 3
+) ENGINE = ReplicatedReplacingMergeTree('/clickhouse/tables/noshard/posthog.raw_error_tracking_fingerprint_issue_state', '{replica}-{shard}', version) ORDER BY (team_id, fingerprint) SETTINGS index_granularity = 512;
+CREATE TABLE posthog.sharded_conversion_goal_attributed_preaggregated (
+ team_id Int64,
+ job_id UUID,
+ person_id UUID,
+ conversion_timestamp DateTime64(6, 'UTC'),
+ conversion_value Float64,
+ touchpoint_timestamp DateTime64(6, 'UTC'),
+ touchpoint_weight Float64,
+ campaign_name String,
+ source_name String,
+ medium_name String,
+ content_name String,
+ term_name String,
+ referring_domain_name String,
+ gclid_name String,
+ fbclid_name String,
+ gad_source_name String,
+ computed_at DateTime64(6, 'UTC') DEFAULT now(),
+ expires_at Date DEFAULT today() + toIntervalDay(7)
+) ENGINE = ReplicatedReplacingMergeTree('/clickhouse/tables/noshard/posthog.conversion_goal_attributed_preaggregated', '{replica}-{shard}', computed_at) ORDER BY (team_id, job_id, person_id, conversion_timestamp, touchpoint_timestamp) PARTITION BY toYYYYMMDD(expires_at) TTL expires_at SETTINGS index_granularity = 8192, ttl_only_drop_parts = 1;
+CREATE TABLE posthog.sharded_experiment_metric_events_preaggregated (
+ team_id Int64,
+ job_id UUID,
+ entity_id String,
+ timestamp DateTime64(6, 'UTC'),
+ event_uuid UUID,
+ session_id String,
+ numeric_value Float64 DEFAULT 0,
+ steps Array(UInt8) DEFAULT [],
+ computed_at DateTime64(6, 'UTC') DEFAULT now(),
+ expires_at Date DEFAULT today() + toIntervalDay(7)
+) ENGINE = ReplicatedReplacingMergeTree('/clickhouse/tables/noshard/posthog.experiment_metric_events_preaggregated', '{replica}-{shard}', computed_at) ORDER BY (team_id, job_id, entity_id, timestamp, event_uuid) PARTITION BY toYYYYMMDD(expires_at) TTL expires_at SETTINGS index_granularity = 8192, ttl_only_drop_parts = 1;
+CREATE TABLE posthog.sharded_marketing_conversions_preaggregated (
+ team_id Int64,
+ job_id UUID,
+ person_id UUID,
+ conversion_timestamp DateTime64(6, 'UTC'),
+ conversion_math_value Float64,
+ session_id String,
+ campaign_name String,
+ source_name String,
+ medium_name String,
+ content_name String,
+ term_name String,
+ referring_domain_name String,
+ gclid_name String,
+ fbclid_name String,
+ gad_source_name String,
+ computed_at DateTime64(6, 'UTC') DEFAULT now(),
+ expires_at Date DEFAULT today() + toIntervalDay(7)
+) ENGINE = ReplicatedReplacingMergeTree('/clickhouse/tables/noshard/posthog.marketing_conversions_preaggregated', '{replica}-{shard}', computed_at) ORDER BY (team_id, job_id, person_id, conversion_timestamp) PARTITION BY toYYYYMMDD(expires_at) TTL expires_at SETTINGS index_granularity = 8192, ttl_only_drop_parts = 1;
+CREATE TABLE posthog.sharded_marketing_costs_preaggregated (
+ team_id Int64,
+ job_id UUID,
+ source_id String,
+ source_name String,
+ grain LowCardinality(String),
+ match_key String,
+ campaign_id String,
+ campaign_name String,
+ ad_group_id String,
+ ad_group_name String,
+ ad_id String,
+ ad_name String,
+ cost_date Date,
+ cost Float64,
+ clicks Float64,
+ impressions Float64,
+ reported_conversions Float64,
+ reported_conversion_value Float64,
+ computed_at DateTime64(6, 'UTC') DEFAULT now(),
+ expires_at Date DEFAULT today() + toIntervalDay(7)
+) ENGINE = ReplicatedReplacingMergeTree('/clickhouse/tables/noshard/posthog.marketing_costs_preaggregated', '{replica}-{shard}', computed_at) ORDER BY (team_id, job_id, source_name, grain, campaign_id, ad_group_id, ad_id, cost_date) PARTITION BY toYYYYMMDD(expires_at) TTL expires_at SETTINGS index_granularity = 8192, ttl_only_drop_parts = 1;
+CREATE TABLE posthog.sharded_marketing_touchpoints_preaggregated (
+ team_id Int64,
+ job_id UUID,
+ person_id UUID,
+ touchpoint_timestamp DateTime64(6, 'UTC'),
+ campaign_name String,
+ source_name String,
+ medium_name String,
+ content_name String,
+ term_name String,
+ referring_domain_name String,
+ gclid_name String,
+ fbclid_name String,
+ gad_source_name String,
+ computed_at DateTime64(6, 'UTC') DEFAULT now(),
+ expires_at Date DEFAULT today() + toIntervalDay(7)
+) ENGINE = ReplicatedReplacingMergeTree('/clickhouse/tables/noshard/posthog.marketing_touchpoints_preaggregated', '{replica}-{shard}', computed_at) ORDER BY (team_id, job_id, person_id, touchpoint_timestamp) PARTITION BY toYYYYMMDD(expires_at) TTL expires_at SETTINGS index_granularity = 8192, ttl_only_drop_parts = 1;
+CREATE TABLE posthog.sharded_session_replay_features (
+ session_id String,
+ team_id Int64,
+ distinct_id String,
+ min_first_timestamp SimpleAggregateFunction(min, DateTime64(6, 'UTC')),
+ max_last_timestamp SimpleAggregateFunction(max, DateTime64(6, 'UTC')),
+ event_count SimpleAggregateFunction(sum, Int64),
+ mouse_position_count SimpleAggregateFunction(sum, Int64),
+ mouse_sum_x SimpleAggregateFunction(sum, Float64),
+ mouse_sum_x_squared SimpleAggregateFunction(sum, Float64),
+ mouse_sum_y SimpleAggregateFunction(sum, Float64),
+ mouse_sum_y_squared SimpleAggregateFunction(sum, Float64),
+ mouse_distance_traveled SimpleAggregateFunction(sum, Float64),
+ mouse_direction_change_count SimpleAggregateFunction(sum, Int64),
+ mouse_velocity_sum SimpleAggregateFunction(sum, Float64),
+ mouse_velocity_sum_of_squares SimpleAggregateFunction(sum, Float64),
+ mouse_velocity_count SimpleAggregateFunction(sum, Int64),
+ scroll_event_count SimpleAggregateFunction(sum, Int64),
+ total_scroll_magnitude SimpleAggregateFunction(sum, Float64),
+ scroll_direction_reversal_count SimpleAggregateFunction(sum, Int64),
+ rapid_scroll_reversal_count SimpleAggregateFunction(sum, Int64),
+ scroll_to_top_count SimpleAggregateFunction(sum, Int64),
+ click_count SimpleAggregateFunction(sum, Int64),
+ keypress_count SimpleAggregateFunction(sum, Int64),
+ mouse_activity_count SimpleAggregateFunction(sum, Int64),
+ rage_click_count SimpleAggregateFunction(sum, Int64),
+ dead_click_count SimpleAggregateFunction(sum, Int64),
+ backspace_count SimpleAggregateFunction(sum, Int64),
+ inter_action_gap_count SimpleAggregateFunction(sum, Int64),
+ inter_action_gap_sum_ms SimpleAggregateFunction(sum, Float64),
+ inter_action_gap_sum_of_squares_ms SimpleAggregateFunction(sum, Float64),
+ max_idle_gap_ms SimpleAggregateFunction(max, Float64),
+ long_idle_gap_count SimpleAggregateFunction(sum, Int64),
+ quick_back_count SimpleAggregateFunction(sum, Int64),
+ page_visit_count SimpleAggregateFunction(sum, Int64),
+ unique_url_count AggregateFunction(uniqCombined(12), String),
+ login_path_visit_count SimpleAggregateFunction(sum, Int64),
+ signup_path_visit_count SimpleAggregateFunction(sum, Int64),
+ checkout_path_visit_count SimpleAggregateFunction(sum, Int64),
+ cart_path_visit_count SimpleAggregateFunction(sum, Int64),
+ billing_path_visit_count SimpleAggregateFunction(sum, Int64),
+ settings_path_visit_count SimpleAggregateFunction(sum, Int64),
+ account_path_visit_count SimpleAggregateFunction(sum, Int64),
+ error_path_visit_count SimpleAggregateFunction(sum, Int64),
+ not_found_path_visit_count SimpleAggregateFunction(sum, Int64),
+ admin_path_visit_count SimpleAggregateFunction(sum, Int64),
+ dashboard_path_visit_count SimpleAggregateFunction(sum, Int64),
+ onboarding_path_visit_count SimpleAggregateFunction(sum, Int64),
+ cancel_path_visit_count SimpleAggregateFunction(sum, Int64),
+ refund_path_visit_count SimpleAggregateFunction(sum, Int64),
+ console_error_count SimpleAggregateFunction(sum, Int64),
+ console_error_after_click_count SimpleAggregateFunction(sum, Int64),
+ console_warn_count SimpleAggregateFunction(sum, Int64),
+ network_request_count SimpleAggregateFunction(sum, Int64),
+ network_failed_request_count SimpleAggregateFunction(sum, Int64),
+ network_4xx_count SimpleAggregateFunction(sum, Int64),
+ network_5xx_count SimpleAggregateFunction(sum, Int64),
+ network_request_duration_sum SimpleAggregateFunction(sum, Float64),
+ network_request_duration_sum_of_squares SimpleAggregateFunction(sum, Float64),
+ network_request_duration_count SimpleAggregateFunction(sum, Int64),
+ mutation_count SimpleAggregateFunction(sum, Int64),
+ viewport_resize_count SimpleAggregateFunction(sum, Int64),
+ touch_event_count SimpleAggregateFunction(sum, Int64),
+ max_scroll_y SimpleAggregateFunction(max, Float64),
+ unique_click_target_count AggregateFunction(uniqCombined(12), Int64),
+ unique_form_field_count AggregateFunction(uniqCombined(12), Int64),
+ text_selection_count SimpleAggregateFunction(sum, Int64),
+ selection_copy_count SimpleAggregateFunction(sum, Int64),
+ is_deleted SimpleAggregateFunction(max, UInt8) DEFAULT 0
+) ENGINE = ReplicatedAggregatingMergeTree('/clickhouse/tables/{shard}/posthog.session_replay_features', '{replica}') ORDER BY (team_id, session_id) PARTITION BY toYYYYMM(min_first_timestamp) SETTINGS index_granularity = 512;
+CREATE TABLE posthog.sharded_usage_report_events_preagg (
+ date Date,
+ team_id Int64,
+ person_mode LowCardinality(String),
+ lib LowCardinality(String),
+ event String,
+ distinct_events_unique AggregateFunction(uniqExact, Tuple(UInt64, UInt64, UInt64)),
+ event_count AggregateFunction(sum, UInt64)
+) ENGINE = ReplicatedAggregatingMergeTree('/clickhouse/tables/{shard}/posthog.sharded_usage_report_events_preagg', '{replica}') ORDER BY (date, team_id, person_mode, lib, event) PARTITION BY date TTL date + toIntervalDay(14) SETTINGS index_granularity = 8192, ttl_only_drop_parts = 1;
+CREATE TABLE posthog.sharded_web_bot_definition (
+ id UInt64,
+ parent_id UInt64,
+ regexp String,
+ keys Array(String),
+ values Array(String)
+) ENGINE = ReplicatedMergeTree('/clickhouse/tables/{shard}/posthog.sharded_web_bot_definition', '{replica}') ORDER BY (id) SETTINGS index_granularity = 8192;
+CREATE TABLE posthog.sharded_web_bounces_dimensional_preaggregated (
+ team_id Int64,
+ job_id UUID,
+ period_bucket DateTime,
+ host String,
+ device_type String,
+ entry_pathname String,
+ end_pathname String,
+ browser String,
+ os String,
+ viewport_width Int64,
+ viewport_height Int64,
+ referring_domain String,
+ utm_source String,
+ utm_medium String,
+ utm_campaign String,
+ utm_term String,
+ utm_content String,
+ country_code String,
+ city_name String,
+ region_code String,
+ region_name String,
+ has_gclid Bool,
+ has_gad_source_paid_search Bool,
+ has_fbclid Bool,
+ mat_metadata_backend Nullable(String),
+ mat_metadata_loggedIn Nullable(Bool),
+ persons_uniq_state AggregateFunction(uniq, UUID),
+ sessions_uniq_state AggregateFunction(uniq, String),
+ pageviews_count_state AggregateFunction(sum, Int64),
+ bounces_count_state AggregateFunction(sum, Int64),
+ total_session_duration_state AggregateFunction(sum, Int64),
+ total_session_count_state AggregateFunction(sum, Int64),
+ computed_at DateTime64(6, 'UTC') DEFAULT now(),
+ expires_at DateTime64(6, 'UTC') DEFAULT now() + toIntervalDay(7)
+) ENGINE = ReplicatedReplacingMergeTree('/clickhouse/tables/{shard}/posthog.web_bounces_dimensional_preaggregated', '{replica}', computed_at) ORDER BY (team_id, job_id, period_bucket, host, device_type, entry_pathname, end_pathname, browser, os, viewport_width, viewport_height, referring_domain, utm_source, utm_medium, utm_campaign, utm_term, utm_content, country_code, city_name, region_code, region_name, has_gclid, has_gad_source_paid_search, has_fbclid, mat_metadata_backend, mat_metadata_loggedIn) PARTITION BY toYYYYMMDD(expires_at) TTL toDateTime(expires_at) SETTINGS allow_nullable_key = 1, index_granularity = 8192, ttl_only_drop_parts = 1;
+CREATE TABLE posthog.sharded_web_goals_preaggregated (
+ team_id Int64,
+ job_id UUID,
+ time_window_start DateTime64(6, 'UTC'),
+ action_id Int64,
+ count_state AggregateFunction(sum, Int64),
+ unique_persons_state AggregateFunction(uniq, UUID),
+ computed_at DateTime64(6, 'UTC') DEFAULT now(),
+ expires_at DateTime64(6, 'UTC') DEFAULT now() + toIntervalDay(7)
+) ENGINE = ReplicatedReplacingMergeTree('/clickhouse/tables/{shard}/posthog.web_goals_preaggregated', '{replica}', computed_at) ORDER BY (team_id, job_id, action_id, time_window_start) PARTITION BY toYYYYMMDD(expires_at) TTL toDateTime(expires_at) SETTINGS index_granularity = 8192, ttl_only_drop_parts = 1;
+CREATE TABLE posthog.sharded_web_overview_preaggregated (
+ team_id Int64,
+ job_id UUID,
+ time_window_start DateTime64(6, 'UTC'),
+ uniq_users_state AggregateFunction(uniq, UUID),
+ uniq_sessions_state AggregateFunction(uniq, String),
+ sum_pageviews_state AggregateFunction(sum, Int64),
+ avg_duration_state AggregateFunction(avg, Float64),
+ avg_bounce_state AggregateFunction(avg, Int64),
+ computed_at DateTime64(6, 'UTC') DEFAULT now(),
+ expires_at DateTime64(6, 'UTC') DEFAULT now() + toIntervalDay(7)
+) ENGINE = ReplicatedReplacingMergeTree('/clickhouse/tables/{shard}/posthog.web_overview_preaggregated', '{replica}', computed_at) ORDER BY (team_id, job_id, time_window_start) PARTITION BY toYYYYMMDD(expires_at) TTL toDateTime(expires_at) SETTINGS index_granularity = 8192, ttl_only_drop_parts = 1;
+CREATE TABLE posthog.sharded_web_stats_dimensional_preaggregated (
+ team_id Int64,
+ job_id UUID,
+ period_bucket DateTime,
+ host String,
+ device_type String,
+ pathname String,
+ entry_pathname String,
+ end_pathname String,
+ browser String,
+ os String,
+ viewport_width Int64,
+ viewport_height Int64,
+ referring_domain String,
+ utm_source String,
+ utm_medium String,
+ utm_campaign String,
+ utm_term String,
+ utm_content String,
+ country_code String,
+ city_name String,
+ region_code String,
+ region_name String,
+ has_gclid Bool,
+ has_gad_source_paid_search Bool,
+ has_fbclid Bool,
+ mat_metadata_backend Nullable(String),
+ mat_metadata_loggedIn Nullable(Bool),
+ persons_uniq_state AggregateFunction(uniq, UUID),
+ sessions_uniq_state AggregateFunction(uniq, String),
+ pageviews_count_state AggregateFunction(sum, Int64),
+ computed_at DateTime64(6, 'UTC') DEFAULT now(),
+ expires_at DateTime64(6, 'UTC') DEFAULT now() + toIntervalDay(7)
+) ENGINE = ReplicatedReplacingMergeTree('/clickhouse/tables/{shard}/posthog.web_stats_dimensional_preaggregated', '{replica}', computed_at) ORDER BY (team_id, job_id, period_bucket, host, device_type, pathname, entry_pathname, end_pathname, browser, os, viewport_width, viewport_height, referring_domain, utm_source, utm_medium, utm_campaign, utm_term, utm_content, country_code, city_name, region_code, region_name, has_gclid, has_gad_source_paid_search, has_fbclid, mat_metadata_backend, mat_metadata_loggedIn) PARTITION BY toYYYYMMDD(expires_at) TTL toDateTime(expires_at) SETTINGS allow_nullable_key = 1, index_granularity = 8192, ttl_only_drop_parts = 1;
+CREATE TABLE posthog.sharded_web_stats_frustration_preaggregated (
+ team_id Int64,
+ job_id UUID,
+ time_window_start DateTime64(6, 'UTC'),
+ breakdown_value String,
+ sum_rage_clicks_state AggregateFunction(sum, Int64),
+ sum_dead_clicks_state AggregateFunction(sum, Int64),
+ sum_errors_state AggregateFunction(sum, Int64),
+ computed_at DateTime64(6, 'UTC') DEFAULT now(),
+ expires_at DateTime64(6, 'UTC') DEFAULT now() + toIntervalDay(7)
+) ENGINE = ReplicatedReplacingMergeTree('/clickhouse/tables/{shard}/posthog.web_stats_frustration_preaggregated', '{replica}', computed_at) ORDER BY (team_id, job_id, breakdown_value, time_window_start) PARTITION BY toYYYYMMDD(expires_at) TTL toDateTime(expires_at) SETTINGS index_granularity = 8192, ttl_only_drop_parts = 1;
+CREATE TABLE posthog.sharded_web_stats_paths_preaggregated (
+ team_id Int64,
+ job_id UUID,
+ time_window_start DateTime64(6, 'UTC'),
+ breakdown_value String,
+ uniq_users_state AggregateFunction(uniq, UUID),
+ sum_pageviews_state AggregateFunction(sum, Int64),
+ avg_bounce_state AggregateFunction(avg, Nullable(Float64)),
+ computed_at DateTime64(6, 'UTC') DEFAULT now(),
+ expires_at DateTime64(6, 'UTC') DEFAULT now() + toIntervalDay(7)
+) ENGINE = ReplicatedReplacingMergeTree('/clickhouse/tables/{shard}/posthog.web_stats_paths_preaggregated', '{replica}', computed_at) ORDER BY (team_id, job_id, breakdown_value, time_window_start) PARTITION BY toYYYYMMDD(expires_at) TTL toDateTime(expires_at) SETTINGS index_granularity = 8192, ttl_only_drop_parts = 1;
+CREATE TABLE posthog.sharded_web_stats_paths_preaggregated_pathkey (
+ team_id Int64,
+ job_id UUID,
+ time_window_start DateTime64(6, 'UTC'),
+ breakdown_value String,
+ uniq_users_state AggregateFunction(uniq, UUID),
+ sum_pageviews_state AggregateFunction(sum, Int64),
+ avg_bounce_state AggregateFunction(avg, Nullable(Float64)),
+ computed_at DateTime64(6, 'UTC') DEFAULT now(),
+ expires_at DateTime64(6, 'UTC') DEFAULT now() + toIntervalDay(7)
+) ENGINE = ReplicatedReplacingMergeTree('/clickhouse/tables/{shard}/posthog.web_stats_paths_preaggregated_pathkey', '{replica}', computed_at) ORDER BY (team_id, time_window_start, breakdown_value, job_id) PARTITION BY toYYYYMMDD(expires_at) TTL toDateTime(expires_at) SETTINGS index_granularity = 8192, ttl_only_drop_parts = 1;
+CREATE TABLE posthog.sharded_web_stats_preaggregated (
+ team_id Int64,
+ job_id UUID,
+ time_window_start DateTime64(6, 'UTC'),
+ breakdown_by String,
+ breakdown_value String,
+ uniq_users_state AggregateFunction(uniq, UUID),
+ sum_pageviews_state AggregateFunction(sum, Int64),
+ computed_at DateTime64(6, 'UTC') DEFAULT now(),
+ expires_at DateTime64(6, 'UTC') DEFAULT now() + toIntervalDay(7)
+) ENGINE = ReplicatedReplacingMergeTree('/clickhouse/tables/{shard}/posthog.web_stats_preaggregated', '{replica}', computed_at) ORDER BY (team_id, job_id, breakdown_by, time_window_start, breakdown_value) PARTITION BY toYYYYMMDD(expires_at) TTL toDateTime(expires_at) SETTINGS index_granularity = 8192, ttl_only_drop_parts = 1;
+CREATE TABLE posthog.sharded_web_vitals_paths_preaggregated (
+ team_id Int64,
+ job_id UUID,
+ time_window_start DateTime64(6, 'UTC'),
+ path String,
+ inp_quantiles_state AggregateFunction(quantiles(0.75, 0.9, 0.99), Float64),
+ lcp_quantiles_state AggregateFunction(quantiles(0.75, 0.9, 0.99), Float64),
+ cls_quantiles_state AggregateFunction(quantiles(0.75, 0.9, 0.99), Float64),
+ fcp_quantiles_state AggregateFunction(quantiles(0.75, 0.9, 0.99), Float64),
+ computed_at DateTime64(6, 'UTC') DEFAULT now(),
+ expires_at DateTime64(6, 'UTC') DEFAULT now() + toIntervalDay(7)
+) ENGINE = ReplicatedReplacingMergeTree('/clickhouse/tables/{shard}/posthog.web_vitals_paths_preaggregated', '{replica}', computed_at) ORDER BY (team_id, job_id, time_window_start, path) PARTITION BY toYYYYMMDD(expires_at) TTL toDateTime(expires_at) SETTINGS index_granularity = 8192, ttl_only_drop_parts = 1;
+CREATE TABLE posthog.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_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_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_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.writable_query_log_archive (
+ hostname LowCardinality(String),
+ user LowCardinality(String),
+ query_id String,
+ initial_query_id String,
+ is_initial_query UInt8,
+ type Enum8('QueryStart'=1, 'QueryFinish'=2, 'ExceptionBeforeStart'=3, 'ExceptionWhileProcessing'=4),
+ event_date Date,
+ event_time DateTime,
+ event_time_microseconds DateTime64(6),
+ query_start_time DateTime,
+ query_start_time_microseconds DateTime64(6),
+ query_duration_ms UInt64,
+ read_rows UInt64,
+ read_bytes UInt64,
+ written_rows UInt64,
+ written_bytes UInt64,
+ result_rows UInt64,
+ result_bytes UInt64,
+ memory_usage UInt64,
+ peak_threads_usage UInt64,
+ current_database LowCardinality(String),
+ query String,
+ formatted_query String,
+ normalized_query_hash UInt64,
+ query_kind LowCardinality(String),
+ exception_code Int32,
+ exception String,
+ stack_trace String,
+ team_id Int64,
+ log_comment JSON(max_dynamic_paths=256, access_method LowCardinality(String), alert_config_id String, api_key_label String, api_key_mask String, batch_export_id String, chargeable Bool, client_query_id String, cohort_id Int64, `dagster.job_name` String, `dagster.run_id` String, `dagster.tags.owner` String, dashboard_id Int64, experiment_feature_flag_key String, experiment_id Int64, feature LowCardinality(String), id String, insight_id Int64, is_impersonated Bool, kind LowCardinality(String), name String, org_id String, person_on_events_mode LowCardinality(String), product LowCardinality(String), query_type LowCardinality(String), request_name String, route_id String, service_name String, session_id String, table_id String, team_id Int64, `temporal.activity_id` String, `temporal.activity_type` String, `temporal.attempt` Int64, `temporal.workflow_id` String, `temporal.workflow_namespace` String, `temporal.workflow_run_id` String, `temporal.workflow_type` String, user_id Int64, warehouse_query Bool, workflow LowCardinality(String), workload LowCardinality(String), SKIP cache_key, SKIP filter, SKIP hogql_features, SKIP http_referer, SKIP http_request_id, SKIP http_user_agent, SKIP query_settings, SKIP timings, SKIP user_email),
+ ProfileEvents Map(String, UInt64)
+) ENGINE = Distributed('ops', 'posthog', 'query_log_archive_buffer');
+CREATE MATERIALIZED VIEW posthog.hog_invocation_results_mv TO posthog.hog_invocation_results_data (team_id Int64, function_kind LowCardinality(String), function_id String, invocation_id String, parent_run_id String, status LowCardinality(String), attempts UInt8, is_retry UInt8, scheduled_at DateTime64(6, 'UTC'), first_scheduled_at DateTime64(6, 'UTC'), started_at Nullable(DateTime64(6, 'UTC')), finished_at Nullable(DateTime64(6, 'UTC')), duration_ms Nullable(UInt32), error_kind LowCardinality(String), error_message String, event_uuid String, distinct_id String, person_id String, invocation_globals String, version UInt64, is_deleted UInt8, _timestamp Nullable(DateTime), _offset UInt64, _partition UInt64) AS SELECT
+ team_id,
+ function_kind,
+ function_id,
+ invocation_id,
+ parent_run_id,
+ status,
+ attempts,
+ is_retry,
+ scheduled_at,
+ if(
+ first_scheduled_at = toDateTime64('1970-01-01 00:00:00', 6, 'UTC'),
+ scheduled_at,
+ first_scheduled_at
+ ) AS first_scheduled_at,
+ started_at,
+ finished_at,
+ duration_ms,
+ error_kind,
+ error_message,
+ event_uuid,
+ distinct_id,
+ person_id,
+ invocation_globals,
+ version,
+ is_deleted,
+ _timestamp,
+ _offset,
+ _partition
+FROM posthog.kafka_hog_invocation_results;
+CREATE MATERIALIZED VIEW posthog.message_assets_mv TO posthog.message_assets_data (team_id Int64, function_kind LowCardinality(String), function_id String, parent_run_id String, invocation_id String, action_id String, kind LowCardinality(String), distinct_id String, person_id String, recipient String, subject String, status LowCardinality(String), sent_at DateTime64(6, 'UTC'), version UInt64, is_deleted UInt8, html String, _timestamp Nullable(DateTime), _offset UInt64, _partition UInt64) AS SELECT
+ team_id,
+ function_kind,
+ function_id,
+ parent_run_id,
+ invocation_id,
+ action_id,
+ kind,
+ distinct_id,
+ person_id,
+ recipient,
+ subject,
+ status,
+ sent_at,
+ version,
+ is_deleted,
+ html,
+ _timestamp,
+ _offset,
+ _partition
+FROM posthog.kafka_message_assets;
+CREATE MATERIALIZED VIEW posthog.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.property_values_mv TO posthog.property_values (team_id Int64, property_type LowCardinality(String), property_key String, property_value String, property_count UInt64, last_seen DateTime) AS SELECT
+ team_id,
+ property_type,
+ property_key,
+ property_value,
+ property_count,
+ coalesce(_timestamp, now()) AS last_seen
+FROM posthog.kafka_property_values;
+CREATE 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 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 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.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.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.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.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.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));
diff --git a/posthog/clickhouse/hcl/sql/prod-eu-sessions.sql b/posthog/clickhouse/hcl/sql/prod-eu-sessions.sql
new file mode 100644
index 000000000000..5d3a586c2097
--- /dev/null
+++ b/posthog/clickhouse/hcl/sql/prod-eu-sessions.sql
@@ -0,0 +1,837 @@
+-- AUTO-GENERATED from the declarative HCL by ops/gen-sql.sh — do not edit.
+-- Full CREATE schema for the prod-eu/sessions node. Apply to a fresh ClickHouse to build it.
+
+CREATE TABLE posthog.channel_definition (
+ domain String,
+ kind String,
+ domain_type Nullable(String),
+ type_if_paid Nullable(String),
+ type_if_organic Nullable(String)
+) ENGINE = Distributed('posthog_single_shard', 'posthog', 'channel_definition');
+CREATE TABLE posthog.cohortpeople (
+ person_id UUID,
+ cohort_id Int64,
+ team_id Int64,
+ sign Int8,
+ version UInt64
+) ENGINE = Distributed('posthog_single_shard', 'posthog', 'cohortpeople', rand());
+CREATE TABLE posthog.events (
+ uuid UUID,
+ event String,
+ properties String,
+ timestamp DateTime64(6, 'UTC'),
+ team_id Int64,
+ distinct_id String,
+ elements_hash String,
+ created_at DateTime64(6, 'UTC'),
+ _timestamp DateTime,
+ _offset UInt64,
+ elements_chain String,
+ mat_$user_id String COMMENT 'column_materializer::$user_id',
+ mat_$browser String COMMENT 'column_materializer::$browser',
+ mat_$host String COMMENT 'column_materializer::$host',
+ mat_$current_url String COMMENT 'column_materializer::$current_url',
+ mat_distinct_id String COMMENT 'column_materializer::distinct_id',
+ mat_action String COMMENT 'column_materializer::action',
+ mat_origin String COMMENT 'column_materializer::origin',
+ mat_email String COMMENT 'column_materializer::email',
+ mat_key String COMMENT 'column_materializer::key',
+ mat_insight String COMMENT 'column_materializer::insight',
+ mat_$event_type String COMMENT 'column_materializer::$event_type',
+ mat_created_by String COMMENT 'column_materializer::created_by',
+ mat_total_event_actions_count String COMMENT 'column_materializer::total_event_actions_count',
+ mat_is_demo_project String COMMENT 'column_materializer::is_demo_project',
+ mat_$active_feature_flags String COMMENT 'column_materializer::$active_feature_flags',
+ mat_filters_count String COMMENT 'column_materializer::filters_count',
+ mat_utm_source String COMMENT 'column_materializer::utm_source',
+ mat_apiErrorMessage String COMMENT 'column_materializer::apiErrorMessage',
+ mat_$referring_domain String COMMENT 'column_materializer::$referring_domain',
+ mat_statusCode String COMMENT 'column_materializer::statusCode',
+ mat_deal_id String COMMENT 'column_materializer::deal_id',
+ mat_realm String COMMENT 'column_materializer::realm',
+ $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',
+ mat_$lib String COMMENT 'column_materializer::$lib',
+ mat_$os String COMMENT 'column_materializer::$os',
+ mat_$initial_referrer String COMMENT 'column_materializer::$initial_referrer',
+ mat_$app_version String COMMENT 'column_materializer::$app_version',
+ mat_$initial_referring_domain String COMMENT 'column_materializer::$initial_referring_domain',
+ mat_symbol String COMMENT 'column_materializer::symbol',
+ mat_page String COMMENT 'column_materializer::page',
+ mat_type String COMMENT 'column_materializer::type',
+ mat_currentScreen String COMMENT 'column_materializer::currentScreen',
+ mat_utm_campaign String COMMENT 'column_materializer::utm_campaign',
+ mat_is_organization_first_user String COMMENT 'column_materializer::is_organization_first_user',
+ mat_is_first_component_load String COMMENT 'column_materializer::is_first_component_load',
+ mat_team String COMMENT 'column_materializer::team',
+ mat_context String COMMENT 'column_materializer::context',
+ mat_sdk String COMMENT 'column_materializer::sdk',
+ mat_created_by_system String COMMENT 'column_materializer::created_by_system',
+ mat_item_count String COMMENT 'column_materializer::item_count',
+ mat_$ip String COMMENT 'column_materializer::$ip',
+ mat_$referrer String COMMENT 'column_materializer::$referrer',
+ mat_action_name String COMMENT 'column_materializer::action_name',
+ mat_$geoip_country_name String COMMENT 'column_materializer::$geoip_country_name',
+ mat_$device_model String COMMENT 'column_materializer::$device_model',
+ mat_progress String COMMENT 'column_materializer::progress',
+ mat_chain String COMMENT 'column_materializer::chain',
+ mat_$device_type String COMMENT 'column_materializer::$device_type',
+ mat_usd String COMMENT 'column_materializer::usd',
+ mat_app_name String COMMENT 'column_materializer::app_name',
+ mat_$screen_name String COMMENT 'column_materializer::$screen_name',
+ mat_index String COMMENT 'column_materializer::index',
+ mat_token String COMMENT 'column_materializer::token',
+ mat_method String COMMENT 'column_materializer::method',
+ mat_address String COMMENT 'column_materializer::address',
+ mat_name String COMMENT 'column_materializer::name',
+ mat_inviteCode String COMMENT 'column_materializer::inviteCode',
+ $window_id String COMMENT 'column_materializer::$window_id',
+ $session_id String COMMENT 'column_materializer::$session_id',
+ mat_osName String COMMENT 'column_materializer::osName',
+ mat_nativeBuildVersion String COMMENT 'column_materializer::nativeBuildVersion',
+ mat_revenue String COMMENT 'column_materializer::revenue',
+ group_0 String ALIAS `$group_0`,
+ group_1 String ALIAS `$group_1`,
+ group_2 String ALIAS `$group_2`,
+ group_3 String ALIAS `$group_3`,
+ group_4 String ALIAS `$group_4`,
+ alias_mat__user_id String ALIAS `mat_$user_id`,
+ alias_mat__browser String ALIAS `mat_$browser`,
+ alias_mat__host String ALIAS `mat_$host`,
+ alias_mat__current_url String ALIAS `mat_$current_url`,
+ alias_mat__event_type String ALIAS `mat_$event_type`,
+ alias_mat__active_feature_flags String ALIAS `mat_$active_feature_flags`,
+ alias_mat__referring_domain String ALIAS `mat_$referring_domain`,
+ alias_mat__lib String ALIAS `mat_$lib`,
+ alias_mat__os String ALIAS `mat_$os`,
+ alias_mat__initial_referrer String ALIAS `mat_$initial_referrer`,
+ alias_mat__app_version String ALIAS `mat_$app_version`,
+ alias_mat__initial_referring_domain String ALIAS `mat_$initial_referring_domain`,
+ alias_mat__ip String ALIAS `mat_$ip`,
+ alias_mat__referrer String ALIAS `mat_$referrer`,
+ alias_mat__geoip_country_name String ALIAS `mat_$geoip_country_name`,
+ alias_mat__device_model String ALIAS `mat_$device_model`,
+ alias_mat__device_type String ALIAS `mat_$device_type`,
+ alias_mat__screen_name String ALIAS `mat_$screen_name`,
+ person_id UUID,
+ person_properties String,
+ group0_properties String,
+ group1_properties String,
+ group2_properties String,
+ group3_properties String,
+ group4_properties String,
+ person_created_at DateTime64(3),
+ group0_created_at DateTime64(3),
+ group1_created_at DateTime64(3),
+ group2_created_at DateTime64(3),
+ group3_created_at DateTime64(3),
+ group4_created_at DateTime64(3),
+ mat_arguments String COMMENT 'column_materializer::properties::arguments',
+ mat_source String COMMENT 'column_materializer::properties::source',
+ mat_pp_email String COMMENT 'column_materializer::person_properties::email',
+ mat_$time String COMMENT 'column_materializer::properties::$time',
+ mat_$pathname String COMMENT 'column_materializer::properties::$pathname',
+ mat_$geoip_city_name String COMMENT 'column_materializer::properties::$geoip_city_name',
+ mat_community_id String COMMENT 'column_materializer::properties::community_id',
+ mat_thread_id String COMMENT 'column_materializer::properties::thread_id',
+ mat_Event_productCode String COMMENT 'column_materializer::properties::Event.productCode',
+ mat_env String COMMENT 'column_materializer::properties::env',
+ mat_target String COMMENT 'column_materializer::properties::target',
+ mat_Subscription_plan_amount String COMMENT 'column_materializer::properties::Subscription.plan.amount',
+ mat_title String COMMENT 'column_materializer::properties::title',
+ mat_Connection_app_name String COMMENT 'column_materializer::properties::Connection.app.name',
+ mat_utm_medium String COMMENT 'column_materializer::properties::utm_medium',
+ mat_Account_client_id String COMMENT 'column_materializer::properties::Account.client_id',
+ mat_HTTP_Method String COMMENT 'column_materializer::properties::HTTP Method',
+ mat_audio_duration String COMMENT 'column_materializer::properties::audio_duration',
+ mat_duration String COMMENT 'column_materializer::properties::duration',
+ mat_url String COMMENT 'column_materializer::properties::url',
+ mat_group_id String COMMENT 'column_materializer::properties::group_id',
+ mat_platform String COMMENT 'column_materializer::properties::platform',
+ mat_pp_$browser String COMMENT 'column_materializer::person_properties::$browser',
+ mat_payment_status String COMMENT 'column_materializer::properties::payment_status',
+ mat_testSessionId String COMMENT 'column_materializer::properties::testSessionId',
+ inserted_at Nullable(DateTime64(6, 'UTC')) DEFAULT now64(),
+ mat_$sent_at String COMMENT 'column_materializer::properties::$sent_at',
+ mat_pp_companyName String COMMENT 'column_materializer::person_properties::companyName',
+ mat_function String COMMENT 'column_materializer::properties::function',
+ mat_store_url String COMMENT 'column_materializer::properties::store_url',
+ mat_email_domain String COMMENT 'column_materializer::properties::email_domain',
+ mat_institution_name String COMMENT 'column_materializer::properties::institution_name',
+ mat_authentication_method String COMMENT 'column_materializer::properties::authentication_method',
+ mat_initial_step String COMMENT 'column_materializer::properties::initial_step',
+ mat_status_message String COMMENT 'column_materializer::properties::status_message',
+ mat_mode String COMMENT 'column_materializer::properties::mode',
+ mat_protocol String COMMENT 'column_materializer::properties::protocol',
+ mat_job_type String COMMENT 'column_materializer::properties::job_type',
+ mat_is_oauth String COMMENT 'column_materializer::properties::is_oauth',
+ mat_is_initial_aggregation String COMMENT 'column_materializer::properties::is_initial_aggregation',
+ mat_search_term String COMMENT 'column_materializer::properties::search_term',
+ mat_valid_ach_accounts String COMMENT 'column_materializer::properties::valid_ach_accounts',
+ mat_gross String COMMENT 'column_materializer::properties::gross',
+ mat_orderType String COMMENT 'column_materializer::properties::orderType',
+ mat_sku String COMMENT 'column_materializer::properties::sku',
+ mat_dual_channel String COMMENT 'column_materializer::properties::dual_channel',
+ mat_channel String COMMENT 'column_materializer::properties::channel',
+ mat_workspaceId String COMMENT 'column_materializer::properties::workspaceId',
+ mat_numberOfSecrets String COMMENT 'column_materializer::properties::numberOfSecrets',
+ mat_organizations String COMMENT 'column_materializer::properties::organizations',
+ mat_organization String COMMENT 'column_materializer::properties::organization',
+ mat_contributionError String COMMENT 'column_materializer::properties::contributionError',
+ mat_phone String COMMENT 'column_materializer::properties::phone',
+ mat_$initial_pathname String COMMENT 'column_materializer::properties::$initial_pathname',
+ mat_organization_name String COMMENT 'column_materializer::properties::organization_name',
+ mat_category String COMMENT 'column_materializer::properties::category',
+ mat_$lib_version String COMMENT 'column_materializer::properties::$lib_version',
+ mat_pp_$initial_utm_campaign String COMMENT 'column_materializer::person_properties::$initial_utm_campaign',
+ mat_pp_$initial_utm_medium String COMMENT 'column_materializer::person_properties::$initial_utm_medium',
+ mat_pp_$initial_gclid String COMMENT 'column_materializer::person_properties::$initial_gclid',
+ mat_pp_$initial_gad_source String COMMENT 'column_materializer::person_properties::$initial_gad_source',
+ mat_pp_$initial_utm_source String COMMENT 'column_materializer::person_properties::$initial_utm_source',
+ mat_pp_$initial_referring_domain String COMMENT 'column_materializer::person_properties::$initial_referring_domain',
+ mat_pp_$initial_utm_term String COMMENT 'column_materializer::person_properties::$initial_utm_term',
+ mat_pp_$initial_utm_content String COMMENT 'column_materializer::person_properties::$initial_utm_content',
+ mat_pp_$initial_gbraid String COMMENT 'column_materializer::person_properties::$initial_gbraid::disabled',
+ mat_pp_$initial_wbraid String COMMENT 'column_materializer::person_properties::$initial_wbraid::disabled',
+ mat_pp_$initial_msclkid String COMMENT 'column_materializer::person_properties::$initial_msclkid',
+ mat_pp_$initial_fbclid String COMMENT 'column_materializer::person_properties::$initial_fbclid',
+ mat_$geoip_subdivision_1_code String COMMENT 'column_materializer::properties::$geoip_subdivision_1_code',
+ mat_wlo_enabled String COMMENT 'column_materializer::properties::wlo_enabled',
+ mat_$prev_pageview_max_scroll_percentage String COMMENT 'column_materializer::properties::$prev_pageview_max_scroll_percentage',
+ mat_$prev_pageview_max_content_percentage String COMMENT 'column_materializer::properties::$prev_pageview_max_content_percentage',
+ mat_$prev_pageview_pathname String COMMENT 'column_materializer::properties::$prev_pageview_pathname',
+ mat_pp_$initial_pathname String COMMENT 'column_materializer::person_properties::$initial_pathname',
+ mat_pp_$geoip_country_code String COMMENT 'column_materializer::person_properties::$geoip_country_code',
+ mat_pp_username String COMMENT 'column_materializer::person_properties::username',
+ mat_pp_serverMasterclass String COMMENT 'column_materializer::person_properties::serverMasterclass',
+ mat_content_length String COMMENT 'column_materializer::properties::content_length',
+ mat_pp_serverMarketing String COMMENT 'column_materializer::person_properties::serverMarketing',
+ mat_$browser_version String COMMENT 'column_materializer::properties::$browser_version',
+ mat_pp_role String COMMENT 'column_materializer::person_properties::role',
+ mat_pp_customer String COMMENT 'column_materializer::person_properties::customer',
+ mat_event String COMMENT 'column_materializer::properties::event',
+ mat_disable_institution_search String COMMENT 'column_materializer::properties::disable_institution_search',
+ mat_is_first_event_for_user String COMMENT 'column_materializer::properties::is_first_event_for_user',
+ mat_current_member_guid String COMMENT 'column_materializer::properties::current_member_guid',
+ mat_user_agent String COMMENT 'column_materializer::properties::user_agent',
+ mat_is_test_user String COMMENT 'column_materializer::properties::is_test_user',
+ mat_referrer String COMMENT 'column_materializer::properties::referrer',
+ mat_pp_$initial_current_url String COMMENT 'column_materializer::person_properties::$initial_current_url',
+ mat_most_recent_app_os String COMMENT 'column_materializer::properties::most_recent_app_os',
+ mat_pp_hubspot_score String COMMENT 'column_materializer::person_properties::hubspot_score',
+ mat_pp_id String COMMENT 'column_materializer::person_properties::id',
+ mat_pp_$current_url String COMMENT 'column_materializer::person_properties::$current_url',
+ mat_product_key String COMMENT 'column_materializer::properties::product_key',
+ mat_Plan_type_and_filter String COMMENT 'column_materializer::properties::Plan type and filter',
+ mat_$app_namespace String COMMENT 'column_materializer::properties::$app_namespace',
+ mat_$os_name String COMMENT 'column_materializer::properties::$os_name',
+ mat_pp_$os_name String COMMENT 'column_materializer::person_properties::$os_name::disabled',
+ mat_pp_$app_version String COMMENT 'column_materializer::person_properties::$app_version',
+ mat_subscriptionStatus String COMMENT 'column_materializer::properties::subscriptionStatus',
+ mat_$screen_height String COMMENT 'column_materializer::properties::$screen_height',
+ mat_$screen_width String COMMENT 'column_materializer::properties::$screen_width',
+ mat_tag String COMMENT 'column_materializer::properties::tag',
+ mat_$app_build String COMMENT 'column_materializer::properties::$app_build',
+ mat_surface_tag String COMMENT 'column_materializer::properties::surface_tag',
+ mat_survey_responses_count_in_period String COMMENT 'column_materializer::properties::survey_responses_count_in_period',
+ mat_event_count_in_month String COMMENT 'column_materializer::properties::event_count_in_month',
+ mat_ramp String COMMENT 'column_materializer::properties::ramp',
+ mat_auto_chapters String COMMENT 'column_materializer::properties::auto_chapters',
+ mat_sentiment_analysis String COMMENT 'column_materializer::properties::sentiment_analysis',
+ mat_redact_pii String COMMENT 'column_materializer::properties::redact_pii',
+ mat_content_safety String COMMENT 'column_materializer::properties::content_safety',
+ mat_iab_categories String COMMENT 'column_materializer::properties::iab_categories',
+ mat_auto_highlights String COMMENT 'column_materializer::properties::auto_highlights',
+ mat_entity_detection String COMMENT 'column_materializer::properties::entity_detection',
+ mat_summarization String COMMENT 'column_materializer::properties::summarization',
+ mat_pp_val_region String COMMENT 'column_materializer::person_properties::val_region',
+ mat_client_id String COMMENT 'column_materializer::properties::client_id',
+ mat_$geoip_country_code String COMMENT 'column_materializer::properties::$geoip_country_code',
+ mat_disfluencies String COMMENT 'column_materializer::properties::disfluencies',
+ mat_filter_profanity String COMMENT 'column_materializer::properties::filter_profanity',
+ mat_speaker_labels String COMMENT 'column_materializer::properties::speaker_labels',
+ mat_language_detection String COMMENT 'column_materializer::properties::language_detection',
+ mat_product_analytics_projected_amount String COMMENT 'column_materializer::properties::product_analytics_projected_amount',
+ mat_recordings_projected_amount String COMMENT 'column_materializer::properties::recordings_projected_amount',
+ mat_events_projected_amount String COMMENT 'column_materializer::properties::events_projected_amount',
+ mat_session_replay_projected_amount String COMMENT 'column_materializer::properties::session_replay_projected_amount',
+ mat_total_usd String COMMENT 'column_materializer::properties::total_usd',
+ mat_stripe_amount_paid String COMMENT 'column_materializer::properties::stripe_amount_paid',
+ mat_workspace String COMMENT 'column_materializer::properties::workspace',
+ mat_created_at String COMMENT 'column_materializer::properties::created_at',
+ mat_kind String COMMENT 'column_materializer::properties::kind',
+ mat_product String COMMENT 'column_materializer::properties::product',
+ mat_message String COMMENT 'column_materializer::properties::message',
+ mat_initiator String COMMENT 'column_materializer::properties::initiator',
+ mat_query String COMMENT 'column_materializer::properties::query',
+ mat_$survey_id String COMMENT 'column_materializer::properties::$survey_id',
+ mat_$survey_response_1 String COMMENT 'column_materializer::properties::$survey_response_1',
+ mat_ticketId String COMMENT 'column_materializer::properties::ticketId',
+ mat_$survey_response String COMMENT 'column_materializer::properties::$survey_response',
+ mat_conceptName String COMMENT 'column_materializer::properties::conceptName',
+ mat_apiName String COMMENT 'column_materializer::properties::apiName',
+ mat_workplace_billing_plan String COMMENT 'column_materializer::properties::workplace_billing_plan',
+ mat_$el_text String COMMENT 'column_materializer::properties::$el_text',
+ mat_recording_count_in_period String COMMENT 'column_materializer::properties::recording_count_in_period',
+ mat_$os_version String COMMENT 'column_materializer::properties::$os_version',
+ mat_orderId String COMMENT 'column_materializer::properties::orderId',
+ mat_commit_sha String COMMENT 'column_materializer::properties::commit_sha',
+ mat_$feature_flag_payloads String COMMENT 'column_materializer::properties::$feature_flag_payloads',
+ mat_event_count_in_period String COMMENT 'column_materializer::properties::event_count_in_period',
+ mat_$groups String COMMENT 'column_materializer::properties::$groups',
+ mat_$feature_flag String COMMENT 'column_materializer::properties::$feature_flag',
+ mat_utm_content String COMMENT 'column_materializer::properties::utm_content',
+ mat_gclid String COMMENT 'column_materializer::properties::gclid',
+ mat_gad_source String COMMENT 'column_materializer::properties::gad_source',
+ mat_gbraid String COMMENT 'column_materializer::properties::gbraid',
+ mat_wbraid String COMMENT 'column_materializer::properties::wbraid',
+ mat_fbclid String COMMENT 'column_materializer::properties::fbclid',
+ mat_msclkid String COMMENT 'column_materializer::properties::msclkid',
+ mat_organization_id String COMMENT 'column_materializer::properties::organization_id',
+ mat_owner_type String COMMENT 'column_materializer::properties::owner_type',
+ mat_device_type String COMMENT 'column_materializer::properties::device_type',
+ mat_$device_id String COMMENT 'column_materializer::properties::$device_id',
+ mat_pp_$geoip_continent_name String COMMENT 'column_materializer::person_properties::$geoip_continent_name',
+ mat_$feature_flag_response String COMMENT 'column_materializer::properties::$feature_flag_response',
+ mat_pp_utm_source String COMMENT 'column_materializer::person_properties::utm_source',
+ mat_pp_$referring_domain String COMMENT 'column_materializer::person_properties::$referring_domain',
+ mat_pp_Email_Domain String COMMENT 'column_materializer::person_properties::Email Domain',
+ mat_machine_id String COMMENT 'column_materializer::properties::machine_id',
+ mat_user_email_domain String COMMENT 'column_materializer::properties::user_email_domain',
+ mat_$lib_version__minor String COMMENT 'column_materializer::properties::$lib_version__minor',
+ mat_region String COMMENT 'column_materializer::properties::region',
+ mat_pp_user_email_domain String COMMENT 'column_materializer::person_properties::user_email_domain',
+ mat_url_promotion_id String COMMENT 'column_materializer::properties::url_promotion_id',
+ mat_$lib_custom_api_host String COMMENT 'column_materializer::properties::$lib_custom_api_host',
+ person_mode Enum8('full'=0, 'propertyless'=1, 'force_upgrade'=2),
+ mat_user_platform String COMMENT 'column_materializer::properties::user_platform',
+ mat_pp_$geoip_country_name String COMMENT 'column_materializer::person_properties::$geoip_country_name',
+ mat_environment String COMMENT 'column_materializer::properties::environment',
+ mat_customer_email String COMMENT 'column_materializer::properties::customer_email',
+ mat_client_name String COMMENT 'column_materializer::properties::client_name',
+ mat_screen_name String COMMENT 'column_materializer::properties::screen_name',
+ mat_app_version String COMMENT 'column_materializer::properties::app_version',
+ elements_chain_href String COMMENT 'column_materializer::elements_chain::href',
+ elements_chain_texts Array(String) COMMENT 'column_materializer::elements_chain::texts',
+ elements_chain_ids Array(String) COMMENT 'column_materializer::elements_chain::ids',
+ elements_chain_elements Array(Enum8('a'=1, 'button'=2, 'form'=3, 'input'=4, 'select'=5, 'textarea'=6, 'label'=7)) COMMENT 'column_materializer::elements_chain::elements',
+ properties_group_custom Map(String, String),
+ properties_group_feature_flags Map(String, String),
+ is_deleted Bool,
+ mat_subdomain String COMMENT 'column_materializer::properties::subdomain',
+ mat_$device String COMMENT 'column_materializer::properties::$device',
+ mat_id String COMMENT 'column_materializer::properties::id',
+ mat_record_id String COMMENT 'column_materializer::properties::record_id',
+ mat_referrer_id String COMMENT 'column_materializer::properties::record_id',
+ mat_$exception_issue_id Nullable(String) COMMENT 'column_materializer::properties::$exception_issue_id',
+ mat_$exception_fingerprint Nullable(String) COMMENT 'column_materializer::properties::$exception_fingerprint',
+ mat_$web_vitals_LCP_value Nullable(String) COMMENT 'column_materializer::properties::$web_vitals_LCP_value',
+ mat_$web_vitals_FCP_value Nullable(String) COMMENT 'column_materializer::properties::$web_vitals_FCP_value',
+ mat_$web_vitals_CLS_value Nullable(String) COMMENT 'column_materializer::properties::$web_vitals_CLS_value',
+ mat_$web_vitals_INP_value Nullable(String) COMMENT 'column_materializer::properties::$web_vitals_INP_value',
+ mat_$viewport_width Nullable(String) COMMENT 'column_materializer::properties::$viewport_width',
+ mat_$viewport_height Nullable(String) COMMENT 'column_materializer::properties::$viewport_height',
+ mat_$anon_distinct_id Nullable(String) COMMENT 'column_materializer::properties::$anon_distinct_id',
+ person_properties_map_custom Map(String, String),
+ mat_$ai_trace_id Nullable(String) COMMENT 'column_materializer::properties::$ai_trace_id',
+ mat_$ai_model Nullable(String) COMMENT 'column_materializer::properties::$ai_model',
+ mat_$ai_provider Nullable(String) COMMENT 'column_materializer::properties::$ai_provider',
+ mat_$ai_parent_id Nullable(String) COMMENT 'column_materializer::properties::$ai_parent_id',
+ mat_$ai_span_id Nullable(String) COMMENT 'column_materializer::properties::$ai_span_id',
+ mat_$ai_http_status Nullable(String) COMMENT 'column_materializer::properties::$ai_http_status',
+ mat_$exception_types Nullable(String) COMMENT 'column_materializer::properties::$exception_types',
+ mat_$exception_values Nullable(String) COMMENT 'column_materializer::properties::$exception_values',
+ mat_$exception_sources Nullable(String) COMMENT 'column_materializer::properties::$exception_sources',
+ mat_$exception_functions Nullable(String) COMMENT 'column_materializer::properties::$exception_functions',
+ $session_id_uuid Nullable(UInt128),
+ mat_$process_person_profile Nullable(String) COMMENT 'column_materializer::properties::$process_person_profile',
+ consumer_breadcrumbs Array(String),
+ properties_group_ai Map(String, String),
+ mat_$is_identified Nullable(String) COMMENT 'column_materializer::properties::$is_identified',
+ mat_historical_migration Nullable(String) COMMENT 'column_materializer::properties::historical_migration',
+ mat_$ai_session_id Nullable(String) COMMENT 'column_materializer::properties::$ai_session_id',
+ mat_$ai_is_error Nullable(String) COMMENT 'column_materializer::properties::$ai_is_error',
+ dmat_string_0 Nullable(String),
+ dmat_string_1 Nullable(String),
+ dmat_string_2 Nullable(String),
+ dmat_string_3 Nullable(String),
+ dmat_string_4 Nullable(String),
+ dmat_string_5 Nullable(String),
+ dmat_string_6 Nullable(String),
+ dmat_string_7 Nullable(String),
+ dmat_string_8 Nullable(String),
+ dmat_string_9 Nullable(String),
+ dmat_numeric_0 Nullable(Float64),
+ dmat_numeric_1 Nullable(Float64),
+ dmat_numeric_2 Nullable(Float64),
+ dmat_numeric_3 Nullable(Float64),
+ dmat_numeric_4 Nullable(Float64),
+ dmat_numeric_5 Nullable(Float64),
+ dmat_numeric_6 Nullable(Float64),
+ dmat_numeric_7 Nullable(Float64),
+ dmat_numeric_8 Nullable(Float64),
+ dmat_numeric_9 Nullable(Float64),
+ dmat_bool_0 Nullable(UInt8),
+ dmat_bool_1 Nullable(UInt8),
+ dmat_bool_2 Nullable(UInt8),
+ dmat_bool_3 Nullable(UInt8),
+ dmat_bool_4 Nullable(UInt8),
+ dmat_bool_5 Nullable(UInt8),
+ dmat_bool_6 Nullable(UInt8),
+ dmat_bool_7 Nullable(UInt8),
+ dmat_bool_8 Nullable(UInt8),
+ dmat_bool_9 Nullable(UInt8),
+ dmat_datetime_0 Nullable(DateTime64(6, 'UTC')),
+ dmat_datetime_1 Nullable(DateTime64(6, 'UTC')),
+ dmat_datetime_2 Nullable(DateTime64(6, 'UTC')),
+ dmat_datetime_3 Nullable(DateTime64(6, 'UTC')),
+ dmat_datetime_4 Nullable(DateTime64(6, 'UTC')),
+ dmat_datetime_5 Nullable(DateTime64(6, 'UTC')),
+ dmat_datetime_6 Nullable(DateTime64(6, 'UTC')),
+ dmat_datetime_7 Nullable(DateTime64(6, 'UTC')),
+ dmat_datetime_8 Nullable(DateTime64(6, 'UTC')),
+ dmat_datetime_9 Nullable(DateTime64(6, 'UTC')),
+ historical_migration Bool,
+ mat_$ai_total_cost_usd Nullable(String) COMMENT 'column_materializer::properties::$ai_total_cost_usd',
+ properties_group_ai_large Map(String, String),
+ mat_$ai_prompt_name Nullable(String) COMMENT 'column_materializer::properties::$ai_prompt_name',
+ mat_$ai_experiment_id Nullable(String) COMMENT 'column_materializer::properties::$ai_experiment_id',
+ mat_$survey_submission_id Nullable(String) COMMENT 'column_materializer::properties::$survey_submission_id',
+ mat_$geoip_subdivision_1_name Nullable(String) COMMENT 'column_materializer::properties::$geoip_subdivision_1_name',
+ mat_$raw_user_agent Nullable(String) COMMENT 'column_materializer::properties::$raw_user_agent',
+ mat_$prev_pageview_duration Nullable(String) COMMENT 'column_materializer::properties::$prev_pageview_duration',
+ mat_pp_$initial_host Nullable(String) COMMENT 'column_materializer::person_properties::$initial_host',
+ mat_pp_$initial_url Nullable(String) COMMENT 'column_materializer::person_properties::$initial_url',
+ mat_pp_$initial_geoip_country_name Nullable(String) COMMENT 'column_materializer::person_properties::$initial_geoip_country_name'
+) ENGINE = Distributed('posthog', 'posthog', 'sharded_events', sipHash64(distinct_id));
+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
+) ENGINE = Distributed('posthog_single_shard', 'posthog', 'person_distinct_id_overrides', sipHash64(distinct_id));
+CREATE TABLE posthog.person_static_cohort (
+ id UUID,
+ person_id UUID,
+ cohort_id Int64,
+ team_id Int64,
+ _timestamp DateTime,
+ _offset UInt64
+) ENGINE = Distributed('posthog_single_shard', 'posthog', 'person_static_cohort', rand());
+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.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_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')),
+ initial__kx AggregateFunction(argMin, String, DateTime64(6, 'UTC'))
+) ENGINE = ReplicatedAggregatingMergeTree('/clickhouse/tables/sessions/noshard/posthog.raw_sessions', '{shard}-{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.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, 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
+) ENGINE = ReplicatedAggregatingMergeTree('/clickhouse/tables/sessions/noshard/posthog.raw_sessions_v3', '{shard}-{replica}') ORDER BY (team_id, session_timestamp, session_id_v7) PARTITION BY toYYYYMM(session_timestamp) SETTINGS index_granularity = 8192;
+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')),
+ event_count_map SimpleAggregateFunction(sumMap, Map(String, Int64)),
+ pageview_count SimpleAggregateFunction(sum, Int64),
+ autocapture_count SimpleAggregateFunction(sum, Int64)
+) ENGINE = ReplicatedAggregatingMergeTree('/clickhouse/tables/sessions/noshard/posthog.sessions', '{shard}-{replica}') ORDER BY (toStartOfDay(min_timestamp), team_id, session_id) PARTITION BY toYYYYMM(min_timestamp) SETTINGS index_granularity = 512;
+CREATE TABLE posthog.web_pre_aggregated_teams (
+ team_id UInt64,
+ enabled_by String DEFAULT 'system',
+ version UInt32 DEFAULT toUnixTimestamp(now())
+) ENGINE = Distributed('posthog_single_shard', 'posthog', 'web_pre_aggregated_teams');
+CREATE TABLE posthog.writable_query_log_archive (
+ hostname LowCardinality(String),
+ user LowCardinality(String),
+ query_id String,
+ initial_query_id String,
+ is_initial_query UInt8,
+ type Enum8('QueryStart'=1, 'QueryFinish'=2, 'ExceptionBeforeStart'=3, 'ExceptionWhileProcessing'=4),
+ event_date Date,
+ event_time DateTime,
+ event_time_microseconds DateTime64(6),
+ query_start_time DateTime,
+ query_start_time_microseconds DateTime64(6),
+ query_duration_ms UInt64,
+ read_rows UInt64,
+ read_bytes UInt64,
+ written_rows UInt64,
+ written_bytes UInt64,
+ result_rows UInt64,
+ result_bytes UInt64,
+ memory_usage UInt64,
+ peak_threads_usage UInt64,
+ current_database LowCardinality(String),
+ query String,
+ formatted_query String,
+ normalized_query_hash UInt64,
+ query_kind LowCardinality(String),
+ exception_code Int32,
+ exception String,
+ stack_trace String,
+ team_id Int64,
+ log_comment JSON(max_dynamic_paths=256, access_method LowCardinality(String), alert_config_id String, api_key_label String, api_key_mask String, batch_export_id String, chargeable Bool, client_query_id String, cohort_id Int64, `dagster.job_name` String, `dagster.run_id` String, `dagster.tags.owner` String, dashboard_id Int64, experiment_feature_flag_key String, experiment_id Int64, feature LowCardinality(String), id String, insight_id Int64, is_impersonated Bool, kind LowCardinality(String), name String, org_id String, person_on_events_mode LowCardinality(String), product LowCardinality(String), query_type LowCardinality(String), request_name String, route_id String, service_name String, session_id String, table_id String, team_id Int64, `temporal.activity_id` String, `temporal.activity_type` String, `temporal.attempt` Int64, `temporal.workflow_id` String, `temporal.workflow_namespace` String, `temporal.workflow_run_id` String, `temporal.workflow_type` String, user_id Int64, warehouse_query Bool, workflow LowCardinality(String), workload LowCardinality(String), SKIP cache_key, SKIP filter, SKIP hogql_features, SKIP http_referer, SKIP http_request_id, SKIP http_user_agent, SKIP query_settings, SKIP timings, SKIP user_email),
+ ProfileEvents Map(String, UInt64)
+) ENGINE = Distributed('ops', 'posthog', 'query_log_archive_buffer');
+CREATE MATERIALIZED VIEW posthog.ops_query_log_archive_mv TO posthog.writable_query_log_archive (hostname LowCardinality(String), user LowCardinality(String), query_id String, initial_query_id String, is_initial_query UInt8, type Enum8('QueryStart'=1, 'QueryFinish'=2, 'ExceptionBeforeStart'=3, 'ExceptionWhileProcessing'=4), event_date Date, event_time DateTime, event_time_microseconds DateTime64(6), query_start_time DateTime, query_start_time_microseconds DateTime64(6), query_duration_ms UInt64, read_rows UInt64, read_bytes UInt64, written_rows UInt64, written_bytes UInt64, result_rows UInt64, result_bytes UInt64, memory_usage UInt64, peak_threads_usage UInt64, current_database LowCardinality(String), query String, formatted_query String, normalized_query_hash UInt64, query_kind LowCardinality(String), exception_code Int32, exception String, stack_trace String, team_id Int64, log_comment String, ProfileEvents Map(LowCardinality(String), UInt64)) AS SELECT
+ hostname,
+ user,
+ query_id,
+ initial_query_id,
+ is_initial_query,
+ type,
+ event_date,
+ event_time,
+ event_time_microseconds,
+ query_start_time,
+ query_start_time_microseconds,
+ query_duration_ms,
+ read_rows,
+ read_bytes,
+ written_rows,
+ written_bytes,
+ result_rows,
+ result_bytes,
+ memory_usage,
+ peak_threads_usage,
+ current_database,
+ query,
+ formatted_query,
+ normalized_query_hash,
+ query_kind,
+ exception_code,
+ exception,
+ stack_trace,
+ JSONExtractInt(log_comment, 'team_id') AS team_id,
+ if(isValidJSON(log_comment), log_comment, '{}') AS log_comment,
+ ProfileEvents
+FROM system.query_log
+WHERE type != 'QueryStart';
+CREATE VIEW posthog.custom_metrics_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 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 'dict_reader' TABLE 'channel_definition')) LAYOUT(COMPLEX_KEY_HASHED()) 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 'dict_reader' QUERY 'SELECT team_id FROM `web_pre_aggregated_teams` FINAL WHERE version > 0')) LAYOUT(HASHED()) LIFETIME(MIN 3000 MAX 3600);
diff --git a/posthog/clickhouse/hcl/sql/prod-us-aux.sql b/posthog/clickhouse/hcl/sql/prod-us-aux.sql
new file mode 100644
index 000000000000..09dc62dd0d25
--- /dev/null
+++ b/posthog/clickhouse/hcl/sql/prod-us-aux.sql
@@ -0,0 +1,1168 @@
+-- AUTO-GENERATED from the declarative HCL by ops/gen-sql.sh — do not edit.
+-- Full CREATE schema for the prod-us/aux node. Apply to a fresh ClickHouse to build it.
+
+CREATE TABLE posthog.hog_invocation_results_data (
+ team_id Int64,
+ function_kind LowCardinality(String),
+ function_id String,
+ invocation_id String,
+ parent_run_id String,
+ status LowCardinality(String),
+ attempts UInt8,
+ is_retry UInt8,
+ scheduled_at DateTime64(6, 'UTC'),
+ first_scheduled_at DateTime64(6, 'UTC') DEFAULT scheduled_at,
+ started_at Nullable(DateTime64(6, 'UTC')),
+ finished_at Nullable(DateTime64(6, 'UTC')),
+ duration_ms Nullable(UInt32),
+ error_kind LowCardinality(String),
+ error_message String,
+ event_uuid String,
+ distinct_id String,
+ person_id String,
+ invocation_globals String,
+ version UInt64,
+ is_deleted UInt8 DEFAULT 0,
+ _timestamp DateTime,
+ _offset UInt64,
+ _partition UInt64,
+ INDEX status_idx status TYPE set(8) GRANULARITY 1,
+ INDEX function_idx function_id TYPE bloom_filter(0.01) GRANULARITY 1,
+ INDEX event_uuid_idx event_uuid TYPE bloom_filter(0.01) GRANULARITY 1,
+ INDEX is_retry_idx is_retry TYPE set(2) GRANULARITY 1
+) ENGINE = ReplicatedReplacingMergeTree('/clickhouse/tables/noshard/posthog.hog_invocation_results_data', '{replica}-{shard}', version) ORDER BY (team_id, function_kind, function_id, invocation_id) PARTITION BY toYYYYMMDD(scheduled_at) TTL toDate(scheduled_at) + toIntervalDay(30) SETTINGS index_granularity = 1024, storage_policy = 's3_tiered', ttl_only_drop_parts = 1;
+CREATE TABLE posthog.kafka_hog_invocation_results (
+ team_id Int64,
+ function_kind LowCardinality(String),
+ function_id String,
+ invocation_id String,
+ parent_run_id String,
+ status LowCardinality(String),
+ attempts UInt8,
+ is_retry UInt8,
+ scheduled_at DateTime64(6, 'UTC'),
+ first_scheduled_at DateTime64(6, 'UTC'),
+ started_at Nullable(DateTime64(6, 'UTC')),
+ finished_at Nullable(DateTime64(6, 'UTC')),
+ duration_ms Nullable(UInt32),
+ error_kind LowCardinality(String),
+ error_message String,
+ event_uuid String,
+ distinct_id String,
+ person_id String,
+ invocation_globals String,
+ version UInt64,
+ is_deleted UInt8
+) ENGINE = Kafka() SETTINGS kafka_broker_list = 'warpstream_cyclotron', kafka_format = 'kafka_format = \'JSONEachRow\'', kafka_group_name = 'kafka_group_name = \'clickhouse_hog_invocation_results\'', kafka_max_block_size = 100000, kafka_num_consumers = 1, kafka_poll_timeout_ms = 10000, kafka_skip_broken_messages = 100, kafka_thread_per_consumer = 1, kafka_topic_list = 'kafka_topic_list = \'clickhouse_hog_invocation_results\'';
+CREATE TABLE posthog.kafka_message_assets (
+ team_id Int64,
+ function_kind LowCardinality(String),
+ function_id String,
+ parent_run_id String,
+ invocation_id String,
+ action_id String,
+ kind LowCardinality(String),
+ distinct_id String,
+ person_id String,
+ recipient String,
+ subject String,
+ status LowCardinality(String),
+ sent_at DateTime64(6, 'UTC'),
+ version UInt64,
+ is_deleted UInt8,
+ html String
+) ENGINE = Kafka() SETTINGS kafka_broker_list = 'warpstream_cyclotron', kafka_format = 'kafka_format = \'JSONEachRow\'', kafka_group_name = 'kafka_group_name = \'clickhouse_message_assets\'', kafka_skip_broken_messages = 100, kafka_topic_list = 'kafka_topic_list = \'clickhouse_message_assets\'';
+CREATE TABLE posthog.kafka_property_values (
+ team_id Int64,
+ property_type LowCardinality(String),
+ property_key String,
+ property_value String,
+ property_count UInt64
+) ENGINE = Kafka() SETTINGS kafka_broker_list = 'warpstream_ingestion', kafka_format = 'kafka_format = \'JSONEachRow\'', kafka_group_name = 'kafka_group_name = \'clickhouse_property_values\'', kafka_num_consumers = 8, kafka_thread_per_consumer = 1, kafka_topic_list = 'kafka_topic_list = \'clickhouse_property_values\'';
+CREATE TABLE posthog.message_assets_data (
+ team_id Int64,
+ function_kind LowCardinality(String),
+ function_id String,
+ parent_run_id String,
+ invocation_id String,
+ action_id String,
+ kind LowCardinality(String),
+ distinct_id String,
+ person_id String,
+ recipient String,
+ subject String,
+ status LowCardinality(String),
+ sent_at DateTime64(6, 'UTC'),
+ version UInt64,
+ is_deleted UInt8 DEFAULT 0,
+ html String CODEC(ZSTD(3)),
+ _timestamp DateTime,
+ _offset UInt64,
+ _partition UInt64,
+ INDEX parent_run_idx parent_run_id TYPE bloom_filter(0.01) GRANULARITY 1,
+ INDEX distinct_id_idx distinct_id TYPE bloom_filter(0.01) GRANULARITY 1,
+ INDEX person_id_idx person_id TYPE bloom_filter(0.01) GRANULARITY 1,
+ INDEX recipient_idx recipient TYPE bloom_filter(0.01) GRANULARITY 1
+) ENGINE = ReplicatedReplacingMergeTree('/clickhouse/tables/noshard/posthog.message_assets_data', '{replica}-{shard}', version) ORDER BY (team_id, function_kind, function_id, invocation_id, action_id) PARTITION BY toYYYYMMDD(sent_at) TTL toDate(sent_at) + toIntervalDay(30) SETTINGS index_granularity = 1024, ttl_only_drop_parts = 1;
+CREATE TABLE posthog.property_values (
+ team_id Int64 CODEC(DoubleDelta, ZSTD(1)),
+ property_type LowCardinality(String),
+ property_key LowCardinality(String),
+ property_value String,
+ property_count SimpleAggregateFunction(sum, UInt64),
+ last_seen SimpleAggregateFunction(max, DateTime) DEFAULT now(),
+ INDEX idx_property_value_ngrambf lower(property_value) TYPE ngrambf_v1(3, 32768, 3, 0) GRANULARITY 1
+) ENGINE = ReplicatedAggregatingMergeTree('/clickhouse/tables/noshard/posthog.property_values', '{replica}-{shard}') ORDER BY (team_id, property_type, property_key, property_value) TTL last_seen + toIntervalDay(30) SETTINGS index_granularity = 8192;
+CREATE TABLE posthog.property_values_distributed (
+ team_id Int64 CODEC(DoubleDelta, ZSTD(1)),
+ property_type LowCardinality(String),
+ property_key LowCardinality(String),
+ property_value String,
+ property_count SimpleAggregateFunction(sum, UInt64),
+ last_seen SimpleAggregateFunction(max, DateTime) DEFAULT now()
+) ENGINE = Distributed('aux', 'posthog', 'property_values');
+CREATE TABLE posthog.query_log_archive (
+ 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.raw_error_tracking_fingerprint_issue_state (
+ team_id Int64,
+ fingerprint String,
+ issue_id UUID,
+ issue_name Nullable(String),
+ issue_description Nullable(String),
+ issue_status String,
+ assigned_user_id Nullable(Int64),
+ assigned_role_id Nullable(UUID),
+ first_seen DateTime64(3, 'UTC'),
+ is_deleted Int8,
+ version Int64,
+ _timestamp DateTime,
+ _offset UInt64,
+ _partition UInt64,
+ INDEX kafka_timestamp_minmax_raw_error_tracking_fingerprint_issue_state _timestamp TYPE minmax GRANULARITY 3
+) ENGINE = ReplicatedReplacingMergeTree('/clickhouse/tables/noshard/posthog.raw_error_tracking_fingerprint_issue_state', '{replica}-{shard}', version) ORDER BY (team_id, fingerprint) SETTINGS index_granularity = 512;
+CREATE TABLE posthog.sharded_conversion_goal_attributed_preaggregated (
+ team_id Int64,
+ job_id UUID,
+ person_id UUID,
+ conversion_timestamp DateTime64(6, 'UTC'),
+ conversion_value Float64,
+ touchpoint_timestamp DateTime64(6, 'UTC'),
+ touchpoint_weight Float64,
+ campaign_name String,
+ source_name String,
+ medium_name String,
+ content_name String,
+ term_name String,
+ referring_domain_name String,
+ gclid_name String,
+ fbclid_name String,
+ gad_source_name String,
+ computed_at DateTime64(6, 'UTC') DEFAULT now(),
+ expires_at Date DEFAULT today() + toIntervalDay(7)
+) ENGINE = ReplicatedReplacingMergeTree('/clickhouse/tables/noshard/posthog.conversion_goal_attributed_preaggregated', '{replica}-{shard}', computed_at) ORDER BY (team_id, job_id, person_id, conversion_timestamp, touchpoint_timestamp) PARTITION BY toYYYYMMDD(expires_at) TTL expires_at SETTINGS index_granularity = 8192, ttl_only_drop_parts = 1;
+CREATE TABLE posthog.sharded_experiment_metric_events_preaggregated (
+ team_id Int64,
+ job_id UUID,
+ entity_id String,
+ timestamp DateTime64(6, 'UTC'),
+ event_uuid UUID,
+ session_id String,
+ numeric_value Float64 DEFAULT 0,
+ steps Array(UInt8) DEFAULT [],
+ computed_at DateTime64(6, 'UTC') DEFAULT now(),
+ expires_at Date DEFAULT today() + toIntervalDay(7)
+) ENGINE = ReplicatedReplacingMergeTree('/clickhouse/tables/noshard/posthog.experiment_metric_events_preaggregated', '{replica}-{shard}', computed_at) ORDER BY (team_id, job_id, entity_id, timestamp, event_uuid) PARTITION BY toYYYYMMDD(expires_at) TTL expires_at SETTINGS index_granularity = 8192, ttl_only_drop_parts = 1;
+CREATE TABLE posthog.sharded_ingestion_warnings (
+ team_id Int64,
+ source LowCardinality(String),
+ type String,
+ details String,
+ timestamp DateTime64(6, 'UTC'),
+ _timestamp DateTime,
+ _offset UInt64,
+ _partition UInt64
+) ENGINE = ReplicatedMergeTree('/clickhouse/tables/reshard/{shard}/posthog.sharded_ingestion_warnings', '{replica}') ORDER BY (team_id, toHour(timestamp), type, source, timestamp) PARTITION BY toYear(timestamp) SETTINGS index_granularity = 8192;
+CREATE TABLE posthog.sharded_marketing_conversions_preaggregated (
+ team_id Int64,
+ job_id UUID,
+ person_id UUID,
+ conversion_timestamp DateTime64(6, 'UTC'),
+ conversion_math_value Float64,
+ session_id String,
+ campaign_name String,
+ source_name String,
+ medium_name String,
+ content_name String,
+ term_name String,
+ referring_domain_name String,
+ gclid_name String,
+ fbclid_name String,
+ gad_source_name String,
+ computed_at DateTime64(6, 'UTC') DEFAULT now(),
+ expires_at Date DEFAULT today() + toIntervalDay(7)
+) ENGINE = ReplicatedReplacingMergeTree('/clickhouse/tables/noshard/posthog.marketing_conversions_preaggregated', '{replica}-{shard}', computed_at) ORDER BY (team_id, job_id, person_id, conversion_timestamp) PARTITION BY toYYYYMMDD(expires_at) TTL expires_at SETTINGS index_granularity = 8192, ttl_only_drop_parts = 1;
+CREATE TABLE posthog.sharded_marketing_costs_preaggregated (
+ team_id Int64,
+ job_id UUID,
+ source_id String,
+ source_name String,
+ grain LowCardinality(String),
+ match_key String,
+ campaign_id String,
+ campaign_name String,
+ ad_group_id String,
+ ad_group_name String,
+ ad_id String,
+ ad_name String,
+ cost_date Date,
+ cost Float64,
+ clicks Float64,
+ impressions Float64,
+ reported_conversions Float64,
+ reported_conversion_value Float64,
+ computed_at DateTime64(6, 'UTC') DEFAULT now(),
+ expires_at Date DEFAULT today() + toIntervalDay(7)
+) ENGINE = ReplicatedReplacingMergeTree('/clickhouse/tables/noshard/posthog.marketing_costs_preaggregated', '{replica}-{shard}', computed_at) ORDER BY (team_id, job_id, source_name, grain, campaign_id, ad_group_id, ad_id, cost_date) PARTITION BY toYYYYMMDD(expires_at) TTL expires_at SETTINGS index_granularity = 8192, ttl_only_drop_parts = 1;
+CREATE TABLE posthog.sharded_marketing_touchpoints_preaggregated (
+ team_id Int64,
+ job_id UUID,
+ person_id UUID,
+ touchpoint_timestamp DateTime64(6, 'UTC'),
+ campaign_name String,
+ source_name String,
+ medium_name String,
+ content_name String,
+ term_name String,
+ referring_domain_name String,
+ gclid_name String,
+ fbclid_name String,
+ gad_source_name String,
+ computed_at DateTime64(6, 'UTC') DEFAULT now(),
+ expires_at Date DEFAULT today() + toIntervalDay(7)
+) ENGINE = ReplicatedReplacingMergeTree('/clickhouse/tables/noshard/posthog.marketing_touchpoints_preaggregated', '{replica}-{shard}', computed_at) ORDER BY (team_id, job_id, person_id, touchpoint_timestamp) PARTITION BY toYYYYMMDD(expires_at) TTL expires_at SETTINGS index_granularity = 8192, ttl_only_drop_parts = 1;
+CREATE TABLE posthog.sharded_session_replay_features (
+ session_id String,
+ team_id Int64,
+ distinct_id String,
+ min_first_timestamp SimpleAggregateFunction(min, DateTime64(6, 'UTC')),
+ max_last_timestamp SimpleAggregateFunction(max, DateTime64(6, 'UTC')),
+ event_count SimpleAggregateFunction(sum, Int64),
+ mouse_position_count SimpleAggregateFunction(sum, Int64),
+ mouse_sum_x SimpleAggregateFunction(sum, Float64),
+ mouse_sum_x_squared SimpleAggregateFunction(sum, Float64),
+ mouse_sum_y SimpleAggregateFunction(sum, Float64),
+ mouse_sum_y_squared SimpleAggregateFunction(sum, Float64),
+ mouse_distance_traveled SimpleAggregateFunction(sum, Float64),
+ mouse_direction_change_count SimpleAggregateFunction(sum, Int64),
+ mouse_velocity_sum SimpleAggregateFunction(sum, Float64),
+ mouse_velocity_sum_of_squares SimpleAggregateFunction(sum, Float64),
+ mouse_velocity_count SimpleAggregateFunction(sum, Int64),
+ scroll_event_count SimpleAggregateFunction(sum, Int64),
+ total_scroll_magnitude SimpleAggregateFunction(sum, Float64),
+ scroll_direction_reversal_count SimpleAggregateFunction(sum, Int64),
+ rapid_scroll_reversal_count SimpleAggregateFunction(sum, Int64),
+ scroll_to_top_count SimpleAggregateFunction(sum, Int64),
+ click_count SimpleAggregateFunction(sum, Int64),
+ keypress_count SimpleAggregateFunction(sum, Int64),
+ mouse_activity_count SimpleAggregateFunction(sum, Int64),
+ rage_click_count SimpleAggregateFunction(sum, Int64),
+ dead_click_count SimpleAggregateFunction(sum, Int64),
+ backspace_count SimpleAggregateFunction(sum, Int64),
+ inter_action_gap_count SimpleAggregateFunction(sum, Int64),
+ inter_action_gap_sum_ms SimpleAggregateFunction(sum, Float64),
+ inter_action_gap_sum_of_squares_ms SimpleAggregateFunction(sum, Float64),
+ max_idle_gap_ms SimpleAggregateFunction(max, Float64),
+ long_idle_gap_count SimpleAggregateFunction(sum, Int64),
+ quick_back_count SimpleAggregateFunction(sum, Int64),
+ page_visit_count SimpleAggregateFunction(sum, Int64),
+ unique_url_count AggregateFunction(uniqCombined(12), String),
+ login_path_visit_count SimpleAggregateFunction(sum, Int64),
+ signup_path_visit_count SimpleAggregateFunction(sum, Int64),
+ checkout_path_visit_count SimpleAggregateFunction(sum, Int64),
+ cart_path_visit_count SimpleAggregateFunction(sum, Int64),
+ billing_path_visit_count SimpleAggregateFunction(sum, Int64),
+ settings_path_visit_count SimpleAggregateFunction(sum, Int64),
+ account_path_visit_count SimpleAggregateFunction(sum, Int64),
+ error_path_visit_count SimpleAggregateFunction(sum, Int64),
+ not_found_path_visit_count SimpleAggregateFunction(sum, Int64),
+ admin_path_visit_count SimpleAggregateFunction(sum, Int64),
+ dashboard_path_visit_count SimpleAggregateFunction(sum, Int64),
+ onboarding_path_visit_count SimpleAggregateFunction(sum, Int64),
+ cancel_path_visit_count SimpleAggregateFunction(sum, Int64),
+ refund_path_visit_count SimpleAggregateFunction(sum, Int64),
+ console_error_count SimpleAggregateFunction(sum, Int64),
+ console_error_after_click_count SimpleAggregateFunction(sum, Int64),
+ console_warn_count SimpleAggregateFunction(sum, Int64),
+ network_request_count SimpleAggregateFunction(sum, Int64),
+ network_failed_request_count SimpleAggregateFunction(sum, Int64),
+ network_4xx_count SimpleAggregateFunction(sum, Int64),
+ network_5xx_count SimpleAggregateFunction(sum, Int64),
+ network_request_duration_sum SimpleAggregateFunction(sum, Float64),
+ network_request_duration_sum_of_squares SimpleAggregateFunction(sum, Float64),
+ network_request_duration_count SimpleAggregateFunction(sum, Int64),
+ mutation_count SimpleAggregateFunction(sum, Int64),
+ viewport_resize_count SimpleAggregateFunction(sum, Int64),
+ touch_event_count SimpleAggregateFunction(sum, Int64),
+ max_scroll_y SimpleAggregateFunction(max, Float64),
+ unique_click_target_count AggregateFunction(uniqCombined(12), Int64),
+ unique_form_field_count AggregateFunction(uniqCombined(12), Int64),
+ text_selection_count SimpleAggregateFunction(sum, Int64),
+ selection_copy_count SimpleAggregateFunction(sum, Int64),
+ is_deleted SimpleAggregateFunction(max, UInt8) DEFAULT 0
+) ENGINE = ReplicatedAggregatingMergeTree('/clickhouse/tables/{shard}/posthog.session_replay_features', '{replica}') ORDER BY (team_id, session_id) PARTITION BY toYYYYMM(min_first_timestamp) SETTINGS index_granularity = 512;
+CREATE TABLE posthog.sharded_usage_report_events_preagg (
+ date Date,
+ team_id Int64,
+ person_mode LowCardinality(String),
+ lib LowCardinality(String),
+ event String,
+ distinct_events_unique AggregateFunction(uniqExact, Tuple(UInt64, UInt64, UInt64)),
+ event_count AggregateFunction(sum, UInt64)
+) ENGINE = ReplicatedAggregatingMergeTree('/clickhouse/tables/{shard}/posthog.sharded_usage_report_events_preagg', '{replica}') ORDER BY (date, team_id, person_mode, lib, event) PARTITION BY date TTL date + toIntervalDay(14) SETTINGS index_granularity = 8192, ttl_only_drop_parts = 1;
+CREATE TABLE posthog.sharded_web_bot_definition (
+ id UInt64,
+ parent_id UInt64,
+ regexp String,
+ keys Array(String),
+ values Array(String)
+) ENGINE = ReplicatedMergeTree('/clickhouse/tables/{shard}/posthog.sharded_web_bot_definition', '{replica}') ORDER BY (id) SETTINGS index_granularity = 8192;
+CREATE TABLE posthog.sharded_web_bounces_dimensional_preaggregated (
+ team_id Int64,
+ job_id UUID,
+ period_bucket DateTime,
+ host String,
+ device_type String,
+ entry_pathname String,
+ end_pathname String,
+ browser String,
+ os String,
+ viewport_width Int64,
+ viewport_height Int64,
+ referring_domain String,
+ utm_source String,
+ utm_medium String,
+ utm_campaign String,
+ utm_term String,
+ utm_content String,
+ country_code String,
+ city_name String,
+ region_code String,
+ region_name String,
+ has_gclid Bool,
+ has_gad_source_paid_search Bool,
+ has_fbclid Bool,
+ mat_metadata_backend Nullable(String),
+ mat_metadata_loggedIn Nullable(Bool),
+ persons_uniq_state AggregateFunction(uniq, UUID),
+ sessions_uniq_state AggregateFunction(uniq, String),
+ pageviews_count_state AggregateFunction(sum, Int64),
+ bounces_count_state AggregateFunction(sum, Int64),
+ total_session_duration_state AggregateFunction(sum, Int64),
+ total_session_count_state AggregateFunction(sum, Int64),
+ computed_at DateTime64(6, 'UTC') DEFAULT now(),
+ expires_at DateTime64(6, 'UTC') DEFAULT now() + toIntervalDay(7)
+) ENGINE = ReplicatedReplacingMergeTree('/clickhouse/tables/{shard}/posthog.web_bounces_dimensional_preaggregated', '{replica}', computed_at) ORDER BY (team_id, job_id, period_bucket, host, device_type, entry_pathname, end_pathname, browser, os, viewport_width, viewport_height, referring_domain, utm_source, utm_medium, utm_campaign, utm_term, utm_content, country_code, city_name, region_code, region_name, has_gclid, has_gad_source_paid_search, has_fbclid, mat_metadata_backend, mat_metadata_loggedIn) PARTITION BY toYYYYMMDD(expires_at) TTL toDateTime(expires_at) SETTINGS allow_nullable_key = 1, index_granularity = 8192, ttl_only_drop_parts = 1;
+CREATE TABLE posthog.sharded_web_goals_preaggregated (
+ team_id Int64,
+ job_id UUID,
+ time_window_start DateTime64(6, 'UTC'),
+ action_id Int64,
+ count_state AggregateFunction(sum, Int64),
+ unique_persons_state AggregateFunction(uniq, UUID),
+ computed_at DateTime64(6, 'UTC') DEFAULT now(),
+ expires_at DateTime64(6, 'UTC') DEFAULT now() + toIntervalDay(7)
+) ENGINE = ReplicatedReplacingMergeTree('/clickhouse/tables/{shard}/posthog.web_goals_preaggregated', '{replica}', computed_at) ORDER BY (team_id, job_id, action_id, time_window_start) PARTITION BY toYYYYMMDD(expires_at) TTL toDateTime(expires_at) SETTINGS index_granularity = 8192, ttl_only_drop_parts = 1;
+CREATE TABLE posthog.sharded_web_overview_preaggregated (
+ team_id Int64,
+ job_id UUID,
+ time_window_start DateTime64(6, 'UTC'),
+ uniq_users_state AggregateFunction(uniq, UUID),
+ uniq_sessions_state AggregateFunction(uniq, String),
+ sum_pageviews_state AggregateFunction(sum, Int64),
+ avg_duration_state AggregateFunction(avg, Float64),
+ avg_bounce_state AggregateFunction(avg, Int64),
+ computed_at DateTime64(6, 'UTC') DEFAULT now(),
+ expires_at DateTime64(6, 'UTC') DEFAULT now() + toIntervalDay(7)
+) ENGINE = ReplicatedReplacingMergeTree('/clickhouse/tables/{shard}/posthog.web_overview_preaggregated', '{replica}', computed_at) ORDER BY (team_id, job_id, time_window_start) PARTITION BY toYYYYMMDD(expires_at) TTL toDateTime(expires_at) SETTINGS index_granularity = 8192, ttl_only_drop_parts = 1;
+CREATE TABLE posthog.sharded_web_stats_dimensional_preaggregated (
+ team_id Int64,
+ job_id UUID,
+ period_bucket DateTime,
+ host String,
+ device_type String,
+ pathname String,
+ entry_pathname String,
+ end_pathname String,
+ browser String,
+ os String,
+ viewport_width Int64,
+ viewport_height Int64,
+ referring_domain String,
+ utm_source String,
+ utm_medium String,
+ utm_campaign String,
+ utm_term String,
+ utm_content String,
+ country_code String,
+ city_name String,
+ region_code String,
+ region_name String,
+ has_gclid Bool,
+ has_gad_source_paid_search Bool,
+ has_fbclid Bool,
+ mat_metadata_backend Nullable(String),
+ mat_metadata_loggedIn Nullable(Bool),
+ persons_uniq_state AggregateFunction(uniq, UUID),
+ sessions_uniq_state AggregateFunction(uniq, String),
+ pageviews_count_state AggregateFunction(sum, Int64),
+ computed_at DateTime64(6, 'UTC') DEFAULT now(),
+ expires_at DateTime64(6, 'UTC') DEFAULT now() + toIntervalDay(7)
+) ENGINE = ReplicatedReplacingMergeTree('/clickhouse/tables/{shard}/posthog.web_stats_dimensional_preaggregated', '{replica}', computed_at) ORDER BY (team_id, job_id, period_bucket, host, device_type, pathname, entry_pathname, end_pathname, browser, os, viewport_width, viewport_height, referring_domain, utm_source, utm_medium, utm_campaign, utm_term, utm_content, country_code, city_name, region_code, region_name, has_gclid, has_gad_source_paid_search, has_fbclid, mat_metadata_backend, mat_metadata_loggedIn) PARTITION BY toYYYYMMDD(expires_at) TTL toDateTime(expires_at) SETTINGS allow_nullable_key = 1, index_granularity = 8192, ttl_only_drop_parts = 1;
+CREATE TABLE posthog.sharded_web_stats_frustration_preaggregated (
+ team_id Int64,
+ job_id UUID,
+ time_window_start DateTime64(6, 'UTC'),
+ breakdown_value String,
+ sum_rage_clicks_state AggregateFunction(sum, Int64),
+ sum_dead_clicks_state AggregateFunction(sum, Int64),
+ sum_errors_state AggregateFunction(sum, Int64),
+ computed_at DateTime64(6, 'UTC') DEFAULT now(),
+ expires_at DateTime64(6, 'UTC') DEFAULT now() + toIntervalDay(7)
+) ENGINE = ReplicatedReplacingMergeTree('/clickhouse/tables/{shard}/posthog.web_stats_frustration_preaggregated', '{replica}', computed_at) ORDER BY (team_id, job_id, breakdown_value, time_window_start) PARTITION BY toYYYYMMDD(expires_at) TTL toDateTime(expires_at) SETTINGS index_granularity = 8192, ttl_only_drop_parts = 1;
+CREATE TABLE posthog.sharded_web_stats_paths_preaggregated (
+ team_id Int64,
+ job_id UUID,
+ time_window_start DateTime64(6, 'UTC'),
+ breakdown_value String,
+ uniq_users_state AggregateFunction(uniq, UUID),
+ sum_pageviews_state AggregateFunction(sum, Int64),
+ avg_bounce_state AggregateFunction(avg, Nullable(Float64)),
+ computed_at DateTime64(6, 'UTC') DEFAULT now(),
+ expires_at DateTime64(6, 'UTC') DEFAULT now() + toIntervalDay(7)
+) ENGINE = ReplicatedReplacingMergeTree('/clickhouse/tables/{shard}/posthog.web_stats_paths_preaggregated', '{replica}', computed_at) ORDER BY (team_id, job_id, breakdown_value, time_window_start) PARTITION BY toYYYYMMDD(expires_at) TTL toDateTime(expires_at) SETTINGS index_granularity = 8192, ttl_only_drop_parts = 1;
+CREATE TABLE posthog.sharded_web_stats_paths_preaggregated_pathkey (
+ team_id Int64,
+ job_id UUID,
+ time_window_start DateTime64(6, 'UTC'),
+ breakdown_value String,
+ uniq_users_state AggregateFunction(uniq, UUID),
+ sum_pageviews_state AggregateFunction(sum, Int64),
+ avg_bounce_state AggregateFunction(avg, Nullable(Float64)),
+ computed_at DateTime64(6, 'UTC') DEFAULT now(),
+ expires_at DateTime64(6, 'UTC') DEFAULT now() + toIntervalDay(7)
+) ENGINE = ReplicatedReplacingMergeTree('/clickhouse/tables/{shard}/posthog.web_stats_paths_preaggregated_pathkey', '{replica}', computed_at) ORDER BY (team_id, time_window_start, breakdown_value, job_id) PARTITION BY toYYYYMMDD(expires_at) TTL toDateTime(expires_at) SETTINGS index_granularity = 8192, ttl_only_drop_parts = 1;
+CREATE TABLE posthog.sharded_web_stats_preaggregated (
+ team_id Int64,
+ job_id UUID,
+ time_window_start DateTime64(6, 'UTC'),
+ breakdown_by String,
+ breakdown_value String,
+ uniq_users_state AggregateFunction(uniq, UUID),
+ sum_pageviews_state AggregateFunction(sum, Int64),
+ computed_at DateTime64(6, 'UTC') DEFAULT now(),
+ expires_at DateTime64(6, 'UTC') DEFAULT now() + toIntervalDay(7)
+) ENGINE = ReplicatedReplacingMergeTree('/clickhouse/tables/{shard}/posthog.web_stats_preaggregated', '{replica}', computed_at) ORDER BY (team_id, job_id, breakdown_by, time_window_start, breakdown_value) PARTITION BY toYYYYMMDD(expires_at) TTL toDateTime(expires_at) SETTINGS index_granularity = 8192, ttl_only_drop_parts = 1;
+CREATE TABLE posthog.sharded_web_vitals_paths_preaggregated (
+ team_id Int64,
+ job_id UUID,
+ time_window_start DateTime64(6, 'UTC'),
+ path String,
+ inp_quantiles_state AggregateFunction(quantiles(0.75, 0.9, 0.99), Float64),
+ lcp_quantiles_state AggregateFunction(quantiles(0.75, 0.9, 0.99), Float64),
+ cls_quantiles_state AggregateFunction(quantiles(0.75, 0.9, 0.99), Float64),
+ fcp_quantiles_state AggregateFunction(quantiles(0.75, 0.9, 0.99), Float64),
+ computed_at DateTime64(6, 'UTC') DEFAULT now(),
+ expires_at DateTime64(6, 'UTC') DEFAULT now() + toIntervalDay(7)
+) ENGINE = ReplicatedReplacingMergeTree('/clickhouse/tables/{shard}/posthog.web_vitals_paths_preaggregated', '{replica}', computed_at) ORDER BY (team_id, job_id, time_window_start, path) PARTITION BY toYYYYMMDD(expires_at) TTL toDateTime(expires_at) SETTINGS index_granularity = 8192, ttl_only_drop_parts = 1;
+CREATE TABLE posthog.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_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_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_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.writable_query_log_archive (
+ hostname LowCardinality(String),
+ user LowCardinality(String),
+ query_id String,
+ initial_query_id String,
+ is_initial_query UInt8,
+ type Enum8('QueryStart'=1, 'QueryFinish'=2, 'ExceptionBeforeStart'=3, 'ExceptionWhileProcessing'=4),
+ event_date Date,
+ event_time DateTime,
+ event_time_microseconds DateTime64(6),
+ query_start_time DateTime,
+ query_start_time_microseconds DateTime64(6),
+ query_duration_ms UInt64,
+ read_rows UInt64,
+ read_bytes UInt64,
+ written_rows UInt64,
+ written_bytes UInt64,
+ result_rows UInt64,
+ result_bytes UInt64,
+ memory_usage UInt64,
+ peak_threads_usage UInt64,
+ current_database LowCardinality(String),
+ query String,
+ formatted_query String,
+ normalized_query_hash UInt64,
+ query_kind LowCardinality(String),
+ exception_code Int32,
+ exception String,
+ stack_trace String,
+ team_id Int64,
+ log_comment JSON(max_dynamic_paths=256, access_method LowCardinality(String), alert_config_id String, api_key_label String, api_key_mask String, batch_export_id String, chargeable Bool, client_query_id String, cohort_id Int64, `dagster.job_name` String, `dagster.run_id` String, `dagster.tags.owner` String, dashboard_id Int64, experiment_feature_flag_key String, experiment_id Int64, feature LowCardinality(String), id String, insight_id Int64, is_impersonated Bool, kind LowCardinality(String), name String, org_id String, person_on_events_mode LowCardinality(String), product LowCardinality(String), query_type LowCardinality(String), request_name String, route_id String, service_name String, session_id String, table_id String, team_id Int64, `temporal.activity_id` String, `temporal.activity_type` String, `temporal.attempt` Int64, `temporal.workflow_id` String, `temporal.workflow_namespace` String, `temporal.workflow_run_id` String, `temporal.workflow_type` String, user_id Int64, warehouse_query Bool, workflow LowCardinality(String), workload LowCardinality(String), SKIP cache_key, SKIP filter, SKIP hogql_features, SKIP http_referer, SKIP http_request_id, SKIP http_user_agent, SKIP query_settings, SKIP timings, SKIP user_email),
+ ProfileEvents Map(String, UInt64)
+) ENGINE = Distributed('ops', 'posthog', 'query_log_archive_buffer');
+CREATE MATERIALIZED VIEW posthog.hog_invocation_results_mv TO posthog.hog_invocation_results_data (team_id Int64, function_kind LowCardinality(String), function_id String, invocation_id String, parent_run_id String, status LowCardinality(String), attempts UInt8, is_retry UInt8, scheduled_at DateTime64(6, 'UTC'), first_scheduled_at DateTime64(6, 'UTC'), started_at Nullable(DateTime64(6, 'UTC')), finished_at Nullable(DateTime64(6, 'UTC')), duration_ms Nullable(UInt32), error_kind LowCardinality(String), error_message String, event_uuid String, distinct_id String, person_id String, invocation_globals String, version UInt64, is_deleted UInt8, _timestamp Nullable(DateTime), _offset UInt64, _partition UInt64) AS SELECT
+ team_id,
+ function_kind,
+ function_id,
+ invocation_id,
+ parent_run_id,
+ status,
+ attempts,
+ is_retry,
+ scheduled_at,
+ if(
+ first_scheduled_at = toDateTime64('1970-01-01 00:00:00', 6, 'UTC'),
+ scheduled_at,
+ first_scheduled_at
+ ) AS first_scheduled_at,
+ started_at,
+ finished_at,
+ duration_ms,
+ error_kind,
+ error_message,
+ event_uuid,
+ distinct_id,
+ person_id,
+ invocation_globals,
+ version,
+ is_deleted,
+ _timestamp,
+ _offset,
+ _partition
+FROM posthog.kafka_hog_invocation_results;
+CREATE MATERIALIZED VIEW posthog.message_assets_mv TO posthog.message_assets_data (team_id Int64, function_kind LowCardinality(String), function_id String, parent_run_id String, invocation_id String, action_id String, kind LowCardinality(String), distinct_id String, person_id String, recipient String, subject String, status LowCardinality(String), sent_at DateTime64(6, 'UTC'), version UInt64, is_deleted UInt8, html String, _timestamp Nullable(DateTime), _offset UInt64, _partition UInt64) AS SELECT
+ team_id,
+ function_kind,
+ function_id,
+ parent_run_id,
+ invocation_id,
+ action_id,
+ kind,
+ distinct_id,
+ person_id,
+ recipient,
+ subject,
+ status,
+ sent_at,
+ version,
+ is_deleted,
+ html,
+ _timestamp,
+ _offset,
+ _partition
+FROM posthog.kafka_message_assets;
+CREATE MATERIALIZED VIEW posthog.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.property_values_mv TO posthog.property_values (team_id Int64, property_type LowCardinality(String), property_key String, property_value String, property_count UInt64, last_seen DateTime) AS SELECT
+ team_id,
+ property_type,
+ property_key,
+ property_value,
+ property_count,
+ coalesce(_timestamp, now()) AS last_seen
+FROM posthog.kafka_property_values;
+CREATE 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 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 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.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.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.hog_invocation_results (
+ team_id Int64,
+ function_kind LowCardinality(String),
+ function_id String,
+ invocation_id String,
+ parent_run_id String,
+ status LowCardinality(String),
+ attempts UInt8,
+ is_retry UInt8,
+ scheduled_at DateTime64(6, 'UTC'),
+ first_scheduled_at DateTime64(6, 'UTC'),
+ started_at Nullable(DateTime64(6, 'UTC')),
+ finished_at Nullable(DateTime64(6, 'UTC')),
+ duration_ms Nullable(UInt32),
+ error_kind LowCardinality(String),
+ error_message String,
+ event_uuid String,
+ distinct_id String,
+ person_id String,
+ invocation_globals String,
+ version UInt64,
+ is_deleted UInt8,
+ _timestamp DateTime,
+ _offset UInt64,
+ _partition UInt64
+) ENGINE = Distributed('aux', 'posthog', 'hog_invocation_results_data');
+CREATE TABLE posthog.ingestion_warnings_main (
+ 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.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.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));
diff --git a/posthog/clickhouse/hcl/sql/prod-us-sessions.sql b/posthog/clickhouse/hcl/sql/prod-us-sessions.sql
new file mode 100644
index 000000000000..2a1a18be8c25
--- /dev/null
+++ b/posthog/clickhouse/hcl/sql/prod-us-sessions.sql
@@ -0,0 +1,856 @@
+-- AUTO-GENERATED from the declarative HCL by ops/gen-sql.sh — do not edit.
+-- Full CREATE schema for the prod-us/sessions node. Apply to a fresh ClickHouse to build it.
+
+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/sessions/noshard/posthog.channel_definition', '{replica}-{shard}') ORDER BY (domain, kind) SETTINGS default_compression_codec = 'lz4', index_granularity = 8192;
+CREATE TABLE posthog.cohortpeople (
+ person_id UUID,
+ cohort_id Int64,
+ team_id Int64,
+ sign Int8,
+ version UInt64
+) ENGINE = Distributed('posthog_single_shard', 'posthog', 'cohortpeople', rand());
+CREATE TABLE posthog.events (
+ uuid UUID,
+ event String,
+ properties String,
+ timestamp DateTime64(6, 'UTC'),
+ team_id Int64,
+ distinct_id String,
+ elements_hash String,
+ created_at DateTime64(6, 'UTC'),
+ _timestamp DateTime,
+ _offset UInt64,
+ elements_chain String,
+ mat_$user_id String COMMENT 'column_materializer::$user_id',
+ mat_$browser String COMMENT 'column_materializer::$browser',
+ mat_$host String COMMENT 'column_materializer::$host',
+ mat_$current_url String COMMENT 'column_materializer::$current_url',
+ mat_distinct_id String COMMENT 'column_materializer::distinct_id',
+ mat_action String COMMENT 'column_materializer::action',
+ mat_origin String COMMENT 'column_materializer::origin',
+ mat_email String COMMENT 'column_materializer::email',
+ mat_key String COMMENT 'column_materializer::key',
+ mat_insight String COMMENT 'column_materializer::insight',
+ mat_$event_type String COMMENT 'column_materializer::$event_type',
+ mat_created_by String COMMENT 'column_materializer::created_by',
+ mat_total_event_actions_count String COMMENT 'column_materializer::total_event_actions_count',
+ mat_is_demo_project String COMMENT 'column_materializer::is_demo_project',
+ mat_$active_feature_flags String COMMENT 'column_materializer::$active_feature_flags',
+ mat_filters_count String COMMENT 'column_materializer::filters_count',
+ mat_utm_source String COMMENT 'column_materializer::utm_source',
+ mat_apiErrorMessage String COMMENT 'column_materializer::apiErrorMessage',
+ mat_$referring_domain String COMMENT 'column_materializer::$referring_domain',
+ mat_statusCode String COMMENT 'column_materializer::statusCode',
+ mat_deal_id String COMMENT 'column_materializer::deal_id',
+ mat_realm String COMMENT 'column_materializer::realm',
+ $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',
+ mat_$lib String COMMENT 'column_materializer::$lib',
+ mat_$os String COMMENT 'column_materializer::$os',
+ mat_$initial_referrer String COMMENT 'column_materializer::$initial_referrer',
+ mat_$app_version String COMMENT 'column_materializer::$app_version',
+ mat_$initial_referring_domain String COMMENT 'column_materializer::$initial_referring_domain',
+ mat_symbol String COMMENT 'column_materializer::symbol',
+ mat_page String COMMENT 'column_materializer::page',
+ mat_type String COMMENT 'column_materializer::type',
+ mat_currentScreen String COMMENT 'column_materializer::currentScreen',
+ mat_utm_campaign String COMMENT 'column_materializer::utm_campaign',
+ mat_is_organization_first_user String COMMENT 'column_materializer::is_organization_first_user',
+ mat_is_first_component_load String COMMENT 'column_materializer::is_first_component_load',
+ mat_team String COMMENT 'column_materializer::team',
+ mat_context String COMMENT 'column_materializer::context',
+ mat_sdk String COMMENT 'column_materializer::sdk',
+ mat_created_by_system String COMMENT 'column_materializer::created_by_system',
+ mat_item_count String COMMENT 'column_materializer::item_count',
+ mat_$ip String COMMENT 'column_materializer::$ip',
+ mat_$referrer String COMMENT 'column_materializer::$referrer',
+ mat_action_name String COMMENT 'column_materializer::action_name',
+ mat_$geoip_country_name String COMMENT 'column_materializer::$geoip_country_name',
+ mat_$device_model String COMMENT 'column_materializer::$device_model',
+ mat_progress String COMMENT 'column_materializer::progress',
+ mat_chain String COMMENT 'column_materializer::chain',
+ mat_$device_type String COMMENT 'column_materializer::$device_type',
+ mat_usd String COMMENT 'column_materializer::usd',
+ mat_app_name String COMMENT 'column_materializer::app_name',
+ mat_$screen_name String COMMENT 'column_materializer::$screen_name',
+ mat_index String COMMENT 'column_materializer::index',
+ mat_token String COMMENT 'column_materializer::token',
+ mat_method String COMMENT 'column_materializer::method',
+ mat_address String COMMENT 'column_materializer::address',
+ mat_name String COMMENT 'column_materializer::name',
+ mat_inviteCode String COMMENT 'column_materializer::inviteCode',
+ $window_id String COMMENT 'column_materializer::$window_id',
+ $session_id String COMMENT 'column_materializer::$session_id',
+ mat_osName String COMMENT 'column_materializer::osName',
+ mat_nativeBuildVersion String COMMENT 'column_materializer::nativeBuildVersion',
+ mat_revenue String COMMENT 'column_materializer::revenue',
+ group_0 String ALIAS `$group_0`,
+ group_1 String ALIAS `$group_1`,
+ group_2 String ALIAS `$group_2`,
+ group_3 String ALIAS `$group_3`,
+ group_4 String ALIAS `$group_4`,
+ alias_mat__user_id String ALIAS `mat_$user_id`,
+ alias_mat__browser String ALIAS `mat_$browser`,
+ alias_mat__host String ALIAS `mat_$host`,
+ alias_mat__current_url String ALIAS `mat_$current_url`,
+ alias_mat__event_type String ALIAS `mat_$event_type`,
+ alias_mat__active_feature_flags String ALIAS `mat_$active_feature_flags`,
+ alias_mat__referring_domain String ALIAS `mat_$referring_domain`,
+ alias_mat__lib String ALIAS `mat_$lib`,
+ alias_mat__os String ALIAS `mat_$os`,
+ alias_mat__initial_referrer String ALIAS `mat_$initial_referrer`,
+ alias_mat__app_version String ALIAS `mat_$app_version`,
+ alias_mat__initial_referring_domain String ALIAS `mat_$initial_referring_domain`,
+ alias_mat__ip String ALIAS `mat_$ip`,
+ alias_mat__referrer String ALIAS `mat_$referrer`,
+ alias_mat__geoip_country_name String ALIAS `mat_$geoip_country_name`,
+ alias_mat__device_model String ALIAS `mat_$device_model`,
+ alias_mat__device_type String ALIAS `mat_$device_type`,
+ alias_mat__screen_name String ALIAS `mat_$screen_name`,
+ person_id UUID,
+ person_properties String,
+ group0_properties String,
+ group1_properties String,
+ group2_properties String,
+ group3_properties String,
+ group4_properties String,
+ person_created_at DateTime64(3),
+ group0_created_at DateTime64(3),
+ group1_created_at DateTime64(3),
+ group2_created_at DateTime64(3),
+ group3_created_at DateTime64(3),
+ group4_created_at DateTime64(3),
+ mat_arguments String COMMENT 'column_materializer::properties::arguments',
+ mat_source String COMMENT 'column_materializer::properties::source',
+ mat_pp_email String COMMENT 'column_materializer::person_properties::email',
+ mat_$time String COMMENT 'column_materializer::properties::$time',
+ mat_$pathname String COMMENT 'column_materializer::properties::$pathname',
+ mat_$geoip_city_name String COMMENT 'column_materializer::properties::$geoip_city_name',
+ mat_community_id String COMMENT 'column_materializer::properties::community_id',
+ mat_thread_id String COMMENT 'column_materializer::properties::thread_id',
+ mat_Event_productCode String COMMENT 'column_materializer::properties::Event.productCode',
+ mat_env String COMMENT 'column_materializer::properties::env',
+ mat_target String COMMENT 'column_materializer::properties::target',
+ mat_Subscription_plan_amount String COMMENT 'column_materializer::properties::Subscription.plan.amount',
+ mat_title String COMMENT 'column_materializer::properties::title',
+ mat_Connection_app_name String COMMENT 'column_materializer::properties::Connection.app.name',
+ mat_utm_medium String COMMENT 'column_materializer::properties::utm_medium',
+ mat_Account_client_id String COMMENT 'column_materializer::properties::Account.client_id',
+ mat_HTTP_Method String COMMENT 'column_materializer::properties::HTTP Method',
+ mat_audio_duration String COMMENT 'column_materializer::properties::audio_duration',
+ mat_duration String COMMENT 'column_materializer::properties::duration',
+ mat_url String COMMENT 'column_materializer::properties::url',
+ mat_group_id String COMMENT 'column_materializer::properties::group_id',
+ mat_platform String COMMENT 'column_materializer::properties::platform',
+ mat_pp_$browser String COMMENT 'column_materializer::person_properties::$browser',
+ mat_payment_status String COMMENT 'column_materializer::properties::payment_status',
+ mat_testSessionId String COMMENT 'column_materializer::properties::testSessionId',
+ inserted_at Nullable(DateTime64(6, 'UTC')) DEFAULT now64(),
+ mat_$sent_at String COMMENT 'column_materializer::properties::$sent_at',
+ mat_pp_companyName String COMMENT 'column_materializer::person_properties::companyName',
+ mat_function String COMMENT 'column_materializer::properties::function',
+ mat_store_url String COMMENT 'column_materializer::properties::store_url',
+ mat_email_domain String COMMENT 'column_materializer::properties::email_domain',
+ mat_institution_name String COMMENT 'column_materializer::properties::institution_name',
+ mat_authentication_method String COMMENT 'column_materializer::properties::authentication_method',
+ mat_initial_step String COMMENT 'column_materializer::properties::initial_step',
+ mat_status_message String COMMENT 'column_materializer::properties::status_message',
+ mat_mode String COMMENT 'column_materializer::properties::mode',
+ mat_protocol String COMMENT 'column_materializer::properties::protocol',
+ mat_job_type String COMMENT 'column_materializer::properties::job_type',
+ mat_is_oauth String COMMENT 'column_materializer::properties::is_oauth',
+ mat_is_initial_aggregation String COMMENT 'column_materializer::properties::is_initial_aggregation',
+ mat_search_term String COMMENT 'column_materializer::properties::search_term',
+ mat_valid_ach_accounts String COMMENT 'column_materializer::properties::valid_ach_accounts',
+ mat_gross String COMMENT 'column_materializer::properties::gross',
+ mat_orderType String COMMENT 'column_materializer::properties::orderType',
+ mat_sku String COMMENT 'column_materializer::properties::sku',
+ mat_dual_channel String COMMENT 'column_materializer::properties::dual_channel',
+ mat_channel String COMMENT 'column_materializer::properties::channel',
+ mat_workspaceId String COMMENT 'column_materializer::properties::workspaceId',
+ mat_numberOfSecrets String COMMENT 'column_materializer::properties::numberOfSecrets',
+ mat_organizations String COMMENT 'column_materializer::properties::organizations',
+ mat_organization String COMMENT 'column_materializer::properties::organization',
+ mat_contributionError String COMMENT 'column_materializer::properties::contributionError',
+ mat_phone String COMMENT 'column_materializer::properties::phone',
+ mat_$initial_pathname String COMMENT 'column_materializer::properties::$initial_pathname',
+ mat_organization_name String COMMENT 'column_materializer::properties::organization_name',
+ mat_category String COMMENT 'column_materializer::properties::category',
+ mat_$lib_version String COMMENT 'column_materializer::properties::$lib_version',
+ mat_pp_$initial_utm_campaign String COMMENT 'column_materializer::person_properties::$initial_utm_campaign',
+ mat_pp_$initial_utm_medium String COMMENT 'column_materializer::person_properties::$initial_utm_medium',
+ mat_pp_$initial_gclid String COMMENT 'column_materializer::person_properties::$initial_gclid',
+ mat_pp_$initial_gad_source String COMMENT 'column_materializer::person_properties::$initial_gad_source',
+ mat_pp_$initial_utm_source String COMMENT 'column_materializer::person_properties::$initial_utm_source',
+ mat_pp_$initial_referring_domain String COMMENT 'column_materializer::person_properties::$initial_referring_domain',
+ mat_pp_$initial_utm_term String COMMENT 'column_materializer::person_properties::$initial_utm_term',
+ mat_pp_$initial_utm_content String COMMENT 'column_materializer::person_properties::$initial_utm_content',
+ mat_pp_$initial_gbraid String COMMENT 'column_materializer::person_properties::$initial_gbraid::disabled',
+ mat_pp_$initial_wbraid String COMMENT 'column_materializer::person_properties::$initial_wbraid::disabled',
+ mat_pp_$initial_msclkid String COMMENT 'column_materializer::person_properties::$initial_msclkid',
+ mat_pp_$initial_fbclid String COMMENT 'column_materializer::person_properties::$initial_fbclid',
+ mat_$geoip_subdivision_1_code String COMMENT 'column_materializer::properties::$geoip_subdivision_1_code',
+ mat_wlo_enabled String COMMENT 'column_materializer::properties::wlo_enabled',
+ mat_$prev_pageview_max_scroll_percentage String COMMENT 'column_materializer::properties::$prev_pageview_max_scroll_percentage',
+ mat_$prev_pageview_max_content_percentage String COMMENT 'column_materializer::properties::$prev_pageview_max_content_percentage',
+ mat_$prev_pageview_pathname String COMMENT 'column_materializer::properties::$prev_pageview_pathname',
+ mat_pp_$initial_pathname String COMMENT 'column_materializer::person_properties::$initial_pathname',
+ mat_pp_$geoip_country_code String COMMENT 'column_materializer::person_properties::$geoip_country_code',
+ mat_pp_username String COMMENT 'column_materializer::person_properties::username',
+ mat_pp_serverMasterclass String COMMENT 'column_materializer::person_properties::serverMasterclass',
+ mat_content_length String COMMENT 'column_materializer::properties::content_length',
+ mat_pp_serverMarketing String COMMENT 'column_materializer::person_properties::serverMarketing',
+ mat_$browser_version String COMMENT 'column_materializer::properties::$browser_version',
+ mat_pp_role String COMMENT 'column_materializer::person_properties::role',
+ mat_pp_customer String COMMENT 'column_materializer::person_properties::customer',
+ mat_event String COMMENT 'column_materializer::properties::event',
+ mat_disable_institution_search String COMMENT 'column_materializer::properties::disable_institution_search',
+ mat_is_first_event_for_user String COMMENT 'column_materializer::properties::is_first_event_for_user',
+ mat_current_member_guid String COMMENT 'column_materializer::properties::current_member_guid',
+ mat_user_agent String COMMENT 'column_materializer::properties::user_agent',
+ mat_is_test_user String COMMENT 'column_materializer::properties::is_test_user',
+ mat_referrer String COMMENT 'column_materializer::properties::referrer',
+ mat_pp_$initial_current_url String COMMENT 'column_materializer::person_properties::$initial_current_url',
+ mat_most_recent_app_os String COMMENT 'column_materializer::properties::most_recent_app_os',
+ mat_pp_hubspot_score String COMMENT 'column_materializer::person_properties::hubspot_score',
+ mat_pp_id String COMMENT 'column_materializer::person_properties::id',
+ mat_pp_$current_url String COMMENT 'column_materializer::person_properties::$current_url',
+ mat_product_key String COMMENT 'column_materializer::properties::product_key',
+ mat_Plan_type_and_filter String COMMENT 'column_materializer::properties::Plan type and filter',
+ mat_$app_namespace String COMMENT 'column_materializer::properties::$app_namespace',
+ mat_$os_name String COMMENT 'column_materializer::properties::$os_name',
+ mat_pp_$os_name String COMMENT 'column_materializer::person_properties::$os_name::disabled',
+ mat_pp_$app_version String COMMENT 'column_materializer::person_properties::$app_version',
+ mat_subscriptionStatus String COMMENT 'column_materializer::properties::subscriptionStatus',
+ mat_$screen_height String COMMENT 'column_materializer::properties::$screen_height',
+ mat_$screen_width String COMMENT 'column_materializer::properties::$screen_width',
+ mat_tag String COMMENT 'column_materializer::properties::tag',
+ mat_$app_build String COMMENT 'column_materializer::properties::$app_build',
+ mat_surface_tag String COMMENT 'column_materializer::properties::surface_tag',
+ mat_survey_responses_count_in_period String COMMENT 'column_materializer::properties::survey_responses_count_in_period',
+ mat_event_count_in_month String COMMENT 'column_materializer::properties::event_count_in_month',
+ mat_ramp String COMMENT 'column_materializer::properties::ramp',
+ mat_auto_chapters String COMMENT 'column_materializer::properties::auto_chapters',
+ mat_sentiment_analysis String COMMENT 'column_materializer::properties::sentiment_analysis',
+ mat_redact_pii String COMMENT 'column_materializer::properties::redact_pii',
+ mat_content_safety String COMMENT 'column_materializer::properties::content_safety',
+ mat_iab_categories String COMMENT 'column_materializer::properties::iab_categories',
+ mat_auto_highlights String COMMENT 'column_materializer::properties::auto_highlights',
+ mat_entity_detection String COMMENT 'column_materializer::properties::entity_detection',
+ mat_summarization String COMMENT 'column_materializer::properties::summarization',
+ mat_pp_val_region String COMMENT 'column_materializer::person_properties::val_region',
+ mat_client_id String COMMENT 'column_materializer::properties::client_id',
+ mat_$geoip_country_code String COMMENT 'column_materializer::properties::$geoip_country_code',
+ mat_disfluencies String COMMENT 'column_materializer::properties::disfluencies',
+ mat_filter_profanity String COMMENT 'column_materializer::properties::filter_profanity',
+ mat_speaker_labels String COMMENT 'column_materializer::properties::speaker_labels',
+ mat_language_detection String COMMENT 'column_materializer::properties::language_detection',
+ mat_product_analytics_projected_amount String COMMENT 'column_materializer::properties::product_analytics_projected_amount',
+ mat_recordings_projected_amount String COMMENT 'column_materializer::properties::recordings_projected_amount',
+ mat_events_projected_amount String COMMENT 'column_materializer::properties::events_projected_amount',
+ mat_session_replay_projected_amount String COMMENT 'column_materializer::properties::session_replay_projected_amount',
+ mat_total_usd String COMMENT 'column_materializer::properties::total_usd',
+ mat_stripe_amount_paid String COMMENT 'column_materializer::properties::stripe_amount_paid',
+ mat_workspace String COMMENT 'column_materializer::properties::workspace',
+ mat_created_at String COMMENT 'column_materializer::properties::created_at',
+ mat_kind String COMMENT 'column_materializer::properties::kind',
+ mat_product String COMMENT 'column_materializer::properties::product',
+ mat_message String COMMENT 'column_materializer::properties::message',
+ mat_initiator String COMMENT 'column_materializer::properties::initiator',
+ mat_query String COMMENT 'column_materializer::properties::query',
+ mat_$survey_id String COMMENT 'column_materializer::properties::$survey_id',
+ mat_$survey_response_1 String COMMENT 'column_materializer::properties::$survey_response_1',
+ mat_ticketId String COMMENT 'column_materializer::properties::ticketId',
+ mat_$survey_response String COMMENT 'column_materializer::properties::$survey_response',
+ mat_conceptName String COMMENT 'column_materializer::properties::conceptName',
+ mat_apiName String COMMENT 'column_materializer::properties::apiName',
+ mat_workplace_billing_plan String COMMENT 'column_materializer::properties::workplace_billing_plan',
+ mat_$el_text String COMMENT 'column_materializer::properties::$el_text',
+ mat_recording_count_in_period String COMMENT 'column_materializer::properties::recording_count_in_period',
+ mat_$os_version String COMMENT 'column_materializer::properties::$os_version',
+ mat_orderId String COMMENT 'column_materializer::properties::orderId',
+ mat_commit_sha String COMMENT 'column_materializer::properties::commit_sha',
+ mat_$feature_flag_payloads String COMMENT 'column_materializer::properties::$feature_flag_payloads',
+ mat_event_count_in_period String COMMENT 'column_materializer::properties::event_count_in_period',
+ mat_$groups String COMMENT 'column_materializer::properties::$groups',
+ mat_$feature_flag String COMMENT 'column_materializer::properties::$feature_flag',
+ mat_utm_content String COMMENT 'column_materializer::properties::utm_content',
+ mat_gclid String COMMENT 'column_materializer::properties::gclid',
+ mat_gad_source String COMMENT 'column_materializer::properties::gad_source',
+ mat_gbraid String COMMENT 'column_materializer::properties::gbraid',
+ mat_wbraid String COMMENT 'column_materializer::properties::wbraid',
+ mat_fbclid String COMMENT 'column_materializer::properties::fbclid',
+ mat_msclkid String COMMENT 'column_materializer::properties::msclkid',
+ mat_organization_id String COMMENT 'column_materializer::properties::organization_id',
+ mat_owner_type String COMMENT 'column_materializer::properties::owner_type',
+ mat_device_type String COMMENT 'column_materializer::properties::device_type',
+ mat_$device_id String COMMENT 'column_materializer::properties::$device_id',
+ mat_pp_$geoip_continent_name String COMMENT 'column_materializer::person_properties::$geoip_continent_name',
+ mat_$feature_flag_response String COMMENT 'column_materializer::properties::$feature_flag_response',
+ mat_pp_utm_source String COMMENT 'column_materializer::person_properties::utm_source',
+ mat_pp_$referring_domain String COMMENT 'column_materializer::person_properties::$referring_domain',
+ mat_pp_Email_Domain String COMMENT 'column_materializer::person_properties::Email Domain',
+ mat_machine_id String COMMENT 'column_materializer::properties::machine_id',
+ mat_user_email_domain String COMMENT 'column_materializer::properties::user_email_domain',
+ mat_$lib_version__minor String COMMENT 'column_materializer::properties::$lib_version__minor',
+ mat_region String COMMENT 'column_materializer::properties::region',
+ mat_pp_user_email_domain String COMMENT 'column_materializer::person_properties::user_email_domain',
+ mat_url_promotion_id String COMMENT 'column_materializer::properties::url_promotion_id',
+ mat_$lib_custom_api_host String COMMENT 'column_materializer::properties::$lib_custom_api_host',
+ person_mode Enum8('full'=0, 'propertyless'=1, 'force_upgrade'=2),
+ mat_user_platform String COMMENT 'column_materializer::properties::user_platform',
+ mat_pp_$geoip_country_name String COMMENT 'column_materializer::person_properties::$geoip_country_name',
+ mat_environment String COMMENT 'column_materializer::properties::environment',
+ mat_customer_email String COMMENT 'column_materializer::properties::customer_email',
+ mat_client_name String COMMENT 'column_materializer::properties::client_name',
+ mat_screen_name String COMMENT 'column_materializer::properties::screen_name',
+ mat_app_version String COMMENT 'column_materializer::properties::app_version',
+ elements_chain_href String COMMENT 'column_materializer::elements_chain::href',
+ elements_chain_texts Array(String) COMMENT 'column_materializer::elements_chain::texts',
+ elements_chain_ids Array(String) COMMENT 'column_materializer::elements_chain::ids',
+ elements_chain_elements Array(Enum8('a'=1, 'button'=2, 'form'=3, 'input'=4, 'select'=5, 'textarea'=6, 'label'=7)) COMMENT 'column_materializer::elements_chain::elements',
+ properties_group_custom Map(String, String),
+ properties_group_feature_flags Map(String, String),
+ is_deleted Bool,
+ mat_subdomain String COMMENT 'column_materializer::properties::subdomain',
+ mat_$device String COMMENT 'column_materializer::properties::$device',
+ mat_id String COMMENT 'column_materializer::properties::id',
+ mat_record_id String COMMENT 'column_materializer::properties::record_id',
+ mat_referrer_id String COMMENT 'column_materializer::properties::record_id',
+ mat_$exception_issue_id Nullable(String) COMMENT 'column_materializer::properties::$exception_issue_id',
+ mat_$exception_fingerprint Nullable(String) COMMENT 'column_materializer::properties::$exception_fingerprint',
+ mat_$web_vitals_LCP_value Nullable(String) COMMENT 'column_materializer::properties::$web_vitals_LCP_value',
+ mat_$web_vitals_FCP_value Nullable(String) COMMENT 'column_materializer::properties::$web_vitals_FCP_value',
+ mat_$web_vitals_CLS_value Nullable(String) COMMENT 'column_materializer::properties::$web_vitals_CLS_value',
+ mat_$web_vitals_INP_value Nullable(String) COMMENT 'column_materializer::properties::$web_vitals_INP_value',
+ mat_$viewport_width Nullable(String) COMMENT 'column_materializer::properties::$viewport_width',
+ mat_$viewport_height Nullable(String) COMMENT 'column_materializer::properties::$viewport_height',
+ mat_$anon_distinct_id Nullable(String) COMMENT 'column_materializer::properties::$anon_distinct_id',
+ person_properties_map_custom Map(String, String),
+ mat_$ai_trace_id Nullable(String) COMMENT 'column_materializer::properties::$ai_trace_id',
+ mat_$ai_model Nullable(String) COMMENT 'column_materializer::properties::$ai_model',
+ mat_$ai_provider Nullable(String) COMMENT 'column_materializer::properties::$ai_provider',
+ mat_$ai_parent_id Nullable(String) COMMENT 'column_materializer::properties::$ai_parent_id',
+ mat_$ai_span_id Nullable(String) COMMENT 'column_materializer::properties::$ai_span_id',
+ mat_$ai_http_status Nullable(String) COMMENT 'column_materializer::properties::$ai_http_status',
+ mat_$exception_types Nullable(String) COMMENT 'column_materializer::properties::$exception_types',
+ mat_$exception_values Nullable(String) COMMENT 'column_materializer::properties::$exception_values',
+ mat_$exception_sources Nullable(String) COMMENT 'column_materializer::properties::$exception_sources',
+ mat_$exception_functions Nullable(String) COMMENT 'column_materializer::properties::$exception_functions',
+ $session_id_uuid Nullable(UInt128),
+ mat_$process_person_profile Nullable(String) COMMENT 'column_materializer::properties::$process_person_profile',
+ consumer_breadcrumbs Array(String),
+ properties_group_ai Map(String, String),
+ mat_$is_identified Nullable(String) COMMENT 'column_materializer::properties::$is_identified',
+ mat_historical_migration Nullable(String) COMMENT 'column_materializer::properties::historical_migration',
+ mat_$ai_session_id Nullable(String) COMMENT 'column_materializer::properties::$ai_session_id',
+ mat_$ai_is_error Nullable(String) COMMENT 'column_materializer::properties::$ai_is_error',
+ dmat_string_0 Nullable(String),
+ dmat_string_1 Nullable(String),
+ dmat_string_2 Nullable(String),
+ dmat_string_3 Nullable(String),
+ dmat_string_4 Nullable(String),
+ dmat_string_5 Nullable(String),
+ dmat_string_6 Nullable(String),
+ dmat_string_7 Nullable(String),
+ dmat_string_8 Nullable(String),
+ dmat_string_9 Nullable(String),
+ dmat_numeric_0 Nullable(Float64),
+ dmat_numeric_1 Nullable(Float64),
+ dmat_numeric_2 Nullable(Float64),
+ dmat_numeric_3 Nullable(Float64),
+ dmat_numeric_4 Nullable(Float64),
+ dmat_numeric_5 Nullable(Float64),
+ dmat_numeric_6 Nullable(Float64),
+ dmat_numeric_7 Nullable(Float64),
+ dmat_numeric_8 Nullable(Float64),
+ dmat_numeric_9 Nullable(Float64),
+ dmat_bool_0 Nullable(UInt8),
+ dmat_bool_1 Nullable(UInt8),
+ dmat_bool_2 Nullable(UInt8),
+ dmat_bool_3 Nullable(UInt8),
+ dmat_bool_4 Nullable(UInt8),
+ dmat_bool_5 Nullable(UInt8),
+ dmat_bool_6 Nullable(UInt8),
+ dmat_bool_7 Nullable(UInt8),
+ dmat_bool_8 Nullable(UInt8),
+ dmat_bool_9 Nullable(UInt8),
+ dmat_datetime_0 Nullable(DateTime64(6, 'UTC')),
+ dmat_datetime_1 Nullable(DateTime64(6, 'UTC')),
+ dmat_datetime_2 Nullable(DateTime64(6, 'UTC')),
+ dmat_datetime_3 Nullable(DateTime64(6, 'UTC')),
+ dmat_datetime_4 Nullable(DateTime64(6, 'UTC')),
+ dmat_datetime_5 Nullable(DateTime64(6, 'UTC')),
+ dmat_datetime_6 Nullable(DateTime64(6, 'UTC')),
+ dmat_datetime_7 Nullable(DateTime64(6, 'UTC')),
+ dmat_datetime_8 Nullable(DateTime64(6, 'UTC')),
+ dmat_datetime_9 Nullable(DateTime64(6, 'UTC')),
+ historical_migration Bool,
+ mat_$ai_total_cost_usd Nullable(String) COMMENT 'column_materializer::properties::$ai_total_cost_usd',
+ properties_group_ai_large Map(String, String),
+ mat_$ai_prompt_name Nullable(String) COMMENT 'column_materializer::properties::$ai_prompt_name'
+) ENGINE = Distributed('posthog', 'posthog', 'sharded_events', sipHash64(distinct_id));
+CREATE TABLE posthog.person_distinct_id_overrides (
+ team_id Int64,
+ distinct_id String,
+ person_id UUID,
+ is_deleted Int8,
+ version Int64,
+ _timestamp DateTime,
+ _offset UInt64,
+ _partition UInt64
+) ENGINE = Distributed('posthog_single_shard', 'posthog', 'person_distinct_id_overrides', sipHash64(distinct_id));
+CREATE TABLE posthog.person_static_cohort (
+ id UUID,
+ person_id UUID,
+ cohort_id Int64,
+ team_id Int64,
+ _timestamp DateTime,
+ _offset UInt64
+) ENGINE = Distributed('posthog_single_shard', 'posthog', 'person_static_cohort', rand());
+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.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_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')),
+ initial__kx AggregateFunction(argMin, String, DateTime64(6, 'UTC'))
+) ENGINE = ReplicatedAggregatingMergeTree('/clickhouse/tables/sessions/noshard/posthog.raw_sessions', '{shard}-{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.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, 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
+) ENGINE = ReplicatedAggregatingMergeTree('/clickhouse/tables/sessions/noshard/posthog.raw_sessions_v3', '{shard}-{replica}') ORDER BY (team_id, session_timestamp, session_id_v7) PARTITION BY toYYYYMM(session_timestamp) SETTINGS index_granularity = 8192, replicated_deduplication_window = 0, replicated_deduplication_window_for_async_inserts = 0;
+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')),
+ event_count_map SimpleAggregateFunction(sumMap, Map(String, Int64)),
+ pageview_count SimpleAggregateFunction(sum, Int64),
+ autocapture_count SimpleAggregateFunction(sum, Int64)
+) ENGINE = ReplicatedAggregatingMergeTree('/clickhouse/tables/sessions/noshard/posthog.sessions', '{shard}-{replica}') ORDER BY (toStartOfDay(min_timestamp), team_id, session_id) PARTITION BY toYYYYMM(min_timestamp) SETTINGS index_granularity = 512;
+CREATE TABLE posthog.web_pre_aggregated_teams (
+ team_id UInt64,
+ enabled_by String DEFAULT 'system',
+ version UInt32 DEFAULT toUnixTimestamp(now())
+) ENGINE = Distributed('posthog_single_shard', 'posthog', 'web_pre_aggregated_teams');
+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_query_log_archive (
+ hostname LowCardinality(String),
+ user LowCardinality(String),
+ query_id String,
+ initial_query_id String,
+ is_initial_query UInt8,
+ type Enum8('QueryStart'=1, 'QueryFinish'=2, 'ExceptionBeforeStart'=3, 'ExceptionWhileProcessing'=4),
+ event_date Date,
+ event_time DateTime,
+ event_time_microseconds DateTime64(6),
+ query_start_time DateTime,
+ query_start_time_microseconds DateTime64(6),
+ query_duration_ms UInt64,
+ read_rows UInt64,
+ read_bytes UInt64,
+ written_rows UInt64,
+ written_bytes UInt64,
+ result_rows UInt64,
+ result_bytes UInt64,
+ memory_usage UInt64,
+ peak_threads_usage UInt64,
+ current_database LowCardinality(String),
+ query String,
+ formatted_query String,
+ normalized_query_hash UInt64,
+ query_kind LowCardinality(String),
+ exception_code Int32,
+ exception String,
+ stack_trace String,
+ team_id Int64,
+ log_comment JSON(max_dynamic_paths=256, access_method LowCardinality(String), alert_config_id String, api_key_label String, api_key_mask String, batch_export_id String, chargeable Bool, client_query_id String, cohort_id Int64, `dagster.job_name` String, `dagster.run_id` String, `dagster.tags.owner` String, dashboard_id Int64, experiment_feature_flag_key String, experiment_id Int64, feature LowCardinality(String), id String, insight_id Int64, is_impersonated Bool, kind LowCardinality(String), name String, org_id String, person_on_events_mode LowCardinality(String), product LowCardinality(String), query_type LowCardinality(String), request_name String, route_id String, service_name String, session_id String, table_id String, team_id Int64, `temporal.activity_id` String, `temporal.activity_type` String, `temporal.attempt` Int64, `temporal.workflow_id` String, `temporal.workflow_namespace` String, `temporal.workflow_run_id` String, `temporal.workflow_type` String, user_id Int64, warehouse_query Bool, workflow LowCardinality(String), workload LowCardinality(String), SKIP cache_key, SKIP filter, SKIP hogql_features, SKIP http_referer, SKIP http_request_id, SKIP http_user_agent, SKIP query_settings, SKIP timings, SKIP user_email),
+ ProfileEvents Map(String, UInt64)
+) ENGINE = Distributed('ops', 'posthog', 'query_log_archive_buffer');
+CREATE MATERIALIZED VIEW posthog.ops_query_log_archive_mv TO posthog.writable_query_log_archive (hostname LowCardinality(String), user LowCardinality(String), query_id String, initial_query_id String, is_initial_query UInt8, type Enum8('QueryStart'=1, 'QueryFinish'=2, 'ExceptionBeforeStart'=3, 'ExceptionWhileProcessing'=4), event_date Date, event_time DateTime, event_time_microseconds DateTime64(6), query_start_time DateTime, query_start_time_microseconds DateTime64(6), query_duration_ms UInt64, read_rows UInt64, read_bytes UInt64, written_rows UInt64, written_bytes UInt64, result_rows UInt64, result_bytes UInt64, memory_usage UInt64, peak_threads_usage UInt64, current_database LowCardinality(String), query String, formatted_query String, normalized_query_hash UInt64, query_kind LowCardinality(String), exception_code Int32, exception String, stack_trace String, team_id Int64, log_comment String, ProfileEvents Map(LowCardinality(String), UInt64)) AS SELECT
+ hostname,
+ user,
+ query_id,
+ initial_query_id,
+ is_initial_query,
+ type,
+ event_date,
+ event_time,
+ event_time_microseconds,
+ query_start_time,
+ query_start_time_microseconds,
+ query_duration_ms,
+ read_rows,
+ read_bytes,
+ written_rows,
+ written_bytes,
+ result_rows,
+ result_bytes,
+ memory_usage,
+ peak_threads_usage,
+ current_database,
+ query,
+ formatted_query,
+ normalized_query_hash,
+ query_kind,
+ exception_code,
+ exception,
+ stack_trace,
+ JSONExtractInt(log_comment, 'team_id') AS team_id,
+ if(isValidJSON(log_comment), log_comment, '{}') AS log_comment,
+ ProfileEvents
+FROM system.query_log
+WHERE type != 'QueryStart';
+CREATE VIEW posthog.custom_metrics_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 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 'dict_reader' TABLE 'channel_definition')) LAYOUT(COMPLEX_KEY_HASHED()) 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 'dict_reader' QUERY 'SELECT team_id FROM `web_pre_aggregated_teams` FINAL WHERE version > 0')) LAYOUT(HASHED()) LIFETIME(MIN 3000 MAX 3600);
diff --git a/posthog/clickhouse/hcl/sql/prod-us-sessionsv3.sql b/posthog/clickhouse/hcl/sql/prod-us-sessionsv3.sql
new file mode 100644
index 000000000000..0b03cc81d3f2
--- /dev/null
+++ b/posthog/clickhouse/hcl/sql/prod-us-sessionsv3.sql
@@ -0,0 +1,798 @@
+-- AUTO-GENERATED from the declarative HCL by ops/gen-sql.sh — do not edit.
+-- Full CREATE schema for the prod-us/sessionsv3 node. Apply to a fresh ClickHouse to build it.
+
+CREATE TABLE posthog.events (
+ uuid UUID,
+ event String,
+ properties String,
+ timestamp DateTime64(6, 'UTC'),
+ team_id Int64,
+ distinct_id String,
+ elements_hash String,
+ created_at DateTime64(6, 'UTC'),
+ _timestamp DateTime,
+ _offset UInt64,
+ elements_chain String,
+ mat_$user_id String COMMENT 'column_materializer::$user_id',
+ mat_$browser String COMMENT 'column_materializer::$browser',
+ mat_$host String COMMENT 'column_materializer::$host',
+ mat_$current_url String COMMENT 'column_materializer::$current_url',
+ mat_distinct_id String COMMENT 'column_materializer::distinct_id',
+ mat_action String COMMENT 'column_materializer::action',
+ mat_origin String COMMENT 'column_materializer::origin',
+ mat_email String COMMENT 'column_materializer::email',
+ mat_key String COMMENT 'column_materializer::key',
+ mat_insight String COMMENT 'column_materializer::insight',
+ mat_$event_type String COMMENT 'column_materializer::$event_type',
+ mat_created_by String COMMENT 'column_materializer::created_by',
+ mat_total_event_actions_count String COMMENT 'column_materializer::total_event_actions_count',
+ mat_is_demo_project String COMMENT 'column_materializer::is_demo_project',
+ mat_$active_feature_flags String COMMENT 'column_materializer::$active_feature_flags',
+ mat_filters_count String COMMENT 'column_materializer::filters_count',
+ mat_utm_source String COMMENT 'column_materializer::utm_source',
+ mat_apiErrorMessage String COMMENT 'column_materializer::apiErrorMessage',
+ mat_$referring_domain String COMMENT 'column_materializer::$referring_domain',
+ mat_statusCode String COMMENT 'column_materializer::statusCode',
+ mat_deal_id String COMMENT 'column_materializer::deal_id',
+ mat_realm String COMMENT 'column_materializer::realm',
+ $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',
+ mat_$lib String COMMENT 'column_materializer::$lib',
+ mat_$os String COMMENT 'column_materializer::$os',
+ mat_$initial_referrer String COMMENT 'column_materializer::$initial_referrer',
+ mat_$app_version String COMMENT 'column_materializer::$app_version',
+ mat_$initial_referring_domain String COMMENT 'column_materializer::$initial_referring_domain',
+ mat_symbol String COMMENT 'column_materializer::symbol',
+ mat_page String COMMENT 'column_materializer::page',
+ mat_type String COMMENT 'column_materializer::type',
+ mat_currentScreen String COMMENT 'column_materializer::currentScreen',
+ mat_utm_campaign String COMMENT 'column_materializer::utm_campaign',
+ mat_is_organization_first_user String COMMENT 'column_materializer::is_organization_first_user',
+ mat_is_first_component_load String COMMENT 'column_materializer::is_first_component_load',
+ mat_team String COMMENT 'column_materializer::team',
+ mat_context String COMMENT 'column_materializer::context',
+ mat_sdk String COMMENT 'column_materializer::sdk',
+ mat_created_by_system String COMMENT 'column_materializer::created_by_system',
+ mat_item_count String COMMENT 'column_materializer::item_count',
+ mat_$ip String COMMENT 'column_materializer::$ip',
+ mat_$referrer String COMMENT 'column_materializer::$referrer',
+ mat_action_name String COMMENT 'column_materializer::action_name',
+ mat_$geoip_country_name String COMMENT 'column_materializer::$geoip_country_name',
+ mat_$device_model String COMMENT 'column_materializer::$device_model',
+ mat_progress String COMMENT 'column_materializer::progress',
+ mat_chain String COMMENT 'column_materializer::chain',
+ mat_$device_type String COMMENT 'column_materializer::$device_type',
+ mat_usd String COMMENT 'column_materializer::usd',
+ mat_app_name String COMMENT 'column_materializer::app_name',
+ mat_$screen_name String COMMENT 'column_materializer::$screen_name',
+ mat_index String COMMENT 'column_materializer::index',
+ mat_token String COMMENT 'column_materializer::token',
+ mat_method String COMMENT 'column_materializer::method',
+ mat_address String COMMENT 'column_materializer::address',
+ mat_name String COMMENT 'column_materializer::name',
+ mat_inviteCode String COMMENT 'column_materializer::inviteCode',
+ $window_id String COMMENT 'column_materializer::$window_id',
+ $session_id String COMMENT 'column_materializer::$session_id',
+ mat_osName String COMMENT 'column_materializer::osName',
+ mat_nativeBuildVersion String COMMENT 'column_materializer::nativeBuildVersion',
+ mat_revenue String COMMENT 'column_materializer::revenue',
+ group_0 String ALIAS `$group_0`,
+ group_1 String ALIAS `$group_1`,
+ group_2 String ALIAS `$group_2`,
+ group_3 String ALIAS `$group_3`,
+ group_4 String ALIAS `$group_4`,
+ alias_mat__user_id String ALIAS `mat_$user_id`,
+ alias_mat__browser String ALIAS `mat_$browser`,
+ alias_mat__host String ALIAS `mat_$host`,
+ alias_mat__current_url String ALIAS `mat_$current_url`,
+ alias_mat__event_type String ALIAS `mat_$event_type`,
+ alias_mat__active_feature_flags String ALIAS `mat_$active_feature_flags`,
+ alias_mat__referring_domain String ALIAS `mat_$referring_domain`,
+ alias_mat__lib String ALIAS `mat_$lib`,
+ alias_mat__os String ALIAS `mat_$os`,
+ alias_mat__initial_referrer String ALIAS `mat_$initial_referrer`,
+ alias_mat__app_version String ALIAS `mat_$app_version`,
+ alias_mat__initial_referring_domain String ALIAS `mat_$initial_referring_domain`,
+ alias_mat__ip String ALIAS `mat_$ip`,
+ alias_mat__referrer String ALIAS `mat_$referrer`,
+ alias_mat__geoip_country_name String ALIAS `mat_$geoip_country_name`,
+ alias_mat__device_model String ALIAS `mat_$device_model`,
+ alias_mat__device_type String ALIAS `mat_$device_type`,
+ alias_mat__screen_name String ALIAS `mat_$screen_name`,
+ person_id UUID,
+ person_properties String,
+ group0_properties String,
+ group1_properties String,
+ group2_properties String,
+ group3_properties String,
+ group4_properties String,
+ person_created_at DateTime64(3),
+ group0_created_at DateTime64(3),
+ group1_created_at DateTime64(3),
+ group2_created_at DateTime64(3),
+ group3_created_at DateTime64(3),
+ group4_created_at DateTime64(3),
+ mat_arguments String COMMENT 'column_materializer::properties::arguments',
+ mat_source String COMMENT 'column_materializer::properties::source',
+ mat_pp_email String COMMENT 'column_materializer::person_properties::email',
+ mat_$time String COMMENT 'column_materializer::properties::$time',
+ mat_$pathname String COMMENT 'column_materializer::properties::$pathname',
+ mat_$geoip_city_name String COMMENT 'column_materializer::properties::$geoip_city_name',
+ mat_community_id String COMMENT 'column_materializer::properties::community_id',
+ mat_thread_id String COMMENT 'column_materializer::properties::thread_id',
+ mat_Event_productCode String COMMENT 'column_materializer::properties::Event.productCode',
+ mat_env String COMMENT 'column_materializer::properties::env',
+ mat_target String COMMENT 'column_materializer::properties::target',
+ mat_Subscription_plan_amount String COMMENT 'column_materializer::properties::Subscription.plan.amount',
+ mat_title String COMMENT 'column_materializer::properties::title',
+ mat_Connection_app_name String COMMENT 'column_materializer::properties::Connection.app.name',
+ mat_utm_medium String COMMENT 'column_materializer::properties::utm_medium',
+ mat_Account_client_id String COMMENT 'column_materializer::properties::Account.client_id',
+ mat_HTTP_Method String COMMENT 'column_materializer::properties::HTTP Method',
+ mat_audio_duration String COMMENT 'column_materializer::properties::audio_duration',
+ mat_duration String COMMENT 'column_materializer::properties::duration',
+ mat_url String COMMENT 'column_materializer::properties::url',
+ mat_group_id String COMMENT 'column_materializer::properties::group_id',
+ mat_platform String COMMENT 'column_materializer::properties::platform',
+ mat_pp_$browser String COMMENT 'column_materializer::person_properties::$browser',
+ mat_payment_status String COMMENT 'column_materializer::properties::payment_status',
+ mat_testSessionId String COMMENT 'column_materializer::properties::testSessionId',
+ inserted_at Nullable(DateTime64(6, 'UTC')) DEFAULT now64(),
+ mat_$sent_at String COMMENT 'column_materializer::properties::$sent_at',
+ mat_pp_companyName String COMMENT 'column_materializer::person_properties::companyName',
+ mat_function String COMMENT 'column_materializer::properties::function',
+ mat_store_url String COMMENT 'column_materializer::properties::store_url',
+ mat_email_domain String COMMENT 'column_materializer::properties::email_domain',
+ mat_institution_name String COMMENT 'column_materializer::properties::institution_name',
+ mat_authentication_method String COMMENT 'column_materializer::properties::authentication_method',
+ mat_initial_step String COMMENT 'column_materializer::properties::initial_step',
+ mat_status_message String COMMENT 'column_materializer::properties::status_message',
+ mat_mode String COMMENT 'column_materializer::properties::mode',
+ mat_protocol String COMMENT 'column_materializer::properties::protocol',
+ mat_job_type String COMMENT 'column_materializer::properties::job_type',
+ mat_is_oauth String COMMENT 'column_materializer::properties::is_oauth',
+ mat_is_initial_aggregation String COMMENT 'column_materializer::properties::is_initial_aggregation',
+ mat_search_term String COMMENT 'column_materializer::properties::search_term',
+ mat_valid_ach_accounts String COMMENT 'column_materializer::properties::valid_ach_accounts',
+ mat_gross String COMMENT 'column_materializer::properties::gross',
+ mat_orderType String COMMENT 'column_materializer::properties::orderType',
+ mat_sku String COMMENT 'column_materializer::properties::sku',
+ mat_dual_channel String COMMENT 'column_materializer::properties::dual_channel',
+ mat_channel String COMMENT 'column_materializer::properties::channel',
+ mat_workspaceId String COMMENT 'column_materializer::properties::workspaceId',
+ mat_numberOfSecrets String COMMENT 'column_materializer::properties::numberOfSecrets',
+ mat_organizations String COMMENT 'column_materializer::properties::organizations',
+ mat_organization String COMMENT 'column_materializer::properties::organization',
+ mat_contributionError String COMMENT 'column_materializer::properties::contributionError',
+ mat_phone String COMMENT 'column_materializer::properties::phone',
+ mat_$initial_pathname String COMMENT 'column_materializer::properties::$initial_pathname',
+ mat_organization_name String COMMENT 'column_materializer::properties::organization_name',
+ mat_category String COMMENT 'column_materializer::properties::category',
+ mat_$lib_version String COMMENT 'column_materializer::properties::$lib_version',
+ mat_pp_$initial_utm_campaign String COMMENT 'column_materializer::person_properties::$initial_utm_campaign',
+ mat_pp_$initial_utm_medium String COMMENT 'column_materializer::person_properties::$initial_utm_medium',
+ mat_pp_$initial_gclid String COMMENT 'column_materializer::person_properties::$initial_gclid',
+ mat_pp_$initial_gad_source String COMMENT 'column_materializer::person_properties::$initial_gad_source',
+ mat_pp_$initial_utm_source String COMMENT 'column_materializer::person_properties::$initial_utm_source',
+ mat_pp_$initial_referring_domain String COMMENT 'column_materializer::person_properties::$initial_referring_domain',
+ mat_pp_$initial_utm_term String COMMENT 'column_materializer::person_properties::$initial_utm_term',
+ mat_pp_$initial_utm_content String COMMENT 'column_materializer::person_properties::$initial_utm_content',
+ mat_pp_$initial_gbraid String COMMENT 'column_materializer::person_properties::$initial_gbraid::disabled',
+ mat_pp_$initial_wbraid String COMMENT 'column_materializer::person_properties::$initial_wbraid::disabled',
+ mat_pp_$initial_msclkid String COMMENT 'column_materializer::person_properties::$initial_msclkid',
+ mat_pp_$initial_fbclid String COMMENT 'column_materializer::person_properties::$initial_fbclid',
+ mat_$geoip_subdivision_1_code String COMMENT 'column_materializer::properties::$geoip_subdivision_1_code',
+ mat_wlo_enabled String COMMENT 'column_materializer::properties::wlo_enabled',
+ mat_$prev_pageview_max_scroll_percentage String COMMENT 'column_materializer::properties::$prev_pageview_max_scroll_percentage',
+ mat_$prev_pageview_max_content_percentage String COMMENT 'column_materializer::properties::$prev_pageview_max_content_percentage',
+ mat_$prev_pageview_pathname String COMMENT 'column_materializer::properties::$prev_pageview_pathname',
+ mat_pp_$initial_pathname String COMMENT 'column_materializer::person_properties::$initial_pathname',
+ mat_pp_$geoip_country_code String COMMENT 'column_materializer::person_properties::$geoip_country_code',
+ mat_pp_username String COMMENT 'column_materializer::person_properties::username',
+ mat_pp_serverMasterclass String COMMENT 'column_materializer::person_properties::serverMasterclass',
+ mat_content_length String COMMENT 'column_materializer::properties::content_length',
+ mat_pp_serverMarketing String COMMENT 'column_materializer::person_properties::serverMarketing',
+ mat_$browser_version String COMMENT 'column_materializer::properties::$browser_version',
+ mat_pp_role String COMMENT 'column_materializer::person_properties::role',
+ mat_pp_customer String COMMENT 'column_materializer::person_properties::customer',
+ mat_event String COMMENT 'column_materializer::properties::event',
+ mat_disable_institution_search String COMMENT 'column_materializer::properties::disable_institution_search',
+ mat_is_first_event_for_user String COMMENT 'column_materializer::properties::is_first_event_for_user',
+ mat_current_member_guid String COMMENT 'column_materializer::properties::current_member_guid',
+ mat_user_agent String COMMENT 'column_materializer::properties::user_agent',
+ mat_is_test_user String COMMENT 'column_materializer::properties::is_test_user',
+ mat_referrer String COMMENT 'column_materializer::properties::referrer',
+ mat_pp_$initial_current_url String COMMENT 'column_materializer::person_properties::$initial_current_url',
+ mat_most_recent_app_os String COMMENT 'column_materializer::properties::most_recent_app_os',
+ mat_pp_hubspot_score String COMMENT 'column_materializer::person_properties::hubspot_score',
+ mat_pp_id String COMMENT 'column_materializer::person_properties::id',
+ mat_pp_$current_url String COMMENT 'column_materializer::person_properties::$current_url',
+ mat_product_key String COMMENT 'column_materializer::properties::product_key',
+ mat_Plan_type_and_filter String COMMENT 'column_materializer::properties::Plan type and filter',
+ mat_$app_namespace String COMMENT 'column_materializer::properties::$app_namespace',
+ mat_$os_name String COMMENT 'column_materializer::properties::$os_name',
+ mat_pp_$os_name String COMMENT 'column_materializer::person_properties::$os_name::disabled',
+ mat_pp_$app_version String COMMENT 'column_materializer::person_properties::$app_version',
+ mat_subscriptionStatus String COMMENT 'column_materializer::properties::subscriptionStatus',
+ mat_$screen_height String COMMENT 'column_materializer::properties::$screen_height',
+ mat_$screen_width String COMMENT 'column_materializer::properties::$screen_width',
+ mat_tag String COMMENT 'column_materializer::properties::tag',
+ mat_$app_build String COMMENT 'column_materializer::properties::$app_build',
+ mat_surface_tag String COMMENT 'column_materializer::properties::surface_tag',
+ mat_survey_responses_count_in_period String COMMENT 'column_materializer::properties::survey_responses_count_in_period',
+ mat_event_count_in_month String COMMENT 'column_materializer::properties::event_count_in_month',
+ mat_ramp String COMMENT 'column_materializer::properties::ramp',
+ mat_auto_chapters String COMMENT 'column_materializer::properties::auto_chapters',
+ mat_sentiment_analysis String COMMENT 'column_materializer::properties::sentiment_analysis',
+ mat_redact_pii String COMMENT 'column_materializer::properties::redact_pii',
+ mat_content_safety String COMMENT 'column_materializer::properties::content_safety',
+ mat_iab_categories String COMMENT 'column_materializer::properties::iab_categories',
+ mat_auto_highlights String COMMENT 'column_materializer::properties::auto_highlights',
+ mat_entity_detection String COMMENT 'column_materializer::properties::entity_detection',
+ mat_summarization String COMMENT 'column_materializer::properties::summarization',
+ mat_pp_val_region String COMMENT 'column_materializer::person_properties::val_region',
+ mat_client_id String COMMENT 'column_materializer::properties::client_id',
+ mat_$geoip_country_code String COMMENT 'column_materializer::properties::$geoip_country_code',
+ mat_disfluencies String COMMENT 'column_materializer::properties::disfluencies',
+ mat_filter_profanity String COMMENT 'column_materializer::properties::filter_profanity',
+ mat_speaker_labels String COMMENT 'column_materializer::properties::speaker_labels',
+ mat_language_detection String COMMENT 'column_materializer::properties::language_detection',
+ mat_product_analytics_projected_amount String COMMENT 'column_materializer::properties::product_analytics_projected_amount',
+ mat_recordings_projected_amount String COMMENT 'column_materializer::properties::recordings_projected_amount',
+ mat_events_projected_amount String COMMENT 'column_materializer::properties::events_projected_amount',
+ mat_session_replay_projected_amount String COMMENT 'column_materializer::properties::session_replay_projected_amount',
+ mat_total_usd String COMMENT 'column_materializer::properties::total_usd',
+ mat_stripe_amount_paid String COMMENT 'column_materializer::properties::stripe_amount_paid',
+ mat_workspace String COMMENT 'column_materializer::properties::workspace',
+ mat_created_at String COMMENT 'column_materializer::properties::created_at',
+ mat_kind String COMMENT 'column_materializer::properties::kind',
+ mat_product String COMMENT 'column_materializer::properties::product',
+ mat_message String COMMENT 'column_materializer::properties::message',
+ mat_initiator String COMMENT 'column_materializer::properties::initiator',
+ mat_query String COMMENT 'column_materializer::properties::query',
+ mat_$survey_id String COMMENT 'column_materializer::properties::$survey_id',
+ mat_$survey_response_1 String COMMENT 'column_materializer::properties::$survey_response_1',
+ mat_ticketId String COMMENT 'column_materializer::properties::ticketId',
+ mat_$survey_response String COMMENT 'column_materializer::properties::$survey_response',
+ mat_conceptName String COMMENT 'column_materializer::properties::conceptName',
+ mat_apiName String COMMENT 'column_materializer::properties::apiName',
+ mat_workplace_billing_plan String COMMENT 'column_materializer::properties::workplace_billing_plan',
+ mat_$el_text String COMMENT 'column_materializer::properties::$el_text',
+ mat_recording_count_in_period String COMMENT 'column_materializer::properties::recording_count_in_period',
+ mat_$os_version String COMMENT 'column_materializer::properties::$os_version',
+ mat_orderId String COMMENT 'column_materializer::properties::orderId',
+ mat_commit_sha String COMMENT 'column_materializer::properties::commit_sha',
+ mat_$feature_flag_payloads String COMMENT 'column_materializer::properties::$feature_flag_payloads',
+ mat_event_count_in_period String COMMENT 'column_materializer::properties::event_count_in_period',
+ mat_$groups String COMMENT 'column_materializer::properties::$groups',
+ mat_$feature_flag String COMMENT 'column_materializer::properties::$feature_flag',
+ mat_utm_content String COMMENT 'column_materializer::properties::utm_content',
+ mat_gclid String COMMENT 'column_materializer::properties::gclid',
+ mat_gad_source String COMMENT 'column_materializer::properties::gad_source',
+ mat_gbraid String COMMENT 'column_materializer::properties::gbraid',
+ mat_wbraid String COMMENT 'column_materializer::properties::wbraid',
+ mat_fbclid String COMMENT 'column_materializer::properties::fbclid',
+ mat_msclkid String COMMENT 'column_materializer::properties::msclkid',
+ mat_organization_id String COMMENT 'column_materializer::properties::organization_id',
+ mat_owner_type String COMMENT 'column_materializer::properties::owner_type',
+ mat_device_type String COMMENT 'column_materializer::properties::device_type',
+ mat_$device_id String COMMENT 'column_materializer::properties::$device_id',
+ mat_pp_$geoip_continent_name String COMMENT 'column_materializer::person_properties::$geoip_continent_name',
+ mat_$feature_flag_response String COMMENT 'column_materializer::properties::$feature_flag_response',
+ mat_pp_utm_source String COMMENT 'column_materializer::person_properties::utm_source',
+ mat_pp_$referring_domain String COMMENT 'column_materializer::person_properties::$referring_domain',
+ mat_pp_Email_Domain String COMMENT 'column_materializer::person_properties::Email Domain',
+ mat_machine_id String COMMENT 'column_materializer::properties::machine_id',
+ mat_user_email_domain String COMMENT 'column_materializer::properties::user_email_domain',
+ mat_$lib_version__minor String COMMENT 'column_materializer::properties::$lib_version__minor',
+ mat_region String COMMENT 'column_materializer::properties::region',
+ mat_pp_user_email_domain String COMMENT 'column_materializer::person_properties::user_email_domain',
+ mat_url_promotion_id String COMMENT 'column_materializer::properties::url_promotion_id',
+ mat_$lib_custom_api_host String COMMENT 'column_materializer::properties::$lib_custom_api_host',
+ person_mode Enum8('full'=0, 'propertyless'=1, 'force_upgrade'=2),
+ mat_user_platform String COMMENT 'column_materializer::properties::user_platform',
+ mat_pp_$geoip_country_name String COMMENT 'column_materializer::person_properties::$geoip_country_name',
+ mat_environment String COMMENT 'column_materializer::properties::environment',
+ mat_customer_email String COMMENT 'column_materializer::properties::customer_email',
+ mat_client_name String COMMENT 'column_materializer::properties::client_name',
+ mat_screen_name String COMMENT 'column_materializer::properties::screen_name',
+ mat_app_version String COMMENT 'column_materializer::properties::app_version',
+ elements_chain_href String COMMENT 'column_materializer::elements_chain::href',
+ elements_chain_texts Array(String) COMMENT 'column_materializer::elements_chain::texts',
+ elements_chain_ids Array(String) COMMENT 'column_materializer::elements_chain::ids',
+ elements_chain_elements Array(Enum8('a'=1, 'button'=2, 'form'=3, 'input'=4, 'select'=5, 'textarea'=6, 'label'=7)) COMMENT 'column_materializer::elements_chain::elements',
+ properties_group_custom Map(String, String),
+ properties_group_feature_flags Map(String, String),
+ is_deleted Bool,
+ mat_subdomain String COMMENT 'column_materializer::properties::subdomain',
+ mat_$device String COMMENT 'column_materializer::properties::$device',
+ mat_id String COMMENT 'column_materializer::properties::id',
+ mat_record_id String COMMENT 'column_materializer::properties::record_id',
+ mat_referrer_id String COMMENT 'column_materializer::properties::record_id',
+ mat_$exception_issue_id Nullable(String) COMMENT 'column_materializer::properties::$exception_issue_id',
+ mat_$exception_fingerprint Nullable(String) COMMENT 'column_materializer::properties::$exception_fingerprint',
+ mat_$web_vitals_LCP_value Nullable(String) COMMENT 'column_materializer::properties::$web_vitals_LCP_value',
+ mat_$web_vitals_FCP_value Nullable(String) COMMENT 'column_materializer::properties::$web_vitals_FCP_value',
+ mat_$web_vitals_CLS_value Nullable(String) COMMENT 'column_materializer::properties::$web_vitals_CLS_value',
+ mat_$web_vitals_INP_value Nullable(String) COMMENT 'column_materializer::properties::$web_vitals_INP_value',
+ mat_$viewport_width Nullable(String) COMMENT 'column_materializer::properties::$viewport_width',
+ mat_$viewport_height Nullable(String) COMMENT 'column_materializer::properties::$viewport_height',
+ mat_$anon_distinct_id Nullable(String) COMMENT 'column_materializer::properties::$anon_distinct_id',
+ person_properties_map_custom Map(String, String),
+ mat_$ai_trace_id Nullable(String) COMMENT 'column_materializer::properties::$ai_trace_id',
+ mat_$ai_model Nullable(String) COMMENT 'column_materializer::properties::$ai_model',
+ mat_$ai_provider Nullable(String) COMMENT 'column_materializer::properties::$ai_provider',
+ mat_$ai_parent_id Nullable(String) COMMENT 'column_materializer::properties::$ai_parent_id',
+ mat_$ai_span_id Nullable(String) COMMENT 'column_materializer::properties::$ai_span_id',
+ mat_$ai_http_status Nullable(String) COMMENT 'column_materializer::properties::$ai_http_status',
+ mat_$exception_types Nullable(String) COMMENT 'column_materializer::properties::$exception_types',
+ mat_$exception_values Nullable(String) COMMENT 'column_materializer::properties::$exception_values',
+ mat_$exception_sources Nullable(String) COMMENT 'column_materializer::properties::$exception_sources',
+ mat_$exception_functions Nullable(String) COMMENT 'column_materializer::properties::$exception_functions',
+ $session_id_uuid Nullable(UInt128),
+ mat_$process_person_profile Nullable(String) COMMENT 'column_materializer::properties::$process_person_profile',
+ consumer_breadcrumbs Array(String),
+ properties_group_ai Map(String, String),
+ mat_$is_identified Nullable(String) COMMENT 'column_materializer::properties::$is_identified',
+ mat_historical_migration Nullable(String) COMMENT 'column_materializer::properties::historical_migration',
+ mat_$ai_session_id Nullable(String) COMMENT 'column_materializer::properties::$ai_session_id',
+ mat_$ai_is_error Nullable(String) COMMENT 'column_materializer::properties::$ai_is_error',
+ dmat_string_0 Nullable(String),
+ dmat_string_1 Nullable(String),
+ dmat_string_2 Nullable(String),
+ dmat_string_3 Nullable(String),
+ dmat_string_4 Nullable(String),
+ dmat_string_5 Nullable(String),
+ dmat_string_6 Nullable(String),
+ dmat_string_7 Nullable(String),
+ dmat_string_8 Nullable(String),
+ dmat_string_9 Nullable(String),
+ dmat_numeric_0 Nullable(Float64),
+ dmat_numeric_1 Nullable(Float64),
+ dmat_numeric_2 Nullable(Float64),
+ dmat_numeric_3 Nullable(Float64),
+ dmat_numeric_4 Nullable(Float64),
+ dmat_numeric_5 Nullable(Float64),
+ dmat_numeric_6 Nullable(Float64),
+ dmat_numeric_7 Nullable(Float64),
+ dmat_numeric_8 Nullable(Float64),
+ dmat_numeric_9 Nullable(Float64),
+ dmat_bool_0 Nullable(UInt8),
+ dmat_bool_1 Nullable(UInt8),
+ dmat_bool_2 Nullable(UInt8),
+ dmat_bool_3 Nullable(UInt8),
+ dmat_bool_4 Nullable(UInt8),
+ dmat_bool_5 Nullable(UInt8),
+ dmat_bool_6 Nullable(UInt8),
+ dmat_bool_7 Nullable(UInt8),
+ dmat_bool_8 Nullable(UInt8),
+ dmat_bool_9 Nullable(UInt8),
+ dmat_datetime_0 Nullable(DateTime64(6, 'UTC')),
+ dmat_datetime_1 Nullable(DateTime64(6, 'UTC')),
+ dmat_datetime_2 Nullable(DateTime64(6, 'UTC')),
+ dmat_datetime_3 Nullable(DateTime64(6, 'UTC')),
+ dmat_datetime_4 Nullable(DateTime64(6, 'UTC')),
+ dmat_datetime_5 Nullable(DateTime64(6, 'UTC')),
+ dmat_datetime_6 Nullable(DateTime64(6, 'UTC')),
+ dmat_datetime_7 Nullable(DateTime64(6, 'UTC')),
+ dmat_datetime_8 Nullable(DateTime64(6, 'UTC')),
+ dmat_datetime_9 Nullable(DateTime64(6, 'UTC')),
+ historical_migration Bool,
+ mat_$ai_total_cost_usd Nullable(String) COMMENT 'column_materializer::properties::$ai_total_cost_usd',
+ properties_group_ai_large Map(String, String),
+ mat_$ai_prompt_name Nullable(String) COMMENT 'column_materializer::properties::$ai_prompt_name'
+) ENGINE = Distributed('posthog', 'posthog', 'sharded_events', sipHash64(distinct_id));
+CREATE TABLE posthog.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_old_ops (
+ 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 = Distributed('ops', 'posthog', 'query_log_archive_old');
+CREATE TABLE posthog.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, 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
+) ENGINE = AggregatingMergeTree() ORDER BY (team_id, session_timestamp, session_id_v7) PARTITION BY toYYYYMM(session_timestamp) SETTINGS index_granularity = 8192;
+CREATE TABLE posthog.writable_query_log_archive (
+ hostname LowCardinality(String),
+ user LowCardinality(String),
+ query_id String,
+ initial_query_id String,
+ is_initial_query UInt8,
+ type Enum8('QueryStart'=1, 'QueryFinish'=2, 'ExceptionBeforeStart'=3, 'ExceptionWhileProcessing'=4),
+ event_date Date,
+ event_time DateTime,
+ event_time_microseconds DateTime64(6),
+ query_start_time DateTime,
+ query_start_time_microseconds DateTime64(6),
+ query_duration_ms UInt64,
+ read_rows UInt64,
+ read_bytes UInt64,
+ written_rows UInt64,
+ written_bytes UInt64,
+ result_rows UInt64,
+ result_bytes UInt64,
+ memory_usage UInt64,
+ peak_threads_usage UInt64,
+ current_database LowCardinality(String),
+ query String,
+ formatted_query String,
+ normalized_query_hash UInt64,
+ query_kind LowCardinality(String),
+ exception_code Int32,
+ exception String,
+ stack_trace String,
+ team_id Int64,
+ log_comment JSON(max_dynamic_paths=256, access_method LowCardinality(String), alert_config_id String, api_key_label String, api_key_mask String, batch_export_id String, chargeable Bool, client_query_id String, cohort_id Int64, `dagster.job_name` String, `dagster.run_id` String, `dagster.tags.owner` String, dashboard_id Int64, experiment_feature_flag_key String, experiment_id Int64, feature LowCardinality(String), id String, insight_id Int64, is_impersonated Bool, kind LowCardinality(String), name String, org_id String, person_on_events_mode LowCardinality(String), product LowCardinality(String), query_type LowCardinality(String), request_name String, route_id String, service_name String, session_id String, table_id String, team_id Int64, `temporal.activity_id` String, `temporal.activity_type` String, `temporal.attempt` Int64, `temporal.workflow_id` String, `temporal.workflow_namespace` String, `temporal.workflow_run_id` String, `temporal.workflow_type` String, user_id Int64, warehouse_query Bool, workflow LowCardinality(String), workload LowCardinality(String), SKIP cache_key, SKIP filter, SKIP hogql_features, SKIP http_referer, SKIP http_request_id, SKIP http_user_agent, SKIP query_settings, SKIP timings, SKIP user_email),
+ ProfileEvents Map(String, UInt64)
+) ENGINE = Distributed('ops', 'posthog', 'query_log_archive_buffer');
+CREATE MATERIALIZED VIEW posthog.ops_query_log_archive_mv TO posthog.writable_query_log_archive (hostname LowCardinality(String), user LowCardinality(String), query_id String, initial_query_id String, is_initial_query UInt8, type Enum8('QueryStart'=1, 'QueryFinish'=2, 'ExceptionBeforeStart'=3, 'ExceptionWhileProcessing'=4), event_date Date, event_time DateTime, event_time_microseconds DateTime64(6), query_start_time DateTime, query_start_time_microseconds DateTime64(6), query_duration_ms UInt64, read_rows UInt64, read_bytes UInt64, written_rows UInt64, written_bytes UInt64, result_rows UInt64, result_bytes UInt64, memory_usage UInt64, peak_threads_usage UInt64, current_database LowCardinality(String), query String, formatted_query String, normalized_query_hash UInt64, query_kind LowCardinality(String), exception_code Int32, exception String, stack_trace String, team_id Int64, log_comment String, ProfileEvents Map(LowCardinality(String), UInt64)) AS SELECT
+ hostname,
+ user,
+ query_id,
+ initial_query_id,
+ is_initial_query,
+ type,
+ event_date,
+ event_time,
+ event_time_microseconds,
+ query_start_time,
+ query_start_time_microseconds,
+ query_duration_ms,
+ read_rows,
+ read_bytes,
+ written_rows,
+ written_bytes,
+ result_rows,
+ result_bytes,
+ memory_usage,
+ peak_threads_usage,
+ current_database,
+ query,
+ formatted_query,
+ normalized_query_hash,
+ query_kind,
+ exception_code,
+ exception,
+ stack_trace,
+ JSONExtractInt(log_comment, 'team_id') AS team_id,
+ if(isValidJSON(log_comment), log_comment, '{}') AS log_comment,
+ ProfileEvents
+FROM system.query_log
+WHERE type != 'QueryStart';
+CREATE VIEW posthog.custom_metrics_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;