Skip to main content

default_aggregation

Definition

The default_aggregation in Veezoo is used to define the aggregation operation that should be applied by default to a certain numeric attribute when a user asks a question that requires aggregation.

For example, if you are querying about "temperature per year", you would likely want to see the average temperature for each year, rather than the sum of all temperatures recorded within a year. In such cases, the attribute Temperature should have average as its default_aggregation.

Usage

In your Veezoo Knowledge Layer (VKL) code, you can set the default_aggregation for an attribute. Here is an example of how you can set the default_aggregation for the temperature attribute:

kb {
class WeatherData {
name.en: "Weather Data"

...

number Temperature {
name.en: "Temperature"

sql: "${WEATHER_DATA.temperature}"

default_aggregation: average
}
}
}

In this example, the default_aggregation for the temperature attribute is set to avg (average). This means that when a user asks something like "what is the temperature per year", Veezoo will compute the average temperature per year.

Possible Aggregation Operations

The possible aggregation operations you can use as default_aggregation are:

  • average: Average
  • sum: Sum
  • median: Median

By default, if no default_aggregation is specified, Veezoo uses sum as the default aggregation operation.

Why Use Default Aggregation

Setting the default_aggregation in Veezoo helps in creating more accurate and meaningful insights from data. The choice of aggregation operation can significantly impact the interpretation of the results. For instance, averaging temperatures provides a more accurate representation of a year's overall climate compared to summing them up. Hence, specifying the right default_aggregation is crucial for producing reliable and interpretable data visualizations and insights.