Skip to content

Commit

Permalink
[decimalv2](compatibility) add config to allow invalid decimalv2 lite…
Browse files Browse the repository at this point in the history
…ral (apache#21327)
  • Loading branch information
Gabriel39 authored and pull[bot] committed Sep 27, 2023
1 parent b6fbc2c commit 5b4914e
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
2 changes: 2 additions & 0 deletions be/src/common/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1027,6 +1027,8 @@ DEFINE_Int64(max_external_file_meta_cache_num, "20000");
// max_write_buffer_number for rocksdb
DEFINE_Int32(rocksdb_max_write_buffer_number, "5");

DEFINE_Bool(allow_invalid_decimalv2_literal, "false");

#ifdef BE_TEST
// test s3
DEFINE_String(test_s3_resource, "resource");
Expand Down
3 changes: 3 additions & 0 deletions be/src/common/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -1043,6 +1043,9 @@ DECLARE_Int64(max_external_file_meta_cache_num);
// max_write_buffer_number for rocksdb
DECLARE_Int32(rocksdb_max_write_buffer_number);

// Allow invalid decimalv2 literal for compatible with old version. Recommend set it false strongly.
DECLARE_mBool(allow_invalid_decimalv2_literal);

#ifdef BE_TEST
// test s3
DECLARE_String(test_s3_resource);
Expand Down
4 changes: 3 additions & 1 deletion be/src/runtime/decimalv2_value.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,9 @@ int DecimalV2Value::parse_from_str(const char* decimal_str, int32_t length) {

_value = StringParser::string_to_decimal<__int128>(decimal_str, length, PRECISION, SCALE,
&result);
if (result != StringParser::PARSE_SUCCESS) {
if (!config::allow_invalid_decimalv2_literal && result != StringParser::PARSE_SUCCESS) {
error = E_DEC_BAD_NUM;
} else if (config::allow_invalid_decimalv2_literal && result == StringParser::PARSE_FAILURE) {
error = E_DEC_BAD_NUM;
}
return error;
Expand Down

0 comments on commit 5b4914e

Please sign in to comment.