0
0
mirror of https://github.com/PostHog/posthog.git synced 2024-12-01 04:12:23 +01:00
posthog/ee/clickhouse/migrations/0019_group_analytics_materialized_columns.py
Karl-Aksel Puulmann a39596c092
Groups: Use materialized columns for groups (#6938)
* Migration to use materialized columns for groups

Workaround for https://github.com/PostHog/posthog/issues/6422

* Use groups materialized columns in queries

* Update mat column creation tests

* Simplify aggregation_target_field

* Fix migration

* Update snapshots
2021-11-08 15:49:39 +02:00

19 lines
584 B
Python

from infi.clickhouse_orm import migrations
from ee.clickhouse.materialized_columns.columns import materialize
def create_materialized_columns(database):
try:
materialize("events", "$group_0", "$group_0")
materialize("events", "$group_1", "$group_1")
materialize("events", "$group_2", "$group_2")
materialize("events", "$group_3", "$group_3")
materialize("events", "$group_4", "$group_4")
except ValueError:
# Group is already materialized, skip
pass
operations = [migrations.RunPython(create_materialized_columns)]