← aggr operator page · clause/aggr/group_except/manual_ex_2

Manual example 2 🟢 all ok

pandas ✅ · DuckDB ✅

Tests:

aggr Me_3 := min( Me_1 ) group except Id_3, over an Integer measure.

Manual:

Aggregation, Example 2, output verbatim: "group except: the Data Points are grouped by the values of the Identifiers not specified as groupingId. The Identifiers specified as groupingId are dropped in the result."

Expected:

Id_1, Id_2 and the smallest Me_1 of each group, 0, 3 and 2. Me_3 stays an Integer, as the manual's ex_2.json writes it: unlike sum, min allows no other type, as Minimun value says "For numeric operands, the result has the same type as the operand".

script.vtl ⇩

DS_r := DS_1 [ aggr Me_3:= min( Me_1 ) group except Id_3 ];

input/DS_1.csv ⇩

Id_1Id_2Id_3Me_1
1AXX0
1AYY2
1BXX3
1BYY5
2AXX7
2AYY2

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": "Id_3", "type": "String", "role": "Identifier", "nullable": false},
        {"name": "Me_1", "type": "Integer", "role": "Measure", "nullable": true}
      ]
    }
  ]
}

expected/DS_r.csv ⇩

Id_1Id_2Me_3
1A0
1B3
2A2

expected/DS_r.json ⇩

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