← case operator page · conditional/case/ds/unmatched_data_point_left_out
pandas ✅ · DuckDB ✅
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.
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).
(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.
DS_c := DS_1 > 10; DS_r := case when DS_c then DS_2 else DS_3;
| Id_1 | Me_1 |
|---|---|
| 1 | 5 |
| 2 | 15 |
| 3 | 25 |
| 4 | 8 |
{
"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 |
| 4 | 400 |
{
"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 |
|---|---|
| 2 | 22 |
| 3 | 33 |
| 4 | 44 |
{
"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 |
|---|---|
| 2 | 200 |
| 3 | 300 |
| 4 | 44 |
{
"datasets": [
{
"name": "DS_r",
"DataStructure": [
{"name": "Id_1", "type": "Integer", "role": "Identifier"},
{"name": "Me_1", "type": "Integer", "role": "Measure"}
]
}
]
}