Helper: parse a SQL SELECT and return the select body + projection.
(sql: &str)
| 398 | |
| 399 | /// Helper: parse a SQL SELECT and return the select body + projection. |
| 400 | fn parse_select(sql: &str) -> ast::Select { |
| 401 | use sqlparser::dialect::GenericDialect; |
| 402 | use sqlparser::parser::Parser; |
| 403 | let stmts = Parser::parse_sql(&GenericDialect {}, sql).unwrap(); |
| 404 | match stmts.into_iter().next().unwrap() { |
| 405 | ast::Statement::Query(q) => match *q.body { |
| 406 | ast::SetExpr::Select(s) => *s, |
| 407 | _ => panic!("expected SELECT"), |
| 408 | }, |
| 409 | _ => panic!("expected query"), |
| 410 | } |
| 411 | } |
| 412 | |
| 413 | #[test] |
| 414 | fn resolve_group_by_alias_to_time_bucket() { |