Skip to content

Commit

Permalink
update toStartOfWeek, primary keys and order by
Browse files Browse the repository at this point in the history
  • Loading branch information
kylemumma committed Feb 25, 2025
1 parent 1e93f04 commit 08033cd
Showing 1 changed file with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ def forwards_ops(self) -> Sequence[SqlOperation]:
table_name=self.str_local_table,
engine=table_engines.AggregatingMergeTree(
storage_set=self.storage_set_key,
primary_key="(organization_id, attr_key)",
order_by="(organization_id, attr_key, item_type, attr_value, project_id, timestamp, retention_days)",
primary_key="(organization_id, project_id, timestamp, item_type, attr_key)",
order_by="(organization_id, project_id, timestamp, item_type, attr_key, attr_value, retention_days)",
partition_by="(retention_days, toMonday(timestamp))",
settings={
"index_granularity": self.granularity,
Expand Down Expand Up @@ -102,7 +102,7 @@ def forwards_ops(self) -> Sequence[SqlOperation]:
item_type,
attrs.1 as attr_key,
attrs.2 as attr_value,
toStartOfDay(timestamp) AS timestamp,
toStartOfWeek(timestamp) AS timestamp,
retention_days,
1 AS count
FROM eap_items_1_local
Expand All @@ -125,8 +125,8 @@ def forwards_ops(self) -> Sequence[SqlOperation]:
table_name=self.num_local_table,
engine=table_engines.AggregatingMergeTree(
storage_set=self.storage_set_key,
primary_key="(organization_id, attr_key)",
order_by="(organization_id, attr_key, item_type, timestamp, project_id, retention_days)",
primary_key="(organization_id, project_id, timestamp, item_type, attr_key)",
order_by="(organization_id, project_id, timestamp, item_type, attr_key, retention_days)",
partition_by="(retention_days, toMonday(timestamp))",
settings={
"index_granularity": self.granularity,
Expand Down Expand Up @@ -159,7 +159,7 @@ def forwards_ops(self) -> Sequence[SqlOperation]:
attrs.1 as attr_key,
attrs.2 as attr_min_value,
attrs.2 as attr_max_value,
toStartOfDay(timestamp) AS timestamp,
toStartOfWeek(timestamp) AS timestamp,
retention_days,
1 AS count
FROM eap_items_1_local
Expand Down

0 comments on commit 08033cd

Please sign in to comment.