Repository: incubator-impala
Updated Branches:
  refs/heads/master 40bce4176 -> 1af0aa4ad


IMPALA-4384: NPE when cols list has trailing comma

The changes to introduce new PRIMARY KEY syntax allowed for
a table definition to have a list of cols, optionally
followed by a PRIMARY KEY clause. However, this rule
was broken and would allow for the list of columns followed
by a trailing comma.

[localhost:21000] > create table foo (id int, x int,);
Query: create table foo (id int, x int,)
ERROR: AnalysisException: null
CAUSED BY: NullPointerException: null

Change-Id: Ibc394dd7e687b501ae7887a51bed2f441d562760
Reviewed-on: http://gerrit.cloudera.org:8080/4869
Reviewed-by: Matthew Jacobs <[email protected]>
Tested-by: Internal Jenkins


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

Branch: refs/heads/master
Commit: a9a00858da2fca89de0efc54393a97c68c033ea6
Parents: 40bce41
Author: Matthew Jacobs <[email protected]>
Authored: Thu Oct 27 13:12:51 2016 -0700
Committer: Internal Jenkins <[email protected]>
Committed: Thu Nov 3 21:37:20 2016 +0000

----------------------------------------------------------------------
 fe/src/main/cup/sql-parser.cup                              | 9 +--------
 fe/src/test/java/org/apache/impala/analysis/ParserTest.java | 5 +++--
 2 files changed, 4 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-impala/blob/a9a00858/fe/src/main/cup/sql-parser.cup
----------------------------------------------------------------------
diff --git a/fe/src/main/cup/sql-parser.cup b/fe/src/main/cup/sql-parser.cup
index 7554b5a..af4f7a6 100644
--- a/fe/src/main/cup/sql-parser.cup
+++ b/fe/src/main/cup/sql-parser.cup
@@ -1058,7 +1058,7 @@ tbl_def_with_col_defs ::=
     tbl_def.getColumnDefs().addAll(list);
     RESULT = tbl_def;
   :}
-  | tbl_def_without_col_defs:tbl_def LPAREN column_def_list:list COMMA 
opt_primary_keys:primary_keys RPAREN
+  | tbl_def_without_col_defs:tbl_def LPAREN column_def_list:list COMMA 
primary_keys:primary_keys RPAREN
   {:
     tbl_def.getColumnDefs().addAll(list);
     tbl_def.getPrimaryKeyColumnNames().addAll(primary_keys);
@@ -1066,13 +1066,6 @@ tbl_def_with_col_defs ::=
   :}
   ;
 
-opt_primary_keys ::=
-  primary_keys:col_names
-  {: RESULT = col_names; :}
-  | /* empty */
-  {: RESULT = null; :}
-  ;
-
 primary_keys ::=
   KW_PRIMARY key_ident LPAREN ident_list:col_names RPAREN
   {: RESULT = col_names; :}

http://git-wip-us.apache.org/repos/asf/incubator-impala/blob/a9a00858/fe/src/test/java/org/apache/impala/analysis/ParserTest.java
----------------------------------------------------------------------
diff --git a/fe/src/test/java/org/apache/impala/analysis/ParserTest.java 
b/fe/src/test/java/org/apache/impala/analysis/ParserTest.java
index 6308293..6dab5f3 100644
--- a/fe/src/test/java/org/apache/impala/analysis/ParserTest.java
+++ b/fe/src/test/java/org/apache/impala/analysis/ParserTest.java
@@ -28,11 +28,11 @@ import java.util.ArrayList;
 import java.util.List;
 
 import org.apache.hadoop.hive.metastore.MetaStoreUtils;
-import org.junit.Test;
-
 import org.apache.impala.analysis.TimestampArithmeticExpr.TimeUnit;
 import org.apache.impala.common.AnalysisException;
 import org.apache.impala.testutil.TestUtils;
+import org.junit.Test;
+
 import com.google.common.base.Preconditions;
 import com.google.common.collect.Lists;
 
@@ -2346,6 +2346,7 @@ public class ParserTest {
     ParserError("CREATE TABLE Foo i int");
     ParserError("CREATE TABLE Foo (i intt)");
     ParserError("CREATE TABLE Foo (int i)");
+    ParserError("CREATE TABLE Foo (i int,)");
     ParserError("CREATE TABLE Foo ()");
     ParserError("CREATE TABLE");
     ParserError("CREATE EXTERNAL");

Reply via email to