tajo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hyun...@apache.org
Subject [1/7] tajo git commit: TAJO-2129: Apply new type implementation to Schema and Catalog.
Date Fri, 13 May 2016 05:32:41 GMT
Repository: tajo
Updated Branches:
  refs/heads/master 01d2fe2a5 -> 8d2bf407f


http://git-wip-us.apache.org/repos/asf/tajo/blob/8d2bf407/tajo-plan/src/main/java/org/apache/tajo/plan/logical/ScanNode.java
----------------------------------------------------------------------
diff --git a/tajo-plan/src/main/java/org/apache/tajo/plan/logical/ScanNode.java b/tajo-plan/src/main/java/org/apache/tajo/plan/logical/ScanNode.java
index 0729d6e..f482e30 100644
--- a/tajo-plan/src/main/java/org/apache/tajo/plan/logical/ScanNode.java
+++ b/tajo-plan/src/main/java/org/apache/tajo/plan/logical/ScanNode.java
@@ -27,6 +27,7 @@ import org.apache.tajo.plan.PlanString;
 import org.apache.tajo.plan.Target;
 import org.apache.tajo.plan.expr.EvalNode;
 import org.apache.tajo.plan.util.PlannerUtil;
+import org.apache.tajo.schema.IdentifierUtil;
 import org.apache.tajo.util.TUtil;
 
 import java.util.ArrayList;
@@ -72,13 +73,13 @@ public class ScanNode extends RelationNode implements Projectable, SelectableNod
     this.tableDesc = desc;
     this.alias = alias;
 
-    if (!CatalogUtil.isFQTableName(this.tableDesc.getName())) {
+    if (!IdentifierUtil.isFQTableName(this.tableDesc.getName())) {
       throw new IllegalArgumentException("the name in TableDesc must be qualified, but it
is \"" +
           desc.getName() + "\"");
     }
 
-    String databaseName = CatalogUtil.extractQualifier(this.tableDesc.getName());
-    String qualifiedAlias = CatalogUtil.buildFQName(databaseName, alias);
+    String databaseName = IdentifierUtil.extractQualifier(this.tableDesc.getName());
+    String qualifiedAlias = IdentifierUtil.buildFQName(databaseName, alias);
     this.setInSchema(tableDesc.getSchema());
     this.getInSchema().setQualifier(qualifiedAlias);
     this.setOutSchema(SchemaBuilder.builder().addAll(getInSchema().getRootColumns()).build());
@@ -108,9 +109,9 @@ public class ScanNode extends RelationNode implements Projectable, SelectableNod
   }
 
   public String getCanonicalName() {
-    if (CatalogUtil.isFQTableName(this.tableDesc.getName())) {
-      String databaseName = CatalogUtil.extractQualifier(this.tableDesc.getName());
-      return hasAlias() ? CatalogUtil.buildFQName(databaseName, alias) : tableDesc.getName();
+    if (IdentifierUtil.isFQTableName(this.tableDesc.getName())) {
+      String databaseName = IdentifierUtil.extractQualifier(this.tableDesc.getName());
+      return hasAlias() ? IdentifierUtil.buildFQName(databaseName, alias) : tableDesc.getName();
     } else {
       return hasAlias() ? alias : tableDesc.getName();
     }

http://git-wip-us.apache.org/repos/asf/tajo/blob/8d2bf407/tajo-plan/src/main/java/org/apache/tajo/plan/nameresolver/NameResolver.java
----------------------------------------------------------------------
diff --git a/tajo-plan/src/main/java/org/apache/tajo/plan/nameresolver/NameResolver.java b/tajo-plan/src/main/java/org/apache/tajo/plan/nameresolver/NameResolver.java
index cbe93d2..95f8f98 100644
--- a/tajo-plan/src/main/java/org/apache/tajo/plan/nameresolver/NameResolver.java
+++ b/tajo-plan/src/main/java/org/apache/tajo/plan/nameresolver/NameResolver.java
@@ -22,7 +22,6 @@ import com.google.common.base.Preconditions;
 import com.google.common.collect.Lists;
 import com.google.common.collect.Maps;
 import org.apache.tajo.algebra.ColumnReferenceExpr;
-import org.apache.tajo.catalog.CatalogUtil;
 import org.apache.tajo.catalog.Column;
 import org.apache.tajo.catalog.NestedPathUtil;
 import org.apache.tajo.catalog.Schema;
@@ -31,6 +30,7 @@ import org.apache.tajo.exception.*;
 import org.apache.tajo.plan.LogicalPlan;
 import org.apache.tajo.plan.logical.RelationNode;
 import org.apache.tajo.plan.logical.ScanNode;
+import org.apache.tajo.schema.IdentifierUtil;
 import org.apache.tajo.util.Pair;
 import org.apache.tajo.util.StringUtils;
 
@@ -100,8 +100,8 @@ public abstract class NameResolver {
         found.add(relation);
 
       // if a table name is not qualified
-      } else if (CatalogUtil.extractSimpleName(relation.getCanonicalName()).equals(tableName)
||
-          CatalogUtil.extractSimpleName(relation.getTableName()).equals(tableName)) {
+      } else if (IdentifierUtil.extractSimpleName(relation.getCanonicalName()).equals(tableName)
||
+          IdentifierUtil.extractSimpleName(relation.getTableName()).equals(tableName)) {
         found.add(relation);
       }
     }
@@ -184,7 +184,7 @@ public abstract class NameResolver {
 
       Column column;
       if (includeSeflDescTable && describeSchemaByItself(relationOp)) {
-        column = guessColumn(CatalogUtil.buildFQName(normalized.getFirst(), normalized.getSecond()));
+        column = guessColumn(IdentifierUtil.buildFQName(normalized.getFirst(), normalized.getSecond()));
 
       } else {
         // Please consider a query case:
@@ -192,9 +192,9 @@ public abstract class NameResolver {
         //
         // The relation lineitem is already renamed to "a", but lineitem.l_orderkey still
should be available.
         // The below code makes it possible. Otherwise, it cannot find any match in the relation
schema.
-        if (block.isAlreadyRenamedTableName(CatalogUtil.extractQualifier(canonicalName)))
{
+        if (block.isAlreadyRenamedTableName(IdentifierUtil.extractQualifier(canonicalName)))
{
           canonicalName =
-              CatalogUtil.buildFQName(relationOp.getCanonicalName(), CatalogUtil.extractSimpleName(canonicalName));
+              IdentifierUtil.buildFQName(relationOp.getCanonicalName(), IdentifierUtil.extractSimpleName(canonicalName));
         }
 
         Schema schema = relationOp.getLogicalSchema();
@@ -242,7 +242,7 @@ public abstract class NameResolver {
    */
   static Column lookupColumnFromAllRelsInBlock(LogicalPlan.QueryBlock block,
                                                String columnName, boolean includeSelfDescTable)
throws AmbiguousColumnException {
-    Preconditions.checkArgument(CatalogUtil.isSimpleIdentifier(columnName));
+    Preconditions.checkArgument(IdentifierUtil.isSimpleIdentifier(columnName));
 
     List<Column> candidates = new ArrayList<>();
 
@@ -266,7 +266,7 @@ public abstract class NameResolver {
           }
         }
         if (candidateRels.size() == 1) {
-          return guessColumn(CatalogUtil.buildFQName(candidateRels.get(0).getCanonicalName(),
columnName));
+          return guessColumn(IdentifierUtil.buildFQName(candidateRels.get(0).getCanonicalName(),
columnName));
         } else if (candidateRels.size() > 1) {
           throw new AmbiguousColumnException(columnName);
         }
@@ -377,7 +377,7 @@ public abstract class NameResolver {
 
     // check for dbname.tbname.column_name.nested_field
     if (qualifierParts.length >= 2) {
-      RelationNode rel = lookupTable(block, CatalogUtil.buildFQName(qualifierParts[0], qualifierParts[1]));
+      RelationNode rel = lookupTable(block, IdentifierUtil.buildFQName(qualifierParts[0],
qualifierParts[1]));
       if (rel != null) {
         guessedRelations.add(rel);
         columnNamePosition = 2;

http://git-wip-us.apache.org/repos/asf/tajo/blob/8d2bf407/tajo-plan/src/main/java/org/apache/tajo/plan/nameresolver/ResolverByLegacy.java
----------------------------------------------------------------------
diff --git a/tajo-plan/src/main/java/org/apache/tajo/plan/nameresolver/ResolverByLegacy.java
b/tajo-plan/src/main/java/org/apache/tajo/plan/nameresolver/ResolverByLegacy.java
index 343b9ab..8cfb1eb 100644
--- a/tajo-plan/src/main/java/org/apache/tajo/plan/nameresolver/ResolverByLegacy.java
+++ b/tajo-plan/src/main/java/org/apache/tajo/plan/nameresolver/ResolverByLegacy.java
@@ -19,7 +19,6 @@
 package org.apache.tajo.plan.nameresolver;
 
 import org.apache.tajo.algebra.ColumnReferenceExpr;
-import org.apache.tajo.catalog.CatalogUtil;
 import org.apache.tajo.catalog.Column;
 import org.apache.tajo.catalog.Schema;
 import org.apache.tajo.exception.AmbiguousColumnException;
@@ -29,6 +28,7 @@ import org.apache.tajo.plan.LogicalPlan;
 import org.apache.tajo.plan.logical.LogicalNode;
 import org.apache.tajo.plan.logical.NodeType;
 import org.apache.tajo.plan.logical.RelationNode;
+import org.apache.tajo.schema.IdentifierUtil;
 import org.apache.tajo.util.Pair;
 
 import java.util.ArrayList;
@@ -57,7 +57,7 @@ public class ResolverByLegacy extends NameResolver {
 
     Pair<String, String> normalized = lookupQualifierAndCanonicalName(block, columnRef,
includeSeflDescTable);
     qualifier = normalized.getFirst();
-    qualifiedName = CatalogUtil.buildFQName(qualifier, columnRef.getName());
+    qualifiedName = IdentifierUtil.buildFQName(qualifier, columnRef.getName());
 
     Column found = resolveFromRelsWithinBlock(plan, block, columnRef, includeSeflDescTable);
     if (found == null) {

http://git-wip-us.apache.org/repos/asf/tajo/blob/8d2bf407/tajo-plan/src/main/java/org/apache/tajo/plan/rewrite/BaseSchemaBuildPhase.java
----------------------------------------------------------------------
diff --git a/tajo-plan/src/main/java/org/apache/tajo/plan/rewrite/BaseSchemaBuildPhase.java
b/tajo-plan/src/main/java/org/apache/tajo/plan/rewrite/BaseSchemaBuildPhase.java
index 99921c3..14fb3ef 100644
--- a/tajo-plan/src/main/java/org/apache/tajo/plan/rewrite/BaseSchemaBuildPhase.java
+++ b/tajo-plan/src/main/java/org/apache/tajo/plan/rewrite/BaseSchemaBuildPhase.java
@@ -22,6 +22,7 @@ import org.apache.tajo.SessionVars;
 import org.apache.tajo.algebra.*;
 import org.apache.tajo.catalog.*;
 import org.apache.tajo.common.TajoDataTypes;
+import org.apache.tajo.exception.NotImplementedException;
 import org.apache.tajo.exception.TajoException;
 import org.apache.tajo.exception.UndefinedColumnException;
 import org.apache.tajo.plan.*;
@@ -36,9 +37,12 @@ import org.apache.tajo.plan.nameresolver.NameResolver;
 import org.apache.tajo.plan.nameresolver.NameResolvingMode;
 import org.apache.tajo.plan.util.PlannerUtil;
 import org.apache.tajo.plan.visitor.SimpleAlgebraVisitor;
+import org.apache.tajo.schema.IdentifierUtil;
 
 import java.util.*;
 
+import static org.apache.tajo.common.TajoDataTypes.Type.RECORD;
+
 /**
  * BaseSchemaBuildPhase builds a basic schema information of tables which have pre-defined
schema.
  * For example, tables like the below example have pre-defined schema.
@@ -117,10 +121,10 @@ public class BaseSchemaBuildPhase extends LogicalPlanPreprocessPhase
{
       if (asteriskExpr.hasQualifier()) {
         String qualifier;
 
-        if (CatalogUtil.isFQTableName(asteriskExpr.getQualifier())) {
+        if (IdentifierUtil.isFQTableName(asteriskExpr.getQualifier())) {
           qualifier = asteriskExpr.getQualifier();
         } else {
-          qualifier = CatalogUtil.buildFQName(
+          qualifier = IdentifierUtil.buildFQName(
               ctx.getQueryContext().get(SessionVars.CURRENT_DATABASE), asteriskExpr.getQualifier());
         }
 
@@ -138,7 +142,7 @@ public class BaseSchemaBuildPhase extends LogicalPlanPreprocessPhase {
 
         // If we cannot find any relation against a qualified column name
         if (relationOp == null) {
-          throw new UndefinedColumnException(CatalogUtil.buildFQName(qualifier, "*"));
+          throw new UndefinedColumnException(IdentifierUtil.buildFQName(qualifier, "*"));
         }
 
         Schema schema = relationOp.getLogicalSchema();
@@ -258,6 +262,10 @@ public class BaseSchemaBuildPhase extends LogicalPlanPreprocessPhase
{
       for (NamedExpr namedExpr : exprs) {
         TajoDataTypes.DataType dataType = typeDeterminant.determineDataType(context, namedExpr.getExpr());
 
+        if (dataType.getType() == RECORD) {
+          throw new NotImplementedException("record projection");
+        }
+
         if (namedExpr.hasAlias()) {
           targets.add(new Target(new FieldEval(new Column(namedExpr.getAlias(), dataType))));
         } else {
@@ -403,11 +411,11 @@ public class BaseSchemaBuildPhase extends LogicalPlanPreprocessPhase
{
         throws TajoException {
 
       String actualRelationName;
-      if (CatalogUtil.isFQTableName(relation.getName())) {
+      if (IdentifierUtil.isFQTableName(relation.getName())) {
         actualRelationName = relation.getName();
       } else {
         actualRelationName =
-            CatalogUtil.buildFQName(ctx.getQueryContext().get(SessionVars.CURRENT_DATABASE),
relation.getName());
+            IdentifierUtil.buildFQName(ctx.getQueryContext().get(SessionVars.CURRENT_DATABASE),
relation.getName());
       }
 
       TableDesc desc = catalog.getTableDesc(actualRelationName);
@@ -439,7 +447,7 @@ public class BaseSchemaBuildPhase extends LogicalPlanPreprocessPhase {
 
       // a table subquery should be dealt as a relation.
       TableSubQueryNode node = ctx.getPlan().createNode(TableSubQueryNode.class);
-      node.init(CatalogUtil.buildFQName(ctx.getQueryContext().get(SessionVars.CURRENT_DATABASE),
expr.getName()), child);
+      node.init(IdentifierUtil.buildFQName(ctx.getQueryContext().get(SessionVars.CURRENT_DATABASE),
expr.getName()), child);
       ctx.getQueryBlock().addRelation(node);
 
       return node;
@@ -458,7 +466,7 @@ public class BaseSchemaBuildPhase extends LogicalPlanPreprocessPhase {
 
       // a table subquery should be dealt as a relation.
       TableSubQueryNode node = ctx.getPlan().createNode(TableSubQueryNode.class);
-      node.init(CatalogUtil.buildFQName(ctx.getQueryContext().get(SessionVars.CURRENT_DATABASE),
+      node.init(IdentifierUtil.buildFQName(ctx.getQueryContext().get(SessionVars.CURRENT_DATABASE),
           ctx.generateUniqueSubQueryName()), child);
       ctx.getQueryBlock().addRelation(node);
       if (stack.peek().getType() == OpType.InPredicate) {

http://git-wip-us.apache.org/repos/asf/tajo/blob/8d2bf407/tajo-plan/src/main/java/org/apache/tajo/plan/rewrite/SelfDescSchemaBuildPhase.java
----------------------------------------------------------------------
diff --git a/tajo-plan/src/main/java/org/apache/tajo/plan/rewrite/SelfDescSchemaBuildPhase.java
b/tajo-plan/src/main/java/org/apache/tajo/plan/rewrite/SelfDescSchemaBuildPhase.java
index 60187d9..a49c423 100644
--- a/tajo-plan/src/main/java/org/apache/tajo/plan/rewrite/SelfDescSchemaBuildPhase.java
+++ b/tajo-plan/src/main/java/org/apache/tajo/plan/rewrite/SelfDescSchemaBuildPhase.java
@@ -39,6 +39,7 @@ import org.apache.tajo.plan.rewrite.BaseSchemaBuildPhase.Processor.NameRefInSele
 import org.apache.tajo.plan.util.ExprFinder;
 import org.apache.tajo.plan.util.PlannerUtil;
 import org.apache.tajo.plan.visitor.SimpleAlgebraVisitor;
+import org.apache.tajo.schema.IdentifierUtil;
 import org.apache.tajo.util.StringUtils;
 import org.apache.tajo.util.TUtil;
 import org.apache.tajo.util.graph.DirectedGraphVisitor;
@@ -65,9 +66,9 @@ public class SelfDescSchemaBuildPhase extends LogicalPlanPreprocessPhase
{
   }
 
   private static String getQualifiedName(PlanContext context, String simpleName) {
-    return CatalogUtil.isFQTableName(simpleName) ?
+    return IdentifierUtil.isFQTableName(simpleName) ?
         simpleName :
-        CatalogUtil.buildFQName(context.getQueryContext().get(SessionVars.CURRENT_DATABASE),
simpleName);
+        IdentifierUtil.buildFQName(context.getQueryContext().get(SessionVars.CURRENT_DATABASE),
simpleName);
   }
 
   @Override
@@ -421,7 +422,7 @@ public class SelfDescSchemaBuildPhase extends LogicalPlanPreprocessPhase
{
           for (int i = 0; i < paths.length-1; i++) {
             String parentName = paths[i];
             if (i == 0) {
-              parentName = CatalogUtil.buildFQName(eachColumn.getQualifier(), parentName);
+              parentName = IdentifierUtil.buildFQName(eachColumn.getQualifier(), parentName);
             }
             // Leaf column type is TEXT; otherwise, RECORD.
             ColumnVertex childVertex = new ColumnVertex(

http://git-wip-us.apache.org/repos/asf/tajo/blob/8d2bf407/tajo-plan/src/main/java/org/apache/tajo/plan/rewrite/rules/FilterPushDownRule.java
----------------------------------------------------------------------
diff --git a/tajo-plan/src/main/java/org/apache/tajo/plan/rewrite/rules/FilterPushDownRule.java
b/tajo-plan/src/main/java/org/apache/tajo/plan/rewrite/rules/FilterPushDownRule.java
index 36d91bd..eb45af1 100644
--- a/tajo-plan/src/main/java/org/apache/tajo/plan/rewrite/rules/FilterPushDownRule.java
+++ b/tajo-plan/src/main/java/org/apache/tajo/plan/rewrite/rules/FilterPushDownRule.java
@@ -42,6 +42,7 @@ import org.apache.tajo.plan.rewrite.rules.FilterPushDownRule.FilterPushDownConte
 import org.apache.tajo.plan.rewrite.rules.IndexScanInfo.SimplePredicate;
 import org.apache.tajo.plan.util.PlannerUtil;
 import org.apache.tajo.plan.visitor.BasicLogicalPlanVisitor;
+import org.apache.tajo.schema.IdentifierUtil;
 
 import java.util.*;
 
@@ -742,9 +743,9 @@ public class FilterPushDownRule extends BasicLogicalPlanVisitor<FilterPushDownCo
         if (partitionColumns != null && !partitionColumns.isEmpty() && node
instanceof ScanNode) {
           ScanNode scanNode = (ScanNode)node;
           boolean isPartitionColumn = false;
-          if (CatalogUtil.isFQColumnName(partitionColumns.iterator().next())) {
+          if (IdentifierUtil.isFQColumnName(partitionColumns.iterator().next())) {
             isPartitionColumn = partitionColumns.contains(
-                CatalogUtil.buildFQName(scanNode.getTableName(), c.getSimpleName()));
+                IdentifierUtil.buildFQName(scanNode.getTableName(), c.getSimpleName()));
           } else {
             isPartitionColumn = partitionColumns.contains(c.getSimpleName());
           }
@@ -921,7 +922,7 @@ public class FilterPushDownRule extends BasicLogicalPlanVisitor<FilterPushDownCo
         // Else partition column is a simple name
         boolean isPartitionColumn = false;
         if (hasQualifiedName) {
-          isPartitionColumn = partitionColumns.contains(CatalogUtil.buildFQName(table.getName(),
column.getSimpleName()));
+          isPartitionColumn = partitionColumns.contains(IdentifierUtil.buildFQName(table.getName(),
column.getSimpleName()));
         } else {
           isPartitionColumn = partitionColumns.contains(column.getSimpleName());
         }
@@ -971,8 +972,8 @@ public class FilterPushDownRule extends BasicLogicalPlanVisitor<FilterPushDownCo
       // Index path can be identified only after filters are pushed into each scan.
       if(context.rewriteRuleContext.getQueryContext().getBool(SessionVars.INDEX_ENABLED))
{
         String databaseName, tableName;
-        databaseName = CatalogUtil.extractQualifier(table.getName());
-        tableName = CatalogUtil.extractSimpleName(table.getName());
+        databaseName = IdentifierUtil.extractQualifier(table.getName());
+        tableName = IdentifierUtil.extractSimpleName(table.getName());
         Set<Predicate> predicates = new HashSet<>();
         for (EvalNode eval : PlannerUtil.getAllEqualEvals(qual)) {
           BinaryEval binaryEval = (BinaryEval) eval;

http://git-wip-us.apache.org/repos/asf/tajo/blob/8d2bf407/tajo-plan/src/main/java/org/apache/tajo/plan/rewrite/rules/PartitionedTableRewriter.java
----------------------------------------------------------------------
diff --git a/tajo-plan/src/main/java/org/apache/tajo/plan/rewrite/rules/PartitionedTableRewriter.java
b/tajo-plan/src/main/java/org/apache/tajo/plan/rewrite/rules/PartitionedTableRewriter.java
index 32e41d3..54b4844 100644
--- a/tajo-plan/src/main/java/org/apache/tajo/plan/rewrite/rules/PartitionedTableRewriter.java
+++ b/tajo-plan/src/main/java/org/apache/tajo/plan/rewrite/rules/PartitionedTableRewriter.java
@@ -44,6 +44,7 @@ import org.apache.tajo.plan.util.EvalNodeToExprConverter;
 import org.apache.tajo.plan.util.PlannerUtil;
 import org.apache.tajo.plan.visitor.BasicLogicalPlanVisitor;
 import org.apache.tajo.storage.StorageConstants;
+import org.apache.tajo.schema.IdentifierUtil;
 import org.apache.tajo.storage.Tuple;
 import org.apache.tajo.storage.VTuple;
 import org.apache.tajo.util.StringUtils;
@@ -147,7 +148,7 @@ public class PartitionedTableRewriter implements LogicalPlanRewriteRule
{
 
     Path [] filteredPaths = null;
     FileSystem fs = tablePath.getFileSystem(queryContext.getConf());
-    String [] splits = CatalogUtil.splitFQTableName(tableName);
+    String [] splits = IdentifierUtil.splitFQTableName(tableName);
     List<PartitionDescProto> partitions = null;
 
     try {

http://git-wip-us.apache.org/repos/asf/tajo/blob/8d2bf407/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 db5215b..92d59c6 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
@@ -97,7 +97,7 @@ public class EvalNodeSerializer
 
     PlanProto.EvalNode.Builder nodeBuilder = PlanProto.EvalNode.newBuilder();
     nodeBuilder.setId(sid);
-    nodeBuilder.setDataType(TypeConverter.convert(node.getValueType()));
+    nodeBuilder.setDataType(TypeConverter.convert(node.getValueType()).getDataType());
     nodeBuilder.setType(PlanProto.EvalType.valueOf(node.getType().name()));
     return nodeBuilder;
   }
@@ -119,7 +119,7 @@ public class EvalNodeSerializer
       unaryBuilder.setNegative(signedEval.isNegative());
     } else if (unary.getType() == EvalType.CAST) {
       CastEval castEval = (CastEval) unary;
-      unaryBuilder.setCastingType(TypeConverter.convert(castEval.getValueType()));
+      unaryBuilder.setCastingType(TypeConverter.convert(castEval.getValueType()).getDataType());
     }
 
     // registering itself and building EvalNode

http://git-wip-us.apache.org/repos/asf/tajo/blob/8d2bf407/tajo-plan/src/main/java/org/apache/tajo/plan/serder/PlanGsonHelper.java
----------------------------------------------------------------------
diff --git a/tajo-plan/src/main/java/org/apache/tajo/plan/serder/PlanGsonHelper.java b/tajo-plan/src/main/java/org/apache/tajo/plan/serder/PlanGsonHelper.java
index 77bf103..3a64398 100644
--- a/tajo-plan/src/main/java/org/apache/tajo/plan/serder/PlanGsonHelper.java
+++ b/tajo-plan/src/main/java/org/apache/tajo/plan/serder/PlanGsonHelper.java
@@ -60,6 +60,7 @@ public class PlanGsonHelper {
     adapters.put(Datum.class, new DatumAdapter());
     adapters.put(DataType.class, new DataTypeAdapter());
     adapters.put(TimeZone.class, new TimeZoneGsonSerdeAdapter());
+    adapters.put(org.apache.tajo.type.Type.class, new TypeAdapter());
     adapters.put(Schema.class, new SchemaAdapter());
 
     return adapters;

http://git-wip-us.apache.org/repos/asf/tajo/blob/8d2bf407/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 86f8286..2ad6b6f 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().baseType(), evalNode.getValue()));
+    exprs.push(convertDatumToExpr(evalNode.getValueType().kind(), evalNode.getValue()));
     return super.visitConst(o, evalNode, stack);
   }
 

http://git-wip-us.apache.org/repos/asf/tajo/blob/8d2bf407/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 2afef4a..1cf3f9c 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
@@ -146,8 +146,8 @@ public class ExprsVerifier extends BasicEvalNodeVisitor<VerificationState,
EvalN
     org.apache.tajo.type.Type leftDataType = leftExpr.getValueType();
     org.apache.tajo.type.Type rightDataType = rightExpr.getValueType();
 
-    TajoDataTypes.Type leftType = leftDataType.baseType();
-    TajoDataTypes.Type rightType = rightDataType.baseType();
+    TajoDataTypes.Type leftType = leftDataType.kind();
+    TajoDataTypes.Type rightType = rightDataType.kind();
 
     if (leftType == DATE &&
           (checkIntType(rightDataType) ||
@@ -179,26 +179,26 @@ public class ExprsVerifier extends BasicEvalNodeVisitor<VerificationState,
EvalN
   }
 
   private static boolean checkNetworkType(org.apache.tajo.type.Type dataType) {
-    return dataType.baseType() == INET4 || dataType.baseType() == INET6;
+    return dataType.kind() == INET4 || dataType.kind() == INET6;
   }
 
   private static boolean checkIntType(org.apache.tajo.type.Type dataType) {
-    int typeNumber = dataType.baseType().getNumber();
+    int typeNumber = dataType.kind().getNumber();
     return INT1.getNumber() < typeNumber && typeNumber <= INT8.getNumber();
   }
 
   private static boolean checkNumericType(org.apache.tajo.type.Type dataType) {
-    int typeNumber = dataType.baseType().getNumber();
+    int typeNumber = dataType.kind().getNumber();
     return INT1.getNumber() <= typeNumber && typeNumber <= NUMERIC.getNumber();
   }
 
   private static boolean checkTextData(org.apache.tajo.type.Type dataType) {
-    int typeNumber = dataType.baseType().getNumber();
+    int typeNumber = dataType.kind().getNumber();
     return CHAR.getNumber() <= typeNumber && typeNumber <= TEXT.getNumber();
   }
 
   private static boolean checkDateTime(org.apache.tajo.type.Type dataType) {
-    int typeNumber = dataType.baseType().getNumber();
+    int typeNumber = dataType.kind().getNumber();
     return (DATE.getNumber() <= typeNumber && typeNumber <= INTERVAL.getNumber())
||
         (TIMEZ.getNumber() <= typeNumber && typeNumber <= TIMESTAMPZ.getNumber());
   }

http://git-wip-us.apache.org/repos/asf/tajo/blob/8d2bf407/tajo-plan/src/main/java/org/apache/tajo/plan/verifier/PreLogicalPlanVerifier.java
----------------------------------------------------------------------
diff --git a/tajo-plan/src/main/java/org/apache/tajo/plan/verifier/PreLogicalPlanVerifier.java
b/tajo-plan/src/main/java/org/apache/tajo/plan/verifier/PreLogicalPlanVerifier.java
index 7fab5ba..2b197ff 100644
--- a/tajo-plan/src/main/java/org/apache/tajo/plan/verifier/PreLogicalPlanVerifier.java
+++ b/tajo-plan/src/main/java/org/apache/tajo/plan/verifier/PreLogicalPlanVerifier.java
@@ -25,11 +25,11 @@ import org.apache.tajo.SessionVars;
 import org.apache.tajo.TajoConstants;
 import org.apache.tajo.algebra.*;
 import org.apache.tajo.catalog.CatalogService;
-import org.apache.tajo.catalog.CatalogUtil;
 import org.apache.tajo.catalog.TableDesc;
 import org.apache.tajo.exception.*;
 import org.apache.tajo.plan.algebra.BaseAlgebraVisitor;
 import org.apache.tajo.plan.util.ExprFinder;
+import org.apache.tajo.schema.IdentifierUtil;
 import org.apache.tajo.validation.ConstraintViolation;
 
 import java.util.Collection;
@@ -148,10 +148,10 @@ public class PreLogicalPlanVerifier extends BaseAlgebraVisitor<PreLogicalPlanVer
   private boolean assertRelationExistence(Context context, String tableName) {
     String qualifiedName;
 
-    if (CatalogUtil.isFQTableName(tableName)) {
+    if (IdentifierUtil.isFQTableName(tableName)) {
       qualifiedName = tableName;
     } else {
-      qualifiedName = CatalogUtil.buildFQName(context.queryContext.get(SessionVars.CURRENT_DATABASE),
tableName);
+      qualifiedName = IdentifierUtil.buildFQName(context.queryContext.get(SessionVars.CURRENT_DATABASE),
tableName);
     }
 
     if (!catalog.existsTable(qualifiedName)) {
@@ -171,10 +171,10 @@ public class PreLogicalPlanVerifier extends BaseAlgebraVisitor<PreLogicalPlanVer
 
   private static String guessTableName(Context context, String givenName) {
     String qualifiedName;
-    if (CatalogUtil.isFQTableName(givenName)) {
+    if (IdentifierUtil.isFQTableName(givenName)) {
       qualifiedName = givenName;
     } else {
-      qualifiedName = CatalogUtil.buildFQName(context.queryContext.get(SessionVars.CURRENT_DATABASE),
givenName);
+      qualifiedName = IdentifierUtil.buildFQName(context.queryContext.get(SessionVars.CURRENT_DATABASE),
givenName);
     }
 
     return qualifiedName;
@@ -327,8 +327,8 @@ public class PreLogicalPlanVerifier extends BaseAlgebraVisitor<PreLogicalPlanVer
         } else {
           if (expr.hasTableName()) {
             String qualifiedName = expr.getTableName();
-            if (TajoConstants.EMPTY_STRING.equals(CatalogUtil.extractQualifier(expr.getTableName())))
{
-              qualifiedName = CatalogUtil.buildFQName(context.queryContext.get(SessionVars.CURRENT_DATABASE),
+            if (TajoConstants.EMPTY_STRING.equals(IdentifierUtil.extractQualifier(expr.getTableName())))
{
+              qualifiedName = IdentifierUtil.buildFQName(context.queryContext.get(SessionVars.CURRENT_DATABASE),
                   expr.getTableName());
             }
 

http://git-wip-us.apache.org/repos/asf/tajo/blob/8d2bf407/tajo-sql-parser/pom.xml
----------------------------------------------------------------------
diff --git a/tajo-sql-parser/pom.xml b/tajo-sql-parser/pom.xml
index cba8af5..956e410 100644
--- a/tajo-sql-parser/pom.xml
+++ b/tajo-sql-parser/pom.xml
@@ -52,6 +52,11 @@
             </goals>
           </execution>
         </executions>
+        <configuration>
+          <excludes>
+            <exclude>**/*.tokens</exclude>
+          </excludes>
+        </configuration>
       </plugin>
       <plugin>
         <artifactId>maven-deploy-plugin</artifactId>

http://git-wip-us.apache.org/repos/asf/tajo/blob/8d2bf407/tajo-sql-parser/src/main/antlr4/org/apache/tajo/parser/sql/SQLLexer.g4
----------------------------------------------------------------------
diff --git a/tajo-sql-parser/src/main/antlr4/org/apache/tajo/parser/sql/SQLLexer.g4 b/tajo-sql-parser/src/main/antlr4/org/apache/tajo/parser/sql/SQLLexer.g4
index 2bb3582..db2bfda 100644
--- a/tajo-sql-parser/src/main/antlr4/org/apache/tajo/parser/sql/SQLLexer.g4
+++ b/tajo-sql-parser/src/main/antlr4/org/apache/tajo/parser/sql/SQLLexer.g4
@@ -259,7 +259,6 @@ LESS : L E S S;
 LIST : L I S T;
 LOCATION : L O C A T I O N;
 
-MAP : M A P;
 MAX : M A X;
 MAXVALUE : M A X V A L U E;
 MICROSECONDS : M I C R O S E C O N D S;
@@ -288,7 +287,6 @@ QUARTER : Q U A R T E R;
 
 RANGE : R A N G E;
 RANK : R A N K;
-RECORD : R E C O R D;
 REGEXP : R E G E X P;
 RENAME : R E N A M E;
 REPAIR : R E P A I R;
@@ -385,6 +383,11 @@ BYTEA : B Y T E A; // alias for BLOB
 
 INET4 : I N E T '4';
 
+// complex types
+ARRAY : A R R A Y;
+MAP : M A P;
+RECORD : R E C O R D;
+
 // Operators
 Similar_To : '~';
 Not_Similar_To : '!~';

http://git-wip-us.apache.org/repos/asf/tajo/blob/8d2bf407/tajo-sql-parser/src/main/antlr4/org/apache/tajo/parser/sql/SQLParser.g4
----------------------------------------------------------------------
diff --git a/tajo-sql-parser/src/main/antlr4/org/apache/tajo/parser/sql/SQLParser.g4 b/tajo-sql-parser/src/main/antlr4/org/apache/tajo/parser/sql/SQLParser.g4
index 1908258..b76b5d9 100644
--- a/tajo-sql-parser/src/main/antlr4/org/apache/tajo/parser/sql/SQLParser.g4
+++ b/tajo-sql-parser/src/main/antlr4/org/apache/tajo/parser/sql/SQLParser.g4
@@ -211,7 +211,7 @@ truncate_table_statement
 
 /*
 ===============================================================================
-  11.21 <data types>
+  11.21 <drop table statement>
 ===============================================================================
 */
 
@@ -442,8 +442,7 @@ predefined_type
   | bit_type
   | binary_type
   | network_type
-  | record_type
-  | map_type
+  | complex_type
   ;
 
 character_string_type
@@ -539,6 +538,16 @@ network_type
   : INET4
   ;
 
+complex_type
+  : array_type
+  | record_type
+  | map_type
+  ;
+
+array_type
+  : ARRAY LTH data_type GTH
+  ;
+
 record_type
   : RECORD table_elements
   ;
@@ -765,10 +774,6 @@ factor
   : (sign)? numeric_primary
   ;
 
-array
-  : LEFT_PAREN numeric_value_expression (COMMA numeric_value_expression )* RIGHT_PAREN
-  ;
-
 numeric_primary
   : value_expression_primary (CAST_EXPRESSION cast_target)*
   | numeric_value_function

http://git-wip-us.apache.org/repos/asf/tajo/blob/8d2bf407/tajo-storage/tajo-storage-hdfs/src/main/java/org/apache/tajo/storage/FileTablespace.java
----------------------------------------------------------------------
diff --git a/tajo-storage/tajo-storage-hdfs/src/main/java/org/apache/tajo/storage/FileTablespace.java
b/tajo-storage/tajo-storage-hdfs/src/main/java/org/apache/tajo/storage/FileTablespace.java
index ad45749..2aa2b91 100644
--- a/tajo-storage/tajo-storage-hdfs/src/main/java/org/apache/tajo/storage/FileTablespace.java
+++ b/tajo-storage/tajo-storage-hdfs/src/main/java/org/apache/tajo/storage/FileTablespace.java
@@ -40,6 +40,7 @@ import org.apache.tajo.plan.LogicalPlan;
 import org.apache.tajo.plan.expr.EvalNode;
 import org.apache.tajo.plan.logical.LogicalNode;
 import org.apache.tajo.plan.logical.NodeType;
+import org.apache.tajo.schema.IdentifierUtil;
 import org.apache.tajo.storage.fragment.FileFragment;
 import org.apache.tajo.storage.fragment.Fragment;
 import org.apache.tajo.util.Bytes;
@@ -612,7 +613,7 @@ public class FileTablespace extends Tablespace {
   @Override
   public void createTable(TableDesc tableDesc, boolean ifNotExists) throws IOException {
     if (!tableDesc.isExternal()) {
-      String [] splitted = CatalogUtil.splitFQTableName(tableDesc.getName());
+      String [] splitted = IdentifierUtil.splitFQTableName(tableDesc.getName());
       String databaseName = splitted[0];
       String simpleTableName = splitted[1];
 

http://git-wip-us.apache.org/repos/asf/tajo/blob/8d2bf407/tajo-storage/tajo-storage-jdbc/src/main/java/org/apache/tajo/storage/jdbc/JdbcMetadataProviderBase.java
----------------------------------------------------------------------
diff --git a/tajo-storage/tajo-storage-jdbc/src/main/java/org/apache/tajo/storage/jdbc/JdbcMetadataProviderBase.java
b/tajo-storage/tajo-storage-jdbc/src/main/java/org/apache/tajo/storage/jdbc/JdbcMetadataProviderBase.java
index 8f5e7a8..fb095a4 100644
--- a/tajo-storage/tajo-storage-jdbc/src/main/java/org/apache/tajo/storage/jdbc/JdbcMetadataProviderBase.java
+++ b/tajo-storage/tajo-storage-jdbc/src/main/java/org/apache/tajo/storage/jdbc/JdbcMetadataProviderBase.java
@@ -30,6 +30,7 @@ import org.apache.tajo.exception.SQLExceptionUtil;
 import org.apache.tajo.exception.TajoInternalError;
 import org.apache.tajo.exception.UndefinedTablespaceException;
 import org.apache.tajo.exception.UnsupportedDataTypeException;
+import org.apache.tajo.schema.IdentifierUtil;
 import org.apache.tajo.util.KeyValueSet;
 import org.apache.tajo.util.Pair;
 
@@ -197,7 +198,7 @@ public abstract class JdbcMetadataProviderBase implements MetadataProvider
{
         final String qualifier = resultForColumns.getString("TABLE_NAME");
         final String columnName = resultForColumns.getString("COLUMN_NAME");
         final TypeDesc type = convertDataType(resultForColumns);
-        final Column c = new Column(CatalogUtil.buildFQName(databaseName, qualifier, columnName),
type);
+        final Column c = new Column(IdentifierUtil.buildFQName(databaseName, qualifier, columnName),
type);
 
         columns.add(new Pair<>(ordinalPos, c));
       }
@@ -224,7 +225,7 @@ public abstract class JdbcMetadataProviderBase implements MetadataProvider
{
       stats.setNumRows(-1); // unknown
 
       final TableDesc table = new TableDesc(
-          CatalogUtil.buildFQName(databaseName, name),
+          IdentifierUtil.buildFQName(databaseName, name),
           schema,
           new TableMeta("rowstore", new KeyValueSet()),
           space.getTableUri(databaseName, name)

http://git-wip-us.apache.org/repos/asf/tajo/blob/8d2bf407/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 0b1df31..da97e32 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
@@ -19,13 +19,12 @@
 package org.apache.tajo.storage.jdbc;
 
 import com.google.common.base.Function;
-import org.apache.tajo.catalog.CatalogUtil;
-import org.apache.tajo.common.TajoDataTypes.DataType;
 import org.apache.tajo.datum.Datum;
 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.schema.IdentifierUtil;
 import org.apache.tajo.type.Type;
 import org.apache.tajo.util.StringUtils;
 
@@ -145,13 +144,13 @@ public class SQLExpressionGenerator extends SimpleEvalNodeVisitor<SQLExpressionG
   protected EvalNode visitField(Context context, FieldEval field, Stack<EvalNode> stack)
{
     // strip the database name
     String tableName;
-    if (CatalogUtil.isSimpleIdentifier(field.getQualifier())) {
+    if (IdentifierUtil.isSimpleIdentifier(field.getQualifier())) {
       tableName = field.getQualifier();
     } else {
-      tableName = CatalogUtil.extractSimpleName(field.getQualifier());
+      tableName = IdentifierUtil.extractSimpleName(field.getQualifier());
     }
 
-    context.append(CatalogUtil.buildFQName(tableName, field.getColumnName()));
+    context.append(IdentifierUtil.buildFQName(tableName, field.getColumnName()));
     return field;
   }
 
@@ -272,7 +271,7 @@ public class SQLExpressionGenerator extends SimpleEvalNodeVisitor<SQLExpressionG
    * @return SQL DataType
    */
   public String convertTajoTypeToSQLType(Type dataType) {
-    switch (dataType.baseType()) {
+    switch (dataType.kind()) {
     case INT1:
       return "TINYINT";
     case INT2:
@@ -286,7 +285,7 @@ public class SQLExpressionGenerator extends SimpleEvalNodeVisitor<SQLExpressionG
     case FLOAT8:
       return "DOUBLE";
     default:
-      return dataType.baseType().name();
+      return dataType.kind().name();
     }
   }
 

http://git-wip-us.apache.org/repos/asf/tajo/blob/8d2bf407/tajo-storage/tajo-storage-pgsql/src/main/java/org/apache/tajo/storage/pgsql/PgSQLTablespace.java
----------------------------------------------------------------------
diff --git a/tajo-storage/tajo-storage-pgsql/src/main/java/org/apache/tajo/storage/pgsql/PgSQLTablespace.java
b/tajo-storage/tajo-storage-pgsql/src/main/java/org/apache/tajo/storage/pgsql/PgSQLTablespace.java
index 8386f74..90c5201 100644
--- a/tajo-storage/tajo-storage-pgsql/src/main/java/org/apache/tajo/storage/pgsql/PgSQLTablespace.java
+++ b/tajo-storage/tajo-storage-pgsql/src/main/java/org/apache/tajo/storage/pgsql/PgSQLTablespace.java
@@ -24,6 +24,7 @@ import org.apache.tajo.exception.TajoInternalError;
 import org.apache.tajo.exception.TajoRuntimeException;
 import org.apache.tajo.exception.UndefinedTableException;
 import org.apache.tajo.plan.expr.EvalNode;
+import org.apache.tajo.schema.IdentifierUtil;
 import org.apache.tajo.storage.NullScanner;
 import org.apache.tajo.storage.Scanner;
 import org.apache.tajo.storage.fragment.Fragment;
@@ -82,7 +83,7 @@ public class PgSQLTablespace extends JdbcTablespace {
   @Override
   public long getTableVolume(TableDesc table, Optional<EvalNode> filter) {
 
-    String sql = "SELECT pg_table_size('" + CatalogUtil.extractSimpleName(table.getName())
+ "')";
+    String sql = "SELECT pg_table_size('" + IdentifierUtil.extractSimpleName(table.getName())
+ "')";
 
     try (Statement stmt = conn.createStatement();
          ResultSet rs = stmt.executeQuery(sql)) {


Mime
View raw message