MCPcopy Create free account
hub / github.com/PaddlePaddle/Research / parse_cols

Function parse_cols

NLP/Text2SQL-BASELINE/tools/evaluation/utils.py:232–258  ·  view source on GitHub ↗

:returns next idx, (agg, col)

(toks, start_idx)

Source from the content-addressed store, hash-verified

230 assert query[0] == 'select'
231
232 def parse_cols(toks, start_idx):
233 """
234 :returns next idx, (agg, col)
235 """
236 if 'from' in toks:
237 toks = toks[:toks.index('from')]
238 idx = start_idx
239 len_ = len(toks)
240 outs = []
241 while idx < len_:
242 if toks[idx] in AGG_OPS:
243 agg_id = sql_agg_dict[toks[idx]]
244 idx += 1
245 assert idx < len_ and toks[idx] == '(', toks[idx]
246 idx += 1
247 agg, col = toks[start_idx], toks[idx]
248 idx += 1
249 assert idx < len_ and toks[idx] == ')', toks[idx] +''.join(toks)
250 idx += 1
251 outs.append((agg, col))
252 elif toks[idx] == ',':
253 idx += 1
254 else:
255 agg, col = '', toks[idx]
256 idx += 1
257 outs.append(('', col))
258 return outs
259
260 def _format_col(old_col):
261 """format"""

Callers 1

query2sqlFunction · 0.85

Calls 2

indexMethod · 0.80
appendMethod · 0.45

Tested by

no test coverage detected