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

Manual example 1 🟢 all ok

pandas ✅ · DuckDB ✅

Tests:

pivot Id_2, Me_1, on a data set with the attribute At_1, whose virality is not defined.

Manual:

Pivoting, Example 1, output verbatim: "It drops the Identifier Component identifier and all the Measure Components from VDS", then "It groups VDS by the values of the remaining Identifiers".

Expected:

One data point per Id_1, with the Measures A, B and C: 5, 2, 7 and 3, 4, 9. At_1 is not kept: each group holds several of its values and the script gives "no explicit indication about the keeping of the Attribute", so by the User Manual "If the virality is not defined, the Attribute is considered as non-viral" and "the non-viral Attributes are not kept in the result and their values are not considered".

Erratum:

The page adds a Measure "for each distinct value of identifier in op" and types Id_2 String, but the Measures must be known without the data: they are the values of the value domain of Id_2 (1-1-6-18 without one), here VD_1, of A, B and C.

script.vtl ⇩

DS_r := DS_1 [ pivot Id_2, Me_1 ];

input/DS_1.csv ⇩

Id_1Id_2Me_1At_1
1A5E
1B2F
1C7F
2A3E
2B4E
2C9F

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},
        {"name": "At_1", "type": "String", "role": "Attribute", "nullable": true}
      ]
    }
  ]
}

expected/DS_r.csv ⇩

Id_1ABC
1527
2349

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"},
        {"name": "C", "type": "Integer", "role": "Measure"}
      ]
    }
  ]
}

value_domains/VD_1.json ⇩

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