Mock Statements
Mock Statements
Mock statements create temporary mock implementations of datasources or concepts for testing and development.
Syntax
mock_statement: "mock" SCOPE (IDENTIFIER ("," IDENTIFIER)*)? ("with" "(" option_list ")")?
Where SCOPE is one of: concepts, concept, datasources, datasource
Mock Datasources
Create mock data for a datasource:
mock datasource customers;
Mock Multiple
Mock multiple datasources at once:
mock datasources customers, orders, products;
Mock Concepts
Mock specific concepts:
mock concept customer.id, customer.name;
Controlling Mock Size
import customer as c;
mock datasource c.customers with (scale_factor = 1000);
scale_factor controls the base entity population; facts can fan out above that population, and finite domains can limit the available unique values. It is not a promise that every generated table has exactly that many rows.
Use Cases
- Unit testing queries without database access
- Rapid prototyping
- Documentation examples
- CI/CD pipelines
Example
import customer as customer;
# Mock the imported customer datasource for testing
mock datasource customer.customers;
# Now queries will use mock data
select
customer.id,
customer.name
;
Tips
Mock data is generated from the model: ranges and enums guide valid values, and partial/nullable bindings affect the generated relationships. Regex mocks support literals, character classes, alternatives, groups, and repetition. Unsupported constructs such as lookaround and backreferences raise an error; provide explicit fixture data for those models. Generated data exercises model structure but cannot establish production data quality.
Imported datasources use their qualified name, for example mock datasource customer.customers;. See Typing and Validation for the distinction between unit tests and warehouse validation.