Skip to content

Commit 4d3ca7b

Browse files
committed
fix(clickhouse): filter zero waits from quantile view and accept string order keys
The wait-time quantile materialized view now excludes wait_ms = 0 rows so it matches the count aggregation. order_key accepts a string or a number. Migration comments no longer contain semicolons that split the migration into invalid statements.
1 parent e08ee4f commit 4d3ca7b

2 files changed

Lines changed: 4 additions & 2 deletions

File tree

internal-packages/clickhouse/schema/035_create_queue_metrics_v1.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ SELECT
8888
max(env_limit) AS max_env_limit,
8989
sumIf(wait_ms, op = 'started') AS wait_ms_sum,
9090
countIf(op = 'started' AND wait_ms > 0) AS wait_ms_count,
91-
quantilesStateIf(0.5, 0.9, 0.95, 0.99)(wait_ms, op = 'started') AS wait_quantiles
91+
quantilesStateIf(0.5, 0.9, 0.95, 0.99)(wait_ms, op = 'started' AND wait_ms > 0) AS wait_quantiles
9292
FROM trigger_dev.queue_metrics_raw_v1
9393
GROUP BY organization_id, project_id, environment_id, queue_name, bucket_start;
9494

internal-packages/clickhouse/src/queueMetrics.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@ export const QueueMetricsRawV1Input = z.object({
77
environment_id: z.string(),
88
queue_name: z.string(),
99
event_time: z.string(),
10-
order_key: z.number().optional(),
10+
// Exact UInt64 ordering key; a string preserves precision past JS safe-integer range
11+
// (see entryOrderKey). A plain number is still accepted for small test values.
12+
order_key: z.union([z.string(), z.number()]).optional(),
1113
op: z.enum(["gauge", "enqueue", "started", "ack", "nack", "dlq"]),
1214
running: z.number().optional(),
1315
queued: z.number().optional(),

0 commit comments

Comments
 (0)