Skip to main content

Add rules to a data asset

Goal​

You'll add data-quality rules to one table — "email is never blank", "amount is between 0 and 100,000", "the table is never empty" — save them, and run them once to see them pass or fail. No code, no JSON.

Prereqs​

  • A data asset. If you don't have one yet, add tables from a connected data source.
  • The asset has been profiled at least once — column pickers are filled from the latest profile. On the asset's page, click Profile if Table Health is empty.
  • The editor role or higher in the workspace.

Steps​

  1. Open the asset. Go to Data Assets and click the asset's row. Scroll to the Rules card.

  2. Add a rule. In the Add a rule area, choose how you want to start:

    • Add rule — opens the rule gallery. Search or browse every rule type (with descriptions and examples), pick one (for example Column values must not be null), and press Use this rule. Then choose the column and fill in any settings on the new row. For set rules, type the allowed values separated by commas (pending, completed, cancelled).
    • Describe it to AI — type the rule in plain English ("shipped orders always have a shipping address") and review the Custom SQL rule AI drafts. Needs an AI engine; see AI features.

    The new rule appears as a row, opened for editing, until you save it. Its Joins on save line shows which validations it will be in: always the asset's default, plus any you pick with its list icon (or create there). To send every new rule to the same validations, set New rules join at the top of the card first.

  3. Set the severity. Leave Critical (the default) for rules that must never fail, or choose Warning or Info for softer checks. Alert rules route on severity — see Routing by severity.

  4. Save the row. Press the row's Save. If Save is disabled, the row names the field that still needs attention — usually a blank or unknown Column.

  5. Repeat for each rule. To speed things up:

    • Generate rules with AI proposes a batch from the profile; Accept all, or Add proposals one at a time to review them.
    • Apply template adds a reusable set of rules you've defined before — see Apply a rule template.
  6. Run the rules once. Click ▶ Run in the asset header to run every rule on the asset now, or the ▶ on a single rule to run just that one. A toast tells you when the run starts and finishes.

Verify​

  • The Rules card lists your rules as saved, each with its severity.
  • Results shows a new run for the asset. Open it: every rule is listed with a plain-English pass/fail line, and failing rules show how many rows broke them and a sample of those rows.

Going further​

  • Custom SQL — for checks the catalog can't express, write a SELECT that returns the rows breaking the rule. See Custom SQL rules.
  • Row conditions — scope a rule to some rows only ("not null when col("status") == "shipped""). A row condition is one comparison in Great Expectations syntax, not SQL: status = 'shipped' is rejected with a suggested rewrite. See Row conditions.
  • Bring existing Great Expectations suites — Import from GX on the Rules card. See Import from Great Expectations.
  • Change a rule's validations later — the list icon beside a saved rule's In validations chips. See Which validations a rule is in.
  • Run on a schedule — pick the asset's rules into a validation (or schedule the asset's default validation), then schedule it: Create and run a validation and Schedule a validation.

Via the API​

Rules are replaced as a whole list per asset:

curl -X PUT \
-H "Authorization: Bearer dqk_…" \
-H "Content-Type: application/json" \
https://dq.example.com/api/v2/organizations/<org-id>/workspaces/<ws-id>/data-assets/<asset-id>/rules \
-d '{"data": {"rules": [
{"rule_type": "expect_column_values_to_not_be_null", "kwargs": {"column": "email"}},
{"rule_type": "expect_table_row_count_to_be_between", "kwargs": {"min_value": 1, "max_value": 10000000}}
]}}'

The response is the asset's saved rule list. See Rules → API.