Exists in · exists_in
---
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["Exists in · exists_in<br/>🟢4"]:::ok
v_retain_default["exists_in(DS, DS)"]:::ok
v_retain_true["exists_in(DS, DS, true)"]:::ok
v_retain_false["exists_in(DS, DS, false)"]:::ok
v_retain_all["exists_in(DS, DS, all)"]:::ok
v_retain_default --- O
v_retain_true --- O
O --- v_retain_false
O --- v_retain_all
click v_retain_default href "#form-retain-default"
click v_retain_true href "#form-retain-true"
click v_retain_false href "#form-retain-false"
click v_retain_all href "#form-retain-all"
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
exists_in(DS, DS) 🟢 · any scalar → boolean
Identifier found with null measure 🟢 pandas ✅ · DuckDB ✅
- Tests:
exists_in(DS_1, DS_2)withretainomitted: id 1 is inDS_2with a null measure, id 2 is not in it.- Manual:
Exists in: “If the retain parameter is omitted, the default is all.” The operator “checks if the combinations of values of these Identifiers which are in op1 also exist in op2”.
- Expected:
bool_varis true, false and true for ids 1 to 3, all of them returned: id 1 is found although its measure inDS_2is null, because only the identifiers are looked at.
DS_r := exists_in(DS_1, DS_2);
| Id_1 | Me_1 |
|---|---|
| 1 | 10 |
| 2 | 20 |
| 3 | 30 |
| Id_1 | Me_1 |
|---|---|
| 1 | |
| 3 | 7 |
| Id_1 | bool_var |
|---|---|
| 1 | true |
| 2 | false |
| 3 | true |
Files: script.vtl · input/DS_1.csv · input/DS_1.json · input/DS_2.csv · input/DS_2.json · expected/DS_r.csv · expected/DS_r.json · example page ↗
exists_in(DS, DS, true) 🟢 · any scalar → boolean
Manual example 2 🟢 pandas ✅ · DuckDB ✅
- Tests:
exists_in (DS_1, DS_2, true): only the data points ofDS_1that are found inDS_2.- Manual:
Exists in, Example 2, output verbatim: “If retain is true then only the data points with bool_var = true are returned.”
- Expected:
B, S, F and W, with
bool_vartrue; G and M are left out, asDS_2has them only withId_4= M.
DS_r := exists_in (DS_1, DS_2, true);
| Id_1 | Id_2 | Id_3 | Id_4 | Me_1 |
|---|---|---|---|---|
| 2012 | B | Total | Total | 11094850 |
| 2012 | G | Total | Total | 11123034 |
| 2012 | S | Total | Total | 46818219 |
| 2012 | M | Total | Total | 417546 |
| 2012 | F | Total | Total | 5401267 |
| 2012 | W | Total | Total | 7954662 |
| Id_1 | Id_2 | Id_3 | Id_4 | Me_1 |
|---|---|---|---|---|
| 2012 | B | Total | Total | 0.023 |
| 2012 | G | Total | M | 0.286 |
| 2012 | S | Total | Total | 0.064 |
| 2012 | M | Total | M | 0.043 |
| 2012 | F | Total | Total | |
| 2012 | W | Total | Total | 0.08 |
| Id_1 | Id_2 | Id_3 | Id_4 | bool_var |
|---|---|---|---|---|
| 2012 | B | Total | Total | true |
| 2012 | S | Total | Total | true |
| 2012 | F | Total | Total | true |
| 2012 | W | Total | Total | true |
Files: script.vtl · input/DS_1.csv · input/DS_1.json · input/DS_2.csv · input/DS_2.json · expected/DS_r.csv · expected/DS_r.json · example page ↗
exists_in(DS, DS, false) 🟢 · any scalar → boolean
Manual example 3 🟢 pandas ✅ · DuckDB ✅
- Tests:
exists_in (DS_1, DS_2, false): only the data points ofDS_1that are not found inDS_2.- Manual:
Exists in, Example 3, output verbatim: “If retain is false then only the Data Points with bool_var = false are returned.”
- Expected:
G and M, with
bool_varfalse, asDS_2has them only withId_4= M; B, S, F and W are left out.
DS_r := exists_in (DS_1, DS_2, false);
| Id_1 | Id_2 | Id_3 | Id_4 | Me_1 |
|---|---|---|---|---|
| 2012 | B | Total | Total | 11094850 |
| 2012 | G | Total | Total | 11123034 |
| 2012 | S | Total | Total | 46818219 |
| 2012 | M | Total | Total | 417546 |
| 2012 | F | Total | Total | 5401267 |
| 2012 | W | Total | Total | 7954662 |
| Id_1 | Id_2 | Id_3 | Id_4 | Me_1 |
|---|---|---|---|---|
| 2012 | B | Total | Total | 0.023 |
| 2012 | G | Total | M | 0.286 |
| 2012 | S | Total | Total | 0.064 |
| 2012 | M | Total | M | 0.043 |
| 2012 | F | Total | Total | |
| 2012 | W | Total | Total | 0.08 |
| Id_1 | Id_2 | Id_3 | Id_4 | bool_var |
|---|---|---|---|---|
| 2012 | G | Total | Total | false |
| 2012 | M | Total | Total | false |
Files: script.vtl · input/DS_1.csv · input/DS_1.json · input/DS_2.csv · input/DS_2.json · expected/DS_r.csv · expected/DS_r.json · example page ↗
exists_in(DS, DS, all) 🟢 · any scalar → boolean
Manual example 1 🟢 pandas ✅ · DuckDB ✅
- Tests:
exists_in (DS_1, DS_2, all): every data point ofDS_1is returned, found inDS_2or not.- Manual:
Exists in, Example 1, output verbatim: “If retain is all then both the Data Points having bool_var = true and bool_var = false are returned.”
- Expected:
bool_varis true for B, S, F and W, and false for G and M, whichDS_2has only withId_4= M, whereDS_1has Total; all six data points are returned.
DS_r := exists_in (DS_1, DS_2, all);
| Id_1 | Id_2 | Id_3 | Id_4 | Me_1 |
|---|---|---|---|---|
| 2012 | B | Total | Total | 11094850 |
| 2012 | G | Total | Total | 11123034 |
| 2012 | S | Total | Total | 46818219 |
| 2012 | M | Total | Total | 417546 |
| 2012 | F | Total | Total | 5401267 |
| 2012 | W | Total | Total | 7954662 |
| Id_1 | Id_2 | Id_3 | Id_4 | Me_1 |
|---|---|---|---|---|
| 2012 | B | Total | Total | 0.023 |
| 2012 | G | Total | M | 0.286 |
| 2012 | S | Total | Total | 0.064 |
| 2012 | M | Total | M | 0.043 |
| 2012 | F | Total | Total | |
| 2012 | W | Total | Total | 0.08 |
| Id_1 | Id_2 | Id_3 | Id_4 | bool_var |
|---|---|---|---|---|
| 2012 | B | Total | Total | true |
| 2012 | G | Total | Total | false |
| 2012 | S | Total | Total | true |
| 2012 | M | Total | Total | false |
| 2012 | F | Total | Total | true |
| 2012 | W | Total | Total | true |
Files: script.vtl · input/DS_1.csv · input/DS_1.json · input/DS_2.csv · input/DS_2.json · expected/DS_r.csv · expected/DS_r.json · example page ↗