← left_join operator page · join/left_join/keep/manual_ex_1
pandas ✅ · DuckDB ✅
keep Me_1, d2#Me_2, Me_1A on two operands that both have Me_2: the aliases let d2#Me_2 name one of them.
Left Join, Example 1, output verbatim: DS_2 has the identifiers of DS_1, so "the using clause is optional", and where a key is not in DS_2 the "Measures coming from that data set take the null value of their respective domains".
the three keys of DS_1; (2,A) is not in DS_2, so its Me_2 and Me_1A are null. d1#Me_2 goes and d2#Me_2 becomes Me_2.
DS_r := left_join ( DS_1 as d1, DS_2 as d2 keep Me_1, d2#Me_2, Me_1A );
| 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_1 | Id_2 | Me_1 | Me_2 | Me_1A |
|---|---|---|---|---|
| 1 | A | A | Q | B |
| 1 | B | C | T | S |
| 2 | A | E |
{
"datasets": [
{
"name": "DS_r",
"DataStructure": [
{"name": "Id_1", "type": "Integer", "role": "Identifier"},
{"name": "Id_2", "type": "String", "role": "Identifier"},
{"name": "Me_1", "type": "String", "role": "Measure"},
{"name": "Me_2", "type": "String", "role": "Measure"},
{"name": "Me_1A", "type": "String", "role": "Measure"}
]
}
]
}