Skip to content

Commit

Permalink
fix: make the ALTER TABLE MODIFY QUERY run ON CLUSTER
Browse files Browse the repository at this point in the history
  • Loading branch information
fuziontech committed Nov 25, 2024
1 parent f255be2 commit 7fecceb
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
1 change: 1 addition & 0 deletions posthog/clickhouse/migrations/0088_noop.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
operations = []

Check failure on line 1 in posthog/clickhouse/migrations/0088_noop.py

View workflow job for this annotation

GitHub Actions / Python code quality checks

Need type annotation for "operations" (hint: "operations: list[<type>] = ...")
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from posthog.clickhouse.client.migration_tools import run_sql_with_exceptions
from posthog.models.raw_sessions.sql import RAW_SESSION_TABLE_UPDATE_SQL

operations = [
run_sql_with_exceptions(RAW_SESSION_TABLE_UPDATE_SQL),
]
4 changes: 3 additions & 1 deletion posthog/models/raw_sessions/sql.py
Original file line number Diff line number Diff line change
Expand Up @@ -409,10 +409,12 @@ def source_nullable_float_column(column_name: str) -> str:

RAW_SESSION_TABLE_UPDATE_SQL = (
lambda: """
ALTER TABLE {table_name} MODIFY QUERY
ALTER TABLE {table_name} ON CLUSTER '{cluster}'
MODIFY QUERY
{select_sql}
""".format(
table_name=f"{TABLE_BASE_NAME}_mv",
cluster=settings.CLICKHOUSE_CLUSTER,
select_sql=RAW_SESSION_TABLE_MV_SELECT_SQL(),
)
)
Expand Down

0 comments on commit 7fecceb

Please sign in to comment.