← check_datapoint operator page · validation/check_datapoint/all/manual_ex_2

Manual example 2 🟢 all ok

pandas ✅ · DuckDB ✅

Tests:

check_datapoint ( DS_1, dpr1 all ), in the manual's script, which calls dpr1 before its definition.

Manual:

Check datapoint, Example 2, output verbatim: all "contains a data point for each Data Point of op and each Rule in dpr. The resulting Data Set has the boolean Measure bool_var"; the User Manual: "The order in which the user defines the Transformations ... cannot override the order of execution".

Expected:

8 data points, one per data point and rule: rule 1 true on all four, the DEBIT ones by its false antecedent, and rule 2 false only on (2011, l, DEBIT), -2, with errorcode Bad debit, null on the valid results. ruleid is 1 or 2, "the progressive order number of the Rule in the Ruleset" (define datapoint ruleset), as the rules have no names, and the null errorlevel Integer, as the manual types it.

script.vtl ⇩

DS_r := check_datapoint ( DS_1, dpr1 all );define datapoint ruleset dpr1 ( variable Id_3, Me_1 ) is
    when Id_3 = "CREDIT" then Me_1 >= 0 errorcode "Bad credit"
    ; when Id_3 = "DEBIT" then Me_1 >= 0 errorcode "Bad debit"
end datapoint ruleset;

input/DS_1.csv ⇩

Id_1Id_2Id_3Me_1
2011lCREDIT10
2011lDEBIT-2
2012lCREDIT10
2012lDEBIT2

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": "Id_3", "type": "String", "role": "Identifier", "nullable": false},
        {"name": "Me_1", "type": "Integer", "role": "Measure", "nullable": true}
      ]
    }
  ]
}

expected/DS_r.csv ⇩

Id_1Id_2Id_3bool_varruleiderrorcodeerrorlevel
2011lCREDITtrue1
2011lDEBITtrue1
2012lCREDITtrue1
2012lDEBITtrue1
2011lCREDITtrue2
2011lDEBITfalse2Bad debit
2012lCREDITtrue2
2012lDEBITtrue2

expected/DS_r.json ⇩

{
  "datasets": [
    {
      "name": "DS_r",
      "DataStructure": [
        {"name": "Id_1", "type": "Time_Period", "role": "Identifier"},
        {"name": "Id_2", "type": "String", "role": "Identifier"},
        {"name": "Id_3", "type": "String", "role": "Identifier"},
        {"name": "ruleid", "type": "String", "role": "Identifier"},
        {"name": "bool_var", "type": "Boolean", "role": "Measure"},
        {"name": "errorcode", "type": "String", "role": "Measure"},
        {"name": "errorlevel", "type": "Integer", "role": "Measure"}
      ]
    }
  ]
}