Professional Documents
Culture Documents
Unkeep Attribute Could Not Be Removed
Unkeep Attribute Could Not Be Removed
Contents
Error Description ................................................................................................................................. 1
Explanation .......................................................................................................................................... 2
Switch off Error Message via Parameter ............................................................................................. 2
Disclaimer ............................................................................................................................................ 3
Sample Queries ................................................................................................................................... 3
Query without Filter on Time Characteristic ................................................................................... 3
Query with Filter on Time Characteristic and Characteristic not added to GROUP BY ................... 4
Query with Filter on Time Characteristic and Characteristic added to GROUP BY ......................... 5
Query with Filter on Time Characteristic and 'finer' Time Characteristic added to GROUP BY ...... 6
Query with Single Value Equal Condition ........................................................................................ 7
Error Description
A SQL query against an External SAP HANA View with Non-Cumulatives that does not consider the
restriction below, as documented in SAP Note 2032830, fails with error message "Unkeep Attribute
could not be removed".
SAP Note 2032830 - External SAP HANA view: Inventory key figures (non-cumulative key figures)
Explanation
1. Non-cumulative key figures are not persisted but calculated at query runtime based on delta
movements and reference points. Therefore, it is not possible to evaluate filter conditions on
time characteristics before the non-cumulative key figures are calculated by the L node of the
calculation scenario.
2. Because of (1) a filter on a time characteristic must be applied after the computation of the non-
cumulative key figures.
3. Because of (2) the time characteristic on which a filter is defined must be processed by the
L node of the calculation scenario as if it had been selected (as part of the field list in the SELECT
and GROUP BY clauses).
4. All records which match the filter condition are then passed to the standard SQL/calculation
scenario processing and there, the specified aggregation is used to aggregate records with the
same "key" (according to the user specified SELECT and GROUP BY clause).
This would, in many cases, result in wrong query results because the special handling for
aggregation of non-cumulative key figures over time is not considered in (4).
To avoid such issues, the generated External SAP HANA View uses the modeling property
'Transparent Filter' on all time characteristics. This in turn leads to the error message "Unkeep
Attribute could not be removed" when a time characteristic is not part of the SELECT and GROUP
BY clause but filtered and the Calculation Engine fails removing that time characteristic from the
internal drilldown.
1. Queries with filter on time characteristic and 'finer' time characteristic added to GROUP BY
Assumed a query uses a time characteristic in the SELECT and GROUP BY clause which is
'finer' than the time characteristic on which the filter is defined. In this special scenario, there
is no need for an aggregation over time after the application of the filter and therefore, the
result of the query is correct.
A time characteristic A is 'finer' than a time characteristic B if for each value of A, it is possible
to uniquely determine a single value of the characteristic B, e.g. 0CALMONTH is finer than
0CALYEAR, but 0CALWEEK is NOT finer than 0CALMONTH.
In the query execution we do not recognize this special scenario and therefore, even in this
case, the query ends up in the above-mentioned error message. It is possible, however, to
suppress the error by setting a parameter via the placeholder syntax as shown below in the
sample queries.
Disclaimer
The SAP HANA placeholder parameter ('PLACEHOLDER' = ('ce_settings','{"disabled_patterns":
"39"}')) is an internal parameter and may only be used in the context of this SAP Note. Using such a
parameter requires that
Sample Queries
The InfoProvider contains a non-cumulative key figure 'STOCK' (with aggregation LAST) and a delta
key figure 'DELTA' is assigned to 'STOCK'.
The InfoProvider contains the records shown below in the inbound queue table. The requests in the
InfoProvider have not been activated yet.
SELECT
"0CALMONTH",
"0MATERIAL",
sum("DELTA"),
sum("STOCK")
FROM <External SAP HANA View>
GROUP BY
"0CALMONTH",
"0MATERIAL"
Result:
SELECT
"0MATERIAL",
sum("DELTA"),
sum("STOCK")
FROM <External SAP HANA View>
WHERE "0CALMONTH" BETWEEN '201902' AND '201903'
GROUP BY
"0MATERIAL"
If we pushed down the filter through the L node of the calculation scenario which computes the non-
cumulative key figures, then only the records matching the filter condition would be considered, in
this example the record with date 2019-02-03. This would lead to wrong query results because also
delta movements in 2019-01 must be considered to calculate the stock value. Therefore, it is not
possible to push down the filter. We must apply the filter after the computation of the non-
cumulative key figures.
To be able to filter after the computation of the non-cumulative key figures, we must add the filter
characteristic to the internal drilldown of the intermediate result set.
Therefore, the first intermediate result after calculating the non-cumulative key figures is the same
result that we have seen above, when selecting 0CALMONTH in the query:
Then, we remove all records that do not match the filter condition. This step leads to:
Now, as the filter has been applied, we would remove the column 0CALMONTH as it is not in the field
list of the SELECT and GROUP BY clause:
And finally, we would get the result of the query by aggregating all records with the same values for
the GROUP BY characteristics using the given aggregation (sum("STOCK")):
SELECT
"0CALMONTH",
"0MATERIAL",
sum("DELTA"),
sum("STOCK")
FROM <External SAP HANA View>
WHERE "0CALMONTH" BETWEEN '201902' AND '201903'
GROUP BY
"0CALMONTH",
"0MATERIAL"
As explained for the previous sample query, it is not possible to push down the filter through the
L node of the calculation scenario which computes the non-cumulative key figures. And to be able to
filter after the computation of the non-cumulative key figures, we must add the filter characteristic
to the internal drilldown of the calculation scenario.
Therefore, the first intermediate result after calculating the non-cumulative key figures is the same
result that we have seen above, when selecting 0CALMONTH in the query:
The second intermediate result after applying the filter is the final result. No additional aggregation is
needed for this sample query:
Therefore, the query would fail with error message "Unkeep Attribute could not be removed".
SELECT
"0CALMONTH",
"0MATERIAL",
sum("DELTA"),
sum("STOCK")
FROM <External SAP HANA View>
WHERE "0CALYEAR" BETWEEN '2019' AND '2020'
GROUP BY
"0CALMONTH",
"0MATERIAL"
However, as 0CALMONTH is finer than 0CALYEAR and 0CALMONTH is selected in the query, it is
possible to use the following parameter to switch off the error if the disclaimer above is considered.
In this special scenario, there is no need for an aggregation over time after the application of the
filter and therefore, the result of the query is correct.
SELECT
"0CALMONTH",
"0MATERIAL",
sum("DELTA"),
sum("STOCK")
FROM <External SAP HANA View>
('PLACEHOLDER' = ('ce_settings','{"disabled_patterns": "39"}') )
WHERE "0CALYEAR" BETWEEN '2019' AND '2020'
GROUP BY
"0CALMONTH",
"0MATERIAL"
Query with Single Value Equal Condition
Queries with a filter representing a single value equal condition might cause the error "Unkeep
Attribute could not be removed" although the query uses a filter on a time characteristic and that
time characteristic is in the SELECT and GROUP BY clause. In that scenario, the SQL optimizer may
transform the GROUP BY clause internally and remove the characteristic from the internal GROUP
BY. Thus, the error message is triggered.
As a workaround, in this scenario, either a parameter via the placeholder syntax can be used as
shown below in the sample queries – or the hint NO_GROUPING_SIMPLIFICATION can be added to the
query.
SELECT
"0CALMONTH",
"0MATERIAL",
sum("DELTA"),
sum("STOCK")
FROM <External SAP HANA View>
WHERE "0CALMONTH" = '201902'
GROUP BY
"0CALMONTH",
"0MATERIAL"
SELECT
"0CALMONTH",
"0MATERIAL",
sum("DELTA"),
sum("STOCK")
FROM <External SAP HANA View>
('PLACEHOLDER' = ('ce_settings','{"disabled_patterns": "39"}') )
WHERE "0CALMONTH" = '201902'
GROUP BY
"0CALMONTH",
"0MATERIAL"
SELECT
"0CALMONTH",
"0MATERIAL",
sum("DELTA"),
sum("STOCK")
FROM <External SAP HANA View>
WHERE "0CALMONTH" = '201902'
GROUP BY
"0CALMONTH",
"0MATERIAL"
WITH HINT( NO_GROUPING_SIMPLIFICATION )