-
Notifications
You must be signed in to change notification settings - Fork 469
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 _execute_select and filter in the Query class. #2363
Conversation
d9acb49
to
e1540bf
Compare
d1d61bc
to
8dcae9d
Compare
superduper/backends/base/query.py
Outdated
:param args: The arguments to filter by. | ||
:param kwargs: Additional keyword arguments. | ||
""" | ||
query = self if self.parts else self.select() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make sure the flavour of single filter query should be the select
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This function will conflict with the ibis
implementation of .filter
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
self.select() implies select * from table
right?
I
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We will find all the columns and fill in to the args.
And I removed this filter method in the base query class
return self._get_chain_native_query(parent, self.parts, method) | ||
|
||
def _get_chain_native_query(self, parent, parts, method='encode'): | ||
try: | ||
for part in parts: | ||
if isinstance(part, str): | ||
parent = getattr(parent, part) | ||
continue | ||
args = self._encode_or_unpack_args( | ||
part[1], self.db, method=method, parent=parent | ||
) | ||
kwargs = self._encode_or_unpack_args( | ||
part[2], self.db, method=method, parent=parent | ||
) | ||
parent = getattr(parent, part[0])(*args, **kwargs) | ||
except Exception as e: | ||
logging.error(f'Error in executing query, parts: {parts}') | ||
raise e | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Separating this method allows for easier future expansion of the query, enabling the query to flexibly construct the parts list without being tied to the expression.
In the future, all Query classes can be merged into one class, with Query only recording the expression and being independent the type of the database.
We can use Databackend to execute the Query
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, yes this is a possible approach.
superduper/backends/ibis/query.py
Outdated
@@ -437,26 +480,3 @@ def __call__(self, *args, **kwargs): | |||
table = self.db.databackend.get_table_or_collection(self.table) | |||
args = tuple(table.columns) | |||
return super().__call__(*args, **kwargs) | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove unuse codes
class MongoOutputs(MongoQuery): | ||
"""A query class for MongoDB outputs. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use _execute_outputs to replace this class.
8dcae9d
to
0a46a52
Compare
if not isinstance(item, slice): | ||
return super().__getitem__(item) | ||
raise TypeError('Query index must be a string or a slice') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The parent class does not define the getitem method.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes
0a46a52
to
caa1e57
Compare
fb2544b
to
95900fa
Compare
95900fa
to
07ab9d1
Compare
superduper/backends/mongodb/query.py
Outdated
|
||
Use aggregate to implement the outputs query | ||
""" | ||
def _get_filter_confitions(self): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
small typo
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
07ab9d1
to
0275d6b
Compare
0275d6b
to
e3ca89e
Compare
Description
Related Issues
Checklist
make unit_testing
andmake integration-testing
successfully?Additional Notes or Comments