提交 f99a61a4 编写于 作者: X Xiaoyu Wang

fix: some problem of parser and planner

上级 df06d22c
...@@ -582,6 +582,7 @@ int32_t* taosGetErrno(); ...@@ -582,6 +582,7 @@ int32_t* taosGetErrno();
#define TSDB_CODE_PAR_INVALID_INTERP_CLAUSE TAOS_DEF_ERROR_CODE(0, 0x265D) #define TSDB_CODE_PAR_INVALID_INTERP_CLAUSE TAOS_DEF_ERROR_CODE(0, 0x265D)
#define TSDB_CODE_PAR_NO_VALID_FUNC_IN_WIN TAOS_DEF_ERROR_CODE(0, 0x265E) #define TSDB_CODE_PAR_NO_VALID_FUNC_IN_WIN TAOS_DEF_ERROR_CODE(0, 0x265E)
#define TSDB_CODE_PAR_ONLY_SUPPORT_SINGLE_TABLE TAOS_DEF_ERROR_CODE(0, 0x265F) #define TSDB_CODE_PAR_ONLY_SUPPORT_SINGLE_TABLE TAOS_DEF_ERROR_CODE(0, 0x265F)
#define TSDB_CODE_PAR_INVALID_SMA_INDEX TAOS_DEF_ERROR_CODE(0, 0x265C)
//planner //planner
#define TSDB_CODE_PLAN_INTERNAL_ERROR TAOS_DEF_ERROR_CODE(0, 0x2700) #define TSDB_CODE_PLAN_INTERNAL_ERROR TAOS_DEF_ERROR_CODE(0, 0x2700)
......
...@@ -270,6 +270,9 @@ static int32_t collectMetaKeyFromCreateIndex(SCollectMetaKeyCxt* pCxt, SCreateIn ...@@ -270,6 +270,9 @@ static int32_t collectMetaKeyFromCreateIndex(SCollectMetaKeyCxt* pCxt, SCreateIn
if (TSDB_CODE_SUCCESS == code) { if (TSDB_CODE_SUCCESS == code) {
code = reserveDbVgInfoInCache(pCxt->pParseCxt->acctId, pCxt->pParseCxt->db, pCxt->pMetaCache); code = reserveDbVgInfoInCache(pCxt->pParseCxt->acctId, pCxt->pParseCxt->db, pCxt->pMetaCache);
} }
if (TSDB_CODE_SUCCESS == code) {
code = reserveDbCfgInCache(pCxt->pParseCxt->acctId, pCxt->pParseCxt->db, pCxt->pMetaCache);
}
} }
return code; return code;
} }
......
...@@ -962,6 +962,10 @@ static EDealRes translateValue(STranslateContext* pCxt, SValueNode* pVal) { ...@@ -962,6 +962,10 @@ static EDealRes translateValue(STranslateContext* pCxt, SValueNode* pVal) {
return translateValueImpl(pCxt, pVal, dt, false); return translateValueImpl(pCxt, pVal, dt, false);
} }
static int32_t doTranslateValue(STranslateContext* pCxt, SValueNode* pVal) {
return DEAL_RES_ERROR == translateValue(pCxt, pVal) ? pCxt->errCode : TSDB_CODE_SUCCESS;
}
static bool isMultiResFunc(SNode* pNode) { static bool isMultiResFunc(SNode* pNode) {
if (NULL == pNode) { if (NULL == pNode) {
return false; return false;
...@@ -1430,6 +1434,24 @@ static EDealRes rewriteColToSelectValFunc(STranslateContext* pCxt, SNode** pNode ...@@ -1430,6 +1434,24 @@ static EDealRes rewriteColToSelectValFunc(STranslateContext* pCxt, SNode** pNode
return TSDB_CODE_SUCCESS == pCxt->errCode ? DEAL_RES_IGNORE_CHILD : DEAL_RES_ERROR; return TSDB_CODE_SUCCESS == pCxt->errCode ? DEAL_RES_IGNORE_CHILD : DEAL_RES_ERROR;
} }
static EDealRes rewriteExprToGroupKeyFunc(STranslateContext* pCxt, SNode** pNode) {
SFunctionNode* pFunc = (SFunctionNode*)nodesMakeNode(QUERY_NODE_FUNCTION);
if (NULL == pFunc) {
pCxt->errCode = TSDB_CODE_OUT_OF_MEMORY;
return DEAL_RES_ERROR;
}
strcpy(pFunc->functionName, "_group_key");
strcpy(pFunc->node.aliasName, ((SExprNode*)*pNode)->aliasName);
pCxt->errCode = nodesListMakeAppend(&pFunc->pParameterList, *pNode);
if (TSDB_CODE_SUCCESS == pCxt->errCode) {
*pNode = (SNode*)pFunc;
pCxt->errCode = fmGetFuncInfo(pFunc, pCxt->msgBuf.buf, pCxt->msgBuf.len);
}
return (TSDB_CODE_SUCCESS == pCxt->errCode ? DEAL_RES_IGNORE_CHILD : DEAL_RES_ERROR);
}
static EDealRes doCheckExprForGroupBy(SNode** pNode, void* pContext) { static EDealRes doCheckExprForGroupBy(SNode** pNode, void* pContext) {
SCheckExprForGroupByCxt* pCxt = (SCheckExprForGroupByCxt*)pContext; SCheckExprForGroupByCxt* pCxt = (SCheckExprForGroupByCxt*)pContext;
if (!nodesIsExprNode(*pNode) || isAliasColumn(*pNode)) { if (!nodesIsExprNode(*pNode) || isAliasColumn(*pNode)) {
...@@ -1455,7 +1477,7 @@ static EDealRes doCheckExprForGroupBy(SNode** pNode, void* pContext) { ...@@ -1455,7 +1477,7 @@ static EDealRes doCheckExprForGroupBy(SNode** pNode, void* pContext) {
SNode* pPartKey = NULL; SNode* pPartKey = NULL;
FOREACH(pPartKey, ((SSelectStmt*)pCxt->pTranslateCxt->pCurrStmt)->pPartitionByList) { FOREACH(pPartKey, ((SSelectStmt*)pCxt->pTranslateCxt->pCurrStmt)->pPartitionByList) {
if (nodesEqualNode(pPartKey, *pNode)) { if (nodesEqualNode(pPartKey, *pNode)) {
return DEAL_RES_IGNORE_CHILD; return rewriteExprToGroupKeyFunc(pCxt->pTranslateCxt, pNode);
} }
} }
if (isScanPseudoColumnFunc(*pNode) || QUERY_NODE_COLUMN == nodeType(*pNode)) { if (isScanPseudoColumnFunc(*pNode) || QUERY_NODE_COLUMN == nodeType(*pNode)) {
...@@ -1515,35 +1537,30 @@ static int32_t rewriteColsToSelectValFunc(STranslateContext* pCxt, SSelectStmt* ...@@ -1515,35 +1537,30 @@ static int32_t rewriteColsToSelectValFunc(STranslateContext* pCxt, SSelectStmt*
typedef struct CheckAggColCoexistCxt { typedef struct CheckAggColCoexistCxt {
STranslateContext* pTranslateCxt; STranslateContext* pTranslateCxt;
bool existAggFunc; bool existVectorFunc;
bool existCol; bool existCol;
bool existIndefiniteRowsFunc;
int32_t selectFuncNum; int32_t selectFuncNum;
bool existOtherAggFunc; bool existOtherVectorFunc;
} CheckAggColCoexistCxt; } CheckAggColCoexistCxt;
static EDealRes doCheckAggColCoexist(SNode* pNode, void* pContext) { static EDealRes doCheckAggColCoexist(SNode** pNode, void* pContext) {
CheckAggColCoexistCxt* pCxt = (CheckAggColCoexistCxt*)pContext; CheckAggColCoexistCxt* pCxt = (CheckAggColCoexistCxt*)pContext;
if (isSelectFunc(pNode)) { if (isSelectFunc(*pNode)) {
++(pCxt->selectFuncNum); ++(pCxt->selectFuncNum);
} else if (isAggFunc(pNode)) { } else if (isAggFunc(*pNode)) {
pCxt->existOtherAggFunc = true; pCxt->existOtherVectorFunc = true;
}
if (isAggFunc(pNode)) {
pCxt->existAggFunc = true;
return DEAL_RES_IGNORE_CHILD;
} }
if (isIndefiniteRowsFunc(pNode)) { if (isVectorFunc(*pNode)) {
pCxt->existIndefiniteRowsFunc = true; pCxt->existVectorFunc = true;
return DEAL_RES_IGNORE_CHILD; return DEAL_RES_IGNORE_CHILD;
} }
SNode* pPartKey = NULL; SNode* pPartKey = NULL;
FOREACH(pPartKey, ((SSelectStmt*)pCxt->pTranslateCxt->pCurrStmt)->pPartitionByList) { FOREACH(pPartKey, ((SSelectStmt*)pCxt->pTranslateCxt->pCurrStmt)->pPartitionByList) {
if (nodesEqualNode(pPartKey, pNode)) { if (nodesEqualNode(pPartKey, *pNode)) {
return DEAL_RES_IGNORE_CHILD; return rewriteExprToGroupKeyFunc(pCxt->pTranslateCxt, pNode);
} }
} }
if (isScanPseudoColumnFunc(pNode) || QUERY_NODE_COLUMN == nodeType(pNode)) { if (isScanPseudoColumnFunc(*pNode) || QUERY_NODE_COLUMN == nodeType(*pNode)) {
pCxt->existCol = true; pCxt->existCol = true;
} }
return DEAL_RES_CONTINUE; return DEAL_RES_CONTINUE;
...@@ -1554,24 +1571,20 @@ static int32_t checkAggColCoexist(STranslateContext* pCxt, SSelectStmt* pSelect) ...@@ -1554,24 +1571,20 @@ static int32_t checkAggColCoexist(STranslateContext* pCxt, SSelectStmt* pSelect)
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
} }
CheckAggColCoexistCxt cxt = {.pTranslateCxt = pCxt, CheckAggColCoexistCxt cxt = {.pTranslateCxt = pCxt,
.existAggFunc = false, .existVectorFunc = false,
.existCol = false, .existCol = false,
.existIndefiniteRowsFunc = false,
.selectFuncNum = 0, .selectFuncNum = 0,
.existOtherAggFunc = false}; .existOtherVectorFunc = false};
nodesWalkExprs(pSelect->pProjectionList, doCheckAggColCoexist, &cxt); nodesRewriteExprs(pSelect->pProjectionList, doCheckAggColCoexist, &cxt);
if (!pSelect->isDistinct) { if (!pSelect->isDistinct) {
nodesWalkExprs(pSelect->pOrderByList, doCheckAggColCoexist, &cxt); nodesRewriteExprs(pSelect->pOrderByList, doCheckAggColCoexist, &cxt);
} }
if (1 == cxt.selectFuncNum && !cxt.existOtherAggFunc) { if (1 == cxt.selectFuncNum && !cxt.existOtherVectorFunc) {
return rewriteColsToSelectValFunc(pCxt, pSelect); return rewriteColsToSelectValFunc(pCxt, pSelect);
} }
if ((cxt.selectFuncNum > 1 || cxt.existAggFunc || NULL != pSelect->pWindow) && cxt.existCol) { if ((cxt.selectFuncNum > 1 || cxt.existVectorFunc || NULL != pSelect->pWindow) && cxt.existCol) {
return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_NOT_SINGLE_GROUP); return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_NOT_SINGLE_GROUP);
} }
if (cxt.existIndefiniteRowsFunc && cxt.existCol) {
return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_NOT_ALLOWED_FUNC);
}
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
} }
...@@ -4047,29 +4060,42 @@ static int32_t buildCreateSmaReq(STranslateContext* pCxt, SCreateIndexStmt* pStm ...@@ -4047,29 +4060,42 @@ static int32_t buildCreateSmaReq(STranslateContext* pCxt, SCreateIndexStmt* pStm
return code; return code;
} }
static int32_t translateCreateSmaIndex(STranslateContext* pCxt, SCreateIndexStmt* pStmt) { static int32_t checkCreateSmaIndex(STranslateContext* pCxt, SCreateIndexStmt* pStmt) {
if (DEAL_RES_ERROR == translateValue(pCxt, (SValueNode*)pStmt->pOptions->pInterval) || SDbCfgInfo dbCfg = {0};
(NULL != pStmt->pOptions->pOffset && int32_t code = getDBCfg(pCxt, pCxt->pParseCxt->db, &dbCfg);
DEAL_RES_ERROR == translateValue(pCxt, (SValueNode*)pStmt->pOptions->pOffset)) || if (TSDB_CODE_SUCCESS == code && NULL != dbCfg.pRetensions) {
(NULL != pStmt->pOptions->pSliding && code = generateSyntaxErrMsgExt(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_SMA_INDEX,
DEAL_RES_ERROR == translateValue(pCxt, (SValueNode*)pStmt->pOptions->pSliding))) { "Tables configured with the 'ROLLUP' option do not support creating sma index");
return pCxt->errCode; }
if (TSDB_CODE_SUCCESS == code) {
code = doTranslateValue(pCxt, (SValueNode*)pStmt->pOptions->pInterval);
}
if (TSDB_CODE_SUCCESS == code && NULL != pStmt->pOptions->pOffset) {
code = doTranslateValue(pCxt, (SValueNode*)pStmt->pOptions->pOffset);
}
if (TSDB_CODE_SUCCESS == code && NULL != pStmt->pOptions->pSliding) {
code = doTranslateValue(pCxt, (SValueNode*)pStmt->pOptions->pSliding);
} }
if (NULL != pStmt->pOptions->pStreamOptions) { if (TSDB_CODE_SUCCESS == code && NULL != pStmt->pOptions->pStreamOptions) {
SStreamOptions* pStreamOpt = (SStreamOptions*)pStmt->pOptions->pStreamOptions; SStreamOptions* pStreamOpt = (SStreamOptions*)pStmt->pOptions->pStreamOptions;
if (NULL != pStreamOpt->pWatermark && if (NULL != pStreamOpt->pWatermark) {
(DEAL_RES_ERROR == translateValue(pCxt, (SValueNode*)pStreamOpt->pWatermark))) { code = doTranslateValue(pCxt, (SValueNode*)pStreamOpt->pWatermark);
return pCxt->errCode;
} }
if (TSDB_CODE_SUCCESS == code && NULL != pStreamOpt->pDelay) {
if (NULL != pStreamOpt->pDelay && (DEAL_RES_ERROR == translateValue(pCxt, (SValueNode*)pStreamOpt->pDelay))) { code = doTranslateValue(pCxt, (SValueNode*)pStreamOpt->pDelay);
return pCxt->errCode;
} }
} }
return code;
}
static int32_t translateCreateSmaIndex(STranslateContext* pCxt, SCreateIndexStmt* pStmt) {
SMCreateSmaReq createSmaReq = {0}; SMCreateSmaReq createSmaReq = {0};
int32_t code = buildCreateSmaReq(pCxt, pStmt, &createSmaReq); int32_t code = checkCreateSmaIndex(pCxt, pStmt);
if (TSDB_CODE_SUCCESS == code) {
code = buildCreateSmaReq(pCxt, pStmt, &createSmaReq);
}
if (TSDB_CODE_SUCCESS == code) { if (TSDB_CODE_SUCCESS == code) {
code = buildCmdMsg(pCxt, TDMT_MND_CREATE_SMA, (FSerializeFunc)tSerializeSMCreateSmaReq, &createSmaReq); code = buildCmdMsg(pCxt, TDMT_MND_CREATE_SMA, (FSerializeFunc)tSerializeSMCreateSmaReq, &createSmaReq);
} }
......
...@@ -485,10 +485,6 @@ static int32_t createAggLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSelect, ...@@ -485,10 +485,6 @@ static int32_t createAggLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSelect,
code = rewriteExprsForSelect(pAgg->pAggFuncs, pSelect, SQL_CLAUSE_GROUP_BY); code = rewriteExprsForSelect(pAgg->pAggFuncs, pSelect, SQL_CLAUSE_GROUP_BY);
} }
if (NULL != pSelect->pPartitionByList) {
code = createGroupKeysFromPartKeys(pSelect->pPartitionByList, &pAgg->pGroupKeys);
}
if (NULL != pSelect->pGroupByList) { if (NULL != pSelect->pGroupByList) {
if (NULL != pAgg->pGroupKeys) { if (NULL != pAgg->pGroupKeys) {
code = nodesListStrictAppendList(pAgg->pGroupKeys, nodesCloneList(pSelect->pGroupByList)); code = nodesListStrictAppendList(pAgg->pGroupKeys, nodesCloneList(pSelect->pGroupByList));
...@@ -845,8 +841,7 @@ static int32_t createProjectLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSel ...@@ -845,8 +841,7 @@ static int32_t createProjectLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSel
} }
static int32_t createPartitionLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSelect, SLogicNode** pLogicNode) { static int32_t createPartitionLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSelect, SLogicNode** pLogicNode) {
if (NULL == pSelect->pPartitionByList || (pSelect->hasAggFuncs && NULL == pSelect->pWindow) || if (NULL == pSelect->pPartitionByList) {
NULL != pSelect->pGroupByList) {
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
} }
......
...@@ -62,4 +62,6 @@ TEST_F(PlanIntervalTest, stable) { ...@@ -62,4 +62,6 @@ TEST_F(PlanIntervalTest, stable) {
run("SELECT _WSTARTTS, COUNT(*) FROM st1 INTERVAL(10s)"); run("SELECT _WSTARTTS, COUNT(*) FROM st1 INTERVAL(10s)");
run("SELECT _WSTARTTS, COUNT(*) FROM st1 PARTITION BY TBNAME INTERVAL(10s)"); run("SELECT _WSTARTTS, COUNT(*) FROM st1 PARTITION BY TBNAME INTERVAL(10s)");
run("SELECT TBNAME, COUNT(*) FROM st1 PARTITION BY TBNAME INTERVAL(10s)");
} }
...@@ -1069,17 +1069,15 @@ static int32_t getArithmeticOperatorResultType(SOperatorNode* pOp) { ...@@ -1069,17 +1069,15 @@ static int32_t getArithmeticOperatorResultType(SOperatorNode* pOp) {
static int32_t getComparisonOperatorResultType(SOperatorNode* pOp) { static int32_t getComparisonOperatorResultType(SOperatorNode* pOp) {
SDataType ldt = ((SExprNode*)(pOp->pLeft))->resType; SDataType ldt = ((SExprNode*)(pOp->pLeft))->resType;
if (NULL != pOp->pRight) {
SDataType rdt = ((SExprNode*)(pOp->pRight))->resType;
if (OP_TYPE_IN == pOp->opType || OP_TYPE_NOT_IN == pOp->opType) { if (OP_TYPE_IN == pOp->opType || OP_TYPE_NOT_IN == pOp->opType) {
rdt = ldt; ((SExprNode*)(pOp->pRight))->resType = ldt;
} else if (nodesIsRegularOp(pOp)) { } else if (nodesIsRegularOp(pOp)) {
SDataType rdt = ((SExprNode*)(pOp->pRight))->resType;
if (!IS_VAR_DATA_TYPE(ldt.type) || QUERY_NODE_VALUE != nodeType(pOp->pRight) || if (!IS_VAR_DATA_TYPE(ldt.type) || QUERY_NODE_VALUE != nodeType(pOp->pRight) ||
(!IS_STR_DATA_TYPE(rdt.type) && (rdt.type != TSDB_DATA_TYPE_NULL))) { (!IS_STR_DATA_TYPE(rdt.type) && (rdt.type != TSDB_DATA_TYPE_NULL))) {
return TSDB_CODE_TSC_INVALID_OPERATION; return TSDB_CODE_TSC_INVALID_OPERATION;
} }
} }
}
pOp->node.resType.type = TSDB_DATA_TYPE_BOOL; pOp->node.resType.type = TSDB_DATA_TYPE_BOOL;
pOp->node.resType.bytes = tDataTypes[TSDB_DATA_TYPE_BOOL].bytes; pOp->node.resType.bytes = tDataTypes[TSDB_DATA_TYPE_BOOL].bytes;
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
......
...@@ -99,7 +99,7 @@ if $rows != 1 then ...@@ -99,7 +99,7 @@ if $rows != 1 then
endi endi
#sql select * from information_schema.`streams` #sql select * from information_schema.`streams`
sql select * from information_schema.user_tables sql select * from information_schema.user_tables
if $rows != 31 then if $rows != 30 then
return -1 return -1
endi endi
#sql select * from information_schema.user_table_distributed #sql select * from information_schema.user_table_distributed
...@@ -197,7 +197,7 @@ if $rows != 1 then ...@@ -197,7 +197,7 @@ if $rows != 1 then
endi endi
#sql select * from performance_schema.`streams` #sql select * from performance_schema.`streams`
sql select * from information_schema.user_tables sql select * from information_schema.user_tables
if $rows != 31 then if $rows != 30 then
return -1 return -1
endi endi
#sql select * from information_schema.user_table_distributed #sql select * from information_schema.user_table_distributed
......
...@@ -1066,7 +1066,7 @@ class TDTestCase: ...@@ -1066,7 +1066,7 @@ class TDTestCase:
tdSql.checkEqual(self.queryLastC10(query_sql), 11) if select_elm == "*" else False tdSql.checkEqual(self.queryLastC10(query_sql), 11) if select_elm == "*" else False
# in # in
query_sql = f'select {select_elm} from {tb_name} where c5 in (1, 6.6)' query_sql = f'select {select_elm} from {tb_name} where c5 in (1, 6.6)'
tdSql.error(query_sql) tdSql.query(query_sql)
# not in # not in
query_sql = f'select {select_elm} from {tb_name} where c5 not in (2, 3)' query_sql = f'select {select_elm} from {tb_name} where c5 not in (2, 3)'
tdSql.query(query_sql) tdSql.query(query_sql)
...@@ -1074,10 +1074,10 @@ class TDTestCase: ...@@ -1074,10 +1074,10 @@ class TDTestCase:
tdSql.checkEqual(self.queryLastC10(query_sql), 11) if select_elm == "*" else False tdSql.checkEqual(self.queryLastC10(query_sql), 11) if select_elm == "*" else False
# and # and
query_sql = f'select {select_elm} from {tb_name} where c5 > 0 and c5 >= 1 and c5 < 7 and c5 <= 6.6 and c5 != 2 and c5 <> 2 and c5 = 6.6 and c5 is not null and c5 between 2 and 6.6 and c5 not between 1 and 2 and c5 in (2,6.6) and c5 not in (1,2)' query_sql = f'select {select_elm} from {tb_name} where c5 > 0 and c5 >= 1 and c5 < 7 and c5 <= 6.6 and c5 != 2 and c5 <> 2 and c5 = 6.6 and c5 is not null and c5 between 2 and 6.6 and c5 not between 1 and 2 and c5 in (2,6.6) and c5 not in (1,2)'
tdSql.error(query_sql) tdSql.query(query_sql)
# or # or
query_sql = f'select {select_elm} from {tb_name} where c5 > 6 or c5 >= 6.6 or c5 < 1 or c5 <= 0 or c5 != 1.1 or c5 <> 1.1 or c5 = 5 or c5 is null or c5 between 4 and 5 or c5 not between 1 and 3 or c5 in (4,5) or c5 not in (1.1,3)' query_sql = f'select {select_elm} from {tb_name} where c5 > 6 or c5 >= 6.6 or c5 < 1 or c5 <= 0 or c5 != 1.1 or c5 <> 1.1 or c5 = 5 or c5 is null or c5 between 4 and 5 or c5 not between 1 and 3 or c5 in (4,5) or c5 not in (1.1,3)'
tdSql.error(query_sql) tdSql.query(query_sql)
# and or # and or
query_sql = f'select {select_elm} from {tb_name} where c5 > 0 and c5 >= 1 or c5 < 5 and c5 <= 6.6 and c5 != 2 and c5 <> 2 and c5 = 4 or c5 is not null and c5 between 2 and 4 and c5 not between 1 and 2 and c5 in (2,4) and c5 not in (1,2)' query_sql = f'select {select_elm} from {tb_name} where c5 > 0 and c5 >= 1 or c5 < 5 and c5 <= 6.6 and c5 != 2 and c5 <> 2 and c5 = 4 or c5 is not null and c5 between 2 and 4 and c5 not between 1 and 2 and c5 in (2,4) and c5 not in (1,2)'
tdSql.query(query_sql) tdSql.query(query_sql)
...@@ -1145,7 +1145,7 @@ class TDTestCase: ...@@ -1145,7 +1145,7 @@ class TDTestCase:
tdSql.checkEqual(self.queryLastC10(query_sql), 11) if select_elm == "*" else False tdSql.checkEqual(self.queryLastC10(query_sql), 11) if select_elm == "*" else False
# in # in
query_sql = f'select {select_elm} from {tb_name} where c6 in (1, 7.7)' query_sql = f'select {select_elm} from {tb_name} where c6 in (1, 7.7)'
tdSql.error(query_sql) tdSql.query(query_sql)
# not in # not in
query_sql = f'select {select_elm} from {tb_name} where c6 not in (2, 3)' query_sql = f'select {select_elm} from {tb_name} where c6 not in (2, 3)'
tdSql.query(query_sql) tdSql.query(query_sql)
...@@ -1153,10 +1153,10 @@ class TDTestCase: ...@@ -1153,10 +1153,10 @@ class TDTestCase:
tdSql.checkEqual(self.queryLastC10(query_sql), 11) if select_elm == "*" else False tdSql.checkEqual(self.queryLastC10(query_sql), 11) if select_elm == "*" else False
# and # and
query_sql = f'select {select_elm} from {tb_name} where c6 > 0 and c6 >= 1 and c6 < 8 and c6 <= 7.7 and c6 != 2 and c6 <> 2 and c6 = 7.7 and c6 is not null and c6 between 2 and 7.7 and c6 not between 1 and 2 and c6 in (2,7.7) and c6 not in (1,2)' query_sql = f'select {select_elm} from {tb_name} where c6 > 0 and c6 >= 1 and c6 < 8 and c6 <= 7.7 and c6 != 2 and c6 <> 2 and c6 = 7.7 and c6 is not null and c6 between 2 and 7.7 and c6 not between 1 and 2 and c6 in (2,7.7) and c6 not in (1,2)'
tdSql.error(query_sql) tdSql.query(query_sql)
# or # or
query_sql = f'select {select_elm} from {tb_name} where c6 > 7 or c6 >= 7.7 or c6 < 1 or c6 <= 0 or c6 != 1.1 or c6 <> 1.1 or c6 = 5 or c6 is null or c6 between 4 and 5 or c6 not between 1 and 3 or c6 in (4,5) or c6 not in (1.1,3)' query_sql = f'select {select_elm} from {tb_name} where c6 > 7 or c6 >= 7.7 or c6 < 1 or c6 <= 0 or c6 != 1.1 or c6 <> 1.1 or c6 = 5 or c6 is null or c6 between 4 and 5 or c6 not between 1 and 3 or c6 in (4,5) or c6 not in (1.1,3)'
tdSql.error(query_sql) tdSql.query(query_sql)
# and or # and or
query_sql = f'select {select_elm} from {tb_name} where c6 > 0 and c6 >= 1 or c6 < 5 and c6 <= 7.7 and c6 != 2 and c6 <> 2 and c6 = 4 or c6 is not null and c6 between 2 and 4 and c6 not between 1 and 2 and c6 in (2,4) and c6 not in (1,2)' query_sql = f'select {select_elm} from {tb_name} where c6 > 0 and c6 >= 1 or c6 < 5 and c6 <= 7.7 and c6 != 2 and c6 <> 2 and c6 = 4 or c6 is not null and c6 between 2 and 4 and c6 not between 1 and 2 and c6 in (2,4) and c6 not in (1,2)'
tdSql.query(query_sql) tdSql.query(query_sql)
...@@ -1398,7 +1398,7 @@ class TDTestCase: ...@@ -1398,7 +1398,7 @@ class TDTestCase:
tdSql.checkEqual(self.queryLastC10(query_sql), 11) if select_elm == "*" else False tdSql.checkEqual(self.queryLastC10(query_sql), 11) if select_elm == "*" else False
# in # in
query_sql = f'select {select_elm} from {tb_name} where c9 in ("binar", false)' query_sql = f'select {select_elm} from {tb_name} where c9 in ("binar", false)'
tdSql.error(query_sql) tdSql.query(query_sql)
# # not in # # not in
query_sql = f'select {select_elm} from {tb_name} where c9 not in (true)' query_sql = f'select {select_elm} from {tb_name} where c9 not in (true)'
tdSql.query(query_sql) tdSql.query(query_sql)
...@@ -1407,13 +1407,13 @@ class TDTestCase: ...@@ -1407,13 +1407,13 @@ class TDTestCase:
# # and # # and
query_sql = f'select {select_elm} from {tb_name} where c9 = true and c9 != "false" and c9 <> "binary" and c9 is not null and c9 in ("binary", true) and c9 not in ("binary")' query_sql = f'select {select_elm} from {tb_name} where c9 = true and c9 != "false" and c9 <> "binary" and c9 is not null and c9 in ("binary", true) and c9 not in ("binary")'
tdSql.error(query_sql) tdSql.query(query_sql)
# # or # # or
query_sql = f'select {select_elm} from {tb_name} where c9 = true or c9 != "false" or c9 <> "binary" or c9 = "true" or c9 is not null or c9 in ("binary", true) or c9 not in ("binary")' query_sql = f'select {select_elm} from {tb_name} where c9 = true or c9 != "false" or c9 <> "binary" or c9 = "true" or c9 is not null or c9 in ("binary", true) or c9 not in ("binary")'
tdSql.error(query_sql) tdSql.query(query_sql)
# # and or # # and or
query_sql = f'select {select_elm} from {tb_name} where c9 = true and c9 != "false" or c9 <> "binary" or c9 = "true" and c9 is not null or c9 in ("binary", true) or c9 not in ("binary")' query_sql = f'select {select_elm} from {tb_name} where c9 = true and c9 != "false" or c9 <> "binary" or c9 = "true" and c9 is not null or c9 in ("binary", true) or c9 not in ("binary")'
tdSql.error(query_sql) tdSql.query(query_sql)
query_sql = f'select c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13 from {tb_name} where c9 > "binary" and c9 >= "binary8" or c9 < "binary9" and c9 <= "binary" and c9 != 2 and c9 <> 2 and c9 = 4 or c9 is not null and c9 between 2 and 4 and c9 not between 1 and 2 and c9 in (2,4) and c9 not in (1,2)' query_sql = f'select c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13 from {tb_name} where c9 > "binary" and c9 >= "binary8" or c9 < "binary9" and c9 <= "binary" and c9 != 2 and c9 <> 2 and c9 = 4 or c9 is not null and c9 between 2 and 4 and c9 not between 1 and 2 and c9 in (2,4) and c9 not in (1,2)'
tdSql.query(query_sql) tdSql.query(query_sql)
tdSql.checkRows(9) tdSql.checkRows(9)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册