Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bind(somefunctions()) interferes with outer service #241

Open
justin2004 opened this issue Apr 3, 2022 · 11 comments
Open

bind(somefunctions()) interferes with outer service #241

justin2004 opened this issue Apr 3, 2022 · 11 comments
Labels
Bug Something isn't working

Comments

@justin2004
Copy link
Contributor

justin2004 commented Apr 3, 2022

This works as expected:

PREFIX  fx:   <http://sparql.xyz/facade-x/ns/>
PREFIX  rdf:  <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX  xyz:  <http://sparql.xyz/facade-x/data/>

SELECT  *
WHERE
  { SERVICE <x-sparql-anything:>
      { SERVICE <x-sparql-anything:>
          { fx:properties
                      fx:command     "echo 4,5,6" ;
                      fx:media-type  "text/csv" .
            ?s        ?p             ?num .
            # BIND(bnode() AS ?bob)           # breaks
            # BIND(struuid() AS ?bob)         # breaks
            # BIND(concat("a","b") AS ?bob)   # works
            # BIND("lala" AS ?bob)            # works
          }
        BIND(concat("seq ", ?num) AS ?second_cmd)
        fx:properties
                  fx:command     ?second_cmd ;
                  fx:media-type  "text/plain" ;
                  fx:txt.split   "\n" .
        ?ss       ?pp            ?oo
      }
  }

but if you uncomment the calls to bind() one at a time some of them cause the outer service to not return any results. That is, all the results come from the inner service.

@justin2004
Copy link
Contributor Author

here is the expected output:

s p num bob second_cmd ss pp oo
_:b0 http://www\.w3\.org/1999/02/22\-rdf\-syntax\-ns\#\_1 4 lala seq 4 _:b1 http://www\.w3\.org/1999/02/22\-rdf\-syntax\-ns\#type http://sparql\.xyz/facade\-x/ns/root
_:b0 http://www\.w3\.org/1999/02/22\-rdf\-syntax\-ns\#\_1 4 lala seq 4 _:b1 http://www\.w3\.org/1999/02/22\-rdf\-syntax\-ns\#\_1 1
_:b0 http://www\.w3\.org/1999/02/22\-rdf\-syntax\-ns\#\_1 4 lala seq 4 _:b1 http://www\.w3\.org/1999/02/22\-rdf\-syntax\-ns\#\_2 2
_:b0 http://www\.w3\.org/1999/02/22\-rdf\-syntax\-ns\#\_1 4 lala seq 4 _:b1 http://www\.w3\.org/1999/02/22\-rdf\-syntax\-ns\#\_3 3
_:b0 http://www\.w3\.org/1999/02/22\-rdf\-syntax\-ns\#\_1 4 lala seq 4 _:b1 http://www\.w3\.org/1999/02/22\-rdf\-syntax\-ns\#\_4 4
_:b0 http://www\.w3\.org/1999/02/22\-rdf\-syntax\-ns\#\_2 5 lala seq 5 _:b2 http://www\.w3\.org/1999/02/22\-rdf\-syntax\-ns\#type http://sparql\.xyz/facade\-x/ns/root
_:b0 http://www\.w3\.org/1999/02/22\-rdf\-syntax\-ns\#\_2 5 lala seq 5 _:b2 http://www\.w3\.org/1999/02/22\-rdf\-syntax\-ns\#\_1 1
_:b0 http://www\.w3\.org/1999/02/22\-rdf\-syntax\-ns\#\_2 5 lala seq 5 _:b2 http://www\.w3\.org/1999/02/22\-rdf\-syntax\-ns\#\_2 2
_:b0 http://www\.w3\.org/1999/02/22\-rdf\-syntax\-ns\#\_2 5 lala seq 5 _:b2 http://www\.w3\.org/1999/02/22\-rdf\-syntax\-ns\#\_3 3
_:b0 http://www\.w3\.org/1999/02/22\-rdf\-syntax\-ns\#\_2 5 lala seq 5 _:b2 http://www\.w3\.org/1999/02/22\-rdf\-syntax\-ns\#\_4 4
_:b0 http://www\.w3\.org/1999/02/22\-rdf\-syntax\-ns\#\_2 5 lala seq 5 _:b2 http://www\.w3\.org/1999/02/22\-rdf\-syntax\-ns\#\_5 5
_:b0 http://www\.w3\.org/1999/02/22\-rdf\-syntax\-ns\#\_3 6 lala seq 6 _:b3 http://www\.w3\.org/1999/02/22\-rdf\-syntax\-ns\#type http://sparql\.xyz/facade\-x/ns/root
_:b0 http://www\.w3\.org/1999/02/22\-rdf\-syntax\-ns\#\_3 6 lala seq 6 _:b3 http://www\.w3\.org/1999/02/22\-rdf\-syntax\-ns\#\_1 1
_:b0 http://www\.w3\.org/1999/02/22\-rdf\-syntax\-ns\#\_3 6 lala seq 6 _:b3 http://www\.w3\.org/1999/02/22\-rdf\-syntax\-ns\#\_2 2
_:b0 http://www\.w3\.org/1999/02/22\-rdf\-syntax\-ns\#\_3 6 lala seq 6 _:b3 http://www\.w3\.org/1999/02/22\-rdf\-syntax\-ns\#\_3 3
_:b0 http://www\.w3\.org/1999/02/22\-rdf\-syntax\-ns\#\_3 6 lala seq 6 _:b3 http://www\.w3\.org/1999/02/22\-rdf\-syntax\-ns\#\_4 4
_:b0 http://www\.w3\.org/1999/02/22\-rdf\-syntax\-ns\#\_3 6 lala seq 6 _:b3 http://www\.w3\.org/1999/02/22\-rdf\-syntax\-ns\#\_5 5
_:b0 http://www\.w3\.org/1999/02/22\-rdf\-syntax\-ns\#\_3 6 lala seq 6 _:b3 http://www\.w3\.org/1999/02/22\-rdf\-syntax\-ns\#\_6 6

@justin2004
Copy link
Contributor Author

The reason I think this should work is that the calls to bind() in this query don't alter the results of the outer service.

PREFIX  xyz:  <http://sparql.xyz/facade-x/data/>
PREFIX  xsd:  <http://www.w3.org/2001/XMLSchema#>
PREFIX  fx:   <http://sparql.xyz/facade-x/ns/>
PREFIX  ex:   <http://example.com/>
PREFIX  rdf:  <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX wd:       <http://www.wikidata.org/entity/>         # Wikibase entity - item or property. 
PREFIX wdt:      <http://www.wikidata.org/prop/direct/>    # Truthy assertions about the data, links entity to value directly. 
select *
WHERE
  { SERVICE <https://query.wikidata.org/sparql>
      {
        SERVICE <https://query.wikidata.org/sparql>{
        wd:Q1 wdt:P1889 ?o .
        bind(bnode() as ?a)
        bind(struuid() as ?b)
        }
        ?o ?p wd:Q1426992 .
      }
  } limit 50

enridaga added a commit that referenced this issue Apr 22, 2022
@luigi-asprino luigi-asprino added the Bug Something isn't working label Aug 3, 2022
luigi-asprino added a commit that referenced this issue Nov 16, 2023
@luigi-asprino
Copy link
Member

I've investigated a little bit the issue without figuring out the problem! I've just modified the query a bit to make it work, but this is very strange. I doubt that it can depend on sparql anything.

@justin2004
Copy link
Contributor Author

I've investigated a little bit the issue without figuring out the problem!

haha. love that cheerfulness.

I doubt that it can depend on sparql anything.

ah, you think it is a jena bug?

@enridaga
Copy link
Member

The query posted originally by @justin2004 #241 (comment) doesn't work on v0.9-DEV -- I get SO:

$ fx -q issue241_retrying.sparql 
[main] INFO io.github.sparqlanything.model.Triplifier - Running command: bash -c echo 4,5,6
[main] INFO io.github.sparqlanything.model.Triplifier - Command stderr: 
[main] INFO io.github.sparqlanything.model.Triplifier - Running command: bash -c echo 4,5,6
[main] INFO io.github.sparqlanything.model.Triplifier - Command stderr: 
[main] INFO io.github.sparqlanything.model.Triplifier - Running command: bash -c echo 4,5,6
[main] INFO io.github.sparqlanything.model.Triplifier - Command stderr: 
[main] INFO io.github.sparqlanything.model.Triplifier - Running command: bash -c echo 4,5,6
[main] INFO io.github.sparqlanything.model.Triplifier - Command stderr: 
s,p,num,second_cmd,ss,pp,oo
Exception in thread "main" java.lang.StackOverflowError
	at org.apache.jena.sparql.engine.binding.BindingBase.get(BindingBase.java:111)

@enridaga
Copy link
Member

In addition, explain -e does not show anything, I wanted to check the algebra...

@luigi-asprino
Copy link
Member

I've investigated a little bit the issue without figuring out the problem!

haha. love that cheerfulness.

:-D

I doubt that it can depend on sparql anything.

ah, you think it is a jena bug?

Not sure, but the query breaks when BNODE or strUUID functions are used in BIND. SA engine does operate on extend operations and BNODE strUUID are standard SPARQL functions.

The query posted originally by @justin2004 #241 (comment) doesn't work on v0.9-DEV -- I get SO:

Maybe because ?num matches with URIs (fx:root) and container blank nodes. This is then concatenated with seq some strange behaviour.

@enridaga
Copy link
Member

Maybe because ?num matches with URIs (fx:root) and container blank nodes. This is then concatenated with seq some strange behaviour.

Actually, the following change makes it work:

PREFIX  fx:   <http://sparql.xyz/facade-x/ns/>
PREFIX  rdf:  <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX  xyz:  <http://sparql.xyz/facade-x/data/>

SELECT  *
WHERE
  { 
     SERVICE <x-sparql-anything:>
     { 
          SERVICE <x-sparql-anything:>
          { fx:properties
                      fx:command     "echo 4,5,6" ;
                      fx:media-type  "text/csv" .
            [] fx:anySlot [ ?p             ?num ] .
            # BIND(bnode() AS ?bob)           # breaks
            # BIND(struuid() AS ?bob)         # breaks
            # BIND(concat("a","b") AS ?bob)   # works
            # BIND("lala" AS ?bob)            # works
          }
        BIND(concat("seq ", ?num) AS ?second_cmd)
        fx:properties
            fx:command     ?second_cmd ;
            fx:media-type  "text/plain" ;
            fx:txt.split   "\n" .
        ?ss       ?pp            ?oo
     }
  }

@luigi-asprino
Copy link
Member

It is similar to that included via 9ddd3ee

@enridaga
Copy link
Member

It is similar to that included via 9ddd3ee

Oh I didn't notice you went through it already

@luigi-asprino
Copy link
Member

No problem, hope you will figure out the problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants