-
Notifications
You must be signed in to change notification settings - Fork 412
filter column must be uint8 in tiflash #180
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
Merged
Merged
Changes from 13 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
6ae41fe
add all scalar function sig in scalarFunMap
windtalker 9fe7bb6
fix literal expr decode
windtalker 2eb5966
merge pingcap/tics cop
windtalker 76903f5
enable ltrim && rtrim
windtalker 06d762f
code refine
windtalker 11af01b
use throw instead of rethrow in DAGDriver.cpp
windtalker 1d8b0f2
Merge branch 'cop' of https://github.com/pingcap/tics into new_cop
windtalker de9b338
1. fix decode UInt literal error, 2. support mysqlDecimal type
windtalker 448b1e3
format code
windtalker a584cff
merge pingcap/tics cop
windtalker a51513d
filter column must be uint8 in tiflash
windtalker a8f3611
address comments
windtalker b4a217f
address comments
windtalker f1c80cb
address comments
windtalker 94b9da8
remove useless include
windtalker File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,10 @@ | |
|
||
#include <AggregateFunctions/AggregateFunctionFactory.h> | ||
#include <Columns/ColumnSet.h> | ||
#include <Common/typeid_cast.h> | ||
#include <DataTypes/DataTypeNullable.h> | ||
#include <DataTypes/DataTypeSet.h> | ||
#include <DataTypes/DataTypesNumber.h> | ||
#include <DataTypes/FieldToDataType.h> | ||
#include <Flash/Coprocessor/DAGUtils.h> | ||
#include <Functions/FunctionFactory.h> | ||
|
@@ -103,6 +106,23 @@ void DAGExpressionAnalyzer::appendAggregation( | |
after_agg = true; | ||
} | ||
|
||
bool isUInt8Type(const DataTypePtr & type) | ||
{ | ||
if (typeid_cast<const DataTypeUInt8 *>(type.get())) | ||
zanmato1984 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
{ | ||
return true; | ||
} | ||
if (type->isNullable()) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I suggest write this function like:
It's shorter. |
||
{ | ||
auto * nullable = typeid_cast<const DataTypeNullable *>(type.get()); | ||
if (typeid_cast<const DataTypeUInt8 *>(nullable->getNestedType().get())) | ||
{ | ||
return true; | ||
} | ||
} | ||
return false; | ||
} | ||
|
||
void DAGExpressionAnalyzer::appendWhere(ExpressionActionsChain & chain, const tipb::Selection & sel, String & filter_column_name) | ||
{ | ||
if (sel.conditions_size() == 0) | ||
|
@@ -124,7 +144,24 @@ void DAGExpressionAnalyzer::appendWhere(ExpressionActionsChain & chain, const ti | |
|
||
const tipb::Expr & filter = sel.conditions_size() > 1 ? final_condition : sel.conditions(0); | ||
initChain(chain, getCurrentInputColumns()); | ||
filter_column_name = getActions(filter, chain.steps.back().actions); | ||
ExpressionActionsChain::Step & last_step = chain.steps.back(); | ||
filter_column_name = getActions(filter, last_step.actions); | ||
auto & filter_column_type = chain.steps.back().actions->getSampleBlock().getByName(filter_column_name).type; | ||
if (!isUInt8Type(filter_column_type)) | ||
{ | ||
// find the original unit8 column | ||
auto & last_actions = last_step.actions->getActions(); | ||
for (auto it = last_actions.rbegin(); it != last_actions.rend(); ++it) | ||
zanmato1984 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
{ | ||
if (it->type == ExpressionAction::Type::APPLY_FUNCTION && it->result_name == filter_column_name | ||
&& it->function->getName() == "CAST") | ||
{ | ||
// for cast function, the casted column is the first argument | ||
filter_column_name = it->argument_names[0]; | ||
break; | ||
} | ||
} | ||
} | ||
chain.steps.back().required_output.push_back(filter_column_name); | ||
} | ||
|
||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Useless include?