← define_hierarchical_ruleset operator page · definitions/define_hierarchical_ruleset/condition/aliased_conditioning_variable

Aliased conditioning variable 🟢 all ok

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

Id_1Id_2Me_1
XA5
XB5
YA5
YB4

input/DS_1.json ⇩

{
  "datasets": [
    {
      "name": "DS_1",
      "DataStructure": [
        {
          "name": "Id_1",
          "type": "String",
          "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
XA1true0

expected/DS_r.json ⇩

{
  "datasets": [
    {
      "name": "DS_r",
      "DataStructure": [
        {
          "name": "Id_1",
          "type": "String",
          "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"
        }
      ]
    }
  ]
}