← calc operator page · clause/calc/measure_default/existing_attribute_keeps_role

Existing attribute keeps role 🟢 all ok

pandas ✅ · DuckDB ✅

Tests:

calc At_1 := "X" with no role: At_1 is an Attribute of DS_1.

Manual:

Calculation of a Component: "if the component exists in the operand Data Set then it maintains its role", and "If the Calculated component is a Measure or an Attribute that already exists in the input Data Set, the calculated values overwrite the original values".

Expected:

At_1 stays an Attribute, with X on every data point; Id_1 and Me_1 are unchanged.

script.vtl ⇩

DS_r := DS_1 [ calc At_1 := "X" ];

input/DS_1.csv ⇩

Id_1Me_1At_1
110A
220B

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": "At_1", "type": "String", "role": "Attribute", "nullable": true}
      ]
    }
  ]
}

expected/DS_r.csv ⇩

Id_1Me_1At_1
110X
220X

expected/DS_r.json ⇩

{
  "datasets": [
    {
      "name": "DS_r",
      "DataStructure": [
        {"name": "Id_1", "type": "Integer", "role": "Identifier"},
        {"name": "Me_1", "type": "Integer", "role": "Measure"},
        {"name": "At_1", "type": "String", "role": "Attribute"}
      ]
    }
  ]
}