Size icon
Assert icon
Queries icon
Parallel icon
Webhook icon

Explode a bill of materials into component demand with DuckDB

Turn a bounded bill of materials and production orders into exact component requirements with DuckDB, cycle checks and purchasing CSV reports.

Categories
Data

Calculate purchased-part requirements from nested assemblies without counting a shared component only once. This flow expands every assembly path and adds its quantity contribution to the relevant order.

How it works

  1. Submit a JSON file manually or send its Kestra storage URI as batch to the keyed webhook.
  2. Bound the file to 1 MiB. Native DuckDB tasks validate IDs, references, unique edges and positive integer quantities, then save typed Parquet checkpoints.
  3. Reject cycles across the entire catalog, including unused assemblies. Reject paths longer than eight edges before expansion.
  4. Multiply quantities along every path using DECIMAL(38,0), aggregate terminal parts per order, and export order and purchasing reports in parallel.

What you get

  • Typed demand Parquet, order-detail CSV and aggregated purchasing CSV with order counts.
  • Shared subassemblies contribute through every path. An ordered terminal part contributes its order quantity directly.
  • Limits: 50 parts, 100 edges, three children per assembly, 20 orders, eight edges per path, 100 units per edge and 1,000,000 units per order. These bound expansion and keep arithmetic exact.

Who it's for

Data engineers preparing small manufacturing, kit-assembly or provisioning batches.

Why orchestrate this with Kestra

Validation, topology checks, expansion and independent exports have separate task histories and inspectable storage artifacts. A failed preflight prevents downstream reports.

Prerequisites

Install the DuckDB JDBC plugin. Supply parts as string IDs, components as objects with parent, component, units, and orders with order_id, product, quantity. Every referenced part must be listed. A terminal part is any part without children; the catalog must be complete.

Secrets

  • BOM_WEBHOOK_KEY: protects event submissions.

Quick start

  1. Configure the secret and import this flow.
  2. Upload {"parts":["kit","bolt"],"components":[{"parent":"kit","component":"bolt","units":4}],"orders":[{"order_id":"run-1","product":"kit","quantity":3}]} as batch.
  3. Execute and check that both CSVs require 12 bolts. Send a stored file URI through the webhook for subsequent batches.

How to extend

Join the purchasing report to inventory and lead times. This calculates gross demand; it does not subtract stock, handle substitutions, scrap, fractional units or revisions. Export an immutable catalog revision with each batch.

Links

Orchestrate with Kestra
Orchestrate DuckDB with Kestra
Share this Blueprint
See How

New to Kestra?

Use blueprints to kickstart your first workflows.