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

Function parse_col

evaluation/test-suite-sql-eval/process_sql.py:167–188  ·  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

165
166
167def 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
191def 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