← cross_join operator page · join/cross_join/aliases/alias_prefixed_measures

Alias prefixed measures 🟢 all ok

pandas ✅ · DuckDB ✅

Tests:

the measure Me_1 of both operands, named through the aliases (d1#Me_1, d2#Me_1) and renamed: the result depends on the operand each alias stands for.

Manual:

Cross Join: the components of several data sets are in VDS₁ once per data set, and their "names ... are prefixed with the alias of the data set they come from, separated by the “#” symbol".

Expected:

the cartesian product of DS_1 (Id_1 1, 2) and DS_2 (Id_2 A, B) has 2 × 2 = 4 data points: Me_11 holds the values of DS_1 (10, 10, 20, 20) and Me_12 those of DS_2 (1, 2, 1, 2). An engine that swapped the aliases would swap the columns.

script.vtl ⇩

DS_r := cross_join(DS_1 as d1, DS_2 as d2 rename d1#Me_1 to Me_11, d2#Me_1 to Me_12);

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_1
A1
B2

input/DS_2.json ⇩

{
  "datasets": [
    {
      "name": "DS_2",
      "DataStructure": [
        {"name": "Id_2", "type": "String", "role": "Identifier", "nullable": false},
        {"name": "Me_1", "type": "Number", "role": "Measure", "nullable": true}
      ]
    }
  ]
}

expected/DS_r.csv ⇩

Id_1Id_2Me_11Me_12
1A101
1B102
2A201
2B202

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_11", "type": "Number", "role": "Measure"},
        {"name": "Me_12", "type": "Number", "role": "Measure"}
      ]
    }
  ]
}