Check datapoint · check_datapoint

🟢 7 of 7 forms all ok · VTL 2.2 Reference Manual ↗ · vtlengine 1.10.0rc3 (9e1c81a6) · pandas 2.3.3 · DuckDB 1.5.5
🟢 all ok🟡 partially implemented🛡️ refused with an error🔴 not implemented or crash🔵 engines differ ✅ match · ❌ wrong result · 🛡 guarded error (code) · 💥 crash · 📌 team decision
        ---
config:
  flowchart:
    useMaxWidth: false

---
flowchart LR
    classDef ok fill:#d4edda,stroke:#28a745,color:#000
    classDef partial fill:#fff3cd,stroke:#ffc107,color:#000
    classDef refused fill:#d4edda,stroke:#28a745,stroke-width:3px,stroke-dasharray: 2 2,color:#000
    classDef missing fill:#f8d7da,stroke:#dc3545,color:#000
    classDef diverge fill:#cce5ff,stroke:#007bff,color:#000
    classDef block fill:#2b3a4a,stroke:#2b3a4a,color:#fff,font-weight:bold
    classDef ext fill:#fff,stroke:#666,color:#000,stroke-dasharray: 5 5
    O["Check datapoint · check_datapoint<br/>🟢7"]:::ok
    v_output_default["check_datapoint(DS, DPR)"]:::ok
    v_invalid["check_datapoint(DS, DPR invalid)"]:::ok
    v_all["check_datapoint(DS, DPR all)"]:::ok
    v_all_measures["check_datapoint(DS, DPR all_measures)"]:::ok
    v_components["check_datapoint(DS, DPR components C1, C2)"]:::ok
    v_errorcode["check_datapoint(DS, DPR all), rules with errorcode"]:::ok
    v_errorlevel["check_datapoint(DS, DPR all), rules with errorlevel"]:::ok
    v_output_default --- O
    v_invalid --- O
    v_all --- O
    v_all_measures --- O
    O --- v_components
    O --- v_errorcode
    O --- v_errorlevel
    click v_output_default href "#form-output-default"
    click v_invalid href "#form-invalid"
    click v_all href "#form-all"
    click v_all_measures href "#form-all-measures"
    click v_components href "#form-components"
    click v_errorcode href "#form-errorcode"
    click v_errorlevel href "#form-errorlevel"
    

Types

Takes datapoint ruleset, any scalar · Gives integer, string, boolean, any type

Comes from: any operator that returns a value

Comes from · datapoint ruleset — 1 operator in 1 block 🟢1
Definitions (VTL-DL) (1) 🟢1

Goes to: whatever takes its input's type

Goes to · integer, string, boolean — 69 operators in 13 blocks 🟢69
General purpose operators (1) 🟢1
Join operators (4) 🟢4
String operators (11) 🟢11
Numeric operators (18) 🟢18
Comparison operators (1) 🟢1
Boolean operators (4) 🟢4
Time operators (6) 🟢6
Hierarchical aggregation (1) 🟢1
Aggregate and Analytic operators (13) 🟢13
Data validation operators (2) 🟢2
Conditional operators (2) 🟢2
Clause operators (2) 🟢2
Definitions (VTL-DL) (4) 🟢4
Goes to · operators that take any scalar — 34 operators in 6 blocks 🟢34
General purpose operators (6) 🟢6
Comparison operators (11) 🟢11
Set operators (4) 🟢4
Aggregate and Analytic operators (5) 🟢5
Conditional operators (1) 🟢1
Clause operators (7) 🟢7

Forms

check_datapoint(DS, DPR) 🟢 · any scalar, datapoint ruleset → any type, string, integer

Manual example 1 🟢 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
Id_1Id_2Id_3Me_1
2011lCREDIT10
2011lDEBIT-2
2012lCREDIT10
2012lDEBIT2
Expected DS_r
Id_1Id_2Id_3Me_1ruleiderrorcodeerrorlevel
2011lDEBIT-22Bad debit

Files: script.vtl · input/DS_1.csv · input/DS_1.json · expected/DS_r.csv · expected/DS_r.json · example page ↗

check_datapoint(DS, DPR invalid) 🟢 · any scalar, datapoint ruleset → any type, string, integer

False results with the measures 🟢 pandas ✅ · DuckDB ✅
Tests:

DPR_1, R1 : when Id_2 = "A" then Me_1 > 0 and R2 : Me_1 < 100, on (1, A, 10), (2, A, -5), (3, B, 200) and (4, A, null), with output invalid.

Manual:

Check datapoint: invalid “contains a Data Point for each Data Point of op and each Rule in dpr that evaluates to false on that Data Point. The resulting Data Set has the Measures of op”; on a false antecedent “the result is considered as valid (true)” (define datapoint ruleset).

Expected:

(2, A, R1) and (3, B, R2), ruleid the rule name, with Me_1 -5 and 200 and no bool_var: (3, B) passes R1 by its false antecedent, and (4, A) is null on both rules. errorcode and errorlevel are null, errorlevel Integer, the manual’s default without errorlevel_vd (#1256).

script.vtl
define datapoint ruleset DPR_1 ( variable Id_2, Me_1 ) is
    R1 : when Id_2 = "A" then Me_1 > 0
    ; R2 : Me_1 < 100
end datapoint ruleset;

DS_r := check_datapoint ( DS_1, DPR_1 invalid );
Input DS_1
Id_1Id_2Me_1
1A10
2A-5
3B200
4A
Expected DS_r
Id_1Id_2ruleidMe_1errorcodeerrorlevel
2AR1-5
3BR2200

Files: script.vtl · input/DS_1.csv · input/DS_1.json · expected/DS_r.csv · expected/DS_r.json · example page ↗

check_datapoint(DS, DPR all) 🟢 · any scalar, datapoint ruleset → boolean, string, integer

Manual example 2 🟢 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
Id_1Id_2Id_3Me_1
2011lCREDIT10
2011lDEBIT-2
2012lCREDIT10
2012lDEBIT2
Expected DS_r
Id_1Id_2Id_3bool_varruleiderrorcodeerrorlevel
2011lCREDITtrue1
2011lDEBITtrue1
2012lCREDITtrue1
2012lDEBITtrue1
2011lCREDITtrue2
2011lDEBITfalse2Bad debit
2012lCREDITtrue2
2012lDEBITtrue2

Files: script.vtl · input/DS_1.csv · input/DS_1.json · expected/DS_r.csv · expected/DS_r.json · example page ↗

check_datapoint(DS, DPR all_measures) 🟢 · any scalar, datapoint ruleset → any type, boolean, string, integer

Every result with the measures 🟢 pandas ✅ · DuckDB ✅
Tests:

DPR_1, R1 : when Id_2 = "A" then Me_1 > 0 and R2 : Me_1 < 100, on (1, A, 10), (2, A, -5), (3, B, 200) and (4, A, null), with output all_measures.

Manual:

Check datapoint: all_measures “contains a Data Point for each Data Point of op and each Rule in dpr. The resulting dataset has the Measures of op and the boolean Measure bool_var”, which is “true, false or null”; on a false antecedent “the result is considered as valid (true)” (define datapoint ruleset).

Expected:

8 data points, one per data point and rule, ruleid the rule name, with Me_1 and bool_var: false on (2, A, R1) and (3, B, R2), null on both rules of (4, A), and true elsewhere, (3, B, R1) by its false antecedent. errorcode and errorlevel are null, errorlevel Integer, the manual’s default without errorlevel_vd (#1256).

script.vtl
define datapoint ruleset DPR_1 ( variable Id_2, Me_1 ) is
    R1 : when Id_2 = "A" then Me_1 > 0
    ; R2 : Me_1 < 100
end datapoint ruleset;

DS_r := check_datapoint ( DS_1, DPR_1 all_measures );
Input DS_1
Id_1Id_2Me_1
1A10
2A-5
3B200
4A
Expected DS_r
Id_1Id_2ruleidMe_1bool_varerrorcodeerrorlevel
1AR110true
1AR210true
2AR1-5false
2AR2-5true
3BR1200true
3BR2200false
4AR1
4AR2

Files: script.vtl · input/DS_1.csv · input/DS_1.json · expected/DS_r.csv · expected/DS_r.json · example page ↗

check_datapoint(DS, DPR components C1, C2) 🟢 · any scalar, datapoint ruleset → any type, boolean, string, integer

Listed variables change nothing 🟢 pandas ✅ · DuckDB ✅
Tests:

DPR_1 on the variables Id_2 and Me_1, R1 : when Id_2 = "A" then Me_1 > 0 and R2 : Me_1 < 100, called with components Id_2, Me_1, in their order, and no output, on (1, A, 10), (2, A, -5), (3, B, 200) and (4, A, null).

Manual:

Check datapoint: “If dpr is defined on Variables then listComp is the list of Components of op to be associated (in positional order) to the conditioning Variables defined in dpr (for documentation purposes)”, and “If not specified then output is assumed to be invalid”.

Expected:

the output of False results with the measures, form invalid: (2, A, R1) and (3, B, R2), ruleid the rule name, with Me_1 -5 and 200, as (3, B) passes R1 by its false antecedent. errorcode and errorlevel are null, errorlevel Integer, the manual’s default without errorlevel_vd (#1256).

script.vtl
define datapoint ruleset DPR_1 ( variable Id_2, Me_1 ) is
    R1 : when Id_2 = "A" then Me_1 > 0
    ; R2 : Me_1 < 100
end datapoint ruleset;

DS_r := check_datapoint ( DS_1, DPR_1 components Id_2, Me_1 );
Input DS_1
Id_1Id_2Me_1
1A10
2A-5
3B200
4A
Expected DS_r
Id_1Id_2ruleidMe_1errorcodeerrorlevel
2AR1-5
3BR2200

Files: script.vtl · input/DS_1.csv · input/DS_1.json · expected/DS_r.csv · expected/DS_r.json · example page ↗

Value domains bound to components 🛡️ pandas 🛡 1-2-8 · DuckDB 🛡 1-2-8

SemanticError 1-2-8: Missing value domain 'VD_M' definition, please provide an structure. Please check transformation with output Dataset DS_r

Tests:

DPR_2, the rules of DPR_1 written on the value domains VD_2 and VD_M, bound to Id_2 and Me_1 by components Id_2, Me_1, with no output.

Manual:

Check datapoint: “If dpr is defined on Value Domains then it is mandatory to specify listComp”, the Components of op “to be associated (in positional order) to the conditioning Value Domains defined in dpr”.

Expected:

the output of Listed variables change nothing: (2, A, R1) and (3, B, R2), with Me_1 -5 and 200, null errorcode and the null errorlevel Integer. VD_2 holds A and B, the values of Id_2, and VD_M, the numbers of Me_1, has no file: a value domain file lists values, and no rule tests membership of VD_M.

script.vtl
define datapoint ruleset DPR_2 ( valuedomain VD_2, VD_M ) is
    R1 : when VD_2 = "A" then VD_M > 0
    ; R2 : VD_M < 100
end datapoint ruleset;

DS_r := check_datapoint ( DS_1, DPR_2 components Id_2, Me_1 );
Input DS_1
Id_1Id_2Me_1
1A10
2A-5
3B200
4A
Expected DS_r
Id_1Id_2ruleidMe_1errorcodeerrorlevel
2AR1-5
3BR2200

Files: script.vtl · input/DS_1.csv · input/DS_1.json · expected/DS_r.csv · expected/DS_r.json · value_domains/VD_2.json · example page ↗

check_datapoint(DS, DPR all), rules with errorcode 🟢 · any scalar, datapoint ruleset → boolean, string, integer

Code only on false results 🟢 pandas ✅ · DuckDB ✅
Tests:

DPR_1, R1 : when Id_2 = "A" then Me_1 > 0 and R2 : Me_1 < 100, with errorcode "E1" on R1 and "E2" on R2, on (1, A, 10), (2, A, -5), (3, B, 200) and (4, A, null), with output all.

Manual:

Check datapoint: “the Measure errorcode that contains the errorcode specified in the rule; if the Measure bool_var is true or null then errorcode is null”; on a false antecedent “the result is considered as valid (true)” (define datapoint ruleset).

Expected:

8 data points, ruleid the rule name: errorcode E1 on (2, A, R1) and E2 on (3, B, R2), the false results, and null on the true ones, (3, B, R1) by its false antecedent, and on the null ones of (4, A). The null errorlevel is Integer, the manual’s default without errorlevel_vd (#1256).

script.vtl
define datapoint ruleset DPR_1 ( variable Id_2, Me_1 ) is
    R1 : when Id_2 = "A" then Me_1 > 0 errorcode "E1"
    ; R2 : Me_1 < 100 errorcode "E2"
end datapoint ruleset;

DS_r := check_datapoint ( DS_1, DPR_1 all );
Input DS_1
Id_1Id_2Me_1
1A10
2A-5
3B200
4A
Expected DS_r
Id_1Id_2ruleidbool_varerrorcodeerrorlevel
1AR1true
1AR2true
2AR1falseE1
2AR2true
3BR1true
3BR2falseE2
4AR1
4AR2

Files: script.vtl · input/DS_1.csv · input/DS_1.json · expected/DS_r.csv · expected/DS_r.json · example page ↗

check_datapoint(DS, DPR all), rules with errorlevel 🟢 · any scalar, datapoint ruleset → boolean, string, integer

Integer level on false results 🟢 pandas ✅ · DuckDB ✅
Tests:

DPR_1, R1 : when Id_2 = "A" then Me_1 > 0 and R2 : Me_1 < 100, with errorlevel 1 on R1 and 2 on R2, on (1, A, 10), (2, A, -5), (3, B, 200) and (4, A, null), with output all.

Manual:

Check datapoint: “the Measure errorlevel that contains the errorlevel specified in the rule; if the Measure bool_var is true or null then errorlevel is null”.

Expected:

errorlevel 1 on (2, A, R1) and 2 on (3, B, R2), the false results, and null elsewhere, typed Integer as in the manual’s example structures, Check datapoint Examples 1 and 2 and Check hierarchy Example 1, and the manual’s default without errorlevel_vd (#1256).

script.vtl
define datapoint ruleset DPR_1 ( variable Id_2, Me_1 ) is
    R1 : when Id_2 = "A" then Me_1 > 0 errorlevel 1
    ; R2 : Me_1 < 100 errorlevel 2
end datapoint ruleset;

DS_r := check_datapoint ( DS_1, DPR_1 all );
Input DS_1
Id_1Id_2Me_1
1A10
2A-5
3B200
4A
Expected DS_r
Id_1Id_2ruleidbool_varerrorcodeerrorlevel
1AR1true
1AR2true
2AR1false1
2AR2true
3BR1true
3BR2false2
4AR1
4AR2

Files: script.vtl · input/DS_1.csv · input/DS_1.json · expected/DS_r.csv · expected/DS_r.json · example page ↗