← cross_join operator page · join/cross_join/calc_default/attribute_becomes_measure
pandas ✅ · DuckDB ✅
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.
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".
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.
#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".
DS_r := cross_join(DS_1, DS_2 calc At_1 := At_1 || "x");
| Id_1 | Me_1 | At_1 |
|---|---|---|
| 1 | 10 | a |
| 2 | 20 | b |
{
"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}
]
}
]
}
| Id_2 | Me_2 |
|---|---|
| A | 1 |
| B | 2 |
{
"datasets": [
{
"name": "DS_2",
"DataStructure": [
{"name": "Id_2", "type": "String", "role": "Identifier", "nullable": false},
{"name": "Me_2", "type": "Number", "role": "Measure", "nullable": true}
]
}
]
}
| Id_1 | Id_2 | Me_1 | Me_2 | At_1 |
|---|---|---|---|---|
| 1 | A | 10 | 1 | ax |
| 1 | B | 10 | 2 | ax |
| 2 | A | 20 | 1 | bx |
| 2 | B | 20 | 2 | bx |
{
"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"}
]
}
]
}