← subtraction operator page · numeric/subtraction/comp_comp/integer_minus_number

Integer minus number 🟢 all ok

pandas ✅ · DuckDB ✅

Tests:

an Integer component minus a Number component, inside calc.

Manual:

Subtraction: "If one of the operands is of type number, then the other operand is implicitly cast to number and therefore the result has type number."

Expected:

Me_3 = Me_1 - Me_2: 2 - 2.5 = -0.5, 4 - 4.0 = 0.0 and 5 - 0.5 = 4.5, a Number; the other components are kept.

script.vtl ⇩

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

input/DS_1.csv ⇩

Id_1Me_1Me_2
122.5
244.0
350.5

input/DS_1.json ⇩

{
  "datasets": [
    {
      "name": "DS_1",
      "DataStructure": [
        {"name": "Id_1", "type": "Integer", "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_1Me_1Me_2Me_3
122.500000-0.500000
244.0000000.000000
350.5000004.500000

expected/DS_r.json ⇩

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