File tree Expand file tree Collapse file tree 3 files changed +25
-2
lines changed
sqllogictest/test_files/expr
docs/source/user-guide/sql Expand file tree Collapse file tree 3 files changed +25
-2
lines changed Original file line number Diff line number Diff line change @@ -68,9 +68,10 @@ use datafusion_macros::user_doc;
6868 - millisecond
6969 - microsecond
7070 - nanosecond
71- - dow (day of the week)
71+ - dow (day of the week where Sunday is 0 )
7272 - doy (day of the year)
7373 - epoch (seconds since Unix epoch)
74+ - isodow (day of the week where Monday is 0)
7475"#
7576 ) ,
7677 argument(
@@ -217,6 +218,7 @@ impl ScalarUDFImpl for DatePartFunc {
217218 "qtr" | "quarter" => date_part ( array. as_ref ( ) , DatePart :: Quarter ) ?,
218219 "doy" => date_part ( array. as_ref ( ) , DatePart :: DayOfYear ) ?,
219220 "dow" => date_part ( array. as_ref ( ) , DatePart :: DayOfWeekSunday0 ) ?,
221+ "isodow" => date_part ( array. as_ref ( ) , DatePart :: DayOfWeekMonday0 ) ?,
220222 "epoch" => epoch ( array. as_ref ( ) ) ?,
221223 _ => return exec_err ! ( "Date part '{part}' not supported" ) ,
222224 }
Original file line number Diff line number Diff line change @@ -1070,3 +1070,23 @@ true
10701070
10711071query error DataFusion error: This feature is not implemented: Date part Nanosecond not supported
10721072SELECT (date_part('nanosecond', now()) = EXTRACT(nanosecond FROM now()))
1073+
1074+ query I
1075+ SELECT date_part('ISODOW', CAST('2000-01-01' AS DATE))
1076+ ----
1077+ 5
1078+
1079+ query I
1080+ SELECT EXTRACT(isodow FROM to_timestamp('2020-09-08T12:00:00+00:00'))
1081+ ----
1082+ 1
1083+
1084+ query I
1085+ SELECT EXTRACT("isodow" FROM to_timestamp('2020-09-08T12:00:00+00:00'))
1086+ ----
1087+ 1
1088+
1089+ query I
1090+ SELECT EXTRACT('isodow' FROM to_timestamp('2020-09-08T12:00:00+00:00'))
1091+ ----
1092+ 1
Original file line number Diff line number Diff line change @@ -2114,9 +2114,10 @@ date_part(part, expression)
21142114 - millisecond
21152115 - microsecond
21162116 - nanosecond
2117- - dow (day of the week)
2117+ - dow (day of the week where Sunday is 0 )
21182118 - doy (day of the year)
21192119 - epoch (seconds since Unix epoch)
2120+ - isodow (day of the week where Monday is 0)
21202121
21212122- ** expression** : Time expression to operate on. Can be a constant, column, or function.
21222123
You can’t perform that action at this time.
0 commit comments