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

Function test_from_unixtime

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

Source from the content-addressed store, hash-verified

3313
3314 #[test]
3315 fn test_from_unixtime() -> Result<()> {
3316 let default_dialect: Arc<dyn Dialect> = Arc::new(DefaultDialect {});
3317 let sqlite_dialect: Arc<dyn Dialect> = Arc::new(SqliteDialect {});
3318
3319 for (dialect, expected) in [
3320 (default_dialect, "from_unixtime(date_col)"),
3321 (sqlite_dialect, "datetime(`date_col`, 'unixepoch')"),
3322 ] {
3323 let unparser = Unparser::new(dialect.as_ref());
3324 let expr = Expr::ScalarFunction(ScalarFunction {
3325 func: Arc::new(ScalarUDF::from(FromUnixtimeFunc::new())),
3326 args: vec![col("date_col")],
3327 });
3328
3329 let ast = unparser.expr_to_sql(&expr)?;
3330
3331 let actual = ast.to_string();
3332 let expected = expected.to_string();
3333
3334 assert_eq!(actual, expected);
3335 }
3336 Ok(())
3337 }
3338
3339 #[test]
3340 fn test_date_trunc() -> Result<()> {

Callers

nothing calls this directly

Calls 5

newFunction · 0.85
ScalarFunctionClass · 0.85
expr_to_sqlMethod · 0.80
as_refMethod · 0.45
to_stringMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…