select d, e from dfs.`%1$s` where _id in (
  select _id
    from (select _id, flatten(f1.t) as f2
      from (select _id, flatten(foo) as f1 from dfs.`%1$s`)) as t1
    where t1.f2.a = 42 and t1.f2.b = 17
    )
