:returns next idx, (agg_op id, col_id)
(toks, start_idx, tables_with_alias, schema, default_tables=None)
| 189 | |
| 190 | |
| 191 | def parse_col_unit(toks, start_idx, tables_with_alias, schema, default_tables=None): |
| 192 | """ |
| 193 | :returns next idx, (agg_op id, col_id) |
| 194 | """ |
| 195 | idx = start_idx |
| 196 | len_ = len(toks) |
| 197 | isBlock = False |
| 198 | isDistinct = False |
| 199 | if toks[idx] == '(': |
| 200 | isBlock = True |
| 201 | idx += 1 |
| 202 | |
| 203 | if toks[idx] in AGG_OPS: |
| 204 | agg_id = AGG_OPS.index(toks[idx]) |
| 205 | idx += 1 |
| 206 | assert idx < len_ and toks[idx] == '(' |
| 207 | idx += 1 |
| 208 | if toks[idx] == "distinct": |
| 209 | idx += 1 |
| 210 | isDistinct = True |
| 211 | idx, col_id = parse_col(toks, idx, tables_with_alias, schema, default_tables) |
| 212 | assert idx < len_ and toks[idx] == ')' |
| 213 | idx += 1 |
| 214 | return idx, (agg_id, col_id, isDistinct) |
| 215 | |
| 216 | if toks[idx] == "distinct": |
| 217 | idx += 1 |
| 218 | isDistinct = True |
| 219 | agg_id = AGG_OPS.index("none") |
| 220 | idx, col_id = parse_col(toks, idx, tables_with_alias, schema, default_tables) |
| 221 | |
| 222 | if isBlock: |
| 223 | assert toks[idx] == ')' |
| 224 | idx += 1 # skip ')' |
| 225 | |
| 226 | return idx, (agg_id, col_id, isDistinct) |
| 227 | |
| 228 | |
| 229 | def parse_val_unit(toks, start_idx, tables_with_alias, schema, default_tables=None): |
no test coverage detected