Skip to content

Apache DataFusion SQL Query Engine

Docs: Update SQL example for current_time() and current_date(). (#18200)

Sriram Sundar6d52e54bc8b2
diff --git a/datafusion/functions/src/datetime/current_date.rs b/datafusion/functions/src/datetime/current_date.rs
index 0ba3afd19b..18b99bca86 100644
--- a/datafusion/functions/src/datetime/current_date.rs
+++ b/datafusion/functions/src/datetime/current_date.rs
@@ -36,7 +36,9 @@ Returns the current date in the session time zone.
The `current_date()` return value is determined at query time and will return the same date, no matter when in the query plan the function executes.
"#,
- syntax_example = "current_date()"
+ syntax_example = r#"current_date()
+ (optional) SET datafusion.execution.time_zone = '+00:00';
+ SELECT current_date();"#
)]
#[derive(Debug, PartialEq, Eq, Hash)]
pub struct CurrentDateFunc {
diff --git a/datafusion/functions/src/datetime/current_time.rs b/datafusion/functions/src/datetime/current_time.rs
index b1592d8df2..4f5b199cce 100644
--- a/datafusion/functions/src/datetime/current_time.rs
+++ b/datafusion/functions/src/datetime/current_time.rs
@@ -38,7 +38,9 @@ The `current_time()` return value is determined at query time and will return th
The session time zone can be set using the statement 'SET datafusion.execution.time_zone = desired time zone'. The time zone can be a value like +00:00, 'Europe/London' etc.
"#,
- syntax_example = "current_time()"
+ syntax_example = r#"current_time()
+ (optional) SET datafusion.execution.time_zone = '+00:00';
+ SELECT current_time();"#
)]
#[derive(Debug, PartialEq, Eq, Hash)]
pub struct CurrentTimeFunc {
diff --git a/docs/source/user-guide/sql/scalar_functions.md b/docs/source/user-guide/sql/scalar_functions.md
index 4ca3a822db..d2e7066191 100644
--- a/docs/source/user-guide/sql/scalar_functions.md
+++ b/docs/source/user-guide/sql/scalar_functions.md
@@ -2409,6 +2409,8 @@ The `current_date()` return value is determined at query time and will return th
```sql
current_date()
+ (optional) SET datafusion.execution.time_zone = '+00:00';
+ SELECT current_date();
```
#### Aliases
@@ -2425,6 +2427,8 @@ The session time zone can be set using the statement 'SET datafusion.execution.t
```sql
current_time()
+ (optional) SET datafusion.execution.time_zone = '+00:00';
+ SELECT current_time();
```
### `current_timestamp`