:returns next idx, column id
(toks, start_idx, tables_with_alias, schema, default_tables=None)
| 194 | |
| 195 | |
| 196 | def parse_col(toks, start_idx, tables_with_alias, schema, default_tables=None): |
| 197 | """ |
| 198 | :returns next idx, column id |
| 199 | """ |
| 200 | tok = toks[start_idx] |
| 201 | if tok == "*": |
| 202 | return start_idx + 1, schema.idMap[tok] |
| 203 | |
| 204 | if '.' in tok: # if token is a composite |
| 205 | alias, col = tok.split('.') |
| 206 | key = tables_with_alias[alias] + "." + col |
| 207 | return start_idx + 1, schema.idMap[key] |
| 208 | |
| 209 | assert default_tables is not None and len(default_tables) > 0, "Default tables should not be None or empty" |
| 210 | |
| 211 | for alias in default_tables: |
| 212 | table = tables_with_alias[alias] |
| 213 | if tok in schema.schema[table]: |
| 214 | key = table + "." + tok |
| 215 | return start_idx + 1, schema.idMap[key] |
| 216 | |
| 217 | assert False, "Error col: {}".format(tok) |
| 218 | |
| 219 | |
| 220 | def parse_col_unit(toks, start_idx, tables_with_alias, schema, default_tables=None): |