Merge pull request #28373 from taosdata/fix/TS-5531/not
fix: not condition
This commit is contained in:
commit
b04b6b21a5
|
@ -887,7 +887,8 @@ _err:
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t addParamToLogicConditionNode(SLogicConditionNode* pCond, SNode* pParam) {
|
static int32_t addParamToLogicConditionNode(SLogicConditionNode* pCond, SNode* pParam) {
|
||||||
if (QUERY_NODE_LOGIC_CONDITION == nodeType(pParam) && pCond->condType == ((SLogicConditionNode*)pParam)->condType) {
|
if (QUERY_NODE_LOGIC_CONDITION == nodeType(pParam) && pCond->condType == ((SLogicConditionNode*)pParam)->condType &&
|
||||||
|
((SLogicConditionNode*)pParam)->condType != LOGIC_COND_TYPE_NOT) {
|
||||||
int32_t code = nodesListAppendList(pCond->pParameterList, ((SLogicConditionNode*)pParam)->pParameterList);
|
int32_t code = nodesListAppendList(pCond->pParameterList, ((SLogicConditionNode*)pParam)->pParameterList);
|
||||||
((SLogicConditionNode*)pParam)->pParameterList = NULL;
|
((SLogicConditionNode*)pParam)->pParameterList = NULL;
|
||||||
nodesDestroyNode(pParam);
|
nodesDestroyNode(pParam);
|
||||||
|
|
|
@ -4679,6 +4679,9 @@ EDealRes fltReviseRewriter(SNode **pNode, void *pContext) {
|
||||||
|
|
||||||
cell = cell->pNext;
|
cell = cell->pNext;
|
||||||
}
|
}
|
||||||
|
if (node->condType == LOGIC_COND_TYPE_NOT) {
|
||||||
|
stat->scalarMode = true;
|
||||||
|
}
|
||||||
|
|
||||||
return DEAL_RES_CONTINUE;
|
return DEAL_RES_CONTINUE;
|
||||||
}
|
}
|
||||||
|
|
|
@ -225,6 +225,7 @@ python3 test.py -f query/distinctOneColTb.py
|
||||||
python3 ./test.py -f query/filter.py
|
python3 ./test.py -f query/filter.py
|
||||||
python3 ./test.py -f query/filterCombo.py
|
python3 ./test.py -f query/filterCombo.py
|
||||||
python3 ./test.py -f query/queryNormal.py
|
python3 ./test.py -f query/queryNormal.py
|
||||||
|
python3 ./test.py -f query/not.py
|
||||||
python3 ./test.py -f query/queryError.py
|
python3 ./test.py -f query/queryError.py
|
||||||
python3 ./test.py -f query/filterAllIntTypes.py
|
python3 ./test.py -f query/filterAllIntTypes.py
|
||||||
python3 ./test.py -f query/filterFloatAndDouble.py
|
python3 ./test.py -f query/filterFloatAndDouble.py
|
||||||
|
|
|
@ -139,6 +139,7 @@ python3 ./test.py -f query/querySort.py
|
||||||
python3 ./test.py -f query/queryJoin.py
|
python3 ./test.py -f query/queryJoin.py
|
||||||
python3 ./test.py -f query/filterCombo.py
|
python3 ./test.py -f query/filterCombo.py
|
||||||
python3 ./test.py -f query/queryNormal.py
|
python3 ./test.py -f query/queryNormal.py
|
||||||
|
python3 ./test.py -f query/not.py
|
||||||
python3 ./test.py -f query/select_last_crash.py
|
python3 ./test.py -f query/select_last_crash.py
|
||||||
python3 ./test.py -f query/queryNullValueTest.py
|
python3 ./test.py -f query/queryNullValueTest.py
|
||||||
python3 ./test.py -f query/queryInsertValue.py
|
python3 ./test.py -f query/queryInsertValue.py
|
||||||
|
|
|
@ -0,0 +1,132 @@
|
||||||
|
from wsgiref.headers import tspecials
|
||||||
|
from util.log import *
|
||||||
|
from util.cases import *
|
||||||
|
from util.sql import *
|
||||||
|
from util.common import tdCom
|
||||||
|
import numpy as np
|
||||||
|
|
||||||
|
|
||||||
|
class TDTestCase:
|
||||||
|
def init(self, conn, logSql, replicaVar=1):
|
||||||
|
self.replicaVar = int(replicaVar)
|
||||||
|
tdLog.debug("start to execute %s" % __file__)
|
||||||
|
tdSql.init(conn.cursor())
|
||||||
|
|
||||||
|
self.dbname = "db"
|
||||||
|
self.rowNum = 10
|
||||||
|
self.ts = 1537146000000
|
||||||
|
|
||||||
|
def notConditionTest(self):
|
||||||
|
dbname = "nottest"
|
||||||
|
stbname = "st1"
|
||||||
|
|
||||||
|
tdsql = tdCom.newTdSql()
|
||||||
|
tdsql.execute(f"create database if not exists {dbname}")
|
||||||
|
|
||||||
|
stype = ["INT", "INT UNSIGNED", "BIGINT", "BIGINT UNSIGNED", "DOUBLE", "FLOAT", "SMALLINT", "SMALLINT UNSIGNED", "TINYINT", "TINYINT UNSIGNED"]
|
||||||
|
|
||||||
|
for type_name in stype:
|
||||||
|
tdsql.execute(f"drop table if exists {dbname}.{stbname}")
|
||||||
|
tdsql.execute(f"create table if not exists {dbname}.{stbname} (ts timestamp, v1 {type_name}) tags(t1 {type_name})")
|
||||||
|
tdsql.execute(f"insert into {dbname}.sub_1 using {dbname}.{stbname} tags(1) values({self.ts}, 10)")
|
||||||
|
tdsql.execute(f"insert into {dbname}.sub_2 using {dbname}.{stbname} tags(2) values({self.ts + 1000}, 20)")
|
||||||
|
tdsql.execute(f"insert into {dbname}.sub_3 using {dbname}.{stbname} tags(3) values({self.ts + 2000}, 30)")
|
||||||
|
|
||||||
|
# Test case 1: NOT IN
|
||||||
|
tdsql.query(f"select t1, * from {dbname}.{stbname} where t1 not in (1, 2) order by t1")
|
||||||
|
tdsql.checkRows(1)
|
||||||
|
tdsql.checkData(0, 0, 3)
|
||||||
|
|
||||||
|
# Test case 2: NOT BETWEEN
|
||||||
|
tdsql.query(f"select * from {dbname}.{stbname} where v1 not between 10 and 20 order by t1")
|
||||||
|
tdsql.checkRows(1)
|
||||||
|
tdsql.checkData(0, 1, 30)
|
||||||
|
tdsql.query(f"select * from {dbname}.{stbname} where not(v1 not between 10 and 20) order by t1")
|
||||||
|
tdsql.checkRows(2)
|
||||||
|
|
||||||
|
# Test case 4: NOT EQUAL
|
||||||
|
tdsql.query(f"select * from {dbname}.{stbname} where v1 != 20 order by t1")
|
||||||
|
tdsql.checkRows(2)
|
||||||
|
tdsql.checkData(0, 1, 10)
|
||||||
|
tdsql.checkData(1, 1, 30)
|
||||||
|
|
||||||
|
# Test case 8: NOT (v1 < 20 OR v1 > 30)
|
||||||
|
tdsql.query(f"select * from {dbname}.{stbname} where not (v1 < 20 or v1 > 30) order by t1")
|
||||||
|
tdsql.checkRows(2)
|
||||||
|
tdsql.checkData(0, 1, 20)
|
||||||
|
tdsql.checkData(1, 1, 30)
|
||||||
|
|
||||||
|
tdsql.query(f"select * from {dbname}.{stbname} where not (v1 < 20 or v1 >= 30) order by t1")
|
||||||
|
tdsql.checkRows(1)
|
||||||
|
|
||||||
|
# Test case 9: NOT (t1 != 1)
|
||||||
|
tdsql.query(f"select * from {dbname}.{stbname} where not (t1 != 1) order by t1")
|
||||||
|
tdsql.checkRows(1)
|
||||||
|
tdsql.checkData(0, 1, 10)
|
||||||
|
|
||||||
|
tdsql.query(f"select * from {dbname}.{stbname} where (t1 != 1) or not (v1 == 20) order by t1")
|
||||||
|
tdsql.checkRows(3)
|
||||||
|
tdsql.checkData(0, 1, 10)
|
||||||
|
tdsql.checkData(1, 1, 20)
|
||||||
|
tdsql.checkData(2, 1, 30)
|
||||||
|
|
||||||
|
tdsql.query(f"select * from {dbname}.{stbname} where not((t1 != 1) or not (v1 == 20)) order by t1")
|
||||||
|
tdsql.checkRows(0)
|
||||||
|
|
||||||
|
tdsql.query(f"select * from {dbname}.{stbname} where not (t1 != 1) and not (v1 != 20) order by t1")
|
||||||
|
tdsql.checkRows(0)
|
||||||
|
|
||||||
|
tdsql.query(f"select * from {dbname}.{stbname} where not(not (t1 != 1) and not (v1 != 20)) order by t1")
|
||||||
|
tdsql.checkRows(3)
|
||||||
|
|
||||||
|
tdsql.query(f"select * from {dbname}.{stbname} where not (t1 != 1) and not (v1 != 10) order by t1")
|
||||||
|
tdsql.checkRows(1)
|
||||||
|
tdsql.checkData(0, 1, 10)
|
||||||
|
|
||||||
|
tdsql.query(f"select * from {dbname}.{stbname} where not (t1 > 2) order by t1")
|
||||||
|
tdsql.checkRows(2)
|
||||||
|
tdsql.checkData(0, 1, 10)
|
||||||
|
tdsql.checkData(1, 1, 20)
|
||||||
|
|
||||||
|
tdsql.query(f"select * from {dbname}.{stbname} where not (t1 == 2) order by t1")
|
||||||
|
tdsql.checkRows(2)
|
||||||
|
tdsql.checkData(0, 1, 10)
|
||||||
|
tdsql.checkData(1, 1, 30)
|
||||||
|
|
||||||
|
tdsql.query(f"select * from {dbname}.{stbname} where not (v1 > 10 and v1 < 30) order by t1")
|
||||||
|
tdsql.checkRows(2)
|
||||||
|
tdsql.checkData(0, 1, 10)
|
||||||
|
tdsql.checkData(1, 1, 30)
|
||||||
|
|
||||||
|
tdsql.query(f"select * from {dbname}.{stbname} where not(not (v1 < 20 or v1 > 30)) order by t1")
|
||||||
|
tdsql.checkRows(1)
|
||||||
|
|
||||||
|
tdsql.query(f"select * from {dbname}.{stbname} where not(not (v1 < 20 or v1 >= 30)) order by t1")
|
||||||
|
tdsql.checkRows(2)
|
||||||
|
|
||||||
|
tdsql.query(f"select * from {dbname}.{stbname} where not(not (t1 != 1)) order by t1")
|
||||||
|
tdsql.checkRows(2)
|
||||||
|
|
||||||
|
tdsql.query(f"select * from {dbname}.{stbname} where not(not (t1 > 2)) order by t1")
|
||||||
|
tdsql.checkRows(1)
|
||||||
|
|
||||||
|
tdsql.query(f"select * from {dbname}.{stbname} where not(not (t1 == 2)) order by t1")
|
||||||
|
tdsql.checkRows(1)
|
||||||
|
|
||||||
|
tdsql.query(f"select * from {dbname}.{stbname} where not(not (v1 > 10 and v1 < 30)) order by t1")
|
||||||
|
tdsql.checkRows(1)
|
||||||
|
|
||||||
|
def run(self):
|
||||||
|
dbname = "db"
|
||||||
|
tdSql.prepare()
|
||||||
|
|
||||||
|
self.notConditionTest()
|
||||||
|
|
||||||
|
|
||||||
|
def stop(self):
|
||||||
|
tdSql.close()
|
||||||
|
tdLog.success("%s successfully executed" % __file__)
|
||||||
|
|
||||||
|
tdCases.addWindows(__file__, TDTestCase())
|
||||||
|
|
||||||
|
tdCases.addLinux(__file__, TDTestCase())
|
|
@ -245,6 +245,8 @@ python3 ./test.py -f 2-query/min.py -P
|
||||||
python3 ./test.py -f 2-query/min.py -P -R
|
python3 ./test.py -f 2-query/min.py -P -R
|
||||||
python3 ./test.py -f 2-query/normal.py -P
|
python3 ./test.py -f 2-query/normal.py -P
|
||||||
python3 ./test.py -f 2-query/normal.py -P -R
|
python3 ./test.py -f 2-query/normal.py -P -R
|
||||||
|
python3 ./test.py -f 2-query/not.py -P
|
||||||
|
python3 ./test.py -f 2-query/not.py -P -R
|
||||||
python3 ./test.py -f 2-query/mode.py -P
|
python3 ./test.py -f 2-query/mode.py -P
|
||||||
python3 ./test.py -f 2-query/mode.py -P -R
|
python3 ./test.py -f 2-query/mode.py -P -R
|
||||||
python3 ./test.py -f 2-query/Now.py -P
|
python3 ./test.py -f 2-query/Now.py -P
|
||||||
|
@ -427,6 +429,7 @@ python3 ./test.py -f 2-query/Today.py -P -Q 2
|
||||||
python3 ./test.py -f 2-query/max.py -P -Q 2
|
python3 ./test.py -f 2-query/max.py -P -Q 2
|
||||||
python3 ./test.py -f 2-query/min.py -P -Q 2
|
python3 ./test.py -f 2-query/min.py -P -Q 2
|
||||||
python3 ./test.py -f 2-query/normal.py -P -Q 2
|
python3 ./test.py -f 2-query/normal.py -P -Q 2
|
||||||
|
python3 ./test.py -f 2-query/not.py -P -Q 2
|
||||||
python3 ./test.py -f 2-query/mode.py -P -Q 2
|
python3 ./test.py -f 2-query/mode.py -P -Q 2
|
||||||
python3 ./test.py -f 2-query/count.py -P -Q 2
|
python3 ./test.py -f 2-query/count.py -P -Q 2
|
||||||
python3 ./test.py -f 2-query/countAlwaysReturnValue.py -P -Q 2
|
python3 ./test.py -f 2-query/countAlwaysReturnValue.py -P -Q 2
|
||||||
|
@ -526,6 +529,7 @@ python3 ./test.py -f 2-query/Today.py -P -Q 3
|
||||||
python3 ./test.py -f 2-query/max.py -P -Q 3
|
python3 ./test.py -f 2-query/max.py -P -Q 3
|
||||||
python3 ./test.py -f 2-query/min.py -P -Q 3
|
python3 ./test.py -f 2-query/min.py -P -Q 3
|
||||||
python3 ./test.py -f 2-query/normal.py -P -Q 3
|
python3 ./test.py -f 2-query/normal.py -P -Q 3
|
||||||
|
python3 ./test.py -f 2-query/not.py -P -Q 3
|
||||||
python3 ./test.py -f 2-query/mode.py -P -Q 3
|
python3 ./test.py -f 2-query/mode.py -P -Q 3
|
||||||
python3 ./test.py -f 2-query/count.py -P -Q 3
|
python3 ./test.py -f 2-query/count.py -P -Q 3
|
||||||
python3 ./test.py -f 2-query/countAlwaysReturnValue.py -P -Q 3
|
python3 ./test.py -f 2-query/countAlwaysReturnValue.py -P -Q 3
|
||||||
|
@ -624,6 +628,7 @@ python3 ./test.py -f 2-query/Today.py -P -Q 4
|
||||||
python3 ./test.py -f 2-query/max.py -P -Q 4
|
python3 ./test.py -f 2-query/max.py -P -Q 4
|
||||||
python3 ./test.py -f 2-query/min.py -P -Q 4
|
python3 ./test.py -f 2-query/min.py -P -Q 4
|
||||||
python3 ./test.py -f 2-query/normal.py -P -Q 4
|
python3 ./test.py -f 2-query/normal.py -P -Q 4
|
||||||
|
python3 ./test.py -f 2-query/not.py -P -Q 4
|
||||||
python3 ./test.py -f 2-query/mode.py -P -Q 4
|
python3 ./test.py -f 2-query/mode.py -P -Q 4
|
||||||
python3 ./test.py -f 2-query/count.py -P -Q 4
|
python3 ./test.py -f 2-query/count.py -P -Q 4
|
||||||
python3 ./test.py -f 2-query/countAlwaysReturnValue.py -P -Q 4
|
python3 ./test.py -f 2-query/countAlwaysReturnValue.py -P -Q 4
|
||||||
|
|
Loading…
Reference in New Issue