Addition · +

🟢 7 of 7 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
Dataset formsComponent formsScalar forms
        ---
config:
  flowchart:
    useMaxWidth: false

---
flowchart TB
    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["Addition · +<br/>🟢7"]:::ok
    subgraph G_ds["Dataset"]
        direction LR
        v_ds_ds["DS + DS"]:::ok
        v_ds_sc["DS + sc"]:::ok
        v_sc_ds["sc + DS"]:::ok
    end
    subgraph G_comp["Component"]
        direction LR
        v_comp_comp["comp + comp"]:::ok
        v_comp_sc["comp + sc"]:::ok
        v_sc_comp["sc + comp"]:::ok
    end
    subgraph G_sc["Scalar"]
        direction LR
        v_sc_sc["sc + sc"]:::ok
    end
    O --- G_ds
    O --- G_comp
    O --- G_sc
    style G_ds fill:#f8f9fa,stroke:#495057,stroke-width:2px
    style G_comp fill:#f8f9fa,stroke:#495057,stroke-width:2px,stroke-dasharray: 8 5
    style G_sc fill:#f8f9fa,stroke:#495057,stroke-width:2px,stroke-dasharray: 2 3
    click v_ds_ds href "#form-ds-ds"
    click v_ds_sc href "#form-ds-sc"
    click v_sc_ds href "#form-sc-ds"
    click v_comp_comp href "#form-comp-comp"
    click v_comp_sc href "#form-comp-sc"
    click v_sc_comp href "#form-sc-comp"
    click v_sc_sc href "#form-sc-sc"
    

Types

Takes number · Gives number

Viral attributes: combined with the propagation rules → Viral propagation

Comes from · number — 44 operators in 6 blocks 🟢44
General purpose operators (2) 🟢2
String operators (3) 🟢3
Numeric operators (17) 🟢17
Time operators (9) 🟢9
Aggregate and Analytic operators (10) 🟢10
Data validation operators (3) 🟢3
Comes from · operators that return any type (their input's) — 37 operators in 8 blocks 🟢37
General purpose operators (5) 🟢5
Join operators (4) 🟢4
Time operators (3) 🟢3
Set operators (4) 🟢4
Hierarchical aggregation (1) 🟢1
Aggregate and Analytic operators (8) 🟢8
Conditional operators (3) 🟢3
Clause operators (9) 🟢9
Goes to · number — 33 operators in 7 blocks 🟢33
General purpose operators (1) 🟢1
Numeric operators (17) 🟢17
Time operators (2) 🟢2
Hierarchical aggregation (1) 🟢1
Aggregate and Analytic operators (8) 🟢8
Data validation operators (2) 🟢2
Definitions (VTL-DL) (2) 🟢2
Goes to · operators that take any scalar — 48 operators in 8 blocks 🟢48
General purpose operators (6) 🟢6
Join operators (4) 🟢4
Comparison operators (11) 🟢11
Set operators (4) 🟢4
Aggregate and Analytic operators (10) 🟢10
Data validation operators (1) 🟢1
Conditional operators (3) 🟢3
Clause operators (9) 🟢9

Forms

DS + DS 🟢 · number → number

Manual example 1 🟢 pandas ✅ · DuckDB ✅
Tests:

the sum of each measure of DS_1 and the same measure of DS_2, on the data points that the two datasets share.

Manual:

Addition, Example 1, output verbatim: “The operator addition returns the sum of two numbers.”

Expected:

only (10, A) and (11, B) are in both datasets: 5 + 10 = 15 and 5.0 + 3.0 = 8.0; 4 + 6 = 10 and 20.3 + 7.0 = 27.3.

script.vtl
DS_r := DS_1 + DS_2;
Input DS_1
Id_1Id_2Me_1Me_2
10A55.0
10B210.5
11A312.2
11B420.3
Input DS_2
Id_1Id_2Me_1Me_2
10A103.0
10C116.2
11B67.0
Expected DS_r
Id_1Id_2Me_1Me_2
10A158.0
11B1027.3

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 ↗

DS + sc 🟢 · number → number

Manual example 2 🟢 pandas ✅ · DuckDB ✅
Tests:

a scalar added to every measure of DS_1.

Manual:

Addition, Example 2, output verbatim: “The operator addition returns the sum of two numbers.”

Expected:

Me_1 (Integer) 8, 5, 6 and 7; Me_2 (Number) 8.0, 13.5, 15.2 and 23.3; all four data points are kept.

script.vtl
DS_r := DS_1 + 3;
Input DS_1
Id_1Id_2Me_1Me_2
10A55.0
10B210.5
11A312.2
11B420.3
Expected DS_r
Id_1Id_2Me_1Me_2
10A88.0
10B513.5
11A615.2
11B723.3

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

sc + DS 🟢 · number → number

Integer and number measures 🟢 pandas ✅ · DuckDB ✅
Tests:

a scalar added to every measure of a dataset that has an Integer and a Number measure.

Manual:

Addition: “If the type of both operands is integer then the result has type integer. If one of the operands is of type number, … the result has type number.”

Expected:

3 + DS_1: Me_1 (Integer) 5, 7 and 8; Me_2 (Number) 5.5, 7.0 and 3.5.

script.vtl
DS_r := 3 + DS_1;
Input DS_1
Id_1Me_1Me_2
122.5
244.0
350.5
Expected DS_r
Id_1Me_1Me_2
155.500000
277.000000
383.500000

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

comp + comp 🟢 · number → number

Integer plus number 🟢 pandas ✅ · DuckDB ✅
Tests:

the sum of an Integer component and a Number component, inside calc.

Manual:

Addition: “If one of the operands is of type number, then the other operand is implicitly cast to number and therefore the result has type number.”

Expected:

Me_3 = Me_1 + Me_2: 2 + 2.5 = 4.5, 4 + 4.0 = 8.0 and 5 + 0.5 = 5.5, a Number; the other components are kept.

script.vtl
DS_r := DS_1[calc Me_3 := Me_1 + Me_2];
Input DS_1
Id_1Me_1Me_2
122.5
244.0
350.5
Expected DS_r
Id_1Me_1Me_2Me_3
122.5000004.500000
244.0000008.000000
350.5000005.500000

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

comp + sc 🟢 · number → number

Manual example 3 🟢 pandas ✅ · DuckDB ✅
Tests:

+ between a component and a Number scalar, inside calc.

Manual:

Addition, Example 3, output verbatim: “The operator addition returns the sum of two numbers.”

Expected:

Me_3 = Me_1 + 3.0 is 8.0, 5.0, 6.0 and 7.0, a Number; the other components are kept.

script.vtl
DS_r := DS_1 [ calc Me_3 := Me_1 + 3.0 ];
Input DS_1
Id_1Id_2Me_1Me_2
10A55.0
10B210.5
11A312.2
11B420.3
Expected DS_r
Id_1Id_2Me_1Me_2Me_3
10A55.08.0
10B210.55.0
11A312.26.0
11B420.37.0

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

sc + comp 🟢 · number → number

Integer plus integer 🟢 pandas ✅ · DuckDB ✅
Tests:

a scalar added to an Integer component, inside calc.

Manual:

Addition: “If the type of both operands is integer then the result has type integer.”

Expected:

Me_3 = 3 + Me_1 is 5, 7 and 8, an Integer; the other components are kept.

script.vtl
DS_r := DS_1[calc Me_3 := 3 + Me_1];
Input DS_1
Id_1Me_1Me_2
122.5
244.0
350.5
Expected DS_r
Id_1Me_1Me_2Me_3
122.5000005
244.0000007
350.5000008

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

sc + sc 🟢 · number → number

Integer plus integer 🟢 pandas ✅ · DuckDB ✅
Tests:

the sum of two integer scalars: SC_1 + SC_2 with SC_1 = 3 and SC_2 = 5.

Manual:

Addition: “3 + 5 gives 8”.

Expected:

SC_r = 8, an Integer.

script.vtl
SC_r := SC_1 + SC_2;
Input scalars
SC_1SC_2
35
Expected scalars

Name

Type

Value

SC_r

Integer

"8"

Files: script.vtl · input/scalars.csv · input/scalars.json · expected/scalars.json · example page ↗