-
Notifications
You must be signed in to change notification settings - Fork 23
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
How to format decimals? #58
Comments
Following the RDF spec, literals should definitely be strictly equal:
I think we could go two ways:
1 is IMO the cleanest solution, but it requires a spec update (unless I'm missing something). 2 is probably the most practical one. |
According to the SPARQL 1.1 Grammar trailing digits in number representations are preserved, and so 1.0 and 1.00 would be considered different terms. IIRC, if the tests represent literals differently, it is intentional. |
Indeed, if terms originate from the underlying data source, then the terms must be returned as-is. However, this issue is about the response of functions, for which there seems to be no guideline on how decimals should be formatted.
It is indeed possible that this was intentional, but it is unclear to me what the reason for this was. For example in the spec tests, However, the SPARQL spec does not seem to make any indications regarding the required format of these decimals, so I would expect the spec tests to be at least consistent in this regard. Perhaps there is some other reason for this inconsistency? |
Functions return values so the way to compare is by value, not by term. (2 is one way to do that but the principle to state is that it is value-equality). XSD changed the canonical form of decimals between 1.0 to 1.1 to require the decimal point. It was "1"^^xsd:decimal, and became "1.0"^^xsd:decimal. The SECONDS case is different because of context of use. There is a reasonable expectation that the term format is like Or what about
I don't think being totally prescriptive about term representation is a good idea. It is the value that matters. |
If the SPARQL spec doesn’t say that a particular lexical form is generated, then any lexical form that has the correct value should be considered correct. So, as Andy said, the test suite documentation should state that literals are compared by value. Canonicalising actual and expected value before comparing them in the test runner is one way to achieve comparison by value. (For |
But that leaves STR() of that value (needlessly?) underspecified. Also, those STRs might be used to construct important things like identifiers. I think we'd like predictable behavior for at least integers. I.e. we'd like Decimals are used less frequently to construct terms but if we say that integer constructors MUST return canonical forms, we may as well do the same for all supported XSD datatypes with a canonical form: e.g. There may be some cases where it's hard to tell if something is being constructed vs. a lexical form is being cast, but hopefully they'll surface in this issue. iirc, the SPARQL 1.0 tests assumed canonical forms, which means any vestiges of them should be updated to reflect the mildly spec-breaking |
In regards to the formatting of decimals, how should spec-compliant engines handle trailing zero's in decimals? I find that the expected results in this test suite are inconsistent, i.e. sometimes they expect a trailing zero, sometimes they do not.
Some examples that have no trailing zero:
Some examples that do have a trailing zero:
Should this test suite be consistent in it's formatting? Either consistently have a trailing zero (in conformance with the canonical representation, or consistently remove it.
Or should we not compare the outputs by string equality?
cc: @rubensworks
The text was updated successfully, but these errors were encountered: