static public Pair<String, String> getDBTableNames(String location) throws IOException { // the location string will be of the form: // <database name>.<table name> - parse it and // communicate the information to HCatInputFormat try { return HCatUtil.getDbAndTableName(location); } catch (IOException e) { String locationErrMsg = "The input location in load statement " + "should be of the form " + "<databasename>.<table name> or <table name>. Got " + location; throw new PigException(locationErrMsg, PIG_EXCEPTION_CODE); } }
exceptionMessage); object = PigContext.instantiateFuncFromSpec(funcSpec); ((PigException) object).setErrorCode(errCode); ((PigException) object).setErrorSource(PigException .determineErrorSource(errCode)); } else { // else for if(errMessageMatcher.find()) exceptionMessage); object = PigContext.instantiateFuncFromSpec(funcSpec); ((PigException) object).setErrorCode(2997);// generic .setErrorSource(PigException.BUG);
if (e instanceof PigException) { PigException pe = (PigException)e; rc = (pe.retriable()) ? ReturnCode.RETRIABLE_EXCEPTION : ReturnCode.PIG_EXCEPTION; PigStatsUtil.setErrorMessage(pe.getMessage()); PigStatsUtil.setErrorCode(pe.getErrorCode()); } else { rc = ReturnCode.IO_EXCEPTION;
message = "ERROR " + pigException.getErrorCode() + ": " + pigException.getMessage(); } else { if((t instanceof ParseException
public static PigException getPigException(Throwable top) { Throwable current = top; Throwable pigException = top; if (current instanceof PigException && (((PigException)current).getErrorCode() != 0) && ((PigException) current).getMarkedAsShowToUser()) { return (PigException) current; } while (current != null && current.getCause() != null){ current = current.getCause(); if((current instanceof PigException) && (((PigException)current).getErrorCode() != 0)) { pigException = current; if (((PigException)pigException).getMarkedAsShowToUser()) { break; } } } return (pigException instanceof PigException? (PigException)pigException : null); }
/** * Returns a short description of this throwable. * The result is the concatenation of: * <ul> * <li> the {@linkplain Class#getName() name} of the class of this object * <li> ": " (a colon and a space) * <li> "ERROR " (the string ERROR followed by a a space) * <li> the result of invoking this object's {@link #getErrorCode} method * <li> ": " (a colon and a space) * <li> the result of invoking {@link Throwable#getLocalizedMessage() getLocalizedMessage} * method * </ul> * If <tt>getLocalizedMessage</tt> returns <tt>null</tt>, then just * the class name is returned. * * @return a string representation of this throwable. */ @Override public String toString() { String s = getClass().getName(); String message = getLocalizedMessage(); return (message != null) ? (s + ": " + "ERROR " + getErrorCode() + ": " + message) : s; } }
/** * Parse the accumulated pig statements and generate an overall plan. */ private void parseQuery() throws FrontendException { UDFContext.getUDFContext().reset(); UDFContext.getUDFContext().setClientSystemProps(pigContext.getProperties()); String query = buildQuery(); if( query.isEmpty() ) { lp = new LogicalPlan(); return; } try { QueryParserDriver parserDriver = new QueryParserDriver( pigContext, scope, fileNameMap ); lp = parserDriver.parse( query ); operators = parserDriver.getOperators(); lastRel = parserDriver.getLastRel(); } catch(Exception ex) { scriptCache.remove( scriptCache.size() -1 ); // remove the bad script from the cache. PigException pe = LogUtils.getPigException(ex); int errCode = 1000; String msg = "Error during parsing. " + (pe == null ? ex.getMessage() : pe.getMessage()); log.error("exception during parsing: " + msg, ex); if (null == pe) { throw new FrontendException (msg, errCode, PigException.INPUT , ex); } else { throw new FrontendException (msg, errCode, PigException.INPUT , ex, pe.getSourceLocation() ); } } }
@Private public void setBackendException(String jobId, Exception e) { if (e instanceof PigException) { LOG.error("ERROR " + ((PigException)e).getErrorCode() + ": " + e.getLocalizedMessage()); } else if (e != null) { LOG.error("ERROR: " + e.getLocalizedMessage()); } if (jobId == null || e == null) { LOG.debug("unable to set backend exception"); return; } Iterator<JobStats> iter = jobPlan.iterator(); while (iter.hasNext()) { JobStats js = iter.next(); if (jobId.equals(js.getJobId())) { js.setBackendException(e); break; } } }
int udfErrorCode = ((PigException)ioe).getErrorCode(); if(udfErrorCode != 0) { errCode = udfErrorCode; msg = ((PigException)ioe).getMessage(); } else { msg += " [" + ((PigException)ioe).getMessage() + " ]";
} catch (Exception ioe) { if(ioe instanceof PigException){ errCode = ((PigException)ioe).getErrorCode();
throw new PigException("HCatalog column type '" + type.toString() + "' is not supported in Pig as a column type", PIG_EXCEPTION_CODE);
public Table getTable(String location, String hcatServerUri, String hcatServerPrincipal, Job job) throws IOException { Pair<String, String> loc_server = new Pair<String, String>(location, hcatServerUri); Table hcatTable = hcatTableCache.get(loc_server); if (hcatTable != null) { return hcatTable; } Pair<String, String> dbTablePair = PigHCatUtil.getDBTableNames(location); String dbName = dbTablePair.first; String tableName = dbTablePair.second; Table table = null; IMetaStoreClient client = null; try { client = getHiveMetaClient(hcatServerUri, hcatServerPrincipal, PigHCatUtil.class, job); table = HCatUtil.getTable(client, dbName, tableName); } catch (NoSuchObjectException nsoe) { throw new PigException("Table not found : " + nsoe.getMessage(), PIG_EXCEPTION_CODE); // prettier error messages to frontend } catch (Exception e) { throw new IOException(e); } finally { HCatUtil.closeHiveClientQuietly(client); } hcatTableCache.put(loc_server, table); return table; }
throw new PigException(he.getMessage(), PigHCatUtil.PIG_EXCEPTION_CODE, he);
@Override public ResourceSchema getSchema(String location, Job job) throws IOException { HCatContext.INSTANCE.setConf(job.getConfiguration()).getConf().get() .setBoolean(HCatConstants.HCAT_DATA_TINY_SMALL_INT_PROMOTION, true); Table table = phutil.getTable(location, hcatServerUri != null ? hcatServerUri : PigHCatUtil.getHCatServerUri(job), PigHCatUtil.getHCatServerPrincipal(job), // Pass job to initialize metastore conf overrides for embedded metastore case // (hive.metastore.uris = ""). job); HCatSchema hcatTableSchema = HCatUtil.getTableSchemaWithPtnCols(table); try { PigHCatUtil.validateHCatTableSchemaFollowsPigRules(hcatTableSchema); } catch (IOException e) { throw new PigException( "Table schema incompatible for reading through HCatLoader :" + e.getMessage() + ";[Table schema was " + hcatTableSchema.toString() + "]" , PigHCatUtil.PIG_EXCEPTION_CODE, e); } storeInUDFContext(signature, HCatConstants.HCAT_TABLE_SCHEMA, hcatTableSchema); outputSchema = hcatTableSchema; return PigHCatUtil.getResourceSchema(hcatTableSchema); }
private static void validateHcatFieldFollowsPigRules(HCatFieldSchema hcatField) throws PigException { try { Type hType = hcatField.getType(); switch (hType) { case BOOLEAN: if (!pigHasBooleanSupport) { throw new PigException("Incompatible type found in HCat table schema: " + hcatField, PigHCatUtil.PIG_EXCEPTION_CODE); } break; case ARRAY: validateHCatSchemaFollowsPigRules(hcatField.getArrayElementSchema()); break; case STRUCT: validateHCatSchemaFollowsPigRules(hcatField.getStructSubSchema()); break; case MAP: // key is only string if (hcatField.getMapKeyType() != Type.STRING) { LOG.info("Converting non-String key of map " + hcatField.getName() + " from " + hcatField.getMapKeyType() + " to String."); } validateHCatSchemaFollowsPigRules(hcatField.getMapValueSchema()); break; } } catch (HCatException e) { throw new PigException("Incompatible type found in hcat table schema: " + hcatField, PigHCatUtil.PIG_EXCEPTION_CODE, e); } }
private void printUsage(final String location) throws PigException { String locationErrMsg = String.format("The input location in load statement should be of the form " + "%s<table name> or %s<query>. Got [%s] ",PHOENIX_TABLE_NAME_SCHEME,PHOENIX_QUERY_SCHEME,location); LOG.error(locationErrMsg); throw new PigException(locationErrMsg); }
final String errorMsg = String.format(" Error transforming PhoenixRecord to Tuple [%s] ", ex.getMessage()); LOG.error(errorMsg); throw new PigException(errorMsg);
private void printUsage(final String location) throws PigException { String locationErrMsg = String.format("The input location in load statement should be of the form " + "%s<table name> or %s<query>. Got [%s] ",PHOENIX_TABLE_NAME_SCHEME,PHOENIX_QUERY_SCHEME,location); LOG.error(locationErrMsg); throw new PigException(locationErrMsg); }
static public Pair<String, String> getDBTableNames(String location) throws IOException { // the location string will be of the form: // <database name>.<table name> - parse it and // communicate the information to HCatInputFormat try { return HCatUtil.getDbAndTableName(location); } catch (IOException e) { String locationErrMsg = "The input location in load statement " + "should be of the form " + "<databasename>.<table name> or <table name>. Got " + location; throw new PigException(locationErrMsg, PIG_EXCEPTION_CODE); } }
public void run(String script) throws PigException { try { pigServer.registerQuery(script); } catch (IOException e) { throw new PigException(e); } } }