cancel
Showing results for 
Search instead for 
Did you mean: 

Windowing Functions in CAP CDL

tfillinger
Discoverer
0 Kudos
378

Hi all.

I'm trying to define a view-entity with the hana row_number()-windowing function. The definition is

entity testtable {
  key id: Integer;
  key validfrom: Date;
      measure: Decimal(10,2);
};

entity tmp_test_rownum 
as select from testtable 
{
  row_number() over ( partition by id order by measure asc, validfrom desc) as rownum,
//                  ^
//                  |
  id,
  measure,
  validfrom
};

The cds-compiler ends up with error:

"Mismatched '(', expecting ',', '.', ':', '{', '@', FROM"
at position I've marked above

What is the correct form to use the function in CDL?

Thanks in advanced,

Thomas.

View Entire Topic
079695
Advisor
Advisor

Unfortunately, this syntax is not yet supported in CAP CDL. As a workaround, you can create a native hdbview that contains the partition by logic and then declare a proxy entity in your CAP model as described in the guide here.

tfillinger
Discoverer
0 Kudos

Dear Elena.

I thought as much 🙂 and thank you for your hint to the native view.

Cheers, Thomas.