You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@olingo.apache.org by Zhiqiang Ren <al...@gmail.com> on 2017/01/11 21:51:44 UTC
Does Olingo support the usage of user-defined functions in $filter query?
Hi all,
I am newbie to OData and Olingo. Currently I want to build a query service
following the syntax of the $filter query in OData. I am using the Olingo
library for parsing the $filter query string.
It seems that OData V4 supports the usage of user-defined function in
$filter query. (Correct me if I am wrong.) The following query
"$filter=xx.Myfun(x=xx.Myfun(x=3)) eq 1" can be parsed by the Olingo
library for OData V4 if CsdlAbstractEdmProvider is implemented
appropriately. However, I notice that the result is of type "expression",
which has no subclass for the structure of function call. Is it true that
Olingo does not support the usage of user-defined functions in $filter
query? Thanks.
RE: Does Olingo support the usage of user-defined functions in
$filter query?
Posted by "Grande, Oliver" <ol...@sap.com>.
Hello Zhiqiang,
actually Olingo is able to do so.
I tried it out. In my example implementation I have an entity storing the population and the area of a region. The area is stored in m2 . I have created a function that calculates the population density. As a density is usually given in km-2. I convert the area from m2 into km2 before I put it into the density function, which leads to the following URL:
…/AdministrativeDivisions?$filter=test.PopulationDensity(Area=test.ConvertToQkm(Area=$it/Area),Population=$it/Population) gt 1000
What you get with the “expression” is parsed version of $filter expression, which is provided as kind of syntax tree. In my example the “expression” contains as Left the function PopulationDensity, which has a as parameter the other function and so on:
[cid:image003.jpg@01D26CCC.B6E93270]
I hope that helps.
Regards,
Oliver
Oliver Grande
PI IC HC Clinical Decision Support DE
SAP SE Dietmar-Hopp-Allee 16, 69190 Walldorf, Germany
E oliver.grande@sap.com
Pflichtangaben/Mandatory Disclosure Statement:
http://www.sap.com/company/legal/impressum.epx
Diese E-Mail kann Betriebs- oder Geschäftsgeheimnisse oder sonstige vertrauliche Informationen enthalten. Sollten Sie diese E-Mail irrtümlich erhalten haben, ist Ihnen eine Kenntnisnahme des Inhalts, eine Vervielfältigung oder Weitergabe der E-Mail ausdrücklich untersagt. Bitte benachrichtigen Sie uns und vernichten Sie die empfangene E-Mail.
Vielen Dank.
This e-mail may contain trade secrets or privileged, undisclosed, or otherwise confidential information. If you have received this e-mail in error, you are hereby notified that any review, copying, or distribution of it is strictly prohibited. Please inform us immediately and destroy the original transmittal.
Thank you for your cooperation
From: Zhiqiang Ren [mailto:alex.ren2006@gmail.com]
Sent: Mittwoch, 11. Januar 2017 22:52
To: user@olingo.apache.org
Subject: Does Olingo support the usage of user-defined functions in $filter query?
Hi all,
I am newbie to OData and Olingo. Currently I want to build a query service following the syntax of the $filter query in OData. I am using the Olingo library for parsing the $filter query string.
It seems that OData V4 supports the usage of user-defined function in $filter query. (Correct me if I am wrong.) The following query "$filter=xx.Myfun(x=xx.Myfun(x=3)) eq 1" can be parsed by the Olingo library for OData V4 if CsdlAbstractEdmProvider is implemented appropriately. However, I notice that the result is of type "expression", which has no subclass for the structure of function call. Is it true that Olingo does not support the usage of user-defined functions in $filter query? Thanks.