use of org.apache.hive.service.rpc.thrift.TColumnDesc in project hive by apache.
the class HiveQueryResultSet method retrieveSchema.
/**
* Retrieve schema from the server
*/
private void retrieveSchema() throws SQLException {
try {
TGetResultSetMetadataReq metadataReq = new TGetResultSetMetadataReq(stmtHandle);
// TODO need session handle
TGetResultSetMetadataResp metadataResp;
metadataResp = client.GetResultSetMetadata(metadataReq);
Utils.verifySuccess(metadataResp.getStatus());
StringBuilder namesSb = new StringBuilder();
StringBuilder typesSb = new StringBuilder();
TTableSchema schema = metadataResp.getSchema();
if (schema == null || !schema.isSetColumns()) {
// TODO: should probably throw an exception here.
return;
}
setSchema(new TableSchema(schema));
List<TColumnDesc> columns = schema.getColumns();
for (int pos = 0; pos < schema.getColumnsSize(); pos++) {
if (pos != 0) {
namesSb.append(",");
typesSb.append(",");
}
String columnName = columns.get(pos).getColumnName();
columnNames.add(columnName);
normalizedColumnNames.add(columnName.toLowerCase());
TPrimitiveTypeEntry primitiveTypeEntry = columns.get(pos).getTypeDesc().getTypes().get(0).getPrimitiveEntry();
String columnTypeName = TYPE_NAMES.get(primitiveTypeEntry.getType());
columnTypes.add(columnTypeName);
columnAttributes.add(getColumnAttributes(primitiveTypeEntry));
}
} catch (SQLException eS) {
// rethrow the SQLException as is
throw eS;
} catch (Exception ex) {
ex.printStackTrace();
throw new SQLException("Could not create ResultSet: " + ex.getMessage(), ex);
}
}
use of org.apache.hive.service.rpc.thrift.TColumnDesc in project hive by apache.
the class ColumnDescriptor method toTColumnDesc.
public TColumnDesc toTColumnDesc() {
TColumnDesc tColumnDesc = new TColumnDesc();
tColumnDesc.setColumnName(name);
tColumnDesc.setComment(comment);
tColumnDesc.setTypeDesc(type.toTTypeDesc());
tColumnDesc.setPosition(position);
return tColumnDesc;
}
Aggregations