Check if an expression is a time_bucket() call and extract the interval.
(expr: &ast::Expr, functions: &FunctionRegistry)
| 153 | |
| 154 | /// Check if an expression is a time_bucket() call and extract the interval. |
| 155 | fn try_extract_time_bucket(expr: &ast::Expr, functions: &FunctionRegistry) -> Result<Option<i64>> { |
| 156 | if let ast::Expr::Function(func) = expr { |
| 157 | let name = func |
| 158 | .name |
| 159 | .0 |
| 160 | .iter() |
| 161 | .map(|p| match p { |
| 162 | ast::ObjectNamePart::Identifier(ident) => normalize_ident(ident), |
| 163 | _ => String::new(), |
| 164 | }) |
| 165 | .collect::<Vec<_>>() |
| 166 | .join("."); |
| 167 | if functions.search_trigger(&name) == SearchTrigger::TimeBucket { |
| 168 | return Ok(Some(extract_bucket_interval(func)?)); |
| 169 | } |
| 170 | } |
| 171 | Ok(None) |
| 172 | } |
| 173 | |
| 174 | /// Resolve a GROUP BY expression that references a SELECT alias or ordinal. |
| 175 | /// |