MCPcopy Create free account
hub / github.com/apache/datafusion / test_utf8_view_to_sql

Function test_utf8_view_to_sql

datafusion/sql/src/unparser/expr.rs:3461–3505  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

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<()> {

Callers

nothing calls this directly

Calls 12

newFunction · 0.85
with_utf8_cast_dtypeMethod · 0.80
expr_to_sqlMethod · 0.80
is_not_nullMethod · 0.80
castFunction · 0.50
colFunction · 0.50
litFunction · 0.50
buildMethod · 0.45
to_stringMethod · 0.45
eqMethod · 0.45
is_nullMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…