Re: Binding graph names for WITH and USING

2017-10-26 Thread Andy Seaborne

Yes, sorry, I missed "UpdateBuilder" has "with(Object)".

We still don't know if they mean "all graphs" or template for "this graph".

On 26/10/17 07:47, Claude Warren wrote:

Another template solution is the query builder where you can bind the ?g
just before query.  Though I am not certain that you can specify a var for
the graph name when building the query.  If you can then using the setVar()
method to replace it just before execution.

Claude

On Wed, Oct 25, 2017 at 10:35 PM, Andy Seaborne <a...@apache.org> wrote:


USING is the like  SELECT-FROM -- the WG decided a different name was
better. It sets up the dataset to query in the WHERE clause.  Again, there
is no variable binding to use.

It looks to me like you really want $resourceMetadataGraph to come from
outside - a parametrized update.  If so, the unsubtle way is to do string
replacement.  I don't know if ParameterizedQueryString will work.

Don't forget

DELETE WHERE  QuadPattern

saves writing template and pattern

 Andy


On 25/10/17 21:04, Charles Greer wrote:



Hi Andy,


I was trying to just recreate the scenario -- the original query did have
a WHERE.

I found it:


prefix raf: <https://xxx/ns/raf/>
with $resourceMetadataGraph
delete {?urn raf:latest ?latest.}
where {?urn raf:latest ?latest.}


It was my attempt to present a workaround that ended up with a USING -
from SPARQL 1.1


"""

To illustrate the use of the WITH clause, an operation of the general
form:

WITH  DELETE { a b c } INSERT { x y z } WHERE { ... }

is considered equivalent to:

DELETE { GRAPH  { a b c } } INSERT { GRAPH  { x y z } } USING
 WHERE { ... }

"""


We have taken on binding after USING and WITH as an enhancement request,
but given your response I'm going to push back

until SPARQL 2.1


Thank you, Charles



From: Andy Seaborne <a...@apache.org>
Sent: Wednesday, October 25, 2017 11:10:12 AM
To: users@jena.apache.org
Subject: Re: Binding graph names for WITH and USING

What are they trying to achieve?

The Update has a second error the parsers didn't get to.

No WHERE clause - it's mandatory

Did they mean:

INSERT {
  GRAPH ?g { <http://example.org/a> <http://example.org/p> "1" }
}
WHERE
{ GRAPH ?g { } }

GRAPH ?g { } returns all graph names.

Where does USING come into this?

   > Sometimes "the spec prohibits it" is not what people want to hear.

That's what the commercial support has to answer!

   Andy


On 25/10/17 19:02, Charles Greer wrote:


The error from Jena when I try to reproduce is fairly clear:


@Test
public void testGraphBinding() {
   MarkLogicDatasetGraph dsg = getMarkLogicDatasetGraph();
   String updateQuery = "WITH ?g INSERT { <http://example.org/a> <
http://example.org/p> \"1\" }";
   BindingMap updateBindings = new BindingHashMap();
   updateBindings.add(Var.alloc("g"),
   NodeFactory.createURI("http://example.org/g;));
   UpdateRequest update = new UpdateRequest();
   update.add(updateQuery);
   UpdateAction.execute(update, dsg, updateBindings);
}



org.apache.jena.query.QueryParseException: Encountered "  "?g ""
at line 1, column 6.
Was expecting one of:
...
...
...



So I guess to reframe my question -- given that the expectation of this
customer is that ?g should be bindable here,

can I give them a rationale?  Sometimes "the spec prohibits it" is not
what people want to hear.




Charles Greer
Lead Engineer
MarkLogic Corporation
cgr...@marklogic.com
@grechaw
www.marklogic.com<http://www.marklogic.com>


Best Database for Integrating Data From Silos | MarkLogic<
http://www.marklogic.com/>
www.marklogic.com
Learn why MarkLogic Enterprise NoSQL is the world's best database for
integrating data from silos.





From: james anderson <ja...@dydra.com>
Sent: Wednesday, October 25, 2017 9:59:14 AM
To: users@jena.apache.org
Subject: Re: Binding graph names for WITH and USING

good evening;


On 2017-10-25, at 18:48, Charles Greer <charles.gr...@marklogic.com>

wrote:

Hi jena folks, I was surprised recently with a customer who was
surprised that my jena connector did not properly

bind graph names as variables after WITH.


WITH ?g

INSERT ...

DELETE ...


When I looked back at the SPARQL specs, it looks indeed true that
variables are inadmissable after WITH or USING.

I am curious about how to write a workaround, short of putting a
literal in for ?g



do you have a concrete example which you are in a position to share?

where did the customer express a binding for the ?g of which they
thought the ‘with’ clause was in its scope?

best regards, from berlin,










Re: Binding graph names for WITH and USING

2017-10-26 Thread Claude Warren
Another template solution is the query builder where you can bind the ?g
just before query.  Though I am not certain that you can specify a var for
the graph name when building the query.  If you can then using the setVar()
method to replace it just before execution.

Claude

On Wed, Oct 25, 2017 at 10:35 PM, Andy Seaborne <a...@apache.org> wrote:

> USING is the like  SELECT-FROM -- the WG decided a different name was
> better. It sets up the dataset to query in the WHERE clause.  Again, there
> is no variable binding to use.
>
> It looks to me like you really want $resourceMetadataGraph to come from
> outside - a parametrized update.  If so, the unsubtle way is to do string
> replacement.  I don't know if ParameterizedQueryString will work.
>
> Don't forget
>
> DELETE WHERE  QuadPattern
>
> saves writing template and pattern
>
> Andy
>
>
> On 25/10/17 21:04, Charles Greer wrote:
>
>>
>> Hi Andy,
>>
>>
>> I was trying to just recreate the scenario -- the original query did have
>> a WHERE.
>>
>> I found it:
>>
>>
>> prefix raf: <https://xxx/ns/raf/>
>> with $resourceMetadataGraph
>> delete {?urn raf:latest ?latest.}
>> where {?urn raf:latest ?latest.}
>>
>>
>> It was my attempt to present a workaround that ended up with a USING -
>> from SPARQL 1.1
>>
>>
>> """
>>
>> To illustrate the use of the WITH clause, an operation of the general
>> form:
>>
>> WITH  DELETE { a b c } INSERT { x y z } WHERE { ... }
>>
>> is considered equivalent to:
>>
>> DELETE { GRAPH  { a b c } } INSERT { GRAPH  { x y z } } USING
>>  WHERE { ... }
>>
>> """
>>
>>
>> We have taken on binding after USING and WITH as an enhancement request,
>> but given your response I'm going to push back
>>
>> until SPARQL 2.1
>>
>>
>> Thank you, Charles
>>
>>
>> 
>> From: Andy Seaborne <a...@apache.org>
>> Sent: Wednesday, October 25, 2017 11:10:12 AM
>> To: users@jena.apache.org
>> Subject: Re: Binding graph names for WITH and USING
>>
>> What are they trying to achieve?
>>
>> The Update has a second error the parsers didn't get to.
>>
>> No WHERE clause - it's mandatory
>>
>> Did they mean:
>>
>> INSERT {
>>  GRAPH ?g { <http://example.org/a> <http://example.org/p> "1" }
>> }
>> WHERE
>>{ GRAPH ?g { } }
>>
>> GRAPH ?g { } returns all graph names.
>>
>> Where does USING come into this?
>>
>>   > Sometimes "the spec prohibits it" is not what people want to hear.
>>
>> That's what the commercial support has to answer!
>>
>>   Andy
>>
>>
>> On 25/10/17 19:02, Charles Greer wrote:
>>
>>> The error from Jena when I try to reproduce is fairly clear:
>>>
>>>
>>> @Test
>>> public void testGraphBinding() {
>>>   MarkLogicDatasetGraph dsg = getMarkLogicDatasetGraph();
>>>   String updateQuery = "WITH ?g INSERT { <http://example.org/a> <
>>> http://example.org/p> \"1\" }";
>>>   BindingMap updateBindings = new BindingHashMap();
>>>   updateBindings.add(Var.alloc("g"),
>>>   NodeFactory.createURI("http://example.org/g;));
>>>   UpdateRequest update = new UpdateRequest();
>>>   update.add(updateQuery);
>>>   UpdateAction.execute(update, dsg, updateBindings);
>>> }
>>>
>>>
>>>
>>> org.apache.jena.query.QueryParseException: Encountered "  "?g ""
>>> at line 1, column 6.
>>> Was expecting one of:
>>>    ...
>>>    ...
>>>...
>>>
>>>
>>>
>>> So I guess to reframe my question -- given that the expectation of this
>>> customer is that ?g should be bindable here,
>>>
>>> can I give them a rationale?  Sometimes "the spec prohibits it" is not
>>> what people want to hear.
>>>
>>>
>>>
>>>
>>> Charles Greer
>>> Lead Engineer
>>> MarkLogic Corporation
>>> cgr...@marklogic.com
>>> @grechaw
>>> www.marklogic.com<http://www.marklogic.com>
>>>
>> Best Database for Integrating Data From Silos | MarkLogic<
>> http://www.marklogic.com/>
>> www.marklogic.com
>> Learn why MarkLogic

Re: Binding graph names for WITH and USING

2017-10-25 Thread Andy Seaborne
USING is the like  SELECT-FROM -- the WG decided a different name was 
better. It sets up the dataset to query in the WHERE clause.  Again, 
there is no variable binding to use.


It looks to me like you really want $resourceMetadataGraph to come from 
outside - a parametrized update.  If so, the unsubtle way is to do 
string replacement.  I don't know if ParameterizedQueryString will work.


Don't forget

DELETE WHERE  QuadPattern

saves writing template and pattern

Andy

On 25/10/17 21:04, Charles Greer wrote:


Hi Andy,


I was trying to just recreate the scenario -- the original query did have a 
WHERE.

I found it:


prefix raf: <https://xxx/ns/raf/>
with $resourceMetadataGraph
delete {?urn raf:latest ?latest.}
where {?urn raf:latest ?latest.}


It was my attempt to present a workaround that ended up with a USING - from 
SPARQL 1.1


"""

To illustrate the use of the WITH clause, an operation of the general form:

WITH  DELETE { a b c } INSERT { x y z } WHERE { ... }

is considered equivalent to:

DELETE { GRAPH  { a b c } } INSERT { GRAPH  { x y z } } USING  
WHERE { ... }

"""


We have taken on binding after USING and WITH as an enhancement request, but 
given your response I'm going to push back

until SPARQL 2.1


Thank you, Charles



From: Andy Seaborne <a...@apache.org>
Sent: Wednesday, October 25, 2017 11:10:12 AM
To: users@jena.apache.org
Subject: Re: Binding graph names for WITH and USING

What are they trying to achieve?

The Update has a second error the parsers didn't get to.

No WHERE clause - it's mandatory

Did they mean:

INSERT {
 GRAPH ?g { <http://example.org/a> <http://example.org/p> "1" }
}
WHERE
   { GRAPH ?g { } }

GRAPH ?g { } returns all graph names.

Where does USING come into this?

  > Sometimes "the spec prohibits it" is not what people want to hear.

That's what the commercial support has to answer!

  Andy


On 25/10/17 19:02, Charles Greer wrote:

The error from Jena when I try to reproduce is fairly clear:


@Test
public void testGraphBinding() {
  MarkLogicDatasetGraph dsg = getMarkLogicDatasetGraph();
  String updateQuery = "WITH ?g INSERT { <http://example.org/a> <http://example.org/p> 
\"1\" }";
  BindingMap updateBindings = new BindingHashMap();
  updateBindings.add(Var.alloc("g"),
  NodeFactory.createURI("http://example.org/g;));
  UpdateRequest update = new UpdateRequest();
  update.add(updateQuery);
  UpdateAction.execute(update, dsg, updateBindings);
}



org.apache.jena.query.QueryParseException: Encountered "  "?g "" at line 
1, column 6.
Was expecting one of:
   ...
   ...
   ...



So I guess to reframe my question -- given that the expectation of this 
customer is that ?g should be bindable here,

can I give them a rationale?  Sometimes "the spec prohibits it" is not what 
people want to hear.




Charles Greer
Lead Engineer
MarkLogic Corporation
cgr...@marklogic.com
@grechaw
www.marklogic.com<http://www.marklogic.com>

Best Database for Integrating Data From Silos | 
MarkLogic<http://www.marklogic.com/>
www.marklogic.com
Learn why MarkLogic Enterprise NoSQL is the world's best database for 
integrating data from silos.




________
From: james anderson <ja...@dydra.com>
Sent: Wednesday, October 25, 2017 9:59:14 AM
To: users@jena.apache.org
Subject: Re: Binding graph names for WITH and USING

good evening;



On 2017-10-25, at 18:48, Charles Greer <charles.gr...@marklogic.com> wrote:

Hi jena folks, I was surprised recently with a customer who was surprised that 
my jena connector did not properly

bind graph names as variables after WITH.


WITH ?g

INSERT ...

DELETE ...


When I looked back at the SPARQL specs, it looks indeed true that variables are 
inadmissable after WITH or USING.

I am curious about how to write a workaround, short of putting a literal in for 
?g


do you have a concrete example which you are in a position to share?

where did the customer express a binding for the ?g of which they thought the 
‘with’ clause was in its scope?

best regards, from berlin,






Re: Binding graph names for WITH and USING

2017-10-25 Thread Charles Greer

Hi Andy,


I was trying to just recreate the scenario -- the original query did have a 
WHERE.

I found it:


prefix raf: <https://xxx/ns/raf/>
with $resourceMetadataGraph
delete {?urn raf:latest ?latest.}
where {?urn raf:latest ?latest.}


It was my attempt to present a workaround that ended up with a USING - from 
SPARQL 1.1


"""

To illustrate the use of the WITH clause, an operation of the general form:

WITH  DELETE { a b c } INSERT { x y z } WHERE { ... }

is considered equivalent to:

DELETE { GRAPH  { a b c } } INSERT { GRAPH  { x y z } } USING  
WHERE { ... }

"""


We have taken on binding after USING and WITH as an enhancement request, but 
given your response I'm going to push back

until SPARQL 2.1


Thank you, Charles



From: Andy Seaborne <a...@apache.org>
Sent: Wednesday, October 25, 2017 11:10:12 AM
To: users@jena.apache.org
Subject: Re: Binding graph names for WITH and USING

What are they trying to achieve?

The Update has a second error the parsers didn't get to.

No WHERE clause - it's mandatory

Did they mean:

INSERT {
GRAPH ?g { <http://example.org/a> <http://example.org/p> "1" }
}
WHERE
  { GRAPH ?g { } }

GRAPH ?g { } returns all graph names.

Where does USING come into this?

 > Sometimes "the spec prohibits it" is not what people want to hear.

That's what the commercial support has to answer!

 Andy


On 25/10/17 19:02, Charles Greer wrote:
> The error from Jena when I try to reproduce is fairly clear:
>
>
> @Test
> public void testGraphBinding() {
>  MarkLogicDatasetGraph dsg = getMarkLogicDatasetGraph();
>  String updateQuery = "WITH ?g INSERT { <http://example.org/a> 
> <http://example.org/p> \"1\" }";
>  BindingMap updateBindings = new BindingHashMap();
>  updateBindings.add(Var.alloc("g"),
>  NodeFactory.createURI("http://example.org/g;));
>  UpdateRequest update = new UpdateRequest();
>  update.add(updateQuery);
>  UpdateAction.execute(update, dsg, updateBindings);
> }
>
>
>
> org.apache.jena.query.QueryParseException: Encountered "  "?g "" at 
> line 1, column 6.
> Was expecting one of:
>   ...
>   ...
>   ...
>
>
>
> So I guess to reframe my question -- given that the expectation of this 
> customer is that ?g should be bindable here,
>
> can I give them a rationale?  Sometimes "the spec prohibits it" is not what 
> people want to hear.
>
>
>
>
> Charles Greer
> Lead Engineer
> MarkLogic Corporation
> cgr...@marklogic.com
> @grechaw
> www.marklogic.com<http://www.marklogic.com>
Best Database for Integrating Data From Silos | 
MarkLogic<http://www.marklogic.com/>
www.marklogic.com
Learn why MarkLogic Enterprise NoSQL is the world's best database for 
integrating data from silos.


>
> 
> From: james anderson <ja...@dydra.com>
> Sent: Wednesday, October 25, 2017 9:59:14 AM
> To: users@jena.apache.org
> Subject: Re: Binding graph names for WITH and USING
>
> good evening;
>
>
>> On 2017-10-25, at 18:48, Charles Greer <charles.gr...@marklogic.com> wrote:
>>
>> Hi jena folks, I was surprised recently with a customer who was surprised 
>> that my jena connector did not properly
>>
>> bind graph names as variables after WITH.
>>
>>
>> WITH ?g
>>
>> INSERT ...
>>
>> DELETE ...
>>
>>
>> When I looked back at the SPARQL specs, it looks indeed true that variables 
>> are inadmissable after WITH or USING.
>>
>> I am curious about how to write a workaround, short of putting a literal in 
>> for ?g
>
> do you have a concrete example which you are in a position to share?
>
> where did the customer express a binding for the ?g of which they thought the 
> ‘with’ clause was in its scope?
>
> best regards, from berlin,
>
>


Re: Binding graph names for WITH and USING

2017-10-25 Thread Andy Seaborne

What are they trying to achieve?

The Update has a second error the parsers didn't get to.

No WHERE clause - it's mandatory

Did they mean:

INSERT {
   GRAPH ?g { <http://example.org/a> <http://example.org/p> "1" }
}
WHERE
 { GRAPH ?g { } }

GRAPH ?g { } returns all graph names.

Where does USING come into this?

> Sometimes "the spec prohibits it" is not what people want to hear.

That's what the commercial support has to answer!

Andy


On 25/10/17 19:02, Charles Greer wrote:

The error from Jena when I try to reproduce is fairly clear:


@Test
public void testGraphBinding() {
 MarkLogicDatasetGraph dsg = getMarkLogicDatasetGraph();
 String updateQuery = "WITH ?g INSERT { <http://example.org/a> <http://example.org/p> 
\"1\" }";
 BindingMap updateBindings = new BindingHashMap();
 updateBindings.add(Var.alloc("g"),
 NodeFactory.createURI("http://example.org/g;));
 UpdateRequest update = new UpdateRequest();
 update.add(updateQuery);
 UpdateAction.execute(update, dsg, updateBindings);
}



org.apache.jena.query.QueryParseException: Encountered "  "?g "" at line 
1, column 6.
Was expecting one of:
  ...
  ...
  ...



So I guess to reframe my question -- given that the expectation of this 
customer is that ?g should be bindable here,

can I give them a rationale?  Sometimes "the spec prohibits it" is not what 
people want to hear.




Charles Greer
Lead Engineer
MarkLogic Corporation
cgr...@marklogic.com
@grechaw
www.marklogic.com


From: james anderson <ja...@dydra.com>
Sent: Wednesday, October 25, 2017 9:59:14 AM
To: users@jena.apache.org
Subject: Re: Binding graph names for WITH and USING

good evening;



On 2017-10-25, at 18:48, Charles Greer <charles.gr...@marklogic.com> wrote:

Hi jena folks, I was surprised recently with a customer who was surprised that 
my jena connector did not properly

bind graph names as variables after WITH.


WITH ?g

INSERT ...

DELETE ...


When I looked back at the SPARQL specs, it looks indeed true that variables are 
inadmissable after WITH or USING.

I am curious about how to write a workaround, short of putting a literal in for 
?g


do you have a concrete example which you are in a position to share?

where did the customer express a binding for the ?g of which they thought the 
‘with’ clause was in its scope?

best regards, from berlin,




Re: Binding graph names for WITH and USING

2017-10-25 Thread Charles Greer
The error from Jena when I try to reproduce is fairly clear:


@Test
public void testGraphBinding() {
MarkLogicDatasetGraph dsg = getMarkLogicDatasetGraph();
String updateQuery = "WITH ?g INSERT { <http://example.org/a> 
<http://example.org/p> \"1\" }";
BindingMap updateBindings = new BindingHashMap();
updateBindings.add(Var.alloc("g"),
NodeFactory.createURI("http://example.org/g;));
UpdateRequest update = new UpdateRequest();
update.add(updateQuery);
UpdateAction.execute(update, dsg, updateBindings);
}



org.apache.jena.query.QueryParseException: Encountered "  "?g "" at line 
1, column 6.
Was expecting one of:
 ...
 ...
 ...



So I guess to reframe my question -- given that the expectation of this 
customer is that ?g should be bindable here,

can I give them a rationale?  Sometimes "the spec prohibits it" is not what 
people want to hear.




Charles Greer
Lead Engineer
MarkLogic Corporation
cgr...@marklogic.com
@grechaw
www.marklogic.com


From: james anderson <ja...@dydra.com>
Sent: Wednesday, October 25, 2017 9:59:14 AM
To: users@jena.apache.org
Subject: Re: Binding graph names for WITH and USING

good evening;


> On 2017-10-25, at 18:48, Charles Greer <charles.gr...@marklogic.com> wrote:
>
> Hi jena folks, I was surprised recently with a customer who was surprised 
> that my jena connector did not properly
>
> bind graph names as variables after WITH.
>
>
> WITH ?g
>
> INSERT ...
>
> DELETE ...
>
>
> When I looked back at the SPARQL specs, it looks indeed true that variables 
> are inadmissable after WITH or USING.
>
> I am curious about how to write a workaround, short of putting a literal in 
> for ?g

do you have a concrete example which you are in a position to share?

where did the customer express a binding for the ?g of which they thought the 
‘with’ clause was in its scope?

best regards, from berlin,



Re: Binding graph names for WITH and USING

2017-10-25 Thread james anderson
good evening;


> On 2017-10-25, at 18:48, Charles Greer  wrote:
> 
> Hi jena folks, I was surprised recently with a customer who was surprised 
> that my jena connector did not properly
> 
> bind graph names as variables after WITH.
> 
> 
> WITH ?g
> 
> INSERT ...
> 
> DELETE ...
> 
> 
> When I looked back at the SPARQL specs, it looks indeed true that variables 
> are inadmissable after WITH or USING.
> 
> I am curious about how to write a workaround, short of putting a literal in 
> for ?g

do you have a concrete example which you are in a position to share?

where did the customer express a binding for the ?g of which they thought the 
‘with’ clause was in its scope?

best regards, from berlin,



Re: Binding graph names for WITH and USING

2017-10-25 Thread Andy Seaborne

Hi Charles,

Indeed as the spec says:

[41]Modify::=
( 'WITH' iri )?
( DeleteClause InsertClause? | InsertClause ) UsingClause*
'WHERE' GroupGraphPattern

Where does the value for $g come from in the example?

Andy

On 25/10/17 17:48, Charles Greer wrote:

Hi jena folks, I was surprised recently with a customer who was surprised that 
my jena connector did not properly

bind graph names as variables after WITH.


WITH ?g

INSERT ...

DELETE ...


When I looked back at the SPARQL specs, it looks indeed true that variables are 
inadmissable after WITH or USING.

I am curious about how to write a workaround, short of putting a literal in for 
?g


Thanks, Charles


Charles Greer
Lead Engineer
MarkLogic Corporation
cgr...@marklogic.com
@grechaw
www.marklogic.com




Binding graph names for WITH and USING

2017-10-25 Thread Charles Greer
Hi jena folks, I was surprised recently with a customer who was surprised that 
my jena connector did not properly

bind graph names as variables after WITH.


WITH ?g

INSERT ...

DELETE ...


When I looked back at the SPARQL specs, it looks indeed true that variables are 
inadmissable after WITH or USING.

I am curious about how to write a workaround, short of putting a literal in for 
?g


Thanks, Charles


Charles Greer
Lead Engineer
MarkLogic Corporation
cgr...@marklogic.com
@grechaw
www.marklogic.com