Parses `SELECT FROM t` and returns the lowered `SqlExpr` for ` `.
(sql: &str)
| 295 | |
| 296 | /// Parses `SELECT <expr> FROM t` and returns the lowered `SqlExpr` for `<expr>`. |
| 297 | fn select_expr_lowered(sql: &str) -> SqlExpr { |
| 298 | let stmts = parse_sql(sql).expect("parse failed"); |
| 299 | let Statement::Query(q) = &stmts[0] else { |
| 300 | panic!("expected query"); |
| 301 | }; |
| 302 | let sqlparser::ast::SetExpr::Select(sel) = q.body.as_ref() else { |
| 303 | panic!("expected select body"); |
| 304 | }; |
| 305 | let raw = &sel.projection[0]; |
| 306 | let raw_expr = match raw { |
| 307 | SelectItem::UnnamedExpr(e) => e, |
| 308 | SelectItem::ExprWithAlias { expr, .. } => expr, |
| 309 | other => panic!("unexpected projection: {other:?}"), |
| 310 | }; |
| 311 | convert_expr(raw_expr).expect("convert_expr failed") |
| 312 | } |
| 313 | |
| 314 | fn assert_json_fn(sql: &str, expected_fn: &str) { |
| 315 | let expr = select_expr_lowered(sql); |
no test coverage detected