Full Join · full_join

🟢 23 of 23 forms all ok · VTL 2.2 Reference Manual ↗ · vtlengine 1.10.0rc2 (90ee9376) · pandas 2.3.3 · DuckDB 1.5.5
🟢 all ok🟡 partially implemented🛡️ refused with an error🔴 not implemented or crash🔵 engines differ ✅ match · ❌ wrong result · 🛡 guarded error (code) · 💥 crash · 📌 team decision
        ---
config:
  flowchart:
    useMaxWidth: false

---
flowchart LR
    classDef ok fill:#d4edda,stroke:#28a745,color:#000
    classDef partial fill:#fff3cd,stroke:#ffc107,color:#000
    classDef refused fill:#d4edda,stroke:#28a745,stroke-width:3px,stroke-dasharray: 2 2,color:#000
    classDef missing fill:#f8d7da,stroke:#dc3545,color:#000
    classDef diverge fill:#cce5ff,stroke:#007bff,color:#000
    classDef block fill:#2b3a4a,stroke:#2b3a4a,color:#fff,font-weight:bold
    classDef ext fill:#fff,stroke:#666,color:#000,stroke-dasharray: 5 5
    O["Full Join · full_join 📌<br/>🟢23"]:::ok
    v_bare["full_join(DS, DS)"]:::ok
    v_aliases["full_join(DS as a, DS as b)"]:::ok
    v_using["full_join(DS, DS using Id)"]:::ok
    v_using_nvl["full_join(DS, DS using Id, nvl(Id, c))"]:::ok
    v_filter["full_join(DS, DS filter cond)"]:::ok
    v_apply["full_join(DS, DS apply expr)"]:::ok
    v_calc_default["full_join(DS, DS calc C #58;#61; expr) 📌"]:::ok
    v_calc_measure["full_join(DS, DS calc measure C #58;#61; expr)"]:::ok
    v_calc_identifier["full_join(DS, DS calc identifier C #58;#61; expr)"]:::ok
    v_calc_attribute["full_join(DS, DS calc attribute C #58;#61; expr)"]:::ok
    v_calc_viral_attribute["full_join(DS, DS calc viral attribute C #58;#61; expr) 📌"]:::ok
    v_aggr_no_group["full_join(DS, DS aggr C #58;#61; agg)"]:::ok
    v_aggr_group_by["full_join(DS, DS aggr C #58;#61; agg group by Id) 📌"]:::ok
    v_aggr_group_except["full_join(DS, DS aggr C #58;#61; agg group except Id)"]:::ok
    v_aggr_group_all["full_join(DS, DS aggr C #58;#61; agg group all time_agg(p))"]:::ok
    v_aggr_having["full_join(DS, DS aggr C #58;#61; agg group by Id having cond)"]:::ok
    v_aggr_measure["full_join(DS, DS aggr measure C #58;#61; agg group by Id)"]:::ok
    v_aggr_attribute["full_join(DS, DS aggr C #58;#61; agg, attribute A #58;#61; agg group by Id)"]:::ok
    v_aggr_viral_attribute["full_join(DS, DS aggr C #58;#61; agg, viral attribute A #58;#61; agg group by Id) 📌"]:::ok
    v_keep["full_join(DS, DS keep C)"]:::ok
    v_drop["full_join(DS, DS drop C)"]:::ok
    v_rename["full_join(DS, DS rename C to C2)"]:::ok
    v_nary["full_join(DS, DS, DS)"]:::ok
    subgraph G_use["Used with"]
        direction LR
        used__clause__filter["filter ↗<br/><small>uses</small>"]:::ext
        used__clause__calc["calc ↗<br/><small>uses</small>"]:::ext
        used__clause__aggr["aggr ↗<br/><small>uses</small>"]:::ext
        used__clause__keep["keep ↗<br/><small>uses</small>"]:::ext
        used__clause__drop["drop ↗<br/><small>uses</small>"]:::ext
        used__clause__rename["rename ↗<br/><small>uses</small>"]:::ext
    end
    v_bare --- O
    v_aliases --- O
    v_using --- O
    v_using_nvl --- O
    v_filter --- O
    v_apply --- O
    v_calc_default --- O
    v_calc_measure --- O
    v_calc_identifier --- O
    v_calc_attribute --- O
    v_calc_viral_attribute --- O
    v_aggr_no_group --- O
    v_aggr_group_by --- O
    v_aggr_group_except --- O
    v_aggr_group_all --- O
    O --- v_aggr_having
    O --- v_aggr_measure
    O --- v_aggr_attribute
    O --- v_aggr_viral_attribute
    O --- v_keep
    O --- v_drop
    O --- v_rename
    O --- v_nary
    O -.- G_use
    style G_use fill:#ffffff,stroke:#868e96,stroke-width:1px,stroke-dasharray: 1 4
    click v_bare href "#form-bare"
    click v_aliases href "#form-aliases"
    click v_using href "#form-using"
    click v_using_nvl href "#form-using-nvl"
    click v_filter href "#form-filter"
    click v_apply href "#form-apply"
    click v_calc_default href "#form-calc-default"
    click v_calc_measure href "#form-calc-measure"
    click v_calc_identifier href "#form-calc-identifier"
    click v_calc_attribute href "#form-calc-attribute"
    click v_calc_viral_attribute href "#form-calc-viral-attribute"
    click v_aggr_no_group href "#form-aggr-no-group"
    click v_aggr_group_by href "#form-aggr-group-by"
    click v_aggr_group_except href "#form-aggr-group-except"
    click v_aggr_group_all href "#form-aggr-group-all"
    click v_aggr_having href "#form-aggr-having"
    click v_aggr_measure href "#form-aggr-measure"
    click v_aggr_attribute href "#form-aggr-attribute"
    click v_aggr_viral_attribute href "#form-aggr-viral-attribute"
    click v_keep href "#form-keep"
    click v_drop href "#form-drop"
    click v_rename href "#form-rename"
    click v_nary href "#form-nary"
    click used__clause__filter href "../clause/filter.html" "Filtering Data Points · filter"
    click used__clause__calc href "../clause/calc.html" "Calculation of a Component · calc"
    click used__clause__aggr href "../clause/aggr.html" "Aggregation · aggr"
    click used__clause__keep href "../clause/keep.html" "Maintaining Components · keep"
    click used__clause__drop href "../clause/drop.html" "Removal of Components · drop"
    click used__clause__rename href "../clause/rename.html" "Change of Component name · rename"
    

Types

Takes boolean, any scalar · Gives any type

Viral attributes: combined with the propagation rules → Viral propagation

Comes from: any operator that returns a value

Goes to: whatever takes its input's type

Forms

full_join(DS, DS) 🟢 · any scalar → any type

Keys of both kept 🟢 pandas ✅ · DuckDB ✅
Tests:

the full join of two operands with the same identifiers, with no clause.

Manual:

Full Join: when all the operands have the same identifiers, “the using clause is optional”; the join is “according to SQL full outer join”, and for a key that is not found “the Measures take the null value of their respective domains”.

Expected:

the five keys of both operands, with Me_2 null at (1,B) (in DS_1 only) and Me_1 null at (1,C) (in DS_2 only).

script.vtl
DS_r := full_join(DS_1, DS_2);
Input DS_1
Id_1Id_2Me_1
1A10
1B20
2A30
2B40
Input DS_2
Id_1Id_2Me_2
1A1
1C2
2A3
2B4
Expected DS_r
Id_1Id_2Me_1Me_2
1A101
1B20
1C2
2A303
2B404

Files: script.vtl · input/DS_1.csv · input/DS_1.json · input/DS_2.csv · input/DS_2.json · expected/DS_r.csv · expected/DS_r.json · example page ↗

full_join(DS as a, DS as b) 🟢 · any scalar → any type

Aliases without clause 🟢 pandas ✅ · DuckDB ✅
Tests:

aliases on the operands (as d1, as d2), with no clause.

Manual:

Full Join: the aliases are “valid only within the “join” operation to make it easier to refer to them”.

Expected:

the aliases do not change the result: that of Keys of both kept, the five keys with Me_2 null at (1,B) and Me_1 null at (1,C).

script.vtl
DS_r := full_join(DS_1 as d1, DS_2 as d2);
Input DS_1
Id_1Id_2Me_1
1A10
1B20
2A30
2B40
Input DS_2
Id_1Id_2Me_2
1A1
1C2
2A3
2B4
Expected DS_r
Id_1Id_2Me_1Me_2
1A101
1B20
1C2
2A303
2B404

Files: script.vtl · input/DS_1.csv · input/DS_1.json · input/DS_2.csv · input/DS_2.json · expected/DS_r.csv · expected/DS_r.json · example page ↗

Alias prefixed measures 🟢 pandas ✅ · DuckDB ✅
Tests:

the measure Me_1 of both operands, named through the aliases (d1#Me_1, d2#Me_1) and renamed: the result depends on the operand each alias stands for.

Manual:

Full Join: the components in several data sets are in VDS₁ once per data set, and their “names … are prefixed with the alias of the data set they come from, separated by the “#” symbol”.

Expected:

the five keys: Me_11 holds the values of DS_1 (10, 20, null, 30, 40) and Me_12 those of DS_2 (1, null, 2, 3, 4). An engine that swapped the aliases would swap the columns.

script.vtl
DS_r := full_join(DS_1 as d1, DS_2 as d2 rename d1#Me_1 to Me_11, d2#Me_1 to Me_12);
Input DS_1
Id_1Id_2Me_1
1A10
1B20
2A30
2B40
Input DS_2
Id_1Id_2Me_1
1A1
1C2
2A3
2B4
Expected DS_r
Id_1Id_2Me_11Me_12
1A101
1B20
1C2
2A303
2B404

Files: script.vtl · input/DS_1.csv · input/DS_1.json · input/DS_2.csv · input/DS_2.json · expected/DS_r.csv · expected/DS_r.json · example page ↗

full_join(DS, DS using Id) 🟢 · any scalar → any type

All common identifiers 🟢 pandas ✅ · DuckDB ✅
Tests:

using Id_1, Id_2 on operands with the same identifiers.

Manual:

Full Join: “The using clause is optional only if I_i = I_j … otherwise it is mandatory, and it must specify a subset of the identifiers common to every join operand. For every other identifier not included in the using clause, a nvl() expression must be specified.”

Expected:

both identifiers are named, so no nvl() is needed and the keys are those without using: the result of Keys of both kept.

script.vtl
DS_r := full_join(DS_1, DS_2 using Id_1, Id_2);
Input DS_1
Id_1Id_2Me_1
1A10
1B20
2A30
2B40
Input DS_2
Id_1Id_2Me_2
1A1
1C2
2A3
2B4
Expected DS_r
Id_1Id_2Me_1Me_2
1A101
1B20
1C2
2A303
2B404

Files: script.vtl · input/DS_1.csv · input/DS_1.json · input/DS_2.csv · input/DS_2.json · expected/DS_r.csv · expected/DS_r.json · example page ↗

full_join(DS, DS using Id, nvl(Id, c)) 🟢 · any scalar → any type

Nvl for extra identifier 🟢 pandas ✅ · DuckDB ✅
Tests:

using Id_1, nvl(Id_2, "X"): DS_1 has Id_1 and DS_2 has Id_1 and Id_2, so the using clause is mandatory, with a rule for Id_2.

Manual:

Full Join: “For every other identifier not included in the using clause, a nvl() expression must be specified”, and for a key that is not found “the missing Identifiers assume the value specified in the relevant nvl() clause, while the Measures take the null value”.

Expected:

(1, A, 10, 1), (2, X, 20, null) and (3, B, null, 3) as Id_1, Id_2, Me_1, Me_2: Id_1 = 2 is in DS_1 only, and Id_1 = 3 is added from DS_2 with its own Id_2.

script.vtl
DS_r := full_join(DS_1, DS_2 using Id_1, nvl(Id_2, "X"));
Input DS_1
Id_1Me_1
110
220
Input DS_2
Id_1Id_2Me_2
1A1
3B3
Expected DS_r
Id_1Id_2Me_1Me_2
1A101
2X20
3B3

Files: script.vtl · input/DS_1.csv · input/DS_1.json · input/DS_2.csv · input/DS_2.json · expected/DS_r.csv · expected/DS_r.json · example page ↗

Nvl per operand alias 🟢 pandas ✅ · DuckDB ✅
Tests:

using Id_1 with two rules, nvl(d1#Id_2, "Y") and nvl(d2#Id_2, "X"): the Id_2 of each operand, named through its alias, gets its own value; the renames name the two Id_2, as stripping their prefixes would give two Id_2, an error.

Manual:

Full Join: “prefixing the identifier name with the alias of the operand in the nvl() rule allows to specify different rules for each of them”.

Expected:

(1,A,C,10,1), (1,B,C,20,1), (2,B,X,30,null) and (3,Y,D,null,3) as Id_1, Id_21, Id_22, Me_1, Me_2: Id_1 = 2 takes the rule of d2#Id_2, Id_1 = 3 that of d1#Id_2.

script.vtl
DS_r := full_join(DS_1 as d1, DS_2 as d2 using Id_1, nvl(d1#Id_2, "Y"), nvl(d2#Id_2, "X") rename d1#Id_2 to Id_21, d2#Id_2 to Id_22);
Input DS_1
Id_1Id_2Me_1
1A10
1B20
2B30
Input DS_2
Id_1Id_2Me_2
1C1
3D3
Expected DS_r
Id_1Id_21Id_22Me_1Me_2
1AC101
1BC201
2BX30
3YD3

Files: script.vtl · input/DS_1.csv · input/DS_1.json · input/DS_2.csv · input/DS_2.json · expected/DS_r.csv · expected/DS_r.json · example page ↗

full_join(DS, DS filter cond) 🟢 · any scalar, boolean → any type

Filter on measure 🟢 pandas ✅ · DuckDB ✅
Tests:

filter Me_1 > 15 on the joined data points, one of which has a null Me_1.

Manual:

Full Join: the filter “is applied on VDS₁ … when the expression is true the Data Point is kept in the result, otherwise it is discarded”; the User Manual: “Whenever a null value is involved in a comparison … the result of the comparison is null”.

Expected:

(1,B), (2,A) and (2,B) (Me_1 = 20, 30 and 40), with Me_2 null at (1,B); (1,A) has 10, and the null Me_1 of (1,C) gives a null condition.

script.vtl
DS_r := full_join(DS_1, DS_2 filter Me_1 > 15);
Input DS_1
Id_1Id_2Me_1
1A10
1B20
2A30
2B40
Input DS_2
Id_1Id_2Me_2
1A1
1C2
2A3
2B4
Expected DS_r
Id_1Id_2Me_1Me_2
1B20
2A303
2B404

Files: script.vtl · input/DS_1.csv · input/DS_1.json · input/DS_2.csv · input/DS_2.json · expected/DS_r.csv · expected/DS_r.json · example page ↗

full_join(DS, DS apply expr) 🟢 · any scalar → any type

Sum of homonym measures 🟢 pandas ✅ · DuckDB ✅
Tests:

apply DS_1 + DS_2, written with the data set names, on the homonym measure Me_1.

Manual:

Full Join: apply “applies the expression to each of the n-uple of homonym Measures in the input data sets producing in the target a single homonym Measure for each n-uple”, and “All the input measures do not appear”.

Expected:

the five keys: Me_1 := DS_1#Me_1 + DS_2#Me_1 is 11, null, null, 33 and 44, as the User Manual says “Whenever a null value is involved in a mathematical operation (+, -, …), the result is null”.

script.vtl
DS_r := full_join(DS_1, DS_2 apply DS_1 + DS_2);
Input DS_1
Id_1Id_2Me_1
1A10
1B20
2A30
2B40
Input DS_2
Id_1Id_2Me_1
1A1
1C2
2A3
2B4
Expected DS_r
Id_1Id_2Me_1
1A11
1B
1C
2A33
2B44

Files: script.vtl · input/DS_1.csv · input/DS_1.json · input/DS_2.csv · input/DS_2.json · expected/DS_r.csv · expected/DS_r.json · example page ↗

full_join(DS, DS calc C := expr) 🟢 · any scalar → any type

Default role is measure 🟢 pandas ✅ · DuckDB ✅
Tests:

calc Me_3 := Me_1 + Me_2 with no role.

Manual:

Full Join: in a join, “The role of the new components can be specified …; if the role is not specified, it will be measure”.

Expected:

the full join keeps the five keys of both operands, with Me_2 null at (1,B) and Me_1 null at (1,C). Me_3 is a Measure, as in Explicit measure role of the calc_measure form: 11, null, null, 33 and 44, as a sum with a null is null.

script.vtl
DS_r := full_join(DS_1, DS_2 calc Me_3 := Me_1 + Me_2);
Input DS_1
Id_1Id_2Me_1
1A10
1B20
2A30
2B40
Input DS_2
Id_1Id_2Me_2
1A1
1C2
2A3
2B4
Expected DS_r
Id_1Id_2Me_1Me_2Me_3
1A10111
1B20
1C2
2A30333
2B40444

Files: script.vtl · input/DS_1.csv · input/DS_1.json · input/DS_2.csv · input/DS_2.json · expected/DS_r.csv · expected/DS_r.json · example page ↗

Viral attribute becomes measure 🟢 pandas ✅ · DuckDB ✅
Tests:

calc At_1 := At_1 || "x": the Viral Attribute At_1 of DS_1 recalculated under its own name, with the role left out.

Manual:

Full Join: VDS₁ has “The viral attributes, coming from any number of Data Sets”, so a plain attribute would not reach the clause, and on viral attributes “if the calc clause is present instead, it may directly replace the computation algorithm used for the propagation”. In calc “the original role can be changed if the name is kept the same; if the role is not specified, it will be measure”.

Expected:

the four keys of DS_1 (every key of DS_2 is in it), with Me_2 null at (2,B), and At_1 as a Measure: ax, bx, cx and dx. Outside a join, the Calculation of a Component page would keep the role.

Team decision:

#1257: as the comments on sdmx-twg/vtl#731 propose, a viral Attribute needs a propagation rule only where its values are combined, until the VTL Task Force discusses it.

script.vtl
DS_r := full_join(DS_1, DS_2 calc At_1 := At_1 || "x");
Input DS_1
Id_1Id_2Me_1At_1
1A10a
1B20b
2A30c
2B40d
Input DS_2
Id_1Id_2Me_2
1A1
1B2
2A3
Expected DS_r
Id_1Id_2Me_1Me_2At_1
1A101ax
1B202bx
2A303cx
2B40dx

Files: script.vtl · input/DS_1.csv · input/DS_1.json · input/DS_2.csv · input/DS_2.json · expected/DS_r.csv · expected/DS_r.json · example page ↗

Overwrite identifier 🟢 pandas ✅ · DuckDB ✅
Tests:

calc Id_2 := "X" with no role: the calculated component has the name of the identifier Id_2, which both operands have.

Manual:

Full Join: “If a generated component already exists in any of the input data sets, all input components homonymous to the former are removed, and only the generated component is kept”.

Expected:

the error 1-1-6-13, “Not allowed to overwrite an Identifier: {comp_name}”, for “if any of the removed components were identifiers, an error is raised”: the calc would remove the identifier Id_2.

script.vtl
DS_r := full_join(DS_1, DS_2 calc Id_2 := "X");
Input DS_1
Id_1Id_2Me_1
1A10
1B20
2A30
2B40
Input DS_2
Id_1Id_2Me_2
1A1
1C2
2A3
2B4

Expected error 1-1-6-13: At op {op}: Not allowed to overwrite an Identifier: {comp_name}

Files: script.vtl · input/DS_1.csv · input/DS_1.json · input/DS_2.csv · input/DS_2.json · expected/error.json · example page ↗

full_join(DS, DS calc measure C := expr) 🟢 · any scalar → any type

Explicit measure role 🟢 pandas ✅ · DuckDB ✅
Tests:

calc measure Me_3 := Me_1 + Me_2, with the role keyword written out.

Manual:

Full Join: “calc calculates new components by independent sub-expressions evaluated at component level. The role of the new components can be specified”.

Expected:

the full join keeps the five keys of both operands, with Me_2 null at (1,B) and Me_1 null at (1,C). The input components stay and Me_3 is added: 11, null, null, 33 and 44, as a sum with a null is null.

script.vtl
DS_r := full_join(DS_1, DS_2 calc measure Me_3 := Me_1 + Me_2);
Input DS_1
Id_1Id_2Me_1
1A10
1B20
2A30
2B40
Input DS_2
Id_1Id_2Me_2
1A1
1C2
2A3
2B4
Expected DS_r
Id_1Id_2Me_1Me_2Me_3
1A10111
1B20
1C2
2A30333
2B40444

Files: script.vtl · input/DS_1.csv · input/DS_1.json · input/DS_2.csv · input/DS_2.json · expected/DS_r.csv · expected/DS_r.json · example page ↗

full_join(DS, DS calc identifier C := expr) 🟢 · any scalar → any type

Constant identifier 🟢 pandas ✅ · DuckDB ✅
Tests:

calc identifier Id_3 := "X", a new constant identifier.

Manual:

Full Join: “The role of the new components can be specified”; Id_3 is new, so no identifier of the input is overwritten.

Expected:

the full join keeps the five keys of both operands, with Me_2 null at (1,B) and Me_1 null at (1,C); each gets Id_3 = X and the keys stay unique. A constant is never null, so the decision of #1010 (1-1-1-16 for an identifier calculated from a declared-nullable expression) does not apply.

script.vtl
DS_r := full_join(DS_1, DS_2 calc identifier Id_3 := "X");
Input DS_1
Id_1Id_2Me_1
1A10
1B20
2A30
2B40
Input DS_2
Id_1Id_2Me_2
1A1
1C2
2A3
2B4
Expected DS_r
Id_1Id_2Id_3Me_1Me_2
1AX101
1BX20
1CX2
2AX303
2BX404

Files: script.vtl · input/DS_1.csv · input/DS_1.json · input/DS_2.csv · input/DS_2.json · expected/DS_r.csv · expected/DS_r.json · example page ↗

full_join(DS, DS calc attribute C := expr) 🟢 · any scalar → any type

Constant attribute 🟢 pandas ✅ · DuckDB ✅
Tests:

calc attribute At_1 := "EP", a constant attribute.

Manual:

Full Join: “calc calculates new components by independent sub-expressions evaluated at component level. The role of the new components can be specified”. The calc clause page has the same calculation, DS_1 [ calc attribute At_1:= "EP" ] (its Example 2).

Expected:

the full join keeps the five keys of both operands, with Me_2 null at (1,B) and Me_1 null at (1,C), and each gets the String Attribute At_1 = EP.

script.vtl
DS_r := full_join(DS_1, DS_2 calc attribute At_1 := "EP");
Input DS_1
Id_1Id_2Me_1
1A10
1B20
2A30
2B40
Input DS_2
Id_1Id_2Me_2
1A1
1C2
2A3
2B4
Expected DS_r
Id_1Id_2Me_1Me_2At_1
1A101EP
1B20EP
1C2EP
2A303EP
2B404EP

Files: script.vtl · input/DS_1.csv · input/DS_1.json · input/DS_2.csv · input/DS_2.json · expected/DS_r.csv · expected/DS_r.json · example page ↗

full_join(DS, DS calc viral attribute C := expr) 🟢 · any scalar → any type

Constant viral attribute 🟢 pandas ✅ · DuckDB ✅
Tests:

calc viral attribute At_1 := "EP", a constant viral attribute.

Manual:

Full Join: on viral attributes, “if the calc clause is present instead, it may directly replace the computation algorithm used for the propagation”.

Expected:

the full join keeps the five keys of both operands, with Me_2 null at (1,B) and Me_1 null at (1,C), and each gets the String Viral Attribute At_1 = EP; the inputs have no attributes, so there is nothing to propagate.

Team decision:

#1257: as the comments on sdmx-twg/vtl#731 propose, a viral Attribute needs a propagation rule only where its values are combined, until the VTL Task Force discusses it.

script.vtl
DS_r := full_join(DS_1, DS_2 calc viral attribute At_1 := "EP");
Input DS_1
Id_1Id_2Me_1
1A10
1B20
2A30
2B40
Input DS_2
Id_1Id_2Me_2
1A1
1C2
2A3
2B4
Expected DS_r
Id_1Id_2Me_1Me_2At_1
1A101EP
1B20EP
1C2EP
2A303EP
2B404EP

Files: script.vtl · input/DS_1.csv · input/DS_1.json · input/DS_2.csv · input/DS_2.json · expected/DS_r.csv · expected/DS_r.json · example page ↗

full_join(DS, DS aggr C := agg) 🟢 · any scalar → any type

Sum without grouping 🟢 pandas ✅ · DuckDB ✅
Tests:

aggr with no grouping clause.

Manual:

Full Join: “If no grouping clause is specified, then all the input Data Points are aggregated in a single group and the clause returns a data set that contains a single Data Point and has no Identifier Components.” The User Manual: in aggregations “the input Data Points having a null value are in general not considered”.

Expected:

one data point with no identifier: Me_3 = 10 + 20 + 30 + 40 = 100; the null Me_1 of (1,C) is not considered.

script.vtl
DS_r := full_join(DS_1, DS_2 aggr Me_3 := sum(Me_1));
Input DS_1
Id_1Id_2Me_1
1A10
1B20
2A30
2B40
Input DS_2
Id_1Id_2Me_2
1A1
1C2
2A3
2B4
Expected DS_r
Me_3
100

Files: script.vtl · input/DS_1.csv · input/DS_1.json · input/DS_2.csv · input/DS_2.json · expected/DS_r.csv · expected/DS_r.json · example page ↗

full_join(DS, DS aggr C := agg group by Id) 🟢 · any scalar → any type

Sum by id 1 🟢 pandas ✅ · DuckDB ✅
Tests:

aggr with group by Id_1, which drops Id_2.

Manual:

Full Join: “All non-identifier components are removed, and only the components generated by the sub-expressions are kept”; Aggregate invocation: with group by “The Identifiers not specified are dropped in the result”. The User Manual: in aggregations “the input Data Points having a null value are in general not considered”.

Expected:

the full join keeps the five keys of both operands, with Me_2 null at (1,B) and Me_1 null at (1,C): Id_1 = 1 groups 10, 20 and null, so Me_3 is 30, and Id_1 = 2 gives 70.

script.vtl
DS_r := full_join(DS_1, DS_2 aggr Me_3 := sum(Me_1) group by Id_1);
Input DS_1
Id_1Id_2Me_1
1A10
1B20
2A30
2B40
Input DS_2
Id_1Id_2Me_2
1A1
1C2
2A3
2B4
Expected DS_r
Id_1Me_3
130
270

Files: script.vtl · input/DS_1.csv · input/DS_1.json · input/DS_2.csv · input/DS_2.json · expected/DS_r.csv · expected/DS_r.json · example page ↗

Viral attribute becomes measure 🟢 pandas ✅ · DuckDB ✅
Tests:

aggr At_1 := max(At_1) group by Id_1: the Viral Attribute At_1 of DS_1 aggregated under its own name, with the role left out.

Manual:

Full Join: VDS₁ has “The viral attributes, coming from any number of Data Sets”, so a plain attribute would not reach the clause, and in aggr “the original role can be changed if the name is kept the same; if the role is not specified, it will be measure”.

Expected:

At_1 is a String Measure: b for Id_1 = 1 and d for Id_1 = 2. DS_2 has no key of its own, so no data point lacks At_1 (the page does not say what it would hold there); the page applies the propagation rule again under aggr, read here as about the viral attributes the clause does not compute.

Team decision:

#1257: as the comments on sdmx-twg/vtl#731 propose, a viral Attribute needs a propagation rule only where its values are combined, until the VTL Task Force discusses it.

script.vtl
DS_r := full_join(DS_1, DS_2 aggr At_1 := max(At_1) group by Id_1);
Input DS_1
Id_1Id_2Me_1At_1
1A10a
1B20b
2A30c
2B40d
Input DS_2
Id_1Id_2Me_2
1A1
1B2
2A3
Expected DS_r
Id_1At_1
1b
2d

Files: script.vtl · input/DS_1.csv · input/DS_1.json · input/DS_2.csv · input/DS_2.json · expected/DS_r.csv · expected/DS_r.json · example page ↗

full_join(DS, DS aggr C := agg group except Id) 🟢 · any scalar → any type

Sum except id 2 🟢 pandas ✅ · DuckDB ✅
Tests:

aggr with group except Id_2, which groups by Id_1.

Manual:

Full Join, and Aggregate invocation: with group except “the Data Points are grouped by the values of the Identifiers not specified in the clause. The specified Identifiers are dropped in the result”. The User Manual: in aggregations “the input Data Points having a null value are in general not considered”.

Expected:

the full join keeps the five keys of both operands, with Me_2 null at (1,B) and Me_1 null at (1,C); the groups are those of group by Id_1: Me_3 is 30 for Id_1 = 1 (10, 20 and null) and 70 for Id_1 = 2.

script.vtl
DS_r := full_join(DS_1, DS_2 aggr Me_3 := sum(Me_1) group except Id_2);
Input DS_1
Id_1Id_2Me_1
1A10
1B20
2A30
2B40
Input DS_2
Id_1Id_2Me_2
1A1
1C2
2A3
2B4
Expected DS_r
Id_1Me_3
130
270

Files: script.vtl · input/DS_1.csv · input/DS_1.json · input/DS_2.csv · input/DS_2.json · expected/DS_r.csv · expected/DS_r.json · example page ↗

full_join(DS, DS aggr C := agg group all time_agg(p)) 🟢 · any scalar → any type

Quarters to years 🟢 pandas ✅ · DuckDB ✅
Tests:

aggr with the deprecated group all time_agg("A"), which groups the quarters of a time_period identifier by year.

Manual:

Full Join, and Aggregate invocation: group all “converts the values of an Identifier Component using conversionExpr and keeps all the resulting Identifiers” (“This option is deprecated”). Time aggregation maps a time_period “into the comprising larger time period”, as its Example 1 turns 2010Q1 into 2010.

Expected:

the full join keeps the five quarters, with Me_1 null at 2010Q3, which is not considered: Me_3 is 10 + 20 = 30 for 2010 and 30 + 40 = 70 for 2011.

script.vtl
DS_r := full_join(DS_1, DS_2 aggr Me_3 := sum(Me_1) group all time_agg("A"));
Input DS_1
Id_1Me_1
2010Q110
2010Q220
2011Q130
2011Q240
Input DS_2
Id_1Me_2
2010Q11
2010Q32
2011Q13
2011Q24
Expected DS_r
Id_1Me_3
201030
201170

Files: script.vtl · input/DS_1.csv · input/DS_1.json · input/DS_2.csv · input/DS_2.json · expected/DS_r.csv · expected/DS_r.json · example page ↗

full_join(DS, DS aggr C := agg group by Id having cond) 🟢 · any scalar, boolean → any type

Having min above 15 🟢 pandas ✅ · DuckDB ✅
Tests:

aggr by Id_1 with having min(Me_1) > 15.

Manual:

Full Join, and Aggregate invocation: “only groups for which havingCondition evaluates to true appear in the result”, and the condition “must invoke aggregate operators” (min here, which the reading of #1119 also allows).

Expected:

the full join keeps the five keys of both operands, with Me_2 null at (1,B) and Me_1 null at (1,C). Leaving the null out, the smallest Me_1 of Id_1 = 1 is 10, so only Id_1 = 2 is kept, with Me_3 = 70.

script.vtl
DS_r := full_join(DS_1, DS_2 aggr Me_3 := sum(Me_1) group by Id_1 having min(Me_1) > 15);
Input DS_1
Id_1Id_2Me_1
1A10
1B20
2A30
2B40
Input DS_2
Id_1Id_2Me_2
1A1
1C2
2A3
2B4
Expected DS_r
Id_1Me_3
270

Files: script.vtl · input/DS_1.csv · input/DS_1.json · input/DS_2.csv · input/DS_2.json · expected/DS_r.csv · expected/DS_r.json · example page ↗

full_join(DS, DS aggr measure C := agg group by Id) 🟢 · any scalar → any type

Explicit measure role 🟢 pandas ✅ · DuckDB ✅
Tests:

aggr with the role keyword measure written out.

Manual:

Full Join: aggrRole ::= { measure | attribute | viral attribute }, and “if the role is not specified, it will be measure”.

Expected:

the result of Sum by id 1, which leaves the role out: Me_3 is 30 for Id_1 = 1 and 70 for Id_1 = 2.

script.vtl
DS_r := full_join(DS_1, DS_2 aggr measure Me_3 := sum(Me_1) group by Id_1);
Input DS_1
Id_1Id_2Me_1
1A10
1B20
2A30
2B40
Input DS_2
Id_1Id_2Me_2
1A1
1C2
2A3
2B4
Expected DS_r
Id_1Me_3
130
270

Files: script.vtl · input/DS_1.csv · input/DS_1.json · input/DS_2.csv · input/DS_2.json · expected/DS_r.csv · expected/DS_r.json · example page ↗

full_join(DS, DS aggr C := agg, attribute A := agg group by Id) 🟢 · any scalar → any type

Max as attribute 🟢 pandas ✅ · DuckDB ✅
Tests:

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, as in the page’s syntax example aggr Me1 := sum(Me1), attribute At20 := avg(Me2).

Manual:

Full 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 User Manual: in aggregations “the input Data Points having a null value are in general not considered”.

Expected:

the full join keeps the five keys of both operands, with Me_2 null at (1,B) and Me_1 null at (1,C), a null that is not considered. Id_1 = 1 gives Me_3 = 30 and At_1 = 20, Id_1 = 2 gives 70 and 40; At_1 is a Number Attribute.

script.vtl
DS_r := full_join(DS_1, DS_2 aggr Me_3 := sum(Me_1), attribute At_1 := max(Me_1) group by Id_1);
Input DS_1
Id_1Id_2Me_1
1A10
1B20
2A30
2B40
Input DS_2
Id_1Id_2Me_2
1A1
1C2
2A3
2B4
Expected DS_r
Id_1Me_3At_1
13020
27040

Files: script.vtl · input/DS_1.csv · input/DS_1.json · input/DS_2.csv · input/DS_2.json · expected/DS_r.csv · expected/DS_r.json · example page ↗

full_join(DS, DS aggr C := agg, viral attribute A := agg group by Id) 🟢 · any scalar → any type

Max as viral attribute 🟢 pandas ✅ · DuckDB ✅
Tests:

aggr with the sum of Me_1 by Id_1 as Me_3 and its maximum as At_1, with the role viral attribute: the page’s syntax example has the same shape, with attribute.

Manual:

Full Join: the role of an aggregated component is aggrRole ::= { measure | attribute | viral attribute }, and “if omitted, the Measure role is assumed”; on viral attributes, “if the aggr clause is present, the Attribute propagation rule is again applied to the set of all values that are aggregated”.

Expected:

the full join keeps the five keys of both operands, with Me_2 null at (1,B) and Me_1 null at (1,C). The inputs have no attributes; At_1 is what its expression computes: Id_1 = 1 gives Me_3 = 30 and At_1 = 20, Id_1 = 2 gives 70 and 40.

Team decision:

#1257: as the comments on sdmx-twg/vtl#731 propose, a viral Attribute needs a propagation rule only where its values are combined, until the VTL Task Force discusses it.

script.vtl
DS_r := full_join(DS_1, DS_2 aggr Me_3 := sum(Me_1), viral attribute At_1 := max(Me_1) group by Id_1);
Input DS_1
Id_1Id_2Me_1
1A10
1B20
2A30
2B40
Input DS_2
Id_1Id_2Me_2
1A1
1C2
2A3
2B4
Expected DS_r
Id_1Me_3At_1
13020
27040

Files: script.vtl · input/DS_1.csv · input/DS_1.json · input/DS_2.csv · input/DS_2.json · expected/DS_r.csv · expected/DS_r.json · example page ↗

full_join(DS, DS keep C) 🟢 · any scalar → any type

Manual example 1 🟢 pandas ✅ · DuckDB ✅
Tests:

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.

Manual:

Full Join, Example 1, output verbatim: “an additional data point is added to this set for each data point in the current join operand that wasn’t matched before”, with null measures.

Expected:

(1,A) and (1,B), in both; (2,A), in DS_1 only, with Me_2 and Me_1A null; (3,A), in DS_2 only, with Me_1 null. d1#Me_2 goes and d2#Me_2 becomes Me_2.

script.vtl
DS_r := full_join ( DS_1 as d1, DS_2 as d2 keep Me_1, d2#Me_2, Me_1A );
Input DS_1
Id_1Id_2Me_1Me_2
1AAB
1BCD
2AEF
Input DS_2
Id_1Id_2Me_1AMe_2
1ABQ
1BST
3AZM
Expected DS_r
Id_1Id_2Me_1Me_2Me_1A
1AAQB
1BCTS
2AE
3AMZ

Files: script.vtl · input/DS_1.csv · input/DS_1.json · input/DS_2.csv · input/DS_2.json · expected/DS_r.csv · expected/DS_r.json · example page ↗

Keep one measure 🟢 pandas ✅ · DuckDB ✅
Tests:

keep Me_1.

Manual:

Full Join: “keep will maintain all the identifiers and only the specified non-identifier components of VDS₃”.

Expected:

the five keys with Me_1 only: 10, 20, null, 30 and 40.

script.vtl
DS_r := full_join(DS_1, DS_2 keep Me_1);
Input DS_1
Id_1Id_2Me_1
1A10
1B20
2A30
2B40
Input DS_2
Id_1Id_2Me_2
1A1
1C2
2A3
2B4
Expected DS_r
Id_1Id_2Me_1
1A10
1B20
1C
2A30
2B40

Files: script.vtl · input/DS_1.csv · input/DS_1.json · input/DS_2.csv · input/DS_2.json · expected/DS_r.csv · expected/DS_r.json · example page ↗

full_join(DS, DS drop C) 🟢 · any scalar → any type

Drop one measure 🟢 pandas ✅ · DuckDB ✅
Tests:

drop Me_1.

Manual:

Full Join: “drop will remove all specified non-identifier components of VDS₃”.

Expected:

the five keys with the identifiers and Me_2 only: 1, null, 2, 3 and 4.

script.vtl
DS_r := full_join(DS_1, DS_2 drop Me_1);
Input DS_1
Id_1Id_2Me_1
1A10
1B20
2A30
2B40
Input DS_2
Id_1Id_2Me_2
1A1
1C2
2A3
2B4
Expected DS_r
Id_1Id_2Me_2
1A1
1B
1C2
2A3
2B4

Files: script.vtl · input/DS_1.csv · input/DS_1.json · input/DS_2.csv · input/DS_2.json · expected/DS_r.csv · expected/DS_r.json · example page ↗

full_join(DS, DS rename C to C2) 🟢 · any scalar → any type

Rename measure 🟢 pandas ✅ · DuckDB ✅
Tests:

rename Me_1 to Me_10.

Manual:

Full Join: rename gives “each specified component with a new name. If the chosen name already exists in VDS₄, an error is raised.”

Expected:

Me_10 is not in VDS₄, so no error: the five keys, with Me_10 (10, 20, null, 30, 40) and Me_2 (1, null, 2, 3, 4).

script.vtl
DS_r := full_join(DS_1, DS_2 rename Me_1 to Me_10);
Input DS_1
Id_1Id_2Me_1
1A10
1B20
2A30
2B40
Input DS_2
Id_1Id_2Me_2
1A1
1C2
2A3
2B4
Expected DS_r
Id_1Id_2Me_10Me_2
1A101
1B20
1C2
2A303
2B404

Files: script.vtl · input/DS_1.csv · input/DS_1.json · input/DS_2.csv · input/DS_2.json · expected/DS_r.csv · expected/DS_r.json · example page ↗

full_join(DS, DS, DS) 🟢 · any scalar → any type

Three operands 🟢 pandas ✅ · DuckDB ✅
Tests:

a full join of three operands with the same identifiers.

Manual:

Full Join: at each step “an additional data point is added to this set for each data point in the current join operand that wasn’t matched before”.

Expected:

the first step gives the five keys of DS_1 and DS_2, the second adds (3,A) of DS_3: six data points, each measure null where its operand lacks the key.

script.vtl
DS_r := full_join(DS_1, DS_2, DS_3);
Input DS_1
Id_1Id_2Me_1
1A10
1B20
2A30
2B40
Input DS_2
Id_1Id_2Me_2
1A1
1C2
2A3
2B4
Input DS_3
Id_1Id_2Me_3
1A100
2B400
3A500
Expected DS_r
Id_1Id_2Me_1Me_2Me_3
1A101100
1B20
1C2
2A303
2B404400
3A500

Files: script.vtl · input/DS_1.csv · input/DS_1.json · input/DS_2.csv · input/DS_2.json · input/DS_3.csv · input/DS_3.json · expected/DS_r.csv · expected/DS_r.json · example page ↗