SQLite does not support timestamp/date scalars like `to_timestamp`, `from_unixtime`, `date_trunc`, etc. This remaps `from_unixtime` to `datetime(expr, 'unixepoch')`, expecting the input to be in seconds. It supports no other arguments, so if any are supplied it will return an error. # Errors - If the number of arguments is not 1 - the column or expression to convert. - If the scalar function can
(
unparser: &Unparser,
from_unixtime_args: &[Expr],
)
| 544 | /// - If the number of arguments is not 1 - the column or expression to convert. |
| 545 | /// - If the scalar function cannot be converted to SQL. |
| 546 | pub(crate) fn sqlite_from_unixtime_to_sql( |
| 547 | unparser: &Unparser, |
| 548 | from_unixtime_args: &[Expr], |
| 549 | ) -> Result<Option<ast::Expr>> { |
| 550 | assert_eq_or_internal_err!( |
| 551 | from_unixtime_args.len(), |
| 552 | 1, |
| 553 | "from_unixtime for SQLite expects 1 argument, found {}", |
| 554 | from_unixtime_args.len() |
| 555 | ); |
| 556 | |
| 557 | Ok(Some(unparser.scalar_function_to_sql( |
| 558 | "datetime", |
| 559 | &[ |
| 560 | from_unixtime_args[0].clone(), |
| 561 | Expr::Literal(ScalarValue::Utf8(Some("unixepoch".to_string())), None), |
| 562 | ], |
| 563 | )?)) |
| 564 | } |
| 565 | |
| 566 | /// SQLite does not support timestamp/date scalars like `to_timestamp`, `from_unixtime`, `date_trunc`, etc. |
| 567 | /// This uses the `strftime` function to format the timestamp as a string depending on the truncation unit. |
no test coverage detected
searching dependent graphs…