Merged
Conversation
Add a programmatic query builder as an alternative to writing raw SPARQL strings. Supports SELECT, ASK, CONSTRUCT, and DESCRIBE queries with fluent method chaining. Accepts both string terms and typed objects (IRI, Variable, Literal, Namespace-produced IRIs). Features: - GraphPattern class for composable WHERE blocks - WHERE, FILTER, OPTIONAL, UNION, BIND, VALUES, sub-query clauses - SELECT modifiers: DISTINCT, ORDER BY, GROUP BY, HAVING, LIMIT, OFFSET - Prefix handling via string pairs or Namespace objects - Light validation in build() for structural correctness - copy() for safe builder reuse
There was a problem hiding this comment.
Important
Looks good to me! 👍
Reviewed everything up to 9ad0846 in 14 seconds. Click for details.
- Reviewed
1005lines of code in6files - Skipped
0files when reviewing. - Skipped posting
0draft comments. View those below. - Modify your settings and rules to customize what types of comments Ellipsis leaves. And don't forget to react with 👍 or 👎 to teach Ellipsis.
Workflow ID: wflow_0Xh8HTTHB8oNNlLD
You can customize by changing your verbosity settings, reacting with 👍 or 👎, replying to comments, or adding code review rules.
Replace raw SPARQL strings with fluent query builder calls in all example files (query.py, query_and_print.py, complete_workflow.py). Add a Query Builder section to the main README with usage examples.
Consolidate _WhereClauseMixin and _PrefixMixin into a single _QueryBase that handles shared init, prefix rendering, WHERE delegation, copy(), and __str__(). Remove unused re import and _PREFIXED_NAME_RE. Extract _ensure_var helper in GraphPattern to deduplicate var normalization.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
rdf4j_python.query) supporting SELECT, ASK, CONSTRUCT, and DESCRIBE queries with method chaining"?var","a","ex:Person") and typed objects (IRI,Variable,Literal,Namespace-produced IRIs) as termsGraphPatternfor composable WHERE blocks with FILTER, OPTIONAL, UNION, BIND, VALUES, and sub-query support, plus SELECT modifiers (DISTINCT, ORDER BY, GROUP BY, HAVING, LIMIT, OFFSET)Test plan
serialize_term()correctly handles all term types (IRI, Variable, Literal with lang/datatype, BlankNode, strings)__str__()matchesbuild(),copy()produces independent builders🤖 Generated with Claude Code
Important
Adds a fluent SPARQL query builder to
rdf4j_pythonwith support for various query types, clauses, and method chaining, along with comprehensive unit tests.rdf4j_python.queryfor SELECT, ASK, CONSTRUCT, DESCRIBE queries with method chaining.GraphPatternfor composable WHERE blocks with FILTER, OPTIONAL, UNION, BIND, VALUES, sub-query support, and SELECT modifiers (DISTINCT, ORDER BY, GROUP BY, HAVING, LIMIT, OFFSET).select(),ask(),construct(),describe()inquery/__init__.pycreate respective query builders.serialize_term()inquery/_term.pyhandles term serialization for SPARQL.SelectQuery,AskQuery,ConstructQuery,DescribeQueryinquery/_builder.pyfor building respective queries.GraphPatterninquery/_pattern.pyfor WHERE clause composition.test_query_builder.pycovering all query types, clauses, and term serialization.This description was created by
for 9ad0846. You can customize this summary. It will automatically update as commits are pushed.