← cross_join operator page · join/cross_join/calc_measure/explicit_measure_role

Explicit measure role 🟢 all ok

pandas ✅ · DuckDB ✅

Tests:

calc measure Me_3 := Me_1 + Me_2, with the role keyword written out.

Manual:

Cross Join: "calc calculates new components by independent sub-expressions evaluated at component level. The role of the new components can be specified".

Expected:

the cartesian product of DS_1 (Id_1 1, 2) and DS_2 (Id_2 A, B) has 2 × 2 = 4 data points. The input components stay and Me_3 is added: 11, 12, 21 and 22.

script.vtl ⇩

DS_r := cross_join(DS_1, DS_2 calc measure Me_3 := Me_1 + Me_2);

input/DS_1.csv ⇩

Id_1Me_1
110
220

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

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_2Me_3
1A10111
1B10212
2A20121
2B20222

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": "Me_3", "type": "Number", "role": "Measure"}
      ]
    }
  ]
}