forked from pingcap/tiflash
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement Space function push down pingcap#5113
- Loading branch information
1 parent
73e708c
commit 4275ae2
Showing
4 changed files
with
181 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
// Copyright 2022 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 <Columns/ColumnString.h> | ||
#include <Columns/ColumnsNumber.h> | ||
#include <DataTypes/DataTypeNullable.h> | ||
#include <DataTypes/DataTypesNumber.h> | ||
#include <Functions/FunctionFactory.h> | ||
#include <Functions/FunctionsString.h> | ||
#include <Interpreters/Context.h> | ||
#include <TestUtils/FunctionTestUtils.h> | ||
#include <TestUtils/TiFlashTestBasic.h> | ||
|
||
#include <string> | ||
#include <vector> | ||
|
||
#pragma GCC diagnostic push | ||
#pragma GCC diagnostic ignored "-Wsign-compare" | ||
#include <Poco/Types.h> | ||
|
||
#pragma GCC diagnostic pop | ||
|
||
namespace DB | ||
{ | ||
namespace tests | ||
{ | ||
class StringSpace : public DB::tests::FunctionTest | ||
{ | ||
public: | ||
static constexpr auto func_name = "space"; | ||
|
||
protected: | ||
ColumnWithTypeAndName toVec(const std::vector<std::optional<String>> & v) | ||
{ | ||
return createColumn<Nullable<String>>(v); | ||
} | ||
}; | ||
|
||
// test string and string | ||
TEST_F(StringReverse, strAndStrTest) | ||
try | ||
{ | ||
ASSERT_COLUMN_EQ( | ||
toVec({" ", "", " "}), | ||
executeFunction( | ||
func_name, | ||
toVec({2, 0, 10}) | ||
)); | ||
} | ||
CATCH | ||
|
||
// test NULL | ||
TEST_F(StringLength, nullTest) | ||
{ | ||
ASSERT_COLUMN_EQ( | ||
toVec({"", {}}), | ||
executeFunction( | ||
func_name, | ||
toVec({"", {}}))); | ||
} | ||
|
||
} // 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
# Copyright 2022 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 if not exists test.t(a char(20), b int, c double); | ||
|
||
mysql> insert into test.t values('www.pingcap.com', 12345, 123.45); | ||
mysql> alter table test.t set tiflash replica 1; | ||
func> wait_table test t | ||
|
||
mysql> set tidb_enforce_mpp=1; set tidb_isolation_read_engines='tiflash'; select space(40) from test.t; | ||
+------------------------------------------+ | ||
| space(40) | | ||
+------------------------------------------+ | ||
| | | ||
| | | ||
| | | ||
+------------------------------------------+ | ||
|
||
|
||
mysql> select space('') from test.t; | ||
+-----------+ | ||
| space('') | | ||
+-----------+ | ||
| | | ||
| | | ||
| | | ||
+-----------+ | ||
|
||
mysql> select space(NULL) from test.t; | ||
+-------------+ | ||
| space(NULL) | | ||
+-------------+ | ||
| NULL | | ||
| NULL | | ||
| NULL | | ||
+-------------+ | ||
|
||
mysql> explain select space(40) from test.t; | ||
+---------------------------+---------+--------------+---------------+----------------------------------------------------+ | ||
| id | estRows | task | access object | operator info | | ||
+---------------------------+---------+--------------+---------------+----------------------------------------------------+ | ||
| TableReader_9 | 3.00 | root | | data:ExchangeSender_8 | | ||
| └─ExchangeSender_8 | 3.00 | mpp[tiflash] | | ExchangeType: PassThrough | | ||
| └─Projection_4 | 3.00 | mpp[tiflash] | | ->Column#3 | | ||
| └─TableFullScan_7 | 3.00 | mpp[tiflash] | table:t | keep order:false, stats:pseudo | | ||
+---------------------------+---------+--------------+---------------+----------------------------------------------------+ | ||
|