/** * This is the recommended constructor to use since it helps use * canonical messages throughout and propagate remote errors. * * @param errorMsg Canonical error message * @param msgArgs message arguments if message is parametrized; must be {@code null} is message takes no arguments */ public DataConstraintViolationError(Throwable cause, ErrorMsg errorMsg, String... msgArgs) { super(errorMsg.format(msgArgs), cause); canonicalErrorMsg = errorMsg; }
/** * This is the recommended constructor to use since it helps use * canonical messages throughout and propagate remote errors. * * @param errorMsg Canonical error message * @param msgArgs message arguments if message is parametrized; must be {@code null} is message takes no arguments */ public HiveException(Throwable cause, String remErrMsg, ErrorMsg errorMsg, String... msgArgs) { super(errorMsg.format(msgArgs), cause); canonicalErrorMsg = errorMsg; remoteErrorMsg = remErrMsg; }
/** * This is the recommended constructor to use since it helps use * canonical messages throughout. * @param errorMsg Canonical error message * @param msgArgs message arguments if message is parametrized; must be {@code null} is message takes no arguments */ public HiveException(Throwable cause, ErrorMsg errorMsg, String... msgArgs) { super(errorMsg.format(msgArgs), cause); canonicalErrorMsg = errorMsg; } public HiveException(Throwable cause, ErrorMsg errorMsg) {
public String getErrorCodedMsg(String... reasons) { return "[Error " + errorCode + "]: " + format(reasons); }
public String getErrorCodedMsg(String... reasons) { return "[Error " + errorCode + "]: " + format(reasons); }
public static boolean replCkptStatus(String dbName, Map<String, String> props, String dumpRoot) throws InvalidOperationException { // If ckpt property not set or empty means, bootstrap is not run on this object. if ((props != null) && props.containsKey(REPL_CHECKPOINT_KEY) && !props.get(REPL_CHECKPOINT_KEY).isEmpty()) { if (props.get(REPL_CHECKPOINT_KEY).equals(dumpRoot)) { return true; } throw new InvalidOperationException(ErrorMsg.REPL_BOOTSTRAP_LOAD_PATH_NOT_VALID.format(dumpRoot, props.get(REPL_CHECKPOINT_KEY))); } return false; }
public CommandProcessorResponse(int responseCode, ErrorMsg canonicalErrMsg, Throwable t, String ... msgArgs) { this(responseCode, canonicalErrMsg.format(msgArgs), canonicalErrMsg.getSQLState(), null, t, canonicalErrMsg.getErrorCode(), null); }
/** * Now generate the predicate for Where clause. */ private String getPredicate() { //normilize table name for mapping List<String> targetCols = table2column.get(targetTableNameInSourceQuery.toLowerCase()); if (targetCols == null) { /*e.g. ON source.t=1 * this is not strictly speaking invalid but it does ensure that all columns from target * table are all NULL for every row. This would make any WHEN MATCHED clause invalid since * we don't have a ROW__ID. The WHEN NOT MATCHED could be meaningful but it's just data from * source satisfying source.t=1... not worth the effort to support this*/ throw new IllegalArgumentException(ErrorMsg.INVALID_TABLE_IN_ON_CLAUSE_OF_MERGE .format(targetTableNameInSourceQuery, onClauseAsString)); } StringBuilder sb = new StringBuilder(); for (String col : targetCols) { if (sb.length() > 0) { sb.append(" AND "); } //but preserve table name in SQL sb.append(HiveUtils.unparseIdentifier(targetTableNameInSourceQuery, conf)) .append(".") .append(HiveUtils.unparseIdentifier(col, conf)) .append(" IS NULL"); } return sb.toString(); } }
/** * @param conf * @return path to destination directory on hdfs * @throws LoginException if we are unable to figure user information * @throws IOException when any dfs operation fails. */ @SuppressWarnings("deprecation") public Path getDefaultDestDir(Configuration conf) throws LoginException, IOException { UserGroupInformation ugi = Utils.getUGI(); String userName = ugi.getShortUserName(); String userPathStr = HiveConf.getVar(conf, HiveConf.ConfVars.HIVE_USER_INSTALL_DIR); Path userPath = new Path(userPathStr); FileSystem fs = userPath.getFileSystem(conf); String jarPathStr = userPathStr + "/" + userName; String hdfsDirPathStr = jarPathStr; Path hdfsDirPath = new Path(hdfsDirPathStr); try { FileStatus fstatus = fs.getFileStatus(hdfsDirPath); if (!fstatus.isDir()) { throw new IOException(ErrorMsg.INVALID_DIR.format(hdfsDirPath.toString())); } } catch (FileNotFoundException e) { // directory does not exist, create it fs.mkdirs(hdfsDirPath); } Path retPath = new Path(hdfsDirPath.toString() + "/.hiveJars"); fs.mkdirs(retPath); return retPath; }
/** * Now generate the predicate for Where clause */ private String getPredicate() { //normilize table name for mapping List<String> targetCols = table2column.get(targetTableNameInSourceQuery.toLowerCase()); if(targetCols == null) { /*e.g. ON source.t=1 * this is not strictly speaking invlaid but it does ensure that all columns from target * table are all NULL for every row. This would make any WHEN MATCHED clause invalid since * we don't have a ROW__ID. The WHEN NOT MATCHED could be meaningful but it's just data from * source satisfying source.t=1... not worth the effort to support this*/ throw new IllegalArgumentException(ErrorMsg.INVALID_TABLE_IN_ON_CLAUSE_OF_MERGE .format(targetTableNameInSourceQuery, onClauseAsString)); } StringBuilder sb = new StringBuilder(); for(String col : targetCols) { if(sb.length() > 0) { sb.append(" AND "); } //but preserve table name in SQL sb.append(HiveUtils.unparseIdentifier(targetTableNameInSourceQuery, conf)).append(".").append(HiveUtils.unparseIdentifier(col, conf)).append(" IS NULL"); } return sb.toString(); } }
public CommandProcessorResponse(int responseCode, ErrorMsg canonicalErrMsg, Throwable t, String ... msgArgs) { this(responseCode, canonicalErrMsg.format(msgArgs), canonicalErrMsg.getSQLState(), null, t, canonicalErrMsg.getErrorCode(), null); }
/** * @param conf * @return path to destination directory on hdfs * @throws LoginException if we are unable to figure user information * @throws IOException when any dfs operation fails. */ @SuppressWarnings("deprecation") public Path getDefaultDestDir(Configuration conf) throws LoginException, IOException { UserGroupInformation ugi = Utils.getUGI(); String userName = ugi.getShortUserName(); String userPathStr = HiveConf.getVar(conf, HiveConf.ConfVars.HIVE_USER_INSTALL_DIR); Path userPath = new Path(userPathStr); FileSystem fs = userPath.getFileSystem(conf); String jarPathStr = userPathStr + "/" + userName; String hdfsDirPathStr = jarPathStr; Path hdfsDirPath = new Path(hdfsDirPathStr); try { FileStatus fstatus = fs.getFileStatus(hdfsDirPath); if (!fstatus.isDir()) { throw new IOException(ErrorMsg.INVALID_DIR.format(hdfsDirPath.toString())); } } catch (FileNotFoundException e) { // directory does not exist, create it fs.mkdirs(hdfsDirPath); } Path retPath = new Path(hdfsDirPath.toString() + "/.hiveJars"); fs.mkdirs(retPath); return retPath; }
/** * If the message is parametrized, this will fill the parameters with supplied * {@code reasons}, otherwise {@code reasons} are appended at the end of the * message. */ public String format(String... reasons) { /* Not all messages are parametrized even those that should have been, e.g {@link #INVALID_TABLE}. INVALID_TABLE is usually used with {@link #getMsg(String)}. This method can also be used with INVALID_TABLE and the like and will match getMsg(String) behavior. Another example: {@link #INVALID_PARTITION}. Ideally you want the message to have 2 parameters one for partition name one for table name. Since this is already defined w/o any parameters, one can still call {@code INVALID_PARTITION.format("<partName> <table Name>"}. This way the message text will be slightly different but at least the errorCode will match. Note this, should not be abused by adding anything other than what should have been parameter names to keep msg text standardized. */ if(reasons == null || reasons.length == 0) { return getMsg(); } if(format != null) { return format.format(reasons); } if(reasons.length > 1) { StringBuilder sb = new StringBuilder(); for(String re : reasons) { if(re != null) { if(sb.length() > 0) { sb.append(" "); } sb.append(re);
static List<Path> getDataPathList(Path fromPath, ReplicationSpec replicationSpec, HiveConf conf) throws IOException { if (replicationSpec.isTransactionalTableDump()) { try { conf.set(ValidTxnList.VALID_TXNS_KEY, replicationSpec.getValidTxnList()); return AcidUtils.getValidDataPaths(fromPath, conf, replicationSpec.getValidWriteIdList()); } catch (FileNotFoundException e) { throw new IOException(ErrorMsg.FILE_NOT_FOUND.format(e.getMessage()), e); } } else { return Collections.singletonList(fromPath); } } }
/** * If the message is parametrized, this will fill the parameters with supplied * {@code reasons}, otherwise {@code reasons} are appended at the end of the * message. */ public String format(String... reasons) { /* Not all messages are parametrized even those that should have been, e.g {@link #INVALID_TABLE}. INVALID_TABLE is usually used with {@link #getMsg(String)}. This method can also be used with INVALID_TABLE and the like and will match getMsg(String) behavior. Another example: {@link #INVALID_PARTITION}. Ideally you want the message to have 2 parameters one for partition name one for table name. Since this is already defined w/o any parameters, one can still call {@code INVALID_PARTITION.format("<partName> <table Name>"}. This way the message text will be slightly different but at least the errorCode will match. Note this, should not be abused by adding anything other than what should have been parameter names to keep msg text standardized. */ if(reasons == null || reasons.length == 0) { return getMsg(); } if(format != null) { return format.format(reasons); } if(reasons.length > 1) { StringBuilder sb = new StringBuilder(); for(String re : reasons) { if(re != null) { if(sb.length() > 0) { sb.append(" "); } sb.append(re);
if (e instanceof FileNotFoundException) { logger.error("exporting data files in dir : " + dataPathList + " to " + exportRootDataDir + " failed"); throw new FileNotFoundException(FILE_NOT_FOUND.format(e.getMessage()));
private String singleTable(String json, String table) throws IOException { Map obj = JsonBuilder.jsonToMap(json); if (JsonBuilder.isError(obj)) return json; List tables = (List) obj.get("tables"); if (TempletonUtils.isset(tables)) return JsonBuilder.mapToJson(tables.get(0)); else { return JsonBuilder .createError(ErrorMsg.INVALID_TABLE.format(table), ErrorMsg.INVALID_TABLE.getErrorCode()). buildJson(); } }
private void testReverseMatch(ErrorMsg errorMsg, String... args) { String parametrizedMsg = errorMsg.format(args); ErrorMsg canonicalMsg = ErrorMsg.getErrorMsg(parametrizedMsg); Assert.assertEquals("Didn't find expected msg", errorMsg.getErrorCode(), canonicalMsg.getErrorCode()); } }
mapJoinOp.getConf().getConds()) < 0) { throw new SemanticException( ErrorMsg.INVALID_BIGTABLE_MAPJOIN.format(mapJoinOp.getConf().getBigTableAlias()));
mapJoinOp.getConf().getConds()) < 0) { throw new SemanticException( ErrorMsg.INVALID_BIGTABLE_MAPJOIN.format(mapJoinOp.getConf().getBigTableAlias()));