← substr operator page · string/substr/ds_noargs/start_and_length_omitted

Start and length omitted 🟢 all ok

pandas ✅ · DuckDB ✅

Tests:

substr(DS_1) with neither start nor length.

Manual:

Sub-string extraction: "If start is omitted, the substring starts from the 1st position." and "If length is omitted or overcomes the length of the input string, the substring ends at the end of the input string."

Expected:

the substring runs from the 1st position to the end, so every value comes out as it went in. 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 := substr(DS_1);

input/DS_1.csv ⇩

Id_1Me_1
1hello world
2ab
3

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}
      ]
    }
  ]
}

expected/DS_r.csv ⇩

Id_1Me_1
1hello world
2ab
3

expected/DS_r.json ⇩

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