Skip to content

Inventory movements with cross-table bounds

Products, locations and movements where a quantity is bounded by its product's stock.

related volume small InventoryProductsLocationsRelationships
Languages
eng
Formats
parquet

Recipe

recipe.gbddl
gbddl 1
language eng

table products rows 10 (
  id    int64 autoincrement primarykey
  name  text unique enum(values: ["Steel bolt M8", "Pallet wrap", "Safety gloves", "LED panel 60x60", "Copper cable 2.5mm", "Shipping carton L", "Hydraulic oil 5L", "Bearing 6204", "Paint white 10L", "Cable ties 200mm"])
  stock int64 integer(min: 20, max: 1000)
)

table locations rows 4 (
  id   int64 autoincrement primarykey
  name text unique enum(values: ["Main warehouse", "North depot", "Cross-dock", "Returns bay"])
)

table movements rows 40 per(products, 1, 5) (
  id          int64 autoincrement primarykey
  product_id  int64 fk(products.id)
  location_id int64 fk(locations.id)
  quantity    int64 lt(product_id.stock) integer(min: 1, max: 1000)
  moved_at    timestamp datetime(min: "2023-01-01 00:00:00", max: "2024-12-31 23:59:59")
  direction   text enum(values: ["in", "out"])
)

output parquet (maxRowsPerFile: 20)

This is the exact recipe.gbddl committed to the repository. Copy it, or download the raw source.

About this recipe

Inventory movements

A multi-table recipe that generates inventory movements: products, locations and movements where each quantity is bounded by its product's stock.

What it demonstrates

  • Cross-table comparison — quantity is lt(product_id.stock), a comparison against the referenced product's stock column.
  • Relationships — movements references products and locations.
  • Row distribution — per(products, 1, 5) gives each product one to five movements.
  • Parquet output — each table is written as a Parquet file.

Run it

Submit the recipe body to POST /api/v1/jobs?input_format=gbddl, or paste it into Chef, to generate the data. The repository's local runner (run by task test) also generates it and verifies its output.

The recipe outputs Parquet files: products.parquet, locations.parquet and movements.parquet.

Guarantees

Every foreign key names an existing parent row, per(...) grouping holds, and every quantity is strictly less than its product's stock. Values are synthetic.

Tested features

Smart types, physical types, rules and formats this recipe exercises and verifies.

integerdatetimeenumcomparison-crossfkperautoincrementprimary-keyparquet.maxRowsPerFile