planOtherTest.cpp 1.9 KB
Newer Older
X
Xiaoyu Wang 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
/*
 * 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;

21
class PlanOtherTest : public PlannerTestBase {};
X
Xiaoyu Wang 已提交
22

23
TEST_F(PlanOtherTest, createTopic) {
X
Xiaoyu Wang 已提交
24 25
  useDb("root", "test");

26
  run("create topic tp as SELECT * FROM st1");
X
Xiaoyu Wang 已提交
27
}
28 29 30 31 32 33 34 35

TEST_F(PlanOtherTest, createStream) {
  useDb("root", "test");

  run("create stream if not exists s1 trigger window_close watermark 10s into st1 as select count(*) from t1 "
      "interval(10s)");
}

36 37 38 39 40 41
TEST_F(PlanOtherTest, createStreamUseSTable) {
  useDb("root", "test");

  run("create stream if not exists s1 as select count(*) from st1 interval(10s)");
}

42 43 44 45 46 47 48 49 50 51 52 53 54 55
TEST_F(PlanOtherTest, createSmaIndex) {
  useDb("root", "test");

  run("create sma index index1 on t1 function(max(c1), min(c3 + 10), sum(c4)) interval(10s)");
}

TEST_F(PlanOtherTest, explain) {
  useDb("root", "test");

  run("explain SELECT * FROM t1");

  run("explain analyze SELECT * FROM t1");

  run("explain analyze verbose true ratio 0.01 SELECT * FROM t1");
X
Xiaoyu Wang 已提交
56 57 58 59 60 61 62
}

TEST_F(PlanOtherTest, show) {
  useDb("root", "test");

  run("SHOW DATABASES");
}
X
Xiaoyu Wang 已提交
63 64 65 66 67 68 69 70 71 72 73 74

TEST_F(PlanOtherTest, delete) {
  useDb("root", "test");

  run("DELETE FROM t1");

  run("DELETE FROM t1 WHERE ts > now - 2d and ts < now - 1d");

  run("DELETE FROM st1");

  run("DELETE FROM st1 WHERE ts > now - 2d and ts < now - 1d AND tag1 = 10");
}