Esempio n. 1
0
 def forwards_dist(self) -> Sequence[operations.SqlOperation]:
     return [
         operations.CreateTable(
             storage_set=StorageSetKey.EVENTS,
             table_name="errors_dist_new",
             columns=columns,
             engine=table_engines.Distributed(
                 local_table_name="errors_local",
                 sharding_key=sample_expr,
             ),
         ),
         operations.AddColumn(
             storage_set=StorageSetKey.EVENTS,
             table_name="errors_dist_new",
             column=Column(
                 "_tags_hash_map",
                 Array(UInt(64),
                       Modifiers(materialized=TAGS_HASH_MAP_COLUMN)),
             ),
             after="tags",
         ),
         operations.DropTable(
             storage_set=StorageSetKey.EVENTS,
             table_name="errors_dist",
         ),
         operations.RenameTable(
             storage_set=StorageSetKey.EVENTS,
             old_table_name="errors_dist_new",
             new_table_name="errors_dist",
         ),
         operations.CreateTable(
             storage_set=StorageSetKey.EVENTS_RO,
             table_name="errors_dist_ro",
             columns=columns,
             engine=table_engines.Distributed(
                 local_table_name="errors_local",
                 sharding_key=sample_expr,
             ),
         ),
     ]
Esempio n. 2
0
 def forwards_local(self) -> Sequence[operations.Operation]:
     return [
         operations.CreateTable(
             storage_set=StorageSetKey.EVENTS,
             table_name="errors_local_new",
             columns=columns,
             engine=table_engines.ReplacingMergeTree(
                 storage_set=StorageSetKey.EVENTS,
                 version_column="deleted",
                 order_by=
                 "(project_id, toStartOfDay(timestamp), primary_hash, %s)" %
                 sample_expr,
                 partition_by="(retention_days, toMonday(timestamp))",
                 sample_by=sample_expr,
                 ttl="timestamp + toIntervalDay(retention_days)",
                 settings={"index_granularity": "8192"},
             ),
         ),
         operations.AddColumn(
             storage_set=StorageSetKey.EVENTS,
             table_name="errors_local_new",
             column=Column(
                 "_tags_hash_map",
                 Array(UInt(64),
                       Modifiers(materialized=TAGS_HASH_MAP_COLUMN)),
             ),
             after="tags",
         ),
         operations.DropTable(
             storage_set=StorageSetKey.EVENTS,
             table_name="errors_local",
         ),
         operations.RenameTable(
             storage_set=StorageSetKey.EVENTS,
             old_table_name="errors_local_new",
             new_table_name="errors_local",
         ),
     ]