← addition operator page · numeric/addition/comp_comp/integer_plus_number

Integer plus number 🟢 all ok

pandas ✅ · DuckDB ✅

Tests:

the sum of an Integer component and a Number component, inside calc.

Manual:

Addition: "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 = 4.5, 4 + 4.0 = 8.0 and 5 + 0.5 = 5.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.5000004.500000
244.0000008.000000
350.5000005.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"}
      ]
    }
  ]
}