[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M77G2318E8JZ2FM523VSJEB2":3,"skill-same:01M77G2318E8JZ2FM523VSJEB2":45},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":24,"commitSha":25,"skillDirectory":26,"forksCount":14,"repositoryHtmlUrl":27,"repositoryHomepageUrl":6,"ownerHtmlUrl":28,"ownerBlogUrl":29,"ownerDescription":6,"updatedAt":30,"install":31,"resources":44},"01M77G2318E8JZ2FM523VSJEB2","coalesce-quality-test-authoring",null,"Decide which data quality tests a table, view or model needs, and write them in whatever test format the project already uses (dbt, SYNQ YAML, SQLMesh audits, Soda, Great Expectations, custom SQL, and so on). Use it when asked to add, suggest, review or extend data tests for a warehouse asset, or when a change to a model should come with tests.","Coalesce-Software-Inc\u002Fcoalesce-platform-skills","Coalesce-Software-Inc","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F91339100?v=4","01M77G0R46A1FMHGV0DGAD04DG","Coalesce.io","01M77G0R4VFVRVQ4ZYKPE8CABW",0,"MIT","https:\u002F\u002Fgithub.com\u002FCoalesce-Software-Inc\u002Fcoalesce-platform-skills\u002Fblob\u002Fdevelop\u002Fskills\u002Fcoalesce-quality-test-authoring\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: coalesce-quality-test-authoring\ndescription: Decide which data quality tests a table, view or model needs, and write them in whatever test format the project already uses (dbt, SYNQ YAML, SQLMesh audits, Soda, Great Expectations, custom SQL, and so on). Use it when asked to add, suggest, review or extend data tests for a warehouse asset, or when a change to a model should come with tests.\n---\n\u003C!-- coalesce-node-managed: true -->\n\n# Data test authoring\n\nA data test is a **deterministic assertion over the rows of one asset**: a query that\nreturns the rows breaking a rule. If it returns no rows, the test passes. This skill\ncovers *which* assertions to write and *with what parameters*. The syntax comes from the\nproject you are working in.\n\n## Stance\n\n- **Suggest fewer, better tests.** Every test costs warehouse compute and adds alert noise.\n  One test that catches a real failure mode is worth more than five that restate the schema.\n  Suggesting nothing is a valid result.\n- **Keep each test to one concern.** To check the same thing on several columns, write one\n  test per column. Combine columns only when the rule needs them together, such as a\n  composite key or a cross-column formula. A multi-column not-null or empty check is fine\n  when the columns form one concern (for example, \"both location IDs present\").\n- **Never guess values.** Any test whose parameters depend on what the data holds\n  (allowed values, bounds, keys) needs evidence from the code, the schema, documentation\n  or a profiling query. If you cannot get evidence, drop the test or ask for the value.\n- **Write rules, not snapshots.** A test should hold for tomorrow's data as well as\n  today's. A bound or value list copied from a sample of current data is a snapshot and\n  will fail on legitimate new data.\n- **Don't duplicate.** Check what already exists before adding anything: tests, schema\n  constraints, and earlier suggestions.\n\n## Workflow\n\n1. **Find the project's test format.** Look for existing tests next to the asset or\n   elsewhere in the repo, such as `schema.yml`\u002F`*.yml` with `tests:`\u002F`data_tests:`, SYNQ\n   `*.yaml` check configs, SQLMesh `audits`, Soda `checks.yml`, GE suites or `tests\u002F*.sql`.\n   Copy their structure, naming, file placement and severity conventions. If there is no\n   format and the user named none, ask before inventing one. If the project uses\n   Coalesce Quality YAML (a file with `version: v1beta2` and `entities:`), follow\n   *Coalesce Quality (SYNQ) YAML* below for field names and behavior. Do not write\n   that format from memory.\n2. **Understand the asset.**\n   - Schema: column types, nullability, primary or unique keys.\n   - Code: the SQL or model that builds it. CASE branches, filters, joins, COALESCEs and\n     derived formulas are where real business rules live.\n   - Grain: what one row represents. This decides the uniqueness key.\n   - Load pattern: full refresh, incremental or append-only, and the refresh schedule.\n     This decides freshness and the time windows.\n   - Immediate lineage: which upstream tables its foreign keys point to.\n   - SQL dialect of the warehouse.\n3. **Collect existing coverage.** Gather existing tests, monitors and constraints for the\n   asset, plus any pending suggestions. Drop any candidate that duplicates or closely\n   resembles one of them, or whose concern they already cover.\n4. **Outline candidates.** List possible tests with one line of reasoning each, and note\n   what evidence each one still needs.\n5. **Gather evidence, only what the candidates need.** Read the code first, because it is\n   free. Profile the data only where parameters depend on it:\n   - distinct values and their counts → accepted values\n   - min and max → bounds\n   - duplicate count over the candidate key → unique\n   - null and empty rate → not null or empty\n   - a sample of rows → relative time or a business rule\n6. **Decide.** Confirm or reject each candidate against the evidence. Reject it if the\n   data already violates it with no sign that this is a bug, if cardinality is too high, or\n   if the rule is not really a constraint.\n7. **Write the tests** in the project's format, each with a short explanation (see\n   *Explanations*).\n8. **Validate** with the project's own tooling if there is any, such as compile, parse or\n   dry-run (for Coalesce Quality, `synqcli deploy \u003Cfiles> --dry-run`). Run the new tests once if you can. A test that fails on its first run needs a\n   look: it has either found a real issue or encoded a wrong rule. Report which.\n\n## Test catalog\n\nThese are the kinds of test to reason with. Map each one onto the closest construct in the\nproject's format (see *Mapping onto the project's format*).\n\n### Not null\n- **Checks that:** none of the listed columns holds NULL.\n- **Use for:** identifiers, foreign keys, required business attributes, timestamps the\n  rest of the pipeline relies on.\n- **Don't use for:** columns the schema already declares NOT NULL or as a primary key, or\n  columns that are optional by design (for example, a LEFT JOIN result or a `cancelled_at`\n  that is null until the event happens).\n- **Evidence:** the schema, plus the code or a profile when you are unsure. A column that\n  is null today can still be required, but say so in the explanation.\n\n### Empty\n- **Checks that:** none of the listed text or array columns is empty, meaning NULL, an\n  empty string, whitespace only, or an empty array.\n- **Use for:** text fields where `''` is as bad as NULL (names, codes, emails).\n- **Note:** in the common implementation this check also catches NULL, so **don't pair it\n  with a not-null test on the same column**. Use one or the other.\n\n### Accepted values\n- **Checks that:** every value in the column is in a complete, closed list.\n- **Use for:** enum-like columns with a small, stable set of values, roughly 20 to 30 or\n  fewer: statuses, types, flags, codes.\n- **Don't use for:** high-cardinality columns, or open sets that grow with the business\n  (country lists your product expands to, product SKUs).\n- **Evidence:** required. Prefer values defined in code (CASE branches, enum definitions,\n  upstream accepted-values tests) over values seen in samples. If you rely on profiling,\n  profile the whole column's distinct values, not a sample. **The list must be complete.**\n- **Note:** this check is usually `col NOT IN (…)`, so NULL passes it. Add a not-null test\n  separately if NULL is invalid too.\n\n### Rejected values\n- **Checks that:** the column never holds any value from a forbidden list.\n- **Use for:** known sentinel or junk values such as `'UNKNOWN'`, `'TEST'`, `'N\u002FA'`, `-1`\n  or `'1970-01-01'`, especially when the set of valid values is open.\n- **Evidence:** the forbidden values must be named by the user, the code or the\n  documentation, or seen in data and confirmed to be junk. No speculative lists.\n\n### Unique\n- **Checks that:** no two rows share the same value, or combination of values, in the\n  listed columns.\n- **Use for:** the asset's grain: primary keys, natural keys and composite business keys.\n- **Don't use for:** columns already declared as primary or unique keys, where the\n  warehouse actually enforces them.\n- **Evidence:** know the grain from the code (GROUP BY, DISTINCT, join cardinality) or\n  profile the duplicate count. If duplicates exist today, find out whether that is a bug\n  before you encode the test.\n- **Scale rule:** on large or growing tables, limit the check to recent rows using the\n  row-creation or load timestamp (for example, the last 30 days or the last week). If\n  there is no clear creation timestamp, check the whole table. The window misses\n  duplicates where one copy falls outside it. That is an accepted trade-off.\n\n### Relationships (referential integrity)\n- **Checks that:** every non-null value of a foreign-key column, or a tuple of columns,\n  exists in the referenced column of another asset.\n- **Use for:** foreign keys you can see in the schema, the join conditions in the code, or\n  immediate upstream lineage.\n- **Parameters:** say whether null foreign keys are allowed, which is usually yes, because\n  optional relations are null. On large tables, scope the check to a time window as you\n  would for unique.\n- **Evidence:** read the referenced asset's schema to confirm the column exists and its\n  type matches.\n\n### Freshness\n- **Checks that:** the most recent value of a timestamp column is no older than a window.\n  The test fails when `max(ts) \u003C now() - window`.\n- **Use for:** assets that are loaded on a schedule or continuously.\n- **Parameters:** pick a timestamp that moves on every load (`loaded_at`, `created_at`,\n  the event time). Set the window to the expected refresh interval plus slack for normal\n  delay, for example daily load → 26 to 36 hours, not exactly 24.\n- **Don't use for:** static reference tables, one-off backfills, or demo and archive data.\n\n### Minimum value \u002F maximum value\n- **Checks that:** the column is ≥ a minimum, or ≤ a maximum. The bound is inclusive\n  unless the format offers strict comparison and you need it.\n- **Use for:** physical or logical bounds such as amounts ≥ 0, quantities ≥ 0, a\n  percentage ≤ 100, or an age ≤ 150.\n- **Rule:** if you don't know the exact range, or it changes over time, assert **only the\n  bound you are sure of**. A non-negative amount gets a minimum of 0 and no maximum.\n\n### Range (min and max)\n- **Checks that:** `min ≤ col ≤ max`.\n- **Use only when both bounds are true by definition:** percentages 0 to 100,\n  probabilities 0 to 1, hour 0 to 23, a rating scale of 1 to 5.\n- **Don't use for:** a range copied from observed min and max (\"0 to 6 passengers because\n  that is what the profile showed\"). That snapshots the data. Use a one-sided bound, or\n  nothing.\n\n### Relative time (ordering)\n- **Checks that:** one timestamp column is not later than another, so the test fails when\n  `first > second`. Equal values and NULLs pass.\n- **Use for:** lifecycle pairs such as `start \u003C end`, `created_at ≤ updated_at`,\n  `ordered_at ≤ shipped_at`, or `pickup ≤ dropoff`.\n- **Evidence:** both columns exist, are date or time types, and a sample confirms the\n  order you expect.\n\n### Business rule (custom SQL)\n- **Checks that:** an expression in the warehouse's SQL dialect, which evaluates to\n  **TRUE for invalid rows**, never matches a row.\n- **Use for:** cross-column logic that no other test can express, such as\n  `total ≠ subtotal + tax` (with a tolerance for floating point), conditional requirements\n  (`status = 'shipped' AND shipped_at IS NULL`), or mutually exclusive flags.\n- **Last resort:** if a catalog test above fits, use it instead.\n- **Rules:**\n  - Use only functions from the asset's SQL dialect.\n  - Compare floating-point values with a tolerance.\n  - Remember that an expression involving NULL evaluates to NULL, which counts as not\n    flagged. Handle NULLs explicitly if they matter.\n  - If the format can deploy one test onto many tables, use its table placeholder rather\n    than a hard-coded name.\n  - Check the polarity: some frameworks want \"returns failing rows\", others want \"the\n    condition that must hold\". Invert accordingly.\n\n## Choosing between overlapping tests\n\n| Situation | Choose |\n|---|---|\n| A text column must be non-blank | **Empty** only (it already covers NULL) |\n| A column must be present, and blank text is fine | **Not null** |\n| Small, closed set of valid values | **Accepted values** (+ not null if NULL is invalid) |\n| Open set, but specific junk values are known | **Rejected values** |\n| Only one bound is certain | **Minimum value** or **Maximum value** |\n| Both bounds are true by definition | **Range** |\n| Two timestamps with a lifecycle order | **Relative time** |\n| A foreign key to another asset | **Relationships** |\n| Multi-column arithmetic or conditional logic | **Business rule** |\n| Grain or key of the asset | **Unique** (time-windowed on large tables) |\n\n## Signals in the asset that point to a test\n\n- A column named `*_id`, `*_key` or `*_code` that is the table's grain → unique (+ not null\n  if the schema does not enforce it).\n- A `*_id` column that joins to another asset, in the code or the lineage → relationships.\n- `status`, `type`, `kind`, `category`, a boolean-like `*_flag` holding `'Y'`\u002F`'N'`, or a\n  CASE expression that produces a fixed set of labels → accepted values.\n- `amount`, `price`, `quantity`, `count`, `duration` or `distance` → minimum 0, if negative\n  values are impossible. Check for refunds and adjustments first.\n- `*_pct`, `*_rate` or `*_ratio` → a range, but only after you confirm whether the scale\n  is 0 to 1 or 0 to 100.\n- Pairs such as `*_start`\u002F`*_end`, `created_at`\u002F`updated_at` or\n  `opened_at`\u002F`closed_at` → relative time.\n- A derived column computed in the code from others (`total = a + b + c`) → business rule.\n- An incremental or scheduled load with a load or event timestamp → freshness.\n- A COALESCE to a sentinel in upstream code (`COALESCE(x, 'UNKNOWN')`) → rejected values on\n  that sentinel downstream, if the sentinel should not reach this asset.\n\n## Scale and cost\n\n- Use time windows on unique and relationships checks for large or append-heavy tables.\n  Anchor the window on the row-creation or load timestamp, not on a business date that can\n  be backdated.\n- Don't profile the whole table when a sample or column statistics will answer the question.\n  Profile only the columns the candidates need.\n- Don't include personal data found while profiling in tests, explanations or summaries.\n  If a rule really needs a sensitive value list, say so and let the user supply it.\n\n## Explanations\n\nEvery test carries a one-sentence explanation of **what it guards against and why it\nmatters**, in business terms. Say where the rule comes from (the code, the schema, the\nuser, or a profile), especially for any value that came from the data.\n\n- Good: \"Order totals must equal the sum of line items plus tax. This is how\n  `fct_orders.sql` derives them, so a mismatch means a broken join upstream.\"\n- Bad: \"Checks total_amount.\"\n\n## Mapping onto the project's format\n\nYou will not always know the target format ahead of time. Map concepts onto it like this:\n\n1. Use the format's **native construct** when one exists (a dbt `not_null`, a SYNQ\n   `accepted_values`, a Soda `invalid_count`, and so on). Match its parameter names, value\n   types and quoting exactly as existing tests do.\n2. If the format has no native construct for a concept, express it as the format's\n   **custom SQL or assertion** construct, with the semantics defined above.\n3. If the format cannot express it at all, such as a time window on uniqueness, **say so**\n   and either drop the refinement and explain the trade-off, or skip the test. Don't skip\n   a test only because you are unsure of the syntax. Look it up, or use the format's\n   custom SQL construct.\n4. Keep the **inclusive or exclusive and NULL semantics** the same as above. When the\n   native construct behaves differently (for example, an accepted-values test that fails\n   on NULL), adjust or note it.\n5. Put tests where the project keeps them and follow its naming, tagging, ownership and\n   severity conventions.\n\n## Coalesce Quality (SYNQ) YAML\n\nCoalesce Quality tests live in YAML files deployed with `synqcli deploy`. The editor\nschema is `https:\u002F\u002Fschemas.synq.io\u002Fsynq-monitors\u002Fv1\u002Fconfig.schema.json`. The schema\nrejects unknown fields, so one wrong key fails the whole deploy.\n\n```yaml\n# yaml-language-server: $schema=https:\u002F\u002Fschemas.synq.io\u002Fsynq-monitors\u002Fv1\u002Fconfig.schema.json\nversion: v1beta2\nnamespace: analytics-orders\ndefaults:\n  severity: ERROR\nentities:\n  - id: \u003Centity id, copied exactly from existing config or the Coalesce Quality UI>\n    tests:\n      - type: not_null\n        columns: [customer_id]\n    monitors:\n      - id: fct_orders_freshness\n        type: freshness\n        expression: loaded_at\n```\n\n- Add tests to the existing entry for the asset under `entities[].tests`. Keep\n  `version: v1beta2`. A file without it is read in a legacy layout.\n- Never guess an entity `id`, including the one a `relationships` test points at. Copy it\n  from another config file in the repo. If no file names it, ask for it.\n- `monitors:` on the same entity are existing coverage too. A `freshness` monitor already\n  covers freshness, so don't add a `freshness` test next to it.\n\n### Fields per test type\n\nEvery test also accepts `id`, `name`, `description`, `severity` (`INFO`, `WARNING` or\n`ERROR`, not `WARN`), `select_columns`, `schedule`, `timezone` and `save_failures`.\n\n| Concept | `type` | Required fields | Optional fields |\n|---|---|---|---|\n| Not null | `not_null` | `columns: [..]` | |\n| Empty | `empty` | `columns: [..]` | |\n| Accepted values | `accepted_values` | `column`, `values: [..]` | |\n| Rejected values | `rejected_values` | `column`, `values: [..]` | |\n| Unique | `unique` | `columns: [..]` | `time_partition_column`, `time_window_seconds` |\n| Relationships | `relationships` | `references` (see below) | `ignore_nulls`, `time_partition_column`, `time_window_seconds` |\n| Freshness | `freshness` | | `time_partition_column`, `time_window_seconds` |\n| Minimum value | `min_value` | `column`, `min_value` | `strictly` |\n| Maximum value | `max_value` | `column`, `max_value` | `strictly` |\n| Range | `min_max` | `column`, `min_value`, `max_value` | `strictly` |\n| Relative time | `relative_time` | `column`, `relative_column` | |\n| Business rule | `business_rule` | `sql_expression` | |\n| Custom query | `business_query` | `sql_query` | `evaluators` |\n\nField names to get right: `columns` is a list and `column` is a single name. The custom\nSQL field is `sql_expression`, not `sql` or `expression`. There is no `custom_sql` type.\n\n```yaml\n- type: relationships\n  references:\n    - entity: \u003Cid of the referenced asset>\n      columns:\n        - source: customer_id\n          reference: customer_id\n  ignore_nulls: true\n  time_partition_column: ordered_at\n  time_window_seconds: 2592000   # 30 days\n```\n\n### How each type behaves\n\nThese come from the SQL that Coalesce Quality generates for each type. Where the public\nexamples disagree, these are correct.\n\n- **`relative_time` fails when `column > relative_column`.** Put the **earlier** timestamp\n  in `column` and the later one in `relative_column`: `column: ordered_at`,\n  `relative_column: shipped_at`. Some published examples show the reverse\n  (`column: ship_date`, `relative_column: order_date`). That version flags every\n  correctly ordered row. Rows where either side is NULL pass.\n- **`relationships` fails on a NULL foreign key unless `ignore_nulls: true` is set.**\n  Optional relations need `ignore_nulls: true`. Leave it off only when NULL is invalid\n  too. That also covers not-null, so don't add a separate not-null test.\n- **`business_rule` reports rows where `sql_expression` is TRUE.** Write the condition\n  for a *bad* row, such as `status = 'shipped' and shipped_at is null`. An expression\n  that describes a good row flags every good row. Write `{{ table }}` to refer to the\n  asset in a subquery. It is the only placeholder allowed.\n- **`accepted_values` lets NULL through** (`col NOT IN (..)`). Add a `not_null` test if\n  NULL is invalid. `rejected_values` lets NULL through as well.\n- **`empty` catches NULL as well as blank text**, so it never needs a `not_null` partner.\n- **`min_value`, `max_value` and `min_max` are inclusive** unless `strictly: true`. NULL\n  passes.\n- **`unique` and `relationships` windows** keep only rows where\n  `time_partition_column >= now - time_window_seconds`. Use the row-creation or load\n  timestamp.\n- **`freshness`** fails when the newest `time_partition_column` value is older than\n  `time_window_seconds`.\n\n## Worked example\n\n### The asset\n\n`analytics.fct_orders` has one row per order. It is loaded incrementally once a day at\n02:00.\n\n```sql\nselect\n  o.id                as order_id,\n  o.customer_id,\n  case o.state\n    when 'new'       then 'open'\n    when 'paid'      then 'open'\n    when 'shipped'   then 'shipped'\n    when 'cancelled' then 'cancelled'\n  end                 as status,\n  o.subtotal,\n  o.tax,\n  o.total             as order_total,\n  o.discount_pct,\n  o.created_at        as ordered_at,\n  s.shipped_at,\n  o.coupon_code,\n  current_timestamp() as loaded_at\nfrom raw.orders o\nleft join raw.shipments s on s.order_id = o.id\nwhere o.created_at > (select max(ordered_at) from analytics.fct_orders)\n```\n\n### What the steps turn up\n\n- **Schema:** `ordered_at` is declared NOT NULL. No other constraints are declared.\n- **Existing coverage:** there is already a not-null test on `order_id`.\n- **Lineage:** `customer_id` joins upstream to `analytics.dim_customers.customer_id`.\n- **Profile, last 30 days:**\n  - 0 duplicate `order_id` values and 0 null `customer_id` values.\n  - `order_total` ranges from 0.00 to 18,400.00.\n  - `discount_pct` ranges from 0.00 to 0.35, so the scale is 0 to 1.\n  - `coupon_code` has 4,210 distinct values and is 61% null.\n- **Sample:** `shipped_at` is never earlier than `ordered_at`. `order_total` matches\n  `subtotal + tax` to within a cent.\n\n### Candidates and decisions\n\n| # | Candidate | Decision | Why |\n|---|---|---|---|\n| 1 | Unique `order_id` | **Keep, windowed on `ordered_at`, last 30 days** | This is the grain. The LEFT JOIN to shipments fans out if an order has two shipments. `ordered_at` is the creation timestamp. |\n| 2 | Not null `order_id` | Drop | Already covered by an existing test. |\n| 3 | Not null `ordered_at` | Drop | The schema already declares it NOT NULL. |\n| 4 | Not null `customer_id` | **Keep** | It is required for every order. The profile shows no nulls today. |\n| 5 | Relationships `customer_id` → `dim_customers.customer_id` | **Keep, windowed** | It is a foreign key visible in the lineage. Nulls are already handled by #4. |\n| 6 | Accepted values `status` ∈ {open, shipped, cancelled} | **Keep** | This is a closed set. The values come from the CASE expression, not from a sample. |\n| 7 | Not null `status` | **Keep** | The CASE has no ELSE, so a new upstream state turns into NULL. Accepted values lets NULL through, so #6 alone would miss it. |\n| 8 | Not null `shipped_at` | Drop | It is null by design for orders that have not shipped (LEFT JOIN). |\n| 9 | Business rule: a shipped order has no ship date | **Keep** | This is the conditional form of #8. Invalid when `status = 'shipped' AND shipped_at IS NULL`. |\n| 10 | Relative time `ordered_at` ≤ `shipped_at` | **Keep** | This is a lifecycle order and the sample confirms it. |\n| 11 | Range `order_total` 0 to 18,400 | Reject | The upper bound is copied from today's data. |\n| 12 | Minimum value `order_total` ≥ 0 | **Keep** | Refunds are modelled elsewhere, so a negative total is a bug. |\n| 13 | Range `discount_pct` 0 to 1 | **Keep** | Both bounds are true by definition for a fraction. Use 1, not the observed 0.35. |\n| 14 | Business rule: `order_total` = `subtotal + tax` | **Keep** | The total comes from the source rather than being computed here, so this checks real data. Invalid when `abs(order_total - (subtotal + tax)) > 0.01`. |\n| 15 | Accepted values `coupon_code` | Reject | 4,210 distinct values is an open set. |\n| 16 | Empty `coupon_code` | Reject | Coupons are optional, so a blank value is not an error. |\n| 17 | Freshness on `loaded_at` | **Keep, 36-hour window** | The load runs daily. The extra 12 hours allow for a late run without alerting. |\n\n### Result\n\nThe result is 11 tests. The schema and existing tests already cover two more candidates,\nand four were rejected. Written out in neutral notation:\n\n```\nunique            columns=[order_id]  window=ordered_at, 30d\n                  — order_id is the grain; the shipments join can fan out an order into duplicates\nnot_null          columns=[customer_id]\n                  — every order belongs to a customer\nrelationships     customer_id → analytics.dim_customers.customer_id  window=ordered_at, 30d\n                  — orders must not point at customers missing from the dimension\naccepted_values   status ∈ {open, shipped, cancelled}\n                  — the only labels the model's CASE produces\nnot_null          columns=[status]\n                  — an unmapped upstream state turns into NULL, which accepted_values lets through\nbusiness_rule     invalid when status = 'shipped' AND shipped_at IS NULL\n                  — a shipped order without a ship date means the shipments join lost its row\nrelative_time     ordered_at ≤ shipped_at\n                  — an order cannot ship before it was placed\nmin_value         order_total ≥ 0\n                  — refunds are modelled separately, so a negative total is a bug\nmin_max           0 ≤ discount_pct ≤ 1\n                  — a discount is a fraction of the order\nbusiness_rule     invalid when abs(order_total - (subtotal + tax)) > 0.01\n                  — the source total must agree with its components\nfreshness         loaded_at, window 36h\n                  — daily load plus 12h of slack\n```\n\n### Mapping onto a format (dbt as an example)\n\n- `unique` and `relationships` have no time-window parameter in dbt. Express the window\n  as the test's `where` config, written in the warehouse dialect.\n- `dbt_utils.expression_is_true` asserts the **valid** condition. Invert the invalid-row\n  expressions, for example `not (status = 'shipped' and shipped_at is null)`.\n- Freshness on a model, rather than a source, has no native test in dbt core. Use\n  `dbt_utils.recency` if the package is installed, or a singular SQL test otherwise.\n\n## Before you finish\n\n- [ ] Each test has a single, clear concern and an explanation of why it exists.\n- [ ] No test duplicates an existing test, a schema constraint or another suggestion.\n- [ ] No not-null test on a column that is NOT NULL or a primary key, and no not-null +\n      empty pair on the same column.\n- [ ] Every value list and bound came from the code, the docs, the user or a profile, and\n      none came from a guess.\n- [ ] Ranges use both bounds only when both are true by definition.\n- [ ] Accepted-values lists are complete.\n- [ ] Unique and relationships checks on big tables are time-windowed on a creation or\n      load timestamp.\n- [ ] Freshness windows include slack over the refresh interval.\n- [ ] Custom SQL uses the asset's dialect, flags *invalid* rows (or is inverted correctly\n      for the format) and handles NULLs.\n- [ ] The tests parse or compile with the project's tooling.\n- [ ] Coalesce Quality YAML: each field matches the table in *Fields per test type*,\n      `relative_time` puts the earlier column in `column`, optional foreign keys set\n      `ignore_nulls: true`, and every entity id is copied, not guessed.\n","\u003C!-- coalesce-node-managed: true -->\n\n# Data test authoring\n\nA data test is a **deterministic assertion over the rows of one asset**: a query that\nreturns the rows breaking a rule. If it returns no rows, the test passes. This skill\ncovers *which* assertions to write and *with what parameters*. The syntax comes from the\nproject you are working in.\n\n## Stance\n\n- **Suggest fewer, better tests.** Every test costs warehouse compute and adds alert noise.\n  One test that catches a real failure mode is worth more than five that restate the schema.\n  Suggesting nothing is a valid result.\n- **Keep each test to one concern.** To check the same thing on several columns, write one\n  test per column. Combine columns only when the rule needs them together, such as a\n  composite key or a cross-column formula. A multi-column not-null or empty check is fine\n  when the columns form one concern (for example, \"both location IDs present\").\n- **Never guess values.** Any test whose parameters depend on what the data holds\n  (allowed values, bounds, keys) needs evidence from the code, the schema, documentation\n  or a profiling query. If you cannot get evidence, drop the test or ask for the value.\n- **Write rules, not snapshots.** A test should hold for tomorrow's data as well as\n  today's. A bound or value list copied from a sample of current data is a snapshot and\n  will fail on legitimate new data.\n- **Don't duplicate.** Check what already exists before adding anything: tests, schema\n  constraints, and earlier suggestions.\n\n## Workflow\n\n1. **Find the project's test format.** Look for existing tests next to the asset or\n   elsewhere in the repo, such as `schema.yml`\u002F`*.yml` with `tests:`\u002F`data_tests:`, SYNQ\n   `*.yaml` check configs, SQLMesh `audits`, Soda `checks.yml`, GE suites or `tests\u002F*.sql`.\n   Copy their structure, naming, file placement and severity conventions. If there is no\n   format and the user named none, ask before inventing one. If the project uses\n   Coalesce Quality YAML (a file with `version: v1beta2` and `entities:`), follow\n   *Coalesce Quality (SYNQ) YAML* below for field names and behavior. Do not write\n   that format from memory.\n2. **Understand the asset.**\n   - Schema: column types, nullability, primary or unique keys.\n   - Code: the SQL or model that builds it. CASE branches, filters, joins, COALESCEs and\n     derived formulas are where real business rules live.\n   - Grain: what one row represents. This decides the uniqueness key.\n   - Load pattern: full refresh, incremental or append-only, and the refresh schedule.\n     This decides freshness and the time windows.\n   - Immediate lineage: which upstream tables its foreign keys point to.\n   - SQL dialect of the warehouse.\n3. **Collect existing coverage.** Gather existing tests, monitors and constraints for the\n   asset, plus any pending suggestions. Drop any candidate that duplicates or closely\n   resembles one of them, or whose concern they already cover.\n4. **Outline candidates.** List possible tests with one line of reasoning each, and note\n   what evidence each one still needs.\n5. **Gather evidence, only what the candidates need.** Read the code first, because it is\n   free. Profile the data only where parameters depend on it:\n   - distinct values and their counts → accepted values\n   - min and max → bounds\n   - duplicate count over the candidate key → unique\n   - null and empty rate → not null or empty\n   - a sample of rows → relative time or a business rule\n6. **Decide.** Confirm or reject each candidate against the evidence. Reject it if the\n   data already violates it with no sign that this is a bug, if cardinality is too high, or\n   if the rule is not really a constraint.\n7. **Write the tests** in the project's format, each with a short explanation (see\n   *Explanations*).\n8. **Validate** with the project's own tooling if there is any, such as compile, parse or\n   dry-run (for Coalesce Quality, `synqcli deploy \u003Cfiles> --dry-run`). Run the new tests once if you can. A test that fails on its first run needs a\n   look: it has either found a real issue or encoded a wrong rule. Report which.\n\n## Test catalog\n\nThese are the kinds of test to reason with. Map each one onto the closest construct in the\nproject's format (see *Mapping onto the project's format*).\n\n### Not null\n- **Checks that:** none of the listed columns holds NULL.\n- **Use for:** identifiers, foreign keys, required business attributes, timestamps the\n  rest of the pipeline relies on.\n- **Don't use for:** columns the schema already declares NOT NULL or as a primary key, or\n  columns that are optional by design (for example, a LEFT JOIN result or a `cancelled_at`\n  that is null until the event happens).\n- **Evidence:** the schema, plus the code or a profile when you are unsure. A column that\n  is null today can still be required, but say so in the explanation.\n\n### Empty\n- **Checks that:** none of the listed text or array columns is empty, meaning NULL, an\n  empty string, whitespace only, or an empty array.\n- **Use for:** text fields where `''` is as bad as NULL (names, codes, emails).\n- **Note:** in the common implementation this check also catches NULL, so **don't pair it\n  with a not-null test on the same column**. Use one or the other.\n\n### Accepted values\n- **Checks that:** every value in the column is in a complete, closed list.\n- **Use for:** enum-like columns with a small, stable set of values, roughly 20 to 30 or\n  fewer: statuses, types, flags, codes.\n- **Don't use for:** high-cardinality columns, or open sets that grow with the business\n  (country lists your product expands to, product SKUs).\n- **Evidence:** required. Prefer values defined in code (CASE branches, enum definitions,\n  upstream accepted-values tests) over values seen in samples. If you rely on profiling,\n  profile the whole column's distinct values, not a sample. **The list must be complete.**\n- **Note:** this check is usually `col NOT IN (…)`, so NULL passes it. Add a not-null test\n  separately if NULL is invalid too.\n\n### Rejected values\n- **Checks that:** the column never holds any value from a forbidden list.\n- **Use for:** known sentinel or junk values such as `'UNKNOWN'`, `'TEST'`, `'N\u002FA'`, `-1`\n  or `'1970-01-01'`, especially when the set of valid values is open.\n- **Evidence:** the forbidden values must be named by the user, the code or the\n  documentation, or seen in data and confirmed to be junk. No speculative lists.\n\n### Unique\n- **Checks that:** no two rows share the same value, or combination of values, in the\n  listed columns.\n- **Use for:** the asset's grain: primary keys, natural keys and composite business keys.\n- **Don't use for:** columns already declared as primary or unique keys, where the\n  warehouse actually enforces them.\n- **Evidence:** know the grain from the code (GROUP BY, DISTINCT, join cardinality) or\n  profile the duplicate count. If duplicates exist today, find out whether that is a bug\n  before you encode the test.\n- **Scale rule:** on large or growing tables, limit the check to recent rows using the\n  row-creation or load timestamp (for example, the last 30 days or the last week). If\n  there is no clear creation timestamp, check the whole table. The window misses\n  duplicates where one copy falls outside it. That is an accepted trade-off.\n\n### Relationships (referential integrity)\n- **Checks that:** every non-null value of a foreign-key column, or a tuple of columns,\n  exists in the referenced column of another asset.\n- **Use for:** foreign keys you can see in the schema, the join conditions in the code, or\n  immediate upstream lineage.\n- **Parameters:** say whether null foreign keys are allowed, which is usually yes, because\n  optional relations are null. On large tables, scope the check to a time window as you\n  would for unique.\n- **Evidence:** read the referenced asset's schema to confirm the column exists and its\n  type matches.\n\n### Freshness\n- **Checks that:** the most recent value of a timestamp column is no older than a window.\n  The test fails when `max(ts) \u003C now() - window`.\n- **Use for:** assets that are loaded on a schedule or continuously.\n- **Parameters:** pick a timestamp that moves on every load (`loaded_at`, `created_at`,\n  the event time). Set the window to the expected refresh interval plus slack for normal\n  delay, for example daily load → 26 to 36 hours, not exactly 24.\n- **Don't use for:** static reference tables, one-off backfills, or demo and archive data.\n\n### Minimum value \u002F maximum value\n- **Checks that:** the column is ≥ a minimum, or ≤ a maximum. The bound is inclusive\n  unless the format offers strict comparison and you need it.\n- **Use for:** physical or logical bounds such as amounts ≥ 0, quantities ≥ 0, a\n  percentage ≤ 100, or an age ≤ 150.\n- **Rule:** if you don't know the exact range, or it changes over time, assert **only the\n  bound you are sure of**. A non-negative amount gets a minimum of 0 and no maximum.\n\n### Range (min and max)\n- **Checks that:** `min ≤ col ≤ max`.\n- **Use only when both bounds are true by definition:** percentages 0 to 100,\n  probabilities 0 to 1, hour 0 to 23, a rating scale of 1 to 5.\n- **Don't use for:** a range copied from observed min and max (\"0 to 6 passengers because\n  that is what the profile showed\"). That snapshots the data. Use a one-sided bound, or\n  nothing.\n\n### Relative time (ordering)\n- **Checks that:** one timestamp column is not later than another, so the test fails when\n  `first > second`. Equal values and NULLs pass.\n- **Use for:** lifecycle pairs such as `start \u003C end`, `created_at ≤ updated_at`,\n  `ordered_at ≤ shipped_at`, or `pickup ≤ dropoff`.\n- **Evidence:** both columns exist, are date or time types, and a sample confirms the\n  order you expect.\n\n### Business rule (custom SQL)\n- **Checks that:** an expression in the warehouse's SQL dialect, which evaluates to\n  **TRUE for invalid rows**, never matches a row.\n- **Use for:** cross-column logic that no other test can express, such as\n  `total ≠ subtotal + tax` (with a tolerance for floating point), conditional requirements\n  (`status = 'shipped' AND shipped_at IS NULL`), or mutually exclusive flags.\n- **Last resort:** if a catalog test above fits, use it instead.\n- **Rules:**\n  - Use only functions from the asset's SQL dialect.\n  - Compare floating-point values with a tolerance.\n  - Remember that an expression involving NULL evaluates to NULL, which counts as not\n    flagged. Handle NULLs explicitly if they matter.\n  - If the format can deploy one test onto many tables, use its table placeholder rather\n    than a hard-coded name.\n  - Check the polarity: some frameworks want \"returns failing rows\", others want \"the\n    condition that must hold\". Invert accordingly.\n\n## Choosing between overlapping tests\n\n| Situation | Choose |\n|---|---|\n| A text column must be non-blank | **Empty** only (it already covers NULL) |\n| A column must be present, and blank text is fine | **Not null** |\n| Small, closed set of valid values | **Accepted values** (+ not null if NULL is invalid) |\n| Open set, but specific junk values are known | **Rejected values** |\n| Only one bound is certain | **Minimum value** or **Maximum value** |\n| Both bounds are true by definition | **Range** |\n| Two timestamps with a lifecycle order | **Relative time** |\n| A foreign key to another asset | **Relationships** |\n| Multi-column arithmetic or conditional logic | **Business rule** |\n| Grain or key of the asset | **Unique** (time-windowed on large tables) |\n\n## Signals in the asset that point to a test\n\n- A column named `*_id`, `*_key` or `*_code` that is the table's grain → unique (+ not null\n  if the schema does not enforce it).\n- A `*_id` column that joins to another asset, in the code or the lineage → relationships.\n- `status`, `type`, `kind`, `category`, a boolean-like `*_flag` holding `'Y'`\u002F`'N'`, or a\n  CASE expression that produces a fixed set of labels → accepted values.\n- `amount`, `price`, `quantity`, `count`, `duration` or `distance` → minimum 0, if negative\n  values are impossible. Check for refunds and adjustments first.\n- `*_pct`, `*_rate` or `*_ratio` → a range, but only after you confirm whether the scale\n  is 0 to 1 or 0 to 100.\n- Pairs such as `*_start`\u002F`*_end`, `created_at`\u002F`updated_at` or\n  `opened_at`\u002F`closed_at` → relative time.\n- A derived column computed in the code from others (`total = a + b + c`) → business rule.\n- An incremental or scheduled load with a load or event timestamp → freshness.\n- A COALESCE to a sentinel in upstream code (`COALESCE(x, 'UNKNOWN')`) → rejected values on\n  that sentinel downstream, if the sentinel should not reach this asset.\n\n## Scale and cost\n\n- Use time windows on unique and relationships checks for large or append-heavy tables.\n  Anchor the window on the row-creation or load timestamp, not on a business date that can\n  be backdated.\n- Don't profile the whole table when a sample or column statistics will answer the question.\n  Profile only the columns the candidates need.\n- Don't include personal data found while profiling in tests, explanations or summaries.\n  If a rule really needs a sensitive value list, say so and let the user supply it.\n\n## Explanations\n\nEvery test carries a one-sentence explanation of **what it guards against and why it\nmatters**, in business terms. Say where the rule comes from (the code, the schema, the\nuser, or a profile), especially for any value that came from the data.\n\n- Good: \"Order totals must equal the sum of line items plus tax. This is how\n  `fct_orders.sql` derives them, so a mismatch means a broken join upstream.\"\n- Bad: \"Checks total_amount.\"\n\n## Mapping onto the project's format\n\nYou will not always know the target format ahead of time. Map concepts onto it like this:\n\n1. Use the format's **native construct** when one exists (a dbt `not_null`, a SYNQ\n   `accepted_values`, a Soda `invalid_count`, and so on). Match its parameter names, value\n   types and quoting exactly as existing tests do.\n2. If the format has no native construct for a concept, express it as the format's\n   **custom SQL or assertion** construct, with the semantics defined above.\n3. If the format cannot express it at all, such as a time window on uniqueness, **say so**\n   and either drop the refinement and explain the trade-off, or skip the test. Don't skip\n   a test only because you are unsure of the syntax. Look it up, or use the format's\n   custom SQL construct.\n4. Keep the **inclusive or exclusive and NULL semantics** the same as above. When the\n   native construct behaves differently (for example, an accepted-values test that fails\n   on NULL), adjust or note it.\n5. Put tests where the project keeps them and follow its naming, tagging, ownership and\n   severity conventions.\n\n## Coalesce Quality (SYNQ) YAML\n\nCoalesce Quality tests live in YAML files deployed with `synqcli deploy`. The editor\nschema is `https:\u002F\u002Fschemas.synq.io\u002Fsynq-monitors\u002Fv1\u002Fconfig.schema.json`. The schema\nrejects unknown fields, so one wrong key fails the whole deploy.\n\n```yaml\n# yaml-language-server: $schema=https:\u002F\u002Fschemas.synq.io\u002Fsynq-monitors\u002Fv1\u002Fconfig.schema.json\nversion: v1beta2\nnamespace: analytics-orders\ndefaults:\n  severity: ERROR\nentities:\n  - id: \u003Centity id, copied exactly from existing config or the Coalesce Quality UI>\n    tests:\n      - type: not_null\n        columns: [customer_id]\n    monitors:\n      - id: fct_orders_freshness\n        type: freshness\n        expression: loaded_at\n```\n\n- Add tests to the existing entry for the asset under `entities[].tests`. Keep\n  `version: v1beta2`. A file without it is read in a legacy layout.\n- Never guess an entity `id`, including the one a `relationships` test points at. Copy it\n  from another config file in the repo. If no file names it, ask for it.\n- `monitors:` on the same entity are existing coverage too. A `freshness` monitor already\n  covers freshness, so don't add a `freshness` test next to it.\n\n### Fields per test type\n\nEvery test also accepts `id`, `name`, `description`, `severity` (`INFO`, `WARNING` or\n`ERROR`, not `WARN`), `select_columns`, `schedule`, `timezone` and `save_failures`.\n\n| Concept | `type` | Required fields | Optional fields |\n|---|---|---|---|\n| Not null | `not_null` | `columns: [..]` | |\n| Empty | `empty` | `columns: [..]` | |\n| Accepted values | `accepted_values` | `column`, `values: [..]` | |\n| Rejected values | `rejected_values` | `column`, `values: [..]` | |\n| Unique | `unique` | `columns: [..]` | `time_partition_column`, `time_window_seconds` |\n| Relationships | `relationships` | `references` (see below) | `ignore_nulls`, `time_partition_column`, `time_window_seconds` |\n| Freshness | `freshness` | | `time_partition_column`, `time_window_seconds` |\n| Minimum value | `min_value` | `column`, `min_value` | `strictly` |\n| Maximum value | `max_value` | `column`, `max_value` | `strictly` |\n| Range | `min_max` | `column`, `min_value`, `max_value` | `strictly` |\n| Relative time | `relative_time` | `column`, `relative_column` | |\n| Business rule | `business_rule` | `sql_expression` | |\n| Custom query | `business_query` | `sql_query` | `evaluators` |\n\nField names to get right: `columns` is a list and `column` is a single name. The custom\nSQL field is `sql_expression`, not `sql` or `expression`. There is no `custom_sql` type.\n\n```yaml\n- type: relationships\n  references:\n    - entity: \u003Cid of the referenced asset>\n      columns:\n        - source: customer_id\n          reference: customer_id\n  ignore_nulls: true\n  time_partition_column: ordered_at\n  time_window_seconds: 2592000   # 30 days\n```\n\n### How each type behaves\n\nThese come from the SQL that Coalesce Quality generates for each type. Where the public\nexamples disagree, these are correct.\n\n- **`relative_time` fails when `column > relative_column`.** Put the **earlier** timestamp\n  in `column` and the later one in `relative_column`: `column: ordered_at`,\n  `relative_column: shipped_at`. Some published examples show the reverse\n  (`column: ship_date`, `relative_column: order_date`). That version flags every\n  correctly ordered row. Rows where either side is NULL pass.\n- **`relationships` fails on a NULL foreign key unless `ignore_nulls: true` is set.**\n  Optional relations need `ignore_nulls: true`. Leave it off only when NULL is invalid\n  too. That also covers not-null, so don't add a separate not-null test.\n- **`business_rule` reports rows where `sql_expression` is TRUE.** Write the condition\n  for a *bad* row, such as `status = 'shipped' and shipped_at is null`. An expression\n  that describes a good row flags every good row. Write `{{ table }}` to refer to the\n  asset in a subquery. It is the only placeholder allowed.\n- **`accepted_values` lets NULL through** (`col NOT IN (..)`). Add a `not_null` test if\n  NULL is invalid. `rejected_values` lets NULL through as well.\n- **`empty` catches NULL as well as blank text**, so it never needs a `not_null` partner.\n- **`min_value`, `max_value` and `min_max` are inclusive** unless `strictly: true`. NULL\n  passes.\n- **`unique` and `relationships` windows** keep only rows where\n  `time_partition_column >= now - time_window_seconds`. Use the row-creation or load\n  timestamp.\n- **`freshness`** fails when the newest `time_partition_column` value is older than\n  `time_window_seconds`.\n\n## Worked example\n\n### The asset\n\n`analytics.fct_orders` has one row per order. It is loaded incrementally once a day at\n02:00.\n\n```sql\nselect\n  o.id                as order_id,\n  o.customer_id,\n  case o.state\n    when 'new'       then 'open'\n    when 'paid'      then 'open'\n    when 'shipped'   then 'shipped'\n    when 'cancelled' then 'cancelled'\n  end                 as status,\n  o.subtotal,\n  o.tax,\n  o.total             as order_total,\n  o.discount_pct,\n  o.created_at        as ordered_at,\n  s.shipped_at,\n  o.coupon_code,\n  current_timestamp() as loaded_at\nfrom raw.orders o\nleft join raw.shipments s on s.order_id = o.id\nwhere o.created_at > (select max(ordered_at) from analytics.fct_orders)\n```\n\n### What the steps turn up\n\n- **Schema:** `ordered_at` is declared NOT NULL. No other constraints are declared.\n- **Existing coverage:** there is already a not-null test on `order_id`.\n- **Lineage:** `customer_id` joins upstream to `analytics.dim_customers.customer_id`.\n- **Profile, last 30 days:**\n  - 0 duplicate `order_id` values and 0 null `customer_id` values.\n  - `order_total` ranges from 0.00 to 18,400.00.\n  - `discount_pct` ranges from 0.00 to 0.35, so the scale is 0 to 1.\n  - `coupon_code` has 4,210 distinct values and is 61% null.\n- **Sample:** `shipped_at` is never earlier than `ordered_at`. `order_total` matches\n  `subtotal + tax` to within a cent.\n\n### Candidates and decisions\n\n| # | Candidate | Decision | Why |\n|---|---|---|---|\n| 1 | Unique `order_id` | **Keep, windowed on `ordered_at`, last 30 days** | This is the grain. The LEFT JOIN to shipments fans out if an order has two shipments. `ordered_at` is the creation timestamp. |\n| 2 | Not null `order_id` | Drop | Already covered by an existing test. |\n| 3 | Not null `ordered_at` | Drop | The schema already declares it NOT NULL. |\n| 4 | Not null `customer_id` | **Keep** | It is required for every order. The profile shows no nulls today. |\n| 5 | Relationships `customer_id` → `dim_customers.customer_id` | **Keep, windowed** | It is a foreign key visible in the lineage. Nulls are already handled by #4. |\n| 6 | Accepted values `status` ∈ {open, shipped, cancelled} | **Keep** | This is a closed set. The values come from the CASE expression, not from a sample. |\n| 7 | Not null `status` | **Keep** | The CASE has no ELSE, so a new upstream state turns into NULL. Accepted values lets NULL through, so #6 alone would miss it. |\n| 8 | Not null `shipped_at` | Drop | It is null by design for orders that have not shipped (LEFT JOIN). |\n| 9 | Business rule: a shipped order has no ship date | **Keep** | This is the conditional form of #8. Invalid when `status = 'shipped' AND shipped_at IS NULL`. |\n| 10 | Relative time `ordered_at` ≤ `shipped_at` | **Keep** | This is a lifecycle order and the sample confirms it. |\n| 11 | Range `order_total` 0 to 18,400 | Reject | The upper bound is copied from today's data. |\n| 12 | Minimum value `order_total` ≥ 0 | **Keep** | Refunds are modelled elsewhere, so a negative total is a bug. |\n| 13 | Range `discount_pct` 0 to 1 | **Keep** | Both bounds are true by definition for a fraction. Use 1, not the observed 0.35. |\n| 14 | Business rule: `order_total` = `subtotal + tax` | **Keep** | The total comes from the source rather than being computed here, so this checks real data. Invalid when `abs(order_total - (subtotal + tax)) > 0.01`. |\n| 15 | Accepted values `coupon_code` | Reject | 4,210 distinct values is an open set. |\n| 16 | Empty `coupon_code` | Reject | Coupons are optional, so a blank value is not an error. |\n| 17 | Freshness on `loaded_at` | **Keep, 36-hour window** | The load runs daily. The extra 12 hours allow for a late run without alerting. |\n\n### Result\n\nThe result is 11 tests. The schema and existing tests already cover two more candidates,\nand four were rejected. Written out in neutral notation:\n\n```\nunique            columns=[order_id]  window=ordered_at, 30d\n                  — order_id is the grain; the shipments join can fan out an order into duplicates\nnot_null          columns=[customer_id]\n                  — every order belongs to a customer\nrelationships     customer_id → analytics.dim_customers.customer_id  window=ordered_at, 30d\n                  — orders must not point at customers missing from the dimension\naccepted_values   status ∈ {open, shipped, cancelled}\n                  — the only labels the model's CASE produces\nnot_null          columns=[status]\n                  — an unmapped upstream state turns into NULL, which accepted_values lets through\nbusiness_rule     invalid when status = 'shipped' AND shipped_at IS NULL\n                  — a shipped order without a ship date means the shipments join lost its row\nrelative_time     ordered_at ≤ shipped_at\n                  — an order cannot ship before it was placed\nmin_value         order_total ≥ 0\n                  — refunds are modelled separately, so a negative total is a bug\nmin_max           0 ≤ discount_pct ≤ 1\n                  — a discount is a fraction of the order\nbusiness_rule     invalid when abs(order_total - (subtotal + tax)) > 0.01\n                  — the source total must agree with its components\nfreshness         loaded_at, window 36h\n                  — daily load plus 12h of slack\n```\n\n### Mapping onto a format (dbt as an example)\n\n- `unique` and `relationships` have no time-window parameter in dbt. Express the window\n  as the test's `where` config, written in the warehouse dialect.\n- `dbt_utils.expression_is_true` asserts the **valid** condition. Invert the invalid-row\n  expressions, for example `not (status = 'shipped' and shipped_at is null)`.\n- Freshness on a model, rather than a source, has no native test in dbt core. Use\n  `dbt_utils.recency` if the package is installed, or a singular SQL test otherwise.\n\n## Before you finish\n\n- [ ] Each test has a single, clear concern and an explanation of why it exists.\n- [ ] No test duplicates an existing test, a schema constraint or another suggestion.\n- [ ] No not-null test on a column that is NOT NULL or a primary key, and no not-null +\n      empty pair on the same column.\n- [ ] Every value list and bound came from the code, the docs, the user or a profile, and\n      none came from a guess.\n- [ ] Ranges use both bounds only when both are true by definition.\n- [ ] Accepted-values lists are complete.\n- [ ] Unique and relationships checks on big tables are time-windowed on a creation or\n      load timestamp.\n- [ ] Freshness windows include slack over the refresh interval.\n- [ ] Custom SQL uses the asset's dialect, flags *invalid* rows (or is inverted correctly\n      for the format) and handles NULLs.\n- [ ] The tests parse or compile with the project's tooling.\n- [ ] Coalesce Quality YAML: each field matches the table in *Fields per test type*,\n      `relative_time` puts the earlier column in `column`, optional foreign keys set\n      `ignore_nulls: true`, and every entity id is copied, not guessed.\n",{"name":5,"description":7},"develop","0380f6339f1c9c60a1129692e86be71db7c8bb89","skills\u002Fcoalesce-quality-test-authoring","https:\u002F\u002Fgithub.com\u002FCoalesce-Software-Inc\u002Fcoalesce-platform-skills","https:\u002F\u002Fgithub.com\u002FCoalesce-Software-Inc","coalesce.io","2026-11-11 05:53:06",{"source":8,"skillName":5,"commands":32,"prompt":42,"zipAvailable":43},[33,36,39],{"tool":34,"command":35},"npx","npx skills add Coalesce-Software-Inc\u002Fcoalesce-platform-skills --skill coalesce-quality-test-authoring",{"tool":37,"command":38},"bunx","bunx skills add Coalesce-Software-Inc\u002Fcoalesce-platform-skills --skill coalesce-quality-test-authoring",{"tool":40,"command":41},"pnpm","pnpm dlx skills add Coalesce-Software-Inc\u002Fcoalesce-platform-skills --skill coalesce-quality-test-authoring","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FCoalesce-Software-Inc\u002Fcoalesce-platform-skills\u002Fblob\u002Fdevelop\u002Fskills\u002Fcoalesce-quality-test-authoring\u002FSKILL.md",true,[],[46,53,60,67,74,81],{"skillNo":47,"name":48,"nameZh":6,"description":49,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":50,"categories":51,"keywords":52,"publishedAt":19},"01M77G2G7J2EP79X0C3RPDV6ND","coalesce-transform-mcp-install","Use when installing, connecting, or troubleshooting the hosted Coalesce Transform MCP server in an MCP client (Claude Code, Claude Desktop, Cursor, VS Code, Cortex Code) — endpoint URL, access token handling, registration, and verification. Not for coa CLI auth (use coalesce-cloud-api).","https:\u002F\u002Fgithub.com\u002FCoalesce-Software-Inc\u002Fcoalesce-platform-skills\u002Fblob\u002Fdevelop\u002Fskills\u002Fcoalesce-transform-mcp-install\u002FSKILL.md",[],[],{"skillNo":54,"name":55,"nameZh":6,"description":56,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":57,"categories":58,"keywords":59,"publishedAt":19},"01M77G2CPHB84J4S949VJ4DXB4","coalesce-sql-transformation","Use when editing the SQL inside existing Coalesce V2 node files (.sql) — changing column expressions, joins, filters, CTEs, inline column annotations, or ref() macros. Not for creating\u002Fdeleting node files (use coalesce-pipeline-structure).","https:\u002F\u002Fgithub.com\u002FCoalesce-Software-Inc\u002Fcoalesce-platform-skills\u002Fblob\u002Fdevelop\u002Fskills\u002Fcoalesce-sql-transformation\u002FSKILL.md",[],[],{"skillNo":61,"name":62,"nameZh":6,"description":63,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":64,"categories":65,"keywords":66,"publishedAt":19},"01M77G29YB2RF8F7KYB3Y6T4ZS","coalesce-review-risk","Use when reviewing Coalesce pipeline changes for correctness, impact, and risk before approval — READ-ONLY analysis of diffs, coa validate\u002Fdry-run evidence, and downstream blast radius. Never edits files or runs warehouse-mutating commands.","https:\u002F\u002Fgithub.com\u002FCoalesce-Software-Inc\u002Fcoalesce-platform-skills\u002Fblob\u002Fdevelop\u002Fskills\u002Fcoalesce-review-risk\u002FSKILL.md",[],[],{"skillNo":68,"name":69,"nameZh":6,"description":70,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":71,"categories":72,"keywords":73,"publishedAt":19},"01M77G27472MK0Q5HEXTTAF9RG","coalesce-rename-node-cascade","Rename a Coalesce node and cascade the new name through every downstream ref(), job selector, and subgraph selector, with quote-agnostic matching and validation.","https:\u002F\u002Fgithub.com\u002FCoalesce-Software-Inc\u002Fcoalesce-platform-skills\u002Fblob\u002Fdevelop\u002Fskills\u002Fcoalesce-rename-node-cascade\u002FSKILL.md",[],[],{"skillNo":75,"name":76,"nameZh":6,"description":77,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":78,"categories":79,"keywords":80,"publishedAt":19},"01M77G1YM5TCKSHQA6QZRERXF2","coalesce-pipelines","Use when working in a Coalesce Transform repository (data.yml + nodes\u002F with \u003CLOCATION>-\u003CNAME>.sql\u002F.yml files) — building, editing, validating, or running data transformation pipelines with the coa CLI, including editing V1 .yml nodes and shared config (data.yml, locations, environments, jobs, node types). Start here; it routes to the more specific coalesce-* skills.","https:\u002F\u002Fgithub.com\u002FCoalesce-Software-Inc\u002Fcoalesce-platform-skills\u002Fblob\u002Fdevelop\u002Fskills\u002Fcoalesce-pipelines\u002FSKILL.md",[],[],{"skillNo":82,"name":83,"nameZh":6,"description":84,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":85,"categories":86,"keywords":87,"publishedAt":19},"01M77G1TQGX567YQYQY734T361","coalesce-pipeline-structure","Use when creating, deleting, renaming, or rewiring Coalesce nodes, subgraphs, or jobs — changing the structural topology of the transformation DAG. Not for editing SQL inside an existing node (use coalesce-sql-transformation).","https:\u002F\u002Fgithub.com\u002FCoalesce-Software-Inc\u002Fcoalesce-platform-skills\u002Fblob\u002Fdevelop\u002Fskills\u002Fcoalesce-pipeline-structure\u002FSKILL.md",[],[]]