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

Function parse_value

evaluation/test-suite-sql-eval/process_sql.py:270–301  ·  view source on GitHub ↗
(toks, start_idx, tables_with_alias, schema, default_tables=None)

Source from the content-addressed store, hash-verified

268
269
270def parse_value(toks, start_idx, tables_with_alias, schema, default_tables=None):
271 idx = start_idx
272 len_ = len(toks)
273
274 isBlock = False
275 if toks[idx] == '(':
276 isBlock = True
277 idx += 1
278
279 if toks[idx] == 'select':
280 idx, val = parse_sql(toks, idx, tables_with_alias, schema)
281 elif "\"" in toks[idx]: # token is a string value
282 val = toks[idx]
283 idx += 1
284 else:
285 try:
286 val = float(toks[idx])
287 idx += 1
288 except:
289 end_idx = idx
290 while end_idx < len_ and toks[end_idx] != ',' and toks[end_idx] != ')'\
291 and toks[end_idx] != 'and' and toks[end_idx] not in CLAUSE_KEYWORDS and toks[end_idx] not in JOIN_KEYWORDS:
292 end_idx += 1
293
294 idx, val = parse_col_unit(toks[start_idx: end_idx], 0, tables_with_alias, schema, default_tables)
295 idx = end_idx
296
297 if isBlock:
298 assert toks[idx] == ')'
299 idx += 1
300
301 return idx, val
302
303
304def parse_condition(toks, start_idx, tables_with_alias, schema, default_tables=None):

Callers 1

parse_conditionFunction · 0.70

Calls 2

parse_sqlFunction · 0.70
parse_col_unitFunction · 0.70

Tested by

no test coverage detected