-
Notifications
You must be signed in to change notification settings - Fork 409
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
Add support for function mod
#2402
Conversation
mod
mod
mod
mod
/run-all-tests |
/run-all-tests |
mod
mod
/run-all-tests |
} | ||
else | ||
{ | ||
return static_cast<Result>(a) % static_cast<Result>(b); |
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.
When both A
and B
are not decimal, the Result
shouldn't be decimal. Suggest only leaving a static_assert(!IsDecimal<Result>)
here.
} | ||
else // both A and B are integrals. | ||
{ | ||
using UnsignedResultType = std::make_unsigned_t<Result>; |
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.
suggest using tics version of make_unsigned_t
and is_signed_v
.
x = static_cast<UnsignedResultType>(a); | ||
|
||
if (std::is_signed_v<B> && b < 0) | ||
y = static_cast<UnsignedResultType>(-b); |
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.
ditto
/run-all-tests |
/run-all-tests |
dbms/src/DataTypes/NumberTraits.h
Outdated
* TODO: | ||
* * add 128-bit and 256-bit integers. | ||
* * change Float32 to Float64. | ||
* * all floating-point arithmetics should evaluate to Float64. |
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.
* * all floating-point arithmetics should evaluate to Float64. | |
* * all floating-point arithmetics should be evaluated to Float64. |
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.
Past tense may not be needed. Here are some examples: https://linggle.com/?q=evaluate+to
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.
Guess they have different subjects. Anyway either style is okay.
auto & a_nullmap_data = a_nullmap->getData(); | ||
auto & b_nullmap_data = b_nullmap->getData(); | ||
for (size_t i = 0; i < size; ++i) | ||
res_null[i] = a_nullmap_data[i] || b_nullmap_data[i]; |
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.
https://godbolt.org/z/Kj7chc3xo seems |
can generate simpler code than ||
.
Anyway I found compiler won't automatically vectorize this for-loop.
} | ||
else if constexpr (is_modulo) | ||
{ | ||
if (scale_a != 1) |
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.
Got it, so would you like to paste your explanation into the code?
Co-authored-by: Fu Zhe <fuzhe1989@gmail.com>
Co-authored-by: Fu Zhe <fuzhe1989@gmail.com>
/run-all-tests |
@fuzhe1989, Thanks for your review. The bot only counts LGTMs from Reviewers and higher roles, but you're still welcome to leave your comments. See the corresponding SIG page for more information. Related SIG: tiflash(slack). |
/merge |
/run-all-tests |
/run-cherry-picker |
cherry pick to release-5.1 in PR #2560 |
cherry pick to release-5.0 in PR #2561 |
What problem does this PR solve?
Issue Number: close #2318
Problem Summary: enable pushing function
mod
down to TiFlash.What is changed and how it works?
Proposal:
What's Changed:
Decimal.h
: compatible with TiDB.DataTypeDecimal.h
: add a helper function to get decimal precision in unit test.DAGUtils.cpp
: add mappings from TiPB codes to scalar function name.FunctionArithmetic.h
: update implementation ofFunctionModulo
.NumberTraits.h
: fix modulo result type deduction.types.h
: addactual_type
, which returns correct size of boost multiprecision integer.mod.test
,mod_extra.test
: the integration test.gtest_arithmetic_functions.cpp
: the unit test.Related changes
pingcap/docs
/pingcap/docs-cn
:Check List
INF
,NaN
Tests
Release note
MOD(N, M)
to TiFlash.