← power operator page · numeric/power/comp_sc/manual_ex_2

Manual example 2 🟢 all ok

pandas ✅ · DuckDB ✅

Tests:

power on a component inside calc, where the result replaces the measure Me_1.

Manual:

Power, Example 2, output verbatim: "The operator power raises a number (the base) to another one (the exponent)."

Expected:

Me_1 = power(Me_1, 2) is 9.0, 16.0 and 25.0, a Number; Me_2 is unchanged.

script.vtl ⇩

DS_r := DS_1[ calc Me_1 := power(Me_1, 2) ];

input/DS_1.csv ⇩

Id_1Id_2Me_1Me_2
10A30.7545
10B413.45
11A51.87

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
10A9.00.7545
10B16.013.45
11A25.01.87

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