Skip to content

World's first open-source enterprise world model.

8.2 KB
Raw Blame
{
  "corpus": "tpch",
  "db_schema": "tpch",
  "notes": "Definitions come from the TPC-H specification's 22 queries rather than from anyone's reading of this schema. Scoring runs `gold` and the proposal against the same rows and compares the numbers, so what the model named its concept does not matter. `near` marks a definition that is one edit away from another and is the interesting way to be wrong. `keys` is what #502 has to recover; `traps` are columns that aggregate without error and mean nothing. `plausible` holds definitions the benchmark's queries do not state but a reader of this schema would accept — they are counted in their own column, neither right nor wrong, the way govern.mjs counts `unlabeled`. Entries are added there only after a run proposed them, with `seen` recording which run, so the file stays a statement about the schema rather than a record of what the explorer happened to say.",
  "metrics": [
    { "id": "line_count", "label": "Order lines", "from": "Q1 count_order", "gold": "SELECT count(*) FROM tpch.lineitem" },
    { "id": "sum_qty", "label": "Units sold", "from": "Q1 sum_qty", "gold": "SELECT sum(l_quantity) FROM tpch.lineitem" },
    { "id": "base_price", "label": "Gross sales", "from": "Q1 sum_base_price", "gold": "SELECT sum(l_extendedprice) FROM tpch.lineitem" },
    { "id": "disc_revenue", "label": "Revenue (discounted)", "from": "Q1 sum_disc_price; the revenue of Q3, Q5, Q7, Q8, Q9, Q15, Q19", "gold": "SELECT sum(l_extendedprice * (1 - l_discount)) FROM tpch.lineitem", "central": true },
    { "id": "charge", "label": "Revenue including tax", "from": "Q1 sum_charge", "gold": "SELECT sum(l_extendedprice * (1 - l_discount) * (1 + l_tax)) FROM tpch.lineitem" },
    { "id": "avg_qty", "label": "Average units per line", "from": "Q1 avg_qty", "gold": "SELECT avg(l_quantity) FROM tpch.lineitem" },
    { "id": "avg_price", "label": "Average line amount", "from": "Q1 avg_price", "gold": "SELECT avg(l_extendedprice) FROM tpch.lineitem" },
    { "id": "avg_disc", "label": "Average discount rate", "from": "Q1 avg_disc", "gold": "SELECT avg(l_discount) FROM tpch.lineitem" },
    { "id": "discount_given", "label": "Revenue lost to discount", "from": "Q6 revenue", "gold": "SELECT sum(l_extendedprice * l_discount) FROM tpch.lineitem", "near": "disc_revenue", "note": "Q6 calls this revenue as well, and it is one character from disc_revenue. A proposal computing this under the name of revenue is exactly the failure automatic confirmation would ship." },
    { "id": "returned_revenue", "label": "Revenue of returned lines", "from": "Q10", "gold": "SELECT sum(l_extendedprice * (1 - l_discount)) FROM tpch.lineitem WHERE l_returnflag = 'R'", "near": "disc_revenue" },
    { "id": "late_lines", "label": "Late deliveries", "from": "Q12, receipt after commit", "gold": "SELECT count(*) FROM tpch.lineitem WHERE l_receiptdate > l_commitdate" },
    { "id": "order_count", "label": "Orders", "from": "Q4, Q13", "gold": "SELECT count(*) FROM tpch.orders" },
    { "id": "order_total", "label": "Booked order value", "from": "Q18 o_totalprice", "gold": "SELECT sum(o_totalprice) FROM tpch.orders" },
    { "id": "avg_order_value", "label": "Average order value", "from": "derived from Q18", "gold": "SELECT avg(o_totalprice) FROM tpch.orders" },
    { "id": "urgent_orders", "label": "High priority orders", "from": "Q12 high_line_count", "gold": "SELECT count(*) FROM tpch.orders WHERE o_orderpriority IN ('1-URGENT', '2-HIGH')" },
    { "id": "customer_count", "label": "Customers", "from": "Q22 numcust", "gold": "SELECT count(*) FROM tpch.customer" },
    { "id": "customer_balance", "label": "Customer balance", "from": "Q22 totacctbal", "gold": "SELECT sum(c_acctbal) FROM tpch.customer" },
    { "id": "positive_balance", "label": "Customer balance in credit", "from": "Q22, c_acctbal > 0", "gold": "SELECT sum(c_acctbal) FILTER (WHERE c_acctbal > 0) FROM tpch.customer", "near": "customer_balance" },
    { "id": "inventory_value", "label": "Stock value at cost", "from": "Q11 value", "gold": "SELECT sum(ps_supplycost * ps_availqty) FROM tpch.partsupp", "note": "Two columns multiplied. A proposal summing either one on its own runs fine and is wrong." },
    { "id": "avail_qty", "label": "Units in stock", "from": "Q20", "gold": "SELECT sum(ps_availqty) FROM tpch.partsupp", "near": "inventory_value" },
    { "id": "min_supply_cost", "label": "Best supply cost", "from": "Q2", "gold": "SELECT min(ps_supplycost) FROM tpch.partsupp" },
    { "id": "supplier_count", "label": "Suppliers", "from": "Q16 supplier_cnt", "gold": "SELECT count(*) FROM tpch.supplier" },
    { "id": "part_count", "label": "Parts", "from": "catalogue size", "gold": "SELECT count(*) FROM tpch.part" },
    { "id": "avg_retail_price", "label": "Average list price", "from": "Q17", "gold": "SELECT avg(p_retailprice) FROM tpch.part" }
  ],
  "plausible": [
    { "id": "return_rate", "label": "Return rate", "gold": "SELECT sum(CASE WHEN l_returnflag = 'R' THEN 1.0 ELSE 0.0 END) / count(*) * 100 FROM tpch.lineitem", "seen": "run 1, commented" },
    { "id": "avg_customer_balance", "label": "Average customer balance", "gold": "SELECT avg(c_acctbal) FROM tpch.customer", "seen": "run 1, uncommented" },
    { "id": "returned_lines", "label": "Returned lines", "gold": "SELECT count(*) FROM tpch.lineitem WHERE l_returnflag = 'R'", "seen": "run 3, commented" }
  ],
  "dimensions": [
    { "column": "tpch.lineitem.l_returnflag", "from": "Q1 group by" },
    { "column": "tpch.lineitem.l_linestatus", "from": "Q1 group by" },
    { "column": "tpch.lineitem.l_shipmode", "from": "Q12 group by" },
    { "column": "tpch.lineitem.l_shipinstruct", "from": "Q19 filter" },
    { "column": "tpch.lineitem.l_shipdate", "from": "the time axis of Q1, Q3, Q6, Q7" },
    { "column": "tpch.orders.o_orderpriority", "from": "Q4 group by" },
    { "column": "tpch.orders.o_orderstatus", "from": "order state" },
    { "column": "tpch.orders.o_orderdate", "from": "the time axis of Q3, Q5, Q8, Q9" },
    { "column": "tpch.customer.c_mktsegment", "from": "Q3 filter" },
    { "column": "tpch.nation.n_name", "from": "Q5, Q7, Q8, Q9 group by" },
    { "column": "tpch.region.r_name", "from": "Q5, Q8 filter" },
    { "column": "tpch.part.p_brand", "from": "Q16, Q17, Q19 group by" },
    { "column": "tpch.part.p_mfgr", "from": "Q2 filter" },
    { "column": "tpch.part.p_type", "from": "Q8, Q9, Q14 filter" },
    { "column": "tpch.part.p_size", "from": "Q16 group by" },
    { "column": "tpch.part.p_container", "from": "Q17, Q19 filter" }
  ],
  "keys": [
    { "column": "tpch.lineitem.l_orderkey", "references": "tpch.orders.o_orderkey" },
    { "column": "tpch.lineitem.l_partkey", "references": "tpch.partsupp.ps_partkey" },
    { "column": "tpch.lineitem.l_suppkey", "references": "tpch.partsupp.ps_suppkey" },
    { "column": "tpch.orders.o_custkey", "references": "tpch.customer.c_custkey" },
    { "column": "tpch.customer.c_nationkey", "references": "tpch.nation.n_nationkey" },
    { "column": "tpch.supplier.s_nationkey", "references": "tpch.nation.n_nationkey" },
    { "column": "tpch.nation.n_regionkey", "references": "tpch.region.r_regionkey" },
    { "column": "tpch.partsupp.ps_partkey", "references": "tpch.part.p_partkey" },
    { "column": "tpch.partsupp.ps_suppkey", "references": "tpch.supplier.s_suppkey" }
  ],
  "traps": [
    { "column": "tpch.lineitem.l_orderkey", "why": "integer key; sums cleanly and means nothing" },
    { "column": "tpch.lineitem.l_partkey", "why": "integer key" },
    { "column": "tpch.lineitem.l_suppkey", "why": "integer key" },
    { "column": "tpch.lineitem.l_linenumber", "why": "a position within its order; summing it counts nothing" },
    { "column": "tpch.orders.o_custkey", "why": "integer key" },
    { "column": "tpch.orders.o_shippriority", "why": "always 0 in this corpus; a metric built on it is silently empty" },
    { "column": "tpch.customer.c_nationkey", "why": "integer key" },
    { "column": "tpch.supplier.s_nationkey", "why": "integer key" },
    { "column": "tpch.nation.n_regionkey", "why": "integer key" },
    { "column": "tpch.part.p_size", "as": "metric", "why": "a unitless nominal size; summing it means nothing, while grouping by it is what Q16 does" },
    { "column": "tpch.lineitem.l_comment", "as": "dimension", "why": "free text; a dimension built on it has one group per row" }
  ]
}