def backwards_dist(self) -> Sequence[operations.Operation]: return [ operations.DropTable(storage_set=StorageSetKey.EVENTS, table_name="sentry_dist"), operations.DropTable(storage_set=StorageSetKey.EVENTS_RO, table_name="sentry_dist_ro"), ]
def backwards_dist(self) -> Sequence[operations.Operation]: return [ operations.DropTable( storage_set=StorageSetKey.SESSIONS, table_name="sessions_hourly_dist", ), operations.DropTable( storage_set=StorageSetKey.SESSIONS, table_name="sessions_raw_dist", ), ]
def backwards_dist(self) -> Sequence[operations.Operation]: return [ operations.DropTable(storage_set=StorageSetKey.OUTCOMES, table_name="outcomes_hourly_local"), operations.DropTable( storage_set=StorageSetKey.OUTCOMES, table_name="outcomes_raw_dist", ), ]
def backwards_local(self) -> Sequence[operations.Operation]: # Drop the temporary tables used by forwards_local if they exist return [ operations.DropTable( storage_set=StorageSetKey.EVENTS, table_name=TABLE_NAME_NEW, ), operations.DropTable( storage_set=StorageSetKey.EVENTS, table_name=TABLE_NAME_OLD, ), ]
def backwards_local(self) -> Sequence[operations.SqlOperation]: return [ operations.DropTable( storage_set=StorageSetKey.SESSIONS, table_name="sessions_hourly_mv_local", ), operations.DropTable( storage_set=StorageSetKey.SESSIONS, table_name="sessions_hourly_local", ), operations.DropTable( storage_set=StorageSetKey.SESSIONS, table_name="sessions_raw_local", ), ]
def backwards_local(self) -> Sequence[operations.SqlOperation]: return [ operations.DropTable( storage_set=StorageSetKey.CDC, table_name="groupedmessage_local", ) ]
def backwards_local(self) -> Sequence[operations.Operation]: return [ operations.DropTable( storage_set=StorageSetKey.TRANSACTIONS, table_name="spans_experimental_local", ), ]
def backwards_local(self) -> Sequence[operations.SqlOperation]: return [ operations.DropTable( storage_set=StorageSetKey.METRICS, table_name=get_consolidated_mv_name("sets"), ) ]
def backwards_local(self) -> Sequence[operations.SqlOperation]: return [ operations.DropTable( storage_set=StorageSetKey.METRICS, table_name=get_polymorphic_mv_name(mv_type), ) for mv_type in ["sets", "counters", "distributions"] ]
def backwards_dist(self) -> Sequence[operations.SqlOperation]: return [ operations.DropTable( storage_set=StorageSetKey.PROFILES, table_name="profiles_dist", ) ]
def backwards_local(self) -> Sequence[operations.SqlOperation]: return [ operations.DropTable( storage_set=StorageSetKey.REPLAYS, table_name="replays_local", ), ]
def backwards_local(self) -> Sequence[operations.SqlOperation]: return [ operations.DropTable( storage_set=StorageSetKey.METRICS, table_name=get_polymorphic_mv_v3_name("counters"), ) ]
def forwards_local(self) -> Sequence[operations.SqlOperation]: return [ operations.DropTable(storage_set=StorageSetKey.METRICS, table_name=table_name) for table_name in [ "metrics_counters_consolidated_mv_local", "metrics_counters_mv_10s_local", "metrics_counters_mv_3600s_local", "metrics_counters_mv_86400s_local", "metrics_counters_mv_local", "metrics_counters_polymorphic_mv_local", "metrics_counters_polymorphic_mv_v2_local", "metrics_counters_polymorphic_mv_v3_local", "metrics_distributions_consolidated_mv_local", "metrics_distributions_mv_10s_local", "metrics_distributions_mv_3600s_local", "metrics_distributions_mv_86400s_local", "metrics_distributions_mv_local", "metrics_distributions_polymorphic_mv_local", "metrics_distributions_polymorphic_mv_v2_local", "metrics_distributions_polymorphic_mv_v3_local", "metrics_sets_consolidated_mv_local", "metrics_sets_mv_10s_local", "metrics_sets_mv_3600s_local", "metrics_sets_mv_86400s_local", "metrics_sets_mv_local", "metrics_sets_polymorphic_mv_local", "metrics_sets_polymorphic_mv_v2_local", "metrics_sets_polymorphic_mv_v3_local", ] ]
def backwards_local(self) -> Sequence[operations.SqlOperation]: return [ operations.DropTable( storage_set=StorageSetKey.DISCOVER, table_name="discover_local", ) ]
def backwards_dist(self) -> Sequence[operations.SqlOperation]: return [ operations.DropTable( storage_set=StorageSetKey.CDC, table_name="groupassignee_dist", ) ]
def backwards_local(self) -> Sequence[operations.Operation]: return [ operations.DropTable( storage_set=StorageSetKey.EVENTS, table_name="groupassignee_local", ) ]
def backwards_local(self) -> Sequence[operations.SqlOperation]: return [ operations.DropTable( storage_set=StorageSetKey.EVENTS, table_name="errors_local", ) ]
def backwards_local(self) -> Sequence[operations.SqlOperation]: return [ operations.DropTable( storage_set=StorageSetKey.TRANSACTIONS, table_name="transactions_local", ) ]
def backwards_local(self) -> Sequence[operations.SqlOperation]: return [ operations.DropTable( storage_set=StorageSetKey.MIGRATIONS, table_name="migrations_local", ) ]
def backwards_dist(self) -> Sequence[operations.Operation]: return [ operations.DropTable( storage_set=StorageSetKey.EVENTS, table_name="groupedmessage_dist", ) ]
def backwards_dist(self) -> Sequence[operations.SqlOperation]: return [ operations.DropTable( storage_set=StorageSetKey.GENERIC_METRICS_SETS, table_name="generic_metric_sets_aggregated_dist", ) ]
def backwards_local(self) -> Sequence[operations.SqlOperation]: return [ operations.DropTable( storage_set=StorageSetKey.METRICS, table_name=get_mv_name("distributions", granularity=10), ) ]
def backwards_local(self) -> Sequence[operations.SqlOperation]: return [ operations.DropTable( storage_set=StorageSetKey.OUTCOMES, table_name="outcomes_mv_hourly_local", ), operations.CreateMaterializedView( storage_set=StorageSetKey.OUTCOMES, view_name="outcomes_mv_hourly_local", destination_table_name="outcomes_hourly_local", columns=old_materialized_view_columns, query=""" SELECT org_id, project_id, ifNull(key_id, 0) AS key_id, toStartOfHour(timestamp) AS timestamp, outcome, ifNull(reason, 'none') AS reason, count() AS times_seen FROM outcomes_raw_local GROUP BY org_id, project_id, key_id, timestamp, outcome, reason """, ), ]
def backwards_local(self) -> Sequence[operations.SqlOperation]: return [ operations.DropTable( storage_set=StorageSetKey.GENERIC_METRICS_SETS, table_name=self.local_table_name, ) ]
def backwards_dist(self) -> Sequence[operations.Operation]: return [ operations.DropTable( storage_set=StorageSetKey.QUERYLOG, table_name="querylog_dist", ) ]
def ensure_drop_temporary_tables() -> None: cluster = get_cluster(StorageSetKey.EVENTS) if not cluster.is_single_node(): return clickhouse = cluster.get_query_connection(ClickhouseClientSettings.MIGRATE) clickhouse.execute( operations.DropTable( storage_set=StorageSetKey.EVENTS, table_name=TABLE_NAME_NEW, ).format_sql()) clickhouse.execute( operations.DropTable( storage_set=StorageSetKey.EVENTS, table_name=TABLE_NAME_OLD, ).format_sql())
def backwards_local(self) -> Sequence[operations.SqlOperation]: return [ operations.DropTable( storage_set=StorageSetKey.METRICS, table_name=get_polymorphic_mv_variant_name( "sets", self.mv_version), ) ]
def get_reverse_table_migration( table_name: str) -> Sequence[operations.SqlOperation]: return [ operations.DropTable( storage_set=StorageSetKey.METRICS, table_name=table_name, ), ]
def backwards_local(self) -> Sequence[operations.Operation]: return [ operations.DropTable( storage_set=StorageSetKey.SESSIONS, table_name="sessions_hourly_mv_local", ), create_matview_v1, ]
def forwards_local(self) -> Sequence[operations.SqlOperation]: return [ operations.DropTable( storage_set=StorageSetKey.METRICS, table_name=get_polymorphic_mv_variant_name( "distributions", self.mv_version), ), get_forward_view_migration_polymorphic_table_v3( source_table_name=self.raw_table_name, table_name=self.dist_table_name, aggregation_col_schema=COL_SCHEMA_DISTRIBUTIONS_V2, mv_name=get_polymorphic_mv_variant_name( "distributions", self.mv_version), aggregation_states= ("quantilesState(0.5, 0.75, 0.9, 0.95, 0.99)((arrayJoin(distribution_values) AS values_rows)) as percentiles, " "minState(values_rows) as min, " "maxState(values_rows) as max, " "avgState(values_rows) as avg, " "sumState(values_rows) as sum, " "countState(values_rows) as count, " "histogramState(250)(values_rows) as histogram_buckets"), metric_type="distribution", target_mat_version=4, ), operations.DropTable( storage_set=StorageSetKey.METRICS, table_name=get_polymorphic_mv_variant_name( "sets", self.mv_version), ), get_forward_view_migration_polymorphic_table_v3( source_table_name=self.raw_table_name, table_name=self.sets_table_name, aggregation_col_schema=[ Column("value", AggregateFunction("uniqCombined64", [UInt(64)])), ], aggregation_states= "uniqCombined64State(arrayJoin(set_values)) as value", mv_name=get_polymorphic_mv_variant_name( "sets", self.mv_version), metric_type="set", target_mat_version=4, ), ]