-
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
Implement Agg_BitOr function push down. #5293
base: master
Are you sure you want to change the base?
Implement Agg_BitOr function push down. #5293
Conversation
[REVIEW NOTIFICATION] This pull request has been approved by:
To complete the pull request process, please ask the reviewers in the list to review by filling The full list of commands accepted by this bot can be found here. Reviewer can indicate their review by submitting an approval review. |
When the rows are all P.S. If there is at least one non-null row, it will work well. |
Welcome @RinChanNOWWW! |
c7d2230
to
44fa596
Compare
cc @XuHuaiyu |
Solved with |
3788123
to
e96b302
Compare
e96b302
to
b9b79ca
Compare
/run-all-tests |
Coverage for changed files
Coverage summary
full coverage report (for internal network access only) |
b9b79ca
to
530d46c
Compare
/run-all-tests |
Coverage for changed files
Coverage summary
full coverage report (for internal network access only) |
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
767fe22
to
552c928
Compare
/run-all-tests |
1 similar comment
/run-all-tests |
Coverage for changed files
Coverage summary
full coverage report (for internal network access only) |
/rebuild |
c497894
to
31bc734
Compare
31bc734
to
602639b
Compare
Signed-off-by: RinChanNOWWW <rinchannow@bupt.edu.cn>
Signed-off-by: RinChanNOWWW <rinchannow@bupt.edu.cn>
Signed-off-by: RinChanNOWWW <rinchannow@bupt.edu.cn>
Signed-off-by: RinChanNOWWW <rinchannow@bupt.edu.cn>
Signed-off-by: RinChanNOWWW <rinchannow@bupt.edu.cn>
602639b
to
75a2fe2
Compare
/run-all-tests |
Coverage for changed files
Coverage summary
full coverage report (for internal network access only) |
@@ -467,6 +474,13 @@ class AggregateFunctionNullUnary final : public AggregateFunctionNullBase<result | |||
arena, | |||
if_argument_pos); | |||
|
|||
if (const String & nested_func_name = this->nested_function->getName(); nested_func_name == "groupBitOr" || nested_func_name == "groupBitAnd" || nested_func_name == "groupBitXor") |
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.
Can we use if constexpr (result_is_nullable)
?
if (!column->isNullAt(row_num)) | ||
{ | ||
this->setFlag(place); | ||
const IColumn * nested_column = &column->getNestedColumn(); | ||
this->nested_function->add(this->nestedPlace(place), &nested_column, row_num, arena); | ||
} | ||
else if (const String & nested_func_name = this->nested_function->getName(); nested_func_name == "groupBitOr" || nested_func_name == "groupBitAnd" || nested_func_name == "groupBitXor") |
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.
Can we use if constexpr (result_is_nullable)
?
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.
I don't know if it is right for non-bitwise functions.
// Bitwise operations can only be applied to integer types. | ||
// So we need to cast the argument to UInt64. |
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.
why we need to add cast here?
Didn't tidb add a cast here?
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.
No, TiDB didn't. We compute the result in TiFlash, so we should cast in TiFlash.
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.
It seems tidb does type cast during operator execution phase.
https://github.com/pingcap/tidb/blob/bce6901705cde161451c0bd707a07ecfac0c7578/expression/aggregation/bit_or.go#L37-L56. This behavior is kind of similar to non-agg bitwise function. I think we might have two choice
- also do type cast during operator execution phase instead of appending cast beforehand
- do the same as non-agg bitwise function, i.e. appending cast in advance
tiflash/dbms/src/Flash/Coprocessor/DAGExpressionAnalyzerHelper.cpp
Lines 326 to 357 in bcb029e
String DAGExpressionAnalyzerHelper::buildBitwiseFunction( | |
DAGExpressionAnalyzer * analyzer, | |
const tipb::Expr & expr, | |
const ExpressionActionsPtr & actions) | |
{ | |
const String & func_name = getFunctionName(expr); | |
Names argument_names; | |
// We should convert arguments to UInt64. | |
// See https://github.com/pingcap/tics/issues/1756 | |
DataTypePtr uint64_type = std::make_shared<DataTypeUInt64>(); | |
const Block & sample_block = actions->getSampleBlock(); | |
for (const auto & child : expr.children()) | |
{ | |
String name = analyzer->getActions(child, actions); | |
DataTypePtr orig_type = sample_block.getByName(name).type; | |
// Bump argument type | |
if (!removeNullable(orig_type)->equals(*uint64_type)) | |
{ | |
if (orig_type->isNullable()) | |
{ | |
name = analyzer->appendCast(makeNullable(uint64_type), actions, name); | |
} | |
else | |
{ | |
name = analyzer->appendCast(uint64_type, actions, name); | |
} | |
} | |
argument_names.push_back(name); | |
} | |
return analyzer->applyFunction(func_name, argument_names, actions, nullptr); | |
} |
However, I think current comment is not accurate. TiDB always pushes integer types to tiflash. The reason why we append a cast, or do type cast in execution phase, is because mysql (prior to 8.0) handle only unsigned 64-bit integer argument and result values.
ref: https://dev.mysql.com/doc/refman/8.0/en/bit-functions.html
Signed-off-by: hezheyu rinchannow@bupt.edu.cn
What problem does this PR solve?
Issue Number: close #5118
Problem Summary:
What is changed and how it works?
Apply
CAST
function to the bitwise aggregation functions' children exprs to make ordinary Clickhouse functions be able to work.Check List
Tests
Release note