:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
feat(clickhouse): add warehouse_object_reads_daily table (#109209)
Thiago Salvatore3ff755b152c3
diff --git a/posthog/clickhouse/hcl/golden/dev/auxiliary.hcl b/posthog/clickhouse/hcl/golden/dev/auxiliary.hclindex 18dfbbe5f265..99528a038599 100644--- a/posthog/clickhouse/hcl/golden/dev/auxiliary.hcl+++ b/posthog/clickhouse/hcl/golden/dev/auxiliary.hcl@@ -2663,6 +2663,166 @@ database "posthog" {}}+ table "sharded_warehouse_object_reads_daily" {+ order_by = ["team_id", "day", "read_kind", "subject_kind", "subject_id", "workflow_id", "lc_kind", "lc_product", "lc_feature", "lc_access_method", "source", "scene", "has_user_id", "read_alone"]+ partition_by = "toYYYYMMDD(day)"+ ttl = "day + toIntervalDay(60)"+ settings = {+ index_granularity = "8192"+ ttl_only_drop_parts = "1"+ }+ column "team_id" {+ type = "Int64"+ }+ column "day" {+ type = "Date"+ }+ column "read_kind" {+ type = "Enum8('read'=1, 'refresh'=2)"+ }+ column "subject_kind" {+ type = "Enum8('saved_query'=1, 'table'=2)"+ }+ column "subject_id" {+ type = "String"+ }+ column "workflow_id" {+ type = "String"+ }+ column "lc_kind" {+ type = "LowCardinality(String)"+ }+ column "lc_product" {+ type = "LowCardinality(String)"+ }+ column "lc_feature" {+ type = "LowCardinality(String)"+ }+ column "lc_access_method" {+ type = "LowCardinality(String)"+ }+ column "source" {+ type = "LowCardinality(String)"+ }+ column "scene" {+ type = "LowCardinality(String)"+ }+ column "has_user_id" {+ type = "Bool"+ }+ column "read_alone" {+ type = "Bool"+ }+ column "requests" {+ type = "AggregateFunction(uniq, String)"+ }+ column "users" {+ type = "AggregateFunction(uniq, Int64)"+ }+ column "read_count" {+ type = "SimpleAggregateFunction(sum, UInt64)"+ }+ column "duration_ms_sum" {+ type = "SimpleAggregateFunction(sum, UInt64)"+ }+ column "read_bytes_sum" {+ type = "SimpleAggregateFunction(sum, UInt64)"+ }+ column "duration_ms_quantiles" {+ type = "AggregateFunction(quantiles(0.5, 0.9), UInt64)"+ }+ column "read_bytes_quantiles" {+ type = "AggregateFunction(quantiles(0.5, 0.9), UInt64)"+ }+ column "max_event_time" {+ type = "SimpleAggregateFunction(max, DateTime)"+ }+ engine "replicated_aggregating_merge_tree" {+ zoo_path = "/clickhouse/tables/noshard/posthog.warehouse_object_reads_daily"+ replica_name = "{replica}-{shard}"+ }+ }++ table "sharded_warehouse_object_reads_daily_staging" {+ order_by = ["team_id", "day", "read_kind", "subject_kind", "subject_id", "workflow_id", "lc_kind", "lc_product", "lc_feature", "lc_access_method", "source", "scene", "has_user_id", "read_alone"]+ partition_by = "toYYYYMMDD(day)"+ ttl = "day + toIntervalDay(60)"+ settings = {+ index_granularity = "8192"+ ttl_only_drop_parts = "1"+ }+ column "team_id" {+ type = "Int64"+ }+ column "day" {+ type = "Date"+ }+ column "read_kind" {+ type = "Enum8('read'=1, 'refresh'=2)"+ }+ column "subject_kind" {+ type = "Enum8('saved_query'=1, 'table'=2)"+ }+ column "subject_id" {+ type = "String"+ }+ column "workflow_id" {+ type = "String"+ }+ column "lc_kind" {+ type = "LowCardinality(String)"+ }+ column "lc_product" {+ type = "LowCardinality(String)"+ }+ column "lc_feature" {+ type = "LowCardinality(String)"+ }+ column "lc_access_method" {+ type = "LowCardinality(String)"+ }+ column "source" {+ type = "LowCardinality(String)"+ }+ column "scene" {+ type = "LowCardinality(String)"+ }+ column "has_user_id" {+ type = "Bool"+ }+ column "read_alone" {+ type = "Bool"+ }+ column "requests" {+ type = "AggregateFunction(uniq, String)"+ }+ column "users" {+ type = "AggregateFunction(uniq, Int64)"+ }+ column "read_count" {+ type = "SimpleAggregateFunction(sum, UInt64)"+ }+ column "duration_ms_sum" {+ type = "SimpleAggregateFunction(sum, UInt64)"+ }+ column "read_bytes_sum" {+ type = "SimpleAggregateFunction(sum, UInt64)"+ }+ column "duration_ms_quantiles" {+ type = "AggregateFunction(quantiles(0.5, 0.9), UInt64)"+ }+ column "read_bytes_quantiles" {+ type = "AggregateFunction(quantiles(0.5, 0.9), UInt64)"+ }+ column "max_event_time" {+ type = "SimpleAggregateFunction(max, DateTime)"+ }+ engine "replicated_aggregating_merge_tree" {+ zoo_path = "/clickhouse/tables/noshard/posthog.sharded_warehouse_object_reads_daily_staging"+ replica_name = "{replica}-{shard}"+ }+ }+table "sharded_web_bot_definition" {order_by = ["id"]settings = {@@ -3308,6 +3468,80 @@ database "posthog" {}}+ table "warehouse_object_reads_daily" {+ column "team_id" {+ type = "Int64"+ }+ column "day" {+ type = "Date"+ }+ column "read_kind" {+ type = "Enum8('read'=1, 'refresh'=2)"+ }+ column "subject_kind" {+ type = "Enum8('saved_query'=1, 'table'=2)"+ }+ column "subject_id" {+ type = "String"+ }+ column "workflow_id" {+ type = "String"+ }+ column "lc_kind" {+ type = "LowCardinality(String)"+ }+ column "lc_product" {+ type = "LowCardinality(String)"+ }+ column "lc_feature" {+ type = "LowCardinality(String)"+ }+ column "lc_access_method" {+ type = "LowCardinality(String)"+ }+ column "source" {+ type = "LowCardinality(String)"+ }+ column "scene" {+ type = "LowCardinality(String)"+ }+ column "has_user_id" {+ type = "Bool"+ }+ column "read_alone" {+ type = "Bool"+ }+ column "requests" {+ type = "AggregateFunction(uniq, String)"+ }+ column "users" {+ type = "AggregateFunction(uniq, Int64)"+ }+ column "read_count" {+ type = "SimpleAggregateFunction(sum, UInt64)"+ }+ column "duration_ms_sum" {+ type = "SimpleAggregateFunction(sum, UInt64)"+ }+ column "read_bytes_sum" {+ type = "SimpleAggregateFunction(sum, UInt64)"+ }+ column "duration_ms_quantiles" {+ type = "AggregateFunction(quantiles(0.5, 0.9), UInt64)"+ }+ column "read_bytes_quantiles" {+ type = "AggregateFunction(quantiles(0.5, 0.9), UInt64)"+ }+ column "max_event_time" {+ type = "SimpleAggregateFunction(max, DateTime)"+ }+ engine "distributed" {+ cluster_name = "aux"+ remote_database = "posthog"+ remote_table = "sharded_warehouse_object_reads_daily"+ }+ }+table "web_bot_definition" {column "id" {type = "UInt64"diff --git a/posthog/clickhouse/hcl/golden/dev/data.hcl b/posthog/clickhouse/hcl/golden/dev/data.hclindex 0d54c0f7d2bf..5aae220ec1d4 100644--- a/posthog/clickhouse/hcl/golden/dev/data.hcl+++ b/posthog/clickhouse/hcl/golden/dev/data.hcl@@ -6929,6 +6929,80 @@ database "posthog" {}}+ table "warehouse_object_reads_daily" {+ column "team_id" {+ type = "Int64"+ }+ column "day" {+ type = "Date"+ }+ column "read_kind" {+ type = "Enum8('read'=1, 'refresh'=2)"+ }+ column "subject_kind" {+ type = "Enum8('saved_query'=1, 'table'=2)"+ }+ column "subject_id" {+ type = "String"+ }+ column "workflow_id" {+ type = "String"+ }+ column "lc_kind" {+ type = "LowCardinality(String)"+ }+ column "lc_product" {+ type = "LowCardinality(String)"+ }+ column "lc_feature" {+ type = "LowCardinality(String)"+ }+ column "lc_access_method" {+ type = "LowCardinality(String)"+ }+ column "source" {+ type = "LowCardinality(String)"+ }+ column "scene" {+ type = "LowCardinality(String)"+ }+ column "has_user_id" {+ type = "Bool"+ }+ column "read_alone" {+ type = "Bool"+ }+ column "requests" {+ type = "AggregateFunction(uniq, String)"+ }+ column "users" {+ type = "AggregateFunction(uniq, Int64)"+ }+ column "read_count" {+ type = "SimpleAggregateFunction(sum, UInt64)"+ }+ column "duration_ms_sum" {+ type = "SimpleAggregateFunction(sum, UInt64)"+ }+ column "read_bytes_sum" {+ type = "SimpleAggregateFunction(sum, UInt64)"+ }+ column "duration_ms_quantiles" {+ type = "AggregateFunction(quantiles(0.5, 0.9), UInt64)"+ }+ column "read_bytes_quantiles" {+ type = "AggregateFunction(quantiles(0.5, 0.9), UInt64)"+ }+ column "max_event_time" {+ type = "SimpleAggregateFunction(max, DateTime)"+ }+ engine "distributed" {+ cluster_name = "aux"+ remote_database = "posthog"+ remote_table = "sharded_warehouse_object_reads_daily"+ }+ }+table "web_bot_definition" {column "id" {type = "UInt64"diff --git a/posthog/clickhouse/hcl/golden/local-multi/auxiliary.hcl b/posthog/clickhouse/hcl/golden/local-multi/auxiliary.hclindex eafeed822db8..cb4394a6babb 100644--- a/posthog/clickhouse/hcl/golden/local-multi/auxiliary.hcl+++ b/posthog/clickhouse/hcl/golden/local-multi/auxiliary.hcl@@ -2670,6 +2670,166 @@ database "posthog" {}}+ table "sharded_warehouse_object_reads_daily" {+ order_by = ["team_id", "day", "read_kind", "subject_kind", "subject_id", "workflow_id", "lc_kind", "lc_product", "lc_feature", "lc_access_method", "source", "scene", "has_user_id", "read_alone"]+ partition_by = "toYYYYMMDD(day)"+ ttl = "day + toIntervalDay(60)"+ settings = {+ index_granularity = "8192"+ ttl_only_drop_parts = "1"+ }+ column "team_id" {+ type = "Int64"+ }+ column "day" {+ type = "Date"+ }+ column "read_kind" {+ type = "Enum8('read'=1, 'refresh'=2)"+ }+ column "subject_kind" {+ type = "Enum8('saved_query'=1, 'table'=2)"+ }+ column "subject_id" {+ type = "String"+ }+ column "workflow_id" {+ type = "String"+ }+ column "lc_kind" {+ type = "LowCardinality(String)"+ }+ column "lc_product" {+ type = "LowCardinality(String)"+ }+ column "lc_feature" {+ type = "LowCardinality(String)"+ }+ column "lc_access_method" {+ type = "LowCardinality(String)"+ }+ column "source" {+ type = "LowCardinality(String)"+ }+ column "scene" {+ type = "LowCardinality(String)"+ }+ column "has_user_id" {+ type = "Bool"+ }+ column "read_alone" {+ type = "Bool"+ }+ column "requests" {+ type = "AggregateFunction(uniq, String)"+ }+ column "users" {+ type = "AggregateFunction(uniq, Int64)"+ }+ column "read_count" {+ type = "SimpleAggregateFunction(sum, UInt64)"+ }+ column "duration_ms_sum" {+ type = "SimpleAggregateFunction(sum, UInt64)"+ }+ column "read_bytes_sum" {+ type = "SimpleAggregateFunction(sum, UInt64)"+ }+ column "duration_ms_quantiles" {+ type = "AggregateFunction(quantiles(0.5, 0.9), UInt64)"+ }+ column "read_bytes_quantiles" {+ type = "AggregateFunction(quantiles(0.5, 0.9), UInt64)"+ }+ column "max_event_time" {+ type = "SimpleAggregateFunction(max, DateTime)"+ }+ engine "replicated_aggregating_merge_tree" {+ zoo_path = "/clickhouse/tables/noshard/posthog.warehouse_object_reads_daily"+ replica_name = "{replica}-{shard}"+ }+ }++ table "sharded_warehouse_object_reads_daily_staging" {+ order_by = ["team_id", "day", "read_kind", "subject_kind", "subject_id", "workflow_id", "lc_kind", "lc_product", "lc_feature", "lc_access_method", "source", "scene", "has_user_id", "read_alone"]+ partition_by = "toYYYYMMDD(day)"+ ttl = "day + toIntervalDay(60)"+ settings = {+ index_granularity = "8192"+ ttl_only_drop_parts = "1"+ }+ column "team_id" {+ type = "Int64"+ }+ column "day" {+ type = "Date"+ }+ column "read_kind" {+ type = "Enum8('read'=1, 'refresh'=2)"+ }+ column "subject_kind" {+ type = "Enum8('saved_query'=1, 'table'=2)"+ }+ column "subject_id" {+ type = "String"+ }+ column "workflow_id" {+ type = "String"+ }+ column "lc_kind" {+ type = "LowCardinality(String)"+ }+ column "lc_product" {+ type = "LowCardinality(String)"+ }+ column "lc_feature" {+ type = "LowCardinality(String)"+ }+ column "lc_access_method" {+ type = "LowCardinality(String)"+ }+ column "source" {+ type = "LowCardinality(String)"+ }+ column "scene" {+ type = "LowCardinality(String)"+ }+ column "has_user_id" {+ type = "Bool"+ }+ column "read_alone" {+ type = "Bool"+ }+ column "requests" {+ type = "AggregateFunction(uniq, String)"+ }+ column "users" {+ type = "AggregateFunction(uniq, Int64)"+ }+ column "read_count" {+ type = "SimpleAggregateFunction(sum, UInt64)"+ }+ column "duration_ms_sum" {+ type = "SimpleAggregateFunction(sum, UInt64)"+ }+ column "read_bytes_sum" {+ type = "SimpleAggregateFunction(sum, UInt64)"+ }+ column "duration_ms_quantiles" {+ type = "AggregateFunction(quantiles(0.5, 0.9), UInt64)"+ }+ column "read_bytes_quantiles" {+ type = "AggregateFunction(quantiles(0.5, 0.9), UInt64)"+ }+ column "max_event_time" {+ type = "SimpleAggregateFunction(max, DateTime)"+ }+ engine "replicated_aggregating_merge_tree" {+ zoo_path = "/clickhouse/tables/noshard/posthog.sharded_warehouse_object_reads_daily_staging"+ replica_name = "{replica}-{shard}"+ }+ }+table "sharded_web_bot_definition" {order_by = ["id"]settings = {@@ -3315,6 +3475,80 @@ database "posthog" {}}+ table "warehouse_object_reads_daily" {+ column "team_id" {+ type = "Int64"+ }+ column "day" {+ type = "Date"+ }+ column "read_kind" {+ type = "Enum8('read'=1, 'refresh'=2)"+ }+ column "subject_kind" {+ type = "Enum8('saved_query'=1, 'table'=2)"+ }+ column "subject_id" {+ type = "String"+ }+ column "workflow_id" {+ type = "String"+ }+ column "lc_kind" {+ type = "LowCardinality(String)"+ }+ column "lc_product" {+ type = "LowCardinality(String)"+ }+ column "lc_feature" {+ type = "LowCardinality(String)"+ }+ column "lc_access_method" {+ type = "LowCardinality(String)"+ }+ column "source" {+ type = "LowCardinality(String)"+ }+ column "scene" {+ type = "LowCardinality(String)"+ }+ column "has_user_id" {+ type = "Bool"+ }+ column "read_alone" {+ type = "Bool"+ }+ column "requests" {+ type = "AggregateFunction(uniq, String)"+ }+ column "users" {+ type = "AggregateFunction(uniq, Int64)"+ }+ column "read_count" {+ type = "SimpleAggregateFunction(sum, UInt64)"+ }+ column "duration_ms_sum" {+ type = "SimpleAggregateFunction(sum, UInt64)"+ }+ column "read_bytes_sum" {+ type = "SimpleAggregateFunction(sum, UInt64)"+ }+ column "duration_ms_quantiles" {+ type = "AggregateFunction(quantiles(0.5, 0.9), UInt64)"+ }+ column "read_bytes_quantiles" {+ type = "AggregateFunction(quantiles(0.5, 0.9), UInt64)"+ }+ column "max_event_time" {+ type = "SimpleAggregateFunction(max, DateTime)"+ }+ engine "distributed" {+ cluster_name = "aux"+ remote_database = "posthog"+ remote_table = "sharded_warehouse_object_reads_daily"+ }+ }+table "web_bot_definition" {column "id" {type = "UInt64"diff --git a/posthog/clickhouse/hcl/golden/local-multi/data.hcl b/posthog/clickhouse/hcl/golden/local-multi/data.hclindex afcaa722337c..be951d1b9dbb 100644--- a/posthog/clickhouse/hcl/golden/local-multi/data.hcl+++ b/posthog/clickhouse/hcl/golden/local-multi/data.hcl@@ -7748,6 +7748,80 @@ database "posthog" {}}+ table "warehouse_object_reads_daily" {+ column "team_id" {+ type = "Int64"+ }+ column "day" {+ type = "Date"+ }+ column "read_kind" {+ type = "Enum8('read'=1, 'refresh'=2)"+ }+ column "subject_kind" {+ type = "Enum8('saved_query'=1, 'table'=2)"+ }+ column "subject_id" {+ type = "String"+ }+ column "workflow_id" {+ type = "String"+ }+ column "lc_kind" {+ type = "LowCardinality(String)"+ }+ column "lc_product" {+ type = "LowCardinality(String)"+ }+ column "lc_feature" {+ type = "LowCardinality(String)"+ }+ column "lc_access_method" {+ type = "LowCardinality(String)"+ }+ column "source" {+ type = "LowCardinality(String)"+ }+ column "scene" {+ type = "LowCardinality(String)"+ }+ column "has_user_id" {+ type = "Bool"+ }+ column "read_alone" {+ type = "Bool"+ }+ column "requests" {+ type = "AggregateFunction(uniq, String)"+ }+ column "users" {+ type = "AggregateFunction(uniq, Int64)"+ }+ column "read_count" {+ type = "SimpleAggregateFunction(sum, UInt64)"+ }+ column "duration_ms_sum" {+ type = "SimpleAggregateFunction(sum, UInt64)"+ }+ column "read_bytes_sum" {+ type = "SimpleAggregateFunction(sum, UInt64)"+ }+ column "duration_ms_quantiles" {+ type = "AggregateFunction(quantiles(0.5, 0.9), UInt64)"+ }+ column "read_bytes_quantiles" {+ type = "AggregateFunction(quantiles(0.5, 0.9), UInt64)"+ }+ column "max_event_time" {+ type = "SimpleAggregateFunction(max, DateTime)"+ }+ engine "distributed" {+ cluster_name = "aux"+ remote_database = "posthog"+ remote_table = "sharded_warehouse_object_reads_daily"+ }+ }+table "web_bot_definition" {column "id" {type = "UInt64"diff --git a/posthog/clickhouse/hcl/golden/local-single/all.hcl b/posthog/clickhouse/hcl/golden/local-single/all.hclindex 02d8c25ad8ad..bf7c4edb8bce 100644--- a/posthog/clickhouse/hcl/golden/local-single/all.hcl+++ b/posthog/clickhouse/hcl/golden/local-single/all.hcl@@ -14283,6 +14283,166 @@ SQL}}+ table "sharded_warehouse_object_reads_daily" {+ order_by = ["team_id", "day", "read_kind", "subject_kind", "subject_id", "workflow_id", "lc_kind", "lc_product", "lc_feature", "lc_access_method", "source", "scene", "has_user_id", "read_alone"]+ partition_by = "toYYYYMMDD(day)"+ ttl = "day + toIntervalDay(60)"+ settings = {+ index_granularity = "8192"+ ttl_only_drop_parts = "1"+ }+ column "team_id" {+ type = "Int64"+ }+ column "day" {+ type = "Date"+ }+ column "read_kind" {+ type = "Enum8('read'=1, 'refresh'=2)"+ }+ column "subject_kind" {+ type = "Enum8('saved_query'=1, 'table'=2)"+ }+ column "subject_id" {+ type = "String"+ }+ column "workflow_id" {+ type = "String"+ }+ column "lc_kind" {+ type = "LowCardinality(String)"+ }+ column "lc_product" {+ type = "LowCardinality(String)"+ }+ column "lc_feature" {+ type = "LowCardinality(String)"+ }+ column "lc_access_method" {+ type = "LowCardinality(String)"+ }+ column "source" {+ type = "LowCardinality(String)"+ }+ column "scene" {+ type = "LowCardinality(String)"+ }+ column "has_user_id" {+ type = "Bool"+ }+ column "read_alone" {+ type = "Bool"+ }+ column "requests" {+ type = "AggregateFunction(uniq, String)"+ }+ column "users" {+ type = "AggregateFunction(uniq, Int64)"+ }+ column "read_count" {+ type = "SimpleAggregateFunction(sum, UInt64)"+ }+ column "duration_ms_sum" {+ type = "SimpleAggregateFunction(sum, UInt64)"+ }+ column "read_bytes_sum" {+ type = "SimpleAggregateFunction(sum, UInt64)"+ }+ column "duration_ms_quantiles" {+ type = "AggregateFunction(quantiles(0.5, 0.9), UInt64)"+ }+ column "read_bytes_quantiles" {+ type = "AggregateFunction(quantiles(0.5, 0.9), UInt64)"+ }+ column "max_event_time" {+ type = "SimpleAggregateFunction(max, DateTime)"+ }+ engine "replicated_aggregating_merge_tree" {+ zoo_path = "/clickhouse/tables/noshard/posthog.warehouse_object_reads_daily"+ replica_name = "{replica}-{shard}"+ }+ }++ table "sharded_warehouse_object_reads_daily_staging" {+ order_by = ["team_id", "day", "read_kind", "subject_kind", "subject_id", "workflow_id", "lc_kind", "lc_product", "lc_feature", "lc_access_method", "source", "scene", "has_user_id", "read_alone"]+ partition_by = "toYYYYMMDD(day)"+ ttl = "day + toIntervalDay(60)"+ settings = {+ index_granularity = "8192"+ ttl_only_drop_parts = "1"+ }+ column "team_id" {+ type = "Int64"+ }+ column "day" {+ type = "Date"+ }+ column "read_kind" {+ type = "Enum8('read'=1, 'refresh'=2)"+ }+ column "subject_kind" {+ type = "Enum8('saved_query'=1, 'table'=2)"+ }+ column "subject_id" {+ type = "String"+ }+ column "workflow_id" {+ type = "String"+ }+ column "lc_kind" {+ type = "LowCardinality(String)"+ }+ column "lc_product" {+ type = "LowCardinality(String)"+ }+ column "lc_feature" {+ type = "LowCardinality(String)"+ }+ column "lc_access_method" {+ type = "LowCardinality(String)"+ }+ column "source" {+ type = "LowCardinality(String)"+ }+ column "scene" {+ type = "LowCardinality(String)"+ }+ column "has_user_id" {+ type = "Bool"+ }+ column "read_alone" {+ type = "Bool"+ }+ column "requests" {+ type = "AggregateFunction(uniq, String)"+ }+ column "users" {+ type = "AggregateFunction(uniq, Int64)"+ }+ column "read_count" {+ type = "SimpleAggregateFunction(sum, UInt64)"+ }+ column "duration_ms_sum" {+ type = "SimpleAggregateFunction(sum, UInt64)"+ }+ column "read_bytes_sum" {+ type = "SimpleAggregateFunction(sum, UInt64)"+ }+ column "duration_ms_quantiles" {+ type = "AggregateFunction(quantiles(0.5, 0.9), UInt64)"+ }+ column "read_bytes_quantiles" {+ type = "AggregateFunction(quantiles(0.5, 0.9), UInt64)"+ }+ column "max_event_time" {+ type = "SimpleAggregateFunction(max, DateTime)"+ }+ engine "replicated_aggregating_merge_tree" {+ zoo_path = "/clickhouse/tables/noshard/posthog.sharded_warehouse_object_reads_daily_staging"+ replica_name = "{replica}-{shard}"+ }+ }+table "sharded_web_bot_definition" {order_by = ["id"]settings = {@@ -15528,6 +15688,80 @@ SQL}}+ table "warehouse_object_reads_daily" {+ column "team_id" {+ type = "Int64"+ }+ column "day" {+ type = "Date"+ }+ column "read_kind" {+ type = "Enum8('read'=1, 'refresh'=2)"+ }+ column "subject_kind" {+ type = "Enum8('saved_query'=1, 'table'=2)"+ }+ column "subject_id" {+ type = "String"+ }+ column "workflow_id" {+ type = "String"+ }+ column "lc_kind" {+ type = "LowCardinality(String)"+ }+ column "lc_product" {+ type = "LowCardinality(String)"+ }+ column "lc_feature" {+ type = "LowCardinality(String)"+ }+ column "lc_access_method" {+ type = "LowCardinality(String)"+ }+ column "source" {+ type = "LowCardinality(String)"+ }+ column "scene" {+ type = "LowCardinality(String)"+ }+ column "has_user_id" {+ type = "Bool"+ }+ column "read_alone" {+ type = "Bool"+ }+ column "requests" {+ type = "AggregateFunction(uniq, String)"+ }+ column "users" {+ type = "AggregateFunction(uniq, Int64)"+ }+ column "read_count" {+ type = "SimpleAggregateFunction(sum, UInt64)"+ }+ column "duration_ms_sum" {+ type = "SimpleAggregateFunction(sum, UInt64)"+ }+ column "read_bytes_sum" {+ type = "SimpleAggregateFunction(sum, UInt64)"+ }+ column "duration_ms_quantiles" {+ type = "AggregateFunction(quantiles(0.5, 0.9), UInt64)"+ }+ column "read_bytes_quantiles" {+ type = "AggregateFunction(quantiles(0.5, 0.9), UInt64)"+ }+ column "max_event_time" {+ type = "SimpleAggregateFunction(max, DateTime)"+ }+ engine "distributed" {+ cluster_name = "aux"+ remote_database = "posthog"+ remote_table = "sharded_warehouse_object_reads_daily"+ }+ }+table "web_bot_definition" {column "id" {type = "UInt64"diff --git a/posthog/clickhouse/hcl/golden/prod-eu/auxiliary.hcl b/posthog/clickhouse/hcl/golden/prod-eu/auxiliary.hclindex cc42af8b4d16..2d92cac6dade 100644--- a/posthog/clickhouse/hcl/golden/prod-eu/auxiliary.hcl+++ b/posthog/clickhouse/hcl/golden/prod-eu/auxiliary.hcl@@ -2663,6 +2663,166 @@ database "posthog" {}}+ table "sharded_warehouse_object_reads_daily" {+ order_by = ["team_id", "day", "read_kind", "subject_kind", "subject_id", "workflow_id", "lc_kind", "lc_product", "lc_feature", "lc_access_method", "source", "scene", "has_user_id", "read_alone"]+ partition_by = "toYYYYMMDD(day)"+ ttl = "day + toIntervalDay(60)"+ settings = {+ index_granularity = "8192"+ ttl_only_drop_parts = "1"+ }+ column "team_id" {+ type = "Int64"+ }+ column "day" {+ type = "Date"+ }+ column "read_kind" {+ type = "Enum8('read'=1, 'refresh'=2)"+ }+ column "subject_kind" {+ type = "Enum8('saved_query'=1, 'table'=2)"+ }+ column "subject_id" {+ type = "String"+ }+ column "workflow_id" {+ type = "String"+ }+ column "lc_kind" {+ type = "LowCardinality(String)"+ }+ column "lc_product" {+ type = "LowCardinality(String)"+ }+ column "lc_feature" {+ type = "LowCardinality(String)"+ }+ column "lc_access_method" {+ type = "LowCardinality(String)"+ }+ column "source" {+ type = "LowCardinality(String)"+ }+ column "scene" {+ type = "LowCardinality(String)"+ }+ column "has_user_id" {+ type = "Bool"+ }+ column "read_alone" {+ type = "Bool"+ }+ column "requests" {+ type = "AggregateFunction(uniq, String)"+ }+ column "users" {+ type = "AggregateFunction(uniq, Int64)"+ }+ column "read_count" {+ type = "SimpleAggregateFunction(sum, UInt64)"+ }+ column "duration_ms_sum" {+ type = "SimpleAggregateFunction(sum, UInt64)"+ }+ column "read_bytes_sum" {+ type = "SimpleAggregateFunction(sum, UInt64)"+ }+ column "duration_ms_quantiles" {+ type = "AggregateFunction(quantiles(0.5, 0.9), UInt64)"+ }+ column "read_bytes_quantiles" {+ type = "AggregateFunction(quantiles(0.5, 0.9), UInt64)"+ }+ column "max_event_time" {+ type = "SimpleAggregateFunction(max, DateTime)"+ }+ engine "replicated_aggregating_merge_tree" {+ zoo_path = "/clickhouse/tables/noshard/posthog.warehouse_object_reads_daily"+ replica_name = "{replica}-{shard}"+ }+ }++ table "sharded_warehouse_object_reads_daily_staging" {+ order_by = ["team_id", "day", "read_kind", "subject_kind", "subject_id", "workflow_id", "lc_kind", "lc_product", "lc_feature", "lc_access_method", "source", "scene", "has_user_id", "read_alone"]+ partition_by = "toYYYYMMDD(day)"+ ttl = "day + toIntervalDay(60)"+ settings = {+ index_granularity = "8192"+ ttl_only_drop_parts = "1"+ }+ column "team_id" {+ type = "Int64"+ }+ column "day" {+ type = "Date"+ }+ column "read_kind" {+ type = "Enum8('read'=1, 'refresh'=2)"+ }+ column "subject_kind" {+ type = "Enum8('saved_query'=1, 'table'=2)"+ }+ column "subject_id" {+ type = "String"+ }+ column "workflow_id" {+ type = "String"+ }+ column "lc_kind" {+ type = "LowCardinality(String)"+ }+ column "lc_product" {+ type = "LowCardinality(String)"+ }+ column "lc_feature" {+ type = "LowCardinality(String)"+ }+ column "lc_access_method" {+ type = "LowCardinality(String)"+ }+ column "source" {+ type = "LowCardinality(String)"+ }+ column "scene" {+ type = "LowCardinality(String)"+ }+ column "has_user_id" {+ type = "Bool"+ }+ column "read_alone" {+ type = "Bool"+ }+ column "requests" {+ type = "AggregateFunction(uniq, String)"+ }+ column "users" {+ type = "AggregateFunction(uniq, Int64)"+ }+ column "read_count" {+ type = "SimpleAggregateFunction(sum, UInt64)"+ }+ column "duration_ms_sum" {+ type = "SimpleAggregateFunction(sum, UInt64)"+ }+ column "read_bytes_sum" {+ type = "SimpleAggregateFunction(sum, UInt64)"+ }+ column "duration_ms_quantiles" {+ type = "AggregateFunction(quantiles(0.5, 0.9), UInt64)"+ }+ column "read_bytes_quantiles" {+ type = "AggregateFunction(quantiles(0.5, 0.9), UInt64)"+ }+ column "max_event_time" {+ type = "SimpleAggregateFunction(max, DateTime)"+ }+ engine "replicated_aggregating_merge_tree" {+ zoo_path = "/clickhouse/tables/noshard/posthog.sharded_warehouse_object_reads_daily_staging"+ replica_name = "{replica}-{shard}"+ }+ }+table "sharded_web_bot_definition" {order_by = ["id"]settings = {@@ -3308,6 +3468,80 @@ database "posthog" {}}+ table "warehouse_object_reads_daily" {+ column "team_id" {+ type = "Int64"+ }+ column "day" {+ type = "Date"+ }+ column "read_kind" {+ type = "Enum8('read'=1, 'refresh'=2)"+ }+ column "subject_kind" {+ type = "Enum8('saved_query'=1, 'table'=2)"+ }+ column "subject_id" {+ type = "String"+ }+ column "workflow_id" {+ type = "String"+ }+ column "lc_kind" {+ type = "LowCardinality(String)"+ }+ column "lc_product" {+ type = "LowCardinality(String)"+ }+ column "lc_feature" {+ type = "LowCardinality(String)"+ }+ column "lc_access_method" {+ type = "LowCardinality(String)"+ }+ column "source" {+ type = "LowCardinality(String)"+ }+ column "scene" {+ type = "LowCardinality(String)"+ }+ column "has_user_id" {+ type = "Bool"+ }+ column "read_alone" {+ type = "Bool"+ }+ column "requests" {+ type = "AggregateFunction(uniq, String)"+ }+ column "users" {+ type = "AggregateFunction(uniq, Int64)"+ }+ column "read_count" {+ type = "SimpleAggregateFunction(sum, UInt64)"+ }+ column "duration_ms_sum" {+ type = "SimpleAggregateFunction(sum, UInt64)"+ }+ column "read_bytes_sum" {+ type = "SimpleAggregateFunction(sum, UInt64)"+ }+ column "duration_ms_quantiles" {+ type = "AggregateFunction(quantiles(0.5, 0.9), UInt64)"+ }+ column "read_bytes_quantiles" {+ type = "AggregateFunction(quantiles(0.5, 0.9), UInt64)"+ }+ column "max_event_time" {+ type = "SimpleAggregateFunction(max, DateTime)"+ }+ engine "distributed" {+ cluster_name = "aux"+ remote_database = "posthog"+ remote_table = "sharded_warehouse_object_reads_daily"+ }+ }+table "web_bot_definition" {column "id" {type = "UInt64"diff --git a/posthog/clickhouse/hcl/golden/prod-eu/data.hcl b/posthog/clickhouse/hcl/golden/prod-eu/data.hclindex 7923c453a275..69067173a70d 100644--- a/posthog/clickhouse/hcl/golden/prod-eu/data.hcl+++ b/posthog/clickhouse/hcl/golden/prod-eu/data.hcl@@ -6825,6 +6825,80 @@ database "posthog" {}}+ table "warehouse_object_reads_daily" {+ column "team_id" {+ type = "Int64"+ }+ column "day" {+ type = "Date"+ }+ column "read_kind" {+ type = "Enum8('read'=1, 'refresh'=2)"+ }+ column "subject_kind" {+ type = "Enum8('saved_query'=1, 'table'=2)"+ }+ column "subject_id" {+ type = "String"+ }+ column "workflow_id" {+ type = "String"+ }+ column "lc_kind" {+ type = "LowCardinality(String)"+ }+ column "lc_product" {+ type = "LowCardinality(String)"+ }+ column "lc_feature" {+ type = "LowCardinality(String)"+ }+ column "lc_access_method" {+ type = "LowCardinality(String)"+ }+ column "source" {+ type = "LowCardinality(String)"+ }+ column "scene" {+ type = "LowCardinality(String)"+ }+ column "has_user_id" {+ type = "Bool"+ }+ column "read_alone" {+ type = "Bool"+ }+ column "requests" {+ type = "AggregateFunction(uniq, String)"+ }+ column "users" {+ type = "AggregateFunction(uniq, Int64)"+ }+ column "read_count" {+ type = "SimpleAggregateFunction(sum, UInt64)"+ }+ column "duration_ms_sum" {+ type = "SimpleAggregateFunction(sum, UInt64)"+ }+ column "read_bytes_sum" {+ type = "SimpleAggregateFunction(sum, UInt64)"+ }+ column "duration_ms_quantiles" {+ type = "AggregateFunction(quantiles(0.5, 0.9), UInt64)"+ }+ column "read_bytes_quantiles" {+ type = "AggregateFunction(quantiles(0.5, 0.9), UInt64)"+ }+ column "max_event_time" {+ type = "SimpleAggregateFunction(max, DateTime)"+ }+ engine "distributed" {+ cluster_name = "aux"+ remote_database = "posthog"+ remote_table = "sharded_warehouse_object_reads_daily"+ }+ }+table "web_bot_definition" {column "id" {type = "UInt64"diff --git a/posthog/clickhouse/hcl/golden/prod-us/auxiliary.hcl b/posthog/clickhouse/hcl/golden/prod-us/auxiliary.hclindex 0bd698ab53bf..05f7d1eba7d4 100644--- a/posthog/clickhouse/hcl/golden/prod-us/auxiliary.hcl+++ b/posthog/clickhouse/hcl/golden/prod-us/auxiliary.hcl@@ -2701,6 +2701,166 @@ database "posthog" {}}+ table "sharded_warehouse_object_reads_daily" {+ order_by = ["team_id", "day", "read_kind", "subject_kind", "subject_id", "workflow_id", "lc_kind", "lc_product", "lc_feature", "lc_access_method", "source", "scene", "has_user_id", "read_alone"]+ partition_by = "toYYYYMMDD(day)"+ ttl = "day + toIntervalDay(60)"+ settings = {+ index_granularity = "8192"+ ttl_only_drop_parts = "1"+ }+ column "team_id" {+ type = "Int64"+ }+ column "day" {+ type = "Date"+ }+ column "read_kind" {+ type = "Enum8('read'=1, 'refresh'=2)"+ }+ column "subject_kind" {+ type = "Enum8('saved_query'=1, 'table'=2)"+ }+ column "subject_id" {+ type = "String"+ }+ column "workflow_id" {+ type = "String"+ }+ column "lc_kind" {+ type = "LowCardinality(String)"+ }+ column "lc_product" {+ type = "LowCardinality(String)"+ }+ column "lc_feature" {+ type = "LowCardinality(String)"+ }+ column "lc_access_method" {+ type = "LowCardinality(String)"+ }+ column "source" {+ type = "LowCardinality(String)"+ }+ column "scene" {+ type = "LowCardinality(String)"+ }+ column "has_user_id" {+ type = "Bool"+ }+ column "read_alone" {+ type = "Bool"+ }+ column "requests" {+ type = "AggregateFunction(uniq, String)"+ }+ column "users" {+ type = "AggregateFunction(uniq, Int64)"+ }+ column "read_count" {+ type = "SimpleAggregateFunction(sum, UInt64)"+ }+ column "duration_ms_sum" {+ type = "SimpleAggregateFunction(sum, UInt64)"+ }+ column "read_bytes_sum" {+ type = "SimpleAggregateFunction(sum, UInt64)"+ }+ column "duration_ms_quantiles" {+ type = "AggregateFunction(quantiles(0.5, 0.9), UInt64)"+ }+ column "read_bytes_quantiles" {+ type = "AggregateFunction(quantiles(0.5, 0.9), UInt64)"+ }+ column "max_event_time" {+ type = "SimpleAggregateFunction(max, DateTime)"+ }+ engine "replicated_aggregating_merge_tree" {+ zoo_path = "/clickhouse/tables/noshard/posthog.warehouse_object_reads_daily"+ replica_name = "{replica}-{shard}"+ }+ }++ table "sharded_warehouse_object_reads_daily_staging" {+ order_by = ["team_id", "day", "read_kind", "subject_kind", "subject_id", "workflow_id", "lc_kind", "lc_product", "lc_feature", "lc_access_method", "source", "scene", "has_user_id", "read_alone"]+ partition_by = "toYYYYMMDD(day)"+ ttl = "day + toIntervalDay(60)"+ settings = {+ index_granularity = "8192"+ ttl_only_drop_parts = "1"+ }+ column "team_id" {+ type = "Int64"+ }+ column "day" {+ type = "Date"+ }+ column "read_kind" {+ type = "Enum8('read'=1, 'refresh'=2)"+ }+ column "subject_kind" {+ type = "Enum8('saved_query'=1, 'table'=2)"+ }+ column "subject_id" {+ type = "String"+ }+ column "workflow_id" {+ type = "String"+ }+ column "lc_kind" {+ type = "LowCardinality(String)"+ }+ column "lc_product" {+ type = "LowCardinality(String)"+ }+ column "lc_feature" {+ type = "LowCardinality(String)"+ }+ column "lc_access_method" {+ type = "LowCardinality(String)"+ }+ column "source" {+ type = "LowCardinality(String)"+ }+ column "scene" {+ type = "LowCardinality(String)"+ }+ column "has_user_id" {+ type = "Bool"+ }+ column "read_alone" {+ type = "Bool"+ }+ column "requests" {+ type = "AggregateFunction(uniq, String)"+ }+ column "users" {+ type = "AggregateFunction(uniq, Int64)"+ }+ column "read_count" {+ type = "SimpleAggregateFunction(sum, UInt64)"+ }+ column "duration_ms_sum" {+ type = "SimpleAggregateFunction(sum, UInt64)"+ }+ column "read_bytes_sum" {+ type = "SimpleAggregateFunction(sum, UInt64)"+ }+ column "duration_ms_quantiles" {+ type = "AggregateFunction(quantiles(0.5, 0.9), UInt64)"+ }+ column "read_bytes_quantiles" {+ type = "AggregateFunction(quantiles(0.5, 0.9), UInt64)"+ }+ column "max_event_time" {+ type = "SimpleAggregateFunction(max, DateTime)"+ }+ engine "replicated_aggregating_merge_tree" {+ zoo_path = "/clickhouse/tables/noshard/posthog.sharded_warehouse_object_reads_daily_staging"+ replica_name = "{replica}-{shard}"+ }+ }+table "sharded_web_bot_definition" {order_by = ["id"]settings = {@@ -3346,6 +3506,80 @@ database "posthog" {}}+ table "warehouse_object_reads_daily" {+ column "team_id" {+ type = "Int64"+ }+ column "day" {+ type = "Date"+ }+ column "read_kind" {+ type = "Enum8('read'=1, 'refresh'=2)"+ }+ column "subject_kind" {+ type = "Enum8('saved_query'=1, 'table'=2)"+ }+ column "subject_id" {+ type = "String"+ }+ column "workflow_id" {+ type = "String"+ }+ column "lc_kind" {+ type = "LowCardinality(String)"+ }+ column "lc_product" {+ type = "LowCardinality(String)"+ }+ column "lc_feature" {+ type = "LowCardinality(String)"+ }+ column "lc_access_method" {+ type = "LowCardinality(String)"+ }+ column "source" {+ type = "LowCardinality(String)"+ }+ column "scene" {+ type = "LowCardinality(String)"+ }+ column "has_user_id" {+ type = "Bool"+ }+ column "read_alone" {+ type = "Bool"+ }+ column "requests" {+ type = "AggregateFunction(uniq, String)"+ }+ column "users" {+ type = "AggregateFunction(uniq, Int64)"+ }+ column "read_count" {+ type = "SimpleAggregateFunction(sum, UInt64)"+ }+ column "duration_ms_sum" {+ type = "SimpleAggregateFunction(sum, UInt64)"+ }+ column "read_bytes_sum" {+ type = "SimpleAggregateFunction(sum, UInt64)"+ }+ column "duration_ms_quantiles" {+ type = "AggregateFunction(quantiles(0.5, 0.9), UInt64)"+ }+ column "read_bytes_quantiles" {+ type = "AggregateFunction(quantiles(0.5, 0.9), UInt64)"+ }+ column "max_event_time" {+ type = "SimpleAggregateFunction(max, DateTime)"+ }+ engine "distributed" {+ cluster_name = "aux"+ remote_database = "posthog"+ remote_table = "sharded_warehouse_object_reads_daily"+ }+ }+table "web_bot_definition" {column "id" {type = "UInt64"diff --git a/posthog/clickhouse/hcl/golden/prod-us/data.hcl b/posthog/clickhouse/hcl/golden/prod-us/data.hclindex d514cabc72a4..2a9d839a0823 100644--- a/posthog/clickhouse/hcl/golden/prod-us/data.hcl+++ b/posthog/clickhouse/hcl/golden/prod-us/data.hcl@@ -6588,6 +6588,80 @@ database "posthog" {}}+ table "warehouse_object_reads_daily" {+ column "team_id" {+ type = "Int64"+ }+ column "day" {+ type = "Date"+ }+ column "read_kind" {+ type = "Enum8('read'=1, 'refresh'=2)"+ }+ column "subject_kind" {+ type = "Enum8('saved_query'=1, 'table'=2)"+ }+ column "subject_id" {+ type = "String"+ }+ column "workflow_id" {+ type = "String"+ }+ column "lc_kind" {+ type = "LowCardinality(String)"+ }+ column "lc_product" {+ type = "LowCardinality(String)"+ }+ column "lc_feature" {+ type = "LowCardinality(String)"+ }+ column "lc_access_method" {+ type = "LowCardinality(String)"+ }+ column "source" {+ type = "LowCardinality(String)"+ }+ column "scene" {+ type = "LowCardinality(String)"+ }+ column "has_user_id" {+ type = "Bool"+ }+ column "read_alone" {+ type = "Bool"+ }+ column "requests" {+ type = "AggregateFunction(uniq, String)"+ }+ column "users" {+ type = "AggregateFunction(uniq, Int64)"+ }+ column "read_count" {+ type = "SimpleAggregateFunction(sum, UInt64)"+ }+ column "duration_ms_sum" {+ type = "SimpleAggregateFunction(sum, UInt64)"+ }+ column "read_bytes_sum" {+ type = "SimpleAggregateFunction(sum, UInt64)"+ }+ column "duration_ms_quantiles" {+ type = "AggregateFunction(quantiles(0.5, 0.9), UInt64)"+ }+ column "read_bytes_quantiles" {+ type = "AggregateFunction(quantiles(0.5, 0.9), UInt64)"+ }+ column "max_event_time" {+ type = "SimpleAggregateFunction(max, DateTime)"+ }+ engine "distributed" {+ cluster_name = "aux"+ remote_database = "posthog"+ remote_table = "sharded_warehouse_object_reads_daily"+ }+ }+table "web_bot_definition" {column "id" {type = "UInt64"diff --git a/posthog/clickhouse/hcl/roles/auxiliary/shared/tables.hcl b/posthog/clickhouse/hcl/roles/auxiliary/shared/tables.hclindex 504572a42bd2..12981f14e134 100644--- a/posthog/clickhouse/hcl/roles/auxiliary/shared/tables.hcl+++ b/posthog/clickhouse/hcl/roles/auxiliary/shared/tables.hcl@@ -1103,4 +1103,32 @@ database "posthog" {skip_broken_messages = 100}}+ table "sharded_warehouse_object_reads_daily" {+ partition_by = "toYYYYMMDD(day)"+ order_by = ["team_id", "day", "read_kind", "subject_kind", "subject_id", "workflow_id", "lc_kind", "lc_product", "lc_feature", "lc_access_method", "source", "scene", "has_user_id", "read_alone"]+ ttl = "day + toIntervalDay(60)"+ settings = {+ index_granularity = "8192"+ ttl_only_drop_parts = "1"+ }+ extend = "_warehouse_object_reads_daily_columns"+ engine "replicated_aggregating_merge_tree" {+ zoo_path = "/clickhouse/tables/noshard/posthog.warehouse_object_reads_daily"+ replica_name = "{replica}-{shard}"+ }+ }+ table "sharded_warehouse_object_reads_daily_staging" {+ partition_by = "toYYYYMMDD(day)"+ order_by = ["team_id", "day", "read_kind", "subject_kind", "subject_id", "workflow_id", "lc_kind", "lc_product", "lc_feature", "lc_access_method", "source", "scene", "has_user_id", "read_alone"]+ ttl = "day + toIntervalDay(60)"+ settings = {+ index_granularity = "8192"+ ttl_only_drop_parts = "1"+ }+ extend = "_warehouse_object_reads_daily_columns"+ engine "replicated_aggregating_merge_tree" {+ zoo_path = "/clickhouse/tables/noshard/posthog.sharded_warehouse_object_reads_daily_staging"+ replica_name = "{replica}-{shard}"+ }+ }}diff --git a/posthog/clickhouse/hcl/roles/coshared/aux_data/tables.hcl b/posthog/clickhouse/hcl/roles/coshared/aux_data/tables.hclindex e3d57f247e37..24a74eed16cb 100644--- a/posthog/clickhouse/hcl/roles/coshared/aux_data/tables.hcl+++ b/posthog/clickhouse/hcl/roles/coshared/aux_data/tables.hcl@@ -1015,6 +1015,75 @@ database "posthog" {default = "now() + toIntervalDay(7)"}}+ table "_warehouse_object_reads_daily_columns" {+ abstract = true+ column "team_id" {+ type = "Int64"+ }+ column "day" {+ type = "Date"+ }+ column "read_kind" {+ type = "Enum8('read'=1, 'refresh'=2)"+ }+ column "subject_kind" {+ type = "Enum8('saved_query'=1, 'table'=2)"+ }+ column "subject_id" {+ type = "String"+ }+ column "workflow_id" {+ type = "String"+ }+ column "lc_kind" {+ type = "LowCardinality(String)"+ }+ column "lc_product" {+ type = "LowCardinality(String)"+ }+ column "lc_feature" {+ type = "LowCardinality(String)"+ }+ column "lc_access_method" {+ type = "LowCardinality(String)"+ }+ column "source" {+ type = "LowCardinality(String)"+ }+ column "scene" {+ type = "LowCardinality(String)"+ }+ column "has_user_id" {+ type = "Bool"+ }+ column "read_alone" {+ type = "Bool"+ }+ column "requests" {+ type = "AggregateFunction(uniq, String)"+ }+ column "users" {+ type = "AggregateFunction(uniq, Int64)"+ }+ column "read_count" {+ type = "SimpleAggregateFunction(sum, UInt64)"+ }+ column "duration_ms_sum" {+ type = "SimpleAggregateFunction(sum, UInt64)"+ }+ column "read_bytes_sum" {+ type = "SimpleAggregateFunction(sum, UInt64)"+ }+ column "duration_ms_quantiles" {+ type = "AggregateFunction(quantiles(0.5, 0.9), UInt64)"+ }+ column "read_bytes_quantiles" {+ type = "AggregateFunction(quantiles(0.5, 0.9), UInt64)"+ }+ column "max_event_time" {+ type = "SimpleAggregateFunction(max, DateTime)"+ }+ }table "conversion_goal_attributed_preaggregated" {extend = "_conversion_goal_attributed_preaggregated_columns"engine "distributed" {@@ -1409,4 +1478,12 @@ database "posthog" {layout "regexp_tree" {}}+ table "warehouse_object_reads_daily" {+ extend = "_warehouse_object_reads_daily_columns"+ engine "distributed" {+ cluster_name = "aux"+ remote_database = "posthog"+ remote_table = "sharded_warehouse_object_reads_daily"+ }+ }}diff --git a/posthog/clickhouse/hcl/sql/dev/auxiliary.sql b/posthog/clickhouse/hcl/sql/dev/auxiliary.sqlindex 7183e4f4e0bd..0960505d88d0 100644--- a/posthog/clickhouse/hcl/sql/dev/auxiliary.sql+++ b/posthog/clickhouse/hcl/sql/dev/auxiliary.sql@@ -532,6 +532,54 @@ CREATE TABLE posthog.sharded_usage_report_events_preagg (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_warehouse_object_reads_daily (+ team_id Int64,+ day Date,+ read_kind Enum8('read'=1, 'refresh'=2),+ subject_kind Enum8('saved_query'=1, 'table'=2),+ subject_id String,+ workflow_id String,+ lc_kind LowCardinality(String),+ lc_product LowCardinality(String),+ lc_feature LowCardinality(String),+ lc_access_method LowCardinality(String),+ source LowCardinality(String),+ scene LowCardinality(String),+ has_user_id Bool,+ read_alone Bool,+ requests AggregateFunction(uniq, String),+ users AggregateFunction(uniq, Int64),+ read_count SimpleAggregateFunction(sum, UInt64),+ duration_ms_sum SimpleAggregateFunction(sum, UInt64),+ read_bytes_sum SimpleAggregateFunction(sum, UInt64),+ duration_ms_quantiles AggregateFunction(quantiles(0.5, 0.9), UInt64),+ read_bytes_quantiles AggregateFunction(quantiles(0.5, 0.9), UInt64),+ max_event_time SimpleAggregateFunction(max, DateTime)+) ENGINE = ReplicatedAggregatingMergeTree('/clickhouse/tables/noshard/posthog.warehouse_object_reads_daily', '{replica}-{shard}') ORDER BY (team_id, day, read_kind, subject_kind, subject_id, workflow_id, lc_kind, lc_product, lc_feature, lc_access_method, source, scene, has_user_id, read_alone) PARTITION BY toYYYYMMDD(day) TTL day + toIntervalDay(60) SETTINGS index_granularity = 8192, ttl_only_drop_parts = 1;+CREATE TABLE posthog.sharded_warehouse_object_reads_daily_staging (+ team_id Int64,+ day Date,+ read_kind Enum8('read'=1, 'refresh'=2),+ subject_kind Enum8('saved_query'=1, 'table'=2),+ subject_id String,+ workflow_id String,+ lc_kind LowCardinality(String),+ lc_product LowCardinality(String),+ lc_feature LowCardinality(String),+ lc_access_method LowCardinality(String),+ source LowCardinality(String),+ scene LowCardinality(String),+ has_user_id Bool,+ read_alone Bool,+ requests AggregateFunction(uniq, String),+ users AggregateFunction(uniq, Int64),+ read_count SimpleAggregateFunction(sum, UInt64),+ duration_ms_sum SimpleAggregateFunction(sum, UInt64),+ read_bytes_sum SimpleAggregateFunction(sum, UInt64),+ duration_ms_quantiles AggregateFunction(quantiles(0.5, 0.9), UInt64),+ read_bytes_quantiles AggregateFunction(quantiles(0.5, 0.9), UInt64),+ max_event_time SimpleAggregateFunction(max, DateTime)+) ENGINE = ReplicatedAggregatingMergeTree('/clickhouse/tables/noshard/posthog.sharded_warehouse_object_reads_daily_staging', '{replica}-{shard}') ORDER BY (team_id, day, read_kind, subject_kind, subject_id, workflow_id, lc_kind, lc_product, lc_feature, lc_access_method, source, scene, has_user_id, read_alone) PARTITION BY toYYYYMMDD(day) TTL day + toIntervalDay(60) SETTINGS index_granularity = 8192, ttl_only_drop_parts = 1;CREATE TABLE posthog.sharded_web_bot_definition (id UInt64,parent_id UInt64,@@ -708,6 +756,30 @@ CREATE TABLE posthog.sharded_web_vitals_paths_preaggregated (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.warehouse_object_reads_daily (+ team_id Int64,+ day Date,+ read_kind Enum8('read'=1, 'refresh'=2),+ subject_kind Enum8('saved_query'=1, 'table'=2),+ subject_id String,+ workflow_id String,+ lc_kind LowCardinality(String),+ lc_product LowCardinality(String),+ lc_feature LowCardinality(String),+ lc_access_method LowCardinality(String),+ source LowCardinality(String),+ scene LowCardinality(String),+ has_user_id Bool,+ read_alone Bool,+ requests AggregateFunction(uniq, String),+ users AggregateFunction(uniq, Int64),+ read_count SimpleAggregateFunction(sum, UInt64),+ duration_ms_sum SimpleAggregateFunction(sum, UInt64),+ read_bytes_sum SimpleAggregateFunction(sum, UInt64),+ duration_ms_quantiles AggregateFunction(quantiles(0.5, 0.9), UInt64),+ read_bytes_quantiles AggregateFunction(quantiles(0.5, 0.9), UInt64),+ max_event_time SimpleAggregateFunction(max, DateTime)+) ENGINE = Distributed('aux', 'posthog', 'sharded_warehouse_object_reads_daily');CREATE TABLE posthog.web_bot_definition (id UInt64,parent_id UInt64,diff --git a/posthog/clickhouse/hcl/sql/dev/data.sql b/posthog/clickhouse/hcl/sql/dev/data.sqlindex f1b9bec617ab..fee75254b0d9 100644--- a/posthog/clickhouse/hcl/sql/dev/data.sql+++ b/posthog/clickhouse/hcl/sql/dev/data.sql@@ -1518,6 +1518,30 @@ CREATE TABLE posthog.usage_report_events_preagg (distinct_events_unique AggregateFunction(uniqExact, Tuple(UInt64, UInt64, UInt64)),event_count AggregateFunction(sum, UInt64)) ENGINE = Distributed('aux', 'posthog', 'sharded_usage_report_events_preagg', sipHash64(date));+CREATE TABLE posthog.warehouse_object_reads_daily (+ team_id Int64,+ day Date,+ read_kind Enum8('read'=1, 'refresh'=2),+ subject_kind Enum8('saved_query'=1, 'table'=2),+ subject_id String,+ workflow_id String,+ lc_kind LowCardinality(String),+ lc_product LowCardinality(String),+ lc_feature LowCardinality(String),+ lc_access_method LowCardinality(String),+ source LowCardinality(String),+ scene LowCardinality(String),+ has_user_id Bool,+ read_alone Bool,+ requests AggregateFunction(uniq, String),+ users AggregateFunction(uniq, Int64),+ read_count SimpleAggregateFunction(sum, UInt64),+ duration_ms_sum SimpleAggregateFunction(sum, UInt64),+ read_bytes_sum SimpleAggregateFunction(sum, UInt64),+ duration_ms_quantiles AggregateFunction(quantiles(0.5, 0.9), UInt64),+ read_bytes_quantiles AggregateFunction(quantiles(0.5, 0.9), UInt64),+ max_event_time SimpleAggregateFunction(max, DateTime)+) ENGINE = Distributed('aux', 'posthog', 'sharded_warehouse_object_reads_daily');CREATE TABLE posthog.web_bot_definition (id UInt64,parent_id UInt64,diff --git a/posthog/clickhouse/hcl/sql/local-multi/auxiliary.sql b/posthog/clickhouse/hcl/sql/local-multi/auxiliary.sqlindex 2f0e66bd2b8a..b7e91d4434d5 100644--- a/posthog/clickhouse/hcl/sql/local-multi/auxiliary.sql+++ b/posthog/clickhouse/hcl/sql/local-multi/auxiliary.sql@@ -536,6 +536,54 @@ CREATE TABLE posthog.sharded_usage_report_events_preagg (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_warehouse_object_reads_daily (+ team_id Int64,+ day Date,+ read_kind Enum8('read'=1, 'refresh'=2),+ subject_kind Enum8('saved_query'=1, 'table'=2),+ subject_id String,+ workflow_id String,+ lc_kind LowCardinality(String),+ lc_product LowCardinality(String),+ lc_feature LowCardinality(String),+ lc_access_method LowCardinality(String),+ source LowCardinality(String),+ scene LowCardinality(String),+ has_user_id Bool,+ read_alone Bool,+ requests AggregateFunction(uniq, String),+ users AggregateFunction(uniq, Int64),+ read_count SimpleAggregateFunction(sum, UInt64),+ duration_ms_sum SimpleAggregateFunction(sum, UInt64),+ read_bytes_sum SimpleAggregateFunction(sum, UInt64),+ duration_ms_quantiles AggregateFunction(quantiles(0.5, 0.9), UInt64),+ read_bytes_quantiles AggregateFunction(quantiles(0.5, 0.9), UInt64),+ max_event_time SimpleAggregateFunction(max, DateTime)+) ENGINE = ReplicatedAggregatingMergeTree('/clickhouse/tables/noshard/posthog.warehouse_object_reads_daily', '{replica}-{shard}') ORDER BY (team_id, day, read_kind, subject_kind, subject_id, workflow_id, lc_kind, lc_product, lc_feature, lc_access_method, source, scene, has_user_id, read_alone) PARTITION BY toYYYYMMDD(day) TTL day + toIntervalDay(60) SETTINGS index_granularity = 8192, ttl_only_drop_parts = 1;+CREATE TABLE posthog.sharded_warehouse_object_reads_daily_staging (+ team_id Int64,+ day Date,+ read_kind Enum8('read'=1, 'refresh'=2),+ subject_kind Enum8('saved_query'=1, 'table'=2),+ subject_id String,+ workflow_id String,+ lc_kind LowCardinality(String),+ lc_product LowCardinality(String),+ lc_feature LowCardinality(String),+ lc_access_method LowCardinality(String),+ source LowCardinality(String),+ scene LowCardinality(String),+ has_user_id Bool,+ read_alone Bool,+ requests AggregateFunction(uniq, String),+ users AggregateFunction(uniq, Int64),+ read_count SimpleAggregateFunction(sum, UInt64),+ duration_ms_sum SimpleAggregateFunction(sum, UInt64),+ read_bytes_sum SimpleAggregateFunction(sum, UInt64),+ duration_ms_quantiles AggregateFunction(quantiles(0.5, 0.9), UInt64),+ read_bytes_quantiles AggregateFunction(quantiles(0.5, 0.9), UInt64),+ max_event_time SimpleAggregateFunction(max, DateTime)+) ENGINE = ReplicatedAggregatingMergeTree('/clickhouse/tables/noshard/posthog.sharded_warehouse_object_reads_daily_staging', '{replica}-{shard}') ORDER BY (team_id, day, read_kind, subject_kind, subject_id, workflow_id, lc_kind, lc_product, lc_feature, lc_access_method, source, scene, has_user_id, read_alone) PARTITION BY toYYYYMMDD(day) TTL day + toIntervalDay(60) SETTINGS index_granularity = 8192, ttl_only_drop_parts = 1;CREATE TABLE posthog.sharded_web_bot_definition (id UInt64,parent_id UInt64,@@ -712,6 +760,30 @@ CREATE TABLE posthog.sharded_web_vitals_paths_preaggregated (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.warehouse_object_reads_daily (+ team_id Int64,+ day Date,+ read_kind Enum8('read'=1, 'refresh'=2),+ subject_kind Enum8('saved_query'=1, 'table'=2),+ subject_id String,+ workflow_id String,+ lc_kind LowCardinality(String),+ lc_product LowCardinality(String),+ lc_feature LowCardinality(String),+ lc_access_method LowCardinality(String),+ source LowCardinality(String),+ scene LowCardinality(String),+ has_user_id Bool,+ read_alone Bool,+ requests AggregateFunction(uniq, String),+ users AggregateFunction(uniq, Int64),+ read_count SimpleAggregateFunction(sum, UInt64),+ duration_ms_sum SimpleAggregateFunction(sum, UInt64),+ read_bytes_sum SimpleAggregateFunction(sum, UInt64),+ duration_ms_quantiles AggregateFunction(quantiles(0.5, 0.9), UInt64),+ read_bytes_quantiles AggregateFunction(quantiles(0.5, 0.9), UInt64),+ max_event_time SimpleAggregateFunction(max, DateTime)+) ENGINE = Distributed('aux', 'posthog', 'sharded_warehouse_object_reads_daily');CREATE TABLE posthog.web_bot_definition (id UInt64,parent_id UInt64,diff --git a/posthog/clickhouse/hcl/sql/local-multi/data.sql b/posthog/clickhouse/hcl/sql/local-multi/data.sqlindex aeb796d31f48..52900357fe49 100644--- a/posthog/clickhouse/hcl/sql/local-multi/data.sql+++ b/posthog/clickhouse/hcl/sql/local-multi/data.sql@@ -1696,6 +1696,30 @@ CREATE TABLE posthog.usage_report_events_preagg (distinct_events_unique AggregateFunction(uniqExact, Tuple(UInt64, UInt64, UInt64)),event_count AggregateFunction(sum, UInt64)) ENGINE = Distributed('aux', 'posthog', 'sharded_usage_report_events_preagg', sipHash64(date));+CREATE TABLE posthog.warehouse_object_reads_daily (+ team_id Int64,+ day Date,+ read_kind Enum8('read'=1, 'refresh'=2),+ subject_kind Enum8('saved_query'=1, 'table'=2),+ subject_id String,+ workflow_id String,+ lc_kind LowCardinality(String),+ lc_product LowCardinality(String),+ lc_feature LowCardinality(String),+ lc_access_method LowCardinality(String),+ source LowCardinality(String),+ scene LowCardinality(String),+ has_user_id Bool,+ read_alone Bool,+ requests AggregateFunction(uniq, String),+ users AggregateFunction(uniq, Int64),+ read_count SimpleAggregateFunction(sum, UInt64),+ duration_ms_sum SimpleAggregateFunction(sum, UInt64),+ read_bytes_sum SimpleAggregateFunction(sum, UInt64),+ duration_ms_quantiles AggregateFunction(quantiles(0.5, 0.9), UInt64),+ read_bytes_quantiles AggregateFunction(quantiles(0.5, 0.9), UInt64),+ max_event_time SimpleAggregateFunction(max, DateTime)+) ENGINE = Distributed('aux', 'posthog', 'sharded_warehouse_object_reads_daily');CREATE TABLE posthog.web_bot_definition (id UInt64,parent_id UInt64,diff --git a/posthog/clickhouse/hcl/sql/local-single/all.sql b/posthog/clickhouse/hcl/sql/local-single/all.sqlindex dfe18477f035..9fbb043557bd 100644--- a/posthog/clickhouse/hcl/sql/local-single/all.sql+++ b/posthog/clickhouse/hcl/sql/local-single/all.sql@@ -2984,6 +2984,54 @@ CREATE TABLE posthog.sharded_usage_report_events_preagg (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_warehouse_object_reads_daily (+ team_id Int64,+ day Date,+ read_kind Enum8('read'=1, 'refresh'=2),+ subject_kind Enum8('saved_query'=1, 'table'=2),+ subject_id String,+ workflow_id String,+ lc_kind LowCardinality(String),+ lc_product LowCardinality(String),+ lc_feature LowCardinality(String),+ lc_access_method LowCardinality(String),+ source LowCardinality(String),+ scene LowCardinality(String),+ has_user_id Bool,+ read_alone Bool,+ requests AggregateFunction(uniq, String),+ users AggregateFunction(uniq, Int64),+ read_count SimpleAggregateFunction(sum, UInt64),+ duration_ms_sum SimpleAggregateFunction(sum, UInt64),+ read_bytes_sum SimpleAggregateFunction(sum, UInt64),+ duration_ms_quantiles AggregateFunction(quantiles(0.5, 0.9), UInt64),+ read_bytes_quantiles AggregateFunction(quantiles(0.5, 0.9), UInt64),+ max_event_time SimpleAggregateFunction(max, DateTime)+) ENGINE = ReplicatedAggregatingMergeTree('/clickhouse/tables/noshard/posthog.warehouse_object_reads_daily', '{replica}-{shard}') ORDER BY (team_id, day, read_kind, subject_kind, subject_id, workflow_id, lc_kind, lc_product, lc_feature, lc_access_method, source, scene, has_user_id, read_alone) PARTITION BY toYYYYMMDD(day) TTL day + toIntervalDay(60) SETTINGS index_granularity = 8192, ttl_only_drop_parts = 1;+CREATE TABLE posthog.sharded_warehouse_object_reads_daily_staging (+ team_id Int64,+ day Date,+ read_kind Enum8('read'=1, 'refresh'=2),+ subject_kind Enum8('saved_query'=1, 'table'=2),+ subject_id String,+ workflow_id String,+ lc_kind LowCardinality(String),+ lc_product LowCardinality(String),+ lc_feature LowCardinality(String),+ lc_access_method LowCardinality(String),+ source LowCardinality(String),+ scene LowCardinality(String),+ has_user_id Bool,+ read_alone Bool,+ requests AggregateFunction(uniq, String),+ users AggregateFunction(uniq, Int64),+ read_count SimpleAggregateFunction(sum, UInt64),+ duration_ms_sum SimpleAggregateFunction(sum, UInt64),+ read_bytes_sum SimpleAggregateFunction(sum, UInt64),+ duration_ms_quantiles AggregateFunction(quantiles(0.5, 0.9), UInt64),+ read_bytes_quantiles AggregateFunction(quantiles(0.5, 0.9), UInt64),+ max_event_time SimpleAggregateFunction(max, DateTime)+) ENGINE = ReplicatedAggregatingMergeTree('/clickhouse/tables/noshard/posthog.sharded_warehouse_object_reads_daily_staging', '{replica}-{shard}') ORDER BY (team_id, day, read_kind, subject_kind, subject_id, workflow_id, lc_kind, lc_product, lc_feature, lc_access_method, source, scene, has_user_id, read_alone) PARTITION BY toYYYYMMDD(day) TTL day + toIntervalDay(60) SETTINGS index_granularity = 8192, ttl_only_drop_parts = 1;CREATE TABLE posthog.sharded_web_bot_definition (id UInt64,parent_id UInt64,@@ -3332,6 +3380,30 @@ CREATE TABLE posthog.usage_report_events_preagg (distinct_events_unique AggregateFunction(uniqExact, Tuple(UInt64, UInt64, UInt64)),event_count AggregateFunction(sum, UInt64)) ENGINE = Distributed('aux', 'posthog', 'sharded_usage_report_events_preagg', sipHash64(date));+CREATE TABLE posthog.warehouse_object_reads_daily (+ team_id Int64,+ day Date,+ read_kind Enum8('read'=1, 'refresh'=2),+ subject_kind Enum8('saved_query'=1, 'table'=2),+ subject_id String,+ workflow_id String,+ lc_kind LowCardinality(String),+ lc_product LowCardinality(String),+ lc_feature LowCardinality(String),+ lc_access_method LowCardinality(String),+ source LowCardinality(String),+ scene LowCardinality(String),+ has_user_id Bool,+ read_alone Bool,+ requests AggregateFunction(uniq, String),+ users AggregateFunction(uniq, Int64),+ read_count SimpleAggregateFunction(sum, UInt64),+ duration_ms_sum SimpleAggregateFunction(sum, UInt64),+ read_bytes_sum SimpleAggregateFunction(sum, UInt64),+ duration_ms_quantiles AggregateFunction(quantiles(0.5, 0.9), UInt64),+ read_bytes_quantiles AggregateFunction(quantiles(0.5, 0.9), UInt64),+ max_event_time SimpleAggregateFunction(max, DateTime)+) ENGINE = Distributed('aux', 'posthog', 'sharded_warehouse_object_reads_daily');CREATE TABLE posthog.web_bot_definition (id UInt64,parent_id UInt64,diff --git a/posthog/clickhouse/hcl/sql/prod-eu/auxiliary.sql b/posthog/clickhouse/hcl/sql/prod-eu/auxiliary.sqlindex 6b93e6adf868..4106eda6fcde 100644--- a/posthog/clickhouse/hcl/sql/prod-eu/auxiliary.sql+++ b/posthog/clickhouse/hcl/sql/prod-eu/auxiliary.sql@@ -532,6 +532,54 @@ CREATE TABLE posthog.sharded_usage_report_events_preagg (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_warehouse_object_reads_daily (+ team_id Int64,+ day Date,+ read_kind Enum8('read'=1, 'refresh'=2),+ subject_kind Enum8('saved_query'=1, 'table'=2),+ subject_id String,+ workflow_id String,+ lc_kind LowCardinality(String),+ lc_product LowCardinality(String),+ lc_feature LowCardinality(String),+ lc_access_method LowCardinality(String),+ source LowCardinality(String),+ scene LowCardinality(String),+ has_user_id Bool,+ read_alone Bool,+ requests AggregateFunction(uniq, String),+ users AggregateFunction(uniq, Int64),+ read_count SimpleAggregateFunction(sum, UInt64),+ duration_ms_sum SimpleAggregateFunction(sum, UInt64),+ read_bytes_sum SimpleAggregateFunction(sum, UInt64),+ duration_ms_quantiles AggregateFunction(quantiles(0.5, 0.9), UInt64),+ read_bytes_quantiles AggregateFunction(quantiles(0.5, 0.9), UInt64),+ max_event_time SimpleAggregateFunction(max, DateTime)+) ENGINE = ReplicatedAggregatingMergeTree('/clickhouse/tables/noshard/posthog.warehouse_object_reads_daily', '{replica}-{shard}') ORDER BY (team_id, day, read_kind, subject_kind, subject_id, workflow_id, lc_kind, lc_product, lc_feature, lc_access_method, source, scene, has_user_id, read_alone) PARTITION BY toYYYYMMDD(day) TTL day + toIntervalDay(60) SETTINGS index_granularity = 8192, ttl_only_drop_parts = 1;+CREATE TABLE posthog.sharded_warehouse_object_reads_daily_staging (+ team_id Int64,+ day Date,+ read_kind Enum8('read'=1, 'refresh'=2),+ subject_kind Enum8('saved_query'=1, 'table'=2),+ subject_id String,+ workflow_id String,+ lc_kind LowCardinality(String),+ lc_product LowCardinality(String),+ lc_feature LowCardinality(String),+ lc_access_method LowCardinality(String),+ source LowCardinality(String),+ scene LowCardinality(String),+ has_user_id Bool,+ read_alone Bool,+ requests AggregateFunction(uniq, String),+ users AggregateFunction(uniq, Int64),+ read_count SimpleAggregateFunction(sum, UInt64),+ duration_ms_sum SimpleAggregateFunction(sum, UInt64),+ read_bytes_sum SimpleAggregateFunction(sum, UInt64),+ duration_ms_quantiles AggregateFunction(quantiles(0.5, 0.9), UInt64),+ read_bytes_quantiles AggregateFunction(quantiles(0.5, 0.9), UInt64),+ max_event_time SimpleAggregateFunction(max, DateTime)+) ENGINE = ReplicatedAggregatingMergeTree('/clickhouse/tables/noshard/posthog.sharded_warehouse_object_reads_daily_staging', '{replica}-{shard}') ORDER BY (team_id, day, read_kind, subject_kind, subject_id, workflow_id, lc_kind, lc_product, lc_feature, lc_access_method, source, scene, has_user_id, read_alone) PARTITION BY toYYYYMMDD(day) TTL day + toIntervalDay(60) SETTINGS index_granularity = 8192, ttl_only_drop_parts = 1;CREATE TABLE posthog.sharded_web_bot_definition (id UInt64,parent_id UInt64,@@ -708,6 +756,30 @@ CREATE TABLE posthog.sharded_web_vitals_paths_preaggregated (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.warehouse_object_reads_daily (+ team_id Int64,+ day Date,+ read_kind Enum8('read'=1, 'refresh'=2),+ subject_kind Enum8('saved_query'=1, 'table'=2),+ subject_id String,+ workflow_id String,+ lc_kind LowCardinality(String),+ lc_product LowCardinality(String),+ lc_feature LowCardinality(String),+ lc_access_method LowCardinality(String),+ source LowCardinality(String),+ scene LowCardinality(String),+ has_user_id Bool,+ read_alone Bool,+ requests AggregateFunction(uniq, String),+ users AggregateFunction(uniq, Int64),+ read_count SimpleAggregateFunction(sum, UInt64),+ duration_ms_sum SimpleAggregateFunction(sum, UInt64),+ read_bytes_sum SimpleAggregateFunction(sum, UInt64),+ duration_ms_quantiles AggregateFunction(quantiles(0.5, 0.9), UInt64),+ read_bytes_quantiles AggregateFunction(quantiles(0.5, 0.9), UInt64),+ max_event_time SimpleAggregateFunction(max, DateTime)+) ENGINE = Distributed('aux', 'posthog', 'sharded_warehouse_object_reads_daily');CREATE TABLE posthog.web_bot_definition (id UInt64,parent_id UInt64,diff --git a/posthog/clickhouse/hcl/sql/prod-eu/data.sql b/posthog/clickhouse/hcl/sql/prod-eu/data.sqlindex ebf1cd26525a..49c8276cbc97 100644--- a/posthog/clickhouse/hcl/sql/prod-eu/data.sql+++ b/posthog/clickhouse/hcl/sql/prod-eu/data.sql@@ -1706,6 +1706,30 @@ CREATE TABLE posthog.usage_report_events_preagg (distinct_events_unique AggregateFunction(uniqExact, Tuple(UInt64, UInt64, UInt64)),event_count AggregateFunction(sum, UInt64)) ENGINE = Distributed('aux', 'posthog', 'sharded_usage_report_events_preagg', sipHash64(date));+CREATE TABLE posthog.warehouse_object_reads_daily (+ team_id Int64,+ day Date,+ read_kind Enum8('read'=1, 'refresh'=2),+ subject_kind Enum8('saved_query'=1, 'table'=2),+ subject_id String,+ workflow_id String,+ lc_kind LowCardinality(String),+ lc_product LowCardinality(String),+ lc_feature LowCardinality(String),+ lc_access_method LowCardinality(String),+ source LowCardinality(String),+ scene LowCardinality(String),+ has_user_id Bool,+ read_alone Bool,+ requests AggregateFunction(uniq, String),+ users AggregateFunction(uniq, Int64),+ read_count SimpleAggregateFunction(sum, UInt64),+ duration_ms_sum SimpleAggregateFunction(sum, UInt64),+ read_bytes_sum SimpleAggregateFunction(sum, UInt64),+ duration_ms_quantiles AggregateFunction(quantiles(0.5, 0.9), UInt64),+ read_bytes_quantiles AggregateFunction(quantiles(0.5, 0.9), UInt64),+ max_event_time SimpleAggregateFunction(max, DateTime)+) ENGINE = Distributed('aux', 'posthog', 'sharded_warehouse_object_reads_daily');CREATE TABLE posthog.web_bot_definition (id UInt64,parent_id UInt64,diff --git a/posthog/clickhouse/hcl/sql/prod-us/auxiliary.sql b/posthog/clickhouse/hcl/sql/prod-us/auxiliary.sqlindex f1715a3d3663..0024aebf1507 100644--- a/posthog/clickhouse/hcl/sql/prod-us/auxiliary.sql+++ b/posthog/clickhouse/hcl/sql/prod-us/auxiliary.sql@@ -532,6 +532,54 @@ CREATE TABLE posthog.sharded_usage_report_events_preagg (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_warehouse_object_reads_daily (+ team_id Int64,+ day Date,+ read_kind Enum8('read'=1, 'refresh'=2),+ subject_kind Enum8('saved_query'=1, 'table'=2),+ subject_id String,+ workflow_id String,+ lc_kind LowCardinality(String),+ lc_product LowCardinality(String),+ lc_feature LowCardinality(String),+ lc_access_method LowCardinality(String),+ source LowCardinality(String),+ scene LowCardinality(String),+ has_user_id Bool,+ read_alone Bool,+ requests AggregateFunction(uniq, String),+ users AggregateFunction(uniq, Int64),+ read_count SimpleAggregateFunction(sum, UInt64),+ duration_ms_sum SimpleAggregateFunction(sum, UInt64),+ read_bytes_sum SimpleAggregateFunction(sum, UInt64),+ duration_ms_quantiles AggregateFunction(quantiles(0.5, 0.9), UInt64),+ read_bytes_quantiles AggregateFunction(quantiles(0.5, 0.9), UInt64),+ max_event_time SimpleAggregateFunction(max, DateTime)+) ENGINE = ReplicatedAggregatingMergeTree('/clickhouse/tables/noshard/posthog.warehouse_object_reads_daily', '{replica}-{shard}') ORDER BY (team_id, day, read_kind, subject_kind, subject_id, workflow_id, lc_kind, lc_product, lc_feature, lc_access_method, source, scene, has_user_id, read_alone) PARTITION BY toYYYYMMDD(day) TTL day + toIntervalDay(60) SETTINGS index_granularity = 8192, ttl_only_drop_parts = 1;+CREATE TABLE posthog.sharded_warehouse_object_reads_daily_staging (+ team_id Int64,+ day Date,+ read_kind Enum8('read'=1, 'refresh'=2),+ subject_kind Enum8('saved_query'=1, 'table'=2),+ subject_id String,+ workflow_id String,+ lc_kind LowCardinality(String),+ lc_product LowCardinality(String),+ lc_feature LowCardinality(String),+ lc_access_method LowCardinality(String),+ source LowCardinality(String),+ scene LowCardinality(String),+ has_user_id Bool,+ read_alone Bool,+ requests AggregateFunction(uniq, String),+ users AggregateFunction(uniq, Int64),+ read_count SimpleAggregateFunction(sum, UInt64),+ duration_ms_sum SimpleAggregateFunction(sum, UInt64),+ read_bytes_sum SimpleAggregateFunction(sum, UInt64),+ duration_ms_quantiles AggregateFunction(quantiles(0.5, 0.9), UInt64),+ read_bytes_quantiles AggregateFunction(quantiles(0.5, 0.9), UInt64),+ max_event_time SimpleAggregateFunction(max, DateTime)+) ENGINE = ReplicatedAggregatingMergeTree('/clickhouse/tables/noshard/posthog.sharded_warehouse_object_reads_daily_staging', '{replica}-{shard}') ORDER BY (team_id, day, read_kind, subject_kind, subject_id, workflow_id, lc_kind, lc_product, lc_feature, lc_access_method, source, scene, has_user_id, read_alone) PARTITION BY toYYYYMMDD(day) TTL day + toIntervalDay(60) SETTINGS index_granularity = 8192, ttl_only_drop_parts = 1;CREATE TABLE posthog.sharded_web_bot_definition (id UInt64,parent_id UInt64,@@ -708,6 +756,30 @@ CREATE TABLE posthog.sharded_web_vitals_paths_preaggregated (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.warehouse_object_reads_daily (+ team_id Int64,+ day Date,+ read_kind Enum8('read'=1, 'refresh'=2),+ subject_kind Enum8('saved_query'=1, 'table'=2),+ subject_id String,+ workflow_id String,+ lc_kind LowCardinality(String),+ lc_product LowCardinality(String),+ lc_feature LowCardinality(String),+ lc_access_method LowCardinality(String),+ source LowCardinality(String),+ scene LowCardinality(String),+ has_user_id Bool,+ read_alone Bool,+ requests AggregateFunction(uniq, String),+ users AggregateFunction(uniq, Int64),+ read_count SimpleAggregateFunction(sum, UInt64),+ duration_ms_sum SimpleAggregateFunction(sum, UInt64),+ read_bytes_sum SimpleAggregateFunction(sum, UInt64),+ duration_ms_quantiles AggregateFunction(quantiles(0.5, 0.9), UInt64),+ read_bytes_quantiles AggregateFunction(quantiles(0.5, 0.9), UInt64),+ max_event_time SimpleAggregateFunction(max, DateTime)+) ENGINE = Distributed('aux', 'posthog', 'sharded_warehouse_object_reads_daily');CREATE TABLE posthog.web_bot_definition (id UInt64,parent_id UInt64,diff --git a/posthog/clickhouse/hcl/sql/prod-us/data.sql b/posthog/clickhouse/hcl/sql/prod-us/data.sqlindex 72b09e17e340..15b00c809c19 100644--- a/posthog/clickhouse/hcl/sql/prod-us/data.sql+++ b/posthog/clickhouse/hcl/sql/prod-us/data.sql@@ -1535,6 +1535,30 @@ CREATE TABLE posthog.usage_report_events_preagg (distinct_events_unique AggregateFunction(uniqExact, Tuple(UInt64, UInt64, UInt64)),event_count AggregateFunction(sum, UInt64)) ENGINE = Distributed('aux', 'posthog', 'sharded_usage_report_events_preagg', sipHash64(date));+CREATE TABLE posthog.warehouse_object_reads_daily (+ team_id Int64,+ day Date,+ read_kind Enum8('read'=1, 'refresh'=2),+ subject_kind Enum8('saved_query'=1, 'table'=2),+ subject_id String,+ workflow_id String,+ lc_kind LowCardinality(String),+ lc_product LowCardinality(String),+ lc_feature LowCardinality(String),+ lc_access_method LowCardinality(String),+ source LowCardinality(String),+ scene LowCardinality(String),+ has_user_id Bool,+ read_alone Bool,+ requests AggregateFunction(uniq, String),+ users AggregateFunction(uniq, Int64),+ read_count SimpleAggregateFunction(sum, UInt64),+ duration_ms_sum SimpleAggregateFunction(sum, UInt64),+ read_bytes_sum SimpleAggregateFunction(sum, UInt64),+ duration_ms_quantiles AggregateFunction(quantiles(0.5, 0.9), UInt64),+ read_bytes_quantiles AggregateFunction(quantiles(0.5, 0.9), UInt64),+ max_event_time SimpleAggregateFunction(max, DateTime)+) ENGINE = Distributed('aux', 'posthog', 'sharded_warehouse_object_reads_daily');CREATE TABLE posthog.web_bot_definition (id UInt64,parent_id UInt64,diff --git a/posthog/clickhouse/migrations/0349_warehouse_object_reads_daily.py b/posthog/clickhouse/migrations/0349_warehouse_object_reads_daily.pynew file mode 100644index 000000000000..ff52639c2941--- /dev/null+++ b/posthog/clickhouse/migrations/0349_warehouse_object_reads_daily.py@@ -0,0 +1,14 @@+from posthog.clickhouse.client.migration_tools import NodeRole, run_sql_with_exceptions+from posthog.clickhouse.warehouse_object_reads import (+ DISTRIBUTED_WAREHOUSE_OBJECT_READS_DAILY_TABLE_SQL,+ SHARDED_WAREHOUSE_OBJECT_READS_DAILY_STAGING_TABLE_SQL,+ SHARDED_WAREHOUSE_OBJECT_READS_DAILY_TABLE_SQL,+)++operations = [+ run_sql_with_exceptions(SHARDED_WAREHOUSE_OBJECT_READS_DAILY_TABLE_SQL(), node_roles=[NodeRole.AUX]),+ run_sql_with_exceptions(SHARDED_WAREHOUSE_OBJECT_READS_DAILY_STAGING_TABLE_SQL(), node_roles=[NodeRole.AUX]),+ run_sql_with_exceptions(+ DISTRIBUTED_WAREHOUSE_OBJECT_READS_DAILY_TABLE_SQL(), node_roles=[NodeRole.AUX, NodeRole.DATA]+ ),+]diff --git a/posthog/clickhouse/migrations/max_migration.txt b/posthog/clickhouse/migrations/max_migration.txtindex 2ad7e345e905..6f775b750940 100644--- a/posthog/clickhouse/migrations/max_migration.txt+++ b/posthog/clickhouse/migrations/max_migration.txt@@ -1 +1 @@-0348_expiry_from_timestamp+0349_warehouse_object_reads_dailydiff --git a/posthog/clickhouse/schema.py b/posthog/clickhouse/schema.pyindex 9693115945dc..4fef1c15f364 100644--- a/posthog/clickhouse/schema.py+++ b/posthog/clickhouse/schema.py@@ -162,6 +162,11 @@ from posthog.clickhouse.traces import (TRACE_SPANS_KAFKA_METRICS_TABLE_SQL,TRACE_SPANS_TABLE_SQL,)+from posthog.clickhouse.warehouse_object_reads import (+ DISTRIBUTED_WAREHOUSE_OBJECT_READS_DAILY_TABLE_SQL,+ SHARDED_WAREHOUSE_OBJECT_READS_DAILY_STAGING_TABLE_SQL,+ SHARDED_WAREHOUSE_OBJECT_READS_DAILY_TABLE_SQL,+)from posthog.heatmaps.sql import (DISTRIBUTED_HEATMAPS_TABLE_SQL,HEATMAPS_TABLE_MV_SQL,@@ -459,6 +464,8 @@ CREATE_MERGETREE_TABLE_QUERIES = (WEB_PRE_AGGREGATED_TEAM_SELECTION_TABLE_SQL,SHARDED_QUERY_LOG_ARCHIVE_OPS_TABLE_SQL,QUERY_LOG_ARCHIVE_BUFFER_OPS_TABLE_SQL,+ SHARDED_WAREHOUSE_OBJECT_READS_DAILY_TABLE_SQL,+ SHARDED_WAREHOUSE_OBJECT_READS_DAILY_STAGING_TABLE_SQL,COHORT_MEMBERSHIP_TABLE_SQL,PRECALCULATED_EVENTS_SHARDED_TABLE_SQL,PRECALCULATED_PERSON_PROPERTIES_SHARDED_TABLE_SQL,@@ -575,6 +582,7 @@ CREATE_DISTRIBUTED_TABLE_QUERIES = (DISTRIBUTED_EXPERIMENT_METRIC_EVENTS_TABLE_SQL,DISTRIBUTED_CONVERSION_GOAL_ATTRIBUTED_TABLE_SQL,DISTRIBUTED_MARKETING_TOUCHPOINTS_TABLE_SQL,+ DISTRIBUTED_WAREHOUSE_OBJECT_READS_DAILY_TABLE_SQL,DISTRIBUTED_MARKETING_CONVERSIONS_TABLE_SQL,DISTRIBUTED_MARKETING_COSTS_TABLE_SQL,DISTRIBUTED_WEB_GOALS_PREAGGREGATED_TABLE_SQL,diff --git a/posthog/clickhouse/test/__snapshots__/test_schema.ambr b/posthog/clickhouse/test/__snapshots__/test_schema.ambrindex 6542df5da073..dea8e733e1fb 100644--- a/posthog/clickhouse/test/__snapshots__/test_schema.ambr+++ b/posthog/clickhouse/test/__snapshots__/test_schema.ambr@@ -8950,6 +8950,76 @@'''# ---+# name: test_create_table_query[sharded_warehouse_object_reads_daily]+ '''++ CREATE TABLE IF NOT EXISTS sharded_warehouse_object_reads_daily+ (+ team_id Int64,+ day Date,+ read_kind Enum8('read' = 1, 'refresh' = 2),+ subject_kind Enum8('saved_query' = 1, 'table' = 2),+ subject_id String,+ workflow_id String,+ lc_kind LowCardinality(String),+ lc_product LowCardinality(String),+ lc_feature LowCardinality(String),+ lc_access_method LowCardinality(String),+ source LowCardinality(String),+ scene LowCardinality(String),+ has_user_id Bool,+ read_alone Bool,+ requests AggregateFunction(uniq, String),+ users AggregateFunction(uniq, Int64),+ read_count SimpleAggregateFunction(sum, UInt64),+ duration_ms_sum SimpleAggregateFunction(sum, UInt64),+ read_bytes_sum SimpleAggregateFunction(sum, UInt64),+ duration_ms_quantiles AggregateFunction(quantiles(0.5, 0.9), UInt64),+ read_bytes_quantiles AggregateFunction(quantiles(0.5, 0.9), UInt64),+ max_event_time SimpleAggregateFunction(max, DateTime)+ ) ENGINE = ReplicatedAggregatingMergeTree('/clickhouse/tables/77f1df52-4b43-11e9-910f-b8ca3a9b9f3e_noshard/posthog.warehouse_object_reads_daily', '{replica}-{shard}')+ PARTITION BY toYYYYMMDD(day)+ ORDER BY (team_id, day, read_kind, subject_kind, subject_id, workflow_id, lc_kind, lc_product, lc_feature, lc_access_method, source, scene, has_user_id, read_alone)+ TTL day + INTERVAL 60 DAY+ SETTINGS ttl_only_drop_parts = 1++ '''+# ---+# name: test_create_table_query[sharded_warehouse_object_reads_daily_staging]+ '''++ CREATE TABLE IF NOT EXISTS sharded_warehouse_object_reads_daily_staging+ (+ team_id Int64,+ day Date,+ read_kind Enum8('read' = 1, 'refresh' = 2),+ subject_kind Enum8('saved_query' = 1, 'table' = 2),+ subject_id String,+ workflow_id String,+ lc_kind LowCardinality(String),+ lc_product LowCardinality(String),+ lc_feature LowCardinality(String),+ lc_access_method LowCardinality(String),+ source LowCardinality(String),+ scene LowCardinality(String),+ has_user_id Bool,+ read_alone Bool,+ requests AggregateFunction(uniq, String),+ users AggregateFunction(uniq, Int64),+ read_count SimpleAggregateFunction(sum, UInt64),+ duration_ms_sum SimpleAggregateFunction(sum, UInt64),+ read_bytes_sum SimpleAggregateFunction(sum, UInt64),+ duration_ms_quantiles AggregateFunction(quantiles(0.5, 0.9), UInt64),+ read_bytes_quantiles AggregateFunction(quantiles(0.5, 0.9), UInt64),+ max_event_time SimpleAggregateFunction(max, DateTime)+ ) ENGINE = ReplicatedAggregatingMergeTree('/clickhouse/tables/77f1df52-4b43-11e9-910f-b8ca3a9b9f3e_noshard/posthog.sharded_warehouse_object_reads_daily_staging', '{replica}-{shard}')+ PARTITION BY toYYYYMMDD(day)+ ORDER BY (team_id, day, read_kind, subject_kind, subject_id, workflow_id, lc_kind, lc_product, lc_feature, lc_access_method, source, scene, has_user_id, read_alone)+ TTL day + INTERVAL 60 DAY+ SETTINGS ttl_only_drop_parts = 1++ '''+# ---# name: test_create_table_query[sharded_web_bounces_dimensional_preaggregated]'''@@ -9555,6 +9625,37 @@'''# ---+# name: test_create_table_query[warehouse_object_reads_daily]+ '''++ CREATE TABLE IF NOT EXISTS warehouse_object_reads_daily+ (+ team_id Int64,+ day Date,+ read_kind Enum8('read' = 1, 'refresh' = 2),+ subject_kind Enum8('saved_query' = 1, 'table' = 2),+ subject_id String,+ workflow_id String,+ lc_kind LowCardinality(String),+ lc_product LowCardinality(String),+ lc_feature LowCardinality(String),+ lc_access_method LowCardinality(String),+ source LowCardinality(String),+ scene LowCardinality(String),+ has_user_id Bool,+ read_alone Bool,+ requests AggregateFunction(uniq, String),+ users AggregateFunction(uniq, Int64),+ read_count SimpleAggregateFunction(sum, UInt64),+ duration_ms_sum SimpleAggregateFunction(sum, UInt64),+ read_bytes_sum SimpleAggregateFunction(sum, UInt64),+ duration_ms_quantiles AggregateFunction(quantiles(0.5, 0.9), UInt64),+ read_bytes_quantiles AggregateFunction(quantiles(0.5, 0.9), UInt64),+ max_event_time SimpleAggregateFunction(max, DateTime)+ ) ENGINE = Distributed('aux', 'posthog_test', 'sharded_warehouse_object_reads_daily')++ '''+# ---# name: test_create_table_query[web_bounces_dimensional_preaggregated]'''@@ -14665,6 +14766,76 @@'''# ---+# name: test_create_table_query_replicated_and_storage[sharded_warehouse_object_reads_daily]+ '''++ CREATE TABLE IF NOT EXISTS sharded_warehouse_object_reads_daily+ (+ team_id Int64,+ day Date,+ read_kind Enum8('read' = 1, 'refresh' = 2),+ subject_kind Enum8('saved_query' = 1, 'table' = 2),+ subject_id String,+ workflow_id String,+ lc_kind LowCardinality(String),+ lc_product LowCardinality(String),+ lc_feature LowCardinality(String),+ lc_access_method LowCardinality(String),+ source LowCardinality(String),+ scene LowCardinality(String),+ has_user_id Bool,+ read_alone Bool,+ requests AggregateFunction(uniq, String),+ users AggregateFunction(uniq, Int64),+ read_count SimpleAggregateFunction(sum, UInt64),+ duration_ms_sum SimpleAggregateFunction(sum, UInt64),+ read_bytes_sum SimpleAggregateFunction(sum, UInt64),+ duration_ms_quantiles AggregateFunction(quantiles(0.5, 0.9), UInt64),+ read_bytes_quantiles AggregateFunction(quantiles(0.5, 0.9), UInt64),+ max_event_time SimpleAggregateFunction(max, DateTime)+ ) ENGINE = ReplicatedAggregatingMergeTree('/clickhouse/tables/77f1df52-4b43-11e9-910f-b8ca3a9b9f3e_noshard/posthog.warehouse_object_reads_daily', '{replica}-{shard}')+ PARTITION BY toYYYYMMDD(day)+ ORDER BY (team_id, day, read_kind, subject_kind, subject_id, workflow_id, lc_kind, lc_product, lc_feature, lc_access_method, source, scene, has_user_id, read_alone)+ TTL day + INTERVAL 60 DAY+ SETTINGS ttl_only_drop_parts = 1++ '''+# ---+# name: test_create_table_query_replicated_and_storage[sharded_warehouse_object_reads_daily_staging]+ '''++ CREATE TABLE IF NOT EXISTS sharded_warehouse_object_reads_daily_staging+ (+ team_id Int64,+ day Date,+ read_kind Enum8('read' = 1, 'refresh' = 2),+ subject_kind Enum8('saved_query' = 1, 'table' = 2),+ subject_id String,+ workflow_id String,+ lc_kind LowCardinality(String),+ lc_product LowCardinality(String),+ lc_feature LowCardinality(String),+ lc_access_method LowCardinality(String),+ source LowCardinality(String),+ scene LowCardinality(String),+ has_user_id Bool,+ read_alone Bool,+ requests AggregateFunction(uniq, String),+ users AggregateFunction(uniq, Int64),+ read_count SimpleAggregateFunction(sum, UInt64),+ duration_ms_sum SimpleAggregateFunction(sum, UInt64),+ read_bytes_sum SimpleAggregateFunction(sum, UInt64),+ duration_ms_quantiles AggregateFunction(quantiles(0.5, 0.9), UInt64),+ read_bytes_quantiles AggregateFunction(quantiles(0.5, 0.9), UInt64),+ max_event_time SimpleAggregateFunction(max, DateTime)+ ) ENGINE = ReplicatedAggregatingMergeTree('/clickhouse/tables/77f1df52-4b43-11e9-910f-b8ca3a9b9f3e_noshard/posthog.sharded_warehouse_object_reads_daily_staging', '{replica}-{shard}')+ PARTITION BY toYYYYMMDD(day)+ ORDER BY (team_id, day, read_kind, subject_kind, subject_id, workflow_id, lc_kind, lc_product, lc_feature, lc_access_method, source, scene, has_user_id, read_alone)+ TTL day + INTERVAL 60 DAY+ SETTINGS ttl_only_drop_parts = 1++ '''+# ---# name: test_create_table_query_replicated_and_storage[sharded_web_bounces_dimensional_preaggregated]'''diff --git a/posthog/clickhouse/warehouse_object_reads.py b/posthog/clickhouse/warehouse_object_reads.pynew file mode 100644index 000000000000..f3344ee224e6--- /dev/null+++ b/posthog/clickhouse/warehouse_object_reads.py@@ -0,0 +1,119 @@+from enum import StrEnum++from django.conf import settings++from posthog.clickhouse.table_engines import AggregatingMergeTree, Distributed++WAREHOUSE_OBJECT_READS_DAILY_TABLE = "warehouse_object_reads_daily"+SHARDED_WAREHOUSE_OBJECT_READS_DAILY_TABLE = f"sharded_{WAREHOUSE_OBJECT_READS_DAILY_TABLE}"+SHARDED_WAREHOUSE_OBJECT_READS_DAILY_STAGING_TABLE = f"{SHARDED_WAREHOUSE_OBJECT_READS_DAILY_TABLE}_staging"+WAREHOUSE_OBJECT_READS_RETENTION_DAYS = 60+++class ReadKind(StrEnum):+ READ = "read"+ REFRESH = "refresh"+++class SubjectKind(StrEnum):+ SAVED_QUERY = "saved_query"+ TABLE = "table"+++def _enum8_type(values: type[StrEnum]) -> str:+ members = ", ".join(f"'{member.value}' = {position}" for position, member in enumerate(values, start=1))+ return f"Enum8({members})"+++DIMENSION_COLUMNS = (+ "workflow_id",+ "lc_kind",+ "lc_product",+ "lc_feature",+ "lc_access_method",+ "source",+ "scene",+ "has_user_id",+ "read_alone",+)++SORT_KEY_COLUMNS = ("team_id", "day", "read_kind", "subject_kind", "subject_id", *DIMENSION_COLUMNS)++_COLUMNS = f"""+ team_id Int64,+ day Date,+ read_kind {_enum8_type(ReadKind)},+ subject_kind {_enum8_type(SubjectKind)},+ subject_id String,+ workflow_id String,+ lc_kind LowCardinality(String),+ lc_product LowCardinality(String),+ lc_feature LowCardinality(String),+ lc_access_method LowCardinality(String),+ source LowCardinality(String),+ scene LowCardinality(String),+ has_user_id Bool,+ read_alone Bool,+ requests AggregateFunction(uniq, String),+ users AggregateFunction(uniq, Int64),+ read_count SimpleAggregateFunction(sum, UInt64),+ duration_ms_sum SimpleAggregateFunction(sum, UInt64),+ read_bytes_sum SimpleAggregateFunction(sum, UInt64),+ duration_ms_quantiles AggregateFunction(quantiles(0.5, 0.9), UInt64),+ read_bytes_quantiles AggregateFunction(quantiles(0.5, 0.9), UInt64),+ max_event_time SimpleAggregateFunction(max, DateTime)"""+++def _storage_table_sql(create_clause: str, table_name: str, engine: AggregatingMergeTree) -> str:+ return f"""+{create_clause} {table_name}+({_COLUMNS}+) ENGINE = {engine}+PARTITION BY toYYYYMMDD(day)+ORDER BY ({", ".join(SORT_KEY_COLUMNS)})+TTL day + INTERVAL {WAREHOUSE_OBJECT_READS_RETENTION_DAYS} DAY+SETTINGS ttl_only_drop_parts = 1+"""+++def SHARDED_WAREHOUSE_OBJECT_READS_DAILY_TABLE_SQL() -> str:+ return _storage_table_sql(+ "CREATE TABLE IF NOT EXISTS",+ SHARDED_WAREHOUSE_OBJECT_READS_DAILY_TABLE,+ AggregatingMergeTree(WAREHOUSE_OBJECT_READS_DAILY_TABLE),+ )+++def SHARDED_WAREHOUSE_OBJECT_READS_DAILY_STAGING_TABLE_SQL() -> str:+ return _storage_table_sql(+ "CREATE TABLE IF NOT EXISTS",+ SHARDED_WAREHOUSE_OBJECT_READS_DAILY_STAGING_TABLE,+ AggregatingMergeTree(SHARDED_WAREHOUSE_OBJECT_READS_DAILY_STAGING_TABLE),+ )+++def REPLACE_SHARDED_WAREHOUSE_OBJECT_READS_DAILY_STAGING_TABLE_SQL() -> str:+ return _storage_table_sql(+ "CREATE OR REPLACE TABLE",+ SHARDED_WAREHOUSE_OBJECT_READS_DAILY_STAGING_TABLE,+ AggregatingMergeTree(SHARDED_WAREHOUSE_OBJECT_READS_DAILY_STAGING_TABLE, force_unique_zk_path=True),+ )+++def DISTRIBUTED_WAREHOUSE_OBJECT_READS_DAILY_TABLE_SQL() -> str:+ engine = Distributed(data_table=SHARDED_WAREHOUSE_OBJECT_READS_DAILY_TABLE, cluster=settings.CLICKHOUSE_AUX_CLUSTER)+ return f"""+CREATE TABLE IF NOT EXISTS {WAREHOUSE_OBJECT_READS_DAILY_TABLE}+({_COLUMNS}+) ENGINE = {engine}+"""+++def TRUNCATE_WAREHOUSE_OBJECT_READS_DAILY_TABLES_SQL() -> list[str]:+ return [+ f"TRUNCATE TABLE IF EXISTS {table_name}"+ for table_name in (+ SHARDED_WAREHOUSE_OBJECT_READS_DAILY_TABLE,+ SHARDED_WAREHOUSE_OBJECT_READS_DAILY_STAGING_TABLE,+ )+ ]diff --git a/posthog/conftest.py b/posthog/conftest.pyindex 8d3b968e8156..9fbc1605cbe8 100644--- a/posthog/conftest.py+++ b/posthog/conftest.py@@ -119,6 +119,7 @@ def reset_clickhouse_tables():from posthog.clickhouse.cleanup_snapshots import TRUNCATE_CLEANUP_SNAPSHOT_TABLES_SQLfrom posthog.clickhouse.dead_letter_queue import TRUNCATE_DEAD_LETTER_QUEUE_TABLE_SQLfrom posthog.clickhouse.plugin_log_entries import TRUNCATE_PLUGIN_LOG_ENTRIES_TABLE_SQL+ from posthog.clickhouse.warehouse_object_reads import TRUNCATE_WAREHOUSE_OBJECT_READS_DAILY_TABLES_SQLfrom posthog.heatmaps.sql import TRUNCATE_HEATMAPS_TABLE_SQLfrom posthog.models.ai.pg_embeddings import TRUNCATE_PG_EMBEDDINGS_TABLE_SQLfrom posthog.models.ai_events.sql import TRUNCATE_AI_EVENTS_TABLE_SQL@@ -178,6 +179,7 @@ def reset_clickhouse_tables():TRUNCATE_PG_EMBEDDINGS_TABLE_SQL(),TRUNCATE_AI_EVENTS_TABLE_SQL(),*TRUNCATE_CLEANUP_SNAPSHOT_TABLES_SQL(),+ *TRUNCATE_WAREHOUSE_OBJECT_READS_DAILY_TABLES_SQL(),]# Drop created Kafka tables because some tests don't expect it.