← cross_join operator page · join/cross_join/rename/manual_ex_1

Manual example 1 🟢 all ok

pandas ✅ · DuckDB ✅

Tests:

renames, through the aliases, of the four identifiers and of d1#Me_2, on two operands that both have Id_1, Id_2 and Me_2.

Manual:

Cross Join, Example 1, output verbatim: "a data point in VDS₁ is generated for each pair of data points in the partial result and the joined data set", and the prefixes of the components of several data sets are stripped at the end.

Expected:

3 × 3 = 9 data points with Id_11, Id_12, Id_21, Id_22, Me_1, Me_12, Me_1A and Me_2 (d2#Me_2 stripped). Without the renames, the stripping would give two Id_1, Id_2 and Me_2, an error.

script.vtl ⇩

DS_r := cross_join (DS_1 as d1, DS_2 as d2 rename d1#Id_1 to Id_11, d1#Id_2 to Id_12, d2#Id_1 to Id_21, d2#Id_2 to Id_22, d1#Me_2 to Me_12 );

input/DS_1.csv ⇩

Id_1Id_2Me_1Me_2
1AAB
1BCD
2AEF

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

input/DS_2.csv ⇩

Id_1Id_2Me_1AMe_2
1ABQ
1BST
3AZM

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

expected/DS_r.csv ⇩

Id_11Id_12Id_21Id_22Me_1Me_12Me_1AMe_2
1A1AABBQ
1A1BABST
1A3AABZM
1B1ACDBQ
1B1BCDST
1B3ACDZM
2A1AEFBQ
2A1BEFST
2A3AEFZM

expected/DS_r.json ⇩

{
  "datasets": [
    {
      "name": "DS_r",
      "DataStructure": [
        {"name": "Id_11", "type": "Integer", "role": "Identifier"},
        {"name": "Id_12", "type": "String", "role": "Identifier"},
        {"name": "Id_21", "type": "Integer", "role": "Identifier"},
        {"name": "Id_22", "type": "String", "role": "Identifier"},
        {"name": "Me_1", "type": "String", "role": "Measure"},
        {"name": "Me_12", "type": "String", "role": "Measure"},
        {"name": "Me_1A", "type": "String", "role": "Measure"},
        {"name": "Me_2", "type": "String", "role": "Measure"}
      ]
    }
  ]
}