← setdiff operator page · set/setdiff/two/manual_ex_1

Manual example 1 🟢 all ok

pandas ✅ · DuckDB ✅

Tests:

setdiff ( DS_1, DS_2 ): five of the six data points of DS_1 are also in DS_2, with the same measures, and DS_2 has one that DS_1 lacks.

Manual:

Set difference, Example 1, output verbatim: the operator returns a Data Set "containing the Data Points that appear in the first Data Set but not in the second".

Expected:

the page's one data point, (2012, B, Total, Total) with the measure 10. The (2011, B, Total, Total) of DS_2 is not in DS_1, so it adds nothing.

script.vtl ⇩

DS_r := setdiff ( DS_1, DS_2 );

input/DS_1.csv ⇩

Id_1Id_2Id_3Id_4Me_1
2012BTotalTotal10
2012GTotalTotal20
2012FTotalTotal30
2012MTotalTotal40
2012ITotalTotal50
2012STotalTotal60

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_2.csv ⇩

Id_1Id_2Id_3Id_4Me_1
2011BTotalTotal10
2012GTotalTotal20
2012FTotalTotal30
2012MTotalTotal40
2012ITotalTotal50
2012STotalTotal60

input/DS_2.json ⇩

{
  "datasets": [
    {
      "name": "DS_2",
      "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
2012BTotalTotal10

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