← calc operator page · clause/calc/multiple/items_are_independent

Items are independent 🟢 all ok

pandas ✅ · DuckDB ✅

Tests:

calc Me_1 := Me_1 + 1, Me_2 := Me_1 * 10: the second item reads Me_1, which the first one recalculates.

Manual:

Calculation of a Component: "The calcExpr sub-expressions are independent one another, they can only reference Components of the input Data Set and cannot use Components generated, for example, by other calcExpr."

Expected:

Me_1 = 11 and 21, and Me_2 = 100 and 200, from the Me_1 of the input (10 and 20), not from the first item; a sequential evaluation would give 110 and 210.

script.vtl ⇩

DS_r := DS_1 [ calc Me_1 := Me_1 + 1, Me_2 := Me_1 * 10 ];

input/DS_1.csv ⇩

Id_1Me_1
110
220

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

expected/DS_r.csv ⇩

Id_1Me_1Me_2
111100
221200

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": "Integer", "role": "Measure"}
      ]
    }
  ]
}