MCPcopy Create free account
hub / github.com/FlyingFeather/DEA-SQL / parse_col

Function parse_col

hardness_eval.py:196–217  ·  view source on GitHub ↗

:returns next idx, column id

(toks, start_idx, tables_with_alias, schema, default_tables=None)

Source from the content-addressed store, hash-verified

194
195
196def 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
220def parse_col_unit(toks, start_idx, tables_with_alias, schema, default_tables=None):

Callers 1

parse_col_unitFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected