hive-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nzh...@apache.org
Subject svn commit: r1196354 - in /hive/trunk: metastore/src/java/org/apache/hadoop/hive/metastore/ ql/src/java/org/apache/hadoop/hive/ql/parse/ ql/src/test/queries/clientnegative/ ql/src/test/queries/clientpositive/ ql/src/test/results/clientnegative/ ql/src/...
Date Tue, 01 Nov 2011 23:04:42 GMT
Author: nzhang
Date: Tue Nov  1 23:04:41 2011
New Revision: 1196354

URL: http://svn.apache.org/viewvc?rev=1196354&view=rev
Log:
HIVE-2510. Hive throws Null Pointer Exception upon CREATE TABLE <db>.<tbl>if <db>
does not exists

Added:
    hive/trunk/ql/src/test/queries/clientnegative/create_table_failure1.q
    hive/trunk/ql/src/test/queries/clientnegative/create_table_failure2.q
    hive/trunk/ql/src/test/queries/clientnegative/create_table_failure3.q
    hive/trunk/ql/src/test/queries/clientnegative/create_table_failure4.q
    hive/trunk/ql/src/test/queries/clientpositive/input46.q
    hive/trunk/ql/src/test/results/clientnegative/create_table_failure1.q.out
    hive/trunk/ql/src/test/results/clientnegative/create_table_failure2.q.out
    hive/trunk/ql/src/test/results/clientnegative/create_table_failure3.q.out
    hive/trunk/ql/src/test/results/clientnegative/create_table_failure4.q.out
    hive/trunk/ql/src/test/results/clientpositive/input46.q.out
Modified:
    hive/trunk/metastore/src/java/org/apache/hadoop/hive/metastore/HiveMetaStore.java
    hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/parse/ErrorMsg.java
    hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/parse/SemanticAnalyzer.java

Modified: hive/trunk/metastore/src/java/org/apache/hadoop/hive/metastore/HiveMetaStore.java
URL: http://svn.apache.org/viewvc/hive/trunk/metastore/src/java/org/apache/hadoop/hive/metastore/HiveMetaStore.java?rev=1196354&r1=1196353&r2=1196354&view=diff
==============================================================================
--- hive/trunk/metastore/src/java/org/apache/hadoop/hive/metastore/HiveMetaStore.java (original)
+++ hive/trunk/metastore/src/java/org/apache/hadoop/hive/metastore/HiveMetaStore.java Tue
Nov  1 23:04:41 2011
@@ -972,6 +972,10 @@ public class HiveMetaStore extends Thrif
       try {
         ms.openTransaction();
 
+        if(ms.getDatabase(tbl.getDbName()) == null){
+          throw new NoSuchObjectException("The database " + tbl.getDbName() + " does not
exist");
+        }
+
         // get_table checks whether database exists, it should be moved here
         if (is_table_exists(ms, tbl.getDbName(), tbl.getTableName())) {
           throw new AlreadyExistsException("Table " + tbl.getTableName()
@@ -1044,6 +1048,8 @@ public class HiveMetaStore extends Thrif
         throw e;
       } catch (InvalidObjectException e) {
         throw e;
+      }catch (NoSuchObjectException e) {
+        throw new InvalidObjectException(e.getMessage());
       } catch (Exception e) {
         assert(e instanceof RuntimeException);
         throw (RuntimeException)e;

Modified: hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/parse/ErrorMsg.java
URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/parse/ErrorMsg.java?rev=1196354&r1=1196353&r2=1196354&view=diff
==============================================================================
--- hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/parse/ErrorMsg.java (original)
+++ hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/parse/ErrorMsg.java Tue Nov  1 23:04:41
2011
@@ -118,6 +118,7 @@ public enum ErrorMsg {
       + "table"),
   CTAS_MULTI_LOADFILE("CREATE-TABLE-AS-SELECT results in multiple file load"),
   CTAS_EXTTBL_COEXISTENCE("CREATE-TABLE-AS-SELECT cannot create external table"),
+  DATABASE_NOT_EXISTS("Database does not exist:"),
   TABLE_ALREADY_EXISTS("Table already exists:", "42S02"),
   COLUMN_ALIAS_ALREADY_EXISTS("Column alias already exists:", "42S02"),
   UDTF_MULTIPLE_EXPR("Only a single expression in the SELECT clause is supported with UDTF's"),

Modified: hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/parse/SemanticAnalyzer.java
URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/parse/SemanticAnalyzer.java?rev=1196354&r1=1196353&r2=1196354&view=diff
==============================================================================
--- hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/parse/SemanticAnalyzer.java (original)
+++ hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/parse/SemanticAnalyzer.java Tue Nov 
1 23:04:41 2011
@@ -7840,6 +7840,9 @@ public class SemanticAnalyzer extends Ba
       // Verify that the table does not already exist
       try {
         Table dumpTable = db.newTable(tableName);
+        if (null == db.getDatabase(dumpTable.getDbName()) ) {
+          throw new SemanticException(ErrorMsg.DATABASE_NOT_EXISTS.getMsg(dumpTable.getDbName()));
+        }
         if (null != db.getTable(dumpTable.getDbName(), dumpTable.getTableName(), false))
{
           throw new SemanticException(ErrorMsg.TABLE_ALREADY_EXISTS.getMsg(tableName));
         }

Added: hive/trunk/ql/src/test/queries/clientnegative/create_table_failure1.q
URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/test/queries/clientnegative/create_table_failure1.q?rev=1196354&view=auto
==============================================================================
--- hive/trunk/ql/src/test/queries/clientnegative/create_table_failure1.q (added)
+++ hive/trunk/ql/src/test/queries/clientnegative/create_table_failure1.q Tue Nov  1 23:04:41
2011
@@ -0,0 +1 @@
+create table table_in_database_creation_not_exist.test as select * from src limit 1;
\ No newline at end of file

Added: hive/trunk/ql/src/test/queries/clientnegative/create_table_failure2.q
URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/test/queries/clientnegative/create_table_failure2.q?rev=1196354&view=auto
==============================================================================
--- hive/trunk/ql/src/test/queries/clientnegative/create_table_failure2.q (added)
+++ hive/trunk/ql/src/test/queries/clientnegative/create_table_failure2.q Tue Nov  1 23:04:41
2011
@@ -0,0 +1 @@
+create table `table_in_database_creation_not_exist.test` as select * from src limit 1;
\ No newline at end of file

Added: hive/trunk/ql/src/test/queries/clientnegative/create_table_failure3.q
URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/test/queries/clientnegative/create_table_failure3.q?rev=1196354&view=auto
==============================================================================
--- hive/trunk/ql/src/test/queries/clientnegative/create_table_failure3.q (added)
+++ hive/trunk/ql/src/test/queries/clientnegative/create_table_failure3.q Tue Nov  1 23:04:41
2011
@@ -0,0 +1 @@
+create table table_in_database_creation_not_exist.test (a string);
\ No newline at end of file

Added: hive/trunk/ql/src/test/queries/clientnegative/create_table_failure4.q
URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/test/queries/clientnegative/create_table_failure4.q?rev=1196354&view=auto
==============================================================================
--- hive/trunk/ql/src/test/queries/clientnegative/create_table_failure4.q (added)
+++ hive/trunk/ql/src/test/queries/clientnegative/create_table_failure4.q Tue Nov  1 23:04:41
2011
@@ -0,0 +1 @@
+create table `table_in_database_creation_not_exist.test` (a string);
\ No newline at end of file

Added: hive/trunk/ql/src/test/queries/clientpositive/input46.q
URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/test/queries/clientpositive/input46.q?rev=1196354&view=auto
==============================================================================
--- hive/trunk/ql/src/test/queries/clientpositive/input46.q (added)
+++ hive/trunk/ql/src/test/queries/clientpositive/input46.q Tue Nov  1 23:04:41 2011
@@ -0,0 +1,6 @@
+create database if not exists table_in_database_creation;
+create table table_in_database_creation.test1  as select * from src limit 1;
+create table `table_in_database_creation.test2` as select * from src limit 1;
+create table table_in_database_creation.test3 (a string);
+create table `table_in_database_creation.test4` (a string);
+drop database table_in_database_creation cascade;
\ No newline at end of file

Added: hive/trunk/ql/src/test/results/clientnegative/create_table_failure1.q.out
URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/test/results/clientnegative/create_table_failure1.q.out?rev=1196354&view=auto
==============================================================================
--- hive/trunk/ql/src/test/results/clientnegative/create_table_failure1.q.out (added)
+++ hive/trunk/ql/src/test/results/clientnegative/create_table_failure1.q.out Tue Nov  1 23:04:41
2011
@@ -0,0 +1 @@
+FAILED: Error in semantic analysis: org.apache.hadoop.hive.ql.parse.SemanticException: Database
does not exist: table_in_database_creation_not_exist

Added: hive/trunk/ql/src/test/results/clientnegative/create_table_failure2.q.out
URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/test/results/clientnegative/create_table_failure2.q.out?rev=1196354&view=auto
==============================================================================
--- hive/trunk/ql/src/test/results/clientnegative/create_table_failure2.q.out (added)
+++ hive/trunk/ql/src/test/results/clientnegative/create_table_failure2.q.out Tue Nov  1 23:04:41
2011
@@ -0,0 +1 @@
+FAILED: Error in semantic analysis: org.apache.hadoop.hive.ql.parse.SemanticException: Database
does not exist: table_in_database_creation_not_exist

Added: hive/trunk/ql/src/test/results/clientnegative/create_table_failure3.q.out
URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/test/results/clientnegative/create_table_failure3.q.out?rev=1196354&view=auto
==============================================================================
--- hive/trunk/ql/src/test/results/clientnegative/create_table_failure3.q.out (added)
+++ hive/trunk/ql/src/test/results/clientnegative/create_table_failure3.q.out Tue Nov  1 23:04:41
2011
@@ -0,0 +1,4 @@
+PREHOOK: query: create table table_in_database_creation_not_exist.test (a string)
+PREHOOK: type: CREATETABLE
+FAILED: Error in metadata: InvalidObjectException(message:There is no database named table_in_database_creation_not_exist)
+FAILED: Execution Error, return code 1 from org.apache.hadoop.hive.ql.exec.DDLTask

Added: hive/trunk/ql/src/test/results/clientnegative/create_table_failure4.q.out
URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/test/results/clientnegative/create_table_failure4.q.out?rev=1196354&view=auto
==============================================================================
--- hive/trunk/ql/src/test/results/clientnegative/create_table_failure4.q.out (added)
+++ hive/trunk/ql/src/test/results/clientnegative/create_table_failure4.q.out Tue Nov  1 23:04:41
2011
@@ -0,0 +1,4 @@
+PREHOOK: query: create table `table_in_database_creation_not_exist.test` (a string)
+PREHOOK: type: CREATETABLE
+FAILED: Error in metadata: InvalidObjectException(message:There is no database named table_in_database_creation_not_exist)
+FAILED: Execution Error, return code 1 from org.apache.hadoop.hive.ql.exec.DDLTask

Added: hive/trunk/ql/src/test/results/clientpositive/input46.q.out
URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/test/results/clientpositive/input46.q.out?rev=1196354&view=auto
==============================================================================
--- hive/trunk/ql/src/test/results/clientpositive/input46.q.out (added)
+++ hive/trunk/ql/src/test/results/clientpositive/input46.q.out Tue Nov  1 23:04:41 2011
@@ -0,0 +1,32 @@
+PREHOOK: query: create database if not exists table_in_database_creation
+PREHOOK: type: CREATEDATABASE
+POSTHOOK: query: create database if not exists table_in_database_creation
+POSTHOOK: type: CREATEDATABASE
+PREHOOK: query: create table table_in_database_creation.test1  as select * from src limit
1
+PREHOOK: type: CREATETABLE_AS_SELECT
+PREHOOK: Input: default@src
+POSTHOOK: query: create table table_in_database_creation.test1  as select * from src limit
1
+POSTHOOK: type: CREATETABLE_AS_SELECT
+POSTHOOK: Input: default@src
+POSTHOOK: Output: table_in_database_creation@test1
+PREHOOK: query: create table `table_in_database_creation.test2` as select * from src limit
1
+PREHOOK: type: CREATETABLE_AS_SELECT
+PREHOOK: Input: default@src
+POSTHOOK: query: create table `table_in_database_creation.test2` as select * from src limit
1
+POSTHOOK: type: CREATETABLE_AS_SELECT
+POSTHOOK: Input: default@src
+POSTHOOK: Output: table_in_database_creation@test2
+PREHOOK: query: create table table_in_database_creation.test3 (a string)
+PREHOOK: type: CREATETABLE
+POSTHOOK: query: create table table_in_database_creation.test3 (a string)
+POSTHOOK: type: CREATETABLE
+POSTHOOK: Output: table_in_database_creation@test3
+PREHOOK: query: create table `table_in_database_creation.test4` (a string)
+PREHOOK: type: CREATETABLE
+POSTHOOK: query: create table `table_in_database_creation.test4` (a string)
+POSTHOOK: type: CREATETABLE
+POSTHOOK: Output: table_in_database_creation@test4
+PREHOOK: query: drop database table_in_database_creation cascade
+PREHOOK: type: DROPDATABASE
+POSTHOOK: query: drop database table_in_database_creation cascade
+POSTHOOK: type: DROPDATABASE



Mime
View raw message