A list of TableExprs.
| 625 | |
| 626 | |
| 627 | class TableExprList(list): |
| 628 | '''A list of TableExprs.''' |
| 629 | |
| 630 | @property |
| 631 | def cols(self): |
| 632 | '''Return a list of all the Columns containd in all the TableExprs.''' |
| 633 | return ValExprList(col for table_expr in self for col in table_expr.cols) |
| 634 | |
| 635 | @property |
| 636 | def joinable_cols_by_type(self): |
| 637 | cols_by_type = defaultdict(ValExprList) |
| 638 | for table_expr in self: |
| 639 | for type_, cols in table_expr.joinable_cols_by_type.items(): |
| 640 | cols_by_type[type_].extend(cols) |
| 641 | return cols_by_type |
| 642 | |
| 643 | @property |
| 644 | def cols_by_type(self): |
| 645 | cols_by_type = defaultdict(ValExprList) |
| 646 | for table_expr in self: |
| 647 | for type_, cols in table_expr.cols_by_type.items(): |
| 648 | cols_by_type[type_].extend(cols) |
| 649 | return cols_by_type |
| 650 | |
| 651 | @property |
| 652 | def col_types(self): |
| 653 | return tuple(self.cols_by_type) |
| 654 | |
| 655 | @property |
| 656 | def collections(self): |
| 657 | result = [] |
| 658 | for table_expr in self: |
| 659 | result.extend(table_expr.collections) |
| 660 | return result |
| 661 | |
| 662 | @property |
| 663 | def by_col_type(self): |
| 664 | '''Return a dict with keys being column types and values being lists of TableExprs |
| 665 | that have at least one Column of that type. |
| 666 | ''' |
| 667 | table_exprs_by_type = defaultdict(TableExprList) |
| 668 | for table_expr in self: |
| 669 | for col_type in table_expr.col_types: |
| 670 | table_exprs_by_type[col_type].append(table_expr) |
| 671 | return table_exprs_by_type |
no outgoing calls