define hierarchical 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 hierarchical ruleset<br/>🟢7"]:::ok
subgraph G_b1["Signature"]
direction LR
v_valuedomain["(valuedomain #91;condition …#93; rule VD)"]:::ok
v_variable["(variable #91;condition …#93; rule V)"]:::ok
v_condition["condition C #91;as alias#93;, …"]:::ok
end
subgraph G_b2["Body"]
direction LR
v_relation["A = #124; #62; #124; #62;= #124; #60; #124; #60;= B ± C …"]:::ok
v_item_condition["B #91;condition#93;"]:::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_condition href "#form-condition"
click v_relation href "#form-relation"
click v_item_condition href "#form-item-condition"
click v_conditioned_rule href "#form-conditioned-rule"
click v_rule_options href "#form-rule-options"
Types
Takes integer, string, boolean, value domain · Gives hierarchical 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 · hierarchical ruleset — 3 operators in 3 blocks 🟢3
Hierarchical aggregation (1) 🟢1
Data validation operators (1) 🟢1
Definitions (VTL-DL) (1) 🟢1
Forms
Signature
(valuedomain [condition …] rule VD) 🟢 · value domain → hierarchical ruleset
Domain bound by rule 🟢 pandas ✅ · DuckDB ✅
- Tests:
a hierarchical ruleset on the value domain
VD_ITEM, whichrule Id_2binds toId_2incheck_hierarchy.- Manual:
define hierarchical ruleset:
vdRulesetSignature ::= valuedomain { condition vdConditioningSignature } rule ruleValueDomain, and in check_hierarchy, on Value Domains “it is mandatory to specify the condition (if any in the ruleset hr) and the rule parameters”.- Expected:
with the defaults
non_nullanddatasetand the outputallofcheck_hierarchy,A = B + Cholds, 10 = 4 + 6:bool_vartrue,imbalance0,ruleid1 and nullerrorcodeanderrorlevel.imbalanceis a Number likeMe_1,ruleidanderrorcodeStrings, anderrorlevelInteger, the manual’s default without errorlevel_vd (#1256).- Finding:
vtlengine’s loader ignores the
variablesanddomainsof its structure schema, so only the call bindsId_2toVD_ITEM.
define hierarchical ruleset HR_1 (valuedomain rule VD_ITEM) is
A = B + C
end hierarchical ruleset;
DS_r := check_hierarchy(DS_1, HR_1 rule Id_2 all);
| Id_1 | Id_2 | Me_1 |
|---|---|---|
| 1 | A | 10 |
| 1 | B | 4 |
| 1 | C | 6 |
| Id_1 | Id_2 | ruleid | bool_var | imbalance | errorcode | errorlevel |
|---|---|---|---|---|---|---|
| 1 | A | 1 | true | 0 |
Files: script.vtl · input/DS_1.csv · input/DS_1.json · expected/DS_r.csv · expected/DS_r.json · value_domains/VD_ITEM.json · example page ↗
(variable [condition …] rule V) 🟢 · nothing → hierarchical ruleset
Unbalanced total 🟢 pandas ✅ · DuckDB ✅
- Tests:
a ruleset on the variable
Id_2, whichcheck_hierarchynames again withrule Id_2.- Manual:
define hierarchical ruleset:
varRulesetSignature ::= variable { condition varConditioningSignature } rule ruleVariable, and in check_hierarchy the components “can be specified all the same if it is desired to show explicitly in the invocation which are the involved Components”.- Expected:
with the defaults
non_nullanddatasetand the outputall,A = B + Cfails, 10 against 4 + 5 = 9:bool_varfalse,imbalance1 andruleid1.errorcodeanderrorlevelare null,imbalanceis a Number likeMe_1,ruleidanderrorcodeStrings, anderrorlevelInteger, the manual’s default without errorlevel_vd (#1256).
define hierarchical ruleset HR_1 (variable rule Id_2) is
A = B + C
end hierarchical ruleset;
DS_r := check_hierarchy(DS_1, HR_1 rule Id_2 all);
| Id_1 | Id_2 | Me_1 |
|---|---|---|
| 1 | A | 10 |
| 1 | B | 4 |
| 1 | C | 5 |
| Id_1 | Id_2 | ruleid | bool_var | imbalance | errorcode | errorlevel |
|---|---|---|---|---|---|---|
| 1 | A | 1 | false | 1 |
Files: script.vtl · input/DS_1.csv · input/DS_1.json · expected/DS_r.csv · expected/DS_r.json · example page ↗
condition C [as alias], … 🟢 · boolean, value domain → hierarchical ruleset
Conditioning domain 🟢 pandas ✅ · DuckDB ✅
- Tests:
a ruleset on
VD_ITEMconditioned by the value domainVD_FLAG,when VD_FLAG = "X" then A = B, bound withcondition Id_1 rule Id_2.- Manual:
define hierarchical ruleset: with no alias “the name of the Value Domain (i.e., condValueDomain) must be used”, and the left condition “defines the pre-condition for evaluating the left member Code Item (i.e., it is evaluated only when the leftCondition is true)”.
- Expected:
one data point, for
X: 5 = 5, sobool_varis true andimbalance0.Yfails the condition and is not compared, so the outputall, “all the Data Points produced by the comparison”, has no data point for it: the reading of the closed issue #1141.- Finding:
vtlengine’s loader ignores the
variablesanddomainsof its structure schema, so only the call binds the components.
define hierarchical ruleset HR_1 (valuedomain condition VD_FLAG rule VD_ITEM) is
when VD_FLAG = "X" then A = B
end hierarchical ruleset;
DS_r := check_hierarchy(DS_1, HR_1 condition Id_1 rule Id_2 all);
| Id_1 | Id_2 | Me_1 |
|---|---|---|
| X | A | 5 |
| X | B | 5 |
| Y | A | 5 |
| Y | B | 4 |
| Id_1 | Id_2 | ruleid | bool_var | imbalance | errorcode | errorlevel |
|---|---|---|---|---|---|---|
| X | A | 1 | true | 0 |
Files: script.vtl · input/DS_1.csv · input/DS_1.json · expected/DS_r.csv · expected/DS_r.json · value_domains/VD_FLAG.json · value_domains/VD_ITEM.json · example page ↗
Aliased conditioning domain 🟢 pandas ✅ · DuckDB ✅
- Tests:
the ruleset conditioned by
VD_FLAGwith the aliasF:when F = "X" then A = B, bound withcondition Id_1 rule Id_2.- Manual:
define hierarchical ruleset: the alias is “an (optional) alias assigned to a Value Domain and valid only within the Ruleset, this can be used for the sake of compactness in writing leftCondition and rightCondition”, and the left condition “defines the pre-condition for evaluating the left member Code Item (i.e., it is evaluated only when the leftCondition is true)”.
- Expected:
one data point, for
X: 5 = 5, sobool_varis true andimbalance0.Yfails the condition and is not compared, so the outputall, “all the Data Points produced by the comparison”, has no data point for it: the reading of the closed issue #1141.- Finding:
vtlengine’s loader ignores the
variablesanddomainsof its structure schema, so only the call binds the components.
define hierarchical ruleset HR_1 (valuedomain condition VD_FLAG as F rule VD_ITEM) is
when F = "X" then A = B
end hierarchical ruleset;
DS_r := check_hierarchy(DS_1, HR_1 condition Id_1 rule Id_2 all);
| Id_1 | Id_2 | Me_1 |
|---|---|---|
| X | A | 5 |
| X | B | 5 |
| Y | A | 5 |
| Y | B | 4 |
| Id_1 | Id_2 | ruleid | bool_var | imbalance | errorcode | errorlevel |
|---|---|---|---|---|---|---|
| X | A | 1 | true | 0 |
Files: script.vtl · input/DS_1.csv · input/DS_1.json · expected/DS_r.csv · expected/DS_r.json · value_domains/VD_FLAG.json · value_domains/VD_ITEM.json · example page ↗
Conditioning variable 🟢 pandas ✅ · DuckDB ✅
- Tests:
a ruleset on
Id_2conditioned by the variableId_1,when Id_1 = "X" then A = B.- Manual:
define hierarchical ruleset:
varConditioningSignature ::= condVariable { as vdAlias } ..., and the left condition “defines the pre-condition for evaluating the left member Code Item (i.e., it is evaluated only when the leftCondition is true)”.- Expected:
one data point, for
X: 5 = 5, sobool_varis true andimbalance0.Yfails the condition and is not compared, so the outputall, “all the Data Points produced by the comparison”, has no data point for it: the reading of the closed issue #1141.
define hierarchical ruleset HR_1 (variable condition Id_1 rule Id_2) is
when Id_1 = "X" then A = B
end hierarchical ruleset;
DS_r := check_hierarchy(DS_1, HR_1 condition Id_1 rule Id_2 all);
| Id_1 | Id_2 | Me_1 |
|---|---|---|
| X | A | 5 |
| X | B | 5 |
| Y | A | 5 |
| Y | B | 4 |
| Id_1 | Id_2 | ruleid | bool_var | imbalance | errorcode | errorlevel |
|---|---|---|---|---|---|---|
| X | A | 1 | true | 0 |
Files: script.vtl · input/DS_1.csv · input/DS_1.json · expected/DS_r.csv · expected/DS_r.json · example page ↗
Aliased conditioning variable 🟢 pandas ✅ · DuckDB ✅
- Tests:
the ruleset conditioned by
Id_1with the aliasC:when C = "X" then A = B.- Manual:
define hierarchical ruleset: the alias is “an (optional) alias assigned to a Variable and valid only within the Ruleset, this can be used for the sake of compactness in writing leftCondition and rightCondition”, and the left condition “defines the pre-condition for evaluating the left member Code Item (i.e., it is evaluated only when the leftCondition is true)”.
- Expected:
one data point, for
X: 5 = 5, sobool_varis true andimbalance0.Yfails the condition and is not compared, so the outputall, “all the Data Points produced by the comparison”, has no data point for it: the reading of the closed issue #1141.
define hierarchical ruleset HR_1 (variable condition Id_1 as C rule Id_2) is
when C = "X" then A = B
end hierarchical ruleset;
DS_r := check_hierarchy(DS_1, HR_1 condition Id_1 rule Id_2 all);
| Id_1 | Id_2 | Me_1 |
|---|---|---|
| X | A | 5 |
| X | B | 5 |
| Y | A | 5 |
| Y | B | 4 |
| Id_1 | Id_2 | ruleid | bool_var | imbalance | errorcode | errorlevel |
|---|---|---|---|---|---|---|
| X | A | 1 | true | 0 |
Files: script.vtl · input/DS_1.csv · input/DS_1.json · expected/DS_r.csv · expected/DS_r.json · example page ↗
Body
A = | > | >= | < | <= B ± C … 🟢 · nothing → hierarchical ruleset
Equality fails on unequal values 🟢 pandas ✅ · DuckDB ✅
- Tests:
the relation
A = B, “coincides”, on two groups ofId_1.- Manual:
define hierarchical ruleset: for validation “all the possible Relations (=, >, >=, <, <=) are evaluated”, and “the result is compared to the first member, according to the specified type of Relation”.
- Expected:
with the defaults
non_nullanddatasetand the outputall, 5 = 5 holds withimbalance0 and 5 = 4 fails withimbalance1, both withruleid1.errorcodeanderrorlevelare null,imbalanceis a Number likeMe_1,ruleidanderrorcodeStrings, anderrorlevelInteger, the manual’s default without errorlevel_vd (#1256).
define hierarchical ruleset HR_1 (variable rule Id_2) is
A = B
end hierarchical ruleset;
DS_r := check_hierarchy(DS_1, HR_1 rule Id_2 all);
| Id_1 | Id_2 | Me_1 |
|---|---|---|
| 1 | A | 5 |
| 1 | B | 5 |
| 2 | A | 5 |
| 2 | B | 4 |
| Id_1 | Id_2 | ruleid | bool_var | imbalance | errorcode | errorlevel |
|---|---|---|---|---|---|---|
| 1 | A | 1 | true | 0 | ||
| 2 | A | 1 | false | 1 |
Files: script.vtl · input/DS_1.csv · input/DS_1.json · expected/DS_r.csv · expected/DS_r.json · example page ↗
Greater than fails on equal values 🟢 pandas ✅ · DuckDB ✅
- Tests:
the relation
A > B, “is implied by”, on two groups ofId_1.- Manual:
define hierarchical ruleset: for validation “all the possible Relations (=, >, >=, <, <=) are evaluated”, and “the result is compared to the first member, according to the specified type of Relation”.
- Expected:
with the defaults
non_nullanddatasetand the outputall, 5 > 4 holds withimbalance1 and 5 > 5 fails withimbalance0, both withruleid1.errorcodeanderrorlevelare null,imbalanceis a Number likeMe_1,ruleidanderrorcodeStrings, anderrorlevelInteger, the manual’s default without errorlevel_vd (#1256).
define hierarchical ruleset HR_1 (variable rule Id_2) is
A > B
end hierarchical ruleset;
DS_r := check_hierarchy(DS_1, HR_1 rule Id_2 all);
| Id_1 | Id_2 | Me_1 |
|---|---|---|
| 1 | A | 5 |
| 1 | B | 4 |
| 2 | A | 5 |
| 2 | B | 5 |
| Id_1 | Id_2 | ruleid | bool_var | imbalance | errorcode | errorlevel |
|---|---|---|---|---|---|---|
| 1 | A | 1 | true | 1 | ||
| 2 | A | 1 | false | 0 |
Files: script.vtl · input/DS_1.csv · input/DS_1.json · expected/DS_r.csv · expected/DS_r.json · example page ↗
Greater or equal holds on equal values 🟢 pandas ✅ · DuckDB ✅
- Tests:
the relation
A >= B, “is implied by or coincides”, on two groups ofId_1.- Manual:
define hierarchical ruleset: for validation “all the possible Relations (=, >, >=, <, <=) are evaluated”, and “the result is compared to the first member, according to the specified type of Relation”.
- Expected:
with the defaults
non_nullanddatasetand the outputall, 5 >= 5 holds withimbalance0 and 4 >= 5 fails withimbalance-1, both withruleid1.errorcodeanderrorlevelare null,imbalanceis a Number likeMe_1,ruleidanderrorcodeStrings, anderrorlevelInteger, the manual’s default without errorlevel_vd (#1256).
define hierarchical ruleset HR_1 (variable rule Id_2) is
A >= B
end hierarchical ruleset;
DS_r := check_hierarchy(DS_1, HR_1 rule Id_2 all);
| Id_1 | Id_2 | Me_1 |
|---|---|---|
| 1 | A | 5 |
| 1 | B | 5 |
| 2 | A | 4 |
| 2 | B | 5 |
| Id_1 | Id_2 | ruleid | bool_var | imbalance | errorcode | errorlevel |
|---|---|---|---|---|---|---|
| 1 | A | 1 | true | 0 | ||
| 2 | A | 1 | false | -1 |
Files: script.vtl · input/DS_1.csv · input/DS_1.json · expected/DS_r.csv · expected/DS_r.json · example page ↗
Less than fails on equal values 🟢 pandas ✅ · DuckDB ✅
- Tests:
the relation
A < B, “implies”, on two groups ofId_1.- Manual:
define hierarchical ruleset: for validation “all the possible Relations (=, >, >=, <, <=) are evaluated”, and “the result is compared to the first member, according to the specified type of Relation”.
- Expected:
with the defaults
non_nullanddatasetand the outputall, 4 < 5 holds withimbalance-1 and 5 < 5 fails withimbalance0, both withruleid1.errorcodeanderrorlevelare null,imbalanceis a Number likeMe_1,ruleidanderrorcodeStrings, anderrorlevelInteger, the manual’s default without errorlevel_vd (#1256).
define hierarchical ruleset HR_1 (variable rule Id_2) is
A < B
end hierarchical ruleset;
DS_r := check_hierarchy(DS_1, HR_1 rule Id_2 all);
| Id_1 | Id_2 | Me_1 |
|---|---|---|
| 1 | A | 4 |
| 1 | B | 5 |
| 2 | A | 5 |
| 2 | B | 5 |
| Id_1 | Id_2 | ruleid | bool_var | imbalance | errorcode | errorlevel |
|---|---|---|---|---|---|---|
| 1 | A | 1 | true | -1 | ||
| 2 | A | 1 | false | 0 |
Files: script.vtl · input/DS_1.csv · input/DS_1.json · expected/DS_r.csv · expected/DS_r.json · example page ↗
Less or equal holds on equal values 🟢 pandas ✅ · DuckDB ✅
- Tests:
the relation
A <= B, “implies or coincides”, on two groups ofId_1.- Manual:
define hierarchical ruleset: for validation “all the possible Relations (=, >, >=, <, <=) are evaluated”, and “the result is compared to the first member, according to the specified type of Relation”.
- Expected:
with the defaults
non_nullanddatasetand the outputall, 5 <= 5 holds withimbalance0 and 5 <= 4 fails withimbalance1, both withruleid1.errorcodeanderrorlevelare null,imbalanceis a Number likeMe_1,ruleidanderrorcodeStrings, anderrorlevelInteger, the manual’s default without errorlevel_vd (#1256).
define hierarchical ruleset HR_1 (variable rule Id_2) is
A <= B
end hierarchical ruleset;
DS_r := check_hierarchy(DS_1, HR_1 rule Id_2 all);
| Id_1 | Id_2 | Me_1 |
|---|---|---|
| 1 | A | 5 |
| 1 | B | 5 |
| 2 | A | 5 |
| 2 | B | 4 |
| Id_1 | Id_2 | ruleid | bool_var | imbalance | errorcode | errorlevel |
|---|---|---|---|---|---|---|
| 1 | A | 1 | true | 0 | ||
| 2 | A | 1 | false | 1 |
Files: script.vtl · input/DS_1.csv · input/DS_1.json · expected/DS_r.csv · expected/DS_r.json · example page ↗
Added and subtracted items 🟢 pandas ✅ · DuckDB ✅
- Tests:
A = B + C - D, code items combined with+and-.- Manual:
define hierarchical ruleset: the relations “allow to obtain the measure values of the compound Code Items … by summing or subtracting the measure values relevant to the component Code Items”.
- Expected:
6 against 5 + 3 - 2 = 6:
bool_vartrue,imbalance0 andruleid1.errorcodeanderrorlevelare null,imbalanceis a Number likeMe_1,ruleidanderrorcodeStrings, anderrorlevelInteger, the manual’s default without errorlevel_vd (#1256).
define hierarchical ruleset HR_1 (variable rule Id_2) is
A = B + C - D
end hierarchical ruleset;
DS_r := check_hierarchy(DS_1, HR_1 rule Id_2 all);
| Id_1 | Id_2 | Me_1 |
|---|---|---|
| 1 | A | 6 |
| 1 | B | 5 |
| 1 | C | 3 |
| 1 | D | 2 |
| Id_1 | Id_2 | ruleid | bool_var | imbalance | errorcode | errorlevel |
|---|---|---|---|---|---|---|
| 1 | A | 1 | true | 0 |
Files: script.vtl · input/DS_1.csv · input/DS_1.json · expected/DS_r.csv · expected/DS_r.json · example page ↗
Sign of the first item 🟢 pandas ✅ · DuckDB ✅
- Tests:
A = - B + C: the first right code item has a sign of its own.- Manual:
define hierarchical ruleset:
codeItemRelation ::= ... leftCodeItem { = | > | < | >= | <= } { + | - } rightCodeItem ..., and the relations “allow to obtain the measure values of the compound Code Items … by summing or subtracting the measure values relevant to the component Code Items”.- Expected:
2 against
- 3 + 5= 2:bool_vartrue andimbalance0. Read without the sign, the right member would be 8, false withimbalance-6.
define hierarchical ruleset HR_1 (variable rule Id_2) is
A = - B + C
end hierarchical ruleset;
DS_r := check_hierarchy(DS_1, HR_1 rule Id_2 all);
| Id_1 | Id_2 | Me_1 |
|---|---|---|
| 1 | A | 2 |
| 1 | B | 3 |
| 1 | C | 5 |
| Id_1 | Id_2 | ruleid | bool_var | imbalance | errorcode | errorlevel |
|---|---|---|---|---|---|---|
| 1 | A | 1 | true | 0 |
Files: script.vtl · input/DS_1.csv · input/DS_1.json · expected/DS_r.csv · expected/DS_r.json · example page ↗
B [condition] 🟢 · boolean → hierarchical ruleset
Item left out by condition 🟢 pandas ✅ · DuckDB ✅
- Tests:
A = B + C [Id_1 = "Y"]on the groupX: the right condition leavesCout.- Manual:
define hierarchical ruleset: “the right member Code Item is taken into account only when the relevant rightCondition is true”.
- Expected:
AagainstBalone, 5 = 5:bool_vartrue andimbalance0. CountingCwould give false withimbalance5 - 8 = -3.
define hierarchical ruleset HR_1 (variable condition Id_1 rule Id_2) is
A = B + C [Id_1 = "Y"]
end hierarchical ruleset;
DS_r := check_hierarchy(DS_1, HR_1 condition Id_1 rule Id_2 all);
| Id_1 | Id_2 | Me_1 |
|---|---|---|
| X | A | 5 |
| X | B | 5 |
| X | C | 3 |
| Id_1 | Id_2 | ruleid | bool_var | imbalance | errorcode | errorlevel |
|---|---|---|---|---|---|---|
| X | A | 1 | true | 0 |
Files: script.vtl · input/DS_1.csv · input/DS_1.json · expected/DS_r.csv · expected/DS_r.json · example page ↗
when … then … 🟢 · boolean → hierarchical ruleset
False condition not compared 🟢 pandas ✅ · DuckDB ✅
- Tests:
when Id_1 = "X" then A = B, where both groups breakA = Bbut onlyXmeets the condition.- Manual:
define hierarchical ruleset: “The Antecedent Condition is evaluated and, if true, the operations specified in the right member of the Relation are performed and the result is compared to the first member”.
- Expected:
one data point, for
X: 5 = 4 fails, withimbalance1.Yis not compared, so the outputall, “all the Data Points produced by the comparison”, has no data point for it: the reading of the closed issue #1141.
define hierarchical ruleset HR_1 (variable condition Id_1 rule Id_2) is
when Id_1 = "X" then A = B
end hierarchical ruleset;
DS_r := check_hierarchy(DS_1, HR_1 condition Id_1 rule Id_2 all);
| Id_1 | Id_2 | Me_1 |
|---|---|---|
| X | A | 5 |
| X | B | 4 |
| Y | A | 5 |
| Y | B | 4 |
| Id_1 | Id_2 | ruleid | bool_var | imbalance | errorcode | errorlevel |
|---|---|---|---|---|---|---|
| X | A | 1 | false | 1 |
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 → hierarchical ruleset
Two named rules 🟢 pandas ✅ · DuckDB ✅
- Tests:
two named rules,
R_1 : A = BandR_2 : C > B.- Manual:
define hierarchical ruleset: “If the Ruleset is used for validation then the ruleName identifies the validation results of the various Rules of the Ruleset”, and “in the validation the various Rules can be evaluated independently”.
- Expected:
one data point per rule, with its left code item in
Id_2:R_1fails, 5 against 4 withimbalance1, andR_2holds, 6 against 4 withimbalance2.errorcodeanderrorlevelare null,imbalanceis a Number likeMe_1,ruleidanderrorcodeStrings, anderrorlevelInteger, the manual’s default without errorlevel_vd (#1256).
define hierarchical ruleset HR_1 (variable rule Id_2) is
R_1 : A = B;
R_2 : C > B
end hierarchical ruleset;
DS_r := check_hierarchy(DS_1, HR_1 rule Id_2 all);
| Id_1 | Id_2 | Me_1 |
|---|---|---|
| 1 | A | 5 |
| 1 | B | 4 |
| 1 | C | 6 |
| Id_1 | Id_2 | ruleid | bool_var | imbalance | errorcode | errorlevel |
|---|---|---|---|---|---|---|
| 1 | A | R_1 | false | 1 | ||
| 1 | C | R_2 | true | 2 |
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,
A = BandC > B.- Manual:
define hierarchical 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 fails, 5 against 4 withimbalance1, and rule 2 holds, 6 against 4 withimbalance2.errorcodeanderrorlevelare null,imbalanceis a Number likeMe_1,ruleidanderrorcodeStrings, anderrorlevelInteger, the manual’s default without errorlevel_vd (#1256).
define hierarchical ruleset HR_1 (variable rule Id_2) is
A = B;
C > B
end hierarchical ruleset;
DS_r := check_hierarchy(DS_1, HR_1 rule Id_2 all);
| Id_1 | Id_2 | Me_1 |
|---|---|---|
| 1 | A | 5 |
| 1 | B | 4 |
| 1 | C | 6 |
| Id_1 | Id_2 | ruleid | bool_var | imbalance | errorcode | errorlevel |
|---|---|---|---|---|---|---|
| 1 | A | 1 | false | 1 | ||
| 1 | C | 2 | true | 2 |
Files: script.vtl · input/DS_1.csv · input/DS_1.json · expected/DS_r.csv · expected/DS_r.json · example page ↗
Errorcode on the failed rule 🟢 pandas ✅ · DuckDB ✅
- Tests:
A = B errorcode "E_AB"on two groups ofId_1.- Manual:
define hierarchical 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_hierarchy “if the Measure bool_var is true or null then errorcode is null”.
- Expected:
5 = 5 holds, and 5 = 4 fails with
imbalance1 anderrorcodeE_AB, both withruleid1.imbalanceis a Number likeMe_1,ruleidanderrorcodeStrings, and the nullerrorlevelInteger, the manual’s default without errorlevel_vd (#1256).
define hierarchical ruleset HR_1 (variable rule Id_2) is
A = B errorcode "E_AB"
end hierarchical ruleset;
DS_r := check_hierarchy(DS_1, HR_1 rule Id_2 all);
| Id_1 | Id_2 | Me_1 |
|---|---|---|
| 1 | A | 5 |
| 1 | B | 5 |
| 2 | A | 5 |
| 2 | B | 4 |
| Id_1 | Id_2 | ruleid | bool_var | imbalance | errorcode | errorlevel |
|---|---|---|---|---|---|---|
| 1 | A | 1 | true | 0 | ||
| 2 | A | 1 | false | 1 | E_AB |
Files: script.vtl · input/DS_1.csv · input/DS_1.json · expected/DS_r.csv · expected/DS_r.json · example page ↗
Errorlevel on the failed rule 🟢 pandas ✅ · DuckDB ✅
- Tests:
A = B errorlevel 3on two groups ofId_1.- Manual:
define hierarchical 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:
5 = 5 holds, and 5 = 4 fails with
errorlevel3, typed Integer: no errorlevel_vd is defined here, and the manual’s examples of check, check_datapoint and check_hierarchy type it Integer.imbalanceis a Number likeMe_1, andruleid1 and the nullerrorcodeStrings.
define hierarchical ruleset HR_1 (variable rule Id_2) is
A = B errorlevel 3
end hierarchical ruleset;
DS_r := check_hierarchy(DS_1, HR_1 rule Id_2 all);
| Id_1 | Id_2 | Me_1 |
|---|---|---|
| 1 | A | 5 |
| 1 | B | 5 |
| 2 | A | 5 |
| 2 | B | 4 |
| Id_1 | Id_2 | ruleid | bool_var | imbalance | errorcode | errorlevel |
|---|---|---|---|---|---|---|
| 1 | A | 1 | true | 0 | ||
| 2 | A | 1 | false | 1 | 3 |
Files: script.vtl · input/DS_1.csv · input/DS_1.json · expected/DS_r.csv · expected/DS_r.json · example page ↗