A custom generic test packages a failing-row query so you can apply it to more than one model or column. Define a test block with model and any required arguments, then declare its name in a properties YAML file. dbt supplies the relation and column arguments when it renders the test.
The returned rows still mean failure.
Write the narrowest rule that matches the name. A nonnegative test rejects negative values, but a NULL comparison produces unknown and doesn't return the row. Add not_null separately when completeness is required. This separation keeps the guarantee understandable.
In these exercises you define and call a reusable predicate, then inspect how the same test behaves on different columns. Keep the macro's SQL valid after rendering; a correct YAML declaration can't rescue an invalid test body.