← intersect operator page · set/intersect/n/point_in_all_three_operands

Point in all three operands 🟢 all ok

pandas ✅ · DuckDB ✅

Tests:

intersect(DS_1, DS_2, DS_3), the list form with three operands, where the page's example has two: ids 3 and 4 are in all three, and ids 1, 2 and 5 are each in two, lacking DS_2, DS_3 and DS_1 in turn. The measure is 10 * Id_1 + k, with k 0, 1 and 2 for DS_1, DS_2 and DS_3.

Manual:

Intersection: dsList ::= ds { , ds }*, the resulting Data Set "contains the Data Points belonging to all the operand Data Sets", and duplicate Data Points "are filtered by choosing the Data Point belonging to the leftmost operand Data Set".

Expected:

Me_1 is 30 and 40 for ids 3 and 4, the values of DS_1. Leaving out DS_1, DS_2 or DS_3 would add id 5, 1 or 2, so every operand takes part in the intersection.

script.vtl ⇩

DS_r := intersect(DS_1, DS_2, DS_3);

input/DS_1.csv ⇩

Id_1Me_1
110
220
330
440

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
551

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

input/DS_3.csv ⇩

Id_1Me_1
112
332
442
552

input/DS_3.json ⇩

{
  "datasets": [
    {
      "name": "DS_3",
      "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
330
440

expected/DS_r.json ⇩

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