tajo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hyun...@apache.org
Subject [3/3] git commit: TAJO-610: Refactor Column class.
Date Thu, 20 Feb 2014 11:10:32 GMT
TAJO-610: Refactor Column class.


Project: http://git-wip-us.apache.org/repos/asf/incubator-tajo/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-tajo/commit/e2f4798b
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tajo/tree/e2f4798b
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tajo/diff/e2f4798b

Branch: refs/heads/master
Commit: e2f4798b09b2efccfe14a6eac46055d3b6c72ffb
Parents: e63f4b0
Author: Hyunsik Choi <hyunsik@apache.org>
Authored: Thu Feb 20 20:02:24 2014 +0900
Committer: Hyunsik Choi <hyunsik@apache.org>
Committed: Thu Feb 20 20:02:24 2014 +0900

----------------------------------------------------------------------
 CHANGES.txt                                     |   4 +-
 .../org/apache/tajo/catalog/CatalogUtil.java    |  61 +++++++-
 .../java/org/apache/tajo/catalog/Column.java    | 146 +++++++++----------
 .../org/apache/tajo/catalog/DDLBuilder.java     |   2 +-
 .../java/org/apache/tajo/catalog/Schema.java    |  65 ++++++---
 .../src/main/proto/CatalogProtos.proto          |   3 +-
 .../org/apache/tajo/catalog/TestColumn.java     |   5 +-
 .../org/apache/tajo/catalog/TestSchema.java     |  40 ++---
 .../tajo/catalog/store/HCatalogStore.java       |   2 +-
 .../tajo/catalog/store/TestHCatalogStore.java   |  26 ++--
 .../tajo/catalog/store/AbstractDBStore.java     |  28 +---
 .../org/apache/tajo/catalog/store/MemStore.java |   2 +-
 .../org/apache/tajo/catalog/TestCatalog.java    |  10 +-
 .../org/apache/tajo/catalog/TestDBStore.java    |  10 +-
 .../org/apache/tajo/cli/DescTableCommand.java   |   4 +-
 .../apache/tajo/jdbc/TajoResultSetMetaData.java |   4 +-
 .../java/org/apache/tajo/TajoConstants.java     |   2 +
 .../apache/tajo/engine/eval/EvalTreeUtil.java   |   4 +-
 .../org/apache/tajo/engine/eval/FieldEval.java  |   4 +-
 .../apache/tajo/engine/planner/LogicalPlan.java |  17 ++-
 .../engine/planner/LogicalPlanPreprocessor.java |  10 +-
 .../engine/planner/LogicalPlanVerifier.java     |  16 +-
 .../tajo/engine/planner/LogicalPlanner.java     |  16 +-
 .../apache/tajo/engine/planner/PlannerUtil.java |  89 +----------
 .../tajo/engine/planner/enforce/Enforcer.java   |   2 +-
 .../engine/planner/global/GlobalPlanner.java    |   2 +-
 .../engine/planner/logical/GroupbyNode.java     |   2 +-
 .../tajo/engine/planner/logical/ScanNode.java   |   3 +-
 .../tajo/engine/planner/logical/SortNode.java   |   2 +-
 .../planner/logical/TableSubQueryNode.java      |   3 +-
 .../engine/planner/logical/join/JoinGraph.java  |   8 +-
 .../engine/planner/physical/BNLJoinExec.java    |   2 +-
 .../planner/physical/BSTIndexScanExec.java      |   2 +-
 .../planner/physical/ColPartitionStoreExec.java |   4 +-
 .../planner/physical/HashAggregateExec.java     |   2 +-
 .../planner/physical/HashFullOuterJoinExec.java |   6 +-
 .../engine/planner/physical/HashJoinExec.java   |   2 +-
 .../planner/physical/HashLeftOuterJoinExec.java |   4 +-
 .../physical/MergeFullOuterJoinExec.java        |   6 +-
 .../engine/planner/physical/MergeJoinExec.java  |   2 +-
 .../engine/planner/physical/NLJoinExec.java     |   2 +-
 .../planner/physical/NLLeftOuterJoinExec.java   |   4 +-
 .../engine/planner/physical/PhysicalExec.java   |   2 +-
 .../engine/planner/physical/ProjectionExec.java |   2 +-
 .../physical/RangeShuffleFileWriteExec.java     |   2 +-
 .../physical/RightOuterMergeJoinExec.java       |   4 +-
 .../planner/physical/SortAggregateExec.java     |   4 +-
 .../rewrite/PartitionedTableRewriter.java       |  10 +-
 .../apache/tajo/engine/query/QueryContext.java  |   4 +-
 .../apache/tajo/engine/utils/SchemaUtil.java    |   4 +-
 .../org/apache/tajo/engine/utils/TupleUtil.java |  14 +-
 .../java/org/apache/tajo/util/IndexUtil.java    |   4 +-
 .../resources/webapps/admin/catalogview.jsp     |  14 +-
 .../apache/tajo/engine/eval/ExprTestBase.java   |   6 +-
 .../tajo/engine/eval/TestEvalTreeUtil.java      |   4 +-
 .../engine/planner/TestLogicalOptimizer.java    |   4 +-
 .../tajo/engine/planner/TestLogicalPlanner.java |  47 +++---
 .../tajo/engine/planner/TestPlannerUtil.java    |  12 +-
 .../planner/physical/TestBNLJoinExec.java       |   8 +-
 .../planner/physical/TestBSTIndexExec.java      |  12 +-
 .../planner/physical/TestExternalSortExec.java  |   2 +-
 .../physical/TestFullOuterHashJoinExec.java     |  10 +-
 .../physical/TestFullOuterMergeJoinExec.java    |  16 +-
 .../planner/physical/TestHashAntiJoinExec.java  |   8 +-
 .../planner/physical/TestHashJoinExec.java      |   4 +-
 .../planner/physical/TestHashSemiJoinExec.java  |   8 +-
 .../physical/TestLeftOuterHashJoinExec.java     |  12 +-
 .../physical/TestLeftOuterNLJoinExec.java       |   6 +-
 .../planner/physical/TestMergeJoinExec.java     |   8 +-
 .../engine/planner/physical/TestNLJoinExec.java |   8 +-
 .../planner/physical/TestPhysicalPlanner.java   |   4 +-
 .../physical/TestRightOuterHashJoinExec.java    |  14 +-
 .../physical/TestRightOuterMergeJoinExec.java   |  16 +-
 .../engine/planner/physical/TestSortExec.java   |   2 +-
 .../apache/tajo/engine/query/TestCTASQuery.java |   4 +-
 .../tajo/engine/query/TestTablePartitions.java  |   9 +-
 .../org/apache/tajo/jdbc/TestResultSet.java     |   9 +-
 .../java/org/apache/tajo/jdbc/TestTajoJdbc.java |   2 +-
 .../tajo/worker/TestRangeRetrieverHandler.java  |  12 +-
 .../apache/tajo/jdbc/TajoDatabaseMetaData.java  |   4 +-
 .../java/org/apache/tajo/storage/CSVFile.java   |   2 +-
 .../org/apache/tajo/storage/FileScanner.java    |   2 +-
 .../java/org/apache/tajo/storage/LazyTuple.java |   2 +-
 .../java/org/apache/tajo/storage/RawFile.java   |  14 +-
 .../java/org/apache/tajo/storage/RowFile.java   |  12 +-
 .../org/apache/tajo/storage/RowStoreUtil.java   |   8 +-
 .../apache/tajo/storage/TableStatistics.java    |  12 +-
 .../org/apache/tajo/storage/rcfile/RCFile.java  |   8 +-
 .../tajo/storage/trevni/TrevniAppender.java     |   6 +-
 .../tajo/storage/trevni/TrevniScanner.java      |   6 +-
 .../apache/tajo/storage/v2/CSVFileScanner.java  |   2 +-
 .../apache/tajo/storage/v2/FileScannerV2.java   |   4 +-
 .../apache/tajo/storage/v2/RCFileScanner.java   |  11 +-
 .../org/apache/tajo/storage/TestLazyTuple.java  |  14 +-
 .../tajo/storage/TestTupleComparator.java       |  10 +-
 .../apache/tajo/storage/index/TestBSTIndex.java |  52 ++++---
 .../index/TestSingleCSVFileBSTIndex.java        |  10 +-
 97 files changed, 543 insertions(+), 575 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-tajo/blob/e2f4798b/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index d7125b0..0be4426 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -130,7 +130,9 @@ Release 0.8.0 - unreleased
 
   IMPROVEMENTS
 
-    TAJO-601: Improve distinct aggregation query processing.
+    TAJO-610: Refactor Column class. (hyunsik)
+
+    TAJO-601: Improve distinct aggregation query processing. (hyunsik)
 
     TAJO-305: Implement killQuery feature. (hyunsik)
 

http://git-wip-us.apache.org/repos/asf/incubator-tajo/blob/e2f4798b/tajo-catalog/tajo-catalog-common/src/main/java/org/apache/tajo/catalog/CatalogUtil.java
----------------------------------------------------------------------
diff --git a/tajo-catalog/tajo-catalog-common/src/main/java/org/apache/tajo/catalog/CatalogUtil.java b/tajo-catalog/tajo-catalog-common/src/main/java/org/apache/tajo/catalog/CatalogUtil.java
index 9f143ac..2a6727e 100644
--- a/tajo-catalog/tajo-catalog-common/src/main/java/org/apache/tajo/catalog/CatalogUtil.java
+++ b/tajo-catalog/tajo-catalog-common/src/main/java/org/apache/tajo/catalog/CatalogUtil.java
@@ -19,6 +19,7 @@
 package org.apache.tajo.catalog;
 
 import org.apache.hadoop.fs.Path;
+import org.apache.tajo.TajoConstants;
 import org.apache.tajo.catalog.partition.PartitionMethodDesc;
 import org.apache.tajo.catalog.proto.CatalogProtos;
 import org.apache.tajo.catalog.proto.CatalogProtos.ColumnProto;
@@ -26,13 +27,66 @@ import org.apache.tajo.catalog.proto.CatalogProtos.SchemaProto;
 import org.apache.tajo.catalog.proto.CatalogProtos.TableDescProto;
 import org.apache.tajo.common.TajoDataTypes.DataType;
 
-import java.sql.*;
+import java.sql.Connection;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Statement;
 import java.util.Collection;
 
 import static org.apache.tajo.catalog.proto.CatalogProtos.StoreType;
 import static org.apache.tajo.common.TajoDataTypes.Type;
 
 public class CatalogUtil {
+  public final static String IDENTIFIER_DELIMITER = ".";
+  public final static String IDENTIFIER_DELIMITER_REGEXP = "\\.";
+
+  /**
+   * Normalize an identifier
+   *
+   * @param identifier The identifier to be normalized
+   * @return The normalized identifier
+   */
+  public static String normalizeIdentifier(String identifier) {
+    return identifier.toLowerCase();
+  }
+
+  /**
+   * Extract a qualification name from an identifier.
+   *
+   * For example, consider a table identifier like 'database1.table1'.
+   * In this case, this method extracts 'database1'.
+   *
+   * @param name The identifier to be extracted
+   * @return The extracted qualifier
+   */
+  public static String extractQualifier(String name) {
+    int lastDelimiterIdx = name.lastIndexOf(IDENTIFIER_DELIMITER);
+    if (lastDelimiterIdx > -1) {
+      return name.substring(0, lastDelimiterIdx);
+    } else {
+      return TajoConstants.EMPTY_STRING;
+    }
+  }
+
+  /**
+   * Extract a simple name from an identifier.
+   *
+   * For example, consider a table identifier like 'database1.table1'.
+   * In this case, this method extracts 'table1'.
+   *
+   * @param name The identifier to be extracted
+   * @return The extracted simple name
+   */
+  public static String extractSimpleName(String name) {
+    int lastDelimiterIdx = name.lastIndexOf(IDENTIFIER_DELIMITER);
+    if (lastDelimiterIdx > -1) {
+      // plus one means skipping a delimiter.
+      return name.substring(lastDelimiterIdx + 1, name.length());
+    } else {
+      return name;
+    }
+  }
+
   public static String getCanonicalName(String signature, Collection<DataType> paramTypes) {
     DataType [] types = paramTypes.toArray(new DataType[paramTypes.size()]);
     return getCanonicalName(signature, types);
@@ -108,8 +162,7 @@ public class CatalogUtil {
     revisedSchema.clearFields();
     for (ColumnProto col : schema.getFieldsList()) {
       ColumnProto.Builder builder = ColumnProto.newBuilder(col);
-      builder.setColumnName(col.getColumnName());
-      builder.setQualifier(tableName);
+      builder.setName(tableName + IDENTIFIER_DELIMITER + extractSimpleName(col.getName()));
       revisedSchema.addFields(builder.build());
     }
 
@@ -145,7 +198,7 @@ public class CatalogUtil {
   }
 
   public static String columnToDDLString(Column column) {
-    StringBuilder sb = new StringBuilder(column.getColumnName());
+    StringBuilder sb = new StringBuilder(column.getSimpleName());
     sb.append(" ").append(column.getDataType().getType());
     if (column.getDataType().hasLength()) {
       sb.append(" (").append(column.getDataType().getLength()).append(")");

http://git-wip-us.apache.org/repos/asf/incubator-tajo/blob/e2f4798b/tajo-catalog/tajo-catalog-common/src/main/java/org/apache/tajo/catalog/Column.java
----------------------------------------------------------------------
diff --git a/tajo-catalog/tajo-catalog-common/src/main/java/org/apache/tajo/catalog/Column.java b/tajo-catalog/tajo-catalog-common/src/main/java/org/apache/tajo/catalog/Column.java
index cb42086..b75cd1c 100644
--- a/tajo-catalog/tajo-catalog-common/src/main/java/org/apache/tajo/catalog/Column.java
+++ b/tajo-catalog/tajo-catalog-common/src/main/java/org/apache/tajo/catalog/Column.java
@@ -26,131 +26,114 @@ import org.apache.tajo.common.ProtoObject;
 import org.apache.tajo.common.TajoDataTypes;
 import org.apache.tajo.common.TajoDataTypes.DataType;
 import org.apache.tajo.json.GsonObject;
-import org.apache.tajo.util.TUtil;
 
 /**
- * It represents a column. It is usually used for relations.
+ * Describes a column. It is an immutable object.
  */
-public class Column implements ProtoObject<ColumnProto>, Cloneable, GsonObject {
-	private ColumnProto.Builder builder = null;
+public class Column implements ProtoObject<ColumnProto>, GsonObject {
+	@Expose protected String name;
+	@Expose protected DataType dataType;
 
-  @Expose protected String qualifier; // optional
-	@Expose protected String name; // required
-	@Expose protected DataType dataType; // required
-	
-	public Column() {
-		this.builder = ColumnProto.newBuilder();
-	}
-	  
-	public Column(String columnName, DataType dataType) {
-	  this();
-		checkAndSetName(columnName.toLowerCase());
+  /**
+   *
+   * @param name Column name
+   * @param dataType Data Type with length
+   */
+	public Column(String name, DataType dataType) {
+    this.name = CatalogUtil.normalizeIdentifier(name);
 		this.dataType = dataType;
 	}
 
-  public Column(String columnName, TajoDataTypes.Type type) {
-    this(columnName, CatalogUtil.newSimpleDataType(type));
+  /**
+   *
+   * @param name Column name
+   * @param type Data Type without length
+   */
+  public Column(String name, TajoDataTypes.Type type) {
+    this(name, CatalogUtil.newSimpleDataType(type));
   }
 
-  public Column(String columnName, TajoDataTypes.Type type, int typeLength) {
-    this(columnName, CatalogUtil.newDataTypeWithLen(type, typeLength));
+  /**
+   *
+   * @param name Column name
+   * @param type Data Type
+   * @param typeLength The length of type
+   */
+  public Column(String name, TajoDataTypes.Type type, int typeLength) {
+    this(name, CatalogUtil.newDataTypeWithLen(type, typeLength));
   }
-	
+
 	public Column(ColumnProto proto) {
-    this();
-    name = proto.getColumnName().toLowerCase();
+    name = CatalogUtil.normalizeIdentifier(proto.getName());
     dataType = proto.getDataType();
-    if (proto.hasQualifier()) {
-      qualifier = proto.getQualifier().toLowerCase();
-    }
 	}
 
-  private void checkAndSetName(String qualifiedOrName) {
-    String [] splits = qualifiedOrName.split("\\.");
-    if (splits.length > 1) {
-      qualifier = qualifiedOrName.substring(0, qualifiedOrName.lastIndexOf("."));
-      name = qualifiedOrName.substring(qualifiedOrName.lastIndexOf(".") + 1, qualifiedOrName.length());
-    } else {
-      qualifier = null;
-      name = qualifiedOrName;
-    }
+  /**
+   *
+   * @return True if a column includes a table name. Otherwise, it returns False.
+   */
+  public boolean hasQualifier() {
+    return name.split(CatalogUtil.IDENTIFIER_DELIMITER_REGEXP).length > 1;
   }
 
+  /**
+   *
+   * @return The full name of this column.
+   */
 	public String getQualifiedName() {
-    if (qualifier != null) {
-      return qualifier + "." + name;
-    } else {
-      return name;
-    }
+    return name;
 	}
-	
-  public boolean hasQualifier() {
-    return qualifier != null;
-  }
-
-  public void setQualifier(String qualifier) {
-    this.qualifier = qualifier.toLowerCase();
-  }
 
+  /**
+   *
+   * @return The qualifier
+   */
   public String getQualifier() {
-    if (qualifier != null) {
-      return qualifier;
-    } else {
-      return "";
-    }    
+    return CatalogUtil.extractQualifier(name);
   }
 
-  public String getColumnName() {
-    return name;
+  /**
+   *
+   * @return The simple name without qualifications
+   */
+  public String getSimpleName() {
+    return CatalogUtil.extractSimpleName(name);
   }
-	
-	public void setName(String name) {
-    checkAndSetName(name.toLowerCase());
-	}
-	
+
+  /**
+   *
+   * @return DataType which includes domain type and scale.
+   */
 	public DataType getDataType() {
 		return this.dataType;
 	}
 	
-	public void setDataType(DataType dataType) {
-		this.dataType = dataType;
-	}
-	
 	@Override
 	public boolean equals(Object o) {
 		if (o instanceof Column) {
 			Column another = (Column)o;
-			return name.equals(another.name) &&
-          dataType.equals(another.dataType) &&
-          TUtil.checkEquals(qualifier, another.qualifier);
+			return name.equals(another.name) && dataType.equals(another.dataType);
     }
 		return false;
 	}
 	
   public int hashCode() {
-    return Objects.hashCode(name, dataType, qualifier);
+    return Objects.hashCode(name, dataType);
 
   }
   
   @Override
-  public Object clone() throws CloneNotSupportedException {
-    Column column = (Column) super.clone();
-    column.builder = ColumnProto.newBuilder();
-    column.name = name;
-    column.dataType = dataType;
-    column.qualifier = qualifier != null ? qualifier : null;
-    return column;
+  public Object clone() {
+    return this;
   }
 
+  /**
+   *
+   * @return The protocol buffer object for Column
+   */
 	@Override
 	public ColumnProto getProto() {
-    builder.setColumnName(this.name);
-    builder.setDataType(this.dataType);
-    if (qualifier != null) {
-      builder.setQualifier(qualifier);
-    }
-
-    return builder.build();
+    return ColumnProto.newBuilder().setName(this.name).setDataType(this.dataType).build();
 	}
 	
 	public String toString() {
@@ -167,4 +150,5 @@ public class Column implements ProtoObject<ColumnProto>, Cloneable, GsonObject {
 	public String toJson() {
 		return CatalogGsonHelper.toJson(this, Column.class);
 	}
+
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-tajo/blob/e2f4798b/tajo-catalog/tajo-catalog-common/src/main/java/org/apache/tajo/catalog/DDLBuilder.java
----------------------------------------------------------------------
diff --git a/tajo-catalog/tajo-catalog-common/src/main/java/org/apache/tajo/catalog/DDLBuilder.java b/tajo-catalog/tajo-catalog-common/src/main/java/org/apache/tajo/catalog/DDLBuilder.java
index 12a1f74..1e51cc2 100644
--- a/tajo-catalog/tajo-catalog-common/src/main/java/org/apache/tajo/catalog/DDLBuilder.java
+++ b/tajo-catalog/tajo-catalog-common/src/main/java/org/apache/tajo/catalog/DDLBuilder.java
@@ -59,7 +59,7 @@ public class DDLBuilder {
         sb.append(", ");
       }
 
-      sb.append(column.getColumnName()).append(" ");
+      sb.append(column.getSimpleName()).append(" ");
       TajoDataTypes.DataType dataType = column.getDataType();
       sb.append(dataType.getType().name());
       if (column.getDataType().hasLength() && column.getDataType().getLength() > 0) {

http://git-wip-us.apache.org/repos/asf/incubator-tajo/blob/e2f4798b/tajo-catalog/tajo-catalog-common/src/main/java/org/apache/tajo/catalog/Schema.java
----------------------------------------------------------------------
diff --git a/tajo-catalog/tajo-catalog-common/src/main/java/org/apache/tajo/catalog/Schema.java b/tajo-catalog/tajo-catalog-common/src/main/java/org/apache/tajo/catalog/Schema.java
index 5f1e8d7..725e9c3 100644
--- a/tajo-catalog/tajo-catalog-common/src/main/java/org/apache/tajo/catalog/Schema.java
+++ b/tajo-catalog/tajo-catalog-common/src/main/java/org/apache/tajo/catalog/Schema.java
@@ -56,14 +56,14 @@ public class Schema implements ProtoObject<SchemaProto>, Cloneable, GsonObject {
       Column tobeAdded = new Column(colProto);
       fields.add(tobeAdded);
       if (tobeAdded.hasQualifier()) {
-        fieldsByQualifiedName.put(tobeAdded.getQualifier() + "." + tobeAdded.getColumnName(), fields.size() - 1);
+        fieldsByQualifiedName.put(tobeAdded.getQualifier() + "." + tobeAdded.getSimpleName(), fields.size() - 1);
       } else {
-        fieldsByQualifiedName.put(tobeAdded.getColumnName(), fields.size() - 1);
+        fieldsByQualifiedName.put(tobeAdded.getSimpleName(), fields.size() - 1);
       }
-      if (fieldsByName.containsKey(tobeAdded.getColumnName())) {
-        fieldsByName.get(tobeAdded.getColumnName()).add(fields.size() - 1);
+      if (fieldsByName.containsKey(tobeAdded.getSimpleName())) {
+        fieldsByName.get(tobeAdded.getSimpleName()).add(fields.size() - 1);
       } else {
-        fieldsByName.put(tobeAdded.getColumnName(), TUtil.newList(fields.size() - 1));
+        fieldsByName.put(tobeAdded.getSimpleName(), TUtil.newList(fields.size() - 1));
       }
     }
   }
@@ -96,13 +96,14 @@ public class Schema implements ProtoObject<SchemaProto>, Cloneable, GsonObject {
    */
   public void setQualifier(String qualifier) {
     fieldsByQualifiedName.clear();
-    for (int i = 0; i < getColumnNum(); i++) {
-      fields.get(i).setQualifier(qualifier);
+    for (int i = 0; i < size(); i++) {
+      Column column = fields.get(i);
+      fields.set(i, new Column(qualifier + "." + column.getSimpleName(), column.getDataType()));
       fieldsByQualifiedName.put(fields.get(i).getQualifiedName(), i);
     }
   }
 	
-	public int getColumnNum() {
+	public int size() {
 		return this.fields.size();
 	}
 
@@ -117,26 +118,47 @@ public class Schema implements ProtoObject<SchemaProto>, Cloneable, GsonObject {
     if (column.hasQualifier()) {
       return fields.get(fieldsByQualifiedName.get(column.getQualifiedName()));
     } else {
-      return fields.get(fieldsByName.get(column.getColumnName()).get(0));
+      return fields.get(fieldsByName.get(column.getSimpleName()).get(0));
     }
   }
 
+  /**
+   * Get a column by a given name.
+   *
+   * @param name The column name to be found.
+   * @return The column matched to a given column name.
+   */
   public Column getColumn(String name) {
     String [] parts = name.split("\\.");
     if (parts.length == 2) {
-      return getColumnByFQN(name);
+      return getColumnByQName(name);
     } else {
       return getColumnByName(name);
     }
   }
 
-	public Column getColumnByFQN(String qualifiedName) {
+  /**
+   * Find a column by a qualified name (e.g., table1.col1).
+   *
+   * @param qualifiedName The qualified name
+   * @return The Column matched to a given qualified name
+   */
+  private Column getColumnByQName(String qualifiedName) {
 		Integer cid = fieldsByQualifiedName.get(qualifiedName.toLowerCase());
 		return cid != null ? fields.get(cid) : null;
 	}
-	
-	public Column getColumnByName(String colName) {
-    String normalized = colName.toLowerCase();
+
+  /**
+   * Find a column by a name (e.g., col1).
+   * The same name columns can be exist in a schema. For example, table1.col1 and table2.col1 coexist in a schema.
+   * In this case, it will throw {@link java.lang.RuntimeException}. But, it occurs rarely because all column names
+   * except for alias have a qualified form.
+   *
+   * @param columnName The column name without qualifier
+   * @return The Column matched to a given name.
+   */
+	private Column getColumnByName(String columnName) {
+    String normalized = columnName.toLowerCase();
 	  List<Integer> list = fieldsByName.get(normalized);
 
     if (list == null || list.size() == 0) {
@@ -188,7 +210,7 @@ public class Schema implements ProtoObject<SchemaProto>, Cloneable, GsonObject {
 
   public int getColumnIdByName(String colName) {
     for (Column col : fields) {
-      if (col.getColumnName().equals(colName.toLowerCase())) {
+      if (col.getSimpleName().equals(colName.toLowerCase())) {
         String qualifiedName = col.getQualifiedName();
         return fieldsByQualifiedName.get(qualifiedName);
       }
@@ -218,13 +240,13 @@ public class Schema implements ProtoObject<SchemaProto>, Cloneable, GsonObject {
     if (column.hasQualifier()) {
       return fieldsByQualifiedName.containsKey(column.getQualifiedName());
     } else {
-      if (fieldsByName.containsKey(column.getColumnName())) {
-        int num = fieldsByName.get(column.getColumnName()).size();
+      if (fieldsByName.containsKey(column.getSimpleName())) {
+        int num = fieldsByName.get(column.getSimpleName()).size();
         if (num == 0) {
-          throw new IllegalStateException("No such column name: " + column.getColumnName());
+          throw new IllegalStateException("No such column name: " + column.getSimpleName());
         }
         if (num > 1) {
-          throw new RuntimeException("Ambiguous column name: " + column.getColumnName());
+          throw new RuntimeException("Ambiguous column name: " + column.getSimpleName());
         }
         return true;
       }
@@ -265,7 +287,7 @@ public class Schema implements ProtoObject<SchemaProto>, Cloneable, GsonObject {
 		Column newCol = new Column(normalized, dataType);
 		fields.add(newCol);
 		fieldsByQualifiedName.put(newCol.getQualifiedName(), fields.size() - 1);
-    fieldsByName.put(newCol.getColumnName(), TUtil.newList(fields.size() - 1));
+    fieldsByName.put(newCol.getSimpleName(), TUtil.newList(fields.size() - 1));
 		
 		return this;
 	}
@@ -320,7 +342,7 @@ public class Schema implements ProtoObject<SchemaProto>, Cloneable, GsonObject {
 
 	public String toString() {
 	  StringBuilder sb = new StringBuilder();
-	  sb.append("{(").append(getColumnNum()).append(") ");
+	  sb.append("{(").append(size()).append(") ");
 	  int i = 0;
 	  for(Column col : fields) {
 	    sb.append(col);
@@ -337,7 +359,6 @@ public class Schema implements ProtoObject<SchemaProto>, Cloneable, GsonObject {
   @Override
 	public String toJson() {
 	  return CatalogGsonHelper.toJson(this, Schema.class);
-		
 	}
 
   public Column [] toArray() {

http://git-wip-us.apache.org/repos/asf/incubator-tajo/blob/e2f4798b/tajo-catalog/tajo-catalog-common/src/main/proto/CatalogProtos.proto
----------------------------------------------------------------------
diff --git a/tajo-catalog/tajo-catalog-common/src/main/proto/CatalogProtos.proto b/tajo-catalog/tajo-catalog-common/src/main/proto/CatalogProtos.proto
index 47792a6..f5fff2c 100644
--- a/tajo-catalog/tajo-catalog-common/src/main/proto/CatalogProtos.proto
+++ b/tajo-catalog/tajo-catalog-common/src/main/proto/CatalogProtos.proto
@@ -70,8 +70,7 @@ message ColumnMetaProto {
 }
 
 message ColumnProto {
-	required string columnName = 1;
-	optional string qualifier = 2;
+	required string name = 1;
 	required DataType dataType = 3;
 }
 

http://git-wip-us.apache.org/repos/asf/incubator-tajo/blob/e2f4798b/tajo-catalog/tajo-catalog-common/src/test/java/org/apache/tajo/catalog/TestColumn.java
----------------------------------------------------------------------
diff --git a/tajo-catalog/tajo-catalog-common/src/test/java/org/apache/tajo/catalog/TestColumn.java b/tajo-catalog/tajo-catalog-common/src/test/java/org/apache/tajo/catalog/TestColumn.java
index 81677c5..ef08d51 100644
--- a/tajo-catalog/tajo-catalog-common/src/test/java/org/apache/tajo/catalog/TestColumn.java
+++ b/tajo-catalog/tajo-catalog-common/src/test/java/org/apache/tajo/catalog/TestColumn.java
@@ -76,9 +76,8 @@ public class TestColumn {
 	@Test
 	public final void testQualifiedName() {
 	  Column col = new Column("table_1.id", Type.INT4);
-	  
 	  assertTrue(col.hasQualifier());
-	  assertEquals("id", col.getColumnName());
+	  assertEquals("id", col.getSimpleName());
 	  assertEquals("table_1.id", col.getQualifiedName());
 	  assertEquals("table_1", col.getQualifier());
 	}
@@ -88,7 +87,7 @@ public class TestColumn {
     Column col = new Column("database1.table_1.id", Type.INT4);
 
     assertTrue(col.hasQualifier());
-    assertEquals("id", col.getColumnName());
+    assertEquals("id", col.getSimpleName());
     assertEquals("database1.table_1.id", col.getQualifiedName());
     assertEquals("database1.table_1", col.getQualifier());
   }

http://git-wip-us.apache.org/repos/asf/incubator-tajo/blob/e2f4798b/tajo-catalog/tajo-catalog-common/src/test/java/org/apache/tajo/catalog/TestSchema.java
----------------------------------------------------------------------
diff --git a/tajo-catalog/tajo-catalog-common/src/test/java/org/apache/tajo/catalog/TestSchema.java b/tajo-catalog/tajo-catalog-common/src/test/java/org/apache/tajo/catalog/TestSchema.java
index c879ecb..a61b422 100644
--- a/tajo-catalog/tajo-catalog-common/src/test/java/org/apache/tajo/catalog/TestSchema.java
+++ b/tajo-catalog/tajo-catalog-common/src/test/java/org/apache/tajo/catalog/TestSchema.java
@@ -61,9 +61,9 @@ public class TestSchema {
 
 	@Test
 	public final void testGetColumnString() {
-		assertEquals(col1, schema.getColumnByFQN("name"));
-		assertEquals(col2, schema.getColumnByFQN("age"));
-		assertEquals(col3, schema.getColumnByFQN("addr"));
+		assertEquals(col1, schema.getColumn("name"));
+		assertEquals(col2, schema.getColumn("age"));
+		assertEquals(col3, schema.getColumn("addr"));
 	}
 
 	@Test
@@ -88,9 +88,9 @@ public class TestSchema {
 	public final void testGetProto() {
 		SchemaProto proto = schema.getProto();
 		
-		assertEquals("name", proto.getFields(0).getColumnName());
-		assertEquals("age", proto.getFields(1).getColumnName());
-		assertEquals("addr", proto.getFields(2).getColumnName());
+		assertEquals("name", proto.getFields(0).getName());
+		assertEquals("age", proto.getFields(1).getName());
+		assertEquals("addr", proto.getFields(2).getName());
 	}
 	
 	@Test
@@ -102,12 +102,12 @@ public class TestSchema {
 	  Schema schema2 = new Schema(schema.getProto());
 	  assertEquals(schema.getProto(), schema2.getProto());
 	  assertEquals(schema.getColumn(0), schema2.getColumn(0));
-	  assertEquals(schema.getColumnNum(), schema2.getColumnNum());
+	  assertEquals(schema.size(), schema2.size());
 	  
 	  Schema schema3 = (Schema) schema.clone();
 	  assertEquals(schema.getProto(), schema3.getProto());
     assertEquals(schema.getColumn(0), schema3.getColumn(0));
-    assertEquals(schema.getColumnNum(), schema3.getColumnNum());
+    assertEquals(schema.size(), schema3.size());
 	}
 	
 	@Test(expected = AlreadyExistsFieldException.class)
@@ -141,32 +141,32 @@ public class TestSchema {
     schema2.setQualifier("test1");
     Column column = schema2.getColumn(1);
     assertEquals(1, schema2.getColumnIdByName("age"));
-    assertEquals(column, schema2.getColumnByName("age"));
-    assertEquals(column, schema2.getColumnByFQN("test1.age"));
+    assertEquals(column, schema2.getColumn("age"));
+    assertEquals(column, schema2.getColumn("test1.age"));
 
     Schema schema3 = new Schema();
     schema3.addColumn("tb1.col1", Type.INT4);
     schema3.addColumn("col2", Type.INT4);
     assertEquals("tb1", schema3.getColumn(0).getQualifier());
     assertEquals("tb1.col1", schema3.getColumn(0).getQualifiedName());
-    assertEquals("col1", schema3.getColumn(0).getColumnName());
+    assertEquals("col1", schema3.getColumn(0).getSimpleName());
     assertEquals("col2", schema3.getColumn(1).getQualifiedName());
 
-    assertEquals(schema3.getColumn(0), schema3.getColumnByName("col1"));
-    assertEquals(schema3.getColumn(0), schema3.getColumnByFQN("tb1.col1"));
-    assertEquals(schema3.getColumn(1), schema3.getColumnByName("col2"));
-    assertEquals(schema3.getColumn(1), schema3.getColumnByFQN("col2"));
+    assertEquals(schema3.getColumn(0), schema3.getColumn("col1"));
+    assertEquals(schema3.getColumn(0), schema3.getColumn("tb1.col1"));
+    assertEquals(schema3.getColumn(1), schema3.getColumn("col2"));
+    assertEquals(schema3.getColumn(1), schema3.getColumn("col2"));
 
     schema3.setQualifier("tb2");
     assertEquals("tb2", schema3.getColumn(0).getQualifier());
     assertEquals("tb2.col1", schema3.getColumn(0).getQualifiedName());
-    assertEquals("col1", schema3.getColumn(0).getColumnName());
+    assertEquals("col1", schema3.getColumn(0).getSimpleName());
     assertEquals("tb2.col2", schema3.getColumn(1).getQualifiedName());
 
-    assertEquals(schema3.getColumn(0), schema3.getColumnByName("col1"));
-    assertEquals(schema3.getColumn(0), schema3.getColumnByFQN("tb2.col1"));
-    assertEquals(schema3.getColumn(1), schema3.getColumnByName("col2"));
-    assertEquals(schema3.getColumn(1), schema3.getColumnByFQN("tb2.col2"));
+    assertEquals(schema3.getColumn(0), schema3.getColumn("col1"));
+    assertEquals(schema3.getColumn(0), schema3.getColumn("tb2.col1"));
+    assertEquals(schema3.getColumn(1), schema3.getColumn("col2"));
+    assertEquals(schema3.getColumn(1), schema3.getColumn("tb2.col2"));
 
   }
 }

http://git-wip-us.apache.org/repos/asf/incubator-tajo/blob/e2f4798b/tajo-catalog/tajo-catalog-drivers/tajo-hcatalog/src/main/java/org/apache/tajo/catalog/store/HCatalogStore.java
----------------------------------------------------------------------
diff --git a/tajo-catalog/tajo-catalog-drivers/tajo-hcatalog/src/main/java/org/apache/tajo/catalog/store/HCatalogStore.java b/tajo-catalog/tajo-catalog-drivers/tajo-hcatalog/src/main/java/org/apache/tajo/catalog/store/HCatalogStore.java
index bc43f2c..3dc0908 100644
--- a/tajo-catalog/tajo-catalog-drivers/tajo-hcatalog/src/main/java/org/apache/tajo/catalog/store/HCatalogStore.java
+++ b/tajo-catalog/tajo-catalog-drivers/tajo-hcatalog/src/main/java/org/apache/tajo/catalog/store/HCatalogStore.java
@@ -320,7 +320,7 @@ public class HCatalogStore extends CatalogConstants implements CatalogStore {
       ArrayList<FieldSchema> cols = new ArrayList<FieldSchema>(tableDesc.getSchema().getFieldsCount());
       for (CatalogProtos.ColumnProto col : tableDesc.getSchema().getFieldsList()) {
         cols.add(new FieldSchema(
-            col.getColumnName(),
+            col.getName(),
             HCatalogUtil.getHiveFieldType(col.getDataType().getType().name()),
             ""));
       }

http://git-wip-us.apache.org/repos/asf/incubator-tajo/blob/e2f4798b/tajo-catalog/tajo-catalog-drivers/tajo-hcatalog/src/test/java/org/apache/tajo/catalog/store/TestHCatalogStore.java
----------------------------------------------------------------------
diff --git a/tajo-catalog/tajo-catalog-drivers/tajo-hcatalog/src/test/java/org/apache/tajo/catalog/store/TestHCatalogStore.java b/tajo-catalog/tajo-catalog-drivers/tajo-hcatalog/src/test/java/org/apache/tajo/catalog/store/TestHCatalogStore.java
index 1abf022..82a334b 100644
--- a/tajo-catalog/tajo-catalog-drivers/tajo-hcatalog/src/test/java/org/apache/tajo/catalog/store/TestHCatalogStore.java
+++ b/tajo-catalog/tajo-catalog-drivers/tajo-hcatalog/src/test/java/org/apache/tajo/catalog/store/TestHCatalogStore.java
@@ -253,21 +253,21 @@ public class TestHCatalogStore {
     List<Column> columns = table.getSchema().getColumns();
     assertEquals(DB_NAME + "." + CUSTOMER, table.getName());
     assertEquals(8, columns.size());
-    assertEquals("c_custkey", columns.get(0).getColumnName());
+    assertEquals("c_custkey", columns.get(0).getSimpleName());
     assertEquals(TajoDataTypes.Type.INT4, columns.get(0).getDataType().getType());
-    assertEquals("c_name", columns.get(1).getColumnName());
+    assertEquals("c_name", columns.get(1).getSimpleName());
     assertEquals(TajoDataTypes.Type.TEXT, columns.get(1).getDataType().getType());
-    assertEquals("c_address", columns.get(2).getColumnName());
+    assertEquals("c_address", columns.get(2).getSimpleName());
     assertEquals(TajoDataTypes.Type.TEXT, columns.get(2).getDataType().getType());
-    assertEquals("c_nationkey", columns.get(3).getColumnName());
+    assertEquals("c_nationkey", columns.get(3).getSimpleName());
     assertEquals(TajoDataTypes.Type.INT4, columns.get(3).getDataType().getType());
-    assertEquals("c_phone", columns.get(4).getColumnName());
+    assertEquals("c_phone", columns.get(4).getSimpleName());
     assertEquals(TajoDataTypes.Type.TEXT, columns.get(4).getDataType().getType());
-    assertEquals("c_acctbal", columns.get(5).getColumnName());
+    assertEquals("c_acctbal", columns.get(5).getSimpleName());
     assertEquals(TajoDataTypes.Type.FLOAT8, columns.get(5).getDataType().getType());
-    assertEquals("c_mktsegment", columns.get(6).getColumnName());
+    assertEquals("c_mktsegment", columns.get(6).getSimpleName());
     assertEquals(TajoDataTypes.Type.TEXT, columns.get(6).getDataType().getType());
-    assertEquals("c_comment", columns.get(7).getColumnName());
+    assertEquals("c_comment", columns.get(7).getSimpleName());
     assertEquals(TajoDataTypes.Type.TEXT, columns.get(7).getDataType().getType());
     assertNull(table.getPartitionMethod());
     assertEquals(table.getMeta().getStoreType().name(), CatalogProtos.StoreType.RCFILE.name());
@@ -277,16 +277,16 @@ public class TestHCatalogStore {
     columns = table.getSchema().getColumns();
     assertEquals(DB_NAME + "." + NATION, table.getName());
     assertEquals(4, columns.size());
-    assertEquals("n_nationkey", columns.get(0).getColumnName());
+    assertEquals("n_nationkey", columns.get(0).getSimpleName());
     assertEquals(TajoDataTypes.Type.INT4, columns.get(0).getDataType().getType());
-    assertEquals("n_name", columns.get(1).getColumnName());
+    assertEquals("n_name", columns.get(1).getSimpleName());
     assertEquals(TajoDataTypes.Type.TEXT, columns.get(1).getDataType().getType());
-    assertEquals("n_regionkey", columns.get(2).getColumnName());
+    assertEquals("n_regionkey", columns.get(2).getSimpleName());
     assertEquals(TajoDataTypes.Type.INT4, columns.get(2).getDataType().getType());
-    assertEquals("n_comment", columns.get(3).getColumnName());
+    assertEquals("n_comment", columns.get(3).getSimpleName());
     assertEquals(TajoDataTypes.Type.TEXT, columns.get(3).getDataType().getType());
     assertNotNull(table.getPartitionMethod());
-    assertEquals("type", table.getPartitionMethod().getExpressionSchema().getColumn(0).getColumnName());
+    assertEquals("type", table.getPartitionMethod().getExpressionSchema().getColumn(0).getSimpleName());
     assertEquals(CatalogProtos.PartitionType.COLUMN, table.getPartitionMethod().getPartitionType());
 
     assertEquals(table.getMeta().getOption(HCatalogStore.CVSFILE_DELIMITER), "\\001");

http://git-wip-us.apache.org/repos/asf/incubator-tajo/blob/e2f4798b/tajo-catalog/tajo-catalog-server/src/main/java/org/apache/tajo/catalog/store/AbstractDBStore.java
----------------------------------------------------------------------
diff --git a/tajo-catalog/tajo-catalog-server/src/main/java/org/apache/tajo/catalog/store/AbstractDBStore.java b/tajo-catalog/tajo-catalog-server/src/main/java/org/apache/tajo/catalog/store/AbstractDBStore.java
index ae8a7d1..8c2c0c3 100644
--- a/tajo-catalog/tajo-catalog-server/src/main/java/org/apache/tajo/catalog/store/AbstractDBStore.java
+++ b/tajo-catalog/tajo-catalog-server/src/main/java/org/apache/tajo/catalog/store/AbstractDBStore.java
@@ -311,7 +311,7 @@ public abstract class AbstractDBStore extends CatalogConstants implements Catalo
         pstmt.setInt(1, tid);
         pstmt.setString(2, tableName);
         pstmt.setInt(3, i);
-        pstmt.setString(4, col.getColumnName());
+        pstmt.setString(4, CatalogUtil.extractSimpleName(col.getName()));
         pstmt.setString(5, col.getDataType().getType().name());
         pstmt.setInt(6, (col.getDataType().hasLength() ? col.getDataType().getLength() : 0));
         pstmt.addBatch();
@@ -1047,7 +1047,7 @@ public abstract class AbstractDBStore extends CatalogConstants implements Catalo
       sql.append("INSERT INTO indexes (index_name, ");
       sql.append(C_TABLE_ID);
       sql.append(", column_name, ");
-      sql.append( "data_type, index_type, is_unique, is_clustered, is_ascending) VALUES ");
+      sql.append("data_type, index_type, is_unique, is_clustered, is_ascending) VALUES ");
       sql.append("(?,?,?,?,?,?,?,?)");
 
       if (LOG.isDebugEnabled()) {
@@ -1059,7 +1059,7 @@ public abstract class AbstractDBStore extends CatalogConstants implements Catalo
 
       pstmt.setString(1, proto.getName());
       pstmt.setString(2, proto.getTableId());
-      pstmt.setString(3, proto.getColumn().getColumnName());
+      pstmt.setString(3, CatalogUtil.extractSimpleName(proto.getColumn().getName()));
       pstmt.setString(4, proto.getColumn().getDataType().getType().name());
       pstmt.setString(5, proto.getIndexMethod().toString());
       pstmt.setBoolean(6, proto.hasIsUnique() && proto.getIsUnique());
@@ -1306,7 +1306,7 @@ public abstract class AbstractDBStore extends CatalogConstants implements Catalo
    */
   private ColumnProto indexResultToColumnProto(final ResultSet res) throws SQLException {
     ColumnProto.Builder builder = ColumnProto.newBuilder();
-    builder.setColumnName(res.getString("column_name").trim());
+    builder.setName(res.getString("column_name").trim());
 
     Type type = getDataType(res.getString("data_type").trim());
     builder.setDataType(CatalogUtil.newSimpleDataType(type));
@@ -1316,7 +1316,7 @@ public abstract class AbstractDBStore extends CatalogConstants implements Catalo
 
   private ColumnProto resultToColumnProto(final ResultSet res) throws SQLException {
     ColumnProto.Builder builder = ColumnProto.newBuilder();
-    builder.setColumnName(res.getString("column_name").trim());
+    builder.setName(res.getString("column_name").trim());
 
     Type type = getDataType(res.getString("data_type").trim());
     int typeLength = res.getInt("type_length");
@@ -1340,24 +1340,6 @@ public abstract class AbstractDBStore extends CatalogConstants implements Catalo
     return setBuilder.build();
   }
 
-  private ColumnProto resultToQualifiedColumnProto(String tableName, final ResultSet res) throws SQLException {
-    ColumnProto.Builder builder = ColumnProto.newBuilder();
-
-    String columnName = tableName + "."
-        + res.getString("column_name").trim();
-    builder.setColumnName(columnName);
-
-    Type type = getDataType(res.getString("data_type").trim());
-    int typeLength = res.getInt("type_length");
-    if(typeLength > 0 ) {
-      builder.setDataType(CatalogUtil.newDataTypeWithLen(type, typeLength));
-    } else {
-      builder.setDataType(CatalogUtil.newSimpleDataType(type));
-    }
-
-    return builder.build();
-  }
-
   private IndexMethod getIndexMethod(final String typeStr) {
     if (typeStr.equals(IndexMethod.TWO_LEVEL_BIN_TREE.toString())) {
       return IndexMethod.TWO_LEVEL_BIN_TREE;

http://git-wip-us.apache.org/repos/asf/incubator-tajo/blob/e2f4798b/tajo-catalog/tajo-catalog-server/src/main/java/org/apache/tajo/catalog/store/MemStore.java
----------------------------------------------------------------------
diff --git a/tajo-catalog/tajo-catalog-server/src/main/java/org/apache/tajo/catalog/store/MemStore.java b/tajo-catalog/tajo-catalog-server/src/main/java/org/apache/tajo/catalog/store/MemStore.java
index e05e0ae..1fef286 100644
--- a/tajo-catalog/tajo-catalog-server/src/main/java/org/apache/tajo/catalog/store/MemStore.java
+++ b/tajo-catalog/tajo-catalog-server/src/main/java/org/apache/tajo/catalog/store/MemStore.java
@@ -172,7 +172,7 @@ public class MemStore implements CatalogStore {
     synchronized(indexes) {
       indexes.put(proto.getName(), proto);
       indexesByColumn.put(proto.getTableId() + "." 
-          + proto.getColumn().getColumnName(), proto);
+          + CatalogUtil.extractSimpleName(proto.getColumn().getName()), proto);
     }
   }
 

http://git-wip-us.apache.org/repos/asf/incubator-tajo/blob/e2f4798b/tajo-catalog/tajo-catalog-server/src/test/java/org/apache/tajo/catalog/TestCatalog.java
----------------------------------------------------------------------
diff --git a/tajo-catalog/tajo-catalog-server/src/test/java/org/apache/tajo/catalog/TestCatalog.java b/tajo-catalog/tajo-catalog-server/src/test/java/org/apache/tajo/catalog/TestCatalog.java
index 441ffe5..08905dd 100644
--- a/tajo-catalog/tajo-catalog-server/src/test/java/org/apache/tajo/catalog/TestCatalog.java
+++ b/tajo-catalog/tajo-catalog-server/src/test/java/org/apache/tajo/catalog/TestCatalog.java
@@ -276,7 +276,7 @@ public class TestCatalog {
 
     assertEquals(retrieved.getName(), tableName);
     assertEquals(retrieved.getPartitionMethod().getPartitionType(), CatalogProtos.PartitionType.HASH);
-    assertEquals(retrieved.getPartitionMethod().getExpressionSchema().getColumn(0).getColumnName(), "id");
+    assertEquals(retrieved.getPartitionMethod().getExpressionSchema().getColumn(0).getSimpleName(), "id");
 
     catalog.deleteTable(tableName);
     assertFalse(catalog.existsTable(tableName));
@@ -315,7 +315,7 @@ public class TestCatalog {
 
     assertEquals(retrieved.getName(), tableName);
     assertEquals(retrieved.getPartitionMethod().getPartitionType(), CatalogProtos.PartitionType.HASH);
-    assertEquals(retrieved.getPartitionMethod().getExpressionSchema().getColumn(0).getColumnName(), "id");
+    assertEquals(retrieved.getPartitionMethod().getExpressionSchema().getColumn(0).getSimpleName(), "id");
 
     catalog.deleteTable(tableName);
     assertFalse(catalog.existsTable(tableName));
@@ -352,7 +352,7 @@ public class TestCatalog {
 
     assertEquals(retrieved.getName(), tableName);
     assertEquals(retrieved.getPartitionMethod().getPartitionType(), CatalogProtos.PartitionType.LIST);
-    assertEquals(retrieved.getPartitionMethod().getExpressionSchema().getColumn(0).getColumnName(), "id");
+    assertEquals(retrieved.getPartitionMethod().getExpressionSchema().getColumn(0).getSimpleName(), "id");
 
     catalog.deleteTable(tableName);
     assertFalse(catalog.existsTable(tableName));
@@ -390,7 +390,7 @@ public class TestCatalog {
 
     assertEquals(retrieved.getName(), tableName);
     assertEquals(retrieved.getPartitionMethod().getPartitionType(), CatalogProtos.PartitionType.RANGE);
-    assertEquals(retrieved.getPartitionMethod().getExpressionSchema().getColumn(0).getColumnName(), "id");
+    assertEquals(retrieved.getPartitionMethod().getExpressionSchema().getColumn(0).getSimpleName(), "id");
 
     catalog.deleteTable(tableName);
     assertFalse(catalog.existsTable(tableName));
@@ -427,7 +427,7 @@ public class TestCatalog {
 
     assertEquals(retrieved.getName(), tableName);
     assertEquals(retrieved.getPartitionMethod().getPartitionType(), CatalogProtos.PartitionType.COLUMN);
-    assertEquals(retrieved.getPartitionMethod().getExpressionSchema().getColumn(0).getColumnName(), "id");
+    assertEquals(retrieved.getPartitionMethod().getExpressionSchema().getColumn(0).getSimpleName(), "id");
 
     catalog.deleteTable(tableName);
     assertFalse(catalog.existsTable(tableName));

http://git-wip-us.apache.org/repos/asf/incubator-tajo/blob/e2f4798b/tajo-catalog/tajo-catalog-server/src/test/java/org/apache/tajo/catalog/TestDBStore.java
----------------------------------------------------------------------
diff --git a/tajo-catalog/tajo-catalog-server/src/test/java/org/apache/tajo/catalog/TestDBStore.java b/tajo-catalog/tajo-catalog-server/src/test/java/org/apache/tajo/catalog/TestDBStore.java
index 502daf0..a6b5b9a 100644
--- a/tajo-catalog/tajo-catalog-server/src/test/java/org/apache/tajo/catalog/TestDBStore.java
+++ b/tajo-catalog/tajo-catalog-server/src/test/java/org/apache/tajo/catalog/TestDBStore.java
@@ -213,12 +213,12 @@ public class TestDBStore {
 
   public static void assertSchemaOrder(Schema s1, Schema s2) {
     // Schema order check
-    assertEquals(s1.getColumnNum(),
-        s2.getColumnNum());
+    assertEquals(s1.size(),
+        s2.size());
 
-    for (int i = 0; i < s1.getColumnNum(); i++) {
-      assertEquals(s1.getColumn(i).getColumnName(),
-          s2.getColumn(i).getColumnName());
+    for (int i = 0; i < s1.size(); i++) {
+      assertEquals(s1.getColumn(i).getSimpleName(),
+          s2.getColumn(i).getSimpleName());
     }
   }
 

http://git-wip-us.apache.org/repos/asf/incubator-tajo/blob/e2f4798b/tajo-client/src/main/java/org/apache/tajo/cli/DescTableCommand.java
----------------------------------------------------------------------
diff --git a/tajo-client/src/main/java/org/apache/tajo/cli/DescTableCommand.java b/tajo-client/src/main/java/org/apache/tajo/cli/DescTableCommand.java
index 8bf00e1..bdeb173 100644
--- a/tajo-client/src/main/java/org/apache/tajo/cli/DescTableCommand.java
+++ b/tajo-client/src/main/java/org/apache/tajo/cli/DescTableCommand.java
@@ -90,9 +90,9 @@ public class DescTableCommand extends TajoShellCommand {
     sb.append("\n");
     sb.append("schema: \n");
 
-    for(int i = 0; i < desc.getSchema().getColumnNum(); i++) {
+    for(int i = 0; i < desc.getSchema().size(); i++) {
       Column col = desc.getSchema().getColumn(i);
-      sb.append(col.getColumnName()).append("\t").append(col.getDataType().getType());
+      sb.append(col.getSimpleName()).append("\t").append(col.getDataType().getType());
       if (col.getDataType().hasLength()) {
         sb.append("(").append(col.getDataType().getLength()).append(")");
       }

http://git-wip-us.apache.org/repos/asf/incubator-tajo/blob/e2f4798b/tajo-client/src/main/java/org/apache/tajo/jdbc/TajoResultSetMetaData.java
----------------------------------------------------------------------
diff --git a/tajo-client/src/main/java/org/apache/tajo/jdbc/TajoResultSetMetaData.java b/tajo-client/src/main/java/org/apache/tajo/jdbc/TajoResultSetMetaData.java
index 98df048..4f2e586 100644
--- a/tajo-client/src/main/java/org/apache/tajo/jdbc/TajoResultSetMetaData.java
+++ b/tajo-client/src/main/java/org/apache/tajo/jdbc/TajoResultSetMetaData.java
@@ -62,7 +62,7 @@ public class TajoResultSetMetaData implements ResultSetMetaData {
     if(schema == null) {
       return 0;
     }
-    return schema.getColumnNum();
+    return schema.size();
   }
 
   @Override
@@ -77,7 +77,7 @@ public class TajoResultSetMetaData implements ResultSetMetaData {
 
   @Override
   public String getColumnName(int column) throws SQLException {
-    return schema.getColumn(column - 1).getColumnName();
+    return schema.getColumn(column - 1).getSimpleName();
   }
 
   @Override

http://git-wip-us.apache.org/repos/asf/incubator-tajo/blob/e2f4798b/tajo-common/src/main/java/org/apache/tajo/TajoConstants.java
----------------------------------------------------------------------
diff --git a/tajo-common/src/main/java/org/apache/tajo/TajoConstants.java b/tajo-common/src/main/java/org/apache/tajo/TajoConstants.java
index 8cdc7bb..d4ce48f 100644
--- a/tajo-common/src/main/java/org/apache/tajo/TajoConstants.java
+++ b/tajo-common/src/main/java/org/apache/tajo/TajoConstants.java
@@ -27,5 +27,7 @@ public class TajoConstants {
   public static final String SYSTEM_RESOURCE_DIR_NAME = "resource";
   public static final String RESULT_DIR_NAME="RESULT";
 
+  public static final String EMPTY_STRING = "";
+
   private TajoConstants() {}
 }

http://git-wip-us.apache.org/repos/asf/incubator-tajo/blob/e2f4798b/tajo-core/tajo-core-backend/src/main/java/org/apache/tajo/engine/eval/EvalTreeUtil.java
----------------------------------------------------------------------
diff --git a/tajo-core/tajo-core-backend/src/main/java/org/apache/tajo/engine/eval/EvalTreeUtil.java b/tajo-core/tajo-core-backend/src/main/java/org/apache/tajo/engine/eval/EvalTreeUtil.java
index 5f1035d..1e2298c 100644
--- a/tajo-core/tajo-core-backend/src/main/java/org/apache/tajo/engine/eval/EvalTreeUtil.java
+++ b/tajo-core/tajo-core-backend/src/main/java/org/apache/tajo/engine/eval/EvalTreeUtil.java
@@ -116,7 +116,7 @@ public class EvalTreeUtil {
 
     case FIELD:
       FieldEval fieldEval = (FieldEval) expr;
-      return inputSchema.getColumnByFQN(fieldEval.getName()).getDataType();
+      return inputSchema.getColumn(fieldEval.getName()).getDataType();
 
       
     default:
@@ -180,7 +180,7 @@ public class EvalTreeUtil {
     switch (expr.getType()) {
     case FIELD:
       FieldEval field = (FieldEval) expr;
-      if (field.getColumnName().equals(target.getColumnName())) {
+      if (field.getColumnName().equals(target.getSimpleName())) {
         exprSet.add(field);
       }
       break;

http://git-wip-us.apache.org/repos/asf/incubator-tajo/blob/e2f4798b/tajo-core/tajo-core-backend/src/main/java/org/apache/tajo/engine/eval/FieldEval.java
----------------------------------------------------------------------
diff --git a/tajo-core/tajo-core-backend/src/main/java/org/apache/tajo/engine/eval/FieldEval.java b/tajo-core/tajo-core-backend/src/main/java/org/apache/tajo/engine/eval/FieldEval.java
index dc9b35b..504023a 100644
--- a/tajo-core/tajo-core-backend/src/main/java/org/apache/tajo/engine/eval/FieldEval.java
+++ b/tajo-core/tajo-core-backend/src/main/java/org/apache/tajo/engine/eval/FieldEval.java
@@ -64,11 +64,11 @@ public class FieldEval extends EvalNode implements Cloneable {
 	}
 	
 	public String getColumnName() {
-	  return column.getColumnName();
+	  return column.getSimpleName();
 	}
 	
 	public void replaceColumnRef(String columnName) {
-	  this.column.setName(columnName);
+	  this.column = new Column(columnName, this.column.getDataType());
 	}
 
 	@Override

http://git-wip-us.apache.org/repos/asf/incubator-tajo/blob/e2f4798b/tajo-core/tajo-core-backend/src/main/java/org/apache/tajo/engine/planner/LogicalPlan.java
----------------------------------------------------------------------
diff --git a/tajo-core/tajo-core-backend/src/main/java/org/apache/tajo/engine/planner/LogicalPlan.java b/tajo-core/tajo-core-backend/src/main/java/org/apache/tajo/engine/planner/LogicalPlan.java
index 47bd166..5491fef 100644
--- a/tajo-core/tajo-core-backend/src/main/java/org/apache/tajo/engine/planner/LogicalPlan.java
+++ b/tajo-core/tajo-core-backend/src/main/java/org/apache/tajo/engine/planner/LogicalPlan.java
@@ -22,6 +22,7 @@ import com.google.common.collect.Lists;
 import org.apache.commons.lang.ObjectUtils;
 import org.apache.tajo.algebra.*;
 import org.apache.tajo.annotation.NotThreadSafe;
+import org.apache.tajo.catalog.CatalogUtil;
 import org.apache.tajo.catalog.Column;
 import org.apache.tajo.catalog.Schema;
 import org.apache.tajo.engine.eval.EvalNode;
@@ -241,7 +242,7 @@ public class LogicalPlan {
       }
 
       Schema schema = relationOp.getTableSchema();
-      Column column = schema.getColumnByFQN(columnRef.getCanonicalName());
+      Column column = schema.getColumn(columnRef.getCanonicalName());
       if (column == null) {
         throw new NoSuchColumnException(columnRef.getCanonicalName());
       }
@@ -283,7 +284,7 @@ public class LogicalPlan {
       }
 
       if (block.getLatestNode() != null) {
-        Column found = block.getLatestNode().getOutSchema().getColumnByName(columnRef.getName());
+        Column found = block.getLatestNode().getOutSchema().getColumn(columnRef.getName());
         if (found != null) {
           return found;
         }
@@ -304,7 +305,7 @@ public class LogicalPlan {
 
       // Trying to find columns from other relations in the current block
       for (RelationNode rel : block.getRelations()) {
-        Column found = rel.getTableSchema().getColumnByName(columnRef.getName());
+        Column found = rel.getTableSchema().getColumn(columnRef.getName());
         if (found != null) {
           candidates.add(found);
         }
@@ -317,7 +318,7 @@ public class LogicalPlan {
       // Trying to find columns from other relations in other blocks
       for (QueryBlock eachBlock : queryBlocks.values()) {
         for (RelationNode rel : eachBlock.getRelations()) {
-          Column found = rel.getTableSchema().getColumnByName(columnRef.getName());
+          Column found = rel.getTableSchema().getColumn(columnRef.getName());
           if (found != null) {
             candidates.add(found);
           }
@@ -330,7 +331,7 @@ public class LogicalPlan {
 
       // Trying to find columns from schema in current block.
       if (block.getSchema() != null) {
-        Column found = block.getSchema().getColumnByName(columnRef.getName());
+        Column found = block.getSchema().getColumn(columnRef.getName());
         if (found != null) {
           candidates.add(found);
         }
@@ -528,15 +529,15 @@ public class LogicalPlan {
     }
 
     public boolean existsRelation(String name) {
-      return nameToRelationMap.containsKey(PlannerUtil.normalizeTableName(name));
+      return nameToRelationMap.containsKey(CatalogUtil.normalizeIdentifier(name));
     }
 
     public RelationNode getRelation(String name) {
-      return nameToRelationMap.get(PlannerUtil.normalizeTableName(name));
+      return nameToRelationMap.get(CatalogUtil.normalizeIdentifier(name));
     }
 
     public void addRelation(RelationNode relation) {
-      nameToRelationMap.put(PlannerUtil.normalizeTableName(relation.getCanonicalName()), relation);
+      nameToRelationMap.put(CatalogUtil.normalizeIdentifier(relation.getCanonicalName()), relation);
     }
 
     public Collection<RelationNode> getRelations() {

http://git-wip-us.apache.org/repos/asf/incubator-tajo/blob/e2f4798b/tajo-core/tajo-core-backend/src/main/java/org/apache/tajo/engine/planner/LogicalPlanPreprocessor.java
----------------------------------------------------------------------
diff --git a/tajo-core/tajo-core-backend/src/main/java/org/apache/tajo/engine/planner/LogicalPlanPreprocessor.java b/tajo-core/tajo-core-backend/src/main/java/org/apache/tajo/engine/planner/LogicalPlanPreprocessor.java
index a6bedcf..818e01c 100644
--- a/tajo-core/tajo-core-backend/src/main/java/org/apache/tajo/engine/planner/LogicalPlanPreprocessor.java
+++ b/tajo-core/tajo-core-backend/src/main/java/org/apache/tajo/engine/planner/LogicalPlanPreprocessor.java
@@ -32,11 +32,7 @@ import org.apache.tajo.engine.planner.logical.*;
 import org.apache.tajo.engine.utils.SchemaUtil;
 import org.apache.tajo.util.TUtil;
 
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Stack;
+import java.util.*;
 
 /**
  * It finds all relations for each block and builds base schema information.
@@ -116,7 +112,7 @@ class LogicalPlanPreprocessor extends BaseAlgebraVisitor<LogicalPlanPreprocessor
       }
 
       Schema schema = relationOp.getTableSchema();
-      Column[] resolvedColumns = new Column[schema.getColumnNum()];
+      Column[] resolvedColumns = new Column[schema.size()];
       return schema.getColumns().toArray(resolvedColumns);
     } else { // if a column reference is not qualified
       // columns of every relation should be resolved.
@@ -151,7 +147,7 @@ class LogicalPlanPreprocessor extends BaseAlgebraVisitor<LogicalPlanPreprocessor
     List<NamedExpr> newTargetExprs = new ArrayList<NamedExpr>(columns.length);
     int i;
     for (i = 0; i < columns.length; i++) {
-      newTargetExprs.add(new NamedExpr(new ColumnReferenceExpr(columns[i].getQualifier(), columns[i].getColumnName())));
+      newTargetExprs.add(new NamedExpr(new ColumnReferenceExpr(columns[i].getQualifier(), columns[i].getSimpleName())));
     }
     return newTargetExprs;
   }

http://git-wip-us.apache.org/repos/asf/incubator-tajo/blob/e2f4798b/tajo-core/tajo-core-backend/src/main/java/org/apache/tajo/engine/planner/LogicalPlanVerifier.java
----------------------------------------------------------------------
diff --git a/tajo-core/tajo-core-backend/src/main/java/org/apache/tajo/engine/planner/LogicalPlanVerifier.java b/tajo-core/tajo-core-backend/src/main/java/org/apache/tajo/engine/planner/LogicalPlanVerifier.java
index 6800519..305548c 100644
--- a/tajo-core/tajo-core-backend/src/main/java/org/apache/tajo/engine/planner/LogicalPlanVerifier.java
+++ b/tajo-core/tajo-core-backend/src/main/java/org/apache/tajo/engine/planner/LogicalPlanVerifier.java
@@ -44,18 +44,18 @@ public class LogicalPlanVerifier extends BasicLogicalPlanVisitor<VerificationSta
     Schema outputSchema = node.getOutSchema();
     Schema targetSchema = PlannerUtil.targetToSchema(node.getTargets());
 
-    if (outputSchema.getColumnNum() != node.getTargets().length) {
+    if (outputSchema.size() != node.getTargets().length) {
       throw new PlanningException(String.format("Output schema and Target's schema are mismatched at Node (%d)",
           + node.getPID()));
     }
 
-    for (int i = 0; i < outputSchema.getColumnNum(); i++) {
+    for (int i = 0; i < outputSchema.size(); i++) {
       if (!outputSchema.getColumn(i).getDataType().equals(targetSchema.getColumn(i).getDataType())) {
         Column targetColumn = targetSchema.getColumn(i);
         Column insertColumn = outputSchema.getColumn(i);
         throw new PlanningException("ERROR: " +
-            insertColumn.getColumnName() + " is of type " + insertColumn.getDataType().getType().name() +
-            ", but target column '" + targetColumn.getColumnName() + "' is of type " +
+            insertColumn.getSimpleName() + " is of type " + insertColumn.getDataType().getType().name() +
+            ", but target column '" + targetColumn.getSimpleName() + "' is of type " +
             targetColumn.getDataType().getType().name());
       }
     }
@@ -126,7 +126,7 @@ public class LogicalPlanVerifier extends BasicLogicalPlanVisitor<VerificationSta
     Schema right = setNode.getRightChild().getOutSchema();
     NodeType type = setNode.getType();
 
-    if (left.getColumnNum() != right.getColumnNum()) {
+    if (left.size() != right.size()) {
       state.addVerification("each " + type.name() + " query must have the same number of columns");
       return;
     }
@@ -203,13 +203,13 @@ public class LogicalPlanVerifier extends BasicLogicalPlanVisitor<VerificationSta
    */
   private static void ensureDomains(VerificationState state, Schema targetTableScheme, Schema schema)
       throws PlanningException {
-    for (int i = 0; i < schema.getColumnNum(); i++) {
+    for (int i = 0; i < schema.size(); i++) {
       if (!schema.getColumn(i).getDataType().equals(targetTableScheme.getColumn(i).getDataType())) {
         Column targetColumn = targetTableScheme.getColumn(i);
         Column insertColumn = schema.getColumn(i);
         state.addVerification("ERROR: " +
-            insertColumn.getColumnName() + " is of type " + insertColumn.getDataType().getType().name() +
-            ", but target column '" + targetColumn.getColumnName() + "' is of type " +
+            insertColumn.getSimpleName() + " is of type " + insertColumn.getDataType().getType().name() +
+            ", but target column '" + targetColumn.getSimpleName() + "' is of type " +
             targetColumn.getDataType().getType().name());
       }
     }

http://git-wip-us.apache.org/repos/asf/incubator-tajo/blob/e2f4798b/tajo-core/tajo-core-backend/src/main/java/org/apache/tajo/engine/planner/LogicalPlanner.java
----------------------------------------------------------------------
diff --git a/tajo-core/tajo-core-backend/src/main/java/org/apache/tajo/engine/planner/LogicalPlanner.java b/tajo-core/tajo-core-backend/src/main/java/org/apache/tajo/engine/planner/LogicalPlanner.java
index e5e84a7..2a4e151 100644
--- a/tajo-core/tajo-core-backend/src/main/java/org/apache/tajo/engine/planner/LogicalPlanner.java
+++ b/tajo-core/tajo-core-backend/src/main/java/org/apache/tajo/engine/planner/LogicalPlanner.java
@@ -857,8 +857,8 @@ public class LogicalPlanner extends BaseAlgebraVisitor<LogicalPlanner.PlanContex
     Column rightJoinKey;
 
     for (Column common : commons.getColumns()) {
-      leftJoinKey = leftSchema.getColumnByName(common.getColumnName());
-      rightJoinKey = rightSchema.getColumnByName(common.getColumnName());
+      leftJoinKey = leftSchema.getColumn(common.getQualifiedName());
+      rightJoinKey = rightSchema.getColumn(common.getQualifiedName());
       equiQual = new BinaryEval(EvalType.EQUAL,
           new FieldEval(leftJoinKey), new FieldEval(rightJoinKey));
       if (njQual == null) {
@@ -1177,7 +1177,7 @@ public class LogicalPlanner extends BaseAlgebraVisitor<LogicalPlanner.PlanContex
 
     if (expr.hasTargetColumns()) { // when a user specified target columns
 
-      if (expr.getTargetColumns().length > insertNode.getChild().getOutSchema().getColumnNum()) {
+      if (expr.getTargetColumns().length > insertNode.getChild().getOutSchema().size()) {
         throw new PlanningException("Target columns and projected columns are mismatched to each other");
       }
 
@@ -1202,7 +1202,7 @@ public class LogicalPlanner extends BaseAlgebraVisitor<LogicalPlanner.PlanContex
       Schema projectedSchema = insertNode.getChild().getOutSchema();
 
       Schema targetColumns = new Schema();
-      for (int i = 0; i < projectedSchema.getColumnNum(); i++) {
+      for (int i = 0; i < projectedSchema.size(); i++) {
         targetColumns.addColumn(tableSchema.getColumn(i));
       }
       insertNode.setTargetSchema(targetColumns);
@@ -1224,13 +1224,13 @@ public class LogicalPlanner extends BaseAlgebraVisitor<LogicalPlanner.PlanContex
     // Modifying projected columns by adding NULL constants
     // It is because that table appender does not support target columns to be written.
     List<Target> targets = TUtil.newList();
-    for (int i = 0, j = 0; i < tableSchema.getColumnNum(); i++) {
+    for (int i = 0, j = 0; i < tableSchema.size(); i++) {
       Column column = tableSchema.getColumn(i);
 
       if(targetColumns.contains(column) && j < projectionNode.getTargets().length) {
         targets.add(projectionNode.getTargets()[j++]);
       } else {
-        targets.add(new Target(new ConstEval(NullDatum.get()), column.getColumnName()));
+        targets.add(new Target(new ConstEval(NullDatum.get()), column.getSimpleName()));
       }
     }
     projectionNode.setTargets(targets.toArray(new Target[targets.size()]));
@@ -1321,11 +1321,11 @@ public class LogicalPlanner extends BaseAlgebraVisitor<LogicalPlanner.PlanContex
           Schema queryOutputSchema = subQuery.getOutSchema();
           Schema partitionExpressionSchema = partitionMethod.getExpressionSchema();
           if (partitionMethod.getPartitionType() == CatalogProtos.PartitionType.COLUMN &&
-              queryOutputSchema.getColumnNum() < partitionExpressionSchema.getColumnNum()) {
+              queryOutputSchema.size() < partitionExpressionSchema.size()) {
             throw new VerifyException("Partition columns cannot be more than table columns.");
           }
           Schema tableSchema = new Schema();
-          for (int i = 0; i < queryOutputSchema.getColumnNum() - partitionExpressionSchema.getColumnNum(); i++) {
+          for (int i = 0; i < queryOutputSchema.size() - partitionExpressionSchema.size(); i++) {
             tableSchema.addColumn(queryOutputSchema.getColumn(i));
           }
           createTableNode.setOutSchema(tableSchema);

http://git-wip-us.apache.org/repos/asf/incubator-tajo/blob/e2f4798b/tajo-core/tajo-core-backend/src/main/java/org/apache/tajo/engine/planner/PlannerUtil.java
----------------------------------------------------------------------
diff --git a/tajo-core/tajo-core-backend/src/main/java/org/apache/tajo/engine/planner/PlannerUtil.java b/tajo-core/tajo-core-backend/src/main/java/org/apache/tajo/engine/planner/PlannerUtil.java
index 8017331..4f1421b 100644
--- a/tajo-core/tajo-core-backend/src/main/java/org/apache/tajo/engine/planner/PlannerUtil.java
+++ b/tajo-core/tajo-core-backend/src/main/java/org/apache/tajo/engine/planner/PlannerUtil.java
@@ -41,9 +41,6 @@ import org.apache.tajo.util.TUtil;
 import java.util.*;
 
 public class PlannerUtil {
-  public static String normalizeTableName(String tableName) {
-    return tableName.toLowerCase();
-  }
 
   public static boolean checkIfDDLPlan(LogicalNode node) {
     LogicalNode baseNode = node;
@@ -334,82 +331,6 @@ public class PlannerUtil {
     return (T) finder.getFoundNodes().get(0);
   }
 
-  public static boolean canBeEvaluated(EvalNode eval, LogicalNode node) {
-    Set<Column> columnRefs = EvalTreeUtil.findUniqueColumns(eval);
-
-    if (node.getType() == NodeType.JOIN) {
-      JoinNode joinNode = (JoinNode) node;
-      Set<String> tableIds = Sets.newHashSet();
-      // getting distinct table references
-      for (Column col : columnRefs) {
-        if (!tableIds.contains(col.getQualifier())) {
-          tableIds.add(col.getQualifier());
-        }
-      }
-
-      // if the references only indicate two relation, the condition can be
-      // pushed into a join operator.
-      if (tableIds.size() != 2) {
-        return false;
-      }
-
-      String [] outer = getRelationLineage(joinNode.getLeftChild());
-      String [] inner = getRelationLineage(joinNode.getRightChild());
-
-      Set<String> o = Sets.newHashSet(outer);
-      Set<String> i = Sets.newHashSet(inner);
-      if (outer == null || inner == null) {
-        throw new InvalidQueryException("ERROR: Unexpected logical plan");
-      }
-      Iterator<String> it = tableIds.iterator();
-      if (o.contains(it.next()) && i.contains(it.next())) {
-        return true;
-      }
-
-      it = tableIds.iterator();
-
-      return i.contains(it.next()) && o.contains(it.next());
-
-    } else if (node instanceof ScanNode) {
-
-      RelationNode scan = (RelationNode) node;
-
-      for (Column col : columnRefs) {
-        if (scan.getCanonicalName().equals(col.getQualifier())) {
-          Column found = scan.getTableSchema().getColumnByName(col.getColumnName());
-          if (found == null) {
-            return false;
-          }
-        } else {
-          return false;
-        }
-      }
-
-    } else if (node instanceof TableSubQueryNode) {
-      TableSubQueryNode subQueryNode = (TableSubQueryNode) node;
-      for (Column col : columnRefs) {
-        if (subQueryNode.getCanonicalName().equals(col.getQualifier())) {
-          Column found = node.getOutSchema().getColumnByName(col.getColumnName());
-          if (found == null) {
-            return false;
-          }
-        } else {
-          return false;
-        }
-      }
-
-    } else {
-
-      for (Column col : columnRefs) {
-        if (!node.getInSchema().containsByQualifiedName(col.getQualifiedName())) {
-          return false;
-        }
-      }
-    }
-
-    return true;
-  }
-
   private static class LogicalNodeFinder implements LogicalNodeVisitor {
     private List<LogicalNode> list = new ArrayList<LogicalNode>();
     private final NodeType[] tofind;
@@ -485,17 +406,17 @@ public class PlannerUtil {
    */
   public static void schemaToTargets(Schema schema, Target [] targets) {
     FieldEval eval;
-    for (int i = 0; i < schema.getColumnNum(); i++) {
+    for (int i = 0; i < schema.size(); i++) {
       eval = new FieldEval(schema.getColumn(i));
       targets[i] = new Target(eval);
     }
   }
 
   public static Target[] schemaToTargets(Schema schema) {
-    Target[] targets = new Target[schema.getColumnNum()];
+    Target[] targets = new Target[schema.size()];
 
     FieldEval eval;
-    for (int i = 0; i < schema.getColumnNum(); i++) {
+    for (int i = 0; i < schema.size(); i++) {
       eval = new FieldEval(schema.getColumn(i));
       targets[i] = new Target(eval);
     }
@@ -506,7 +427,7 @@ public class PlannerUtil {
     List<Target> targets = TUtil.newList();
 
     FieldEval eval;
-    for (int i = 0; i < schema.getColumnNum(); i++) {
+    for (int i = 0; i < schema.size(); i++) {
       eval = new FieldEval(schema.getColumn(i));
       targets.add(new Target(eval));
     }
@@ -683,7 +604,7 @@ public class PlannerUtil {
       if (copy[i].getEvalTree().getType() == EvalType.FIELD) {
         FieldEval fieldEval = copy[i].getEvalTree();
         if (fieldEval.getColumnRef().hasQualifier()) {
-          fieldEval.getColumnRef().setName(fieldEval.getColumnName());
+          fieldEval.replaceColumnRef(fieldEval.getColumnName());
         }
       }
     }

http://git-wip-us.apache.org/repos/asf/incubator-tajo/blob/e2f4798b/tajo-core/tajo-core-backend/src/main/java/org/apache/tajo/engine/planner/enforce/Enforcer.java
----------------------------------------------------------------------
diff --git a/tajo-core/tajo-core-backend/src/main/java/org/apache/tajo/engine/planner/enforce/Enforcer.java b/tajo-core/tajo-core-backend/src/main/java/org/apache/tajo/engine/planner/enforce/Enforcer.java
index da8cb01..91190f6 100644
--- a/tajo-core/tajo-core-backend/src/main/java/org/apache/tajo/engine/planner/enforce/Enforcer.java
+++ b/tajo-core/tajo-core-backend/src/main/java/org/apache/tajo/engine/planner/enforce/Enforcer.java
@@ -213,7 +213,7 @@ public class Enforcer implements ProtoObject<EnforcerProto> {
           } else {
             sb.append(", ");
           }
-          sb.append(sortSpec.getColumn().getColumnName());
+          sb.append(sortSpec.getColumn().getName());
           sb.append(" (").append(sortSpec.getAscending() ? "asc":"desc").append(")");
         }
       }

http://git-wip-us.apache.org/repos/asf/incubator-tajo/blob/e2f4798b/tajo-core/tajo-core-backend/src/main/java/org/apache/tajo/engine/planner/global/GlobalPlanner.java
----------------------------------------------------------------------
diff --git a/tajo-core/tajo-core-backend/src/main/java/org/apache/tajo/engine/planner/global/GlobalPlanner.java b/tajo-core/tajo-core-backend/src/main/java/org/apache/tajo/engine/planner/global/GlobalPlanner.java
index 15aa00f..258a2e7 100644
--- a/tajo-core/tajo-core-backend/src/main/java/org/apache/tajo/engine/planner/global/GlobalPlanner.java
+++ b/tajo-core/tajo-core-backend/src/main/java/org/apache/tajo/engine/planner/global/GlobalPlanner.java
@@ -847,7 +847,7 @@ public class GlobalPlanner {
     if (node.getType() == NodeType.INSERT) {
       InsertNode insertNode = (InsertNode) node;
       channel.setSchema(((InsertNode)node).getProjectedSchema());
-      Column [] shuffleKeys = new Column[partitionMethod.getExpressionSchema().getColumnNum()];
+      Column [] shuffleKeys = new Column[partitionMethod.getExpressionSchema().size()];
       int i = 0;
       for (Column column : partitionMethod.getExpressionSchema().getColumns()) {
         int id = insertNode.getTableSchema().getColumnId(column.getQualifiedName());

http://git-wip-us.apache.org/repos/asf/incubator-tajo/blob/e2f4798b/tajo-core/tajo-core-backend/src/main/java/org/apache/tajo/engine/planner/logical/GroupbyNode.java
----------------------------------------------------------------------
diff --git a/tajo-core/tajo-core-backend/src/main/java/org/apache/tajo/engine/planner/logical/GroupbyNode.java b/tajo-core/tajo-core-backend/src/main/java/org/apache/tajo/engine/planner/logical/GroupbyNode.java
index a7f36ec..38ca29b 100644
--- a/tajo-core/tajo-core-backend/src/main/java/org/apache/tajo/engine/planner/logical/GroupbyNode.java
+++ b/tajo-core/tajo-core-backend/src/main/java/org/apache/tajo/engine/planner/logical/GroupbyNode.java
@@ -171,7 +171,7 @@ public class GroupbyNode extends UnaryNode implements Projectable, Cloneable {
     sb.append("(");
     Column [] groupingColumns = this.groupingColumns;
     for (int j = 0; j < groupingColumns.length; j++) {
-      sb.append(groupingColumns[j].getColumnName());
+      sb.append(groupingColumns[j].getSimpleName());
       if(j < groupingColumns.length - 1) {
         sb.append(",");
       }

http://git-wip-us.apache.org/repos/asf/incubator-tajo/blob/e2f4798b/tajo-core/tajo-core-backend/src/main/java/org/apache/tajo/engine/planner/logical/ScanNode.java
----------------------------------------------------------------------
diff --git a/tajo-core/tajo-core-backend/src/main/java/org/apache/tajo/engine/planner/logical/ScanNode.java b/tajo-core/tajo-core-backend/src/main/java/org/apache/tajo/engine/planner/logical/ScanNode.java
index aa91090..0ec8110 100644
--- a/tajo-core/tajo-core-backend/src/main/java/org/apache/tajo/engine/planner/logical/ScanNode.java
+++ b/tajo-core/tajo-core-backend/src/main/java/org/apache/tajo/engine/planner/logical/ScanNode.java
@@ -20,6 +20,7 @@ package org.apache.tajo.engine.planner.logical;
 
 import com.google.common.base.Objects;
 import com.google.gson.annotations.Expose;
+import org.apache.tajo.catalog.CatalogUtil;
 import org.apache.tajo.catalog.Schema;
 import org.apache.tajo.catalog.TableDesc;
 import org.apache.tajo.engine.eval.EvalNode;
@@ -51,7 +52,7 @@ public class ScanNode extends RelationNode implements Projectable {
   
 	public ScanNode(int pid, TableDesc desc, String alias) {
     this(pid, desc);
-    this.alias = PlannerUtil.normalizeTableName(alias);
+    this.alias = CatalogUtil.normalizeIdentifier(alias);
     this.setInSchema(tableDesc.getSchema());
     this.getInSchema().setQualifier(alias);
     this.setOutSchema(new Schema(getInSchema()));

http://git-wip-us.apache.org/repos/asf/incubator-tajo/blob/e2f4798b/tajo-core/tajo-core-backend/src/main/java/org/apache/tajo/engine/planner/logical/SortNode.java
----------------------------------------------------------------------
diff --git a/tajo-core/tajo-core-backend/src/main/java/org/apache/tajo/engine/planner/logical/SortNode.java b/tajo-core/tajo-core-backend/src/main/java/org/apache/tajo/engine/planner/logical/SortNode.java
index 8154016..a732710 100644
--- a/tajo-core/tajo-core-backend/src/main/java/org/apache/tajo/engine/planner/logical/SortNode.java
+++ b/tajo-core/tajo-core-backend/src/main/java/org/apache/tajo/engine/planner/logical/SortNode.java
@@ -65,7 +65,7 @@ public final class SortNode extends UnaryNode implements Cloneable {
     PlanString planStr = new PlanString(this);
     StringBuilder sb = new StringBuilder("Sort Keys: ");
     for (int i = 0; i < sortKeys.length; i++) {
-      sb.append(sortKeys[i].getSortKey().getColumnName()).append(" ")
+      sb.append(sortKeys[i].getSortKey().getSimpleName()).append(" ")
           .append(sortKeys[i].isAscending() ? "asc" : "desc");
       if( i < sortKeys.length - 1) {
         sb.append(",");

http://git-wip-us.apache.org/repos/asf/incubator-tajo/blob/e2f4798b/tajo-core/tajo-core-backend/src/main/java/org/apache/tajo/engine/planner/logical/TableSubQueryNode.java
----------------------------------------------------------------------
diff --git a/tajo-core/tajo-core-backend/src/main/java/org/apache/tajo/engine/planner/logical/TableSubQueryNode.java b/tajo-core/tajo-core-backend/src/main/java/org/apache/tajo/engine/planner/logical/TableSubQueryNode.java
index e205454..3f251f8 100644
--- a/tajo-core/tajo-core-backend/src/main/java/org/apache/tajo/engine/planner/logical/TableSubQueryNode.java
+++ b/tajo-core/tajo-core-backend/src/main/java/org/apache/tajo/engine/planner/logical/TableSubQueryNode.java
@@ -20,6 +20,7 @@ package org.apache.tajo.engine.planner.logical;
 
 import com.google.common.base.Objects;
 import com.google.gson.annotations.Expose;
+import org.apache.tajo.catalog.CatalogUtil;
 import org.apache.tajo.catalog.Schema;
 import org.apache.tajo.engine.planner.PlanString;
 import org.apache.tajo.engine.planner.PlannerUtil;
@@ -34,7 +35,7 @@ public class TableSubQueryNode extends RelationNode implements Projectable {
 
   public TableSubQueryNode(int pid, String tableName, LogicalNode subQuery) {
     super(pid, NodeType.TABLE_SUBQUERY);
-    this.tableName = PlannerUtil.normalizeTableName(tableName);
+    this.tableName = CatalogUtil.normalizeIdentifier(tableName);
     if (subQuery != null) {
       this.subQuery = subQuery;
       setOutSchema(SchemaUtil.clone(this.subQuery.getOutSchema()));

http://git-wip-us.apache.org/repos/asf/incubator-tajo/blob/e2f4798b/tajo-core/tajo-core-backend/src/main/java/org/apache/tajo/engine/planner/logical/join/JoinGraph.java
----------------------------------------------------------------------
diff --git a/tajo-core/tajo-core-backend/src/main/java/org/apache/tajo/engine/planner/logical/join/JoinGraph.java b/tajo-core/tajo-core-backend/src/main/java/org/apache/tajo/engine/planner/logical/join/JoinGraph.java
index 9d66dd5..b4f4d9d 100644
--- a/tajo-core/tajo-core-backend/src/main/java/org/apache/tajo/engine/planner/logical/join/JoinGraph.java
+++ b/tajo-core/tajo-core-backend/src/main/java/org/apache/tajo/engine/planner/logical/join/JoinGraph.java
@@ -51,8 +51,8 @@ public class JoinGraph extends SimpleUndirectedGraph<String, JoinEdge> {
     if (leftExpr.hasQualifier()) {
       relationNames[0] = leftExpr.getQualifier();
     } else {
-      if (namedExprsMgr.isAliasedName(leftExpr.getColumnName())) {
-        String columnName = namedExprsMgr.getOriginalName(leftExpr.getColumnName());
+      if (namedExprsMgr.isAliasedName(leftExpr.getSimpleName())) {
+        String columnName = namedExprsMgr.getOriginalName(leftExpr.getSimpleName());
         String [] parts = columnName.split("\\.");
 
         if (parts.length != 2) {
@@ -68,8 +68,8 @@ public class JoinGraph extends SimpleUndirectedGraph<String, JoinEdge> {
     if (rightExpr.hasQualifier()) {
       relationNames[1] = rightExpr.getQualifier();
     } else {
-      if (namedExprsMgr.isAliasedName(rightExpr.getColumnName())) {
-        String columnName = namedExprsMgr.getOriginalName(rightExpr.getColumnName());
+      if (namedExprsMgr.isAliasedName(rightExpr.getSimpleName())) {
+        String columnName = namedExprsMgr.getOriginalName(rightExpr.getSimpleName());
         String [] parts = columnName.split("\\.");
         if (parts.length != 2) {
           throw new PlanningException("Cannot expect a referenced relation: " + leftExpr);

http://git-wip-us.apache.org/repos/asf/incubator-tajo/blob/e2f4798b/tajo-core/tajo-core-backend/src/main/java/org/apache/tajo/engine/planner/physical/BNLJoinExec.java
----------------------------------------------------------------------
diff --git a/tajo-core/tajo-core-backend/src/main/java/org/apache/tajo/engine/planner/physical/BNLJoinExec.java b/tajo-core/tajo-core-backend/src/main/java/org/apache/tajo/engine/planner/physical/BNLJoinExec.java
index 71581e3..60a7c19 100644
--- a/tajo-core/tajo-core-backend/src/main/java/org/apache/tajo/engine/planner/physical/BNLJoinExec.java
+++ b/tajo-core/tajo-core-backend/src/main/java/org/apache/tajo/engine/planner/physical/BNLJoinExec.java
@@ -83,7 +83,7 @@ public class BNLJoinExec extends BinaryPhysicalExec {
 
     // for join
     frameTuple = new FrameTuple();
-    outputTuple = new VTuple(outSchema.getColumnNum());
+    outputTuple = new VTuple(outSchema.size());
   }
 
   public JoinNode getPlan() {

http://git-wip-us.apache.org/repos/asf/incubator-tajo/blob/e2f4798b/tajo-core/tajo-core-backend/src/main/java/org/apache/tajo/engine/planner/physical/BSTIndexScanExec.java
----------------------------------------------------------------------
diff --git a/tajo-core/tajo-core-backend/src/main/java/org/apache/tajo/engine/planner/physical/BSTIndexScanExec.java b/tajo-core/tajo-core-backend/src/main/java/org/apache/tajo/engine/planner/physical/BSTIndexScanExec.java
index 753dcc8..d2f0922 100644
--- a/tajo-core/tajo-core-backend/src/main/java/org/apache/tajo/engine/planner/physical/BSTIndexScanExec.java
+++ b/tajo-core/tajo-core-backend/src/main/java/org/apache/tajo/engine/planner/physical/BSTIndexScanExec.java
@@ -98,7 +98,7 @@ public class BSTIndexScanExec extends PhysicalExec {
       }
     }
     Tuple tuple;
-    Tuple outTuple = new VTuple(this.outSchema.getColumnNum());
+    Tuple outTuple = new VTuple(this.outSchema.size());
     if (!scanNode.hasQual()) {
       if ((tuple = fileScanner.next()) != null) {
         projector.eval(tuple, outTuple);

http://git-wip-us.apache.org/repos/asf/incubator-tajo/blob/e2f4798b/tajo-core/tajo-core-backend/src/main/java/org/apache/tajo/engine/planner/physical/ColPartitionStoreExec.java
----------------------------------------------------------------------
diff --git a/tajo-core/tajo-core-backend/src/main/java/org/apache/tajo/engine/planner/physical/ColPartitionStoreExec.java b/tajo-core/tajo-core-backend/src/main/java/org/apache/tajo/engine/planner/physical/ColPartitionStoreExec.java
index c81f3bd..2ec0315 100644
--- a/tajo-core/tajo-core-backend/src/main/java/org/apache/tajo/engine/planner/physical/ColPartitionStoreExec.java
+++ b/tajo-core/tajo-core-backend/src/main/java/org/apache/tajo/engine/planner/physical/ColPartitionStoreExec.java
@@ -58,13 +58,13 @@ public abstract class ColPartitionStoreExec extends UnaryPhysicalExec {
     }
 
     // Find column index to name subpartition directory path
-    keyNum = this.plan.getPartitionMethod().getExpressionSchema().getColumnNum();
+    keyNum = this.plan.getPartitionMethod().getExpressionSchema().size();
 
     keyIds = new int[keyNum];
     keyNames = new String[keyNum];
     for (int i = 0; i < keyNum; i++) {
       Column column = this.plan.getPartitionMethod().getExpressionSchema().getColumn(i);
-      keyNames[i] = column.getColumnName();
+      keyNames[i] = column.getSimpleName();
 
       if (this.plan.getType() == NodeType.INSERT) {
         InsertNode insertNode = ((InsertNode)plan);

http://git-wip-us.apache.org/repos/asf/incubator-tajo/blob/e2f4798b/tajo-core/tajo-core-backend/src/main/java/org/apache/tajo/engine/planner/physical/HashAggregateExec.java
----------------------------------------------------------------------
diff --git a/tajo-core/tajo-core-backend/src/main/java/org/apache/tajo/engine/planner/physical/HashAggregateExec.java b/tajo-core/tajo-core-backend/src/main/java/org/apache/tajo/engine/planner/physical/HashAggregateExec.java
index 1f8d000..a31ad90 100644
--- a/tajo-core/tajo-core-backend/src/main/java/org/apache/tajo/engine/planner/physical/HashAggregateExec.java
+++ b/tajo-core/tajo-core-backend/src/main/java/org/apache/tajo/engine/planner/physical/HashAggregateExec.java
@@ -42,7 +42,7 @@ public class HashAggregateExec extends AggregationExec {
   public HashAggregateExec(TaskAttemptContext ctx, GroupbyNode plan, PhysicalExec subOp) throws IOException {
     super(ctx, plan, subOp);
     hashTable = new HashMap<Tuple, FunctionContext []>(100000);
-    this.tuple = new VTuple(plan.getOutSchema().getColumnNum());
+    this.tuple = new VTuple(plan.getOutSchema().size());
   }
 
   private void compute() throws IOException {

http://git-wip-us.apache.org/repos/asf/incubator-tajo/blob/e2f4798b/tajo-core/tajo-core-backend/src/main/java/org/apache/tajo/engine/planner/physical/HashFullOuterJoinExec.java
----------------------------------------------------------------------
diff --git a/tajo-core/tajo-core-backend/src/main/java/org/apache/tajo/engine/planner/physical/HashFullOuterJoinExec.java b/tajo-core/tajo-core-backend/src/main/java/org/apache/tajo/engine/planner/physical/HashFullOuterJoinExec.java
index 70dd10b..3875b6d 100644
--- a/tajo-core/tajo-core-backend/src/main/java/org/apache/tajo/engine/planner/physical/HashFullOuterJoinExec.java
+++ b/tajo-core/tajo-core-backend/src/main/java/org/apache/tajo/engine/planner/physical/HashFullOuterJoinExec.java
@@ -94,11 +94,11 @@ public class HashFullOuterJoinExec extends BinaryPhysicalExec {
 
     // for join
     frameTuple = new FrameTuple();
-    outTuple = new VTuple(outSchema.getColumnNum());
+    outTuple = new VTuple(outSchema.size());
     leftKeyTuple = new VTuple(leftKeyList.length);
 
-    leftNumCols = outer.getSchema().getColumnNum();
-    rightNumCols = inner.getSchema().getColumnNum();
+    leftNumCols = outer.getSchema().size();
+    rightNumCols = inner.getSchema().size();
   }
 
   protected void getKeyLeftTuple(final Tuple outerTuple, Tuple keyTuple) {

http://git-wip-us.apache.org/repos/asf/incubator-tajo/blob/e2f4798b/tajo-core/tajo-core-backend/src/main/java/org/apache/tajo/engine/planner/physical/HashJoinExec.java
----------------------------------------------------------------------
diff --git a/tajo-core/tajo-core-backend/src/main/java/org/apache/tajo/engine/planner/physical/HashJoinExec.java b/tajo-core/tajo-core-backend/src/main/java/org/apache/tajo/engine/planner/physical/HashJoinExec.java
index 51d0b4c..9f576a7 100644
--- a/tajo-core/tajo-core-backend/src/main/java/org/apache/tajo/engine/planner/physical/HashJoinExec.java
+++ b/tajo-core/tajo-core-backend/src/main/java/org/apache/tajo/engine/planner/physical/HashJoinExec.java
@@ -84,7 +84,7 @@ public class HashJoinExec extends BinaryPhysicalExec {
 
     // for join
     frameTuple = new FrameTuple();
-    outTuple = new VTuple(outSchema.getColumnNum());
+    outTuple = new VTuple(outSchema.size());
     leftKeyTuple = new VTuple(leftKeyList.length);
   }
 

http://git-wip-us.apache.org/repos/asf/incubator-tajo/blob/e2f4798b/tajo-core/tajo-core-backend/src/main/java/org/apache/tajo/engine/planner/physical/HashLeftOuterJoinExec.java
----------------------------------------------------------------------
diff --git a/tajo-core/tajo-core-backend/src/main/java/org/apache/tajo/engine/planner/physical/HashLeftOuterJoinExec.java b/tajo-core/tajo-core-backend/src/main/java/org/apache/tajo/engine/planner/physical/HashLeftOuterJoinExec.java
index 93383a3..9afe8e6 100644
--- a/tajo-core/tajo-core-backend/src/main/java/org/apache/tajo/engine/planner/physical/HashLeftOuterJoinExec.java
+++ b/tajo-core/tajo-core-backend/src/main/java/org/apache/tajo/engine/planner/physical/HashLeftOuterJoinExec.java
@@ -90,10 +90,10 @@ public class HashLeftOuterJoinExec extends BinaryPhysicalExec {
 
     // for join
     frameTuple = new FrameTuple();
-    outTuple = new VTuple(outSchema.getColumnNum());
+    outTuple = new VTuple(outSchema.size());
     leftKeyTuple = new VTuple(leftKeyList.length);
 
-    rightNumCols = rightChild.getSchema().getColumnNum();
+    rightNumCols = rightChild.getSchema().size();
   }
 
   protected void getKeyLeftTuple(final Tuple outerTuple, Tuple keyTuple) {


Mime
View raw message