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

Function test_cast_value_to_binary_expr

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

Source from the content-addressed store, hash-verified

2803
2804 #[test]
2805 fn test_cast_value_to_binary_expr() {
2806 let tests = [
2807 (
2808 Expr::Cast(Cast::new(
2809 Box::new(Expr::Literal(
2810 ScalarValue::Utf8(Some("blah".to_string())),
2811 None,
2812 )),
2813 DataType::Binary,
2814 )),
2815 "'blah'",
2816 ),
2817 (
2818 Expr::Cast(Cast::new(
2819 Box::new(Expr::Literal(
2820 ScalarValue::Utf8(Some("blah".to_string())),
2821 None,
2822 )),
2823 DataType::BinaryView,
2824 )),
2825 "'blah'",
2826 ),
2827 ];
2828 for (value, expected) in tests {
2829 let dialect = CustomDialectBuilder::new().build();
2830 let unparser = Unparser::new(&dialect);
2831
2832 let ast = unparser.expr_to_sql(&value).expect("to be unparsed");
2833 let actual = format!("{ast}");
2834
2835 assert_eq!(actual, expected);
2836 }
2837 }
2838
2839 #[test]
2840 fn custom_dialect_use_char_for_utf8_cast() -> Result<()> {

Callers

nothing calls this directly

Calls 6

CastClass · 0.85
newFunction · 0.85
expr_to_sqlMethod · 0.80
LiteralInterface · 0.50
to_stringMethod · 0.45
buildMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…