← inner_join operator page · join/inner_join/calc_attribute/constant_attribute

Constant attribute 🟢 all ok

pandas ✅ · DuckDB ✅

Tests:

calc attribute At_1 := "EP", a constant attribute.

Manual:

Inner Join: "calc calculates new components by independent sub-expressions evaluated at component level. The role of the new components can be specified". The calc clause page has the same calculation, DS_1 [ calc attribute At_1:= "EP" ] (its Example 2).

Expected:

the natural join keeps (1,A), (2,A) and (2,B), the keys in both operands, and each gets the String Attribute At_1 = EP.

script.vtl ⇩

DS_r := inner_join(DS_1, DS_2 calc attribute At_1 := "EP");

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_2At_1
1A101EP
2A303EP
2B404EP

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"},
        {"name": "At_1", "type": "String", "role": "Attribute"}
      ]
    }
  ]
}