-
Notifications
You must be signed in to change notification settings - Fork 3.7k
[enhancement](function) floor/ceil/round/round_bankers can use column as scale argument #34391
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
Conversation
|
Thank you for your contribution to Apache Doris. Since 2024-03-18, the Document has been moved to doris-website. |
a804e99 to
908a495
Compare
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.
clang-tidy made some suggestions
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.
clang-tidy made some suggestions
df5f558 to
6313577
Compare
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.
clang-tidy made some suggestions
6313577 to
9ed83f2
Compare
|
clang-tidy review says "All clean, LGTM! 👍" |
9ed83f2 to
472f4db
Compare
|
run buildall |
|
clang-tidy review says "All clean, LGTM! 👍" |
|
TeamCity be ut coverage result: |
TPC-H: Total hot run time: 41175 ms |
TPC-DS: Total hot run time: 186675 ms |
472f4db to
ef697bb
Compare
|
run buildall |
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.
clang-tidy made some suggestions
|
TeamCity be ut coverage result: |
TPC-H: Total hot run time: 41854 ms |
ef697bb to
3fc43b4
Compare
TPC-DS: Total hot run time: 185793 ms |
|
clang-tidy review says "All clean, LGTM! 👍" |
3fc43b4 to
adb88e9
Compare
|
clang-tidy review says "All clean, LGTM! 👍" |
|
run buildall |
|
TeamCity be ut coverage result: |
TPC-DS: Total hot run time: 186675 ms |
Oh, you get the point. No wonder I just wanted to print the log but got nothing. Thanks~~~ |
|
clang-tidy review says "All clean, LGTM! 👍" |
|
run buildall |
|
TeamCity be ut coverage result: |
TPC-DS: Total hot run time: 187296 ms |
|
https://dev.mysql.com/doc/refman/8.0/en/mathematical-functions.html#function_ceil ceil function in mysql and pg do not support using second argument. So, @superdiaodiao could you please do a small modification so that we can detect the above situation for function ceil? Just need to modify the logic in planner and do not register two argument for ceil on BE. |
Doris has been support two arguments for a long time, I think we shouldn't delete this behavior in this enhancement PR. What's more, Clickhouse also supports two argument on ceil(). |
ok, we can keep the code in this pr, and we can change behavior in another pr if necessary. |
Yes, I agree with this. |
zhiqiang-hhhh
left a comment
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, excellent job
|
PR approved by anyone and no changes requested. |
|
run feut |
HappenLee
left a comment
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
|
PR approved by at least one committer and no changes requested. |
lide-reed
left a comment
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
… as scale argument (apache#34391)
1. fix compute wrong scale of round_bankers/truncate/round/dround/floor/dfloor/ceil/dceil, introduced by #32746 and #34391 this sql will throw exception: ```sql create table test_round_bankers_scale( id bigint, a decimal(32,6) ) properties ("replication_num" = "1"); select round_bankers(a, 1-2) from test_round_bankers_scale order by id (1105, 'errCode = 2, detailMessage = (172.20.48.119)[INTERNAL_ERROR]output type not match expr type , col name , expected type Nullable(Decimal(32, 6)) , real type Nullable(Decimal(32, 0))') ``` The scale of return type of the round_bankers function depends on the type of its arguments. If the second argument is an integer constant, that constant is used as the scale. If it is not a constant, the scale of the first argument is used instead. This leads to a problem: for expressions like `1 - 2`, the scale used in the computation differs before and after constant folding, which can cause the Backend to throw an exception: type mismatch So we need to fold the arguments into constants before binding the function, to ensure that the scale will not change 2. keep idempotent of function signature. when we select a signature for a function, we should not change signature after do some rewrite
Proposed changes
Issue Number: #32755
Like PR: #32746, we enhanced floor/ceil/round/round_bankers can use column as scale argument.
Meanwhile, we moved these round based function register into new file named round.cpp to accelerate compile process and enable code more readable.
What's more, we made truncate() can run with single const argument avoiding BE crash, like branch2.0's behavior or Clickhouse's.
Docs refer PR: apache/doris-website#620
Further comments
If this is a relatively large or complex change, kick off the discussion at dev@doris.apache.org by explaining why you chose the solution you did and what alternatives you considered, etc...