Skip to content

Conversation

@phacops
Copy link
Contributor

@phacops phacops commented Jan 26, 2026

Add a new timestamp_ns column of type UInt16 to the eap_items_1 table for storing sub-second timestamp precision.

The migration:

  • Adds the timestamp_ns column after the existing timestamp column
  • Modifies the sort key to include timestamp_ns after timestamp: (organization_id, project_id, item_type, timestamp, timestamp_ns, trace_id, item_id)
  • Includes proper backwards migration to revert the sort key and drop the column

Add a new UInt16 column `timestamp_ns` to the eap_items_1 table for
storing sub-second timestamp precision. The column is added after the
existing `timestamp` column and included in the sort key.

Co-Authored-By: Claude <noreply@anthropic.com>
@phacops phacops requested review from a team as code owners January 26, 2026 23:27
@github-actions
Copy link

This PR has a migration; here is the generated SQL for ./snuba/migrations/groups.py ()

-- start migrations

-- forward migration events_analytics_platform : 0052_add_timestamp_ns_column
Local op: 
                    ALTER TABLE eap_items_1_local
                    ADD COLUMN IF NOT EXISTS timestamp_ns UInt16 AFTER timestamp,
                    MODIFY ORDER BY (organization_id, project_id, item_type, timestamp, timestamp_ns, trace_id, item_id)
                
Distributed op: ALTER TABLE eap_items_1_dist ADD COLUMN IF NOT EXISTS timestamp_ns UInt16 AFTER timestamp
-- end forward migration events_analytics_platform : 0052_add_timestamp_ns_column




-- backward migration events_analytics_platform : 0052_add_timestamp_ns_column
Distributed op: ALTER TABLE eap_items_1_dist ON CLUSTER 'cluster_one_sh' DROP COLUMN IF EXISTS timestamp_ns;
Local op: 
                    ALTER TABLE eap_items_1_local
                    MODIFY ORDER BY (organization_id, project_id, item_type, timestamp, trace_id, item_id)
                
Local op: ALTER TABLE eap_items_1_local ON CLUSTER 'cluster_one_sh' DROP COLUMN IF EXISTS timestamp_ns;
-- end backward migration events_analytics_platform : 0052_add_timestamp_ns_column

),
operations.RunSql(
storage_set=self.storage_set_key,
statement=f"ALTER TABLE {self.dist_table_name} ADD COLUMN IF NOT EXISTS timestamp_ns UInt16 AFTER timestamp",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have an add column operation for this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants