:returns next idx, (agg_op id, col_id)
(toks, start_idx, tables_with_alias, schema, default_tables=None)
| 218 | |
| 219 | |
| 220 | def parse_col_unit(toks, start_idx, tables_with_alias, schema, default_tables=None): |
| 221 | """ |
| 222 | :returns next idx, (agg_op id, col_id) |
| 223 | """ |
| 224 | idx = start_idx |
| 225 | len_ = len(toks) |
| 226 | isBlock = False |
| 227 | isDistinct = False |
| 228 | if toks[idx] == '(': |
| 229 | isBlock = True |
| 230 | idx += 1 |
| 231 | |
| 232 | if toks[idx] in AGG_OPS: |
| 233 | agg_id = AGG_OPS.index(toks[idx]) |
| 234 | idx += 1 |
| 235 | assert idx < len_ and toks[idx] == '(' |
| 236 | idx += 1 |
| 237 | if toks[idx] == "distinct": |
| 238 | idx += 1 |
| 239 | isDistinct = True |
| 240 | idx, col_id = parse_col(toks, idx, tables_with_alias, schema, default_tables) |
| 241 | assert idx < len_ and toks[idx] == ')' |
| 242 | idx += 1 |
| 243 | return idx, (agg_id, col_id, isDistinct) |
| 244 | |
| 245 | if toks[idx] == "distinct": |
| 246 | idx += 1 |
| 247 | isDistinct = True |
| 248 | agg_id = AGG_OPS.index("none") |
| 249 | idx, col_id = parse_col(toks, idx, tables_with_alias, schema, default_tables) |
| 250 | |
| 251 | if isBlock: |
| 252 | assert toks[idx] == ')' |
| 253 | idx += 1 # skip ')' |
| 254 | |
| 255 | return idx, (agg_id, col_id, isDistinct) |
| 256 | |
| 257 | |
| 258 | def parse_val_unit(toks, start_idx, tables_with_alias, schema, default_tables=None): |
no test coverage detected