From f1f00b1c7cab8f165bebe8b6e3f6d9a8a5275bdd Mon Sep 17 00:00:00 2001 From: Ping Xiao Date: Sun, 31 May 2020 00:29:43 +0800 Subject: [PATCH] =?UTF-8?q?TD-350:=20query=20=E7=BB=84=E5=90=88=E6=B5=8B?= =?UTF-8?q?=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tests/pytest/query/filterCombo.py | 3 +- tests/pytest/query/queryError.py | 5 ++- tests/pytest/query/queryNormal.py | 54 ++++++++++++++++++++++++++++--- 3 files changed, 53 insertions(+), 9 deletions(-) diff --git a/tests/pytest/query/filterCombo.py b/tests/pytest/query/filterCombo.py index c25b6156b85..c9c7ade73ee 100644 --- a/tests/pytest/query/filterCombo.py +++ b/tests/pytest/query/filterCombo.py @@ -49,7 +49,8 @@ def run(self): tdSql.error("select * from db.st where ts > '2020-05-13 10:00:00.002' OR tagtype < 2") # illegal condition - tdSql.error("select * from db.st where ts != '2020-05-13 10:00:00.002' OR tagtype < 2") + tdSql.error("select * from db.st where ts != '2020-05-13 10:00:00.002' OR tagtype < 2") + tdSql.error("select * from db.st where tagtype <> 1 OR tagtype < 2") def stop(self): tdSql.close() diff --git a/tests/pytest/query/queryError.py b/tests/pytest/query/queryError.py index d0515ef34dd..95924f48cc0 100644 --- a/tests/pytest/query/queryError.py +++ b/tests/pytest/query/queryError.py @@ -41,13 +41,12 @@ def run(self): ('2020-05-13 10:00:00.002', 3, 'third') dev_002 VALUES('2020-05-13 10:00:00.003', 1, 'first'), ('2020-05-13 10:00:00.004', 2, 'second'), ('2020-05-13 10:00:00.005', 3, 'third')""") - """Error expected here, but no errors + # query first .. as .. tdSql.error("select first(*) as one from st") # query last .. as .. - tdSql.error("select last(*) as latest from st") - """ + tdSql.error("select last(*) as latest from st") # query last row .. as .. tdSql.error("select last_row as latest from st") diff --git a/tests/pytest/query/queryNormal.py b/tests/pytest/query/queryNormal.py index 3ca9c1d1357..c4fa46c063f 100644 --- a/tests/pytest/query/queryNormal.py +++ b/tests/pytest/query/queryNormal.py @@ -31,14 +31,22 @@ def run(self): tdSql.execute("create table stb1 (ts timestamp, c1 int, c2 float) tags(t1 int, t2 binary(10), t3 nchar(10))") tdSql.execute("insert into tb1 using stb1 tags(1,'tb1', '表1') values ('2020-04-18 15:00:00.000', 1, 0.1), ('2020-04-18 15:00:01.000', 2, 0.1)") tdSql.execute("insert into tb2 using stb1 tags(2,'tb2', '表2') values ('2020-04-18 15:00:02.000', 3, 2.1), ('2020-04-18 15:00:03.000', 4, 2.2)") - - # join 2 tables -- bug exists - # tdSql.query("select * from tb1 a, tb2 b where a.ts = b.ts") - # tdSql.checkRows(1) + + # inner join --- bug + tdSql.query("select * from tb1 a, tb2 b where a.ts = b.ts") + tdSql.checkRows(1) # join 3 tables -- bug exists - # tdSql.query("select stb_t.ts, stb_t.dscrption, stb_t.temperature, stb_p.id, stb_p.dscrption, stb_p.pressure,stb_v.velocity from stb_p, stb_t, stb_v where stb_p.ts=stb_t.ts and stb_p.ts=stb_v.ts and stb_p.id = stb_t.id") + tdSql.query("select stb_t.ts, stb_t.dscrption, stb_t.temperature, stb_p.id, stb_p.dscrption, stb_p.pressure,stb_v.velocity from stb_p, stb_t, stb_v where stb_p.ts=stb_t.ts and stb_p.ts=stb_v.ts and stb_p.id = stb_t.id") + # query show stable + tdSql.query("show stables") + tdSql.checkRows(1) + + # query show tables + tdSql.query("show table") + tdSql.checkRows(2) + # query count tdSql.query("select count(*) from stb1") tdSql.checkData(0, 0, 4) @@ -51,6 +59,10 @@ def run(self): tdSql.query("select last(*) from stb1") tdSql.checkData(0, 1, 4) + # query last_row + tdSql.query("select last_row(*) from stb1") + tdSql.checkData(0, 1, 4) + # query as tdSql.query("select t2 as number from stb1") tdSql.checkRows(2) @@ -63,6 +75,10 @@ def run(self): tdSql.query("select last(*) as end from stb1") tdSql.checkData(0, 1, 4) + # query last_row ... as + tdSql.query("select last_row(*) as end from stb1") + tdSql.checkData(0, 1, 4) + # query group .. by tdSql.query("select sum(c1), t2 from stb1 group by t2") tdSql.checkRows(2) @@ -75,6 +91,34 @@ def run(self): tdSql.query("select * from stb1 limit 2 offset 3") tdSql.checkRows(1) + # query ... alien for table ---- bug + tdSql.query("select t.ts from tb1 t") + tdSql.checkRows(2) + + # query ... tbname + tdSql.query("select tbname from stb1") + tdSql.checkRows(2) + + # query ... tbname count ---- bug + tdSql.query("select count(tbname) from stb1") + tdSql.checkRows(2) + + # query ... select database ---- bug + tdSql.query("SELECT database()") + tdSql.checkRows(1) + + # query ... select client_version ---- bug + tdSql.query("SELECT client_version()") + tdSql.checkRows(1) + + # query ... select server_version ---- bug + tdSql.query("SELECT server_version()") + tdSql.checkRows(1) + + # query ... select server_status ---- bug + tdSql.query("SELECT server_status()") + tdSql.checkRows(1) + def stop(self): tdSql.close() tdLog.success("%s successfully executed" % __file__)