mirror of
https://github.com/apache/impala.git
synced 2026-01-03 15:00:52 -05:00
This change set adds support for dealing with custom date/time formats in Impala. The following date/time tokens are supported:
y – Year
M – Month
d – Day
H – Hour
m – Minute
s – second
S – Fractional second
The token names and usage have been modeled on the SimpleDateFormat class used in Java. This allows the use of repeating tokens to indicate zero padding for an output scenario (TS -> String) and a guide for reading data to a given length in a parsing scenario. Representing literals months is achieved by specifying three repeating tokens e.g. yyyy-MMM-dd -> 2013-Nov-21.
Formatting character groups can appear in any order along with any separators e.g.
yyyy/MM/dd
dd-MMM-yy
(dd)(MM)(yyyy) HH:mm:sss
..etc..
The following features are not supported with this patch:
- Long literal months e.g. MMMM
- Nested strings e.g. “Year: “ yyyy “Month: “ mm “Day: “ dd
- Lazy formatting
Change-Id: Ibba2eaed366fd736b921b31b8d0d517ac1248bca
Reviewed-on: http://gerrit.ent.cloudera.com:8080/1001
Reviewed-by: Christopher Channing <cchanning@cloudera.com>
Tested-by: Christopher Channing <cchanning@cloudera.com>
1375 lines
37 KiB
Plaintext
1375 lines
37 KiB
Plaintext
====
|
|
---- QUERY
|
|
# IS NULL predicate
|
|
select count(*) from alltypesagg
|
|
---- TYPES
|
|
bigint
|
|
---- RESULTS
|
|
10000
|
|
====
|
|
---- QUERY
|
|
select count(*) from alltypesagg where tinyint_col is null
|
|
---- TYPES
|
|
bigint
|
|
---- RESULTS
|
|
1000
|
|
====
|
|
---- QUERY
|
|
select count(*) from alltypesagg where tinyint_col is not null
|
|
---- TYPES
|
|
bigint
|
|
---- RESULTS
|
|
9000
|
|
====
|
|
---- QUERY
|
|
# =
|
|
select count(*) from alltypesagg where tinyint_col = 1
|
|
---- TYPES
|
|
bigint
|
|
---- RESULTS
|
|
1000
|
|
====
|
|
---- QUERY
|
|
select count(*) from alltypesagg where smallint_col = 1
|
|
---- TYPES
|
|
bigint
|
|
---- RESULTS
|
|
100
|
|
====
|
|
---- QUERY
|
|
select count(*) from alltypesagg where int_col = 1
|
|
---- TYPES
|
|
bigint
|
|
---- RESULTS
|
|
10
|
|
====
|
|
---- QUERY
|
|
select count(*) from alltypesagg where bigint_col = 10
|
|
---- TYPES
|
|
bigint
|
|
---- RESULTS
|
|
10
|
|
====
|
|
---- QUERY
|
|
select count(*) from alltypesagg where float_col = cast(1.1 as float)
|
|
---- TYPES
|
|
bigint
|
|
---- RESULTS
|
|
10
|
|
====
|
|
---- QUERY
|
|
select count(*) from alltypesagg where double_col = 10.1
|
|
---- TYPES
|
|
bigint
|
|
---- RESULTS
|
|
10
|
|
====
|
|
---- QUERY
|
|
select count(*) from alltypesagg where date_string_col = '01/01/10'
|
|
---- TYPES
|
|
bigint
|
|
---- RESULTS
|
|
1000
|
|
====
|
|
---- QUERY
|
|
# <>
|
|
select count(*) from alltypesagg where tinyint_col <> 1
|
|
---- TYPES
|
|
bigint
|
|
---- RESULTS
|
|
8000
|
|
====
|
|
---- QUERY
|
|
select count(*) from alltypesagg where smallint_col <> 1
|
|
---- TYPES
|
|
bigint
|
|
---- RESULTS
|
|
9800
|
|
====
|
|
---- QUERY
|
|
select count(*) from alltypesagg where int_col <> 1
|
|
---- TYPES
|
|
bigint
|
|
---- RESULTS
|
|
9980
|
|
====
|
|
---- QUERY
|
|
select count(*) from alltypesagg where bigint_col <> 1
|
|
---- TYPES
|
|
bigint
|
|
---- RESULTS
|
|
9990
|
|
====
|
|
---- QUERY
|
|
select count(*) from alltypesagg where float_col <> cast(1.1 as float)
|
|
---- TYPES
|
|
bigint
|
|
---- RESULTS
|
|
9980
|
|
====
|
|
---- QUERY
|
|
select count(*) from alltypesagg where double_col <> 10.1
|
|
---- TYPES
|
|
bigint
|
|
---- RESULTS
|
|
9980
|
|
====
|
|
---- QUERY
|
|
# <
|
|
select count(*) from alltypesagg where tinyint_col < 2
|
|
---- TYPES
|
|
bigint
|
|
---- RESULTS
|
|
1000
|
|
====
|
|
---- QUERY
|
|
select count(*) from alltypesagg where smallint_col < 2
|
|
---- TYPES
|
|
bigint
|
|
---- RESULTS
|
|
100
|
|
====
|
|
---- QUERY
|
|
select count(*) from alltypesagg where int_col < 2
|
|
---- TYPES
|
|
bigint
|
|
---- RESULTS
|
|
10
|
|
====
|
|
---- QUERY
|
|
select count(*) from alltypesagg where bigint_col < 20
|
|
---- TYPES
|
|
bigint
|
|
---- RESULTS
|
|
10
|
|
====
|
|
---- QUERY
|
|
select count(*) from alltypesagg where float_col < 2.2
|
|
---- TYPES
|
|
bigint
|
|
---- RESULTS
|
|
10
|
|
====
|
|
---- QUERY
|
|
select count(*) from alltypesagg where double_col < 20.2
|
|
---- TYPES
|
|
bigint
|
|
---- RESULTS
|
|
10
|
|
====
|
|
---- QUERY
|
|
# >
|
|
select count(*) from alltypesagg where tinyint_col > 1
|
|
---- TYPES
|
|
bigint
|
|
---- RESULTS
|
|
8000
|
|
====
|
|
---- QUERY
|
|
select count(*) from alltypesagg where smallint_col > 1
|
|
---- TYPES
|
|
bigint
|
|
---- RESULTS
|
|
9800
|
|
====
|
|
---- QUERY
|
|
select count(*) from alltypesagg where int_col > 1
|
|
---- TYPES
|
|
bigint
|
|
---- RESULTS
|
|
9980
|
|
====
|
|
---- QUERY
|
|
select count(*) from alltypesagg where bigint_col > 10
|
|
---- TYPES
|
|
bigint
|
|
---- RESULTS
|
|
9980
|
|
====
|
|
---- QUERY
|
|
select count(*) from alltypesagg where float_col > cast(1.1 as float)
|
|
---- TYPES
|
|
bigint
|
|
---- RESULTS
|
|
9980
|
|
====
|
|
---- QUERY
|
|
select count(*) from alltypesagg where double_col > 10.1
|
|
---- TYPES
|
|
bigint
|
|
---- RESULTS
|
|
9980
|
|
====
|
|
---- QUERY
|
|
# <=
|
|
select count(*) from alltypesagg where tinyint_col <= 1
|
|
---- TYPES
|
|
bigint
|
|
---- RESULTS
|
|
1000
|
|
====
|
|
---- QUERY
|
|
select count(*) from alltypesagg where smallint_col <= 1
|
|
---- TYPES
|
|
bigint
|
|
---- RESULTS
|
|
100
|
|
====
|
|
---- QUERY
|
|
select count(*) from alltypesagg where int_col <= 1
|
|
---- TYPES
|
|
bigint
|
|
---- RESULTS
|
|
10
|
|
====
|
|
---- QUERY
|
|
select count(*) from alltypesagg where bigint_col <= 10
|
|
---- TYPES
|
|
bigint
|
|
---- RESULTS
|
|
10
|
|
====
|
|
---- QUERY
|
|
select count(*) from alltypesagg where float_col <= cast(1.1 as float)
|
|
---- TYPES
|
|
bigint
|
|
---- RESULTS
|
|
10
|
|
====
|
|
---- QUERY
|
|
select count(*) from alltypesagg where double_col <= 10.1
|
|
---- TYPES
|
|
bigint
|
|
---- RESULTS
|
|
10
|
|
====
|
|
---- QUERY
|
|
# >=
|
|
select count(*) from alltypesagg where tinyint_col >= 2
|
|
---- TYPES
|
|
bigint
|
|
---- RESULTS
|
|
8000
|
|
====
|
|
---- QUERY
|
|
select count(*) from alltypesagg where smallint_col >= 2
|
|
---- TYPES
|
|
bigint
|
|
---- RESULTS
|
|
9800
|
|
====
|
|
---- QUERY
|
|
select count(*) from alltypesagg where int_col >= 2
|
|
---- TYPES
|
|
bigint
|
|
---- RESULTS
|
|
9980
|
|
====
|
|
---- QUERY
|
|
select count(*) from alltypesagg where bigint_col >= 20
|
|
---- TYPES
|
|
bigint
|
|
---- RESULTS
|
|
9980
|
|
====
|
|
---- QUERY
|
|
select count(*) from alltypesagg where float_col >= 2.2
|
|
---- TYPES
|
|
bigint
|
|
---- RESULTS
|
|
9980
|
|
====
|
|
---- QUERY
|
|
select count(*) from alltypesagg where double_col >= 20.2
|
|
---- TYPES
|
|
bigint
|
|
---- RESULTS
|
|
9980
|
|
====
|
|
---- QUERY
|
|
# Type synonym check: DOUBLE = REAL
|
|
select count(*) from alltypesagg where double_col >= 20.2 and cast(double_col as double) = cast(double_col as real)
|
|
---- TYPES
|
|
bigint
|
|
---- RESULTS
|
|
9980
|
|
====
|
|
---- QUERY
|
|
# Type synonym check: INT = INTEGER
|
|
select count(*) from alltypesagg where double_col >= 20.2 and cast(double_col as int) = cast(double_col as integer)
|
|
---- TYPES
|
|
bigint
|
|
---- RESULTS
|
|
9980
|
|
====
|
|
---- QUERY
|
|
# TODO: figure out why the last col has a diff
|
|
# result: 111428999.9997675
|
|
# +
|
|
#select
|
|
#SUM(tinyint_col) + SUM(smallint_col),
|
|
#SUM(tinyint_col + smallint_col),
|
|
#SUM(tinyint_col) + SUM(smallint_col) + SUM(int_col),
|
|
#SUM(tinyint_col + smallint_col + int_col),
|
|
#SUM(tinyint_col) + SUM(smallint_col) + SUM(int_col) + SUM(bigint_col),
|
|
#SUM(tinyint_col + smallint_col + int_col + bigint_col),
|
|
#SUM(tinyint_col) + SUM(smallint_col) + SUM(int_col) + SUM(bigint_col) + SUM(float_col),
|
|
#SUM(tinyint_col + smallint_col + int_col + bigint_col + float_col),
|
|
#SUM(tinyint_col) + SUM(smallint_col) + SUM(int_col) + SUM(bigint_col) + SUM(float_col) + SUM(double_col),
|
|
#SUM(tinyint_col + smallint_col + int_col + bigint_col + float_col + double_col)
|
|
#from alltypesaggnonulls
|
|
#---- TYPES
|
|
#bigint, bigint, bigint, bigint, bigint, bigint, double, double, double, double
|
|
#---- RESULTS
|
|
#540000,540000,5535000,5535000,55485000,55485000,60979499.99976754,60979499.99976754,111428999.9997675,111428999.9997676
|
|
#====
|
|
## -
|
|
#select
|
|
#-1 * SUM(tinyint_col) - SUM(smallint_col),
|
|
#SUM(-1 * tinyint_col - smallint_col),
|
|
#-1 * SUM(tinyint_col) - SUM(smallint_col) - SUM(int_col),
|
|
#SUM(-1 * tinyint_col - smallint_col - int_col),
|
|
#-1 * SUM(tinyint_col) - SUM(smallint_col) - SUM(int_col) - SUM(bigint_col),
|
|
#SUM(-1 * tinyint_col - smallint_col - int_col - bigint_col),
|
|
#-1 * SUM(tinyint_col) - SUM(smallint_col) - SUM(int_col) - SUM(bigint_col) - SUM(float_col),
|
|
#SUM(-1 * tinyint_col - smallint_col - int_col - bigint_col - float_col),
|
|
#-1 * SUM(tinyint_col) - SUM(smallint_col) - SUM(int_col) - SUM(bigint_col) - SUM(float_col) - SUM(double_col),
|
|
#SUM(-1 * tinyint_col - smallint_col - int_col - bigint_col - float_col - double_col)
|
|
#from alltypesaggnonulls
|
|
#---- TYPES
|
|
#bigint, bigint, bigint, bigint, bigint, bigint, double, double, double, double
|
|
#---- RESULTS
|
|
#-540000,-540000,-5535000,-5535000,-55485000,-55485000,-60979499.99976754,-60979499.99976754,-111428999.9997675,-111428999.9997676
|
|
#====
|
|
# *
|
|
#select
|
|
#MAX(tinyint_col) * MAX(smallint_col),
|
|
#MAX(tinyint_col * smallint_col),
|
|
#MAX(tinyint_col) * MAX(smallint_col) * MAX(int_col),
|
|
#MAX(tinyint_col * smallint_col * int_col),
|
|
#MAX(tinyint_col) * MAX(smallint_col) * MAX(int_col) * MAX(bigint_col),
|
|
#MAX(tinyint_col * smallint_col * int_col * bigint_col),
|
|
#MAX(tinyint_col) * MAX(smallint_col) * MAX(int_col) * MAX(bigint_col) * MAX(float_col),
|
|
#MAX(tinyint_col * smallint_col * int_col * bigint_col * float_col),
|
|
#MAX(tinyint_col) * MAX(smallint_col) * MAX(int_col) * MAX(bigint_col) * MAX(float_col) * MAX(double_col),
|
|
#MAX(tinyint_col * smallint_col * int_col * bigint_col * float_col * double_col)
|
|
#from alltypesaggnonulls
|
|
#---- TYPES
|
|
#bigint, bigint, bigint, bigint, bigint, bigint, double, double, double, double
|
|
#---- RESULTS
|
|
#891,891,890109,890109,8892188910,8892188910,9771626610293.455,9771626610293.455,9.859473533519994e+16,9.859473533519994e+16
|
|
#====
|
|
# LIKE exprs w/ the like/regex pattern coming from a column
|
|
select * from LikeTbl
|
|
---- TYPES
|
|
string, string, string, string, string
|
|
---- RESULTS
|
|
'NULL','%','NULL','.*','X'
|
|
'','%','','.*','X'
|
|
'beginning of line','begin%','not begin%','^begin.*','^not begin.*'
|
|
'eight','%eight%','n%eight%','.*eight.*','n.*eight.*'
|
|
'end of line','%line','%line end','.*line$','.*line end$'
|
|
'five','%five%','n%five%','.*five.*','n.*five.*'
|
|
'four','%four%','n%four%','.*four.*','n.*four.*'
|
|
'middle of line','%of%','%of','^.*of.*$','.*of$'
|
|
'nine','%nine%','n%nine%','.*nine.*','n.*nine.*'
|
|
'one','%one%','n%one%','.*one.*','n.*one.*'
|
|
'seven','%seven%','n%seven%','.*seven.*','n.*seven.*'
|
|
'six','%six%','n%six%','.*six.*','n.*six.*'
|
|
'ten','%ten%','n%ten%','.*ten.*','n.*ten.*'
|
|
'three','%three%','n%three%','.*three.*','n.*three.*'
|
|
'two','%two%','n%two%','.*two.*','n.*two.*'
|
|
====
|
|
---- QUERY
|
|
select str_col, match_like_col from LikeTbl
|
|
where str_col LIKE match_like_col
|
|
---- TYPES
|
|
string, string
|
|
---- RESULTS
|
|
'beginning of line','begin%'
|
|
'eight','%eight%'
|
|
'end of line','%line'
|
|
'five','%five%'
|
|
'four','%four%'
|
|
'middle of line','%of%'
|
|
'nine','%nine%'
|
|
'one','%one%'
|
|
'seven','%seven%'
|
|
'six','%six%'
|
|
'ten','%ten%'
|
|
'three','%three%'
|
|
'two','%two%'
|
|
'','%'
|
|
====
|
|
---- QUERY
|
|
select str_col, match_like_col from LikeTbl
|
|
where str_col NOT LIKE match_like_col
|
|
---- TYPES
|
|
string, string
|
|
---- RESULTS
|
|
====
|
|
---- QUERY
|
|
select str_col, match_like_col from LikeTbl
|
|
where str_col LIKE no_match_like_col
|
|
---- TYPES
|
|
string, string
|
|
---- RESULTS
|
|
'','%'
|
|
====
|
|
---- QUERY
|
|
select str_col, no_match_like_col from LikeTbl
|
|
where str_col NOT LIKE no_match_like_col
|
|
---- TYPES
|
|
string, string
|
|
---- RESULTS
|
|
'beginning of line','not begin%'
|
|
'eight','n%eight%'
|
|
'end of line','%line end'
|
|
'five','n%five%'
|
|
'four','n%four%'
|
|
'middle of line','%of'
|
|
'nine','n%nine%'
|
|
'one','n%one%'
|
|
'seven','n%seven%'
|
|
'six','n%six%'
|
|
'ten','n%ten%'
|
|
'three','n%three%'
|
|
'two','n%two%'
|
|
====
|
|
---- QUERY
|
|
select str_col, match_regex_col from LikeTbl
|
|
where str_col REGEXP match_regex_col
|
|
---- TYPES
|
|
string, string
|
|
---- RESULTS
|
|
'beginning of line','^begin.*'
|
|
'eight','.*eight.*'
|
|
'end of line','.*line$'
|
|
'five','.*five.*'
|
|
'four','.*four.*'
|
|
'middle of line','^.*of.*$'
|
|
'nine','.*nine.*'
|
|
'one','.*one.*'
|
|
'seven','.*seven.*'
|
|
'six','.*six.*'
|
|
'ten','.*ten.*'
|
|
'three','.*three.*'
|
|
'two','.*two.*'
|
|
'','.*'
|
|
====
|
|
---- QUERY
|
|
select str_col, no_match_regex_col from LikeTbl
|
|
where str_col REGEXP no_match_regex_col
|
|
---- TYPES
|
|
string, string
|
|
---- RESULTS
|
|
====
|
|
---- QUERY
|
|
select str_col, match_regex_col from LikeTbl
|
|
where str_col NOT REGEXP match_regex_col
|
|
---- TYPES
|
|
string, string
|
|
---- RESULTS
|
|
====
|
|
---- QUERY
|
|
select str_col, no_match_regex_col from LikeTbl
|
|
where str_col NOT REGEXP no_match_regex_col
|
|
---- TYPES
|
|
string, string
|
|
---- RESULTS
|
|
'beginning of line','^not begin.*'
|
|
'eight','n.*eight.*'
|
|
'end of line','.*line end$'
|
|
'five','n.*five.*'
|
|
'four','n.*four.*'
|
|
'middle of line','.*of$'
|
|
'nine','n.*nine.*'
|
|
'one','n.*one.*'
|
|
'seven','n.*seven.*'
|
|
'six','n.*six.*'
|
|
'ten','n.*ten.*'
|
|
'three','n.*three.*'
|
|
'two','n.*two.*'
|
|
'','X'
|
|
====
|
|
---- QUERY
|
|
select 1+2
|
|
---- TYPES
|
|
smallint
|
|
---- RESULTS
|
|
3
|
|
====
|
|
---- QUERY
|
|
select timestamp_col, to_date(timestamp_col), year(timestamp_col), month(timestamp_col),
|
|
dayofmonth(timestamp_col), dayofyear(timestamp_col), weekofyear(timestamp_col),
|
|
hour(timestamp_col), minute(timestamp_col), second(timestamp_col)
|
|
from alltypessmall
|
|
---- TYPES
|
|
timestamp, string, int, int, int, int, int, int, int, int
|
|
---- RESULTS
|
|
2009-01-01 00:00:00,'2009-01-01',2009,1,1,1,1,0,0,0
|
|
2009-01-01 00:01:00,'2009-01-01',2009,1,1,1,1,0,1,0
|
|
2009-01-01 00:02:00.100000000,'2009-01-01',2009,1,1,1,1,0,2,0
|
|
2009-01-01 00:03:00.300000000,'2009-01-01',2009,1,1,1,1,0,3,0
|
|
2009-01-01 00:04:00.600000000,'2009-01-01',2009,1,1,1,1,0,4,0
|
|
2009-01-01 00:05:00.100000000,'2009-01-01',2009,1,1,1,1,0,5,0
|
|
2009-01-01 00:06:00.150000000,'2009-01-01',2009,1,1,1,1,0,6,0
|
|
2009-01-01 00:07:00.210000000,'2009-01-01',2009,1,1,1,1,0,7,0
|
|
2009-01-01 00:08:00.280000000,'2009-01-01',2009,1,1,1,1,0,8,0
|
|
2009-01-01 00:09:00.360000000,'2009-01-01',2009,1,1,1,1,0,9,0
|
|
2009-01-02 00:10:00.450000000,'2009-01-02',2009,1,2,2,1,0,10,0
|
|
2009-01-02 00:11:00.450000000,'2009-01-02',2009,1,2,2,1,0,11,0
|
|
2009-01-02 00:12:00.460000000,'2009-01-02',2009,1,2,2,1,0,12,0
|
|
2009-01-02 00:13:00.480000000,'2009-01-02',2009,1,2,2,1,0,13,0
|
|
2009-01-02 00:14:00.510000000,'2009-01-02',2009,1,2,2,1,0,14,0
|
|
2009-01-02 00:15:00.550000000,'2009-01-02',2009,1,2,2,1,0,15,0
|
|
2009-01-02 00:16:00.600000000,'2009-01-02',2009,1,2,2,1,0,16,0
|
|
2009-01-02 00:17:00.660000000,'2009-01-02',2009,1,2,2,1,0,17,0
|
|
2009-01-02 00:18:00.730000000,'2009-01-02',2009,1,2,2,1,0,18,0
|
|
2009-01-02 00:19:00.810000000,'2009-01-02',2009,1,2,2,1,0,19,0
|
|
2009-01-03 00:20:00.900000000,'2009-01-03',2009,1,3,3,1,0,20,0
|
|
2009-01-03 00:21:00.900000000,'2009-01-03',2009,1,3,3,1,0,21,0
|
|
2009-01-03 00:22:00.910000000,'2009-01-03',2009,1,3,3,1,0,22,0
|
|
2009-01-03 00:23:00.930000000,'2009-01-03',2009,1,3,3,1,0,23,0
|
|
2009-01-03 00:24:00.960000000,'2009-01-03',2009,1,3,3,1,0,24,0
|
|
2009-02-01 00:00:00,'2009-02-01',2009,2,1,32,5,0,0,0
|
|
2009-02-01 00:01:00,'2009-02-01',2009,2,1,32,5,0,1,0
|
|
2009-02-01 00:02:00.100000000,'2009-02-01',2009,2,1,32,5,0,2,0
|
|
2009-02-01 00:03:00.300000000,'2009-02-01',2009,2,1,32,5,0,3,0
|
|
2009-02-01 00:04:00.600000000,'2009-02-01',2009,2,1,32,5,0,4,0
|
|
2009-02-01 00:05:00.100000000,'2009-02-01',2009,2,1,32,5,0,5,0
|
|
2009-02-01 00:06:00.150000000,'2009-02-01',2009,2,1,32,5,0,6,0
|
|
2009-02-01 00:07:00.210000000,'2009-02-01',2009,2,1,32,5,0,7,0
|
|
2009-02-01 00:08:00.280000000,'2009-02-01',2009,2,1,32,5,0,8,0
|
|
2009-02-01 00:09:00.360000000,'2009-02-01',2009,2,1,32,5,0,9,0
|
|
2009-02-02 00:10:00.450000000,'2009-02-02',2009,2,2,33,6,0,10,0
|
|
2009-02-02 00:11:00.450000000,'2009-02-02',2009,2,2,33,6,0,11,0
|
|
2009-02-02 00:12:00.460000000,'2009-02-02',2009,2,2,33,6,0,12,0
|
|
2009-02-02 00:13:00.480000000,'2009-02-02',2009,2,2,33,6,0,13,0
|
|
2009-02-02 00:14:00.510000000,'2009-02-02',2009,2,2,33,6,0,14,0
|
|
2009-02-02 00:15:00.550000000,'2009-02-02',2009,2,2,33,6,0,15,0
|
|
2009-02-02 00:16:00.600000000,'2009-02-02',2009,2,2,33,6,0,16,0
|
|
2009-02-02 00:17:00.660000000,'2009-02-02',2009,2,2,33,6,0,17,0
|
|
2009-02-02 00:18:00.730000000,'2009-02-02',2009,2,2,33,6,0,18,0
|
|
2009-02-02 00:19:00.810000000,'2009-02-02',2009,2,2,33,6,0,19,0
|
|
2009-02-03 00:20:00.900000000,'2009-02-03',2009,2,3,34,6,0,20,0
|
|
2009-02-03 00:21:00.900000000,'2009-02-03',2009,2,3,34,6,0,21,0
|
|
2009-02-03 00:22:00.910000000,'2009-02-03',2009,2,3,34,6,0,22,0
|
|
2009-02-03 00:23:00.930000000,'2009-02-03',2009,2,3,34,6,0,23,0
|
|
2009-02-03 00:24:00.960000000,'2009-02-03',2009,2,3,34,6,0,24,0
|
|
2009-03-01 00:00:00,'2009-03-01',2009,3,1,60,9,0,0,0
|
|
2009-03-01 00:01:00,'2009-03-01',2009,3,1,60,9,0,1,0
|
|
2009-03-01 00:02:00.100000000,'2009-03-01',2009,3,1,60,9,0,2,0
|
|
2009-03-01 00:03:00.300000000,'2009-03-01',2009,3,1,60,9,0,3,0
|
|
2009-03-01 00:04:00.600000000,'2009-03-01',2009,3,1,60,9,0,4,0
|
|
2009-03-01 00:05:00.100000000,'2009-03-01',2009,3,1,60,9,0,5,0
|
|
2009-03-01 00:06:00.150000000,'2009-03-01',2009,3,1,60,9,0,6,0
|
|
2009-03-01 00:07:00.210000000,'2009-03-01',2009,3,1,60,9,0,7,0
|
|
2009-03-01 00:08:00.280000000,'2009-03-01',2009,3,1,60,9,0,8,0
|
|
2009-03-01 00:09:00.360000000,'2009-03-01',2009,3,1,60,9,0,9,0
|
|
2009-03-02 00:10:00.450000000,'2009-03-02',2009,3,2,61,10,0,10,0
|
|
2009-03-02 00:11:00.450000000,'2009-03-02',2009,3,2,61,10,0,11,0
|
|
2009-03-02 00:12:00.460000000,'2009-03-02',2009,3,2,61,10,0,12,0
|
|
2009-03-02 00:13:00.480000000,'2009-03-02',2009,3,2,61,10,0,13,0
|
|
2009-03-02 00:14:00.510000000,'2009-03-02',2009,3,2,61,10,0,14,0
|
|
2009-03-02 00:15:00.550000000,'2009-03-02',2009,3,2,61,10,0,15,0
|
|
2009-03-02 00:16:00.600000000,'2009-03-02',2009,3,2,61,10,0,16,0
|
|
2009-03-02 00:17:00.660000000,'2009-03-02',2009,3,2,61,10,0,17,0
|
|
2009-03-02 00:18:00.730000000,'2009-03-02',2009,3,2,61,10,0,18,0
|
|
2009-03-02 00:19:00.810000000,'2009-03-02',2009,3,2,61,10,0,19,0
|
|
2009-03-03 00:20:00.900000000,'2009-03-03',2009,3,3,62,10,0,20,0
|
|
2009-03-03 00:21:00.900000000,'2009-03-03',2009,3,3,62,10,0,21,0
|
|
2009-03-03 00:22:00.910000000,'2009-03-03',2009,3,3,62,10,0,22,0
|
|
2009-03-03 00:23:00.930000000,'2009-03-03',2009,3,3,62,10,0,23,0
|
|
2009-03-03 00:24:00.960000000,'2009-03-03',2009,3,3,62,10,0,24,0
|
|
2009-04-01 00:00:00,'2009-04-01',2009,4,1,91,14,0,0,0
|
|
2009-04-01 00:01:00,'2009-04-01',2009,4,1,91,14,0,1,0
|
|
2009-04-01 00:02:00.100000000,'2009-04-01',2009,4,1,91,14,0,2,0
|
|
2009-04-01 00:03:00.300000000,'2009-04-01',2009,4,1,91,14,0,3,0
|
|
2009-04-01 00:04:00.600000000,'2009-04-01',2009,4,1,91,14,0,4,0
|
|
2009-04-01 00:05:00.100000000,'2009-04-01',2009,4,1,91,14,0,5,0
|
|
2009-04-01 00:06:00.150000000,'2009-04-01',2009,4,1,91,14,0,6,0
|
|
2009-04-01 00:07:00.210000000,'2009-04-01',2009,4,1,91,14,0,7,0
|
|
2009-04-01 00:08:00.280000000,'2009-04-01',2009,4,1,91,14,0,8,0
|
|
2009-04-01 00:09:00.360000000,'2009-04-01',2009,4,1,91,14,0,9,0
|
|
2009-04-02 00:10:00.450000000,'2009-04-02',2009,4,2,92,14,0,10,0
|
|
2009-04-02 00:11:00.450000000,'2009-04-02',2009,4,2,92,14,0,11,0
|
|
2009-04-02 00:12:00.460000000,'2009-04-02',2009,4,2,92,14,0,12,0
|
|
2009-04-02 00:13:00.480000000,'2009-04-02',2009,4,2,92,14,0,13,0
|
|
2009-04-02 00:14:00.510000000,'2009-04-02',2009,4,2,92,14,0,14,0
|
|
2009-04-02 00:15:00.550000000,'2009-04-02',2009,4,2,92,14,0,15,0
|
|
2009-04-02 00:16:00.600000000,'2009-04-02',2009,4,2,92,14,0,16,0
|
|
2009-04-02 00:17:00.660000000,'2009-04-02',2009,4,2,92,14,0,17,0
|
|
2009-04-02 00:18:00.730000000,'2009-04-02',2009,4,2,92,14,0,18,0
|
|
2009-04-02 00:19:00.810000000,'2009-04-02',2009,4,2,92,14,0,19,0
|
|
2009-04-03 00:20:00.900000000,'2009-04-03',2009,4,3,93,14,0,20,0
|
|
2009-04-03 00:21:00.900000000,'2009-04-03',2009,4,3,93,14,0,21,0
|
|
2009-04-03 00:22:00.910000000,'2009-04-03',2009,4,3,93,14,0,22,0
|
|
2009-04-03 00:23:00.930000000,'2009-04-03',2009,4,3,93,14,0,23,0
|
|
2009-04-03 00:24:00.960000000,'2009-04-03',2009,4,3,93,14,0,24,0
|
|
====
|
|
---- QUERY
|
|
# IN predicate
|
|
select NULL in (1, 2, 3)
|
|
---- TYPES
|
|
boolean
|
|
---- RESULTS
|
|
NULL
|
|
====
|
|
---- QUERY
|
|
select NULL in (1, NULL, 3)
|
|
---- TYPES
|
|
boolean
|
|
---- RESULTS
|
|
NULL
|
|
====
|
|
---- QUERY
|
|
select 1 in (2, NULL, 1)
|
|
---- TYPES
|
|
boolean
|
|
---- RESULTS
|
|
true
|
|
====
|
|
---- QUERY
|
|
select 1 in (1, NULL, 2)
|
|
---- TYPES
|
|
boolean
|
|
---- RESULTS
|
|
true
|
|
====
|
|
---- QUERY
|
|
select 1 in (2, NULL, 3)
|
|
---- TYPES
|
|
boolean
|
|
---- RESULTS
|
|
NULL
|
|
====
|
|
---- QUERY
|
|
select 1 in (2, 3, 4)
|
|
---- TYPES
|
|
boolean
|
|
---- RESULTS
|
|
false
|
|
====
|
|
---- QUERY
|
|
select NULL not in (1, 2, 3)
|
|
---- TYPES
|
|
boolean
|
|
---- RESULTS
|
|
NULL
|
|
====
|
|
---- QUERY
|
|
select NULL not in (1, NULL, 3)
|
|
----
|
|
boolean
|
|
---- RESULTS
|
|
NULL
|
|
====
|
|
---- QUERY
|
|
select 1 not in (2, NULL, 1)
|
|
---- TYPES
|
|
boolean
|
|
---- RESULTS
|
|
false
|
|
====
|
|
---- QUERY
|
|
select 1 not in (1, NULL, 2)
|
|
---- TYPES
|
|
boolean
|
|
---- RESULTS
|
|
false
|
|
====
|
|
---- QUERY
|
|
select 1 not in (2, NULL, 3)
|
|
---- TYPES
|
|
boolean
|
|
---- RESULTS
|
|
NULL
|
|
====
|
|
---- QUERY
|
|
select 1 not in (2, 3, 4)
|
|
---- TYPES
|
|
boolean
|
|
---- RESULTS
|
|
true
|
|
====
|
|
---- QUERY
|
|
# IN predicate with NULLs and other types
|
|
select NULL in ('a', NULL, 'b')
|
|
---- TYPES
|
|
boolean
|
|
---- RESULTS
|
|
NULL
|
|
====
|
|
---- QUERY
|
|
select NULL not in ('a', NULL, 'b')
|
|
---- TYPES
|
|
boolean
|
|
---- RESULTS
|
|
NULL
|
|
====
|
|
---- QUERY
|
|
select NULL not in (1.0, NULL, 2.0)
|
|
---- TYPES
|
|
boolean
|
|
---- RESULTS
|
|
NULL
|
|
====
|
|
---- QUERY
|
|
select NULL in (1.0, NULL, 2.0)
|
|
---- TYPES
|
|
boolean
|
|
---- RESULTS
|
|
NULL
|
|
====
|
|
---- QUERY
|
|
select NULL in (true, NULL, false)
|
|
---- TYPES
|
|
boolean
|
|
---- RESULTS
|
|
NULL
|
|
====
|
|
---- QUERY
|
|
select NULL not in (true, NULL, false)
|
|
---- TYPES
|
|
boolean
|
|
---- RESULTS
|
|
NULL
|
|
====
|
|
---- QUERY
|
|
select true in (NULL, false)
|
|
---- TYPES
|
|
boolean
|
|
---- RESULTS
|
|
NULL
|
|
====
|
|
---- QUERY
|
|
select true not in (NULL, false)
|
|
---- TYPES
|
|
boolean
|
|
---- RESULTS
|
|
NULL
|
|
====
|
|
---- QUERY
|
|
select count(*) from alltypesagg
|
|
where true in (bool_col, tinyint_col)
|
|
---- TYPES
|
|
bigint
|
|
---- RESULTS
|
|
6000
|
|
====
|
|
---- QUERY
|
|
select count(*) from alltypesagg
|
|
where true not in (bool_col, tinyint_col)
|
|
---- TYPES
|
|
bigint
|
|
---- RESULTS
|
|
4000
|
|
====
|
|
---- QUERY
|
|
select count(*) from alltypesagg
|
|
where 1 in (tinyint_col, smallint_col, int_col, bigint_col)
|
|
---- TYPES
|
|
bigint
|
|
---- RESULTS
|
|
1000
|
|
====
|
|
---- QUERY
|
|
select count(*) from alltypesagg
|
|
where 1 not in (tinyint_col, smallint_col, int_col, bigint_col)
|
|
---- TYPES
|
|
bigint
|
|
---- RESULTS
|
|
8000
|
|
====
|
|
---- QUERY
|
|
select count(*) from alltypesagg
|
|
where 10.1 in (tinyint_col, smallint_col, int_col, bigint_col, float_col, double_col)
|
|
---- TYPES
|
|
bigint
|
|
---- RESULTS
|
|
10
|
|
====
|
|
---- QUERY
|
|
select count(*) from alltypesagg
|
|
where 10.1 not in (tinyint_col, smallint_col, int_col, bigint_col, float_col, double_col)
|
|
---- TYPES
|
|
bigint
|
|
---- RESULTS
|
|
8990
|
|
====
|
|
---- QUERY
|
|
select count(*) from alltypesagg
|
|
where '01/01/10' in (date_string_col, string_col, 'abc')
|
|
---- TYPES
|
|
bigint
|
|
---- RESULTS
|
|
1000
|
|
====
|
|
---- QUERY
|
|
select count(*) from alltypesagg
|
|
where '01/01/10' not in (date_string_col, string_col, 'abc')
|
|
---- TYPES
|
|
bigint
|
|
---- RESULTS
|
|
9000
|
|
====
|
|
---- QUERY
|
|
select count(*) from alltypesagg
|
|
where cast('2010-01-01 00:00:00' as timestamp) in (timestamp_col)
|
|
---- TYPES
|
|
bigint
|
|
---- RESULTS
|
|
1
|
|
====
|
|
---- QUERY
|
|
select count(*) from alltypesagg
|
|
where cast('2010-01-01 00:00:00' as timestamp) not in (timestamp_col)
|
|
---- TYPES
|
|
bigint
|
|
---- RESULTS
|
|
9999
|
|
====
|
|
---- QUERY
|
|
# BETWEEN predicate
|
|
select count(*) from alltypesagg where tinyint_col between 1 and 2
|
|
---- TYPES
|
|
bigint
|
|
---- RESULTS
|
|
2000
|
|
====
|
|
---- QUERY
|
|
select count(*) from alltypesagg where tinyint_col not between 1 and 2
|
|
---- TYPES
|
|
bigint
|
|
---- RESULTS
|
|
7000
|
|
====
|
|
---- QUERY
|
|
select count(*) from alltypesagg where smallint_col between 1 and 20
|
|
---- TYPES
|
|
bigint
|
|
---- RESULTS
|
|
2000
|
|
====
|
|
---- QUERY
|
|
select count(*) from alltypesagg where smallint_col not between 1 and 20
|
|
---- TYPES
|
|
bigint
|
|
---- RESULTS
|
|
7900
|
|
====
|
|
---- QUERY
|
|
select count(*) from alltypesagg where int_col between 1 and 200
|
|
---- TYPES
|
|
bigint
|
|
---- RESULTS
|
|
2000
|
|
====
|
|
---- QUERY
|
|
select count(*) from alltypesagg where int_col not between 1 and 200
|
|
---- TYPES
|
|
bigint
|
|
---- RESULTS
|
|
7990
|
|
====
|
|
---- QUERY
|
|
select count(*) from alltypesagg where bigint_col between 1 and 2000
|
|
---- TYPES
|
|
bigint
|
|
---- RESULTS
|
|
2000
|
|
====
|
|
---- QUERY
|
|
select count(*) from alltypesagg where bigint_col not between 1 and 2000
|
|
---- TYPES
|
|
bigint
|
|
---- RESULTS
|
|
7990
|
|
====
|
|
---- QUERY
|
|
select count(*) from alltypesagg
|
|
where float_col between cast(1.0 as float) and cast(110.0 as float)
|
|
---- TYPES
|
|
bigint
|
|
---- RESULTS
|
|
1000
|
|
====
|
|
---- QUERY
|
|
select count(*) from alltypesagg
|
|
where float_col not between cast(1.0 as float) and cast(110.0 as float)
|
|
---- TYPES
|
|
bigint
|
|
---- RESULTS
|
|
8990
|
|
====
|
|
---- QUERY
|
|
select count(*) from alltypesagg where double_col between 1.0 and 110.0
|
|
---- TYPES
|
|
bigint
|
|
---- RESULTS
|
|
100
|
|
====
|
|
---- QUERY
|
|
select count(*) from alltypesagg where double_col not between 1.0 and 110.0
|
|
---- TYPES
|
|
bigint
|
|
---- RESULTS
|
|
9890
|
|
====
|
|
---- QUERY
|
|
select count(*) from alltypesagg where date_string_col
|
|
between '01/01/10' and '01/05/10'
|
|
---- TYPES
|
|
bigint
|
|
---- RESULTS
|
|
5000
|
|
====
|
|
---- QUERY
|
|
select count(*) from alltypesagg where date_string_col
|
|
not between '01/01/10' and '01/05/10'
|
|
---- TYPES
|
|
bigint
|
|
---- RESULTS
|
|
5000
|
|
====
|
|
---- QUERY
|
|
select count(*) from alltypesagg where timestamp_col
|
|
between cast('2010-01-01 00:00:00' as timestamp)
|
|
and cast('2010-01-01 01:40:00' as timestamp)
|
|
---- TYPES
|
|
bigint
|
|
---- RESULTS
|
|
100
|
|
====
|
|
---- QUERY
|
|
select count(*) from alltypesagg where timestamp_col
|
|
not between cast('2010-01-01 00:00:00' as timestamp)
|
|
and cast('2010-01-01 01:40:00' as timestamp)
|
|
---- TYPES
|
|
bigint
|
|
---- RESULTS
|
|
9900
|
|
====
|
|
---- QUERY
|
|
# Test NOW() function.
|
|
select now()
|
|
---- TYPES
|
|
timestamp
|
|
---- RESULTS
|
|
# Matches a single date of the form 'yyyy-MM-dd HH:mm:ss'
|
|
# or 'yyyy-MM-dd HH:mm:ss.SSSSSS'
|
|
row_regex: \d{4}-\d{2}-\d{2}\s\d{2}:\d{2}:\d{2}(\.\d{9})?
|
|
====
|
|
---- QUERY
|
|
select now(), now(), now(), now()
|
|
---- TYPES
|
|
timestamp, timestamp, timestamp, timestamp
|
|
---- RESULTS
|
|
# Matches four identical timestamps separated by commas.
|
|
row_regex: (\d{4}-\d{2}-\d{2}\s\d{2}:\d{2}:\d{2}(\.\d{9})?),\1,\1,\1
|
|
====
|
|
---- QUERY
|
|
select now(), now(), now(), now() from alltypestiny
|
|
---- TYPES
|
|
timestamp, timestamp, timestamp, timestamp
|
|
---- RESULTS
|
|
# Matches four identical timestamps separated by commas.
|
|
row_regex: (\d{4}-\d{2}-\d{2}\s\d{2}:\d{2}:\d{2}(\.\d{9})?),\1,\1,\1
|
|
row_regex: (\d{4}-\d{2}-\d{2}\s\d{2}:\d{2}:\d{2}(\.\d{9})?),\1,\1,\1
|
|
row_regex: (\d{4}-\d{2}-\d{2}\s\d{2}:\d{2}:\d{2}(\.\d{9})?),\1,\1,\1
|
|
row_regex: (\d{4}-\d{2}-\d{2}\s\d{2}:\d{2}:\d{2}(\.\d{9})?),\1,\1,\1
|
|
row_regex: (\d{4}-\d{2}-\d{2}\s\d{2}:\d{2}:\d{2}(\.\d{9})?),\1,\1,\1
|
|
row_regex: (\d{4}-\d{2}-\d{2}\s\d{2}:\d{2}:\d{2}(\.\d{9})?),\1,\1,\1
|
|
row_regex: (\d{4}-\d{2}-\d{2}\s\d{2}:\d{2}:\d{2}(\.\d{9})?),\1,\1,\1
|
|
row_regex: (\d{4}-\d{2}-\d{2}\s\d{2}:\d{2}:\d{2}(\.\d{9})?),\1,\1,\1
|
|
====
|
|
---- QUERY
|
|
# Check that now() returns the same value when evaluated on different nodes
|
|
# (alltypessmall is partitioned)
|
|
select min(now()), max(now()) from alltypessmall
|
|
---- TYPES
|
|
timestamp, timestamp
|
|
---- RESULTS
|
|
# Matches two identical timestamps separated by commas.
|
|
row_regex: (\d{4}-\d{2}-\d{2}\s\d{2}:\d{2}:\d{2}(\.\d{9})?),\1
|
|
====
|
|
---- QUERY
|
|
# Timestamp arithmetic tests (lowest timestamp_col has value 2009-01-01 00:00:00).
|
|
# Add/sub years, non-function-call like version.
|
|
select timestamp_col + interval 10 years,
|
|
interval 10 years + timestamp_col,
|
|
timestamp_col - interval 10 years
|
|
from alltypes order by id limit 1
|
|
---- TYPES
|
|
timestamp,timestamp,timestamp
|
|
---- RESULTS
|
|
2019-01-01 00:00:00,2019-01-01 00:00:00,1999-01-01 00:00:00
|
|
====
|
|
---- QUERY
|
|
# Add/sub years, function-call like version.
|
|
select date_add(timestamp_col, interval 10 years),
|
|
date_sub(timestamp_col, interval 10 years)
|
|
from alltypes order by id limit 1
|
|
---- TYPES
|
|
timestamp,timestamp
|
|
---- RESULTS
|
|
2019-01-01 00:00:00,1999-01-01 00:00:00
|
|
====
|
|
---- QUERY
|
|
# Add/sub months, non-function-call like version.
|
|
select timestamp_col + interval 13 months,
|
|
timestamp_col + interval 1 month,
|
|
interval 13 months + timestamp_col,
|
|
interval 1 month + timestamp_col,
|
|
timestamp_col - interval 13 months,
|
|
timestamp_col - interval 1 month
|
|
from alltypes order by id limit 1
|
|
---- TYPES
|
|
timestamp,timestamp,timestamp,timestamp,timestamp,timestamp
|
|
---- RESULTS
|
|
2010-02-01 00:00:00,2009-02-01 00:00:00,2010-02-01 00:00:00,2009-02-01 00:00:00,2007-12-01 00:00:00,2008-12-01 00:00:00
|
|
====
|
|
---- QUERY
|
|
# Add/sub months, function-call like version.
|
|
select date_add(timestamp_col, interval 13 months),
|
|
date_add(timestamp_col, interval 1 month),
|
|
date_sub(timestamp_col, interval 13 months),
|
|
date_sub(timestamp_col, interval 1 month)
|
|
from alltypes order by id limit 1
|
|
---- TYPES
|
|
timestamp,timestamp,timestamp,timestamp
|
|
---- RESULTS
|
|
2010-02-01 00:00:00,2009-02-01 00:00:00,2007-12-01 00:00:00,2008-12-01 00:00:00
|
|
====
|
|
---- QUERY
|
|
# Add/sub weeks, non-function-call like version.
|
|
select timestamp_col + interval 2 weeks,
|
|
timestamp_col + interval 53 weeks,
|
|
interval 2 weeks + timestamp_col,
|
|
interval 53 weeks + timestamp_col,
|
|
timestamp_col - interval 2 weeks,
|
|
timestamp_col - interval 53 weeks
|
|
from alltypes order by id limit 1
|
|
---- TYPES
|
|
timestamp,timestamp,timestamp,timestamp,timestamp,timestamp
|
|
---- RESULTS
|
|
2009-01-15 00:00:00,2010-01-07 00:00:00,2009-01-15 00:00:00,2010-01-07 00:00:00,2008-12-18 00:00:00,2007-12-27 00:00:00
|
|
====
|
|
---- QUERY
|
|
# Add/sub weeks, function-call like version.
|
|
select date_add(timestamp_col, interval 2 weeks),
|
|
date_add(timestamp_col, interval 53 weeks),
|
|
date_sub(timestamp_col, interval 2 weeks),
|
|
date_sub(timestamp_col, interval 53 weeks)
|
|
from alltypes order by id limit 1
|
|
---- TYPES
|
|
timestamp,timestamp,timestamp,timestamp
|
|
---- RESULTS
|
|
2009-01-15 00:00:00,2010-01-07 00:00:00,2008-12-18 00:00:00,2007-12-27 00:00:00
|
|
====
|
|
---- QUERY
|
|
# Add/sub days, non-function-call like version.
|
|
select timestamp_col + interval 10 days,
|
|
timestamp_col + interval 10 days,
|
|
interval 10 days + timestamp_col,
|
|
interval 10 days + timestamp_col,
|
|
timestamp_col - interval 10 days,
|
|
timestamp_col - interval 365 days
|
|
from alltypes order by id limit 1
|
|
---- TYPES
|
|
timestamp,timestamp,timestamp,timestamp,timestamp,timestamp
|
|
---- RESULTS
|
|
2009-01-11 00:00:00,2009-01-11 00:00:00,2009-01-11 00:00:00,2009-01-11 00:00:00,2008-12-22 00:00:00,2008-01-02 00:00:00
|
|
====
|
|
---- QUERY
|
|
# Add/sub days, function-call like version.
|
|
select date_add(timestamp_col, interval 10 days),
|
|
date_add(timestamp_col, interval 10 days),
|
|
date_sub(timestamp_col, interval 10 days),
|
|
date_sub(timestamp_col, interval 365 days)
|
|
from alltypes order by id limit 1
|
|
---- TYPES
|
|
timestamp,timestamp,timestamp,timestamp
|
|
---- RESULTS
|
|
2009-01-11 00:00:00,2009-01-11 00:00:00,2008-12-22 00:00:00,2008-01-02 00:00:00
|
|
====
|
|
---- QUERY
|
|
# Add/sub hours, non-function-call like version.
|
|
select timestamp_col + interval 25 hours,
|
|
interval 25 hours + timestamp_col,
|
|
timestamp_col - interval 25 hours
|
|
from alltypes order by id limit 1
|
|
---- TYPES
|
|
timestamp,timestamp,timestamp
|
|
---- RESULTS
|
|
2009-01-02 01:00:00,2009-01-02 01:00:00,2008-12-30 23:00:00
|
|
====
|
|
---- QUERY
|
|
# Add/sub hours, function-call like version.
|
|
select date_add(timestamp_col, interval 25 hours),
|
|
date_sub(timestamp_col, interval 25 hours)
|
|
from alltypes order by id limit 1
|
|
---- TYPES
|
|
timestamp,timestamp
|
|
---- RESULTS
|
|
2009-01-02 01:00:00,2008-12-30 23:00:00
|
|
====
|
|
---- QUERY
|
|
# Add/sub minutes (1533 minutes are 25h33m), non-function-call like version.
|
|
select timestamp_col + interval 1533 minutes,
|
|
interval 1533 minutes + timestamp_col,
|
|
timestamp_col - interval 1533 minutes
|
|
from alltypes order by id limit 1
|
|
---- TYPES
|
|
timestamp,timestamp,timestamp
|
|
---- RESULTS
|
|
2009-01-02 01:33:00,2009-01-02 01:33:00,2008-12-30 22:27:00
|
|
====
|
|
---- QUERY
|
|
# Add/sub minutes (1533 minutes are 25h33m), function-call like version.
|
|
select date_add(timestamp_col, interval 1533 minutes),
|
|
date_sub(timestamp_col, interval 1533 minutes)
|
|
from alltypes order by id limit 1
|
|
---- TYPES
|
|
timestamp,timestamp
|
|
---- RESULTS
|
|
2009-01-02 01:33:00,2008-12-30 22:27:00
|
|
====
|
|
---- QUERY
|
|
# Add/sub seconds (90033 seconds are 25h33s), non-function-call like version.
|
|
select timestamp_col + interval 90033 seconds,
|
|
interval 90033 seconds + timestamp_col,
|
|
timestamp_col - interval 90033 seconds
|
|
from alltypes order by id limit 1
|
|
---- TYPES
|
|
timestamp,timestamp,timestamp
|
|
---- RESULTS
|
|
2009-01-02 01:00:33,2009-01-02 01:00:33,2008-12-30 22:59:27
|
|
====
|
|
---- QUERY
|
|
# Add/sub seconds (90033 seconds are 25h33s), function-call like version.
|
|
select date_add(timestamp_col, interval 90033 seconds),
|
|
date_sub(timestamp_col, interval 90033 seconds)
|
|
from alltypes order by id limit 1
|
|
---- TYPES
|
|
timestamp,timestamp
|
|
---- RESULTS
|
|
2009-01-02 01:00:33,2008-12-30 22:59:27
|
|
====
|
|
---- QUERY
|
|
# Add/sub milliseconds (90000033 seconds are 25h33ms), non-function-call like version.
|
|
select timestamp_col + interval 90000033 milliseconds,
|
|
interval 90000033 milliseconds + timestamp_col,
|
|
timestamp_col - interval 90000033 milliseconds
|
|
from alltypes order by id limit 1
|
|
---- TYPES
|
|
timestamp,timestamp,timestamp
|
|
---- RESULTS
|
|
2009-01-02 01:00:00.033000000,2009-01-02 01:00:00.033000000,2008-12-30 22:59:59.967000000
|
|
====
|
|
---- QUERY
|
|
# Add/sub milliseconds (90000033 seconds are 25h33ms), function-call like version.
|
|
select date_add(timestamp_col, interval 90000033 milliseconds),
|
|
date_sub(timestamp_col, interval 90000033 milliseconds)
|
|
from alltypes order by id limit 1
|
|
---- TYPES
|
|
timestamp,timestamp
|
|
---- RESULTS
|
|
2009-01-02 01:00:00.033000000,2008-12-30 22:59:59.967000000
|
|
====
|
|
---- QUERY
|
|
# Add/sub microseconds, non-function-call like version.
|
|
select timestamp_col + interval 1033 microseconds,
|
|
interval 1033 microseconds + timestamp_col,
|
|
timestamp_col - interval 1033 microseconds
|
|
from alltypes order by id limit 1
|
|
---- TYPES
|
|
timestamp,timestamp,timestamp
|
|
---- RESULTS
|
|
2009-01-01 00:00:00.001033000,2009-01-01 00:00:00.001033000,2008-12-31 23:59:59.998967000
|
|
====
|
|
---- QUERY
|
|
# Add/sub microseconds, function-call like version.
|
|
select date_add(timestamp_col, interval 1033 microseconds),
|
|
date_sub(timestamp_col, interval 1033 microseconds)
|
|
from alltypes order by id limit 1
|
|
---- TYPES
|
|
timestamp,timestamp
|
|
---- RESULTS
|
|
2009-01-01 00:00:00.001033000,2008-12-31 23:59:59.998967000
|
|
====
|
|
---- QUERY
|
|
# Add/sub nanoseconds, non-function-call like version.
|
|
select timestamp_col + interval 1033 nanoseconds,
|
|
interval 1033 nanoseconds + timestamp_col,
|
|
timestamp_col - interval 1033 nanoseconds
|
|
from alltypes order by id limit 1
|
|
---- TYPES
|
|
timestamp,timestamp,timestamp
|
|
---- RESULTS
|
|
2009-01-01 00:00:00.000001033,2009-01-01 00:00:00.000001033,2008-12-31 23:59:59.999998967
|
|
====
|
|
---- QUERY
|
|
# Add/sub nanoseconds, function-call like version.
|
|
select date_add(timestamp_col, interval 1033 nanoseconds),
|
|
date_sub(timestamp_col, interval 1033 nanoseconds)
|
|
from alltypes order by id limit 1
|
|
---- TYPES
|
|
timestamp,timestamp
|
|
---- RESULTS
|
|
2009-01-01 00:00:00.000001033,2008-12-31 23:59:59.999998967
|
|
====
|
|
---- QUERY
|
|
# Chaining of arithmetic operations (only non-function-call like version).
|
|
select timestamp_col + interval 10 years + interval 2 months + interval 5 days,
|
|
interval 10 years + timestamp_col + interval 2 months + interval 5 days,
|
|
timestamp_col + interval 10 years - interval 2 months + interval 5 days,
|
|
interval 10 years + timestamp_col - interval 2 months + interval 5 days,
|
|
timestamp_col - interval 10 years - interval 2 months - interval 5 days
|
|
from alltypes order by id limit 1
|
|
---- TYPES
|
|
timestamp,timestamp,timestamp,timestamp,timestamp
|
|
---- RESULTS
|
|
2019-03-06 00:00:00,2019-03-06 00:00:00,2018-11-06 00:00:00,2018-11-06 00:00:00,1998-10-27 00:00:00
|
|
====
|
|
---- QUERY
|
|
select timestamp_col + interval 10 hours + interval 2 minutes + interval 5 seconds
|
|
+ interval 3 milliseconds + interval 3 microseconds + interval 3 nanoseconds,
|
|
interval 10 hours + timestamp_col + interval 2 minutes + interval 5 seconds
|
|
+ interval 3 milliseconds + interval 3 microseconds + interval 3 nanoseconds,
|
|
timestamp_col + interval 10 hours - interval 2 minutes + interval 5 seconds
|
|
- interval 3 milliseconds + interval 3 microseconds - interval 3 nanoseconds,
|
|
interval 10 hours + timestamp_col + interval 2 minutes + interval 5 seconds
|
|
- interval 3 milliseconds + interval 3 microseconds - interval 3 nanoseconds,
|
|
timestamp_col - interval 10 hours - interval 2 minutes - interval 5 seconds
|
|
- interval 3 milliseconds - interval 3 microseconds - interval 3 nanoseconds
|
|
from alltypes order by id limit 1
|
|
---- TYPES
|
|
timestamp,timestamp,timestamp,timestamp,timestamp
|
|
---- RESULTS
|
|
2009-01-01 10:02:05.003003003,2009-01-01 10:02:05.003003003,2009-01-01 09:58:04.997002997,2009-01-01 10:02:04.997002997,2008-12-31 13:57:54.996996997
|
|
====
|
|
---- QUERY
|
|
# Test corner cases and also timestamp arithmetic without from clause.
|
|
select cast("2012-02-29 00:00:00" as timestamp) + interval 1 year,
|
|
cast("2013-02-28 00:00:00" as timestamp) - interval 1 year,
|
|
cast("2012-01-01 00:00:00" as timestamp) + interval 365 days,
|
|
cast("2013-01-01 00:00:00" as timestamp) - interval 366 days
|
|
---- TYPES
|
|
timestamp,timestamp,timestamp,timestamp
|
|
---- RESULTS
|
|
2013-02-28 00:00:00,2012-02-29 00:00:00,2012-12-31 00:00:00,2012-01-01 00:00:00
|
|
====
|
|
---- QUERY
|
|
# Test overflow (2147483647 is MAX_INT).
|
|
select cast("2012-01-01 00:00:00" as timestamp) + interval 2147483647 years,
|
|
cast("2012-01-01 00:00:00" as timestamp) - interval 2147483647 years
|
|
---- TYPES
|
|
timestamp,timestamp
|
|
---- RESULTS
|
|
2011-01-01 00:00:00,2013-01-01 00:00:00
|
|
====
|
|
---- QUERY
|
|
# Timestamp arithmetic inside a predicate.
|
|
select year, month from alltypes
|
|
where year = year((cast('2012-01-01 09:10:11' as timestamp) - interval 3 years))
|
|
and month = month((cast('2012-01-01 09:10:11' as timestamp) + interval 3 months))
|
|
limit 3
|
|
---- TYPES
|
|
int,int
|
|
---- RESULTS
|
|
2009,4
|
|
2009,4
|
|
2009,4
|
|
====
|
|
---- QUERY
|
|
# Test NULLs in second operand
|
|
select count(*) from alltypesagg
|
|
where (cast('2012-01-01 09:10:11' as timestamp) + interval tinyint_col seconds) IS NULL
|
|
---- TYPES
|
|
bigint
|
|
---- RESULTS
|
|
1000
|
|
====
|
|
---- QUERY
|
|
# Test NULLs in first operand
|
|
select count(*) from alltypesagg
|
|
where (cast('2012-01-01 09:10:11' as timestamp) + interval tinyint_col seconds)
|
|
+ interval 10 years IS NULL
|
|
---- TYPES
|
|
bigint
|
|
---- RESULTS
|
|
1000
|
|
====
|
|
---- QUERY
|
|
# Test rounding (IMPALA-266)
|
|
select round(8.072, 3), round(8, 3), round(8.0719999999,3), round(8.072, 0),
|
|
round(8.072, 4), 8, 8.0;
|
|
---- TYPES
|
|
double, double, double, double, double, tinyint, float
|
|
---- RESULTS
|
|
8.072,8.000,8.072,8,8.0720,8,8
|
|
====
|
|
---- QUERY
|
|
# Test a fix of codegen/non-codegen exprs(IMPALA-350)
|
|
# Test having a thread-safe expr followed by a non thread-safe one and
|
|
# vice versa.
|
|
select count(*) from alltypes where string_col REGEXP '^1' and id < 10
|
|
---- TYPES
|
|
BIGINT
|
|
---- RESULTS
|
|
1
|
|
====
|
|
---- QUERY
|
|
# Test a fix of codegen/non-codegen exprs(IMPALA-350)
|
|
select count(*) from alltypes where id < 10 and string_col REGEXP '^1'
|
|
---- TYPES
|
|
BIGINT
|
|
---- RESULTS
|
|
1
|
|
====
|
|
---- QUERY
|
|
# Test a fix of codegen/non-codegen for floating-point modulo(IMPALA-391)
|
|
# TODO: Remove this test when IMPALA-498 is resolved.
|
|
select float_col, double_col, float_col % double_col,
|
|
double_col % NULL, NULL % double_col from alltypessmall limit 10
|
|
---- TYPES
|
|
FLOAT,DOUBLE,DOUBLE,DOUBLE,DOUBLE
|
|
---- RESULTS
|
|
0,0,NULL,NULL,NULL
|
|
1.100000023841858,10.1,1.100000023841858,NULL,NULL
|
|
2.200000047683716,20.2,2.200000047683716,NULL,NULL
|
|
3.299999952316284,30.3,3.299999952316284,NULL,NULL
|
|
4.400000095367432,40.4,4.400000095367432,NULL,NULL
|
|
5.5,50.5,5.5,NULL,NULL
|
|
6.599999904632568,60.6,6.599999904632568,NULL,NULL
|
|
7.699999809265137,70.7,7.699999809265137,NULL,NULL
|
|
8.800000190734863,80.8,8.800000190734863,NULL,NULL
|
|
9.899999618530273,90.90000000000001,9.899999618530273,NULL,NULL
|
|
====
|
|
---- QUERY
|
|
select unix_timestamp(tmp.val, tmp.fmt) from (values
|
|
('1970-01-01 00:00:00' as val, 'yyyy-MM-dd HH:mm:ss' as fmt),
|
|
('01:01:01 02/1971/02', 'HH:mm:ss dd/yyyy/MM'),
|
|
('1972||mar||03||030303', 'yyyy||MMM||dd||HHmmss')) as tmp
|
|
---- TYPES
|
|
int
|
|
---- RESULTS
|
|
0
|
|
34304461
|
|
68439783
|
|
====
|
|
---- QUERY
|
|
select from_unixtime(tmp.val, tmp.fmt) from (values
|
|
(0 as val, 'yyyy-MM-dd HH:mm:ss' as fmt),
|
|
(34304461, 'HH:mm:ss dd/yyyy/MM'),
|
|
(68439783, 'yyyy||MMM||dd||HHmmss')) as tmp
|
|
---- TYPES
|
|
string
|
|
---- RESULTS
|
|
'1970-01-01 00:00:00'
|
|
'01:01:01 02/1971/02'
|
|
'1972||Mar||03||030303'
|
|
====
|