()
| 3230 | |
| 3231 | #[test] |
| 3232 | fn test_round_scalar_fn_to_expr() -> Result<()> { |
| 3233 | let default_dialect: Arc<dyn Dialect> = Arc::new( |
| 3234 | CustomDialectBuilder::new() |
| 3235 | .with_identifier_quote_style('"') |
| 3236 | .build(), |
| 3237 | ); |
| 3238 | let postgres_dialect: Arc<dyn Dialect> = Arc::new(PostgreSqlDialect {}); |
| 3239 | |
| 3240 | for (dialect, identifier) in |
| 3241 | [(default_dialect, "DOUBLE"), (postgres_dialect, "NUMERIC")] |
| 3242 | { |
| 3243 | let unparser = Unparser::new(dialect.as_ref()); |
| 3244 | let expr = Expr::ScalarFunction(ScalarFunction { |
| 3245 | func: Arc::new(ScalarUDF::from( |
| 3246 | datafusion_functions::math::round::RoundFunc::new(), |
| 3247 | )), |
| 3248 | args: vec![ |
| 3249 | Expr::Cast(Cast::new(Box::new(col("a")), DataType::Float64)), |
| 3250 | Expr::Literal(ScalarValue::Int64(Some(2)), None), |
| 3251 | ], |
| 3252 | }); |
| 3253 | let ast = unparser.expr_to_sql(&expr)?; |
| 3254 | |
| 3255 | let actual = format!("{ast}"); |
| 3256 | let expected = format!(r#"round(CAST("a" AS {identifier}), 2)"#); |
| 3257 | |
| 3258 | assert_eq!(actual, expected); |
| 3259 | } |
| 3260 | Ok(()) |
| 3261 | } |
| 3262 | |
| 3263 | #[test] |
| 3264 | fn test_postgres_array_has_to_any() -> Result<()> { |
nothing calls this directly
no test coverage detected
searching dependent graphs…