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

Function get_keywords

single_eval.py:245–283  ·  view source on GitHub ↗
(sql)

Source from the content-addressed store, hash-verified

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

Callers 1

eval_keywordsFunction · 0.70

Calls 1

addMethod · 0.45

Tested by

no test coverage detected