← check_hierarchy operator page · validation/check_hierarchy/rule/manual_ex_1

Manual example 1 🟢 all ok

pandas ✅ · DuckDB ✅

Tests:

the manual's HR_1, eleven rules on VD_1, "the 26 uppercase letters of the English language", with rule Id_2 partial_null all.

Manual:

Check hierarchy, Example 1, with the erratum below: partial_null produces a data point "if at least one Data Point ... of the rule is found (whichever is its Measure value)"; R080, with H found but null, follows this, not the mode table's "If at least the involved Data Points is not null".

Expected:

the error 1-3-2-3, "At op {op}: Vtl Script contains Cycles, no DAG established. Nodes involved: {nodes}": R020 B = M + N + O, R070 G = B + C and R110 M <= G form a cycle, as a rule with <= or >= links its items as = does (team decision). The manual's example is to be fixed.

script.vtl ⇩

define hierarchical ruleset HR_1 ( valuedomain rule VD_1 ) is
    R010 : A = J + K + L errorlevel 5
    ; R020 : B = M + N + O errorlevel 5
    ; R030 : C = P + Q errorcode "XX" errorlevel 5
    ; R040 : D = R + S errorlevel 1
    ; R050 : E = T + U + V errorlevel 0
    ; R060 : F = Y + W + Z errorlevel 7
    ; R070 : G = B + C
    ; R080 : H = D + E errorlevel 0
    ; R090 : I = D + G errorcode "YY" errorlevel 0
    ; R100 : M >= N errorlevel 5
    ; R110 : M <= G errorlevel 5
end hierarchical ruleset;

DS_r := check_hierarchy ( DS_1, HR_1 rule Id_2 partial_null all );

input/DS_1.csv ⇩

Id_1Id_2Me_1
2010A5
2010B11
2010C0
2010G19
2010H
2010I14
2010M2
2010N5
2010O4
2010P7
2010Q-7
2010S3
2010T9
2010U
2010V6

input/DS_1.json ⇩

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

expected/error.json ⇩

{"code": "1-3-2-3"}

value_domains/VD_1.json ⇩

{
  "name": "VD_1",
  "setlist": [
    "A",
    "B",
    "C",
    "D",
    "E",
    "F",
    "G",
    "H",
    "I",
    "J",
    "K",
    "L",
    "M",
    "N",
    "O",
    "P",
    "Q",
    "R",
    "S",
    "T",
    "U",
    "V",
    "W",
    "X",
    "Y",
    "Z"
  ],
  "type": "String"
}