← instr operator page · string/instr/comp_params/all_parameters_from_components

All parameters from components 🟢 all ok

pandas ✅ · DuckDB ✅

Tests:

instr(Me_1, Me_2, Me_3, Me_4) inside calc: pattern, start and occurrence all come from components.

Manual:

String pattern location types occurrence as component<integer [value >= 1]> | integer [value >= 1], and "If the nth occurrence of the string-pattern after the start th character is not found in the input string, the returned value is 0."

Expected:

Me_5 is 8, 4, 5 and 0: the 2nd o of hello world is at 8, an from the 3rd character of banana at 4, the 3rd o of o-o-o at 5, and hello has no 2nd o.

script.vtl ⇩

DS_r := DS_1[calc Me_5 := instr(Me_1, Me_2, Me_3, Me_4)];

input/DS_1.csv ⇩

Id_1Me_1Me_2Me_3Me_4
1hello worldo12
2bananaan31
3o-o-oo13
4helloo12

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},
        {"name": "Me_3", "type": "Integer", "role": "Measure", "nullable": true},
        {"name": "Me_4", "type": "Integer", "role": "Measure", "nullable": true}
      ]
    }
  ]
}

expected/DS_r.csv ⇩

Id_1Me_1Me_2Me_3Me_4Me_5
1hello worldo128
2bananaan314
3o-o-oo135
4helloo120

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": "Integer", "role": "Measure"},
        {"name": "Me_4", "type": "Integer", "role": "Measure"},
        {"name": "Me_5", "type": "Integer", "role": "Measure"}
      ]
    }
  ]
}