@Test(expected = Exception.class) public void shouldThrowExceptionForUnknownParquetType() throws Exception { HiveClient hiveClient = new HiveClient(driverName, "jdbc:hive2: hdfsTemp + "/garmadon_database"); PrimitiveType unsupported = new PrimitiveType(Type.Repetition.OPTIONAL, PrimitiveType.PrimitiveTypeName.INT96, "unsupported"); hiveClient.inferHiveType(unsupported); }
protected String inferHiveType(Type field) throws Exception { String fieldHiveType; switch (field.asPrimitiveType().getPrimitiveTypeName().name()) { case "BINARY": fieldHiveType = "string"; break; case "INT32": fieldHiveType = "int"; break; case "INT64": fieldHiveType = "bigint"; break; case "FLOAT": fieldHiveType = "float"; break; case "DOUBLE": fieldHiveType = "double"; break; case "BOOLEAN": fieldHiveType = "boolean"; break; default: throw new Exception("Unsupported Data Type: " + field.asPrimitiveType().getPrimitiveTypeName().name()); } if (field.isRepetition(Type.Repetition.REPEATED)) { fieldHiveType = "array<" + fieldHiveType + ">"; } return fieldHiveType; }
HiveClient { protected String inferHiveType(Type field) throws Exception { String fieldHiveType; switch (field.asPrimitiveType().getPrimitiveTypeName().name()) { case "BINARY": fieldHiveType = "string"; break; case "INT32": fieldHiveType = "int"; break; case "INT64": fieldHiveType = "bigint"; break; case "FLOAT": fieldHiveType = "float"; break; case "DOUBLE": fieldHiveType = "double"; break; case "BOOLEAN": fieldHiveType = "boolean"; break; default: throw new Exception("Unsupported Data Type: " + field.asPrimitiveType().getPrimitiveTypeName().name()); } if (field.isRepetition(Type.Repetition.REPEATED)) { fieldHiveType = "array<" + fieldHiveType + ">"; } return fieldHiveType; } }
HiveClient { protected String inferHiveType(Type field) throws Exception { String fieldHiveType; switch (field.asPrimitiveType().getPrimitiveTypeName().name()) { case "BINARY": fieldHiveType = "string"; break; case "INT32": fieldHiveType = "int"; break; case "INT64": fieldHiveType = "bigint"; break; case "FLOAT": fieldHiveType = "float"; break; case "DOUBLE": fieldHiveType = "double"; break; case "BOOLEAN": fieldHiveType = "boolean"; break; default: throw new Exception("Unsupported Data Type: " + field.asPrimitiveType().getPrimitiveTypeName().name()); } if (field.isRepetition(Type.Repetition.REPEATED)) { fieldHiveType = "array<" + fieldHiveType + ">"; } return fieldHiveType; } HiveClient(String driverName, String jdbcUrl, String database, String location); }
HiveClient { protected String inferHiveType(Type field) throws Exception { String fieldHiveType; switch (field.asPrimitiveType().getPrimitiveTypeName().name()) { case "BINARY": fieldHiveType = "string"; break; case "INT32": fieldHiveType = "int"; break; case "INT64": fieldHiveType = "bigint"; break; case "FLOAT": fieldHiveType = "float"; break; case "DOUBLE": fieldHiveType = "double"; break; case "BOOLEAN": fieldHiveType = "boolean"; break; default: throw new Exception("Unsupported Data Type: " + field.asPrimitiveType().getPrimitiveTypeName().name()); } if (field.isRepetition(Type.Repetition.REPEATED)) { fieldHiveType = "array<" + fieldHiveType + ">"; } return fieldHiveType; } HiveClient(String driverName, String jdbcUrl, String database, String location); void createDatabaseIfAbsent(String location); void createPartitionIfNotExist(String table, MessageType schema, String partition, String location); void close(); }
HiveClient { protected String inferHiveType(Type field) throws Exception { String fieldHiveType; switch (field.asPrimitiveType().getPrimitiveTypeName().name()) { case "BINARY": fieldHiveType = "string"; break; case "INT32": fieldHiveType = "int"; break; case "INT64": fieldHiveType = "bigint"; break; case "FLOAT": fieldHiveType = "float"; break; case "DOUBLE": fieldHiveType = "double"; break; case "BOOLEAN": fieldHiveType = "boolean"; break; default: throw new Exception("Unsupported Data Type: " + field.asPrimitiveType().getPrimitiveTypeName().name()); } if (field.isRepetition(Type.Repetition.REPEATED)) { fieldHiveType = "array<" + fieldHiveType + ">"; } return fieldHiveType; } HiveClient(String driverName, String jdbcUrl, String database, String location); void createDatabaseIfAbsent(String location); void createPartitionIfNotExist(String table, MessageType schema, String partition, String location); void close();  }