2022-04-24 10:05:28 +00:00
|
|
|
/*
|
|
|
|
|
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
|
|
|
|
|
*
|
|
|
|
|
* This program is free software: you can use, redistribute, and/or modify
|
|
|
|
|
* it under the terms of the GNU Affero General Public License, version 3
|
|
|
|
|
* or later ("AGPL"), as published by the Free Software Foundation.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
|
|
|
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU Affero General Public License
|
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include "planTestUtil.h"
|
|
|
|
|
#include "planner.h"
|
|
|
|
|
|
|
|
|
|
using namespace std;
|
|
|
|
|
|
2022-04-26 03:50:35 +00:00
|
|
|
class PlanOptimizeTest : public PlannerTestBase {};
|
2022-04-24 10:05:28 +00:00
|
|
|
|
2022-05-06 09:52:59 +00:00
|
|
|
TEST_F(PlanOptimizeTest, optimizeScanData) {
|
|
|
|
|
useDb("root", "test");
|
|
|
|
|
|
|
|
|
|
run("SELECT COUNT(*) FROM t1");
|
|
|
|
|
|
|
|
|
|
run("SELECT COUNT(c1) FROM t1");
|
|
|
|
|
|
|
|
|
|
run("SELECT COUNT(CAST(c1 AS BIGINT)) FROM t1");
|
2022-05-12 09:17:02 +00:00
|
|
|
|
|
|
|
|
run("SELECT PERCENTILE(c1, 40), COUNT(*) FROM t1");
|
2022-05-06 09:52:59 +00:00
|
|
|
}
|
|
|
|
|
|
2022-05-23 11:50:08 +00:00
|
|
|
TEST_F(PlanOptimizeTest, ConditionPushDown) {
|
|
|
|
|
useDb("root", "test");
|
|
|
|
|
|
|
|
|
|
run("SELECT ts, c1 FROM st1 WHERE tag1 > 4");
|
|
|
|
|
}
|
|
|
|
|
|
2022-04-24 10:05:28 +00:00
|
|
|
TEST_F(PlanOptimizeTest, orderByPrimaryKey) {
|
|
|
|
|
useDb("root", "test");
|
|
|
|
|
|
2022-05-06 09:52:59 +00:00
|
|
|
run("SELECT * FROM t1 ORDER BY ts");
|
|
|
|
|
run("SELECT * FROM t1 ORDER BY ts DESC");
|
|
|
|
|
run("SELECT c1 FROM t1 ORDER BY ts");
|
|
|
|
|
run("SELECT c1 FROM t1 ORDER BY ts DESC");
|
2022-05-09 12:20:05 +00:00
|
|
|
|
|
|
|
|
run("SELECT COUNT(*) FROM t1 INTERVAL(10S) ORDER BY _WSTARTTS DESC");
|
2022-04-24 10:05:28 +00:00
|
|
|
}
|