← concat operator page · string/concat/comp_comp/null_right_operand

Null right operand 🟢 all ok

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.csv ⇩

Id_1Me_1Me_2
1foobar
2abcd
3x

input/DS_1.json ⇩

{
  "datasets": [
    {
      "name": "DS_1",
      "DataStructure": [
        {"name": "Id_1", "type": "Integer", "role": "Identifier", "nullable": false},
        {"name": "Me_1", "type": "String", "role": "Measure", "nullable": true},
        {"name": "Me_2", "type": "String", "role": "Measure", "nullable": true}
      ]
    }
  ]
}

expected/DS_r.csv ⇩

Id_1Me_1Me_2Me_3
1foobarfoobar
2abcdabcd
3x

expected/DS_r.json ⇩

{
  "datasets": [
    {
      "name": "DS_r",
      "DataStructure": [
        {"name": "Id_1", "type": "Integer", "role": "Identifier"},
        {"name": "Me_1", "type": "String", "role": "Measure"},
        {"name": "Me_2", "type": "String", "role": "Measure"},
        {"name": "Me_3", "type": "String", "role": "Measure"}
      ]
    }
  ]
}