Translates PRQL date format (based on `chrono` crate) to dialect specific date format For now only date format as string literal is supported
(
expr: &rq::Expr,
op_name: &str,
args: &[rq::Expr],
ctx: &mut Context,
)
| 298 | /// Translates PRQL date format (based on `chrono` crate) to dialect specific date format |
| 299 | /// For now only date format as string literal is supported |
| 300 | fn process_date_to_text( |
| 301 | expr: &rq::Expr, |
| 302 | op_name: &str, |
| 303 | args: &[rq::Expr], |
| 304 | ctx: &mut Context, |
| 305 | ) -> Result<sql_ast::Expr> { |
| 306 | if let [date_format_exp @ rq::Expr { |
| 307 | kind: rq::ExprKind::Literal(Literal::String(date_format)), |
| 308 | .. |
| 309 | }, col_expr] = args |
| 310 | { |
| 311 | let expr = rq::Expr { |
| 312 | kind: rq::ExprKind::Operator { |
| 313 | name: op_name.to_string(), |
| 314 | args: vec![ |
| 315 | rq::Expr { |
| 316 | kind: rq::ExprKind::Literal(Literal::String( |
| 317 | ctx.dialect |
| 318 | .translate_prql_date_format(date_format) |
| 319 | .map_err(|e| e.with_span(date_format_exp.span))?, |
| 320 | )), |
| 321 | span: date_format_exp.span, |
| 322 | }, |
| 323 | col_expr.clone(), |
| 324 | ], |
| 325 | }, |
| 326 | ..expr.clone() |
| 327 | }; |
| 328 | Ok(super::operators::translate_operator_expr(expr, ctx)?.into_ast()) |
| 329 | } else { |
| 330 | Err( |
| 331 | Error::new_simple("`std.date.to_text` only supports a string literal as format") |
| 332 | .with_span(expr.span), |
| 333 | ) |
| 334 | } |
| 335 | } |
| 336 | |
| 337 | fn process_concat(expr: &rq::Expr, ctx: &mut Context) -> Result<sql_ast::Expr> { |
| 338 | if ctx.dialect.has_concat_function() { |
no test coverage detected