(&mut self, op: AggOp)
| 220 | } |
| 221 | |
| 222 | fn parse_aggregation(&mut self, op: AggOp) -> Result<Expr, PromqlError> { |
| 223 | self.advance(); |
| 224 | let grouping_before = self.try_parse_grouping()?; |
| 225 | |
| 226 | self.expect(&Token::LParen)?; |
| 227 | let param = if matches!( |
| 228 | op, |
| 229 | AggOp::Topk | AggOp::Bottomk | AggOp::Quantile | AggOp::CountValues |
| 230 | ) { |
| 231 | let p = self.parse_expr(0)?; |
| 232 | self.expect(&Token::Comma)?; |
| 233 | Some(Box::new(p)) |
| 234 | } else { |
| 235 | None |
| 236 | }; |
| 237 | |
| 238 | let expr = self.parse_expr(0)?; |
| 239 | self.expect(&Token::RParen)?; |
| 240 | |
| 241 | let grouping = if matches!(grouping_before, Grouping::None) { |
| 242 | self.try_parse_grouping()? |
| 243 | } else { |
| 244 | grouping_before |
| 245 | }; |
| 246 | |
| 247 | Ok(Expr::Aggregate { |
| 248 | op, |
| 249 | expr: Box::new(expr), |
| 250 | param, |
| 251 | grouping, |
| 252 | }) |
| 253 | } |
| 254 | |
| 255 | fn parse_label_matchers(&mut self) -> Result<Vec<LabelMatcher>, PromqlError> { |
| 256 | self.expect(&Token::LBrace)?; |
no test coverage detected