Skip to content

Commit

Permalink
[fix](delete) fix the error message for valid decimal data for 2.1 (a…
Browse files Browse the repository at this point in the history
…pache#37710)

## Proposed changes

cherry-pick : apache#36802

<!--Describe your changes.-->
  • Loading branch information
felixwluo authored Jul 15, 2024
1 parent 16de141 commit b55dd6f
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 2 deletions.
5 changes: 3 additions & 2 deletions be/src/olap/utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand All @@ -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;
}

Expand Down
2 changes: 2 additions & 0 deletions regression-test/data/delete_p0/test_delete.out
Original file line number Diff line number Diff line change
Expand Up @@ -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
27 changes: 27 additions & 0 deletions regression-test/suites/delete_p0/test_delete.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -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;
"""

}

0 comments on commit b55dd6f

Please sign in to comment.