@Override public String toString() { return getMessage(); }
private static void assertTypeInCategory(Type type, Category category, String fieldName) throws HCatException { Category typeCategory = Category.fromType(type); if (typeCategory != category) { throw new HCatException("Type category mismatch. Expected " + category + " but type " + type + " in category " + typeCategory + " (field " + fieldName + ")"); } }
/** * Instantiates a new hcat exception. * @param errorType the error type * @param extraMessage extra messages to add to the message string * @param cause the cause */ public HCatException(ErrorType errorType, String extraMessage, Throwable cause) { super(buildErrorMessage( errorType, extraMessage, cause), cause); this.errorType = errorType; }
assertEquals(ErrorType.ERROR_SCHEMA_COLUMN_MISMATCH, ((HCatException) exc).getErrorType());
assertTrue(exc != null); assertTrue(exc instanceof HCatException); assertTrue("Got exception of type [" + ((HCatException) exc).getErrorType().toString() + "] Expected ERROR_PUBLISHING_PARTITION or ERROR_MOVE_FAILED " + "or ERROR_DUPLICATE_PARTITION", (ErrorType.ERROR_PUBLISHING_PARTITION == ((HCatException) exc).getErrorType()) || (ErrorType.ERROR_MOVE_FAILED == ((HCatException) exc).getErrorType()) || (ErrorType.ERROR_DUPLICATE_PARTITION == ((HCatException) exc).getErrorType()) );
private static void assertTypeNotInCategory(Type type, Category category) throws HCatException { Category typeCategory = Category.fromType(type); if (typeCategory == category) { throw new HCatException("Type category mismatch. Expected type " + type + " not in category " + category + " but was so."); } }
/** Constructs HCatSchema from pigSchema. Passed tableSchema is the existing * schema of the table in metastore. */ protected HCatSchema convertPigSchemaToHCatSchema(Schema pigSchema, HCatSchema tableSchema) throws FrontendException { if(LOG.isDebugEnabled()) { LOG.debug("convertPigSchemaToHCatSchema(pigSchema,tblSchema)=(" + pigSchema + "," + tableSchema + ")"); } List<HCatFieldSchema> fieldSchemas = new ArrayList<HCatFieldSchema>(pigSchema.size()); for (FieldSchema fSchema : pigSchema.getFields()) { try { HCatFieldSchema hcatFieldSchema = getColFromSchema(fSchema.alias, tableSchema); //if writing to a partitioned table, then pigSchema will have more columns than tableSchema //partition columns are not part of tableSchema... e.g. TestHCatStorer#testPartColsInData() // HCatUtil.assertNotNull(hcatFieldSchema, "Nothing matching '" + fSchema.alias + "' found " + // "in target table schema", LOG); fieldSchemas.add(getHCatFSFromPigFS(fSchema, hcatFieldSchema, pigSchema, tableSchema)); } catch (HCatException he) { throw new FrontendException(he.getMessage(), PigHCatUtil.PIG_EXCEPTION_CODE, he); } } HCatSchema s = new HCatSchema(fieldSchemas); LOG.debug("convertPigSchemaToHCatSchema(computed)=(" + s + ")"); return s; }
/** * Instantiates a new hcat exception. * @param errorType the error type * @param extraMessage extra messages to add to the message string * @param cause the cause */ public HCatException(ErrorType errorType, String extraMessage, Throwable cause) { super(buildErrorMessage( errorType, extraMessage, cause), cause); this.errorType = errorType; }
assertEquals(ErrorType.ERROR_SCHEMA_TYPE_MISMATCH, ((HCatException) exc).getErrorType());
/** * Setter for the "root" location of the HCatPartitionSpec. * @param location The new "root" location of the HCatPartitionSpec. * @throws HCatException On failure to set a new location. */ public void setRootLocation(String location) throws HCatException { try { partitionSpecProxy.setRootLocation(location); } catch (MetaException metaException) { throw new HCatException("Unable to set root-path!", metaException); } }
throw new PigException(he.getMessage(), PigHCatUtil.PIG_EXCEPTION_CODE, he); doSchemaValidations(pigSchema, hcatTblSchema); } catch (HCatException he) { throw new FrontendException(he.getMessage(), PigHCatUtil.PIG_EXCEPTION_CODE, he);
/** * Instantiates a new hcat exception. * @param errorType the error type * @param extraMessage extra messages to add to the message string * @param cause the cause */ public HCatException(ErrorType errorType, String extraMessage, Throwable cause) { super(buildErrorMessage( errorType, extraMessage, cause), cause); this.errorType = errorType; }
exc = e; assertTrue(exc instanceof HCatException); assertEquals(ErrorType.ERROR_NON_EMPTY_TABLE, ((HCatException) exc).getErrorType()); assertTrue(exc != null); assertTrue(exc instanceof HCatException); assertEquals(ErrorType.ERROR_INVALID_PARTITION_VALUES, ((HCatException) exc).getErrorType());
@Override void initialize(Configuration conf) throws HCatException { this.config = conf; try { hiveConfig = HCatUtil.getHiveConf(config); hmsClient = HCatUtil.getHiveMetastoreClient(hiveConfig); } catch (MetaException exp) { throw new HCatException("MetaException while creating HMS client", exp); } catch (IOException exp) { throw new HCatException("IOException while creating HMS client", exp); } }
public void testRemoveAddField() throws HCatException { List<HCatFieldSchema> fieldSchemaList = new ArrayList<HCatFieldSchema>(); fieldSchemaList.add(new HCatFieldSchema("memberID", HCatFieldSchema.Type.INT, "as a number")); HCatFieldSchema locationField = new HCatFieldSchema("location", HCatFieldSchema.Type.STRING, "there's Waldo"); fieldSchemaList.add(locationField); HCatSchema schema = new HCatSchema(fieldSchemaList); schema.remove(locationField); Integer position = schema.getPosition(locationField.getName()); assertTrue("position is not null after remove" , position == null); try { schema.append(locationField); } catch (HCatException ex) { assertFalse(ex.getMessage(), true); } }
/** * Instantiates a new hcat exception. * @param errorType the error type * @param extraMessage extra messages to add to the message string * @param cause the cause */ public HCatException(ErrorType errorType, String extraMessage, Throwable cause) { super(buildErrorMessage( errorType, extraMessage, cause), cause); this.errorType = errorType; }
exc = e; assertTrue(exc instanceof HCatException); assertTrue(ErrorType.ERROR_DUPLICATE_PARTITION.equals(((HCatException) exc).getErrorType())); assertNotNull(exc); assertTrue(exc instanceof HCatException); assertEquals(ErrorType.ERROR_MISSING_PARTITION_KEY, ((HCatException) exc).getErrorType()); assertEquals(ErrorType.ERROR_INVALID_PARTITION_VALUES, ((HCatException) exc).getErrorType());
/** * Gets the HCatOuputJobInfo object by reading the Configuration and deserializing * the string. If InputJobInfo is not present in the configuration, throws an * exception since that means HCatOutputFormat.setOutput has not been called. * @param conf the job Configuration object * @return the OutputJobInfo object * @throws IOException the IO exception */ public static OutputJobInfo getJobInfo(Configuration conf) throws IOException { String jobString = conf.get(HCatConstants.HCAT_KEY_OUTPUT_INFO); if (jobString == null) { throw new HCatException(ErrorType.ERROR_NOT_INITIALIZED); } return (OutputJobInfo) HCatUtil.deserialize(jobString); }
public void testCannotAddFieldMoreThanOnce() throws HCatException { List<HCatFieldSchema> fieldSchemaList = new ArrayList<HCatFieldSchema>(); fieldSchemaList.add(new HCatFieldSchema("name", HCatFieldSchema.Type.STRING, "What's your handle?")); fieldSchemaList.add(new HCatFieldSchema("age", HCatFieldSchema.Type.INT, "So very old")); HCatSchema schema = new HCatSchema(fieldSchemaList); assertTrue(schema.getFieldNames().contains("age")); assertEquals(2, schema.getFields().size()); try { schema.append(new HCatFieldSchema("age", HCatFieldSchema.Type.INT, "So very old")); fail("Was able to append field schema with same name"); } catch (HCatException he) { assertTrue(he.getMessage().contains("Attempt to append HCatFieldSchema with already existing name: age.")); } assertTrue(schema.getFieldNames().contains("age")); assertEquals(2, schema.getFields().size()); // Should also not be able to add fields of different types with same name try { schema.append(new HCatFieldSchema("age", HCatFieldSchema.Type.STRING, "Maybe spelled out?")); fail("Was able to append field schema with same name"); } catch (HCatException he) { assertTrue(he.getMessage().contains("Attempt to append HCatFieldSchema with already existing name: age.")); } assertTrue(schema.getFieldNames().contains("age")); assertEquals(2, schema.getFields().size()); }
/** * Instantiates a new hcat exception. * @param errorType the error type * @param extraMessage extra messages to add to the message string * @param cause the cause */ public HCatException(ErrorType errorType, String extraMessage, Throwable cause) { super(buildErrorMessage( errorType, extraMessage, cause), cause); this.errorType = errorType; }