sdmx-twg / vtl

This repository is used for maintaining the SDMX-VTL specification
11 stars 7 forks source link

Allow set of components as argument of UDOs #389

Open antonio-olleros opened 8 months ago

antonio-olleros commented 8 months ago

Issue Description

In some cases, we want to write UDOs that are valid for different data structures. That is generally possible, but if we cannot pass as argument a dynamic number of components, the functionality is limited in cases of aggregations. For instance:

define operator moving_agerage  (DS dataset, part_comp component, order_comp component, number_periods integer)
returns dataset is
    avg(
        DS
            over(
                partition by part_comp
                order by order_comp asc
                data points between number_periods preceding and current data point
        )
    )
end operator;

This operator is only valid for partitions with one component. If we wanted partitions by two components, we would need to write a new UDO.

Proposed Solution

We would like to be able to write the UDO like this:

define operator moving_agerage  (DS dataset, part_comps component_set, order_comp component, number_periods integer)
returns dataset is
    avg(
        DS
            over(
                partition by part_comps
                order by order_comp asc
                data points between number_periods preceding and current data point
        )
    )
end operator;