diff --git a/src/client/src/tscFunctionImpl.c b/src/client/src/tscFunctionImpl.c index d8ac0d3109fc207278882e365724879a8114897a..be38a7af71ed8b97f9deb001b7bbc4fef80104e6 100644 --- a/src/client/src/tscFunctionImpl.c +++ b/src/client/src/tscFunctionImpl.c @@ -326,7 +326,7 @@ int32_t getResultDataInfo(int32_t dataType, int32_t dataBytes, int32_t functionI } else if (functionId == TSDB_FUNC_LAST_ROW) { *type = (int16_t)dataType; *bytes = (int16_t)dataBytes; - *interBytes = dataBytes + sizeof(SLastrowInfo); + *interBytes = dataBytes; } else { return TSDB_CODE_TSC_INVALID_SQL; } @@ -1843,8 +1843,10 @@ static void last_row_function(SQLFunctionCtx *pCtx) { pInfo1->hasResult = DATA_SET_FLAG; DO_UPDATE_TAG_COLUMNS(pCtx, pInfo1->ts); + } else { + DO_UPDATE_TAG_COLUMNS(pCtx, pCtx->ptsList[pCtx->size - 1]); } - + SET_VAL(pCtx, pCtx->size, 1); } diff --git a/src/client/src/tscSQLParser.c b/src/client/src/tscSQLParser.c index cceb876a06d65dcc07af5e8157aa27548fdc8f01..4555b0e08d362e528cde070e2f7ff1a2b0020e20 100644 --- a/src/client/src/tscSQLParser.c +++ b/src/client/src/tscSQLParser.c @@ -5286,9 +5286,12 @@ void doAddGroupColumnForSubquery(SQueryInfo* pQueryInfo, int32_t tagIndex) { static void doUpdateSqlFunctionForTagPrj(SQueryInfo* pQueryInfo) { int32_t tagLength = 0; - size_t size = taosArrayGetSize(pQueryInfo->exprList); - + +//todo is 0?? + STableMetaInfo* pTableMetaInfo = tscGetMetaInfo(pQueryInfo, 0); + bool isSTable = UTIL_TABLE_IS_SUPER_TABLE(pTableMetaInfo); + for (int32_t i = 0; i < size; ++i) { SSqlExpr* pExpr = tscSqlExprGet(pQueryInfo, i); if (pExpr->functionId == TSDB_FUNC_TAGPRJ || pExpr->functionId == TSDB_FUNC_TAG) { @@ -5300,8 +5303,7 @@ static void doUpdateSqlFunctionForTagPrj(SQueryInfo* pQueryInfo) { } } - STableMetaInfo* pTableMetaInfo = tscGetMetaInfo(pQueryInfo, 0); - SSchema* pSchema = tscGetTableSchema(pTableMetaInfo->pTableMeta); + SSchema* pSchema = tscGetTableSchema(pTableMetaInfo->pTableMeta); for (int32_t i = 0; i < size; ++i) { SSqlExpr* pExpr = tscSqlExprGet(pQueryInfo, i); @@ -5309,7 +5311,7 @@ static void doUpdateSqlFunctionForTagPrj(SQueryInfo* pQueryInfo) { !(pExpr->functionId == TSDB_FUNC_PRJ && TSDB_COL_IS_UD_COL(pExpr->colInfo.flag))) { SSchema* pColSchema = &pSchema[pExpr->colInfo.colIndex]; getResultDataInfo(pColSchema->type, pColSchema->bytes, pExpr->functionId, (int32_t)pExpr->param[0].i64Key, &pExpr->resType, - &pExpr->resBytes, &pExpr->interBytes, tagLength, true); + &pExpr->resBytes, &pExpr->interBytes, tagLength, isSTable); } } } @@ -5320,7 +5322,7 @@ static int32_t doUpdateSqlFunctionForColPrj(SQueryInfo* pQueryInfo) { for (int32_t i = 0; i < size; ++i) { SSqlExpr* pExpr = tscSqlExprGet(pQueryInfo, i); - if (pExpr->functionId == TSDB_FUNC_PRJ && (!TSDB_COL_IS_UD_COL(pExpr->colInfo.flag))) { + if (pExpr->functionId == TSDB_FUNC_PRJ && (!TSDB_COL_IS_UD_COL(pExpr->colInfo.flag) && (pExpr->colInfo.colId != PRIMARYKEY_TIMESTAMP_COL_INDEX))) { bool qualifiedCol = false; for (int32_t j = 0; j < pQueryInfo->groupbyExpr.numOfGroupCols; ++j) { SColIndex* pColIndex = taosArrayGet(pQueryInfo->groupbyExpr.columnInfo, j); @@ -5418,13 +5420,6 @@ static int32_t checkUpdateTagPrjFunctions(SQueryInfo* pQueryInfo, SSqlCmd* pCmd) int16_t numOfSelectivity = 0; int16_t numOfAggregation = 0; - // todo is 0?? - STableMetaInfo* pTableMetaInfo = tscGetMetaInfo(pQueryInfo, 0); - bool isSTable = UTIL_TABLE_IS_SUPER_TABLE(pTableMetaInfo); - if (!isSTable) { - return TSDB_CODE_SUCCESS; - } - size_t numOfExprs = taosArrayGetSize(pQueryInfo->exprList); for (int32_t i = 0; i < numOfExprs; ++i) { SSqlExpr* pExpr = taosArrayGetP(pQueryInfo->exprList, i); diff --git a/src/query/src/qExecutor.c b/src/query/src/qExecutor.c index d3f44cdcc715bb236fafaa4947a54771052df307..f2d324e376390e27252c22af0d8c07b5e587b20a 100644 --- a/src/query/src/qExecutor.c +++ b/src/query/src/qExecutor.c @@ -2120,7 +2120,7 @@ static bool needToLoadDataBlock(SQueryRuntimeEnv* pRuntimeEnv, SDataStatis *pDat } } - // no statistics data + // no statistics data, load the true data block if (index == -1) { return true; } @@ -2130,8 +2130,17 @@ static bool needToLoadDataBlock(SQueryRuntimeEnv* pRuntimeEnv, SDataStatis *pDat return true; } - // all points in current column are NULL, no need to check its boundary value + // all data in current column are NULL, no need to check its boundary value if (pDataStatis[index].numOfNull == numOfRows) { + + // if isNULL query exists, load the null data column + for (int32_t j = 0; j < pFilterInfo->numOfFilters; ++j) { + SColumnFilterElem *pFilterElem = &pFilterInfo->pFilters[j]; + if (pFilterElem->fp == isNull_filter) { + return true; + } + } + continue; } @@ -2957,11 +2966,10 @@ int32_t mergeIntoGroupResultImpl(SQInfo *pQInfo, SArray *pGroup) { STableQueryInfo *item = taosArrayGetP(pGroup, i); SIDList list = getDataBufPagesIdList(pRuntimeEnv->pResultBuf, TSDB_TABLEID(item->pTable)->tid); - pageList = list; - tid = TSDB_TABLEID(item->pTable)->tid; - if (taosArrayGetSize(list) > 0 && item->windowResInfo.size > 0) { pTableList[numOfTables++] = item; + tid = TSDB_TABLEID(item->pTable)->tid; + pageList = list; } } diff --git a/tests/script/general/parser/where.sim b/tests/script/general/parser/where.sim index fb15fb6dbe0f641d9d94c284d29b3ae7fbcb0f94..f9fd919bd6c5a424ddcac52a0d00b142168702e9 100644 --- a/tests/script/general/parser/where.sim +++ b/tests/script/general/parser/where.sim @@ -308,13 +308,25 @@ sleep 2000 system sh/exec.sh -n dnode1 -s start -sql select * from wh_mt0 where c3 = 'abc' and tbname in ('test_null_filter'); +sql_error select * from wh_mt0 where c3 = 'abc' and tbname in ('test_null_filter'); + +sql select * from wh_mt0 where c3 = '1' and tbname in ('test_null_filter'); if $row != 0 then return -1 endi -sql select * from wh_mt0 where c3 = 'abc' and tbname in ('test_null_filter'); -if $row != 0 then +sql select * from wh_mt0 where c3 = '1'; +if $row == 0 then + return -1 +endi + +sql select * from wh_mt0 where c3 is null and tbname in ('test_null_filter'); +if $rows != 10000 then + return -1 +endi + +sql select * from wh_mt0 where c3 is not null and tbname in ('test_null_filter'); +if $rows != 0 then return -1 endi