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

Function parse_col_unit

hardness_eval.py:220–255  ·  view source on GitHub ↗

:returns next idx, (agg_op id, col_id)

(toks, start_idx, tables_with_alias, schema, default_tables=None)

Source from the content-addressed store, hash-verified

218
219
220def parse_col_unit(toks, start_idx, tables_with_alias, schema, default_tables=None):
221 """
222 :returns next idx, (agg_op id, col_id)
223 """
224 idx = start_idx
225 len_ = len(toks)
226 isBlock = False
227 isDistinct = False
228 if toks[idx] == '(':
229 isBlock = True
230 idx += 1
231
232 if toks[idx] in AGG_OPS:
233 agg_id = AGG_OPS.index(toks[idx])
234 idx += 1
235 assert idx < len_ and toks[idx] == '('
236 idx += 1
237 if toks[idx] == "distinct":
238 idx += 1
239 isDistinct = True
240 idx, col_id = parse_col(toks, idx, tables_with_alias, schema, default_tables)
241 assert idx < len_ and toks[idx] == ')'
242 idx += 1
243 return idx, (agg_id, col_id, isDistinct)
244
245 if toks[idx] == "distinct":
246 idx += 1
247 isDistinct = True
248 agg_id = AGG_OPS.index("none")
249 idx, col_id = parse_col(toks, idx, tables_with_alias, schema, default_tables)
250
251 if isBlock:
252 assert toks[idx] == ')'
253 idx += 1 # skip ')'
254
255 return idx, (agg_id, col_id, isDistinct)
256
257
258def parse_val_unit(toks, start_idx, tables_with_alias, schema, default_tables=None):

Callers 3

parse_val_unitFunction · 0.70
parse_valueFunction · 0.70
parse_group_byFunction · 0.70

Calls 1

parse_colFunction · 0.70

Tested by

no test coverage detected