Division · /

🟢 7 of 7 forms all ok · VTL 2.2 Reference Manual ↗ · vtlengine 1.10.0rc3 (9e1c81a6) · 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["Division · /<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:

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

Manual:

Division, Example 1, output verbatim: “The operator … divides two numbers.”

Expected:

only (10, A) and (11, B) are in both datasets: 7.6 / 2.0 = 3.8 and 20.0 / 1.0 = 20.0.

script.vtl
DS_r := DS_1 / DS_2;
Input DS_1
Id_1Id_2Me_1
10A7.6
10B12.3
11A25.0
11B20.0
Input DS_2
Id_1Id_2Me_1
10A2.0
10C3.0
11B1.0
Expected DS_r
Id_1Id_2Me_1
10A3.8
11B20.0

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:

every measure of DS_1 divided by a scalar.

Manual:

Division, Example 2, output verbatim: “The operator … divides two numbers.”

Expected:

DS_1 / 10 is 0.76, 1.23, 2.5 and 2.0; all four data points are kept.

script.vtl
DS_r := DS_1 / 10;
Input DS_1
Id_1Id_2Me_1
10A7.6
10B12.3
11A25.0
11B20.0
Expected DS_r
Id_1Id_2Me_1
10A0.76
10B1.23
11A2.5
11B2.0

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 dividend 🟢 pandas ✅ · DuckDB ✅
Tests:

a scalar divided by every measure of a dataset, so the order matters.

Manual:

Division: op1 is “the dividend” and op2 is “the divisor”, and “The result has type number.”

Expected:

10 / DS_1: Me_1 is 5.0, 2.5 and 2.0, a Number although the source measure is an Integer; Me_2 is 4.0, 2.5 and 20.0.

script.vtl
DS_r := 10 / DS_1;
Input DS_1
Id_1Me_1Me_2
122.5
244.0
350.5
Expected DS_r
Id_1Me_1Me_2
15.0000004.000000
22.5000002.500000
32.00000020.000000

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

Manual example 3 🟢 pandas ✅ · DuckDB ✅
Tests:

the quotient of two components of DS_3, inside calc.

Manual:

Division, Example 3, output verbatim: “The operator … divides two numbers.”

Expected:

Me_3 = Me_2 / Me_1: 7.6 / 100 = 0.076, 12.3 / 10 = 1.23, 25.0 / 20 = 1.25 and 20.0 / 2 = 10.0; the other components are kept.

script.vtl
DS_r := DS_3 [ calc Me_3 := Me_2 / Me_1 ];
Input DS_3
Id_1Id_2Me_1Me_2
10A1007.6
10B1012.3
11A2025.0
11B220.0
Expected DS_r
Id_1Id_2Me_1Me_2Me_3
10A1007.60.076
10B1012.31.23
11A2025.01.25
11B220.010.0

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

comp / sc 🟢 · number → number

Number result 🟢 pandas ✅ · DuckDB ✅
Tests:

an Integer component divided by an integer scalar, inside calc.

Manual:

Division: “The result has type number.”

Expected:

Me_3 = Me_1 / 4 is 0.5, 1.0 and 1.25, a Number although both operands are integers; the other components are kept.

script.vtl
DS_r := DS_1[calc Me_3 := Me_1 / 4];
Input DS_1
Id_1Me_1Me_2
122.5
244.0
350.5
Expected DS_r
Id_1Me_1Me_2Me_3
122.5000000.500000
244.0000001.000000
350.5000001.250000

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 dividend 🟢 pandas ✅ · DuckDB ✅
Tests:

a scalar divided by a component, so the order matters.

Manual:

Division: op1 is “the dividend” and op2 is “the divisor”, and “The result has type number.”

Expected:

Me_3 = 10 / Me_1 is 5.0, 2.5 and 2.0, a Number; the other components are kept.

script.vtl
DS_r := DS_1[calc Me_3 := 10 / 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.000000
244.0000002.500000
350.5000002.000000

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

Number result 🟢 pandas ✅ · DuckDB ✅
Tests:

the quotient of two integer scalars: SC_1 / SC_2 with SC_1 = 3 and SC_2 = 5.

Manual:

Division: “3 / 5 gives 0.6”.

Expected:

SC_r = 0.6, a Number: “The result has type number.”

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

Name

Type

Value

SC_r

Number

"0.600000"

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

Zero divisor 🟢 pandas ✅ · DuckDB ✅
Tests:

a scalar division by 0: SC_1 / SC_2 with SC_1 = 3 and SC_2 = 0.

Manual:

Division: “If op2 is 0 then the operation generates a run-time error.”

Expected:

an error and no value: “If op2 is 0 then the operation generates a run-time error”. The error is 2-1-15-6, “At op {op}: Scalar division by Zero.”

script.vtl
SC_r := SC_1 / SC_2;
Input scalars
SC_1SC_2
30

Expected error 2-1-15-6: At op {op}: Scalar division by Zero.

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