:returns next idx, column id
(toks, start_idx, tables_with_alias, schema, default_tables=None)
| 165 | |
| 166 | |
| 167 | def parse_col(toks, start_idx, tables_with_alias, schema, default_tables=None): |
| 168 | """ |
| 169 | :returns next idx, column id |
| 170 | """ |
| 171 | tok = toks[start_idx] |
| 172 | if tok == "*": |
| 173 | return start_idx + 1, schema.idMap[tok] |
| 174 | |
| 175 | if '.' in tok: # if token is a composite |
| 176 | alias, col = tok.split('.') |
| 177 | key = tables_with_alias[alias] + "." + col |
| 178 | return start_idx+1, schema.idMap[key] |
| 179 | |
| 180 | assert default_tables is not None and len(default_tables) > 0, "Default tables should not be None or empty" |
| 181 | |
| 182 | for alias in default_tables: |
| 183 | table = tables_with_alias[alias] |
| 184 | if tok in schema.schema[table]: |
| 185 | key = table + "." + tok |
| 186 | return start_idx+1, schema.idMap[key] |
| 187 | |
| 188 | assert False, "Error col: {}".format(tok) |
| 189 | |
| 190 | |
| 191 | def parse_col_unit(toks, start_idx, tables_with_alias, schema, default_tables=None): |