record_sample
sqllocks_spindle.engine.strategies.record_sample
¶
Record sample strategy — sample complete records from a reference dataset.
Picks N rows from a dataset of dicts, extracts one field as the column value,
and stashes all other fields into ctx.current_table under _rs_{dataset}_{field}
keys so that subsequent record_field strategy calls can read correlated values.
Usage in schema
Anchor column — samples the record and returns one field¶
"city": { "generator": { "strategy": "record_sample", "dataset": "us_zip_locations", "field": "city" } }
Derived columns — read fields from the already-sampled record¶
"state": {"generator": {"strategy": "record_field", "dataset": "us_zip_locations", "field": "state"}} "zip_code": {"generator": {"strategy": "record_field", "dataset": "us_zip_locations", "field": "zip"}} "lat": {"generator": {"strategy": "record_field", "dataset": "us_zip_locations", "field": "lat"}} "lng": {"generator": {"strategy": "record_field", "dataset": "us_zip_locations", "field": "lng"}}
The anchor column MUST appear before any record_field columns for the same dataset in the schema definition (Python dicts preserve insertion order since 3.7).