define hierarchical ruleset

🟢 7 of 7 forms all ok · VTL 2.2 Reference Manual ↗ · vtlengine 1.10.0rc3 (9e1c81a6) · pandas 2.3.3 · DuckDB 1.5.5
🟢 all ok🟡 partially implemented🛡️ refused with an error🔴 not implemented or crash🔵 engines differ ✅ match · ❌ wrong result · 🛡 guarded error (code) · 💥 crash · 📌 team decision
        ---
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
Clause operators (9) 🟢9

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, which rule Id_2 binds to Id_2 in check_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_null and dataset and the output all of check_hierarchy, A = B + C holds, 10 = 4 + 6: bool_var true, imbalance 0, ruleid 1 and null errorcode and errorlevel. imbalance is a Number like Me_1, ruleid and errorcode Strings, and errorlevel Integer, the manual’s default without errorlevel_vd (#1256).

Finding:

vtlengine’s loader ignores the variables and domains of its structure schema, so only the call binds Id_2 to VD_ITEM.

script.vtl
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);
Input DS_1
Id_1Id_2Me_1
1A10
1B4
1C6
Expected DS_r
Id_1Id_2ruleidbool_varimbalanceerrorcodeerrorlevel
1A1true0

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, which check_hierarchy names again with rule 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_null and dataset and the output all, A = B + C fails, 10 against 4 + 5 = 9: bool_var false, imbalance 1 and ruleid 1. errorcode and errorlevel are null, imbalance is a Number like Me_1, ruleid and errorcode Strings, and errorlevel Integer, the manual’s default without errorlevel_vd (#1256).

script.vtl
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);
Input DS_1
Id_1Id_2Me_1
1A10
1B4
1C5
Expected DS_r
Id_1Id_2ruleidbool_varimbalanceerrorcodeerrorlevel
1A1false1

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_ITEM conditioned by the value domain VD_FLAG, when VD_FLAG = "X" then A = B, bound with condition 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, so bool_var is true and imbalance 0. Y fails the condition and is not compared, so the output all, “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 variables and domains of its structure schema, so only the call binds the components.

script.vtl
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);
Input DS_1
Id_1Id_2Me_1
XA5
XB5
YA5
YB4
Expected DS_r
Id_1Id_2ruleidbool_varimbalanceerrorcodeerrorlevel
XA1true0

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_FLAG with the alias F: when F = "X" then A = B, bound with condition 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, so bool_var is true and imbalance 0. Y fails the condition and is not compared, so the output all, “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 variables and domains of its structure schema, so only the call binds the components.

script.vtl
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);
Input DS_1
Id_1Id_2Me_1
XA5
XB5
YA5
YB4
Expected DS_r
Id_1Id_2ruleidbool_varimbalanceerrorcodeerrorlevel
XA1true0

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_2 conditioned by the variable Id_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, so bool_var is true and imbalance 0. Y fails the condition and is not compared, so the output all, “all the Data Points produced by the comparison”, has no data point for it: the reading of the closed issue #1141.

script.vtl
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);
Input DS_1
Id_1Id_2Me_1
XA5
XB5
YA5
YB4
Expected DS_r
Id_1Id_2ruleidbool_varimbalanceerrorcodeerrorlevel
XA1true0

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_1 with the alias C: 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, so bool_var is true and imbalance 0. Y fails the condition and is not compared, so the output all, “all the Data Points produced by the comparison”, has no data point for it: the reading of the closed issue #1141.

script.vtl
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);
Input DS_1
Id_1Id_2Me_1
XA5
XB5
YA5
YB4
Expected DS_r
Id_1Id_2ruleidbool_varimbalanceerrorcodeerrorlevel
XA1true0

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 of Id_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_null and dataset and the output all, 5 = 5 holds with imbalance 0 and 5 = 4 fails with imbalance 1, both with ruleid 1. errorcode and errorlevel are null, imbalance is a Number like Me_1, ruleid and errorcode Strings, and errorlevel Integer, the manual’s default without errorlevel_vd (#1256).

script.vtl
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);
Input DS_1
Id_1Id_2Me_1
1A5
1B5
2A5
2B4
Expected DS_r
Id_1Id_2ruleidbool_varimbalanceerrorcodeerrorlevel
1A1true0
2A1false1

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 of Id_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_null and dataset and the output all, 5 > 4 holds with imbalance 1 and 5 > 5 fails with imbalance 0, both with ruleid 1. errorcode and errorlevel are null, imbalance is a Number like Me_1, ruleid and errorcode Strings, and errorlevel Integer, the manual’s default without errorlevel_vd (#1256).

script.vtl
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);
Input DS_1
Id_1Id_2Me_1
1A5
1B4
2A5
2B5
Expected DS_r
Id_1Id_2ruleidbool_varimbalanceerrorcodeerrorlevel
1A1true1
2A1false0

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 of Id_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_null and dataset and the output all, 5 >= 5 holds with imbalance 0 and 4 >= 5 fails with imbalance -1, both with ruleid 1. errorcode and errorlevel are null, imbalance is a Number like Me_1, ruleid and errorcode Strings, and errorlevel Integer, the manual’s default without errorlevel_vd (#1256).

script.vtl
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);
Input DS_1
Id_1Id_2Me_1
1A5
1B5
2A4
2B5
Expected DS_r
Id_1Id_2ruleidbool_varimbalanceerrorcodeerrorlevel
1A1true0
2A1false-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 of Id_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_null and dataset and the output all, 4 < 5 holds with imbalance -1 and 5 < 5 fails with imbalance 0, both with ruleid 1. errorcode and errorlevel are null, imbalance is a Number like Me_1, ruleid and errorcode Strings, and errorlevel Integer, the manual’s default without errorlevel_vd (#1256).

script.vtl
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);
Input DS_1
Id_1Id_2Me_1
1A4
1B5
2A5
2B5
Expected DS_r
Id_1Id_2ruleidbool_varimbalanceerrorcodeerrorlevel
1A1true-1
2A1false0

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 of Id_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_null and dataset and the output all, 5 <= 5 holds with imbalance 0 and 5 <= 4 fails with imbalance 1, both with ruleid 1. errorcode and errorlevel are null, imbalance is a Number like Me_1, ruleid and errorcode Strings, and errorlevel Integer, the manual’s default without errorlevel_vd (#1256).

script.vtl
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);
Input DS_1
Id_1Id_2Me_1
1A5
1B5
2A5
2B4
Expected DS_r
Id_1Id_2ruleidbool_varimbalanceerrorcodeerrorlevel
1A1true0
2A1false1

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_var true, imbalance 0 and ruleid 1. errorcode and errorlevel are null, imbalance is a Number like Me_1, ruleid and errorcode Strings, and errorlevel Integer, the manual’s default without errorlevel_vd (#1256).

script.vtl
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);
Input DS_1
Id_1Id_2Me_1
1A6
1B5
1C3
1D2
Expected DS_r
Id_1Id_2ruleidbool_varimbalanceerrorcodeerrorlevel
1A1true0

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_var true and imbalance 0. Read without the sign, the right member would be 8, false with imbalance -6.

script.vtl
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);
Input DS_1
Id_1Id_2Me_1
1A2
1B3
1C5
Expected DS_r
Id_1Id_2ruleidbool_varimbalanceerrorcodeerrorlevel
1A1true0

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 group X: the right condition leaves C out.

Manual:

define hierarchical ruleset: “the right member Code Item is taken into account only when the relevant rightCondition is true”.

Expected:

A against B alone, 5 = 5: bool_var true and imbalance 0. Counting C would give false with imbalance 5 - 8 = -3.

script.vtl
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);
Input DS_1
Id_1Id_2Me_1
XA5
XB5
XC3
Expected DS_r
Id_1Id_2ruleidbool_varimbalanceerrorcodeerrorlevel
XA1true0

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 break A = B but only X meets 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, with imbalance 1. Y is not compared, so the output all, “all the Data Points produced by the comparison”, has no data point for it: the reading of the closed issue #1141.

script.vtl
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);
Input DS_1
Id_1Id_2Me_1
XA5
XB4
YA5
YB4
Expected DS_r
Id_1Id_2ruleidbool_varimbalanceerrorcodeerrorlevel
XA1false1

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 = B and R_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_1 fails, 5 against 4 with imbalance 1, and R_2 holds, 6 against 4 with imbalance 2. errorcode and errorlevel are null, imbalance is a Number like Me_1, ruleid and errorcode Strings, and errorlevel Integer, the manual’s default without errorlevel_vd (#1256).

script.vtl
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);
Input DS_1
Id_1Id_2Me_1
1A5
1B4
1C6
Expected DS_r
Id_1Id_2ruleidbool_varimbalanceerrorcodeerrorlevel
1AR_1false1
1CR_2true2

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 = B and C > 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:

ruleid 1 and 2: rule 1 fails, 5 against 4 with imbalance 1, and rule 2 holds, 6 against 4 with imbalance 2. errorcode and errorlevel are null, imbalance is a Number like Me_1, ruleid and errorcode Strings, and errorlevel Integer, the manual’s default without errorlevel_vd (#1256).

script.vtl
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);
Input DS_1
Id_1Id_2Me_1
1A5
1B4
1C6
Expected DS_r
Id_1Id_2ruleidbool_varimbalanceerrorcodeerrorlevel
1A1false1
1C2true2

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 of Id_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 imbalance 1 and errorcode E_AB, both with ruleid 1. imbalance is a Number like Me_1, ruleid and errorcode Strings, and the null errorlevel Integer, the manual’s default without errorlevel_vd (#1256).

script.vtl
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);
Input DS_1
Id_1Id_2Me_1
1A5
1B5
2A5
2B4
Expected DS_r
Id_1Id_2ruleidbool_varimbalanceerrorcodeerrorlevel
1A1true0
2A1false1E_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 3 on two groups of Id_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 errorlevel 3, typed Integer: no errorlevel_vd is defined here, and the manual’s examples of check, check_datapoint and check_hierarchy type it Integer. imbalance is a Number like Me_1, and ruleid 1 and the null errorcode Strings.

script.vtl
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);
Input DS_1
Id_1Id_2Me_1
1A5
1B5
2A5
2B4
Expected DS_r
Id_1Id_2ruleidbool_varimbalanceerrorcodeerrorlevel
1A1true0
2A1false13

Files: script.vtl · input/DS_1.csv · input/DS_1.json · expected/DS_r.csv · expected/DS_r.json · example page ↗