← inner_join operator page · join/inner_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.
Inner 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 join keeps (1,A), (1,B) and (2,A) ((2,B) is in DS_1 only), and At_1 is a Measure: ax, bx and cx.
#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 := inner_join(DS_1, DS_2 calc At_1 := At_1 || "x");
| Id_1 | Id_2 | Me_1 | At_1 |
|---|---|---|---|
| 1 | A | 10 | a |
| 1 | B | 20 | b |
| 2 | A | 30 | c |
| 2 | B | 40 | d |
{
"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": "Number", "role": "Measure", "nullable": true},
{"name": "At_1", "type": "String", "role": "Attribute", "nullable": true}
]
}
]
}
| Id_1 | Id_2 | Me_2 |
|---|---|---|
| 1 | A | 1 |
| 1 | B | 2 |
| 2 | A | 3 |
{
"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_2", "type": "Number", "role": "Measure", "nullable": true}
]
}
]
}
| Id_1 | Id_2 | Me_1 | Me_2 | At_1 |
|---|---|---|---|---|
| 1 | A | 10 | 1 | ax |
| 1 | B | 20 | 2 | bx |
| 2 | A | 30 | 3 | cx |
{
"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"}
]
}
]
}