FlowKit
FlowKit copied to clipboard
Query.query_id can iterate over results of dependencies
If you create a query subclass which holds a dict of query objects as an attribute, then calling query_id will cause the id to be generated by iterating through the results of the dependent queries.
e.g.
class UhOh(Query):
def __init__(self, a_dict):
self.oh_dear = a_dict
super().__init__()
@property
def column_names(self):
return ["badness"]
def _make_query(self):
return next(self.oh_dear.values()).get_query()
And as a companion issue - queries in a dict won't get picked up by dependencies either.
Nice suggestion from @jc-harrison that an alternative approach to query ids where we hash on the sql generated 'as if' all dependent queries were cached would resolve this, as well as #4489. Should also facilitate #814, but I would like it to not make #390 worse.