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

Function parse_col_unit

evaluation/test-suite-sql-eval/process_sql.py:191–226  ·  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

189
190
191def parse_col_unit(toks, start_idx, tables_with_alias, schema, default_tables=None):
192 """
193 :returns next idx, (agg_op id, col_id)
194 """
195 idx = start_idx
196 len_ = len(toks)
197 isBlock = False
198 isDistinct = False
199 if toks[idx] == '(':
200 isBlock = True
201 idx += 1
202
203 if toks[idx] in AGG_OPS:
204 agg_id = AGG_OPS.index(toks[idx])
205 idx += 1
206 assert idx < len_ and toks[idx] == '('
207 idx += 1
208 if toks[idx] == "distinct":
209 idx += 1
210 isDistinct = True
211 idx, col_id = parse_col(toks, idx, tables_with_alias, schema, default_tables)
212 assert idx < len_ and toks[idx] == ')'
213 idx += 1
214 return idx, (agg_id, col_id, isDistinct)
215
216 if toks[idx] == "distinct":
217 idx += 1
218 isDistinct = True
219 agg_id = AGG_OPS.index("none")
220 idx, col_id = parse_col(toks, idx, tables_with_alias, schema, default_tables)
221
222 if isBlock:
223 assert toks[idx] == ')'
224 idx += 1 # skip ')'
225
226 return idx, (agg_id, col_id, isDistinct)
227
228
229def 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