← cross_join operator page · join/cross_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:

Cross 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 cartesian product of DS_1 (Id_1 1, 2) and DS_2 (Id_2 A, B) has 2 × 2 = 4 data points, and At_1 is a Measure: ax, ax, bx and bx.

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 := cross_join(DS_1, DS_2 calc At_1 := At_1 || "x");

input/DS_1.csv ⇩

Id_1Me_1At_1
110a
220b

input/DS_1.json ⇩

{
  "datasets": [
    {
      "name": "DS_1",
      "DataStructure": [
        {"name": "Id_1", "type": "Integer", "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_2Me_2
A1
B2

input/DS_2.json ⇩

{
  "datasets": [
    {
      "name": "DS_2",
      "DataStructure": [
        {"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
1B102ax
2A201bx
2B202bx

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