Skip to content

Commit

Permalink
Merge pull request #2083 from taosdata/morequerycases
Browse files Browse the repository at this point in the history
More query cases
  • Loading branch information
guanshengliang committed May 31, 2020
2 parents d3e9a5a + af5f5e8 commit 423fa69
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 9 deletions.
3 changes: 2 additions & 1 deletion tests/pytest/query/filterCombo.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
5 changes: 2 additions & 3 deletions tests/pytest/query/queryError.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
54 changes: 49 additions & 5 deletions tests/pytest/query/queryNormal.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -75,6 +91,34 @@ def run(self):
tdSql.query("select * from stb1 limit 2 offset 3")
tdSql.checkRows(1)

# query ... alias 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__)
Expand Down

0 comments on commit 423fa69

Please sign in to comment.