define datapoint ruleset
---
config:
flowchart:
useMaxWidth: false
---
flowchart TB
classDef ok fill:#d4edda,stroke:#28a745,color:#000
classDef partial fill:#fff3cd,stroke:#ffc107,color:#000
classDef refused fill:#d4edda,stroke:#28a745,stroke-width:3px,stroke-dasharray: 2 2,color:#000
classDef missing fill:#f8d7da,stroke:#dc3545,color:#000
classDef diverge fill:#cce5ff,stroke:#007bff,color:#000
classDef block fill:#2b3a4a,stroke:#2b3a4a,color:#fff,font-weight:bold
classDef ext fill:#fff,stroke:#666,color:#000,stroke-dasharray: 5 5
O["define datapoint ruleset<br/>🟢4 🛡️1"]:::ok
subgraph G_b1["Signature"]
direction LR
v_valuedomain["(valuedomain VD #91;as alias#93;, …)"]:::refused
v_variable["(variable V #91;as alias#93;, …)"]:::ok
end
subgraph G_b2["Body"]
direction LR
v_unconditioned_rule["consequent"]:::ok
v_conditioned_rule["when … then …"]:::ok
v_rule_options["#91;name :#93; … #91;errorcode …#93; #91;errorlevel …#93;"]:::ok
end
O --- G_b1
O --- G_b2
style G_b1 fill:#f8f9fa,stroke:#868e96,stroke-width:1px
style G_b2 fill:#f8f9fa,stroke:#868e96,stroke-width:1px
click v_valuedomain href "#form-valuedomain"
click v_variable href "#form-variable"
click v_unconditioned_rule href "#form-unconditioned-rule"
click v_conditioned_rule href "#form-conditioned-rule"
click v_rule_options href "#form-rule-options"
Types
Takes integer, string, boolean, value domain · Gives datapoint ruleset
Comes from · integer, string, boolean — 44 operators in 8 blocks 🟢44
General purpose operators (2) 🟢2
String operators (10) 🟢10
Numeric operators (4) 🟢4
Comparison operators (12) 🟢12
Boolean operators (4) 🟢4
Time operators (7) 🟢7
Aggregate and Analytic operators (2) 🟢2
Data validation operators (3) 🟢3
Comes from · operators that return any type (their input's) — 37 operators in 8 blocks 🟢37
General purpose operators (5) 🟢5
Join operators (4) 🟢4
Time operators (3) 🟢3
Set operators (4) 🟢4
Hierarchical aggregation (1) 🟢1
Aggregate and Analytic operators (8) 🟢8
Conditional operators (3) 🟢3
Comes from · value domain: none
Goes to · datapoint ruleset — 2 operators in 2 blocks 🟢2
Data validation operators (1) 🟢1
Definitions (VTL-DL) (1) 🟢1
Forms
Signature
(valuedomain VD [as alias], …) 🛡️ · boolean, value domain → datapoint ruleset
Domains bound to components 🛡️ pandas 🛡 1-2-8 · DuckDB 🛡 1-2-8
SemanticError 1-2-8: Missing value domain 'VD_AMOUNT' definition, please provide an structure. Please check transformation with output Dataset DS_r
- Tests:
a ruleset on the value domains
VD_FLOWandVD_AMOUNT, bound toId_2andMe_1withcomponentsincheck_datapoint.- Manual:
define datapoint ruleset: “If an alias is not specified then the name of the Value Domain … is used in the body of the rules”, and in check_datapoint, “If dpr is defined on Value Domains then it is mandatory to specify listComp”.
- Expected:
ruleid1 andbool_vartrue, false and true for (CREDIT, 10), (CREDIT, -5) and (DEBIT, -2), the last as its antecedent is false.errorcodeanderrorlevelare null,ruleidanderrorcodeStrings, anderrorlevelInteger, the manual’s default without errorlevel_vd (#1256).- Finding:
VD_AMOUNT, the integer amounts, has no file, as a vtlengine value-domain file lists values only, and the loader ignores thevariablesanddomainsof its structure schema.
define datapoint ruleset DPR_1 (valuedomain VD_FLOW, VD_AMOUNT) is
when VD_FLOW = "CREDIT" then VD_AMOUNT >= 0
end datapoint ruleset;
DS_r := check_datapoint(DS_1, DPR_1 components Id_2, Me_1 all);
| Id_1 | Id_2 | Me_1 |
|---|---|---|
| 1 | CREDIT | 10 |
| 2 | CREDIT | -5 |
| 3 | DEBIT | -2 |
| Id_1 | Id_2 | ruleid | bool_var | errorcode | errorlevel |
|---|---|---|---|---|---|
| 1 | CREDIT | 1 | true | ||
| 2 | CREDIT | 1 | false | ||
| 3 | DEBIT | 1 | true |
Files: script.vtl · input/DS_1.csv · input/DS_1.json · expected/DS_r.csv · expected/DS_r.json · value_domains/VD_FLOW.json · example page ↗
Domain aliases in the rule 🛡️ pandas 🛡 1-2-8 · DuckDB 🛡 1-2-8
SemanticError 1-2-8: Missing value domain 'VD_AMOUNT' definition, please provide an structure. Please check transformation with output Dataset DS_r
- Tests:
the value domains with the aliases
FandA, which the rule uses, bound toId_2andMe_1withcomponents.- Manual:
define datapoint ruleset: the alias is “an (optional) alias assigned to a Value Domain and valid only within the Ruleset”, and in check_datapoint, “If dpr is defined on Value Domains then it is mandatory to specify listComp”.
- Expected:
ruleid1 andbool_vartrue, false and true for (CREDIT, 10), (CREDIT, -5) and (DEBIT, -2), the last as its antecedent is false.errorcodeanderrorlevelare null,ruleidanderrorcodeStrings, anderrorlevelInteger, the manual’s default without errorlevel_vd (#1256).- Finding:
VD_AMOUNT, the integer amounts, has no file, as a vtlengine value-domain file lists values only, and the loader ignores thevariablesanddomainsof its structure schema.
define datapoint ruleset DPR_1 (valuedomain VD_FLOW as F, VD_AMOUNT as A) is
when F = "CREDIT" then A >= 0
end datapoint ruleset;
DS_r := check_datapoint(DS_1, DPR_1 components Id_2, Me_1 all);
| Id_1 | Id_2 | Me_1 |
|---|---|---|
| 1 | CREDIT | 10 |
| 2 | CREDIT | -5 |
| 3 | DEBIT | -2 |
| Id_1 | Id_2 | ruleid | bool_var | errorcode | errorlevel |
|---|---|---|---|---|---|
| 1 | CREDIT | 1 | true | ||
| 2 | CREDIT | 1 | false | ||
| 3 | DEBIT | 1 | true |
Files: script.vtl · input/DS_1.csv · input/DS_1.json · expected/DS_r.csv · expected/DS_r.json · value_domains/VD_FLOW.json · example page ↗
(variable V [as alias], …) 🟢 · boolean → datapoint ruleset
Variables of the dataset 🟢 pandas ✅ · DuckDB ✅
- Tests:
a datapoint ruleset on the variables
Id_2andMe_1, components ofDS_1, socheck_datapointneeds nocomponents.- Manual:
define datapoint ruleset: “If variable is specified then the Ruleset is applicable to Data Sets having the specified Variables as Components”.
- Expected:
ruleid1, the unnamed rule’s order number, andbool_vartrue for (CREDIT, 10), false for (CREDIT, -5) and true for (DEBIT, -2), whose antecedent is false.errorcodeanderrorlevelare null,ruleidanderrorcodeStrings as in the manual’s examples, anderrorlevelInteger, the manual’s default without errorlevel_vd (#1256).
define datapoint ruleset DPR_1 (variable Id_2, Me_1) is
when Id_2 = "CREDIT" then Me_1 >= 0
end datapoint ruleset;
DS_r := check_datapoint(DS_1, DPR_1 all);
| Id_1 | Id_2 | Me_1 |
|---|---|---|
| 1 | CREDIT | 10 |
| 2 | CREDIT | -5 |
| 3 | DEBIT | -2 |
| Id_1 | Id_2 | ruleid | bool_var | errorcode | errorlevel |
|---|---|---|---|---|---|
| 1 | CREDIT | 1 | true | ||
| 2 | CREDIT | 1 | false | ||
| 3 | DEBIT | 1 | true |
Files: script.vtl · input/DS_1.csv · input/DS_1.json · expected/DS_r.csv · expected/DS_r.json · example page ↗
Variable aliases in the rule 🟢 pandas ✅ · DuckDB ✅
- Tests:
the variables with the aliases
FandA, which the rule uses;check_datapointneeds nocomponents.- Manual:
define datapoint ruleset: the alias is “an (optional) alias assigned to a Variable and valid only within the Ruleset”.
- Expected:
ruleid1, the unnamed rule’s order number, andbool_vartrue for (CREDIT, 10), false for (CREDIT, -5) and true for (DEBIT, -2), whose antecedent is false.errorcodeanderrorlevelare null,ruleidanderrorcodeStrings as in the manual’s examples, anderrorlevelInteger, the manual’s default without errorlevel_vd (#1256).
define datapoint ruleset DPR_1 (variable Id_2 as F, Me_1 as A) is
when F = "CREDIT" then A >= 0
end datapoint ruleset;
DS_r := check_datapoint(DS_1, DPR_1 all);
| Id_1 | Id_2 | Me_1 |
|---|---|---|
| 1 | CREDIT | 10 |
| 2 | CREDIT | -5 |
| 3 | DEBIT | -2 |
| Id_1 | Id_2 | ruleid | bool_var | errorcode | errorlevel |
|---|---|---|---|---|---|
| 1 | CREDIT | 1 | true | ||
| 2 | CREDIT | 1 | false | ||
| 3 | DEBIT | 1 | true |
Files: script.vtl · input/DS_1.csv · input/DS_1.json · expected/DS_r.csv · expected/DS_r.json · example page ↗
Body
consequent 🟢 · boolean → datapoint ruleset
Consequent alone 🟢 pandas ✅ · DuckDB ✅
- Tests:
a rule with no antecedent,
Me_1 >= 0.- Manual:
define datapoint ruleset: “In case the antecedentCondition is absent then it is assumed to be always true, therefore the consequentCondition is expected to evaluate to true for all the Data Points”.
- Expected:
ruleid1, the order number of the unnamed rule, andbool_vartrue for 10 and false for -5.errorcodeanderrorlevelare null,ruleidanderrorcodeStrings as in the manual’s examples, anderrorlevelInteger, the manual’s default without errorlevel_vd (#1256).
define datapoint ruleset DPR_1 (variable Me_1) is
Me_1 >= 0
end datapoint ruleset;
DS_r := check_datapoint(DS_1, DPR_1 all);
| Id_1 | Id_2 | Me_1 |
|---|---|---|
| 1 | CREDIT | 10 |
| 2 | DEBIT | -5 |
| Id_1 | Id_2 | ruleid | bool_var | errorcode | errorlevel |
|---|---|---|---|---|---|
| 1 | CREDIT | 1 | true | ||
| 2 | DEBIT | 1 | false |
Files: script.vtl · input/DS_1.csv · input/DS_1.json · expected/DS_r.csv · expected/DS_r.json · example page ↗
when … then … 🟢 · boolean → datapoint ruleset
Three cases of the implication 🟢 pandas ✅ · DuckDB ✅
- Tests:
when Id_2 = "CREDIT" then Me_1 >= 0on three data points, one for each case of the implication.- Manual:
define datapoint ruleset: “if the antecedentCondition evaluates to false, the consequentCondition does not applies and is not evaluated at all, and the result is considered as valid (true)”.
- Expected:
ruleid1, the unnamed rule’s order number, andbool_vartrue for (CREDIT, 10), false for (CREDIT, -5) and true for (DEBIT, -2), whose antecedent is false.errorcodeanderrorlevelare null,ruleidanderrorcodeStrings as in the manual’s examples, anderrorlevelInteger, the manual’s default without errorlevel_vd (#1256).
define datapoint ruleset DPR_1 (variable Id_2, Me_1) is
when Id_2 = "CREDIT" then Me_1 >= 0
end datapoint ruleset;
DS_r := check_datapoint(DS_1, DPR_1 all);
| Id_1 | Id_2 | Me_1 |
|---|---|---|
| 1 | CREDIT | 10 |
| 2 | CREDIT | -5 |
| 3 | DEBIT | -2 |
| Id_1 | Id_2 | ruleid | bool_var | errorcode | errorlevel |
|---|---|---|---|---|---|
| 1 | CREDIT | 1 | true | ||
| 2 | CREDIT | 1 | false | ||
| 3 | DEBIT | 1 | true |
Files: script.vtl · input/DS_1.csv · input/DS_1.json · expected/DS_r.csv · expected/DS_r.json · example page ↗
[name :] … [errorcode …] [errorlevel …] 🟢 · integer, string, boolean → datapoint ruleset
Two named rules 🟢 pandas ✅ · DuckDB ✅
- Tests:
two named rules,
R_CREDITandR_DEBIT, on two data points.- Manual:
define datapoint ruleset: “If the Ruleset is used for validation then the ruleName identifies the validation results of the various Rules of the Ruleset”, and “Either ruleName is specified for all the Rules of the Ruleset or for none”.
- Expected:
one result per data point and rule, named in
ruleid:R_CREDITis true for both, andR_DEBITtrue for (CREDIT, 10), whose antecedent is false, and false for (DEBIT, 5).errorcodeanderrorlevelare null,ruleidanderrorcodeStrings as in the manual’s examples, anderrorlevelInteger, the manual’s default without errorlevel_vd (#1256).
define datapoint ruleset DPR_1 (variable Id_2, Me_1) is
R_CREDIT : when Id_2 = "CREDIT" then Me_1 >= 0;
R_DEBIT : when Id_2 = "DEBIT" then Me_1 <= 0
end datapoint ruleset;
DS_r := check_datapoint(DS_1, DPR_1 all);
| Id_1 | Id_2 | Me_1 |
|---|---|---|
| 1 | CREDIT | 10 |
| 2 | DEBIT | 5 |
| Id_1 | Id_2 | ruleid | bool_var | errorcode | errorlevel |
|---|---|---|---|---|---|
| 1 | CREDIT | R_CREDIT | true | ||
| 2 | DEBIT | R_CREDIT | true | ||
| 1 | CREDIT | R_DEBIT | true | ||
| 2 | DEBIT | R_DEBIT | false |
Files: script.vtl · input/DS_1.csv · input/DS_1.json · expected/DS_r.csv · expected/DS_r.json · example page ↗
Rules named by their order 🟢 pandas ✅ · DuckDB ✅
- Tests:
two unnamed rules on two data points.
- Manual:
define datapoint ruleset: “The ruleName is optional and, if not specified, is assumed to be the progressive order number of the Rule in the Ruleset”.
- Expected:
ruleid1 and 2: rule 1 is true for both data points, and rule 2 true for (CREDIT, 10), whose antecedent is false, and false for (DEBIT, 5).errorcodeanderrorlevelare null,ruleidanderrorcodeStrings as in the manual’s examples, anderrorlevelInteger, the manual’s default without errorlevel_vd (#1256).
define datapoint ruleset DPR_1 (variable Id_2, Me_1) is
when Id_2 = "CREDIT" then Me_1 >= 0;
when Id_2 = "DEBIT" then Me_1 <= 0
end datapoint ruleset;
DS_r := check_datapoint(DS_1, DPR_1 all);
| Id_1 | Id_2 | Me_1 |
|---|---|---|
| 1 | CREDIT | 10 |
| 2 | DEBIT | 5 |
| Id_1 | Id_2 | ruleid | bool_var | errorcode | errorlevel |
|---|---|---|---|---|---|
| 1 | CREDIT | 1 | true | ||
| 2 | DEBIT | 1 | true | ||
| 1 | CREDIT | 2 | true | ||
| 2 | DEBIT | 2 | false |
Files: script.vtl · input/DS_1.csv · input/DS_1.json · expected/DS_r.csv · expected/DS_r.json · example page ↗
Errorcode on the invalid point 🟢 pandas ✅ · DuckDB ✅
- Tests:
when Id_2 = "CREDIT" then Me_1 >= 0 errorcode "NEG_CREDIT".- Manual:
define datapoint ruleset: the error code is “a literal denoting the error code associated to the rule, to be assigned to the possible non-valid results”, and in check_datapoint “if the Measure bool_var is true or null then errorcode is null”.
- Expected:
ruleid1 andbool_vartrue, false and true for (CREDIT, 10), (CREDIT, -5) and (DEBIT, -2), witherrorcodeNEG_CREDITonly on the false one.ruleidanderrorcodeare Strings as in the manual’s examples, and the nullerrorlevelInteger, the manual’s default without errorlevel_vd (#1256).
define datapoint ruleset DPR_1 (variable Id_2, Me_1) is
when Id_2 = "CREDIT" then Me_1 >= 0 errorcode "NEG_CREDIT"
end datapoint ruleset;
DS_r := check_datapoint(DS_1, DPR_1 all);
| Id_1 | Id_2 | Me_1 |
|---|---|---|
| 1 | CREDIT | 10 |
| 2 | CREDIT | -5 |
| 3 | DEBIT | -2 |
| Id_1 | Id_2 | ruleid | bool_var | errorcode | errorlevel |
|---|---|---|---|---|---|
| 1 | CREDIT | 1 | true | ||
| 2 | CREDIT | 1 | false | NEG_CREDIT | |
| 3 | DEBIT | 1 | true |
Files: script.vtl · input/DS_1.csv · input/DS_1.json · expected/DS_r.csv · expected/DS_r.json · example page ↗
Errorlevel on the invalid point 🟢 pandas ✅ · DuckDB ✅
- Tests:
when Id_2 = "CREDIT" then Me_1 >= 0 errorlevel 5.- Manual:
define datapoint ruleset: the error level is “a literal denoting the error level (severity) associated to the rule, to be assigned to the possible non-valid results”, and in check it “must be a valid value of the errorlevel_vd Value Domain (or integer if the errorcode_vd Value Domain is not found)”.
- Expected:
errorlevel5 only on the false data point, (CREDIT, -5), typed Integer: no errorlevel_vd is defined here, and the manual’s examples of check, check_datapoint and check_hierarchy type it Integer.ruleid1 and the nullerrorcodeare Strings.
define datapoint ruleset DPR_1 (variable Id_2, Me_1) is
when Id_2 = "CREDIT" then Me_1 >= 0 errorlevel 5
end datapoint ruleset;
DS_r := check_datapoint(DS_1, DPR_1 all);
| Id_1 | Id_2 | Me_1 |
|---|---|---|
| 1 | CREDIT | 10 |
| 2 | CREDIT | -5 |
| 3 | DEBIT | -2 |
| Id_1 | Id_2 | ruleid | bool_var | errorcode | errorlevel |
|---|---|---|---|---|---|
| 1 | CREDIT | 1 | true | ||
| 2 | CREDIT | 1 | false | 5 | |
| 3 | DEBIT | 1 | true |
Files: script.vtl · input/DS_1.csv · input/DS_1.json · expected/DS_r.csv · expected/DS_r.json · example page ↗