← define_hierarchical_ruleset operator page · definitions/define_hierarchical_ruleset/variable/unbalanced_total

Unbalanced total 🟢 all ok

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.csv ⇩

Id_1Id_2Me_1
1A10
1B4
1C5

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_2ruleidbool_varimbalanceerrorcodeerrorlevel
1A1false1

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": "bool_var",
          "type": "Boolean",
          "role": "Measure"
        },
        {
          "name": "imbalance",
          "type": "Number",
          "role": "Measure"
        },
        {
          "name": "errorcode",
          "type": "String",
          "role": "Measure"
        },
        {
          "name": "errorlevel",
          "type": "Integer",
          "role": "Measure"
        }
      ]
    }
  ]
}