Insert with blank node failing - There was an error while generating the plan

Hi,

I’m trying to insert a node into the end of a list. Fails with an error about generating the plan. Here is a minimal example based off of my query.

insert {?elt rdf:rest [ rdf:first "YAY" ; rdf:rest rdf:nil ]}
where {?elt ?b ?c}

This is a tricky little bug indeed. While the SPARQL spec does imply that you can use this bnode syntax in an INSERT clause, it’s being interpreted in a way that causes the query planner to make a false assumption and throw an Exception. I will log an internal bug to look at this, but in the meantime you can use this slightly different bnode syntax:

insert {?elt rdf:rest _:b0 . _:b0 rdf:first "YAY" ; rdf:rest rdf:nil}

As an aside, if you’re trying to add an element to the end of an RDF list, I would recommend a DELETE/INSERT query, as inserting the ?elt rdf:rest _:b0 triple won’t by itself remove the existing ?elt rdf:rest rdf:nil triple:

delete {?elt rdf:rest rdf:nil }
insert {?elt rdf:rest _:b0 . _:b0 rdf:first "YAY" ; rdf:rest rdf:nil}
where {?elt rdf:rest rdf:nil }

Thanks Stephen. Will try that.

I cut out everything I could from the query to find out what was going wrong.

Found this nice blog post with lots of examples for adding to front/end/arbitrary places in a list with SPARQL. Super useful. ARQtick: Updating RDF Lists with SPARQL