Skip to content

Commit 7f5e069

Browse files
codetyri0ntobixdev
authored andcommitted
Docs: Update SQL example for current_time() and current_date(). (apache#18200)
## Which issue does this PR close? - Closes apache#18199 ## What changes are included in this PR? - Added a SQL example in scalar functions md to demonstrate setting execution time zone (optional) for current_time() and current_date(). ## Are these changes tested? ## Are there any user-facing changes?
1 parent 5a28c85 commit 7f5e069

File tree

3 files changed

+10
-2
lines changed

3 files changed

+10
-2
lines changed

datafusion/functions/src/datetime/current_date.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,9 @@ Returns the current date in the session time zone.
3636
3737
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.
3838
"#,
39-
syntax_example = "current_date()"
39+
syntax_example = r#"current_date()
40+
(optional) SET datafusion.execution.time_zone = '+00:00';
41+
SELECT current_date();"#
4042
)]
4143
#[derive(Debug, PartialEq, Eq, Hash)]
4244
pub struct CurrentDateFunc {

datafusion/functions/src/datetime/current_time.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,9 @@ The `current_time()` return value is determined at query time and will return th
3838
3939
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.
4040
"#,
41-
syntax_example = "current_time()"
41+
syntax_example = r#"current_time()
42+
(optional) SET datafusion.execution.time_zone = '+00:00';
43+
SELECT current_time();"#
4244
)]
4345
#[derive(Debug, PartialEq, Eq, Hash)]
4446
pub struct CurrentTimeFunc {

docs/source/user-guide/sql/scalar_functions.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2409,6 +2409,8 @@ The `current_date()` return value is determined at query time and will return th
24092409

24102410
```sql
24112411
current_date()
2412+
(optional) SET datafusion.execution.time_zone = '+00:00';
2413+
SELECT current_date();
24122414
```
24132415

24142416
#### Aliases
@@ -2425,6 +2427,8 @@ The session time zone can be set using the statement 'SET datafusion.execution.t
24252427

24262428
```sql
24272429
current_time()
2430+
(optional) SET datafusion.execution.time_zone = '+00:00';
2431+
SELECT current_time();
24282432
```
24292433

24302434
### `current_timestamp`

0 commit comments

Comments
 (0)