@Test public void mapHiveTypeComplex() throws Exception { for (String[] line : complexTypes) { String hiveType = line[0]; String expectedType = line[1]; hiveColumn = new FieldSchema("field" + hiveType, hiveType, null); Metadata.Field result = HiveUtilities.mapHiveType(hiveColumn); assertEquals("field" + hiveType, result.getName()); assertEquals(expectedType, result.getType().getTypeName()); assertNull(result.getModifiers()); } }
public static Metadata.Field mapHiveType(FieldSchema hiveColumn) throws UnsupportedTypeException { String fieldName = hiveColumn.getName(); String hiveType = hiveColumn.getType(); String hiveTypeName; String[] modifiers = null; EnumHiveToGpdbType hiveToGpdbType = EnumHiveToGpdbType.getHiveToGpdbType(hiveType); EnumGpdbType gpdbType = hiveToGpdbType.getGpdbType(); if (hiveToGpdbType.getSplitExpression() != null) { String[] tokens = hiveType.split(hiveToGpdbType.getSplitExpression()); hiveTypeName = tokens[0]; if (gpdbType.getModifiersNum() > 0) { modifiers = Arrays.copyOfRange(tokens, 1, tokens.length); if (modifiers.length != gpdbType.getModifiersNum()) { throw new UnsupportedTypeException( "GPDB does not support type " + hiveType + " (Field " + fieldName + "), " + "expected number of modifiers: " + gpdbType.getModifiersNum() + ", actual number of modifiers: " + modifiers.length); } if (!verifyIntegerModifiers(modifiers)) { throw new UnsupportedTypeException("GPDB does not support type " + hiveType + " (Field " + fieldName + "), modifiers should be integers"); } } } else hiveTypeName = hiveType; return new Metadata.Field(fieldName, gpdbType, hiveToGpdbType.isComplexType(), hiveTypeName, modifiers); }
HiveUtilities { public static Metadata.Field mapHiveType(FieldSchema hiveColumn) throws UnsupportedTypeException { String fieldName = hiveColumn.getName(); String hiveType = hiveColumn.getType(); String hiveTypeName; String[] modifiers = null; EnumHiveToGpdbType hiveToGpdbType = EnumHiveToGpdbType.getHiveToGpdbType(hiveType); EnumGpdbType gpdbType = hiveToGpdbType.getGpdbType(); if (hiveToGpdbType.getSplitExpression() != null) { String[] tokens = hiveType.split(hiveToGpdbType.getSplitExpression()); hiveTypeName = tokens[0]; if (gpdbType.getModifiersNum() > 0) { modifiers = Arrays.copyOfRange(tokens, 1, tokens.length); if (modifiers.length != gpdbType.getModifiersNum()) { throw new UnsupportedTypeException( "GPDB does not support type " + hiveType + " (Field " + fieldName + "), " + "expected number of modifiers: " + gpdbType.getModifiersNum() + ", actual number of modifiers: " + modifiers.length); } if (!verifyIntegerModifiers(modifiers)) { throw new UnsupportedTypeException("GPDB does not support type " + hiveType + " (Field " + fieldName + "), modifiers should be integers"); } } } else hiveTypeName = hiveType; return new Metadata.Field(fieldName, gpdbType, hiveToGpdbType.isComplexType(), hiveTypeName, modifiers); } }
HiveUtilities { public static Metadata.Field mapHiveType(FieldSchema hiveColumn) throws UnsupportedTypeException { String fieldName = hiveColumn.getName(); String hiveType = hiveColumn.getType(); String hiveTypeName; String[] modifiers = null; EnumHiveToGpdbType hiveToGpdbType = EnumHiveToGpdbType.getHiveToGpdbType(hiveType); EnumGpdbType gpdbType = hiveToGpdbType.getGpdbType(); if (hiveToGpdbType.getSplitExpression() != null) { String[] tokens = hiveType.split(hiveToGpdbType.getSplitExpression()); hiveTypeName = tokens[0]; if (gpdbType.getModifiersNum() > 0) { modifiers = Arrays.copyOfRange(tokens, 1, tokens.length); if (modifiers.length != gpdbType.getModifiersNum()) { throw new UnsupportedTypeException( "GPDB does not support type " + hiveType + " (Field " + fieldName + "), " + "expected number of modifiers: " + gpdbType.getModifiersNum() + ", actual number of modifiers: " + modifiers.length); } if (!verifyIntegerModifiers(modifiers)) { throw new UnsupportedTypeException("GPDB does not support type " + hiveType + " (Field " + fieldName + "), modifiers should be integers"); } } } else hiveTypeName = hiveType; return new Metadata.Field(fieldName, gpdbType, hiveToGpdbType.isComplexType(), hiveTypeName, modifiers); }  }
HiveUtilities { public static Metadata.Field mapHiveType(FieldSchema hiveColumn) throws UnsupportedTypeException { String fieldName = hiveColumn.getName(); String hiveType = hiveColumn.getType(); String hiveTypeName; String[] modifiers = null; EnumHiveToGpdbType hiveToGpdbType = EnumHiveToGpdbType.getHiveToGpdbType(hiveType); EnumGpdbType gpdbType = hiveToGpdbType.getGpdbType(); if (hiveToGpdbType.getSplitExpression() != null) { String[] tokens = hiveType.split(hiveToGpdbType.getSplitExpression()); hiveTypeName = tokens[0]; if (gpdbType.getModifiersNum() > 0) { modifiers = Arrays.copyOfRange(tokens, 1, tokens.length); if (modifiers.length != gpdbType.getModifiersNum()) { throw new UnsupportedTypeException( "GPDB does not support type " + hiveType + " (Field " + fieldName + "), " + "expected number of modifiers: " + gpdbType.getModifiersNum() + ", actual number of modifiers: " + modifiers.length); } if (!verifyIntegerModifiers(modifiers)) { throw new UnsupportedTypeException("GPDB does not support type " + hiveType + " (Field " + fieldName + "), modifiers should be integers"); } } } else hiveTypeName = hiveType; return new Metadata.Field(fieldName, gpdbType, hiveToGpdbType.isComplexType(), hiveTypeName, modifiers); }  static Metadata.Field mapHiveType(FieldSchema hiveColumn); static String toCompatibleHiveType(DataType type, Integer[] modifiers); static void validateTypeCompatible(DataType gpdbDataType, Integer[] gpdbTypeMods, String hiveType, String gpdbColumnName); static HiveUserData parseHiveUserData(RequestContext context); static Deserializer createDeserializer(String serdeClassName); static Reader getOrcReader(Configuration configuration, RequestContext requestContext); }
HiveUtilities { public static Metadata.Field mapHiveType(FieldSchema hiveColumn) throws UnsupportedTypeException { String fieldName = hiveColumn.getName(); String hiveType = hiveColumn.getType(); String hiveTypeName; String[] modifiers = null; EnumHiveToGpdbType hiveToGpdbType = EnumHiveToGpdbType.getHiveToGpdbType(hiveType); EnumGpdbType gpdbType = hiveToGpdbType.getGpdbType(); if (hiveToGpdbType.getSplitExpression() != null) { String[] tokens = hiveType.split(hiveToGpdbType.getSplitExpression()); hiveTypeName = tokens[0]; if (gpdbType.getModifiersNum() > 0) { modifiers = Arrays.copyOfRange(tokens, 1, tokens.length); if (modifiers.length != gpdbType.getModifiersNum()) { throw new UnsupportedTypeException( "GPDB does not support type " + hiveType + " (Field " + fieldName + "), " + "expected number of modifiers: " + gpdbType.getModifiersNum() + ", actual number of modifiers: " + modifiers.length); } if (!verifyIntegerModifiers(modifiers)) { throw new UnsupportedTypeException("GPDB does not support type " + hiveType + " (Field " + fieldName + "), modifiers should be integers"); } } } else hiveTypeName = hiveType; return new Metadata.Field(fieldName, gpdbType, hiveToGpdbType.isComplexType(), hiveTypeName, modifiers); }  static Metadata.Field mapHiveType(FieldSchema hiveColumn); static String toCompatibleHiveType(DataType type, Integer[] modifiers); static void validateTypeCompatible(DataType gpdbDataType, Integer[] gpdbTypeMods, String hiveType, String gpdbColumnName); static HiveUserData parseHiveUserData(RequestContext context); static Deserializer createDeserializer(String serdeClassName); static Reader getOrcReader(Configuration configuration, RequestContext requestContext);  }