← exists_in operator page · comparison/exists_in/retain_all/manual_ex_1

Manual example 1 🟢 all ok

pandas ✅ · DuckDB ✅

Tests:

exists_in (DS_1, DS_2, all): every data point of DS_1 is returned, found in DS_2 or 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_var is true for B, S, F and W, and false for G and M, which DS_2 has only with Id_4 = M, where DS_1 has Total; all six data points are returned.

script.vtl ⇩

DS_r := exists_in (DS_1, DS_2, all);

input/DS_1.csv ⇩

Id_1Id_2Id_3Id_4Me_1
2012BTotalTotal11094850
2012GTotalTotal11123034
2012STotalTotal46818219
2012MTotalTotal417546
2012FTotalTotal5401267
2012WTotalTotal7954662

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": "Id_4", "type": "String", "role": "Identifier", "nullable": false},
        {"name": "Me_1", "type": "Integer", "role": "Measure", "nullable": true}
      ]
    }
  ]
}

input/DS_2.csv ⇩

Id_1Id_2Id_3Id_4Me_1
2012BTotalTotal0.023
2012GTotalM0.286
2012STotalTotal0.064
2012MTotalM0.043
2012FTotalTotal
2012WTotalTotal0.08

input/DS_2.json ⇩

{
  "datasets": [
    {
      "name": "DS_2",
      "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": "Id_4", "type": "String", "role": "Identifier", "nullable": false},
        {"name": "Me_1", "type": "Number", "role": "Measure", "nullable": true}
      ]
    }
  ]
}

expected/DS_r.csv ⇩

Id_1Id_2Id_3Id_4bool_var
2012BTotalTotaltrue
2012GTotalTotalfalse
2012STotalTotaltrue
2012MTotalTotalfalse
2012FTotalTotaltrue
2012WTotalTotaltrue

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": "Id_4", "type": "String", "role": "Identifier"},
        {"name": "bool_var", "type": "Boolean", "role": "Measure"}
      ]
    }
  ]
}