Merge pull request #11398 from taosdata/feature/3.0_liaohj

fix[query]: enable min/max function to be applied to bool data type.
This commit is contained in:
Haojun Liao 2022-04-11 22:54:55 +08:00 committed by GitHub
commit 6f6adece3e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 2 deletions

View File

@ -212,6 +212,9 @@ bool maxFunctionSetup(SqlFunctionCtx *pCtx, SResultRowEntryInfo* pResultInfo) {
case TSDB_DATA_TYPE_UTINYINT: case TSDB_DATA_TYPE_UTINYINT:
*((uint8_t *)buf) = 0; *((uint8_t *)buf) = 0;
break; break;
case TSDB_DATA_TYPE_BOOL:
*((int8_t*)buf) = 0;
break;
default: default:
assert(0); assert(0);
} }
@ -255,6 +258,9 @@ bool minFunctionSetup(SqlFunctionCtx *pCtx, SResultRowEntryInfo* pResultInfo) {
case TSDB_DATA_TYPE_DOUBLE: case TSDB_DATA_TYPE_DOUBLE:
SET_DOUBLE_VAL(((double *)buf), DBL_MAX); SET_DOUBLE_VAL(((double *)buf), DBL_MAX);
break; break;
case TSDB_DATA_TYPE_BOOL:
*((int8_t*)buf) = 1;
break;
default: default:
assert(0); assert(0);
} }
@ -385,8 +391,8 @@ int32_t doMinMaxHelper(SqlFunctionCtx *pCtx, int32_t isMinFunc) {
int32_t start = pInput->startRowIndex; int32_t start = pInput->startRowIndex;
int32_t numOfRows = pInput->numOfRows; int32_t numOfRows = pInput->numOfRows;
if (IS_SIGNED_NUMERIC_TYPE(type)) { if (IS_SIGNED_NUMERIC_TYPE(type) || type == TSDB_DATA_TYPE_BOOL) {
if (type == TSDB_DATA_TYPE_TINYINT) { if (type == TSDB_DATA_TYPE_TINYINT || type == TSDB_DATA_TYPE_BOOL) {
LOOPCHECK_N(*(int8_t*)buf, pCol, pCtx, int8_t, numOfRows, start, isMinFunc, numOfElems); LOOPCHECK_N(*(int8_t*)buf, pCol, pCtx, int8_t, numOfRows, start, isMinFunc, numOfElems);
} else if (type == TSDB_DATA_TYPE_SMALLINT) { } else if (type == TSDB_DATA_TYPE_SMALLINT) {
LOOPCHECK_N(*(int16_t*) buf, pCol, pCtx, int16_t, numOfRows, start, isMinFunc, numOfElems); LOOPCHECK_N(*(int16_t*) buf, pCol, pCtx, int16_t, numOfRows, start, isMinFunc, numOfElems);