You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pig.apache.org by ch...@apache.org on 2013/11/18 19:50:30 UTC

svn commit: r1543105 [2/2] - in /pig/branches/tez: ./ src/ src/org/apache/pig/ src/org/apache/pig/backend/executionengine/ src/org/apache/pig/backend/hadoop/executionengine/mapReduceLayer/ src/org/apache/pig/builtin/ src/org/apache/pig/scripting/ src/o...

Modified: pig/branches/tez/test/org/apache/pig/test/TestBuiltin.java
URL: http://svn.apache.org/viewvc/pig/branches/tez/test/org/apache/pig/test/TestBuiltin.java?rev=1543105&r1=1543104&r2=1543105&view=diff
==============================================================================
--- pig/branches/tez/test/org/apache/pig/test/TestBuiltin.java (original)
+++ pig/branches/tez/test/org/apache/pig/test/TestBuiltin.java Mon Nov 18 18:50:29 2013
@@ -189,13 +189,13 @@ public class TestBuiltin {
 
     String[][] aggs = {
             {"SUM", "IntSum", "LongSum", "FloatSum", "DoubleSum", "BigDecimalSum", "BigIntegerSum"},
-            {"AVG", "IntAvg", "LongAvg", "FloatAvg", "DoubleAvg"},
-            {"MIN", "IntMin", "LongMin", "FloatMin", "DoubleMin", "StringMin", "DateTimeMin"},
-            {"MAX", "IntMax", "LongMax", "FloatMax", "DoubleMax", "StringMax", "DateTimeMax"},
+            {"AVG", "IntAvg", "LongAvg", "FloatAvg", "DoubleAvg", "BigDecimalAvg", "BigIntegerAvg"},
+            {"MIN", "IntMin", "LongMin", "FloatMin", "DoubleMin", "BigDecimalMin", "BigIntegerMin","StringMin", "DateTimeMin"},
+            {"MAX", "IntMax", "LongMax", "FloatMax", "DoubleMax", "BigDecimalMax", "BigIntegerMax","StringMax", "DateTimeMax"},
             {"COUNT"},
-            };
+    };
 
-    String[] inputTypeAsString = {"ByteArray", "Integer", "Long", "Float", "Double", "String", "DateTime"};
+    String[] inputTypeAsString = {"ByteArray", "Integer", "Long", "Float", "Double", "BigDecimal", "BigInteger", "String", "DateTime"};
 
 
     @Before
@@ -228,12 +228,16 @@ public class TestBuiltin {
         expectedMap.put("LongAvg", new Double(14577696466636.2));
         expectedMap.put("IntAvg", new Double(5.5));
         expectedMap.put("FloatAvg", new Double(5.615394958853722));
+        expectedMap.put("BigDecimalAvg", new BigDecimal("24999999999999997.25000000000000000"));
+        expectedMap.put("BigIntegerAvg", new BigDecimal("2.499999999997222222219444444444444E+59"));
 
         expectedMap.put("MIN", new Double(1));
         expectedMap.put("IntMin", new Integer(1));
         expectedMap.put("LongMin", new Long(2));
         expectedMap.put("FloatMin", new Float(0.09f));
         expectedMap.put("DoubleMin", new Double(0.000000834593));
+        expectedMap.put("BigDecimalMin", BigDecimal.ZERO);
+        expectedMap.put("BigIntegerMin", BigInteger.ZERO);
         expectedMap.put("StringMin", "input");
         expectedMap.put("DateTimeMin", new DateTime("2008-10-09T01:07:02.000Z"));
 
@@ -242,6 +246,8 @@ public class TestBuiltin {
         expectedMap.put("LongMax", new Long(145769183483345L));
         expectedMap.put("FloatMax", new Float(10.4f));
         expectedMap.put("DoubleMax", new Double(121.0));
+        expectedMap.put("BigDecimalMax", new BigDecimal("99999999999999977.9999999999999999999999999999999999999999"));
+        expectedMap.put("BigIntegerMax", new BigInteger("999999999998888888887777777777777744444488888889999999999977"));
         expectedMap.put("StringMax", "unit");
         expectedMap.put("DateTimeMax", new DateTime("2014-12-25T11:11:11.000Z"));
 
@@ -250,15 +256,8 @@ public class TestBuiltin {
         // set up allowedInput
         for (String[] aggGroups : aggs) {
             int i = 0;
-            for(String agg: aggGroups) {
-                //This portion could be reverted once MIN, MAX and AVG are implemented for BigDecimal and BigInteger
-                if(agg == "BigDecimalSum")
-                        allowedInput.put(agg, "BigDecimal");
-                else if(agg == "BigIntegerSum")
-                        allowedInput.put(agg,"BigInteger");
-                else
-                    allowedInput.put(agg, inputTypeAsString[i++]);
-                
+            for (String agg: aggGroups) {                
+                allowedInput.put(agg, inputTypeAsString[i++]);    
             }
         }
 
@@ -269,9 +268,9 @@ public class TestBuiltin {
         // function.
 
         for (String[] aggGroups : aggs) {
-            for(String agg: aggGroups) {
+            for (String agg: aggGroups) {
                 for (String stage : stages) {
-                    if(stage.equals("Initial")) {
+                    if (stage.equals("Initial")) {
                         // For the Initial function, the input should match the input
                         // for the aggregate function itself. In the test cases, the
                         // output of Initial is sent to Intermediate, so we don't
@@ -286,7 +285,7 @@ public class TestBuiltin {
                         // and Float to Double respectively) - Likewise for SUMIntermediate
                         // and SumFinal the input is expected to be Double - The Initial
                         // version is supposed to convert byteArrays to Double
-                        if((agg).equals("IntSum") || (agg).equals("IntAvg")) {
+                        if ((agg).equals("IntSum") || (agg).equals("IntAvg")) {
                             allowedInput.put(agg + stage, "IntegerAsLong");
                         } else if ((agg).equals("FloatSum") || agg.equals("FloatAvg")) {
                             allowedInput.put(agg + stage, "FloatAsDouble");
@@ -306,7 +305,7 @@ public class TestBuiltin {
                         // For Average, we set up expectedMap only for the "Final" stage
                         // For other aggs, set up expected Map for both "Intermediate"
                         // and "Final"
-                        if(! agg.matches("(?i)avg") || stage.equals("Final")) {
+                        if (! agg.matches("(?i)avg") || stage.equals("Final")) {
                             expectedMap.put(agg + stage, expectedMap.get(agg));
                         }
                     }
@@ -321,35 +320,35 @@ public class TestBuiltin {
         expectedMap.put("LongAvgIntermediate", expectedMap.get("LongSum"));
         expectedMap.put("IntAvgIntermediate", expectedMap.get("IntSum"));
         expectedMap.put("FloatAvgIntermediate", expectedMap.get("FloatSum"));
-
+        expectedMap.put("BigDecimalAvgIntermediate", expectedMap.get("BigDecimalSum"));
+        expectedMap.put("BigIntegerAvgIntermediate", expectedMap.get("BigIntegerSum"));
 
         // set up input hash
-            inputMap.put("Integer", Util.loadNestTuple(TupleFactory.getInstance().newTuple(1), intInput));
-            inputMap.put("IntegerAsLong", Util.loadNestTuple(TupleFactory.getInstance().newTuple(1), intAsLong));
-            inputMap.put("Long", Util.loadNestTuple(TupleFactory.getInstance().newTuple(1), longInput));
-            inputMap.put("Float", Util.loadNestTuple(TupleFactory.getInstance().newTuple(1), floatInput));
-            inputMap.put("FloatAsDouble", Util.loadNestTuple(TupleFactory.getInstance().newTuple(1), floatAsDouble));
-            inputMap.put("Double", Util.loadNestTuple(TupleFactory.getInstance().newTuple(1), doubleInput));
-            inputMap.put("BigDecimal", Util.loadNestTuple(TupleFactory.getInstance().newTuple(1), bigDecimalInput));
-            inputMap.put("BigInteger", Util.loadNestTuple(TupleFactory.getInstance().newTuple(1), bigIntegerInput));
-            inputMap.put("ByteArray", Util.loadNestTuple(TupleFactory.getInstance().newTuple(1), ByteArrayInput));
-            inputMap.put("ByteArrayAsDouble", Util.loadNestTuple(TupleFactory.getInstance().newTuple(1), baAsDouble));
-            inputMap.put("String", Util.loadNestTuple(TupleFactory.getInstance().newTuple(1), stringInput));
-            inputMap.put("DateTime", Util.loadNestTuple(TupleFactory.getInstance().newTuple(1), datetimeInput));
+        inputMap.put("Integer", Util.loadNestTuple(TupleFactory.getInstance().newTuple(1), intInput));
+        inputMap.put("IntegerAsLong", Util.loadNestTuple(TupleFactory.getInstance().newTuple(1), intAsLong));
+        inputMap.put("Long", Util.loadNestTuple(TupleFactory.getInstance().newTuple(1), longInput));
+        inputMap.put("Float", Util.loadNestTuple(TupleFactory.getInstance().newTuple(1), floatInput));
+        inputMap.put("FloatAsDouble", Util.loadNestTuple(TupleFactory.getInstance().newTuple(1), floatAsDouble));
+        inputMap.put("Double", Util.loadNestTuple(TupleFactory.getInstance().newTuple(1), doubleInput));
+        inputMap.put("BigDecimal", Util.loadNestTuple(TupleFactory.getInstance().newTuple(1), bigDecimalInput));
+        inputMap.put("BigInteger", Util.loadNestTuple(TupleFactory.getInstance().newTuple(1), bigIntegerInput));
+        inputMap.put("ByteArray", Util.loadNestTuple(TupleFactory.getInstance().newTuple(1), ByteArrayInput));
+        inputMap.put("ByteArrayAsDouble", Util.loadNestTuple(TupleFactory.getInstance().newTuple(1), baAsDouble));
+        inputMap.put("String", Util.loadNestTuple(TupleFactory.getInstance().newTuple(1), stringInput));
+        inputMap.put("DateTime", Util.loadNestTuple(TupleFactory.getInstance().newTuple(1), datetimeInput));
 
         DateTimeZone.setDefault(DateTimeZone.forOffsetMillis(DateTimeZone.UTC.getOffset(null)));
     }
 
     @AfterClass
     public static void shutDown() {
-      cluster.shutDown();
+        cluster.shutDown();
     }
 
     /**
      *
      */
     private void setupEvalFuncMap() {
-
         for (String[] aggGroup : aggs) {
             for (String agg : aggGroup) {
                 // doing this as a two step process because PigContext.instantiateFuncFromSpec("SUM.Intermediate")
@@ -494,10 +493,10 @@ public class TestBuiltin {
 
             for (String stage: stages) {
                 String[] aggTypesArray = null;
-                if(stage.equals("Initial")) {
+                if (stage.equals("Initial")) {
                     aggInitialTypes = new String[aggGroup.length];
                     aggTypesArray = aggInitialTypes;
-                } else  if(stage.equals("Final")) {
+                } else if (stage.equals("Final")) {
                     aggFinalTypes = new String[aggGroup.length];
                     aggTypesArray = aggFinalTypes;
                 } else { // Intermediate
@@ -508,7 +507,7 @@ public class TestBuiltin {
                 }
             }
 
-            for(int k = 0; k < aggFinalTypes.length; k++) {
+            for (int k = 0; k < aggFinalTypes.length; k++) {
                 EvalFunc<?> avgInitial = evalFuncMap.get(aggInitialTypes[k]);
                 Tuple tup = inputMap.get(getInputType(aggInitialTypes[k]));
 
@@ -536,10 +535,14 @@ public class TestBuiltin {
                 // for doubles, precisions can be a problem - so check
                 // if the type is double for expected result and check
                 // within some precision
-                if(getExpected(aggFinalTypes[k]) instanceof Double) {
+                if (getExpected(aggFinalTypes[k]) instanceof Double) {
                     assertEquals(msg, (Double)getExpected(aggFinalTypes[k]), (Double)output, 0.00001);
+                } else if (getExpected(aggFinalTypes[k]) instanceof BigDecimal) {
+                    assertEquals(msg, ((BigDecimal)getExpected(aggFinalTypes[k])).toPlainString(), ((BigDecimal)output).toPlainString());
+                } else if (getExpected(aggFinalTypes[k]) instanceof BigInteger) {
+                    assertEquals(msg, ((BigInteger)getExpected(aggFinalTypes[k])).toString(), ((BigInteger)output).toString());
                 // Compare millis so that we dont have to worry about TZ
-                } else if(getExpected(aggFinalTypes[k]) instanceof DateTime) {
+                } else if (getExpected(aggFinalTypes[k]) instanceof DateTime) {
                     assertEquals(msg, ((DateTime)getExpected(aggFinalTypes[k])).getMillis(), ((DateTime)output).getMillis());
                 } else {
                     assertEquals(msg, getExpected(aggFinalTypes[k]), output);
@@ -562,13 +565,13 @@ public class TestBuiltin {
             String[] aggIntermediateTypes = null; // will contains AVGIntermediate, DoubleAvgIntermediate etc
             for (String stage: stages) {
                 String[] aggTypesArray = null;
-                if(stage.equals("Initial")) {
+                if (stage.equals("Initial")) {
                     aggInitialTypes = new String[aggGroup.length];
                     aggTypesArray = aggInitialTypes;
                 } else if (stage.equals("Intermediate")) {
                     aggIntermediateTypes = new String[aggGroup.length];
                     aggTypesArray = aggIntermediateTypes;
-                } else  {// final
+                } else {// final
                     aggFinalTypes = new String[aggGroup.length];
                     aggTypesArray = aggFinalTypes;
                 }
@@ -577,7 +580,7 @@ public class TestBuiltin {
                     aggTypesArray[i] = aggGroup[i] + stage;
                 }
             }
-            for(int k = 0; k < aggFinalTypes.length; k++) {
+            for (int k = 0; k < aggFinalTypes.length; k++) {
                 EvalFunc<?> aggInitial = evalFuncMap.get(aggInitialTypes[k]);
                 Tuple tup = inputMap.get(getInputType(aggInitialTypes[k]));
                 // To test this case, first <Agg>Initial is called for each input
@@ -597,7 +600,7 @@ public class TestBuiltin {
                     DataBag initialInputBg = bagFactory.newDefaultBag();
                     initialInputBg.add(tuple);
                     Tuple initialInputTuple = tupleFactory.newTuple(initialInputBg);
-                    if(i < bg.size()/2) {
+                    if (i < bg.size()/2) {
                         intermediateInputBg1.add((Tuple)aggInitial.exec(initialInputTuple));
                     } else {
                         intermediateInputBg2.add((Tuple)aggInitial.exec(initialInputTuple));
@@ -621,10 +624,14 @@ public class TestBuiltin {
                 // for doubles, precisions can be a problem - so check
                 // if the type is double for expected result and check
                 // within some precision
-                if(getExpected(aggFinalTypes[k]) instanceof Double) {
+                if (getExpected(aggFinalTypes[k]) instanceof Double) {
                     assertEquals(msg, (Double)getExpected(aggFinalTypes[k]), (Double)output, 0.00001);
+                } else if (getExpected(aggFinalTypes[k]) instanceof BigDecimal) {
+                    assertEquals(msg, ((BigDecimal)getExpected(aggFinalTypes[k])).toPlainString(), ((BigDecimal)output).toPlainString());
+                } else if (getExpected(aggFinalTypes[k]) instanceof BigInteger) {
+                    assertEquals(msg, ((BigInteger)getExpected(aggFinalTypes[k])).toString(), ((BigInteger)output).toString());
                 // Compare millis so that we dont have to worry about TZ
-                } else if(getExpected(aggFinalTypes[k]) instanceof DateTime) {
+                } else if (getExpected(aggFinalTypes[k]) instanceof DateTime) {
                     assertEquals(msg, ((DateTime)getExpected(aggFinalTypes[k])).getMillis(), ((DateTime)output).getMillis());
                 } else {
                     assertEquals(msg, getExpected(aggFinalTypes[k]), output);
@@ -649,13 +656,13 @@ public class TestBuiltin {
             String[] aggIntermediateTypes = null; // will contains AVGIntermediate, DoubleAvgIntermediate etc
             for (String stage: stages) {
                 String[] aggTypesArray = null;
-                if(stage.equals("Initial")) {
+                if (stage.equals("Initial")) {
                     aggInitialTypes = new String[aggGroup.length];
                     aggTypesArray = aggInitialTypes;
                 } else if (stage.equals("Intermediate")) {
                     aggIntermediateTypes = new String[aggGroup.length];
                     aggTypesArray = aggIntermediateTypes;
-                } else  {// final
+                } else {// final
                     aggFinalTypes = new String[aggGroup.length];
                     aggTypesArray = aggFinalTypes;
                 }
@@ -664,7 +671,7 @@ public class TestBuiltin {
                     aggTypesArray[i] = aggGroup[i] + stage;
                 }
             }
-            for(int k = 0; k < aggFinalTypes.length; k++) {
+            for (int k = 0; k < aggFinalTypes.length; k++) {
                 EvalFunc<?> aggInitial = evalFuncMap.get(aggInitialTypes[k]);
                 Tuple tup = inputMap.get(getInputType(aggInitialTypes[k]));
                 // To test this case, first <Agg>Initial is called for each input
@@ -686,14 +693,14 @@ public class TestBuiltin {
                     mapIntermediateInputBgs[i] = bagFactory.newDefaultBag();
                 }
                 Iterator<Tuple> it = bg.iterator();
-                for(int i = 0; i < 4; i++) {
-                    for(int j = 0; j < bg.size()/4; j++) {
+                for (int i = 0; i < 4; i++) {
+                    for (int j = 0; j < bg.size()/4; j++) {
                         DataBag initialInputBg = bagFactory.newDefaultBag();
                         initialInputBg.add(it.next());
                         Tuple initialInputTuple = tupleFactory.newTuple(initialInputBg);
                         mapIntermediateInputBgs[i].add((Tuple)aggInitial.exec(initialInputTuple));
                     }
-                    if(i == 3) {
+                    if (i == 3) {
                         // if the last quarter has more elements process them
                         while(it.hasNext()) {
                             DataBag initialInputBg = bagFactory.newDefaultBag();
@@ -711,9 +718,9 @@ public class TestBuiltin {
                 }
 
                 // simulate call to combine after map
-                for(int i = 0; i < 4; i++) {
+                for (int i = 0; i < 4; i++) {
                     Tuple intermediateInputTuple = tupleFactory.newTuple(mapIntermediateInputBgs[i]);
-                    if(i < 2) {
+                    if (i < 2) {
                         reduceIntermediateInputBgs[0].add((Tuple)aggIntermediate.exec(intermediateInputTuple));
                     } else {
                         reduceIntermediateInputBgs[1].add((Tuple)aggIntermediate.exec(intermediateInputTuple));
@@ -722,7 +729,7 @@ public class TestBuiltin {
 
                 DataBag finalInputBag = bagFactory.newDefaultBag();
                 // simulate call to combine before reduce
-                for(int i = 0; i < 2; i++) {
+                for (int i = 0; i < 2; i++) {
                     Tuple intermediateInputTuple = tupleFactory.newTuple(reduceIntermediateInputBgs[i]);
                     finalInputBag.add((Tuple)aggIntermediate.exec(intermediateInputTuple));
                 }
@@ -737,10 +744,14 @@ public class TestBuiltin {
                 // for doubles, precisions can be a problem - so check
                 // if the type is double for expected result and check
                 // within some precision
-                if(getExpected(aggFinalTypes[k]) instanceof Double) {
+                if (getExpected(aggFinalTypes[k]) instanceof Double) {
                     assertEquals(msg, (Double)getExpected(aggFinalTypes[k]), (Double)output, 0.00001);
+                } else if (getExpected(aggFinalTypes[k]) instanceof BigDecimal) {
+                    assertEquals(msg, ((BigDecimal)getExpected(aggFinalTypes[k])).toPlainString(), ((BigDecimal)output).toPlainString());
+                } else if (getExpected(aggFinalTypes[k]) instanceof BigInteger) {
+                    assertEquals(msg, ((BigInteger)getExpected(aggFinalTypes[k])).toString(), ((BigInteger)output).toString());
                 // Compare millis so that we dont have to worry about TZ
-                } else if(getExpected(aggFinalTypes[k]) instanceof DateTime) {
+                } else if (getExpected(aggFinalTypes[k]) instanceof DateTime) {
                     assertEquals(msg, ((DateTime)getExpected(aggFinalTypes[k])).getMillis(), ((DateTime)output).getMillis());
                 } else {
                     assertEquals(msg, getExpected(aggFinalTypes[k]), output);
@@ -765,7 +776,7 @@ public class TestBuiltin {
             String[] aggIntermediateTypes = null; // will contains AVGIntermediate, DoubleAvgIntermediate etc
             for (String stage: stages) {
                 String[] aggTypesArray = null;
-                if(stage.equals("Initial")) {
+                if (stage.equals("Initial")) {
                     aggInitialTypes = new String[aggGroup.length];
                     aggTypesArray = aggInitialTypes;
                 } else if (stage.equals("Intermediate")) {
@@ -780,7 +791,7 @@ public class TestBuiltin {
                     aggTypesArray[i] = aggGroup[i] + stage;
                 }
             }
-            for(int k = 0; k < aggFinalTypes.length; k++) {
+            for (int k = 0; k < aggFinalTypes.length; k++) {
                 EvalFunc<?> aggInitial = evalFuncMap.get(aggInitialTypes[k]);
                 // To test this case, first <Agg>Initial is called with an empty bag
                 // as input. This is done in two ierations of 5 calls.
@@ -793,13 +804,13 @@ public class TestBuiltin {
                 DataBag  intermediateInputBg1 = bagFactory.newDefaultBag();
                 DataBag  intermediateInputBg2 = bagFactory.newDefaultBag();
                 Tuple outputTuple = null;
-                for(int i = 0; i < 10; i++) {
+                for (int i = 0; i < 10; i++) {
                     // create empty bag input to be provided as input
                     // argument to the "Initial" function
                     DataBag initialInputBg = bagFactory.newDefaultBag();
                     Tuple initialInputTuple = tupleFactory.newTuple(initialInputBg);
 
-                    if(i < 5) {
+                    if (i < 5) {
                         outputTuple = (Tuple)aggInitial.exec(initialInputTuple);
                         // check that output is null for all aggs except COUNT
                         // COUNT will give an output of 0 for empty bag input
@@ -851,7 +862,7 @@ public class TestBuiltin {
 
         for (String[] aggGroup : aggs) {
 
-            for(int k = 0; k < aggGroup.length; k++) {
+            for (int k = 0; k < aggGroup.length; k++) {
                 EvalFunc<?> agg = evalFuncMap.get(aggGroup[k]);
 
                 // call agg with empty bag as input
@@ -868,7 +879,7 @@ public class TestBuiltin {
     }
 
     private void checkZeroOrNull(EvalFunc<?> func, Object output) {
-        if(func.getClass().getName().contains("COUNT")) {
+        if (func.getClass().getName().contains("COUNT")) {
             assertEquals(new Long(0), output);
         } else {
             assertEquals(null, output);
@@ -880,22 +891,26 @@ public class TestBuiltin {
     // =======================
     @Test
     public void testAVG() throws Exception {
-        String[] avgTypes = {"AVG", "DoubleAvg", "LongAvg", "IntAvg", "FloatAvg"};
-        for(int k = 0; k < avgTypes.length; k++) {
+        String[] avgTypes = {"AVG", "DoubleAvg", "LongAvg", "IntAvg", "FloatAvg", "BigDecimalAvg", "BigIntegerAvg"};
+        for (int k = 0; k < avgTypes.length; k++) {
             EvalFunc<?> avg = evalFuncMap.get(avgTypes[k]);
             Tuple tup = inputMap.get(getInputType(avgTypes[k]));
             Object output = avg.exec(tup);
             String msg = "[Testing " + avgTypes[k] + " on input type: " + getInputType(avgTypes[k]) + " ( (output) " +
                          output + " == " + getExpected(avgTypes[k]) + " (expected) )]";
-            assertEquals(msg, (Double)output, (Double)getExpected(avgTypes[k]), 0.00001);
-
+            if (getInputType(avgTypes[k]) == "BigDecimal" || getInputType(avgTypes[k]) == "BigInteger") {
+                assertEquals(msg, ((BigDecimal)output).toPlainString(), ((BigDecimal)getExpected(avgTypes[k])).toPlainString());
+            } else {
+                assertEquals(msg, (Double)output, (Double)getExpected(avgTypes[k]), 0.00001);
+            }
         }
     }
 
     @Test
     public void testAVGIntermediate() throws Exception {
-        String[] avgTypes = {"AVGIntermediate", "DoubleAvgIntermediate", "LongAvgIntermediate", "IntAvgIntermediate", "FloatAvgIntermediate"};
-        for(int k = 0; k < avgTypes.length; k++) {
+        String[] avgTypes = {"AVGIntermediate", "DoubleAvgIntermediate", "LongAvgIntermediate", "IntAvgIntermediate", "FloatAvgIntermediate",
+                             "BigDecimalAvgIntermediate", "BigIntegerAvgIntermediate"};
+        for (int k = 0; k < avgTypes.length; k++) {
             EvalFunc<?> avg = evalFuncMap.get(avgTypes[k]);
             String inputType = getInputType(avgTypes[k]);
             Tuple tup = inputMap.get(inputType);
@@ -909,7 +924,13 @@ public class TestBuiltin {
             for (Tuple t: bag) {
                 Tuple newTuple = tupleFactory.newTuple(2);
                 newTuple.set(0, t.get(0));
-                newTuple.set(1, new Long(1));
+                if (inputType == "BigDecimal") {
+                    newTuple.set(1, BigDecimal.ONE);
+                } else if (inputType == "BigInteger") {
+                    newTuple.set(1, BigInteger.ONE);
+                } else {
+                    newTuple.set(1, new Long(1));
+                }
                 bg.add(newTuple);
             }
             Tuple intermediateInput = tupleFactory.newTuple();
@@ -917,28 +938,51 @@ public class TestBuiltin {
 
             Object output = avg.exec(intermediateInput);
 
-            if(inputType == "Long" || inputType == "Integer" || inputType == "IntegerAsLong") {
+            if (inputType == "Long" || inputType == "Integer" || inputType == "IntegerAsLong") {
                 Long l = (Long)((Tuple)output).get(0);
                 String msg = "[Testing " + avgTypes[k] + " on input type: " + getInputType(avgTypes[k]) + " ( (output) " +
                               l + " == " + getExpected(avgTypes[k]) + " (expected) )]";
                 assertEquals(msg, getExpected(avgTypes[k]), l);
+            } else if (inputType == "BigDecimal") {
+                BigDecimal f1 = (BigDecimal)((Tuple)output).get(0);
+                String msg = "[Testing " + avgTypes[k] + " on input type: " + getInputType(avgTypes[k]) + " ( (output) " +
+                               f1 + " == " + getExpected(avgTypes[k]) + " (expected) )]";
+                assertEquals(msg, ((BigDecimal)getExpected(avgTypes[k])).toPlainString(), f1.toPlainString());
+            } else if (inputType == "BigInteger") {
+                BigInteger f1 = (BigInteger)((Tuple)output).get(0);
+                String msg = "[Testing " + avgTypes[k] + " on input type: " + getInputType(avgTypes[k]) + " ( (output) " +
+                               f1 + " == " + getExpected(avgTypes[k]) + " (expected) )]";
+                assertEquals(msg, ((BigInteger)getExpected(avgTypes[k])).toString(), f1.toString());
             } else {
                 Double f1 = (Double)((Tuple)output).get(0);
                 String msg = "[Testing " + avgTypes[k] + " on input type: " + getInputType(avgTypes[k]) + " ( (output) " +
                                f1 + " == " + getExpected(avgTypes[k]) + " (expected) )]";
                 assertEquals(msg, (Double)getExpected(avgTypes[k]), f1, 0.00001);
             }
-            Long f2 = (Long)((Tuple)output).get(1);
-            assertEquals("[Testing " + avgTypes[k] + " on input type: "+
-                inputType+"]Expected count to be 11", 11, f2.longValue());
+            if (inputType == "BigDecimal") {
+                BigDecimal f2 = (BigDecimal)((Tuple)output).get(1);
+                assertEquals("[Testing " + avgTypes[k] + " on input type: "+
+                    inputType+"]Expected count to be 4", "4", f2.toPlainString());
+
+            } else if (inputType == "BigInteger") {
+                BigInteger f2 = (BigInteger)((Tuple)output).get(1);
+                assertEquals("[Testing " + avgTypes[k] + " on input type: "+
+                    inputType+"]Expected count to be 4", "4", f2.toString());
+
+            } else {
+                Long f2 = (Long)((Tuple)output).get(1);
+                assertEquals("[Testing " + avgTypes[k] + " on input type: "+
+                    inputType+"]Expected count to be 11", 11, f2.longValue());
+            }
         }
     }
 
     @Test
     public void testAVGFinal() throws Exception {
-        String[] avgTypes = {"AVGFinal", "DoubleAvgFinal", "LongAvgFinal", "IntAvgFinal", "FloatAvgFinal"};
-        String[] avgIntermediateTypes = {"AVGIntermediate", "DoubleAvgIntermediate", "LongAvgIntermediate", "IntAvgIntermediate", "FloatAvgIntermediate"};
-        for(int k = 0; k < avgTypes.length; k++) {
+        String[] avgTypes = {"AVGFinal", "DoubleAvgFinal", "LongAvgFinal", "IntAvgFinal", "FloatAvgFinal", "BigDecimalAvgFinal", "BigIntegerAvgFinal"};
+        String[] avgIntermediateTypes = {"AVGIntermediate", "DoubleAvgIntermediate", "LongAvgIntermediate", "IntAvgIntermediate", "FloatAvgIntermediate",
+                                         "BigDecimalAvgIntermediate", "BigIntegerAvgIntermediate"};
+        for (int k = 0; k < avgTypes.length; k++) {
             EvalFunc<?> avg = evalFuncMap.get(avgTypes[k]);
             Tuple tup = inputMap.get(getInputType(avgTypes[k]));
 
@@ -965,11 +1009,24 @@ public class TestBuiltin {
             for (Tuple t: bg) {
                 Tuple newTuple = tupleFactory.newTuple(2);
                 newTuple.set(0, t.get(0));
-                if ( t.get(0) == null)
-                    newTuple.set(1, new Long(0));
-                else
-                    newTuple.set(1, new Long(1));
-                if(i < 5) {
+                if ( t.get(0) == null) {
+                    if (getInputType(avgTypes[k]) == "BigDecimal") {
+                        newTuple.set(1, BigDecimal.ZERO);
+                    } else if (getInputType(avgTypes[k]) == "BigInteger") {
+                        newTuple.set(1, BigInteger.ZERO);
+                    } else {
+                        newTuple.set(1, new Long(0));
+                    }
+                } else {
+                    if (getInputType(avgTypes[k]) == "BigDecimal") {
+                        newTuple.set(1, BigDecimal.ONE);
+                    } else if (getInputType(avgTypes[k]) == "BigInteger") {
+                        newTuple.set(1, BigInteger.ONE);
+                    } else {
+                        newTuple.set(1, new Long(1));
+                    }
+                }
+                if (i < 5) {
                     bg1.add(newTuple);
                 } else {
                     bg2.add(newTuple);
@@ -990,7 +1047,11 @@ public class TestBuiltin {
             Object output = avg.exec(finalTuple);
             String msg = "[Testing " + avgTypes[k] + " on input type: " + getInputType(avgTypes[k]) + " ( (output) " +
             output + " == " + getExpected(avgTypes[k]) + " (expected) )]";
-            assertEquals(msg, (Double)getExpected(avgTypes[k]), (Double)output, 0.00001);
+            if (getInputType(avgTypes[k]) == "BigDecimal" || getInputType(avgTypes[k]) == "BigInteger") {
+                assertEquals(msg, ((BigDecimal)getExpected(avgTypes[k])).toPlainString(), ((BigDecimal)output).toPlainString());
+            } else {
+                assertEquals(msg, (Double)getExpected(avgTypes[k]), (Double)output, 0.00001);
+            }
         }
     }
 
@@ -1042,15 +1103,13 @@ public class TestBuiltin {
 
     @Test
     public void testCOUNTBagNullCheck() throws Exception{
-
         DataBag b = null;
-        Tuple t = tupleFactory.getInstance().newTuple(b);
+        Tuple t = TupleFactory.getInstance().newTuple(b);
 
         EvalFunc<Long> count = new COUNT();
         assertNull(count.exec(t));
        }
 
-
     @Test
     public void testCount_ValidNumberOfArguments_WithoutInputSchema_One() throws Exception {
          File inputFile = createCountInputFile();
@@ -1059,9 +1118,9 @@ public class TestBuiltin {
              pigServer.registerQuery("=> group @ all;");
              pigServer.registerQuery("C = foreach @ generate COUNT($1.$0);");
              assertValidCount();
-         }catch(TypeCheckerException e) {
+         } catch (TypeCheckerException e) {
              Assert.fail("Query is in accordance with schema, still it failed to execute");
-         }finally {
+         } finally {
              inputFile.delete();
          }
     }
@@ -1074,9 +1133,9 @@ public class TestBuiltin {
              pigServer.registerQuery("=> group @ all;");
              pigServer.registerQuery("C = foreach @ generate COUNT($1);");
              assertValidCount();
-         }catch(TypeCheckerException e) {
+         } catch (TypeCheckerException e) {
              Assert.fail("Query is in accordance with schema, still it failed to execute");
-         }finally {
+         } finally {
              inputFile.delete();
          }
     }
@@ -1097,9 +1156,9 @@ public class TestBuiltin {
              pigServer.registerQuery("=> group @ all;");
              pigServer.registerQuery("C = foreach @ generate COUNT($1);");
              assertValidCount();
-         }catch(TypeCheckerException e) {
+         } catch (TypeCheckerException e) {
              Assert.fail("Query is in accordance with schema, still it failed to execute");
-         }finally {
+         } finally {
              inputFile.delete();
          }
     }
@@ -1120,7 +1179,7 @@ public class TestBuiltin {
              pigServer.registerQuery("=> group @ all;");
              pigServer.registerQuery("C = foreach @ generate COUNT($1.$0);");
              assertValidCount();
-         }catch(TypeCheckerException e) {
+         } catch (TypeCheckerException e) {
              Assert.fail("Query is in accordance with schema, still it failed to execute");
          } finally {
            file.delete();
@@ -1136,7 +1195,7 @@ public class TestBuiltin {
              pigServer.registerQuery("=> group @ all;");
              pigServer.registerQuery("C = foreach @ generate COUNT($1.$0);");
              assertValidCount();
-         }catch(TypeCheckerException e) {
+         } catch (TypeCheckerException e) {
              Assert.fail("Query is in accordance with schema, still it failed to execute");
          } finally {
            inputFile.delete();
@@ -1151,7 +1210,7 @@ public class TestBuiltin {
              pigServer.registerQuery("=> group @ all;");
              pigServer.registerQuery("C = foreach @ generate COUNT($1);");
              assertValidCount();
-         }catch(TypeCheckerException e) {
+         } catch (TypeCheckerException e) {
              Assert.fail("Query is in accordance with schema, still it failed to execute");
          } finally {
            inputFile.delete();
@@ -1188,7 +1247,7 @@ public class TestBuiltin {
              pigServer.registerQuery("C = foreach @ generate COUNT($1.$0, $1.$0);");
              pigServer.openIterator("C");
              Assert.fail("COUNT is suppose to run with one argument of type BAG, however it ran with couple of arguments.");
-         }catch(FrontendException e) {
+         } catch (FrontendException e) {
              Assert.assertTrue( e.getCause() instanceof TypeCheckerException );
          } finally {
            inputFile.delete();
@@ -1204,7 +1263,7 @@ public class TestBuiltin {
              pigServer.registerQuery("C = foreach @ generate COUNT($1.$0, $1.$0);");
              pigServer.openIterator("C");
              Assert.fail("COUNT is suppose to run with one argument of type BAG, however it ran with couple of arguments.");
-         }catch(FrontendException e) {
+         } catch (FrontendException e) {
              Assert.assertTrue( e.getCause() instanceof TypeCheckerException );
          } finally {
            inputFile.delete();
@@ -1220,7 +1279,7 @@ public class TestBuiltin {
              pigServer.registerQuery("C = foreach @ generate COUNT('data');");
              pigServer.openIterator("C");
              Assert.fail("COUNT is suppose to run with one argument of type BAG, however it ran with an argument of type chararray.");
-         }catch(FrontendException e) {
+         } catch (FrontendException e) {
              Assert.assertTrue( e.getCause() instanceof TypeCheckerException );
          } finally {
            inputFile.delete();
@@ -1292,7 +1351,7 @@ public class TestBuiltin {
     @Test
     public void testSUM() throws Exception {
         String[] sumTypes = {"SUM", "DoubleSum", "LongSum", "IntSum", "FloatSum", "BigDecimalSum", "BigIntegerSum"};
-        for(int k = 0; k < sumTypes.length; k++) {
+        for (int k = 0; k < sumTypes.length; k++) {
             EvalFunc<?> sum = evalFuncMap.get(sumTypes[k]);
             String inputType = getInputType(sumTypes[k]);
             Tuple tup = inputMap.get(inputType);
@@ -1301,13 +1360,13 @@ public class TestBuiltin {
             String msg = "[Testing " + sumTypes[k] + " on input type: " + getInputType(sumTypes[k]) + " ( (output) " +
                           output + " == " + getExpected(sumTypes[k]) + " (expected) )]";
 
-            if(inputType == "Integer" || inputType == "Long") {
+            if (inputType == "Integer" || inputType == "Long") {
                 assertEquals(msg, (Long)output, (Long)getExpected(sumTypes[k]), 0.00001);
             }
             //Assert Equals does not support BigDecimal or BigInteger. Converting into String
-            else if(inputType == "BigDecimal")
+            else if (inputType == "BigDecimal")
                 assertEquals(msg, ((BigDecimal) output).toPlainString(), ((BigDecimal)getExpected(sumTypes[k])).toPlainString());
-            else if(inputType == "BigInteger")
+            else if (inputType == "BigInteger")
                 assertEquals(msg, ((BigInteger) output).toString(), ((BigInteger)getExpected(sumTypes[k])).toString());
             else {
                 assertEquals(msg, (Double)output, (Double)getExpected(sumTypes[k]), 0.00001);
@@ -1318,7 +1377,7 @@ public class TestBuiltin {
     @Test
     public void testSUMIntermed() throws Exception {
         String[] sumTypes = {"SUMIntermediate", "DoubleSumIntermediate", "LongSumIntermediate", "IntSumIntermediate", "FloatSumIntermediate", "BigDecimalSumIntermediate", "BigIntegerSumIntermediate"};
-        for(int k = 0; k < sumTypes.length; k++) {
+        for (int k = 0; k < sumTypes.length; k++) {
             EvalFunc<?> sum = evalFuncMap.get(sumTypes[k]);
             String inputType = getInputType(sumTypes[k]);
 
@@ -1327,15 +1386,13 @@ public class TestBuiltin {
 
             String msg = "[Testing " + sumTypes[k] + " on input type: " + getInputType(sumTypes[k]) + " ( (output) " +
                             ((Tuple)output).get(0) + " == " + getExpected(sumTypes[k]) + " (expected) )]";
-            if(inputType.equals("Integer") || inputType.equals("Long") || inputType.equals("IntegerAsLong")) {
+            if (inputType.equals("Integer") || inputType.equals("Long") || inputType.equals("IntegerAsLong")) {
               assertEquals(msg, (Long) ((Tuple)output).get(0), (Long)getExpected(sumTypes[k]), 0.00001);
-            }
-            //Assert Equals does not support BigDecimal or BigInteger. Converting into String
-            else if(inputType == "BigDecimal")
+            } else if (inputType == "BigDecimal") {
                 assertEquals(msg, ((BigDecimal) ((Tuple)output).get(0)).toPlainString(), ((BigDecimal)getExpected(sumTypes[k])).toPlainString());
-            else if(inputType == "BigInteger")
-                assertEquals(msg, ((BigInteger) ((Tuple)output).get(0)).toString(), ((BigInteger)getExpected(sumTypes[k])).toString()); 
-            else {
+            } else if (inputType == "BigInteger") {
+                assertEquals(msg, ((BigInteger) ((Tuple)output).get(0)).toString(), ((BigInteger)getExpected(sumTypes[k])).toString());
+            } else {
               assertEquals(msg, (Double) ((Tuple)output).get(0), (Double)getExpected(sumTypes[k]), 0.00001);
             }
         }
@@ -1344,7 +1401,7 @@ public class TestBuiltin {
     @Test
     public void testSUMFinal() throws Exception {
         String[] sumTypes = {"SUMFinal", "DoubleSumFinal", "LongSumFinal", "IntSumFinal", "FloatSumFinal", "BigDecimalSumFinal", "BigIntegerSumFinal"};
-        for(int k = 0; k < sumTypes.length; k++) {
+        for (int k = 0; k < sumTypes.length; k++) {
             EvalFunc<?> sum = evalFuncMap.get(sumTypes[k]);
             String inputType = getInputType(sumTypes[k]);
             Tuple tup = inputMap.get(inputType);
@@ -1353,13 +1410,13 @@ public class TestBuiltin {
             String msg = "[Testing " + sumTypes[k] + " on input type: " + getInputType(sumTypes[k]) + " ( (output) " +
             output + " == " + getExpected(sumTypes[k]) + " (expected) )]";
 
-            if(inputType.equals("Integer") || inputType.equals("Long") || inputType.equals("IntegerAsLong")) {
+            if (inputType.equals("Integer") || inputType.equals("Long") || inputType.equals("IntegerAsLong")) {
               assertEquals(msg, (Long)output, (Long)getExpected(sumTypes[k]), 0.00001);
             }
             //Assert Equals does not support BigDecimal or BigInteger. Converting into String
-            else if(inputType == "BigDecimal")
+            else if (inputType == "BigDecimal")
                 assertEquals(msg, ((BigDecimal) output).toPlainString(), ((BigDecimal)getExpected(sumTypes[k])).toPlainString());
-            else if(inputType == "BigInteger")
+            else if (inputType == "BigInteger")
                 assertEquals(msg, ((BigInteger) output).toString(), ((BigInteger)getExpected(sumTypes[k])).toString()); 
             else {
               assertEquals(msg, (Double)output, (Double)getExpected(sumTypes[k]), 0.00001);
@@ -1369,8 +1426,8 @@ public class TestBuiltin {
 
     @Test
     public void testMIN() throws Exception {
-        String[] minTypes = {"MIN", "LongMin", "IntMin", "FloatMin", "StringMin", "DateTimeMin"};
-        for(int k = 0; k < minTypes.length; k++) {
+        String[] minTypes = {"MIN", "LongMin", "IntMin", "FloatMin","BigDecimalMin","BigIntegerMin", "StringMin", "DateTimeMin"};
+        for (int k = 0; k < minTypes.length; k++) {
             EvalFunc<?> min = evalFuncMap.get(minTypes[k]);
             String inputType = getInputType(minTypes[k]);
             Tuple tup = inputMap.get(inputType);
@@ -1379,11 +1436,11 @@ public class TestBuiltin {
             String msg = "[Testing " + minTypes[k] + " on input type: " + getInputType(minTypes[k]) + " ( (output) " +
                            output + " == " + getExpected(minTypes[k]) + " (expected) )]";
 
-            if(inputType == "ByteArray") {
+            if (inputType == "ByteArray") {
               assertEquals(msg, output, getExpected(minTypes[k]));
-            } else if(inputType == "Long") {
+            } else if (inputType == "Long") {
                 assertEquals(msg, output, getExpected(minTypes[k]));
-            } else if(inputType == "Integer") {
+            } else if (inputType == "Integer") {
                 assertEquals(msg, output, getExpected(minTypes[k]));
             } else if (inputType == "Double") {
                 assertEquals(msg, output, getExpected(minTypes[k]));
@@ -1391,6 +1448,11 @@ public class TestBuiltin {
                 assertEquals(msg, output, getExpected(minTypes[k]));
             } else if (inputType == "String") {
                 assertEquals(msg, output, getExpected(minTypes[k]));
+            } else if (inputType == "BigDecimal") {
+                assertEquals(msg, ((BigDecimal) output).toPlainString(),  ((BigDecimal) getExpected(minTypes[k])).toPlainString());
+            } else if (inputType == "BigInteger") {
+                assertEquals(msg, ((BigInteger) output).toString(), ((BigInteger) getExpected(minTypes[k])).toString());
+
             } else if (inputType == "DateTime") {
                 // Compare millis so that we dont have to worry about TZ
                 assertEquals(msg, ((DateTime)output).getMillis(), ((DateTime)getExpected(minTypes[k])).getMillis());
@@ -1402,8 +1464,10 @@ public class TestBuiltin {
     @Test
     public void testMINIntermediate() throws Exception {
 
-        String[] minTypes = {"MINIntermediate", "LongMinIntermediate", "IntMinIntermediate", "FloatMinIntermediate", "StringMinIntermediate", "DateTimeMinIntermediate"};
-        for(int k = 0; k < minTypes.length; k++) {
+        String[] minTypes = {"MINIntermediate", "LongMinIntermediate", "IntMinIntermediate", "FloatMinIntermediate",
+                             "BigDecimalMinIntermediate", "BigIntegerMinIntermediate", 
+                             "StringMinIntermediate", "DateTimeMinIntermediate"};
+        for (int k = 0; k < minTypes.length; k++) {
             EvalFunc<?> min = evalFuncMap.get(minTypes[k]);
             String inputType = getInputType(minTypes[k]);
             Tuple tup = inputMap.get(inputType);
@@ -1412,16 +1476,21 @@ public class TestBuiltin {
             String msg = "[Testing " + minTypes[k] + " on input type: " + getInputType(minTypes[k]) + " ( (output) " +
                            ((Tuple)output).get(0) + " == " + getExpected(minTypes[k]) + " (expected) )]";
 
-            if(inputType == "ByteArray") {
+            if (inputType == "ByteArray") {
               assertEquals(msg, ((Tuple)output).get(0), getExpected(minTypes[k]));
-            } else if(inputType == "Long") {
+            } else if (inputType == "Long") {
                 assertEquals(msg, ((Tuple)output).get(0), getExpected(minTypes[k]));
-            } else if(inputType == "Integer") {
+            } else if (inputType == "Integer") {
                 assertEquals(msg, ((Tuple)output).get(0), getExpected(minTypes[k]));
             } else if (inputType == "Double") {
                 assertEquals(msg, ((Tuple)output).get(0), getExpected(minTypes[k]));
             } else if (inputType == "Float") {
                 assertEquals(msg, ((Tuple)output).get(0), getExpected(minTypes[k]));
+            } else if (inputType == "BigDecimal") {
+                assertEquals(msg, ((BigDecimal)((Tuple)output).get(0)).toPlainString(), ((BigDecimal)getExpected(minTypes[k])).toPlainString());
+            } else if (inputType == "BigInteger") {
+                assertEquals(msg, ((BigInteger)((Tuple)output).get(0)).toString(), ((BigInteger)getExpected(minTypes[k])).toString());
+                System.out.println("xxx: here");
             } else if (inputType == "String") {
                 assertEquals(msg, ((Tuple)output).get(0), getExpected(minTypes[k]));
             } else if (inputType == "DateTime") {
@@ -1433,8 +1502,8 @@ public class TestBuiltin {
 
     @Test
     public void testMINFinal() throws Exception {
-        String[] minTypes = {"MINFinal", "LongMinFinal", "IntMinFinal", "FloatMinFinal", "StringMinFinal", "DateTimeMinFinal"};
-        for(int k = 0; k < minTypes.length; k++) {
+        String[] minTypes = {"MINFinal", "LongMinFinal", "IntMinFinal", "FloatMinFinal", "BigDecimalMinFinal", "BigIntegerMinFinal", "StringMinFinal", "DateTimeMinFinal"};
+        for (int k = 0; k < minTypes.length; k++) {
             EvalFunc<?> min = evalFuncMap.get(minTypes[k]);
             String inputType = getInputType(minTypes[k]);
             Tuple tup = inputMap.get(inputType);
@@ -1443,16 +1512,20 @@ public class TestBuiltin {
             String msg = "[Testing " + minTypes[k] + " on input type: " + getInputType(minTypes[k]) + " ( (output) " +
                            output + " == " + getExpected(minTypes[k]) + " (expected) )]";
 
-            if(inputType == "ByteArray") {
+            if (inputType == "ByteArray") {
               assertEquals(msg, output, getExpected(minTypes[k]));
-            } else if(inputType == "Long") {
+            } else if (inputType == "Long") {
                 assertEquals(msg, output, getExpected(minTypes[k]));
-            } else if(inputType == "Integer") {
+            } else if (inputType == "Integer") {
                 assertEquals(msg, output, getExpected(minTypes[k]));
             } else if (inputType == "Double") {
                 assertEquals(msg, output, getExpected(minTypes[k]));
             } else if (inputType == "Float") {
                 assertEquals(msg, output, getExpected(minTypes[k]));
+            } else if (inputType == "BigDecimal") {
+                assertEquals(msg, ((BigDecimal)output).toPlainString(), ((BigDecimal)getExpected(minTypes[k])).toPlainString());
+            } else if (inputType == "BigInteger") {
+                assertEquals(msg, ((BigInteger)output).toString(), ((BigInteger)getExpected(minTypes[k])).toString());
             } else if (inputType == "String") {
                 assertEquals(msg, output, getExpected(minTypes[k]));
             } else if (inputType == "DateTime") {
@@ -1465,8 +1538,8 @@ public class TestBuiltin {
     @Test
     public void testMAX() throws Exception {
 
-        String[] maxTypes = {"MAX", "LongMax", "IntMax", "FloatMax", "StringMax", "DateTimeMax"};
-        for(int k = 0; k < maxTypes.length; k++) {
+        String[] maxTypes = {"MAX", "LongMax", "IntMax", "FloatMax", "BigDecimalMax", "BigIntegerMax", "StringMax", "DateTimeMax"};
+        for (int k = 0; k < maxTypes.length; k++) {
             EvalFunc<?> max = evalFuncMap.get(maxTypes[k]);
             String inputType = getInputType(maxTypes[k]);
             Tuple tup = inputMap.get(inputType);
@@ -1475,16 +1548,20 @@ public class TestBuiltin {
             String msg = "[Testing " + maxTypes[k] + " on input type: " + getInputType(maxTypes[k]) + " ( (output) " +
                            output + " == " + getExpected(maxTypes[k]) + " (expected) )]";
 
-            if(inputType == "ByteArray") {
+            if (inputType == "ByteArray") {
               assertEquals(msg, output, getExpected(maxTypes[k]));
-            } else if(inputType == "Long") {
+            } else if (inputType == "Long") {
                 assertEquals(msg, output, getExpected(maxTypes[k]));
-            } else if(inputType == "Integer") {
+            } else if (inputType == "Integer") {
                 assertEquals(msg, output, getExpected(maxTypes[k]));
             } else if (inputType == "Double") {
                 assertEquals(msg, output, getExpected(maxTypes[k]));
             } else if (inputType == "Float") {
                 assertEquals(msg, output, getExpected(maxTypes[k]));
+            } else if (inputType == "BigDecimal") {
+                assertEquals(msg, ((BigDecimal)output).toPlainString(), ((BigDecimal)getExpected(maxTypes[k])).toPlainString());
+            } else if (inputType == "BigInteger") {
+                assertEquals(msg, ((BigInteger)output).toString(), ((BigInteger)getExpected(maxTypes[k])).toString());
             } else if (inputType == "String") {
                 assertEquals(msg, output, getExpected(maxTypes[k]));
             } else if (inputType == "DateTime") {
@@ -1498,8 +1575,10 @@ public class TestBuiltin {
     @Test
     public void testMAXIntermed() throws Exception {
 
-        String[] maxTypes = {"MAXIntermediate", "LongMaxIntermediate", "IntMaxIntermediate", "FloatMaxIntermediate", "StringMaxIntermediate", "DateTimeMaxIntermediate"};
-        for(int k = 0; k < maxTypes.length; k++) {
+        String[] maxTypes = {"MAXIntermediate", "LongMaxIntermediate", "IntMaxIntermediate", "FloatMaxIntermediate",
+                             "BigDecimalMaxIntermediate", "BigIntegerMaxIntermediate",
+                             "StringMaxIntermediate", "DateTimeMaxIntermediate"};
+        for (int k = 0; k < maxTypes.length; k++) {
             EvalFunc<?> max = evalFuncMap.get(maxTypes[k]);
             String inputType = getInputType(maxTypes[k]);
             Tuple tup = inputMap.get(inputType);
@@ -1508,16 +1587,20 @@ public class TestBuiltin {
             String msg = "[Testing " + maxTypes[k] + " on input type: " + getInputType(maxTypes[k]) + " ( (output) " +
                            ((Tuple)output).get(0) + " == " + getExpected(maxTypes[k]) + " (expected) )]";
 
-            if(inputType == "ByteArray") {
+            if (inputType == "ByteArray") {
               assertEquals(msg, ((Tuple)output).get(0), getExpected(maxTypes[k]));
-            } else if(inputType == "Long") {
+            } else if (inputType == "Long") {
                 assertEquals(msg, ((Tuple)output).get(0), getExpected(maxTypes[k]));
-            } else if(inputType == "Integer") {
+            } else if (inputType == "Integer") {
                 assertEquals(msg, ((Tuple)output).get(0), getExpected(maxTypes[k]));
             } else if (inputType == "Double") {
                 assertEquals(msg, ((Tuple)output).get(0), getExpected(maxTypes[k]));
             } else if (inputType == "Float") {
                 assertEquals(msg, ((Tuple)output).get(0), getExpected(maxTypes[k]));
+            } else if (inputType == "BigDecimal") {
+                assertEquals(msg, ((BigDecimal)((Tuple)output).get(0)).toPlainString(), ((BigDecimal)getExpected(maxTypes[k])).toPlainString());
+            } else if (inputType == "BigInteger") {
+                assertEquals(msg, ((BigInteger)((Tuple)output).get(0)).toString(), ((BigInteger)getExpected(maxTypes[k])).toString());
             } else if (inputType == "String") {
                 assertEquals(msg, ((Tuple)output).get(0), getExpected(maxTypes[k]));
             } else if (inputType == "DateTime") {
@@ -1530,8 +1613,8 @@ public class TestBuiltin {
     @Test
     public void testMAXFinal() throws Exception {
 
-        String[] maxTypes = {"MAXFinal", "LongMaxFinal", "IntMaxFinal", "FloatMaxFinal", "StringMaxFinal", "DateTimeMaxFinal"};
-        for(int k = 0; k < maxTypes.length; k++) {
+        String[] maxTypes = {"MAXFinal", "LongMaxFinal", "IntMaxFinal", "FloatMaxFinal", "BigDecimalMaxFinal", "BigIntegerMaxFinal", "StringMaxFinal", "DateTimeMaxFinal"};
+        for (int k = 0; k < maxTypes.length; k++) {
             EvalFunc<?> max = evalFuncMap.get(maxTypes[k]);
             String inputType = getInputType(maxTypes[k]);
             Tuple tup = inputMap.get(inputType);
@@ -1540,16 +1623,20 @@ public class TestBuiltin {
             String msg = "[Testing " + maxTypes[k] + " on input type: " + getInputType(maxTypes[k]) + " ( (output) " +
                            output + " == " + getExpected(maxTypes[k]) + " (expected) )]";
 
-            if(inputType == "ByteArray") {
+            if (inputType == "ByteArray") {
               assertEquals(msg, output, getExpected(maxTypes[k]));
-            } else if(inputType == "Long") {
+            } else if (inputType == "Long") {
                 assertEquals(msg, output, getExpected(maxTypes[k]));
-            } else if(inputType == "Integer") {
+            } else if (inputType == "Integer") {
                 assertEquals(msg, output, getExpected(maxTypes[k]));
             } else if (inputType == "Double") {
                 assertEquals(msg, output, getExpected(maxTypes[k]));
             } else if (inputType == "Float") {
                 assertEquals(msg, output, getExpected(maxTypes[k]));
+            } else if (inputType == "BigDecimal") {
+                assertEquals(msg, ((BigDecimal)output).toPlainString(), ((BigDecimal)getExpected(maxTypes[k])).toPlainString());
+            } else if (inputType == "BigInteger") {
+                assertEquals(msg, ((BigInteger)output).toString(), ((BigInteger)getExpected(maxTypes[k])).toString());
             } else if (inputType == "String") {
                 assertEquals(msg, output, getExpected(maxTypes[k]));
             } else if (inputType == "DateTime") {
@@ -1594,7 +1681,7 @@ public class TestBuiltin {
         Double input, actual, expected;
         Method mathMethod;
         String msg;
-        for(String func: mathFuncs) {
+        for (String func: mathFuncs) {
             evalFunc = (EvalFunc<Double>) Class.forName(udfPackage + func).newInstance();
             tup = TupleFactory.getInstance().newTuple(1);
             // double value between 0.0 and 1.0
@@ -2055,19 +2142,19 @@ public class TestBuiltin {
         Tuple output = tt.exec(input);
         assertEquals(input, output);
 
-	// TOMAP - construct a map from input fields
-	TOMAP tm = new TOMAP();
-	Tuple t = TupleFactory.getInstance().newTuple(6);
-	t.set(0, "k1");
-	t.set(1, 1);
-	t.set(2, "k2");
-	t.set(3, 2.0);
-	t.set(4, "k3");
-	t.set(5, "foo");
-	Map m = tm.exec(t);
-	assertEquals("", m.get("k1"), 1);
-	assertEquals("", m.get("k2"), 2.0);
-	assertEquals("", m.get("k3"), "foo");
+        // TOMAP - construct a map from input fields
+        TOMAP tm = new TOMAP();
+        Tuple t = TupleFactory.getInstance().newTuple(6);
+        t.set(0, "k1");
+        t.set(1, 1);
+        t.set(2, "k2");
+        t.set(3, 2.0);
+        t.set(4, "k3");
+        t.set(5, "foo");
+        Map m = tm.exec(t);
+        assertEquals("", m.get("k1"), 1);
+        assertEquals("", m.get("k2"), 2.0);
+        assertEquals("", m.get("k3"), "foo");
 
         // TOP - tests migrated to org.apache.pig.builtin.TestTop
     }
@@ -2083,7 +2170,7 @@ public class TestBuiltin {
         int i = 0;
         for (Tuple t : inputBag) {
             Tuple initialOutput = initial.exec(tupleFactory.newTuple(t));
-            if(i < inp.length/2 ) {
+            if (i < inp.length/2 ) {
                 intermedInputBg1.add(initialOutput);
             } else {
                 intermedInputBg2.add(initialOutput);
@@ -2124,7 +2211,7 @@ public class TestBuiltin {
 
         int inputSize = 2002;
         Integer[] inp = new Integer[inputSize];
-        for(int i = 0; i < inputSize; i+=2) {
+        for (int i = 0; i < inputSize; i+=2) {
             inp[i] = i/2;
             inp[i+1] = i/2;
         }
@@ -2134,7 +2221,7 @@ public class TestBuiltin {
         DataBag result = distinct.exec(tupleFactory.newTuple(inputBag));
 
         Integer[] exp = new Integer[inputSize/2];
-        for(int j = 0; j < inputSize/2; ++j) {
+        for (int j = 0; j < inputSize/2; ++j) {
             exp[j] = j;
         }
 
@@ -2335,13 +2422,13 @@ public class TestBuiltin {
     */
     @Test
     public void testTupleSize() throws Exception {
-    	String inputFileName = "TupleSizeIn.txt";
-    	String[] inputData = new String[] {
-    			"Don't call my name, don't call my name, Alejandro",
-    			"I'm not your babe, I'm not your babe, Fernando",
-    			"Don't wanna kiss, don't wanna touch",
-    			"Just smoke my cigarette and hush",
-    			"Don't call my name, don't call my name, Roberto"};
+        String inputFileName = "TupleSizeIn.txt";
+        String[] inputData = new String[] {
+                "Don't call my name, don't call my name, Alejandro",
+                "I'm not your babe, I'm not your babe, Fernando",
+                "Don't wanna kiss, don't wanna touch",
+                "Just smoke my cigarette and hush",
+                "Don't call my name, don't call my name, Roberto"};
         File inputFile = Util.createInputFile("tmp", inputFileName, inputData);
 
         // test typed data
@@ -2352,9 +2439,9 @@ public class TestBuiltin {
         Iterator<Tuple> it = pigServer.openIterator("C");
         int i=0;
         while (it.hasNext()) {
-        	Tuple t = it.next();
-        	assertEquals("Testing SIZE(<Tuple>): ", new Long(new StringTokenizer(inputData[i]).countTokens()), t.get(1));
-        	i++;
+            Tuple t = it.next();
+            assertEquals("Testing SIZE(<Tuple>): ", new Long(new StringTokenizer(inputData[i]).countTokens()), t.get(1));
+            i++;
         }
         inputFile.delete();
         assertTrue(!it.hasNext());
@@ -2468,7 +2555,7 @@ public class TestBuiltin {
                 newTuple(input.length), input);
         String outputLocation = "testSFPig-output.txt";
         String query = "a = load 'testSFPig-input.txt';" +
-        		"store a into '" + outputLocation + "';";
+                "store a into '" + outputLocation + "';";
         mrPigServer.setBatchOn();
         Util.registerMultiLineQuery(mrPigServer, query);
         mrPigServer.executeBatch();
@@ -2627,12 +2714,12 @@ public class TestBuiltin {
              int i=0;
              while(it.hasNext())
              {
-            	 assertTrue(it.next().get(0).equals(inputData[i]));
-            	 i++;
+                 assertTrue(it.next().get(0).equals(inputData[i]));
+                 i++;
              }
              assertTrue(i==3);
-         }catch(Exception e) {
-         }finally {
+         } catch (Exception e) {
+         } finally {
              Util.deleteFile(cluster, inputFileName);
          }
     }

Modified: pig/branches/tez/test/org/apache/pig/test/TestJobControlCompiler.java
URL: http://svn.apache.org/viewvc/pig/branches/tez/test/org/apache/pig/test/TestJobControlCompiler.java?rev=1543105&r1=1543104&r2=1543105&view=diff
==============================================================================
--- pig/branches/tez/test/org/apache/pig/test/TestJobControlCompiler.java (original)
+++ pig/branches/tez/test/org/apache/pig/test/TestJobControlCompiler.java Mon Nov 18 18:50:29 2013
@@ -33,7 +33,6 @@ import java.util.Arrays;
 import java.util.Enumeration;
 import java.util.HashSet;
 import java.util.List;
-import java.util.Properties;
 import java.util.jar.JarEntry;
 import java.util.jar.JarFile;
 import java.util.jar.JarOutputStream;
@@ -55,6 +54,7 @@ import org.apache.hadoop.mapreduce.Job;
 import org.apache.pig.ExecType;
 import org.apache.pig.FuncSpec;
 import org.apache.pig.LoadFunc;
+import org.apache.pig.PigServer;
 import org.apache.pig.backend.hadoop.executionengine.mapReduceLayer.JobControlCompiler;
 import org.apache.pig.backend.hadoop.executionengine.mapReduceLayer.MapReduceOper;
 import org.apache.pig.backend.hadoop.executionengine.mapReduceLayer.plans.MROperPlan;
@@ -109,7 +109,8 @@ public class TestJobControlCompiler {
     final String testUDFFileName = className+".class";
 
     // JobControlCompiler setup
-    PigContext pigContext = new PigContext(ExecType.MAPREDUCE, new Properties());
+    PigServer pigServer = new PigServer(ExecType.MAPREDUCE);
+    PigContext pigContext = pigServer.getPigContext();
     pigContext.connect();
     pigContext.addJar(tmpFile.getAbsolutePath());
     JobControlCompiler jobControlCompiler = new JobControlCompiler(pigContext, CONF);
@@ -168,7 +169,8 @@ public class TestJobControlCompiler {
         zipArchives.add(textFile);
         final List<File> tarArchives = createFiles(".tgz", ".tar.gz", ".tar");
 
-        final PigContext pigContext = new PigContext();
+        final PigServer pigServer = new PigServer(ExecType.MAPREDUCE);
+        final PigContext pigContext = pigServer.getPigContext();
         pigContext.connect();
         pigContext.getProperties().put("pig.streaming.ship.files",
                 StringUtils.join(zipArchives, ","));

Modified: pig/branches/tez/test/org/apache/pig/test/TestPOPartialAggPlan.java
URL: http://svn.apache.org/viewvc/pig/branches/tez/test/org/apache/pig/test/TestPOPartialAggPlan.java?rev=1543105&r1=1543104&r2=1543105&view=diff
==============================================================================
--- pig/branches/tez/test/org/apache/pig/test/TestPOPartialAggPlan.java (original)
+++ pig/branches/tez/test/org/apache/pig/test/TestPOPartialAggPlan.java Mon Nov 18 18:50:29 2013
@@ -22,10 +22,10 @@ import static org.junit.Assert.assertNot
 import static org.junit.Assert.assertNull;
 
 import java.util.Iterator;
-import java.util.Properties;
 
 import org.apache.pig.ExecType;
 import org.apache.pig.PigConfiguration;
+import org.apache.pig.PigServer;
 import org.apache.pig.backend.executionengine.ExecException;
 import org.apache.pig.backend.hadoop.executionengine.mapReduceLayer.plans.MROperPlan;
 import org.apache.pig.backend.hadoop.executionengine.physicalLayer.PhysicalOperator;
@@ -39,11 +39,13 @@ import org.junit.Test;
  * Test POPartialAgg runtime
  */
 public class TestPOPartialAggPlan  {
-    PigContext pc;
+    private static PigContext pc;
+    private static PigServer ps;
 
     @Before
     public void setUp() throws ExecException {
-        pc = new PigContext(ExecType.LOCAL, new Properties());
+        ps = new PigServer(ExecType.LOCAL);
+        pc = ps.getPigContext();
         pc.connect();
     }
 

Modified: pig/branches/tez/test/org/apache/pig/test/TestPlanGeneration.java
URL: http://svn.apache.org/viewvc/pig/branches/tez/test/org/apache/pig/test/TestPlanGeneration.java?rev=1543105&r1=1543104&r2=1543105&view=diff
==============================================================================
--- pig/branches/tez/test/org/apache/pig/test/TestPlanGeneration.java (original)
+++ pig/branches/tez/test/org/apache/pig/test/TestPlanGeneration.java Mon Nov 18 18:50:29 2013
@@ -20,12 +20,12 @@ import static org.junit.Assert.assertNot
 import static org.junit.Assert.assertNull;
 
 import java.io.IOException;
-import java.util.Properties;
 
 import org.apache.hadoop.mapreduce.Job;
 import org.apache.pig.ExecType;
 import org.apache.pig.Expression;
 import org.apache.pig.LoadMetadata;
+import org.apache.pig.PigServer;
 import org.apache.pig.ResourceSchema;
 import org.apache.pig.ResourceStatistics;
 import org.apache.pig.backend.executionengine.ExecException;
@@ -57,11 +57,13 @@ import org.junit.Test;
 
 public class TestPlanGeneration {
 
-    static PigContext pc;
+    private static PigContext pc;
+    private static PigServer ps;
 
     @BeforeClass
     public static void setUp() throws ExecException {
-        pc = new PigContext(ExecType.LOCAL, new Properties());
+        ps = new PigServer(ExecType.LOCAL);
+        pc = ps.getPigContext();
         pc.connect();
     }
 

Modified: pig/branches/tez/test/org/apache/pig/test/TestScriptLanguage.java
URL: http://svn.apache.org/viewvc/pig/branches/tez/test/org/apache/pig/test/TestScriptLanguage.java?rev=1543105&r1=1543104&r2=1543105&view=diff
==============================================================================
--- pig/branches/tez/test/org/apache/pig/test/TestScriptLanguage.java (original)
+++ pig/branches/tez/test/org/apache/pig/test/TestScriptLanguage.java Mon Nov 18 18:50:29 2013
@@ -38,14 +38,12 @@ import org.apache.pig.tools.pigstats.Pig
 import org.apache.pig.tools.pigstats.PigStatsUtil;
 import org.junit.After;
 import org.junit.AfterClass;
-import org.junit.Before;
 import org.junit.BeforeClass;
 import org.junit.Test;
 
 public class TestScriptLanguage {
 
     static MiniCluster cluster = MiniCluster.buildCluster();
-    private PigServer pigServer;
 
     @BeforeClass
     public static void setUpBeforeClass() throws Exception {
@@ -57,11 +55,6 @@ public class TestScriptLanguage {
         cluster.shutDown();
     }
 
-    @Before
-    public void setUp() throws Exception {
-        pigServer = new PigServer(ExecType.MAPREDUCE, cluster.getProperties());
-    }
-
     @After
     public void tearDown() throws Exception {
         Util.deleteFile(cluster, "simple_out");
@@ -78,6 +71,7 @@ public class TestScriptLanguage {
         String scriptName = name + "_testScript.py";
         Util.createLocalInputFile(scriptName, script);
         ScriptEngine scriptEngine = ScriptEngine.getInstance("jython");
+        PigServer pigServer = new PigServer(ExecType.MAPREDUCE, cluster.getProperties());
         Map<String, List<PigStats>> statsMap = scriptEngine.run(pigServer.getPigContext(), scriptName);
         return statsMap;
     }

Propchange: pig/branches/tez/test/org/apache/pig/test/data/bzipdir1.bz2/bzipdir2.bz2/recordLossblockHeaderEndsAt136500.txt.bz2
------------------------------------------------------------------------------
  Merged /pig/trunk/test/org/apache/pig/test/data/bzipdir1.bz2/bzipdir2.bz2/recordLossblockHeaderEndsAt136500.txt.bz2:r1542433-1543104