Subtraction · -
---
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["Subtraction · -<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
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
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
Forms
DS - DS 🟢 · number → number
Manual example 1 🟢 pandas ✅ · DuckDB ✅
- Tests:
each measure of
DS_2subtracted from the same measure ofDS_1, on the data points that the two datasets share.- Manual:
Subtraction, Example 1, output verbatim: “The operator subtraction returns the difference of two numbers.”
- Expected:
only (10, A) and (11, B) are in both datasets:
5 - 10 = -5and5.0 - 3.0 = 2.0;4 - 6 = -2and20.3 - 7.0 = 13.3.
DS_r := DS_1 - DS_2;
| Id_1 | Id_2 | Me_1 | Me_2 |
|---|---|---|---|
| 10 | A | 5 | 5.0 |
| 10 | B | 2 | 10.5 |
| 11 | A | 3 | 12.2 |
| 11 | B | 4 | 20.3 |
| Id_1 | Id_2 | Me_1 | Me_2 |
|---|---|---|---|
| 10 | A | 10 | 3.0 |
| 10 | C | 11 | 6.2 |
| 11 | B | 6 | 7.0 |
| Id_1 | Id_2 | Me_1 | Me_2 |
|---|---|---|---|
| 10 | A | -5 | 2.0 |
| 11 | B | -2 | 13.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 subtracted from every measure of
DS_1.- Manual:
Subtraction, Example 2, output verbatim: “The operator subtraction returns the difference of two numbers.”
- Expected:
Me_1(Integer) 2, -1, 0 and 1;Me_2(Number) 2.0, 7.5, 9.2 and 17.3; all four data points are kept.
DS_r := DS_1 - 3;
| Id_1 | Id_2 | Me_1 | Me_2 |
|---|---|---|---|
| 10 | A | 5 | 5.0 |
| 10 | B | 2 | 10.5 |
| 11 | A | 3 | 12.2 |
| 11 | B | 4 | 20.3 |
| Id_1 | Id_2 | Me_1 | Me_2 |
|---|---|---|---|
| 10 | A | 2 | 2.0 |
| 10 | B | -1 | 7.5 |
| 11 | A | 0 | 9.2 |
| 11 | B | 1 | 17.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
Scalar minuend 🟢 pandas ✅ · DuckDB ✅
- Tests:
every measure of a dataset subtracted from a scalar, so the order matters.
- Manual:
Subtraction: op1 is “the minuend” and op2 is “the subtrahend”.
- Expected:
10 - DS_1:Me_1(Integer) 8, 6 and 5;Me_2(Number) 7.5, 6.0 and 9.5.
DS_r := 10 - DS_1;
| Id_1 | Me_1 | Me_2 |
|---|---|---|
| 1 | 2 | 2.5 |
| 2 | 4 | 4.0 |
| 3 | 5 | 0.5 |
| Id_1 | Me_1 | Me_2 |
|---|---|---|
| 1 | 8 | 7.500000 |
| 2 | 6 | 6.000000 |
| 3 | 5 | 9.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 minus number 🟢 pandas ✅ · DuckDB ✅
- Tests:
an Integer component minus a Number component, inside
calc.- Manual:
Subtraction: “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 = -0.5,4 - 4.0 = 0.0and5 - 0.5 = 4.5, a Number; the other components are kept.
DS_r := DS_1[calc Me_3 := Me_1 - Me_2];
| Id_1 | Me_1 | Me_2 |
|---|---|---|
| 1 | 2 | 2.5 |
| 2 | 4 | 4.0 |
| 3 | 5 | 0.5 |
| Id_1 | Me_1 | Me_2 | Me_3 |
|---|---|---|---|
| 1 | 2 | 2.500000 | -0.500000 |
| 2 | 4 | 4.000000 | 0.000000 |
| 3 | 5 | 0.500000 | 4.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 an Integer component and an integer scalar, insidecalc.- Manual:
Subtraction, Example 3, output verbatim: “The operator subtraction returns the difference of two numbers.”
- Expected:
Me_3 = Me_1 - 3is 2, -1, 0 and 1, an Integer as both operands are integers; the other components are kept.
DS_r := DS_1 [ calc Me_3 := Me_1 - 3 ];
| Id_1 | Id_2 | Me_1 | Me_2 |
|---|---|---|---|
| 10 | A | 5 | 5.0 |
| 10 | B | 2 | 10.5 |
| 11 | A | 3 | 12.2 |
| 11 | B | 4 | 20.3 |
| Id_1 | Id_2 | Me_1 | Me_2 | Me_3 |
|---|---|---|---|---|
| 10 | A | 5 | 5.0 | 2 |
| 10 | B | 2 | 10.5 | -1 |
| 11 | A | 3 | 12.2 | 0 |
| 11 | B | 4 | 20.3 | 1 |
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
Scalar minuend 🟢 pandas ✅ · DuckDB ✅
- Tests:
a component subtracted from a scalar, so the order matters.
- Manual:
Subtraction: op1 is “the minuend” and op2 is “the subtrahend”.
- Expected:
Me_3 = 10 - Me_1is 8, 6 and 5, an Integer; the other components are kept.
DS_r := DS_1[calc Me_3 := 10 - Me_1];
| Id_1 | Me_1 | Me_2 |
|---|---|---|
| 1 | 2 | 2.5 |
| 2 | 4 | 4.0 |
| 3 | 5 | 0.5 |
| Id_1 | Me_1 | Me_2 | Me_3 |
|---|---|---|---|
| 1 | 2 | 2.500000 | 8 |
| 2 | 4 | 4.000000 | 6 |
| 3 | 5 | 0.500000 | 5 |
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
Negative result 🟢 pandas ✅ · DuckDB ✅
- Tests:
the difference of two integer scalars when it is negative:
SC_1 - SC_2withSC_1= 3 andSC_2= 5.- Manual:
Subtraction: “
3 - 5gives-2”.- Expected:
SC_r = -2, an Integer.
SC_r := SC_1 - SC_2;
| SC_1 | SC_2 |
|---|---|
| 3 | 5 |
Name |
Type |
Value |
|---|---|---|
|
Integer |
|
Files: script.vtl · input/scalars.csv · input/scalars.json · expected/scalars.json · example page ↗