← cross_join operator page · join/cross_join/rename/manual_ex_1
pandas ✅ · DuckDB ✅
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.
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.
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.
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 );
| Id_1 | Id_2 | Me_1 | Me_2 |
|---|---|---|---|
| 1 | A | A | B |
| 1 | B | C | D |
| 2 | A | E | F |
{
"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}
]
}
]
}
| Id_1 | Id_2 | Me_1A | Me_2 |
|---|---|---|---|
| 1 | A | B | Q |
| 1 | B | S | T |
| 3 | A | Z | M |
{
"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}
]
}
]
}
| Id_11 | Id_12 | Id_21 | Id_22 | Me_1 | Me_12 | Me_1A | Me_2 |
|---|---|---|---|---|---|---|---|
| 1 | A | 1 | A | A | B | B | Q |
| 1 | A | 1 | B | A | B | S | T |
| 1 | A | 3 | A | A | B | Z | M |
| 1 | B | 1 | A | C | D | B | Q |
| 1 | B | 1 | B | C | D | S | T |
| 1 | B | 3 | A | C | D | Z | M |
| 2 | A | 1 | A | E | F | B | Q |
| 2 | A | 1 | B | E | F | S | T |
| 2 | A | 3 | A | E | F | Z | M |
{
"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"}
]
}
]
}