-
Notifications
You must be signed in to change notification settings - Fork 3.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[fix](decimal) throw overflow exception if result is NaN of Infinit when converting from decimal to float #40290
Conversation
Thank you for your contribution to Apache Doris. Since 2024-03-18, the Document has been moved to doris-website. |
run buildall |
clang-tidy review says "All clean, LGTM! 👍" |
1 similar comment
clang-tidy review says "All clean, LGTM! 👍" |
TPC-H: Total hot run time: 38180 ms
|
TPC-DS: Total hot run time: 192271 ms
|
ClickBench: Total hot run time: 31.68 s
|
run buildall |
TPC-H: Total hot run time: 38298 ms
|
TPC-DS: Total hot run time: 188038 ms
|
""" | ||
test { | ||
sql """ | ||
select cast(v1 as float) from dec256cast_to_float; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also add cast for literal and test fold constant is true or false
@@ -41,4 +41,29 @@ suite("test_decimal256_cast") { | |||
select cast('0.000000000000000000000000000000000000000000000000000000000000000000000012345678901' as decimalv3(76,0)); | |||
""" | |||
|
|||
sql """ | |||
drop table if exists dec256cast_to_float; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The previous cast test only test const literal, should also add some test to insert the data to a table and cast them during select.
ClickBench: Total hot run time: 33.01 s
|
@@ -41,4 +41,29 @@ suite("test_decimal256_cast") { | |||
select cast('0.000000000000000000000000000000000000000000000000000000000000000000000012345678901' as decimalv3(76,0)); | |||
""" | |||
|
|||
sql """ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
字面常量的测试:包括打开常量折叠,关闭常量折叠
变量的测试:把数据插入到表中,然后select 执行函数
cast: 别的类型,到decimal; decimal 到别的类型。
不论是字面量还是变量,都要测试异常的值。
…hen converting from decimal to float
run buildall |
clang-tidy review says "All clean, LGTM! 👍" |
1 similar comment
clang-tidy review says "All clean, LGTM! 👍" |
TPC-H: Total hot run time: 38641 ms
|
TPC-DS: Total hot run time: 188229 ms
|
ClickBench: Total hot run time: 32.16 s
|
PR approved by at least one committer and no changes requested. |
PR approved by anyone and no changes requested. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
…hen converting from decimal to float (apache#40290)
…hen converting from decimal to float (apache#40290)
…hen converting from decimal to float (apache#40290)
…hen converting from decimal to float (apache#40290)
Proposed changes
When casting
decimal256
tofloat
, BE first convertingdecimal256
tolong double
, and then converting tofloat
, but for some values, the resulting float value isstd::inf
, this PR check this situation and reportArithmetic overflow
.CPP test:
result: