Skip to content

Commit

Permalink
Update query snapshots
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions[bot] committed Apr 17, 2024
1 parent c433819 commit 0f8eeea
Showing 1 changed file with 211 additions and 0 deletions.
211 changes: 211 additions & 0 deletions posthog/clickhouse/test/__snapshots__/test_schema.ambr
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,31 @@

'''
# ---
# name: test_create_kafka_table_with_different_kafka_host[kafka_heatmaps]
'''

CREATE TABLE IF NOT EXISTS kafka_heatmaps ON CLUSTER 'posthog'
(
session_id VARCHAR,
team_id Int64,
distinct_id VARCHAR,
timestamp DateTime64(6, 'UTC'),
-- x is the x with resolution applied, the resolution converts high fidelity mouse positions into an NxN grid
x Int16,
-- y is the y with resolution applied, the resolution converts high fidelity mouse positions into an NxN grid
y Int16,
-- stored so that in future we can support other resolutions
scale_factor Int16,
viewport_width Int16,
viewport_height Int16,
-- some elements move when the page scrolls, others do not
pointer_target_fixed Bool,
current_url VARCHAR,
type LowCardinality(String)
) ENGINE = Kafka('test.kafka.broker:9092', 'clickhouse_heatmap_events_test', 'group1', 'JSONEachRow')

'''
# ---
# name: test_create_kafka_table_with_different_kafka_host[kafka_ingestion_warnings]
'''

Expand Down Expand Up @@ -648,6 +673,59 @@

'''
# ---
# name: test_create_table_query[heatmaps]
'''

CREATE TABLE IF NOT EXISTS heatmaps ON CLUSTER 'posthog'
(
session_id VARCHAR,
team_id Int64,
distinct_id VARCHAR,
timestamp DateTime64(6, 'UTC'),
-- x is the x with resolution applied, the resolution converts high fidelity mouse positions into an NxN grid
x Int16,
-- y is the y with resolution applied, the resolution converts high fidelity mouse positions into an NxN grid
y Int16,
-- stored so that in future we can support other resolutions
scale_factor Int16,
viewport_width Int16,
viewport_height Int16,
-- some elements move when the page scrolls, others do not
pointer_target_fixed Bool,
current_url VARCHAR,
type LowCardinality(String),
_timestamp DateTime
) ENGINE = Distributed('posthog', 'posthog_test', 'sharded_heatmaps', cityHash64(concat(toString(team_id), '-', current_url, '-', toString(toDate(timestamp)))))

'''
# ---
# name: test_create_table_query[heatmaps_mv]
'''

CREATE MATERIALIZED VIEW IF NOT EXISTS heatmaps_mv ON CLUSTER 'posthog'
TO posthog_test.writable_heatmaps
AS SELECT
session_id,
team_id,
distinct_id,
timestamp,
-- x is the x with resolution applied, the resolution converts high fidelity mouse positions into an NxN grid
x,
-- y is the y with resolution applied, the resolution converts high fidelity mouse positions into an NxN grid
y,
-- stored so that in future we can support other resolutions
scale_factor,
viewport_width,
viewport_height,
-- some elements move when the page scrolls, others do not
pointer_target_fixed,
current_url,
type,
_timestamp
FROM posthog_test.kafka_heatmaps

'''
# ---
# name: test_create_table_query[ingestion_warnings]
'''

Expand Down Expand Up @@ -783,6 +861,31 @@

'''
# ---
# name: test_create_table_query[kafka_heatmaps]
'''

CREATE TABLE IF NOT EXISTS kafka_heatmaps ON CLUSTER 'posthog'
(
session_id VARCHAR,
team_id Int64,
distinct_id VARCHAR,
timestamp DateTime64(6, 'UTC'),
-- x is the x with resolution applied, the resolution converts high fidelity mouse positions into an NxN grid
x Int16,
-- y is the y with resolution applied, the resolution converts high fidelity mouse positions into an NxN grid
y Int16,
-- stored so that in future we can support other resolutions
scale_factor Int16,
viewport_width Int16,
viewport_height Int16,
-- some elements move when the page scrolls, others do not
pointer_target_fixed Bool,
current_url VARCHAR,
type LowCardinality(String)
) ENGINE = Kafka('kafka:9092', 'clickhouse_heatmap_events_test', 'group1', 'JSONEachRow')

'''
# ---
# name: test_create_table_query[kafka_ingestion_warnings]
'''

Expand Down Expand Up @@ -1811,6 +1914,47 @@
SAMPLE BY cityHash64(distinct_id)


'''
# ---
# name: test_create_table_query[sharded_heatmaps]
'''

CREATE TABLE IF NOT EXISTS sharded_heatmaps ON CLUSTER 'posthog'
(
session_id VARCHAR,
team_id Int64,
distinct_id VARCHAR,
timestamp DateTime64(6, 'UTC'),
-- x is the x with resolution applied, the resolution converts high fidelity mouse positions into an NxN grid
x Int16,
-- y is the y with resolution applied, the resolution converts high fidelity mouse positions into an NxN grid
y Int16,
-- stored so that in future we can support other resolutions
scale_factor Int16,
viewport_width Int16,
viewport_height Int16,
-- some elements move when the page scrolls, others do not
pointer_target_fixed Bool,
current_url VARCHAR,
type LowCardinality(String),
_timestamp DateTime
) ENGINE = ReplicatedMergeTree('/clickhouse/tables/77f1df52-4b43-11e9-910f-b8ca3a9b9f3e_{shard}/posthog.heatmaps', '{replica}')

PARTITION BY toYYYYMM(timestamp)
-- almost always this is being queried by
-- * type,
-- * team_id,
-- * date range,
-- * URL (maybe matching wild cards),
-- * width
-- we'll almost never query this by session id
-- so from least to most cardinality that's
ORDER BY (type, team_id, toDate(timestamp), current_url, viewport_width)
-- I am purposefully not setting index granularity
-- the default is 8192, and we will be loading a lot of data
-- per query, we tend to copy this 512 around the place but
-- i don't think it applies here

'''
# ---
# name: test_create_table_query[sharded_ingestion_warnings]
Expand Down Expand Up @@ -2083,6 +2227,32 @@

'''
# ---
# name: test_create_table_query[writable_heatmaps]
'''

CREATE TABLE IF NOT EXISTS writable_heatmaps ON CLUSTER 'posthog'
(
session_id VARCHAR,
team_id Int64,
distinct_id VARCHAR,
timestamp DateTime64(6, 'UTC'),
-- x is the x with resolution applied, the resolution converts high fidelity mouse positions into an NxN grid
x Int16,
-- y is the y with resolution applied, the resolution converts high fidelity mouse positions into an NxN grid
y Int16,
-- stored so that in future we can support other resolutions
scale_factor Int16,
viewport_width Int16,
viewport_height Int16,
-- some elements move when the page scrolls, others do not
pointer_target_fixed Bool,
current_url VARCHAR,
type LowCardinality(String),
_timestamp DateTime
) ENGINE = Distributed('posthog', 'posthog_test', 'sharded_heatmaps', cityHash64(concat(toString(team_id), '-', session_id, '-', toString(toDate(timestamp)))))

'''
# ---
# name: test_create_table_query[writable_session_recording_events]
'''

Expand Down Expand Up @@ -2633,6 +2803,47 @@

'''
# ---
# name: test_create_table_query_replicated_and_storage[sharded_heatmaps]
'''

CREATE TABLE IF NOT EXISTS sharded_heatmaps ON CLUSTER 'posthog'
(
session_id VARCHAR,
team_id Int64,
distinct_id VARCHAR,
timestamp DateTime64(6, 'UTC'),
-- x is the x with resolution applied, the resolution converts high fidelity mouse positions into an NxN grid
x Int16,
-- y is the y with resolution applied, the resolution converts high fidelity mouse positions into an NxN grid
y Int16,
-- stored so that in future we can support other resolutions
scale_factor Int16,
viewport_width Int16,
viewport_height Int16,
-- some elements move when the page scrolls, others do not
pointer_target_fixed Bool,
current_url VARCHAR,
type LowCardinality(String),
_timestamp DateTime
) ENGINE = ReplicatedMergeTree('/clickhouse/tables/77f1df52-4b43-11e9-910f-b8ca3a9b9f3e_{shard}/posthog.heatmaps', '{replica}')

PARTITION BY toYYYYMM(timestamp)
-- almost always this is being queried by
-- * type,
-- * team_id,
-- * date range,
-- * URL (maybe matching wild cards),
-- * width
-- we'll almost never query this by session id
-- so from least to most cardinality that's
ORDER BY (type, team_id, toDate(timestamp), current_url, viewport_width)
-- I am purposefully not setting index granularity
-- the default is 8192, and we will be loading a lot of data
-- per query, we tend to copy this 512 around the place but
-- i don't think it applies here

'''
# ---
# name: test_create_table_query_replicated_and_storage[sharded_ingestion_warnings]
'''

Expand Down

0 comments on commit 0f8eeea

Please sign in to comment.