Complete the code to define a basic test that checks if a column has any null values.
version: 2 models: - name: customers columns: - name: email tests: - [1]
The not_null test checks if the column contains any null values, which is a basic data quality check.
Complete the code to add an advanced test that checks if values in a column belong to a specific set.
version: 2 models: - name: orders columns: - name: status tests: - accepted_values: values: [1]
The accepted_values test checks if the column values are within the specified list. Here, order statuses are 'pending', 'shipped', or 'cancelled'.
Fix the error in the test configuration that causes the test to fail due to incorrect syntax.
version: 2 models: - name: products columns: - name: price tests: - [1]: {min: 0}
The not_null test supports no parameters, but the test that supports 'min' parameter is a custom or specific test. The original 'accepted_values' with 'min' is incorrect. Here, 'not_null' is the closest correct standard test, but to check minimum value, a custom test is needed.
Fill both blanks to create a custom test that checks if the average value of a column is above a threshold.
version: 2 models: - name: sales tests: - custom_test: sql: "SELECT COUNT(*) FROM [1] WHERE [2] <= 100"
The ref('sales') function references the sales model, and amount is the column checked to ensure values are above 100.
Fill all three blanks to write a test that ensures no duplicate user IDs exist and all IDs are positive.
version: 2 models: - name: users columns: - name: user_id tests: - [1] - [2] - custom_test: sql: "SELECT COUNT(*) FROM [3] WHERE user_id <= 0"
The unique test checks for duplicates, not_null ensures no missing IDs, and ref('users') references the users model in the custom test.