in server/pxf-hive/src/main/java/org/greenplum/pxf/plugins/hive/HiveResolver.java [191:287]
void initPartitionFields() {
partitionColumnNames = new HashMap<>();
List<HivePartition> hivePartitionList = metadata.getPartitions();
if (hivePartitionList == null || hivePartitionList.size() == 0) {
// no partition column information
return;
}
for (HivePartition partition : hivePartitionList) {
String columnName = partition.getName();
String type = partition.getType();
String val = partition.getValue();
DataType convertedType;
Object convertedValue;
boolean isDefaultPartition;
// check if value is default partition
isDefaultPartition = isDefaultPartition(type, val);
// ignore the type's parameters
String typeName = type.replaceAll("\\(.*\\)", "");
switch (typeName) {
case serdeConstants.STRING_TYPE_NAME:
convertedType = DataType.TEXT;
convertedValue = isDefaultPartition ? null : val;
break;
case serdeConstants.BOOLEAN_TYPE_NAME:
convertedType = DataType.BOOLEAN;
convertedValue = isDefaultPartition ? null
: Boolean.valueOf(val);
break;
case serdeConstants.TINYINT_TYPE_NAME:
case serdeConstants.SMALLINT_TYPE_NAME:
convertedType = DataType.SMALLINT;
convertedValue = isDefaultPartition ? null
: Short.parseShort(val);
break;
case serdeConstants.INT_TYPE_NAME:
convertedType = DataType.INTEGER;
convertedValue = isDefaultPartition ? null
: Integer.parseInt(val);
break;
case serdeConstants.BIGINT_TYPE_NAME:
convertedType = DataType.BIGINT;
convertedValue = isDefaultPartition ? null
: Long.parseLong(val);
break;
case serdeConstants.FLOAT_TYPE_NAME:
convertedType = DataType.REAL;
convertedValue = isDefaultPartition ? null
: Float.parseFloat(val);
break;
case serdeConstants.DOUBLE_TYPE_NAME:
convertedType = DataType.FLOAT8;
convertedValue = isDefaultPartition ? null
: Double.parseDouble(val);
break;
case serdeConstants.TIMESTAMP_TYPE_NAME:
convertedType = DataType.TIMESTAMP;
convertedValue = isDefaultPartition ? null
: Timestamp.valueOf(val);
break;
case serdeConstants.DATE_TYPE_NAME:
convertedType = DataType.DATE;
convertedValue = isDefaultPartition ? null
: Date.valueOf(val);
break;
case serdeConstants.DECIMAL_TYPE_NAME:
convertedType = DataType.NUMERIC;
convertedValue = isDefaultPartition ? null
: HiveDecimal.create(val).bigDecimalValue().toString();
break;
case serdeConstants.VARCHAR_TYPE_NAME:
convertedType = DataType.VARCHAR;
convertedValue = isDefaultPartition ? null : val;
break;
case serdeConstants.CHAR_TYPE_NAME:
convertedType = DataType.BPCHAR;
convertedValue = isDefaultPartition ? null : val;
break;
case serdeConstants.BINARY_TYPE_NAME:
convertedType = DataType.BYTEA;
convertedValue = isDefaultPartition ? null : val.getBytes();
break;
default:
throw new UnsupportedTypeException(
"Unsupported partition type: " + type);
}
if (columnDescriptorContainsColumn(columnName)) {
partitionColumnNames.put(StringUtils.lowerCase(columnName),
new OneField(convertedType.getOID(), convertedValue));
}
}
numberOfPartitions = partitionColumnNames.size();
}