← sqrt operator page · numeric/sqrt/comp/manual_ex_2

Manual example 2 🟢 all ok

pandas ✅ · DuckDB ✅

Tests:

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

Manual:

Square root, Example 2, output verbatim: "The operator sqrt calculates the square root of a number."

Expected:

Me_1 = sqrt(Me_1) is 4.0, 9.0 and 8.0; Me_2 is unchanged.

script.vtl ⇩

DS_r := DS_1 [ calc Me_1 := sqrt ( Me_1 ) ];

input/DS_1.csv ⇩

Id_1Id_2Me_1Me_2
10A161.5625
10B8111.2225
11A6452.5625

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
10A4.01.5625
10B9.011.2225
11A8.052.5625

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