-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Support property group migrations on distributed and sharded tables #24274
Conversation
… writable (sharded) tables
|
||
def get_create_table_pieces(self, table: TableName) -> Iterable[str]: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure what the correct terminology is here. They're not expressions, but also not whole statements, so just went with something generic.
TableName = str | ||
ColumnName = str | ||
PropertyGroupName = str |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(These aliases are just for documentation purposes.)
"sharded_events": event_property_group_definitions, | ||
"events": { | ||
column_name: { | ||
group_name: dataclasses.replace(group_definition, is_materialized=False) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is kind of clunky — maybe in retrospect it would have been better to have this as some sort of flag up at the table level rather than each individual property group definition…
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah it's definitely not easy reading
for group_name in groups: | ||
yield self.__get_column_definition(table, column, group_name) | ||
for index_definition in self.__get_index_definitions(table, column, group_name): | ||
yield f"INDEX {index_definition}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I dig this. Really nice use of python iterator building up table bits
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm!
Co-authored-by: James Greenhill <[email protected]>
Problem
#24152 added the property group columns to the sharded tables, but not the distributed tables.
Changes
This extracts the migration related parts from #24171:
PropertyGroupManager
to more cleanly support managing multiple tablessharded_events
table in migrationposthog/models/event/sql.py
so that they are created in test environment which does not apply migrations, and updates migrations to useIF NOT EXISTS
to avoid conflictsDoes this work well for both Cloud and self-hosted?
Yes.
How did you test this code?
Run migrations and see updated snapshot.