datafuselabs / databend

𝗗𝗮𝘁𝗮, 𝗔𝗻𝗮𝗹𝘆𝘁𝗶𝗰𝘀 & 𝗔𝗜. Modern alternative to Snowflake. Cost-effective and simple for massive-scale analytics. https://databend.com
https://docs.databend.com
Other
7.31k stars 704 forks source link

bug: decimal overflow conversion error #15568

Closed malwaregarry closed 2 weeks ago

malwaregarry commented 2 weeks ago

Search before asking

Version

8.0.26-v1.2.453-d7c9a83f6b(rust-1.77.0-nightly-2024-05-06T12:12:40.122758622Z)

What's Wrong?

There seem to be a problem with the implicit inference / casting of decimals during comparison operations.

For example,

SELECT (0.12)>(-123456.1);

returns

ERROR 1105 (HY000): BadArguments. Code: 1006, Text = error:
  --> SQL:1:16
  |
1 | SELECT (0.12)>(-123456.1)
  |                ^ Decimal overflow at line : 723 while evaluating function `to_decimal(7, 2)(-123456.1)`

The bug discovered using SQLancer

How to Reproduce?

-- errors
SELECT (0.123)>(-1.1);
SELECT (0.1234)>(-1.1);
SELECT (0.1234)>(-12.1);
SELECT (0.1234)>(-123.1);
-- no errors
SELECT (0.12)>(1.1);
SELECT (0.1)>(-1.1);
SELECT (0.12)>(-1.12);
SELECT (0.12)>(-1);

Are you willing to submit PR?