← pivot operator page · clause/pivot/basic/missing_combination_is_null
pandas ✅ · DuckDB ✅
pivot Id_2, Me_1, where Id_1 = 2 has no data point with Id_2 = B. Id_2 is defined on the value domain VD_1, of A and B, whose values give the Measures of the result.
Pivoting: "For each distinct value of identifier in op, it adds a corresponding measure to VDS, named as the value of identifier. These Measures are initialized with the null value."
Id_1 and the Measures A and B: 5 and 2 for Id_1 = 1, and 3 and null for Id_1 = 2, whose B keeps the null it was initialized with.
DS_r := DS_1 [ pivot Id_2, Me_1 ];
| Id_1 | Id_2 | Me_1 |
|---|---|---|
| 1 | A | 5 |
| 1 | B | 2 |
| 2 | A | 3 |
{
"datasets": [
{
"name": "DS_1",
"DataStructure": [
{"name": "Id_1", "type": "Integer", "role": "Identifier", "nullable": false},
{"name": "Id_2", "type": "VD_1", "role": "Identifier", "nullable": false},
{"name": "Me_1", "type": "Integer", "role": "Measure", "nullable": true}
]
}
]
}
| Id_1 | A | B |
|---|---|---|
| 1 | 5 | 2 |
| 2 | 3 |
{
"datasets": [
{
"name": "DS_r",
"DataStructure": [
{"name": "Id_1", "type": "Integer", "role": "Identifier"},
{"name": "A", "type": "Integer", "role": "Measure"},
{"name": "B", "type": "Integer", "role": "Measure"}
]
}
]
}
{
"name": "VD_1",
"type": "String",
"setlist": [
"A",
"B"
]
}