← intersect operator page · set/intersect/two/leftmost_wins_when_measures_differ

Leftmost wins when measures differ 🟢 all ok

pandas ✅ · DuckDB ✅

Tests:

intersect(DS_1, DS_2) where ids 2 and 3 are in both operands with different measures (the page's example shares one data point, with the same measure in both), to show whether data points are matched by identifiers alone and which one is kept. The measure is 10 * Id_1 + k, with k 0 for DS_1 and 1 for DS_2, so its last digit names the operand.

Manual:

Intersection: duplicate Data Points "are filtered by choosing the Data Point belonging to the leftmost operand Data Set"; the User Manual: "The Data Points common (or not common) to the input Data Sets are determined by taking into account only the values of the Identifiers".

Expected:

Me_1 is 20 and 30 for ids 2 and 3, the values of DS_1, the leftmost operand; ids 1 and 4 are each in one operand only, so they are out.

script.vtl ⇩

DS_r := intersect(DS_1, DS_2);

input/DS_1.csv ⇩

Id_1Me_1
110
220
330

input/DS_1.json ⇩

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

input/DS_2.csv ⇩

Id_1Me_1
221
331
441

input/DS_2.json ⇩

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

expected/DS_r.csv ⇩

Id_1Me_1
220
330

expected/DS_r.json ⇩

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