Re: DM and R2RML should use same datatype mapping

* Richard Cyganiak <richard@cyganiak.de> [2011-11-02 20:04+0000]
> On 2 Nov 2011, at 18:13, Eric Prud'hommeaux wrote:
> > My only issue with this is that folks have to go chasing down these implementation bars, which, as you are in a fine position to appreciate, is a PITA.
> 
> Acknowledged.
> 
> > How about normative text that says that the lexical representation is the canonical XML Schema Datatype form
> 
> Well, it still needs to formally define how to get from a SQL value to an XSD value. It needs to describe a mapping of some sort. What you propose just states the range of the mapping function, but not its definition.
> 
> R2RML defines the function by starting with the canonical SQL literal representation (which is defined as “Conversion to string” – the SQL expression for getting that canonical representation is CAST(xxx AS CHARACTER VARYING(yyy)), and then where necessary describing a transformation from that to the valid XSD form.

I used to think it was a good idea to follow the SQL spec 'cause, well, it existed. I've come to believe that it's unnecessarily complex without being helpful.
  MySQL doesn't parse "VARYING" (I haven't tried MS SQL yet, 10 mins remaining on download and probably 1hr of screwing around before i know the equivalent of "mysql -u root" or "sudo su postgres -c psql").
  We don't know how consistent most databases are if they do implement casting to variable-width strings.
  We don't know how closely SQL's casting produces canonical XSD lexical forms.
  Folks will mostly be executing some driver-specific (mysql_fetch_fields(result)) or generic (SQLGetData(...)) values without pushing the canonicalization into the SQL statement (SELECT CAST(Employee.salary AS CHARACTER VARYING(16)) FROM ... ).

I think we can more specify usefully consistent behavior by saying "produce the xsd canonical form" than by providing the SQL recipe. I think an argument against this would be if there were some question about how the value spaces mapped, but I don't see that as an issue because, apart from range extremes and precision, ints are ints and doubles are doubles.

> I think this is the right way of doing it, because implementers can actually try it on the SQL prompt (if their DB is sufficiently compatible), and potentially use directly in their implementations. It also follows ISO/IEC 9075-14:2008, which uses the same CAST expression. This method also provides a decent fallback for any vendor-specific types – casting them to a string can't be completely wrong – and this is explicitly explained in the R2RML text.
> 
> > and an informative table that indicates the ranges for minimal conformance
> 
> Would this table say anything besides what's already in the XSD spec? If not, then I'd rather just add an informative note pointing to that document, as it does a better job at explaining the relevant issues than we can do in the appropriate amount of space.

Well, there's the question about DATETIMEs and DATEs which have a much larger data space in XML than they do in SQL.


> How about this:
> 
> [[
> Note: This mapping to XML Schema datatypes tends to rely on arbitrary-precision types such as xsd:decimal, xsd:integer and xsd:dateTime, since the precision of many SQL datatypes is not fixed in [SQL2], but implementation-defined.
> 
> In practice, implementation considerations may require setting upper limits to the supported precision of these types. The XML Schema specification allows such “partial implementations”, and defines some minimum requirements and other constraints [XSD2-11].
> ]]

I didn't reallize they were “partial implementations” but I certainly want to be consistent with XSD's language. I prefer explicitly spelling out an expected supported data space with extension guidance, but if folks prefer a less-defined demarcation, I think this text is a good start.


> The [XSD2-11] link would go to http://www.w3.org/TR/xmlschema11-2/#partial-implementation . This section only exists in XML Schema 1.1, which isn't REC yet, so depending on their timeline we may have to link both to XSD 1.0 (normatively) and XSD 1.1 (informatively).
> 
> > and examples of the canonical forms?
> 
> R2RML already has plenty of examples for the conversion process, downwards from here:
> http://www.w3.org/2001/sw/rdb2rdf/r2rml/#datatype-table
> 
> (Looking at this now I feel that the table at the end of 10.1, and the one in 10.2, ought to be combined into one.)

I believe that everything can be condensed into one table.


> Best,
> Richard
> 
> 
> > 
> > 
> >> Best,
> >> Richard
> >> 
> >> [1] http://www.w3.org/TR/xmlschema11-2/#partial-implementation
> >> 
> >> 
> >> On 31 Oct 2011, at 03:39, Eric Prud'hommeaux wrote:
> >> 
> >>> * Richard Cyganiak <richard@cyganiak.de> [2011-10-31 00:09+0000]
> >>>> On 30 Oct 2011, at 23:11, Eric Prud'hommeaux wrote:
> >>>>> A tool which uses e.g. floats or ints to manipulate the graph defined by R2RML would have to qualify its conformance by the version of the database to which it was connected (e.g. "offers R2RML for MySQL 5.01, but not Oracle 11G").
> >>>> 
> >>>> Neither floats nor ints are sufficient to represent xsd:decimal even if we consider only xsd:decimals restricted to 18 digits.
> >>> 
> >>> True, and that does raise the bar for implementation. However, floating point and integer types are very commonly used in SQL and can be very simply implemented.
> >>> 
> >>> 
> >>>> Any programming language these days has some sort of arbitrary-precision decimal type in a readily available library. That is sufficient for conformance with any SQL 2008 conforming implementation of DECIMAL, regardless of how many digits it uses.
> >>>> 
> >>>>> General compatibility with R2RML over any database can only be preserved if you don't use native types at any step of the e.g. query answering process.
> >>>> 
> >>>> I have no idea what you're trying to say here.
> >>> 
> >>> As you point out above, one needs to use arbitrary-precision decimals and not native datatypes to implement the arbitrary precision required by R2RML.
> >>> Some programs, e.g. Jena, use efficient native types for integers and arbitrary-precision only for decimals.
> >>> 
> >>> 
> >>>>> Applying the unbounded precision support to DM would mean that FeDeRate would no longer be an implementation (it uses Jena to parse and execute queries which I believe uses java native types)
> >>>> 
> >>>> You may want to check that again. Jena uses BigDecimal to represent xsd:decimal.
> >>> 
> >>> The query
> >>> ASK {FILTER (20000000000000000000/2=10000000000000000000)}
> >>> at <http://sparql.org/sparql.html> indicates that ARC supports up to, but no more than, 18 digit integers.
> >>> 
> >>> 
> >>>>> and SWObjects would have an even harder time as it is intended to connect multiple databases with potentially different maximum precisions.
> >>>> 
> >>>> I don't understand the problem. When you query the DB you get back some value. Then you stuff that value into a BigDecimal.
> >>>> 
> >>>> I don't understand how knowing that you're never going to see a decimal longer than 18 digits simplifies an implementation. It's not like it's particularly hard to write arbitrary-precision code.
> >>> 
> >>> True, but do the use cases motivate raising the bar to that extent? Can we motivate Jena abandoning native integers?
> >>> 
> >>> 
> >>>> As far as I can see, the text in R2RML works fine, is easy to implement, easy to test, and meets user expectations. I have seen no evidence yet that changing the text would benefit users or implementers, and I have seen no argument being made why R2RML and DM should differ. As far as I can tell, you're trying to solve an imaginary problem.
> >>> 
> >>> I don't foresee many implementations of arbitrary precision for integers and floats and I don't see much motivation for that. Further, it makes more sense to define the lexical values in terms of the XSD canonical types rather than via a recipe which some popular databases (e.g. MySQL) don't support. 
> >>> 
> >>> 
> >>>> Best,
> >>>> Richard
> >>> 
> >>> -- 
> >>> -ericP
> >>> 
> >> 
> > 
> > -- 
> > -ericP
> 

-- 
-ericP

Received on Thursday, 3 November 2011 01:48:26 UTC