This encapsulates the SELECT part of a query. It is convenient to separate non-agg items from agg items so that it is simple to know if the query is an agg query or not.
| 178 | |
| 179 | |
| 180 | class SelectClause(object): |
| 181 | '''This encapsulates the SELECT part of a query. It is convenient to separate |
| 182 | non-agg items from agg items so that it is simple to know if the query |
| 183 | is an agg query or not. |
| 184 | ''' |
| 185 | |
| 186 | def __init__(self, select_items): |
| 187 | self.items = select_items |
| 188 | self.distinct = False |
| 189 | |
| 190 | @property |
| 191 | def basic_items(self): |
| 192 | '''Returns a list of SelectItems that are also basic items. Deletions from |
| 193 | this list will be propagated but additions will not be. |
| 194 | ''' |
| 195 | return SelectItemSubList(self.items, lambda item: item.is_basic) |
| 196 | |
| 197 | @property |
| 198 | def agg_items(self): |
| 199 | '''Returns a list of SelectItems that are also aggregate items. Deletions from |
| 200 | this list will be propagated but additions will not be. |
| 201 | ''' |
| 202 | return SelectItemSubList(self.items, lambda item: item.is_agg) |
| 203 | |
| 204 | @property |
| 205 | def analytic_items(self): |
| 206 | '''Returns a list of SelectItems that are also analytic items. Deletions from |
| 207 | this list will be propagated but additions will not be. |
| 208 | ''' |
| 209 | return SelectItemSubList(self.items, lambda item: item.is_analytic) |
| 210 | |
| 211 | @property |
| 212 | def contains_approximate_types(self): |
| 213 | '''Returns true if there is a select item that is approximate (such as Float).''' |
| 214 | return any(item.type.is_approximate() for item in self.items) |
| 215 | |
| 216 | def __deepcopy__(self, memo): |
| 217 | other = SelectClause([deepcopy(item, memo) for item in self.items]) |
| 218 | other.distinct = self.distinct |
| 219 | return other |
| 220 | |
| 221 | |
| 222 | # This is used in the query simplifier (not yet checked in) to simplify reduction |
no outgoing calls
no test coverage detected