-3

I try the following SPARQL query on the end point, but it tells me

Virtuoso 37000 Error SP030: SPARQL compiler, line 4: syntax error at 'UNION' before 'select'

select ?uri, ?label where { quad map virtrdf:DefaultQuadMap { graph ?g { ?uri ?p ?label.FILTER (?label = 'biomass'@en) .}. values ?g {<BEFDATA>}}}
UNION
 select ?uri, ?label where { quad map virtrdf:DefaultQuadMap { graph ?g { ?uri ?p ? label.FILTER (?label = 'biomass'@en) .}. values ?g {<COPY>}}}
Joshua Taylor
  • 84,998
  • 9
  • 154
  • 353
callback
  • 3,981
  • 1
  • 31
  • 55
  • Just a thought, but maybe you have a syntax error at 'UNION' before 'select'. Did you bother to balance your braces? –  May 01 '14 at 07:08
  • @torazaburo It's not even that; it's that `union` doesn't combine multiple `select`s, but rather combines triple patterns within a `select`. – Joshua Taylor May 01 '14 at 11:29

1 Answers1

3

On what endpoint are you running this? That makes a big difference. There are lots of things that aren't legal SPARQL in your query (though they might be accepted by a Virtuoso endpoint). For instance: (i) it uses undefined prefixes; (ii) you have commas between the projection variables (?uri, ?label); (iii) quad map ... isn't part of SPARQL syntax; etc.

The main problem, though, that you're getting an error message about, is that union should appear between some triple patterns, not between two queries. E.g., you could do:

prefix : <http://example.org/>

select ?person ?name where {
  { ?person :firstName ?name }
  union 
  { ?person :lastName ?name }
}

but you wouldn't do

prefix : <http://example.org/>

select ?person ?name where { ?person :firstName ?name }
union 
select ?person ?name where { ?person :lastName ?name }
Joshua Taylor
  • 84,998
  • 9
  • 154
  • 353