Skip to content

v1.16.0

Choose a tag to compare

@jarichb jarichb released this 13 Oct 13:53
Immutable release. Only release title and notes can be modified.
7bfe9ba

An order can no longer predate its customer: after now names a parent's column. Integer primary keys number the rows 1..N, in key order. This release also carries the fixes of v1.15.0, whose package never reached PyPI. Every model with an integer primary key generates different data for the same seed: see Upgrading below.

Added

  • after can name a parent's column. order_date: {after: customers.created_at} keeps every order on or after the created_at of the customer its foreign key points at. In examples/ecommerce, half the orders used to predate their customer; now none do.
    • after takes a column of the same row (as before), a parent's column as <table>.<column>, or a list of either: after: [orders.ordered_at, products.launched_at]. A date compared with a timestamp compares by day.
    • The parent is reached through exactly one one-column foreign key onto its primary key or a unique column; a null foreign key constrains nothing. Two foreign keys to the same parent (sender_id and receiver_id to users) are an error naming both: choosing one is not built yet.
    • The child keeps its own shape. A row dated before its parent takes another parent created by then, so growth, seasonality, business hours and the as_of window hold exactly; only a row with no such parent (or a one-to-one) moves its date, within the column's own shape and never past as_of. On the coffee-webshop example the gift-season peak and growth are unchanged; a skewed foreign key gets steeper, because early customers have had longer to order.
    • Needs spec 0.5.0: a document using a parent's column or a list says model2data: 0.5.0, and an older document using them gets an error naming the version to write. DBML converts to 0.5.0 on its own. Schema: https://www.jbanalytica.com/model2data/spec/0.5.0/model.schema.json
  • A warning where a child's date can fall before its parent's, with the hint to add: "can fall before customers.created_at (the customers row it points at through customer_id); add after: customers.created_at to keep it after". It carries a structured suggestion (path, value, spec) for tools to offer as a fix. Generation itself does not change.
  • dbt test model2data_not_before_parent. With --hint-tests, each parent column an after names gets a test that fails on rows dated before their parent row. The macro ships in macros/model2data_parent_tests.sql, written only when needed. The defects report includes it in EXPECTED_FAILURES.md.
  • The bundled examples use it where it is plainly right (ecommerce, ecommerce_daily, ecommerce_training, advanced_features, saas_platform) and now say spec 0.5.0.

Changed

  • Integer primary keys number the rows 1..N, and rows come out in key order. They used to be a shuffled sample starting at 0 (the first customers were 4251, 4557, 1941, ...). Every output (seeds, later days' batches and change log, the defects' files) lists rows in key order. Keys with min/max or a distribution, and integer keys that are also a foreign key, are drawn as before and sorted. Text, uuid and composite keys are unchanged. Later days continue from the largest key, as before.

Fixed (first released as v1.15.0, which never reached PyPI)

  • A binary column holds a short value. binary, varbinary, bytea, blob and bytes columns now hold 16 random bytes written as 32 hex characters, instead of a whole MiB per value (a 50-row table wrote a 391 MB seed that dbt refused). They stay unique when they are a key.
  • A key that references a column with fewer distinct values caps its table at one row per distinct parent value, instead of failing its own unique test, and the summary names the table and the reference that capped it.

Upgrading

Output changes for the same seed:

  • Every model with an integer primary key: the key is 1..N and no longer draws from the table's random stream, so every column after it draws differently.
  • Dates change only where a model uses a parent's column in after.
  • A table with a byte column, and a table whose key references a column short of distinct values (see Fixed).

The same model, seed, --as-of and options still give the same bytes on any machine and any day with 1.16.0. Pin model2data==1.14.0 (or the Action's version: 1.14.0) to keep fixtures of the old shape, or regenerate and commit the new ones.

Full changelog: v1.14.0...v1.16.0