Index: ql/src/java/org/apache/hadoop/hive/ql/processors/AddResourceProcessor.java =================================================================== --- ql/src/java/org/apache/hadoop/hive/ql/processors/AddResourceProcessor.java (revision 1074048) +++ ql/src/java/org/apache/hadoop/hive/ql/processors/AddResourceProcessor.java (working copy) @@ -51,7 +51,10 @@ 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){ + throw new RuntimeException(tokens[i]+" does not exist."); + } } 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 1074048) +++ ql/src/java/org/apache/hadoop/hive/ql/session/SessionState.java (working copy) @@ -96,13 +96,13 @@ * type of the command. */ private HiveOperation commandType; - + private HiveAuthorizationProvider authorizer; - + private HiveAuthenticationProvider authenticator; - + private CreateTableAutomaticGrant createTableGrants; - + /** * Lineage state. */ @@ -182,7 +182,7 @@ /** * start a new session and set it to current session. - * @throws HiveException + * @throws HiveException */ public static SessionState start(HiveConf conf) throws HiveException { SessionState ss = new SessionState(conf); @@ -200,7 +200,7 @@ * set current session to existing session object if a thread is running * multiple sessions - it must call this method with the new session object * when switching from one session to another. - * @throws HiveException + * @throws HiveException */ public static SessionState start(SessionState startSs) { @@ -214,7 +214,7 @@ if (startSs.hiveHist == null) { startSs.hiveHist = new HiveHistory(startSs); } - + try { startSs.authenticator = HiveUtils.getAuthenticator(startSs .getConf()); @@ -225,7 +225,7 @@ } catch (HiveException e) { throw new RuntimeException(e); } - + return startSs; } @@ -490,9 +490,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) { @@ -604,7 +604,7 @@ } return commandType.getOperationName(); } - + public HiveOperation getHiveOperation() { return commandType; } @@ -612,7 +612,7 @@ public void setCommandType(HiveOperation commandType) { this.commandType = commandType; } - + public HiveAuthorizationProvider getAuthorizer() { return authorizer; } @@ -628,7 +628,7 @@ public void setAuthenticator(HiveAuthenticationProvider authenticator) { this.authenticator = authenticator; } - + public CreateTableAutomaticGrant getCreateTableGrants() { return createTableGrants; } Index: service/src/test/org/apache/hadoop/hive/service/TestHiveServer.java =================================================================== --- service/src/test/org/apache/hadoop/hive/service/TestHiveServer.java (revision 1074048) +++ 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"); @@ -332,4 +334,41 @@ 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"); + } + } }