Skip to content

Commit dc25411

Browse files
committed
Add = and != for IRIs, bnodes and triple terms
1 parent 03fb4e0 commit dc25411

File tree

1 file changed

+126
-102
lines changed

1 file changed

+126
-102
lines changed

spec/index.html

Lines changed: 126 additions & 102 deletions
Original file line numberDiff line numberDiff line change
@@ -243,8 +243,7 @@
243243
span.cancast:hover { background-color: #ffa;
244244
color: black; }
245245

246-
.SPARQLoperator { background-color: #FFFFbf; /* yellow */
247-
}
246+
.SPARQLoperator { font-weight: 600; }
248247

249248
/* ReSpec */
250249
dfn { font-style: normal ; }
@@ -4665,6 +4664,7 @@

Operand Data Types

46654664

SPARQL language extensions may treat additional types as being derived from XML schema

46664665
datatypes.

46674666
4667+
46684668
46694669

Filter Evaluation

46704670

SPARQL provides a subset of the functions and operators defined by

@@ -4826,6 +4826,7 @@

Effective Boolean Value (EBV)

48264826
with a datatype of xsd:boolean and a lexical value of "false".

48274827
48284828
4829+
48294830
48304831

Operator Mapping

48314832

The SPARQL grammar identifies a set of operators

@@ -4925,7 +4926,7 @@

Operator Mapping

49254926
Logical Connectives
49264927
49274928
4928-
4929+
49294930
49304931
49314932
@@ -4934,7 +4935,7 @@

Operator Mapping

49344935
49354936
xsd:boolean (EBV)
49364937
4937-
4938+
49384939
logical-or(A, B)
49394940
49404941
xsd:boolean
@@ -5275,32 +5276,91 @@

Operator Mapping

52755276
SPARQL Tests
52765277
52775278
5278-
5279-
5280-
5279+
A = B
5280+
IRI
5281+
IRI
5282+
5283+
sameTerm(A, B)
5284+
5285+
xsd:boolean
5286+
5287+
5288+
A = B
5289+
Blank Node
5290+
Blank Node
5291+
5292+
sameTerm(A, B)
5293+
5294+
xsd:boolean
5295+
5296+
5297+
A = B
5298+
Triple Term
5299+
Triple Term
5300+
5301+
( A.subject = B.subject ) &&
5302+
( A.predicate = B.predicate ) &&
5303+
( A.object = B.object )
5304+
5305+
xsd:boolean
5306+
5307+
5308+
A != B
5309+
IRI
5310+
IRI
5311+
fn:not(sameTerm(A, B))
5312+
xsd:boolean
5313+
5314+
5315+
A != B
5316+
Blank Node
5317+
Blank Node
5318+
5319+
5320+
5321+
xsd:boolean
5322+
5323+
5324+
A != B
5325+
Triple Term
5326+
Triple Term
5327+
5328+
( A.subject != B.subject ) ||
5329+
( A.predicate != B.predicate ) ||
5330+
( A.object != B.object )
5331+
5332+
xsd:boolean
5333+
5334+
5335+
A = B
52815336
RDF term
52825337
RDF term
52835338
5284-
5285-
5339+
sameValue(A, B)
5340+
52865341
xsd:boolean
52875342
52885343
5289-
5290-
5291-
5344+
A != B
52925345
RDF term
52935346
RDF term
52945347
5295-
5348+
52965349
52975350
xsd:boolean
52985351
52995352
53005353
5301-
xsd:boolean function arguments marked with "(EBV)" are
5354+

5355+
xsd:boolean function arguments marked with "(EBV)" are
53025356
coerced to xsd:boolean by evaluating the effective boolean value of that
530353575358+

5359+

5360+
Operators = and != applied to
5361+5362+
apply the operator to each of the components.
5363+

53045364
53055365

Operator Extensibility

53065366

SPARQL language extensions may provide additional associations between operators and

@@ -5314,6 +5374,7 @@

Operator Extensibility

53145374
BY clause.

53155375
53165376
5377+
53175378
53185379

Function Definitions

53195380

This section defines the operators and functions introduced by the SPARQL query language.

@@ -5678,7 +5739,7 @@
sameTerm
56785739
defined in [[[RDF12-CONCEPTS]]] [[RDF12-CONCEPTS]]; returns FALSE otherwise.

56795740

56805741
|term1| and |term2| are the
5681-5742+56825743
if one of the following is true:
56835744

56845745
    @@ -5756,77 +5817,61 @@
    sameValue
    57565817

    57575818

    This function cannot be used directly in expressions. The purpose

    57585819
    of this function is to define the semantics of the "=" operator when applied to
    5759-
    two RDF terms that do not fall into any of the other, more concrete cases
    5820+
    two RDF terms that do not fall into the concrete cases
    57605821
    covered in the operator mapping table in Section
    57615822
    .
    57625823

    57635824

    5764-

    5765-
    Revise for triple terms.
    5766-

    5767-
    Consider adding non-literal `=` to operator mapping table.
    5768-

    5769-
    57705825

    The result of this function is determined by going through the following steps.

    5826+
    57715827
      57725828
    1. If term1 and term2 are
    2. 577358295774-
      the return TRUE.
      5830+
      then return TRUE.
      57755831
      5776-
    3. If both arguments are literals,
    4. 5832+
    5. If term1 or term2 is an
    6. 5833+
      IRI or a
      5834+5835+
      then return FALSE.
      5836+
    7. If term1 and term2 are both
    8. 577758375778-
      and one or both arguments are known to be ill-typed,
      5838+
      and one or both of these literals has a datatype that is
      5839+
      not handled by the SPARQL processor,
      57795840
      then produce a type error.
      57805841
      5781-
    9. If term1 and term2 both
    10. 5842+
    11. If term1 and term2 are both
    12. 5843+5844+
      and one or both of these literals are known to be
      5845+5846+
      then produce a type error.
      5847+
      5848+
    13. 5849+
      `"NaN"^^xsd:double` and `"NaN"^^xsd:float` are considered to
      5850+
      represent the same value.
      5851+
      If term1 and term2 are
      5852+
      both "NaN" for either xsd:double or xsd:float, then
      5853+
      return TRUE.
      5854+
      5855+
    14. If term1 and term2 are both
    15. 578258565783-
      and the SPARQL processor can determine the values are equal,
      5857+
      and the SPARQL processor can determine that their the values are equal,
      57845858
      then return TRUE.
      57855859
      5786-
    16. If term1 and term2 both
    17. 5860+
    18. If term1 and term2 are both
    19. 5787586157885862
      and the SPARQL processor can determine the values can not be equal,
      57895863
      then return FALSE.
      57905864
      5791-
    20. Otherwise, return FALSE.
    21. 5865+
    22. 5866+
      If term1 and term2 are both
      5867+5868+
      apply the function `sameValue` pair-wise to each of the components.
      5869+
      Return TRUE if each component pair returns TRUE;
      5870+
      produce a type error if any component pair produces an error;
      5871+
      otherwise return FALSE.
      57925872
      5873+
    23. Otherwise, return FALSE.
    24. 57935874
      5794-
      5795-

      5796-
      The treatment of `NaN` can not be consistent with both "same term means same value"
      5797-
      and "`fn:numeric-equal(NaN, NaN)` is false". So it is an arbitrary choice with
      5798-
      arguments for all three possible choices.
      5799-
      For pattern matching, `"NaN"^^xsd:double` must match itself and
      5800-
      `"NaN"^^xsd:double` does not pattern match `"NaN"^^xsd:float`.
      5801-

      5802-

      5803-
      The operator mapping for `=` goes to `fn:numeric-compare` which is false.
      5804-
      The `sameValue` result could be made an error (or false) as a special case.
      5805-

      5806-

      5807-
      `"NaN"^^xsd:double = "NaN"^^xsd:float` is also handled by the
      5808-
      operator mapping and is false – `xsd:float` is promoted to `xsd:double`.
      5809-
      A reading of IEEE 754 is that `"NaN"^^xsd:double` and `"NaN"^^xsd:float`
      5810-
      are the same term also suggests that `sameValue` is true.
      5811-

      5812-

      5813-
      Proposal 1: follow "sameTerm means sameValue" and `sameValue("NaN"^^xsd:double, "NaN"^^xsd:double)`
      5814-
      and `sameValue("NaN"^^xsd:float, "NaN"^^xsd:float)` are trues.
      5815-

      5816-
      Proposal 2:
      5817-
      follow "there is one NaN" so `sameValue("NaN"^^xsd:double, "NaN"^^xsd:float)` is true.
      5818-

      5819-

      5820-5821-
      "are members of the datatype's ·value space·. ". It is not clear whether "special value" literals
      5822-
      added to the value spaces of `xsd:double` and `xsd:float` are "the same" literals.
      5823-

      5824-5825-
      IEEE 754 specifies a special value called "Not a Number" (NaN).
      5826-
      suggests they are the same.
      5827-

      5828-
      5829-
      58305875
      58315876

      A literal is

      58325877
      @@ -5847,31 +5892,19 @@
      sameValue
      58475892
      The Operator Mapping for "`=`"
      58485893
      is the function
      584958945850-
      which returns `false` when comparing arguments involving `NaN`.
      5851-
      However, `sameTerm("NaN"^^xsd:double, "NaN"^^xsd:double)` is true;
      5852-
      `sameValue` treats "NaN" as the "same value".
      5853-
      `sameTerm("NaN"^^xsd:double, "NaN"^^xsd:float)` is `true`.
      5895+
      which is defined to return `false` when comparing arguments involving `NaN`.
      5896+
      However, `sameTerm("NaN"^^xsd:double, "NaN"^^xsd:double)` is true.
      5897+
      The function `sameValue` defines `sameValue("NaN"^^xsd:double, "NaN"^^xsd:double)`
      5898+
      to be true because the arguments are the same element of the value space.
      58545899

      5855-
      5856-
      5857-

      This function was previously called `RDFterm-equal`.

      5858-
      5859-
      5860-
      58615900

      5862-
      A SPARQL processor may support datatypes beyond those required.
      5863-
      Suppose `ex:romanNumeral` is the datatype IRI
      5864-5865-
      which are integer numbers. The SPARQL processor may then be able
      5866-
      to detemine if two literals have the same value, for example,
      5867-
      `sameValue(4, "IV"^^ex:romanNumeral)` can then return `true`
      5868-
      because argument bot represent the value 4.
      5869-
      For `sameValue("abc"^^xsd:string, "IV"^^ex:romanNumeral)`
      5870-
      can return `false` because `xsd:string` and `ex:romanNumeral`
      5871-
      have different value spaces so the arguments can not be the same value.
      5901+
      `sameValue` treats the values of `"NaN"^^xsd:double` and `"NaN"^^xsd:float` as being
      5902+
      the same. `sameValue("NaN"^^xsd:double, "NaN"^^xsd:float)` is `true`.
      58725903

      58735904
      5874-
      5905+

      5906+
      For xsd:double and xsd:float, `+0`, `-0` and `0` are same value.
      5907+

      58755908

      58765909
      An extended implementation may support additional datatypes for literals. An
      58775910
      implementation processing a query that tests for equivalence of literals with non-recognized datatypes
      @@ -5890,22 +5923,6 @@
      sameValue
      58905923
      sameValue
      58915924
      Results
      58925925
      5893-
      5894-
      sameValue(2, +2)
      5895-
      true
      5896-
      5897-
      5898-
      sameValue(2.0, 2)
      5899-
      true
      5900-
      5901-
      5902-
      sameValue(2, "2")
      5903-
      false
      5904-
      5905-
      5906-
      sameValue(4, "iv"^^my:romanNumeral)
      5907-
      error, or true by extension
      5908-
      59095926
      59105927
      sameValue(1e10, "NaN"^^xsd:double)
      59115928
      false
      @@ -5918,9 +5935,16 @@
      sameValue
      59185935
      sameValue("NaN"^^xsd:double, "NaN"^^xsd:float)
      59195936
      true
      59205937
      5938+
      5939+
      sameValue( <<(:s :p 123)>> , <<(:s :p 123.0)>> )
      5940+
      true
      5941+
      59215942
      59225943
      59235944
      5945+

      5946+
      This function was called `RDFterm-equal` up until SPARQL 1.1.
      5947+

      59245948
      59255949

      59265950

      0 commit comments

      Comments
       (0)