19 #include "gen-cpp/TCLIService_constants.h"
23 using namespace apache::hive::service::cli::thrift;
30 case TPrimitiveType::NULL_TYPE:
return TYPE_NULL;
34 case TPrimitiveType::INT:
return TYPE_INT;
38 case TPrimitiveType::DATE:
return TYPE_DATE;
45 case TPrimitiveType::CHAR:
return TYPE_CHAR;
53 case TYPE_NULL:
return TPrimitiveType::NULL_TYPE;
57 case TYPE_INT:
return TPrimitiveType::INT;
61 case TYPE_DATE:
return TPrimitiveType::DATE;
68 case TYPE_CHAR:
return TPrimitiveType::CHAR;
120 TTypeEntry ColumnType::ToHs2Type()
const {
121 TPrimitiveTypeEntry type_entry;
126 type_entry.__set_type(TTypeId::BOOLEAN_TYPE);
129 type_entry.__set_type(TTypeId::BOOLEAN_TYPE);
132 type_entry.__set_type(TTypeId::TINYINT_TYPE);
135 type_entry.__set_type(TTypeId::SMALLINT_TYPE);
138 type_entry.__set_type(TTypeId::INT_TYPE);
141 type_entry.__set_type(TTypeId::BIGINT_TYPE);
144 type_entry.__set_type(TTypeId::FLOAT_TYPE);
147 type_entry.__set_type(TTypeId::DOUBLE_TYPE);
150 type_entry.__set_type(TTypeId::TIMESTAMP_TYPE);
153 type_entry.__set_type(TTypeId::STRING_TYPE);
156 type_entry.__set_type(TTypeId::BINARY_TYPE);
159 TTypeQualifierValue tprecision;
160 tprecision.__set_i32Value(precision);
161 TTypeQualifierValue tscale;
162 tscale.__set_i32Value(scale);
164 TTypeQualifiers type_quals;
165 type_quals.qualifiers[g_TCLIService_constants.PRECISION] = tprecision;
166 type_quals.qualifiers[g_TCLIService_constants.SCALE] = tscale;
167 type_entry.__set_typeQualifiers(type_quals);
168 type_entry.__set_type(TTypeId::DECIMAL_TYPE);
173 TTypeQualifierValue tmax_len;
174 tmax_len.__set_i32Value(len);
176 TTypeQualifiers type_quals;
177 type_quals.qualifiers[g_TCLIService_constants.CHARACTER_MAXIMUM_LENGTH] = tmax_len;
178 type_entry.__set_typeQualifiers(type_quals);
179 type_entry.__set_type(
180 (type ==
TYPE_CHAR) ? TTypeId::CHAR_TYPE : TTypeId::VARCHAR_TYPE);
185 DCHECK(
false) <<
"bad TypeToTValueType() type: " <<
DebugString();
186 type_entry.__set_type(TTypeId::STRING_TYPE);
190 result.__set_primitiveEntry(type_entry);
198 ss <<
"CHAR(" << len <<
")";
201 ss <<
"DECIMAL(" << precision <<
", " << scale <<
")";
PrimitiveType ThriftToType(TPrimitiveType::type ttype)
string TypeToOdbcString(PrimitiveType t)
string TypeToString(PrimitiveType t)
std::string DebugString() const
TPrimitiveType::type ToThrift(PrimitiveType ptype)
std::string DebugString(const T &val)
ostream & operator<<(ostream &os, const ColumnType &type)