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

UUID() and STRUUID() evaluated once per query rather than once per binding #515

Open
jindrichmynarz opened this issue Dec 30, 2015 · 22 comments
Open

Comments

@jindrichmynarz
Copy link

@jindrichmynarz jindrichmynarz commented Dec 30, 2015

If you execute a query that uses UUID() or STRUUID() the same UUID is generated for each binding. For example (tested on Virtuoso 07.20.3215):

SELECT ?s ?p ?o (STRUUID() AS ?uuid)
WHERE {
  ?s ?p ?o .
}
LIMIT 10

This leads me to believe that the UUID functions are evaluated only once per query execution rather than once per each query binding. The SPARQL specification says that "Each call of UUID() returns a different UUID." It seems that Virtuoso violates that. Moreover, I think previous versions of Virtuoso implemented this correctly, so it may be a regression.

@HughWilliams
Copy link
Collaborator

@HughWilliams HughWilliams commented Dec 30, 2015

@jindrichmynarz: Works fine for me with each execution returning a different UUID ...

SQL> SPARQL SELECT ?s ?p ?o (STRUUID() AS ?uuid) WHERE {   ?s ?p ?o . } LIMIT 2; 
s                                                                                 p                                                                                 o                                                                                 uuid
LONG VARCHAR                                                                      LONG VARCHAR                                                                      LONG VARCHAR                                                                      VARCHAR
_______________________________________________________________________________

http://www.openlinksw.com/virtrdf-data-formats#default-iid                        http://www.w3.org/1999/02/22-rdf-syntax-ns#type                                   http://www.openlinksw.com/schemas/virtrdf#QuadMapFormat                           8CE00A58-AF0D-11E5-9AD7-C8463BEB0D19
http://www.openlinksw.com/virtrdf-data-formats#default-iid-nullable               http://www.w3.org/1999/02/22-rdf-syntax-ns#type                                   http://www.openlinksw.com/schemas/virtrdf#QuadMapFormat                           8CE00A58-AF0D-11E5-9AD7-C8463BEB0D19

2 Rows. -- 3 msec.
SQL> SQL> SPARQL SELECT ?s ?p ?o (STRUUID() AS ?uuid) WHERE {   ?s ?p ?o . } LIMIT 2;
s                                                                                 p                                                                                 o                                                                                 uuid
LONG VARCHAR                                                                      LONG VARCHAR                                                                      LONG VARCHAR                                                                      VARCHAR
_______________________________________________________________________________

http://www.openlinksw.com/virtrdf-data-formats#default-iid                        http://www.w3.org/1999/02/22-rdf-syntax-ns#type                                   http://www.openlinksw.com/schemas/virtrdf#QuadMapFormat                           97009E76-AF0D-11E5-9AD7-C8463BEB0D19
http://www.openlinksw.com/virtrdf-data-formats#default-iid-nullable               http://www.w3.org/1999/02/22-rdf-syntax-ns#type                                   http://www.openlinksw.com/schemas/virtrdf#QuadMapFormat                           97009E76-AF0D-11E5-9AD7-C8463BEB0D19

2 Rows. -- 1 msec.
SQL> SPARQL SELECT ?s ?p ?o (STRUUID() AS ?uuid) WHERE {   ?s ?p ?o . } LIMIT 2;
s                                                                                 p                                                                                 o                                                                                 uuid
LONG VARCHAR                                                                      LONG VARCHAR                                                                      LONG VARCHAR                                                                      VARCHAR
_______________________________________________________________________________

http://www.openlinksw.com/virtrdf-data-formats#default-iid                        http://www.w3.org/1999/02/22-rdf-syntax-ns#type                                   http://www.openlinksw.com/schemas/virtrdf#QuadMapFormat                           9BEF4874-AF0D-11E5-9AD7-C8463BEB0D19
http://www.openlinksw.com/virtrdf-data-formats#default-iid-nullable               http://www.w3.org/1999/02/22-rdf-syntax-ns#type                                   http://www.openlinksw.com/schemas/virtrdf#QuadMapFormat                           9BEF4874-AF0D-11E5-9AD7-C8463BEB0D19

2 Rows. -- 0 msec.
SQL> status('');
REPORT
VARCHAR
_______________________________________________________________________________

OpenLink Virtuoso  Server
Version 07.20.3215-pthreads for Darwin as of Dec 30 2015 
Started on: 2015-12-30 15:35 GMT+0

@jindrichmynarz
Copy link
Author

@jindrichmynarz jindrichmynarz commented Dec 30, 2015

Yes, it returns a different UUID per each query execution. The issue is that the generated UUIDs are the same for each binding in the result set.

@jindrichmynarz
Copy link
Author

@jindrichmynarz jindrichmynarz commented Dec 30, 2015

For example, try this query:

SELECT (STRUUID() AS ?uuid)
WHERE { VALUES ?line { 1 2 3 4 5 } }

Using Virtuoso, all 5 generated UUIDs are the same. Using Apache Jena Fuseki, each UUID is distinct (see here).

@HughWilliams
Copy link
Collaborator

@HughWilliams HughWilliams commented Dec 30, 2015

@jindrichmynarz: OK, I misread your description. I can see the problem now and have reported to development ...

@Polymathronic
Copy link

@Polymathronic Polymathronic commented Jan 19, 2016

+1. Any updates?

@openlink
Copy link
Owner

@openlink openlink commented Jan 19, 2016

Development is working on a fix which will hopefully be committed soon.

@jindrichmynarz
Copy link
Author

@jindrichmynarz jindrichmynarz commented Apr 7, 2016

Is there a progress on this issue?

@irygaev
Copy link

@irygaev irygaev commented Apr 29, 2016

The same issue is with bif:next_sequence function

@Polymathronic
Copy link

@Polymathronic Polymathronic commented Aug 24, 2016

Has this been resolved?

@HughWilliams
Copy link
Collaborator

@HughWilliams HughWilliams commented Aug 26, 2016

This issue is still to be resolved ...

@jindrichmynarz
Copy link
Author

@jindrichmynarz jindrichmynarz commented Nov 1, 2016

This is still an issue in 377438a.

@yyz1989
Copy link

@yyz1989 yyz1989 commented Feb 8, 2017

is it still open?

@jindrichmynarz
Copy link
Author

@jindrichmynarz jindrichmynarz commented Apr 17, 2017

Still an issue in 07.20.3217.

@HughWilliams
Copy link
Collaborator

@HughWilliams HughWilliams commented Apr 22, 2017

Chased development of update on fix for this issue ...

@jakubklimek
Copy link

@jakubklimek jakubklimek commented Sep 8, 2017

Any news?

@ghost
Copy link

@ghost ghost commented Nov 6, 2017

Any update?

@boutros
Copy link

@boutros boutros commented Jul 5, 2018

Would be great to have this fixed. Any pointers to where to look in the code if I where to have a go at it?

@nvdk
Copy link

@nvdk nvdk commented Jan 23, 2019

we ran into this as well. for those interested you can use the following construct as a workaround. This will cause STRUUID to be evaluated for each row.

OPTIONAL { ?s mu:uuid ?uuid } BIND(IF(BOUND(?uuid), ?uuid, STRUUID()) as ?realUUID)

hat tip to @Rahien

@rwynne
Copy link

@rwynne rwynne commented May 2, 2019

What would it take for bif:UUID() to be called in a function that is processed over and over within a query? It requires a value.

Example:

BIND(IRI(CONCAT('<namespace>#foo-', bif:uuid(?bar_value))) as ?my_result)

@HughWilliams
Copy link
Collaborator

@HughWilliams HughWilliams commented May 29, 2019

@rwynne - Not sure what you are asking, please provide a specific demonstrable example ...

@kidehen
Copy link

@kidehen kidehen commented Oct 27, 2019

This is still an issue in 377438a.

It is an issue in the Open Source edition rather than the Commercial Edition.

SELECT DISTINCT  (STRUUID() AS ?strUUID) (UUID() AS ?UUID)
WHERE {
        [] a ?o . 
      }

LIMIT 10

SeeAlso Live Query Solution Page -- based on the Commercial Edition.

/cc @HughWilliams

@TallTed
Copy link
Collaborator

@TallTed TallTed commented Oct 28, 2019

@kidehen /cc @HughWilliams

To be clear, the issue is resolved in Commercial/Enterprise Edition v08.03.3315 (9c4e63d226) built 2019-10-25, if not earlier, as seen here (your link), which has 10 unique strUUID and 10 unique UUID.

It persists in Commercial/Enterprise Edition v07.20.3232 (2afcc45d7c) built 2019-08-09, if not later, as seen here, which has 10 unique strUUID and 1 UUID repeated 10 times.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet