Skip to content
This repository has been archived by the owner on Jan 28, 2025. It is now read-only.

[Bug] Corese sparql binds multiples NOW() value in one query #168

Closed
MaillPierre opened this issue Jan 10, 2024 · 2 comments
Closed

[Bug] Corese sparql binds multiples NOW() value in one query #168

MaillPierre opened this issue Jan 10, 2024 · 2 comments

Comments

@MaillPierre
Copy link
Member

Issue Description:

During one query, if NOW() is bound to a variable in the results, the variable will have as many values as the number of milliseconds taken to execute the query.

Steps to Reproduce:

  1. Create test_query.rq containg:
PREFIX pav: <http://purl.org/pav/>

CONSTRUCT {
    <> pav:lastUpdateOn ?date .
}
WHERE {
    ?s ?p ?o .
    BIND(NOW() AS ?date)
}
  1. Execute the following query, you can replace the target with any large enough file:
    java -jar corese-command-4.5.0.jar sparql -q test_query.rq -i https://raw.githubusercontent.com/Wimmics/IndeGx/main/catalogs/all_catalog_edited.ttl

  2. The result will look something like:

@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix pav: <http://purl.org/pav/> .

<> pav:lastUpdateOn "2024-01-10T11:06:04.503+01:00"^^xsd:dateTime ;
  pav:lastUpdateOn "2024-01-10T11:06:04.504+01:00"^^xsd:dateTime ;
  pav:lastUpdateOn "2024-01-10T11:06:04.505+01:00"^^xsd:dateTime ;
  pav:lastUpdateOn "2024-01-10T11:06:04.506+01:00"^^xsd:dateTime ;
  pav:lastUpdateOn "2024-01-10T11:06:04.507+01:00"^^xsd:dateTime ;
  pav:lastUpdateOn "2024-01-10T11:06:04.508+01:00"^^xsd:dateTime ;
  pav:lastUpdateOn "2024-01-10T11:06:04.509+01:00"^^xsd:dateTime ;
  pav:lastUpdateOn "2024-01-10T11:06:04.510+01:00"^^xsd:dateTime .

Expected Behavior:
The result should contain only one binding for NOW(), either at the start of the execution or at the end, at the developer's discretion. This is the behavior expected by the SPARQL 1.1 standard

Note to Developers:

Correcting this bug could slightly speed up querying because this implies a lot of unnecessary calls to the NOW() function.

@remiceres
Copy link
Collaborator

Hello Pierre,

Thank you for your report. After testing, we've found that the problem is reproducible and is not limited to the Corese command but affects Corese in general, including all interfaces. We will investigate this further and work on a fix.

@remiceres remiceres changed the title [Bug] Corese-command sparql binds multiples NOW() value in one query [Bug] Corese sparql binds multiples NOW() value in one query Jan 11, 2024
remiceres added a commit that referenced this issue Jan 12, 2024
The Binding class has been updated to store and retrieve the current time value, allowing the now() function to return the same value during processing. This improves the consistency and reliability of the now() function. Fix #168.
@remiceres
Copy link
Collaborator

Hello,

The issue with the now function has been fixed and will be available in the next release.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants