/** * Handle sql exception * * @param sqlex SQLException * @throws LensException */ private LensException handleJDBCSQLException(SQLException sqlex) throws LensException { String cause = LensUtil.getCauseMessage(sqlex); if (getSqlSynataxExceptions(sqlex).contains("SyntaxError")) { throw new LensException(LensDriverErrorCode.SEMANTIC_ERROR.getLensErrorInfo(), sqlex, cause); } throw new LensException(LensDriverErrorCode.DRIVER_ERROR.getLensErrorInfo(), sqlex, cause); }
/** * Handle sql exception * * @param sqlex SQLException * @throws LensException */ private LensException handleJDBCSQLException(SQLException sqlex) throws LensException { String cause = LensUtil.getCauseMessage(sqlex); if (getSqlSynataxExceptions(sqlex).contains("SyntaxError")) { throw new LensException(LensDriverErrorCode.SEMANTIC_ERROR.getLensErrorInfo(), sqlex, cause); } throw new LensException(LensDriverErrorCode.DRIVER_ERROR.getLensErrorInfo(), sqlex, cause); }
private LensException handleHiveSQLException(HiveSQLException ex) throws LensException { if (ex.getMessage().contains("SemanticException")) { throw new LensException(SEMANTIC_ERROR.getLensErrorInfo(), ex, ex.getMessage()); } throw new LensException(DRIVER_ERROR.getLensErrorInfo(), ex, ex.getMessage()); }
private LensException handleHiveSQLException(HiveSQLException ex) throws LensException { if (ex.getMessage().contains("SemanticException")) { throw new LensException(SEMANTIC_ERROR.getLensErrorInfo(), ex, ex.getMessage()); } throw new LensException(DRIVER_ERROR.getLensErrorInfo(), ex, ex.getMessage()); }
/** * Test semantic error for hive query on non-existent table. * * @throws IOException Signals that an I/O exception has occurred. * @throws InterruptedException the interrupted exception */ @Test(dataProvider = "mediaTypeData") public void testHiveSemanticFailure(MediaType mt) throws InterruptedException, IOException { final WebTarget target = target().path("queryapi/queries"); final FormDataMultiPart mp = new FormDataMultiPart(); mp.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("sessionid").build(), lensSessionId, mt)); mp.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("query").build(), " select ID from NOT_EXISTS")); mp.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("operation").build(), "execute")); mp.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("conf").fileName("conf").build(), new LensConf(), mt)); Response response = target.request(mt).post(Entity.entity(mp, MediaType .MULTIPART_FORM_DATA_TYPE)); LensAPIResult result = response.readEntity(LensAPIResult.class); List<LensErrorTO> childErrors = result.getLensErrorTO().getChildErrors(); boolean hiveSemanticErrorExists = false; for (LensErrorTO error : childErrors) { if (error.getCode() == LensDriverErrorCode.SEMANTIC_ERROR.getLensErrorInfo().getErrorCode()) { hiveSemanticErrorExists = true; break; } } assertTrue(hiveSemanticErrorExists); }