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

Function get_keywords

evaluation/test-suite-sql-eval/evaluation.py:244–282  ·  view source on GitHub ↗
(sql)

Source from the content-addressed store, hash-verified

242
243
244def get_keywords(sql):
245 res = set()
246 if len(sql['where']) > 0:
247 res.add('where')
248 if len(sql['groupBy']) > 0:
249 res.add('group')
250 if len(sql['having']) > 0:
251 res.add('having')
252 if len(sql['orderBy']) > 0:
253 res.add(sql['orderBy'][0])
254 res.add('order')
255 if sql['limit'] is not None:
256 res.add('limit')
257 if sql['except'] is not None:
258 res.add('except')
259 if sql['union'] is not None:
260 res.add('union')
261 if sql['intersect'] is not None:
262 res.add('intersect')
263
264 # or keyword
265 ao = sql['from']['conds'][1::2] + sql['where'][1::2] + sql['having'][1::2]
266 if len([token for token in ao if token == 'or']) > 0:
267 res.add('or')
268
269 cond_units = sql['from']['conds'][::2] + sql['where'][::2] + sql['having'][::2]
270 # not keyword
271 if len([cond_unit for cond_unit in cond_units if cond_unit[0]]) > 0:
272 res.add('not')
273
274 # in keyword
275 if len([cond_unit for cond_unit in cond_units if cond_unit[1] == WHERE_OPS.index('in')]) > 0:
276 res.add('in')
277
278 # like keyword
279 if len([cond_unit for cond_unit in cond_units if cond_unit[1] == WHERE_OPS.index('like')]) > 0:
280 res.add('like')
281
282 return res
283
284
285def eval_keywords(pred, label):

Callers 1

eval_keywordsFunction · 0.70

Calls 1

addMethod · 0.45

Tested by

no test coverage detected