MCPcopy Create free account
hub / github.com/awslabs/gap-text2sql / parse_cond

Method parse_cond

rat-sql-gap/seq2struct/grammars/spider.py:210–234  ·  view source on GitHub ↗
(self, cond, optional=False)

Source from the content-addressed store, hash-verified

208 raise ValueError(table_type)
209
210 def parse_cond(self, cond, optional=False):
211 if optional and not cond:
212 return None
213
214 if len(cond) > 1:
215 return {
216 '_type': self.LOGIC_OPERATORS_F[cond[1]],
217 'left': self.parse_cond(cond[:1]),
218 'right': self.parse_cond(cond[2:]),
219 }
220
221 (not_op, op_id, val_unit, val1, val2), = cond
222 result = {
223 '_type': self.COND_TYPES_F[op_id],
224 'val_unit': self.parse_val_unit(val_unit),
225 'val1': self.parse_val(val1),
226 }
227 if op_id == 1: # between
228 result['val2'] = self.parse_val(val2)
229 if not_op:
230 result = {
231 '_type': 'Not',
232 'c': result,
233 }
234 return result
235
236 def parse_sql(self, sql, optional=False):
237 if optional and sql is None:

Callers 2

parse_sqlMethod · 0.95
parse_fromMethod · 0.95

Calls 2

parse_val_unitMethod · 0.95
parse_valMethod · 0.95

Tested by

no test coverage detected