### Question:
ParserHelper { public static void deriveDataTypes(TableSchemaType type, List<? extends Field> fields) { for (Field field : fields) { if (StringUtils.isEmpty(field.getDerivedDataType())) { JDBCType jdbcType = JDBCType.VARCHAR; try { if (!StringUtils.isEmpty(field.getNativeDataType())) { jdbcType = JDBCType.valueOf(field.getNativeDataType()); } else { jdbcType = deriveJDBCDataType(field.getSampleValues()); } } catch (IllegalArgumentException e) { log.warn("Unable to convert data type [?] will be converted to VARCHAR", field.getNativeDataType()); } switch (type) { case HIVE: String hiveType = sqlTypeToHiveType(jdbcType); field.setDerivedDataType(hiveType); field.setDataTypeDescriptor(hiveTypeToDescriptor(hiveType)); break; case RDBMS: field.setDerivedDataType(jdbcType.getName()); } } } }  static String sqlTypeToHiveType(Integer type); static String sqlTypeToHiveType(JDBCType jdbcType); static JDBCType deriveJDBCDataType(List<String> values); static void deriveDataTypes(TableSchemaType type, List<? extends Field> fields); static DataTypeDescriptor hiveTypeToDescriptor(String hiveType); static String toNativeType(Integer dataType);  }### Answer:
@Test public void testDeriveDataTypes() throws Exception { TestField f1 = new TestField(); f1.setSampleValues(Arrays.asList("10", "20", "30")); TestField f2 = new TestField(); f2.setNativeDataType(""); f2.setSampleValues(Arrays.asList("10.2", "20.3", "30.4")); TestField f3 = new TestField(); f3.setNativeDataType(""); f3.setSampleValues(Arrays.asList("BOB", "20.3", "30.4")); TestField f4 = new TestField(); f4.setNativeDataType("BIGINT"); f4.setSampleValues(Arrays.asList("2015", "203", "304")); TestField f5 = new TestField(); f5.setNativeDataType("INVALIDTYPE"); f5.setSampleValues(Arrays.asList("BOB", "20.3", "30.4")); TestField f6 = new TestField(); f6.setSampleValues(null); ParserHelper.deriveDataTypes(TableSchemaType.HIVE, Arrays.asList(f1, f2, f3, f4, f5, f6)); assertEquals("int", f1.getDerivedDataType()); assertEquals("double", f2.getDerivedDataType()); assertEquals("string", f3.getDerivedDataType()); assertEquals("bigint", f4.getDerivedDataType()); assertEquals("string", f5.getDerivedDataType()); assertEquals("string", f6.getDerivedDataType()); }