| 275 | |
| 276 | |
| 277 | def _emit_relation_like(ctx: SuggestContext) -> list[Suggestion]: |
| 278 | schema = _parent_name(ctx) |
| 279 | is_join = bool(ctx.token_value and ctx.token_value.endswith('join') and isinstance(ctx.token, Token) and ctx.token.is_keyword) |
| 280 | |
| 281 | # Suggest tables from either the currently-selected schema or the |
| 282 | # public schema if no schema has been specified |
| 283 | table_suggestion: Suggestion = {'type': 'table', 'schema': schema} |
| 284 | if is_join: |
| 285 | table_suggestion['join'] = True |
| 286 | suggest: list[Suggestion] = [table_suggestion] |
| 287 | |
| 288 | if not schema: |
| 289 | # Suggest schemas |
| 290 | suggest.append({'type': 'database'}) |
| 291 | |
| 292 | # Only tables can be TRUNCATED, otherwise suggest views |
| 293 | if ctx.token_value != 'truncate': |
| 294 | suggest.append({'type': 'view', 'schema': schema}) |
| 295 | |
| 296 | return suggest |
| 297 | |
| 298 | |
| 299 | def _emit_relation_name(ctx: SuggestContext) -> list[Suggestion]: |