← check_datapoint operator page · validation/check_datapoint/output_default/manual_ex_1

Manual example 1 🟢 all ok

pandas ✅ · DuckDB ✅

Tests:

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

Manual:

Check datapoint, Example 1, output verbatim: "If not specified then output is assumed to be invalid"; the User Manual: "The order in which the user defines the Transformations ... cannot override the order of execution".

Expected:

(2011, l, DEBIT) only: rule 2, when Id_3 = "DEBIT" then Me_1 >= 0, is false on -2, with errorcode Bad debit, and rule 1 holds everywhere, on the DEBIT data points by its false antecedent. ruleid is 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 );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_3Me_1ruleiderrorcodeerrorlevel
2011lDEBIT-22Bad debit

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