-
Notifications
You must be signed in to change notification settings - Fork 28k
/
datetime.sql.out
147 lines (111 loc) · 3.9 KB
/
datetime.sql.out
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
-- Automatically generated by SQLQueryTestSuite
-- Number of queries: 17
-- !query 0
select current_date = current_date(), current_timestamp = current_timestamp()
-- !query 0 schema
struct<(current_date() = current_date()):boolean,(current_timestamp() = current_timestamp()):boolean>
-- !query 0 output
true true
-- !query 1
select to_date(null), to_date('2016-12-31'), to_date('2016-12-31', 'yyyy-MM-dd')
-- !query 1 schema
struct<to_date(NULL):date,to_date('2016-12-31'):date,to_date('2016-12-31', 'yyyy-MM-dd'):date>
-- !query 1 output
NULL 2016-12-31 2016-12-31
-- !query 2
select to_timestamp(null), to_timestamp('2016-12-31 00:12:00'), to_timestamp('2016-12-31', 'yyyy-MM-dd')
-- !query 2 schema
struct<to_timestamp(NULL):timestamp,to_timestamp('2016-12-31 00:12:00'):timestamp,to_timestamp('2016-12-31', 'yyyy-MM-dd'):timestamp>
-- !query 2 output
NULL 2016-12-31 00:12:00 2016-12-31 00:00:00
-- !query 3
select dayofweek('2007-02-03'), dayofweek('2009-07-30'), dayofweek('2017-05-27'), dayofweek(null), dayofweek('1582-10-15 13:10:15')
-- !query 3 schema
struct<dayofweek(CAST(2007-02-03 AS DATE)):int,dayofweek(CAST(2009-07-30 AS DATE)):int,dayofweek(CAST(2017-05-27 AS DATE)):int,dayofweek(CAST(NULL AS DATE)):int,dayofweek(CAST(1582-10-15 13:10:15 AS DATE)):int>
-- !query 3 output
7 5 7 NULL 6
-- !query 4
create temporary view ttf1 as select * from values
(1, 2),
(2, 3)
as ttf1(current_date, current_timestamp)
-- !query 4 schema
struct<>
-- !query 4 output
-- !query 5
select current_date, current_timestamp from ttf1
-- !query 5 schema
struct<current_date:int,current_timestamp:int>
-- !query 5 output
1 2
2 3
-- !query 6
create temporary view ttf2 as select * from values
(1, 2),
(2, 3)
as ttf2(a, b)
-- !query 6 schema
struct<>
-- !query 6 output
-- !query 7
select current_date = current_date(), current_timestamp = current_timestamp(), a, b from ttf2
-- !query 7 schema
struct<(current_date() = current_date()):boolean,(current_timestamp() = current_timestamp()):boolean,a:int,b:int>
-- !query 7 output
true true 1 2
true true 2 3
-- !query 8
select a, b from ttf2 order by a, current_date
-- !query 8 schema
struct<a:int,b:int>
-- !query 8 output
1 2
2 3
-- !query 9
select weekday('2007-02-03'), weekday('2009-07-30'), weekday('2017-05-27'), weekday(null), weekday('1582-10-15 13:10:15')
-- !query 9 schema
struct<weekday(CAST(2007-02-03 AS DATE)):int,weekday(CAST(2009-07-30 AS DATE)):int,weekday(CAST(2017-05-27 AS DATE)):int,weekday(CAST(NULL AS DATE)):int,weekday(CAST(1582-10-15 13:10:15 AS DATE)):int>
-- !query 9 output
5 3 5 NULL 4
-- !query 10
select year('1500-01-01'), month('1500-01-01'), dayOfYear('1500-01-01')
-- !query 10 schema
struct<year(CAST(1500-01-01 AS DATE)):int,month(CAST(1500-01-01 AS DATE)):int,dayofyear(CAST(1500-01-01 AS DATE)):int>
-- !query 10 output
1500 1 1
-- !query 11
select date '2001-09-28' + 7
-- !query 11 schema
struct<date_add(DATE '2001-09-28', 7):date>
-- !query 11 output
2001-10-05
-- !query 12
select 7 + date '2001-09-28'
-- !query 12 schema
struct<date_add(DATE '2001-09-28', 7):date>
-- !query 12 output
2001-10-05
-- !query 13
select date '2001-10-01' - 7
-- !query 13 schema
struct<date_sub(DATE '2001-10-01', 7):date>
-- !query 13 output
2001-09-24
-- !query 14
select date '2001-10-01' - date '2001-09-28'
-- !query 14 schema
struct<subtractdates(DATE '2001-10-01', DATE '2001-09-28'):interval>
-- !query 14 output
3 days
-- !query 15
select date'2020-01-01' - timestamp'2019-10-06 10:11:12.345678'
-- !query 15 schema
struct<subtracttimestamps(CAST(DATE '2020-01-01' AS TIMESTAMP), TIMESTAMP('2019-10-06 10:11:12.345678')):interval>
-- !query 15 output
2078 hours 48 minutes 47.654322 seconds
-- !query 16
select timestamp'2019-10-06 10:11:12.345678' - date'2020-01-01'
-- !query 16 schema
struct<subtracttimestamps(TIMESTAMP('2019-10-06 10:11:12.345678'), CAST(DATE '2020-01-01' AS TIMESTAMP)):interval>
-- !query 16 output
-2078 hours -48 minutes -47.654322 seconds