Академический Документы
Профессиональный Документы
Культура Документы
In HDI modeling the last node (Default node) of Calculation Views shows a different aggregation behavior
than it shows for Calculation Views in the old HANA repository.
Differences can occur when
a) filters are applied on measures in the end user query
b) the end user query requests a different aggregation behavior than the behavior defined in the
Default node, i.e., the last node below the Default node
The overall motivation for a different treatment of the Default Node in HDI was to make the Default
Node overwritable by the end user query to avoid unexpected aggregation behaviors. This
overwriting of the modeled aggregation which leads to a kind of transparency of the Default Node to
the end user query will be discussed in more detail under b)
Examples
Use the following statements to create a table and fill the table with values. This table will be used
throughout the examples:
Applying the filter for sales > 1000 afterwards will not remove entries because all aggregated values are
above 1000. Therefore, you will see the following results being returned:
Now let’s turn to modeling in HDI and recreate the same model in SAP Web IDE for SAP HANA:
Running the same query will return different results:
The reason is that now the filtering for sales>1000 is done before the aggregation. Therefore, the values
400 and 700 of Bike are filtered out first, which leaves only one value for Bike to be aggregated:
If the old behavior should be restored an aggregation node can be put below the Default node and by this
force the aggregation to happen before the filtering. The reason that this works is that the filter on
measures only “passes” the Default Node but not further aggregation nodes below:
leads to:
In sum, modeling the view in SAP HANA Studio will apply the filter after the Default Node aggregation.
Modeling in SAP Web IDE for SAP HANA will apply the filter before the Default Node aggregation. If you
want to achieve the old SAP HANA Studio behavior you will need to add an additional aggregation node
below the Default Node.
Case 2. Aggregation behavior for measures
If an end-user query defines a different aggregation function than is defined in the Default Node the
behavior of models created in SAP HANA Studio will calculate the user query aggregation after the Default
Node aggregation. Models created in SAP Web IDE for SAP HANA will replace the Default Node
aggregation with the aggregation of the user query.
As an example let’s use the model from above but change the aggregation of the Default Node to "Count"
Running the same query from above but without the filter to avoid confusing effects of a) and b)
SELECT
"ARTICLE",
SUM(sales)
from
"_SYS_BIC"."…/ON_TABLEWHEREFILTERONMEASURE"
GROUP BY
"ARTICLE"
What happens is that Count is first executed resulting in 2 for Car and 3 for Bike. This is afterwards
summed up as requested by the SQL query. Given that the SQL Query does not remove a column and thus
keeps the same aggregation columns the result does not change anymore by the SUM aggregation.
However, it might come as a surprise to the end user to see Count values while the end user query
requests SUM values. Also the other way around would be surprising. Imagine the Default Node
aggregation of SUM is followed up by a Count defined in the end user query. In this case Count would
work on the summed values and therefore only return 1 for each ARTICLE.
This surprising behavior has thus been changed in HDI and if you run the same query on the same model
but deployed in HDI you will see the following results when the end user query requests SUM:
The aggregation “SUM” that has been defined in the user query has replaced the aggregation behavior of
the Default Node.
Analogously, if the end user query requests Count you will, irrespective of the aggregation defined in the
Default Node see:
Again, if you wanted to reproduce the old behavior you would need to add another aggregation node
before the Default Node. This will force the aggregation defined in the lower aggregation node to be
executed and not being overwritten by the aggregation that is defined in the user query:
Even if the end user query requests SUM the result will contain the Count values (followed up by the SUM
defined in the end user query)