throw new CatalogException(e);
}
// convert hcatalog field schema into tajo field schema.
schema = new org.apache.tajo.catalog.Schema();
HCatSchema tableSchema = null;
try {
tableSchema = HCatUtil.getTableSchemaWithPtnCols(table);
} catch (IOException ioe) {
throw new CatalogException("Fail to get table schema. - tableName:" + tableName, ioe);
}
List<HCatFieldSchema> fieldSchemaList = tableSchema.getFields();
boolean isPartitionKey = false;
for (HCatFieldSchema eachField : fieldSchemaList) {
isPartitionKey = false;
if (table.getPartitionKeys() != null) {
for (FieldSchema partitionKey : table.getPartitionKeys()) {
if (partitionKey.getName().equals(eachField.getName())) {
isPartitionKey = true;
}
}
}
if (!isPartitionKey) {
String fieldName = databaseName + CatalogConstants.IDENTIFIER_DELIMITER + tableName +
CatalogConstants.IDENTIFIER_DELIMITER + eachField.getName();
TajoDataTypes.Type dataType = HCatalogUtil.getTajoFieldType(eachField.getType().toString());
schema.addColumn(fieldName, dataType);
}
}
// validate field schema.
try {
HCatalogUtil.validateHCatTableAndTajoSchema(tableSchema);
} catch (Exception e) {
throw new CatalogException("HCatalog cannot support schema. - schema:" + tableSchema.toString(), e);
}
stats = new TableStats();
options = new Options();
options.putAll(table.getParameters());