You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hive.apache.org by ai...@apache.org on 2017/01/12 14:25:45 UTC

[01/13] hive git commit: HIVE-15520: Improve the sum performance for Range based window (Aihua Xu, reviewed by Yongzhi Chen)

Repository: hive
Updated Branches:
  refs/heads/master 6973edcfb -> a28b28f32


http://git-wip-us.apache.org/repos/asf/hive/blob/a28b28f3/ql/src/test/results/clientpositive/windowing.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/windowing.q.out b/ql/src/test/results/clientpositive/windowing.q.out
index b17bfc1..4665c97 100644
--- a/ql/src/test/results/clientpositive/windowing.q.out
+++ b/ql/src/test/results/clientpositive/windowing.q.out
@@ -4,7 +4,7 @@ PREHOOK: query: -- SORT_QUERY_RESULTS
 select p_mfgr, p_name, p_size,
 rank() over(distribute by p_mfgr sort by p_name) as r,
 dense_rank() over(distribute by p_mfgr sort by p_name) as dr,
-sum(p_retailprice) over (distribute by p_mfgr sort by p_name rows between unbounded preceding and current row) as s1
+round(sum(p_retailprice) over (distribute by p_mfgr sort by p_name rows between unbounded preceding and current row),2) as s1
 from part
 PREHOOK: type: QUERY
 PREHOOK: Input: default@part
@@ -15,7 +15,7 @@ POSTHOOK: query: -- SORT_QUERY_RESULTS
 select p_mfgr, p_name, p_size,
 rank() over(distribute by p_mfgr sort by p_name) as r,
 dense_rank() over(distribute by p_mfgr sort by p_name) as dr,
-sum(p_retailprice) over (distribute by p_mfgr sort by p_name rows between unbounded preceding and current row) as s1
+round(sum(p_retailprice) over (distribute by p_mfgr sort by p_name rows between unbounded preceding and current row),2) as s1
 from part
 POSTHOOK: type: QUERY
 POSTHOOK: Input: default@part
@@ -23,12 +23,12 @@ POSTHOOK: Input: default@part
 Manufacturer#1	almond antique burnished rose metallic	2	1	1	1173.15
 Manufacturer#1	almond antique burnished rose metallic	2	1	1	2346.3
 Manufacturer#1	almond antique chartreuse lavender yellow	34	3	2	4100.06
-Manufacturer#1	almond antique salmon chartreuse burlywood	6	4	3	5702.650000000001
-Manufacturer#1	almond aquamarine burnished black steel	28	5	4	7117.070000000001
-Manufacturer#1	almond aquamarine pink moccasin thistle	42	6	5	8749.730000000001
+Manufacturer#1	almond antique salmon chartreuse burlywood	6	4	3	5702.65
+Manufacturer#1	almond aquamarine burnished black steel	28	5	4	7117.07
+Manufacturer#1	almond aquamarine pink moccasin thistle	42	6	5	8749.73
 Manufacturer#2	almond antique violet chocolate turquoise	14	1	1	1690.68
 Manufacturer#2	almond antique violet turquoise frosted	40	2	2	3491.38
-Manufacturer#2	almond aquamarine midnight light salmon	2	3	3	5523.360000000001
+Manufacturer#2	almond aquamarine midnight light salmon	2	3	3	5523.36
 Manufacturer#2	almond aquamarine rose maroon antique	25	4	4	7222.02
 Manufacturer#2	almond aquamarine sandy cyan gainsboro	18	5	5	8923.62
 Manufacturer#3	almond antique chartreuse khaki white	17	1	1	1671.68
@@ -40,9 +40,9 @@ Manufacturer#4	almond antique gainsboro frosted violet	10	1	1	1620.67
 Manufacturer#4	almond antique violet mint lemon	39	2	2	2996.09
 Manufacturer#4	almond aquamarine floral ivory bisque	27	3	3	4202.35
 Manufacturer#4	almond aquamarine yellow dodger mint	7	4	4	6047.27
-Manufacturer#4	almond azure aquamarine papaya violet	12	5	5	7337.620000000001
+Manufacturer#4	almond azure aquamarine papaya violet	12	5	5	7337.62
 Manufacturer#5	almond antique blue firebrick mint	31	1	1	1789.69
-Manufacturer#5	almond antique medium spring khaki	6	2	2	3401.3500000000004
+Manufacturer#5	almond antique medium spring khaki	6	2	2	3401.35
 Manufacturer#5	almond antique sky peru orange	2	3	3	5190.08
 Manufacturer#5	almond aquamarine dodger light gainsboro	46	4	4	6208.18
 Manufacturer#5	almond azure blanched chiffon midnight	23	5	5	7672.66
@@ -185,7 +185,7 @@ select p_mfgr, p_name,
 rank() over(distribute by p_mfgr sort by p_name) as r, 
 dense_rank() over(distribute by p_mfgr sort by p_name) as dr, 
 count(p_size) over(distribute by p_mfgr sort by p_name) as cd, 
-p_retailprice, sum(p_retailprice) over (distribute by p_mfgr sort by p_name rows between unbounded preceding and current row) as s1, 
+p_retailprice, round(sum(p_retailprice) over (distribute by p_mfgr sort by p_name rows between unbounded preceding and current row),2) as s1,
 p_size, p_size - lag(p_size,1,p_size) over(distribute by p_mfgr sort by p_name) as deltaSz 
 from part
 PREHOOK: type: QUERY
@@ -196,7 +196,7 @@ select p_mfgr, p_name,
 rank() over(distribute by p_mfgr sort by p_name) as r, 
 dense_rank() over(distribute by p_mfgr sort by p_name) as dr, 
 count(p_size) over(distribute by p_mfgr sort by p_name) as cd, 
-p_retailprice, sum(p_retailprice) over (distribute by p_mfgr sort by p_name rows between unbounded preceding and current row) as s1, 
+p_retailprice, round(sum(p_retailprice) over (distribute by p_mfgr sort by p_name rows between unbounded preceding and current row),2) as s1,
 p_size, p_size - lag(p_size,1,p_size) over(distribute by p_mfgr sort by p_name) as deltaSz 
 from part
 POSTHOOK: type: QUERY
@@ -205,12 +205,12 @@ POSTHOOK: Input: default@part
 Manufacturer#1	almond antique burnished rose metallic	1	1	2	1173.15	1173.15	2	0
 Manufacturer#1	almond antique burnished rose metallic	1	1	2	1173.15	2346.3	2	0
 Manufacturer#1	almond antique chartreuse lavender yellow	3	2	3	1753.76	4100.06	34	32
-Manufacturer#1	almond antique salmon chartreuse burlywood	4	3	4	1602.59	5702.650000000001	6	-28
-Manufacturer#1	almond aquamarine burnished black steel	5	4	5	1414.42	7117.070000000001	28	22
-Manufacturer#1	almond aquamarine pink moccasin thistle	6	5	6	1632.66	8749.730000000001	42	14
+Manufacturer#1	almond antique salmon chartreuse burlywood	4	3	4	1602.59	5702.65	6	-28
+Manufacturer#1	almond aquamarine burnished black steel	5	4	5	1414.42	7117.07	28	22
+Manufacturer#1	almond aquamarine pink moccasin thistle	6	5	6	1632.66	8749.73	42	14
 Manufacturer#2	almond antique violet chocolate turquoise	1	1	1	1690.68	1690.68	14	0
 Manufacturer#2	almond antique violet turquoise frosted	2	2	2	1800.7	3491.38	40	26
-Manufacturer#2	almond aquamarine midnight light salmon	3	3	3	2031.98	5523.360000000001	2	-38
+Manufacturer#2	almond aquamarine midnight light salmon	3	3	3	2031.98	5523.36	2	-38
 Manufacturer#2	almond aquamarine rose maroon antique	4	4	4	1698.66	7222.02	25	23
 Manufacturer#2	almond aquamarine sandy cyan gainsboro	5	5	5	1701.6	8923.62	18	-7
 Manufacturer#3	almond antique chartreuse khaki white	1	1	1	1671.68	1671.68	17	0
@@ -222,9 +222,9 @@ Manufacturer#4	almond antique gainsboro frosted violet	1	1	1	1620.67	1620.67	10
 Manufacturer#4	almond antique violet mint lemon	2	2	2	1375.42	2996.09	39	29
 Manufacturer#4	almond aquamarine floral ivory bisque	3	3	3	1206.26	4202.35	27	-12
 Manufacturer#4	almond aquamarine yellow dodger mint	4	4	4	1844.92	6047.27	7	-20
-Manufacturer#4	almond azure aquamarine papaya violet	5	5	5	1290.35	7337.620000000001	12	5
+Manufacturer#4	almond azure aquamarine papaya violet	5	5	5	1290.35	7337.62	12	5
 Manufacturer#5	almond antique blue firebrick mint	1	1	1	1789.69	1789.69	31	0
-Manufacturer#5	almond antique medium spring khaki	2	2	2	1611.66	3401.3500000000004	6	-25
+Manufacturer#5	almond antique medium spring khaki	2	2	2	1611.66	3401.35	6	-25
 Manufacturer#5	almond antique sky peru orange	3	3	3	1788.73	5190.08	2	-4
 Manufacturer#5	almond aquamarine dodger light gainsboro	4	4	4	1018.1	6208.18	46	44
 Manufacturer#5	almond azure blanched chiffon midnight	5	5	5	1464.48	7672.66	23	-23
@@ -234,7 +234,7 @@ from (select p_mfgr, p_name,
 rank() over(distribute by p_mfgr sort by p_name) as r, 
 dense_rank() over(distribute by p_mfgr sort by p_name) as dr, 
 count(p_size) over(distribute by p_mfgr sort by p_name) as cd, 
-p_retailprice, sum(p_retailprice) over (distribute by p_mfgr sort by p_name rows between unbounded preceding and current row) as s1, 
+p_retailprice, round(sum(p_retailprice) over (distribute by p_mfgr sort by p_name rows between unbounded preceding and current row),2) as s1,
 p_size, p_size - lag(p_size,1,p_size) over(distribute by p_mfgr sort by p_name) as deltaSz 
 from part 
 ) sub1
@@ -247,7 +247,7 @@ from (select p_mfgr, p_name,
 rank() over(distribute by p_mfgr sort by p_name) as r, 
 dense_rank() over(distribute by p_mfgr sort by p_name) as dr, 
 count(p_size) over(distribute by p_mfgr sort by p_name) as cd, 
-p_retailprice, sum(p_retailprice) over (distribute by p_mfgr sort by p_name rows between unbounded preceding and current row) as s1, 
+p_retailprice, round(sum(p_retailprice) over (distribute by p_mfgr sort by p_name rows between unbounded preceding and current row),2) as s1,
 p_size, p_size - lag(p_size,1,p_size) over(distribute by p_mfgr sort by p_name) as deltaSz 
 from part 
 ) sub1
@@ -262,29 +262,29 @@ POSTHOOK: Input: default@part
 1	1	2	2346.3	0
 2	2	2	2861.95	-3
 2	2	2	2996.09	29
-2	2	2	3401.3500000000004	-25
+2	2	2	3401.35	-25
 2	2	2	3491.38	26
 3	2	3	4100.06	32
 3	3	3	4202.35	-12
 3	3	3	4272.34	5
 3	3	3	5190.08	-4
-3	3	3	5523.360000000001	-38
-4	3	4	5702.650000000001	-28
+3	3	3	5523.36	-38
+4	3	4	5702.65	-28
 4	4	4	6047.27	-20
 4	4	4	6195.32	-18
 4	4	4	6208.18	44
 4	4	4	7222.02	23
-5	4	5	7117.070000000001	22
-5	5	5	7337.620000000001	5
+5	4	5	7117.07	22
+5	5	5	7337.62	5
 5	5	5	7532.61	44
 5	5	5	7672.66	-23
 5	5	5	8923.62	-7
-6	5	6	8749.730000000001	14
+6	5	6	8749.73	14
 PREHOOK: query: -- 7. testJoinWithWindowingAndPTF
 select abc.p_mfgr, abc.p_name, 
 rank() over(distribute by abc.p_mfgr sort by abc.p_name) as r, 
 dense_rank() over(distribute by abc.p_mfgr sort by abc.p_name) as dr, 
-abc.p_retailprice, sum(abc.p_retailprice) over (distribute by abc.p_mfgr sort by abc.p_name rows between unbounded preceding and current row) as s1, 
+abc.p_retailprice, round(sum(abc.p_retailprice) over (distribute by abc.p_mfgr sort by abc.p_name rows between unbounded preceding and current row),2) as s1,
 abc.p_size, abc.p_size - lag(abc.p_size,1,abc.p_size) over(distribute by abc.p_mfgr sort by abc.p_name) as deltaSz 
 from noop(on part 
 partition by p_mfgr 
@@ -297,7 +297,7 @@ POSTHOOK: query: -- 7. testJoinWithWindowingAndPTF
 select abc.p_mfgr, abc.p_name, 
 rank() over(distribute by abc.p_mfgr sort by abc.p_name) as r, 
 dense_rank() over(distribute by abc.p_mfgr sort by abc.p_name) as dr, 
-abc.p_retailprice, sum(abc.p_retailprice) over (distribute by abc.p_mfgr sort by abc.p_name rows between unbounded preceding and current row) as s1, 
+abc.p_retailprice, round(sum(abc.p_retailprice) over (distribute by abc.p_mfgr sort by abc.p_name rows between unbounded preceding and current row),2) as s1,
 abc.p_size, abc.p_size - lag(abc.p_size,1,abc.p_size) over(distribute by abc.p_mfgr sort by abc.p_name) as deltaSz 
 from noop(on part 
 partition by p_mfgr 
@@ -308,15 +308,15 @@ POSTHOOK: Input: default@part
 #### A masked pattern was here ####
 Manufacturer#1	almond antique burnished rose metallic	1	1	1173.15	1173.15	2	0
 Manufacturer#1	almond antique burnished rose metallic	1	1	1173.15	2346.3	2	0
-Manufacturer#1	almond antique burnished rose metallic	1	1	1173.15	3519.4500000000003	2	0
+Manufacturer#1	almond antique burnished rose metallic	1	1	1173.15	3519.45	2	0
 Manufacturer#1	almond antique burnished rose metallic	1	1	1173.15	4692.6	2	0
-Manufacturer#1	almond antique chartreuse lavender yellow	5	2	1753.76	6446.360000000001	34	32
-Manufacturer#1	almond antique salmon chartreuse burlywood	6	3	1602.59	8048.950000000001	6	-28
+Manufacturer#1	almond antique chartreuse lavender yellow	5	2	1753.76	6446.36	34	32
+Manufacturer#1	almond antique salmon chartreuse burlywood	6	3	1602.59	8048.95	6	-28
 Manufacturer#1	almond aquamarine burnished black steel	7	4	1414.42	9463.37	28	22
 Manufacturer#1	almond aquamarine pink moccasin thistle	8	5	1632.66	11096.03	42	14
 Manufacturer#2	almond antique violet chocolate turquoise	1	1	1690.68	1690.68	14	0
 Manufacturer#2	almond antique violet turquoise frosted	2	2	1800.7	3491.38	40	26
-Manufacturer#2	almond aquamarine midnight light salmon	3	3	2031.98	5523.360000000001	2	-38
+Manufacturer#2	almond aquamarine midnight light salmon	3	3	2031.98	5523.36	2	-38
 Manufacturer#2	almond aquamarine rose maroon antique	4	4	1698.66	7222.02	25	23
 Manufacturer#2	almond aquamarine sandy cyan gainsboro	5	5	1701.6	8923.62	18	-7
 Manufacturer#3	almond antique chartreuse khaki white	1	1	1671.68	1671.68	17	0
@@ -328,9 +328,9 @@ Manufacturer#4	almond antique gainsboro frosted violet	1	1	1620.67	1620.67	10	0
 Manufacturer#4	almond antique violet mint lemon	2	2	1375.42	2996.09	39	29
 Manufacturer#4	almond aquamarine floral ivory bisque	3	3	1206.26	4202.35	27	-12
 Manufacturer#4	almond aquamarine yellow dodger mint	4	4	1844.92	6047.27	7	-20
-Manufacturer#4	almond azure aquamarine papaya violet	5	5	1290.35	7337.620000000001	12	5
+Manufacturer#4	almond azure aquamarine papaya violet	5	5	1290.35	7337.62	12	5
 Manufacturer#5	almond antique blue firebrick mint	1	1	1789.69	1789.69	31	0
-Manufacturer#5	almond antique medium spring khaki	2	2	1611.66	3401.3500000000004	6	-25
+Manufacturer#5	almond antique medium spring khaki	2	2	1611.66	3401.35	6	-25
 Manufacturer#5	almond antique sky peru orange	3	3	1788.73	5190.08	2	-4
 Manufacturer#5	almond aquamarine dodger light gainsboro	4	4	1018.1	6208.18	46	44
 Manufacturer#5	almond azure blanched chiffon midnight	5	5	1464.48	7672.66	23	-23
@@ -378,7 +378,7 @@ PREHOOK: query: -- 9. testHavingWithWindowingNoGBY
 select p_mfgr, p_name, p_size, 
 rank() over(distribute by p_mfgr sort by p_name) as r, 
 dense_rank() over(distribute by p_mfgr sort by p_name) as dr, 
-sum(p_retailprice) over (distribute by p_mfgr sort by p_name rows between unbounded preceding and current row)  as s1
+round(sum(p_retailprice) over (distribute by p_mfgr sort by p_name rows between unbounded preceding and current row),2)  as s1
 from part
 PREHOOK: type: QUERY
 PREHOOK: Input: default@part
@@ -387,7 +387,7 @@ POSTHOOK: query: -- 9. testHavingWithWindowingNoGBY
 select p_mfgr, p_name, p_size, 
 rank() over(distribute by p_mfgr sort by p_name) as r, 
 dense_rank() over(distribute by p_mfgr sort by p_name) as dr, 
-sum(p_retailprice) over (distribute by p_mfgr sort by p_name rows between unbounded preceding and current row)  as s1
+round(sum(p_retailprice) over (distribute by p_mfgr sort by p_name rows between unbounded preceding and current row),2)  as s1
 from part
 POSTHOOK: type: QUERY
 POSTHOOK: Input: default@part
@@ -395,12 +395,12 @@ POSTHOOK: Input: default@part
 Manufacturer#1	almond antique burnished rose metallic	2	1	1	1173.15
 Manufacturer#1	almond antique burnished rose metallic	2	1	1	2346.3
 Manufacturer#1	almond antique chartreuse lavender yellow	34	3	2	4100.06
-Manufacturer#1	almond antique salmon chartreuse burlywood	6	4	3	5702.650000000001
-Manufacturer#1	almond aquamarine burnished black steel	28	5	4	7117.070000000001
-Manufacturer#1	almond aquamarine pink moccasin thistle	42	6	5	8749.730000000001
+Manufacturer#1	almond antique salmon chartreuse burlywood	6	4	3	5702.65
+Manufacturer#1	almond aquamarine burnished black steel	28	5	4	7117.07
+Manufacturer#1	almond aquamarine pink moccasin thistle	42	6	5	8749.73
 Manufacturer#2	almond antique violet chocolate turquoise	14	1	1	1690.68
 Manufacturer#2	almond antique violet turquoise frosted	40	2	2	3491.38
-Manufacturer#2	almond aquamarine midnight light salmon	2	3	3	5523.360000000001
+Manufacturer#2	almond aquamarine midnight light salmon	2	3	3	5523.36
 Manufacturer#2	almond aquamarine rose maroon antique	25	4	4	7222.02
 Manufacturer#2	almond aquamarine sandy cyan gainsboro	18	5	5	8923.62
 Manufacturer#3	almond antique chartreuse khaki white	17	1	1	1671.68
@@ -412,9 +412,9 @@ Manufacturer#4	almond antique gainsboro frosted violet	10	1	1	1620.67
 Manufacturer#4	almond antique violet mint lemon	39	2	2	2996.09
 Manufacturer#4	almond aquamarine floral ivory bisque	27	3	3	4202.35
 Manufacturer#4	almond aquamarine yellow dodger mint	7	4	4	6047.27
-Manufacturer#4	almond azure aquamarine papaya violet	12	5	5	7337.620000000001
+Manufacturer#4	almond azure aquamarine papaya violet	12	5	5	7337.62
 Manufacturer#5	almond antique blue firebrick mint	31	1	1	1789.69
-Manufacturer#5	almond antique medium spring khaki	6	2	2	3401.3500000000004
+Manufacturer#5	almond antique medium spring khaki	6	2	2	3401.35
 Manufacturer#5	almond antique sky peru orange	2	3	3	5190.08
 Manufacturer#5	almond aquamarine dodger light gainsboro	46	4	4	6208.18
 Manufacturer#5	almond azure blanched chiffon midnight	23	5	5	7672.66
@@ -422,7 +422,7 @@ PREHOOK: query: -- 10. testHavingWithWindowingCondRankNoGBY
 select p_mfgr, p_name, p_size, 
 rank() over(distribute by p_mfgr sort by p_name) as r, 
 dense_rank() over(distribute by p_mfgr sort by p_name) as dr, 
-sum(p_retailprice) over (distribute by p_mfgr sort by p_name rows between unbounded preceding and current row) as s1 
+round(sum(p_retailprice) over (distribute by p_mfgr sort by p_name rows between unbounded preceding and current row),2) as s1
 from part
 PREHOOK: type: QUERY
 PREHOOK: Input: default@part
@@ -431,7 +431,7 @@ POSTHOOK: query: -- 10. testHavingWithWindowingCondRankNoGBY
 select p_mfgr, p_name, p_size, 
 rank() over(distribute by p_mfgr sort by p_name) as r, 
 dense_rank() over(distribute by p_mfgr sort by p_name) as dr, 
-sum(p_retailprice) over (distribute by p_mfgr sort by p_name rows between unbounded preceding and current row) as s1 
+round(sum(p_retailprice) over (distribute by p_mfgr sort by p_name rows between unbounded preceding and current row),2) as s1
 from part
 POSTHOOK: type: QUERY
 POSTHOOK: Input: default@part
@@ -439,12 +439,12 @@ POSTHOOK: Input: default@part
 Manufacturer#1	almond antique burnished rose metallic	2	1	1	1173.15
 Manufacturer#1	almond antique burnished rose metallic	2	1	1	2346.3
 Manufacturer#1	almond antique chartreuse lavender yellow	34	3	2	4100.06
-Manufacturer#1	almond antique salmon chartreuse burlywood	6	4	3	5702.650000000001
-Manufacturer#1	almond aquamarine burnished black steel	28	5	4	7117.070000000001
-Manufacturer#1	almond aquamarine pink moccasin thistle	42	6	5	8749.730000000001
+Manufacturer#1	almond antique salmon chartreuse burlywood	6	4	3	5702.65
+Manufacturer#1	almond aquamarine burnished black steel	28	5	4	7117.07
+Manufacturer#1	almond aquamarine pink moccasin thistle	42	6	5	8749.73
 Manufacturer#2	almond antique violet chocolate turquoise	14	1	1	1690.68
 Manufacturer#2	almond antique violet turquoise frosted	40	2	2	3491.38
-Manufacturer#2	almond aquamarine midnight light salmon	2	3	3	5523.360000000001
+Manufacturer#2	almond aquamarine midnight light salmon	2	3	3	5523.36
 Manufacturer#2	almond aquamarine rose maroon antique	25	4	4	7222.02
 Manufacturer#2	almond aquamarine sandy cyan gainsboro	18	5	5	8923.62
 Manufacturer#3	almond antique chartreuse khaki white	17	1	1	1671.68
@@ -456,9 +456,9 @@ Manufacturer#4	almond antique gainsboro frosted violet	10	1	1	1620.67
 Manufacturer#4	almond antique violet mint lemon	39	2	2	2996.09
 Manufacturer#4	almond aquamarine floral ivory bisque	27	3	3	4202.35
 Manufacturer#4	almond aquamarine yellow dodger mint	7	4	4	6047.27
-Manufacturer#4	almond azure aquamarine papaya violet	12	5	5	7337.620000000001
+Manufacturer#4	almond azure aquamarine papaya violet	12	5	5	7337.62
 Manufacturer#5	almond antique blue firebrick mint	31	1	1	1789.69
-Manufacturer#5	almond antique medium spring khaki	6	2	2	3401.3500000000004
+Manufacturer#5	almond antique medium spring khaki	6	2	2	3401.35
 Manufacturer#5	almond antique sky peru orange	2	3	3	5190.08
 Manufacturer#5	almond aquamarine dodger light gainsboro	46	4	4	6208.18
 Manufacturer#5	almond azure blanched chiffon midnight	23	5	5	7672.66
@@ -785,10 +785,10 @@ Manufacturer#5	almond aquamarine dodger light gainsboro	46	4	4	6
 Manufacturer#5	almond azure blanched chiffon midnight	23	5	5	2
 PREHOOK: query: -- 18. testUDAFs
 select  p_mfgr,p_name, p_size, 
-sum(p_retailprice) over w1 as s, 
+round(sum(p_retailprice) over w1,2) as s,
 min(p_retailprice) over w1 as mi,
 max(p_retailprice) over w1 as ma,
-avg(p_retailprice) over w1 as ag
+round(avg(p_retailprice) over w1,2) as ag
 from part
 window w1 as (distribute by p_mfgr sort by p_mfgr, p_name rows between 2 preceding and 2 following)
 PREHOOK: type: QUERY
@@ -796,47 +796,47 @@ PREHOOK: Input: default@part
 #### A masked pattern was here ####
 POSTHOOK: query: -- 18. testUDAFs
 select  p_mfgr,p_name, p_size, 
-sum(p_retailprice) over w1 as s, 
+round(sum(p_retailprice) over w1,2) as s,
 min(p_retailprice) over w1 as mi,
 max(p_retailprice) over w1 as ma,
-avg(p_retailprice) over w1 as ag
+round(avg(p_retailprice) over w1,2) as ag
 from part
 window w1 as (distribute by p_mfgr sort by p_mfgr, p_name rows between 2 preceding and 2 following)
 POSTHOOK: type: QUERY
 POSTHOOK: Input: default@part
 #### A masked pattern was here ####
-Manufacturer#1	almond antique burnished rose metallic	2	4100.06	1173.15	1753.76	1366.6866666666667
-Manufacturer#1	almond antique burnished rose metallic	2	5702.650000000001	1173.15	1753.76	1425.6625000000001
-Manufacturer#1	almond antique chartreuse lavender yellow	34	7117.070000000001	1173.15	1753.76	1423.4140000000002
-Manufacturer#1	almond antique salmon chartreuse burlywood	6	7576.580000000002	1173.15	1753.76	1515.3160000000003
-Manufacturer#1	almond aquamarine burnished black steel	28	6403.430000000001	1414.42	1753.76	1600.8575000000003
-Manufacturer#1	almond aquamarine pink moccasin thistle	42	4649.670000000001	1414.42	1632.66	1549.8900000000003
-Manufacturer#2	almond antique violet chocolate turquoise	14	5523.360000000001	1690.68	2031.98	1841.1200000000001
-Manufacturer#2	almond antique violet turquoise frosted	40	7222.02	1690.68	2031.98	1805.505
-Manufacturer#2	almond aquamarine midnight light salmon	2	8923.62	1690.68	2031.98	1784.7240000000002
-Manufacturer#2	almond aquamarine rose maroon antique	25	7232.9400000000005	1698.66	2031.98	1808.2350000000001
-Manufacturer#2	almond aquamarine sandy cyan gainsboro	18	5432.240000000001	1698.66	2031.98	1810.746666666667
-Manufacturer#3	almond antique chartreuse khaki white	17	4272.34	1190.27	1671.68	1424.1133333333335
+Manufacturer#1	almond antique burnished rose metallic	2	4100.06	1173.15	1753.76	1366.69
+Manufacturer#1	almond antique burnished rose metallic	2	5702.65	1173.15	1753.76	1425.66
+Manufacturer#1	almond antique chartreuse lavender yellow	34	7117.07	1173.15	1753.76	1423.41
+Manufacturer#1	almond antique salmon chartreuse burlywood	6	7576.58	1173.15	1753.76	1515.32
+Manufacturer#1	almond aquamarine burnished black steel	28	6403.43	1414.42	1753.76	1600.86
+Manufacturer#1	almond aquamarine pink moccasin thistle	42	4649.67	1414.42	1632.66	1549.89
+Manufacturer#2	almond antique violet chocolate turquoise	14	5523.36	1690.68	2031.98	1841.12
+Manufacturer#2	almond antique violet turquoise frosted	40	7222.02	1690.68	2031.98	1805.51
+Manufacturer#2	almond aquamarine midnight light salmon	2	8923.62	1690.68	2031.98	1784.72
+Manufacturer#2	almond aquamarine rose maroon antique	25	7232.94	1698.66	2031.98	1808.24
+Manufacturer#2	almond aquamarine sandy cyan gainsboro	18	5432.24	1698.66	2031.98	1810.75
+Manufacturer#3	almond antique chartreuse khaki white	17	4272.34	1190.27	1671.68	1424.11
 Manufacturer#3	almond antique forest lavender goldenrod	14	6195.32	1190.27	1922.98	1548.83
-Manufacturer#3	almond antique metallic orange dim	19	7532.61	1190.27	1922.98	1506.522
-Manufacturer#3	almond antique misty red olive	1	5860.929999999999	1190.27	1922.98	1465.2324999999998
-Manufacturer#3	almond antique olive coral navajo	45	4670.66	1337.29	1922.98	1556.8866666666665
-Manufacturer#4	almond antique gainsboro frosted violet	10	4202.35	1206.26	1620.67	1400.7833333333335
-Manufacturer#4	almond antique violet mint lemon	39	6047.27	1206.26	1844.92	1511.8175
-Manufacturer#4	almond aquamarine floral ivory bisque	27	7337.620000000001	1206.26	1844.92	1467.5240000000001
-Manufacturer#4	almond aquamarine yellow dodger mint	7	5716.950000000001	1206.26	1844.92	1429.2375000000002
-Manufacturer#4	almond azure aquamarine papaya violet	12	4341.530000000001	1206.26	1844.92	1447.176666666667
-Manufacturer#5	almond antique blue firebrick mint	31	5190.08	1611.66	1789.69	1730.0266666666666
-Manufacturer#5	almond antique medium spring khaki	6	6208.18	1018.1	1789.69	1552.045
-Manufacturer#5	almond antique sky peru orange	2	7672.66	1018.1	1789.69	1534.532
-Manufacturer#5	almond aquamarine dodger light gainsboro	46	5882.969999999999	1018.1	1788.73	1470.7424999999998
-Manufacturer#5	almond azure blanched chiffon midnight	23	4271.3099999999995	1018.1	1788.73	1423.7699999999998
+Manufacturer#3	almond antique metallic orange dim	19	7532.61	1190.27	1922.98	1506.52
+Manufacturer#3	almond antique misty red olive	1	5860.93	1190.27	1922.98	1465.23
+Manufacturer#3	almond antique olive coral navajo	45	4670.66	1337.29	1922.98	1556.89
+Manufacturer#4	almond antique gainsboro frosted violet	10	4202.35	1206.26	1620.67	1400.78
+Manufacturer#4	almond antique violet mint lemon	39	6047.27	1206.26	1844.92	1511.82
+Manufacturer#4	almond aquamarine floral ivory bisque	27	7337.62	1206.26	1844.92	1467.52
+Manufacturer#4	almond aquamarine yellow dodger mint	7	5716.95	1206.26	1844.92	1429.24
+Manufacturer#4	almond azure aquamarine papaya violet	12	4341.53	1206.26	1844.92	1447.18
+Manufacturer#5	almond antique blue firebrick mint	31	5190.08	1611.66	1789.69	1730.03
+Manufacturer#5	almond antique medium spring khaki	6	6208.18	1018.1	1789.69	1552.05
+Manufacturer#5	almond antique sky peru orange	2	7672.66	1018.1	1789.69	1534.53
+Manufacturer#5	almond aquamarine dodger light gainsboro	46	5882.97	1018.1	1788.73	1470.74
+Manufacturer#5	almond azure blanched chiffon midnight	23	4271.31	1018.1	1788.73	1423.77
 PREHOOK: query: -- 19. testUDAFsWithGBY
 select  p_mfgr,p_name, p_size, p_retailprice, 
-sum(p_retailprice) over w1 as s, 
+round(sum(p_retailprice) over w1,2) as s,
 min(p_retailprice) as mi ,
 max(p_retailprice) as ma ,
-avg(p_retailprice) over w1 as ag
+round(avg(p_retailprice) over w1,2) as ag
 from part
 group by p_mfgr,p_name, p_size, p_retailprice
 window w1 as (distribute by p_mfgr sort by p_mfgr, p_name rows between 2 preceding and 2 following)
@@ -845,41 +845,41 @@ PREHOOK: Input: default@part
 #### A masked pattern was here ####
 POSTHOOK: query: -- 19. testUDAFsWithGBY
 select  p_mfgr,p_name, p_size, p_retailprice, 
-sum(p_retailprice) over w1 as s, 
+round(sum(p_retailprice) over w1,2) as s,
 min(p_retailprice) as mi ,
 max(p_retailprice) as ma ,
-avg(p_retailprice) over w1 as ag
+round(avg(p_retailprice) over w1,2) as ag
 from part
 group by p_mfgr,p_name, p_size, p_retailprice
 window w1 as (distribute by p_mfgr sort by p_mfgr, p_name rows between 2 preceding and 2 following)
 POSTHOOK: type: QUERY
 POSTHOOK: Input: default@part
 #### A masked pattern was here ####
-Manufacturer#1	almond antique burnished rose metallic	2	1173.15	4529.5	1173.15	1173.15	1509.8333333333333
+Manufacturer#1	almond antique burnished rose metallic	2	1173.15	4529.5	1173.15	1173.15	1509.83
 Manufacturer#1	almond antique chartreuse lavender yellow	34	1753.76	5943.92	1753.76	1753.76	1485.98
-Manufacturer#1	almond antique salmon chartreuse burlywood	6	1602.59	7576.58	1602.59	1602.59	1515.316
-Manufacturer#1	almond aquamarine burnished black steel	28	1414.42	6403.43	1414.42	1414.42	1600.8575
+Manufacturer#1	almond antique salmon chartreuse burlywood	6	1602.59	7576.58	1602.59	1602.59	1515.32
+Manufacturer#1	almond aquamarine burnished black steel	28	1414.42	6403.43	1414.42	1414.42	1600.86
 Manufacturer#1	almond aquamarine pink moccasin thistle	42	1632.66	4649.67	1632.66	1632.66	1549.89
-Manufacturer#2	almond antique violet chocolate turquoise	14	1690.68	5523.360000000001	1690.68	1690.68	1841.1200000000001
-Manufacturer#2	almond antique violet turquoise frosted	40	1800.7	7222.02	1800.7	1800.7	1805.505
-Manufacturer#2	almond aquamarine midnight light salmon	2	2031.98	8923.62	2031.98	2031.98	1784.7240000000002
-Manufacturer#2	almond aquamarine rose maroon antique	25	1698.66	7232.9400000000005	1698.66	1698.66	1808.2350000000001
-Manufacturer#2	almond aquamarine sandy cyan gainsboro	18	1701.6	5432.240000000001	1701.6	1701.6	1810.746666666667
-Manufacturer#3	almond antique chartreuse khaki white	17	1671.68	4272.34	1671.68	1671.68	1424.1133333333335
+Manufacturer#2	almond antique violet chocolate turquoise	14	1690.68	5523.36	1690.68	1690.68	1841.12
+Manufacturer#2	almond antique violet turquoise frosted	40	1800.7	7222.02	1800.7	1800.7	1805.51
+Manufacturer#2	almond aquamarine midnight light salmon	2	2031.98	8923.62	2031.98	2031.98	1784.72
+Manufacturer#2	almond aquamarine rose maroon antique	25	1698.66	7232.94	1698.66	1698.66	1808.24
+Manufacturer#2	almond aquamarine sandy cyan gainsboro	18	1701.6	5432.24	1701.6	1701.6	1810.75
+Manufacturer#3	almond antique chartreuse khaki white	17	1671.68	4272.34	1671.68	1671.68	1424.11
 Manufacturer#3	almond antique forest lavender goldenrod	14	1190.27	6195.32	1190.27	1190.27	1548.83
-Manufacturer#3	almond antique metallic orange dim	19	1410.39	7532.61	1410.39	1410.39	1506.522
-Manufacturer#3	almond antique misty red olive	1	1922.98	5860.929999999999	1922.98	1922.98	1465.2324999999998
-Manufacturer#3	almond antique olive coral navajo	45	1337.29	4670.66	1337.29	1337.29	1556.8866666666665
-Manufacturer#4	almond antique gainsboro frosted violet	10	1620.67	4202.35	1620.67	1620.67	1400.7833333333335
-Manufacturer#4	almond antique violet mint lemon	39	1375.42	6047.27	1375.42	1375.42	1511.8175
-Manufacturer#4	almond aquamarine floral ivory bisque	27	1206.26	7337.620000000001	1206.26	1206.26	1467.5240000000001
-Manufacturer#4	almond aquamarine yellow dodger mint	7	1844.92	5716.950000000001	1844.92	1844.92	1429.2375000000002
-Manufacturer#4	almond azure aquamarine papaya violet	12	1290.35	4341.530000000001	1290.35	1290.35	1447.176666666667
-Manufacturer#5	almond antique blue firebrick mint	31	1789.69	5190.08	1789.69	1789.69	1730.0266666666666
-Manufacturer#5	almond antique medium spring khaki	6	1611.66	6208.18	1611.66	1611.66	1552.045
-Manufacturer#5	almond antique sky peru orange	2	1788.73	7672.66	1788.73	1788.73	1534.532
-Manufacturer#5	almond aquamarine dodger light gainsboro	46	1018.1	5882.969999999999	1018.1	1018.1	1470.7424999999998
-Manufacturer#5	almond azure blanched chiffon midnight	23	1464.48	4271.3099999999995	1464.48	1464.48	1423.7699999999998
+Manufacturer#3	almond antique metallic orange dim	19	1410.39	7532.61	1410.39	1410.39	1506.52
+Manufacturer#3	almond antique misty red olive	1	1922.98	5860.93	1922.98	1922.98	1465.23
+Manufacturer#3	almond antique olive coral navajo	45	1337.29	4670.66	1337.29	1337.29	1556.89
+Manufacturer#4	almond antique gainsboro frosted violet	10	1620.67	4202.35	1620.67	1620.67	1400.78
+Manufacturer#4	almond antique violet mint lemon	39	1375.42	6047.27	1375.42	1375.42	1511.82
+Manufacturer#4	almond aquamarine floral ivory bisque	27	1206.26	7337.62	1206.26	1206.26	1467.52
+Manufacturer#4	almond aquamarine yellow dodger mint	7	1844.92	5716.95	1844.92	1844.92	1429.24
+Manufacturer#4	almond azure aquamarine papaya violet	12	1290.35	4341.53	1290.35	1290.35	1447.18
+Manufacturer#5	almond antique blue firebrick mint	31	1789.69	5190.08	1789.69	1789.69	1730.03
+Manufacturer#5	almond antique medium spring khaki	6	1611.66	6208.18	1611.66	1611.66	1552.05
+Manufacturer#5	almond antique sky peru orange	2	1788.73	7672.66	1788.73	1788.73	1534.53
+Manufacturer#5	almond aquamarine dodger light gainsboro	46	1018.1	5882.97	1018.1	1018.1	1470.74
+Manufacturer#5	almond azure blanched chiffon midnight	23	1464.48	4271.31	1464.48	1464.48	1423.77
 PREHOOK: query: -- 20. testSTATs
 select  p_mfgr,p_name, p_size, 
 stddev(p_retailprice) over w1 as sdev, 
@@ -1073,7 +1073,7 @@ Manufacturer#5	Brand#53	2806.83	7672.66
 PREHOOK: query: -- 23. testCreateViewWithWindowingQuery
 create view IF NOT EXISTS mfgr_brand_price_view as 
 select p_mfgr, p_brand, 
-sum(p_retailprice) over w1  as s
+round(sum(p_retailprice) over w1,2) as s
 from part 
 window w1 as (distribute by p_mfgr sort by p_name rows between 2 preceding and current row)
 PREHOOK: type: CREATEVIEW
@@ -1083,7 +1083,7 @@ PREHOOK: Output: default@mfgr_brand_price_view
 POSTHOOK: query: -- 23. testCreateViewWithWindowingQuery
 create view IF NOT EXISTS mfgr_brand_price_view as 
 select p_mfgr, p_brand, 
-sum(p_retailprice) over w1  as s
+round(sum(p_retailprice) over w1,2) as s
 from part 
 window w1 as (distribute by p_mfgr sort by p_name rows between 2 preceding and current row)
 POSTHOOK: type: CREATEVIEW
@@ -1101,29 +1101,29 @@ POSTHOOK: Input: default@mfgr_brand_price_view
 POSTHOOK: Input: default@part
 #### A masked pattern was here ####
 Manufacturer#1	Brand#12	4100.06
-Manufacturer#1	Brand#12	4649.670000000001
+Manufacturer#1	Brand#12	4649.67
 Manufacturer#1	Brand#12	4770.77
 Manufacturer#1	Brand#14	1173.15
 Manufacturer#1	Brand#14	2346.3
 Manufacturer#1	Brand#15	4529.5
 Manufacturer#2	Brand#22	1690.68
 Manufacturer#2	Brand#22	3491.38
-Manufacturer#2	Brand#23	5523.360000000001
+Manufacturer#2	Brand#23	5523.36
 Manufacturer#2	Brand#24	5531.34
-Manufacturer#2	Brand#25	5432.240000000001
+Manufacturer#2	Brand#25	5432.24
 Manufacturer#3	Brand#31	1671.68
 Manufacturer#3	Brand#32	4272.34
-Manufacturer#3	Brand#32	4523.639999999999
+Manufacturer#3	Brand#32	4523.64
 Manufacturer#3	Brand#34	4670.66
 Manufacturer#3	Brand#35	2861.95
 Manufacturer#4	Brand#41	1620.67
-Manufacturer#4	Brand#41	4341.530000000001
+Manufacturer#4	Brand#41	4341.53
 Manufacturer#4	Brand#41	4426.6
 Manufacturer#4	Brand#42	2996.09
 Manufacturer#4	Brand#42	4202.35
-Manufacturer#5	Brand#51	3401.3500000000004
+Manufacturer#5	Brand#51	3401.35
 Manufacturer#5	Brand#52	1789.69
-Manufacturer#5	Brand#52	4271.3099999999995
+Manufacturer#5	Brand#52	4271.31
 Manufacturer#5	Brand#53	4418.49
 Manufacturer#5	Brand#53	5190.08
 PREHOOK: query: -- 24. testLateralViews
@@ -1293,7 +1293,7 @@ INSERT OVERWRITE TABLE part_1
 select p_mfgr, p_name, p_size, 
 rank() over(distribute by p_mfgr sort by p_name ) as r, 
 dense_rank() over(distribute by p_mfgr sort by p_name ) as dr, 
-sum(p_retailprice) over (distribute by p_mfgr sort by p_name rows between unbounded preceding and current row)  as s
+round(sum(p_retailprice) over (distribute by p_mfgr sort by p_name rows between unbounded preceding and current row),2) as s
 INSERT OVERWRITE TABLE part_2 
 select  p_mfgr,p_name, p_size,  
 rank() over(distribute by p_mfgr sort by p_name) as r, 
@@ -1318,7 +1318,7 @@ INSERT OVERWRITE TABLE part_1
 select p_mfgr, p_name, p_size, 
 rank() over(distribute by p_mfgr sort by p_name ) as r, 
 dense_rank() over(distribute by p_mfgr sort by p_name ) as dr, 
-sum(p_retailprice) over (distribute by p_mfgr sort by p_name rows between unbounded preceding and current row)  as s
+round(sum(p_retailprice) over (distribute by p_mfgr sort by p_name rows between unbounded preceding and current row),2) as s
 INSERT OVERWRITE TABLE part_2 
 select  p_mfgr,p_name, p_size,  
 rank() over(distribute by p_mfgr sort by p_name) as r, 
@@ -1369,12 +1369,12 @@ POSTHOOK: Input: default@part_1
 Manufacturer#1	almond antique burnished rose metallic	2	1	1	1173.15
 Manufacturer#1	almond antique burnished rose metallic	2	1	1	2346.3
 Manufacturer#1	almond antique chartreuse lavender yellow	34	3	2	4100.06
-Manufacturer#1	almond antique salmon chartreuse burlywood	6	4	3	5702.650000000001
-Manufacturer#1	almond aquamarine burnished black steel	28	5	4	7117.070000000001
-Manufacturer#1	almond aquamarine pink moccasin thistle	42	6	5	8749.730000000001
+Manufacturer#1	almond antique salmon chartreuse burlywood	6	4	3	5702.65
+Manufacturer#1	almond aquamarine burnished black steel	28	5	4	7117.07
+Manufacturer#1	almond aquamarine pink moccasin thistle	42	6	5	8749.73
 Manufacturer#2	almond antique violet chocolate turquoise	14	1	1	1690.68
 Manufacturer#2	almond antique violet turquoise frosted	40	2	2	3491.38
-Manufacturer#2	almond aquamarine midnight light salmon	2	3	3	5523.360000000001
+Manufacturer#2	almond aquamarine midnight light salmon	2	3	3	5523.36
 Manufacturer#2	almond aquamarine rose maroon antique	25	4	4	7222.02
 Manufacturer#2	almond aquamarine sandy cyan gainsboro	18	5	5	8923.62
 Manufacturer#3	almond antique chartreuse khaki white	17	1	1	1671.68
@@ -1386,9 +1386,9 @@ Manufacturer#4	almond antique gainsboro frosted violet	10	1	1	1620.67
 Manufacturer#4	almond antique violet mint lemon	39	2	2	2996.09
 Manufacturer#4	almond aquamarine floral ivory bisque	27	3	3	4202.35
 Manufacturer#4	almond aquamarine yellow dodger mint	7	4	4	6047.27
-Manufacturer#4	almond azure aquamarine papaya violet	12	5	5	7337.620000000001
+Manufacturer#4	almond azure aquamarine papaya violet	12	5	5	7337.62
 Manufacturer#5	almond antique blue firebrick mint	31	1	1	1789.69
-Manufacturer#5	almond antique medium spring khaki	6	2	2	3401.3500000000004
+Manufacturer#5	almond antique medium spring khaki	6	2	2	3401.35
 Manufacturer#5	almond antique sky peru orange	2	3	3	5190.08
 Manufacturer#5	almond aquamarine dodger light gainsboro	46	4	4	6208.18
 Manufacturer#5	almond azure blanched chiffon midnight	23	5	5	7672.66
@@ -1872,23 +1872,124 @@ Manufacturer#5	almond antique sky peru orange	2	2	39	108
 Manufacturer#5	almond aquamarine dodger light gainsboro	46	46	85	77
 Manufacturer#5	almond azure blanched chiffon midnight	23	23	108	71
 PREHOOK: query: -- 35. testDistinctWithWindowing
+explain
 select DISTINCT p_mfgr, p_name, p_size,
 sum(p_size) over w1 as s
 from part
 window w1 as (distribute by p_mfgr sort by p_name rows between 2 preceding and 2 following)
 PREHOOK: type: QUERY
-PREHOOK: Input: default@part
-#### A masked pattern was here ####
 POSTHOOK: query: -- 35. testDistinctWithWindowing
+explain
 select DISTINCT p_mfgr, p_name, p_size,
 sum(p_size) over w1 as s
 from part
 window w1 as (distribute by p_mfgr sort by p_name rows between 2 preceding and 2 following)
 POSTHOOK: type: QUERY
+STAGE DEPENDENCIES:
+  Stage-1 is a root stage
+  Stage-2 depends on stages: Stage-1
+  Stage-0 depends on stages: Stage-2
+
+STAGE PLANS:
+  Stage: Stage-1
+    Map Reduce
+      Map Operator Tree:
+          TableScan
+            alias: part
+            Statistics: Num rows: 26 Data size: 3147 Basic stats: COMPLETE Column stats: NONE
+            Reduce Output Operator
+              key expressions: p_mfgr (type: string), p_name (type: string)
+              sort order: ++
+              Map-reduce partition columns: p_mfgr (type: string)
+              Statistics: Num rows: 26 Data size: 3147 Basic stats: COMPLETE Column stats: NONE
+              value expressions: p_size (type: int)
+      Reduce Operator Tree:
+        Select Operator
+          expressions: KEY.reducesinkkey1 (type: string), KEY.reducesinkkey0 (type: string), VALUE._col3 (type: int)
+          outputColumnNames: _col1, _col2, _col5
+          Statistics: Num rows: 26 Data size: 3147 Basic stats: COMPLETE Column stats: NONE
+          PTF Operator
+            Function definitions:
+                Input definition
+                  input alias: ptf_0
+                  output shape: _col1: string, _col2: string, _col5: int
+                  type: WINDOWING
+                Windowing table definition
+                  input alias: ptf_1
+                  name: windowingtablefunction
+                  order by: _col1 ASC NULLS FIRST
+                  partition by: _col2
+                  raw input shape:
+                  window functions:
+                      window function definition
+                        alias: sum_window_0
+                        arguments: _col5
+                        name: sum
+                        window function: GenericUDAFSumLong
+                        window frame: PRECEDING(2)~FOLLOWING(2)
+            Statistics: Num rows: 26 Data size: 3147 Basic stats: COMPLETE Column stats: NONE
+            Select Operator
+              expressions: _col2 (type: string), _col1 (type: string), _col5 (type: int), sum_window_0 (type: bigint)
+              outputColumnNames: _col0, _col1, _col2, _col3
+              Statistics: Num rows: 26 Data size: 3147 Basic stats: COMPLETE Column stats: NONE
+              Group By Operator
+                keys: _col0 (type: string), _col1 (type: string), _col2 (type: int), _col3 (type: bigint)
+                mode: hash
+                outputColumnNames: _col0, _col1, _col2, _col3
+                Statistics: Num rows: 26 Data size: 3147 Basic stats: COMPLETE Column stats: NONE
+                File Output Operator
+                  compressed: false
+                  table:
+                      input format: org.apache.hadoop.mapred.SequenceFileInputFormat
+                      output format: org.apache.hadoop.hive.ql.io.HiveSequenceFileOutputFormat
+                      serde: org.apache.hadoop.hive.serde2.lazybinary.LazyBinarySerDe
+
+  Stage: Stage-2
+    Map Reduce
+      Map Operator Tree:
+          TableScan
+            Reduce Output Operator
+              key expressions: _col0 (type: string), _col1 (type: string), _col2 (type: int), _col3 (type: bigint)
+              sort order: ++++
+              Map-reduce partition columns: _col0 (type: string), _col1 (type: string), _col2 (type: int), _col3 (type: bigint)
+              Statistics: Num rows: 26 Data size: 3147 Basic stats: COMPLETE Column stats: NONE
+      Reduce Operator Tree:
+        Group By Operator
+          keys: KEY._col0 (type: string), KEY._col1 (type: string), KEY._col2 (type: int), KEY._col3 (type: bigint)
+          mode: mergepartial
+          outputColumnNames: _col0, _col1, _col2, _col3
+          Statistics: Num rows: 13 Data size: 1573 Basic stats: COMPLETE Column stats: NONE
+          File Output Operator
+            compressed: false
+            Statistics: Num rows: 13 Data size: 1573 Basic stats: COMPLETE Column stats: NONE
+            table:
+                input format: org.apache.hadoop.mapred.SequenceFileInputFormat
+                output format: org.apache.hadoop.hive.ql.io.HiveSequenceFileOutputFormat
+                serde: org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe
+
+  Stage: Stage-0
+    Fetch Operator
+      limit: -1
+      Processor Tree:
+        ListSink
+
+PREHOOK: query: select DISTINCT p_mfgr, p_name, p_size,
+sum(p_size) over w1 as s
+from part
+window w1 as (distribute by p_mfgr sort by p_name rows between 2 preceding and 2 following)
+PREHOOK: type: QUERY
+PREHOOK: Input: default@part
+#### A masked pattern was here ####
+POSTHOOK: query: select DISTINCT p_mfgr, p_name, p_size,
+sum(p_size) over w1 as s
+from part
+window w1 as (distribute by p_mfgr sort by p_name rows between 2 preceding and 2 following)
+POSTHOOK: type: QUERY
 POSTHOOK: Input: default@part
 #### A masked pattern was here ####
-Manufacturer#1	almond antique burnished rose metallic	2	42
-Manufacturer#1	almond antique chartreuse lavender yellow	34	70
+Manufacturer#1	almond antique burnished rose metallic	2	38
+Manufacturer#1	almond antique burnished rose metallic	2	44
+Manufacturer#1	almond antique chartreuse lavender yellow	34	72
 Manufacturer#1	almond antique salmon chartreuse burlywood	6	112
 Manufacturer#1	almond aquamarine burnished black steel	28	110
 Manufacturer#1	almond aquamarine pink moccasin thistle	42	76
@@ -2002,7 +2103,7 @@ Manufacturer#5	7672.66	1018.1	1789.69	1534.53	5
 Manufacturer#5	7672.66	1018.1	1789.69	1534.53	5
 PREHOOK: query: -- 38. testPartitioningVariousForms2
 select p_mfgr, p_name, p_size,
-sum(p_retailprice) over (partition by p_mfgr, p_name order by p_mfgr, p_name rows between unbounded preceding and current row) as s1,
+round(sum(p_retailprice) over (partition by p_mfgr, p_name order by p_mfgr, p_name rows between unbounded preceding and current row),2) as s1,
 min(p_retailprice) over (distribute by p_mfgr, p_name sort by p_mfgr, p_name rows between unbounded preceding and current row) as s2,
 max(p_retailprice) over (partition by p_mfgr, p_name order by p_name) as s3
 from part
@@ -2011,7 +2112,7 @@ PREHOOK: Input: default@part
 #### A masked pattern was here ####
 POSTHOOK: query: -- 38. testPartitioningVariousForms2
 select p_mfgr, p_name, p_size,
-sum(p_retailprice) over (partition by p_mfgr, p_name order by p_mfgr, p_name rows between unbounded preceding and current row) as s1,
+round(sum(p_retailprice) over (partition by p_mfgr, p_name order by p_mfgr, p_name rows between unbounded preceding and current row),2) as s1,
 min(p_retailprice) over (distribute by p_mfgr, p_name sort by p_mfgr, p_name rows between unbounded preceding and current row) as s2,
 max(p_retailprice) over (partition by p_mfgr, p_name order by p_name) as s3
 from part
@@ -2086,14 +2187,14 @@ Manufacturer#5	SMALL PLATED BRASS	MALL PLATED BRASS	4
 Manufacturer#5	STANDARD BURNISHED TIN	TANDARD BURNISHED TIN	5
 PREHOOK: query: -- 40. testNoBetweenForRows
 select p_mfgr, p_name, p_size,
-    sum(p_retailprice) over (distribute by p_mfgr sort by p_name rows unbounded preceding) as s1
+    round(sum(p_retailprice) over (distribute by p_mfgr sort by p_name rows unbounded preceding),2) as s1
      from part
 PREHOOK: type: QUERY
 PREHOOK: Input: default@part
 #### A masked pattern was here ####
 POSTHOOK: query: -- 40. testNoBetweenForRows
 select p_mfgr, p_name, p_size,
-    sum(p_retailprice) over (distribute by p_mfgr sort by p_name rows unbounded preceding) as s1
+    round(sum(p_retailprice) over (distribute by p_mfgr sort by p_name rows unbounded preceding),2) as s1
      from part
 POSTHOOK: type: QUERY
 POSTHOOK: Input: default@part
@@ -2101,12 +2202,12 @@ POSTHOOK: Input: default@part
 Manufacturer#1	almond antique burnished rose metallic	2	1173.15
 Manufacturer#1	almond antique burnished rose metallic	2	2346.3
 Manufacturer#1	almond antique chartreuse lavender yellow	34	4100.06
-Manufacturer#1	almond antique salmon chartreuse burlywood	6	5702.650000000001
-Manufacturer#1	almond aquamarine burnished black steel	28	7117.070000000001
-Manufacturer#1	almond aquamarine pink moccasin thistle	42	8749.730000000001
+Manufacturer#1	almond antique salmon chartreuse burlywood	6	5702.65
+Manufacturer#1	almond aquamarine burnished black steel	28	7117.07
+Manufacturer#1	almond aquamarine pink moccasin thistle	42	8749.73
 Manufacturer#2	almond antique violet chocolate turquoise	14	1690.68
 Manufacturer#2	almond antique violet turquoise frosted	40	3491.38
-Manufacturer#2	almond aquamarine midnight light salmon	2	5523.360000000001
+Manufacturer#2	almond aquamarine midnight light salmon	2	5523.36
 Manufacturer#2	almond aquamarine rose maroon antique	25	7222.02
 Manufacturer#2	almond aquamarine sandy cyan gainsboro	18	8923.62
 Manufacturer#3	almond antique chartreuse khaki white	17	1671.68
@@ -2118,32 +2219,32 @@ Manufacturer#4	almond antique gainsboro frosted violet	10	1620.67
 Manufacturer#4	almond antique violet mint lemon	39	2996.09
 Manufacturer#4	almond aquamarine floral ivory bisque	27	4202.35
 Manufacturer#4	almond aquamarine yellow dodger mint	7	6047.27
-Manufacturer#4	almond azure aquamarine papaya violet	12	7337.620000000001
+Manufacturer#4	almond azure aquamarine papaya violet	12	7337.62
 Manufacturer#5	almond antique blue firebrick mint	31	1789.69
-Manufacturer#5	almond antique medium spring khaki	6	3401.3500000000004
+Manufacturer#5	almond antique medium spring khaki	6	3401.35
 Manufacturer#5	almond antique sky peru orange	2	5190.08
 Manufacturer#5	almond aquamarine dodger light gainsboro	46	6208.18
 Manufacturer#5	almond azure blanched chiffon midnight	23	7672.66
 PREHOOK: query: -- 41. testNoBetweenForRange
 select p_mfgr, p_name, p_size,
-    sum(p_retailprice) over (distribute by p_mfgr sort by p_size range unbounded preceding) as s1
+    round(sum(p_retailprice) over (distribute by p_mfgr sort by p_size range unbounded preceding),2) as s1
      from part
 PREHOOK: type: QUERY
 PREHOOK: Input: default@part
 #### A masked pattern was here ####
 POSTHOOK: query: -- 41. testNoBetweenForRange
 select p_mfgr, p_name, p_size,
-    sum(p_retailprice) over (distribute by p_mfgr sort by p_size range unbounded preceding) as s1
+    round(sum(p_retailprice) over (distribute by p_mfgr sort by p_size range unbounded preceding),2) as s1
      from part
 POSTHOOK: type: QUERY
 POSTHOOK: Input: default@part
 #### A masked pattern was here ####
 Manufacturer#1	almond antique burnished rose metallic	2	2346.3
 Manufacturer#1	almond antique burnished rose metallic	2	2346.3
-Manufacturer#1	almond antique chartreuse lavender yellow	34	7117.070000000001
-Manufacturer#1	almond antique salmon chartreuse burlywood	6	3948.8900000000003
+Manufacturer#1	almond antique chartreuse lavender yellow	34	7117.07
+Manufacturer#1	almond antique salmon chartreuse burlywood	6	3948.89
 Manufacturer#1	almond aquamarine burnished black steel	28	5363.31
-Manufacturer#1	almond aquamarine pink moccasin thistle	42	8749.730000000001
+Manufacturer#1	almond aquamarine pink moccasin thistle	42	8749.73
 Manufacturer#2	almond antique violet chocolate turquoise	14	3722.66
 Manufacturer#2	almond antique violet turquoise frosted	40	8923.62
 Manufacturer#2	almond aquamarine midnight light salmon	2	2031.98
@@ -2151,97 +2252,97 @@ Manufacturer#2	almond aquamarine rose maroon antique	25	7122.92
 Manufacturer#2	almond aquamarine sandy cyan gainsboro	18	5424.26
 Manufacturer#3	almond antique chartreuse khaki white	17	4784.93
 Manufacturer#3	almond antique forest lavender goldenrod	14	3113.25
-Manufacturer#3	almond antique metallic orange dim	19	6195.320000000001
+Manufacturer#3	almond antique metallic orange dim	19	6195.32
 Manufacturer#3	almond antique misty red olive	1	1922.98
-Manufacturer#3	almond antique olive coral navajo	45	7532.610000000001
+Manufacturer#3	almond antique olive coral navajo	45	7532.61
 Manufacturer#4	almond antique gainsboro frosted violet	10	3465.59
-Manufacturer#4	almond antique violet mint lemon	39	7337.620000000001
-Manufacturer#4	almond aquamarine floral ivory bisque	27	5962.200000000001
+Manufacturer#4	almond antique violet mint lemon	39	7337.62
+Manufacturer#4	almond aquamarine floral ivory bisque	27	5962.2
 Manufacturer#4	almond aquamarine yellow dodger mint	7	1844.92
-Manufacturer#4	almond azure aquamarine papaya violet	12	4755.9400000000005
-Manufacturer#5	almond antique blue firebrick mint	31	6654.560000000001
-Manufacturer#5	almond antique medium spring khaki	6	3400.3900000000003
+Manufacturer#4	almond azure aquamarine papaya violet	12	4755.94
+Manufacturer#5	almond antique blue firebrick mint	31	6654.56
+Manufacturer#5	almond antique medium spring khaki	6	3400.39
 Manufacturer#5	almond antique sky peru orange	2	1788.73
-Manufacturer#5	almond aquamarine dodger light gainsboro	46	7672.660000000002
-Manufacturer#5	almond azure blanched chiffon midnight	23	4864.870000000001
+Manufacturer#5	almond aquamarine dodger light gainsboro	46	7672.66
+Manufacturer#5	almond azure blanched chiffon midnight	23	4864.87
 PREHOOK: query: -- 42. testUnboundedFollowingForRows
 select p_mfgr, p_name, p_size,
-    sum(p_retailprice) over (distribute by p_mfgr sort by p_name rows between current row and unbounded following) as s1
+    round(sum(p_retailprice) over (distribute by p_mfgr sort by p_name rows between current row and unbounded following),2) as s1
     from part
 PREHOOK: type: QUERY
 PREHOOK: Input: default@part
 #### A masked pattern was here ####
 POSTHOOK: query: -- 42. testUnboundedFollowingForRows
 select p_mfgr, p_name, p_size,
-    sum(p_retailprice) over (distribute by p_mfgr sort by p_name rows between current row and unbounded following) as s1
+    round(sum(p_retailprice) over (distribute by p_mfgr sort by p_name rows between current row and unbounded following),2) as s1
     from part
 POSTHOOK: type: QUERY
 POSTHOOK: Input: default@part
 #### A masked pattern was here ####
 Manufacturer#1	almond antique burnished rose metallic	2	7576.58
-Manufacturer#1	almond antique burnished rose metallic	2	8749.730000000001
+Manufacturer#1	almond antique burnished rose metallic	2	8749.73
 Manufacturer#1	almond antique chartreuse lavender yellow	34	6403.43
 Manufacturer#1	almond antique salmon chartreuse burlywood	6	4649.67
 Manufacturer#1	almond aquamarine burnished black steel	28	3047.08
 Manufacturer#1	almond aquamarine pink moccasin thistle	42	1632.66
 Manufacturer#2	almond antique violet chocolate turquoise	14	8923.62
-Manufacturer#2	almond antique violet turquoise frosted	40	7232.9400000000005
+Manufacturer#2	almond antique violet turquoise frosted	40	7232.94
 Manufacturer#2	almond aquamarine midnight light salmon	2	5432.24
 Manufacturer#2	almond aquamarine rose maroon antique	25	3400.26
 Manufacturer#2	almond aquamarine sandy cyan gainsboro	18	1701.6
 Manufacturer#3	almond antique chartreuse khaki white	17	7532.61
-Manufacturer#3	almond antique forest lavender goldenrod	14	5860.929999999999
+Manufacturer#3	almond antique forest lavender goldenrod	14	5860.93
 Manufacturer#3	almond antique metallic orange dim	19	4670.66
 Manufacturer#3	almond antique misty red olive	1	3260.27
 Manufacturer#3	almond antique olive coral navajo	45	1337.29
-Manufacturer#4	almond antique gainsboro frosted violet	10	7337.620000000001
-Manufacturer#4	almond antique violet mint lemon	39	5716.950000000001
-Manufacturer#4	almond aquamarine floral ivory bisque	27	4341.530000000001
+Manufacturer#4	almond antique gainsboro frosted violet	10	7337.62
+Manufacturer#4	almond antique violet mint lemon	39	5716.95
+Manufacturer#4	almond aquamarine floral ivory bisque	27	4341.53
 Manufacturer#4	almond aquamarine yellow dodger mint	7	3135.27
 Manufacturer#4	almond azure aquamarine papaya violet	12	1290.35
 Manufacturer#5	almond antique blue firebrick mint	31	7672.66
-Manufacturer#5	almond antique medium spring khaki	6	5882.970000000001
-Manufacturer#5	almond antique sky peru orange	2	4271.3099999999995
+Manufacturer#5	almond antique medium spring khaki	6	5882.97
+Manufacturer#5	almond antique sky peru orange	2	4271.31
 Manufacturer#5	almond aquamarine dodger light gainsboro	46	2482.58
 Manufacturer#5	almond azure blanched chiffon midnight	23	1464.48
 PREHOOK: query: -- 43. testUnboundedFollowingForRange
 select p_mfgr, p_name, p_size,
-    sum(p_retailprice) over (distribute by p_mfgr sort by p_size range between current row and unbounded following) as s1
+    round(sum(p_retailprice) over (distribute by p_mfgr sort by p_size range between current row and unbounded following),2) as s1
     from part
 PREHOOK: type: QUERY
 PREHOOK: Input: default@part
 #### A masked pattern was here ####
 POSTHOOK: query: -- 43. testUnboundedFollowingForRange
 select p_mfgr, p_name, p_size,
-    sum(p_retailprice) over (distribute by p_mfgr sort by p_size range between current row and unbounded following) as s1
+    round(sum(p_retailprice) over (distribute by p_mfgr sort by p_size range between current row and unbounded following),2) as s1
     from part
 POSTHOOK: type: QUERY
 POSTHOOK: Input: default@part
 #### A masked pattern was here ####
-Manufacturer#1	almond antique burnished rose metallic	2	8749.730000000001
-Manufacturer#1	almond antique burnished rose metallic	2	8749.730000000001
+Manufacturer#1	almond antique burnished rose metallic	2	8749.73
+Manufacturer#1	almond antique burnished rose metallic	2	8749.73
 Manufacturer#1	almond antique chartreuse lavender yellow	34	3386.42
 Manufacturer#1	almond antique salmon chartreuse burlywood	6	6403.43
 Manufacturer#1	almond aquamarine burnished black steel	28	4800.84
 Manufacturer#1	almond aquamarine pink moccasin thistle	42	1632.66
-Manufacturer#2	almond antique violet chocolate turquoise	14	6891.639999999999
+Manufacturer#2	almond antique violet chocolate turquoise	14	6891.64
 Manufacturer#2	almond antique violet turquoise frosted	40	1800.7
 Manufacturer#2	almond aquamarine midnight light salmon	2	8923.62
 Manufacturer#2	almond aquamarine rose maroon antique	25	3499.36
 Manufacturer#2	almond aquamarine sandy cyan gainsboro	18	5200.96
-Manufacturer#3	almond antique chartreuse khaki white	17	4419.360000000001
+Manufacturer#3	almond antique chartreuse khaki white	17	4419.36
 Manufacturer#3	almond antique forest lavender goldenrod	14	5609.63
-Manufacturer#3	almond antique metallic orange dim	19	2747.6800000000003
-Manufacturer#3	almond antique misty red olive	1	7532.610000000001
+Manufacturer#3	almond antique metallic orange dim	19	2747.68
+Manufacturer#3	almond antique misty red olive	1	7532.61
 Manufacturer#3	almond antique olive coral navajo	45	1337.29
 Manufacturer#4	almond antique gainsboro frosted violet	10	5492.7
 Manufacturer#4	almond antique violet mint lemon	39	1375.42
-Manufacturer#4	almond aquamarine floral ivory bisque	27	2581.6800000000003
-Manufacturer#4	almond aquamarine yellow dodger mint	7	7337.620000000001
-Manufacturer#4	almond azure aquamarine papaya violet	12	3872.0299999999997
+Manufacturer#4	almond aquamarine floral ivory bisque	27	2581.68
+Manufacturer#4	almond aquamarine yellow dodger mint	7	7337.62
+Manufacturer#4	almond azure aquamarine papaya violet	12	3872.03
 Manufacturer#5	almond antique blue firebrick mint	31	2807.79
 Manufacturer#5	almond antique medium spring khaki	6	5883.93
-Manufacturer#5	almond antique sky peru orange	2	7672.660000000002
+Manufacturer#5	almond antique sky peru orange	2	7672.66
 Manufacturer#5	almond aquamarine dodger light gainsboro	46	1018.1
 Manufacturer#5	almond azure blanched chiffon midnight	23	4272.27
 PREHOOK: query: -- 44. testOverNoPartitionSingleAggregate
@@ -2303,27 +2404,27 @@ POSTHOOK: type: QUERY
 POSTHOOK: Input: default@part
 #### A masked pattern was here ####
 PREHOOK: query: -- 46. window sz is same as partition sz
-select p_retailprice, avg(p_retailprice) over (partition by p_mfgr order by p_name rows between current row and 6 following), 
-sum(p_retailprice) over (partition by p_mfgr order by p_name rows between current row and 6 following) 
+select p_retailprice, round(avg(p_retailprice) over (partition by p_mfgr order by p_name rows between current row and 6 following),2),
+round(sum(p_retailprice) over (partition by p_mfgr order by p_name rows between current row and 6 following),2)
 from part 
 where p_mfgr='Manufacturer#1'
 PREHOOK: type: QUERY
 PREHOOK: Input: default@part
 #### A masked pattern was here ####
 POSTHOOK: query: -- 46. window sz is same as partition sz
-select p_retailprice, avg(p_retailprice) over (partition by p_mfgr order by p_name rows between current row and 6 following), 
-sum(p_retailprice) over (partition by p_mfgr order by p_name rows between current row and 6 following) 
+select p_retailprice, round(avg(p_retailprice) over (partition by p_mfgr order by p_name rows between current row and 6 following),2),
+round(sum(p_retailprice) over (partition by p_mfgr order by p_name rows between current row and 6 following),2)
 from part 
 where p_mfgr='Manufacturer#1'
 POSTHOOK: type: QUERY
 POSTHOOK: Input: default@part
 #### A masked pattern was here ####
-1173.15	1458.2883333333336	8749.730000000001
-1173.15	1515.3160000000003	7576.580000000002
-1414.42	1523.5400000000004	3047.080000000001
-1602.59	1549.8900000000003	4649.670000000001
-1632.66	1632.6600000000008	1632.6600000000008
-1753.76	1600.8575000000003	6403.430000000001
+1173.15	1458.29	8749.73
+1173.15	1515.32	7576.58
+1414.42	1523.54	3047.08
+1602.59	1549.89	4649.67
+1632.66	1632.66	1632.66
+1753.76	1600.86	6403.43
 PREHOOK: query: -- 47. empty partition
 select sum(p_size) over (partition by p_mfgr )
 from part where p_mfgr = 'm1'


[08/13] hive git commit: HIVE-15520: Improve the sum performance for Range based window (Aihua Xu, reviewed by Yongzhi Chen)

Posted by ai...@apache.org.
http://git-wip-us.apache.org/repos/asf/hive/blob/a28b28f3/ql/src/test/results/clientpositive/llap/vectorized_ptf.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/llap/vectorized_ptf.q.out b/ql/src/test/results/clientpositive/llap/vectorized_ptf.q.out
index 7efb739..127dee7 100644
--- a/ql/src/test/results/clientpositive/llap/vectorized_ptf.q.out
+++ b/ql/src/test/results/clientpositive/llap/vectorized_ptf.q.out
@@ -124,7 +124,7 @@ explain extended
 select p_mfgr, p_name, p_size,
 rank() over (partition by p_mfgr order by p_name) as r,
 dense_rank() over (partition by p_mfgr order by p_name) as dr,
-sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row) as s1
+round(sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row),2) as s1
 from noop(on part_orc 
   partition by p_mfgr
   order by p_name
@@ -136,7 +136,7 @@ explain extended
 select p_mfgr, p_name, p_size,
 rank() over (partition by p_mfgr order by p_name) as r,
 dense_rank() over (partition by p_mfgr order by p_name) as dr,
-sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row) as s1
+round(sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row),2) as s1
 from noop(on part_orc 
   partition by p_mfgr
   order by p_name
@@ -295,7 +295,7 @@ STAGE PLANS:
                               window frame: PRECEDING(MAX)~CURRENT
                   Statistics: Num rows: 26 Data size: 16042 Basic stats: COMPLETE Column stats: NONE
                   Select Operator
-                    expressions: _col2 (type: string), _col1 (type: string), _col5 (type: int), rank_window_0 (type: int), dense_rank_window_1 (type: int), sum_window_2 (type: double)
+                    expressions: _col2 (type: string), _col1 (type: string), _col5 (type: int), rank_window_0 (type: int), dense_rank_window_1 (type: int), round(sum_window_2, 2) (type: double)
                     outputColumnNames: _col0, _col1, _col2, _col3, _col4, _col5
                     Statistics: Num rows: 26 Data size: 16042 Basic stats: COMPLETE Column stats: NONE
                     File Output Operator
@@ -900,7 +900,7 @@ explain extended
 select p_mfgr, p_name, p_size,
 rank() over (partition by p_mfgr order by p_name) as r,
 dense_rank() over (partition by p_mfgr order by p_name) as dr,
-sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row) as s1
+round(sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row),2) as s1
 from noop(on part_orc 
   partition by p_mfgr
   order by p_name
@@ -912,7 +912,7 @@ explain extended
 select p_mfgr, p_name, p_size,
 rank() over (partition by p_mfgr order by p_name) as r,
 dense_rank() over (partition by p_mfgr order by p_name) as dr,
-sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row) as s1
+round(sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row),2) as s1
 from noop(on part_orc 
   partition by p_mfgr
   order by p_name
@@ -1071,7 +1071,7 @@ STAGE PLANS:
                               window frame: PRECEDING(MAX)~CURRENT
                   Statistics: Num rows: 26 Data size: 16042 Basic stats: COMPLETE Column stats: NONE
                   Select Operator
-                    expressions: _col2 (type: string), _col1 (type: string), _col5 (type: int), rank_window_0 (type: int), dense_rank_window_1 (type: int), sum_window_2 (type: double)
+                    expressions: _col2 (type: string), _col1 (type: string), _col5 (type: int), rank_window_0 (type: int), dense_rank_window_1 (type: int), round(sum_window_2, 2) (type: double)
                     outputColumnNames: _col0, _col1, _col2, _col3, _col4, _col5
                     Statistics: Num rows: 26 Data size: 16042 Basic stats: COMPLETE Column stats: NONE
                     File Output Operator
@@ -1106,7 +1106,7 @@ STAGE PLANS:
 PREHOOK: query: select p_mfgr, p_name, p_size,
 rank() over (partition by p_mfgr order by p_name) as r,
 dense_rank() over (partition by p_mfgr order by p_name) as dr,
-sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row) as s1
+round(sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row),2) as s1
 from noop(on part_orc 
   partition by p_mfgr
   order by p_name
@@ -1117,7 +1117,7 @@ PREHOOK: Input: default@part_orc
 POSTHOOK: query: select p_mfgr, p_name, p_size,
 rank() over (partition by p_mfgr order by p_name) as r,
 dense_rank() over (partition by p_mfgr order by p_name) as dr,
-sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row) as s1
+round(sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row),2) as s1
 from noop(on part_orc 
   partition by p_mfgr
   order by p_name
@@ -1128,12 +1128,12 @@ POSTHOOK: Input: default@part_orc
 Manufacturer#1	almond antique burnished rose metallic	2	1	1	1173.15
 Manufacturer#1	almond antique burnished rose metallic	2	1	1	2346.3
 Manufacturer#1	almond antique chartreuse lavender yellow	34	3	2	4100.06
-Manufacturer#1	almond antique salmon chartreuse burlywood	6	4	3	5702.650000000001
-Manufacturer#1	almond aquamarine burnished black steel	28	5	4	7117.070000000001
-Manufacturer#1	almond aquamarine pink moccasin thistle	42	6	5	8749.730000000001
+Manufacturer#1	almond antique salmon chartreuse burlywood	6	4	3	5702.65
+Manufacturer#1	almond aquamarine burnished black steel	28	5	4	7117.07
+Manufacturer#1	almond aquamarine pink moccasin thistle	42	6	5	8749.73
 Manufacturer#2	almond antique violet chocolate turquoise	14	1	1	1690.68
 Manufacturer#2	almond antique violet turquoise frosted	40	2	2	3491.38
-Manufacturer#2	almond aquamarine midnight light salmon	2	3	3	5523.360000000001
+Manufacturer#2	almond aquamarine midnight light salmon	2	3	3	5523.36
 Manufacturer#2	almond aquamarine rose maroon antique	25	4	4	7222.02
 Manufacturer#2	almond aquamarine sandy cyan gainsboro	18	5	5	8923.62
 Manufacturer#3	almond antique chartreuse khaki white	17	1	1	1671.68
@@ -1145,9 +1145,9 @@ Manufacturer#4	almond antique gainsboro frosted violet	10	1	1	1620.67
 Manufacturer#4	almond antique violet mint lemon	39	2	2	2996.09
 Manufacturer#4	almond aquamarine floral ivory bisque	27	3	3	4202.35
 Manufacturer#4	almond aquamarine yellow dodger mint	7	4	4	6047.27
-Manufacturer#4	almond azure aquamarine papaya violet	12	5	5	7337.620000000001
+Manufacturer#4	almond azure aquamarine papaya violet	12	5	5	7337.62
 Manufacturer#5	almond antique blue firebrick mint	31	1	1	1789.69
-Manufacturer#5	almond antique medium spring khaki	6	2	2	3401.3500000000004
+Manufacturer#5	almond antique medium spring khaki	6	2	2	3401.35
 Manufacturer#5	almond antique sky peru orange	2	3	3	5190.08
 Manufacturer#5	almond aquamarine dodger light gainsboro	46	4	4	6208.18
 Manufacturer#5	almond azure blanched chiffon midnight	23	5	5	7672.66
@@ -2510,7 +2510,7 @@ explain extended
 select p_mfgr, p_name, p_size,
 rank() over (partition by p_mfgr order by p_name) as r,
 dense_rank() over (partition by p_mfgr order by p_name) as dr,
-sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row) as s1
+round(sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row),2) as s1
 from noopwithmap(on part_orc 
   partition by p_mfgr
   order by p_name)
@@ -2521,7 +2521,7 @@ explain extended
 select p_mfgr, p_name, p_size,
 rank() over (partition by p_mfgr order by p_name) as r,
 dense_rank() over (partition by p_mfgr order by p_name) as dr,
-sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row) as s1
+round(sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row),2) as s1
 from noopwithmap(on part_orc 
   partition by p_mfgr
   order by p_name)
@@ -2696,7 +2696,7 @@ STAGE PLANS:
                               window frame: PRECEDING(MAX)~CURRENT
                   Statistics: Num rows: 26 Data size: 16042 Basic stats: COMPLETE Column stats: NONE
                   Select Operator
-                    expressions: _col2 (type: string), _col1 (type: string), _col5 (type: int), rank_window_0 (type: int), dense_rank_window_1 (type: int), sum_window_2 (type: double)
+                    expressions: _col2 (type: string), _col1 (type: string), _col5 (type: int), rank_window_0 (type: int), dense_rank_window_1 (type: int), round(sum_window_2, 2) (type: double)
                     outputColumnNames: _col0, _col1, _col2, _col3, _col4, _col5
                     Statistics: Num rows: 26 Data size: 16042 Basic stats: COMPLETE Column stats: NONE
                     File Output Operator
@@ -2731,7 +2731,7 @@ STAGE PLANS:
 PREHOOK: query: select p_mfgr, p_name, p_size,
 rank() over (partition by p_mfgr order by p_name) as r,
 dense_rank() over (partition by p_mfgr order by p_name) as dr,
-sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row) as s1
+round(sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row),2) as s1
 from noopwithmap(on part_orc 
   partition by p_mfgr
   order by p_name)
@@ -2741,7 +2741,7 @@ PREHOOK: Input: default@part_orc
 POSTHOOK: query: select p_mfgr, p_name, p_size,
 rank() over (partition by p_mfgr order by p_name) as r,
 dense_rank() over (partition by p_mfgr order by p_name) as dr,
-sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row) as s1
+round(sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row),2) as s1
 from noopwithmap(on part_orc 
   partition by p_mfgr
   order by p_name)
@@ -2751,12 +2751,12 @@ POSTHOOK: Input: default@part_orc
 Manufacturer#1	almond antique burnished rose metallic	2	1	1	1173.15
 Manufacturer#1	almond antique burnished rose metallic	2	1	1	2346.3
 Manufacturer#1	almond antique chartreuse lavender yellow	34	3	2	4100.06
-Manufacturer#1	almond antique salmon chartreuse burlywood	6	4	3	5702.650000000001
-Manufacturer#1	almond aquamarine burnished black steel	28	5	4	7117.070000000001
-Manufacturer#1	almond aquamarine pink moccasin thistle	42	6	5	8749.730000000001
+Manufacturer#1	almond antique salmon chartreuse burlywood	6	4	3	5702.65
+Manufacturer#1	almond aquamarine burnished black steel	28	5	4	7117.07
+Manufacturer#1	almond aquamarine pink moccasin thistle	42	6	5	8749.73
 Manufacturer#2	almond antique violet chocolate turquoise	14	1	1	1690.68
 Manufacturer#2	almond antique violet turquoise frosted	40	2	2	3491.38
-Manufacturer#2	almond aquamarine midnight light salmon	2	3	3	5523.360000000001
+Manufacturer#2	almond aquamarine midnight light salmon	2	3	3	5523.36
 Manufacturer#2	almond aquamarine rose maroon antique	25	4	4	7222.02
 Manufacturer#2	almond aquamarine sandy cyan gainsboro	18	5	5	8923.62
 Manufacturer#3	almond antique chartreuse khaki white	17	1	1	1671.68
@@ -2768,9 +2768,9 @@ Manufacturer#4	almond antique gainsboro frosted violet	10	1	1	1620.67
 Manufacturer#4	almond antique violet mint lemon	39	2	2	2996.09
 Manufacturer#4	almond aquamarine floral ivory bisque	27	3	3	4202.35
 Manufacturer#4	almond aquamarine yellow dodger mint	7	4	4	6047.27
-Manufacturer#4	almond azure aquamarine papaya violet	12	5	5	7337.620000000001
+Manufacturer#4	almond azure aquamarine papaya violet	12	5	5	7337.62
 Manufacturer#5	almond antique blue firebrick mint	31	1	1	1789.69
-Manufacturer#5	almond antique medium spring khaki	6	2	2	3401.3500000000004
+Manufacturer#5	almond antique medium spring khaki	6	2	2	3401.35
 Manufacturer#5	almond antique sky peru orange	2	3	3	5190.08
 Manufacturer#5	almond aquamarine dodger light gainsboro	46	4	4	6208.18
 Manufacturer#5	almond azure blanched chiffon midnight	23	5	5	7672.66
@@ -2780,7 +2780,7 @@ explain extended
 select p_mfgr, p_name, p_size,
 rank() over (partition by p_mfgr order by p_name) as r,
 dense_rank() over (partition by p_mfgr order by p_name) as dr,
-sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row) as s1
+round(sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row),2) as s1
 from noop(on part_orc
 partition by p_mfgr
 order by p_name)
@@ -2791,7 +2791,7 @@ explain extended
 select p_mfgr, p_name, p_size,
 rank() over (partition by p_mfgr order by p_name) as r,
 dense_rank() over (partition by p_mfgr order by p_name) as dr,
-sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row) as s1
+round(sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row),2) as s1
 from noop(on part_orc
 partition by p_mfgr
 order by p_name)
@@ -2949,7 +2949,7 @@ STAGE PLANS:
                               window frame: PRECEDING(MAX)~CURRENT
                   Statistics: Num rows: 26 Data size: 16042 Basic stats: COMPLETE Column stats: NONE
                   Select Operator
-                    expressions: _col2 (type: string), _col1 (type: string), _col5 (type: int), rank_window_0 (type: int), dense_rank_window_1 (type: int), sum_window_2 (type: double)
+                    expressions: _col2 (type: string), _col1 (type: string), _col5 (type: int), rank_window_0 (type: int), dense_rank_window_1 (type: int), round(sum_window_2, 2) (type: double)
                     outputColumnNames: _col0, _col1, _col2, _col3, _col4, _col5
                     Statistics: Num rows: 26 Data size: 16042 Basic stats: COMPLETE Column stats: NONE
                     File Output Operator
@@ -2984,7 +2984,7 @@ STAGE PLANS:
 PREHOOK: query: select p_mfgr, p_name, p_size,
 rank() over (partition by p_mfgr order by p_name) as r,
 dense_rank() over (partition by p_mfgr order by p_name) as dr,
-sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row) as s1
+round(sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row),2) as s1
 from noop(on part_orc
 partition by p_mfgr
 order by p_name)
@@ -2994,7 +2994,7 @@ PREHOOK: Input: default@part_orc
 POSTHOOK: query: select p_mfgr, p_name, p_size,
 rank() over (partition by p_mfgr order by p_name) as r,
 dense_rank() over (partition by p_mfgr order by p_name) as dr,
-sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row) as s1
+round(sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row),2) as s1
 from noop(on part_orc
 partition by p_mfgr
 order by p_name)
@@ -3004,12 +3004,12 @@ POSTHOOK: Input: default@part_orc
 Manufacturer#1	almond antique burnished rose metallic	2	1	1	1173.15
 Manufacturer#1	almond antique burnished rose metallic	2	1	1	2346.3
 Manufacturer#1	almond antique chartreuse lavender yellow	34	3	2	4100.06
-Manufacturer#1	almond antique salmon chartreuse burlywood	6	4	3	5702.650000000001
-Manufacturer#1	almond aquamarine burnished black steel	28	5	4	7117.070000000001
-Manufacturer#1	almond aquamarine pink moccasin thistle	42	6	5	8749.730000000001
+Manufacturer#1	almond antique salmon chartreuse burlywood	6	4	3	5702.65
+Manufacturer#1	almond aquamarine burnished black steel	28	5	4	7117.07
+Manufacturer#1	almond aquamarine pink moccasin thistle	42	6	5	8749.73
 Manufacturer#2	almond antique violet chocolate turquoise	14	1	1	1690.68
 Manufacturer#2	almond antique violet turquoise frosted	40	2	2	3491.38
-Manufacturer#2	almond aquamarine midnight light salmon	2	3	3	5523.360000000001
+Manufacturer#2	almond aquamarine midnight light salmon	2	3	3	5523.36
 Manufacturer#2	almond aquamarine rose maroon antique	25	4	4	7222.02
 Manufacturer#2	almond aquamarine sandy cyan gainsboro	18	5	5	8923.62
 Manufacturer#3	almond antique chartreuse khaki white	17	1	1	1671.68
@@ -3021,9 +3021,9 @@ Manufacturer#4	almond antique gainsboro frosted violet	10	1	1	1620.67
 Manufacturer#4	almond antique violet mint lemon	39	2	2	2996.09
 Manufacturer#4	almond aquamarine floral ivory bisque	27	3	3	4202.35
 Manufacturer#4	almond aquamarine yellow dodger mint	7	4	4	6047.27
-Manufacturer#4	almond azure aquamarine papaya violet	12	5	5	7337.620000000001
+Manufacturer#4	almond azure aquamarine papaya violet	12	5	5	7337.62
 Manufacturer#5	almond antique blue firebrick mint	31	1	1	1789.69
-Manufacturer#5	almond antique medium spring khaki	6	2	2	3401.3500000000004
+Manufacturer#5	almond antique medium spring khaki	6	2	2	3401.35
 Manufacturer#5	almond antique sky peru orange	2	3	3	5190.08
 Manufacturer#5	almond aquamarine dodger light gainsboro	46	4	4	6208.18
 Manufacturer#5	almond azure blanched chiffon midnight	23	5	5	7672.66
@@ -3033,7 +3033,7 @@ explain extended
 select p_mfgr, p_name, p_size, 
 rank() over (partition by p_mfgr order by p_name) as r, 
 dense_rank() over (partition by p_mfgr order by p_name) as dr, 
-sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row)  as s1
+round(sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row),2) as s1
 from noop(on noopwithmap(on noop(on part_orc 
 partition by p_mfgr 
 order by p_mfgr, p_name
@@ -3045,7 +3045,7 @@ explain extended
 select p_mfgr, p_name, p_size, 
 rank() over (partition by p_mfgr order by p_name) as r, 
 dense_rank() over (partition by p_mfgr order by p_name) as dr, 
-sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row)  as s1
+round(sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row),2) as s1
 from noop(on noopwithmap(on noop(on part_orc 
 partition by p_mfgr 
 order by p_mfgr, p_name
@@ -3267,7 +3267,7 @@ STAGE PLANS:
                               window frame: PRECEDING(MAX)~CURRENT
                   Statistics: Num rows: 26 Data size: 16042 Basic stats: COMPLETE Column stats: NONE
                   Select Operator
-                    expressions: _col2 (type: string), _col1 (type: string), _col5 (type: int), rank_window_0 (type: int), dense_rank_window_1 (type: int), sum_window_2 (type: double)
+                    expressions: _col2 (type: string), _col1 (type: string), _col5 (type: int), rank_window_0 (type: int), dense_rank_window_1 (type: int), round(sum_window_2, 2) (type: double)
                     outputColumnNames: _col0, _col1, _col2, _col3, _col4, _col5
                     Statistics: Num rows: 26 Data size: 16042 Basic stats: COMPLETE Column stats: NONE
                     File Output Operator
@@ -3302,7 +3302,7 @@ STAGE PLANS:
 PREHOOK: query: select p_mfgr, p_name, p_size, 
 rank() over (partition by p_mfgr order by p_name) as r, 
 dense_rank() over (partition by p_mfgr order by p_name) as dr, 
-sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row)  as s1
+round(sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row),2) as s1
 from noop(on noopwithmap(on noop(on part_orc 
 partition by p_mfgr 
 order by p_mfgr, p_name
@@ -3313,7 +3313,7 @@ PREHOOK: Input: default@part_orc
 POSTHOOK: query: select p_mfgr, p_name, p_size, 
 rank() over (partition by p_mfgr order by p_name) as r, 
 dense_rank() over (partition by p_mfgr order by p_name) as dr, 
-sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row)  as s1
+round(sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row),2) as s1
 from noop(on noopwithmap(on noop(on part_orc 
 partition by p_mfgr 
 order by p_mfgr, p_name
@@ -3324,12 +3324,12 @@ POSTHOOK: Input: default@part_orc
 Manufacturer#1	almond antique burnished rose metallic	2	1	1	1173.15
 Manufacturer#1	almond antique burnished rose metallic	2	1	1	2346.3
 Manufacturer#1	almond antique chartreuse lavender yellow	34	3	2	4100.06
-Manufacturer#1	almond antique salmon chartreuse burlywood	6	4	3	5702.650000000001
-Manufacturer#1	almond aquamarine burnished black steel	28	5	4	7117.070000000001
-Manufacturer#1	almond aquamarine pink moccasin thistle	42	6	5	8749.730000000001
+Manufacturer#1	almond antique salmon chartreuse burlywood	6	4	3	5702.65
+Manufacturer#1	almond aquamarine burnished black steel	28	5	4	7117.07
+Manufacturer#1	almond aquamarine pink moccasin thistle	42	6	5	8749.73
 Manufacturer#2	almond antique violet chocolate turquoise	14	1	1	1690.68
 Manufacturer#2	almond antique violet turquoise frosted	40	2	2	3491.38
-Manufacturer#2	almond aquamarine midnight light salmon	2	3	3	5523.360000000001
+Manufacturer#2	almond aquamarine midnight light salmon	2	3	3	5523.36
 Manufacturer#2	almond aquamarine rose maroon antique	25	4	4	7222.02
 Manufacturer#2	almond aquamarine sandy cyan gainsboro	18	5	5	8923.62
 Manufacturer#3	almond antique chartreuse khaki white	17	1	1	1671.68
@@ -3341,9 +3341,9 @@ Manufacturer#4	almond antique gainsboro frosted violet	10	1	1	1620.67
 Manufacturer#4	almond antique violet mint lemon	39	2	2	2996.09
 Manufacturer#4	almond aquamarine floral ivory bisque	27	3	3	4202.35
 Manufacturer#4	almond aquamarine yellow dodger mint	7	4	4	6047.27
-Manufacturer#4	almond azure aquamarine papaya violet	12	5	5	7337.620000000001
+Manufacturer#4	almond azure aquamarine papaya violet	12	5	5	7337.62
 Manufacturer#5	almond antique blue firebrick mint	31	1	1	1789.69
-Manufacturer#5	almond antique medium spring khaki	6	2	2	3401.3500000000004
+Manufacturer#5	almond antique medium spring khaki	6	2	2	3401.35
 Manufacturer#5	almond antique sky peru orange	2	3	3	5190.08
 Manufacturer#5	almond aquamarine dodger light gainsboro	46	4	4	6208.18
 Manufacturer#5	almond azure blanched chiffon midnight	23	5	5	7672.66
@@ -3355,7 +3355,7 @@ sub1.cd, sub1.s1
 from (select p_mfgr, p_name, 
 count(p_size) over (partition by p_mfgr order by p_name) as cd, 
 p_retailprice, 
-sum(p_retailprice) over w1  as s1
+round(sum(p_retailprice) over w1,2) as s1
 from noop(on part_orc 
 partition by p_mfgr 
 order by p_name) 
@@ -3370,7 +3370,7 @@ sub1.cd, sub1.s1
 from (select p_mfgr, p_name, 
 count(p_size) over (partition by p_mfgr order by p_name) as cd, 
 p_retailprice, 
-sum(p_retailprice) over w1  as s1
+round(sum(p_retailprice) over w1,2) as s1
 from noop(on part_orc 
 partition by p_mfgr 
 order by p_name) 
@@ -3522,7 +3522,7 @@ STAGE PLANS:
                               window frame: PRECEDING(2)~FOLLOWING(2)
                   Statistics: Num rows: 26 Data size: 16042 Basic stats: COMPLETE Column stats: NONE
                   Select Operator
-                    expressions: _col2 (type: string), _col1 (type: string), count_window_0 (type: bigint), sum_window_1 (type: double)
+                    expressions: _col2 (type: string), _col1 (type: string), count_window_0 (type: bigint), round(sum_window_1, 2) (type: double)
                     outputColumnNames: _col0, _col1, _col2, _col3
                     Statistics: Num rows: 26 Data size: 16042 Basic stats: COMPLETE Column stats: NONE
                     File Output Operator
@@ -3559,7 +3559,7 @@ sub1.cd, sub1.s1
 from (select p_mfgr, p_name, 
 count(p_size) over (partition by p_mfgr order by p_name) as cd, 
 p_retailprice, 
-sum(p_retailprice) over w1  as s1
+round(sum(p_retailprice) over w1,2) as s1
 from noop(on part_orc 
 partition by p_mfgr 
 order by p_name) 
@@ -3573,7 +3573,7 @@ sub1.cd, sub1.s1
 from (select p_mfgr, p_name, 
 count(p_size) over (partition by p_mfgr order by p_name) as cd, 
 p_retailprice, 
-sum(p_retailprice) over w1  as s1
+round(sum(p_retailprice) over w1,2) as s1
 from noop(on part_orc 
 partition by p_mfgr 
 order by p_name) 
@@ -3583,31 +3583,31 @@ POSTHOOK: type: QUERY
 POSTHOOK: Input: default@part_orc
 #### A masked pattern was here ####
 Manufacturer#1	almond antique burnished rose metallic	2	4100.06
-Manufacturer#1	almond antique burnished rose metallic	2	5702.650000000001
-Manufacturer#1	almond antique chartreuse lavender yellow	3	7117.070000000001
+Manufacturer#1	almond antique burnished rose metallic	2	5702.65
+Manufacturer#1	almond antique chartreuse lavender yellow	3	7117.07
 Manufacturer#1	almond antique salmon chartreuse burlywood	4	7576.58
 Manufacturer#1	almond aquamarine burnished black steel	5	6403.43
 Manufacturer#1	almond aquamarine pink moccasin thistle	6	4649.67
-Manufacturer#2	almond antique violet chocolate turquoise	1	5523.360000000001
+Manufacturer#2	almond antique violet chocolate turquoise	1	5523.36
 Manufacturer#2	almond antique violet turquoise frosted	2	7222.02
 Manufacturer#2	almond aquamarine midnight light salmon	3	8923.62
-Manufacturer#2	almond aquamarine rose maroon antique	4	7232.9400000000005
+Manufacturer#2	almond aquamarine rose maroon antique	4	7232.94
 Manufacturer#2	almond aquamarine sandy cyan gainsboro	5	5432.24
 Manufacturer#3	almond antique chartreuse khaki white	1	4272.34
 Manufacturer#3	almond antique forest lavender goldenrod	2	6195.32
 Manufacturer#3	almond antique metallic orange dim	3	7532.61
-Manufacturer#3	almond antique misty red olive	4	5860.929999999999
+Manufacturer#3	almond antique misty red olive	4	5860.93
 Manufacturer#3	almond antique olive coral navajo	5	4670.66
 Manufacturer#4	almond antique gainsboro frosted violet	1	4202.35
 Manufacturer#4	almond antique violet mint lemon	2	6047.27
-Manufacturer#4	almond aquamarine floral ivory bisque	3	7337.620000000001
-Manufacturer#4	almond aquamarine yellow dodger mint	4	5716.950000000001
-Manufacturer#4	almond azure aquamarine papaya violet	5	4341.530000000001
+Manufacturer#4	almond aquamarine floral ivory bisque	3	7337.62
+Manufacturer#4	almond aquamarine yellow dodger mint	4	5716.95
+Manufacturer#4	almond azure aquamarine papaya violet	5	4341.53
 Manufacturer#5	almond antique blue firebrick mint	1	5190.08
 Manufacturer#5	almond antique medium spring khaki	2	6208.18
 Manufacturer#5	almond antique sky peru orange	3	7672.66
-Manufacturer#5	almond aquamarine dodger light gainsboro	4	5882.970000000001
-Manufacturer#5	almond azure blanched chiffon midnight	5	4271.3099999999995
+Manufacturer#5	almond aquamarine dodger light gainsboro	4	5882.97
+Manufacturer#5	almond azure blanched chiffon midnight	5	4271.31
 PREHOOK: query: -- 14. testPTFJoinWithWindowingWithCount
 
 explain extended
@@ -3615,7 +3615,7 @@ select abc.p_mfgr, abc.p_name,
 rank() over (distribute by abc.p_mfgr sort by abc.p_name) as r, 
 dense_rank() over (distribute by abc.p_mfgr sort by abc.p_name) as dr, 
 count(abc.p_name) over (distribute by abc.p_mfgr sort by abc.p_name) as cd, 
-abc.p_retailprice, sum(abc.p_retailprice) over (distribute by abc.p_mfgr sort by abc.p_name rows between unbounded preceding and current row) as s1, 
+abc.p_retailprice, round(sum(abc.p_retailprice) over (distribute by abc.p_mfgr sort by abc.p_name rows between unbounded preceding and current row),2) as s1,
 abc.p_size, abc.p_size - lag(abc.p_size,1,abc.p_size) over (distribute by abc.p_mfgr sort by abc.p_name) as deltaSz 
 from noop(on part_orc 
 partition by p_mfgr 
@@ -3629,7 +3629,7 @@ select abc.p_mfgr, abc.p_name,
 rank() over (distribute by abc.p_mfgr sort by abc.p_name) as r, 
 dense_rank() over (distribute by abc.p_mfgr sort by abc.p_name) as dr, 
 count(abc.p_name) over (distribute by abc.p_mfgr sort by abc.p_name) as cd, 
-abc.p_retailprice, sum(abc.p_retailprice) over (distribute by abc.p_mfgr sort by abc.p_name rows between unbounded preceding and current row) as s1, 
+abc.p_retailprice, round(sum(abc.p_retailprice) over (distribute by abc.p_mfgr sort by abc.p_name rows between unbounded preceding and current row),2) as s1,
 abc.p_size, abc.p_size - lag(abc.p_size,1,abc.p_size) over (distribute by abc.p_mfgr sort by abc.p_name) as deltaSz 
 from noop(on part_orc 
 partition by p_mfgr 
@@ -3898,7 +3898,7 @@ STAGE PLANS:
                               isPivotResult: true
                   Statistics: Num rows: 28 Data size: 17646 Basic stats: COMPLETE Column stats: NONE
                   Select Operator
-                    expressions: _col2 (type: string), _col1 (type: string), rank_window_0 (type: int), dense_rank_window_1 (type: int), count_window_2 (type: bigint), _col7 (type: double), sum_window_3 (type: double), _col5 (type: int), (_col5 - lag_window_4) (type: int)
+                    expressions: _col2 (type: string), _col1 (type: string), rank_window_0 (type: int), dense_rank_window_1 (type: int), count_window_2 (type: bigint), _col7 (type: double), round(sum_window_3, 2) (type: double), _col5 (type: int), (_col5 - lag_window_4) (type: int)
                     outputColumnNames: _col0, _col1, _col2, _col3, _col4, _col5, _col6, _col7, _col8
                     Statistics: Num rows: 28 Data size: 17646 Basic stats: COMPLETE Column stats: NONE
                     File Output Operator
@@ -3934,7 +3934,7 @@ PREHOOK: query: select abc.p_mfgr, abc.p_name,
 rank() over (distribute by abc.p_mfgr sort by abc.p_name) as r, 
 dense_rank() over (distribute by abc.p_mfgr sort by abc.p_name) as dr, 
 count(abc.p_name) over (distribute by abc.p_mfgr sort by abc.p_name) as cd, 
-abc.p_retailprice, sum(abc.p_retailprice) over (distribute by abc.p_mfgr sort by abc.p_name rows between unbounded preceding and current row) as s1, 
+abc.p_retailprice, round(sum(abc.p_retailprice) over (distribute by abc.p_mfgr sort by abc.p_name rows between unbounded preceding and current row),2) as s1,
 abc.p_size, abc.p_size - lag(abc.p_size,1,abc.p_size) over (distribute by abc.p_mfgr sort by abc.p_name) as deltaSz 
 from noop(on part_orc 
 partition by p_mfgr 
@@ -3947,7 +3947,7 @@ POSTHOOK: query: select abc.p_mfgr, abc.p_name,
 rank() over (distribute by abc.p_mfgr sort by abc.p_name) as r, 
 dense_rank() over (distribute by abc.p_mfgr sort by abc.p_name) as dr, 
 count(abc.p_name) over (distribute by abc.p_mfgr sort by abc.p_name) as cd, 
-abc.p_retailprice, sum(abc.p_retailprice) over (distribute by abc.p_mfgr sort by abc.p_name rows between unbounded preceding and current row) as s1, 
+abc.p_retailprice, round(sum(abc.p_retailprice) over (distribute by abc.p_mfgr sort by abc.p_name rows between unbounded preceding and current row),2) as s1,
 abc.p_size, abc.p_size - lag(abc.p_size,1,abc.p_size) over (distribute by abc.p_mfgr sort by abc.p_name) as deltaSz 
 from noop(on part_orc 
 partition by p_mfgr 
@@ -3958,15 +3958,15 @@ POSTHOOK: Input: default@part_orc
 #### A masked pattern was here ####
 Manufacturer#1	almond antique burnished rose metallic	1	1	4	1173.15	1173.15	2	0
 Manufacturer#1	almond antique burnished rose metallic	1	1	4	1173.15	2346.3	2	0
-Manufacturer#1	almond antique burnished rose metallic	1	1	4	1173.15	3519.4500000000003	2	0
+Manufacturer#1	almond antique burnished rose metallic	1	1	4	1173.15	3519.45	2	0
 Manufacturer#1	almond antique burnished rose metallic	1	1	4	1173.15	4692.6	2	0
-Manufacturer#1	almond antique chartreuse lavender yellow	5	2	5	1753.76	6446.360000000001	34	32
-Manufacturer#1	almond antique salmon chartreuse burlywood	6	3	6	1602.59	8048.950000000001	6	-28
+Manufacturer#1	almond antique chartreuse lavender yellow	5	2	5	1753.76	6446.36	34	32
+Manufacturer#1	almond antique salmon chartreuse burlywood	6	3	6	1602.59	8048.95	6	-28
 Manufacturer#1	almond aquamarine burnished black steel	7	4	7	1414.42	9463.37	28	22
 Manufacturer#1	almond aquamarine pink moccasin thistle	8	5	8	1632.66	11096.03	42	14
 Manufacturer#2	almond antique violet chocolate turquoise	1	1	1	1690.68	1690.68	14	0
 Manufacturer#2	almond antique violet turquoise frosted	2	2	2	1800.7	3491.38	40	26
-Manufacturer#2	almond aquamarine midnight light salmon	3	3	3	2031.98	5523.360000000001	2	-38
+Manufacturer#2	almond aquamarine midnight light salmon	3	3	3	2031.98	5523.36	2	-38
 Manufacturer#2	almond aquamarine rose maroon antique	4	4	4	1698.66	7222.02	25	23
 Manufacturer#2	almond aquamarine sandy cyan gainsboro	5	5	5	1701.6	8923.62	18	-7
 Manufacturer#3	almond antique chartreuse khaki white	1	1	1	1671.68	1671.68	17	0
@@ -3978,9 +3978,9 @@ Manufacturer#4	almond antique gainsboro frosted violet	1	1	1	1620.67	1620.67	10
 Manufacturer#4	almond antique violet mint lemon	2	2	2	1375.42	2996.09	39	29
 Manufacturer#4	almond aquamarine floral ivory bisque	3	3	3	1206.26	4202.35	27	-12
 Manufacturer#4	almond aquamarine yellow dodger mint	4	4	4	1844.92	6047.27	7	-20
-Manufacturer#4	almond azure aquamarine papaya violet	5	5	5	1290.35	7337.620000000001	12	5
+Manufacturer#4	almond azure aquamarine papaya violet	5	5	5	1290.35	7337.62	12	5
 Manufacturer#5	almond antique blue firebrick mint	1	1	1	1789.69	1789.69	31	0
-Manufacturer#5	almond antique medium spring khaki	2	2	2	1611.66	3401.3500000000004	6	-25
+Manufacturer#5	almond antique medium spring khaki	2	2	2	1611.66	3401.35	6	-25
 Manufacturer#5	almond antique sky peru orange	3	3	3	1788.73	5190.08	2	-4
 Manufacturer#5	almond aquamarine dodger light gainsboro	4	4	4	1018.1	6208.18	46	44
 Manufacturer#5	almond azure blanched chiffon midnight	5	5	5	1464.48	7672.66	23	-23
@@ -4198,7 +4198,7 @@ Manufacturer#5	almond azure blanched chiffon midnight	23
 PREHOOK: query: -- 16. testViewAsTableInputToPTF
 create view IF NOT EXISTS mfgr_price_view as 
 select p_mfgr, p_brand, 
-sum(p_retailprice) as s 
+round(sum(p_retailprice),2) as s
 from part_orc 
 group by p_mfgr, p_brand
 PREHOOK: type: CREATEVIEW
@@ -4208,7 +4208,7 @@ PREHOOK: Output: default@mfgr_price_view
 POSTHOOK: query: -- 16. testViewAsTableInputToPTF
 create view IF NOT EXISTS mfgr_price_view as 
 select p_mfgr, p_brand, 
-sum(p_retailprice) as s 
+round(sum(p_retailprice),2) as s
 from part_orc 
 group by p_mfgr, p_brand
 POSTHOOK: type: CREATEVIEW
@@ -4217,7 +4217,7 @@ POSTHOOK: Output: database:default
 POSTHOOK: Output: default@mfgr_price_view
 PREHOOK: query: explain extended
 select p_mfgr, p_brand, s, 
-sum(s) over w1  as s1
+round(sum(s) over w1,2) as s1
 from noop(on mfgr_price_view 
 partition by p_mfgr 
 order by p_mfgr)  
@@ -4225,7 +4225,7 @@ window w1 as ( partition by p_mfgr order by p_brand rows between 2 preceding and
 PREHOOK: type: QUERY
 POSTHOOK: query: explain extended
 select p_mfgr, p_brand, s, 
-sum(s) over w1  as s1
+round(sum(s) over w1,2) as s1
 from noop(on mfgr_price_view 
 partition by p_mfgr 
 order by p_mfgr)  
@@ -4330,29 +4330,33 @@ STAGE PLANS:
                 mode: mergepartial
                 outputColumnNames: _col0, _col1, _col2
                 Statistics: Num rows: 13 Data size: 8021 Basic stats: COMPLETE Column stats: NONE
-                PTF Operator
-                  Function definitions:
-                      Input definition
-                        input alias: mfgr_price_view
-                        output shape: _col0: string, _col1: string, _col2: double
-                        type: TABLE
-                      Partition table definition
-                        input alias: ptf_1
-                        name: noop
-                        order by: _col0 ASC NULLS FIRST
-                        output shape: _col0: string, _col1: string, _col2: double
-                        partition by: _col0
-                        raw input shape:
+                Select Operator
+                  expressions: _col0 (type: string), _col1 (type: string), round(_col2, 2) (type: double)
+                  outputColumnNames: _col0, _col1, _col2
                   Statistics: Num rows: 13 Data size: 8021 Basic stats: COMPLETE Column stats: NONE
-                  Reduce Output Operator
-                    key expressions: _col0 (type: string), _col1 (type: string)
-                    null sort order: aa
-                    sort order: ++
-                    Map-reduce partition columns: _col0 (type: string)
+                  PTF Operator
+                    Function definitions:
+                        Input definition
+                          input alias: mfgr_price_view
+                          output shape: _col0: string, _col1: string, _col2: double
+                          type: TABLE
+                        Partition table definition
+                          input alias: ptf_1
+                          name: noop
+                          order by: _col0 ASC NULLS FIRST
+                          output shape: _col0: string, _col1: string, _col2: double
+                          partition by: _col0
+                          raw input shape:
                     Statistics: Num rows: 13 Data size: 8021 Basic stats: COMPLETE Column stats: NONE
-                    tag: -1
-                    value expressions: _col2 (type: double)
-                    auto parallelism: true
+                    Reduce Output Operator
+                      key expressions: _col0 (type: string), _col1 (type: string)
+                      null sort order: aa
+                      sort order: ++
+                      Map-reduce partition columns: _col0 (type: string)
+                      Statistics: Num rows: 13 Data size: 8021 Basic stats: COMPLETE Column stats: NONE
+                      tag: -1
+                      value expressions: _col2 (type: double)
+                      auto parallelism: true
         Reducer 3 
             Execution mode: llap
             Needs Tagging: false
@@ -4382,7 +4386,7 @@ STAGE PLANS:
                               window frame: PRECEDING(2)~CURRENT
                   Statistics: Num rows: 13 Data size: 8021 Basic stats: COMPLETE Column stats: NONE
                   Select Operator
-                    expressions: _col0 (type: string), _col1 (type: string), _col2 (type: double), sum_window_0 (type: double)
+                    expressions: _col0 (type: string), _col1 (type: string), _col2 (type: double), round(sum_window_0, 2) (type: double)
                     outputColumnNames: _col0, _col1, _col2, _col3
                     Statistics: Num rows: 13 Data size: 8021 Basic stats: COMPLETE Column stats: NONE
                     File Output Operator
@@ -4415,7 +4419,7 @@ STAGE PLANS:
         ListSink
 
 PREHOOK: query: select p_mfgr, p_brand, s, 
-sum(s) over w1  as s1
+round(sum(s) over w1,2) as s1
 from noop(on mfgr_price_view 
 partition by p_mfgr 
 order by p_mfgr)  
@@ -4425,7 +4429,7 @@ PREHOOK: Input: default@mfgr_price_view
 PREHOOK: Input: default@part_orc
 #### A masked pattern was here ####
 POSTHOOK: query: select p_mfgr, p_brand, s, 
-sum(s) over w1  as s1
+round(sum(s) over w1,2) as s1
 from noop(on mfgr_price_view 
 partition by p_mfgr 
 order by p_mfgr)  
@@ -4438,15 +4442,15 @@ Manufacturer#1	Brand#12	4800.84	4800.84
 Manufacturer#1	Brand#14	2346.3	7147.14
 Manufacturer#1	Brand#15	1602.59	8749.73
 Manufacturer#2	Brand#22	3491.38	3491.38
-Manufacturer#2	Brand#23	2031.98	5523.360000000001
+Manufacturer#2	Brand#23	2031.98	5523.36
 Manufacturer#2	Brand#24	1698.66	7222.02
-Manufacturer#2	Brand#25	1701.6	5432.240000000001
+Manufacturer#2	Brand#25	1701.6	5432.24
 Manufacturer#3	Brand#31	1671.68	1671.68
 Manufacturer#3	Brand#32	3333.37	5005.05
 Manufacturer#3	Brand#34	1337.29	6342.34
 Manufacturer#3	Brand#35	1190.27	5860.93
-Manufacturer#4	Brand#41	4755.9400000000005	4755.9400000000005
-Manufacturer#4	Brand#42	2581.6800000000003	7337.620000000001
+Manufacturer#4	Brand#41	4755.94	4755.94
+Manufacturer#4	Brand#42	2581.68	7337.62
 Manufacturer#5	Brand#51	1611.66	1611.66
 Manufacturer#5	Brand#52	3254.17	4865.83
 Manufacturer#5	Brand#53	2806.83	7672.66
@@ -4503,7 +4507,7 @@ order by p_name)
 INSERT OVERWRITE TABLE part_4 select p_mfgr, p_name, p_size, 
 rank() over (distribute by p_mfgr sort by p_name) as r, 
 dense_rank() over (distribute by p_mfgr sort by p_name) as dr, 
-sum(p_retailprice) over (distribute by p_mfgr sort by p_name rows between unbounded preceding and current row)  as s  
+round(sum(p_retailprice) over (distribute by p_mfgr sort by p_name rows between unbounded preceding and current row),2) as s
 INSERT OVERWRITE TABLE part_5 select  p_mfgr,p_name, p_size,  
 round(sum(p_size) over (distribute by p_mfgr sort by p_size range between 5 preceding and current row),1) as s2,
 rank() over (distribute by p_mfgr sort by p_mfgr, p_name) as r, 
@@ -4519,7 +4523,7 @@ order by p_name)
 INSERT OVERWRITE TABLE part_4 select p_mfgr, p_name, p_size, 
 rank() over (distribute by p_mfgr sort by p_name) as r, 
 dense_rank() over (distribute by p_mfgr sort by p_name) as dr, 
-sum(p_retailprice) over (distribute by p_mfgr sort by p_name rows between unbounded preceding and current row)  as s  
+round(sum(p_retailprice) over (distribute by p_mfgr sort by p_name rows between unbounded preceding and current row),2) as s
 INSERT OVERWRITE TABLE part_5 select  p_mfgr,p_name, p_size,  
 round(sum(p_size) over (distribute by p_mfgr sort by p_size range between 5 preceding and current row),1) as s2,
 rank() over (distribute by p_mfgr sort by p_mfgr, p_name) as r, 
@@ -4696,7 +4700,7 @@ STAGE PLANS:
                               window frame: PRECEDING(MAX)~CURRENT
                   Statistics: Num rows: 26 Data size: 16042 Basic stats: COMPLETE Column stats: NONE
                   Select Operator
-                    expressions: _col2 (type: string), _col1 (type: string), _col5 (type: int), rank_window_0 (type: int), dense_rank_window_1 (type: int), sum_window_2 (type: double)
+                    expressions: _col2 (type: string), _col1 (type: string), _col5 (type: int), rank_window_0 (type: int), dense_rank_window_1 (type: int), round(sum_window_2, 2) (type: double)
                     outputColumnNames: _col0, _col1, _col2, _col3, _col4, _col5
                     Statistics: Num rows: 26 Data size: 16042 Basic stats: COMPLETE Column stats: NONE
                     File Output Operator
@@ -4927,7 +4931,7 @@ order by p_name)
 INSERT OVERWRITE TABLE part_4 select p_mfgr, p_name, p_size, 
 rank() over (distribute by p_mfgr sort by p_name) as r, 
 dense_rank() over (distribute by p_mfgr sort by p_name) as dr, 
-sum(p_retailprice) over (distribute by p_mfgr sort by p_name rows between unbounded preceding and current row)  as s  
+round(sum(p_retailprice) over (distribute by p_mfgr sort by p_name rows between unbounded preceding and current row),2) as s
 INSERT OVERWRITE TABLE part_5 select  p_mfgr,p_name, p_size,  
 round(sum(p_size) over (distribute by p_mfgr sort by p_size range between 5 preceding and current row),1) as s2,
 rank() over (distribute by p_mfgr sort by p_mfgr, p_name) as r, 
@@ -4945,7 +4949,7 @@ order by p_name)
 INSERT OVERWRITE TABLE part_4 select p_mfgr, p_name, p_size, 
 rank() over (distribute by p_mfgr sort by p_name) as r, 
 dense_rank() over (distribute by p_mfgr sort by p_name) as dr, 
-sum(p_retailprice) over (distribute by p_mfgr sort by p_name rows between unbounded preceding and current row)  as s  
+round(sum(p_retailprice) over (distribute by p_mfgr sort by p_name rows between unbounded preceding and current row),2) as s
 INSERT OVERWRITE TABLE part_5 select  p_mfgr,p_name, p_size,  
 round(sum(p_size) over (distribute by p_mfgr sort by p_size range between 5 preceding and current row),1) as s2,
 rank() over (distribute by p_mfgr sort by p_mfgr, p_name) as r, 
@@ -4982,12 +4986,12 @@ POSTHOOK: Input: default@part_4
 Manufacturer#1	almond antique burnished rose metallic	2	1	1	1173.15
 Manufacturer#1	almond antique burnished rose metallic	2	1	1	2346.3
 Manufacturer#1	almond antique chartreuse lavender yellow	34	3	2	4100.06
-Manufacturer#1	almond antique salmon chartreuse burlywood	6	4	3	5702.650000000001
-Manufacturer#1	almond aquamarine burnished black steel	28	5	4	7117.070000000001
-Manufacturer#1	almond aquamarine pink moccasin thistle	42	6	5	8749.730000000001
+Manufacturer#1	almond antique salmon chartreuse burlywood	6	4	3	5702.65
+Manufacturer#1	almond aquamarine burnished black steel	28	5	4	7117.07
+Manufacturer#1	almond aquamarine pink moccasin thistle	42	6	5	8749.73
 Manufacturer#2	almond antique violet chocolate turquoise	14	1	1	1690.68
 Manufacturer#2	almond antique violet turquoise frosted	40	2	2	3491.38
-Manufacturer#2	almond aquamarine midnight light salmon	2	3	3	5523.360000000001
+Manufacturer#2	almond aquamarine midnight light salmon	2	3	3	5523.36
 Manufacturer#2	almond aquamarine rose maroon antique	25	4	4	7222.02
 Manufacturer#2	almond aquamarine sandy cyan gainsboro	18	5	5	8923.62
 Manufacturer#3	almond antique chartreuse khaki white	17	1	1	1671.68
@@ -4999,9 +5003,9 @@ Manufacturer#4	almond antique gainsboro frosted violet	10	1	1	1620.67
 Manufacturer#4	almond antique violet mint lemon	39	2	2	2996.09
 Manufacturer#4	almond aquamarine floral ivory bisque	27	3	3	4202.35
 Manufacturer#4	almond aquamarine yellow dodger mint	7	4	4	6047.27
-Manufacturer#4	almond azure aquamarine papaya violet	12	5	5	7337.620000000001
+Manufacturer#4	almond azure aquamarine papaya violet	12	5	5	7337.62
 Manufacturer#5	almond antique blue firebrick mint	31	1	1	1789.69
-Manufacturer#5	almond antique medium spring khaki	6	2	2	3401.3500000000004
+Manufacturer#5	almond antique medium spring khaki	6	2	2	3401.35
 Manufacturer#5	almond antique sky peru orange	2	3	3	5190.08
 Manufacturer#5	almond aquamarine dodger light gainsboro	46	4	4	6208.18
 Manufacturer#5	almond azure blanched chiffon midnight	23	5	5	7672.66


[10/13] hive git commit: HIVE-15520: Improve the sum performance for Range based window (Aihua Xu, reviewed by Yongzhi Chen)

Posted by ai...@apache.org.
http://git-wip-us.apache.org/repos/asf/hive/blob/a28b28f3/ql/src/test/results/clientpositive/llap/cbo_rp_windowing_2.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/llap/cbo_rp_windowing_2.q.out b/ql/src/test/results/clientpositive/llap/cbo_rp_windowing_2.q.out
index 3434336..db68276 100644
--- a/ql/src/test/results/clientpositive/llap/cbo_rp_windowing_2.q.out
+++ b/ql/src/test/results/clientpositive/llap/cbo_rp_windowing_2.q.out
@@ -4,7 +4,7 @@ PREHOOK: query: -- SORT_QUERY_RESULTS
 select p_mfgr, p_name, p_size,
 rank() over(distribute by p_mfgr sort by p_name) as r,
 dense_rank() over(distribute by p_mfgr sort by p_name) as dr,
-sum(p_retailprice) over (distribute by p_mfgr sort by p_name rows between unbounded preceding and current row) as s1
+round(sum(p_retailprice) over (distribute by p_mfgr sort by p_name rows between unbounded preceding and current row),2) as s1
 from part
 PREHOOK: type: QUERY
 PREHOOK: Input: default@part
@@ -15,7 +15,7 @@ POSTHOOK: query: -- SORT_QUERY_RESULTS
 select p_mfgr, p_name, p_size,
 rank() over(distribute by p_mfgr sort by p_name) as r,
 dense_rank() over(distribute by p_mfgr sort by p_name) as dr,
-sum(p_retailprice) over (distribute by p_mfgr sort by p_name rows between unbounded preceding and current row) as s1
+round(sum(p_retailprice) over (distribute by p_mfgr sort by p_name rows between unbounded preceding and current row),2) as s1
 from part
 POSTHOOK: type: QUERY
 POSTHOOK: Input: default@part
@@ -23,12 +23,12 @@ POSTHOOK: Input: default@part
 Manufacturer#1	almond antique burnished rose metallic	2	1	1	1173.15
 Manufacturer#1	almond antique burnished rose metallic	2	1	1	2346.3
 Manufacturer#1	almond antique chartreuse lavender yellow	34	3	2	4100.06
-Manufacturer#1	almond antique salmon chartreuse burlywood	6	4	3	5702.650000000001
-Manufacturer#1	almond aquamarine burnished black steel	28	5	4	7117.070000000001
-Manufacturer#1	almond aquamarine pink moccasin thistle	42	6	5	8749.730000000001
+Manufacturer#1	almond antique salmon chartreuse burlywood	6	4	3	5702.65
+Manufacturer#1	almond aquamarine burnished black steel	28	5	4	7117.07
+Manufacturer#1	almond aquamarine pink moccasin thistle	42	6	5	8749.73
 Manufacturer#2	almond antique violet chocolate turquoise	14	1	1	1690.68
 Manufacturer#2	almond antique violet turquoise frosted	40	2	2	3491.38
-Manufacturer#2	almond aquamarine midnight light salmon	2	3	3	5523.360000000001
+Manufacturer#2	almond aquamarine midnight light salmon	2	3	3	5523.36
 Manufacturer#2	almond aquamarine rose maroon antique	25	4	4	7222.02
 Manufacturer#2	almond aquamarine sandy cyan gainsboro	18	5	5	8923.62
 Manufacturer#3	almond antique chartreuse khaki white	17	1	1	1671.68
@@ -40,9 +40,9 @@ Manufacturer#4	almond antique gainsboro frosted violet	10	1	1	1620.67
 Manufacturer#4	almond antique violet mint lemon	39	2	2	2996.09
 Manufacturer#4	almond aquamarine floral ivory bisque	27	3	3	4202.35
 Manufacturer#4	almond aquamarine yellow dodger mint	7	4	4	6047.27
-Manufacturer#4	almond azure aquamarine papaya violet	12	5	5	7337.620000000001
+Manufacturer#4	almond azure aquamarine papaya violet	12	5	5	7337.62
 Manufacturer#5	almond antique blue firebrick mint	31	1	1	1789.69
-Manufacturer#5	almond antique medium spring khaki	6	2	2	3401.3500000000004
+Manufacturer#5	almond antique medium spring khaki	6	2	2	3401.35
 Manufacturer#5	almond antique sky peru orange	2	3	3	5190.08
 Manufacturer#5	almond aquamarine dodger light gainsboro	46	4	4	6208.18
 Manufacturer#5	almond azure blanched chiffon midnight	23	5	5	7672.66
@@ -185,7 +185,7 @@ select p_mfgr, p_name,
 rank() over(distribute by p_mfgr sort by p_name) as r, 
 dense_rank() over(distribute by p_mfgr sort by p_name) as dr, 
 count(p_size) over(distribute by p_mfgr sort by p_name) as cd, 
-p_retailprice, sum(p_retailprice) over (distribute by p_mfgr sort by p_name rows between unbounded preceding and current row) as s1, 
+p_retailprice, round(sum(p_retailprice) over (distribute by p_mfgr sort by p_name rows between unbounded preceding and current row),2) as s1, 
 p_size, p_size - lag(p_size,1,p_size) over(distribute by p_mfgr sort by p_name) as deltaSz 
 from part
 PREHOOK: type: QUERY
@@ -196,7 +196,7 @@ select p_mfgr, p_name,
 rank() over(distribute by p_mfgr sort by p_name) as r, 
 dense_rank() over(distribute by p_mfgr sort by p_name) as dr, 
 count(p_size) over(distribute by p_mfgr sort by p_name) as cd, 
-p_retailprice, sum(p_retailprice) over (distribute by p_mfgr sort by p_name rows between unbounded preceding and current row) as s1, 
+p_retailprice, round(sum(p_retailprice) over (distribute by p_mfgr sort by p_name rows between unbounded preceding and current row),2) as s1, 
 p_size, p_size - lag(p_size,1,p_size) over(distribute by p_mfgr sort by p_name) as deltaSz 
 from part
 POSTHOOK: type: QUERY
@@ -205,12 +205,12 @@ POSTHOOK: Input: default@part
 Manufacturer#1	almond antique burnished rose metallic	1	1	2	1173.15	1173.15	2	0
 Manufacturer#1	almond antique burnished rose metallic	1	1	2	1173.15	2346.3	2	0
 Manufacturer#1	almond antique chartreuse lavender yellow	3	2	3	1753.76	4100.06	34	32
-Manufacturer#1	almond antique salmon chartreuse burlywood	4	3	4	1602.59	5702.650000000001	6	-28
-Manufacturer#1	almond aquamarine burnished black steel	5	4	5	1414.42	7117.070000000001	28	22
-Manufacturer#1	almond aquamarine pink moccasin thistle	6	5	6	1632.66	8749.730000000001	42	14
+Manufacturer#1	almond antique salmon chartreuse burlywood	4	3	4	1602.59	5702.65	6	-28
+Manufacturer#1	almond aquamarine burnished black steel	5	4	5	1414.42	7117.07	28	22
+Manufacturer#1	almond aquamarine pink moccasin thistle	6	5	6	1632.66	8749.73	42	14
 Manufacturer#2	almond antique violet chocolate turquoise	1	1	1	1690.68	1690.68	14	0
 Manufacturer#2	almond antique violet turquoise frosted	2	2	2	1800.7	3491.38	40	26
-Manufacturer#2	almond aquamarine midnight light salmon	3	3	3	2031.98	5523.360000000001	2	-38
+Manufacturer#2	almond aquamarine midnight light salmon	3	3	3	2031.98	5523.36	2	-38
 Manufacturer#2	almond aquamarine rose maroon antique	4	4	4	1698.66	7222.02	25	23
 Manufacturer#2	almond aquamarine sandy cyan gainsboro	5	5	5	1701.6	8923.62	18	-7
 Manufacturer#3	almond antique chartreuse khaki white	1	1	1	1671.68	1671.68	17	0
@@ -222,9 +222,9 @@ Manufacturer#4	almond antique gainsboro frosted violet	1	1	1	1620.67	1620.67	10
 Manufacturer#4	almond antique violet mint lemon	2	2	2	1375.42	2996.09	39	29
 Manufacturer#4	almond aquamarine floral ivory bisque	3	3	3	1206.26	4202.35	27	-12
 Manufacturer#4	almond aquamarine yellow dodger mint	4	4	4	1844.92	6047.27	7	-20
-Manufacturer#4	almond azure aquamarine papaya violet	5	5	5	1290.35	7337.620000000001	12	5
+Manufacturer#4	almond azure aquamarine papaya violet	5	5	5	1290.35	7337.62	12	5
 Manufacturer#5	almond antique blue firebrick mint	1	1	1	1789.69	1789.69	31	0
-Manufacturer#5	almond antique medium spring khaki	2	2	2	1611.66	3401.3500000000004	6	-25
+Manufacturer#5	almond antique medium spring khaki	2	2	2	1611.66	3401.35	6	-25
 Manufacturer#5	almond antique sky peru orange	3	3	3	1788.73	5190.08	2	-4
 Manufacturer#5	almond aquamarine dodger light gainsboro	4	4	4	1018.1	6208.18	46	44
 Manufacturer#5	almond azure blanched chiffon midnight	5	5	5	1464.48	7672.66	23	-23
@@ -234,7 +234,7 @@ from (select p_mfgr, p_name,
 rank() over(distribute by p_mfgr sort by p_name) as r, 
 dense_rank() over(distribute by p_mfgr sort by p_name) as dr, 
 count(p_size) over(distribute by p_mfgr sort by p_name) as cd, 
-p_retailprice, sum(p_retailprice) over (distribute by p_mfgr sort by p_name rows between unbounded preceding and current row) as s1, 
+p_retailprice, round(sum(p_retailprice) over (distribute by p_mfgr sort by p_name rows between unbounded preceding and current row),2) as s1, 
 p_size, p_size - lag(p_size,1,p_size) over(distribute by p_mfgr sort by p_name) as deltaSz 
 from part 
 ) sub1
@@ -247,7 +247,7 @@ from (select p_mfgr, p_name,
 rank() over(distribute by p_mfgr sort by p_name) as r, 
 dense_rank() over(distribute by p_mfgr sort by p_name) as dr, 
 count(p_size) over(distribute by p_mfgr sort by p_name) as cd, 
-p_retailprice, sum(p_retailprice) over (distribute by p_mfgr sort by p_name rows between unbounded preceding and current row) as s1, 
+p_retailprice, round(sum(p_retailprice) over (distribute by p_mfgr sort by p_name rows between unbounded preceding and current row),2) as s1, 
 p_size, p_size - lag(p_size,1,p_size) over(distribute by p_mfgr sort by p_name) as deltaSz 
 from part 
 ) sub1
@@ -262,29 +262,29 @@ POSTHOOK: Input: default@part
 1	1	2	2346.3	0
 2	2	2	2861.95	-3
 2	2	2	2996.09	29
-2	2	2	3401.3500000000004	-25
+2	2	2	3401.35	-25
 2	2	2	3491.38	26
 3	2	3	4100.06	32
 3	3	3	4202.35	-12
 3	3	3	4272.34	5
 3	3	3	5190.08	-4
-3	3	3	5523.360000000001	-38
-4	3	4	5702.650000000001	-28
+3	3	3	5523.36	-38
+4	3	4	5702.65	-28
 4	4	4	6047.27	-20
 4	4	4	6195.32	-18
 4	4	4	6208.18	44
 4	4	4	7222.02	23
-5	4	5	7117.070000000001	22
-5	5	5	7337.620000000001	5
+5	4	5	7117.07	22
+5	5	5	7337.62	5
 5	5	5	7532.61	44
 5	5	5	7672.66	-23
 5	5	5	8923.62	-7
-6	5	6	8749.730000000001	14
+6	5	6	8749.73	14
 PREHOOK: query: -- 7. testJoinWithWindowingAndPTF
 select abc.p_mfgr, abc.p_name, 
 rank() over(distribute by abc.p_mfgr sort by abc.p_name) as r, 
 dense_rank() over(distribute by abc.p_mfgr sort by abc.p_name) as dr, 
-abc.p_retailprice, sum(abc.p_retailprice) over (distribute by abc.p_mfgr sort by abc.p_name rows between unbounded preceding and current row) as s1, 
+abc.p_retailprice, round(sum(abc.p_retailprice) over (distribute by abc.p_mfgr sort by abc.p_name rows between unbounded preceding and current row),2) as s1, 
 abc.p_size, abc.p_size - lag(abc.p_size,1,abc.p_size) over(distribute by abc.p_mfgr sort by abc.p_name) as deltaSz 
 from noop(on part 
 partition by p_mfgr 
@@ -297,7 +297,7 @@ POSTHOOK: query: -- 7. testJoinWithWindowingAndPTF
 select abc.p_mfgr, abc.p_name, 
 rank() over(distribute by abc.p_mfgr sort by abc.p_name) as r, 
 dense_rank() over(distribute by abc.p_mfgr sort by abc.p_name) as dr, 
-abc.p_retailprice, sum(abc.p_retailprice) over (distribute by abc.p_mfgr sort by abc.p_name rows between unbounded preceding and current row) as s1, 
+abc.p_retailprice, round(sum(abc.p_retailprice) over (distribute by abc.p_mfgr sort by abc.p_name rows between unbounded preceding and current row),2) as s1, 
 abc.p_size, abc.p_size - lag(abc.p_size,1,abc.p_size) over(distribute by abc.p_mfgr sort by abc.p_name) as deltaSz 
 from noop(on part 
 partition by p_mfgr 
@@ -308,15 +308,15 @@ POSTHOOK: Input: default@part
 #### A masked pattern was here ####
 Manufacturer#1	almond antique burnished rose metallic	1	1	1173.15	1173.15	2	0
 Manufacturer#1	almond antique burnished rose metallic	1	1	1173.15	2346.3	2	0
-Manufacturer#1	almond antique burnished rose metallic	1	1	1173.15	3519.4500000000003	2	0
+Manufacturer#1	almond antique burnished rose metallic	1	1	1173.15	3519.45	2	0
 Manufacturer#1	almond antique burnished rose metallic	1	1	1173.15	4692.6	2	0
-Manufacturer#1	almond antique chartreuse lavender yellow	5	2	1753.76	6446.360000000001	34	32
-Manufacturer#1	almond antique salmon chartreuse burlywood	6	3	1602.59	8048.950000000001	6	-28
+Manufacturer#1	almond antique chartreuse lavender yellow	5	2	1753.76	6446.36	34	32
+Manufacturer#1	almond antique salmon chartreuse burlywood	6	3	1602.59	8048.95	6	-28
 Manufacturer#1	almond aquamarine burnished black steel	7	4	1414.42	9463.37	28	22
 Manufacturer#1	almond aquamarine pink moccasin thistle	8	5	1632.66	11096.03	42	14
 Manufacturer#2	almond antique violet chocolate turquoise	1	1	1690.68	1690.68	14	0
 Manufacturer#2	almond antique violet turquoise frosted	2	2	1800.7	3491.38	40	26
-Manufacturer#2	almond aquamarine midnight light salmon	3	3	2031.98	5523.360000000001	2	-38
+Manufacturer#2	almond aquamarine midnight light salmon	3	3	2031.98	5523.36	2	-38
 Manufacturer#2	almond aquamarine rose maroon antique	4	4	1698.66	7222.02	25	23
 Manufacturer#2	almond aquamarine sandy cyan gainsboro	5	5	1701.6	8923.62	18	-7
 Manufacturer#3	almond antique chartreuse khaki white	1	1	1671.68	1671.68	17	0
@@ -328,9 +328,9 @@ Manufacturer#4	almond antique gainsboro frosted violet	1	1	1620.67	1620.67	10	0
 Manufacturer#4	almond antique violet mint lemon	2	2	1375.42	2996.09	39	29
 Manufacturer#4	almond aquamarine floral ivory bisque	3	3	1206.26	4202.35	27	-12
 Manufacturer#4	almond aquamarine yellow dodger mint	4	4	1844.92	6047.27	7	-20
-Manufacturer#4	almond azure aquamarine papaya violet	5	5	1290.35	7337.620000000001	12	5
+Manufacturer#4	almond azure aquamarine papaya violet	5	5	1290.35	7337.62	12	5
 Manufacturer#5	almond antique blue firebrick mint	1	1	1789.69	1789.69	31	0
-Manufacturer#5	almond antique medium spring khaki	2	2	1611.66	3401.3500000000004	6	-25
+Manufacturer#5	almond antique medium spring khaki	2	2	1611.66	3401.35	6	-25
 Manufacturer#5	almond antique sky peru orange	3	3	1788.73	5190.08	2	-4
 Manufacturer#5	almond aquamarine dodger light gainsboro	4	4	1018.1	6208.18	46	44
 Manufacturer#5	almond azure blanched chiffon midnight	5	5	1464.48	7672.66	23	-23
@@ -378,7 +378,7 @@ PREHOOK: query: -- 9. testHavingWithWindowingNoGBY
 select p_mfgr, p_name, p_size, 
 rank() over(distribute by p_mfgr sort by p_name) as r, 
 dense_rank() over(distribute by p_mfgr sort by p_name) as dr, 
-sum(p_retailprice) over (distribute by p_mfgr sort by p_name rows between unbounded preceding and current row)  as s1
+round(sum(p_retailprice) over (distribute by p_mfgr sort by p_name rows between unbounded preceding and current row),2) as s1
 from part
 PREHOOK: type: QUERY
 PREHOOK: Input: default@part
@@ -387,7 +387,7 @@ POSTHOOK: query: -- 9. testHavingWithWindowingNoGBY
 select p_mfgr, p_name, p_size, 
 rank() over(distribute by p_mfgr sort by p_name) as r, 
 dense_rank() over(distribute by p_mfgr sort by p_name) as dr, 
-sum(p_retailprice) over (distribute by p_mfgr sort by p_name rows between unbounded preceding and current row)  as s1
+round(sum(p_retailprice) over (distribute by p_mfgr sort by p_name rows between unbounded preceding and current row),2) as s1
 from part
 POSTHOOK: type: QUERY
 POSTHOOK: Input: default@part
@@ -395,12 +395,12 @@ POSTHOOK: Input: default@part
 Manufacturer#1	almond antique burnished rose metallic	2	1	1	1173.15
 Manufacturer#1	almond antique burnished rose metallic	2	1	1	2346.3
 Manufacturer#1	almond antique chartreuse lavender yellow	34	3	2	4100.06
-Manufacturer#1	almond antique salmon chartreuse burlywood	6	4	3	5702.650000000001
-Manufacturer#1	almond aquamarine burnished black steel	28	5	4	7117.070000000001
-Manufacturer#1	almond aquamarine pink moccasin thistle	42	6	5	8749.730000000001
+Manufacturer#1	almond antique salmon chartreuse burlywood	6	4	3	5702.65
+Manufacturer#1	almond aquamarine burnished black steel	28	5	4	7117.07
+Manufacturer#1	almond aquamarine pink moccasin thistle	42	6	5	8749.73
 Manufacturer#2	almond antique violet chocolate turquoise	14	1	1	1690.68
 Manufacturer#2	almond antique violet turquoise frosted	40	2	2	3491.38
-Manufacturer#2	almond aquamarine midnight light salmon	2	3	3	5523.360000000001
+Manufacturer#2	almond aquamarine midnight light salmon	2	3	3	5523.36
 Manufacturer#2	almond aquamarine rose maroon antique	25	4	4	7222.02
 Manufacturer#2	almond aquamarine sandy cyan gainsboro	18	5	5	8923.62
 Manufacturer#3	almond antique chartreuse khaki white	17	1	1	1671.68
@@ -412,9 +412,9 @@ Manufacturer#4	almond antique gainsboro frosted violet	10	1	1	1620.67
 Manufacturer#4	almond antique violet mint lemon	39	2	2	2996.09
 Manufacturer#4	almond aquamarine floral ivory bisque	27	3	3	4202.35
 Manufacturer#4	almond aquamarine yellow dodger mint	7	4	4	6047.27
-Manufacturer#4	almond azure aquamarine papaya violet	12	5	5	7337.620000000001
+Manufacturer#4	almond azure aquamarine papaya violet	12	5	5	7337.62
 Manufacturer#5	almond antique blue firebrick mint	31	1	1	1789.69
-Manufacturer#5	almond antique medium spring khaki	6	2	2	3401.3500000000004
+Manufacturer#5	almond antique medium spring khaki	6	2	2	3401.35
 Manufacturer#5	almond antique sky peru orange	2	3	3	5190.08
 Manufacturer#5	almond aquamarine dodger light gainsboro	46	4	4	6208.18
 Manufacturer#5	almond azure blanched chiffon midnight	23	5	5	7672.66
@@ -422,7 +422,7 @@ PREHOOK: query: -- 10. testHavingWithWindowingCondRankNoGBY
 select p_mfgr, p_name, p_size, 
 rank() over(distribute by p_mfgr sort by p_name) as r, 
 dense_rank() over(distribute by p_mfgr sort by p_name) as dr, 
-sum(p_retailprice) over (distribute by p_mfgr sort by p_name rows between unbounded preceding and current row) as s1 
+round(sum(p_retailprice) over (distribute by p_mfgr sort by p_name rows between unbounded preceding and current row),2) as s1 
 from part
 PREHOOK: type: QUERY
 PREHOOK: Input: default@part
@@ -431,7 +431,7 @@ POSTHOOK: query: -- 10. testHavingWithWindowingCondRankNoGBY
 select p_mfgr, p_name, p_size, 
 rank() over(distribute by p_mfgr sort by p_name) as r, 
 dense_rank() over(distribute by p_mfgr sort by p_name) as dr, 
-sum(p_retailprice) over (distribute by p_mfgr sort by p_name rows between unbounded preceding and current row) as s1 
+round(sum(p_retailprice) over (distribute by p_mfgr sort by p_name rows between unbounded preceding and current row),2) as s1 
 from part
 POSTHOOK: type: QUERY
 POSTHOOK: Input: default@part
@@ -439,12 +439,12 @@ POSTHOOK: Input: default@part
 Manufacturer#1	almond antique burnished rose metallic	2	1	1	1173.15
 Manufacturer#1	almond antique burnished rose metallic	2	1	1	2346.3
 Manufacturer#1	almond antique chartreuse lavender yellow	34	3	2	4100.06
-Manufacturer#1	almond antique salmon chartreuse burlywood	6	4	3	5702.650000000001
-Manufacturer#1	almond aquamarine burnished black steel	28	5	4	7117.070000000001
-Manufacturer#1	almond aquamarine pink moccasin thistle	42	6	5	8749.730000000001
+Manufacturer#1	almond antique salmon chartreuse burlywood	6	4	3	5702.65
+Manufacturer#1	almond aquamarine burnished black steel	28	5	4	7117.07
+Manufacturer#1	almond aquamarine pink moccasin thistle	42	6	5	8749.73
 Manufacturer#2	almond antique violet chocolate turquoise	14	1	1	1690.68
 Manufacturer#2	almond antique violet turquoise frosted	40	2	2	3491.38
-Manufacturer#2	almond aquamarine midnight light salmon	2	3	3	5523.360000000001
+Manufacturer#2	almond aquamarine midnight light salmon	2	3	3	5523.36
 Manufacturer#2	almond aquamarine rose maroon antique	25	4	4	7222.02
 Manufacturer#2	almond aquamarine sandy cyan gainsboro	18	5	5	8923.62
 Manufacturer#3	almond antique chartreuse khaki white	17	1	1	1671.68
@@ -456,9 +456,9 @@ Manufacturer#4	almond antique gainsboro frosted violet	10	1	1	1620.67
 Manufacturer#4	almond antique violet mint lemon	39	2	2	2996.09
 Manufacturer#4	almond aquamarine floral ivory bisque	27	3	3	4202.35
 Manufacturer#4	almond aquamarine yellow dodger mint	7	4	4	6047.27
-Manufacturer#4	almond azure aquamarine papaya violet	12	5	5	7337.620000000001
+Manufacturer#4	almond azure aquamarine papaya violet	12	5	5	7337.62
 Manufacturer#5	almond antique blue firebrick mint	31	1	1	1789.69
-Manufacturer#5	almond antique medium spring khaki	6	2	2	3401.3500000000004
+Manufacturer#5	almond antique medium spring khaki	6	2	2	3401.35
 Manufacturer#5	almond antique sky peru orange	2	3	3	5190.08
 Manufacturer#5	almond aquamarine dodger light gainsboro	46	4	4	6208.18
 Manufacturer#5	almond azure blanched chiffon midnight	23	5	5	7672.66
@@ -785,10 +785,10 @@ Manufacturer#5	almond aquamarine dodger light gainsboro	46	4	4	6
 Manufacturer#5	almond azure blanched chiffon midnight	23	5	5	2
 PREHOOK: query: -- 18. testUDAFs
 select  p_mfgr,p_name, p_size, 
-sum(p_retailprice) over w1 as s, 
+round(sum(p_retailprice) over w1,2) as s,
 min(p_retailprice) over w1 as mi,
 max(p_retailprice) over w1 as ma,
-avg(p_retailprice) over w1 as ag
+round(avg(p_retailprice) over w1,2) as ag
 from part
 window w1 as (distribute by p_mfgr sort by p_mfgr, p_name rows between 2 preceding and 2 following)
 PREHOOK: type: QUERY
@@ -796,47 +796,47 @@ PREHOOK: Input: default@part
 #### A masked pattern was here ####
 POSTHOOK: query: -- 18. testUDAFs
 select  p_mfgr,p_name, p_size, 
-sum(p_retailprice) over w1 as s, 
+round(sum(p_retailprice) over w1,2) as s,
 min(p_retailprice) over w1 as mi,
 max(p_retailprice) over w1 as ma,
-avg(p_retailprice) over w1 as ag
+round(avg(p_retailprice) over w1,2) as ag
 from part
 window w1 as (distribute by p_mfgr sort by p_mfgr, p_name rows between 2 preceding and 2 following)
 POSTHOOK: type: QUERY
 POSTHOOK: Input: default@part
 #### A masked pattern was here ####
-Manufacturer#1	almond antique burnished rose metallic	2	4100.06	1173.15	1753.76	1366.6866666666667
-Manufacturer#1	almond antique burnished rose metallic	2	5702.650000000001	1173.15	1753.76	1425.6625000000001
-Manufacturer#1	almond antique chartreuse lavender yellow	34	7117.070000000001	1173.15	1753.76	1423.4140000000002
-Manufacturer#1	almond antique salmon chartreuse burlywood	6	7576.580000000002	1173.15	1753.76	1515.3160000000003
-Manufacturer#1	almond aquamarine burnished black steel	28	6403.430000000001	1414.42	1753.76	1600.8575000000003
-Manufacturer#1	almond aquamarine pink moccasin thistle	42	4649.670000000001	1414.42	1632.66	1549.8900000000003
-Manufacturer#2	almond antique violet chocolate turquoise	14	5523.360000000001	1690.68	2031.98	1841.1200000000001
-Manufacturer#2	almond antique violet turquoise frosted	40	7222.02	1690.68	2031.98	1805.505
-Manufacturer#2	almond aquamarine midnight light salmon	2	8923.62	1690.68	2031.98	1784.7240000000002
-Manufacturer#2	almond aquamarine rose maroon antique	25	7232.9400000000005	1698.66	2031.98	1808.2350000000001
-Manufacturer#2	almond aquamarine sandy cyan gainsboro	18	5432.240000000001	1698.66	2031.98	1810.746666666667
-Manufacturer#3	almond antique chartreuse khaki white	17	4272.34	1190.27	1671.68	1424.1133333333335
+Manufacturer#1	almond antique burnished rose metallic	2	4100.06	1173.15	1753.76	1366.69
+Manufacturer#1	almond antique burnished rose metallic	2	5702.65	1173.15	1753.76	1425.66
+Manufacturer#1	almond antique chartreuse lavender yellow	34	7117.07	1173.15	1753.76	1423.41
+Manufacturer#1	almond antique salmon chartreuse burlywood	6	7576.58	1173.15	1753.76	1515.32
+Manufacturer#1	almond aquamarine burnished black steel	28	6403.43	1414.42	1753.76	1600.86
+Manufacturer#1	almond aquamarine pink moccasin thistle	42	4649.67	1414.42	1632.66	1549.89
+Manufacturer#2	almond antique violet chocolate turquoise	14	5523.36	1690.68	2031.98	1841.12
+Manufacturer#2	almond antique violet turquoise frosted	40	7222.02	1690.68	2031.98	1805.51
+Manufacturer#2	almond aquamarine midnight light salmon	2	8923.62	1690.68	2031.98	1784.72
+Manufacturer#2	almond aquamarine rose maroon antique	25	7232.94	1698.66	2031.98	1808.24
+Manufacturer#2	almond aquamarine sandy cyan gainsboro	18	5432.24	1698.66	2031.98	1810.75
+Manufacturer#3	almond antique chartreuse khaki white	17	4272.34	1190.27	1671.68	1424.11
 Manufacturer#3	almond antique forest lavender goldenrod	14	6195.32	1190.27	1922.98	1548.83
-Manufacturer#3	almond antique metallic orange dim	19	7532.61	1190.27	1922.98	1506.522
-Manufacturer#3	almond antique misty red olive	1	5860.929999999999	1190.27	1922.98	1465.2324999999998
-Manufacturer#3	almond antique olive coral navajo	45	4670.66	1337.29	1922.98	1556.8866666666665
-Manufacturer#4	almond antique gainsboro frosted violet	10	4202.35	1206.26	1620.67	1400.7833333333335
-Manufacturer#4	almond antique violet mint lemon	39	6047.27	1206.26	1844.92	1511.8175
-Manufacturer#4	almond aquamarine floral ivory bisque	27	7337.620000000001	1206.26	1844.92	1467.5240000000001
-Manufacturer#4	almond aquamarine yellow dodger mint	7	5716.950000000001	1206.26	1844.92	1429.2375000000002
-Manufacturer#4	almond azure aquamarine papaya violet	12	4341.530000000001	1206.26	1844.92	1447.176666666667
-Manufacturer#5	almond antique blue firebrick mint	31	5190.08	1611.66	1789.69	1730.0266666666666
-Manufacturer#5	almond antique medium spring khaki	6	6208.18	1018.1	1789.69	1552.045
-Manufacturer#5	almond antique sky peru orange	2	7672.66	1018.1	1789.69	1534.532
-Manufacturer#5	almond aquamarine dodger light gainsboro	46	5882.969999999999	1018.1	1788.73	1470.7424999999998
-Manufacturer#5	almond azure blanched chiffon midnight	23	4271.3099999999995	1018.1	1788.73	1423.7699999999998
+Manufacturer#3	almond antique metallic orange dim	19	7532.61	1190.27	1922.98	1506.52
+Manufacturer#3	almond antique misty red olive	1	5860.93	1190.27	1922.98	1465.23
+Manufacturer#3	almond antique olive coral navajo	45	4670.66	1337.29	1922.98	1556.89
+Manufacturer#4	almond antique gainsboro frosted violet	10	4202.35	1206.26	1620.67	1400.78
+Manufacturer#4	almond antique violet mint lemon	39	6047.27	1206.26	1844.92	1511.82
+Manufacturer#4	almond aquamarine floral ivory bisque	27	7337.62	1206.26	1844.92	1467.52
+Manufacturer#4	almond aquamarine yellow dodger mint	7	5716.95	1206.26	1844.92	1429.24
+Manufacturer#4	almond azure aquamarine papaya violet	12	4341.53	1206.26	1844.92	1447.18
+Manufacturer#5	almond antique blue firebrick mint	31	5190.08	1611.66	1789.69	1730.03
+Manufacturer#5	almond antique medium spring khaki	6	6208.18	1018.1	1789.69	1552.05
+Manufacturer#5	almond antique sky peru orange	2	7672.66	1018.1	1789.69	1534.53
+Manufacturer#5	almond aquamarine dodger light gainsboro	46	5882.97	1018.1	1788.73	1470.74
+Manufacturer#5	almond azure blanched chiffon midnight	23	4271.31	1018.1	1788.73	1423.77
 PREHOOK: query: -- 19. testUDAFsWithGBY
 select  p_mfgr,p_name, p_size, p_retailprice, 
-sum(p_retailprice) over w1 as s, 
+round(sum(p_retailprice) over w1,2) as s,
 min(p_retailprice) as mi ,
 max(p_retailprice) as ma ,
-avg(p_retailprice) over w1 as ag
+round(avg(p_retailprice) over w1,2) as ag
 from part
 group by p_mfgr,p_name, p_size, p_retailprice
 window w1 as (distribute by p_mfgr sort by p_mfgr, p_name rows between 2 preceding and 2 following)
@@ -845,41 +845,41 @@ PREHOOK: Input: default@part
 #### A masked pattern was here ####
 POSTHOOK: query: -- 19. testUDAFsWithGBY
 select  p_mfgr,p_name, p_size, p_retailprice, 
-sum(p_retailprice) over w1 as s, 
+round(sum(p_retailprice) over w1,2) as s,
 min(p_retailprice) as mi ,
 max(p_retailprice) as ma ,
-avg(p_retailprice) over w1 as ag
+round(avg(p_retailprice) over w1,2) as ag
 from part
 group by p_mfgr,p_name, p_size, p_retailprice
 window w1 as (distribute by p_mfgr sort by p_mfgr, p_name rows between 2 preceding and 2 following)
 POSTHOOK: type: QUERY
 POSTHOOK: Input: default@part
 #### A masked pattern was here ####
-Manufacturer#1	almond antique burnished rose metallic	2	1173.15	4529.5	1173.15	1173.15	1509.8333333333333
+Manufacturer#1	almond antique burnished rose metallic	2	1173.15	4529.5	1173.15	1173.15	1509.83
 Manufacturer#1	almond antique chartreuse lavender yellow	34	1753.76	5943.92	1753.76	1753.76	1485.98
-Manufacturer#1	almond antique salmon chartreuse burlywood	6	1602.59	7576.58	1602.59	1602.59	1515.316
-Manufacturer#1	almond aquamarine burnished black steel	28	1414.42	6403.43	1414.42	1414.42	1600.8575
+Manufacturer#1	almond antique salmon chartreuse burlywood	6	1602.59	7576.58	1602.59	1602.59	1515.32
+Manufacturer#1	almond aquamarine burnished black steel	28	1414.42	6403.43	1414.42	1414.42	1600.86
 Manufacturer#1	almond aquamarine pink moccasin thistle	42	1632.66	4649.67	1632.66	1632.66	1549.89
-Manufacturer#2	almond antique violet chocolate turquoise	14	1690.68	5523.360000000001	1690.68	1690.68	1841.1200000000001
-Manufacturer#2	almond antique violet turquoise frosted	40	1800.7	7222.02	1800.7	1800.7	1805.505
-Manufacturer#2	almond aquamarine midnight light salmon	2	2031.98	8923.62	2031.98	2031.98	1784.7240000000002
-Manufacturer#2	almond aquamarine rose maroon antique	25	1698.66	7232.9400000000005	1698.66	1698.66	1808.2350000000001
-Manufacturer#2	almond aquamarine sandy cyan gainsboro	18	1701.6	5432.240000000001	1701.6	1701.6	1810.746666666667
-Manufacturer#3	almond antique chartreuse khaki white	17	1671.68	4272.34	1671.68	1671.68	1424.1133333333335
+Manufacturer#2	almond antique violet chocolate turquoise	14	1690.68	5523.36	1690.68	1690.68	1841.12
+Manufacturer#2	almond antique violet turquoise frosted	40	1800.7	7222.02	1800.7	1800.7	1805.51
+Manufacturer#2	almond aquamarine midnight light salmon	2	2031.98	8923.62	2031.98	2031.98	1784.72
+Manufacturer#2	almond aquamarine rose maroon antique	25	1698.66	7232.94	1698.66	1698.66	1808.24
+Manufacturer#2	almond aquamarine sandy cyan gainsboro	18	1701.6	5432.24	1701.6	1701.6	1810.75
+Manufacturer#3	almond antique chartreuse khaki white	17	1671.68	4272.34	1671.68	1671.68	1424.11
 Manufacturer#3	almond antique forest lavender goldenrod	14	1190.27	6195.32	1190.27	1190.27	1548.83
-Manufacturer#3	almond antique metallic orange dim	19	1410.39	7532.61	1410.39	1410.39	1506.522
-Manufacturer#3	almond antique misty red olive	1	1922.98	5860.929999999999	1922.98	1922.98	1465.2324999999998
-Manufacturer#3	almond antique olive coral navajo	45	1337.29	4670.66	1337.29	1337.29	1556.8866666666665
-Manufacturer#4	almond antique gainsboro frosted violet	10	1620.67	4202.35	1620.67	1620.67	1400.7833333333335
-Manufacturer#4	almond antique violet mint lemon	39	1375.42	6047.27	1375.42	1375.42	1511.8175
-Manufacturer#4	almond aquamarine floral ivory bisque	27	1206.26	7337.620000000001	1206.26	1206.26	1467.5240000000001
-Manufacturer#4	almond aquamarine yellow dodger mint	7	1844.92	5716.950000000001	1844.92	1844.92	1429.2375000000002
-Manufacturer#4	almond azure aquamarine papaya violet	12	1290.35	4341.530000000001	1290.35	1290.35	1447.176666666667
-Manufacturer#5	almond antique blue firebrick mint	31	1789.69	5190.08	1789.69	1789.69	1730.0266666666666
-Manufacturer#5	almond antique medium spring khaki	6	1611.66	6208.18	1611.66	1611.66	1552.045
-Manufacturer#5	almond antique sky peru orange	2	1788.73	7672.66	1788.73	1788.73	1534.532
-Manufacturer#5	almond aquamarine dodger light gainsboro	46	1018.1	5882.969999999999	1018.1	1018.1	1470.7424999999998
-Manufacturer#5	almond azure blanched chiffon midnight	23	1464.48	4271.3099999999995	1464.48	1464.48	1423.7699999999998
+Manufacturer#3	almond antique metallic orange dim	19	1410.39	7532.61	1410.39	1410.39	1506.52
+Manufacturer#3	almond antique misty red olive	1	1922.98	5860.93	1922.98	1922.98	1465.23
+Manufacturer#3	almond antique olive coral navajo	45	1337.29	4670.66	1337.29	1337.29	1556.89
+Manufacturer#4	almond antique gainsboro frosted violet	10	1620.67	4202.35	1620.67	1620.67	1400.78
+Manufacturer#4	almond antique violet mint lemon	39	1375.42	6047.27	1375.42	1375.42	1511.82
+Manufacturer#4	almond aquamarine floral ivory bisque	27	1206.26	7337.62	1206.26	1206.26	1467.52
+Manufacturer#4	almond aquamarine yellow dodger mint	7	1844.92	5716.95	1844.92	1844.92	1429.24
+Manufacturer#4	almond azure aquamarine papaya violet	12	1290.35	4341.53	1290.35	1290.35	1447.18
+Manufacturer#5	almond antique blue firebrick mint	31	1789.69	5190.08	1789.69	1789.69	1730.03
+Manufacturer#5	almond antique medium spring khaki	6	1611.66	6208.18	1611.66	1611.66	1552.05
+Manufacturer#5	almond antique sky peru orange	2	1788.73	7672.66	1788.73	1788.73	1534.53
+Manufacturer#5	almond aquamarine dodger light gainsboro	46	1018.1	5882.97	1018.1	1018.1	1470.74
+Manufacturer#5	almond azure blanched chiffon midnight	23	1464.48	4271.31	1464.48	1464.48	1423.77
 PREHOOK: query: -- 20. testSTATs
 select  p_mfgr,p_name, p_size, 
 stddev(p_retailprice) over w1 as sdev, 
@@ -1073,7 +1073,7 @@ Manufacturer#5	Brand#53	2806.83	7672.66
 PREHOOK: query: -- 23. testCreateViewWithWindowingQuery
 create view IF NOT EXISTS mfgr_brand_price_view as 
 select p_mfgr, p_brand, 
-sum(p_retailprice) over w1  as s
+round(sum(p_retailprice) over w1,2) as s
 from part 
 window w1 as (distribute by p_mfgr sort by p_name rows between 2 preceding and current row)
 PREHOOK: type: CREATEVIEW
@@ -1083,7 +1083,7 @@ PREHOOK: Output: default@mfgr_brand_price_view
 POSTHOOK: query: -- 23. testCreateViewWithWindowingQuery
 create view IF NOT EXISTS mfgr_brand_price_view as 
 select p_mfgr, p_brand, 
-sum(p_retailprice) over w1  as s
+round(sum(p_retailprice) over w1,2) as s
 from part 
 window w1 as (distribute by p_mfgr sort by p_name rows between 2 preceding and current row)
 POSTHOOK: type: CREATEVIEW
@@ -1101,29 +1101,29 @@ POSTHOOK: Input: default@mfgr_brand_price_view
 POSTHOOK: Input: default@part
 #### A masked pattern was here ####
 Manufacturer#1	Brand#12	4100.06
-Manufacturer#1	Brand#12	4649.670000000001
+Manufacturer#1	Brand#12	4649.67
 Manufacturer#1	Brand#12	4770.77
 Manufacturer#1	Brand#14	1173.15
 Manufacturer#1	Brand#14	2346.3
 Manufacturer#1	Brand#15	4529.5
 Manufacturer#2	Brand#22	1690.68
 Manufacturer#2	Brand#22	3491.38
-Manufacturer#2	Brand#23	5523.360000000001
+Manufacturer#2	Brand#23	5523.36
 Manufacturer#2	Brand#24	5531.34
-Manufacturer#2	Brand#25	5432.240000000001
+Manufacturer#2	Brand#25	5432.24
 Manufacturer#3	Brand#31	1671.68
 Manufacturer#3	Brand#32	4272.34
-Manufacturer#3	Brand#32	4523.639999999999
+Manufacturer#3	Brand#32	4523.64
 Manufacturer#3	Brand#34	4670.66
 Manufacturer#3	Brand#35	2861.95
 Manufacturer#4	Brand#41	1620.67
-Manufacturer#4	Brand#41	4341.530000000001
+Manufacturer#4	Brand#41	4341.53
 Manufacturer#4	Brand#41	4426.6
 Manufacturer#4	Brand#42	2996.09
 Manufacturer#4	Brand#42	4202.35
-Manufacturer#5	Brand#51	3401.3500000000004
+Manufacturer#5	Brand#51	3401.35
 Manufacturer#5	Brand#52	1789.69
-Manufacturer#5	Brand#52	4271.3099999999995
+Manufacturer#5	Brand#52	4271.31
 Manufacturer#5	Brand#53	4418.49
 Manufacturer#5	Brand#53	5190.08
 PREHOOK: query: -- 24. testLateralViews
@@ -1293,7 +1293,7 @@ INSERT OVERWRITE TABLE part_1
 select p_mfgr, p_name, p_size, 
 rank() over(distribute by p_mfgr sort by p_name ) as r, 
 dense_rank() over(distribute by p_mfgr sort by p_name ) as dr, 
-sum(p_retailprice) over (distribute by p_mfgr sort by p_name rows between unbounded preceding and current row)  as s
+round(sum(p_retailprice) over (distribute by p_mfgr sort by p_name rows between unbounded preceding and current row),2) as s
 INSERT OVERWRITE TABLE part_2 
 select  p_mfgr,p_name, p_size,  
 rank() over(distribute by p_mfgr sort by p_name) as r, 
@@ -1318,7 +1318,7 @@ INSERT OVERWRITE TABLE part_1
 select p_mfgr, p_name, p_size, 
 rank() over(distribute by p_mfgr sort by p_name ) as r, 
 dense_rank() over(distribute by p_mfgr sort by p_name ) as dr, 
-sum(p_retailprice) over (distribute by p_mfgr sort by p_name rows between unbounded preceding and current row)  as s
+round(sum(p_retailprice) over (distribute by p_mfgr sort by p_name rows between unbounded preceding and current row),2) as s
 INSERT OVERWRITE TABLE part_2 
 select  p_mfgr,p_name, p_size,  
 rank() over(distribute by p_mfgr sort by p_name) as r, 
@@ -1369,12 +1369,12 @@ POSTHOOK: Input: default@part_1
 Manufacturer#1	almond antique burnished rose metallic	2	1	1	1173.15
 Manufacturer#1	almond antique burnished rose metallic	2	1	1	2346.3
 Manufacturer#1	almond antique chartreuse lavender yellow	34	3	2	4100.06
-Manufacturer#1	almond antique salmon chartreuse burlywood	6	4	3	5702.650000000001
-Manufacturer#1	almond aquamarine burnished black steel	28	5	4	7117.070000000001
-Manufacturer#1	almond aquamarine pink moccasin thistle	42	6	5	8749.730000000001
+Manufacturer#1	almond antique salmon chartreuse burlywood	6	4	3	5702.65
+Manufacturer#1	almond aquamarine burnished black steel	28	5	4	7117.07
+Manufacturer#1	almond aquamarine pink moccasin thistle	42	6	5	8749.73
 Manufacturer#2	almond antique violet chocolate turquoise	14	1	1	1690.68
 Manufacturer#2	almond antique violet turquoise frosted	40	2	2	3491.38
-Manufacturer#2	almond aquamarine midnight light salmon	2	3	3	5523.360000000001
+Manufacturer#2	almond aquamarine midnight light salmon	2	3	3	5523.36
 Manufacturer#2	almond aquamarine rose maroon antique	25	4	4	7222.02
 Manufacturer#2	almond aquamarine sandy cyan gainsboro	18	5	5	8923.62
 Manufacturer#3	almond antique chartreuse khaki white	17	1	1	1671.68
@@ -1386,9 +1386,9 @@ Manufacturer#4	almond antique gainsboro frosted violet	10	1	1	1620.67
 Manufacturer#4	almond antique violet mint lemon	39	2	2	2996.09
 Manufacturer#4	almond aquamarine floral ivory bisque	27	3	3	4202.35
 Manufacturer#4	almond aquamarine yellow dodger mint	7	4	4	6047.27
-Manufacturer#4	almond azure aquamarine papaya violet	12	5	5	7337.620000000001
+Manufacturer#4	almond azure aquamarine papaya violet	12	5	5	7337.62
 Manufacturer#5	almond antique blue firebrick mint	31	1	1	1789.69
-Manufacturer#5	almond antique medium spring khaki	6	2	2	3401.3500000000004
+Manufacturer#5	almond antique medium spring khaki	6	2	2	3401.35
 Manufacturer#5	almond antique sky peru orange	2	3	3	5190.08
 Manufacturer#5	almond aquamarine dodger light gainsboro	46	4	4	6208.18
 Manufacturer#5	almond azure blanched chiffon midnight	23	5	5	7672.66
@@ -2003,7 +2003,7 @@ Manufacturer#5	7672.66	1018.1	1789.69	1534.53	5
 Manufacturer#5	7672.66	1018.1	1789.69	1534.53	5
 PREHOOK: query: -- 38. testPartitioningVariousForms2
 select p_mfgr, p_name, p_size,
-sum(p_retailprice) over (partition by p_mfgr, p_name order by p_mfgr, p_name rows between unbounded preceding and current row) as s1,
+round(sum(p_retailprice) over (partition by p_mfgr, p_name order by p_mfgr, p_name rows between unbounded preceding and current row),2) as s1,
 min(p_retailprice) over (distribute by p_mfgr, p_name sort by p_mfgr, p_name rows between unbounded preceding and current row) as s2,
 max(p_retailprice) over (partition by p_mfgr, p_name order by p_name) as s3
 from part
@@ -2012,7 +2012,7 @@ PREHOOK: Input: default@part
 #### A masked pattern was here ####
 POSTHOOK: query: -- 38. testPartitioningVariousForms2
 select p_mfgr, p_name, p_size,
-sum(p_retailprice) over (partition by p_mfgr, p_name order by p_mfgr, p_name rows between unbounded preceding and current row) as s1,
+round(sum(p_retailprice) over (partition by p_mfgr, p_name order by p_mfgr, p_name rows between unbounded preceding and current row),2) as s1,
 min(p_retailprice) over (distribute by p_mfgr, p_name sort by p_mfgr, p_name rows between unbounded preceding and current row) as s2,
 max(p_retailprice) over (partition by p_mfgr, p_name order by p_name) as s3
 from part
@@ -2087,14 +2087,14 @@ Manufacturer#5	SMALL PLATED BRASS	MALL PLATED BRASS	4
 Manufacturer#5	STANDARD BURNISHED TIN	TANDARD BURNISHED TIN	5
 PREHOOK: query: -- 40. testNoBetweenForRows
 select p_mfgr, p_name, p_size,
-    sum(p_retailprice) over (distribute by p_mfgr sort by p_name rows unbounded preceding) as s1
+    round(sum(p_retailprice) over (distribute by p_mfgr sort by p_name rows unbounded preceding),2) as s1
      from part
 PREHOOK: type: QUERY
 PREHOOK: Input: default@part
 #### A masked pattern was here ####
 POSTHOOK: query: -- 40. testNoBetweenForRows
 select p_mfgr, p_name, p_size,
-    sum(p_retailprice) over (distribute by p_mfgr sort by p_name rows unbounded preceding) as s1
+    round(sum(p_retailprice) over (distribute by p_mfgr sort by p_name rows unbounded preceding),2) as s1
      from part
 POSTHOOK: type: QUERY
 POSTHOOK: Input: default@part
@@ -2102,12 +2102,12 @@ POSTHOOK: Input: default@part
 Manufacturer#1	almond antique burnished rose metallic	2	1173.15
 Manufacturer#1	almond antique burnished rose metallic	2	2346.3
 Manufacturer#1	almond antique chartreuse lavender yellow	34	4100.06
-Manufacturer#1	almond antique salmon chartreuse burlywood	6	5702.650000000001
-Manufacturer#1	almond aquamarine burnished black steel	28	7117.070000000001
-Manufacturer#1	almond aquamarine pink moccasin thistle	42	8749.730000000001
+Manufacturer#1	almond antique salmon chartreuse burlywood	6	5702.65
+Manufacturer#1	almond aquamarine burnished black steel	28	7117.07
+Manufacturer#1	almond aquamarine pink moccasin thistle	42	8749.73
 Manufacturer#2	almond antique violet chocolate turquoise	14	1690.68
 Manufacturer#2	almond antique violet turquoise frosted	40	3491.38
-Manufacturer#2	almond aquamarine midnight light salmon	2	5523.360000000001
+Manufacturer#2	almond aquamarine midnight light salmon	2	5523.36
 Manufacturer#2	almond aquamarine rose maroon antique	25	7222.02
 Manufacturer#2	almond aquamarine sandy cyan gainsboro	18	8923.62
 Manufacturer#3	almond antique chartreuse khaki white	17	1671.68
@@ -2119,32 +2119,32 @@ Manufacturer#4	almond antique gainsboro frosted violet	10	1620.67
 Manufacturer#4	almond antique violet mint lemon	39	2996.09
 Manufacturer#4	almond aquamarine floral ivory bisque	27	4202.35
 Manufacturer#4	almond aquamarine yellow dodger mint	7	6047.27
-Manufacturer#4	almond azure aquamarine papaya violet	12	7337.620000000001
+Manufacturer#4	almond azure aquamarine papaya violet	12	7337.62
 Manufacturer#5	almond antique blue firebrick mint	31	1789.69
-Manufacturer#5	almond antique medium spring khaki	6	3401.3500000000004
+Manufacturer#5	almond antique medium spring khaki	6	3401.35
 Manufacturer#5	almond antique sky peru orange	2	5190.08
 Manufacturer#5	almond aquamarine dodger light gainsboro	46	6208.18
 Manufacturer#5	almond azure blanched chiffon midnight	23	7672.66
 PREHOOK: query: -- 41. testNoBetweenForRange
 select p_mfgr, p_name, p_size,
-    sum(p_retailprice) over (distribute by p_mfgr sort by p_size range unbounded preceding) as s1
+    round(sum(p_retailprice) over (distribute by p_mfgr sort by p_size range unbounded preceding),2) as s1
      from part
 PREHOOK: type: QUERY
 PREHOOK: Input: default@part
 #### A masked pattern was here ####
 POSTHOOK: query: -- 41. testNoBetweenForRange
 select p_mfgr, p_name, p_size,
-    sum(p_retailprice) over (distribute by p_mfgr sort by p_size range unbounded preceding) as s1
+    round(sum(p_retailprice) over (distribute by p_mfgr sort by p_size range unbounded preceding),2) as s1
      from part
 POSTHOOK: type: QUERY
 POSTHOOK: Input: default@part
 #### A masked pattern was here ####
 Manufacturer#1	almond antique burnished rose metallic	2	2346.3
 Manufacturer#1	almond antique burnished rose metallic	2	2346.3
-Manufacturer#1	almond antique chartreuse lavender yellow	34	7117.070000000001
-Manufacturer#1	almond antique salmon chartreuse burlywood	6	3948.8900000000003
+Manufacturer#1	almond antique chartreuse lavender yellow	34	7117.07
+Manufacturer#1	almond antique salmon chartreuse burlywood	6	3948.89
 Manufacturer#1	almond aquamarine burnished black steel	28	5363.31
-Manufacturer#1	almond aquamarine pink moccasin thistle	42	8749.730000000001
+Manufacturer#1	almond aquamarine pink moccasin thistle	42	8749.73
 Manufacturer#2	almond antique violet chocolate turquoise	14	3722.66
 Manufacturer#2	almond antique violet turquoise frosted	40	8923.62
 Manufacturer#2	almond aquamarine midnight light salmon	2	2031.98
@@ -2152,97 +2152,97 @@ Manufacturer#2	almond aquamarine rose maroon antique	25	7122.92
 Manufacturer#2	almond aquamarine sandy cyan gainsboro	18	5424.26
 Manufacturer#3	almond antique chartreuse khaki white	17	4784.93
 Manufacturer#3	almond antique forest lavender goldenrod	14	3113.25
-Manufacturer#3	almond antique metallic orange dim	19	6195.320000000001
+Manufacturer#3	almond antique metallic orange dim	19	6195.32
 Manufacturer#3	almond antique misty red olive	1	1922.98
-Manufacturer#3	almond antique olive coral navajo	45	7532.610000000001
+Manufacturer#3	almond antique olive coral navajo	45	7532.61
 Manufacturer#4	almond antique gainsboro frosted violet	10	3465.59
-Manufacturer#4	almond antique violet mint lemon	39	7337.620000000001
-Manufacturer#4	almond aquamarine floral ivory bisque	27	5962.200000000001
+Manufacturer#4	almond antique violet mint lemon	39	7337.62
+Manufacturer#4	almond aquamarine floral ivory bisque	27	5962.2
 Manufacturer#4	almond aquamarine yellow dodger mint	7	1844.92
-Manufacturer#4	almond azure aquamarine papaya violet	12	4755.9400000000005
-Manufacturer#5	almond antique blue firebrick mint	31	6654.560000000001
-Manufacturer#5	almond antique medium spring khaki	6	3400.3900000000003
+Manufacturer#4	almond azure aquamarine papaya violet	12	4755.94
+Manufacturer#5	almond antique blue firebrick mint	31	6654.56
+Manufacturer#5	almond antique medium spring khaki	6	3400.39
 Manufacturer#5	almond antique sky peru orange	2	1788.73
-Manufacturer#5	almond aquamarine dodger light gainsboro	46	7672.660000000002
-Manufacturer#5	almond azure blanched chiffon midnight	23	4864.870000000001
+Manufacturer#5	almond aquamarine dodger light gainsboro	46	7672.66
+Manufacturer#5	almond azure blanched chiffon midnight	23	4864.87
 PREHOOK: query: -- 42. testUnboundedFollowingForRows
 select p_mfgr, p_name, p_size,
-    sum(p_retailprice) over (distribute by p_mfgr sort by p_name rows between current row and unbounded following) as s1
+    round(sum(p_retailprice) over (distribute by p_mfgr sort by p_name rows between current row and unbounded following),2) as s1
     from part
 PREHOOK: type: QUERY
 PREHOOK: Input: default@part
 #### A masked pattern was here ####
 POSTHOOK: query: -- 42. testUnboundedFollowingForRows
 select p_mfgr, p_name, p_size,
-    sum(p_retailprice) over (distribute by p_mfgr sort by p_name rows between current row and unbounded following) as s1
+    round(sum(p_retailprice) over (distribute by p_mfgr sort by p_name rows between current row and unbounded following),2) as s1
     from part
 POSTHOOK: type: QUERY
 POSTHOOK: Input: default@part
 #### A masked pattern was here ####
 Manufacturer#1	almond antique burnished rose metallic	2	7576.58
-Manufacturer#1	almond antique burnished rose metallic	2	8749.730000000001
+Manufacturer#1	almond antique burnished rose metallic	2	8749.73
 Manufacturer#1	almond antique chartreuse lavender yellow	34	6403.43
 Manufacturer#1	almond antique salmon chartreuse burlywood	6	4649.67
 Manufacturer#1	almond aquamarine burnished black steel	28	3047.08
 Manufacturer#1	almond aquamarine pink moccasin thistle	42	1632.66
 Manufacturer#2	almond antique violet chocolate turquoise	14	8923.62
-Manufacturer#2	almond antique violet turquoise frosted	40	7232.9400000000005
+Manufacturer#2	almond antique violet turquoise frosted	40	7232.94
 Manufacturer#2	almond aquamarine midnight light salmon	2	5432.24
 Manufacturer#2	almond aquamarine rose maroon antique	25	3400.26
 Manufacturer#2	almond aquamarine sandy cyan gainsboro	18	1701.6
 Manufacturer#3	almond antique chartreuse khaki white	17	7532.61
-Manufacturer#3	almond antique forest lavender goldenrod	14	5860.929999999999
+Manufacturer#3	almond antique forest lavender goldenrod	14	5860.93
 Manufacturer#3	almond antique metallic orange dim	19	4670.66
 Manufacturer#3	almond antique misty red olive	1	3260.27
 Manufacturer#3	almond antique olive coral navajo	45	1337.29
-Manufacturer#4	almond antique gainsboro frosted violet	10	7337.620000000001
-Manufacturer#4	almond antique violet mint lemon	39	5716.950000000001
-Manufacturer#4	almond aquamarine floral ivory bisque	27	4341.530000000001
+Manufacturer#4	almond antique gainsboro frosted violet	10	7337.62
+Manufacturer#4	almond antique violet mint lemon	39	5716.95
+Manufacturer#4	almond aquamarine floral ivory bisque	27	4341.53
 Manufacturer#4	almond aquamarine yellow dodger mint	7	3135.27
 Manufacturer#4	almond azure aquamarine papaya violet	12	1290.35
 Manufacturer#5	almond antique blue firebrick mint	31	7672.66
-Manufacturer#5	almond antique medium spring khaki	6	5882.970000000001
-Manufacturer#5	almond antique sky peru orange	2	4271.3099999999995
+Manufacturer#5	almond antique medium spring khaki	6	5882.97
+Manufacturer#5	almond antique sky peru orange	2	4271.31
 Manufacturer#5	almond aquamarine dodger light gainsboro	46	2482.58
 Manufacturer#5	almond azure blanched chiffon midnight	23	1464.48
 PREHOOK: query: -- 43. testUnboundedFollowingForRange
 select p_mfgr, p_name, p_size,
-    sum(p_retailprice) over (distribute by p_mfgr sort by p_size range between current row and unbounded following) as s1
+    round(sum(p_retailprice) over (distribute by p_mfgr sort by p_size range between current row and unbounded following),2) as s1
     from part
 PREHOOK: type: QUERY
 PREHOOK: Input: default@part
 #### A masked pattern was here ####
 POSTHOOK: query: -- 43. testUnboundedFollowingForRange
 select p_mfgr, p_name, p_size,
-    sum(p_retailprice) over (distribute by p_mfgr sort by p_size range between current row and unbounded following) as s1
+    round(sum(p_retailprice) over (distribute by p_mfgr sort by p_size range between current row and unbounded following),2) as s1
     from part
 POSTHOOK: type: QUERY
 POSTHOOK: Input: default@part
 #### A masked pattern was here ####
-Manufacturer#1	almond antique burnished rose metallic	2	8749.730000000001
-Manufacturer#1	almond antique burnished rose metallic	2	8749.730000000001
+Manufacturer#1	almond antique burnished rose metallic	2	8749.73
+Manufacturer#1	almond antique burnished rose metallic	2	8749.73
 Manufacturer#1	almond antique chartreuse lavender yellow	34	3386.42
 Manufacturer#1	almond antique salmon chartreuse burlywood	6	6403.43
 Manufacturer#1	almond aquamarine burnished black steel	28	4800.84
 Manufacturer#1	almond aquamarine pink moccasin thistle	42	1632.66
-Manufacturer#2	almond antique violet chocolate turquoise	14	6891.639999999999
+Manufacturer#2	almond antique violet chocolate turquoise	14	6891.64
 Manufacturer#2	almond antique violet turquoise frosted	40	1800.7
 Manufacturer#2	almond aquamarine midnight light salmon	2	8923.62
 Manufacturer#2	almond aquamarine rose maroon antique	25	3499.36
 Manufacturer#2	almond aquamarine sandy cyan gainsboro	18	5200.96
-Manufacturer#3	almond antique chartreuse khaki white	17	4419.360000000001
+Manufacturer#3	almond antique chartreuse khaki white	17	4419.36
 Manufacturer#3	almond antique forest lavender goldenrod	14	5609.63
-Manufacturer#3	almond antique metallic orange dim	19	2747.6800000000003
-Manufacturer#3	almond antique misty red olive	1	7532.610000000001
+Manufacturer#3	almond antique metallic orange dim	19	2747.68
+Manufacturer#3	almond antique misty red olive	1	7532.61
 Manufacturer#3	almond antique olive coral navajo	45	1337.29
 Manufacturer#4	almond antique gainsboro frosted violet	10	5492.7
 Manufacturer#4	almond antique violet mint lemon	39	1375.42
-Manufacturer#4	almond aquamarine floral ivory bisque	27	2581.6800000000003
-Manufacturer#4	almond aquamarine yellow dodger mint	7	7337.620000000001
-Manufacturer#4	almond azure aquamarine papaya violet	12	3872.0299999999997
+Manufacturer#4	almond aquamarine floral ivory bisque	27	2581.68
+Manufacturer#4	almond aquamarine yellow dodger mint	7	7337.62
+Manufacturer#4	almond azure aquamarine papaya violet	12	3872.03
 Manufacturer#5	almond antique blue firebrick mint	31	2807.79
 Manufacturer#5	almond antique medium spring khaki	6	5883.93
-Manufacturer#5	almond antique sky peru orange	2	7672.660000000002
+Manufacturer#5	almond antique sky peru orange	2	7672.66
 Manufacturer#5	almond aquamarine dodger light gainsboro	46	1018.1
 Manufacturer#5	almond azure blanched chiffon midnight	23	4272.27
 PREHOOK: query: -- 44. testOverNoPartitionSingleAggregate
@@ -2304,27 +2304,27 @@ POSTHOOK: type: QUERY
 POSTHOOK: Input: default@part
 #### A masked pattern was here ####
 PREHOOK: query: -- 46. window sz is same as partition sz
-select p_retailprice, avg(p_retailprice) over (partition by p_mfgr order by p_name rows between current row and 6 following), 
-sum(p_retailprice) over (partition by p_mfgr order by p_name rows between current row and 6 following) 
+select p_retailprice, round(avg(p_retailprice) over (partition by p_mfgr order by p_name rows between current row and 6 following),2), 
+round(sum(p_retailprice) over (partition by p_mfgr order by p_name rows between current row and 6 following),2) 
 from part 
 where p_mfgr='Manufacturer#1'
 PREHOOK: type: QUERY
 PREHOOK: Input: default@part
 #### A masked pattern was here ####
 POSTHOOK: query: -- 46. window sz is same as partition sz
-select p_retailprice, avg(p_retailprice) over (partition by p_mfgr order by p_name rows between current row and 6 following), 
-sum(p_retailprice) over (partition by p_mfgr order by p_name rows between current row and 6 following) 
+select p_retailprice, round(avg(p_retailprice) over (partition by p_mfgr order by p_name rows between current row and 6 following),2), 
+round(sum(p_retailprice) over (partition by p_mfgr order by p_name rows between current row and 6 following),2) 
 from part 
 where p_mfgr='Manufacturer#1'
 POSTHOOK: type: QUERY
 POSTHOOK: Input: default@part
 #### A masked pattern was here ####
-1173.15	1458.2883333333336	8749.730000000001
-1173.15	1515.3160000000003	7576.580000000002
-1414.42	1523.5400000000004	3047.080000000001
-1602.59	1549.8900000000003	4649.670000000001
-1632.66	1632.6600000000008	1632.6600000000008
-1753.76	1600.8575000000003	6403.430000000001
+1173.15	1458.29	8749.73
+1173.15	1515.32	7576.58
+1414.42	1523.54	3047.08
+1602.59	1549.89	4649.67
+1632.66	1632.66	1632.66
+1753.76	1600.86	6403.43
 PREHOOK: query: -- 47. empty partition
 select sum(p_size) over (partition by p_mfgr )
 from part where p_mfgr = 'm1'


[02/13] hive git commit: HIVE-15520: Improve the sum performance for Range based window (Aihua Xu, reviewed by Yongzhi Chen)

Posted by ai...@apache.org.
http://git-wip-us.apache.org/repos/asf/hive/blob/a28b28f3/ql/src/test/results/clientpositive/vectorized_ptf.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/vectorized_ptf.q.out b/ql/src/test/results/clientpositive/vectorized_ptf.q.out
index dd6c62c..77b5075 100644
--- a/ql/src/test/results/clientpositive/vectorized_ptf.q.out
+++ b/ql/src/test/results/clientpositive/vectorized_ptf.q.out
@@ -124,7 +124,7 @@ explain extended
 select p_mfgr, p_name, p_size,
 rank() over (partition by p_mfgr order by p_name) as r,
 dense_rank() over (partition by p_mfgr order by p_name) as dr,
-sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row) as s1
+round(sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row),2) as s1
 from noop(on part_orc 
   partition by p_mfgr
   order by p_name
@@ -136,7 +136,7 @@ explain extended
 select p_mfgr, p_name, p_size,
 rank() over (partition by p_mfgr order by p_name) as r,
 dense_rank() over (partition by p_mfgr order by p_name) as dr,
-sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row) as s1
+round(sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row),2) as s1
 from noop(on part_orc 
   partition by p_mfgr
   order by p_name
@@ -332,7 +332,7 @@ STAGE PLANS:
                         window frame: PRECEDING(MAX)~CURRENT
             Statistics: Num rows: 26 Data size: 16042 Basic stats: COMPLETE Column stats: NONE
             Select Operator
-              expressions: _col2 (type: string), _col1 (type: string), _col5 (type: int), rank_window_0 (type: int), dense_rank_window_1 (type: int), sum_window_2 (type: double)
+              expressions: _col2 (type: string), _col1 (type: string), _col5 (type: int), rank_window_0 (type: int), dense_rank_window_1 (type: int), round(sum_window_2, 2) (type: double)
               outputColumnNames: _col0, _col1, _col2, _col3, _col4, _col5
               Statistics: Num rows: 26 Data size: 16042 Basic stats: COMPLETE Column stats: NONE
               File Output Operator
@@ -956,7 +956,7 @@ explain extended
 select p_mfgr, p_name, p_size,
 rank() over (partition by p_mfgr order by p_name) as r,
 dense_rank() over (partition by p_mfgr order by p_name) as dr,
-sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row) as s1
+round(sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row),2) as s1
 from noop(on part_orc 
   partition by p_mfgr
   order by p_name
@@ -968,7 +968,7 @@ explain extended
 select p_mfgr, p_name, p_size,
 rank() over (partition by p_mfgr order by p_name) as r,
 dense_rank() over (partition by p_mfgr order by p_name) as dr,
-sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row) as s1
+round(sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row),2) as s1
 from noop(on part_orc 
   partition by p_mfgr
   order by p_name
@@ -1164,7 +1164,7 @@ STAGE PLANS:
                         window frame: PRECEDING(MAX)~CURRENT
             Statistics: Num rows: 26 Data size: 16042 Basic stats: COMPLETE Column stats: NONE
             Select Operator
-              expressions: _col2 (type: string), _col1 (type: string), _col5 (type: int), rank_window_0 (type: int), dense_rank_window_1 (type: int), sum_window_2 (type: double)
+              expressions: _col2 (type: string), _col1 (type: string), _col5 (type: int), rank_window_0 (type: int), dense_rank_window_1 (type: int), round(sum_window_2, 2) (type: double)
               outputColumnNames: _col0, _col1, _col2, _col3, _col4, _col5
               Statistics: Num rows: 26 Data size: 16042 Basic stats: COMPLETE Column stats: NONE
               File Output Operator
@@ -1199,7 +1199,7 @@ STAGE PLANS:
 PREHOOK: query: select p_mfgr, p_name, p_size,
 rank() over (partition by p_mfgr order by p_name) as r,
 dense_rank() over (partition by p_mfgr order by p_name) as dr,
-sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row) as s1
+round(sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row),2) as s1
 from noop(on part_orc 
   partition by p_mfgr
   order by p_name
@@ -1210,7 +1210,7 @@ PREHOOK: Input: default@part_orc
 POSTHOOK: query: select p_mfgr, p_name, p_size,
 rank() over (partition by p_mfgr order by p_name) as r,
 dense_rank() over (partition by p_mfgr order by p_name) as dr,
-sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row) as s1
+round(sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row),2) as s1
 from noop(on part_orc 
   partition by p_mfgr
   order by p_name
@@ -1221,12 +1221,12 @@ POSTHOOK: Input: default@part_orc
 Manufacturer#1	almond antique burnished rose metallic	2	1	1	1173.15
 Manufacturer#1	almond antique burnished rose metallic	2	1	1	2346.3
 Manufacturer#1	almond antique chartreuse lavender yellow	34	3	2	4100.06
-Manufacturer#1	almond antique salmon chartreuse burlywood	6	4	3	5702.650000000001
-Manufacturer#1	almond aquamarine burnished black steel	28	5	4	7117.070000000001
-Manufacturer#1	almond aquamarine pink moccasin thistle	42	6	5	8749.730000000001
+Manufacturer#1	almond antique salmon chartreuse burlywood	6	4	3	5702.65
+Manufacturer#1	almond aquamarine burnished black steel	28	5	4	7117.07
+Manufacturer#1	almond aquamarine pink moccasin thistle	42	6	5	8749.73
 Manufacturer#2	almond antique violet chocolate turquoise	14	1	1	1690.68
 Manufacturer#2	almond antique violet turquoise frosted	40	2	2	3491.38
-Manufacturer#2	almond aquamarine midnight light salmon	2	3	3	5523.360000000001
+Manufacturer#2	almond aquamarine midnight light salmon	2	3	3	5523.36
 Manufacturer#2	almond aquamarine rose maroon antique	25	4	4	7222.02
 Manufacturer#2	almond aquamarine sandy cyan gainsboro	18	5	5	8923.62
 Manufacturer#3	almond antique chartreuse khaki white	17	1	1	1671.68
@@ -1238,9 +1238,9 @@ Manufacturer#4	almond antique gainsboro frosted violet	10	1	1	1620.67
 Manufacturer#4	almond antique violet mint lemon	39	2	2	2996.09
 Manufacturer#4	almond aquamarine floral ivory bisque	27	3	3	4202.35
 Manufacturer#4	almond aquamarine yellow dodger mint	7	4	4	6047.27
-Manufacturer#4	almond azure aquamarine papaya violet	12	5	5	7337.620000000001
+Manufacturer#4	almond azure aquamarine papaya violet	12	5	5	7337.62
 Manufacturer#5	almond antique blue firebrick mint	31	1	1	1789.69
-Manufacturer#5	almond antique medium spring khaki	6	2	2	3401.3500000000004
+Manufacturer#5	almond antique medium spring khaki	6	2	2	3401.35
 Manufacturer#5	almond antique sky peru orange	2	3	3	5190.08
 Manufacturer#5	almond aquamarine dodger light gainsboro	46	4	4	6208.18
 Manufacturer#5	almond azure blanched chiffon midnight	23	5	5	7672.66
@@ -2769,7 +2769,7 @@ explain extended
 select p_mfgr, p_name, p_size,
 rank() over (partition by p_mfgr order by p_name) as r,
 dense_rank() over (partition by p_mfgr order by p_name) as dr,
-sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row) as s1
+round(sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row),2) as s1
 from noopwithmap(on part_orc 
   partition by p_mfgr
   order by p_name)
@@ -2780,7 +2780,7 @@ explain extended
 select p_mfgr, p_name, p_size,
 rank() over (partition by p_mfgr order by p_name) as r,
 dense_rank() over (partition by p_mfgr order by p_name) as dr,
-sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row) as s1
+round(sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row),2) as s1
 from noopwithmap(on part_orc 
   partition by p_mfgr
   order by p_name)
@@ -2991,7 +2991,7 @@ STAGE PLANS:
                         window frame: PRECEDING(MAX)~CURRENT
             Statistics: Num rows: 26 Data size: 16042 Basic stats: COMPLETE Column stats: NONE
             Select Operator
-              expressions: _col2 (type: string), _col1 (type: string), _col5 (type: int), rank_window_0 (type: int), dense_rank_window_1 (type: int), sum_window_2 (type: double)
+              expressions: _col2 (type: string), _col1 (type: string), _col5 (type: int), rank_window_0 (type: int), dense_rank_window_1 (type: int), round(sum_window_2, 2) (type: double)
               outputColumnNames: _col0, _col1, _col2, _col3, _col4, _col5
               Statistics: Num rows: 26 Data size: 16042 Basic stats: COMPLETE Column stats: NONE
               File Output Operator
@@ -3026,7 +3026,7 @@ STAGE PLANS:
 PREHOOK: query: select p_mfgr, p_name, p_size,
 rank() over (partition by p_mfgr order by p_name) as r,
 dense_rank() over (partition by p_mfgr order by p_name) as dr,
-sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row) as s1
+round(sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row),2) as s1
 from noopwithmap(on part_orc 
   partition by p_mfgr
   order by p_name)
@@ -3036,7 +3036,7 @@ PREHOOK: Input: default@part_orc
 POSTHOOK: query: select p_mfgr, p_name, p_size,
 rank() over (partition by p_mfgr order by p_name) as r,
 dense_rank() over (partition by p_mfgr order by p_name) as dr,
-sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row) as s1
+round(sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row),2) as s1
 from noopwithmap(on part_orc 
   partition by p_mfgr
   order by p_name)
@@ -3046,12 +3046,12 @@ POSTHOOK: Input: default@part_orc
 Manufacturer#1	almond antique burnished rose metallic	2	1	1	1173.15
 Manufacturer#1	almond antique burnished rose metallic	2	1	1	2346.3
 Manufacturer#1	almond antique chartreuse lavender yellow	34	3	2	4100.06
-Manufacturer#1	almond antique salmon chartreuse burlywood	6	4	3	5702.650000000001
-Manufacturer#1	almond aquamarine burnished black steel	28	5	4	7117.070000000001
-Manufacturer#1	almond aquamarine pink moccasin thistle	42	6	5	8749.730000000001
+Manufacturer#1	almond antique salmon chartreuse burlywood	6	4	3	5702.65
+Manufacturer#1	almond aquamarine burnished black steel	28	5	4	7117.07
+Manufacturer#1	almond aquamarine pink moccasin thistle	42	6	5	8749.73
 Manufacturer#2	almond antique violet chocolate turquoise	14	1	1	1690.68
 Manufacturer#2	almond antique violet turquoise frosted	40	2	2	3491.38
-Manufacturer#2	almond aquamarine midnight light salmon	2	3	3	5523.360000000001
+Manufacturer#2	almond aquamarine midnight light salmon	2	3	3	5523.36
 Manufacturer#2	almond aquamarine rose maroon antique	25	4	4	7222.02
 Manufacturer#2	almond aquamarine sandy cyan gainsboro	18	5	5	8923.62
 Manufacturer#3	almond antique chartreuse khaki white	17	1	1	1671.68
@@ -3063,9 +3063,9 @@ Manufacturer#4	almond antique gainsboro frosted violet	10	1	1	1620.67
 Manufacturer#4	almond antique violet mint lemon	39	2	2	2996.09
 Manufacturer#4	almond aquamarine floral ivory bisque	27	3	3	4202.35
 Manufacturer#4	almond aquamarine yellow dodger mint	7	4	4	6047.27
-Manufacturer#4	almond azure aquamarine papaya violet	12	5	5	7337.620000000001
+Manufacturer#4	almond azure aquamarine papaya violet	12	5	5	7337.62
 Manufacturer#5	almond antique blue firebrick mint	31	1	1	1789.69
-Manufacturer#5	almond antique medium spring khaki	6	2	2	3401.3500000000004
+Manufacturer#5	almond antique medium spring khaki	6	2	2	3401.35
 Manufacturer#5	almond antique sky peru orange	2	3	3	5190.08
 Manufacturer#5	almond aquamarine dodger light gainsboro	46	4	4	6208.18
 Manufacturer#5	almond azure blanched chiffon midnight	23	5	5	7672.66
@@ -3075,7 +3075,7 @@ explain extended
 select p_mfgr, p_name, p_size,
 rank() over (partition by p_mfgr order by p_name) as r,
 dense_rank() over (partition by p_mfgr order by p_name) as dr,
-sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row) as s1
+round(sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row),2) as s1
 from noop(on part_orc
 partition by p_mfgr
 order by p_name)
@@ -3086,7 +3086,7 @@ explain extended
 select p_mfgr, p_name, p_size,
 rank() over (partition by p_mfgr order by p_name) as r,
 dense_rank() over (partition by p_mfgr order by p_name) as dr,
-sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row) as s1
+round(sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row),2) as s1
 from noop(on part_orc
 partition by p_mfgr
 order by p_name)
@@ -3281,7 +3281,7 @@ STAGE PLANS:
                         window frame: PRECEDING(MAX)~CURRENT
             Statistics: Num rows: 26 Data size: 16042 Basic stats: COMPLETE Column stats: NONE
             Select Operator
-              expressions: _col2 (type: string), _col1 (type: string), _col5 (type: int), rank_window_0 (type: int), dense_rank_window_1 (type: int), sum_window_2 (type: double)
+              expressions: _col2 (type: string), _col1 (type: string), _col5 (type: int), rank_window_0 (type: int), dense_rank_window_1 (type: int), round(sum_window_2, 2) (type: double)
               outputColumnNames: _col0, _col1, _col2, _col3, _col4, _col5
               Statistics: Num rows: 26 Data size: 16042 Basic stats: COMPLETE Column stats: NONE
               File Output Operator
@@ -3316,7 +3316,7 @@ STAGE PLANS:
 PREHOOK: query: select p_mfgr, p_name, p_size,
 rank() over (partition by p_mfgr order by p_name) as r,
 dense_rank() over (partition by p_mfgr order by p_name) as dr,
-sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row) as s1
+round(sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row),2) as s1
 from noop(on part_orc
 partition by p_mfgr
 order by p_name)
@@ -3326,7 +3326,7 @@ PREHOOK: Input: default@part_orc
 POSTHOOK: query: select p_mfgr, p_name, p_size,
 rank() over (partition by p_mfgr order by p_name) as r,
 dense_rank() over (partition by p_mfgr order by p_name) as dr,
-sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row) as s1
+round(sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row),2) as s1
 from noop(on part_orc
 partition by p_mfgr
 order by p_name)
@@ -3336,12 +3336,12 @@ POSTHOOK: Input: default@part_orc
 Manufacturer#1	almond antique burnished rose metallic	2	1	1	1173.15
 Manufacturer#1	almond antique burnished rose metallic	2	1	1	2346.3
 Manufacturer#1	almond antique chartreuse lavender yellow	34	3	2	4100.06
-Manufacturer#1	almond antique salmon chartreuse burlywood	6	4	3	5702.650000000001
-Manufacturer#1	almond aquamarine burnished black steel	28	5	4	7117.070000000001
-Manufacturer#1	almond aquamarine pink moccasin thistle	42	6	5	8749.730000000001
+Manufacturer#1	almond antique salmon chartreuse burlywood	6	4	3	5702.65
+Manufacturer#1	almond aquamarine burnished black steel	28	5	4	7117.07
+Manufacturer#1	almond aquamarine pink moccasin thistle	42	6	5	8749.73
 Manufacturer#2	almond antique violet chocolate turquoise	14	1	1	1690.68
 Manufacturer#2	almond antique violet turquoise frosted	40	2	2	3491.38
-Manufacturer#2	almond aquamarine midnight light salmon	2	3	3	5523.360000000001
+Manufacturer#2	almond aquamarine midnight light salmon	2	3	3	5523.36
 Manufacturer#2	almond aquamarine rose maroon antique	25	4	4	7222.02
 Manufacturer#2	almond aquamarine sandy cyan gainsboro	18	5	5	8923.62
 Manufacturer#3	almond antique chartreuse khaki white	17	1	1	1671.68
@@ -3353,9 +3353,9 @@ Manufacturer#4	almond antique gainsboro frosted violet	10	1	1	1620.67
 Manufacturer#4	almond antique violet mint lemon	39	2	2	2996.09
 Manufacturer#4	almond aquamarine floral ivory bisque	27	3	3	4202.35
 Manufacturer#4	almond aquamarine yellow dodger mint	7	4	4	6047.27
-Manufacturer#4	almond azure aquamarine papaya violet	12	5	5	7337.620000000001
+Manufacturer#4	almond azure aquamarine papaya violet	12	5	5	7337.62
 Manufacturer#5	almond antique blue firebrick mint	31	1	1	1789.69
-Manufacturer#5	almond antique medium spring khaki	6	2	2	3401.3500000000004
+Manufacturer#5	almond antique medium spring khaki	6	2	2	3401.35
 Manufacturer#5	almond antique sky peru orange	2	3	3	5190.08
 Manufacturer#5	almond aquamarine dodger light gainsboro	46	4	4	6208.18
 Manufacturer#5	almond azure blanched chiffon midnight	23	5	5	7672.66
@@ -3365,7 +3365,7 @@ explain extended
 select p_mfgr, p_name, p_size, 
 rank() over (partition by p_mfgr order by p_name) as r, 
 dense_rank() over (partition by p_mfgr order by p_name) as dr, 
-sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row)  as s1
+round(sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row),2) as s1
 from noop(on noopwithmap(on noop(on part_orc 
 partition by p_mfgr 
 order by p_mfgr, p_name
@@ -3377,7 +3377,7 @@ explain extended
 select p_mfgr, p_name, p_size, 
 rank() over (partition by p_mfgr order by p_name) as r, 
 dense_rank() over (partition by p_mfgr order by p_name) as dr, 
-sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row)  as s1
+round(sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row),2) as s1
 from noop(on noopwithmap(on noop(on part_orc 
 partition by p_mfgr 
 order by p_mfgr, p_name
@@ -3682,7 +3682,7 @@ STAGE PLANS:
                         window frame: PRECEDING(MAX)~CURRENT
             Statistics: Num rows: 26 Data size: 16042 Basic stats: COMPLETE Column stats: NONE
             Select Operator
-              expressions: _col2 (type: string), _col1 (type: string), _col5 (type: int), rank_window_0 (type: int), dense_rank_window_1 (type: int), sum_window_2 (type: double)
+              expressions: _col2 (type: string), _col1 (type: string), _col5 (type: int), rank_window_0 (type: int), dense_rank_window_1 (type: int), round(sum_window_2, 2) (type: double)
               outputColumnNames: _col0, _col1, _col2, _col3, _col4, _col5
               Statistics: Num rows: 26 Data size: 16042 Basic stats: COMPLETE Column stats: NONE
               File Output Operator
@@ -3717,7 +3717,7 @@ STAGE PLANS:
 PREHOOK: query: select p_mfgr, p_name, p_size, 
 rank() over (partition by p_mfgr order by p_name) as r, 
 dense_rank() over (partition by p_mfgr order by p_name) as dr, 
-sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row)  as s1
+round(sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row),2) as s1
 from noop(on noopwithmap(on noop(on part_orc 
 partition by p_mfgr 
 order by p_mfgr, p_name
@@ -3728,7 +3728,7 @@ PREHOOK: Input: default@part_orc
 POSTHOOK: query: select p_mfgr, p_name, p_size, 
 rank() over (partition by p_mfgr order by p_name) as r, 
 dense_rank() over (partition by p_mfgr order by p_name) as dr, 
-sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row)  as s1
+round(sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row),2) as s1
 from noop(on noopwithmap(on noop(on part_orc 
 partition by p_mfgr 
 order by p_mfgr, p_name
@@ -3739,12 +3739,12 @@ POSTHOOK: Input: default@part_orc
 Manufacturer#1	almond antique burnished rose metallic	2	1	1	1173.15
 Manufacturer#1	almond antique burnished rose metallic	2	1	1	2346.3
 Manufacturer#1	almond antique chartreuse lavender yellow	34	3	2	4100.06
-Manufacturer#1	almond antique salmon chartreuse burlywood	6	4	3	5702.650000000001
-Manufacturer#1	almond aquamarine burnished black steel	28	5	4	7117.070000000001
-Manufacturer#1	almond aquamarine pink moccasin thistle	42	6	5	8749.730000000001
+Manufacturer#1	almond antique salmon chartreuse burlywood	6	4	3	5702.65
+Manufacturer#1	almond aquamarine burnished black steel	28	5	4	7117.07
+Manufacturer#1	almond aquamarine pink moccasin thistle	42	6	5	8749.73
 Manufacturer#2	almond antique violet chocolate turquoise	14	1	1	1690.68
 Manufacturer#2	almond antique violet turquoise frosted	40	2	2	3491.38
-Manufacturer#2	almond aquamarine midnight light salmon	2	3	3	5523.360000000001
+Manufacturer#2	almond aquamarine midnight light salmon	2	3	3	5523.36
 Manufacturer#2	almond aquamarine rose maroon antique	25	4	4	7222.02
 Manufacturer#2	almond aquamarine sandy cyan gainsboro	18	5	5	8923.62
 Manufacturer#3	almond antique chartreuse khaki white	17	1	1	1671.68
@@ -3756,9 +3756,9 @@ Manufacturer#4	almond antique gainsboro frosted violet	10	1	1	1620.67
 Manufacturer#4	almond antique violet mint lemon	39	2	2	2996.09
 Manufacturer#4	almond aquamarine floral ivory bisque	27	3	3	4202.35
 Manufacturer#4	almond aquamarine yellow dodger mint	7	4	4	6047.27
-Manufacturer#4	almond azure aquamarine papaya violet	12	5	5	7337.620000000001
+Manufacturer#4	almond azure aquamarine papaya violet	12	5	5	7337.62
 Manufacturer#5	almond antique blue firebrick mint	31	1	1	1789.69
-Manufacturer#5	almond antique medium spring khaki	6	2	2	3401.3500000000004
+Manufacturer#5	almond antique medium spring khaki	6	2	2	3401.35
 Manufacturer#5	almond antique sky peru orange	2	3	3	5190.08
 Manufacturer#5	almond aquamarine dodger light gainsboro	46	4	4	6208.18
 Manufacturer#5	almond azure blanched chiffon midnight	23	5	5	7672.66
@@ -3770,7 +3770,7 @@ sub1.cd, sub1.s1
 from (select p_mfgr, p_name, 
 count(p_size) over (partition by p_mfgr order by p_name) as cd, 
 p_retailprice, 
-sum(p_retailprice) over w1  as s1
+round(sum(p_retailprice) over w1,2) as s1
 from noop(on part_orc 
 partition by p_mfgr 
 order by p_name) 
@@ -3785,7 +3785,7 @@ sub1.cd, sub1.s1
 from (select p_mfgr, p_name, 
 count(p_size) over (partition by p_mfgr order by p_name) as cd, 
 p_retailprice, 
-sum(p_retailprice) over w1  as s1
+round(sum(p_retailprice) over w1,2) as s1
 from noop(on part_orc 
 partition by p_mfgr 
 order by p_name) 
@@ -3974,7 +3974,7 @@ STAGE PLANS:
                         window frame: PRECEDING(2)~FOLLOWING(2)
             Statistics: Num rows: 26 Data size: 16042 Basic stats: COMPLETE Column stats: NONE
             Select Operator
-              expressions: _col2 (type: string), _col1 (type: string), count_window_0 (type: bigint), sum_window_1 (type: double)
+              expressions: _col2 (type: string), _col1 (type: string), count_window_0 (type: bigint), round(sum_window_1, 2) (type: double)
               outputColumnNames: _col0, _col1, _col2, _col3
               Statistics: Num rows: 26 Data size: 16042 Basic stats: COMPLETE Column stats: NONE
               File Output Operator
@@ -4011,7 +4011,7 @@ sub1.cd, sub1.s1
 from (select p_mfgr, p_name, 
 count(p_size) over (partition by p_mfgr order by p_name) as cd, 
 p_retailprice, 
-sum(p_retailprice) over w1  as s1
+round(sum(p_retailprice) over w1,2) as s1
 from noop(on part_orc 
 partition by p_mfgr 
 order by p_name) 
@@ -4025,7 +4025,7 @@ sub1.cd, sub1.s1
 from (select p_mfgr, p_name, 
 count(p_size) over (partition by p_mfgr order by p_name) as cd, 
 p_retailprice, 
-sum(p_retailprice) over w1  as s1
+round(sum(p_retailprice) over w1,2) as s1
 from noop(on part_orc 
 partition by p_mfgr 
 order by p_name) 
@@ -4035,31 +4035,31 @@ POSTHOOK: type: QUERY
 POSTHOOK: Input: default@part_orc
 #### A masked pattern was here ####
 Manufacturer#1	almond antique burnished rose metallic	2	4100.06
-Manufacturer#1	almond antique burnished rose metallic	2	5702.650000000001
-Manufacturer#1	almond antique chartreuse lavender yellow	3	7117.070000000001
+Manufacturer#1	almond antique burnished rose metallic	2	5702.65
+Manufacturer#1	almond antique chartreuse lavender yellow	3	7117.07
 Manufacturer#1	almond antique salmon chartreuse burlywood	4	7576.58
 Manufacturer#1	almond aquamarine burnished black steel	5	6403.43
 Manufacturer#1	almond aquamarine pink moccasin thistle	6	4649.67
-Manufacturer#2	almond antique violet chocolate turquoise	1	5523.360000000001
+Manufacturer#2	almond antique violet chocolate turquoise	1	5523.36
 Manufacturer#2	almond antique violet turquoise frosted	2	7222.02
 Manufacturer#2	almond aquamarine midnight light salmon	3	8923.62
-Manufacturer#2	almond aquamarine rose maroon antique	4	7232.9400000000005
+Manufacturer#2	almond aquamarine rose maroon antique	4	7232.94
 Manufacturer#2	almond aquamarine sandy cyan gainsboro	5	5432.24
 Manufacturer#3	almond antique chartreuse khaki white	1	4272.34
 Manufacturer#3	almond antique forest lavender goldenrod	2	6195.32
 Manufacturer#3	almond antique metallic orange dim	3	7532.61
-Manufacturer#3	almond antique misty red olive	4	5860.929999999999
+Manufacturer#3	almond antique misty red olive	4	5860.93
 Manufacturer#3	almond antique olive coral navajo	5	4670.66
 Manufacturer#4	almond antique gainsboro frosted violet	1	4202.35
 Manufacturer#4	almond antique violet mint lemon	2	6047.27
-Manufacturer#4	almond aquamarine floral ivory bisque	3	7337.620000000001
-Manufacturer#4	almond aquamarine yellow dodger mint	4	5716.950000000001
-Manufacturer#4	almond azure aquamarine papaya violet	5	4341.530000000001
+Manufacturer#4	almond aquamarine floral ivory bisque	3	7337.62
+Manufacturer#4	almond aquamarine yellow dodger mint	4	5716.95
+Manufacturer#4	almond azure aquamarine papaya violet	5	4341.53
 Manufacturer#5	almond antique blue firebrick mint	1	5190.08
 Manufacturer#5	almond antique medium spring khaki	2	6208.18
 Manufacturer#5	almond antique sky peru orange	3	7672.66
-Manufacturer#5	almond aquamarine dodger light gainsboro	4	5882.970000000001
-Manufacturer#5	almond azure blanched chiffon midnight	5	4271.3099999999995
+Manufacturer#5	almond aquamarine dodger light gainsboro	4	5882.97
+Manufacturer#5	almond azure blanched chiffon midnight	5	4271.31
 PREHOOK: query: -- 14. testPTFJoinWithWindowingWithCount
 
 explain extended
@@ -4067,7 +4067,7 @@ select abc.p_mfgr, abc.p_name,
 rank() over (distribute by abc.p_mfgr sort by abc.p_name) as r, 
 dense_rank() over (distribute by abc.p_mfgr sort by abc.p_name) as dr, 
 count(abc.p_name) over (distribute by abc.p_mfgr sort by abc.p_name) as cd, 
-abc.p_retailprice, sum(abc.p_retailprice) over (distribute by abc.p_mfgr sort by abc.p_name rows between unbounded preceding and current row) as s1, 
+abc.p_retailprice, round(sum(abc.p_retailprice) over (distribute by abc.p_mfgr sort by abc.p_name rows between unbounded preceding and current row),2) as s1,
 abc.p_size, abc.p_size - lag(abc.p_size,1,abc.p_size) over (distribute by abc.p_mfgr sort by abc.p_name) as deltaSz 
 from noop(on part_orc 
 partition by p_mfgr 
@@ -4081,7 +4081,7 @@ select abc.p_mfgr, abc.p_name,
 rank() over (distribute by abc.p_mfgr sort by abc.p_name) as r, 
 dense_rank() over (distribute by abc.p_mfgr sort by abc.p_name) as dr, 
 count(abc.p_name) over (distribute by abc.p_mfgr sort by abc.p_name) as cd, 
-abc.p_retailprice, sum(abc.p_retailprice) over (distribute by abc.p_mfgr sort by abc.p_name rows between unbounded preceding and current row) as s1, 
+abc.p_retailprice, round(sum(abc.p_retailprice) over (distribute by abc.p_mfgr sort by abc.p_name rows between unbounded preceding and current row),2) as s1,
 abc.p_size, abc.p_size - lag(abc.p_size,1,abc.p_size) over (distribute by abc.p_mfgr sort by abc.p_name) as deltaSz 
 from noop(on part_orc 
 partition by p_mfgr 
@@ -4424,7 +4424,7 @@ STAGE PLANS:
                         isPivotResult: true
             Statistics: Num rows: 28 Data size: 17646 Basic stats: COMPLETE Column stats: NONE
             Select Operator
-              expressions: _col2 (type: string), _col1 (type: string), rank_window_0 (type: int), dense_rank_window_1 (type: int), count_window_2 (type: bigint), _col7 (type: double), sum_window_3 (type: double), _col5 (type: int), (_col5 - lag_window_4) (type: int)
+              expressions: _col2 (type: string), _col1 (type: string), rank_window_0 (type: int), dense_rank_window_1 (type: int), count_window_2 (type: bigint), _col7 (type: double), round(sum_window_3, 2) (type: double), _col5 (type: int), (_col5 - lag_window_4) (type: int)
               outputColumnNames: _col0, _col1, _col2, _col3, _col4, _col5, _col6, _col7, _col8
               Statistics: Num rows: 28 Data size: 17646 Basic stats: COMPLETE Column stats: NONE
               File Output Operator
@@ -4460,7 +4460,7 @@ PREHOOK: query: select abc.p_mfgr, abc.p_name,
 rank() over (distribute by abc.p_mfgr sort by abc.p_name) as r, 
 dense_rank() over (distribute by abc.p_mfgr sort by abc.p_name) as dr, 
 count(abc.p_name) over (distribute by abc.p_mfgr sort by abc.p_name) as cd, 
-abc.p_retailprice, sum(abc.p_retailprice) over (distribute by abc.p_mfgr sort by abc.p_name rows between unbounded preceding and current row) as s1, 
+abc.p_retailprice, round(sum(abc.p_retailprice) over (distribute by abc.p_mfgr sort by abc.p_name rows between unbounded preceding and current row),2) as s1,
 abc.p_size, abc.p_size - lag(abc.p_size,1,abc.p_size) over (distribute by abc.p_mfgr sort by abc.p_name) as deltaSz 
 from noop(on part_orc 
 partition by p_mfgr 
@@ -4473,7 +4473,7 @@ POSTHOOK: query: select abc.p_mfgr, abc.p_name,
 rank() over (distribute by abc.p_mfgr sort by abc.p_name) as r, 
 dense_rank() over (distribute by abc.p_mfgr sort by abc.p_name) as dr, 
 count(abc.p_name) over (distribute by abc.p_mfgr sort by abc.p_name) as cd, 
-abc.p_retailprice, sum(abc.p_retailprice) over (distribute by abc.p_mfgr sort by abc.p_name rows between unbounded preceding and current row) as s1, 
+abc.p_retailprice, round(sum(abc.p_retailprice) over (distribute by abc.p_mfgr sort by abc.p_name rows between unbounded preceding and current row),2) as s1,
 abc.p_size, abc.p_size - lag(abc.p_size,1,abc.p_size) over (distribute by abc.p_mfgr sort by abc.p_name) as deltaSz 
 from noop(on part_orc 
 partition by p_mfgr 
@@ -4484,15 +4484,15 @@ POSTHOOK: Input: default@part_orc
 #### A masked pattern was here ####
 Manufacturer#1	almond antique burnished rose metallic	1	1	4	1173.15	1173.15	2	0
 Manufacturer#1	almond antique burnished rose metallic	1	1	4	1173.15	2346.3	2	0
-Manufacturer#1	almond antique burnished rose metallic	1	1	4	1173.15	3519.4500000000003	2	0
+Manufacturer#1	almond antique burnished rose metallic	1	1	4	1173.15	3519.45	2	0
 Manufacturer#1	almond antique burnished rose metallic	1	1	4	1173.15	4692.6	2	0
-Manufacturer#1	almond antique chartreuse lavender yellow	5	2	5	1753.76	6446.360000000001	34	32
-Manufacturer#1	almond antique salmon chartreuse burlywood	6	3	6	1602.59	8048.950000000001	6	-28
+Manufacturer#1	almond antique chartreuse lavender yellow	5	2	5	1753.76	6446.36	34	32
+Manufacturer#1	almond antique salmon chartreuse burlywood	6	3	6	1602.59	8048.95	6	-28
 Manufacturer#1	almond aquamarine burnished black steel	7	4	7	1414.42	9463.37	28	22
 Manufacturer#1	almond aquamarine pink moccasin thistle	8	5	8	1632.66	11096.03	42	14
 Manufacturer#2	almond antique violet chocolate turquoise	1	1	1	1690.68	1690.68	14	0
 Manufacturer#2	almond antique violet turquoise frosted	2	2	2	1800.7	3491.38	40	26
-Manufacturer#2	almond aquamarine midnight light salmon	3	3	3	2031.98	5523.360000000001	2	-38
+Manufacturer#2	almond aquamarine midnight light salmon	3	3	3	2031.98	5523.36	2	-38
 Manufacturer#2	almond aquamarine rose maroon antique	4	4	4	1698.66	7222.02	25	23
 Manufacturer#2	almond aquamarine sandy cyan gainsboro	5	5	5	1701.6	8923.62	18	-7
 Manufacturer#3	almond antique chartreuse khaki white	1	1	1	1671.68	1671.68	17	0
@@ -4504,9 +4504,9 @@ Manufacturer#4	almond antique gainsboro frosted violet	1	1	1	1620.67	1620.67	10
 Manufacturer#4	almond antique violet mint lemon	2	2	2	1375.42	2996.09	39	29
 Manufacturer#4	almond aquamarine floral ivory bisque	3	3	3	1206.26	4202.35	27	-12
 Manufacturer#4	almond aquamarine yellow dodger mint	4	4	4	1844.92	6047.27	7	-20
-Manufacturer#4	almond azure aquamarine papaya violet	5	5	5	1290.35	7337.620000000001	12	5
+Manufacturer#4	almond azure aquamarine papaya violet	5	5	5	1290.35	7337.62	12	5
 Manufacturer#5	almond antique blue firebrick mint	1	1	1	1789.69	1789.69	31	0
-Manufacturer#5	almond antique medium spring khaki	2	2	2	1611.66	3401.3500000000004	6	-25
+Manufacturer#5	almond antique medium spring khaki	2	2	2	1611.66	3401.35	6	-25
 Manufacturer#5	almond antique sky peru orange	3	3	3	1788.73	5190.08	2	-4
 Manufacturer#5	almond aquamarine dodger light gainsboro	4	4	4	1018.1	6208.18	46	44
 Manufacturer#5	almond azure blanched chiffon midnight	5	5	5	1464.48	7672.66	23	-23
@@ -4761,7 +4761,7 @@ Manufacturer#5	almond azure blanched chiffon midnight	23
 PREHOOK: query: -- 16. testViewAsTableInputToPTF
 create view IF NOT EXISTS mfgr_price_view as 
 select p_mfgr, p_brand, 
-sum(p_retailprice) as s 
+round(sum(p_retailprice),2) as s
 from part_orc 
 group by p_mfgr, p_brand
 PREHOOK: type: CREATEVIEW
@@ -4771,7 +4771,7 @@ PREHOOK: Output: default@mfgr_price_view
 POSTHOOK: query: -- 16. testViewAsTableInputToPTF
 create view IF NOT EXISTS mfgr_price_view as 
 select p_mfgr, p_brand, 
-sum(p_retailprice) as s 
+round(sum(p_retailprice),2) as s
 from part_orc 
 group by p_mfgr, p_brand
 POSTHOOK: type: CREATEVIEW
@@ -4780,7 +4780,7 @@ POSTHOOK: Output: database:default
 POSTHOOK: Output: default@mfgr_price_view
 PREHOOK: query: explain extended
 select p_mfgr, p_brand, s, 
-sum(s) over w1  as s1
+round(sum(s) over w1,2) as s1
 from noop(on mfgr_price_view 
 partition by p_mfgr 
 order by p_mfgr)  
@@ -4788,7 +4788,7 @@ window w1 as ( partition by p_mfgr order by p_brand rows between 2 preceding and
 PREHOOK: type: QUERY
 POSTHOOK: query: explain extended
 select p_mfgr, p_brand, s, 
-sum(s) over w1  as s1
+round(sum(s) over w1,2) as s1
 from noop(on mfgr_price_view 
 partition by p_mfgr 
 order by p_mfgr)  
@@ -4884,37 +4884,41 @@ STAGE PLANS:
           mode: mergepartial
           outputColumnNames: _col0, _col1, _col2
           Statistics: Num rows: 13 Data size: 8021 Basic stats: COMPLETE Column stats: NONE
-          PTF Operator
-            Function definitions:
-                Input definition
-                  input alias: mfgr_price_view
-                  output shape: _col0: string, _col1: string, _col2: double
-                  type: TABLE
-                Partition table definition
-                  input alias: ptf_1
-                  name: noop
-                  order by: _col0 ASC NULLS FIRST
-                  output shape: _col0: string, _col1: string, _col2: double
-                  partition by: _col0
-                  raw input shape:
+          Select Operator
+            expressions: _col0 (type: string), _col1 (type: string), round(_col2, 2) (type: double)
+            outputColumnNames: _col0, _col1, _col2
             Statistics: Num rows: 13 Data size: 8021 Basic stats: COMPLETE Column stats: NONE
-            File Output Operator
-              compressed: false
-              GlobalTableId: 0
+            PTF Operator
+              Function definitions:
+                  Input definition
+                    input alias: mfgr_price_view
+                    output shape: _col0: string, _col1: string, _col2: double
+                    type: TABLE
+                  Partition table definition
+                    input alias: ptf_1
+                    name: noop
+                    order by: _col0 ASC NULLS FIRST
+                    output shape: _col0: string, _col1: string, _col2: double
+                    partition by: _col0
+                    raw input shape:
+              Statistics: Num rows: 13 Data size: 8021 Basic stats: COMPLETE Column stats: NONE
+              File Output Operator
+                compressed: false
+                GlobalTableId: 0
 #### A masked pattern was here ####
-              NumFilesPerFileSink: 1
-              table:
-                  input format: org.apache.hadoop.mapred.SequenceFileInputFormat
-                  output format: org.apache.hadoop.hive.ql.io.HiveSequenceFileOutputFormat
-                  properties:
-                    columns _col0,_col1,_col2
-                    columns.types string,string,double
-                    escape.delim \
-                    serialization.lib org.apache.hadoop.hive.serde2.lazybinary.LazyBinarySerDe
-                  serde: org.apache.hadoop.hive.serde2.lazybinary.LazyBinarySerDe
-              TotalFiles: 1
-              GatherStats: false
-              MultiFileSpray: false
+                NumFilesPerFileSink: 1
+                table:
+                    input format: org.apache.hadoop.mapred.SequenceFileInputFormat
+                    output format: org.apache.hadoop.hive.ql.io.HiveSequenceFileOutputFormat
+                    properties:
+                      columns _col0,_col1,_col2
+                      columns.types string,string,double
+                      escape.delim \
+                      serialization.lib org.apache.hadoop.hive.serde2.lazybinary.LazyBinarySerDe
+                    serde: org.apache.hadoop.hive.serde2.lazybinary.LazyBinarySerDe
+                TotalFiles: 1
+                GatherStats: false
+                MultiFileSpray: false
 
   Stage: Stage-2
     Map Reduce
@@ -4982,7 +4986,7 @@ STAGE PLANS:
                         window frame: PRECEDING(2)~CURRENT
             Statistics: Num rows: 13 Data size: 8021 Basic stats: COMPLETE Column stats: NONE
             Select Operator
-              expressions: _col0 (type: string), _col1 (type: string), _col2 (type: double), sum_window_0 (type: double)
+              expressions: _col0 (type: string), _col1 (type: string), _col2 (type: double), round(sum_window_0, 2) (type: double)
               outputColumnNames: _col0, _col1, _col2, _col3
               Statistics: Num rows: 13 Data size: 8021 Basic stats: COMPLETE Column stats: NONE
               File Output Operator
@@ -5015,7 +5019,7 @@ STAGE PLANS:
         ListSink
 
 PREHOOK: query: select p_mfgr, p_brand, s, 
-sum(s) over w1  as s1
+round(sum(s) over w1,2) as s1
 from noop(on mfgr_price_view 
 partition by p_mfgr 
 order by p_mfgr)  
@@ -5025,7 +5029,7 @@ PREHOOK: Input: default@mfgr_price_view
 PREHOOK: Input: default@part_orc
 #### A masked pattern was here ####
 POSTHOOK: query: select p_mfgr, p_brand, s, 
-sum(s) over w1  as s1
+round(sum(s) over w1,2) as s1
 from noop(on mfgr_price_view 
 partition by p_mfgr 
 order by p_mfgr)  
@@ -5038,15 +5042,15 @@ Manufacturer#1	Brand#12	4800.84	4800.84
 Manufacturer#1	Brand#14	2346.3	7147.14
 Manufacturer#1	Brand#15	1602.59	8749.73
 Manufacturer#2	Brand#22	3491.38	3491.38
-Manufacturer#2	Brand#23	2031.98	5523.360000000001
+Manufacturer#2	Brand#23	2031.98	5523.36
 Manufacturer#2	Brand#24	1698.66	7222.02
-Manufacturer#2	Brand#25	1701.6	5432.240000000001
+Manufacturer#2	Brand#25	1701.6	5432.24
 Manufacturer#3	Brand#31	1671.68	1671.68
 Manufacturer#3	Brand#32	3333.37	5005.05
 Manufacturer#3	Brand#34	1337.29	6342.34
 Manufacturer#3	Brand#35	1190.27	5860.93
-Manufacturer#4	Brand#41	4755.9400000000005	4755.9400000000005
-Manufacturer#4	Brand#42	2581.6800000000003	7337.620000000001
+Manufacturer#4	Brand#41	4755.94	4755.94
+Manufacturer#4	Brand#42	2581.68	7337.62
 Manufacturer#5	Brand#51	1611.66	1611.66
 Manufacturer#5	Brand#52	3254.17	4865.83
 Manufacturer#5	Brand#53	2806.83	7672.66
@@ -5103,7 +5107,7 @@ order by p_name)
 INSERT OVERWRITE TABLE part_4 select p_mfgr, p_name, p_size, 
 rank() over (distribute by p_mfgr sort by p_name) as r, 
 dense_rank() over (distribute by p_mfgr sort by p_name) as dr, 
-sum(p_retailprice) over (distribute by p_mfgr sort by p_name rows between unbounded preceding and current row)  as s  
+round(sum(p_retailprice) over (distribute by p_mfgr sort by p_name rows between unbounded preceding and current row),2) as s
 INSERT OVERWRITE TABLE part_5 select  p_mfgr,p_name, p_size,  
 round(sum(p_size) over (distribute by p_mfgr sort by p_size range between 5 preceding and current row),1) as s2,
 rank() over (distribute by p_mfgr sort by p_mfgr, p_name) as r, 
@@ -5119,7 +5123,7 @@ order by p_name)
 INSERT OVERWRITE TABLE part_4 select p_mfgr, p_name, p_size, 
 rank() over (distribute by p_mfgr sort by p_name) as r, 
 dense_rank() over (distribute by p_mfgr sort by p_name) as dr, 
-sum(p_retailprice) over (distribute by p_mfgr sort by p_name rows between unbounded preceding and current row)  as s  
+round(sum(p_retailprice) over (distribute by p_mfgr sort by p_name rows between unbounded preceding and current row),2) as s
 INSERT OVERWRITE TABLE part_5 select  p_mfgr,p_name, p_size,  
 round(sum(p_size) over (distribute by p_mfgr sort by p_size range between 5 preceding and current row),1) as s2,
 rank() over (distribute by p_mfgr sort by p_mfgr, p_name) as r, 
@@ -5340,7 +5344,7 @@ STAGE PLANS:
                         window frame: PRECEDING(MAX)~CURRENT
             Statistics: Num rows: 26 Data size: 16042 Basic stats: COMPLETE Column stats: NONE
             Select Operator
-              expressions: _col2 (type: string), _col1 (type: string), _col5 (type: int), rank_window_0 (type: int), dense_rank_window_1 (type: int), sum_window_2 (type: double)
+              expressions: _col2 (type: string), _col1 (type: string), _col5 (type: int), rank_window_0 (type: int), dense_rank_window_1 (type: int), round(sum_window_2, 2) (type: double)
               outputColumnNames: _col0, _col1, _col2, _col3, _col4, _col5
               Statistics: Num rows: 26 Data size: 16042 Basic stats: COMPLETE Column stats: NONE
               File Output Operator
@@ -5652,7 +5656,7 @@ order by p_name)
 INSERT OVERWRITE TABLE part_4 select p_mfgr, p_name, p_size, 
 rank() over (distribute by p_mfgr sort by p_name) as r, 
 dense_rank() over (distribute by p_mfgr sort by p_name) as dr, 
-sum(p_retailprice) over (distribute by p_mfgr sort by p_name rows between unbounded preceding and current row)  as s  
+round(sum(p_retailprice) over (distribute by p_mfgr sort by p_name rows between unbounded preceding and current row),2) as s
 INSERT OVERWRITE TABLE part_5 select  p_mfgr,p_name, p_size,  
 round(sum(p_size) over (distribute by p_mfgr sort by p_size range between 5 preceding and current row),1) as s2,
 rank() over (distribute by p_mfgr sort by p_mfgr, p_name) as r, 
@@ -5670,7 +5674,7 @@ order by p_name)
 INSERT OVERWRITE TABLE part_4 select p_mfgr, p_name, p_size, 
 rank() over (distribute by p_mfgr sort by p_name) as r, 
 dense_rank() over (distribute by p_mfgr sort by p_name) as dr, 
-sum(p_retailprice) over (distribute by p_mfgr sort by p_name rows between unbounded preceding and current row)  as s  
+round(sum(p_retailprice) over (distribute by p_mfgr sort by p_name rows between unbounded preceding and current row),2) as s
 INSERT OVERWRITE TABLE part_5 select  p_mfgr,p_name, p_size,  
 round(sum(p_size) over (distribute by p_mfgr sort by p_size range between 5 preceding and current row),1) as s2,
 rank() over (distribute by p_mfgr sort by p_mfgr, p_name) as r, 
@@ -5707,12 +5711,12 @@ POSTHOOK: Input: default@part_4
 Manufacturer#1	almond antique burnished rose metallic	2	1	1	1173.15
 Manufacturer#1	almond antique burnished rose metallic	2	1	1	2346.3
 Manufacturer#1	almond antique chartreuse lavender yellow	34	3	2	4100.06
-Manufacturer#1	almond antique salmon chartreuse burlywood	6	4	3	5702.650000000001
-Manufacturer#1	almond aquamarine burnished black steel	28	5	4	7117.070000000001
-Manufacturer#1	almond aquamarine pink moccasin thistle	42	6	5	8749.730000000001
+Manufacturer#1	almond antique salmon chartreuse burlywood	6	4	3	5702.65
+Manufacturer#1	almond aquamarine burnished black steel	28	5	4	7117.07
+Manufacturer#1	almond aquamarine pink moccasin thistle	42	6	5	8749.73
 Manufacturer#2	almond antique violet chocolate turquoise	14	1	1	1690.68
 Manufacturer#2	almond antique violet turquoise frosted	40	2	2	3491.38
-Manufacturer#2	almond aquamarine midnight light salmon	2	3	3	5523.360000000001
+Manufacturer#2	almond aquamarine midnight light salmon	2	3	3	5523.36
 Manufacturer#2	almond aquamarine rose maroon antique	25	4	4	7222.02
 Manufacturer#2	almond aquamarine sandy cyan gainsboro	18	5	5	8923.62
 Manufacturer#3	almond antique chartreuse khaki white	17	1	1	1671.68
@@ -5724,9 +5728,9 @@ Manufacturer#4	almond antique gainsboro frosted violet	10	1	1	1620.67
 Manufacturer#4	almond antique violet mint lemon	39	2	2	2996.09
 Manufacturer#4	almond aquamarine floral ivory bisque	27	3	3	4202.35
 Manufacturer#4	almond aquamarine yellow dodger mint	7	4	4	6047.27
-Manufacturer#4	almond azure aquamarine papaya violet	12	5	5	7337.620000000001
+Manufacturer#4	almond azure aquamarine papaya violet	12	5	5	7337.62
 Manufacturer#5	almond antique blue firebrick mint	31	1	1	1789.69
-Manufacturer#5	almond antique medium spring khaki	6	2	2	3401.3500000000004
+Manufacturer#5	almond antique medium spring khaki	6	2	2	3401.35
 Manufacturer#5	almond antique sky peru orange	2	3	3	5190.08
 Manufacturer#5	almond aquamarine dodger light gainsboro	46	4	4	6208.18
 Manufacturer#5	almond azure blanched chiffon midnight	23	5	5	7672.66


[04/13] hive git commit: HIVE-15520: Improve the sum performance for Range based window (Aihua Xu, reviewed by Yongzhi Chen)

Posted by ai...@apache.org.
http://git-wip-us.apache.org/repos/asf/hive/blob/a28b28f3/ql/src/test/results/clientpositive/spark/vectorized_ptf.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/spark/vectorized_ptf.q.out b/ql/src/test/results/clientpositive/spark/vectorized_ptf.q.out
index 9ab7a0b..c1cf0e8 100644
--- a/ql/src/test/results/clientpositive/spark/vectorized_ptf.q.out
+++ b/ql/src/test/results/clientpositive/spark/vectorized_ptf.q.out
@@ -124,7 +124,7 @@ explain extended
 select p_mfgr, p_name, p_size,
 rank() over (partition by p_mfgr order by p_name) as r,
 dense_rank() over (partition by p_mfgr order by p_name) as dr,
-sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row) as s1
+round(sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row),2) as s1
 from noop(on part_orc 
   partition by p_mfgr
   order by p_name
@@ -136,7 +136,7 @@ explain extended
 select p_mfgr, p_name, p_size,
 rank() over (partition by p_mfgr order by p_name) as r,
 dense_rank() over (partition by p_mfgr order by p_name) as dr,
-sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row) as s1
+round(sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row),2) as s1
 from noop(on part_orc 
   partition by p_mfgr
   order by p_name
@@ -291,7 +291,7 @@ STAGE PLANS:
                               window frame: PRECEDING(MAX)~CURRENT
                   Statistics: Num rows: 26 Data size: 16042 Basic stats: COMPLETE Column stats: NONE
                   Select Operator
-                    expressions: _col2 (type: string), _col1 (type: string), _col5 (type: int), rank_window_0 (type: int), dense_rank_window_1 (type: int), sum_window_2 (type: double)
+                    expressions: _col2 (type: string), _col1 (type: string), _col5 (type: int), rank_window_0 (type: int), dense_rank_window_1 (type: int), round(sum_window_2, 2) (type: double)
                     outputColumnNames: _col0, _col1, _col2, _col3, _col4, _col5
                     Statistics: Num rows: 26 Data size: 16042 Basic stats: COMPLETE Column stats: NONE
                     File Output Operator
@@ -886,7 +886,7 @@ explain extended
 select p_mfgr, p_name, p_size,
 rank() over (partition by p_mfgr order by p_name) as r,
 dense_rank() over (partition by p_mfgr order by p_name) as dr,
-sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row) as s1
+round(sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row),2) as s1
 from noop(on part_orc 
   partition by p_mfgr
   order by p_name
@@ -898,7 +898,7 @@ explain extended
 select p_mfgr, p_name, p_size,
 rank() over (partition by p_mfgr order by p_name) as r,
 dense_rank() over (partition by p_mfgr order by p_name) as dr,
-sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row) as s1
+round(sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row),2) as s1
 from noop(on part_orc 
   partition by p_mfgr
   order by p_name
@@ -1053,7 +1053,7 @@ STAGE PLANS:
                               window frame: PRECEDING(MAX)~CURRENT
                   Statistics: Num rows: 26 Data size: 16042 Basic stats: COMPLETE Column stats: NONE
                   Select Operator
-                    expressions: _col2 (type: string), _col1 (type: string), _col5 (type: int), rank_window_0 (type: int), dense_rank_window_1 (type: int), sum_window_2 (type: double)
+                    expressions: _col2 (type: string), _col1 (type: string), _col5 (type: int), rank_window_0 (type: int), dense_rank_window_1 (type: int), round(sum_window_2, 2) (type: double)
                     outputColumnNames: _col0, _col1, _col2, _col3, _col4, _col5
                     Statistics: Num rows: 26 Data size: 16042 Basic stats: COMPLETE Column stats: NONE
                     File Output Operator
@@ -1088,7 +1088,7 @@ STAGE PLANS:
 PREHOOK: query: select p_mfgr, p_name, p_size,
 rank() over (partition by p_mfgr order by p_name) as r,
 dense_rank() over (partition by p_mfgr order by p_name) as dr,
-sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row) as s1
+round(sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row),2) as s1
 from noop(on part_orc 
   partition by p_mfgr
   order by p_name
@@ -1099,7 +1099,7 @@ PREHOOK: Input: default@part_orc
 POSTHOOK: query: select p_mfgr, p_name, p_size,
 rank() over (partition by p_mfgr order by p_name) as r,
 dense_rank() over (partition by p_mfgr order by p_name) as dr,
-sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row) as s1
+round(sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row),2) as s1
 from noop(on part_orc 
   partition by p_mfgr
   order by p_name
@@ -1110,12 +1110,12 @@ POSTHOOK: Input: default@part_orc
 Manufacturer#1	almond antique burnished rose metallic	2	1	1	1173.15
 Manufacturer#1	almond antique burnished rose metallic	2	1	1	2346.3
 Manufacturer#1	almond antique chartreuse lavender yellow	34	3	2	4100.06
-Manufacturer#1	almond antique salmon chartreuse burlywood	6	4	3	5702.650000000001
-Manufacturer#1	almond aquamarine burnished black steel	28	5	4	7117.070000000001
-Manufacturer#1	almond aquamarine pink moccasin thistle	42	6	5	8749.730000000001
+Manufacturer#1	almond antique salmon chartreuse burlywood	6	4	3	5702.65
+Manufacturer#1	almond aquamarine burnished black steel	28	5	4	7117.07
+Manufacturer#1	almond aquamarine pink moccasin thistle	42	6	5	8749.73
 Manufacturer#2	almond antique violet chocolate turquoise	14	1	1	1690.68
 Manufacturer#2	almond antique violet turquoise frosted	40	2	2	3491.38
-Manufacturer#2	almond aquamarine midnight light salmon	2	3	3	5523.360000000001
+Manufacturer#2	almond aquamarine midnight light salmon	2	3	3	5523.36
 Manufacturer#2	almond aquamarine rose maroon antique	25	4	4	7222.02
 Manufacturer#2	almond aquamarine sandy cyan gainsboro	18	5	5	8923.62
 Manufacturer#3	almond antique chartreuse khaki white	17	1	1	1671.68
@@ -1127,9 +1127,9 @@ Manufacturer#4	almond antique gainsboro frosted violet	10	1	1	1620.67
 Manufacturer#4	almond antique violet mint lemon	39	2	2	2996.09
 Manufacturer#4	almond aquamarine floral ivory bisque	27	3	3	4202.35
 Manufacturer#4	almond aquamarine yellow dodger mint	7	4	4	6047.27
-Manufacturer#4	almond azure aquamarine papaya violet	12	5	5	7337.620000000001
+Manufacturer#4	almond azure aquamarine papaya violet	12	5	5	7337.62
 Manufacturer#5	almond antique blue firebrick mint	31	1	1	1789.69
-Manufacturer#5	almond antique medium spring khaki	6	2	2	3401.3500000000004
+Manufacturer#5	almond antique medium spring khaki	6	2	2	3401.35
 Manufacturer#5	almond antique sky peru orange	2	3	3	5190.08
 Manufacturer#5	almond aquamarine dodger light gainsboro	46	4	4	6208.18
 Manufacturer#5	almond azure blanched chiffon midnight	23	5	5	7672.66
@@ -2467,7 +2467,7 @@ explain extended
 select p_mfgr, p_name, p_size,
 rank() over (partition by p_mfgr order by p_name) as r,
 dense_rank() over (partition by p_mfgr order by p_name) as dr,
-sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row) as s1
+round(sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row),2) as s1
 from noopwithmap(on part_orc 
   partition by p_mfgr
   order by p_name)
@@ -2478,7 +2478,7 @@ explain extended
 select p_mfgr, p_name, p_size,
 rank() over (partition by p_mfgr order by p_name) as r,
 dense_rank() over (partition by p_mfgr order by p_name) as dr,
-sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row) as s1
+round(sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row),2) as s1
 from noopwithmap(on part_orc 
   partition by p_mfgr
   order by p_name)
@@ -2648,7 +2648,7 @@ STAGE PLANS:
                               window frame: PRECEDING(MAX)~CURRENT
                   Statistics: Num rows: 26 Data size: 16042 Basic stats: COMPLETE Column stats: NONE
                   Select Operator
-                    expressions: _col2 (type: string), _col1 (type: string), _col5 (type: int), rank_window_0 (type: int), dense_rank_window_1 (type: int), sum_window_2 (type: double)
+                    expressions: _col2 (type: string), _col1 (type: string), _col5 (type: int), rank_window_0 (type: int), dense_rank_window_1 (type: int), round(sum_window_2, 2) (type: double)
                     outputColumnNames: _col0, _col1, _col2, _col3, _col4, _col5
                     Statistics: Num rows: 26 Data size: 16042 Basic stats: COMPLETE Column stats: NONE
                     File Output Operator
@@ -2683,7 +2683,7 @@ STAGE PLANS:
 PREHOOK: query: select p_mfgr, p_name, p_size,
 rank() over (partition by p_mfgr order by p_name) as r,
 dense_rank() over (partition by p_mfgr order by p_name) as dr,
-sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row) as s1
+round(sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row),2) as s1
 from noopwithmap(on part_orc 
   partition by p_mfgr
   order by p_name)
@@ -2693,7 +2693,7 @@ PREHOOK: Input: default@part_orc
 POSTHOOK: query: select p_mfgr, p_name, p_size,
 rank() over (partition by p_mfgr order by p_name) as r,
 dense_rank() over (partition by p_mfgr order by p_name) as dr,
-sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row) as s1
+round(sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row),2) as s1
 from noopwithmap(on part_orc 
   partition by p_mfgr
   order by p_name)
@@ -2703,12 +2703,12 @@ POSTHOOK: Input: default@part_orc
 Manufacturer#1	almond antique burnished rose metallic	2	1	1	1173.15
 Manufacturer#1	almond antique burnished rose metallic	2	1	1	2346.3
 Manufacturer#1	almond antique chartreuse lavender yellow	34	3	2	4100.06
-Manufacturer#1	almond antique salmon chartreuse burlywood	6	4	3	5702.650000000001
-Manufacturer#1	almond aquamarine burnished black steel	28	5	4	7117.070000000001
-Manufacturer#1	almond aquamarine pink moccasin thistle	42	6	5	8749.730000000001
+Manufacturer#1	almond antique salmon chartreuse burlywood	6	4	3	5702.65
+Manufacturer#1	almond aquamarine burnished black steel	28	5	4	7117.07
+Manufacturer#1	almond aquamarine pink moccasin thistle	42	6	5	8749.73
 Manufacturer#2	almond antique violet chocolate turquoise	14	1	1	1690.68
 Manufacturer#2	almond antique violet turquoise frosted	40	2	2	3491.38
-Manufacturer#2	almond aquamarine midnight light salmon	2	3	3	5523.360000000001
+Manufacturer#2	almond aquamarine midnight light salmon	2	3	3	5523.36
 Manufacturer#2	almond aquamarine rose maroon antique	25	4	4	7222.02
 Manufacturer#2	almond aquamarine sandy cyan gainsboro	18	5	5	8923.62
 Manufacturer#3	almond antique chartreuse khaki white	17	1	1	1671.68
@@ -2720,9 +2720,9 @@ Manufacturer#4	almond antique gainsboro frosted violet	10	1	1	1620.67
 Manufacturer#4	almond antique violet mint lemon	39	2	2	2996.09
 Manufacturer#4	almond aquamarine floral ivory bisque	27	3	3	4202.35
 Manufacturer#4	almond aquamarine yellow dodger mint	7	4	4	6047.27
-Manufacturer#4	almond azure aquamarine papaya violet	12	5	5	7337.620000000001
+Manufacturer#4	almond azure aquamarine papaya violet	12	5	5	7337.62
 Manufacturer#5	almond antique blue firebrick mint	31	1	1	1789.69
-Manufacturer#5	almond antique medium spring khaki	6	2	2	3401.3500000000004
+Manufacturer#5	almond antique medium spring khaki	6	2	2	3401.35
 Manufacturer#5	almond antique sky peru orange	2	3	3	5190.08
 Manufacturer#5	almond aquamarine dodger light gainsboro	46	4	4	6208.18
 Manufacturer#5	almond azure blanched chiffon midnight	23	5	5	7672.66
@@ -2732,7 +2732,7 @@ explain extended
 select p_mfgr, p_name, p_size,
 rank() over (partition by p_mfgr order by p_name) as r,
 dense_rank() over (partition by p_mfgr order by p_name) as dr,
-sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row) as s1
+round(sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row),2) as s1
 from noop(on part_orc
 partition by p_mfgr
 order by p_name)
@@ -2743,7 +2743,7 @@ explain extended
 select p_mfgr, p_name, p_size,
 rank() over (partition by p_mfgr order by p_name) as r,
 dense_rank() over (partition by p_mfgr order by p_name) as dr,
-sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row) as s1
+round(sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row),2) as s1
 from noop(on part_orc
 partition by p_mfgr
 order by p_name)
@@ -2897,7 +2897,7 @@ STAGE PLANS:
                               window frame: PRECEDING(MAX)~CURRENT
                   Statistics: Num rows: 26 Data size: 16042 Basic stats: COMPLETE Column stats: NONE
                   Select Operator
-                    expressions: _col2 (type: string), _col1 (type: string), _col5 (type: int), rank_window_0 (type: int), dense_rank_window_1 (type: int), sum_window_2 (type: double)
+                    expressions: _col2 (type: string), _col1 (type: string), _col5 (type: int), rank_window_0 (type: int), dense_rank_window_1 (type: int), round(sum_window_2, 2) (type: double)
                     outputColumnNames: _col0, _col1, _col2, _col3, _col4, _col5
                     Statistics: Num rows: 26 Data size: 16042 Basic stats: COMPLETE Column stats: NONE
                     File Output Operator
@@ -2932,7 +2932,7 @@ STAGE PLANS:
 PREHOOK: query: select p_mfgr, p_name, p_size,
 rank() over (partition by p_mfgr order by p_name) as r,
 dense_rank() over (partition by p_mfgr order by p_name) as dr,
-sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row) as s1
+round(sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row),2) as s1
 from noop(on part_orc
 partition by p_mfgr
 order by p_name)
@@ -2942,7 +2942,7 @@ PREHOOK: Input: default@part_orc
 POSTHOOK: query: select p_mfgr, p_name, p_size,
 rank() over (partition by p_mfgr order by p_name) as r,
 dense_rank() over (partition by p_mfgr order by p_name) as dr,
-sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row) as s1
+round(sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row),2) as s1
 from noop(on part_orc
 partition by p_mfgr
 order by p_name)
@@ -2952,12 +2952,12 @@ POSTHOOK: Input: default@part_orc
 Manufacturer#1	almond antique burnished rose metallic	2	1	1	1173.15
 Manufacturer#1	almond antique burnished rose metallic	2	1	1	2346.3
 Manufacturer#1	almond antique chartreuse lavender yellow	34	3	2	4100.06
-Manufacturer#1	almond antique salmon chartreuse burlywood	6	4	3	5702.650000000001
-Manufacturer#1	almond aquamarine burnished black steel	28	5	4	7117.070000000001
-Manufacturer#1	almond aquamarine pink moccasin thistle	42	6	5	8749.730000000001
+Manufacturer#1	almond antique salmon chartreuse burlywood	6	4	3	5702.65
+Manufacturer#1	almond aquamarine burnished black steel	28	5	4	7117.07
+Manufacturer#1	almond aquamarine pink moccasin thistle	42	6	5	8749.73
 Manufacturer#2	almond antique violet chocolate turquoise	14	1	1	1690.68
 Manufacturer#2	almond antique violet turquoise frosted	40	2	2	3491.38
-Manufacturer#2	almond aquamarine midnight light salmon	2	3	3	5523.360000000001
+Manufacturer#2	almond aquamarine midnight light salmon	2	3	3	5523.36
 Manufacturer#2	almond aquamarine rose maroon antique	25	4	4	7222.02
 Manufacturer#2	almond aquamarine sandy cyan gainsboro	18	5	5	8923.62
 Manufacturer#3	almond antique chartreuse khaki white	17	1	1	1671.68
@@ -2969,9 +2969,9 @@ Manufacturer#4	almond antique gainsboro frosted violet	10	1	1	1620.67
 Manufacturer#4	almond antique violet mint lemon	39	2	2	2996.09
 Manufacturer#4	almond aquamarine floral ivory bisque	27	3	3	4202.35
 Manufacturer#4	almond aquamarine yellow dodger mint	7	4	4	6047.27
-Manufacturer#4	almond azure aquamarine papaya violet	12	5	5	7337.620000000001
+Manufacturer#4	almond azure aquamarine papaya violet	12	5	5	7337.62
 Manufacturer#5	almond antique blue firebrick mint	31	1	1	1789.69
-Manufacturer#5	almond antique medium spring khaki	6	2	2	3401.3500000000004
+Manufacturer#5	almond antique medium spring khaki	6	2	2	3401.35
 Manufacturer#5	almond antique sky peru orange	2	3	3	5190.08
 Manufacturer#5	almond aquamarine dodger light gainsboro	46	4	4	6208.18
 Manufacturer#5	almond azure blanched chiffon midnight	23	5	5	7672.66
@@ -2981,7 +2981,7 @@ explain extended
 select p_mfgr, p_name, p_size, 
 rank() over (partition by p_mfgr order by p_name) as r, 
 dense_rank() over (partition by p_mfgr order by p_name) as dr, 
-sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row)  as s1
+round(sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row),2) as s1
 from noop(on noopwithmap(on noop(on part_orc 
 partition by p_mfgr 
 order by p_mfgr, p_name
@@ -2993,7 +2993,7 @@ explain extended
 select p_mfgr, p_name, p_size, 
 rank() over (partition by p_mfgr order by p_name) as r, 
 dense_rank() over (partition by p_mfgr order by p_name) as dr, 
-sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row)  as s1
+round(sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row),2) as s1
 from noop(on noopwithmap(on noop(on part_orc 
 partition by p_mfgr 
 order by p_mfgr, p_name
@@ -3210,7 +3210,7 @@ STAGE PLANS:
                               window frame: PRECEDING(MAX)~CURRENT
                   Statistics: Num rows: 26 Data size: 16042 Basic stats: COMPLETE Column stats: NONE
                   Select Operator
-                    expressions: _col2 (type: string), _col1 (type: string), _col5 (type: int), rank_window_0 (type: int), dense_rank_window_1 (type: int), sum_window_2 (type: double)
+                    expressions: _col2 (type: string), _col1 (type: string), _col5 (type: int), rank_window_0 (type: int), dense_rank_window_1 (type: int), round(sum_window_2, 2) (type: double)
                     outputColumnNames: _col0, _col1, _col2, _col3, _col4, _col5
                     Statistics: Num rows: 26 Data size: 16042 Basic stats: COMPLETE Column stats: NONE
                     File Output Operator
@@ -3245,7 +3245,7 @@ STAGE PLANS:
 PREHOOK: query: select p_mfgr, p_name, p_size, 
 rank() over (partition by p_mfgr order by p_name) as r, 
 dense_rank() over (partition by p_mfgr order by p_name) as dr, 
-sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row)  as s1
+round(sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row),2) as s1
 from noop(on noopwithmap(on noop(on part_orc 
 partition by p_mfgr 
 order by p_mfgr, p_name
@@ -3256,7 +3256,7 @@ PREHOOK: Input: default@part_orc
 POSTHOOK: query: select p_mfgr, p_name, p_size, 
 rank() over (partition by p_mfgr order by p_name) as r, 
 dense_rank() over (partition by p_mfgr order by p_name) as dr, 
-sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row)  as s1
+round(sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row),2) as s1
 from noop(on noopwithmap(on noop(on part_orc 
 partition by p_mfgr 
 order by p_mfgr, p_name
@@ -3267,12 +3267,12 @@ POSTHOOK: Input: default@part_orc
 Manufacturer#1	almond antique burnished rose metallic	2	1	1	1173.15
 Manufacturer#1	almond antique burnished rose metallic	2	1	1	2346.3
 Manufacturer#1	almond antique chartreuse lavender yellow	34	3	2	4100.06
-Manufacturer#1	almond antique salmon chartreuse burlywood	6	4	3	5702.650000000001
-Manufacturer#1	almond aquamarine burnished black steel	28	5	4	7117.070000000001
-Manufacturer#1	almond aquamarine pink moccasin thistle	42	6	5	8749.730000000001
+Manufacturer#1	almond antique salmon chartreuse burlywood	6	4	3	5702.65
+Manufacturer#1	almond aquamarine burnished black steel	28	5	4	7117.07
+Manufacturer#1	almond aquamarine pink moccasin thistle	42	6	5	8749.73
 Manufacturer#2	almond antique violet chocolate turquoise	14	1	1	1690.68
 Manufacturer#2	almond antique violet turquoise frosted	40	2	2	3491.38
-Manufacturer#2	almond aquamarine midnight light salmon	2	3	3	5523.360000000001
+Manufacturer#2	almond aquamarine midnight light salmon	2	3	3	5523.36
 Manufacturer#2	almond aquamarine rose maroon antique	25	4	4	7222.02
 Manufacturer#2	almond aquamarine sandy cyan gainsboro	18	5	5	8923.62
 Manufacturer#3	almond antique chartreuse khaki white	17	1	1	1671.68
@@ -3284,9 +3284,9 @@ Manufacturer#4	almond antique gainsboro frosted violet	10	1	1	1620.67
 Manufacturer#4	almond antique violet mint lemon	39	2	2	2996.09
 Manufacturer#4	almond aquamarine floral ivory bisque	27	3	3	4202.35
 Manufacturer#4	almond aquamarine yellow dodger mint	7	4	4	6047.27
-Manufacturer#4	almond azure aquamarine papaya violet	12	5	5	7337.620000000001
+Manufacturer#4	almond azure aquamarine papaya violet	12	5	5	7337.62
 Manufacturer#5	almond antique blue firebrick mint	31	1	1	1789.69
-Manufacturer#5	almond antique medium spring khaki	6	2	2	3401.3500000000004
+Manufacturer#5	almond antique medium spring khaki	6	2	2	3401.35
 Manufacturer#5	almond antique sky peru orange	2	3	3	5190.08
 Manufacturer#5	almond aquamarine dodger light gainsboro	46	4	4	6208.18
 Manufacturer#5	almond azure blanched chiffon midnight	23	5	5	7672.66
@@ -3298,7 +3298,7 @@ sub1.cd, sub1.s1
 from (select p_mfgr, p_name, 
 count(p_size) over (partition by p_mfgr order by p_name) as cd, 
 p_retailprice, 
-sum(p_retailprice) over w1  as s1
+round(sum(p_retailprice) over w1,2) as s1
 from noop(on part_orc 
 partition by p_mfgr 
 order by p_name) 
@@ -3313,7 +3313,7 @@ sub1.cd, sub1.s1
 from (select p_mfgr, p_name, 
 count(p_size) over (partition by p_mfgr order by p_name) as cd, 
 p_retailprice, 
-sum(p_retailprice) over w1  as s1
+round(sum(p_retailprice) over w1,2) as s1
 from noop(on part_orc 
 partition by p_mfgr 
 order by p_name) 
@@ -3461,7 +3461,7 @@ STAGE PLANS:
                               window frame: PRECEDING(2)~FOLLOWING(2)
                   Statistics: Num rows: 26 Data size: 16042 Basic stats: COMPLETE Column stats: NONE
                   Select Operator
-                    expressions: _col2 (type: string), _col1 (type: string), count_window_0 (type: bigint), sum_window_1 (type: double)
+                    expressions: _col2 (type: string), _col1 (type: string), count_window_0 (type: bigint), round(sum_window_1, 2) (type: double)
                     outputColumnNames: _col0, _col1, _col2, _col3
                     Statistics: Num rows: 26 Data size: 16042 Basic stats: COMPLETE Column stats: NONE
                     File Output Operator
@@ -3498,7 +3498,7 @@ sub1.cd, sub1.s1
 from (select p_mfgr, p_name, 
 count(p_size) over (partition by p_mfgr order by p_name) as cd, 
 p_retailprice, 
-sum(p_retailprice) over w1  as s1
+round(sum(p_retailprice) over w1,2) as s1
 from noop(on part_orc 
 partition by p_mfgr 
 order by p_name) 
@@ -3512,7 +3512,7 @@ sub1.cd, sub1.s1
 from (select p_mfgr, p_name, 
 count(p_size) over (partition by p_mfgr order by p_name) as cd, 
 p_retailprice, 
-sum(p_retailprice) over w1  as s1
+round(sum(p_retailprice) over w1,2) as s1
 from noop(on part_orc 
 partition by p_mfgr 
 order by p_name) 
@@ -3522,31 +3522,31 @@ POSTHOOK: type: QUERY
 POSTHOOK: Input: default@part_orc
 #### A masked pattern was here ####
 Manufacturer#1	almond antique burnished rose metallic	2	4100.06
-Manufacturer#1	almond antique burnished rose metallic	2	5702.650000000001
-Manufacturer#1	almond antique chartreuse lavender yellow	3	7117.070000000001
+Manufacturer#1	almond antique burnished rose metallic	2	5702.65
+Manufacturer#1	almond antique chartreuse lavender yellow	3	7117.07
 Manufacturer#1	almond antique salmon chartreuse burlywood	4	7576.58
 Manufacturer#1	almond aquamarine burnished black steel	5	6403.43
 Manufacturer#1	almond aquamarine pink moccasin thistle	6	4649.67
-Manufacturer#2	almond antique violet chocolate turquoise	1	5523.360000000001
+Manufacturer#2	almond antique violet chocolate turquoise	1	5523.36
 Manufacturer#2	almond antique violet turquoise frosted	2	7222.02
 Manufacturer#2	almond aquamarine midnight light salmon	3	8923.62
-Manufacturer#2	almond aquamarine rose maroon antique	4	7232.9400000000005
+Manufacturer#2	almond aquamarine rose maroon antique	4	7232.94
 Manufacturer#2	almond aquamarine sandy cyan gainsboro	5	5432.24
 Manufacturer#3	almond antique chartreuse khaki white	1	4272.34
 Manufacturer#3	almond antique forest lavender goldenrod	2	6195.32
 Manufacturer#3	almond antique metallic orange dim	3	7532.61
-Manufacturer#3	almond antique misty red olive	4	5860.929999999999
+Manufacturer#3	almond antique misty red olive	4	5860.93
 Manufacturer#3	almond antique olive coral navajo	5	4670.66
 Manufacturer#4	almond antique gainsboro frosted violet	1	4202.35
 Manufacturer#4	almond antique violet mint lemon	2	6047.27
-Manufacturer#4	almond aquamarine floral ivory bisque	3	7337.620000000001
-Manufacturer#4	almond aquamarine yellow dodger mint	4	5716.950000000001
-Manufacturer#4	almond azure aquamarine papaya violet	5	4341.530000000001
+Manufacturer#4	almond aquamarine floral ivory bisque	3	7337.62
+Manufacturer#4	almond aquamarine yellow dodger mint	4	5716.95
+Manufacturer#4	almond azure aquamarine papaya violet	5	4341.53
 Manufacturer#5	almond antique blue firebrick mint	1	5190.08
 Manufacturer#5	almond antique medium spring khaki	2	6208.18
 Manufacturer#5	almond antique sky peru orange	3	7672.66
-Manufacturer#5	almond aquamarine dodger light gainsboro	4	5882.970000000001
-Manufacturer#5	almond azure blanched chiffon midnight	5	4271.3099999999995
+Manufacturer#5	almond aquamarine dodger light gainsboro	4	5882.97
+Manufacturer#5	almond azure blanched chiffon midnight	5	4271.31
 PREHOOK: query: -- 14. testPTFJoinWithWindowingWithCount
 
 explain extended
@@ -3554,7 +3554,7 @@ select abc.p_mfgr, abc.p_name,
 rank() over (distribute by abc.p_mfgr sort by abc.p_name) as r, 
 dense_rank() over (distribute by abc.p_mfgr sort by abc.p_name) as dr, 
 count(abc.p_name) over (distribute by abc.p_mfgr sort by abc.p_name) as cd, 
-abc.p_retailprice, sum(abc.p_retailprice) over (distribute by abc.p_mfgr sort by abc.p_name rows between unbounded preceding and current row) as s1, 
+abc.p_retailprice, round(sum(abc.p_retailprice) over (distribute by abc.p_mfgr sort by abc.p_name rows between unbounded preceding and current row),2) as s1,
 abc.p_size, abc.p_size - lag(abc.p_size,1,abc.p_size) over (distribute by abc.p_mfgr sort by abc.p_name) as deltaSz 
 from noop(on part_orc 
 partition by p_mfgr 
@@ -3568,7 +3568,7 @@ select abc.p_mfgr, abc.p_name,
 rank() over (distribute by abc.p_mfgr sort by abc.p_name) as r, 
 dense_rank() over (distribute by abc.p_mfgr sort by abc.p_name) as dr, 
 count(abc.p_name) over (distribute by abc.p_mfgr sort by abc.p_name) as cd, 
-abc.p_retailprice, sum(abc.p_retailprice) over (distribute by abc.p_mfgr sort by abc.p_name rows between unbounded preceding and current row) as s1, 
+abc.p_retailprice, round(sum(abc.p_retailprice) over (distribute by abc.p_mfgr sort by abc.p_name rows between unbounded preceding and current row),2) as s1,
 abc.p_size, abc.p_size - lag(abc.p_size,1,abc.p_size) over (distribute by abc.p_mfgr sort by abc.p_name) as deltaSz 
 from noop(on part_orc 
 partition by p_mfgr 
@@ -3830,7 +3830,7 @@ STAGE PLANS:
                               isPivotResult: true
                   Statistics: Num rows: 28 Data size: 17646 Basic stats: COMPLETE Column stats: NONE
                   Select Operator
-                    expressions: _col2 (type: string), _col1 (type: string), rank_window_0 (type: int), dense_rank_window_1 (type: int), count_window_2 (type: bigint), _col7 (type: double), sum_window_3 (type: double), _col5 (type: int), (_col5 - lag_window_4) (type: int)
+                    expressions: _col2 (type: string), _col1 (type: string), rank_window_0 (type: int), dense_rank_window_1 (type: int), count_window_2 (type: bigint), _col7 (type: double), round(sum_window_3, 2) (type: double), _col5 (type: int), (_col5 - lag_window_4) (type: int)
                     outputColumnNames: _col0, _col1, _col2, _col3, _col4, _col5, _col6, _col7, _col8
                     Statistics: Num rows: 28 Data size: 17646 Basic stats: COMPLETE Column stats: NONE
                     File Output Operator
@@ -3866,7 +3866,7 @@ PREHOOK: query: select abc.p_mfgr, abc.p_name,
 rank() over (distribute by abc.p_mfgr sort by abc.p_name) as r, 
 dense_rank() over (distribute by abc.p_mfgr sort by abc.p_name) as dr, 
 count(abc.p_name) over (distribute by abc.p_mfgr sort by abc.p_name) as cd, 
-abc.p_retailprice, sum(abc.p_retailprice) over (distribute by abc.p_mfgr sort by abc.p_name rows between unbounded preceding and current row) as s1, 
+abc.p_retailprice, round(sum(abc.p_retailprice) over (distribute by abc.p_mfgr sort by abc.p_name rows between unbounded preceding and current row),2) as s1,
 abc.p_size, abc.p_size - lag(abc.p_size,1,abc.p_size) over (distribute by abc.p_mfgr sort by abc.p_name) as deltaSz 
 from noop(on part_orc 
 partition by p_mfgr 
@@ -3879,7 +3879,7 @@ POSTHOOK: query: select abc.p_mfgr, abc.p_name,
 rank() over (distribute by abc.p_mfgr sort by abc.p_name) as r, 
 dense_rank() over (distribute by abc.p_mfgr sort by abc.p_name) as dr, 
 count(abc.p_name) over (distribute by abc.p_mfgr sort by abc.p_name) as cd, 
-abc.p_retailprice, sum(abc.p_retailprice) over (distribute by abc.p_mfgr sort by abc.p_name rows between unbounded preceding and current row) as s1, 
+abc.p_retailprice, round(sum(abc.p_retailprice) over (distribute by abc.p_mfgr sort by abc.p_name rows between unbounded preceding and current row),2) as s1,
 abc.p_size, abc.p_size - lag(abc.p_size,1,abc.p_size) over (distribute by abc.p_mfgr sort by abc.p_name) as deltaSz 
 from noop(on part_orc 
 partition by p_mfgr 
@@ -3890,15 +3890,15 @@ POSTHOOK: Input: default@part_orc
 #### A masked pattern was here ####
 Manufacturer#1	almond antique burnished rose metallic	1	1	4	1173.15	1173.15	2	0
 Manufacturer#1	almond antique burnished rose metallic	1	1	4	1173.15	2346.3	2	0
-Manufacturer#1	almond antique burnished rose metallic	1	1	4	1173.15	3519.4500000000003	2	0
+Manufacturer#1	almond antique burnished rose metallic	1	1	4	1173.15	3519.45	2	0
 Manufacturer#1	almond antique burnished rose metallic	1	1	4	1173.15	4692.6	2	0
-Manufacturer#1	almond antique chartreuse lavender yellow	5	2	5	1753.76	6446.360000000001	34	32
-Manufacturer#1	almond antique salmon chartreuse burlywood	6	3	6	1602.59	8048.950000000001	6	-28
+Manufacturer#1	almond antique chartreuse lavender yellow	5	2	5	1753.76	6446.36	34	32
+Manufacturer#1	almond antique salmon chartreuse burlywood	6	3	6	1602.59	8048.95	6	-28
 Manufacturer#1	almond aquamarine burnished black steel	7	4	7	1414.42	9463.37	28	22
 Manufacturer#1	almond aquamarine pink moccasin thistle	8	5	8	1632.66	11096.03	42	14
 Manufacturer#2	almond antique violet chocolate turquoise	1	1	1	1690.68	1690.68	14	0
 Manufacturer#2	almond antique violet turquoise frosted	2	2	2	1800.7	3491.38	40	26
-Manufacturer#2	almond aquamarine midnight light salmon	3	3	3	2031.98	5523.360000000001	2	-38
+Manufacturer#2	almond aquamarine midnight light salmon	3	3	3	2031.98	5523.36	2	-38
 Manufacturer#2	almond aquamarine rose maroon antique	4	4	4	1698.66	7222.02	25	23
 Manufacturer#2	almond aquamarine sandy cyan gainsboro	5	5	5	1701.6	8923.62	18	-7
 Manufacturer#3	almond antique chartreuse khaki white	1	1	1	1671.68	1671.68	17	0
@@ -3910,9 +3910,9 @@ Manufacturer#4	almond antique gainsboro frosted violet	1	1	1	1620.67	1620.67	10
 Manufacturer#4	almond antique violet mint lemon	2	2	2	1375.42	2996.09	39	29
 Manufacturer#4	almond aquamarine floral ivory bisque	3	3	3	1206.26	4202.35	27	-12
 Manufacturer#4	almond aquamarine yellow dodger mint	4	4	4	1844.92	6047.27	7	-20
-Manufacturer#4	almond azure aquamarine papaya violet	5	5	5	1290.35	7337.620000000001	12	5
+Manufacturer#4	almond azure aquamarine papaya violet	5	5	5	1290.35	7337.62	12	5
 Manufacturer#5	almond antique blue firebrick mint	1	1	1	1789.69	1789.69	31	0
-Manufacturer#5	almond antique medium spring khaki	2	2	2	1611.66	3401.3500000000004	6	-25
+Manufacturer#5	almond antique medium spring khaki	2	2	2	1611.66	3401.35	6	-25
 Manufacturer#5	almond antique sky peru orange	3	3	3	1788.73	5190.08	2	-4
 Manufacturer#5	almond aquamarine dodger light gainsboro	4	4	4	1018.1	6208.18	46	44
 Manufacturer#5	almond azure blanched chiffon midnight	5	5	5	1464.48	7672.66	23	-23
@@ -4127,7 +4127,7 @@ Manufacturer#5	almond azure blanched chiffon midnight	23
 PREHOOK: query: -- 16. testViewAsTableInputToPTF
 create view IF NOT EXISTS mfgr_price_view as 
 select p_mfgr, p_brand, 
-sum(p_retailprice) as s 
+round(sum(p_retailprice),2) as s
 from part_orc 
 group by p_mfgr, p_brand
 PREHOOK: type: CREATEVIEW
@@ -4137,7 +4137,7 @@ PREHOOK: Output: default@mfgr_price_view
 POSTHOOK: query: -- 16. testViewAsTableInputToPTF
 create view IF NOT EXISTS mfgr_price_view as 
 select p_mfgr, p_brand, 
-sum(p_retailprice) as s 
+round(sum(p_retailprice),2) as s
 from part_orc 
 group by p_mfgr, p_brand
 POSTHOOK: type: CREATEVIEW
@@ -4146,7 +4146,7 @@ POSTHOOK: Output: database:default
 POSTHOOK: Output: default@mfgr_price_view
 PREHOOK: query: explain extended
 select p_mfgr, p_brand, s, 
-sum(s) over w1  as s1
+round(sum(s) over w1,2) as s1
 from noop(on mfgr_price_view 
 partition by p_mfgr 
 order by p_mfgr)  
@@ -4154,7 +4154,7 @@ window w1 as ( partition by p_mfgr order by p_brand rows between 2 preceding and
 PREHOOK: type: QUERY
 POSTHOOK: query: explain extended
 select p_mfgr, p_brand, s, 
-sum(s) over w1  as s1
+round(sum(s) over w1,2) as s1
 from noop(on mfgr_price_view 
 partition by p_mfgr 
 order by p_mfgr)  
@@ -4256,29 +4256,33 @@ STAGE PLANS:
                 mode: mergepartial
                 outputColumnNames: _col0, _col1, _col2
                 Statistics: Num rows: 13 Data size: 8021 Basic stats: COMPLETE Column stats: NONE
-                PTF Operator
-                  Function definitions:
-                      Input definition
-                        input alias: mfgr_price_view
-                        output shape: _col0: string, _col1: string, _col2: double
-                        type: TABLE
-                      Partition table definition
-                        input alias: ptf_1
-                        name: noop
-                        order by: _col0 ASC NULLS FIRST
-                        output shape: _col0: string, _col1: string, _col2: double
-                        partition by: _col0
-                        raw input shape:
+                Select Operator
+                  expressions: _col0 (type: string), _col1 (type: string), round(_col2, 2) (type: double)
+                  outputColumnNames: _col0, _col1, _col2
                   Statistics: Num rows: 13 Data size: 8021 Basic stats: COMPLETE Column stats: NONE
-                  Reduce Output Operator
-                    key expressions: _col0 (type: string), _col1 (type: string)
-                    null sort order: aa
-                    sort order: ++
-                    Map-reduce partition columns: _col0 (type: string)
+                  PTF Operator
+                    Function definitions:
+                        Input definition
+                          input alias: mfgr_price_view
+                          output shape: _col0: string, _col1: string, _col2: double
+                          type: TABLE
+                        Partition table definition
+                          input alias: ptf_1
+                          name: noop
+                          order by: _col0 ASC NULLS FIRST
+                          output shape: _col0: string, _col1: string, _col2: double
+                          partition by: _col0
+                          raw input shape:
                     Statistics: Num rows: 13 Data size: 8021 Basic stats: COMPLETE Column stats: NONE
-                    tag: -1
-                    value expressions: _col2 (type: double)
-                    auto parallelism: false
+                    Reduce Output Operator
+                      key expressions: _col0 (type: string), _col1 (type: string)
+                      null sort order: aa
+                      sort order: ++
+                      Map-reduce partition columns: _col0 (type: string)
+                      Statistics: Num rows: 13 Data size: 8021 Basic stats: COMPLETE Column stats: NONE
+                      tag: -1
+                      value expressions: _col2 (type: double)
+                      auto parallelism: false
         Reducer 3 
             Needs Tagging: false
             Reduce Operator Tree:
@@ -4307,7 +4311,7 @@ STAGE PLANS:
                               window frame: PRECEDING(2)~CURRENT
                   Statistics: Num rows: 13 Data size: 8021 Basic stats: COMPLETE Column stats: NONE
                   Select Operator
-                    expressions: _col0 (type: string), _col1 (type: string), _col2 (type: double), sum_window_0 (type: double)
+                    expressions: _col0 (type: string), _col1 (type: string), _col2 (type: double), round(sum_window_0, 2) (type: double)
                     outputColumnNames: _col0, _col1, _col2, _col3
                     Statistics: Num rows: 13 Data size: 8021 Basic stats: COMPLETE Column stats: NONE
                     File Output Operator
@@ -4340,7 +4344,7 @@ STAGE PLANS:
         ListSink
 
 PREHOOK: query: select p_mfgr, p_brand, s, 
-sum(s) over w1  as s1
+round(sum(s) over w1,2) as s1
 from noop(on mfgr_price_view 
 partition by p_mfgr 
 order by p_mfgr)  
@@ -4350,7 +4354,7 @@ PREHOOK: Input: default@mfgr_price_view
 PREHOOK: Input: default@part_orc
 #### A masked pattern was here ####
 POSTHOOK: query: select p_mfgr, p_brand, s, 
-sum(s) over w1  as s1
+round(sum(s) over w1,2) as s1
 from noop(on mfgr_price_view 
 partition by p_mfgr 
 order by p_mfgr)  
@@ -4363,15 +4367,15 @@ Manufacturer#1	Brand#12	4800.84	4800.84
 Manufacturer#1	Brand#14	2346.3	7147.14
 Manufacturer#1	Brand#15	1602.59	8749.73
 Manufacturer#2	Brand#22	3491.38	3491.38
-Manufacturer#2	Brand#23	2031.98	5523.360000000001
+Manufacturer#2	Brand#23	2031.98	5523.36
 Manufacturer#2	Brand#24	1698.66	7222.02
-Manufacturer#2	Brand#25	1701.6	5432.240000000001
+Manufacturer#2	Brand#25	1701.6	5432.24
 Manufacturer#3	Brand#31	1671.68	1671.68
 Manufacturer#3	Brand#32	3333.37	5005.05
 Manufacturer#3	Brand#34	1337.29	6342.34
 Manufacturer#3	Brand#35	1190.27	5860.93
-Manufacturer#4	Brand#41	4755.9400000000005	4755.9400000000005
-Manufacturer#4	Brand#42	2581.6800000000003	7337.620000000001
+Manufacturer#4	Brand#41	4755.94	4755.94
+Manufacturer#4	Brand#42	2581.68	7337.62
 Manufacturer#5	Brand#51	1611.66	1611.66
 Manufacturer#5	Brand#52	3254.17	4865.83
 Manufacturer#5	Brand#53	2806.83	7672.66
@@ -4428,7 +4432,7 @@ order by p_name)
 INSERT OVERWRITE TABLE part_4 select p_mfgr, p_name, p_size, 
 rank() over (distribute by p_mfgr sort by p_name) as r, 
 dense_rank() over (distribute by p_mfgr sort by p_name) as dr, 
-sum(p_retailprice) over (distribute by p_mfgr sort by p_name rows between unbounded preceding and current row)  as s  
+round(sum(p_retailprice) over (distribute by p_mfgr sort by p_name rows between unbounded preceding and current row),2) as s
 INSERT OVERWRITE TABLE part_5 select  p_mfgr,p_name, p_size,  
 round(sum(p_size) over (distribute by p_mfgr sort by p_size range between 5 preceding and current row),1) as s2,
 rank() over (distribute by p_mfgr sort by p_mfgr, p_name) as r, 
@@ -4444,7 +4448,7 @@ order by p_name)
 INSERT OVERWRITE TABLE part_4 select p_mfgr, p_name, p_size, 
 rank() over (distribute by p_mfgr sort by p_name) as r, 
 dense_rank() over (distribute by p_mfgr sort by p_name) as dr, 
-sum(p_retailprice) over (distribute by p_mfgr sort by p_name rows between unbounded preceding and current row)  as s  
+round(sum(p_retailprice) over (distribute by p_mfgr sort by p_name rows between unbounded preceding and current row),2) as s
 INSERT OVERWRITE TABLE part_5 select  p_mfgr,p_name, p_size,  
 round(sum(p_size) over (distribute by p_mfgr sort by p_size range between 5 preceding and current row),1) as s2,
 rank() over (distribute by p_mfgr sort by p_mfgr, p_name) as r, 
@@ -4578,7 +4582,7 @@ STAGE PLANS:
                               window frame: PRECEDING(MAX)~CURRENT
                   Statistics: Num rows: 26 Data size: 16042 Basic stats: COMPLETE Column stats: NONE
                   Select Operator
-                    expressions: _col2 (type: string), _col1 (type: string), _col5 (type: int), rank_window_0 (type: int), dense_rank_window_1 (type: int), sum_window_2 (type: double)
+                    expressions: _col2 (type: string), _col1 (type: string), _col5 (type: int), rank_window_0 (type: int), dense_rank_window_1 (type: int), round(sum_window_2, 2) (type: double)
                     outputColumnNames: _col0, _col1, _col2, _col3, _col4, _col5
                     Statistics: Num rows: 26 Data size: 16042 Basic stats: COMPLETE Column stats: NONE
                     File Output Operator
@@ -4860,7 +4864,7 @@ order by p_name)
 INSERT OVERWRITE TABLE part_4 select p_mfgr, p_name, p_size, 
 rank() over (distribute by p_mfgr sort by p_name) as r, 
 dense_rank() over (distribute by p_mfgr sort by p_name) as dr, 
-sum(p_retailprice) over (distribute by p_mfgr sort by p_name rows between unbounded preceding and current row)  as s  
+round(sum(p_retailprice) over (distribute by p_mfgr sort by p_name rows between unbounded preceding and current row),2) as s
 INSERT OVERWRITE TABLE part_5 select  p_mfgr,p_name, p_size,  
 round(sum(p_size) over (distribute by p_mfgr sort by p_size range between 5 preceding and current row),1) as s2,
 rank() over (distribute by p_mfgr sort by p_mfgr, p_name) as r, 
@@ -4878,7 +4882,7 @@ order by p_name)
 INSERT OVERWRITE TABLE part_4 select p_mfgr, p_name, p_size, 
 rank() over (distribute by p_mfgr sort by p_name) as r, 
 dense_rank() over (distribute by p_mfgr sort by p_name) as dr, 
-sum(p_retailprice) over (distribute by p_mfgr sort by p_name rows between unbounded preceding and current row)  as s  
+round(sum(p_retailprice) over (distribute by p_mfgr sort by p_name rows between unbounded preceding and current row),2) as s
 INSERT OVERWRITE TABLE part_5 select  p_mfgr,p_name, p_size,  
 round(sum(p_size) over (distribute by p_mfgr sort by p_size range between 5 preceding and current row),1) as s2,
 rank() over (distribute by p_mfgr sort by p_mfgr, p_name) as r, 
@@ -4915,12 +4919,12 @@ POSTHOOK: Input: default@part_4
 Manufacturer#1	almond antique burnished rose metallic	2	1	1	1173.15
 Manufacturer#1	almond antique burnished rose metallic	2	1	1	2346.3
 Manufacturer#1	almond antique chartreuse lavender yellow	34	3	2	4100.06
-Manufacturer#1	almond antique salmon chartreuse burlywood	6	4	3	5702.650000000001
-Manufacturer#1	almond aquamarine burnished black steel	28	5	4	7117.070000000001
-Manufacturer#1	almond aquamarine pink moccasin thistle	42	6	5	8749.730000000001
+Manufacturer#1	almond antique salmon chartreuse burlywood	6	4	3	5702.65
+Manufacturer#1	almond aquamarine burnished black steel	28	5	4	7117.07
+Manufacturer#1	almond aquamarine pink moccasin thistle	42	6	5	8749.73
 Manufacturer#2	almond antique violet chocolate turquoise	14	1	1	1690.68
 Manufacturer#2	almond antique violet turquoise frosted	40	2	2	3491.38
-Manufacturer#2	almond aquamarine midnight light salmon	2	3	3	5523.360000000001
+Manufacturer#2	almond aquamarine midnight light salmon	2	3	3	5523.36
 Manufacturer#2	almond aquamarine rose maroon antique	25	4	4	7222.02
 Manufacturer#2	almond aquamarine sandy cyan gainsboro	18	5	5	8923.62
 Manufacturer#3	almond antique chartreuse khaki white	17	1	1	1671.68
@@ -4932,9 +4936,9 @@ Manufacturer#4	almond antique gainsboro frosted violet	10	1	1	1620.67
 Manufacturer#4	almond antique violet mint lemon	39	2	2	2996.09
 Manufacturer#4	almond aquamarine floral ivory bisque	27	3	3	4202.35
 Manufacturer#4	almond aquamarine yellow dodger mint	7	4	4	6047.27
-Manufacturer#4	almond azure aquamarine papaya violet	12	5	5	7337.620000000001
+Manufacturer#4	almond azure aquamarine papaya violet	12	5	5	7337.62
 Manufacturer#5	almond antique blue firebrick mint	31	1	1	1789.69
-Manufacturer#5	almond antique medium spring khaki	6	2	2	3401.3500000000004
+Manufacturer#5	almond antique medium spring khaki	6	2	2	3401.35
 Manufacturer#5	almond antique sky peru orange	2	3	3	5190.08
 Manufacturer#5	almond aquamarine dodger light gainsboro	46	4	4	6208.18
 Manufacturer#5	almond azure blanched chiffon midnight	23	5	5	7672.66


[13/13] hive git commit: HIVE-15520: Improve the sum performance for Range based window (Aihua Xu, reviewed by Yongzhi Chen)

Posted by ai...@apache.org.
HIVE-15520: Improve the sum performance for Range based window (Aihua Xu, reviewed by Yongzhi Chen)


Project: http://git-wip-us.apache.org/repos/asf/hive/repo
Commit: http://git-wip-us.apache.org/repos/asf/hive/commit/a28b28f3
Tree: http://git-wip-us.apache.org/repos/asf/hive/tree/a28b28f3
Diff: http://git-wip-us.apache.org/repos/asf/hive/diff/a28b28f3

Branch: refs/heads/master
Commit: a28b28f3217708e9a19207920babad5562b03cef
Parents: 6973edc
Author: Aihua Xu <ai...@apache.org>
Authored: Thu Jan 5 17:12:25 2017 -0500
Committer: Aihua Xu <ai...@apache.org>
Committed: Thu Jan 12 09:23:51 2017 -0500

----------------------------------------------------------------------
 .../apache/hadoop/hive/ql/exec/PTFOperator.java |  12 +-
 .../hadoop/hive/ql/exec/PTFPartition.java       |   6 +-
 .../ql/udf/generic/GenericUDAFEvaluator.java    |  44 +
 .../hive/ql/udf/generic/GenericUDAFSum.java     |  39 +-
 .../hive/ql/udf/ptf/BasePartitionEvaluator.java | 348 ++++++++
 .../hive/ql/udf/ptf/TableFunctionEvaluator.java |   2 +-
 .../hive/ql/udf/ptf/ValueBoundaryScanner.java   | 729 +++++++++++++++
 .../hive/ql/udf/ptf/WindowingTableFunction.java | 882 +------------------
 .../queries/clientpositive/cbo_rp_windowing_2.q |  38 +-
 ql/src/test/queries/clientpositive/ptf.q        |  40 +-
 .../queries/clientpositive/vectorized_ptf.q     |  36 +-
 ql/src/test/queries/clientpositive/windowing.q  |  38 +-
 .../clientpositive/cbo_rp_windowing_2.q.out     | 357 ++++----
 .../test/results/clientpositive/leadlag.q.out   |  20 +-
 .../llap/cbo_rp_windowing_2.q.out               | 352 ++++----
 .../test/results/clientpositive/llap/ptf.q.out  | 250 +++---
 .../clientpositive/llap/vectorized_ptf.q.out    | 236 ++---
 .../results/clientpositive/llap/windowing.q.out | 352 ++++----
 ql/src/test/results/clientpositive/ptf.q.out    | 252 +++---
 .../test/results/clientpositive/spark/ptf.q.out | 250 +++---
 .../clientpositive/spark/vectorized_ptf.q.out   | 236 ++---
 .../clientpositive/spark/windowing.q.out        | 352 ++++----
 .../results/clientpositive/vectorized_ptf.q.out | 252 +++---
 .../test/results/clientpositive/windowing.q.out | 461 ++++++----
 24 files changed, 3030 insertions(+), 2554 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hive/blob/a28b28f3/ql/src/java/org/apache/hadoop/hive/ql/exec/PTFOperator.java
----------------------------------------------------------------------
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/exec/PTFOperator.java b/ql/src/java/org/apache/hadoop/hive/ql/exec/PTFOperator.java
index f418a7f..f06ee56 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/exec/PTFOperator.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/exec/PTFOperator.java
@@ -27,6 +27,7 @@ import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.hive.ql.CompilationOpContext;
 import org.apache.hadoop.hive.ql.exec.PTFPartition.PTFPartitionIterator;
 import org.apache.hadoop.hive.ql.metadata.HiveException;
+import org.apache.hadoop.hive.ql.parse.LeadLagInfo;
 import org.apache.hadoop.hive.ql.plan.ExprNodeGenericFuncDesc;
 import org.apache.hadoop.hive.ql.plan.PTFDesc;
 import org.apache.hadoop.hive.ql.plan.PTFDeserializer;
@@ -217,15 +218,14 @@ public class PTFOperator extends Operator<PTFDesc> implements Serializable {
     return first;
   }
 
-  public static void connectLeadLagFunctionsToPartition(PTFDesc ptfDesc,
+  public static void connectLeadLagFunctionsToPartition(LeadLagInfo leadLagInfo,
       PTFPartitionIterator<Object> pItr) throws HiveException {
-    List<ExprNodeGenericFuncDesc> llFnDescs = ptfDesc.getLlInfo().getLeadLagExprs();
-    if (llFnDescs == null) {
+    if (leadLagInfo == null || leadLagInfo.getLeadLagExprs() == null) {
       return;
     }
-    for (ExprNodeGenericFuncDesc llFnDesc : llFnDescs) {
-      GenericUDFLeadLag llFn = (GenericUDFLeadLag) llFnDesc
-          .getGenericUDF();
+
+    for (ExprNodeGenericFuncDesc llFnDesc : leadLagInfo.getLeadLagExprs()) {
+      GenericUDFLeadLag llFn = (GenericUDFLeadLag) llFnDesc.getGenericUDF();
       llFn.setpItr(pItr);
     }
   }

http://git-wip-us.apache.org/repos/asf/hive/blob/a28b28f3/ql/src/java/org/apache/hadoop/hive/ql/exec/PTFPartition.java
----------------------------------------------------------------------
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/exec/PTFPartition.java b/ql/src/java/org/apache/hadoop/hive/ql/exec/PTFPartition.java
index edcb8f7..3226f26 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/exec/PTFPartition.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/exec/PTFPartition.java
@@ -182,14 +182,14 @@ public class PTFPartition {
     @Override
     public Object lead(int amt) throws HiveException {
       int i = idx + amt;
-      i = i >= end ? end - 1 : i;
+      i = i >= createTimeSz ? createTimeSz - 1 : i; // Lead on the whole partition not the iterator range
       return getAt(i);
     }
 
     @Override
     public Object lag(int amt) throws HiveException {
       int i = idx - amt;
-      i = i < start ? start : i;
+      i = i < 0 ? 0 : i; // Lag on the whole partition not the iterator range
       return getAt(i);
     }
 
@@ -215,7 +215,7 @@ public class PTFPartition {
   };
 
   /*
-   * provide an Iterator on the rows in a Partiton.
+   * provide an Iterator on the rows in a Partition.
    * Iterator exposes the index of the next location.
    * Client can invoke lead/lag relative to the next location.
    */

http://git-wip-us.apache.org/repos/asf/hive/blob/a28b28f3/ql/src/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDAFEvaluator.java
----------------------------------------------------------------------
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDAFEvaluator.java b/ql/src/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDAFEvaluator.java
index 4fc7089..18d5285 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDAFEvaluator.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDAFEvaluator.java
@@ -22,11 +22,15 @@ import java.io.Closeable;
 import java.io.IOException;
 import java.lang.annotation.Retention;
 import java.lang.annotation.RetentionPolicy;
+import java.util.List;
 
 import org.apache.hadoop.hive.ql.exec.MapredContext;
+import org.apache.hadoop.hive.ql.exec.PTFPartition;
 import org.apache.hadoop.hive.ql.metadata.HiveException;
+import org.apache.hadoop.hive.ql.plan.ptf.PTFExpressionDef;
 import org.apache.hadoop.hive.ql.plan.ptf.WindowFrameDef;
 import org.apache.hadoop.hive.ql.udf.UDFType;
+import org.apache.hadoop.hive.ql.udf.ptf.BasePartitionEvaluator;
 import org.apache.hadoop.hive.serde2.objectinspector.ObjectInspector;
 import org.apache.hive.common.util.AnnotationUtils;
 
@@ -258,4 +262,44 @@ public abstract class GenericUDAFEvaluator implements Closeable {
     return null;
   }
 
+  protected BasePartitionEvaluator partitionEvaluator;
+
+  /**
+   * When evaluating an aggregates over a fixed Window, streaming is not possible
+   * especially for RANGE Window type. For such case, the whole partition data needs
+   * to be collected and then to evaluate the aggregates. The naive approach is to
+   * calculate a row range for each row and to perform the aggregates. For some
+   * functions, a better implementation can be used to reduce the calculation.
+   * Note: since the evaluator is reused across different partitions, AggregationBuffer
+   * needs reset before aggregating for the new partition in the implementation.
+   * @param winFrame    the Window definition in play for this evaluation.
+   * @param partition   the partition data
+   * @param parameters  the list of the expressions in the function
+   * @param outputOI    the output object inspector
+   * @return            the evaluator, default to BasePartitionEvaluator which
+   *                    implements the naive approach
+   */
+  public final BasePartitionEvaluator getPartitionWindowingEvaluator(
+      WindowFrameDef winFrame,
+      PTFPartition partition,
+      List<PTFExpressionDef> parameters,
+      ObjectInspector outputOI) {
+    if (partitionEvaluator == null) {
+      partitionEvaluator = createPartitionEvaluator(winFrame, partition, parameters, outputOI);
+    }
+
+    return partitionEvaluator;
+  }
+
+  /**
+   *  This class needs to be overridden by the child class to implement function
+   *  specific evaluator.
+   */
+  protected BasePartitionEvaluator createPartitionEvaluator(
+      WindowFrameDef winFrame,
+      PTFPartition partition,
+      List<PTFExpressionDef> parameters,
+      ObjectInspector outputOI) {
+    return new BasePartitionEvaluator(this, winFrame, partition, parameters, outputOI);
+  }
 }

http://git-wip-us.apache.org/repos/asf/hive/blob/a28b28f3/ql/src/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDAFSum.java
----------------------------------------------------------------------
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDAFSum.java b/ql/src/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDAFSum.java
index e2cd213..6d3b92b 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDAFSum.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDAFSum.java
@@ -18,33 +18,36 @@
 package org.apache.hadoop.hive.ql.udf.generic;
 
 import java.util.HashSet;
+import java.util.List;
 
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 import org.apache.hadoop.hive.common.type.HiveDecimal;
 import org.apache.hadoop.hive.ql.exec.Description;
+import org.apache.hadoop.hive.ql.exec.PTFPartition;
 import org.apache.hadoop.hive.ql.exec.UDFArgumentTypeException;
 import org.apache.hadoop.hive.ql.metadata.HiveException;
 import org.apache.hadoop.hive.ql.parse.SemanticException;
+import org.apache.hadoop.hive.ql.plan.ptf.PTFExpressionDef;
 import org.apache.hadoop.hive.ql.plan.ptf.WindowFrameDef;
+import org.apache.hadoop.hive.ql.udf.ptf.BasePartitionEvaluator;
 import org.apache.hadoop.hive.ql.util.JavaDataModel;
 import org.apache.hadoop.hive.serde2.io.DoubleWritable;
 import org.apache.hadoop.hive.serde2.io.HiveDecimalWritable;
 import org.apache.hadoop.hive.serde2.objectinspector.ObjectInspector;
 import org.apache.hadoop.hive.serde2.objectinspector.ObjectInspectorUtils;
-import org.apache.hadoop.hive.serde2.objectinspector.PrimitiveObjectInspector;
 import org.apache.hadoop.hive.serde2.objectinspector.ObjectInspectorUtils.ObjectInspectorCopyOption;
 import org.apache.hadoop.hive.serde2.objectinspector.ObjectInspectorUtils.ObjectInspectorObject;
+import org.apache.hadoop.hive.serde2.objectinspector.PrimitiveObjectInspector;
 import org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorFactory;
 import org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorUtils;
 import org.apache.hadoop.hive.serde2.typeinfo.DecimalTypeInfo;
-import org.apache.hadoop.hive.serde2.typeinfo.HiveDecimalUtils;
 import org.apache.hadoop.hive.serde2.typeinfo.PrimitiveTypeInfo;
 import org.apache.hadoop.hive.serde2.typeinfo.TypeInfo;
 import org.apache.hadoop.hive.serde2.typeinfo.TypeInfoFactory;
 import org.apache.hadoop.io.LongWritable;
 import org.apache.hadoop.io.Writable;
 import org.apache.hadoop.util.StringUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 /**
  * GenericUDAFSum.
@@ -152,7 +155,7 @@ public class GenericUDAFSum extends AbstractGenericUDAFResolver {
       this.sumDistinct = sumDistinct;
     }
 
-    protected boolean isWindowingDistinct() {
+    public boolean isWindowingDistinct() {
       return isWindowing && sumDistinct;
     }
 
@@ -335,6 +338,15 @@ public class GenericUDAFSum extends AbstractGenericUDAFResolver {
 
       };
     }
+
+    @Override
+    protected BasePartitionEvaluator createPartitionEvaluator(
+        WindowFrameDef winFrame,
+        PTFPartition partition,
+        List<PTFExpressionDef> parameters,
+        ObjectInspector outputOI) {
+      return new BasePartitionEvaluator.SumPartitionHiveDecimalEvaluator(this, winFrame, partition, parameters, outputOI);
+    }
   }
 
   /**
@@ -455,6 +467,14 @@ public class GenericUDAFSum extends AbstractGenericUDAFResolver {
       };
     }
 
+    @Override
+    protected BasePartitionEvaluator createPartitionEvaluator(
+        WindowFrameDef winFrame,
+        PTFPartition partition,
+        List<PTFExpressionDef> parameters,
+        ObjectInspector outputOI) {
+      return new BasePartitionEvaluator.SumPartitionDoubleEvaluator(this, winFrame, partition, parameters, outputOI);
+    }
   }
 
   /**
@@ -570,5 +590,14 @@ public class GenericUDAFSum extends AbstractGenericUDAFResolver {
         }
       };
     }
+
+    @Override
+    protected BasePartitionEvaluator createPartitionEvaluator(
+        WindowFrameDef winFrame,
+        PTFPartition partition,
+        List<PTFExpressionDef> parameters,
+        ObjectInspector outputOI) {
+      return new BasePartitionEvaluator.SumPartitionLongEvaluator(this, winFrame, partition, parameters, outputOI);
+    }
   }
 }

http://git-wip-us.apache.org/repos/asf/hive/blob/a28b28f3/ql/src/java/org/apache/hadoop/hive/ql/udf/ptf/BasePartitionEvaluator.java
----------------------------------------------------------------------
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/udf/ptf/BasePartitionEvaluator.java b/ql/src/java/org/apache/hadoop/hive/ql/udf/ptf/BasePartitionEvaluator.java
new file mode 100644
index 0000000..f5f9f7b
--- /dev/null
+++ b/ql/src/java/org/apache/hadoop/hive/ql/udf/ptf/BasePartitionEvaluator.java
@@ -0,0 +1,348 @@
+/**
+ * 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.ql.udf.ptf;
+
+import java.util.List;
+
+import org.apache.hadoop.hive.ql.exec.PTFOperator;
+import org.apache.hadoop.hive.ql.exec.PTFPartition;
+import org.apache.hadoop.hive.ql.exec.PTFPartition.PTFPartitionIterator;
+import org.apache.hadoop.hive.ql.metadata.HiveException;
+import org.apache.hadoop.hive.ql.parse.LeadLagInfo;
+import org.apache.hadoop.hive.ql.parse.WindowingSpec.BoundarySpec;
+import org.apache.hadoop.hive.ql.parse.WindowingSpec.Direction;
+import org.apache.hadoop.hive.ql.parse.WindowingSpec.WindowType;
+import org.apache.hadoop.hive.ql.plan.ptf.BoundaryDef;
+import org.apache.hadoop.hive.ql.plan.ptf.PTFExpressionDef;
+import org.apache.hadoop.hive.ql.plan.ptf.WindowFrameDef;
+import org.apache.hadoop.hive.ql.udf.generic.GenericUDAFEvaluator;
+import org.apache.hadoop.hive.ql.udf.generic.GenericUDAFEvaluator.AbstractAggregationBuffer;
+import org.apache.hadoop.hive.ql.udf.generic.GenericUDAFEvaluator.AggregationBuffer;
+import org.apache.hadoop.hive.ql.udf.generic.GenericUDAFSum.GenericUDAFSumEvaluator;
+import org.apache.hadoop.hive.serde2.io.DoubleWritable;
+import org.apache.hadoop.hive.serde2.io.HiveDecimalWritable;
+import org.apache.hadoop.hive.serde2.objectinspector.ObjectInspector;
+import org.apache.hadoop.hive.serde2.objectinspector.ObjectInspectorUtils;
+import org.apache.hadoop.io.LongWritable;
+import org.apache.hadoop.io.Writable;
+
+/**
+ * This class is mostly used for RANGE windowing type to do some optimization. ROWS
+ * windowing type can support streaming.
+ *
+ */
+public class BasePartitionEvaluator {
+  protected final GenericUDAFEvaluator wrappedEvaluator;
+  protected final WindowFrameDef winFrame;
+  protected final PTFPartition partition;
+  protected final List<PTFExpressionDef> parameters;
+  protected final ObjectInspector outputOI;
+
+  /**
+   * Internal class to represent a window range in a partition by searching the
+   * relative position (ROWS) or relative value (RANGE) of the current row
+   */
+  protected static class Range
+  {
+    int start;
+    int end;
+    PTFPartition p;
+
+    public Range(int start, int end, PTFPartition p)
+    {
+      this.start = start;
+      this.end = end;
+      this.p = p;
+    }
+
+    public PTFPartitionIterator<Object> iterator()
+    {
+      return p.range(start, end);
+    }
+
+    public int getDiff(Range prevRange) {
+      return this.start - prevRange.start + this.end - prevRange.end;
+    }
+
+    public int getSize() {
+      return end - start;
+    }
+  }
+
+  public BasePartitionEvaluator(
+      GenericUDAFEvaluator wrappedEvaluator,
+      WindowFrameDef winFrame,
+      PTFPartition partition,
+      List<PTFExpressionDef> parameters,
+      ObjectInspector outputOI) {
+    this.wrappedEvaluator = wrappedEvaluator;
+    this.winFrame = winFrame;
+    this.partition = partition;
+    this.parameters = parameters;
+    this.outputOI = outputOI;
+  }
+
+  /**
+   * Get the aggregation for the whole partition. Used in the case where windowing
+   * is unbounded or the function value is calculated based on all the rows in the
+   * partition such as percent_rank().
+   * @return the aggregated result
+   * @throws HiveException
+   */
+  public Object getPartitionAgg() throws HiveException {
+    return calcFunctionValue(partition.iterator(), null);
+  }
+
+  /**
+   * Given the current row, get the aggregation for the window
+   *
+   * @throws HiveException
+   */
+  public Object iterate(int currentRow, LeadLagInfo leadLagInfo) throws HiveException {
+    Range range = getRange(winFrame, currentRow, partition);
+    PTFPartitionIterator<Object> pItr = range.iterator();
+    return calcFunctionValue(pItr, leadLagInfo);
+  }
+
+  /**
+   * Given a partition iterator, calculate the function value
+   * @param pItr  the partition pointer
+   * @return      the function value
+   * @throws HiveException
+   */
+  protected Object calcFunctionValue(PTFPartitionIterator<Object> pItr, LeadLagInfo leadLagInfo)
+      throws HiveException {
+    // To handle the case like SUM(LAG(f)) over(), aggregation function includes
+    // LAG/LEAD call
+    PTFOperator.connectLeadLagFunctionsToPartition(leadLagInfo, pItr);
+
+    AggregationBuffer aggBuffer = wrappedEvaluator.getNewAggregationBuffer();
+    Object[] argValues = new Object[parameters == null ? 0 : parameters.size()];
+    while(pItr.hasNext())
+    {
+      Object row = pItr.next();
+      int i = 0;
+      if ( parameters != null ) {
+        for(PTFExpressionDef param : parameters)
+        {
+          argValues[i++] = param.getExprEvaluator().evaluate(row);
+        }
+      }
+      wrappedEvaluator.aggregate(aggBuffer, argValues);
+    }
+
+    // The object is reused during evaluating, make a copy here
+    return ObjectInspectorUtils.copyToStandardObject(wrappedEvaluator.evaluate(aggBuffer), outputOI);
+  }
+
+  protected static Range getRange(WindowFrameDef winFrame, int currRow, PTFPartition p)
+      throws HiveException {
+    BoundaryDef startB = winFrame.getStart();
+    BoundaryDef endB = winFrame.getEnd();
+
+    int start, end;
+    if (winFrame.getWindowType() == WindowType.ROWS) {
+      start = getRowBoundaryStart(startB, currRow);
+      end = getRowBoundaryEnd(endB, currRow, p);
+    } else {
+      ValueBoundaryScanner vbs = ValueBoundaryScanner.getScanner(winFrame);
+      start = vbs.computeStart(currRow, p);
+      end = vbs.computeEnd(currRow, p);
+    }
+    start = start < 0 ? 0 : start;
+    end = end > p.size() ? p.size() : end;
+    return new Range(start, end, p);
+  }
+
+  private static int getRowBoundaryStart(BoundaryDef b, int currRow) throws HiveException {
+    Direction d = b.getDirection();
+    int amt = b.getAmt();
+    switch(d) {
+    case PRECEDING:
+      if (amt == BoundarySpec.UNBOUNDED_AMOUNT) {
+        return 0;
+      }
+      else {
+        return currRow - amt;
+      }
+    case CURRENT:
+      return currRow;
+    case FOLLOWING:
+      return currRow + amt;
+    }
+    throw new HiveException("Unknown Start Boundary Direction: " + d);
+  }
+
+  private static int getRowBoundaryEnd(BoundaryDef b, int currRow, PTFPartition p) throws HiveException {
+    Direction d = b.getDirection();
+    int amt = b.getAmt();
+    switch(d) {
+    case PRECEDING:
+      if ( amt == 0 ) {
+        return currRow + 1;
+      }
+      return currRow - amt + 1;
+    case CURRENT:
+      return currRow + 1;
+    case FOLLOWING:
+      if (amt == BoundarySpec.UNBOUNDED_AMOUNT) {
+        return p.size();
+      }
+      else {
+        return currRow + amt + 1;
+      }
+    }
+    throw new HiveException("Unknown End Boundary Direction: " + d);
+  }
+
+  /**
+   * The base type for sum operator evaluator when a partition data is available
+   * and streaming process is not possible. Some optimization can be done for such
+   * case.
+   *
+   */
+  public static abstract class SumPartitionEvaluator<ResultType extends Writable> extends BasePartitionEvaluator {
+    protected final WindowSumAgg<ResultType> sumAgg;
+
+    public SumPartitionEvaluator(
+        GenericUDAFEvaluator wrappedEvaluator,
+        WindowFrameDef winFrame,
+        PTFPartition partition,
+        List<PTFExpressionDef> parameters,
+        ObjectInspector outputOI) {
+      super(wrappedEvaluator, winFrame, partition, parameters, outputOI);
+      sumAgg = new WindowSumAgg<ResultType>();
+    }
+
+    static class WindowSumAgg<ResultType> extends AbstractAggregationBuffer {
+      Range prevRange;
+      ResultType prevSum;
+      boolean empty;
+    }
+
+    public abstract ResultType add(ResultType t1, ResultType t2);
+    public abstract ResultType minus(ResultType t1, ResultType t2);
+
+    @SuppressWarnings({ "unchecked", "rawtypes" })
+    @Override
+    public Object iterate(int currentRow, LeadLagInfo leadLagInfo) throws HiveException {
+      // Currently sum(distinct) not supported in PartitionEvaluator
+      if (((GenericUDAFSumEvaluator)wrappedEvaluator).isWindowingDistinct()) {
+        return super.iterate(currentRow, leadLagInfo);
+      }
+
+      Range currentRange = getRange(winFrame, currentRow, partition);
+      ResultType result;
+      if (currentRow == 0 ||  // Reset for the new partition
+          sumAgg.prevRange == null ||
+          currentRange.getSize() <= currentRange.getDiff(sumAgg.prevRange)) {
+        result = (ResultType)calcFunctionValue(currentRange.iterator(), leadLagInfo);
+        sumAgg.prevRange = currentRange;
+        sumAgg.empty = false;
+        sumAgg.prevSum = result;
+      } else {
+        // Given the previous range and the current range, calculate the new sum
+        // from the previous sum and the difference to save the computation.
+        Range r1 = new Range(sumAgg.prevRange.start, currentRange.start, partition);
+        Range r2 = new Range(sumAgg.prevRange.end, currentRange.end, partition);
+        ResultType sum1 = (ResultType)calcFunctionValue(r1.iterator(), leadLagInfo);
+        ResultType sum2 = (ResultType)calcFunctionValue(r2.iterator(), leadLagInfo);
+        result = add(minus(sumAgg.prevSum, sum1), sum2);
+        sumAgg.prevRange = currentRange;
+        sumAgg.prevSum = result;
+      }
+
+      return result;
+    }
+  }
+
+  public static class SumPartitionDoubleEvaluator extends SumPartitionEvaluator<DoubleWritable> {
+    public SumPartitionDoubleEvaluator(GenericUDAFEvaluator wrappedEvaluator,
+        WindowFrameDef winFrame, PTFPartition partition,
+        List<PTFExpressionDef> parameters, ObjectInspector outputOI) {
+      super(wrappedEvaluator, winFrame, partition, parameters, outputOI);
+    }
+
+    @Override
+    public DoubleWritable add(DoubleWritable t1, DoubleWritable t2) {
+      if (t1 == null && t2 == null) return null;
+      return new DoubleWritable((t1 == null ? 0 : t1.get()) + (t2 == null ? 0 : t2.get()));
+    }
+
+    @Override
+    public DoubleWritable minus(DoubleWritable t1, DoubleWritable t2) {
+      if (t1 == null && t2 == null) return null;
+      return new DoubleWritable((t1 == null ? 0 : t1.get()) - (t2 == null ? 0 : t2.get()));
+    }
+  }
+
+  public static class SumPartitionLongEvaluator extends SumPartitionEvaluator<LongWritable> {
+    public SumPartitionLongEvaluator(GenericUDAFEvaluator wrappedEvaluator,
+        WindowFrameDef winFrame, PTFPartition partition,
+        List<PTFExpressionDef> parameters, ObjectInspector outputOI) {
+      super(wrappedEvaluator, winFrame, partition, parameters, outputOI);
+    }
+
+    @Override
+    public LongWritable add(LongWritable t1, LongWritable t2) {
+      if (t1 == null && t2 == null) return null;
+      return new LongWritable((t1 == null ? 0 : t1.get()) + (t2 == null ? 0 : t2.get()));
+    }
+
+    @Override
+    public LongWritable minus(LongWritable t1, LongWritable t2) {
+      if (t1 == null && t2 == null) return null;
+      return new LongWritable((t1 == null ? 0 : t1.get()) - (t2 == null ? 0 : t2.get()));
+    }
+  }
+
+  public static class SumPartitionHiveDecimalEvaluator extends SumPartitionEvaluator<HiveDecimalWritable> {
+    public SumPartitionHiveDecimalEvaluator(GenericUDAFEvaluator wrappedEvaluator,
+        WindowFrameDef winFrame, PTFPartition partition,
+        List<PTFExpressionDef> parameters, ObjectInspector outputOI) {
+      super(wrappedEvaluator, winFrame, partition, parameters, outputOI);
+    }
+
+    @Override
+    public HiveDecimalWritable add(HiveDecimalWritable t1, HiveDecimalWritable t2) {
+      if (t1 == null && t2 == null) return null;
+      if (t1 == null) {
+        return t2;
+      } else {
+        if (t2 != null) {
+          t1.mutateAdd(t2);
+        }
+        return t1;
+      }
+    }
+
+    @Override
+    public HiveDecimalWritable minus(HiveDecimalWritable t1, HiveDecimalWritable t2) {
+      if (t1 == null && t2 == null) return null;
+      if (t1 == null) {
+        t2.mutateNegate();
+        return t2;
+      } else {
+        if (t2 != null) {
+          t1.mutateSubtract(t2);
+        }
+        return t1;
+      }
+    }
+  }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/hive/blob/a28b28f3/ql/src/java/org/apache/hadoop/hive/ql/udf/ptf/TableFunctionEvaluator.java
----------------------------------------------------------------------
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/udf/ptf/TableFunctionEvaluator.java b/ql/src/java/org/apache/hadoop/hive/ql/udf/ptf/TableFunctionEvaluator.java
index c76118b..7b30838 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/udf/ptf/TableFunctionEvaluator.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/udf/ptf/TableFunctionEvaluator.java
@@ -140,7 +140,7 @@ public abstract class TableFunctionEvaluator {
       return transformRawInput(iPart);
     }
     PTFPartitionIterator<Object> pItr = iPart.iterator();
-    PTFOperator.connectLeadLagFunctionsToPartition(ptfDesc, pItr);
+    PTFOperator.connectLeadLagFunctionsToPartition(ptfDesc.getLlInfo(), pItr);
 
     if ( outputPartition == null ) {
       outputPartition = PTFPartition.create(ptfDesc.getCfg(),

http://git-wip-us.apache.org/repos/asf/hive/blob/a28b28f3/ql/src/java/org/apache/hadoop/hive/ql/udf/ptf/ValueBoundaryScanner.java
----------------------------------------------------------------------
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/udf/ptf/ValueBoundaryScanner.java b/ql/src/java/org/apache/hadoop/hive/ql/udf/ptf/ValueBoundaryScanner.java
new file mode 100644
index 0000000..88837dc
--- /dev/null
+++ b/ql/src/java/org/apache/hadoop/hive/ql/udf/ptf/ValueBoundaryScanner.java
@@ -0,0 +1,729 @@
+/**
+ * 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.ql.udf.ptf;
+
+import java.util.Date;
+
+import org.apache.hadoop.hive.common.type.HiveDecimal;
+import org.apache.hadoop.hive.ql.exec.PTFPartition;
+import org.apache.hadoop.hive.ql.metadata.HiveException;
+import org.apache.hadoop.hive.ql.parse.PTFInvocationSpec.Order;
+import org.apache.hadoop.hive.ql.parse.WindowingSpec.BoundarySpec;
+import org.apache.hadoop.hive.ql.plan.ptf.BoundaryDef;
+import org.apache.hadoop.hive.ql.plan.ptf.OrderDef;
+import org.apache.hadoop.hive.ql.plan.ptf.OrderExpressionDef;
+import org.apache.hadoop.hive.ql.plan.ptf.WindowFrameDef;
+import org.apache.hadoop.hive.serde2.objectinspector.ObjectInspectorUtils;
+import org.apache.hadoop.hive.serde2.objectinspector.PrimitiveObjectInspector;
+import org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorUtils;
+
+public abstract class ValueBoundaryScanner {
+  BoundaryDef start, end;
+
+  public ValueBoundaryScanner(BoundaryDef start, BoundaryDef end) {
+    this.start = start;
+    this.end = end;
+  }
+
+  public abstract int computeStart(int rowIdx, PTFPartition p) throws HiveException;
+
+  public abstract int computeEnd(int rowIdx, PTFPartition p) throws HiveException;
+
+  public static ValueBoundaryScanner getScanner(WindowFrameDef winFrameDef)
+      throws HiveException {
+    OrderDef orderDef = winFrameDef.getOrderDef();
+    int numOrders = orderDef.getExpressions().size();
+    if (numOrders != 1) {
+      return new MultiValueBoundaryScanner(winFrameDef.getStart(), winFrameDef.getEnd(), orderDef);
+    } else {
+      return SingleValueBoundaryScanner.getScanner(winFrameDef.getStart(), winFrameDef.getEnd(), orderDef);
+    }
+  }
+}
+
+/*
+ * - starting from the given rowIdx scan in the given direction until a row's expr
+ * evaluates to an amt that crosses the 'amt' threshold specified in the BoundaryDef.
+ */
+abstract class SingleValueBoundaryScanner extends ValueBoundaryScanner {
+  OrderExpressionDef expressionDef;
+
+  public SingleValueBoundaryScanner(BoundaryDef start, BoundaryDef end, OrderExpressionDef expressionDef) {
+    super(start, end);
+    this.expressionDef = expressionDef;
+  }
+
+  /*
+|  Use | Boundary1.type | Boundary1. amt | Sort Key | Order | Behavior                          |
+| Case |                |                |          |       |                                   |
+|------+----------------+----------------+----------+-------+-----------------------------------|
+|   1. | PRECEDING      | UNB            | ANY      | ANY   | start = 0                         |
+|   2. | PRECEDING      | unsigned int   | NULL     | ASC   | start = 0                         |
+|   3. |                |                |          | DESC  | scan backwards to row R2          |
+|      |                |                |          |       | such that R2.sk is not null       |
+|      |                |                |          |       | start = R2.idx + 1                |
+|   4. | PRECEDING      | unsigned int   | not NULL | DESC  | scan backwards until row R2       |
+|      |                |                |          |       | such that R2.sk - R.sk > amt      |
+|      |                |                |          |       | start = R2.idx + 1                |
+|   5. | PRECEDING      | unsigned int   | not NULL | ASC   | scan backward until row R2        |
+|      |                |                |          |       | such that R.sk - R2.sk > bnd1.amt |
+|      |                |                |          |       | start = R2.idx + 1                |
+|   6. | CURRENT ROW    |                | NULL     | ANY   | scan backwards until row R2       |
+|      |                |                |          |       | such that R2.sk is not null       |
+|      |                |                |          |       | start = R2.idx + 1                |
+|   7. | CURRENT ROW    |                | not NULL | ANY   | scan backwards until row R2       |
+|      |                |                |          |       | such R2.sk != R.sk                |
+|      |                |                |          |       | start = R2.idx + 1                |
+|   8. | FOLLOWING      | UNB            | ANY      | ANY   | Error                             |
+|   9. | FOLLOWING      | unsigned int   | NULL     | DESC  | start = partition.size            |
+|  10. |                |                |          | ASC   | scan forward until R2             |
+|      |                |                |          |       | such that R2.sk is not null       |
+|      |                |                |          |       | start = R2.idx                    |
+|  11. | FOLLOWING      | unsigned int   | not NULL | DESC  | scan forward until row R2         |
+|      |                |                |          |       | such that R.sk - R2.sk > amt      |
+|      |                |                |          |       | start = R2.idx                    |
+|  12. |                |                |          | ASC   | scan forward until row R2         |
+|      |                |                |          |       | such that R2.sk - R.sk > amt      |
+|------+----------------+----------------+----------+-------+-----------------------------------|
+   */
+  @Override
+  public int computeStart(int rowIdx, PTFPartition p) throws HiveException {
+    switch(start.getDirection()) {
+    case PRECEDING:
+      return computeStartPreceding(rowIdx, p);
+    case CURRENT:
+      return computeStartCurrentRow(rowIdx, p);
+    case FOLLOWING:
+      default:
+        return computeStartFollowing(rowIdx, p);
+    }
+  }
+
+  protected int computeStartPreceding(int rowIdx, PTFPartition p) throws HiveException {
+    int amt = start.getAmt();
+    // Use Case 1.
+    if ( amt == BoundarySpec.UNBOUNDED_AMOUNT ) {
+      return 0;
+    }
+    Object sortKey = computeValue(p.getAt(rowIdx));
+
+    if ( sortKey == null ) {
+      // Use Case 2.
+      if ( expressionDef.getOrder() == Order.ASC ) {
+        return 0;
+      }
+      else { // Use Case 3.
+        while ( sortKey == null && rowIdx >= 0 ) {
+          --rowIdx;
+          if ( rowIdx >= 0 ) {
+            sortKey = computeValue(p.getAt(rowIdx));
+          }
+        }
+        return rowIdx+1;
+      }
+    }
+
+    Object rowVal = sortKey;
+    int r = rowIdx;
+
+    // Use Case 4.
+    if ( expressionDef.getOrder() == Order.DESC ) {
+      while (r >= 0 && !isDistanceGreater(rowVal, sortKey, amt) ) {
+        r--;
+        if ( r >= 0 ) {
+          rowVal = computeValue(p.getAt(r));
+        }
+      }
+      return r + 1;
+    }
+    else { // Use Case 5.
+      while (r >= 0 && !isDistanceGreater(sortKey, rowVal, amt) ) {
+        r--;
+        if ( r >= 0 ) {
+          rowVal = computeValue(p.getAt(r));
+        }
+      }
+      return r + 1;
+    }
+  }
+
+  protected int computeStartCurrentRow(int rowIdx, PTFPartition p) throws HiveException {
+    Object sortKey = computeValue(p.getAt(rowIdx));
+
+    // Use Case 6.
+    if ( sortKey == null ) {
+      while ( sortKey == null && rowIdx >= 0 ) {
+        --rowIdx;
+        if ( rowIdx >= 0 ) {
+          sortKey = computeValue(p.getAt(rowIdx));
+        }
+      }
+      return rowIdx+1;
+    }
+
+    Object rowVal = sortKey;
+    int r = rowIdx;
+
+    // Use Case 7.
+    while (r >= 0 && isEqual(rowVal, sortKey) ) {
+      r--;
+      if ( r >= 0 ) {
+        rowVal = computeValue(p.getAt(r));
+      }
+    }
+    return r + 1;
+  }
+
+  protected int computeStartFollowing(int rowIdx, PTFPartition p) throws HiveException {
+    int amt = start.getAmt();
+    Object sortKey = computeValue(p.getAt(rowIdx));
+
+    Object rowVal = sortKey;
+    int r = rowIdx;
+
+    if ( sortKey == null ) {
+      // Use Case 9.
+      if ( expressionDef.getOrder() == Order.DESC) {
+        return p.size();
+      }
+      else { // Use Case 10.
+        while (r < p.size() && rowVal == null ) {
+          r++;
+          if ( r < p.size() ) {
+            rowVal = computeValue(p.getAt(r));
+          }
+        }
+        return r;
+      }
+    }
+
+    // Use Case 11.
+    if ( expressionDef.getOrder() == Order.DESC) {
+      while (r < p.size() && !isDistanceGreater(sortKey, rowVal, amt) ) {
+        r++;
+        if ( r < p.size() ) {
+          rowVal = computeValue(p.getAt(r));
+        }
+      }
+      return r;
+    }
+    else { // Use Case 12.
+      while (r < p.size() && !isDistanceGreater(rowVal, sortKey, amt) ) {
+        r++;
+        if ( r < p.size() ) {
+          rowVal = computeValue(p.getAt(r));
+        }
+      }
+      return r;
+    }
+  }
+
+  /*
+|  Use | Boundary2.type | Boundary2.amt | Sort Key | Order | Behavior                          |
+| Case |                |               |          |       |                                   |
+|------+----------------+---------------+----------+-------+-----------------------------------|
+|   1. | PRECEDING      | UNB           | ANY      | ANY   | Error                             |
+|   2. | PRECEDING      | unsigned int  | NULL     | DESC  | end = partition.size()            |
+|   3. |                |               |          | ASC   | end = 0                           |
+|   4. | PRECEDING      | unsigned int  | not null | DESC  | scan backward until row R2        |
+|      |                |               |          |       | such that R2.sk - R.sk > bnd.amt  |
+|      |                |               |          |       | end = R2.idx + 1                  |
+|   5. | PRECEDING      | unsigned int  | not null | ASC   | scan backward until row R2        |
+|      |                |               |          |       | such that R.sk -  R2.sk > bnd.amt |
+|      |                |               |          |       | end = R2.idx + 1                  |
+|   6. | CURRENT ROW    |               | NULL     | ANY   | scan forward until row R2         |
+|      |                |               |          |       | such that R2.sk is not null       |
+|      |                |               |          |       | end = R2.idx                      |
+|   7. | CURRENT ROW    |               | not null | ANY   | scan forward until row R2         |
+|      |                |               |          |       | such that R2.sk != R.sk           |
+|      |                |               |          |       | end = R2.idx                      |
+|   8. | FOLLOWING      | UNB           | ANY      | ANY   | end = partition.size()            |
+|   9. | FOLLOWING      | unsigned int  | NULL     | DESC  | end = partition.size()            |
+|  10. |                |               |          | ASC   | scan forward until row R2         |
+|      |                |               |          |       | such that R2.sk is not null       |
+|      |                |               |          |       | end = R2.idx                      |
+|  11. | FOLLOWING      | unsigned int  | not NULL | DESC  | scan forward until row R2         |
+|      |                |               |          |       | such R.sk - R2.sk > bnd.amt       |
+|      |                |               |          |       | end = R2.idx                      |
+|  12. |                |               |          | ASC   | scan forward until row R2         |
+|      |                |               |          |       | such R2.sk - R2.sk > bnd.amt      |
+|      |                |               |          |       | end = R2.idx                      |
+|------+----------------+---------------+----------+-------+-----------------------------------|
+   */
+  @Override
+  public int computeEnd(int rowIdx, PTFPartition p) throws HiveException {
+    switch(end.getDirection()) {
+    case PRECEDING:
+      return computeEndPreceding(rowIdx, p);
+    case CURRENT:
+      return computeEndCurrentRow(rowIdx, p);
+    case FOLLOWING:
+      default:
+        return computeEndFollowing(rowIdx, p);
+    }
+  }
+
+  protected int computeEndPreceding(int rowIdx, PTFPartition p) throws HiveException {
+    int amt = end.getAmt();
+    // Use Case 1.
+    // amt == UNBOUNDED, is caught during translation
+
+    Object sortKey = computeValue(p.getAt(rowIdx));
+
+    if ( sortKey == null ) {
+      // Use Case 2.
+      if ( expressionDef.getOrder() == Order.DESC ) {
+        return p.size();
+      }
+      else { // Use Case 3.
+        return 0;
+      }
+    }
+
+    Object rowVal = sortKey;
+    int r = rowIdx;
+
+    // Use Case 4.
+    if ( expressionDef.getOrder() == Order.DESC ) {
+      while (r >= 0 && !isDistanceGreater(rowVal, sortKey, amt) ) {
+        r--;
+        if ( r >= 0 ) {
+          rowVal = computeValue(p.getAt(r));
+        }
+      }
+      return r + 1;
+    }
+    else { // Use Case 5.
+      while (r >= 0 && !isDistanceGreater(sortKey, rowVal, amt) ) {
+        r--;
+        if ( r >= 0 ) {
+          rowVal = computeValue(p.getAt(r));
+        }
+      }
+      return r + 1;
+    }
+  }
+
+  protected int computeEndCurrentRow(int rowIdx, PTFPartition p) throws HiveException {
+    Object sortKey = computeValue(p.getAt(rowIdx));
+
+    // Use Case 6.
+    if ( sortKey == null ) {
+      while ( sortKey == null && rowIdx < p.size() ) {
+        ++rowIdx;
+        if ( rowIdx < p.size() ) {
+          sortKey = computeValue(p.getAt(rowIdx));
+        }
+      }
+      return rowIdx;
+    }
+
+    Object rowVal = sortKey;
+    int r = rowIdx;
+
+    // Use Case 7.
+    while (r < p.size() && isEqual(sortKey, rowVal) ) {
+      r++;
+      if ( r < p.size() ) {
+        rowVal = computeValue(p.getAt(r));
+      }
+    }
+    return r;
+  }
+
+  protected int computeEndFollowing(int rowIdx, PTFPartition p) throws HiveException {
+    int amt = end.getAmt();
+
+    // Use Case 8.
+    if ( amt == BoundarySpec.UNBOUNDED_AMOUNT ) {
+      return p.size();
+    }
+    Object sortKey = computeValue(p.getAt(rowIdx));
+
+    Object rowVal = sortKey;
+    int r = rowIdx;
+
+    if ( sortKey == null ) {
+      // Use Case 9.
+      if ( expressionDef.getOrder() == Order.DESC) {
+        return p.size();
+      }
+      else { // Use Case 10.
+        while (r < p.size() && rowVal == null ) {
+          r++;
+          if ( r < p.size() ) {
+            rowVal = computeValue(p.getAt(r));
+          }
+        }
+        return r;
+      }
+    }
+
+    // Use Case 11.
+    if ( expressionDef.getOrder() == Order.DESC) {
+      while (r < p.size() && !isDistanceGreater(sortKey, rowVal, amt) ) {
+        r++;
+        if ( r < p.size() ) {
+          rowVal = computeValue(p.getAt(r));
+        }
+      }
+      return r;
+    }
+    else { // Use Case 12.
+      while (r < p.size() && !isDistanceGreater(rowVal, sortKey, amt) ) {
+        r++;
+        if ( r < p.size() ) {
+          rowVal = computeValue(p.getAt(r));
+        }
+      }
+      return r;
+    }
+  }
+
+  public Object computeValue(Object row) throws HiveException {
+    Object o = expressionDef.getExprEvaluator().evaluate(row);
+    return ObjectInspectorUtils.copyToStandardObject(o, expressionDef.getOI());
+  }
+
+  /**
+   * Checks if the distance of v2 to v1 is greater than the given amt.
+   * @return True if the value of v1 - v2 is greater than amt or either value is null.
+   */
+  public abstract boolean isDistanceGreater(Object v1, Object v2, int amt);
+
+  /**
+   * Checks if the values of v1 or v2 are the same.
+   * @return True if both values are the same or both are nulls.
+   */
+  public abstract boolean isEqual(Object v1, Object v2);
+
+
+  @SuppressWarnings("incomplete-switch")
+  public static SingleValueBoundaryScanner getScanner(BoundaryDef start, BoundaryDef end, OrderDef orderDef)
+      throws HiveException {
+    if (orderDef.getExpressions().size() != 1) {
+      throw new HiveException("Internal error: initializing SingleValueBoundaryScanner with"
+              + " multiple expression for sorting");
+    }
+    OrderExpressionDef exprDef = orderDef.getExpressions().get(0);
+    PrimitiveObjectInspector pOI = (PrimitiveObjectInspector) exprDef.getOI();
+    switch(pOI.getPrimitiveCategory()) {
+    case BYTE:
+    case INT:
+    case LONG:
+    case SHORT:
+    case TIMESTAMP:
+      return new LongValueBoundaryScanner(start, end, exprDef);
+    case DOUBLE:
+    case FLOAT:
+      return new DoubleValueBoundaryScanner(start, end, exprDef);
+    case DECIMAL:
+      return new HiveDecimalValueBoundaryScanner(start, end, exprDef);
+    case DATE:
+      return new DateValueBoundaryScanner(start, end, exprDef);
+    case STRING:
+      return new StringValueBoundaryScanner(start, end, exprDef);
+    }
+    throw new HiveException(
+        String.format("Internal Error: attempt to setup a Window for datatype %s",
+            pOI.getPrimitiveCategory()));
+  }
+}
+
+class LongValueBoundaryScanner extends SingleValueBoundaryScanner {
+  public LongValueBoundaryScanner(BoundaryDef start, BoundaryDef end, OrderExpressionDef expressionDef) {
+    super(start, end,expressionDef);
+  }
+
+  @Override
+  public boolean isDistanceGreater(Object v1, Object v2, int amt) {
+    if (v1 != null && v2 != null) {
+      long l1 = PrimitiveObjectInspectorUtils.getLong(v1,
+          (PrimitiveObjectInspector) expressionDef.getOI());
+      long l2 = PrimitiveObjectInspectorUtils.getLong(v2,
+          (PrimitiveObjectInspector) expressionDef.getOI());
+      return (l1 -l2) > amt;
+    }
+
+    return v1 != null || v2 != null; // True if only one value is null
+  }
+
+  @Override
+  public boolean isEqual(Object v1, Object v2) {
+    if (v1 != null && v2 != null) {
+      long l1 = PrimitiveObjectInspectorUtils.getLong(v1,
+          (PrimitiveObjectInspector) expressionDef.getOI());
+      long l2 = PrimitiveObjectInspectorUtils.getLong(v2,
+          (PrimitiveObjectInspector) expressionDef.getOI());
+      return l1 == l2;
+    }
+
+    return v1 == null && v2 == null; // True if both are null
+  }
+}
+
+class DoubleValueBoundaryScanner extends SingleValueBoundaryScanner {
+  public DoubleValueBoundaryScanner(BoundaryDef start, BoundaryDef end, OrderExpressionDef expressionDef) {
+    super(start, end,expressionDef);
+  }
+
+  @Override
+  public boolean isDistanceGreater(Object v1, Object v2, int amt) {
+    if (v1 != null && v2 != null) {
+      double d1 = PrimitiveObjectInspectorUtils.getDouble(v1,
+          (PrimitiveObjectInspector) expressionDef.getOI());
+      double d2 = PrimitiveObjectInspectorUtils.getDouble(v2,
+          (PrimitiveObjectInspector) expressionDef.getOI());
+      return (d1 -d2) > amt;
+    }
+
+    return v1 != null || v2 != null; // True if only one value is null
+  }
+
+  @Override
+  public boolean isEqual(Object v1, Object v2) {
+    if (v1 != null && v2 != null) {
+      double d1 = PrimitiveObjectInspectorUtils.getDouble(v1,
+          (PrimitiveObjectInspector) expressionDef.getOI());
+      double d2 = PrimitiveObjectInspectorUtils.getDouble(v2,
+          (PrimitiveObjectInspector) expressionDef.getOI());
+      return d1 == d2;
+    }
+
+    return v1 == null && v2 == null; // True if both are null
+  }
+}
+
+class HiveDecimalValueBoundaryScanner extends SingleValueBoundaryScanner {
+  public HiveDecimalValueBoundaryScanner(BoundaryDef start, BoundaryDef end, OrderExpressionDef expressionDef) {
+    super(start, end,expressionDef);
+  }
+
+  @Override
+  public boolean isDistanceGreater(Object v1, Object v2, int amt) {
+    HiveDecimal d1 = PrimitiveObjectInspectorUtils.getHiveDecimal(v1,
+        (PrimitiveObjectInspector) expressionDef.getOI());
+    HiveDecimal d2 = PrimitiveObjectInspectorUtils.getHiveDecimal(v2,
+        (PrimitiveObjectInspector) expressionDef.getOI());
+    if ( d1 != null && d2 != null ) {
+      return d1.subtract(d2).intValue() > amt;  // TODO: lossy conversion!
+    }
+
+    return d1 != null || d2 != null; // True if only one value is null
+  }
+
+  @Override
+  public boolean isEqual(Object v1, Object v2) {
+    HiveDecimal d1 = PrimitiveObjectInspectorUtils.getHiveDecimal(v1,
+        (PrimitiveObjectInspector) expressionDef.getOI());
+    HiveDecimal d2 = PrimitiveObjectInspectorUtils.getHiveDecimal(v2,
+        (PrimitiveObjectInspector) expressionDef.getOI());
+    if ( d1 != null && d2 != null ) {
+      return d1.equals(d2);
+    }
+
+    return d1 == null && d2 == null; // True if both are null
+  }
+}
+
+class DateValueBoundaryScanner extends SingleValueBoundaryScanner {
+  public DateValueBoundaryScanner(BoundaryDef start, BoundaryDef end, OrderExpressionDef expressionDef) {
+    super(start, end,expressionDef);
+  }
+
+  @Override
+  public boolean isDistanceGreater(Object v1, Object v2, int amt) {
+    Date l1 = PrimitiveObjectInspectorUtils.getDate(v1,
+        (PrimitiveObjectInspector) expressionDef.getOI());
+    Date l2 = PrimitiveObjectInspectorUtils.getDate(v2,
+        (PrimitiveObjectInspector) expressionDef.getOI());
+    if (l1 != null && l2 != null) {
+        return (double)(l1.getTime() - l2.getTime())/1000 > (long)amt * 24 * 3600; // Converts amt days to milliseconds
+    }
+    return l1 != l2; // True if only one date is null
+  }
+
+  @Override
+  public boolean isEqual(Object v1, Object v2) {
+    Date l1 = PrimitiveObjectInspectorUtils.getDate(v1,
+        (PrimitiveObjectInspector) expressionDef.getOI());
+    Date l2 = PrimitiveObjectInspectorUtils.getDate(v2,
+        (PrimitiveObjectInspector) expressionDef.getOI());
+    return (l1 == null && l2 == null) || (l1 != null && l1.equals(l2));
+  }
+}
+
+class StringValueBoundaryScanner extends SingleValueBoundaryScanner {
+  public StringValueBoundaryScanner(BoundaryDef start, BoundaryDef end, OrderExpressionDef expressionDef) {
+    super(start, end,expressionDef);
+  }
+
+  @Override
+  public boolean isDistanceGreater(Object v1, Object v2, int amt) {
+    String s1 = PrimitiveObjectInspectorUtils.getString(v1,
+        (PrimitiveObjectInspector) expressionDef.getOI());
+    String s2 = PrimitiveObjectInspectorUtils.getString(v2,
+        (PrimitiveObjectInspector) expressionDef.getOI());
+    return s1 != null && s2 != null && s1.compareTo(s2) > 0;
+  }
+
+  @Override
+  public boolean isEqual(Object v1, Object v2) {
+    String s1 = PrimitiveObjectInspectorUtils.getString(v1,
+        (PrimitiveObjectInspector) expressionDef.getOI());
+    String s2 = PrimitiveObjectInspectorUtils.getString(v2,
+        (PrimitiveObjectInspector) expressionDef.getOI());
+    return (s1 == null && s2 == null) || (s1 != null && s1.equals(s2));
+  }
+}
+
+/*
+ */
+ class MultiValueBoundaryScanner extends ValueBoundaryScanner {
+  OrderDef orderDef;
+
+  public MultiValueBoundaryScanner(BoundaryDef start, BoundaryDef end, OrderDef orderDef) {
+    super(start, end);
+    this.orderDef = orderDef;
+  }
+
+  /*
+|------+----------------+----------------+----------+-------+-----------------------------------|
+| Use  | Boundary1.type | Boundary1. amt | Sort Key | Order | Behavior                          |
+| Case |                |                |          |       |                                   |
+|------+----------------+----------------+----------+-------+-----------------------------------|
+|   1. | PRECEDING      | UNB            | ANY      | ANY   | start = 0                         |
+|   2. | CURRENT ROW    |                | ANY      | ANY   | scan backwards until row R2       |
+|      |                |                |          |       | such R2.sk != R.sk                |
+|      |                |                |          |       | start = R2.idx + 1                |
+|------+----------------+----------------+----------+-------+-----------------------------------|
+   */
+  @Override
+  public int computeStart(int rowIdx, PTFPartition p) throws HiveException {
+    switch(start.getDirection()) {
+    case PRECEDING:
+      return computeStartPreceding(rowIdx, p);
+    case CURRENT:
+      return computeStartCurrentRow(rowIdx, p);
+    case FOLLOWING:
+      default:
+        throw new HiveException(
+                "FOLLOWING not allowed for starting RANGE with multiple expressions in ORDER BY");
+    }
+  }
+
+  protected int computeStartPreceding(int rowIdx, PTFPartition p) throws HiveException {
+    int amt = start.getAmt();
+    if ( amt == BoundarySpec.UNBOUNDED_AMOUNT ) {
+      return 0;
+    }
+    throw new HiveException(
+            "PRECEDING needs UNBOUNDED for RANGE with multiple expressions in ORDER BY");
+  }
+
+  protected int computeStartCurrentRow(int rowIdx, PTFPartition p) throws HiveException {
+    Object[] sortKey = computeValues(p.getAt(rowIdx));
+    Object[] rowVal = sortKey;
+    int r = rowIdx;
+
+    while (r >= 0 && isEqual(rowVal, sortKey) ) {
+      r--;
+      if ( r >= 0 ) {
+        rowVal = computeValues(p.getAt(r));
+      }
+    }
+    return r + 1;
+  }
+
+  /*
+|------+----------------+---------------+----------+-------+-----------------------------------|
+| Use  | Boundary2.type | Boundary2.amt | Sort Key | Order | Behavior                          |
+| Case |                |               |          |       |                                   |
+|------+----------------+---------------+----------+-------+-----------------------------------|
+|   1. | CURRENT ROW    |               | ANY      | ANY   | scan forward until row R2         |
+|      |                |               |          |       | such that R2.sk != R.sk           |
+|      |                |               |          |       | end = R2.idx                      |
+|   2. | FOLLOWING      | UNB           | ANY      | ANY   | end = partition.size()            |
+|------+----------------+---------------+----------+-------+-----------------------------------|
+   */
+  @Override
+  public int computeEnd(int rowIdx, PTFPartition p) throws HiveException {
+    switch(end.getDirection()) {
+    case PRECEDING:
+      throw new HiveException(
+              "PRECEDING not allowed for finishing RANGE with multiple expressions in ORDER BY");
+    case CURRENT:
+      return computeEndCurrentRow(rowIdx, p);
+    case FOLLOWING:
+      default:
+        return computeEndFollowing(rowIdx, p);
+    }
+  }
+
+  protected int computeEndCurrentRow(int rowIdx, PTFPartition p) throws HiveException {
+    Object[] sortKey = computeValues(p.getAt(rowIdx));
+    Object[] rowVal = sortKey;
+    int r = rowIdx;
+
+    while (r < p.size() && isEqual(sortKey, rowVal) ) {
+      r++;
+      if ( r < p.size() ) {
+        rowVal = computeValues(p.getAt(r));
+      }
+    }
+    return r;
+  }
+
+  protected int computeEndFollowing(int rowIdx, PTFPartition p) throws HiveException {
+    int amt = end.getAmt();
+    if ( amt == BoundarySpec.UNBOUNDED_AMOUNT ) {
+      return p.size();
+    }
+    throw new HiveException(
+            "FOLLOWING needs UNBOUNDED for RANGE with multiple expressions in ORDER BY");
+  }
+
+  public Object[] computeValues(Object row) throws HiveException {
+    Object[] objs = new Object[orderDef.getExpressions().size()];
+    for (int i = 0; i < objs.length; i++) {
+      Object o = orderDef.getExpressions().get(i).getExprEvaluator().evaluate(row);
+      objs[i] = ObjectInspectorUtils.copyToStandardObject(o, orderDef.getExpressions().get(i).getOI());
+    }
+    return objs;
+  }
+
+  public boolean isEqual(Object[] v1, Object[] v2) {
+    assert v1.length == v2.length;
+    for (int i = 0; i < v1.length; i++) {
+      if (v1[i] == null && v2[i] == null) {
+        continue;
+      }
+      if (v1[i] == null || v2[i] == null) {
+        return false;
+      }
+      if (ObjectInspectorUtils.compare(
+              v1[i], orderDef.getExpressions().get(i).getOI(),
+              v2[i], orderDef.getExpressions().get(i).getOI()) != 0) {
+        return false;
+      }
+    }
+    return true;
+  }
+}
+


[12/13] hive git commit: HIVE-15520: Improve the sum performance for Range based window (Aihua Xu, reviewed by Yongzhi Chen)

Posted by ai...@apache.org.
http://git-wip-us.apache.org/repos/asf/hive/blob/a28b28f3/ql/src/java/org/apache/hadoop/hive/ql/udf/ptf/WindowingTableFunction.java
----------------------------------------------------------------------
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/udf/ptf/WindowingTableFunction.java b/ql/src/java/org/apache/hadoop/hive/ql/udf/ptf/WindowingTableFunction.java
index 2fdb492..86783be 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/udf/ptf/WindowingTableFunction.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/udf/ptf/WindowingTableFunction.java
@@ -20,7 +20,6 @@ package org.apache.hadoop.hive.ql.udf.ptf;
 
 import java.util.AbstractList;
 import java.util.ArrayList;
-import java.util.Date;
 import java.util.HashMap;
 import java.util.Iterator;
 import java.util.List;
@@ -28,25 +27,19 @@ import java.util.Map;
 
 import org.apache.commons.lang.ArrayUtils;
 import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.hive.common.type.HiveDecimal;
 import org.apache.hadoop.hive.conf.HiveConf;
 import org.apache.hadoop.hive.conf.HiveConf.ConfVars;
 import org.apache.hadoop.hive.ql.exec.FunctionRegistry;
-import org.apache.hadoop.hive.ql.exec.PTFOperator;
 import org.apache.hadoop.hive.ql.exec.PTFPartition;
 import org.apache.hadoop.hive.ql.exec.PTFPartition.PTFPartitionIterator;
 import org.apache.hadoop.hive.ql.exec.PTFRollingPartition;
 import org.apache.hadoop.hive.ql.exec.WindowFunctionInfo;
 import org.apache.hadoop.hive.ql.metadata.HiveException;
-import org.apache.hadoop.hive.ql.parse.PTFInvocationSpec.Order;
 import org.apache.hadoop.hive.ql.parse.SemanticException;
 import org.apache.hadoop.hive.ql.parse.WindowingSpec.BoundarySpec;
-import org.apache.hadoop.hive.ql.parse.WindowingSpec.Direction;
 import org.apache.hadoop.hive.ql.parse.WindowingSpec.WindowType;
 import org.apache.hadoop.hive.ql.plan.PTFDesc;
 import org.apache.hadoop.hive.ql.plan.ptf.BoundaryDef;
-import org.apache.hadoop.hive.ql.plan.ptf.OrderDef;
-import org.apache.hadoop.hive.ql.plan.ptf.OrderExpressionDef;
 import org.apache.hadoop.hive.ql.plan.ptf.PTFExpressionDef;
 import org.apache.hadoop.hive.ql.plan.ptf.PartitionedTableFunctionDef;
 import org.apache.hadoop.hive.ql.plan.ptf.WindowFrameDef;
@@ -61,7 +54,6 @@ import org.apache.hadoop.hive.serde2.objectinspector.ObjectInspectorUtils;
 import org.apache.hadoop.hive.serde2.objectinspector.PrimitiveObjectInspector;
 import org.apache.hadoop.hive.serde2.objectinspector.StructField;
 import org.apache.hadoop.hive.serde2.objectinspector.StructObjectInspector;
-import org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -112,16 +104,16 @@ public class WindowingTableFunction extends TableFunctionEvaluator {
 
     WindowTableFunctionDef wTFnDef = (WindowTableFunctionDef) getTableDef();
     for(WindowFunctionDef wFn : wTFnDef.getWindowFunctions()) {
-      boolean processWindow = processWindow(wFn);
+      boolean processWindow = processWindow(wFn.getWindowFrame());
       pItr.reset();
       if ( !processWindow ) {
-        Object out = evaluateWindowFunction(wFn, pItr);
+        Object out = evaluateFunctionOnPartition(wFn, iPart);
         if ( !wFn.isPivotResult()) {
           out = new SameList(iPart.size(), out);
         }
         oColumns.add((List<?>)out);
       } else {
-        oColumns.add(executeFnwithWindow(getQueryDef(), wFn, iPart));
+        oColumns.add(executeFnwithWindow(wFn, iPart));
       }
     }
 
@@ -147,30 +139,36 @@ public class WindowingTableFunction extends TableFunctionEvaluator {
     }
   }
 
-  Object evaluateWindowFunction(WindowFunctionDef wFn,
-      PTFPartitionIterator<Object> pItr) throws HiveException {
-    GenericUDAFEvaluator fEval = wFn.getWFnEval();
-    Object[] args = new Object[wFn.getArgs() == null ? 0 : wFn.getArgs().size()];
-    AggregationBuffer aggBuffer = fEval.getNewAggregationBuffer();
-    while(pItr.hasNext())
-    {
-      Object row = pItr.next();
-      int i =0;
-      if ( wFn.getArgs() != null ) {
-        for(PTFExpressionDef arg : wFn.getArgs())
-        {
-          args[i++] = arg.getExprEvaluator().evaluate(row);
-        }
-      }
-      fEval.aggregate(aggBuffer, args);
+  // Evaluate the result given a partition and the row number to process
+  private Object evaluateWindowFunction(WindowFunctionDef wFn, int rowToProcess, PTFPartition partition)
+      throws HiveException {
+    BasePartitionEvaluator partitionEval = wFn.getWFnEval()
+        .getPartitionWindowingEvaluator(wFn.getWindowFrame(), partition, wFn.getArgs(), wFn.getOI());
+    return partitionEval.iterate(rowToProcess, ptfDesc.getLlInfo());
+  }
+
+  // Evaluate the result given a partition
+  private Object evaluateFunctionOnPartition(WindowFunctionDef wFn,
+      PTFPartition partition) throws HiveException {
+    BasePartitionEvaluator partitionEval = wFn.getWFnEval()
+        .getPartitionWindowingEvaluator(wFn.getWindowFrame(), partition, wFn.getArgs(), wFn.getOI());
+    return partitionEval.getPartitionAgg();
+  }
+
+  // Evaluate the function result for each row in the partition
+  ArrayList<Object> executeFnwithWindow(
+      WindowFunctionDef wFnDef,
+      PTFPartition iPart)
+    throws HiveException {
+    ArrayList<Object> vals = new ArrayList<Object>();
+    for(int i=0; i < iPart.size(); i++) {
+      Object out = evaluateWindowFunction(wFnDef, i, iPart);
+      vals.add(out);
     }
-    Object out = fEval.evaluate(aggBuffer);
-    out = ObjectInspectorUtils.copyToStandardObject(out, wFn.getOI());
-    return out;
+    return vals;
   }
 
-  private boolean processWindow(WindowFunctionDef wFn) {
-    WindowFrameDef frame = wFn.getWindowFrame();
+  private static boolean processWindow(WindowFrameDef frame) {
     if ( frame == null ) {
       return false;
     }
@@ -391,7 +389,7 @@ public class WindowingTableFunction extends TableFunctionEvaluator {
 
     streamingState.rollingPart.append(row);
 
-    WindowTableFunctionDef tabDef = (WindowTableFunctionDef) getTableDef();
+    WindowTableFunctionDef tabDef = (WindowTableFunctionDef) tableDef;
 
     for (int i = 0; i < tabDef.getWindowFunctions().size(); i++) {
       WindowFunctionDef wFn = tabDef.getWindowFunctions().get(i);
@@ -417,10 +415,7 @@ public class WindowingTableFunction extends TableFunctionEvaluator {
       } else {
         int rowToProcess = streamingState.rollingPart.rowToProcess(wFn.getWindowFrame());
         if (rowToProcess >= 0) {
-          Range rng = getRange(wFn, rowToProcess, streamingState.rollingPart);
-          PTFPartitionIterator<Object> rItr = rng.iterator();
-          PTFOperator.connectLeadLagFunctionsToPartition(ptfDesc, rItr);
-          Object out = evaluateWindowFunction(wFn, rItr);
+          Object out =  evaluateWindowFunction(wFn, rowToProcess, streamingState.rollingPart);
           streamingState.fnOutputs[i].add(out);
         }
       }
@@ -495,10 +490,7 @@ public class WindowingTableFunction extends TableFunctionEvaluator {
         while (numRowsRemaining > 0) {
           int rowToProcess = streamingState.rollingPart.size() - numRowsRemaining;
           if (rowToProcess >= 0) {
-            Range rng = getRange(wFn, rowToProcess, streamingState.rollingPart);
-            PTFPartitionIterator<Object> rItr = rng.iterator();
-            PTFOperator.connectLeadLagFunctionsToPartition(ptfDesc, rItr);
-            Object out = evaluateWindowFunction(wFn, rItr);
+            Object out = evaluateWindowFunction(wFn, rowToProcess, streamingState.rollingPart);
             streamingState.fnOutputs[i].add(out);
           }
           numRowsRemaining--;
@@ -540,10 +532,10 @@ public class WindowingTableFunction extends TableFunctionEvaluator {
 
     int i=0;
     for(WindowFunctionDef wFn : wTFnDef.getWindowFunctions()) {
-      boolean processWindow = processWindow(wFn);
+      boolean processWindow = processWindow(wFn.getWindowFrame());
       pItr.reset();
       if ( !processWindow && !wFn.isPivotResult() ) {
-        Object out = evaluateWindowFunction(wFn, pItr);
+        Object out = evaluateFunctionOnPartition(wFn, iPart);
         output.add(out);
       } else if (wFn.isPivotResult()) {
         GenericUDAFEvaluator streamingEval = wFn.getWFnEval().getWindowingEvaluator(wFn.getWindowFrame());
@@ -558,12 +550,11 @@ public class WindowingTableFunction extends TableFunctionEvaluator {
             output.add(null);
             wFnsWithWindows.add(i);
           } else {
-            outputFromPivotFunctions[i] = (List) evaluateWindowFunction(wFn,
-                pItr);
+            outputFromPivotFunctions[i] = (List) evaluateFunctionOnPartition(wFn, iPart);
             output.add(null);
           }
         } else {
-          outputFromPivotFunctions[i] = (List) evaluateWindowFunction(wFn, pItr);
+          outputFromPivotFunctions[i] = (List) evaluateFunctionOnPartition(wFn, iPart);
           output.add(null);
         }
       } else {
@@ -652,797 +643,6 @@ public class WindowingTableFunction extends TableFunctionEvaluator {
 
   }
 
-  ArrayList<Object> executeFnwithWindow(PTFDesc ptfDesc,
-      WindowFunctionDef wFnDef,
-      PTFPartition iPart)
-    throws HiveException {
-    ArrayList<Object> vals = new ArrayList<Object>();
-    for(int i=0; i < iPart.size(); i++) {
-      Range rng = getRange(wFnDef, i, iPart);
-      PTFPartitionIterator<Object> rItr = rng.iterator();
-      PTFOperator.connectLeadLagFunctionsToPartition(ptfDesc, rItr);
-      Object out = evaluateWindowFunction(wFnDef, rItr);
-      vals.add(out);
-    }
-    return vals;
-  }
-
-  private Range getRange(WindowFunctionDef wFnDef, int currRow, PTFPartition p) throws HiveException
-  {
-    WindowFrameDef winFrame = wFnDef.getWindowFrame();
-    BoundaryDef startB = winFrame.getStart();
-    BoundaryDef endB = winFrame.getEnd();
-
-    int start, end;
-    if (winFrame.getWindowType() == WindowType.ROWS) {
-      start = getRowBoundaryStart(startB, currRow);
-      end = getRowBoundaryEnd(endB, currRow, p);
-    } else {
-      ValueBoundaryScanner vbs = ValueBoundaryScanner.getScanner(winFrame);
-      start = vbs.computeStart(currRow, p);
-      end = vbs.computeEnd(currRow, p);
-    }
-    start = start < 0 ? 0 : start;
-    end = end > p.size() ? p.size() : end;
-    return new Range(start, end, p);
-  }
-
-  private int getRowBoundaryStart(BoundaryDef b, int currRow) throws HiveException {
-    Direction d = b.getDirection();
-    int amt = b.getAmt();
-    switch(d) {
-    case PRECEDING:
-      if (amt == BoundarySpec.UNBOUNDED_AMOUNT) {
-        return 0;
-      }
-      else {
-        return currRow - amt;
-      }
-    case CURRENT:
-      return currRow;
-    case FOLLOWING:
-      return currRow + amt;
-    }
-    throw new HiveException("Unknown Start Boundary Direction: " + d);
-  }
-
-  private int getRowBoundaryEnd(BoundaryDef b, int currRow, PTFPartition p) throws HiveException {
-    Direction d = b.getDirection();
-    int amt = b.getAmt();
-    switch(d) {
-    case PRECEDING:
-      if ( amt == 0 ) {
-        return currRow + 1;
-      }
-      return currRow - amt + 1;
-    case CURRENT:
-      return currRow + 1;
-    case FOLLOWING:
-      if (amt == BoundarySpec.UNBOUNDED_AMOUNT) {
-        return p.size();
-      }
-      else {
-        return currRow + amt + 1;
-      }
-    }
-    throw new HiveException("Unknown End Boundary Direction: " + d);
-  }
-
-  static class Range
-  {
-    int start;
-    int end;
-    PTFPartition p;
-
-    public Range(int start, int end, PTFPartition p)
-    {
-      super();
-      this.start = start;
-      this.end = end;
-      this.p = p;
-    }
-
-    public PTFPartitionIterator<Object> iterator()
-    {
-      return p.range(start, end);
-    }
-  }
-
-
-  static abstract class ValueBoundaryScanner {
-    BoundaryDef start, end;
-
-    public ValueBoundaryScanner(BoundaryDef start, BoundaryDef end) {
-      this.start = start;
-      this.end = end;
-    }
-
-    protected abstract int computeStart(int rowIdx, PTFPartition p) throws HiveException;
-
-    protected abstract int computeEnd(int rowIdx, PTFPartition p) throws HiveException;
-
-    public static ValueBoundaryScanner getScanner(WindowFrameDef winFrameDef)
-        throws HiveException {
-      OrderDef orderDef = winFrameDef.getOrderDef();
-      int numOrders = orderDef.getExpressions().size();
-      if (numOrders != 1) {
-        return new MultiValueBoundaryScanner(winFrameDef.getStart(), winFrameDef.getEnd(), orderDef);
-      } else {
-        return SingleValueBoundaryScanner.getScanner(winFrameDef.getStart(), winFrameDef.getEnd(), orderDef);
-      }
-    }
-  }
-
-  /*
-   * - starting from the given rowIdx scan in the given direction until a row's expr
-   * evaluates to an amt that crosses the 'amt' threshold specified in the BoundaryDef.
-   */
-  static abstract class SingleValueBoundaryScanner extends ValueBoundaryScanner {
-    OrderExpressionDef expressionDef;
-
-    public SingleValueBoundaryScanner(BoundaryDef start, BoundaryDef end, OrderExpressionDef expressionDef) {
-      super(start, end);
-      this.expressionDef = expressionDef;
-    }
-
-    /*
-|  Use | Boundary1.type | Boundary1. amt | Sort Key | Order | Behavior                          |
-| Case |                |                |          |       |                                   |
-|------+----------------+----------------+----------+-------+-----------------------------------|
-|   1. | PRECEDING      | UNB            | ANY      | ANY   | start = 0                         |
-|   2. | PRECEDING      | unsigned int   | NULL     | ASC   | start = 0                         |
-|   3. |                |                |          | DESC  | scan backwards to row R2          |
-|      |                |                |          |       | such that R2.sk is not null       |
-|      |                |                |          |       | start = R2.idx + 1                |
-|   4. | PRECEDING      | unsigned int   | not NULL | DESC  | scan backwards until row R2       |
-|      |                |                |          |       | such that R2.sk - R.sk > amt      |
-|      |                |                |          |       | start = R2.idx + 1                |
-|   5. | PRECEDING      | unsigned int   | not NULL | ASC   | scan backward until row R2        |
-|      |                |                |          |       | such that R.sk - R2.sk > bnd1.amt |
-|      |                |                |          |       | start = R2.idx + 1                |
-|   6. | CURRENT ROW    |                | NULL     | ANY   | scan backwards until row R2       |
-|      |                |                |          |       | such that R2.sk is not null       |
-|      |                |                |          |       | start = R2.idx + 1                |
-|   7. | CURRENT ROW    |                | not NULL | ANY   | scan backwards until row R2       |
-|      |                |                |          |       | such R2.sk != R.sk                |
-|      |                |                |          |       | start = R2.idx + 1                |
-|   8. | FOLLOWING      | UNB            | ANY      | ANY   | Error                             |
-|   9. | FOLLOWING      | unsigned int   | NULL     | DESC  | start = partition.size            |
-|  10. |                |                |          | ASC   | scan forward until R2             |
-|      |                |                |          |       | such that R2.sk is not null       |
-|      |                |                |          |       | start = R2.idx                    |
-|  11. | FOLLOWING      | unsigned int   | not NULL | DESC  | scan forward until row R2         |
-|      |                |                |          |       | such that R.sk - R2.sk > amt      |
-|      |                |                |          |       | start = R2.idx                    |
-|  12. |                |                |          | ASC   | scan forward until row R2         |
-|      |                |                |          |       | such that R2.sk - R.sk > amt      |
-|------+----------------+----------------+----------+-------+-----------------------------------|
-     */
-    @Override
-    protected int computeStart(int rowIdx, PTFPartition p) throws HiveException {
-      switch(start.getDirection()) {
-      case PRECEDING:
-        return computeStartPreceding(rowIdx, p);
-      case CURRENT:
-        return computeStartCurrentRow(rowIdx, p);
-      case FOLLOWING:
-        default:
-          return computeStartFollowing(rowIdx, p);
-      }
-    }
-
-    protected int computeStartPreceding(int rowIdx, PTFPartition p) throws HiveException {
-      int amt = start.getAmt();
-      // Use Case 1.
-      if ( amt == BoundarySpec.UNBOUNDED_AMOUNT ) {
-        return 0;
-      }
-      Object sortKey = computeValue(p.getAt(rowIdx));
-
-      if ( sortKey == null ) {
-        // Use Case 2.
-        if ( expressionDef.getOrder() == Order.ASC ) {
-          return 0;
-        }
-        else { // Use Case 3.
-          while ( sortKey == null && rowIdx >= 0 ) {
-            --rowIdx;
-            if ( rowIdx >= 0 ) {
-              sortKey = computeValue(p.getAt(rowIdx));
-            }
-          }
-          return rowIdx+1;
-        }
-      }
-
-      Object rowVal = sortKey;
-      int r = rowIdx;
-
-      // Use Case 4.
-      if ( expressionDef.getOrder() == Order.DESC ) {
-        while (r >= 0 && !isDistanceGreater(rowVal, sortKey, amt) ) {
-          r--;
-          if ( r >= 0 ) {
-            rowVal = computeValue(p.getAt(r));
-          }
-        }
-        return r + 1;
-      }
-      else { // Use Case 5.
-        while (r >= 0 && !isDistanceGreater(sortKey, rowVal, amt) ) {
-          r--;
-          if ( r >= 0 ) {
-            rowVal = computeValue(p.getAt(r));
-          }
-        }
-        return r + 1;
-      }
-    }
-
-    protected int computeStartCurrentRow(int rowIdx, PTFPartition p) throws HiveException {
-      Object sortKey = computeValue(p.getAt(rowIdx));
-
-      // Use Case 6.
-      if ( sortKey == null ) {
-        while ( sortKey == null && rowIdx >= 0 ) {
-          --rowIdx;
-          if ( rowIdx >= 0 ) {
-            sortKey = computeValue(p.getAt(rowIdx));
-          }
-        }
-        return rowIdx+1;
-      }
-
-      Object rowVal = sortKey;
-      int r = rowIdx;
-
-      // Use Case 7.
-      while (r >= 0 && isEqual(rowVal, sortKey) ) {
-        r--;
-        if ( r >= 0 ) {
-          rowVal = computeValue(p.getAt(r));
-        }
-      }
-      return r + 1;
-    }
-
-    protected int computeStartFollowing(int rowIdx, PTFPartition p) throws HiveException {
-      int amt = start.getAmt();
-      Object sortKey = computeValue(p.getAt(rowIdx));
-
-      Object rowVal = sortKey;
-      int r = rowIdx;
-
-      if ( sortKey == null ) {
-        // Use Case 9.
-        if ( expressionDef.getOrder() == Order.DESC) {
-          return p.size();
-        }
-        else { // Use Case 10.
-          while (r < p.size() && rowVal == null ) {
-            r++;
-            if ( r < p.size() ) {
-              rowVal = computeValue(p.getAt(r));
-            }
-          }
-          return r;
-        }
-      }
-
-      // Use Case 11.
-      if ( expressionDef.getOrder() == Order.DESC) {
-        while (r < p.size() && !isDistanceGreater(sortKey, rowVal, amt) ) {
-          r++;
-          if ( r < p.size() ) {
-            rowVal = computeValue(p.getAt(r));
-          }
-        }
-        return r;
-      }
-      else { // Use Case 12.
-        while (r < p.size() && !isDistanceGreater(rowVal, sortKey, amt) ) {
-          r++;
-          if ( r < p.size() ) {
-            rowVal = computeValue(p.getAt(r));
-          }
-        }
-        return r;
-      }
-    }
-
-    /*
-|  Use | Boundary2.type | Boundary2.amt | Sort Key | Order | Behavior                          |
-| Case |                |               |          |       |                                   |
-|------+----------------+---------------+----------+-------+-----------------------------------|
-|   1. | PRECEDING      | UNB           | ANY      | ANY   | Error                             |
-|   2. | PRECEDING      | unsigned int  | NULL     | DESC  | end = partition.size()            |
-|   3. |                |               |          | ASC   | end = 0                           |
-|   4. | PRECEDING      | unsigned int  | not null | DESC  | scan backward until row R2        |
-|      |                |               |          |       | such that R2.sk - R.sk > bnd.amt  |
-|      |                |               |          |       | end = R2.idx + 1                  |
-|   5. | PRECEDING      | unsigned int  | not null | ASC   | scan backward until row R2        |
-|      |                |               |          |       | such that R.sk -  R2.sk > bnd.amt |
-|      |                |               |          |       | end = R2.idx + 1                  |
-|   6. | CURRENT ROW    |               | NULL     | ANY   | scan forward until row R2         |
-|      |                |               |          |       | such that R2.sk is not null       |
-|      |                |               |          |       | end = R2.idx                      |
-|   7. | CURRENT ROW    |               | not null | ANY   | scan forward until row R2         |
-|      |                |               |          |       | such that R2.sk != R.sk           |
-|      |                |               |          |       | end = R2.idx                      |
-|   8. | FOLLOWING      | UNB           | ANY      | ANY   | end = partition.size()            |
-|   9. | FOLLOWING      | unsigned int  | NULL     | DESC  | end = partition.size()            |
-|  10. |                |               |          | ASC   | scan forward until row R2         |
-|      |                |               |          |       | such that R2.sk is not null       |
-|      |                |               |          |       | end = R2.idx                      |
-|  11. | FOLLOWING      | unsigned int  | not NULL | DESC  | scan forward until row R2         |
-|      |                |               |          |       | such R.sk - R2.sk > bnd.amt       |
-|      |                |               |          |       | end = R2.idx                      |
-|  12. |                |               |          | ASC   | scan forward until row R2         |
-|      |                |               |          |       | such R2.sk - R2.sk > bnd.amt      |
-|      |                |               |          |       | end = R2.idx                      |
-|------+----------------+---------------+----------+-------+-----------------------------------|
-     */
-    @Override
-    protected int computeEnd(int rowIdx, PTFPartition p) throws HiveException {
-      switch(end.getDirection()) {
-      case PRECEDING:
-        return computeEndPreceding(rowIdx, p);
-      case CURRENT:
-        return computeEndCurrentRow(rowIdx, p);
-      case FOLLOWING:
-        default:
-          return computeEndFollowing(rowIdx, p);
-      }
-    }
-
-    protected int computeEndPreceding(int rowIdx, PTFPartition p) throws HiveException {
-      int amt = end.getAmt();
-      // Use Case 1.
-      // amt == UNBOUNDED, is caught during translation
-
-      Object sortKey = computeValue(p.getAt(rowIdx));
-
-      if ( sortKey == null ) {
-        // Use Case 2.
-        if ( expressionDef.getOrder() == Order.DESC ) {
-          return p.size();
-        }
-        else { // Use Case 3.
-          return 0;
-        }
-      }
-
-      Object rowVal = sortKey;
-      int r = rowIdx;
-
-      // Use Case 4.
-      if ( expressionDef.getOrder() == Order.DESC ) {
-        while (r >= 0 && !isDistanceGreater(rowVal, sortKey, amt) ) {
-          r--;
-          if ( r >= 0 ) {
-            rowVal = computeValue(p.getAt(r));
-          }
-        }
-        return r + 1;
-      }
-      else { // Use Case 5.
-        while (r >= 0 && !isDistanceGreater(sortKey, rowVal, amt) ) {
-          r--;
-          if ( r >= 0 ) {
-            rowVal = computeValue(p.getAt(r));
-          }
-        }
-        return r + 1;
-      }
-    }
-
-    protected int computeEndCurrentRow(int rowIdx, PTFPartition p) throws HiveException {
-      Object sortKey = computeValue(p.getAt(rowIdx));
-
-      // Use Case 6.
-      if ( sortKey == null ) {
-        while ( sortKey == null && rowIdx < p.size() ) {
-          ++rowIdx;
-          if ( rowIdx < p.size() ) {
-            sortKey = computeValue(p.getAt(rowIdx));
-          }
-        }
-        return rowIdx;
-      }
-
-      Object rowVal = sortKey;
-      int r = rowIdx;
-
-      // Use Case 7.
-      while (r < p.size() && isEqual(sortKey, rowVal) ) {
-        r++;
-        if ( r < p.size() ) {
-          rowVal = computeValue(p.getAt(r));
-        }
-      }
-      return r;
-    }
-
-    protected int computeEndFollowing(int rowIdx, PTFPartition p) throws HiveException {
-      int amt = end.getAmt();
-
-      // Use Case 8.
-      if ( amt == BoundarySpec.UNBOUNDED_AMOUNT ) {
-        return p.size();
-      }
-      Object sortKey = computeValue(p.getAt(rowIdx));
-
-      Object rowVal = sortKey;
-      int r = rowIdx;
-
-      if ( sortKey == null ) {
-        // Use Case 9.
-        if ( expressionDef.getOrder() == Order.DESC) {
-          return p.size();
-        }
-        else { // Use Case 10.
-          while (r < p.size() && rowVal == null ) {
-            r++;
-            if ( r < p.size() ) {
-              rowVal = computeValue(p.getAt(r));
-            }
-          }
-          return r;
-        }
-      }
-
-      // Use Case 11.
-      if ( expressionDef.getOrder() == Order.DESC) {
-        while (r < p.size() && !isDistanceGreater(sortKey, rowVal, amt) ) {
-          r++;
-          if ( r < p.size() ) {
-            rowVal = computeValue(p.getAt(r));
-          }
-        }
-        return r;
-      }
-      else { // Use Case 12.
-        while (r < p.size() && !isDistanceGreater(rowVal, sortKey, amt) ) {
-          r++;
-          if ( r < p.size() ) {
-            rowVal = computeValue(p.getAt(r));
-          }
-        }
-        return r;
-      }
-    }
-
-    public Object computeValue(Object row) throws HiveException {
-      Object o = expressionDef.getExprEvaluator().evaluate(row);
-      return ObjectInspectorUtils.copyToStandardObject(o, expressionDef.getOI());
-    }
-
-    /**
-     * Checks if the distance of v2 to v1 is greater than the given amt.
-     * @return True if the value of v1 - v2 is greater than amt or either value is null.
-     */
-    public abstract boolean isDistanceGreater(Object v1, Object v2, int amt);
-
-    /**
-     * Checks if the values of v1 or v2 are the same.
-     * @return True if both values are the same or both are nulls.
-     */
-    public abstract boolean isEqual(Object v1, Object v2);
-
-
-    @SuppressWarnings("incomplete-switch")
-    public static SingleValueBoundaryScanner getScanner(BoundaryDef start, BoundaryDef end, OrderDef orderDef)
-        throws HiveException {
-      if (orderDef.getExpressions().size() != 1) {
-        throw new HiveException("Internal error: initializing SingleValueBoundaryScanner with"
-                + " multiple expression for sorting");
-      }
-      OrderExpressionDef exprDef = orderDef.getExpressions().get(0);
-      PrimitiveObjectInspector pOI = (PrimitiveObjectInspector) exprDef.getOI();
-      switch(pOI.getPrimitiveCategory()) {
-      case BYTE:
-      case INT:
-      case LONG:
-      case SHORT:
-      case TIMESTAMP:
-        return new LongValueBoundaryScanner(start, end, exprDef);
-      case DOUBLE:
-      case FLOAT:
-        return new DoubleValueBoundaryScanner(start, end, exprDef);
-      case DECIMAL:
-        return new HiveDecimalValueBoundaryScanner(start, end, exprDef);
-      case DATE:
-        return new DateValueBoundaryScanner(start, end, exprDef);
-      case STRING:
-        return new StringValueBoundaryScanner(start, end, exprDef);
-      }
-      throw new HiveException(
-          String.format("Internal Error: attempt to setup a Window for datatype %s",
-              pOI.getPrimitiveCategory()));
-    }
-  }
-
-  public static class LongValueBoundaryScanner extends SingleValueBoundaryScanner {
-    public LongValueBoundaryScanner(BoundaryDef start, BoundaryDef end, OrderExpressionDef expressionDef) {
-      super(start, end,expressionDef);
-    }
-
-    @Override
-    public boolean isDistanceGreater(Object v1, Object v2, int amt) {
-      if (v1 != null && v2 != null) {
-        long l1 = PrimitiveObjectInspectorUtils.getLong(v1,
-            (PrimitiveObjectInspector) expressionDef.getOI());
-        long l2 = PrimitiveObjectInspectorUtils.getLong(v2,
-            (PrimitiveObjectInspector) expressionDef.getOI());
-        return (l1 -l2) > amt;
-      }
-
-      return v1 != null || v2 != null; // True if only one value is null
-    }
-
-    @Override
-    public boolean isEqual(Object v1, Object v2) {
-      if (v1 != null && v2 != null) {
-        long l1 = PrimitiveObjectInspectorUtils.getLong(v1,
-            (PrimitiveObjectInspector) expressionDef.getOI());
-        long l2 = PrimitiveObjectInspectorUtils.getLong(v2,
-            (PrimitiveObjectInspector) expressionDef.getOI());
-        return l1 == l2;
-      }
-
-      return v1 == null && v2 == null; // True if both are null
-    }
-  }
-
-  public static class DoubleValueBoundaryScanner extends SingleValueBoundaryScanner {
-    public DoubleValueBoundaryScanner(BoundaryDef start, BoundaryDef end, OrderExpressionDef expressionDef) {
-      super(start, end,expressionDef);
-    }
-
-    @Override
-    public boolean isDistanceGreater(Object v1, Object v2, int amt) {
-      if (v1 != null && v2 != null) {
-        double d1 = PrimitiveObjectInspectorUtils.getDouble(v1,
-            (PrimitiveObjectInspector) expressionDef.getOI());
-        double d2 = PrimitiveObjectInspectorUtils.getDouble(v2,
-            (PrimitiveObjectInspector) expressionDef.getOI());
-        return (d1 -d2) > amt;
-      }
-
-      return v1 != null || v2 != null; // True if only one value is null
-    }
-
-    @Override
-    public boolean isEqual(Object v1, Object v2) {
-      if (v1 != null && v2 != null) {
-        double d1 = PrimitiveObjectInspectorUtils.getDouble(v1,
-            (PrimitiveObjectInspector) expressionDef.getOI());
-        double d2 = PrimitiveObjectInspectorUtils.getDouble(v2,
-            (PrimitiveObjectInspector) expressionDef.getOI());
-        return d1 == d2;
-      }
-
-      return v1 == null && v2 == null; // True if both are null
-    }
-  }
-
-  public static class HiveDecimalValueBoundaryScanner extends SingleValueBoundaryScanner {
-    public HiveDecimalValueBoundaryScanner(BoundaryDef start, BoundaryDef end, OrderExpressionDef expressionDef) {
-      super(start, end,expressionDef);
-    }
-
-    @Override
-    public boolean isDistanceGreater(Object v1, Object v2, int amt) {
-      HiveDecimal d1 = PrimitiveObjectInspectorUtils.getHiveDecimal(v1,
-          (PrimitiveObjectInspector) expressionDef.getOI());
-      HiveDecimal d2 = PrimitiveObjectInspectorUtils.getHiveDecimal(v2,
-          (PrimitiveObjectInspector) expressionDef.getOI());
-      if ( d1 != null && d2 != null ) {
-        return d1.subtract(d2).intValue() > amt;  // TODO: lossy conversion!
-      }
-
-      return d1 != null || d2 != null; // True if only one value is null
-    }
-
-    @Override
-    public boolean isEqual(Object v1, Object v2) {
-      HiveDecimal d1 = PrimitiveObjectInspectorUtils.getHiveDecimal(v1,
-          (PrimitiveObjectInspector) expressionDef.getOI());
-      HiveDecimal d2 = PrimitiveObjectInspectorUtils.getHiveDecimal(v2,
-          (PrimitiveObjectInspector) expressionDef.getOI());
-      if ( d1 != null && d2 != null ) {
-        return d1.equals(d2);
-      }
-
-      return d1 == null && d2 == null; // True if both are null
-    }
-  }
-
-  public static class DateValueBoundaryScanner extends SingleValueBoundaryScanner {
-    public DateValueBoundaryScanner(BoundaryDef start, BoundaryDef end, OrderExpressionDef expressionDef) {
-      super(start, end,expressionDef);
-    }
-
-    @Override
-    public boolean isDistanceGreater(Object v1, Object v2, int amt) {
-      Date l1 = PrimitiveObjectInspectorUtils.getDate(v1,
-          (PrimitiveObjectInspector) expressionDef.getOI());
-      Date l2 = PrimitiveObjectInspectorUtils.getDate(v2,
-          (PrimitiveObjectInspector) expressionDef.getOI());
-      if (l1 != null && l2 != null) {
-          return (double)(l1.getTime() - l2.getTime())/1000 > (long)amt * 24 * 3600; // Converts amt days to milliseconds
-      }
-      return l1 != l2; // True if only one date is null
-    }
-
-    @Override
-    public boolean isEqual(Object v1, Object v2) {
-      Date l1 = PrimitiveObjectInspectorUtils.getDate(v1,
-          (PrimitiveObjectInspector) expressionDef.getOI());
-      Date l2 = PrimitiveObjectInspectorUtils.getDate(v2,
-          (PrimitiveObjectInspector) expressionDef.getOI());
-      return (l1 == null && l2 == null) || (l1 != null && l1.equals(l2));
-    }
-  }
-
-  public static class StringValueBoundaryScanner extends SingleValueBoundaryScanner {
-    public StringValueBoundaryScanner(BoundaryDef start, BoundaryDef end, OrderExpressionDef expressionDef) {
-      super(start, end,expressionDef);
-    }
-
-    @Override
-    public boolean isDistanceGreater(Object v1, Object v2, int amt) {
-      String s1 = PrimitiveObjectInspectorUtils.getString(v1,
-          (PrimitiveObjectInspector) expressionDef.getOI());
-      String s2 = PrimitiveObjectInspectorUtils.getString(v2,
-          (PrimitiveObjectInspector) expressionDef.getOI());
-      return s1 != null && s2 != null && s1.compareTo(s2) > 0;
-    }
-
-    @Override
-    public boolean isEqual(Object v1, Object v2) {
-      String s1 = PrimitiveObjectInspectorUtils.getString(v1,
-          (PrimitiveObjectInspector) expressionDef.getOI());
-      String s2 = PrimitiveObjectInspectorUtils.getString(v2,
-          (PrimitiveObjectInspector) expressionDef.getOI());
-      return (s1 == null && s2 == null) || (s1 != null && s1.equals(s2));
-    }
-  }
-
-  /*
-   */
-  static class MultiValueBoundaryScanner extends ValueBoundaryScanner {
-    OrderDef orderDef;
-
-    public MultiValueBoundaryScanner(BoundaryDef start, BoundaryDef end, OrderDef orderDef) {
-      super(start, end);
-      this.orderDef = orderDef;
-    }
-
-    /*
-|------+----------------+----------------+----------+-------+-----------------------------------|
-| Use  | Boundary1.type | Boundary1. amt | Sort Key | Order | Behavior                          |
-| Case |                |                |          |       |                                   |
-|------+----------------+----------------+----------+-------+-----------------------------------|
-|   1. | PRECEDING      | UNB            | ANY      | ANY   | start = 0                         |
-|   2. | CURRENT ROW    |                | ANY      | ANY   | scan backwards until row R2       |
-|      |                |                |          |       | such R2.sk != R.sk                |
-|      |                |                |          |       | start = R2.idx + 1                |
-|------+----------------+----------------+----------+-------+-----------------------------------|
-     */
-    @Override
-    protected int computeStart(int rowIdx, PTFPartition p) throws HiveException {
-      switch(start.getDirection()) {
-      case PRECEDING:
-        return computeStartPreceding(rowIdx, p);
-      case CURRENT:
-        return computeStartCurrentRow(rowIdx, p);
-      case FOLLOWING:
-        default:
-          throw new HiveException(
-                  "FOLLOWING not allowed for starting RANGE with multiple expressions in ORDER BY");
-      }
-    }
-
-    protected int computeStartPreceding(int rowIdx, PTFPartition p) throws HiveException {
-      int amt = start.getAmt();
-      if ( amt == BoundarySpec.UNBOUNDED_AMOUNT ) {
-        return 0;
-      }
-      throw new HiveException(
-              "PRECEDING needs UNBOUNDED for RANGE with multiple expressions in ORDER BY");
-    }
-
-    protected int computeStartCurrentRow(int rowIdx, PTFPartition p) throws HiveException {
-      Object[] sortKey = computeValues(p.getAt(rowIdx));
-      Object[] rowVal = sortKey;
-      int r = rowIdx;
-
-      while (r >= 0 && isEqual(rowVal, sortKey) ) {
-        r--;
-        if ( r >= 0 ) {
-          rowVal = computeValues(p.getAt(r));
-        }
-      }
-      return r + 1;
-    }
-
-    /*
-|------+----------------+---------------+----------+-------+-----------------------------------|
-| Use  | Boundary2.type | Boundary2.amt | Sort Key | Order | Behavior                          |
-| Case |                |               |          |       |                                   |
-|------+----------------+---------------+----------+-------+-----------------------------------|
-|   1. | CURRENT ROW    |               | ANY      | ANY   | scan forward until row R2         |
-|      |                |               |          |       | such that R2.sk != R.sk           |
-|      |                |               |          |       | end = R2.idx                      |
-|   2. | FOLLOWING      | UNB           | ANY      | ANY   | end = partition.size()            |
-|------+----------------+---------------+----------+-------+-----------------------------------|
-     */
-    @Override
-    protected int computeEnd(int rowIdx, PTFPartition p) throws HiveException {
-      switch(end.getDirection()) {
-      case PRECEDING:
-        throw new HiveException(
-                "PRECEDING not allowed for finishing RANGE with multiple expressions in ORDER BY");
-      case CURRENT:
-        return computeEndCurrentRow(rowIdx, p);
-      case FOLLOWING:
-        default:
-          return computeEndFollowing(rowIdx, p);
-      }
-    }
-
-    protected int computeEndCurrentRow(int rowIdx, PTFPartition p) throws HiveException {
-      Object[] sortKey = computeValues(p.getAt(rowIdx));
-      Object[] rowVal = sortKey;
-      int r = rowIdx;
-
-      while (r < p.size() && isEqual(sortKey, rowVal) ) {
-        r++;
-        if ( r < p.size() ) {
-          rowVal = computeValues(p.getAt(r));
-        }
-      }
-      return r;
-    }
-
-    protected int computeEndFollowing(int rowIdx, PTFPartition p) throws HiveException {
-      int amt = end.getAmt();
-      if ( amt == BoundarySpec.UNBOUNDED_AMOUNT ) {
-        return p.size();
-      }
-      throw new HiveException(
-              "FOLLOWING needs UNBOUNDED for RANGE with multiple expressions in ORDER BY");
-    }
-
-    public Object[] computeValues(Object row) throws HiveException {
-      Object[] objs = new Object[orderDef.getExpressions().size()];
-      for (int i = 0; i < objs.length; i++) {
-        Object o = orderDef.getExpressions().get(i).getExprEvaluator().evaluate(row);
-        objs[i] = ObjectInspectorUtils.copyToStandardObject(o, orderDef.getExpressions().get(i).getOI());
-      }
-      return objs;
-    }
-
-    public boolean isEqual(Object[] v1, Object[] v2) {
-      assert v1.length == v2.length;
-      for (int i = 0; i < v1.length; i++) {
-        if (v1[i] == null && v2[i] == null) {
-          continue;
-        }
-        if (v1[i] == null || v2[i] == null) {
-          return false;
-        }
-        if (ObjectInspectorUtils.compare(
-                v1[i], orderDef.getExpressions().get(i).getOI(),
-                v2[i], orderDef.getExpressions().get(i).getOI()) != 0) {
-          return false;
-        }
-      }
-      return true;
-    }
-  }
-
   public static class SameList<E> extends AbstractList<E> {
     int sz;
     E val;
@@ -1518,6 +718,8 @@ public class WindowingTableFunction extends TableFunctionEvaluator {
       return currIdx < iPart.size();
     }
 
+    // Given the data in a partition, evaluate the result for the next row for
+    // streaming and batch mode
     @Override
     public Object next() {
       int i;
@@ -1550,10 +752,8 @@ public class WindowingTableFunction extends TableFunctionEvaluator {
             }
             output.set(j, out);
           } else {
-            Range rng = getRange(wFn, currIdx, iPart);
-            PTFPartitionIterator<Object> rItr = rng.iterator();
-            PTFOperator.connectLeadLagFunctionsToPartition(ptfDesc, rItr);
-            output.set(j, evaluateWindowFunction(wFn, rItr));
+            Object out = evaluateWindowFunction(wFn, currIdx, iPart);
+            output.set(j, out);
           }
         }
 

http://git-wip-us.apache.org/repos/asf/hive/blob/a28b28f3/ql/src/test/queries/clientpositive/cbo_rp_windowing_2.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientpositive/cbo_rp_windowing_2.q b/ql/src/test/queries/clientpositive/cbo_rp_windowing_2.q
index 97f113c..1877927 100644
--- a/ql/src/test/queries/clientpositive/cbo_rp_windowing_2.q
+++ b/ql/src/test/queries/clientpositive/cbo_rp_windowing_2.q
@@ -9,7 +9,7 @@ set mapred.reduce.tasks=4;
 select p_mfgr, p_name, p_size,
 rank() over(distribute by p_mfgr sort by p_name) as r,
 dense_rank() over(distribute by p_mfgr sort by p_name) as dr,
-sum(p_retailprice) over (distribute by p_mfgr sort by p_name rows between unbounded preceding and current row) as s1
+round(sum(p_retailprice) over (distribute by p_mfgr sort by p_name rows between unbounded preceding and current row),2) as s1
 from part
 ;
 
@@ -44,7 +44,7 @@ select p_mfgr, p_name,
 rank() over(distribute by p_mfgr sort by p_name) as r, 
 dense_rank() over(distribute by p_mfgr sort by p_name) as dr, 
 count(p_size) over(distribute by p_mfgr sort by p_name) as cd, 
-p_retailprice, sum(p_retailprice) over (distribute by p_mfgr sort by p_name rows between unbounded preceding and current row) as s1, 
+p_retailprice, round(sum(p_retailprice) over (distribute by p_mfgr sort by p_name rows between unbounded preceding and current row),2) as s1, 
 p_size, p_size - lag(p_size,1,p_size) over(distribute by p_mfgr sort by p_name) as deltaSz 
 from part 
 ;
@@ -55,7 +55,7 @@ from (select p_mfgr, p_name,
 rank() over(distribute by p_mfgr sort by p_name) as r, 
 dense_rank() over(distribute by p_mfgr sort by p_name) as dr, 
 count(p_size) over(distribute by p_mfgr sort by p_name) as cd, 
-p_retailprice, sum(p_retailprice) over (distribute by p_mfgr sort by p_name rows between unbounded preceding and current row) as s1, 
+p_retailprice, round(sum(p_retailprice) over (distribute by p_mfgr sort by p_name rows between unbounded preceding and current row),2) as s1, 
 p_size, p_size - lag(p_size,1,p_size) over(distribute by p_mfgr sort by p_name) as deltaSz 
 from part 
 ) sub1;
@@ -64,7 +64,7 @@ from part
 select abc.p_mfgr, abc.p_name, 
 rank() over(distribute by abc.p_mfgr sort by abc.p_name) as r, 
 dense_rank() over(distribute by abc.p_mfgr sort by abc.p_name) as dr, 
-abc.p_retailprice, sum(abc.p_retailprice) over (distribute by abc.p_mfgr sort by abc.p_name rows between unbounded preceding and current row) as s1, 
+abc.p_retailprice, round(sum(abc.p_retailprice) over (distribute by abc.p_mfgr sort by abc.p_name rows between unbounded preceding and current row),2) as s1, 
 abc.p_size, abc.p_size - lag(abc.p_size,1,abc.p_size) over(distribute by abc.p_mfgr sort by abc.p_name) as deltaSz 
 from noop(on part 
 partition by p_mfgr 
@@ -82,7 +82,7 @@ from part
 select p_mfgr, p_name, p_size, 
 rank() over(distribute by p_mfgr sort by p_name) as r, 
 dense_rank() over(distribute by p_mfgr sort by p_name) as dr, 
-sum(p_retailprice) over (distribute by p_mfgr sort by p_name rows between unbounded preceding and current row)  as s1
+round(sum(p_retailprice) over (distribute by p_mfgr sort by p_name rows between unbounded preceding and current row),2) as s1
 from part  
 ; 
 
@@ -90,7 +90,7 @@ from part
 select p_mfgr, p_name, p_size, 
 rank() over(distribute by p_mfgr sort by p_name) as r, 
 dense_rank() over(distribute by p_mfgr sort by p_name) as dr, 
-sum(p_retailprice) over (distribute by p_mfgr sort by p_name rows between unbounded preceding and current row) as s1 
+round(sum(p_retailprice) over (distribute by p_mfgr sort by p_name rows between unbounded preceding and current row),2) as s1 
 from part 
 ;
 
@@ -162,19 +162,19 @@ window w1 as (distribute by p_mfgr sort by p_mfgr, p_name rows between 2 precedi
 
 -- 18. testUDAFs
 select  p_mfgr,p_name, p_size, 
-sum(p_retailprice) over w1 as s, 
+round(sum(p_retailprice) over w1,2) as s,
 min(p_retailprice) over w1 as mi,
 max(p_retailprice) over w1 as ma,
-avg(p_retailprice) over w1 as ag
+round(avg(p_retailprice) over w1,2) as ag
 from part
 window w1 as (distribute by p_mfgr sort by p_mfgr, p_name rows between 2 preceding and 2 following);
 
 -- 19. testUDAFsWithGBY
 select  p_mfgr,p_name, p_size, p_retailprice, 
-sum(p_retailprice) over w1 as s, 
+round(sum(p_retailprice) over w1,2) as s,
 min(p_retailprice) as mi ,
 max(p_retailprice) as ma ,
-avg(p_retailprice) over w1 as ag
+round(avg(p_retailprice) over w1,2) as ag
 from part
 group by p_mfgr,p_name, p_size, p_retailprice
 window w1 as (distribute by p_mfgr sort by p_mfgr, p_name rows between 2 preceding and 2 following);
@@ -222,7 +222,7 @@ window w1 as (distribute by p_mfgr sort by p_brand rows between 2 preceding and
 -- 23. testCreateViewWithWindowingQuery
 create view IF NOT EXISTS mfgr_brand_price_view as 
 select p_mfgr, p_brand, 
-sum(p_retailprice) over w1  as s
+round(sum(p_retailprice) over w1,2) as s
 from part 
 window w1 as (distribute by p_mfgr sort by p_name rows between 2 preceding and current row);
         
@@ -267,7 +267,7 @@ INSERT OVERWRITE TABLE part_1
 select p_mfgr, p_name, p_size, 
 rank() over(distribute by p_mfgr sort by p_name ) as r, 
 dense_rank() over(distribute by p_mfgr sort by p_name ) as dr, 
-sum(p_retailprice) over (distribute by p_mfgr sort by p_name rows between unbounded preceding and current row)  as s
+round(sum(p_retailprice) over (distribute by p_mfgr sort by p_name rows between unbounded preceding and current row),2) as s
 INSERT OVERWRITE TABLE part_2 
 select  p_mfgr,p_name, p_size,  
 rank() over(distribute by p_mfgr sort by p_name) as r, 
@@ -386,7 +386,7 @@ from part;
 
 -- 38. testPartitioningVariousForms2
 select p_mfgr, p_name, p_size,
-sum(p_retailprice) over (partition by p_mfgr, p_name order by p_mfgr, p_name rows between unbounded preceding and current row) as s1,
+round(sum(p_retailprice) over (partition by p_mfgr, p_name order by p_mfgr, p_name rows between unbounded preceding and current row),2) as s1,
 min(p_retailprice) over (distribute by p_mfgr, p_name sort by p_mfgr, p_name rows between unbounded preceding and current row) as s2,
 max(p_retailprice) over (partition by p_mfgr, p_name order by p_name) as s3
 from part;
@@ -398,22 +398,22 @@ from part;
 
 -- 40. testNoBetweenForRows
 select p_mfgr, p_name, p_size,
-    sum(p_retailprice) over (distribute by p_mfgr sort by p_name rows unbounded preceding) as s1
+    round(sum(p_retailprice) over (distribute by p_mfgr sort by p_name rows unbounded preceding),2) as s1
      from part ;
 
 -- 41. testNoBetweenForRange
 select p_mfgr, p_name, p_size,
-    sum(p_retailprice) over (distribute by p_mfgr sort by p_size range unbounded preceding) as s1
+    round(sum(p_retailprice) over (distribute by p_mfgr sort by p_size range unbounded preceding),2) as s1
      from part ;
 
 -- 42. testUnboundedFollowingForRows
 select p_mfgr, p_name, p_size,
-    sum(p_retailprice) over (distribute by p_mfgr sort by p_name rows between current row and unbounded following) as s1
+    round(sum(p_retailprice) over (distribute by p_mfgr sort by p_name rows between current row and unbounded following),2) as s1
     from part ;
 
 -- 43. testUnboundedFollowingForRange
 select p_mfgr, p_name, p_size,
-    sum(p_retailprice) over (distribute by p_mfgr sort by p_size range between current row and unbounded following) as s1
+    round(sum(p_retailprice) over (distribute by p_mfgr sort by p_size range between current row and unbounded following),2) as s1
     from part ;
         
 -- 44. testOverNoPartitionSingleAggregate
@@ -430,8 +430,8 @@ where p_mfgr = 'Manufacturer#6'
 ;
 
 -- 46. window sz is same as partition sz
-select p_retailprice, avg(p_retailprice) over (partition by p_mfgr order by p_name rows between current row and 6 following), 
-sum(p_retailprice) over (partition by p_mfgr order by p_name rows between current row and 6 following) 
+select p_retailprice, round(avg(p_retailprice) over (partition by p_mfgr order by p_name rows between current row and 6 following),2), 
+round(sum(p_retailprice) over (partition by p_mfgr order by p_name rows between current row and 6 following),2) 
 from part 
 where p_mfgr='Manufacturer#1';
 

http://git-wip-us.apache.org/repos/asf/hive/blob/a28b28f3/ql/src/test/queries/clientpositive/ptf.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientpositive/ptf.q b/ql/src/test/queries/clientpositive/ptf.q
index b5b271b..5ab6cdc 100644
--- a/ql/src/test/queries/clientpositive/ptf.q
+++ b/ql/src/test/queries/clientpositive/ptf.q
@@ -6,7 +6,7 @@ explain
 select p_mfgr, p_name, p_size,
 rank() over (partition by p_mfgr order by p_name) as r,
 dense_rank() over (partition by p_mfgr order by p_name) as dr,
-sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row) as s1
+round(sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row),2) as s1
 from noop(on part 
   partition by p_mfgr
   order by p_name
@@ -15,7 +15,7 @@ from noop(on part
 select p_mfgr, p_name, p_size,
 rank() over (partition by p_mfgr order by p_name) as r,
 dense_rank() over (partition by p_mfgr order by p_name) as dr,
-sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row) as s1
+round(sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row),2) as s1
 from noop(on part 
   partition by p_mfgr
   order by p_name
@@ -54,7 +54,7 @@ explain
 select p_mfgr, p_name, p_size,
 rank() over (partition by p_mfgr order by p_name) as r,
 dense_rank() over (partition by p_mfgr order by p_name) as dr,
-sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row) as s1
+round(sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row),2) as s1
 from noop(on part 
   partition by p_mfgr
   order by p_name
@@ -63,7 +63,7 @@ from noop(on part
 select p_mfgr, p_name, p_size,
 rank() over (partition by p_mfgr order by p_name) as r,
 dense_rank() over (partition by p_mfgr order by p_name) as dr,
-sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row) as s1
+round(sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row),2) as s1
 from noop(on part 
   partition by p_mfgr
   order by p_name
@@ -162,7 +162,7 @@ explain
 select p_mfgr, p_name, p_size,
 rank() over (partition by p_mfgr order by p_name) as r,
 dense_rank() over (partition by p_mfgr order by p_name) as dr,
-sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row) as s1
+round(sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row),2) as s1
 from noopwithmap(on part 
   partition by p_mfgr
   order by p_name);
@@ -170,7 +170,7 @@ from noopwithmap(on part
 select p_mfgr, p_name, p_size,
 rank() over (partition by p_mfgr order by p_name) as r,
 dense_rank() over (partition by p_mfgr order by p_name) as dr,
-sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row) as s1
+round(sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row),2) as s1
 from noopwithmap(on part 
   partition by p_mfgr
   order by p_name);
@@ -180,7 +180,7 @@ explain
 select p_mfgr, p_name, p_size,
 rank() over (partition by p_mfgr order by p_name) as r,
 dense_rank() over (partition by p_mfgr order by p_name) as dr,
-sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row) as s1
+round(sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row),2) as s1
 from noop(on part
 partition by p_mfgr
 order by p_name)
@@ -189,7 +189,7 @@ order by p_name)
 select p_mfgr, p_name, p_size,
 rank() over (partition by p_mfgr order by p_name) as r,
 dense_rank() over (partition by p_mfgr order by p_name) as dr,
-sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row) as s1
+round(sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row),2) as s1
 from noop(on part
 partition by p_mfgr
 order by p_name)
@@ -200,7 +200,7 @@ explain
 select p_mfgr, p_name, p_size, 
 rank() over (partition by p_mfgr order by p_name) as r, 
 dense_rank() over (partition by p_mfgr order by p_name) as dr, 
-sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row)  as s1
+round(sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row),2) as s1
 from noop(on noopwithmap(on noop(on part 
 partition by p_mfgr 
 order by p_mfgr DESC, p_name
@@ -209,7 +209,7 @@ order by p_mfgr DESC, p_name
 select p_mfgr, p_name, p_size, 
 rank() over (partition by p_mfgr order by p_name) as r, 
 dense_rank() over (partition by p_mfgr order by p_name) as dr, 
-sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row)  as s1
+round(sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row),2) as s1
 from noop(on noopwithmap(on noop(on part 
 partition by p_mfgr 
 order by p_mfgr DESC, p_name
@@ -222,7 +222,7 @@ sub1.cd, sub1.s1
 from (select p_mfgr, p_name, 
 count(p_size) over (partition by p_mfgr order by p_name) as cd, 
 p_retailprice, 
-sum(p_retailprice) over w1  as s1
+round(sum(p_retailprice) over w1,2) as s1
 from noop(on part 
 partition by p_mfgr 
 order by p_name) 
@@ -234,7 +234,7 @@ sub1.cd, sub1.s1
 from (select p_mfgr, p_name, 
 count(p_size) over (partition by p_mfgr order by p_name) as cd, 
 p_retailprice, 
-sum(p_retailprice) over w1  as s1
+round(sum(p_retailprice) over w1,2)  as s1
 from noop(on part 
 partition by p_mfgr 
 order by p_name) 
@@ -247,7 +247,7 @@ select abc.p_mfgr, abc.p_name,
 rank() over (distribute by abc.p_mfgr sort by abc.p_name) as r, 
 dense_rank() over (distribute by abc.p_mfgr sort by abc.p_name) as dr, 
 count(abc.p_name) over (distribute by abc.p_mfgr sort by abc.p_name) as cd, 
-abc.p_retailprice, sum(abc.p_retailprice) over (distribute by abc.p_mfgr sort by abc.p_name rows between unbounded preceding and current row) as s1, 
+abc.p_retailprice, round(sum(abc.p_retailprice) over (distribute by abc.p_mfgr sort by abc.p_name rows between unbounded preceding and current row),2) as s1,
 abc.p_size, abc.p_size - lag(abc.p_size,1,abc.p_size) over (distribute by abc.p_mfgr sort by abc.p_name) as deltaSz 
 from noop(on part 
 partition by p_mfgr 
@@ -258,8 +258,8 @@ order by p_name
 select abc.p_mfgr, abc.p_name, 
 rank() over (distribute by abc.p_mfgr sort by abc.p_name) as r, 
 dense_rank() over (distribute by abc.p_mfgr sort by abc.p_name) as dr, 
-count(abc.p_name) over (distribute by abc.p_mfgr sort by abc.p_name) as cd, 
-abc.p_retailprice, sum(abc.p_retailprice) over (distribute by abc.p_mfgr sort by abc.p_name rows between unbounded preceding and current row) as s1, 
+count(abc.p_name) over (distribute by abc.p_mfgr sort by abc.p_name) as cd,
+abc.p_retailprice, round(sum(abc.p_retailprice) over (distribute by abc.p_mfgr sort by abc.p_name rows between unbounded preceding and current row),2) as s1,
 abc.p_size, abc.p_size - lag(abc.p_size,1,abc.p_size) over (distribute by abc.p_mfgr sort by abc.p_name) as deltaSz 
 from noop(on part 
 partition by p_mfgr 
@@ -283,20 +283,20 @@ order by p_name);
 -- 16. testViewAsTableInputToPTF
 create view IF NOT EXISTS mfgr_price_view as 
 select p_mfgr, p_brand, 
-sum(p_retailprice) as s 
+round(sum(p_retailprice),2) as s
 from part 
 group by p_mfgr, p_brand;
 
 explain
 select p_mfgr, p_brand, s, 
-sum(s) over w1  as s1
+round(sum(s) over w1,2)  as s1
 from noop(on mfgr_price_view 
 partition by p_mfgr 
 order by p_mfgr)  
 window w1 as ( partition by p_mfgr order by p_brand rows between 2 preceding and current row);
 
 select p_mfgr, p_brand, s, 
-sum(s) over w1  as s1
+round(sum(s) over w1,2) as s1
 from noop(on mfgr_price_view 
 partition by p_mfgr 
 order by p_mfgr)  
@@ -328,7 +328,7 @@ order by p_name)
 INSERT OVERWRITE TABLE part_4 select p_mfgr, p_name, p_size, 
 rank() over (distribute by p_mfgr sort by p_name) as r, 
 dense_rank() over (distribute by p_mfgr sort by p_name) as dr, 
-sum(p_retailprice) over (distribute by p_mfgr sort by p_name rows between unbounded preceding and current row)  as s  
+round(sum(p_retailprice) over (distribute by p_mfgr sort by p_name rows between unbounded preceding and current row),2)  as s
 INSERT OVERWRITE TABLE part_5 select  p_mfgr,p_name, p_size,  
 round(sum(p_size) over (distribute by p_mfgr sort by p_size range between 5 preceding and current row),1) as s2,
 rank() over (distribute by p_mfgr sort by p_mfgr, p_name) as r, 
@@ -343,7 +343,7 @@ order by p_name)
 INSERT OVERWRITE TABLE part_4 select p_mfgr, p_name, p_size, 
 rank() over (distribute by p_mfgr sort by p_name) as r, 
 dense_rank() over (distribute by p_mfgr sort by p_name) as dr, 
-sum(p_retailprice) over (distribute by p_mfgr sort by p_name rows between unbounded preceding and current row)  as s  
+round(sum(p_retailprice) over (distribute by p_mfgr sort by p_name rows between unbounded preceding and current row),2)  as s
 INSERT OVERWRITE TABLE part_5 select  p_mfgr,p_name, p_size,  
 round(sum(p_size) over (distribute by p_mfgr sort by p_size range between 5 preceding and current row),1) as s2,
 rank() over (distribute by p_mfgr sort by p_mfgr, p_name) as r, 

http://git-wip-us.apache.org/repos/asf/hive/blob/a28b28f3/ql/src/test/queries/clientpositive/vectorized_ptf.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientpositive/vectorized_ptf.q b/ql/src/test/queries/clientpositive/vectorized_ptf.q
index 64082e9..db2dbe1 100644
--- a/ql/src/test/queries/clientpositive/vectorized_ptf.q
+++ b/ql/src/test/queries/clientpositive/vectorized_ptf.q
@@ -46,7 +46,7 @@ explain extended
 select p_mfgr, p_name, p_size,
 rank() over (partition by p_mfgr order by p_name) as r,
 dense_rank() over (partition by p_mfgr order by p_name) as dr,
-sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row) as s1
+round(sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row),2) as s1
 from noop(on part_orc 
   partition by p_mfgr
   order by p_name
@@ -97,7 +97,7 @@ explain extended
 select p_mfgr, p_name, p_size,
 rank() over (partition by p_mfgr order by p_name) as r,
 dense_rank() over (partition by p_mfgr order by p_name) as dr,
-sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row) as s1
+round(sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row),2) as s1
 from noop(on part_orc 
   partition by p_mfgr
   order by p_name
@@ -106,7 +106,7 @@ from noop(on part_orc
 select p_mfgr, p_name, p_size,
 rank() over (partition by p_mfgr order by p_name) as r,
 dense_rank() over (partition by p_mfgr order by p_name) as dr,
-sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row) as s1
+round(sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row),2) as s1
 from noop(on part_orc 
   partition by p_mfgr
   order by p_name
@@ -211,7 +211,7 @@ explain extended
 select p_mfgr, p_name, p_size,
 rank() over (partition by p_mfgr order by p_name) as r,
 dense_rank() over (partition by p_mfgr order by p_name) as dr,
-sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row) as s1
+round(sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row),2) as s1
 from noopwithmap(on part_orc 
   partition by p_mfgr
   order by p_name);
@@ -219,7 +219,7 @@ from noopwithmap(on part_orc
 select p_mfgr, p_name, p_size,
 rank() over (partition by p_mfgr order by p_name) as r,
 dense_rank() over (partition by p_mfgr order by p_name) as dr,
-sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row) as s1
+round(sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row),2) as s1
 from noopwithmap(on part_orc 
   partition by p_mfgr
   order by p_name);
@@ -230,7 +230,7 @@ explain extended
 select p_mfgr, p_name, p_size,
 rank() over (partition by p_mfgr order by p_name) as r,
 dense_rank() over (partition by p_mfgr order by p_name) as dr,
-sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row) as s1
+round(sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row),2) as s1
 from noop(on part_orc
 partition by p_mfgr
 order by p_name)
@@ -239,7 +239,7 @@ order by p_name)
 select p_mfgr, p_name, p_size,
 rank() over (partition by p_mfgr order by p_name) as r,
 dense_rank() over (partition by p_mfgr order by p_name) as dr,
-sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row) as s1
+round(sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row),2) as s1
 from noop(on part_orc
 partition by p_mfgr
 order by p_name)
@@ -251,7 +251,7 @@ explain extended
 select p_mfgr, p_name, p_size, 
 rank() over (partition by p_mfgr order by p_name) as r, 
 dense_rank() over (partition by p_mfgr order by p_name) as dr, 
-sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row)  as s1
+round(sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row),2) as s1
 from noop(on noopwithmap(on noop(on part_orc 
 partition by p_mfgr 
 order by p_mfgr, p_name
@@ -260,7 +260,7 @@ order by p_mfgr, p_name
 select p_mfgr, p_name, p_size, 
 rank() over (partition by p_mfgr order by p_name) as r, 
 dense_rank() over (partition by p_mfgr order by p_name) as dr, 
-sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row)  as s1
+round(sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row),2) as s1
 from noop(on noopwithmap(on noop(on part_orc 
 partition by p_mfgr 
 order by p_mfgr, p_name
@@ -274,7 +274,7 @@ sub1.cd, sub1.s1
 from (select p_mfgr, p_name, 
 count(p_size) over (partition by p_mfgr order by p_name) as cd, 
 p_retailprice, 
-sum(p_retailprice) over w1  as s1
+round(sum(p_retailprice) over w1,2) as s1
 from noop(on part_orc 
 partition by p_mfgr 
 order by p_name) 
@@ -286,7 +286,7 @@ sub1.cd, sub1.s1
 from (select p_mfgr, p_name, 
 count(p_size) over (partition by p_mfgr order by p_name) as cd, 
 p_retailprice, 
-sum(p_retailprice) over w1  as s1
+round(sum(p_retailprice) over w1,2) as s1
 from noop(on part_orc 
 partition by p_mfgr 
 order by p_name) 
@@ -300,7 +300,7 @@ select abc.p_mfgr, abc.p_name,
 rank() over (distribute by abc.p_mfgr sort by abc.p_name) as r, 
 dense_rank() over (distribute by abc.p_mfgr sort by abc.p_name) as dr, 
 count(abc.p_name) over (distribute by abc.p_mfgr sort by abc.p_name) as cd, 
-abc.p_retailprice, sum(abc.p_retailprice) over (distribute by abc.p_mfgr sort by abc.p_name rows between unbounded preceding and current row) as s1, 
+abc.p_retailprice, round(sum(abc.p_retailprice) over (distribute by abc.p_mfgr sort by abc.p_name rows between unbounded preceding and current row),2) as s1,
 abc.p_size, abc.p_size - lag(abc.p_size,1,abc.p_size) over (distribute by abc.p_mfgr sort by abc.p_name) as deltaSz 
 from noop(on part_orc 
 partition by p_mfgr 
@@ -312,7 +312,7 @@ select abc.p_mfgr, abc.p_name,
 rank() over (distribute by abc.p_mfgr sort by abc.p_name) as r, 
 dense_rank() over (distribute by abc.p_mfgr sort by abc.p_name) as dr, 
 count(abc.p_name) over (distribute by abc.p_mfgr sort by abc.p_name) as cd, 
-abc.p_retailprice, sum(abc.p_retailprice) over (distribute by abc.p_mfgr sort by abc.p_name rows between unbounded preceding and current row) as s1, 
+abc.p_retailprice, round(sum(abc.p_retailprice) over (distribute by abc.p_mfgr sort by abc.p_name rows between unbounded preceding and current row),2) as s1,
 abc.p_size, abc.p_size - lag(abc.p_size,1,abc.p_size) over (distribute by abc.p_mfgr sort by abc.p_name) as deltaSz 
 from noop(on part_orc 
 partition by p_mfgr 
@@ -337,20 +337,20 @@ order by p_name);
 -- 16. testViewAsTableInputToPTF
 create view IF NOT EXISTS mfgr_price_view as 
 select p_mfgr, p_brand, 
-sum(p_retailprice) as s 
+round(sum(p_retailprice),2) as s
 from part_orc 
 group by p_mfgr, p_brand;
 
 explain extended
 select p_mfgr, p_brand, s, 
-sum(s) over w1  as s1
+round(sum(s) over w1,2) as s1
 from noop(on mfgr_price_view 
 partition by p_mfgr 
 order by p_mfgr)  
 window w1 as ( partition by p_mfgr order by p_brand rows between 2 preceding and current row);
 
 select p_mfgr, p_brand, s, 
-sum(s) over w1  as s1
+round(sum(s) over w1,2) as s1
 from noop(on mfgr_price_view 
 partition by p_mfgr 
 order by p_mfgr)  
@@ -382,7 +382,7 @@ order by p_name)
 INSERT OVERWRITE TABLE part_4 select p_mfgr, p_name, p_size, 
 rank() over (distribute by p_mfgr sort by p_name) as r, 
 dense_rank() over (distribute by p_mfgr sort by p_name) as dr, 
-sum(p_retailprice) over (distribute by p_mfgr sort by p_name rows between unbounded preceding and current row)  as s  
+round(sum(p_retailprice) over (distribute by p_mfgr sort by p_name rows between unbounded preceding and current row),2) as s
 INSERT OVERWRITE TABLE part_5 select  p_mfgr,p_name, p_size,  
 round(sum(p_size) over (distribute by p_mfgr sort by p_size range between 5 preceding and current row),1) as s2,
 rank() over (distribute by p_mfgr sort by p_mfgr, p_name) as r, 
@@ -397,7 +397,7 @@ order by p_name)
 INSERT OVERWRITE TABLE part_4 select p_mfgr, p_name, p_size, 
 rank() over (distribute by p_mfgr sort by p_name) as r, 
 dense_rank() over (distribute by p_mfgr sort by p_name) as dr, 
-sum(p_retailprice) over (distribute by p_mfgr sort by p_name rows between unbounded preceding and current row)  as s  
+round(sum(p_retailprice) over (distribute by p_mfgr sort by p_name rows between unbounded preceding and current row),2) as s
 INSERT OVERWRITE TABLE part_5 select  p_mfgr,p_name, p_size,  
 round(sum(p_size) over (distribute by p_mfgr sort by p_size range between 5 preceding and current row),1) as s2,
 rank() over (distribute by p_mfgr sort by p_mfgr, p_name) as r, 

http://git-wip-us.apache.org/repos/asf/hive/blob/a28b28f3/ql/src/test/queries/clientpositive/windowing.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientpositive/windowing.q b/ql/src/test/queries/clientpositive/windowing.q
index e60a6ef..19fa1ad 100644
--- a/ql/src/test/queries/clientpositive/windowing.q
+++ b/ql/src/test/queries/clientpositive/windowing.q
@@ -6,7 +6,7 @@ set mapred.reduce.tasks=4;
 select p_mfgr, p_name, p_size,
 rank() over(distribute by p_mfgr sort by p_name) as r,
 dense_rank() over(distribute by p_mfgr sort by p_name) as dr,
-sum(p_retailprice) over (distribute by p_mfgr sort by p_name rows between unbounded preceding and current row) as s1
+round(sum(p_retailprice) over (distribute by p_mfgr sort by p_name rows between unbounded preceding and current row),2) as s1
 from part
 ;
 
@@ -41,7 +41,7 @@ select p_mfgr, p_name,
 rank() over(distribute by p_mfgr sort by p_name) as r, 
 dense_rank() over(distribute by p_mfgr sort by p_name) as dr, 
 count(p_size) over(distribute by p_mfgr sort by p_name) as cd, 
-p_retailprice, sum(p_retailprice) over (distribute by p_mfgr sort by p_name rows between unbounded preceding and current row) as s1, 
+p_retailprice, round(sum(p_retailprice) over (distribute by p_mfgr sort by p_name rows between unbounded preceding and current row),2) as s1,
 p_size, p_size - lag(p_size,1,p_size) over(distribute by p_mfgr sort by p_name) as deltaSz 
 from part 
 ;
@@ -52,7 +52,7 @@ from (select p_mfgr, p_name,
 rank() over(distribute by p_mfgr sort by p_name) as r, 
 dense_rank() over(distribute by p_mfgr sort by p_name) as dr, 
 count(p_size) over(distribute by p_mfgr sort by p_name) as cd, 
-p_retailprice, sum(p_retailprice) over (distribute by p_mfgr sort by p_name rows between unbounded preceding and current row) as s1, 
+p_retailprice, round(sum(p_retailprice) over (distribute by p_mfgr sort by p_name rows between unbounded preceding and current row),2) as s1,
 p_size, p_size - lag(p_size,1,p_size) over(distribute by p_mfgr sort by p_name) as deltaSz 
 from part 
 ) sub1;
@@ -61,7 +61,7 @@ from part
 select abc.p_mfgr, abc.p_name, 
 rank() over(distribute by abc.p_mfgr sort by abc.p_name) as r, 
 dense_rank() over(distribute by abc.p_mfgr sort by abc.p_name) as dr, 
-abc.p_retailprice, sum(abc.p_retailprice) over (distribute by abc.p_mfgr sort by abc.p_name rows between unbounded preceding and current row) as s1, 
+abc.p_retailprice, round(sum(abc.p_retailprice) over (distribute by abc.p_mfgr sort by abc.p_name rows between unbounded preceding and current row),2) as s1,
 abc.p_size, abc.p_size - lag(abc.p_size,1,abc.p_size) over(distribute by abc.p_mfgr sort by abc.p_name) as deltaSz 
 from noop(on part 
 partition by p_mfgr 
@@ -79,7 +79,7 @@ from part
 select p_mfgr, p_name, p_size, 
 rank() over(distribute by p_mfgr sort by p_name) as r, 
 dense_rank() over(distribute by p_mfgr sort by p_name) as dr, 
-sum(p_retailprice) over (distribute by p_mfgr sort by p_name rows between unbounded preceding and current row)  as s1
+round(sum(p_retailprice) over (distribute by p_mfgr sort by p_name rows between unbounded preceding and current row),2)  as s1
 from part  
 ; 
 
@@ -87,7 +87,7 @@ from part
 select p_mfgr, p_name, p_size, 
 rank() over(distribute by p_mfgr sort by p_name) as r, 
 dense_rank() over(distribute by p_mfgr sort by p_name) as dr, 
-sum(p_retailprice) over (distribute by p_mfgr sort by p_name rows between unbounded preceding and current row) as s1 
+round(sum(p_retailprice) over (distribute by p_mfgr sort by p_name rows between unbounded preceding and current row),2) as s1
 from part 
 ;
 
@@ -159,19 +159,19 @@ window w1 as (distribute by p_mfgr sort by p_mfgr, p_name rows between 2 precedi
 
 -- 18. testUDAFs
 select  p_mfgr,p_name, p_size, 
-sum(p_retailprice) over w1 as s, 
+round(sum(p_retailprice) over w1,2) as s,
 min(p_retailprice) over w1 as mi,
 max(p_retailprice) over w1 as ma,
-avg(p_retailprice) over w1 as ag
+round(avg(p_retailprice) over w1,2) as ag
 from part
 window w1 as (distribute by p_mfgr sort by p_mfgr, p_name rows between 2 preceding and 2 following);
 
 -- 19. testUDAFsWithGBY
 select  p_mfgr,p_name, p_size, p_retailprice, 
-sum(p_retailprice) over w1 as s, 
+round(sum(p_retailprice) over w1,2) as s,
 min(p_retailprice) as mi ,
 max(p_retailprice) as ma ,
-avg(p_retailprice) over w1 as ag
+round(avg(p_retailprice) over w1,2) as ag
 from part
 group by p_mfgr,p_name, p_size, p_retailprice
 window w1 as (distribute by p_mfgr sort by p_mfgr, p_name rows between 2 preceding and 2 following);
@@ -219,7 +219,7 @@ window w1 as (distribute by p_mfgr sort by p_brand rows between 2 preceding and
 -- 23. testCreateViewWithWindowingQuery
 create view IF NOT EXISTS mfgr_brand_price_view as 
 select p_mfgr, p_brand, 
-sum(p_retailprice) over w1  as s
+round(sum(p_retailprice) over w1,2) as s
 from part 
 window w1 as (distribute by p_mfgr sort by p_name rows between 2 preceding and current row);
         
@@ -264,7 +264,7 @@ INSERT OVERWRITE TABLE part_1
 select p_mfgr, p_name, p_size, 
 rank() over(distribute by p_mfgr sort by p_name ) as r, 
 dense_rank() over(distribute by p_mfgr sort by p_name ) as dr, 
-sum(p_retailprice) over (distribute by p_mfgr sort by p_name rows between unbounded preceding and current row)  as s
+round(sum(p_retailprice) over (distribute by p_mfgr sort by p_name rows between unbounded preceding and current row),2) as s
 INSERT OVERWRITE TABLE part_2 
 select  p_mfgr,p_name, p_size,  
 rank() over(distribute by p_mfgr sort by p_name) as r, 
@@ -389,7 +389,7 @@ from part;
 
 -- 38. testPartitioningVariousForms2
 select p_mfgr, p_name, p_size,
-sum(p_retailprice) over (partition by p_mfgr, p_name order by p_mfgr, p_name rows between unbounded preceding and current row) as s1,
+round(sum(p_retailprice) over (partition by p_mfgr, p_name order by p_mfgr, p_name rows between unbounded preceding and current row),2) as s1,
 min(p_retailprice) over (distribute by p_mfgr, p_name sort by p_mfgr, p_name rows between unbounded preceding and current row) as s2,
 max(p_retailprice) over (partition by p_mfgr, p_name order by p_name) as s3
 from part;
@@ -401,22 +401,22 @@ from part;
 
 -- 40. testNoBetweenForRows
 select p_mfgr, p_name, p_size,
-    sum(p_retailprice) over (distribute by p_mfgr sort by p_name rows unbounded preceding) as s1
+    round(sum(p_retailprice) over (distribute by p_mfgr sort by p_name rows unbounded preceding),2) as s1
      from part ;
 
 -- 41. testNoBetweenForRange
 select p_mfgr, p_name, p_size,
-    sum(p_retailprice) over (distribute by p_mfgr sort by p_size range unbounded preceding) as s1
+    round(sum(p_retailprice) over (distribute by p_mfgr sort by p_size range unbounded preceding),2) as s1
      from part ;
 
 -- 42. testUnboundedFollowingForRows
 select p_mfgr, p_name, p_size,
-    sum(p_retailprice) over (distribute by p_mfgr sort by p_name rows between current row and unbounded following) as s1
+    round(sum(p_retailprice) over (distribute by p_mfgr sort by p_name rows between current row and unbounded following),2) as s1
     from part ;
 
 -- 43. testUnboundedFollowingForRange
 select p_mfgr, p_name, p_size,
-    sum(p_retailprice) over (distribute by p_mfgr sort by p_size range between current row and unbounded following) as s1
+    round(sum(p_retailprice) over (distribute by p_mfgr sort by p_size range between current row and unbounded following),2) as s1
     from part ;
         
 -- 44. testOverNoPartitionSingleAggregate
@@ -433,8 +433,8 @@ where p_mfgr = 'Manufacturer#6'
 ;
 
 -- 46. window sz is same as partition sz
-select p_retailprice, avg(p_retailprice) over (partition by p_mfgr order by p_name rows between current row and 6 following), 
-sum(p_retailprice) over (partition by p_mfgr order by p_name rows between current row and 6 following) 
+select p_retailprice, round(avg(p_retailprice) over (partition by p_mfgr order by p_name rows between current row and 6 following),2),
+round(sum(p_retailprice) over (partition by p_mfgr order by p_name rows between current row and 6 following),2)
 from part 
 where p_mfgr='Manufacturer#1';
 


[05/13] hive git commit: HIVE-15520: Improve the sum performance for Range based window (Aihua Xu, reviewed by Yongzhi Chen)

Posted by ai...@apache.org.
http://git-wip-us.apache.org/repos/asf/hive/blob/a28b28f3/ql/src/test/results/clientpositive/spark/ptf.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/spark/ptf.q.out b/ql/src/test/results/clientpositive/spark/ptf.q.out
index 2903003..eafe457 100644
--- a/ql/src/test/results/clientpositive/spark/ptf.q.out
+++ b/ql/src/test/results/clientpositive/spark/ptf.q.out
@@ -5,7 +5,7 @@ explain
 select p_mfgr, p_name, p_size,
 rank() over (partition by p_mfgr order by p_name) as r,
 dense_rank() over (partition by p_mfgr order by p_name) as dr,
-sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row) as s1
+round(sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row),2) as s1
 from noop(on part 
   partition by p_mfgr
   order by p_name
@@ -18,7 +18,7 @@ explain
 select p_mfgr, p_name, p_size,
 rank() over (partition by p_mfgr order by p_name) as r,
 dense_rank() over (partition by p_mfgr order by p_name) as dr,
-sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row) as s1
+round(sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row),2) as s1
 from noop(on part 
   partition by p_mfgr
   order by p_name
@@ -114,7 +114,7 @@ STAGE PLANS:
                               window frame: PRECEDING(MAX)~CURRENT
                   Statistics: Num rows: 26 Data size: 3147 Basic stats: COMPLETE Column stats: NONE
                   Select Operator
-                    expressions: _col2 (type: string), _col1 (type: string), _col5 (type: int), rank_window_0 (type: int), dense_rank_window_1 (type: int), sum_window_2 (type: double)
+                    expressions: _col2 (type: string), _col1 (type: string), _col5 (type: int), rank_window_0 (type: int), dense_rank_window_1 (type: int), round(sum_window_2, 2) (type: double)
                     outputColumnNames: _col0, _col1, _col2, _col3, _col4, _col5
                     Statistics: Num rows: 26 Data size: 3147 Basic stats: COMPLETE Column stats: NONE
                     File Output Operator
@@ -134,7 +134,7 @@ STAGE PLANS:
 PREHOOK: query: select p_mfgr, p_name, p_size,
 rank() over (partition by p_mfgr order by p_name) as r,
 dense_rank() over (partition by p_mfgr order by p_name) as dr,
-sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row) as s1
+round(sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row),2) as s1
 from noop(on part 
   partition by p_mfgr
   order by p_name
@@ -145,7 +145,7 @@ PREHOOK: Input: default@part
 POSTHOOK: query: select p_mfgr, p_name, p_size,
 rank() over (partition by p_mfgr order by p_name) as r,
 dense_rank() over (partition by p_mfgr order by p_name) as dr,
-sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row) as s1
+round(sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row),2) as s1
 from noop(on part 
   partition by p_mfgr
   order by p_name
@@ -156,12 +156,12 @@ POSTHOOK: Input: default@part
 Manufacturer#1	almond antique burnished rose metallic	2	1	1	1173.15
 Manufacturer#1	almond antique burnished rose metallic	2	1	1	2346.3
 Manufacturer#1	almond antique chartreuse lavender yellow	34	3	2	4100.06
-Manufacturer#1	almond antique salmon chartreuse burlywood	6	4	3	5702.650000000001
-Manufacturer#1	almond aquamarine burnished black steel	28	5	4	7117.070000000001
-Manufacturer#1	almond aquamarine pink moccasin thistle	42	6	5	8749.730000000001
+Manufacturer#1	almond antique salmon chartreuse burlywood	6	4	3	5702.65
+Manufacturer#1	almond aquamarine burnished black steel	28	5	4	7117.07
+Manufacturer#1	almond aquamarine pink moccasin thistle	42	6	5	8749.73
 Manufacturer#2	almond antique violet chocolate turquoise	14	1	1	1690.68
 Manufacturer#2	almond antique violet turquoise frosted	40	2	2	3491.38
-Manufacturer#2	almond aquamarine midnight light salmon	2	3	3	5523.360000000001
+Manufacturer#2	almond aquamarine midnight light salmon	2	3	3	5523.36
 Manufacturer#2	almond aquamarine rose maroon antique	25	4	4	7222.02
 Manufacturer#2	almond aquamarine sandy cyan gainsboro	18	5	5	8923.62
 Manufacturer#3	almond antique chartreuse khaki white	17	1	1	1671.68
@@ -173,9 +173,9 @@ Manufacturer#4	almond antique gainsboro frosted violet	10	1	1	1620.67
 Manufacturer#4	almond antique violet mint lemon	39	2	2	2996.09
 Manufacturer#4	almond aquamarine floral ivory bisque	27	3	3	4202.35
 Manufacturer#4	almond aquamarine yellow dodger mint	7	4	4	6047.27
-Manufacturer#4	almond azure aquamarine papaya violet	12	5	5	7337.620000000001
+Manufacturer#4	almond azure aquamarine papaya violet	12	5	5	7337.62
 Manufacturer#5	almond antique blue firebrick mint	31	1	1	1789.69
-Manufacturer#5	almond antique medium spring khaki	6	2	2	3401.3500000000004
+Manufacturer#5	almond antique medium spring khaki	6	2	2	3401.35
 Manufacturer#5	almond antique sky peru orange	2	3	3	5190.08
 Manufacturer#5	almond aquamarine dodger light gainsboro	46	4	4	6208.18
 Manufacturer#5	almond azure blanched chiffon midnight	23	5	5	7672.66
@@ -485,7 +485,7 @@ explain
 select p_mfgr, p_name, p_size,
 rank() over (partition by p_mfgr order by p_name) as r,
 dense_rank() over (partition by p_mfgr order by p_name) as dr,
-sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row) as s1
+round(sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row),2) as s1
 from noop(on part 
   partition by p_mfgr
   order by p_name
@@ -496,7 +496,7 @@ explain
 select p_mfgr, p_name, p_size,
 rank() over (partition by p_mfgr order by p_name) as r,
 dense_rank() over (partition by p_mfgr order by p_name) as dr,
-sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row) as s1
+round(sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row),2) as s1
 from noop(on part 
   partition by p_mfgr
   order by p_name
@@ -592,7 +592,7 @@ STAGE PLANS:
                               window frame: PRECEDING(MAX)~CURRENT
                   Statistics: Num rows: 26 Data size: 3147 Basic stats: COMPLETE Column stats: NONE
                   Select Operator
-                    expressions: _col2 (type: string), _col1 (type: string), _col5 (type: int), rank_window_0 (type: int), dense_rank_window_1 (type: int), sum_window_2 (type: double)
+                    expressions: _col2 (type: string), _col1 (type: string), _col5 (type: int), rank_window_0 (type: int), dense_rank_window_1 (type: int), round(sum_window_2, 2) (type: double)
                     outputColumnNames: _col0, _col1, _col2, _col3, _col4, _col5
                     Statistics: Num rows: 26 Data size: 3147 Basic stats: COMPLETE Column stats: NONE
                     File Output Operator
@@ -612,7 +612,7 @@ STAGE PLANS:
 PREHOOK: query: select p_mfgr, p_name, p_size,
 rank() over (partition by p_mfgr order by p_name) as r,
 dense_rank() over (partition by p_mfgr order by p_name) as dr,
-sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row) as s1
+round(sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row),2) as s1
 from noop(on part 
   partition by p_mfgr
   order by p_name
@@ -623,7 +623,7 @@ PREHOOK: Input: default@part
 POSTHOOK: query: select p_mfgr, p_name, p_size,
 rank() over (partition by p_mfgr order by p_name) as r,
 dense_rank() over (partition by p_mfgr order by p_name) as dr,
-sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row) as s1
+round(sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row),2) as s1
 from noop(on part 
   partition by p_mfgr
   order by p_name
@@ -634,12 +634,12 @@ POSTHOOK: Input: default@part
 Manufacturer#1	almond antique burnished rose metallic	2	1	1	1173.15
 Manufacturer#1	almond antique burnished rose metallic	2	1	1	2346.3
 Manufacturer#1	almond antique chartreuse lavender yellow	34	3	2	4100.06
-Manufacturer#1	almond antique salmon chartreuse burlywood	6	4	3	5702.650000000001
-Manufacturer#1	almond aquamarine burnished black steel	28	5	4	7117.070000000001
-Manufacturer#1	almond aquamarine pink moccasin thistle	42	6	5	8749.730000000001
+Manufacturer#1	almond antique salmon chartreuse burlywood	6	4	3	5702.65
+Manufacturer#1	almond aquamarine burnished black steel	28	5	4	7117.07
+Manufacturer#1	almond aquamarine pink moccasin thistle	42	6	5	8749.73
 Manufacturer#2	almond antique violet chocolate turquoise	14	1	1	1690.68
 Manufacturer#2	almond antique violet turquoise frosted	40	2	2	3491.38
-Manufacturer#2	almond aquamarine midnight light salmon	2	3	3	5523.360000000001
+Manufacturer#2	almond aquamarine midnight light salmon	2	3	3	5523.36
 Manufacturer#2	almond aquamarine rose maroon antique	25	4	4	7222.02
 Manufacturer#2	almond aquamarine sandy cyan gainsboro	18	5	5	8923.62
 Manufacturer#3	almond antique chartreuse khaki white	17	1	1	1671.68
@@ -651,9 +651,9 @@ Manufacturer#4	almond antique gainsboro frosted violet	10	1	1	1620.67
 Manufacturer#4	almond antique violet mint lemon	39	2	2	2996.09
 Manufacturer#4	almond aquamarine floral ivory bisque	27	3	3	4202.35
 Manufacturer#4	almond aquamarine yellow dodger mint	7	4	4	6047.27
-Manufacturer#4	almond azure aquamarine papaya violet	12	5	5	7337.620000000001
+Manufacturer#4	almond azure aquamarine papaya violet	12	5	5	7337.62
 Manufacturer#5	almond antique blue firebrick mint	31	1	1	1789.69
-Manufacturer#5	almond antique medium spring khaki	6	2	2	3401.3500000000004
+Manufacturer#5	almond antique medium spring khaki	6	2	2	3401.35
 Manufacturer#5	almond antique sky peru orange	2	3	3	5190.08
 Manufacturer#5	almond aquamarine dodger light gainsboro	46	4	4	6208.18
 Manufacturer#5	almond azure blanched chiffon midnight	23	5	5	7672.66
@@ -1499,7 +1499,7 @@ explain
 select p_mfgr, p_name, p_size,
 rank() over (partition by p_mfgr order by p_name) as r,
 dense_rank() over (partition by p_mfgr order by p_name) as dr,
-sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row) as s1
+round(sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row),2) as s1
 from noopwithmap(on part 
   partition by p_mfgr
   order by p_name)
@@ -1509,7 +1509,7 @@ explain
 select p_mfgr, p_name, p_size,
 rank() over (partition by p_mfgr order by p_name) as r,
 dense_rank() over (partition by p_mfgr order by p_name) as dr,
-sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row) as s1
+round(sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row),2) as s1
 from noopwithmap(on part 
   partition by p_mfgr
   order by p_name)
@@ -1621,7 +1621,7 @@ STAGE PLANS:
                               window frame: PRECEDING(MAX)~CURRENT
                   Statistics: Num rows: 26 Data size: 3147 Basic stats: COMPLETE Column stats: NONE
                   Select Operator
-                    expressions: _col2 (type: string), _col1 (type: string), _col5 (type: int), rank_window_0 (type: int), dense_rank_window_1 (type: int), sum_window_2 (type: double)
+                    expressions: _col2 (type: string), _col1 (type: string), _col5 (type: int), rank_window_0 (type: int), dense_rank_window_1 (type: int), round(sum_window_2, 2) (type: double)
                     outputColumnNames: _col0, _col1, _col2, _col3, _col4, _col5
                     Statistics: Num rows: 26 Data size: 3147 Basic stats: COMPLETE Column stats: NONE
                     File Output Operator
@@ -1641,7 +1641,7 @@ STAGE PLANS:
 PREHOOK: query: select p_mfgr, p_name, p_size,
 rank() over (partition by p_mfgr order by p_name) as r,
 dense_rank() over (partition by p_mfgr order by p_name) as dr,
-sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row) as s1
+round(sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row),2) as s1
 from noopwithmap(on part 
   partition by p_mfgr
   order by p_name)
@@ -1651,7 +1651,7 @@ PREHOOK: Input: default@part
 POSTHOOK: query: select p_mfgr, p_name, p_size,
 rank() over (partition by p_mfgr order by p_name) as r,
 dense_rank() over (partition by p_mfgr order by p_name) as dr,
-sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row) as s1
+round(sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row),2) as s1
 from noopwithmap(on part 
   partition by p_mfgr
   order by p_name)
@@ -1661,12 +1661,12 @@ POSTHOOK: Input: default@part
 Manufacturer#1	almond antique burnished rose metallic	2	1	1	1173.15
 Manufacturer#1	almond antique burnished rose metallic	2	1	1	2346.3
 Manufacturer#1	almond antique chartreuse lavender yellow	34	3	2	4100.06
-Manufacturer#1	almond antique salmon chartreuse burlywood	6	4	3	5702.650000000001
-Manufacturer#1	almond aquamarine burnished black steel	28	5	4	7117.070000000001
-Manufacturer#1	almond aquamarine pink moccasin thistle	42	6	5	8749.730000000001
+Manufacturer#1	almond antique salmon chartreuse burlywood	6	4	3	5702.65
+Manufacturer#1	almond aquamarine burnished black steel	28	5	4	7117.07
+Manufacturer#1	almond aquamarine pink moccasin thistle	42	6	5	8749.73
 Manufacturer#2	almond antique violet chocolate turquoise	14	1	1	1690.68
 Manufacturer#2	almond antique violet turquoise frosted	40	2	2	3491.38
-Manufacturer#2	almond aquamarine midnight light salmon	2	3	3	5523.360000000001
+Manufacturer#2	almond aquamarine midnight light salmon	2	3	3	5523.36
 Manufacturer#2	almond aquamarine rose maroon antique	25	4	4	7222.02
 Manufacturer#2	almond aquamarine sandy cyan gainsboro	18	5	5	8923.62
 Manufacturer#3	almond antique chartreuse khaki white	17	1	1	1671.68
@@ -1678,9 +1678,9 @@ Manufacturer#4	almond antique gainsboro frosted violet	10	1	1	1620.67
 Manufacturer#4	almond antique violet mint lemon	39	2	2	2996.09
 Manufacturer#4	almond aquamarine floral ivory bisque	27	3	3	4202.35
 Manufacturer#4	almond aquamarine yellow dodger mint	7	4	4	6047.27
-Manufacturer#4	almond azure aquamarine papaya violet	12	5	5	7337.620000000001
+Manufacturer#4	almond azure aquamarine papaya violet	12	5	5	7337.62
 Manufacturer#5	almond antique blue firebrick mint	31	1	1	1789.69
-Manufacturer#5	almond antique medium spring khaki	6	2	2	3401.3500000000004
+Manufacturer#5	almond antique medium spring khaki	6	2	2	3401.35
 Manufacturer#5	almond antique sky peru orange	2	3	3	5190.08
 Manufacturer#5	almond aquamarine dodger light gainsboro	46	4	4	6208.18
 Manufacturer#5	almond azure blanched chiffon midnight	23	5	5	7672.66
@@ -1689,7 +1689,7 @@ explain
 select p_mfgr, p_name, p_size,
 rank() over (partition by p_mfgr order by p_name) as r,
 dense_rank() over (partition by p_mfgr order by p_name) as dr,
-sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row) as s1
+round(sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row),2) as s1
 from noop(on part
 partition by p_mfgr
 order by p_name)
@@ -1699,7 +1699,7 @@ explain
 select p_mfgr, p_name, p_size,
 rank() over (partition by p_mfgr order by p_name) as r,
 dense_rank() over (partition by p_mfgr order by p_name) as dr,
-sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row) as s1
+round(sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row),2) as s1
 from noop(on part
 partition by p_mfgr
 order by p_name)
@@ -1794,7 +1794,7 @@ STAGE PLANS:
                               window frame: PRECEDING(MAX)~CURRENT
                   Statistics: Num rows: 26 Data size: 3147 Basic stats: COMPLETE Column stats: NONE
                   Select Operator
-                    expressions: _col2 (type: string), _col1 (type: string), _col5 (type: int), rank_window_0 (type: int), dense_rank_window_1 (type: int), sum_window_2 (type: double)
+                    expressions: _col2 (type: string), _col1 (type: string), _col5 (type: int), rank_window_0 (type: int), dense_rank_window_1 (type: int), round(sum_window_2, 2) (type: double)
                     outputColumnNames: _col0, _col1, _col2, _col3, _col4, _col5
                     Statistics: Num rows: 26 Data size: 3147 Basic stats: COMPLETE Column stats: NONE
                     File Output Operator
@@ -1814,7 +1814,7 @@ STAGE PLANS:
 PREHOOK: query: select p_mfgr, p_name, p_size,
 rank() over (partition by p_mfgr order by p_name) as r,
 dense_rank() over (partition by p_mfgr order by p_name) as dr,
-sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row) as s1
+round(sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row),2) as s1
 from noop(on part
 partition by p_mfgr
 order by p_name)
@@ -1824,7 +1824,7 @@ PREHOOK: Input: default@part
 POSTHOOK: query: select p_mfgr, p_name, p_size,
 rank() over (partition by p_mfgr order by p_name) as r,
 dense_rank() over (partition by p_mfgr order by p_name) as dr,
-sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row) as s1
+round(sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row),2) as s1
 from noop(on part
 partition by p_mfgr
 order by p_name)
@@ -1834,12 +1834,12 @@ POSTHOOK: Input: default@part
 Manufacturer#1	almond antique burnished rose metallic	2	1	1	1173.15
 Manufacturer#1	almond antique burnished rose metallic	2	1	1	2346.3
 Manufacturer#1	almond antique chartreuse lavender yellow	34	3	2	4100.06
-Manufacturer#1	almond antique salmon chartreuse burlywood	6	4	3	5702.650000000001
-Manufacturer#1	almond aquamarine burnished black steel	28	5	4	7117.070000000001
-Manufacturer#1	almond aquamarine pink moccasin thistle	42	6	5	8749.730000000001
+Manufacturer#1	almond antique salmon chartreuse burlywood	6	4	3	5702.65
+Manufacturer#1	almond aquamarine burnished black steel	28	5	4	7117.07
+Manufacturer#1	almond aquamarine pink moccasin thistle	42	6	5	8749.73
 Manufacturer#2	almond antique violet chocolate turquoise	14	1	1	1690.68
 Manufacturer#2	almond antique violet turquoise frosted	40	2	2	3491.38
-Manufacturer#2	almond aquamarine midnight light salmon	2	3	3	5523.360000000001
+Manufacturer#2	almond aquamarine midnight light salmon	2	3	3	5523.36
 Manufacturer#2	almond aquamarine rose maroon antique	25	4	4	7222.02
 Manufacturer#2	almond aquamarine sandy cyan gainsboro	18	5	5	8923.62
 Manufacturer#3	almond antique chartreuse khaki white	17	1	1	1671.68
@@ -1851,9 +1851,9 @@ Manufacturer#4	almond antique gainsboro frosted violet	10	1	1	1620.67
 Manufacturer#4	almond antique violet mint lemon	39	2	2	2996.09
 Manufacturer#4	almond aquamarine floral ivory bisque	27	3	3	4202.35
 Manufacturer#4	almond aquamarine yellow dodger mint	7	4	4	6047.27
-Manufacturer#4	almond azure aquamarine papaya violet	12	5	5	7337.620000000001
+Manufacturer#4	almond azure aquamarine papaya violet	12	5	5	7337.62
 Manufacturer#5	almond antique blue firebrick mint	31	1	1	1789.69
-Manufacturer#5	almond antique medium spring khaki	6	2	2	3401.3500000000004
+Manufacturer#5	almond antique medium spring khaki	6	2	2	3401.35
 Manufacturer#5	almond antique sky peru orange	2	3	3	5190.08
 Manufacturer#5	almond aquamarine dodger light gainsboro	46	4	4	6208.18
 Manufacturer#5	almond azure blanched chiffon midnight	23	5	5	7672.66
@@ -1862,7 +1862,7 @@ explain
 select p_mfgr, p_name, p_size, 
 rank() over (partition by p_mfgr order by p_name) as r, 
 dense_rank() over (partition by p_mfgr order by p_name) as dr, 
-sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row)  as s1
+round(sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row),2) as s1
 from noop(on noopwithmap(on noop(on part 
 partition by p_mfgr 
 order by p_mfgr DESC, p_name
@@ -1873,7 +1873,7 @@ explain
 select p_mfgr, p_name, p_size, 
 rank() over (partition by p_mfgr order by p_name) as r, 
 dense_rank() over (partition by p_mfgr order by p_name) as dr, 
-sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row)  as s1
+round(sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row),2) as s1
 from noop(on noopwithmap(on noop(on part 
 partition by p_mfgr 
 order by p_mfgr DESC, p_name
@@ -2027,7 +2027,7 @@ STAGE PLANS:
                               window frame: PRECEDING(MAX)~CURRENT
                   Statistics: Num rows: 26 Data size: 3147 Basic stats: COMPLETE Column stats: NONE
                   Select Operator
-                    expressions: _col2 (type: string), _col1 (type: string), _col5 (type: int), rank_window_0 (type: int), dense_rank_window_1 (type: int), sum_window_2 (type: double)
+                    expressions: _col2 (type: string), _col1 (type: string), _col5 (type: int), rank_window_0 (type: int), dense_rank_window_1 (type: int), round(sum_window_2, 2) (type: double)
                     outputColumnNames: _col0, _col1, _col2, _col3, _col4, _col5
                     Statistics: Num rows: 26 Data size: 3147 Basic stats: COMPLETE Column stats: NONE
                     File Output Operator
@@ -2047,7 +2047,7 @@ STAGE PLANS:
 PREHOOK: query: select p_mfgr, p_name, p_size, 
 rank() over (partition by p_mfgr order by p_name) as r, 
 dense_rank() over (partition by p_mfgr order by p_name) as dr, 
-sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row)  as s1
+round(sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row),2) as s1
 from noop(on noopwithmap(on noop(on part 
 partition by p_mfgr 
 order by p_mfgr DESC, p_name
@@ -2058,7 +2058,7 @@ PREHOOK: Input: default@part
 POSTHOOK: query: select p_mfgr, p_name, p_size, 
 rank() over (partition by p_mfgr order by p_name) as r, 
 dense_rank() over (partition by p_mfgr order by p_name) as dr, 
-sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row)  as s1
+round(sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row),2) as s1
 from noop(on noopwithmap(on noop(on part 
 partition by p_mfgr 
 order by p_mfgr DESC, p_name
@@ -2069,12 +2069,12 @@ POSTHOOK: Input: default@part
 Manufacturer#1	almond antique burnished rose metallic	2	1	1	1173.15
 Manufacturer#1	almond antique burnished rose metallic	2	1	1	2346.3
 Manufacturer#1	almond antique chartreuse lavender yellow	34	3	2	4100.06
-Manufacturer#1	almond antique salmon chartreuse burlywood	6	4	3	5702.650000000001
-Manufacturer#1	almond aquamarine burnished black steel	28	5	4	7117.070000000001
-Manufacturer#1	almond aquamarine pink moccasin thistle	42	6	5	8749.730000000001
+Manufacturer#1	almond antique salmon chartreuse burlywood	6	4	3	5702.65
+Manufacturer#1	almond aquamarine burnished black steel	28	5	4	7117.07
+Manufacturer#1	almond aquamarine pink moccasin thistle	42	6	5	8749.73
 Manufacturer#2	almond antique violet chocolate turquoise	14	1	1	1690.68
 Manufacturer#2	almond antique violet turquoise frosted	40	2	2	3491.38
-Manufacturer#2	almond aquamarine midnight light salmon	2	3	3	5523.360000000001
+Manufacturer#2	almond aquamarine midnight light salmon	2	3	3	5523.36
 Manufacturer#2	almond aquamarine rose maroon antique	25	4	4	7222.02
 Manufacturer#2	almond aquamarine sandy cyan gainsboro	18	5	5	8923.62
 Manufacturer#3	almond antique chartreuse khaki white	17	1	1	1671.68
@@ -2086,9 +2086,9 @@ Manufacturer#4	almond antique gainsboro frosted violet	10	1	1	1620.67
 Manufacturer#4	almond antique violet mint lemon	39	2	2	2996.09
 Manufacturer#4	almond aquamarine floral ivory bisque	27	3	3	4202.35
 Manufacturer#4	almond aquamarine yellow dodger mint	7	4	4	6047.27
-Manufacturer#4	almond azure aquamarine papaya violet	12	5	5	7337.620000000001
+Manufacturer#4	almond azure aquamarine papaya violet	12	5	5	7337.62
 Manufacturer#5	almond antique blue firebrick mint	31	1	1	1789.69
-Manufacturer#5	almond antique medium spring khaki	6	2	2	3401.3500000000004
+Manufacturer#5	almond antique medium spring khaki	6	2	2	3401.35
 Manufacturer#5	almond antique sky peru orange	2	3	3	5190.08
 Manufacturer#5	almond aquamarine dodger light gainsboro	46	4	4	6208.18
 Manufacturer#5	almond azure blanched chiffon midnight	23	5	5	7672.66
@@ -2099,7 +2099,7 @@ sub1.cd, sub1.s1
 from (select p_mfgr, p_name, 
 count(p_size) over (partition by p_mfgr order by p_name) as cd, 
 p_retailprice, 
-sum(p_retailprice) over w1  as s1
+round(sum(p_retailprice) over w1,2) as s1
 from noop(on part 
 partition by p_mfgr 
 order by p_name) 
@@ -2113,7 +2113,7 @@ sub1.cd, sub1.s1
 from (select p_mfgr, p_name, 
 count(p_size) over (partition by p_mfgr order by p_name) as cd, 
 p_retailprice, 
-sum(p_retailprice) over w1  as s1
+round(sum(p_retailprice) over w1,2) as s1
 from noop(on part 
 partition by p_mfgr 
 order by p_name) 
@@ -2202,7 +2202,7 @@ STAGE PLANS:
                               window frame: PRECEDING(2)~FOLLOWING(2)
                   Statistics: Num rows: 26 Data size: 3147 Basic stats: COMPLETE Column stats: NONE
                   Select Operator
-                    expressions: _col2 (type: string), _col1 (type: string), count_window_0 (type: bigint), sum_window_1 (type: double)
+                    expressions: _col2 (type: string), _col1 (type: string), count_window_0 (type: bigint), round(sum_window_1, 2) (type: double)
                     outputColumnNames: _col0, _col1, _col2, _col3
                     Statistics: Num rows: 26 Data size: 3147 Basic stats: COMPLETE Column stats: NONE
                     File Output Operator
@@ -2224,7 +2224,7 @@ sub1.cd, sub1.s1
 from (select p_mfgr, p_name, 
 count(p_size) over (partition by p_mfgr order by p_name) as cd, 
 p_retailprice, 
-sum(p_retailprice) over w1  as s1
+round(sum(p_retailprice) over w1,2)  as s1
 from noop(on part 
 partition by p_mfgr 
 order by p_name) 
@@ -2238,7 +2238,7 @@ sub1.cd, sub1.s1
 from (select p_mfgr, p_name, 
 count(p_size) over (partition by p_mfgr order by p_name) as cd, 
 p_retailprice, 
-sum(p_retailprice) over w1  as s1
+round(sum(p_retailprice) over w1,2)  as s1
 from noop(on part 
 partition by p_mfgr 
 order by p_name) 
@@ -2248,38 +2248,38 @@ POSTHOOK: type: QUERY
 POSTHOOK: Input: default@part
 #### A masked pattern was here ####
 Manufacturer#1	almond antique burnished rose metallic	2	4100.06
-Manufacturer#1	almond antique burnished rose metallic	2	5702.650000000001
-Manufacturer#1	almond antique chartreuse lavender yellow	3	7117.070000000001
+Manufacturer#1	almond antique burnished rose metallic	2	5702.65
+Manufacturer#1	almond antique chartreuse lavender yellow	3	7117.07
 Manufacturer#1	almond antique salmon chartreuse burlywood	4	7576.58
 Manufacturer#1	almond aquamarine burnished black steel	5	6403.43
 Manufacturer#1	almond aquamarine pink moccasin thistle	6	4649.67
-Manufacturer#2	almond antique violet chocolate turquoise	1	5523.360000000001
+Manufacturer#2	almond antique violet chocolate turquoise	1	5523.36
 Manufacturer#2	almond antique violet turquoise frosted	2	7222.02
 Manufacturer#2	almond aquamarine midnight light salmon	3	8923.62
-Manufacturer#2	almond aquamarine rose maroon antique	4	7232.9400000000005
+Manufacturer#2	almond aquamarine rose maroon antique	4	7232.94
 Manufacturer#2	almond aquamarine sandy cyan gainsboro	5	5432.24
 Manufacturer#3	almond antique chartreuse khaki white	1	4272.34
 Manufacturer#3	almond antique forest lavender goldenrod	2	6195.32
 Manufacturer#3	almond antique metallic orange dim	3	7532.61
-Manufacturer#3	almond antique misty red olive	4	5860.929999999999
+Manufacturer#3	almond antique misty red olive	4	5860.93
 Manufacturer#3	almond antique olive coral navajo	5	4670.66
 Manufacturer#4	almond antique gainsboro frosted violet	1	4202.35
 Manufacturer#4	almond antique violet mint lemon	2	6047.27
-Manufacturer#4	almond aquamarine floral ivory bisque	3	7337.620000000001
-Manufacturer#4	almond aquamarine yellow dodger mint	4	5716.950000000001
-Manufacturer#4	almond azure aquamarine papaya violet	5	4341.530000000001
+Manufacturer#4	almond aquamarine floral ivory bisque	3	7337.62
+Manufacturer#4	almond aquamarine yellow dodger mint	4	5716.95
+Manufacturer#4	almond azure aquamarine papaya violet	5	4341.53
 Manufacturer#5	almond antique blue firebrick mint	1	5190.08
 Manufacturer#5	almond antique medium spring khaki	2	6208.18
 Manufacturer#5	almond antique sky peru orange	3	7672.66
-Manufacturer#5	almond aquamarine dodger light gainsboro	4	5882.970000000001
-Manufacturer#5	almond azure blanched chiffon midnight	5	4271.3099999999995
+Manufacturer#5	almond aquamarine dodger light gainsboro	4	5882.97
+Manufacturer#5	almond azure blanched chiffon midnight	5	4271.31
 PREHOOK: query: -- 14. testPTFJoinWithWindowingWithCount
 explain
 select abc.p_mfgr, abc.p_name, 
 rank() over (distribute by abc.p_mfgr sort by abc.p_name) as r, 
 dense_rank() over (distribute by abc.p_mfgr sort by abc.p_name) as dr, 
 count(abc.p_name) over (distribute by abc.p_mfgr sort by abc.p_name) as cd, 
-abc.p_retailprice, sum(abc.p_retailprice) over (distribute by abc.p_mfgr sort by abc.p_name rows between unbounded preceding and current row) as s1, 
+abc.p_retailprice, round(sum(abc.p_retailprice) over (distribute by abc.p_mfgr sort by abc.p_name rows between unbounded preceding and current row),2) as s1,
 abc.p_size, abc.p_size - lag(abc.p_size,1,abc.p_size) over (distribute by abc.p_mfgr sort by abc.p_name) as deltaSz 
 from noop(on part 
 partition by p_mfgr 
@@ -2292,7 +2292,7 @@ select abc.p_mfgr, abc.p_name,
 rank() over (distribute by abc.p_mfgr sort by abc.p_name) as r, 
 dense_rank() over (distribute by abc.p_mfgr sort by abc.p_name) as dr, 
 count(abc.p_name) over (distribute by abc.p_mfgr sort by abc.p_name) as cd, 
-abc.p_retailprice, sum(abc.p_retailprice) over (distribute by abc.p_mfgr sort by abc.p_name rows between unbounded preceding and current row) as s1, 
+abc.p_retailprice, round(sum(abc.p_retailprice) over (distribute by abc.p_mfgr sort by abc.p_name rows between unbounded preceding and current row),2) as s1,
 abc.p_size, abc.p_size - lag(abc.p_size,1,abc.p_size) over (distribute by abc.p_mfgr sort by abc.p_name) as deltaSz 
 from noop(on part 
 partition by p_mfgr 
@@ -2435,7 +2435,7 @@ STAGE PLANS:
                               isPivotResult: true
                   Statistics: Num rows: 28 Data size: 3461 Basic stats: COMPLETE Column stats: NONE
                   Select Operator
-                    expressions: _col2 (type: string), _col1 (type: string), rank_window_0 (type: int), dense_rank_window_1 (type: int), count_window_2 (type: bigint), _col7 (type: double), sum_window_3 (type: double), _col5 (type: int), (_col5 - lag_window_4) (type: int)
+                    expressions: _col2 (type: string), _col1 (type: string), rank_window_0 (type: int), dense_rank_window_1 (type: int), count_window_2 (type: bigint), _col7 (type: double), round(sum_window_3, 2) (type: double), _col5 (type: int), (_col5 - lag_window_4) (type: int)
                     outputColumnNames: _col0, _col1, _col2, _col3, _col4, _col5, _col6, _col7, _col8
                     Statistics: Num rows: 28 Data size: 3461 Basic stats: COMPLETE Column stats: NONE
                     File Output Operator
@@ -2455,8 +2455,8 @@ STAGE PLANS:
 PREHOOK: query: select abc.p_mfgr, abc.p_name, 
 rank() over (distribute by abc.p_mfgr sort by abc.p_name) as r, 
 dense_rank() over (distribute by abc.p_mfgr sort by abc.p_name) as dr, 
-count(abc.p_name) over (distribute by abc.p_mfgr sort by abc.p_name) as cd, 
-abc.p_retailprice, sum(abc.p_retailprice) over (distribute by abc.p_mfgr sort by abc.p_name rows between unbounded preceding and current row) as s1, 
+count(abc.p_name) over (distribute by abc.p_mfgr sort by abc.p_name) as cd,
+abc.p_retailprice, round(sum(abc.p_retailprice) over (distribute by abc.p_mfgr sort by abc.p_name rows between unbounded preceding and current row),2) as s1,
 abc.p_size, abc.p_size - lag(abc.p_size,1,abc.p_size) over (distribute by abc.p_mfgr sort by abc.p_name) as deltaSz 
 from noop(on part 
 partition by p_mfgr 
@@ -2468,8 +2468,8 @@ PREHOOK: Input: default@part
 POSTHOOK: query: select abc.p_mfgr, abc.p_name, 
 rank() over (distribute by abc.p_mfgr sort by abc.p_name) as r, 
 dense_rank() over (distribute by abc.p_mfgr sort by abc.p_name) as dr, 
-count(abc.p_name) over (distribute by abc.p_mfgr sort by abc.p_name) as cd, 
-abc.p_retailprice, sum(abc.p_retailprice) over (distribute by abc.p_mfgr sort by abc.p_name rows between unbounded preceding and current row) as s1, 
+count(abc.p_name) over (distribute by abc.p_mfgr sort by abc.p_name) as cd,
+abc.p_retailprice, round(sum(abc.p_retailprice) over (distribute by abc.p_mfgr sort by abc.p_name rows between unbounded preceding and current row),2) as s1,
 abc.p_size, abc.p_size - lag(abc.p_size,1,abc.p_size) over (distribute by abc.p_mfgr sort by abc.p_name) as deltaSz 
 from noop(on part 
 partition by p_mfgr 
@@ -2480,15 +2480,15 @@ POSTHOOK: Input: default@part
 #### A masked pattern was here ####
 Manufacturer#1	almond antique burnished rose metallic	1	1	4	1173.15	1173.15	2	0
 Manufacturer#1	almond antique burnished rose metallic	1	1	4	1173.15	2346.3	2	0
-Manufacturer#1	almond antique burnished rose metallic	1	1	4	1173.15	3519.4500000000003	2	0
+Manufacturer#1	almond antique burnished rose metallic	1	1	4	1173.15	3519.45	2	0
 Manufacturer#1	almond antique burnished rose metallic	1	1	4	1173.15	4692.6	2	0
-Manufacturer#1	almond antique chartreuse lavender yellow	5	2	5	1753.76	6446.360000000001	34	32
-Manufacturer#1	almond antique salmon chartreuse burlywood	6	3	6	1602.59	8048.950000000001	6	-28
+Manufacturer#1	almond antique chartreuse lavender yellow	5	2	5	1753.76	6446.36	34	32
+Manufacturer#1	almond antique salmon chartreuse burlywood	6	3	6	1602.59	8048.95	6	-28
 Manufacturer#1	almond aquamarine burnished black steel	7	4	7	1414.42	9463.37	28	22
 Manufacturer#1	almond aquamarine pink moccasin thistle	8	5	8	1632.66	11096.03	42	14
 Manufacturer#2	almond antique violet chocolate turquoise	1	1	1	1690.68	1690.68	14	0
 Manufacturer#2	almond antique violet turquoise frosted	2	2	2	1800.7	3491.38	40	26
-Manufacturer#2	almond aquamarine midnight light salmon	3	3	3	2031.98	5523.360000000001	2	-38
+Manufacturer#2	almond aquamarine midnight light salmon	3	3	3	2031.98	5523.36	2	-38
 Manufacturer#2	almond aquamarine rose maroon antique	4	4	4	1698.66	7222.02	25	23
 Manufacturer#2	almond aquamarine sandy cyan gainsboro	5	5	5	1701.6	8923.62	18	-7
 Manufacturer#3	almond antique chartreuse khaki white	1	1	1	1671.68	1671.68	17	0
@@ -2500,9 +2500,9 @@ Manufacturer#4	almond antique gainsboro frosted violet	1	1	1	1620.67	1620.67	10
 Manufacturer#4	almond antique violet mint lemon	2	2	2	1375.42	2996.09	39	29
 Manufacturer#4	almond aquamarine floral ivory bisque	3	3	3	1206.26	4202.35	27	-12
 Manufacturer#4	almond aquamarine yellow dodger mint	4	4	4	1844.92	6047.27	7	-20
-Manufacturer#4	almond azure aquamarine papaya violet	5	5	5	1290.35	7337.620000000001	12	5
+Manufacturer#4	almond azure aquamarine papaya violet	5	5	5	1290.35	7337.62	12	5
 Manufacturer#5	almond antique blue firebrick mint	1	1	1	1789.69	1789.69	31	0
-Manufacturer#5	almond antique medium spring khaki	2	2	2	1611.66	3401.3500000000004	6	-25
+Manufacturer#5	almond antique medium spring khaki	2	2	2	1611.66	3401.35	6	-25
 Manufacturer#5	almond antique sky peru orange	3	3	3	1788.73	5190.08	2	-4
 Manufacturer#5	almond aquamarine dodger light gainsboro	4	4	4	1018.1	6208.18	46	44
 Manufacturer#5	almond azure blanched chiffon midnight	5	5	5	1464.48	7672.66	23	-23
@@ -2640,7 +2640,7 @@ Manufacturer#5	almond azure blanched chiffon midnight	23
 PREHOOK: query: -- 16. testViewAsTableInputToPTF
 create view IF NOT EXISTS mfgr_price_view as 
 select p_mfgr, p_brand, 
-sum(p_retailprice) as s 
+round(sum(p_retailprice),2) as s
 from part 
 group by p_mfgr, p_brand
 PREHOOK: type: CREATEVIEW
@@ -2650,7 +2650,7 @@ PREHOOK: Output: default@mfgr_price_view
 POSTHOOK: query: -- 16. testViewAsTableInputToPTF
 create view IF NOT EXISTS mfgr_price_view as 
 select p_mfgr, p_brand, 
-sum(p_retailprice) as s 
+round(sum(p_retailprice),2) as s
 from part 
 group by p_mfgr, p_brand
 POSTHOOK: type: CREATEVIEW
@@ -2659,7 +2659,7 @@ POSTHOOK: Output: database:default
 POSTHOOK: Output: default@mfgr_price_view
 PREHOOK: query: explain
 select p_mfgr, p_brand, s, 
-sum(s) over w1  as s1
+round(sum(s) over w1,2)  as s1
 from noop(on mfgr_price_view 
 partition by p_mfgr 
 order by p_mfgr)  
@@ -2667,7 +2667,7 @@ window w1 as ( partition by p_mfgr order by p_brand rows between 2 preceding and
 PREHOOK: type: QUERY
 POSTHOOK: query: explain
 select p_mfgr, p_brand, s, 
-sum(s) over w1  as s1
+round(sum(s) over w1,2)  as s1
 from noop(on mfgr_price_view 
 partition by p_mfgr 
 order by p_mfgr)  
@@ -2714,26 +2714,30 @@ STAGE PLANS:
                 mode: mergepartial
                 outputColumnNames: _col0, _col1, _col2
                 Statistics: Num rows: 13 Data size: 1573 Basic stats: COMPLETE Column stats: NONE
-                PTF Operator
-                  Function definitions:
-                      Input definition
-                        input alias: mfgr_price_view
-                        output shape: _col0: string, _col1: string, _col2: double
-                        type: TABLE
-                      Partition table definition
-                        input alias: ptf_1
-                        name: noop
-                        order by: _col0 ASC NULLS FIRST
-                        output shape: _col0: string, _col1: string, _col2: double
-                        partition by: _col0
-                        raw input shape:
+                Select Operator
+                  expressions: _col0 (type: string), _col1 (type: string), round(_col2, 2) (type: double)
+                  outputColumnNames: _col0, _col1, _col2
                   Statistics: Num rows: 13 Data size: 1573 Basic stats: COMPLETE Column stats: NONE
-                  Reduce Output Operator
-                    key expressions: _col0 (type: string), _col1 (type: string)
-                    sort order: ++
-                    Map-reduce partition columns: _col0 (type: string)
+                  PTF Operator
+                    Function definitions:
+                        Input definition
+                          input alias: mfgr_price_view
+                          output shape: _col0: string, _col1: string, _col2: double
+                          type: TABLE
+                        Partition table definition
+                          input alias: ptf_1
+                          name: noop
+                          order by: _col0 ASC NULLS FIRST
+                          output shape: _col0: string, _col1: string, _col2: double
+                          partition by: _col0
+                          raw input shape:
                     Statistics: Num rows: 13 Data size: 1573 Basic stats: COMPLETE Column stats: NONE
-                    value expressions: _col2 (type: double)
+                    Reduce Output Operator
+                      key expressions: _col0 (type: string), _col1 (type: string)
+                      sort order: ++
+                      Map-reduce partition columns: _col0 (type: string)
+                      Statistics: Num rows: 13 Data size: 1573 Basic stats: COMPLETE Column stats: NONE
+                      value expressions: _col2 (type: double)
         Reducer 3 
             Reduce Operator Tree:
               Select Operator
@@ -2761,7 +2765,7 @@ STAGE PLANS:
                               window frame: PRECEDING(2)~CURRENT
                   Statistics: Num rows: 13 Data size: 1573 Basic stats: COMPLETE Column stats: NONE
                   Select Operator
-                    expressions: _col0 (type: string), _col1 (type: string), _col2 (type: double), sum_window_0 (type: double)
+                    expressions: _col0 (type: string), _col1 (type: string), _col2 (type: double), round(sum_window_0, 2) (type: double)
                     outputColumnNames: _col0, _col1, _col2, _col3
                     Statistics: Num rows: 13 Data size: 1573 Basic stats: COMPLETE Column stats: NONE
                     File Output Operator
@@ -2779,7 +2783,7 @@ STAGE PLANS:
         ListSink
 
 PREHOOK: query: select p_mfgr, p_brand, s, 
-sum(s) over w1  as s1
+round(sum(s) over w1,2) as s1
 from noop(on mfgr_price_view 
 partition by p_mfgr 
 order by p_mfgr)  
@@ -2789,7 +2793,7 @@ PREHOOK: Input: default@mfgr_price_view
 PREHOOK: Input: default@part
 #### A masked pattern was here ####
 POSTHOOK: query: select p_mfgr, p_brand, s, 
-sum(s) over w1  as s1
+round(sum(s) over w1,2) as s1
 from noop(on mfgr_price_view 
 partition by p_mfgr 
 order by p_mfgr)  
@@ -2802,15 +2806,15 @@ Manufacturer#1	Brand#12	4800.84	4800.84
 Manufacturer#1	Brand#14	2346.3	7147.14
 Manufacturer#1	Brand#15	1602.59	8749.73
 Manufacturer#2	Brand#22	3491.38	3491.38
-Manufacturer#2	Brand#23	2031.98	5523.360000000001
+Manufacturer#2	Brand#23	2031.98	5523.36
 Manufacturer#2	Brand#24	1698.66	7222.02
-Manufacturer#2	Brand#25	1701.6	5432.240000000001
+Manufacturer#2	Brand#25	1701.6	5432.24
 Manufacturer#3	Brand#31	1671.68	1671.68
 Manufacturer#3	Brand#32	3333.37	5005.05
 Manufacturer#3	Brand#34	1337.29	6342.34
 Manufacturer#3	Brand#35	1190.27	5860.93
-Manufacturer#4	Brand#41	4755.9400000000005	4755.9400000000005
-Manufacturer#4	Brand#42	2581.6800000000003	7337.620000000001
+Manufacturer#4	Brand#41	4755.94	4755.94
+Manufacturer#4	Brand#42	2581.68	7337.62
 Manufacturer#5	Brand#51	1611.66	1611.66
 Manufacturer#5	Brand#52	3254.17	4865.83
 Manufacturer#5	Brand#53	2806.83	7672.66
@@ -2867,7 +2871,7 @@ order by p_name)
 INSERT OVERWRITE TABLE part_4 select p_mfgr, p_name, p_size, 
 rank() over (distribute by p_mfgr sort by p_name) as r, 
 dense_rank() over (distribute by p_mfgr sort by p_name) as dr, 
-sum(p_retailprice) over (distribute by p_mfgr sort by p_name rows between unbounded preceding and current row)  as s  
+round(sum(p_retailprice) over (distribute by p_mfgr sort by p_name rows between unbounded preceding and current row),2)  as s
 INSERT OVERWRITE TABLE part_5 select  p_mfgr,p_name, p_size,  
 round(sum(p_size) over (distribute by p_mfgr sort by p_size range between 5 preceding and current row),1) as s2,
 rank() over (distribute by p_mfgr sort by p_mfgr, p_name) as r, 
@@ -2883,7 +2887,7 @@ order by p_name)
 INSERT OVERWRITE TABLE part_4 select p_mfgr, p_name, p_size, 
 rank() over (distribute by p_mfgr sort by p_name) as r, 
 dense_rank() over (distribute by p_mfgr sort by p_name) as dr, 
-sum(p_retailprice) over (distribute by p_mfgr sort by p_name rows between unbounded preceding and current row)  as s  
+round(sum(p_retailprice) over (distribute by p_mfgr sort by p_name rows between unbounded preceding and current row),2)  as s
 INSERT OVERWRITE TABLE part_5 select  p_mfgr,p_name, p_size,  
 round(sum(p_size) over (distribute by p_mfgr sort by p_size range between 5 preceding and current row),1) as s2,
 rank() over (distribute by p_mfgr sort by p_mfgr, p_name) as r, 
@@ -2962,7 +2966,7 @@ STAGE PLANS:
                               window frame: PRECEDING(MAX)~CURRENT
                   Statistics: Num rows: 26 Data size: 3147 Basic stats: COMPLETE Column stats: NONE
                   Select Operator
-                    expressions: _col2 (type: string), _col1 (type: string), _col5 (type: int), rank_window_0 (type: int), dense_rank_window_1 (type: int), sum_window_2 (type: double)
+                    expressions: _col2 (type: string), _col1 (type: string), _col5 (type: int), rank_window_0 (type: int), dense_rank_window_1 (type: int), round(sum_window_2, 2) (type: double)
                     outputColumnNames: _col0, _col1, _col2, _col3, _col4, _col5
                     Statistics: Num rows: 26 Data size: 3147 Basic stats: COMPLETE Column stats: NONE
                     File Output Operator
@@ -3149,7 +3153,7 @@ order by p_name)
 INSERT OVERWRITE TABLE part_4 select p_mfgr, p_name, p_size, 
 rank() over (distribute by p_mfgr sort by p_name) as r, 
 dense_rank() over (distribute by p_mfgr sort by p_name) as dr, 
-sum(p_retailprice) over (distribute by p_mfgr sort by p_name rows between unbounded preceding and current row)  as s  
+round(sum(p_retailprice) over (distribute by p_mfgr sort by p_name rows between unbounded preceding and current row),2)  as s
 INSERT OVERWRITE TABLE part_5 select  p_mfgr,p_name, p_size,  
 round(sum(p_size) over (distribute by p_mfgr sort by p_size range between 5 preceding and current row),1) as s2,
 rank() over (distribute by p_mfgr sort by p_mfgr, p_name) as r, 
@@ -3167,7 +3171,7 @@ order by p_name)
 INSERT OVERWRITE TABLE part_4 select p_mfgr, p_name, p_size, 
 rank() over (distribute by p_mfgr sort by p_name) as r, 
 dense_rank() over (distribute by p_mfgr sort by p_name) as dr, 
-sum(p_retailprice) over (distribute by p_mfgr sort by p_name rows between unbounded preceding and current row)  as s  
+round(sum(p_retailprice) over (distribute by p_mfgr sort by p_name rows between unbounded preceding and current row),2)  as s
 INSERT OVERWRITE TABLE part_5 select  p_mfgr,p_name, p_size,  
 round(sum(p_size) over (distribute by p_mfgr sort by p_size range between 5 preceding and current row),1) as s2,
 rank() over (distribute by p_mfgr sort by p_mfgr, p_name) as r, 
@@ -3204,12 +3208,12 @@ POSTHOOK: Input: default@part_4
 Manufacturer#1	almond antique burnished rose metallic	2	1	1	1173.15
 Manufacturer#1	almond antique burnished rose metallic	2	1	1	2346.3
 Manufacturer#1	almond antique chartreuse lavender yellow	34	3	2	4100.06
-Manufacturer#1	almond antique salmon chartreuse burlywood	6	4	3	5702.650000000001
-Manufacturer#1	almond aquamarine burnished black steel	28	5	4	7117.070000000001
-Manufacturer#1	almond aquamarine pink moccasin thistle	42	6	5	8749.730000000001
+Manufacturer#1	almond antique salmon chartreuse burlywood	6	4	3	5702.65
+Manufacturer#1	almond aquamarine burnished black steel	28	5	4	7117.07
+Manufacturer#1	almond aquamarine pink moccasin thistle	42	6	5	8749.73
 Manufacturer#2	almond antique violet chocolate turquoise	14	1	1	1690.68
 Manufacturer#2	almond antique violet turquoise frosted	40	2	2	3491.38
-Manufacturer#2	almond aquamarine midnight light salmon	2	3	3	5523.360000000001
+Manufacturer#2	almond aquamarine midnight light salmon	2	3	3	5523.36
 Manufacturer#2	almond aquamarine rose maroon antique	25	4	4	7222.02
 Manufacturer#2	almond aquamarine sandy cyan gainsboro	18	5	5	8923.62
 Manufacturer#3	almond antique chartreuse khaki white	17	1	1	1671.68
@@ -3221,9 +3225,9 @@ Manufacturer#4	almond antique gainsboro frosted violet	10	1	1	1620.67
 Manufacturer#4	almond antique violet mint lemon	39	2	2	2996.09
 Manufacturer#4	almond aquamarine floral ivory bisque	27	3	3	4202.35
 Manufacturer#4	almond aquamarine yellow dodger mint	7	4	4	6047.27
-Manufacturer#4	almond azure aquamarine papaya violet	12	5	5	7337.620000000001
+Manufacturer#4	almond azure aquamarine papaya violet	12	5	5	7337.62
 Manufacturer#5	almond antique blue firebrick mint	31	1	1	1789.69
-Manufacturer#5	almond antique medium spring khaki	6	2	2	3401.3500000000004
+Manufacturer#5	almond antique medium spring khaki	6	2	2	3401.35
 Manufacturer#5	almond antique sky peru orange	2	3	3	5190.08
 Manufacturer#5	almond aquamarine dodger light gainsboro	46	4	4	6208.18
 Manufacturer#5	almond azure blanched chiffon midnight	23	5	5	7672.66


[06/13] hive git commit: HIVE-15520: Improve the sum performance for Range based window (Aihua Xu, reviewed by Yongzhi Chen)

Posted by ai...@apache.org.
http://git-wip-us.apache.org/repos/asf/hive/blob/a28b28f3/ql/src/test/results/clientpositive/ptf.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/ptf.q.out b/ql/src/test/results/clientpositive/ptf.q.out
index c4c7f59..3549c62 100644
--- a/ql/src/test/results/clientpositive/ptf.q.out
+++ b/ql/src/test/results/clientpositive/ptf.q.out
@@ -5,7 +5,7 @@ explain
 select p_mfgr, p_name, p_size,
 rank() over (partition by p_mfgr order by p_name) as r,
 dense_rank() over (partition by p_mfgr order by p_name) as dr,
-sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row) as s1
+round(sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row),2) as s1
 from noop(on part 
   partition by p_mfgr
   order by p_name
@@ -18,7 +18,7 @@ explain
 select p_mfgr, p_name, p_size,
 rank() over (partition by p_mfgr order by p_name) as r,
 dense_rank() over (partition by p_mfgr order by p_name) as dr,
-sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row) as s1
+round(sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row),2) as s1
 from noop(on part 
   partition by p_mfgr
   order by p_name
@@ -118,7 +118,7 @@ STAGE PLANS:
                         window frame: PRECEDING(MAX)~CURRENT
             Statistics: Num rows: 26 Data size: 3147 Basic stats: COMPLETE Column stats: NONE
             Select Operator
-              expressions: _col2 (type: string), _col1 (type: string), _col5 (type: int), rank_window_0 (type: int), dense_rank_window_1 (type: int), sum_window_2 (type: double)
+              expressions: _col2 (type: string), _col1 (type: string), _col5 (type: int), rank_window_0 (type: int), dense_rank_window_1 (type: int), round(sum_window_2, 2) (type: double)
               outputColumnNames: _col0, _col1, _col2, _col3, _col4, _col5
               Statistics: Num rows: 26 Data size: 3147 Basic stats: COMPLETE Column stats: NONE
               File Output Operator
@@ -138,7 +138,7 @@ STAGE PLANS:
 PREHOOK: query: select p_mfgr, p_name, p_size,
 rank() over (partition by p_mfgr order by p_name) as r,
 dense_rank() over (partition by p_mfgr order by p_name) as dr,
-sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row) as s1
+round(sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row),2) as s1
 from noop(on part 
   partition by p_mfgr
   order by p_name
@@ -149,7 +149,7 @@ PREHOOK: Input: default@part
 POSTHOOK: query: select p_mfgr, p_name, p_size,
 rank() over (partition by p_mfgr order by p_name) as r,
 dense_rank() over (partition by p_mfgr order by p_name) as dr,
-sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row) as s1
+round(sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row),2) as s1
 from noop(on part 
   partition by p_mfgr
   order by p_name
@@ -160,12 +160,12 @@ POSTHOOK: Input: default@part
 Manufacturer#1	almond antique burnished rose metallic	2	1	1	1173.15
 Manufacturer#1	almond antique burnished rose metallic	2	1	1	2346.3
 Manufacturer#1	almond antique chartreuse lavender yellow	34	3	2	4100.06
-Manufacturer#1	almond antique salmon chartreuse burlywood	6	4	3	5702.650000000001
-Manufacturer#1	almond aquamarine burnished black steel	28	5	4	7117.070000000001
-Manufacturer#1	almond aquamarine pink moccasin thistle	42	6	5	8749.730000000001
+Manufacturer#1	almond antique salmon chartreuse burlywood	6	4	3	5702.65
+Manufacturer#1	almond aquamarine burnished black steel	28	5	4	7117.07
+Manufacturer#1	almond aquamarine pink moccasin thistle	42	6	5	8749.73
 Manufacturer#2	almond antique violet chocolate turquoise	14	1	1	1690.68
 Manufacturer#2	almond antique violet turquoise frosted	40	2	2	3491.38
-Manufacturer#2	almond aquamarine midnight light salmon	2	3	3	5523.360000000001
+Manufacturer#2	almond aquamarine midnight light salmon	2	3	3	5523.36
 Manufacturer#2	almond aquamarine rose maroon antique	25	4	4	7222.02
 Manufacturer#2	almond aquamarine sandy cyan gainsboro	18	5	5	8923.62
 Manufacturer#3	almond antique chartreuse khaki white	17	1	1	1671.68
@@ -177,9 +177,9 @@ Manufacturer#4	almond antique gainsboro frosted violet	10	1	1	1620.67
 Manufacturer#4	almond antique violet mint lemon	39	2	2	2996.09
 Manufacturer#4	almond aquamarine floral ivory bisque	27	3	3	4202.35
 Manufacturer#4	almond aquamarine yellow dodger mint	7	4	4	6047.27
-Manufacturer#4	almond azure aquamarine papaya violet	12	5	5	7337.620000000001
+Manufacturer#4	almond azure aquamarine papaya violet	12	5	5	7337.62
 Manufacturer#5	almond antique blue firebrick mint	31	1	1	1789.69
-Manufacturer#5	almond antique medium spring khaki	6	2	2	3401.3500000000004
+Manufacturer#5	almond antique medium spring khaki	6	2	2	3401.35
 Manufacturer#5	almond antique sky peru orange	2	3	3	5190.08
 Manufacturer#5	almond aquamarine dodger light gainsboro	46	4	4	6208.18
 Manufacturer#5	almond azure blanched chiffon midnight	23	5	5	7672.66
@@ -495,7 +495,7 @@ explain
 select p_mfgr, p_name, p_size,
 rank() over (partition by p_mfgr order by p_name) as r,
 dense_rank() over (partition by p_mfgr order by p_name) as dr,
-sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row) as s1
+round(sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row),2) as s1
 from noop(on part 
   partition by p_mfgr
   order by p_name
@@ -506,7 +506,7 @@ explain
 select p_mfgr, p_name, p_size,
 rank() over (partition by p_mfgr order by p_name) as r,
 dense_rank() over (partition by p_mfgr order by p_name) as dr,
-sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row) as s1
+round(sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row),2) as s1
 from noop(on part 
   partition by p_mfgr
   order by p_name
@@ -606,7 +606,7 @@ STAGE PLANS:
                         window frame: PRECEDING(MAX)~CURRENT
             Statistics: Num rows: 26 Data size: 3147 Basic stats: COMPLETE Column stats: NONE
             Select Operator
-              expressions: _col2 (type: string), _col1 (type: string), _col5 (type: int), rank_window_0 (type: int), dense_rank_window_1 (type: int), sum_window_2 (type: double)
+              expressions: _col2 (type: string), _col1 (type: string), _col5 (type: int), rank_window_0 (type: int), dense_rank_window_1 (type: int), round(sum_window_2, 2) (type: double)
               outputColumnNames: _col0, _col1, _col2, _col3, _col4, _col5
               Statistics: Num rows: 26 Data size: 3147 Basic stats: COMPLETE Column stats: NONE
               File Output Operator
@@ -626,7 +626,7 @@ STAGE PLANS:
 PREHOOK: query: select p_mfgr, p_name, p_size,
 rank() over (partition by p_mfgr order by p_name) as r,
 dense_rank() over (partition by p_mfgr order by p_name) as dr,
-sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row) as s1
+round(sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row),2) as s1
 from noop(on part 
   partition by p_mfgr
   order by p_name
@@ -637,7 +637,7 @@ PREHOOK: Input: default@part
 POSTHOOK: query: select p_mfgr, p_name, p_size,
 rank() over (partition by p_mfgr order by p_name) as r,
 dense_rank() over (partition by p_mfgr order by p_name) as dr,
-sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row) as s1
+round(sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row),2) as s1
 from noop(on part 
   partition by p_mfgr
   order by p_name
@@ -648,12 +648,12 @@ POSTHOOK: Input: default@part
 Manufacturer#1	almond antique burnished rose metallic	2	1	1	1173.15
 Manufacturer#1	almond antique burnished rose metallic	2	1	1	2346.3
 Manufacturer#1	almond antique chartreuse lavender yellow	34	3	2	4100.06
-Manufacturer#1	almond antique salmon chartreuse burlywood	6	4	3	5702.650000000001
-Manufacturer#1	almond aquamarine burnished black steel	28	5	4	7117.070000000001
-Manufacturer#1	almond aquamarine pink moccasin thistle	42	6	5	8749.730000000001
+Manufacturer#1	almond antique salmon chartreuse burlywood	6	4	3	5702.65
+Manufacturer#1	almond aquamarine burnished black steel	28	5	4	7117.07
+Manufacturer#1	almond aquamarine pink moccasin thistle	42	6	5	8749.73
 Manufacturer#2	almond antique violet chocolate turquoise	14	1	1	1690.68
 Manufacturer#2	almond antique violet turquoise frosted	40	2	2	3491.38
-Manufacturer#2	almond aquamarine midnight light salmon	2	3	3	5523.360000000001
+Manufacturer#2	almond aquamarine midnight light salmon	2	3	3	5523.36
 Manufacturer#2	almond aquamarine rose maroon antique	25	4	4	7222.02
 Manufacturer#2	almond aquamarine sandy cyan gainsboro	18	5	5	8923.62
 Manufacturer#3	almond antique chartreuse khaki white	17	1	1	1671.68
@@ -665,9 +665,9 @@ Manufacturer#4	almond antique gainsboro frosted violet	10	1	1	1620.67
 Manufacturer#4	almond antique violet mint lemon	39	2	2	2996.09
 Manufacturer#4	almond aquamarine floral ivory bisque	27	3	3	4202.35
 Manufacturer#4	almond aquamarine yellow dodger mint	7	4	4	6047.27
-Manufacturer#4	almond azure aquamarine papaya violet	12	5	5	7337.620000000001
+Manufacturer#4	almond azure aquamarine papaya violet	12	5	5	7337.62
 Manufacturer#5	almond antique blue firebrick mint	31	1	1	1789.69
-Manufacturer#5	almond antique medium spring khaki	6	2	2	3401.3500000000004
+Manufacturer#5	almond antique medium spring khaki	6	2	2	3401.35
 Manufacturer#5	almond antique sky peru orange	2	3	3	5190.08
 Manufacturer#5	almond aquamarine dodger light gainsboro	46	4	4	6208.18
 Manufacturer#5	almond azure blanched chiffon midnight	23	5	5	7672.66
@@ -1529,7 +1529,7 @@ explain
 select p_mfgr, p_name, p_size,
 rank() over (partition by p_mfgr order by p_name) as r,
 dense_rank() over (partition by p_mfgr order by p_name) as dr,
-sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row) as s1
+round(sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row),2) as s1
 from noopwithmap(on part 
   partition by p_mfgr
   order by p_name)
@@ -1539,7 +1539,7 @@ explain
 select p_mfgr, p_name, p_size,
 rank() over (partition by p_mfgr order by p_name) as r,
 dense_rank() over (partition by p_mfgr order by p_name) as dr,
-sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row) as s1
+round(sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row),2) as s1
 from noopwithmap(on part 
   partition by p_mfgr
   order by p_name)
@@ -1655,7 +1655,7 @@ STAGE PLANS:
                         window frame: PRECEDING(MAX)~CURRENT
             Statistics: Num rows: 26 Data size: 3147 Basic stats: COMPLETE Column stats: NONE
             Select Operator
-              expressions: _col2 (type: string), _col1 (type: string), _col5 (type: int), rank_window_0 (type: int), dense_rank_window_1 (type: int), sum_window_2 (type: double)
+              expressions: _col2 (type: string), _col1 (type: string), _col5 (type: int), rank_window_0 (type: int), dense_rank_window_1 (type: int), round(sum_window_2, 2) (type: double)
               outputColumnNames: _col0, _col1, _col2, _col3, _col4, _col5
               Statistics: Num rows: 26 Data size: 3147 Basic stats: COMPLETE Column stats: NONE
               File Output Operator
@@ -1675,7 +1675,7 @@ STAGE PLANS:
 PREHOOK: query: select p_mfgr, p_name, p_size,
 rank() over (partition by p_mfgr order by p_name) as r,
 dense_rank() over (partition by p_mfgr order by p_name) as dr,
-sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row) as s1
+round(sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row),2) as s1
 from noopwithmap(on part 
   partition by p_mfgr
   order by p_name)
@@ -1685,7 +1685,7 @@ PREHOOK: Input: default@part
 POSTHOOK: query: select p_mfgr, p_name, p_size,
 rank() over (partition by p_mfgr order by p_name) as r,
 dense_rank() over (partition by p_mfgr order by p_name) as dr,
-sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row) as s1
+round(sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row),2) as s1
 from noopwithmap(on part 
   partition by p_mfgr
   order by p_name)
@@ -1695,12 +1695,12 @@ POSTHOOK: Input: default@part
 Manufacturer#1	almond antique burnished rose metallic	2	1	1	1173.15
 Manufacturer#1	almond antique burnished rose metallic	2	1	1	2346.3
 Manufacturer#1	almond antique chartreuse lavender yellow	34	3	2	4100.06
-Manufacturer#1	almond antique salmon chartreuse burlywood	6	4	3	5702.650000000001
-Manufacturer#1	almond aquamarine burnished black steel	28	5	4	7117.070000000001
-Manufacturer#1	almond aquamarine pink moccasin thistle	42	6	5	8749.730000000001
+Manufacturer#1	almond antique salmon chartreuse burlywood	6	4	3	5702.65
+Manufacturer#1	almond aquamarine burnished black steel	28	5	4	7117.07
+Manufacturer#1	almond aquamarine pink moccasin thistle	42	6	5	8749.73
 Manufacturer#2	almond antique violet chocolate turquoise	14	1	1	1690.68
 Manufacturer#2	almond antique violet turquoise frosted	40	2	2	3491.38
-Manufacturer#2	almond aquamarine midnight light salmon	2	3	3	5523.360000000001
+Manufacturer#2	almond aquamarine midnight light salmon	2	3	3	5523.36
 Manufacturer#2	almond aquamarine rose maroon antique	25	4	4	7222.02
 Manufacturer#2	almond aquamarine sandy cyan gainsboro	18	5	5	8923.62
 Manufacturer#3	almond antique chartreuse khaki white	17	1	1	1671.68
@@ -1712,9 +1712,9 @@ Manufacturer#4	almond antique gainsboro frosted violet	10	1	1	1620.67
 Manufacturer#4	almond antique violet mint lemon	39	2	2	2996.09
 Manufacturer#4	almond aquamarine floral ivory bisque	27	3	3	4202.35
 Manufacturer#4	almond aquamarine yellow dodger mint	7	4	4	6047.27
-Manufacturer#4	almond azure aquamarine papaya violet	12	5	5	7337.620000000001
+Manufacturer#4	almond azure aquamarine papaya violet	12	5	5	7337.62
 Manufacturer#5	almond antique blue firebrick mint	31	1	1	1789.69
-Manufacturer#5	almond antique medium spring khaki	6	2	2	3401.3500000000004
+Manufacturer#5	almond antique medium spring khaki	6	2	2	3401.35
 Manufacturer#5	almond antique sky peru orange	2	3	3	5190.08
 Manufacturer#5	almond aquamarine dodger light gainsboro	46	4	4	6208.18
 Manufacturer#5	almond azure blanched chiffon midnight	23	5	5	7672.66
@@ -1723,7 +1723,7 @@ explain
 select p_mfgr, p_name, p_size,
 rank() over (partition by p_mfgr order by p_name) as r,
 dense_rank() over (partition by p_mfgr order by p_name) as dr,
-sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row) as s1
+round(sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row),2) as s1
 from noop(on part
 partition by p_mfgr
 order by p_name)
@@ -1733,7 +1733,7 @@ explain
 select p_mfgr, p_name, p_size,
 rank() over (partition by p_mfgr order by p_name) as r,
 dense_rank() over (partition by p_mfgr order by p_name) as dr,
-sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row) as s1
+round(sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row),2) as s1
 from noop(on part
 partition by p_mfgr
 order by p_name)
@@ -1832,7 +1832,7 @@ STAGE PLANS:
                         window frame: PRECEDING(MAX)~CURRENT
             Statistics: Num rows: 26 Data size: 3147 Basic stats: COMPLETE Column stats: NONE
             Select Operator
-              expressions: _col2 (type: string), _col1 (type: string), _col5 (type: int), rank_window_0 (type: int), dense_rank_window_1 (type: int), sum_window_2 (type: double)
+              expressions: _col2 (type: string), _col1 (type: string), _col5 (type: int), rank_window_0 (type: int), dense_rank_window_1 (type: int), round(sum_window_2, 2) (type: double)
               outputColumnNames: _col0, _col1, _col2, _col3, _col4, _col5
               Statistics: Num rows: 26 Data size: 3147 Basic stats: COMPLETE Column stats: NONE
               File Output Operator
@@ -1852,7 +1852,7 @@ STAGE PLANS:
 PREHOOK: query: select p_mfgr, p_name, p_size,
 rank() over (partition by p_mfgr order by p_name) as r,
 dense_rank() over (partition by p_mfgr order by p_name) as dr,
-sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row) as s1
+round(sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row),2) as s1
 from noop(on part
 partition by p_mfgr
 order by p_name)
@@ -1862,7 +1862,7 @@ PREHOOK: Input: default@part
 POSTHOOK: query: select p_mfgr, p_name, p_size,
 rank() over (partition by p_mfgr order by p_name) as r,
 dense_rank() over (partition by p_mfgr order by p_name) as dr,
-sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row) as s1
+round(sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row),2) as s1
 from noop(on part
 partition by p_mfgr
 order by p_name)
@@ -1872,12 +1872,12 @@ POSTHOOK: Input: default@part
 Manufacturer#1	almond antique burnished rose metallic	2	1	1	1173.15
 Manufacturer#1	almond antique burnished rose metallic	2	1	1	2346.3
 Manufacturer#1	almond antique chartreuse lavender yellow	34	3	2	4100.06
-Manufacturer#1	almond antique salmon chartreuse burlywood	6	4	3	5702.650000000001
-Manufacturer#1	almond aquamarine burnished black steel	28	5	4	7117.070000000001
-Manufacturer#1	almond aquamarine pink moccasin thistle	42	6	5	8749.730000000001
+Manufacturer#1	almond antique salmon chartreuse burlywood	6	4	3	5702.65
+Manufacturer#1	almond aquamarine burnished black steel	28	5	4	7117.07
+Manufacturer#1	almond aquamarine pink moccasin thistle	42	6	5	8749.73
 Manufacturer#2	almond antique violet chocolate turquoise	14	1	1	1690.68
 Manufacturer#2	almond antique violet turquoise frosted	40	2	2	3491.38
-Manufacturer#2	almond aquamarine midnight light salmon	2	3	3	5523.360000000001
+Manufacturer#2	almond aquamarine midnight light salmon	2	3	3	5523.36
 Manufacturer#2	almond aquamarine rose maroon antique	25	4	4	7222.02
 Manufacturer#2	almond aquamarine sandy cyan gainsboro	18	5	5	8923.62
 Manufacturer#3	almond antique chartreuse khaki white	17	1	1	1671.68
@@ -1889,9 +1889,9 @@ Manufacturer#4	almond antique gainsboro frosted violet	10	1	1	1620.67
 Manufacturer#4	almond antique violet mint lemon	39	2	2	2996.09
 Manufacturer#4	almond aquamarine floral ivory bisque	27	3	3	4202.35
 Manufacturer#4	almond aquamarine yellow dodger mint	7	4	4	6047.27
-Manufacturer#4	almond azure aquamarine papaya violet	12	5	5	7337.620000000001
+Manufacturer#4	almond azure aquamarine papaya violet	12	5	5	7337.62
 Manufacturer#5	almond antique blue firebrick mint	31	1	1	1789.69
-Manufacturer#5	almond antique medium spring khaki	6	2	2	3401.3500000000004
+Manufacturer#5	almond antique medium spring khaki	6	2	2	3401.35
 Manufacturer#5	almond antique sky peru orange	2	3	3	5190.08
 Manufacturer#5	almond aquamarine dodger light gainsboro	46	4	4	6208.18
 Manufacturer#5	almond azure blanched chiffon midnight	23	5	5	7672.66
@@ -1900,7 +1900,7 @@ explain
 select p_mfgr, p_name, p_size, 
 rank() over (partition by p_mfgr order by p_name) as r, 
 dense_rank() over (partition by p_mfgr order by p_name) as dr, 
-sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row)  as s1
+round(sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row),2) as s1
 from noop(on noopwithmap(on noop(on part 
 partition by p_mfgr 
 order by p_mfgr DESC, p_name
@@ -1911,7 +1911,7 @@ explain
 select p_mfgr, p_name, p_size, 
 rank() over (partition by p_mfgr order by p_name) as r, 
 dense_rank() over (partition by p_mfgr order by p_name) as dr, 
-sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row)  as s1
+round(sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row),2) as s1
 from noop(on noopwithmap(on noop(on part 
 partition by p_mfgr 
 order by p_mfgr DESC, p_name
@@ -2079,7 +2079,7 @@ STAGE PLANS:
                         window frame: PRECEDING(MAX)~CURRENT
             Statistics: Num rows: 26 Data size: 3147 Basic stats: COMPLETE Column stats: NONE
             Select Operator
-              expressions: _col2 (type: string), _col1 (type: string), _col5 (type: int), rank_window_0 (type: int), dense_rank_window_1 (type: int), sum_window_2 (type: double)
+              expressions: _col2 (type: string), _col1 (type: string), _col5 (type: int), rank_window_0 (type: int), dense_rank_window_1 (type: int), round(sum_window_2, 2) (type: double)
               outputColumnNames: _col0, _col1, _col2, _col3, _col4, _col5
               Statistics: Num rows: 26 Data size: 3147 Basic stats: COMPLETE Column stats: NONE
               File Output Operator
@@ -2099,7 +2099,7 @@ STAGE PLANS:
 PREHOOK: query: select p_mfgr, p_name, p_size, 
 rank() over (partition by p_mfgr order by p_name) as r, 
 dense_rank() over (partition by p_mfgr order by p_name) as dr, 
-sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row)  as s1
+round(sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row),2) as s1
 from noop(on noopwithmap(on noop(on part 
 partition by p_mfgr 
 order by p_mfgr DESC, p_name
@@ -2110,7 +2110,7 @@ PREHOOK: Input: default@part
 POSTHOOK: query: select p_mfgr, p_name, p_size, 
 rank() over (partition by p_mfgr order by p_name) as r, 
 dense_rank() over (partition by p_mfgr order by p_name) as dr, 
-sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row)  as s1
+round(sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row),2) as s1
 from noop(on noopwithmap(on noop(on part 
 partition by p_mfgr 
 order by p_mfgr DESC, p_name
@@ -2121,12 +2121,12 @@ POSTHOOK: Input: default@part
 Manufacturer#1	almond antique burnished rose metallic	2	1	1	1173.15
 Manufacturer#1	almond antique burnished rose metallic	2	1	1	2346.3
 Manufacturer#1	almond antique chartreuse lavender yellow	34	3	2	4100.06
-Manufacturer#1	almond antique salmon chartreuse burlywood	6	4	3	5702.650000000001
-Manufacturer#1	almond aquamarine burnished black steel	28	5	4	7117.070000000001
-Manufacturer#1	almond aquamarine pink moccasin thistle	42	6	5	8749.730000000001
+Manufacturer#1	almond antique salmon chartreuse burlywood	6	4	3	5702.65
+Manufacturer#1	almond aquamarine burnished black steel	28	5	4	7117.07
+Manufacturer#1	almond aquamarine pink moccasin thistle	42	6	5	8749.73
 Manufacturer#2	almond antique violet chocolate turquoise	14	1	1	1690.68
 Manufacturer#2	almond antique violet turquoise frosted	40	2	2	3491.38
-Manufacturer#2	almond aquamarine midnight light salmon	2	3	3	5523.360000000001
+Manufacturer#2	almond aquamarine midnight light salmon	2	3	3	5523.36
 Manufacturer#2	almond aquamarine rose maroon antique	25	4	4	7222.02
 Manufacturer#2	almond aquamarine sandy cyan gainsboro	18	5	5	8923.62
 Manufacturer#3	almond antique chartreuse khaki white	17	1	1	1671.68
@@ -2138,9 +2138,9 @@ Manufacturer#4	almond antique gainsboro frosted violet	10	1	1	1620.67
 Manufacturer#4	almond antique violet mint lemon	39	2	2	2996.09
 Manufacturer#4	almond aquamarine floral ivory bisque	27	3	3	4202.35
 Manufacturer#4	almond aquamarine yellow dodger mint	7	4	4	6047.27
-Manufacturer#4	almond azure aquamarine papaya violet	12	5	5	7337.620000000001
+Manufacturer#4	almond azure aquamarine papaya violet	12	5	5	7337.62
 Manufacturer#5	almond antique blue firebrick mint	31	1	1	1789.69
-Manufacturer#5	almond antique medium spring khaki	6	2	2	3401.3500000000004
+Manufacturer#5	almond antique medium spring khaki	6	2	2	3401.35
 Manufacturer#5	almond antique sky peru orange	2	3	3	5190.08
 Manufacturer#5	almond aquamarine dodger light gainsboro	46	4	4	6208.18
 Manufacturer#5	almond azure blanched chiffon midnight	23	5	5	7672.66
@@ -2151,7 +2151,7 @@ sub1.cd, sub1.s1
 from (select p_mfgr, p_name, 
 count(p_size) over (partition by p_mfgr order by p_name) as cd, 
 p_retailprice, 
-sum(p_retailprice) over w1  as s1
+round(sum(p_retailprice) over w1,2) as s1
 from noop(on part 
 partition by p_mfgr 
 order by p_name) 
@@ -2165,7 +2165,7 @@ sub1.cd, sub1.s1
 from (select p_mfgr, p_name, 
 count(p_size) over (partition by p_mfgr order by p_name) as cd, 
 p_retailprice, 
-sum(p_retailprice) over w1  as s1
+round(sum(p_retailprice) over w1,2) as s1
 from noop(on part 
 partition by p_mfgr 
 order by p_name) 
@@ -2258,7 +2258,7 @@ STAGE PLANS:
                         window frame: PRECEDING(2)~FOLLOWING(2)
             Statistics: Num rows: 26 Data size: 3147 Basic stats: COMPLETE Column stats: NONE
             Select Operator
-              expressions: _col2 (type: string), _col1 (type: string), count_window_0 (type: bigint), sum_window_1 (type: double)
+              expressions: _col2 (type: string), _col1 (type: string), count_window_0 (type: bigint), round(sum_window_1, 2) (type: double)
               outputColumnNames: _col0, _col1, _col2, _col3
               Statistics: Num rows: 26 Data size: 3147 Basic stats: COMPLETE Column stats: NONE
               File Output Operator
@@ -2280,7 +2280,7 @@ sub1.cd, sub1.s1
 from (select p_mfgr, p_name, 
 count(p_size) over (partition by p_mfgr order by p_name) as cd, 
 p_retailprice, 
-sum(p_retailprice) over w1  as s1
+round(sum(p_retailprice) over w1,2)  as s1
 from noop(on part 
 partition by p_mfgr 
 order by p_name) 
@@ -2294,7 +2294,7 @@ sub1.cd, sub1.s1
 from (select p_mfgr, p_name, 
 count(p_size) over (partition by p_mfgr order by p_name) as cd, 
 p_retailprice, 
-sum(p_retailprice) over w1  as s1
+round(sum(p_retailprice) over w1,2)  as s1
 from noop(on part 
 partition by p_mfgr 
 order by p_name) 
@@ -2304,38 +2304,38 @@ POSTHOOK: type: QUERY
 POSTHOOK: Input: default@part
 #### A masked pattern was here ####
 Manufacturer#1	almond antique burnished rose metallic	2	4100.06
-Manufacturer#1	almond antique burnished rose metallic	2	5702.650000000001
-Manufacturer#1	almond antique chartreuse lavender yellow	3	7117.070000000001
+Manufacturer#1	almond antique burnished rose metallic	2	5702.65
+Manufacturer#1	almond antique chartreuse lavender yellow	3	7117.07
 Manufacturer#1	almond antique salmon chartreuse burlywood	4	7576.58
 Manufacturer#1	almond aquamarine burnished black steel	5	6403.43
 Manufacturer#1	almond aquamarine pink moccasin thistle	6	4649.67
-Manufacturer#2	almond antique violet chocolate turquoise	1	5523.360000000001
+Manufacturer#2	almond antique violet chocolate turquoise	1	5523.36
 Manufacturer#2	almond antique violet turquoise frosted	2	7222.02
 Manufacturer#2	almond aquamarine midnight light salmon	3	8923.62
-Manufacturer#2	almond aquamarine rose maroon antique	4	7232.9400000000005
+Manufacturer#2	almond aquamarine rose maroon antique	4	7232.94
 Manufacturer#2	almond aquamarine sandy cyan gainsboro	5	5432.24
 Manufacturer#3	almond antique chartreuse khaki white	1	4272.34
 Manufacturer#3	almond antique forest lavender goldenrod	2	6195.32
 Manufacturer#3	almond antique metallic orange dim	3	7532.61
-Manufacturer#3	almond antique misty red olive	4	5860.929999999999
+Manufacturer#3	almond antique misty red olive	4	5860.93
 Manufacturer#3	almond antique olive coral navajo	5	4670.66
 Manufacturer#4	almond antique gainsboro frosted violet	1	4202.35
 Manufacturer#4	almond antique violet mint lemon	2	6047.27
-Manufacturer#4	almond aquamarine floral ivory bisque	3	7337.620000000001
-Manufacturer#4	almond aquamarine yellow dodger mint	4	5716.950000000001
-Manufacturer#4	almond azure aquamarine papaya violet	5	4341.530000000001
+Manufacturer#4	almond aquamarine floral ivory bisque	3	7337.62
+Manufacturer#4	almond aquamarine yellow dodger mint	4	5716.95
+Manufacturer#4	almond azure aquamarine papaya violet	5	4341.53
 Manufacturer#5	almond antique blue firebrick mint	1	5190.08
 Manufacturer#5	almond antique medium spring khaki	2	6208.18
 Manufacturer#5	almond antique sky peru orange	3	7672.66
-Manufacturer#5	almond aquamarine dodger light gainsboro	4	5882.970000000001
-Manufacturer#5	almond azure blanched chiffon midnight	5	4271.3099999999995
+Manufacturer#5	almond aquamarine dodger light gainsboro	4	5882.97
+Manufacturer#5	almond azure blanched chiffon midnight	5	4271.31
 PREHOOK: query: -- 14. testPTFJoinWithWindowingWithCount
 explain
 select abc.p_mfgr, abc.p_name, 
 rank() over (distribute by abc.p_mfgr sort by abc.p_name) as r, 
 dense_rank() over (distribute by abc.p_mfgr sort by abc.p_name) as dr, 
 count(abc.p_name) over (distribute by abc.p_mfgr sort by abc.p_name) as cd, 
-abc.p_retailprice, sum(abc.p_retailprice) over (distribute by abc.p_mfgr sort by abc.p_name rows between unbounded preceding and current row) as s1, 
+abc.p_retailprice, round(sum(abc.p_retailprice) over (distribute by abc.p_mfgr sort by abc.p_name rows between unbounded preceding and current row),2) as s1,
 abc.p_size, abc.p_size - lag(abc.p_size,1,abc.p_size) over (distribute by abc.p_mfgr sort by abc.p_name) as deltaSz 
 from noop(on part 
 partition by p_mfgr 
@@ -2348,7 +2348,7 @@ select abc.p_mfgr, abc.p_name,
 rank() over (distribute by abc.p_mfgr sort by abc.p_name) as r, 
 dense_rank() over (distribute by abc.p_mfgr sort by abc.p_name) as dr, 
 count(abc.p_name) over (distribute by abc.p_mfgr sort by abc.p_name) as cd, 
-abc.p_retailprice, sum(abc.p_retailprice) over (distribute by abc.p_mfgr sort by abc.p_name rows between unbounded preceding and current row) as s1, 
+abc.p_retailprice, round(sum(abc.p_retailprice) over (distribute by abc.p_mfgr sort by abc.p_name rows between unbounded preceding and current row),2) as s1,
 abc.p_size, abc.p_size - lag(abc.p_size,1,abc.p_size) over (distribute by abc.p_mfgr sort by abc.p_name) as deltaSz 
 from noop(on part 
 partition by p_mfgr 
@@ -2503,7 +2503,7 @@ STAGE PLANS:
                         isPivotResult: true
             Statistics: Num rows: 28 Data size: 3461 Basic stats: COMPLETE Column stats: NONE
             Select Operator
-              expressions: _col2 (type: string), _col1 (type: string), rank_window_0 (type: int), dense_rank_window_1 (type: int), count_window_2 (type: bigint), _col7 (type: double), sum_window_3 (type: double), _col5 (type: int), (_col5 - lag_window_4) (type: int)
+              expressions: _col2 (type: string), _col1 (type: string), rank_window_0 (type: int), dense_rank_window_1 (type: int), count_window_2 (type: bigint), _col7 (type: double), round(sum_window_3, 2) (type: double), _col5 (type: int), (_col5 - lag_window_4) (type: int)
               outputColumnNames: _col0, _col1, _col2, _col3, _col4, _col5, _col6, _col7, _col8
               Statistics: Num rows: 28 Data size: 3461 Basic stats: COMPLETE Column stats: NONE
               File Output Operator
@@ -2523,8 +2523,8 @@ STAGE PLANS:
 PREHOOK: query: select abc.p_mfgr, abc.p_name, 
 rank() over (distribute by abc.p_mfgr sort by abc.p_name) as r, 
 dense_rank() over (distribute by abc.p_mfgr sort by abc.p_name) as dr, 
-count(abc.p_name) over (distribute by abc.p_mfgr sort by abc.p_name) as cd, 
-abc.p_retailprice, sum(abc.p_retailprice) over (distribute by abc.p_mfgr sort by abc.p_name rows between unbounded preceding and current row) as s1, 
+count(abc.p_name) over (distribute by abc.p_mfgr sort by abc.p_name) as cd,
+abc.p_retailprice, round(sum(abc.p_retailprice) over (distribute by abc.p_mfgr sort by abc.p_name rows between unbounded preceding and current row),2) as s1,
 abc.p_size, abc.p_size - lag(abc.p_size,1,abc.p_size) over (distribute by abc.p_mfgr sort by abc.p_name) as deltaSz 
 from noop(on part 
 partition by p_mfgr 
@@ -2536,8 +2536,8 @@ PREHOOK: Input: default@part
 POSTHOOK: query: select abc.p_mfgr, abc.p_name, 
 rank() over (distribute by abc.p_mfgr sort by abc.p_name) as r, 
 dense_rank() over (distribute by abc.p_mfgr sort by abc.p_name) as dr, 
-count(abc.p_name) over (distribute by abc.p_mfgr sort by abc.p_name) as cd, 
-abc.p_retailprice, sum(abc.p_retailprice) over (distribute by abc.p_mfgr sort by abc.p_name rows between unbounded preceding and current row) as s1, 
+count(abc.p_name) over (distribute by abc.p_mfgr sort by abc.p_name) as cd,
+abc.p_retailprice, round(sum(abc.p_retailprice) over (distribute by abc.p_mfgr sort by abc.p_name rows between unbounded preceding and current row),2) as s1,
 abc.p_size, abc.p_size - lag(abc.p_size,1,abc.p_size) over (distribute by abc.p_mfgr sort by abc.p_name) as deltaSz 
 from noop(on part 
 partition by p_mfgr 
@@ -2548,15 +2548,15 @@ POSTHOOK: Input: default@part
 #### A masked pattern was here ####
 Manufacturer#1	almond antique burnished rose metallic	1	1	4	1173.15	1173.15	2	0
 Manufacturer#1	almond antique burnished rose metallic	1	1	4	1173.15	2346.3	2	0
-Manufacturer#1	almond antique burnished rose metallic	1	1	4	1173.15	3519.4500000000003	2	0
+Manufacturer#1	almond antique burnished rose metallic	1	1	4	1173.15	3519.45	2	0
 Manufacturer#1	almond antique burnished rose metallic	1	1	4	1173.15	4692.6	2	0
-Manufacturer#1	almond antique chartreuse lavender yellow	5	2	5	1753.76	6446.360000000001	34	32
-Manufacturer#1	almond antique salmon chartreuse burlywood	6	3	6	1602.59	8048.950000000001	6	-28
+Manufacturer#1	almond antique chartreuse lavender yellow	5	2	5	1753.76	6446.36	34	32
+Manufacturer#1	almond antique salmon chartreuse burlywood	6	3	6	1602.59	8048.95	6	-28
 Manufacturer#1	almond aquamarine burnished black steel	7	4	7	1414.42	9463.37	28	22
 Manufacturer#1	almond aquamarine pink moccasin thistle	8	5	8	1632.66	11096.03	42	14
 Manufacturer#2	almond antique violet chocolate turquoise	1	1	1	1690.68	1690.68	14	0
 Manufacturer#2	almond antique violet turquoise frosted	2	2	2	1800.7	3491.38	40	26
-Manufacturer#2	almond aquamarine midnight light salmon	3	3	3	2031.98	5523.360000000001	2	-38
+Manufacturer#2	almond aquamarine midnight light salmon	3	3	3	2031.98	5523.36	2	-38
 Manufacturer#2	almond aquamarine rose maroon antique	4	4	4	1698.66	7222.02	25	23
 Manufacturer#2	almond aquamarine sandy cyan gainsboro	5	5	5	1701.6	8923.62	18	-7
 Manufacturer#3	almond antique chartreuse khaki white	1	1	1	1671.68	1671.68	17	0
@@ -2568,9 +2568,9 @@ Manufacturer#4	almond antique gainsboro frosted violet	1	1	1	1620.67	1620.67	10
 Manufacturer#4	almond antique violet mint lemon	2	2	2	1375.42	2996.09	39	29
 Manufacturer#4	almond aquamarine floral ivory bisque	3	3	3	1206.26	4202.35	27	-12
 Manufacturer#4	almond aquamarine yellow dodger mint	4	4	4	1844.92	6047.27	7	-20
-Manufacturer#4	almond azure aquamarine papaya violet	5	5	5	1290.35	7337.620000000001	12	5
+Manufacturer#4	almond azure aquamarine papaya violet	5	5	5	1290.35	7337.62	12	5
 Manufacturer#5	almond antique blue firebrick mint	1	1	1	1789.69	1789.69	31	0
-Manufacturer#5	almond antique medium spring khaki	2	2	2	1611.66	3401.3500000000004	6	-25
+Manufacturer#5	almond antique medium spring khaki	2	2	2	1611.66	3401.35	6	-25
 Manufacturer#5	almond antique sky peru orange	3	3	3	1788.73	5190.08	2	-4
 Manufacturer#5	almond aquamarine dodger light gainsboro	4	4	4	1018.1	6208.18	46	44
 Manufacturer#5	almond azure blanched chiffon midnight	5	5	5	1464.48	7672.66	23	-23
@@ -2712,7 +2712,7 @@ Manufacturer#5	almond azure blanched chiffon midnight	23
 PREHOOK: query: -- 16. testViewAsTableInputToPTF
 create view IF NOT EXISTS mfgr_price_view as 
 select p_mfgr, p_brand, 
-sum(p_retailprice) as s 
+round(sum(p_retailprice),2) as s
 from part 
 group by p_mfgr, p_brand
 PREHOOK: type: CREATEVIEW
@@ -2722,7 +2722,7 @@ PREHOOK: Output: default@mfgr_price_view
 POSTHOOK: query: -- 16. testViewAsTableInputToPTF
 create view IF NOT EXISTS mfgr_price_view as 
 select p_mfgr, p_brand, 
-sum(p_retailprice) as s 
+round(sum(p_retailprice),2) as s
 from part 
 group by p_mfgr, p_brand
 POSTHOOK: type: CREATEVIEW
@@ -2731,7 +2731,7 @@ POSTHOOK: Output: database:default
 POSTHOOK: Output: default@mfgr_price_view
 PREHOOK: query: explain
 select p_mfgr, p_brand, s, 
-sum(s) over w1  as s1
+round(sum(s) over w1,2)  as s1
 from noop(on mfgr_price_view 
 partition by p_mfgr 
 order by p_mfgr)  
@@ -2739,7 +2739,7 @@ window w1 as ( partition by p_mfgr order by p_brand rows between 2 preceding and
 PREHOOK: type: QUERY
 POSTHOOK: query: explain
 select p_mfgr, p_brand, s, 
-sum(s) over w1  as s1
+round(sum(s) over w1,2)  as s1
 from noop(on mfgr_price_view 
 partition by p_mfgr 
 order by p_mfgr)  
@@ -2780,26 +2780,30 @@ STAGE PLANS:
           mode: mergepartial
           outputColumnNames: _col0, _col1, _col2
           Statistics: Num rows: 13 Data size: 1573 Basic stats: COMPLETE Column stats: NONE
-          PTF Operator
-            Function definitions:
-                Input definition
-                  input alias: mfgr_price_view
-                  output shape: _col0: string, _col1: string, _col2: double
-                  type: TABLE
-                Partition table definition
-                  input alias: ptf_1
-                  name: noop
-                  order by: _col0 ASC NULLS FIRST
-                  output shape: _col0: string, _col1: string, _col2: double
-                  partition by: _col0
-                  raw input shape:
+          Select Operator
+            expressions: _col0 (type: string), _col1 (type: string), round(_col2, 2) (type: double)
+            outputColumnNames: _col0, _col1, _col2
             Statistics: Num rows: 13 Data size: 1573 Basic stats: COMPLETE Column stats: NONE
-            File Output Operator
-              compressed: false
-              table:
-                  input format: org.apache.hadoop.mapred.SequenceFileInputFormat
-                  output format: org.apache.hadoop.hive.ql.io.HiveSequenceFileOutputFormat
-                  serde: org.apache.hadoop.hive.serde2.lazybinary.LazyBinarySerDe
+            PTF Operator
+              Function definitions:
+                  Input definition
+                    input alias: mfgr_price_view
+                    output shape: _col0: string, _col1: string, _col2: double
+                    type: TABLE
+                  Partition table definition
+                    input alias: ptf_1
+                    name: noop
+                    order by: _col0 ASC NULLS FIRST
+                    output shape: _col0: string, _col1: string, _col2: double
+                    partition by: _col0
+                    raw input shape:
+              Statistics: Num rows: 13 Data size: 1573 Basic stats: COMPLETE Column stats: NONE
+              File Output Operator
+                compressed: false
+                table:
+                    input format: org.apache.hadoop.mapred.SequenceFileInputFormat
+                    output format: org.apache.hadoop.hive.ql.io.HiveSequenceFileOutputFormat
+                    serde: org.apache.hadoop.hive.serde2.lazybinary.LazyBinarySerDe
 
   Stage: Stage-2
     Map Reduce
@@ -2837,7 +2841,7 @@ STAGE PLANS:
                         window frame: PRECEDING(2)~CURRENT
             Statistics: Num rows: 13 Data size: 1573 Basic stats: COMPLETE Column stats: NONE
             Select Operator
-              expressions: _col0 (type: string), _col1 (type: string), _col2 (type: double), sum_window_0 (type: double)
+              expressions: _col0 (type: string), _col1 (type: string), _col2 (type: double), round(sum_window_0, 2) (type: double)
               outputColumnNames: _col0, _col1, _col2, _col3
               Statistics: Num rows: 13 Data size: 1573 Basic stats: COMPLETE Column stats: NONE
               File Output Operator
@@ -2855,7 +2859,7 @@ STAGE PLANS:
         ListSink
 
 PREHOOK: query: select p_mfgr, p_brand, s, 
-sum(s) over w1  as s1
+round(sum(s) over w1,2) as s1
 from noop(on mfgr_price_view 
 partition by p_mfgr 
 order by p_mfgr)  
@@ -2865,7 +2869,7 @@ PREHOOK: Input: default@mfgr_price_view
 PREHOOK: Input: default@part
 #### A masked pattern was here ####
 POSTHOOK: query: select p_mfgr, p_brand, s, 
-sum(s) over w1  as s1
+round(sum(s) over w1,2) as s1
 from noop(on mfgr_price_view 
 partition by p_mfgr 
 order by p_mfgr)  
@@ -2878,15 +2882,15 @@ Manufacturer#1	Brand#12	4800.84	4800.84
 Manufacturer#1	Brand#14	2346.3	7147.14
 Manufacturer#1	Brand#15	1602.59	8749.73
 Manufacturer#2	Brand#22	3491.38	3491.38
-Manufacturer#2	Brand#23	2031.98	5523.360000000001
+Manufacturer#2	Brand#23	2031.98	5523.36
 Manufacturer#2	Brand#24	1698.66	7222.02
-Manufacturer#2	Brand#25	1701.6	5432.240000000001
+Manufacturer#2	Brand#25	1701.6	5432.24
 Manufacturer#3	Brand#31	1671.68	1671.68
 Manufacturer#3	Brand#32	3333.37	5005.05
 Manufacturer#3	Brand#34	1337.29	6342.34
 Manufacturer#3	Brand#35	1190.27	5860.93
-Manufacturer#4	Brand#41	4755.9400000000005	4755.9400000000005
-Manufacturer#4	Brand#42	2581.6800000000003	7337.620000000001
+Manufacturer#4	Brand#41	4755.94	4755.94
+Manufacturer#4	Brand#42	2581.68	7337.62
 Manufacturer#5	Brand#51	1611.66	1611.66
 Manufacturer#5	Brand#52	3254.17	4865.83
 Manufacturer#5	Brand#53	2806.83	7672.66
@@ -2943,7 +2947,7 @@ order by p_name)
 INSERT OVERWRITE TABLE part_4 select p_mfgr, p_name, p_size, 
 rank() over (distribute by p_mfgr sort by p_name) as r, 
 dense_rank() over (distribute by p_mfgr sort by p_name) as dr, 
-sum(p_retailprice) over (distribute by p_mfgr sort by p_name rows between unbounded preceding and current row)  as s  
+round(sum(p_retailprice) over (distribute by p_mfgr sort by p_name rows between unbounded preceding and current row),2)  as s
 INSERT OVERWRITE TABLE part_5 select  p_mfgr,p_name, p_size,  
 round(sum(p_size) over (distribute by p_mfgr sort by p_size range between 5 preceding and current row),1) as s2,
 rank() over (distribute by p_mfgr sort by p_mfgr, p_name) as r, 
@@ -2959,7 +2963,7 @@ order by p_name)
 INSERT OVERWRITE TABLE part_4 select p_mfgr, p_name, p_size, 
 rank() over (distribute by p_mfgr sort by p_name) as r, 
 dense_rank() over (distribute by p_mfgr sort by p_name) as dr, 
-sum(p_retailprice) over (distribute by p_mfgr sort by p_name rows between unbounded preceding and current row)  as s  
+round(sum(p_retailprice) over (distribute by p_mfgr sort by p_name rows between unbounded preceding and current row),2)  as s
 INSERT OVERWRITE TABLE part_5 select  p_mfgr,p_name, p_size,  
 round(sum(p_size) over (distribute by p_mfgr sort by p_size range between 5 preceding and current row),1) as s2,
 rank() over (distribute by p_mfgr sort by p_mfgr, p_name) as r, 
@@ -3073,7 +3077,7 @@ STAGE PLANS:
                         window frame: PRECEDING(MAX)~CURRENT
             Statistics: Num rows: 26 Data size: 3147 Basic stats: COMPLETE Column stats: NONE
             Select Operator
-              expressions: _col2 (type: string), _col1 (type: string), _col5 (type: int), rank_window_0 (type: int), dense_rank_window_1 (type: int), sum_window_2 (type: double)
+              expressions: _col2 (type: string), _col1 (type: string), _col5 (type: int), rank_window_0 (type: int), dense_rank_window_1 (type: int), round(sum_window_2, 2) (type: double)
               outputColumnNames: _col0, _col1, _col2, _col3, _col4, _col5
               Statistics: Num rows: 26 Data size: 3147 Basic stats: COMPLETE Column stats: NONE
               File Output Operator
@@ -3232,7 +3236,7 @@ order by p_name)
 INSERT OVERWRITE TABLE part_4 select p_mfgr, p_name, p_size, 
 rank() over (distribute by p_mfgr sort by p_name) as r, 
 dense_rank() over (distribute by p_mfgr sort by p_name) as dr, 
-sum(p_retailprice) over (distribute by p_mfgr sort by p_name rows between unbounded preceding and current row)  as s  
+round(sum(p_retailprice) over (distribute by p_mfgr sort by p_name rows between unbounded preceding and current row),2)  as s
 INSERT OVERWRITE TABLE part_5 select  p_mfgr,p_name, p_size,  
 round(sum(p_size) over (distribute by p_mfgr sort by p_size range between 5 preceding and current row),1) as s2,
 rank() over (distribute by p_mfgr sort by p_mfgr, p_name) as r, 
@@ -3250,7 +3254,7 @@ order by p_name)
 INSERT OVERWRITE TABLE part_4 select p_mfgr, p_name, p_size, 
 rank() over (distribute by p_mfgr sort by p_name) as r, 
 dense_rank() over (distribute by p_mfgr sort by p_name) as dr, 
-sum(p_retailprice) over (distribute by p_mfgr sort by p_name rows between unbounded preceding and current row)  as s  
+round(sum(p_retailprice) over (distribute by p_mfgr sort by p_name rows between unbounded preceding and current row),2)  as s
 INSERT OVERWRITE TABLE part_5 select  p_mfgr,p_name, p_size,  
 round(sum(p_size) over (distribute by p_mfgr sort by p_size range between 5 preceding and current row),1) as s2,
 rank() over (distribute by p_mfgr sort by p_mfgr, p_name) as r, 
@@ -3287,12 +3291,12 @@ POSTHOOK: Input: default@part_4
 Manufacturer#1	almond antique burnished rose metallic	2	1	1	1173.15
 Manufacturer#1	almond antique burnished rose metallic	2	1	1	2346.3
 Manufacturer#1	almond antique chartreuse lavender yellow	34	3	2	4100.06
-Manufacturer#1	almond antique salmon chartreuse burlywood	6	4	3	5702.650000000001
-Manufacturer#1	almond aquamarine burnished black steel	28	5	4	7117.070000000001
-Manufacturer#1	almond aquamarine pink moccasin thistle	42	6	5	8749.730000000001
+Manufacturer#1	almond antique salmon chartreuse burlywood	6	4	3	5702.65
+Manufacturer#1	almond aquamarine burnished black steel	28	5	4	7117.07
+Manufacturer#1	almond aquamarine pink moccasin thistle	42	6	5	8749.73
 Manufacturer#2	almond antique violet chocolate turquoise	14	1	1	1690.68
 Manufacturer#2	almond antique violet turquoise frosted	40	2	2	3491.38
-Manufacturer#2	almond aquamarine midnight light salmon	2	3	3	5523.360000000001
+Manufacturer#2	almond aquamarine midnight light salmon	2	3	3	5523.36
 Manufacturer#2	almond aquamarine rose maroon antique	25	4	4	7222.02
 Manufacturer#2	almond aquamarine sandy cyan gainsboro	18	5	5	8923.62
 Manufacturer#3	almond antique chartreuse khaki white	17	1	1	1671.68
@@ -3304,9 +3308,9 @@ Manufacturer#4	almond antique gainsboro frosted violet	10	1	1	1620.67
 Manufacturer#4	almond antique violet mint lemon	39	2	2	2996.09
 Manufacturer#4	almond aquamarine floral ivory bisque	27	3	3	4202.35
 Manufacturer#4	almond aquamarine yellow dodger mint	7	4	4	6047.27
-Manufacturer#4	almond azure aquamarine papaya violet	12	5	5	7337.620000000001
+Manufacturer#4	almond azure aquamarine papaya violet	12	5	5	7337.62
 Manufacturer#5	almond antique blue firebrick mint	31	1	1	1789.69
-Manufacturer#5	almond antique medium spring khaki	6	2	2	3401.3500000000004
+Manufacturer#5	almond antique medium spring khaki	6	2	2	3401.35
 Manufacturer#5	almond antique sky peru orange	2	3	3	5190.08
 Manufacturer#5	almond aquamarine dodger light gainsboro	46	4	4	6208.18
 Manufacturer#5	almond azure blanched chiffon midnight	23	5	5	7672.66


[11/13] hive git commit: HIVE-15520: Improve the sum performance for Range based window (Aihua Xu, reviewed by Yongzhi Chen)

Posted by ai...@apache.org.
http://git-wip-us.apache.org/repos/asf/hive/blob/a28b28f3/ql/src/test/results/clientpositive/cbo_rp_windowing_2.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/cbo_rp_windowing_2.q.out b/ql/src/test/results/clientpositive/cbo_rp_windowing_2.q.out
index aa34d3d..db68276 100644
--- a/ql/src/test/results/clientpositive/cbo_rp_windowing_2.q.out
+++ b/ql/src/test/results/clientpositive/cbo_rp_windowing_2.q.out
@@ -4,7 +4,7 @@ PREHOOK: query: -- SORT_QUERY_RESULTS
 select p_mfgr, p_name, p_size,
 rank() over(distribute by p_mfgr sort by p_name) as r,
 dense_rank() over(distribute by p_mfgr sort by p_name) as dr,
-sum(p_retailprice) over (distribute by p_mfgr sort by p_name rows between unbounded preceding and current row) as s1
+round(sum(p_retailprice) over (distribute by p_mfgr sort by p_name rows between unbounded preceding and current row),2) as s1
 from part
 PREHOOK: type: QUERY
 PREHOOK: Input: default@part
@@ -15,7 +15,7 @@ POSTHOOK: query: -- SORT_QUERY_RESULTS
 select p_mfgr, p_name, p_size,
 rank() over(distribute by p_mfgr sort by p_name) as r,
 dense_rank() over(distribute by p_mfgr sort by p_name) as dr,
-sum(p_retailprice) over (distribute by p_mfgr sort by p_name rows between unbounded preceding and current row) as s1
+round(sum(p_retailprice) over (distribute by p_mfgr sort by p_name rows between unbounded preceding and current row),2) as s1
 from part
 POSTHOOK: type: QUERY
 POSTHOOK: Input: default@part
@@ -23,12 +23,12 @@ POSTHOOK: Input: default@part
 Manufacturer#1	almond antique burnished rose metallic	2	1	1	1173.15
 Manufacturer#1	almond antique burnished rose metallic	2	1	1	2346.3
 Manufacturer#1	almond antique chartreuse lavender yellow	34	3	2	4100.06
-Manufacturer#1	almond antique salmon chartreuse burlywood	6	4	3	5702.650000000001
-Manufacturer#1	almond aquamarine burnished black steel	28	5	4	7117.070000000001
-Manufacturer#1	almond aquamarine pink moccasin thistle	42	6	5	8749.730000000001
+Manufacturer#1	almond antique salmon chartreuse burlywood	6	4	3	5702.65
+Manufacturer#1	almond aquamarine burnished black steel	28	5	4	7117.07
+Manufacturer#1	almond aquamarine pink moccasin thistle	42	6	5	8749.73
 Manufacturer#2	almond antique violet chocolate turquoise	14	1	1	1690.68
 Manufacturer#2	almond antique violet turquoise frosted	40	2	2	3491.38
-Manufacturer#2	almond aquamarine midnight light salmon	2	3	3	5523.360000000001
+Manufacturer#2	almond aquamarine midnight light salmon	2	3	3	5523.36
 Manufacturer#2	almond aquamarine rose maroon antique	25	4	4	7222.02
 Manufacturer#2	almond aquamarine sandy cyan gainsboro	18	5	5	8923.62
 Manufacturer#3	almond antique chartreuse khaki white	17	1	1	1671.68
@@ -40,9 +40,9 @@ Manufacturer#4	almond antique gainsboro frosted violet	10	1	1	1620.67
 Manufacturer#4	almond antique violet mint lemon	39	2	2	2996.09
 Manufacturer#4	almond aquamarine floral ivory bisque	27	3	3	4202.35
 Manufacturer#4	almond aquamarine yellow dodger mint	7	4	4	6047.27
-Manufacturer#4	almond azure aquamarine papaya violet	12	5	5	7337.620000000001
+Manufacturer#4	almond azure aquamarine papaya violet	12	5	5	7337.62
 Manufacturer#5	almond antique blue firebrick mint	31	1	1	1789.69
-Manufacturer#5	almond antique medium spring khaki	6	2	2	3401.3500000000004
+Manufacturer#5	almond antique medium spring khaki	6	2	2	3401.35
 Manufacturer#5	almond antique sky peru orange	2	3	3	5190.08
 Manufacturer#5	almond aquamarine dodger light gainsboro	46	4	4	6208.18
 Manufacturer#5	almond azure blanched chiffon midnight	23	5	5	7672.66
@@ -185,7 +185,7 @@ select p_mfgr, p_name,
 rank() over(distribute by p_mfgr sort by p_name) as r, 
 dense_rank() over(distribute by p_mfgr sort by p_name) as dr, 
 count(p_size) over(distribute by p_mfgr sort by p_name) as cd, 
-p_retailprice, sum(p_retailprice) over (distribute by p_mfgr sort by p_name rows between unbounded preceding and current row) as s1, 
+p_retailprice, round(sum(p_retailprice) over (distribute by p_mfgr sort by p_name rows between unbounded preceding and current row),2) as s1, 
 p_size, p_size - lag(p_size,1,p_size) over(distribute by p_mfgr sort by p_name) as deltaSz 
 from part
 PREHOOK: type: QUERY
@@ -196,7 +196,7 @@ select p_mfgr, p_name,
 rank() over(distribute by p_mfgr sort by p_name) as r, 
 dense_rank() over(distribute by p_mfgr sort by p_name) as dr, 
 count(p_size) over(distribute by p_mfgr sort by p_name) as cd, 
-p_retailprice, sum(p_retailprice) over (distribute by p_mfgr sort by p_name rows between unbounded preceding and current row) as s1, 
+p_retailprice, round(sum(p_retailprice) over (distribute by p_mfgr sort by p_name rows between unbounded preceding and current row),2) as s1, 
 p_size, p_size - lag(p_size,1,p_size) over(distribute by p_mfgr sort by p_name) as deltaSz 
 from part
 POSTHOOK: type: QUERY
@@ -205,12 +205,12 @@ POSTHOOK: Input: default@part
 Manufacturer#1	almond antique burnished rose metallic	1	1	2	1173.15	1173.15	2	0
 Manufacturer#1	almond antique burnished rose metallic	1	1	2	1173.15	2346.3	2	0
 Manufacturer#1	almond antique chartreuse lavender yellow	3	2	3	1753.76	4100.06	34	32
-Manufacturer#1	almond antique salmon chartreuse burlywood	4	3	4	1602.59	5702.650000000001	6	-28
-Manufacturer#1	almond aquamarine burnished black steel	5	4	5	1414.42	7117.070000000001	28	22
-Manufacturer#1	almond aquamarine pink moccasin thistle	6	5	6	1632.66	8749.730000000001	42	14
+Manufacturer#1	almond antique salmon chartreuse burlywood	4	3	4	1602.59	5702.65	6	-28
+Manufacturer#1	almond aquamarine burnished black steel	5	4	5	1414.42	7117.07	28	22
+Manufacturer#1	almond aquamarine pink moccasin thistle	6	5	6	1632.66	8749.73	42	14
 Manufacturer#2	almond antique violet chocolate turquoise	1	1	1	1690.68	1690.68	14	0
 Manufacturer#2	almond antique violet turquoise frosted	2	2	2	1800.7	3491.38	40	26
-Manufacturer#2	almond aquamarine midnight light salmon	3	3	3	2031.98	5523.360000000001	2	-38
+Manufacturer#2	almond aquamarine midnight light salmon	3	3	3	2031.98	5523.36	2	-38
 Manufacturer#2	almond aquamarine rose maroon antique	4	4	4	1698.66	7222.02	25	23
 Manufacturer#2	almond aquamarine sandy cyan gainsboro	5	5	5	1701.6	8923.62	18	-7
 Manufacturer#3	almond antique chartreuse khaki white	1	1	1	1671.68	1671.68	17	0
@@ -222,9 +222,9 @@ Manufacturer#4	almond antique gainsboro frosted violet	1	1	1	1620.67	1620.67	10
 Manufacturer#4	almond antique violet mint lemon	2	2	2	1375.42	2996.09	39	29
 Manufacturer#4	almond aquamarine floral ivory bisque	3	3	3	1206.26	4202.35	27	-12
 Manufacturer#4	almond aquamarine yellow dodger mint	4	4	4	1844.92	6047.27	7	-20
-Manufacturer#4	almond azure aquamarine papaya violet	5	5	5	1290.35	7337.620000000001	12	5
+Manufacturer#4	almond azure aquamarine papaya violet	5	5	5	1290.35	7337.62	12	5
 Manufacturer#5	almond antique blue firebrick mint	1	1	1	1789.69	1789.69	31	0
-Manufacturer#5	almond antique medium spring khaki	2	2	2	1611.66	3401.3500000000004	6	-25
+Manufacturer#5	almond antique medium spring khaki	2	2	2	1611.66	3401.35	6	-25
 Manufacturer#5	almond antique sky peru orange	3	3	3	1788.73	5190.08	2	-4
 Manufacturer#5	almond aquamarine dodger light gainsboro	4	4	4	1018.1	6208.18	46	44
 Manufacturer#5	almond azure blanched chiffon midnight	5	5	5	1464.48	7672.66	23	-23
@@ -234,7 +234,7 @@ from (select p_mfgr, p_name,
 rank() over(distribute by p_mfgr sort by p_name) as r, 
 dense_rank() over(distribute by p_mfgr sort by p_name) as dr, 
 count(p_size) over(distribute by p_mfgr sort by p_name) as cd, 
-p_retailprice, sum(p_retailprice) over (distribute by p_mfgr sort by p_name rows between unbounded preceding and current row) as s1, 
+p_retailprice, round(sum(p_retailprice) over (distribute by p_mfgr sort by p_name rows between unbounded preceding and current row),2) as s1, 
 p_size, p_size - lag(p_size,1,p_size) over(distribute by p_mfgr sort by p_name) as deltaSz 
 from part 
 ) sub1
@@ -247,7 +247,7 @@ from (select p_mfgr, p_name,
 rank() over(distribute by p_mfgr sort by p_name) as r, 
 dense_rank() over(distribute by p_mfgr sort by p_name) as dr, 
 count(p_size) over(distribute by p_mfgr sort by p_name) as cd, 
-p_retailprice, sum(p_retailprice) over (distribute by p_mfgr sort by p_name rows between unbounded preceding and current row) as s1, 
+p_retailprice, round(sum(p_retailprice) over (distribute by p_mfgr sort by p_name rows between unbounded preceding and current row),2) as s1, 
 p_size, p_size - lag(p_size,1,p_size) over(distribute by p_mfgr sort by p_name) as deltaSz 
 from part 
 ) sub1
@@ -262,29 +262,29 @@ POSTHOOK: Input: default@part
 1	1	2	2346.3	0
 2	2	2	2861.95	-3
 2	2	2	2996.09	29
-2	2	2	3401.3500000000004	-25
+2	2	2	3401.35	-25
 2	2	2	3491.38	26
 3	2	3	4100.06	32
 3	3	3	4202.35	-12
 3	3	3	4272.34	5
 3	3	3	5190.08	-4
-3	3	3	5523.360000000001	-38
-4	3	4	5702.650000000001	-28
+3	3	3	5523.36	-38
+4	3	4	5702.65	-28
 4	4	4	6047.27	-20
 4	4	4	6195.32	-18
 4	4	4	6208.18	44
 4	4	4	7222.02	23
-5	4	5	7117.070000000001	22
-5	5	5	7337.620000000001	5
+5	4	5	7117.07	22
+5	5	5	7337.62	5
 5	5	5	7532.61	44
 5	5	5	7672.66	-23
 5	5	5	8923.62	-7
-6	5	6	8749.730000000001	14
+6	5	6	8749.73	14
 PREHOOK: query: -- 7. testJoinWithWindowingAndPTF
 select abc.p_mfgr, abc.p_name, 
 rank() over(distribute by abc.p_mfgr sort by abc.p_name) as r, 
 dense_rank() over(distribute by abc.p_mfgr sort by abc.p_name) as dr, 
-abc.p_retailprice, sum(abc.p_retailprice) over (distribute by abc.p_mfgr sort by abc.p_name rows between unbounded preceding and current row) as s1, 
+abc.p_retailprice, round(sum(abc.p_retailprice) over (distribute by abc.p_mfgr sort by abc.p_name rows between unbounded preceding and current row),2) as s1, 
 abc.p_size, abc.p_size - lag(abc.p_size,1,abc.p_size) over(distribute by abc.p_mfgr sort by abc.p_name) as deltaSz 
 from noop(on part 
 partition by p_mfgr 
@@ -297,7 +297,7 @@ POSTHOOK: query: -- 7. testJoinWithWindowingAndPTF
 select abc.p_mfgr, abc.p_name, 
 rank() over(distribute by abc.p_mfgr sort by abc.p_name) as r, 
 dense_rank() over(distribute by abc.p_mfgr sort by abc.p_name) as dr, 
-abc.p_retailprice, sum(abc.p_retailprice) over (distribute by abc.p_mfgr sort by abc.p_name rows between unbounded preceding and current row) as s1, 
+abc.p_retailprice, round(sum(abc.p_retailprice) over (distribute by abc.p_mfgr sort by abc.p_name rows between unbounded preceding and current row),2) as s1, 
 abc.p_size, abc.p_size - lag(abc.p_size,1,abc.p_size) over(distribute by abc.p_mfgr sort by abc.p_name) as deltaSz 
 from noop(on part 
 partition by p_mfgr 
@@ -308,15 +308,15 @@ POSTHOOK: Input: default@part
 #### A masked pattern was here ####
 Manufacturer#1	almond antique burnished rose metallic	1	1	1173.15	1173.15	2	0
 Manufacturer#1	almond antique burnished rose metallic	1	1	1173.15	2346.3	2	0
-Manufacturer#1	almond antique burnished rose metallic	1	1	1173.15	3519.4500000000003	2	0
+Manufacturer#1	almond antique burnished rose metallic	1	1	1173.15	3519.45	2	0
 Manufacturer#1	almond antique burnished rose metallic	1	1	1173.15	4692.6	2	0
-Manufacturer#1	almond antique chartreuse lavender yellow	5	2	1753.76	6446.360000000001	34	32
-Manufacturer#1	almond antique salmon chartreuse burlywood	6	3	1602.59	8048.950000000001	6	-28
+Manufacturer#1	almond antique chartreuse lavender yellow	5	2	1753.76	6446.36	34	32
+Manufacturer#1	almond antique salmon chartreuse burlywood	6	3	1602.59	8048.95	6	-28
 Manufacturer#1	almond aquamarine burnished black steel	7	4	1414.42	9463.37	28	22
 Manufacturer#1	almond aquamarine pink moccasin thistle	8	5	1632.66	11096.03	42	14
 Manufacturer#2	almond antique violet chocolate turquoise	1	1	1690.68	1690.68	14	0
 Manufacturer#2	almond antique violet turquoise frosted	2	2	1800.7	3491.38	40	26
-Manufacturer#2	almond aquamarine midnight light salmon	3	3	2031.98	5523.360000000001	2	-38
+Manufacturer#2	almond aquamarine midnight light salmon	3	3	2031.98	5523.36	2	-38
 Manufacturer#2	almond aquamarine rose maroon antique	4	4	1698.66	7222.02	25	23
 Manufacturer#2	almond aquamarine sandy cyan gainsboro	5	5	1701.6	8923.62	18	-7
 Manufacturer#3	almond antique chartreuse khaki white	1	1	1671.68	1671.68	17	0
@@ -328,9 +328,9 @@ Manufacturer#4	almond antique gainsboro frosted violet	1	1	1620.67	1620.67	10	0
 Manufacturer#4	almond antique violet mint lemon	2	2	1375.42	2996.09	39	29
 Manufacturer#4	almond aquamarine floral ivory bisque	3	3	1206.26	4202.35	27	-12
 Manufacturer#4	almond aquamarine yellow dodger mint	4	4	1844.92	6047.27	7	-20
-Manufacturer#4	almond azure aquamarine papaya violet	5	5	1290.35	7337.620000000001	12	5
+Manufacturer#4	almond azure aquamarine papaya violet	5	5	1290.35	7337.62	12	5
 Manufacturer#5	almond antique blue firebrick mint	1	1	1789.69	1789.69	31	0
-Manufacturer#5	almond antique medium spring khaki	2	2	1611.66	3401.3500000000004	6	-25
+Manufacturer#5	almond antique medium spring khaki	2	2	1611.66	3401.35	6	-25
 Manufacturer#5	almond antique sky peru orange	3	3	1788.73	5190.08	2	-4
 Manufacturer#5	almond aquamarine dodger light gainsboro	4	4	1018.1	6208.18	46	44
 Manufacturer#5	almond azure blanched chiffon midnight	5	5	1464.48	7672.66	23	-23
@@ -378,7 +378,7 @@ PREHOOK: query: -- 9. testHavingWithWindowingNoGBY
 select p_mfgr, p_name, p_size, 
 rank() over(distribute by p_mfgr sort by p_name) as r, 
 dense_rank() over(distribute by p_mfgr sort by p_name) as dr, 
-sum(p_retailprice) over (distribute by p_mfgr sort by p_name rows between unbounded preceding and current row)  as s1
+round(sum(p_retailprice) over (distribute by p_mfgr sort by p_name rows between unbounded preceding and current row),2) as s1
 from part
 PREHOOK: type: QUERY
 PREHOOK: Input: default@part
@@ -387,7 +387,7 @@ POSTHOOK: query: -- 9. testHavingWithWindowingNoGBY
 select p_mfgr, p_name, p_size, 
 rank() over(distribute by p_mfgr sort by p_name) as r, 
 dense_rank() over(distribute by p_mfgr sort by p_name) as dr, 
-sum(p_retailprice) over (distribute by p_mfgr sort by p_name rows between unbounded preceding and current row)  as s1
+round(sum(p_retailprice) over (distribute by p_mfgr sort by p_name rows between unbounded preceding and current row),2) as s1
 from part
 POSTHOOK: type: QUERY
 POSTHOOK: Input: default@part
@@ -395,12 +395,12 @@ POSTHOOK: Input: default@part
 Manufacturer#1	almond antique burnished rose metallic	2	1	1	1173.15
 Manufacturer#1	almond antique burnished rose metallic	2	1	1	2346.3
 Manufacturer#1	almond antique chartreuse lavender yellow	34	3	2	4100.06
-Manufacturer#1	almond antique salmon chartreuse burlywood	6	4	3	5702.650000000001
-Manufacturer#1	almond aquamarine burnished black steel	28	5	4	7117.070000000001
-Manufacturer#1	almond aquamarine pink moccasin thistle	42	6	5	8749.730000000001
+Manufacturer#1	almond antique salmon chartreuse burlywood	6	4	3	5702.65
+Manufacturer#1	almond aquamarine burnished black steel	28	5	4	7117.07
+Manufacturer#1	almond aquamarine pink moccasin thistle	42	6	5	8749.73
 Manufacturer#2	almond antique violet chocolate turquoise	14	1	1	1690.68
 Manufacturer#2	almond antique violet turquoise frosted	40	2	2	3491.38
-Manufacturer#2	almond aquamarine midnight light salmon	2	3	3	5523.360000000001
+Manufacturer#2	almond aquamarine midnight light salmon	2	3	3	5523.36
 Manufacturer#2	almond aquamarine rose maroon antique	25	4	4	7222.02
 Manufacturer#2	almond aquamarine sandy cyan gainsboro	18	5	5	8923.62
 Manufacturer#3	almond antique chartreuse khaki white	17	1	1	1671.68
@@ -412,9 +412,9 @@ Manufacturer#4	almond antique gainsboro frosted violet	10	1	1	1620.67
 Manufacturer#4	almond antique violet mint lemon	39	2	2	2996.09
 Manufacturer#4	almond aquamarine floral ivory bisque	27	3	3	4202.35
 Manufacturer#4	almond aquamarine yellow dodger mint	7	4	4	6047.27
-Manufacturer#4	almond azure aquamarine papaya violet	12	5	5	7337.620000000001
+Manufacturer#4	almond azure aquamarine papaya violet	12	5	5	7337.62
 Manufacturer#5	almond antique blue firebrick mint	31	1	1	1789.69
-Manufacturer#5	almond antique medium spring khaki	6	2	2	3401.3500000000004
+Manufacturer#5	almond antique medium spring khaki	6	2	2	3401.35
 Manufacturer#5	almond antique sky peru orange	2	3	3	5190.08
 Manufacturer#5	almond aquamarine dodger light gainsboro	46	4	4	6208.18
 Manufacturer#5	almond azure blanched chiffon midnight	23	5	5	7672.66
@@ -422,7 +422,7 @@ PREHOOK: query: -- 10. testHavingWithWindowingCondRankNoGBY
 select p_mfgr, p_name, p_size, 
 rank() over(distribute by p_mfgr sort by p_name) as r, 
 dense_rank() over(distribute by p_mfgr sort by p_name) as dr, 
-sum(p_retailprice) over (distribute by p_mfgr sort by p_name rows between unbounded preceding and current row) as s1 
+round(sum(p_retailprice) over (distribute by p_mfgr sort by p_name rows between unbounded preceding and current row),2) as s1 
 from part
 PREHOOK: type: QUERY
 PREHOOK: Input: default@part
@@ -431,7 +431,7 @@ POSTHOOK: query: -- 10. testHavingWithWindowingCondRankNoGBY
 select p_mfgr, p_name, p_size, 
 rank() over(distribute by p_mfgr sort by p_name) as r, 
 dense_rank() over(distribute by p_mfgr sort by p_name) as dr, 
-sum(p_retailprice) over (distribute by p_mfgr sort by p_name rows between unbounded preceding and current row) as s1 
+round(sum(p_retailprice) over (distribute by p_mfgr sort by p_name rows between unbounded preceding and current row),2) as s1 
 from part
 POSTHOOK: type: QUERY
 POSTHOOK: Input: default@part
@@ -439,12 +439,12 @@ POSTHOOK: Input: default@part
 Manufacturer#1	almond antique burnished rose metallic	2	1	1	1173.15
 Manufacturer#1	almond antique burnished rose metallic	2	1	1	2346.3
 Manufacturer#1	almond antique chartreuse lavender yellow	34	3	2	4100.06
-Manufacturer#1	almond antique salmon chartreuse burlywood	6	4	3	5702.650000000001
-Manufacturer#1	almond aquamarine burnished black steel	28	5	4	7117.070000000001
-Manufacturer#1	almond aquamarine pink moccasin thistle	42	6	5	8749.730000000001
+Manufacturer#1	almond antique salmon chartreuse burlywood	6	4	3	5702.65
+Manufacturer#1	almond aquamarine burnished black steel	28	5	4	7117.07
+Manufacturer#1	almond aquamarine pink moccasin thistle	42	6	5	8749.73
 Manufacturer#2	almond antique violet chocolate turquoise	14	1	1	1690.68
 Manufacturer#2	almond antique violet turquoise frosted	40	2	2	3491.38
-Manufacturer#2	almond aquamarine midnight light salmon	2	3	3	5523.360000000001
+Manufacturer#2	almond aquamarine midnight light salmon	2	3	3	5523.36
 Manufacturer#2	almond aquamarine rose maroon antique	25	4	4	7222.02
 Manufacturer#2	almond aquamarine sandy cyan gainsboro	18	5	5	8923.62
 Manufacturer#3	almond antique chartreuse khaki white	17	1	1	1671.68
@@ -456,9 +456,9 @@ Manufacturer#4	almond antique gainsboro frosted violet	10	1	1	1620.67
 Manufacturer#4	almond antique violet mint lemon	39	2	2	2996.09
 Manufacturer#4	almond aquamarine floral ivory bisque	27	3	3	4202.35
 Manufacturer#4	almond aquamarine yellow dodger mint	7	4	4	6047.27
-Manufacturer#4	almond azure aquamarine papaya violet	12	5	5	7337.620000000001
+Manufacturer#4	almond azure aquamarine papaya violet	12	5	5	7337.62
 Manufacturer#5	almond antique blue firebrick mint	31	1	1	1789.69
-Manufacturer#5	almond antique medium spring khaki	6	2	2	3401.3500000000004
+Manufacturer#5	almond antique medium spring khaki	6	2	2	3401.35
 Manufacturer#5	almond antique sky peru orange	2	3	3	5190.08
 Manufacturer#5	almond aquamarine dodger light gainsboro	46	4	4	6208.18
 Manufacturer#5	almond azure blanched chiffon midnight	23	5	5	7672.66
@@ -785,10 +785,10 @@ Manufacturer#5	almond aquamarine dodger light gainsboro	46	4	4	6
 Manufacturer#5	almond azure blanched chiffon midnight	23	5	5	2
 PREHOOK: query: -- 18. testUDAFs
 select  p_mfgr,p_name, p_size, 
-sum(p_retailprice) over w1 as s, 
+round(sum(p_retailprice) over w1,2) as s,
 min(p_retailprice) over w1 as mi,
 max(p_retailprice) over w1 as ma,
-avg(p_retailprice) over w1 as ag
+round(avg(p_retailprice) over w1,2) as ag
 from part
 window w1 as (distribute by p_mfgr sort by p_mfgr, p_name rows between 2 preceding and 2 following)
 PREHOOK: type: QUERY
@@ -796,47 +796,47 @@ PREHOOK: Input: default@part
 #### A masked pattern was here ####
 POSTHOOK: query: -- 18. testUDAFs
 select  p_mfgr,p_name, p_size, 
-sum(p_retailprice) over w1 as s, 
+round(sum(p_retailprice) over w1,2) as s,
 min(p_retailprice) over w1 as mi,
 max(p_retailprice) over w1 as ma,
-avg(p_retailprice) over w1 as ag
+round(avg(p_retailprice) over w1,2) as ag
 from part
 window w1 as (distribute by p_mfgr sort by p_mfgr, p_name rows between 2 preceding and 2 following)
 POSTHOOK: type: QUERY
 POSTHOOK: Input: default@part
 #### A masked pattern was here ####
-Manufacturer#1	almond antique burnished rose metallic	2	4100.06	1173.15	1753.76	1366.6866666666667
-Manufacturer#1	almond antique burnished rose metallic	2	5702.650000000001	1173.15	1753.76	1425.6625000000001
-Manufacturer#1	almond antique chartreuse lavender yellow	34	7117.070000000001	1173.15	1753.76	1423.4140000000002
-Manufacturer#1	almond antique salmon chartreuse burlywood	6	7576.580000000002	1173.15	1753.76	1515.3160000000003
-Manufacturer#1	almond aquamarine burnished black steel	28	6403.430000000001	1414.42	1753.76	1600.8575000000003
-Manufacturer#1	almond aquamarine pink moccasin thistle	42	4649.670000000001	1414.42	1632.66	1549.8900000000003
-Manufacturer#2	almond antique violet chocolate turquoise	14	5523.360000000001	1690.68	2031.98	1841.1200000000001
-Manufacturer#2	almond antique violet turquoise frosted	40	7222.02	1690.68	2031.98	1805.505
-Manufacturer#2	almond aquamarine midnight light salmon	2	8923.62	1690.68	2031.98	1784.7240000000002
-Manufacturer#2	almond aquamarine rose maroon antique	25	7232.9400000000005	1698.66	2031.98	1808.2350000000001
-Manufacturer#2	almond aquamarine sandy cyan gainsboro	18	5432.240000000001	1698.66	2031.98	1810.746666666667
-Manufacturer#3	almond antique chartreuse khaki white	17	4272.34	1190.27	1671.68	1424.1133333333335
+Manufacturer#1	almond antique burnished rose metallic	2	4100.06	1173.15	1753.76	1366.69
+Manufacturer#1	almond antique burnished rose metallic	2	5702.65	1173.15	1753.76	1425.66
+Manufacturer#1	almond antique chartreuse lavender yellow	34	7117.07	1173.15	1753.76	1423.41
+Manufacturer#1	almond antique salmon chartreuse burlywood	6	7576.58	1173.15	1753.76	1515.32
+Manufacturer#1	almond aquamarine burnished black steel	28	6403.43	1414.42	1753.76	1600.86
+Manufacturer#1	almond aquamarine pink moccasin thistle	42	4649.67	1414.42	1632.66	1549.89
+Manufacturer#2	almond antique violet chocolate turquoise	14	5523.36	1690.68	2031.98	1841.12
+Manufacturer#2	almond antique violet turquoise frosted	40	7222.02	1690.68	2031.98	1805.51
+Manufacturer#2	almond aquamarine midnight light salmon	2	8923.62	1690.68	2031.98	1784.72
+Manufacturer#2	almond aquamarine rose maroon antique	25	7232.94	1698.66	2031.98	1808.24
+Manufacturer#2	almond aquamarine sandy cyan gainsboro	18	5432.24	1698.66	2031.98	1810.75
+Manufacturer#3	almond antique chartreuse khaki white	17	4272.34	1190.27	1671.68	1424.11
 Manufacturer#3	almond antique forest lavender goldenrod	14	6195.32	1190.27	1922.98	1548.83
-Manufacturer#3	almond antique metallic orange dim	19	7532.61	1190.27	1922.98	1506.522
-Manufacturer#3	almond antique misty red olive	1	5860.929999999999	1190.27	1922.98	1465.2324999999998
-Manufacturer#3	almond antique olive coral navajo	45	4670.66	1337.29	1922.98	1556.8866666666665
-Manufacturer#4	almond antique gainsboro frosted violet	10	4202.35	1206.26	1620.67	1400.7833333333335
-Manufacturer#4	almond antique violet mint lemon	39	6047.27	1206.26	1844.92	1511.8175
-Manufacturer#4	almond aquamarine floral ivory bisque	27	7337.620000000001	1206.26	1844.92	1467.5240000000001
-Manufacturer#4	almond aquamarine yellow dodger mint	7	5716.950000000001	1206.26	1844.92	1429.2375000000002
-Manufacturer#4	almond azure aquamarine papaya violet	12	4341.530000000001	1206.26	1844.92	1447.176666666667
-Manufacturer#5	almond antique blue firebrick mint	31	5190.08	1611.66	1789.69	1730.0266666666666
-Manufacturer#5	almond antique medium spring khaki	6	6208.18	1018.1	1789.69	1552.045
-Manufacturer#5	almond antique sky peru orange	2	7672.66	1018.1	1789.69	1534.532
-Manufacturer#5	almond aquamarine dodger light gainsboro	46	5882.969999999999	1018.1	1788.73	1470.7424999999998
-Manufacturer#5	almond azure blanched chiffon midnight	23	4271.3099999999995	1018.1	1788.73	1423.7699999999998
+Manufacturer#3	almond antique metallic orange dim	19	7532.61	1190.27	1922.98	1506.52
+Manufacturer#3	almond antique misty red olive	1	5860.93	1190.27	1922.98	1465.23
+Manufacturer#3	almond antique olive coral navajo	45	4670.66	1337.29	1922.98	1556.89
+Manufacturer#4	almond antique gainsboro frosted violet	10	4202.35	1206.26	1620.67	1400.78
+Manufacturer#4	almond antique violet mint lemon	39	6047.27	1206.26	1844.92	1511.82
+Manufacturer#4	almond aquamarine floral ivory bisque	27	7337.62	1206.26	1844.92	1467.52
+Manufacturer#4	almond aquamarine yellow dodger mint	7	5716.95	1206.26	1844.92	1429.24
+Manufacturer#4	almond azure aquamarine papaya violet	12	4341.53	1206.26	1844.92	1447.18
+Manufacturer#5	almond antique blue firebrick mint	31	5190.08	1611.66	1789.69	1730.03
+Manufacturer#5	almond antique medium spring khaki	6	6208.18	1018.1	1789.69	1552.05
+Manufacturer#5	almond antique sky peru orange	2	7672.66	1018.1	1789.69	1534.53
+Manufacturer#5	almond aquamarine dodger light gainsboro	46	5882.97	1018.1	1788.73	1470.74
+Manufacturer#5	almond azure blanched chiffon midnight	23	4271.31	1018.1	1788.73	1423.77
 PREHOOK: query: -- 19. testUDAFsWithGBY
 select  p_mfgr,p_name, p_size, p_retailprice, 
-sum(p_retailprice) over w1 as s, 
+round(sum(p_retailprice) over w1,2) as s,
 min(p_retailprice) as mi ,
 max(p_retailprice) as ma ,
-avg(p_retailprice) over w1 as ag
+round(avg(p_retailprice) over w1,2) as ag
 from part
 group by p_mfgr,p_name, p_size, p_retailprice
 window w1 as (distribute by p_mfgr sort by p_mfgr, p_name rows between 2 preceding and 2 following)
@@ -845,41 +845,41 @@ PREHOOK: Input: default@part
 #### A masked pattern was here ####
 POSTHOOK: query: -- 19. testUDAFsWithGBY
 select  p_mfgr,p_name, p_size, p_retailprice, 
-sum(p_retailprice) over w1 as s, 
+round(sum(p_retailprice) over w1,2) as s,
 min(p_retailprice) as mi ,
 max(p_retailprice) as ma ,
-avg(p_retailprice) over w1 as ag
+round(avg(p_retailprice) over w1,2) as ag
 from part
 group by p_mfgr,p_name, p_size, p_retailprice
 window w1 as (distribute by p_mfgr sort by p_mfgr, p_name rows between 2 preceding and 2 following)
 POSTHOOK: type: QUERY
 POSTHOOK: Input: default@part
 #### A masked pattern was here ####
-Manufacturer#1	almond antique burnished rose metallic	2	1173.15	4529.5	1173.15	1173.15	1509.8333333333333
+Manufacturer#1	almond antique burnished rose metallic	2	1173.15	4529.5	1173.15	1173.15	1509.83
 Manufacturer#1	almond antique chartreuse lavender yellow	34	1753.76	5943.92	1753.76	1753.76	1485.98
-Manufacturer#1	almond antique salmon chartreuse burlywood	6	1602.59	7576.58	1602.59	1602.59	1515.316
-Manufacturer#1	almond aquamarine burnished black steel	28	1414.42	6403.43	1414.42	1414.42	1600.8575
+Manufacturer#1	almond antique salmon chartreuse burlywood	6	1602.59	7576.58	1602.59	1602.59	1515.32
+Manufacturer#1	almond aquamarine burnished black steel	28	1414.42	6403.43	1414.42	1414.42	1600.86
 Manufacturer#1	almond aquamarine pink moccasin thistle	42	1632.66	4649.67	1632.66	1632.66	1549.89
-Manufacturer#2	almond antique violet chocolate turquoise	14	1690.68	5523.360000000001	1690.68	1690.68	1841.1200000000001
-Manufacturer#2	almond antique violet turquoise frosted	40	1800.7	7222.02	1800.7	1800.7	1805.505
-Manufacturer#2	almond aquamarine midnight light salmon	2	2031.98	8923.62	2031.98	2031.98	1784.7240000000002
-Manufacturer#2	almond aquamarine rose maroon antique	25	1698.66	7232.9400000000005	1698.66	1698.66	1808.2350000000001
-Manufacturer#2	almond aquamarine sandy cyan gainsboro	18	1701.6	5432.240000000001	1701.6	1701.6	1810.746666666667
-Manufacturer#3	almond antique chartreuse khaki white	17	1671.68	4272.34	1671.68	1671.68	1424.1133333333335
+Manufacturer#2	almond antique violet chocolate turquoise	14	1690.68	5523.36	1690.68	1690.68	1841.12
+Manufacturer#2	almond antique violet turquoise frosted	40	1800.7	7222.02	1800.7	1800.7	1805.51
+Manufacturer#2	almond aquamarine midnight light salmon	2	2031.98	8923.62	2031.98	2031.98	1784.72
+Manufacturer#2	almond aquamarine rose maroon antique	25	1698.66	7232.94	1698.66	1698.66	1808.24
+Manufacturer#2	almond aquamarine sandy cyan gainsboro	18	1701.6	5432.24	1701.6	1701.6	1810.75
+Manufacturer#3	almond antique chartreuse khaki white	17	1671.68	4272.34	1671.68	1671.68	1424.11
 Manufacturer#3	almond antique forest lavender goldenrod	14	1190.27	6195.32	1190.27	1190.27	1548.83
-Manufacturer#3	almond antique metallic orange dim	19	1410.39	7532.61	1410.39	1410.39	1506.522
-Manufacturer#3	almond antique misty red olive	1	1922.98	5860.929999999999	1922.98	1922.98	1465.2324999999998
-Manufacturer#3	almond antique olive coral navajo	45	1337.29	4670.66	1337.29	1337.29	1556.8866666666665
-Manufacturer#4	almond antique gainsboro frosted violet	10	1620.67	4202.35	1620.67	1620.67	1400.7833333333335
-Manufacturer#4	almond antique violet mint lemon	39	1375.42	6047.27	1375.42	1375.42	1511.8175
-Manufacturer#4	almond aquamarine floral ivory bisque	27	1206.26	7337.620000000001	1206.26	1206.26	1467.5240000000001
-Manufacturer#4	almond aquamarine yellow dodger mint	7	1844.92	5716.950000000001	1844.92	1844.92	1429.2375000000002
-Manufacturer#4	almond azure aquamarine papaya violet	12	1290.35	4341.530000000001	1290.35	1290.35	1447.176666666667
-Manufacturer#5	almond antique blue firebrick mint	31	1789.69	5190.08	1789.69	1789.69	1730.0266666666666
-Manufacturer#5	almond antique medium spring khaki	6	1611.66	6208.18	1611.66	1611.66	1552.045
-Manufacturer#5	almond antique sky peru orange	2	1788.73	7672.66	1788.73	1788.73	1534.532
-Manufacturer#5	almond aquamarine dodger light gainsboro	46	1018.1	5882.969999999999	1018.1	1018.1	1470.7424999999998
-Manufacturer#5	almond azure blanched chiffon midnight	23	1464.48	4271.3099999999995	1464.48	1464.48	1423.7699999999998
+Manufacturer#3	almond antique metallic orange dim	19	1410.39	7532.61	1410.39	1410.39	1506.52
+Manufacturer#3	almond antique misty red olive	1	1922.98	5860.93	1922.98	1922.98	1465.23
+Manufacturer#3	almond antique olive coral navajo	45	1337.29	4670.66	1337.29	1337.29	1556.89
+Manufacturer#4	almond antique gainsboro frosted violet	10	1620.67	4202.35	1620.67	1620.67	1400.78
+Manufacturer#4	almond antique violet mint lemon	39	1375.42	6047.27	1375.42	1375.42	1511.82
+Manufacturer#4	almond aquamarine floral ivory bisque	27	1206.26	7337.62	1206.26	1206.26	1467.52
+Manufacturer#4	almond aquamarine yellow dodger mint	7	1844.92	5716.95	1844.92	1844.92	1429.24
+Manufacturer#4	almond azure aquamarine papaya violet	12	1290.35	4341.53	1290.35	1290.35	1447.18
+Manufacturer#5	almond antique blue firebrick mint	31	1789.69	5190.08	1789.69	1789.69	1730.03
+Manufacturer#5	almond antique medium spring khaki	6	1611.66	6208.18	1611.66	1611.66	1552.05
+Manufacturer#5	almond antique sky peru orange	2	1788.73	7672.66	1788.73	1788.73	1534.53
+Manufacturer#5	almond aquamarine dodger light gainsboro	46	1018.1	5882.97	1018.1	1018.1	1470.74
+Manufacturer#5	almond azure blanched chiffon midnight	23	1464.48	4271.31	1464.48	1464.48	1423.77
 PREHOOK: query: -- 20. testSTATs
 select  p_mfgr,p_name, p_size, 
 stddev(p_retailprice) over w1 as sdev, 
@@ -1073,7 +1073,7 @@ Manufacturer#5	Brand#53	2806.83	7672.66
 PREHOOK: query: -- 23. testCreateViewWithWindowingQuery
 create view IF NOT EXISTS mfgr_brand_price_view as 
 select p_mfgr, p_brand, 
-sum(p_retailprice) over w1  as s
+round(sum(p_retailprice) over w1,2) as s
 from part 
 window w1 as (distribute by p_mfgr sort by p_name rows between 2 preceding and current row)
 PREHOOK: type: CREATEVIEW
@@ -1083,7 +1083,7 @@ PREHOOK: Output: default@mfgr_brand_price_view
 POSTHOOK: query: -- 23. testCreateViewWithWindowingQuery
 create view IF NOT EXISTS mfgr_brand_price_view as 
 select p_mfgr, p_brand, 
-sum(p_retailprice) over w1  as s
+round(sum(p_retailprice) over w1,2) as s
 from part 
 window w1 as (distribute by p_mfgr sort by p_name rows between 2 preceding and current row)
 POSTHOOK: type: CREATEVIEW
@@ -1101,29 +1101,29 @@ POSTHOOK: Input: default@mfgr_brand_price_view
 POSTHOOK: Input: default@part
 #### A masked pattern was here ####
 Manufacturer#1	Brand#12	4100.06
-Manufacturer#1	Brand#12	4649.670000000001
+Manufacturer#1	Brand#12	4649.67
 Manufacturer#1	Brand#12	4770.77
 Manufacturer#1	Brand#14	1173.15
 Manufacturer#1	Brand#14	2346.3
 Manufacturer#1	Brand#15	4529.5
 Manufacturer#2	Brand#22	1690.68
 Manufacturer#2	Brand#22	3491.38
-Manufacturer#2	Brand#23	5523.360000000001
+Manufacturer#2	Brand#23	5523.36
 Manufacturer#2	Brand#24	5531.34
-Manufacturer#2	Brand#25	5432.240000000001
+Manufacturer#2	Brand#25	5432.24
 Manufacturer#3	Brand#31	1671.68
 Manufacturer#3	Brand#32	4272.34
-Manufacturer#3	Brand#32	4523.639999999999
+Manufacturer#3	Brand#32	4523.64
 Manufacturer#3	Brand#34	4670.66
 Manufacturer#3	Brand#35	2861.95
 Manufacturer#4	Brand#41	1620.67
-Manufacturer#4	Brand#41	4341.530000000001
+Manufacturer#4	Brand#41	4341.53
 Manufacturer#4	Brand#41	4426.6
 Manufacturer#4	Brand#42	2996.09
 Manufacturer#4	Brand#42	4202.35
-Manufacturer#5	Brand#51	3401.3500000000004
+Manufacturer#5	Brand#51	3401.35
 Manufacturer#5	Brand#52	1789.69
-Manufacturer#5	Brand#52	4271.3099999999995
+Manufacturer#5	Brand#52	4271.31
 Manufacturer#5	Brand#53	4418.49
 Manufacturer#5	Brand#53	5190.08
 PREHOOK: query: -- 24. testLateralViews
@@ -1293,7 +1293,7 @@ INSERT OVERWRITE TABLE part_1
 select p_mfgr, p_name, p_size, 
 rank() over(distribute by p_mfgr sort by p_name ) as r, 
 dense_rank() over(distribute by p_mfgr sort by p_name ) as dr, 
-sum(p_retailprice) over (distribute by p_mfgr sort by p_name rows between unbounded preceding and current row)  as s
+round(sum(p_retailprice) over (distribute by p_mfgr sort by p_name rows between unbounded preceding and current row),2) as s
 INSERT OVERWRITE TABLE part_2 
 select  p_mfgr,p_name, p_size,  
 rank() over(distribute by p_mfgr sort by p_name) as r, 
@@ -1318,7 +1318,7 @@ INSERT OVERWRITE TABLE part_1
 select p_mfgr, p_name, p_size, 
 rank() over(distribute by p_mfgr sort by p_name ) as r, 
 dense_rank() over(distribute by p_mfgr sort by p_name ) as dr, 
-sum(p_retailprice) over (distribute by p_mfgr sort by p_name rows between unbounded preceding and current row)  as s
+round(sum(p_retailprice) over (distribute by p_mfgr sort by p_name rows between unbounded preceding and current row),2) as s
 INSERT OVERWRITE TABLE part_2 
 select  p_mfgr,p_name, p_size,  
 rank() over(distribute by p_mfgr sort by p_name) as r, 
@@ -1369,12 +1369,12 @@ POSTHOOK: Input: default@part_1
 Manufacturer#1	almond antique burnished rose metallic	2	1	1	1173.15
 Manufacturer#1	almond antique burnished rose metallic	2	1	1	2346.3
 Manufacturer#1	almond antique chartreuse lavender yellow	34	3	2	4100.06
-Manufacturer#1	almond antique salmon chartreuse burlywood	6	4	3	5702.650000000001
-Manufacturer#1	almond aquamarine burnished black steel	28	5	4	7117.070000000001
-Manufacturer#1	almond aquamarine pink moccasin thistle	42	6	5	8749.730000000001
+Manufacturer#1	almond antique salmon chartreuse burlywood	6	4	3	5702.65
+Manufacturer#1	almond aquamarine burnished black steel	28	5	4	7117.07
+Manufacturer#1	almond aquamarine pink moccasin thistle	42	6	5	8749.73
 Manufacturer#2	almond antique violet chocolate turquoise	14	1	1	1690.68
 Manufacturer#2	almond antique violet turquoise frosted	40	2	2	3491.38
-Manufacturer#2	almond aquamarine midnight light salmon	2	3	3	5523.360000000001
+Manufacturer#2	almond aquamarine midnight light salmon	2	3	3	5523.36
 Manufacturer#2	almond aquamarine rose maroon antique	25	4	4	7222.02
 Manufacturer#2	almond aquamarine sandy cyan gainsboro	18	5	5	8923.62
 Manufacturer#3	almond antique chartreuse khaki white	17	1	1	1671.68
@@ -1386,9 +1386,9 @@ Manufacturer#4	almond antique gainsboro frosted violet	10	1	1	1620.67
 Manufacturer#4	almond antique violet mint lemon	39	2	2	2996.09
 Manufacturer#4	almond aquamarine floral ivory bisque	27	3	3	4202.35
 Manufacturer#4	almond aquamarine yellow dodger mint	7	4	4	6047.27
-Manufacturer#4	almond azure aquamarine papaya violet	12	5	5	7337.620000000001
+Manufacturer#4	almond azure aquamarine papaya violet	12	5	5	7337.62
 Manufacturer#5	almond antique blue firebrick mint	31	1	1	1789.69
-Manufacturer#5	almond antique medium spring khaki	6	2	2	3401.3500000000004
+Manufacturer#5	almond antique medium spring khaki	6	2	2	3401.35
 Manufacturer#5	almond antique sky peru orange	2	3	3	5190.08
 Manufacturer#5	almond aquamarine dodger light gainsboro	46	4	4	6208.18
 Manufacturer#5	almond azure blanched chiffon midnight	23	5	5	7672.66
@@ -1887,8 +1887,9 @@ window w1 as (distribute by p_mfgr sort by p_name rows between 2 preceding and 2
 POSTHOOK: type: QUERY
 POSTHOOK: Input: default@part
 #### A masked pattern was here ####
-Manufacturer#1	almond antique burnished rose metallic	2	42
-Manufacturer#1	almond antique chartreuse lavender yellow	34	70
+Manufacturer#1	almond antique burnished rose metallic	2	38
+Manufacturer#1	almond antique burnished rose metallic	2	44
+Manufacturer#1	almond antique chartreuse lavender yellow	34	72
 Manufacturer#1	almond antique salmon chartreuse burlywood	6	112
 Manufacturer#1	almond aquamarine burnished black steel	28	110
 Manufacturer#1	almond aquamarine pink moccasin thistle	42	76
@@ -2002,7 +2003,7 @@ Manufacturer#5	7672.66	1018.1	1789.69	1534.53	5
 Manufacturer#5	7672.66	1018.1	1789.69	1534.53	5
 PREHOOK: query: -- 38. testPartitioningVariousForms2
 select p_mfgr, p_name, p_size,
-sum(p_retailprice) over (partition by p_mfgr, p_name order by p_mfgr, p_name rows between unbounded preceding and current row) as s1,
+round(sum(p_retailprice) over (partition by p_mfgr, p_name order by p_mfgr, p_name rows between unbounded preceding and current row),2) as s1,
 min(p_retailprice) over (distribute by p_mfgr, p_name sort by p_mfgr, p_name rows between unbounded preceding and current row) as s2,
 max(p_retailprice) over (partition by p_mfgr, p_name order by p_name) as s3
 from part
@@ -2011,7 +2012,7 @@ PREHOOK: Input: default@part
 #### A masked pattern was here ####
 POSTHOOK: query: -- 38. testPartitioningVariousForms2
 select p_mfgr, p_name, p_size,
-sum(p_retailprice) over (partition by p_mfgr, p_name order by p_mfgr, p_name rows between unbounded preceding and current row) as s1,
+round(sum(p_retailprice) over (partition by p_mfgr, p_name order by p_mfgr, p_name rows between unbounded preceding and current row),2) as s1,
 min(p_retailprice) over (distribute by p_mfgr, p_name sort by p_mfgr, p_name rows between unbounded preceding and current row) as s2,
 max(p_retailprice) over (partition by p_mfgr, p_name order by p_name) as s3
 from part
@@ -2086,14 +2087,14 @@ Manufacturer#5	SMALL PLATED BRASS	MALL PLATED BRASS	4
 Manufacturer#5	STANDARD BURNISHED TIN	TANDARD BURNISHED TIN	5
 PREHOOK: query: -- 40. testNoBetweenForRows
 select p_mfgr, p_name, p_size,
-    sum(p_retailprice) over (distribute by p_mfgr sort by p_name rows unbounded preceding) as s1
+    round(sum(p_retailprice) over (distribute by p_mfgr sort by p_name rows unbounded preceding),2) as s1
      from part
 PREHOOK: type: QUERY
 PREHOOK: Input: default@part
 #### A masked pattern was here ####
 POSTHOOK: query: -- 40. testNoBetweenForRows
 select p_mfgr, p_name, p_size,
-    sum(p_retailprice) over (distribute by p_mfgr sort by p_name rows unbounded preceding) as s1
+    round(sum(p_retailprice) over (distribute by p_mfgr sort by p_name rows unbounded preceding),2) as s1
      from part
 POSTHOOK: type: QUERY
 POSTHOOK: Input: default@part
@@ -2101,12 +2102,12 @@ POSTHOOK: Input: default@part
 Manufacturer#1	almond antique burnished rose metallic	2	1173.15
 Manufacturer#1	almond antique burnished rose metallic	2	2346.3
 Manufacturer#1	almond antique chartreuse lavender yellow	34	4100.06
-Manufacturer#1	almond antique salmon chartreuse burlywood	6	5702.650000000001
-Manufacturer#1	almond aquamarine burnished black steel	28	7117.070000000001
-Manufacturer#1	almond aquamarine pink moccasin thistle	42	8749.730000000001
+Manufacturer#1	almond antique salmon chartreuse burlywood	6	5702.65
+Manufacturer#1	almond aquamarine burnished black steel	28	7117.07
+Manufacturer#1	almond aquamarine pink moccasin thistle	42	8749.73
 Manufacturer#2	almond antique violet chocolate turquoise	14	1690.68
 Manufacturer#2	almond antique violet turquoise frosted	40	3491.38
-Manufacturer#2	almond aquamarine midnight light salmon	2	5523.360000000001
+Manufacturer#2	almond aquamarine midnight light salmon	2	5523.36
 Manufacturer#2	almond aquamarine rose maroon antique	25	7222.02
 Manufacturer#2	almond aquamarine sandy cyan gainsboro	18	8923.62
 Manufacturer#3	almond antique chartreuse khaki white	17	1671.68
@@ -2118,32 +2119,32 @@ Manufacturer#4	almond antique gainsboro frosted violet	10	1620.67
 Manufacturer#4	almond antique violet mint lemon	39	2996.09
 Manufacturer#4	almond aquamarine floral ivory bisque	27	4202.35
 Manufacturer#4	almond aquamarine yellow dodger mint	7	6047.27
-Manufacturer#4	almond azure aquamarine papaya violet	12	7337.620000000001
+Manufacturer#4	almond azure aquamarine papaya violet	12	7337.62
 Manufacturer#5	almond antique blue firebrick mint	31	1789.69
-Manufacturer#5	almond antique medium spring khaki	6	3401.3500000000004
+Manufacturer#5	almond antique medium spring khaki	6	3401.35
 Manufacturer#5	almond antique sky peru orange	2	5190.08
 Manufacturer#5	almond aquamarine dodger light gainsboro	46	6208.18
 Manufacturer#5	almond azure blanched chiffon midnight	23	7672.66
 PREHOOK: query: -- 41. testNoBetweenForRange
 select p_mfgr, p_name, p_size,
-    sum(p_retailprice) over (distribute by p_mfgr sort by p_size range unbounded preceding) as s1
+    round(sum(p_retailprice) over (distribute by p_mfgr sort by p_size range unbounded preceding),2) as s1
      from part
 PREHOOK: type: QUERY
 PREHOOK: Input: default@part
 #### A masked pattern was here ####
 POSTHOOK: query: -- 41. testNoBetweenForRange
 select p_mfgr, p_name, p_size,
-    sum(p_retailprice) over (distribute by p_mfgr sort by p_size range unbounded preceding) as s1
+    round(sum(p_retailprice) over (distribute by p_mfgr sort by p_size range unbounded preceding),2) as s1
      from part
 POSTHOOK: type: QUERY
 POSTHOOK: Input: default@part
 #### A masked pattern was here ####
 Manufacturer#1	almond antique burnished rose metallic	2	2346.3
 Manufacturer#1	almond antique burnished rose metallic	2	2346.3
-Manufacturer#1	almond antique chartreuse lavender yellow	34	7117.070000000001
-Manufacturer#1	almond antique salmon chartreuse burlywood	6	3948.8900000000003
+Manufacturer#1	almond antique chartreuse lavender yellow	34	7117.07
+Manufacturer#1	almond antique salmon chartreuse burlywood	6	3948.89
 Manufacturer#1	almond aquamarine burnished black steel	28	5363.31
-Manufacturer#1	almond aquamarine pink moccasin thistle	42	8749.730000000001
+Manufacturer#1	almond aquamarine pink moccasin thistle	42	8749.73
 Manufacturer#2	almond antique violet chocolate turquoise	14	3722.66
 Manufacturer#2	almond antique violet turquoise frosted	40	8923.62
 Manufacturer#2	almond aquamarine midnight light salmon	2	2031.98
@@ -2151,97 +2152,97 @@ Manufacturer#2	almond aquamarine rose maroon antique	25	7122.92
 Manufacturer#2	almond aquamarine sandy cyan gainsboro	18	5424.26
 Manufacturer#3	almond antique chartreuse khaki white	17	4784.93
 Manufacturer#3	almond antique forest lavender goldenrod	14	3113.25
-Manufacturer#3	almond antique metallic orange dim	19	6195.320000000001
+Manufacturer#3	almond antique metallic orange dim	19	6195.32
 Manufacturer#3	almond antique misty red olive	1	1922.98
-Manufacturer#3	almond antique olive coral navajo	45	7532.610000000001
+Manufacturer#3	almond antique olive coral navajo	45	7532.61
 Manufacturer#4	almond antique gainsboro frosted violet	10	3465.59
-Manufacturer#4	almond antique violet mint lemon	39	7337.620000000001
-Manufacturer#4	almond aquamarine floral ivory bisque	27	5962.200000000001
+Manufacturer#4	almond antique violet mint lemon	39	7337.62
+Manufacturer#4	almond aquamarine floral ivory bisque	27	5962.2
 Manufacturer#4	almond aquamarine yellow dodger mint	7	1844.92
-Manufacturer#4	almond azure aquamarine papaya violet	12	4755.9400000000005
-Manufacturer#5	almond antique blue firebrick mint	31	6654.560000000001
-Manufacturer#5	almond antique medium spring khaki	6	3400.3900000000003
+Manufacturer#4	almond azure aquamarine papaya violet	12	4755.94
+Manufacturer#5	almond antique blue firebrick mint	31	6654.56
+Manufacturer#5	almond antique medium spring khaki	6	3400.39
 Manufacturer#5	almond antique sky peru orange	2	1788.73
-Manufacturer#5	almond aquamarine dodger light gainsboro	46	7672.660000000002
-Manufacturer#5	almond azure blanched chiffon midnight	23	4864.870000000001
+Manufacturer#5	almond aquamarine dodger light gainsboro	46	7672.66
+Manufacturer#5	almond azure blanched chiffon midnight	23	4864.87
 PREHOOK: query: -- 42. testUnboundedFollowingForRows
 select p_mfgr, p_name, p_size,
-    sum(p_retailprice) over (distribute by p_mfgr sort by p_name rows between current row and unbounded following) as s1
+    round(sum(p_retailprice) over (distribute by p_mfgr sort by p_name rows between current row and unbounded following),2) as s1
     from part
 PREHOOK: type: QUERY
 PREHOOK: Input: default@part
 #### A masked pattern was here ####
 POSTHOOK: query: -- 42. testUnboundedFollowingForRows
 select p_mfgr, p_name, p_size,
-    sum(p_retailprice) over (distribute by p_mfgr sort by p_name rows between current row and unbounded following) as s1
+    round(sum(p_retailprice) over (distribute by p_mfgr sort by p_name rows between current row and unbounded following),2) as s1
     from part
 POSTHOOK: type: QUERY
 POSTHOOK: Input: default@part
 #### A masked pattern was here ####
 Manufacturer#1	almond antique burnished rose metallic	2	7576.58
-Manufacturer#1	almond antique burnished rose metallic	2	8749.730000000001
+Manufacturer#1	almond antique burnished rose metallic	2	8749.73
 Manufacturer#1	almond antique chartreuse lavender yellow	34	6403.43
 Manufacturer#1	almond antique salmon chartreuse burlywood	6	4649.67
 Manufacturer#1	almond aquamarine burnished black steel	28	3047.08
 Manufacturer#1	almond aquamarine pink moccasin thistle	42	1632.66
 Manufacturer#2	almond antique violet chocolate turquoise	14	8923.62
-Manufacturer#2	almond antique violet turquoise frosted	40	7232.9400000000005
+Manufacturer#2	almond antique violet turquoise frosted	40	7232.94
 Manufacturer#2	almond aquamarine midnight light salmon	2	5432.24
 Manufacturer#2	almond aquamarine rose maroon antique	25	3400.26
 Manufacturer#2	almond aquamarine sandy cyan gainsboro	18	1701.6
 Manufacturer#3	almond antique chartreuse khaki white	17	7532.61
-Manufacturer#3	almond antique forest lavender goldenrod	14	5860.929999999999
+Manufacturer#3	almond antique forest lavender goldenrod	14	5860.93
 Manufacturer#3	almond antique metallic orange dim	19	4670.66
 Manufacturer#3	almond antique misty red olive	1	3260.27
 Manufacturer#3	almond antique olive coral navajo	45	1337.29
-Manufacturer#4	almond antique gainsboro frosted violet	10	7337.620000000001
-Manufacturer#4	almond antique violet mint lemon	39	5716.950000000001
-Manufacturer#4	almond aquamarine floral ivory bisque	27	4341.530000000001
+Manufacturer#4	almond antique gainsboro frosted violet	10	7337.62
+Manufacturer#4	almond antique violet mint lemon	39	5716.95
+Manufacturer#4	almond aquamarine floral ivory bisque	27	4341.53
 Manufacturer#4	almond aquamarine yellow dodger mint	7	3135.27
 Manufacturer#4	almond azure aquamarine papaya violet	12	1290.35
 Manufacturer#5	almond antique blue firebrick mint	31	7672.66
-Manufacturer#5	almond antique medium spring khaki	6	5882.970000000001
-Manufacturer#5	almond antique sky peru orange	2	4271.3099999999995
+Manufacturer#5	almond antique medium spring khaki	6	5882.97
+Manufacturer#5	almond antique sky peru orange	2	4271.31
 Manufacturer#5	almond aquamarine dodger light gainsboro	46	2482.58
 Manufacturer#5	almond azure blanched chiffon midnight	23	1464.48
 PREHOOK: query: -- 43. testUnboundedFollowingForRange
 select p_mfgr, p_name, p_size,
-    sum(p_retailprice) over (distribute by p_mfgr sort by p_size range between current row and unbounded following) as s1
+    round(sum(p_retailprice) over (distribute by p_mfgr sort by p_size range between current row and unbounded following),2) as s1
     from part
 PREHOOK: type: QUERY
 PREHOOK: Input: default@part
 #### A masked pattern was here ####
 POSTHOOK: query: -- 43. testUnboundedFollowingForRange
 select p_mfgr, p_name, p_size,
-    sum(p_retailprice) over (distribute by p_mfgr sort by p_size range between current row and unbounded following) as s1
+    round(sum(p_retailprice) over (distribute by p_mfgr sort by p_size range between current row and unbounded following),2) as s1
     from part
 POSTHOOK: type: QUERY
 POSTHOOK: Input: default@part
 #### A masked pattern was here ####
-Manufacturer#1	almond antique burnished rose metallic	2	8749.730000000001
-Manufacturer#1	almond antique burnished rose metallic	2	8749.730000000001
+Manufacturer#1	almond antique burnished rose metallic	2	8749.73
+Manufacturer#1	almond antique burnished rose metallic	2	8749.73
 Manufacturer#1	almond antique chartreuse lavender yellow	34	3386.42
 Manufacturer#1	almond antique salmon chartreuse burlywood	6	6403.43
 Manufacturer#1	almond aquamarine burnished black steel	28	4800.84
 Manufacturer#1	almond aquamarine pink moccasin thistle	42	1632.66
-Manufacturer#2	almond antique violet chocolate turquoise	14	6891.639999999999
+Manufacturer#2	almond antique violet chocolate turquoise	14	6891.64
 Manufacturer#2	almond antique violet turquoise frosted	40	1800.7
 Manufacturer#2	almond aquamarine midnight light salmon	2	8923.62
 Manufacturer#2	almond aquamarine rose maroon antique	25	3499.36
 Manufacturer#2	almond aquamarine sandy cyan gainsboro	18	5200.96
-Manufacturer#3	almond antique chartreuse khaki white	17	4419.360000000001
+Manufacturer#3	almond antique chartreuse khaki white	17	4419.36
 Manufacturer#3	almond antique forest lavender goldenrod	14	5609.63
-Manufacturer#3	almond antique metallic orange dim	19	2747.6800000000003
-Manufacturer#3	almond antique misty red olive	1	7532.610000000001
+Manufacturer#3	almond antique metallic orange dim	19	2747.68
+Manufacturer#3	almond antique misty red olive	1	7532.61
 Manufacturer#3	almond antique olive coral navajo	45	1337.29
 Manufacturer#4	almond antique gainsboro frosted violet	10	5492.7
 Manufacturer#4	almond antique violet mint lemon	39	1375.42
-Manufacturer#4	almond aquamarine floral ivory bisque	27	2581.6800000000003
-Manufacturer#4	almond aquamarine yellow dodger mint	7	7337.620000000001
-Manufacturer#4	almond azure aquamarine papaya violet	12	3872.0299999999997
+Manufacturer#4	almond aquamarine floral ivory bisque	27	2581.68
+Manufacturer#4	almond aquamarine yellow dodger mint	7	7337.62
+Manufacturer#4	almond azure aquamarine papaya violet	12	3872.03
 Manufacturer#5	almond antique blue firebrick mint	31	2807.79
 Manufacturer#5	almond antique medium spring khaki	6	5883.93
-Manufacturer#5	almond antique sky peru orange	2	7672.660000000002
+Manufacturer#5	almond antique sky peru orange	2	7672.66
 Manufacturer#5	almond aquamarine dodger light gainsboro	46	1018.1
 Manufacturer#5	almond azure blanched chiffon midnight	23	4272.27
 PREHOOK: query: -- 44. testOverNoPartitionSingleAggregate
@@ -2303,27 +2304,27 @@ POSTHOOK: type: QUERY
 POSTHOOK: Input: default@part
 #### A masked pattern was here ####
 PREHOOK: query: -- 46. window sz is same as partition sz
-select p_retailprice, avg(p_retailprice) over (partition by p_mfgr order by p_name rows between current row and 6 following), 
-sum(p_retailprice) over (partition by p_mfgr order by p_name rows between current row and 6 following) 
+select p_retailprice, round(avg(p_retailprice) over (partition by p_mfgr order by p_name rows between current row and 6 following),2), 
+round(sum(p_retailprice) over (partition by p_mfgr order by p_name rows between current row and 6 following),2) 
 from part 
 where p_mfgr='Manufacturer#1'
 PREHOOK: type: QUERY
 PREHOOK: Input: default@part
 #### A masked pattern was here ####
 POSTHOOK: query: -- 46. window sz is same as partition sz
-select p_retailprice, avg(p_retailprice) over (partition by p_mfgr order by p_name rows between current row and 6 following), 
-sum(p_retailprice) over (partition by p_mfgr order by p_name rows between current row and 6 following) 
+select p_retailprice, round(avg(p_retailprice) over (partition by p_mfgr order by p_name rows between current row and 6 following),2), 
+round(sum(p_retailprice) over (partition by p_mfgr order by p_name rows between current row and 6 following),2) 
 from part 
 where p_mfgr='Manufacturer#1'
 POSTHOOK: type: QUERY
 POSTHOOK: Input: default@part
 #### A masked pattern was here ####
-1173.15	1458.2883333333336	8749.730000000001
-1173.15	1515.3160000000003	7576.580000000002
-1414.42	1523.5400000000004	3047.080000000001
-1602.59	1549.8900000000003	4649.670000000001
-1632.66	1632.6600000000008	1632.6600000000008
-1753.76	1600.8575000000003	6403.430000000001
+1173.15	1458.29	8749.73
+1173.15	1515.32	7576.58
+1414.42	1523.54	3047.08
+1602.59	1549.89	4649.67
+1632.66	1632.66	1632.66
+1753.76	1600.86	6403.43
 PREHOOK: query: -- 47. empty partition
 select sum(p_size) over (partition by p_mfgr )
 from part where p_mfgr = 'm1'

http://git-wip-us.apache.org/repos/asf/hive/blob/a28b28f3/ql/src/test/results/clientpositive/leadlag.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/leadlag.q.out b/ql/src/test/results/clientpositive/leadlag.q.out
index 86718ae..77eaeff 100644
--- a/ql/src/test/results/clientpositive/leadlag.q.out
+++ b/ql/src/test/results/clientpositive/leadlag.q.out
@@ -200,28 +200,28 @@ Manufacturer#1	almond antique burnished rose metallic	2	32
 Manufacturer#1	almond antique burnished rose metallic	2	4
 Manufacturer#1	almond antique chartreuse lavender yellow	34	26
 Manufacturer#1	almond antique salmon chartreuse burlywood	6	40
-Manufacturer#1	almond aquamarine burnished black steel	28	8
-Manufacturer#1	almond aquamarine pink moccasin thistle	42	36
+Manufacturer#1	almond aquamarine burnished black steel	28	40
+Manufacturer#1	almond aquamarine pink moccasin thistle	42	8
 Manufacturer#2	almond antique violet chocolate turquoise	14	-12
 Manufacturer#2	almond antique violet turquoise frosted	40	11
 Manufacturer#2	almond aquamarine midnight light salmon	2	4
-Manufacturer#2	almond aquamarine rose maroon antique	25	-22
-Manufacturer#2	almond aquamarine sandy cyan gainsboro	18	16
+Manufacturer#2	almond aquamarine rose maroon antique	25	4
+Manufacturer#2	almond aquamarine sandy cyan gainsboro	18	-22
 Manufacturer#3	almond antique chartreuse khaki white	17	2
 Manufacturer#3	almond antique forest lavender goldenrod	14	-16
 Manufacturer#3	almond antique metallic orange dim	19	28
-Manufacturer#3	almond antique misty red olive	1	31
-Manufacturer#3	almond antique olive coral navajo	45	26
+Manufacturer#3	almond antique misty red olive	1	28
+Manufacturer#3	almond antique olive coral navajo	45	31
 Manufacturer#4	almond antique gainsboro frosted violet	10	17
 Manufacturer#4	almond antique violet mint lemon	39	-3
 Manufacturer#4	almond aquamarine floral ivory bisque	27	2
-Manufacturer#4	almond aquamarine yellow dodger mint	7	-27
-Manufacturer#4	almond azure aquamarine papaya violet	12	-15
+Manufacturer#4	almond aquamarine yellow dodger mint	7	2
+Manufacturer#4	almond azure aquamarine papaya violet	12	-27
 Manufacturer#5	almond antique blue firebrick mint	31	-29
 Manufacturer#5	almond antique medium spring khaki	6	15
 Manufacturer#5	almond antique sky peru orange	2	-8
-Manufacturer#5	almond aquamarine dodger light gainsboro	46	17
-Manufacturer#5	almond azure blanched chiffon midnight	23	21
+Manufacturer#5	almond aquamarine dodger light gainsboro	46	-8
+Manufacturer#5	almond azure blanched chiffon midnight	23	17
 PREHOOK: query: -- 6. testRankInLead
 -- disable cbo because of CALCITE-653
 


[03/13] hive git commit: HIVE-15520: Improve the sum performance for Range based window (Aihua Xu, reviewed by Yongzhi Chen)

Posted by ai...@apache.org.
http://git-wip-us.apache.org/repos/asf/hive/blob/a28b28f3/ql/src/test/results/clientpositive/spark/windowing.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/spark/windowing.q.out b/ql/src/test/results/clientpositive/spark/windowing.q.out
index 72b2245..23f0b91 100644
--- a/ql/src/test/results/clientpositive/spark/windowing.q.out
+++ b/ql/src/test/results/clientpositive/spark/windowing.q.out
@@ -4,7 +4,7 @@ PREHOOK: query: -- SORT_QUERY_RESULTS
 select p_mfgr, p_name, p_size,
 rank() over(distribute by p_mfgr sort by p_name) as r,
 dense_rank() over(distribute by p_mfgr sort by p_name) as dr,
-sum(p_retailprice) over (distribute by p_mfgr sort by p_name rows between unbounded preceding and current row) as s1
+round(sum(p_retailprice) over (distribute by p_mfgr sort by p_name rows between unbounded preceding and current row),2) as s1
 from part
 PREHOOK: type: QUERY
 PREHOOK: Input: default@part
@@ -15,7 +15,7 @@ POSTHOOK: query: -- SORT_QUERY_RESULTS
 select p_mfgr, p_name, p_size,
 rank() over(distribute by p_mfgr sort by p_name) as r,
 dense_rank() over(distribute by p_mfgr sort by p_name) as dr,
-sum(p_retailprice) over (distribute by p_mfgr sort by p_name rows between unbounded preceding and current row) as s1
+round(sum(p_retailprice) over (distribute by p_mfgr sort by p_name rows between unbounded preceding and current row),2) as s1
 from part
 POSTHOOK: type: QUERY
 POSTHOOK: Input: default@part
@@ -23,12 +23,12 @@ POSTHOOK: Input: default@part
 Manufacturer#1	almond antique burnished rose metallic	2	1	1	1173.15
 Manufacturer#1	almond antique burnished rose metallic	2	1	1	2346.3
 Manufacturer#1	almond antique chartreuse lavender yellow	34	3	2	4100.06
-Manufacturer#1	almond antique salmon chartreuse burlywood	6	4	3	5702.650000000001
-Manufacturer#1	almond aquamarine burnished black steel	28	5	4	7117.070000000001
-Manufacturer#1	almond aquamarine pink moccasin thistle	42	6	5	8749.730000000001
+Manufacturer#1	almond antique salmon chartreuse burlywood	6	4	3	5702.65
+Manufacturer#1	almond aquamarine burnished black steel	28	5	4	7117.07
+Manufacturer#1	almond aquamarine pink moccasin thistle	42	6	5	8749.73
 Manufacturer#2	almond antique violet chocolate turquoise	14	1	1	1690.68
 Manufacturer#2	almond antique violet turquoise frosted	40	2	2	3491.38
-Manufacturer#2	almond aquamarine midnight light salmon	2	3	3	5523.360000000001
+Manufacturer#2	almond aquamarine midnight light salmon	2	3	3	5523.36
 Manufacturer#2	almond aquamarine rose maroon antique	25	4	4	7222.02
 Manufacturer#2	almond aquamarine sandy cyan gainsboro	18	5	5	8923.62
 Manufacturer#3	almond antique chartreuse khaki white	17	1	1	1671.68
@@ -40,9 +40,9 @@ Manufacturer#4	almond antique gainsboro frosted violet	10	1	1	1620.67
 Manufacturer#4	almond antique violet mint lemon	39	2	2	2996.09
 Manufacturer#4	almond aquamarine floral ivory bisque	27	3	3	4202.35
 Manufacturer#4	almond aquamarine yellow dodger mint	7	4	4	6047.27
-Manufacturer#4	almond azure aquamarine papaya violet	12	5	5	7337.620000000001
+Manufacturer#4	almond azure aquamarine papaya violet	12	5	5	7337.62
 Manufacturer#5	almond antique blue firebrick mint	31	1	1	1789.69
-Manufacturer#5	almond antique medium spring khaki	6	2	2	3401.3500000000004
+Manufacturer#5	almond antique medium spring khaki	6	2	2	3401.35
 Manufacturer#5	almond antique sky peru orange	2	3	3	5190.08
 Manufacturer#5	almond aquamarine dodger light gainsboro	46	4	4	6208.18
 Manufacturer#5	almond azure blanched chiffon midnight	23	5	5	7672.66
@@ -185,7 +185,7 @@ select p_mfgr, p_name,
 rank() over(distribute by p_mfgr sort by p_name) as r, 
 dense_rank() over(distribute by p_mfgr sort by p_name) as dr, 
 count(p_size) over(distribute by p_mfgr sort by p_name) as cd, 
-p_retailprice, sum(p_retailprice) over (distribute by p_mfgr sort by p_name rows between unbounded preceding and current row) as s1, 
+p_retailprice, round(sum(p_retailprice) over (distribute by p_mfgr sort by p_name rows between unbounded preceding and current row),2) as s1,
 p_size, p_size - lag(p_size,1,p_size) over(distribute by p_mfgr sort by p_name) as deltaSz 
 from part
 PREHOOK: type: QUERY
@@ -196,7 +196,7 @@ select p_mfgr, p_name,
 rank() over(distribute by p_mfgr sort by p_name) as r, 
 dense_rank() over(distribute by p_mfgr sort by p_name) as dr, 
 count(p_size) over(distribute by p_mfgr sort by p_name) as cd, 
-p_retailprice, sum(p_retailprice) over (distribute by p_mfgr sort by p_name rows between unbounded preceding and current row) as s1, 
+p_retailprice, round(sum(p_retailprice) over (distribute by p_mfgr sort by p_name rows between unbounded preceding and current row),2) as s1,
 p_size, p_size - lag(p_size,1,p_size) over(distribute by p_mfgr sort by p_name) as deltaSz 
 from part
 POSTHOOK: type: QUERY
@@ -205,12 +205,12 @@ POSTHOOK: Input: default@part
 Manufacturer#1	almond antique burnished rose metallic	1	1	2	1173.15	1173.15	2	0
 Manufacturer#1	almond antique burnished rose metallic	1	1	2	1173.15	2346.3	2	0
 Manufacturer#1	almond antique chartreuse lavender yellow	3	2	3	1753.76	4100.06	34	32
-Manufacturer#1	almond antique salmon chartreuse burlywood	4	3	4	1602.59	5702.650000000001	6	-28
-Manufacturer#1	almond aquamarine burnished black steel	5	4	5	1414.42	7117.070000000001	28	22
-Manufacturer#1	almond aquamarine pink moccasin thistle	6	5	6	1632.66	8749.730000000001	42	14
+Manufacturer#1	almond antique salmon chartreuse burlywood	4	3	4	1602.59	5702.65	6	-28
+Manufacturer#1	almond aquamarine burnished black steel	5	4	5	1414.42	7117.07	28	22
+Manufacturer#1	almond aquamarine pink moccasin thistle	6	5	6	1632.66	8749.73	42	14
 Manufacturer#2	almond antique violet chocolate turquoise	1	1	1	1690.68	1690.68	14	0
 Manufacturer#2	almond antique violet turquoise frosted	2	2	2	1800.7	3491.38	40	26
-Manufacturer#2	almond aquamarine midnight light salmon	3	3	3	2031.98	5523.360000000001	2	-38
+Manufacturer#2	almond aquamarine midnight light salmon	3	3	3	2031.98	5523.36	2	-38
 Manufacturer#2	almond aquamarine rose maroon antique	4	4	4	1698.66	7222.02	25	23
 Manufacturer#2	almond aquamarine sandy cyan gainsboro	5	5	5	1701.6	8923.62	18	-7
 Manufacturer#3	almond antique chartreuse khaki white	1	1	1	1671.68	1671.68	17	0
@@ -222,9 +222,9 @@ Manufacturer#4	almond antique gainsboro frosted violet	1	1	1	1620.67	1620.67	10
 Manufacturer#4	almond antique violet mint lemon	2	2	2	1375.42	2996.09	39	29
 Manufacturer#4	almond aquamarine floral ivory bisque	3	3	3	1206.26	4202.35	27	-12
 Manufacturer#4	almond aquamarine yellow dodger mint	4	4	4	1844.92	6047.27	7	-20
-Manufacturer#4	almond azure aquamarine papaya violet	5	5	5	1290.35	7337.620000000001	12	5
+Manufacturer#4	almond azure aquamarine papaya violet	5	5	5	1290.35	7337.62	12	5
 Manufacturer#5	almond antique blue firebrick mint	1	1	1	1789.69	1789.69	31	0
-Manufacturer#5	almond antique medium spring khaki	2	2	2	1611.66	3401.3500000000004	6	-25
+Manufacturer#5	almond antique medium spring khaki	2	2	2	1611.66	3401.35	6	-25
 Manufacturer#5	almond antique sky peru orange	3	3	3	1788.73	5190.08	2	-4
 Manufacturer#5	almond aquamarine dodger light gainsboro	4	4	4	1018.1	6208.18	46	44
 Manufacturer#5	almond azure blanched chiffon midnight	5	5	5	1464.48	7672.66	23	-23
@@ -234,7 +234,7 @@ from (select p_mfgr, p_name,
 rank() over(distribute by p_mfgr sort by p_name) as r, 
 dense_rank() over(distribute by p_mfgr sort by p_name) as dr, 
 count(p_size) over(distribute by p_mfgr sort by p_name) as cd, 
-p_retailprice, sum(p_retailprice) over (distribute by p_mfgr sort by p_name rows between unbounded preceding and current row) as s1, 
+p_retailprice, round(sum(p_retailprice) over (distribute by p_mfgr sort by p_name rows between unbounded preceding and current row),2) as s1,
 p_size, p_size - lag(p_size,1,p_size) over(distribute by p_mfgr sort by p_name) as deltaSz 
 from part 
 ) sub1
@@ -247,7 +247,7 @@ from (select p_mfgr, p_name,
 rank() over(distribute by p_mfgr sort by p_name) as r, 
 dense_rank() over(distribute by p_mfgr sort by p_name) as dr, 
 count(p_size) over(distribute by p_mfgr sort by p_name) as cd, 
-p_retailprice, sum(p_retailprice) over (distribute by p_mfgr sort by p_name rows between unbounded preceding and current row) as s1, 
+p_retailprice, round(sum(p_retailprice) over (distribute by p_mfgr sort by p_name rows between unbounded preceding and current row),2) as s1,
 p_size, p_size - lag(p_size,1,p_size) over(distribute by p_mfgr sort by p_name) as deltaSz 
 from part 
 ) sub1
@@ -262,29 +262,29 @@ POSTHOOK: Input: default@part
 1	1	2	2346.3	0
 2	2	2	2861.95	-3
 2	2	2	2996.09	29
-2	2	2	3401.3500000000004	-25
+2	2	2	3401.35	-25
 2	2	2	3491.38	26
 3	2	3	4100.06	32
 3	3	3	4202.35	-12
 3	3	3	4272.34	5
 3	3	3	5190.08	-4
-3	3	3	5523.360000000001	-38
-4	3	4	5702.650000000001	-28
+3	3	3	5523.36	-38
+4	3	4	5702.65	-28
 4	4	4	6047.27	-20
 4	4	4	6195.32	-18
 4	4	4	6208.18	44
 4	4	4	7222.02	23
-5	4	5	7117.070000000001	22
-5	5	5	7337.620000000001	5
+5	4	5	7117.07	22
+5	5	5	7337.62	5
 5	5	5	7532.61	44
 5	5	5	7672.66	-23
 5	5	5	8923.62	-7
-6	5	6	8749.730000000001	14
+6	5	6	8749.73	14
 PREHOOK: query: -- 7. testJoinWithWindowingAndPTF
 select abc.p_mfgr, abc.p_name, 
 rank() over(distribute by abc.p_mfgr sort by abc.p_name) as r, 
 dense_rank() over(distribute by abc.p_mfgr sort by abc.p_name) as dr, 
-abc.p_retailprice, sum(abc.p_retailprice) over (distribute by abc.p_mfgr sort by abc.p_name rows between unbounded preceding and current row) as s1, 
+abc.p_retailprice, round(sum(abc.p_retailprice) over (distribute by abc.p_mfgr sort by abc.p_name rows between unbounded preceding and current row),2) as s1,
 abc.p_size, abc.p_size - lag(abc.p_size,1,abc.p_size) over(distribute by abc.p_mfgr sort by abc.p_name) as deltaSz 
 from noop(on part 
 partition by p_mfgr 
@@ -297,7 +297,7 @@ POSTHOOK: query: -- 7. testJoinWithWindowingAndPTF
 select abc.p_mfgr, abc.p_name, 
 rank() over(distribute by abc.p_mfgr sort by abc.p_name) as r, 
 dense_rank() over(distribute by abc.p_mfgr sort by abc.p_name) as dr, 
-abc.p_retailprice, sum(abc.p_retailprice) over (distribute by abc.p_mfgr sort by abc.p_name rows between unbounded preceding and current row) as s1, 
+abc.p_retailprice, round(sum(abc.p_retailprice) over (distribute by abc.p_mfgr sort by abc.p_name rows between unbounded preceding and current row),2) as s1,
 abc.p_size, abc.p_size - lag(abc.p_size,1,abc.p_size) over(distribute by abc.p_mfgr sort by abc.p_name) as deltaSz 
 from noop(on part 
 partition by p_mfgr 
@@ -308,15 +308,15 @@ POSTHOOK: Input: default@part
 #### A masked pattern was here ####
 Manufacturer#1	almond antique burnished rose metallic	1	1	1173.15	1173.15	2	0
 Manufacturer#1	almond antique burnished rose metallic	1	1	1173.15	2346.3	2	0
-Manufacturer#1	almond antique burnished rose metallic	1	1	1173.15	3519.4500000000003	2	0
+Manufacturer#1	almond antique burnished rose metallic	1	1	1173.15	3519.45	2	0
 Manufacturer#1	almond antique burnished rose metallic	1	1	1173.15	4692.6	2	0
-Manufacturer#1	almond antique chartreuse lavender yellow	5	2	1753.76	6446.360000000001	34	32
-Manufacturer#1	almond antique salmon chartreuse burlywood	6	3	1602.59	8048.950000000001	6	-28
+Manufacturer#1	almond antique chartreuse lavender yellow	5	2	1753.76	6446.36	34	32
+Manufacturer#1	almond antique salmon chartreuse burlywood	6	3	1602.59	8048.95	6	-28
 Manufacturer#1	almond aquamarine burnished black steel	7	4	1414.42	9463.37	28	22
 Manufacturer#1	almond aquamarine pink moccasin thistle	8	5	1632.66	11096.03	42	14
 Manufacturer#2	almond antique violet chocolate turquoise	1	1	1690.68	1690.68	14	0
 Manufacturer#2	almond antique violet turquoise frosted	2	2	1800.7	3491.38	40	26
-Manufacturer#2	almond aquamarine midnight light salmon	3	3	2031.98	5523.360000000001	2	-38
+Manufacturer#2	almond aquamarine midnight light salmon	3	3	2031.98	5523.36	2	-38
 Manufacturer#2	almond aquamarine rose maroon antique	4	4	1698.66	7222.02	25	23
 Manufacturer#2	almond aquamarine sandy cyan gainsboro	5	5	1701.6	8923.62	18	-7
 Manufacturer#3	almond antique chartreuse khaki white	1	1	1671.68	1671.68	17	0
@@ -328,9 +328,9 @@ Manufacturer#4	almond antique gainsboro frosted violet	1	1	1620.67	1620.67	10	0
 Manufacturer#4	almond antique violet mint lemon	2	2	1375.42	2996.09	39	29
 Manufacturer#4	almond aquamarine floral ivory bisque	3	3	1206.26	4202.35	27	-12
 Manufacturer#4	almond aquamarine yellow dodger mint	4	4	1844.92	6047.27	7	-20
-Manufacturer#4	almond azure aquamarine papaya violet	5	5	1290.35	7337.620000000001	12	5
+Manufacturer#4	almond azure aquamarine papaya violet	5	5	1290.35	7337.62	12	5
 Manufacturer#5	almond antique blue firebrick mint	1	1	1789.69	1789.69	31	0
-Manufacturer#5	almond antique medium spring khaki	2	2	1611.66	3401.3500000000004	6	-25
+Manufacturer#5	almond antique medium spring khaki	2	2	1611.66	3401.35	6	-25
 Manufacturer#5	almond antique sky peru orange	3	3	1788.73	5190.08	2	-4
 Manufacturer#5	almond aquamarine dodger light gainsboro	4	4	1018.1	6208.18	46	44
 Manufacturer#5	almond azure blanched chiffon midnight	5	5	1464.48	7672.66	23	-23
@@ -378,7 +378,7 @@ PREHOOK: query: -- 9. testHavingWithWindowingNoGBY
 select p_mfgr, p_name, p_size, 
 rank() over(distribute by p_mfgr sort by p_name) as r, 
 dense_rank() over(distribute by p_mfgr sort by p_name) as dr, 
-sum(p_retailprice) over (distribute by p_mfgr sort by p_name rows between unbounded preceding and current row)  as s1
+round(sum(p_retailprice) over (distribute by p_mfgr sort by p_name rows between unbounded preceding and current row),2)  as s1
 from part
 PREHOOK: type: QUERY
 PREHOOK: Input: default@part
@@ -387,7 +387,7 @@ POSTHOOK: query: -- 9. testHavingWithWindowingNoGBY
 select p_mfgr, p_name, p_size, 
 rank() over(distribute by p_mfgr sort by p_name) as r, 
 dense_rank() over(distribute by p_mfgr sort by p_name) as dr, 
-sum(p_retailprice) over (distribute by p_mfgr sort by p_name rows between unbounded preceding and current row)  as s1
+round(sum(p_retailprice) over (distribute by p_mfgr sort by p_name rows between unbounded preceding and current row),2)  as s1
 from part
 POSTHOOK: type: QUERY
 POSTHOOK: Input: default@part
@@ -395,12 +395,12 @@ POSTHOOK: Input: default@part
 Manufacturer#1	almond antique burnished rose metallic	2	1	1	1173.15
 Manufacturer#1	almond antique burnished rose metallic	2	1	1	2346.3
 Manufacturer#1	almond antique chartreuse lavender yellow	34	3	2	4100.06
-Manufacturer#1	almond antique salmon chartreuse burlywood	6	4	3	5702.650000000001
-Manufacturer#1	almond aquamarine burnished black steel	28	5	4	7117.070000000001
-Manufacturer#1	almond aquamarine pink moccasin thistle	42	6	5	8749.730000000001
+Manufacturer#1	almond antique salmon chartreuse burlywood	6	4	3	5702.65
+Manufacturer#1	almond aquamarine burnished black steel	28	5	4	7117.07
+Manufacturer#1	almond aquamarine pink moccasin thistle	42	6	5	8749.73
 Manufacturer#2	almond antique violet chocolate turquoise	14	1	1	1690.68
 Manufacturer#2	almond antique violet turquoise frosted	40	2	2	3491.38
-Manufacturer#2	almond aquamarine midnight light salmon	2	3	3	5523.360000000001
+Manufacturer#2	almond aquamarine midnight light salmon	2	3	3	5523.36
 Manufacturer#2	almond aquamarine rose maroon antique	25	4	4	7222.02
 Manufacturer#2	almond aquamarine sandy cyan gainsboro	18	5	5	8923.62
 Manufacturer#3	almond antique chartreuse khaki white	17	1	1	1671.68
@@ -412,9 +412,9 @@ Manufacturer#4	almond antique gainsboro frosted violet	10	1	1	1620.67
 Manufacturer#4	almond antique violet mint lemon	39	2	2	2996.09
 Manufacturer#4	almond aquamarine floral ivory bisque	27	3	3	4202.35
 Manufacturer#4	almond aquamarine yellow dodger mint	7	4	4	6047.27
-Manufacturer#4	almond azure aquamarine papaya violet	12	5	5	7337.620000000001
+Manufacturer#4	almond azure aquamarine papaya violet	12	5	5	7337.62
 Manufacturer#5	almond antique blue firebrick mint	31	1	1	1789.69
-Manufacturer#5	almond antique medium spring khaki	6	2	2	3401.3500000000004
+Manufacturer#5	almond antique medium spring khaki	6	2	2	3401.35
 Manufacturer#5	almond antique sky peru orange	2	3	3	5190.08
 Manufacturer#5	almond aquamarine dodger light gainsboro	46	4	4	6208.18
 Manufacturer#5	almond azure blanched chiffon midnight	23	5	5	7672.66
@@ -422,7 +422,7 @@ PREHOOK: query: -- 10. testHavingWithWindowingCondRankNoGBY
 select p_mfgr, p_name, p_size, 
 rank() over(distribute by p_mfgr sort by p_name) as r, 
 dense_rank() over(distribute by p_mfgr sort by p_name) as dr, 
-sum(p_retailprice) over (distribute by p_mfgr sort by p_name rows between unbounded preceding and current row) as s1 
+round(sum(p_retailprice) over (distribute by p_mfgr sort by p_name rows between unbounded preceding and current row),2) as s1
 from part
 PREHOOK: type: QUERY
 PREHOOK: Input: default@part
@@ -431,7 +431,7 @@ POSTHOOK: query: -- 10. testHavingWithWindowingCondRankNoGBY
 select p_mfgr, p_name, p_size, 
 rank() over(distribute by p_mfgr sort by p_name) as r, 
 dense_rank() over(distribute by p_mfgr sort by p_name) as dr, 
-sum(p_retailprice) over (distribute by p_mfgr sort by p_name rows between unbounded preceding and current row) as s1 
+round(sum(p_retailprice) over (distribute by p_mfgr sort by p_name rows between unbounded preceding and current row),2) as s1
 from part
 POSTHOOK: type: QUERY
 POSTHOOK: Input: default@part
@@ -439,12 +439,12 @@ POSTHOOK: Input: default@part
 Manufacturer#1	almond antique burnished rose metallic	2	1	1	1173.15
 Manufacturer#1	almond antique burnished rose metallic	2	1	1	2346.3
 Manufacturer#1	almond antique chartreuse lavender yellow	34	3	2	4100.06
-Manufacturer#1	almond antique salmon chartreuse burlywood	6	4	3	5702.650000000001
-Manufacturer#1	almond aquamarine burnished black steel	28	5	4	7117.070000000001
-Manufacturer#1	almond aquamarine pink moccasin thistle	42	6	5	8749.730000000001
+Manufacturer#1	almond antique salmon chartreuse burlywood	6	4	3	5702.65
+Manufacturer#1	almond aquamarine burnished black steel	28	5	4	7117.07
+Manufacturer#1	almond aquamarine pink moccasin thistle	42	6	5	8749.73
 Manufacturer#2	almond antique violet chocolate turquoise	14	1	1	1690.68
 Manufacturer#2	almond antique violet turquoise frosted	40	2	2	3491.38
-Manufacturer#2	almond aquamarine midnight light salmon	2	3	3	5523.360000000001
+Manufacturer#2	almond aquamarine midnight light salmon	2	3	3	5523.36
 Manufacturer#2	almond aquamarine rose maroon antique	25	4	4	7222.02
 Manufacturer#2	almond aquamarine sandy cyan gainsboro	18	5	5	8923.62
 Manufacturer#3	almond antique chartreuse khaki white	17	1	1	1671.68
@@ -456,9 +456,9 @@ Manufacturer#4	almond antique gainsboro frosted violet	10	1	1	1620.67
 Manufacturer#4	almond antique violet mint lemon	39	2	2	2996.09
 Manufacturer#4	almond aquamarine floral ivory bisque	27	3	3	4202.35
 Manufacturer#4	almond aquamarine yellow dodger mint	7	4	4	6047.27
-Manufacturer#4	almond azure aquamarine papaya violet	12	5	5	7337.620000000001
+Manufacturer#4	almond azure aquamarine papaya violet	12	5	5	7337.62
 Manufacturer#5	almond antique blue firebrick mint	31	1	1	1789.69
-Manufacturer#5	almond antique medium spring khaki	6	2	2	3401.3500000000004
+Manufacturer#5	almond antique medium spring khaki	6	2	2	3401.35
 Manufacturer#5	almond antique sky peru orange	2	3	3	5190.08
 Manufacturer#5	almond aquamarine dodger light gainsboro	46	4	4	6208.18
 Manufacturer#5	almond azure blanched chiffon midnight	23	5	5	7672.66
@@ -785,10 +785,10 @@ Manufacturer#5	almond aquamarine dodger light gainsboro	46	4	4	6
 Manufacturer#5	almond azure blanched chiffon midnight	23	5	5	2
 PREHOOK: query: -- 18. testUDAFs
 select  p_mfgr,p_name, p_size, 
-sum(p_retailprice) over w1 as s, 
+round(sum(p_retailprice) over w1,2) as s,
 min(p_retailprice) over w1 as mi,
 max(p_retailprice) over w1 as ma,
-avg(p_retailprice) over w1 as ag
+round(avg(p_retailprice) over w1,2) as ag
 from part
 window w1 as (distribute by p_mfgr sort by p_mfgr, p_name rows between 2 preceding and 2 following)
 PREHOOK: type: QUERY
@@ -796,47 +796,47 @@ PREHOOK: Input: default@part
 #### A masked pattern was here ####
 POSTHOOK: query: -- 18. testUDAFs
 select  p_mfgr,p_name, p_size, 
-sum(p_retailprice) over w1 as s, 
+round(sum(p_retailprice) over w1,2) as s,
 min(p_retailprice) over w1 as mi,
 max(p_retailprice) over w1 as ma,
-avg(p_retailprice) over w1 as ag
+round(avg(p_retailprice) over w1,2) as ag
 from part
 window w1 as (distribute by p_mfgr sort by p_mfgr, p_name rows between 2 preceding and 2 following)
 POSTHOOK: type: QUERY
 POSTHOOK: Input: default@part
 #### A masked pattern was here ####
-Manufacturer#1	almond antique burnished rose metallic	2	4100.06	1173.15	1753.76	1366.6866666666667
-Manufacturer#1	almond antique burnished rose metallic	2	5702.650000000001	1173.15	1753.76	1425.6625000000001
-Manufacturer#1	almond antique chartreuse lavender yellow	34	7117.070000000001	1173.15	1753.76	1423.4140000000002
-Manufacturer#1	almond antique salmon chartreuse burlywood	6	7576.580000000002	1173.15	1753.76	1515.3160000000003
-Manufacturer#1	almond aquamarine burnished black steel	28	6403.430000000001	1414.42	1753.76	1600.8575000000003
-Manufacturer#1	almond aquamarine pink moccasin thistle	42	4649.670000000001	1414.42	1632.66	1549.8900000000003
-Manufacturer#2	almond antique violet chocolate turquoise	14	5523.360000000001	1690.68	2031.98	1841.1200000000001
-Manufacturer#2	almond antique violet turquoise frosted	40	7222.02	1690.68	2031.98	1805.505
-Manufacturer#2	almond aquamarine midnight light salmon	2	8923.62	1690.68	2031.98	1784.7240000000002
-Manufacturer#2	almond aquamarine rose maroon antique	25	7232.9400000000005	1698.66	2031.98	1808.2350000000001
-Manufacturer#2	almond aquamarine sandy cyan gainsboro	18	5432.240000000001	1698.66	2031.98	1810.746666666667
-Manufacturer#3	almond antique chartreuse khaki white	17	4272.34	1190.27	1671.68	1424.1133333333335
+Manufacturer#1	almond antique burnished rose metallic	2	4100.06	1173.15	1753.76	1366.69
+Manufacturer#1	almond antique burnished rose metallic	2	5702.65	1173.15	1753.76	1425.66
+Manufacturer#1	almond antique chartreuse lavender yellow	34	7117.07	1173.15	1753.76	1423.41
+Manufacturer#1	almond antique salmon chartreuse burlywood	6	7576.58	1173.15	1753.76	1515.32
+Manufacturer#1	almond aquamarine burnished black steel	28	6403.43	1414.42	1753.76	1600.86
+Manufacturer#1	almond aquamarine pink moccasin thistle	42	4649.67	1414.42	1632.66	1549.89
+Manufacturer#2	almond antique violet chocolate turquoise	14	5523.36	1690.68	2031.98	1841.12
+Manufacturer#2	almond antique violet turquoise frosted	40	7222.02	1690.68	2031.98	1805.51
+Manufacturer#2	almond aquamarine midnight light salmon	2	8923.62	1690.68	2031.98	1784.72
+Manufacturer#2	almond aquamarine rose maroon antique	25	7232.94	1698.66	2031.98	1808.24
+Manufacturer#2	almond aquamarine sandy cyan gainsboro	18	5432.24	1698.66	2031.98	1810.75
+Manufacturer#3	almond antique chartreuse khaki white	17	4272.34	1190.27	1671.68	1424.11
 Manufacturer#3	almond antique forest lavender goldenrod	14	6195.32	1190.27	1922.98	1548.83
-Manufacturer#3	almond antique metallic orange dim	19	7532.61	1190.27	1922.98	1506.522
-Manufacturer#3	almond antique misty red olive	1	5860.929999999999	1190.27	1922.98	1465.2324999999998
-Manufacturer#3	almond antique olive coral navajo	45	4670.66	1337.29	1922.98	1556.8866666666665
-Manufacturer#4	almond antique gainsboro frosted violet	10	4202.35	1206.26	1620.67	1400.7833333333335
-Manufacturer#4	almond antique violet mint lemon	39	6047.27	1206.26	1844.92	1511.8175
-Manufacturer#4	almond aquamarine floral ivory bisque	27	7337.620000000001	1206.26	1844.92	1467.5240000000001
-Manufacturer#4	almond aquamarine yellow dodger mint	7	5716.950000000001	1206.26	1844.92	1429.2375000000002
-Manufacturer#4	almond azure aquamarine papaya violet	12	4341.530000000001	1206.26	1844.92	1447.176666666667
-Manufacturer#5	almond antique blue firebrick mint	31	5190.08	1611.66	1789.69	1730.0266666666666
-Manufacturer#5	almond antique medium spring khaki	6	6208.18	1018.1	1789.69	1552.045
-Manufacturer#5	almond antique sky peru orange	2	7672.66	1018.1	1789.69	1534.532
-Manufacturer#5	almond aquamarine dodger light gainsboro	46	5882.969999999999	1018.1	1788.73	1470.7424999999998
-Manufacturer#5	almond azure blanched chiffon midnight	23	4271.3099999999995	1018.1	1788.73	1423.7699999999998
+Manufacturer#3	almond antique metallic orange dim	19	7532.61	1190.27	1922.98	1506.52
+Manufacturer#3	almond antique misty red olive	1	5860.93	1190.27	1922.98	1465.23
+Manufacturer#3	almond antique olive coral navajo	45	4670.66	1337.29	1922.98	1556.89
+Manufacturer#4	almond antique gainsboro frosted violet	10	4202.35	1206.26	1620.67	1400.78
+Manufacturer#4	almond antique violet mint lemon	39	6047.27	1206.26	1844.92	1511.82
+Manufacturer#4	almond aquamarine floral ivory bisque	27	7337.62	1206.26	1844.92	1467.52
+Manufacturer#4	almond aquamarine yellow dodger mint	7	5716.95	1206.26	1844.92	1429.24
+Manufacturer#4	almond azure aquamarine papaya violet	12	4341.53	1206.26	1844.92	1447.18
+Manufacturer#5	almond antique blue firebrick mint	31	5190.08	1611.66	1789.69	1730.03
+Manufacturer#5	almond antique medium spring khaki	6	6208.18	1018.1	1789.69	1552.05
+Manufacturer#5	almond antique sky peru orange	2	7672.66	1018.1	1789.69	1534.53
+Manufacturer#5	almond aquamarine dodger light gainsboro	46	5882.97	1018.1	1788.73	1470.74
+Manufacturer#5	almond azure blanched chiffon midnight	23	4271.31	1018.1	1788.73	1423.77
 PREHOOK: query: -- 19. testUDAFsWithGBY
 select  p_mfgr,p_name, p_size, p_retailprice, 
-sum(p_retailprice) over w1 as s, 
+round(sum(p_retailprice) over w1,2) as s,
 min(p_retailprice) as mi ,
 max(p_retailprice) as ma ,
-avg(p_retailprice) over w1 as ag
+round(avg(p_retailprice) over w1,2) as ag
 from part
 group by p_mfgr,p_name, p_size, p_retailprice
 window w1 as (distribute by p_mfgr sort by p_mfgr, p_name rows between 2 preceding and 2 following)
@@ -845,41 +845,41 @@ PREHOOK: Input: default@part
 #### A masked pattern was here ####
 POSTHOOK: query: -- 19. testUDAFsWithGBY
 select  p_mfgr,p_name, p_size, p_retailprice, 
-sum(p_retailprice) over w1 as s, 
+round(sum(p_retailprice) over w1,2) as s,
 min(p_retailprice) as mi ,
 max(p_retailprice) as ma ,
-avg(p_retailprice) over w1 as ag
+round(avg(p_retailprice) over w1,2) as ag
 from part
 group by p_mfgr,p_name, p_size, p_retailprice
 window w1 as (distribute by p_mfgr sort by p_mfgr, p_name rows between 2 preceding and 2 following)
 POSTHOOK: type: QUERY
 POSTHOOK: Input: default@part
 #### A masked pattern was here ####
-Manufacturer#1	almond antique burnished rose metallic	2	1173.15	4529.5	1173.15	1173.15	1509.8333333333333
+Manufacturer#1	almond antique burnished rose metallic	2	1173.15	4529.5	1173.15	1173.15	1509.83
 Manufacturer#1	almond antique chartreuse lavender yellow	34	1753.76	5943.92	1753.76	1753.76	1485.98
-Manufacturer#1	almond antique salmon chartreuse burlywood	6	1602.59	7576.58	1602.59	1602.59	1515.316
-Manufacturer#1	almond aquamarine burnished black steel	28	1414.42	6403.43	1414.42	1414.42	1600.8575
+Manufacturer#1	almond antique salmon chartreuse burlywood	6	1602.59	7576.58	1602.59	1602.59	1515.32
+Manufacturer#1	almond aquamarine burnished black steel	28	1414.42	6403.43	1414.42	1414.42	1600.86
 Manufacturer#1	almond aquamarine pink moccasin thistle	42	1632.66	4649.67	1632.66	1632.66	1549.89
-Manufacturer#2	almond antique violet chocolate turquoise	14	1690.68	5523.360000000001	1690.68	1690.68	1841.1200000000001
-Manufacturer#2	almond antique violet turquoise frosted	40	1800.7	7222.02	1800.7	1800.7	1805.505
-Manufacturer#2	almond aquamarine midnight light salmon	2	2031.98	8923.62	2031.98	2031.98	1784.7240000000002
-Manufacturer#2	almond aquamarine rose maroon antique	25	1698.66	7232.9400000000005	1698.66	1698.66	1808.2350000000001
-Manufacturer#2	almond aquamarine sandy cyan gainsboro	18	1701.6	5432.240000000001	1701.6	1701.6	1810.746666666667
-Manufacturer#3	almond antique chartreuse khaki white	17	1671.68	4272.34	1671.68	1671.68	1424.1133333333335
+Manufacturer#2	almond antique violet chocolate turquoise	14	1690.68	5523.36	1690.68	1690.68	1841.12
+Manufacturer#2	almond antique violet turquoise frosted	40	1800.7	7222.02	1800.7	1800.7	1805.51
+Manufacturer#2	almond aquamarine midnight light salmon	2	2031.98	8923.62	2031.98	2031.98	1784.72
+Manufacturer#2	almond aquamarine rose maroon antique	25	1698.66	7232.94	1698.66	1698.66	1808.24
+Manufacturer#2	almond aquamarine sandy cyan gainsboro	18	1701.6	5432.24	1701.6	1701.6	1810.75
+Manufacturer#3	almond antique chartreuse khaki white	17	1671.68	4272.34	1671.68	1671.68	1424.11
 Manufacturer#3	almond antique forest lavender goldenrod	14	1190.27	6195.32	1190.27	1190.27	1548.83
-Manufacturer#3	almond antique metallic orange dim	19	1410.39	7532.61	1410.39	1410.39	1506.522
-Manufacturer#3	almond antique misty red olive	1	1922.98	5860.929999999999	1922.98	1922.98	1465.2324999999998
-Manufacturer#3	almond antique olive coral navajo	45	1337.29	4670.66	1337.29	1337.29	1556.8866666666665
-Manufacturer#4	almond antique gainsboro frosted violet	10	1620.67	4202.35	1620.67	1620.67	1400.7833333333335
-Manufacturer#4	almond antique violet mint lemon	39	1375.42	6047.27	1375.42	1375.42	1511.8175
-Manufacturer#4	almond aquamarine floral ivory bisque	27	1206.26	7337.620000000001	1206.26	1206.26	1467.5240000000001
-Manufacturer#4	almond aquamarine yellow dodger mint	7	1844.92	5716.950000000001	1844.92	1844.92	1429.2375000000002
-Manufacturer#4	almond azure aquamarine papaya violet	12	1290.35	4341.530000000001	1290.35	1290.35	1447.176666666667
-Manufacturer#5	almond antique blue firebrick mint	31	1789.69	5190.08	1789.69	1789.69	1730.0266666666666
-Manufacturer#5	almond antique medium spring khaki	6	1611.66	6208.18	1611.66	1611.66	1552.045
-Manufacturer#5	almond antique sky peru orange	2	1788.73	7672.66	1788.73	1788.73	1534.532
-Manufacturer#5	almond aquamarine dodger light gainsboro	46	1018.1	5882.969999999999	1018.1	1018.1	1470.7424999999998
-Manufacturer#5	almond azure blanched chiffon midnight	23	1464.48	4271.3099999999995	1464.48	1464.48	1423.7699999999998
+Manufacturer#3	almond antique metallic orange dim	19	1410.39	7532.61	1410.39	1410.39	1506.52
+Manufacturer#3	almond antique misty red olive	1	1922.98	5860.93	1922.98	1922.98	1465.23
+Manufacturer#3	almond antique olive coral navajo	45	1337.29	4670.66	1337.29	1337.29	1556.89
+Manufacturer#4	almond antique gainsboro frosted violet	10	1620.67	4202.35	1620.67	1620.67	1400.78
+Manufacturer#4	almond antique violet mint lemon	39	1375.42	6047.27	1375.42	1375.42	1511.82
+Manufacturer#4	almond aquamarine floral ivory bisque	27	1206.26	7337.62	1206.26	1206.26	1467.52
+Manufacturer#4	almond aquamarine yellow dodger mint	7	1844.92	5716.95	1844.92	1844.92	1429.24
+Manufacturer#4	almond azure aquamarine papaya violet	12	1290.35	4341.53	1290.35	1290.35	1447.18
+Manufacturer#5	almond antique blue firebrick mint	31	1789.69	5190.08	1789.69	1789.69	1730.03
+Manufacturer#5	almond antique medium spring khaki	6	1611.66	6208.18	1611.66	1611.66	1552.05
+Manufacturer#5	almond antique sky peru orange	2	1788.73	7672.66	1788.73	1788.73	1534.53
+Manufacturer#5	almond aquamarine dodger light gainsboro	46	1018.1	5882.97	1018.1	1018.1	1470.74
+Manufacturer#5	almond azure blanched chiffon midnight	23	1464.48	4271.31	1464.48	1464.48	1423.77
 PREHOOK: query: -- 20. testSTATs
 select  p_mfgr,p_name, p_size, 
 stddev(p_retailprice) over w1 as sdev, 
@@ -1073,7 +1073,7 @@ Manufacturer#5	Brand#53	2806.83	7672.66
 PREHOOK: query: -- 23. testCreateViewWithWindowingQuery
 create view IF NOT EXISTS mfgr_brand_price_view as 
 select p_mfgr, p_brand, 
-sum(p_retailprice) over w1  as s
+round(sum(p_retailprice) over w1,2) as s
 from part 
 window w1 as (distribute by p_mfgr sort by p_name rows between 2 preceding and current row)
 PREHOOK: type: CREATEVIEW
@@ -1083,7 +1083,7 @@ PREHOOK: Output: default@mfgr_brand_price_view
 POSTHOOK: query: -- 23. testCreateViewWithWindowingQuery
 create view IF NOT EXISTS mfgr_brand_price_view as 
 select p_mfgr, p_brand, 
-sum(p_retailprice) over w1  as s
+round(sum(p_retailprice) over w1,2) as s
 from part 
 window w1 as (distribute by p_mfgr sort by p_name rows between 2 preceding and current row)
 POSTHOOK: type: CREATEVIEW
@@ -1101,29 +1101,29 @@ POSTHOOK: Input: default@mfgr_brand_price_view
 POSTHOOK: Input: default@part
 #### A masked pattern was here ####
 Manufacturer#1	Brand#12	4100.06
-Manufacturer#1	Brand#12	4649.670000000001
+Manufacturer#1	Brand#12	4649.67
 Manufacturer#1	Brand#12	4770.77
 Manufacturer#1	Brand#14	1173.15
 Manufacturer#1	Brand#14	2346.3
 Manufacturer#1	Brand#15	4529.5
 Manufacturer#2	Brand#22	1690.68
 Manufacturer#2	Brand#22	3491.38
-Manufacturer#2	Brand#23	5523.360000000001
+Manufacturer#2	Brand#23	5523.36
 Manufacturer#2	Brand#24	5531.34
-Manufacturer#2	Brand#25	5432.240000000001
+Manufacturer#2	Brand#25	5432.24
 Manufacturer#3	Brand#31	1671.68
 Manufacturer#3	Brand#32	4272.34
-Manufacturer#3	Brand#32	4523.639999999999
+Manufacturer#3	Brand#32	4523.64
 Manufacturer#3	Brand#34	4670.66
 Manufacturer#3	Brand#35	2861.95
 Manufacturer#4	Brand#41	1620.67
-Manufacturer#4	Brand#41	4341.530000000001
+Manufacturer#4	Brand#41	4341.53
 Manufacturer#4	Brand#41	4426.6
 Manufacturer#4	Brand#42	2996.09
 Manufacturer#4	Brand#42	4202.35
-Manufacturer#5	Brand#51	3401.3500000000004
+Manufacturer#5	Brand#51	3401.35
 Manufacturer#5	Brand#52	1789.69
-Manufacturer#5	Brand#52	4271.3099999999995
+Manufacturer#5	Brand#52	4271.31
 Manufacturer#5	Brand#53	4418.49
 Manufacturer#5	Brand#53	5190.08
 PREHOOK: query: -- 24. testLateralViews
@@ -1293,7 +1293,7 @@ INSERT OVERWRITE TABLE part_1
 select p_mfgr, p_name, p_size, 
 rank() over(distribute by p_mfgr sort by p_name ) as r, 
 dense_rank() over(distribute by p_mfgr sort by p_name ) as dr, 
-sum(p_retailprice) over (distribute by p_mfgr sort by p_name rows between unbounded preceding and current row)  as s
+round(sum(p_retailprice) over (distribute by p_mfgr sort by p_name rows between unbounded preceding and current row),2) as s
 INSERT OVERWRITE TABLE part_2 
 select  p_mfgr,p_name, p_size,  
 rank() over(distribute by p_mfgr sort by p_name) as r, 
@@ -1318,7 +1318,7 @@ INSERT OVERWRITE TABLE part_1
 select p_mfgr, p_name, p_size, 
 rank() over(distribute by p_mfgr sort by p_name ) as r, 
 dense_rank() over(distribute by p_mfgr sort by p_name ) as dr, 
-sum(p_retailprice) over (distribute by p_mfgr sort by p_name rows between unbounded preceding and current row)  as s
+round(sum(p_retailprice) over (distribute by p_mfgr sort by p_name rows between unbounded preceding and current row),2) as s
 INSERT OVERWRITE TABLE part_2 
 select  p_mfgr,p_name, p_size,  
 rank() over(distribute by p_mfgr sort by p_name) as r, 
@@ -1369,12 +1369,12 @@ POSTHOOK: Input: default@part_1
 Manufacturer#1	almond antique burnished rose metallic	2	1	1	1173.15
 Manufacturer#1	almond antique burnished rose metallic	2	1	1	2346.3
 Manufacturer#1	almond antique chartreuse lavender yellow	34	3	2	4100.06
-Manufacturer#1	almond antique salmon chartreuse burlywood	6	4	3	5702.650000000001
-Manufacturer#1	almond aquamarine burnished black steel	28	5	4	7117.070000000001
-Manufacturer#1	almond aquamarine pink moccasin thistle	42	6	5	8749.730000000001
+Manufacturer#1	almond antique salmon chartreuse burlywood	6	4	3	5702.65
+Manufacturer#1	almond aquamarine burnished black steel	28	5	4	7117.07
+Manufacturer#1	almond aquamarine pink moccasin thistle	42	6	5	8749.73
 Manufacturer#2	almond antique violet chocolate turquoise	14	1	1	1690.68
 Manufacturer#2	almond antique violet turquoise frosted	40	2	2	3491.38
-Manufacturer#2	almond aquamarine midnight light salmon	2	3	3	5523.360000000001
+Manufacturer#2	almond aquamarine midnight light salmon	2	3	3	5523.36
 Manufacturer#2	almond aquamarine rose maroon antique	25	4	4	7222.02
 Manufacturer#2	almond aquamarine sandy cyan gainsboro	18	5	5	8923.62
 Manufacturer#3	almond antique chartreuse khaki white	17	1	1	1671.68
@@ -1386,9 +1386,9 @@ Manufacturer#4	almond antique gainsboro frosted violet	10	1	1	1620.67
 Manufacturer#4	almond antique violet mint lemon	39	2	2	2996.09
 Manufacturer#4	almond aquamarine floral ivory bisque	27	3	3	4202.35
 Manufacturer#4	almond aquamarine yellow dodger mint	7	4	4	6047.27
-Manufacturer#4	almond azure aquamarine papaya violet	12	5	5	7337.620000000001
+Manufacturer#4	almond azure aquamarine papaya violet	12	5	5	7337.62
 Manufacturer#5	almond antique blue firebrick mint	31	1	1	1789.69
-Manufacturer#5	almond antique medium spring khaki	6	2	2	3401.3500000000004
+Manufacturer#5	almond antique medium spring khaki	6	2	2	3401.35
 Manufacturer#5	almond antique sky peru orange	2	3	3	5190.08
 Manufacturer#5	almond aquamarine dodger light gainsboro	46	4	4	6208.18
 Manufacturer#5	almond azure blanched chiffon midnight	23	5	5	7672.66
@@ -2099,7 +2099,7 @@ Manufacturer#5	7672.66	1018.1	1789.69	1534.53	5
 Manufacturer#5	7672.66	1018.1	1789.69	1534.53	5
 PREHOOK: query: -- 38. testPartitioningVariousForms2
 select p_mfgr, p_name, p_size,
-sum(p_retailprice) over (partition by p_mfgr, p_name order by p_mfgr, p_name rows between unbounded preceding and current row) as s1,
+round(sum(p_retailprice) over (partition by p_mfgr, p_name order by p_mfgr, p_name rows between unbounded preceding and current row),2) as s1,
 min(p_retailprice) over (distribute by p_mfgr, p_name sort by p_mfgr, p_name rows between unbounded preceding and current row) as s2,
 max(p_retailprice) over (partition by p_mfgr, p_name order by p_name) as s3
 from part
@@ -2108,7 +2108,7 @@ PREHOOK: Input: default@part
 #### A masked pattern was here ####
 POSTHOOK: query: -- 38. testPartitioningVariousForms2
 select p_mfgr, p_name, p_size,
-sum(p_retailprice) over (partition by p_mfgr, p_name order by p_mfgr, p_name rows between unbounded preceding and current row) as s1,
+round(sum(p_retailprice) over (partition by p_mfgr, p_name order by p_mfgr, p_name rows between unbounded preceding and current row),2) as s1,
 min(p_retailprice) over (distribute by p_mfgr, p_name sort by p_mfgr, p_name rows between unbounded preceding and current row) as s2,
 max(p_retailprice) over (partition by p_mfgr, p_name order by p_name) as s3
 from part
@@ -2183,14 +2183,14 @@ Manufacturer#5	SMALL PLATED BRASS	MALL PLATED BRASS	4
 Manufacturer#5	STANDARD BURNISHED TIN	TANDARD BURNISHED TIN	5
 PREHOOK: query: -- 40. testNoBetweenForRows
 select p_mfgr, p_name, p_size,
-    sum(p_retailprice) over (distribute by p_mfgr sort by p_name rows unbounded preceding) as s1
+    round(sum(p_retailprice) over (distribute by p_mfgr sort by p_name rows unbounded preceding),2) as s1
      from part
 PREHOOK: type: QUERY
 PREHOOK: Input: default@part
 #### A masked pattern was here ####
 POSTHOOK: query: -- 40. testNoBetweenForRows
 select p_mfgr, p_name, p_size,
-    sum(p_retailprice) over (distribute by p_mfgr sort by p_name rows unbounded preceding) as s1
+    round(sum(p_retailprice) over (distribute by p_mfgr sort by p_name rows unbounded preceding),2) as s1
      from part
 POSTHOOK: type: QUERY
 POSTHOOK: Input: default@part
@@ -2198,12 +2198,12 @@ POSTHOOK: Input: default@part
 Manufacturer#1	almond antique burnished rose metallic	2	1173.15
 Manufacturer#1	almond antique burnished rose metallic	2	2346.3
 Manufacturer#1	almond antique chartreuse lavender yellow	34	4100.06
-Manufacturer#1	almond antique salmon chartreuse burlywood	6	5702.650000000001
-Manufacturer#1	almond aquamarine burnished black steel	28	7117.070000000001
-Manufacturer#1	almond aquamarine pink moccasin thistle	42	8749.730000000001
+Manufacturer#1	almond antique salmon chartreuse burlywood	6	5702.65
+Manufacturer#1	almond aquamarine burnished black steel	28	7117.07
+Manufacturer#1	almond aquamarine pink moccasin thistle	42	8749.73
 Manufacturer#2	almond antique violet chocolate turquoise	14	1690.68
 Manufacturer#2	almond antique violet turquoise frosted	40	3491.38
-Manufacturer#2	almond aquamarine midnight light salmon	2	5523.360000000001
+Manufacturer#2	almond aquamarine midnight light salmon	2	5523.36
 Manufacturer#2	almond aquamarine rose maroon antique	25	7222.02
 Manufacturer#2	almond aquamarine sandy cyan gainsboro	18	8923.62
 Manufacturer#3	almond antique chartreuse khaki white	17	1671.68
@@ -2215,32 +2215,32 @@ Manufacturer#4	almond antique gainsboro frosted violet	10	1620.67
 Manufacturer#4	almond antique violet mint lemon	39	2996.09
 Manufacturer#4	almond aquamarine floral ivory bisque	27	4202.35
 Manufacturer#4	almond aquamarine yellow dodger mint	7	6047.27
-Manufacturer#4	almond azure aquamarine papaya violet	12	7337.620000000001
+Manufacturer#4	almond azure aquamarine papaya violet	12	7337.62
 Manufacturer#5	almond antique blue firebrick mint	31	1789.69
-Manufacturer#5	almond antique medium spring khaki	6	3401.3500000000004
+Manufacturer#5	almond antique medium spring khaki	6	3401.35
 Manufacturer#5	almond antique sky peru orange	2	5190.08
 Manufacturer#5	almond aquamarine dodger light gainsboro	46	6208.18
 Manufacturer#5	almond azure blanched chiffon midnight	23	7672.66
 PREHOOK: query: -- 41. testNoBetweenForRange
 select p_mfgr, p_name, p_size,
-    sum(p_retailprice) over (distribute by p_mfgr sort by p_size range unbounded preceding) as s1
+    round(sum(p_retailprice) over (distribute by p_mfgr sort by p_size range unbounded preceding),2) as s1
      from part
 PREHOOK: type: QUERY
 PREHOOK: Input: default@part
 #### A masked pattern was here ####
 POSTHOOK: query: -- 41. testNoBetweenForRange
 select p_mfgr, p_name, p_size,
-    sum(p_retailprice) over (distribute by p_mfgr sort by p_size range unbounded preceding) as s1
+    round(sum(p_retailprice) over (distribute by p_mfgr sort by p_size range unbounded preceding),2) as s1
      from part
 POSTHOOK: type: QUERY
 POSTHOOK: Input: default@part
 #### A masked pattern was here ####
 Manufacturer#1	almond antique burnished rose metallic	2	2346.3
 Manufacturer#1	almond antique burnished rose metallic	2	2346.3
-Manufacturer#1	almond antique chartreuse lavender yellow	34	7117.070000000001
-Manufacturer#1	almond antique salmon chartreuse burlywood	6	3948.8900000000003
+Manufacturer#1	almond antique chartreuse lavender yellow	34	7117.07
+Manufacturer#1	almond antique salmon chartreuse burlywood	6	3948.89
 Manufacturer#1	almond aquamarine burnished black steel	28	5363.31
-Manufacturer#1	almond aquamarine pink moccasin thistle	42	8749.730000000001
+Manufacturer#1	almond aquamarine pink moccasin thistle	42	8749.73
 Manufacturer#2	almond antique violet chocolate turquoise	14	3722.66
 Manufacturer#2	almond antique violet turquoise frosted	40	8923.62
 Manufacturer#2	almond aquamarine midnight light salmon	2	2031.98
@@ -2248,97 +2248,97 @@ Manufacturer#2	almond aquamarine rose maroon antique	25	7122.92
 Manufacturer#2	almond aquamarine sandy cyan gainsboro	18	5424.26
 Manufacturer#3	almond antique chartreuse khaki white	17	4784.93
 Manufacturer#3	almond antique forest lavender goldenrod	14	3113.25
-Manufacturer#3	almond antique metallic orange dim	19	6195.320000000001
+Manufacturer#3	almond antique metallic orange dim	19	6195.32
 Manufacturer#3	almond antique misty red olive	1	1922.98
-Manufacturer#3	almond antique olive coral navajo	45	7532.610000000001
+Manufacturer#3	almond antique olive coral navajo	45	7532.61
 Manufacturer#4	almond antique gainsboro frosted violet	10	3465.59
-Manufacturer#4	almond antique violet mint lemon	39	7337.620000000001
-Manufacturer#4	almond aquamarine floral ivory bisque	27	5962.200000000001
+Manufacturer#4	almond antique violet mint lemon	39	7337.62
+Manufacturer#4	almond aquamarine floral ivory bisque	27	5962.2
 Manufacturer#4	almond aquamarine yellow dodger mint	7	1844.92
-Manufacturer#4	almond azure aquamarine papaya violet	12	4755.9400000000005
-Manufacturer#5	almond antique blue firebrick mint	31	6654.560000000001
-Manufacturer#5	almond antique medium spring khaki	6	3400.3900000000003
+Manufacturer#4	almond azure aquamarine papaya violet	12	4755.94
+Manufacturer#5	almond antique blue firebrick mint	31	6654.56
+Manufacturer#5	almond antique medium spring khaki	6	3400.39
 Manufacturer#5	almond antique sky peru orange	2	1788.73
-Manufacturer#5	almond aquamarine dodger light gainsboro	46	7672.660000000002
-Manufacturer#5	almond azure blanched chiffon midnight	23	4864.870000000001
+Manufacturer#5	almond aquamarine dodger light gainsboro	46	7672.66
+Manufacturer#5	almond azure blanched chiffon midnight	23	4864.87
 PREHOOK: query: -- 42. testUnboundedFollowingForRows
 select p_mfgr, p_name, p_size,
-    sum(p_retailprice) over (distribute by p_mfgr sort by p_name rows between current row and unbounded following) as s1
+    round(sum(p_retailprice) over (distribute by p_mfgr sort by p_name rows between current row and unbounded following),2) as s1
     from part
 PREHOOK: type: QUERY
 PREHOOK: Input: default@part
 #### A masked pattern was here ####
 POSTHOOK: query: -- 42. testUnboundedFollowingForRows
 select p_mfgr, p_name, p_size,
-    sum(p_retailprice) over (distribute by p_mfgr sort by p_name rows between current row and unbounded following) as s1
+    round(sum(p_retailprice) over (distribute by p_mfgr sort by p_name rows between current row and unbounded following),2) as s1
     from part
 POSTHOOK: type: QUERY
 POSTHOOK: Input: default@part
 #### A masked pattern was here ####
 Manufacturer#1	almond antique burnished rose metallic	2	7576.58
-Manufacturer#1	almond antique burnished rose metallic	2	8749.730000000001
+Manufacturer#1	almond antique burnished rose metallic	2	8749.73
 Manufacturer#1	almond antique chartreuse lavender yellow	34	6403.43
 Manufacturer#1	almond antique salmon chartreuse burlywood	6	4649.67
 Manufacturer#1	almond aquamarine burnished black steel	28	3047.08
 Manufacturer#1	almond aquamarine pink moccasin thistle	42	1632.66
 Manufacturer#2	almond antique violet chocolate turquoise	14	8923.62
-Manufacturer#2	almond antique violet turquoise frosted	40	7232.9400000000005
+Manufacturer#2	almond antique violet turquoise frosted	40	7232.94
 Manufacturer#2	almond aquamarine midnight light salmon	2	5432.24
 Manufacturer#2	almond aquamarine rose maroon antique	25	3400.26
 Manufacturer#2	almond aquamarine sandy cyan gainsboro	18	1701.6
 Manufacturer#3	almond antique chartreuse khaki white	17	7532.61
-Manufacturer#3	almond antique forest lavender goldenrod	14	5860.929999999999
+Manufacturer#3	almond antique forest lavender goldenrod	14	5860.93
 Manufacturer#3	almond antique metallic orange dim	19	4670.66
 Manufacturer#3	almond antique misty red olive	1	3260.27
 Manufacturer#3	almond antique olive coral navajo	45	1337.29
-Manufacturer#4	almond antique gainsboro frosted violet	10	7337.620000000001
-Manufacturer#4	almond antique violet mint lemon	39	5716.950000000001
-Manufacturer#4	almond aquamarine floral ivory bisque	27	4341.530000000001
+Manufacturer#4	almond antique gainsboro frosted violet	10	7337.62
+Manufacturer#4	almond antique violet mint lemon	39	5716.95
+Manufacturer#4	almond aquamarine floral ivory bisque	27	4341.53
 Manufacturer#4	almond aquamarine yellow dodger mint	7	3135.27
 Manufacturer#4	almond azure aquamarine papaya violet	12	1290.35
 Manufacturer#5	almond antique blue firebrick mint	31	7672.66
-Manufacturer#5	almond antique medium spring khaki	6	5882.970000000001
-Manufacturer#5	almond antique sky peru orange	2	4271.3099999999995
+Manufacturer#5	almond antique medium spring khaki	6	5882.97
+Manufacturer#5	almond antique sky peru orange	2	4271.31
 Manufacturer#5	almond aquamarine dodger light gainsboro	46	2482.58
 Manufacturer#5	almond azure blanched chiffon midnight	23	1464.48
 PREHOOK: query: -- 43. testUnboundedFollowingForRange
 select p_mfgr, p_name, p_size,
-    sum(p_retailprice) over (distribute by p_mfgr sort by p_size range between current row and unbounded following) as s1
+    round(sum(p_retailprice) over (distribute by p_mfgr sort by p_size range between current row and unbounded following),2) as s1
     from part
 PREHOOK: type: QUERY
 PREHOOK: Input: default@part
 #### A masked pattern was here ####
 POSTHOOK: query: -- 43. testUnboundedFollowingForRange
 select p_mfgr, p_name, p_size,
-    sum(p_retailprice) over (distribute by p_mfgr sort by p_size range between current row and unbounded following) as s1
+    round(sum(p_retailprice) over (distribute by p_mfgr sort by p_size range between current row and unbounded following),2) as s1
     from part
 POSTHOOK: type: QUERY
 POSTHOOK: Input: default@part
 #### A masked pattern was here ####
-Manufacturer#1	almond antique burnished rose metallic	2	8749.730000000001
-Manufacturer#1	almond antique burnished rose metallic	2	8749.730000000001
+Manufacturer#1	almond antique burnished rose metallic	2	8749.73
+Manufacturer#1	almond antique burnished rose metallic	2	8749.73
 Manufacturer#1	almond antique chartreuse lavender yellow	34	3386.42
 Manufacturer#1	almond antique salmon chartreuse burlywood	6	6403.43
 Manufacturer#1	almond aquamarine burnished black steel	28	4800.84
 Manufacturer#1	almond aquamarine pink moccasin thistle	42	1632.66
-Manufacturer#2	almond antique violet chocolate turquoise	14	6891.639999999999
+Manufacturer#2	almond antique violet chocolate turquoise	14	6891.64
 Manufacturer#2	almond antique violet turquoise frosted	40	1800.7
 Manufacturer#2	almond aquamarine midnight light salmon	2	8923.62
 Manufacturer#2	almond aquamarine rose maroon antique	25	3499.36
 Manufacturer#2	almond aquamarine sandy cyan gainsboro	18	5200.96
-Manufacturer#3	almond antique chartreuse khaki white	17	4419.360000000001
+Manufacturer#3	almond antique chartreuse khaki white	17	4419.36
 Manufacturer#3	almond antique forest lavender goldenrod	14	5609.63
-Manufacturer#3	almond antique metallic orange dim	19	2747.6800000000003
-Manufacturer#3	almond antique misty red olive	1	7532.610000000001
+Manufacturer#3	almond antique metallic orange dim	19	2747.68
+Manufacturer#3	almond antique misty red olive	1	7532.61
 Manufacturer#3	almond antique olive coral navajo	45	1337.29
 Manufacturer#4	almond antique gainsboro frosted violet	10	5492.7
 Manufacturer#4	almond antique violet mint lemon	39	1375.42
-Manufacturer#4	almond aquamarine floral ivory bisque	27	2581.6800000000003
-Manufacturer#4	almond aquamarine yellow dodger mint	7	7337.620000000001
-Manufacturer#4	almond azure aquamarine papaya violet	12	3872.0299999999997
+Manufacturer#4	almond aquamarine floral ivory bisque	27	2581.68
+Manufacturer#4	almond aquamarine yellow dodger mint	7	7337.62
+Manufacturer#4	almond azure aquamarine papaya violet	12	3872.03
 Manufacturer#5	almond antique blue firebrick mint	31	2807.79
 Manufacturer#5	almond antique medium spring khaki	6	5883.93
-Manufacturer#5	almond antique sky peru orange	2	7672.660000000002
+Manufacturer#5	almond antique sky peru orange	2	7672.66
 Manufacturer#5	almond aquamarine dodger light gainsboro	46	1018.1
 Manufacturer#5	almond azure blanched chiffon midnight	23	4272.27
 PREHOOK: query: -- 44. testOverNoPartitionSingleAggregate
@@ -2400,27 +2400,27 @@ POSTHOOK: type: QUERY
 POSTHOOK: Input: default@part
 #### A masked pattern was here ####
 PREHOOK: query: -- 46. window sz is same as partition sz
-select p_retailprice, avg(p_retailprice) over (partition by p_mfgr order by p_name rows between current row and 6 following), 
-sum(p_retailprice) over (partition by p_mfgr order by p_name rows between current row and 6 following) 
+select p_retailprice, round(avg(p_retailprice) over (partition by p_mfgr order by p_name rows between current row and 6 following),2),
+round(sum(p_retailprice) over (partition by p_mfgr order by p_name rows between current row and 6 following),2)
 from part 
 where p_mfgr='Manufacturer#1'
 PREHOOK: type: QUERY
 PREHOOK: Input: default@part
 #### A masked pattern was here ####
 POSTHOOK: query: -- 46. window sz is same as partition sz
-select p_retailprice, avg(p_retailprice) over (partition by p_mfgr order by p_name rows between current row and 6 following), 
-sum(p_retailprice) over (partition by p_mfgr order by p_name rows between current row and 6 following) 
+select p_retailprice, round(avg(p_retailprice) over (partition by p_mfgr order by p_name rows between current row and 6 following),2),
+round(sum(p_retailprice) over (partition by p_mfgr order by p_name rows between current row and 6 following),2)
 from part 
 where p_mfgr='Manufacturer#1'
 POSTHOOK: type: QUERY
 POSTHOOK: Input: default@part
 #### A masked pattern was here ####
-1173.15	1458.2883333333336	8749.730000000001
-1173.15	1515.3160000000003	7576.580000000002
-1414.42	1523.5400000000004	3047.080000000001
-1602.59	1549.8900000000003	4649.670000000001
-1632.66	1632.6600000000008	1632.6600000000008
-1753.76	1600.8575000000003	6403.430000000001
+1173.15	1458.29	8749.73
+1173.15	1515.32	7576.58
+1414.42	1523.54	3047.08
+1602.59	1549.89	4649.67
+1632.66	1632.66	1632.66
+1753.76	1600.86	6403.43
 PREHOOK: query: -- 47. empty partition
 select sum(p_size) over (partition by p_mfgr )
 from part where p_mfgr = 'm1'


[09/13] hive git commit: HIVE-15520: Improve the sum performance for Range based window (Aihua Xu, reviewed by Yongzhi Chen)

Posted by ai...@apache.org.
http://git-wip-us.apache.org/repos/asf/hive/blob/a28b28f3/ql/src/test/results/clientpositive/llap/ptf.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/llap/ptf.q.out b/ql/src/test/results/clientpositive/llap/ptf.q.out
index 542347d2..c97f1ce 100644
--- a/ql/src/test/results/clientpositive/llap/ptf.q.out
+++ b/ql/src/test/results/clientpositive/llap/ptf.q.out
@@ -5,7 +5,7 @@ explain
 select p_mfgr, p_name, p_size,
 rank() over (partition by p_mfgr order by p_name) as r,
 dense_rank() over (partition by p_mfgr order by p_name) as dr,
-sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row) as s1
+round(sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row),2) as s1
 from noop(on part 
   partition by p_mfgr
   order by p_name
@@ -18,7 +18,7 @@ explain
 select p_mfgr, p_name, p_size,
 rank() over (partition by p_mfgr order by p_name) as r,
 dense_rank() over (partition by p_mfgr order by p_name) as dr,
-sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row) as s1
+round(sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row),2) as s1
 from noop(on part 
   partition by p_mfgr
   order by p_name
@@ -119,7 +119,7 @@ STAGE PLANS:
                               window frame: PRECEDING(MAX)~CURRENT
                   Statistics: Num rows: 26 Data size: 12974 Basic stats: COMPLETE Column stats: COMPLETE
                   Select Operator
-                    expressions: _col2 (type: string), _col1 (type: string), _col5 (type: int), rank_window_0 (type: int), dense_rank_window_1 (type: int), sum_window_2 (type: double)
+                    expressions: _col2 (type: string), _col1 (type: string), _col5 (type: int), rank_window_0 (type: int), dense_rank_window_1 (type: int), round(sum_window_2, 2) (type: double)
                     outputColumnNames: _col0, _col1, _col2, _col3, _col4, _col5
                     Statistics: Num rows: 26 Data size: 6214 Basic stats: COMPLETE Column stats: COMPLETE
                     File Output Operator
@@ -139,7 +139,7 @@ STAGE PLANS:
 PREHOOK: query: select p_mfgr, p_name, p_size,
 rank() over (partition by p_mfgr order by p_name) as r,
 dense_rank() over (partition by p_mfgr order by p_name) as dr,
-sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row) as s1
+round(sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row),2) as s1
 from noop(on part 
   partition by p_mfgr
   order by p_name
@@ -150,7 +150,7 @@ PREHOOK: Input: default@part
 POSTHOOK: query: select p_mfgr, p_name, p_size,
 rank() over (partition by p_mfgr order by p_name) as r,
 dense_rank() over (partition by p_mfgr order by p_name) as dr,
-sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row) as s1
+round(sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row),2) as s1
 from noop(on part 
   partition by p_mfgr
   order by p_name
@@ -161,12 +161,12 @@ POSTHOOK: Input: default@part
 Manufacturer#1	almond antique burnished rose metallic	2	1	1	1173.15
 Manufacturer#1	almond antique burnished rose metallic	2	1	1	2346.3
 Manufacturer#1	almond antique chartreuse lavender yellow	34	3	2	4100.06
-Manufacturer#1	almond antique salmon chartreuse burlywood	6	4	3	5702.650000000001
-Manufacturer#1	almond aquamarine burnished black steel	28	5	4	7117.070000000001
-Manufacturer#1	almond aquamarine pink moccasin thistle	42	6	5	8749.730000000001
+Manufacturer#1	almond antique salmon chartreuse burlywood	6	4	3	5702.65
+Manufacturer#1	almond aquamarine burnished black steel	28	5	4	7117.07
+Manufacturer#1	almond aquamarine pink moccasin thistle	42	6	5	8749.73
 Manufacturer#2	almond antique violet chocolate turquoise	14	1	1	1690.68
 Manufacturer#2	almond antique violet turquoise frosted	40	2	2	3491.38
-Manufacturer#2	almond aquamarine midnight light salmon	2	3	3	5523.360000000001
+Manufacturer#2	almond aquamarine midnight light salmon	2	3	3	5523.36
 Manufacturer#2	almond aquamarine rose maroon antique	25	4	4	7222.02
 Manufacturer#2	almond aquamarine sandy cyan gainsboro	18	5	5	8923.62
 Manufacturer#3	almond antique chartreuse khaki white	17	1	1	1671.68
@@ -178,9 +178,9 @@ Manufacturer#4	almond antique gainsboro frosted violet	10	1	1	1620.67
 Manufacturer#4	almond antique violet mint lemon	39	2	2	2996.09
 Manufacturer#4	almond aquamarine floral ivory bisque	27	3	3	4202.35
 Manufacturer#4	almond aquamarine yellow dodger mint	7	4	4	6047.27
-Manufacturer#4	almond azure aquamarine papaya violet	12	5	5	7337.620000000001
+Manufacturer#4	almond azure aquamarine papaya violet	12	5	5	7337.62
 Manufacturer#5	almond antique blue firebrick mint	31	1	1	1789.69
-Manufacturer#5	almond antique medium spring khaki	6	2	2	3401.3500000000004
+Manufacturer#5	almond antique medium spring khaki	6	2	2	3401.35
 Manufacturer#5	almond antique sky peru orange	2	3	3	5190.08
 Manufacturer#5	almond aquamarine dodger light gainsboro	46	4	4	6208.18
 Manufacturer#5	almond azure blanched chiffon midnight	23	5	5	7672.66
@@ -502,7 +502,7 @@ explain
 select p_mfgr, p_name, p_size,
 rank() over (partition by p_mfgr order by p_name) as r,
 dense_rank() over (partition by p_mfgr order by p_name) as dr,
-sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row) as s1
+round(sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row),2) as s1
 from noop(on part 
   partition by p_mfgr
   order by p_name
@@ -513,7 +513,7 @@ explain
 select p_mfgr, p_name, p_size,
 rank() over (partition by p_mfgr order by p_name) as r,
 dense_rank() over (partition by p_mfgr order by p_name) as dr,
-sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row) as s1
+round(sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row),2) as s1
 from noop(on part 
   partition by p_mfgr
   order by p_name
@@ -614,7 +614,7 @@ STAGE PLANS:
                               window frame: PRECEDING(MAX)~CURRENT
                   Statistics: Num rows: 26 Data size: 12974 Basic stats: COMPLETE Column stats: COMPLETE
                   Select Operator
-                    expressions: _col2 (type: string), _col1 (type: string), _col5 (type: int), rank_window_0 (type: int), dense_rank_window_1 (type: int), sum_window_2 (type: double)
+                    expressions: _col2 (type: string), _col1 (type: string), _col5 (type: int), rank_window_0 (type: int), dense_rank_window_1 (type: int), round(sum_window_2, 2) (type: double)
                     outputColumnNames: _col0, _col1, _col2, _col3, _col4, _col5
                     Statistics: Num rows: 26 Data size: 6214 Basic stats: COMPLETE Column stats: COMPLETE
                     File Output Operator
@@ -634,7 +634,7 @@ STAGE PLANS:
 PREHOOK: query: select p_mfgr, p_name, p_size,
 rank() over (partition by p_mfgr order by p_name) as r,
 dense_rank() over (partition by p_mfgr order by p_name) as dr,
-sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row) as s1
+round(sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row),2) as s1
 from noop(on part 
   partition by p_mfgr
   order by p_name
@@ -645,7 +645,7 @@ PREHOOK: Input: default@part
 POSTHOOK: query: select p_mfgr, p_name, p_size,
 rank() over (partition by p_mfgr order by p_name) as r,
 dense_rank() over (partition by p_mfgr order by p_name) as dr,
-sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row) as s1
+round(sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row),2) as s1
 from noop(on part 
   partition by p_mfgr
   order by p_name
@@ -656,12 +656,12 @@ POSTHOOK: Input: default@part
 Manufacturer#1	almond antique burnished rose metallic	2	1	1	1173.15
 Manufacturer#1	almond antique burnished rose metallic	2	1	1	2346.3
 Manufacturer#1	almond antique chartreuse lavender yellow	34	3	2	4100.06
-Manufacturer#1	almond antique salmon chartreuse burlywood	6	4	3	5702.650000000001
-Manufacturer#1	almond aquamarine burnished black steel	28	5	4	7117.070000000001
-Manufacturer#1	almond aquamarine pink moccasin thistle	42	6	5	8749.730000000001
+Manufacturer#1	almond antique salmon chartreuse burlywood	6	4	3	5702.65
+Manufacturer#1	almond aquamarine burnished black steel	28	5	4	7117.07
+Manufacturer#1	almond aquamarine pink moccasin thistle	42	6	5	8749.73
 Manufacturer#2	almond antique violet chocolate turquoise	14	1	1	1690.68
 Manufacturer#2	almond antique violet turquoise frosted	40	2	2	3491.38
-Manufacturer#2	almond aquamarine midnight light salmon	2	3	3	5523.360000000001
+Manufacturer#2	almond aquamarine midnight light salmon	2	3	3	5523.36
 Manufacturer#2	almond aquamarine rose maroon antique	25	4	4	7222.02
 Manufacturer#2	almond aquamarine sandy cyan gainsboro	18	5	5	8923.62
 Manufacturer#3	almond antique chartreuse khaki white	17	1	1	1671.68
@@ -673,9 +673,9 @@ Manufacturer#4	almond antique gainsboro frosted violet	10	1	1	1620.67
 Manufacturer#4	almond antique violet mint lemon	39	2	2	2996.09
 Manufacturer#4	almond aquamarine floral ivory bisque	27	3	3	4202.35
 Manufacturer#4	almond aquamarine yellow dodger mint	7	4	4	6047.27
-Manufacturer#4	almond azure aquamarine papaya violet	12	5	5	7337.620000000001
+Manufacturer#4	almond azure aquamarine papaya violet	12	5	5	7337.62
 Manufacturer#5	almond antique blue firebrick mint	31	1	1	1789.69
-Manufacturer#5	almond antique medium spring khaki	6	2	2	3401.3500000000004
+Manufacturer#5	almond antique medium spring khaki	6	2	2	3401.35
 Manufacturer#5	almond antique sky peru orange	2	3	3	5190.08
 Manufacturer#5	almond aquamarine dodger light gainsboro	46	4	4	6208.18
 Manufacturer#5	almond azure blanched chiffon midnight	23	5	5	7672.66
@@ -1550,7 +1550,7 @@ explain
 select p_mfgr, p_name, p_size,
 rank() over (partition by p_mfgr order by p_name) as r,
 dense_rank() over (partition by p_mfgr order by p_name) as dr,
-sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row) as s1
+round(sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row),2) as s1
 from noopwithmap(on part 
   partition by p_mfgr
   order by p_name)
@@ -1560,7 +1560,7 @@ explain
 select p_mfgr, p_name, p_size,
 rank() over (partition by p_mfgr order by p_name) as r,
 dense_rank() over (partition by p_mfgr order by p_name) as dr,
-sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row) as s1
+round(sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row),2) as s1
 from noopwithmap(on part 
   partition by p_mfgr
   order by p_name)
@@ -1677,7 +1677,7 @@ STAGE PLANS:
                               window frame: PRECEDING(MAX)~CURRENT
                   Statistics: Num rows: 26 Data size: 12974 Basic stats: COMPLETE Column stats: COMPLETE
                   Select Operator
-                    expressions: _col2 (type: string), _col1 (type: string), _col5 (type: int), rank_window_0 (type: int), dense_rank_window_1 (type: int), sum_window_2 (type: double)
+                    expressions: _col2 (type: string), _col1 (type: string), _col5 (type: int), rank_window_0 (type: int), dense_rank_window_1 (type: int), round(sum_window_2, 2) (type: double)
                     outputColumnNames: _col0, _col1, _col2, _col3, _col4, _col5
                     Statistics: Num rows: 26 Data size: 6214 Basic stats: COMPLETE Column stats: COMPLETE
                     File Output Operator
@@ -1697,7 +1697,7 @@ STAGE PLANS:
 PREHOOK: query: select p_mfgr, p_name, p_size,
 rank() over (partition by p_mfgr order by p_name) as r,
 dense_rank() over (partition by p_mfgr order by p_name) as dr,
-sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row) as s1
+round(sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row),2) as s1
 from noopwithmap(on part 
   partition by p_mfgr
   order by p_name)
@@ -1707,7 +1707,7 @@ PREHOOK: Input: default@part
 POSTHOOK: query: select p_mfgr, p_name, p_size,
 rank() over (partition by p_mfgr order by p_name) as r,
 dense_rank() over (partition by p_mfgr order by p_name) as dr,
-sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row) as s1
+round(sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row),2) as s1
 from noopwithmap(on part 
   partition by p_mfgr
   order by p_name)
@@ -1717,12 +1717,12 @@ POSTHOOK: Input: default@part
 Manufacturer#1	almond antique burnished rose metallic	2	1	1	1173.15
 Manufacturer#1	almond antique burnished rose metallic	2	1	1	2346.3
 Manufacturer#1	almond antique chartreuse lavender yellow	34	3	2	4100.06
-Manufacturer#1	almond antique salmon chartreuse burlywood	6	4	3	5702.650000000001
-Manufacturer#1	almond aquamarine burnished black steel	28	5	4	7117.070000000001
-Manufacturer#1	almond aquamarine pink moccasin thistle	42	6	5	8749.730000000001
+Manufacturer#1	almond antique salmon chartreuse burlywood	6	4	3	5702.65
+Manufacturer#1	almond aquamarine burnished black steel	28	5	4	7117.07
+Manufacturer#1	almond aquamarine pink moccasin thistle	42	6	5	8749.73
 Manufacturer#2	almond antique violet chocolate turquoise	14	1	1	1690.68
 Manufacturer#2	almond antique violet turquoise frosted	40	2	2	3491.38
-Manufacturer#2	almond aquamarine midnight light salmon	2	3	3	5523.360000000001
+Manufacturer#2	almond aquamarine midnight light salmon	2	3	3	5523.36
 Manufacturer#2	almond aquamarine rose maroon antique	25	4	4	7222.02
 Manufacturer#2	almond aquamarine sandy cyan gainsboro	18	5	5	8923.62
 Manufacturer#3	almond antique chartreuse khaki white	17	1	1	1671.68
@@ -1734,9 +1734,9 @@ Manufacturer#4	almond antique gainsboro frosted violet	10	1	1	1620.67
 Manufacturer#4	almond antique violet mint lemon	39	2	2	2996.09
 Manufacturer#4	almond aquamarine floral ivory bisque	27	3	3	4202.35
 Manufacturer#4	almond aquamarine yellow dodger mint	7	4	4	6047.27
-Manufacturer#4	almond azure aquamarine papaya violet	12	5	5	7337.620000000001
+Manufacturer#4	almond azure aquamarine papaya violet	12	5	5	7337.62
 Manufacturer#5	almond antique blue firebrick mint	31	1	1	1789.69
-Manufacturer#5	almond antique medium spring khaki	6	2	2	3401.3500000000004
+Manufacturer#5	almond antique medium spring khaki	6	2	2	3401.35
 Manufacturer#5	almond antique sky peru orange	2	3	3	5190.08
 Manufacturer#5	almond aquamarine dodger light gainsboro	46	4	4	6208.18
 Manufacturer#5	almond azure blanched chiffon midnight	23	5	5	7672.66
@@ -1745,7 +1745,7 @@ explain
 select p_mfgr, p_name, p_size,
 rank() over (partition by p_mfgr order by p_name) as r,
 dense_rank() over (partition by p_mfgr order by p_name) as dr,
-sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row) as s1
+round(sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row),2) as s1
 from noop(on part
 partition by p_mfgr
 order by p_name)
@@ -1755,7 +1755,7 @@ explain
 select p_mfgr, p_name, p_size,
 rank() over (partition by p_mfgr order by p_name) as r,
 dense_rank() over (partition by p_mfgr order by p_name) as dr,
-sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row) as s1
+round(sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row),2) as s1
 from noop(on part
 partition by p_mfgr
 order by p_name)
@@ -1855,7 +1855,7 @@ STAGE PLANS:
                               window frame: PRECEDING(MAX)~CURRENT
                   Statistics: Num rows: 26 Data size: 12974 Basic stats: COMPLETE Column stats: COMPLETE
                   Select Operator
-                    expressions: _col2 (type: string), _col1 (type: string), _col5 (type: int), rank_window_0 (type: int), dense_rank_window_1 (type: int), sum_window_2 (type: double)
+                    expressions: _col2 (type: string), _col1 (type: string), _col5 (type: int), rank_window_0 (type: int), dense_rank_window_1 (type: int), round(sum_window_2, 2) (type: double)
                     outputColumnNames: _col0, _col1, _col2, _col3, _col4, _col5
                     Statistics: Num rows: 26 Data size: 6214 Basic stats: COMPLETE Column stats: COMPLETE
                     File Output Operator
@@ -1875,7 +1875,7 @@ STAGE PLANS:
 PREHOOK: query: select p_mfgr, p_name, p_size,
 rank() over (partition by p_mfgr order by p_name) as r,
 dense_rank() over (partition by p_mfgr order by p_name) as dr,
-sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row) as s1
+round(sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row),2) as s1
 from noop(on part
 partition by p_mfgr
 order by p_name)
@@ -1885,7 +1885,7 @@ PREHOOK: Input: default@part
 POSTHOOK: query: select p_mfgr, p_name, p_size,
 rank() over (partition by p_mfgr order by p_name) as r,
 dense_rank() over (partition by p_mfgr order by p_name) as dr,
-sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row) as s1
+round(sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row),2) as s1
 from noop(on part
 partition by p_mfgr
 order by p_name)
@@ -1895,12 +1895,12 @@ POSTHOOK: Input: default@part
 Manufacturer#1	almond antique burnished rose metallic	2	1	1	1173.15
 Manufacturer#1	almond antique burnished rose metallic	2	1	1	2346.3
 Manufacturer#1	almond antique chartreuse lavender yellow	34	3	2	4100.06
-Manufacturer#1	almond antique salmon chartreuse burlywood	6	4	3	5702.650000000001
-Manufacturer#1	almond aquamarine burnished black steel	28	5	4	7117.070000000001
-Manufacturer#1	almond aquamarine pink moccasin thistle	42	6	5	8749.730000000001
+Manufacturer#1	almond antique salmon chartreuse burlywood	6	4	3	5702.65
+Manufacturer#1	almond aquamarine burnished black steel	28	5	4	7117.07
+Manufacturer#1	almond aquamarine pink moccasin thistle	42	6	5	8749.73
 Manufacturer#2	almond antique violet chocolate turquoise	14	1	1	1690.68
 Manufacturer#2	almond antique violet turquoise frosted	40	2	2	3491.38
-Manufacturer#2	almond aquamarine midnight light salmon	2	3	3	5523.360000000001
+Manufacturer#2	almond aquamarine midnight light salmon	2	3	3	5523.36
 Manufacturer#2	almond aquamarine rose maroon antique	25	4	4	7222.02
 Manufacturer#2	almond aquamarine sandy cyan gainsboro	18	5	5	8923.62
 Manufacturer#3	almond antique chartreuse khaki white	17	1	1	1671.68
@@ -1912,9 +1912,9 @@ Manufacturer#4	almond antique gainsboro frosted violet	10	1	1	1620.67
 Manufacturer#4	almond antique violet mint lemon	39	2	2	2996.09
 Manufacturer#4	almond aquamarine floral ivory bisque	27	3	3	4202.35
 Manufacturer#4	almond aquamarine yellow dodger mint	7	4	4	6047.27
-Manufacturer#4	almond azure aquamarine papaya violet	12	5	5	7337.620000000001
+Manufacturer#4	almond azure aquamarine papaya violet	12	5	5	7337.62
 Manufacturer#5	almond antique blue firebrick mint	31	1	1	1789.69
-Manufacturer#5	almond antique medium spring khaki	6	2	2	3401.3500000000004
+Manufacturer#5	almond antique medium spring khaki	6	2	2	3401.35
 Manufacturer#5	almond antique sky peru orange	2	3	3	5190.08
 Manufacturer#5	almond aquamarine dodger light gainsboro	46	4	4	6208.18
 Manufacturer#5	almond azure blanched chiffon midnight	23	5	5	7672.66
@@ -1923,7 +1923,7 @@ explain
 select p_mfgr, p_name, p_size, 
 rank() over (partition by p_mfgr order by p_name) as r, 
 dense_rank() over (partition by p_mfgr order by p_name) as dr, 
-sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row)  as s1
+round(sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row),2) as s1
 from noop(on noopwithmap(on noop(on part 
 partition by p_mfgr 
 order by p_mfgr DESC, p_name
@@ -1934,7 +1934,7 @@ explain
 select p_mfgr, p_name, p_size, 
 rank() over (partition by p_mfgr order by p_name) as r, 
 dense_rank() over (partition by p_mfgr order by p_name) as dr, 
-sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row)  as s1
+round(sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row),2) as s1
 from noop(on noopwithmap(on noop(on part 
 partition by p_mfgr 
 order by p_mfgr DESC, p_name
@@ -2094,7 +2094,7 @@ STAGE PLANS:
                               window frame: PRECEDING(MAX)~CURRENT
                   Statistics: Num rows: 26 Data size: 12974 Basic stats: COMPLETE Column stats: COMPLETE
                   Select Operator
-                    expressions: _col2 (type: string), _col1 (type: string), _col5 (type: int), rank_window_0 (type: int), dense_rank_window_1 (type: int), sum_window_2 (type: double)
+                    expressions: _col2 (type: string), _col1 (type: string), _col5 (type: int), rank_window_0 (type: int), dense_rank_window_1 (type: int), round(sum_window_2, 2) (type: double)
                     outputColumnNames: _col0, _col1, _col2, _col3, _col4, _col5
                     Statistics: Num rows: 26 Data size: 6214 Basic stats: COMPLETE Column stats: COMPLETE
                     File Output Operator
@@ -2114,7 +2114,7 @@ STAGE PLANS:
 PREHOOK: query: select p_mfgr, p_name, p_size, 
 rank() over (partition by p_mfgr order by p_name) as r, 
 dense_rank() over (partition by p_mfgr order by p_name) as dr, 
-sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row)  as s1
+round(sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row),2) as s1
 from noop(on noopwithmap(on noop(on part 
 partition by p_mfgr 
 order by p_mfgr DESC, p_name
@@ -2125,7 +2125,7 @@ PREHOOK: Input: default@part
 POSTHOOK: query: select p_mfgr, p_name, p_size, 
 rank() over (partition by p_mfgr order by p_name) as r, 
 dense_rank() over (partition by p_mfgr order by p_name) as dr, 
-sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row)  as s1
+round(sum(p_retailprice) over (partition by p_mfgr order by p_name rows between unbounded preceding and current row),2) as s1
 from noop(on noopwithmap(on noop(on part 
 partition by p_mfgr 
 order by p_mfgr DESC, p_name
@@ -2136,12 +2136,12 @@ POSTHOOK: Input: default@part
 Manufacturer#1	almond antique burnished rose metallic	2	1	1	1173.15
 Manufacturer#1	almond antique burnished rose metallic	2	1	1	2346.3
 Manufacturer#1	almond antique chartreuse lavender yellow	34	3	2	4100.06
-Manufacturer#1	almond antique salmon chartreuse burlywood	6	4	3	5702.650000000001
-Manufacturer#1	almond aquamarine burnished black steel	28	5	4	7117.070000000001
-Manufacturer#1	almond aquamarine pink moccasin thistle	42	6	5	8749.730000000001
+Manufacturer#1	almond antique salmon chartreuse burlywood	6	4	3	5702.65
+Manufacturer#1	almond aquamarine burnished black steel	28	5	4	7117.07
+Manufacturer#1	almond aquamarine pink moccasin thistle	42	6	5	8749.73
 Manufacturer#2	almond antique violet chocolate turquoise	14	1	1	1690.68
 Manufacturer#2	almond antique violet turquoise frosted	40	2	2	3491.38
-Manufacturer#2	almond aquamarine midnight light salmon	2	3	3	5523.360000000001
+Manufacturer#2	almond aquamarine midnight light salmon	2	3	3	5523.36
 Manufacturer#2	almond aquamarine rose maroon antique	25	4	4	7222.02
 Manufacturer#2	almond aquamarine sandy cyan gainsboro	18	5	5	8923.62
 Manufacturer#3	almond antique chartreuse khaki white	17	1	1	1671.68
@@ -2153,9 +2153,9 @@ Manufacturer#4	almond antique gainsboro frosted violet	10	1	1	1620.67
 Manufacturer#4	almond antique violet mint lemon	39	2	2	2996.09
 Manufacturer#4	almond aquamarine floral ivory bisque	27	3	3	4202.35
 Manufacturer#4	almond aquamarine yellow dodger mint	7	4	4	6047.27
-Manufacturer#4	almond azure aquamarine papaya violet	12	5	5	7337.620000000001
+Manufacturer#4	almond azure aquamarine papaya violet	12	5	5	7337.62
 Manufacturer#5	almond antique blue firebrick mint	31	1	1	1789.69
-Manufacturer#5	almond antique medium spring khaki	6	2	2	3401.3500000000004
+Manufacturer#5	almond antique medium spring khaki	6	2	2	3401.35
 Manufacturer#5	almond antique sky peru orange	2	3	3	5190.08
 Manufacturer#5	almond aquamarine dodger light gainsboro	46	4	4	6208.18
 Manufacturer#5	almond azure blanched chiffon midnight	23	5	5	7672.66
@@ -2166,7 +2166,7 @@ sub1.cd, sub1.s1
 from (select p_mfgr, p_name, 
 count(p_size) over (partition by p_mfgr order by p_name) as cd, 
 p_retailprice, 
-sum(p_retailprice) over w1  as s1
+round(sum(p_retailprice) over w1,2) as s1
 from noop(on part 
 partition by p_mfgr 
 order by p_name) 
@@ -2180,7 +2180,7 @@ sub1.cd, sub1.s1
 from (select p_mfgr, p_name, 
 count(p_size) over (partition by p_mfgr order by p_name) as cd, 
 p_retailprice, 
-sum(p_retailprice) over w1  as s1
+round(sum(p_retailprice) over w1,2) as s1
 from noop(on part 
 partition by p_mfgr 
 order by p_name) 
@@ -2274,7 +2274,7 @@ STAGE PLANS:
                               window frame: PRECEDING(2)~FOLLOWING(2)
                   Statistics: Num rows: 26 Data size: 12974 Basic stats: COMPLETE Column stats: COMPLETE
                   Select Operator
-                    expressions: _col2 (type: string), _col1 (type: string), count_window_0 (type: bigint), sum_window_1 (type: double)
+                    expressions: _col2 (type: string), _col1 (type: string), count_window_0 (type: bigint), round(sum_window_1, 2) (type: double)
                     outputColumnNames: _col0, _col1, _col2, _col3
                     Statistics: Num rows: 26 Data size: 6110 Basic stats: COMPLETE Column stats: COMPLETE
                     File Output Operator
@@ -2296,7 +2296,7 @@ sub1.cd, sub1.s1
 from (select p_mfgr, p_name, 
 count(p_size) over (partition by p_mfgr order by p_name) as cd, 
 p_retailprice, 
-sum(p_retailprice) over w1  as s1
+round(sum(p_retailprice) over w1,2)  as s1
 from noop(on part 
 partition by p_mfgr 
 order by p_name) 
@@ -2310,7 +2310,7 @@ sub1.cd, sub1.s1
 from (select p_mfgr, p_name, 
 count(p_size) over (partition by p_mfgr order by p_name) as cd, 
 p_retailprice, 
-sum(p_retailprice) over w1  as s1
+round(sum(p_retailprice) over w1,2)  as s1
 from noop(on part 
 partition by p_mfgr 
 order by p_name) 
@@ -2320,38 +2320,38 @@ POSTHOOK: type: QUERY
 POSTHOOK: Input: default@part
 #### A masked pattern was here ####
 Manufacturer#1	almond antique burnished rose metallic	2	4100.06
-Manufacturer#1	almond antique burnished rose metallic	2	5702.650000000001
-Manufacturer#1	almond antique chartreuse lavender yellow	3	7117.070000000001
+Manufacturer#1	almond antique burnished rose metallic	2	5702.65
+Manufacturer#1	almond antique chartreuse lavender yellow	3	7117.07
 Manufacturer#1	almond antique salmon chartreuse burlywood	4	7576.58
 Manufacturer#1	almond aquamarine burnished black steel	5	6403.43
 Manufacturer#1	almond aquamarine pink moccasin thistle	6	4649.67
-Manufacturer#2	almond antique violet chocolate turquoise	1	5523.360000000001
+Manufacturer#2	almond antique violet chocolate turquoise	1	5523.36
 Manufacturer#2	almond antique violet turquoise frosted	2	7222.02
 Manufacturer#2	almond aquamarine midnight light salmon	3	8923.62
-Manufacturer#2	almond aquamarine rose maroon antique	4	7232.9400000000005
+Manufacturer#2	almond aquamarine rose maroon antique	4	7232.94
 Manufacturer#2	almond aquamarine sandy cyan gainsboro	5	5432.24
 Manufacturer#3	almond antique chartreuse khaki white	1	4272.34
 Manufacturer#3	almond antique forest lavender goldenrod	2	6195.32
 Manufacturer#3	almond antique metallic orange dim	3	7532.61
-Manufacturer#3	almond antique misty red olive	4	5860.929999999999
+Manufacturer#3	almond antique misty red olive	4	5860.93
 Manufacturer#3	almond antique olive coral navajo	5	4670.66
 Manufacturer#4	almond antique gainsboro frosted violet	1	4202.35
 Manufacturer#4	almond antique violet mint lemon	2	6047.27
-Manufacturer#4	almond aquamarine floral ivory bisque	3	7337.620000000001
-Manufacturer#4	almond aquamarine yellow dodger mint	4	5716.950000000001
-Manufacturer#4	almond azure aquamarine papaya violet	5	4341.530000000001
+Manufacturer#4	almond aquamarine floral ivory bisque	3	7337.62
+Manufacturer#4	almond aquamarine yellow dodger mint	4	5716.95
+Manufacturer#4	almond azure aquamarine papaya violet	5	4341.53
 Manufacturer#5	almond antique blue firebrick mint	1	5190.08
 Manufacturer#5	almond antique medium spring khaki	2	6208.18
 Manufacturer#5	almond antique sky peru orange	3	7672.66
-Manufacturer#5	almond aquamarine dodger light gainsboro	4	5882.970000000001
-Manufacturer#5	almond azure blanched chiffon midnight	5	4271.3099999999995
+Manufacturer#5	almond aquamarine dodger light gainsboro	4	5882.97
+Manufacturer#5	almond azure blanched chiffon midnight	5	4271.31
 PREHOOK: query: -- 14. testPTFJoinWithWindowingWithCount
 explain
 select abc.p_mfgr, abc.p_name, 
 rank() over (distribute by abc.p_mfgr sort by abc.p_name) as r, 
 dense_rank() over (distribute by abc.p_mfgr sort by abc.p_name) as dr, 
 count(abc.p_name) over (distribute by abc.p_mfgr sort by abc.p_name) as cd, 
-abc.p_retailprice, sum(abc.p_retailprice) over (distribute by abc.p_mfgr sort by abc.p_name rows between unbounded preceding and current row) as s1, 
+abc.p_retailprice, round(sum(abc.p_retailprice) over (distribute by abc.p_mfgr sort by abc.p_name rows between unbounded preceding and current row),2) as s1,
 abc.p_size, abc.p_size - lag(abc.p_size,1,abc.p_size) over (distribute by abc.p_mfgr sort by abc.p_name) as deltaSz 
 from noop(on part 
 partition by p_mfgr 
@@ -2364,7 +2364,7 @@ select abc.p_mfgr, abc.p_name,
 rank() over (distribute by abc.p_mfgr sort by abc.p_name) as r, 
 dense_rank() over (distribute by abc.p_mfgr sort by abc.p_name) as dr, 
 count(abc.p_name) over (distribute by abc.p_mfgr sort by abc.p_name) as cd, 
-abc.p_retailprice, sum(abc.p_retailprice) over (distribute by abc.p_mfgr sort by abc.p_name rows between unbounded preceding and current row) as s1, 
+abc.p_retailprice, round(sum(abc.p_retailprice) over (distribute by abc.p_mfgr sort by abc.p_name rows between unbounded preceding and current row),2) as s1,
 abc.p_size, abc.p_size - lag(abc.p_size,1,abc.p_size) over (distribute by abc.p_mfgr sort by abc.p_name) as deltaSz 
 from noop(on part 
 partition by p_mfgr 
@@ -2515,7 +2515,7 @@ STAGE PLANS:
                               isPivotResult: true
                   Statistics: Num rows: 29 Data size: 22243 Basic stats: COMPLETE Column stats: COMPLETE
                   Select Operator
-                    expressions: _col2 (type: string), _col1 (type: string), rank_window_0 (type: int), dense_rank_window_1 (type: int), count_window_2 (type: bigint), _col7 (type: double), sum_window_3 (type: double), _col5 (type: int), (_col5 - lag_window_4) (type: int)
+                    expressions: _col2 (type: string), _col1 (type: string), rank_window_0 (type: int), dense_rank_window_1 (type: int), count_window_2 (type: bigint), _col7 (type: double), round(sum_window_3, 2) (type: double), _col5 (type: int), (_col5 - lag_window_4) (type: int)
                     outputColumnNames: _col0, _col1, _col2, _col3, _col4, _col5, _col6, _col7, _col8
                     Statistics: Num rows: 29 Data size: 7511 Basic stats: COMPLETE Column stats: COMPLETE
                     File Output Operator
@@ -2535,8 +2535,8 @@ STAGE PLANS:
 PREHOOK: query: select abc.p_mfgr, abc.p_name, 
 rank() over (distribute by abc.p_mfgr sort by abc.p_name) as r, 
 dense_rank() over (distribute by abc.p_mfgr sort by abc.p_name) as dr, 
-count(abc.p_name) over (distribute by abc.p_mfgr sort by abc.p_name) as cd, 
-abc.p_retailprice, sum(abc.p_retailprice) over (distribute by abc.p_mfgr sort by abc.p_name rows between unbounded preceding and current row) as s1, 
+count(abc.p_name) over (distribute by abc.p_mfgr sort by abc.p_name) as cd,
+abc.p_retailprice, round(sum(abc.p_retailprice) over (distribute by abc.p_mfgr sort by abc.p_name rows between unbounded preceding and current row),2) as s1,
 abc.p_size, abc.p_size - lag(abc.p_size,1,abc.p_size) over (distribute by abc.p_mfgr sort by abc.p_name) as deltaSz 
 from noop(on part 
 partition by p_mfgr 
@@ -2548,8 +2548,8 @@ PREHOOK: Input: default@part
 POSTHOOK: query: select abc.p_mfgr, abc.p_name, 
 rank() over (distribute by abc.p_mfgr sort by abc.p_name) as r, 
 dense_rank() over (distribute by abc.p_mfgr sort by abc.p_name) as dr, 
-count(abc.p_name) over (distribute by abc.p_mfgr sort by abc.p_name) as cd, 
-abc.p_retailprice, sum(abc.p_retailprice) over (distribute by abc.p_mfgr sort by abc.p_name rows between unbounded preceding and current row) as s1, 
+count(abc.p_name) over (distribute by abc.p_mfgr sort by abc.p_name) as cd,
+abc.p_retailprice, round(sum(abc.p_retailprice) over (distribute by abc.p_mfgr sort by abc.p_name rows between unbounded preceding and current row),2) as s1,
 abc.p_size, abc.p_size - lag(abc.p_size,1,abc.p_size) over (distribute by abc.p_mfgr sort by abc.p_name) as deltaSz 
 from noop(on part 
 partition by p_mfgr 
@@ -2560,15 +2560,15 @@ POSTHOOK: Input: default@part
 #### A masked pattern was here ####
 Manufacturer#1	almond antique burnished rose metallic	1	1	4	1173.15	1173.15	2	0
 Manufacturer#1	almond antique burnished rose metallic	1	1	4	1173.15	2346.3	2	0
-Manufacturer#1	almond antique burnished rose metallic	1	1	4	1173.15	3519.4500000000003	2	0
+Manufacturer#1	almond antique burnished rose metallic	1	1	4	1173.15	3519.45	2	0
 Manufacturer#1	almond antique burnished rose metallic	1	1	4	1173.15	4692.6	2	0
-Manufacturer#1	almond antique chartreuse lavender yellow	5	2	5	1753.76	6446.360000000001	34	32
-Manufacturer#1	almond antique salmon chartreuse burlywood	6	3	6	1602.59	8048.950000000001	6	-28
+Manufacturer#1	almond antique chartreuse lavender yellow	5	2	5	1753.76	6446.36	34	32
+Manufacturer#1	almond antique salmon chartreuse burlywood	6	3	6	1602.59	8048.95	6	-28
 Manufacturer#1	almond aquamarine burnished black steel	7	4	7	1414.42	9463.37	28	22
 Manufacturer#1	almond aquamarine pink moccasin thistle	8	5	8	1632.66	11096.03	42	14
 Manufacturer#2	almond antique violet chocolate turquoise	1	1	1	1690.68	1690.68	14	0
 Manufacturer#2	almond antique violet turquoise frosted	2	2	2	1800.7	3491.38	40	26
-Manufacturer#2	almond aquamarine midnight light salmon	3	3	3	2031.98	5523.360000000001	2	-38
+Manufacturer#2	almond aquamarine midnight light salmon	3	3	3	2031.98	5523.36	2	-38
 Manufacturer#2	almond aquamarine rose maroon antique	4	4	4	1698.66	7222.02	25	23
 Manufacturer#2	almond aquamarine sandy cyan gainsboro	5	5	5	1701.6	8923.62	18	-7
 Manufacturer#3	almond antique chartreuse khaki white	1	1	1	1671.68	1671.68	17	0
@@ -2580,9 +2580,9 @@ Manufacturer#4	almond antique gainsboro frosted violet	1	1	1	1620.67	1620.67	10
 Manufacturer#4	almond antique violet mint lemon	2	2	2	1375.42	2996.09	39	29
 Manufacturer#4	almond aquamarine floral ivory bisque	3	3	3	1206.26	4202.35	27	-12
 Manufacturer#4	almond aquamarine yellow dodger mint	4	4	4	1844.92	6047.27	7	-20
-Manufacturer#4	almond azure aquamarine papaya violet	5	5	5	1290.35	7337.620000000001	12	5
+Manufacturer#4	almond azure aquamarine papaya violet	5	5	5	1290.35	7337.62	12	5
 Manufacturer#5	almond antique blue firebrick mint	1	1	1	1789.69	1789.69	31	0
-Manufacturer#5	almond antique medium spring khaki	2	2	2	1611.66	3401.3500000000004	6	-25
+Manufacturer#5	almond antique medium spring khaki	2	2	2	1611.66	3401.35	6	-25
 Manufacturer#5	almond antique sky peru orange	3	3	3	1788.73	5190.08	2	-4
 Manufacturer#5	almond aquamarine dodger light gainsboro	4	4	4	1018.1	6208.18	46	44
 Manufacturer#5	almond azure blanched chiffon midnight	5	5	5	1464.48	7672.66	23	-23
@@ -2725,7 +2725,7 @@ Manufacturer#5	almond azure blanched chiffon midnight	23
 PREHOOK: query: -- 16. testViewAsTableInputToPTF
 create view IF NOT EXISTS mfgr_price_view as 
 select p_mfgr, p_brand, 
-sum(p_retailprice) as s 
+round(sum(p_retailprice),2) as s
 from part 
 group by p_mfgr, p_brand
 PREHOOK: type: CREATEVIEW
@@ -2735,7 +2735,7 @@ PREHOOK: Output: default@mfgr_price_view
 POSTHOOK: query: -- 16. testViewAsTableInputToPTF
 create view IF NOT EXISTS mfgr_price_view as 
 select p_mfgr, p_brand, 
-sum(p_retailprice) as s 
+round(sum(p_retailprice),2) as s
 from part 
 group by p_mfgr, p_brand
 POSTHOOK: type: CREATEVIEW
@@ -2744,7 +2744,7 @@ POSTHOOK: Output: database:default
 POSTHOOK: Output: default@mfgr_price_view
 PREHOOK: query: explain
 select p_mfgr, p_brand, s, 
-sum(s) over w1  as s1
+round(sum(s) over w1,2)  as s1
 from noop(on mfgr_price_view 
 partition by p_mfgr 
 order by p_mfgr)  
@@ -2752,7 +2752,7 @@ window w1 as ( partition by p_mfgr order by p_brand rows between 2 preceding and
 PREHOOK: type: QUERY
 POSTHOOK: query: explain
 select p_mfgr, p_brand, s, 
-sum(s) over w1  as s1
+round(sum(s) over w1,2)  as s1
 from noop(on mfgr_price_view 
 partition by p_mfgr 
 order by p_mfgr)  
@@ -2803,26 +2803,30 @@ STAGE PLANS:
                 mode: mergepartial
                 outputColumnNames: _col0, _col1, _col2
                 Statistics: Num rows: 13 Data size: 2574 Basic stats: COMPLETE Column stats: COMPLETE
-                PTF Operator
-                  Function definitions:
-                      Input definition
-                        input alias: mfgr_price_view
-                        output shape: _col0: string, _col1: string, _col2: double
-                        type: TABLE
-                      Partition table definition
-                        input alias: ptf_1
-                        name: noop
-                        order by: _col0 ASC NULLS FIRST
-                        output shape: _col0: string, _col1: string, _col2: double
-                        partition by: _col0
-                        raw input shape:
+                Select Operator
+                  expressions: _col0 (type: string), _col1 (type: string), round(_col2, 2) (type: double)
+                  outputColumnNames: _col0, _col1, _col2
                   Statistics: Num rows: 13 Data size: 2574 Basic stats: COMPLETE Column stats: COMPLETE
-                  Reduce Output Operator
-                    key expressions: _col0 (type: string), _col1 (type: string)
-                    sort order: ++
-                    Map-reduce partition columns: _col0 (type: string)
+                  PTF Operator
+                    Function definitions:
+                        Input definition
+                          input alias: mfgr_price_view
+                          output shape: _col0: string, _col1: string, _col2: double
+                          type: TABLE
+                        Partition table definition
+                          input alias: ptf_1
+                          name: noop
+                          order by: _col0 ASC NULLS FIRST
+                          output shape: _col0: string, _col1: string, _col2: double
+                          partition by: _col0
+                          raw input shape:
                     Statistics: Num rows: 13 Data size: 2574 Basic stats: COMPLETE Column stats: COMPLETE
-                    value expressions: _col2 (type: double)
+                    Reduce Output Operator
+                      key expressions: _col0 (type: string), _col1 (type: string)
+                      sort order: ++
+                      Map-reduce partition columns: _col0 (type: string)
+                      Statistics: Num rows: 13 Data size: 2574 Basic stats: COMPLETE Column stats: COMPLETE
+                      value expressions: _col2 (type: double)
         Reducer 3 
             Execution mode: llap
             Reduce Operator Tree:
@@ -2851,7 +2855,7 @@ STAGE PLANS:
                               window frame: PRECEDING(2)~CURRENT
                   Statistics: Num rows: 13 Data size: 2574 Basic stats: COMPLETE Column stats: COMPLETE
                   Select Operator
-                    expressions: _col0 (type: string), _col1 (type: string), _col2 (type: double), sum_window_0 (type: double)
+                    expressions: _col0 (type: string), _col1 (type: string), _col2 (type: double), round(sum_window_0, 2) (type: double)
                     outputColumnNames: _col0, _col1, _col2, _col3
                     Statistics: Num rows: 13 Data size: 2678 Basic stats: COMPLETE Column stats: COMPLETE
                     File Output Operator
@@ -2869,7 +2873,7 @@ STAGE PLANS:
         ListSink
 
 PREHOOK: query: select p_mfgr, p_brand, s, 
-sum(s) over w1  as s1
+round(sum(s) over w1,2) as s1
 from noop(on mfgr_price_view 
 partition by p_mfgr 
 order by p_mfgr)  
@@ -2879,7 +2883,7 @@ PREHOOK: Input: default@mfgr_price_view
 PREHOOK: Input: default@part
 #### A masked pattern was here ####
 POSTHOOK: query: select p_mfgr, p_brand, s, 
-sum(s) over w1  as s1
+round(sum(s) over w1,2) as s1
 from noop(on mfgr_price_view 
 partition by p_mfgr 
 order by p_mfgr)  
@@ -2892,15 +2896,15 @@ Manufacturer#1	Brand#12	4800.84	4800.84
 Manufacturer#1	Brand#14	2346.3	7147.14
 Manufacturer#1	Brand#15	1602.59	8749.73
 Manufacturer#2	Brand#22	3491.38	3491.38
-Manufacturer#2	Brand#23	2031.98	5523.360000000001
+Manufacturer#2	Brand#23	2031.98	5523.36
 Manufacturer#2	Brand#24	1698.66	7222.02
-Manufacturer#2	Brand#25	1701.6	5432.240000000001
+Manufacturer#2	Brand#25	1701.6	5432.24
 Manufacturer#3	Brand#31	1671.68	1671.68
 Manufacturer#3	Brand#32	3333.37	5005.05
 Manufacturer#3	Brand#34	1337.29	6342.34
 Manufacturer#3	Brand#35	1190.27	5860.93
-Manufacturer#4	Brand#41	4755.9400000000005	4755.9400000000005
-Manufacturer#4	Brand#42	2581.6800000000003	7337.620000000001
+Manufacturer#4	Brand#41	4755.94	4755.94
+Manufacturer#4	Brand#42	2581.68	7337.62
 Manufacturer#5	Brand#51	1611.66	1611.66
 Manufacturer#5	Brand#52	3254.17	4865.83
 Manufacturer#5	Brand#53	2806.83	7672.66
@@ -2957,7 +2961,7 @@ order by p_name)
 INSERT OVERWRITE TABLE part_4 select p_mfgr, p_name, p_size, 
 rank() over (distribute by p_mfgr sort by p_name) as r, 
 dense_rank() over (distribute by p_mfgr sort by p_name) as dr, 
-sum(p_retailprice) over (distribute by p_mfgr sort by p_name rows between unbounded preceding and current row)  as s  
+round(sum(p_retailprice) over (distribute by p_mfgr sort by p_name rows between unbounded preceding and current row),2)  as s
 INSERT OVERWRITE TABLE part_5 select  p_mfgr,p_name, p_size,  
 round(sum(p_size) over (distribute by p_mfgr sort by p_size range between 5 preceding and current row),1) as s2,
 rank() over (distribute by p_mfgr sort by p_mfgr, p_name) as r, 
@@ -2973,7 +2977,7 @@ order by p_name)
 INSERT OVERWRITE TABLE part_4 select p_mfgr, p_name, p_size, 
 rank() over (distribute by p_mfgr sort by p_name) as r, 
 dense_rank() over (distribute by p_mfgr sort by p_name) as dr, 
-sum(p_retailprice) over (distribute by p_mfgr sort by p_name rows between unbounded preceding and current row)  as s  
+round(sum(p_retailprice) over (distribute by p_mfgr sort by p_name rows between unbounded preceding and current row),2)  as s
 INSERT OVERWRITE TABLE part_5 select  p_mfgr,p_name, p_size,  
 round(sum(p_size) over (distribute by p_mfgr sort by p_size range between 5 preceding and current row),1) as s2,
 rank() over (distribute by p_mfgr sort by p_mfgr, p_name) as r, 
@@ -3089,7 +3093,7 @@ STAGE PLANS:
                               window frame: PRECEDING(MAX)~CURRENT
                   Statistics: Num rows: 26 Data size: 12974 Basic stats: COMPLETE Column stats: COMPLETE
                   Select Operator
-                    expressions: _col2 (type: string), _col1 (type: string), _col5 (type: int), rank_window_0 (type: int), dense_rank_window_1 (type: int), sum_window_2 (type: double)
+                    expressions: _col2 (type: string), _col1 (type: string), _col5 (type: int), rank_window_0 (type: int), dense_rank_window_1 (type: int), round(sum_window_2, 2) (type: double)
                     outputColumnNames: _col0, _col1, _col2, _col3, _col4, _col5
                     Statistics: Num rows: 26 Data size: 6214 Basic stats: COMPLETE Column stats: COMPLETE
                     File Output Operator
@@ -3233,7 +3237,7 @@ order by p_name)
 INSERT OVERWRITE TABLE part_4 select p_mfgr, p_name, p_size, 
 rank() over (distribute by p_mfgr sort by p_name) as r, 
 dense_rank() over (distribute by p_mfgr sort by p_name) as dr, 
-sum(p_retailprice) over (distribute by p_mfgr sort by p_name rows between unbounded preceding and current row)  as s  
+round(sum(p_retailprice) over (distribute by p_mfgr sort by p_name rows between unbounded preceding and current row),2)  as s
 INSERT OVERWRITE TABLE part_5 select  p_mfgr,p_name, p_size,  
 round(sum(p_size) over (distribute by p_mfgr sort by p_size range between 5 preceding and current row),1) as s2,
 rank() over (distribute by p_mfgr sort by p_mfgr, p_name) as r, 
@@ -3251,7 +3255,7 @@ order by p_name)
 INSERT OVERWRITE TABLE part_4 select p_mfgr, p_name, p_size, 
 rank() over (distribute by p_mfgr sort by p_name) as r, 
 dense_rank() over (distribute by p_mfgr sort by p_name) as dr, 
-sum(p_retailprice) over (distribute by p_mfgr sort by p_name rows between unbounded preceding and current row)  as s  
+round(sum(p_retailprice) over (distribute by p_mfgr sort by p_name rows between unbounded preceding and current row),2)  as s
 INSERT OVERWRITE TABLE part_5 select  p_mfgr,p_name, p_size,  
 round(sum(p_size) over (distribute by p_mfgr sort by p_size range between 5 preceding and current row),1) as s2,
 rank() over (distribute by p_mfgr sort by p_mfgr, p_name) as r, 
@@ -3288,12 +3292,12 @@ POSTHOOK: Input: default@part_4
 Manufacturer#1	almond antique burnished rose metallic	2	1	1	1173.15
 Manufacturer#1	almond antique burnished rose metallic	2	1	1	2346.3
 Manufacturer#1	almond antique chartreuse lavender yellow	34	3	2	4100.06
-Manufacturer#1	almond antique salmon chartreuse burlywood	6	4	3	5702.650000000001
-Manufacturer#1	almond aquamarine burnished black steel	28	5	4	7117.070000000001
-Manufacturer#1	almond aquamarine pink moccasin thistle	42	6	5	8749.730000000001
+Manufacturer#1	almond antique salmon chartreuse burlywood	6	4	3	5702.65
+Manufacturer#1	almond aquamarine burnished black steel	28	5	4	7117.07
+Manufacturer#1	almond aquamarine pink moccasin thistle	42	6	5	8749.73
 Manufacturer#2	almond antique violet chocolate turquoise	14	1	1	1690.68
 Manufacturer#2	almond antique violet turquoise frosted	40	2	2	3491.38
-Manufacturer#2	almond aquamarine midnight light salmon	2	3	3	5523.360000000001
+Manufacturer#2	almond aquamarine midnight light salmon	2	3	3	5523.36
 Manufacturer#2	almond aquamarine rose maroon antique	25	4	4	7222.02
 Manufacturer#2	almond aquamarine sandy cyan gainsboro	18	5	5	8923.62
 Manufacturer#3	almond antique chartreuse khaki white	17	1	1	1671.68
@@ -3305,9 +3309,9 @@ Manufacturer#4	almond antique gainsboro frosted violet	10	1	1	1620.67
 Manufacturer#4	almond antique violet mint lemon	39	2	2	2996.09
 Manufacturer#4	almond aquamarine floral ivory bisque	27	3	3	4202.35
 Manufacturer#4	almond aquamarine yellow dodger mint	7	4	4	6047.27
-Manufacturer#4	almond azure aquamarine papaya violet	12	5	5	7337.620000000001
+Manufacturer#4	almond azure aquamarine papaya violet	12	5	5	7337.62
 Manufacturer#5	almond antique blue firebrick mint	31	1	1	1789.69
-Manufacturer#5	almond antique medium spring khaki	6	2	2	3401.3500000000004
+Manufacturer#5	almond antique medium spring khaki	6	2	2	3401.35
 Manufacturer#5	almond antique sky peru orange	2	3	3	5190.08
 Manufacturer#5	almond aquamarine dodger light gainsboro	46	4	4	6208.18
 Manufacturer#5	almond azure blanched chiffon midnight	23	5	5	7672.66


[07/13] hive git commit: HIVE-15520: Improve the sum performance for Range based window (Aihua Xu, reviewed by Yongzhi Chen)

Posted by ai...@apache.org.
http://git-wip-us.apache.org/repos/asf/hive/blob/a28b28f3/ql/src/test/results/clientpositive/llap/windowing.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/llap/windowing.q.out b/ql/src/test/results/clientpositive/llap/windowing.q.out
index 190d13b..175a128 100644
--- a/ql/src/test/results/clientpositive/llap/windowing.q.out
+++ b/ql/src/test/results/clientpositive/llap/windowing.q.out
@@ -4,7 +4,7 @@ PREHOOK: query: -- SORT_QUERY_RESULTS
 select p_mfgr, p_name, p_size,
 rank() over(distribute by p_mfgr sort by p_name) as r,
 dense_rank() over(distribute by p_mfgr sort by p_name) as dr,
-sum(p_retailprice) over (distribute by p_mfgr sort by p_name rows between unbounded preceding and current row) as s1
+round(sum(p_retailprice) over (distribute by p_mfgr sort by p_name rows between unbounded preceding and current row),2) as s1
 from part
 PREHOOK: type: QUERY
 PREHOOK: Input: default@part
@@ -15,7 +15,7 @@ POSTHOOK: query: -- SORT_QUERY_RESULTS
 select p_mfgr, p_name, p_size,
 rank() over(distribute by p_mfgr sort by p_name) as r,
 dense_rank() over(distribute by p_mfgr sort by p_name) as dr,
-sum(p_retailprice) over (distribute by p_mfgr sort by p_name rows between unbounded preceding and current row) as s1
+round(sum(p_retailprice) over (distribute by p_mfgr sort by p_name rows between unbounded preceding and current row),2) as s1
 from part
 POSTHOOK: type: QUERY
 POSTHOOK: Input: default@part
@@ -23,12 +23,12 @@ POSTHOOK: Input: default@part
 Manufacturer#1	almond antique burnished rose metallic	2	1	1	1173.15
 Manufacturer#1	almond antique burnished rose metallic	2	1	1	2346.3
 Manufacturer#1	almond antique chartreuse lavender yellow	34	3	2	4100.06
-Manufacturer#1	almond antique salmon chartreuse burlywood	6	4	3	5702.650000000001
-Manufacturer#1	almond aquamarine burnished black steel	28	5	4	7117.070000000001
-Manufacturer#1	almond aquamarine pink moccasin thistle	42	6	5	8749.730000000001
+Manufacturer#1	almond antique salmon chartreuse burlywood	6	4	3	5702.65
+Manufacturer#1	almond aquamarine burnished black steel	28	5	4	7117.07
+Manufacturer#1	almond aquamarine pink moccasin thistle	42	6	5	8749.73
 Manufacturer#2	almond antique violet chocolate turquoise	14	1	1	1690.68
 Manufacturer#2	almond antique violet turquoise frosted	40	2	2	3491.38
-Manufacturer#2	almond aquamarine midnight light salmon	2	3	3	5523.360000000001
+Manufacturer#2	almond aquamarine midnight light salmon	2	3	3	5523.36
 Manufacturer#2	almond aquamarine rose maroon antique	25	4	4	7222.02
 Manufacturer#2	almond aquamarine sandy cyan gainsboro	18	5	5	8923.62
 Manufacturer#3	almond antique chartreuse khaki white	17	1	1	1671.68
@@ -40,9 +40,9 @@ Manufacturer#4	almond antique gainsboro frosted violet	10	1	1	1620.67
 Manufacturer#4	almond antique violet mint lemon	39	2	2	2996.09
 Manufacturer#4	almond aquamarine floral ivory bisque	27	3	3	4202.35
 Manufacturer#4	almond aquamarine yellow dodger mint	7	4	4	6047.27
-Manufacturer#4	almond azure aquamarine papaya violet	12	5	5	7337.620000000001
+Manufacturer#4	almond azure aquamarine papaya violet	12	5	5	7337.62
 Manufacturer#5	almond antique blue firebrick mint	31	1	1	1789.69
-Manufacturer#5	almond antique medium spring khaki	6	2	2	3401.3500000000004
+Manufacturer#5	almond antique medium spring khaki	6	2	2	3401.35
 Manufacturer#5	almond antique sky peru orange	2	3	3	5190.08
 Manufacturer#5	almond aquamarine dodger light gainsboro	46	4	4	6208.18
 Manufacturer#5	almond azure blanched chiffon midnight	23	5	5	7672.66
@@ -185,7 +185,7 @@ select p_mfgr, p_name,
 rank() over(distribute by p_mfgr sort by p_name) as r, 
 dense_rank() over(distribute by p_mfgr sort by p_name) as dr, 
 count(p_size) over(distribute by p_mfgr sort by p_name) as cd, 
-p_retailprice, sum(p_retailprice) over (distribute by p_mfgr sort by p_name rows between unbounded preceding and current row) as s1, 
+p_retailprice, round(sum(p_retailprice) over (distribute by p_mfgr sort by p_name rows between unbounded preceding and current row),2) as s1,
 p_size, p_size - lag(p_size,1,p_size) over(distribute by p_mfgr sort by p_name) as deltaSz 
 from part
 PREHOOK: type: QUERY
@@ -196,7 +196,7 @@ select p_mfgr, p_name,
 rank() over(distribute by p_mfgr sort by p_name) as r, 
 dense_rank() over(distribute by p_mfgr sort by p_name) as dr, 
 count(p_size) over(distribute by p_mfgr sort by p_name) as cd, 
-p_retailprice, sum(p_retailprice) over (distribute by p_mfgr sort by p_name rows between unbounded preceding and current row) as s1, 
+p_retailprice, round(sum(p_retailprice) over (distribute by p_mfgr sort by p_name rows between unbounded preceding and current row),2) as s1,
 p_size, p_size - lag(p_size,1,p_size) over(distribute by p_mfgr sort by p_name) as deltaSz 
 from part
 POSTHOOK: type: QUERY
@@ -205,12 +205,12 @@ POSTHOOK: Input: default@part
 Manufacturer#1	almond antique burnished rose metallic	1	1	2	1173.15	1173.15	2	0
 Manufacturer#1	almond antique burnished rose metallic	1	1	2	1173.15	2346.3	2	0
 Manufacturer#1	almond antique chartreuse lavender yellow	3	2	3	1753.76	4100.06	34	32
-Manufacturer#1	almond antique salmon chartreuse burlywood	4	3	4	1602.59	5702.650000000001	6	-28
-Manufacturer#1	almond aquamarine burnished black steel	5	4	5	1414.42	7117.070000000001	28	22
-Manufacturer#1	almond aquamarine pink moccasin thistle	6	5	6	1632.66	8749.730000000001	42	14
+Manufacturer#1	almond antique salmon chartreuse burlywood	4	3	4	1602.59	5702.65	6	-28
+Manufacturer#1	almond aquamarine burnished black steel	5	4	5	1414.42	7117.07	28	22
+Manufacturer#1	almond aquamarine pink moccasin thistle	6	5	6	1632.66	8749.73	42	14
 Manufacturer#2	almond antique violet chocolate turquoise	1	1	1	1690.68	1690.68	14	0
 Manufacturer#2	almond antique violet turquoise frosted	2	2	2	1800.7	3491.38	40	26
-Manufacturer#2	almond aquamarine midnight light salmon	3	3	3	2031.98	5523.360000000001	2	-38
+Manufacturer#2	almond aquamarine midnight light salmon	3	3	3	2031.98	5523.36	2	-38
 Manufacturer#2	almond aquamarine rose maroon antique	4	4	4	1698.66	7222.02	25	23
 Manufacturer#2	almond aquamarine sandy cyan gainsboro	5	5	5	1701.6	8923.62	18	-7
 Manufacturer#3	almond antique chartreuse khaki white	1	1	1	1671.68	1671.68	17	0
@@ -222,9 +222,9 @@ Manufacturer#4	almond antique gainsboro frosted violet	1	1	1	1620.67	1620.67	10
 Manufacturer#4	almond antique violet mint lemon	2	2	2	1375.42	2996.09	39	29
 Manufacturer#4	almond aquamarine floral ivory bisque	3	3	3	1206.26	4202.35	27	-12
 Manufacturer#4	almond aquamarine yellow dodger mint	4	4	4	1844.92	6047.27	7	-20
-Manufacturer#4	almond azure aquamarine papaya violet	5	5	5	1290.35	7337.620000000001	12	5
+Manufacturer#4	almond azure aquamarine papaya violet	5	5	5	1290.35	7337.62	12	5
 Manufacturer#5	almond antique blue firebrick mint	1	1	1	1789.69	1789.69	31	0
-Manufacturer#5	almond antique medium spring khaki	2	2	2	1611.66	3401.3500000000004	6	-25
+Manufacturer#5	almond antique medium spring khaki	2	2	2	1611.66	3401.35	6	-25
 Manufacturer#5	almond antique sky peru orange	3	3	3	1788.73	5190.08	2	-4
 Manufacturer#5	almond aquamarine dodger light gainsboro	4	4	4	1018.1	6208.18	46	44
 Manufacturer#5	almond azure blanched chiffon midnight	5	5	5	1464.48	7672.66	23	-23
@@ -234,7 +234,7 @@ from (select p_mfgr, p_name,
 rank() over(distribute by p_mfgr sort by p_name) as r, 
 dense_rank() over(distribute by p_mfgr sort by p_name) as dr, 
 count(p_size) over(distribute by p_mfgr sort by p_name) as cd, 
-p_retailprice, sum(p_retailprice) over (distribute by p_mfgr sort by p_name rows between unbounded preceding and current row) as s1, 
+p_retailprice, round(sum(p_retailprice) over (distribute by p_mfgr sort by p_name rows between unbounded preceding and current row),2) as s1,
 p_size, p_size - lag(p_size,1,p_size) over(distribute by p_mfgr sort by p_name) as deltaSz 
 from part 
 ) sub1
@@ -247,7 +247,7 @@ from (select p_mfgr, p_name,
 rank() over(distribute by p_mfgr sort by p_name) as r, 
 dense_rank() over(distribute by p_mfgr sort by p_name) as dr, 
 count(p_size) over(distribute by p_mfgr sort by p_name) as cd, 
-p_retailprice, sum(p_retailprice) over (distribute by p_mfgr sort by p_name rows between unbounded preceding and current row) as s1, 
+p_retailprice, round(sum(p_retailprice) over (distribute by p_mfgr sort by p_name rows between unbounded preceding and current row),2) as s1,
 p_size, p_size - lag(p_size,1,p_size) over(distribute by p_mfgr sort by p_name) as deltaSz 
 from part 
 ) sub1
@@ -262,29 +262,29 @@ POSTHOOK: Input: default@part
 1	1	2	2346.3	0
 2	2	2	2861.95	-3
 2	2	2	2996.09	29
-2	2	2	3401.3500000000004	-25
+2	2	2	3401.35	-25
 2	2	2	3491.38	26
 3	2	3	4100.06	32
 3	3	3	4202.35	-12
 3	3	3	4272.34	5
 3	3	3	5190.08	-4
-3	3	3	5523.360000000001	-38
-4	3	4	5702.650000000001	-28
+3	3	3	5523.36	-38
+4	3	4	5702.65	-28
 4	4	4	6047.27	-20
 4	4	4	6195.32	-18
 4	4	4	6208.18	44
 4	4	4	7222.02	23
-5	4	5	7117.070000000001	22
-5	5	5	7337.620000000001	5
+5	4	5	7117.07	22
+5	5	5	7337.62	5
 5	5	5	7532.61	44
 5	5	5	7672.66	-23
 5	5	5	8923.62	-7
-6	5	6	8749.730000000001	14
+6	5	6	8749.73	14
 PREHOOK: query: -- 7. testJoinWithWindowingAndPTF
 select abc.p_mfgr, abc.p_name, 
 rank() over(distribute by abc.p_mfgr sort by abc.p_name) as r, 
 dense_rank() over(distribute by abc.p_mfgr sort by abc.p_name) as dr, 
-abc.p_retailprice, sum(abc.p_retailprice) over (distribute by abc.p_mfgr sort by abc.p_name rows between unbounded preceding and current row) as s1, 
+abc.p_retailprice, round(sum(abc.p_retailprice) over (distribute by abc.p_mfgr sort by abc.p_name rows between unbounded preceding and current row),2) as s1,
 abc.p_size, abc.p_size - lag(abc.p_size,1,abc.p_size) over(distribute by abc.p_mfgr sort by abc.p_name) as deltaSz 
 from noop(on part 
 partition by p_mfgr 
@@ -297,7 +297,7 @@ POSTHOOK: query: -- 7. testJoinWithWindowingAndPTF
 select abc.p_mfgr, abc.p_name, 
 rank() over(distribute by abc.p_mfgr sort by abc.p_name) as r, 
 dense_rank() over(distribute by abc.p_mfgr sort by abc.p_name) as dr, 
-abc.p_retailprice, sum(abc.p_retailprice) over (distribute by abc.p_mfgr sort by abc.p_name rows between unbounded preceding and current row) as s1, 
+abc.p_retailprice, round(sum(abc.p_retailprice) over (distribute by abc.p_mfgr sort by abc.p_name rows between unbounded preceding and current row),2) as s1,
 abc.p_size, abc.p_size - lag(abc.p_size,1,abc.p_size) over(distribute by abc.p_mfgr sort by abc.p_name) as deltaSz 
 from noop(on part 
 partition by p_mfgr 
@@ -308,15 +308,15 @@ POSTHOOK: Input: default@part
 #### A masked pattern was here ####
 Manufacturer#1	almond antique burnished rose metallic	1	1	1173.15	1173.15	2	0
 Manufacturer#1	almond antique burnished rose metallic	1	1	1173.15	2346.3	2	0
-Manufacturer#1	almond antique burnished rose metallic	1	1	1173.15	3519.4500000000003	2	0
+Manufacturer#1	almond antique burnished rose metallic	1	1	1173.15	3519.45	2	0
 Manufacturer#1	almond antique burnished rose metallic	1	1	1173.15	4692.6	2	0
-Manufacturer#1	almond antique chartreuse lavender yellow	5	2	1753.76	6446.360000000001	34	32
-Manufacturer#1	almond antique salmon chartreuse burlywood	6	3	1602.59	8048.950000000001	6	-28
+Manufacturer#1	almond antique chartreuse lavender yellow	5	2	1753.76	6446.36	34	32
+Manufacturer#1	almond antique salmon chartreuse burlywood	6	3	1602.59	8048.95	6	-28
 Manufacturer#1	almond aquamarine burnished black steel	7	4	1414.42	9463.37	28	22
 Manufacturer#1	almond aquamarine pink moccasin thistle	8	5	1632.66	11096.03	42	14
 Manufacturer#2	almond antique violet chocolate turquoise	1	1	1690.68	1690.68	14	0
 Manufacturer#2	almond antique violet turquoise frosted	2	2	1800.7	3491.38	40	26
-Manufacturer#2	almond aquamarine midnight light salmon	3	3	2031.98	5523.360000000001	2	-38
+Manufacturer#2	almond aquamarine midnight light salmon	3	3	2031.98	5523.36	2	-38
 Manufacturer#2	almond aquamarine rose maroon antique	4	4	1698.66	7222.02	25	23
 Manufacturer#2	almond aquamarine sandy cyan gainsboro	5	5	1701.6	8923.62	18	-7
 Manufacturer#3	almond antique chartreuse khaki white	1	1	1671.68	1671.68	17	0
@@ -328,9 +328,9 @@ Manufacturer#4	almond antique gainsboro frosted violet	1	1	1620.67	1620.67	10	0
 Manufacturer#4	almond antique violet mint lemon	2	2	1375.42	2996.09	39	29
 Manufacturer#4	almond aquamarine floral ivory bisque	3	3	1206.26	4202.35	27	-12
 Manufacturer#4	almond aquamarine yellow dodger mint	4	4	1844.92	6047.27	7	-20
-Manufacturer#4	almond azure aquamarine papaya violet	5	5	1290.35	7337.620000000001	12	5
+Manufacturer#4	almond azure aquamarine papaya violet	5	5	1290.35	7337.62	12	5
 Manufacturer#5	almond antique blue firebrick mint	1	1	1789.69	1789.69	31	0
-Manufacturer#5	almond antique medium spring khaki	2	2	1611.66	3401.3500000000004	6	-25
+Manufacturer#5	almond antique medium spring khaki	2	2	1611.66	3401.35	6	-25
 Manufacturer#5	almond antique sky peru orange	3	3	1788.73	5190.08	2	-4
 Manufacturer#5	almond aquamarine dodger light gainsboro	4	4	1018.1	6208.18	46	44
 Manufacturer#5	almond azure blanched chiffon midnight	5	5	1464.48	7672.66	23	-23
@@ -378,7 +378,7 @@ PREHOOK: query: -- 9. testHavingWithWindowingNoGBY
 select p_mfgr, p_name, p_size, 
 rank() over(distribute by p_mfgr sort by p_name) as r, 
 dense_rank() over(distribute by p_mfgr sort by p_name) as dr, 
-sum(p_retailprice) over (distribute by p_mfgr sort by p_name rows between unbounded preceding and current row)  as s1
+round(sum(p_retailprice) over (distribute by p_mfgr sort by p_name rows between unbounded preceding and current row),2)  as s1
 from part
 PREHOOK: type: QUERY
 PREHOOK: Input: default@part
@@ -387,7 +387,7 @@ POSTHOOK: query: -- 9. testHavingWithWindowingNoGBY
 select p_mfgr, p_name, p_size, 
 rank() over(distribute by p_mfgr sort by p_name) as r, 
 dense_rank() over(distribute by p_mfgr sort by p_name) as dr, 
-sum(p_retailprice) over (distribute by p_mfgr sort by p_name rows between unbounded preceding and current row)  as s1
+round(sum(p_retailprice) over (distribute by p_mfgr sort by p_name rows between unbounded preceding and current row),2)  as s1
 from part
 POSTHOOK: type: QUERY
 POSTHOOK: Input: default@part
@@ -395,12 +395,12 @@ POSTHOOK: Input: default@part
 Manufacturer#1	almond antique burnished rose metallic	2	1	1	1173.15
 Manufacturer#1	almond antique burnished rose metallic	2	1	1	2346.3
 Manufacturer#1	almond antique chartreuse lavender yellow	34	3	2	4100.06
-Manufacturer#1	almond antique salmon chartreuse burlywood	6	4	3	5702.650000000001
-Manufacturer#1	almond aquamarine burnished black steel	28	5	4	7117.070000000001
-Manufacturer#1	almond aquamarine pink moccasin thistle	42	6	5	8749.730000000001
+Manufacturer#1	almond antique salmon chartreuse burlywood	6	4	3	5702.65
+Manufacturer#1	almond aquamarine burnished black steel	28	5	4	7117.07
+Manufacturer#1	almond aquamarine pink moccasin thistle	42	6	5	8749.73
 Manufacturer#2	almond antique violet chocolate turquoise	14	1	1	1690.68
 Manufacturer#2	almond antique violet turquoise frosted	40	2	2	3491.38
-Manufacturer#2	almond aquamarine midnight light salmon	2	3	3	5523.360000000001
+Manufacturer#2	almond aquamarine midnight light salmon	2	3	3	5523.36
 Manufacturer#2	almond aquamarine rose maroon antique	25	4	4	7222.02
 Manufacturer#2	almond aquamarine sandy cyan gainsboro	18	5	5	8923.62
 Manufacturer#3	almond antique chartreuse khaki white	17	1	1	1671.68
@@ -412,9 +412,9 @@ Manufacturer#4	almond antique gainsboro frosted violet	10	1	1	1620.67
 Manufacturer#4	almond antique violet mint lemon	39	2	2	2996.09
 Manufacturer#4	almond aquamarine floral ivory bisque	27	3	3	4202.35
 Manufacturer#4	almond aquamarine yellow dodger mint	7	4	4	6047.27
-Manufacturer#4	almond azure aquamarine papaya violet	12	5	5	7337.620000000001
+Manufacturer#4	almond azure aquamarine papaya violet	12	5	5	7337.62
 Manufacturer#5	almond antique blue firebrick mint	31	1	1	1789.69
-Manufacturer#5	almond antique medium spring khaki	6	2	2	3401.3500000000004
+Manufacturer#5	almond antique medium spring khaki	6	2	2	3401.35
 Manufacturer#5	almond antique sky peru orange	2	3	3	5190.08
 Manufacturer#5	almond aquamarine dodger light gainsboro	46	4	4	6208.18
 Manufacturer#5	almond azure blanched chiffon midnight	23	5	5	7672.66
@@ -422,7 +422,7 @@ PREHOOK: query: -- 10. testHavingWithWindowingCondRankNoGBY
 select p_mfgr, p_name, p_size, 
 rank() over(distribute by p_mfgr sort by p_name) as r, 
 dense_rank() over(distribute by p_mfgr sort by p_name) as dr, 
-sum(p_retailprice) over (distribute by p_mfgr sort by p_name rows between unbounded preceding and current row) as s1 
+round(sum(p_retailprice) over (distribute by p_mfgr sort by p_name rows between unbounded preceding and current row),2) as s1
 from part
 PREHOOK: type: QUERY
 PREHOOK: Input: default@part
@@ -431,7 +431,7 @@ POSTHOOK: query: -- 10. testHavingWithWindowingCondRankNoGBY
 select p_mfgr, p_name, p_size, 
 rank() over(distribute by p_mfgr sort by p_name) as r, 
 dense_rank() over(distribute by p_mfgr sort by p_name) as dr, 
-sum(p_retailprice) over (distribute by p_mfgr sort by p_name rows between unbounded preceding and current row) as s1 
+round(sum(p_retailprice) over (distribute by p_mfgr sort by p_name rows between unbounded preceding and current row),2) as s1
 from part
 POSTHOOK: type: QUERY
 POSTHOOK: Input: default@part
@@ -439,12 +439,12 @@ POSTHOOK: Input: default@part
 Manufacturer#1	almond antique burnished rose metallic	2	1	1	1173.15
 Manufacturer#1	almond antique burnished rose metallic	2	1	1	2346.3
 Manufacturer#1	almond antique chartreuse lavender yellow	34	3	2	4100.06
-Manufacturer#1	almond antique salmon chartreuse burlywood	6	4	3	5702.650000000001
-Manufacturer#1	almond aquamarine burnished black steel	28	5	4	7117.070000000001
-Manufacturer#1	almond aquamarine pink moccasin thistle	42	6	5	8749.730000000001
+Manufacturer#1	almond antique salmon chartreuse burlywood	6	4	3	5702.65
+Manufacturer#1	almond aquamarine burnished black steel	28	5	4	7117.07
+Manufacturer#1	almond aquamarine pink moccasin thistle	42	6	5	8749.73
 Manufacturer#2	almond antique violet chocolate turquoise	14	1	1	1690.68
 Manufacturer#2	almond antique violet turquoise frosted	40	2	2	3491.38
-Manufacturer#2	almond aquamarine midnight light salmon	2	3	3	5523.360000000001
+Manufacturer#2	almond aquamarine midnight light salmon	2	3	3	5523.36
 Manufacturer#2	almond aquamarine rose maroon antique	25	4	4	7222.02
 Manufacturer#2	almond aquamarine sandy cyan gainsboro	18	5	5	8923.62
 Manufacturer#3	almond antique chartreuse khaki white	17	1	1	1671.68
@@ -456,9 +456,9 @@ Manufacturer#4	almond antique gainsboro frosted violet	10	1	1	1620.67
 Manufacturer#4	almond antique violet mint lemon	39	2	2	2996.09
 Manufacturer#4	almond aquamarine floral ivory bisque	27	3	3	4202.35
 Manufacturer#4	almond aquamarine yellow dodger mint	7	4	4	6047.27
-Manufacturer#4	almond azure aquamarine papaya violet	12	5	5	7337.620000000001
+Manufacturer#4	almond azure aquamarine papaya violet	12	5	5	7337.62
 Manufacturer#5	almond antique blue firebrick mint	31	1	1	1789.69
-Manufacturer#5	almond antique medium spring khaki	6	2	2	3401.3500000000004
+Manufacturer#5	almond antique medium spring khaki	6	2	2	3401.35
 Manufacturer#5	almond antique sky peru orange	2	3	3	5190.08
 Manufacturer#5	almond aquamarine dodger light gainsboro	46	4	4	6208.18
 Manufacturer#5	almond azure blanched chiffon midnight	23	5	5	7672.66
@@ -785,10 +785,10 @@ Manufacturer#5	almond aquamarine dodger light gainsboro	46	4	4	6
 Manufacturer#5	almond azure blanched chiffon midnight	23	5	5	2
 PREHOOK: query: -- 18. testUDAFs
 select  p_mfgr,p_name, p_size, 
-sum(p_retailprice) over w1 as s, 
+round(sum(p_retailprice) over w1,2) as s,
 min(p_retailprice) over w1 as mi,
 max(p_retailprice) over w1 as ma,
-avg(p_retailprice) over w1 as ag
+round(avg(p_retailprice) over w1,2) as ag
 from part
 window w1 as (distribute by p_mfgr sort by p_mfgr, p_name rows between 2 preceding and 2 following)
 PREHOOK: type: QUERY
@@ -796,47 +796,47 @@ PREHOOK: Input: default@part
 #### A masked pattern was here ####
 POSTHOOK: query: -- 18. testUDAFs
 select  p_mfgr,p_name, p_size, 
-sum(p_retailprice) over w1 as s, 
+round(sum(p_retailprice) over w1,2) as s,
 min(p_retailprice) over w1 as mi,
 max(p_retailprice) over w1 as ma,
-avg(p_retailprice) over w1 as ag
+round(avg(p_retailprice) over w1,2) as ag
 from part
 window w1 as (distribute by p_mfgr sort by p_mfgr, p_name rows between 2 preceding and 2 following)
 POSTHOOK: type: QUERY
 POSTHOOK: Input: default@part
 #### A masked pattern was here ####
-Manufacturer#1	almond antique burnished rose metallic	2	4100.06	1173.15	1753.76	1366.6866666666667
-Manufacturer#1	almond antique burnished rose metallic	2	5702.650000000001	1173.15	1753.76	1425.6625000000001
-Manufacturer#1	almond antique chartreuse lavender yellow	34	7117.070000000001	1173.15	1753.76	1423.4140000000002
-Manufacturer#1	almond antique salmon chartreuse burlywood	6	7576.580000000002	1173.15	1753.76	1515.3160000000003
-Manufacturer#1	almond aquamarine burnished black steel	28	6403.430000000001	1414.42	1753.76	1600.8575000000003
-Manufacturer#1	almond aquamarine pink moccasin thistle	42	4649.670000000001	1414.42	1632.66	1549.8900000000003
-Manufacturer#2	almond antique violet chocolate turquoise	14	5523.360000000001	1690.68	2031.98	1841.1200000000001
-Manufacturer#2	almond antique violet turquoise frosted	40	7222.02	1690.68	2031.98	1805.505
-Manufacturer#2	almond aquamarine midnight light salmon	2	8923.62	1690.68	2031.98	1784.7240000000002
-Manufacturer#2	almond aquamarine rose maroon antique	25	7232.9400000000005	1698.66	2031.98	1808.2350000000001
-Manufacturer#2	almond aquamarine sandy cyan gainsboro	18	5432.240000000001	1698.66	2031.98	1810.746666666667
-Manufacturer#3	almond antique chartreuse khaki white	17	4272.34	1190.27	1671.68	1424.1133333333335
+Manufacturer#1	almond antique burnished rose metallic	2	4100.06	1173.15	1753.76	1366.69
+Manufacturer#1	almond antique burnished rose metallic	2	5702.65	1173.15	1753.76	1425.66
+Manufacturer#1	almond antique chartreuse lavender yellow	34	7117.07	1173.15	1753.76	1423.41
+Manufacturer#1	almond antique salmon chartreuse burlywood	6	7576.58	1173.15	1753.76	1515.32
+Manufacturer#1	almond aquamarine burnished black steel	28	6403.43	1414.42	1753.76	1600.86
+Manufacturer#1	almond aquamarine pink moccasin thistle	42	4649.67	1414.42	1632.66	1549.89
+Manufacturer#2	almond antique violet chocolate turquoise	14	5523.36	1690.68	2031.98	1841.12
+Manufacturer#2	almond antique violet turquoise frosted	40	7222.02	1690.68	2031.98	1805.51
+Manufacturer#2	almond aquamarine midnight light salmon	2	8923.62	1690.68	2031.98	1784.72
+Manufacturer#2	almond aquamarine rose maroon antique	25	7232.94	1698.66	2031.98	1808.24
+Manufacturer#2	almond aquamarine sandy cyan gainsboro	18	5432.24	1698.66	2031.98	1810.75
+Manufacturer#3	almond antique chartreuse khaki white	17	4272.34	1190.27	1671.68	1424.11
 Manufacturer#3	almond antique forest lavender goldenrod	14	6195.32	1190.27	1922.98	1548.83
-Manufacturer#3	almond antique metallic orange dim	19	7532.61	1190.27	1922.98	1506.522
-Manufacturer#3	almond antique misty red olive	1	5860.929999999999	1190.27	1922.98	1465.2324999999998
-Manufacturer#3	almond antique olive coral navajo	45	4670.66	1337.29	1922.98	1556.8866666666665
-Manufacturer#4	almond antique gainsboro frosted violet	10	4202.35	1206.26	1620.67	1400.7833333333335
-Manufacturer#4	almond antique violet mint lemon	39	6047.27	1206.26	1844.92	1511.8175
-Manufacturer#4	almond aquamarine floral ivory bisque	27	7337.620000000001	1206.26	1844.92	1467.5240000000001
-Manufacturer#4	almond aquamarine yellow dodger mint	7	5716.950000000001	1206.26	1844.92	1429.2375000000002
-Manufacturer#4	almond azure aquamarine papaya violet	12	4341.530000000001	1206.26	1844.92	1447.176666666667
-Manufacturer#5	almond antique blue firebrick mint	31	5190.08	1611.66	1789.69	1730.0266666666666
-Manufacturer#5	almond antique medium spring khaki	6	6208.18	1018.1	1789.69	1552.045
-Manufacturer#5	almond antique sky peru orange	2	7672.66	1018.1	1789.69	1534.532
-Manufacturer#5	almond aquamarine dodger light gainsboro	46	5882.969999999999	1018.1	1788.73	1470.7424999999998
-Manufacturer#5	almond azure blanched chiffon midnight	23	4271.3099999999995	1018.1	1788.73	1423.7699999999998
+Manufacturer#3	almond antique metallic orange dim	19	7532.61	1190.27	1922.98	1506.52
+Manufacturer#3	almond antique misty red olive	1	5860.93	1190.27	1922.98	1465.23
+Manufacturer#3	almond antique olive coral navajo	45	4670.66	1337.29	1922.98	1556.89
+Manufacturer#4	almond antique gainsboro frosted violet	10	4202.35	1206.26	1620.67	1400.78
+Manufacturer#4	almond antique violet mint lemon	39	6047.27	1206.26	1844.92	1511.82
+Manufacturer#4	almond aquamarine floral ivory bisque	27	7337.62	1206.26	1844.92	1467.52
+Manufacturer#4	almond aquamarine yellow dodger mint	7	5716.95	1206.26	1844.92	1429.24
+Manufacturer#4	almond azure aquamarine papaya violet	12	4341.53	1206.26	1844.92	1447.18
+Manufacturer#5	almond antique blue firebrick mint	31	5190.08	1611.66	1789.69	1730.03
+Manufacturer#5	almond antique medium spring khaki	6	6208.18	1018.1	1789.69	1552.05
+Manufacturer#5	almond antique sky peru orange	2	7672.66	1018.1	1789.69	1534.53
+Manufacturer#5	almond aquamarine dodger light gainsboro	46	5882.97	1018.1	1788.73	1470.74
+Manufacturer#5	almond azure blanched chiffon midnight	23	4271.31	1018.1	1788.73	1423.77
 PREHOOK: query: -- 19. testUDAFsWithGBY
 select  p_mfgr,p_name, p_size, p_retailprice, 
-sum(p_retailprice) over w1 as s, 
+round(sum(p_retailprice) over w1,2) as s,
 min(p_retailprice) as mi ,
 max(p_retailprice) as ma ,
-avg(p_retailprice) over w1 as ag
+round(avg(p_retailprice) over w1,2) as ag
 from part
 group by p_mfgr,p_name, p_size, p_retailprice
 window w1 as (distribute by p_mfgr sort by p_mfgr, p_name rows between 2 preceding and 2 following)
@@ -845,41 +845,41 @@ PREHOOK: Input: default@part
 #### A masked pattern was here ####
 POSTHOOK: query: -- 19. testUDAFsWithGBY
 select  p_mfgr,p_name, p_size, p_retailprice, 
-sum(p_retailprice) over w1 as s, 
+round(sum(p_retailprice) over w1,2) as s,
 min(p_retailprice) as mi ,
 max(p_retailprice) as ma ,
-avg(p_retailprice) over w1 as ag
+round(avg(p_retailprice) over w1,2) as ag
 from part
 group by p_mfgr,p_name, p_size, p_retailprice
 window w1 as (distribute by p_mfgr sort by p_mfgr, p_name rows between 2 preceding and 2 following)
 POSTHOOK: type: QUERY
 POSTHOOK: Input: default@part
 #### A masked pattern was here ####
-Manufacturer#1	almond antique burnished rose metallic	2	1173.15	4529.5	1173.15	1173.15	1509.8333333333333
+Manufacturer#1	almond antique burnished rose metallic	2	1173.15	4529.5	1173.15	1173.15	1509.83
 Manufacturer#1	almond antique chartreuse lavender yellow	34	1753.76	5943.92	1753.76	1753.76	1485.98
-Manufacturer#1	almond antique salmon chartreuse burlywood	6	1602.59	7576.58	1602.59	1602.59	1515.316
-Manufacturer#1	almond aquamarine burnished black steel	28	1414.42	6403.43	1414.42	1414.42	1600.8575
+Manufacturer#1	almond antique salmon chartreuse burlywood	6	1602.59	7576.58	1602.59	1602.59	1515.32
+Manufacturer#1	almond aquamarine burnished black steel	28	1414.42	6403.43	1414.42	1414.42	1600.86
 Manufacturer#1	almond aquamarine pink moccasin thistle	42	1632.66	4649.67	1632.66	1632.66	1549.89
-Manufacturer#2	almond antique violet chocolate turquoise	14	1690.68	5523.360000000001	1690.68	1690.68	1841.1200000000001
-Manufacturer#2	almond antique violet turquoise frosted	40	1800.7	7222.02	1800.7	1800.7	1805.505
-Manufacturer#2	almond aquamarine midnight light salmon	2	2031.98	8923.62	2031.98	2031.98	1784.7240000000002
-Manufacturer#2	almond aquamarine rose maroon antique	25	1698.66	7232.9400000000005	1698.66	1698.66	1808.2350000000001
-Manufacturer#2	almond aquamarine sandy cyan gainsboro	18	1701.6	5432.240000000001	1701.6	1701.6	1810.746666666667
-Manufacturer#3	almond antique chartreuse khaki white	17	1671.68	4272.34	1671.68	1671.68	1424.1133333333335
+Manufacturer#2	almond antique violet chocolate turquoise	14	1690.68	5523.36	1690.68	1690.68	1841.12
+Manufacturer#2	almond antique violet turquoise frosted	40	1800.7	7222.02	1800.7	1800.7	1805.51
+Manufacturer#2	almond aquamarine midnight light salmon	2	2031.98	8923.62	2031.98	2031.98	1784.72
+Manufacturer#2	almond aquamarine rose maroon antique	25	1698.66	7232.94	1698.66	1698.66	1808.24
+Manufacturer#2	almond aquamarine sandy cyan gainsboro	18	1701.6	5432.24	1701.6	1701.6	1810.75
+Manufacturer#3	almond antique chartreuse khaki white	17	1671.68	4272.34	1671.68	1671.68	1424.11
 Manufacturer#3	almond antique forest lavender goldenrod	14	1190.27	6195.32	1190.27	1190.27	1548.83
-Manufacturer#3	almond antique metallic orange dim	19	1410.39	7532.61	1410.39	1410.39	1506.522
-Manufacturer#3	almond antique misty red olive	1	1922.98	5860.929999999999	1922.98	1922.98	1465.2324999999998
-Manufacturer#3	almond antique olive coral navajo	45	1337.29	4670.66	1337.29	1337.29	1556.8866666666665
-Manufacturer#4	almond antique gainsboro frosted violet	10	1620.67	4202.35	1620.67	1620.67	1400.7833333333335
-Manufacturer#4	almond antique violet mint lemon	39	1375.42	6047.27	1375.42	1375.42	1511.8175
-Manufacturer#4	almond aquamarine floral ivory bisque	27	1206.26	7337.620000000001	1206.26	1206.26	1467.5240000000001
-Manufacturer#4	almond aquamarine yellow dodger mint	7	1844.92	5716.950000000001	1844.92	1844.92	1429.2375000000002
-Manufacturer#4	almond azure aquamarine papaya violet	12	1290.35	4341.530000000001	1290.35	1290.35	1447.176666666667
-Manufacturer#5	almond antique blue firebrick mint	31	1789.69	5190.08	1789.69	1789.69	1730.0266666666666
-Manufacturer#5	almond antique medium spring khaki	6	1611.66	6208.18	1611.66	1611.66	1552.045
-Manufacturer#5	almond antique sky peru orange	2	1788.73	7672.66	1788.73	1788.73	1534.532
-Manufacturer#5	almond aquamarine dodger light gainsboro	46	1018.1	5882.969999999999	1018.1	1018.1	1470.7424999999998
-Manufacturer#5	almond azure blanched chiffon midnight	23	1464.48	4271.3099999999995	1464.48	1464.48	1423.7699999999998
+Manufacturer#3	almond antique metallic orange dim	19	1410.39	7532.61	1410.39	1410.39	1506.52
+Manufacturer#3	almond antique misty red olive	1	1922.98	5860.93	1922.98	1922.98	1465.23
+Manufacturer#3	almond antique olive coral navajo	45	1337.29	4670.66	1337.29	1337.29	1556.89
+Manufacturer#4	almond antique gainsboro frosted violet	10	1620.67	4202.35	1620.67	1620.67	1400.78
+Manufacturer#4	almond antique violet mint lemon	39	1375.42	6047.27	1375.42	1375.42	1511.82
+Manufacturer#4	almond aquamarine floral ivory bisque	27	1206.26	7337.62	1206.26	1206.26	1467.52
+Manufacturer#4	almond aquamarine yellow dodger mint	7	1844.92	5716.95	1844.92	1844.92	1429.24
+Manufacturer#4	almond azure aquamarine papaya violet	12	1290.35	4341.53	1290.35	1290.35	1447.18
+Manufacturer#5	almond antique blue firebrick mint	31	1789.69	5190.08	1789.69	1789.69	1730.03
+Manufacturer#5	almond antique medium spring khaki	6	1611.66	6208.18	1611.66	1611.66	1552.05
+Manufacturer#5	almond antique sky peru orange	2	1788.73	7672.66	1788.73	1788.73	1534.53
+Manufacturer#5	almond aquamarine dodger light gainsboro	46	1018.1	5882.97	1018.1	1018.1	1470.74
+Manufacturer#5	almond azure blanched chiffon midnight	23	1464.48	4271.31	1464.48	1464.48	1423.77
 PREHOOK: query: -- 20. testSTATs
 select  p_mfgr,p_name, p_size, 
 stddev(p_retailprice) over w1 as sdev, 
@@ -1073,7 +1073,7 @@ Manufacturer#5	Brand#53	2806.83	7672.66
 PREHOOK: query: -- 23. testCreateViewWithWindowingQuery
 create view IF NOT EXISTS mfgr_brand_price_view as 
 select p_mfgr, p_brand, 
-sum(p_retailprice) over w1  as s
+round(sum(p_retailprice) over w1,2) as s
 from part 
 window w1 as (distribute by p_mfgr sort by p_name rows between 2 preceding and current row)
 PREHOOK: type: CREATEVIEW
@@ -1083,7 +1083,7 @@ PREHOOK: Output: default@mfgr_brand_price_view
 POSTHOOK: query: -- 23. testCreateViewWithWindowingQuery
 create view IF NOT EXISTS mfgr_brand_price_view as 
 select p_mfgr, p_brand, 
-sum(p_retailprice) over w1  as s
+round(sum(p_retailprice) over w1,2) as s
 from part 
 window w1 as (distribute by p_mfgr sort by p_name rows between 2 preceding and current row)
 POSTHOOK: type: CREATEVIEW
@@ -1101,29 +1101,29 @@ POSTHOOK: Input: default@mfgr_brand_price_view
 POSTHOOK: Input: default@part
 #### A masked pattern was here ####
 Manufacturer#1	Brand#12	4100.06
-Manufacturer#1	Brand#12	4649.670000000001
+Manufacturer#1	Brand#12	4649.67
 Manufacturer#1	Brand#12	4770.77
 Manufacturer#1	Brand#14	1173.15
 Manufacturer#1	Brand#14	2346.3
 Manufacturer#1	Brand#15	4529.5
 Manufacturer#2	Brand#22	1690.68
 Manufacturer#2	Brand#22	3491.38
-Manufacturer#2	Brand#23	5523.360000000001
+Manufacturer#2	Brand#23	5523.36
 Manufacturer#2	Brand#24	5531.34
-Manufacturer#2	Brand#25	5432.240000000001
+Manufacturer#2	Brand#25	5432.24
 Manufacturer#3	Brand#31	1671.68
 Manufacturer#3	Brand#32	4272.34
-Manufacturer#3	Brand#32	4523.639999999999
+Manufacturer#3	Brand#32	4523.64
 Manufacturer#3	Brand#34	4670.66
 Manufacturer#3	Brand#35	2861.95
 Manufacturer#4	Brand#41	1620.67
-Manufacturer#4	Brand#41	4341.530000000001
+Manufacturer#4	Brand#41	4341.53
 Manufacturer#4	Brand#41	4426.6
 Manufacturer#4	Brand#42	2996.09
 Manufacturer#4	Brand#42	4202.35
-Manufacturer#5	Brand#51	3401.3500000000004
+Manufacturer#5	Brand#51	3401.35
 Manufacturer#5	Brand#52	1789.69
-Manufacturer#5	Brand#52	4271.3099999999995
+Manufacturer#5	Brand#52	4271.31
 Manufacturer#5	Brand#53	4418.49
 Manufacturer#5	Brand#53	5190.08
 PREHOOK: query: -- 24. testLateralViews
@@ -1293,7 +1293,7 @@ INSERT OVERWRITE TABLE part_1
 select p_mfgr, p_name, p_size, 
 rank() over(distribute by p_mfgr sort by p_name ) as r, 
 dense_rank() over(distribute by p_mfgr sort by p_name ) as dr, 
-sum(p_retailprice) over (distribute by p_mfgr sort by p_name rows between unbounded preceding and current row)  as s
+round(sum(p_retailprice) over (distribute by p_mfgr sort by p_name rows between unbounded preceding and current row),2) as s
 INSERT OVERWRITE TABLE part_2 
 select  p_mfgr,p_name, p_size,  
 rank() over(distribute by p_mfgr sort by p_name) as r, 
@@ -1318,7 +1318,7 @@ INSERT OVERWRITE TABLE part_1
 select p_mfgr, p_name, p_size, 
 rank() over(distribute by p_mfgr sort by p_name ) as r, 
 dense_rank() over(distribute by p_mfgr sort by p_name ) as dr, 
-sum(p_retailprice) over (distribute by p_mfgr sort by p_name rows between unbounded preceding and current row)  as s
+round(sum(p_retailprice) over (distribute by p_mfgr sort by p_name rows between unbounded preceding and current row),2) as s
 INSERT OVERWRITE TABLE part_2 
 select  p_mfgr,p_name, p_size,  
 rank() over(distribute by p_mfgr sort by p_name) as r, 
@@ -1369,12 +1369,12 @@ POSTHOOK: Input: default@part_1
 Manufacturer#1	almond antique burnished rose metallic	2	1	1	1173.15
 Manufacturer#1	almond antique burnished rose metallic	2	1	1	2346.3
 Manufacturer#1	almond antique chartreuse lavender yellow	34	3	2	4100.06
-Manufacturer#1	almond antique salmon chartreuse burlywood	6	4	3	5702.650000000001
-Manufacturer#1	almond aquamarine burnished black steel	28	5	4	7117.070000000001
-Manufacturer#1	almond aquamarine pink moccasin thistle	42	6	5	8749.730000000001
+Manufacturer#1	almond antique salmon chartreuse burlywood	6	4	3	5702.65
+Manufacturer#1	almond aquamarine burnished black steel	28	5	4	7117.07
+Manufacturer#1	almond aquamarine pink moccasin thistle	42	6	5	8749.73
 Manufacturer#2	almond antique violet chocolate turquoise	14	1	1	1690.68
 Manufacturer#2	almond antique violet turquoise frosted	40	2	2	3491.38
-Manufacturer#2	almond aquamarine midnight light salmon	2	3	3	5523.360000000001
+Manufacturer#2	almond aquamarine midnight light salmon	2	3	3	5523.36
 Manufacturer#2	almond aquamarine rose maroon antique	25	4	4	7222.02
 Manufacturer#2	almond aquamarine sandy cyan gainsboro	18	5	5	8923.62
 Manufacturer#3	almond antique chartreuse khaki white	17	1	1	1671.68
@@ -1386,9 +1386,9 @@ Manufacturer#4	almond antique gainsboro frosted violet	10	1	1	1620.67
 Manufacturer#4	almond antique violet mint lemon	39	2	2	2996.09
 Manufacturer#4	almond aquamarine floral ivory bisque	27	3	3	4202.35
 Manufacturer#4	almond aquamarine yellow dodger mint	7	4	4	6047.27
-Manufacturer#4	almond azure aquamarine papaya violet	12	5	5	7337.620000000001
+Manufacturer#4	almond azure aquamarine papaya violet	12	5	5	7337.62
 Manufacturer#5	almond antique blue firebrick mint	31	1	1	1789.69
-Manufacturer#5	almond antique medium spring khaki	6	2	2	3401.3500000000004
+Manufacturer#5	almond antique medium spring khaki	6	2	2	3401.35
 Manufacturer#5	almond antique sky peru orange	2	3	3	5190.08
 Manufacturer#5	almond aquamarine dodger light gainsboro	46	4	4	6208.18
 Manufacturer#5	almond azure blanched chiffon midnight	23	5	5	7672.66
@@ -2104,7 +2104,7 @@ Manufacturer#5	7672.66	1018.1	1789.69	1534.53	5
 Manufacturer#5	7672.66	1018.1	1789.69	1534.53	5
 PREHOOK: query: -- 38. testPartitioningVariousForms2
 select p_mfgr, p_name, p_size,
-sum(p_retailprice) over (partition by p_mfgr, p_name order by p_mfgr, p_name rows between unbounded preceding and current row) as s1,
+round(sum(p_retailprice) over (partition by p_mfgr, p_name order by p_mfgr, p_name rows between unbounded preceding and current row),2) as s1,
 min(p_retailprice) over (distribute by p_mfgr, p_name sort by p_mfgr, p_name rows between unbounded preceding and current row) as s2,
 max(p_retailprice) over (partition by p_mfgr, p_name order by p_name) as s3
 from part
@@ -2113,7 +2113,7 @@ PREHOOK: Input: default@part
 #### A masked pattern was here ####
 POSTHOOK: query: -- 38. testPartitioningVariousForms2
 select p_mfgr, p_name, p_size,
-sum(p_retailprice) over (partition by p_mfgr, p_name order by p_mfgr, p_name rows between unbounded preceding and current row) as s1,
+round(sum(p_retailprice) over (partition by p_mfgr, p_name order by p_mfgr, p_name rows between unbounded preceding and current row),2) as s1,
 min(p_retailprice) over (distribute by p_mfgr, p_name sort by p_mfgr, p_name rows between unbounded preceding and current row) as s2,
 max(p_retailprice) over (partition by p_mfgr, p_name order by p_name) as s3
 from part
@@ -2188,14 +2188,14 @@ Manufacturer#5	SMALL PLATED BRASS	MALL PLATED BRASS	4
 Manufacturer#5	STANDARD BURNISHED TIN	TANDARD BURNISHED TIN	5
 PREHOOK: query: -- 40. testNoBetweenForRows
 select p_mfgr, p_name, p_size,
-    sum(p_retailprice) over (distribute by p_mfgr sort by p_name rows unbounded preceding) as s1
+    round(sum(p_retailprice) over (distribute by p_mfgr sort by p_name rows unbounded preceding),2) as s1
      from part
 PREHOOK: type: QUERY
 PREHOOK: Input: default@part
 #### A masked pattern was here ####
 POSTHOOK: query: -- 40. testNoBetweenForRows
 select p_mfgr, p_name, p_size,
-    sum(p_retailprice) over (distribute by p_mfgr sort by p_name rows unbounded preceding) as s1
+    round(sum(p_retailprice) over (distribute by p_mfgr sort by p_name rows unbounded preceding),2) as s1
      from part
 POSTHOOK: type: QUERY
 POSTHOOK: Input: default@part
@@ -2203,12 +2203,12 @@ POSTHOOK: Input: default@part
 Manufacturer#1	almond antique burnished rose metallic	2	1173.15
 Manufacturer#1	almond antique burnished rose metallic	2	2346.3
 Manufacturer#1	almond antique chartreuse lavender yellow	34	4100.06
-Manufacturer#1	almond antique salmon chartreuse burlywood	6	5702.650000000001
-Manufacturer#1	almond aquamarine burnished black steel	28	7117.070000000001
-Manufacturer#1	almond aquamarine pink moccasin thistle	42	8749.730000000001
+Manufacturer#1	almond antique salmon chartreuse burlywood	6	5702.65
+Manufacturer#1	almond aquamarine burnished black steel	28	7117.07
+Manufacturer#1	almond aquamarine pink moccasin thistle	42	8749.73
 Manufacturer#2	almond antique violet chocolate turquoise	14	1690.68
 Manufacturer#2	almond antique violet turquoise frosted	40	3491.38
-Manufacturer#2	almond aquamarine midnight light salmon	2	5523.360000000001
+Manufacturer#2	almond aquamarine midnight light salmon	2	5523.36
 Manufacturer#2	almond aquamarine rose maroon antique	25	7222.02
 Manufacturer#2	almond aquamarine sandy cyan gainsboro	18	8923.62
 Manufacturer#3	almond antique chartreuse khaki white	17	1671.68
@@ -2220,32 +2220,32 @@ Manufacturer#4	almond antique gainsboro frosted violet	10	1620.67
 Manufacturer#4	almond antique violet mint lemon	39	2996.09
 Manufacturer#4	almond aquamarine floral ivory bisque	27	4202.35
 Manufacturer#4	almond aquamarine yellow dodger mint	7	6047.27
-Manufacturer#4	almond azure aquamarine papaya violet	12	7337.620000000001
+Manufacturer#4	almond azure aquamarine papaya violet	12	7337.62
 Manufacturer#5	almond antique blue firebrick mint	31	1789.69
-Manufacturer#5	almond antique medium spring khaki	6	3401.3500000000004
+Manufacturer#5	almond antique medium spring khaki	6	3401.35
 Manufacturer#5	almond antique sky peru orange	2	5190.08
 Manufacturer#5	almond aquamarine dodger light gainsboro	46	6208.18
 Manufacturer#5	almond azure blanched chiffon midnight	23	7672.66
 PREHOOK: query: -- 41. testNoBetweenForRange
 select p_mfgr, p_name, p_size,
-    sum(p_retailprice) over (distribute by p_mfgr sort by p_size range unbounded preceding) as s1
+    round(sum(p_retailprice) over (distribute by p_mfgr sort by p_size range unbounded preceding),2) as s1
      from part
 PREHOOK: type: QUERY
 PREHOOK: Input: default@part
 #### A masked pattern was here ####
 POSTHOOK: query: -- 41. testNoBetweenForRange
 select p_mfgr, p_name, p_size,
-    sum(p_retailprice) over (distribute by p_mfgr sort by p_size range unbounded preceding) as s1
+    round(sum(p_retailprice) over (distribute by p_mfgr sort by p_size range unbounded preceding),2) as s1
      from part
 POSTHOOK: type: QUERY
 POSTHOOK: Input: default@part
 #### A masked pattern was here ####
 Manufacturer#1	almond antique burnished rose metallic	2	2346.3
 Manufacturer#1	almond antique burnished rose metallic	2	2346.3
-Manufacturer#1	almond antique chartreuse lavender yellow	34	7117.070000000001
-Manufacturer#1	almond antique salmon chartreuse burlywood	6	3948.8900000000003
+Manufacturer#1	almond antique chartreuse lavender yellow	34	7117.07
+Manufacturer#1	almond antique salmon chartreuse burlywood	6	3948.89
 Manufacturer#1	almond aquamarine burnished black steel	28	5363.31
-Manufacturer#1	almond aquamarine pink moccasin thistle	42	8749.730000000001
+Manufacturer#1	almond aquamarine pink moccasin thistle	42	8749.73
 Manufacturer#2	almond antique violet chocolate turquoise	14	3722.66
 Manufacturer#2	almond antique violet turquoise frosted	40	8923.62
 Manufacturer#2	almond aquamarine midnight light salmon	2	2031.98
@@ -2253,97 +2253,97 @@ Manufacturer#2	almond aquamarine rose maroon antique	25	7122.92
 Manufacturer#2	almond aquamarine sandy cyan gainsboro	18	5424.26
 Manufacturer#3	almond antique chartreuse khaki white	17	4784.93
 Manufacturer#3	almond antique forest lavender goldenrod	14	3113.25
-Manufacturer#3	almond antique metallic orange dim	19	6195.320000000001
+Manufacturer#3	almond antique metallic orange dim	19	6195.32
 Manufacturer#3	almond antique misty red olive	1	1922.98
-Manufacturer#3	almond antique olive coral navajo	45	7532.610000000001
+Manufacturer#3	almond antique olive coral navajo	45	7532.61
 Manufacturer#4	almond antique gainsboro frosted violet	10	3465.59
-Manufacturer#4	almond antique violet mint lemon	39	7337.620000000001
-Manufacturer#4	almond aquamarine floral ivory bisque	27	5962.200000000001
+Manufacturer#4	almond antique violet mint lemon	39	7337.62
+Manufacturer#4	almond aquamarine floral ivory bisque	27	5962.2
 Manufacturer#4	almond aquamarine yellow dodger mint	7	1844.92
-Manufacturer#4	almond azure aquamarine papaya violet	12	4755.9400000000005
-Manufacturer#5	almond antique blue firebrick mint	31	6654.560000000001
-Manufacturer#5	almond antique medium spring khaki	6	3400.3900000000003
+Manufacturer#4	almond azure aquamarine papaya violet	12	4755.94
+Manufacturer#5	almond antique blue firebrick mint	31	6654.56
+Manufacturer#5	almond antique medium spring khaki	6	3400.39
 Manufacturer#5	almond antique sky peru orange	2	1788.73
-Manufacturer#5	almond aquamarine dodger light gainsboro	46	7672.660000000002
-Manufacturer#5	almond azure blanched chiffon midnight	23	4864.870000000001
+Manufacturer#5	almond aquamarine dodger light gainsboro	46	7672.66
+Manufacturer#5	almond azure blanched chiffon midnight	23	4864.87
 PREHOOK: query: -- 42. testUnboundedFollowingForRows
 select p_mfgr, p_name, p_size,
-    sum(p_retailprice) over (distribute by p_mfgr sort by p_name rows between current row and unbounded following) as s1
+    round(sum(p_retailprice) over (distribute by p_mfgr sort by p_name rows between current row and unbounded following),2) as s1
     from part
 PREHOOK: type: QUERY
 PREHOOK: Input: default@part
 #### A masked pattern was here ####
 POSTHOOK: query: -- 42. testUnboundedFollowingForRows
 select p_mfgr, p_name, p_size,
-    sum(p_retailprice) over (distribute by p_mfgr sort by p_name rows between current row and unbounded following) as s1
+    round(sum(p_retailprice) over (distribute by p_mfgr sort by p_name rows between current row and unbounded following),2) as s1
     from part
 POSTHOOK: type: QUERY
 POSTHOOK: Input: default@part
 #### A masked pattern was here ####
 Manufacturer#1	almond antique burnished rose metallic	2	7576.58
-Manufacturer#1	almond antique burnished rose metallic	2	8749.730000000001
+Manufacturer#1	almond antique burnished rose metallic	2	8749.73
 Manufacturer#1	almond antique chartreuse lavender yellow	34	6403.43
 Manufacturer#1	almond antique salmon chartreuse burlywood	6	4649.67
 Manufacturer#1	almond aquamarine burnished black steel	28	3047.08
 Manufacturer#1	almond aquamarine pink moccasin thistle	42	1632.66
 Manufacturer#2	almond antique violet chocolate turquoise	14	8923.62
-Manufacturer#2	almond antique violet turquoise frosted	40	7232.9400000000005
+Manufacturer#2	almond antique violet turquoise frosted	40	7232.94
 Manufacturer#2	almond aquamarine midnight light salmon	2	5432.24
 Manufacturer#2	almond aquamarine rose maroon antique	25	3400.26
 Manufacturer#2	almond aquamarine sandy cyan gainsboro	18	1701.6
 Manufacturer#3	almond antique chartreuse khaki white	17	7532.61
-Manufacturer#3	almond antique forest lavender goldenrod	14	5860.929999999999
+Manufacturer#3	almond antique forest lavender goldenrod	14	5860.93
 Manufacturer#3	almond antique metallic orange dim	19	4670.66
 Manufacturer#3	almond antique misty red olive	1	3260.27
 Manufacturer#3	almond antique olive coral navajo	45	1337.29
-Manufacturer#4	almond antique gainsboro frosted violet	10	7337.620000000001
-Manufacturer#4	almond antique violet mint lemon	39	5716.950000000001
-Manufacturer#4	almond aquamarine floral ivory bisque	27	4341.530000000001
+Manufacturer#4	almond antique gainsboro frosted violet	10	7337.62
+Manufacturer#4	almond antique violet mint lemon	39	5716.95
+Manufacturer#4	almond aquamarine floral ivory bisque	27	4341.53
 Manufacturer#4	almond aquamarine yellow dodger mint	7	3135.27
 Manufacturer#4	almond azure aquamarine papaya violet	12	1290.35
 Manufacturer#5	almond antique blue firebrick mint	31	7672.66
-Manufacturer#5	almond antique medium spring khaki	6	5882.970000000001
-Manufacturer#5	almond antique sky peru orange	2	4271.3099999999995
+Manufacturer#5	almond antique medium spring khaki	6	5882.97
+Manufacturer#5	almond antique sky peru orange	2	4271.31
 Manufacturer#5	almond aquamarine dodger light gainsboro	46	2482.58
 Manufacturer#5	almond azure blanched chiffon midnight	23	1464.48
 PREHOOK: query: -- 43. testUnboundedFollowingForRange
 select p_mfgr, p_name, p_size,
-    sum(p_retailprice) over (distribute by p_mfgr sort by p_size range between current row and unbounded following) as s1
+    round(sum(p_retailprice) over (distribute by p_mfgr sort by p_size range between current row and unbounded following),2) as s1
     from part
 PREHOOK: type: QUERY
 PREHOOK: Input: default@part
 #### A masked pattern was here ####
 POSTHOOK: query: -- 43. testUnboundedFollowingForRange
 select p_mfgr, p_name, p_size,
-    sum(p_retailprice) over (distribute by p_mfgr sort by p_size range between current row and unbounded following) as s1
+    round(sum(p_retailprice) over (distribute by p_mfgr sort by p_size range between current row and unbounded following),2) as s1
     from part
 POSTHOOK: type: QUERY
 POSTHOOK: Input: default@part
 #### A masked pattern was here ####
-Manufacturer#1	almond antique burnished rose metallic	2	8749.730000000001
-Manufacturer#1	almond antique burnished rose metallic	2	8749.730000000001
+Manufacturer#1	almond antique burnished rose metallic	2	8749.73
+Manufacturer#1	almond antique burnished rose metallic	2	8749.73
 Manufacturer#1	almond antique chartreuse lavender yellow	34	3386.42
 Manufacturer#1	almond antique salmon chartreuse burlywood	6	6403.43
 Manufacturer#1	almond aquamarine burnished black steel	28	4800.84
 Manufacturer#1	almond aquamarine pink moccasin thistle	42	1632.66
-Manufacturer#2	almond antique violet chocolate turquoise	14	6891.639999999999
+Manufacturer#2	almond antique violet chocolate turquoise	14	6891.64
 Manufacturer#2	almond antique violet turquoise frosted	40	1800.7
 Manufacturer#2	almond aquamarine midnight light salmon	2	8923.62
 Manufacturer#2	almond aquamarine rose maroon antique	25	3499.36
 Manufacturer#2	almond aquamarine sandy cyan gainsboro	18	5200.96
-Manufacturer#3	almond antique chartreuse khaki white	17	4419.360000000001
+Manufacturer#3	almond antique chartreuse khaki white	17	4419.36
 Manufacturer#3	almond antique forest lavender goldenrod	14	5609.63
-Manufacturer#3	almond antique metallic orange dim	19	2747.6800000000003
-Manufacturer#3	almond antique misty red olive	1	7532.610000000001
+Manufacturer#3	almond antique metallic orange dim	19	2747.68
+Manufacturer#3	almond antique misty red olive	1	7532.61
 Manufacturer#3	almond antique olive coral navajo	45	1337.29
 Manufacturer#4	almond antique gainsboro frosted violet	10	5492.7
 Manufacturer#4	almond antique violet mint lemon	39	1375.42
-Manufacturer#4	almond aquamarine floral ivory bisque	27	2581.6800000000003
-Manufacturer#4	almond aquamarine yellow dodger mint	7	7337.620000000001
-Manufacturer#4	almond azure aquamarine papaya violet	12	3872.0299999999997
+Manufacturer#4	almond aquamarine floral ivory bisque	27	2581.68
+Manufacturer#4	almond aquamarine yellow dodger mint	7	7337.62
+Manufacturer#4	almond azure aquamarine papaya violet	12	3872.03
 Manufacturer#5	almond antique blue firebrick mint	31	2807.79
 Manufacturer#5	almond antique medium spring khaki	6	5883.93
-Manufacturer#5	almond antique sky peru orange	2	7672.660000000002
+Manufacturer#5	almond antique sky peru orange	2	7672.66
 Manufacturer#5	almond aquamarine dodger light gainsboro	46	1018.1
 Manufacturer#5	almond azure blanched chiffon midnight	23	4272.27
 PREHOOK: query: -- 44. testOverNoPartitionSingleAggregate
@@ -2405,27 +2405,27 @@ POSTHOOK: type: QUERY
 POSTHOOK: Input: default@part
 #### A masked pattern was here ####
 PREHOOK: query: -- 46. window sz is same as partition sz
-select p_retailprice, avg(p_retailprice) over (partition by p_mfgr order by p_name rows between current row and 6 following), 
-sum(p_retailprice) over (partition by p_mfgr order by p_name rows between current row and 6 following) 
+select p_retailprice, round(avg(p_retailprice) over (partition by p_mfgr order by p_name rows between current row and 6 following),2),
+round(sum(p_retailprice) over (partition by p_mfgr order by p_name rows between current row and 6 following),2)
 from part 
 where p_mfgr='Manufacturer#1'
 PREHOOK: type: QUERY
 PREHOOK: Input: default@part
 #### A masked pattern was here ####
 POSTHOOK: query: -- 46. window sz is same as partition sz
-select p_retailprice, avg(p_retailprice) over (partition by p_mfgr order by p_name rows between current row and 6 following), 
-sum(p_retailprice) over (partition by p_mfgr order by p_name rows between current row and 6 following) 
+select p_retailprice, round(avg(p_retailprice) over (partition by p_mfgr order by p_name rows between current row and 6 following),2),
+round(sum(p_retailprice) over (partition by p_mfgr order by p_name rows between current row and 6 following),2)
 from part 
 where p_mfgr='Manufacturer#1'
 POSTHOOK: type: QUERY
 POSTHOOK: Input: default@part
 #### A masked pattern was here ####
-1173.15	1458.2883333333336	8749.730000000001
-1173.15	1515.3160000000003	7576.580000000002
-1414.42	1523.5400000000004	3047.080000000001
-1602.59	1549.8900000000003	4649.670000000001
-1632.66	1632.6600000000008	1632.6600000000008
-1753.76	1600.8575000000003	6403.430000000001
+1173.15	1458.29	8749.73
+1173.15	1515.32	7576.58
+1414.42	1523.54	3047.08
+1602.59	1549.89	4649.67
+1632.66	1632.66	1632.66
+1753.76	1600.86	6403.43
 PREHOOK: query: -- 47. empty partition
 select sum(p_size) over (partition by p_mfgr )
 from part where p_mfgr = 'm1'