Trailing whitespace removal · rtrim

🟢 3 of 3 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["Trailing whitespace removal · rtrim<br/>🟢3"]:::ok
    subgraph G_ds["Dataset"]
        direction LR
        v_ds["rtrim(DS)"]:::ok
    end
    subgraph G_comp["Component"]
        direction LR
        v_comp["rtrim(comp)"]:::ok
    end
    subgraph G_sc["Scalar"]
        direction LR
        v_sc["rtrim(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 string · Gives string

Comes from · string — 12 operators in 3 blocks 🟢12
General purpose operators (2) 🟢2
String operators (7) 🟢7
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 · string — 16 operators in 5 blocks 🟢16
General purpose operators (1) 🟢1
String operators (10) 🟢10
Comparison operators (1) 🟢1
Data validation operators (1) 🟢1
Definitions (VTL-DL) (3) 🟢3
Goes to · operators that take any scalar — 49 operators in 9 blocks 🟢49
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
Definitions (VTL-DL) (1) 🟢1

Forms

rtrim(DS) 🟢 · string → string

Manual example 1 🟢 pandas ✅ · DuckDB ✅
Tests:

rtrim on values that end with a space, which “may not be visualised” on the page; the input quotes "hello " and "hi ", so the space is data.

Manual:

Whitespace removal, Example 1, output verbatim: “Removes trailing or/and leading whitespace from a string.”

Expected:

Me_1 is hello and hi, without the trailing space.

script.vtl
DS_r := rtrim(DS_1);
Input DS_1
Id_1Id_2Me_1
1Ahello
2Bhi
Expected DS_r
Id_1Id_2Me_1
1Ahello
2Bhi

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

rtrim(comp) 🟢 · string → string

Manual example 2 🟢 pandas ✅ · DuckDB ✅
Tests:

rtrim of a component inside calc, on values that end with a space; the input quotes them, so the space is data.

Manual:

Whitespace removal, Example 2, output verbatim: “Removes trailing or/and leading whitespace from a string.”

Expected:

the new measure Me_2 is hello and hi, without the trailing space; Me_1 keeps "hello " and "hi ".

script.vtl
DS_r := DS_1[ calc Me_2:= rtrim(Me_1)];
Input DS_1
Id_1Id_2Me_1
1Ahello
2Bhi
Expected DS_r
Id_1Id_2Me_1Me_2
1Ahello hello
2Bhi hi

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

rtrim(sc) 🟢 · string → string

Trailing removed leading kept 🟢 pandas ✅ · DuckDB ✅
Tests:

rtrim of a string with two spaces at each end.

Manual:

Whitespace removal: “Removes trailing or/and leading whitespace from a string.”

Expected:

SC_r is "  Hello", a String: the two leading spaces are kept.

script.vtl
SC_r := rtrim("  Hello  ");
Expected scalars

Name

Type

Value

SC_r

String

"  Hello"

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

Padded input value 🟢 pandas ✅ · DuckDB ✅
Tests:

rtrim(SC_1) with the input scalar SC_1 = "  Hello  ", two spaces at each end, quoted in the CSV so that they are kept.

Manual:

Whitespace removal: “Removes trailing or/and leading whitespace from a string.”

Expected:

SC_r is "  Hello", a String: the two leading spaces are kept.

script.vtl
SC_r := rtrim(SC_1);
Input scalars
SC_1
Hello
Expected scalars

Name

Type

Value

SC_r

String

"  Hello"

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