From d87cc3b641981bae95047868d44c7f9b0db9c78b Mon Sep 17 00:00:00 2001 From: Ping Xiao Date: Mon, 7 Jun 2021 18:10:42 +0800 Subject: [PATCH] [TD-4421]: add test case for subquery with filter --- tests/pytest/fulltest.sh | 2 +- tests/pytest/query/subqueryFilter.py | 79 ++++++++++++++++++++++++++++ 2 files changed, 80 insertions(+), 1 deletion(-) create mode 100644 tests/pytest/query/subqueryFilter.py diff --git a/tests/pytest/fulltest.sh b/tests/pytest/fulltest.sh index be920dc1ba..68d7bbefee 100755 --- a/tests/pytest/fulltest.sh +++ b/tests/pytest/fulltest.sh @@ -229,7 +229,7 @@ python3 ./test.py -f query/queryFilterTswithDateUnit.py python3 ./test.py -f query/queryTscomputWithNow.py python3 ./test.py -f query/computeErrorinWhere.py python3 ./test.py -f query/queryTsisNull.py - +python3 ./test.py -f query/subqueryFilter.py #stream diff --git a/tests/pytest/query/subqueryFilter.py b/tests/pytest/query/subqueryFilter.py new file mode 100644 index 0000000000..1e111360e2 --- /dev/null +++ b/tests/pytest/query/subqueryFilter.py @@ -0,0 +1,79 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import taos +from util.log import tdLog +from util.cases import tdCases +from util.sql import tdSql +from util.dnodes import tdDnodes + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + self.ts = 1601481600000 + self.tables = 10 + self.perfix = 'dev' + + def insertData(self): + print("==============step1") + tdSql.execute( + "create table if not exists st (ts timestamp, tagtype int) tags(dev nchar(50))") + + for i in range(self.tables): + tdSql.execute("create table %s%d using st tags(%d)" % (self.perfix, i, i)) + rows = 15 + i + for j in range(rows): + tdSql.execute("insert into %s%d values(%d, %d)" %(self.perfix, i, self.ts + i * 20 * 10000 + j * 10000, j)) + + def run(self): + tdSql.prepare() + + self.insertData() + + tdSql.query("select count(*) val from st group by tbname") + tdSql.checkRows(10) + + tdSql.query("select * from (select count(*) val from st group by tbname)") + tdSql.checkRows(10) + + tdSql.query("select * from (select count(*) val from st group by tbname) a where a.val < 20") + tdSql.checkRows(5) + + tdSql.query("select * from (select count(*) val from st group by tbname) a where a.val > 20") + tdSql.checkRows(4) + + tdSql.query("select * from (select count(*) val from st group by tbname) a where a.val = 20") + tdSql.checkRows(1) + + tdSql.query("select * from (select count(*) val from st group by tbname) a where a.val <= 20") + tdSql.checkRows(6) + + tdSql.query("select * from (select count(*) val from st group by tbname) a where a.val >= 20") + tdSql.checkRows(5) + + tdSql.query("select count(*) from (select first(tagtype) val from st interval(30s)) a where a.val > 20") + tdSql.checkRows(1) + tdSql.checkData(0, 0, 1) + + + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) -- GitLab