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