← pivot operator page · clause/pivot/basic/missing_combination_is_null

Missing combination is null 🟢 all ok

pandas ✅ · DuckDB ✅

Tests:

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.

Manual:

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."

Expected:

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.

script.vtl ⇩

DS_r := DS_1 [ pivot Id_2, Me_1 ];

input/DS_1.csv ⇩

Id_1Id_2Me_1
1A5
1B2
2A3

input/DS_1.json ⇩

{
  "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}
      ]
    }
  ]
}

expected/DS_r.csv ⇩

Id_1AB
152
23

expected/DS_r.json ⇩

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

value_domains/VD_1.json ⇩

{
  "name": "VD_1",
  "type": "String",
  "setlist": [
    "A",
    "B"
  ]
}