aboutsummaryrefslogtreecommitdiff
path: root/contrib/native/client
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/native/client')
-rw-r--r--contrib/native/client/src/clientlib/decimalUtils.cpp15
-rw-r--r--contrib/native/client/src/clientlib/fieldmeta.cpp3
-rw-r--r--contrib/native/client/src/clientlib/metadata.cpp51
-rw-r--r--contrib/native/client/src/clientlib/recordBatch.cpp4
-rw-r--r--contrib/native/client/src/include/drill/decimalUtils.hpp1
-rw-r--r--contrib/native/client/src/include/drill/protobuf/Types.pb.h5
-rw-r--r--contrib/native/client/src/include/drill/recordBatch.hpp55
-rw-r--r--contrib/native/client/src/protobuf/Types.pb.cc11
8 files changed, 133 insertions, 12 deletions
diff --git a/contrib/native/client/src/clientlib/decimalUtils.cpp b/contrib/native/client/src/clientlib/decimalUtils.cpp
index 6e26c5528..465eefeb5 100644
--- a/contrib/native/client/src/clientlib/decimalUtils.cpp
+++ b/contrib/native/client/src/clientlib/decimalUtils.cpp
@@ -95,6 +95,21 @@ DecimalValue getDecimalValueFromByteBuf(SlicedByteBuf& data, size_t startIndex,
return val;
}
+DecimalValue getDecimalValueFromByteBuf(SlicedByteBuf& data, size_t length, int scale) {
+
+ cpp_int decimalDigits;
+ // casts the first unsigned byte to signed to determine the sign of the value
+ decimalDigits = decimalDigits | cpp_int(static_cast<int8_t>(data.getByte(0))) << (length - 1) * 8;
+ for (int pos = length - 1; pos > 0; pos--) {
+ decimalDigits = decimalDigits | cpp_int(data.getByte(pos)) << (length - pos - 1) * 8;
+ }
+
+ DecimalValue val;
+ val.m_unscaledValue = decimalDigits;
+ val.m_scale = scale;
+ return val;
+}
+
DecimalValue getDecimalValueFromDense(SlicedByteBuf& data, size_t startIndex, int nDecimalDigits, int scale, int maxPrecision, int width)
{
/* This method converts the dense representation to
diff --git a/contrib/native/client/src/clientlib/fieldmeta.cpp b/contrib/native/client/src/clientlib/fieldmeta.cpp
index 797b038eb..b48f3bc06 100644
--- a/contrib/native/client/src/clientlib/fieldmeta.cpp
+++ b/contrib/native/client/src/clientlib/fieldmeta.cpp
@@ -71,6 +71,7 @@ static const std::string& getSQLType(common::MinorType type, common::DataMode mo
case common::DECIMAL28DENSE:
case common::DECIMAL28SPARSE:
case common::DECIMAL38DENSE:
+ case common::VARDECIMAL:
case common::DECIMAL38SPARSE: return SQLDecimal;
case common::VARCHAR: return SQLVarchar;
@@ -133,6 +134,7 @@ static bool isSigned(common::MinorType type, common::DataMode mode) {
case common::DECIMAL28DENSE:
case common::DECIMAL38DENSE:
case common::DECIMAL38SPARSE:
+ case common::VARDECIMAL:
case common::INTERVALYEAR:
case common::INTERVALDAY:
@@ -304,6 +306,7 @@ static uint32_t getDisplaySize(const ::common::MajorType& type) {
case ::common::DECIMAL28SPARSE:
case ::common::DECIMAL38DENSE:
case ::common::DECIMAL38SPARSE:
+ case ::common::VARDECIMAL:
case ::common::MONEY: return 2 + precision; // precision of the column plus a sign and a decimal point
case ::common::VARCHAR:
diff --git a/contrib/native/client/src/clientlib/metadata.cpp b/contrib/native/client/src/clientlib/metadata.cpp
index 637c83b33..0f1cf2eab 100644
--- a/contrib/native/client/src/clientlib/metadata.cpp
+++ b/contrib/native/client/src/clientlib/metadata.cpp
@@ -110,6 +110,7 @@ static const convert_support_set s_convertMap = boost::assign::list_of
(ConvertSupport(common::TINYINT, common::DECIMAL18))
(ConvertSupport(common::TINYINT, common::DECIMAL28SPARSE))
(ConvertSupport(common::TINYINT, common::DECIMAL38SPARSE))
+ (ConvertSupport(common::TINYINT, common::VARDECIMAL))
(ConvertSupport(common::TINYINT, common::DATE))
(ConvertSupport(common::TINYINT, common::TIME))
(ConvertSupport(common::TINYINT, common::TIMESTAMP))
@@ -128,6 +129,7 @@ static const convert_support_set s_convertMap = boost::assign::list_of
(ConvertSupport(common::SMALLINT, common::DECIMAL18))
(ConvertSupport(common::SMALLINT, common::DECIMAL28SPARSE))
(ConvertSupport(common::SMALLINT, common::DECIMAL38SPARSE))
+ (ConvertSupport(common::SMALLINT, common::VARDECIMAL))
(ConvertSupport(common::SMALLINT, common::DATE))
(ConvertSupport(common::SMALLINT, common::TIME))
(ConvertSupport(common::SMALLINT, common::TIMESTAMP))
@@ -146,6 +148,7 @@ static const convert_support_set s_convertMap = boost::assign::list_of
(ConvertSupport(common::INT, common::DECIMAL18))
(ConvertSupport(common::INT, common::DECIMAL28SPARSE))
(ConvertSupport(common::INT, common::DECIMAL38SPARSE))
+ (ConvertSupport(common::INT, common::VARDECIMAL))
(ConvertSupport(common::INT, common::DATE))
(ConvertSupport(common::INT, common::TIME))
(ConvertSupport(common::INT, common::TIMESTAMP))
@@ -164,6 +167,7 @@ static const convert_support_set s_convertMap = boost::assign::list_of
(ConvertSupport(common::BIGINT, common::DECIMAL18))
(ConvertSupport(common::BIGINT, common::DECIMAL28SPARSE))
(ConvertSupport(common::BIGINT, common::DECIMAL38SPARSE))
+ (ConvertSupport(common::BIGINT, common::VARDECIMAL))
(ConvertSupport(common::BIGINT, common::DATE))
(ConvertSupport(common::BIGINT, common::TIME))
(ConvertSupport(common::BIGINT, common::TIMESTAMP))
@@ -182,6 +186,7 @@ static const convert_support_set s_convertMap = boost::assign::list_of
(ConvertSupport(common::DECIMAL9, common::DECIMAL18))
(ConvertSupport(common::DECIMAL9, common::DECIMAL28SPARSE))
(ConvertSupport(common::DECIMAL9, common::DECIMAL38SPARSE))
+ (ConvertSupport(common::DECIMAL9, common::VARDECIMAL))
(ConvertSupport(common::DECIMAL9, common::DATE))
(ConvertSupport(common::DECIMAL9, common::TIME))
(ConvertSupport(common::DECIMAL9, common::TIMESTAMP))
@@ -200,6 +205,7 @@ static const convert_support_set s_convertMap = boost::assign::list_of
(ConvertSupport(common::DECIMAL18, common::DECIMAL18))
(ConvertSupport(common::DECIMAL18, common::DECIMAL28SPARSE))
(ConvertSupport(common::DECIMAL18, common::DECIMAL38SPARSE))
+ (ConvertSupport(common::DECIMAL18, common::VARDECIMAL))
(ConvertSupport(common::DECIMAL18, common::DATE))
(ConvertSupport(common::DECIMAL18, common::TIME))
(ConvertSupport(common::DECIMAL18, common::TIMESTAMP))
@@ -218,6 +224,7 @@ static const convert_support_set s_convertMap = boost::assign::list_of
(ConvertSupport(common::DECIMAL28SPARSE, common::DECIMAL18))
(ConvertSupport(common::DECIMAL28SPARSE, common::DECIMAL28SPARSE))
(ConvertSupport(common::DECIMAL28SPARSE, common::DECIMAL38SPARSE))
+ (ConvertSupport(common::DECIMAL28SPARSE, common::VARDECIMAL))
(ConvertSupport(common::DECIMAL28SPARSE, common::DATE))
(ConvertSupport(common::DECIMAL28SPARSE, common::TIME))
(ConvertSupport(common::DECIMAL28SPARSE, common::TIMESTAMP))
@@ -236,6 +243,7 @@ static const convert_support_set s_convertMap = boost::assign::list_of
(ConvertSupport(common::DECIMAL38SPARSE, common::DECIMAL18))
(ConvertSupport(common::DECIMAL38SPARSE, common::DECIMAL28SPARSE))
(ConvertSupport(common::DECIMAL38SPARSE, common::DECIMAL38SPARSE))
+ (ConvertSupport(common::DECIMAL38SPARSE, common::VARDECIMAL))
(ConvertSupport(common::DECIMAL38SPARSE, common::DATE))
(ConvertSupport(common::DECIMAL38SPARSE, common::TIME))
(ConvertSupport(common::DECIMAL38SPARSE, common::TIMESTAMP))
@@ -248,12 +256,32 @@ static const convert_support_set s_convertMap = boost::assign::list_of
(ConvertSupport(common::DECIMAL38SPARSE, common::VARBINARY))
(ConvertSupport(common::DECIMAL38SPARSE, common::INTERVALYEAR))
(ConvertSupport(common::DECIMAL38SPARSE, common::INTERVALDAY))
+ (ConvertSupport(common::VARDECIMAL, common::INT))
+ (ConvertSupport(common::VARDECIMAL, common::BIGINT))
+ (ConvertSupport(common::VARDECIMAL, common::DECIMAL9))
+ (ConvertSupport(common::VARDECIMAL, common::DECIMAL18))
+ (ConvertSupport(common::VARDECIMAL, common::DECIMAL28SPARSE))
+ (ConvertSupport(common::VARDECIMAL, common::DECIMAL38SPARSE))
+ (ConvertSupport(common::VARDECIMAL, common::VARDECIMAL))
+ (ConvertSupport(common::VARDECIMAL, common::DATE))
+ (ConvertSupport(common::VARDECIMAL, common::TIME))
+ (ConvertSupport(common::VARDECIMAL, common::TIMESTAMP))
+ (ConvertSupport(common::VARDECIMAL, common::INTERVAL))
+ (ConvertSupport(common::VARDECIMAL, common::FLOAT4))
+ (ConvertSupport(common::VARDECIMAL, common::FLOAT8))
+ (ConvertSupport(common::VARDECIMAL, common::BIT))
+ (ConvertSupport(common::VARDECIMAL, common::VARCHAR))
+ (ConvertSupport(common::VARDECIMAL, common::VAR16CHAR))
+ (ConvertSupport(common::VARDECIMAL, common::VARBINARY))
+ (ConvertSupport(common::VARDECIMAL, common::INTERVALYEAR))
+ (ConvertSupport(common::VARDECIMAL, common::INTERVALDAY))
(ConvertSupport(common::MONEY, common::INT))
(ConvertSupport(common::MONEY, common::BIGINT))
(ConvertSupport(common::MONEY, common::DECIMAL9))
(ConvertSupport(common::MONEY, common::DECIMAL18))
(ConvertSupport(common::MONEY, common::DECIMAL28SPARSE))
(ConvertSupport(common::MONEY, common::DECIMAL38SPARSE))
+ (ConvertSupport(common::MONEY, common::VARDECIMAL))
(ConvertSupport(common::MONEY, common::DATE))
(ConvertSupport(common::MONEY, common::TIME))
(ConvertSupport(common::MONEY, common::TIMESTAMP))
@@ -272,6 +300,7 @@ static const convert_support_set s_convertMap = boost::assign::list_of
(ConvertSupport(common::DATE, common::DECIMAL18))
(ConvertSupport(common::DATE, common::DECIMAL28SPARSE))
(ConvertSupport(common::DATE, common::DECIMAL38SPARSE))
+ (ConvertSupport(common::DATE, common::VARDECIMAL))
(ConvertSupport(common::DATE, common::DATE))
(ConvertSupport(common::DATE, common::TIME))
(ConvertSupport(common::DATE, common::TIMESTAMP))
@@ -290,6 +319,7 @@ static const convert_support_set s_convertMap = boost::assign::list_of
(ConvertSupport(common::TIME, common::DECIMAL18))
(ConvertSupport(common::TIME, common::DECIMAL28SPARSE))
(ConvertSupport(common::TIME, common::DECIMAL38SPARSE))
+ (ConvertSupport(common::TIME, common::VARDECIMAL))
(ConvertSupport(common::TIME, common::DATE))
(ConvertSupport(common::TIME, common::TIME))
(ConvertSupport(common::TIME, common::TIMESTAMP))
@@ -308,6 +338,7 @@ static const convert_support_set s_convertMap = boost::assign::list_of
(ConvertSupport(common::TIMESTAMPTZ, common::DECIMAL18))
(ConvertSupport(common::TIMESTAMPTZ, common::DECIMAL28SPARSE))
(ConvertSupport(common::TIMESTAMPTZ, common::DECIMAL38SPARSE))
+ (ConvertSupport(common::TIMESTAMPTZ, common::VARDECIMAL))
(ConvertSupport(common::TIMESTAMPTZ, common::DATE))
(ConvertSupport(common::TIMESTAMPTZ, common::TIME))
(ConvertSupport(common::TIMESTAMPTZ, common::TIMESTAMP))
@@ -326,6 +357,7 @@ static const convert_support_set s_convertMap = boost::assign::list_of
(ConvertSupport(common::TIMESTAMP, common::DECIMAL18))
(ConvertSupport(common::TIMESTAMP, common::DECIMAL28SPARSE))
(ConvertSupport(common::TIMESTAMP, common::DECIMAL38SPARSE))
+ (ConvertSupport(common::TIMESTAMP, common::VARDECIMAL))
(ConvertSupport(common::TIMESTAMP, common::DATE))
(ConvertSupport(common::TIMESTAMP, common::TIME))
(ConvertSupport(common::TIMESTAMP, common::TIMESTAMP))
@@ -344,6 +376,7 @@ static const convert_support_set s_convertMap = boost::assign::list_of
(ConvertSupport(common::INTERVAL, common::DECIMAL18))
(ConvertSupport(common::INTERVAL, common::DECIMAL28SPARSE))
(ConvertSupport(common::INTERVAL, common::DECIMAL38SPARSE))
+ (ConvertSupport(common::INTERVAL, common::VARDECIMAL))
(ConvertSupport(common::INTERVAL, common::DATE))
(ConvertSupport(common::INTERVAL, common::TIME))
(ConvertSupport(common::INTERVAL, common::TIMESTAMP))
@@ -362,6 +395,7 @@ static const convert_support_set s_convertMap = boost::assign::list_of
(ConvertSupport(common::FLOAT4, common::DECIMAL18))
(ConvertSupport(common::FLOAT4, common::DECIMAL28SPARSE))
(ConvertSupport(common::FLOAT4, common::DECIMAL38SPARSE))
+ (ConvertSupport(common::FLOAT4, common::VARDECIMAL))
(ConvertSupport(common::FLOAT4, common::DATE))
(ConvertSupport(common::FLOAT4, common::TIME))
(ConvertSupport(common::FLOAT4, common::TIMESTAMP))
@@ -380,6 +414,7 @@ static const convert_support_set s_convertMap = boost::assign::list_of
(ConvertSupport(common::FLOAT8, common::DECIMAL18))
(ConvertSupport(common::FLOAT8, common::DECIMAL28SPARSE))
(ConvertSupport(common::FLOAT8, common::DECIMAL38SPARSE))
+ (ConvertSupport(common::FLOAT8, common::VARDECIMAL))
(ConvertSupport(common::FLOAT8, common::DATE))
(ConvertSupport(common::FLOAT8, common::TIME))
(ConvertSupport(common::FLOAT8, common::TIMESTAMP))
@@ -399,6 +434,7 @@ static const convert_support_set s_convertMap = boost::assign::list_of
(ConvertSupport(common::BIT, common::DECIMAL18))
(ConvertSupport(common::BIT, common::DECIMAL28SPARSE))
(ConvertSupport(common::BIT, common::DECIMAL38SPARSE))
+ (ConvertSupport(common::BIT, common::VARDECIMAL))
(ConvertSupport(common::BIT, common::DATE))
(ConvertSupport(common::BIT, common::TIME))
(ConvertSupport(common::BIT, common::TIMESTAMP))
@@ -418,6 +454,7 @@ static const convert_support_set s_convertMap = boost::assign::list_of
(ConvertSupport(common::FIXEDCHAR, common::DECIMAL18))
(ConvertSupport(common::FIXEDCHAR, common::DECIMAL28SPARSE))
(ConvertSupport(common::FIXEDCHAR, common::DECIMAL38SPARSE))
+ (ConvertSupport(common::FIXEDCHAR, common::VARDECIMAL))
(ConvertSupport(common::FIXEDCHAR, common::DATE))
(ConvertSupport(common::FIXEDCHAR, common::TIME))
(ConvertSupport(common::FIXEDCHAR, common::TIMESTAMP))
@@ -437,6 +474,7 @@ static const convert_support_set s_convertMap = boost::assign::list_of
(ConvertSupport(common::FIXED16CHAR, common::DECIMAL18))
(ConvertSupport(common::FIXED16CHAR, common::DECIMAL28SPARSE))
(ConvertSupport(common::FIXED16CHAR, common::DECIMAL38SPARSE))
+ (ConvertSupport(common::FIXED16CHAR, common::VARDECIMAL))
(ConvertSupport(common::FIXED16CHAR, common::DATE))
(ConvertSupport(common::FIXED16CHAR, common::TIME))
(ConvertSupport(common::FIXED16CHAR, common::TIMESTAMP))
@@ -455,6 +493,7 @@ static const convert_support_set s_convertMap = boost::assign::list_of
(ConvertSupport(common::FIXEDBINARY, common::DECIMAL18))
(ConvertSupport(common::FIXEDBINARY, common::DECIMAL28SPARSE))
(ConvertSupport(common::FIXEDBINARY, common::DECIMAL38SPARSE))
+ (ConvertSupport(common::FIXEDBINARY, common::VARDECIMAL))
(ConvertSupport(common::FIXEDBINARY, common::DATE))
(ConvertSupport(common::FIXEDBINARY, common::TIME))
(ConvertSupport(common::FIXEDBINARY, common::TIMESTAMP))
@@ -474,6 +513,7 @@ static const convert_support_set s_convertMap = boost::assign::list_of
(ConvertSupport(common::VARCHAR, common::DECIMAL18))
(ConvertSupport(common::VARCHAR, common::DECIMAL28SPARSE))
(ConvertSupport(common::VARCHAR, common::DECIMAL38SPARSE))
+ (ConvertSupport(common::VARCHAR, common::VARDECIMAL))
(ConvertSupport(common::VARCHAR, common::DATE))
(ConvertSupport(common::VARCHAR, common::TIME))
(ConvertSupport(common::VARCHAR, common::TIMESTAMP))
@@ -493,6 +533,7 @@ static const convert_support_set s_convertMap = boost::assign::list_of
(ConvertSupport(common::VAR16CHAR, common::DECIMAL18))
(ConvertSupport(common::VAR16CHAR, common::DECIMAL28SPARSE))
(ConvertSupport(common::VAR16CHAR, common::DECIMAL38SPARSE))
+ (ConvertSupport(common::VAR16CHAR, common::VARDECIMAL))
(ConvertSupport(common::VAR16CHAR, common::DATE))
(ConvertSupport(common::VAR16CHAR, common::TIME))
(ConvertSupport(common::VAR16CHAR, common::TIMESTAMP))
@@ -511,6 +552,7 @@ static const convert_support_set s_convertMap = boost::assign::list_of
(ConvertSupport(common::VARBINARY, common::DECIMAL18))
(ConvertSupport(common::VARBINARY, common::DECIMAL28SPARSE))
(ConvertSupport(common::VARBINARY, common::DECIMAL38SPARSE))
+ (ConvertSupport(common::VARBINARY, common::VARDECIMAL))
(ConvertSupport(common::VARBINARY, common::DATE))
(ConvertSupport(common::VARBINARY, common::TIME))
(ConvertSupport(common::VARBINARY, common::TIMESTAMP))
@@ -529,6 +571,7 @@ static const convert_support_set s_convertMap = boost::assign::list_of
(ConvertSupport(common::UINT1, common::DECIMAL18))
(ConvertSupport(common::UINT1, common::DECIMAL28SPARSE))
(ConvertSupport(common::UINT1, common::DECIMAL38SPARSE))
+ (ConvertSupport(common::UINT1, common::VARDECIMAL))
(ConvertSupport(common::UINT1, common::DATE))
(ConvertSupport(common::UINT1, common::TIME))
(ConvertSupport(common::UINT1, common::TIMESTAMP))
@@ -547,6 +590,7 @@ static const convert_support_set s_convertMap = boost::assign::list_of
(ConvertSupport(common::UINT2, common::DECIMAL18))
(ConvertSupport(common::UINT2, common::DECIMAL28SPARSE))
(ConvertSupport(common::UINT2, common::DECIMAL38SPARSE))
+ (ConvertSupport(common::UINT2, common::VARDECIMAL))
(ConvertSupport(common::UINT2, common::DATE))
(ConvertSupport(common::UINT2, common::TIME))
(ConvertSupport(common::UINT2, common::TIMESTAMP))
@@ -565,6 +609,7 @@ static const convert_support_set s_convertMap = boost::assign::list_of
(ConvertSupport(common::UINT4, common::DECIMAL18))
(ConvertSupport(common::UINT4, common::DECIMAL28SPARSE))
(ConvertSupport(common::UINT4, common::DECIMAL38SPARSE))
+ (ConvertSupport(common::UINT4, common::VARDECIMAL))
(ConvertSupport(common::UINT4, common::DATE))
(ConvertSupport(common::UINT4, common::TIME))
(ConvertSupport(common::UINT4, common::TIMESTAMP))
@@ -583,6 +628,7 @@ static const convert_support_set s_convertMap = boost::assign::list_of
(ConvertSupport(common::UINT8, common::DECIMAL18))
(ConvertSupport(common::UINT8, common::DECIMAL28SPARSE))
(ConvertSupport(common::UINT8, common::DECIMAL38SPARSE))
+ (ConvertSupport(common::UINT8, common::VARDECIMAL))
(ConvertSupport(common::UINT8, common::DATE))
(ConvertSupport(common::UINT8, common::TIME))
(ConvertSupport(common::UINT8, common::TIMESTAMP))
@@ -601,6 +647,7 @@ static const convert_support_set s_convertMap = boost::assign::list_of
(ConvertSupport(common::DECIMAL28DENSE, common::DECIMAL18))
(ConvertSupport(common::DECIMAL28DENSE, common::DECIMAL28SPARSE))
(ConvertSupport(common::DECIMAL28DENSE, common::DECIMAL38SPARSE))
+ (ConvertSupport(common::DECIMAL28DENSE, common::VARDECIMAL))
(ConvertSupport(common::DECIMAL28DENSE, common::DATE))
(ConvertSupport(common::DECIMAL28DENSE, common::TIME))
(ConvertSupport(common::DECIMAL28DENSE, common::TIMESTAMP))
@@ -619,6 +666,7 @@ static const convert_support_set s_convertMap = boost::assign::list_of
(ConvertSupport(common::DECIMAL38DENSE, common::DECIMAL18))
(ConvertSupport(common::DECIMAL38DENSE, common::DECIMAL28SPARSE))
(ConvertSupport(common::DECIMAL38DENSE, common::DECIMAL38SPARSE))
+ (ConvertSupport(common::DECIMAL38DENSE, common::VARDECIMAL))
(ConvertSupport(common::DECIMAL38DENSE, common::DATE))
(ConvertSupport(common::DECIMAL38DENSE, common::TIME))
(ConvertSupport(common::DECIMAL38DENSE, common::TIMESTAMP))
@@ -638,6 +686,7 @@ static const convert_support_set s_convertMap = boost::assign::list_of
(ConvertSupport(common::DM_UNKNOWN, common::DECIMAL18))
(ConvertSupport(common::DM_UNKNOWN, common::DECIMAL28SPARSE))
(ConvertSupport(common::DM_UNKNOWN, common::DECIMAL38SPARSE))
+ (ConvertSupport(common::DM_UNKNOWN, common::VARDECIMAL))
(ConvertSupport(common::DM_UNKNOWN, common::DATE))
(ConvertSupport(common::DM_UNKNOWN, common::TIME))
(ConvertSupport(common::DM_UNKNOWN, common::TIMESTAMP))
@@ -656,6 +705,7 @@ static const convert_support_set s_convertMap = boost::assign::list_of
(ConvertSupport(common::INTERVALYEAR, common::DECIMAL18))
(ConvertSupport(common::INTERVALYEAR, common::DECIMAL28SPARSE))
(ConvertSupport(common::INTERVALYEAR, common::DECIMAL38SPARSE))
+ (ConvertSupport(common::INTERVALYEAR, common::VARDECIMAL))
(ConvertSupport(common::INTERVALYEAR, common::DATE))
(ConvertSupport(common::INTERVALYEAR, common::TIME))
(ConvertSupport(common::INTERVALYEAR, common::TIMESTAMP))
@@ -674,6 +724,7 @@ static const convert_support_set s_convertMap = boost::assign::list_of
(ConvertSupport(common::INTERVALDAY, common::DECIMAL18))
(ConvertSupport(common::INTERVALDAY, common::DECIMAL28SPARSE))
(ConvertSupport(common::INTERVALDAY, common::DECIMAL38SPARSE))
+ (ConvertSupport(common::INTERVALDAY, common::VARDECIMAL))
(ConvertSupport(common::INTERVALDAY, common::DATE))
(ConvertSupport(common::INTERVALDAY, common::TIME))
(ConvertSupport(common::INTERVALDAY, common::TIMESTAMP))
diff --git a/contrib/native/client/src/clientlib/recordBatch.cpp b/contrib/native/client/src/clientlib/recordBatch.cpp
index d7c196d00..1c897d694 100644
--- a/contrib/native/client/src/clientlib/recordBatch.cpp
+++ b/contrib/native/client/src/clientlib/recordBatch.cpp
@@ -201,6 +201,8 @@ ValueVectorBase* ValueVectorFactory::allocateValueVector(const Drill::FieldMetad
return new ValueVectorDecimal28Sparse(b,f.getValueCount(), f.getScale());
case common::DECIMAL38SPARSE:
return new ValueVectorDecimal38Sparse(b,f.getValueCount(), f.getScale());
+ case common::VARDECIMAL:
+ return new ValueVectorVarDecimal(b, f.getValueCount(), f.getScale());
case common::DATE:
return new ValueVectorTyped<DateHolder, int64_t>(b,f.getValueCount());
case common::TIMESTAMP:
@@ -251,6 +253,8 @@ ValueVectorBase* ValueVectorFactory::allocateValueVector(const Drill::FieldMetad
return new NullableValueVectorDecimal28Sparse(b,f.getValueCount(), f.getScale());
case common::DECIMAL38SPARSE:
return new NullableValueVectorDecimal38Sparse(b,f.getValueCount(), f.getScale());
+ case common::VARDECIMAL:
+ return new NullableValueVectorVarDecimal(b, f.getValueCount(), f.getScale());
case common::DATE:
return new NullableValueVectorTyped<DateHolder,
ValueVectorTyped<DateHolder, int64_t> >(b,f.getValueCount());
diff --git a/contrib/native/client/src/include/drill/decimalUtils.hpp b/contrib/native/client/src/include/drill/decimalUtils.hpp
index 2ace85772..5f9d37a99 100644
--- a/contrib/native/client/src/include/drill/decimalUtils.hpp
+++ b/contrib/native/client/src/include/drill/decimalUtils.hpp
@@ -41,6 +41,7 @@ struct DecimalValue
// These functions need not be exported. They are used by the templates that return the DecimalValue class.
DecimalValue getDecimalValueFromByteBuf(SlicedByteBuf& data, size_t startIndex, int nDecimalDigits, int scale, bool truncateScale);
+DecimalValue getDecimalValueFromByteBuf(SlicedByteBuf& data, size_t length, int scale);
DecimalValue getDecimalValueFromDense(SlicedByteBuf& data, size_t startIndex, int nDecimalDigits, int scale, int maxPrecision, int width);
inline DecimalValue getDecimalValueFromIntermediate(SlicedByteBuf& data, size_t startIndex, int nDecimalDigits, int scale)
diff --git a/contrib/native/client/src/include/drill/protobuf/Types.pb.h b/contrib/native/client/src/include/drill/protobuf/Types.pb.h
index f9200ec09..b1dec7bd6 100644
--- a/contrib/native/client/src/include/drill/protobuf/Types.pb.h
+++ b/contrib/native/client/src/include/drill/protobuf/Types.pb.h
@@ -74,11 +74,12 @@ enum MinorType {
INTERVALDAY = 39,
LIST = 40,
GENERIC_OBJECT = 41,
- UNION = 42
+ UNION = 42,
+ VARDECIMAL = 43
};
bool MinorType_IsValid(int value);
const MinorType MinorType_MIN = LATE;
-const MinorType MinorType_MAX = UNION;
+const MinorType MinorType_MAX = VARDECIMAL;
const int MinorType_ARRAYSIZE = MinorType_MAX + 1;
const ::google::protobuf::EnumDescriptor* MinorType_descriptor();
diff --git a/contrib/native/client/src/include/drill/recordBatch.hpp b/contrib/native/client/src/include/drill/recordBatch.hpp
index 30287b6ad..435eb7715 100644
--- a/contrib/native/client/src/include/drill/recordBatch.hpp
+++ b/contrib/native/client/src/include/drill/recordBatch.hpp
@@ -346,7 +346,8 @@ template <int DECIMAL_DIGITS, int WIDTH_IN_BYTES, bool IS_SPARSE, int MAX_PRECIS
strncpy(buf, str.c_str(), nChars);
} else {
size_t idxDecimalMark = str.length() - m_scale;
- const std::string& decStr= str.substr(0, idxDecimalMark) + "." + str.substr(idxDecimalMark, m_scale);
+ const std::string& decStr =
+ (idxDecimalMark == 0 ? "0" : str.substr(0, idxDecimalMark)) + "." + str.substr(idxDecimalMark, m_scale);
strncpy(buf, decStr.c_str(), nChars);
}
return;
@@ -734,6 +735,49 @@ class DECLSPEC_DRILL_CLIENT ValueVectorVarChar:public ValueVectorVarWidth{
}
};
+class DECLSPEC_DRILL_CLIENT ValueVectorVarDecimal:public ValueVectorVarWidth{
+ public:
+ ValueVectorVarDecimal(SlicedByteBuf *b, size_t rowCount, size_t scale):
+ ValueVectorVarWidth(b, rowCount),
+ m_scale(scale)
+ {
+ }
+ DecimalValue get(size_t index) const {
+ size_t length = getSize(index);
+ ByteBuf_t buff = getRaw(index);
+ SlicedByteBuf intermediateData(&buff[0], 0, length);
+ return getDecimalValueFromByteBuf(intermediateData, length, this->m_scale);
+ }
+
+ void getValueAt(size_t index, char* buf, size_t nChars) const {
+ const DecimalValue& val = this->get(index);
+ std::string str = boost::lexical_cast<std::string>(val.m_unscaledValue);
+ if (str[0] == '-') {
+ str = str.substr(1);
+ while (str.length() < m_scale) {
+ str = "0" + str;
+ }
+ str = "-" + str;
+ } else {
+ while (str.length() < m_scale) {
+ str = "0" + str;
+ }
+ }
+ if (m_scale == 0) {
+ strncpy(buf, str.c_str(), nChars);
+ } else {
+ size_t idxDecimalMark = str.length() - m_scale;
+ const std::string& decStr =
+ (idxDecimalMark == 0 ? "0" : str.substr(0, idxDecimalMark)) + "." + str.substr(idxDecimalMark, m_scale);
+ strncpy(buf, decStr.c_str(), nChars);
+ }
+ return;
+ }
+
+ private:
+ int32_t m_scale;
+};
+
class DECLSPEC_DRILL_CLIENT ValueVectorVarBinary:public ValueVectorVarWidth{
public:
ValueVectorVarBinary(SlicedByteBuf *b, size_t rowCount):ValueVectorVarWidth(b, rowCount){
@@ -764,10 +808,11 @@ typedef ValueVectorDecimal<6, 24, true, 38> ValueVectorDecimal38Sparse;
typedef NullableValueVectorTyped<int32_t, ValueVectorDecimal9> NullableValueVectorDecimal9;
typedef NullableValueVectorTyped<int64_t, ValueVectorDecimal18> NullableValueVectorDecimal18;
-typedef NullableValueVectorTyped<DecimalValue , ValueVectorDecimal28Dense> NullableValueVectorDecimal28Dense;
-typedef NullableValueVectorTyped<DecimalValue , ValueVectorDecimal38Dense> NullableValueVectorDecimal38Dense;
-typedef NullableValueVectorTyped<DecimalValue , ValueVectorDecimal28Sparse> NullableValueVectorDecimal28Sparse;
-typedef NullableValueVectorTyped<DecimalValue , ValueVectorDecimal38Sparse> NullableValueVectorDecimal38Sparse;
+typedef NullableValueVectorTyped<DecimalValue, ValueVectorDecimal28Dense> NullableValueVectorDecimal28Dense;
+typedef NullableValueVectorTyped<DecimalValue, ValueVectorDecimal38Dense> NullableValueVectorDecimal38Dense;
+typedef NullableValueVectorTyped<DecimalValue, ValueVectorDecimal28Sparse> NullableValueVectorDecimal28Sparse;
+typedef NullableValueVectorTyped<DecimalValue, ValueVectorDecimal38Sparse> NullableValueVectorDecimal38Sparse;
+typedef NullableValueVectorTyped<DecimalValue, ValueVectorVarDecimal> NullableValueVectorVarDecimal;
typedef ValueVectorTyped<DateHolder, int64_t> ValueVectorDate;
typedef ValueVectorTyped<DateTimeHolder, int64_t> ValueVectorTimestamp;
diff --git a/contrib/native/client/src/protobuf/Types.pb.cc b/contrib/native/client/src/protobuf/Types.pb.cc
index ec8a1c84f..675bba02d 100644
--- a/contrib/native/client/src/protobuf/Types.pb.cc
+++ b/contrib/native/client/src/protobuf/Types.pb.cc
@@ -93,7 +93,7 @@ void protobuf_AddDesc_Types_2eproto() {
"de\030\002 \001(\0162\020.common.DataMode\022\r\n\005width\030\003 \001("
"\005\022\021\n\tprecision\030\004 \001(\005\022\r\n\005scale\030\005 \001(\005\022\020\n\010t"
"imeZone\030\006 \001(\005\022#\n\010sub_type\030\007 \003(\0162\021.common"
- ".MinorType*\233\004\n\tMinorType\022\010\n\004LATE\020\000\022\007\n\003MA"
+ ".MinorType*\253\004\n\tMinorType\022\010\n\004LATE\020\000\022\007\n\003MA"
"P\020\001\022\013\n\007TINYINT\020\003\022\014\n\010SMALLINT\020\004\022\007\n\003INT\020\005\022"
"\n\n\006BIGINT\020\006\022\014\n\010DECIMAL9\020\007\022\r\n\tDECIMAL18\020\010"
"\022\023\n\017DECIMAL28SPARSE\020\t\022\023\n\017DECIMAL38SPARSE"
@@ -106,10 +106,10 @@ void protobuf_AddDesc_Types_2eproto() {
"\n\005UINT4\020\037\022\t\n\005UINT8\020 \022\022\n\016DECIMAL28DENSE\020!"
"\022\022\n\016DECIMAL38DENSE\020\"\022\016\n\nDM_UNKNOWN\020%\022\020\n\014"
"INTERVALYEAR\020&\022\017\n\013INTERVALDAY\020\'\022\010\n\004LIST\020"
- "(\022\022\n\016GENERIC_OBJECT\020)\022\t\n\005UNION\020**=\n\010Data"
- "Mode\022\017\n\013DM_OPTIONAL\020\000\022\017\n\013DM_REQUIRED\020\001\022\017"
- "\n\013DM_REPEATED\020\002B-\n\035org.apache.drill.comm"
- "on.typesB\nTypeProtosH\001", 862);
+ "(\022\022\n\016GENERIC_OBJECT\020)\022\t\n\005UNION\020*\022\016\n\nVARD"
+ "ECIMAL\020+*=\n\010DataMode\022\017\n\013DM_OPTIONAL\020\000\022\017\n"
+ "\013DM_REQUIRED\020\001\022\017\n\013DM_REPEATED\020\002B-\n\035org.a"
+ "pache.drill.common.typesB\nTypeProtosH\001", 878);
::google::protobuf::MessageFactory::InternalRegisterGeneratedFile(
"Types.proto", &protobuf_RegisterTypes);
MajorType::default_instance_ = new MajorType();
@@ -167,6 +167,7 @@ bool MinorType_IsValid(int value) {
case 40:
case 41:
case 42:
+ case 43:
return true;
default:
return false;