← inner_join operator page · join/inner_join/using/subset_of_identifiers

Subset of identifiers 🟢 all ok

pandas ✅ · DuckDB ✅

Tests:

using Id_1 only, on operands with Id_1 and Id_2 that share no (Id_1, Id_2) key; the renames name the two Id_2.

Manual:

Inner Join: with using, it "only uses the remaining identifiers as join keys"; the other components of several data sets "appear as many times as the data sets they come from", with a prefix.

Expected:

Id_1 = 1 pairs both data points of DS_1 with the one of DS_2: (1,A,C) and (1,B,C) as Id_1, Id_21, Id_22. The natural join would match nothing, and without the renames, stripping the prefixes would give two Id_2, an error.

script.vtl ⇩

DS_r := inner_join(DS_1 as d1, DS_2 as d2 using Id_1 rename d1#Id_2 to Id_21, d2#Id_2 to Id_22);

input/DS_1.csv ⇩

Id_1Id_2Me_1
1A10
1B20
2B30

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_1Id_2Me_2
1C1
3D3

input/DS_2.json ⇩

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

expected/DS_r.csv ⇩

Id_1Id_21Id_22Me_1Me_2
1AC101
1BC201

expected/DS_r.json ⇩

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