Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HAWQ-1196. Added partitons support to HiveOrc profile. #1041

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ public class HiveColumnarSerdeResolver extends HiveResolver {
private boolean firstColumn;
private StringBuilder builder;
private StringBuilder parts;
private int numberOfPartitions;
private HiveInputFormatFragmenter.PXF_HIVE_SERDES serdeType;

public HiveColumnarSerdeResolver(InputData input) throws Exception {
Expand All @@ -88,7 +87,7 @@ void parseUserData(InputData input) throws Exception {

@Override
void initPartitionFields() {
numberOfPartitions = initPartitionFields(parts);
initPartitionFields(parts);
}

/**
Expand Down Expand Up @@ -118,7 +117,7 @@ public List<OneField> getFields(OneRow onerow) throws Exception {
@Override
void initSerde(InputData input) throws Exception {
Properties serdeProperties = new Properties();
int numberOfDataColumns = input.getColumns() - numberOfPartitions;
int numberOfDataColumns = input.getColumns() - getNumberOfPartitions();

LOG.debug("Serde number of columns is " + numberOfDataColumns);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,6 @@
public class HiveORCSerdeResolver extends HiveResolver {
private static final Log LOG = LogFactory.getLog(HiveORCSerdeResolver.class);
private OrcSerde deserializer;
private StringBuilder parts;
private int numberOfPartitions;
private HiveInputFormatFragmenter.PXF_HIVE_SERDES serdeType;

public HiveORCSerdeResolver(InputData input) throws Exception {
Expand All @@ -70,12 +68,6 @@ void parseUserData(InputData input) throws Exception {
: input.getUserProperty("MAPKEY_DELIM");
}

@Override
void initPartitionFields() {
parts = new StringBuilder();
numberOfPartitions = initPartitionFields(parts);
}

/**
* getFields returns a singleton list of OneField item.
* OneField item contains two fields: an integer representing the VARCHAR type and a Java
Expand All @@ -89,6 +81,9 @@ public List<OneField> getFields(OneRow onerow) throws Exception {
StructObjectInspector soi = (StructObjectInspector) deserializer.getObjectInspector();
List<OneField> record = traverseStruct(tuple, soi, false);

//Add partition fields if any
record.addAll(getPartitionFields());

return record;

}
Expand All @@ -102,7 +97,7 @@ public List<OneField> getFields(OneRow onerow) throws Exception {
@Override
void initSerde(InputData input) throws Exception {
Properties serdeProperties = new Properties();
int numberOfDataColumns = input.getColumns() - numberOfPartitions;
int numberOfDataColumns = input.getColumns() - getNumberOfPartitions();

LOG.debug("Serde number of columns is " + numberOfDataColumns);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ public class HiveResolver extends Plugin implements ReadResolver {
String nullChar = "\\N";
private Configuration conf;
private String hiveDefaultPartName;
private int numberOfPartitions;

/**
* Constructs the HiveResolver by parsing the userdata in the input and
Expand Down Expand Up @@ -122,6 +123,14 @@ public List<OneField> getFields(OneRow onerow) throws Exception {
return record;
}

public List<OneField> getPartitionFields() {
return partitionFields;
}

public int getNumberOfPartitions() {
return numberOfPartitions;
}

/* Parses user data string (arrived from fragmenter). */
void parseUserData(InputData input) throws Exception {
final int EXPECTED_NUM_OF_TOKS = 5;
Expand Down Expand Up @@ -254,16 +263,17 @@ void initPartitionFields() {
"Unsupported partition type: " + type);
}
addOneFieldToRecord(partitionFields, convertedType, convertedValue);
numberOfPartitions = partitionFields.size();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can instead just set numberOfPartitions after the for loop is complete

}
}

/*
* The partition fields are initialized one time based on userData provided
* by the fragmenter.
*/
int initPartitionFields(StringBuilder parts) {
void initPartitionFields(StringBuilder parts) {
if (partitionKeys.equals(HiveDataFragmenter.HIVE_NO_PART_TBL)) {
return 0;
return;
}
String[] partitionLevels = partitionKeys.split(HiveDataFragmenter.HIVE_PARTITIONS_DELIM);
for (String partLevel : partitionLevels) {
Expand Down Expand Up @@ -320,7 +330,7 @@ int initPartitionFields(StringBuilder parts) {
}
}
}
return partitionLevels.length;
this.numberOfPartitions = partitionLevels.length;
}

/**
Expand Down