← unary_minus operator page · numeric/unary_minus/ds/manual_ex_1

Manual example 1 🟢 all ok

pandas ✅ · DuckDB ✅

Tests:

- on a dataset with an Integer measure and a Number measure.

Manual:

Unary minus, Example 1, output verbatim: "The operator - inverts the sign of op."

Expected:

both measures change sign and keep their types: Me_1 (Integer) -1, -2 and -3, Me_2 (Number) -5.0, -10.0 and -12.0.

script.vtl ⇩

DS_r := - DS_1;

input/DS_1.csv ⇩

Id_1Id_2Me_1Me_2
10A15.0
10B210.0
11A312.0

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_2
10A-1-5.0
10B-2-10.0
11A-3-12.0

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"}
      ]
    }
  ]
}