← check_hierarchy operator page · validation/check_hierarchy/condition/conditioning_variable_named

Conditioning variable named 🟢 all ok

pandas ✅ · DuckDB ✅

Tests:

HR_2 on Id_2 conditioned by the variable Id_1, R1 : when Id_1 = 2 then A = B, called with condition Id_1 and the default non_null, dataset and invalid.

Manual:

Check hierarchy: on Variables, condComp "can be specified all the same if it is desired to show explicitly in the invocation which are the involved Components"; the leftCondition "defines the pre-condition for evaluating the left member Code Item (i.e., it is evaluated only when the leftCondition is true)" (define hierarchical ruleset).

Expected:

(2, A, R1) only, 7 = 4 being false, with Me_1 7 and imbalance 3: for Id_1 1 the rule is not evaluated, though 5 = 2 would be false, and invalid leaves such a rule out whatever it returns. imbalance, left minus right, is a Number like Me_1, and the null errorlevel Integer, the manual's default without errorlevel_vd (#1256).

script.vtl ⇩

define hierarchical ruleset HR_2 ( variable condition Id_1 rule Id_2 ) is
    R1 : when Id_1 = 2 then A = B
end hierarchical ruleset;

DS_r := check_hierarchy ( DS_1, HR_2 condition Id_1 );

input/DS_1.csv ⇩

Id_1Id_2Me_1
1A5
1B2
2A7
2B4

input/DS_1.json ⇩

{
  "datasets": [
    {
      "name": "DS_1",
      "DataStructure": [
        {"name": "Id_1", "type": "Integer", "role": "Identifier", "nullable": false},
        {"name": "Id_2", "type": "String", "role": "Identifier", "nullable": false},
        {"name": "Me_1", "type": "Number", "role": "Measure", "nullable": true}
      ]
    }
  ]
}

expected/DS_r.csv ⇩

Id_1Id_2ruleidMe_1imbalanceerrorcodeerrorlevel
2AR173

expected/DS_r.json ⇩

{
  "datasets": [
    {
      "name": "DS_r",
      "DataStructure": [
        {"name": "Id_1", "type": "Integer", "role": "Identifier"},
        {"name": "Id_2", "type": "String", "role": "Identifier"},
        {"name": "ruleid", "type": "String", "role": "Identifier"},
        {"name": "Me_1", "type": "Number", "role": "Measure"},
        {"name": "imbalance", "type": "Number", "role": "Measure"},
        {"name": "errorcode", "type": "String", "role": "Measure"},
        {"name": "errorlevel", "type": "Integer", "role": "Measure"}
      ]
    }
  ]
}