tajo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hyun...@apache.org
Subject git commit: TAJO-497: Rearrange reserved and non-reserved keywords. (sirpkt via hyunsik)
Date Wed, 29 Jan 2014 04:59:22 GMT
Updated Branches:
  refs/heads/master 32775bb5e -> b0d81a590


TAJO-497: Rearrange reserved and non-reserved keywords. (sirpkt via 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/b0d81a59
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tajo/tree/b0d81a59
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tajo/diff/b0d81a59

Branch: refs/heads/master
Commit: b0d81a590bb45c37f838eae93663736767040c02
Parents: 32775bb
Author: Hyunsik Choi <hyunsik@apache.org>
Authored: Wed Jan 29 13:58:51 2014 +0900
Committer: Hyunsik Choi <hyunsik@apache.org>
Committed: Wed Jan 29 13:58:51 2014 +0900

----------------------------------------------------------------------
 CHANGES.txt                                     |   2 +
 .../org/apache/tajo/engine/parser/SQLLexer.g4   | 132 ++++----------
 .../org/apache/tajo/engine/parser/SQLParser.g4  | 179 ++++++++++++++++---
 .../apache/tajo/engine/parser/SQLAnalyzer.java  |  63 +++++--
 .../tajo/engine/query/TestCreateTable.java      | 122 +++++++++++++
 5 files changed, 360 insertions(+), 138 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-tajo/blob/b0d81a59/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index da42b26..1f78565 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -125,6 +125,8 @@ Release 0.8.0 - unreleased
 
   IMPROVEMENTS
 
+    TAJO-497: Rearrange reserved and non-reserved keywords. (sirpkt via hyunsik)
+
     TAJO-475: Table partition catalog recap. (Min Zhou and hyunsik)
 
     TAJO-539: Change some EvalNode::eval to directly return a Datum value.

http://git-wip-us.apache.org/repos/asf/incubator-tajo/blob/b0d81a59/tajo-core/tajo-core-backend/src/main/antlr4/org/apache/tajo/engine/parser/SQLLexer.g4
----------------------------------------------------------------------
diff --git a/tajo-core/tajo-core-backend/src/main/antlr4/org/apache/tajo/engine/parser/SQLLexer.g4
b/tajo-core/tajo-core-backend/src/main/antlr4/org/apache/tajo/engine/parser/SQLLexer.g4
index 2151387..1ceaca8 100644
--- a/tajo-core/tajo-core-backend/src/main/antlr4/org/apache/tajo/engine/parser/SQLLexer.g4
+++ b/tajo-core/tajo-core-backend/src/main/antlr4/org/apache/tajo/engine/parser/SQLLexer.g4
@@ -136,60 +136,36 @@ ELSE : E L S E;
 EXCEPT : E X C E P T;
 
 FALSE : F A L S E;
-FILTER : F I L T E R;
-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;
-GROUPING : G R O U P I N G;
 
 HAVING : H A V I N G;
-HASH : H A S H;
 
 ILIKE : I L I K E;
 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;
 LEADING : L E A D I N G;
 LEFT : L E F T;
 LIKE : L I K E;
 LIMIT : L I M I T;
-LIST : L I S 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;
-NULLIF : N U L L I F;
-
-MAX : M A X;
-MIN : M I N;
 
 ON : O N;
 OUTER : O U T E R;
 OR : O R;
 ORDER : O R D E R;
-OVERWRITE : O V E R W R I T E;
-
-PRECISION : P R E C I S I ON;
-
-RANGE : R A N G E;
-REGEXP : R E G E X P;
 RIGHT : R I G H T;
-RLIKE : R L I K E;
-
-SET : S E T;
 SELECT : S E L E C T;
 SOME : S O M E;
 SYMMETRIC : S Y M M E T R I C;
@@ -201,19 +177,12 @@ 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;
 
-VAR_SAMP : V A R UNDERLINE S A M P;
-VAR_POP : V A R UNDERLINE P O P;
-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;
-
 /*
 ===============================================================================
   Non Reserved Keywords
@@ -245,32 +214,56 @@ EXISTS : E X I S T S;
 EXTERNAL : E X T E R N A L;
 EXTRACT : E X T R A C T;
 
-LESS : L E S S;
 
+FILTER : F I L T E R;
+FIRST : F I R S T;
+FORMAT : F O R M A T;
 FUSION : F U S I O N;
 
+GROUPING : G R O U P I N G;
+
+HASH : H A S H;
 HOUR : H O U R;
 
+INDEX : I N D E X;
+INSERT : I N S E R T;
 INTERSECTION : I N T E R S E C T I O N;
 ISODOW : I S O D O W;
 ISOYEAR : I S O Y E A R;
 
+LAST : L A S T;
+LESS : L E S S;
+LIST : L I S T;
+LOCATION : L O C A T I O N;
+
+MAX : M A X;
 MAXVALUE : M A X V A L U E;
 MICROSECONDS : M I C R O S E C O N D S;
 MILLENNIUM : M I L L E N N I U M;
 MILLISECONDS : M I L L I S E C O N D S;
+MIN : M I N;
 MINUTE : M I N U T E;
 MONTH : M O N T H;
 
+NATIONAL : N A T I O N A L;
+NULLIF : N U L L I F;
+
+OVERWRITE : O V E R W R I T E;
+
 PARTITION : P A R T I T I O N;
 PARTITIONS : P A R T I T I O N S;
+PRECISION : P R E C I S I O N;
 PURGE : P U R G E;
 
 QUARTER : Q U A R T E R;
 
+RANGE : R A N G E;
+REGEXP : R E G E X P;
+RLIKE : R L I K E;
 ROLLUP : R O L L U P;
 
 SECOND : S E C O N D;
+SET : S E T;
 SIMILAR : S I M I L A R;
 STDDEV_POP : S T D D E V UNDERLINE P O P;
 STDDEV_SAMP : S T D D E V UNDERLINE S A M P;
@@ -285,77 +278,19 @@ TIMEZONE_MINUTE: T I M E Z O N E UNDERLINE M I N U T E;
 TRIM : T R I M;
 TO : T O;
 
+UNKNOWN : U N K N O W N;
+
 VALUES : V A L U E S;
+VAR_SAMP : V A R UNDERLINE S A M P;
+VAR_POP : V A R UNDERLINE P O P;
+VARYING : V A R Y I N G;
 
 WEEK : W E E K;
 
 YEAR : Y E A R;
 
-Nonreserved_keywords
-  : AVG
-  | BETWEEN
-  | BY
-
-  | CENTURY
-  | CHARACTER
-  | COALESCE
-  | COLLECT
-  | COLUMN
-  | COUNT
-  | CUBE
-  | DAY
-  | DEC
-  | DECADE
-  | DOW
-  | DOY
-  | DROP
-  | EPOCH
-  | EVERY
-  | EXISTS
-  | EXTERNAL
-  | EXTRACT
-  | FUSION
-  | HASH
-  | INTERSECTION
-  | ISODOW
-  | ISOYEAR
-
-  | LESS
-  | LIST
-
-  | MAXVALUE
-  | MICROSECONDS
-  | MILLENNIUM
-  | MILLISECONDS
-  | MINUTE
-  | MONTH
-
-  | PARTITION
-  | PARTITIONS
-  | QUARTER
-  | ROLLUP
-
-  | SECOND
-  | SIMILAR
-  | STDDEV_POP
-  | STDDEV_SAMP
-  | SUBPARTITION
-  | SUM
-
-  | TABLESPACE
-  | THAN
-  | TIMEZONE
-  | TIMEZONE_HOUR
-  | TIMEZONE_MINUTE
-  | TRIM
-  | TO
-
-  | VALUES
-
-  | WEEK
-
-  | YEAR
-  ;
+ZONE : Z O N E;
+
 
 /*
 ===============================================================================
@@ -469,8 +404,7 @@ LineComment
 */
 
 Identifier
-  : Nonreserved_keywords
-  | Regular_Identifier
+  : Regular_Identifier
   ;
 
 fragment

http://git-wip-us.apache.org/repos/asf/incubator-tajo/blob/b0d81a59/tajo-core/tajo-core-backend/src/main/antlr4/org/apache/tajo/engine/parser/SQLParser.g4
----------------------------------------------------------------------
diff --git a/tajo-core/tajo-core-backend/src/main/antlr4/org/apache/tajo/engine/parser/SQLParser.g4
b/tajo-core/tajo-core-backend/src/main/antlr4/org/apache/tajo/engine/parser/SQLParser.g4
index 0b7ced0..ab6bff6 100644
--- a/tajo-core/tajo-core-backend/src/main/antlr4/org/apache/tajo/engine/parser/SQLParser.g4
+++ b/tajo-core/tajo-core-backend/src/main/antlr4/org/apache/tajo/engine/parser/SQLParser.g4
@@ -59,16 +59,16 @@ schema_statement
   ;
 
 index_statement
-  : CREATE (u=UNIQUE)? INDEX n=Identifier ON t=table_name (m=method_specifier)?
+  : CREATE (u=UNIQUE)? INDEX n=identifier ON t=table_name (m=method_specifier)?
     LEFT_PAREN s=sort_specifier_list RIGHT_PAREN p=param_clause?
   ;
 
 create_table_statement
-  : CREATE EXTERNAL TABLE table_name table_elements USING file_type=Identifier
+  : CREATE EXTERNAL TABLE table_name table_elements USING file_type=identifier
     (param_clause)? (table_partitioning_clauses)? (LOCATION path=Character_String_Literal)
-  | CREATE TABLE table_name table_elements (USING file_type=Identifier)?
+  | CREATE TABLE table_name table_elements (USING file_type=identifier)?
     (param_clause)? (table_partitioning_clauses)? (AS query_expression)?
-  | CREATE TABLE table_name (USING file_type=Identifier)?
+  | CREATE TABLE table_name (USING file_type=identifier)?
     (param_clause)? (table_partitioning_clauses)? AS query_expression
   ;
 
@@ -77,7 +77,7 @@ table_elements
   ;
 
 field_element
-  : name=Identifier field_type
+  : name=identifier field_type
   ;
 
 field_type
@@ -93,7 +93,7 @@ param
   ;
 
 method_specifier
-  : USING m=Identifier
+  : USING m=identifier
   ;
 
 table_space_specifier
@@ -101,7 +101,7 @@ table_space_specifier
   ;
 
 table_space_name
-  : Identifier
+  : identifier
   ;
 
 table_partitioning_clauses
@@ -158,7 +158,7 @@ column_partitions
   ;
 
 partition_name
-  : Identifier
+  : identifier
   ;
 
 /*
@@ -173,6 +173,135 @@ drop_table_statement
 
 /*
 ===============================================================================
+  5.2 <token and separator>
+
+  Specifying lexical units (tokens and separators) that participate in SQL language
+===============================================================================
+*/
+
+identifier
+  : Identifier
+  | nonreserved_keywords
+  ;
+
+nonreserved_keywords
+  : AVG
+  | BETWEEN
+  | BY
+  | CENTURY
+  | CHARACTER
+  | COALESCE
+  | COLLECT
+  | COLUMN
+  | COUNT
+  | CUBE
+  | DAY
+  | DEC
+  | DECADE
+  | DOW
+  | DOY
+  | DROP
+  | EPOCH
+  | EVERY
+  | EXISTS
+  | EXTERNAL
+  | EXTRACT
+  | FILTER
+  | FIRST
+  | FORMAT
+  | FUSION
+  | GROUPING
+  | HASH
+  | INDEX
+  | INSERT
+  | INTERSECTION
+  | ISODOW
+  | ISOYEAR
+  | LAST
+  | LESS
+  | LIST
+  | LOCATION
+  | MAX
+  | MAXVALUE
+  | MICROSECONDS
+  | MILLENNIUM
+  | MILLISECONDS
+  | MIN
+  | MINUTE
+  | MONTH
+  | NATIONAL
+  | NULLIF
+  | OVERWRITE
+  | PARTITION
+  | PARTITIONS
+  | PRECISION
+  | PURGE
+  | QUARTER
+  | RANGE
+  | REGEXP
+  | RLIKE
+  | ROLLUP
+  | SECOND
+  | SET
+  | SIMILAR
+  | STDDEV_POP
+  | STDDEV_SAMP
+  | SUBPARTITION
+  | SUM
+  | TABLESPACE
+  | THAN
+  | TIMEZONE
+  | TIMEZONE_HOUR
+  | TIMEZONE_MINUTE
+  | TRIM
+  | TO
+  | UNKNOWN
+  | VALUES
+  | VAR_POP
+  | VAR_SAMP
+  | VARYING
+  | WEEK
+  | YEAR
+  | ZONE
+
+  | BIGINT
+  | BIT
+  | BLOB
+  | BOOL
+  | BOOLEAN
+  | BYTEA
+  | CHAR
+  | DATE
+  | DECIMAL
+  | DOUBLE
+  | FLOAT
+  | FLOAT4
+  | FLOAT8
+  | INET4
+  | INT
+  | INT1
+  | INT2
+  | INT4
+  | INT8
+  | INTEGER
+  | NCHAR
+  | NUMERIC
+  | NVARCHAR
+  | REAL
+  | SMALLINT
+  | TEXT
+  | TIME
+  | TIMESTAMP
+  | TIMESTAMPTZ
+  | TIMETZ
+  | TINYINT
+  | VARBINARY
+  | VARBIT
+  | VARCHAR
+  ;
+
+/*
+===============================================================================
   5.3 <literal>
 ===============================================================================
 */
@@ -773,12 +902,12 @@ named_columns_join
   ;
 
 table_primary
-  : table_or_query_name ((AS)? alias=Identifier)? (LEFT_PAREN column_name_list RIGHT_PAREN)?
-  | derived_table (AS)? name=Identifier (LEFT_PAREN column_name_list RIGHT_PAREN)?
+  : table_or_query_name ((AS)? alias=identifier)? (LEFT_PAREN column_name_list RIGHT_PAREN)?
+  | derived_table (AS)? name=identifier (LEFT_PAREN column_name_list RIGHT_PAREN)?
   ;
 
 column_name_list
-  :  Identifier  ( COMMA Identifier  )*
+  :  identifier  ( COMMA identifier  )*
   ;
 
 derived_table
@@ -812,23 +941,27 @@ grouping_element_list
   ;
 
 grouping_element
-  : ordinary_grouping_set
-  | rollup_list
+  : rollup_list
   | cube_list
   | empty_grouping_set
+  | ordinary_grouping_set
   ;
 
 ordinary_grouping_set
-  : row_value_predicand_list
+  : row_value_predicand
   | LEFT_PAREN row_value_predicand_list RIGHT_PAREN
   ;
 
+ordinary_grouping_set_list
+  : ordinary_grouping_set (COMMA ordinary_grouping_set)*
+  ;
+
 rollup_list
-  : ROLLUP LEFT_PAREN c=ordinary_grouping_set RIGHT_PAREN
+  : ROLLUP LEFT_PAREN c=ordinary_grouping_set_list RIGHT_PAREN
   ;
 
 cube_list
-  : CUBE LEFT_PAREN c=ordinary_grouping_set RIGHT_PAREN
+  : CUBE LEFT_PAREN c=ordinary_grouping_set_list RIGHT_PAREN
   ;
 
 empty_grouping_set
@@ -895,11 +1028,11 @@ explicit_table
 
 table_or_query_name
   : table_name
-  | Identifier
+  | identifier
   ;
 
 table_name
-  : Identifier  ( DOT  Identifier (  DOT Identifier )? )?
+  : identifier  ( DOT  identifier (  DOT identifier )? )?
   ;
 
 query_specification
@@ -913,7 +1046,7 @@ select_list
 
 select_sublist
   : derived_column
-  | asterisked_qualifier=Identifier DOT MULTIPLY
+  | asterisked_qualifier=identifier DOT MULTIPLY
   ;
 
 set_qualifier
@@ -926,11 +1059,11 @@ derived_column
   ;
 
 column_reference
-  : (tb_name=Identifier DOT)? name=Identifier
+  : (tb_name=identifier DOT)? name=identifier
   ;
 
 as_clause
-  : (AS)? Identifier
+  : (AS)? identifier
   ;
 
 column_reference_list
@@ -1156,7 +1289,7 @@ function_names_for_reserved_words
   ;
 
 function_name
-  : Identifier
+  : identifier
   | function_names_for_reserved_words
   ;
 
@@ -1204,5 +1337,5 @@ null_ordering
 
 insert_statement
   : INSERT (OVERWRITE)? INTO table_name (LEFT_PAREN column_name_list RIGHT_PAREN)? query_expression
-  | INSERT (OVERWRITE)? INTO LOCATION path=Character_String_Literal (USING file_type=Identifier
(param_clause)?)? query_expression
+  | INSERT (OVERWRITE)? INTO LOCATION path=Character_String_Literal (USING file_type=identifier
(param_clause)?)? query_expression
   ;

http://git-wip-us.apache.org/repos/asf/incubator-tajo/blob/b0d81a59/tajo-core/tajo-core-backend/src/main/java/org/apache/tajo/engine/parser/SQLAnalyzer.java
----------------------------------------------------------------------
diff --git a/tajo-core/tajo-core-backend/src/main/java/org/apache/tajo/engine/parser/SQLAnalyzer.java
b/tajo-core/tajo-core-backend/src/main/java/org/apache/tajo/engine/parser/SQLAnalyzer.java
index daa8f8d..493f892 100644
--- a/tajo-core/tajo-core-backend/src/main/java/org/apache/tajo/engine/parser/SQLAnalyzer.java
+++ b/tajo-core/tajo-core-backend/src/main/java/org/apache/tajo/engine/parser/SQLAnalyzer.java
@@ -31,9 +31,7 @@ import org.apache.tajo.algebra.LiteralValue.LiteralType;
 import org.apache.tajo.engine.parser.SQLParser.*;
 import org.apache.tajo.storage.CSVFile;
 
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
 
 import static org.apache.tajo.algebra.Aggregation.GroupElement;
 import static org.apache.tajo.algebra.CreateTable.*;
@@ -275,23 +273,37 @@ public class SQLAnalyzer extends SQLParserBaseVisitor<Expr> {
 
     // If grouping group is not empty
     if (ctx.grouping_element_list().grouping_element().get(0).empty_grouping_set() == null)
{
-      GroupElement [] groups = new GroupElement[ctx.grouping_element_list().
-          grouping_element().size()];
-      for (int i = 0; i < groups.length; i++) {
+      int elementSize = ctx.grouping_element_list().grouping_element().size();
+      ArrayList<GroupElement> groups = new ArrayList<GroupElement>(elementSize
+ 1);
+      ArrayList<Expr> ordinaryExprs = null;
+      int groupSize = 1;
+      groups.add(null);
+
+      for (int i = 0; i < elementSize; i++) {
         SQLParser.Grouping_elementContext element =
             ctx.grouping_element_list().grouping_element().get(i);
         if (element.ordinary_grouping_set() != null) {
-          groups[i] = new GroupElement(GroupType.OrdinaryGroup,
-              getRowValuePredicands(element.ordinary_grouping_set().row_value_predicand_list()));
+          if (ordinaryExprs == null) {
+            ordinaryExprs = new ArrayList<Expr>();
+          }
+          Collections.addAll(ordinaryExprs, getRowValuePredicandsFromOrdinaryGroupingSet(element.ordinary_grouping_set()));
         } else if (element.rollup_list() != null) {
-          groups[i] = new GroupElement(GroupType.Rollup,
-              getRowValuePredicands(element.rollup_list().c.row_value_predicand_list()));
+          groupSize++;
+          groups.add(new GroupElement(GroupType.Rollup,
+              getRowValuePredicandsFromOrdinaryGroupingSetList(element.rollup_list().c)));
         } else if (element.cube_list() != null) {
-          groups[i] = new GroupElement(GroupType.Cube,
-              getRowValuePredicands(element.cube_list().c.row_value_predicand_list()));
+          groupSize++;
+          groups.add(new GroupElement(GroupType.Cube,
+              getRowValuePredicandsFromOrdinaryGroupingSetList(element.cube_list().c)));
         }
       }
-      clause.setGroups(groups);
+
+      if (ordinaryExprs != null) {
+        groups.set(0, new GroupElement(GroupType.OrdinaryGroup, ordinaryExprs.toArray(new
Expr[ordinaryExprs.size()])));
+        clause.setGroups(groups.subList(0, groupSize).toArray(new GroupElement[groupSize]));
+      } else if (groupSize > 1) {
+        clause.setGroups(groups.subList(1, groupSize).toArray(new GroupElement[groupSize
- 1]));
+      }
     }
 
     return clause;
@@ -384,6 +396,25 @@ public class SQLAnalyzer extends SQLParserBaseVisitor<Expr> {
     return join;
   }
 
+  private Expr [] getRowValuePredicandsFromOrdinaryGroupingSetList(Ordinary_grouping_set_listContext
ctx) {
+    ArrayList<Expr> rowValuePredicands = new ArrayList<Expr>();
+    for (int i = 0; i < ctx.ordinary_grouping_set().size(); i++) {
+      Collections.addAll(rowValuePredicands, getRowValuePredicandsFromOrdinaryGroupingSet(ctx.ordinary_grouping_set(i)));
+    }
+    return rowValuePredicands.toArray(new Expr[rowValuePredicands.size()]);
+  }
+
+  private Expr [] getRowValuePredicandsFromOrdinaryGroupingSet(Ordinary_grouping_setContext
ctx) {
+    ArrayList<Expr> rowValuePredicands = new ArrayList<Expr>();
+    if (ctx.row_value_predicand() != null) {
+      rowValuePredicands.add(visitRow_value_predicand(ctx.row_value_predicand()));
+    }
+    if (ctx.row_value_predicand_list() != null) {
+      Collections.addAll(rowValuePredicands, getRowValuePredicands(ctx.row_value_predicand_list()));
+    }
+    return rowValuePredicands.toArray(new Expr[rowValuePredicands.size()]);
+  }
+
   private Expr [] getRowValuePredicands(Row_value_predicand_listContext ctx) {
     Expr [] rowValuePredicands = new Expr[ctx.row_value_predicand().size()];
     for (int i = 0; i < rowValuePredicands.length; i++) {
@@ -833,7 +864,7 @@ public class SQLAnalyzer extends SQLParserBaseVisitor<Expr> {
   public NamedExpr visitDerived_column(SQLParser.Derived_columnContext ctx) {
     NamedExpr target = new NamedExpr(visitValue_expression(ctx.value_expression()));
     if (ctx.as_clause() != null) {
-      target.setAlias(ctx.as_clause().Identifier().getText());
+      target.setAlias(ctx.as_clause().identifier().getText());
     }
     return target;
   }
@@ -1197,9 +1228,9 @@ public class SQLAnalyzer extends SQLParserBaseVisitor<Expr> {
       insertExpr.setTableName(ctx.table_name().getText());
 
       if (ctx.column_name_list() != null) {
-        String [] targetColumns = new String[ctx.column_name_list().Identifier().size()];
+        String [] targetColumns = new String[ctx.column_name_list().identifier().size()];
         for (int i = 0; i < targetColumns.length; i++) {
-          targetColumns[i] = ctx.column_name_list().Identifier().get(i).getText();
+          targetColumns[i] = ctx.column_name_list().identifier().get(i).getText();
         }
 
         insertExpr.setTargetColumns(targetColumns);

http://git-wip-us.apache.org/repos/asf/incubator-tajo/blob/b0d81a59/tajo-core/tajo-core-backend/src/test/java/org/apache/tajo/engine/query/TestCreateTable.java
----------------------------------------------------------------------
diff --git a/tajo-core/tajo-core-backend/src/test/java/org/apache/tajo/engine/query/TestCreateTable.java
b/tajo-core/tajo-core-backend/src/test/java/org/apache/tajo/engine/query/TestCreateTable.java
index f6930ba..f39ceb8 100644
--- a/tajo-core/tajo-core-backend/src/test/java/org/apache/tajo/engine/query/TestCreateTable.java
+++ b/tajo-core/tajo-core-backend/src/test/java/org/apache/tajo/engine/query/TestCreateTable.java
@@ -37,4 +37,126 @@ public class TestCreateTable extends QueryTestCaseBase {
     String tableName = executeDDL("table1_ddl.sql", "table1.tbl", "table1");
     assertTableExists(tableName);
   }
+
+  @Test
+  public final void testNonreservedKeywordTableNames() throws Exception {
+    String tableName = null;
+    tableName = executeDDL("table1_ddl.sql", "table1.tbl", "filter");
+    assertTableExists(tableName);
+    tableName = executeDDL("table1_ddl.sql", "table1.tbl", "first");
+    assertTableExists(tableName);
+    tableName = executeDDL("table1_ddl.sql", "table1.tbl", "format");
+    assertTableExists(tableName);
+    tableName = executeDDL("table1_ddl.sql", "table1.tbl", "grouping");
+    assertTableExists(tableName);
+    tableName = executeDDL("table1_ddl.sql", "table1.tbl", "hash");
+    assertTableExists(tableName);
+    tableName = executeDDL("table1_ddl.sql", "table1.tbl", "index");
+    assertTableExists(tableName);
+    tableName = executeDDL("table1_ddl.sql", "table1.tbl", "insert");
+    assertTableExists(tableName);
+    tableName = executeDDL("table1_ddl.sql", "table1.tbl", "last");
+    assertTableExists(tableName);
+    tableName = executeDDL("table1_ddl.sql", "table1.tbl", "location");
+    assertTableExists(tableName);
+    tableName = executeDDL("table1_ddl.sql", "table1.tbl", "max");
+    assertTableExists(tableName);
+    tableName = executeDDL("table1_ddl.sql", "table1.tbl", "min");
+    assertTableExists(tableName);
+    tableName = executeDDL("table1_ddl.sql", "table1.tbl", "national");
+    assertTableExists(tableName);
+    tableName = executeDDL("table1_ddl.sql", "table1.tbl", "nullif");
+    assertTableExists(tableName);
+    tableName = executeDDL("table1_ddl.sql", "table1.tbl", "overwrite");
+    assertTableExists(tableName);
+    tableName = executeDDL("table1_ddl.sql", "table1.tbl", "precision");
+    assertTableExists(tableName);
+    tableName = executeDDL("table1_ddl.sql", "table1.tbl", "range");
+    assertTableExists(tableName);
+    tableName = executeDDL("table1_ddl.sql", "table1.tbl", "regexp");
+    assertTableExists(tableName);
+    tableName = executeDDL("table1_ddl.sql", "table1.tbl", "rlike");
+    assertTableExists(tableName);
+    tableName = executeDDL("table1_ddl.sql", "table1.tbl", "set");
+    assertTableExists(tableName);
+    tableName = executeDDL("table1_ddl.sql", "table1.tbl", "unknown");
+    assertTableExists(tableName);
+    tableName = executeDDL("table1_ddl.sql", "table1.tbl", "var_pop");
+    assertTableExists(tableName);
+    tableName = executeDDL("table1_ddl.sql", "table1.tbl", "var_samp");
+    assertTableExists(tableName);
+    tableName = executeDDL("table1_ddl.sql", "table1.tbl", "varying");
+    assertTableExists(tableName);
+    tableName = executeDDL("table1_ddl.sql", "table1.tbl", "zone");
+    assertTableExists(tableName);
+
+    tableName = executeDDL("table1_ddl.sql", "table1.tbl", "bigint");
+    assertTableExists(tableName);
+    tableName = executeDDL("table1_ddl.sql", "table1.tbl", "bit");
+    assertTableExists(tableName);
+    tableName = executeDDL("table1_ddl.sql", "table1.tbl", "blob");
+    assertTableExists(tableName);
+    tableName = executeDDL("table1_ddl.sql", "table1.tbl", "bool");
+    assertTableExists(tableName);
+    tableName = executeDDL("table1_ddl.sql", "table1.tbl", "boolean");
+    assertTableExists(tableName);
+    tableName = executeDDL("table1_ddl.sql", "table1.tbl", "bytea");
+    assertTableExists(tableName);
+    tableName = executeDDL("table1_ddl.sql", "table1.tbl", "char");
+    assertTableExists(tableName);
+    tableName = executeDDL("table1_ddl.sql", "table1.tbl", "date");
+    assertTableExists(tableName);
+    tableName = executeDDL("table1_ddl.sql", "table1.tbl", "decimal");
+    assertTableExists(tableName);
+    tableName = executeDDL("table1_ddl.sql", "table1.tbl", "double");
+    assertTableExists(tableName);
+    tableName = executeDDL("table1_ddl.sql", "table1.tbl", "float");
+    assertTableExists(tableName);
+    tableName = executeDDL("table1_ddl.sql", "table1.tbl", "float4");
+    assertTableExists(tableName);
+    tableName = executeDDL("table1_ddl.sql", "table1.tbl", "float8");
+    assertTableExists(tableName);
+    tableName = executeDDL("table1_ddl.sql", "table1.tbl", "inet4");
+    assertTableExists(tableName);
+    tableName = executeDDL("table1_ddl.sql", "table1.tbl", "int");
+    assertTableExists(tableName);
+    tableName = executeDDL("table1_ddl.sql", "table1.tbl", "int1");
+    assertTableExists(tableName);
+    tableName = executeDDL("table1_ddl.sql", "table1.tbl", "int2");
+    assertTableExists(tableName);
+    tableName = executeDDL("table1_ddl.sql", "table1.tbl", "int4");
+    assertTableExists(tableName);
+    tableName = executeDDL("table1_ddl.sql", "table1.tbl", "int8");
+    assertTableExists(tableName);
+    tableName = executeDDL("table1_ddl.sql", "table1.tbl", "integer");
+    assertTableExists(tableName);
+    tableName = executeDDL("table1_ddl.sql", "table1.tbl", "nchar");
+    assertTableExists(tableName);
+    tableName = executeDDL("table1_ddl.sql", "table1.tbl", "numeric");
+    assertTableExists(tableName);
+    tableName = executeDDL("table1_ddl.sql", "table1.tbl", "nvarchar");
+    assertTableExists(tableName);
+    tableName = executeDDL("table1_ddl.sql", "table1.tbl", "real");
+    assertTableExists(tableName);
+    tableName = executeDDL("table1_ddl.sql", "table1.tbl", "smallint");
+    assertTableExists(tableName);
+    tableName = executeDDL("table1_ddl.sql", "table1.tbl", "text");
+    assertTableExists(tableName);
+    tableName = executeDDL("table1_ddl.sql", "table1.tbl", "time");
+    assertTableExists(tableName);
+    tableName = executeDDL("table1_ddl.sql", "table1.tbl", "timestamp");
+    assertTableExists(tableName);
+    tableName = executeDDL("table1_ddl.sql", "table1.tbl", "timestamptz");
+    assertTableExists(tableName);
+    tableName = executeDDL("table1_ddl.sql", "table1.tbl", "timetz");
+    assertTableExists(tableName);
+    tableName = executeDDL("table1_ddl.sql", "table1.tbl", "tinyint");
+    assertTableExists(tableName);
+    tableName = executeDDL("table1_ddl.sql", "table1.tbl", "varbinary");
+    assertTableExists(tableName);
+    tableName = executeDDL("table1_ddl.sql", "table1.tbl", "varbit");
+    assertTableExists(tableName);
+    tableName = executeDDL("table1_ddl.sql", "table1.tbl", "varchar");
+    assertTableExists(tableName);
+  }
 }


Mime
View raw message