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

Attribute becomes measure 🟢 all ok

pandas ✅ · DuckDB ✅

Tests:

calc At_1 := At_1 || "x": At_1, a plain (not viral) Attribute of DS_1, recalculated under its own name, with the role left out.

Manual:

Inner Join: VDS₁ has the identifiers and the measures of the operands, and "The viral attributes, coming from any number of Data Sets, which appear once", and no other attribute, so the clause could not read At_1 (error 1-1-1-10); in calc, "if the role is not specified, it will be measure".

Expected:

the join keeps (1,A), (1,B) and (2,A) ((2,B) is in DS_1 only), and At_1 is a Measure: ax, bx and cx.

Team decision:

#1258: the joins keep their non-viral Attributes until the VTL Task Force settles sdmx-twg/vtl#730, "Attributes in joins should be treated as measures": dropping them "may have many unintended implications in the use of non-viral attributes".

script.vtl ⇩

DS_r := inner_join(DS_1, DS_2 calc At_1 := At_1 || "x");

input/DS_1.csv ⇩

Id_1Id_2Me_1At_1
1A10a
1B20b
2A30c
2B40d

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

input/DS_2.csv ⇩

Id_1Id_2Me_2
1A1
1B2
2A3

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
1A101ax
1B202bx
2A303cx

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