Skip to content

Commit f76f5ec

Browse files
committed
Added function tests for timezones
1 parent 2713280 commit f76f5ec

File tree

1 file changed

+76
-1
lines changed
  • x-pack/plugin/esql/qa/testFixtures/src/main/resources

1 file changed

+76
-1
lines changed

x-pack/plugin/esql/qa/testFixtures/src/main/resources/date.csv-spec

Lines changed: 76 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ emp_no:integer | x:keyword | y:keyword
5555
10061 | 1985-09-17T00:00:00.000Z | 1985-09-17
5656
;
5757

58-
5958
compareToString
6059
from employees | where hire_date < "1985-03-01T00:00:00Z" | keep emp_no, hire_date;
6160
ignoreOrder:true
@@ -1085,6 +1084,33 @@ date:date | year:long
10851084
2022-05-06T00:00:00.000Z | 2022
10861085
;
10871086

1087+
dateExtractSetTimezoneFrom
1088+
required_capability: global_timezone_parameter
1089+
1090+
set time_zone="+07:00"\;
1091+
from employees
1092+
| sort hire_date
1093+
| eval hour = date_extract("hour_of_day", hire_date)
1094+
| keep emp_no, hire_date, dat
1095+
| limit 2;
1096+
1097+
emp_no:integer | hire_date:date | hour:long
1098+
10009 | 1985-02-18T00:00:00.000Z | 7
1099+
10048 | 1985-02-24T00:00:00.000Z | 7
1100+
;
1101+
1102+
dateExtractSetTimezoneRow
1103+
required_capability: global_timezone_parameter
1104+
1105+
set time_zone="+07:00"\;
1106+
ROW hire_date = "2020-02-28T23:00:00.000Z"::date
1107+
| EVAL hour = date_extract("hour_of_day", hire_date)
1108+
| KEEP hour;
1109+
1110+
hour:long
1111+
6
1112+
;
1113+
10881114
docsDateExtractBusinessHours
10891115
// tag::docsDateExtractBusinessHours[]
10901116
FROM sample_data
@@ -1971,6 +1997,30 @@ emp_no:integer | birth_date:date | hire_date:date
19711997
10040 | null | 1993-02-14T00:00:00.000Z | null
19721998
;
19731999

2000+
dayNameSetTimezoneRow
2001+
required_capability: global_timezone_parameter
2002+
2003+
set time_zone="-02:00"\;
2004+
row dt = to_datetime("1953-09-02T00:00:00.000Z")
2005+
| eval weekday = day_name(dt);
2006+
2007+
dt:date | weekday:keyword
2008+
1953-09-02T00:00:00.000Z | Tuesday
2009+
;
2010+
2011+
dayNameSetTimezoneFrom
2012+
required_capability: global_timezone_parameter
2013+
2014+
set time_zone="-02:00"\;
2015+
from employees
2016+
| sort emp_no
2017+
| keep emp_no, hire_date
2018+
| eval day = day_name(hire_date)
2019+
| limit 1;
2020+
2021+
emp_no:integer | hire_date:date | day:keyword
2022+
10001 | 1986-06-26T00:00:00.000Z | Wednesday
2023+
;
19742024

19752025
monthNameRowTest
19762026
required_capability:fn_month_name
@@ -2068,3 +2118,28 @@ from employees
20682118
emp_no:integer | birth_date:date | hire_date:date | monthName:keyword
20692119
10040 | null | 1993-02-14T00:00:00.000Z | null
20702120
;
2121+
2122+
monthNameSetTimezoneRow
2123+
required_capability: global_timezone_parameter
2124+
2125+
set time_zone="Europe/Paris"\;
2126+
row dt = to_datetime("1996-01-31T23:00:00.000Z")
2127+
| eval monthName = MONTH_NAME(dt);
2128+
2129+
dt:date | monthName:keyword
2130+
1996-01-31T23:00:00.000Z | February
2131+
;
2132+
2133+
monthNameSetTimezoneFrom
2134+
required_capability:fn_month_name
2135+
2136+
set time_zone="-10:00"\;
2137+
from employees
2138+
| WHERE emp_no == 10004
2139+
| keep emp_no, hire_date
2140+
| eval monthName = month_name(hire_date)
2141+
| limit 1;
2142+
2143+
emp_no:integer | hire_date:date | monthName:keyword
2144+
10004 | 1986-12-01T00:00:00.000Z | November
2145+
;

0 commit comments

Comments
 (0)