← inner_join operator page · join/inner_join/bare/one_shared_identifier

One shared identifier 🟢 all ok

pandas ✅ · DuckDB ✅

Tests:

a natural join of DS_1 (Id_1, Id_2) and DS_2 (Id_2, Id_3): they share Id_2, and neither has all the identifiers of the other.

Manual:

Inner Join: inner_join requires "that there exists a permutation of the join operands such that each operand has at least one identifier in common with any of the operands preceding it", and joins on "all the identifiers appearing in more than one dataset".

Expected:

the key is Id_2. A pairs the data point of DS_1 with both of DS_2, so the result has Id_1, Id_2, Id_3 = (1,A,X) and (1,A,Y); B and C have no match.

script.vtl ⇩

DS_r := inner_join(DS_1, DS_2);

input/DS_1.csv ⇩

Id_1Id_2Me_1
1A10
2B20

input/DS_1.json ⇩

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

input/DS_2.csv ⇩

Id_2Id_3Me_2
AX1
AY2
CX3

input/DS_2.json ⇩

{
  "datasets": [
    {
      "name": "DS_2",
      "DataStructure": [
        {"name": "Id_2", "type": "String", "role": "Identifier", "nullable": false},
        {"name": "Id_3", "type": "String", "role": "Identifier", "nullable": false},
        {"name": "Me_2", "type": "Number", "role": "Measure", "nullable": true}
      ]
    }
  ]
}

expected/DS_r.csv ⇩

Id_1Id_2Id_3Me_1Me_2
1AX101
1AY102

expected/DS_r.json ⇩

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