← subtraction operator page · numeric/subtraction/comp_sc/manual_ex_3

Manual example 3 🟢 all ok

pandas ✅ · DuckDB ✅

Tests:

- between an Integer component and an integer scalar, inside calc.

Manual:

Subtraction, Example 3, output verbatim: "The operator subtraction returns the difference of two numbers."

Expected:

Me_3 = Me_1 - 3 is 2, -1, 0 and 1, an Integer as both operands are integers; the other components are kept.

script.vtl ⇩

DS_r := DS_1 [ calc Me_3 := Me_1 - 3 ];

input/DS_1.csv ⇩

Id_1Id_2Me_1Me_2
10A55.0
10B210.5
11A312.2
11B420.3

input/DS_1.json ⇩

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

expected/DS_r.csv ⇩

Id_1Id_2Me_1Me_2Me_3
10A55.02
10B210.5-1
11A312.20
11B420.31

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