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

Add support for processing tabular data from select queries #291

Open
1 of 3 tasks
blcham opened this issue Dec 22, 2024 · 0 comments
Open
1 of 3 tasks

Add support for processing tabular data from select queries #291

blcham opened this issue Dec 22, 2024 · 0 comments

Comments

@blcham
Copy link
Contributor

blcham commented Dec 22, 2024

SPARQL is inefficient to process tabular data respecting an order of that data.


Use cases

Use case 1: inference of has-next-trail-point:

PREFIX : <http://onto.fel.cvut.cz/ontologies/safety-performance-kpis/>

INSERT {
    GRAPH :has-next-trail-point {
    	?timePoint :has-next-trail-point ?nextTimePoint    
    }    
}
WHERE { 
    ?trail a :trail .
    
    ?trail :has-point ?timePoint .
    ?timePoint :date ?date .
    
    ?trail :has-point ?nextTimePoint . 
    ?nextTimePoint :date ?nextDate .
    
    FILTER(?nextDate > ?date) 
    
    FILTER NOT EXISTS {
      ?trail :has-point ?nextTimePointNE . 
      ?nextTimePointNE :date ?nextDateNE .
      
      FILTER(?nextDateNE > ?date)
      FILTER(?nextDate > ?nextDateNE)
    }
}
  • solution:
      1. create ordered tabular data (see SELECT query)
      1. use order to compute final inferences (see not existing predicates with suffix __previous())
PREFIX : <http://onto.fel.cvut.cz/ontologies/safety-performance-kpis/>

CONSTRUCT {
  ?timePoint__previous :has-next-trail-point ?timePoint .
} WHERE {
  SELECT ?trail ?trailId ?timePoint ?date {
    ?trail a :trail .  
    ?trail :id ?trailId .
    
    ?trail :has-point ?timePoint .
    ?timePoint :date ?date .
  } ORDER BY ?trailId ?date 
  
  FILTER(?trial__previous = ?trial)   # note that ?trial__previous does not exist but could be provided from the SELECT query above
}

A/C:

  • implement extension of apply-construct-with-chunked-values
  • implement extension of apply-construct-with-chunked-values-and-scrollable-cursor
  • implement extension of tabular module
blcham added a commit that referenced this issue Dec 26, 2024
…ries

This way the combination of select and construct query might be more efficient in specific cases.
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

No branches or pull requests

1 participant