use of org.apache.hive.service.rpc.thrift.TTypeQualifierValue in project hive by apache.
the class TypeQualifiers method toTTypeQualifiers.
public TTypeQualifiers toTTypeQualifiers() {
TTypeQualifiers ret = null;
Map<String, TTypeQualifierValue> qMap = new HashMap<String, TTypeQualifierValue>();
if (getCharacterMaximumLength() != null) {
TTypeQualifierValue val = new TTypeQualifierValue();
val.setI32Value(getCharacterMaximumLength().intValue());
qMap.put(TCLIServiceConstants.CHARACTER_MAXIMUM_LENGTH, val);
}
if (precision != null) {
TTypeQualifierValue val = new TTypeQualifierValue();
val.setI32Value(precision.intValue());
qMap.put(TCLIServiceConstants.PRECISION, val);
}
if (scale != null) {
TTypeQualifierValue val = new TTypeQualifierValue();
val.setI32Value(scale.intValue());
qMap.put(TCLIServiceConstants.SCALE, val);
}
if (qMap.size() > 0) {
ret = new TTypeQualifiers(qMap);
}
return ret;
}
use of org.apache.hive.service.rpc.thrift.TTypeQualifierValue in project hive by apache.
the class TypeQualifiers method fromTTypeQualifiers.
public static TypeQualifiers fromTTypeQualifiers(TTypeQualifiers ttq) {
TypeQualifiers ret = null;
if (ttq != null) {
ret = new TypeQualifiers();
Map<String, TTypeQualifierValue> tqMap = ttq.getQualifiers();
if (tqMap.containsKey(TCLIServiceConstants.CHARACTER_MAXIMUM_LENGTH)) {
ret.setCharacterMaximumLength(tqMap.get(TCLIServiceConstants.CHARACTER_MAXIMUM_LENGTH).getI32Value());
}
if (tqMap.containsKey(TCLIServiceConstants.PRECISION)) {
ret.setPrecision(tqMap.get(TCLIServiceConstants.PRECISION).getI32Value());
}
if (tqMap.containsKey(TCLIServiceConstants.SCALE)) {
ret.setScale(tqMap.get(TCLIServiceConstants.SCALE).getI32Value());
}
}
return ret;
}
use of org.apache.hive.service.rpc.thrift.TTypeQualifierValue in project hive by apache.
the class HiveQueryResultSet method getColumnAttributes.
/**
* Generate ColumnAttributes object from a TTypeQualifiers
* @param primitiveTypeEntry primitive type
* @return generated ColumnAttributes, or null
*/
private static JdbcColumnAttributes getColumnAttributes(TPrimitiveTypeEntry primitiveTypeEntry) {
JdbcColumnAttributes ret = null;
if (primitiveTypeEntry.isSetTypeQualifiers()) {
TTypeQualifiers tq = primitiveTypeEntry.getTypeQualifiers();
switch(primitiveTypeEntry.getType()) {
case CHAR_TYPE:
case VARCHAR_TYPE:
TTypeQualifierValue val = tq.getQualifiers().get(TCLIServiceConstants.CHARACTER_MAXIMUM_LENGTH);
if (val != null) {
// precision is char length
ret = new JdbcColumnAttributes(val.getI32Value(), 0);
}
break;
case DECIMAL_TYPE:
TTypeQualifierValue prec = tq.getQualifiers().get(TCLIServiceConstants.PRECISION);
TTypeQualifierValue scale = tq.getQualifiers().get(TCLIServiceConstants.SCALE);
ret = new JdbcColumnAttributes(prec == null ? HiveDecimal.USER_DEFAULT_PRECISION : prec.getI32Value(), scale == null ? HiveDecimal.USER_DEFAULT_SCALE : scale.getI32Value());
break;
default:
break;
}
}
return ret;
}
Aggregations