Between · between

🟢 4 of 4 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
Dataset formsComponent formsScalar forms
        ---
config:
  flowchart:
    useMaxWidth: false

---
flowchart TB
    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["Between · between<br/>🟢4"]:::ok
    subgraph G_ds["Dataset"]
        direction LR
        v_ds_sc_sc["between(DS, sc, sc)"]:::ok
    end
    subgraph G_comp["Component"]
        direction LR
        v_comp_sc_sc["between(comp, sc, sc)"]:::ok
        v_comp_comp_comp["between(comp, comp, comp)"]:::ok
    end
    subgraph G_sc["Scalar"]
        direction LR
        v_sc_sc_sc["between(sc, sc, sc)"]:::ok
    end
    O --- G_ds
    O --- G_comp
    O --- G_sc
    style G_ds fill:#f8f9fa,stroke:#495057,stroke-width:2px
    style G_comp fill:#f8f9fa,stroke:#495057,stroke-width:2px,stroke-dasharray: 8 5
    style G_sc fill:#f8f9fa,stroke:#495057,stroke-width:2px,stroke-dasharray: 2 3
    click v_ds_sc_sc href "#form-ds-sc-sc"
    click v_comp_sc_sc href "#form-comp-sc-sc"
    click v_comp_comp_comp href "#form-comp-comp-comp"
    click v_sc_sc_sc href "#form-sc-sc-sc"
    

Types

Takes any scalar · Gives boolean

Comes from: any operator that returns a value

Goes to · boolean — 27 operators in 8 blocks 🟢27
General purpose operators (1) 🟢1
Join operators (4) 🟢4
Boolean operators (4) 🟢4
Aggregate and Analytic operators (10) 🟢10
Data validation operators (1) 🟢1
Conditional operators (2) 🟢2
Clause operators (2) 🟢2
Definitions (VTL-DL) (3) 🟢3
Goes to · operators that take any scalar — 37 operators in 8 blocks 🟢37
General purpose operators (6) 🟢6
Comparison operators (10) 🟢10
Set operators (4) 🟢4
Aggregate and Analytic operators (7) 🟢7
Data validation operators (1) 🟢1
Conditional operators (1) 🟢1
Clause operators (7) 🟢7
Definitions (VTL-DL) (1) 🟢1

Forms

between(DS, sc, sc) 🟢 · any scalar → boolean

Manual example 1 🟢 pandas ✅ · DuckDB ✅
Tests:

between(DS_1, 5, 10): every measure value of DS_1 against two scalar limits.

Manual:

Between, Example 1, output verbatim: “The operator returns true if op is greater than or equal to from and lower than or equal to to.”

Expected:

bool_var is true for G (6) and false for R (-2).

script.vtl
DS_r:= between(DS_1, 5, 10);
Input DS_1
Id_1Id_2Id_3Id_4Me_1
GTotalPercentageTotal6
RTotalPercentageTotal-2
Expected DS_r
Id_1Id_2Id_3Id_4bool_var
GTotalPercentageTotaltrue
RTotalPercentageTotalfalse

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

between(comp, sc, sc) 🟢 · any scalar → boolean

Limits included and null operand 🟢 pandas ✅ · DuckDB ✅
Tests:

between(Me_1, 5, 10) inside calc: values on each limit, above the range, and null.

Manual:

Between: “The operator returns true if op is greater than or equal to from and lower than or equal to to. In other terms, it is a shortcut for the following: op >= from and op <= to”. A null operand gives a null result: “Whenever a null value is involved in a comparison (>, <, >=, <=, in, not in, between) the result of the comparison is null” (User Manual).

Expected:

Me_2 is a new boolean measure: true, true, false and null for ids 1 to 4: 5 and 10 are the limits themselves, so they are between 5 and 10; 11 is above; a null operand gives null; Me_1 is kept.

script.vtl
DS_r := DS_1 [ calc Me_2 := between(Me_1, 5, 10) ];
Input DS_1
Id_1Me_1
15
210
311
4
Expected DS_r
Id_1Me_1Me_2
15true
210true
311false
4

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

between(comp, comp, comp) 🟢 · any scalar → boolean

Component limits and null operand 🟢 pandas ✅ · DuckDB ✅
Tests:

between(Me_1, Me_2, Me_3) inside calc: the limits are components, so each data point has its own, and the operand is null in one.

Manual:

Between: “The operator returns true if op is greater than or equal to from and lower than or equal to to. In other terms, it is a shortcut for the following: op >= from and op <= to”. from and to may be components: they are typed component<scalar> | scalar.

Expected:

Me_4 is a new boolean measure: true, true, false and null for ids 1 to 4: 5 and 10 are the limits of ids 1 and 2, so they count; 7 is below its limit 8; Me_1 to Me_3 are kept. A null operand makes both comparisons of the shortcut null, and so their conjunction: “Whenever a null value is involved in a comparison (>, <, >=, <=, in, not in, between) the result of the comparison is null” (User Manual).

script.vtl
DS_r := DS_1 [ calc Me_4 := between(Me_1, Me_2, Me_3) ];
Input DS_1
Id_1Me_1Me_2Me_3
15510
210110
3789
412
Expected DS_r
Id_1Me_1Me_2Me_3Me_4
15510true
210110true
3789false
412

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

between(sc, sc, sc) 🟢 · any scalar → boolean

Upper limit included 🟢 pandas ✅ · DuckDB ✅
Tests:

between(SC_1, SC_2, SC_3) with SC_1 = 10, SC_2 = 5 and SC_3 = 10: an operand equal to the upper limit.

Manual:

Between: “The operator returns true if op is greater than or equal to from and lower than or equal to to. In other terms, it is a shortcut for the following: op >= from and op <= to”.

Expected:

SC_r = true, a Boolean: 10 >= 5 and 10 <= 10; it would be false if the limit were excluded.

script.vtl
SC_r := between(SC_1, SC_2, SC_3);
Input scalars
SC_1SC_2SC_3
10510
Expected scalars

Name

Type

Value

SC_r

Boolean

true

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