28.01.2013 Views

SAP HANA Developer Guide - Get a Free Blog

SAP HANA Developer Guide - Get a Free Blog

SAP HANA Developer Guide - Get a Free Blog

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Derived Aggregation<br />

The simplest way to define aggregations of columns in an object is to derive this information from metadata in the<br />

database. The only objects with this information are calculation views and analytic views. For all other object<br />

types, for example, tables and SQL views, the activation will not work. To cause the service to use derived<br />

information, you must specify the keywords aggregates always, as illustrated in the following example:<br />

service {<br />

"sample.odata:calc.calculationview" as "CalcView"<br />

keys generate local "ID"<br />

aggregates always;<br />

}<br />

Explicit Aggregation<br />

The example for the explicit aggregation is based on the following table definition:<br />

sample.odata:revenues.hdbtable<br />

table.schemaName = "ODATASAMPLES";<br />

table.tableType = COLUMNSTORE;<br />

table.columns = [<br />

{name = "Month"; sqlType = INTEGER; nullable = false;},<br />

{name = "Year"; sqlType = INTEGER; nullable = false;},<br />

{name = "Amount"; sqlType = INTEGER; nullable = true;}<br />

];<br />

table.primaryKey.pkcolumns = ["Month","Year"];<br />

You can aggregate the columns of objects (without metadata) that are necessary for the derivation of aggregation<br />

by explicitly denoting the column names and the functions to use, as illustrated in the following example of a<br />

service definition: sample.odata:aggrexpl.xsodata<br />

service {<br />

"sample.odata:revenues.hdbtable" as "Revenues"<br />

keys generate local "ID"<br />

aggregates always (SUM of "Amount");<br />

}<br />

The results of the entity set Revenues always contain the aggregated value of the column Amount. To extract<br />

the aggregated revenue amount per year, add $select=Year,Amount to your requested URI.<br />

OData Parameter Entity Sets<br />

<strong>SAP</strong> <strong>HANA</strong> calculation views and analytic views can interpret input parameters. For OData, these parameters can<br />

be entered by using a special parameter entity set.<br />

Parameter entity sets can be generated for both calculation views and analytic views by adding parameters via<br />

entity to the entity:<br />

service {<br />

"sample.odata:calc.calculationview" as "CalcView"<br />

keys generate local "ID"<br />

200<br />

P U B L I C<br />

© 2012 <strong>SAP</strong> AG. All rights reserved.<br />

<strong>SAP</strong> <strong>HANA</strong> <strong>Developer</strong> <strong>Guide</strong><br />

Defining Web-based Data Access

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!