From dc4cbab11ef73ef1dccc649b4df1ac404f76b01a Mon Sep 17 00:00:00 2001 From: Mingyu Chen Date: Mon, 17 Dec 2018 21:04:18 +0800 Subject: [PATCH] Report error when loading decimal value with scientific notation (#428) Currently we do not support scientific notation of decimal value. --- be/src/runtime/decimal_value.cpp | 39 ++++++++++--------- .../help/Contents/Data Definition/ddl_stmt.md | 3 ++ .../Data Manipulation/manipulation_stmt.md | 1 + 3 files changed, 24 insertions(+), 19 deletions(-) diff --git a/be/src/runtime/decimal_value.cpp b/be/src/runtime/decimal_value.cpp index c54e2c5fcf..3ce57313a0 100755 --- a/be/src/runtime/decimal_value.cpp +++ b/be/src/runtime/decimal_value.cpp @@ -900,26 +900,27 @@ int DecimalValue::parse_from_str(const char* decimal_str, int32_t length) { *buff = value * powers10[DIG_PER_DEC1 - index_in_powers10]; } - // Handle exponent + // TODO: we do not support decimal in scientific notation if ((frac_ptr + 1) < end && (*frac_ptr == 'e' || *frac_ptr == 'E')) { - int64_t exponent = strtoll(frac_ptr + 1, (char**) end, 10); - if (end != frac_ptr + 1) { // If at least one digit - if (errno) { // system error number, it is thread local - set_to_zero(); - return E_DEC_BAD_NUM; - } - if (exponent > (INT_MAX / 2) || (errno == 0 && exponent < 0)) { - set_to_zero(); - return E_DEC_OVERFLOW; - } - if (exponent < INT_MAX / 2 && error != E_DEC_OVERFLOW) { - set_to_zero(); - return E_DEC_TRUNCATED; - } - if (error != E_DEC_OVERFLOW) { - // error = shift((int32_t) exponent); - } - } + return E_DEC_BAD_NUM; + // int64_t exponent = strtoll(frac_ptr + 1, (char**) &end, 10); + // if (end != frac_ptr + 1) { // If at least one digit + // if (errno) { // system error number, it is thread local + // set_to_zero(); + // return E_DEC_BAD_NUM; + // } + // if (exponent > (INT_MAX / 2) || (errno == 0 && exponent < 0)) { + // set_to_zero(); + // return E_DEC_OVERFLOW; + // } + // if (exponent < INT_MAX / 2 && error != E_DEC_OVERFLOW) { + // set_to_zero(); + // return E_DEC_TRUNCATED; + // } + // if (error != E_DEC_OVERFLOW) { + // // error = shift((int32_t) exponent); + // } + // } } if (_sign && is_zero()) { _sign = false; diff --git a/docs/help/Contents/Data Definition/ddl_stmt.md b/docs/help/Contents/Data Definition/ddl_stmt.md index 72603dae29..790b11eb4f 100644 --- a/docs/help/Contents/Data Definition/ddl_stmt.md +++ b/docs/help/Contents/Data Definition/ddl_stmt.md @@ -58,12 +58,15 @@ LARGEINT(16字节) 范围:0 ~ 2^127 - 1 FLOAT(4字节) + 支持科学计数法 DOUBLE(12字节) + 支持科学计数法 DECIMAL[(precision, scale)] (40字节) 保证精度的小数类型。默认是 DECIMAL(10, 0) precision: 1 ~ 27 scale: 0 ~ 9 其中整数部分为 1 ~ 18 + 不支持科学计数法 DATE(3字节) 范围:1900-01-01 ~ 9999-12-31 DATETIME(8字节) diff --git a/docs/help/Contents/Data Manipulation/manipulation_stmt.md b/docs/help/Contents/Data Manipulation/manipulation_stmt.md index 9565062178..92d517a1f3 100644 --- a/docs/help/Contents/Data Manipulation/manipulation_stmt.md +++ b/docs/help/Contents/Data Manipulation/manipulation_stmt.md @@ -380,6 +380,7 @@ NOTE: 需要进行url编码,譬如 需要指定'\t'为分隔符,那么应该传入'column_separator=%09' 需要指定'\x01'为分隔符,那么应该传入'column_separator=%01' + 需要指定','为分隔符,那么应该传入'column_separator=%2c' max_filter_ratio: 用于指定允许过滤不规范数据的最大比例,默认是0,不允许过滤