Unary plus · +

🟢 3 of 3 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["Unary plus · +<br/>🟢3"]:::ok
    subgraph G_ds["Dataset"]
        direction LR
        v_ds["+DS"]:::ok
    end
    subgraph G_comp["Component"]
        direction LR
        v_comp["+comp"]:::ok
    end
    subgraph G_sc["Scalar"]
        direction LR
        v_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 href "#form-ds"
    click v_comp href "#form-comp"
    click v_sc href "#form-sc"
    

Types

Takes number · Gives number

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 🟢 · number → number

Manual example 1 🟢 pandas ✅ · DuckDB ✅
Tests:

+ on a dataset with a Number measure and an Integer measure.

Manual:

Unary plus, Example 1, output verbatim: “The operator + returns the operand unchanged.”

Expected:

both measures come back unchanged and keep their types: Me_1 (Number) 1.0, 2.3 and 3.2, Me_2 (Integer) 5, 10 and 12.

script.vtl
DS_r := + DS_1;
Input DS_1
Id_1Id_2Me_1Me_2
10A1.05
10B2.310
11A3.212
Expected DS_r
Id_1Id_2Me_1Me_2
10A1.05
10B2.310
11A3.212

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

+comp 🟢 · number → number

Manual example 2 🟢 pandas ✅ · DuckDB ✅
Tests:

+ on a component inside calc.

Manual:

Unary plus, Example 2, output verbatim: “The operator + returns the operand unchanged.”

Expected:

Me_3 := + Me_1 repeats Me_1 as a Number, 1.0, 2.3 and 3.2; the other components are kept.

script.vtl
DS_r := DS_1 [ calc Me_3 := + Me_1 ];
Input DS_1
Id_1Id_2Me_1Me_2
10A1.05
10B2.310
11A3.212
Expected DS_r
Id_1Id_2Me_1Me_2Me_3
10A1.051.0
10B2.3102.3
11A3.2123.2

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

+sc 🟢 · number → number

Negative operand 🟢 pandas ✅ · DuckDB ✅
Tests:

+ on a negative scalar: +SC_1 with SC_1 = -5.

Manual:

Unary plus: “+(-5) gives -5”.

Expected:

SC_r = -5, an Integer: “If the type of the operand is integer then the result has type integer.”

script.vtl
SC_r := +SC_1;
Input scalars
SC_1
-5
Expected scalars

Name

Type

Value

SC_r

Integer

"-5"

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