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

Clarify representation of property paths in groupby with leading segments being null

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: V4.0_CS02
    • Fix Version/s: V4.0_CSD04
    • Component/s: Data Aggregation
    • Labels:
      None
    • Environment:

      Applied

    • Proposal:
      Hide

      Rephrase the beginning of section 3.10 as follows (insertions are indented or italicized.)

      3.10 Transformation groupby

      The groupby transformation takes one or two parameters where the second is a list of set transformations, separated by forward slashes to express that they are consecutively applied.

      3.10.1 Simple Grouping

      In its simplest form the first parameter of groupby specifies the grouping properties, a comma-separated list of one or more single-valued property paths that is enclosed in parentheses. A path may consist of a sequence of single-valued navigation and complex properties. The same property path SHOULD NOT appear more than once; redundant property paths MAY be considered valid, but MUST NOT alter the meaning of the request. If the property path leads to a single-valued navigation property, this means grouping by the entity-id of the related entities. Other navigation properties specified in grouping property paths are expanded by default.

      The output set is constructed in five steps:

      1. For each instance in the input set:
        1. Create a projection of the instance with all related entities included that are reached via navigation properties that occur in the grouping properties.
        2. Remove from the projection all structural and navigation properties that are not traversed by any grouping property.
      2. The input set is split into subsets where two instances are in the same subset if their projections are the same with null considered different from absent.
      3. The set transformations from the second parameter are applied to each subset, resulting in a new set of potentially different structure and cardinality. If the second parameter is absent, each subset is transformed into a set consisting of a single instance without properties. Transformations may take into account the grouping properties for producing their result, e.g. aggregate removes properties that are used neither for grouping nor for aggregation.
      4. In each set resulting from the previous step, each entity and complex type, including nested complex and navigation properties, are augmented if necessary to include all primitive property values of the corresponding projection.
      5. The output set is the union of the augmented sets of the previous step.

      If the service is unable to group by same values for any of the specified properties, it MUST reject the request with an error response. It MUST NOT apply any implicit rules to group instances indirectly by another property related to it in some way.

       

      Show
      Rephrase the beginning of section 3.10 as follows (insertions are indented or italicized.) 3.10 Transformation groupby The groupby transformation takes one or two parameters where the second is a list of set transformations, separated by forward slashes to express that they are consecutively applied. 3.10.1 Simple Grouping In its simplest form the first parameter of groupby  specifies the grouping properties , a comma-separated list of one or more single-valued property paths that is enclosed in parentheses. A path may consist of a sequence of single-valued navigation and complex properties. The same property path SHOULD NOT appear more than once; redundant property paths MAY be considered valid, but MUST NOT alter the meaning of the request. If the property path leads to a single-valued navigation property, this means grouping by the entity-id of the related entities. Other navigation properties specified in grouping property paths are expanded by default. The output set is constructed in five steps: For each instance in the input set: Create a projection of the instance with all related entities included that are reached via navigation properties that occur in the grouping properties. Remove from the projection all structural and navigation properties that are not traversed by any grouping property. The input set is split into subsets where two instances are in the same subset if their projections are the same with null considered different from absent. The set transformations from the second parameter are applied to each subset, resulting in a new set of potentially different structure and cardinality. If the second parameter is absent, each subset is transformed into a set consisting of a single instance without properties. Transformations may take into account the grouping properties for producing their result, e.g. aggregate removes properties that are used neither for grouping nor for aggregation. In each set resulting from the previous step, each entity and complex type, including nested complex and navigation properties, are augmented if necessary to include all primitive property values of the corresponding projection. The output set is the union of the augmented sets of the previous step. If the service is unable to group by same values for any of the specified properties, it MUST reject the request with an error response. It MUST NOT apply any implicit rules to group instances indirectly by another property related to it in some way.  
    • Resolution:
      Show
      https://www.oasis-open.org/apps/org/workgroup/odata/download.php/69519/odata-data-aggregation-ext-v4.0-wd05.docx

      Description

      The specification text contains an example for tranformation outerjoin whose result is applied to a subsequent groupby transformation:

      Example 66:

      GET ~/Customers?$apply=outerjoin(Sales as ProductSales)
                             /groupby((Country,ProductSales/Product/Name))
      

      returning

      {
        "@odata.context":"$metadata#Customers(Country,ProductSales(Product(Name)))",
        "value": [
           { "Country": "Netherlands",
            "ProductSales": { "Product": { "Name": "Paper"  } } },
           { "Country": "Netherlands",
            "ProductSales": { "Product": { "Name": "Sugar"  } } },
           { "Country": "USA",
            "ProductSales": { "Product": { "Name": "Coffee" } } },
           { "Country": "USA",
            "ProductSales": { "Product": { "Name": "Paper"  } } },
           { "Country": "USA",
            "ProductSales": { "Product": { "Name": "Sugar"  } } },
          { "Country": "France", "ProductSales": null }
        ]
      }
      

      Looking at the first step, outerjoin returns combinations of customer instances and the related sales instances:

      [
        { 'ID': 'C1', 'Name': 'Joe', 'Country': 'USA', 'ProductSales': { 'ID': '1', … } },
        { 'ID': 'C1', 'Name': 'Joe', 'Country': 'USA', 'ProductSales': { 'ID': '2', … } },
        …
        { 'ID': 'C4', 'Name': Luc', 'Country': France', 'ProductSales': null }
      ]
      

      The following groupby operates on two grouping properties: Country and ProductSales/Product/Name.

      The latter property path is not defined for the last instance returned by outerjoin. Intuition says its value should be null.

      It should be clarified

      1. that the value for such a property path is clearly defined in some specification, when a leading segment is already null
      2. how the groupby result should look like for the last instance returned by outerjoin:
        1. like shown above:
          'ProductSales': null
        2. returning the complete structure of the grouping property:
          {{ 'ProductSales':
          Unknown macro: { 'Product'}

          }

       

       

       

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              gerald.krause1 Gerald Krause
            • Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: