Index: ql/src/java/org/apache/hadoop/hive/ql/processors/AddResourceProcessor.java =================================================================== --- ql/src/java/org/apache/hadoop/hive/ql/processors/AddResourceProcessor.java (revision 1077888) +++ ql/src/java/org/apache/hadoop/hive/ql/processors/AddResourceProcessor.java (working copy) @@ -51,7 +51,11 @@ return new CommandProcessorResponse(1); } for (int i = 1; i < tokens.length; i++) { - ss.add_resource(t, tokens[i]); + String resourceFile = ss.add_resource(t, tokens[i]); + if(resourceFile == null){ + String errMsg = tokens[i]+" does not exist."; + return new CommandProcessorResponse(1,errMsg,null); + } } return new CommandProcessorResponse(0); } Index: ql/src/java/org/apache/hadoop/hive/ql/session/SessionState.java =================================================================== --- ql/src/java/org/apache/hadoop/hive/ql/session/SessionState.java (revision 1077888) +++ ql/src/java/org/apache/hadoop/hive/ql/session/SessionState.java (working copy) @@ -512,9 +512,9 @@ private final HashMap> resource_map = new HashMap>(); - public void add_resource(ResourceType t, String value) { + public String add_resource(ResourceType t, String value) { // By default don't convert to unix - add_resource(t, value, false); + return add_resource(t, value, false); } public String add_resource(ResourceType t, String value, boolean convertToUnix) { Index: service/src/test/org/apache/hadoop/hive/service/TestHiveServer.java =================================================================== --- service/src/test/org/apache/hadoop/hive/service/TestHiveServer.java (revision 1077888) +++ service/src/test/org/apache/hadoop/hive/service/TestHiveServer.java (working copy) @@ -50,12 +50,14 @@ private final HiveConf conf; private boolean standAloneServer = false; private TTransport transport; + private final String invalidPath; public TestHiveServer(String name) { super(name); conf = new HiveConf(TestHiveServer.class); String dataFileDir = conf.get("test.data.files").replace('\\', '/') .replace("c:", ""); + invalidPath = dataFileDir+"/invalidpath/"; dataFilePath = new Path(dataFileDir, "kv1.txt"); // See data/conf/hive-site.xml String paramStr = System.getProperty("test.service.standalone.server"); @@ -347,4 +349,40 @@ o = ds.deserialize(new BytesWritable(row.getBytes())); } + public void testAddJarShouldFailIfJarNotExist() throws Exception { + boolean queryExecutionFailed = false; + try { + client.execute("add jar " + invalidPath + "sample.jar"); + } catch (Exception e) { + queryExecutionFailed = true; + } + if (!queryExecutionFailed) { + fail("It should throw exception since jar does not exist"); + } + } + + public void testAddFileShouldFailIfFileNotExist() throws Exception { + boolean queryExecutionFailed = false; + try { + client.execute("add file " + invalidPath + "sample.txt"); + } catch (Exception e) { + queryExecutionFailed = true; + } + if (!queryExecutionFailed) { + fail("It should throw exception since file does not exist"); + } + } + + public void testAddArchiveShouldFailIfFileNotExist() throws Exception { + boolean queryExecutionFailed = false; + try { + client.execute("add archive " + invalidPath + "sample.zip"); + } catch (Exception e) { + queryExecutionFailed = true; + } + if (!queryExecutionFailed) { + fail("It should trow exception since archive does not exist"); + } + } + }