← addition operator page · numeric/addition/sc_ds/integer_and_number_measures

Integer and number measures 🟢 all ok

pandas ✅ · DuckDB ✅

Tests:

a scalar added to every measure of a dataset that has an Integer and a Number measure.

Manual:

Addition: "If the type of both operands is integer then the result has type integer. If one of the operands is of type number, ... the result has type number."

Expected:

3 + DS_1: Me_1 (Integer) 5, 7 and 8; Me_2 (Number) 5.5, 7.0 and 3.5.

script.vtl ⇩

DS_r := 3 + DS_1;

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_2
155.500000
277.000000
383.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"}
      ]
    }
  ]
}