--- license: mit pretty_name: Enterprise Corpus — Tabular Relationship Inference & Forecasting size_categories: - 10M 36 labelled foreign keys lines = pd.read_parquet( f"{path}/consumer_goods_medium_mixed_dirty/dirty/sales_order_lines.parquet") ``` Grab a single corpus instead of all 2.5 GB: ```python snapshot_download("hemanthreddy901/enterprise-corpus", repo_type="dataset", allow_patterns="consumer_goods_medium_mixed_dirty/*") ``` No account or token is needed to download. --- ## What ships with every corpus ``` clean/ 22 tables as CSV + Parquet, pristine dirty/ the same tables with defects injected workbooks/ .xlsx across 4 upload bundles x N difficulty tiers ground_truth.json 36 FKs with cardinality, PKs, grains, roles, column stats, the true generating process, column_name_map, difficulty score verification.csv 124 assertions, run on clean data before dirtying dirt_manifest.json every defect located, with a how_to_score note pathologies.json which Excel corruption hit which sheet ``` Ground truth is verified **before** dirt is injected, so the labels are proven against pristine data while the workbooks are built from the dirty version. --- ## The 22 tables | Table | Role | Primary key | Represents | |---|---|---|---| | `regions` | dimension | `region_id` | EMEA / AMER / APAC reporting regions | | `countries` | dimension | `country_id` | Countries of operation | | `currencies` | dimension | `currency_code` | Trading currencies — **natural string key** | | `fx_rates` | rate | `currency_code + rate_date` | Daily USD conversion rate | | `date_calendar` | calendar | `date_key` | Calendar + fiscal attributes, FY starts April | | `product_categories` | hierarchy | `category_id` | Two-level taxonomy in one table | | `products` | dimension | `product_id` | Sellable range with lifecycle dates | | `customers` | hierarchy | `customer_id` | Trade accounts with corporate rollups | | `suppliers` | dimension | `supplier_id` | Vendors with lead times and terms | | `product_suppliers` | **bridge** | `product_id + supplier_id` | **True many-to-many** | | `warehouses` | dimension | `warehouse_id` | Distribution centres | | `employees` | hierarchy | `employee_id` | Staff across 8 departments, manager chains | | `gl_accounts` | hierarchy | `account_code` | Chart of accounts with parent rollups | | `marketing_campaigns` | dimension | `campaign_id` | Campaigns with budget and planned lift | | `campaign_products` | **bridge** | `campaign_id + product_id` | **True many-to-many** | | `sales_orders` | fact | `order_id` | Order headers | | `sales_order_lines` | fact_line | `line_id` | Line detail — finest transactional grain | | `sales_returns` | fact | `return_id` | Returns against delivered orders | | `purchase_orders` | fact | `po_id` | Inbound POs | | `purchase_order_lines` | fact_line | `po_line_id` | PO line detail | | `inventory_snapshots` | **snapshot** | `warehouse_id + product_id + snapshot_date` | Month-end stock — **semi-additive** | | `gl_transactions` | fact | `gl_id` | Monthly postings by account and country | --- ## Structures that break naive engines | Structure | Where | The failure it catches | |---|---|---| | True M:N bridge | `product_suppliers` | Row inflation 2.06×; `SUM(unit_cost)` overstated **108%** | | Semi-additive snapshot | `inventory_snapshots` | 136M units summed across dates vs the correct 3.7M | | Self-referencing hierarchy | 4 tables | Parent and child both summed — silent double-count | | Role-specific FK | `sales_orders.sales_rep_id` | Targets a subset; 276 of 400 employees never referenced | | Composite reference | `sales_returns` → lines | Needs two columns matched together | | Redundant join path | `sales_orders.country_id` | One relationship reported as two independent facts | | As-of join | `fx_rates` by `order_date` | A dated lookup treated as an equi-join | Five further relationships are declared in `semantic_relationships` that **no key-matching algorithm can find** — procurement lead/lag, GL reconciliation, campaign causality, FX conversion, denormalisation. Score those separately. --- ## Difficulty controls ### Column naming With generated names, **31 of 36 foreign keys are solvable by exact column-name match alone** — a twenty-line matcher scores 86% with no inference. Corpora suffixed `_mixed` disguise columns per table, as four files from four systems: ``` clean customer_id order_date net_amount sap KUNNR AUDAT NETWR legacy CUST_NO ORD_DT NET_AMT verbose Customer Account Number Net Value bilingual Kundennummer Bestelldatum Nettobetrag opaque Col1 FIELD_5 F2 ``` That drops name-solvability to **25%**. `ground_truth.json → difficulty` records the figure, so the benchmark reports its own honesty. ### Eight defect classes (`_dirty` corpora) | Defect | Correct handling | |---|---| | `orphan_fk` — 3.0% point at non-existent IDs | Report the relationship **anyway** | | `duplicate_entity` — `Clearwater Supply Inc` / `Inc.` | Merge; clusters supplied | | `missing_not_at_random` — `ship_date`, `credit_limit` | Do **not** impute | | `blank_means_zero` — `discount_pct` | Fill with zero | | `impossible_value` — negative qty, dates in 2099/1900 | Flag as invalid | | `unit_inconsistency` — 8% of `weight_kg` in grams | Detect bimodal distribution | | `duplicate_rows` — re-uploaded file signature | De-duplicate | | `free_text_column` — notes embedding a real `po_number` | Surface the text-only link | The imputation pairing is deliberate: `credit_limit` blanks must **not** be filled, `discount_pct` blanks **must** be. Same shape, opposite answers. ### Four Excel tiers `0` pristine · `1` system export (title block, header on row 5, numbers as text, mixed date formats) · `2` analyst-touched (merged two-row headers, embedded subtotals, month-tab splits needing a **union**, pivoted P&L) · `3` in the wild (hidden columns, `#REF!`, ` CUS-000706` / `cus-000477`, meaning in fill colour, near-duplicate `customers FINAL` sheets) --- ## Forecast-grade time series Sales come from a known process, recorded in `data_generating_process`, so forecast quality can be scored against the **true signal** rather than only a holdout: 8.5%/yr trend, weekday shape (Mon 18.9% of revenue → Sun 4.9%), holiday effects (Black Friday 1.65×), product lifecycle, campaign lift, and an 8-week supply shock at 55% through the history. Month-of-year index (1.00 = average month): ``` consumer_goods 1:0.71 ... 11:1.45 12:1.37 industrial 1:0.82 ... 7:0.73 12:1.32 pharma 1:1.24 ... 7:0.73 12:1.25 apparel 1:0.64 ... 11:1.44 12:1.41 ``` Pharma peaks in January while apparel bottoms out there at 0.64. A forecaster that learned "Q4 high, Q1 low" from one vertical gets pharma backwards. **A built-in trap:** the naive campaign-lift estimate reads ~51% against a true injected lift of ~25%, because the window carries trend and seasonality too. Recovering the real figure needs a control group or a seasonality-adjusted model. --- ## The twelve corpora ### Hard mode — mixed naming + injected dirt | Corpus | Rows | Workbooks | Defects | |---|---|---|---| | `industrial_large_mixed_dirty` | 12,735,187 | 8 | 4,721,338 | | `consumer_goods_medium_mixed_dirty` | 1,659,139 | 16 | 667,136 | | `apparel_retail_small_mixed_dirty` | 276,961 | 16 | 116,788 | | `consumer_goods_small_mixed_dirty` | 273,611 | — | 114,690 | | `pharma_distribution_small_mixed_dirty` | 269,998 | 16 | 112,176 | | `consumer_goods_tiny_mixed_dirty` | 59,482 | 4 | 20,302 | ### Clean baseline — the control group | Corpus | Rows | Workbooks | |---|---|---| | `apparel_retail_small` | 276,961 | 16 | | `consumer_goods_small` | 273,611 | 16 | | `pharma_distribution_small` | 269,998 | 16 | | `industrial_small` | 261,377 | 16 | | `consumer_goods_tiny` | 59,982 | 8 | | `apparel_retail_tiny` | 60,247 | — | Same seed, same row counts — the only variables between a pair are naming and dirt, so the difficulty delta is cleanly attributable. Two corpora have no workbooks (they were `--no-excel` runs) and remain fully usable for inference testing. **Start with** `consumer_goods_medium_mixed_dirty`, paired with `consumer_goods_small` as the control. --- ## Suggested metrics **Structure** — FK-graph precision/recall · PK and grain detection · cardinality classification, tracking *1:N mistaken for N:M* separately because it silently corrupts every downstream number · union-vs-join classification on month tabs. **Interaction** — number of confirmation questions asked (budget: ≤7 before users abandon) · accuracy gained per question. **Insight & forecast** — recovery of the known DGP components · error vs a seasonal-naive baseline · does it detect the supply shock · does it report the naive 51% campaign lift or the true 25%. **Operational** — determinism · cost and latency per workbook · accuracy per tier and per pathology. The [Valentine benchmark](https://arxiv.org/abs/2010.07386) (ICDE 2021) formalised this sub-problem and introduced *recall @ ground truth* for ranking quality — worth adopting rather than reinventing. --- ## Reproducibility Every corpus is byte-reproducible from its seed — verified: all 22 tables hash-identical on regeneration. The generator is ~360 KB of Python, so regenerating is often cheaper than downloading. ```bash python -m gen.run --industry consumer_goods --scale medium --naming mixed --dirt ``` Scales: `tiny` 60k rows / 5s · `small` 274k / 48s · `medium` 1.66M / 100s · `large` 12.7M / 204s. --- ## Limitations - **One schema in four costumes.** Real diversity means different people's design decisions. Pair this with real relational databases for schema variety. - **Unknown unknowns.** A generator only injects defects someone thought of. Real data carries mid-history rule changes and half-finished migrations. - **Overfitting risk.** Tuning against a generator is overfitting with extra steps. Hold out real workbooks the engine is never tuned on.