| 295 | } |
| 296 | |
| 297 | fn parse_duration(&mut self) -> Result<Duration, PromqlError> { |
| 298 | match self.advance().clone() { |
| 299 | Token::Duration(s) => { |
| 300 | Duration::parse(&s).ok_or(PromqlError::InvalidDuration { literal: s }) |
| 301 | } |
| 302 | Token::Number(n) if n > 0.0 => Ok(Duration((n * 1000.0) as i64)), |
| 303 | t => Err(PromqlError::UnexpectedToken { |
| 304 | expected: "duration".to_string(), |
| 305 | found: format!("{t:?}"), |
| 306 | }), |
| 307 | } |
| 308 | } |
| 309 | |
| 310 | fn try_parse_grouping(&mut self) -> Result<Grouping, PromqlError> { |
| 311 | if self.try_keyword("by") { |