{
  "license": "CC BY 4.0",
  "licenseUrl": "https://creativecommons.org/licenses/by/4.0/",
  "recipe": {
    "slug": "duplicate-event-ids",
    "title": "Find Duplicate Event IDs",
    "testedWith": "Apache DataFusion 45.2.0",
    "lastReviewed": "2026-07-27"
  },
  "contract": {
    "tableName": "telemetry_events",
    "schema": [
      {
        "name": "timestamp_utc",
        "type": "Timestamp",
        "description": "Event occurrence time."
      },
      {
        "name": "event_id",
        "type": "Utf8",
        "description": "Stable identifier reused for delivery retries."
      },
      {
        "name": "event_name",
        "type": "Utf8",
        "description": "Event contract name."
      },
      {
        "name": "source",
        "type": "Utf8",
        "description": "Producer name."
      }
    ]
  },
  "query": "SELECT\n  event_id,\n  event_name,\n  source,\n  COUNT(*) AS deliveries,\n  MIN(timestamp_utc) AS first_seen_at,\n  MAX(timestamp_utc) AS last_seen_at\nFROM telemetry_events\nWHERE timestamp_utc >= now() - INTERVAL '7 days'\n  AND event_id IS NOT NULL\nGROUP BY event_id, event_name, source\nHAVING COUNT(*) > 1\nORDER BY deliveries DESC, last_seen_at DESC\nLIMIT 100;",
  "fixtureKind": "schema-example",
  "inputRows": [
    {
      "timestamp_utc": "2026-07-28T10:00:00Z",
      "event_id": "event_id_example_1",
      "event_name": "workflow_completed",
      "source": "source_example_1"
    },
    {
      "timestamp_utc": "2026-07-28T11:00:00Z",
      "event_id": "event_id_example_2",
      "event_name": "workflow_completed",
      "source": "source_example_2"
    },
    {
      "timestamp_utc": "2026-07-28T12:00:00Z",
      "event_id": "event_id_example_3",
      "event_name": "workflow_completed",
      "source": "source_example_3"
    }
  ],
  "illustrativeInputRows": [
    {
      "timestamp_utc": "2026-07-28T10:00:00Z",
      "event_id": "event_id_example_1",
      "event_name": "workflow_completed",
      "source": "source_example_1"
    },
    {
      "timestamp_utc": "2026-07-28T11:00:00Z",
      "event_id": "event_id_example_2",
      "event_name": "workflow_completed",
      "source": "source_example_2"
    },
    {
      "timestamp_utc": "2026-07-28T12:00:00Z",
      "event_id": "event_id_example_3",
      "event_name": "workflow_completed",
      "source": "source_example_3"
    }
  ],
  "expectedOutput": {
    "columns": [
      "event_id",
      "event_name",
      "source",
      "deliveries",
      "first_seen_at",
      "last_seen_at"
    ],
    "rows": [
      {
        "event_id": "evt_8f31",
        "event_name": "invoice_paid",
        "source": "stripe_webhook",
        "deliveries": 4,
        "first_seen_at": "12:01:03",
        "last_seen_at": "12:06:44"
      },
      {
        "event_id": "evt_77ac",
        "event_name": "job_completed",
        "source": "billing_worker",
        "deliveries": 2,
        "first_seen_at": "10:14:22",
        "last_seen_at": "10:14:39"
      }
    ]
  },
  "notes": [
    "The compact input rows demonstrate field names and JSON types; they are not claimed to generate the displayed aggregate by themselves.",
    "The expected output is deterministic synthetic review data for the documented output shape.",
    "Adapt time windows, thresholds, identities, and business definitions before operational use."
  ]
}