Return suggestions for an expression, taking account of any partially-typed identifier's parent, which may be a table alias or schema name.
(token_v, stmt)
| 520 | |
| 521 | |
| 522 | def _suggest_expression(token_v, stmt): |
| 523 | """ |
| 524 | Return suggestions for an expression, taking account of any partially-typed |
| 525 | identifier's parent, which may be a table alias or schema name. |
| 526 | """ |
| 527 | parent = stmt.identifier.get_parent_name() if stmt.identifier else [] |
| 528 | tables = stmt.get_tables() |
| 529 | |
| 530 | if parent: |
| 531 | tables = tuple(t for t in tables if identifies(parent, t)) |
| 532 | return ( |
| 533 | Column(table_refs=tables, local_tables=stmt.local_tables), |
| 534 | Table(schema=parent), |
| 535 | View(schema=parent), |
| 536 | Function(schema=parent), |
| 537 | ) |
| 538 | |
| 539 | return ( |
| 540 | Column(table_refs=tables, local_tables=stmt.local_tables, qualifiable=True), |
| 541 | Function(schema=None), |
| 542 | Keyword(token_v.upper()), |
| 543 | ) |
| 544 | |
| 545 | |
| 546 | def identifies(table_id, ref): |
no test coverage detected