{
 "synthetic": true,
 "note": "Computed by the build script from the synthetic source database. Seed 20260930.",
 "source": {
  "tables": 7,
  "columns": 34,
  "rows": {
   "src_brand": 5,
   "src_inventory_snapshot": 1800,
   "src_invoice_line": 1812,
   "src_movement": 1800,
   "src_product": 12,
   "src_promo": 49,
   "src_region": 5
  },
  "profile": {
   "distinct_grain_keys": 1800,
   "invoice_lines": 1812,
   "null_movement_keys": 6,
   "sku_no_exact_match": 9,
   "promo_rows": 49
  }
 },
 "schema": {
  "src_brand": {
   "columns": [
    {
     "name": "brand_id",
     "type": "TEXT",
     "pk": true
    },
    {
     "name": "brand_name",
     "type": "TEXT",
     "pk": false
    }
   ],
   "fks": [],
   "rows": 5
  },
  "src_inventory_snapshot": {
   "columns": [
    {
     "name": "snapshot_id",
     "type": "TEXT",
     "pk": true
    },
    {
     "name": "month",
     "type": "TEXT",
     "pk": false
    },
    {
     "name": "region_id",
     "type": "TEXT",
     "pk": false
    },
    {
     "name": "sku",
     "type": "TEXT",
     "pk": false
    },
    {
     "name": "cases_on_hand",
     "type": "INTEGER",
     "pk": false
    }
   ],
   "fks": [
    {
     "col": "sku",
     "ref": "src_product",
     "refcol": "sku"
    },
    {
     "col": "region_id",
     "ref": "src_region",
     "refcol": "region_id"
    }
   ],
   "rows": 1800
  },
  "src_invoice_line": {
   "columns": [
    {
     "name": "invoice_line_id",
     "type": "TEXT",
     "pk": true
    },
    {
     "name": "month",
     "type": "TEXT",
     "pk": false
    },
    {
     "name": "region_id",
     "type": "TEXT",
     "pk": false
    },
    {
     "name": "sku",
     "type": "TEXT",
     "pk": false
    },
    {
     "name": "gross_sales",
     "type": "INTEGER",
     "pk": false
    },
    {
     "name": "discounts",
     "type": "INTEGER",
     "pk": false
    },
    {
     "name": "net_sales",
     "type": "INTEGER",
     "pk": false
    },
    {
     "name": "cogs",
     "type": "INTEGER",
     "pk": false
    }
   ],
   "fks": [
    {
     "col": "sku",
     "ref": "src_product",
     "refcol": "sku"
    },
    {
     "col": "region_id",
     "ref": "src_region",
     "refcol": "region_id"
    }
   ],
   "rows": 1812
  },
  "src_movement": {
   "columns": [
    {
     "name": "movement_id",
     "type": "TEXT",
     "pk": true
    },
    {
     "name": "month",
     "type": "TEXT",
     "pk": false
    },
    {
     "name": "region_id",
     "type": "TEXT",
     "pk": false
    },
    {
     "name": "sku",
     "type": "TEXT",
     "pk": false
    },
    {
     "name": "shipments_cases",
     "type": "INTEGER",
     "pk": false
    },
    {
     "name": "depletions_cases",
     "type": "INTEGER",
     "pk": false
    }
   ],
   "fks": [
    {
     "col": "sku",
     "ref": "src_product",
     "refcol": "sku"
    },
    {
     "col": "region_id",
     "ref": "src_region",
     "refcol": "region_id"
    }
   ],
   "rows": 1800
  },
  "src_product": {
   "columns": [
    {
     "name": "sku",
     "type": "TEXT",
     "pk": true
    },
    {
     "name": "product_name",
     "type": "TEXT",
     "pk": false
    },
    {
     "name": "brand_id",
     "type": "TEXT",
     "pk": false
    },
    {
     "name": "category",
     "type": "TEXT",
     "pk": false
    }
   ],
   "fks": [
    {
     "col": "brand_id",
     "ref": "src_brand",
     "refcol": "brand_id"
    }
   ],
   "rows": 12
  },
  "src_promo": {
   "columns": [
    {
     "name": "promo_id",
     "type": "TEXT",
     "pk": true
    },
    {
     "name": "sku",
     "type": "TEXT",
     "pk": false
    },
    {
     "name": "region_id",
     "type": "TEXT",
     "pk": false
    },
    {
     "name": "start_month",
     "type": "TEXT",
     "pk": false
    },
    {
     "name": "end_month",
     "type": "TEXT",
     "pk": false
    },
    {
     "name": "promo_type",
     "type": "TEXT",
     "pk": false
    },
    {
     "name": "discount_pct",
     "type": "REAL",
     "pk": false
    }
   ],
   "fks": [
    {
     "col": "region_id",
     "ref": "src_region",
     "refcol": "region_id"
    },
    {
     "col": "sku",
     "ref": "src_product",
     "refcol": "sku"
    }
   ],
   "rows": 49
  },
  "src_region": {
   "columns": [
    {
     "name": "region_id",
     "type": "TEXT",
     "pk": true
    },
    {
     "name": "region_name",
     "type": "TEXT",
     "pk": false
    }
   ],
   "fks": [],
   "rows": 5
  }
 },
 "checks": [
  {
   "id": "S1",
   "scope": "source",
   "severity": "error",
   "kind": "zero",
   "round": 1,
   "title": "Duplicate grain keys in invoice lines (extra rows per month, region, SKU)",
   "sql": "SELECT COALESCE(SUM(n - 1), 0) FROM (\n  SELECT COUNT(*) AS n FROM src_invoice_line\n  GROUP BY month, region_id, UPPER(TRIM(sku)) HAVING COUNT(*) > 1)",
   "result": {
    "value": 12,
    "ok": false,
    "status": "FAIL"
   }
  },
  {
   "id": "S2",
   "scope": "source",
   "severity": "error",
   "kind": "zero",
   "round": 1,
   "title": "Invoice lines whose SKU does not match a product exactly",
   "sql": "SELECT COUNT(*) FROM src_invoice_line WHERE sku NOT IN (SELECT sku FROM src_product)",
   "result": {
    "value": 9,
    "ok": false,
    "status": "FAIL"
   }
  },
  {
   "id": "S3",
   "scope": "source",
   "severity": "error",
   "kind": "zero",
   "round": 1,
   "title": "Movement rows with a missing key (month, region or SKU)",
   "sql": "SELECT COUNT(*) FROM src_movement WHERE month IS NULL OR region_id IS NULL OR sku IS NULL",
   "result": {
    "value": 6,
    "ok": false,
    "status": "FAIL"
   }
  },
  {
   "id": "S4",
   "scope": "source",
   "severity": "error",
   "kind": "zero",
   "round": 1,
   "title": "Overlapping promotions for the same SKU and region",
   "sql": "SELECT COUNT(*) FROM src_promo a JOIN src_promo b\n  ON a.sku = b.sku AND a.region_id = b.region_id AND a.promo_id < b.promo_id\n AND a.start_month <= b.end_month AND b.start_month <= a.end_month",
   "result": {
    "value": 5,
    "ok": false,
    "status": "FAIL"
   }
  },
  {
   "id": "S5",
   "scope": "source",
   "severity": "warn",
   "kind": "zero",
   "round": 2,
   "title": "Depletions above 4x the SKU-region average (possible unit error)",
   "sql": "SELECT COUNT(*) FROM (\n  SELECT depletions_cases AS d,\n         AVG(depletions_cases) OVER (PARTITION BY region_id, sku) AS avg_d\n  FROM src_movement WHERE region_id IS NOT NULL) WHERE d > 4 * avg_d",
   "result": {
    "value": 3,
    "ok": false,
    "status": "warn"
   }
  },
  {
   "id": "S6",
   "scope": "source",
   "severity": "error",
   "kind": "zero",
   "round": 1,
   "title": "Invoice lines whose region is not in the region table",
   "sql": "SELECT COUNT(*) FROM src_invoice_line WHERE region_id NOT IN (SELECT region_id FROM src_region)",
   "result": {
    "value": 0,
    "ok": true,
    "status": "pass"
   }
  },
  {
   "id": "S7",
   "scope": "source",
   "severity": "error",
   "kind": "zero",
   "round": 1,
   "title": "Invoice lines where net sales differs from gross sales minus discounts",
   "sql": "SELECT COUNT(*) FROM src_invoice_line WHERE ABS(net_sales - (gross_sales - discounts)) > 1",
   "result": {
    "value": 4,
    "ok": false,
    "status": "FAIL"
   }
  },
  {
   "id": "M1",
   "scope": "model",
   "severity": "error",
   "kind": "equal",
   "round": 1,
   "title": "Row count: source invoice lines vs model rows plus quarantined rows",
   "sql": "SELECT (SELECT COUNT(*) FROM src_invoice_line),\n       (SELECT COUNT(*) FROM fact_sales_monthly_{v}) + {q_rows}",
   "result": {
    "v1": {
     "a": 1812,
     "b": 1803,
     "diff": 9,
     "ok": false,
     "status": "FAIL"
    },
    "v2": {
     "a": 1812,
     "b": 1812,
     "diff": 0,
     "ok": true,
     "status": "pass"
    }
   }
  },
  {
   "id": "M2",
   "scope": "model",
   "severity": "error",
   "kind": "equal",
   "round": 1,
   "title": "Net sales total: source vs model plus quarantined",
   "sql": "SELECT (SELECT SUM(net_sales) FROM src_invoice_line),\n       (SELECT SUM(net_sales) FROM fact_sales_monthly_{v}) + {q_net}",
   "result": {
    "v1": {
     "a": 769672150,
     "b": 767877297,
     "diff": 1794853,
     "ok": false,
     "status": "FAIL"
    },
    "v2": {
     "a": 769672150,
     "b": 769672150,
     "diff": 0,
     "ok": true,
     "status": "pass"
    }
   }
  },
  {
   "id": "M3",
   "scope": "model",
   "severity": "error",
   "kind": "zero",
   "round": 1,
   "title": "Join fan-out: fact rows beyond one per month, region, SKU",
   "sql": "SELECT COUNT(*) - COUNT(DISTINCT month || '|' || region_id || '|' || sku) FROM fact_sales_monthly_{v}",
   "result": {
    "v1": {
     "value": 18,
     "ok": false,
     "status": "FAIL"
    },
    "v2": {
     "value": 0,
     "ok": true,
     "status": "pass"
    }
   }
  },
  {
   "id": "M4",
   "scope": "model",
   "severity": "error",
   "kind": "zero",
   "round": 1,
   "title": "Null keys in the fact table",
   "sql": "SELECT COUNT(*) FROM fact_sales_monthly_{v} WHERE month IS NULL OR region_id IS NULL OR sku IS NULL",
   "result": {
    "v1": {
     "value": 0,
     "ok": true,
     "status": "pass"
    },
    "v2": {
     "value": 0,
     "ok": true,
     "status": "pass"
    }
   }
  },
  {
   "id": "M5",
   "scope": "model",
   "severity": "error",
   "kind": "zero",
   "round": 1,
   "title": "Fact rows with no matching product or region",
   "sql": "SELECT COUNT(*) FROM fact_sales_monthly_{v} f\nWHERE f.sku NOT IN (SELECT sku FROM dim_product_{v}) OR f.region_id NOT IN (SELECT region_id FROM dim_region_{v})",
   "result": {
    "v1": {
     "value": 0,
     "ok": true,
     "status": "pass"
    },
    "v2": {
     "value": 0,
     "ok": true,
     "status": "pass"
    }
   }
  },
  {
   "id": "M6",
   "scope": "model",
   "severity": "error",
   "kind": "zero",
   "round": 1,
   "title": "Source month-region-SKU keys missing from the fact table (dropped by a join)",
   "sql": "SELECT COUNT(*) FROM (SELECT DISTINCT month, region_id, UPPER(TRIM(sku)) AS sku FROM src_invoice_line) i\nLEFT JOIN fact_sales_monthly_{v} f ON f.month = i.month AND f.region_id = i.region_id AND f.sku = i.sku\nWHERE f.sku IS NULL",
   "result": {
    "v1": {
     "value": 15,
     "ok": false,
     "status": "FAIL"
    },
    "v2": {
     "value": 0,
     "ok": true,
     "status": "pass"
    }
   }
  },
  {
   "id": "M7",
   "scope": "model",
   "severity": "error",
   "kind": "zero",
   "round": 1,
   "title": "Fact rows where net sales differs from gross sales minus discounts",
   "sql": "SELECT COUNT(*) FROM fact_sales_monthly_{v} WHERE ABS(net_sales - (gross_sales - discounts)) > 1",
   "result": {
    "v1": {
     "value": 4,
     "ok": false,
     "status": "FAIL"
    },
    "v2": {
     "value": 4,
     "ok": false,
     "status": "FAIL"
    }
   }
  },
  {
   "id": "M8",
   "scope": "model",
   "severity": "error",
   "kind": "zero",
   "round": 1,
   "title": "Duplicate product keys in the product dimension",
   "sql": "SELECT COUNT(*) - COUNT(DISTINCT sku) FROM dim_product_{v}",
   "result": {
    "v1": {
     "value": 0,
     "ok": true,
     "status": "pass"
    },
    "v2": {
     "value": 0,
     "ok": true,
     "status": "pass"
    }
   }
  },
  {
   "id": "M9",
   "scope": "model",
   "severity": "warn",
   "kind": "zero",
   "round": 2,
   "title": "Fact rows with no movement match (shipments and depletions are null)",
   "sql": "SELECT COUNT(*) FROM fact_sales_monthly_{v} WHERE shipments_cases IS NULL",
   "result": {
    "v1": {
     "value": 0,
     "ok": true,
     "status": "pass"
    },
    "v2": {
     "value": 6,
     "ok": false,
     "status": "warn"
    }
   }
  }
 ],
 "tally": {
  "v1": {
   "total": 9,
   "passed": 4,
   "failed": 5,
   "warned": 0
  },
  "v2": {
   "total": 9,
   "passed": 7,
   "failed": 1,
   "warned": 1
  }
 },
 "source_tally": {
  "total": 7,
  "clean": 1,
  "flagged": 6
 },
 "n_checks": 16,
 "n_source": 7,
 "n_model": 9,
 "defects": [
  {
   "id": "D1",
   "name": "Duplicate invoice lines (double load)",
   "seeded": 12,
   "check": "S1",
   "found": 12,
   "exact": true
  },
  {
   "id": "D2",
   "name": "SKU written with different case or trailing space",
   "seeded": 9,
   "check": "S2",
   "found": 9,
   "exact": true
  },
  {
   "id": "D3",
   "name": "Movement rows with a missing region key",
   "seeded": 6,
   "check": "S3",
   "found": 6,
   "exact": true
  },
  {
   "id": "D4",
   "name": "Overlapping promotions for one SKU and region",
   "seeded": 5,
   "check": "S4",
   "found": 5,
   "exact": true
  },
  {
   "id": "D5",
   "name": "Net sales that does not equal gross minus discounts",
   "seeded": 4,
   "check": "S7",
   "found": 4,
   "exact": true
  },
  {
   "id": "D6",
   "name": "Depletions inflated ten-fold (unit error)",
   "seeded": 3,
   "check": "S5",
   "found": 3,
   "exact": true
  }
 ],
 "defects_caught": 6,
 "defects_seeded": 6,
 "defects_exact": 6,
 "v1": {
  "rows": 1803,
  "distinct_keys": 1785,
  "extra_from_fanout": 18,
  "dropped_by_inner_joins": 15,
  "fanout_from_promos": 6,
  "net_src": 769672150,
  "net_model": 767877297,
  "row_check_balanced": false
 },
 "v2": {
  "rows": 1800,
  "distinct_keys": 1800,
  "net_model": 764620724,
  "quarantined_rows": 12,
  "quarantined_net": 5051426
 },
 "reference": {
  "rows": 1800,
  "net": 764620724
 },
 "eval": {
  "v1": {
   "tables_ref": 7,
   "tables_matched": 4,
   "extra_tables": [
    "dim_brand"
   ],
   "grain_match": 4,
   "keys_hold": 3,
   "cols_matched": 17,
   "ref_cols_in_matched": 19,
   "model_cols_in_matched": 20,
   "ref_cols_total": 32,
   "measures_placed": 6,
   "measures_total": 8,
   "per_table": [
    {
     "table": "dim_product",
     "present": true,
     "grain_declared_match": true,
     "key_unique": true,
     "rows": 12,
     "distinct": 12,
     "cols_matched": 3,
     "ref_cols": 4,
     "model_cols": 4,
     "extra": [
      "brand_id"
     ],
     "missing": [
      "brand_name"
     ]
    },
    {
     "table": "dim_region",
     "present": true,
     "grain_declared_match": true,
     "key_unique": true,
     "rows": 5,
     "distinct": 5,
     "cols_matched": 2,
     "ref_cols": 2,
     "model_cols": 2,
     "extra": [],
     "missing": []
    },
    {
     "table": "dim_month",
     "present": true,
     "grain_declared_match": true,
     "key_unique": true,
     "rows": 30,
     "distinct": 30,
     "cols_matched": 3,
     "ref_cols": 3,
     "model_cols": 3,
     "extra": [],
     "missing": []
    },
    {
     "table": "dim_promo",
     "present": false,
     "missing": [
      "promo_id",
      "promo_type",
      "discount_pct",
      "start_month",
      "end_month"
     ]
    },
    {
     "table": "bridge_promo_coverage",
     "present": false,
     "missing": [
      "promo_id",
      "month",
      "region_id",
      "sku"
     ]
    },
    {
     "table": "fact_sales_monthly",
     "present": true,
     "grain_declared_match": true,
     "key_unique": false,
     "rows": 1803,
     "distinct": 1785,
     "cols_matched": 9,
     "ref_cols": 10,
     "model_cols": 11,
     "extra": [
      "inventory_cases",
      "promo_type"
     ],
     "missing": [
      "gross_profit"
     ]
    },
    {
     "table": "fact_inventory_monthly",
     "present": false,
     "missing": [
      "month",
      "region_id",
      "sku",
      "inventory_cases"
     ]
    }
   ],
   "fact_keys_in_ref": 1785,
   "fact_rows_equal_ref": 1767,
   "ref_keys": 1800,
   "ref_net": 764620724
  },
  "v2": {
   "tables_ref": 7,
   "tables_matched": 6,
   "extra_tables": [],
   "grain_match": 6,
   "keys_hold": 6,
   "cols_matched": 26,
   "ref_cols_in_matched": 27,
   "model_cols_in_matched": 30,
   "ref_cols_total": 32,
   "measures_placed": 7,
   "measures_total": 8,
   "per_table": [
    {
     "table": "dim_product",
     "present": true,
     "grain_declared_match": true,
     "key_unique": true,
     "rows": 12,
     "distinct": 12,
     "cols_matched": 4,
     "ref_cols": 4,
     "model_cols": 4,
     "extra": [],
     "missing": []
    },
    {
     "table": "dim_region",
     "present": true,
     "grain_declared_match": true,
     "key_unique": true,
     "rows": 5,
     "distinct": 5,
     "cols_matched": 2,
     "ref_cols": 2,
     "model_cols": 2,
     "extra": [],
     "missing": []
    },
    {
     "table": "dim_month",
     "present": true,
     "grain_declared_match": true,
     "key_unique": true,
     "rows": 30,
     "distinct": 30,
     "cols_matched": 3,
     "ref_cols": 3,
     "model_cols": 3,
     "extra": [],
     "missing": []
    },
    {
     "table": "dim_promo",
     "present": false,
     "missing": [
      "promo_id",
      "promo_type",
      "discount_pct",
      "start_month",
      "end_month"
     ]
    },
    {
     "table": "bridge_promo_coverage",
     "present": true,
     "grain_declared_match": true,
     "key_unique": true,
     "rows": 100,
     "distinct": 100,
     "cols_matched": 4,
     "ref_cols": 4,
     "model_cols": 6,
     "extra": [
      "discount_pct",
      "promo_type"
     ],
     "missing": []
    },
    {
     "table": "fact_sales_monthly",
     "present": true,
     "grain_declared_match": true,
     "key_unique": true,
     "rows": 1800,
     "distinct": 1800,
     "cols_matched": 9,
     "ref_cols": 10,
     "model_cols": 11,
     "extra": [
      "active_promos",
      "amount_check_failed"
     ],
     "missing": [
      "gross_profit"
     ]
    },
    {
     "table": "fact_inventory_monthly",
     "present": true,
     "grain_declared_match": true,
     "key_unique": true,
     "rows": 1800,
     "distinct": 1800,
     "cols_matched": 4,
     "ref_cols": 4,
     "model_cols": 4,
     "extra": [],
     "missing": []
    }
   ],
   "fact_keys_in_ref": 1800,
   "fact_rows_equal_ref": 1800,
   "ref_keys": 1800,
   "ref_net": 764620724
  }
 },
 "guard": {
  "UPDATE": "refused by connector",
  "DROP": "refused by connector",
  "two statements": "refused by connector",
  "direct write, bypassing the connector": "refused by the read-only account (attempt to write a readonly database)",
  "row cap": {
   "cap": 200,
   "returned": 200,
   "table_rows": 1812
  }
 },
 "connector_log": [
  {
   "n": 1,
   "target": "lake (read-only account)",
   "purpose": "list tables",
   "sql": "SELECT name FROM sqlite_master WHERE type='table' ORDER BY name",
   "rows": 7,
   "truncated": false,
   "outcome": "ok"
  },
  {
   "n": 2,
   "target": "lake (read-only account)",
   "purpose": "row count src_brand",
   "sql": "SELECT COUNT(*) FROM src_brand",
   "rows": 1,
   "truncated": false,
   "outcome": "ok"
  },
  {
   "n": 3,
   "target": "lake (read-only account)",
   "purpose": "row count src_inventory_snapshot",
   "sql": "SELECT COUNT(*) FROM src_inventory_snapshot",
   "rows": 1,
   "truncated": false,
   "outcome": "ok"
  },
  {
   "n": 4,
   "target": "lake (read-only account)",
   "purpose": "row count src_invoice_line",
   "sql": "SELECT COUNT(*) FROM src_invoice_line",
   "rows": 1,
   "truncated": false,
   "outcome": "ok"
  },
  {
   "n": 5,
   "target": "lake (read-only account)",
   "purpose": "row count src_movement",
   "sql": "SELECT COUNT(*) FROM src_movement",
   "rows": 1,
   "truncated": false,
   "outcome": "ok"
  },
  {
   "n": 6,
   "target": "lake (read-only account)",
   "purpose": "row count src_product",
   "sql": "SELECT COUNT(*) FROM src_product",
   "rows": 1,
   "truncated": false,
   "outcome": "ok"
  },
  {
   "n": 7,
   "target": "lake (read-only account)",
   "purpose": "row count src_promo",
   "sql": "SELECT COUNT(*) FROM src_promo",
   "rows": 1,
   "truncated": false,
   "outcome": "ok"
  },
  {
   "n": 8,
   "target": "lake (read-only account)",
   "purpose": "row count src_region",
   "sql": "SELECT COUNT(*) FROM src_region",
   "rows": 1,
   "truncated": false,
   "outcome": "ok"
  },
  {
   "n": 9,
   "target": "lake (read-only account)",
   "purpose": "profile: distinct month-region-SKU keys",
   "sql": "SELECT COUNT(*) FROM (SELECT DISTINCT month, region_id, UPPER(TRIM(sku)) FROM src_invoice_line)",
   "rows": 1,
   "truncated": false,
   "outcome": "ok"
  },
  {
   "n": 10,
   "target": "lake (read-only account)",
   "purpose": "profile: null keys in movement",
   "sql": "SELECT COUNT(*) FROM src_movement WHERE region_id IS NULL OR month IS NULL OR sku IS NULL",
   "rows": 1,
   "truncated": false,
   "outcome": "ok"
  },
  {
   "n": 11,
   "target": "lake (read-only account)",
   "purpose": "profile: SKUs with no exact product match",
   "sql": "SELECT COUNT(*) FROM src_invoice_line WHERE sku NOT IN (SELECT sku FROM src_product)",
   "rows": 1,
   "truncated": false,
   "outcome": "ok"
  },
  {
   "n": 12,
   "target": "lake (read-only account)",
   "purpose": "guard test: UPDATE",
   "sql": "UPDATE src_promo SET discount_pct = 0",
   "outcome": "refused by connector (not a single read-only SELECT)"
  },
  {
   "n": 13,
   "target": "lake (read-only account)",
   "purpose": "guard test: DROP",
   "sql": "DROP TABLE src_promo",
   "outcome": "refused by connector (not a single read-only SELECT)"
  },
  {
   "n": 14,
   "target": "lake (read-only account)",
   "purpose": "guard test: two statements",
   "sql": "SELECT 1; SELECT 2",
   "outcome": "refused by connector (not a single read-only SELECT)"
  },
  {
   "n": 15,
   "target": "lake (read-only account)",
   "purpose": "guard test: unbounded SELECT",
   "sql": "SELECT * FROM src_invoice_line",
   "rows": 200,
   "truncated": true,
   "outcome": "ok"
  },
  {
   "n": 16,
   "target": "lake (read-only account)",
   "purpose": "check S1",
   "sql": "SELECT COALESCE(SUM(n - 1), 0) FROM ( SELECT COUNT(*) AS n FROM src_invoice_line GROUP BY month, region_id, UPPER(TRIM(sku)) HAVING COUNT(*) > 1)",
   "rows": 1,
   "truncated": false,
   "outcome": "ok"
  },
  {
   "n": 17,
   "target": "lake (read-only account)",
   "purpose": "check S2",
   "sql": "SELECT COUNT(*) FROM src_invoice_line WHERE sku NOT IN (SELECT sku FROM src_product)",
   "rows": 1,
   "truncated": false,
   "outcome": "ok"
  },
  {
   "n": 18,
   "target": "lake (read-only account)",
   "purpose": "check S3",
   "sql": "SELECT COUNT(*) FROM src_movement WHERE month IS NULL OR region_id IS NULL OR sku IS NULL",
   "rows": 1,
   "truncated": false,
   "outcome": "ok"
  },
  {
   "n": 19,
   "target": "lake (read-only account)",
   "purpose": "check S4",
   "sql": "SELECT COUNT(*) FROM src_promo a JOIN src_promo b ON a.sku = b.sku AND a.region_id = b.region_id AND a.promo_id < b.promo_id AND a.start_month <= b.end_month AN",
   "rows": 1,
   "truncated": false,
   "outcome": "ok"
  },
  {
   "n": 20,
   "target": "lake (read-only account)",
   "purpose": "check S5",
   "sql": "SELECT COUNT(*) FROM ( SELECT depletions_cases AS d, AVG(depletions_cases) OVER (PARTITION BY region_id, sku) AS avg_d FROM src_movement WHERE region_id IS NOT ",
   "rows": 1,
   "truncated": false,
   "outcome": "ok"
  },
  {
   "n": 21,
   "target": "lake (read-only account)",
   "purpose": "check S6",
   "sql": "SELECT COUNT(*) FROM src_invoice_line WHERE region_id NOT IN (SELECT region_id FROM src_region)",
   "rows": 1,
   "truncated": false,
   "outcome": "ok"
  },
  {
   "n": 22,
   "target": "lake (read-only account)",
   "purpose": "check S7",
   "sql": "SELECT COUNT(*) FROM src_invoice_line WHERE ABS(net_sales - (gross_sales - discounts)) > 1",
   "rows": 1,
   "truncated": false,
   "outcome": "ok"
  },
  {
   "n": 23,
   "target": "sandbox (scratch copy)",
   "purpose": "check M1 on v1",
   "sql": "SELECT (SELECT COUNT(*) FROM src_invoice_line), (SELECT COUNT(*) FROM fact_sales_monthly_v1) + 0",
   "rows": 1,
   "truncated": false,
   "outcome": "ok"
  },
  {
   "n": 24,
   "target": "sandbox (scratch copy)",
   "purpose": "check M1 on v2",
   "sql": "SELECT (SELECT COUNT(*) FROM src_invoice_line), (SELECT COUNT(*) FROM fact_sales_monthly_v2) + 12",
   "rows": 1,
   "truncated": false,
   "outcome": "ok"
  },
  {
   "n": 25,
   "target": "sandbox (scratch copy)",
   "purpose": "check M2 on v1",
   "sql": "SELECT (SELECT SUM(net_sales) FROM src_invoice_line), (SELECT SUM(net_sales) FROM fact_sales_monthly_v1) + 0",
   "rows": 1,
   "truncated": false,
   "outcome": "ok"
  },
  {
   "n": 26,
   "target": "sandbox (scratch copy)",
   "purpose": "check M2 on v2",
   "sql": "SELECT (SELECT SUM(net_sales) FROM src_invoice_line), (SELECT SUM(net_sales) FROM fact_sales_monthly_v2) + 5051426",
   "rows": 1,
   "truncated": false,
   "outcome": "ok"
  },
  {
   "n": 27,
   "target": "sandbox (scratch copy)",
   "purpose": "check M3 on v1",
   "sql": "SELECT COUNT(*) - COUNT(DISTINCT month || '|' || region_id || '|' || sku) FROM fact_sales_monthly_v1",
   "rows": 1,
   "truncated": false,
   "outcome": "ok"
  },
  {
   "n": 28,
   "target": "sandbox (scratch copy)",
   "purpose": "check M3 on v2",
   "sql": "SELECT COUNT(*) - COUNT(DISTINCT month || '|' || region_id || '|' || sku) FROM fact_sales_monthly_v2",
   "rows": 1,
   "truncated": false,
   "outcome": "ok"
  },
  {
   "n": 29,
   "target": "sandbox (scratch copy)",
   "purpose": "check M4 on v1",
   "sql": "SELECT COUNT(*) FROM fact_sales_monthly_v1 WHERE month IS NULL OR region_id IS NULL OR sku IS NULL",
   "rows": 1,
   "truncated": false,
   "outcome": "ok"
  },
  {
   "n": 30,
   "target": "sandbox (scratch copy)",
   "purpose": "check M4 on v2",
   "sql": "SELECT COUNT(*) FROM fact_sales_monthly_v2 WHERE month IS NULL OR region_id IS NULL OR sku IS NULL",
   "rows": 1,
   "truncated": false,
   "outcome": "ok"
  },
  {
   "n": 31,
   "target": "sandbox (scratch copy)",
   "purpose": "check M5 on v1",
   "sql": "SELECT COUNT(*) FROM fact_sales_monthly_v1 f WHERE f.sku NOT IN (SELECT sku FROM dim_product_v1) OR f.region_id NOT IN (SELECT region_id FROM dim_region_v1)",
   "rows": 1,
   "truncated": false,
   "outcome": "ok"
  },
  {
   "n": 32,
   "target": "sandbox (scratch copy)",
   "purpose": "check M5 on v2",
   "sql": "SELECT COUNT(*) FROM fact_sales_monthly_v2 f WHERE f.sku NOT IN (SELECT sku FROM dim_product_v2) OR f.region_id NOT IN (SELECT region_id FROM dim_region_v2)",
   "rows": 1,
   "truncated": false,
   "outcome": "ok"
  },
  {
   "n": 33,
   "target": "sandbox (scratch copy)",
   "purpose": "check M6 on v1",
   "sql": "SELECT COUNT(*) FROM (SELECT DISTINCT month, region_id, UPPER(TRIM(sku)) AS sku FROM src_invoice_line) i LEFT JOIN fact_sales_monthly_v1 f ON f.month = i.month ",
   "rows": 1,
   "truncated": false,
   "outcome": "ok"
  },
  {
   "n": 34,
   "target": "sandbox (scratch copy)",
   "purpose": "check M6 on v2",
   "sql": "SELECT COUNT(*) FROM (SELECT DISTINCT month, region_id, UPPER(TRIM(sku)) AS sku FROM src_invoice_line) i LEFT JOIN fact_sales_monthly_v2 f ON f.month = i.month ",
   "rows": 1,
   "truncated": false,
   "outcome": "ok"
  },
  {
   "n": 35,
   "target": "sandbox (scratch copy)",
   "purpose": "check M7 on v1",
   "sql": "SELECT COUNT(*) FROM fact_sales_monthly_v1 WHERE ABS(net_sales - (gross_sales - discounts)) > 1",
   "rows": 1,
   "truncated": false,
   "outcome": "ok"
  },
  {
   "n": 36,
   "target": "sandbox (scratch copy)",
   "purpose": "check M7 on v2",
   "sql": "SELECT COUNT(*) FROM fact_sales_monthly_v2 WHERE ABS(net_sales - (gross_sales - discounts)) > 1",
   "rows": 1,
   "truncated": false,
   "outcome": "ok"
  },
  {
   "n": 37,
   "target": "sandbox (scratch copy)",
   "purpose": "check M8 on v1",
   "sql": "SELECT COUNT(*) - COUNT(DISTINCT sku) FROM dim_product_v1",
   "rows": 1,
   "truncated": false,
   "outcome": "ok"
  },
  {
   "n": 38,
   "target": "sandbox (scratch copy)",
   "purpose": "check M8 on v2",
   "sql": "SELECT COUNT(*) - COUNT(DISTINCT sku) FROM dim_product_v2",
   "rows": 1,
   "truncated": false,
   "outcome": "ok"
  },
  {
   "n": 39,
   "target": "sandbox (scratch copy)",
   "purpose": "check M9 on v1",
   "sql": "SELECT COUNT(*) FROM fact_sales_monthly_v1 WHERE shipments_cases IS NULL",
   "rows": 1,
   "truncated": false,
   "outcome": "ok"
  },
  {
   "n": 40,
   "target": "sandbox (scratch copy)",
   "purpose": "check M9 on v2",
   "sql": "SELECT COUNT(*) FROM fact_sales_monthly_v2 WHERE shipments_cases IS NULL",
   "rows": 1,
   "truncated": false,
   "outcome": "ok"
  }
 ],
 "connector_summary": {
  "statements": 40,
  "refused": 3,
  "row_cap": 200,
  "truncated": 1
 },
 "model_columns": {
  "v1": {
   "dim_brand": [
    "brand_id",
    "brand_name"
   ],
   "dim_product": [
    "sku",
    "product_name",
    "brand_id",
    "category"
   ],
   "dim_region": [
    "region_id",
    "region_name"
   ],
   "dim_month": [
    "month",
    "year",
    "quarter"
   ],
   "fact_sales_monthly": [
    "month",
    "region_id",
    "sku",
    "gross_sales",
    "discounts",
    "net_sales",
    "cogs",
    "shipments_cases",
    "depletions_cases",
    "inventory_cases",
    "promo_type"
   ]
  },
  "v2": {
   "dim_product": [
    "sku",
    "product_name",
    "brand_name",
    "category"
   ],
   "dim_region": [
    "region_id",
    "region_name"
   ],
   "dim_month": [
    "month",
    "year",
    "quarter"
   ],
   "bridge_promo_coverage": [
    "promo_id",
    "month",
    "region_id",
    "sku",
    "promo_type",
    "discount_pct"
   ],
   "fact_sales_monthly": [
    "month",
    "region_id",
    "sku",
    "gross_sales",
    "discounts",
    "net_sales",
    "cogs",
    "shipments_cases",
    "depletions_cases",
    "active_promos",
    "amount_check_failed"
   ],
   "fact_inventory_monthly": [
    "month",
    "region_id",
    "sku",
    "inventory_cases"
   ]
  }
 },
 "seeded_manifest": {
  "D1": {
   "name": "Duplicate invoice lines (double load)",
   "n": 12
  },
  "D2": {
   "name": "SKU written with different case or trailing space",
   "n": 9
  },
  "D3": {
   "name": "Movement rows with a missing region key",
   "n": 6
  },
  "D5": {
   "name": "Net sales that does not equal gross minus discounts",
   "n": 4
  },
  "D6": {
   "name": "Depletions inflated ten-fold (unit error)",
   "n": 3
  },
  "D4": {
   "name": "Overlapping promotions for one SKU and region",
   "n": 5
  }
 }
}