diff --git a/src/client/inc/tscUtil.h b/src/client/inc/tscUtil.h index 5e8805e49d..21941d81d4 100644 --- a/src/client/inc/tscUtil.h +++ b/src/client/inc/tscUtil.h @@ -61,6 +61,7 @@ typedef struct SJoinSupporter { uint64_t uid; // query table uid SArray* colList; // previous query information, no need to use this attribute, and the corresponding attribution SArray* exprList; + SArray* colCond; SFieldInfo fieldsInfo; STagCond tagCond; SGroupbyExpr groupInfo; // group by info diff --git a/src/client/src/tscSQLParser.c b/src/client/src/tscSQLParser.c index 1721c9bcd5..315125d411 100644 --- a/src/client/src/tscSQLParser.c +++ b/src/client/src/tscSQLParser.c @@ -3517,6 +3517,8 @@ static int32_t checkColumnFilterInfo(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SCol SColumn* pColumn = tscColumnListInsert(pQueryInfo->colList, pIndex->columnIndex, pTableMeta->id.uid, pSchema); + pColumn->info.flist.numOfFilters++; + /* * in case of TK_AND filter condition, we first find the corresponding column and build the query condition together * the already existed condition. diff --git a/src/client/src/tscServer.c b/src/client/src/tscServer.c index 76945c50b5..45e131d8a5 100644 --- a/src/client/src/tscServer.c +++ b/src/client/src/tscServer.c @@ -914,7 +914,7 @@ int tscBuildQueryMsg(SSqlObj *pSql, SSqlInfo *pInfo) { //serializeColFilterInfo(pCol->flist.filterInfo, pCol->flist.numOfFilters, &pMsg); } - if (pQueryInfo->colCond && taosArrayGetSize(pQueryInfo->colCond) > 0) { + if (pQueryInfo->colCond && taosArrayGetSize(pQueryInfo->colCond) > 0 && !onlyQueryTags(&query) ) { SCond *pCond = tsGetTableFilter(pQueryInfo->colCond, pTableMeta->id.uid); if (pCond != NULL && pCond->cond != NULL) { pQueryMsg->colCondLen = htons(pCond->len); diff --git a/src/client/src/tscSubquery.c b/src/client/src/tscSubquery.c index 75ee8bcea7..06809a6406 100644 --- a/src/client/src/tscSubquery.c +++ b/src/client/src/tscSubquery.c @@ -808,6 +808,7 @@ static void issueTsCompQuery(SSqlObj* pSql, SJoinSupporter* pSupporter, SSqlObj* STimeWindow window = pQueryInfo->window; tscInitQueryInfo(pQueryInfo); + pQueryInfo->colCond = pSupporter->colCond; pQueryInfo->window = window; TSDB_QUERY_CLEAR_TYPE(pQueryInfo->type, TSDB_QUERY_TYPE_TAG_FILTER_QUERY); TSDB_QUERY_SET_TYPE(pQueryInfo->type, TSDB_QUERY_TYPE_MULTITABLE_QUERY); @@ -1883,6 +1884,9 @@ int32_t tscCreateJoinSubquery(SSqlObj *pSql, int16_t tableIndex, SJoinSupporter if (UTIL_TABLE_IS_SUPER_TABLE(pTableMetaInfo)) { // return the tableId & tag SColumnIndex colIndex = {0}; + pSupporter->colCond = pNewQueryInfo->colCond; + pNewQueryInfo->colCond = NULL; + STagCond* pTagCond = &pSupporter->tagCond; assert(pTagCond->joinInfo.hasJoin); diff --git a/src/client/src/tscUtil.c b/src/client/src/tscUtil.c index d7ae97da1a..d5d5292e2b 100644 --- a/src/client/src/tscUtil.c +++ b/src/client/src/tscUtil.c @@ -2011,6 +2011,11 @@ int32_t tscGetResRowLength(SArray* pExprList) { } static void destroyFilterInfo(SColumnFilterList* pFilterList) { + if (pFilterList->filterInfo == NULL) { + pFilterList->numOfFilters = 0; + return; + } + for(int32_t i = 0; i < pFilterList->numOfFilters; ++i) { if (pFilterList->filterInfo[i].filterstr) { tfree(pFilterList->filterInfo[i].pz); diff --git a/src/common/src/tname.c b/src/common/src/tname.c index c1c6ffa4b3..692338acdf 100644 --- a/src/common/src/tname.c +++ b/src/common/src/tname.c @@ -61,7 +61,7 @@ bool tscValidateTableNameLength(size_t len) { // TODO refactor SColumnFilterInfo* tFilterInfoDup(const SColumnFilterInfo* src, int32_t numOfFilters) { - if (numOfFilters == 0) { + if (numOfFilters == 0 || src == NULL) { assert(src == NULL); return NULL; } diff --git a/src/query/src/qExecutor.c b/src/query/src/qExecutor.c index 93a19ce636..458c956cea 100644 --- a/src/query/src/qExecutor.c +++ b/src/query/src/qExecutor.c @@ -7078,7 +7078,7 @@ void* doDestroyFilterInfo(SSingleColumnFilterInfo* pFilterInfo, int32_t numOfFil int32_t createFilterInfo(SQueryAttr* pQueryAttr, uint64_t qId) { for (int32_t i = 0; i < pQueryAttr->numOfCols; ++i) { - if (pQueryAttr->tableCols[i].flist.numOfFilters > 0) { + if (pQueryAttr->tableCols[i].flist.numOfFilters > 0 && pQueryAttr->tableCols[i].flist.filterInfo != NULL) { pQueryAttr->numOfFilterCols++; } }