-
Notifications
You must be signed in to change notification settings - Fork 415
add GeneratedColumnPlaceholderInputStream #6796
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 all commits
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
ade7a44
add GeneratedColumnPlaceholderInputStream
guo-shaoge b58875e
clear gtest change
guo-shaoge fddbabe
fix log
guo-shaoge 93a4c11
add case
guo-shaoge a6daf46
least/greatest function for string (#6662)
ywqzzy 5b033a1
fix tls ipv6 metric (#6736)
ywqzzy 6a1bee4
Refine spiller (#6780)
windtalker 9f8724e
remove legacy code in RegionPersister (#6781)
lidezhu 3e8ce03
fix RegionKVStoreTest (#6768)
flowbehappy 8981dfa
Collect request unit for tiflash compute (#6649)
SeaRise c6493d4
Remove useless IDAsPathUpgrader (#6782)
JaySon-Huang 76e725e
fix tsan fail in unit test `JoinExecutorTestRunner.MultiJoin` (#6770)
SeaRise c5ea678
Refine the hostname backlist in `MetricsPrometheus` (#6784)
SeaRise 0d25d4d
Add more information to the error message in MPPTunnel (#6787)
windtalker 206b807
fix the issue that decimal divide not round. (#6471)
LittleFall ff2949f
Refine the spill threshold for aggregation/sort, refine the memory us…
windtalker 8de0167
fix format
guo-shaoge 8eb8ab7
Merge branch 'master' into gen_col_placeholder
guo-shaoge c204038
trivial fix
guo-shaoge 9ca51bc
fix nullable column bug
guo-shaoge 79d7ec1
fix fmt
guo-shaoge f1bb9e4
fix remote stream
guo-shaoge 22bd4f7
Merge branch 'master' into gen_col_placeholder
guo-shaoge 2c24e58
add getGeneratedColumnInfos
guo-shaoge ec1914d
del getGeneratedColumnInfos
guo-shaoge 53dbdef
Merge branch 'master' into gen_col_placeholder
ti-chi-bot 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
97 changes: 97 additions & 0 deletions
97
dbms/src/DataStreams/GeneratedColumnPlaceholderBlockInputStream.h
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 |
|---|---|---|
| @@ -0,0 +1,97 @@ | ||
| // Copyright 2023 PingCAP, Ltd. | ||
| // | ||
| // Licensed under the Apache License, Version 2.0 (the "License"); | ||
| // you may not use this file except in compliance with the License. | ||
| // You may obtain a copy of the License at | ||
| // | ||
| // http://www.apache.org/licenses/LICENSE-2.0 | ||
| // | ||
| // Unless required by applicable law or agreed to in writing, software | ||
| // distributed under the License is distributed on an "AS IS" BASIS, | ||
| // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| // See the License for the specific language governing permissions and | ||
| // limitations under the License. | ||
|
|
||
| #pragma once | ||
|
|
||
| #include <Columns/ColumnNullable.h> | ||
| #include <Columns/ColumnString.h> | ||
| #include <Columns/ColumnsNumber.h> | ||
| #include <Core/ColumnsWithTypeAndName.h> | ||
| #include <DataStreams/IProfilingBlockInputStream.h> | ||
| #include <DataTypes/DataTypeNullable.h> | ||
| #include <DataTypes/DataTypeString.h> | ||
| #include <Flash/Coprocessor/TiDBTableScan.h> | ||
|
|
||
| namespace DB | ||
| { | ||
| class GeneratedColumnPlaceholderBlockInputStream : public IProfilingBlockInputStream | ||
| { | ||
| public: | ||
| GeneratedColumnPlaceholderBlockInputStream( | ||
| const BlockInputStreamPtr & input, | ||
| const std::vector<std::tuple<UInt64, String, DataTypePtr>> & generated_column_infos_, | ||
| const String & req_id_) | ||
| : generated_column_infos(generated_column_infos_) | ||
| , log(Logger::get(req_id_)) | ||
| { | ||
| children.push_back(input); | ||
| } | ||
|
|
||
| String getName() const override { return NAME; } | ||
| Block getHeader() const override | ||
| { | ||
| Block block = children.back()->getHeader(); | ||
| insertColumns(block, /*insert_data=*/false); | ||
| return block; | ||
| } | ||
|
|
||
| static String getColumnName(UInt64 col_index) | ||
| { | ||
| return "generated_column_" + std::to_string(col_index); | ||
| } | ||
|
|
||
| protected: | ||
| void readPrefix() override | ||
| { | ||
| RUNTIME_CHECK(!generated_column_infos.empty()); | ||
| // Validation check. | ||
| for (size_t i = 1; i < generated_column_infos.size(); ++i) | ||
| { | ||
| RUNTIME_CHECK(std::get<0>(generated_column_infos[i]) > std::get<0>(generated_column_infos[i - 1])); | ||
| } | ||
| } | ||
|
|
||
| Block readImpl() override | ||
| { | ||
| Block block = children.back()->read(); | ||
| insertColumns(block, /*insert_data=*/true); | ||
| return block; | ||
| } | ||
|
|
||
| private: | ||
| void insertColumns(Block & block, bool insert_data) const | ||
| { | ||
| if (!block) | ||
| return; | ||
|
|
||
| for (const auto & ele : generated_column_infos) | ||
| { | ||
| const auto & col_index = std::get<0>(ele); | ||
| const auto & col_name = std::get<1>(ele); | ||
| const auto & data_type = std::get<2>(ele); | ||
| ColumnPtr column = nullptr; | ||
| if (insert_data) | ||
| column = data_type->createColumnConstWithDefaultValue(block.rows()); | ||
| else | ||
| column = data_type->createColumn(); | ||
| block.insert(col_index, ColumnWithTypeAndName{column, data_type, col_name}); | ||
| } | ||
| } | ||
|
|
||
| static constexpr auto NAME = "GeneratedColumnPlaceholder"; | ||
| const std::vector<std::tuple<UInt64, String, DataTypePtr>> generated_column_infos; | ||
| const LoggerPtr log; | ||
| }; | ||
|
|
||
| } // namespace DB |
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
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
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
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
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
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
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
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 |
|---|---|---|
| @@ -0,0 +1,147 @@ | ||
| # Copyright 2023 PingCAP, Ltd. | ||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
|
|
||
| mysql> drop table if exists test.t; | ||
| mysql> create table test.t(c1 varchar(100), c2 varchar(100)); | ||
| mysql> insert into test.t values('ABC', 'DEF'); | ||
| mysql> alter table test.t set tiflash replica 1; | ||
| func> wait_table test t | ||
| mysql> alter table test.t add index idx2((lower(c2))); | ||
|
|
||
| mysql> select /*+ nth_plan(1) */ * from test.t where lower(test.t.c2) = 'def'; | ||
| +------+------+ | ||
| | c1 | c2 | | ||
| +------+------+ | ||
| | ABC | DEF | | ||
| +------+------+ | ||
| mysql> select /*+ nth_plan(2) */ * from test.t where lower(test.t.c2) = 'def'; | ||
| +------+------+ | ||
| | c1 | c2 | | ||
| +------+------+ | ||
| | ABC | DEF | | ||
| +------+------+ | ||
| mysql> select /*+ nth_plan(3) */ * from test.t where lower(test.t.c2) = 'def'; | ||
| +------+------+ | ||
| | c1 | c2 | | ||
| +------+------+ | ||
| | ABC | DEF | | ||
| +------+------+ | ||
| mysql> select /*+ nth_plan(4) */ * from test.t where lower(test.t.c2) = 'def'; | ||
| +------+------+ | ||
| | c1 | c2 | | ||
| +------+------+ | ||
| | ABC | DEF | | ||
| +------+------+ | ||
| mysql> select /*+ nth_plan(5) */ * from test.t where lower(test.t.c2) = 'def'; | ||
| +------+------+ | ||
| | c1 | c2 | | ||
| +------+------+ | ||
| | ABC | DEF | | ||
| +------+------+ | ||
| mysql> select /*+ nth_plan(6) */ * from test.t where lower(test.t.c2) = 'def'; | ||
| +------+------+ | ||
| | c1 | c2 | | ||
| +------+------+ | ||
| | ABC | DEF | | ||
| +------+------+ | ||
| mysql> select /*+ nth_plan(7) */ * from test.t where lower(test.t.c2) = 'def'; | ||
| +------+------+ | ||
| | c1 | c2 | | ||
| +------+------+ | ||
| | ABC | DEF | | ||
| +------+------+ | ||
| mysql> select /*+ nth_plan(8) */ * from test.t where lower(test.t.c2) = 'def'; | ||
| +------+------+ | ||
| | c1 | c2 | | ||
| +------+------+ | ||
| | ABC | DEF | | ||
| +------+------+ | ||
| mysql> select /*+ nth_plan(9) */ * from test.t where lower(test.t.c2) = 'def'; | ||
| +------+------+ | ||
| | c1 | c2 | | ||
| +------+------+ | ||
| | ABC | DEF | | ||
| +------+------+ | ||
| mysql> select /*+ nth_plan(10) */ * from test.t where lower(test.t.c2) = 'def'; | ||
| +------+------+ | ||
| | c1 | c2 | | ||
| +------+------+ | ||
| | ABC | DEF | | ||
| +------+------+ | ||
|
|
||
| mysql> drop table if exists test.t; | ||
| mysql> create table test.t(id int, value int); | ||
| mysql> alter table test.t set tiflash replica 1; | ||
| func> wait_table test t | ||
| mysql> create unique index uk on test.t((tidb_shard(id)), id); | ||
| mysql> select /*+ nth_paln(1) */ max(value) from test.t; | ||
| +------------+ | ||
| | max(value) | | ||
| +------------+ | ||
| | NULL | | ||
| +------------+ | ||
| mysql> select /*+ nth_paln(2) */ max(value) from test.t; | ||
| +------------+ | ||
| | max(value) | | ||
| +------------+ | ||
| | NULL | | ||
| +------------+ | ||
| mysql> select /*+ nth_paln(3) */ max(value) from test.t; | ||
| +------------+ | ||
| | max(value) | | ||
| +------------+ | ||
| | NULL | | ||
| +------------+ | ||
| mysql> select /*+ nth_paln(4) */ max(value) from test.t; | ||
| +------------+ | ||
| | max(value) | | ||
| +------------+ | ||
| | NULL | | ||
| +------------+ | ||
| mysql> select /*+ nth_paln(5) */ max(value) from test.t; | ||
| +------------+ | ||
| | max(value) | | ||
| +------------+ | ||
| | NULL | | ||
| +------------+ | ||
| mysql> select /*+ nth_paln(6) */ max(value) from test.t; | ||
| +------------+ | ||
| | max(value) | | ||
| +------------+ | ||
| | NULL | | ||
| +------------+ | ||
| mysql> select /*+ nth_paln(7) */ max(value) from test.t; | ||
| +------------+ | ||
| | max(value) | | ||
| +------------+ | ||
| | NULL | | ||
| +------------+ | ||
| mysql> select /*+ nth_paln(8) */ max(value) from test.t; | ||
| +------------+ | ||
| | max(value) | | ||
| +------------+ | ||
| | NULL | | ||
| +------------+ | ||
| mysql> select /*+ nth_paln(9) */ max(value) from test.t; | ||
| +------------+ | ||
| | max(value) | | ||
| +------------+ | ||
| | NULL | | ||
| +------------+ | ||
| mysql> select /*+ nth_paln(10) */ max(value) from test.t; | ||
| +------------+ | ||
| | max(value) | | ||
| +------------+ | ||
| | NULL | | ||
| +------------+ |
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.
Uh oh!
There was an error while loading. Please reload this page.