Help needed in resolving an issue regarding SPARQL query enhancement

39 views
Skip to first unread message

Akash Sharma

unread,
Apr 29, 2020, 12:30:29 PM4/29/20
to rdflib-dev

Hi! I was working on an issue https://github.com/RDFLib/rdflib/issues/629.

I found that for Raw Literals, it was quite easy to extend this case of duration by handling it in rdfliB/term.py. I assumed that fixing the catch here would result in fixing it in SPARQL. However, this is not the case. I realised SPARQL queries' literal operations are done separately to the Raw Literal handling. 

This is a new codebase for me. Hence it would be really helpful if anyone can suggest where should I look at for manipulating such SPARQL query expressions? 
Thanks for the help. 

Nicholas Car

unread,
May 2, 2020, 9:38:23 PM5/2/20
to rdfli...@googlegroups.com
Hi Akash,

I see the discussion in Issue 629. Can you submit a PR to add your work for Literals? That would be useful even before contributing to the SPARQL queries.


Regarding where to start with SPARQL, how about:


And then


The unary expression is detected, parsed and then evaluated at these points.

The first point in the code does seem to be using Literal though...

Feel free to add better stuff here other long-timer RDFlib contributors!

Nick


--
http://github.com/RDFLib
---
You received this message because you are subscribed to the Google Groups "rdflib-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rdflib-dev+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rdflib-dev/a2dbe289-b056-4e19-a675-ce3783e0af1f%40googlegroups.com.

______________________________________________________________________________________
 
Dr Nicholas Car
Data Systems Architect
SURROUND Australia Pty Ltd
Address P.O. Box 86, Mawson, Canberra ACT 2607
Phone  +61 477 560 177
Email  nichol...@surroundaustralia.com
Website  https://surroundaustralia.com

Enhancing Intelligence Within Organisations
delivering evidence that connects decisions to outcomes






akashtheg...@gmail.com

unread,
May 2, 2020, 11:52:42 PM5/2/20
to rdflib-dev
Thank you, Sir, for replying to the post!

Sir, when I was reading through the code, I saw that "AdditiveExpression" here (https://github.com/RDFLib/rdflib/blob/master/rdflib/plugins/sparql/operators.py#L755)  dealt with both subtraction and addition of variables in the SPARQL query expression, for instance, a+b, a-b etc. So far, this handled only numeric types of Literals (integer, float, double etc)  in the SPARQL query, which were actually converted to python numeric types to perform additions and subtractions and giving result in appropriate datatypes. 

Hence,  adding these additive and subtractive properties to Date, Time and DateTime raw Literals itself wasn't working because for evaluation in SPARQL query these Literals are converted to python numeric types and since dateTime  Literals cannot be converted to numeric type, it ignores such variables. Thus, it looked important to handle the case of DateTime arithmetic in the SPARQL query.
The unary operator, in this case, wasn't working because I needed to use minus operator between two variables.

As you said, It will be also useful to add these arithmetic operations to raw Literals also. I have done this work for raw Literals also, I'll soon submit a PR for this, before the SPARQL query fix PR 😀

Thank you again, for taking out the time in guiding and helping me, Sir. 😊

Regards, 
Akash Sharma

Reply all
Reply to author
Forward
0 new messages