← left_join operator page · join/left_join/aggr_attribute/max_as_attribute
pandas ✅ · DuckDB ✅
aggr with two components: the sum of Me_1 by Id_1 as the measure Me_3, and its maximum as At_1, with the role attribute.
Left Join: the role of an aggregated component is aggrRole ::= { measure | attribute | viral attribute }, and "if omitted, the Measure role is assumed"; "All non-identifier components are removed, and only the components generated by the sub-expressions are kept".
the left join keeps the four keys of DS_1, with Me_2 null at (1,B). Id_1 = 1 gives Me_3 = 30 and At_1 = 20, Id_1 = 2 gives 70 and 40; At_1 is a Number Attribute.
DS_r := left_join(DS_1, DS_2 aggr Me_3 := sum(Me_1), attribute At_1 := max(Me_1) group by Id_1);
| Id_1 | Id_2 | Me_1 |
|---|---|---|
| 1 | A | 10 |
| 1 | B | 20 |
| 2 | A | 30 |
| 2 | B | 40 |
{
"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}
]
}
]
}
| Id_1 | Id_2 | Me_2 |
|---|---|---|
| 1 | A | 1 |
| 1 | C | 2 |
| 2 | A | 3 |
| 2 | B | 4 |
{
"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 | Me_3 | At_1 |
|---|---|---|
| 1 | 30 | 20 |
| 2 | 70 | 40 |
{
"datasets": [
{
"name": "DS_r",
"DataStructure": [
{"name": "Id_1", "type": "Integer", "role": "Identifier"},
{"name": "Me_3", "type": "Number", "role": "Measure"},
{"name": "At_1", "type": "Number", "role": "Attribute"}
]
}
]
}