@Test public void testBuildSchemaThrowsException() { thrown.expect(UnsupportedOperationException.class); ParquetUtil.buildSchema(Arrays.asList(new Field("Object", Object.class))); }
public static String buildSchema(List<Field> fields) { StringBuilder sb = new StringBuilder("message row { "); for (Field field : fields) { String fieldName = field.getName(); Class<?> type = field.getJavaTypeClass(); switch (type.getSimpleName()) { case "String": sb.append("optional binary ").append(fieldName).append(" (UTF8); "); break; case "Byte": case "Short": case "Integer": sb.append("optional INT32 ").append(fieldName).append("; "); break; case "Long": case "Date": sb.append("optional INT64 ").append(fieldName).append("; "); break; case "Float": sb.append("optional FLOAT ").append(fieldName).append("; "); break; case "Double": case "BigDecimal": sb.append("optional DOUBLE ").append(fieldName).append("; "); break; case "Boolean": sb.append("optional BOOLEAN ").append(fieldName).append("; "); break; case "byte[]": sb.append("optional binary ").append(fieldName).append("; "); break; case "Map": throw new UnsupportedOperationException("this type[Map] have't support!"); default: throw new UnsupportedOperationException("this " + type + " have't support!"); } } sb.append("} "); return sb.toString(); }
ParquetUtil { public static String buildSchema(List<Field> fields) { StringBuilder sb = new StringBuilder("message row { "); for (Field field : fields) { String fieldName = field.getName(); Class<?> type = field.getJavaTypeClass(); switch (type.getSimpleName()) { case "String": sb.append("optional binary ").append(fieldName).append(" (UTF8); "); break; case "Byte": case "Short": case "Integer": sb.append("optional INT32 ").append(fieldName).append("; "); break; case "Long": case "Date": sb.append("optional INT64 ").append(fieldName).append("; "); break; case "Float": sb.append("optional FLOAT ").append(fieldName).append("; "); break; case "Double": case "BigDecimal": sb.append("optional DOUBLE ").append(fieldName).append("; "); break; case "Boolean": sb.append("optional BOOLEAN ").append(fieldName).append("; "); break; case "byte[]": sb.append("optional binary ").append(fieldName).append("; "); break; case "Map": throw new UnsupportedOperationException("this type[Map] have't support!"); default: throw new UnsupportedOperationException("this " + type + " have't support!"); } } sb.append("} "); return sb.toString(); } }
ParquetUtil { public static String buildSchema(List<Field> fields) { StringBuilder sb = new StringBuilder("message row { "); for (Field field : fields) { String fieldName = field.getName(); Class<?> type = field.getJavaTypeClass(); switch (type.getSimpleName()) { case "String": sb.append("optional binary ").append(fieldName).append(" (UTF8); "); break; case "Byte": case "Short": case "Integer": sb.append("optional INT32 ").append(fieldName).append("; "); break; case "Long": case "Date": sb.append("optional INT64 ").append(fieldName).append("; "); break; case "Float": sb.append("optional FLOAT ").append(fieldName).append("; "); break; case "Double": case "BigDecimal": sb.append("optional DOUBLE ").append(fieldName).append("; "); break; case "Boolean": sb.append("optional BOOLEAN ").append(fieldName).append("; "); break; case "byte[]": sb.append("optional binary ").append(fieldName).append("; "); break; case "Map": throw new UnsupportedOperationException("this type[Map] have't support!"); default: throw new UnsupportedOperationException("this " + type + " have't support!"); } } sb.append("} "); return sb.toString(); } private  ParquetUtil(); }
ParquetUtil { public static String buildSchema(List<Field> fields) { StringBuilder sb = new StringBuilder("message row { "); for (Field field : fields) { String fieldName = field.getName(); Class<?> type = field.getJavaTypeClass(); switch (type.getSimpleName()) { case "String": sb.append("optional binary ").append(fieldName).append(" (UTF8); "); break; case "Byte": case "Short": case "Integer": sb.append("optional INT32 ").append(fieldName).append("; "); break; case "Long": case "Date": sb.append("optional INT64 ").append(fieldName).append("; "); break; case "Float": sb.append("optional FLOAT ").append(fieldName).append("; "); break; case "Double": case "BigDecimal": sb.append("optional DOUBLE ").append(fieldName).append("; "); break; case "Boolean": sb.append("optional BOOLEAN ").append(fieldName).append("; "); break; case "byte[]": sb.append("optional binary ").append(fieldName).append("; "); break; case "Map": throw new UnsupportedOperationException("this type[Map] have't support!"); default: throw new UnsupportedOperationException("this " + type + " have't support!"); } } sb.append("} "); return sb.toString(); } private  ParquetUtil(); static String buildSchema(List<Field> fields); }
ParquetUtil { public static String buildSchema(List<Field> fields) { StringBuilder sb = new StringBuilder("message row { "); for (Field field : fields) { String fieldName = field.getName(); Class<?> type = field.getJavaTypeClass(); switch (type.getSimpleName()) { case "String": sb.append("optional binary ").append(fieldName).append(" (UTF8); "); break; case "Byte": case "Short": case "Integer": sb.append("optional INT32 ").append(fieldName).append("; "); break; case "Long": case "Date": sb.append("optional INT64 ").append(fieldName).append("; "); break; case "Float": sb.append("optional FLOAT ").append(fieldName).append("; "); break; case "Double": case "BigDecimal": sb.append("optional DOUBLE ").append(fieldName).append("; "); break; case "Boolean": sb.append("optional BOOLEAN ").append(fieldName).append("; "); break; case "byte[]": sb.append("optional binary ").append(fieldName).append("; "); break; case "Map": throw new UnsupportedOperationException("this type[Map] have't support!"); default: throw new UnsupportedOperationException("this " + type + " have't support!"); } } sb.append("} "); return sb.toString(); } private  ParquetUtil(); static String buildSchema(List<Field> fields);  }