[fix](delete) fix the error message for valid decimal data for 2.1 (#37710)
## Proposed changes cherry-pick : #36802 <!--Describe your changes.-->
This commit is contained in:
@ -546,7 +546,8 @@ bool valid_decimal(const std::string& value_str, const uint32_t precision, const
|
||||
}
|
||||
|
||||
size_t number_length = value_str.size();
|
||||
if (value_str[0] == '-') {
|
||||
bool is_negative = value_str[0] == '-';
|
||||
if (is_negative) {
|
||||
--number_length;
|
||||
}
|
||||
|
||||
@ -557,7 +558,7 @@ bool valid_decimal(const std::string& value_str, const uint32_t precision, const
|
||||
integer_len = number_length;
|
||||
fractional_len = 0;
|
||||
} else {
|
||||
integer_len = point_pos;
|
||||
integer_len = point_pos - (is_negative ? 1 : 0);
|
||||
fractional_len = number_length - point_pos - 1;
|
||||
}
|
||||
|
||||
|
||||
@ -145,3 +145,5 @@ ccc ccc
|
||||
39 40 42 43 131.200 s o 2023-02-10 2023-02-10T00:01:02 false 22236.106 nn
|
||||
43 44 46 47 135.200 g t 2023-02-14 2023-02-14T00:01:02 false 22240.106 rr
|
||||
|
||||
-- !check_decimal --
|
||||
true -1.0 10
|
||||
@ -512,4 +512,31 @@ suite("test_delete") {
|
||||
sql "delete from table_bitmap where user_id is null"
|
||||
exception "Can not apply delete condition to column type: BITMAP"
|
||||
}
|
||||
|
||||
sql "drop table if exists table_decimal"
|
||||
sql """
|
||||
CREATE TABLE table_decimal (
|
||||
`k1` BOOLEAN NOT NULL,
|
||||
`k2` DECIMAL(17, 1) NOT NULL,
|
||||
`k3` INT NOT NULL
|
||||
) ENGINE=OLAP
|
||||
DUPLICATE KEY(`k1`,`k2`,`k3`)
|
||||
DISTRIBUTED BY HASH(`k1`,`k2`,`k3`) BUCKETS 4
|
||||
PROPERTIES (
|
||||
"replication_num" = "1",
|
||||
"disable_auto_compaction" = "false"
|
||||
);
|
||||
"""
|
||||
sql """
|
||||
insert into table_decimal values
|
||||
(false, '-9999782574499444.2', -20),
|
||||
(true, '-1', 10);
|
||||
"""
|
||||
sql """
|
||||
delete from table_decimal where k1 = false and k2 = '-9999782574499444.2' and k3 = '-20';
|
||||
"""
|
||||
qt_check_decimal """
|
||||
select * from table_decimal;
|
||||
"""
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user