[16/50] [abbrv] hive git commit: HIVE-11441: No DDL allowed on table if user accidentally set table location wrong (Daniel Dai reviewed by Thejas Nair)

2015-08-25 Thread sershe
HIVE-11441: No DDL allowed on table if user accidentally set table location 
wrong (Daniel Dai reviewed by Thejas Nair)


Project: http://git-wip-us.apache.org/repos/asf/hive/repo
Commit: http://git-wip-us.apache.org/repos/asf/hive/commit/2ccd0616
Tree: http://git-wip-us.apache.org/repos/asf/hive/tree/2ccd0616
Diff: http://git-wip-us.apache.org/repos/asf/hive/diff/2ccd0616

Branch: refs/heads/llap
Commit: 2ccd061691cd52ed9fa341b61590edb2c022b031
Parents: 17e95c7
Author: Daniel Dai da...@hortonworks.com
Authored: Fri Aug 14 15:28:44 2015 -0700
Committer: Daniel Dai da...@hortonworks.com
Committed: Fri Aug 14 15:28:44 2015 -0700

--
 .../apache/hadoop/hive/ql/parse/DDLSemanticAnalyzer.java | 11 +++
 .../queries/clientnegative/alter_table_wrong_location.q  |  4 
 .../clientnegative/alter_table_wrong_location.q.out  |  9 +
 3 files changed, 24 insertions(+)
--


http://git-wip-us.apache.org/repos/asf/hive/blob/2ccd0616/ql/src/java/org/apache/hadoop/hive/ql/parse/DDLSemanticAnalyzer.java
--
diff --git 
a/ql/src/java/org/apache/hadoop/hive/ql/parse/DDLSemanticAnalyzer.java 
b/ql/src/java/org/apache/hadoop/hive/ql/parse/DDLSemanticAnalyzer.java
index 21625bc..9f8c756 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/parse/DDLSemanticAnalyzer.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/parse/DDLSemanticAnalyzer.java
@@ -23,6 +23,7 @@ import org.antlr.runtime.tree.CommonTree;
 import org.antlr.runtime.tree.Tree;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.apache.hadoop.fs.FileSystem;
 import org.apache.hadoop.fs.Path;
 import org.apache.hadoop.hive.common.JavaUtils;
 import org.apache.hadoop.hive.conf.HiveConf;
@@ -137,6 +138,7 @@ import org.apache.hadoop.mapred.InputFormat;
 import org.apache.hadoop.mapred.TextInputFormat;
 import org.apache.hadoop.util.StringUtils;
 
+import java.io.FileNotFoundException;
 import java.io.Serializable;
 import java.lang.reflect.Constructor;
 import java.lang.reflect.InvocationTargetException;
@@ -1464,6 +1466,15 @@ public class DDLSemanticAnalyzer extends 
BaseSemanticAnalyzer {
   HashMapString, String partSpec) throws SemanticException {
 
 String newLocation = unescapeSQLString(ast.getChild(0).getText());
+try {
+  // To make sure host/port pair is valid, the status of the location
+  // does not matter
+  FileSystem.get(new URI(newLocation), conf).getFileStatus(new 
Path(newLocation));
+} catch (FileNotFoundException e) {
+  // Only check host/port pair is valid, wheter the file exist or not does 
not matter
+} catch (Exception e) {
+  throw new SemanticException(Cannot connect to namenode, please check if 
host/port pair for  + newLocation +  is valid, e);
+}
 addLocationToOutputs(newLocation);
 AlterTableDesc alterTblDesc = new AlterTableDesc(tableName, newLocation, 
partSpec);
 

http://git-wip-us.apache.org/repos/asf/hive/blob/2ccd0616/ql/src/test/queries/clientnegative/alter_table_wrong_location.q
--
diff --git a/ql/src/test/queries/clientnegative/alter_table_wrong_location.q 
b/ql/src/test/queries/clientnegative/alter_table_wrong_location.q
new file mode 100644
index 000..3721867
--- /dev/null
+++ b/ql/src/test/queries/clientnegative/alter_table_wrong_location.q
@@ -0,0 +1,4 @@
+create table testwrongloc(id int);
+
+-- Assume port 12345 is not open
+alter table testwrongloc set location 
hdfs://localhost:12345/tmp/testwrongloc;

http://git-wip-us.apache.org/repos/asf/hive/blob/2ccd0616/ql/src/test/results/clientnegative/alter_table_wrong_location.q.out
--
diff --git 
a/ql/src/test/results/clientnegative/alter_table_wrong_location.q.out 
b/ql/src/test/results/clientnegative/alter_table_wrong_location.q.out
new file mode 100644
index 000..d788d55
--- /dev/null
+++ b/ql/src/test/results/clientnegative/alter_table_wrong_location.q.out
@@ -0,0 +1,9 @@
+PREHOOK: query: create table testwrongloc(id int)
+PREHOOK: type: CREATETABLE
+PREHOOK: Output: database:default
+PREHOOK: Output: default@testwrongloc
+POSTHOOK: query: create table testwrongloc(id int)
+POSTHOOK: type: CREATETABLE
+POSTHOOK: Output: database:default
+POSTHOOK: Output: default@testwrongloc
+ A masked pattern was here 



[40/50] [abbrv] hive git commit: HIVE-11441: No DDL allowed on table if user accidentally set table location wrong (Daniel Dai reviewed by Thejas Nair)

2015-08-17 Thread sershe
HIVE-11441: No DDL allowed on table if user accidentally set table location 
wrong (Daniel Dai reviewed by Thejas Nair)


Project: http://git-wip-us.apache.org/repos/asf/hive/repo
Commit: http://git-wip-us.apache.org/repos/asf/hive/commit/2ccd0616
Tree: http://git-wip-us.apache.org/repos/asf/hive/tree/2ccd0616
Diff: http://git-wip-us.apache.org/repos/asf/hive/diff/2ccd0616

Branch: refs/heads/hbase-metastore
Commit: 2ccd061691cd52ed9fa341b61590edb2c022b031
Parents: 17e95c7
Author: Daniel Dai da...@hortonworks.com
Authored: Fri Aug 14 15:28:44 2015 -0700
Committer: Daniel Dai da...@hortonworks.com
Committed: Fri Aug 14 15:28:44 2015 -0700

--
 .../apache/hadoop/hive/ql/parse/DDLSemanticAnalyzer.java | 11 +++
 .../queries/clientnegative/alter_table_wrong_location.q  |  4 
 .../clientnegative/alter_table_wrong_location.q.out  |  9 +
 3 files changed, 24 insertions(+)
--


http://git-wip-us.apache.org/repos/asf/hive/blob/2ccd0616/ql/src/java/org/apache/hadoop/hive/ql/parse/DDLSemanticAnalyzer.java
--
diff --git 
a/ql/src/java/org/apache/hadoop/hive/ql/parse/DDLSemanticAnalyzer.java 
b/ql/src/java/org/apache/hadoop/hive/ql/parse/DDLSemanticAnalyzer.java
index 21625bc..9f8c756 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/parse/DDLSemanticAnalyzer.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/parse/DDLSemanticAnalyzer.java
@@ -23,6 +23,7 @@ import org.antlr.runtime.tree.CommonTree;
 import org.antlr.runtime.tree.Tree;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.apache.hadoop.fs.FileSystem;
 import org.apache.hadoop.fs.Path;
 import org.apache.hadoop.hive.common.JavaUtils;
 import org.apache.hadoop.hive.conf.HiveConf;
@@ -137,6 +138,7 @@ import org.apache.hadoop.mapred.InputFormat;
 import org.apache.hadoop.mapred.TextInputFormat;
 import org.apache.hadoop.util.StringUtils;
 
+import java.io.FileNotFoundException;
 import java.io.Serializable;
 import java.lang.reflect.Constructor;
 import java.lang.reflect.InvocationTargetException;
@@ -1464,6 +1466,15 @@ public class DDLSemanticAnalyzer extends 
BaseSemanticAnalyzer {
   HashMapString, String partSpec) throws SemanticException {
 
 String newLocation = unescapeSQLString(ast.getChild(0).getText());
+try {
+  // To make sure host/port pair is valid, the status of the location
+  // does not matter
+  FileSystem.get(new URI(newLocation), conf).getFileStatus(new 
Path(newLocation));
+} catch (FileNotFoundException e) {
+  // Only check host/port pair is valid, wheter the file exist or not does 
not matter
+} catch (Exception e) {
+  throw new SemanticException(Cannot connect to namenode, please check if 
host/port pair for  + newLocation +  is valid, e);
+}
 addLocationToOutputs(newLocation);
 AlterTableDesc alterTblDesc = new AlterTableDesc(tableName, newLocation, 
partSpec);
 

http://git-wip-us.apache.org/repos/asf/hive/blob/2ccd0616/ql/src/test/queries/clientnegative/alter_table_wrong_location.q
--
diff --git a/ql/src/test/queries/clientnegative/alter_table_wrong_location.q 
b/ql/src/test/queries/clientnegative/alter_table_wrong_location.q
new file mode 100644
index 000..3721867
--- /dev/null
+++ b/ql/src/test/queries/clientnegative/alter_table_wrong_location.q
@@ -0,0 +1,4 @@
+create table testwrongloc(id int);
+
+-- Assume port 12345 is not open
+alter table testwrongloc set location 
hdfs://localhost:12345/tmp/testwrongloc;

http://git-wip-us.apache.org/repos/asf/hive/blob/2ccd0616/ql/src/test/results/clientnegative/alter_table_wrong_location.q.out
--
diff --git 
a/ql/src/test/results/clientnegative/alter_table_wrong_location.q.out 
b/ql/src/test/results/clientnegative/alter_table_wrong_location.q.out
new file mode 100644
index 000..d788d55
--- /dev/null
+++ b/ql/src/test/results/clientnegative/alter_table_wrong_location.q.out
@@ -0,0 +1,9 @@
+PREHOOK: query: create table testwrongloc(id int)
+PREHOOK: type: CREATETABLE
+PREHOOK: Output: database:default
+PREHOOK: Output: default@testwrongloc
+POSTHOOK: query: create table testwrongloc(id int)
+POSTHOOK: type: CREATETABLE
+POSTHOOK: Output: database:default
+POSTHOOK: Output: default@testwrongloc
+ A masked pattern was here 



[1/2] hive git commit: HIVE-11441: No DDL allowed on table if user accidentally set table location wrong (Daniel Dai reviewed by Thejas Nair)

2015-08-14 Thread daijy
Repository: hive
Updated Branches:
  refs/heads/branch-1 b9af10d28 - 878e75b9e


HIVE-11441: No DDL allowed on table if user accidentally set table location 
wrong (Daniel Dai reviewed by Thejas Nair)


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

Branch: refs/heads/branch-1
Commit: b55b6d6000e6606a18e4108c404db3c8170c111e
Parents: 89f16ab
Author: Daniel Dai da...@hortonworks.com
Authored: Fri Aug 14 15:49:13 2015 -0700
Committer: Daniel Dai da...@hortonworks.com
Committed: Fri Aug 14 15:49:13 2015 -0700

--
 .../apache/hadoop/hive/ql/parse/DDLSemanticAnalyzer.java | 11 +++
 .../queries/clientnegative/alter_table_wrong_location.q  |  4 
 .../clientnegative/alter_table_wrong_location.q.out  |  9 +
 3 files changed, 24 insertions(+)
--


http://git-wip-us.apache.org/repos/asf/hive/blob/b55b6d60/ql/src/java/org/apache/hadoop/hive/ql/parse/DDLSemanticAnalyzer.java
--
diff --git 
a/ql/src/java/org/apache/hadoop/hive/ql/parse/DDLSemanticAnalyzer.java 
b/ql/src/java/org/apache/hadoop/hive/ql/parse/DDLSemanticAnalyzer.java
index 24ca663..ba8cdd3 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/parse/DDLSemanticAnalyzer.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/parse/DDLSemanticAnalyzer.java
@@ -21,6 +21,7 @@ package org.apache.hadoop.hive.ql.parse;
 import static org.apache.hadoop.hive.ql.parse.HiveParser.TOK_DATABASELOCATION;
 import static 
org.apache.hadoop.hive.ql.parse.HiveParser.TOK_DATABASEPROPERTIES;
 
+import java.io.FileNotFoundException;
 import java.io.Serializable;
 import java.lang.reflect.Constructor;
 import java.lang.reflect.InvocationTargetException;
@@ -44,6 +45,7 @@ import org.antlr.runtime.tree.CommonTree;
 import org.antlr.runtime.tree.Tree;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.apache.hadoop.fs.FileSystem;
 import org.apache.hadoop.fs.Path;
 import org.apache.hadoop.hive.common.JavaUtils;
 import org.apache.hadoop.hive.conf.HiveConf;
@@ -1467,6 +1469,15 @@ public class DDLSemanticAnalyzer extends 
BaseSemanticAnalyzer {
   HashMapString, String partSpec) throws SemanticException {
 
 String newLocation = unescapeSQLString(ast.getChild(0).getText());
+try {
+  // To make sure host/port pair is valid, the status of the location
+  // does not matter
+  FileSystem.get(new URI(newLocation), conf).getFileStatus(new 
Path(newLocation));
+} catch (FileNotFoundException e) {
+  // Only check host/port pair is valid, wheter the file exist or not does 
not matter
+} catch (Exception e) {
+  throw new SemanticException(Cannot connect to namenode, please check if 
host/port pair for  + newLocation +  is valid, e);
+}
 addLocationToOutputs(newLocation);
 AlterTableDesc alterTblDesc = new AlterTableDesc(tableName, newLocation, 
partSpec);
 

http://git-wip-us.apache.org/repos/asf/hive/blob/b55b6d60/ql/src/test/queries/clientnegative/alter_table_wrong_location.q
--
diff --git a/ql/src/test/queries/clientnegative/alter_table_wrong_location.q 
b/ql/src/test/queries/clientnegative/alter_table_wrong_location.q
new file mode 100644
index 000..3721867
--- /dev/null
+++ b/ql/src/test/queries/clientnegative/alter_table_wrong_location.q
@@ -0,0 +1,4 @@
+create table testwrongloc(id int);
+
+-- Assume port 12345 is not open
+alter table testwrongloc set location 
hdfs://localhost:12345/tmp/testwrongloc;

http://git-wip-us.apache.org/repos/asf/hive/blob/b55b6d60/ql/src/test/results/clientnegative/alter_table_wrong_location.q.out
--
diff --git 
a/ql/src/test/results/clientnegative/alter_table_wrong_location.q.out 
b/ql/src/test/results/clientnegative/alter_table_wrong_location.q.out
new file mode 100644
index 000..d788d55
--- /dev/null
+++ b/ql/src/test/results/clientnegative/alter_table_wrong_location.q.out
@@ -0,0 +1,9 @@
+PREHOOK: query: create table testwrongloc(id int)
+PREHOOK: type: CREATETABLE
+PREHOOK: Output: database:default
+PREHOOK: Output: default@testwrongloc
+POSTHOOK: query: create table testwrongloc(id int)
+POSTHOOK: type: CREATETABLE
+POSTHOOK: Output: database:default
+POSTHOOK: Output: default@testwrongloc
+ A masked pattern was here 



hive git commit: HIVE-11441: No DDL allowed on table if user accidentally set table location wrong (Daniel Dai reviewed by Thejas Nair)

2015-08-14 Thread daijy
Repository: hive
Updated Branches:
  refs/heads/master 17e95c7c7 - 2ccd06169


HIVE-11441: No DDL allowed on table if user accidentally set table location 
wrong (Daniel Dai reviewed by Thejas Nair)


Project: http://git-wip-us.apache.org/repos/asf/hive/repo
Commit: http://git-wip-us.apache.org/repos/asf/hive/commit/2ccd0616
Tree: http://git-wip-us.apache.org/repos/asf/hive/tree/2ccd0616
Diff: http://git-wip-us.apache.org/repos/asf/hive/diff/2ccd0616

Branch: refs/heads/master
Commit: 2ccd061691cd52ed9fa341b61590edb2c022b031
Parents: 17e95c7
Author: Daniel Dai da...@hortonworks.com
Authored: Fri Aug 14 15:28:44 2015 -0700
Committer: Daniel Dai da...@hortonworks.com
Committed: Fri Aug 14 15:28:44 2015 -0700

--
 .../apache/hadoop/hive/ql/parse/DDLSemanticAnalyzer.java | 11 +++
 .../queries/clientnegative/alter_table_wrong_location.q  |  4 
 .../clientnegative/alter_table_wrong_location.q.out  |  9 +
 3 files changed, 24 insertions(+)
--


http://git-wip-us.apache.org/repos/asf/hive/blob/2ccd0616/ql/src/java/org/apache/hadoop/hive/ql/parse/DDLSemanticAnalyzer.java
--
diff --git 
a/ql/src/java/org/apache/hadoop/hive/ql/parse/DDLSemanticAnalyzer.java 
b/ql/src/java/org/apache/hadoop/hive/ql/parse/DDLSemanticAnalyzer.java
index 21625bc..9f8c756 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/parse/DDLSemanticAnalyzer.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/parse/DDLSemanticAnalyzer.java
@@ -23,6 +23,7 @@ import org.antlr.runtime.tree.CommonTree;
 import org.antlr.runtime.tree.Tree;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.apache.hadoop.fs.FileSystem;
 import org.apache.hadoop.fs.Path;
 import org.apache.hadoop.hive.common.JavaUtils;
 import org.apache.hadoop.hive.conf.HiveConf;
@@ -137,6 +138,7 @@ import org.apache.hadoop.mapred.InputFormat;
 import org.apache.hadoop.mapred.TextInputFormat;
 import org.apache.hadoop.util.StringUtils;
 
+import java.io.FileNotFoundException;
 import java.io.Serializable;
 import java.lang.reflect.Constructor;
 import java.lang.reflect.InvocationTargetException;
@@ -1464,6 +1466,15 @@ public class DDLSemanticAnalyzer extends 
BaseSemanticAnalyzer {
   HashMapString, String partSpec) throws SemanticException {
 
 String newLocation = unescapeSQLString(ast.getChild(0).getText());
+try {
+  // To make sure host/port pair is valid, the status of the location
+  // does not matter
+  FileSystem.get(new URI(newLocation), conf).getFileStatus(new 
Path(newLocation));
+} catch (FileNotFoundException e) {
+  // Only check host/port pair is valid, wheter the file exist or not does 
not matter
+} catch (Exception e) {
+  throw new SemanticException(Cannot connect to namenode, please check if 
host/port pair for  + newLocation +  is valid, e);
+}
 addLocationToOutputs(newLocation);
 AlterTableDesc alterTblDesc = new AlterTableDesc(tableName, newLocation, 
partSpec);
 

http://git-wip-us.apache.org/repos/asf/hive/blob/2ccd0616/ql/src/test/queries/clientnegative/alter_table_wrong_location.q
--
diff --git a/ql/src/test/queries/clientnegative/alter_table_wrong_location.q 
b/ql/src/test/queries/clientnegative/alter_table_wrong_location.q
new file mode 100644
index 000..3721867
--- /dev/null
+++ b/ql/src/test/queries/clientnegative/alter_table_wrong_location.q
@@ -0,0 +1,4 @@
+create table testwrongloc(id int);
+
+-- Assume port 12345 is not open
+alter table testwrongloc set location 
hdfs://localhost:12345/tmp/testwrongloc;

http://git-wip-us.apache.org/repos/asf/hive/blob/2ccd0616/ql/src/test/results/clientnegative/alter_table_wrong_location.q.out
--
diff --git 
a/ql/src/test/results/clientnegative/alter_table_wrong_location.q.out 
b/ql/src/test/results/clientnegative/alter_table_wrong_location.q.out
new file mode 100644
index 000..d788d55
--- /dev/null
+++ b/ql/src/test/results/clientnegative/alter_table_wrong_location.q.out
@@ -0,0 +1,9 @@
+PREHOOK: query: create table testwrongloc(id int)
+PREHOOK: type: CREATETABLE
+PREHOOK: Output: database:default
+PREHOOK: Output: default@testwrongloc
+POSTHOOK: query: create table testwrongloc(id int)
+POSTHOOK: type: CREATETABLE
+POSTHOOK: Output: database:default
+POSTHOOK: Output: default@testwrongloc
+ A masked pattern was here