Uploaded image for project: 'OASIS Open Data Protocol (OData) TC'
  1. OASIS Open Data Protocol (OData) TC
  2. ODATA-827

introduce $compute query option

    XMLWordPrintable

    Details

    • Proposal:
      Hide

      Add "$compute" query option allowing additional computed properties to be added to each instance. The syntax is similar to the compute() transformation in Data Aggregation, i.e. $compute=<list of compute expressions>, but without the restriction to simple values: allowed compute expressions are any expressions valid in a $filter system query option on the input set.

      More formally:
      compute = '$compute' EQ computeItem *( COMMA computeItem )
      computeItem = commonExpr RWS 'as' RWS computedProperty
      computedProperty = odataIdentifier

      $compute is also allowed as query option nested within $expand to add computed dynamic properties to expanded entities.

      $compute is logically evaluated first, so the computed dynamic properties can be used in $expand, $filter, $orderby, and $select.

      Computed structural properties SHOULD be added to the default selection (in absence of $select), and are treated as other dynamic properties:

      • $select=* includes computed structural properties
      • $expand=* includes computed navigation properties or computed entities/collections of entities
      • appear in context URL same way as other (dynamic) properties

      GET ~Customers?$expand=Orders($compute=price*qty as totalprice;$select=name,price,qty,totalprice)

      Note: in this example, totalprice is available outside of the expand as Orders/totalprice, as in:
      GET ~Customers?$filter=Orders/any(o:o/totalprice gt 100)&$expand=Orders($compute=price*qty as totalprice;$select=name,price,qty,totalprice)

      Show
      Add "$compute" query option allowing additional computed properties to be added to each instance. The syntax is similar to the compute() transformation in Data Aggregation, i.e. $compute=<list of compute expressions>, but without the restriction to simple values: allowed compute expressions are any expressions valid in a $filter system query option on the input set. More formally: compute = '$compute' EQ computeItem *( COMMA computeItem ) computeItem = commonExpr RWS 'as' RWS computedProperty computedProperty = odataIdentifier $compute is also allowed as query option nested within $expand to add computed dynamic properties to expanded entities. $compute is logically evaluated first, so the computed dynamic properties can be used in $expand, $filter, $orderby, and $select. Computed structural properties SHOULD be added to the default selection (in absence of $select), and are treated as other dynamic properties: $select=* includes computed structural properties $expand=* includes computed navigation properties or computed entities/collections of entities appear in context URL same way as other (dynamic) properties GET ~Customers?$expand=Orders($compute=price*qty as totalprice;$select=name,price,qty,totalprice) Note: in this example, totalprice is available outside of the expand as Orders/totalprice, as in: GET ~Customers?$filter=Orders/any(o:o/totalprice gt 100)&$expand=Orders($compute=price*qty as totalprice;$select=name,price,qty,totalprice)
    • Resolution:
      Show
      https://tools.oasis-open.org/version-control/browse/wsvn/odata/trunk/4.01%20spec/ABNF/odata-abnf-construction-rules.txt?op=diff&rev=898 https://tools.oasis-open.org/version-control/browse/wsvn/odata/trunk/4.01%20spec/ABNF/odata-abnf-testcases.xml?op=diff&rev=898

      Description

      OData could be extended to allow derived computed values to be returned along with the properties of an entity.

      This could be expressed as:

      http://odata.netflix.com/v2/Catalog/Titles?$compute=substring(ShortSynopsis,20) as Summary&$select=Name,Summary

      In ODATA-9 we added support for an equivalent compute transformation in our Data Aggregation Extensions.

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              andrew.eisenberg Andrew Eisenberg
            • Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: