-
Notifications
You must be signed in to change notification settings - Fork 409
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
support scan concurrency hint for mock table (#6591)
ref #6528
- Loading branch information
1 parent
3350580
commit 20c5a07
Showing
12 changed files
with
186 additions
and
50 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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 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 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 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 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,81 @@ | ||
// 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. | ||
|
||
#include <TestUtils/ExecutorTestUtils.h> | ||
|
||
#include <ext/enumerate.h> | ||
#include <tuple> | ||
|
||
namespace DB | ||
{ | ||
namespace tests | ||
{ | ||
class ScanConcurrencyHintTest : public DB::tests::ExecutorTest | ||
{ | ||
public: | ||
void initializeContext() override | ||
{ | ||
ExecutorTest::initializeContext(); | ||
} | ||
}; | ||
|
||
TEST_F(ScanConcurrencyHintTest, InvalidHint) | ||
try | ||
{ | ||
context.addMockTable("simple_test", "t1", {{"a", TiDB::TP::TypeString}, {"b", TiDB::TP::TypeString}}, {toNullableVec<String>("a", {"1", "2", {}, "1", {}}), toNullableVec<String>("b", {"3", "4", "3", {}, {}})}, 0); | ||
auto request = context.scan("simple_test", "t1").build(context); | ||
{ | ||
/// the scan concurrency hint is invalid, the final stream concurrency is the original concurrency | ||
String expected = R"( | ||
Union: <for test> | ||
Expression x 10: <final projection> | ||
MockTableScan)"; | ||
ASSERT_BLOCKINPUTSTREAM_EQAUL(expected, request, 10); | ||
} | ||
} | ||
CATCH | ||
|
||
TEST_F(ScanConcurrencyHintTest, ValidHint) | ||
try | ||
{ | ||
context.addMockTable("simple_test", "t1", {{"a", TiDB::TP::TypeString}, {"b", TiDB::TP::TypeString}}, {toNullableVec<String>("a", {"1", "2", {}, "1", {}}), toNullableVec<String>("b", {"3", "4", "3", {}, {}})}, 3); | ||
auto request = context.scan("simple_test", "t1").build(context); | ||
{ | ||
/// case 1, concurrency < scan concurrency hint, the final stream concurrency is the original concurrency | ||
String expected = R"( | ||
Expression: <final projection> | ||
MockTableScan)"; | ||
ASSERT_BLOCKINPUTSTREAM_EQAUL(expected, request, 1); | ||
} | ||
{ | ||
/// case 2, concurrency = scan concurrency hint, the final stream concurrency is the original concurrency | ||
String expected = R"( | ||
Union: <for test> | ||
Expression x 3: <final projection> | ||
MockTableScan)"; | ||
ASSERT_BLOCKINPUTSTREAM_EQAUL(expected, request, 3); | ||
} | ||
{ | ||
/// case 3, concurrency > scan concurrency hint, the final stream concurrency is the scan concurrency hint | ||
String expected = R"( | ||
Union: <for test> | ||
Expression x 3: <final projection> | ||
MockTableScan)"; | ||
ASSERT_BLOCKINPUTSTREAM_EQAUL(expected, request, 10); | ||
} | ||
} | ||
CATCH | ||
|
||
} // namespace tests | ||
} // namespace DB |
This file contains 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 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
Oops, something went wrong.