Search in sources :

Example 1 with TTypeQualifierValue

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;
}
Also used : TTypeQualifiers(org.apache.hive.service.rpc.thrift.TTypeQualifiers) HashMap(java.util.HashMap) TTypeQualifierValue(org.apache.hive.service.rpc.thrift.TTypeQualifierValue)

Example 2 with TTypeQualifierValue

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;
}
Also used : TTypeQualifierValue(org.apache.hive.service.rpc.thrift.TTypeQualifierValue) TTypeQualifiers(org.apache.hive.service.rpc.thrift.TTypeQualifiers)

Example 3 with TTypeQualifierValue

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;
}
Also used : TTypeQualifiers(org.apache.hive.service.rpc.thrift.TTypeQualifiers) TTypeQualifierValue(org.apache.hive.service.rpc.thrift.TTypeQualifierValue)

Aggregations

TTypeQualifierValue (org.apache.hive.service.rpc.thrift.TTypeQualifierValue)3 TTypeQualifiers (org.apache.hive.service.rpc.thrift.TTypeQualifiers)3 HashMap (java.util.HashMap)1