← union operator page · set/union/two/manual_ex_2

Manual example 2 🟢 all ok

pandas ✅ · DuckDB ✅

Tests:

union ( DS_1, DS_3 ): two data sets that share one data point, (2012, B, Total, Total), with the measure 5 in DS_1 and 23 in DS_3.

Manual:

Union, Example 2, output verbatim: duplicate Data Points "are filtered by choosing the Data Point belonging to the left most operand Data Set".

Expected:

the page's four data points: (2012, B, Total, Total) has the measure 5 of DS_1, the leftmost operand, and not the 23 of DS_3.

script.vtl ⇩

DS_r := union ( DS_1, DS_3 );

input/DS_1.csv ⇩

Id_1Id_2Id_3Id_4Me_1
2012BTotalTotal5
2012GTotalTotal2
2012FTotalTotal3

input/DS_1.json ⇩

{
  "datasets": [
    {
      "name": "DS_1",
      "DataStructure": [
        {"name": "Id_1", "type": "Time_Period", "role": "Identifier", "nullable": false},
        {"name": "Id_2", "type": "String", "role": "Identifier", "nullable": false},
        {"name": "Id_3", "type": "String", "role": "Identifier", "nullable": false},
        {"name": "Id_4", "type": "String", "role": "Identifier", "nullable": false},
        {"name": "Me_1", "type": "Integer", "role": "Measure", "nullable": true}
      ]
    }
  ]
}

input/DS_3.csv ⇩

Id_1Id_2Id_3Id_4Me_1
2012BTotalTotal23
2012STotalTotal5

input/DS_3.json ⇩

{
  "datasets": [
    {
      "name": "DS_3",
      "DataStructure": [
        {"name": "Id_1", "type": "Time_Period", "role": "Identifier", "nullable": false},
        {"name": "Id_2", "type": "String", "role": "Identifier", "nullable": false},
        {"name": "Id_3", "type": "String", "role": "Identifier", "nullable": false},
        {"name": "Id_4", "type": "String", "role": "Identifier", "nullable": false},
        {"name": "Me_1", "type": "Integer", "role": "Measure", "nullable": true}
      ]
    }
  ]
}

expected/DS_r.csv ⇩

Id_1Id_2Id_3Id_4Me_1
2012BTotalTotal5
2012GTotalTotal2
2012FTotalTotal3
2012STotalTotal5

expected/DS_r.json ⇩

{
  "datasets": [
    {
      "name": "DS_r",
      "DataStructure": [
        {"name": "Id_1", "type": "Time_Period", "role": "Identifier"},
        {"name": "Id_2", "type": "String", "role": "Identifier"},
        {"name": "Id_3", "type": "String", "role": "Identifier"},
        {"name": "Id_4", "type": "String", "role": "Identifier"},
        {"name": "Me_1", "type": "Integer", "role": "Measure"}
      ]
    }
  ]
}