Tasks: share rules across fields
Who does this: a data steward, with the quality-steward policyPolicy A set of permissions an administrator gives an account or a group. The product ships ready-made ones for the usual roles, such as quality-steward and quality-viewer.. The
global rulesGlobal rules A dataset's file reglas_globales.yaml: what several fields share, such as lists, populations and named rules, declared once for every rules file of the dataset. are a rulesRule It applies a pattern to a field; the pattern gives it its dimension and a default severity. The rules that count are the ones on main, the approved version. file like any other: written, checked and taken to
main as in Write, change and test a rule. What each
section means is in Rule language: what the dataset declares
once.
What the global rules are for
Section titled “What the global rules are for”Each datasetDataset One table of a source as Quality Data reads it: a name, its fields and the rules that check them. has one Global rules file, reglas_globales.yaml, beside
its fields’ files. It declares once what several fields use, and every file
of the dataset sees it as if it declared it itself:
- populations, lists, placeholders, derived fields, references to other datasets and combination tables;
- named rules: a check written once, which a field’s ruleRule It applies a pattern to a field; the pattern gives it its dimension and a default severity. The rules that count are the ones on main, the approved version. takes with
extends.
It has no rules of its own: each rule stays in its field’s file. A name means one thing in the whole dataset, so a list or population declared in the global rules is not declared again in a field’s file.
To open the global rules
Section titled “To open the global rules”In the Explorer, open the datasetDataset One table of a source as Quality Data reads it: a name, its fields and the rules that check them. (◆ customers) and choose
◆ Global rules, its first line. If the dataset has none yet, the editor
opens an empty one, dataset: customers, and saving or deploying creates
it.
To declare a list once and use it
Section titled “To declare a list once and use it”-
In the global rulesGlobal rules A dataset's file reglas_globales.yaml: what several fields share, such as lists, populations and named rules, declared once for every rules file of the dataset., add the list:
dataset: customerslists:regions: [NORTH, SOUTH, EAST, WEST] -
Deploy it (Deploy, then Deploy again to confirm).
-
In
Region.yaml, use it:- id: REG-01field: Regioncheck: domainin: { list: regions }alert: The region is not one of the organisation's
Deploy the global rules first: a field’s file is checked with the global
rules on main, so until then the editor says There is no list named
regions (QR004). The same holds for a test.
To write a check once and reuse it
Section titled “To write a check once and reuse it”Say customers has two e-mail fields, Email and WorkEmail, checked the
same way.
-
In the global rulesGlobal rules A dataset's file reglas_globales.yaml: what several fields share, such as lists, populations and named rules, declared once for every rules file of the dataset., under
named, write the check with everything butidandfield:named:valid_email:check: formatnamed: emailseverity: majoralert: The e-mail address is not valid -
Deploy the global rules.
-
In each field’s file, start the ruleRule It applies a pattern to a field; the pattern gives it its dimension and a default severity. The rules that count are the ones on main, the approved version. from it with
extends, and change only what differs:- id: WEM-01field: WorkEmailextends: valid_emailseverity: minor
At the extends line the editor says the rule as it results, such as As
valid_email: it applies to …; it fails when …, and As read shows it
whole. A named ruleNamed rule A check written once in a dataset's global rules, with everything but its id and field; a field's rule starts from it with extends. needs a patternPattern A reusable way of validating (required, format, fresh and eleven more). Each rule is a pattern applied to a field with its condition. (check) and cannot extend another.
To change or remove a shared check
Section titled “To change or remove a shared check”A change to a named ruleNamed rule A check written once in a dataset's global rules, with everything but its id and field; a field's rule starts from it with extends. changes every ruleRule It applies a pattern to a field; the pattern gives it its dimension and a default severity. The rules that count are the ones on main, the approved version. that extends it, from the next cutCut The dataset's data as it was on one date, copied into the lake so it can be measured again without touching the source. Every figure of a report refers to that moment., without touching their files. Two things to know before you deploy:
- The confirmation of the global rulesGlobal rules A dataset's file reglas_globales.yaml: what several fields share, such as lists, populations and named rules, declared once for every rules file of the dataset. lists no rules: it says No rule changes what it checks: only how the file is written changes. even when a named rule changed, because the rules that change are in other files. Nothing lists the rules that extend a named rule yet: search the datasetDataset One table of a source as Quality Data reads it: a name, its fields and the rules that check them.’s Rules page (▤) for words of what it fails on.
- The global rules are checked alone. A named rule removed while a field still extends it leaves that field’s file unreadable: the Rules page then names the file at the top with … is not a named rule of the table’s global rules. So first change or remove the rules that extend it, one field’s file at a time, then remove the named rule.
A Test of a field’s file uses the global rules on main: test a rule
that extends the named rule right after you deploy, and if it is wrong,
undo the change from the global rules’ history
(See a rule’s history and undo a change).
To move older files to one file per field
Section titled “To move older files to one file per field”A datasetDataset One table of a source as Quality Data reads it: a name, its fields and the rules that check them. whose rulesRule It applies a pattern to a field; the pattern gives it its dimension and a default severity. The rules that count are the ones on main, the approved version. were written before files went by field may have files that hold several fields’ rules. Split by field, beside Global rules in the Explorer, rewrites them on a draftDraft A change to a dataset's rules kept apart from main, usually saved by an author who may edit rules but not approve them, until someone who may approve reviews it and approves or discards it.: each rule in its field’s file, the declarations and the checks several fields share in the global rules, and fields named as their columns.
- Choose Split by field.
- You should see Draft made: review it with ⎇ beside the dataset.
- Review and approve it as in Take a change to main, from the ⎇ beside the dataset.
main does not change until the draft is approved, and the split is
refused unless the very same rules still run. Renaming fields changes the
mappingMapping How a dataset's table is read: which column each field reads and its type, the record key, each field's priority and the roles of some fields., so it needs the right to manage the dataset, which
quality-steward gives.
Findings and refusals you will meet
Section titled “Findings and refusals you will meet”| What you see | What it means and what to do |
|---|---|
… is not a named rule of the table’s global rules (QR012) |
The name after extends is wrong, or the named ruleNamed rule A check written once in a dataset's global rules, with everything but its id and field; a field's rule starts from it with extends. is not deployed yet. |
… is already declared by the table’s global rules: … (QR013) |
A field’s file declares a name the global rulesGlobal rules A dataset's file reglas_globales.yaml: what several fields share, such as lists, populations and named rules, declared once for every rules file of the dataset. declare: take it away from the field’s file, or rename it. |
The global rules have no rules of their own: … (QR014) |
Move the ruleRule It applies a pattern to a field; the pattern gives it its dimension and a default severity. The rules that count are the ones on main, the approved version. to its field’s file. |
… repeats what … already says: it is not needed (QR211), a warning |
The rule repeats a key of its named rule with the same value: remove the key. |
There is no population named … (QR004), or list, table, reference |
Declare it in the global rules and deploy them before the file that uses it. |
| The rules are already split by field. | Nothing to do. |
| … has errors: fix them before splitting | Fix the file named, deploy it, and split again. |
| Split, the rules would not be the same: nothing was split | The split would change what is checked, so it was not made. Move those rules by hand. |
| Two fields would take the name …: …, Which field rule … of … is about cannot be told | Fix as the message says, or move those rules by hand. |
Government Data · Guide v0.8.1