add test case
This commit is contained in:
parent
f55ac240d5
commit
deff7a76b1
|
@ -2472,7 +2472,7 @@ static EDealRes translateFunction(STranslateContext* pCxt, SFunctionNode** pFunc
|
|||
nodeType(((SSelectStmt*)pCxt->pCurrStmt)->pFromTable) == QUERY_NODE_REAL_TABLE) {
|
||||
SRealTableNode* pRealTable = (SRealTableNode*)((SSelectStmt*)pCxt->pCurrStmt)->pFromTable;
|
||||
if (strcmp(((SValueNode*)pParam)->literal, pRealTable->table.tableName) == 0) {
|
||||
nodesClearList((*pFunc)->pParameterList);
|
||||
NODES_DESTORY_LIST((*pFunc)->pParameterList);
|
||||
(*pFunc)->pParameterList = NULL;
|
||||
}
|
||||
}
|
||||
|
@ -2724,11 +2724,14 @@ static bool hasTbnameFunction(SNodeList* pPartitionByList) {
|
|||
return false;
|
||||
}
|
||||
|
||||
static bool fromSubtable(SNode* table) {
|
||||
static bool fromSingleTable(SNode* table) {
|
||||
if (NULL == table) return false;
|
||||
if (table->type == QUERY_NODE_REAL_TABLE && ((SRealTableNode*)table)->pMeta &&
|
||||
((SRealTableNode*)table)->pMeta->tableType == TSDB_CHILD_TABLE) {
|
||||
return true;
|
||||
if (table->type == QUERY_NODE_REAL_TABLE && ((SRealTableNode*)table)->pMeta) {
|
||||
int8_t type = ((SRealTableNode*)table)->pMeta->tableType;
|
||||
if(type == TSDB_CHILD_TABLE || type == TSDB_NORMAL_TABLE
|
||||
|| type == TSDB_SYSTEM_TABLE) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -2827,7 +2830,7 @@ static EDealRes doCheckAggColCoexist(SNode** pNode, void* pContext) {
|
|||
}
|
||||
SNode* pPartKey = NULL;
|
||||
bool partionByTbname = false;
|
||||
if (fromSubtable(((SSelectStmt*)pCxt->pTranslateCxt->pCurrStmt)->pFromTable) ||
|
||||
if (fromSingleTable(((SSelectStmt*)pCxt->pTranslateCxt->pCurrStmt)->pFromTable) ||
|
||||
hasTbnameFunction(((SSelectStmt*)pCxt->pTranslateCxt->pCurrStmt)->pPartitionByList)) {
|
||||
partionByTbname = true;
|
||||
}
|
||||
|
|
|
@ -105,6 +105,10 @@
|
|||
,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/last_cache_scan.py -Q 2
|
||||
,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/last_cache_scan.py -Q 3
|
||||
,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/last_cache_scan.py -Q 4
|
||||
,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/tbname.py
|
||||
,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/tbname.py -Q 2
|
||||
,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/tbname.py -Q 3
|
||||
,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/tbname.py -Q 4
|
||||
,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/tmqShow.py
|
||||
,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/tmqDropStb.py
|
||||
,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/subscribeStb0.py
|
||||
|
|
|
@ -0,0 +1,194 @@
|
|||
###################################################################
|
||||
# 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 *
|
||||
from util.cases import *
|
||||
from util.sql import *
|
||||
|
||||
|
||||
class TDTestCase:
|
||||
def init(self, conn, logSql, replicaVar=1):
|
||||
self.replicaVar = int(replicaVar)
|
||||
tdLog.debug(f"start to excute {__file__}")
|
||||
tdSql.init(conn.cursor())
|
||||
|
||||
def td29092(self, dbname="db"):
|
||||
tdSql.execute(f'use {dbname}')
|
||||
tdSql.execute('CREATE STABLE `st` (`ts` TIMESTAMP, `v1` INT) TAGS (`t1` INT);')
|
||||
tdSql.execute('CREATE STABLE `st2` (`ts` TIMESTAMP, `v1` INT) TAGS (`t1` INT);')
|
||||
tdSql.execute('CREATE TABLE `t1` USING `st` (`t1`) TAGS (1);')
|
||||
tdSql.execute('CREATE TABLE `t2` USING `st` (`t1`) TAGS (2);')
|
||||
tdSql.execute('CREATE TABLE `t21` USING `st2` (`t1`) TAGS (21);')
|
||||
tdSql.execute('CREATE TABLE `nt` (`ts` TIMESTAMP, `v1` INT);')
|
||||
|
||||
now_time = int(datetime.datetime.timestamp(datetime.datetime.now()) * 1000)
|
||||
for i in range(3):
|
||||
tdSql.execute(
|
||||
f"insert into {dbname}.t1 values ( { now_time + i * 1000 }, {i} )"
|
||||
)
|
||||
tdSql.execute(
|
||||
f"insert into {dbname}.t2 values ( { now_time + i * 1000 }, {i} )"
|
||||
)
|
||||
tdSql.execute(
|
||||
f"insert into {dbname}.nt values ( { now_time + i * 1000 }, {i} )"
|
||||
)
|
||||
|
||||
tdLog.debug(f"-------------- step1: normal table test ------------------")
|
||||
tdSql.query("select tbname, count(*) from nt;")
|
||||
tdSql.checkRows(1)
|
||||
tdSql.checkData(0, 0, "nt")
|
||||
tdSql.checkData(0, 1, 3)
|
||||
|
||||
tdSql.query("select nt.tbname, count(*) from nt;")
|
||||
tdSql.checkRows(1)
|
||||
tdSql.checkData(0, 0, "nt")
|
||||
tdSql.checkData(0, 1, 3)
|
||||
|
||||
tdSql.query("select tbname, count(*) from nt group by tbname")
|
||||
tdSql.checkRows(1)
|
||||
tdSql.checkData(0, 0, "nt")
|
||||
tdSql.checkData(0, 1, 3)
|
||||
|
||||
tdSql.query("select nt.tbname, count(*) from nt group by tbname")
|
||||
tdSql.checkRows(1)
|
||||
tdSql.checkData(0, 0, "nt")
|
||||
tdSql.checkData(0, 1, 3)
|
||||
|
||||
tdSql.query("select nt.tbname, count(*) from nt group by nt.tbname")
|
||||
tdSql.checkRows(1)
|
||||
tdSql.checkData(0, 0, "nt")
|
||||
tdSql.checkData(0, 1, 3)
|
||||
|
||||
tdLog.debug(f"-------------- step2: system table test ------------------")
|
||||
tdSql.query("select tbname, count(*) from information_schema.ins_dnodes")
|
||||
tdSql.checkRows(1)
|
||||
tdSql.checkData(0, 1, 1)
|
||||
|
||||
tdSql.query("select ins_dnodes.tbname, count(*) from information_schema.ins_dnodes")
|
||||
tdSql.checkRows(1)
|
||||
tdSql.checkData(0, 1, 1)
|
||||
|
||||
tdSql.query("select tbname, count(*) from information_schema.ins_dnodes group by tbname")
|
||||
tdSql.checkRows(1)
|
||||
tdSql.checkData(0, 1, 1)
|
||||
|
||||
tdSql.query("select ins_dnodes.tbname, count(*) from information_schema.ins_dnodes group by tbname")
|
||||
tdSql.checkRows(1)
|
||||
tdSql.checkData(0, 1, 1)
|
||||
|
||||
tdSql.query("select ins_dnodes.tbname, count(*) from information_schema.ins_dnodes group by ins_dnodes.tbname")
|
||||
tdSql.checkRows(1)
|
||||
tdSql.checkData(0, 1, 1)
|
||||
|
||||
tdLog.debug(f"-------------- step3: subtable test ------------------")
|
||||
tdSql.query("select tbname, count(*) from t1")
|
||||
tdSql.checkRows(1)
|
||||
tdSql.checkData(0, 1, 3)
|
||||
|
||||
tdSql.query("select t1.tbname, count(*) from t1")
|
||||
tdSql.checkRows(1)
|
||||
tdSql.checkData(0, 1, 3)
|
||||
|
||||
tdSql.query("select tbname, count(*) from t1 group by tbname")
|
||||
tdSql.checkRows(1)
|
||||
tdSql.checkData(0, 1, 3)
|
||||
|
||||
tdSql.query("select t1.tbname, count(*) from t1 group by tbname")
|
||||
tdSql.checkRows(1)
|
||||
tdSql.checkData(0, 1, 3)
|
||||
|
||||
tdSql.query("select t1.tbname, count(*) from t1 group by t1.tbname")
|
||||
tdSql.checkRows(1)
|
||||
tdSql.checkData(0, 1, 3)
|
||||
|
||||
tdSql.error("select t1.tbname, count(*) from t2 group by t1.tbname")
|
||||
tdSql.error("select t1.tbname, count(*) from t1 group by t2.tbname")
|
||||
tdSql.error("select t2.tbname, count(*) from t1 group by t1.tbname")
|
||||
|
||||
tdLog.debug(f"-------------- step4: super table test ------------------")
|
||||
tdSql.query("select tbname, count(*) from st group by tbname")
|
||||
tdSql.checkRows(2)
|
||||
tdSql.checkData(0, 1, 3)
|
||||
tdSql.checkData(1, 1, 3)
|
||||
|
||||
tdSql.query("select tbname, count(*) from st partition by tbname")
|
||||
tdSql.checkRows(2)
|
||||
tdSql.checkData(0, 1, 3)
|
||||
tdSql.checkData(1, 1, 3)
|
||||
|
||||
tdSql.query("select ts, t1 from st where st.tbname=\"t1\"")
|
||||
tdSql.checkRows(3)
|
||||
tdSql.checkData(0, 1, 1)
|
||||
tdSql.checkData(1, 1, 1)
|
||||
tdSql.checkData(2, 1, 1)
|
||||
|
||||
tdSql.query("select tbname, ts from st where tbname=\"t2\"")
|
||||
tdSql.checkRows(3)
|
||||
|
||||
tdSql.query("select tbname, ts from st where tbname=\"t2\" order by tbname")
|
||||
tdSql.checkRows(3)
|
||||
|
||||
tdSql.query("select tbname, ts from st where tbname=\"t2\" order by st.tbname")
|
||||
tdSql.checkRows(3)
|
||||
|
||||
tdSql.query("select tbname, count(*) from st where tbname=\"t2\" group by tbname order by tbname")
|
||||
tdSql.checkRows(1)
|
||||
tdSql.checkData(0, 1, 3)
|
||||
|
||||
tdSql.query("select tbname, count(*) from st group by tbname order by tbname")
|
||||
tdSql.checkRows(2)
|
||||
tdSql.checkData(0, 1, 3)
|
||||
tdSql.checkData(1, 1, 3)
|
||||
|
||||
tdSql.query("select tbname, count(*) from st group by st.tbname order by st.tbname")
|
||||
tdSql.checkRows(2)
|
||||
tdSql.checkData(0, 1, 3)
|
||||
tdSql.checkData(1, 1, 3)
|
||||
|
||||
tdLog.debug(f"-------------- step4: join test ------------------")
|
||||
tdSql.query("select t1.tbname, t2.tbname from t1, t2 where t1.ts=t2.ts and t1.tbname!=t2.tbname")
|
||||
tdSql.checkRows(3)
|
||||
|
||||
tdSql.query("select t1.tbname, t2.tbname from t1, t2 where t1.ts=t2.ts and t1.tbname!=t2.tbname order by t1.tbname")
|
||||
tdSql.checkRows(3)
|
||||
|
||||
tdSql.query("select st.tbname, st2.tbname from st, st2 where st.ts=st2.ts and st.tbname!=st2.tbname order by st.tbname")
|
||||
tdSql.checkRows(0)
|
||||
|
||||
tdSql.execute(f"insert into t21 values ( { now_time + 1000 }, 1 )")
|
||||
tdSql.query("select st.tbname, st2.tbname from st, st2 where st.ts=st2.ts and st.tbname!=st2.tbname order by st.tbname")
|
||||
tdSql.checkRows(2)
|
||||
|
||||
tdSql.query("select t1.tbname, st2.tbname from t1, st2 where t1.ts=st2.ts and t1.tbname!=st2.tbname order by t1.tbname")
|
||||
tdSql.checkRows(1)
|
||||
|
||||
tdSql.query("select nt.ts, st.tbname from nt, st where nt.ts=st.ts order by st.tbname")
|
||||
tdSql.checkRows(6)
|
||||
|
||||
tdSql.query("select nt.ts, t1.tbname from nt, t1 where nt.ts=t1.ts order by t1.tbname")
|
||||
tdSql.checkRows(3)
|
||||
|
||||
def run(self):
|
||||
tdSql.prepare()
|
||||
|
||||
self.td29092()
|
||||
|
||||
def stop(self):
|
||||
tdSql.close()
|
||||
tdLog.success("%s successfully executed" % __file__)
|
||||
|
||||
|
||||
tdCases.addWindows(__file__, TDTestCase())
|
||||
tdCases.addLinux(__file__, TDTestCase())
|
Loading…
Reference in New Issue