Skip to content

Add builtin function ql:toEpoch#2841

Open
yarox-1 wants to merge 8 commits intoad-freiburg:masterfrom
yarox-1:Epoch
Open

Add builtin function ql:toEpoch#2841
yarox-1 wants to merge 8 commits intoad-freiburg:masterfrom
yarox-1:Epoch

Conversation

@yarox-1
Copy link
Copy Markdown
Contributor

@yarox-1 yarox-1 commented Apr 24, 2026

This adds the function ql:toEpoch. With this a xsd:datetime can be turned into an epoch timepoint in int. This function allows to correcly use =, <, > for xsd:datetime objects.

Here is an example for =:

PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
SELECT ?date1 ?date2 ?neqWithoutEpoch ?eqWithEpoch 
WHERE {
     BIND("2025-12-24T18:15:00Z"^^xsd:dateTime AS ?date1)
     BIND("2025-12-24T17:15:00-01:00"^^xsd:dateTime AS ?date2)
     BIND(?date1 = ?date2 AS ?neqWithoutEpoch)
     BIND(ql:toEpoch(?date1) = ql:toEpoch(?date2) AS ?eqWithEpoch)
}

and here for <:

PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
SELECT ?date1 ?date2 ?lt1 ?lt2
WHERE {
    BIND("2025-12-24T14:15:00Z"^^xsd:dateTime AS ?date1)
    BIND("2025-12-24T13:15:00-02:00"^^xsd:dateTime AS ?date2)
    BIND(ql:toEpoch(?date1) < ql:toEpoch(?date2) AS ?lt1)
    BIND(ql:toEpoch(?date2) < ql:toEpoch(?date1) AS ?lt2)
}

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 24, 2026

Codecov Report

❌ Patch coverage is 57.69231% with 11 lines in your changes missing coverage. Please review.
✅ Project coverage is 92.34%. Comparing base (eeb9fd0) to head (4105ab0).
⚠️ Report is 13 commits behind head on master.

Files with missing lines Patch % Lines
src/engine/sparqlExpressions/DateExpressions.cpp 15.38% 11 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2841      +/-   ##
==========================================
- Coverage   92.38%   92.34%   -0.04%     
==========================================
  Files         506      510       +4     
  Lines       43998    44139     +141     
  Branches     5824     5836      +12     
==========================================
+ Hits        40649    40762     +113     
- Misses       1697     1715      +18     
- Partials     1652     1662      +10     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Copy Markdown
Member

@ullingerc ullingerc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you very much, this is a very useful function.
I have pointed out two minor details, otherwise this is good to go.

Comment thread src/engine/sparqlExpressions/DateExpressions.cpp Outdated
Comment thread test/DateYearDurationTest.cpp Outdated
@sparql-conformance
Copy link
Copy Markdown

Overview

Number of Tests Passed ✅ Intended ✅ Failed ❌ Not tested
548 447 73 28 0

Conformance check passed ✅

No test result changes.

Details: https://qlever.dev/sparql-conformance-ui?cur=4105ab0c10a6564e99831cb4ab3b57ea33f96a54&prev=f54b0a34f8d91af3bbdb7dbc32f115d295e11c31

@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud Bot commented May 4, 2026

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants