def get_join_table(self):
"""
Generates a join table, consisting of an entry for each combination of
groups and dates in the from_obj
"""
groups = list(self.groups.values())
intervals = list(set(chain(*self.intervals.values())))
queries = []
for date in self.dates:
columns = groups + [ex.literal_column("'%s'::date" % date).label(
self.output_date_column)]
queries.append(ex.select(columns, from_obj=self.from_obj)
.where(self.where(date, intervals))
.group_by(*groups))
return str.join("\nUNION ALL\n", map(str, queries))
评论列表
文章目录