A representation of any possible expr than would be valid in SELECT [, ...] FROM ... Each SelectItem contains a ValExpr which will either be a instance of a DataType (representing a constant), a Column, or a Func. Ex: "SELECT int_col + smallint_col FROM
| 352 | |
| 353 | |
| 354 | class SelectItem(object): |
| 355 | '''A representation of any possible expr than would be valid in |
| 356 | |
| 357 | SELECT <SelectItem>[, <SelectItem>...] FROM ... |
| 358 | |
| 359 | Each SelectItem contains a ValExpr which will either be a instance of a |
| 360 | DataType (representing a constant), a Column, or a Func. |
| 361 | |
| 362 | Ex: "SELECT int_col + smallint_col FROM alltypes" would have a val_expr of |
| 363 | Plus(Column(<alltypes.int_col>), Column(<alltypes.smallint_col>)). |
| 364 | |
| 365 | ''' |
| 366 | |
| 367 | def __init__(self, val_expr, alias=None): |
| 368 | self.val_expr = val_expr |
| 369 | self.alias = alias |
| 370 | |
| 371 | @property |
| 372 | def name(self): |
| 373 | if self.alias: |
| 374 | return self.alias |
| 375 | if self.val_expr.is_col: |
| 376 | return self.val_expr.name |
| 377 | raise Exception('Could not determine name') |
| 378 | |
| 379 | @property |
| 380 | def type(self): |
| 381 | '''Returns the DataType of this item.''' |
| 382 | return self.val_expr.type |
| 383 | |
| 384 | @property |
| 385 | def base_type(self): |
| 386 | '''Returns the base DataType of this item.''' |
| 387 | return self.val_expr.base_type |
| 388 | |
| 389 | @property |
| 390 | def is_basic(self): |
| 391 | '''Evaluates to True if this item is neither an aggregate nor an analytic expression. |
| 392 | ''' |
| 393 | return not self.is_agg and not self.is_analytic |
| 394 | |
| 395 | @property |
| 396 | def is_agg(self): |
| 397 | '''Evaluates to True if this item contains an aggregate expression and does not |
| 398 | contain an analytic expression. If an expression contains both an aggregate |
| 399 | and an analytic, it is considered an analytic expression. |
| 400 | ''' |
| 401 | return not self.is_analytic and self.val_expr.contains_agg |
| 402 | |
| 403 | @property |
| 404 | def is_analytic(self): |
| 405 | '''Evaluates to True if this item contains an analytic expression.''' |
| 406 | return self.val_expr.contains_analytic |
| 407 | |
| 408 | def __deepcopy__(self, memo): |
| 409 | other = SelectItem(deepcopy(self.val_expr, memo)) |
| 410 | other.alias = self.alias |
| 411 | return other |
no outgoing calls
no test coverage detected