← time_agg operator page · time/time_agg/group_all/manual_ex_1

Manual example 1 🟢 all ok

pandas ✅ · DuckDB ✅

Tests:

sum(DS_1 group all time_agg("A")): the quarters of 2010 summed by year, time_agg used with an aggregation and no operand.

Manual:

Time aggregation, Example 1, its data points verbatim: "VTL also provides a component version, for use in combination with an aggregation operator, because the change of frequency requires an aggregation."

Expected:

2010 with 60, 100 and 20 for A, B and C. Me_1 may be Integer or Number: Sum declares a number, but "implementations may preserve the integer type for the resulting measure or component when all operand values are integer"; the manual's output writes Integer, one of the two.

script.vtl ⇩

DS_r := sum ( DS_1  group all time_agg ( "A" ));

input/DS_1.csv ⇩

Id_1Id_2Me_1
2010Q1A20
2010Q2A20
2010Q3A20
2010Q1B50
2010Q2B50
2010Q1C10
2010Q2C10

input/DS_1.json ⇩

{
  "datasets": [
    {
      "name": "DS_1",
      "DataStructure": [
        {"name": "Id_1", "type": "Time_Period", "role": "Identifier", "nullable": false},
        {"name": "Id_2", "type": "String", "role": "Identifier", "nullable": false},
        {"name": "Me_1", "type": "Integer", "role": "Measure", "nullable": true}
      ]
    }
  ]
}

expected/DS_r.csv ⇩

Id_1Id_2Me_1
2010A60
2010B100
2010C20

expected/DS_r.json ⇩

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