Hello Richard

The problem is probably that some column is defined not as a string type
> (e.g., VARCHAR or CLOB) but as a binary type (e.g., BINARY or BLOB), so the
> datatype of the SQL expression ends up being binary, and D2RQ by default
> maps binary values to xsd:hexBinary literals.


> Indeed you need to cast it to a string in a uriSqlExpression.
>

The root of the problem is in the way CONCAT() works when one of the
parameters isn't a char. In the case, I'm concatenating 'EHR' and
users.user_id (INT(11)) or 'UNIV' and users.universal_id (varchar(11)).

I found this neat trick to discover the type of an expression in mysql:

mysql> create temporary table t select CONCAT('
http://www.cipe.accamargo.org.br/ontologias/h2tc.owl#users',if(
users.universal_id is null, concat('EHR',users.user_id),
concat('UNIV',users.universal_id))) as test from users;
Query OK, 2213 rows affected (0.04 sec)
Records: 2213  Duplicates: 0  Warnings: 0

mysql> desc t;
+-------+----------------+------+-----+---------+-------+
| Field | Type           | Null | Key | Default | Extra |
+-------+----------------+------+-----+---------+-------+
| test  | varbinary(103) | YES  |     | NULL    |       |
+-------+----------------+------+-----+---------+-------+


Or maybe there's a bug somewhere… What are the datatypes of the columns
> involved in the expression?
>

I don't think it's a bug; but maybe D2R should throw an exception when the
type of the expression is not a *CHAR.

Cheers,

dfcp


> Best,
> Richard
>
>
> On 11 Apr 2013, at 14:22, Diogo FC Patrao <djogopat...@gmail.com> wrote:
>
> > Thanks Martin, that did the trick!
> >
> > I tried to put a d2rq:datatype string in there, but uriSqlExpression
> won't let me.
> >
> > Really thanks!
> >
> > --
> > diogo patrão
> >
> >
> >
> >
> > On Thu, Apr 11, 2013 at 10:05 AM, "Martin G. Skjæveland" <
> mart...@ifi.uio.no> wrote:
> > Hi Diogo,
> >
> > not having really understood you problem, however, have you tried to
> > cast the value to CHAR? I think I had similiar results as you which were
> > fixed by casting to CHAR, in my code:
> >
> >    d2rq:sqlExpression "Cast(AsText(apaAreaGross.apaAreaGeometryEWKT) AS
> > char)" .
> >
> > (AsText is a function to convert geometrics to text.)
> >
> > Martin
> >
> > On 11/04/13 14:53, Diogo FC Patrao wrote:
> > > More info; The mapping below is working perfectly. To me it sounds like
> > > a problem with uriSqlExpression,what do you think?
> > >
> > > map:documentAuthor1 a d2rq:PropertyBridge;
> > >      d2rq:belongsToClassMap map:Document;
> > >      d2rq:property :documentAuthor;
> > >      d2rq:refersToClassMap map:User1;
> > >      d2rq:condition "users.universal_id is not null";
> > >      d2rq:join "documents.responsible = users.user_id";
> > >      .
> > >
> > > map:documentAuthor2 a d2rq:PropertyBridge;
> > >      d2rq:belongsToClassMap map:Document;
> > >      d2rq:property :documentAuthor;
> > >      d2rq:refersToClassMap map:User2;
> > >      d2rq:condition "users.universal_id is null";
> > >      d2rq:join "documents.responsible = users.user_id";
> > >      .
> > >
> > > map:User1 a d2rq:ClassMap;
> > >      d2rq:dataStorage map:Database;
> > >      d2rq:class :User;
> > >      d2rq:condition "users.universal_id is not null";
> > >      d2rq:uriPattern
> > > "
> http://www.cipe.accamargo.org.br/ontologias/h2tc.owl#usersUNIV@@users.universal_id@@
> ";
> > >      .
> > >
> > > map:User2 a d2rq:ClassMap;
> > >      d2rq:dataStorage map:Database;
> > >      d2rq:class :User;
> > >      d2rq:condition "users.universal_id is null";
> > >      d2rq:uriPattern
> > > "
> http://www.cipe.accamargo.org.br/ontologias/h2tc.owl#usersEHR@@users.user_id@@
> ";
> > >      .
> > >
> > >
> > >
> > > --
> > > diogo patrão
> > >
> > >
> > >
> > >
> > > On Thu, Apr 11, 2013 at 9:40 AM, Diogo FC Patrao <
> djogopat...@gmail.com
> > > <mailto:djogopat...@gmail.com>> wrote:
> > >
> > >     Hi Richard
> > >
> > >     Did another couple of tests and the problem is not really related
> to
> > >     SERVICE.
> > >
> > >     This time, I issued the following query directly to D2R-Server:
> > >
> > >     SELECT * WHERE { ?document
> > >     <
> http://www.cipe.accamargo.org.br/ontologias/h2tc.owl#documentAuthor>
> ?author
> > >     . } limit 5
> > >
> > >     The results for ?author are still hex-coded. However, take a look
> on
> > >     map:documentAuthor:
> > >
> > >     map:documentAuthor a d2rq:PropertyBridge;
> > >          d2rq:belongsToClassMap map:Document;
> > >          d2rq:property :documentAuthor;
> > >          #d2rq:refersToClassMap map:User;
> > >          d2rq:join "documents.responsible = users.user_id";
> > >          d2rq:uriSqlExpression
> > >     "CONCAT('
> http://www.cipe.accamargo.org.br/ontologias/h2tc.owl#users',if(
> > >     users.universal_id is null, concat('EHR',users.user_id),
> > >     concat('UNIV',users.universal_id) ) )";
> > >          .
> > >
> > >     Does this point to something?
> > >
> > >     thanks!
> > >
> > >
> > >
> > >
> > >     --
> > >     diogo patrão
> > >
> > >
> > >
> > >
> > >     On Wed, Apr 10, 2013 at 1:33 PM, Richard Cyganiak
> > >     <rich...@cyganiak.de <mailto:rich...@cyganiak.de>> wrote:
> > >
> > >         --debug should print the query that ARQ sent. Run that query
> > >         yourself in D2RQ. And I'm pretty sure it's either Joseki or ARQ
> > >         messing up the result, and both are Jena products :-)
> > >
> > >         Richard
> > >
> > >
> > >         On 10 Apr 2013, at 14:12, Diogo FC Patrao <
> djogopat...@gmail.com
> > >         <mailto:djogopat...@gmail.com>> wrote:
> > >
> > >>         BTW2, how can I be sure that those results are coming out of
> > >>         D2R or are being messed up by ARQ client? I turned on --debug
> > >>         on my d2r-server, however it won print results.
> > >>
> > >>         Thanks again
> > >>
> > >>         --
> > >>         diogo patrão
> > >>
> > >>
> > >>
> > >>
> > >>         On Wed, Apr 10, 2013 at 10:10 AM, Diogo FC Patrao
> > >>         <djogopat...@gmail.com <mailto:djogopat...@gmail.com>> wrote:
> > >>
> > >>             Hi Richard
> > >>
> > >>             I'm writing to them right now. Are you in that list too?
> > >>
> > >>             BTW, Arq is in 2.10.1 version right now; do you think D2R
> > >>             0.8.1 would work with that version?
> > >>
> > >>             Thanks
> > >>
> > >>             --
> > >>             diogo patrão
> > >>
> > >>
> > >>
> > >>
> > >>             On Wed, Apr 10, 2013 at 3:18 AM, Richard Cyganiak
> > >>             <rich...@cyganiak.de <mailto:rich...@cyganiak.de>> wrote:
> > >>
> > >>                 Off the top of my head I can't think of a reason why
> > >>                 this might be happening. I suggest you also try asking
> > >>                 on the Jena list, mentioning that the D2R endpoint
> > >>                 uses the Joseki server code.
> > >>
> > >>                 Richard
> > >>
> > >>
> > >>                 On 9 Apr 2013, at 21:59, Diogo FC Patrao
> > >>                 <djogopat...@gmail.com <mailto:djogopat...@gmail.com
> >>
> > >>                 wrote:
> > >>
> > >>>                 Hello
> > >>>
> > >>>                 I noticed a strange effect happening when I issue the
> > >>>                 following query:
> > >>>
> > >>>                 SELECT DISTINCT  *
> > >>>                 WHERE
> > >>>                   {
> > >>>                 SERVICE <http://0.0.0.0:2020/sparql> { ?document
> > >>>                 <
> http://www.cipe.accamargo.org.br/ontologias/h2tc.owl#documentType>
> > >>>
> > >>>                 "exam request" . }
> > >>>                 SERVICE <http://0.0.0.0:2020/sparql> { ?document
> > >>>                 <
> http://www.cipe.accamargo.org.br/ontologias/h2tc.owl#documentAuthor>
> > >>>
> > >>>                 ?author . }
> > >>>                   }
> > >>>                 0.0.0.0:2020/sparql <http://0.0.0.0:2020/sparql>
> > >>>                 points to a d2r-server instance. This query was
> > >>>                 issued not directly to this instance, but rather by a
> > >>>                  command line ARQ over an empty graph.
> > >>>
> > >>>                 This query is part of a bigger query that refers to
> > >>>                 several d2r-server instances, and I know that I could
> > >>>                 join both of them in one SERVICE only for
> > >>>                 optimization, but that's not the point.
> > >>>
> > >>>                 The point is, instead of getting proper URIs for
> > >>>                 ?author, I'm getting those huge hex data, like
> > >>>
> > >>>
> <687474703A2F2F7777772E636970652E616363616D6172676F2E6F72672E62722F6F6E746F6C6F676961732F683274632E6F776C237573657273554E495636363837353234353636>
> > >>>
> > >>>                 Interestingly enough, converting consecutive pairs of
> > >>>                 those bytes to chars, it turns into a URI!
> > >>>
> > >>>
> http://www.cipe.accamargo.org.br/ontologias/h2tc.owl#usersUNIV6687524566
> > >>>
> > >>>                 Which is a valid answer to ?author.
> > >>>
> > >>>                 I have verified that a query without those SERVICE
> > >>>                 keywords works perfectly, when issued directly to
> > >>>                 D2R-server.
> > >>>
> > >>>
> > >>>                 I'm not really sure whose fault is this, ARQ or D2R.
> > >>>
> > >>>                 Any help in order to get things straight will be
> > >>>                 appreciated.
> > >>>
> > >>>                 Thanks,
> > >>>
> > >>>
> > >>>
> > >>>
> > >>>                 --
> > >>>                 diogo patrão
> > >>>
> > >>>
> > >>>
> ------------------------------------------------------------------------------
> > >>>                 Precog is a next-generation analytics platform
> > >>>                 capable of advanced
> > >>>                 analytics on semi-structured data. The platform
> > >>>                 includes APIs for building
> > >>>                 apps and a phenomenal toolset for data science.
> > >>>                 Developers can use
> > >>>                 our toolset for easy data analysis & visualization.
> > >>>                 Get a free account!
> > >>>
> http://www2.precog.com/precogplatform/slashdotnewsletter
> > >>>                 _______________________________________________
> > >>>                 d2rq-map-devel mailing list
> > >>>                 d2rq-map-devel@lists.sourceforge.net
> > >>>                 <mailto:d2rq-map-devel@lists.sourceforge.net>
> > >>>
> https://lists.sourceforge.net/lists/listinfo/d2rq-map-devel
> > >>
> > >>
> > >>
> > >
> > >
> > >
> > >
> > >
> ------------------------------------------------------------------------------
> > > Precog is a next-generation analytics platform capable of advanced
> > > analytics on semi-structured data. The platform includes APIs for
> building
> > > apps and a phenomenal toolset for data science. Developers can use
> > > our toolset for easy data analysis & visualization. Get a free account!
> > > http://www2.precog.com/precogplatform/slashdotnewsletter
> > >
> > >
> > >
> > > _______________________________________________
> > > d2rq-map-devel mailing list
> > > d2rq-map-devel@lists.sourceforge.net
> > > https://lists.sourceforge.net/lists/listinfo/d2rq-map-devel
> > >
> >
> >
> >
> ------------------------------------------------------------------------------
> > Precog is a next-generation analytics platform capable of advanced
> > analytics on semi-structured data. The platform includes APIs for
> building
> > apps and a phenomenal toolset for data science. Developers can use
> > our toolset for easy data analysis & visualization. Get a free account!
> > http://www2.precog.com/precogplatform/slashdotnewsletter
> > _______________________________________________
> > d2rq-map-devel mailing list
> > d2rq-map-devel@lists.sourceforge.net
> > https://lists.sourceforge.net/lists/listinfo/d2rq-map-devel
> >
> >
> ------------------------------------------------------------------------------
> > Precog is a next-generation analytics platform capable of advanced
> > analytics on semi-structured data. The platform includes APIs for
> building
> > apps and a phenomenal toolset for data science. Developers can use
> > our toolset for easy data analysis & visualization. Get a free account!
> >
> http://www2.precog.com/precogplatform/slashdotnewsletter_______________________________________________
> > d2rq-map-devel mailing list
> > d2rq-map-devel@lists.sourceforge.net
> > https://lists.sourceforge.net/lists/listinfo/d2rq-map-devel
>
>
------------------------------------------------------------------------------
Precog is a next-generation analytics platform capable of advanced
analytics on semi-structured data. The platform includes APIs for building
apps and a phenomenal toolset for data science. Developers can use
our toolset for easy data analysis & visualization. Get a free account!
http://www2.precog.com/precogplatform/slashdotnewsletter
_______________________________________________
d2rq-map-devel mailing list
d2rq-map-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/d2rq-map-devel

Reply via email to