跳转到内容
数据质量 SQL查询示例

Catch event-field renames that hide rows from averages

Compare an old timing-field average with schema-aware coverage so an event rename cannot silently drop completed jobs.

中级job_finished已审核 2026-09-30测试用 阿帕奇 DataFusion 45.2.0

审阅者 Telemetry产品团队 上 . 我们检查了 SQL 语法、必需的事件字段、示例结果和查询使用限制. 谁负责审核此页面

问题已回答

Did a field rename make the duration average ignore completed jobs?

A query can keep returning a plausible average after instrumentation changes. Count all completed events, map each documented schema version to its timing field, and show the share with a usable value beside the average.

事件结构

查询期望的字段

字段类型为什么存在
timestamp_utcTimestampUTC finish-event time; use a fixed analysis window 中 production.
job_idUtf8One fictional completed logical job per row.
schema_versionInt64Version of the event contract; 1 uses duration_ms and 2 uses latency_ms.
duration_msInt64Release-1 duration, null on release 2.
latency_msInt64Release-2 duration, null on release 1.
DataFusion SQL

复制查询

sql
WITH normalized AS (
  SELECT
    job_id,
    schema_version,
    duration_ms,
    CASE schema_version
      WHEN 1 THEN duration_ms
      WHEN 2 THEN latency_ms
    END AS measured_ms
  FROM job_finished
)
SELECT
  COUNT(*) AS completed_jobs,
  COUNT(duration_ms) AS jobs_in_old_average,
  ROUND(AVG(duration_ms), 1) AS old_average_ms,
  COUNT(measured_ms) AS jobs_with_duration,
  SUM(CASE WHEN measured_ms IS NULL THEN 1 ELSE 0 END) AS unmeasured_jobs,
  ROUND(100.0 * COUNT(measured_ms) / NULLIF(COUNT(*), 0), 1)
    AS duration_coverage_pct,
  ROUND(AVG(measured_ms), 1) AS schema_aware_average_ms
FROM normalized;

此只读查询是针对空类型表计划和执行的 阿帕奇 DataFusion 45.2.0。确定性样本输出是综合的并单独审查;根据您自己的数据验证字段类型、阈值和业务定义。 阅读测试方法。

查询结果

A plausible average can cover only half the jobs

The old field averages two fictional jobs at 475 ms. The version-aware query covers all four at 580 ms.

completed_jobsjobs_in_old_averageold_average_msjobs_with_durationunmeasured_jobsduration_coverage_pctschema_aware_average_ms
4247540100580

综合示例输出。在将其用于操作决策之前,针对您自己的事件架构和阈值运行查询。

A plausible average can cover only half the jobs:来自 Catch event-field renames that hide rows from averages 示例结果的合成 jobs_with_duration 值的静态图表
确定性示例输出的可索引 SVG。下载它以获取带有归属的文章、操作手册或设计评论。

重现示例

下载示例数据

JSON 包包含类型化事件契约, reproducible 输入行、确切的 SQL、预期输出、审阅注释和引擎版本。 CSV 包含显示的结果。

SQL 是如何工作的

  1. 1The old query AVG(duration_ms) still returns 475 ms because SQL averages ignore nulls. Only two of four completed jobs contribute to it.
  2. 2The version-aware CASE maps release 1 to duration_ms and release 2 to latency_ms, giving 580 ms across all four fictional jobs.
  3. 3Keep duration coverage beside the average. An unknown version or a missing field can leave the average unchanged while coverage falls.

需要检查的边界情况

  • Use a fixed UTC time window when comparing releases; this four-row lesson leaves all fictional rows 中 scope.
  • This example assumes one finish row per completed logical job. Deduplicate repeated finish events by job_id before using it for a real job count.
  • A field rename is comparable only if both versions time the same start and stop points 中 the same unit.
  • A missing or unknown schema_version maps to null and lowers coverage; do not silently coalesce it to an old field.
  • The four rows are fictional and do not describe a customer, a real incident, or measured product performance.

推荐仪表板

  • Table: completed jobs, duration coverage, and average by release
  • Trend: duration coverage percentage over deploy time

警报指导

Alert on falling duration coverage only after establishing an expected minimum event count and documenting the version mapping.

读取警报设置

设置此查询需要的事件

相关埋点和指南

继续分析

在你的事件上运行

创建表,调整字段并保存结果

免费开始,发送结构化事件,并将查询结果用作图表、共享仪表板小部件或警报输入。

获取 API 密钥