← case operator page · conditional/case/ds/unmatched_data_point_left_out

Unmatched data point left out 🟢 all ok

pandas ✅ · DuckDB ✅

Tests:

case when DS_c then DS_2 else DS_3, where the condition DS_c := DS_1 > 10 has a data point, Id_1 = 1, that DS_3 lacks. The condition is named, so that the example shows only how the branches are joined and does not depend on how an engine handles an inline condition.

Manual:

Case: "its true Data Points are inner joined with thenOperand and its false Data Points are inner joined with elseOperand, finally the union is made of these two partial results"; and "Data Points that are not coupled are left out" (Typical behaviours).

Expected:

(2, 200), (3, 300) and (4, 44): ids 2 and 3 are true and come from DS_2; ids 1 and 4 are false, and DS_3 has 4 but not 1, so id 1 is left out. DS_3's values for ids 2 and 3 are not used.

script.vtl ⇩

DS_c := DS_1 > 10;
DS_r := case when DS_c then DS_2 else DS_3;

input/DS_1.csv ⇩

Id_1Me_1
15
215
325
48

input/DS_1.json ⇩

{
  "datasets": [
    {
      "name": "DS_1",
      "DataStructure": [
        {"name": "Id_1", "type": "Integer", "role": "Identifier", "nullable": false},
        {"name": "Me_1", "type": "Integer", "role": "Measure", "nullable": true}
      ]
    }
  ]
}

input/DS_2.csv ⇩

Id_1Me_1
1100
2200
3300
4400

input/DS_2.json ⇩

{
  "datasets": [
    {
      "name": "DS_2",
      "DataStructure": [
        {"name": "Id_1", "type": "Integer", "role": "Identifier", "nullable": false},
        {"name": "Me_1", "type": "Integer", "role": "Measure", "nullable": true}
      ]
    }
  ]
}

input/DS_3.csv ⇩

Id_1Me_1
222
333
444

input/DS_3.json ⇩

{
  "datasets": [
    {
      "name": "DS_3",
      "DataStructure": [
        {"name": "Id_1", "type": "Integer", "role": "Identifier", "nullable": false},
        {"name": "Me_1", "type": "Integer", "role": "Measure", "nullable": true}
      ]
    }
  ]
}

expected/DS_r.csv ⇩

Id_1Me_1
2200
3300
444

expected/DS_r.json ⇩

{
  "datasets": [
    {
      "name": "DS_r",
      "DataStructure": [
        {"name": "Id_1", "type": "Integer", "role": "Identifier"},
        {"name": "Me_1", "type": "Integer", "role": "Measure"}
      ]
    }
  ]
}