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

Inline dataset condition 🟢 all ok

pandas ✅ · DuckDB ✅

Tests:

case when DS_1 > 10 then DS_2 else DS_3: a data set condition written inline, with data sets as branches.

Manual:

Case: "The same rules apply as for the if-then-else operator", and "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".

Expected:

(1, 1), (2, 200) and (3, 300): id 1 is false (5), so it comes from DS_3; ids 2 and 3 are true (15 and 25), so they come from DS_2. All three ids are in both branches, so none is left out.

script.vtl ⇩

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

input/DS_1.csv ⇩

Id_1Me_1
15
215
325

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

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
11
22
33

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
11
2200
3300

expected/DS_r.json ⇩

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