SPARQL parser has a problem with comments

2 views
Skip to first unread message

Conrad Leonard

unread,
Apr 13, 2015, 7:57:35 PM4/13/15
to sta...@clarkparsia.com
There is an odd issue with the parsing of SPARQL containing comment characters when there are spaces before the characters in certain positions:

using Stardog 3.0 create an empty test database and 3 test queries differeing only in where/whether there are preceding spaces in the comment lines:

[conradL@qimr13054 ~]$ stardog-admin db create -n test
Loading complete.
Inserted 0 triples in 00:00:00.782 at 0.0K triples/sec
Successfully created database 'test'.

[conradL@qimr13054 ~]$ for n in `seq 1 3`; do queryfile="test$n.sparql"; echo ==$queryfile==; cat $queryfile; stardog query test $queryfile; done
==test1.sparql==
#
#
#
SELECT * 
WHERE {
  ?s ?p ?o
}
+-------+-------+-------+
|   s   |   p   |   o   |
+-------+-------+-------+
+-------+-------+-------+

Query returned 0 results in 00:00:00.030
==test2.sparql==
 #
 #
#
SELECT * 
WHERE {
  ?s ?p ?o
}
+-------+-------+-------+
|   s   |   p   |   o   |
+-------+-------+-------+
+-------+-------+-------+

Query returned 0 results in 00:00:00.029
==test3.sparql==
#
 #
 #
SELECT * 
WHERE {
  ?s ?p ?o
}
Not a valid query string or a file: Encountered " "select" "SELECT "" at line 4, column 1.
Was expecting one of:
    <EOF> 
    ";" ...
    "base" ...
    "prefix" ...
    "load" ...
    "clear" ...
    "drop" ...
    "add" ...
    "move" ...
    "copy" ...
    "create" ...
    "insert" ...
    "delete" ...
    "with" ...

    


=Result= 
Error for the query where there is a space before the 2nd and 3rd comment lines
Same when entered into the web console query widget.

Michael Grove

unread,
Apr 14, 2015, 8:17:36 AM4/14/15
to stardog
Are you sure there's not some non-printable character in that file?  Your third example works fine for me:

mhgrove:dist mhgrove$ echo " #

>  #
> #
> SELECT *
> WHERE {
>   ?s ?p ?o
> }" > input.sparql
mhgrove:dist mhgrove$ ./bin/stardog query foo input.sparql
+-------+-------+-------+
|   s   |   p   |   o   |
+-------+-------+-------+
+-------+-------+-------+

Query returned 0 results in 00:00:00.102

Cheers,

Mike
 
=Result= 
Error for the query where there is a space before the 2nd and 3rd comment lines
Same when entered into the web console query widget.

--
-- --
You received this message because you are subscribed to the C&P "Stardog" group.
To post to this group, send email to sta...@clarkparsia.com
To unsubscribe from this group, send email to
stardog+u...@clarkparsia.com
For more options, visit this group at
http://groups.google.com/a/clarkparsia.com/group/stardog?hl=en

Conrad Leonard

unread,
Apr 14, 2015, 9:24:29 AM4/14/15
to sta...@clarkparsia.com
Hi Mike:
Yr working example is actually test2 (which works for me) - it's the 3rd one that's dodgy, with the leading spaces on 2nd and 3rd lines. I'm sure there are no bad chars involved, I can reproduce this in various ways.

Michael Grove

unread,
Apr 15, 2015, 11:17:34 AM4/15/15
to stardog
On Tue, Apr 14, 2015 at 9:24 AM, Conrad Leonard <conrad....@hotmail.com> wrote:
Hi Mike:
Yr working example is actually test2 (which works for me) - it's the 3rd one that's dodgy, with the leading spaces on 2nd and 3rd lines. I'm sure there are no bad chars involved, I can reproduce this in various ways.

Yep, you're right.  Looks like a bug in the utility we have to sniff the query type when it comes into the server. 

Thanks for reporting this, it'll be fixed in the next release.

Cheers,

Mike
 
Reply all
Reply to author
Forward
0 new messages