You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@impala.apache.org by ta...@apache.org on 2018/01/18 04:27:50 UTC

[10/12] impala git commit: IMPALA-5478: Run TPCDS queries with decimal_v2 enabled

http://git-wip-us.apache.org/repos/asf/impala/blob/35a3e186/testdata/workloads/tpcds/queries/tpcds-decimal_v2-q20.test
----------------------------------------------------------------------
diff --git a/testdata/workloads/tpcds/queries/tpcds-decimal_v2-q20.test b/testdata/workloads/tpcds/queries/tpcds-decimal_v2-q20.test
new file mode 100644
index 0000000..9c39adc
--- /dev/null
+++ b/testdata/workloads/tpcds/queries/tpcds-decimal_v2-q20.test
@@ -0,0 +1,133 @@
+====
+---- QUERY: TPCDS-Q20
+select  i_item_id
+       ,i_item_desc
+       ,i_category
+       ,i_class
+       ,i_current_price
+       ,sum(cs_ext_sales_price) as itemrevenue
+       ,sum(cs_ext_sales_price)*100/sum(sum(cs_ext_sales_price)) over
+           (partition by i_class) as revenueratio
+ from  catalog_sales
+     ,item
+     ,date_dim
+ where cs_item_sk = i_item_sk
+   and i_category in ('Sports', 'Books', 'Home')
+   and cs_sold_date_sk = d_date_sk
+   and cast(d_date as timestamp) between cast('1999-02-22' as timestamp)
+   and (cast('1999-02-22' as timestamp) + interval 30 days)
+ group by i_item_id
+         ,i_item_desc
+         ,i_category
+         ,i_class
+         ,i_current_price
+ order by i_category
+         ,i_class
+         ,i_item_id
+         ,i_item_desc
+         ,revenueratio
+limit 100;
+---- RESULTS
+'AAAAAAAAAAKAAAAA','Small, political activities help great, bad policies. Therefore square features provide on a machines. Rules make over me','Books','arts',2.42,6478.75,3.228812
+'AAAAAAAAACKBAAAA','Clinical, inc initiatives make specially according to a activities.','Books','arts',6.92,1806.72,0.900414
+'AAAAAAAAAIJCAAAA','Simply small grounds use exactly effects. Services could kill especially aware, large observers. Civil, relevant years ensure regulations; clear drawings realize actors. Products employ a','Books','arts',1.76,14302.11,7.127737
+'AAAAAAAAAJIAAAAA','Joint, superior police would use through an restrictions. Buyers ought to contract generally in a efforts. Days cut also sure, frequent s','Books','arts',0.43,1094.80,0.545615
+'AAAAAAAABFHDAAAA','Little days answer in a emotions; players touch.','Books','arts',2.58,6331.08,3.155218
+'AAAAAAAABHDCAAAA','Minor heads close common children; recently strong firms provide. Useful, young men ought to create changes. Popular, common regulations might decide. Points fit. Obvious, glad officials ','Books','arts',3.88,2596.68,1.294106
+'AAAAAAAACBACAAAA','Remaining, main passengers go far sure men. ','Books','arts',4.78,700.70,0.349208
+'AAAAAAAACKDBAAAA','Positions can win increasingly entire units. Unions used to exclude fairly afraid fans. National fields appear also ways. Great lips print new teachers. Constant, primary deaths expect a little ','Books','arts',3.82,2828.38,1.409579
+'AAAAAAAACKEAAAAA','Legs appear eventually soci','Books','arts',35.27,438.70,0.218635
+'AAAAAAAACMDCAAAA','Black, powerful others go now years. Diverse orders might not mean away medium minutes; tight authorities ought to put however for the things','Books','arts',2.75,6743.51,3.360760
+'AAAAAAAACNEDAAAA','Particularly labour stores get farmers. Hence true records see rel','Books','arts',6.89,9386.80,4.678096
+'AAAAAAAADCCDAAAA','Glad users understand very almost original jobs. Towns can understand. Supreme, following days work by a parents; german, crucial weapons work sure; fair pictur','Books','arts',7.18,3375.52,1.682256
+'AAAAAAAADJFCAAAA','Significant, preliminary boys can remain lightly more pale discussion','Books','arts',2.74,3316.75,1.652967
+'AAAAAAAADPCCAAAA','Especially true items might supply particularly. Black, automatic words might develop post-war problems. Fresh, visible workers could not appe','Books','arts',4.23,4567.89,2.276497
+'AAAAAAAAEDKDAAAA','Times live now to a sales. British years bring all financ','Books','arts',4.24,5014.90,2.499274
+'AAAAAAAAEGAEAAAA','Far injuries pay so various arms. Courses could go anywhere universal possibilities; talks stand since mean, colonial scho','Books','arts',9.57,17491.20,8.717082
+'AAAAAAAAEPDDAAAA','Services used to work most new provi','Books','arts',2.84,481.44,0.239935
+'AAAAAAAAEPKAAAAA','Here political studies give once at the qu','Books','arts',1.78,2562.67,1.277157
+'AAAAAAAAFBMBAAAA','Years light glasses. Contemporary members might detect even drawings. Private instructions ought to expect well main streets. Children will say well; usually young members ought to ensure enough. ','Books','arts',4.78,1718.83,0.856613
+'AAAAAAAAFCKCAAAA','Brilliant, acceptable resources might not pick as. Positive, married parties support only strongly impossible needs. Photogra','Books','arts',2.44,2958.33,1.474342
+'AAAAAAAAGAKAAAAA','Especially early girls glance however specific, relevant steps. Financial worlds telephone most dark gains. Warm, outdoor devices defend besides. Unions must not say narrow powers; individual ti','Books','arts',8.96,2310.78,1.151622
+'AAAAAAAAGFHBAAAA','Contemporary occasions provide she','Books','arts',1.75,11988.75,5.974828
+'AAAAAAAAGHOBAAAA','Fully existing proceedings could not tak','Books','arts',8.66,2402.76,1.197463
+'AAAAAAAAGOKBAAAA','Othe','Books','arts',60.94,2242.14,1.117414
+'AAAAAAAAHPNCAAAA','Correct, certain humans cut','Books','arts',37.98,6152.65,3.066294
+'AAAAAAAAIAOAAAAA','Professional circumstances could live else others. Symptoms can see very leaves. Just personal institutions used to go. Capable workers used to play then able police.','Books','arts',2.40,2219.11,1.105937
+'AAAAAAAAIEPCAAAA','New, popular years should think. Shareholders speak also friends; special members could not identify social eyes; indoors full ','Books','arts',0.91,5462.06,2.722125
+'AAAAAAAAIHKBAAAA','Very historic arms may happen even able exis','Books','arts',9.19,8280.09,4.126545
+'AAAAAAAAIIPDAAAA','Af','Books','arts',6.04,4695.48,2.340084
+'AAAAAAAAIJGAAAAA','Then western animals could teach somewhere. Today waiting servants confuse','Books','arts',4.10,1589.42,0.792119
+'AAAAAAAAJJDBAAAA','Problems compete with a sets. Interesting, automatic pounds tell complete hills. ','Books','arts',1.20,18501.43,9.220550
+'AAAAAAAAKGBAAAAA','Light moments cannot date following sy','Books','arts',5.60,9688.12,4.828264
+'AAAAAAAAKICDAAAA','Wet, concerned representatives get up to a owners. Necessary, like','Books','arts',1.89,10823.82,5.394263
+'AAAAAAAAMFFAAAAA','Communities used to relocate clearly strange, new walls; european, rich championships make current depths. Sure studies may reflect only instinctively old forces. Foreign, diverse','Books','arts',8.22,3557.07,1.772735
+'AAAAAAAANIBAAAAA','Beneath decent wives write t','Books','arts',2.72,2235.93,1.114320
+'AAAAAAAAOJJCAAAA','Troops take only, right dogs. Briefly genuine eyes used to provide mutually coming, just parents. Too social services shall feel only rec','Books','arts',6.40,2193.52,1.093184
+'AAAAAAAAOKPBAAAA','Just good settings must not make; payments assure to a bishops. Principal, sorry amounts would safeguard very so other leaders; tory, substantial stairs m','Books','arts',2.60,5632.64,2.807136
+'AAAAAAAAOPKCAAAA','Less imp','Books','arts',9.12,1511.60,0.753335
+'AAAAAAAAPIEBAAAA','Main cheeks must put ','Books','arts',0.45,13.44,0.006698
+'AAAAAAAAPLLDAAAA','Old eyes could not give later issues. Claims might','Books','arts',9.00,4957.73,2.470782
+'AAAAAAAAABMBAAAA','Situations retain; units might sit operations; girls shall make. Ca','Books','business',3.16,905.62,0.577071
+'AAAAAAAAACEBAAAA','Prese','Books','business',15.17,5628.92,3.586812
+'AAAAAAAAADFAAAAA','Satisfactory, technical shadows get. Lexical structures would not blame. Only hard ','Books','business',78.25,9249.55,5.893918
+'AAAAAAAAAKBDAAAA','Essential students change even despite a powers. General connections will not maximi','Books','business',3.10,1162.52,0.740771
+'AAAAAAAAANHCAAAA','High ministers should not remove for a stations. Certain, linear weeks might not ask so from a improvements. Lakes must not implement f','Books','business',4.80,504.32,0.321358
+'AAAAAAAABIPBAAAA','Ultimate, other objects might not install good ','Books','business',2.57,2399.32,1.528874
+'AAAAAAAABKACAAAA','Total pp. accept with a questions; able, generous a','Books','business',5.25,6380.42,4.065676
+'AAAAAAAACDBCAAAA','Tiny years could run too above tough volumes. New germans must not leave as possible sales; inj','Books','business',1.22,5339.66,3.402492
+'AAAAAAAACDIBAAAA','Small results would go colours; sexual agencies ought to assure moreover unique premises; then complex provisions use often normal windows. Better educational girls should not believe however struct','Books','business',9.78,566.04,0.360687
+'AAAAAAAACEACAAAA','Other, direct letters ought to make from a ways. British, large men could not work a','Books','business',0.48,9562.96,6.093626
+'AAAAAAAACPODAAAA','Cells stay economic, thin members. Soon special conservatives solve to the figu','Books','business',2.93,13212.32,8.419040
+'AAAAAAAADHNCAAAA','Originally major industries matter mediterranean bodies. Cases should not ','Books','business',45.06,303.70,0.193521
+'AAAAAAAADNDDAAAA','Clear, harsh police used to include large, appropriate plans. Prices could produce more. There white weapons expect directly free conclusions. Responsibl','Books','business',4.57,3220.52,2.052152
+'AAAAAAAAEICAAAAA','Cases include proudly without a columns. Solid, pre','Books','business',2.42,7199.25,4.587444
+'AAAAAAAAEILDAAAA','Bad, able systems shall fall else. Nuclear, economic ways put in an paths. Serious, labour women must not muster however. Wide new readers ought to help ','Books','business',1.36,1349.33,0.859808
+'AAAAAAAAFGJCAAAA','Secondary, red structures may seek eyes. High true titles should make now junior fat thoughts. Partly excellent authorities receive direct, net parties. Parents look most also other issues. Empty, con','Books','business',8.59,3655.68,2.329441
+'AAAAAAAAFLMDAAAA','Significantly relevant colleges extract knowingly broad investors. Entire members stay. Mediterranean legs would cut on the knees. Forthcoming, particular students u','Books','business',4.81,1809.71,1.153168
+'AAAAAAAAGFDCAAAA','Particularly medieval blocks would not find slightly with a carers. Years respond about at a sec','Books','business',6.00,318.24,0.202786
+'AAAAAAAAGONBAAAA','Ever top offers might struggle far, automatic men. Long-term, long goods dare however; new, other gr','Books','business',2.30,1639.26,1.044555
+'AAAAAAAAIBKDAAAA','Hundreds drop nearly unacceptable accidents. Then strong methods tell large unions. Short companies should help so. Moves shall not set later chief problems. R','Books','business',0.78,1490.85,0.949986
+'AAAAAAAAIINDAAAA','Frames can park highly parents. White ma','Books','business',6.97,4313.52,2.748624
+'AAAAAAAAIJECAAAA','Difficult, royal units put particularly significant, other plans. Essential, contemporary journals will need players. Alternatively parental','Books','business',4.34,2268.00,1.445195
+'AAAAAAAAIJJCAAAA','Euro','Books','business',3.01,4889.34,3.115543
+'AAAAAAAAIKEAAAAA','All ','Books','business',9.44,182.52,0.116304
+'AAAAAAAAIPADAAAA','Orders go into the documents. Social, existing specialists will seem twice associated wishes. Finally nation','Books','business',5.15,242.88,0.154766
+'AAAAAAAAJMEDAAAA','Personal, significant activities agree only by a couples. Elaborate aut','Books','business',3.06,85.26,0.054329
+'AAAAAAAAKAJDAAAA','Short neighbours implement innocently tiny titles. Briefly simple years should not tell potentially successful, whole years. Orange workers carry; home hot feet l','Books','business',4.43,4949.49,3.153871
+'AAAAAAAAKAKAAAAA','Still urban stages shall not take for a legs. Other, holy demands pay further young, positive numbers. A little criminal i','Books','business',7.68,9959.06,6.346026
+'AAAAAAAAKMAAAAAA','Plans consult interested, light boys. Selective, other problems create scientific, young parties. Sufficient speakers might not kiss too social, basic interests. Dual, other times s','Books','business',0.19,910.16,0.579964
+'AAAAAAAALDFAAAAA','Hands may not allow only in a lands; linear, other pubs say; social, precise women identify for a patients. Preferences develop alone now rich motives. Ever good tas','Books','business',3.68,1816.45,1.157462
+'AAAAAAAALGBBAAAA','Modern records retain about there civil plans. Social bodies survive. Great, living losses bother late, coherent others. About british sports ought to use cautiously from ','Books','business',1.94,1252.09,0.797846
+'AAAAAAAAMALDAAAA','Here final difficulties would not comply just legal good motives. Enough sensitive things could not spend obviously with a systems. In pu','Books','business',91.76,356.85,0.227389
+'AAAAAAAAMIGCAAAA','Carefully physical hotels must put together; similar details cannot appreciate by a standards. Rates can break m','Books','business',6.63,562.96,0.358724
+'AAAAAAAAMIMCAAAA','About likely houses like international members. Final, relevant birds answer after the paintings. Hungry, personal days borrow tiny, primary resources. As social relations could choose quite also ','Books','business',0.77,2889.22,1.841044
+'AAAAAAAAMKHAAAAA','Unions shall see enough over true attitudes; of course full variable','Books','business',8.90,15263.90,9.726330
+'AAAAAAAAMKNDAAAA','Special, clear elements would buy at a games. Things should spot today strange, only devices. Armies should like at a patients. Hands could perform simply narrow values. N','Books','business',1.28,1069.76,0.681663
+'AAAAAAAANACBAAAA','New teachers might demand never assets. Deeply bright ministers make generally never prime imports. Odd writings step common readers; talks take young, r','Books','business',2.95,3975.16,2.533017
+'AAAAAAAAPDNAAAAA','Local, unlikely bits sign completely. Areas feel only manufacturing legs. Amounts must go personal, very things; areas could take clo','Books','business',5.20,3545.37,2.259150
+'AAAAAAAAPEKCAAAA','Alone countries must use so old, international functions. Only public cases see in a words. Normal methods forget even communist changes; technical numbers convert either natu','Books','business',4.67,3899.62,2.484882
+'AAAAAAAAPGDBAAAA','Certainly remaining flowers can wonder then just significant papers; places secure below as a bombs. Other, domestic members must allow very polite thi','Books','business',0.60,12462.77,7.941418
+'AAAAAAAAPHJAAAAA','Possibly great customs suit close looks. Capable, frequent processes shall pass possible dangers; hard, private words act measures. Mysterious, acceptable fac','Books','business',6.64,6141.24,3.913268
+'AAAAAAAAAALDAAAA','Forward liable funds may not end from time to time local, domestic chiefs. Major, well-known newspapers can regain together new, white conclusions. Very vital employees can draw','Books','computers',17.54,588.01,0.311080
+'AAAAAAAAAHKDAAAA','Decisions play actually exclusive activities. Well assistant e','Books','computers',8.77,1619.66,0.856862
+'AAAAAAAAAKGDAAAA','Tonnes could use slowly off a servants. Initial letters must walk now companies; rapid, previous towns put here large, prime needs. Historical, negative grou','Books','computers',0.19,3319.10,1.755930
+'AAAAAAAAAOBCAAAA','Years should try in line with a conditions. Pp. spend well evenings. Other, afraid sides speculate at a years. Options ought to know leading, app','Books','computers',5.23,8468.08,4.479937
+'AAAAAAAABHEEAAAA','Subjects may remain officials. Forward, straight objects used to see wh','Books','computers',6.97,13658.40,7.225814
+'AAAAAAAABLMBAAAA','External improvements effect so tough words. Great roads cause quickly popular, black stories. Clearly white members might ask enough details. Min','Books','computers',31.74,4154.04,2.197646
+'AAAAAAAACHOCAAAA','Final governm','Books','computers',6.22,5102.98,2.699671
+'AAAAAAAACOHDAAAA','Left, important sports shall get on an specialists. Overall, e','Books','computers',3.56,14321.37,7.576551
+'AAAAAAAAEANCAAAA','Ye','Books','computers',9.75,1367.76,0.723597
+'AAAAAAAAEAPAAAAA','Just distinct children think individuals; popular arguments develop here cautious methods; appropriate children might beat. Proper, empirical hundreds fall oth','Books','computers',4.01,328.50,0.173789
+'AAAAAAAAEDMAAAAA','Books understand. Principles produce just at a premises. Years ','Books','computers',44.48,188.86,0.099914
+'AAAAAAAAFEEAAAAA','Capital, united feelings paint only things. Greatly financial economies should not pay somewhere soviet necessary armies; educational concepts mus','Books','computers',3.83,812.19,0.429679
+'AAAAAAAAFLFEAAAA','Social weeks may hope. However parental objects shall get just potential logical stations. Agreements attend on a arms; circa real reforms may interpret dogs. T','Books','computers',2.06,449.61,0.237861
+'AAAAAAAAGENAAAAA','Genera','Books','computers',2.84,950.58,0.502893
+'AAAAAAAAGHCBAAAA','Hundreds would meet regardless german, foreign scien','Books','computers',9.77,1969.60,1.041994
+'AAAAAAAAGNGBAAAA','Brilliant, massive prisons take still national others. Only northern guidelines go right by the lips. General, spiritual walls shall reach in a languages. British nations eat substantial polici','Books','computers',3.42,377.26,0.199585
+'AAAAAAAAHPADAAAA','Used, young sizes take requirements. Electoral, standard stones worry still private scenes. Major, still bedrooms say all once effective years. Long new moments will own after the','Books','computers',9.19,690.90,0.365512
+'AAAAAAAAIAMAAAAA','Alone walls mus','Books','computers',2.00,4530.16,2.396627
+'AAAAAAAAIGCEAAAA','Concerned numbers can attempt now particular, white friends; un','Books','computers',3.38,14627.99,7.738765
+---- TYPES
+STRING, STRING, STRING, STRING, DECIMAL, DECIMAL, DECIMAL
+====
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/impala/blob/35a3e186/testdata/workloads/tpcds/queries/tpcds-decimal_v2-q21.test
----------------------------------------------------------------------
diff --git a/testdata/workloads/tpcds/queries/tpcds-decimal_v2-q21.test b/testdata/workloads/tpcds/queries/tpcds-decimal_v2-q21.test
new file mode 100644
index 0000000..b185108
--- /dev/null
+++ b/testdata/workloads/tpcds/queries/tpcds-decimal_v2-q21.test
@@ -0,0 +1,133 @@
+====
+---- QUERY: TPCDS-Q21
+select  *
+ from(select w_warehouse_name
+            ,i_item_id
+            ,sum(case when (cast(d_date as timestamp) < cast ('2000-03-11' as timestamp))
+                  then inv_quantity_on_hand
+                      else 0 end) as inv_before
+            ,sum(case when (cast(d_date as timestamp) >= cast ('2000-03-11' as timestamp))
+                      then inv_quantity_on_hand
+                      else 0 end) as inv_after
+   from inventory
+       ,warehouse
+       ,item
+       ,date_dim
+   where i_current_price between 0.99 and 1.49
+     and i_item_sk          = inv_item_sk
+     and inv_warehouse_sk   = w_warehouse_sk
+     and inv_date_sk    = d_date_sk
+     and cast(d_date as timestamp) between (cast ('2000-03-11' as timestamp) - interval 30 days)
+                    and (cast ('2000-03-11' as timestamp) + interval 30 days)
+   group by w_warehouse_name, i_item_id) x
+ where (case when inv_before > 0
+             then inv_after / inv_before
+             else null
+             end) between 2.0/3.0 and 3.0/2.0
+ order by w_warehouse_name
+         ,i_item_id
+ limit 100;
+---- RESULTS
+'Bad cards must make.','AAAAAAAAAACDAAAA',1889,2168
+'Bad cards must make.','AAAAAAAAAAHDAAAA',2739,2039
+'Bad cards must make.','AAAAAAAAABDAAAAA',1717,1782
+'Bad cards must make.','AAAAAAAAACGCAAAA',2296,2276
+'Bad cards must make.','AAAAAAAAACKCAAAA',2443,1878
+'Bad cards must make.','AAAAAAAAACOBAAAA',2705,2428
+'Bad cards must make.','AAAAAAAAADGBAAAA',2242,2759
+'Bad cards must make.','AAAAAAAAADKBAAAA',2138,2456
+'Bad cards must make.','AAAAAAAAAEADAAAA',2914,2237
+'Bad cards must make.','AAAAAAAAAEOCAAAA',1797,2073
+'Bad cards must make.','AAAAAAAAAFACAAAA',2058,2734
+'Bad cards must make.','AAAAAAAAAFADAAAA',2173,2515
+'Bad cards must make.','AAAAAAAAAFDCAAAA',2309,2277
+'Bad cards must make.','AAAAAAAAAGIDAAAA',1864,2197
+'Bad cards must make.','AAAAAAAAAHDEAAAA',2483,2077
+'Bad cards must make.','AAAAAAAAAHJBAAAA',2904,3312
+'Bad cards must make.','AAAAAAAAAIECAAAA',2239,2526
+'Bad cards must make.','AAAAAAAAAIMCAAAA',1948,2693
+'Bad cards must make.','AAAAAAAAAJKBAAAA',2184,2190
+'Bad cards must make.','AAAAAAAAALECAAAA',2539,3052
+'Bad cards must make.','AAAAAAAAALNBAAAA',1406,1728
+'Bad cards must make.','AAAAAAAAAMPBAAAA',3450,3033
+'Bad cards must make.','AAAAAAAAANFEAAAA',2255,1517
+'Bad cards must make.','AAAAAAAAAPLAAAAA',1465,1227
+'Bad cards must make.','AAAAAAAABBIDAAAA',2822,2125
+'Bad cards must make.','AAAAAAAABDCEAAAA',2068,2187
+'Bad cards must make.','AAAAAAAABEFDAAAA',1023,1510
+'Bad cards must make.','AAAAAAAABFNAAAAA',1962,2719
+'Bad cards must make.','AAAAAAAABFOCAAAA',2392,2520
+'Bad cards must make.','AAAAAAAABHPCAAAA',2945,3058
+'Bad cards must make.','AAAAAAAABIDBAAAA',1746,1706
+'Bad cards must make.','AAAAAAAABJFEAAAA',2458,2647
+'Bad cards must make.','AAAAAAAABKFAAAAA',3152,2529
+'Bad cards must make.','AAAAAAAABLDEAAAA',2439,2899
+'Bad cards must make.','AAAAAAAABNHBAAAA',2254,2117
+'Bad cards must make.','AAAAAAAABNLAAAAA',2552,2608
+'Bad cards must make.','AAAAAAAABNLDAAAA',3103,2489
+'Bad cards must make.','AAAAAAAABNMCAAAA',1752,2078
+'Bad cards must make.','AAAAAAAABOCCAAAA',1697,1547
+'Bad cards must make.','AAAAAAAACAAAAAAA',2736,1937
+'Bad cards must make.','AAAAAAAACAJCAAAA',1921,1806
+'Bad cards must make.','AAAAAAAACBFAAAAA',1237,1460
+'Bad cards must make.','AAAAAAAACBIAAAAA',2157,1915
+'Bad cards must make.','AAAAAAAACBPBAAAA',3220,2970
+'Bad cards must make.','AAAAAAAACCABAAAA',1167,1704
+'Bad cards must make.','AAAAAAAACCMDAAAA',2057,2563
+'Bad cards must make.','AAAAAAAACDBCAAAA',2017,1494
+'Bad cards must make.','AAAAAAAACGFDAAAA',2811,3027
+'Bad cards must make.','AAAAAAAACHHDAAAA',2589,1935
+'Bad cards must make.','AAAAAAAACJDCAAAA',1299,1807
+'Bad cards must make.','AAAAAAAACKHAAAAA',1484,2158
+'Bad cards must make.','AAAAAAAACLKAAAAA',2743,2910
+'Bad cards must make.','AAAAAAAACMJAAAAA',1345,1776
+'Bad cards must make.','AAAAAAAACMLAAAAA',1869,2372
+'Bad cards must make.','AAAAAAAACMPDAAAA',1480,2177
+'Bad cards must make.','AAAAAAAACNBBAAAA',2914,2373
+'Bad cards must make.','AAAAAAAACNEBAAAA',2170,2456
+'Bad cards must make.','AAAAAAAACNFAAAAA',2854,2071
+'Bad cards must make.','AAAAAAAACNGBAAAA',1830,2659
+'Bad cards must make.','AAAAAAAACNHDAAAA',1507,1643
+'Bad cards must make.','AAAAAAAACNPCAAAA',2756,2402
+'Bad cards must make.','AAAAAAAADCBEAAAA',2403,2684
+'Bad cards must make.','AAAAAAAADCPCAAAA',2112,1881
+'Bad cards must make.','AAAAAAAADDNDAAAA',3404,2652
+'Bad cards must make.','AAAAAAAADEJDAAAA',1719,1822
+'Bad cards must make.','AAAAAAAADFLAAAAA',3242,2344
+'Bad cards must make.','AAAAAAAADGCCAAAA',2435,2159
+'Bad cards must make.','AAAAAAAADGFCAAAA',2350,1867
+'Bad cards must make.','AAAAAAAADGGBAAAA',2686,3567
+'Bad cards must make.','AAAAAAAADGKAAAAA',2927,2595
+'Bad cards must make.','AAAAAAAADHPAAAAA',2639,2216
+'Bad cards must make.','AAAAAAAADKPDAAAA',2476,3512
+'Bad cards must make.','AAAAAAAADMBAAAAA',2472,2301
+'Bad cards must make.','AAAAAAAADNLBAAAA',2792,2077
+'Bad cards must make.','AAAAAAAADPABAAAA',1719,1667
+'Bad cards must make.','AAAAAAAAEAICAAAA',1420,2094
+'Bad cards must make.','AAAAAAAAEAPAAAAA',1875,2244
+'Bad cards must make.','AAAAAAAAEBCEAAAA',2241,1924
+'Bad cards must make.','AAAAAAAAEBPCAAAA',2544,2281
+'Bad cards must make.','AAAAAAAAECGCAAAA',2039,1848
+'Bad cards must make.','AAAAAAAAEDOCAAAA',2401,1770
+'Bad cards must make.','AAAAAAAAEDPDAAAA',3041,2119
+'Bad cards must make.','AAAAAAAAEGGBAAAA',2717,2032
+'Bad cards must make.','AAAAAAAAEGJAAAAA',2996,2092
+'Bad cards must make.','AAAAAAAAEGMAAAAA',3051,2982
+'Bad cards must make.','AAAAAAAAEGOCAAAA',2086,1958
+'Bad cards must make.','AAAAAAAAEHECAAAA',1993,1498
+'Bad cards must make.','AAAAAAAAEHFDAAAA',2217,2151
+'Bad cards must make.','AAAAAAAAEHLBAAAA',1417,2034
+'Bad cards must make.','AAAAAAAAEIDEAAAA',1804,1474
+'Bad cards must make.','AAAAAAAAEJAEAAAA',2287,2006
+'Bad cards must make.','AAAAAAAAEJJDAAAA',2080,1660
+'Bad cards must make.','AAAAAAAAEJPDAAAA',1788,2188
+'Bad cards must make.','AAAAAAAAEKCAAAAA',2451,2182
+'Bad cards must make.','AAAAAAAAENFBAAAA',2123,2294
+'Bad cards must make.','AAAAAAAAEONAAAAA',2706,1887
+'Bad cards must make.','AAAAAAAAEPHCAAAA',1332,1209
+'Bad cards must make.','AAAAAAAAEPKCAAAA',2445,1824
+'Bad cards must make.','AAAAAAAAFAKBAAAA',843,1256
+'Bad cards must make.','AAAAAAAAFALDAAAA',2391,2019
+---- TYPES
+STRING, STRING, BIGINT, BIGINT
+====
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/impala/blob/35a3e186/testdata/workloads/tpcds/queries/tpcds-decimal_v2-q22a.test
----------------------------------------------------------------------
diff --git a/testdata/workloads/tpcds/queries/tpcds-decimal_v2-q22a.test b/testdata/workloads/tpcds/queries/tpcds-decimal_v2-q22a.test
new file mode 100644
index 0000000..dcf9178
--- /dev/null
+++ b/testdata/workloads/tpcds/queries/tpcds-decimal_v2-q22a.test
@@ -0,0 +1,147 @@
+====
+---- QUERY: TPCDS-Q22A
+-- RESULT MISMATCH FROM ORIGINAL in LSD of AVG() values
+-- FIXED, HAND_ROUNDED AVG() VALUES IN RESULT SET
+with results as
+(select  i_product_name
+             ,i_brand
+             ,i_class
+             ,i_category
+             ,inv_quantity_on_hand qoh
+       from inventory
+           ,date_dim
+           ,item
+           ,warehouse
+       where  inv_date_sk=d_date_sk
+              and inv_item_sk=i_item_sk
+              and inv_warehouse_sk = w_warehouse_sk
+              and d_month_seq between 1200 and 1200 + 11
+       -- group by i_product_name,i_brand,i_class,i_category
+),
+results_rollup as
+(select i_product_name, i_brand, i_class, i_category,avg(qoh) qoh
+from results
+group by i_product_name,i_brand,i_class,i_category
+union all
+select i_product_name, i_brand, i_class, null i_category,avg(qoh) qoh
+from results
+group by i_product_name,i_brand,i_class
+union all
+select i_product_name, i_brand, null i_class, null i_category,avg(qoh) qoh
+from results
+group by i_product_name,i_brand
+union all
+select i_product_name, null i_brand, null i_class, null i_category,avg(qoh)  qoh
+from results
+group by i_product_name
+union all
+select null i_product_name, null i_brand, null i_class, null i_category,avg(qoh) qoh
+from results)
+ select  i_product_name, i_brand, i_class, i_category, cast(qoh as decimal(12, 2))
+      from results_rollup
+      order by qoh, i_product_name, i_brand, i_class, i_category
+limit 100;
+---- RESULTS
+'ationbarn station','amalgbrand #8','bathroom','Home',430.36
+'ationbarn station','amalgbrand #8','bathroom','NULL',430.36
+'ationbarn station','amalgbrand #8','NULL','NULL',430.36
+'ationbarn station','NULL','NULL','NULL',430.36
+'ationoughtn stn st','edu packimporto #2','sports-apparel','Men',435.27
+'ationoughtn stn st','edu packimporto #2','sports-apparel','NULL',435.27
+'ationoughtn stn st','edu packimporto #2','NULL','NULL',435.27
+'ationoughtn stn st','NULL','NULL','NULL',435.27
+'ationationprin st','amalgexporti #2','newborn','Children',435.51
+'ationationprin st','amalgexporti #2','newborn','NULL',435.51
+'ationationprin st','amalgexporti #2','NULL','NULL',435.51
+'ationationprin st','NULL','NULL','NULL',435.51
+'oughtcallyn stantiought','corpcorp #2','rings','Jewelry',436.49
+'oughtcallyn stantiought','corpcorp #2','rings','NULL',436.49
+'oughtcallyn stantiought','corpcorp #2','NULL','NULL',436.49
+'oughtcallyn stantiought','NULL','NULL','NULL',436.49
+'callyesebaration','namelesscorp #7','mens watch','Jewelry',437.39
+'callyesebaration','namelesscorp #7','mens watch','NULL',437.39
+'callyesebaration','namelesscorp #7','NULL','NULL',437.39
+'callyesebaration','NULL','NULL','NULL',437.39
+'n stprieingationought','namelesscorp #8','mens watch','Jewelry',439.06
+'n stprieingationought','namelesscorp #8','mens watch','NULL',439.06
+'n stprieingationought','namelesscorp #8','NULL','NULL',439.06
+'n stprieingationought','NULL','NULL','NULL',439.06
+'priationn stn st','importoscholar #2','country','Music',439.10
+'priationn stn st','importoscholar #2','country','NULL',439.10
+'priationn stn st','importoscholar #2','NULL','NULL',439.10
+'priationn stn st','NULL','NULL','NULL',439.10
+'n stcallyableoughtought','amalgimporto #2','accessories','Men',439.72
+'n stcallyableoughtought','amalgimporto #2','accessories','NULL',439.72
+'n stcallyableoughtought','amalgimporto #2','NULL','NULL',439.72
+'n stcallyableoughtought','NULL','NULL','NULL',439.72
+'n stbarought','corpbrand #10','rugs','Home',440.31
+'n stbarought','corpbrand #10','rugs','NULL',440.31
+'n stbarought','corpbrand #10','NULL','NULL',440.31
+'n stbarought','NULL','NULL','NULL',440.31
+'n stn stantioughtought','exportimaxi #8','computers','Books',440.93
+'n stn stantioughtought','exportimaxi #8','computers','NULL',440.93
+'n stn stantioughtought','exportimaxi #8','NULL','NULL',440.93
+'n stn stantioughtought','NULL','NULL','NULL',440.93
+'n stcallyesepriought','edu packscholar #2','classical','Music',441.54
+'n stcallyesepriought','edu packscholar #2','classical','NULL',441.54
+'n stcallyesepriought','edu packscholar #2','NULL','NULL',441.54
+'n stcallyesepriought','NULL','NULL','NULL',441.54
+'priantiationation','importoimporto #2','shirts','Men',441.67
+'priantiationation','importoimporto #2','shirts','NULL',441.67
+'priantiationation','importoimporto #2','NULL','NULL',441.67
+'priantiationation','NULL','NULL','NULL',441.67
+'oughtbarantiese','exportiedu pack #2','kids','Shoes',441.75
+'oughtbarantiese','exportiedu pack #2','kids','NULL',441.75
+'oughtbarantiese','exportiedu pack #2','NULL','NULL',441.75
+'oughtbarantiese','NULL','NULL','NULL',441.75
+'oughtbarprin st','edu packscholar #2','classical','Music',442.07
+'oughtbarprin st','edu packscholar #2','classical','NULL',442.07
+'oughtbarprin st','edu packscholar #2','NULL','NULL',442.07
+'oughtbarprin st','NULL','NULL','NULL',442.07
+'ationeingation','amalgexporti #2','newborn','Children',443.78
+'ationeingation','amalgexporti #2','newborn','NULL',443.78
+'ationeingation','amalgexporti #2','NULL','NULL',443.78
+'ationeingation','NULL','NULL','NULL',443.78
+'ationbarn stableought','corpbrand #8','rugs','Home',444.09
+'ationbarn stableought','corpbrand #8','rugs','NULL',444.09
+'ationbarn stableought','corpbrand #8','NULL','NULL',444.09
+'ationbarn stableought','NULL','NULL','NULL',444.09
+'eseationcallyableought','importoexporti #1','infants','Children',444.54
+'eseationcallyableought','importoexporti #1','infants','NULL',444.54
+'eseationcallyableought','importoexporti #1','NULL','NULL',444.54
+'eseationcallyableought','NULL','NULL','NULL',444.54
+'eingableableationought','amalgimporto #1','accessories','Men',444.71
+'eingableableationought','amalgimporto #1','accessories','NULL',444.71
+'eingableableationought','amalgimporto #1','NULL','NULL',444.71
+'eingableableationought','NULL','NULL','NULL',444.71
+'n steseantiation','univmaxi #10','pools','Sports',445.33
+'n steseantiation','univmaxi #10','pools','NULL',445.33
+'n steseantiation','univmaxi #10','NULL','NULL',445.33
+'n steseantiation','NULL','NULL','NULL',445.33
+'antibareingantiought','importoimporto #2','shirts','Men',445.41
+'antibareingantiought','importoimporto #2','shirts','NULL',445.41
+'antibareingantiought','importoimporto #2','NULL','NULL',445.41
+'antibareingantiought','NULL','NULL','NULL',445.41
+'ationantibarationought','univmaxi #8','pools','Sports',445.42
+'ationantibarationought','univmaxi #8','pools','NULL',445.42
+'ationantibarationought','univmaxi #8','NULL','NULL',445.42
+'ationantibarationought','NULL','NULL','NULL',445.42
+'oughtpricallybarought','edu packexporti #2','school-uniforms','Children',445.49
+'oughtpricallybarought','edu packexporti #2','school-uniforms','NULL',445.49
+'oughtpricallybarought','edu packexporti #2','NULL','NULL',445.49
+'oughtpricallybarought','NULL','NULL','NULL',445.49
+'ableationprieing','amalgamalg #1','dresses','Women',446.00
+'ableationprieing','amalgamalg #1','dresses','NULL',446.00
+'ableationprieing','amalgamalg #1','NULL','NULL',446.00
+'ableationprieing','NULL','NULL','NULL',446.00
+'pribarpribarought','edu packimporto #2','sports-apparel','Men',446.04
+'pribarpribarought','edu packimporto #2','sports-apparel','NULL',446.04
+'pribarpribarought','edu packimporto #2','NULL','NULL',446.04
+'pribarpribarought','NULL','NULL','NULL',446.04
+'oughtn stprin st','exportiamalgamalg #8','stereo','Electronics',447.27
+'oughtn stprin st','exportiamalgamalg #8','stereo','NULL',447.27
+'oughtn stprin st','exportiamalgamalg #8','NULL','NULL',447.27
+'oughtn stprin st','NULL','NULL','NULL',447.27
+---- TYPES
+STRING, STRING, STRING, STRING, DECIMAL
+====

http://git-wip-us.apache.org/repos/asf/impala/blob/35a3e186/testdata/workloads/tpcds/queries/tpcds-decimal_v2-q25.test
----------------------------------------------------------------------
diff --git a/testdata/workloads/tpcds/queries/tpcds-decimal_v2-q25.test b/testdata/workloads/tpcds/queries/tpcds-decimal_v2-q25.test
new file mode 100644
index 0000000..93e775f
--- /dev/null
+++ b/testdata/workloads/tpcds/queries/tpcds-decimal_v2-q25.test
@@ -0,0 +1,52 @@
+====
+---- QUERY: TPCDS-Q25
+select
+ i_item_id
+ ,i_item_desc
+ ,s_store_id
+ ,s_store_name
+ ,sum(ss_net_profit) as store_sales_profit
+ ,sum(sr_net_loss) as store_returns_loss
+ ,sum(cs_net_profit) as catalog_sales_profit
+ from
+ store_sales
+ ,store_returns
+ ,catalog_sales
+ ,date_dim d1
+ ,date_dim d2
+ ,date_dim d3
+ ,store
+ ,item
+ where
+ d1.d_moy = 4
+ and d1.d_year = 2001
+ and d1.d_date_sk = ss_sold_date_sk
+ and i_item_sk = ss_item_sk
+ and s_store_sk = ss_store_sk
+ and ss_customer_sk = sr_customer_sk
+ and ss_item_sk = sr_item_sk
+ and ss_ticket_number = sr_ticket_number
+ and sr_returned_date_sk = d2.d_date_sk
+ and d2.d_moy               between 4 and  10
+ and d2.d_year              = 2001
+ and sr_customer_sk = cs_bill_customer_sk
+ and sr_item_sk = cs_item_sk
+ and cs_sold_date_sk = d3.d_date_sk
+ and d3.d_moy               between 4 and  10
+ and d3.d_year              = 2001
+ group by
+ i_item_id
+ ,i_item_desc
+ ,s_store_id
+ ,s_store_name
+ order by
+ i_item_id
+ ,i_item_desc
+ ,s_store_id
+ ,s_store_name
+ limit 100;
+---- RESULTS
+'AAAAAAAADPMBAAAA','Things know alone letters. Flights should tend even jewish fees. Civil plans could not cry also social days; other losses might not pay walls; still able signs should not remove too human ','AAAAAAAAHAAAAAAA','ation',12.84,91.41,-1329.46
+---- TYPES
+STRING, STRING, STRING, STRING, DECIMAL, DECIMAL, DECIMAL
+====
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/impala/blob/35a3e186/testdata/workloads/tpcds/queries/tpcds-decimal_v2-q29.test
----------------------------------------------------------------------
diff --git a/testdata/workloads/tpcds/queries/tpcds-decimal_v2-q29.test b/testdata/workloads/tpcds/queries/tpcds-decimal_v2-q29.test
new file mode 100644
index 0000000..12038a7
--- /dev/null
+++ b/testdata/workloads/tpcds/queries/tpcds-decimal_v2-q29.test
@@ -0,0 +1,51 @@
+====
+---- QUERY: TPCDS-Q29
+select
+     i_item_id
+    ,i_item_desc
+    ,s_store_id
+    ,s_store_name
+    ,sum(ss_quantity)        as store_sales_quantity
+    ,sum(sr_return_quantity) as store_returns_quantity
+    ,sum(cs_quantity)        as catalog_sales_quantity
+ from
+    store_sales
+   ,store_returns
+   ,catalog_sales
+   ,date_dim             d1
+   ,date_dim             d2
+   ,date_dim             d3
+   ,store
+   ,item
+ where
+     d1.d_moy               = 9
+ and d1.d_year              = 1999
+ and d1.d_date_sk           = ss_sold_date_sk
+ and i_item_sk              = ss_item_sk
+ and s_store_sk             = ss_store_sk
+ and ss_customer_sk         = sr_customer_sk
+ and ss_item_sk             = sr_item_sk
+ and ss_ticket_number       = sr_ticket_number
+ and sr_returned_date_sk    = d2.d_date_sk
+ and d2.d_moy               between 9 and 9 + 3
+ and d2.d_year              = 1999
+ and sr_customer_sk         = cs_bill_customer_sk
+ and sr_item_sk             = cs_item_sk
+ and cs_sold_date_sk        = d3.d_date_sk
+ and d3.d_year              in (1999,1999+1,1999+2)
+ group by
+    i_item_id
+   ,i_item_desc
+   ,s_store_id
+   ,s_store_name
+ order by
+    i_item_id
+   ,i_item_desc
+   ,s_store_id
+   ,s_store_name
+ limit 100;
+---- RESULTS
+'AAAAAAAABOKDAAAA','Immediate women sell. Slowly sure measures might ensure in order from a duties. Privately aware damages may compensate so for example previous letters','AAAAAAAABAAAAAAA','ought',99,81,22
+---- TYPES
+STRING, STRING, STRING, STRING, BIGINT, BIGINT, BIGINT
+====
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/impala/blob/35a3e186/testdata/workloads/tpcds/queries/tpcds-decimal_v2-q3.test
----------------------------------------------------------------------
diff --git a/testdata/workloads/tpcds/queries/tpcds-decimal_v2-q3.test b/testdata/workloads/tpcds/queries/tpcds-decimal_v2-q3.test
new file mode 100644
index 0000000..44597a5
--- /dev/null
+++ b/testdata/workloads/tpcds/queries/tpcds-decimal_v2-q3.test
@@ -0,0 +1,118 @@
+====
+---- QUERY: TPCDS-Q3
+select
+  dt.d_year,
+  item.i_brand_id brand_id,
+  item.i_brand brand,
+  sum(ss_ext_sales_price) sum_agg
+from
+  date_dim dt,
+  store_sales ss,
+  item
+where
+  dt.d_date_sk = ss.ss_sold_date_sk
+  and ss.ss_item_sk = item.i_item_sk
+  and item.i_manufact_id = 128
+  and dt.d_moy = 11
+group by
+  dt.d_year,
+  item.i_brand,
+  item.i_brand_id
+order by
+  dt.d_year,
+  sum_agg desc,
+  brand_id
+limit 100;
+---- RESULTS
+1998,2001001,'amalgimporto #1',45162.45
+1998,5003001,'exportischolar #1',40600.56
+1998,5001001,'amalgscholar #1',32515.11
+1998,3004001,'edu packexporti #1',32443.16
+1998,3001001,'amalgexporti #1',30280.72
+1998,3001002,'amalgexporti #2',27644.68
+1998,1003001,'exportiamalg #1',25408.10
+1998,7007010,'brandbrand #10',23346.45
+1998,8001009,'amalgnameless #9',20792.57
+1998,10010002,'univamalgamalg #2',20398.90
+1998,7009008,'maxibrand #8',19199.75
+1998,6004008,'edu packcorp #8',18022.24
+1998,1004001,'edu packamalg #1',17434.09
+1998,10001002,'amalgunivamalg #2',15434.73
+1998,5004001,'edu packscholar #1',15184.40
+1998,7003009,'exportibrand #9',11669.32
+1998,1001002,'amalgamalg #2',10725.87
+1998,5003002,'exportischolar #2',10250.29
+1999,7003009,'exportibrand #9',60081.08
+1999,3004001,'edu packexporti #1',57285.04
+1999,2001001,'amalgimporto #1',46294.06
+1999,5004001,'edu packscholar #1',29587.74
+1999,1003001,'exportiamalg #1',28354.52
+1999,10001002,'amalgunivamalg #2',25166.82
+1999,5003001,'exportischolar #1',20350.80
+1999,1001002,'amalgamalg #2',18476.51
+1999,5003002,'exportischolar #2',17769.35
+1999,7009008,'maxibrand #8',16413.03
+1999,1004001,'edu packamalg #1',14950.65
+1999,6004008,'edu packcorp #8',14524.78
+1999,3001001,'amalgexporti #1',13895.01
+1999,5001001,'amalgscholar #1',11468.36
+1999,7007010,'brandbrand #10',10103.81
+1999,10010002,'univamalgamalg #2',7640.55
+1999,8001009,'amalgnameless #9',7324.50
+1999,3001002,'amalgexporti #2',2940.88
+2000,1003001,'exportiamalg #1',35841.00
+2000,2001001,'amalgimporto #1',32500.27
+2000,3001002,'amalgexporti #2',32059.56
+2000,3004001,'edu packexporti #1',29891.01
+2000,1001002,'amalgamalg #2',19888.62
+2000,10001002,'amalgunivamalg #2',19325.34
+2000,3001001,'amalgexporti #1',19261.58
+2000,10008017,'namelessunivamalg #17',17207.60
+2000,5003002,'exportischolar #2',16365.82
+2000,5003001,'amalgunivamalg #2',15140.30
+2000,1004001,'edu packamalg #1',15074.32
+2000,7009008,'maxibrand #8',15042.42
+2000,5004001,'edu packscholar #1',14744.21
+2000,6004008,'edu packcorp #8',13303.65
+2000,7007010,'brandbrand #10',12915.75
+2000,7003009,'exportibrand #9',11347.80
+2000,8001009,'importoexporti #2',10520.76
+2001,1001002,'amalgamalg #2',40840.34
+2001,1004001,'exportiexporti #2',27499.42
+2001,10008017,'namelessunivamalg #17',25766.09
+2001,4001001,'scholaramalgamalg #15',23917.98
+2001,7007010,'brandbrand #10',23807.16
+2001,1003001,'exportiamalg #2',21192.81
+2001,6004008,'edu packcorp #8',20966.17
+2001,5003002,'exportischolar #2',20410.45
+2001,8001009,'importoexporti #2',19273.11
+2001,3001002,'amalgexporti #2',18047.23
+2001,6005001,'edu packimporto #2',16801.34
+2001,2001001,'exportischolar #2',15894.57
+2001,5003001,'amalgunivamalg #2',15883.30
+2001,7011010,'amalgnameless #10',15174.18
+2001,5004001,'edu packunivamalg #8',10452.64
+2001,8004010,'edu packnameless #10',8565.95
+2001,3001001,'importoscholar #2',7765.96
+2001,7009008,'maxibrand #8',3570.11
+2002,1001002,'amalgamalg #2',57204.62
+2002,6004008,'edu packcorp #8',39584.99
+2002,8004010,'edu packnameless #10',30357.37
+2002,3001002,'amalgexporti #2',23025.23
+2002,3001001,'importoscholar #2',21157.23
+2002,1003001,'exportiamalg #2',20535.46
+2002,7007010,'brandbrand #10',19387.78
+2002,7009008,'maxibrand #8',17673.93
+2002,5004001,'edu packunivamalg #8',15175.94
+2002,4001001,'scholaramalgamalg #15',14984.83
+2002,6005001,'edu packimporto #2',14774.23
+2002,1004001,'exportiexporti #2',13016.75
+2002,7011010,'amalgnameless #10',12343.97
+2002,10008017,'amalgedu pack #1',10334.40
+2002,10013016,'exportiamalgamalg #16',8356.19
+2002,5003002,'exportischolar #2',5435.81
+2002,2001001,'exportischolar #2',4162.39
+2002,5001001,'amalgscholar #1',3537.49
+---- TYPES
+INT, INT, STRING, DECIMAL
+====
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/impala/blob/35a3e186/testdata/workloads/tpcds/queries/tpcds-decimal_v2-q32.test
----------------------------------------------------------------------
diff --git a/testdata/workloads/tpcds/queries/tpcds-decimal_v2-q32.test b/testdata/workloads/tpcds/queries/tpcds-decimal_v2-q32.test
new file mode 100644
index 0000000..52bbea4
--- /dev/null
+++ b/testdata/workloads/tpcds/queries/tpcds-decimal_v2-q32.test
@@ -0,0 +1,32 @@
+====
+---- QUERY: TPCDS-Q32
+select  sum(cs_ext_discount_amt)  as "excess discount amount"
+from
+   catalog_sales
+   ,item
+   ,date_dim
+where
+i_manufact_id = 977
+and i_item_sk = cs_item_sk
+and cast(d_date as timestamp) between cast('2000-01-27' as timestamp) and
+        (cast('2000-01-27' as timestamp) + interval 90 days)
+and d_date_sk = cs_sold_date_sk
+and cs_ext_discount_amt
+     > (
+         select
+            1.3 * avg(cs_ext_discount_amt)
+         from
+            catalog_sales
+           ,date_dim
+         where
+              cs_item_sk = i_item_sk
+          and cast(d_date as timestamp) between cast('2000-01-27' as timestamp) and
+                             (cast('2000-01-27' as timestamp) + interval 90 days)
+          and d_date_sk = cs_sold_date_sk
+      )
+limit 100;
+---- RESULTS
+28038.14
+---- TYPES
+DECIMAL
+====
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/impala/blob/35a3e186/testdata/workloads/tpcds/queries/tpcds-decimal_v2-q33.test
----------------------------------------------------------------------
diff --git a/testdata/workloads/tpcds/queries/tpcds-decimal_v2-q33.test b/testdata/workloads/tpcds/queries/tpcds-decimal_v2-q33.test
new file mode 100644
index 0000000..7492a17
--- /dev/null
+++ b/testdata/workloads/tpcds/queries/tpcds-decimal_v2-q33.test
@@ -0,0 +1,178 @@
+====
+---- QUERY: TPCDS-Q33
+with ss as (
+ select
+          i_manufact_id,sum(ss_ext_sales_price) total_sales
+ from
+  store_sales,
+  date_dim,
+         customer_address,
+         item
+ where
+         i_manufact_id in (select
+  i_manufact_id
+from
+ item
+where i_category in ('Electronics'))
+ and     ss_item_sk              = i_item_sk
+ and     ss_sold_date_sk         = d_date_sk
+ and     d_year                  = 1998
+ and     d_moy                   = 5
+ and     ss_addr_sk              = ca_address_sk
+ and     ca_gmt_offset           = -5
+ group by i_manufact_id),
+ cs as (
+ select
+          i_manufact_id,sum(cs_ext_sales_price) total_sales
+ from
+  catalog_sales,
+  date_dim,
+         customer_address,
+         item
+ where
+         i_manufact_id               in (select
+  i_manufact_id
+from
+ item
+where i_category in ('Electronics'))
+ and     cs_item_sk              = i_item_sk
+ and     cs_sold_date_sk         = d_date_sk
+ and     d_year                  = 1998
+ and     d_moy                   = 5
+ and     cs_bill_addr_sk         = ca_address_sk
+ and     ca_gmt_offset           = -5
+ group by i_manufact_id),
+ ws as (
+ select
+          i_manufact_id,sum(ws_ext_sales_price) total_sales
+ from
+  web_sales,
+  date_dim,
+         customer_address,
+         item
+ where
+         i_manufact_id               in (select
+  i_manufact_id
+from
+ item
+where i_category in ('Electronics'))
+ and     ws_item_sk              = i_item_sk
+ and     ws_sold_date_sk         = d_date_sk
+ and     d_year                  = 1998
+ and     d_moy                   = 5
+ and     ws_bill_addr_sk         = ca_address_sk
+ and     ca_gmt_offset           = -5
+ group by i_manufact_id)
+  select  i_manufact_id ,sum(total_sales) total_sales
+ from  (select * from ss
+        union all
+        select * from cs
+        union all
+        select * from ws) tmp1
+ group by i_manufact_id
+ order by total_sales
+limit 100;
+---- RESULTS
+698,214.34
+929,539.60
+464,641.96
+938,858.22
+697,959.48
+682,1074.64
+741,1195.96
+812,2069.00
+838,2256.80
+910,2291.67
+899,2355.04
+990,2370.68
+963,2380.92
+832,2684.32
+692,2773.42
+738,2945.77
+564,3210.59
+770,3379.72
+821,3446.02
+797,3485.44
+974,3527.17
+704,3574.75
+853,3850.44
+898,3854.56
+937,3968.27
+737,4284.65
+942,4618.19
+798,5017.15
+849,5099.82
+939,5122.92
+947,5138.04
+774,5138.38
+668,5666.30
+607,5770.19
+358,5955.66
+860,5957.46
+951,5973.81
+472,6060.92
+824,6198.72
+766,6237.09
+783,6341.40
+799,6360.64
+794,6474.90
+529,6476.80
+928,6536.81
+946,6817.54
+795,6859.76
+793,6871.33
+423,6878.60
+811,6887.18
+887,6998.14
+961,7098.23
+806,7143.83
+772,7196.00
+880,7202.52
+709,7247.76
+696,7732.80
+710,7783.45
+784,7894.58
+780,7973.56
+476,8166.70
+839,8299.55
+828,8398.05
+968,8461.36
+966,8715.08
+872,8722.84
+432,8779.74
+842,8879.82
+981,8899.15
+567,9226.08
+773,9431.83
+430,9891.62
+445,9913.18
+678,9976.96
+977,10067.34
+705,10202.62
+402,10322.05
+789,10376.28
+733,10653.42
+936,10760.28
+920,10922.38
+658,10926.50
+1000,10992.09
+651,11129.87
+965,11158.41
+844,11348.42
+954,11383.41
+655,11632.71
+99,11785.13
+493,11859.91
+723,12068.58
+623,12388.39
+874,12585.39
+810,12598.51
+299,12649.43
+826,12657.78
+870,12927.40
+385,12992.19
+590,13381.82
+718,13768.98
+---- TYPES
+INT, DECIMAL
+====
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/impala/blob/35a3e186/testdata/workloads/tpcds/queries/tpcds-decimal_v2-q34.test
----------------------------------------------------------------------
diff --git a/testdata/workloads/tpcds/queries/tpcds-decimal_v2-q34.test b/testdata/workloads/tpcds/queries/tpcds-decimal_v2-q34.test
new file mode 100644
index 0000000..7572aed
--- /dev/null
+++ b/testdata/workloads/tpcds/queries/tpcds-decimal_v2-q34.test
@@ -0,0 +1,504 @@
+====
+---- QUERY: TPCDS-Q34
+select
+  c_last_name,
+  c_first_name,
+  c_salutation,
+  c_preferred_cust_flag,
+  ss_ticket_number,
+  cnt
+from
+  (select
+    ss_ticket_number,
+    ss_customer_sk,
+    count(*) cnt
+  from
+    store_sales,
+    date_dim,
+    store,
+    household_demographics
+  where
+    store_sales.ss_sold_date_sk = date_dim.d_date_sk
+    and store_sales.ss_store_sk = store.s_store_sk
+    and store_sales.ss_hdemo_sk = household_demographics.hd_demo_sk
+    and (date_dim.d_dom between 1 and 3
+      or date_dim.d_dom between 25 and 28)
+    and (household_demographics.hd_buy_potential = '>10000'
+      or household_demographics.hd_buy_potential = 'Unknown')
+    and household_demographics.hd_vehicle_count > 0
+    and (case when household_demographics.hd_vehicle_count > 0
+         then (1.0 * household_demographics.hd_dep_count) / (1.0 * household_demographics.hd_vehicle_count)
+         else null end) > 1.2
+    and date_dim.d_year in (1999, 1999 + 1, 1999 + 2)
+    and store.s_county in ('Williamson County','Williamson County','Williamson County','Williamson County',
+                           'Williamson County','Williamson County','Williamson County','Williamson County')
+  group by
+    ss_ticket_number,
+    ss_customer_sk
+  ) dn,
+  customer
+where
+  ss_customer_sk = c_customer_sk
+  and cnt between 15 and 20
+order by
+  c_last_name,
+  c_first_name,
+  c_salutation,
+  c_preferred_cust_flag desc,
+  cnt,
+  ss_ticket_number;
+---- RESULTS
+'Abbott','Harriet','Ms.','N',195008,15
+'Acosta','Victor','Mr.','N',156807,15
+'Adams','Jerry','Sir','N',216653,15
+'Adams','Willie','Sir','N',88285,15
+'Alford','Deborah','Miss','N',97678,15
+'Allen','Marty','Sir','N',63646,15
+'Anderson','Cindy','Miss','N',90504,15
+'Anderson','Eloise','Mrs.','Y',59994,16
+'Anderson','Marta','Dr.','N',176320,15
+'Anderson','Martha','Mrs.','N',74295,15
+'Anderson','Norma','Miss','Y',132983,16
+'Anderson','Rosemarie','Mrs.','N',178489,15
+'Andrews','Cindy','Miss','Y',132595,16
+'Andrews','Michael','Sir','N',135694,15
+'Andrews','Robert','Sir','Y',30467,15
+'Appleton','Gary','Dr.','N',58554,16
+'Archibald','Cindy','Miss','Y',87178,16
+'Arredondo','Phyllis','Ms.','Y',226220,16
+'Arsenault','Janet','Mrs.','N',169973,16
+'Ashton','Irma','Mrs.','Y',99233,15
+'Bailey','Lucille','Mrs.','N',2490,15
+'Baker','Erik','Sir','Y',69511,15
+'Barba','William','Sir','Y',102719,15
+'Barnes','John','Dr.','N',74071,15
+'Barnes','Michael','Mr.','N',168802,15
+'Bear','Tommy','Sir','Y',27468,15
+'Beasley','Joshua','Dr.','Y',32731,15
+'Bell','William','Mr.','Y',82227,15
+'Bender','Grover','Dr.','N',152239,15
+'Benedict','Bridget','Dr.','N',16544,15
+'Benson','Mike','Sir','Y',53219,16
+'Berry','Theresa','Ms.','Y',77257,15
+'Bilodeau','Norma','Ms.','Y',136244,15
+'Blake','John','Mr.','N',193896,15
+'Blanchard','Joanne','Dr.','N',5917,15
+'Boles','George','Sir','N',64282,15
+'Bolin','Yolanda','Dr.','N',13057,16
+'Bowden','Kathleen','Ms.','N',106265,15
+'Box','Eric','Dr.','N',79283,16
+'Boyd','Mildred','Miss','N',190083,15
+'Boyer','Betty','Mrs.','Y',171238,16
+'Boyle','Timothy','Dr.','N',21865,16
+'Brandt','James','Sir','Y',60562,15
+'Brantley','Frank','Dr.','N',66867,15
+'Brewer','Lynne','Ms.','N',77584,15
+'Broughton','Doretta','Ms.','Y',206939,16
+'Brower','Donald','Dr.','N',163579,15
+'Brown','David','Mr.','N',162755,16
+'Brown','Frederick','Mr.','N',120037,15
+'Brown','Janette','Dr.','Y',7269,16
+'Brown','Janice','Ms.','Y',138617,15
+'Brown','Raymond','Mr.','Y',212279,15
+'Brown','Roderick','Mr.','N',221290,16
+'Brown','Will','Mr.','Y',147392,15
+'Buck','Andrew','Dr.','N',128839,15
+'Burch','Diana','Mrs.','Y',115522,15
+'Burdette','Ronald','Mr.','Y',118097,15
+'Butcher','Francine','Mrs.','N',112093,15
+'Butcher','Thomas','Mr.','N',213918,15
+'Butler','Amos','Dr.','N',7184,15
+'Butler','Nicole','Dr.','N',214214,16
+'Byrd','Stephanie','Miss','Y',24803,15
+'Byrd','Wanda','Ms.','Y',155385,15
+'Campbell','Gordon','Mr.','N',196090,15
+'Campbell','William','Mr.','N',95665,15
+'Carlson','Gwendolyn','Dr.','Y',88472,15
+'Carpenter','Stephen','Mr.','Y',174519,16
+'Carroll','Frederick','Mr.','Y',56635,15
+'Carter','Cecil','Dr.','Y',34336,16
+'Carter','Eddie','Dr.','N',226103,16
+'Carter','Olga','Mrs.','N',84776,15
+'Casey','Darrell','Sir','N',181470,15
+'Castro','Sandra','Ms.','N',87567,15
+'Chandler','Lisa','Dr.','N',102461,16
+'Chang','Bradley','Sir','Y',53396,15
+'Chang','Erik','Sir','Y',140138,15
+'Chase','Daniel','Dr.','Y',129179,15
+'Cheek','Rebecca','Mrs.','Y',82193,15
+'Chen','Brett','Mr.','N',7880,15
+'Christenson','Steven','Mr.','Y',156157,15
+'Clark','Elisa','Mrs.','Y',234445,15
+'Clark','Elizabeth','Dr.','Y',58831,15
+'Clark','Meredith','Dr.','N',229216,16
+'Clark','Rosemary','Miss','Y',31542,15
+'Clayton','Michael','Mr.','N',69714,16
+'Clemente','Patrick','Sir','Y',179702,15
+'Clifford','Bessie','Dr.','N',61376,16
+'Clifford','John','Sir','Y',12960,15
+'Cochran','Dennis','Sir','Y',94375,15
+'Coker','John','Mr.','N',2730,15
+'Cole','Amanda','Dr.','Y',92994,15
+'Cole','Gretchen','Dr.','N',191039,15
+'Cole','June','Miss','N',206225,16
+'Cole','Melanie','Mrs.','Y',208547,15
+'Coleman','Nancy','Ms.','N',39446,16
+'Collier','NULL','Mr.','Y',179488,15
+'Collins','Patsy','Ms.','N',13775,15
+'Conner','Sondra','Miss','N',191684,15
+'Conrad','Jason','Mr.','N',166289,15
+'Cook','John','Mr.','N',237195,15
+'Cook','NULL','Sir','NULL',81755,15
+'Cope','Felicia','Dr.','Y',195003,15
+'Cordero','Dwight','Sir','Y',147038,15
+'Cota','Jorge','Mr.','N',3324,15
+'Crouch','Roberto','Dr.','Y',160826,15
+'Cruz','Donna','Ms.','N',180864,15
+'Cruz','Tamara','Ms.','N',112086,16
+'Dalton','Dorthea','Dr.','Y',37698,15
+'David','Timothy','Mr.','Y',20342,16
+'Davis','Donya','Miss','N',31118,15
+'Davis','Jess','Sir','Y',197947,15
+'Davis','Sandra','Ms.','N',141249,15
+'Davis','Vickie','Miss','Y',35264,15
+'Davison','Jeffrey','Mr.','Y',81413,16
+'Dejesus','Lorena','Dr.','NULL',157934,15
+'Delacruz','Brenton','Mr.','Y',96016,15
+'Delagarza','John','Mr.','N',62980,15
+'Diaz','Brian','Mr.','N',73210,15
+'Dietrich','Tammy','Dr.','N',114650,15
+'Dorsey','Lisa','Dr.','Y',5587,15
+'Dorsey','Melvin','Mr.','Y',231758,15
+'Dunn','Stephen','Sir','N',32455,15
+'Eason','Mario','Sir','N',174089,15
+'Easton','Christopher','Sir','Y',10691,15
+'Elliot','Mark','Mr.','Y',35782,16
+'Esquivel','Hee','Mrs.','Y',42741,15
+'Evans','April','Dr.','Y',41310,15
+'Faison','Roy','Sir','Y',147757,15
+'Farnsworth','Danny','Mr.','Y',29979,15
+'Ferrell','Roy','Mr.','N',139997,15
+'Ferris','William','Sir','Y',12536,15
+'Fields','Philomena','Dr.','N',217374,15
+'Fife','Terry','Dr.','N',81012,15
+'Finn','Margaret','Dr.','N',207070,15
+'Fitzgerald','Thomas','Mr.','Y',2698,15
+'Floyd','Lillian','Dr.','Y',84374,16
+'Flynn','Rhonda','Miss','N',96322,15
+'Forney','Christopher','Sir','N',175230,15
+'Franklin','Dorothy','Miss','Y',210152,15
+'Franklin','Eileen','Miss','Y',88556,15
+'Franklin','Judy','Ms.','Y',27813,15
+'Freeman','Rayford','Dr.','N',36115,15
+'Freeman','NULL','Mrs.','Y',175123,15
+'Fuqua','Harvey','Mr.','N',130609,16
+'Galindo','Karen','Dr.','N',100437,15
+'Galloway','Betty','Mrs.','Y',10097,15
+'Garcia','Kenny','Dr.','N',197122,16
+'Garrison','Robert','Sir','Y',40421,15
+'Garza','William','Sir','N',43273,15
+'German','Katie','Dr.','N',33536,16
+'Gibbons','Christopher','Sir','Y',237265,16
+'Gibbons','Vivian','Mrs.','Y',95173,16
+'Gibson','Agnes','Miss','N',228161,15
+'Gil','Yvette','Mrs.','Y',86699,15
+'Gill','Joshua','Sir','Y',230910,16
+'Glass','Jorge','Sir','N',137536,15
+'Gomez','Brandon','Sir','Y',160457,15
+'Gonzales','Cindy','Dr.','Y',96495,15
+'Gonzales','Edgar','Sir','N',153714,15
+'Gonzalez','Ruby','Mrs.','Y',228694,15
+'Gordon','Larry','Sir','Y',99782,15
+'Graham','Brian','Mr.','N',13629,15
+'Graham','Jerry','Sir','NULL',152656,15
+'Gray','Jeffery','Mr.','Y',154258,15
+'Grayson','Carolyn','Mrs.','N',69374,16
+'Grayson','Terry','Mr.','N',130480,16
+'Green','Cynthia','Mrs.','Y',141374,15
+'Green','Robert','Mr.','N',73965,15
+'Griffin','Martha','Dr.','N',82841,16
+'Grubbs','Florence','Mrs.','N',47930,15
+'Gulley','Daniel','Sir','Y',37484,16
+'Gutierrez','Ashley','Dr.','N',209948,16
+'Guzman','Mason','Mr.','Y',235019,16
+'Haley','Henry','Sir','Y',141619,15
+'Hall','Roger','Mr.','N',136216,15
+'Hamilton','Alex','Mrs.','N',23084,15
+'Hammonds','Richelle','Dr.','Y',135423,15
+'Hampton','NULL','NULL','N',11567,15
+'Hardy','Inez','Ms.','Y',104878,15
+'Harris','Charles','Dr.','Y',61618,15
+'Harris','Ezekiel','Sir','N',142043,15
+'Harrison','Jennifer','Ms.','Y',63097,15
+'Harrison','Michal','Mr.','Y',209687,15
+'Harrison','Qiana','Dr.','Y',10522,15
+'Hawkins','Clyde','Dr.','Y',236510,15
+'Hayes','Elizabeth','Mrs.','N',213826,15
+'Hayes','Johnnie','Sir','N',57732,15
+'Hayes','William','Sir','Y',223946,15
+'Haynes','Jennifer','Dr.','N',203136,15
+'Haywood','Judy','Mrs.','N',167146,15
+'Hernandez','Paul','Dr.','N',190691,15
+'Hernandez','Sandra','Dr.','Y',14252,16
+'Hewitt','Michelle','Dr.','N',155492,15
+'Hill','Barbara','Ms.','Y',88890,15
+'Hill','Julia','Dr.','N',191695,16
+'Horton','Michelle','Ms.','Y',112716,16
+'Howell','Katherine','Dr.','N',147571,16
+'Huffman','Beverly','Ms.','Y',166660,16
+'Hughes','Martin','Dr.','Y',178631,15
+'Ivey','John','Mr.','N',189224,15
+'Jackman','Ida','Dr.','Y',11753,15
+'Jackson','Kathy','Ms.','N',233945,15
+'Johnson','Lottie','Ms.','N',131031,15
+'Johnson','Olen','Mr.','N',12862,15
+'Johnson','Richard','Dr.','N',52256,15
+'Johnston','Walter','Mr.','Y',219689,15
+'Jones','Austin','Dr.','Y',57009,15
+'Jones','Eleanor','Ms.','N',27477,16
+'Jones','Jarvis','Sir','Y',74474,16
+'Jones','Rebecca','Dr.','Y',187035,16
+'Jones','Richard','Dr.','Y',232872,15
+'Joseph','Ramon','Mr.','N',7856,15
+'Joyce','NULL','Ms.','NULL',154184,16
+'Keaton','Lacey','Mrs.','N',133023,15
+'Keith','Bruce','Dr.','Y',24541,15
+'Kelly','Betty','Dr.','Y',151468,16
+'Kim','Bridget','Mrs.','Y',62861,15
+'King','Thomas','Sir','N',62796,15
+'Kinney','Angelica','Mrs.','N',192978,16
+'Kline','Donald','Mr.','Y',161957,15
+'Knight','Terence','Dr.','N',176372,16
+'Kraus','Roger','Dr.','Y',117604,16
+'Kruse','Jose','Dr.','N',114533,15
+'Lacy','Mina','Miss','N',227155,15
+'Ladner','Lisa','Dr.','Y',213223,15
+'Laird','Mark','Mr.','N',65882,15
+'Lavender','Robert','Sir','Y',3754,15
+'Lawson','Amanda','Ms.','Y',61212,16
+'Lawson','Kelly','Mr.','Y',64975,15
+'Le','Rodney','Dr.','Y',79356,16
+'Leigh','Abraham','Mr.','N',10283,15
+'Lewis','Annie','Ms.','Y',131418,15
+'Lewis','Bradley','Sir','N',182566,16
+'Lewis','Jerry','Mr.','Y',233447,15
+'Light','Robert','Mr.','Y',90021,15
+'Lin','Robert','Dr.','Y',236887,15
+'Lopez','Randee','Miss','N',9979,15
+'Lopez','Theresa','Miss','Y',169110,15
+'Lott','Ronald','Sir','N',79453,15
+'Love','Sean','Mr.','N',196652,15
+'Lowe','Elmer','Sir','N',133003,16
+'Lozano','Charlotte','Mrs.','Y',31661,15
+'Macias','Roger','Sir','N',82746,15
+'Mansfield','Paul','Dr.','Y',5723,15
+'Manuel','Doris','Mrs.','Y',148847,15
+'Marks','Duane','Dr.','Y',34432,15
+'Marsh','Gary','Sir','Y',6580,15
+'Martin','Donald','Dr.','N',238840,16
+'Martin','Steve','Mr.','N',72094,16
+'Mason','Richard','Sir','Y',27500,16
+'Mast','Catalina','Miss','Y',178574,15
+'Matos','Josephine','Ms.','N',128283,16
+'Maxey','Sharon','Ms.','N',74649,16
+'Mccallister','Andrew','Ms.','Y',122178,15
+'Mccloud','Nicholas','Mr.','Y',28001,15
+'Mcconnell','Scott','Mr.','Y',78305,15
+'Mccormick','Joanne','Ms.','N',236985,15
+'Mcdaniel','Brian','Sir','N',217760,15
+'Mcdonald','Araceli','Ms.','Y',121343,15
+'Mcewen','Barbara','Mrs.','N',179491,15
+'Mckenzie','Ana','Ms.','N',201062,16
+'Mcnamara','Joann','Mrs.','Y',229870,15
+'Mcswain','Virgil','Mr.','N',71937,16
+'Melton','Monique','Ms.','Y',177605,15
+'Miller','Brian','Dr.','N',203465,16
+'Miller','Dennis','Dr.','N',137781,15
+'Miller','Edward','Sir','N',64767,16
+'Miller','Georgia','Ms.','N',40740,16
+'Miller','Karrie','Dr.','N',170750,15
+'Miller','Nancy','Mrs.','N',82671,16
+'Montgomery','Julie','Miss','N',17471,15
+'Moore','Barbara','Dr.','N',69608,15
+'Moore','Jeffrey','Sir','Y',155931,15
+'Moore','Lorena','Mrs.','Y',47752,15
+'Moore','Peggy','Miss','Y',191466,15
+'Morgan','Betty','Dr.','N',90306,15
+'Morgan','Latricia','Mrs.','N',216137,15
+'Morris','John','Dr.','Y',214378,15
+'Morris','Martina','Miss','N',32596,15
+'Morris','Meghan','Mrs.','Y',127565,15
+'Moses','Amy','Dr.','Y',182188,15
+'Moss','Michael','NULL','NULL',137243,15
+'Moultrie','Martin','Dr.','N',215102,15
+'Mulligan','Mark','Sir','Y',184598,16
+'Mullins','Vicki','Dr.','Y',162762,15
+'Murphy','Michael','Sir','Y',210567,15
+'Neeley','Stephanie','Mrs.','N',216299,15
+'Nelson','Everette','Dr.','N',80821,15
+'Nesbitt','Andrew','Miss','N',185257,15
+'Norfleet','Ethel','Miss','N',14366,15
+'Olds','Stephen','Dr.','N',206275,16
+'Olson','David','Dr.','Y',87821,16
+'Oneill','Thomas','Mr.','N',188154,15
+'Oneill','Thomas','Mr.','N',93473,16
+'Osborn','Lena','Miss','Y',226949,16
+'Outlaw','Dennis','Sir','N',115215,16
+'Owens','Terry','Dr.','N',144931,15
+'Page','Elizabeth','Ms.','N',146879,15
+'Page','James','Dr.','Y',214208,16
+'Palacios','Amber','Dr.','Y',225723,15
+'Palmer','Debbie','Dr.','Y',121860,15
+'Park','Jerry','Dr.','N',73028,15
+'Peace','Carlos','Sir','N',203823,15
+'Perez','Harold','Mr.','Y',6311,15
+'Perez','Sheri','Ms.','N',157585,15
+'Perry','Sarah','Ms.','N',100885,15
+'Perry','Valeria','Mrs.','N',64861,15
+'Phelps','Marco','Dr.','Y',86494,16
+'Powell','Robert','Sir','Y',185862,15
+'Price','Florence','Ms.','Y',17220,15
+'Price','Gloria','Mrs.','Y',22568,15
+'Price','Marguerite','Mrs.','N',134265,16
+'Price','Marie','Ms.','N',88963,15
+'Price','Paul','Sir','N',103985,16
+'Price','Reginald','Sir','Y',123793,15
+'Price','NULL','Sir','N',55817,15
+'Pridgen','Hans','Dr.','N',207216,15
+'Ramirez','Lee','Sir','N',234584,15
+'Ramos','David','Dr.','Y',189463,16
+'Reece','Jimmy','Sir','N',166493,16
+'Reyes','Frank','NULL','NULL',84620,15
+'Reyna','Rod','Sir','N',46248,16
+'Reynolds','Oscar','Sir','Y',222749,15
+'Richardson','Alice','Ms.','N',43255,16
+'Riddle','John','Sir','Y',83916,15
+'Riddle','Marcelino','Dr.','N',60749,15
+'Rivera','Kate','Ms.','Y',204524,15
+'Robb','Laura','Miss','NULL',173667,15
+'Roberts','Candice','Dr.','Y',111855,16
+'Roberts','Dorothy','Ms.','N',183154,15
+'Roberts','Jennifer','Miss','Y',141296,15
+'Robinson','Gary','Mr.','Y',87081,15
+'Robinson','Sara','Mrs.','N',190406,15
+'Roldan','Dorothy','Mrs.','N',9370,15
+'Roman','Jimmie','Dr.','Y',221049,15
+'Ross','Rachael','Mrs.','N',106042,16
+'Ross','Robert','Mr.','Y',165295,15
+'Russ','Amber','Mrs.','N',225981,15
+'Russell','Larry','Dr.','Y',15209,16
+'Russell','Mark','Dr.','N',126453,15
+'Sacco','Brian','Sir','N',124398,16
+'Saddler','Robert','Mr.','Y',74571,15
+'Salinas','Kenneth','Dr.','Y',167446,15
+'Salter','Antonio','Miss','N',27497,16
+'Sanders','Dustin','Mr.','N',20319,15
+'Sandoval','Vincent','Mr.','N',140438,16
+'Sanford','Ronald','Sir','N',211947,15
+'Saunders','Mae','Miss','N',108927,15
+'Scott','Adam','Mrs.','N',13944,15
+'Scott','Ethel','Dr.','N',112707,15
+'Scott','Michael','Mr.','Y',104162,15
+'Self','Harry','Sir','Y',102208,16
+'Shaffer','Richard','Dr.','N',190775,16
+'Shuler','Joseph','Sir','N',57224,16
+'Sims','Fern','Dr.','Y',175233,15
+'Sims','John','Dr.','Y',113923,15
+'Smalls','Celeste','Ms.','Y',168837,15
+'Smith','Dalene','Ms.','Y',143125,16
+'Smith','Herbert','Dr.','Y',238646,15
+'Smith','John','Mr.','N',93525,16
+'Smith','Marion','Mr.','Y',65393,15
+'Smith','Ralph','Sir','N',87132,16
+'Smith','Terry','Dr.','Y',16945,15
+'Smith','Toni','Miss','N',50011,15
+'Smith','Wendell','Sir','N',85496,15
+'Soares','Sally','Ms.','Y',203554,16
+'Sparks','Michael','Mr.','Y',23696,15
+'Spears','Edith','Ms.','Y',223566,15
+'Spencer','Alfred','Mr.','Y',159308,15
+'Spencer','Teri','Mrs.','N',28551,16
+'Stafford','Jerry','Mr.','Y',230470,15
+'Stamper','Rebekah','Dr.','N',235329,15
+'Stephens','Donna','Ms.','N',151844,15
+'Stevens','Mattie','Ms.','N',202640,15
+'Stevens','Micheal','Dr.','Y',38659,16
+'Stewart','Amanda','Mrs.','Y',145235,15
+'Stewart','Gilbert','Mr.','Y',217862,15
+'Stewart','Kendra','Mrs.','Y',16423,15
+'Stewart','Pamela','Mrs.','Y',88160,16
+'Straub','Lowell','Dr.','Y',215956,16
+'Street','Lee','Mr.','N',171013,15
+'Sullivan','Amy','Dr.','N',166225,15
+'Swain','Laura','Ms.','Y',36774,16
+'Swisher','Brian','Mr.','Y',53341,15
+'Taylor','Arlene','Dr.','Y',71934,15
+'Taylor','Jacqueline','Mrs.','Y',89977,16
+'Taylor','Karen','Dr.','N',29777,15
+'Taylor','Robert','Dr.','N',37700,15
+'Thomas','Barbara','Dr.','N',172596,15
+'Thomas','Christel','Dr.','Y',34579,15
+'Thomas','Jeffrey','Dr.','Y',115846,15
+'Thomas','Nichole','Miss','N',200721,16
+'Thomas','Rebecca','Mrs.','N',80953,15
+'Thompson','Brenda','Dr.','N',171735,15
+'Thompson','Melissa','Dr.','N',162831,15
+'Tidwell','Phyllis','NULL','NULL',234037,16
+'Tilley','Jane','Mrs.','Y',45378,15
+'Tinsley','Charlie','Dr.','N',23881,16
+'Tolbert','Emily','Miss','Y',40132,15
+'Tompkins','Charlotte','NULL','NULL',197857,15
+'Torres','Jason','Dr.','N',224,16
+'Torres','Roberta','Ms.','N',29436,15
+'Townsend','Michelle','Mrs.','N',39872,15
+'Turner','Kerry','Dr.','Y',23710,16
+'Turner','Marjorie','Mrs.','N',65289,15
+'Valenzuela','Bryan','Sir','Y',221858,16
+'Vance','Josefina','Mrs.','N',147148,15
+'Vargas','Charles','Dr.','Y',79536,15
+'Vogel','Leroy','Sir','Y',29032,15
+'Walker','Jim','Sir','N',46947,15
+'Walker','Jose','Sir','Y',189670,16
+'Walker','Richard','Sir','NULL',226475,15
+'Wall','Russell','Sir','N',17231,16
+'Wallace','Joseph','Sir','N',27193,15
+'Walsh','Javier','Sir','Y',211987,16
+'Warren','Brian','Dr.','N',15877,15
+'Watson','Tina','Ms.','Y',120030,16
+'Webb','Gloria','Ms.','N',65663,15
+'Welch','Pauline','Mrs.','Y',47529,15
+'West','Carman','Ms.','NULL',237594,15
+'West','Rachel','Dr.','Y',138384,15
+'Wetzel','Bebe','Dr.','N',82518,15
+'White','Diane','Dr.','Y',82960,16
+'White','Johnny','Dr.','N',204026,16
+'Whitehead','Magan','Dr.','N',192159,16
+'Wiggins','Kermit','Sir','N',112643,15
+'Wilbur','Terry','Sir','N',200312,15
+'Williams','Archie','Mr.','N',113007,15
+'Williams','Karen','Ms.','Y',140802,15
+'Williams','Scott','NULL','NULL',136844,16
+'Willis','Amber','Ms.','N',53815,15
+'Willis','Michael','Sir','Y',207326,15
+'Wilson','Charles','Mr.','Y',60,15
+'Wood','Mark','Dr.','N',4376,15
+'Woody','Philip','Mr.','N',211173,16
+'Wright','Amanda','NULL','Y',105395,15
+'Yates','Kimberly','Ms.','Y',220849,15
+'NULL','Grace','NULL','NULL',147095,16
+'NULL','Joshua','Sir','N',108357,15
+'NULL','Judy','Dr.','NULL',234350,16
+'NULL','Roy','NULL','NULL',200033,15
+'NULL','NULL','Mr.','Y',214003,15
+'NULL','NULL','Ms.','NULL',54536,16
+'NULL','NULL','NULL','NULL',151297,15
+'NULL','NULL','NULL','NULL',148695,16
+'NULL','NULL','NULL','Y',16278,15
+'NULL','NULL','NULL','Y',146557,16
+'NULL','NULL','NULL','N',55640,15
+'NULL','NULL','NULL','N',58614,15
+'NULL','NULL','NULL','N',96514,15
+'NULL','NULL','NULL','N',220211,15
+---- TYPES
+STRING, STRING, STRING, STRING, BIGINT, BIGINT
+====
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/impala/blob/35a3e186/testdata/workloads/tpcds/queries/tpcds-decimal_v2-q37.test
----------------------------------------------------------------------
diff --git a/testdata/workloads/tpcds/queries/tpcds-decimal_v2-q37.test b/testdata/workloads/tpcds/queries/tpcds-decimal_v2-q37.test
new file mode 100644
index 0000000..b283ebc
--- /dev/null
+++ b/testdata/workloads/tpcds/queries/tpcds-decimal_v2-q37.test
@@ -0,0 +1,22 @@
+====
+---- QUERY: TPCDS-Q37
+-- start query 1 in stream 0 using template query37.tpl
+select  i_item_id
+       ,i_item_desc
+       ,i_current_price
+ from item, inventory, date_dim, catalog_sales
+ where i_current_price between 68 and 68 + 30
+ and inv_item_sk = i_item_sk
+ and d_date_sk=inv_date_sk
+ and cast(d_date as timestamp) between cast('2000-02-01' as timestamp) and (cast('2000-02-01' as timestamp) + interval 60 days)
+ and i_manufact_id in (677,940,694,808)
+ and inv_quantity_on_hand between 100 and 500
+ and cs_item_sk = i_item_sk
+ group by i_item_id,i_item_desc,i_current_price
+ order by i_item_id
+ limit 100;
+---- RESULTS
+'AAAAAAAAHFMBAAAA','Jobs crack at all public countries. Possible, traditional initiatives will make british problems. Fiscal years call extremely just growing pupils. Soon dutch voices',86.11
+---- TYPES
+STRING, STRING, DECIMAL
+====
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/impala/blob/35a3e186/testdata/workloads/tpcds/queries/tpcds-decimal_v2-q39-1.test
----------------------------------------------------------------------
diff --git a/testdata/workloads/tpcds/queries/tpcds-decimal_v2-q39-1.test b/testdata/workloads/tpcds/queries/tpcds-decimal_v2-q39-1.test
new file mode 100644
index 0000000..29d712b
--- /dev/null
+++ b/testdata/workloads/tpcds/queries/tpcds-decimal_v2-q39-1.test
@@ -0,0 +1,278 @@
+====
+---- QUERY: TPCDS-Q39.1
+-- RESULT MISMATCH FROM ORIGINAL
+-- ADD ROUND()s TO 4th, 5th, 9th, 10th COLUMNS, TAKE ACTUAL RESULTS AS EXPECTED.
+with inv as
+(select w_warehouse_name,w_warehouse_sk,i_item_sk,d_moy
+       ,stdev,mean, case mean when 0 then null else stdev/mean end cov
+ from(select w_warehouse_name,w_warehouse_sk,i_item_sk,d_moy
+            ,stddev_samp(inv_quantity_on_hand) stdev,avg(inv_quantity_on_hand) mean
+      from inventory
+          ,item
+          ,warehouse
+          ,date_dim
+      where inv_item_sk = i_item_sk
+        and inv_warehouse_sk = w_warehouse_sk
+        and inv_date_sk = d_date_sk
+        and d_year =2001
+      group by w_warehouse_name,w_warehouse_sk,i_item_sk,d_moy) foo
+ where case mean when 0 then 0 else stdev/mean end > 1)
+select inv1.w_warehouse_sk,inv1.i_item_sk,inv1.d_moy
+        ,round(inv1.mean, 2), round(inv1.cov, 8)
+        ,inv2.w_warehouse_sk,inv2.i_item_sk,inv2.d_moy
+        ,round(inv2.mean, 2), round(inv2.cov, 8)
+from inv inv1,inv inv2
+where inv1.i_item_sk = inv2.i_item_sk
+  and inv1.w_warehouse_sk =  inv2.w_warehouse_sk
+  and inv1.d_moy=1
+  and inv2.d_moy=1+1
+order by inv1.w_warehouse_sk,inv1.i_item_sk,inv1.d_moy,inv1.mean,inv1.cov
+        ,inv2.d_moy,inv2.mean, inv2.cov
+;
+---- RESULTS
+1,265,1,324.75,1.24383918,1,265,2,329.00,1.01515813
+1,363,1,499.50,1.03194157,1,363,2,321.00,1.14117668
+1,679,1,373.75,1.09554981,1,679,2,417.50,1.04297099
+1,695,1,450.75,1.08358883,1,695,2,368.75,1.13564941
+1,789,1,357.25,1.03450938,1,789,2,410.00,1.02842219
+1,815,1,216.50,1.17022709,1,815,2,150.50,1.30572815
+1,827,1,271.75,1.10468901,1,827,2,424.75,1.16531986
+1,1041,1,382.50,1.28480840,1,1041,2,424.75,1.00057727
+1,1569,1,212.00,1.63021352,1,1569,2,239.25,1.26415133
+1,1623,1,338.25,1.12854833,1,1623,2,261.33,1.27178090
+1,2581,1,448.50,1.06042904,1,2581,2,476.25,1.03629847
+1,2705,1,246.25,1.01203084,1,2705,2,294.67,1.07421341
+1,3131,1,393.75,1.00376140,1,3131,2,480.50,1.06691450
+1,3291,1,374.50,1.19518983,1,3291,2,265.25,1.57297211
+1,3687,1,279.75,1.42609091,1,3687,2,157.25,1.45343409
+1,4955,1,495.25,1.03182962,1,4955,2,322.50,1.16938423
+1,5627,1,282.75,1.56570324,1,5627,2,297.50,1.20842868
+1,7017,1,175.50,1.04274542,1,7017,2,321.33,1.01833569
+1,7317,1,366.33,1.02546640,1,7317,2,378.00,1.21725132
+1,7569,1,430.50,1.08743969,1,7569,2,360.25,1.04700556
+1,7999,1,166.25,1.79242317,1,7999,2,375.33,1.00809226
+1,8319,1,306.75,1.16153780,1,8319,2,276.00,1.14209964
+1,8443,1,327.75,1.25671837,1,8443,2,332.50,1.00441673
+1,8583,1,319.50,1.02410889,1,8583,2,310.25,1.23588138
+1,8591,1,398.00,1.14781687,1,8591,2,355.75,1.00244721
+1,8611,1,300.50,1.51915452,1,8611,2,243.75,1.23421228
+1,9081,1,367.00,1.08789321,1,9081,2,435.00,1.03305308
+1,9357,1,351.67,1.19029226,1,9357,2,427.00,1.04385830
+1,9449,1,406.25,1.01831831,1,9449,2,175.00,1.05447798
+1,9713,1,242.50,1.10350444,1,9713,2,393.00,1.20847461
+1,9809,1,479.00,1.01896025,1,9809,2,317.50,1.06141421
+1,9993,1,417.75,1.00998327,1,9993,2,204.50,1.55287075
+1,10127,1,239.75,1.05617706,1,10127,2,359.25,1.18579804
+1,11159,1,407.25,1.07855072,1,11159,2,250.00,1.33475791
+1,11277,1,211.25,1.26158583,1,11277,2,330.75,1.08087680
+1,11937,1,344.50,1.08580403,1,11937,2,200.33,1.06385271
+1,12373,1,387.75,1.10149048,1,12373,2,306.00,1.07617444
+1,12471,1,365.25,1.06075702,1,12471,2,327.25,1.05475606
+1,12625,1,279.00,1.30165605,1,12625,2,443.25,1.06049588
+1,12751,1,280.75,1.10833058,1,12751,2,369.33,1.34165044
+1,12779,1,331.00,1.04169021,1,12779,2,359.00,1.02897806
+1,13077,1,367.67,1.34552390,1,13077,2,358.67,1.51324291
+1,13191,1,260.25,1.06356963,1,13191,2,405.00,1.01979992
+1,13561,1,335.25,1.26096170,1,13561,2,240.00,1.05136045
+1,13935,1,311.75,1.03992897,1,13935,2,275.00,1.03675272
+1,14687,1,358.00,1.43693569,1,14687,2,187.00,1.54936315
+1,14719,1,209.00,1.04115096,1,14719,2,489.00,1.37661688
+1,15345,1,148.50,1.52957840,1,15345,2,246.50,1.50879877
+1,15427,1,482.75,1.01242389,1,15427,2,333.25,1.27247701
+1,15647,1,201.67,1.28579319,1,15647,2,249.25,1.36481730
+1,16079,1,280.50,1.24447574,1,16079,2,361.25,1.07378057
+1,16223,1,245.67,1.06011490,1,16223,2,412.67,1.06712311
+1,16289,1,171.00,1.08726331,1,16289,2,316.50,1.36953067
+1,16451,1,300.00,1.25165076,1,16451,2,467.50,1.29623639
+1,17051,1,349.75,1.13464238,1,17051,2,319.75,1.03793549
+2,71,1,221.50,1.56397411,2,71,2,309.00,1.49170579
+2,833,1,363.33,1.04228138,2,833,2,158.75,1.21308917
+2,969,1,282.00,1.13743403,2,969,2,386.00,1.13710012
+2,1401,1,249.00,1.32062377,2,1401,2,296.67,1.28681219
+2,1681,1,337.75,1.05215660,2,1681,2,252.75,1.03179107
+2,1991,1,356.00,1.13367900,2,1991,2,273.25,1.33241964
+2,2031,1,407.50,1.02098768,2,2031,2,418.75,1.00533886
+2,2481,1,319.75,1.11602666,2,2481,2,378.33,1.05971853
+2,2725,1,349.75,1.11487049,2,2725,2,265.67,1.54629721
+2,3073,1,385.00,1.10208458,2,3073,2,231.75,1.08849891
+2,3769,1,334.00,1.19542966,2,3769,2,335.00,1.04946496
+2,4085,1,327.75,1.10054139,2,4085,2,281.75,1.01876081
+2,4995,1,282.25,1.26041833,2,4995,2,248.00,1.25482290
+2,5099,1,418.67,1.06809009,2,5099,2,428.67,1.03523728
+2,5211,1,157.00,1.06955174,2,5211,2,270.25,1.19402008
+2,5769,1,341.25,1.27231327,2,5769,2,267.00,1.18157918
+2,6103,1,194.33,1.51606702,2,6103,2,158.50,1.27436986
+2,6243,1,168.50,1.07321081,2,6243,2,386.75,1.08329026
+2,6489,1,268.00,1.69563724,2,6489,2,389.00,1.41057805
+2,6585,1,183.75,1.11519376,2,6585,2,353.75,1.09397071
+2,6767,1,341.00,1.09316398,2,6767,2,235.00,1.13995439
+2,7411,1,460.00,1.06282933,2,7411,2,297.50,1.00057654
+2,8489,1,126.75,1.34164630,2,8489,2,398.25,1.00411248
+2,8633,1,218.50,1.46451897,2,8633,2,230.25,1.31169630
+2,8807,1,417.25,1.02581129,2,8807,2,356.25,1.10797306
+2,8883,1,249.25,1.11122718,2,8883,2,189.25,1.01007549
+2,9253,1,413.33,1.16066599,2,9253,2,465.00,1.02424458
+2,9467,1,108.25,1.09112239,2,9467,2,107.00,1.03092204
+2,9561,1,190.50,1.03030325,2,9561,2,271.00,1.20583495
+2,9575,1,452.50,1.04944922,2,9575,2,155.75,1.15340567
+2,9903,1,322.75,1.07610801,2,9903,2,387.33,1.26124068
+2,10535,1,324.33,1.05711040,2,10535,2,310.25,1.00406350
+2,10955,1,356.00,1.15828133,2,10955,2,339.00,1.07025321
+2,12089,1,212.00,1.08275011,2,12089,2,173.33,1.07398122
+2,12633,1,402.75,1.00713621,2,12633,2,367.00,1.12705356
+2,12765,1,308.00,1.11884769,2,12765,2,347.00,1.15717446
+2,13077,1,277.00,1.23233608,2,13077,2,223.50,1.13940034
+2,13687,1,361.25,1.01073417,2,13687,2,468.25,1.00984292
+2,14025,1,371.75,1.01501361,2,14025,2,141.00,1.25431703
+2,14117,1,298.50,1.02512380,2,14117,2,220.25,1.41526845
+2,14347,1,366.00,1.03278929,2,14347,2,369.75,1.01857399
+2,14697,1,397.75,1.00812054,2,14697,2,328.75,1.16084956
+2,14987,1,146.75,1.02900406,2,14987,2,436.50,1.04476815
+2,15321,1,527.00,1.21026626,2,15321,2,298.75,1.13090984
+2,15347,1,243.00,1.22262398,2,15347,2,310.75,1.20365849
+2,15533,1,223.00,1.09651113,2,15533,2,330.00,1.49674885
+2,15839,1,353.00,1.50636844,2,15839,2,255.50,1.23623932
+2,16107,1,376.00,1.01332463,2,16107,2,364.75,1.06886780
+2,16749,1,200.00,1.09447095,2,16749,2,438.25,1.03606466
+2,17329,1,321.33,1.30932795,2,17329,2,490.25,1.07565806
+2,17417,1,321.75,1.13067648,2,17417,2,534.00,1.00107252
+3,1049,1,252.50,1.10906411,3,1049,2,457.25,1.02398412
+3,1415,1,247.50,1.13216178,3,1415,2,369.75,1.09546796
+3,2199,1,185.75,1.20281256,3,2199,2,300.75,1.07678451
+3,2403,1,270.75,1.32587057,3,2403,2,384.00,1.09039872
+3,2541,1,364.75,1.07921353,3,2541,2,550.50,1.05455889
+3,2727,1,303.75,1.03016470,3,2727,2,219.25,1.38220918
+3,3207,1,383.75,1.08545880,3,3207,2,258.25,1.21133925
+3,3373,1,404.50,1.01433741,3,3373,2,171.25,1.28566540
+3,3969,1,234.25,1.04228318,3,3969,2,217.25,1.42154907
+3,4407,1,438.50,1.06566635,3,4407,2,330.75,1.02444040
+3,6051,1,289.75,1.26388809,3,6051,2,439.00,1.10457692
+3,6521,1,381.00,1.00156829,3,6521,2,437.75,1.03651493
+3,6691,1,377.00,1.10907373,3,6691,2,380.50,1.05813013
+3,6757,1,282.50,1.08950094,3,6757,2,345.25,1.22638287
+3,6915,1,420.67,1.04683456,3,6915,2,292.50,1.25061711
+3,7207,1,329.67,1.59544822,3,7207,2,414.50,1.01791971
+3,7889,1,318.50,1.28790300,3,7889,2,291.33,1.00429253
+3,8559,1,356.25,1.00651935,3,8559,2,393.50,1.01288317
+3,8829,1,364.25,1.07928523,3,8829,2,350.25,1.11339122
+3,9555,1,377.00,1.13084693,3,9555,2,444.75,1.01715882
+3,9623,1,331.33,1.15512893,3,9623,2,284.67,1.03037244
+3,9813,1,343.75,1.05169538,3,9813,2,384.67,1.08150059
+3,9881,1,351.50,1.17888206,3,9881,2,287.75,1.09093861
+3,10035,1,378.25,1.02163995,3,10035,2,364.25,1.15679227
+3,10509,1,420.25,1.05486269,3,10509,2,368.25,1.18206334
+3,10547,1,182.33,1.53256415,3,10547,2,320.25,1.30244184
+3,10743,1,233.25,1.27930224,3,10743,2,110.25,1.10720463
+3,11477,1,264.25,1.09535300,3,11477,2,278.50,1.03279098
+3,11959,1,358.00,1.06848353,3,11959,2,268.50,1.00898568
+3,12043,1,169.25,1.03309381,3,12043,2,377.25,1.01619625
+3,12157,1,326.33,1.00223187,3,12157,2,396.33,1.02878181
+3,12433,1,199.75,1.30725892,3,12433,2,478.50,1.01647421
+3,12867,1,278.25,1.64038001,3,12867,2,350.75,1.20069333
+3,13499,1,281.00,1.14319655,3,13499,2,446.75,1.03315203
+3,14589,1,266.50,1.11432439,3,14589,2,334.33,1.14531468
+3,15207,1,300.25,1.48446113,3,15207,2,564.00,1.00048087
+3,15395,1,258.25,1.05138769,3,15395,2,307.50,1.13822532
+3,15973,1,477.50,1.20393259,3,15973,2,286.00,1.28722942
+3,16233,1,260.67,1.12042355,3,16233,2,210.50,1.17881433
+3,16267,1,456.00,1.00422635,3,16267,2,364.33,1.48188554
+3,16605,1,394.25,1.11374136,3,16605,2,296.25,1.28858927
+3,16949,1,155.75,1.11861773,3,16949,2,229.50,1.02894692
+3,17319,1,364.75,1.27093644,3,17319,2,359.25,1.15787514
+4,947,1,247.50,1.69331818,4,947,2,203.33,1.20543315
+4,1895,1,354.75,1.23973415,4,1895,2,383.75,1.08930770
+4,3429,1,358.50,1.06655934,4,3429,2,346.00,1.25194893
+4,4559,1,215.00,1.24323299,4,4559,2,360.75,1.03335459
+4,4773,1,328.25,1.05098366,4,4773,2,330.50,1.00625806
+4,4885,1,151.00,1.32055704,4,4885,2,377.25,1.04890352
+4,4915,1,289.25,1.08639295,4,4915,2,368.00,1.06965855
+4,5043,1,476.00,1.01559643,4,5043,2,244.25,1.35628937
+4,5095,1,334.00,1.22588613,4,5095,2,390.25,1.06217881
+4,5193,1,263.33,1.25017095,4,5193,2,323.00,1.09796162
+4,5975,1,434.00,1.02336145,4,5975,2,359.75,1.19793569
+4,6251,1,285.00,1.12153803,4,6251,2,335.50,1.16021925
+4,6389,1,280.75,1.20492361,4,6389,2,259.33,1.48165506
+4,6487,1,452.75,1.07106266,4,6487,2,350.50,1.17164757
+4,6619,1,430.00,1.00072626,4,6619,2,226.25,1.54855745
+4,7191,1,260.75,1.00126668,4,7191,2,195.25,1.53726755
+4,7427,1,239.50,1.41835671,4,7427,2,373.25,1.04297920
+4,8453,1,314.75,1.02597149,4,8453,2,376.75,1.00990239
+4,8781,1,518.50,1.10055000,4,8781,2,521.00,1.12377047
+4,9571,1,314.00,1.21685782,4,9571,2,309.00,1.08921674
+4,9587,1,248.00,1.49818873,4,9587,2,248.00,1.00649878
+4,10333,1,321.00,1.14861071,4,10333,2,317.00,1.04692263
+4,10969,1,186.67,1.10442062,4,10969,2,307.00,1.10947641
+4,10993,1,446.00,1.00923763,4,10993,2,206.67,1.23553335
+4,11571,1,342.50,1.14262840,4,11571,2,304.67,1.03199432
+4,11979,1,225.33,1.46706562,4,11979,2,438.25,1.13899270
+4,13409,1,312.33,1.34275025,4,13409,2,336.25,1.10819783
+4,13443,1,417.75,1.02177961,4,13443,2,334.00,1.30764309
+4,13567,1,271.50,1.00876216,4,13567,2,370.00,1.45576861
+4,13683,1,318.75,1.01498277,4,13683,2,363.50,1.07811546
+4,14143,1,367.00,1.04417994,4,14143,2,290.00,1.19330608
+4,14401,1,342.75,1.18365590,4,14401,2,344.25,1.20670831
+4,14693,1,447.25,1.05166749,4,14693,2,498.00,1.35173826
+4,14877,1,414.33,1.17077239,4,14877,2,282.50,1.58305829
+4,15063,1,378.25,1.11281926,4,15063,2,444.00,1.06327777
+4,15275,1,335.50,1.15363829,4,15275,2,292.67,1.29783137
+4,15509,1,296.33,1.02467405,4,15509,2,317.67,1.44703646
+4,15969,1,423.00,1.04728755,4,15969,2,342.50,1.25117694
+4,16627,1,485.50,1.01514609,4,16627,2,161.25,1.35332527
+4,16641,1,521.50,1.10506621,4,16641,2,221.50,1.03085905
+4,16751,1,549.50,1.08221438,4,16751,2,223.33,1.33778976
+5,75,1,333.00,1.26563188,5,75,2,226.00,1.03580785
+5,125,1,441.67,1.09597146,5,125,2,331.50,1.00811483
+5,431,1,159.00,1.10617948,5,431,2,304.00,1.12242254
+5,671,1,403.33,1.00560141,5,671,2,281.33,1.33668352
+5,745,1,466.75,1.01090655,5,745,2,351.00,1.11472129
+5,1701,1,374.00,1.08644582,5,1701,2,385.00,1.33063087
+5,2521,1,360.75,1.09924823,5,2521,2,265.50,1.17240777
+5,2855,1,406.00,1.40376371,5,2855,2,183.25,1.06622499
+5,3137,1,271.25,1.57545322,5,3137,2,380.00,1.08342034
+5,3279,1,299.50,1.05366972,5,3279,2,276.75,1.44588781
+5,3467,1,294.00,1.14772946,5,3467,2,349.67,1.16742237
+5,4463,1,338.00,1.06993201,5,4463,2,273.50,1.23697973
+5,4719,1,340.50,1.05718578,5,4719,2,423.67,1.02550002
+5,4739,1,281.33,1.02429715,5,4739,2,383.50,1.03343374
+5,4839,1,310.25,1.03590344,5,4839,2,232.00,1.29541938
+5,4979,1,359.50,1.10464081,5,4979,2,323.75,1.17042510
+5,5401,1,219.25,1.27738702,5,5401,2,203.00,1.09156752
+5,5635,1,370.00,1.02270546,5,5635,2,351.67,1.37776645
+5,5797,1,403.00,1.02348823,5,5797,2,457.50,1.00370401
+5,5901,1,360.25,1.12596313,5,5901,2,376.00,1.00950384
+5,6129,1,419.25,1.01691802,5,6129,2,359.50,1.04788894
+5,6213,1,351.67,1.20562125,5,6213,2,361.50,1.11684081
+5,6479,1,301.33,1.27800104,5,6479,2,395.75,1.17797435
+5,7333,1,227.00,1.46113460,5,7333,2,243.75,1.17891625
+5,7923,1,358.00,1.10467709,5,7923,2,342.33,1.16077811
+5,8737,1,217.25,1.07421364,5,8737,2,403.50,1.04420805
+5,8945,1,344.25,1.14148377,5,8945,2,298.00,1.00083670
+5,8993,1,399.00,1.18737229,5,8993,2,371.75,1.13163538
+5,10667,1,288.00,1.34536402,5,10667,2,289.50,1.09522380
+5,10771,1,394.75,1.04806801,5,10771,2,323.25,1.23773488
+5,10949,1,383.00,1.11256774,5,10949,2,378.25,1.12554061
+5,11107,1,446.50,1.26534898,5,11107,2,258.50,1.55361256
+5,11795,1,395.50,1.01044732,5,11795,2,430.75,1.13106259
+5,12017,1,347.75,1.16823794,5,12017,2,308.00,1.15932280
+5,12027,1,456.25,1.02629401,5,12027,2,390.33,1.11427701
+5,13583,1,430.33,1.04238393,5,13583,2,256.25,1.54103483
+5,13651,1,272.33,1.16952312,5,13651,2,330.50,1.19018735
+5,13783,1,419.50,1.05846997,5,13783,2,339.50,1.06809095
+5,13859,1,318.00,1.14222390,5,13859,2,380.25,1.05644962
+5,14537,1,206.00,1.22834400,5,14537,2,357.75,1.03879827
+5,15309,1,276.33,1.29875906,5,15309,2,409.00,1.01024062
+5,15883,1,385.33,1.01247775,5,15883,2,173.25,1.35622382
+5,15935,1,293.50,1.01876594,5,15935,2,271.25,1.40009475
+5,15949,1,241.50,1.14866599,5,15949,2,235.00,1.40728879
+5,16037,1,327.25,1.13076173,5,16037,2,412.67,1.18302002
+5,16291,1,380.50,1.05495950,5,16291,2,411.67,1.03492140
+5,16459,1,370.00,1.27564991,5,16459,2,265.75,1.29881917
+5,16901,1,305.25,1.10430105,5,16901,2,186.50,1.02312693
+5,17199,1,376.50,1.10389698,5,17199,2,374.00,1.08730312
+5,17387,1,298.33,1.38487417,5,17387,2,327.67,1.36708758
+5,17717,1,283.75,1.15571566,5,17717,2,235.25,1.14162394
+5,17927,1,217.50,1.35499643,5,17927,2,250.75,1.07092131
+5,17943,1,209.75,1.37170713,5,17943,2,428.00,1.10907993
+---- TYPES
+INT, BIGINT, INT, DOUBLE, DOUBLE, INT, BIGINT, INT, DOUBLE, DOUBLE
+====
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/impala/blob/35a3e186/testdata/workloads/tpcds/queries/tpcds-decimal_v2-q39-2.test
----------------------------------------------------------------------
diff --git a/testdata/workloads/tpcds/queries/tpcds-decimal_v2-q39-2.test b/testdata/workloads/tpcds/queries/tpcds-decimal_v2-q39-2.test
new file mode 100644
index 0000000..503d89d
--- /dev/null
+++ b/testdata/workloads/tpcds/queries/tpcds-decimal_v2-q39-2.test
@@ -0,0 +1,50 @@
+====
+---- QUERY: TPCDS-Q39.2
+-- RESULT MISMATCH FROM ORIGINAL
+-- ADDED ROUND()s TO 4th, 5th, 9th, 10th COLUMNS, TAKE ACTUAL RESULTS AS EXPECTED.
+with inv as
+(select w_warehouse_name,w_warehouse_sk,i_item_sk,d_moy
+       ,stdev,mean, case mean when 0 then null else stdev/mean end cov
+ from(select w_warehouse_name,w_warehouse_sk,i_item_sk,d_moy
+            ,stddev_samp(inv_quantity_on_hand) stdev,avg(inv_quantity_on_hand) mean
+      from inventory
+          ,item
+          ,warehouse
+          ,date_dim
+      where inv_item_sk = i_item_sk
+        and inv_warehouse_sk = w_warehouse_sk
+        and inv_date_sk = d_date_sk
+        and d_year =2001
+      group by w_warehouse_name,w_warehouse_sk,i_item_sk,d_moy) foo
+ where case mean when 0 then 0 else stdev/mean end > 1)
+select inv1.w_warehouse_sk,inv1.i_item_sk,inv1.d_moy
+        ,round(inv1.mean, 2), round(inv1.cov, 8)
+        ,inv2.w_warehouse_sk,inv2.i_item_sk,inv2.d_moy
+        ,round(inv2.mean, 2), round(inv2.cov, 8)
+from inv inv1,inv inv2
+where inv1.i_item_sk = inv2.i_item_sk
+  and inv1.w_warehouse_sk =  inv2.w_warehouse_sk
+  and inv1.d_moy=1
+  and inv2.d_moy=1+1
+  and inv1.cov > 1.5
+order by inv1.w_warehouse_sk,inv1.i_item_sk,inv1.d_moy,inv1.mean,inv1.cov
+        ,inv2.d_moy,inv2.mean, inv2.cov
+;
+---- RESULTS
+1,1569,1,212.00,1.63021352,1,1569,2,239.25,1.26415133
+1,5627,1,282.75,1.56570324,1,5627,2,297.50,1.20842868
+1,7999,1,166.25,1.79242317,1,7999,2,375.33,1.00809226
+1,8611,1,300.50,1.51915452,1,8611,2,243.75,1.23421228
+1,15345,1,148.50,1.52957840,1,15345,2,246.50,1.50879877
+2,71,1,221.50,1.56397411,2,71,2,309.00,1.49170579
+2,6103,1,194.33,1.51606702,2,6103,2,158.50,1.27436986
+2,6489,1,268.00,1.69563724,2,6489,2,389.00,1.41057805
+2,15839,1,353.00,1.50636844,2,15839,2,255.50,1.23623932
+3,7207,1,329.67,1.59544822,3,7207,2,414.50,1.01791971
+3,10547,1,182.33,1.53256415,3,10547,2,320.25,1.30244184
+3,12867,1,278.25,1.64038001,3,12867,2,350.75,1.20069333
+4,947,1,247.50,1.69331818,4,947,2,203.33,1.20543315
+5,3137,1,271.25,1.57545322,5,3137,2,380.00,1.08342034
+---- TYPES
+INT, BIGINT, INT, DOUBLE, DOUBLE, INT, BIGINT, INT, DOUBLE, DOUBLE
+====
\ No newline at end of file