← left_join operator page · join/left_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:

Left Join, Example 1, output verbatim: DS_2 has the identifiers of DS_1, so "the using clause is optional", and where a key is not in DS_2 the "Measures coming from that data set take the null value of their respective domains".

Expected:

the three keys of DS_1; (2,A) is not in DS_2, so its Me_2 and Me_1A are null. d1#Me_2 goes and d2#Me_2 becomes Me_2.

script.vtl ⇩

DS_r := left_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

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