rdflib icon indicating copy to clipboard operation
rdflib copied to clipboard

Fix Issue #790. Adding QueryBuilder.

Open anubhavj99 opened this issue 4 years ago • 7 comments

Fixes #790. Developing a query-builder taking guidance from the examples in the issue.

Functions added:

  1. SELECT
  2. WHERE
  3. OPTIONAL
  4. UNION
  5. ORDER BY, GROUP BY
  6. AGGREGATES - (functions)
  7. FILTER - (functions), (operations)
  8. LIMIT, OFFSET
  9. FOR_GRAPH - setting graph for a query using
  10. MOVE, ADD
  11. INSERT, DELETE
  12. NESTED QUERY (example)

anubhavj99 avatar May 28 '20 19:05 anubhavj99

Coverage Status

Coverage increased (+0.4%) to 76.161% when pulling 3e429bd167456e1b50a831c1a78b016581aab699 on anubhavj99:Issue790 into 037ea51e5f4863a7f98ff59972fcd34d39a7ed97 on RDFLib:master.

coveralls avatar May 28 '20 19:05 coveralls

What's the status? Can we get it merged?

magdasalatka avatar Oct 16 '20 14:10 magdasalatka

Hi @anubhavj99 , @Arshdeep25 & @magdasalatka apoligies for missing this PR, I don't know why we haven't addressed it yet. I'm going to put it to multiple review now.

nicholascar avatar Dec 17 '20 19:12 nicholascar

@joernhees I think you might like to review this since you were part of the discussion on Issue #790 that it claims to fix.

nicholascar avatar Dec 17 '20 19:12 nicholascar

As commented in the issue (https://github.com/RDFLib/rdflib/issues/790#issuecomment-687613468) I would prefer to have separate QueryBuilders for different query types, e.g.

query = query_builder.Select().where(...)

instead of:

query = query_builder.QueryBuilder.Select().where(...)

As it allows for simplifications in the code and also avoids the question how to handle api usage like:

query = query_builder.QueryBuilder().SELECT(...).INSERT(...)

FlorianLudwig avatar Dec 19 '20 07:12 FlorianLudwig

I can see the appeal of the current naming SELECT().WHERE() instead of the pep8 conform .where() but I would like to ask: is that appeal big enough to not follow pep8 as requested in the dev-guide?

With every exception we get further away from doing more linting inside the CI

FlorianLudwig avatar Dec 19 '20 08:12 FlorianLudwig

I'd like to emphasize that this is a very valuable contribution. It helped me a lot in one of my recent projects. Thanks @anubhavj99, @Arshdeep25 and @saksham16085!

Now, how can we get this into RDFLib?

I'd be happy to contribute some additions from my (not yet public) project, such as

  • group graph pattern
  • UNION
  • OPTIONAL with arbitrary graph pattern
  • VALUES
  • GROUP_CONCAT
  • FILTER (NOT) EXISTS
  • execution of xpath functions

flange-ipb avatar May 22 '24 12:05 flange-ipb