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

Function parse_value

hardness_eval.py:299–330  ·  view source on GitHub ↗
(toks, start_idx, tables_with_alias, schema, default_tables=None)

Source from the content-addressed store, hash-verified

297
298
299def parse_value(toks, start_idx, tables_with_alias, schema, default_tables=None):
300 idx = start_idx
301 len_ = len(toks)
302
303 isBlock = False
304 if toks[idx] == '(':
305 isBlock = True
306 idx += 1
307
308 if toks[idx] == 'select':
309 idx, val = parse_sql(toks, idx, tables_with_alias, schema)
310 elif "\"" in toks[idx]: # token is a string value
311 val = toks[idx]
312 idx += 1
313 else:
314 try:
315 val = float(toks[idx])
316 idx += 1
317 except:
318 end_idx = idx
319 while end_idx < len_ and toks[end_idx] != ',' and toks[end_idx] != ')'\
320 and toks[end_idx] != 'and' and toks[end_idx] not in CLAUSE_KEYWORDS and toks[end_idx] not in JOIN_KEYWORDS:
321 end_idx += 1
322
323 idx, val = parse_col_unit(toks[start_idx: end_idx], 0, tables_with_alias, schema, default_tables)
324 idx = end_idx
325
326 if isBlock:
327 assert toks[idx] == ')'
328 idx += 1
329
330 return idx, val
331
332
333def 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