Not element of · not_in

🟢 5 of 5 forms all ok · VTL 2.2 Reference Manual ↗ · vtlengine 1.10.0rc2 (90ee9376) · 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["Not element of · not_in<br/>🟢5"]:::ok
    subgraph G_ds["Dataset"]
        direction LR
        v_ds_set["DS not_in set"]:::ok
        v_ds_value_domain["DS not_in value domain"]:::ok
    end
    subgraph G_comp["Component"]
        direction LR
        v_comp_set["comp not_in set"]:::ok
        v_comp_value_domain["comp not_in value domain"]:::ok
    end
    subgraph G_sc["Scalar"]
        direction LR
        v_sc_set["sc not_in set"]:::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_set href "#form-ds-set"
    click v_comp_set href "#form-comp-set"
    click v_sc_set href "#form-sc-set"
    click v_ds_value_domain href "#form-ds-value-domain"
    click v_comp_value_domain href "#form-comp-value-domain"
    

Types

Takes set, value domain, any scalar · Gives boolean

Comes from: any operator that returns a value

Comes from · set, value domain: none

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

DS not_in set 🟢 · any scalar, set → boolean

Members and null operand 🟢 pandas ✅ · DuckDB ✅
Tests:

DS_1 not_in { 0, 3, 6, 12 }: every measure value of DS_1 against a set literal, with two elements, a non-element and a null.

Manual:

Element of: “The not_in operator returns false if op belongs to the collection, true otherwise.” 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:

bool_var, the page’s measure for a data set result, is false for 0, true for 4, false for 6 and null for the null measure.

script.vtl
DS_r := DS_1 not_in { 0, 3, 6, 12 };
Input DS_1
Id_1Me_1
10
24
36
4
Expected DS_r
Id_1bool_var
1false
2true
3false
4

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

DS not_in value domain 🟢 · any scalar, value domain → boolean

Members and null operand 🟢 pandas ✅ · DuckDB ✅
Tests:

DS_1 not_in myGeoValueDomain: every measure value of DS_1 against a value domain, with the elements AF and UG (the first and the last), the non-element CQ and a null.

Manual:

Element of: “The not_in operator returns false if op belongs to the collection, true otherwise.” The page defines the Value Domain myGeoValueDomain (string) in the text before its examples, as {"AF", "BS", "FJ", "GA", "KH", "MO", "PK", "QA", "UG"}; it is passed to run as value_domains/myGeoValueDomain.json.

Expected:

bool_var, the page’s measure for a data set result, is false for AF, true for CQ, false for UG and null for the null measure. 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).

script.vtl
DS_r := DS_1 not_in myGeoValueDomain;
Input DS_1
Id_1Me_1
1AF
2CQ
3UG
4
Expected DS_r
Id_1bool_var
1false
2true
3false
4

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

comp not_in set 🟢 · any scalar, set → boolean

Members and null operand 🟢 pandas ✅ · DuckDB ✅
Tests:

Me_1 not_in { 0, 3, 6, 12 } inside calc: two elements of the set, a non-element and a null.

Manual:

Element of: “The not_in operator returns false if op belongs to the collection, true otherwise.” 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: false for 0, true for 4, false for 6 and null for the null; Me_1 is kept.

script.vtl
DS_r := DS_1 [ calc Me_2 := Me_1 not_in { 0, 3, 6, 12 } ];
Input DS_1
Id_1Me_1
10
24
36
4
Expected DS_r
Id_1Me_1Me_2
10false
24true
36false
4

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

comp not_in value domain 🟢 · any scalar, value domain → boolean

Members and null operand 🟢 pandas ✅ · DuckDB ✅
Tests:

Me_1 not_in myGeoValueDomain inside calc: the elements AF and UG (the first and the last of the value domain), the non-element CQ and a null.

Manual:

Element of: “The not_in operator returns false if op belongs to the collection, true otherwise.” The page defines the Value Domain myGeoValueDomain (string) in the text before its examples, as {"AF", "BS", "FJ", "GA", "KH", "MO", "PK", "QA", "UG"}; it is passed to run as value_domains/myGeoValueDomain.json.

Expected:

Me_2 is a new boolean measure: false for AF, true for CQ, false for UG and null for the null; Me_1 is kept. 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).

script.vtl
DS_r := DS_1 [ calc Me_2 := Me_1 not_in myGeoValueDomain ];
Input DS_1
Id_1Me_1
1AF
2CQ
3UG
4
Expected DS_r
Id_1Me_1Me_2
1AFfalse
2CQtrue
3UGfalse
4

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

sc not_in set 🟢 · any scalar, set → boolean

Member of a set 🟢 pandas ✅ · DuckDB ✅
Tests:

SC_1 not_in { "b", "hello", "c" } with SC_1 = "b": a scalar that is an element of a set literal.

Manual:

Element of, semantics for scalar operations: “``”b” not_in { “b”, “hello”, “c” }`` returns false”.

Expected:

SC_r = false, a Boolean: b is an element of the set, so not_in is false.

script.vtl
SC_r := SC_1 not_in { "b", "hello", "c" };
Input scalars
SC_1
b
Expected scalars

Name

Type

Value

SC_r

Boolean

false

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