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

Clarify treatment of duplicates in OData-Aggr example 7

    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

      Modify the relevant part of the specification as follows (deletions are striked out, insertions are in italics or indented). To be discussed whether the fifth alternative (the green text) can be abolished and remove example 7. TC agrees to abolish it on 2021-06-10.

      The aggregate transformation takes a comma-separated list of one or more aggregate expressions as parameters and returns a result set with a single instance, representing the aggregated value for all instances in the input set.

      In the following, P is a path made up of navigation properties, complex properties, and complex collection properties.

      An aggregate expression may be:

      • an aggregatable expression on the input set with a specified aggregation method,
      • an aggregatable property that can be reached via a path P consisting of a sequence of navigation properties, complex properties and complex collection properties, with a specified aggregation method,
      • a custom aggregate that can be reached via a path P consisting of a sequence of navigation properties, complex properties and complex collection properties,
      • any of the above, followed by a from expression,
      • any of the above, enclosed in parentheses and prefixed with a navigation path to related entities, which serve as input set for the enclosed aggregate expression,
      • $count, which is a shortcut for the expression 1 with sum

      If P is present, it must be well-defined for all instances in the input set. Let Q be the portion of P up to and including the last navigation property, if any, and let R be the remainder, if any, of P that contains no navigation properties, such that P equals the concatenated path Q/R. The aggregate transformation considers each entity reached via the path Q exactly once. To this end

      • if Q is non-empty, let E be the set of distinct entities reached via Q starting from the input set
      • if Q is empty, let E be the input set (which may contain multiple instances with the same value).

      Then, if R is empty, the aggregated value is computed for all instances in E, otherwise the aggregated value is computed for all instances addressed via R starting from E.

      If no paths are present, the aggregated value is computed for all instances in the input set.

      Any aggregate expression that specifies an aggregation method MUST define an alias for the resulting aggregated value. The resulting instance contains one dynamic property per parameter representing the aggregated value across all instances within the input set. If paths are present, the corresponding navigation properties are implicitly expanded to make the properties part of the result representation.

      The properties of P do not appear in the result (cf. example 59, with P = Q = Sales and R = empty).

      Show
      Modify the relevant part of the specification as follows (deletions are striked out, insertions are in italics or indented). To be discussed whether the fifth alternative (the green text) can be abolished and remove example 7. TC agrees to abolish it on 2021-06-10. The aggregate transformation takes a comma-separated list of one or more aggregate expressions as parameters and returns a result set with a single instance, representing the aggregated value for all instances in the input set. In the following, P is a path made up of navigation properties, complex properties, and complex collection properties. An aggregate expression may be: an aggregatable expression on the input set with a specified aggregation method, an aggregatable property that can be reached via a path P   consisting of a sequence of navigation properties, complex properties and complex collection properties, with a specified aggregation method, a custom aggregate that can be reached via a path P   consisting of a sequence of navigation properties, complex properties and complex collection properties, any of the above, followed by a from expression, any of the above, enclosed in parentheses and prefixed with a navigation path to related entities, which serve as input set for the enclosed aggregate expression, $count, which is a shortcut for the expression 1 with sum If P is present, it must be well-defined for all instances in the input set. Let Q be the portion of P up to and including the last navigation property, if any, and let R be the remainder, if any, of P that contains no navigation properties, such that P equals the concatenated path Q/R. The aggregate transformation considers each entity reached via the path Q exactly once. To this end if Q is non-empty, let E be the set of distinct entities reached via Q starting from the input set if Q is empty, let E be the input set (which may contain multiple instances with the same value). Then, if R is empty, the aggregated value is computed for all instances in E, otherwise the aggregated value is computed for all instances addressed via R starting from E. If no paths are present, the aggregated value is computed for all instances in the input set. Any aggregate expression that specifies an aggregation method MUST define an alias for the resulting aggregated value. The resulting instance contains one dynamic property per parameter representing the aggregated value across all instances within the input set . If paths are present, the corresponding navigation properties are implicitly expanded to make the properties part of the result representation. The properties of P do not appear in the result (cf. example 59, with P = Q = Sales and R = empty).
    • Resolution:
      Hide

      https://www.oasis-open.org/apps/org/workgroup/odata/download.php/69078/odata-data-aggregation-ext-v4.0-wd05.docx

      Resolution edited on 2022-01-21: Path P may not only contain navigation and complex properties, but also entity- or complex-valued instance annotations. The ABNF already supports that. See https://www.oasis-open.org/apps/org/workgroup/odata/download.php/69525/odata-data-aggregation-ext-v4.0-wd05.docx

      Show
      https://www.oasis-open.org/apps/org/workgroup/odata/download.php/69078/odata-data-aggregation-ext-v4.0-wd05.docx Resolution edited on 2022-01-21: Path P may not only contain navigation and complex properties, but also entity- or complex-valued instance annotations. The ABNF already supports that. See  https://www.oasis-open.org/apps/org/workgroup/odata/download.php/69525/odata-data-aggregation-ext-v4.0-wd05.docx

      Description

      Example 7 in the aggregate ... as specification leaves unclear whether entities that are reachable via more than one instance path are considered once during aggregation or as often as they are reachable.

      Does

      GET CainAndAbel?$apply=aggregate(Parents($count as c))
      

      count Adam and Eve once or twice (https://www.bibleserver.com/KJV/Genesis4)? Is the result

      "Parents": [{"c": 2}]
      

      or 4?

        Attachments

          Activity

          Hide
          heiko.theissen Heiko Theissen added a comment - - edited

          Interpret the path mentioned in the second and third bullet points as follows:

          • Split the path into P/Q/A where Q contains no navigation property and A is the last segment.
          • Compute the set (not multiset) E of entities addressed by P.
          • Second bullet point (A is an aggegatable property): Aggregate all occurrences in E/Q of A with the given aggregation method. (The same primitive value may, of course, occur more than once.)
          • Third bullet point (A is a custom aggregate): Compute the custom aggregate A of instances E/Q.

          The fifth bullet point with navigation path N is interpreted similarly:

          • Split the path from inside the parenthesised expression into P/Q/A as above.
          • Compute the set (not multiset) E of entities addressed by N/P.
          • Parenthesised expression according to second bullet point: Aggregate all occurrences in E/Q of A with the given aggregation method.
          • Parenthesised expression according to third bullet point: Compute the custom aggregate A of instances E/Q.
          Show
          heiko.theissen Heiko Theissen added a comment - - edited Interpret the path mentioned in the second and third bullet points as follows: Split the path into P/Q/A where Q contains no navigation property and A is the last segment. Compute the set (not multiset) E of entities addressed by P. Second bullet point (A is an aggegatable property): Aggregate all occurrences in E/Q of A with the given aggregation method. (The same primitive value may, of course, occur more than once.) Third bullet point (A is a custom aggregate): Compute the custom aggregate A of instances E/Q. The fifth bullet point with navigation path N is interpreted similarly: Split the path from inside the parenthesised expression into P/Q/A as above. Compute the set (not multiset) E of entities addressed by N/P. Parenthesised expression according to second bullet point: Aggregate all occurrences in E/Q of A with the given aggregation method. Parenthesised expression according to third bullet point: Compute the custom aggregate A of instances E/Q.
          Hide
          heiko.theissen Heiko Theissen added a comment -

          How does OData-Aggr, example 7 look in the Atom representation? I assume, following OData-Atom, section 8.3, that the Sales property is represented as a link:

          <atom:link rel="http://docs.oasis-open.org/odata/ns/related/Sales"
           href="???" type="application/atom+xml;type=feed"> 
           <metadata:inline>
            <atom:feed>...</atom:feed>
           </metadata:inline>
          </atom:link>
          

          But what's the href?

          And, how would it look if Sales was a structural rather than a navigation property? The current proposal allows both.

          Show
          heiko.theissen Heiko Theissen added a comment - How does OData-Aggr, example 7 look in the Atom representation? I assume, following OData-Atom, section 8.3 , that the Sales property is represented as a link: <atom:link rel= "http://docs.oasis-open.org/odata/ns/related/Sales" href= "???" type= "application/atom+xml;type=feed" > <metadata:inline> <atom:feed> ... </atom:feed> </metadata:inline> </atom:link> But what's the href ? And, how would it look if Sales was a structural rather than a navigation property? The current proposal allows both.
          Hide
          heiko.theissen Heiko Theissen added a comment -

          We assume that P need not be collection-valued.

          Show
          heiko.theissen Heiko Theissen added a comment - We assume that P need not be collection-valued.
          Hide
          heiko.theissen Heiko Theissen added a comment -

          Resolve as proposed. TC 2021-06-17

          Show
          heiko.theissen Heiko Theissen added a comment - Resolve as proposed. TC 2021-06-17
          Show
          heiko.theissen Heiko Theissen added a comment - Applied as resolved:  https://www.oasis-open.org/apps/org/workgroup/odata/download.php/68748/odata-data-aggregation-ext-v4.0-wd05.docx

            People

            • Assignee:
              Unassigned
              Reporter:
              heiko.theissen Heiko Theissen
            • Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: