diff --git a/source/libs/function/src/builtins.c b/source/libs/function/src/builtins.c index a63596d0d2..94ccf799bb 100644 --- a/source/libs/function/src/builtins.c +++ b/source/libs/function/src/builtins.c @@ -1748,6 +1748,7 @@ static int32_t translateHistogramPartial(SFunctionNode* pFunc, char* pErrBuf, in return TSDB_CODE_SUCCESS; } +#define NUMERIC_TO_STRINGS_LEN 25 static int32_t translateGreatestleast(SFunctionNode* pFunc, char* pErrBuf, int32_t len) { if (LIST_LENGTH(pFunc->pParameterList) < 2) { return invaildFuncParaNumErrMsg(pErrBuf, len, pFunc->functionName); @@ -1756,32 +1757,48 @@ static int32_t translateGreatestleast(SFunctionNode* pFunc, char* pErrBuf, int32 bool mixTypeToStrings = tsTransToStrWhenMixTypeInLeast; SDataType res = {.type = 0}; + bool resInit = false; for (int32_t i = 0; i < LIST_LENGTH(pFunc->pParameterList); i++) { SDataType* para = getSDataTypeFromNode(nodesListGetNode(pFunc->pParameterList, i)); if (IS_NULL_TYPE(para->type)) { res.type = TSDB_DATA_TYPE_NULL; + res.bytes = tDataTypes[TSDB_DATA_TYPE_NULL].bytes; break; - } else if (IS_MATHABLE_TYPE(para->type)) { - if(res.type == 0) { - res.type = para->type; - res.bytes = para->bytes; - } else if(IS_MATHABLE_TYPE(res.type) || !mixTypeToStrings) { + } + + if (!resInit) { + res.type = para->type; + res.bytes = para->bytes; + resInit = true; + continue; + } + + if (IS_MATHABLE_TYPE(para->type)) { + if (res.type == para->type) { + continue; + } else if (IS_MATHABLE_TYPE(res.type) || !mixTypeToStrings) { int32_t resType = vectorGetConvertType(res.type, para->type); res.type = resType == 0 ? res.type : resType; - res.bytes = tDataTypes[resType].bytes; + res.bytes = tDataTypes[resType].bytes; + } else { + // last res is strings, para is numeric and mixTypeToStrings is true + res.bytes = TMAX(res.bytes, NUMERIC_TO_STRINGS_LEN); } } else if (IS_COMPARE_STR_DATA_TYPE(para->type)) { - if(res.type == 0) { - res.type = para->type; - res.bytes = para->bytes; - } else if(IS_COMPARE_STR_DATA_TYPE(res.type)) { + if (IS_COMPARE_STR_DATA_TYPE(res.type)) { int32_t resType = vectorGetConvertType(res.type, para->type); res.type = resType == 0 ? res.type : resType; res.bytes = TMAX(res.bytes, para->bytes); - } else if(mixTypeToStrings) { // res.type is mathable type + } else if (mixTypeToStrings) { + // last res is numeric, para is string, and mixTypeToStrings is true res.type = para->type; - res.bytes = para->bytes; + res.bytes = TMAX(para->bytes, NUMERIC_TO_STRINGS_LEN); + } else { + // last res is numeric, para is string, and mixTypeToStrings is false + int32_t resType = vectorGetConvertType(res.type, para->type); + res.type = resType == 0 ? res.type : resType; + res.bytes = tDataTypes[resType].bytes; } } else { return invaildFuncParaTypeErrMsg(pErrBuf, len, pFunc->functionName); diff --git a/source/libs/scalar/src/sclfunc.c b/source/libs/scalar/src/sclfunc.c index 3ce310a261..280a469153 100644 --- a/source/libs/scalar/src/sclfunc.c +++ b/source/libs/scalar/src/sclfunc.c @@ -4473,9 +4473,12 @@ static int32_t greatestLeastImpl(SScalarParam *pInput, int32_t inputNum, SScalar int32_t *resultColIndex = NULL; int32_t numOfRows = 0; - bool IsNullType = false; + bool IsNullType = outputType == TSDB_DATA_TYPE_NULL ? true : false; // If any column is NULL type, the output is NULL type for (int32_t i = 0; i < inputNum; i++) { + if (IsNullType) { + break; + } if (numOfRows != 0 && numOfRows != pInput[i].numOfRows && pInput[i].numOfRows != 1 && numOfRows != 1) { qError("input rows not match, func:%s, rows:%d, %d", __FUNCTION__, numOfRows, pInput[i].numOfRows); code = TSDB_CODE_TSC_INTERNAL_ERROR; diff --git a/tests/army/query/function/ans/greatest.csv b/tests/army/query/function/ans/greatest.csv new file mode 100644 index 0000000000..ced28474f8 --- /dev/null +++ b/tests/army/query/function/ans/greatest.csv @@ -0,0 +1,1409 @@ + +taos> alter local 'transToStrWhenMixTypeInLeast' '1'; + +taos> select GREATEST(1,2,3,4,5,6,7,8,9,10); + greatest(1,2,3,4,5,6,7,8,9,10) | +================================= + 10 | + +taos> select GREATEST(1,1.1,2.23,3.4444,5.66666666,6.21241241,7.999999999999); + greatest(1,1.1,2.23,3.4444,5.66666666,6.21241241,7.999999999999) | +=================================================================== + 7.999999999999 | + +taos> select GREATEST(1,'2',3.3,4.4,5); + greatest(1,'2',3.3,4.4,5) | +============================ + 5 | + +taos> select GREATEST(121,'18'); + greatest(121,'18') | +============================ + 18 | + +taos> select GREATEST(18888,'18'); + greatest(18888,'18') | +============================ + 18888 | + +taos> select GREATEST(1,2,3,4,5,'5.1'); + greatest(1,2,3,4,5,'5.1') | +============================ + 5.1 | + +taos> select GREATEST('1','2','3','4',5); + greatest('1','2','3','4',5) | +============================== + 5 | + +taos> select GREATEST('1','2','3','4','5'); + greatest('1','2','3','4','5') | +================================ + 5 | + +taos> select GREATEST(1,2,3,4,5,6,7,'a','b','一','二','三'); + greatest(1,2,3,4,5,6,7,'a','b','一','二','三') | +==================================================== + 二 | + +taos> select GREATEST(1,2,3,4,5,6,7,'a','b','c','1','2','1231213'); + greatest(1,2,3,4,5,6,7,'a','b','c','1','2','1231213') | +======================================================== + c | + +taos> select GREATEST(1,2,3,4,5,6,7,'a','b','c','1','2','1231213','1231213.123123'); + greatest(1,2,3,4,5,6,7,'a','b','c','1','2','1231213','1231213.12 | +=================================================================== + c | + +taos> select GREATEST(cast(0 as bool), cast(1 as tinyint), cast(2 as smallint), cast(3 as int), cast(4 as bigint), cast(5 as float), cast(6 as double), cast(8 as varchar(20)), cast(9 as nchar(20))); + greatest(cast(0 as bool), cast(1 as tinyint), cast(2 as smallint | +=================================================================== + 9 | + +taos> select GREATEST(cast(0 as bool), cast(1 as tinyint unsigned), cast(2 as smallint unsigned), cast(3 as int unsigned), cast(4 as bigint unsigned), cast(5 as float), cast(6 as double), cast(8 as varchar(20)), cast(9 as nchar(20))); + greatest(cast(0 as bool), cast(1 as tinyint unsigned), cast(2 as | +=================================================================== + 9 | + +taos> select GREATEST(cast(0 as bool), cast(1 as tinyint), cast(2 as smallint), cast(3 as int), cast(4 as bigint), cast(5 as float), cast(6 as double), cast(8 as varchar(20)), cast(9 as nchar(20)), cast(0 as bool), cast(1 as tinyint unsigned), cast(2 as smallint unsigned), cast(3 as int unsigned), cast(4 as bigint unsigned), cast(5 as float), cast(6 as double)); + greatest(cast(0 as bool), cast(1 as tinyint), cast(2 as smallint | +=================================================================== + 9 | + +taos> select GREATEST(cast(100 as tinyint), cast(101 as tinyint)); + greatest(cast(100 as tinyint), cast(101 as tinyint)) | +======================================================= + 101 | + +taos> select GREATEST(cast(100 as tinyint), cast(101 as smallint)); + greatest(cast(100 as tinyint), cast(101 as smallint)) | +======================================================== + 101 | + +taos> select GREATEST(cast(100 as tinyint), cast(101 as int)); + greatest(cast(100 as tinyint), cast(101 as int)) | +=================================================== + 101 | + +taos> select GREATEST(cast(100 as tinyint), cast(101 as bigint)); + greatest(cast(100 as tinyint), cast(101 as bigint)) | +====================================================== + 101 | + +taos> select GREATEST(cast(100 as tinyint), cast(101 as float)); + greatest(cast(100 as tinyint), cast(101 as float)) | +===================================================== + 101 | + +taos> select GREATEST(cast(100 as tinyint), cast(101 as double)); + greatest(cast(100 as tinyint), cast(101 as double)) | +====================================================== + 101 | + +taos> select GREATEST(cast(100 as tinyint), cast(101 as varchar(20))); + greatest(cast(100 as tinyint), cast(101 as varchar(20))) | +=========================================================== + 101 | + +taos> select GREATEST(cast(100 as tinyint), cast(101 as nchar(20))); + greatest(cast(100 as tinyint), cast(101 as nchar(20))) | +========================================================= + 101 | + +taos> select GREATEST(cast(101 as tinyint), cast(100 as tinyint)); + greatest(cast(101 as tinyint), cast(100 as tinyint)) | +======================================================= + 101 | + +taos> select GREATEST(cast(101 as tinyint), cast(100 as smallint)); + greatest(cast(101 as tinyint), cast(100 as smallint)) | +======================================================== + 101 | + +taos> select GREATEST(cast(101 as tinyint), cast(100 as int)); + greatest(cast(101 as tinyint), cast(100 as int)) | +=================================================== + 101 | + +taos> select GREATEST(cast(101 as tinyint), cast(100 as bigint)); + greatest(cast(101 as tinyint), cast(100 as bigint)) | +====================================================== + 101 | + +taos> select GREATEST(cast(101 as tinyint), cast(100 as float)); + greatest(cast(101 as tinyint), cast(100 as float)) | +===================================================== + 101 | + +taos> select GREATEST(cast(101 as tinyint), cast(100 as double)); + greatest(cast(101 as tinyint), cast(100 as double)) | +====================================================== + 101 | + +taos> select GREATEST(cast(101 as tinyint), cast(100 as varchar(20))); + greatest(cast(101 as tinyint), cast(100 as varchar(20))) | +=========================================================== + 101 | + +taos> select GREATEST(cast(101 as tinyint), cast(100 as nchar(20))); + greatest(cast(101 as tinyint), cast(100 as nchar(20))) | +========================================================= + 101 | + +taos> select GREATEST(cast(1000 as smallint), cast(1001 as smallint)); + greatest(cast(1000 as smallint), cast(1001 as smallint)) | +=========================================================== + 1001 | + +taos> select GREATEST(cast(1000 as smallint), cast(1001 as int)); + greatest(cast(1000 as smallint), cast(1001 as int)) | +====================================================== + 1001 | + +taos> select GREATEST(cast(1000 as smallint), cast(1001 as bigint)); + greatest(cast(1000 as smallint), cast(1001 as bigint)) | +========================================================= + 1001 | + +taos> select GREATEST(cast(1000 as smallint), cast(1001 as float)); + greatest(cast(1000 as smallint), cast(1001 as float)) | +======================================================== + 1001 | + +taos> select GREATEST(cast(1000 as smallint), cast(1001 as double)); + greatest(cast(1000 as smallint), cast(1001 as double)) | +========================================================= + 1001 | + +taos> select GREATEST(cast(1000 as smallint), cast(1001 as varchar(20))); + greatest(cast(1000 as smallint), cast(1001 as varchar(20))) | +============================================================== + 1001 | + +taos> select GREATEST(cast(1000 as smallint), cast(1001 as nchar(20))); + greatest(cast(1000 as smallint), cast(1001 as nchar(20))) | +============================================================ + 1001 | + +taos> select GREATEST(cast(1001 as smallint), cast(1000 as smallint)); + greatest(cast(1001 as smallint), cast(1000 as smallint)) | +=========================================================== + 1001 | + +taos> select GREATEST(cast(1001 as smallint), cast(1000 as int)); + greatest(cast(1001 as smallint), cast(1000 as int)) | +====================================================== + 1001 | + +taos> select GREATEST(cast(1001 as smallint), cast(1000 as bigint)); + greatest(cast(1001 as smallint), cast(1000 as bigint)) | +========================================================= + 1001 | + +taos> select GREATEST(cast(1001 as smallint), cast(1000 as float)); + greatest(cast(1001 as smallint), cast(1000 as float)) | +======================================================== + 1001 | + +taos> select GREATEST(cast(1001 as smallint), cast(1000 as double)); + greatest(cast(1001 as smallint), cast(1000 as double)) | +========================================================= + 1001 | + +taos> select GREATEST(cast(1001 as smallint), cast(1000 as varchar(20))); + greatest(cast(1001 as smallint), cast(1000 as varchar(20))) | +============================================================== + 1001 | + +taos> select GREATEST(cast(1001 as smallint), cast(1000 as nchar(20))); + greatest(cast(1001 as smallint), cast(1000 as nchar(20))) | +============================================================ + 1001 | + +taos> select GREATEST(cast(1000000 as int), cast(1000001 as int)); + greatest(cast(1000000 as int), cast(1000001 as int)) | +======================================================= + 1000001 | + +taos> select GREATEST(cast(1000000 as int), cast(1000001 as bigint)); + greatest(cast(1000000 as int), cast(1000001 as bigint)) | +========================================================== + 1000001 | + +taos> select GREATEST(cast(1000000 as int), cast(1000001 as float)); + greatest(cast(1000000 as int), cast(1000001 as float)) | +========================================================= + 1e+06 | + +taos> select GREATEST(cast(1000000 as int), cast(1000001 as double)); + greatest(cast(1000000 as int), cast(1000001 as double)) | +========================================================== + 1000001 | + +taos> select GREATEST(cast(1000000 as int), cast(1000001 as varchar(20))); + greatest(cast(1000000 as int), cast(1000001 as varchar(20))) | +=============================================================== + 1000001 | + +taos> select GREATEST(cast(1000000 as int), cast(1000001 as nchar(20))); + greatest(cast(1000000 as int), cast(1000001 as nchar(20))) | +============================================================= + 1000001 | + +taos> select GREATEST(cast(1000001 as int), cast(1000000 as int)); + greatest(cast(1000001 as int), cast(1000000 as int)) | +======================================================= + 1000001 | + +taos> select GREATEST(cast(1000001 as int), cast(1000000 as bigint)); + greatest(cast(1000001 as int), cast(1000000 as bigint)) | +========================================================== + 1000001 | + +taos> select GREATEST(cast(1000001 as int), cast(1000000 as float)); + greatest(cast(1000001 as int), cast(1000000 as float)) | +========================================================= + 1e+06 | + +taos> select GREATEST(cast(1000001 as int), cast(1000000 as double)); + greatest(cast(1000001 as int), cast(1000000 as double)) | +========================================================== + 1000001 | + +taos> select GREATEST(cast(1000001 as int), cast(1000000 as varchar(20))); + greatest(cast(1000001 as int), cast(1000000 as varchar(20))) | +=============================================================== + 1000001 | + +taos> select GREATEST(cast(1000001 as int), cast(1000000 as nchar(20))); + greatest(cast(1000001 as int), cast(1000000 as nchar(20))) | +============================================================= + 1000001 | + +taos> select GREATEST(cast(1000000000 as bigint), cast(1000000001 as bigint)); + greatest(cast(1000000000 as bigint), cast(1000000001 as bigint)) | +=================================================================== + 1000000001 | + +taos> select GREATEST(cast(1000000000 as bigint), cast(1000000001 as float)); + greatest(cast(1000000000 as bigint), cast(1000000001 as float)) | +================================================================== + 1e+09 | + +taos> select GREATEST(cast(1000000000 as bigint), cast(1000000001 as double)); + greatest(cast(1000000000 as bigint), cast(1000000001 as double)) | +=================================================================== + 1000000001 | + +taos> select GREATEST(cast(1000000000 as bigint), cast(1000000001 as varchar(20))); + greatest(cast(1000000000 as bigint), cast(1000000001 as varchar( | +=================================================================== + 1000000001 | + +taos> select GREATEST(cast(1000000000 as bigint), cast(1000000001 as nchar(20))); + greatest(cast(1000000000 as bigint), cast(1000000001 as nchar(20 | +=================================================================== + 1000000001 | + +taos> select GREATEST(cast(1000000001 as bigint), cast(1000000000 as bigint)); + greatest(cast(1000000001 as bigint), cast(1000000000 as bigint)) | +=================================================================== + 1000000001 | + +taos> select GREATEST(cast(1000000001 as bigint), cast(1000000000 as float)); + greatest(cast(1000000001 as bigint), cast(1000000000 as float)) | +================================================================== + 1e+09 | + +taos> select GREATEST(cast(1000000001 as bigint), cast(1000000000 as double)); + greatest(cast(1000000001 as bigint), cast(1000000000 as double)) | +=================================================================== + 1000000001 | + +taos> select GREATEST(cast(1000000001 as bigint), cast(1000000000 as varchar(20))); + greatest(cast(1000000001 as bigint), cast(1000000000 as varchar( | +=================================================================== + 1000000001 | + +taos> select GREATEST(cast(1000000001 as bigint), cast(1000000000 as nchar(20))); + greatest(cast(1000000001 as bigint), cast(1000000000 as nchar(20 | +=================================================================== + 1000000001 | + +taos> select GREATEST(cast(100000.1111111 as float), cast(100001.1111111 as float)); + greatest(cast(100000.1111111 as float), cast(100001.1111111 as f | +=================================================================== + 100001 | + +taos> select GREATEST(cast(100000.1111111 as float), cast(100001.1111111 as double)); + greatest(cast(100000.1111111 as float), cast(100001.1111111 as d | +=================================================================== + 100001.1111111 | + +taos> select GREATEST(cast(100000.1111111 as float), cast(100001.1111111 as timestamp)); + greatest(cast(100000.1111111 as float), cast(100001.1111111 as t | +=================================================================== + 100001 | + +taos> select GREATEST(cast(100000.1111111 as float), cast(100001.1111111 as varchar(20))); + greatest(cast(100000.1111111 as float), cast(100001.1111111 as v | +=================================================================== + 100001.1111111 | + +taos> select GREATEST(cast(100000.1111111 as float), cast(100001.1111111 as nchar(20))); + greatest(cast(100000.1111111 as float), cast(100001.1111111 as n | +=================================================================== + 100001.1111111 | + +taos> select GREATEST(cast(100001.1111111 as float), cast(100000.1111111 as float)); + greatest(cast(100001.1111111 as float), cast(100000.1111111 as f | +=================================================================== + 100001 | + +taos> select GREATEST(cast(100001.1111111 as float), cast(100000.1111111 as double)); + greatest(cast(100001.1111111 as float), cast(100000.1111111 as d | +=================================================================== + 100001.109375 | + +taos> select GREATEST(cast(100001.1111111 as float), cast(100000.1111111 as timestamp)); + greatest(cast(100001.1111111 as float), cast(100000.1111111 as t | +=================================================================== + 100001 | + +taos> select GREATEST(cast(100001.1111111 as float), cast(100000.1111111 as varchar(20))); + greatest(cast(100001.1111111 as float), cast(100000.1111111 as v | +=================================================================== + 100001.109375 | + +taos> select GREATEST(cast(100001.1111111 as float), cast(100000.1111111 as nchar(20))); + greatest(cast(100001.1111111 as float), cast(100000.1111111 as n | +=================================================================== + 100001.109375 | + +taos> select GREATEST(cast(100000.1111111 as double), cast(100001.1111111 as double)); + greatest(cast(100000.1111111 as double), cast(100001.1111111 as | +=================================================================== + 100001.1111111 | + +taos> select GREATEST(cast(100000.1111111 as double), cast(100001.1111111 as timestamp)); + greatest(cast(100000.1111111 as double), cast(100001.1111111 as | +=================================================================== + 100001 | + +taos> select GREATEST(cast(100000.1111111 as double), cast(100001.1111111 as varchar(20))); + greatest(cast(100000.1111111 as double), cast(100001.1111111 as | +=================================================================== + 100001.1111111 | + +taos> select GREATEST(cast(100000.1111111 as double), cast(100001.1111111 as nchar(20))); + greatest(cast(100000.1111111 as double), cast(100001.1111111 as | +=================================================================== + 100001.1111111 | + +taos> select GREATEST(cast(100001.1111111 as double), cast(100000.1111111 as double)); + greatest(cast(100001.1111111 as double), cast(100000.1111111 as | +=================================================================== + 100001.1111111 | + +taos> select GREATEST(cast(100001.1111111 as double), cast(100000.1111111 as timestamp)); + greatest(cast(100001.1111111 as double), cast(100000.1111111 as | +=================================================================== + 100001.1111111 | + +taos> select GREATEST(cast(100001.1111111 as double), cast(100000.1111111 as varchar(20))); + greatest(cast(100001.1111111 as double), cast(100000.1111111 as | +=================================================================== + 100001.111111 | + +taos> select GREATEST(cast(100001.1111111 as double), cast(100000.1111111 as nchar(20))); + greatest(cast(100001.1111111 as double), cast(100000.1111111 as | +=================================================================== + 100001.111111 | + +taos> select GREATEST(cast('中文测试' as varchar(20)), cast('中文测试一' as varchar(20))); + greatest(cast('中文测试' as varchar(20)), cast('中文测试 | +=================================================================== + 中文测试一 | + +taos> select GREATEST(cast('中文测试' as varchar(20)), cast('中文测试一' as nchar(20))); + greatest(cast('中文测试' as varchar(20)), cast('中文测试 | +=================================================================== + 中文测试一 | + +taos> select GREATEST(cast('中文测试一' as varchar(20)), cast('中文测试' as varchar(20))); + greatest(cast('中文测试一' as varchar(20)), cast('中文测 | +=================================================================== + 中文测试一 | + +taos> select GREATEST(cast('中文测试一' as varchar(20)), cast('中文测试' as nchar(20))); + greatest(cast('中文测试一' as varchar(20)), cast('中文测 | +=================================================================== + 中文测试一 | + +taos> select GREATEST(cast('abc123abc' as varchar(20)), cast('abc124abc' as varchar(20))); + greatest(cast('abc123abc' as varchar(20)), cast('abc124abc' as v | +=================================================================== + abc124abc | + +taos> select GREATEST(cast('abc123abc' as varchar(20)), cast('abc124abc' as nchar(20))); + greatest(cast('abc123abc' as varchar(20)), cast('abc124abc' as n | +=================================================================== + abc124abc | + +taos> select GREATEST(cast('abc124abc' as varchar(20)), cast('abc123abc' as varchar(20))); + greatest(cast('abc124abc' as varchar(20)), cast('abc123abc' as v | +=================================================================== + abc124abc | + +taos> select GREATEST(cast('abc124abc' as varchar(20)), cast('abc123abc' as nchar(20))); + greatest(cast('abc124abc' as varchar(20)), cast('abc123abc' as n | +=================================================================== + abc124abc | + +taos> select GREATEST(cast('abc123abc' as nchar(20)), cast('abc124abc' as nchar(20))); + greatest(cast('abc123abc' as nchar(20)), cast('abc124abc' as nch | +=================================================================== + abc124abc | + +taos> select GREATEST(cast(100 as tinyint), cast(101 as float), cast(102 as varchar(20))); + greatest(cast(100 as tinyint), cast(101 as float), cast(102 as v | +=================================================================== + 102 | + +taos> select GREATEST(cast(100 as float), cast(101 as tinyint), cast(102 as varchar(20))); + greatest(cast(100 as float), cast(101 as tinyint), cast(102 as v | +=================================================================== + 102 | + +taos> select GREATEST(cast(100 as float), cast(101 as varchar(20)), cast(102 as tinyint)); + greatest(cast(100 as float), cast(101 as varchar(20)), cast(102 | +=================================================================== + 102 | + +taos> select GREATEST(cast(100 as varchar(20)), cast(101 as float), cast(102 as tinyint)); + greatest(cast(100 as varchar(20)), cast(101 as float), cast(102 | +=================================================================== + 102 | + +taos> select GREATEST('a','b','c','d','e','f','g','h','1231','15155'); + greatest('a','b','c','d','e','f','g','h','1231','15155') | +=========================================================== + h | + +taos> select GREATEST(current, voltage, phase, id, nch1, nch2, var1, var2) from ts_4893.meters order by ts limit 10; + greatest(current, voltage, phase, id, nch1, nch2, var1, var2) | +================================================================ + 四 | + 三a | + 四 | + 一 | + 一二三四五六七八九十 | + 一二三 | + prision | + 一二三四五六七八九十 | + prision | + 一 | + +taos> select GREATEST(current, voltage, phase, id) from ts_4893.meters order by ts limit 10; + greatest(current, voltage, phase, id) | +======================================== + 221 | + 220 | + 215 | + 216 | + 219 | + 221 | + 215 | + 217 | + 216 | + 223 | + +taos> select GREATEST(nch1, nch2, var1, var2) from ts_4893.meters order by ts limit 10; + greatest(nch1, nch2, var1, var2) | +=================================== + 四 | + 三a | + 四 | + 一 | + 一二三四五六七八九十 | + 一二三 | + prision | + 一二三四五六七八九十 | + prision | + 一 | + +taos> select GREATEST(221, voltage) from ts_4893.meters order by ts limit 10; + greatest(221, voltage) | +========================= + 221 | + 221 | + 221 | + 221 | + 221 | + 221 | + 221 | + 221 | + 221 | + 223 | + +taos> select GREATEST(5, id) from ts_4893.meters order by ts limit 10; + greatest(5, id) | +======================== + 5 | + 5 | + 5 | + 5 | + 5 | + 5 | + 6 | + 7 | + 8 | + 9 | + +taos> select GREATEST('r', nch1) from ts_4893.meters order by ts limit 10; + greatest('r', nch1) | +================================= + r | + 一二三四五六七八九十 | + update | + r | + r | + r | + r | + 一二三四五六七八九十 | + r | + r | + +taos> select GREATEST('r', nch1, nch2) from ts_4893.meters order by ts limit 10; + greatest('r', nch1, nch2) | +================================= + 四 | + 一二三四五六七八九十 | + update | + 一 | + r | + 一二三 | + r | + 一二三四五六七八九十 | + r | + r | + +taos> select GREATEST('r', var1) from ts_4893.meters order by ts limit 10; + greatest('r', var1) | +================================= + r | + r | + r | + r | + 一二三四五六七八九十 | + update | + r | + r | + r | + r | + +taos> select GREATEST('r', var1, var2) from ts_4893.meters order by ts limit 10; + greatest('r', var1, var2) | +================================= + r | + 三a | + 四 | + r | + 一二三四五六七八九十 | + update | + r | + r | + r | + 一 | + +taos> select GREATEST('二中文测试', nch1) from ts_4893.meters order by ts limit 10; + greatest('二中文测试', nch1) | +==================================== + 二中文测试 | + 二中文测试 | + 二中文测试 | + 二中文测试 | + 二中文测试 | + 二中文测试 | + 二中文测试 | + 二中文测试 | + 二中文测试 | + 二中文测试 | + +taos> select GREATEST('二中文测试', nch1, nch2) from ts_4893.meters order by ts limit 10; + greatest('二中文测试', nch1, nch2) | +========================================== + 四 | + 二中文测试 | + 二中文测试 | + 二中文测试 | + 二中文测试 | + 二中文测试 | + 二中文测试 | + 二中文测试 | + 二中文测试 | + 二中文测试 | + +taos> select GREATEST('二中文测试', var1) from ts_4893.meters order by ts limit 10; + greatest('二中文测试', var1) | +==================================== + 二中文测试 | + 二中文测试 | + 二中文测试 | + 二中文测试 | + 二中文测试 | + 二中文测试 | + 二中文测试 | + 二中文测试 | + 二中文测试 | + 二中文测试 | + +taos> select GREATEST('二中文测试', var1, var2) from ts_4893.meters order by ts limit 10; + greatest('二中文测试', var1, var2) | +========================================== + 二中文测试 | + 二中文测试 | + 四 | + 二中文测试 | + 二中文测试 | + 二中文测试 | + 二中文测试 | + 二中文测试 | + 二中文测试 | + 二中文测试 | + +taos> select GREATEST('23', 3443434343434343); + greatest('23', 3443434343434343) | +=================================== + 3443434343434343 | + +taos> select GREATEST(co, 3443434343434343) from ts_4893.n1; + greatest(co, 3443434343434343) | +================================= + 3443434343434343 | + 3443434343434343 | + 3443434343434343 | + +taos> select GREATEST('23', 3443434343434343) from ts_4893.n1; + greatest('23', 3443434343434343) | +=================================== + 3443434343434343 | + 3443434343434343 | + 3443434343434343 | + +taos> select GREATEST('23', 1443434343434343) from ts_4893.n1; + greatest('23', 1443434343434343) | +=================================== + 23 | + 23 | + 23 | + +taos> select GREATEST(current, voltage) from ts_4893.n1; + greatest(current, voltage) | +============================= + NULL | + NULL | + 5 | + +taos> select GREATEST(current, voltage, '15') from ts_4893.n1; + greatest(current, voltage, '15') | +=================================== + NULL | + NULL | + 5.000000 | + +taos> alter local 'transToStrWhenMixTypeInLeast' '0'; + +taos> select GREATEST(1,'2',3.3,4.4,5); + greatest(1,'2',3.3,4.4,5) | +============================ + 5 | + +taos> select GREATEST(1,2,3,4,5,'5.1'); + greatest(1,2,3,4,5,'5.1') | +============================ + 5 | + +taos> select GREATEST(121,'18'); + greatest(121,'18') | +======================== + 121 | + +taos> select GREATEST('1','2','3','4','5'); + greatest('1','2','3','4','5') | +================================ + 5 | + +taos> select GREATEST(1,2,3,4,5,6,7,'a','b','一','二','三'); + greatest(1,2,3,4,5,6,7,'a','b','一','二','三') | +==================================================== + 7 | + +taos> select GREATEST(1,2,3,4,5,6,7,'a','b','c','1','2','1231213'); + greatest(1,2,3,4,5,6,7,'a','b','c','1','2','1231213') | +======================================================== + 1231213 | + +taos> select GREATEST(1,2,3,4,5,6,7,'a','b','c','1','2','1231213','1231213.123123'); + greatest(1,2,3,4,5,6,7,'a','b','c','1','2','1231213','1231213.12 | +=================================================================== + 1231213 | + +taos> select GREATEST(cast(0 as bool), cast(1 as tinyint), cast(2 as smallint), cast(3 as int), cast(4 as bigint), cast(5 as float), cast(6 as double), cast(8 as varchar(20)), cast(9 as nchar(20))); + greatest(cast(0 as bool), cast(1 as tinyint), cast(2 as smallint | +=================================================================== + 9 | + +taos> select GREATEST(cast(0 as bool), cast(1 as tinyint unsigned), cast(2 as smallint unsigned), cast(3 as int unsigned), cast(4 as bigint unsigned), cast(5 as float), cast(6 as double), cast(8 as varchar(20)), cast(9 as nchar(20))); + greatest(cast(0 as bool), cast(1 as tinyint unsigned), cast(2 as | +=================================================================== + 9 | + +taos> select GREATEST(cast(0 as bool), cast(1 as tinyint), cast(2 as smallint), cast(3 as int), cast(4 as bigint), cast(5 as float), cast(6 as double), cast(8 as varchar(20)), cast(9 as nchar(20)), cast(0 as bool), cast(1 as tinyint unsigned), cast(2 as smallint unsigned), cast(3 as int unsigned), cast(4 as bigint unsigned), cast(5 as float), cast(6 as double)); + greatest(cast(0 as bool), cast(1 as tinyint), cast(2 as smallint | +=================================================================== + 9 | + +taos> select GREATEST(cast(100 as tinyint), cast(101 as tinyint)); + greatest(cast(100 as tinyint), cast(101 as tinyint)) | +======================================================= + 101 | + +taos> select GREATEST(cast(100 as tinyint), cast(101 as smallint)); + greatest(cast(100 as tinyint), cast(101 as smallint)) | +======================================================== + 101 | + +taos> select GREATEST(cast(100 as tinyint), cast(101 as int)); + greatest(cast(100 as tinyint), cast(101 as int)) | +=================================================== + 101 | + +taos> select GREATEST(cast(100 as tinyint), cast(101 as bigint)); + greatest(cast(100 as tinyint), cast(101 as bigint)) | +====================================================== + 101 | + +taos> select GREATEST(cast(100 as tinyint), cast(101 as float)); + greatest(cast(100 as tinyint), cast(101 as float)) | +===================================================== + 101 | + +taos> select GREATEST(cast(100 as tinyint), cast(101 as double)); + greatest(cast(100 as tinyint), cast(101 as double)) | +====================================================== + 101 | + +taos> select GREATEST(cast(100 as tinyint), cast(101 as varchar(20))); + greatest(cast(100 as tinyint), cast(101 as varchar(20))) | +=========================================================== + 101 | + +taos> select GREATEST(cast(100 as tinyint), cast(101 as nchar(20))); + greatest(cast(100 as tinyint), cast(101 as nchar(20))) | +========================================================= + 101 | + +taos> select GREATEST(cast(101 as tinyint), cast(100 as tinyint)); + greatest(cast(101 as tinyint), cast(100 as tinyint)) | +======================================================= + 101 | + +taos> select GREATEST(cast(101 as tinyint), cast(100 as smallint)); + greatest(cast(101 as tinyint), cast(100 as smallint)) | +======================================================== + 101 | + +taos> select GREATEST(cast(101 as tinyint), cast(100 as int)); + greatest(cast(101 as tinyint), cast(100 as int)) | +=================================================== + 101 | + +taos> select GREATEST(cast(101 as tinyint), cast(100 as bigint)); + greatest(cast(101 as tinyint), cast(100 as bigint)) | +====================================================== + 101 | + +taos> select GREATEST(cast(101 as tinyint), cast(100 as float)); + greatest(cast(101 as tinyint), cast(100 as float)) | +===================================================== + 101 | + +taos> select GREATEST(cast(101 as tinyint), cast(100 as double)); + greatest(cast(101 as tinyint), cast(100 as double)) | +====================================================== + 101 | + +taos> select GREATEST(cast(101 as tinyint), cast(100 as varchar(20))); + greatest(cast(101 as tinyint), cast(100 as varchar(20))) | +=========================================================== + 101 | + +taos> select GREATEST(cast(101 as tinyint), cast(100 as nchar(20))); + greatest(cast(101 as tinyint), cast(100 as nchar(20))) | +========================================================= + 101 | + +taos> select GREATEST(cast(1000 as smallint), cast(1001 as smallint)); + greatest(cast(1000 as smallint), cast(1001 as smallint)) | +=========================================================== + 1001 | + +taos> select GREATEST(cast(1000 as smallint), cast(1001 as int)); + greatest(cast(1000 as smallint), cast(1001 as int)) | +====================================================== + 1001 | + +taos> select GREATEST(cast(1000 as smallint), cast(1001 as bigint)); + greatest(cast(1000 as smallint), cast(1001 as bigint)) | +========================================================= + 1001 | + +taos> select GREATEST(cast(1000 as smallint), cast(1001 as float)); + greatest(cast(1000 as smallint), cast(1001 as float)) | +======================================================== + 1001 | + +taos> select GREATEST(cast(1000 as smallint), cast(1001 as double)); + greatest(cast(1000 as smallint), cast(1001 as double)) | +========================================================= + 1001 | + +taos> select GREATEST(cast(1000 as smallint), cast(1001 as varchar(20))); + greatest(cast(1000 as smallint), cast(1001 as varchar(20))) | +============================================================== + 1001 | + +taos> select GREATEST(cast(1000 as smallint), cast(1001 as nchar(20))); + greatest(cast(1000 as smallint), cast(1001 as nchar(20))) | +============================================================ + 1001 | + +taos> select GREATEST(cast(1001 as smallint), cast(1000 as smallint)); + greatest(cast(1001 as smallint), cast(1000 as smallint)) | +=========================================================== + 1001 | + +taos> select GREATEST(cast(1001 as smallint), cast(1000 as int)); + greatest(cast(1001 as smallint), cast(1000 as int)) | +====================================================== + 1001 | + +taos> select GREATEST(cast(1001 as smallint), cast(1000 as bigint)); + greatest(cast(1001 as smallint), cast(1000 as bigint)) | +========================================================= + 1001 | + +taos> select GREATEST(cast(1001 as smallint), cast(1000 as float)); + greatest(cast(1001 as smallint), cast(1000 as float)) | +======================================================== + 1001 | + +taos> select GREATEST(cast(1001 as smallint), cast(1000 as double)); + greatest(cast(1001 as smallint), cast(1000 as double)) | +========================================================= + 1001 | + +taos> select GREATEST(cast(1001 as smallint), cast(1000 as varchar(20))); + greatest(cast(1001 as smallint), cast(1000 as varchar(20))) | +============================================================== + 1001 | + +taos> select GREATEST(cast(1001 as smallint), cast(1000 as nchar(20))); + greatest(cast(1001 as smallint), cast(1000 as nchar(20))) | +============================================================ + 1001 | + +taos> select GREATEST(cast(1000000 as int), cast(1000001 as int)); + greatest(cast(1000000 as int), cast(1000001 as int)) | +======================================================= + 1000001 | + +taos> select GREATEST(cast(1000000 as int), cast(1000001 as bigint)); + greatest(cast(1000000 as int), cast(1000001 as bigint)) | +========================================================== + 1000001 | + +taos> select GREATEST(cast(1000000 as int), cast(1000001 as float)); + greatest(cast(1000000 as int), cast(1000001 as float)) | +========================================================= + 1e+06 | + +taos> select GREATEST(cast(1000000 as int), cast(1000001 as double)); + greatest(cast(1000000 as int), cast(1000001 as double)) | +========================================================== + 1000001 | + +taos> select GREATEST(cast(1000000 as int), cast(1000001 as varchar(20))); + greatest(cast(1000000 as int), cast(1000001 as varchar(20))) | +=============================================================== + 1000001 | + +taos> select GREATEST(cast(1000000 as int), cast(1000001 as nchar(20))); + greatest(cast(1000000 as int), cast(1000001 as nchar(20))) | +============================================================= + 1000001 | + +taos> select GREATEST(cast(1000001 as int), cast(1000000 as int)); + greatest(cast(1000001 as int), cast(1000000 as int)) | +======================================================= + 1000001 | + +taos> select GREATEST(cast(1000001 as int), cast(1000000 as bigint)); + greatest(cast(1000001 as int), cast(1000000 as bigint)) | +========================================================== + 1000001 | + +taos> select GREATEST(cast(1000001 as int), cast(1000000 as float)); + greatest(cast(1000001 as int), cast(1000000 as float)) | +========================================================= + 1e+06 | + +taos> select GREATEST(cast(1000001 as int), cast(1000000 as double)); + greatest(cast(1000001 as int), cast(1000000 as double)) | +========================================================== + 1000001 | + +taos> select GREATEST(cast(1000001 as int), cast(1000000 as varchar(20))); + greatest(cast(1000001 as int), cast(1000000 as varchar(20))) | +=============================================================== + 1000001 | + +taos> select GREATEST(cast(1000001 as int), cast(1000000 as nchar(20))); + greatest(cast(1000001 as int), cast(1000000 as nchar(20))) | +============================================================= + 1000001 | + +taos> select GREATEST(cast(1000000000 as bigint), cast(1000000001 as bigint)); + greatest(cast(1000000000 as bigint), cast(1000000001 as bigint)) | +=================================================================== + 1000000001 | + +taos> select GREATEST(cast(1000000000 as bigint), cast(1000000001 as float)); + greatest(cast(1000000000 as bigint), cast(1000000001 as float)) | +================================================================== + 1e+09 | + +taos> select GREATEST(cast(1000000000 as bigint), cast(1000000001 as double)); + greatest(cast(1000000000 as bigint), cast(1000000001 as double)) | +=================================================================== + 1000000001 | + +taos> select GREATEST(cast(1000000000 as bigint), cast(1000000001 as varchar(20))); + greatest(cast(1000000000 as bigint), cast(1000000001 as varchar( | +=================================================================== + 1000000001 | + +taos> select GREATEST(cast(1000000000 as bigint), cast(1000000001 as nchar(20))); + greatest(cast(1000000000 as bigint), cast(1000000001 as nchar(20 | +=================================================================== + 1000000001 | + +taos> select GREATEST(cast(1000000001 as bigint), cast(1000000000 as bigint)); + greatest(cast(1000000001 as bigint), cast(1000000000 as bigint)) | +=================================================================== + 1000000001 | + +taos> select GREATEST(cast(1000000001 as bigint), cast(1000000000 as float)); + greatest(cast(1000000001 as bigint), cast(1000000000 as float)) | +================================================================== + 1e+09 | + +taos> select GREATEST(cast(1000000001 as bigint), cast(1000000000 as double)); + greatest(cast(1000000001 as bigint), cast(1000000000 as double)) | +=================================================================== + 1000000001 | + +taos> select GREATEST(cast(1000000001 as bigint), cast(1000000000 as varchar(20))); + greatest(cast(1000000001 as bigint), cast(1000000000 as varchar( | +=================================================================== + 1000000001 | + +taos> select GREATEST(cast(1000000001 as bigint), cast(1000000000 as nchar(20))); + greatest(cast(1000000001 as bigint), cast(1000000000 as nchar(20 | +=================================================================== + 1000000001 | + +taos> select GREATEST(cast(100000.1111111 as float), cast(100001.1111111 as float)); + greatest(cast(100000.1111111 as float), cast(100001.1111111 as f | +=================================================================== + 100001 | + +taos> select GREATEST(cast(100000.1111111 as float), cast(100001.1111111 as double)); + greatest(cast(100000.1111111 as float), cast(100001.1111111 as d | +=================================================================== + 100001.1111111 | + +taos> select GREATEST(cast(100000.1111111 as float), cast(100001.1111111 as timestamp)); + greatest(cast(100000.1111111 as float), cast(100001.1111111 as t | +=================================================================== + 100001 | + +taos> select GREATEST(cast(100000.1111111 as float), cast(100001.1111111 as varchar(20))); + greatest(cast(100000.1111111 as float), cast(100001.1111111 as v | +=================================================================== + 100001 | + +taos> select GREATEST(cast(100000.1111111 as float), cast(100001.1111111 as nchar(20))); + greatest(cast(100000.1111111 as float), cast(100001.1111111 as n | +=================================================================== + 100001 | + +taos> select GREATEST(cast(100001.1111111 as float), cast(100000.1111111 as float)); + greatest(cast(100001.1111111 as float), cast(100000.1111111 as f | +=================================================================== + 100001 | + +taos> select GREATEST(cast(100001.1111111 as float), cast(100000.1111111 as double)); + greatest(cast(100001.1111111 as float), cast(100000.1111111 as d | +=================================================================== + 100001.109375 | + +taos> select GREATEST(cast(100001.1111111 as float), cast(100000.1111111 as timestamp)); + greatest(cast(100001.1111111 as float), cast(100000.1111111 as t | +=================================================================== + 100001 | + +taos> select GREATEST(cast(100001.1111111 as float), cast(100000.1111111 as varchar(20))); + greatest(cast(100001.1111111 as float), cast(100000.1111111 as v | +=================================================================== + 100001 | + +taos> select GREATEST(cast(100001.1111111 as float), cast(100000.1111111 as nchar(20))); + greatest(cast(100001.1111111 as float), cast(100000.1111111 as n | +=================================================================== + 100001 | + +taos> select GREATEST(cast(100000.1111111 as double), cast(100001.1111111 as double)); + greatest(cast(100000.1111111 as double), cast(100001.1111111 as | +=================================================================== + 100001.1111111 | + +taos> select GREATEST(cast(100000.1111111 as double), cast(100001.1111111 as timestamp)); + greatest(cast(100000.1111111 as double), cast(100001.1111111 as | +=================================================================== + 100001 | + +taos> select GREATEST(cast(100000.1111111 as double), cast(100001.1111111 as varchar(20))); + greatest(cast(100000.1111111 as double), cast(100001.1111111 as | +=================================================================== + 100001.1111111 | + +taos> select GREATEST(cast(100000.1111111 as double), cast(100001.1111111 as nchar(20))); + greatest(cast(100000.1111111 as double), cast(100001.1111111 as | +=================================================================== + 100001.1111111 | + +taos> select GREATEST(cast(100001.1111111 as double), cast(100000.1111111 as double)); + greatest(cast(100001.1111111 as double), cast(100000.1111111 as | +=================================================================== + 100001.1111111 | + +taos> select GREATEST(cast(100001.1111111 as double), cast(100000.1111111 as timestamp)); + greatest(cast(100001.1111111 as double), cast(100000.1111111 as | +=================================================================== + 100001.1111111 | + +taos> select GREATEST(cast(100001.1111111 as double), cast(100000.1111111 as varchar(20))); + greatest(cast(100001.1111111 as double), cast(100000.1111111 as | +=================================================================== + 100001.1111111 | + +taos> select GREATEST(cast(100001.1111111 as double), cast(100000.1111111 as nchar(20))); + greatest(cast(100001.1111111 as double), cast(100000.1111111 as | +=================================================================== + 100001.1111111 | + +taos> select GREATEST(cast('中文测试' as varchar(20)), cast('中文测试一' as varchar(20))); + greatest(cast('中文测试' as varchar(20)), cast('中文测试 | +=================================================================== + 中文测试一 | + +taos> select GREATEST(cast('中文测试' as varchar(20)), cast('中文测试一' as nchar(20))); + greatest(cast('中文测试' as varchar(20)), cast('中文测试 | +=================================================================== + 中文测试一 | + +taos> select GREATEST(cast('中文测试一' as varchar(20)), cast('中文测试' as varchar(20))); + greatest(cast('中文测试一' as varchar(20)), cast('中文测 | +=================================================================== + 中文测试一 | + +taos> select GREATEST(cast('中文测试一' as varchar(20)), cast('中文测试' as nchar(20))); + greatest(cast('中文测试一' as varchar(20)), cast('中文测 | +=================================================================== + 中文测试一 | + +taos> select GREATEST(cast('abc123abc' as varchar(20)), cast('abc124abc' as varchar(20))); + greatest(cast('abc123abc' as varchar(20)), cast('abc124abc' as v | +=================================================================== + abc124abc | + +taos> select GREATEST(cast('abc123abc' as varchar(20)), cast('abc124abc' as nchar(20))); + greatest(cast('abc123abc' as varchar(20)), cast('abc124abc' as n | +=================================================================== + abc124abc | + +taos> select GREATEST(cast('abc124abc' as varchar(20)), cast('abc123abc' as varchar(20))); + greatest(cast('abc124abc' as varchar(20)), cast('abc123abc' as v | +=================================================================== + abc124abc | + +taos> select GREATEST(cast('abc124abc' as varchar(20)), cast('abc123abc' as nchar(20))); + greatest(cast('abc124abc' as varchar(20)), cast('abc123abc' as n | +=================================================================== + abc124abc | + +taos> select GREATEST(cast('abc123abc' as nchar(20)), cast('abc124abc' as nchar(20))); + greatest(cast('abc123abc' as nchar(20)), cast('abc124abc' as nch | +=================================================================== + abc124abc | + +taos> select GREATEST(cast(100 as tinyint), cast(101 as float), cast(102 as varchar(20))); + greatest(cast(100 as tinyint), cast(101 as float), cast(102 as v | +=================================================================== + 102 | + +taos> select GREATEST(cast(100 as float), cast(101 as tinyint), cast(102 as varchar(20))); + greatest(cast(100 as float), cast(101 as tinyint), cast(102 as v | +=================================================================== + 102 | + +taos> select GREATEST(cast(100 as float), cast(101 as varchar(20)), cast(102 as tinyint)); + greatest(cast(100 as float), cast(101 as varchar(20)), cast(102 | +=================================================================== + 102 | + +taos> select GREATEST(cast(100 as varchar(20)), cast(101 as float), cast(102 as tinyint)); + greatest(cast(100 as varchar(20)), cast(101 as float), cast(102 | +=================================================================== + 102 | + +taos> select GREATEST('a','b','c','d','e','f','g','h','1231','15155'); + greatest('a','b','c','d','e','f','g','h','1231','15155') | +=========================================================== + h | + +taos> select GREATEST(current, voltage, phase, id, nch1, nch2, var1, var2) from ts_4893.meters order by ts limit 10; + greatest(current, voltage, phase, id, nch1, nch2, var1, var2) | +================================================================ + 221 | + 220 | + 215 | + 216 | + 219 | + 221 | + 215 | + 217 | + 216 | + 223 | + +taos> select GREATEST(current, voltage, phase, id) from ts_4893.meters order by ts limit 10; + greatest(current, voltage, phase, id) | +======================================== + 221 | + 220 | + 215 | + 216 | + 219 | + 221 | + 215 | + 217 | + 216 | + 223 | + +taos> select GREATEST(nch1, nch2, var1, var2) from ts_4893.meters order by ts limit 10; + greatest(nch1, nch2, var1, var2) | +=================================== + 四 | + 三a | + 四 | + 一 | + 一二三四五六七八九十 | + 一二三 | + prision | + 一二三四五六七八九十 | + prision | + 一 | + +taos> select GREATEST(221, voltage) from ts_4893.meters order by ts limit 10; + greatest(221, voltage) | +========================= + 221 | + 221 | + 221 | + 221 | + 221 | + 221 | + 221 | + 221 | + 221 | + 223 | + +taos> select GREATEST(5, id) from ts_4893.meters order by ts limit 10; + greatest(5, id) | +======================== + 5 | + 5 | + 5 | + 5 | + 5 | + 5 | + 6 | + 7 | + 8 | + 9 | + +taos> select GREATEST('r', nch1) from ts_4893.meters order by ts limit 10; + greatest('r', nch1) | +================================= + r | + 一二三四五六七八九十 | + update | + r | + r | + r | + r | + 一二三四五六七八九十 | + r | + r | + +taos> select GREATEST('r', nch1, nch2) from ts_4893.meters order by ts limit 10; + greatest('r', nch1, nch2) | +================================= + 四 | + 一二三四五六七八九十 | + update | + 一 | + r | + 一二三 | + r | + 一二三四五六七八九十 | + r | + r | + +taos> select GREATEST('r', var1) from ts_4893.meters order by ts limit 10; + greatest('r', var1) | +================================= + r | + r | + r | + r | + 一二三四五六七八九十 | + update | + r | + r | + r | + r | + +taos> select GREATEST('r', var1, var2) from ts_4893.meters order by ts limit 10; + greatest('r', var1, var2) | +================================= + r | + 三a | + 四 | + r | + 一二三四五六七八九十 | + update | + r | + r | + r | + 一 | + +taos> select GREATEST('二中文测试', nch1) from ts_4893.meters order by ts limit 10; + greatest('二中文测试', nch1) | +==================================== + 二中文测试 | + 二中文测试 | + 二中文测试 | + 二中文测试 | + 二中文测试 | + 二中文测试 | + 二中文测试 | + 二中文测试 | + 二中文测试 | + 二中文测试 | + +taos> select GREATEST('二中文测试', nch1, nch2) from ts_4893.meters order by ts limit 10; + greatest('二中文测试', nch1, nch2) | +========================================== + 四 | + 二中文测试 | + 二中文测试 | + 二中文测试 | + 二中文测试 | + 二中文测试 | + 二中文测试 | + 二中文测试 | + 二中文测试 | + 二中文测试 | + +taos> select GREATEST('二中文测试', var1) from ts_4893.meters order by ts limit 10; + greatest('二中文测试', var1) | +==================================== + 二中文测试 | + 二中文测试 | + 二中文测试 | + 二中文测试 | + 二中文测试 | + 二中文测试 | + 二中文测试 | + 二中文测试 | + 二中文测试 | + 二中文测试 | + +taos> select GREATEST('二中文测试', var1, var2) from ts_4893.meters order by ts limit 10; + greatest('二中文测试', var1, var2) | +========================================== + 二中文测试 | + 二中文测试 | + 四 | + 二中文测试 | + 二中文测试 | + 二中文测试 | + 二中文测试 | + 二中文测试 | + 二中文测试 | + 二中文测试 | + +taos> select GREATEST('23', 3443434343434343); + greatest('23', 3443434343434343) | +=================================== + 3443434343434343 | + +taos> select GREATEST(co, 3443434343434343) from ts_4893.n1; + greatest(co, 3443434343434343) | +================================= + 3443434343434343 | + 3443434343434343 | + 3443434343434343 | + +taos> select GREATEST('23', 1443434343434343) from ts_4893.n1; + greatest('23', 1443434343434343) | +=================================== + 1443434343434343 | + 1443434343434343 | + 1443434343434343 | + +taos> select GREATEST('23', 3443434343434343) from ts_4893.n1 + greatest('23', 3443434343434343) | +=================================== + 3443434343434343 | + 3443434343434343 | + 3443434343434343 | + +taos> select GREATEST(current, voltage) from ts_4893.n1; + greatest(current, voltage) | +============================= + NULL | + NULL | + 5 | + +taos> select GREATEST(current, voltage, '15') from ts_4893.n1; + greatest(current, voltage, '15') | +=================================== + NULL | + NULL | + 15 | + diff --git a/tests/army/query/function/ans/least.csv b/tests/army/query/function/ans/least.csv new file mode 100644 index 0000000000..e1ee1095ce --- /dev/null +++ b/tests/army/query/function/ans/least.csv @@ -0,0 +1,1389 @@ + +taos> alter local 'transToStrWhenMixTypeInLeast' '1'; + +taos> select LEAST(1,2,3,4,5,6,7,8,9,10); + least(1,2,3,4,5,6,7,8,9,10) | +============================== + 1 | + +taos> select LEAST(1,1.1,2.23,3.4444,5.66666666,6.21241241,7.999999999999); + least(1,1.1,2.23,3.4444,5.66666666,6.21241241,7.999999999999) | +================================================================ + 1 | + +taos> select LEAST(1,'2',3.3,4.4,5); + least(1,'2',3.3,4.4,5) | +============================ + 1 | + +taos> select LEAST(1,2,3,4,5,'5.1'); + least(1,2,3,4,5,'5.1') | +============================ + 1 | + +taos> select LEAST('1','2','3','4',5); + least('1','2','3','4',5) | +============================ + 1 | + +taos> select LEAST('1','2','3','4','5'); + least('1','2','3','4','5') | +============================= + 1 | + +taos> select LEAST(1,2,3,4,5,6,7,'a','b','一','二','三'); + least(1,2,3,4,5,6,7,'a','b','一','二','三') | +================================================= + 1 | + +taos> select LEAST(1,2,3,4,5,6,7,'a','b','c','1','2','1231213'); + least(1,2,3,4,5,6,7,'a','b','c','1','2','1231213') | +===================================================== + 1 | + +taos> select LEAST(1,2,3,4,5,6,7,'a','b','c','1','2','1231213','1231213.123123'); + least(1,2,3,4,5,6,7,'a','b','c','1','2','1231213','1231213.12312 | +=================================================================== + 1 | + +taos> select LEAST(cast(0 as bool), cast(1 as tinyint), cast(2 as smallint), cast(3 as int), cast(4 as bigint), cast(5 as float), cast(6 as double), cast(8 as varchar(20)), cast(9 as nchar(20))); + least(cast(0 as bool), cast(1 as tinyint), cast(2 as smallint), | +=================================================================== + 0 | + +taos> select LEAST(cast(0 as bool), cast(1 as tinyint unsigned), cast(2 as smallint unsigned), cast(3 as int unsigned), cast(4 as bigint unsigned), cast(5 as float), cast(6 as double), cast(8 as varchar(20)), cast(9 as nchar(20))); + least(cast(0 as bool), cast(1 as tinyint unsigned), cast(2 as sm | +=================================================================== + 0 | + +taos> select LEAST(cast(0 as bool), cast(1 as tinyint), cast(2 as smallint), cast(3 as int), cast(4 as bigint), cast(5 as float), cast(6 as double), cast(8 as varchar(20)), cast(9 as nchar(20)), cast(0 as bool), cast(1 as tinyint unsigned), cast(2 as smallint unsigned), cast(3 as int unsigned), cast(4 as bigint unsigned), cast(5 as float), cast(6 as double)); + least(cast(0 as bool), cast(1 as tinyint), cast(2 as smallint), | +=================================================================== + 0 | + +taos> select LEAST(cast(100 as tinyint), cast(101 as tinyint)); + least(cast(100 as tinyint), cast(101 as tinyint)) | +==================================================== + 100 | + +taos> select LEAST(cast(100 as tinyint), cast(101 as smallint)); + least(cast(100 as tinyint), cast(101 as smallint)) | +===================================================== + 100 | + +taos> select LEAST(cast(100 as tinyint), cast(101 as int)); + least(cast(100 as tinyint), cast(101 as int)) | +================================================ + 100 | + +taos> select LEAST(cast(100 as tinyint), cast(101 as bigint)); + least(cast(100 as tinyint), cast(101 as bigint)) | +=================================================== + 100 | + +taos> select LEAST(cast(100 as tinyint), cast(101 as float)); + least(cast(100 as tinyint), cast(101 as float)) | +================================================== + 100 | + +taos> select LEAST(cast(100 as tinyint), cast(101 as double)); + least(cast(100 as tinyint), cast(101 as double)) | +=================================================== + 100 | + +taos> select LEAST(cast(100 as tinyint), cast(101 as varchar(20))); + least(cast(100 as tinyint), cast(101 as varchar(20))) | +======================================================== + 100 | + +taos> select LEAST(cast(100 as tinyint), cast(101 as nchar(20))); + least(cast(100 as tinyint), cast(101 as nchar(20))) | +====================================================== + 100 | + +taos> select LEAST(cast(101 as tinyint), cast(100 as tinyint)); + least(cast(101 as tinyint), cast(100 as tinyint)) | +==================================================== + 100 | + +taos> select LEAST(cast(101 as tinyint), cast(100 as smallint)); + least(cast(101 as tinyint), cast(100 as smallint)) | +===================================================== + 100 | + +taos> select LEAST(cast(101 as tinyint), cast(100 as int)); + least(cast(101 as tinyint), cast(100 as int)) | +================================================ + 100 | + +taos> select LEAST(cast(101 as tinyint), cast(100 as bigint)); + least(cast(101 as tinyint), cast(100 as bigint)) | +=================================================== + 100 | + +taos> select LEAST(cast(101 as tinyint), cast(100 as float)); + least(cast(101 as tinyint), cast(100 as float)) | +================================================== + 100 | + +taos> select LEAST(cast(101 as tinyint), cast(100 as double)); + least(cast(101 as tinyint), cast(100 as double)) | +=================================================== + 100 | + +taos> select LEAST(cast(101 as tinyint), cast(100 as varchar(20))); + least(cast(101 as tinyint), cast(100 as varchar(20))) | +======================================================== + 100 | + +taos> select LEAST(cast(101 as tinyint), cast(100 as nchar(20))); + least(cast(101 as tinyint), cast(100 as nchar(20))) | +====================================================== + 100 | + +taos> select LEAST(cast(1000 as smallint), cast(1001 as smallint)); + least(cast(1000 as smallint), cast(1001 as smallint)) | +======================================================== + 1000 | + +taos> select LEAST(cast(1000 as smallint), cast(1001 as int)); + least(cast(1000 as smallint), cast(1001 as int)) | +=================================================== + 1000 | + +taos> select LEAST(cast(1000 as smallint), cast(1001 as bigint)); + least(cast(1000 as smallint), cast(1001 as bigint)) | +====================================================== + 1000 | + +taos> select LEAST(cast(1000 as smallint), cast(1001 as float)); + least(cast(1000 as smallint), cast(1001 as float)) | +===================================================== + 1000 | + +taos> select LEAST(cast(1000 as smallint), cast(1001 as double)); + least(cast(1000 as smallint), cast(1001 as double)) | +====================================================== + 1000 | + +taos> select LEAST(cast(1000 as smallint), cast(1001 as varchar(20))); + least(cast(1000 as smallint), cast(1001 as varchar(20))) | +=========================================================== + 1000 | + +taos> select LEAST(cast(1000 as smallint), cast(1001 as nchar(20))); + least(cast(1000 as smallint), cast(1001 as nchar(20))) | +========================================================= + 1000 | + +taos> select LEAST(cast(1001 as smallint), cast(1000 as smallint)); + least(cast(1001 as smallint), cast(1000 as smallint)) | +======================================================== + 1000 | + +taos> select LEAST(cast(1001 as smallint), cast(1000 as int)); + least(cast(1001 as smallint), cast(1000 as int)) | +=================================================== + 1000 | + +taos> select LEAST(cast(1001 as smallint), cast(1000 as bigint)); + least(cast(1001 as smallint), cast(1000 as bigint)) | +====================================================== + 1000 | + +taos> select LEAST(cast(1001 as smallint), cast(1000 as float)); + least(cast(1001 as smallint), cast(1000 as float)) | +===================================================== + 1000 | + +taos> select LEAST(cast(1001 as smallint), cast(1000 as double)); + least(cast(1001 as smallint), cast(1000 as double)) | +====================================================== + 1000 | + +taos> select LEAST(cast(1001 as smallint), cast(1000 as varchar(20))); + least(cast(1001 as smallint), cast(1000 as varchar(20))) | +=========================================================== + 1000 | + +taos> select LEAST(cast(1001 as smallint), cast(1000 as nchar(20))); + least(cast(1001 as smallint), cast(1000 as nchar(20))) | +========================================================= + 1000 | + +taos> select LEAST(cast(1000000 as int), cast(1000001 as int)); + least(cast(1000000 as int), cast(1000001 as int)) | +==================================================== + 1000000 | + +taos> select LEAST(cast(1000000 as int), cast(1000001 as bigint)); + least(cast(1000000 as int), cast(1000001 as bigint)) | +======================================================= + 1000000 | + +taos> select LEAST(cast(1000000 as int), cast(1000001 as float)); + least(cast(1000000 as int), cast(1000001 as float)) | +====================================================== + 1e+06 | + +taos> select LEAST(cast(1000000 as int), cast(1000001 as double)); + least(cast(1000000 as int), cast(1000001 as double)) | +======================================================= + 1000000 | + +taos> select LEAST(cast(1000000 as int), cast(1000001 as varchar(20))); + least(cast(1000000 as int), cast(1000001 as varchar(20))) | +============================================================ + 1000000 | + +taos> select LEAST(cast(1000000 as int), cast(1000001 as nchar(20))); + least(cast(1000000 as int), cast(1000001 as nchar(20))) | +========================================================== + 1000000 | + +taos> select LEAST(cast(1000001 as int), cast(1000000 as int)); + least(cast(1000001 as int), cast(1000000 as int)) | +==================================================== + 1000000 | + +taos> select LEAST(cast(1000001 as int), cast(1000000 as bigint)); + least(cast(1000001 as int), cast(1000000 as bigint)) | +======================================================= + 1000000 | + +taos> select LEAST(cast(1000001 as int), cast(1000000 as float)); + least(cast(1000001 as int), cast(1000000 as float)) | +====================================================== + 1e+06 | + +taos> select LEAST(cast(1000001 as int), cast(1000000 as double)); + least(cast(1000001 as int), cast(1000000 as double)) | +======================================================= + 1000000 | + +taos> select LEAST(cast(1000001 as int), cast(1000000 as varchar(20))); + least(cast(1000001 as int), cast(1000000 as varchar(20))) | +============================================================ + 1000000 | + +taos> select LEAST(cast(1000001 as int), cast(1000000 as nchar(20))); + least(cast(1000001 as int), cast(1000000 as nchar(20))) | +========================================================== + 1000000 | + +taos> select LEAST(cast(1000000000 as bigint), cast(1000000001 as bigint)); + least(cast(1000000000 as bigint), cast(1000000001 as bigint)) | +================================================================ + 1000000000 | + +taos> select LEAST(cast(1000000000 as bigint), cast(1000000001 as float)); + least(cast(1000000000 as bigint), cast(1000000001 as float)) | +=============================================================== + 1e+09 | + +taos> select LEAST(cast(1000000000 as bigint), cast(1000000001 as double)); + least(cast(1000000000 as bigint), cast(1000000001 as double)) | +================================================================ + 1000000000 | + +taos> select LEAST(cast(1000000000 as bigint), cast(1000000001 as varchar(20))); + least(cast(1000000000 as bigint), cast(1000000001 as varchar(20) | +=================================================================== + 1000000000 | + +taos> select LEAST(cast(1000000000 as bigint), cast(1000000001 as nchar(20))); + least(cast(1000000000 as bigint), cast(1000000001 as nchar(20))) | +=================================================================== + 1000000000 | + +taos> select LEAST(cast(1000000001 as bigint), cast(1000000000 as bigint)); + least(cast(1000000001 as bigint), cast(1000000000 as bigint)) | +================================================================ + 1000000000 | + +taos> select LEAST(cast(1000000001 as bigint), cast(1000000000 as float)); + least(cast(1000000001 as bigint), cast(1000000000 as float)) | +=============================================================== + 1e+09 | + +taos> select LEAST(cast(1000000001 as bigint), cast(1000000000 as double)); + least(cast(1000000001 as bigint), cast(1000000000 as double)) | +================================================================ + 1000000000 | + +taos> select LEAST(cast(1000000001 as bigint), cast(1000000000 as varchar(20))); + least(cast(1000000001 as bigint), cast(1000000000 as varchar(20) | +=================================================================== + 1000000000 | + +taos> select LEAST(cast(1000000001 as bigint), cast(1000000000 as nchar(20))); + least(cast(1000000001 as bigint), cast(1000000000 as nchar(20))) | +=================================================================== + 1000000000 | + +taos> select LEAST(cast(100000.1111111 as float), cast(100001.1111111 as float)); + least(cast(100000.1111111 as float), cast(100001.1111111 as floa | +=================================================================== + 100000 | + +taos> select LEAST(cast(100000.1111111 as float), cast(100001.1111111 as double)); + least(cast(100000.1111111 as float), cast(100001.1111111 as doub | +=================================================================== + 100000.109375 | + +taos> select LEAST(cast(100000.1111111 as float), cast(100001.1111111 as timestamp)); + least(cast(100000.1111111 as float), cast(100001.1111111 as time | +=================================================================== + 100000 | + +taos> select LEAST(cast(100000.1111111 as float), cast(100001.1111111 as varchar(20))); + least(cast(100000.1111111 as float), cast(100001.1111111 as varc | +=================================================================== + 100000.109375 | + +taos> select LEAST(cast(100000.1111111 as float), cast(100001.1111111 as nchar(20))); + least(cast(100000.1111111 as float), cast(100001.1111111 as ncha | +=================================================================== + 100000.109375 | + +taos> select LEAST(cast(100001.1111111 as float), cast(100000.1111111 as float)); + least(cast(100001.1111111 as float), cast(100000.1111111 as floa | +=================================================================== + 100000 | + +taos> select LEAST(cast(100001.1111111 as float), cast(100000.1111111 as double)); + least(cast(100001.1111111 as float), cast(100000.1111111 as doub | +=================================================================== + 100000.1111111 | + +taos> select LEAST(cast(100001.1111111 as float), cast(100000.1111111 as timestamp)); + least(cast(100001.1111111 as float), cast(100000.1111111 as time | +=================================================================== + 100000 | + +taos> select LEAST(cast(100001.1111111 as float), cast(100000.1111111 as varchar(20))); + least(cast(100001.1111111 as float), cast(100000.1111111 as varc | +=================================================================== + 100000.1111111 | + +taos> select LEAST(cast(100001.1111111 as float), cast(100000.1111111 as nchar(20))); + least(cast(100001.1111111 as float), cast(100000.1111111 as ncha | +=================================================================== + 100000.1111111 | + +taos> select LEAST(cast(100000.1111111 as double), cast(100001.1111111 as double)); + least(cast(100000.1111111 as double), cast(100001.1111111 as dou | +=================================================================== + 100000.1111111 | + +taos> select LEAST(cast(100000.1111111 as double), cast(100001.1111111 as timestamp)); + least(cast(100000.1111111 as double), cast(100001.1111111 as tim | +=================================================================== + 100000.1111111 | + +taos> select LEAST(cast(100000.1111111 as double), cast(100001.1111111 as varchar(20))); + least(cast(100000.1111111 as double), cast(100001.1111111 as var | +=================================================================== + 100000.111111 | + +taos> select LEAST(cast(100000.1111111 as double), cast(100001.1111111 as nchar(20))); + least(cast(100000.1111111 as double), cast(100001.1111111 as nch | +=================================================================== + 100000.111111 | + +taos> select LEAST(cast(100001.1111111 as double), cast(100000.1111111 as double)); + least(cast(100001.1111111 as double), cast(100000.1111111 as dou | +=================================================================== + 100000.1111111 | + +taos> select LEAST(cast(100001.1111111 as double), cast(100000.1111111 as timestamp)); + least(cast(100001.1111111 as double), cast(100000.1111111 as tim | +=================================================================== + 100000 | + +taos> select LEAST(cast(100001.1111111 as double), cast(100000.1111111 as varchar(20))); + least(cast(100001.1111111 as double), cast(100000.1111111 as var | +=================================================================== + 100000.1111111 | + +taos> select LEAST(cast(100001.1111111 as double), cast(100000.1111111 as nchar(20))); + least(cast(100001.1111111 as double), cast(100000.1111111 as nch | +=================================================================== + 100000.1111111 | + +taos> select LEAST(cast('中文测试' as varchar(20)), cast('中文测试一' as varchar(20))); + least(cast('中文测试' as varchar(20)), cast('中文测试一 | +=================================================================== + 中文测试 | + +taos> select LEAST(cast('中文测试' as varchar(20)), cast('中文测试一' as nchar(20))); + least(cast('中文测试' as varchar(20)), cast('中文测试一 | +=================================================================== + 中文测试 | + +taos> select LEAST(cast('中文测试一' as varchar(20)), cast('中文测试' as varchar(20))); + least(cast('中文测试一' as varchar(20)), cast('中文测试 | +=================================================================== + 中文测试 | + +taos> select LEAST(cast('中文测试一' as varchar(20)), cast('中文测试' as nchar(20))); + least(cast('中文测试一' as varchar(20)), cast('中文测试 | +=================================================================== + 中文测试 | + +taos> select LEAST(cast('abc123abc' as varchar(20)), cast('abc124abc' as varchar(20))); + least(cast('abc123abc' as varchar(20)), cast('abc124abc' as varc | +=================================================================== + abc123abc | + +taos> select LEAST(cast('abc123abc' as varchar(20)), cast('abc124abc' as nchar(20))); + least(cast('abc123abc' as varchar(20)), cast('abc124abc' as ncha | +=================================================================== + abc123abc | + +taos> select LEAST(cast('abc124abc' as varchar(20)), cast('abc123abc' as varchar(20))); + least(cast('abc124abc' as varchar(20)), cast('abc123abc' as varc | +=================================================================== + abc123abc | + +taos> select LEAST(cast('abc124abc' as varchar(20)), cast('abc123abc' as nchar(20))); + least(cast('abc124abc' as varchar(20)), cast('abc123abc' as ncha | +=================================================================== + abc123abc | + +taos> select LEAST(cast('abc123abc' as nchar(20)), cast('abc124abc' as nchar(20))); + least(cast('abc123abc' as nchar(20)), cast('abc124abc' as nchar( | +=================================================================== + abc123abc | + +taos> select LEAST(cast(100 as tinyint), cast(101 as float), cast(102 as varchar(20))); + least(cast(100 as tinyint), cast(101 as float), cast(102 as varc | +=================================================================== + 100 | + +taos> select LEAST(cast(100 as varchar(20)), cast(101 as float), cast(102 as tinyint)); + least(cast(100 as varchar(20)), cast(101 as float), cast(102 as | +=================================================================== + 100 | + +taos> select LEAST('a','b','c','d','e','f','g','h','1231','15155'); + least('a','b','c','d','e','f','g','h','1231','15155') | +======================================================== + 1231 | + +taos> select LEAST(current, voltage, phase, id, nch1, nch2, var1, var2) from ts_4893.meters order by ts limit 10; + least(current, voltage, phase, id, nch1, nch2, var1, var2) | +============================================================= + 0 | + 0.138830 | + 0.796942 | + 0.537330 | + 0.313430 | + 0.332767 | + 0.846763 | + 0.637813 | + 0.115989 | + 0.373575 | + +taos> select LEAST(current, voltage, phase, id) from ts_4893.meters order by ts limit 10; + least(current, voltage, phase, id) | +===================================== + 0 | + 0.13883 | + 0.796942 | + 0.53733 | + 0.31343 | + 0.332767 | + 0.846763 | + 0.637813 | + 0.115989 | + 0.373575 | + +taos> select LEAST(nch1, nch2, var1, var2) from ts_4893.meters order by ts limit 10; + least(nch1, nch2, var1, var2) | +================================= + e | + f | + c | + e | + b | + g | + again | + b | + c | + again | + +taos> select LEAST(221, voltage) from ts_4893.meters order by ts limit 10; + least(221, voltage) | +======================== + 221 | + 220 | + 215 | + 216 | + 219 | + 221 | + 215 | + 217 | + 216 | + 221 | + +taos> select LEAST(5, id) from ts_4893.meters order by ts limit 10; + least(5, id) | +======================== + 0 | + 1 | + 2 | + 3 | + 4 | + 5 | + 5 | + 5 | + 5 | + 5 | + +taos> select LEAST('r', nch1) from ts_4893.meters order by ts limit 10; + least('r', nch1) | +================================= + novel | + r | + r | + prision | + novel | + novel | + again | + r | + novel | + again | + +taos> select LEAST('r', nch1, nch2) from ts_4893.meters order by ts limit 10; + least('r', nch1, nch2) | +================================= + novel | + f | + c | + prision | + e | + novel | + again | + d | + c | + again | + +taos> select LEAST('r', var1) from ts_4893.meters order by ts limit 10; + least('r', var1) | +================================= + novel | + person | + novel | + plate | + r | + r | + prision | + person | + prision | + plate | + +taos> select LEAST('r', var1, var2) from ts_4893.meters order by ts limit 10; + least('r', var1, var2) | +================================= + e | + person | + novel | + e | + b | + g | + b | + b | + e | + plate | + +taos> select LEAST('二中文测试', nch1) from ts_4893.meters order by ts limit 10; + least('二中文测试', nch1) | +================================= + novel | + 一二三四五六七八九十 | + update | + prision | + novel | + novel | + again | + 一二三四五六七八九十 | + novel | + again | + +taos> select LEAST('二中文测试', nch1, nch2) from ts_4893.meters order by ts limit 10; + least('二中文测试', nch1, nch2) | +======================================= + novel | + f | + c | + prision | + e | + novel | + again | + d | + c | + again | + +taos> select LEAST('二中文测试', var1) from ts_4893.meters order by ts limit 10; + least('二中文测试', var1) | +================================= + novel | + person | + novel | + plate | + 一二三四五六七八九十 | + update | + prision | + person | + prision | + plate | + +taos> select LEAST('二中文测试', var1, var2) from ts_4893.meters order by ts limit 10; + least('二中文测试', var1, var2) | +======================================= + e | + person | + novel | + e | + b | + g | + b | + b | + e | + plate | + +taos> select LEAST('23', 3443434343434343); + least('23', 3443434343434343) | +================================ + 23 | + +taos> select LEAST(co, 3443434343434343) from ts_4893.n1; + least(co, 3443434343434343) | +================================= + 23 | + 23 | + 23 | + +taos> select LEAST('23', 3443434343434343) from ts_4893.n1; + least('23', 3443434343434343) | +================================ + 23 | + 23 | + 23 | + +taos> select LEAST('23', 1443434343434343) from ts_4893.n1; + least('23', 1443434343434343) | +================================ + 1443434343434343 | + 1443434343434343 | + 1443434343434343 | + +taos> select LEAST(current, voltage) from ts_4893.n1; + least(current, voltage) | +========================== + NULL | + NULL | + 3 | + +taos> select LEAST(current, voltage, '15') from ts_4893.n1; + least(current, voltage, '15') | +================================ + NULL | + NULL | + 15 | + +taos> alter local 'transToStrWhenMixTypeInLeast' '0'; + +taos> select LEAST(1,2,3,4,5,6,7,8,9,10); + least(1,2,3,4,5,6,7,8,9,10) | +============================== + 1 | + +taos> select LEAST(1,1.1,2.23,3.4444,5.66666666,6.21241241,7.999999999999); + least(1,1.1,2.23,3.4444,5.66666666,6.21241241,7.999999999999) | +================================================================ + 1 | + +taos> select LEAST(1,'2',3.3,4.4,5); + least(1,'2',3.3,4.4,5) | +============================ + 1 | + +taos> select LEAST(1,2,3,4,5,'5.1'); + least(1,2,3,4,5,'5.1') | +========================= + 1 | + +taos> select LEAST('1','2','3','4',5); + least('1','2','3','4',5) | +=========================== + 1 | + +taos> select LEAST('1','2','3','4','5'); + least('1','2','3','4','5') | +============================= + 1 | + +taos> select LEAST(1,2,3,4,5,6,7,'a','b','一','二','三'); + least(1,2,3,4,5,6,7,'a','b','一','二','三') | +================================================= + 0 | + +taos> select LEAST(1,2,3,4,5,6,7,'a','b','c','1','2','1231213'); + least(1,2,3,4,5,6,7,'a','b','c','1','2','1231213') | +===================================================== + 0 | + +taos> select LEAST(1,2,3,4,5,6,7,'a','b','c','1','2','1231213','1231213.123123'); + least(1,2,3,4,5,6,7,'a','b','c','1','2','1231213','1231213.12312 | +=================================================================== + 0 | + +taos> select LEAST(cast(0 as bool), cast(1 as tinyint), cast(2 as smallint), cast(3 as int), cast(4 as bigint), cast(5 as float), cast(6 as double), cast(8 as varchar(20)), cast(9 as nchar(20))); + least(cast(0 as bool), cast(1 as tinyint), cast(2 as smallint), | +=================================================================== + 0 | + +taos> select LEAST(cast(0 as bool), cast(1 as tinyint unsigned), cast(2 as smallint unsigned), cast(3 as int unsigned), cast(4 as bigint unsigned), cast(5 as float), cast(6 as double), cast(8 as varchar(20)), cast(9 as nchar(20))); + least(cast(0 as bool), cast(1 as tinyint unsigned), cast(2 as sm | +=================================================================== + 0 | + +taos> select LEAST(cast(0 as bool), cast(1 as tinyint), cast(2 as smallint), cast(3 as int), cast(4 as bigint), cast(5 as float), cast(6 as double), cast(8 as varchar(20)), cast(9 as nchar(20)), cast(0 as bool), cast(1 as tinyint unsigned), cast(2 as smallint unsigned), cast(3 as int unsigned), cast(4 as bigint unsigned), cast(5 as float), cast(6 as double)); + least(cast(0 as bool), cast(1 as tinyint), cast(2 as smallint), | +=================================================================== + 0 | + +taos> select LEAST(cast(100 as tinyint), cast(101 as tinyint)); + least(cast(100 as tinyint), cast(101 as tinyint)) | +==================================================== + 100 | + +taos> select LEAST(cast(100 as tinyint), cast(101 as smallint)); + least(cast(100 as tinyint), cast(101 as smallint)) | +===================================================== + 100 | + +taos> select LEAST(cast(100 as tinyint), cast(101 as int)); + least(cast(100 as tinyint), cast(101 as int)) | +================================================ + 100 | + +taos> select LEAST(cast(100 as tinyint), cast(101 as bigint)); + least(cast(100 as tinyint), cast(101 as bigint)) | +=================================================== + 100 | + +taos> select LEAST(cast(100 as tinyint), cast(101 as float)); + least(cast(100 as tinyint), cast(101 as float)) | +================================================== + 100 | + +taos> select LEAST(cast(100 as tinyint), cast(101 as double)); + least(cast(100 as tinyint), cast(101 as double)) | +=================================================== + 100 | + +taos> select LEAST(cast(100 as tinyint), cast(101 as varchar(20))); + least(cast(100 as tinyint), cast(101 as varchar(20))) | +======================================================== + 100 | + +taos> select LEAST(cast(100 as tinyint), cast(101 as nchar(20))); + least(cast(100 as tinyint), cast(101 as nchar(20))) | +====================================================== + 100 | + +taos> select LEAST(cast(101 as tinyint), cast(100 as tinyint)); + least(cast(101 as tinyint), cast(100 as tinyint)) | +==================================================== + 100 | + +taos> select LEAST(cast(101 as tinyint), cast(100 as smallint)); + least(cast(101 as tinyint), cast(100 as smallint)) | +===================================================== + 100 | + +taos> select LEAST(cast(101 as tinyint), cast(100 as int)); + least(cast(101 as tinyint), cast(100 as int)) | +================================================ + 100 | + +taos> select LEAST(cast(101 as tinyint), cast(100 as bigint)); + least(cast(101 as tinyint), cast(100 as bigint)) | +=================================================== + 100 | + +taos> select LEAST(cast(101 as tinyint), cast(100 as float)); + least(cast(101 as tinyint), cast(100 as float)) | +================================================== + 100 | + +taos> select LEAST(cast(101 as tinyint), cast(100 as double)); + least(cast(101 as tinyint), cast(100 as double)) | +=================================================== + 100 | + +taos> select LEAST(cast(101 as tinyint), cast(100 as varchar(20))); + least(cast(101 as tinyint), cast(100 as varchar(20))) | +======================================================== + 100 | + +taos> select LEAST(cast(101 as tinyint), cast(100 as nchar(20))); + least(cast(101 as tinyint), cast(100 as nchar(20))) | +====================================================== + 100 | + +taos> select LEAST(cast(1000 as smallint), cast(1001 as smallint)); + least(cast(1000 as smallint), cast(1001 as smallint)) | +======================================================== + 1000 | + +taos> select LEAST(cast(1000 as smallint), cast(1001 as int)); + least(cast(1000 as smallint), cast(1001 as int)) | +=================================================== + 1000 | + +taos> select LEAST(cast(1000 as smallint), cast(1001 as bigint)); + least(cast(1000 as smallint), cast(1001 as bigint)) | +====================================================== + 1000 | + +taos> select LEAST(cast(1000 as smallint), cast(1001 as float)); + least(cast(1000 as smallint), cast(1001 as float)) | +===================================================== + 1000 | + +taos> select LEAST(cast(1000 as smallint), cast(1001 as double)); + least(cast(1000 as smallint), cast(1001 as double)) | +====================================================== + 1000 | + +taos> select LEAST(cast(1000 as smallint), cast(1001 as varchar(20))); + least(cast(1000 as smallint), cast(1001 as varchar(20))) | +=========================================================== + 1000 | + +taos> select LEAST(cast(1000 as smallint), cast(1001 as nchar(20))); + least(cast(1000 as smallint), cast(1001 as nchar(20))) | +========================================================= + 1000 | + +taos> select LEAST(cast(1001 as smallint), cast(1000 as smallint)); + least(cast(1001 as smallint), cast(1000 as smallint)) | +======================================================== + 1000 | + +taos> select LEAST(cast(1001 as smallint), cast(1000 as int)); + least(cast(1001 as smallint), cast(1000 as int)) | +=================================================== + 1000 | + +taos> select LEAST(cast(1001 as smallint), cast(1000 as bigint)); + least(cast(1001 as smallint), cast(1000 as bigint)) | +====================================================== + 1000 | + +taos> select LEAST(cast(1001 as smallint), cast(1000 as float)); + least(cast(1001 as smallint), cast(1000 as float)) | +===================================================== + 1000 | + +taos> select LEAST(cast(1001 as smallint), cast(1000 as double)); + least(cast(1001 as smallint), cast(1000 as double)) | +====================================================== + 1000 | + +taos> select LEAST(cast(1001 as smallint), cast(1000 as varchar(20))); + least(cast(1001 as smallint), cast(1000 as varchar(20))) | +=========================================================== + 1000 | + +taos> select LEAST(cast(1001 as smallint), cast(1000 as nchar(20))); + least(cast(1001 as smallint), cast(1000 as nchar(20))) | +========================================================= + 1000 | + +taos> select LEAST(cast(1000000 as int), cast(1000001 as int)); + least(cast(1000000 as int), cast(1000001 as int)) | +==================================================== + 1000000 | + +taos> select LEAST(cast(1000000 as int), cast(1000001 as bigint)); + least(cast(1000000 as int), cast(1000001 as bigint)) | +======================================================= + 1000000 | + +taos> select LEAST(cast(1000000 as int), cast(1000001 as float)); + least(cast(1000000 as int), cast(1000001 as float)) | +====================================================== + 1e+06 | + +taos> select LEAST(cast(1000000 as int), cast(1000001 as double)); + least(cast(1000000 as int), cast(1000001 as double)) | +======================================================= + 1000000 | + +taos> select LEAST(cast(1000000 as int), cast(1000001 as varchar(20))); + least(cast(1000000 as int), cast(1000001 as varchar(20))) | +============================================================ + 1000000 | + +taos> select LEAST(cast(1000000 as int), cast(1000001 as nchar(20))); + least(cast(1000000 as int), cast(1000001 as nchar(20))) | +========================================================== + 1000000 | + +taos> select LEAST(cast(1000001 as int), cast(1000000 as int)); + least(cast(1000001 as int), cast(1000000 as int)) | +==================================================== + 1000000 | + +taos> select LEAST(cast(1000001 as int), cast(1000000 as bigint)); + least(cast(1000001 as int), cast(1000000 as bigint)) | +======================================================= + 1000000 | + +taos> select LEAST(cast(1000001 as int), cast(1000000 as float)); + least(cast(1000001 as int), cast(1000000 as float)) | +====================================================== + 1e+06 | + +taos> select LEAST(cast(1000001 as int), cast(1000000 as double)); + least(cast(1000001 as int), cast(1000000 as double)) | +======================================================= + 1000000 | + +taos> select LEAST(cast(1000001 as int), cast(1000000 as varchar(20))); + least(cast(1000001 as int), cast(1000000 as varchar(20))) | +============================================================ + 1000000 | + +taos> select LEAST(cast(1000001 as int), cast(1000000 as nchar(20))); + least(cast(1000001 as int), cast(1000000 as nchar(20))) | +========================================================== + 1000000 | + +taos> select LEAST(cast(1000000000 as bigint), cast(1000000001 as bigint)); + least(cast(1000000000 as bigint), cast(1000000001 as bigint)) | +================================================================ + 1000000000 | + +taos> select LEAST(cast(1000000000 as bigint), cast(1000000001 as float)); + least(cast(1000000000 as bigint), cast(1000000001 as float)) | +=============================================================== + 1e+09 | + +taos> select LEAST(cast(1000000000 as bigint), cast(1000000001 as double)); + least(cast(1000000000 as bigint), cast(1000000001 as double)) | +================================================================ + 1000000000 | + +taos> select LEAST(cast(1000000000 as bigint), cast(1000000001 as varchar(20))); + least(cast(1000000000 as bigint), cast(1000000001 as varchar(20) | +=================================================================== + 1000000000 | + +taos> select LEAST(cast(1000000000 as bigint), cast(1000000001 as nchar(20))); + least(cast(1000000000 as bigint), cast(1000000001 as nchar(20))) | +=================================================================== + 1000000000 | + +taos> select LEAST(cast(1000000001 as bigint), cast(1000000000 as bigint)); + least(cast(1000000001 as bigint), cast(1000000000 as bigint)) | +================================================================ + 1000000000 | + +taos> select LEAST(cast(1000000001 as bigint), cast(1000000000 as float)); + least(cast(1000000001 as bigint), cast(1000000000 as float)) | +=============================================================== + 1e+09 | + +taos> select LEAST(cast(1000000001 as bigint), cast(1000000000 as double)); + least(cast(1000000001 as bigint), cast(1000000000 as double)) | +================================================================ + 1000000000 | + +taos> select LEAST(cast(1000000001 as bigint), cast(1000000000 as varchar(20))); + least(cast(1000000001 as bigint), cast(1000000000 as varchar(20) | +=================================================================== + 1000000000 | + +taos> select LEAST(cast(1000000001 as bigint), cast(1000000000 as nchar(20))); + least(cast(1000000001 as bigint), cast(1000000000 as nchar(20))) | +=================================================================== + 1000000000 | + +taos> select LEAST(cast(100000.1111111 as float), cast(100001.1111111 as float)); + least(cast(100000.1111111 as float), cast(100001.1111111 as floa | +=================================================================== + 100000 | + +taos> select LEAST(cast(100000.1111111 as float), cast(100001.1111111 as double)); + least(cast(100000.1111111 as float), cast(100001.1111111 as doub | +=================================================================== + 100000.109375 | + +taos> select LEAST(cast(100000.1111111 as float), cast(100001.1111111 as timestamp)); + least(cast(100000.1111111 as float), cast(100001.1111111 as time | +=================================================================== + 100000 | + +taos> select LEAST(cast(100000.1111111 as float), cast(100001.1111111 as varchar(20))); + least(cast(100000.1111111 as float), cast(100001.1111111 as varc | +=================================================================== + 100000 | + +taos> select LEAST(cast(100000.1111111 as float), cast(100001.1111111 as nchar(20))); + least(cast(100000.1111111 as float), cast(100001.1111111 as ncha | +=================================================================== + 100000 | + +taos> select LEAST(cast(100001.1111111 as float), cast(100000.1111111 as float)); + least(cast(100001.1111111 as float), cast(100000.1111111 as floa | +=================================================================== + 100000 | + +taos> select LEAST(cast(100001.1111111 as float), cast(100000.1111111 as double)); + least(cast(100001.1111111 as float), cast(100000.1111111 as doub | +=================================================================== + 100000.1111111 | + +taos> select LEAST(cast(100001.1111111 as float), cast(100000.1111111 as timestamp)); + least(cast(100001.1111111 as float), cast(100000.1111111 as time | +=================================================================== + 100000 | + +taos> select LEAST(cast(100001.1111111 as float), cast(100000.1111111 as varchar(20))); + least(cast(100001.1111111 as float), cast(100000.1111111 as varc | +=================================================================== + 100000 | + +taos> select LEAST(cast(100001.1111111 as float), cast(100000.1111111 as nchar(20))); + least(cast(100001.1111111 as float), cast(100000.1111111 as ncha | +=================================================================== + 100000 | + +taos> select LEAST(cast(100000.1111111 as double), cast(100001.1111111 as double)); + least(cast(100000.1111111 as double), cast(100001.1111111 as dou | +=================================================================== + 100000.1111111 | + +taos> select LEAST(cast(100000.1111111 as double), cast(100001.1111111 as timestamp)); + least(cast(100000.1111111 as double), cast(100001.1111111 as tim | +=================================================================== + 100000.1111111 | + +taos> select LEAST(cast(100000.1111111 as double), cast(100001.1111111 as varchar(20))); + least(cast(100000.1111111 as double), cast(100001.1111111 as var | +=================================================================== + 100000.1111111 | + +taos> select LEAST(cast(100000.1111111 as double), cast(100001.1111111 as nchar(20))); + least(cast(100000.1111111 as double), cast(100001.1111111 as nch | +=================================================================== + 100000.1111111 | + +taos> select LEAST(cast(100001.1111111 as double), cast(100000.1111111 as double)); + least(cast(100001.1111111 as double), cast(100000.1111111 as dou | +=================================================================== + 100000.1111111 | + +taos> select LEAST(cast(100001.1111111 as double), cast(100000.1111111 as timestamp)); + least(cast(100001.1111111 as double), cast(100000.1111111 as tim | +=================================================================== + 100000 | + +taos> select LEAST(cast(100001.1111111 as double), cast(100000.1111111 as varchar(20))); + least(cast(100001.1111111 as double), cast(100000.1111111 as var | +=================================================================== + 100000.1111111 | + +taos> select LEAST(cast(100001.1111111 as double), cast(100000.1111111 as nchar(20))); + least(cast(100001.1111111 as double), cast(100000.1111111 as nch | +=================================================================== + 100000.1111111 | + +taos> select LEAST(cast('中文测试' as varchar(20)), cast('中文测试一' as varchar(20))); + least(cast('中文测试' as varchar(20)), cast('中文测试一 | +=================================================================== + 中文测试 | + +taos> select LEAST(cast('中文测试' as varchar(20)), cast('中文测试一' as nchar(20))); + least(cast('中文测试' as varchar(20)), cast('中文测试一 | +=================================================================== + 中文测试 | + +taos> select LEAST(cast('中文测试一' as varchar(20)), cast('中文测试' as varchar(20))); + least(cast('中文测试一' as varchar(20)), cast('中文测试 | +=================================================================== + 中文测试 | + +taos> select LEAST(cast('中文测试一' as varchar(20)), cast('中文测试' as nchar(20))); + least(cast('中文测试一' as varchar(20)), cast('中文测试 | +=================================================================== + 中文测试 | + +taos> select LEAST(cast('abc123abc' as varchar(20)), cast('abc124abc' as varchar(20))); + least(cast('abc123abc' as varchar(20)), cast('abc124abc' as varc | +=================================================================== + abc123abc | + +taos> select LEAST(cast('abc123abc' as varchar(20)), cast('abc124abc' as nchar(20))); + least(cast('abc123abc' as varchar(20)), cast('abc124abc' as ncha | +=================================================================== + abc123abc | + +taos> select LEAST(cast('abc124abc' as varchar(20)), cast('abc123abc' as varchar(20))); + least(cast('abc124abc' as varchar(20)), cast('abc123abc' as varc | +=================================================================== + abc123abc | + +taos> select LEAST(cast('abc124abc' as varchar(20)), cast('abc123abc' as nchar(20))); + least(cast('abc124abc' as varchar(20)), cast('abc123abc' as ncha | +=================================================================== + abc123abc | + +taos> select LEAST(cast('abc123abc' as nchar(20)), cast('abc124abc' as nchar(20))); + least(cast('abc123abc' as nchar(20)), cast('abc124abc' as nchar( | +=================================================================== + abc123abc | + +taos> select LEAST(cast(100 as tinyint), cast(101 as float), cast(102 as varchar(20))); + least(cast(100 as tinyint), cast(101 as float), cast(102 as varc | +=================================================================== + 100 | + +taos> select LEAST(cast(100 as varchar(20)), cast(101 as float), cast(102 as tinyint)); + least(cast(100 as varchar(20)), cast(101 as float), cast(102 as | +=================================================================== + 100 | + +taos> select LEAST('a','b','c','d','e','f','g','h','1231','15155'); + least('a','b','c','d','e','f','g','h','1231','15155') | +======================================================== + 1231 | + +taos> select LEAST(current, voltage, phase, id, nch1, nch2, var1, var2) from ts_4893.meters order by ts limit 10; + least(current, voltage, phase, id, nch1, nch2, var1, var2) | +============================================================= + 0 | + 0 | + 0 | + 0 | + 0 | + 0 | + 0 | + 0 | + 0 | + 0 | + +taos> select LEAST(current, voltage, phase, id) from ts_4893.meters order by ts limit 10; + least(current, voltage, phase, id) | +===================================== + 0 | + 0.13883 | + 0.796942 | + 0.53733 | + 0.31343 | + 0.332767 | + 0.846763 | + 0.637813 | + 0.115989 | + 0.373575 | + +taos> select LEAST(nch1, nch2, var1, var2) from ts_4893.meters order by ts limit 10; + least(nch1, nch2, var1, var2) | +================================= + e | + f | + c | + e | + b | + g | + again | + b | + c | + again | + +taos> select LEAST(221, voltage) from ts_4893.meters order by ts limit 10; + least(221, voltage) | +======================== + 221 | + 220 | + 215 | + 216 | + 219 | + 221 | + 215 | + 217 | + 216 | + 221 | + +taos> select LEAST(5, id) from ts_4893.meters order by ts limit 10; + least(5, id) | +======================== + 0 | + 1 | + 2 | + 3 | + 4 | + 5 | + 5 | + 5 | + 5 | + 5 | + +taos> select LEAST('r', nch1) from ts_4893.meters order by ts limit 10; + least('r', nch1) | +================================= + novel | + r | + r | + prision | + novel | + novel | + again | + r | + novel | + again | + +taos> select LEAST('r', nch1, nch2) from ts_4893.meters order by ts limit 10; + least('r', nch1, nch2) | +================================= + novel | + f | + c | + prision | + e | + novel | + again | + d | + c | + again | + +taos> select LEAST('r', var1) from ts_4893.meters order by ts limit 10; + least('r', var1) | +================================= + novel | + person | + novel | + plate | + r | + r | + prision | + person | + prision | + plate | + +taos> select LEAST('r', var1, var2) from ts_4893.meters order by ts limit 10; + least('r', var1, var2) | +================================= + e | + person | + novel | + e | + b | + g | + b | + b | + e | + plate | + +taos> select LEAST('二中文测试', nch1) from ts_4893.meters order by ts limit 10; + least('二中文测试', nch1) | +================================= + novel | + 一二三四五六七八九十 | + update | + prision | + novel | + novel | + again | + 一二三四五六七八九十 | + novel | + again | + +taos> select LEAST('二中文测试', nch1, nch2) from ts_4893.meters order by ts limit 10; + least('二中文测试', nch1, nch2) | +======================================= + novel | + f | + c | + prision | + e | + novel | + again | + d | + c | + again | + +taos> select LEAST('二中文测试', var1) from ts_4893.meters order by ts limit 10; + least('二中文测试', var1) | +================================= + novel | + person | + novel | + plate | + 一二三四五六七八九十 | + update | + prision | + person | + prision | + plate | + +taos> select LEAST('二中文测试', var1, var2) from ts_4893.meters order by ts limit 10; + least('二中文测试', var1, var2) | +======================================= + e | + person | + novel | + e | + b | + g | + b | + b | + e | + plate | + +taos> select LEAST('23', 3443434343434343); + least('23', 3443434343434343) | +================================ + 23 | + +taos> select LEAST(co, 3443434343434343) from ts_4893.n1; + least(co, 3443434343434343) | +============================== + 23 | + 23 | + 23 | + +taos> select LEAST('23', 3443434343434343) from ts_4893.n1; + least('23', 3443434343434343) | +================================ + 23 | + 23 | + 23 | + +taos> select LEAST('23', 1443434343434343) from ts_4893.n1; + least('23', 1443434343434343) | +================================ + 23 | + 23 | + 23 | + +taos> select LEAST(current, voltage) from ts_4893.n1; + least(current, voltage) | +========================== + NULL | + NULL | + 3 | + +taos> select LEAST(current, voltage, '15') from ts_4893.n1; + least(current, voltage, '15') | +================================ + NULL | + NULL | + 3 | + diff --git a/tests/army/query/function/ans/mod.csv b/tests/army/query/function/ans/mod.csv index 05770289db..c222257308 100644 --- a/tests/army/query/function/ans/mod.csv +++ b/tests/army/query/function/ans/mod.csv @@ -42,12 +42,12 @@ taos> select MOD(10.55, 1) + 1 taos> select MOD(MOD(MOD(MOD(MOD(MOD(MOD(123.123456789, 9), 8), 7), 6), 5), 4), 3) mod(mod(mod(mod(mod(mod(mod(123.123456789, 9), 8), 7), 6), 5), 4 | =================================================================== - 0.12345678900000 | + 0.123456789000002 | taos> select MOD(MOD(MOD(MOD(MOD(MOD(MOD(123456789.123456789, -1), -2), -3), -4), -5), -6), -7) mod(mod(mod(mod(mod(mod(mod(123456789.123456789, -1), -2), -3), | =================================================================== - 0.12345679104328 | + 0.123456791043282 | taos> select MOD(87654321.123456789, id + 1) from ts_4893.meters order by ts limit 10 mod(87654321.123456789, id + 1) | diff --git a/tests/army/query/function/ans/round.csv b/tests/army/query/function/ans/round.csv index 023c1fd43d..4ae3a85376 100644 --- a/tests/army/query/function/ans/round.csv +++ b/tests/army/query/function/ans/round.csv @@ -67,12 +67,12 @@ taos> select ROUND(10.55, 1) + 1 taos> select ROUND(ROUND(ROUND(ROUND(ROUND(ROUND(ROUND(123.123456789, 9), 8), 7), 6), 5), 4)) round(round(round(round(round(round(round(123.123456789, 9), 8), | =================================================================== - 12 | + 123 | taos> select ROUND(ROUND(ROUND(ROUND(ROUND(ROUND(ROUND(123456789.123456789, -1), -2), -3), -4), -5), -6)) round(round(round(round(round(round(round(123456789.123456789, - | =================================================================== - 12300000 | + 123000000 | taos> select ROUND(current) from ts_4893.meters order by ts limit 20 round(current) | diff --git a/tests/army/query/function/ans/trunc.csv b/tests/army/query/function/ans/trunc.csv index 77b6127cba..8d1316b760 100644 --- a/tests/army/query/function/ans/trunc.csv +++ b/tests/army/query/function/ans/trunc.csv @@ -47,12 +47,12 @@ taos> select TRUNCATE(10.55, 1) + 1 taos> select TRUNCATE(TRUNCATE(TRUNCATE(TRUNCATE(TRUNCATE(TRUNCATE(TRUNCATE(123.123456789, 9), 8), 7), 6), 5), 4), 3) truncate(truncate(truncate(truncate(truncate(truncate(truncate(1 | =================================================================== - 123.12 | + 123.123 | taos> select TRUNCATE(TRUNCATE(TRUNCATE(TRUNCATE(TRUNCATE(TRUNCATE(TRUNCATE(123456789.123456789, -1), -2), -3), -4), -5), -6), -7) truncate(truncate(truncate(truncate(truncate(truncate(truncate(1 | =================================================================== - 12000000 | + 120000000 | taos> select TRUNCATE(87654321.123456789, id) from ts_4893.meters order by ts limit 10 truncate(87654321.123456789, id) | @@ -144,12 +144,12 @@ taos> select TRUNC(10.55, 1) + 1 taos> select TRUNC(TRUNC(TRUNC(TRUNC(TRUNC(TRUNC(TRUNC(123.123456789, 9), 8), 7), 6), 5), 4), 3) trunc(trunc(trunc(trunc(trunc(trunc(trunc(123.123456789, 9), 8), | =================================================================== - 123.12 | + 123.123 | taos> select TRUNC(TRUNC(TRUNC(TRUNC(TRUNC(TRUNC(TRUNC(123456789.123456789, -1), -2), -3), -4), -5), -6), -7) trunc(trunc(trunc(trunc(trunc(trunc(trunc(123456789.123456789, - | =================================================================== - 12000000 | + 120000000 | taos> select TRUNC(87654321.123456789, id) from ts_4893.meters order by ts limit 10 trunc(87654321.123456789, id) | diff --git a/tests/army/query/function/in/greatest.in b/tests/army/query/function/in/greatest.in new file mode 100644 index 0000000000..1ae8bee06b --- /dev/null +++ b/tests/army/query/function/in/greatest.in @@ -0,0 +1,232 @@ +alter local 'transToStrWhenMixTypeInLeast' '1'; +select GREATEST(1,2,3,4,5,6,7,8,9,10); +select GREATEST(1,1.1,2.23,3.4444,5.66666666,6.21241241,7.999999999999); +select GREATEST(1,'2',3.3,4.4,5); +select GREATEST(121,'18'); +select GREATEST(18888,'18'); +select GREATEST(1,2,3,4,5,'5.1'); +select GREATEST('1','2','3','4',5); +select GREATEST('1','2','3','4','5'); +select GREATEST(1,2,3,4,5,6,7,'a','b','一','二','三'); +select GREATEST(1,2,3,4,5,6,7,'a','b','c','1','2','1231213'); +select GREATEST(1,2,3,4,5,6,7,'a','b','c','1','2','1231213','1231213.123123'); +select GREATEST(cast(0 as bool), cast(1 as tinyint), cast(2 as smallint), cast(3 as int), cast(4 as bigint), cast(5 as float), cast(6 as double), cast(8 as varchar(20)), cast(9 as nchar(20))); +select GREATEST(cast(0 as bool), cast(1 as tinyint unsigned), cast(2 as smallint unsigned), cast(3 as int unsigned), cast(4 as bigint unsigned), cast(5 as float), cast(6 as double), cast(8 as varchar(20)), cast(9 as nchar(20))); +select GREATEST(cast(0 as bool), cast(1 as tinyint), cast(2 as smallint), cast(3 as int), cast(4 as bigint), cast(5 as float), cast(6 as double), cast(8 as varchar(20)), cast(9 as nchar(20)), cast(0 as bool), cast(1 as tinyint unsigned), cast(2 as smallint unsigned), cast(3 as int unsigned), cast(4 as bigint unsigned), cast(5 as float), cast(6 as double)); +select GREATEST(cast(100 as tinyint), cast(101 as tinyint)); +select GREATEST(cast(100 as tinyint), cast(101 as smallint)); +select GREATEST(cast(100 as tinyint), cast(101 as int)); +select GREATEST(cast(100 as tinyint), cast(101 as bigint)); +select GREATEST(cast(100 as tinyint), cast(101 as float)); +select GREATEST(cast(100 as tinyint), cast(101 as double)); +select GREATEST(cast(100 as tinyint), cast(101 as varchar(20))); +select GREATEST(cast(100 as tinyint), cast(101 as nchar(20))); +select GREATEST(cast(101 as tinyint), cast(100 as tinyint)); +select GREATEST(cast(101 as tinyint), cast(100 as smallint)); +select GREATEST(cast(101 as tinyint), cast(100 as int)); +select GREATEST(cast(101 as tinyint), cast(100 as bigint)); +select GREATEST(cast(101 as tinyint), cast(100 as float)); +select GREATEST(cast(101 as tinyint), cast(100 as double)); +select GREATEST(cast(101 as tinyint), cast(100 as varchar(20))); +select GREATEST(cast(101 as tinyint), cast(100 as nchar(20))); +select GREATEST(cast(1000 as smallint), cast(1001 as smallint)); +select GREATEST(cast(1000 as smallint), cast(1001 as int)); +select GREATEST(cast(1000 as smallint), cast(1001 as bigint)); +select GREATEST(cast(1000 as smallint), cast(1001 as float)); +select GREATEST(cast(1000 as smallint), cast(1001 as double)); +select GREATEST(cast(1000 as smallint), cast(1001 as varchar(20))); +select GREATEST(cast(1000 as smallint), cast(1001 as nchar(20))); +select GREATEST(cast(1001 as smallint), cast(1000 as smallint)); +select GREATEST(cast(1001 as smallint), cast(1000 as int)); +select GREATEST(cast(1001 as smallint), cast(1000 as bigint)); +select GREATEST(cast(1001 as smallint), cast(1000 as float)); +select GREATEST(cast(1001 as smallint), cast(1000 as double)); +select GREATEST(cast(1001 as smallint), cast(1000 as varchar(20))); +select GREATEST(cast(1001 as smallint), cast(1000 as nchar(20))); +select GREATEST(cast(1000000 as int), cast(1000001 as int)); +select GREATEST(cast(1000000 as int), cast(1000001 as bigint)); +select GREATEST(cast(1000000 as int), cast(1000001 as float)); +select GREATEST(cast(1000000 as int), cast(1000001 as double)); +select GREATEST(cast(1000000 as int), cast(1000001 as varchar(20))); +select GREATEST(cast(1000000 as int), cast(1000001 as nchar(20))); +select GREATEST(cast(1000001 as int), cast(1000000 as int)); +select GREATEST(cast(1000001 as int), cast(1000000 as bigint)); +select GREATEST(cast(1000001 as int), cast(1000000 as float)); +select GREATEST(cast(1000001 as int), cast(1000000 as double)); +select GREATEST(cast(1000001 as int), cast(1000000 as varchar(20))); +select GREATEST(cast(1000001 as int), cast(1000000 as nchar(20))); +select GREATEST(cast(1000000000 as bigint), cast(1000000001 as bigint)); +select GREATEST(cast(1000000000 as bigint), cast(1000000001 as float)); +select GREATEST(cast(1000000000 as bigint), cast(1000000001 as double)); +select GREATEST(cast(1000000000 as bigint), cast(1000000001 as varchar(20))); +select GREATEST(cast(1000000000 as bigint), cast(1000000001 as nchar(20))); +select GREATEST(cast(1000000001 as bigint), cast(1000000000 as bigint)); +select GREATEST(cast(1000000001 as bigint), cast(1000000000 as float)); +select GREATEST(cast(1000000001 as bigint), cast(1000000000 as double)); +select GREATEST(cast(1000000001 as bigint), cast(1000000000 as varchar(20))); +select GREATEST(cast(1000000001 as bigint), cast(1000000000 as nchar(20))); +select GREATEST(cast(100000.1111111 as float), cast(100001.1111111 as float)); +select GREATEST(cast(100000.1111111 as float), cast(100001.1111111 as double)); +select GREATEST(cast(100000.1111111 as float), cast(100001.1111111 as timestamp)); +select GREATEST(cast(100000.1111111 as float), cast(100001.1111111 as varchar(20))); +select GREATEST(cast(100000.1111111 as float), cast(100001.1111111 as nchar(20))); +select GREATEST(cast(100001.1111111 as float), cast(100000.1111111 as float)); +select GREATEST(cast(100001.1111111 as float), cast(100000.1111111 as double)); +select GREATEST(cast(100001.1111111 as float), cast(100000.1111111 as timestamp)); +select GREATEST(cast(100001.1111111 as float), cast(100000.1111111 as varchar(20))); +select GREATEST(cast(100001.1111111 as float), cast(100000.1111111 as nchar(20))); +select GREATEST(cast(100000.1111111 as double), cast(100001.1111111 as double)); +select GREATEST(cast(100000.1111111 as double), cast(100001.1111111 as timestamp)); +select GREATEST(cast(100000.1111111 as double), cast(100001.1111111 as varchar(20))); +select GREATEST(cast(100000.1111111 as double), cast(100001.1111111 as nchar(20))); +select GREATEST(cast(100001.1111111 as double), cast(100000.1111111 as double)); +select GREATEST(cast(100001.1111111 as double), cast(100000.1111111 as timestamp)); +select GREATEST(cast(100001.1111111 as double), cast(100000.1111111 as varchar(20))); +select GREATEST(cast(100001.1111111 as double), cast(100000.1111111 as nchar(20))); +select GREATEST(cast('中文测试' as varchar(20)), cast('中文测试一' as varchar(20))); +select GREATEST(cast('中文测试' as varchar(20)), cast('中文测试一' as nchar(20))); +select GREATEST(cast('中文测试一' as varchar(20)), cast('中文测试' as varchar(20))); +select GREATEST(cast('中文测试一' as varchar(20)), cast('中文测试' as nchar(20))); +select GREATEST(cast('abc123abc' as varchar(20)), cast('abc124abc' as varchar(20))); +select GREATEST(cast('abc123abc' as varchar(20)), cast('abc124abc' as nchar(20))); +select GREATEST(cast('abc124abc' as varchar(20)), cast('abc123abc' as varchar(20))); +select GREATEST(cast('abc124abc' as varchar(20)), cast('abc123abc' as nchar(20))); +select GREATEST(cast('abc123abc' as nchar(20)), cast('abc124abc' as nchar(20))); +select GREATEST(cast(100 as tinyint), cast(101 as float), cast(102 as varchar(20))); +select GREATEST(cast(100 as float), cast(101 as tinyint), cast(102 as varchar(20))); +select GREATEST(cast(100 as float), cast(101 as varchar(20)), cast(102 as tinyint)); +select GREATEST(cast(100 as varchar(20)), cast(101 as float), cast(102 as tinyint)); +select GREATEST('a','b','c','d','e','f','g','h','1231','15155'); +select GREATEST(current, voltage, phase, id, nch1, nch2, var1, var2) from ts_4893.meters order by ts limit 10; +select GREATEST(current, voltage, phase, id) from ts_4893.meters order by ts limit 10; +select GREATEST(nch1, nch2, var1, var2) from ts_4893.meters order by ts limit 10; +select GREATEST(221, voltage) from ts_4893.meters order by ts limit 10; +select GREATEST(5, id) from ts_4893.meters order by ts limit 10; +select GREATEST('r', nch1) from ts_4893.meters order by ts limit 10; +select GREATEST('r', nch1, nch2) from ts_4893.meters order by ts limit 10; +select GREATEST('r', var1) from ts_4893.meters order by ts limit 10; +select GREATEST('r', var1, var2) from ts_4893.meters order by ts limit 10; +select GREATEST('二中文测试', nch1) from ts_4893.meters order by ts limit 10; +select GREATEST('二中文测试', nch1, nch2) from ts_4893.meters order by ts limit 10; +select GREATEST('二中文测试', var1) from ts_4893.meters order by ts limit 10; +select GREATEST('二中文测试', var1, var2) from ts_4893.meters order by ts limit 10; +select GREATEST('23', 3443434343434343); +select GREATEST(co, 3443434343434343) from ts_4893.n1; +select GREATEST('23', 3443434343434343) from ts_4893.n1; +select GREATEST('23', 1443434343434343) from ts_4893.n1; +select GREATEST(current, voltage) from ts_4893.n1; +select GREATEST(current, voltage, '15') from ts_4893.n1; +alter local 'transToStrWhenMixTypeInLeast' '0'; +select GREATEST(1,'2',3.3,4.4,5); +select GREATEST(1,2,3,4,5,'5.1'); +select GREATEST(121,'18'); +select GREATEST('1','2','3','4','5'); +select GREATEST(1,2,3,4,5,6,7,'a','b','一','二','三'); +select GREATEST(1,2,3,4,5,6,7,'a','b','c','1','2','1231213'); +select GREATEST(1,2,3,4,5,6,7,'a','b','c','1','2','1231213','1231213.123123'); +select GREATEST(cast(0 as bool), cast(1 as tinyint), cast(2 as smallint), cast(3 as int), cast(4 as bigint), cast(5 as float), cast(6 as double), cast(8 as varchar(20)), cast(9 as nchar(20))); +select GREATEST(cast(0 as bool), cast(1 as tinyint unsigned), cast(2 as smallint unsigned), cast(3 as int unsigned), cast(4 as bigint unsigned), cast(5 as float), cast(6 as double), cast(8 as varchar(20)), cast(9 as nchar(20))); +select GREATEST(cast(0 as bool), cast(1 as tinyint), cast(2 as smallint), cast(3 as int), cast(4 as bigint), cast(5 as float), cast(6 as double), cast(8 as varchar(20)), cast(9 as nchar(20)), cast(0 as bool), cast(1 as tinyint unsigned), cast(2 as smallint unsigned), cast(3 as int unsigned), cast(4 as bigint unsigned), cast(5 as float), cast(6 as double)); +select GREATEST(cast(100 as tinyint), cast(101 as tinyint)); +select GREATEST(cast(100 as tinyint), cast(101 as smallint)); +select GREATEST(cast(100 as tinyint), cast(101 as int)); +select GREATEST(cast(100 as tinyint), cast(101 as bigint)); +select GREATEST(cast(100 as tinyint), cast(101 as float)); +select GREATEST(cast(100 as tinyint), cast(101 as double)); +select GREATEST(cast(100 as tinyint), cast(101 as varchar(20))); +select GREATEST(cast(100 as tinyint), cast(101 as nchar(20))); +select GREATEST(cast(101 as tinyint), cast(100 as tinyint)); +select GREATEST(cast(101 as tinyint), cast(100 as smallint)); +select GREATEST(cast(101 as tinyint), cast(100 as int)); +select GREATEST(cast(101 as tinyint), cast(100 as bigint)); +select GREATEST(cast(101 as tinyint), cast(100 as float)); +select GREATEST(cast(101 as tinyint), cast(100 as double)); +select GREATEST(cast(101 as tinyint), cast(100 as varchar(20))); +select GREATEST(cast(101 as tinyint), cast(100 as nchar(20))); +select GREATEST(cast(1000 as smallint), cast(1001 as smallint)); +select GREATEST(cast(1000 as smallint), cast(1001 as int)); +select GREATEST(cast(1000 as smallint), cast(1001 as bigint)); +select GREATEST(cast(1000 as smallint), cast(1001 as float)); +select GREATEST(cast(1000 as smallint), cast(1001 as double)); +select GREATEST(cast(1000 as smallint), cast(1001 as varchar(20))); +select GREATEST(cast(1000 as smallint), cast(1001 as nchar(20))); +select GREATEST(cast(1001 as smallint), cast(1000 as smallint)); +select GREATEST(cast(1001 as smallint), cast(1000 as int)); +select GREATEST(cast(1001 as smallint), cast(1000 as bigint)); +select GREATEST(cast(1001 as smallint), cast(1000 as float)); +select GREATEST(cast(1001 as smallint), cast(1000 as double)); +select GREATEST(cast(1001 as smallint), cast(1000 as varchar(20))); +select GREATEST(cast(1001 as smallint), cast(1000 as nchar(20))); +select GREATEST(cast(1000000 as int), cast(1000001 as int)); +select GREATEST(cast(1000000 as int), cast(1000001 as bigint)); +select GREATEST(cast(1000000 as int), cast(1000001 as float)); +select GREATEST(cast(1000000 as int), cast(1000001 as double)); +select GREATEST(cast(1000000 as int), cast(1000001 as varchar(20))); +select GREATEST(cast(1000000 as int), cast(1000001 as nchar(20))); +select GREATEST(cast(1000001 as int), cast(1000000 as int)); +select GREATEST(cast(1000001 as int), cast(1000000 as bigint)); +select GREATEST(cast(1000001 as int), cast(1000000 as float)); +select GREATEST(cast(1000001 as int), cast(1000000 as double)); +select GREATEST(cast(1000001 as int), cast(1000000 as varchar(20))); +select GREATEST(cast(1000001 as int), cast(1000000 as nchar(20))); +select GREATEST(cast(1000000000 as bigint), cast(1000000001 as bigint)); +select GREATEST(cast(1000000000 as bigint), cast(1000000001 as float)); +select GREATEST(cast(1000000000 as bigint), cast(1000000001 as double)); +select GREATEST(cast(1000000000 as bigint), cast(1000000001 as varchar(20))); +select GREATEST(cast(1000000000 as bigint), cast(1000000001 as nchar(20))); +select GREATEST(cast(1000000001 as bigint), cast(1000000000 as bigint)); +select GREATEST(cast(1000000001 as bigint), cast(1000000000 as float)); +select GREATEST(cast(1000000001 as bigint), cast(1000000000 as double)); +select GREATEST(cast(1000000001 as bigint), cast(1000000000 as varchar(20))); +select GREATEST(cast(1000000001 as bigint), cast(1000000000 as nchar(20))); +select GREATEST(cast(100000.1111111 as float), cast(100001.1111111 as float)); +select GREATEST(cast(100000.1111111 as float), cast(100001.1111111 as double)); +select GREATEST(cast(100000.1111111 as float), cast(100001.1111111 as timestamp)); +select GREATEST(cast(100000.1111111 as float), cast(100001.1111111 as varchar(20))); +select GREATEST(cast(100000.1111111 as float), cast(100001.1111111 as nchar(20))); +select GREATEST(cast(100001.1111111 as float), cast(100000.1111111 as float)); +select GREATEST(cast(100001.1111111 as float), cast(100000.1111111 as double)); +select GREATEST(cast(100001.1111111 as float), cast(100000.1111111 as timestamp)); +select GREATEST(cast(100001.1111111 as float), cast(100000.1111111 as varchar(20))); +select GREATEST(cast(100001.1111111 as float), cast(100000.1111111 as nchar(20))); +select GREATEST(cast(100000.1111111 as double), cast(100001.1111111 as double)); +select GREATEST(cast(100000.1111111 as double), cast(100001.1111111 as timestamp)); +select GREATEST(cast(100000.1111111 as double), cast(100001.1111111 as varchar(20))); +select GREATEST(cast(100000.1111111 as double), cast(100001.1111111 as nchar(20))); +select GREATEST(cast(100001.1111111 as double), cast(100000.1111111 as double)); +select GREATEST(cast(100001.1111111 as double), cast(100000.1111111 as timestamp)); +select GREATEST(cast(100001.1111111 as double), cast(100000.1111111 as varchar(20))); +select GREATEST(cast(100001.1111111 as double), cast(100000.1111111 as nchar(20))); +select GREATEST(cast('中文测试' as varchar(20)), cast('中文测试一' as varchar(20))); +select GREATEST(cast('中文测试' as varchar(20)), cast('中文测试一' as nchar(20))); +select GREATEST(cast('中文测试一' as varchar(20)), cast('中文测试' as varchar(20))); +select GREATEST(cast('中文测试一' as varchar(20)), cast('中文测试' as nchar(20))); +select GREATEST(cast('abc123abc' as varchar(20)), cast('abc124abc' as varchar(20))); +select GREATEST(cast('abc123abc' as varchar(20)), cast('abc124abc' as nchar(20))); +select GREATEST(cast('abc124abc' as varchar(20)), cast('abc123abc' as varchar(20))); +select GREATEST(cast('abc124abc' as varchar(20)), cast('abc123abc' as nchar(20))); +select GREATEST(cast('abc123abc' as nchar(20)), cast('abc124abc' as nchar(20))); +select GREATEST(cast(100 as tinyint), cast(101 as float), cast(102 as varchar(20))); +select GREATEST(cast(100 as float), cast(101 as tinyint), cast(102 as varchar(20))); +select GREATEST(cast(100 as float), cast(101 as varchar(20)), cast(102 as tinyint)); +select GREATEST(cast(100 as varchar(20)), cast(101 as float), cast(102 as tinyint)); +select GREATEST('a','b','c','d','e','f','g','h','1231','15155'); +select GREATEST(current, voltage, phase, id, nch1, nch2, var1, var2) from ts_4893.meters order by ts limit 10; +select GREATEST(current, voltage, phase, id) from ts_4893.meters order by ts limit 10; +select GREATEST(nch1, nch2, var1, var2) from ts_4893.meters order by ts limit 10; +select GREATEST(221, voltage) from ts_4893.meters order by ts limit 10; +select GREATEST(5, id) from ts_4893.meters order by ts limit 10; +select GREATEST('r', nch1) from ts_4893.meters order by ts limit 10; +select GREATEST('r', nch1, nch2) from ts_4893.meters order by ts limit 10; +select GREATEST('r', var1) from ts_4893.meters order by ts limit 10; +select GREATEST('r', var1, var2) from ts_4893.meters order by ts limit 10; +select GREATEST('二中文测试', nch1) from ts_4893.meters order by ts limit 10; +select GREATEST('二中文测试', nch1, nch2) from ts_4893.meters order by ts limit 10; +select GREATEST('二中文测试', var1) from ts_4893.meters order by ts limit 10; +select GREATEST('二中文测试', var1, var2) from ts_4893.meters order by ts limit 10; +select GREATEST('23', 3443434343434343); +select GREATEST(co, 3443434343434343) from ts_4893.n1; +select GREATEST('23', 1443434343434343) from ts_4893.n1; +select GREATEST('23', 3443434343434343) from ts_4893.n1 +select GREATEST(current, voltage) from ts_4893.n1; +select GREATEST(current, voltage, '15') from ts_4893.n1; \ No newline at end of file diff --git a/tests/army/query/function/in/least.in b/tests/army/query/function/in/least.in new file mode 100644 index 0000000000..1dd664824d --- /dev/null +++ b/tests/army/query/function/in/least.in @@ -0,0 +1,228 @@ +alter local 'transToStrWhenMixTypeInLeast' '1'; +select LEAST(1,2,3,4,5,6,7,8,9,10); +select LEAST(1,1.1,2.23,3.4444,5.66666666,6.21241241,7.999999999999); +select LEAST(1,'2',3.3,4.4,5); +select LEAST(1,2,3,4,5,'5.1'); +select LEAST('1','2','3','4',5); +select LEAST('1','2','3','4','5'); +select LEAST(1,2,3,4,5,6,7,'a','b','一','二','三'); +select LEAST(1,2,3,4,5,6,7,'a','b','c','1','2','1231213'); +select LEAST(1,2,3,4,5,6,7,'a','b','c','1','2','1231213','1231213.123123'); +select LEAST(cast(0 as bool), cast(1 as tinyint), cast(2 as smallint), cast(3 as int), cast(4 as bigint), cast(5 as float), cast(6 as double), cast(8 as varchar(20)), cast(9 as nchar(20))); +select LEAST(cast(0 as bool), cast(1 as tinyint unsigned), cast(2 as smallint unsigned), cast(3 as int unsigned), cast(4 as bigint unsigned), cast(5 as float), cast(6 as double), cast(8 as varchar(20)), cast(9 as nchar(20))); +select LEAST(cast(0 as bool), cast(1 as tinyint), cast(2 as smallint), cast(3 as int), cast(4 as bigint), cast(5 as float), cast(6 as double), cast(8 as varchar(20)), cast(9 as nchar(20)), cast(0 as bool), cast(1 as tinyint unsigned), cast(2 as smallint unsigned), cast(3 as int unsigned), cast(4 as bigint unsigned), cast(5 as float), cast(6 as double)); +select LEAST(cast(100 as tinyint), cast(101 as tinyint)); +select LEAST(cast(100 as tinyint), cast(101 as smallint)); +select LEAST(cast(100 as tinyint), cast(101 as int)); +select LEAST(cast(100 as tinyint), cast(101 as bigint)); +select LEAST(cast(100 as tinyint), cast(101 as float)); +select LEAST(cast(100 as tinyint), cast(101 as double)); +select LEAST(cast(100 as tinyint), cast(101 as varchar(20))); +select LEAST(cast(100 as tinyint), cast(101 as nchar(20))); +select LEAST(cast(101 as tinyint), cast(100 as tinyint)); +select LEAST(cast(101 as tinyint), cast(100 as smallint)); +select LEAST(cast(101 as tinyint), cast(100 as int)); +select LEAST(cast(101 as tinyint), cast(100 as bigint)); +select LEAST(cast(101 as tinyint), cast(100 as float)); +select LEAST(cast(101 as tinyint), cast(100 as double)); +select LEAST(cast(101 as tinyint), cast(100 as varchar(20))); +select LEAST(cast(101 as tinyint), cast(100 as nchar(20))); +select LEAST(cast(1000 as smallint), cast(1001 as smallint)); +select LEAST(cast(1000 as smallint), cast(1001 as int)); +select LEAST(cast(1000 as smallint), cast(1001 as bigint)); +select LEAST(cast(1000 as smallint), cast(1001 as float)); +select LEAST(cast(1000 as smallint), cast(1001 as double)); +select LEAST(cast(1000 as smallint), cast(1001 as varchar(20))); +select LEAST(cast(1000 as smallint), cast(1001 as nchar(20))); +select LEAST(cast(1001 as smallint), cast(1000 as smallint)); +select LEAST(cast(1001 as smallint), cast(1000 as int)); +select LEAST(cast(1001 as smallint), cast(1000 as bigint)); +select LEAST(cast(1001 as smallint), cast(1000 as float)); +select LEAST(cast(1001 as smallint), cast(1000 as double)); +select LEAST(cast(1001 as smallint), cast(1000 as varchar(20))); +select LEAST(cast(1001 as smallint), cast(1000 as nchar(20))); +select LEAST(cast(1000000 as int), cast(1000001 as int)); +select LEAST(cast(1000000 as int), cast(1000001 as bigint)); +select LEAST(cast(1000000 as int), cast(1000001 as float)); +select LEAST(cast(1000000 as int), cast(1000001 as double)); +select LEAST(cast(1000000 as int), cast(1000001 as varchar(20))); +select LEAST(cast(1000000 as int), cast(1000001 as nchar(20))); +select LEAST(cast(1000001 as int), cast(1000000 as int)); +select LEAST(cast(1000001 as int), cast(1000000 as bigint)); +select LEAST(cast(1000001 as int), cast(1000000 as float)); +select LEAST(cast(1000001 as int), cast(1000000 as double)); +select LEAST(cast(1000001 as int), cast(1000000 as varchar(20))); +select LEAST(cast(1000001 as int), cast(1000000 as nchar(20))); +select LEAST(cast(1000000000 as bigint), cast(1000000001 as bigint)); +select LEAST(cast(1000000000 as bigint), cast(1000000001 as float)); +select LEAST(cast(1000000000 as bigint), cast(1000000001 as double)); +select LEAST(cast(1000000000 as bigint), cast(1000000001 as varchar(20))); +select LEAST(cast(1000000000 as bigint), cast(1000000001 as nchar(20))); +select LEAST(cast(1000000001 as bigint), cast(1000000000 as bigint)); +select LEAST(cast(1000000001 as bigint), cast(1000000000 as float)); +select LEAST(cast(1000000001 as bigint), cast(1000000000 as double)); +select LEAST(cast(1000000001 as bigint), cast(1000000000 as varchar(20))); +select LEAST(cast(1000000001 as bigint), cast(1000000000 as nchar(20))); +select LEAST(cast(100000.1111111 as float), cast(100001.1111111 as float)); +select LEAST(cast(100000.1111111 as float), cast(100001.1111111 as double)); +select LEAST(cast(100000.1111111 as float), cast(100001.1111111 as timestamp)); +select LEAST(cast(100000.1111111 as float), cast(100001.1111111 as varchar(20))); +select LEAST(cast(100000.1111111 as float), cast(100001.1111111 as nchar(20))); +select LEAST(cast(100001.1111111 as float), cast(100000.1111111 as float)); +select LEAST(cast(100001.1111111 as float), cast(100000.1111111 as double)); +select LEAST(cast(100001.1111111 as float), cast(100000.1111111 as timestamp)); +select LEAST(cast(100001.1111111 as float), cast(100000.1111111 as varchar(20))); +select LEAST(cast(100001.1111111 as float), cast(100000.1111111 as nchar(20))); +select LEAST(cast(100000.1111111 as double), cast(100001.1111111 as double)); +select LEAST(cast(100000.1111111 as double), cast(100001.1111111 as timestamp)); +select LEAST(cast(100000.1111111 as double), cast(100001.1111111 as varchar(20))); +select LEAST(cast(100000.1111111 as double), cast(100001.1111111 as nchar(20))); +select LEAST(cast(100001.1111111 as double), cast(100000.1111111 as double)); +select LEAST(cast(100001.1111111 as double), cast(100000.1111111 as timestamp)); +select LEAST(cast(100001.1111111 as double), cast(100000.1111111 as varchar(20))); +select LEAST(cast(100001.1111111 as double), cast(100000.1111111 as nchar(20))); +select LEAST(cast('中文测试' as varchar(20)), cast('中文测试一' as varchar(20))); +select LEAST(cast('中文测试' as varchar(20)), cast('中文测试一' as nchar(20))); +select LEAST(cast('中文测试一' as varchar(20)), cast('中文测试' as varchar(20))); +select LEAST(cast('中文测试一' as varchar(20)), cast('中文测试' as nchar(20))); +select LEAST(cast('abc123abc' as varchar(20)), cast('abc124abc' as varchar(20))); +select LEAST(cast('abc123abc' as varchar(20)), cast('abc124abc' as nchar(20))); +select LEAST(cast('abc124abc' as varchar(20)), cast('abc123abc' as varchar(20))); +select LEAST(cast('abc124abc' as varchar(20)), cast('abc123abc' as nchar(20))); +select LEAST(cast('abc123abc' as nchar(20)), cast('abc124abc' as nchar(20))); +select LEAST(cast(100 as tinyint), cast(101 as float), cast(102 as varchar(20))); +select LEAST(cast(100 as varchar(20)), cast(101 as float), cast(102 as tinyint)); +select LEAST('a','b','c','d','e','f','g','h','1231','15155'); +select LEAST(current, voltage, phase, id, nch1, nch2, var1, var2) from ts_4893.meters order by ts limit 10; +select LEAST(current, voltage, phase, id) from ts_4893.meters order by ts limit 10; +select LEAST(nch1, nch2, var1, var2) from ts_4893.meters order by ts limit 10; +select LEAST(221, voltage) from ts_4893.meters order by ts limit 10; +select LEAST(5, id) from ts_4893.meters order by ts limit 10; +select LEAST('r', nch1) from ts_4893.meters order by ts limit 10; +select LEAST('r', nch1, nch2) from ts_4893.meters order by ts limit 10; +select LEAST('r', var1) from ts_4893.meters order by ts limit 10; +select LEAST('r', var1, var2) from ts_4893.meters order by ts limit 10; +select LEAST('二中文测试', nch1) from ts_4893.meters order by ts limit 10; +select LEAST('二中文测试', nch1, nch2) from ts_4893.meters order by ts limit 10; +select LEAST('二中文测试', var1) from ts_4893.meters order by ts limit 10; +select LEAST('二中文测试', var1, var2) from ts_4893.meters order by ts limit 10; +select LEAST('23', 3443434343434343); +select LEAST(co, 3443434343434343) from ts_4893.n1; +select LEAST('23', 3443434343434343) from ts_4893.n1; +select LEAST('23', 1443434343434343) from ts_4893.n1; +select LEAST(current, voltage) from ts_4893.n1; +select LEAST(current, voltage, '15') from ts_4893.n1; +alter local 'transToStrWhenMixTypeInLeast' '0'; +select LEAST(1,2,3,4,5,6,7,8,9,10); +select LEAST(1,1.1,2.23,3.4444,5.66666666,6.21241241,7.999999999999); +select LEAST(1,'2',3.3,4.4,5); +select LEAST(1,2,3,4,5,'5.1'); +select LEAST('1','2','3','4',5); +select LEAST('1','2','3','4','5'); +select LEAST(1,2,3,4,5,6,7,'a','b','一','二','三'); +select LEAST(1,2,3,4,5,6,7,'a','b','c','1','2','1231213'); +select LEAST(1,2,3,4,5,6,7,'a','b','c','1','2','1231213','1231213.123123'); +select LEAST(cast(0 as bool), cast(1 as tinyint), cast(2 as smallint), cast(3 as int), cast(4 as bigint), cast(5 as float), cast(6 as double), cast(8 as varchar(20)), cast(9 as nchar(20))); +select LEAST(cast(0 as bool), cast(1 as tinyint unsigned), cast(2 as smallint unsigned), cast(3 as int unsigned), cast(4 as bigint unsigned), cast(5 as float), cast(6 as double), cast(8 as varchar(20)), cast(9 as nchar(20))); +select LEAST(cast(0 as bool), cast(1 as tinyint), cast(2 as smallint), cast(3 as int), cast(4 as bigint), cast(5 as float), cast(6 as double), cast(8 as varchar(20)), cast(9 as nchar(20)), cast(0 as bool), cast(1 as tinyint unsigned), cast(2 as smallint unsigned), cast(3 as int unsigned), cast(4 as bigint unsigned), cast(5 as float), cast(6 as double)); +select LEAST(cast(100 as tinyint), cast(101 as tinyint)); +select LEAST(cast(100 as tinyint), cast(101 as smallint)); +select LEAST(cast(100 as tinyint), cast(101 as int)); +select LEAST(cast(100 as tinyint), cast(101 as bigint)); +select LEAST(cast(100 as tinyint), cast(101 as float)); +select LEAST(cast(100 as tinyint), cast(101 as double)); +select LEAST(cast(100 as tinyint), cast(101 as varchar(20))); +select LEAST(cast(100 as tinyint), cast(101 as nchar(20))); +select LEAST(cast(101 as tinyint), cast(100 as tinyint)); +select LEAST(cast(101 as tinyint), cast(100 as smallint)); +select LEAST(cast(101 as tinyint), cast(100 as int)); +select LEAST(cast(101 as tinyint), cast(100 as bigint)); +select LEAST(cast(101 as tinyint), cast(100 as float)); +select LEAST(cast(101 as tinyint), cast(100 as double)); +select LEAST(cast(101 as tinyint), cast(100 as varchar(20))); +select LEAST(cast(101 as tinyint), cast(100 as nchar(20))); +select LEAST(cast(1000 as smallint), cast(1001 as smallint)); +select LEAST(cast(1000 as smallint), cast(1001 as int)); +select LEAST(cast(1000 as smallint), cast(1001 as bigint)); +select LEAST(cast(1000 as smallint), cast(1001 as float)); +select LEAST(cast(1000 as smallint), cast(1001 as double)); +select LEAST(cast(1000 as smallint), cast(1001 as varchar(20))); +select LEAST(cast(1000 as smallint), cast(1001 as nchar(20))); +select LEAST(cast(1001 as smallint), cast(1000 as smallint)); +select LEAST(cast(1001 as smallint), cast(1000 as int)); +select LEAST(cast(1001 as smallint), cast(1000 as bigint)); +select LEAST(cast(1001 as smallint), cast(1000 as float)); +select LEAST(cast(1001 as smallint), cast(1000 as double)); +select LEAST(cast(1001 as smallint), cast(1000 as varchar(20))); +select LEAST(cast(1001 as smallint), cast(1000 as nchar(20))); +select LEAST(cast(1000000 as int), cast(1000001 as int)); +select LEAST(cast(1000000 as int), cast(1000001 as bigint)); +select LEAST(cast(1000000 as int), cast(1000001 as float)); +select LEAST(cast(1000000 as int), cast(1000001 as double)); +select LEAST(cast(1000000 as int), cast(1000001 as varchar(20))); +select LEAST(cast(1000000 as int), cast(1000001 as nchar(20))); +select LEAST(cast(1000001 as int), cast(1000000 as int)); +select LEAST(cast(1000001 as int), cast(1000000 as bigint)); +select LEAST(cast(1000001 as int), cast(1000000 as float)); +select LEAST(cast(1000001 as int), cast(1000000 as double)); +select LEAST(cast(1000001 as int), cast(1000000 as varchar(20))); +select LEAST(cast(1000001 as int), cast(1000000 as nchar(20))); +select LEAST(cast(1000000000 as bigint), cast(1000000001 as bigint)); +select LEAST(cast(1000000000 as bigint), cast(1000000001 as float)); +select LEAST(cast(1000000000 as bigint), cast(1000000001 as double)); +select LEAST(cast(1000000000 as bigint), cast(1000000001 as varchar(20))); +select LEAST(cast(1000000000 as bigint), cast(1000000001 as nchar(20))); +select LEAST(cast(1000000001 as bigint), cast(1000000000 as bigint)); +select LEAST(cast(1000000001 as bigint), cast(1000000000 as float)); +select LEAST(cast(1000000001 as bigint), cast(1000000000 as double)); +select LEAST(cast(1000000001 as bigint), cast(1000000000 as varchar(20))); +select LEAST(cast(1000000001 as bigint), cast(1000000000 as nchar(20))); +select LEAST(cast(100000.1111111 as float), cast(100001.1111111 as float)); +select LEAST(cast(100000.1111111 as float), cast(100001.1111111 as double)); +select LEAST(cast(100000.1111111 as float), cast(100001.1111111 as timestamp)); +select LEAST(cast(100000.1111111 as float), cast(100001.1111111 as varchar(20))); +select LEAST(cast(100000.1111111 as float), cast(100001.1111111 as nchar(20))); +select LEAST(cast(100001.1111111 as float), cast(100000.1111111 as float)); +select LEAST(cast(100001.1111111 as float), cast(100000.1111111 as double)); +select LEAST(cast(100001.1111111 as float), cast(100000.1111111 as timestamp)); +select LEAST(cast(100001.1111111 as float), cast(100000.1111111 as varchar(20))); +select LEAST(cast(100001.1111111 as float), cast(100000.1111111 as nchar(20))); +select LEAST(cast(100000.1111111 as double), cast(100001.1111111 as double)); +select LEAST(cast(100000.1111111 as double), cast(100001.1111111 as timestamp)); +select LEAST(cast(100000.1111111 as double), cast(100001.1111111 as varchar(20))); +select LEAST(cast(100000.1111111 as double), cast(100001.1111111 as nchar(20))); +select LEAST(cast(100001.1111111 as double), cast(100000.1111111 as double)); +select LEAST(cast(100001.1111111 as double), cast(100000.1111111 as timestamp)); +select LEAST(cast(100001.1111111 as double), cast(100000.1111111 as varchar(20))); +select LEAST(cast(100001.1111111 as double), cast(100000.1111111 as nchar(20))); +select LEAST(cast('中文测试' as varchar(20)), cast('中文测试一' as varchar(20))); +select LEAST(cast('中文测试' as varchar(20)), cast('中文测试一' as nchar(20))); +select LEAST(cast('中文测试一' as varchar(20)), cast('中文测试' as varchar(20))); +select LEAST(cast('中文测试一' as varchar(20)), cast('中文测试' as nchar(20))); +select LEAST(cast('abc123abc' as varchar(20)), cast('abc124abc' as varchar(20))); +select LEAST(cast('abc123abc' as varchar(20)), cast('abc124abc' as nchar(20))); +select LEAST(cast('abc124abc' as varchar(20)), cast('abc123abc' as varchar(20))); +select LEAST(cast('abc124abc' as varchar(20)), cast('abc123abc' as nchar(20))); +select LEAST(cast('abc123abc' as nchar(20)), cast('abc124abc' as nchar(20))); +select LEAST(cast(100 as tinyint), cast(101 as float), cast(102 as varchar(20))); +select LEAST(cast(100 as varchar(20)), cast(101 as float), cast(102 as tinyint)); +select LEAST('a','b','c','d','e','f','g','h','1231','15155'); +select LEAST(current, voltage, phase, id, nch1, nch2, var1, var2) from ts_4893.meters order by ts limit 10; +select LEAST(current, voltage, phase, id) from ts_4893.meters order by ts limit 10; +select LEAST(nch1, nch2, var1, var2) from ts_4893.meters order by ts limit 10; +select LEAST(221, voltage) from ts_4893.meters order by ts limit 10; +select LEAST(5, id) from ts_4893.meters order by ts limit 10; +select LEAST('r', nch1) from ts_4893.meters order by ts limit 10; +select LEAST('r', nch1, nch2) from ts_4893.meters order by ts limit 10; +select LEAST('r', var1) from ts_4893.meters order by ts limit 10; +select LEAST('r', var1, var2) from ts_4893.meters order by ts limit 10; +select LEAST('二中文测试', nch1) from ts_4893.meters order by ts limit 10; +select LEAST('二中文测试', nch1, nch2) from ts_4893.meters order by ts limit 10; +select LEAST('二中文测试', var1) from ts_4893.meters order by ts limit 10; +select LEAST('二中文测试', var1, var2) from ts_4893.meters order by ts limit 10; +select LEAST('23', 3443434343434343); +select LEAST(co, 3443434343434343) from ts_4893.n1; +select LEAST('23', 3443434343434343) from ts_4893.n1; +select LEAST('23', 1443434343434343) from ts_4893.n1; +select LEAST(current, voltage) from ts_4893.n1; +select LEAST(current, voltage, '15') from ts_4893.n1; \ No newline at end of file diff --git a/tests/army/query/function/test_function.py b/tests/army/query/function/test_function.py index c583d08cec..0925a0e066 100644 --- a/tests/army/query/function/test_function.py +++ b/tests/army/query/function/test_function.py @@ -40,37 +40,10 @@ class TDTestCase(TBase): "`var2` VARCHAR(50)) TAGS (`groupid` TINYINT, `location` VARCHAR(16));") tdSql.execute("CREATE table d0 using meters tags(1, 'beijing')") tdSql.execute("insert into d0 file '%s'" % datafile) - - def test_normal_query(self, testCase): - # read sql from .sql file and execute - tdLog.info(f"test normal query.") - sqlFile = etool.curFile(__file__, f"in/{testCase}.in") - ansFile = etool.curFile(__file__, f"ans/{testCase}.csv") - with open(sqlFile, 'r') as sql_file: - sql_statement = '' - tdSql.csvLine = 0 - for line in sql_file: - if not line.strip() or line.strip().startswith('--'): - continue - - sql_statement += line.strip() - if sql_statement.endswith(';'): - sql_statement = sql_statement.rstrip(';') - tdSql.checkDataCsvByLine(sql_statement, ansFile) - sql_statement = '' - err_file_path = etool.curFile(__file__, f"in/{testCase}.err") - if not os.path.isfile(err_file_path): - return None - with open(err_file_path, 'r') as err_file: - err_statement = '' - for line in err_file: - if not line.strip() or line.strip().startswith('--'): - continue - - err_statement += line.strip() - if err_statement.endswith(';'): - tdSql.error(err_statement) - err_statement = '' + tdSql.execute("CREATE TABLE `n1` (`ts` TIMESTAMP, `current` FLOAT, `voltage` INT, co NCHAR(10))") + tdSql.execute("insert into n1 values(now, 1, null, '23')") + tdSql.execute("insert into n1 values(now, null, 3, '23')") + tdSql.execute("insert into n1 values(now, 5, 3, '23')") def test_normal_query_new(self, testCase): # read sql from .sql file and execute @@ -310,6 +283,150 @@ class TDTestCase(TBase): tdSql.error("select * from (select to_iso8601(ts, timezone()), timezone() from ts_4893.meters \ order by ts desc) limit 1000;", expectErrInfo="Invalid parameter data type : to_iso8601") # TS-5340 + def test_greatest(self): + self.test_normal_query_new("greatest") + + tdSql.execute("alter local 'transToStrWhenMixTypeInLeast' '1';") + + tdSql.query("select GREATEST(NULL, NULL, NULL, NULL);") + tdSql.checkRows(1) + tdSql.checkData(0, 0, None) + + tdSql.query("select GREATEST(1, NULL, NULL, NULL);") + tdSql.checkRows(1) + tdSql.checkData(0, 0, None) + + tdSql.query("select GREATEST(id, NULL, 1) from ts_4893.meters order by ts limit 10;") + tdSql.checkRows(10) + tdSql.checkData(0, 0, None) + + tdSql.query("select GREATEST(cast(100 as tinyint), cast(101 as timestamp));") + tdSql.checkRows(1) + tdSql.checkData(0, 0, "1970-01-01 08:00:00.101") + + tdSql.query("select GREATEST(cast(101 as tinyint), cast(100 as timestamp));") + tdSql.checkRows(1) + tdSql.checkData(0, 0, "1970-01-01 08:00:00.101") + + tdSql.query("select GREATEST(cast(1000 as smallint), cast(1001 as timestamp));") + tdSql.checkRows(1) + tdSql.checkData(0, 0, "1970-01-01 08:00:01.001") + + tdSql.query("select GREATEST(cast(1001 as smallint), cast(1000 as timestamp));") + tdSql.checkRows(1) + tdSql.checkData(0, 0, "1970-01-01 08:00:01.001") + + tdSql.query("select GREATEST(cast(1000000 as int), cast(1000001 as timestamp));") + tdSql.checkRows(1) + tdSql.checkData(0, 0, "1970-01-01 08:16:40.001") + + tdSql.query("select GREATEST(cast(1000001 as int), cast(1000000 as timestamp));") + tdSql.checkRows(1) + tdSql.checkData(0, 0, "1970-01-01 08:16:40.001") + + tdSql.query("select GREATEST(cast(1000000000 as bigint), cast(1000000001 as timestamp));") + tdSql.checkRows(1) + tdSql.checkData(0, 0, "1970-01-12 21:46:40.001") + + tdSql.query("select GREATEST(cast(1000000001 as bigint), cast(1000000000 as timestamp));") + tdSql.checkRows(1) + tdSql.checkData(0, 0, "1970-01-12 21:46:40.001") + + tdSql.query("select GREATEST(cast(1725506504000 as timestamp), cast(1725506510000 as timestamp));") + tdSql.checkRows(1) + tdSql.checkData(0, 0, "2024-09-05 11:21:50") + + tdSql.query("select GREATEST(cast(1725506510000 as timestamp), cast(1725506504000 as timestamp));") + tdSql.checkRows(1) + tdSql.checkData(0, 0, "2024-09-05 11:21:50") + + tdSql.query("select GREATEST(cast(100 as tinyint), cast(101 as varchar(20)), cast(102 as float));") + tdSql.checkRows(1) + tdSql.checkData(0, 0, "102.000000") + + tdSql.query("select GREATEST(cast(100 as varchar(20)), cast(101 as tinyint), cast(102 as float));") + tdSql.checkRows(1) + tdSql.checkData(0, 0, "102.000000") + + tdSql.error("select GREATEST(cast('a' as varbinary), cast('b' as varbinary), 'c', 'd');") + tdSql.error("select GREATEST(6, cast('f' as varbinary), cast('b' as varbinary), 'c', 'd');") + + def test_least(self): + self.test_normal_query_new("least") + + tdSql.execute("alter local 'transToStrWhenMixTypeInLeast' '1';") + + tdSql.query("select LEAST(NULL, NULL, NULL, NULL);") + tdSql.checkRows(1) + tdSql.checkData(0, 0, None) + + tdSql.query("select LEAST(1, NULL, NULL, NULL);") + tdSql.checkRows(1) + tdSql.checkData(0, 0, None) + + tdSql.query("select LEAST(id, NULL, 1) from ts_4893.meters order by ts limit 10;") + tdSql.checkRows(10) + tdSql.checkData(0, 0, None) + + tdSql.query("select LEAST(cast(100 as tinyint), cast(101 as timestamp));") + tdSql.checkRows(1) + tdSql.checkData(0, 0, "1970-01-01 08:00:00.100") + + tdSql.query("select LEAST(cast(101 as tinyint), cast(100 as timestamp));") + tdSql.checkRows(1) + tdSql.checkData(0, 0, "1970-01-01 08:00:00.100") + + tdSql.query("select LEAST(cast(1000 as smallint), cast(1001 as timestamp));") + tdSql.checkRows(1) + tdSql.checkData(0, 0, "1970-01-01 08:00:01.000") + + tdSql.query("select LEAST(cast(1001 as smallint), cast(1000 as timestamp));") + tdSql.checkRows(1) + tdSql.checkData(0, 0, "1970-01-01 08:00:01.000") + + tdSql.query("select LEAST(cast(1000000 as int), cast(1000001 as timestamp));") + tdSql.checkRows(1) + tdSql.checkData(0, 0, "1970-01-01 08:16:40.000") + + tdSql.query("select LEAST(cast(1000001 as int), cast(1000000 as timestamp));") + tdSql.checkRows(1) + tdSql.checkData(0, 0, "1970-01-01 08:16:40.000") + + tdSql.query("select LEAST(cast(1000000000 as bigint), cast(1000000001 as timestamp));") + tdSql.checkRows(1) + tdSql.checkData(0, 0, "1970-01-12 21:46:40.000") + + tdSql.query("select LEAST(cast(1000000001 as bigint), cast(1000000000 as timestamp));") + tdSql.checkRows(1) + tdSql.checkData(0, 0, "1970-01-12 21:46:40.000") + + tdSql.query("select LEAST(cast(1725506504000 as timestamp), cast(1725506510000 as timestamp));") + tdSql.checkRows(1) + tdSql.checkData(0, 0, "2024-09-05 11:21:44") + + tdSql.query("select LEAST(cast(1725506510000 as timestamp), cast(1725506504000 as timestamp));") + tdSql.checkRows(1) + tdSql.checkData(0, 0, "2024-09-05 11:21:44") + + tdSql.query("select LEAST(cast(100 as tinyint), cast(101 as varchar(20)), cast(102 as float));") + tdSql.checkRows(1) + tdSql.checkData(0, 0, "100") + + tdSql.query("select LEAST(cast(100 as varchar(20)), cast(101 as tinyint), cast(102 as float));") + tdSql.checkRows(1) + tdSql.checkData(0, 0, "100") + + tdSql.query("select LEAST(cast(100 as float), cast(101 as tinyint), cast(102 as varchar(20)));") + tdSql.checkRows(1) + tdSql.checkData(0, 0, "100.000000") + + tdSql.query("select LEAST(cast(100 as float), cast(101 as varchar(20)), cast(102 as tinyint));") + tdSql.checkRows(1) + tdSql.checkData(0, 0, "100.000000") + + tdSql.error("select LEAST(cast('a' as varbinary), cast('b' as varbinary), 'c', 'd');") + tdSql.error("select LEAST(cast('f' as varbinary), cast('b' as varbinary), 'c', 'd');") + def run(self): tdLog.debug(f"start to excute {__file__}") @@ -326,7 +443,9 @@ class TDTestCase(TBase): self.test_degrees() self.test_radians() self.test_rand() - + self.test_greatest() + self.test_least() + # char function self.test_char_length() self.test_char() diff --git a/tools/shell/src/shellEngine.c b/tools/shell/src/shellEngine.c index b1e21e8f62..99b1c204a2 100644 --- a/tools/shell/src/shellEngine.c +++ b/tools/shell/src/shellEngine.c @@ -668,6 +668,7 @@ void shellPrintField(const char *val, TAOS_FIELD *field, int32_t width, int32_t printf("%*" PRIu64, width, *((uint64_t *)val)); break; case TSDB_DATA_TYPE_FLOAT: + width = width >= LENGTH ? LENGTH - 1 : width; if (tsEnableScience) { printf("%*.7e", width, GET_FLOAT_VAL(val)); } else { @@ -676,6 +677,7 @@ void shellPrintField(const char *val, TAOS_FIELD *field, int32_t width, int32_t } break; case TSDB_DATA_TYPE_DOUBLE: + width = width >= LENGTH ? LENGTH - 1 : width; if (tsEnableScience) { snprintf(buf, LENGTH, "%*.15e", width, GET_DOUBLE_VAL(val)); printf("%s", buf);