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

Clarifications needed for Filter System Query Option: Operators and Functions

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: V4.0_WD01
    • Fix Version/s: V4.0_CSD02
    • Component/s: URL Conventions
    • Labels:
      None
    • Environment:

      [Applied]

    • Proposal:
      Hide

      Q1. Apart from EQ and NE (where comparison with null can be easily understood to always return TRUE or FALSE), what is the result of using GT, GE, LT, LE with one (or both arguments) being NULL?

      Answered in ODATA-166

      Q2. What is the result of an arithmetic operator applied to one (or both) NULL operands?

      Answered in ODATA-166

      Q3. What is the ordering of numeric types for promotion when mixed types are used (e.g. if ADD is applied to Single and Decimal, what type is the result)?

      Order: SByte, Int16, Int32, Int64, Decimal, Single, Double.

      Decimal is considered "less" than Single because Single can in nearly all implementations have a larger exponent than Decimal (so we prefer "range" over "precision" for promotion).

      Q4. What is the result of a canonical function applied to one (or more) NULL parameters?

      Define per function

      Q5. Where does NULL occur in ascending sort, and where in descending sort?

      null sorts first asc and last desc

      Q6. Examples in the spec show spaces in filters. Shouldn't these be %-encoded (e.g. "%20") so they are valid in URLs?

      Not an issue; we url encode, and explicitly mention that the examples are simplified for readability

      Q7. Which primitive types support the use of LT, LE, GT, GE?

      All except binary, geo, stream, and of course no collection of any primitive type
      true is greater than false

      Q8. Which geo types permit the use of EQ and NE?

      Geo types do not permit any comparison operator, and they MUST NOT be used as primary keys, not even Geo.Point.
      Reason is that geographies can be "spatially equal" without being "literally" equal.

      Q9. Are the LHS and RHS operands for a logical operator allowed to have different types (e.g. LHS=Decimal, RHS=Int32)? If so, then can non-string values be compared with string values?

      We define promotions

      Q10. What is the result of division/modulo arithmetic operators where the divisor is zero?

      positive / zero = INF
      negative / zero = -INF
      zero / zero = NaN

      NaN is not equal to any number, including NaN
      INF is equal to INF and unequal to any other number and -INF
      -INF is equal to -INF and unequal to any other number and INF

      Q11. What are the rules for the calculation of the result of modulo where one or both operands are negative?

      Dividend owns the sign. Many programming languages either use this rule or offer special operator that uses this rule, including C++ and SQL

      Q12. What are the rules for scale of the results of arithmetic operators where the operands are decimal?
      More general: how do we handle overflows?

      Define per operator in URL 5.1.1.2

      Q13. Which style of rounding is used by the round function (e.g. round-half-even)?

      Round (half) away from zero. This is the default in C++, possible in C# , and possible in Java (rounding-mode HALF_UP).

      Examples:
      -1.1 -> -1
      -0.5 -> -1
      0.5 -> 1
      1.1 -> 1

      Q14. Does the 'length' function calculate length according to UTF-8 bytes, UTF-16 characters, or something else?

      Characters, already in URL conventions

      Show
      Q1. Apart from EQ and NE (where comparison with null can be easily understood to always return TRUE or FALSE), what is the result of using GT, GE, LT, LE with one (or both arguments) being NULL? Answered in ODATA-166 Q2. What is the result of an arithmetic operator applied to one (or both) NULL operands? Answered in ODATA-166 Q3. What is the ordering of numeric types for promotion when mixed types are used (e.g. if ADD is applied to Single and Decimal, what type is the result)? Order: SByte, Int16, Int32, Int64, Decimal, Single, Double. Decimal is considered "less" than Single because Single can in nearly all implementations have a larger exponent than Decimal (so we prefer "range" over "precision" for promotion). Q4. What is the result of a canonical function applied to one (or more) NULL parameters? Define per function Q5. Where does NULL occur in ascending sort, and where in descending sort? null sorts first asc and last desc Q6. Examples in the spec show spaces in filters. Shouldn't these be %-encoded (e.g. "%20") so they are valid in URLs? Not an issue; we url encode, and explicitly mention that the examples are simplified for readability Q7. Which primitive types support the use of LT, LE, GT, GE? All except binary, geo, stream, and of course no collection of any primitive type true is greater than false Q8. Which geo types permit the use of EQ and NE? Geo types do not permit any comparison operator, and they MUST NOT be used as primary keys, not even Geo.Point. Reason is that geographies can be "spatially equal" without being "literally" equal. Q9. Are the LHS and RHS operands for a logical operator allowed to have different types (e.g. LHS=Decimal, RHS=Int32)? If so, then can non-string values be compared with string values? We define promotions Q10. What is the result of division/modulo arithmetic operators where the divisor is zero? positive / zero = INF negative / zero = -INF zero / zero = NaN NaN is not equal to any number, including NaN INF is equal to INF and unequal to any other number and -INF -INF is equal to -INF and unequal to any other number and INF Q11. What are the rules for the calculation of the result of modulo where one or both operands are negative? Dividend owns the sign. Many programming languages either use this rule or offer special operator that uses this rule, including C++ and SQL Q12. What are the rules for scale of the results of arithmetic operators where the operands are decimal? More general: how do we handle overflows? Define per operator in URL 5.1.1.2 Q13. Which style of rounding is used by the round function (e.g. round-half-even)? Round (half) away from zero. This is the default in C++, possible in C# , and possible in Java (rounding-mode HALF_UP). Examples: -1.1 -> -1 -0.5 -> -1 0.5 -> 1 1.1 -> 1 Q14. Does the 'length' function calculate length according to UTF-8 bytes, UTF-16 characters, or something else? Characters, already in URL conventions
    • Resolution:
      Show
      https://www.oasis-open.org/committees/download.php/49613/odata-v4.0-wd02-part1-protocol-2013-06-19.docx https://tools.oasis-open.org/version-control/browse/wsvn/odata/trunk/spec/vocabularies/Org.OData.Core.V1.xml?rev=377 https://tools.oasis-open.org/version-control/browse/wsvn/odata/trunk/spec/vocabularies/Org.OData.Capabilities.V1.xml?rev=379 https://www.oasis-open.org/committees/download.php/49614/odata-v4.0-wd02-part2-url-conventions-2013-06-19.docx https://tools.oasis-open.org/version-control/browse/wsvn/odata/trunk/spec/ABNF/odata-abnf-construction-rules.txt?rev=380 https://tools.oasis-open.org/version-control/browse/wsvn/odata/trunk/spec/ABNF/odata-abnf-testcases.xml?rev=380 https://www.oasis-open.org/committees/download.php/49615/odata-v4.0-wd02-part3-csdl-2013-06-19.docx https://tools.oasis-open.org/version-control/browse/wsvn/odata/trunk/spec/schemas/edmx.xsd?rev=357 https://tools.oasis-open.org/version-control/browse/wsvn/odata/trunk/spec/schemas/edm.xsd?rev=377 https://tools.oasis-open.org/version-control/browse/wsvn/odata/trunk/spec/schemas/MetadataService.edmx?rev=374 https://www.oasis-open.org/committees/download.php/49611/odata-atom-format-v4.0-wd02-2013-06-19.docx https://tools.oasis-open.org/version-control/browse/wsvn/odata/trunk/spec/schemas/metadata.xsd?rev=382 https://www.oasis-open.org/committees/download.php/49612/odata-json-format-v4.0-wd02-2013-06-19.docx

      Description

      Some questions which may be nicely addressed by additional clarifications in the URL Conventions spec...

      Logical Operators:

      Q1. Apart from EQ and NE (where comparison with null can be easily understood to always return TRUE or FALSE), what is the result of using GT, GE, LT, LE with one (or both arguments) being NULL?

      Possible answers: (a) undefined by the spec; (b) result is NULL; (c) result is FALSE; (d) a NULL value is considered less-than non-NULL values.

      If the answer is (b) NULL, then we should define that a filter that evaluates to NULL is considered FALSE, for the purposes of determining a filter match. Since NULLs may propagate up the filter expresion tree rather quickly.

      Arithmetic Operators:

      Q2. What is the result of an arithmetic operator applied to one (or both) NULL operands?

      Possible answers: (a) undefined by the spec; (b) NULL.

      Q3. What is the ordering of numeric types for promotion when mixed types are used (e.g. if ADD is applied to Single and Decimal, what type is the result)?

      Suggested answer: SByte, Int16, Int32, Int64, Decimal, Single, Double. Decimal is considered "less" than Single because Single can in nearly all implementations have a larger exponent than Decimal (so we prefer "range" over "precision" for promotion).

      Q4. What is the result of a canonical function applied to one (or more) NULL parameters?

      Possible answers: (a) undefined by the spec; (b) NULL; (c) depends on the function (e.g. boolean-valued functions might return FALSE).

      OrderBy:

      Q5. Where does NULL occur in ascending sort, and where in descending sort?

      Spaces in URLs

      Q6. Examples in the spec show spaces in filters. Shouldn't these be %-encoded (e.g. "%20") so they are valid in URLs?

      Filter Related

      Q7. Which primitive types support the use of LT, LE, GT, GE? (when answering, consider in particular the binary, boolean and geo types)?

      Q8. Which geo types permit the use of EQ and NE? When comparing points (e.g. latitude/longitude for GeographyPoint) is the comparison of coordinates assumed to use Decimal or Double comparison (consider that Single/Double are not usually recommended as suitable for use in database indexes due to the possibility of rounding errors affecting comparisons).

      Q9. Are the LHS and RHS operands for a logical operator allowed to have different types (e.g. LHS=Decimal, RHS=Int32)? If so, then can non-string values be compared with string values?

      Q10. What is the result of division/modulo arithmetic operators where the divisor is zero? Is it undefined by the spec, null, or +/- infinity? (noting that infinity is only applicable to Single/Double).

      Q11. What are the rules for the calculation of the result of modulo where one or both operands are negative?

      Q12. What are the rules for scale of the results of arithmetic operators where the operands are decimal?

      Q13. Which style of rounding is used by the round function (e.g. round-half-even)?

      Q14. Does the 'length' function calculate length according to UTF-8 bytes, UTF-16 characters, or something else? (noting that the CSDL spec defines String as a fixed-length or variable-length sequence of UTF-8 characters, we should just ensure that we have consistent rules for filters).

        Attachments

          Activity

            People

            • Assignee:
              handl Ralf Handl
              Reporter:
              evan.ireland.2 Evan Ireland
            • Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: