String concatenation · ||

🟢 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["String concatenation · #124;#124;<br/>🟢7"]:::ok
    subgraph G_ds["Dataset"]
        direction LR
        v_ds_ds["DS #124;#124; DS"]:::ok
        v_ds_sc["DS #124;#124; sc"]:::ok
        v_sc_ds["sc #124;#124; DS"]:::ok
    end
    subgraph G_comp["Component"]
        direction LR
        v_comp_comp["comp #124;#124; comp"]:::ok
        v_comp_sc["comp #124;#124; sc"]:::ok
        v_sc_comp["sc #124;#124; comp"]:::ok
    end
    subgraph G_sc["Scalar"]
        direction LR
        v_sc_sc["sc #124;#124; 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 string · Gives string

Viral attributes: combined with the propagation rules → Viral propagation

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

DS || DS 🟢 · string → string

Manual example 1 🟢 pandas ✅ · DuckDB ✅
Tests:

the measure of DS_1 followed by that of DS_2, on each data point.

Manual:

String concatenation, Example 1, output verbatim: “Concatenates two strings.”

Expected:

Me_1 is helloworld for (1, A) and hithere for (2, B).

script.vtl
DS_r := DS_1 || DS_2;
Input DS_1
Id_1Id_2Me_1
1Ahello
2Bhi
Input DS_2
Id_1Id_2Me_1
1Aworld
2Bthere
Expected DS_r
Id_1Id_2Me_1
1Ahelloworld
2Bhithere

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

Suffix and null measure 🟢 pandas ✅ · DuckDB ✅
Tests:

DS_1 || "!": a scalar appended to every value, where one measure is null.

Manual:

String concatenation: “Concatenates two strings.” The scalar is composed with every measure: “An operand Scalar value is composed with all the Measures of the other operand” (Typical behaviours).

Expected:

Me_1 is hello! and world!. A null operand gives a null result: “most of the scalar operations (arithmetic, logical, and others) return null when any of their arguments is null” (User Manual), as the manual’s length and instr examples show.

script.vtl
DS_r := DS_1 || "!";
Input DS_1
Id_1Me_1
1hello
2world
3
Expected DS_r
Id_1Me_1
1hello!
2world!
3

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

sc || DS 🟢 · string → string

Prefix and null measure 🟢 pandas ✅ · DuckDB ✅
Tests:

"Dear " || DS_1: a scalar put before every value, so that the order of the operands shows; one measure is null.

Manual:

String concatenation: “Concatenates two strings.” The scalar is composed with every measure: “An operand Scalar value is composed with all the Measures of the other operand” (Typical behaviours).

Expected:

Me_1 is Dear Ann and Dear Bob: the scalar is the left operand, so it comes first. A null operand gives a null result: “most of the scalar operations (arithmetic, logical, and others) return null when any of their arguments is null” (User Manual), as the manual’s length and instr examples show.

script.vtl
DS_r := "Dear " || DS_1;
Input DS_1
Id_1Me_1
1Ann
2Bob
3
Expected DS_r
Id_1Me_1
1Dear Ann
2Dear Bob
3

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

comp || comp 🟢 · string → string

Null right operand 🟢 pandas ✅ · DuckDB ✅
Tests:

Me_1 || Me_2 inside calc, where Me_2 is null in one data point.

Manual:

String concatenation: “Concatenates two strings.” A new component “is added to the original Components of DS_1, by default as a Measure” (Typical behaviours).

Expected:

Me_3 is foobar and abcd; Me_1 and Me_2 are kept. A null operand gives a null result: “most of the scalar operations (arithmetic, logical, and others) return null when any of their arguments is null” (User Manual), as the manual’s length and instr examples show.

script.vtl
DS_r := DS_1[calc Me_3 := Me_1 || Me_2];
Input DS_1
Id_1Me_1Me_2
1foobar
2abcd
3x
Expected DS_r
Id_1Me_1Me_2Me_3
1foobarfoobar
2abcdabcd
3x

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

comp || sc 🟢 · string → string

Manual example 2 🟢 pandas ✅ · DuckDB ✅
Tests:

Me_1 || " world" inside calc, where the new measure Me_2 takes the result.

Manual:

String concatenation, Example 2, output verbatim: “Concatenates two strings.”

Expected:

Me_2 is hello world and hi world; Me_1 is kept.

script.vtl
DS_r := DS_1[calc Me_2 := Me_1 || " world"];
Input DS_1
Id_1Id_2Me_1
1Ahello
2Bhi
Expected DS_r
Id_1Id_2Me_1Me_2
1Ahellohello world
2Bhihi world

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

sc || comp 🟢 · string → string

Prefix and null component 🟢 pandas ✅ · DuckDB ✅
Tests:

"Hello " || Me_1 inside calc, where Me_1 is null in one data point.

Manual:

String concatenation: “Concatenates two strings.” A new component “is added to the original Components of DS_1, by default as a Measure” (Typical behaviours).

Expected:

Me_2 is Hello World and Hello VTL; Me_1 is kept. A null operand gives a null result: “most of the scalar operations (arithmetic, logical, and others) return null when any of their arguments is null” (User Manual), as the manual’s length and instr examples show.

script.vtl
DS_r := DS_1[calc Me_2 := "Hello " || Me_1];
Input DS_1
Id_1Me_1
1World
2VTL
3
Expected DS_r
Id_1Me_1Me_2
1WorldHello World
2VTLHello VTL
3

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

sc || sc 🟢 · string → string

Two strings 🟢 pandas ✅ · DuckDB ✅
Tests:

the concatenation of two input scalars, SC_1 || SC_2 with SC_1 = Hello and SC_2 = , World.

Manual:

String concatenation: “Concatenates two strings. For example, "Hello" || ", World" gives "Hello, World".”

Expected:

SC_r is Hello, World, a String.

script.vtl
SC_r := SC_1 || SC_2;
Input scalars
SC_1SC_2
Hello, World
Expected scalars

Name

Type

Value

SC_r

String

"Hello, World"

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