This is an automated email from the ASF dual-hosted git repository.
alamb pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/datafusion.git
The following commit(s) were added to refs/heads/main by this push:
new ccfe020a9a Added current_timestamp alias (#12958)
ccfe020a9a is described below
commit ccfe020a9a98203d7d37d1431e351be8d4418f63
Author: Jonathan Chen <[email protected]>
AuthorDate: Thu Oct 17 13:23:04 2024 -0400
Added current_timestamp alias (#12958)
* Add current_timestamp
* ft fix?
* fmt fix
---
datafusion/functions/src/datetime/now.rs | 6 ++++++
datafusion/sqllogictest/test_files/timestamps.slt | 5 +++++
2 files changed, 11 insertions(+)
diff --git a/datafusion/functions/src/datetime/now.rs
b/datafusion/functions/src/datetime/now.rs
index 74eb5aea42..690008d972 100644
--- a/datafusion/functions/src/datetime/now.rs
+++ b/datafusion/functions/src/datetime/now.rs
@@ -28,6 +28,7 @@ use datafusion_expr::{ColumnarValue, Expr, ScalarUDFImpl,
Signature, Volatility}
#[derive(Debug)]
pub struct NowFunc {
signature: Signature,
+ aliases: Vec<String>,
}
impl Default for NowFunc {
@@ -40,6 +41,7 @@ impl NowFunc {
pub fn new() -> Self {
Self {
signature: Signature::uniform(0, vec![], Volatility::Stable),
+ aliases: vec!["current_timestamp".to_string()],
}
}
}
@@ -85,6 +87,10 @@ impl ScalarUDFImpl for NowFunc {
)))
}
+ fn aliases(&self) -> &[String] {
+ &self.aliases
+ }
+
fn is_nullable(&self, _args: &[Expr], _schema: &dyn ExprSchema) -> bool {
false
}
diff --git a/datafusion/sqllogictest/test_files/timestamps.slt
b/datafusion/sqllogictest/test_files/timestamps.slt
index a680e0db52..d866ec8c94 100644
--- a/datafusion/sqllogictest/test_files/timestamps.slt
+++ b/datafusion/sqllogictest/test_files/timestamps.slt
@@ -84,6 +84,11 @@ select case when current_time() = (now()::bigint %
86400000000000)::time then 'O
----
OK
+query B
+select now() = current_timestamp;
+----
+true
+
##########
## Timestamp Handling Tests
##########
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]