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

Function parse_order_by

hardness_eval.py:473–497  ·  view source on GitHub ↗
(toks, start_idx, tables_with_alias, schema, default_tables)

Source from the content-addressed store, hash-verified

471
472
473def parse_order_by(toks, start_idx, tables_with_alias, schema, default_tables):
474 idx = start_idx
475 len_ = len(toks)
476 val_units = []
477 order_type = 'asc' # default type is 'asc'
478
479 if idx >= len_ or toks[idx] != 'order':
480 return idx, val_units
481
482 idx += 1
483 assert toks[idx] == 'by'
484 idx += 1
485
486 while idx < len_ and not (toks[idx] in CLAUSE_KEYWORDS or toks[idx] in (")", ";")):
487 idx, val_unit = parse_val_unit(toks, idx, tables_with_alias, schema, default_tables)
488 val_units.append(val_unit)
489 if idx < len_ and toks[idx] in ORDER_OPS:
490 order_type = toks[idx]
491 idx += 1
492 if idx < len_ and toks[idx] == ',':
493 idx += 1 # skip ','
494 else:
495 break
496
497 return idx, (order_type, val_units)
498
499
500def parse_having(toks, start_idx, tables_with_alias, schema, default_tables):

Callers 1

parse_sqlFunction · 0.70

Calls 1

parse_val_unitFunction · 0.70

Tested by

no test coverage detected