aboutsummaryrefslogtreecommitdiff
path: root/contrib/native/client/src/include
diff options
context:
space:
mode:
authornorrislee <norrislee18@hotmail.com>2014-07-15 13:03:01 -0700
committerAditya Kishore <aditya@maprtech.com>2014-07-24 16:16:03 -0700
commit6d48ff8c22bf91a4acfcd55bfe7fb220b38387c4 (patch)
tree17498f5ce74314ac262d5e5dab9c9fe7932118f3 /contrib/native/client/src/include
parentd59536313365b826f8d1e075a17d33411605ebf1 (diff)
DRILL-1144 Fix cases where leading zeros are ignored in decimals
Diffstat (limited to 'contrib/native/client/src/include')
-rw-r--r--contrib/native/client/src/include/drill/recordBatch.hpp13
1 files changed, 12 insertions, 1 deletions
diff --git a/contrib/native/client/src/include/drill/recordBatch.hpp b/contrib/native/client/src/include/drill/recordBatch.hpp
index 80c714214..8d7942a9b 100644
--- a/contrib/native/client/src/include/drill/recordBatch.hpp
+++ b/contrib/native/client/src/include/drill/recordBatch.hpp
@@ -302,7 +302,18 @@ template <int DECIMAL_DIGITS, int WIDTH_IN_BYTES, bool IS_SPARSE, int MAX_PRECIS
void getValueAt(size_t index, char* buf, size_t nChars) const {
const DecimalValue& val = this->get(index);
- const std::string& str = boost::lexical_cast<std::string>(val.m_unscaledValue);
+ 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 {