Author: rohini
Date: Wed Sep 2 21:42:04 2015
New Revision: 1700906
URL: http://svn.apache.org/r1700906
Log:
Fix test failure from PIG-3622: Allow casting bytearray fields to bytearray type
Modified:
pig/trunk/src/org/apache/pig/newplan/logical/visitor/TypeCheckingExpVisitor.java
pig/trunk/test/org/apache/pig/test/TestTypeCheckingValidatorNewLP.java
Modified:
pig/trunk/src/org/apache/pig/newplan/logical/visitor/TypeCheckingExpVisitor.java
URL:
http://svn.apache.org/viewvc/pig/trunk/src/org/apache/pig/newplan/logical/visitor/TypeCheckingExpVisitor.java?rev=1700906&r1=1700905&r2=1700906&view=diff
==============================================================================
---
pig/trunk/src/org/apache/pig/newplan/logical/visitor/TypeCheckingExpVisitor.java
(original)
+++
pig/trunk/src/org/apache/pig/newplan/logical/visitor/TypeCheckingExpVisitor.java
Wed Sep 2 21:42:04 2015
@@ -227,7 +227,7 @@ public class TypeCheckingExpVisitor exte
private String generateIncompatibleTypesMessage(BinaryExpression binOp)
throws FrontendException {
String msg = binOp.toString();
- if (currentRelOp.getAlias()!=null){
+ if (currentRelOp != null && currentRelOp.getAlias() != null) {
msg = "In alias " + currentRelOp.getAlias() + ", ";
}
LogicalFieldSchema lhsFs = binOp.getLhs().getFieldSchema();
@@ -710,7 +710,7 @@ public class TypeCheckingExpVisitor exte
String msg = "Unable to get list of overloaded methods.";
throw new TypeCheckerException(func, msg, errCode,
PigException.INPUT, e);
}
-
+
// EvalFunc's schema type
SchemaType udfSchemaType = ef.getSchemaType();
@@ -820,7 +820,7 @@ public class TypeCheckingExpVisitor exte
* input schema
* @param func -
* udf expression
- * @param udfSchemaType -
+ * @param udfSchemaType -
* schema type of the udf
* @return the funcSpec that supports the schema that is best suited to s.
* The best suited schema is one that has the lowest score as
@@ -912,6 +912,7 @@ public class TypeCheckingExpVisitor exte
/* (non-Javadoc)
* @see java.util.Comparator#compare(java.lang.Object,
java.lang.Object)
*/
+ @Override
public int compare(Pair<Long, FuncSpec> o1, Pair<Long, FuncSpec> o2) {
if(o1.first < o2.first)
return -1;
@@ -1135,11 +1136,11 @@ public class TypeCheckingExpVisitor exte
//if there's no more UDF field: take the last one which is the
vararg field
udfFieldSchema = j.hasNext() ? j.next() : udfFieldSchema;
-
+
if(ignoreByteArrays && inputFieldSchema.type ==
DataType.BYTEARRAY) {
continue;
}
-
+
if (inputFieldSchema.type != udfFieldSchema.type) {
return false;
}
@@ -1313,7 +1314,7 @@ public class TypeCheckingExpVisitor exte
if(s1==null || s2==null) return INF;
List<FieldSchema> sFields = s1.getFields();
List<FieldSchema> fsFields = s2.getFields();
-
+
if((s2Type == SchemaType.NORMAL) && (sFields.size()!=fsFields.size()))
return INF;
if((s2Type == SchemaType.VARARG) && (sFields.size() < fsFields.size()))
@@ -1332,9 +1333,9 @@ public class TypeCheckingExpVisitor exte
// of this function
if (sFS.type == DataType.BYTEARRAY)
continue;
-
+
//if we get to the vararg field (if defined) : take it repeatedly
- FieldSchema fsFS = ((s2Type == SchemaType.VARARG) && i >=
s2.size()) ?
+ FieldSchema fsFS = ((s2Type == SchemaType.VARARG) && i >=
s2.size()) ?
fsFields.get(s2.size() - 1) : fsFields.get(i);
if(DataType.isSchemaType(sFS.type)){
@@ -1361,7 +1362,7 @@ public class TypeCheckingExpVisitor exte
for (FieldSchema fFSch : fsLst) {
++i;
//if we get to the vararg field (if defined) : take it repeatedly
- FieldSchema tFSch = ((toSchType == SchemaType.VARARG) && i >=
tsLst.size()) ?
+ FieldSchema tFSch = ((toSchType == SchemaType.VARARG) && i >=
tsLst.size()) ?
tsLst.get(tsLst.size() - 1) : tsLst.get(i);
if (fFSch.type == tFSch.type) {
continue;
Modified: pig/trunk/test/org/apache/pig/test/TestTypeCheckingValidatorNewLP.java
URL:
http://svn.apache.org/viewvc/pig/trunk/test/org/apache/pig/test/TestTypeCheckingValidatorNewLP.java?rev=1700906&r1=1700905&r2=1700906&view=diff
==============================================================================
--- pig/trunk/test/org/apache/pig/test/TestTypeCheckingValidatorNewLP.java
(original)
+++ pig/trunk/test/org/apache/pig/test/TestTypeCheckingValidatorNewLP.java Wed
Sep 2 21:42:04 2015
@@ -745,8 +745,8 @@ public class TestTypeCheckingValidatorNe
// value of datetime and one of other type
LogicalExpressionPlan plan = new LogicalExpressionPlan();
ConstantExpression constant0 = new ConstantExpression(plan, new
DateTime(0L));
- ConstantExpression constant1 = new ConstantExpression(plan, new
DataByteArray("1970-01-01T00:00:00.000Z"));
- CastExpression cast1 = new CastExpression(plan, constant1,
createFS(DataType.BYTEARRAY));
+ ConstantExpression constant1 = new ConstantExpression(plan, new
String("1970-01-01T00:00:00.000Z"));
+ CastExpression cast1 = new CastExpression(plan, constant1,
createFS(DataType.CHARARRAY));
EqualExpression eq1 = new EqualExpression(plan, constant0, cast1);
CompilationMessageCollector collector = new
CompilationMessageCollector();
@@ -3685,6 +3685,7 @@ public class TestTypeCheckingValidatorNe
super(p, walker);
}
+ @Override
public void visit(CastExpression cExp){
casts.add(cExp);
}