You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tajo.apache.org by hy...@apache.org on 2013/06/17 11:24:45 UTC

git commit: TAJO-71: Case-insensitive parser. (hyunsik)

Updated Branches:
  refs/heads/master 16a0f2dfd -> 30f27131d


TAJO-71: Case-insensitive parser. (hyunsik)


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

Branch: refs/heads/master
Commit: 30f27131d1383fb84df3c75496b00f03e325a8c8
Parents: 16a0f2d
Author: Hyunsik Choi <hy...@apache.org>
Authored: Mon Jun 17 18:01:16 2013 +0900
Committer: Hyunsik Choi <hy...@apache.org>
Committed: Mon Jun 17 18:01:16 2013 +0900

----------------------------------------------------------------------
 CHANGES.txt                                     |   2 +
 .../src/main/antlr3/tajo/engine/parser/NQL.g    | 455 +++++++++++++------
 .../main/java/tajo/engine/parser/ParseUtil.java |   4 +-
 .../java/tajo/engine/parser/QueryAnalyzer.java  |   8 +-
 .../java/tajo/engine/parser/TestNQLParser.java  | 126 ++---
 .../java/tajo/engine/query/TestSelectQuery.java |   2 +-
 6 files changed, 376 insertions(+), 221 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-tajo/blob/30f27131/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index 990ae35..763ebe2 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -10,6 +10,8 @@ Release 0.2.0 - unreleased
 
   IMPROVEMENTS
 
+    TAJO-71: Case-insensitive parser. (hyunsik)
+
     TAJO-40: Adopt YarnClient to GlobalEngine. (jihoon)
 
     TAJO-69: Add .reviewboardrc file to the ignore lists of Rat and .gitignore. (hyunsik)

http://git-wip-us.apache.org/repos/asf/incubator-tajo/blob/30f27131/tajo-core/tajo-core-backend/src/main/antlr3/tajo/engine/parser/NQL.g
----------------------------------------------------------------------
diff --git a/tajo-core/tajo-core-backend/src/main/antlr3/tajo/engine/parser/NQL.g b/tajo-core/tajo-core-backend/src/main/antlr3/tajo/engine/parser/NQL.g
index 49eb91a..6507722 100644
--- a/tajo-core/tajo-core-backend/src/main/antlr3/tajo/engine/parser/NQL.g
+++ b/tajo-core/tajo-core-backend/src/main/antlr3/tajo/engine/parser/NQL.g
@@ -95,7 +95,236 @@ import tajo.engine.query.exception.TQLParseError;
    }
 }
 
-// NQL Main
+/*
+===============================================================================
+  Tokens for Case Insensitive Keywords
+===============================================================================
+*/
+fragment A
+	:	'A' | 'a';
+
+fragment B
+	:	'B' | 'b';
+
+fragment C
+	:	'C' | 'c';
+
+fragment D
+	:	'D' | 'd';
+
+fragment E
+	:	'E' | 'e';
+
+fragment F
+	:	'F' | 'f';
+
+fragment G
+	:	'G' | 'g';
+
+fragment H
+	:	'H' | 'h';
+
+fragment I
+	:	'I' | 'i';
+
+fragment J
+	:	'J' | 'j';
+
+fragment K
+	:	'K' | 'k';
+
+fragment L
+	:	'L' | 'l';
+
+fragment M
+	:	'M' | 'm';
+
+fragment N
+	:	'N' | 'n';
+
+fragment O
+	:	'O' | 'o';
+
+fragment P
+	:	'P' | 'p';
+
+fragment Q
+	:	'Q' | 'q';
+
+fragment R
+	:	'R' | 'r';
+
+fragment S
+	:	'S' | 's';
+
+fragment T
+	:	'T' | 't';
+
+fragment U
+	:	'U' | 'u';
+
+fragment V
+	:	'V' | 'v';
+
+fragment W
+	:	'W' | 'w';
+
+fragment X
+	:	'X' | 'x';
+
+fragment Y
+	:	'Y' | 'y';
+
+fragment Z
+	:	'Z' | 'z';
+
+/*
+===============================================================================
+  Reserved Keywords
+===============================================================================
+*/
+
+AS : A S;
+ALL : A L L;
+AND : A N D;
+ASC : A S C;
+
+BY : B Y;
+
+CASE : C A S E;
+CHARACTER : C H A R A C T E R;
+COUNT : C O U N T;
+COPY : C O P Y;
+CREATE : C R E A T E;
+CROSS : C R O S S;
+CUBE : C U B E;
+
+DESC : D E S C;
+DISTINCT : D I S T I N C T;
+DROP : D R O P;
+
+END : E N D;
+ELSE : E L S E;
+EXCEPT : E X C E P T;
+EXTERNAL : E X T E R N A L;
+FALSE : F A L S E;
+FIRST : F I R S T;
+FORMAT : F O R M A T;
+FULL : F U L L;
+FROM : F R O M;
+
+GROUP : G R O U P;
+
+HAVING : H A V I N G;
+
+IN : I N;
+INDEX : I N D E X;
+INNER : I N N E R;
+INSERT : I N S E R T;
+INTERSECT : I N T E R S E C T;
+INTO : I N T O;
+IS : I S;
+
+JOIN : J O I N;
+
+LAST : L A S T;
+LEFT : L E F T;
+LIKE : L I K E;
+LIMIT : L I M I T;
+LOCATION : L O C A T I O N;
+
+NATIONAL : N A T I O N A L;
+NATURAL : N A T U R A L;
+NOT : N O T;
+NULL : N U L L;
+
+ON : O N;
+OUTER : O U T E R;
+OR : O R;
+ORDER : O R D E R;
+
+PRECISION : P R E C I S I ON;
+
+RIGHT : R I G H T;
+ROLLUP : R O L L U P;
+
+SET : S E T;
+SELECT : S E L E C T;
+
+TABLE : T A B L E;
+THEN : T H E N;
+TRUE : T R U E;
+
+UNION : U N I O N;
+UNIQUE : U N I Q U E;
+UNKNOWN : U N K N O W N;
+USING : U S I N G;
+
+VALUES : V A L U E S;
+VARYING : V A R Y I N G;
+
+WHEN : W H E N;
+WHERE : W H E R E;
+WITH : W I T H;
+
+ZONE : Z O N E;
+
+/*
+===============================================================================
+  Data Type Tokens
+===============================================================================
+*/
+BOOLEAN : B O O L E A N;
+BOOL : B O O L;
+BIT : B I T;
+VARBIT : V A R B I T;
+
+INT1 : I N T '1';
+INT2 : I N T '2';
+INT4 : I N T '4';
+INT8 : I N T '8';
+
+TINYINT : T I N Y I N T; // alias for INT1
+SMALLINT : S M A L L I N T; // alias for INT2
+INT : I N T; // alias for INT4
+INTEGER : I N T E G E R; // alias - INT4
+BIGINT : B I G I N T; // alias for INT8
+
+FLOAT4 : F L O A T '4';
+FLOAT8 : F L O A T '8';
+
+REAL : R E A L; // alias for FLOAT4
+FLOAT : F L O A T; // alias for FLOAT8
+DOUBLE : D O U B L E; // alias for FLOAT8
+
+NUMERIC : N U M E R I C;
+DECIMAL : D E C I M A L; // alias for number
+
+CHAR : C H A R;
+VARCHAR : V A R C H A R;
+NCHAR : N C H A R;
+NVARCHAR : N V A R C H A R;
+
+DATE : D A T E;
+TIME : T I M E;
+TIMETZ : T I M E T Z;
+TIMESTAMP : T I M E S T A M P;
+TIMESTAMPTZ : T I M E S T A M P T Z;
+
+TEXT : T E X T;
+
+BINARY : B I N A R Y;
+VARBINARY : V A R B I N A R Y;
+BLOB : B L O B;
+BYTEA : B Y T E A; // alias for BLOB
+
+INET4 : I N E T '4';
+
+/*
+===============================================================================
+  SQL Main
+===============================================================================
+*/
 sql
   : statement EOF
   ;
@@ -135,18 +364,18 @@ schemaStatement
   ;
 
 indexStatement
-  : CREATE (u=UNIQUE)? INDEX n=ID ON t=table (m=method_specifier)? LEFT_PAREN s=sort_specifier_list RIGHT_PAREN p=param_clause?-> ^(CREATE_INDEX $u? $m? $p? $n $t $s)
+  : CREATE (u=UNIQUE)? INDEX n=Identifier ON t=table (m=method_specifier)? LEFT_PAREN s=sort_specifier_list RIGHT_PAREN p=param_clause?-> ^(CREATE_INDEX $u? $m? $p? $n $t $s)
   ;
 
 createTableStatement
-  : CREATE EXTERNAL TABLE t=table def=tableElements USING f=ID p=param_clause? (LOCATION path=STRING)
+  : CREATE EXTERNAL TABLE t=table def=tableElements USING f=Identifier p=param_clause? (LOCATION path=Character_String_Literal)
       -> ^(CREATE_TABLE $t EXTERNAL ^(TABLE_DEF $def) ^(USING $f) $p? ^(LOCATION $path))
-  | CREATE TABLE t=table (def=tableElements)? (USING s=ID)? (p=param_clause)? (AS q=query_expression)?
+  | CREATE TABLE t=table (def=tableElements)? (USING s=Identifier)? (p=param_clause)? (AS q=query_expression)?
       -> ^(CREATE_TABLE $t ^(TABLE_DEF $def)? ^(USING $s)? $p? ^(AS $q)?)
   ;
 
 copyStatement
-  : COPY t=table FROM path=string_value_expr FORMAT s=ID (p=param_clause)? -> ^(COPY $t $path $s $p?)
+  : COPY t=table FROM path=string_value_expr FORMAT s=Identifier (p=param_clause)? -> ^(COPY $t $path $s $p?)
   ;
 
 tableElements
@@ -154,7 +383,7 @@ tableElements
   ;
 
 fieldElement
-  : ID fieldType -> ^(FIELD_DEF ID fieldType)
+  : Identifier fieldType -> ^(FIELD_DEF Identifier fieldType)
   ;
 
 fieldType
@@ -162,11 +391,11 @@ fieldType
   ;
 
 precision_param
-  : LEFT_PAREN! DIGIT RIGHT_PAREN!
-  | LEFT_PAREN! DIGIT COMMA! DIGIT RIGHT_PAREN!
+  : LEFT_PAREN! NUMBER RIGHT_PAREN!
+  | LEFT_PAREN! NUMBER COMMA! NUMBER RIGHT_PAREN!
   ;
 type_length
-  : LEFT_PAREN! DIGIT RIGHT_PAREN!
+  : LEFT_PAREN! NUMBER RIGHT_PAREN!
   ;
 
 boolean_type
@@ -337,7 +566,7 @@ derivedColumn
   ;
 
 fieldName
-	:	(t=ID DOT)? b=ID -> ^(FIELD_NAME $b $t?)
+	:	(t=Identifier DOT)? b=Identifier -> ^(FIELD_NAME $b $t?)
 	;
 
 asClause
@@ -349,12 +578,12 @@ column_reference
 	;
 
 table
-  : ID
+  : Identifier
   ;
 
 // TODO - to be improved
 funcCall
-	: ID LEFT_PAREN funcArgs? RIGHT_PAREN -> ^(FUNCTION[$ID.text] funcArgs?)
+	: Identifier LEFT_PAREN funcArgs? RIGHT_PAREN -> ^(FUNCTION[$Identifier.text] funcArgs?)
 	| COUNT LEFT_PAREN funcArgs RIGHT_PAREN -> ^(COUNT_VAL funcArgs)
 	| COUNT LEFT_PAREN MULTIPLY RIGHT_PAREN -> ^(COUNT_ROWS)
 	;
@@ -405,7 +634,8 @@ union_join
 
 join_type
   : INNER
-  | t=outer_join_type ('outer')? -> ^(OUTER $t)
+  | t=outer_join_type OUTER -> ^(OUTER $t)
+  | t=outer_join_type -> ^(OUTER $t)
   ;
 
 outer_join_type
@@ -428,7 +658,7 @@ named_columns_join
   ;
 
 table_primary
-  : table ((AS)? a=ID)? -> ^(TABLE table ($a)?)
+  : table ((AS)? a=Identifier)? -> ^(TABLE table ($a)?)
   ;
 
 where_clause
@@ -498,7 +728,7 @@ null_ordering
   ;
 
 set_stmt
-	:	'set' ('union'|'intersect'|'diff') table
+	:	SET (UNION|INTERSECT|EXCEPT) table
 	;
 
 search_condition
@@ -510,11 +740,11 @@ param_clause
   ;
 
 param
-  : k=STRING EQUAL v=bool_expr -> ^(PARAM $k $v)
+  : k=Character_String_Literal EQUAL v=bool_expr -> ^(PARAM $k $v)
   ;
 
 method_specifier
-  : USING m=ID -> ^(USING[$m.text])
+  : USING m=Identifier -> ^(USING[$m.text])
   ;
 
 bool_expr
@@ -604,7 +834,7 @@ literal
   ;
 
 string_value_expr
-  : STRING
+  : Character_String_Literal
   ;
 
 signed_numerical_literal
@@ -612,7 +842,7 @@ signed_numerical_literal
   ;
 
 unsigned_numerical_literal
-  : DIGIT
+  : NUMBER
   | REAL_NUMBER
   ;
 
@@ -647,125 +877,6 @@ result
   : bool_expr
   ;
 
-////////////////////////////////
-// Lexer Section
-////////////////////////////////
-// Keywords
-AS : 'as';
-ALL : 'all';
-AND : 'and';
-ASC : 'asc';
-BY : 'by';
-CASE : 'case';
-CHARACTER : 'character';
-COUNT : 'count';
-COPY : 'copy';
-CREATE : 'create';
-CROSS : 'cross';
-CUBE : 'cube';
-DESC : 'desc';
-DISTINCT : 'distinct';
-DROP : 'drop';
-END : 'end';
-ELSE : 'else';
-EXCEPT : 'except';
-EXTERNAL : 'external';
-FALSE : 'false';
-FIRST : 'first';
-FORMAT : 'format';
-FULL : 'full';
-FROM : 'from';
-GROUP : 'group';
-HAVING : 'having';
-IN : 'in';
-INDEX : 'index';
-INNER : 'inner';
-INSERT : 'insert';
-INTERSECT : 'intersect';
-INTO : 'into';
-IS : 'is';
-JOIN : 'join';
-LAST : 'last';
-LEFT : 'left';
-LIKE : 'like';
-LIMIT : 'limit';
-LOCATION : 'location';
-NATIONAL : 'national';
-NATURAL : 'natural';
-NOT : 'not';
-NULL : 'null';
-ON : 'on';
-OUTER : 'outer';
-OR : 'or';
-ORDER : 'order';
-PRECISION : 'precision';
-RIGHT : 'right';
-ROLLUP : 'rollup';
-SELECT : 'select';
-TABLE : 'table';
-THEN : 'then';
-TRUE : 'true';
-UNION : 'union';
-UNIQUE : 'unique';
-UNKNOWN: 'unknown';
-USING : 'using';
-VALUES : 'values';
-VARYING : 'varying';
-WHEN : 'when';
-WHERE : 'where';
-WITH : 'with';
-ZONE : 'zone';
-
-///////////////////////////////////////////////////
-// Data Types
-///////////////////////////////////////////////////
-BOOLEAN : 'boolean';
-BOOL : 'bool';
-BIT : 'bit';
-VARBIT : 'varbit';
-
-// Numeric Types
-INT1 : 'int1';
-INT2 : 'int2';
-INT4 : 'int4';
-INT8 : 'int8';
-
-TINYINT : 'tinyint'; // alias for INT1
-SMALLINT : 'smallint'; // alias for INT2
-INT : 'int'; // alias for INT4
-INTEGER : 'integer'; // alias - INT4
-BIGINT : 'bigint'; // alias for INT8
-
-FLOAT4 : 'float4';
-FLOAT8 : 'float8';
-
-REAL : 'real'; // alias for FLOAT4
-FLOAT : 'float'; // alias for FLOAT8
-DOUBLE : 'double'; // alias for FLOAT8
-
-NUMERIC : 'numeric';
-DECIMAL : 'decimal'; // alias for number
-
-CHAR : 'char';
-VARCHAR : 'varchar';
-NCHAR : 'nchar';
-NVARCHAR : 'nvarchar';
-
-DATE : 'date';
-TIME : 'time';
-TIMETZ : 'timetz';
-TIMESTAMP : 'timestamp';
-TIMESTAMPTZ : 'timestamptz';
-
-TEXT : 'text';
-
-BINARY : 'binary';
-VARBINARY : 'varbinary';
-BLOB : 'blob';
-BYTEA : 'bytea'; // alias for BLOB
-
-INET4 : 'inet4';
-
 // Operators
 ASSIGN  : ':=';
 EQUAL  : '=';
@@ -785,12 +896,10 @@ DIVIDE  : '/';
 MODULAR : '%';
 DOT : '.';
 
-// Regular Expressions for Tokens
-ID  : ('a'..'z'|'A'..'Z'|'_') ('a'..'z'|'A'..'Z'|'0'..'9'|'_'|':')*
-    ;
+NUMBER : Digit+;
 
-DIGIT : '0'..'9'+
-    ;
+fragment
+Digit : '0'..'9';
 
 REAL_NUMBER
     :   ('0'..'9')+ '.' ('0'..'9')* EXPONENT?
@@ -803,17 +912,39 @@ COMMENT
     |   '/*' ( options {greedy=false;} : . )* '*/' {$channel=HIDDEN;}
     ;
 
-WS  :   ( ' '
-        | '\t'
-        | '\r'
-        | '\n'
-        ) {$channel=HIDDEN;}
+/*
+===============================================================================
+ Identifiers
+===============================================================================
+*/
+
+// Regular Expressions for Tokens
+Identifier  : ('a'..'z'|'A'..'Z'|'_') ('a'..'z'|'A'..'Z'|Digit|'_'|':')*
     ;
 
-STRING
-    :  '\'' ( ESC_SEQ | ~('\\'|'\'') )* '\'' {setText(getText().substring(1, getText().length()-1));}
+/*
+===============================================================================
+ Literal
+===============================================================================
+*/
+
+// Some Unicode Character Ranges
+fragment
+Control_Characters                  :   '\u0001' .. '\u001F';
+fragment
+Extended_Control_Characters         :   '\u0080' .. '\u009F';
+
+Character_String_Literal
+    : Quote ( ESC_SEQ | ~('\\'|Quote) )* Quote {setText(getText().substring(1, getText().length()-1));}
+    | Double_Quote ( ESC_SEQ | ~('\\'|Double_Quote) )* Double_Quote {setText(getText().substring(1, getText().length()-1));}
     ;
 
+Quote
+  : '\'';
+
+Double_Quote
+  : '"';
+
 fragment
 EXPONENT : ('e'|'E') ('+'|'-')? ('0'..'9')+ ;
 
@@ -837,4 +968,26 @@ OCTAL_ESC
 fragment
 UNICODE_ESC
     :   '\\' 'u' HEX_DIGIT HEX_DIGIT HEX_DIGIT HEX_DIGIT
-    ;
\ No newline at end of file
+    ;
+
+
+/*
+===============================================================================
+ Whitespace Tokens
+===============================================================================
+*/
+
+Space : ' '
+{
+	$channel = HIDDEN;
+};
+
+White_Space :	( Control_Characters  | Extended_Control_Characters )+
+{
+	$channel = HIDDEN;
+};
+
+
+BAD : . {
+  skip();
+} ;
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-tajo/blob/30f27131/tajo-core/tajo-core-backend/src/main/java/tajo/engine/parser/ParseUtil.java
----------------------------------------------------------------------
diff --git a/tajo-core/tajo-core-backend/src/main/java/tajo/engine/parser/ParseUtil.java b/tajo-core/tajo-core-backend/src/main/java/tajo/engine/parser/ParseUtil.java
index 66e7a2e..75db55a 100644
--- a/tajo-core/tajo-core-backend/src/main/java/tajo/engine/parser/ParseUtil.java
+++ b/tajo-core/tajo-core-backend/src/main/java/tajo/engine/parser/ParseUtil.java
@@ -29,9 +29,9 @@ public class ParseUtil {
 
   public static boolean isConstant(final Tree tree) {
     switch (tree.getType()) {
-      case NQLParser.DIGIT:
+      case NQLParser.NUMBER:
       case NQLParser.REAL:
-      case NQLParser.STRING:
+      case NQLParser.Character_String_Literal:
         return true;
       default:
         return false;

http://git-wip-us.apache.org/repos/asf/incubator-tajo/blob/30f27131/tajo-core/tajo-core-backend/src/main/java/tajo/engine/parser/QueryAnalyzer.java
----------------------------------------------------------------------
diff --git a/tajo-core/tajo-core-backend/src/main/java/tajo/engine/parser/QueryAnalyzer.java b/tajo-core/tajo-core-backend/src/main/java/tajo/engine/parser/QueryAnalyzer.java
index 09dac27..b1a55d1 100644
--- a/tajo-core/tajo-core-backend/src/main/java/tajo/engine/parser/QueryAnalyzer.java
+++ b/tajo-core/tajo-core-backend/src/main/java/tajo/engine/parser/QueryAnalyzer.java
@@ -1010,7 +1010,7 @@ public final class QueryAnalyzer {
     switch(ast.getType()) {
 
       // constants
-      case NQLParser.DIGIT:
+      case NQLParser.NUMBER:
         return new ConstEval(DatumFactory.createInt4(
             Integer.valueOf(ast.getText())));
 
@@ -1018,7 +1018,7 @@ public final class QueryAnalyzer {
         return new ConstEval(DatumFactory.createFloat4(
             Float.valueOf(ast.getText())));
 
-      case NQLParser.STRING:
+      case NQLParser.Character_String_Literal:
         return new ConstEval(DatumFactory.createText(ast.getText()));
 
       // unary expression
@@ -1251,7 +1251,7 @@ public final class QueryAnalyzer {
       Tree constAst = tree.getChild(constId);
 
       switch (tree.getChild(constId).getType()) {
-        case NQLParser.DIGIT:
+        case NQLParser.NUMBER:
           exprs[constId] = parseDigitByTypeInfer(context, block, constAst,
               exprs[fieldId].getValueType()[0]);
           break;
@@ -1261,7 +1261,7 @@ public final class QueryAnalyzer {
               exprs[fieldId].getValueType()[0]);
           break;
 
-        case NQLParser.STRING:
+        case NQLParser.Character_String_Literal:
           exprs[constId] = parseStringByTypeInfer(context, block, constAst,
               exprs[fieldId].getValueType()[0]);
           break;

http://git-wip-us.apache.org/repos/asf/incubator-tajo/blob/30f27131/tajo-core/tajo-core-backend/src/test/java/tajo/engine/parser/TestNQLParser.java
----------------------------------------------------------------------
diff --git a/tajo-core/tajo-core-backend/src/test/java/tajo/engine/parser/TestNQLParser.java b/tajo-core/tajo-core-backend/src/test/java/tajo/engine/parser/TestNQLParser.java
index 29d815a..2cd2f19 100644
--- a/tajo-core/tajo-core-backend/src/test/java/tajo/engine/parser/TestNQLParser.java
+++ b/tajo-core/tajo-core-backend/src/test/java/tajo/engine/parser/TestNQLParser.java
@@ -159,7 +159,7 @@ public class TestNQLParser {
     assertEquals(tree.getChild(0).getType(), NQLParser.FIELD_NAME);
     FieldName fieldName = new FieldName(tree.getChild(0));
     assertEquals(fieldName.getName(), "age");
-    assertEquals(tree.getChild(1).getType(), NQLParser.DIGIT);
+    assertEquals(tree.getChild(1).getType(), NQLParser.NUMBER);
     assertEquals(tree.getChild(1).getText(), "30");
   }
 
@@ -452,52 +452,52 @@ public class TestNQLParser {
     "create table name (name text, age int) using rcfile as select * from test", // 6
     "create table name (name text, age int) using rcfile with ('rcfile.buffer'= 4096) as select * from test", // 7
     "create table widetable (" +
-        "col0 bit," +
-        "col0 bit(10)," +
-        "col0 bit varying," +
-        "col0 bit varying(10)," +
-        "col1 tinyint, " +
-        "col2 smallint, " +
-        "col3 integer, " +
-        "col4 bigint, " +
-        "col5 real, " +
-        "col5 float, " +
-        "col5 float(53), " +
-        "col6 double, " +
-        "col6 double precision, " +
-        "col7 numeric, " +
-        "col7 numeric(10), " +
-        "col7 numeric(10,2), " +
-        "col8 decimal," +
-        "col8 decimal(10)," +
-        "col8 decimal(10,2)," +
-        "col9 char," +
-        "col9 character," +
-        "col10 char(10)," +
-        "col10 character(10)," +
-        "col11 varchar," +
-        "col11 character varying," +
-        "col12 varchar(255)," +
-        "col11 character varying (255)," +
-        "col11 nchar," +
-        "col11 nchar(255)," +
-        "col11 national character," +
-        "col11 national character(255)," +
-        "col11 nvarchar," +
-        "col11 nvarchar(255)," +
-        "col11 national character varying," +
-        "col11 national character varying (255)," +
-        "col11 date," +
-        "col11 time," +
-        "col11 timetz," +
-        "col11 time with time zone," +
-        "col11 timestamptz," +
-        "col11 timestamp with time zone," +
-        "col11 binary," +
-        "col11 binary(10)," +
-        "col11 varbinary(10)," +
-        "col11 binary varying(10)," +
-        "col11 blob" +
+        "col0 bit,\n" +
+        "col0 BIT(10),\n" +
+        "col0 bit varying,\n" +
+        "col0 bit VARYING(10),\n" +
+        "col1 tinyint,\n" +
+        "col2 smallInt,\n" +
+        "col3 integer,\n" +
+        "col4 biginT,\n" +
+        "col5 real,\n" +
+        "col5 float,\n" +
+        "col5 float(53),\n" +
+        "col6 double,\n" +
+        "col6 doublE precision,\n" +
+        "col7 numeric,\n" +
+        "col7 numeric(10),\n" +
+        "col7 numeric(10,2),\n" +
+        "col8 decimal,\n" +
+        "col8 decimal(10),\n" +
+        "col8 decimal(10,2),\n" +
+        "col9 char,\n" +
+        "col9 character,\n" +
+        "col10 chaR(10),\n" +
+        "col10 character(10),\n" +
+        "col11 varchar,\n" +
+        "col11 character varying,\n" +
+        "col12 varchar(255),\n" +
+        "col11 character varying (255),\n" +
+        "col11 nchar,\n" +
+        "col11 nchar(255),\n" +
+        "col11 national character,\n" +
+        "col11 national character(255),\n" +
+        "col11 nvarchar,\n" +
+        "col11 nvarchar(255),\n" +
+        "col11 natIonal character varying,\n" +
+        "col11 national character varying (255),\n" +
+        "col11 date,\n" +
+        "col11 time,\n" +
+        "col11 timetz,\n" +
+        "col11 time With time zone,\n" +
+        "col11 timesTamptz,\n" +
+        "col11 timestamp with time zone,\n" +
+        "col11 binary,\n" +
+        "col11 binary(10),\n" +
+        "col11 varbinary(10),\n" +
+        "col11 binary Varying(10),\n" +
+        "col11 blOb\n" +
         ") as select * from test", // 8
     "create table widetable (col1 float(10), col2 float) as select * from test", // 9
     "create external table table1 (name text, age int, earn bigint, score float) using csv location '/tmp/data'", // 10
@@ -507,7 +507,7 @@ public class TestNQLParser {
   public void testCreateTableAsSelect1() throws RecognitionException, TQLSyntaxError {
     Tree ast = parseQuery(schemaStmts[1]);
     assertEquals(ast.getType(), NQLParser.CREATE_TABLE);
-    assertEquals(NQLParser.ID, ast.getChild(0).getType());
+    assertEquals(NQLParser.Identifier, ast.getChild(0).getType());
     assertEquals(NQLParser.TABLE_DEF, ast.getChild(1).getType());
   }
 
@@ -515,7 +515,7 @@ public class TestNQLParser {
   public void testCreateTableAsSelect2() throws RecognitionException, TQLSyntaxError {
     Tree ast = parseQuery(schemaStmts[2]);
     assertEquals(ast.getType(), NQLParser.CREATE_TABLE);
-    assertEquals(NQLParser.ID, ast.getChild(0).getType());
+    assertEquals(NQLParser.Identifier, ast.getChild(0).getType());
     assertEquals(NQLParser.TABLE_DEF, ast.getChild(1).getType());
     assertEquals(NQLParser.USING, ast.getChild(2).getType());
     assertEquals("rcfile", ast.getChild(2).getChild(0).getText());
@@ -525,7 +525,7 @@ public class TestNQLParser {
   public void testCreateTableAsSelect3() throws RecognitionException, TQLSyntaxError {
     Tree ast = parseQuery(schemaStmts[3]);
     assertEquals(ast.getType(), NQLParser.CREATE_TABLE);
-    assertEquals(NQLParser.ID, ast.getChild(0).getType());
+    assertEquals(NQLParser.Identifier, ast.getChild(0).getType());
     assertEquals(NQLParser.TABLE_DEF, ast.getChild(1).getType());
     assertEquals(NQLParser.USING, ast.getChild(2).getType());
     assertEquals("rcfile", ast.getChild(2).getChild(0).getText());
@@ -536,7 +536,7 @@ public class TestNQLParser {
   public void testCreateTableAsSelect4() throws RecognitionException, TQLSyntaxError {
     Tree ast = parseQuery(schemaStmts[4]);
     assertEquals(ast.getType(), NQLParser.CREATE_TABLE);
-    assertEquals(NQLParser.ID, ast.getChild(0).getType());
+    assertEquals(NQLParser.Identifier, ast.getChild(0).getType());
     assertEquals(NQLParser.AS, ast.getChild(1).getType());
     assertEquals(NQLParser.SELECT, ast.getChild(1).getChild(0).getType());
   }
@@ -545,7 +545,7 @@ public class TestNQLParser {
   public void testCreateTableAsSelect5() throws RecognitionException, TQLSyntaxError {
     Tree ast = parseQuery(schemaStmts[5]);
     assertEquals(ast.getType(), NQLParser.CREATE_TABLE);
-    assertEquals(NQLParser.ID, ast.getChild(0).getType());
+    assertEquals(NQLParser.Identifier, ast.getChild(0).getType());
     assertEquals(NQLParser.TABLE_DEF, ast.getChild(1).getType());
     assertEquals(NQLParser.AS, ast.getChild(2).getType());
     assertEquals(NQLParser.SELECT, ast.getChild(2).getChild(0).getType());
@@ -555,7 +555,7 @@ public class TestNQLParser {
   public void testCreateTableAsSelect6() throws RecognitionException, TQLSyntaxError {
     Tree ast = parseQuery(schemaStmts[6]);
     assertEquals(ast.getType(), NQLParser.CREATE_TABLE);
-    assertEquals(NQLParser.ID, ast.getChild(0).getType());
+    assertEquals(NQLParser.Identifier, ast.getChild(0).getType());
     assertEquals(NQLParser.TABLE_DEF, ast.getChild(1).getType());
     assertEquals(NQLParser.USING, ast.getChild(2).getType());
     assertEquals(NQLParser.AS, ast.getChild(3).getType());
@@ -566,7 +566,7 @@ public class TestNQLParser {
   public void testCreateTableAsSelect7() throws RecognitionException, TQLSyntaxError {
     Tree ast = parseQuery(schemaStmts[7]);
     assertEquals(ast.getType(), NQLParser.CREATE_TABLE);
-    assertEquals(NQLParser.ID, ast.getChild(0).getType());
+    assertEquals(NQLParser.Identifier, ast.getChild(0).getType());
     assertEquals(NQLParser.TABLE_DEF, ast.getChild(1).getType());
     assertEquals(NQLParser.USING, ast.getChild(2).getType());
     assertEquals(NQLParser.PARAMS, ast.getChild(3).getType());
@@ -578,7 +578,7 @@ public class TestNQLParser {
   public void testCreateTableWithVariousDataType1() throws RecognitionException, TQLSyntaxError {
     Tree ast = parseQuery(schemaStmts[8]);
     assertEquals(ast.getType(), NQLParser.CREATE_TABLE);
-    assertEquals(NQLParser.ID, ast.getChild(0).getType());
+    assertEquals(NQLParser.Identifier, ast.getChild(0).getType());
     assertEquals(NQLParser.TABLE_DEF, ast.getChild(1).getType());
     assertEquals(NQLParser.AS, ast.getChild(2).getType());
     assertEquals(NQLParser.SELECT, ast.getChild(2).getChild(0).getType());
@@ -588,7 +588,7 @@ public class TestNQLParser {
   public void testCreateTableWithVariousDataType2() throws RecognitionException, TQLSyntaxError {
     Tree ast = parseQuery(schemaStmts[9]);
     assertEquals(ast.getType(), NQLParser.CREATE_TABLE);
-    assertEquals(NQLParser.ID, ast.getChild(0).getType());
+    assertEquals(NQLParser.Identifier, ast.getChild(0).getType());
     assertEquals(NQLParser.TABLE_DEF, ast.getChild(1).getType());
     assertEquals("10", ast.getChild(1).getChild(0).getChild(1).getChild(0).getText());
     assertEquals(NQLParser.AS, ast.getChild(2).getType());
@@ -599,7 +599,7 @@ public class TestNQLParser {
   public void testCreateTableLocation1() throws RecognitionException, TQLSyntaxError {
     Tree ast = parseQuery(schemaStmts[10]);
     assertEquals(ast.getType(), NQLParser.CREATE_TABLE);
-    assertEquals(NQLParser.ID, ast.getChild(0).getType());
+    assertEquals(NQLParser.Identifier, ast.getChild(0).getType());
     assertEquals(NQLParser.EXTERNAL, ast.getChild(1).getType());
     assertEquals(NQLParser.TABLE_DEF, ast.getChild(2).getType());
     assertEquals(NQLParser.USING, ast.getChild(3).getType());
@@ -834,8 +834,8 @@ public class TestNQLParser {
     assertEquals(node.getType(), NQLParser.NOT);
     assertEquals(node.getChild(0).getType(), NQLParser.GTH);
     CommonTree gth = (CommonTree) node.getChild(0);
-    assertEquals(gth.getChild(0).getType(), NQLParser.DIGIT);
-    assertEquals(gth.getChild(1).getType(), NQLParser.DIGIT);
+    assertEquals(gth.getChild(0).getType(), NQLParser.NUMBER);
+    assertEquals(gth.getChild(1).getType(), NQLParser.NUMBER);
   }
 
   @Test
@@ -863,7 +863,7 @@ public class TestNQLParser {
     assertEquals(NQLParser.FIELD_NAME, node.getChild(0).getType());
     FieldName fieldName = new FieldName(node.getChild(0));
     assertEquals(fieldName.getName(), "type");
-    assertEquals(NQLParser.STRING, node.getChild(1).getType());
+    assertEquals(NQLParser.Character_String_Literal, node.getChild(1).getType());
     
     p = parseExpr(exprs[25]);
     node = (CommonTree) p.search_condition().getTree();    
@@ -872,7 +872,7 @@ public class TestNQLParser {
     assertEquals(NQLParser.FIELD_NAME, node.getChild(1).getType());
     fieldName = new FieldName(node.getChild(1));
     assertEquals(fieldName.getName(), "type");
-    assertEquals(NQLParser.STRING, node.getChild(2).getType());
+    assertEquals(NQLParser.Character_String_Literal, node.getChild(2).getType());
   }
 
   @Test
@@ -884,7 +884,7 @@ public class TestNQLParser {
     CommonTree node = (CommonTree) p.search_condition().getTree();
     assertEquals(NQLParser.EQUAL, node.getType());
     assertEquals(NQLParser.FIELD_NAME, node.getChild(0).getType());
-    assertEquals(NQLParser.STRING, node.getChild(1).getType());
+    assertEquals(NQLParser.Character_String_Literal, node.getChild(1).getType());
   }
 
   @Test
@@ -959,7 +959,7 @@ public class TestNQLParser {
 
     assertEquals(NQLParser.LIKE, cond1.getChild(0).getType());
     assertEquals(NQLParser.EQUAL, cond2.getChild(0).getType());
-    assertEquals(NQLParser.DIGIT, elseStmt.getChild(0).getType());
+    assertEquals(NQLParser.NUMBER, elseStmt.getChild(0).getType());
   }
 
   public class FieldName {

http://git-wip-us.apache.org/repos/asf/incubator-tajo/blob/30f27131/tajo-core/tajo-core-backend/src/test/java/tajo/engine/query/TestSelectQuery.java
----------------------------------------------------------------------
diff --git a/tajo-core/tajo-core-backend/src/test/java/tajo/engine/query/TestSelectQuery.java b/tajo-core/tajo-core-backend/src/test/java/tajo/engine/query/TestSelectQuery.java
index fb60751..89a94fa 100644
--- a/tajo-core/tajo-core-backend/src/test/java/tajo/engine/query/TestSelectQuery.java
+++ b/tajo-core/tajo-core-backend/src/test/java/tajo/engine/query/TestSelectQuery.java
@@ -168,7 +168,7 @@ public class TestSelectQuery {
         "ALGERIA", "ETHIOPIA", "INDIA", "INDONESIA", "ROMANIA", "SAUDI ARABIA", "RUSSIA");
 
     ResultSet res = tpch.execute(
-        "select n_name from nation where n_name like '%IA'");
+        "SELECT n_name FROM nation WHERE n_name LIKE '%IA'");
     int cnt = 0;
     while(res.next()) {
       assertTrue(result.contains(res.getString(1)));