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

Method parse_val

rat-sql-gap/seq2struct/grammars/spider.py:146–172  ·  view source on GitHub ↗
(self, val)

Source from the content-addressed store, hash-verified

144 #
145
146 def parse_val(self, val):
147 if isinstance(val, str):
148 if not self.include_literals:
149 return {'_type': 'Terminal'}
150 return {
151 '_type': 'String',
152 's': val,
153 }
154 elif isinstance(val, list):
155 return {
156 '_type': 'ColUnit',
157 'c': self.parse_col_unit(val),
158 }
159 elif isinstance(val, float):
160 if not self.include_literals:
161 return {'_type': 'Terminal'}
162 return {
163 '_type': 'Number',
164 'f': val,
165 }
166 elif isinstance(val, dict):
167 return {
168 '_type': 'ValSql',
169 's': self.parse_sql(val),
170 }
171 else:
172 raise ValueError(val)
173
174 def parse_col_unit(self, col_unit):
175 agg_id, col_id, is_distinct = col_unit

Callers 1

parse_condMethod · 0.95

Calls 2

parse_col_unitMethod · 0.95
parse_sqlMethod · 0.95

Tested by

no test coverage detected