Change ParallelQuerySet to use QueryBuilder - #725
Conversation
There was a problem hiding this comment.
Pull request overview
Refactors ParallelQuerySet constraint handling by centralizing “command extraction” logic into a new QueryBuilder.get_query_cmd helper, reducing duplicated parsing logic and aiming to standardize query-structure interpretation.
Changes:
- Added
QueryBuilder.get_query_cmdto extract the command name from supported query structures. - Updated
ParallelQuerySetto callQueryBuilder.get_query_cmdinstead of manually inspecting dict/list shapes. - Wrapped command extraction in a
try/exceptto raise a constraint-specific error when unsupported structures are encountered.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| aperturedb/Query.py | Adds QueryBuilder.get_query_cmd to encapsulate query command-name extraction. |
| aperturedb/ParallelQuerySet.py | Replaces inline query-structure parsing with QueryBuilder.get_query_cmd during constraint evaluation. |
Comments suppressed due to low confidence (1)
aperturedb/Query.py:284
- The exception message "Cannot extract command from query structure" is hard to act on when debugging. It would be more helpful to include what structures are supported (e.g., single-command dict vs
[constraints_dict, command_dict]) and basic info about the received value (type/length/keys) without dumping large payloads.
elif isinstance(query, list) and isinstance(query[0], dict) \
and all(map(lambda k: k in known_constraint_keywords, query[0].keys())) \
and isinstance(query[1], dict):
return list(query[1].keys())[0]
else:
raise Exception("Cannot extract command from query structure")
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Refine get_query_cmd to validate input structure and raise ValueError for invalid shapes - Chain exceptions when get_query_cmd fails in ParallelQuerySet - Fix typo in exception message 'Contraints' -> 'Constraints' - Add unit tests for QueryBuilder.get_query_cmd in test_Datawizard.py
|
All PR review comments have been addressed in commit |
|
All actionable review comments have been addressed in commit a9522cc. |
Addressed the reviewer's feedback to include the type, length, and keys of the received payload instead of dumping the full payload when parsing fails.
|
Done. Refined the |
Summary
Extracted the command resolution logic in
ParallelQuerySetintoQueryBuilder.get_query_cmd. This refactoring simplifies the codebase and leveragesQueryBuildereffectively.Verification
get_query_cmdtoQueryBuilderinaperturedb/Query.py.ParallelQuerySet.py.Fixes #265