← membership operator page · general/membership/viral_attribute/manual_ex_8

Manual example 8 🟢 all ok

pandas ✅ · DuckDB ✅

Tests:

SC_r := DS_2#At_1 on a viral attribute of a dataset that has identifiers.

Manual:

Membership, Example 8: "The membership operator returns a Data Set having the same Identifier Components of ds and a single Measure." As in Manual example 6, ds_2.json names its dataset DS_1.

Expected:

The dataset of Manual example 6, assigned to SC_r.

Erratum:

The manual expects the scalar "P", but the scalar rule is for a dataset without identifiers, and DS_2 has Id_1, Id_2 and three data points, so the general rule gives a dataset. The scalar case has its own example, Dataset without identifiers.

Adaptation:

string_var is written str_var, as in Manual example 3.

Team decision:

#1257: as the comments on sdmx-twg/vtl#731 propose, a viral Attribute needs a propagation rule only where its values are combined, until the VTL Task Force discusses it.

script.vtl ⇩

SC_r := DS_2#At_1;

input/DS_2.csv ⇩

Id_1Id_2Me_1Me_2At_1
1A15
1B210P
2A312

input/DS_2.json ⇩

{
  "datasets": [
    {
      "name": "DS_2",
      "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": "ViralAttribute", "nullable": true}
      ]
    }
  ]
}

expected/SC_r.csv ⇩

Id_1Id_2str_varAt_1
1A
1BPP
2A

expected/SC_r.json ⇩

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