tajo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hyun...@apache.org
Subject [1/2] tajo git commit: TAJO-2127: Use Type instead of DataType for EvalNode.
Date Fri, 22 Apr 2016 12:06:50 GMT
Repository: tajo
Updated Branches:
  refs/heads/master dc96f7e27 -> 552376a80


http://git-wip-us.apache.org/repos/asf/tajo/blob/552376a8/tajo-plan/src/main/java/org/apache/tajo/plan/expr/BetweenPredicateEval.java
----------------------------------------------------------------------
diff --git a/tajo-plan/src/main/java/org/apache/tajo/plan/expr/BetweenPredicateEval.java b/tajo-plan/src/main/java/org/apache/tajo/plan/expr/BetweenPredicateEval.java
index eb3e36b..9c78497 100644
--- a/tajo-plan/src/main/java/org/apache/tajo/plan/expr/BetweenPredicateEval.java
+++ b/tajo-plan/src/main/java/org/apache/tajo/plan/expr/BetweenPredicateEval.java
@@ -19,17 +19,14 @@
 package org.apache.tajo.plan.expr;
 
 import com.google.gson.annotations.Expose;
-
-import org.apache.tajo.catalog.CatalogUtil;
 import org.apache.tajo.catalog.Schema;
-import org.apache.tajo.common.TajoDataTypes;
 import org.apache.tajo.datum.Datum;
 import org.apache.tajo.datum.DatumFactory;
 import org.apache.tajo.datum.NullDatum;
 import org.apache.tajo.storage.Tuple;
+import org.apache.tajo.type.Type;
 
 public class BetweenPredicateEval extends EvalNode implements Cloneable {
-  private static final TajoDataTypes.DataType RES_TYPE = CatalogUtil.newSimpleDataType(TajoDataTypes.Type.BOOLEAN);
   @Expose private boolean not;
   @Expose private boolean symmetric;
   @Expose private EvalNode predicand;
@@ -194,8 +191,8 @@ public class BetweenPredicateEval extends EvalNode implements Cloneable
{
   }
 
   @Override
-  public TajoDataTypes.DataType getValueType() {
-    return RES_TYPE;
+  public Type getValueType() {
+    return Type.Bool;
   }
 
   @Override

http://git-wip-us.apache.org/repos/asf/tajo/blob/552376a8/tajo-plan/src/main/java/org/apache/tajo/plan/expr/BinaryEval.java
----------------------------------------------------------------------
diff --git a/tajo-plan/src/main/java/org/apache/tajo/plan/expr/BinaryEval.java b/tajo-plan/src/main/java/org/apache/tajo/plan/expr/BinaryEval.java
index e792c34..b565b80 100644
--- a/tajo-plan/src/main/java/org/apache/tajo/plan/expr/BinaryEval.java
+++ b/tajo-plan/src/main/java/org/apache/tajo/plan/expr/BinaryEval.java
@@ -20,21 +20,21 @@ package org.apache.tajo.plan.expr;
 
 import com.google.common.base.Objects;
 import com.google.gson.annotations.Expose;
-import org.apache.tajo.catalog.CatalogUtil;
-import org.apache.tajo.common.TajoDataTypes.DataType;
+import org.apache.tajo.DataTypeUtil;
+import org.apache.tajo.common.TajoDataTypes;
 import org.apache.tajo.datum.Datum;
 import org.apache.tajo.datum.DatumFactory;
 import org.apache.tajo.datum.NullDatum;
-import org.apache.tajo.DataTypeUtil;
 import org.apache.tajo.exception.InvalidOperationException;
 import org.apache.tajo.storage.Tuple;
 
-import static org.apache.tajo.common.TajoDataTypes.Type;
+import static org.apache.tajo.type.Type.Bool;
+import static org.apache.tajo.type.Type.Text;
 
 public class BinaryEval extends EvalNode implements Cloneable {
   @Expose protected EvalNode leftExpr;
   @Expose protected EvalNode rightExpr;
-  @Expose protected DataType returnType;
+  @Expose protected org.apache.tajo.type.Type returnType;
 
   protected BinaryEval(EvalType type) {
     super(type);
@@ -54,7 +54,7 @@ public class BinaryEval extends EvalNode implements Cloneable {
             type == EvalType.GTH ||
             type == EvalType.LEQ ||
             type == EvalType.GEQ ) {
-      this.returnType = CatalogUtil.newSimpleDataType(Type.BOOLEAN);
+      this.returnType = Bool;
     } else if (
         type == EvalType.PLUS ||
             type == EvalType.MINUS ||
@@ -64,7 +64,7 @@ public class BinaryEval extends EvalNode implements Cloneable {
       this.returnType = DataTypeUtil.determineType(left.getValueType(), right.getValueType());
 
     } else if (type == EvalType.CONCATENATE) {
-      this.returnType = CatalogUtil.newSimpleDataType(Type.TEXT);
+      this.returnType = Text;
     }
   }
 
@@ -154,7 +154,7 @@ public class BinaryEval extends EvalNode implements Cloneable {
       return lhs.modular(rhs);
 
     case CONCATENATE:
-      if (lhs.type() == Type.NULL_TYPE || rhs.type() == Type.NULL_TYPE) {
+      if (lhs.type() == TajoDataTypes.Type.NULL_TYPE || rhs.type() == TajoDataTypes.Type.NULL_TYPE)
{
         return NullDatum.get();
       }
       return DatumFactory.createText(lhs.asChars() + rhs.asChars());
@@ -169,7 +169,7 @@ public class BinaryEval extends EvalNode implements Cloneable {
 	}
 
 	@Override
-	public DataType getValueType() {
+	public org.apache.tajo.type.Type getValueType() {
 	  return returnType;
 	}
 

http://git-wip-us.apache.org/repos/asf/tajo/blob/552376a8/tajo-plan/src/main/java/org/apache/tajo/plan/expr/CaseWhenEval.java
----------------------------------------------------------------------
diff --git a/tajo-plan/src/main/java/org/apache/tajo/plan/expr/CaseWhenEval.java b/tajo-plan/src/main/java/org/apache/tajo/plan/expr/CaseWhenEval.java
index 331b8e1..d55cff9 100644
--- a/tajo-plan/src/main/java/org/apache/tajo/plan/expr/CaseWhenEval.java
+++ b/tajo-plan/src/main/java/org/apache/tajo/plan/expr/CaseWhenEval.java
@@ -20,11 +20,6 @@ package org.apache.tajo.plan.expr;
 
 import com.google.common.collect.Lists;
 import com.google.gson.annotations.Expose;
-
-import org.apache.tajo.catalog.CatalogUtil;
-import org.apache.tajo.common.TajoDataTypes;
-import org.apache.tajo.common.TajoDataTypes.DataType;
-import org.apache.tajo.common.TajoDataTypes.Type;
 import org.apache.tajo.datum.Datum;
 import org.apache.tajo.datum.NullDatum;
 import org.apache.tajo.json.GsonObject;
@@ -68,10 +63,10 @@ public class CaseWhenEval extends EvalNode implements GsonObject {
   }
 
   @Override
-  public DataType getValueType() {
+  public org.apache.tajo.type.Type getValueType() {
     // Find not null type
     for (IfThenEval eachWhen: whens) {
-      if (eachWhen.getResult().getValueType().getType() != Type.NULL_TYPE) {
+      if (!eachWhen.getResult().getValueType().isNull()) {
         return eachWhen.getResult().getValueType();
       }
     }
@@ -80,7 +75,7 @@ public class CaseWhenEval extends EvalNode implements GsonObject {
       return elseResult.getValueType();
     }
 
-    return NullDatum.getDataType();
+    return org.apache.tajo.type.Type.Null;
   }
 
   @Override
@@ -202,8 +197,8 @@ public class CaseWhenEval extends EvalNode implements GsonObject {
     }
 
     @Override
-    public DataType getValueType() {
-      return CatalogUtil.newSimpleDataType(TajoDataTypes.Type.BOOLEAN);
+    public org.apache.tajo.type.Type getValueType() {
+      return org.apache.tajo.type.Type.Bool;
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/tajo/blob/552376a8/tajo-plan/src/main/java/org/apache/tajo/plan/expr/CastEval.java
----------------------------------------------------------------------
diff --git a/tajo-plan/src/main/java/org/apache/tajo/plan/expr/CastEval.java b/tajo-plan/src/main/java/org/apache/tajo/plan/expr/CastEval.java
index b8b768b..653eeb0 100644
--- a/tajo-plan/src/main/java/org/apache/tajo/plan/expr/CastEval.java
+++ b/tajo-plan/src/main/java/org/apache/tajo/plan/expr/CastEval.java
@@ -19,12 +19,13 @@
 package org.apache.tajo.plan.expr;
 
 import com.google.gson.annotations.Expose;
-
 import org.apache.tajo.OverridableConf;
 import org.apache.tajo.SessionVars;
+import org.apache.tajo.catalog.TypeConverter;
 import org.apache.tajo.datum.Datum;
 import org.apache.tajo.datum.DatumFactory;
 import org.apache.tajo.storage.Tuple;
+import org.apache.tajo.type.Type;
 import org.apache.tajo.util.TUtil;
 
 import java.util.TimeZone;
@@ -50,8 +51,8 @@ public class CastEval extends UnaryEval implements Cloneable {
   }
 
   @Override
-  public DataType getValueType() {
-    return target;
+  public Type getValueType() {
+    return TypeConverter.convert(target);
   }
 
   public boolean hasTimeZone() {

http://git-wip-us.apache.org/repos/asf/tajo/blob/552376a8/tajo-plan/src/main/java/org/apache/tajo/plan/expr/ConstEval.java
----------------------------------------------------------------------
diff --git a/tajo-plan/src/main/java/org/apache/tajo/plan/expr/ConstEval.java b/tajo-plan/src/main/java/org/apache/tajo/plan/expr/ConstEval.java
index ff964e6..25c12d4 100644
--- a/tajo-plan/src/main/java/org/apache/tajo/plan/expr/ConstEval.java
+++ b/tajo-plan/src/main/java/org/apache/tajo/plan/expr/ConstEval.java
@@ -20,10 +20,10 @@ package org.apache.tajo.plan.expr;
 
 import com.google.common.base.Objects;
 import com.google.gson.annotations.Expose;
-import org.apache.tajo.catalog.CatalogUtil;
-import org.apache.tajo.common.TajoDataTypes.DataType;
+import org.apache.tajo.catalog.TypeConverter;
 import org.apache.tajo.datum.Datum;
 import org.apache.tajo.storage.Tuple;
+import org.apache.tajo.type.Type;
 
 public class ConstEval extends EvalNode implements Comparable<ConstEval>, Cloneable
{
 	@Expose Datum datum = null;
@@ -50,8 +50,8 @@ public class ConstEval extends EvalNode implements Comparable<ConstEval>,
Clonea
   }
 
   @Override
-	public DataType getValueType() {
-    return CatalogUtil.newSimpleDataType(datum.type());
+	public Type getValueType() {
+    return TypeConverter.convert(datum.type());
 	}
 
   @Override

http://git-wip-us.apache.org/repos/asf/tajo/blob/552376a8/tajo-plan/src/main/java/org/apache/tajo/plan/expr/EvalNode.java
----------------------------------------------------------------------
diff --git a/tajo-plan/src/main/java/org/apache/tajo/plan/expr/EvalNode.java b/tajo-plan/src/main/java/org/apache/tajo/plan/expr/EvalNode.java
index b154532..665a770 100644
--- a/tajo-plan/src/main/java/org/apache/tajo/plan/expr/EvalNode.java
+++ b/tajo-plan/src/main/java/org/apache/tajo/plan/expr/EvalNode.java
@@ -29,6 +29,7 @@ import org.apache.tajo.plan.serder.EvalNodeSerializer;
 import org.apache.tajo.plan.serder.PlanGsonHelper;
 import org.apache.tajo.plan.serder.PlanProto;
 import org.apache.tajo.storage.Tuple;
+import org.apache.tajo.type.Type;
 
 /**
  * An annotated expression which includes actual data domains.
@@ -50,7 +51,7 @@ public abstract class EvalNode implements Cloneable, GsonObject, ProtoObject<Pla
     return this.type;
   }
 
-  public abstract DataType getValueType();
+  public abstract Type getValueType();
 
   public abstract int childNum();
 

http://git-wip-us.apache.org/repos/asf/tajo/blob/552376a8/tajo-plan/src/main/java/org/apache/tajo/plan/expr/EvalTreeUtil.java
----------------------------------------------------------------------
diff --git a/tajo-plan/src/main/java/org/apache/tajo/plan/expr/EvalTreeUtil.java b/tajo-plan/src/main/java/org/apache/tajo/plan/expr/EvalTreeUtil.java
index c71dba2..bb48030 100644
--- a/tajo-plan/src/main/java/org/apache/tajo/plan/expr/EvalTreeUtil.java
+++ b/tajo-plan/src/main/java/org/apache/tajo/plan/expr/EvalTreeUtil.java
@@ -179,7 +179,7 @@ public class EvalTreeUtil {
     case DIVIDE:
     case CONST:
     case FUNCTION:
-        return expr.getValueType();
+        return TypeConverter.convert(expr.getValueType());
 
     case FIELD:
       FieldEval fieldEval = (FieldEval) expr;

http://git-wip-us.apache.org/repos/asf/tajo/blob/552376a8/tajo-plan/src/main/java/org/apache/tajo/plan/expr/FieldEval.java
----------------------------------------------------------------------
diff --git a/tajo-plan/src/main/java/org/apache/tajo/plan/expr/FieldEval.java b/tajo-plan/src/main/java/org/apache/tajo/plan/expr/FieldEval.java
index 2b301b6..60144ce 100644
--- a/tajo-plan/src/main/java/org/apache/tajo/plan/expr/FieldEval.java
+++ b/tajo-plan/src/main/java/org/apache/tajo/plan/expr/FieldEval.java
@@ -21,9 +21,11 @@ package org.apache.tajo.plan.expr;
 import com.google.gson.annotations.Expose;
 import org.apache.tajo.catalog.Column;
 import org.apache.tajo.catalog.Schema;
+import org.apache.tajo.catalog.TypeConverter;
 import org.apache.tajo.common.TajoDataTypes.DataType;
 import org.apache.tajo.datum.Datum;
 import org.apache.tajo.storage.Tuple;
+import org.apache.tajo.type.Type;
 
 public class FieldEval extends EvalNode implements Cloneable {
 	@Expose private Column column;
@@ -33,6 +35,11 @@ public class FieldEval extends EvalNode implements Cloneable {
 		super(EvalType.FIELD);
 		this.column = new Column(columnName, domain);
 	}
+
+  public FieldEval(String columnName, Type type) {
+    super(EvalType.FIELD);
+    this.column = new Column(columnName, TypeConverter.convert(type));
+  }
 	
 	public FieldEval(Column column) {
 	  super(EvalType.FIELD);
@@ -62,8 +69,8 @@ public class FieldEval extends EvalNode implements Cloneable {
   }
 
   @Override
-	public DataType getValueType() {
-		return column.getDataType();
+	public Type getValueType() {
+		return TypeConverter.convert(column.getDataType());
 	}
 
   @Override

http://git-wip-us.apache.org/repos/asf/tajo/blob/552376a8/tajo-plan/src/main/java/org/apache/tajo/plan/expr/FunctionEval.java
----------------------------------------------------------------------
diff --git a/tajo-plan/src/main/java/org/apache/tajo/plan/expr/FunctionEval.java b/tajo-plan/src/main/java/org/apache/tajo/plan/expr/FunctionEval.java
index e4bb46c..1a4ea8e 100644
--- a/tajo-plan/src/main/java/org/apache/tajo/plan/expr/FunctionEval.java
+++ b/tajo-plan/src/main/java/org/apache/tajo/plan/expr/FunctionEval.java
@@ -23,11 +23,13 @@ import com.google.common.base.Preconditions;
 import com.google.gson.annotations.Expose;
 import org.apache.tajo.catalog.FunctionDesc;
 import org.apache.tajo.catalog.Schema;
+import org.apache.tajo.catalog.TypeConverter;
 import org.apache.tajo.common.TajoDataTypes;
 import org.apache.tajo.common.TajoDataTypes.DataType;
 import org.apache.tajo.datum.Datum;
 import org.apache.tajo.storage.Tuple;
 import org.apache.tajo.storage.VTuple;
+import org.apache.tajo.type.Type;
 import org.apache.tajo.util.TUtil;
 
 import static org.apache.tajo.catalog.proto.CatalogProtos.FunctionType.DISTINCT_AGGREGATION;
@@ -71,7 +73,7 @@ public abstract class FunctionEval extends EvalNode implements Cloneable
{
     ParamType [] paramTypes = new ParamType[argEvals.length];
     for (int i = 0; i < argEvals.length; i++) {
       if (argEvals[i].getType() == EvalType.CONST) {
-        if (argEvals[i].getValueType().getType() == TajoDataTypes.Type.NULL_TYPE) {
+        if (argEvals[i].getValueType().isNull()) {
           paramTypes[i] = ParamType.NULL;
         } else {
           paramTypes[i] = ParamType.CONSTANT;
@@ -111,8 +113,8 @@ public abstract class FunctionEval extends EvalNode implements Cloneable
{
   }
 
 
-	public DataType getValueType() {
-		return this.funcDesc.getReturnType();
+	public Type getValueType() {
+		return TypeConverter.convert(this.funcDesc.getReturnType());
 	}
 
 	@Override

http://git-wip-us.apache.org/repos/asf/tajo/blob/552376a8/tajo-plan/src/main/java/org/apache/tajo/plan/expr/InEval.java
----------------------------------------------------------------------
diff --git a/tajo-plan/src/main/java/org/apache/tajo/plan/expr/InEval.java b/tajo-plan/src/main/java/org/apache/tajo/plan/expr/InEval.java
index 66bb5b0..5ee6e9e 100644
--- a/tajo-plan/src/main/java/org/apache/tajo/plan/expr/InEval.java
+++ b/tajo-plan/src/main/java/org/apache/tajo/plan/expr/InEval.java
@@ -26,14 +26,13 @@ import org.apache.tajo.datum.Datum;
 import org.apache.tajo.datum.DatumFactory;
 import org.apache.tajo.datum.NullDatum;
 import org.apache.tajo.storage.Tuple;
+import org.apache.tajo.type.Type;
 
 import java.util.Arrays;
 import java.util.HashSet;
 import java.util.Set;
 
 public class InEval extends BinaryEval {
-  private static final TajoDataTypes.DataType RES_TYPE = CatalogUtil.newSimpleDataType(TajoDataTypes.Type.BOOLEAN);
-
   @Expose private boolean not;
   Set<Datum> values;
 
@@ -47,8 +46,8 @@ public class InEval extends BinaryEval {
   }
 
   @Override
-  public TajoDataTypes.DataType getValueType() {
-    return RES_TYPE;
+  public Type getValueType() {
+    return Type.Bool;
   }
 
   @Override

http://git-wip-us.apache.org/repos/asf/tajo/blob/552376a8/tajo-plan/src/main/java/org/apache/tajo/plan/expr/IsNullEval.java
----------------------------------------------------------------------
diff --git a/tajo-plan/src/main/java/org/apache/tajo/plan/expr/IsNullEval.java b/tajo-plan/src/main/java/org/apache/tajo/plan/expr/IsNullEval.java
index 72b36eb..f337b8a 100644
--- a/tajo-plan/src/main/java/org/apache/tajo/plan/expr/IsNullEval.java
+++ b/tajo-plan/src/main/java/org/apache/tajo/plan/expr/IsNullEval.java
@@ -19,19 +19,12 @@
 package org.apache.tajo.plan.expr;
 
 import com.google.gson.annotations.Expose;
-
-import org.apache.tajo.catalog.CatalogUtil;
-import org.apache.tajo.common.TajoDataTypes;
-import org.apache.tajo.common.TajoDataTypes.DataType;
 import org.apache.tajo.datum.Datum;
 import org.apache.tajo.datum.DatumFactory;
 import org.apache.tajo.storage.Tuple;
+import org.apache.tajo.type.Type;
 
 public class IsNullEval extends UnaryEval {
-  // it's just a hack to emulate a binary expression
-  private final static ConstEval DUMMY_EVAL = new ConstEval(DatumFactory.createBool(true));
-  private static final DataType RES_TYPE = CatalogUtil.newSimpleDataType(TajoDataTypes.Type.BOOLEAN);
-
   // persistent variables
   @Expose private boolean isNot;
 
@@ -41,8 +34,8 @@ public class IsNullEval extends UnaryEval {
   }
 
   @Override
-  public DataType getValueType() {
-    return RES_TYPE;
+  public Type getValueType() {
+    return Type.Bool;
   }
 
   @Override

http://git-wip-us.apache.org/repos/asf/tajo/blob/552376a8/tajo-plan/src/main/java/org/apache/tajo/plan/expr/NotEval.java
----------------------------------------------------------------------
diff --git a/tajo-plan/src/main/java/org/apache/tajo/plan/expr/NotEval.java b/tajo-plan/src/main/java/org/apache/tajo/plan/expr/NotEval.java
index 088f3a5..f9b5393 100644
--- a/tajo-plan/src/main/java/org/apache/tajo/plan/expr/NotEval.java
+++ b/tajo-plan/src/main/java/org/apache/tajo/plan/expr/NotEval.java
@@ -18,23 +18,19 @@
 
 package org.apache.tajo.plan.expr;
 
-import org.apache.tajo.catalog.CatalogUtil;
-import org.apache.tajo.common.TajoDataTypes;
-import org.apache.tajo.common.TajoDataTypes.DataType;
 import org.apache.tajo.datum.Datum;
 import org.apache.tajo.datum.DatumFactory;
 import org.apache.tajo.storage.Tuple;
+import org.apache.tajo.type.Type;
 
 public class NotEval extends UnaryEval implements Cloneable {
-  private static final DataType RES_TYPE = CatalogUtil.newSimpleDataType(TajoDataTypes.Type.BOOLEAN);
-
   public NotEval(EvalNode child) {
     super(EvalType.NOT, child);
   }
 
   @Override
-  public DataType getValueType() {
-    return RES_TYPE;
+  public Type getValueType() {
+    return Type.Bool;
   }
 
   @Override

http://git-wip-us.apache.org/repos/asf/tajo/blob/552376a8/tajo-plan/src/main/java/org/apache/tajo/plan/expr/PartialBinaryExpr.java
----------------------------------------------------------------------
diff --git a/tajo-plan/src/main/java/org/apache/tajo/plan/expr/PartialBinaryExpr.java b/tajo-plan/src/main/java/org/apache/tajo/plan/expr/PartialBinaryExpr.java
index 1b1ee44..78b8910 100644
--- a/tajo-plan/src/main/java/org/apache/tajo/plan/expr/PartialBinaryExpr.java
+++ b/tajo-plan/src/main/java/org/apache/tajo/plan/expr/PartialBinaryExpr.java
@@ -18,10 +18,10 @@
 
 package org.apache.tajo.plan.expr;
 
-import org.apache.tajo.common.TajoDataTypes.DataType;
 import org.apache.tajo.datum.Datum;
 import org.apache.tajo.exception.InvalidOperationException;
 import org.apache.tajo.storage.Tuple;
+import org.apache.tajo.type.Type;
 
 public class PartialBinaryExpr extends BinaryEval {
   
@@ -37,7 +37,7 @@ public class PartialBinaryExpr extends BinaryEval {
   }
 
   @Override
-  public DataType getValueType() {
+  public Type getValueType() {
     return null;
   }
 

http://git-wip-us.apache.org/repos/asf/tajo/blob/552376a8/tajo-plan/src/main/java/org/apache/tajo/plan/expr/PatternMatchPredicateEval.java
----------------------------------------------------------------------
diff --git a/tajo-plan/src/main/java/org/apache/tajo/plan/expr/PatternMatchPredicateEval.java
b/tajo-plan/src/main/java/org/apache/tajo/plan/expr/PatternMatchPredicateEval.java
index ec143f7..0f595b1 100644
--- a/tajo-plan/src/main/java/org/apache/tajo/plan/expr/PatternMatchPredicateEval.java
+++ b/tajo-plan/src/main/java/org/apache/tajo/plan/expr/PatternMatchPredicateEval.java
@@ -19,21 +19,17 @@
 package org.apache.tajo.plan.expr;
 
 import com.google.gson.annotations.Expose;
-import org.apache.tajo.catalog.CatalogUtil;
 import org.apache.tajo.catalog.Schema;
-import org.apache.tajo.common.TajoDataTypes;
-import org.apache.tajo.common.TajoDataTypes.DataType;
 import org.apache.tajo.datum.Datum;
 import org.apache.tajo.datum.DatumFactory;
 import org.apache.tajo.datum.NullDatum;
 import org.apache.tajo.storage.Tuple;
+import org.apache.tajo.type.Type;
 
 import java.util.regex.Pattern;
 import java.util.regex.PatternSyntaxException;
 
 public abstract class PatternMatchPredicateEval extends BinaryEval {
-  private static final DataType RES_TYPE = CatalogUtil.newSimpleDataType(TajoDataTypes.Type.BOOLEAN);
-
   @Expose protected boolean not;
   @Expose protected String pattern;
   @Expose protected boolean caseInsensitive;
@@ -64,8 +60,8 @@ public abstract class PatternMatchPredicateEval extends BinaryEval {
   }
 
   @Override
-  public DataType getValueType() {
-    return RES_TYPE;
+  public Type getValueType() {
+    return Type.Bool;
   }
 
   @Override

http://git-wip-us.apache.org/repos/asf/tajo/blob/552376a8/tajo-plan/src/main/java/org/apache/tajo/plan/expr/RowConstantEval.java
----------------------------------------------------------------------
diff --git a/tajo-plan/src/main/java/org/apache/tajo/plan/expr/RowConstantEval.java b/tajo-plan/src/main/java/org/apache/tajo/plan/expr/RowConstantEval.java
index d2dae5a..aaaba22 100644
--- a/tajo-plan/src/main/java/org/apache/tajo/plan/expr/RowConstantEval.java
+++ b/tajo-plan/src/main/java/org/apache/tajo/plan/expr/RowConstantEval.java
@@ -19,17 +19,16 @@
 package org.apache.tajo.plan.expr;
 
 import com.google.gson.annotations.Expose;
-import org.apache.tajo.catalog.CatalogUtil;
+import org.apache.tajo.catalog.TypeConverter;
 import org.apache.tajo.datum.Datum;
 import org.apache.tajo.datum.NullDatum;
 import org.apache.tajo.storage.Tuple;
+import org.apache.tajo.type.Type;
 import org.apache.tajo.util.StringUtils;
 import org.apache.tajo.util.TUtil;
 
 import java.util.Arrays;
 
-import static org.apache.tajo.common.TajoDataTypes.DataType;
-
 public class RowConstantEval extends ValueSetEval {
   @Expose Datum [] values;
 
@@ -39,8 +38,8 @@ public class RowConstantEval extends ValueSetEval {
   }
 
   @Override
-  public DataType getValueType() {
-    return CatalogUtil.newSimpleDataType(values[0].type());
+  public Type getValueType() {
+    return TypeConverter.convert(values[0].type());
   }
 
   @Override

http://git-wip-us.apache.org/repos/asf/tajo/blob/552376a8/tajo-plan/src/main/java/org/apache/tajo/plan/expr/SignedEval.java
----------------------------------------------------------------------
diff --git a/tajo-plan/src/main/java/org/apache/tajo/plan/expr/SignedEval.java b/tajo-plan/src/main/java/org/apache/tajo/plan/expr/SignedEval.java
index baa78a2..085d82c 100644
--- a/tajo-plan/src/main/java/org/apache/tajo/plan/expr/SignedEval.java
+++ b/tajo-plan/src/main/java/org/apache/tajo/plan/expr/SignedEval.java
@@ -20,10 +20,10 @@ package org.apache.tajo.plan.expr;
 
 import com.google.common.base.Objects;
 import com.google.gson.annotations.Expose;
-import org.apache.tajo.common.TajoDataTypes.DataType;
 import org.apache.tajo.datum.Datum;
 import org.apache.tajo.datum.NumericDatum;
 import org.apache.tajo.storage.Tuple;
+import org.apache.tajo.type.Type;
 
 public class SignedEval extends UnaryEval implements Cloneable {
   @Expose private boolean negative;
@@ -38,7 +38,7 @@ public class SignedEval extends UnaryEval implements Cloneable {
   }
 
   @Override
-  public DataType getValueType() {
+  public Type getValueType() {
     return child.getValueType();
   }
 

http://git-wip-us.apache.org/repos/asf/tajo/blob/552376a8/tajo-plan/src/main/java/org/apache/tajo/plan/expr/SubqueryEval.java
----------------------------------------------------------------------
diff --git a/tajo-plan/src/main/java/org/apache/tajo/plan/expr/SubqueryEval.java b/tajo-plan/src/main/java/org/apache/tajo/plan/expr/SubqueryEval.java
index f2af073..1cac7ff 100644
--- a/tajo-plan/src/main/java/org/apache/tajo/plan/expr/SubqueryEval.java
+++ b/tajo-plan/src/main/java/org/apache/tajo/plan/expr/SubqueryEval.java
@@ -20,12 +20,13 @@ package org.apache.tajo.plan.expr;
 
 import org.apache.tajo.annotation.Nullable;
 import org.apache.tajo.catalog.Schema;
-import org.apache.tajo.common.TajoDataTypes.DataType;
+import org.apache.tajo.catalog.TypeConverter;
 import org.apache.tajo.datum.Datum;
 import org.apache.tajo.exception.TajoRuntimeException;
 import org.apache.tajo.exception.UnsupportedException;
 import org.apache.tajo.plan.logical.TableSubQueryNode;
 import org.apache.tajo.storage.Tuple;
+import org.apache.tajo.type.Type;
 
 /**
  * SubqueryEval is a temporal eval to keep subquery information when the subquery occurs
in expressions,
@@ -44,8 +45,8 @@ public class SubqueryEval extends ValueSetEval {
   }
 
   @Override
-  public DataType getValueType() {
-    return subQueryNode.getOutSchema().getColumn(0).getDataType();
+  public Type getValueType() {
+    return TypeConverter.convert(subQueryNode.getOutSchema().getColumn(0).getDataType());
   }
 
   @Override

http://git-wip-us.apache.org/repos/asf/tajo/blob/552376a8/tajo-plan/src/main/java/org/apache/tajo/plan/expr/UnaryEval.java
----------------------------------------------------------------------
diff --git a/tajo-plan/src/main/java/org/apache/tajo/plan/expr/UnaryEval.java b/tajo-plan/src/main/java/org/apache/tajo/plan/expr/UnaryEval.java
index 4db2b90..5c7ee6e 100644
--- a/tajo-plan/src/main/java/org/apache/tajo/plan/expr/UnaryEval.java
+++ b/tajo-plan/src/main/java/org/apache/tajo/plan/expr/UnaryEval.java
@@ -21,9 +21,9 @@ package org.apache.tajo.plan.expr;
 import com.google.common.base.Objects;
 import com.google.common.base.Preconditions;
 import com.google.gson.annotations.Expose;
-import org.apache.tajo.common.TajoDataTypes;
 import org.apache.tajo.datum.Datum;
 import org.apache.tajo.storage.Tuple;
+import org.apache.tajo.type.Type;
 
 public abstract class UnaryEval extends EvalNode implements Cloneable {
   @Expose protected EvalNode child;
@@ -56,7 +56,7 @@ public abstract class UnaryEval extends EvalNode implements Cloneable {
   }
 
   @Override
-  public TajoDataTypes.DataType getValueType() {
+  public Type getValueType() {
     return null;
   }
 

http://git-wip-us.apache.org/repos/asf/tajo/blob/552376a8/tajo-plan/src/main/java/org/apache/tajo/plan/expr/WindowFunctionEval.java
----------------------------------------------------------------------
diff --git a/tajo-plan/src/main/java/org/apache/tajo/plan/expr/WindowFunctionEval.java b/tajo-plan/src/main/java/org/apache/tajo/plan/expr/WindowFunctionEval.java
index e5b88f2..6c70395 100644
--- a/tajo-plan/src/main/java/org/apache/tajo/plan/expr/WindowFunctionEval.java
+++ b/tajo-plan/src/main/java/org/apache/tajo/plan/expr/WindowFunctionEval.java
@@ -21,11 +21,13 @@ package org.apache.tajo.plan.expr;
 import com.google.gson.annotations.Expose;
 import org.apache.tajo.catalog.FunctionDesc;
 import org.apache.tajo.catalog.SortSpec;
+import org.apache.tajo.catalog.TypeConverter;
 import org.apache.tajo.common.TajoDataTypes.DataType;
 import org.apache.tajo.datum.Datum;
 import org.apache.tajo.plan.function.FunctionContext;
 import org.apache.tajo.plan.logical.WindowSpec;
 import org.apache.tajo.storage.Tuple;
+import org.apache.tajo.type.Type;
 import org.apache.tajo.util.StringUtils;
 import org.apache.tajo.util.TUtil;
 
@@ -71,8 +73,8 @@ public class WindowFunctionEval extends AggregationFunctionCallEval implements
C
   }
 
   @Override
-  public DataType getValueType() {
-    return funcDesc.getReturnType();
+  public Type getValueType() {
+    return TypeConverter.convert(funcDesc.getReturnType());
   }
 
   @Override

http://git-wip-us.apache.org/repos/asf/tajo/blob/552376a8/tajo-plan/src/main/java/org/apache/tajo/plan/serder/EvalNodeSerializer.java
----------------------------------------------------------------------
diff --git a/tajo-plan/src/main/java/org/apache/tajo/plan/serder/EvalNodeSerializer.java b/tajo-plan/src/main/java/org/apache/tajo/plan/serder/EvalNodeSerializer.java
index f37ce69..759867f 100644
--- a/tajo-plan/src/main/java/org/apache/tajo/plan/serder/EvalNodeSerializer.java
+++ b/tajo-plan/src/main/java/org/apache/tajo/plan/serder/EvalNodeSerializer.java
@@ -23,6 +23,7 @@ import com.google.common.collect.Maps;
 import com.google.protobuf.ByteString;
 import org.apache.tajo.algebra.WindowSpec.WindowFrameEndBoundType;
 import org.apache.tajo.algebra.WindowSpec.WindowFrameStartBoundType;
+import org.apache.tajo.catalog.TypeConverter;
 import org.apache.tajo.catalog.proto.CatalogProtos;
 import org.apache.tajo.datum.AnyDatum;
 import org.apache.tajo.datum.Datum;
@@ -96,7 +97,7 @@ public class EvalNodeSerializer
 
     PlanProto.EvalNode.Builder nodeBuilder = PlanProto.EvalNode.newBuilder();
     nodeBuilder.setId(sid);
-    nodeBuilder.setDataType(node.getValueType());
+    nodeBuilder.setDataType(TypeConverter.convert(node.getValueType()));
     nodeBuilder.setType(PlanProto.EvalType.valueOf(node.getType().name()));
     return nodeBuilder;
   }
@@ -118,7 +119,7 @@ public class EvalNodeSerializer
       unaryBuilder.setNegative(signedEval.isNegative());
     } else if (unary.getType() == EvalType.CAST) {
       CastEval castEval = (CastEval) unary;
-      unaryBuilder.setCastingType(castEval.getValueType());
+      unaryBuilder.setCastingType(TypeConverter.convert(castEval.getValueType()));
       if (castEval.hasTimeZone()) {
         unaryBuilder.setTimezone(castEval.getTimezone().getID());
       }

http://git-wip-us.apache.org/repos/asf/tajo/blob/552376a8/tajo-plan/src/main/java/org/apache/tajo/plan/util/EvalNodeToExprConverter.java
----------------------------------------------------------------------
diff --git a/tajo-plan/src/main/java/org/apache/tajo/plan/util/EvalNodeToExprConverter.java
b/tajo-plan/src/main/java/org/apache/tajo/plan/util/EvalNodeToExprConverter.java
index 00638c2..86f8286 100644
--- a/tajo-plan/src/main/java/org/apache/tajo/plan/util/EvalNodeToExprConverter.java
+++ b/tajo-plan/src/main/java/org/apache/tajo/plan/util/EvalNodeToExprConverter.java
@@ -145,7 +145,7 @@ public class EvalNodeToExprConverter extends SimpleEvalNodeVisitor<Object>
{
 
   @Override
   protected EvalNode visitConst(Object o, ConstEval evalNode, Stack<EvalNode> stack)
{
-    exprs.push(convertDatumToExpr(evalNode.getValueType().getType(), evalNode.getValue()));
+    exprs.push(convertDatumToExpr(evalNode.getValueType().baseType(), evalNode.getValue()));
     return super.visitConst(o, evalNode, stack);
   }
 

http://git-wip-us.apache.org/repos/asf/tajo/blob/552376a8/tajo-plan/src/main/java/org/apache/tajo/plan/util/PlannerUtil.java
----------------------------------------------------------------------
diff --git a/tajo-plan/src/main/java/org/apache/tajo/plan/util/PlannerUtil.java b/tajo-plan/src/main/java/org/apache/tajo/plan/util/PlannerUtil.java
index ff3e3c8..7dc5ae3 100644
--- a/tajo-plan/src/main/java/org/apache/tajo/plan/util/PlannerUtil.java
+++ b/tajo-plan/src/main/java/org/apache/tajo/plan/util/PlannerUtil.java
@@ -25,8 +25,6 @@ import com.google.common.collect.Sets;
 import org.apache.tajo.algebra.*;
 import org.apache.tajo.annotation.Nullable;
 import org.apache.tajo.catalog.*;
-import org.apache.tajo.common.TajoDataTypes;
-import org.apache.tajo.common.TajoDataTypes.DataType;
 import org.apache.tajo.exception.*;
 import org.apache.tajo.plan.LogicalPlan;
 import org.apache.tajo.plan.Target;
@@ -36,6 +34,7 @@ import org.apache.tajo.plan.serder.PlanProto.ShuffleType;
 import org.apache.tajo.plan.visitor.BasicLogicalPlanVisitor;
 import org.apache.tajo.plan.visitor.ExplainLogicalPlanVisitor;
 import org.apache.tajo.plan.visitor.SimpleAlgebraVisitor;
+import org.apache.tajo.type.Type;
 import org.apache.tajo.util.KeyValueSet;
 import org.apache.tajo.util.StringUtils;
 
@@ -658,10 +657,10 @@ public class PlannerUtil {
   public static Schema targetToSchema(List<Target> targets) {
     SchemaBuilder schema = SchemaBuilder.uniqueNameBuilder();
     for (Target t : targets) {
-      DataType type = t.getEvalTree().getValueType();
+      Type type = t.getEvalTree().getValueType();
 
       // hack to avoid projecting record type.
-      if (type.getType() == TajoDataTypes.Type.RECORD) {
+      if (type.isStruct()) {
         throw new TajoRuntimeException(new NotImplementedException("record projection"));
       }
 
@@ -672,7 +671,7 @@ public class PlannerUtil {
         name = t.getEvalTree().getName();
       }
 
-      schema.add(name, type);
+      schema.add(name, TypeConverter.convert(type));
     }
 
     return schema.build();

http://git-wip-us.apache.org/repos/asf/tajo/blob/552376a8/tajo-plan/src/main/java/org/apache/tajo/plan/verifier/ExprsVerifier.java
----------------------------------------------------------------------
diff --git a/tajo-plan/src/main/java/org/apache/tajo/plan/verifier/ExprsVerifier.java b/tajo-plan/src/main/java/org/apache/tajo/plan/verifier/ExprsVerifier.java
index a9737e0..2040ae3 100644
--- a/tajo-plan/src/main/java/org/apache/tajo/plan/verifier/ExprsVerifier.java
+++ b/tajo-plan/src/main/java/org/apache/tajo/plan/verifier/ExprsVerifier.java
@@ -19,6 +19,7 @@
 package org.apache.tajo.plan.verifier;
 
 import org.apache.tajo.catalog.Column;
+import org.apache.tajo.common.TajoDataTypes;
 import org.apache.tajo.error.Errors;
 import org.apache.tajo.exception.TajoException;
 import org.apache.tajo.exception.TajoInternalError;
@@ -29,8 +30,7 @@ import org.apache.tajo.plan.logical.LogicalNode;
 import java.util.Set;
 import java.util.Stack;
 
-import static org.apache.tajo.common.TajoDataTypes.DataType;
-import static org.apache.tajo.common.TajoDataTypes.Type;
+import static org.apache.tajo.common.TajoDataTypes.Type.*;
 
 /**
  * It verifies one predicate or expression with the semantic and data type checks as follows:
@@ -61,7 +61,7 @@ public class ExprsVerifier extends BasicEvalNodeVisitor<VerificationState,
EvalN
   /**
    * It checks the compatibility of two data types.
    */
-  private static boolean isCompatibleType(DataType dataType1, DataType dataType2) {
+  private static boolean isCompatibleType(org.apache.tajo.type.Type dataType1, org.apache.tajo.type.Type
dataType2) {
     if (checkNumericType(dataType1) && checkNumericType(dataType2)) {
       return true;
     }
@@ -85,9 +85,7 @@ public class ExprsVerifier extends BasicEvalNodeVisitor<VerificationState,
EvalN
    * It checks both expressions in a comparison operator are compatible to each other.
    */
   private static void verifyComparisonOperator(VerificationState state, BinaryEval expr)
{
-    DataType leftType = expr.getLeftExpr().getValueType();
-    DataType rightType = expr.getRightExpr().getValueType();
-    if (!isCompatibleType(leftType, rightType)) {
+    if (!isCompatibleType(expr.getLeftExpr().getValueType(), expr.getRightExpr().getValueType()))
{
       state.addVerification(new UndefinedOperatorException(expr.toString()));
     }
   }
@@ -145,32 +143,32 @@ public class ExprsVerifier extends BasicEvalNodeVisitor<VerificationState,
EvalN
     EvalNode leftExpr = evalNode.getLeftExpr();
     EvalNode rightExpr = evalNode.getRightExpr();
 
-    DataType leftDataType = leftExpr.getValueType();
-    DataType rightDataType = rightExpr.getValueType();
+    org.apache.tajo.type.Type leftDataType = leftExpr.getValueType();
+    org.apache.tajo.type.Type rightDataType = rightExpr.getValueType();
 
-    Type leftType = leftDataType.getType();
-    Type rightType = rightDataType.getType();
+    TajoDataTypes.Type leftType = leftDataType.baseType();
+    TajoDataTypes.Type rightType = rightDataType.baseType();
 
-    if (leftType == Type.DATE &&
+    if (leftType == DATE &&
           (checkIntType(rightDataType) ||
-              rightType == Type.DATE || rightType == Type.INTERVAL || rightType == Type.TIME))
{
+              rightType == DATE || rightType == INTERVAL || rightType == TIME)) {
       return;
     }
 
-    if (leftType == Type.INTERVAL &&
+    if (leftType == INTERVAL &&
         (checkNumericType(rightDataType) ||
-            rightType == Type.DATE || rightType == Type.INTERVAL || rightType == Type.TIME
||
-            rightType == Type.TIMESTAMP)) {
+            rightType == DATE || rightType == INTERVAL || rightType == TIME ||
+            rightType == TIMESTAMP)) {
       return;
     }
 
-    if (leftType == Type.TIME &&
-        (rightType == Type.DATE || rightType == Type.INTERVAL || rightType == Type.TIME))
{
+    if (leftType == TIME &&
+        (rightType == DATE || rightType == INTERVAL || rightType == TIME)) {
       return;
     }
 
-    if (leftType == Type.TIMESTAMP &&
-        (rightType == Type.TIMESTAMP || rightType == Type.INTERVAL || rightType == Type.TIME))
{
+    if (leftType == TIMESTAMP &&
+        (rightType == TIMESTAMP || rightType == INTERVAL || rightType == TajoDataTypes.Type.TIME))
{
       return;
     }
 
@@ -179,29 +177,29 @@ public class ExprsVerifier extends BasicEvalNodeVisitor<VerificationState,
EvalN
     }
   }
 
-  private static boolean checkNetworkType(DataType dataType) {
-    return dataType.getType() == Type.INET4 || dataType.getType() == Type.INET6;
+  private static boolean checkNetworkType(org.apache.tajo.type.Type dataType) {
+    return dataType.baseType() == INET4 || dataType.baseType() == INET6;
   }
 
-  private static boolean checkIntType(DataType dataType) {
-    int typeNumber = dataType.getType().getNumber();
-    return Type.INT1.getNumber() < typeNumber && typeNumber <= Type.INT8.getNumber();
+  private static boolean checkIntType(org.apache.tajo.type.Type dataType) {
+    int typeNumber = dataType.baseType().getNumber();
+    return INT1.getNumber() < typeNumber && typeNumber <= INT8.getNumber();
   }
 
-  private static boolean checkNumericType(DataType dataType) {
-    int typeNumber = dataType.getType().getNumber();
-    return Type.INT1.getNumber() <= typeNumber && typeNumber <= Type.NUMERIC.getNumber();
+  private static boolean checkNumericType(org.apache.tajo.type.Type dataType) {
+    int typeNumber = dataType.baseType().getNumber();
+    return INT1.getNumber() <= typeNumber && typeNumber <= NUMERIC.getNumber();
   }
 
-  private static boolean checkTextData(DataType dataType) {
-    int typeNumber = dataType.getType().getNumber();
-    return Type.CHAR.getNumber() <= typeNumber && typeNumber <= Type.TEXT.getNumber();
+  private static boolean checkTextData(org.apache.tajo.type.Type dataType) {
+    int typeNumber = dataType.baseType().getNumber();
+    return CHAR.getNumber() <= typeNumber && typeNumber <= TEXT.getNumber();
   }
 
-  private static boolean checkDateTime(DataType dataType) {
-    int typeNumber = dataType.getType().getNumber();
-    return (Type.DATE.getNumber() <= typeNumber && typeNumber <= Type.INTERVAL.getNumber())
||
-        (Type.TIMEZ.getNumber() <= typeNumber && typeNumber <= Type.TIMESTAMPZ.getNumber());
+  private static boolean checkDateTime(org.apache.tajo.type.Type dataType) {
+    int typeNumber = dataType.baseType().getNumber();
+    return (DATE.getNumber() <= typeNumber && typeNumber <= INTERVAL.getNumber())
||
+        (TIMEZ.getNumber() <= typeNumber && typeNumber <= TIMESTAMPZ.getNumber());
   }
 
   @Override

http://git-wip-us.apache.org/repos/asf/tajo/blob/552376a8/tajo-storage/tajo-storage-jdbc/src/main/java/org/apache/tajo/storage/jdbc/SQLExpressionGenerator.java
----------------------------------------------------------------------
diff --git a/tajo-storage/tajo-storage-jdbc/src/main/java/org/apache/tajo/storage/jdbc/SQLExpressionGenerator.java
b/tajo-storage/tajo-storage-jdbc/src/main/java/org/apache/tajo/storage/jdbc/SQLExpressionGenerator.java
index a265efe..0b1df31 100644
--- a/tajo-storage/tajo-storage-jdbc/src/main/java/org/apache/tajo/storage/jdbc/SQLExpressionGenerator.java
+++ b/tajo-storage/tajo-storage-jdbc/src/main/java/org/apache/tajo/storage/jdbc/SQLExpressionGenerator.java
@@ -26,6 +26,7 @@ import org.apache.tajo.exception.NotImplementedException;
 import org.apache.tajo.exception.TajoRuntimeException;
 import org.apache.tajo.exception.UnsupportedDataTypeException;
 import org.apache.tajo.plan.expr.*;
+import org.apache.tajo.type.Type;
 import org.apache.tajo.util.StringUtils;
 
 import java.sql.DatabaseMetaData;
@@ -270,8 +271,8 @@ public class SQLExpressionGenerator extends SimpleEvalNodeVisitor<SQLExpressionG
    * @param dataType Tajo DataType
    * @return SQL DataType
    */
-  public String convertTajoTypeToSQLType(DataType dataType) {
-    switch (dataType.getType()) {
+  public String convertTajoTypeToSQLType(Type dataType) {
+    switch (dataType.baseType()) {
     case INT1:
       return "TINYINT";
     case INT2:
@@ -285,7 +286,7 @@ public class SQLExpressionGenerator extends SimpleEvalNodeVisitor<SQLExpressionG
     case FLOAT8:
       return "DOUBLE";
     default:
-      return dataType.getType().name();
+      return dataType.baseType().name();
     }
   }
 


Mime
View raw message