From 32c5eb8f3b4d4f30b8d23b308a3d697586e44de8 Mon Sep 17 00:00:00 2001 From: Andy Grove Date: Fri, 20 Nov 2026 12:35:09 -0700 Subject: [PATCH] docs: regenerate the function reference for dayofweek #327 added dayofweek without regenerating docs/functions, so the Lint workflow fails on main. This reruns dev/update_function_docs.sh. It only changes generated docs. --- docs/functions/README.md | 3 ++- docs/functions/scalar/time_and_date.md | 26 ++++++++++++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/docs/functions/README.md b/docs/functions/README.md index e8e68a9b..2532c7f7 100644 --- a/docs/functions/README.md +++ b/docs/functions/README.md @@ -21,7 +21,7 @@ function differs from the DataFusion built-in of the same name, if there is one. - [Conditional Functions](scalar/conditional.md) (2) - [String Functions](scalar/string.md) (17) - [Binary String Functions](scalar/binary_string.md) (5) -- [Time and Date Functions](scalar/time_and_date.md) (28) +- [Time and Date Functions](scalar/time_and_date.md) (29) - [Array Functions](scalar/array.md) (10) - [Hashing Functions](scalar/hashing.md) (4) - [Other Functions](scalar/other.md) (6) @@ -77,6 +77,7 @@ function differs from the DataFusion built-in of the same name, if there is one. - [datediff](scalar/time_and_date.md#datediff) - [datepart](scalar/time_and_date.md#datepart) - [dayname](scalar/time_and_date.md#dayname) +- [dayofweek](scalar/time_and_date.md#dayofweek) - [elt](scalar/string.md#elt) - [encode](scalar/binary_string.md#encode) - [equal_null](scalar/other.md#equal_null) diff --git a/docs/functions/scalar/time_and_date.md b/docs/functions/scalar/time_and_date.md index 82ccde3c..20cd32ed 100644 --- a/docs/functions/scalar/time_and_date.md +++ b/docs/functions/scalar/time_and_date.md @@ -25,6 +25,7 @@ Part of the [datafusion-spark function reference](../README.md). - [datediff](#datediff) - [datepart](#datepart) - [dayname](#dayname) +- [dayofweek](#dayofweek) - [from_utc_timestamp](#from_utc_timestamp) - [hour](#hour) - [last_day](#last_day) @@ -284,6 +285,31 @@ Mon NULL ``` +## `dayofweek` + +Returns the day of the week as an INT from 1 (Sunday) to 7 (Saturday). This differs from `weekday`, which counts from 0 (Monday) to 6 (Sunday), and from DataFusion's `date_part('dow', ...)`, which counts from 0 (Sunday) to 6 (Saturday). DataFusion has no built-in `dayofweek`. Strings are implicitly cast to DATE. A malformed string is an error, even with ANSI mode off where Spark returns NULL. A string that Spark reads as a partial date, such as '2009' or '2009-07', is also an error, where Spark uses the first day of that year or month. Timestamps are cast to DATE first, so the time of day is ignored. A timestamp with a time zone is converted in its own time zone, not the session time zone that Spark uses. Returns NULL if the input is NULL. + +```sql +dayofweek(date) +``` + +### Arguments + +- **date**: DATE, TIMESTAMP or string expression. NULL returns NULL. + +### Example + +```sql +> SELECT dayofweek('2009-07-30'::DATE); +5 +> SELECT dayofweek('2009-07-30'); +5 +> SELECT dayofweek(arrow_cast('2024-01-07 23:59:59', 'Timestamp(Microsecond, None)')); +1 +> SELECT dayofweek(NULL::DATE); +NULL +``` + ## `from_utc_timestamp` Treats `ts` as a UTC wall-clock time and returns the wall-clock time in time zone `tz`. DataFusion has no built-in equivalent. A string `ts` is cast to a timestamp, so a string with an offset is first converted to UTC. The result has the same type as `ts`, including any time zone it carries. Returns NULL if either argument is NULL. `tz` accepts Spark's spellings: region IDs, offsets such as `+01:00`, `GMT+1`, `UTC+1:2` and `UT-010203`, Java short IDs such as `PST`, and legacy `SystemV/` IDs. An offset beyond 18 hours or an unknown zone is an error. Differences from Spark: `tz` is only parsed for rows where both arguments are non-NULL, so an invalid constant `tz` can return NULL where Spark raises an error; conversion is limited to Chrono's calendar range, which is narrower than the range Spark implements but covers Spark's documented range; and region rules from `chrono-tz` may differ after 2099, because it does not extrapolate later daylight saving time transitions.