← unpivot operator page · clause/unpivot/basic/manual_ex_2

Manual example 2 🟢 all ok

pandas ✅ · DuckDB ✅

Tests:

unpivot Id_3, Me_2, on the measures A (Number), B and C (Integer).

Manual:

Unpivoting, Example 2, output verbatim: "All the measures of op must have the same basic scalar type, including sub-types", which accepts them, as Integer is a sub-type of Number. The manual's ds_2.json names its dataset DS_1, a slip: the example loads it as DS_2, the name that the page and the script give it.

Expected:

Nine data points, with Me_2 typed Number, as the manual types it. The manual prints 2.1 for (6, A) with trailing spaces, which the importer stripped, as for every non-String value.

script.vtl ⇩

DS_r := DS_2 [ unpivot Id_3, Me_2 ];

input/DS_2.csv ⇩

Id_1ABC
43.116
54.223
62.132

input/DS_2.json ⇩

{
  "datasets": [
    {
      "name": "DS_2",
      "DataStructure": [
        {"name": "Id_1", "type": "Integer", "role": "Identifier", "nullable": false},
        {"name": "A", "type": "Number", "role": "Measure", "nullable": true},
        {"name": "B", "type": "Integer", "role": "Measure", "nullable": true},
        {"name": "C", "type": "Integer", "role": "Measure", "nullable": true}
      ]
    }
  ]
}

expected/DS_r.csv ⇩

Id_1Id_3Me_2
4A3.1
5A4.2
6A2.1
4B1
5B2
6B3
4C6
5C3
6C2

expected/DS_r.json ⇩

{
  "datasets": [
    {
      "name": "DS_r",
      "DataStructure": [
        {"name": "Id_1", "type": "Integer", "role": "Identifier"},
        {"name": "Id_3", "type": "String", "role": "Identifier"},
        {"name": "Me_2", "type": "Number", "role": "Measure"}
      ]
    }
  ]
}