Skip to content
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 push down instr function to tiflash #6081

Open
wants to merge 36 commits into
base: master
Choose a base branch
from

Conversation

lizhenhuan
Copy link
Contributor

@lizhenhuan lizhenhuan commented Oct 6, 2022

What problem does this PR solve?

Issue Number: close #5109

Related PR:pingcap/tidb#35753

Problem Summary:Implement instr function push down to tiflash
Related PR:pingcap/tidb#38309

What is changed and how it works?

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)
  • No code

Side effects

  • Performance regression: Consumes more CPU
  • Performance regression: Consumes more Memory
  • Breaking backward compatibility

Documentation

  • Affects user behaviors
  • Contains syntax changes
  • Contains variable changes
  • Contains experimental features
  • Changes MySQL compatibility

Release note

Implement push down instr function to tiflash 

@ti-chi-bot
Copy link
Member

ti-chi-bot commented Oct 6, 2022

[REVIEW NOTIFICATION]

This pull request has been approved by:

  • ywqzzy

To complete the pull request process, please ask the reviewers in the list to review by filling /cc @reviewer in the comment.
After your PR has acquired the required number of LGTMs, you can assign this pull request to the committer in the list by filling /assign @committer in the comment to help you merge this pull request.

The full list of commands accepted by this bot can be found here.

Reviewer can indicate their review by submitting an approval review.
Reviewer can cancel approval by submitting a request changes review.

@ti-chi-bot ti-chi-bot added release-note Denotes a PR that will be considered when it comes time to generate release notes. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Oct 6, 2022
@lizhenhuan
Copy link
Contributor Author

/run-all-tests

@sre-bot
Copy link
Collaborator

sre-bot commented Oct 6, 2022

Coverage for changed files

Filename                                   Regions    Missed Regions     Cover   Functions  Missed Functions  Executed       Lines      Missed Lines     Cover    Branches   Missed Branches     Cover
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Flash/Coprocessor/DAGUtils.cpp                 347               124    64.27%          45                 6    86.67%         638               240    62.38%         412               158    61.65%
Functions/FunctionsString.cpp                 1616               396    75.50%         306                76    75.16%        3456               822    76.22%        1002               331    66.97%
Functions/tests/gtest_string_instr.cpp          29                15    48.28%           5                 1    80.00%          41                 3    92.68%           8                 8     0.00%
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
TOTAL                                         1992               535    73.14%         356                83    76.69%        4135              1065    74.24%        1422               497    65.05%

Coverage summary

Functions  MissedFunctions  Executed  Lines   MissedLines  Cover
18404      7486             59.32%    215439  77119        64.20%

full coverage report (for internal network access only)

@lizhenhuan
Copy link
Contributor Author

/run-all-tests

Signed-off-by: lizhenhuan <1916038084@qq.com>
@sre-bot
Copy link
Collaborator

sre-bot commented Oct 8, 2022

Coverage for changed files

Filename                                   Regions    Missed Regions     Cover   Functions  Missed Functions  Executed       Lines      Missed Lines     Cover    Branches   Missed Branches     Cover
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Flash/Coprocessor/DAGUtils.cpp                 347               124    64.27%          45                 6    86.67%         638               240    62.38%         412               158    61.65%
Functions/FunctionsString.cpp                 1616               396    75.50%         306                76    75.16%        3456               822    76.22%        1002               331    66.97%
Functions/tests/gtest_string_instr.cpp          29                15    48.28%           5                 1    80.00%          41                 3    92.68%           8                 8     0.00%
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
TOTAL                                         1992               535    73.14%         356                83    76.69%        4135              1065    74.24%        1422               497    65.05%

Coverage summary

Functions  MissedFunctions  Executed  Lines   MissedLines  Cover
18404      7486             59.32%    215439  77065        64.23%

full coverage report (for internal network access only)

Signed-off-by: lizhenhuan <1916038084@qq.com>
Signed-off-by: lizhenhuan <1916038084@qq.com>
Signed-off-by: lizhenhuan <1916038084@qq.com>
@lizhenhuan
Copy link
Contributor Author

/run-all-tests

Signed-off-by: lizhenhuan <1916038084@qq.com>
@lizhenhuan
Copy link
Contributor Author

/run-all-tests

Signed-off-by: lizhenhuan <1916038084@qq.com>
@lizhenhuan
Copy link
Contributor Author

/run-all-tests

2 similar comments
@lizhenhuan
Copy link
Contributor Author

/run-all-tests

@lizhenhuan
Copy link
Contributor Author

/run-all-tests

@lizhenhuan
Copy link
Contributor Author

/run-build

1 similar comment
@lizhenhuan
Copy link
Contributor Author

/run-build

@lizhenhuan
Copy link
Contributor Author

/run-integration-test

@lizhenhuan
Copy link
Contributor Author

/build

dbms/src/Functions/FunctionsString.cpp Outdated Show resolved Hide resolved
dbms/src/Functions/FunctionsString.cpp Outdated Show resolved Hide resolved
dbms/src/Functions/FunctionsString.cpp Outdated Show resolved Hide resolved
dbms/src/Functions/FunctionsString.cpp Outdated Show resolved Hide resolved
dbms/src/Functions/FunctionsString.cpp Outdated Show resolved Hide resolved
dbms/src/Functions/FunctionsString.cpp Outdated Show resolved Hide resolved
Signed-off-by: lizhenhuan <1916038084@qq.com>
Signed-off-by: lizhenhuan <1916038084@qq.com>
@lizhenhuan
Copy link
Contributor Author

/run-all-tests

@xzhangxian1008
Copy link
Contributor

LGTM

@lizhenhuan
Copy link
Contributor Author

/run-all-tests

@ti-chi-bot ti-chi-bot added the status/LGT1 Indicates that a PR has LGTM 1. label Oct 31, 2022
Signed-off-by: lizhenhuan <1916038084@qq.com>
@lizhenhuan
Copy link
Contributor Author

/run-all-tests

dbms/src/Functions/FunctionsString.cpp Outdated Show resolved Hide resolved
dbms/src/Functions/FunctionsString.cpp Outdated Show resolved Hide resolved
dbms/src/Functions/FunctionsString.cpp Outdated Show resolved Hide resolved
Signed-off-by: lizhenhuan <1916038084@qq.com>
@lizhenhuan
Copy link
Contributor Author

/run-all-tests

Comment on lines +4430 to +4436
const auto * substr_const_string = checkAndGetColumnConst<ColumnString>(c1_col_column.get());
if (!substr_const_string)
{
const auto * substr_vector_string = checkAndGetColumn<ColumnString>(c1_col_column.get());
const auto * str_const_string_value = checkAndGetColumn<ColumnString>(str_const_string->getDataColumnPtr().get());
constVector(str_const_string_value->getChars(), str_const_string_value->getOffsets(), substr_vector_string->getChars(), substr_vector_string->getOffsets(), val_num, res_vec);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const auto * substr_const_string = checkAndGetColumnConst<ColumnString>(c1_col_column.get());
if (!substr_const_string)
{
const auto * substr_vector_string = checkAndGetColumn<ColumnString>(c1_col_column.get());
const auto * str_const_string_value = checkAndGetColumn<ColumnString>(str_const_string->getDataColumnPtr().get());
constVector(str_const_string_value->getChars(), str_const_string_value->getOffsets(), substr_vector_string->getChars(), substr_vector_string->getOffsets(), val_num, res_vec);
}
if (const auto * substr_vector_string = checkAndGetColumn<ColumnString>(c1_col_column.get()))
{
const auto * str_const_string_value = checkAndGetColumn<ColumnString>(str_const_string->getDataColumnPtr().get());
constVector(str_const_string_value->getChars(), str_const_string_value->getOffsets(), substr_vector_string->getChars(), substr_vector_string->getOffsets(), val_num, res_vec);
}
else
throw Exception(
fmt::format("Illegal column {} of argument of function {}", c1_col_column->getName(), getName()),
ErrorCodes::ILLEGAL_COLUMN);

Comment on lines +4611 to +4617
const auto * substr_const_string = checkAndGetColumnConst<ColumnString>(c1_col_column.get());
if (!substr_const_string)
{
const auto * substr_vector_string = checkAndGetColumn<ColumnString>(c1_col_column.get());
const auto * str_const_string_value = checkAndGetColumn<ColumnString>(str_const_string->getDataColumnPtr().get());
constVector(str_const_string_value->getChars(), str_const_string_value->getOffsets(), substr_vector_string->getChars(), substr_vector_string->getOffsets(), val_num, res_vec);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const auto * substr_const_string = checkAndGetColumnConst<ColumnString>(c1_col_column.get());
if (!substr_const_string)
{
const auto * substr_vector_string = checkAndGetColumn<ColumnString>(c1_col_column.get());
const auto * str_const_string_value = checkAndGetColumn<ColumnString>(str_const_string->getDataColumnPtr().get());
constVector(str_const_string_value->getChars(), str_const_string_value->getOffsets(), substr_vector_string->getChars(), substr_vector_string->getOffsets(), val_num, res_vec);
}
if (const auto * substr_vector_string = checkAndGetColumn<ColumnString>(c1_col_column.get()))
{
const auto * str_const_string_value = checkAndGetColumn<ColumnString>(str_const_string->getDataColumnPtr().get());
constVector(str_const_string_value->getChars(), str_const_string_value->getOffsets(), substr_vector_string->getChars(), substr_vector_string->getOffsets(), val_num, res_vec);
}
else
throw Exception(
fmt::format("Illegal column {} of argument of function {}", c1_col_column->getName(), getName()),
ErrorCodes::ILLEGAL_COLUMN);

}

private:
static Int64 find(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like we can use Volnitsky directly.
#include <Common/Volnitsky.h>
Ref

class FunctionSubStringIndex : public IFunction

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release-note Denotes a PR that will be considered when it comes time to generate release notes. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. status/LGT1 Indicates that a PR has LGTM 1.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implement InstrUTF8/Instr function push down
8 participants