← membership operator page · general/membership/attribute/manual_ex_3

Manual example 3 🟢 all ok

pandas ✅ · DuckDB ✅

Tests:

DS_1#At_1 on a non-viral attribute: its values become a new measure, and the attribute itself is dropped.

Manual:

Membership, Example 3: "A default conventional name is assigned to the new Measure depending on its type: for example num_var if the Measure is numeric, string_var if it is string".

Expected:

Id_1, Id_2 and a String measure with the values of At_1; the values are the manual's.

Adaptation:

The manual names the new measure string_var; the expected output names it str_var, vtlengine's default name for a String measure, documented in docs/data_types.rst. Default names "can be personalised in the implementations" (Typical behaviour).

script.vtl ⇩

DS_r := DS_1#At_1;

input/DS_1.csv ⇩

Id_1Id_2Me_1Me_2At_1
1A15
1B210P
2A312

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

expected/DS_r.csv ⇩

Id_1Id_2str_var
1A
1BP
2A

expected/DS_r.json ⇩

{
  "datasets": [
    {
      "name": "DS_r",
      "DataStructure": [
        {"name": "Id_1", "type": "Integer", "role": "Identifier"},
        {"name": "Id_2", "type": "String", "role": "Identifier"},
        {"name": "str_var", "type": "String", "role": "Measure"}
      ]
    }
  ]
}