Revision 3518
Added by Aaron Marcuse-Kubitza over 12 years ago
lib/sql_gen.py | ||
---|---|---|
1 | 1 |
# SQL code generation |
2 | 2 |
|
3 | 3 |
import copy |
4 |
import itertools |
|
4 | 5 |
import operator |
5 | 6 |
from ordereddict import OrderedDict |
6 | 7 |
import re |
... | ... | |
345 | 346 |
|
346 | 347 |
def has_srcs(col): return is_col(col) and col.srcs |
347 | 348 |
|
348 |
def srcs_str(cols): |
|
349 |
cols = filter(has_srcs, cols) |
|
350 |
return ','.join(('+'.join((s.name for s in c.srcs)) for c in cols)) |
|
349 |
def cross_join_srcs(cols): |
|
350 |
cols = filter(has_srcs, cols) # empty srcs will mess up the cross join |
|
351 |
srcs = [[s.name for s in c.srcs] for c in cols] |
|
352 |
return [Col(','.join(s)) for s in itertools.product(*srcs)] |
|
351 | 353 |
|
352 | 354 |
class NamedCol(Col): |
353 | 355 |
def __init__(self, name, code): |
Also available in: Unified diff
sql_gen.py: Replaced srcs_str() with cross_join_srcs() which more correctly combines the srcs of each column using a Cartesian product. Eventually, the entire tree of srcs will need to be preserved instead of flattened in order to properly attribute errors to a specific column or set of columns.