← case operator page · conditional/case/ds/inline_dataset_condition
pandas ✅ · DuckDB ✅
case when DS_1 > 10 then DS_2 else DS_3: a data set condition written inline, with data sets as branches.
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".
(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.
DS_r := case when DS_1 > 10 then DS_2 else DS_3;
| Id_1 | Me_1 |
|---|---|
| 1 | 5 |
| 2 | 15 |
| 3 | 25 |
{
"datasets": [
{
"name": "DS_1",
"DataStructure": [
{"name": "Id_1", "type": "Integer", "role": "Identifier", "nullable": false},
{"name": "Me_1", "type": "Integer", "role": "Measure", "nullable": true}
]
}
]
}
| Id_1 | Me_1 |
|---|---|
| 1 | 100 |
| 2 | 200 |
| 3 | 300 |
{
"datasets": [
{
"name": "DS_2",
"DataStructure": [
{"name": "Id_1", "type": "Integer", "role": "Identifier", "nullable": false},
{"name": "Me_1", "type": "Integer", "role": "Measure", "nullable": true}
]
}
]
}
| Id_1 | Me_1 |
|---|---|
| 1 | 1 |
| 2 | 2 |
| 3 | 3 |
{
"datasets": [
{
"name": "DS_3",
"DataStructure": [
{"name": "Id_1", "type": "Integer", "role": "Identifier", "nullable": false},
{"name": "Me_1", "type": "Integer", "role": "Measure", "nullable": true}
]
}
]
}
| Id_1 | Me_1 |
|---|---|
| 1 | 1 |
| 2 | 200 |
| 3 | 300 |
{
"datasets": [
{
"name": "DS_r",
"DataStructure": [
{"name": "Id_1", "type": "Integer", "role": "Identifier"},
{"name": "Me_1", "type": "Integer", "role": "Measure"}
]
}
]
}