-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(persons-on-events): add required person and group columns to eve…
…nts table (#9251) * refactor(ingestion): establish setup for json consumption from kafka into clickhouse [nuke protobuf pt. 1] * address review * fix kafka table name across the board * Update posthog/async_migrations/test/test_0004_replicated_schema.py * run checks * feat(persons-on-events): add required person and group columns to events table * rename * update snapshots * address review * Revert "update snapshots" This reverts commit 63d7126. * address review * update snapshots * update more snapshots * use runpython * update schemas * update more queries * some improvements :D * fix naming * fix breakdown prop name * update snapshot * fix naming * fix ambiguous test * fix queries' * last bits * fix typo to retrigger tests * also handle kafka and mv tables in migration * update snapshots * drop tables if exists Co-authored-by: eric <[email protected]>
- Loading branch information
1 parent
38bf3ef
commit 3d71ad0
Showing
22 changed files
with
164 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
ee/clickhouse/migrations/0026_persons_and_groups_on_events.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
from infi.clickhouse_orm import migrations | ||
|
||
from ee.clickhouse.replication.utils import clickhouse_is_replicated | ||
from ee.clickhouse.sql.events import EVENTS_TABLE_JSON_MV_SQL, KAFKA_EVENTS_TABLE_JSON_SQL | ||
from posthog.client import sync_execute | ||
from posthog.settings import CLICKHOUSE_CLUSTER | ||
|
||
ADD_COLUMNS_BASE_SQL = """ | ||
ALTER TABLE {table} | ||
ON CLUSTER '{cluster}' | ||
ADD COLUMN IF NOT EXISTS person_id UUID, | ||
ADD COLUMN IF NOT EXISTS person_properties VARCHAR, | ||
ADD COLUMN IF NOT EXISTS group0_properties VARCHAR, | ||
ADD COLUMN IF NOT EXISTS group1_properties VARCHAR, | ||
ADD COLUMN IF NOT EXISTS group2_properties VARCHAR, | ||
ADD COLUMN IF NOT EXISTS group3_properties VARCHAR, | ||
ADD COLUMN IF NOT EXISTS group4_properties VARCHAR | ||
""" | ||
|
||
|
||
def add_columns_to_required_tables(_): | ||
sync_execute(ADD_COLUMNS_BASE_SQL.format(table="events", cluster=CLICKHOUSE_CLUSTER)) | ||
|
||
if clickhouse_is_replicated(): | ||
sync_execute(ADD_COLUMNS_BASE_SQL.format(table="writable_events", cluster=CLICKHOUSE_CLUSTER)) | ||
sync_execute(ADD_COLUMNS_BASE_SQL.format(table="sharded_events", cluster=CLICKHOUSE_CLUSTER)) | ||
|
||
|
||
operations = [ | ||
migrations.RunPython(add_columns_to_required_tables), | ||
migrations.RunSQL(f"DROP TABLE IF EXISTS events_json_mv ON CLUSTER '{CLICKHOUSE_CLUSTER}'"), | ||
migrations.RunSQL(f"DROP TABLE IF EXISTS kafka_events_json ON CLUSTER '{CLICKHOUSE_CLUSTER}'"), | ||
migrations.RunSQL(KAFKA_EVENTS_TABLE_JSON_SQL()), | ||
migrations.RunSQL(EVENTS_TABLE_JSON_MV_SQL()), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.