Skip to content

Refactors Query Language for Thicket#72

Merged
slabasan merged 11 commits intollnl:developfrom
TauferLab:ql_rework_for_thicket
Feb 27, 2023
Merged

Refactors Query Language for Thicket#72
slabasan merged 11 commits intollnl:developfrom
TauferLab:ql_rework_for_thicket

Conversation

@ilumsden
Copy link
Collaborator

@ilumsden ilumsden commented Dec 5, 2022

Summary

This PR refactors the Query Language (QL) to prepare it for use in Thicket, improve its overall extensibility, and make its terminology more in line with that of the QL paper.

First and foremost, the QL is no longer contained within a single file. Now, all code for the QL is contained in the new query directory. This directory contains the following files:

  • __init__.py: contains re-exports for everything in the QL so it can all be imported with from hatchet.query import ... (same as before)
  • engine.py: contains a class containing the algorithm for applying queries to GraphFrames
  • errors.py: contains any errors the QL may raise
  • query.py: contains the class representing the base QL syntax and compound queries (i.e., classes for operations like "and," "or," "xor," and "not"
  • object_dialect.py: contains the class representing the Object-based dialect
  • string_dialect.py: contains the class representing the String-based dialect
  • compat.py: contains various classes that ensure (deprecated) backwards compatibility with earlier versions of Hatchet

In this PR, queries are represented by one of 3 classes:

  • Query: represents the base syntax for the QL
  • StringQuery: represents the String-based dialect. This class extends Query and implements the conversion from String-based dialect to base syntax
  • ObjectQuery: represents the Object-based dialect. This class extends Query and implements the conversion from Object-based dialect to base syntax

Additionally, as before, there are classes to allow queries to combined via set operations. All of these classes extend the CompoundQuery class. These classes are:

  • ConjunctionQuery: combines the results of a set of queries through set conjunction (equivalent to logical AND)
  • DisjunctionQuery: combines the results of a set of queries through set disjunction (equivalent to logical OR)
  • ExclusiveDisjunctionQuery: combines the results of a set of queries through exclusive set disjunction (equivalent to logical XOR)
  • NegationQuery: inverts the results of a query (equivalent to logical NOT)

As before, these "compound queries" can easily be created from the 3 main query classes using the &, |, ^, and ~ operators.

New in this PR, the algorithm for applying queries to GraphFrames has been separated from query composition. The algorithm is now contained within the new QueryEngine class.

Finally, all the old QL classes and functions have been reimplemented to be thin wrappers around the classes mentioned above. As a result, this PR should ensure full backwards compatibility with old QL code. However, if this PR is merged, all "old-style" query code should be considered deprecated.

What's left to do

All the implementation has been completed for this PR. Additionally, all existing unit tests that do not involve query composition are passing, which validates my claims about backwards compatibility. All that's left to do before this PR can be merged is:

  • Move the existing QL unit tests into a new file (e.g., query_compat.py)
  • Create a new QL unit tests file for "new-style" queries
  • Move query construction unit tests into the new file and refactor as needed
  • Add tests (based on the old ones) to confirm that new-style queries are working as intended

@ilumsden ilumsden self-assigned this Dec 5, 2022
@ilumsden ilumsden requested a review from slabasan December 5, 2022 21:59
@ilumsden ilumsden added area-query-lang Issues and PRs related to Hatchet's query language priority-normal Normal priority issues and PRs status-work-in-progress PR is currently being worked on type-feature Requests for new features or PRs which implement new features type-internal-cleanup PR or issues related to the structure of the codebase, directories and refactors labels Dec 5, 2022
@ilumsden ilumsden force-pushed the ql_rework_for_thicket branch from 8d58521 to 1f8379b Compare December 21, 2022 15:04
@ilumsden
Copy link
Collaborator Author

This PR is now ready for review. However, it should not be merged until after #73 so that we can make sure it passes CI.

@ilumsden ilumsden force-pushed the ql_rework_for_thicket branch 6 times, most recently from eb05fdd to 1b2585e Compare January 20, 2023 20:47
@ilumsden ilumsden marked this pull request as ready for review January 20, 2023 21:21
@ilumsden ilumsden added status-ready-for-review This PR is ready to be reviewed by assigned reviewers and removed status-work-in-progress PR is currently being worked on labels Jan 20, 2023
Copy link
Collaborator

@slabasan slabasan left a comment

Choose a reason for hiding this comment

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

Code looks good, but please resolve branch conflicts and update copyright year in the header to 2023.

@ilumsden ilumsden force-pushed the ql_rework_for_thicket branch from 1b2585e to 0fa6bc5 Compare February 22, 2023 18:18
@ilumsden ilumsden force-pushed the ql_rework_for_thicket branch from 1227dd7 to 831a4df Compare February 23, 2023 16:49
@ilumsden
Copy link
Collaborator Author

@slabasan I've updated the copyright year, and (as requested by @pearce8) I've added some DeprecationWarnings when using old-style queries.

@ilumsden ilumsden requested a review from slabasan February 23, 2023 16:52
@slabasan slabasan merged commit 7431adf into llnl:develop Feb 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-query-lang Issues and PRs related to Hatchet's query language priority-normal Normal priority issues and PRs status-ready-for-review This PR is ready to be reviewed by assigned reviewers type-feature Requests for new features or PRs which implement new features type-internal-cleanup PR or issues related to the structure of the codebase, directories and refactors

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants