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

Function parse_order_by

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

Source from the content-addressed store, hash-verified

442
443
444def parse_order_by(toks, start_idx, tables_with_alias, schema, default_tables):
445 idx = start_idx
446 len_ = len(toks)
447 val_units = []
448 order_type = 'asc' # default type is 'asc'
449
450 if idx >= len_ or toks[idx] != 'order':
451 return idx, val_units
452
453 idx += 1
454 assert toks[idx] == 'by'
455 idx += 1
456
457 while idx < len_ and not (toks[idx] in CLAUSE_KEYWORDS or toks[idx] in (")", ";")):
458 idx, val_unit = parse_val_unit(toks, idx, tables_with_alias, schema, default_tables)
459 val_units.append(val_unit)
460 if idx < len_ and toks[idx] in ORDER_OPS:
461 order_type = toks[idx]
462 idx += 1
463 if idx < len_ and toks[idx] == ',':
464 idx += 1 # skip ','
465 else:
466 break
467
468 return idx, (order_type, val_units)
469
470
471def 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