← full_join operator page · join/full_join/keep/manual_ex_1

Manual example 1 🟢 all ok

pandas ✅ · DuckDB ✅

Tests:

keep Me_1, d2#Me_2, Me_1A on two operands that both have Me_2: the aliases let d2#Me_2 name one of them.

Manual:

Full Join, Example 1, output verbatim: "an additional data point is added to this set for each data point in the current join operand that wasn't matched before", with null measures.

Expected:

(1,A) and (1,B), in both; (2,A), in DS_1 only, with Me_2 and Me_1A null; (3,A), in DS_2 only, with Me_1 null. d1#Me_2 goes and d2#Me_2 becomes Me_2.

script.vtl ⇩

DS_r := full_join ( DS_1 as d1, DS_2 as d2 keep Me_1, d2#Me_2, Me_1A );

input/DS_1.csv ⇩

Id_1Id_2Me_1Me_2
1AAB
1BCD
2AEF

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": "String", "role": "Measure", "nullable": true},
        {"name": "Me_2", "type": "String", "role": "Measure", "nullable": true}
      ]
    }
  ]
}

input/DS_2.csv ⇩

Id_1Id_2Me_1AMe_2
1ABQ
1BST
3AZM

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_1A", "type": "String", "role": "Measure", "nullable": true},
        {"name": "Me_2", "type": "String", "role": "Measure", "nullable": true}
      ]
    }
  ]
}

expected/DS_r.csv ⇩

Id_1Id_2Me_1Me_2Me_1A
1AAQB
1BCTS
2AE
3AMZ

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": "String", "role": "Measure"},
        {"name": "Me_2", "type": "String", "role": "Measure"},
        {"name": "Me_1A", "type": "String", "role": "Measure"}
      ]
    }
  ]
}