-
Notifications
You must be signed in to change notification settings - Fork 2
Add missing comparison operators for triple terms #289
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In addition to the suggestions in my review, I propose to remove the sentence about triple terms that is after the operator mapping table in Sec.17.3.
Aside from bringing A smaller issue (if we ignore the above) is that the signature of |
Correct, for subjects and predicates, it can only return 0 (since equality is defined for IRIs and bnodes) or error. This change also offers a baseline for systems that offer operator extensions for defining < and > for IRIs and blank nodes. |
How would this comparison work? The definition says:
The
Those tests aren't approved yet, just proposed, so while we can clean them up no "retraction" would be necessary. |
If A and B are equal (e.g. when evaluating
So I do see how "the next step" could be interpreted differently, so wording should be improved there. |
Apologies. I misread your example, and didn't notice that subject and object were the same. However, this feels like a very small special case that could just as easily be handled by My opinion is that we should not include If we did include the operator support for triple terms, I think we would need to also include similar definitions for IRIs and blank nodes for consistency (which to be clear I think would be a bad idea). |
Co-authored-by: Olaf Hartig <olaf.hartig@liu.se>
Co-authored-by: Olaf Hartig <olaf.hartig@liu.se>
I understand your concern. The lack of default comparison support for IRIs and bnodes can introduce confusion indeed (it already has in the tests).
I would also not add support for bnodes indeed. However, I don't see immediate issues with adding IRI support, so I wouldn't be against that. |
+1 to @kasei I have a hard time to find a usecase for this extension of |
Chiming in from the side: All I can say about |
I also do not have a strong opinion, but I also think that adding support for iri comparison makes sense. If support for IRIs would be added, I think adding support for triple terms also makes sense. But like the majority here I also think adding, triple term comparison without defining IRI comparison is really confusing (to reason on what an engine would return). |
@hartig —
There are no section numbers here. Can you please change the above quoted snippet to identify that location in some way which is visible in the HTML/ReSpec source? |
@TallTed , @rubensworks has already implemented my suggestion, see commit 189d62e |
Mapping</a> and <a href="#operatorExtensibility">17.3.1 Operator Extensibility</a>) defines | ||
the relative order of pairs of <code>numerics</code>, | ||
<code>xsd:strings</code>, <code>xsd:booleans</code> and <code>xsd:dateTimes</code>. Pairs of | ||
<code>xsd:strings</code>, <code>xsd:booleans</code>, <code>xsd:dateTimes</code>, and <a data-cite="RDF12-CONCEPTS#dfn-triple-term">Triple Terms</a>. Pairs of |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Making source more readable. A little manual tidy
.
<code>xsd:strings</code>, <code>xsd:booleans</code>, <code>xsd:dateTimes</code>, and <a data-cite="RDF12-CONCEPTS#dfn-triple-term">Triple Terms</a>. Pairs of | |
<code>xsd:strings</code>, <code>xsd:booleans</code>, <code>xsd:dateTimes</code>, and | |
<a data-cite="RDF12-CONCEPTS#dfn-triple-term">Triple Terms</a>. Pairs of |
( A.subject = B.subject ) <a href="#logical-and-operator" class="SPARQLoperator">&&</a><br/> | ||
( A.predicate = B.predicate ) <a href="#logical-and-operator" class="SPARQLoperator">&&</a><br/> | ||
( A.object = B.object ) | ||
<a data-cite="XPATH-FUNCTIONS-31#func-numeric-equal">op:numeric-equal</a>(<a href="#func-compareTripleTerm">compareTripleTerm</a>(A, B), 0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Making source more readable. A little manual tidy
.
<a data-cite="XPATH-FUNCTIONS-31#func-numeric-equal">op:numeric-equal</a>(<a href="#func-compareTripleTerm">compareTripleTerm</a>(A, B), 0) | |
<a data-cite="XPATH-FUNCTIONS-31#func-numeric-equal">op:numeric-equal</a>(<a | |
href="#func-compareTripleTerm">compareTripleTerm</a>(A, B), 0) |
( A.subject != B.subject ) <a href="#logical-or-operator" class="SPARQLoperator">||</a><br/> | ||
( A.predicate != B.predicate ) <a href="#logical-or-operator" class="SPARQLoperator">||</a><br/> | ||
( A.object != B.object ) | ||
<a data-cite="XPATH-FUNCTIONS-31#func-not">fn:not</a>(<a data-cite="XPATH-FUNCTIONS-31#func-numeric-equal">op:numeric-equal</a>(<a href="#func-compareTripleTerm">compareTripleTerm</a>(A, B), 0)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Making source more readable. A little manual tidy
.
<a data-cite="XPATH-FUNCTIONS-31#func-not">fn:not</a>(<a data-cite="XPATH-FUNCTIONS-31#func-numeric-equal">op:numeric-equal</a>(<a href="#func-compareTripleTerm">compareTripleTerm</a>(A, B), 0)) | |
<a data-cite="XPATH-FUNCTIONS-31#func-not">fn:not</a>(<a | |
data-cite="XPATH-FUNCTIONS-31#func-numeric-equal">op:numeric-equal</a>(<a | |
href="#func-compareTripleTerm">compareTripleTerm</a>(A, B), 0)) |
<section id="func-compareTripleTerm"> | ||
<h5>compareTripleTerm</h5> | ||
<pre class="prototype nohighlight"> | ||
<span class="return">xsd:integer</span> <span class="operator" style="text-transform: none;">compareTripleTerm</span> (<span class="type"><span class="type RDFterm">Triple term</span></span> <span class="name">term1</span>, <span class="type"><span class="type RDFterm">Triple term</span></span> <span class="name">term2</span>) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Making source more readable. A little manual tidy
.
<span class="return">xsd:integer</span> <span class="operator" style="text-transform: none;">compareTripleTerm</span> (<span class="type"><span class="type RDFterm">Triple term</span></span> <span class="name">term1</span>, <span class="type"><span class="type RDFterm">Triple term</span></span> <span class="name">term2</span>) | |
<span class="return">xsd:integer</span> | |
<span class="operator" style="text-transform: none;">compareTripleTerm</span> | |
(<span class="type"><span class="type RDFterm">Triple term</span></span> | |
<span class="name">term1</span>, | |
<span class="type"><span class="type RDFterm">Triple term</span></span> | |
<span class="name">term2</span>) |
<p>This function returns -1, 0, 1, or throws an error. | ||
Comparison is performed pairwise on the components of the triple terms in the order subject, predicate, object until the result is determined. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Making source more readable. A little manual tidy
.
<p>This function returns -1, 0, 1, or throws an error. | |
Comparison is performed pairwise on the components of the triple terms in the order subject, predicate, object until the result is determined. | |
<p>This function returns `-1`, `0`, or `1`, or throws an error. | |
Comparison is performed pairwise on the components of the triple terms | |
in the order subject, predicate, object until the result is determined. |
<ol> | ||
<li>If <code><a href="#func-subject">SUBJECT</a>(term1) = <a href="#func-subject">SUBJECT</a>(term2)</code> evaluates to true, go to step 2. | ||
If <code><a href="#func-subject">SUBJECT</a>(term1) < <a href="#func-subject">SUBJECT</a>(term2)</code> evaluates to true, return -1. | ||
If <code><a href="#func-subject">SUBJECT</a>(term1) > <a href="#func-subject">SUBJECT</a>(term2)</code> evaluates to true, return 1. | ||
If any of the evaluations causes an error, raise an error. | ||
</li> | ||
<li>If <code><a href="#func-predicate">PREDICATE</a>(term1) = <a href="#func-predicate">PREDICATE</a>(term2)</code> evaluates to true, go to step 3. | ||
If <code><a href="#func-predicate">PREDICATE</a>(term1) < <a href="#func-predicate">PREDICATE</a>(term2)</code> evaluates to true, return -1. | ||
If <code><a href="#func-predicate">PREDICATE</a>(term1) > <a href="#func-predicate">PREDICATE</a>(term2)</code> evaluates to true, return 1. | ||
If any of the evaluations causes an error, raise an error. | ||
</li> | ||
<li>If <code><a href="#func-object">OBJECT</a>(term1) = <a href="#func-object">OBJECT</a>(term2)</code> evaluates to true, return 0. | ||
If <code><a href="#func-object">OBJECT</a>(term1) < <a href="#func-object">OBJECT</a>(term2)</code> evaluates to true, return -1. | ||
If <code><a href="#func-object">OBJECT</a>(term1) > <a href="#func-object">OBJECT</a>(term2)</code> evaluates to true, return 1. | ||
If any of the evaluations causes an error, raise an error. | ||
</li> | ||
</ol> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We make life easier for ourselves, by formatting the ReSpec/HTML source with line breaks and such. We should carry that through to readers, with formatting like the following:
<ol> | |
<li>If <code><a href="#func-subject">SUBJECT</a>(term1) = <a href="#func-subject">SUBJECT</a>(term2)</code> evaluates to true, go to step 2. | |
If <code><a href="#func-subject">SUBJECT</a>(term1) < <a href="#func-subject">SUBJECT</a>(term2)</code> evaluates to true, return -1. | |
If <code><a href="#func-subject">SUBJECT</a>(term1) > <a href="#func-subject">SUBJECT</a>(term2)</code> evaluates to true, return 1. | |
If any of the evaluations causes an error, raise an error. | |
</li> | |
<li>If <code><a href="#func-predicate">PREDICATE</a>(term1) = <a href="#func-predicate">PREDICATE</a>(term2)</code> evaluates to true, go to step 3. | |
If <code><a href="#func-predicate">PREDICATE</a>(term1) < <a href="#func-predicate">PREDICATE</a>(term2)</code> evaluates to true, return -1. | |
If <code><a href="#func-predicate">PREDICATE</a>(term1) > <a href="#func-predicate">PREDICATE</a>(term2)</code> evaluates to true, return 1. | |
If any of the evaluations causes an error, raise an error. | |
</li> | |
<li>If <code><a href="#func-object">OBJECT</a>(term1) = <a href="#func-object">OBJECT</a>(term2)</code> evaluates to true, return 0. | |
If <code><a href="#func-object">OBJECT</a>(term1) < <a href="#func-object">OBJECT</a>(term2)</code> evaluates to true, return -1. | |
If <code><a href="#func-object">OBJECT</a>(term1) > <a href="#func-object">OBJECT</a>(term2)</code> evaluates to true, return 1. | |
If any of the evaluations causes an error, raise an error. | |
</li> | |
</ol> | |
<ol> | |
<li> | |
<ol type="i"> | |
<li>If <code><a href="#func-subject">SUBJECT</a>(term1) = <a href="#func-subject">SUBJECT</a>(term2)</code> evaluates to true, go to step 2.</li> | |
<li>If <code><a href="#func-subject">SUBJECT</a>(term1) < <a href="#func-subject">SUBJECT</a>(term2)</code> evaluates to true, return -1.</li> | |
<li>If <code><a href="#func-subject">SUBJECT</a>(term1) > <a href="#func-subject">SUBJECT</a>(term2)</code> evaluates to true, return 1.</li> | |
<li>If any of the evaluations causes an error, raise an error.</li> | |
</ol> | |
</li> | |
<li> | |
<ol type="i"> | |
<li>If <code><a href="#func-predicate">PREDICATE</a>(term1) = <a href="#func-predicate">PREDICATE</a>(term2)</code> evaluates to true, go to step 3.</li> | |
<li>If <code><a href="#func-predicate">PREDICATE</a>(term1) < <a href="#func-predicate">PREDICATE</a>(term2)</code> evaluates to true, return -1.</li> | |
<li>If <code><a href="#func-predicate">PREDICATE</a>(term1) > <a href="#func-predicate">PREDICATE</a>(term2)</code> evaluates to true, return 1.</li> | |
<li>If any of the evaluations causes an error, raise an error.</li> | |
</ol> | |
</li> | |
<li> | |
<ol type="i"> | |
<li>If <code><a href="#func-object">OBJECT</a>(term1) = <a href="#func-object">OBJECT</a>(term2)</code> evaluates to true, return 0.</li> | |
<li>If <code><a href="#func-object">OBJECT</a>(term1) < <a href="#func-object">OBJECT</a>(term2)</code> evaluates to true, return -1.</li> | |
<li>If <code><a href="#func-object">OBJECT</a>(term1) > <a href="#func-object">OBJECT</a>(term2)</code> evaluates to true, return 1.</li> | |
<li>If any of the evaluations causes an error, raise an error.</li> | |
</ol> | |
</li> | |
</ol> |
While #194 introduced sameValue and sameTerm support for triple terms, but
<
,<=
,>
, and>=
were missing, so this PR adds them.It also adds ORDER BY support for triple terms.
The same approach as the RDF-star spec was followed here, with some small tweaks.
Thanks to the keen eye of @jitsedesmet for noticing this was missing!
Preview | Diff