parquet-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jul...@apache.org
Subject parquet-mr git commit: PARQUET-334: UT test failure with Pig 0.15
Date Sat, 12 Dec 2015 23:35:31 GMT
Repository: parquet-mr
Updated Branches:
  refs/heads/master 491690335 -> fa7588c4c


PARQUET-334: UT test failure with Pig 0.15

I made a few updates to the original patch PARQUET-334-1.patch proposed by Daniel. As the
inputschema is maintained in EvalFunc, any reference to the private class variable inputSchema
should be changed to getInputSchema(), and inputSchema can be removed because it will be null
always.

Author: Thomas Friedrich <tfriedr@us.ibm.com>

Closes #292 from tfriedr/parquet-334 and squashes the following commits:

012563e [Thomas Friedrich] PARQUET_334: UT test failure with Pig 0.15


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

Branch: refs/heads/master
Commit: fa7588c4c0f8d403e4815fa72e3b8a3bc98d73ec
Parents: 4916903
Author: Thomas Friedrich <tfriedr@us.ibm.com>
Authored: Sat Dec 12 15:35:21 2015 -0800
Committer: Julien Le Dem <julien@dremio.com>
Committed: Sat Dec 12 15:35:21 2015 -0800

----------------------------------------------------------------------
 .../org/apache/parquet/pig/summary/Summary.java | 56 +-------------------
 1 file changed, 2 insertions(+), 54 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/parquet-mr/blob/fa7588c4/parquet-pig/src/main/java/org/apache/parquet/pig/summary/Summary.java
----------------------------------------------------------------------
diff --git a/parquet-pig/src/main/java/org/apache/parquet/pig/summary/Summary.java b/parquet-pig/src/main/java/org/apache/parquet/pig/summary/Summary.java
index 32199cc..5447858 100644
--- a/parquet-pig/src/main/java/org/apache/parquet/pig/summary/Summary.java
+++ b/parquet-pig/src/main/java/org/apache/parquet/pig/summary/Summary.java
@@ -25,7 +25,6 @@ import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Iterator;
 import java.util.List;
-import java.util.Properties;
 
 import org.apache.pig.Algebraic;
 import org.apache.pig.EvalFunc;
@@ -34,11 +33,7 @@ import org.apache.pig.data.DataBag;
 import org.apache.pig.data.DataType;
 import org.apache.pig.data.Tuple;
 import org.apache.pig.data.TupleFactory;
-import org.apache.pig.impl.logicalLayer.FrontendException;
 import org.apache.pig.impl.logicalLayer.schema.Schema;
-import org.apache.pig.impl.util.UDFContext;
-import org.apache.pig.impl.util.Utils;
-import org.apache.pig.parser.ParserException;
 import org.codehaus.jackson.JsonParseException;
 import org.codehaus.jackson.map.JsonMappingException;
 
@@ -51,21 +46,12 @@ import org.codehaus.jackson.map.JsonMappingException;
 public class Summary extends EvalFunc<String> implements Algebraic {
 
   private static final TupleFactory TF = TupleFactory.getInstance();
-  private Schema inputSchema;
-  private String signature;
 
   public static class Initial extends EvalFunc<Tuple> {
 
-    private Schema inputSchema;
-
-    @Override
-    public void setUDFContextSignature(String signature) {
-      inputSchema = Summary.getInputSchema(signature);
-    }
-
     @Override
     public Tuple exec(Tuple t) throws IOException {
-      return new JSONTuple(sumUp(inputSchema, t));
+      return new JSONTuple(sumUp(getInputSchema(), t));
     }
   }
 
@@ -179,18 +165,6 @@ public class Summary extends EvalFunc<String> implements Algebraic
{
 
   }
 
-  private static Properties getProperties(String signature) {
-    return UDFContext.getUDFContext().getUDFProperties(Summary.class, new String[] { signature
});
-  }
-
-  private static Schema getInputSchema(String signature) {
-    try {
-      return Utils.getSchemaFromString(getProperties(signature).getProperty("inputSchema"));
-    } catch (ParserException e) {
-       throw new RuntimeException(e);
-    }
-  }
-
   private static TupleSummaryData getData(Tuple tuple) throws ExecException {
     if (tuple instanceof JSONTuple) {
       return ((JSONTuple) tuple).data;
@@ -236,7 +210,7 @@ public class Summary extends EvalFunc<String> implements Algebraic
{
 
   @Override
   public String exec(Tuple t) throws IOException {
-    return SummaryData.toPrettyJSON(sumUp(inputSchema, t));
+    return SummaryData.toPrettyJSON(sumUp(getInputSchema(), t));
   }
 
   @Override
@@ -254,30 +228,4 @@ public class Summary extends EvalFunc<String> implements Algebraic
{
     return Final.class.getName();
   }
 
-  @Override
-  public void setInputSchema(Schema input) {
-    try {
-      // relation.bag.tuple
-      this.inputSchema = input.getField(0).schema.getField(0).schema;
-      saveSchemaToUDFContext();
-    } catch (FrontendException e) {
-      throw new RuntimeException("Usage: B = FOREACH (GROUP A ALL) GENERATE Summary(A); Can
not get schema from " + input, e);
-    } catch (RuntimeException e) {
-      throw new RuntimeException("Usage: B = FOREACH (GROUP A ALL) GENERATE Summary(A); Can
not get schema from "+input, e);
-    }
-  }
-
-  @Override
-  public void setUDFContextSignature(String signature) {
-    this.signature = signature;
-    saveSchemaToUDFContext();
-  }
-
-  private void saveSchemaToUDFContext() {
-    if (signature != null && inputSchema != null) {
-      String schemaString = inputSchema.toString();
-      getProperties(signature).put("inputSchema", schemaString.substring(1, schemaString.length()
- 1));
-    }
-  }
-
 }


Mime
View raw message