(tok, pos0)
| 94 | |
| 95 | |
| 96 | def get_cte_from_token(tok, pos0): |
| 97 | cte_name = tok.get_real_name() |
| 98 | if not cte_name: |
| 99 | return None |
| 100 | |
| 101 | # Find the start position of the opening parens enclosing the cte body |
| 102 | idx, parens = tok.token_next_by(Parenthesis) |
| 103 | if not parens: |
| 104 | return None |
| 105 | |
| 106 | start_pos = pos0 + token_start_pos(tok.tokens, idx) |
| 107 | cte_len = len(str(parens)) # includes parens |
| 108 | stop_pos = start_pos + cte_len |
| 109 | |
| 110 | column_names = extract_column_names(parens) |
| 111 | |
| 112 | return TableExpression(cte_name, column_names, start_pos, stop_pos) |
| 113 | |
| 114 | |
| 115 | def extract_column_names(parsed): |
no test coverage detected