← membership operator page · general/membership/on_aggregate/manual_ex_7

Manual example 7 🟢 all ok

pandas ✅ · DuckDB ✅

Tests:

max(DS_1)#Me_1: membership on the result of an aggregate invocation, which has no identifiers, gives a scalar.

Manual:

Membership, Example 7, output verbatim: "If ds has no Identifier Components (for example is a result of an aggregate invocation), [...] the operator returns a scalar value equal to the value of comp in ds".

Expected:

max(DS_1) has one data point, Me_1 = 3 and Me_2 = 12, so SC_r = 3, an Integer.

script.vtl ⇩

SC_r := max(DS_1)#Me_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/scalars.json ⇩

{
  "scalars": [
    {"name": "SC_r", "type": "Integer", "value": "3"}
  ]
}