← length operator page · string/length/comp/manual_ex_3

Manual example 3 🟢 all ok

pandas ✅ · DuckDB ✅

Tests:

two length calls in one calc on DS_2, where Me_1 is null in one data point.

Manual:

String length, Example 3, output verbatim: "Returns the length of a string."

Expected:

Me_10 is 5 and null, and Me_20 is 5 and 2; 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).

script.vtl ⇩

DS_r := DS_2 [calc Me_10:= length(Me_1), Me_20:=length(Me_2)];

input/DS_2.csv ⇩

Id_1Id_2Me_1Me_2
1Ahelloworld
2Bhi

input/DS_2.json ⇩

{
  "datasets": [
    {
      "name": "DS_2",
      "DataStructure": [
        {"name": "Id_1", "type": "Integer", "role": "Identifier", "nullable": false},
        {"name": "Id_2", "type": "String", "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_1Id_2Me_1Me_2Me_10Me_20
1Ahelloworld55
2Bhi2

expected/DS_r.json ⇩

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