← inner_join operator page · join/inner_join/apply/manual_ex_4

Manual example 4 🟢 all ok

pandas ✅ · DuckDB ✅

Tests:

apply d1 || d2, written with the aliases, on two operands that both have Me_1 and Me_2.

Manual:

Inner Join, Example 4, output verbatim: "apply combines the homonym Measures in the source operands", and "The expression applyExpr can use as input the names or aliases of the operand data sets".

Expected:

the join keeps (1,A) and (1,B): Me_1 := d1#Me_1 || d2#Me_1 gives AB and CS, Me_2 := d1#Me_2 || d2#Me_2 gives BQ and DT.

script.vtl ⇩

DS_r := inner_join (DS_1 as d1, DS_3 as d2 apply d1 || d2);

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_3.csv ⇩

Id_1Id_2Me_1Me_2
1ABQ
1BST
3AZM

input/DS_3.json ⇩

{
  "datasets": [
    {
      "name": "DS_3",
      "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}
      ]
    }
  ]
}

expected/DS_r.csv ⇩

Id_1Id_2Me_1Me_2
1AABBQ
1BCSDT

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