← left_join operator page · join/left_join/bare/left_keys_kept

Left keys kept 🟢 all ok

pandas ✅ · DuckDB ✅

Tests:

the left join of two operands with the same identifiers, with no clause.

Manual:

Left Join: when "all the join operands from the second on have exactly the same identifiers and the left-most operand contains them all", "the using clause is optional"; the join is "according to SQL left-outer join", and the "Measures coming from that data set take the null value" when a key is not found.

Expected:

the four keys of DS_1, (1,A), (1,B), (2,A) and (2,B), with Me_2 null at (1,B); (1,C) is in DS_2 only and is not kept.

script.vtl ⇩

DS_r := left_join(DS_1, DS_2);

input/DS_1.csv ⇩

Id_1Id_2Me_1
1A10
1B20
2A30
2B40

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
1A1
1C2
2A3
2B4

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_2Me_1Me_2
1A101
1B20
2A303
2B404

expected/DS_r.json ⇩

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