()
| 3459 | |
| 3460 | #[test] |
| 3461 | fn test_utf8_view_to_sql() -> Result<()> { |
| 3462 | let dialect = CustomDialectBuilder::new() |
| 3463 | .with_utf8_cast_dtype(ast::DataType::Char(None)) |
| 3464 | .build(); |
| 3465 | let unparser = Unparser::new(&dialect); |
| 3466 | |
| 3467 | let arrow_field = Arc::new(Field::new("", DataType::Utf8View, true)); |
| 3468 | let ast_dtype = unparser.arrow_dtype_to_ast_dtype(&arrow_field)?; |
| 3469 | |
| 3470 | assert_eq!(ast_dtype, ast::DataType::Char(None)); |
| 3471 | |
| 3472 | let expr = cast(col("a"), DataType::Utf8View); |
| 3473 | let ast = unparser.expr_to_sql(&expr)?; |
| 3474 | |
| 3475 | let actual = format!("{ast}"); |
| 3476 | let expected = r#"CAST(a AS CHAR)"#.to_string(); |
| 3477 | |
| 3478 | assert_eq!(actual, expected); |
| 3479 | |
| 3480 | let expr = col("a").eq(lit(ScalarValue::Utf8View(Some("hello".to_string())))); |
| 3481 | let ast = unparser.expr_to_sql(&expr)?; |
| 3482 | |
| 3483 | let actual = format!("{ast}"); |
| 3484 | let expected = r#"(a = 'hello')"#.to_string(); |
| 3485 | |
| 3486 | assert_eq!(actual, expected); |
| 3487 | |
| 3488 | let expr = col("a").is_not_null(); |
| 3489 | |
| 3490 | let ast = unparser.expr_to_sql(&expr)?; |
| 3491 | let actual = format!("{ast}"); |
| 3492 | let expected = r#"a IS NOT NULL"#.to_string(); |
| 3493 | |
| 3494 | assert_eq!(actual, expected); |
| 3495 | |
| 3496 | let expr = col("a").is_null(); |
| 3497 | |
| 3498 | let ast = unparser.expr_to_sql(&expr)?; |
| 3499 | let actual = format!("{ast}"); |
| 3500 | let expected = r#"a IS NULL"#.to_string(); |
| 3501 | |
| 3502 | assert_eq!(actual, expected); |
| 3503 | |
| 3504 | Ok(()) |
| 3505 | } |
| 3506 | |
| 3507 | #[test] |
| 3508 | fn test_custom_scalar_overrides_duckdb() -> Result<()> { |
nothing calls this directly
no test coverage detected
searching dependent graphs…