← inner_join operator page · join/inner_join/calc_default/manual_ex_3

Manual example 3 🟢 all ok

pandas ✅ · DuckDB ✅

Tests:

filter, then calc Me_2 := Me_2 || "_NEW" with no role, then keep, in a join of one operand.

Manual:

Inner Join, Example 3, output verbatim: "If a generated component already exists in any of the input data sets, all input components homonymous to the former are removed, and only the generated component is kept". The page asks for "a minimum of two data set operands", but the grammar (joinClauseItem (COMMA joinClauseItem)*?) accepts one and the page prints its result, so the example is kept as it is.

Expected:

VDS₁ is DS_1; filter Id_2 = "B" keeps (1,B), where the calc gives Me_2 = D_NEW, a Measure as "if the role is not specified, it will be measure", and keep keeps it with Me_1 = C.

script.vtl ⇩

DS_r := inner_join ( DS_1  filter Id_2 ="B" calc Me_2 := Me_2 || "_NEW" keep Me_1, Me_2);

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

expected/DS_r.csv ⇩

Id_1Id_2Me_1Me_2
1BCD_NEW

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