FlowKit icon indicating copy to clipboard operation
FlowKit copied to clipboard

Query.query_id can iterate over results of dependencies

Open greenape opened this issue 4 years ago • 2 comments

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()

greenape avatar Nov 09 '21 16:11 greenape

And as a companion issue - queries in a dict won't get picked up by dependencies either.

greenape avatar Nov 09 '21 16:11 greenape

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.

greenape avatar Nov 16 '21 10:11 greenape