http://git-wip-us.apache.org/repos/asf/hive/blob/c95136a0/ql/src/test/results/clientpositive/vectorized_timestamp_funcs.q.out
----------------------------------------------------------------------
diff --git 
a/ql/src/test/results/clientpositive/vectorized_timestamp_funcs.q.out 
b/ql/src/test/results/clientpositive/vectorized_timestamp_funcs.q.out
index 72e9916..8bd77f9 100644
--- a/ql/src/test/results/clientpositive/vectorized_timestamp_funcs.q.out
+++ b/ql/src/test/results/clientpositive/vectorized_timestamp_funcs.q.out
@@ -257,13 +257,13 @@ STAGE PLANS:
             TableScan Vectorization:
                 native: true
             Select Operator
-              expressions: to_unix_timestamp(ctimestamp1) (type: bigint), 
year(ctimestamp1) (type: int), month(ctimestamp1) (type: int), day(ctimestamp1) 
(type: int), dayofmonth(ctimestamp1) (type: int), weekofyear(ctimestamp1) 
(type: int), hour(ctimestamp1) (type: int), minute(ctimestamp1) (type: int), 
second(ctimestamp1) (type: int), cboolean1 (type: boolean), ctimestamp1 (type: 
timestamp), ctimestamp2 (type: timestamp), if(cboolean1, ctimestamp1, 
TIMESTAMP'1319-02-02 16:31:57.778') (type: timestamp), if(cboolean1, 
TIMESTAMP'2000-12-18 08:42:30.0005', ctimestamp1) (type: timestamp), 
if(cboolean1, ctimestamp1, ctimestamp2) (type: timestamp), if(cboolean1, 
ctimestamp1, null) (type: timestamp), if(cboolean1, null, ctimestamp2) (type: 
timestamp)
-              outputColumnNames: _col0, _col1, _col2, _col3, _col4, _col5, 
_col6, _col7, _col8, _col9, _col10, _col11, _col12, _col13, _col14, _col15, 
_col16
+              expressions: to_unix_timestamp(ctimestamp1) (type: bigint), 
year(ctimestamp1) (type: int), month(ctimestamp1) (type: int), day(ctimestamp1) 
(type: int), weekofyear(ctimestamp1) (type: int), hour(ctimestamp1) (type: 
int), minute(ctimestamp1) (type: int), second(ctimestamp1) (type: int), 
cboolean1 (type: boolean), ctimestamp1 (type: timestamp), ctimestamp2 (type: 
timestamp), if(cboolean1, ctimestamp1, TIMESTAMP'1319-02-02 16:31:57.778') 
(type: timestamp), if(cboolean1, TIMESTAMP'2000-12-18 08:42:30.0005', 
ctimestamp1) (type: timestamp), if(cboolean1, ctimestamp1, ctimestamp2) (type: 
timestamp), if(cboolean1, ctimestamp1, null) (type: timestamp), if(cboolean1, 
null, ctimestamp2) (type: timestamp)
+              outputColumnNames: _col0, _col1, _col2, _col3, _col5, _col6, 
_col7, _col8, _col9, _col10, _col11, _col12, _col13, _col14, _col15, _col16
               Select Vectorization:
                   className: VectorSelectOperator
                   native: true
-                  projectedOutputColumnNums: [5, 6, 7, 8, 9, 10, 11, 12, 13, 
0, 1, 3, 14, 15, 16, 17, 18]
-                  selectExpressions: VectorUDFUnixTimeStampTimestamp(col 
1:timestamp) -> 5:bigint, VectorUDFYearTimestamp(col 1:timestamp, field YEAR) 
-> 6:int, VectorUDFMonthTimestamp(col 1:timestamp, field MONTH) -> 7:int, 
VectorUDFDayOfMonthTimestamp(col 1:timestamp, field DAY_OF_MONTH) -> 8:int, 
VectorUDFDayOfMonthTimestamp(col 1:timestamp, field DAY_OF_MONTH) -> 9:int, 
VectorUDFWeekOfYearTimestamp(col 1:timestamp, field WEEK_OF_YEAR) -> 10:int, 
VectorUDFHourTimestamp(col 1:timestamp, field HOUR_OF_DAY) -> 11:int, 
VectorUDFMinuteTimestamp(col 1:timestamp, field MINUTE) -> 12:int, 
VectorUDFSecondTimestamp(col 1:timestamp, field SECOND) -> 13:int, 
IfExprTimestampColumnScalar(col 0:boolean, col 1:timestamp, val 1319-02-02 
16:31:57.778) -> 14:timestamp, IfExprTimestampScalarColumn(col 0:boolean, val 
2000-12-18 08:42:30.0005, col 1:timestamp) -> 15:timestamp, 
IfExprTimestampColumnColumn(col 0:boolean, col 1:timestampcol 3:timestamp) -> 
16:timestamp, IfExprColumnNull(col 0:boolean, co
 l 1:timestamp, null)(children: col 0:boolean, col 1:timestamp) -> 
17:timestamp, IfExprNullColumn(col 0:boolean, null, col 3)(children: col 
0:boolean, col 3:timestamp) -> 18:timestamp
+                  projectedOutputColumnNums: [5, 6, 7, 8, 9, 10, 11, 12, 0, 1, 
3, 13, 14, 15, 16, 17]
+                  selectExpressions: VectorUDFUnixTimeStampTimestamp(col 
1:timestamp) -> 5:bigint, VectorUDFYearTimestamp(col 1:timestamp, field YEAR) 
-> 6:int, VectorUDFMonthTimestamp(col 1:timestamp, field MONTH) -> 7:int, 
VectorUDFDayOfMonthTimestamp(col 1:timestamp, field DAY_OF_MONTH) -> 8:int, 
VectorUDFWeekOfYearTimestamp(col 1:timestamp, field WEEK_OF_YEAR) -> 9:int, 
VectorUDFHourTimestamp(col 1:timestamp, field HOUR_OF_DAY) -> 10:int, 
VectorUDFMinuteTimestamp(col 1:timestamp, field MINUTE) -> 11:int, 
VectorUDFSecondTimestamp(col 1:timestamp, field SECOND) -> 12:int, 
IfExprTimestampColumnScalar(col 0:boolean, col 1:timestamp, val 1319-01-25 
08:31:57.778) -> 13:timestamp, IfExprTimestampScalarColumn(col 0:boolean, val 
2000-12-18 00:42:30.0005, col 1:timestamp) -> 14:timestamp, 
IfExprTimestampColumnColumn(col 0:boolean, col 1:timestampcol 3:timestamp) -> 
15:timestamp, IfExprColumnNull(col 0:boolean, col 1:timestamp, null)(children: 
col 0:boolean, col 1:timestamp) -> 16:timestam
 p, IfExprNullColumn(col 0:boolean, null, col 3)(children: col 0:boolean, col 
3:timestamp) -> 17:timestamp
               Statistics: Num rows: 52 Data size: 3179 Basic stats: COMPLETE 
Column stats: NONE
               Reduce Output Operator
                 key expressions: _col0 (type: bigint)
@@ -274,7 +274,7 @@ STAGE PLANS:
                     nativeConditionsMet: 
hive.vectorized.execution.reducesink.new.enabled IS true, No PTF TopN IS true, 
No DISTINCT columns IS true, BinarySortableSerDe for keys IS true, 
LazyBinarySerDe for values IS true
                     nativeConditionsNotMet: hive.execution.engine mr IN [tez, 
spark] IS false
                 Statistics: Num rows: 52 Data size: 3179 Basic stats: COMPLETE 
Column stats: NONE
-                value expressions: _col1 (type: int), _col2 (type: int), _col3 
(type: int), _col4 (type: int), _col5 (type: int), _col6 (type: int), _col7 
(type: int), _col8 (type: int), _col9 (type: boolean), _col10 (type: 
timestamp), _col11 (type: timestamp), _col12 (type: timestamp), _col13 (type: 
timestamp), _col14 (type: timestamp), _col15 (type: timestamp), _col16 (type: 
timestamp)
+                value expressions: _col1 (type: int), _col2 (type: int), _col3 
(type: int), _col5 (type: int), _col6 (type: int), _col7 (type: int), _col8 
(type: int), _col9 (type: boolean), _col10 (type: timestamp), _col11 (type: 
timestamp), _col12 (type: timestamp), _col13 (type: timestamp), _col14 (type: 
timestamp), _col15 (type: timestamp), _col16 (type: timestamp)
       Execution mode: vectorized
       Map Vectorization:
           enabled: true
@@ -291,7 +291,7 @@ STAGE PLANS:
           enableConditionsNotMet: hive.execution.engine mr IN [tez, spark] IS 
false
       Reduce Operator Tree:
         Select Operator
-          expressions: KEY.reducesinkkey0 (type: bigint), VALUE._col0 (type: 
int), VALUE._col1 (type: int), VALUE._col2 (type: int), VALUE._col3 (type: 
int), VALUE._col4 (type: int), VALUE._col5 (type: int), VALUE._col6 (type: 
int), VALUE._col7 (type: int), VALUE._col8 (type: boolean), VALUE._col9 (type: 
timestamp), VALUE._col10 (type: timestamp), VALUE._col11 (type: timestamp), 
VALUE._col12 (type: timestamp), VALUE._col13 (type: timestamp), VALUE._col14 
(type: timestamp), VALUE._col15 (type: timestamp)
+          expressions: KEY.reducesinkkey0 (type: bigint), VALUE._col0 (type: 
int), VALUE._col1 (type: int), VALUE._col2 (type: int), VALUE._col2 (type: 
int), VALUE._col3 (type: int), VALUE._col4 (type: int), VALUE._col5 (type: 
int), VALUE._col6 (type: int), VALUE._col7 (type: boolean), VALUE._col8 (type: 
timestamp), VALUE._col9 (type: timestamp), VALUE._col10 (type: timestamp), 
VALUE._col11 (type: timestamp), VALUE._col12 (type: timestamp), VALUE._col13 
(type: timestamp), VALUE._col14 (type: timestamp)
           outputColumnNames: _col0, _col1, _col2, _col3, _col4, _col5, _col6, 
_col7, _col8, _col9, _col10, _col11, _col12, _col13, _col14, _col15, _col16
           Statistics: Num rows: 52 Data size: 3179 Basic stats: COMPLETE 
Column stats: NONE
           File Output Operator
@@ -354,14 +354,14 @@ ORDER BY c1
 POSTHOOK: type: QUERY
 POSTHOOK: Input: default@alltypesorc_string
 #### A masked pattern was here ####
--45479000681   528     10      27      27      43      8       15      18      
true    0528-10-27 08:15:18.941718273   NULL    0528-10-27 08:15:18.941718273   
2000-12-18 08:42:30.0005        0528-10-27 08:15:18.941718273   0528-10-27 
08:15:18.941718273   NULL
-1632478712     2021    9       24      24      38      3       18      32      
NULL    2021-09-24 03:18:32.4   1974-10-04 17:21:03.989 1319-02-02 16:31:57.778 
2021-09-24 03:18:32.4   1974-10-04 17:21:03.989 NULL    1974-10-04 17:21:03.989
-1632478712     2021    9       24      24      38      3       18      32      
false   2021-09-24 03:18:32.4   1999-10-03 16:59:10.396903939   1319-02-02 
16:31:57.778 2021-09-24 03:18:32.4   1999-10-03 16:59:10.396903939   NULL    
1999-10-03 16:59:10.396903939
-1632478712     2021    9       24      24      38      3       18      32      
false   2021-09-24 03:18:32.4   2010-04-08 02:43:35.861742727   1319-02-02 
16:31:57.778 2021-09-24 03:18:32.4   2010-04-08 02:43:35.861742727   NULL    
2010-04-08 02:43:35.861742727
-1632478712     2021    9       24      24      38      3       18      32      
false   2021-09-24 03:18:32.4   NULL    1319-02-02 16:31:57.778 2021-09-24 
03:18:32.4   NULL    NULL    NULL
-163809612024   7160    12      2       2       48      6       0       24      
NULL    7160-12-02 06:00:24.81200852    1966-08-16 13:36:50.183 1319-02-02 
16:31:57.778 7160-12-02 06:00:24.81200852    1966-08-16 13:36:50.183 NULL    
1966-08-16 13:36:50.183
-163809612024   7160    12      2       2       48      6       0       24      
NULL    7160-12-02 06:00:24.81200852    NULL    1319-02-02 16:31:57.778 
7160-12-02 06:00:24.81200852    NULL    NULL    NULL
-490725011      1985    7       20      20      29      9       30      11      
true    1985-07-20 09:30:11     1319-02-02 16:31:57.778 1985-07-20 09:30:11     
2000-12-18 08:42:30.0005        1985-07-20 09:30:11     1985-07-20 09:30:11     
NULL
+-45479202281   528     10      25      25      43      8       15      18      
true    0528-10-27 08:15:18.941718273   NULL    0528-10-27 08:15:18.941718273   
2000-12-18 08:42:30.0005        0528-10-27 08:15:18.941718273   0528-10-27 
08:15:18.941718273   NULL
+1632453512     2021    9       24      24      38      3       18      32      
NULL    2021-09-24 03:18:32.4   1974-10-04 17:21:03.989 1319-02-02 16:31:57.778 
2021-09-24 03:18:32.4   1974-10-04 17:21:03.989 NULL    1974-10-04 17:21:03.989
+1632453512     2021    9       24      24      38      3       18      32      
false   2021-09-24 03:18:32.4   1999-10-03 16:59:10.396903939   1319-02-02 
16:31:57.778 2021-09-24 03:18:32.4   1999-10-03 16:59:10.396903939   NULL    
1999-10-03 16:59:10.396903939
+1632453512     2021    9       24      24      38      3       18      32      
false   2021-09-24 03:18:32.4   2010-04-08 02:43:35.861742727   1319-02-02 
16:31:57.778 2021-09-24 03:18:32.4   2010-04-08 02:43:35.861742727   NULL    
2010-04-08 02:43:35.861742727
+1632453512     2021    9       24      24      38      3       18      32      
false   2021-09-24 03:18:32.4   NULL    1319-02-02 16:31:57.778 2021-09-24 
03:18:32.4   NULL    NULL    NULL
+163809583224   7160    12      2       2       48      6       0       24      
NULL    7160-12-02 06:00:24.81200852    1966-08-16 13:36:50.183 1319-02-02 
16:31:57.778 7160-12-02 06:00:24.81200852    1966-08-16 13:36:50.183 NULL    
1966-08-16 13:36:50.183
+163809583224   7160    12      2       2       48      6       0       24      
NULL    7160-12-02 06:00:24.81200852    NULL    1319-02-02 16:31:57.778 
7160-12-02 06:00:24.81200852    NULL    NULL    NULL
+490699811      1985    7       20      20      29      9       30      11      
true    1985-07-20 09:30:11     1319-02-02 16:31:57.778 1985-07-20 09:30:11     
2000-12-18 08:42:30.0005        1985-07-20 09:30:11     1985-07-20 09:30:11     
NULL
 NULL   NULL    NULL    NULL    NULL    NULL    NULL    NULL    NULL    NULL    
NULL    NULL    1319-02-02 16:31:57.778 NULL    NULL    NULL    NULL
 NULL   NULL    NULL    NULL    NULL    NULL    NULL    NULL    NULL    false   
NULL    1969-12-31 15:59:44.028 1319-02-02 16:31:57.778 NULL    1969-12-31 
15:59:44.028 NULL    1969-12-31 15:59:44.028
 NULL   NULL    NULL    NULL    NULL    NULL    NULL    NULL    NULL    false   
NULL    1969-12-31 15:59:44.809 1319-02-02 16:31:57.778 NULL    1969-12-31 
15:59:44.809 NULL    1969-12-31 15:59:44.809
@@ -450,7 +450,7 @@ STAGE PLANS:
             TableScan Vectorization:
                 native: true
             Select Operator
-              expressions: to_unix_timestamp(stimestamp1) (type: bigint), 
year(CAST( stimestamp1 AS DATE)) (type: int), month(CAST( stimestamp1 AS DATE)) 
(type: int), day(CAST( stimestamp1 AS DATE)) (type: int), 
dayofmonth(stimestamp1) (type: int), weekofyear(CAST( stimestamp1 AS DATE)) 
(type: int), hour(CAST( stimestamp1 AS TIMESTAMP)) (type: int), minute(CAST( 
stimestamp1 AS TIMESTAMP)) (type: int), second(CAST( stimestamp1 AS TIMESTAMP)) 
(type: int)
+              expressions: to_unix_timestamp(stimestamp1) (type: bigint), 
year(CAST( stimestamp1 AS DATE)) (type: int), month(CAST( stimestamp1 AS DATE)) 
(type: int), day(CAST( stimestamp1 AS DATE)) (type: int), day(stimestamp1) 
(type: int), weekofyear(CAST( stimestamp1 AS DATE)) (type: int), hour(CAST( 
stimestamp1 AS TIMESTAMP)) (type: int), minute(CAST( stimestamp1 AS TIMESTAMP)) 
(type: int), second(CAST( stimestamp1 AS TIMESTAMP)) (type: int)
               outputColumnNames: _col0, _col1, _col2, _col3, _col4, _col5, 
_col6, _col7, _col8
               Select Vectorization:
                   className: VectorSelectOperator
@@ -531,14 +531,14 @@ ORDER BY c1
 POSTHOOK: type: QUERY
 POSTHOOK: Input: default@alltypesorc_string
 #### A masked pattern was here ####
--2736243926    1883    4       17      17      16      4       14      34
--62018170411   4       9       22      22      39      18      26      29
-1365579826     2013    4       10      10      15      0       43      46
-206731024925   8521    1       16      16      3       20      42      5
-271201265      1978    8       5       5       31      14      41      5
-501208674      1985    11      18      18      47      16      37      54
-501208674      1985    11      18      18      47      16      37      54
-94573848655    4966    12      4       4       49      9       30      55
+-2736272726    1883    4       17      17      16      4       14      34
+-62018199211   4       9       24      22      39      18      26      29
+1365554626     2013    4       10      10      15      0       43      46
+206730996125   8521    1       16      16      3       20      42      5
+271176065      1978    8       5       5       31      14      41      5
+501179874      1985    11      18      18      47      16      37      54
+501179874      1985    11      18      18      47      16      37      54
+94573819855    4966    12      4       4       49      9       30      55
 NULL   NULL    NULL    NULL    NULL    NULL    NULL    NULL    NULL
 NULL   NULL    NULL    NULL    NULL    NULL    NULL    NULL    NULL
 NULL   NULL    NULL    NULL    NULL    NULL    NULL    NULL    NULL
@@ -627,7 +627,7 @@ STAGE PLANS:
             TableScan Vectorization:
                 native: true
             Select Operator
-              expressions: (to_unix_timestamp(ctimestamp1) = 
to_unix_timestamp(stimestamp1)) (type: boolean), (year(ctimestamp1) = 
year(CAST( stimestamp1 AS DATE))) (type: boolean), (month(ctimestamp1) = 
month(CAST( stimestamp1 AS DATE))) (type: boolean), (day(ctimestamp1) = 
day(CAST( stimestamp1 AS DATE))) (type: boolean), (dayofmonth(ctimestamp1) = 
dayofmonth(stimestamp1)) (type: boolean), (weekofyear(ctimestamp1) = 
weekofyear(CAST( stimestamp1 AS DATE))) (type: boolean), (hour(ctimestamp1) = 
hour(CAST( stimestamp1 AS TIMESTAMP))) (type: boolean), (minute(ctimestamp1) = 
minute(CAST( stimestamp1 AS TIMESTAMP))) (type: boolean), (second(ctimestamp1) 
= second(CAST( stimestamp1 AS TIMESTAMP))) (type: boolean)
+              expressions: (to_unix_timestamp(ctimestamp1) = 
to_unix_timestamp(stimestamp1)) (type: boolean), (year(ctimestamp1) = 
year(CAST( stimestamp1 AS DATE))) (type: boolean), (month(ctimestamp1) = 
month(CAST( stimestamp1 AS DATE))) (type: boolean), (day(ctimestamp1) = 
day(CAST( stimestamp1 AS DATE))) (type: boolean), (day(ctimestamp1) = 
day(stimestamp1)) (type: boolean), (weekofyear(ctimestamp1) = weekofyear(CAST( 
stimestamp1 AS DATE))) (type: boolean), (hour(ctimestamp1) = hour(CAST( 
stimestamp1 AS TIMESTAMP))) (type: boolean), (minute(ctimestamp1) = 
minute(CAST( stimestamp1 AS TIMESTAMP))) (type: boolean), (second(ctimestamp1) 
= second(CAST( stimestamp1 AS TIMESTAMP))) (type: boolean)
               outputColumnNames: _col0, _col1, _col2, _col3, _col4, _col5, 
_col6, _col7, _col8
               Select Vectorization:
                   className: VectorSelectOperator
@@ -804,7 +804,7 @@ STAGE PLANS:
             TableScan Vectorization:
                 native: true
             Select Operator
-              expressions: to_unix_timestamp(stimestamp1) (type: bigint), 
year(CAST( stimestamp1 AS DATE)) (type: int), month(CAST( stimestamp1 AS DATE)) 
(type: int), day(CAST( stimestamp1 AS DATE)) (type: int), 
dayofmonth(stimestamp1) (type: int), weekofyear(CAST( stimestamp1 AS DATE)) 
(type: int), hour(CAST( stimestamp1 AS TIMESTAMP)) (type: int), minute(CAST( 
stimestamp1 AS TIMESTAMP)) (type: int), second(CAST( stimestamp1 AS TIMESTAMP)) 
(type: int)
+              expressions: to_unix_timestamp(stimestamp1) (type: bigint), 
year(CAST( stimestamp1 AS DATE)) (type: int), month(CAST( stimestamp1 AS DATE)) 
(type: int), day(CAST( stimestamp1 AS DATE)) (type: int), day(stimestamp1) 
(type: int), weekofyear(CAST( stimestamp1 AS DATE)) (type: int), hour(CAST( 
stimestamp1 AS TIMESTAMP)) (type: int), minute(CAST( stimestamp1 AS TIMESTAMP)) 
(type: int), second(CAST( stimestamp1 AS TIMESTAMP)) (type: int)
               outputColumnNames: _col0, _col1, _col2, _col3, _col4, _col5, 
_col6, _col7, _col8
               Select Vectorization:
                   className: VectorSelectOperator
@@ -885,7 +885,7 @@ ORDER BY c1
 POSTHOOK: type: QUERY
 POSTHOOK: Input: default@alltypesorc_wrong
 #### A masked pattern was here ####
-NULL   2       11      30      NULL    48      NULL    NULL    NULL
+NULL   2       12      2       NULL    49      4       40      39
 NULL   NULL    NULL    NULL    NULL    NULL    NULL    NULL    NULL
 NULL   NULL    NULL    NULL    NULL    NULL    NULL    NULL    NULL
 PREHOOK: query: EXPLAIN VECTORIZATION EXPRESSION  SELECT
@@ -1105,7 +1105,7 @@ FROM alltypesorc_string
 POSTHOOK: type: QUERY
 POSTHOOK: Input: default@alltypesorc_string
 #### A masked pattern was here ####
-2.89160863229166E11
+2.89160478029166E11
 PREHOOK: query: EXPLAIN VECTORIZATION EXPRESSION  SELECT
   round(avg(ctimestamp1), 0),
   variance(ctimestamp1) between 8.97077295279421E19 and 8.97077295279422E19,
@@ -1239,4 +1239,4 @@ FROM alltypesorc_string
 POSTHOOK: type: QUERY
 POSTHOOK: Input: default@alltypesorc_string
 #### A masked pattern was here ####
-3.6145107904E10        false   false   false   7.5245155692476E10      
7.5245155692476E10      7.5245155692476E10      8.0440455033059E10
+3.6145059754E10        false   false   false   7.5245178084814E10      
7.5245178084814E10      7.5245178084814E10      8.0440478971476E10

http://git-wip-us.apache.org/repos/asf/hive/blob/c95136a0/ql/src/test/results/clientpositive/vectorized_timestamp_ints_casts.q.out
----------------------------------------------------------------------
diff --git 
a/ql/src/test/results/clientpositive/vectorized_timestamp_ints_casts.q.out 
b/ql/src/test/results/clientpositive/vectorized_timestamp_ints_casts.q.out
index 95f07d9..603851d 100644
--- a/ql/src/test/results/clientpositive/vectorized_timestamp_ints_casts.q.out
+++ b/ql/src/test/results/clientpositive/vectorized_timestamp_ints_casts.q.out
@@ -132,32 +132,32 @@ where cbigint % 250 = 0
 POSTHOOK: type: QUERY
 POSTHOOK: Input: default@alltypesorc
 #### A masked pattern was here ####
-1969-12-31 15:59:59.964        1969-12-31 15:59:59.8   NULL    1969-12-08 
10:43:03.25  1969-12-31 15:59:24     1969-12-31 15:56:40     NULL    1969-12-31 
16:00:00     1969-12-31 15:59:45.748 NULL    NULL
-1969-12-31 15:59:59.964        1969-12-31 15:59:59.8   NULL    1970-01-19 
04:24:39     1969-12-31 15:59:24     1969-12-31 15:56:40     NULL    1969-12-31 
16:00:00     1969-12-31 15:59:53.817 NULL    NULL
-1969-12-31 15:59:59.97 1969-12-31 15:59:59.8   NULL    1970-01-17 05:10:52.25  
1969-12-31 15:59:30     1969-12-31 15:56:40     NULL    1969-12-31 16:00:00     
1969-12-31 16:00:12.935 NULL    NULL
-1969-12-31 15:59:59.949        NULL    1970-01-09 14:53:20.971 1970-01-12 
20:45:23.25  1969-12-31 15:59:09     NULL    1969-12-31 16:00:00     1969-12-31 
16:00:00     1969-12-31 16:00:08.451 NULL    NULL
-1969-12-31 15:59:59.949        NULL    1970-01-09 07:39:13.882 1969-12-09 
07:45:32.75  1969-12-31 15:59:09     NULL    1969-12-31 16:00:00.001 1969-12-31 
16:00:00     1969-12-31 16:00:08.451 NULL    NULL
-1969-12-31 16:00:00.02 1969-12-31 16:00:15.601 NULL    1969-12-27 11:19:26.75  
1969-12-31 16:00:20     1969-12-31 20:20:01     NULL    1969-12-31 16:00:00     
1969-12-31 15:59:45.129 NULL    NULL
-1969-12-31 15:59:59.962        1969-12-31 16:00:15.601 NULL    1969-12-10 
03:41:51     1969-12-31 15:59:22     1969-12-31 20:20:01     NULL    1969-12-31 
16:00:00     1969-12-31 15:59:58.614 NULL    NULL
-1969-12-31 15:59:59.995        1969-12-31 16:00:15.601 NULL    1970-01-07 
18:06:56     1969-12-31 15:59:55     1969-12-31 20:20:01     NULL    1969-12-31 
16:00:00     1969-12-31 16:00:04.679 NULL    NULL
-1969-12-31 16:00:00.048        1969-12-31 16:00:15.601 NULL    1969-12-22 
11:03:59     1969-12-31 16:00:48     1969-12-31 20:20:01     NULL    1969-12-31 
16:00:00     1969-12-31 15:59:50.235 NULL    NULL
-1969-12-31 16:00:00.008        NULL    1969-12-24 00:12:58.862 1969-12-20 
21:16:47.25  1969-12-31 16:00:08     NULL    1969-12-31 16:00:00     1969-12-31 
16:00:00     1969-12-31 16:00:15.892 NULL    NULL
-1969-12-31 16:00:00.008        NULL    1969-12-30 11:24:23.566 1969-12-16 
11:20:17.25  1969-12-31 16:00:08     NULL    1969-12-31 16:00:00     1969-12-31 
16:00:00     1969-12-31 16:00:15.892 NULL    NULL
-1969-12-31 16:00:00.008        NULL    1970-01-09 23:39:39.664 1970-01-10 
17:09:21.5   1969-12-31 16:00:08     NULL    1969-12-31 16:00:00     1969-12-31 
16:00:00     1969-12-31 16:00:15.892 NULL    NULL
-1969-12-31 16:00:00.008        NULL    1969-12-23 21:59:27.689 1970-01-19 
01:16:31.25  1969-12-31 16:00:08     NULL    1969-12-31 16:00:00     1969-12-31 
16:00:00     1969-12-31 16:00:15.892 NULL    NULL
-1969-12-31 16:00:00.008        NULL    1970-01-10 23:29:48.972 1969-12-10 
02:41:39     1969-12-31 16:00:08     NULL    1969-12-31 16:00:00.001 1969-12-31 
16:00:00     1969-12-31 16:00:15.892 NULL    NULL
-1969-12-31 16:00:00.008        NULL    1970-01-11 10:34:27.246 1970-01-14 
14:49:59.25  1969-12-31 16:00:08     NULL    1969-12-31 16:00:00.001 1969-12-31 
16:00:00     1969-12-31 16:00:15.892 NULL    NULL
-1969-12-31 15:59:59.941        1969-12-31 15:59:52.804 NULL    1969-12-13 
02:11:50     1969-12-31 15:59:01     1969-12-31 14:00:04     NULL    1969-12-31 
16:00:00     1969-12-31 16:00:13.15  NULL    NULL
-1969-12-31 15:59:59.979        1969-12-31 15:59:52.804 NULL    1970-01-18 
12:27:09     1969-12-31 15:59:39     1969-12-31 14:00:04     NULL    1969-12-31 
16:00:00     1969-12-31 15:59:55.9   NULL    NULL
-1969-12-31 15:59:59.94 1969-12-31 15:59:52.804 NULL    1970-01-18 05:11:54.75  
1969-12-31 15:59:00     1969-12-31 14:00:04     NULL    1969-12-31 16:00:00     
1969-12-31 15:59:52.408 NULL    NULL
-1969-12-31 15:59:59.986        1969-12-31 15:59:52.804 NULL    1969-12-13 
16:50:00.5   1969-12-31 15:59:46     1969-12-31 14:00:04     NULL    1969-12-31 
16:00:00     1969-12-31 16:00:11.065 NULL    NULL
-1969-12-31 16:00:00.059        1969-12-31 15:59:52.804 NULL    1969-12-18 
11:57:25.5   1969-12-31 16:00:59     1969-12-31 14:00:04     NULL    1969-12-31 
16:00:00     1969-12-31 16:00:10.956 NULL    NULL
-1969-12-31 15:59:59.992        1969-12-31 15:59:52.804 NULL    1969-12-10 
06:06:48.5   1969-12-31 15:59:52     1969-12-31 14:00:04     NULL    1969-12-31 
16:00:00     1969-12-31 16:00:03.136 NULL    NULL
-1969-12-31 16:00:00.005        1969-12-31 15:59:52.804 NULL    1969-12-19 
21:53:12.5   1969-12-31 16:00:05     1969-12-31 14:00:04     NULL    1969-12-31 
16:00:00     1969-12-31 16:00:10.973 NULL    NULL
-1969-12-31 15:59:59.976        1969-12-31 15:59:52.804 NULL    1970-01-10 
06:18:31     1969-12-31 15:59:36     1969-12-31 14:00:04     NULL    1969-12-31 
16:00:00     1969-12-31 15:59:53.145 NULL    NULL
-1969-12-31 15:59:59.95 1969-12-31 15:59:52.804 NULL    1969-12-19 17:33:32.75  
1969-12-31 15:59:10     1969-12-31 14:00:04     NULL    1969-12-31 16:00:00     
1969-12-31 15:59:54.733 NULL    NULL
-1969-12-31 16:00:00.011        NULL    1969-12-30 22:03:04.018 1970-01-21 
12:50:53.75  1969-12-31 16:00:11     NULL    1969-12-31 16:00:00.001 1969-12-31 
16:00:00     1969-12-31 16:00:02.351 NULL    NULL
-1969-12-31 16:00:00.011        NULL    1969-12-27 18:49:09.583 1970-01-14 
22:35:27     1969-12-31 16:00:11     NULL    1969-12-31 16:00:00.001 1969-12-31 
16:00:00     1969-12-31 16:00:02.351 NULL    NULL
+1969-12-31 23:59:59.964        1969-12-31 23:59:59.8   NULL    1969-12-08 
18:43:03.25  1969-12-31 23:59:24     1969-12-31 23:56:40     NULL    1970-01-01 
00:00:00     1969-12-31 15:59:45.748 NULL    NULL
+1969-12-31 23:59:59.964        1969-12-31 23:59:59.8   NULL    1970-01-19 
12:24:39     1969-12-31 23:59:24     1969-12-31 23:56:40     NULL    1970-01-01 
00:00:00     1969-12-31 15:59:53.817 NULL    NULL
+1969-12-31 23:59:59.97 1969-12-31 23:59:59.8   NULL    1970-01-17 13:10:52.25  
1969-12-31 23:59:30     1969-12-31 23:56:40     NULL    1970-01-01 00:00:00     
1969-12-31 16:00:12.935 NULL    NULL
+1969-12-31 23:59:59.949        NULL    1970-01-09 22:53:20.971 1970-01-13 
04:45:23.25  1969-12-31 23:59:09     NULL    1970-01-01 00:00:00     1970-01-01 
00:00:00     1969-12-31 16:00:08.451 NULL    NULL
+1969-12-31 23:59:59.949        NULL    1970-01-09 15:39:13.882 1969-12-09 
15:45:32.75  1969-12-31 23:59:09     NULL    1970-01-01 00:00:00.001 1970-01-01 
00:00:00     1969-12-31 16:00:08.451 NULL    NULL
+1970-01-01 00:00:00.02 1970-01-01 00:00:15.601 NULL    1969-12-27 19:19:26.75  
1970-01-01 00:00:20     1970-01-01 04:20:01     NULL    1970-01-01 00:00:00     
1969-12-31 15:59:45.129 NULL    NULL
+1969-12-31 23:59:59.962        1970-01-01 00:00:15.601 NULL    1969-12-10 
11:41:51     1969-12-31 23:59:22     1970-01-01 04:20:01     NULL    1970-01-01 
00:00:00     1969-12-31 15:59:58.614 NULL    NULL
+1969-12-31 23:59:59.995        1970-01-01 00:00:15.601 NULL    1970-01-08 
02:06:56     1969-12-31 23:59:55     1970-01-01 04:20:01     NULL    1970-01-01 
00:00:00     1969-12-31 16:00:04.679 NULL    NULL
+1970-01-01 00:00:00.048        1970-01-01 00:00:15.601 NULL    1969-12-22 
19:03:59     1970-01-01 00:00:48     1970-01-01 04:20:01     NULL    1970-01-01 
00:00:00     1969-12-31 15:59:50.235 NULL    NULL
+1970-01-01 00:00:00.008        NULL    1969-12-24 08:12:58.862 1969-12-21 
05:16:47.25  1970-01-01 00:00:08     NULL    1970-01-01 00:00:00     1970-01-01 
00:00:00     1969-12-31 16:00:15.892 NULL    NULL
+1970-01-01 00:00:00.008        NULL    1969-12-30 19:24:23.566 1969-12-16 
19:20:17.25  1970-01-01 00:00:08     NULL    1970-01-01 00:00:00     1970-01-01 
00:00:00     1969-12-31 16:00:15.892 NULL    NULL
+1970-01-01 00:00:00.008        NULL    1970-01-10 07:39:39.664 1970-01-11 
01:09:21.5   1970-01-01 00:00:08     NULL    1970-01-01 00:00:00     1970-01-01 
00:00:00     1969-12-31 16:00:15.892 NULL    NULL
+1970-01-01 00:00:00.008        NULL    1969-12-24 05:59:27.689 1970-01-19 
09:16:31.25  1970-01-01 00:00:08     NULL    1970-01-01 00:00:00     1970-01-01 
00:00:00     1969-12-31 16:00:15.892 NULL    NULL
+1970-01-01 00:00:00.008        NULL    1970-01-11 07:29:48.972 1969-12-10 
10:41:39     1970-01-01 00:00:08     NULL    1970-01-01 00:00:00.001 1970-01-01 
00:00:00     1969-12-31 16:00:15.892 NULL    NULL
+1970-01-01 00:00:00.008        NULL    1970-01-11 18:34:27.246 1970-01-14 
22:49:59.25  1970-01-01 00:00:08     NULL    1970-01-01 00:00:00.001 1970-01-01 
00:00:00     1969-12-31 16:00:15.892 NULL    NULL
+1969-12-31 23:59:59.941        1969-12-31 23:59:52.804 NULL    1969-12-13 
10:11:50     1969-12-31 23:59:01     1969-12-31 22:00:04     NULL    1970-01-01 
00:00:00     1969-12-31 16:00:13.15  NULL    NULL
+1969-12-31 23:59:59.979        1969-12-31 23:59:52.804 NULL    1970-01-18 
20:27:09     1969-12-31 23:59:39     1969-12-31 22:00:04     NULL    1970-01-01 
00:00:00     1969-12-31 15:59:55.9   NULL    NULL
+1969-12-31 23:59:59.94 1969-12-31 23:59:52.804 NULL    1970-01-18 13:11:54.75  
1969-12-31 23:59:00     1969-12-31 22:00:04     NULL    1970-01-01 00:00:00     
1969-12-31 15:59:52.408 NULL    NULL
+1969-12-31 23:59:59.986        1969-12-31 23:59:52.804 NULL    1969-12-14 
00:50:00.5   1969-12-31 23:59:46     1969-12-31 22:00:04     NULL    1970-01-01 
00:00:00     1969-12-31 16:00:11.065 NULL    NULL
+1970-01-01 00:00:00.059        1969-12-31 23:59:52.804 NULL    1969-12-18 
19:57:25.5   1970-01-01 00:00:59     1969-12-31 22:00:04     NULL    1970-01-01 
00:00:00     1969-12-31 16:00:10.956 NULL    NULL
+1969-12-31 23:59:59.992        1969-12-31 23:59:52.804 NULL    1969-12-10 
14:06:48.5   1969-12-31 23:59:52     1969-12-31 22:00:04     NULL    1970-01-01 
00:00:00     1969-12-31 16:00:03.136 NULL    NULL
+1970-01-01 00:00:00.005        1969-12-31 23:59:52.804 NULL    1969-12-20 
05:53:12.5   1970-01-01 00:00:05     1969-12-31 22:00:04     NULL    1970-01-01 
00:00:00     1969-12-31 16:00:10.973 NULL    NULL
+1969-12-31 23:59:59.976        1969-12-31 23:59:52.804 NULL    1970-01-10 
14:18:31     1969-12-31 23:59:36     1969-12-31 22:00:04     NULL    1970-01-01 
00:00:00     1969-12-31 15:59:53.145 NULL    NULL
+1969-12-31 23:59:59.95 1969-12-31 23:59:52.804 NULL    1969-12-20 01:33:32.75  
1969-12-31 23:59:10     1969-12-31 22:00:04     NULL    1970-01-01 00:00:00     
1969-12-31 15:59:54.733 NULL    NULL
+1970-01-01 00:00:00.011        NULL    1969-12-31 06:03:04.018 1970-01-21 
20:50:53.75  1970-01-01 00:00:11     NULL    1970-01-01 00:00:00.001 1970-01-01 
00:00:00     1969-12-31 16:00:02.351 NULL    NULL
+1970-01-01 00:00:00.011        NULL    1969-12-28 02:49:09.583 1970-01-15 
06:35:27     1970-01-01 00:00:11     NULL    1970-01-01 00:00:00.001 1970-01-01 
00:00:00     1969-12-31 16:00:02.351 NULL    NULL
 PREHOOK: query: explain vectorization expression
 select
 
@@ -292,29 +292,29 @@ where cbigint % 250 = 0
 POSTHOOK: type: QUERY
 POSTHOOK: Input: default@alltypesorc
 #### A masked pattern was here ####
-1969-12-31 15:59:24    1969-12-31 15:56:40     NULL    1906-06-05 13:34:10     
1969-12-31 15:59:24     1969-12-31 15:56:40     NULL    1969-12-31 16:00:00     
1969-12-31 15:59:45.748 NULL    NULL
-1969-12-31 15:59:24    1969-12-31 15:56:40     NULL    2020-09-11 19:50:00     
1969-12-31 15:59:24     1969-12-31 15:56:40     NULL    1969-12-31 16:00:00     
1969-12-31 15:59:53.817 NULL    NULL
-1969-12-31 15:59:30    1969-12-31 15:56:40     NULL    2015-04-23 22:10:50     
1969-12-31 15:59:30     1969-12-31 15:56:40     NULL    1969-12-31 16:00:00     
1969-12-31 16:00:12.935 NULL    NULL
-1969-12-31 15:59:09    NULL    1994-07-07 10:09:31     2003-05-25 21:27:30     
1969-12-31 15:59:09     NULL    1969-12-31 16:00:00     1969-12-31 16:00:00     
1969-12-31 16:00:08.451 NULL    NULL
-1969-12-31 15:59:09    NULL    1993-09-08 22:51:22     1908-10-29 07:05:50     
1969-12-31 15:59:09     NULL    1969-12-31 16:00:01     1969-12-31 16:00:00     
1969-12-31 16:00:08.451 NULL    NULL
-1969-12-31 16:00:20    1969-12-31 20:20:01     NULL    1958-07-07 21:05:50     
1969-12-31 16:00:20     1969-12-31 20:20:01     NULL    1969-12-31 16:00:00     
1969-12-31 15:59:45.129 NULL    NULL
-1969-12-31 15:59:22    1969-12-31 20:20:01     NULL    1911-02-07 01:30:00     
1969-12-31 15:59:22     1969-12-31 20:20:01     NULL    1969-12-31 16:00:00     
1969-12-31 15:59:58.614 NULL    NULL
-1969-12-31 15:59:55    1969-12-31 20:20:01     NULL    1989-05-28 20:33:20     
1969-12-31 15:59:55     1969-12-31 20:20:01     NULL    1969-12-31 16:00:00     
1969-12-31 16:00:04.679 NULL    NULL
-1969-12-31 16:00:48    1969-12-31 20:20:01     NULL    1944-10-18 03:23:20     
1969-12-31 16:00:48     1969-12-31 20:20:01     NULL    1969-12-31 16:00:00     
1969-12-31 15:59:50.235 NULL    NULL
-1969-12-31 16:00:08    NULL    1949-01-13 00:21:02     1940-06-26 15:47:30     
1969-12-31 16:00:08     NULL    1969-12-31 16:00:00     1969-12-31 16:00:00     
1969-12-31 16:00:15.892 NULL    NULL
-1969-12-31 16:00:08    NULL    1966-09-27 07:32:46     1928-05-26 10:07:30     
1969-12-31 16:00:08     NULL    1969-12-31 16:00:00     1969-12-31 16:00:00     
1969-12-31 16:00:15.892 NULL    NULL
-1969-12-31 16:00:08    NULL    1995-07-07 22:01:04     1997-07-05 20:58:20     
1969-12-31 16:00:08     NULL    1969-12-31 16:00:00     1969-12-31 16:00:00     
1969-12-31 16:00:15.892 NULL    NULL
-1969-12-31 16:00:08    NULL    1948-10-12 08:01:29     2020-05-04 04:20:50     
1969-12-31 16:00:08     NULL    1969-12-31 16:00:00     1969-12-31 16:00:00     
1969-12-31 16:00:15.892 NULL    NULL
-1969-12-31 16:00:08    NULL    1998-03-27 00:56:12     1910-12-27 06:10:00     
1969-12-31 16:00:08     NULL    1969-12-31 16:00:01     1969-12-31 16:00:00     
1969-12-31 16:00:15.892 NULL    NULL
-1969-12-31 16:00:08    NULL    1999-07-01 15:14:06     2008-03-13 02:07:30     
1969-12-31 16:00:08     NULL    1969-12-31 16:00:01     1969-12-31 16:00:00     
1969-12-31 16:00:15.892 NULL    NULL
-1969-12-31 15:59:01    1969-12-31 14:00:04     NULL    1919-02-22 13:13:20     
1969-12-31 15:59:01     1969-12-31 14:00:04     NULL    1969-12-31 16:00:00     
1969-12-31 16:00:13.15  NULL    NULL
-1969-12-31 15:59:39    1969-12-31 14:00:04     NULL    2018-11-16 20:30:00     
1969-12-31 15:59:39     1969-12-31 14:00:04     NULL    1969-12-31 16:00:00     
1969-12-31 15:59:55.9   NULL    NULL
-1969-12-31 15:59:00    1969-12-31 14:00:04     NULL    2018-01-18 14:32:30     
1969-12-31 15:59:00     1969-12-31 14:00:04     NULL    1969-12-31 16:00:00     
1969-12-31 15:59:52.408 NULL    NULL
-1969-12-31 15:59:46    1969-12-31 14:00:04     NULL    1920-10-24 09:28:20     
1969-12-31 15:59:46     1969-12-31 14:00:04     NULL    1969-12-31 16:00:00     
1969-12-31 16:00:11.065 NULL    NULL
-1969-12-31 16:00:59    1969-12-31 14:00:04     NULL    1933-12-12 05:05:00     
1969-12-31 16:00:59     1969-12-31 14:00:04     NULL    1969-12-31 16:00:00     
1969-12-31 16:00:10.956 NULL    NULL
-1969-12-31 15:59:52    1969-12-31 14:00:04     NULL    1911-05-18 17:28:20     
1969-12-31 15:59:52     1969-12-31 14:00:04     NULL    1969-12-31 16:00:00     
1969-12-31 16:00:03.136 NULL    NULL
-1969-12-31 16:00:05    1969-12-31 14:00:04     NULL    1937-10-25 22:48:20     
1969-12-31 16:00:05     1969-12-31 14:00:04     NULL    1969-12-31 16:00:00     
1969-12-31 16:00:10.973 NULL    NULL
-1969-12-31 15:59:36    1969-12-31 14:00:04     NULL    1996-04-09 21:36:40     
1969-12-31 15:59:36     1969-12-31 14:00:04     NULL    1969-12-31 16:00:00     
1969-12-31 15:59:53.145 NULL    NULL
-1969-12-31 15:59:10    1969-12-31 14:00:04     NULL    1937-04-28 15:05:50     
1969-12-31 15:59:10     1969-12-31 14:00:04     NULL    1969-12-31 16:00:00     
1969-12-31 15:59:54.733 NULL    NULL
-1969-12-31 16:00:11    NULL    1967-12-14 19:06:58     2027-02-19 08:15:50     
1969-12-31 16:00:11     NULL    1969-12-31 16:00:01     1969-12-31 16:00:00     
1969-12-31 16:00:02.351 NULL    NULL
-1969-12-31 16:00:11    NULL    1959-05-16 04:19:43     2009-01-30 06:50:00     
1969-12-31 16:00:11     NULL    1969-12-31 16:00:01     1969-12-31 16:00:00     
1969-12-31 16:00:02.351 NULL    NULL
+1969-12-31 23:59:24    1969-12-31 23:56:40     NULL    1906-06-05 21:34:10     
1969-12-31 23:59:24     1969-12-31 23:56:40     NULL    1970-01-01 00:00:00     
1969-12-31 15:59:45.748 NULL    NULL
+1969-12-31 23:59:24    1969-12-31 23:56:40     NULL    2020-09-12 02:50:00     
1969-12-31 23:59:24     1969-12-31 23:56:40     NULL    1970-01-01 00:00:00     
1969-12-31 15:59:53.817 NULL    NULL
+1969-12-31 23:59:30    1969-12-31 23:56:40     NULL    2015-04-24 05:10:50     
1969-12-31 23:59:30     1969-12-31 23:56:40     NULL    1970-01-01 00:00:00     
1969-12-31 16:00:12.935 NULL    NULL
+1969-12-31 23:59:09    NULL    1994-07-07 17:09:31     2003-05-26 04:27:30     
1969-12-31 23:59:09     NULL    1970-01-01 00:00:00     1970-01-01 00:00:00     
1969-12-31 16:00:08.451 NULL    NULL
+1969-12-31 23:59:09    NULL    1993-09-09 05:51:22     1908-10-29 15:05:50     
1969-12-31 23:59:09     NULL    1970-01-01 00:00:01     1970-01-01 00:00:00     
1969-12-31 16:00:08.451 NULL    NULL
+1970-01-01 00:00:20    1970-01-01 04:20:01     NULL    1958-07-08 04:05:50     
1970-01-01 00:00:20     1970-01-01 04:20:01     NULL    1970-01-01 00:00:00     
1969-12-31 15:59:45.129 NULL    NULL
+1969-12-31 23:59:22    1970-01-01 04:20:01     NULL    1911-02-07 09:30:00     
1969-12-31 23:59:22     1970-01-01 04:20:01     NULL    1970-01-01 00:00:00     
1969-12-31 15:59:58.614 NULL    NULL
+1969-12-31 23:59:55    1970-01-01 04:20:01     NULL    1989-05-29 03:33:20     
1969-12-31 23:59:55     1970-01-01 04:20:01     NULL    1970-01-01 00:00:00     
1969-12-31 16:00:04.679 NULL    NULL
+1970-01-01 00:00:48    1970-01-01 04:20:01     NULL    1944-10-18 10:23:20     
1970-01-01 00:00:48     1970-01-01 04:20:01     NULL    1970-01-01 00:00:00     
1969-12-31 15:59:50.235 NULL    NULL
+1970-01-01 00:00:08    NULL    1949-01-13 08:21:02     1940-06-26 23:47:30     
1970-01-01 00:00:08     NULL    1970-01-01 00:00:00     1970-01-01 00:00:00     
1969-12-31 16:00:15.892 NULL    NULL
+1970-01-01 00:00:08    NULL    1966-09-27 14:32:46     1928-05-26 18:07:30     
1970-01-01 00:00:08     NULL    1970-01-01 00:00:00     1970-01-01 00:00:00     
1969-12-31 16:00:15.892 NULL    NULL
+1970-01-01 00:00:08    NULL    1995-07-08 05:01:04     1997-07-06 03:58:20     
1970-01-01 00:00:08     NULL    1970-01-01 00:00:00     1970-01-01 00:00:00     
1969-12-31 16:00:15.892 NULL    NULL
+1970-01-01 00:00:08    NULL    1948-10-12 15:01:29     2020-05-04 11:20:50     
1970-01-01 00:00:08     NULL    1970-01-01 00:00:00     1970-01-01 00:00:00     
1969-12-31 16:00:15.892 NULL    NULL
+1970-01-01 00:00:08    NULL    1998-03-27 08:56:12     1910-12-27 14:10:00     
1970-01-01 00:00:08     NULL    1970-01-01 00:00:01     1970-01-01 00:00:00     
1969-12-31 16:00:15.892 NULL    NULL
+1970-01-01 00:00:08    NULL    1999-07-01 22:14:06     2008-03-13 09:07:30     
1970-01-01 00:00:08     NULL    1970-01-01 00:00:01     1970-01-01 00:00:00     
1969-12-31 16:00:15.892 NULL    NULL
+1969-12-31 23:59:01    1969-12-31 22:00:04     NULL    1919-02-22 21:13:20     
1969-12-31 23:59:01     1969-12-31 22:00:04     NULL    1970-01-01 00:00:00     
1969-12-31 16:00:13.15  NULL    NULL
+1969-12-31 23:59:39    1969-12-31 22:00:04     NULL    2018-11-17 04:30:00     
1969-12-31 23:59:39     1969-12-31 22:00:04     NULL    1970-01-01 00:00:00     
1969-12-31 15:59:55.9   NULL    NULL
+1969-12-31 23:59:00    1969-12-31 22:00:04     NULL    2018-01-18 22:32:30     
1969-12-31 23:59:00     1969-12-31 22:00:04     NULL    1970-01-01 00:00:00     
1969-12-31 15:59:52.408 NULL    NULL
+1969-12-31 23:59:46    1969-12-31 22:00:04     NULL    1920-10-24 17:28:20     
1969-12-31 23:59:46     1969-12-31 22:00:04     NULL    1970-01-01 00:00:00     
1969-12-31 16:00:11.065 NULL    NULL
+1970-01-01 00:00:59    1969-12-31 22:00:04     NULL    1933-12-12 13:05:00     
1970-01-01 00:00:59     1969-12-31 22:00:04     NULL    1970-01-01 00:00:00     
1969-12-31 16:00:10.956 NULL    NULL
+1969-12-31 23:59:52    1969-12-31 22:00:04     NULL    1911-05-19 01:28:20     
1969-12-31 23:59:52     1969-12-31 22:00:04     NULL    1970-01-01 00:00:00     
1969-12-31 16:00:03.136 NULL    NULL
+1970-01-01 00:00:05    1969-12-31 22:00:04     NULL    1937-10-26 06:48:20     
1970-01-01 00:00:05     1969-12-31 22:00:04     NULL    1970-01-01 00:00:00     
1969-12-31 16:00:10.973 NULL    NULL
+1969-12-31 23:59:36    1969-12-31 22:00:04     NULL    1996-04-10 04:36:40     
1969-12-31 23:59:36     1969-12-31 22:00:04     NULL    1970-01-01 00:00:00     
1969-12-31 15:59:53.145 NULL    NULL
+1969-12-31 23:59:10    1969-12-31 22:00:04     NULL    1937-04-28 23:05:50     
1969-12-31 23:59:10     1969-12-31 22:00:04     NULL    1970-01-01 00:00:00     
1969-12-31 15:59:54.733 NULL    NULL
+1970-01-01 00:00:11    NULL    1967-12-15 03:06:58     2027-02-19 16:15:50     
1970-01-01 00:00:11     NULL    1970-01-01 00:00:01     1970-01-01 00:00:00     
1969-12-31 16:00:02.351 NULL    NULL
+1970-01-01 00:00:11    NULL    1959-05-16 11:19:43     2009-01-30 14:50:00     
1970-01-01 00:00:11     NULL    1970-01-01 00:00:01     1970-01-01 00:00:00     
1969-12-31 16:00:02.351 NULL    NULL

http://git-wip-us.apache.org/repos/asf/hive/blob/c95136a0/ql/src/test/results/clientpositive/windowing_distinct.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/windowing_distinct.q.out 
b/ql/src/test/results/clientpositive/windowing_distinct.q.out
index eab1d88..07bc8a1 100644
--- a/ql/src/test/results/clientpositive/windowing_distinct.q.out
+++ b/ql/src/test/results/clientpositive/windowing_distinct.q.out
@@ -96,12 +96,12 @@ FROM windowing_distinct
 POSTHOOK: type: QUERY
 POSTHOOK: Input: default@windowing_distinct
 #### A masked pattern was here ####
-54     56.63   0.0     0.0     2.724315837406296E9     57
-54     56.63   0.0     0.0     2.724315837406296E9     57
-54     56.63   0.0     0.0     2.724315837406296E9     57
-235    77.42   0.0     0.0     2.724315837406612E9     69
-235    77.42   0.0     0.0     2.724315837406612E9     69
-235    77.42   0.0     0.0     2.724315837406612E9     69
+54     56.63   0.0     0.0     2.724258237406296E9     57
+54     56.63   0.0     0.0     2.724258237406296E9     57
+54     56.63   0.0     0.0     2.724258237406296E9     57
+235    77.42   0.0     0.0     2.724258237406612E9     69
+235    77.42   0.0     0.0     2.724258237406612E9     69
+235    77.42   0.0     0.0     2.724258237406612E9     69
 PREHOOK: query: SELECT AVG(DISTINCT t) OVER (PARTITION BY index),
        AVG(DISTINCT d) OVER (PARTITION BY index),
        AVG(DISTINCT s) OVER (PARTITION BY index),
@@ -122,12 +122,12 @@ FROM windowing_distinct
 POSTHOOK: type: QUERY
 POSTHOOK: Input: default@windowing_distinct
 #### A masked pattern was here ####
-27.0   28.315  NULL    NULL    1.362157918703148E9     28.5000
-27.0   28.315  NULL    NULL    1.362157918703148E9     28.5000
-27.0   28.315  NULL    NULL    1.362157918703148E9     28.5000
-117.5  38.71   NULL    NULL    1.362157918703306E9     34.5000
-117.5  38.71   NULL    NULL    1.362157918703306E9     34.5000
-117.5  38.71   NULL    NULL    1.362157918703306E9     34.5000
+27.0   28.315  NULL    NULL    1.362129118703148E9     28.5000
+27.0   28.315  NULL    NULL    1.362129118703148E9     28.5000
+27.0   28.315  NULL    NULL    1.362129118703148E9     28.5000
+117.5  38.71   NULL    NULL    1.362129118703306E9     34.5000
+117.5  38.71   NULL    NULL    1.362129118703306E9     34.5000
+117.5  38.71   NULL    NULL    1.362129118703306E9     34.5000
 PREHOOK: query: select index, f, count(distinct f) over (partition by index 
order by f rows between 2 preceding and 1 preceding),
                  count(distinct f) over (partition by index order by f rows 
between unbounded preceding and 1 preceding),
                  count(distinct f) over (partition by index order by f rows 
between 1 following and 2 following),

http://git-wip-us.apache.org/repos/asf/hive/blob/c95136a0/serde/src/java/org/apache/hadoop/hive/serde2/JsonSerDe.java
----------------------------------------------------------------------
diff --git a/serde/src/java/org/apache/hadoop/hive/serde2/JsonSerDe.java 
b/serde/src/java/org/apache/hadoop/hive/serde2/JsonSerDe.java
index 1119fa2..2bb4a0f 100644
--- a/serde/src/java/org/apache/hadoop/hive/serde2/JsonSerDe.java
+++ b/serde/src/java/org/apache/hadoop/hive/serde2/JsonSerDe.java
@@ -21,8 +21,6 @@ package org.apache.hadoop.hive.serde2;
 import java.io.ByteArrayInputStream;
 import java.io.IOException;
 import java.nio.charset.CharacterCodingException;
-import java.sql.Date;
-import java.sql.Timestamp;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collections;
@@ -34,14 +32,13 @@ import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
 import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.hive.common.type.Date;
 import org.apache.hadoop.hive.common.type.HiveChar;
 import org.apache.hadoop.hive.common.type.HiveDecimal;
 import org.apache.hadoop.hive.common.type.HiveVarchar;
+import org.apache.hadoop.hive.common.type.Timestamp;
 import org.apache.hadoop.hive.conf.HiveConf;
 import org.apache.hadoop.hive.serde.serdeConstants;
-import org.apache.hadoop.hive.serde2.lazy.LazyFactory;
-import org.apache.hadoop.hive.serde2.lazy.LazyObjectBase;
-import org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe;
 import org.apache.hadoop.hive.serde2.objectinspector.ListObjectInspector;
 import org.apache.hadoop.hive.serde2.objectinspector.MapObjectInspector;
 import org.apache.hadoop.hive.serde2.objectinspector.ObjectInspector;

http://git-wip-us.apache.org/repos/asf/hive/blob/c95136a0/serde/src/java/org/apache/hadoop/hive/serde2/RandomTypeUtil.java
----------------------------------------------------------------------
diff --git a/serde/src/java/org/apache/hadoop/hive/serde2/RandomTypeUtil.java 
b/serde/src/java/org/apache/hadoop/hive/serde2/RandomTypeUtil.java
new file mode 100644
index 0000000..9360509
--- /dev/null
+++ b/serde/src/java/org/apache/hadoop/hive/serde2/RandomTypeUtil.java
@@ -0,0 +1,189 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.hadoop.hive.serde2;
+
+import org.apache.hadoop.hive.common.type.Date;
+import org.apache.hadoop.hive.common.type.HiveDecimal;
+import org.apache.hadoop.hive.common.type.Timestamp;
+
+import java.text.DateFormat;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.Random;
+import java.util.concurrent.TimeUnit;
+
+public class RandomTypeUtil {
+
+  public static String getRandString(Random r) {
+    return getRandString(r, null, r.nextInt(10));
+  }
+
+  public static String getRandString(Random r, String characters, int length) {
+    if (characters == null) {
+      characters = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
+
+    }
+    StringBuilder sb = new StringBuilder();
+    for (int i = 0; i < length; i++) {
+      if (characters == null) {
+        sb.append((char) (r.nextInt(128)));
+      } else {
+        sb.append(characters.charAt(r.nextInt(characters.length())));
+      }
+    }
+    return sb.toString();
+  }
+
+  public static byte[] getRandBinary(Random r, int len){
+    byte[] bytes = new byte[len];
+    for (int j = 0; j < len; j++){
+      bytes[j] = Byte.valueOf((byte) r.nextInt());
+    }
+    return bytes;
+  }
+
+  private static final String DECIMAL_CHARS = "0123456789";
+
+  public static HiveDecimal getRandHiveDecimal(Random r) {
+    int precision;
+    int scale;
+    while (true) {
+      StringBuilder sb = new StringBuilder();
+      precision = 1 + r.nextInt(18);
+      scale = 0 + r.nextInt(precision + 1);
+
+      int integerDigits = precision - scale;
+
+      if (r.nextBoolean()) {
+        sb.append("-");
+      }
+
+      if (integerDigits == 0) {
+        sb.append("0");
+      } else {
+        sb.append(getRandString(r, DECIMAL_CHARS, integerDigits));
+      }
+      if (scale != 0) {
+        sb.append(".");
+        sb.append(getRandString(r, DECIMAL_CHARS, scale));
+      }
+
+      return HiveDecimal.create(sb.toString());
+    }
+  }
+
+  public static Date getRandDate(Random r) {
+    String dateStr = String.format("%d-%02d-%02d",
+        Integer.valueOf(1800 + r.nextInt(500)),  // year
+        Integer.valueOf(1 + r.nextInt(12)),      // month
+        Integer.valueOf(1 + r.nextInt(28)));     // day
+    Date dateVal = Date.valueOf(dateStr);
+    return dateVal;
+  }
+
+  /**
+   * TIMESTAMP.
+   */
+
+  public static final long NANOSECONDS_PER_SECOND = 
TimeUnit.SECONDS.toNanos(1);
+  public static final long MILLISECONDS_PER_SECOND = 
TimeUnit.SECONDS.toMillis(1);
+  public static final long NANOSECONDS_PER_MILLISSECOND = 
TimeUnit.MILLISECONDS.toNanos(1);
+
+  private static final ThreadLocal<DateFormat> DATE_FORMAT =
+      new ThreadLocal<DateFormat>() {
+        @Override
+        protected DateFormat initialValue() {
+          return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+        }
+      };
+
+  // We've switched to Joda/Java Calendar which has a more limited time 
range....
+  public static final int MIN_YEAR = 1900;
+  public static final int MAX_YEAR = 3000;
+  private static final long MIN_FOUR_DIGIT_YEAR_MILLIS = 
parseToMillis("1900-01-01 00:00:00");
+  private static final long MAX_FOUR_DIGIT_YEAR_MILLIS = 
parseToMillis("3000-01-01 00:00:00");
+
+  private static long parseToMillis(String s) {
+    try {
+      return DATE_FORMAT.get().parse(s).getTime();
+    } catch (ParseException ex) {
+      throw new RuntimeException(ex);
+    }
+  }
+
+  public static Timestamp getRandTimestamp(Random r) {
+    return getRandTimestamp(r, MIN_YEAR, MAX_YEAR);
+  }
+
+  public static Timestamp getRandTimestamp(Random r, int minYear, int maxYear) 
{
+    String optionalNanos = "";
+    switch (r.nextInt(4)) {
+    case 0:
+      // No nanos.
+      break;
+    case 1:
+      optionalNanos = String.format(".%09d",
+          Integer.valueOf(r.nextInt((int) NANOSECONDS_PER_SECOND)));
+      break;
+    case 2:
+      // Limit to milliseconds only...
+      optionalNanos = String.format(".%09d",
+          Integer.valueOf(r.nextInt((int) MILLISECONDS_PER_SECOND)) * 
NANOSECONDS_PER_MILLISSECOND);
+      break;
+    case 3:
+      // Limit to below milliseconds only...
+      optionalNanos = String.format(".%09d",
+          Integer.valueOf(r.nextInt((int) NANOSECONDS_PER_MILLISSECOND)));
+      break;
+    }
+    String timestampStr = String.format("%04d-%02d-%02d %02d:%02d:%02d%s",
+        Integer.valueOf(minYear + r.nextInt(maxYear - minYear + 1)),  // year
+        Integer.valueOf(1 + r.nextInt(12)),      // month
+        Integer.valueOf(1 + r.nextInt(28)),      // day
+        Integer.valueOf(0 + r.nextInt(24)),      // hour
+        Integer.valueOf(0 + r.nextInt(60)),      // minute
+        Integer.valueOf(0 + r.nextInt(60)),      // second
+        optionalNanos);
+    Timestamp timestampVal;
+    try {
+      timestampVal = Timestamp.valueOf(timestampStr);
+    } catch (Exception e) {
+      System.err.println("Timestamp string " + timestampStr + " did not 
parse");
+      throw e;
+    }
+    return timestampVal;
+  }
+
+  public static long randomMillis(long minMillis, long maxMillis, Random rand) 
{
+    return minMillis + (long) ((maxMillis - minMillis) * rand.nextDouble());
+  }
+
+  public static long randomMillis(Random rand) {
+    return randomMillis(MIN_FOUR_DIGIT_YEAR_MILLIS, 
MAX_FOUR_DIGIT_YEAR_MILLIS, rand);
+  }
+
+  public static int randomNanos(Random rand, int decimalDigits) {
+    // Only keep the most significant decimalDigits digits.
+    int nanos = rand.nextInt((int) NANOSECONDS_PER_SECOND);
+    return nanos - nanos % (int) Math.pow(10, 9 - decimalDigits);
+  }
+
+  public static int randomNanos(Random rand) {
+    return randomNanos(rand, 9);
+  }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/hive/blob/c95136a0/serde/src/java/org/apache/hadoop/hive/serde2/RegexSerDe.java
----------------------------------------------------------------------
diff --git a/serde/src/java/org/apache/hadoop/hive/serde2/RegexSerDe.java 
b/serde/src/java/org/apache/hadoop/hive/serde2/RegexSerDe.java
index e1ecdc1..71a9cfc 100644
--- a/serde/src/java/org/apache/hadoop/hive/serde2/RegexSerDe.java
+++ b/serde/src/java/org/apache/hadoop/hive/serde2/RegexSerDe.java
@@ -17,8 +17,6 @@
  */
 package org.apache.hadoop.hive.serde2;
 
-import java.sql.Date;
-import java.sql.Timestamp;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.List;
@@ -26,6 +24,8 @@ import java.util.Properties;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
+import org.apache.hadoop.hive.common.type.Date;
+import org.apache.hadoop.hive.common.type.Timestamp;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.apache.hadoop.conf.Configuration;

http://git-wip-us.apache.org/repos/asf/hive/blob/c95136a0/serde/src/java/org/apache/hadoop/hive/serde2/avro/AvroDeserializer.java
----------------------------------------------------------------------
diff --git 
a/serde/src/java/org/apache/hadoop/hive/serde2/avro/AvroDeserializer.java 
b/serde/src/java/org/apache/hadoop/hive/serde2/avro/AvroDeserializer.java
index 34da50d..8cdc567 100644
--- a/serde/src/java/org/apache/hadoop/hive/serde2/avro/AvroDeserializer.java
+++ b/serde/src/java/org/apache/hadoop/hive/serde2/avro/AvroDeserializer.java
@@ -22,8 +22,6 @@ import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 import java.nio.ByteBuffer;
 import java.rmi.server.UID;
-import java.sql.Date;
-import java.sql.Timestamp;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.HashSet;
@@ -42,12 +40,14 @@ import org.apache.avro.io.BinaryEncoder;
 import org.apache.avro.io.DecoderFactory;
 import org.apache.avro.io.EncoderFactory;
 import org.apache.avro.UnresolvedUnionException;
+import org.apache.hadoop.hive.common.type.Date;
+import org.apache.hadoop.hive.common.type.Timestamp;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.apache.hadoop.hive.common.type.HiveChar;
 import org.apache.hadoop.hive.common.type.HiveDecimal;
 import org.apache.hadoop.hive.common.type.HiveVarchar;
-import org.apache.hadoop.hive.serde2.io.DateWritable;
+import org.apache.hadoop.hive.serde2.io.DateWritableV2;
 import 
org.apache.hadoop.hive.serde2.objectinspector.StandardUnionObjectInspector;
 import 
org.apache.hadoop.hive.serde2.objectinspector.primitive.JavaHiveDecimalObjectInspector;
 import 
org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorFactory;
@@ -295,13 +295,13 @@ class AvroDeserializer {
         throw new AvroSerdeException("Unexpected Avro schema for Date 
TypeInfo: " + recordSchema.getType());
       }
 
-      return new Date(DateWritable.daysToMillis((Integer)datum));
+      return Date.ofEpochMilli(DateWritableV2.daysToMillis((Integer)datum));
     case TIMESTAMP:
       if (recordSchema.getType() != Type.LONG) {
         throw new AvroSerdeException(
           "Unexpected Avro schema for Date TypeInfo: " + 
recordSchema.getType());
       }
-      return new Timestamp((Long)datum);
+      return Timestamp.ofEpochMilli((Long)datum);
     default:
       return datum;
     }

http://git-wip-us.apache.org/repos/asf/hive/blob/c95136a0/serde/src/java/org/apache/hadoop/hive/serde2/avro/AvroSerializer.java
----------------------------------------------------------------------
diff --git 
a/serde/src/java/org/apache/hadoop/hive/serde2/avro/AvroSerializer.java 
b/serde/src/java/org/apache/hadoop/hive/serde2/avro/AvroSerializer.java
index b4c9c22..99a0b9a 100644
--- a/serde/src/java/org/apache/hadoop/hive/serde2/avro/AvroSerializer.java
+++ b/serde/src/java/org/apache/hadoop/hive/serde2/avro/AvroSerializer.java
@@ -17,8 +17,6 @@
  */
 package org.apache.hadoop.hive.serde2.avro;
 
-import java.sql.Date;
-import java.sql.Timestamp;
 import java.util.ArrayList;
 import java.util.LinkedHashMap;
 import java.util.List;
@@ -28,16 +26,15 @@ import java.util.Set;
 import org.apache.avro.Schema;
 import org.apache.avro.Schema.Field;
 import org.apache.avro.Schema.Type;
-import org.apache.avro.generic.GenericArray;
 import org.apache.avro.generic.GenericData;
 import org.apache.avro.generic.GenericData.Fixed;
 import org.apache.avro.generic.GenericEnumSymbol;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import org.apache.hadoop.hive.common.type.Date;
 import org.apache.hadoop.hive.common.type.HiveChar;
 import org.apache.hadoop.hive.common.type.HiveDecimal;
 import org.apache.hadoop.hive.common.type.HiveVarchar;
-import org.apache.hadoop.hive.serde2.io.DateWritable;
+import org.apache.hadoop.hive.common.type.Timestamp;
+import org.apache.hadoop.hive.serde2.io.DateWritableV2;
 import org.apache.hadoop.hive.serde2.objectinspector.ListObjectInspector;
 import org.apache.hadoop.hive.serde2.objectinspector.MapObjectInspector;
 import org.apache.hadoop.hive.serde2.objectinspector.ObjectInspector;
@@ -210,11 +207,11 @@ class AvroSerializer {
       return vc.getValue();
     case DATE:
       Date date = 
((DateObjectInspector)fieldOI).getPrimitiveJavaObject(structFieldData);
-      return DateWritable.dateToDays(date);
+      return DateWritableV2.dateToDays(date);
     case TIMESTAMP:
       Timestamp timestamp =
         ((TimestampObjectInspector) 
fieldOI).getPrimitiveJavaObject(structFieldData);
-      return timestamp.getTime();
+      return timestamp.toEpochMilli();
     case UNKNOWN:
       throw new AvroSerdeException("Received UNKNOWN primitive category.");
     case VOID:

http://git-wip-us.apache.org/repos/asf/hive/blob/c95136a0/serde/src/java/org/apache/hadoop/hive/serde2/binarysortable/BinarySortableSerDe.java
----------------------------------------------------------------------
diff --git 
a/serde/src/java/org/apache/hadoop/hive/serde2/binarysortable/BinarySortableSerDe.java
 
b/serde/src/java/org/apache/hadoop/hive/serde2/binarysortable/BinarySortableSerDe.java
index a48d4fe..f58fb72 100644
--- 
a/serde/src/java/org/apache/hadoop/hive/serde2/binarysortable/BinarySortableSerDe.java
+++ 
b/serde/src/java/org/apache/hadoop/hive/serde2/binarysortable/BinarySortableSerDe.java
@@ -43,7 +43,7 @@ import org.apache.hadoop.hive.serde2.SerDeSpec;
 import org.apache.hadoop.hive.serde2.SerDeStats;
 import org.apache.hadoop.hive.serde2.SerDeUtils;
 import org.apache.hadoop.hive.serde2.io.ByteWritable;
-import org.apache.hadoop.hive.serde2.io.DateWritable;
+import org.apache.hadoop.hive.serde2.io.DateWritableV2;
 import org.apache.hadoop.hive.serde2.io.DoubleWritable;
 import org.apache.hadoop.hive.serde2.io.HiveCharWritable;
 import org.apache.hadoop.hive.serde2.io.HiveDecimalWritable;
@@ -52,7 +52,7 @@ import 
org.apache.hadoop.hive.serde2.io.HiveIntervalYearMonthWritable;
 import org.apache.hadoop.hive.serde2.io.HiveVarcharWritable;
 import org.apache.hadoop.hive.serde2.io.ShortWritable;
 import org.apache.hadoop.hive.serde2.io.TimestampLocalTZWritable;
-import org.apache.hadoop.hive.serde2.io.TimestampWritable;
+import org.apache.hadoop.hive.serde2.io.TimestampWritableV2;
 import org.apache.hadoop.hive.serde2.objectinspector.ListObjectInspector;
 import org.apache.hadoop.hive.serde2.objectinspector.MapObjectInspector;
 import org.apache.hadoop.hive.serde2.objectinspector.ObjectInspector;
@@ -407,16 +407,16 @@ public class BinarySortableSerDe extends AbstractSerDe {
       }
 
       case DATE: {
-        DateWritable d = reuse == null ? new DateWritable()
-            : (DateWritable) reuse;
+        DateWritableV2 d = reuse == null ? new DateWritableV2()
+            : (DateWritableV2) reuse;
         d.set(deserializeInt(buffer, invert));
         return d;
       }
 
       case TIMESTAMP:
-        TimestampWritable t = (reuse == null ? new TimestampWritable() :
-            (TimestampWritable) reuse);
-        byte[] bytes = new byte[TimestampWritable.BINARY_SORTABLE_LENGTH];
+        TimestampWritableV2 t = (reuse == null ? new TimestampWritableV2() :
+            (TimestampWritableV2) reuse);
+        byte[] bytes = new byte[TimestampWritableV2.BINARY_SORTABLE_LENGTH];
 
         for (int i = 0; i < bytes.length; i++) {
           bytes[i] = buffer.read(invert);
@@ -797,7 +797,7 @@ public class BinarySortableSerDe extends AbstractSerDe {
       }
       case TIMESTAMP: {
         TimestampObjectInspector toi = (TimestampObjectInspector) poi;
-        TimestampWritable t = toi.getPrimitiveWritableObject(o);
+        TimestampWritableV2 t = toi.getPrimitiveWritableObject(o);
         serializeTimestampWritable(buffer, t, invert);
         return;
       }
@@ -970,7 +970,7 @@ public class BinarySortableSerDe extends AbstractSerDe {
     writeByte(buffer, (byte) v, invert);
   }
 
-  public static void serializeTimestampWritable(ByteStream.Output buffer, 
TimestampWritable t, boolean invert) {
+  public static void serializeTimestampWritable(ByteStream.Output buffer, 
TimestampWritableV2 t, boolean invert) {
     byte[] data = t.getBinarySortable();
     for (int i = 0; i < data.length; i++) {
       writeByte(buffer, data[i], invert);

http://git-wip-us.apache.org/repos/asf/hive/blob/c95136a0/serde/src/java/org/apache/hadoop/hive/serde2/binarysortable/fast/BinarySortableDeserializeRead.java
----------------------------------------------------------------------
diff --git 
a/serde/src/java/org/apache/hadoop/hive/serde2/binarysortable/fast/BinarySortableDeserializeRead.java
 
b/serde/src/java/org/apache/hadoop/hive/serde2/binarysortable/fast/BinarySortableDeserializeRead.java
index 461043d..62f59af 100644
--- 
a/serde/src/java/org/apache/hadoop/hive/serde2/binarysortable/fast/BinarySortableDeserializeRead.java
+++ 
b/serde/src/java/org/apache/hadoop/hive/serde2/binarysortable/fast/BinarySortableDeserializeRead.java
@@ -35,7 +35,7 @@ import org.slf4j.LoggerFactory;
 import org.apache.hadoop.hive.serde2.binarysortable.BinarySortableSerDe;
 import org.apache.hadoop.hive.serde2.binarysortable.InputByteBuffer;
 import org.apache.hadoop.hive.serde2.fast.DeserializeRead;
-import org.apache.hadoop.hive.serde2.io.TimestampWritable;
+import org.apache.hadoop.hive.serde2.io.TimestampWritableV2;
 import org.apache.hadoop.hive.serde2.typeinfo.DecimalTypeInfo;
 import org.apache.hadoop.hive.serde2.typeinfo.PrimitiveTypeInfo;
 import org.apache.hadoop.hive.serde2.typeinfo.TypeInfo;
@@ -279,7 +279,7 @@ public final class BinarySortableDeserializeRead extends 
DeserializeRead {
     case TIMESTAMP:
       {
         if (tempTimestampBytes == null) {
-          tempTimestampBytes = new 
byte[TimestampWritable.BINARY_SORTABLE_LENGTH];
+          tempTimestampBytes = new 
byte[TimestampWritableV2.BINARY_SORTABLE_LENGTH];
         }
         final boolean invert = columnSortOrderIsDesc[fieldIndex];
         for (int i = 0; i < tempTimestampBytes.length; i++) {

http://git-wip-us.apache.org/repos/asf/hive/blob/c95136a0/serde/src/java/org/apache/hadoop/hive/serde2/binarysortable/fast/BinarySortableSerializeWrite.java
----------------------------------------------------------------------
diff --git 
a/serde/src/java/org/apache/hadoop/hive/serde2/binarysortable/fast/BinarySortableSerializeWrite.java
 
b/serde/src/java/org/apache/hadoop/hive/serde2/binarysortable/fast/BinarySortableSerializeWrite.java
index 2f987bf..b1ee7ec 100644
--- 
a/serde/src/java/org/apache/hadoop/hive/serde2/binarysortable/fast/BinarySortableSerializeWrite.java
+++ 
b/serde/src/java/org/apache/hadoop/hive/serde2/binarysortable/fast/BinarySortableSerializeWrite.java
@@ -19,23 +19,23 @@
 package org.apache.hadoop.hive.serde2.binarysortable.fast;
 
 import java.io.IOException;
-import java.sql.Date;
-import java.sql.Timestamp;
 import java.util.Arrays;
 import java.util.List;
 import java.util.Map;
 
+import org.apache.hadoop.hive.common.type.Date;
 import org.apache.hadoop.hive.common.type.HiveChar;
 import org.apache.hadoop.hive.common.type.HiveDecimal;
 import org.apache.hadoop.hive.common.type.HiveIntervalDayTime;
 import org.apache.hadoop.hive.common.type.HiveIntervalYearMonth;
 import org.apache.hadoop.hive.common.type.HiveVarchar;
+import org.apache.hadoop.hive.common.type.Timestamp;
 import org.apache.hadoop.hive.serde2.ByteStream.Output;
 import org.apache.hadoop.hive.serde2.binarysortable.BinarySortableSerDe;
 import org.apache.hadoop.hive.serde2.fast.SerializeWrite;
-import org.apache.hadoop.hive.serde2.io.DateWritable;
+import org.apache.hadoop.hive.serde2.io.DateWritableV2;
 import org.apache.hadoop.hive.serde2.io.HiveDecimalWritable;
-import org.apache.hadoop.hive.serde2.io.TimestampWritable;
+import org.apache.hadoop.hive.serde2.io.TimestampWritableV2;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -60,7 +60,7 @@ public final class BinarySortableSerializeWrite implements 
SerializeWrite {
   private int index;
   private int level;
 
-  private TimestampWritable tempTimestampWritable;
+  private TimestampWritableV2 tempTimestampWritable;
   private HiveDecimalWritable hiveDecimalWritable;
   private byte[] decimalBytesScratch;
 
@@ -88,7 +88,7 @@ public final class BinarySortableSerializeWrite implements 
SerializeWrite {
 
   // Not public since we must have the field count or column sort order 
information.
   private BinarySortableSerializeWrite() {
-    tempTimestampWritable = new TimestampWritable();
+    tempTimestampWritable = new TimestampWritableV2();
   }
 
   /*
@@ -262,7 +262,7 @@ public final class BinarySortableSerializeWrite implements 
SerializeWrite {
   @Override
   public void writeDate(Date date) throws IOException {
     beginElement();
-    BinarySortableSerDe.serializeInt(output, DateWritable.dateToDays(date), 
columnSortOrderIsDesc[index]);
+    BinarySortableSerDe.serializeInt(output, DateWritableV2.dateToDays(date), 
columnSortOrderIsDesc[index]);
   }
 
   // We provide a faster way to write a date without a Date object.

http://git-wip-us.apache.org/repos/asf/hive/blob/c95136a0/serde/src/java/org/apache/hadoop/hive/serde2/fast/DeserializeRead.java
----------------------------------------------------------------------
diff --git 
a/serde/src/java/org/apache/hadoop/hive/serde2/fast/DeserializeRead.java 
b/serde/src/java/org/apache/hadoop/hive/serde2/fast/DeserializeRead.java
index 197031d..2c9aaa3 100644
--- a/serde/src/java/org/apache/hadoop/hive/serde2/fast/DeserializeRead.java
+++ b/serde/src/java/org/apache/hadoop/hive/serde2/fast/DeserializeRead.java
@@ -22,11 +22,11 @@ import java.io.IOException;
 import java.util.Arrays;
 
 import org.apache.hadoop.hive.common.type.DataTypePhysicalVariation;
-import org.apache.hadoop.hive.serde2.io.DateWritable;
+import org.apache.hadoop.hive.serde2.io.DateWritableV2;
 import org.apache.hadoop.hive.serde2.io.HiveDecimalWritable;
 import org.apache.hadoop.hive.serde2.io.HiveIntervalDayTimeWritable;
 import org.apache.hadoop.hive.serde2.io.HiveIntervalYearMonthWritable;
-import org.apache.hadoop.hive.serde2.io.TimestampWritable;
+import org.apache.hadoop.hive.serde2.io.TimestampWritableV2;
 import org.apache.hadoop.hive.serde2.objectinspector.ObjectInspector.Category;
 import 
org.apache.hadoop.hive.serde2.objectinspector.PrimitiveObjectInspector.PrimitiveCategory;
 import org.apache.hadoop.hive.serde2.typeinfo.ListTypeInfo;
@@ -75,12 +75,12 @@ public abstract class DeserializeRead {
       switch (((PrimitiveTypeInfo) typeInfo).getPrimitiveCategory()) {
       case DATE:
         if (currentDateWritable == null) {
-          currentDateWritable = new DateWritable();
+          currentDateWritable = new DateWritableV2();
         }
         break;
       case TIMESTAMP:
         if (currentTimestampWritable == null) {
-          currentTimestampWritable = new TimestampWritable();
+          currentTimestampWritable = new TimestampWritableV2();
         }
         break;
       case INTERVAL_YEAR_MONTH:
@@ -343,12 +343,12 @@ public abstract class DeserializeRead {
   /*
    * DATE.
    */
-  public DateWritable currentDateWritable;
+  public DateWritableV2 currentDateWritable;
 
   /*
    * TIMESTAMP.
    */
-  public TimestampWritable currentTimestampWritable;
+  public TimestampWritableV2 currentTimestampWritable;
 
   /*
    * INTERVAL_YEAR_MONTH.

http://git-wip-us.apache.org/repos/asf/hive/blob/c95136a0/serde/src/java/org/apache/hadoop/hive/serde2/fast/SerializeWrite.java
----------------------------------------------------------------------
diff --git 
a/serde/src/java/org/apache/hadoop/hive/serde2/fast/SerializeWrite.java 
b/serde/src/java/org/apache/hadoop/hive/serde2/fast/SerializeWrite.java
index 3aff610..4d4717f 100644
--- a/serde/src/java/org/apache/hadoop/hive/serde2/fast/SerializeWrite.java
+++ b/serde/src/java/org/apache/hadoop/hive/serde2/fast/SerializeWrite.java
@@ -19,17 +19,17 @@
 package org.apache.hadoop.hive.serde2.fast;
 
 import java.io.IOException;
-import java.sql.Date;
-import java.sql.Timestamp;
 import java.util.List;
 import java.util.Map;
 
+import org.apache.hadoop.hive.common.type.Date;
 import org.apache.hadoop.hive.common.type.HiveChar;
 import org.apache.hadoop.hive.common.type.HiveDecimal;
 import org.apache.hadoop.hive.serde2.io.HiveDecimalWritable;
 import org.apache.hadoop.hive.common.type.HiveIntervalDayTime;
 import org.apache.hadoop.hive.common.type.HiveIntervalYearMonth;
 import org.apache.hadoop.hive.common.type.HiveVarchar;
+import org.apache.hadoop.hive.common.type.Timestamp;
 import org.apache.hadoop.hive.serde2.ByteStream.Output;
 
 /*

http://git-wip-us.apache.org/repos/asf/hive/blob/c95136a0/serde/src/java/org/apache/hadoop/hive/serde2/io/DateWritableV2.java
----------------------------------------------------------------------
diff --git 
a/serde/src/java/org/apache/hadoop/hive/serde2/io/DateWritableV2.java 
b/serde/src/java/org/apache/hadoop/hive/serde2/io/DateWritableV2.java
new file mode 100644
index 0000000..ba77608
--- /dev/null
+++ b/serde/src/java/org/apache/hadoop/hive/serde2/io/DateWritableV2.java
@@ -0,0 +1,154 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.hadoop.hive.serde2.io;
+
+import java.io.DataInput;
+import java.io.DataOutput;
+import java.io.IOException;
+
+import org.apache.hadoop.hive.common.type.Date;
+import org.apache.hadoop.io.WritableComparable;
+import org.apache.hadoop.io.WritableUtils;
+
+
+/**
+ * DateWritableV2
+ * Writable equivalent of java.sql.Date.
+ *
+ * Dates are of the format
+ *    YYYY-MM-DD
+ *
+ */
+public class DateWritableV2 implements WritableComparable<DateWritableV2> {
+
+  private Date date = new Date();
+
+  /* Constructors */
+  public DateWritableV2() {
+  }
+
+  public DateWritableV2(DateWritableV2 d) {
+    set(d);
+  }
+
+  public DateWritableV2(Date d) {
+    set(d);
+  }
+
+  public DateWritableV2(int d) {
+    set(d);
+  }
+
+  /**
+   * Set the DateWritableV2 based on the days since epoch date.
+   * @param d integer value representing days since epoch date
+   */
+  public void set(int d) {
+    date = Date.ofEpochDay(d);
+  }
+
+  /**
+   * Set the DateWritableV2 based on the year/month/day of the date in the 
local timezone.
+   * @param d Date value
+   */
+  public void set(Date d) {
+    if (d == null) {
+      date = new Date();
+      return;
+    }
+
+    set(d.toEpochDay());
+  }
+
+  public void set(DateWritableV2 d) {
+    set(d.getDays());
+  }
+
+  /**
+   * @return Date value corresponding to the date in the local time zone
+   */
+  public Date get() {
+    return date;
+  }
+
+  public int getDays() {
+    return date.toEpochDay();
+  }
+
+  /**
+   *
+   * @return time in seconds corresponding to this DateWritableV2
+   */
+  public long getTimeInSeconds() {
+    return date.toEpochSecond();
+  }
+
+  public static Date timeToDate(long seconds) {
+    return Date.ofEpochMilli(seconds * 1000);
+  }
+
+  public static long daysToMillis(int days) {
+    return Date.ofEpochDay(days).toEpochMilli();
+  }
+
+  public static int millisToDays(long millis) {
+    return Date.ofEpochMilli(millis).toEpochDay();
+  }
+
+  public static int dateToDays(Date d) {
+    return d.toEpochDay();
+  }
+
+  @Deprecated
+  public static int dateToDays(java.sql.Date d) {
+    return Date.ofEpochMilli(d.getTime()).toEpochDay();
+  }
+
+  @Override
+  public void readFields(DataInput in) throws IOException {
+    date.setTimeInDays(WritableUtils.readVInt(in));
+  }
+
+  @Override
+  public void write(DataOutput out) throws IOException {
+    WritableUtils.writeVInt(out, (int) date.toEpochDay());
+  }
+
+  @Override
+  public int compareTo(DateWritableV2 d) {
+    return date.compareTo(d.date);
+  }
+
+  @Override
+  public boolean equals(Object o) {
+    if (!(o instanceof DateWritableV2)) {
+      return false;
+    }
+    return compareTo((DateWritableV2) o) == 0;
+  }
+
+  @Override
+  public String toString() {
+    return date.toString();
+  }
+
+  @Override
+  public int hashCode() {
+    return date.hashCode();
+  }
+}

http://git-wip-us.apache.org/repos/asf/hive/blob/c95136a0/serde/src/java/org/apache/hadoop/hive/serde2/io/TimestampLocalTZWritable.java
----------------------------------------------------------------------
diff --git 
a/serde/src/java/org/apache/hadoop/hive/serde2/io/TimestampLocalTZWritable.java 
b/serde/src/java/org/apache/hadoop/hive/serde2/io/TimestampLocalTZWritable.java
index e685f4e..3ffcb7a 100644
--- 
a/serde/src/java/org/apache/hadoop/hive/serde2/io/TimestampLocalTZWritable.java
+++ 
b/serde/src/java/org/apache/hadoop/hive/serde2/io/TimestampLocalTZWritable.java
@@ -31,7 +31,7 @@ import java.time.ZoneId;
 import java.util.Arrays;
 
 /**
- * Writable for TimestampTZ. Copied from TimestampWritable.
+ * Writable for TimestampTZ. Copied from TimestampWritableV2.
  * After we replace {@link java.sql.Timestamp} with {@link 
java.time.LocalDateTime} for Timestamp,
  * it'll need a new Writable.
  * All timestamp with time zone will be serialized as UTC retaining the 
instant.
@@ -45,7 +45,7 @@ public class TimestampLocalTZWritable implements 
WritableComparable<TimestampLoc
   private static final long SEVEN_BYTE_LONG_SIGN_FLIP = 0xff80L << 48; // only 
need flip the MSB?
 
   /**
-   * The maximum number of bytes required for a TimestampWritable
+   * The maximum number of bytes required for a TimestampWritableV2
    */
   public static final int MAX_BYTES = 13;
 

Reply via email to