diff --git a/.github/workflows/taosd-ci.yml b/.github/workflows/taosd-ci.yml index b7b97cee8e..31eda597ad 100644 --- a/.github/workflows/taosd-ci.yml +++ b/.github/workflows/taosd-ci.yml @@ -70,33 +70,24 @@ jobs: echo ${{ github.event.pull_request.number }} run-tests-on-linux: - uses: taosdata/.github/.github/workflows/run-tests-on-linux.yml + uses: taosdata/.github/.github/workflows/run-tests-on-linux.yml@main needs: fetch-parameters if: ${{ needs.fetch-parameters.outputs.run_tdgpt_test == 'true' || needs.fetch-parameters.outputs.run_function_test == 'true' }} with: tdinternal: false - run_function_test: ${{ needs.fetch-parameters.outputs.run_function_test == 'true' || false }} - run_tdgpt_test: ${{ needs.fetch-parameters.outputs.run_tdgpt_test == 'true' || false }} - source_branch: ${{ github.event.pull_request.head.ref }} - target_branch: ${{ github.event.pull_request.base.ref }} - pr_number: ${{ github.event.pull_request.number }} + run_function_test: ${{ needs.fetch-parameters.outputs.run_function_test == 'true' }} + run_tdgpt_test: ${{ needs.fetch-parameters.outputs.run_tdgpt_test == 'true' }} run-tests-on-mac: - uses: taosdata/.github/.github/workflows/run-tests-on-macos.yml + uses: taosdata/.github/.github/workflows/run-tests-on-macos.yml@main needs: fetch-parameters if: ${{ needs.fetch-parameters.outputs.run_function_test == 'true' }} with: tdinternal: false - source_branch: ${{ github.event.pull_request.head.ref }} - target_branch: ${{ github.event.pull_request.base.ref }} - pr_number: ${{ github.event.pull_request.number }} run-tests-on-windows: - uses: taosdata/.github/.github/workflows/run-tests-on-windows.yml + uses: taosdata/.github/.github/workflows/run-tests-on-windows.yml@main needs: fetch-parameters if: ${{ needs.fetch-parameters.outputs.run_function_test == 'true' }} with: tdinternal: false - source_branch: ${{ github.event.pull_request.head.ref }} - target_branch: ${{ github.event.pull_request.base.ref }} - pr_number: ${{ github.event.pull_request.number }} diff --git a/.github/workflows/tdgpt-ci.yml b/.github/workflows/tdgpt-ci.yml new file mode 100644 index 0000000000..4a438938dc --- /dev/null +++ b/.github/workflows/tdgpt-ci.yml @@ -0,0 +1,51 @@ +name: TDgpt CI + +on: + pull_request: + branches: + - '3.0' + paths: + - 'tools/tdgpt/**' + +jobs: + build: + runs-on: ubuntu-latest + + strategy: + fail-fast: false + matrix: + python-version: ["3.10"] + + defaults: + run: + working-directory: ${{ github.workspace }}/tools/tdgpt + + steps: + - uses: actions/checkout@v4 + + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v3 + with: + python-version: ${{ matrix.python-version }} + cache: 'pip' + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + python -m pip install flake8 pytest pylint + if [ -f requirements.txt ]; then pip install -r requirements.txt; fi + + - name: Checking the code with pylint + run: | + pylint $(git ls-files '*.py') --exit-zero + + - name: Checking the code with flake8 + run: | + # stop the build if there are Python syntax errors or undefined names + flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics + # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide + flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics + + - name: Run test cases with pytest + run: | + pytest diff --git a/.github/workflows/tdgpt-update-service.yml b/.github/workflows/tdgpt-update-service.yml new file mode 100644 index 0000000000..fa7344ce74 --- /dev/null +++ b/.github/workflows/tdgpt-update-service.yml @@ -0,0 +1,41 @@ +name: TDgpt Update Service + +on: + schedule: + - cron: '30 00 * * *' + +env: + WKC: "/root/TDengine" + +jobs: + update-service: + runs-on: + group: CI + labels: [self-hosted, Linux, X64, tdgpt-anode-service] + steps: + - name: Update TDengine codes + run: | + set -euo pipefail + cd ${{ env.WKC }} + git checkout 3.0 + + - name: Package the TDGpt Anode Service + run: | + set -euo pipefail + cd ${{ env.WKC }}/tools/tdgpt/script && ./release.sh + + - name: Reinstall and restart the TDGpt Anode Service + run: | + set -euo pipefail + cd ${{ env.WKC }}/tools/tdgpt/release + if [[ -f "TDengine-enterprise-anode-1.0.1.tar.gz" ]]; then + tar -xzf TDengine-enterprise-anode-1.0.1.tar.gz + cd TDengine-enterprise-anode-1.0.1 + ./install.sh + fi + systemctl restart taosanoded + + - name: Clean up + if: always() + run: | + if [[ -f ${{ env.WKC }}/tools/tdgpt/release/TDengine-enterprise-anode-1.0.1 ]] then rm -rf ${{ env.WKC }}/tools/tdgpt/release/TDengine-enterprise-anode-1.0.1; fi diff --git a/docs/en/14-reference/01-components/02-taosc.md b/docs/en/14-reference/01-components/02-taosc.md index 7b8d3ae78c..83cb3d765b 100644 --- a/docs/en/14-reference/01-components/02-taosc.md +++ b/docs/en/14-reference/01-components/02-taosc.md @@ -44,6 +44,7 @@ The TDengine client driver provides all the APIs needed for application programm |enableQueryHb | |Supported, effective immediately |Internal parameter, whether to send query heartbeat messages| |minSlidingTime | |Supported, effective immediately |Internal parameter, minimum allowable value for sliding| |minIntervalTime | |Supported, effective immediately |Internal parameter, minimum allowable value for interval| +|compareAsStrInGreatest | v3.3.6.0 |Supported, effective immediately |When the greatest and least functions have both numeric and string types as parameters, the comparison type conversion rules are as follows: Integer; 1: uniformly converted to string comparison, 0: uniformly converted to numeric type comparison.| ### Writing Related diff --git a/docs/en/14-reference/03-taos-sql/10-function.md b/docs/en/14-reference/03-taos-sql/10-function.md index 7875501e7e..993b1176fe 100644 --- a/docs/en/14-reference/03-taos-sql/10-function.md +++ b/docs/en/14-reference/03-taos-sql/10-function.md @@ -124,7 +124,39 @@ FLOOR(expr) ``` **Function Description**: Gets the floor of the specified field. - Other usage notes see CEIL function description. + Other usage notes see [CEIL](#ceil) function description. + +#### GREATEST +```sql +GREATEST(expr1, expr2[, expr]...) +``` + +**Function Description**: Get the maximum value of all input parameters. The minimum number of parameters for this function is 2. + +**Version**:ver-3.3.6.0 + +**Return Type**:Refer to the comparison rules. The comparison type is the final return type. + +**Applicable Data Types**: +- Numeric types: timestamp, bool, integer and floating point types +- Strings types: nchar and varchar types. + +**Comparison rules**: The following rules describe the conversion method of the comparison operation: +- If any parameter is NULL, the comparison result is NULL. +- If all parameters in the comparison operation are string types, compare them as string types +- If all parameters are numeric types, compare them as numeric types. +- If there are both string types and numeric types in the parameters, according to the `compareAsStrInGreatest` configuration item, they are uniformly compared as strings or numeric values. By default, they are compared as strings. +- In all cases, when different types are compared, the comparison type will choose the type with a larger range for comparison. For example, when comparing integer types, if there is a BIGINT type, BIGINT will definitely be selected as the comparison type. + +**Related configuration items**: Client configuration, compareAsStrInGreatest is 1, which means that both string types and numeric types are converted to string comparisons, and 0 means that they are converted to numeric types. The default is 1. + + +#### LEAST +```sql +LEAST(expr1, expr2[, expr]...) +``` + +**Function Description**:Get the minimum value of all input parameters. The rest of the description is the same as the [GREATEST](#greatest) function. #### LOG diff --git a/docs/zh/14-reference/01-components/02-taosc.md b/docs/zh/14-reference/01-components/02-taosc.md index 262027bff6..8952e35664 100755 --- a/docs/zh/14-reference/01-components/02-taosc.md +++ b/docs/zh/14-reference/01-components/02-taosc.md @@ -221,6 +221,12 @@ TDengine 客户端驱动提供了应用编程所需要的全部 API,并且在 - 动态修改:不支持 - 支持版本:从 v3.0.0.0 版本开始引入 +#### compareAsStrInGreatest +- 说明:用于决定 greatest、least 函数的参数既有数值类型又有字符串类型时,比较类型的转换规则。 +- 类型:整数;1:统一转为字符串比较,0:统一转为数值类型比较。 +- 动态修改:支持通过 SQL 修改,立即生效 +- 支持版本:从 v3.3.6.0 版本开始引入 + ### 写入相关 #### smlChildTableName diff --git a/docs/zh/14-reference/03-taos-sql/10-function.md b/docs/zh/14-reference/03-taos-sql/10-function.md index ca7fb18b9f..a8959d1d22 100644 --- a/docs/zh/14-reference/03-taos-sql/10-function.md +++ b/docs/zh/14-reference/03-taos-sql/10-function.md @@ -186,7 +186,38 @@ FLOOR(expr) ``` **功能说明**:获得指定字段的向下取整数的结果。 - 其他使用说明参见 CEIL 函数描述。 + 其他使用说明参见 [CEIL](#ceil) 函数描述。 + +#### GREATEST +```sql +GREATEST(expr1, expr2[, expr]...) +``` + +**功能说明**:获得输入的所有参数中的最大值。该函数最小参数个数为 2 个。 + +**使用说明**:ver-3.3.6.0 + +**返回结果类型**:参考比较规则,比较类型即为最终返回类型。 + +**适用数据类型**: +- 数值类型:包括 bool 型,整型和浮点型 +- 字符串类型:包括 nchar 和 varchar 类型。 + +**比较规则**:以下规则描述了比较操作的转换方式: +- 如果有任何一个参数为 NULL,则比较结果为 NULL。 +- 如果比较操作中的所有参数都是字符串类型,按照字符串类型比较 +- 如果所有参数都是数值类型,则将它们作为数值类型进行比较。 +- 如果参数中既有字符串类型,也有数值类型,根据 compareAsStrInGreatest 配置项,统一作为字符串或者数值进行比较。默认按照字符串比较。 +- 在所有情况下,不同类型比较,比较类型会选择范围更大的类型进行比较,例如作为整数类型比较时,如果存在 BIGINT 类型,必定会选择 BIGINT 作为比较类型。 + +**相关配置项**:客户端配置,compareAsStrInGreatest 为 1 表示同时存在字符串类型和数值类型统一转为字符串比较,为 0 表示统一转为数值类型比较。默认为 1。 + +#### LEAST +```sql +LEAST(expr1, expr2[, expr]...) +``` + +**功能说明**:获得输入的所有参数中的最小值。其余部分说明同 [GREATEST](#greatest) 函数。 #### LN diff --git a/include/common/tglobal.h b/include/common/tglobal.h index 8acff4e04b..8e9367d7c2 100644 --- a/include/common/tglobal.h +++ b/include/common/tglobal.h @@ -299,6 +299,7 @@ extern bool tsStreamCoverage; extern int8_t tsS3EpNum; extern int32_t tsStreamNotifyMessageSize; extern int32_t tsStreamNotifyFrameSize; +extern bool tsCompareAsStrInGreatest; extern bool tsExperimental; // #define NEEDTO_COMPRESSS_MSG(size) (tsCompressMsgSize != -1 && (size) > tsCompressMsgSize) diff --git a/include/common/tmsgcb.h b/include/common/tmsgcb.h index cdff5aaba2..4af223b537 100644 --- a/include/common/tmsgcb.h +++ b/include/common/tmsgcb.h @@ -40,6 +40,7 @@ typedef enum { ARB_QUEUE, STREAM_CTRL_QUEUE, STREAM_LONG_EXEC_QUEUE, + STREAM_CHKPT_QUEUE, QUEUE_MAX, } EQueueType; diff --git a/include/common/tmsgdef.h b/include/common/tmsgdef.h index 13a26910c1..2b367939ff 100644 --- a/include/common/tmsgdef.h +++ b/include/common/tmsgdef.h @@ -355,6 +355,7 @@ TD_DEF_MSG_TYPE(TDMT_STREAM_DROP, "stream-drop", NULL, NULL) TD_DEF_MSG_TYPE(TDMT_STREAM_RETRIEVE_TRIGGER, "stream-retri-trigger", NULL, NULL) TD_DEF_MSG_TYPE(TDMT_STREAM_CONSEN_CHKPT, "stream-consen-chkpt", NULL, NULL) + TD_DEF_MSG_TYPE(TDMT_STREAM_CHKPT_EXEC, "stream-exec-chkpt", NULL, NULL) TD_CLOSE_MSG_SEG(TDMT_STREAM_MSG) TD_NEW_MSG_SEG(TDMT_MON_MSG) //5 << 8 diff --git a/include/common/ttypes.h b/include/common/ttypes.h index d0cddd87a9..95fe14e572 100644 --- a/include/common/ttypes.h +++ b/include/common/ttypes.h @@ -276,6 +276,9 @@ typedef struct { #define IS_STR_DATA_TYPE(t) \ (((t) == TSDB_DATA_TYPE_VARCHAR) || ((t) == TSDB_DATA_TYPE_VARBINARY) || ((t) == TSDB_DATA_TYPE_NCHAR)) +#define IS_COMPARE_STR_DATA_TYPE(t) \ + (((t) == TSDB_DATA_TYPE_VARCHAR) || ((t) == TSDB_DATA_TYPE_NCHAR)) + #define IS_VALID_TINYINT(_t) ((_t) >= INT8_MIN && (_t) <= INT8_MAX) #define IS_VALID_SMALLINT(_t) ((_t) >= INT16_MIN && (_t) <= INT16_MAX) #define IS_VALID_INT(_t) ((_t) >= INT32_MIN && (_t) <= INT32_MAX) diff --git a/include/libs/function/functionMgt.h b/include/libs/function/functionMgt.h index 41b5d76371..1949081993 100644 --- a/include/libs/function/functionMgt.h +++ b/include/libs/function/functionMgt.h @@ -90,6 +90,8 @@ typedef enum EFunctionType { FUNCTION_TYPE_DEGREES, FUNCTION_TYPE_RADIANS, FUNCTION_TYPE_TRUNCATE, + FUNCTION_TYPE_GREATEST, + FUNCTION_TYPE_LEAST, // string function FUNCTION_TYPE_LENGTH = 1500, diff --git a/include/libs/scalar/filter.h b/include/libs/scalar/filter.h index a98bf29afb..99f1759a7a 100644 --- a/include/libs/scalar/filter.h +++ b/include/libs/scalar/filter.h @@ -66,6 +66,8 @@ int32_t filterPartitionCond(SNode **pCondition, SNode **pPrimaryKeyCond, SNode * SNode **pOtherCond); int32_t filterIsMultiTableColsCond(SNode *pCond, bool *res); EConditionType filterClassifyCondition(SNode *pNode); +int32_t filterGetCompFunc(__compar_fn_t *func, int32_t type, int32_t optr); +bool filterDoCompare(__compar_fn_t func, uint8_t optr, void *left, void *right); #ifdef __cplusplus } diff --git a/include/libs/scalar/scalar.h b/include/libs/scalar/scalar.h index 67fd954ad7..d1dda544ae 100644 --- a/include/libs/scalar/scalar.h +++ b/include/libs/scalar/scalar.h @@ -44,6 +44,7 @@ int32_t scalarGenerateSetFromList(void **data, void *pNode, uint32_t type, int8_ int32_t vectorGetConvertType(int32_t type1, int32_t type2); int32_t vectorConvertSingleColImpl(const SScalarParam *pIn, SScalarParam *pOut, int32_t *overflow, int32_t startIndex, int32_t numOfRows); +int32_t vectorConvertSingleCol(SScalarParam *input, SScalarParam *output, int32_t type, int32_t startIndex, int32_t numOfRows); /* Math functions */ int32_t absFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput); @@ -71,6 +72,8 @@ int32_t signFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutp int32_t degreesFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput); int32_t radiansFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput); int32_t randFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput); +int32_t greatestFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput); +int32_t leastFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput); /* String functions */ int32_t lengthFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput); diff --git a/include/libs/stream/tstream.h b/include/libs/stream/tstream.h index 372322c0b8..bdb8bde2da 100644 --- a/include/libs/stream/tstream.h +++ b/include/libs/stream/tstream.h @@ -702,8 +702,8 @@ int32_t streamTaskClearHTaskAttr(SStreamTask* pTask, int32_t clearRelHalt); int32_t streamExecTask(SStreamTask* pTask); int32_t streamResumeTask(SStreamTask* pTask); -int32_t streamTrySchedExec(SStreamTask* pTask); -int32_t streamTaskSchedTask(SMsgCb* pMsgCb, int32_t vgId, int64_t streamId, int32_t taskId, int32_t execType); +int32_t streamTrySchedExec(SStreamTask* pTask, bool chkptExec); +int32_t streamTaskSchedTask(SMsgCb* pMsgCb, int32_t vgId, int64_t streamId, int32_t taskId, int32_t execType, bool chkptExec); void streamTaskResumeInFuture(SStreamTask* pTask); void streamTaskClearSchedIdleInfo(SStreamTask* pTask); void streamTaskSetIdleInfo(SStreamTask* pTask, int32_t idleTime); diff --git a/source/common/src/tglobal.c b/source/common/src/tglobal.c index a3c8f4fd52..756d03fd8a 100644 --- a/source/common/src/tglobal.c +++ b/source/common/src/tglobal.c @@ -130,6 +130,8 @@ uint32_t tsEncryptionKeyChksum = 0; int8_t tsEncryptionKeyStat = ENCRYPT_KEY_STAT_UNSET; int8_t tsGrant = 1; +bool tsCompareAsStrInGreatest = true; + // monitor bool tsEnableMonitor = true; int32_t tsMonitorInterval = 30; @@ -746,6 +748,8 @@ static int32_t taosAddClientCfg(SConfig *pCfg) { TAOS_CHECK_RETURN( cfgAddBool(pCfg, "streamCoverage", tsStreamCoverage, CFG_DYN_CLIENT, CFG_DYN_CLIENT, CFG_CATEGORY_LOCAL)); + + TAOS_CHECK_RETURN(cfgAddBool(pCfg, "compareAsStrInGreatest", tsCompareAsStrInGreatest, CFG_SCOPE_CLIENT, CFG_DYN_CLIENT,CFG_CATEGORY_LOCAL)); TAOS_RETURN(TSDB_CODE_SUCCESS); } @@ -1480,6 +1484,9 @@ static int32_t taosSetClientCfg(SConfig *pCfg) { TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "streamCoverage"); tsStreamCoverage = pItem->bval; + TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "compareAsStrInGreatest"); + tsCompareAsStrInGreatest = pItem->bval; + TAOS_RETURN(TSDB_CODE_SUCCESS); } @@ -2783,7 +2790,8 @@ static int32_t taosCfgDynamicOptionsForClient(SConfig *pCfg, const char *name) { {"numOfRpcSessions", &tsNumOfRpcSessions}, {"bypassFlag", &tsBypassFlag}, {"safetyCheckLevel", &tsSafetyCheckLevel}, - {"streamCoverage", &tsStreamCoverage}}; + {"streamCoverage", &tsStreamCoverage}, + {"compareAsStrInGreatest", &tsCompareAsStrInGreatest}}; if ((code = taosCfgSetOption(debugOptions, tListLen(debugOptions), pItem, true)) != TSDB_CODE_SUCCESS) { code = taosCfgSetOption(options, tListLen(options), pItem, false); diff --git a/source/dnode/mgmt/mgmt_snode/inc/smInt.h b/source/dnode/mgmt/mgmt_snode/inc/smInt.h index 9d519e88f0..0df4b1c58a 100644 --- a/source/dnode/mgmt/mgmt_snode/inc/smInt.h +++ b/source/dnode/mgmt/mgmt_snode/inc/smInt.h @@ -47,7 +47,7 @@ int32_t smPutMsgToQueue(SSnodeMgmt *pMgmt, EQueueType qtype, SRpcMsg *pMsg); int32_t smPutNodeMsgToMgmtQueue(SSnodeMgmt *pMgmt, SRpcMsg *pMsg); int32_t smPutNodeMsgToWriteQueue(SSnodeMgmt *pMgmt, SRpcMsg *pMsg); int32_t smPutNodeMsgToStreamQueue(SSnodeMgmt *pMgmt, SRpcMsg *pMsg); -void sndEnqueueStreamDispatch(SSnode *pSnode, SRpcMsg *pMsg); +int32_t smPutNodeMsgToChkptQueue(SSnodeMgmt *pMgmt, SRpcMsg *pMsg); #ifdef __cplusplus } diff --git a/source/dnode/mgmt/mgmt_snode/src/smHandle.c b/source/dnode/mgmt/mgmt_snode/src/smHandle.c index 024e2e4e99..11710d7b39 100644 --- a/source/dnode/mgmt/mgmt_snode/src/smHandle.c +++ b/source/dnode/mgmt/mgmt_snode/src/smHandle.c @@ -102,6 +102,8 @@ SArray *smGetMsgHandles() { if (dmSetMgmtHandle(pArray, TDMT_MND_STREAM_REQ_CHKPT_RSP, smPutNodeMsgToStreamQueue, 1) == NULL) goto _OVER; if (dmSetMgmtHandle(pArray, TDMT_MND_STREAM_CHKPT_REPORT_RSP, smPutNodeMsgToStreamQueue, 1) == NULL) goto _OVER; + if (dmSetMgmtHandle(pArray, TDMT_STREAM_CHKPT_EXEC, smPutNodeMsgToStreamQueue, 0) == NULL) goto _OVER; + code = 0; _OVER: if (code != 0) { diff --git a/source/dnode/mgmt/mgmt_snode/src/smWorker.c b/source/dnode/mgmt/mgmt_snode/src/smWorker.c index 1e882fc656..1255542454 100644 --- a/source/dnode/mgmt/mgmt_snode/src/smWorker.c +++ b/source/dnode/mgmt/mgmt_snode/src/smWorker.c @@ -162,6 +162,9 @@ int32_t smPutMsgToQueue(SSnodeMgmt *pMgmt, EQueueType qtype, SRpcMsg *pRpc) { case WRITE_QUEUE: code = smPutNodeMsgToWriteQueue(pMgmt, pMsg); break; + case STREAM_CHKPT_QUEUE: + code = smPutNodeMsgToStreamQueue(pMgmt, pMsg); + break; default: code = TSDB_CODE_INVALID_PARA; rpcFreeCont(pMsg->pCont); @@ -172,7 +175,6 @@ int32_t smPutMsgToQueue(SSnodeMgmt *pMgmt, EQueueType qtype, SRpcMsg *pRpc) { } int32_t smPutNodeMsgToMgmtQueue(SSnodeMgmt *pMgmt, SRpcMsg *pMsg) { - int32_t code = 0; SMultiWorker *pWorker = taosArrayGetP(pMgmt->writeWroker, 0); if (pWorker == NULL) { return TSDB_CODE_INVALID_MSG; @@ -198,3 +200,10 @@ int32_t smPutNodeMsgToStreamQueue(SSnodeMgmt *pMgmt, SRpcMsg *pMsg) { dTrace("msg:%p, put into worker %s", pMsg, pWorker->name); return taosWriteQitem(pWorker->queue, pMsg); } + +//int32_t smPutNodeMsgToChkptQueue(SSnodeMgmt *pMgmt, SRpcMsg *pMsg) { +// SSingleWorker *pWorker = &pMgmt->chkptWorker; +// +// dTrace("msg:%p, put into worker %s", pMsg, pWorker->name); +// return taosWriteQitem(pWorker->queue, pMsg); +//} diff --git a/source/dnode/mgmt/mgmt_vnode/inc/vmInt.h b/source/dnode/mgmt/mgmt_vnode/inc/vmInt.h index e33730130d..cb41bc0ea7 100644 --- a/source/dnode/mgmt/mgmt_vnode/inc/vmInt.h +++ b/source/dnode/mgmt/mgmt_vnode/inc/vmInt.h @@ -34,6 +34,7 @@ typedef struct SVnodeMgmt { SAutoQWorkerPool streamPool; SAutoQWorkerPool streamLongExecPool; SWWorkerPool streamCtrlPool; + SWWorkerPool streamChkPool; SWWorkerPool fetchPool; SSingleWorker mgmtWorker; SSingleWorker mgmtMultiWorker; @@ -77,6 +78,7 @@ typedef struct { STaosQueue *pStreamQ; STaosQueue *pStreamCtrlQ; STaosQueue *pStreamLongExecQ; + STaosQueue *pStreamChkQ; STaosQueue *pFetchQ; STaosQueue *pMultiMgmQ; } SVnodeObj; @@ -141,6 +143,7 @@ int32_t vmPutMsgToStreamQueue(SVnodeMgmt *pMgmt, SRpcMsg *pMsg); int32_t vmPutMsgToStreamCtrlQueue(SVnodeMgmt *pMgmt, SRpcMsg *pMsg); int32_t vmPutMsgToStreamLongExecQueue(SVnodeMgmt *pMgmt, SRpcMsg *pMsg); +int32_t vmPutMsgToStreamChkQueue(SVnodeMgmt *pMgmt, SRpcMsg *pMsg); int32_t vmPutMsgToMergeQueue(SVnodeMgmt *pMgmt, SRpcMsg *pMsg); int32_t vmPutMsgToMgmtQueue(SVnodeMgmt *pMgmt, SRpcMsg *pMsg); int32_t vmPutMsgToMultiMgmtQueue(SVnodeMgmt *pMgmt, SRpcMsg *pMsg); diff --git a/source/dnode/mgmt/mgmt_vnode/src/vmHandle.c b/source/dnode/mgmt/mgmt_vnode/src/vmHandle.c index fc8ff3133a..8a18727b99 100644 --- a/source/dnode/mgmt/mgmt_vnode/src/vmHandle.c +++ b/source/dnode/mgmt/mgmt_vnode/src/vmHandle.c @@ -1022,6 +1022,7 @@ SArray *vmGetMsgHandles() { if (dmSetMgmtHandle(pArray, TDMT_MND_STREAM_CHKPT_REPORT_RSP, vmPutMsgToStreamCtrlQueue, 0) == NULL) goto _OVER; if (dmSetMgmtHandle(pArray, TDMT_VND_STREAM_SCAN_HISTORY, vmPutMsgToStreamLongExecQueue, 0) == NULL) goto _OVER; + if (dmSetMgmtHandle(pArray, TDMT_STREAM_CHKPT_EXEC, vmPutMsgToStreamChkQueue, 0) == NULL) goto _OVER; if (dmSetMgmtHandle(pArray, TDMT_VND_GET_STREAM_PROGRESS, vmPutMsgToStreamQueue, 0) == NULL) goto _OVER; if (dmSetMgmtHandle(pArray, TDMT_STREAM_RETRIEVE, vmPutMsgToStreamQueue, 0) == NULL) goto _OVER; if (dmSetMgmtHandle(pArray, TDMT_STREAM_RETRIEVE_RSP, vmPutMsgToStreamQueue, 0) == NULL) goto _OVER; diff --git a/source/dnode/mgmt/mgmt_vnode/src/vmInt.c b/source/dnode/mgmt/mgmt_vnode/src/vmInt.c index 8871cd575f..5da3b2ce9a 100644 --- a/source/dnode/mgmt/mgmt_vnode/src/vmInt.c +++ b/source/dnode/mgmt/mgmt_vnode/src/vmInt.c @@ -407,6 +407,9 @@ void vmCloseVnode(SVnodeMgmt *pMgmt, SVnodeObj *pVnode, bool commitAndRemoveWal, pVnode->pStreamLongExecQ, taosQueueItemSize(pVnode->pStreamLongExecQ)); while (!taosQueueEmpty(pVnode->pStreamLongExecQ)) taosMsleep(50); + dInfo("vgId:%d, wait for vnode stream chkpt queue:%p is empty", pVnode->vgId, pVnode->pStreamChkQ); + while (!taosQueueEmpty(pVnode->pStreamChkQ)) taosMsleep(10); + dInfo("vgId:%d, all vnode queues is empty", pVnode->vgId); dInfo("vgId:%d, post close", pVnode->vgId); diff --git a/source/dnode/mgmt/mgmt_vnode/src/vmWorker.c b/source/dnode/mgmt/mgmt_vnode/src/vmWorker.c index 5acd06bbda..41f3c64e7d 100644 --- a/source/dnode/mgmt/mgmt_vnode/src/vmWorker.c +++ b/source/dnode/mgmt/mgmt_vnode/src/vmWorker.c @@ -165,6 +165,34 @@ static void vmProcessStreamCtrlQueue(SQueueInfo *pInfo, STaosQall* pQall, int32_ } } +static void vmProcessStreamChkptQueue(SQueueInfo *pInfo, STaosQall* pQall, int32_t numOfItems) { + SVnodeObj *pVnode = pInfo->ahandle; + void *pItem = NULL; + int32_t code = 0; + + while (1) { + if (taosGetQitem(pQall, &pItem) == 0) { + break; + } + + SRpcMsg *pMsg = pItem; + const STraceId *trace = &pMsg->info.traceId; + + dGTrace("vgId:%d, msg:%p get from vnode-stream-chkpt queue", pVnode->vgId, pMsg); + code = vnodeProcessStreamChkptMsg(pVnode->pImpl, pMsg, pInfo); + if (code != 0) { + terrno = code; + dGError("vgId:%d, msg:%p failed to process stream chkpt msg %s since %s", pVnode->vgId, pMsg, + TMSG_INFO(pMsg->msgType), tstrerror(code)); + vmSendRsp(pMsg, code); + } + + dGTrace("vgId:%d, msg:%p is freed, code:0x%x", pVnode->vgId, pMsg, code); + rpcFreeCont(pMsg->pCont); + taosFreeQitem(pMsg); + } +} + static void vmProcessStreamLongExecQueue(SQueueInfo *pInfo, SRpcMsg *pMsg) { SVnodeObj *pVnode = pInfo->ahandle; const STraceId *trace = &pMsg->info.traceId; @@ -301,6 +329,10 @@ static int32_t vmPutMsgToQueue(SVnodeMgmt *pMgmt, SRpcMsg *pMsg, EQueueType qtyp dGTrace("vgId:%d, msg:%p put into vnode-stream-long-exec queue", pVnode->vgId, pMsg); code = taosWriteQitem(pVnode->pStreamLongExecQ, pMsg); break; + case STREAM_CHKPT_QUEUE: + dGTrace("vgId:%d, msg:%p put into vnode-stream-chkpt queue", pVnode->vgId, pMsg); + code = taosWriteQitem(pVnode->pStreamChkQ, pMsg); + break; case FETCH_QUEUE: dGTrace("vgId:%d, msg:%p put into vnode-fetch queue", pVnode->vgId, pMsg); code = taosWriteQitem(pVnode->pFetchQ, pMsg); @@ -361,6 +393,8 @@ int32_t vmPutMsgToStreamCtrlQueue(SVnodeMgmt *pMgmt, SRpcMsg *pMsg) { return vmP int32_t vmPutMsgToStreamLongExecQueue(SVnodeMgmt *pMgmt, SRpcMsg *pMsg) { return vmPutMsgToQueue(pMgmt, pMsg, STREAM_LONG_EXEC_QUEUE); } +int32_t vmPutMsgToStreamChkQueue(SVnodeMgmt *pMgmt, SRpcMsg *pMsg) { return vmPutMsgToQueue(pMgmt, pMsg, STREAM_CHKPT_QUEUE); } + int32_t vmPutMsgToMultiMgmtQueue(SVnodeMgmt *pMgmt, SRpcMsg *pMsg) { const STraceId *trace = &pMsg->info.traceId; dGTrace("msg:%p, put into vnode-multi-mgmt queue", pMsg); @@ -439,6 +473,8 @@ int32_t vmGetQueueSize(SVnodeMgmt *pMgmt, int32_t vgId, EQueueType qtype) { case STREAM_LONG_EXEC_QUEUE: size = taosQueueItemSize(pVnode->pStreamLongExecQ); break; + case STREAM_CHKPT_QUEUE: + size = taosQueueItemSize(pVnode->pStreamChkQ); default: break; } @@ -487,10 +523,11 @@ int32_t vmAllocQueue(SVnodeMgmt *pMgmt, SVnodeObj *pVnode) { pVnode->pStreamQ = tAutoQWorkerAllocQueue(&pMgmt->streamPool, pVnode, (FItem)vmProcessStreamQueue, 2); pVnode->pStreamCtrlQ = tWWorkerAllocQueue(&pMgmt->streamCtrlPool, pVnode, (FItems)vmProcessStreamCtrlQueue); pVnode->pStreamLongExecQ = tAutoQWorkerAllocQueue(&pMgmt->streamLongExecPool, pVnode, (FItem)vmProcessStreamLongExecQueue, 1); + pVnode->pStreamChkQ = tWWorkerAllocQueue(&pMgmt->streamChkPool, pVnode, (FItems)vmProcessStreamChkptQueue); if (pVnode->pWriteW.queue == NULL || pVnode->pSyncW.queue == NULL || pVnode->pSyncRdW.queue == NULL || pVnode->pApplyW.queue == NULL || pVnode->pQueryQ == NULL || pVnode->pStreamQ == NULL || pVnode->pFetchQ == NULL - || pVnode->pStreamCtrlQ == NULL || pVnode->pStreamLongExecQ == NULL) { + || pVnode->pStreamCtrlQ == NULL || pVnode->pStreamLongExecQ == NULL || pVnode->pStreamChkQ == NULL) { return TSDB_CODE_OUT_OF_MEMORY; } @@ -509,6 +546,8 @@ int32_t vmAllocQueue(SVnodeMgmt *pMgmt, SVnodeObj *pVnode) { dInfo("vgId:%d, stream-long-exec-queue:%p is alloced", pVnode->vgId, pVnode->pStreamLongExecQ); dInfo("vgId:%d, stream-ctrl-queue:%p is alloced, thread:%08" PRId64, pVnode->vgId, pVnode->pStreamCtrlQ, taosQueueGetThreadId(pVnode->pStreamCtrlQ)); + dInfo("vgId:%d, stream-chk-queue:%p is alloced, thread:%08" PRId64, pVnode->vgId, pVnode->pStreamChkQ, + taosQueueGetThreadId(pVnode->pStreamChkQ)); return 0; } @@ -517,6 +556,7 @@ void vmFreeQueue(SVnodeMgmt *pMgmt, SVnodeObj *pVnode) { tAutoQWorkerFreeQueue(&pMgmt->streamPool, pVnode->pStreamQ); tAutoQWorkerFreeQueue(&pMgmt->streamLongExecPool, pVnode->pStreamLongExecQ); tWWorkerFreeQueue(&pMgmt->streamCtrlPool, pVnode->pStreamCtrlQ); + tWWorkerFreeQueue(&pMgmt->streamChkPool, pVnode->pStreamChkQ); tWWorkerFreeQueue(&pMgmt->fetchPool, pVnode->pFetchQ); pVnode->pQueryQ = NULL; pVnode->pFetchQ = NULL; @@ -525,6 +565,8 @@ void vmFreeQueue(SVnodeMgmt *pMgmt, SVnodeObj *pVnode) { pVnode->pStreamCtrlQ = NULL; pVnode->pStreamLongExecQ = NULL; + pVnode->pStreamChkQ = NULL; + pVnode->pFetchQ = NULL; dDebug("vgId:%d, queue is freed", pVnode->vgId); } @@ -554,6 +596,11 @@ int32_t vmStartWorker(SVnodeMgmt *pMgmt) { pStreamCtrlPool->max = 1; if ((code = tWWorkerInit(pStreamCtrlPool)) != 0) return code; + SWWorkerPool *pStreamChkPool = &pMgmt->streamChkPool; + pStreamChkPool->name = "vnode-stream-chkpt"; + pStreamChkPool->max = 1; + if ((code = tWWorkerInit(pStreamChkPool)) != 0) return code; + SWWorkerPool *pFPool = &pMgmt->fetchPool; pFPool->name = "vnode-fetch"; pFPool->max = tsNumOfVnodeFetchThreads; @@ -587,6 +634,7 @@ void vmStopWorker(SVnodeMgmt *pMgmt) { tAutoQWorkerCleanup(&pMgmt->streamPool); tAutoQWorkerCleanup(&pMgmt->streamLongExecPool); tWWorkerCleanup(&pMgmt->streamCtrlPool); + tWWorkerCleanup(&pMgmt->streamChkPool); tWWorkerCleanup(&pMgmt->fetchPool); dDebug("vnode workers are closed"); } diff --git a/source/dnode/snode/src/snode.c b/source/dnode/snode/src/snode.c index 851bf25665..dcdc70da68 100644 --- a/source/dnode/snode/src/snode.c +++ b/source/dnode/snode/src/snode.c @@ -92,7 +92,7 @@ FAIL: } int32_t sndInit(SSnode *pSnode) { - if (streamTaskSchedTask(&pSnode->msgCb, pSnode->pMeta->vgId, 0, 0, STREAM_EXEC_T_START_ALL_TASKS) != 0) { + if (streamTaskSchedTask(&pSnode->msgCb, pSnode->pMeta->vgId, 0, 0, STREAM_EXEC_T_START_ALL_TASKS, false) != 0) { sndError("failed to start all tasks"); } return 0; @@ -138,6 +138,8 @@ int32_t sndProcessStreamMsg(SSnode *pSnode, SRpcMsg *pMsg) { return tqStreamTaskProcessRetrieveTriggerReq(pSnode->pMeta, pMsg); case TDMT_STREAM_RETRIEVE_TRIGGER_RSP: return tqStreamTaskProcessRetrieveTriggerRsp(pSnode->pMeta, pMsg); + case TDMT_STREAM_CHKPT_EXEC: + return tqStreamTaskProcessRunReq(pSnode->pMeta, pMsg, true); default: sndError("invalid snode msg:%d", pMsg->msgType); return TSDB_CODE_INVALID_MSG; diff --git a/source/dnode/vnode/inc/vnode.h b/source/dnode/vnode/inc/vnode.h index d224f9a411..a85dca05d5 100644 --- a/source/dnode/vnode/inc/vnode.h +++ b/source/dnode/vnode/inc/vnode.h @@ -114,6 +114,7 @@ int32_t vnodeProcessFetchMsg(SVnode *pVnode, SRpcMsg *pMsg, SQueueInfo *pInfo); int32_t vnodeProcessStreamMsg(SVnode *pVnode, SRpcMsg *pMsg, SQueueInfo *pInfo); int32_t vnodeProcessStreamCtrlMsg(SVnode *pVnode, SRpcMsg *pMsg, SQueueInfo *pInfo); int32_t vnodeProcessStreamLongExecMsg(SVnode *pVnode, SRpcMsg *pMsg, SQueueInfo *pInfo); +int32_t vnodeProcessStreamChkptMsg(SVnode *pVnode, SRpcMsg *pMsg, SQueueInfo *pInfo); void vnodeProposeWriteMsg(SQueueInfo *pInfo, STaosQall *qall, int32_t numOfMsgs); void vnodeApplyWriteMsg(SQueueInfo *pInfo, STaosQall *qall, int32_t numOfMsgs); void vnodeProposeCommitOnNeed(SVnode *pVnode, bool atExit); diff --git a/source/dnode/vnode/src/tq/tqStreamTask.c b/source/dnode/vnode/src/tq/tqStreamTask.c index b9cbb33746..6a6b3574db 100644 --- a/source/dnode/vnode/src/tq/tqStreamTask.c +++ b/source/dnode/vnode/src/tq/tqStreamTask.c @@ -165,7 +165,7 @@ static void doStartScanWal(void* param, void* tmrId) { taosMsleep(10000); #endif - code = streamTaskSchedTask(&pParam->msgCb, vgId, 0, 0, STREAM_EXEC_T_EXTRACT_WAL_DATA); + code = streamTaskSchedTask(&pParam->msgCb, vgId, 0, 0, STREAM_EXEC_T_EXTRACT_WAL_DATA, false); if (code) { tqError("vgId:%d failed sched task to scan wal, code:%s", vgId, tstrerror(code)); } @@ -216,7 +216,7 @@ void tqScanWalAsync(STQ* pTq) { } int32_t tqStopStreamAllTasksAsync(SStreamMeta* pMeta, SMsgCb* pMsgCb) { - return streamTaskSchedTask(pMsgCb, pMeta->vgId, 0, 0, STREAM_EXEC_T_STOP_ALL_TASKS); + return streamTaskSchedTask(pMsgCb, pMeta->vgId, 0, 0, STREAM_EXEC_T_STOP_ALL_TASKS, false); } int32_t setWalReaderStartOffset(SStreamTask* pTask, int32_t vgId) { @@ -322,7 +322,7 @@ bool taskReadyForDataFromWal(SStreamTask* pTask) { // check whether input queue is full or not if (streamQueueIsFull(pTask->inputq.queue)) { tqTrace("s-task:%s input queue is full, launch task without scanning wal", pTask->id.idStr); - int32_t code = streamTrySchedExec(pTask); + int32_t code = streamTrySchedExec(pTask, false); if (code) { tqError("s-task:%s failed to start task while inputQ is full", pTask->id.idStr); } @@ -461,7 +461,7 @@ int32_t doScanWalForAllTasks(SStreamMeta* pStreamMeta, int32_t* pNumOfTasks) { streamMutexUnlock(&pTask->lock); if ((numOfItems > 0) || hasNewData) { - code = streamTrySchedExec(pTask); + code = streamTrySchedExec(pTask, false); if (code != TSDB_CODE_SUCCESS) { streamMetaReleaseTask(pStreamMeta, pTask); taosArrayDestroy(pTaskList); diff --git a/source/dnode/vnode/src/tqCommon/tqCommon.c b/source/dnode/vnode/src/tqCommon/tqCommon.c index 4295969c85..64072bbda1 100644 --- a/source/dnode/vnode/src/tqCommon/tqCommon.c +++ b/source/dnode/vnode/src/tqCommon/tqCommon.c @@ -131,7 +131,7 @@ int32_t tqStreamTaskStartAsync(SStreamMeta* pMeta, SMsgCb* cb, bool restart) { tqDebug("vgId:%d start all %d stream task(s) async", vgId, numOfTasks); int32_t type = restart ? STREAM_EXEC_T_RESTART_ALL_TASKS : STREAM_EXEC_T_START_ALL_TASKS; - return streamTaskSchedTask(cb, vgId, 0, 0, type); + return streamTaskSchedTask(cb, vgId, 0, 0, type, false); } int32_t tqStreamStartOneTaskAsync(SStreamMeta* pMeta, SMsgCb* cb, int64_t streamId, int32_t taskId) { @@ -143,7 +143,7 @@ int32_t tqStreamStartOneTaskAsync(SStreamMeta* pMeta, SMsgCb* cb, int64_t stream } tqDebug("vgId:%d start task:0x%x async", vgId, taskId); - return streamTaskSchedTask(cb, vgId, streamId, taskId, STREAM_EXEC_T_START_ONE_TASK); + return streamTaskSchedTask(cb, vgId, streamId, taskId, STREAM_EXEC_T_START_ONE_TASK, false); } // this is to process request from transaction, always return true. @@ -1222,7 +1222,7 @@ static int32_t tqProcessTaskResumeImpl(void* handle, SStreamTask* pTask, int64_t } else if (level == TASK_LEVEL__SOURCE && (streamQueueGetNumOfItems(pTask->inputq.queue) == 0)) { // code = tqScanWalAsync((STQ*)handle, false); } else { - code = streamTrySchedExec(pTask); + code = streamTrySchedExec(pTask, false); } } diff --git a/source/dnode/vnode/src/vnd/vnodeSvr.c b/source/dnode/vnode/src/vnd/vnodeSvr.c index 22d9c2657d..ea4ca896ab 100644 --- a/source/dnode/vnode/src/vnd/vnodeSvr.c +++ b/source/dnode/vnode/src/vnd/vnodeSvr.c @@ -940,6 +940,8 @@ int32_t vnodeProcessFetchMsg(SVnode *pVnode, SRpcMsg *pMsg, SQueueInfo *pInfo) { int32_t vnodeProcessStreamMsg(SVnode *pVnode, SRpcMsg *pMsg, SQueueInfo *pInfo) { vTrace("vgId:%d, msg:%p in stream queue is processing", pVnode->config.vgId, pMsg); + + // todo: NOTE: some command needs to run on follower, such as, stop_all_tasks if ((pMsg->msgType == TDMT_SCH_FETCH || pMsg->msgType == TDMT_VND_TABLE_META || pMsg->msgType == TDMT_VND_TABLE_CFG || pMsg->msgType == TDMT_VND_BATCH_META) && !syncIsReadyForRead(pVnode->sync)) { @@ -1016,6 +1018,24 @@ int32_t vnodeProcessStreamLongExecMsg(SVnode *pVnode, SRpcMsg *pMsg, SQueueInfo } } +int32_t vnodeProcessStreamChkptMsg(SVnode *pVnode, SRpcMsg *pMsg, SQueueInfo *pInfo) { + vTrace("vgId:%d, msg:%p in stream chkpt queue is processing", pVnode->config.vgId, pMsg); + if ((pMsg->msgType == TDMT_SCH_FETCH || pMsg->msgType == TDMT_VND_TABLE_META || pMsg->msgType == TDMT_VND_TABLE_CFG || + pMsg->msgType == TDMT_VND_BATCH_META) && + !syncIsReadyForRead(pVnode->sync)) { + vnodeRedirectRpcMsg(pVnode, pMsg, terrno); + return 0; + } + + switch (pMsg->msgType) { + case TDMT_STREAM_CHKPT_EXEC: + return tqProcessTaskRunReq(pVnode->pTq, pMsg); + default: + vError("unknown msg type:%d in stream chkpt queue", pMsg->msgType); + return TSDB_CODE_APP_ERROR; + } +} + void smaHandleRes(void *pVnode, int64_t smaId, const SArray *data) { int32_t code = tdProcessTSmaInsert(((SVnode *)pVnode)->pSma, smaId, (const char *)data); if (code) { diff --git a/source/dnode/vnode/src/vnd/vnodeSync.c b/source/dnode/vnode/src/vnd/vnodeSync.c index 2a06686a31..317fd3307e 100644 --- a/source/dnode/vnode/src/vnd/vnodeSync.c +++ b/source/dnode/vnode/src/vnd/vnodeSync.c @@ -597,7 +597,7 @@ static void vnodeRestoreFinish(const SSyncFSM *pFsm, const SyncIndex commitIdx) streamMetaWUnLock(pMeta); tqInfo("vgId:%d stream task already loaded, start them", vgId); - int32_t code = streamTaskSchedTask(&pVnode->msgCb, TD_VID(pVnode), 0, 0, STREAM_EXEC_T_START_ALL_TASKS); + int32_t code = streamTaskSchedTask(&pVnode->msgCb, TD_VID(pVnode), 0, 0, STREAM_EXEC_T_START_ALL_TASKS, false); if (code != 0) { tqError("vgId:%d failed to sched stream task, code:%s", vgId, tstrerror(code)); } diff --git a/source/libs/executor/src/streamcountwindowoperator.c b/source/libs/executor/src/streamcountwindowoperator.c index 63ff2fa92b..37466aac8d 100644 --- a/source/libs/executor/src/streamcountwindowoperator.c +++ b/source/libs/executor/src/streamcountwindowoperator.c @@ -57,11 +57,12 @@ void destroyStreamCountAggOperatorInfo(void* param) { } destroyStreamBasicInfo(&pInfo->basic); - destroyStreamAggSupporter(&pInfo->streamAggSup); + cleanupExprSupp(&pInfo->scalarSupp); clearGroupResInfo(&pInfo->groupResInfo); taosArrayDestroyP(pInfo->pUpdated, destroyFlusedPos); pInfo->pUpdated = NULL; + destroyStreamAggSupporter(&pInfo->streamAggSup); colDataDestroy(&pInfo->twAggSup.timeWindowData); blockDataDestroy(pInfo->pDelRes); diff --git a/source/libs/executor/src/streameventwindowoperator.c b/source/libs/executor/src/streameventwindowoperator.c index eacb2fcfc8..f25f711783 100644 --- a/source/libs/executor/src/streameventwindowoperator.c +++ b/source/libs/executor/src/streameventwindowoperator.c @@ -56,10 +56,11 @@ void destroyStreamEventOperatorInfo(void* param) { } destroyStreamBasicInfo(&pInfo->basic); - destroyStreamAggSupporter(&pInfo->streamAggSup); + clearGroupResInfo(&pInfo->groupResInfo); taosArrayDestroyP(pInfo->pUpdated, destroyFlusedPos); pInfo->pUpdated = NULL; + destroyStreamAggSupporter(&pInfo->streamAggSup); cleanupExprSupp(&pInfo->scalarSupp); if (pInfo->pChildren != NULL) { diff --git a/source/libs/executor/src/streamtimesliceoperator.c b/source/libs/executor/src/streamtimesliceoperator.c index 681e07f452..f511c5ab4f 100644 --- a/source/libs/executor/src/streamtimesliceoperator.c +++ b/source/libs/executor/src/streamtimesliceoperator.c @@ -151,7 +151,7 @@ void destroyStreamTimeSliceOperatorInfo(void* param) { pInfo->pOperator = NULL; } colDataDestroy(&pInfo->twAggSup.timeWindowData); - destroyStreamAggSupporter(&pInfo->streamAggSup); + resetPrevAndNextWindow(pInfo->pFillSup); destroyStreamFillSupporter(pInfo->pFillSup); destroyStreamFillInfo(pInfo->pFillInfo); @@ -179,6 +179,7 @@ void destroyStreamTimeSliceOperatorInfo(void* param) { taosArrayDestroy(pInfo->historyWins); taosArrayDestroy(pInfo->pCloseTs); + destroyStreamAggSupporter(&pInfo->streamAggSup); taosMemoryFreeClear(param); } diff --git a/source/libs/executor/src/streamtimewindowoperator.c b/source/libs/executor/src/streamtimewindowoperator.c index 33efd0cfb1..c15a9f9224 100644 --- a/source/libs/executor/src/streamtimewindowoperator.c +++ b/source/libs/executor/src/streamtimewindowoperator.c @@ -462,7 +462,7 @@ _end: void destroyFlusedPos(void* pRes) { SRowBuffPos* pPos = (SRowBuffPos*)pRes; - if (!pPos->needFree && !pPos->pRowBuff) { + if (pPos->needFree && !pPos->pRowBuff) { taosMemoryFreeClear(pPos->pKey); taosMemoryFree(pPos); } @@ -475,9 +475,11 @@ void destroyFlusedppPos(void* ppRes) { void clearGroupResInfo(SGroupResInfo* pGroupResInfo) { int32_t size = taosArrayGetSize(pGroupResInfo->pRows); - for (int32_t i = pGroupResInfo->index; i < size; i++) { - void* pPos = taosArrayGetP(pGroupResInfo->pRows, i); - destroyFlusedPos(pPos); + if (pGroupResInfo->index >= 0 && pGroupResInfo->index < size) { + for (int32_t i = pGroupResInfo->index; i < size; i++) { + void* pPos = taosArrayGetP(pGroupResInfo->pRows, i); + destroyFlusedPos(pPos); + } } pGroupResInfo->freeItem = false; taosArrayDestroy(pGroupResInfo->pRows); @@ -2204,11 +2206,12 @@ void destroyStreamSessionAggOperatorInfo(void* param) { } destroyStreamBasicInfo(&pInfo->basic); - destroyStreamAggSupporter(&pInfo->streamAggSup); + cleanupExprSupp(&pInfo->scalarSupp); clearGroupResInfo(&pInfo->groupResInfo); taosArrayDestroyP(pInfo->pUpdated, destroyFlusedPos); pInfo->pUpdated = NULL; + destroyStreamAggSupporter(&pInfo->streamAggSup); if (pInfo->pChildren != NULL) { int32_t size = taosArrayGetSize(pInfo->pChildren); @@ -4442,10 +4445,11 @@ void destroyStreamStateOperatorInfo(void* param) { } destroyStreamBasicInfo(&pInfo->basic); - destroyStreamAggSupporter(&pInfo->streamAggSup); + clearGroupResInfo(&pInfo->groupResInfo); taosArrayDestroyP(pInfo->pUpdated, destroyFlusedPos); pInfo->pUpdated = NULL; + destroyStreamAggSupporter(&pInfo->streamAggSup); cleanupExprSupp(&pInfo->scalarSupp); if (pInfo->pChildren != NULL) { diff --git a/source/libs/function/src/builtins.c b/source/libs/function/src/builtins.c index be3f0d362b..8233b2d450 100644 --- a/source/libs/function/src/builtins.c +++ b/source/libs/function/src/builtins.c @@ -22,6 +22,9 @@ #include "tanalytics.h" #include "taoserror.h" #include "ttime.h" +#include "functionMgt.h" +#include "ttypes.h" +#include "tglobal.h" static int32_t buildFuncErrMsg(char* pErrBuf, int32_t len, int32_t errCode, const char* pFormat, ...) { va_list vArgList; @@ -1745,6 +1748,62 @@ 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) { + FUNC_ERR_RET(validateParam(pFunc, pErrBuf, len)); + + bool mixTypeToStrings = tsCompareAsStrInGreatest; + + 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; + } + + 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[res.type].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(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) { + // last res is numeric, para is string, and mixTypeToStrings is true + res.type = para->type; + 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; + } + } + } + pFunc->node.resType = res; + return TSDB_CODE_SUCCESS; +} + // clang-format off const SBuiltinFuncDefinition funcMgtBuiltins[] = { { @@ -5656,6 +5715,48 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { .name = "cols", .translateFunc = invalidColsFunction, }, + { + .name = "greatest", + .type = FUNCTION_TYPE_GREATEST, + .classification = FUNC_MGT_SCALAR_FUNC, + .parameters = {.minParamNum = 2, + .maxParamNum = -1, + .paramInfoPattern = 1, + .inputParaInfo[0][0] = {.isLastParam = true, + .startParam = 1, + .endParam = -1, + .validDataType = FUNC_PARAM_SUPPORT_NUMERIC_TYPE | FUNC_PARAM_SUPPORT_NULL_TYPE | FUNC_PARAM_SUPPORT_BOOL_TYPE | FUNC_PARAM_SUPPORT_TIMESTAMP_TYPE | FUNC_PARAM_SUPPORT_VARCHAR_TYPE | FUNC_PARAM_SUPPORT_NCHAR_TYPE, + .validNodeType = FUNC_PARAM_SUPPORT_EXPR_NODE, + .paramAttribute = FUNC_PARAM_NO_SPECIFIC_ATTRIBUTE, + .valueRangeFlag = FUNC_PARAM_NO_SPECIFIC_VALUE,}, + .outputParaInfo = {.validDataType = FUNC_PARAM_SUPPORT_ALL_TYPE}}, + .translateFunc = translateGreatestleast, + .getEnvFunc = NULL, + .initFunc = NULL, + .sprocessFunc = greatestFunction, + .finalizeFunc = NULL + }, + { + .name = "least", + .type = FUNCTION_TYPE_LEAST, + .classification = FUNC_MGT_SCALAR_FUNC, + .parameters = {.minParamNum = 2, + .maxParamNum = -1, + .paramInfoPattern = 1, + .inputParaInfo[0][0] = {.isLastParam = true, + .startParam = 1, + .endParam = -1, + .validDataType = FUNC_PARAM_SUPPORT_NUMERIC_TYPE | FUNC_PARAM_SUPPORT_NULL_TYPE | FUNC_PARAM_SUPPORT_BOOL_TYPE | FUNC_PARAM_SUPPORT_TIMESTAMP_TYPE | FUNC_PARAM_SUPPORT_VARCHAR_TYPE | FUNC_PARAM_SUPPORT_NCHAR_TYPE, + .validNodeType = FUNC_PARAM_SUPPORT_EXPR_NODE, + .paramAttribute = FUNC_PARAM_NO_SPECIFIC_ATTRIBUTE, + .valueRangeFlag = FUNC_PARAM_NO_SPECIFIC_VALUE,}, + .outputParaInfo = {.validDataType = FUNC_PARAM_SUPPORT_ALL_TYPE}}, + .translateFunc = translateGreatestleast, + .getEnvFunc = NULL, + .initFunc = NULL, + .sprocessFunc = leastFunction, + .finalizeFunc = NULL + }, }; // clang-format on diff --git a/source/libs/scalar/src/sclfunc.c b/source/libs/scalar/src/sclfunc.c index f3b56da372..280a469153 100644 --- a/source/libs/scalar/src/sclfunc.c +++ b/source/libs/scalar/src/sclfunc.c @@ -1,11 +1,14 @@ +#include #include "cJSON.h" #include "function.h" #include "scalar.h" #include "sclInt.h" #include "sclvector.h" #include "tdatablock.h" +#include "tdef.h" #include "tjson.h" #include "ttime.h" +#include "filter.h" typedef float (*_float_fn)(float); typedef float (*_float_fn_2)(float, float); @@ -4403,3 +4406,136 @@ int32_t modeScalarFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam return selectScalarFunction(pInput, inputNum, pOutput); } +typedef struct SCovertScarlarParam { + SScalarParam covertParam; + SScalarParam *param; + bool converted; +} SCovertScarlarParam; + +void freeSCovertScarlarParams(SCovertScarlarParam *pCovertParams, int32_t num) { + if (pCovertParams == NULL) { + return; + } + for (int32_t i = 0; i < num; i++) { + if (pCovertParams[i].converted) { + sclFreeParam(pCovertParams[i].param); + } + } + taosMemoryFree(pCovertParams); +} + +static int32_t vectorCompareAndSelect(SCovertScarlarParam *pParams, int32_t numOfRows, int numOfCols, + int32_t *resultColIndex, EOperatorType optr) { + int32_t code = TSDB_CODE_SUCCESS; + int32_t type = GET_PARAM_TYPE(pParams[0].param); + + __compar_fn_t fp = NULL; + code = filterGetCompFunc(&fp, type, optr); + if(code != TSDB_CODE_SUCCESS) { + qError("failed to get compare function, func:%s type:%d, optr:%d", __FUNCTION__, type, optr); + return code; + } + + for (int32_t i = 0; i < numOfRows; i++) { + int selectIndex = 0; + if (colDataIsNull_s(pParams[selectIndex].param->columnData, i)) { + resultColIndex[i] = -1; + continue; + } + for (int32_t j = 1; j < numOfCols; j++) { + if (colDataIsNull_s(pParams[j].param->columnData, i)) { + resultColIndex[i] = -1; + break; + } else { + int32_t leftRowNo = pParams[selectIndex].param->numOfRows == 1 ? 0 : i; + int32_t rightRowNo = pParams[j].param->numOfRows == 1 ? 0 : i; + char *pLeftData = colDataGetData(pParams[selectIndex].param->columnData, leftRowNo); + char *pRightData = colDataGetData(pParams[j].param->columnData, rightRowNo); + bool pRes = filterDoCompare(fp, optr, pLeftData, pRightData); + if (!pRes) { + selectIndex = j; + } + } + resultColIndex[i] = selectIndex; + } + } + + return code; +} + +static int32_t greatestLeastImpl(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput, EOperatorType order) { + int32_t code = TSDB_CODE_SUCCESS; + SColumnInfoData *pOutputData = pOutput[0].columnData; + int16_t outputType = GET_PARAM_TYPE(&pOutput[0]); + int64_t outputLen = GET_PARAM_BYTES(&pOutput[0]); + + SCovertScarlarParam *pCovertParams = NULL; + int32_t *resultColIndex = NULL; + + int32_t numOfRows = 0; + 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; + goto _return; + } + numOfRows = TMAX(numOfRows, pInput[i].numOfRows); + IsNullType |= IS_NULL_TYPE(GET_PARAM_TYPE(&pInput[i])); + } + + if (IsNullType) { + colDataSetNNULL(pOutputData, 0, numOfRows); + pOutput->numOfRows = numOfRows; + return TSDB_CODE_SUCCESS; + } + pCovertParams = taosMemoryMalloc(inputNum * sizeof(SCovertScarlarParam)); + for (int32_t j = 0; j < inputNum; j++) { + SScalarParam *pParam = &pInput[j]; + int16_t oldType = GET_PARAM_TYPE(&pInput[j]); + if (oldType != outputType) { + pCovertParams[j].covertParam = (SScalarParam){0}; + setTzCharset(&pCovertParams[j].covertParam, pParam->tz, pParam->charsetCxt); + SCL_ERR_JRET(vectorConvertSingleCol(pParam, &pCovertParams[j].covertParam, outputType, 0, pParam->numOfRows)); + pCovertParams[j].param = &pCovertParams[j].covertParam; + pCovertParams[j].converted = true; + } else { + pCovertParams[j].param = pParam; + pCovertParams[j].converted = false; + } + } + + resultColIndex = taosMemoryCalloc(numOfRows, sizeof(int32_t)); + SCL_ERR_JRET(vectorCompareAndSelect(pCovertParams, numOfRows, inputNum, resultColIndex, order)); + + for (int32_t i = 0; i < numOfRows; i++) { + int32_t index = resultColIndex[i]; + if (index == -1) { + colDataSetNULL(pOutputData, i); + continue; + } + int32_t rowNo = pCovertParams[index].param->numOfRows == 1 ? 0 : i; + char *data = colDataGetData(pCovertParams[index].param->columnData, rowNo); + SCL_ERR_JRET(colDataSetVal(pOutputData, i, data, false)); + } + + pOutput->numOfRows = numOfRows; + +_return: + freeSCovertScarlarParams(pCovertParams, inputNum); + taosMemoryFree(resultColIndex); + return code; +} + +int32_t greatestFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput) { + return greatestLeastImpl(pInput, inputNum, pOutput, OP_TYPE_GREATER_THAN); +} + +int32_t leastFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput) { + return greatestLeastImpl(pInput, inputNum, pOutput, OP_TYPE_LOWER_THAN); +} + diff --git a/source/libs/scalar/src/sclvector.c b/source/libs/scalar/src/sclvector.c index 14dae1226d..ff45baa1e0 100644 --- a/source/libs/scalar/src/sclvector.c +++ b/source/libs/scalar/src/sclvector.c @@ -996,7 +996,7 @@ int32_t vectorConvertSingleColImpl(const SScalarParam *pIn, SScalarParam *pOut, } int8_t gConvertTypes[TSDB_DATA_TYPE_MAX][TSDB_DATA_TYPE_MAX] = { - /*NULL BOOL TINY SMAL INT BIG FLOA DOUB VARC TIME NCHA UTIN USMA UINT UBIG JSON VARB DECI BLOB MEDB GEOM*/ + /* NULL BOOL TINY SMAL INT BIG FLOA DOUB VARC TIME NCHA UTIN USMA UINT UBIG JSON VARB DECI BLOB MEDB GEOM*/ /*NULL*/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /*BOOL*/ 0, 0, 2, 3, 4, 5, 6, 7, 5, 9, 5, 11, 12, 13, 14, 0, -1, 0, 0, 0, -1, /*TINY*/ 0, 0, 0, 3, 4, 5, 6, 7, 5, 9, 5, 3, 4, 5, 7, 0, -1, 0, 0, 0, -1, @@ -1021,7 +1021,7 @@ int8_t gConvertTypes[TSDB_DATA_TYPE_MAX][TSDB_DATA_TYPE_MAX] = { }; int8_t gDisplyTypes[TSDB_DATA_TYPE_MAX][TSDB_DATA_TYPE_MAX] = { - /*NULL BOOL TINY SMAL INT BIGI FLOA DOUB VARC TIM NCHA UTIN USMA UINT UBIG JSON VARB DECI BLOB MEDB GEOM*/ + /* NULL BOOL TINY SMAL INT BIGI FLOA DOUB VARC TIM NCHA UTIN USMA UINT UBIG JSON VARB DECI BLOB MEDB GEOM*/ /*NULL*/ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, -1, -1, -1, 20, /*BOOL*/ 0, 1, 2, 3, 4, 5, 6, 7, 8, 5, 10, 11, 12, 13, 14, -1, -1, -1, -1, -1, -1, /*TINY*/ 0, 0, 2, 3, 4, 5, 8, 8, 8, 5, 10, 3, 4, 5, 8, -1, -1, -1, -1, -1, -1, diff --git a/source/libs/stream/src/streamCheckStatus.c b/source/libs/stream/src/streamCheckStatus.c index ebb13654b7..29da3fc88e 100644 --- a/source/libs/stream/src/streamCheckStatus.c +++ b/source/libs/stream/src/streamCheckStatus.c @@ -717,7 +717,7 @@ void handleNotReadyDownstreamTask(SStreamTask* pTask, SArray* pNotReadyList) { // The restart of all tasks requires that all tasks should not have active timer for now. Therefore, the execution // of restart in timer thread will result in a deadlock. int32_t addDownstreamFailedStatusResultAsync(SMsgCb* pMsgCb, int32_t vgId, int64_t streamId, int32_t taskId) { - return streamTaskSchedTask(pMsgCb, vgId, streamId, taskId, STREAM_EXEC_T_ADD_FAILED_TASK); + return streamTaskSchedTask(pMsgCb, vgId, streamId, taskId, STREAM_EXEC_T_ADD_FAILED_TASK, false); } static void doCleanup(SStreamTask* pTask, SArray* pNotReadyList, SArray* pTimeoutList, void* param) { diff --git a/source/libs/stream/src/streamCheckpoint.c b/source/libs/stream/src/streamCheckpoint.c index f07d6f4cc1..afda288b90 100644 --- a/source/libs/stream/src/streamCheckpoint.c +++ b/source/libs/stream/src/streamCheckpoint.c @@ -93,7 +93,7 @@ int32_t appendCheckpointIntoInputQ(SStreamTask* pTask, int32_t checkpointType, i return TSDB_CODE_OUT_OF_MEMORY; } - return streamTrySchedExec(pTask); + return streamTrySchedExec(pTask, true); } int32_t streamProcessCheckpointSourceReq(SStreamTask* pTask, SStreamCheckpointSourceReq* pReq) { diff --git a/source/libs/stream/src/streamDispatch.c b/source/libs/stream/src/streamDispatch.c index 24ac193937..f08b4a7922 100644 --- a/source/libs/stream/src/streamDispatch.c +++ b/source/libs/stream/src/streamDispatch.c @@ -1834,6 +1834,7 @@ int32_t streamProcessDispatchMsg(SStreamTask* pTask, SStreamDispatchReq* pReq, S int32_t status = 0; SStreamMeta* pMeta = pTask->pMeta; const char* id = pTask->id.idStr; + bool chkptMsg = false; stDebug("s-task:%s receive dispatch msg from taskId:0x%x(vgId:%d), msgLen:%" PRId64 ", msgId:%d", id, pReq->upstreamTaskId, pReq->upstreamNodeId, pReq->totalLen, pReq->msgId); @@ -1863,6 +1864,7 @@ int32_t streamProcessDispatchMsg(SStreamTask* pTask, SStreamDispatchReq* pReq, S // blocked. Note that there is no race condition here. if (pReq->type == STREAM_INPUT__CHECKPOINT_TRIGGER) { streamTaskCloseUpstreamInput(pTask, pReq->upstreamTaskId); + chkptMsg = true; stDebug("s-task:%s close inputQ for upstream:0x%x, msgId:%d", id, pReq->upstreamTaskId, pReq->msgId); } else if (pReq->type == STREAM_INPUT__TRANS_STATE) { stDebug("s-task:%s recv trans-state msgId:%d from upstream:0x%x", id, pReq->msgId, pReq->upstreamTaskId); @@ -1890,5 +1892,5 @@ int32_t streamProcessDispatchMsg(SStreamTask* pTask, SStreamDispatchReq* pReq, S tmsgSendRsp(pRsp); } - return streamTrySchedExec(pTask); + return streamTrySchedExec(pTask, chkptMsg); } diff --git a/source/libs/stream/src/streamQueue.c b/source/libs/stream/src/streamQueue.c index 7c7ef83d6d..5a507358ee 100644 --- a/source/libs/stream/src/streamQueue.c +++ b/source/libs/stream/src/streamQueue.c @@ -144,11 +144,20 @@ void streamQueueNextItemInSourceQ(SStreamQueue* pQueue, SStreamQueueItem** pItem // let's try the ordinary input q pQueue->qItem = NULL; - int32_t num = taosGetQitem(pQueue->qall, &pQueue->qItem); + int32_t code = taosGetQitem(pQueue->qall, &pQueue->qItem); + if (code) { + stError("s-task:%s failed to extract data from inputQ, code:%s", id, tstrerror(code)); + } if (pQueue->qItem == NULL) { - num = taosReadAllQitems(pQueue->pQueue, pQueue->qall); - num = taosGetQitem(pQueue->qall, &pQueue->qItem); + code = taosReadAllQitems(pQueue->pQueue, pQueue->qall); + if (code) { + stError("s-task:%s failed to read qitem into qall, code:%s", id, tstrerror(code)); + } + code = taosGetQitem(pQueue->qall, &pQueue->qItem); + if (code) { + stError("s-task:%s failed to extract data from inputQ(qall), code:%s", id, tstrerror(code)); + } } *pItem = streamQueueCurItem(pQueue); diff --git a/source/libs/stream/src/streamSched.c b/source/libs/stream/src/streamSched.c index 1f76f349ae..367e54d1a1 100644 --- a/source/libs/stream/src/streamSched.c +++ b/source/libs/stream/src/streamSched.c @@ -93,17 +93,21 @@ void streamSetupScheduleTrigger(SStreamTask* pTask) { } } -int32_t streamTrySchedExec(SStreamTask* pTask) { +int32_t streamTrySchedExec(SStreamTask* pTask, bool chkptQueue) { if (streamTaskSetSchedStatusWait(pTask)) { - return streamTaskSchedTask(pTask->pMsgCb, pTask->info.nodeId, pTask->id.streamId, pTask->id.taskId, 0); + return streamTaskSchedTask(pTask->pMsgCb, pTask->info.nodeId, pTask->id.streamId, pTask->id.taskId, 0, chkptQueue); } else { - stTrace("s-task:%s not launch task since sched status:%d", pTask->id.idStr, pTask->status.schedStatus); + if (chkptQueue) { + stWarn("s-task:%s not launch task in chkpt queue, may delay checkpoint procedure", pTask->id.idStr); + } else { + stTrace("s-task:%s not launch task since sched status:%d", pTask->id.idStr, pTask->status.schedStatus); + } } return 0; } -int32_t streamTaskSchedTask(SMsgCb* pMsgCb, int32_t vgId, int64_t streamId, int32_t taskId, int32_t execType) { +int32_t streamTaskSchedTask(SMsgCb* pMsgCb, int32_t vgId, int64_t streamId, int32_t taskId, int32_t execType, bool chkptExec) { int32_t code = 0; int32_t tlen = 0; @@ -142,10 +146,18 @@ int32_t streamTaskSchedTask(SMsgCb* pMsgCb, int32_t vgId, int64_t streamId, int3 stDebug("vgId:%d create msg to exec, type:%d, %s", vgId, execType, streamTaskGetExecType(execType)); } - SRpcMsg msg = {.msgType = TDMT_STREAM_TASK_RUN, .pCont = buf, .contLen = tlen + sizeof(SMsgHead)}; - code = tmsgPutToQueue(pMsgCb, STREAM_QUEUE, &msg); - if (code) { - stError("vgId:%d failed to put msg into stream queue, code:%s, %x", vgId, tstrerror(code), taskId); + if (chkptExec) { + SRpcMsg msg = {.msgType = TDMT_STREAM_CHKPT_EXEC, .pCont = buf, .contLen = tlen + sizeof(SMsgHead)}; + code = tmsgPutToQueue(pMsgCb, STREAM_CHKPT_QUEUE, &msg); + if (code) { + stError("vgId:%d failed to put msg into stream chkpt queue, code:%s, %x", vgId, tstrerror(code), taskId); + } + } else { + SRpcMsg msg = {.msgType = TDMT_STREAM_TASK_RUN, .pCont = buf, .contLen = tlen + sizeof(SMsgHead)}; + code = tmsgPutToQueue(pMsgCb, STREAM_QUEUE, &msg); + if (code) { + stError("vgId:%d failed to put msg into stream queue, code:%s, %x", vgId, tstrerror(code), taskId); + } } return code; } @@ -191,12 +203,17 @@ void streamTaskResumeHelper(void* param, void* tmrId) { return; } - code = streamTaskSchedTask(pTask->pMsgCb, pTask->info.nodeId, pId->streamId, pId->taskId, STREAM_EXEC_T_RESUME_TASK); + code = streamTaskSchedTask(pTask->pMsgCb, pTask->info.nodeId, pId->streamId, pId->taskId, STREAM_EXEC_T_RESUME_TASK, + (p.state == TASK_STATUS__CK)); if (code) { stError("s-task:%s sched task failed, code:%s", pId->idStr, tstrerror(code)); } else { - stDebug("trigger to resume s-task:%s after idled for %dms", pId->idStr, pTask->status.schedIdleTime); - + if (p.state == TASK_STATUS__CK) { + stDebug("trigger to resume s-task:%s in stream chkpt queue after idled for %dms", pId->idStr, + pTask->status.schedIdleTime); + } else { + stDebug("trigger to resume s-task:%s after idled for %dms", pId->idStr, pTask->status.schedIdleTime); + } // release the task ref count streamTaskClearSchedIdleInfo(pTask); } @@ -339,7 +356,7 @@ void streamTaskSchedHelper(void* param, void* tmrId) { } } - code = streamTrySchedExec(pTask); + code = streamTrySchedExec(pTask, false); if (code != TSDB_CODE_SUCCESS) { stError("s-task:%s failed to sched to run, wait for next time", pTask->id.idStr); } diff --git a/source/libs/stream/src/streamTask.c b/source/libs/stream/src/streamTask.c index 378aaa27d0..f7ae4915ec 100644 --- a/source/libs/stream/src/streamTask.c +++ b/source/libs/stream/src/streamTask.c @@ -1194,7 +1194,7 @@ int32_t streamProcessRetrieveReq(SStreamTask* pTask, SStreamRetrieveReq* pReq) { if (code != 0) { return code; } - return streamTrySchedExec(pTask); + return streamTrySchedExec(pTask, false); } void streamTaskSetRemoveBackendFiles(SStreamTask* pTask) { pTask->status.removeBackendFiles = true; } diff --git a/source/libs/stream/src/tstreamFileState.c b/source/libs/stream/src/tstreamFileState.c index d6dfde1ee6..0255ac01b5 100644 --- a/source/libs/stream/src/tstreamFileState.c +++ b/source/libs/stream/src/tstreamFileState.c @@ -394,14 +394,17 @@ int32_t clearFlushedRowBuff(SStreamFileState* pFileState, SStreamSnapshot* pFlus pFileState->flushMark = TMAX(pFileState->flushMark, pFileState->getTs(pPos->pKey)); pFileState->stateBuffRemoveByPosFn(pFileState, pPos); - SListNode* tmp = tdListPopNode(pFileState->usedBuffs, pNode); - taosMemoryFreeClear(tmp); + if (pPos->beUsed == false) { + SListNode* tmp = tdListPopNode(pFileState->usedBuffs, pNode); + taosMemoryFreeClear(tmp); + } if (pPos->pRowBuff) { i++; } } } } + qDebug("clear flushed row buff. %d rows to disk. is all:%d", listNEles(pFlushList), all); _end: if (code != TSDB_CODE_SUCCESS) { @@ -433,7 +436,6 @@ int32_t popUsedBuffs(SStreamFileState* pFileState, SStreamSnapshot* pFlushList, SRowBuffPos* pPos = *(SRowBuffPos**)pNode->data; if (pPos->beUsed == used) { if (used && !pPos->pRowBuff) { - QUERY_CHECK_CONDITION((pPos->needFree == true), code, lino, _end, TSDB_CODE_QRY_EXECUTOR_INTERNAL_ERROR); continue; } code = tdListAppend(pFlushList, &pPos); @@ -441,8 +443,10 @@ int32_t popUsedBuffs(SStreamFileState* pFileState, SStreamSnapshot* pFlushList, pFileState->flushMark = TMAX(pFileState->flushMark, pFileState->getTs(pPos->pKey)); pFileState->stateBuffRemoveByPosFn(pFileState, pPos); - SListNode* tmp = tdListPopNode(pFileState->usedBuffs, pNode); - taosMemoryFreeClear(tmp); + if (pPos->beUsed == false) { + SListNode* tmp = tdListPopNode(pFileState->usedBuffs, pNode); + taosMemoryFreeClear(tmp); + } if (pPos->pRowBuff) { i++; } @@ -511,9 +515,12 @@ int32_t clearRowBuff(SStreamFileState* pFileState) { if (pFileState->deleteMark != INT64_MAX) { clearExpiredRowBuff(pFileState, pFileState->maxTs - pFileState->deleteMark, false); } - if (isListEmpty(pFileState->freeBuffs)) { - return flushRowBuff(pFileState); - } + do { + int32_t code = flushRowBuff(pFileState); + if (code != TSDB_CODE_SUCCESS) { + return code; + } + } while (isListEmpty(pFileState->freeBuffs) && pFileState->curRowCount == pFileState->maxRowCount); return TSDB_CODE_SUCCESS; } @@ -756,10 +763,10 @@ int32_t getRowBuffByPos(SStreamFileState* pFileState, SRowBuffPos* pPos, void** QUERY_CHECK_CODE(code, lino, _end); (*pVal) = pPos->pRowBuff; - if (!pPos->needFree) { - code = tdListPrepend(pFileState->usedBuffs, &pPos); - QUERY_CHECK_CODE(code, lino, _end); - } + // if (!pPos->needFree) { + // code = tdListPrepend(pFileState->usedBuffs, &pPos); + // QUERY_CHECK_CODE(code, lino, _end); + // } _end: if (code != TSDB_CODE_SUCCESS) { diff --git a/tests/army/query/function/ans/ascii.csv b/tests/army/query/function/ans/ascii.csv index 8d186f63e3..0e67acc9d1 100644 --- a/tests/army/query/function/ans/ascii.csv +++ b/tests/army/query/function/ans/ascii.csv @@ -51,7 +51,7 @@ taos> select ASCII('hello') + 1 from ts_4893.meters limit 1 taos> select ASCII('hello') + ASCII('hello') from ts_4893.meters limit 1 ascii('hello') + ascii('hello') | ================================== - 2.080000000000000e+02 | + 208 | taos> select ASCII(nch1) from ts_4893.meters order by ts limit 5 ascii(nch1) | diff --git a/tests/army/query/function/ans/char_length.csv b/tests/army/query/function/ans/char_length.csv index 4b79a42bfa..a8352357cf 100644 --- a/tests/army/query/function/ans/char_length.csv +++ b/tests/army/query/function/ans/char_length.csv @@ -51,7 +51,7 @@ taos> select CHAR_LENGTH('hello') + 1 from ts_4893.meters limit 1 taos> select CHAR_LENGTH('hello') + CHAR_LENGTH('hello') from ts_4893.meters limit 1 char_length('hello') + char_length('hello') | ============================================== - 1.000000000000000e+01 | + 10 | taos> select CHAR_LENGTH(nch1) from ts_4893.meters order by ts limit 5 char_length(nch1) | diff --git a/tests/army/query/function/ans/greatest.csv b/tests/army/query/function/ans/greatest.csv new file mode 100644 index 0000000000..b6854a95d6 --- /dev/null +++ b/tests/army/query/function/ans/greatest.csv @@ -0,0 +1,1409 @@ + +taos> alter local 'compareAsStrInGreatest' '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 'compareAsStrInGreatest' '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..de66426bd2 --- /dev/null +++ b/tests/army/query/function/ans/least.csv @@ -0,0 +1,1389 @@ + +taos> alter local 'compareAsStrInGreatest' '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 'compareAsStrInGreatest' '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/max.csv b/tests/army/query/function/ans/max.csv index 40f8b2ac23..e13a26847b 100644 --- a/tests/army/query/function/ans/max.csv +++ b/tests/army/query/function/ans/max.csv @@ -576,7 +576,7 @@ taos> select max(total_voltage) from (select sum(voltage) as total_voltage from taos> select round(max(current), 2) from ts_4893.meters round(max(current), 2) | ========================= - 1.2000000e+01 | + 12 | taos> select pow(max(current), 2) from ts_4893.meters pow(max(current), 2) | @@ -651,7 +651,7 @@ taos> select max(cast(10000000000 as bigint unsigned)) taos> select max(cast(1.1 as float)) max(cast(1.1 as float)) | ========================== - 1.1000000e+00 | + 1.1 | taos> select max(cast(1.1 as double)) max(cast(1.1 as double)) | diff --git a/tests/army/query/function/ans/min.csv b/tests/army/query/function/ans/min.csv index d77744a4f9..6426276446 100644 --- a/tests/army/query/function/ans/min.csv +++ b/tests/army/query/function/ans/min.csv @@ -576,7 +576,7 @@ taos> select min(total_voltage) from (select sum(voltage) as total_voltage from taos> select round(min(current), 2) from ts_4893.meters round(min(current), 2) | ========================= - 8.0000000e+00 | + 8 | taos> select pow(min(current), 2) from ts_4893.meters pow(min(current), 2) | @@ -651,7 +651,7 @@ taos> select min(cast(10000000000 as bigint unsigned)) taos> select min(cast(1.1 as float)) min(cast(1.1 as float)) | ========================== - 1.1000000e+00 | + 1.1 | taos> select min(cast(1.1 as double)) min(cast(1.1 as double)) | diff --git a/tests/army/query/function/ans/mod.csv b/tests/army/query/function/ans/mod.csv index 9d2232f49d..c222257308 100644 --- a/tests/army/query/function/ans/mod.csv +++ b/tests/army/query/function/ans/mod.csv @@ -42,26 +42,26 @@ 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 | =================================================================== - 1.234567890000022e-01 | + 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), | =================================================================== - 1.234567910432816e-01 | + 0.123456791043282 | taos> select MOD(87654321.123456789, id + 1) from ts_4893.meters order by ts limit 10 mod(87654321.123456789, id + 1) | ================================== - 1.234567910432816e-01 | - 1.123456791043282e+00 | - 1.234567910432816e-01 | - 1.123456791043282e+00 | - 1.123456791043282e+00 | - 3.123456791043282e+00 | - 6.123456791043282e+00 | - 1.123456791043282e+00 | - 1.234567910432816e-01 | - 1.123456791043282e+00 | + 0.123456791043282 | + 1.12345679104328 | + 0.123456791043282 | + 1.12345679104328 | + 1.12345679104328 | + 3.12345679104328 | + 6.12345679104328 | + 1.12345679104328 | + 0.123456791043282 | + 1.12345679104328 | taos> select MOD(current, id + 1) from ts_4893.meters order by ts limit 10 mod(current, id + 1) | @@ -94,16 +94,16 @@ taos> select MOD(current, 1) from ts_4893.meters order by ts limit 10 taos> select MOD(sqrt(current), abs(id + 1)) from ts_4893.meters order by ts limit 10 mod(sqrt(current), abs(id + 1)) | ================================== - 2.634337159700784e-01 | - 9.281394021770111e-01 | - 1.296964830944782e-01 | - 3.351566768190027e+00 | - 3.272002495118848e+00 | - 2.916847677517688e+00 | - 3.097741066924800e+00 | - 3.310891102586806e+00 | - 3.350522322288470e+00 | - 3.215120509901375e+00 | + 0.263433715970078 | + 0.928139402177011 | + 0.129696483094478 | + 3.35156676819003 | + 3.27200249511885 | + 2.91684767751769 | + 3.0977410669248 | + 3.31089110258681 | + 3.35052232228847 | + 3.21512050990137 | taos> select mod(10, -3) mod(10, -3) | diff --git a/tests/army/query/function/ans/pi.csv b/tests/army/query/function/ans/pi.csv index fb7d662ca3..a364f472c6 100644 --- a/tests/army/query/function/ans/pi.csv +++ b/tests/army/query/function/ans/pi.csv @@ -190,5 +190,5 @@ taos> select voltage / pi() from ts_4893.meters limit 1 taos> select id, case when voltage > 100 then pi() else pi() / 2 end from ts_4893.meters limit 1 id | case when voltage > 100 then pi() else pi() / 2 end | ==================================================================== - 0 | 3.141592653589793e+00 | + 0 | 3.14159265358979 | diff --git a/tests/army/query/function/ans/position.csv b/tests/army/query/function/ans/position.csv index 1547564322..8e082ef574 100644 --- a/tests/army/query/function/ans/position.csv +++ b/tests/army/query/function/ans/position.csv @@ -201,7 +201,7 @@ taos> select ABS(POSITION('aaa' IN 'aaaaaaaaa')) taos> select POW(POSITION('aaa' IN 'aaaaaaaaa'), 2) pow(position('aaa' in 'aaaaaaaaa'), 2) | ========================================= - 1.000000000000000e+00 | + 1 | taos> select position('t' in 'taos') position('t' in 'taos') | diff --git a/tests/army/query/function/ans/rand.csv b/tests/army/query/function/ans/rand.csv index 2e87f3404f..5685bd901e 100644 --- a/tests/army/query/function/ans/rand.csv +++ b/tests/army/query/function/ans/rand.csv @@ -50,12 +50,12 @@ taos> select rand(-1) taos> select rand(12345678901234567890) rand(12345678901234567890) | ============================= - 2.008294813338805e-01 | + 0.20082948133388 | taos> select rand(-12345678901234567890) rand(-12345678901234567890) | ============================== - 8.401877171547095e-01 | + 0.84018771715471 | taos> select rand(12345), rand(12345) rand(12345) | rand(12345) | diff --git a/tests/army/query/function/ans/round.csv b/tests/army/query/function/ans/round.csv index 2c185abd73..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), | =================================================================== - 1.230000000000000e+02 | + 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, - | =================================================================== - 1.230000000000000e+08 | + 123000000 | taos> select ROUND(current) from ts_4893.meters order by ts limit 20 round(current) | @@ -101,16 +101,16 @@ taos> select ROUND(current) from ts_4893.meters order by ts limit 20 taos> select ROUND(87654321.123456789, id) from ts_4893.meters order by ts limit 10 round(87654321.123456789, id) | ================================ - 8.765432100000000e+07 | - 8.765432109999999e+07 | - 8.765432112000000e+07 | - 8.765432112300000e+07 | - 8.765432112350000e+07 | - 8.765432112345999e+07 | - 8.765432112345700e+07 | - 8.765432112345681e+07 | - 8.765432112345679e+07 | - 8.765432112345679e+07 | + 87654321 | + 87654321.1 | + 87654321.12 | + 87654321.123 | + 87654321.1235 | + 87654321.12346 | + 87654321.123457 | + 87654321.1234568 | + 87654321.1234568 | + 87654321.1234568 | taos> select ROUND(current, id) from ts_4893.meters order by ts limit 10 round(current, id) | @@ -286,7 +286,7 @@ taos> select round(voltage, -1) from ts_4893.meters limit 1 taos> select round(current * voltage, 2) from ts_4893.meters limit 1 round(current * voltage, 2) | ============================== - 2.353650000000000e+03 | + 2353.65 | taos> select round(abs(voltage), 2) from ts_4893.meters limit 1 round(abs(voltage), 2) | diff --git a/tests/army/query/function/ans/sign.csv b/tests/army/query/function/ans/sign.csv index f8fc961c2b..700e88fde6 100644 --- a/tests/army/query/function/ans/sign.csv +++ b/tests/army/query/function/ans/sign.csv @@ -164,7 +164,7 @@ taos> select sign(cast(1 as bigint unsigned)) taos> select sign(cast(1 as float)) sign(cast(1 as float)) | ========================= - 1.0000000e+00 | + 1 | taos> select sign(cast(1 as double)) sign(cast(1 as double)) | @@ -316,30 +316,30 @@ taos> select sign(current) from ts_4893.meters order by ts limit 10 taos> select sign(cast(current as float)) from ts_4893.d0 order by ts limit 10 sign(cast(current as float)) | =============================== - 1.0000000e+00 | - 1.0000000e+00 | - 1.0000000e+00 | - 1.0000000e+00 | - 1.0000000e+00 | - 1.0000000e+00 | - 1.0000000e+00 | - 1.0000000e+00 | - 1.0000000e+00 | - 1.0000000e+00 | + 1 | + 1 | + 1 | + 1 | + 1 | + 1 | + 1 | + 1 | + 1 | + 1 | taos> select sign(cast(current as float)) from ts_4893.meters order by ts limit 10 sign(cast(current as float)) | =============================== - 1.0000000e+00 | - 1.0000000e+00 | - 1.0000000e+00 | - 1.0000000e+00 | - 1.0000000e+00 | - 1.0000000e+00 | - 1.0000000e+00 | - 1.0000000e+00 | - 1.0000000e+00 | - 1.0000000e+00 | + 1 | + 1 | + 1 | + 1 | + 1 | + 1 | + 1 | + 1 | + 1 | + 1 | taos> select sign(null) sign(null) | diff --git a/tests/army/query/function/ans/stddev.csv b/tests/army/query/function/ans/stddev.csv index c0f93a9bcd..02f83a7742 100644 --- a/tests/army/query/function/ans/stddev.csv +++ b/tests/army/query/function/ans/stddev.csv @@ -109,17 +109,17 @@ taos> select stddev_pop(total_voltage) from (select sum(voltage) as total_voltag taos> select round(stddev_pop(current), 2) from ts_4893.meters round(stddev_pop(current), 2) | ================================ - 1.150000000000000e+00 | + 1.15 | taos> select pow(stddev_pop(current), 2) from ts_4893.meters pow(stddev_pop(current), 2) | ============================== - 1.332500071133751e+00 | + 1.33250007113375 | taos> select log(stddev_pop(voltage) + 1) from ts_4893.meters log(stddev_pop(voltage) + 1) | =============================== - 1.354922290183882e+00 | + 1.35492229018388 | taos> select groupid, stddev_pop(voltage) from ts_4893.meters group by groupid order by groupid groupid | stddev_pop(voltage) | diff --git a/tests/army/query/function/ans/trunc.csv b/tests/army/query/function/ans/trunc.csv index 15411afbf3..8d1316b760 100644 --- a/tests/army/query/function/ans/trunc.csv +++ b/tests/army/query/function/ans/trunc.csv @@ -47,40 +47,40 @@ 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 | =================================================================== - 1.231230000000000e+02 | + 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 | =================================================================== - 1.200000000000000e+08 | + 120000000 | taos> select TRUNCATE(87654321.123456789, id) from ts_4893.meters order by ts limit 10 truncate(87654321.123456789, id) | =================================== - 8.765432100000000e+07 | - 8.765432109999999e+07 | - 8.765432112000000e+07 | - 8.765432112300000e+07 | - 8.765432112340000e+07 | - 8.765432112345000e+07 | - 8.765432112345600e+07 | - 8.765432112345670e+07 | - 8.765432112345679e+07 | - 8.765432112345679e+07 | + 87654321 | + 87654321.1 | + 87654321.12 | + 87654321.123 | + 87654321.1234 | + 87654321.12345 | + 87654321.123456 | + 87654321.1234567 | + 87654321.1234568 | + 87654321.1234568 | taos> select TRUNCATE(current, id) from ts_4893.meters order by ts limit 10 truncate(current, id) | ======================== - 1.0000000e+01 | - 8.5000000e+00 | - 9.7900000e+00 | - 1.1233000e+01 | - 1.0706000e+01 | - 8.5080004e+00 | - 9.5959997e+00 | - 1.0962000e+01 | - 1.1226000e+01 | - 1.0337000e+01 | + 10 | + 8.5 | + 9.79 | + 11.233 | + 10.706 | + 8.508 | + 9.596 | + 10.962 | + 11.226 | + 10.337 | taos> select TRUNCATE(current, 1) from ts_4893.meters order by ts limit 10 truncate(current, 1) | @@ -144,26 +144,26 @@ 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), | =================================================================== - 1.231230000000000e+02 | + 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, - | =================================================================== - 1.200000000000000e+08 | + 120000000 | taos> select TRUNC(87654321.123456789, id) from ts_4893.meters order by ts limit 10 trunc(87654321.123456789, id) | ================================ - 8.765432100000000e+07 | - 8.765432109999999e+07 | - 8.765432112000000e+07 | - 8.765432112300000e+07 | - 8.765432112340000e+07 | - 8.765432112345000e+07 | - 8.765432112345600e+07 | - 8.765432112345670e+07 | - 8.765432112345679e+07 | - 8.765432112345679e+07 | + 87654321 | + 87654321.1 | + 87654321.12 | + 87654321.123 | + 87654321.1234 | + 87654321.12345 | + 87654321.123456 | + 87654321.1234567 | + 87654321.1234568 | + 87654321.1234568 | taos> select TRUNC(current, id) from ts_4893.meters order by ts limit 10 trunc(current, id) | @@ -289,7 +289,7 @@ taos> select truncate(100.9876, 2) taos> select truncate(99999999999999.9999, 2) truncate(99999999999999.9999, 2) | =================================== - 1.000000000000000e+14 | + 100000000000000 | taos> select truncate(-5.678, 2) truncate(-5.678, 2) | @@ -314,7 +314,7 @@ taos> select truncate(phase, 3) from ts_4893.meters limit 1 taos> select truncate(voltage + current, 2) from ts_4893.meters limit 1 truncate(voltage + current, 2) | ================================= - 2.316400000000000e+02 | + 231.64 | taos> select truncate(voltage, -1) from ts_4893.meters limit 1 truncate(voltage, -1) | @@ -329,7 +329,7 @@ taos> select round(truncate(voltage, 1), 2) from ts_4893.meters limit 1 taos> select truncate(abs(current), 1) from ts_4893.meters limit 1 truncate(abs(current), 1) | ============================ - 1.0600000e+01 | + 10.6 | taos> select truncate(exp(phase), 2) from ts_4893.meters limit 1 truncate(exp(phase), 2) | diff --git a/tests/army/query/function/ans/varpop.csv b/tests/army/query/function/ans/varpop.csv index 829996d978..ec5d479f3a 100644 --- a/tests/army/query/function/ans/varpop.csv +++ b/tests/army/query/function/ans/varpop.csv @@ -99,7 +99,7 @@ taos> select var_pop(total_voltage) from (select sum(voltage) as total_voltage f taos> select round(var_pop(current), 2) from ts_4893.meters round(var_pop(current), 2) | ============================= - 1.330000000000000e+00 | + 1.33 | taos> select pow(var_pop(current), 2) from ts_4893.meters pow(var_pop(current), 2) | diff --git a/tests/army/query/function/in/greatest.in b/tests/army/query/function/in/greatest.in new file mode 100644 index 0000000000..098ef626e9 --- /dev/null +++ b/tests/army/query/function/in/greatest.in @@ -0,0 +1,232 @@ +alter local 'compareAsStrInGreatest' '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 'compareAsStrInGreatest' '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..946d00b59b --- /dev/null +++ b/tests/army/query/function/in/least.in @@ -0,0 +1,228 @@ +alter local 'compareAsStrInGreatest' '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 'compareAsStrInGreatest' '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..27e54407cc 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,223 @@ 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 'compareAsStrInGreatest' '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.query("select GREATEST(now, 1);") + tdSql.query("select GREATEST(now, 1.0);") + tdSql.query("select GREATEST(now, '1');") + + tdSql.error("select GREATEST(1)") + 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 'compareAsStrInGreatest' '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.query("select LEAST(now, 1);") + tdSql.checkRows(1) + tdSql.checkCols(1) + tdSql.checkData(0, 0, "1970-01-01 08:00:00.001") + + tdSql.query("select LEAST(now, 1.0);") + tdSql.checkRows(1) + tdSql.checkCols(1) + tdSql.checkData(0, 0, 1) + + tdSql.query("select LEAST(now, '1');") + tdSql.checkRows(1) + tdSql.checkCols(1) + tdSql.checkData(0, 0, "1") + + 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 test_greatest_large_table(self): + tdLog.info("test greatest large table.") + + ts = 1741341251000 + create_table_sql = "CREATE TABLE `large_table` (`ts` TIMESTAMP" + for i in range(1, 1001): + if i % 5 == 1: + create_table_sql += f", `col{i}` INT" + elif i % 5 == 2: + create_table_sql += f", `col{i}` FLOAT" + elif i % 5 == 3: + create_table_sql += f", `col{i}` DOUBLE" + elif i % 5 == 4: + create_table_sql += f", `col{i}` VARCHAR(64)" + else: + create_table_sql += f", `col{i}` NCHAR(50)" + create_table_sql += ");" + tdSql.execute(create_table_sql) + + for j in range(1000): + insert_sql = f"INSERT INTO `large_table` VALUES ({ts +j}" + for i in range(1, 1001): + if i % 5 == 1: + insert_sql += f", {j + i}" + elif i % 5 == 2: + insert_sql += f", {j + i}.1" + elif i % 5 == 3: + insert_sql += f", {j + i}.2" + elif i % 5 == 4: + insert_sql += f", '{j + i}'" + else: + insert_sql += f", '{j + i}'" + insert_sql += ");" + tdSql.execute(insert_sql) + + greatest_query = "SELECT GREATEST(" + for i in range(1, 1001): + greatest_query += f"`col{i}`" + if i < 1000: + greatest_query += ", " + greatest_query += ") FROM `large_table` LIMIT 1;" + tdLog.info(f"greatest_query: {greatest_query}") + tdSql.execute(greatest_query) + + greatest_query = "SELECT " + for i in range(1, 1001): + greatest_query += f"`col{i}` > `col5`" + if i < 1000: + greatest_query += ", " + greatest_query += " FROM `large_table` LIMIT 1;" + tdLog.info(f"greatest_query: {greatest_query}") + tdSql.execute(greatest_query) + def run(self): tdLog.debug(f"start to excute {__file__}") @@ -326,7 +516,10 @@ class TDTestCase(TBase): self.test_degrees() self.test_radians() self.test_rand() - + self.test_greatest() + self.test_least() + self.test_greatest_large_table() + # char function self.test_char_length() self.test_char() diff --git a/tests/system-test/8-stream/checkpoint_info2.py b/tests/system-test/8-stream/checkpoint_info2.py index 3dc57477f7..f4c8da8c9d 100644 --- a/tests/system-test/8-stream/checkpoint_info2.py +++ b/tests/system-test/8-stream/checkpoint_info2.py @@ -22,6 +22,8 @@ from util.cluster import * # should be used by -N option class TDTestCase: updatecfgDict = {'checkpointInterval': 60 , + 'vdebugflag':143, + 'ddebugflag':143 } def init(self, conn, logSql, replicaVar=1): self.replicaVar = int(replicaVar) diff --git a/tools/shell/src/shellEngine.c b/tools/shell/src/shellEngine.c index a3e542a768..99b1c204a2 100644 --- a/tools/shell/src/shellEngine.c +++ b/tools/shell/src/shellEngine.c @@ -668,28 +668,22 @@ 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 { - n = snprintf(buf, LENGTH, "%*.*g", width, FLT_DIG, GET_FLOAT_VAL(val)); - if (n > SHELL_FLOAT_WIDTH) { - printf("%*.7e", width, GET_FLOAT_VAL(val)); - } else { - printf("%s", buf); - } + snprintf(buf, LENGTH, "%*.*g", width, FLT_DIG, GET_FLOAT_VAL(val)); + printf("%s", buf); } 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); } else { - n = snprintf(buf, LENGTH, "%*.*g", width, DBL_DIG, GET_DOUBLE_VAL(val)); - if (n > SHELL_DOUBLE_WIDTH) { - printf("%*.15e", width, GET_DOUBLE_VAL(val)); - } else { - printf("%*s", width, buf); - } + snprintf(buf, LENGTH, "%*.*g", width, DBL_DIG, GET_DOUBLE_VAL(val)); + printf("%*s", width, buf); } break; case TSDB_DATA_TYPE_VARBINARY: {