diff --git a/packaging/tools/makeclient.sh b/packaging/tools/makeclient.sh index 278388f39f8a93c4e38ec6b344c7e902dfed549e..4c3278e41b0c51e86d84c3e200092b4554e6523c 100755 --- a/packaging/tools/makeclient.sh +++ b/packaging/tools/makeclient.sh @@ -47,7 +47,8 @@ if [ "$osType" != "Darwin" ]; then else bin_files="${script_dir}/remove_client.sh \ ${script_dir}/set_core.sh \ - ${script_dir}/get_client.sh ${script_dir}/taosd-dump-cfg.gdb" + ${script_dir}/get_client.sh" + #${script_dir}/get_client.sh ${script_dir}/taosd-dump-cfg.gdb" fi lib_files="${build_dir}/lib/libtaos.so.${version}" else diff --git a/packaging/tools/makeclient_jh.sh b/packaging/tools/makeclient_jh.sh index ed61cffaf793ede0f774fa1ba2c81d7645f714dc..bfbdcfc578bc7f8dfb15fef302d9817014ff3bef 100755 --- a/packaging/tools/makeclient_jh.sh +++ b/packaging/tools/makeclient_jh.sh @@ -77,7 +77,7 @@ if [ "$osType" != "Darwin" ]; then cp ${build_dir}/bin/taosdump ${install_dir}/bin/jh_taosdump cp ${script_dir}/set_core.sh ${install_dir}/bin cp ${script_dir}/get_client.sh ${install_dir}/bin - cp ${script_dir}/taosd-dump-cfg.gdb ${install_dir}/bin + #cp ${script_dir}/taosd-dump-cfg.gdb ${install_dir}/bin fi else cp ${bin_files} ${install_dir}/bin diff --git a/packaging/tools/makeclient_kh.sh b/packaging/tools/makeclient_kh.sh index 86d37105a4acd3fcefbfa8d230804d7d2f820fb5..fe171664f62b07152c876846e8a64cc41b8c2eed 100755 --- a/packaging/tools/makeclient_kh.sh +++ b/packaging/tools/makeclient_kh.sh @@ -77,7 +77,7 @@ if [ "$osType" != "Darwin" ]; then cp ${build_dir}/bin/taosdump ${install_dir}/bin/khdump cp ${script_dir}/set_core.sh ${install_dir}/bin cp ${script_dir}/get_client.sh ${install_dir}/bin - cp ${script_dir}/taosd-dump-cfg.gdb ${install_dir}/bin + #cp ${script_dir}/taosd-dump-cfg.gdb ${install_dir}/bin fi else cp ${bin_files} ${install_dir}/bin diff --git a/packaging/tools/makeclient_power.sh b/packaging/tools/makeclient_power.sh index 2f01748f5e40925b905a715b3c308692d46e71b0..0931d1350197bf31cfaa9f8a87cd1fe50d28ced3 100755 --- a/packaging/tools/makeclient_power.sh +++ b/packaging/tools/makeclient_power.sh @@ -117,7 +117,7 @@ if [ "$osType" != "Darwin" ]; then cp ${build_dir}/bin/taosdump ${install_dir}/bin/powerdump cp ${script_dir}/set_core.sh ${install_dir}/bin cp ${script_dir}/get_client.sh ${install_dir}/bin - cp ${script_dir}/taosd-dump-cfg.gdb ${install_dir}/bin + #cp ${script_dir}/taosd-dump-cfg.gdb ${install_dir}/bin fi else cp ${bin_files} ${install_dir}/bin diff --git a/packaging/tools/makeclient_pro.sh b/packaging/tools/makeclient_pro.sh index 769d0274e5eb5198fedb6c6c3a7f1590fd2ff44a..023c16cf820481fcc16bb26f31e6acf58d8edbc1 100755 --- a/packaging/tools/makeclient_pro.sh +++ b/packaging/tools/makeclient_pro.sh @@ -77,7 +77,7 @@ if [ "$osType" != "Darwin" ]; then cp ${build_dir}/bin/taosdump ${install_dir}/bin/prodump cp ${script_dir}/set_core.sh ${install_dir}/bin cp ${script_dir}/get_client.sh ${install_dir}/bin - cp ${script_dir}/taosd-dump-cfg.gdb ${install_dir}/bin + #cp ${script_dir}/taosd-dump-cfg.gdb ${install_dir}/bin fi else cp ${bin_files} ${install_dir}/bin diff --git a/packaging/tools/makeclient_tq.sh b/packaging/tools/makeclient_tq.sh index f8d87ba76a9ab32ea729d4999a05712976a32634..d554a05f6af40b79362d397071026591cf6714d4 100755 --- a/packaging/tools/makeclient_tq.sh +++ b/packaging/tools/makeclient_tq.sh @@ -77,7 +77,7 @@ if [ "$osType" != "Darwin" ]; then cp ${build_dir}/bin/taosdump ${install_dir}/bin/tqdump cp ${script_dir}/set_core.sh ${install_dir}/bin cp ${script_dir}/get_client.sh ${install_dir}/bin - cp ${script_dir}/taosd-dump-cfg.gdb ${install_dir}/bin + #cp ${script_dir}/taosd-dump-cfg.gdb ${install_dir}/bin fi else cp ${bin_files} ${install_dir}/bin diff --git a/src/client/inc/tscSubquery.h b/src/client/inc/tscSubquery.h index b6f0ec712c9bbd0d48b560a5e72768a021e2b74d..5293a176d85a0d928e3cf6211c31e301352ce2e7 100644 --- a/src/client/inc/tscSubquery.h +++ b/src/client/inc/tscSubquery.h @@ -42,7 +42,7 @@ int32_t tscHandleInsertRetry(SSqlObj* parent, SSqlObj* child); void tscBuildResFromSubqueries(SSqlObj *pSql); TAOS_ROW doSetResultRowData(SSqlObj *pSql); -char *getArithmeticInputSrc(void *param, const char *name, int32_t colId); +char *getScalarExprInputSrc(void *param, const char *name, int32_t colId); void tscLockByThread(int64_t *lockedBy); diff --git a/src/client/inc/tscUtil.h b/src/client/inc/tscUtil.h index 7baa1bd08877164a0fcacb6e1a95660347a2c0e2..dd9db517956e9e72ebef040c6b765c8a315a95ad 100644 --- a/src/client/inc/tscUtil.h +++ b/src/client/inc/tscUtil.h @@ -35,12 +35,12 @@ extern "C" { #define UTIL_TABLE_IS_CHILD_TABLE(metaInfo) \ (((metaInfo)->pTableMeta != NULL) && ((metaInfo)->pTableMeta->tableType == TSDB_CHILD_TABLE)) -#define UTIL_TABLE_IS_NORMAL_TABLE(metaInfo) \ - (!(UTIL_TABLE_IS_SUPER_TABLE(metaInfo) || UTIL_TABLE_IS_CHILD_TABLE(metaInfo))) - #define UTIL_TABLE_IS_TMP_TABLE(metaInfo) \ (((metaInfo)->pTableMeta != NULL) && ((metaInfo)->pTableMeta->tableType == TSDB_TEMP_TABLE)) +#define UTIL_TABLE_IS_NORMAL_TABLE(metaInfo) \ + (!(UTIL_TABLE_IS_SUPER_TABLE(metaInfo) || UTIL_TABLE_IS_CHILD_TABLE(metaInfo) || UTIL_TABLE_IS_TMP_TABLE(metaInfo))) + #define UTIL_GET_VGROUPMAP(pSql) \ (pSql->pTscObj->pClusterInfo->vgroupMap) @@ -364,7 +364,7 @@ bool subAndCheckDone(SSqlObj *pSql, SSqlObj *pParentSql, int idx); bool tscSetSqlOwner(SSqlObj* pSql); void tscClearSqlOwner(SSqlObj* pSql); -int32_t doArithmeticCalculate(SQueryInfo* pQueryInfo, tFilePage* pOutput, int32_t rowSize, int32_t finalRowSize); +int32_t doScalarExprCalculate(SQueryInfo* pQueryInfo, tFilePage* pOutput, int32_t rowSize, int32_t finalRowSize); char* serializeTagData(STagData* pTagData, char* pMsg); int32_t copyTagData(STagData* dst, const STagData* src); diff --git a/src/client/inc/tsclient.h b/src/client/inc/tsclient.h index 84296f8e7d325154b445aae12630637f6aee56fa..10cfe8bcc5053fa9fe44982268d9e8843d071ce6 100644 --- a/src/client/inc/tsclient.h +++ b/src/client/inc/tsclient.h @@ -115,8 +115,9 @@ typedef struct SParsedDataColInfo { int16_t numOfCols; int16_t numOfBound; uint16_t flen; // TODO: get from STSchema - uint16_t allNullLen; // TODO: get from STSchema + uint16_t allNullLen; // TODO: get from STSchema(base on SDataRow) uint16_t extendedVarLen; + uint16_t boundNullLen; // bound column len with all NULL value(without VarDataOffsetT/SColIdx part) int32_t * boundedColumns; // bound column idx according to schema SBoundColumn * cols; SBoundIdxInfo *colIdxInfo; @@ -132,7 +133,7 @@ typedef struct { typedef struct { uint8_t memRowType; // default is 0, that is SDataRow uint8_t compareStat; // 0 no need, 1 need compare - TDRowTLenT kvRowInitLen; + int32_t rowSize; SMemRowInfo *rowInfo; } SMemRowBuilder; @@ -150,8 +151,7 @@ typedef struct { int tsParseTime(SStrToken *pToken, int64_t *time, char **next, char *error, int16_t timePrec); -int initMemRowBuilder(SMemRowBuilder *pBuilder, uint32_t nRows, uint32_t nCols, uint32_t nBoundCols, - int32_t allNullLen); +int initMemRowBuilder(SMemRowBuilder *pBuilder, uint32_t nRows, SParsedDataColInfo *pColInfo); void destroyMemRowBuilder(SMemRowBuilder *pBuilder); /** @@ -499,6 +499,8 @@ bool tscHasReachLimitation(SQueryInfo *pQueryInfo, SSqlRes *pRes); void tscSetBoundColumnInfo(SParsedDataColInfo *pColInfo, SSchema *pSchema, int32_t numOfCols); char *tscGetErrorMsgPayload(SSqlCmd *pCmd); +int32_t tscGetErrorMsgLength(SSqlCmd* pCmd); + int32_t tscErrorMsgWithCode(int32_t code, char* dstBuffer, const char* errMsg, const char* sql); int32_t tscInvalidOperationMsg(char *msg, const char *additionalInfo, const char *sql); @@ -531,16 +533,6 @@ static FORCE_INLINE int32_t getExtendedRowSize(STableDataBlocks *pBlock) { return pBlock->rowSize + TD_MEM_ROW_DATA_HEAD_SIZE + pBlock->boundColumnInfo.extendedVarLen; } -static FORCE_INLINE void checkAndConvertMemRow(SMemRow row, int32_t dataLen, int32_t kvLen) { - if (isDataRow(row)) { - if (kvLen < (dataLen * KVRatioConvert)) { - memRowSetConvert(row); - } - } else if (kvLen > dataLen) { - memRowSetConvert(row); - } -} - static FORCE_INLINE void initSMemRow(SMemRow row, uint8_t memRowType, STableDataBlocks *pBlock, int16_t nBoundCols) { memRowSetType(row, memRowType); if (isDataRowT(memRowType)) { @@ -640,8 +632,7 @@ static uint8_t TRUE_VALUE = (uint8_t)TSDB_TRUE; static uint8_t FALSE_VALUE = (uint8_t)TSDB_FALSE; static FORCE_INLINE int32_t tsParseOneColumnKV(SSchema *pSchema, SStrToken *pToken, SMemRow row, char *msg, char **str, - bool primaryKey, int16_t timePrec, int32_t toffset, int16_t colId, - int32_t *dataLen, int32_t *kvLen, uint8_t compareStat) { + bool primaryKey, int16_t timePrec, int32_t toffset, int16_t colId) { int64_t iv; int32_t ret; char * endptr = NULL; @@ -653,26 +644,22 @@ static FORCE_INLINE int32_t tsParseOneColumnKV(SSchema *pSchema, SStrToken *pTok switch (pSchema->type) { case TSDB_DATA_TYPE_BOOL: { // bool if (isNullStr(pToken)) { - tscAppendMemRowColValEx(row, getNullValue(pSchema->type), true, colId, pSchema->type, toffset, dataLen, kvLen, - compareStat); + tdAppendMemRowColVal(row, getNullValue(pSchema->type), true, colId, pSchema->type, toffset); } else { if ((pToken->type == TK_BOOL || pToken->type == TK_STRING) && (pToken->n != 0)) { if (strncmp(pToken->z, "true", pToken->n) == 0) { - tscAppendMemRowColValEx(row, &TRUE_VALUE, true, colId, pSchema->type, toffset, dataLen, kvLen, compareStat); + tdAppendMemRowColVal(row, &TRUE_VALUE, true, colId, pSchema->type, toffset); } else if (strncmp(pToken->z, "false", pToken->n) == 0) { - tscAppendMemRowColValEx(row, &FALSE_VALUE, true, colId, pSchema->type, toffset, dataLen, kvLen, - compareStat); + tdAppendMemRowColVal(row, &FALSE_VALUE, true, colId, pSchema->type, toffset); } else { return tscSQLSyntaxErrMsg(msg, "invalid bool data", pToken->z); } } else if (pToken->type == TK_INTEGER) { iv = strtoll(pToken->z, NULL, 10); - tscAppendMemRowColValEx(row, ((iv == 0) ? &FALSE_VALUE : &TRUE_VALUE), true, colId, pSchema->type, toffset, - dataLen, kvLen, compareStat); + tdAppendMemRowColVal(row, ((iv == 0) ? &FALSE_VALUE : &TRUE_VALUE), true, colId, pSchema->type, toffset); } else if (pToken->type == TK_FLOAT) { double dv = strtod(pToken->z, NULL); - tscAppendMemRowColValEx(row, ((dv == 0) ? &FALSE_VALUE : &TRUE_VALUE), true, colId, pSchema->type, toffset, - dataLen, kvLen, compareStat); + tdAppendMemRowColVal(row, ((dv == 0) ? &FALSE_VALUE : &TRUE_VALUE), true, colId, pSchema->type, toffset); } else { return tscInvalidOperationMsg(msg, "invalid bool data", pToken->z); } @@ -682,8 +669,7 @@ static FORCE_INLINE int32_t tsParseOneColumnKV(SSchema *pSchema, SStrToken *pTok case TSDB_DATA_TYPE_TINYINT: if (isNullStr(pToken)) { - tscAppendMemRowColValEx(row, getNullValue(pSchema->type), true, colId, pSchema->type, toffset, dataLen, kvLen, - compareStat); + tdAppendMemRowColVal(row, getNullValue(pSchema->type), true, colId, pSchema->type, toffset); } else { ret = tStrToInteger(pToken->z, pToken->type, pToken->n, &iv, true); if (ret != TSDB_CODE_SUCCESS) { @@ -693,15 +679,14 @@ static FORCE_INLINE int32_t tsParseOneColumnKV(SSchema *pSchema, SStrToken *pTok } uint8_t tmpVal = (uint8_t)iv; - tscAppendMemRowColValEx(row, &tmpVal, true, colId, pSchema->type, toffset, dataLen, kvLen, compareStat); + tdAppendMemRowColVal(row, &tmpVal, true, colId, pSchema->type, toffset); } break; case TSDB_DATA_TYPE_UTINYINT: if (isNullStr(pToken)) { - tscAppendMemRowColValEx(row, getNullValue(pSchema->type), true, colId, pSchema->type, toffset, dataLen, kvLen, - compareStat); + tdAppendMemRowColVal(row, getNullValue(pSchema->type), true, colId, pSchema->type, toffset); } else { ret = tStrToInteger(pToken->z, pToken->type, pToken->n, &iv, false); if (ret != TSDB_CODE_SUCCESS) { @@ -711,15 +696,14 @@ static FORCE_INLINE int32_t tsParseOneColumnKV(SSchema *pSchema, SStrToken *pTok } uint8_t tmpVal = (uint8_t)iv; - tscAppendMemRowColValEx(row, &tmpVal, true, colId, pSchema->type, toffset, dataLen, kvLen, compareStat); + tdAppendMemRowColVal(row, &tmpVal, true, colId, pSchema->type, toffset); } break; case TSDB_DATA_TYPE_SMALLINT: if (isNullStr(pToken)) { - tscAppendMemRowColValEx(row, getNullValue(pSchema->type), true, colId, pSchema->type, toffset, dataLen, kvLen, - compareStat); + tdAppendMemRowColVal(row, getNullValue(pSchema->type), true, colId, pSchema->type, toffset); } else { ret = tStrToInteger(pToken->z, pToken->type, pToken->n, &iv, true); if (ret != TSDB_CODE_SUCCESS) { @@ -729,15 +713,14 @@ static FORCE_INLINE int32_t tsParseOneColumnKV(SSchema *pSchema, SStrToken *pTok } int16_t tmpVal = (int16_t)iv; - tscAppendMemRowColValEx(row, &tmpVal, true, colId, pSchema->type, toffset, dataLen, kvLen, compareStat); + tdAppendMemRowColVal(row, &tmpVal, true, colId, pSchema->type, toffset); } break; case TSDB_DATA_TYPE_USMALLINT: if (isNullStr(pToken)) { - tscAppendMemRowColValEx(row, getNullValue(pSchema->type), true, colId, pSchema->type, toffset, dataLen, kvLen, - compareStat); + tdAppendMemRowColVal(row, getNullValue(pSchema->type), true, colId, pSchema->type, toffset); } else { ret = tStrToInteger(pToken->z, pToken->type, pToken->n, &iv, false); if (ret != TSDB_CODE_SUCCESS) { @@ -747,15 +730,14 @@ static FORCE_INLINE int32_t tsParseOneColumnKV(SSchema *pSchema, SStrToken *pTok } uint16_t tmpVal = (uint16_t)iv; - tscAppendMemRowColValEx(row, &tmpVal, true, colId, pSchema->type, toffset, dataLen, kvLen, compareStat); + tdAppendMemRowColVal(row, &tmpVal, true, colId, pSchema->type, toffset); } break; case TSDB_DATA_TYPE_INT: if (isNullStr(pToken)) { - tscAppendMemRowColValEx(row, getNullValue(pSchema->type), true, colId, pSchema->type, toffset, dataLen, kvLen, - compareStat); + tdAppendMemRowColVal(row, getNullValue(pSchema->type), true, colId, pSchema->type, toffset); } else { ret = tStrToInteger(pToken->z, pToken->type, pToken->n, &iv, true); if (ret != TSDB_CODE_SUCCESS) { @@ -765,15 +747,14 @@ static FORCE_INLINE int32_t tsParseOneColumnKV(SSchema *pSchema, SStrToken *pTok } int32_t tmpVal = (int32_t)iv; - tscAppendMemRowColValEx(row, &tmpVal, true, colId, pSchema->type, toffset, dataLen, kvLen, compareStat); + tdAppendMemRowColVal(row, &tmpVal, true, colId, pSchema->type, toffset); } break; case TSDB_DATA_TYPE_UINT: if (isNullStr(pToken)) { - tscAppendMemRowColValEx(row, getNullValue(pSchema->type), true, colId, pSchema->type, toffset, dataLen, kvLen, - compareStat); + tdAppendMemRowColVal(row, getNullValue(pSchema->type), true, colId, pSchema->type, toffset); } else { ret = tStrToInteger(pToken->z, pToken->type, pToken->n, &iv, false); if (ret != TSDB_CODE_SUCCESS) { @@ -783,15 +764,14 @@ static FORCE_INLINE int32_t tsParseOneColumnKV(SSchema *pSchema, SStrToken *pTok } uint32_t tmpVal = (uint32_t)iv; - tscAppendMemRowColValEx(row, &tmpVal, true, colId, pSchema->type, toffset, dataLen, kvLen, compareStat); + tdAppendMemRowColVal(row, &tmpVal, true, colId, pSchema->type, toffset); } break; case TSDB_DATA_TYPE_BIGINT: if (isNullStr(pToken)) { - tscAppendMemRowColValEx(row, getNullValue(pSchema->type), true, colId, pSchema->type, toffset, dataLen, kvLen, - compareStat); + tdAppendMemRowColVal(row, getNullValue(pSchema->type), true, colId, pSchema->type, toffset); } else { ret = tStrToInteger(pToken->z, pToken->type, pToken->n, &iv, true); if (ret != TSDB_CODE_SUCCESS) { @@ -800,14 +780,13 @@ static FORCE_INLINE int32_t tsParseOneColumnKV(SSchema *pSchema, SStrToken *pTok return tscInvalidOperationMsg(msg, "bigint data overflow", pToken->z); } - tscAppendMemRowColValEx(row, &iv, true, colId, pSchema->type, toffset, dataLen, kvLen, compareStat); + tdAppendMemRowColVal(row, &iv, true, colId, pSchema->type, toffset); } break; case TSDB_DATA_TYPE_UBIGINT: if (isNullStr(pToken)) { - tscAppendMemRowColValEx(row, getNullValue(pSchema->type), true, colId, pSchema->type, toffset, dataLen, kvLen, - compareStat); + tdAppendMemRowColVal(row, getNullValue(pSchema->type), true, colId, pSchema->type, toffset); } else { ret = tStrToInteger(pToken->z, pToken->type, pToken->n, &iv, false); if (ret != TSDB_CODE_SUCCESS) { @@ -817,14 +796,13 @@ static FORCE_INLINE int32_t tsParseOneColumnKV(SSchema *pSchema, SStrToken *pTok } uint64_t tmpVal = (uint64_t)iv; - tscAppendMemRowColValEx(row, &tmpVal, true, colId, pSchema->type, toffset, dataLen, kvLen, compareStat); + tdAppendMemRowColVal(row, &tmpVal, true, colId, pSchema->type, toffset); } break; case TSDB_DATA_TYPE_FLOAT: if (isNullStr(pToken)) { - tscAppendMemRowColValEx(row, getNullValue(pSchema->type), true, colId, pSchema->type, toffset, dataLen, kvLen, - compareStat); + tdAppendMemRowColVal(row, getNullValue(pSchema->type), true, colId, pSchema->type, toffset); } else { double dv; if (TK_ILLEGAL == tscToDouble(pToken, &dv, &endptr)) { @@ -837,14 +815,13 @@ static FORCE_INLINE int32_t tsParseOneColumnKV(SSchema *pSchema, SStrToken *pTok } float tmpVal = (float)dv; - tscAppendMemRowColValEx(row, &tmpVal, true, colId, pSchema->type, toffset, dataLen, kvLen, compareStat); + tdAppendMemRowColVal(row, &tmpVal, true, colId, pSchema->type, toffset); } break; case TSDB_DATA_TYPE_DOUBLE: if (isNullStr(pToken)) { - tscAppendMemRowColValEx(row, getNullValue(pSchema->type), true, colId, pSchema->type, toffset, dataLen, kvLen, - compareStat); + tdAppendMemRowColVal(row, getNullValue(pSchema->type), true, colId, pSchema->type, toffset); } else { double dv; if (TK_ILLEGAL == tscToDouble(pToken, &dv, &endptr)) { @@ -855,15 +832,14 @@ static FORCE_INLINE int32_t tsParseOneColumnKV(SSchema *pSchema, SStrToken *pTok return tscInvalidOperationMsg(msg, "illegal double data", pToken->z); } - tscAppendMemRowColValEx(row, &dv, true, colId, pSchema->type, toffset, dataLen, kvLen, compareStat); + tdAppendMemRowColVal(row, &dv, true, colId, pSchema->type, toffset); } break; case TSDB_DATA_TYPE_BINARY: // binary data cannot be null-terminated char string, otherwise the last char of the string is lost if (pToken->type == TK_NULL) { - tscAppendMemRowColValEx(row, getNullValue(pSchema->type), true, colId, pSchema->type, toffset, dataLen, kvLen, - compareStat); + tdAppendMemRowColVal(row, getNullValue(pSchema->type), true, colId, pSchema->type, toffset); } else { // too long values will return invalid sql, not be truncated automatically if (pToken->n + VARSTR_HEADER_SIZE > pSchema->bytes) { // todo refactor return tscInvalidOperationMsg(msg, "string data overflow", pToken->z); @@ -871,14 +847,13 @@ static FORCE_INLINE int32_t tsParseOneColumnKV(SSchema *pSchema, SStrToken *pTok // STR_WITH_SIZE_TO_VARSTR(payload, pToken->z, pToken->n); char *rowEnd = memRowEnd(row); STR_WITH_SIZE_TO_VARSTR(rowEnd, pToken->z, pToken->n); - tscAppendMemRowColValEx(row, rowEnd, false, colId, pSchema->type, toffset, dataLen, kvLen, compareStat); + tdAppendMemRowColVal(row, rowEnd, false, colId, pSchema->type, toffset); } break; case TSDB_DATA_TYPE_NCHAR: if (pToken->type == TK_NULL) { - tscAppendMemRowColValEx(row, getNullValue(pSchema->type), true, colId, pSchema->type, toffset, dataLen, kvLen, - compareStat); + tdAppendMemRowColVal(row, getNullValue(pSchema->type), true, colId, pSchema->type, toffset); } else { // if the converted output len is over than pColumnModel->bytes, return error: 'Argument list too long' int32_t output = 0; @@ -890,7 +865,7 @@ static FORCE_INLINE int32_t tsParseOneColumnKV(SSchema *pSchema, SStrToken *pTok return tscInvalidOperationMsg(msg, buf, pToken->z); } varDataSetLen(rowEnd, output); - tscAppendMemRowColValEx(row, rowEnd, false, colId, pSchema->type, toffset, dataLen, kvLen, compareStat); + tdAppendMemRowColVal(row, rowEnd, false, colId, pSchema->type, toffset); } break; @@ -899,17 +874,16 @@ static FORCE_INLINE int32_t tsParseOneColumnKV(SSchema *pSchema, SStrToken *pTok if (primaryKey) { // When building SKVRow primaryKey, we should not skip even with NULL value. int64_t tmpVal = 0; - tscAppendMemRowColValEx(row, &tmpVal, true, colId, pSchema->type, toffset, dataLen, kvLen, compareStat); + tdAppendMemRowColVal(row, &tmpVal, true, colId, pSchema->type, toffset); } else { - tscAppendMemRowColValEx(row, getNullValue(pSchema->type), true, colId, pSchema->type, toffset, dataLen, kvLen, - compareStat); + tdAppendMemRowColVal(row, getNullValue(pSchema->type), true, colId, pSchema->type, toffset); } } else { int64_t tmpVal; if (tsParseTime(pToken, &tmpVal, str, msg, timePrec) != TSDB_CODE_SUCCESS) { return tscInvalidOperationMsg(msg, "invalid timestamp", pToken->z); } - tscAppendMemRowColValEx(row, &tmpVal, true, colId, pSchema->type, toffset, dataLen, kvLen, compareStat); + tdAppendMemRowColVal(row, &tmpVal, true, colId, pSchema->type, toffset); } break; diff --git a/src/client/src/tscGlobalmerge.c b/src/client/src/tscGlobalmerge.c index e3062f9300aae277e37a7313b5878455f348a93d..5d936fe7067a9ce13a590537c2ba6162cf2a6c83 100644 --- a/src/client/src/tscGlobalmerge.c +++ b/src/client/src/tscGlobalmerge.c @@ -608,6 +608,7 @@ static void doMergeResultImpl(SMultiwayMergeInfo* pInfo, SQLFunctionCtx *pCtx, i SUdfInfo* pUdfInfo = taosArrayGet(pInfo->udfInfo, -1 * functionId - 1); doInvokeUdf(pUdfInfo, &pCtx[j], 0, TSDB_UDF_FUNC_MERGE); } else { + assert(!TSDB_FUNC_IS_SCALAR(functionId)); aAggs[functionId].mergeFunc(&pCtx[j]); } } @@ -624,6 +625,7 @@ static void doFinalizeResultImpl(SMultiwayMergeInfo* pInfo, SQLFunctionCtx *pCtx SUdfInfo* pUdfInfo = taosArrayGet(pInfo->udfInfo, -1 * functionId - 1); doInvokeUdf(pUdfInfo, &pCtx[j], 0, TSDB_UDF_FUNC_FINALIZE); } else { + assert(!TSDB_FUNC_IS_SCALAR(functionId)); aAggs[functionId].xFinalize(&pCtx[j]); } } @@ -663,8 +665,10 @@ static void doExecuteFinalMerge(SOperatorInfo* pOperator, int32_t numOfExpr, SSD if (pCtx[j].functionId < 0) { continue; } - - aAggs[pCtx[j].functionId].init(&pCtx[j], pCtx[j].resultInfo); + { + assert(!TSDB_FUNC_IS_SCALAR(pCtx[j].functionId)); + aAggs[pCtx[j].functionId].init(&pCtx[j], pCtx[j].resultInfo); + } } doMergeResultImpl(pInfo, pCtx, numOfExpr, i, addrPtr); @@ -706,12 +710,12 @@ SGlobalMerger* tscInitResObjForLocalQuery(int32_t numOfRes, int32_t rowLen, uint } // todo remove it -int32_t doArithmeticCalculate(SQueryInfo* pQueryInfo, tFilePage* pOutput, int32_t rowSize, int32_t finalRowSize) { +int32_t doScalarExprCalculate(SQueryInfo* pQueryInfo, tFilePage* pOutput, int32_t rowSize, int32_t finalRowSize) { int32_t maxRowSize = MAX(rowSize, finalRowSize); char* pbuf = calloc(1, (size_t)(pOutput->num * maxRowSize)); size_t size = tscNumOfFields(pQueryInfo); - SArithmeticSupport arithSup = {0}; + SScalarExprSupport arithSup = {0}; // todo refactor arithSup.offset = 0; @@ -732,7 +736,10 @@ int32_t doArithmeticCalculate(SQueryInfo* pQueryInfo, tFilePage* pOutput, int32_ // calculate the result from several other columns if (pSup->pExpr->pExpr != NULL) { arithSup.pExprInfo = pSup->pExpr; - arithmeticTreeTraverse(arithSup.pExprInfo->pExpr, (int32_t) pOutput->num, pbuf + pOutput->num*offset, &arithSup, TSDB_ORDER_ASC, getArithmeticInputSrc); + tExprOperandInfo output; + output.data = pbuf + pOutput->num*offset; + exprTreeNodeTraverse(arithSup.pExprInfo->pExpr, (int32_t)pOutput->num, &output, &arithSup, TSDB_ORDER_ASC, + getScalarExprInputSrc); } else { SExprInfo* pExpr = pSup->pExpr; memcpy(pbuf + pOutput->num * offset, pExpr->base.offset * pOutput->num + pOutput->data, (size_t)(pExpr->base.resBytes * pOutput->num)); @@ -904,8 +911,10 @@ SSDataBlock* doGlobalAggregate(void* param, bool* newgroup) { clearOutputBuf(&pAggInfo->binfo, &pAggInfo->bufCapacity); continue; } - - aAggs[pCtx->functionId].init(pCtx, pCtx->resultInfo); + { + assert(!TSDB_FUNC_IS_SCALAR(pCtx->functionId)); + aAggs[pCtx->functionId].init(pCtx, pCtx->resultInfo); + } } } diff --git a/src/client/src/tscParseInsert.c b/src/client/src/tscParseInsert.c index 3c6c79ad40454a19eb373e7c2f3dce3e773e48db..05b8b031d99c2b0f4e54e9fc3392a20a9e1bcfcc 100644 --- a/src/client/src/tscParseInsert.c +++ b/src/client/src/tscParseInsert.c @@ -41,9 +41,8 @@ enum { static int32_t tscAllocateMemIfNeed(STableDataBlocks *pDataBlock, int32_t rowSize, int32_t *numOfRows); static int32_t parseBoundColumns(SInsertStatementParam *pInsertParam, SParsedDataColInfo *pColInfo, SSchema *pSchema, char *str, char **end); -int initMemRowBuilder(SMemRowBuilder *pBuilder, uint32_t nRows, uint32_t nCols, uint32_t nBoundCols, - int32_t allNullLen) { - ASSERT(nRows >= 0 && nCols > 0 && (nBoundCols <= nCols)); +int initMemRowBuilder(SMemRowBuilder *pBuilder, uint32_t nRows, SParsedDataColInfo *pColInfo) { + ASSERT(nRows >= 0 && pColInfo->numOfCols > 0 && (pColInfo->numOfBound <= pColInfo->numOfCols)); if (nRows > 0) { // already init(bind multiple rows by single column) if (pBuilder->compareStat == ROW_COMPARE_NEED && (pBuilder->rowInfo != NULL)) { @@ -51,41 +50,12 @@ int initMemRowBuilder(SMemRowBuilder *pBuilder, uint32_t nRows, uint3 } } - // default compareStat is ROW_COMPARE_NO_NEED - if (nBoundCols == 0) { // file input - pBuilder->memRowType = SMEM_ROW_DATA; - return TSDB_CODE_SUCCESS; + uint32_t dataLen = TD_MEM_ROW_DATA_HEAD_SIZE + pColInfo->allNullLen; + uint32_t kvLen = TD_MEM_ROW_KV_HEAD_SIZE + pColInfo->numOfBound * sizeof(SColIdx) + pColInfo->boundNullLen; + if (isUtilizeKVRow(kvLen, dataLen)) { + pBuilder->memRowType = SMEM_ROW_KV; } else { - float boundRatio = ((float)nBoundCols / (float)nCols); - - if (boundRatio < KVRatioKV) { - pBuilder->memRowType = SMEM_ROW_KV; - return TSDB_CODE_SUCCESS; - } else if (boundRatio > KVRatioData) { - pBuilder->memRowType = SMEM_ROW_DATA; - return TSDB_CODE_SUCCESS; - } - pBuilder->compareStat = ROW_COMPARE_NEED; - - if (boundRatio < KVRatioPredict) { - pBuilder->memRowType = SMEM_ROW_KV; - } else { - pBuilder->memRowType = SMEM_ROW_DATA; - } - } - - pBuilder->kvRowInitLen = TD_MEM_ROW_KV_HEAD_SIZE + nBoundCols * sizeof(SColIdx); - - if (nRows > 0) { - pBuilder->rowInfo = tcalloc(nRows, sizeof(SMemRowInfo)); - if (pBuilder->rowInfo == NULL) { - return TSDB_CODE_TSC_OUT_OF_MEMORY; - } - - for (int i = 0; i < nRows; ++i) { - (pBuilder->rowInfo + i)->dataLen = TD_MEM_ROW_DATA_HEAD_SIZE + allNullLen; - (pBuilder->rowInfo + i)->kvLen = pBuilder->kvRowInitLen; - } + pBuilder->memRowType = SMEM_ROW_DATA; } return TSDB_CODE_SUCCESS; @@ -468,8 +438,6 @@ int tsParseOneRow(char **str, STableDataBlocks *pDataBlocks, int16_t timePrec, i STableMeta * pTableMeta = pDataBlocks->pTableMeta; SSchema * schema = tscGetTableSchema(pTableMeta); SMemRowBuilder * pBuilder = &pDataBlocks->rowBuilder; - int32_t dataLen = spd->allNullLen + TD_MEM_ROW_DATA_HEAD_SIZE; - int32_t kvLen = pBuilder->kvRowInitLen; bool isParseBindParam = false; initSMemRow(row, pBuilder->memRowType, pDataBlocks, spd->numOfBound); @@ -546,8 +514,8 @@ int tsParseOneRow(char **str, STableDataBlocks *pDataBlocks, int16_t timePrec, i int16_t colId = -1; tscGetMemRowAppendInfo(schema, pBuilder->memRowType, spd, i, &toffset, &colId); - int32_t ret = tsParseOneColumnKV(pSchema, &sToken, row, pInsertParam->msg, str, isPrimaryKey, timePrec, toffset, - colId, &dataLen, &kvLen, pBuilder->compareStat); + int32_t ret = + tsParseOneColumnKV(pSchema, &sToken, row, pInsertParam->msg, str, isPrimaryKey, timePrec, toffset, colId); if (ret != TSDB_CODE_SUCCESS) { return ret; } @@ -562,13 +530,8 @@ int tsParseOneRow(char **str, STableDataBlocks *pDataBlocks, int16_t timePrec, i } if (!isParseBindParam) { - // 2. check and set convert flag - if (pBuilder->compareStat == ROW_COMPARE_NEED) { - checkAndConvertMemRow(row, dataLen, kvLen); - } - - // 3. set the null value for the columns that do not assign values - if ((spd->numOfBound < spd->numOfCols) && isDataRow(row) && !isNeedConvertRow(row)) { + // set the null value for the columns that do not assign values + if ((spd->numOfBound < spd->numOfCols) && isDataRow(row)) { SDataRow dataRow = memRowDataBody(row); for (int32_t i = 0; i < spd->numOfCols; ++i) { if (spd->cols[i].valStat == VAL_STAT_NONE) { @@ -578,7 +541,7 @@ int tsParseOneRow(char **str, STableDataBlocks *pDataBlocks, int16_t timePrec, i } } - *len = getExtendedRowSize(pDataBlocks); + *len = pBuilder->rowSize; return TSDB_CODE_SUCCESS; } @@ -631,11 +594,11 @@ int32_t tsParseValues(char **str, STableDataBlocks *pDataBlock, int maxRows, SIn int32_t extendedRowSize = getExtendedRowSize(pDataBlock); - if (TSDB_CODE_SUCCESS != - (code = initMemRowBuilder(&pDataBlock->rowBuilder, 0, tinfo.numOfColumns, pDataBlock->boundColumnInfo.numOfBound, - pDataBlock->boundColumnInfo.allNullLen))) { + if (TSDB_CODE_SUCCESS != (code = initMemRowBuilder(&pDataBlock->rowBuilder, 0, &pDataBlock->boundColumnInfo))) { return code; } + pDataBlock->rowBuilder.rowSize = extendedRowSize; + while (1) { index = 0; sToken = tStrGetToken(*str, &index, false); @@ -714,6 +677,7 @@ void tscSetBoundColumnInfo(SParsedDataColInfo *pColInfo, SSchema *pSchema, int32 pColInfo->boundedColumns[i] = i; } pColInfo->allNullLen += pColInfo->flen; + pColInfo->boundNullLen = pColInfo->allNullLen; // default set allNullLen pColInfo->extendedVarLen = (uint16_t)(nVar * sizeof(VarDataOffsetT)); } @@ -1254,6 +1218,7 @@ static int32_t parseBoundColumns(SInsertStatementParam *pInsertParam, SParsedDat int32_t nCols = pColInfo->numOfCols; pColInfo->numOfBound = 0; + pColInfo->boundNullLen = 0; memset(pColInfo->boundedColumns, 0, sizeof(int32_t) * nCols); for (int32_t i = 0; i < nCols; ++i) { pColInfo->cols[i].valStat = VAL_STAT_NONE; @@ -1311,6 +1276,17 @@ static int32_t parseBoundColumns(SInsertStatementParam *pInsertParam, SParsedDat pColInfo->cols[t].valStat = VAL_STAT_HAS; pColInfo->boundedColumns[pColInfo->numOfBound] = t; ++pColInfo->numOfBound; + switch (pSchema[t].type) { + case TSDB_DATA_TYPE_BINARY: + pColInfo->boundNullLen += (VARSTR_HEADER_SIZE + CHAR_BYTES); + break; + case TSDB_DATA_TYPE_NCHAR: + pColInfo->boundNullLen += (VARSTR_HEADER_SIZE + TSDB_NCHAR_SIZE); + break; + default: + pColInfo->boundNullLen += TYPE_BYTES[pSchema[t].type]; + break; + } findColumnIndex = true; if (isOrdered && (lastColIdx > t)) { isOrdered = false; @@ -1334,6 +1310,17 @@ static int32_t parseBoundColumns(SInsertStatementParam *pInsertParam, SParsedDat pColInfo->cols[t].valStat = VAL_STAT_HAS; pColInfo->boundedColumns[pColInfo->numOfBound] = t; ++pColInfo->numOfBound; + switch (pSchema[t].type) { + case TSDB_DATA_TYPE_BINARY: + pColInfo->boundNullLen += (VARSTR_HEADER_SIZE + CHAR_BYTES); + break; + case TSDB_DATA_TYPE_NCHAR: + pColInfo->boundNullLen += (VARSTR_HEADER_SIZE + TSDB_NCHAR_SIZE); + break; + default: + pColInfo->boundNullLen += TYPE_BYTES[pSchema[t].type]; + break; + } findColumnIndex = true; if (isOrdered && (lastColIdx > t)) { isOrdered = false; @@ -1784,13 +1771,18 @@ static void parseFileSendDataBlock(void *param, TAOS_RES *tres, int32_t numOfRow goto _error; } - tscAllocateMemIfNeed(pTableDataBlock, getExtendedRowSize(pTableDataBlock), &maxRows); + int32_t extendedRowSize = getExtendedRowSize(pTableDataBlock); + tscAllocateMemIfNeed(pTableDataBlock, extendedRowSize, &maxRows); tokenBuf = calloc(1, TSDB_MAX_BYTES_PER_ROW); if (tokenBuf == NULL) { code = TSDB_CODE_TSC_OUT_OF_MEMORY; goto _error; } + // insert from .csv means full and ordered columns, thus use SDataRow all the time + ASSERT(SMEM_ROW_DATA == pTableDataBlock->rowBuilder.memRowType); + pTableDataBlock->rowBuilder.rowSize = extendedRowSize; + while ((readLen = tgetline(&line, &n, fp)) != -1) { if (('\r' == line[readLen - 1]) || ('\n' == line[readLen - 1])) { line[--readLen] = 0; diff --git a/src/client/src/tscParseLineProtocol.c b/src/client/src/tscParseLineProtocol.c index 98d6ff8e4d6fe3cc4c08691ab027622b7410e32d..085b949cc102e3752abd41caacdf07985351e1db 100644 --- a/src/client/src/tscParseLineProtocol.c +++ b/src/client/src/tscParseLineProtocol.c @@ -702,6 +702,7 @@ static int32_t modifyDBSchemas(TAOS* taos, SArray* stableSchemas, SSmlLinesInfo* if (code == TSDB_CODE_SUCCESS) { pointSchema->precision = dbSchema.precision; + size_t pointTagSize = taosArrayGetSize(pointSchema->tags); size_t pointFieldSize = taosArrayGetSize(pointSchema->fields); diff --git a/src/client/src/tscSQLParser.c b/src/client/src/tscSQLParser.c index a775f3982a64a63c1f9b1b4f1f84aad591ae6fa6..2f800339b792191685057a7e54077677156bbe01 100644 --- a/src/client/src/tscSQLParser.c +++ b/src/client/src/tscSQLParser.c @@ -109,7 +109,8 @@ static int32_t tsRewriteFieldNameIfNecessary(SSqlCmd* pCmd, SQueryInfo* pQueryIn static int32_t setAlterTableInfo(SSqlObj* pSql, struct SSqlInfo* pInfo); static int32_t validateSqlFunctionInStreamSql(SSqlCmd* pCmd, SQueryInfo* pQueryInfo); static int32_t validateFunctionsInIntervalOrGroupbyQuery(SSqlCmd* pCmd, SQueryInfo* pQueryInfo); -static int32_t validateArithmeticSQLExpr(SSqlCmd* pCmd, tSqlExpr* pExpr, SQueryInfo* pQueryInfo, SColumnList* pList, int32_t* type); +static int32_t validateSQLExprItem(SSqlCmd* pCmd, tSqlExpr* pExpr, + SQueryInfo* pQueryInfo, SColumnList* pList, int32_t* type, uint64_t* uid, int32_t* height); static int32_t validateEp(char* ep); static int32_t validateDNodeConfig(SMiscInfo* pOptions); static int32_t validateLocalConfig(SMiscInfo* pOptions); @@ -1810,123 +1811,149 @@ void tscInsertPrimaryTsSourceColumn(SQueryInfo* pQueryInfo, uint64_t tableUid) { tscColumnListInsert(pQueryInfo->colList, PRIMARYKEY_TIMESTAMP_COL_INDEX, tableUid, &s); } -static int32_t handleArithmeticExpr(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, int32_t exprIndex, tSqlExprItem* pItem) { - const char* msg1 = "invalid column name, illegal column type, or columns in arithmetic expression from two tables"; +static int32_t handleScalarTypeExpr(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, int32_t exprIndex, tSqlExprItem* pItem, + SColumnList* columnList, bool finalResult) { const char* msg2 = "invalid arithmetic expression in select clause"; const char* msg3 = "tag columns can not be used in arithmetic expression"; const char* msg4 = "columns from different table mixed up in arithmetic expression"; - SColumnList columnList = {0}; - int32_t arithmeticType = NON_ARITHMEIC_EXPR; + int32_t tableIndex = columnList->ids[0].tableIndex; + pQueryInfo->type |= TSDB_QUERY_TYPE_PROJECTION_QUERY; - if (validateArithmeticSQLExpr(pCmd, pItem->pNode, pQueryInfo, &columnList, &arithmeticType) != TSDB_CODE_SUCCESS) { - return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg1); + // all columns in scalar expression must belong to the same table + for (int32_t f = 1; f < columnList->num; ++f) { + if (columnList->ids[f].tableIndex != tableIndex) { + return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg4); + } } - int32_t tableIndex = columnList.ids[0].tableIndex; - if (arithmeticType == NORMAL_ARITHMETIC) { - pQueryInfo->type |= TSDB_QUERY_TYPE_PROJECTION_QUERY; + // expr string is set as the parameter of function + SColumnIndex index = {.tableIndex = tableIndex}; - // all columns in arithmetic expression must belong to the same table - for (int32_t f = 1; f < columnList.num; ++f) { - if (columnList.ids[f].tableIndex != tableIndex) { - return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg4); - } - } + tExprNode* pNode = NULL; + SArray* colList = taosArrayInit(10, sizeof(SColIndex)); - // expr string is set as the parameter of function - SColumnIndex index = {.tableIndex = tableIndex}; + int32_t ret = exprTreeFromSqlExpr(pCmd, &pNode, pItem->pNode, pQueryInfo, colList, NULL); + if (ret != TSDB_CODE_SUCCESS) { + taosArrayDestroy(colList); + tExprTreeDestroy(pNode, NULL); + if (tscGetErrorMsgLength(pCmd) > 0) { + return ret; + } + + return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg2); + } - SExprInfo* pExpr = tscExprAppend(pQueryInfo, TSDB_FUNC_ARITHM, &index, TSDB_DATA_TYPE_DOUBLE, sizeof(double), - getNewResColId(pCmd), sizeof(double), false); + // check for if there is a tag in the scalar expression + size_t numOfNode = taosArrayGetSize(colList); + for(int32_t k = 0; k < numOfNode; ++k) { + SColIndex* pIndex = taosArrayGet(colList, k); + if (TSDB_COL_IS_TAG(pIndex->flag)) { + tExprTreeDestroy(pNode, NULL); + taosArrayDestroy(colList); + + return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg3); + } + } - char* name = (pItem->aliasName != NULL)? pItem->aliasName:pItem->pNode->exprToken.z; - size_t len = MIN(sizeof(pExpr->base.aliasName), pItem->pNode->exprToken.n + 1); - tstrncpy(pExpr->base.aliasName, name, len); + ret = exprTreeValidateTree(tscGetErrorMsgPayload(pCmd), pNode); + if (ret != TSDB_CODE_SUCCESS) { + taosArrayDestroy(colList); + tExprTreeDestroy(pNode, NULL); + if (tscGetErrorMsgLength(pCmd) > 0) { + return ret; + } + + return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg2); + } - tExprNode* pNode = NULL; - SArray* colList = taosArrayInit(10, sizeof(SColIndex)); - int32_t ret = exprTreeFromSqlExpr(pCmd, &pNode, pItem->pNode, pQueryInfo, colList, NULL); - if (ret != TSDB_CODE_SUCCESS) { - taosArrayDestroy(colList); - tExprTreeDestroy(pNode, NULL); - return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg2); - } + SExprInfo* pExpr = tscExprAppend(pQueryInfo, TSDB_FUNC_SCALAR_EXPR, &index, pNode->resultType, pNode->resultBytes, + getNewResColId(pCmd), 0, false); - // check for if there is a tag in the arithmetic express - size_t numOfNode = taosArrayGetSize(colList); - for(int32_t k = 0; k < numOfNode; ++k) { - SColIndex* pIndex = taosArrayGet(colList, k); - if (TSDB_COL_IS_TAG(pIndex->flag)) { - tExprTreeDestroy(pNode, NULL); - taosArrayDestroy(colList); + char* name = (pItem->aliasName != NULL)? pItem->aliasName:pItem->pNode->exprToken.z; + size_t len = MIN(sizeof(pExpr->base.aliasName), pItem->pNode->exprToken.n + 1); + tstrncpy(pExpr->base.aliasName, name, len); - return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg3); - } - } + SBufferWriter bw = tbufInitWriter(NULL, false); - SBufferWriter bw = tbufInitWriter(NULL, false); + TRY(0) { + exprTreeToBinary(&bw, pNode); + } CATCH(code) { + tbufCloseWriter(&bw); + UNUSED(code); + // TODO: other error handling + } END_TRY - TRY(0) { - exprTreeToBinary(&bw, pNode); - } CATCH(code) { - tbufCloseWriter(&bw); - UNUSED(code); - // TODO: other error handling - } END_TRY + len = tbufTell(&bw); + char* c = tbufGetData(&bw, false); - len = tbufTell(&bw); - char* c = tbufGetData(&bw, false); + // set the serialized binary string as the parameter of arithmetic expression + tscExprAddParams(&pExpr->base, c, TSDB_DATA_TYPE_BINARY, (int32_t)len); + if (finalResult) { + insertResultField(pQueryInfo, exprIndex, columnList, pExpr->base.resBytes, (int8_t)pExpr->base.resType, pExpr->base.aliasName, + pExpr); + } - // set the serialized binary string as the parameter of arithmetic expression - tscExprAddParams(&pExpr->base, c, TSDB_DATA_TYPE_BINARY, (int32_t)len); - insertResultField(pQueryInfo, exprIndex, &columnList, sizeof(double), TSDB_DATA_TYPE_DOUBLE, pExpr->base.aliasName, pExpr); + // add ts column + tscInsertPrimaryTsSourceColumn(pQueryInfo, pExpr->base.uid); - // add ts column - tscInsertPrimaryTsSourceColumn(pQueryInfo, pExpr->base.uid); + tbufCloseWriter(&bw); + taosArrayDestroy(colList); + tExprTreeDestroy(pNode, NULL); - tbufCloseWriter(&bw); - taosArrayDestroy(colList); - tExprTreeDestroy(pNode, NULL); - } else { - columnList.num = 0; - columnList.ids[0] = (SColumnIndex) {0, 0}; + return TSDB_CODE_SUCCESS; +} - char rawName[TSDB_COL_NAME_LEN] = {0}; - char aliasName[TSDB_COL_NAME_LEN] = {0}; - getColumnName(pItem, aliasName, rawName, TSDB_COL_NAME_LEN); +static int32_t handleAggTypeExpr(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, int32_t exprIndex, tSqlExprItem* pItem, + SColumnList* columnList, bool finalResult) { + const char* msg2 = "invalid arithmetic expression in select clause"; - insertResultField(pQueryInfo, exprIndex, &columnList, sizeof(double), TSDB_DATA_TYPE_DOUBLE, aliasName, NULL); + columnList->num = 0; + columnList->ids[0] = (SColumnIndex) {0, 0}; - int32_t slot = tscNumOfFields(pQueryInfo) - 1; - SInternalField* pInfo = tscFieldInfoGetInternalField(&pQueryInfo->fieldsInfo, slot); - assert(pInfo->pExpr == NULL); + char rawName[TSDB_COL_NAME_LEN] = {0}; + char aliasName[TSDB_COL_NAME_LEN] = {0}; + getColumnName(pItem, aliasName, rawName, TSDB_COL_NAME_LEN); - SExprInfo* pExprInfo = calloc(1, sizeof(SExprInfo)); + tExprNode *pExpr = NULL; + uint64_t uid = 0; + int32_t ret = exprTreeFromSqlExpr(pCmd, &pExpr, pItem->pNode, pQueryInfo, NULL, &uid); + if (ret != TSDB_CODE_SUCCESS) { + tExprTreeDestroy(pExpr, NULL); + return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), "invalid expression in select clause"); + } - // arithmetic expression always return result in the format of double float - pExprInfo->base.resBytes = sizeof(double); - pExprInfo->base.interBytes = 0; - pExprInfo->base.resType = TSDB_DATA_TYPE_DOUBLE; + ret = exprTreeValidateTree(tscGetErrorMsgPayload(pCmd), pExpr); + if (ret != TSDB_CODE_SUCCESS) { + tExprTreeDestroy(pExpr, NULL); + return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg2); + } + // the expr associated with the result field will become exprList1 in SQueryInfo, then pExpr2 in SQueryAttr + insertResultField(pQueryInfo, exprIndex, columnList, pExpr->resultBytes, (int8_t)pExpr->resultType, aliasName, NULL); - pExprInfo->base.functionId = TSDB_FUNC_ARITHM; - pExprInfo->base.numOfParams = 1; - pExprInfo->base.resColId = getNewResColId(pCmd); - strncpy(pExprInfo->base.aliasName, aliasName, tListLen(pExprInfo->base.aliasName)); - strncpy(pExprInfo->base.token, rawName, tListLen(pExprInfo->base.token)); + int32_t slot = tscNumOfFields(pQueryInfo) - 1; + SInternalField* pInfo = tscFieldInfoGetInternalField(&pQueryInfo->fieldsInfo, slot); + assert(pInfo->pExpr == NULL); + SExprInfo* pExprInfo = calloc(1, sizeof(SExprInfo)); + // arithmetic expression always return result in the format of double float + pExprInfo->base.resBytes = pExpr->resultBytes; + pExprInfo->base.interBytes = 0; + pExprInfo->base.resType = pExpr->resultType; - int32_t ret = exprTreeFromSqlExpr(pCmd, &pExprInfo->pExpr, pItem->pNode, pQueryInfo, NULL, &(pExprInfo->base.uid)); - if (ret != TSDB_CODE_SUCCESS) { - tExprTreeDestroy(pExprInfo->pExpr, NULL); - return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), "invalid expression in select clause"); - } + pExprInfo->base.functionId = TSDB_FUNC_SCALAR_EXPR; + pExprInfo->base.numOfParams = 1; + pExprInfo->base.resColId = getNewResColId(pCmd); + strncpy(pExprInfo->base.aliasName, aliasName, tListLen(pExprInfo->base.aliasName)); + strncpy(pExprInfo->base.token, rawName, tListLen(pExprInfo->base.token)); - pInfo->pExpr = pExprInfo; + pExprInfo->pExpr = pExpr; + pExprInfo->base.uid = uid; + pInfo->pExpr = pExprInfo; - SBufferWriter bw = tbufInitWriter(NULL, false); + SBufferWriter bw = tbufInitWriter(NULL, false); - TRY(0) { + TRY(0) { exprTreeToBinary(&bw, pInfo->pExpr->pExpr); } CATCH(code) { tbufCloseWriter(&bw); @@ -1934,15 +1961,38 @@ static int32_t handleArithmeticExpr(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, int32 // TODO: other error handling } END_TRY - SSqlExpr* pSqlExpr = &pInfo->pExpr->base; - pSqlExpr->param[0].nLen = (int16_t) tbufTell(&bw); - pSqlExpr->param[0].pz = tbufGetData(&bw, true); - pSqlExpr->param[0].nType = TSDB_DATA_TYPE_BINARY; + SSqlExpr* pSqlExpr = &pInfo->pExpr->base; + pSqlExpr->param[0].nLen = (int16_t) tbufTell(&bw); + pSqlExpr->param[0].pz = tbufGetData(&bw, true); + pSqlExpr->param[0].nType = TSDB_DATA_TYPE_BINARY; // tbufCloseWriter(&bw); // TODO there is a memory leak + return TSDB_CODE_SUCCESS; +} + +static int32_t handleSQLExprItem(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, int32_t exprIndex, tSqlExprItem* pItem) { + SColumnList columnList = {0}; + int32_t sqlExprType = SQLEXPR_TYPE_UNASSIGNED; + + uint64_t uid; + int32_t height = 0; + int32_t code = validateSQLExprItem(pCmd, pItem->pNode, pQueryInfo, &columnList, &sqlExprType, &uid, &height); + + if (code != TSDB_CODE_SUCCESS) { + return code; } - return TSDB_CODE_SUCCESS; + if (height > 16) { + return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), "the max expression nested levels must be equal or less than 16"); + } + + if (sqlExprType == SQLEXPR_TYPE_SCALAR) { + code = handleScalarTypeExpr(pCmd, pQueryInfo, exprIndex, pItem, &columnList, true); + } else { + code = handleAggTypeExpr(pCmd, pQueryInfo, exprIndex, pItem, &columnList, true); + } + + return code; } static void addProjectQueryCol(SQueryInfo* pQueryInfo, int32_t startPos, SColumnIndex* pIndex, tSqlExprItem* pItem, int32_t colId) { @@ -1999,7 +2049,7 @@ static void addPrimaryTsColIntoResult(SQueryInfo* pQueryInfo, SSqlCmd* pCmd) { // add the timestamp column into the output columns SColumnIndex index = {0}; // primary timestamp column info - int32_t numOfCols = (int32_t)tscNumOfExprs(pQueryInfo); + int32_t numOfCols = (int32_t)tscNumOfFields(pQueryInfo); tscAddFuncInSelectClause(pQueryInfo, numOfCols, TSDB_FUNC_PRJ, &index, pSchema, TSDB_COL_NORMAL, getNewResColId(pCmd)); SInternalField* pSupInfo = tscFieldInfoGetInternalField(&pQueryInfo->fieldsInfo, numOfCols); @@ -2090,6 +2140,16 @@ static SUdfInfo* isValidUdf(SArray* pUdfInfo, const char* name, int32_t len) { return NULL; } +static bool willProcessFunctionWithExpr(const tSqlExprItem* pItem) { + assert(pItem->pNode->type == SQL_NODE_SQLFUNCTION); + int32_t functionId = pItem->pNode->functionId; + + if (TSDB_FUNC_IS_SCALAR(functionId)) { + return true; + } + return false; +} + int32_t validateSelectNodeList(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SArray* pSelNodeList, bool joinQuery, bool timeWindowQuery, bool outerQuery) { assert(pSelNodeList != NULL && pCmd != NULL); @@ -2136,7 +2196,12 @@ int32_t validateSelectNodeList(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SArray* pS } int32_t type = pItem->pNode->type; - if (type == SQL_NODE_SQLFUNCTION) { + if (type == SQL_NODE_EXPR && pItem->pNode->tokenId != TK_ARROW) { + int32_t code = handleSQLExprItem(pCmd, pQueryInfo, i, pItem); + if (code != TSDB_CODE_SUCCESS) { + return code; + } + } else if (type == SQL_NODE_SQLFUNCTION) { hasAgg = true; if (hasDistinct) break; @@ -2160,22 +2225,25 @@ int32_t validateSelectNodeList(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SArray* pS pItem->pNode->functionId = pUdfInfo->functionId; } - // sql function in selection clause, append sql function info in pSqlCmd structure sequentially - if (addExprAndResultField(pCmd, pQueryInfo, outputIndex, pItem, true, pUdfInfo) != TSDB_CODE_SUCCESS) { - return TSDB_CODE_TSC_INVALID_OPERATION; + if (willProcessFunctionWithExpr(pItem)) { + int32_t code = handleSQLExprItem(pCmd, pQueryInfo, i, pItem); + if (code != TSDB_CODE_SUCCESS) { + return code; + } + } else { + // sql function in selection clause, append sql function info in pSqlCmd structure sequentially + if (addExprAndResultField(pCmd, pQueryInfo, outputIndex, pItem, true, pUdfInfo) != TSDB_CODE_SUCCESS) { + return TSDB_CODE_TSC_INVALID_OPERATION; + } } - } else if (type == SQL_NODE_TABLE_COLUMN || type == SQL_NODE_VALUE) { + } else if (type == SQL_NODE_TABLE_COLUMN || type == SQL_NODE_VALUE || + (type == SQL_NODE_EXPR && pItem->pNode->tokenId == TK_ARROW)) { // use the dynamic array list to decide if the function is valid or not // select table_name1.field_name1, table_name2.field_name2 from table_name1, table_name2 if (addProjectionExprAndResultField(pCmd, pQueryInfo, pItem, outerQuery) != TSDB_CODE_SUCCESS) { return TSDB_CODE_TSC_INVALID_OPERATION; } - } else if (type == SQL_NODE_EXPR) { - int32_t code = handleArithmeticExpr(pCmd, pQueryInfo, i, pItem); - if (code != TSDB_CODE_SUCCESS) { - return code; - } - } else { + } else { return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg3); } @@ -2519,11 +2587,20 @@ void setResultColName(char* name, tSqlExprItem* pItem, int32_t functionId, SStrT if (tsKeepOriginalColumnName) { // keep the original column name tstrncpy(name, uname, TSDB_COL_NAME_LEN); } else { - int32_t size = TSDB_COL_NAME_LEN + tListLen(aAggs[functionId].name) + 2 + 1; - char tmp[TSDB_COL_NAME_LEN + tListLen(aAggs[functionId].name) + 2 + 1] = {0}; - snprintf(tmp, size, "%s(%s)", aAggs[functionId].name, uname); + if (!TSDB_FUNC_IS_SCALAR(functionId)) { + int32_t size = TSDB_COL_NAME_LEN + tListLen(aAggs[functionId].name) + 2 + 1; + char tmp[TSDB_COL_NAME_LEN + tListLen(aAggs[functionId].name) + 2 + 1] = {0}; + snprintf(tmp, size, "%s(%s)", aAggs[functionId].name, uname); + + tstrncpy(name, tmp, TSDB_COL_NAME_LEN); + } else { + int32_t index = TSDB_FUNC_SCALAR_INDEX(functionId); + int32_t size = TSDB_COL_NAME_LEN + tListLen(aScalarFunctions[index].name) + 2 + 1; + char tmp[TSDB_COL_NAME_LEN + tListLen(aScalarFunctions[index].name) + 2 + 1] = {0}; + snprintf(tmp, size, "%s(%s)", aScalarFunctions[index].name, uname); - tstrncpy(name, tmp, TSDB_COL_NAME_LEN); + tstrncpy(name, tmp, TSDB_COL_NAME_LEN); + } } } else { // use the user-input result column name int32_t len = MIN(pItem->pNode->exprToken.n + 1, TSDB_COL_NAME_LEN); @@ -2672,9 +2749,6 @@ int32_t addExprAndResultField(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, int32_t col case TSDB_FUNC_DIFF: case TSDB_FUNC_DERIVATIVE: case TSDB_FUNC_CSUM: - case TSDB_FUNC_CEIL: - case TSDB_FUNC_FLOOR: - case TSDB_FUNC_ROUND: case TSDB_FUNC_STDDEV: case TSDB_FUNC_LEASTSQR: case TSDB_FUNC_ELAPSED: { @@ -3214,6 +3288,7 @@ int32_t addExprAndResultField(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, int32_t col return TSDB_CODE_SUCCESS; } default: { + assert(!TSDB_FUNC_IS_SCALAR(functionId)); pUdfInfo = isValidUdf(pQueryInfo->pUdfInfo, pItem->pNode->Expr.operand.z, pItem->pNode->Expr.operand.n); if (pUdfInfo == NULL) { return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg9); @@ -3577,7 +3652,11 @@ int32_t tscTansformFuncForSTableQuery(SQueryInfo* pQueryInfo) { size_t size = tscNumOfExprs(pQueryInfo); for (int32_t k = 0; k < size; ++k) { SExprInfo* pExpr = tscExprGet(pQueryInfo, k); - int16_t functionId = aAggs[pExpr->base.functionId].stableFuncId; + + int16_t functionId = pExpr->base.functionId; + if (!TSDB_FUNC_IS_SCALAR(functionId)) { + functionId = aAggs[pExpr->base.functionId].stableFuncId; + } int32_t colIndex = pExpr->base.colInfo.colIndex; SSchema* pSrcSchema = tscGetTableColumnSchema(pTableMetaInfo->pTableMeta, colIndex); @@ -3652,6 +3731,10 @@ bool hasUnsupportFunctionsForSTableQuery(SSqlCmd* pCmd, SQueryInfo* pQueryInfo) continue; } + if (TSDB_FUNC_IS_SCALAR(functionId)) { + continue; + } + if ((aAggs[functionId].status & TSDB_FUNCSTATE_STABLE) == 0) { invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg3); return true; @@ -3727,7 +3810,8 @@ static bool functionCompatibleCheck(SQueryInfo* pQueryInfo, bool joinQuery, bool int32_t scalarUdf = 0; int32_t prjNum = 0; int32_t aggNum = 0; - int32_t scalNum = 0; + int32_t scalarFuncNum = 0; + int32_t funcCompatFactor = INT_MAX; int32_t countTbname = 0; size_t numOfExpr = tscNumOfExprs(pQueryInfo); @@ -3760,18 +3844,28 @@ static bool functionCompatibleCheck(SQueryInfo* pQueryInfo, bool joinQuery, bool ++prjNum; } - if (functionId == TSDB_FUNC_CEIL || functionId == TSDB_FUNC_FLOOR || functionId == TSDB_FUNC_ROUND) { - ++scalNum; + if (TSDB_FUNC_IS_SCALAR(functionId)) { + ++scalarFuncNum; + } + + if (functionId == TSDB_FUNC_SCALAR_EXPR) { + ++scalarFuncNum; } if (functionId == TSDB_FUNC_PRJ && (pExpr1->base.colInfo.colId == PRIMARYKEY_TIMESTAMP_COL_INDEX || TSDB_COL_IS_UD_COL(pExpr1->base.colInfo.flag))) { continue; } + if (TSDB_FUNC_IS_SCALAR(functionId)) { + funcCompatFactor = 1; + } else { + funcCompatFactor = functionCompatList[functionId]; + } + if (factor == INT32_MAX) { - factor = functionCompatList[functionId]; + factor = funcCompatFactor; } else { - if (functionCompatList[functionId] != factor) { + if (funcCompatFactor != factor) { return false; } else { if (factor == -1) { // two functions with the same -1 flag @@ -3789,19 +3883,19 @@ static bool functionCompatibleCheck(SQueryInfo* pQueryInfo, bool joinQuery, bool } } - aggNum = (int32_t)size - prjNum - scalNum - aggUdf - scalarUdf - countTbname; + aggNum = (int32_t)size - prjNum - scalarFuncNum - aggUdf - scalarUdf - countTbname; assert(aggNum >= 0); - if (aggUdf > 0 && (prjNum > 0 || aggNum > 0 || scalNum > 0 || scalarUdf > 0)) { + if (aggUdf > 0 && (prjNum > 0 || aggNum > 0 || scalarFuncNum > 0 || scalarUdf > 0)) { return false; } - if (scalarUdf > 0 && (aggNum > 0 || scalNum > 0)) { + if (scalarUdf > 0 && (aggNum > 0 || scalarFuncNum > 0)) { return false; } - if (aggNum > 0 && scalNum > 0) { + if (aggNum > 0 && scalarFuncNum > 0) { return false; } @@ -4393,48 +4487,80 @@ static int32_t getJoinCondInfo(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, tSqlExpr* return checkAndSetJoinCondInfo(pCmd, pQueryInfo, pExpr); } -static int32_t validateSQLExpr(SSqlCmd* pCmd, tSqlExpr* pExpr, SQueryInfo* pQueryInfo, SColumnList* pList, - int32_t* type, uint64_t* uid) { - if (pExpr->type == SQL_NODE_TABLE_COLUMN) { - if (*type == NON_ARITHMEIC_EXPR) { - *type = NORMAL_ARITHMETIC; - } else if (*type == AGG_ARIGHTMEIC) { - return TSDB_CODE_TSC_INVALID_OPERATION; - } +static int32_t validateSQLExprItemSQLFunc(SSqlCmd* pCmd, tSqlExpr* pExpr, + SQueryInfo* pQueryInfo, SColumnList* pList, int32_t* type, uint64_t *uid, int32_t* height) { + int32_t code = TSDB_CODE_SUCCESS; + const char* msg1 = "invalid function parameters"; + const char* msg2 = "not supported functions in arithmetic expression"; + + int32_t functionId = isValidFunction(pExpr->Expr.operand.z, pExpr->Expr.operand.n); + + pExpr->functionId = functionId; + if (pExpr->Expr.paramList != NULL) { + size_t numChildren = taosArrayGetSize(pExpr->Expr.paramList); + int32_t* childrenTypes = calloc(numChildren, sizeof(int32_t)); + int32_t* childrenHeight = calloc(numChildren, sizeof(int32_t)); + for (int32_t i = 0; i < numChildren; ++i) { + tSqlExprItem* pParamElem = taosArrayGet(pExpr->Expr.paramList, i); + if (TSDB_FUNC_IS_SCALAR(functionId)) { + code = validateSQLExprItem(pCmd, pParamElem->pNode, pQueryInfo, pList, childrenTypes + i, uid, childrenHeight+i); + if (code != TSDB_CODE_SUCCESS) { + free(childrenTypes); + return code; + } + } - if (pExpr->tokenId == TK_ARROW) {pExpr = pExpr->pLeft;} - SColumnIndex index = COLUMN_INDEX_INITIALIZER; - if (getColumnIndexByName(&pExpr->columnName, pQueryInfo, &index, tscGetErrorMsgPayload(pCmd)) != TSDB_CODE_SUCCESS) { - return TSDB_CODE_TSC_INVALID_OPERATION; - } + if (!TSDB_FUNC_IS_SCALAR(functionId) && + (pParamElem->pNode->type == SQL_NODE_EXPR || pParamElem->pNode->type == SQL_NODE_SQLFUNCTION)) { + return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg1); + } - // if column is timestamp, bool, binary, nchar, not support arithmetic, so return invalid sql - STableMeta* pTableMeta = tscGetMetaInfo(pQueryInfo, index.tableIndex)->pTableMeta; - SSchema* pSchema = tscGetTableSchema(pTableMeta) + index.columnIndex; - - if ((pSchema->type == TSDB_DATA_TYPE_TIMESTAMP) || (pSchema->type == TSDB_DATA_TYPE_BOOL) || - (pSchema->type == TSDB_DATA_TYPE_BINARY) || (pSchema->type == TSDB_DATA_TYPE_NCHAR)) { - return TSDB_CODE_TSC_INVALID_OPERATION; } + { + if (TSDB_FUNC_IS_SCALAR(functionId)) { + bool anyChildScalar = false; + bool anyChildAgg = false; + int32_t maxChildrenHeight = 0; + for (int i = 0; i < numChildren; ++i) { + assert (childrenTypes[i] != SQLEXPR_TYPE_UNASSIGNED); + anyChildScalar = anyChildScalar || (childrenTypes[i] == SQLEXPR_TYPE_SCALAR); + anyChildAgg = anyChildAgg || (childrenTypes[i] == SQLEXPR_TYPE_AGG); + if (childrenHeight[i] > maxChildrenHeight) { + maxChildrenHeight = childrenHeight[i]; + } + } - pList->ids[pList->num++] = index; - } else if ((pExpr->tokenId == TK_FLOAT && (isnan(pExpr->value.dKey) || isinf(pExpr->value.dKey))) || - pExpr->tokenId == TK_NULL) { - return TSDB_CODE_TSC_INVALID_OPERATION; - } else if (pExpr->type == SQL_NODE_SQLFUNCTION) { - if (*type == NON_ARITHMEIC_EXPR) { - *type = AGG_ARIGHTMEIC; - } else if (*type == NORMAL_ARITHMETIC) { - return TSDB_CODE_TSC_INVALID_OPERATION; + *height = maxChildrenHeight + 1; + + if (anyChildAgg && anyChildScalar) { + return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg1); + } + if (anyChildAgg) { + *type = SQLEXPR_TYPE_AGG; + } else { + *type = SQLEXPR_TYPE_SCALAR; + } + } else { + *type = SQLEXPR_TYPE_AGG; + } } + free(childrenTypes); + //end if param list is not null + } else { + if (TSDB_FUNC_IS_SCALAR(functionId)) { + *type = SQLEXPR_TYPE_SCALAR; + } else { + *type = SQLEXPR_TYPE_AGG; + } + } // else param list is null + if (!TSDB_FUNC_IS_SCALAR(functionId)) { int32_t outputIndex = (int32_t)tscNumOfExprs(pQueryInfo); - + tSqlExprItem item = {.pNode = pExpr, .aliasName = NULL}; - + // sql function list in selection clause. // Append the sqlExpr into exprList of pQueryInfo structure sequentially - pExpr->functionId = isValidFunction(pExpr->Expr.operand.z, pExpr->Expr.operand.n); if (pExpr->functionId < 0) { SUdfInfo* pUdfInfo = NULL; pUdfInfo = isValidUdf(pQueryInfo->pUdfInfo, pExpr->Expr.operand.z, pExpr->Expr.operand.n); @@ -4443,23 +4569,25 @@ static int32_t validateSQLExpr(SSqlCmd* pCmd, tSqlExpr* pExpr, SQueryInfo* pQuer } } + // add the aggregate function to SQueryInfo exprList, which is pExpr1/global aggregate pExpr3 in SQueryAttr if (addExprAndResultField(pCmd, pQueryInfo, outputIndex, &item, false, NULL) != TSDB_CODE_SUCCESS) { return TSDB_CODE_TSC_INVALID_OPERATION; } // It is invalid in case of more than one sqlExpr, such as first(ts, k) - last(ts, k) - int32_t inc = (int32_t) tscNumOfExprs(pQueryInfo) - outputIndex; + int32_t inc = (int32_t)tscNumOfExprs(pQueryInfo) - outputIndex; if (inc > 1) { - return TSDB_CODE_TSC_INVALID_OPERATION; + return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg2); } // Not supported data type in arithmetic expression uint64_t id = -1; - for(int32_t i = 0; i < inc; ++i) { + for (int32_t i = 0; i < inc; ++i) { SExprInfo* p1 = tscExprGet(pQueryInfo, i + outputIndex); int16_t t = p1->base.resType; - if (t == TSDB_DATA_TYPE_BINARY || t == TSDB_DATA_TYPE_NCHAR || t == TSDB_DATA_TYPE_BOOL || t == TSDB_DATA_TYPE_TIMESTAMP) { + if (t == TSDB_DATA_TYPE_BINARY || t == TSDB_DATA_TYPE_NCHAR || t == TSDB_DATA_TYPE_BOOL || + t == TSDB_DATA_TYPE_TIMESTAMP) { return TSDB_CODE_TSC_INVALID_OPERATION; } @@ -4475,49 +4603,101 @@ static int32_t validateSQLExpr(SSqlCmd* pCmd, tSqlExpr* pExpr, SQueryInfo* pQuer *uid = id; } + return TSDB_CODE_SUCCESS; +} + +static int32_t validateSQLExprItemArithmeticExpr(SSqlCmd* pCmd, tSqlExpr* pExpr, SQueryInfo* pQueryInfo, SColumnList* pList, + int32_t* type, uint64_t* uid, int32_t* height) { + uint64_t uidLeft = 0; + uint64_t uidRight = 0; + int32_t leftType = SQLEXPR_TYPE_UNASSIGNED; + int32_t rightType = SQLEXPR_TYPE_UNASSIGNED; + const char* msg1 = "arithmetic expression composed with columns from different tables"; + const char* msg2 = "arithmetic expression composed with functions/columns of different types"; + int32_t leftHeight = 0; + int32_t ret = validateSQLExprItem(pCmd, pExpr->pLeft, pQueryInfo, pList, &leftType, &uidLeft, &leftHeight); + if (ret != TSDB_CODE_SUCCESS) { + return ret; + } + int32_t rightHeight = 0; + ret = validateSQLExprItem(pCmd, pExpr->pRight, pQueryInfo, pList, &rightType, &uidRight, &rightHeight); + if (ret != TSDB_CODE_SUCCESS) { + return ret; + } + + if (uidLeft != uidRight && uidLeft != 0 && uidRight != 0) { + return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg1); + } + *uid = uidLeft; + + *height = (leftHeight > rightHeight) ? leftHeight + 1 : rightHeight+1; + { + assert(leftType != SQLEXPR_TYPE_UNASSIGNED && rightType != SQLEXPR_TYPE_UNASSIGNED); + + // return invalid operation when one child aggregate and the other child scalar or column + if ((leftType == SQLEXPR_TYPE_AGG && rightType == SQLEXPR_TYPE_SCALAR) || (rightType == SQLEXPR_TYPE_AGG && leftType == SQLEXPR_TYPE_SCALAR)) { + return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg2); + } + if (leftType == SQLEXPR_TYPE_AGG || rightType == SQLEXPR_TYPE_AGG) { + *type = SQLEXPR_TYPE_AGG; + } else if (leftType == SQLEXPR_TYPE_VALUE && rightType == SQLEXPR_TYPE_VALUE) { + *type = SQLEXPR_TYPE_VALUE; + } else if (leftType == SQLEXPR_TYPE_SCALAR || rightType == SQLEXPR_TYPE_SCALAR){ + *type = SQLEXPR_TYPE_SCALAR; + } + } return TSDB_CODE_SUCCESS; } -static int32_t validateArithmeticSQLExpr(SSqlCmd* pCmd, tSqlExpr* pExpr, SQueryInfo* pQueryInfo, SColumnList* pList, int32_t* type) { +static int32_t validateSQLExprItem(SSqlCmd* pCmd, tSqlExpr* pExpr, + SQueryInfo* pQueryInfo, SColumnList* pList, int32_t* type, uint64_t* uid, int32_t* height) { + const char* msg1 = "invalid column name in select clause"; + const char* msg2 = "invalid data type in select clause"; + const char* msg3 = "invalid select clause"; + if (pExpr == NULL) { return TSDB_CODE_SUCCESS; } - - tSqlExpr* pLeft = pExpr->pLeft; - uint64_t uidLeft = 0; - uint64_t uidRight = 0; - - if (pLeft->type == SQL_NODE_EXPR) { - int32_t ret = validateArithmeticSQLExpr(pCmd, pLeft, pQueryInfo, pList, type); + if (pExpr->type == SQL_NODE_EXPR) { + int32_t ret = validateSQLExprItemArithmeticExpr(pCmd, pExpr, pQueryInfo, pList, type, uid, height); if (ret != TSDB_CODE_SUCCESS) { return ret; } - } else { - int32_t ret = validateSQLExpr(pCmd, pLeft, pQueryInfo, pList, type, &uidLeft); + } else if (pExpr->type == SQL_NODE_SQLFUNCTION) { + int32_t ret = validateSQLExprItemSQLFunc(pCmd, pExpr, pQueryInfo, pList, type, uid, height); if (ret != TSDB_CODE_SUCCESS) { return ret; } - } + } else if (pExpr->type == SQL_NODE_TABLE_COLUMN) { + SColumnIndex index = COLUMN_INDEX_INITIALIZER; - tSqlExpr* pRight = pExpr->pRight; - if (pRight->type == SQL_NODE_EXPR) { - int32_t ret = validateArithmeticSQLExpr(pCmd, pRight, pQueryInfo, pList, type); - if (ret != TSDB_CODE_SUCCESS) { - return ret; + if (getColumnIndexByName(&pExpr->columnName, pQueryInfo, &index, tscGetErrorMsgPayload(pCmd)) != + TSDB_CODE_SUCCESS) { + return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg1); + } + + pList->ids[pList->num++] = index; + *type = SQLEXPR_TYPE_SCALAR; + } else if (pExpr->type == SQL_NODE_DATA_TYPE) { + if (pExpr->dataType.type < 0 || pExpr->dataType.bytes <= 0) { + return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg2); } + *type = SQLEXPR_TYPE_VALUE; } else { - int32_t ret = validateSQLExpr(pCmd, pRight, pQueryInfo, pList, type, &uidRight); - if (ret != TSDB_CODE_SUCCESS) { - return ret; + if ((pExpr->tokenId == TK_FLOAT && (isnan(pExpr->value.dKey) || isinf(pExpr->value.dKey))) || + pExpr->tokenId == TK_NULL) { + return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg3); } - // the expression not from the same table, return error - if (uidLeft != uidRight && uidLeft != 0 && uidRight != 0) { - return TSDB_CODE_TSC_INVALID_OPERATION; + if (pExpr->value.nType == (uint32_t)-1) { + return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg3); + } + + if (pExpr->type == SQL_NODE_VALUE) { + *type = SQLEXPR_TYPE_VALUE; } } - return TSDB_CODE_SUCCESS; } @@ -6414,6 +6594,27 @@ int32_t validateOrderbyNode(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SSqlNode* pSq return invalidOperationMsg(pMsgBuf, msg11); } + if (tscIsProjectionQuery(pQueryInfo)) { + bool found = false; + for (int32_t i = 0; i < tscNumOfExprs(pQueryInfo); ++i) { + SExprInfo* pExpr = tscExprGet(pQueryInfo, i); + if (pExpr->base.functionId == TSDB_FUNC_PRJ && pExpr->base.colInfo.colId == pSchema[index.columnIndex].colId) { + found = true; + break; + } + } + + if (!found) { + int32_t numOfCols = (int32_t)tscNumOfFields(pQueryInfo); + tscAddFuncInSelectClause(pQueryInfo, numOfCols, TSDB_FUNC_PRJ, &index, pSchema, TSDB_COL_NORMAL, getNewResColId(pCmd)); + + SInternalField* pSupInfo = tscFieldInfoGetInternalField(&pQueryInfo->fieldsInfo, numOfCols); + pSupInfo->visible = false; + + pQueryInfo->type |= TSDB_QUERY_TYPE_PROJECTION_QUERY; + } + } + pItem = taosArrayGet(pSqlNode->pSortOrder, 0); pQueryInfo->order.order = pItem->sortOrder; pQueryInfo->order.orderColId = pSchema[index.columnIndex].colId; @@ -6904,6 +7105,9 @@ int32_t validateSqlFunctionInStreamSql(SSqlCmd* pCmd, SQueryInfo* pQueryInfo) { size_t size = taosArrayGetSize(pQueryInfo->exprList); for (int32_t i = 0; i < size; ++i) { int32_t functId = tscExprGet(pQueryInfo, i)->base.functionId; + if (TSDB_FUNC_IS_SCALAR(functId)) { + continue; + } if (!IS_STREAM_QUERY_VALID(aAggs[functId].status)) { return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg1); } @@ -6932,6 +7136,11 @@ int32_t validateFunctionsInIntervalOrGroupbyQuery(SSqlCmd* pCmd, SQueryInfo* pQu } } + if (TSDB_FUNC_IS_SCALAR(pExpr->base.functionId)) { + isProjectionFunction = true; + break; + } + // projection query on primary timestamp, the selectivity function needs to be present. if (pExpr->base.functionId == TSDB_FUNC_PRJ && pExpr->base.colInfo.colId == PRIMARYKEY_TIMESTAMP_COL_INDEX) { bool hasSelectivity = false; @@ -6950,9 +7159,8 @@ int32_t validateFunctionsInIntervalOrGroupbyQuery(SSqlCmd* pCmd, SQueryInfo* pQu int32_t f = pExpr->base.functionId; if ((f == TSDB_FUNC_PRJ && pExpr->base.numOfParams == 0) || - f == TSDB_FUNC_DIFF || f == TSDB_FUNC_ARITHM || f == TSDB_FUNC_DERIVATIVE || - f == TSDB_FUNC_CSUM || f == TSDB_FUNC_MAVG || - f == TSDB_FUNC_CEIL || f == TSDB_FUNC_FLOOR || f == TSDB_FUNC_ROUND) + f == TSDB_FUNC_DIFF || f == TSDB_FUNC_SCALAR_EXPR || f == TSDB_FUNC_DERIVATIVE || + f == TSDB_FUNC_CSUM || f == TSDB_FUNC_MAVG) { isProjectionFunction = true; break; @@ -7506,7 +7714,8 @@ static bool onlyTagPrjFunction(SQueryInfo* pQueryInfo) { size_t size = taosArrayGetSize(pQueryInfo->exprList); for (int32_t i = 0; i < size; ++i) { SExprInfo* pExpr = tscExprGet(pQueryInfo, i); - if (pExpr->base.functionId == TSDB_FUNC_PRJ) { + if (pExpr->base.functionId == TSDB_FUNC_PRJ || + (pExpr->base.functionId == TSDB_FUNC_SCALAR_EXPR && ((pQueryInfo->type & TSDB_QUERY_TYPE_PROJECTION_QUERY) != 0))) { hasColumnPrj = true; } else if (pExpr->base.functionId == TSDB_FUNC_TAGPRJ) { hasTagPrj = true; @@ -7578,7 +7787,7 @@ static int32_t checkUpdateTagPrjFunctions(SQueryInfo* pQueryInfo, char* msg) { int16_t functionId = pExpr->base.functionId; if (functionId == TSDB_FUNC_TAGPRJ || functionId == TSDB_FUNC_PRJ || functionId == TSDB_FUNC_TS || - functionId == TSDB_FUNC_ARITHM || functionId == TSDB_FUNC_TS_DUMMY) { + functionId == TSDB_FUNC_SCALAR_EXPR || functionId == TSDB_FUNC_TS_DUMMY) { continue; } @@ -7591,10 +7800,13 @@ static int32_t checkUpdateTagPrjFunctions(SQueryInfo* pQueryInfo, char* msg) { continue; } + if (TSDB_FUNC_IS_SCALAR(functionId)) { + numOfScalar++; + continue; + } + if ((aAggs[functionId].status & TSDB_FUNCSTATE_SELECTIVITY) != 0) { numOfSelectivity++; - } else if ((aAggs[functionId].status & TSDB_FUNCSTATE_SCALAR) != 0) { - numOfScalar++; } else { numOfAggregation++; } @@ -7625,6 +7837,10 @@ static int32_t checkUpdateTagPrjFunctions(SQueryInfo* pQueryInfo, char* msg) { for (int32_t i = 0; i < numOfExprs; ++i) { SExprInfo* pExpr = tscExprGet(pQueryInfo, i); int16_t functionId = pExpr->base.functionId; + if (TSDB_FUNC_IS_SCALAR(functionId)) { + continue; + } + if (functionId == TSDB_FUNC_TAGPRJ || (aAggs[functionId].status & TSDB_FUNCSTATE_SELECTIVITY) == 0) { continue; } @@ -7670,7 +7886,7 @@ static int32_t doAddGroupbyColumnsOnDemand(SSqlCmd* pCmd, SQueryInfo* pQueryInfo SSchema* pSchema = tscGetTableSchema(pTableMetaInfo->pTableMeta); SSchema* tagSchema = NULL; - if (!UTIL_TABLE_IS_NORMAL_TABLE(pTableMetaInfo)) { + if (UTIL_TABLE_IS_SUPER_TABLE(pTableMetaInfo) || UTIL_TABLE_IS_CHILD_TABLE(pTableMetaInfo)) { tagSchema = tscGetTableTagSchema(pTableMetaInfo->pTableMeta); } @@ -7839,6 +8055,11 @@ int32_t doFunctionsCompatibleCheck(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, char* continue; } + if (f == TSDB_FUNC_SCALAR_EXPR && + (pQueryInfo->type & TSDB_QUERY_TYPE_PROJECTION_QUERY) != 0) { + return invalidOperationMsg(msg, msg1); + } + if ((!pQueryInfo->stateWindow) && (f == TSDB_FUNC_DIFF || f == TSDB_FUNC_DERIVATIVE || f == TSDB_FUNC_TWA || f == TSDB_FUNC_IRATE || f == TSDB_FUNC_CSUM || f == TSDB_FUNC_MAVG || f == TSDB_FUNC_ELAPSED)) { for (int32_t j = 0; j < pQueryInfo->groupbyExpr.numOfGroupCols; ++j) { @@ -7859,9 +8080,6 @@ int32_t doFunctionsCompatibleCheck(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, char* return invalidOperationMsg(msg, msg1); } - if (IS_SCALAR_FUNCTION(aAggs[f].status)) { - return invalidOperationMsg(msg, msg1); - } if (f == TSDB_FUNC_COUNT && pExpr->base.colInfo.colIndex == TSDB_TBNAME_COLUMN_INDEX) { return invalidOperationMsg(msg, msg1); @@ -8151,8 +8369,10 @@ void tscPrintSelNodeList(SSqlObj* pSql, int32_t subClauseIndex) { if (pExpr->base.functionId < 0) { SUdfInfo* pUdfInfo = taosArrayGet(pQueryInfo->pUdfInfo, -1 * pExpr->base.functionId - 1); name = pUdfInfo->name; - } else { + } else if (!TSDB_FUNC_IS_SCALAR(pExpr->base.functionId)) { name = aAggs[pExpr->base.functionId].name; + } else { + name = aScalarFunctions[TSDB_FUNC_SCALAR_INDEX(pExpr->base.functionId)].name; } tmpLen = @@ -9795,33 +10015,8 @@ int32_t validateSqlNode(SSqlObj* pSql, SSqlNode* pSqlNode, SQueryInfo* pQueryInf } int32_t exprTreeFromSqlExpr(SSqlCmd* pCmd, tExprNode **pExpr, const tSqlExpr* pSqlExpr, SQueryInfo* pQueryInfo, SArray* pCols, uint64_t *uid) { - tExprNode* pLeft = NULL; - tExprNode* pRight= NULL; - SColumnIndex index = COLUMN_INDEX_INITIALIZER; - - if (pSqlExpr->pLeft != NULL) { - int32_t ret = exprTreeFromSqlExpr(pCmd, &pLeft, pSqlExpr->pLeft, pQueryInfo, pCols, uid); - if (ret != TSDB_CODE_SUCCESS) { - return ret; - } - } - - if (pSqlExpr->pRight != NULL) { - int32_t ret = exprTreeFromSqlExpr(pCmd, &pRight, pSqlExpr->pRight, pQueryInfo, pCols, uid); - if (ret != TSDB_CODE_SUCCESS) { - tExprTreeDestroy(pLeft, NULL); - return ret; - } - } - - if (pSqlExpr->pLeft == NULL && pSqlExpr->pRight == NULL && pSqlExpr->tokenId == 0) { - *pExpr = calloc(1, sizeof(tExprNode)); - return TSDB_CODE_SUCCESS; - } - - if (pSqlExpr->pLeft == NULL) { // it is the leaf node - assert(pSqlExpr->pRight == NULL); - + if (pSqlExpr->type != SQL_NODE_EXPR && pSqlExpr->type != SQL_NODE_SQLFUNCTION) { + assert(pSqlExpr->pLeft == NULL && pSqlExpr->pRight == NULL); if (pSqlExpr->type == SQL_NODE_VALUE) { if(pSqlExpr->value.nType == -1){ return TSDB_CODE_TSC_INVALID_VALUE; @@ -9838,7 +10033,7 @@ int32_t exprTreeFromSqlExpr(SSqlCmd* pCmd, tExprNode **pExpr, const tSqlExpr* pS if (colSize > 0) { SColIndex* idx = taosArrayGet(pCols, colSize - 1); - + SSchema* pSchema = tscGetTableColumnSchema(pTableMeta, idx->colIndex); // convert time by precision if (pSchema != NULL && TSDB_DATA_TYPE_TIMESTAMP == pSchema->type && TSDB_DATA_TYPE_BINARY == (*pExpr)->pVal->nType) { @@ -9847,32 +10042,9 @@ int32_t exprTreeFromSqlExpr(SSqlCmd* pCmd, tExprNode **pExpr, const tSqlExpr* pS } } return ret; - } else if (pSqlExpr->type == SQL_NODE_SQLFUNCTION) { - // arithmetic expression on the results of aggregation functions - *pExpr = calloc(1, sizeof(tExprNode)); - (*pExpr)->nodeType = TSQL_NODE_COL; - (*pExpr)->pSchema = calloc(1, sizeof(SSchema)); - strncpy((*pExpr)->pSchema->name, pSqlExpr->exprToken.z, pSqlExpr->exprToken.n); - - // set the input column data byte and type. - size_t size = taosArrayGetSize(pQueryInfo->exprList); - - for (int32_t i = 0; i < size; ++i) { - SExprInfo* p1 = taosArrayGetP(pQueryInfo->exprList, i); - - if (strcmp((*pExpr)->pSchema->name, p1->base.aliasName) == 0) { - (*pExpr)->pSchema->type = (uint8_t)p1->base.resType; - (*pExpr)->pSchema->bytes = p1->base.resBytes; - (*pExpr)->pSchema->colId = p1->base.resColId; - - if (uid != NULL) { - *uid = p1->base.uid; - } + } else if (pSqlExpr->type == SQL_NODE_TABLE_COLUMN) { // column name, normal column arithmetic expression + SColumnIndex index = COLUMN_INDEX_INITIALIZER; - break; - } - } - } else if (pSqlExpr->type == SQL_NODE_TABLE_COLUMN) { // column name, normal column arithmetic expression int32_t ret = getColumnIndexByName(&pSqlExpr->columnName, pQueryInfo, &index, tscGetErrorMsgPayload(pCmd)); if (ret != TSDB_CODE_SUCCESS) { return ret; @@ -9880,34 +10052,41 @@ int32_t exprTreeFromSqlExpr(SSqlCmd* pCmd, tExprNode **pExpr, const tSqlExpr* pS pQueryInfo->curTableIdx = index.tableIndex; STableMeta* pTableMeta = tscGetMetaInfo(pQueryInfo, index.tableIndex)->pTableMeta; - int32_t numOfColumns = tscGetNumOfColumns(pTableMeta); + int32_t numOfColumns = tscGetNumOfColumns(pTableMeta); *pExpr = calloc(1, sizeof(tExprNode)); (*pExpr)->nodeType = TSQL_NODE_COL; (*pExpr)->pSchema = calloc(1, sizeof(SSchema)); SSchema* pSchema = NULL; - + if (index.columnIndex == TSDB_TBNAME_COLUMN_INDEX) { pSchema = (*pExpr)->pSchema; - strcpy(pSchema->name, TSQL_TBNAME_L); - pSchema->type = TSDB_DATA_TYPE_BINARY; - pSchema->colId = TSDB_TBNAME_COLUMN_INDEX; - pSchema->bytes = -1; + strcpy(pSchema->name, tGetTbnameColumnSchema()->name); + pSchema->type = tGetTbnameColumnSchema()->type; + pSchema->colId = tGetTbnameColumnSchema()->colId; + pSchema->bytes = tGetTbnameColumnSchema()->bytes; } else { pSchema = tscGetTableColumnSchema(pTableMeta, index.columnIndex); *(*pExpr)->pSchema = *pSchema; } - + if (pCols != NULL) { // record the involved columns SColIndex colIndex = {0}; tstrncpy(colIndex.name, pSchema->name, sizeof(colIndex.name)); colIndex.colId = pSchema->colId; colIndex.colIndex = index.columnIndex; - colIndex.flag = (index.columnIndex >= numOfColumns)? 1:0; + colIndex.flag = (index.columnIndex >= numOfColumns) ? 1 : 0; taosArrayPush(pCols, &colIndex); } + return TSDB_CODE_SUCCESS; + } else if (pSqlExpr->type == SQL_NODE_DATA_TYPE) { + *pExpr = calloc(1, sizeof(tExprNode)); + (*pExpr)->nodeType = TSQL_NODE_TYPE; + (*pExpr)->pType = calloc(1, sizeof(TAOS_FIELD)); + + *(*pExpr)->pType = pSqlExpr->dataType; return TSDB_CODE_SUCCESS; } else if (pSqlExpr->tokenId == TK_SET) { @@ -9942,21 +10121,44 @@ int32_t exprTreeFromSqlExpr(SSqlCmd* pCmd, tExprNode **pExpr, const tSqlExpr* pS *pExpr = calloc(1, sizeof(tExprNode)); (*pExpr)->nodeType = TSQL_NODE_VALUE; (*pExpr)->pVal = pVal; + return TSDB_CODE_SUCCESS; + } else if (pSqlExpr->tokenId == 0) { + *pExpr = calloc(1, sizeof(tExprNode)); + return TSDB_CODE_SUCCESS; } else { return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), "not support filter expression"); } - - } else { + } + + if (pSqlExpr->type == SQL_NODE_EXPR) { + tExprNode* pLeft = NULL; + tExprNode* pRight= NULL; + + if (pSqlExpr->pLeft != NULL) { + int32_t ret = exprTreeFromSqlExpr(pCmd, &pLeft, pSqlExpr->pLeft, pQueryInfo, pCols, uid); + if (ret != TSDB_CODE_SUCCESS) { + return ret; + } + } + + if (pSqlExpr->pRight != NULL) { + int32_t ret = exprTreeFromSqlExpr(pCmd, &pRight, pSqlExpr->pRight, pQueryInfo, pCols, uid); + if (ret != TSDB_CODE_SUCCESS) { + tExprTreeDestroy(pLeft, NULL); + return ret; + } + } + *pExpr = (tExprNode *)calloc(1, sizeof(tExprNode)); (*pExpr)->nodeType = TSQL_NODE_EXPR; - + (*pExpr)->_node.hasPK = false; (*pExpr)->_node.pLeft = pLeft; (*pExpr)->_node.pRight = pRight; - + SStrToken t = {.type = pSqlExpr->tokenId}; (*pExpr)->_node.optr = convertRelationalOperator(&t); - + assert((*pExpr)->_node.optr != 0); // check for dividing by 0 @@ -9981,8 +10183,52 @@ int32_t exprTreeFromSqlExpr(SSqlCmd* pCmd, tExprNode **pExpr, const tSqlExpr* pS } } } + + } else if (pSqlExpr->type == SQL_NODE_SQLFUNCTION) { + if (TSDB_FUNC_IS_SCALAR(pSqlExpr->functionId)) { + *pExpr = calloc(1, sizeof(tExprNode)); + (*pExpr)->nodeType = TSQL_NODE_FUNC; + (*pExpr)->_func.functionId = pSqlExpr->functionId; + SArray* paramList = pSqlExpr->Expr.paramList; + size_t paramSize = paramList ? taosArrayGetSize(paramList) : 0; + if (paramSize > 0) { + (*pExpr)->_func.numChildren = (int32_t)paramSize; + (*pExpr)->_func.pChildren = (tExprNode**)calloc(paramSize, sizeof(tExprNode*)); + } + for (int32_t i = 0; i < paramSize; ++i) { + tSqlExprItem* param = taosArrayGet(paramList, i); + tSqlExpr* paramNode = param->pNode; + int32_t ret = exprTreeFromSqlExpr(pCmd, (*pExpr)->_func.pChildren+i, paramNode, pQueryInfo, pCols, uid); + if (ret != TSDB_CODE_SUCCESS) { + return ret; + } + } + } else { + // arithmetic expression on the results of aggregation functions + *pExpr = calloc(1, sizeof(tExprNode)); + (*pExpr)->nodeType = TSQL_NODE_COL; + (*pExpr)->pSchema = calloc(1, sizeof(SSchema)); + strncpy((*pExpr)->pSchema->name, pSqlExpr->exprToken.z, pSqlExpr->exprToken.n); + + // set the input column data byte and type. + size_t size = taosArrayGetSize(pQueryInfo->exprList); + + for (int32_t i = 0; i < size; ++i) { + SExprInfo* p1 = taosArrayGetP(pQueryInfo->exprList, i); + + if (strcmp((*pExpr)->pSchema->name, p1->base.aliasName) == 0) { + (*pExpr)->pSchema->type = (uint8_t)p1->base.resType; + (*pExpr)->pSchema->bytes = p1->base.resBytes; + (*pExpr)->pSchema->colId = p1->base.resColId; + + if (uid != NULL) { + *uid = p1->base.uid; + } + break; + } + } // endfor each expr + } // end not scalar function } - return TSDB_CODE_SUCCESS; } @@ -10030,5 +10276,3 @@ void normalizeSqlNode(SSqlNode* pSqlNode, const char* dbName) { } #endif - - diff --git a/src/client/src/tscSubquery.c b/src/client/src/tscSubquery.c index 3e81b2fe64e1e9cce96837be1fcf6cf445d464c2..5f8964bb34b5939ab768877cb8ae701e20443f75 100644 --- a/src/client/src/tscSubquery.c +++ b/src/client/src/tscSubquery.c @@ -3621,7 +3621,7 @@ static void doBuildResFromSubqueries(SSqlObj* pSql) { finalRowSize += pField->bytes; } - doArithmeticCalculate(pQueryInfo, pFilePage, rowSize, finalRowSize); + doScalarExprCalculate(pQueryInfo, pFilePage, rowSize, finalRowSize); pRes->data = pFilePage->data; tscSetResRawPtr(pRes, pQueryInfo, pRes->dataConverted); @@ -3660,8 +3660,8 @@ void tscBuildResFromSubqueries(SSqlObj *pSql) { } } -char *getArithmeticInputSrc(void *param, const char *name, int32_t colId) { - SArithmeticSupport *pSupport = (SArithmeticSupport *) param; +char * getScalarExprInputSrc(void *param, const char *name, int32_t colId) { + SScalarExprSupport*pSupport = (SScalarExprSupport*) param; int32_t index = -1; SExprInfo* pExpr = NULL; diff --git a/src/client/src/tscUtil.c b/src/client/src/tscUtil.c index c5f3a1cdaffd48acc7f0091c63c164d58484bc09..e2263f696a885e885091e86c6b1210bc817996c2 100644 --- a/src/client/src/tscUtil.c +++ b/src/client/src/tscUtil.c @@ -287,13 +287,11 @@ bool tscIsProjectionQueryOnSTable(SQueryInfo* pQueryInfo, int32_t tableIndex) { functionId != TSDB_FUNC_TAGPRJ && functionId != TSDB_FUNC_TAG && functionId != TSDB_FUNC_TS && - functionId != TSDB_FUNC_ARITHM && + functionId != TSDB_FUNC_SCALAR_EXPR && functionId != TSDB_FUNC_TS_COMP && functionId != TSDB_FUNC_TS_DUMMY && functionId != TSDB_FUNC_TID_TAG && - functionId != TSDB_FUNC_CEIL && - functionId != TSDB_FUNC_FLOOR && - functionId != TSDB_FUNC_ROUND) { + !TSDB_FUNC_IS_SCALAR(functionId)) { return false; } } @@ -330,8 +328,8 @@ bool tscIsProjectionQuery(SQueryInfo* pQueryInfo) { } if (f != TSDB_FUNC_PRJ && f != TSDB_FUNC_TAGPRJ && f != TSDB_FUNC_TAG && - f != TSDB_FUNC_TS && f != TSDB_FUNC_ARITHM && f != TSDB_FUNC_DIFF && - f != TSDB_FUNC_DERIVATIVE) { + f != TSDB_FUNC_TS && f != TSDB_FUNC_SCALAR_EXPR && f != TSDB_FUNC_DIFF && + f != TSDB_FUNC_DERIVATIVE && !TSDB_FUNC_IS_SCALAR(f)) { return false; } } @@ -680,6 +678,10 @@ bool isSimpleAggregateRv(SQueryInfo* pQueryInfo) { continue; } + if (TSDB_FUNC_IS_SCALAR(functionId)) { + continue; + } + if (functionId == TSDB_FUNC_TS || functionId == TSDB_FUNC_TS_DUMMY) { continue; } @@ -2064,18 +2066,11 @@ static int trimDataBlock(void* pDataBlock, STableDataBlocks* pTableDataBlock, SI } } else { for (int32_t i = 0; i < numOfRows; ++i) { - char* payload = (blkKeyTuple + i)->payloadAddr; - if (isNeedConvertRow(payload)) { - convertSMemRow(pDataBlock, payload, pTableDataBlock); - TDRowTLenT rowTLen = memRowTLen(pDataBlock); - pDataBlock = POINTER_SHIFT(pDataBlock, rowTLen); - pBlock->dataLen += rowTLen; - } else { - TDRowTLenT rowTLen = memRowTLen(payload); - memcpy(pDataBlock, payload, rowTLen); - pDataBlock = POINTER_SHIFT(pDataBlock, rowTLen); - pBlock->dataLen += rowTLen; - } + char* payload = (blkKeyTuple + i)->payloadAddr; + TDRowTLenT rowTLen = memRowTLen(payload); + memcpy(pDataBlock, payload, rowTLen); + pDataBlock = POINTER_SHIFT(pDataBlock, rowTLen); + pBlock->dataLen += rowTLen; } } @@ -4475,6 +4470,8 @@ bool tscHasReachLimitation(SQueryInfo* pQueryInfo, SSqlRes* pRes) { char* tscGetErrorMsgPayload(SSqlCmd* pCmd) { return pCmd->payload; } +int32_t tscGetErrorMsgLength(SSqlCmd* pCmd) { return (int32_t)strlen(pCmd->payload); } + /** * If current vnode query does not return results anymore (pRes->numOfRows == 0), try the next vnode if exists, * while multi-vnode super table projection query and the result does not reach the limitation. @@ -4917,7 +4914,7 @@ int32_t createProjectionExpr(SQueryInfo* pQueryInfo, STableMetaInfo* pTableMetaI strncpy(pse->aliasName, pSource->base.aliasName, tListLen(pse->aliasName)); strncpy(pse->token, pSource->base.token, tListLen(pse->token)); - if (pSource->base.functionId != TSDB_FUNC_ARITHM) { // this should be switched to projection query + if (pSource->base.functionId != TSDB_FUNC_SCALAR_EXPR) { // this should be switched to projection query pse->numOfParams = 0; // no params for projection query pse->functionId = TSDB_FUNC_PRJ; pse->colInfo.colId = pSource->base.resColId; @@ -4961,16 +4958,17 @@ int32_t createProjectionExpr(SQueryInfo* pQueryInfo, STableMetaInfo* pTableMetaI pse->colInfo.colId = pSource->base.colInfo.colId; pse->colType = pSource->base.colType; pse->colBytes = pSource->base.colBytes; - pse->resBytes = sizeof(double); - pse->resType = TSDB_DATA_TYPE_DOUBLE; pse->functionId = pSource->base.functionId; pse->numOfParams = pSource->base.numOfParams; for (int32_t j = 0; j < pSource->base.numOfParams; ++j) { tVariantAssign(&pse->param[j], &pSource->base.param[j]); - buildArithmeticExprFromMsg(px, NULL); + buildScalarExprFromMsg(px, NULL); } + + pse->resBytes = px->pExpr->resultBytes; + pse->resType = px->pExpr->resultType; } } @@ -5163,9 +5161,9 @@ int32_t tscCreateQueryFromQueryInfo(SQueryInfo* pQueryInfo, SQueryAttr* pQueryAt SExprInfo* pExpr = tscExprGet(pQueryInfo, i); tscExprAssign(&pQueryAttr->pExpr1[i], pExpr); - if (pQueryAttr->pExpr1[i].base.functionId == TSDB_FUNC_ARITHM) { + if (pQueryAttr->pExpr1[i].base.functionId == TSDB_FUNC_SCALAR_EXPR) { for (int32_t j = 0; j < pQueryAttr->pExpr1[i].base.numOfParams; ++j) { - buildArithmeticExprFromMsg(&pQueryAttr->pExpr1[i], NULL); + buildScalarExprFromMsg(&pQueryAttr->pExpr1[i], NULL); } } } diff --git a/src/common/inc/tarithoperator.h b/src/common/inc/tarithoperator.h index 27e8871e2f7b32bf7772dfa0cbc9c3164a312f2d..38c9feed466e5d326c21acbd0f0775ddee61562a 100644 --- a/src/common/inc/tarithoperator.h +++ b/src/common/inc/tarithoperator.h @@ -25,6 +25,7 @@ typedef void (*_arithmetic_operator_fn_t)(void *left, int32_t numLeft, int32_t l _arithmetic_operator_fn_t getArithmeticOperatorFn(int32_t arithmeticOptr); + #ifdef __cplusplus } #endif diff --git a/src/common/inc/tdataformat.h b/src/common/inc/tdataformat.h index c9359d821d1adb8571bf14cb8c413b41a99a9b42..cb001becd45271989586b0d45d4f91c36bbba5aa 100644 --- a/src/common/inc/tdataformat.h +++ b/src/common/inc/tdataformat.h @@ -614,22 +614,17 @@ typedef void *SMemRow; #define SMEM_ROW_DATA 0x0U // SDataRow #define SMEM_ROW_KV 0x01U // SKVRow -#define SMEM_ROW_CONVERT 0x80U // SMemRow convert flag -#define KVRatioKV (0.2f) // all bool -#define KVRatioPredict (0.4f) -#define KVRatioData (0.75f) // all bigint #define KVRatioConvert (0.9f) #define memRowType(r) ((*(uint8_t *)(r)) & 0x01) #define memRowSetType(r, t) ((*(uint8_t *)(r)) = (t)) // set the total byte in case of dirty memory -#define memRowSetConvert(r) ((*(uint8_t *)(r)) = (((*(uint8_t *)(r)) & 0x7F) | SMEM_ROW_CONVERT)) // highest bit #define isDataRowT(t) (SMEM_ROW_DATA == (((uint8_t)(t)) & 0x01)) #define isDataRow(r) (SMEM_ROW_DATA == memRowType(r)) #define isKvRowT(t) (SMEM_ROW_KV == (((uint8_t)(t)) & 0x01)) #define isKvRow(r) (SMEM_ROW_KV == memRowType(r)) -#define isNeedConvertRow(r) (((*(uint8_t *)(r)) & 0x80) == SMEM_ROW_CONVERT) +#define isUtilizeKVRow(k, d) ((k) < ((d)*KVRatioConvert)) #define memRowDataBody(r) POINTER_SHIFT(r, TD_MEM_ROW_TYPE_SIZE) // section after flag #define memRowKvBody(r) \ diff --git a/src/common/inc/texpr.h b/src/common/inc/texpr.h index bfeb3a6dfeee22f793c82748611c28ec537e8825..311f65073367e2b2a2c5e436b4655cf12ef4c02a 100644 --- a/src/common/inc/texpr.h +++ b/src/common/inc/texpr.h @@ -41,6 +41,55 @@ struct SSchema; #define QUERY_COND_REL_PREFIX_MATCH_LEN 6 #define QUERY_COND_REL_PREFIX_NMATCH_LEN 7 +#define TSDB_FUNC_FLAG_SCALAR 0x4000 +#define TSDB_FUNC_IS_SCALAR(id) ((((id) > 0)) && (((id) & TSDB_FUNC_FLAG_SCALAR) != 0)) +#define TSDB_FUNC_SCALAR_INDEX(id) ((id) & ~TSDB_FUNC_FLAG_SCALAR) + +/////////////////////////////////////////// +// SCALAR FUNCTIONS +#define TSDB_FUNC_SCALAR_POW (TSDB_FUNC_FLAG_SCALAR | 0x0000) +#define TSDB_FUNC_SCALAR_LOG (TSDB_FUNC_FLAG_SCALAR | 0x0001) +#define TSDB_FUNC_SCALAR_ABS (TSDB_FUNC_FLAG_SCALAR | 0x0002) +#define TSDB_FUNC_SCALAR_ACOS (TSDB_FUNC_FLAG_SCALAR | 0x0003) +#define TSDB_FUNC_SCALAR_ASIN (TSDB_FUNC_FLAG_SCALAR | 0x0004) +#define TSDB_FUNC_SCALAR_ATAN (TSDB_FUNC_FLAG_SCALAR | 0x0005) +#define TSDB_FUNC_SCALAR_COS (TSDB_FUNC_FLAG_SCALAR | 0x0006) +#define TSDB_FUNC_SCALAR_SIN (TSDB_FUNC_FLAG_SCALAR | 0x0007) +#define TSDB_FUNC_SCALAR_TAN (TSDB_FUNC_FLAG_SCALAR | 0x0008) +#define TSDB_FUNC_SCALAR_SQRT (TSDB_FUNC_FLAG_SCALAR | 0x0009) +#define TSDB_FUNC_SCALAR_CEIL (TSDB_FUNC_FLAG_SCALAR | 0x000A) +#define TSDB_FUNC_SCALAR_FLOOR (TSDB_FUNC_FLAG_SCALAR | 0x000B) +#define TSDB_FUNC_SCALAR_ROUND (TSDB_FUNC_FLAG_SCALAR | 0x000C) +#define TSDB_FUNC_SCALAR_CONCAT (TSDB_FUNC_FLAG_SCALAR | 0x000D) +#define TSDB_FUNC_SCALAR_LENGTH (TSDB_FUNC_FLAG_SCALAR | 0x000E) +#define TSDB_FUNC_SCALAR_CONCAT_WS (TSDB_FUNC_FLAG_SCALAR | 0x000F) +#define TSDB_FUNC_SCALAR_CHAR_LENGTH (TSDB_FUNC_FLAG_SCALAR | 0x0010) +#define TSDB_FUNC_SCALAR_CAST (TSDB_FUNC_FLAG_SCALAR | 0x0011) +#define TSDB_FUNC_SCALAR_MAX_NUM 18 + +#define TSDB_FUNC_SCALAR_NAME_MAX_LEN 16 + +typedef struct { + int16_t type; + int16_t bytes; + int16_t numOfRows; + char* data; +} tExprOperandInfo; + +typedef void (*_expr_scalar_function_t)(int16_t functionId, tExprOperandInfo* pInputs, int32_t numInputs, tExprOperandInfo* pOutput, int32_t order); + +_expr_scalar_function_t getExprScalarFunction(uint16_t scalar); + +typedef struct tScalarFunctionInfo{ + int16_t functionId; // scalar function id & ~TSDB_FUNC_FLAG_SCALAR == index + char name[TSDB_FUNC_SCALAR_NAME_MAX_LEN]; + _expr_scalar_function_t scalarFunc; +} tScalarFunctionInfo; + +/* global scalar sql functions array */ +extern struct tScalarFunctionInfo aScalarFunctions[TSDB_FUNC_SCALAR_MAX_NUM]; + + typedef bool (*__result_filter_fn_t)(const void *, void *); typedef void (*__do_filter_suppl_fn_t)(void *, void *); @@ -49,6 +98,8 @@ enum { TSQL_NODE_EXPR = 0x1, TSQL_NODE_COL = 0x2, TSQL_NODE_VALUE = 0x4, + TSQL_NODE_FUNC = 0x8, + TSQL_NODE_TYPE = 0x10 }; /** @@ -74,8 +125,19 @@ typedef struct tExprNode { } _node; struct SSchema *pSchema; + tVariant *pVal; + + struct { + int16_t functionId; + int32_t numChildren; + struct tExprNode **pChildren; + } _func; + + TAOS_FIELD *pType; }; + int16_t resultType; + int16_t resultBytes; } tExprNode; typedef struct SExprTraverseSupp { @@ -86,6 +148,8 @@ typedef struct SExprTraverseSupp { void tExprTreeDestroy(tExprNode *pNode, void (*fp)(void *)); +int32_t exprTreeValidateTree(char* msgbuf, tExprNode *pExpr); + void exprTreeToBinary(SBufferWriter* bw, tExprNode* pExprTree); tExprNode* exprTreeFromBinary(const void* data, size_t size); tExprNode* exprdup(tExprNode* pTree); @@ -94,8 +158,8 @@ void exprTreeToBinary(SBufferWriter* bw, tExprNode* pExprTree); bool exprTreeApplyFilter(tExprNode *pExpr, const void *pItem, SExprTraverseSupp *param); -void arithmeticTreeTraverse(tExprNode *pExprs, int32_t numOfRows, char *pOutput, void *param, int32_t order, - char *(*cb)(void *, const char*, int32_t)); +void exprTreeNodeTraverse(tExprNode *pExpr, int32_t numOfRows, tExprOperandInfo *output, void *param, int32_t order, + char *(*getSourceDataBlock)(void *, const char*, int32_t)); void buildFilterSetFromBinary(void **q, const char *buf, int32_t len); diff --git a/src/common/src/tarithoperator.c b/src/common/src/tarithoperator.c index 000ef79fcf9b5ee9e52dae65b99f719cec6a8059..31c7e32773965c866f069d04910cbbc59c187762 100644 --- a/src/common/src/tarithoperator.c +++ b/src/common/src/tarithoperator.c @@ -19,6 +19,7 @@ #include "tutil.h" #include "tarithoperator.h" #include "tcompare.h" +#include "texpr.h" //GET_TYPED_DATA(v, double, _right_type, (char *)&((right)[i])); diff --git a/src/common/src/texpr.c b/src/common/src/texpr.c index 36da3817824f1c03dc0bc19492e23d25799945cc..63a19c5c1b74028b8536982b0b2445c06de121b4 100644 --- a/src/common/src/texpr.c +++ b/src/common/src/texpr.c @@ -28,6 +28,129 @@ #include "texpr.h" #include "tarithoperator.h" +static int32_t exprValidateMathNode(tExprNode *pExpr); +static int32_t exprValidateStringConcatNode(tExprNode *pExpr); +static int32_t exprValidateStringConcatWsNode(tExprNode *pExpr); +static int32_t exprValidateStringLengthNode(tExprNode *pExpr); +static int32_t exprValidateCastNode(char* msgbuf, tExprNode *pExpr); + +static int32_t exprInvalidOperationMsg(char *msgbuf, const char *msg) { + const char* msgFormat = "invalid operation: %s"; + + sprintf(msgbuf, msgFormat, msg); + + return TSDB_CODE_TSC_INVALID_OPERATION; +} + + + +int32_t exprTreeValidateFunctionNode(char* msgbuf, tExprNode *pExpr) { + int32_t code = TSDB_CODE_SUCCESS; + //TODO: check childs for every function + switch (pExpr->_func.functionId) { + case TSDB_FUNC_SCALAR_POW: + case TSDB_FUNC_SCALAR_LOG: + case TSDB_FUNC_SCALAR_ABS: + case TSDB_FUNC_SCALAR_ACOS: + case TSDB_FUNC_SCALAR_ASIN: + case TSDB_FUNC_SCALAR_ATAN: + case TSDB_FUNC_SCALAR_COS: + case TSDB_FUNC_SCALAR_SIN: + case TSDB_FUNC_SCALAR_TAN: + case TSDB_FUNC_SCALAR_SQRT: + case TSDB_FUNC_SCALAR_CEIL: + case TSDB_FUNC_SCALAR_FLOOR: + case TSDB_FUNC_SCALAR_ROUND: { + return exprValidateMathNode(pExpr); + } + case TSDB_FUNC_SCALAR_CONCAT: { + return exprValidateStringConcatNode(pExpr); + } + case TSDB_FUNC_SCALAR_LENGTH: + case TSDB_FUNC_SCALAR_CHAR_LENGTH: { + return exprValidateStringLengthNode(pExpr); + } + case TSDB_FUNC_SCALAR_CAST: { + return exprValidateCastNode(msgbuf, pExpr); + } + case TSDB_FUNC_SCALAR_CONCAT_WS: { + return exprValidateStringConcatWsNode(pExpr); + } + + default: + break; + } + return code; +} + +int32_t exprTreeValidateExprNode(tExprNode *pExpr) { + if (pExpr->_node.optr == TSDB_BINARY_OP_ADD || pExpr->_node.optr == TSDB_BINARY_OP_SUBTRACT || + pExpr->_node.optr == TSDB_BINARY_OP_MULTIPLY || pExpr->_node.optr == TSDB_BINARY_OP_DIVIDE || + pExpr->_node.optr == TSDB_BINARY_OP_REMAINDER) { + int16_t leftType = pExpr->_node.pLeft->resultType; + int16_t rightType = pExpr->_node.pRight->resultType; + if (!IS_NUMERIC_TYPE(leftType) || !IS_NUMERIC_TYPE(rightType)) { + return TSDB_CODE_TSC_INVALID_OPERATION; + } + pExpr->resultType = TSDB_DATA_TYPE_DOUBLE; + pExpr->resultBytes = tDataTypes[TSDB_DATA_TYPE_DOUBLE].bytes; + return TSDB_CODE_SUCCESS; + } else { + return TSDB_CODE_SUCCESS; + } +} + +int32_t exprTreeValidateTree(char* msgbuf, tExprNode *pExpr) { + int32_t code = TSDB_CODE_SUCCESS; + if (pExpr == NULL) { + return TSDB_CODE_SUCCESS; + } + if (pExpr->nodeType == TSQL_NODE_VALUE) { + pExpr->resultType = pExpr->pVal->nType; + if (!IS_VAR_DATA_TYPE(pExpr->pVal->nType)) { + pExpr->resultBytes = tDataTypes[pExpr->pVal->nType].bytes; + } else { + pExpr->resultBytes = (int16_t)(pExpr->pVal->nLen + VARSTR_HEADER_SIZE); + } + } else if (pExpr->nodeType == TSQL_NODE_COL) { + pExpr->resultType = pExpr->pSchema->type; + if (pExpr->pSchema->colId != TSDB_TBNAME_COLUMN_INDEX) { + pExpr->resultBytes = pExpr->pSchema->bytes; + } else { + pExpr->resultBytes = tGetTbnameColumnSchema()->bytes; + } + } else if (pExpr->nodeType == TSQL_NODE_EXPR) { + code = exprTreeValidateTree(msgbuf, pExpr->_node.pLeft); + if (code != TSDB_CODE_SUCCESS) { + return code; + } + code = exprTreeValidateTree(msgbuf, pExpr->_node.pRight); + if (code != TSDB_CODE_SUCCESS) { + return code; + } + code = exprTreeValidateExprNode(pExpr); + if (code != TSDB_CODE_SUCCESS) { + return code; + } + } else if (pExpr->nodeType == TSQL_NODE_FUNC) { + for (int32_t i = 0; i < pExpr->_func.numChildren; ++i) { + code = exprTreeValidateTree(msgbuf, pExpr->_func.pChildren[i]); + if (code != TSDB_CODE_SUCCESS) { + return code; + } + } + code = exprTreeValidateFunctionNode(msgbuf, pExpr); + if (code != TSDB_CODE_SUCCESS) { + return code; + } + } else if (pExpr->nodeType == TSQL_NODE_TYPE) { + pExpr->resultType = pExpr->pType->type; + pExpr->resultBytes = pExpr->pType->bytes; + } + + return TSDB_CODE_SUCCESS; +} + static uint8_t UNUSED_FUNC isQueryOnPrimaryKey(const char *primaryColumnName, const tExprNode *pLeft, const tExprNode *pRight) { if (pLeft->nodeType == TSQL_NODE_COL) { // if left node is the primary column,return true @@ -41,7 +164,7 @@ static uint8_t UNUSED_FUNC isQueryOnPrimaryKey(const char *primaryColumnName, co } } -static void reverseCopy(char* dest, const char* src, int16_t type, int32_t numOfRows) { +static void reverseCopy(char* dest, const char* src, int16_t type, int32_t numOfRows, int16_t colSize) { switch(type) { case TSDB_DATA_TYPE_TINYINT: case TSDB_DATA_TYPE_UTINYINT:{ @@ -102,6 +225,13 @@ static void reverseCopy(char* dest, const char* src, int16_t type, int32_t numOf } return; } + case TSDB_DATA_TYPE_BINARY: + case TSDB_DATA_TYPE_NCHAR:{ + for(int32_t i = 0; i < numOfRows; ++i) { + memcpy(dest + i * colSize, src + (numOfRows - i - 1) * colSize, colSize); + } + return; + } default: assert(0); } } @@ -120,6 +250,10 @@ void tExprTreeDestroy(tExprNode *pNode, void (*fp)(void *)) { tfree(pNode->pVal); } else if (pNode->nodeType == TSQL_NODE_COL) { tfree(pNode->pSchema); + } else if (pNode->nodeType == TSQL_NODE_FUNC) { + doExprTreeDestroy(&pNode, fp); + } else if (pNode->nodeType == TSQL_NODE_TYPE) { + tfree(pNode->pType); } tfree(pNode); @@ -141,7 +275,14 @@ static void doExprTreeDestroy(tExprNode **pExpr, void (*fp)(void *)) { tVariantDestroy((*pExpr)->pVal); tfree((*pExpr)->pVal); } else if ((*pExpr)->nodeType == TSQL_NODE_COL) { - tfree((*pExpr)->pSchema); + free((*pExpr)->pSchema); + } else if ((*pExpr)->nodeType == TSQL_NODE_FUNC) { + for (int i = 0; i < (*pExpr)->_func.numChildren; ++i) { + doExprTreeDestroy((*pExpr)->_func.pChildren + i, fp); + } + free((*pExpr)->_func.pChildren); + } else if ((*pExpr)->nodeType == TSQL_NODE_TYPE) { + tfree((*pExpr)->pType); } tfree(*pExpr); @@ -175,111 +316,184 @@ bool exprTreeApplyFilter(tExprNode *pExpr, const void *pItem, SExprTraverseSupp return param->nodeFilterFn(pItem, pExpr->_node.info); } -void arithmeticTreeTraverse(tExprNode *pExprs, int32_t numOfRows, char *pOutput, void *param, int32_t order, - char *(*getSourceDataBlock)(void *, const char*, int32_t)) { - if (pExprs == NULL) { - return; - } +void exprTreeExprNodeTraverse(tExprNode *pExpr, int32_t numOfRows, tExprOperandInfo *output, void *param, int32_t order, + char *(*getSourceDataBlock)(void *, const char*, int32_t)); - tExprNode *pLeft = pExprs->_node.pLeft; - tExprNode *pRight = pExprs->_node.pRight; +void exprTreeFunctionNodeTraverse(tExprNode *pExprs, int32_t numOfRows, tExprOperandInfo *output, void *param, int32_t order, + char *(*getSourceDataBlock)(void *, const char*, int32_t)); +void exprTreeInternalNodeTraverse(tExprNode *pExpr, int32_t numOfRows, tExprOperandInfo *output, void *param, int32_t order, + char *(*getSourceDataBlock)(void *, const char*, int32_t)); - /* the left output has result from the left child syntax tree */ - char *pLeftOutput = (char*)malloc(sizeof(int64_t) * numOfRows); - if (pLeft->nodeType == TSQL_NODE_EXPR) { - arithmeticTreeTraverse(pLeft, numOfRows, pLeftOutput, param, order, getSourceDataBlock); +void exprTreeNodeTraverse(tExprNode *pExpr, int32_t numOfRows, tExprOperandInfo *output, void *param, int32_t order, + char *(*getSourceDataBlock)(void*, const char*, int32_t)) { + char* pOutput = output->data; + if (pExpr->nodeType == TSQL_NODE_FUNC || pExpr->nodeType == TSQL_NODE_EXPR) { + exprTreeInternalNodeTraverse(pExpr, numOfRows, output, param, order, getSourceDataBlock); + } else if (pExpr->nodeType == TSQL_NODE_COL) { + char *pInputData = getSourceDataBlock(param, pExpr->pSchema->name, pExpr->pSchema->colId); + if (order == TSDB_ORDER_DESC) { + reverseCopy(pOutput, pInputData, pExpr->pSchema->type, numOfRows, pExpr->pSchema->bytes); + } else { + memcpy(pOutput, pInputData, pExpr->pSchema->bytes*numOfRows); + } + assert(pExpr->resultType == pExpr->pSchema->type && pExpr->pSchema->bytes == pExpr->resultBytes); + output->numOfRows = numOfRows; + } else if (pExpr->nodeType == TSQL_NODE_VALUE) { + tVariantDump(pExpr->pVal, pOutput, pExpr->resultType, true); + output->numOfRows = 1; } +} - /* the right output has result from the right child syntax tree */ - char *pRightOutput = malloc(sizeof(int64_t) * numOfRows); - char *pdata = malloc(sizeof(int64_t) * numOfRows); +void exprTreeInternalNodeTraverse(tExprNode *pExpr, int32_t numOfRows, tExprOperandInfo *output, void *param, int32_t order, + char *(*getSourceDataBlock)(void *, const char*, int32_t)) { + if (pExpr->nodeType == TSQL_NODE_FUNC) { + exprTreeFunctionNodeTraverse(pExpr, numOfRows, output, param, order, getSourceDataBlock); + } else if (pExpr->nodeType == TSQL_NODE_EXPR){ + exprTreeExprNodeTraverse(pExpr, numOfRows, output, param, order, getSourceDataBlock); + } +} - if (pRight->nodeType == TSQL_NODE_EXPR) { - arithmeticTreeTraverse(pRight, numOfRows, pRightOutput, param, order, getSourceDataBlock); +void exprTreeFunctionNodeTraverse(tExprNode *pExpr, int32_t numOfRows, tExprOperandInfo *output, void *param, int32_t order, + char *(*getSourceDataBlock)(void *, const char*, int32_t)) { + int32_t numChildren = pExpr->_func.numChildren; + if (numChildren == 0) { + _expr_scalar_function_t scalarFn = getExprScalarFunction(pExpr->_func.functionId); + output->type = pExpr->resultType; + output->bytes = pExpr->resultBytes; + output->numOfRows = numOfRows; + scalarFn(pExpr->_func.functionId, NULL, 0, output, order); + return; } - if (pLeft->nodeType == TSQL_NODE_EXPR) { - if (pRight->nodeType == TSQL_NODE_EXPR) { - /* - * exprLeft + exprRight - * the type of returned value of one expression is always double float precious - */ - _arithmetic_operator_fn_t OperatorFn = getArithmeticOperatorFn(pExprs->_node.optr); - OperatorFn(pLeftOutput, numOfRows, TSDB_DATA_TYPE_DOUBLE, pRightOutput, numOfRows, TSDB_DATA_TYPE_DOUBLE, pOutput, TSDB_ORDER_ASC); + char** pChildrenOutput = calloc(numChildren, sizeof(char*)); + tExprOperandInfo* pChildrenResults = calloc(numChildren, sizeof(tExprOperandInfo)); - } else if (pRight->nodeType == TSQL_NODE_COL) { // exprLeft + columnRight - _arithmetic_operator_fn_t OperatorFn = getArithmeticOperatorFn(pExprs->_node.optr); + tExprOperandInfo* pInputs = calloc(numChildren, sizeof(tExprOperandInfo)); + for (int i = 0; i < numChildren; ++i) { + tExprNode *pChild = pExpr->_func.pChildren[i]; + pInputs[i].type = pChild->resultType; + pInputs[i].bytes = pChild->resultBytes; + } - // set input buffer - char *pInputData = getSourceDataBlock(param, pRight->pSchema->name, pRight->pSchema->colId); + for (int i = 0; i < numChildren; ++i) { + tExprNode *pChild = pExpr->_func.pChildren[i]; + if (pChild->nodeType == TSQL_NODE_EXPR || pChild->nodeType == TSQL_NODE_FUNC) { + pChildrenOutput[i] = malloc(pChild->resultBytes * numOfRows); + pChildrenResults[i].data = pChildrenOutput[i]; + exprTreeInternalNodeTraverse(pChild, numOfRows, pChildrenResults+i, param, order, getSourceDataBlock); + pInputs[i].data = pChildrenOutput[i]; + pInputs[i].numOfRows = pChildrenResults[i].numOfRows; + } else if (pChild->nodeType == TSQL_NODE_COL) { + assert(pChild->resultType == pChild->pSchema->type && pChild->resultBytes == pChild->pSchema->bytes); + char *pInputData = getSourceDataBlock(param, pChild->pSchema->name, pChild->pSchema->colId); if (order == TSDB_ORDER_DESC) { - reverseCopy(pdata, pInputData, pRight->pSchema->type, numOfRows); - OperatorFn(pLeftOutput, numOfRows, TSDB_DATA_TYPE_DOUBLE, pdata, numOfRows, pRight->pSchema->type, pOutput, TSDB_ORDER_ASC); + pChildrenOutput[i] = malloc(pChild->pSchema->bytes * numOfRows); + reverseCopy(pChildrenOutput[i], pInputData, pChild->pSchema->type, numOfRows, pChild->pSchema->bytes); + pInputs[i].data = pChildrenOutput[i]; } else { - OperatorFn(pLeftOutput, numOfRows, TSDB_DATA_TYPE_DOUBLE, pInputData, numOfRows, pRight->pSchema->type, pOutput, TSDB_ORDER_ASC); + pInputs[i].data = pInputData; } - - } else if (pRight->nodeType == TSQL_NODE_VALUE) { // exprLeft + 12 - _arithmetic_operator_fn_t OperatorFn = getArithmeticOperatorFn(pExprs->_node.optr); - OperatorFn(pLeftOutput, numOfRows, TSDB_DATA_TYPE_DOUBLE, &pRight->pVal->i64, 1, pRight->pVal->nType, pOutput, TSDB_ORDER_ASC); + pInputs[i].numOfRows = (int16_t)numOfRows; + } else if (pChild->nodeType == TSQL_NODE_VALUE) { + pChildrenOutput[i] = malloc(pChild->resultBytes); + tVariantDump(pChild->pVal, pChildrenOutput[i], pChild->resultType, true); + pInputs[i].data = pChildrenOutput[i]; + pInputs[i].numOfRows = 1; } - } else if (pLeft->nodeType == TSQL_NODE_COL) { - // column data specified on left-hand-side - char *pLeftInputData = getSourceDataBlock(param, pLeft->pSchema->name, pLeft->pSchema->colId); - if (pRight->nodeType == TSQL_NODE_EXPR) { // columnLeft + expr2 - _arithmetic_operator_fn_t OperatorFn = getArithmeticOperatorFn(pExprs->_node.optr); + } - if (order == TSDB_ORDER_DESC) { - reverseCopy(pdata, pLeftInputData, pLeft->pSchema->type, numOfRows); - OperatorFn(pdata, numOfRows, pLeft->pSchema->type, pRightOutput, numOfRows, TSDB_DATA_TYPE_DOUBLE, pOutput, TSDB_ORDER_ASC); - } else { - OperatorFn(pLeftInputData, numOfRows, pLeft->pSchema->type, pRightOutput, numOfRows, TSDB_DATA_TYPE_DOUBLE, pOutput, TSDB_ORDER_ASC); - } + _expr_scalar_function_t scalarFn = getExprScalarFunction(pExpr->_func.functionId); + output->type = pExpr->resultType; + output->bytes = pExpr->resultBytes; + output->numOfRows = (int16_t)numOfRows; + scalarFn(pExpr->_func.functionId, pInputs, numChildren, output, TSDB_ORDER_ASC); - } else if (pRight->nodeType == TSQL_NODE_COL) { // columnLeft + columnRight - // column data specified on right-hand-side - char *pRightInputData = getSourceDataBlock(param, pRight->pSchema->name, pRight->pSchema->colId); - _arithmetic_operator_fn_t OperatorFn = getArithmeticOperatorFn(pExprs->_node.optr); + tfree(pChildrenResults); + for (int i = 0; i < numChildren; ++i) { + tfree(pChildrenOutput[i]); + } + tfree(pInputs); + tfree(pChildrenOutput); +} - // both columns are descending order, do not reverse the source data - OperatorFn(pLeftInputData, numOfRows, pLeft->pSchema->type, pRightInputData, numOfRows, pRight->pSchema->type, pOutput, order); - } else if (pRight->nodeType == TSQL_NODE_VALUE) { // columnLeft + 12 - _arithmetic_operator_fn_t OperatorFn = getArithmeticOperatorFn(pExprs->_node.optr); +void exprTreeExprNodeTraverse(tExprNode *pExpr, int32_t numOfRows, tExprOperandInfo *output, void *param, int32_t order, + char *(*getSourceDataBlock)(void *, const char*, int32_t)) { - if (order == TSDB_ORDER_DESC) { - reverseCopy(pdata, pLeftInputData, pLeft->pSchema->type, numOfRows); - OperatorFn(pdata, numOfRows, pLeft->pSchema->type, &pRight->pVal->i64, 1, pRight->pVal->nType, pOutput, TSDB_ORDER_ASC); - } else { - OperatorFn(pLeftInputData, numOfRows, pLeft->pSchema->type, &pRight->pVal->i64, 1, pRight->pVal->nType, pOutput, TSDB_ORDER_ASC); - } + tExprNode *pLeft = pExpr->_node.pLeft; + tExprNode *pRight = pExpr->_node.pRight; + char *ltmp = NULL, *rtmp = NULL; + char *leftIn = NULL, *rightIn = NULL; + int32_t leftNum = 0, rightNum = 0; + int32_t leftType = 0, rightType = 0; + int32_t fnOrder = TSDB_ORDER_ASC; + + if (pLeft->nodeType == TSQL_NODE_EXPR || pLeft->nodeType == TSQL_NODE_FUNC) { + ltmp = (char*)malloc(sizeof(int64_t) * numOfRows); + tExprOperandInfo left; + left.data = ltmp; + exprTreeInternalNodeTraverse(pLeft, numOfRows, &left, param, order, getSourceDataBlock); + + leftIn = ltmp; + leftType = left.type; + leftNum = left.numOfRows; + } else if (pLeft->nodeType == TSQL_NODE_COL) { + char *pInputData = getSourceDataBlock(param, pLeft->pSchema->name, pLeft->pSchema->colId); + if (order == TSDB_ORDER_DESC && (pRight->nodeType != TSQL_NODE_COL)) { + ltmp = malloc(sizeof(int64_t) * numOfRows); + reverseCopy(ltmp, pInputData, pLeft->pSchema->type, numOfRows, pLeft->pSchema->bytes); + leftIn = ltmp; + } else { + leftIn = pInputData; + fnOrder = order; } - } else { - // column data specified on left-hand-side - if (pRight->nodeType == TSQL_NODE_EXPR) { // 12 + expr2 - _arithmetic_operator_fn_t OperatorFn = getArithmeticOperatorFn(pExprs->_node.optr); - OperatorFn(&pLeft->pVal->i64, 1, pLeft->pVal->nType, pRightOutput, numOfRows, TSDB_DATA_TYPE_DOUBLE, pOutput, TSDB_ORDER_ASC); - } else if (pRight->nodeType == TSQL_NODE_COL) { // 12 + columnRight - // column data specified on right-hand-side - char *pRightInputData = getSourceDataBlock(param, pRight->pSchema->name, pRight->pSchema->colId); - _arithmetic_operator_fn_t OperatorFn = getArithmeticOperatorFn(pExprs->_node.optr); - - if (order == TSDB_ORDER_DESC) { - reverseCopy(pdata, pRightInputData, pRight->pSchema->type, numOfRows); - OperatorFn(&pLeft->pVal->i64, 1, pLeft->pVal->nType, pdata, numOfRows, pRight->pSchema->type, pOutput, TSDB_ORDER_ASC); - } else { - OperatorFn(&pLeft->pVal->i64, 1, pLeft->pVal->nType, pRightInputData, numOfRows, pRight->pSchema->type, pOutput, TSDB_ORDER_ASC); - } + leftType = pLeft->pSchema->type; + leftNum = numOfRows; + } else { + assert(pLeft->nodeType == TSQL_NODE_VALUE); + leftIn = (char *)&pLeft->pVal->i64; + leftType = pLeft->pVal->nType; + leftNum = 1; + } - } else if (pRight->nodeType == TSQL_NODE_VALUE) { // 12 + 12 - _arithmetic_operator_fn_t OperatorFn = getArithmeticOperatorFn(pExprs->_node.optr); - OperatorFn(&pLeft->pVal->i64, 1, pLeft->pVal->nType, &pRight->pVal->i64, 1, pRight->pVal->nType, pOutput, TSDB_ORDER_ASC); + if (pRight->nodeType == TSQL_NODE_EXPR || pRight->nodeType == TSQL_NODE_FUNC) { + rtmp = (char*)malloc(sizeof(int64_t) * numOfRows); + tExprOperandInfo right; + right.data = rtmp; + exprTreeInternalNodeTraverse(pRight, numOfRows, &right, param, order, getSourceDataBlock); + + rightIn = rtmp; + rightType = right.type; + rightNum = right.numOfRows; + } else if (pRight->nodeType == TSQL_NODE_COL) { + char *pInputData = getSourceDataBlock(param, pRight->pSchema->name, pRight->pSchema->colId); + if (order == TSDB_ORDER_DESC && (pLeft->nodeType != TSQL_NODE_COL)) { + rtmp = malloc(sizeof(int64_t) * numOfRows); + reverseCopy(rtmp, pInputData, pRight->pSchema->type, numOfRows, pRight->pSchema->bytes); + rightIn = rtmp; + } else { + rightIn = pInputData; + fnOrder = order; } + + rightType = pRight->pSchema->type; + rightNum = numOfRows; + } else { + assert(pRight->nodeType == TSQL_NODE_VALUE); + rightIn = (char *)&pRight->pVal->i64; + rightType = pRight->pVal->nType; + rightNum = 1; } - tfree(pdata); - tfree(pLeftOutput); - tfree(pRightOutput); + _arithmetic_operator_fn_t OperatorFn = getArithmeticOperatorFn(pExpr->_node.optr); + OperatorFn(leftIn, leftNum, leftType, rightIn, rightNum, rightType, output->data, fnOrder); + + output->numOfRows = MAX(leftNum, rightNum); + output->type = TSDB_DATA_TYPE_DOUBLE; + output->bytes = tDataTypes[output->type].bytes; + + tfree(ltmp); + tfree(rtmp); } static void exprTreeToBinaryImpl(SBufferWriter* bw, tExprNode* expr) { @@ -308,7 +522,15 @@ static void exprTreeToBinaryImpl(SBufferWriter* bw, tExprNode* expr) { tbufWriteUint8(bw, expr->_node.hasPK); exprTreeToBinaryImpl(bw, expr->_node.pLeft); exprTreeToBinaryImpl(bw, expr->_node.pRight); + } else if (expr->nodeType == TSQL_NODE_FUNC) { + tbufWriteInt16(bw, expr->_func.functionId); + tbufWriteInt32(bw, expr->_func.numChildren); + for (int i = 0; i < expr->_func.numChildren; ++i) { + exprTreeToBinaryImpl(bw, expr->_func.pChildren[i]); + } } + tbufWriteInt16(bw, expr->resultType); + tbufWriteInt16(bw, expr->resultBytes); } void exprTreeToBinary(SBufferWriter* bw, tExprNode* expr) { @@ -373,8 +595,16 @@ static tExprNode* exprTreeFromBinaryImpl(SBufferReader* br) { pExpr->_node.pLeft = exprTreeFromBinaryImpl(br); pExpr->_node.pRight = exprTreeFromBinaryImpl(br); assert(pExpr->_node.pLeft != NULL && pExpr->_node.pRight != NULL); + } else if (pExpr->nodeType == TSQL_NODE_FUNC) { + pExpr->_func.functionId = tbufReadInt16(br); + pExpr->_func.numChildren = tbufReadInt32(br); + pExpr->_func.pChildren = (tExprNode**)calloc(pExpr->_func.numChildren, sizeof(tExprNode*)); + for (int i = 0; i < pExpr->_func.numChildren; ++i) { + pExpr->_func.pChildren[i] = exprTreeFromBinaryImpl(br); + } } - + pExpr->resultType = tbufReadInt16(br); + pExpr->resultBytes = tbufReadInt16(br); CLEANUP_EXECUTE_TO(anchor, false); return pExpr; } @@ -621,9 +851,854 @@ tExprNode* exprdup(tExprNode* pNode) { } else if (pNode->nodeType == TSQL_NODE_COL) { pCloned->pSchema = calloc(1, sizeof(SSchema)); *pCloned->pSchema = *pNode->pSchema; - } - + } else if (pNode->nodeType == TSQL_NODE_FUNC) { + pCloned->_func.functionId = pNode->_func.functionId; + pCloned->_func.numChildren = pNode->_func.numChildren; + pCloned->_func.pChildren = calloc(pNode->_func.numChildren, sizeof(tExprNode*)); + for (int i = 0; i < pNode->_func.numChildren; ++i) { + pCloned->_func.pChildren[i] = exprdup(pNode->_func.pChildren[i]); + } + } else if (pNode->nodeType == TSQL_NODE_TYPE) { + pCloned->pType = calloc(1, sizeof(TAOS_FIELD)); + *pCloned->pType = *pNode->pType; + } + pCloned->nodeType = pNode->nodeType; + pCloned->resultType = pNode->resultType; + pCloned->resultBytes = pNode->resultBytes; return pCloned; } +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +// scalar functions +int32_t exprValidateStringConcatNode(tExprNode *pExpr) { + if (pExpr->_func.numChildren < 2 || pExpr->_func.numChildren > 8) { + return TSDB_CODE_TSC_INVALID_OPERATION; + } + + int16_t prevResultType = TSDB_DATA_TYPE_NULL; + int16_t resultType = TSDB_DATA_TYPE_NULL; + bool resultTypeDeduced = false; + for (int32_t i = 0; i < pExpr->_func.numChildren; ++i) { + tExprNode *child = pExpr->_func.pChildren[i]; + if (child->nodeType != TSQL_NODE_VALUE) { + resultType = child->resultType; + if (!IS_VAR_DATA_TYPE(resultType)) { + return TSDB_CODE_TSC_INVALID_OPERATION; + } + if (!resultTypeDeduced) { + resultTypeDeduced = true; + } else { + if (resultType != prevResultType) { + return TSDB_CODE_TSC_INVALID_OPERATION; + } + } + prevResultType = child->resultType; + } else { + if (!IS_VAR_DATA_TYPE(child->resultType)) { + return TSDB_CODE_TSC_INVALID_OPERATION; + } + } + } + + if (resultTypeDeduced) { + for (int32_t i = 0; i < pExpr->_func.numChildren; ++i) { + tExprNode *child = pExpr->_func.pChildren[i]; + if (child->nodeType == TSQL_NODE_VALUE) { + if (!IS_VAR_DATA_TYPE(child->pVal->nType)) { + return TSDB_CODE_TSC_INVALID_OPERATION; + } + char* payload = malloc(child->pVal->nLen * TSDB_NCHAR_SIZE + VARSTR_HEADER_SIZE); + tVariantDump(child->pVal, payload, resultType, true); + int16_t resultBytes = varDataTLen(payload); + free(payload); + child->resultType = resultType; + child->resultBytes = (int16_t)(resultBytes); + } + } + } else { + for (int32_t i = 0; i < pExpr->_func.numChildren; ++i) { + tExprNode *child = pExpr->_func.pChildren[i]; + assert(child->nodeType == TSQL_NODE_VALUE) ; + resultType = child->resultType; + for (int j = i+1; j < pExpr->_func.numChildren; ++j) { + if (pExpr->_func.pChildren[j]->resultType != resultType) { + return TSDB_CODE_TSC_INVALID_OPERATION; + } + } + } + } + + pExpr->resultType = resultType; + int16_t resultBytes = 0; + for (int32_t i = 0; i < pExpr->_func.numChildren; ++i) { + tExprNode *child = pExpr->_func.pChildren[i]; + if (resultBytes <= resultBytes + child->resultBytes - VARSTR_HEADER_SIZE) { + resultBytes += child->resultBytes - VARSTR_HEADER_SIZE; + } else { + return TSDB_CODE_TSC_INVALID_OPERATION; + } + } + pExpr->resultBytes = resultBytes + VARSTR_HEADER_SIZE; + return TSDB_CODE_SUCCESS; +} + +int32_t exprValidateStringConcatWsNode(tExprNode *pExpr) { + if (pExpr->_func.numChildren < 3 || pExpr->_func.numChildren > 9) { + return TSDB_CODE_TSC_INVALID_OPERATION; + } + + int16_t prevResultType = TSDB_DATA_TYPE_NULL; + int16_t resultType = TSDB_DATA_TYPE_NULL; + bool resultTypeDeduced = false; + for (int32_t i = 0; i < pExpr->_func.numChildren; ++i) { + tExprNode *child = pExpr->_func.pChildren[i]; + if (child->nodeType != TSQL_NODE_VALUE) { + resultType = child->resultType; + if (!IS_VAR_DATA_TYPE(resultType)) { + return TSDB_CODE_TSC_INVALID_OPERATION; + } + if (!resultTypeDeduced) { + resultTypeDeduced = true; + } else { + if (resultType != prevResultType) { + return TSDB_CODE_TSC_INVALID_OPERATION; + } + } + prevResultType = child->resultType; + } else { + if (!IS_VAR_DATA_TYPE(child->resultType)) { + return TSDB_CODE_TSC_INVALID_OPERATION; + } + } + } + + if (resultTypeDeduced) { + for (int32_t i = 0; i < pExpr->_func.numChildren; ++i) { + tExprNode *child = pExpr->_func.pChildren[i]; + if (child->nodeType == TSQL_NODE_VALUE) { + if (!IS_VAR_DATA_TYPE(child->pVal->nType)) { + return TSDB_CODE_TSC_INVALID_OPERATION; + } + char* payload = malloc(child->pVal->nLen * TSDB_NCHAR_SIZE + VARSTR_HEADER_SIZE); + tVariantDump(child->pVal, payload, resultType, true); + int16_t resultBytes = varDataTLen(payload); + free(payload); + child->resultType = resultType; + child->resultBytes = (int16_t)(resultBytes); + } + } + } else { + for (int32_t i = 0; i < pExpr->_func.numChildren; ++i) { + tExprNode *child = pExpr->_func.pChildren[i]; + assert(child->nodeType == TSQL_NODE_VALUE) ; + resultType = child->resultType; + for (int j = i+1; j < pExpr->_func.numChildren; ++j) { + if (pExpr->_func.pChildren[j]->resultType != resultType) { + return TSDB_CODE_TSC_INVALID_OPERATION; + } + } + } + } + + pExpr->resultType = resultType; + int16_t resultBytes = 0; + for (int32_t i = 1; i < pExpr->_func.numChildren; ++i) { + tExprNode *child = pExpr->_func.pChildren[i]; + if (resultBytes <= resultBytes + child->resultBytes - VARSTR_HEADER_SIZE) { + resultBytes += child->resultBytes - VARSTR_HEADER_SIZE; + } else { + return TSDB_CODE_TSC_INVALID_OPERATION; + } + } + tExprNode* wsNode = pExpr->_func.pChildren[0]; + int16_t wsResultBytes = wsNode->resultBytes - VARSTR_HEADER_SIZE; + resultBytes += wsResultBytes * (pExpr->_func.numChildren - 2); + pExpr->resultBytes = resultBytes + VARSTR_HEADER_SIZE; + return TSDB_CODE_SUCCESS; +} + + +int32_t exprValidateStringLengthNode(tExprNode *pExpr) { + if (pExpr->_func.numChildren != 1) { + return TSDB_CODE_TSC_INVALID_OPERATION; + } + + tExprNode* child1 = pExpr->_func.pChildren[0]; + + if (child1->nodeType == TSQL_NODE_VALUE) { + child1->resultType = (int16_t)child1->pVal->nType; + child1->resultBytes = (int16_t)(child1->pVal->nLen + VARSTR_HEADER_SIZE); + } + + if (!IS_VAR_DATA_TYPE(child1->resultType)) { + return TSDB_CODE_TSC_INVALID_OPERATION; + } + + pExpr->resultType = TSDB_DATA_TYPE_INT; + pExpr->resultBytes = tDataTypes[TSDB_DATA_TYPE_INT].bytes; + + return TSDB_CODE_SUCCESS; +} + +int32_t exprValidateCastNode(char* msgbuf, tExprNode *pExpr) { + const char* msg1 = "invalid param num for cast function"; + const char* msg2 = "the second param should be a valid type name for cast function"; + const char* msg3 = "target type is not supported for cast function"; + const char* msg4 = "not supported type convertion for cast function"; + + if (pExpr->_func.numChildren != 2) { + return exprInvalidOperationMsg(msgbuf, msg1); + } + + tExprNode* child0 = pExpr->_func.pChildren[0]; + tExprNode* child1 = pExpr->_func.pChildren[1]; + + if (child1->nodeType != TSQL_NODE_TYPE) { + return exprInvalidOperationMsg(msgbuf, msg2); + } + + if (child1->resultType != TSDB_DATA_TYPE_BIGINT && child1->resultType != TSDB_DATA_TYPE_UBIGINT + && child1->resultType != TSDB_DATA_TYPE_TIMESTAMP && child1->resultType != TSDB_DATA_TYPE_BINARY + && child1->resultType != TSDB_DATA_TYPE_NCHAR) { + return exprInvalidOperationMsg(msgbuf, msg3); + } + + if ((child0->resultType == TSDB_DATA_TYPE_BINARY && child1->resultType == TSDB_DATA_TYPE_TIMESTAMP) + || (child0->resultType == TSDB_DATA_TYPE_TIMESTAMP && (child1->resultType == TSDB_DATA_TYPE_BINARY || child1->resultType == TSDB_DATA_TYPE_NCHAR)) + || (child0->resultType == TSDB_DATA_TYPE_NCHAR && (child1->resultType == TSDB_DATA_TYPE_BINARY || child1->resultType == TSDB_DATA_TYPE_TIMESTAMP))) { + return exprInvalidOperationMsg(msgbuf, msg4); + } + + pExpr->resultType = child1->resultType; + pExpr->resultBytes = child1->resultBytes; + + doExprTreeDestroy(&pExpr->_func.pChildren[1], NULL); + pExpr->_func.numChildren = 1; + + return TSDB_CODE_SUCCESS; +} + + +int32_t exprValidateMathNode(tExprNode *pExpr) { + switch (pExpr->_func.functionId) { + case TSDB_FUNC_SCALAR_POW: + case TSDB_FUNC_SCALAR_LOG: { + if (pExpr->_func.numChildren != 2) { + return TSDB_CODE_TSC_INVALID_OPERATION; + } + tExprNode *child1 = pExpr->_func.pChildren[0]; + tExprNode *child2 = pExpr->_func.pChildren[1]; + if (!IS_NUMERIC_TYPE(child1->resultType) || !IS_NUMERIC_TYPE(child2->resultType)) { + return TSDB_CODE_TSC_INVALID_OPERATION; + } + + pExpr->resultType = TSDB_DATA_TYPE_DOUBLE; + pExpr->resultBytes = tDataTypes[TSDB_DATA_TYPE_DOUBLE].bytes; + + return TSDB_CODE_SUCCESS; + } + case TSDB_FUNC_SCALAR_ABS: { + if (pExpr->_func.numChildren != 1) { + return TSDB_CODE_TSC_INVALID_OPERATION; + } + tExprNode *child1 = pExpr->_func.pChildren[0]; + if (!IS_NUMERIC_TYPE(child1->resultType)) { + return TSDB_CODE_TSC_INVALID_OPERATION; + } + if (IS_SIGNED_NUMERIC_TYPE(child1->resultType) || IS_UNSIGNED_NUMERIC_TYPE(child1->resultType)) { + pExpr->resultType = TSDB_DATA_TYPE_UBIGINT; + pExpr->resultBytes = tDataTypes[TSDB_DATA_TYPE_UBIGINT].bytes; + } else if (IS_FLOAT_TYPE(child1->resultType)) { + pExpr->resultType = TSDB_DATA_TYPE_DOUBLE; + pExpr->resultBytes = tDataTypes[TSDB_DATA_TYPE_DOUBLE].bytes; + } + break; + } + case TSDB_FUNC_SCALAR_SQRT: + case TSDB_FUNC_SCALAR_ASIN: + case TSDB_FUNC_SCALAR_ACOS: + case TSDB_FUNC_SCALAR_ATAN: + case TSDB_FUNC_SCALAR_SIN: + case TSDB_FUNC_SCALAR_COS: + case TSDB_FUNC_SCALAR_TAN: { + if (pExpr->_func.numChildren != 1) { + return TSDB_CODE_TSC_INVALID_OPERATION; + } + tExprNode *child1 = pExpr->_func.pChildren[0]; + if (!IS_NUMERIC_TYPE(child1->resultType)) { + return TSDB_CODE_TSC_INVALID_OPERATION; + } + pExpr->resultType = TSDB_DATA_TYPE_DOUBLE; + pExpr->resultBytes = tDataTypes[TSDB_DATA_TYPE_DOUBLE].bytes; + break; + } + + case TSDB_FUNC_SCALAR_CEIL: + case TSDB_FUNC_SCALAR_FLOOR: + case TSDB_FUNC_SCALAR_ROUND: { + if (pExpr->_func.numChildren != 1) { + return TSDB_CODE_TSC_INVALID_OPERATION; + } + tExprNode* child = pExpr->_func.pChildren[0]; + if (!IS_NUMERIC_TYPE(child->resultType)) { + return TSDB_CODE_TSC_INVALID_OPERATION; + } + pExpr->resultType = child->resultType; + pExpr->resultBytes = child->resultBytes; + break; + } + default: { + assert(false); + break; + } + } + return TSDB_CODE_SUCCESS; +} + +void vectorConcat(int16_t functionId, tExprOperandInfo* pInputs, int32_t numInputs, tExprOperandInfo* pOutput, int32_t order) { + assert(functionId == TSDB_FUNC_SCALAR_CONCAT && numInputs >=2 && order == TSDB_ORDER_ASC); + for (int i = 0; i < numInputs; ++i) { + assert(pInputs[i].numOfRows == 1 || pInputs[i].numOfRows == pOutput->numOfRows); + } + + char* outputData = NULL; + char** inputData = calloc(numInputs, sizeof(char*)); + for (int i = 0; i < pOutput->numOfRows; ++i) { + for (int j = 0; j < numInputs; ++j) { + if (pInputs[j].numOfRows == 1) { + inputData[j] = pInputs[j].data; + } else { + inputData[j] = pInputs[j].data + i * pInputs[j].bytes; + } + } + + outputData = pOutput->data + i * pOutput->bytes; + + bool hasNullInputs = false; + for (int j = 0; j < numInputs; ++j) { + if (isNull(inputData[j], pInputs[j].type)) { + hasNullInputs = true; + setNull(outputData, pOutput->type, pOutput->bytes); + } + } + + if (!hasNullInputs) { + int16_t dataLen = 0; + for (int j = 0; j < numInputs; ++j) { + memcpy(((char*)varDataVal(outputData))+dataLen, varDataVal(inputData[j]), varDataLen(inputData[j])); + dataLen += varDataLen(inputData[j]); + } + varDataSetLen(outputData, dataLen); + } + } + + free(inputData); +} + +void vectorConcatWs(int16_t functionId, tExprOperandInfo* pInputs, int32_t numInputs, tExprOperandInfo* pOutput, int32_t order) { + assert(functionId == TSDB_FUNC_SCALAR_CONCAT_WS && numInputs >=3 && order == TSDB_ORDER_ASC); + for (int i = 0; i < numInputs; ++i) { + assert(pInputs[i].numOfRows == 1 || pInputs[i].numOfRows == pOutput->numOfRows); + } + + char* outputData = NULL; + char** inputData = calloc(numInputs, sizeof(char*)); + for (int i = 0; i < pOutput->numOfRows; ++i) { + for (int j = 0; j < numInputs; ++j) { + if (pInputs[j].numOfRows == 1) { + inputData[j] = pInputs[j].data; + } else { + inputData[j] = pInputs[j].data + i * pInputs[j].bytes; + } + } + + outputData = pOutput->data + i * pOutput->bytes; + + if (isNull(inputData[0], pInputs[0].type)) { + setNull(outputData, pOutput->type, pOutput->bytes); + continue; + } + + int16_t dataLen = 0; + for (int j = 1; j < numInputs; ++j) { + if (isNull(inputData[j], pInputs[j].type)) { + continue; + } + memcpy(((char*)varDataVal(outputData))+dataLen, varDataVal(inputData[j]), varDataLen(inputData[j])); + dataLen += varDataLen(inputData[j]); + if (j < numInputs - 1) { + memcpy(((char*)varDataVal(outputData))+dataLen, varDataVal(inputData[0]), varDataLen(inputData[0])); + dataLen += varDataLen(inputData[0]); + } + } + varDataSetLen(outputData, dataLen); + } + + + free(inputData); +} + +void vectorLength(int16_t functionId, tExprOperandInfo *pInputs, int32_t numInputs, tExprOperandInfo* pOutput, int32_t order) { + assert(functionId == TSDB_FUNC_SCALAR_LENGTH && numInputs == 1 && order == TSDB_ORDER_ASC); + assert(IS_VAR_DATA_TYPE(pInputs[0].type)); + + char* data0 = NULL; + char* outputData = NULL; + for (int32_t i = 0; i < pOutput->numOfRows; ++i) { + if (pInputs[0].numOfRows == 1) { + data0 = pInputs[0].data; + } else { + data0 = pInputs[0].data + i * pInputs[0].bytes; + } + + outputData = pOutput->data + i * pOutput->bytes; + if (isNull(data0, pInputs[0].type)) { + setNull(outputData, pOutput->type, pOutput->bytes); + } else { + int16_t result = varDataLen(data0); + SET_TYPED_DATA(outputData, pOutput->type, result); + } + } +} + +void castConvert(int16_t inputType, int16_t inputBytes, char *input, int16_t OutputType, int16_t outputBytes, char *output) { + switch (OutputType) { + case TSDB_DATA_TYPE_BIGINT: + if (inputType == TSDB_DATA_TYPE_BINARY) { + char *tmp = malloc(varDataLen(input) + 1); + memcpy(tmp, varDataVal(input), varDataLen(input)); + tmp[varDataLen(input)] = 0; + *(int64_t *)output = strtoll(tmp, NULL, 10); + free(tmp); + } else if (inputType == TSDB_DATA_TYPE_NCHAR) { + char *newColData = calloc(1, outputBytes * TSDB_NCHAR_SIZE + 1); + int len = taosUcs4ToMbs(varDataVal(input), varDataLen(input), newColData); + newColData[len] = 0; + *(int64_t *)output = strtoll(newColData, NULL, 10); + tfree(newColData); + } else { + GET_TYPED_DATA(*(int64_t *)output, int64_t, inputType, input); + } + break; + case TSDB_DATA_TYPE_UBIGINT: + if (inputType == TSDB_DATA_TYPE_BINARY) { + char *tmp = malloc(varDataLen(input) + 1); + memcpy(tmp, varDataVal(input), varDataLen(input)); + tmp[varDataLen(input)] = 0; + *(uint64_t *)output = strtoull(tmp, NULL, 10); + free(tmp); + } else if (inputType == TSDB_DATA_TYPE_NCHAR) { + char *newColData = calloc(1, outputBytes * TSDB_NCHAR_SIZE + 1); + int len = taosUcs4ToMbs(varDataVal(input), varDataLen(input), newColData); + newColData[len] = 0; + *(int64_t *)output = strtoull(newColData, NULL, 10); + tfree(newColData); + } else { + GET_TYPED_DATA(*(uint64_t *)output, uint64_t, inputType, input); + } + break; + case TSDB_DATA_TYPE_TIMESTAMP: + if (inputType == TSDB_DATA_TYPE_BINARY || inputType == TSDB_DATA_TYPE_NCHAR) { + assert(0); + } else { + GET_TYPED_DATA(*(int64_t *)output, int64_t, inputType, input); + } + break; + case TSDB_DATA_TYPE_BINARY: + if (inputType == TSDB_DATA_TYPE_BOOL) { + int32_t len = sprintf(varDataVal(output), "%.*s", (int32_t)(outputBytes - VARSTR_HEADER_SIZE), *(int8_t*)input ? "true" : "false"); + varDataSetLen(output, len); + } else if (inputType == TSDB_DATA_TYPE_BINARY) { + char *tmp = malloc(varDataLen(input) + 1); + memcpy(tmp, varDataVal(input), varDataLen(input)); + tmp[varDataLen(input)] = 0; + int32_t len = sprintf(varDataVal(output), "%.*s", (int32_t)(outputBytes - VARSTR_HEADER_SIZE), tmp); + varDataSetLen(output, len); + free(tmp); + } else if (inputType == TSDB_DATA_TYPE_TIMESTAMP || inputType == TSDB_DATA_TYPE_NCHAR) { + assert(0); + } else { + char tmp[400] = {0}; + NUM_TO_STRING(inputType, input, sizeof(tmp), tmp); + int32_t len = (int32_t)strlen(tmp); + len = (outputBytes - VARSTR_HEADER_SIZE) > len ? len : (outputBytes - VARSTR_HEADER_SIZE); + memcpy(varDataVal(output), tmp, len); + varDataSetLen(output, len); + } + break; + case TSDB_DATA_TYPE_NCHAR: { + int32_t ncharSize = (outputBytes - VARSTR_HEADER_SIZE) / TSDB_NCHAR_SIZE; + if (inputType == TSDB_DATA_TYPE_BOOL) { + char tmp[8] = {0}; + int32_t len = sprintf(tmp, "%.*s", ncharSize, *(int8_t*)input ? "true" : "false"); + taosMbsToUcs4(tmp, len, varDataVal(output), outputBytes - VARSTR_HEADER_SIZE, &len); + varDataSetLen(output, len); + } else if (inputType == TSDB_DATA_TYPE_BINARY) { + int32_t len = ncharSize > varDataLen(input) ? varDataLen(input) : ncharSize; + taosMbsToUcs4(input + VARSTR_HEADER_SIZE, len, varDataVal(output), outputBytes - VARSTR_HEADER_SIZE, &len); + varDataSetLen(output, len); + } else if (inputType == TSDB_DATA_TYPE_TIMESTAMP) { + assert(0); + } else if (inputType == TSDB_DATA_TYPE_NCHAR) { + int32_t len = (inputBytes > outputBytes) ? outputBytes : inputBytes; + memcpy(output, input, len); + varDataSetLen(output, len - VARSTR_HEADER_SIZE); + } else { + char tmp[400] = {0}; + NUM_TO_STRING(inputType, input, sizeof(tmp), tmp); + int32_t len = (int32_t)(ncharSize > strlen(tmp) ? strlen(tmp) : ncharSize); + taosMbsToUcs4(tmp, len, varDataVal(output), outputBytes - VARSTR_HEADER_SIZE, &len); + varDataSetLen(output, len); + } + break; + } + default: + assert(0); + break; + } +} + +void vectorCharLength(int16_t functionId, tExprOperandInfo *pInputs, int32_t numInputs, tExprOperandInfo* pOutput, int32_t order) { + assert(functionId == TSDB_FUNC_SCALAR_CHAR_LENGTH && numInputs == 1 && order == TSDB_ORDER_ASC); + assert(IS_VAR_DATA_TYPE(pInputs[0].type)); + + char* data0 = NULL; + char* outputData = NULL; + for (int32_t i = 0; i < pOutput->numOfRows; ++i) { + if (pInputs[0].numOfRows == 1) { + data0 = pInputs[0].data; + } else { + data0 = pInputs[0].data + i * pInputs[0].bytes; + } + + outputData = pOutput->data + i * pOutput->bytes; + if (isNull(data0, pInputs[0].type)) { + setNull(outputData, pOutput->type, pOutput->bytes); + } else { + int16_t result = varDataLen(data0); + if (pInputs[0].type == TSDB_DATA_TYPE_BINARY) { + SET_TYPED_DATA(outputData, pOutput->type, result); + } else if (pInputs[0].type == TSDB_DATA_TYPE_NCHAR) { + SET_TYPED_DATA(outputData, pOutput->type, result/TSDB_NCHAR_SIZE); + } + } + } +} + +void vectorMathFunc(int16_t functionId, tExprOperandInfo *pInputs, int32_t numInputs, tExprOperandInfo* pOutput, int32_t order) { + for (int i = 0; i < numInputs; ++i) { + assert(pInputs[i].numOfRows == 1 || pInputs[i].numOfRows == pOutput->numOfRows); + } + + char* outputData = NULL; + char** inputData = calloc(numInputs, sizeof(char*)); + for (int i = 0; i < pOutput->numOfRows; ++i) { + for (int j = 0; j < numInputs; ++j) { + if (pInputs[j].numOfRows == 1) { + inputData[j] = pInputs[j].data; + } else { + inputData[j] = pInputs[j].data + i * pInputs[j].bytes; + } + } + + outputData = pOutput->data + i * pOutput->bytes; + + bool hasNullInputs = false; + for (int j = 0; j < numInputs; ++j) { + if (isNull(inputData[j], pInputs[j].type)) { + hasNullInputs = true; + setNull(outputData, pOutput->type, pOutput->bytes); + } + } + + if (!hasNullInputs) { + switch (functionId) { + case TSDB_FUNC_SCALAR_LOG: { + assert(numInputs == 2); + double base = 0; + GET_TYPED_DATA(base, double, pInputs[1].type, inputData[1]); + double v1 = 0; + GET_TYPED_DATA(v1, double, pInputs[0].type, inputData[0]); + double result = log(v1) / log(base); + SET_TYPED_DATA(outputData, pOutput->type, result); + break; + } + + case TSDB_FUNC_SCALAR_POW:{ + assert(numInputs == 2); + double base = 0; + GET_TYPED_DATA(base, double, pInputs[1].type, inputData[1]); + double v1 = 0; + GET_TYPED_DATA(v1, double, pInputs[0].type, inputData[0]); + double result = pow(v1, base); + SET_TYPED_DATA(outputData, pOutput->type, result); + break; + } + + case TSDB_FUNC_SCALAR_ABS: { + assert(numInputs == 1); + assert(IS_NUMERIC_TYPE(pInputs[0].type)); + if (IS_SIGNED_NUMERIC_TYPE(pInputs[0].type)) { + int64_t v1 = 0; + GET_TYPED_DATA(v1, int64_t, pInputs[0].type, inputData[0]); + uint64_t result = (uint64_t)(llabs(v1)); + SET_TYPED_DATA(outputData, pOutput->type, result); + } else if (IS_UNSIGNED_NUMERIC_TYPE(pInputs[0].type)) { + uint64_t v1 = 0; + GET_TYPED_DATA(v1, uint64_t, pInputs[0].type, inputData[0]); + SET_TYPED_DATA(outputData, pOutput->type, v1); + } else if (IS_FLOAT_TYPE(pInputs[0].type)) { + double v1 = 0; + GET_TYPED_DATA(v1, double, pInputs[0].type, inputData[0]); + double result = fabs(v1); + SET_TYPED_DATA(outputData, pOutput->type, result); + } + break; + } + case TSDB_FUNC_SCALAR_SQRT: { + assert(numInputs == 1); + assert(IS_NUMERIC_TYPE(pInputs[0].type)); + + double v1 = 0; + GET_TYPED_DATA(v1, double, pInputs[0].type, inputData[0]); + double result = sqrt(v1); + SET_TYPED_DATA(outputData, pOutput->type, result); + + break; + } + case TSDB_FUNC_SCALAR_ASIN: { + assert(numInputs == 1); + assert(IS_NUMERIC_TYPE(pInputs[0].type)); + + double v1 = 0; + GET_TYPED_DATA(v1, double, pInputs[0].type, inputData[0]); + double result = asin(v1); + SET_TYPED_DATA(outputData, pOutput->type, result); + break; + } + case TSDB_FUNC_SCALAR_ACOS: { + assert(numInputs == 1); + assert(IS_NUMERIC_TYPE(pInputs[0].type)); + + double v1 = 0; + GET_TYPED_DATA(v1, double, pInputs[0].type, inputData[0]); + double result = acos(v1); + SET_TYPED_DATA(outputData, pOutput->type, result); + break; + } + case TSDB_FUNC_SCALAR_ATAN: { + assert(numInputs == 1); + assert(IS_NUMERIC_TYPE(pInputs[0].type)); + + double v1 = 0; + GET_TYPED_DATA(v1, double, pInputs[0].type, inputData[0]); + double result = atan(v1); + SET_TYPED_DATA(outputData, pOutput->type, result); + break; + } + case TSDB_FUNC_SCALAR_SIN: { + assert(numInputs == 1); + assert(IS_NUMERIC_TYPE(pInputs[0].type)); + + double v1 = 0; + GET_TYPED_DATA(v1, double, pInputs[0].type, inputData[0]); + double result = sin(v1); + SET_TYPED_DATA(outputData, pOutput->type, result); + break; + } + case TSDB_FUNC_SCALAR_COS: { + assert(numInputs == 1); + assert(IS_NUMERIC_TYPE(pInputs[0].type)); + + double v1 = 0; + GET_TYPED_DATA(v1, double, pInputs[0].type, inputData[0]); + double result = cos(v1); + SET_TYPED_DATA(outputData, pOutput->type, result); + break; + } + case TSDB_FUNC_SCALAR_TAN:{ + assert(numInputs == 1); + assert(IS_NUMERIC_TYPE(pInputs[0].type)); + + double v1 = 0; + GET_TYPED_DATA(v1, double, pInputs[0].type, inputData[0]); + double result = tan(v1); + SET_TYPED_DATA(outputData, pOutput->type, result); + break; + } + + case TSDB_FUNC_SCALAR_CEIL: { + assert(numInputs == 1); + assert(IS_NUMERIC_TYPE(pInputs[0].type)); + if (IS_UNSIGNED_NUMERIC_TYPE(pInputs[0].type) || IS_SIGNED_NUMERIC_TYPE(pInputs[0].type)) { + memcpy(outputData, inputData[0], pInputs[0].bytes); + } else { + if (pInputs[0].type == TSDB_DATA_TYPE_FLOAT) { + float v = 0; + GET_TYPED_DATA(v, float, pInputs[0].type, inputData[0]); + float result = ceilf(v); + SET_TYPED_DATA(outputData, pOutput->type, result); + } else if (pInputs[0].type == TSDB_DATA_TYPE_DOUBLE) { + double v = 0; + GET_TYPED_DATA(v, double, pInputs[0].type, inputData[0]); + double result = ceil(v); + SET_TYPED_DATA(outputData, pOutput->type, result); + } + } + break; + } + case TSDB_FUNC_SCALAR_FLOOR: { + assert(numInputs == 1); + assert(IS_NUMERIC_TYPE(pInputs[0].type)); + if (IS_UNSIGNED_NUMERIC_TYPE(pInputs[0].type) || IS_SIGNED_NUMERIC_TYPE(pInputs[0].type)) { + memcpy(outputData, inputData[0], pInputs[0].bytes); + } else { + if (pInputs[0].type == TSDB_DATA_TYPE_FLOAT) { + float v = 0; + GET_TYPED_DATA(v, float, pInputs[0].type, inputData[0]); + float result = floorf(v); + SET_TYPED_DATA(outputData, pOutput->type, result); + } else if (pInputs[0].type == TSDB_DATA_TYPE_DOUBLE) { + double v = 0; + GET_TYPED_DATA(v, double, pInputs[0].type, inputData[0]); + double result = floor(v); + SET_TYPED_DATA(outputData, pOutput->type, result); + } + } + break; + } + + case TSDB_FUNC_SCALAR_ROUND: { + assert(numInputs == 1); + assert(IS_NUMERIC_TYPE(pInputs[0].type)); + if (IS_UNSIGNED_NUMERIC_TYPE(pInputs[0].type) || IS_SIGNED_NUMERIC_TYPE(pInputs[0].type)) { + memcpy(outputData, inputData[0], pInputs[0].bytes); + } else { + if (pInputs[0].type == TSDB_DATA_TYPE_FLOAT) { + float v = 0; + GET_TYPED_DATA(v, float, pInputs[0].type, inputData[0]); + float result = roundf(v); + SET_TYPED_DATA(outputData, pOutput->type, result); + } else if (pInputs[0].type == TSDB_DATA_TYPE_DOUBLE) { + double v = 0; + GET_TYPED_DATA(v, double, pInputs[0].type, inputData[0]); + double result = round(v); + SET_TYPED_DATA(outputData, pOutput->type, result); + } + } + break; + } + case TSDB_FUNC_SCALAR_CAST: { + castConvert(pInputs[0].type, pInputs[0].bytes, inputData[0], pOutput->type, pOutput->bytes, outputData); + break; + } + default: { + assert(false); + break; + } + } // end switch function(id) + } // end can produce value, all child has value + } // end for each row + free(inputData); +} + +_expr_scalar_function_t getExprScalarFunction(uint16_t funcId) { + assert(TSDB_FUNC_IS_SCALAR(funcId)); + int16_t scalaIdx = TSDB_FUNC_SCALAR_INDEX(funcId); + assert(scalaIdx>=0 && scalaIdx <= TSDB_FUNC_SCALAR_MAX_NUM); + return aScalarFunctions[scalaIdx].scalarFunc; +} + +tScalarFunctionInfo aScalarFunctions[] = { + { + TSDB_FUNC_SCALAR_POW, + "pow", + vectorMathFunc + }, + { + TSDB_FUNC_SCALAR_LOG, + "log", + vectorMathFunc + }, + { + TSDB_FUNC_SCALAR_ABS, + "abs", + vectorMathFunc, + }, + { + TSDB_FUNC_SCALAR_ACOS, + "acos", + vectorMathFunc, + }, + { + TSDB_FUNC_SCALAR_ASIN, + "asin", + vectorMathFunc, + }, + { + TSDB_FUNC_SCALAR_ATAN, + "atan", + vectorMathFunc, + }, + { + TSDB_FUNC_SCALAR_COS, + "cos", + vectorMathFunc, + }, + { + TSDB_FUNC_SCALAR_SIN, + "sin", + vectorMathFunc, + }, + { + TSDB_FUNC_SCALAR_TAN, + "tan", + vectorMathFunc, + }, + { + TSDB_FUNC_SCALAR_SQRT, + "sqrt", + vectorMathFunc, + }, + { + TSDB_FUNC_SCALAR_CEIL, + "ceil", + vectorMathFunc, + }, + { + TSDB_FUNC_SCALAR_FLOOR, + "floor", + vectorMathFunc, + }, + { + TSDB_FUNC_SCALAR_ROUND, + "round", + vectorMathFunc + }, + { + TSDB_FUNC_SCALAR_CONCAT, + "concat", + vectorConcat + }, + { + TSDB_FUNC_SCALAR_LENGTH, + "length", + vectorLength + }, + { + TSDB_FUNC_SCALAR_CONCAT_WS, + "concat_ws", + vectorConcatWs + }, + { + TSDB_FUNC_SCALAR_CHAR_LENGTH, + "char_length", + vectorCharLength + }, + { + TSDB_FUNC_SCALAR_CAST, + "cast", + vectorMathFunc + }, +}; diff --git a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/AbstractStatementWrapper.java b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/AbstractStatementWrapper.java deleted file mode 100644 index 0b46226d1113b82d9333204427eaad074d3572cb..0000000000000000000000000000000000000000 --- a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/AbstractStatementWrapper.java +++ /dev/null @@ -1,51 +0,0 @@ -package com.taosdata.jdbc; - -import java.sql.*; - -public class AbstractStatementWrapper extends AbstractStatement{ - protected Statement statement; - - public AbstractStatementWrapper(Statement statement) { - this.statement = statement; - } - - @Override - public ResultSet executeQuery(String sql) throws SQLException { - return statement.executeQuery(sql); - } - - @Override - public int executeUpdate(String sql) throws SQLException { - return statement.executeUpdate(sql); - } - - @Override - public void close() throws SQLException { - statement.close(); - } - - @Override - public boolean execute(String sql) throws SQLException { - return statement.execute(sql); - } - - @Override - public ResultSet getResultSet() throws SQLException { - return statement.getResultSet(); - } - - @Override - public int getUpdateCount() throws SQLException { - return statement.getUpdateCount(); - } - - @Override - public Connection getConnection() throws SQLException { - return statement.getConnection(); - } - - @Override - public boolean isClosed() throws SQLException { - return statement.isClosed(); - } -} diff --git a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/SchemalessStatement.java b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/SchemalessStatement.java deleted file mode 100644 index d1184abc2722d81e8688a024d08e26200d104ce8..0000000000000000000000000000000000000000 --- a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/SchemalessStatement.java +++ /dev/null @@ -1,54 +0,0 @@ -package com.taosdata.jdbc; - -import com.taosdata.jdbc.enums.SchemalessProtocolType; -import com.taosdata.jdbc.enums.SchemalessTimestampType; -import com.taosdata.jdbc.rs.RestfulConnection; - -import java.sql.Connection; -import java.sql.SQLException; -import java.sql.Statement; - -/** - * this class is an extension of {@link Statement}. e.g.: - * Statement statement = conn.createStatement(); - * SchemalessStatement schemalessStatement = new SchemalessStatement(statement); - * schemalessStatement.execute(sql); - * schemalessStatement.insert(lines, SchemalessProtocolType, SchemalessTimestampType); - */ -public class SchemalessStatement extends AbstractStatementWrapper { - public SchemalessStatement(Statement statement) { - super(statement); - } - - /** - * batch insert schemaless lines - * - * @param lines schemaless lines - * @param protocolType schemaless type {@link SchemalessProtocolType} - * @param timestampType Time precision {@link SchemalessTimestampType} - * @throws SQLException execute insert exception - */ - public void insert(String[] lines, SchemalessProtocolType protocolType, SchemalessTimestampType timestampType) throws SQLException { - Connection connection = this.getConnection(); - if (connection instanceof TSDBConnection) { - TSDBConnection tsdbConnection = (TSDBConnection) connection; - tsdbConnection.getConnector().insertLines(lines, protocolType, timestampType); - } else if (connection instanceof RestfulConnection) { - throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_UNSUPPORTED_METHOD, "restful connection is not supported currently"); - } else { - throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_UNKNOWN, "unknown connection:" + connection.getMetaData().getURL()); - } - } - - /** - * only one insert - * - * @param line schemaless line - * @param protocolType schemaless type {@link SchemalessProtocolType} - * @param timestampType Time precision {@link SchemalessTimestampType} - * @throws SQLException execute insert exception - */ - public void insert(String line, SchemalessProtocolType protocolType, SchemalessTimestampType timestampType) throws SQLException { - insert(new String[]{line}, protocolType, timestampType); - } -} diff --git a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/SchemalessWriter.java b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/SchemalessWriter.java new file mode 100644 index 0000000000000000000000000000000000000000..d8cb5795f05e0fad785fc0c4ffcdaea7be411be6 --- /dev/null +++ b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/SchemalessWriter.java @@ -0,0 +1,67 @@ +package com.taosdata.jdbc; + +import com.taosdata.jdbc.enums.SchemalessProtocolType; +import com.taosdata.jdbc.enums.SchemalessTimestampType; +import com.taosdata.jdbc.rs.RestfulConnection; + +import java.sql.Connection; +import java.sql.SQLException; +import java.util.List; + +/** + * This class is for schemaless lines(line/telnet/json) write to tdengine. + * e.g.: + * SchemalessWriter writer = new SchemalessWriter(connection); + * writer.write(lines, SchemalessProtocolType, SchemalessTimestampType); + */ +public class SchemalessWriter { + protected Connection connection; + + public SchemalessWriter(Connection connection) { + this.connection = connection; + } + + /** + * batch schemaless lines write to db + * + * @param lines schemaless lines + * @param protocolType schemaless type {@link SchemalessProtocolType} + * @param timestampType Time precision {@link SchemalessTimestampType} + * @throws SQLException execute exception + */ + public void write(String[] lines, SchemalessProtocolType protocolType, SchemalessTimestampType timestampType) throws SQLException { + if (connection instanceof TSDBConnection) { + TSDBConnection tsdbConnection = (TSDBConnection) connection; + tsdbConnection.getConnector().insertLines(lines, protocolType, timestampType); + } else if (connection instanceof RestfulConnection) { + throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_UNSUPPORTED_METHOD, "restful connection is not supported currently"); + } else { + throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_UNKNOWN, "unknown connection:" + connection.getMetaData().getURL()); + } + } + + /** + * only one line writes to db + * + * @param line schemaless line + * @param protocolType schemaless type {@link SchemalessProtocolType} + * @param timestampType Time precision {@link SchemalessTimestampType} + * @throws SQLException execute exception + */ + public void write(String line, SchemalessProtocolType protocolType, SchemalessTimestampType timestampType) throws SQLException { + write(new String[]{line}, protocolType, timestampType); + } + + /** + * batch schemaless lines write to db with list + * + * @param lines schemaless list + * @param protocolType schemaless type {@link SchemalessProtocolType} + * @param timestampType Time precision {@link SchemalessTimestampType} + * @throws SQLException execute exception + */ + public void write(List lines, SchemalessProtocolType protocolType, SchemalessTimestampType timestampType) throws SQLException { + String[] strings = lines.toArray(new String[0]); + write(strings, protocolType, timestampType); + } +} diff --git a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/SchemalessInsertTest.java b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/SchemalessInsertTest.java index b24271615ccf50d459e41687a51ba37394cbce4d..a090dd10e3564d498ab807909f97aefb3b2f3466 100644 --- a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/SchemalessInsertTest.java +++ b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/SchemalessInsertTest.java @@ -10,6 +10,8 @@ import org.junit.Before; import org.junit.Test; import java.sql.*; +import java.util.ArrayList; +import java.util.List; public class SchemalessInsertTest { private final String dbname = "test_schemaless_insert"; @@ -27,10 +29,8 @@ public class SchemalessInsertTest { "st,t1=3i64,t2=4f64,t3=\"t3\" c1=3i64,c3=L\"passit\",c2=false,c4=4f64 1626006833639000000", "st,t1=4i64,t3=\"t4\",t2=5f64,t4=5f64 c1=3i64,c3=L\"passitagin\",c2=true,c4=5f64,c5=5f64 1626006833640000000"}; // when - try (Statement statement = conn.createStatement(); - SchemalessStatement schemalessStatement = new SchemalessStatement(statement)) { - schemalessStatement.insert(lines, SchemalessProtocolType.LINE, SchemalessTimestampType.NANO_SECONDS); - } + SchemalessWriter writer = new SchemalessWriter(conn); + writer.write(lines, SchemalessProtocolType.LINE, SchemalessTimestampType.NANO_SECONDS); // then Statement statement = conn.createStatement(); @@ -62,10 +62,9 @@ public class SchemalessInsertTest { }; // when - try (Statement statement = conn.createStatement(); - SchemalessStatement schemalessStatement = new SchemalessStatement(statement)) { - schemalessStatement.insert(lines, SchemalessProtocolType.TELNET, SchemalessTimestampType.NOT_CONFIGURED); - } + + SchemalessWriter writer = new SchemalessWriter(conn); + writer.write(lines, SchemalessProtocolType.TELNET, SchemalessTimestampType.NOT_CONFIGURED); // then Statement statement = conn.createStatement(); @@ -114,10 +113,8 @@ public class SchemalessInsertTest { "]"; // when - try (Statement statement = conn.createStatement(); - SchemalessStatement schemalessStatement = new SchemalessStatement(statement)) { - schemalessStatement.insert(json, SchemalessProtocolType.JSON, SchemalessTimestampType.NOT_CONFIGURED); - } + SchemalessWriter writer = new SchemalessWriter(conn); + writer.write(json, SchemalessProtocolType.JSON, SchemalessTimestampType.NOT_CONFIGURED); // then Statement statement = conn.createStatement(); @@ -135,6 +132,33 @@ public class SchemalessInsertTest { statement.close(); } + @Test + public void telnetListInsert() throws SQLException { + // given + List list = new ArrayList<>(); + list.add("stb0_0 1626006833 4 host=host0 interface=eth0"); + list.add("stb0_1 1626006833 4 host=host0 interface=eth0"); + list.add("stb0_2 1626006833 4 host=host0 interface=eth0 id=\"special_name\""); + // when + + SchemalessWriter writer = new SchemalessWriter(conn); + writer.write(list, SchemalessProtocolType.TELNET, SchemalessTimestampType.NOT_CONFIGURED); + + // then + Statement statement = conn.createStatement(); + ResultSet rs = statement.executeQuery("show tables"); + Assert.assertNotNull(rs); + ResultSetMetaData metaData = rs.getMetaData(); + Assert.assertTrue(metaData.getColumnCount() > 0); + int rowCnt = 0; + while (rs.next()) { + rowCnt++; + } + Assert.assertEquals(list.size(), rowCnt); + rs.close(); + statement.close(); + } + @Before public void before() { String host = "127.0.0.1"; diff --git a/src/inc/ttokendef.h b/src/inc/ttokendef.h index 3e639c878c5bd101418a9177ec5c5409a5d65838..5d73f48eb6378573bbecc8261790a18a147f2133 100644 --- a/src/inc/ttokendef.h +++ b/src/inc/ttokendef.h @@ -16,6 +16,7 @@ #ifndef TDENGINE_TTOKENDEF_H #define TDENGINE_TTOKENDEF_H + #define TK_ID 1 #define TK_BOOL 2 #define TK_TINYINT 3 @@ -59,164 +60,164 @@ #define TK_STAR 41 #define TK_SLASH 42 #define TK_REM 43 -#define TK_CONCAT 44 -#define TK_UMINUS 45 -#define TK_UPLUS 46 -#define TK_BITNOT 47 -#define TK_ARROW 48 -#define TK_SHOW 49 -#define TK_DATABASES 50 -#define TK_TOPICS 51 -#define TK_FUNCTIONS 52 -#define TK_MNODES 53 -#define TK_DNODES 54 -#define TK_ACCOUNTS 55 -#define TK_USERS 56 -#define TK_MODULES 57 -#define TK_QUERIES 58 -#define TK_CONNECTIONS 59 -#define TK_STREAMS 60 -#define TK_VARIABLES 61 -#define TK_SCORES 62 -#define TK_GRANTS 63 -#define TK_VNODES 64 -#define TK_DOT 65 -#define TK_CREATE 66 -#define TK_TABLE 67 -#define TK_STABLE 68 -#define TK_DATABASE 69 -#define TK_TABLES 70 -#define TK_STABLES 71 -#define TK_VGROUPS 72 -#define TK_DROP 73 -#define TK_TOPIC 74 -#define TK_FUNCTION 75 -#define TK_DNODE 76 -#define TK_USER 77 -#define TK_ACCOUNT 78 -#define TK_USE 79 -#define TK_DESCRIBE 80 -#define TK_DESC 81 -#define TK_ALTER 82 -#define TK_PASS 83 -#define TK_PRIVILEGE 84 -#define TK_LOCAL 85 -#define TK_COMPACT 86 -#define TK_LP 87 -#define TK_RP 88 -#define TK_IF 89 -#define TK_EXISTS 90 -#define TK_AS 91 -#define TK_OUTPUTTYPE 92 -#define TK_AGGREGATE 93 -#define TK_BUFSIZE 94 -#define TK_PPS 95 -#define TK_TSERIES 96 -#define TK_DBS 97 -#define TK_STORAGE 98 -#define TK_QTIME 99 -#define TK_CONNS 100 -#define TK_STATE 101 -#define TK_COMMA 102 -#define TK_KEEP 103 -#define TK_CACHE 104 -#define TK_REPLICA 105 -#define TK_QUORUM 106 -#define TK_DAYS 107 -#define TK_MINROWS 108 -#define TK_MAXROWS 109 -#define TK_BLOCKS 110 -#define TK_CTIME 111 -#define TK_WAL 112 -#define TK_FSYNC 113 -#define TK_COMP 114 -#define TK_PRECISION 115 -#define TK_UPDATE 116 -#define TK_CACHELAST 117 -#define TK_PARTITIONS 118 -#define TK_UNSIGNED 119 -#define TK_TAGS 120 -#define TK_USING 121 -#define TK_NULL 122 -#define TK_NOW 123 -#define TK_SELECT 124 -#define TK_UNION 125 -#define TK_ALL 126 -#define TK_DISTINCT 127 -#define TK_FROM 128 -#define TK_VARIABLE 129 -#define TK_RANGE 130 -#define TK_INTERVAL 131 -#define TK_EVERY 132 -#define TK_SESSION 133 -#define TK_STATE_WINDOW 134 -#define TK_FILL 135 -#define TK_SLIDING 136 -#define TK_ORDER 137 -#define TK_BY 138 -#define TK_ASC 139 -#define TK_GROUP 140 -#define TK_HAVING 141 -#define TK_LIMIT 142 -#define TK_OFFSET 143 -#define TK_SLIMIT 144 -#define TK_SOFFSET 145 -#define TK_WHERE 146 -#define TK_RESET 147 -#define TK_QUERY 148 -#define TK_SYNCDB 149 -#define TK_ADD 150 -#define TK_COLUMN 151 -#define TK_MODIFY 152 -#define TK_TAG 153 -#define TK_CHANGE 154 -#define TK_SET 155 -#define TK_KILL 156 -#define TK_CONNECTION 157 -#define TK_STREAM 158 -#define TK_COLON 159 -#define TK_ABORT 160 -#define TK_AFTER 161 -#define TK_ATTACH 162 -#define TK_BEFORE 163 -#define TK_BEGIN 164 -#define TK_CASCADE 165 -#define TK_CLUSTER 166 -#define TK_CONFLICT 167 -#define TK_COPY 168 -#define TK_DEFERRED 169 -#define TK_DELIMITERS 170 -#define TK_DETACH 171 -#define TK_EACH 172 -#define TK_END 173 -#define TK_EXPLAIN 174 -#define TK_FAIL 175 -#define TK_FOR 176 -#define TK_IGNORE 177 -#define TK_IMMEDIATE 178 -#define TK_INITIALLY 179 -#define TK_INSTEAD 180 -#define TK_KEY 181 -#define TK_OF 182 -#define TK_RAISE 183 -#define TK_REPLACE 184 -#define TK_RESTRICT 185 -#define TK_ROW 186 -#define TK_STATEMENT 187 -#define TK_TRIGGER 188 -#define TK_VIEW 189 -#define TK_IPTOKEN 190 -#define TK_SEMI 191 -#define TK_NONE 192 -#define TK_PREV 193 -#define TK_LINEAR 194 -#define TK_IMPORT 195 -#define TK_TBNAME 196 -#define TK_JOIN 197 -#define TK_INSERT 198 -#define TK_INTO 199 -#define TK_VALUES 200 -#define TK_FILE 201 +#define TK_UMINUS 44 +#define TK_UPLUS 45 +#define TK_BITNOT 46 +#define TK_ARROW 47 +#define TK_SHOW 48 +#define TK_DATABASES 49 +#define TK_TOPICS 50 +#define TK_FUNCTIONS 51 +#define TK_MNODES 52 +#define TK_DNODES 53 +#define TK_ACCOUNTS 54 +#define TK_USERS 55 +#define TK_MODULES 56 +#define TK_QUERIES 57 +#define TK_CONNECTIONS 58 +#define TK_STREAMS 59 +#define TK_VARIABLES 60 +#define TK_SCORES 61 +#define TK_GRANTS 62 +#define TK_VNODES 63 +#define TK_DOT 64 +#define TK_CREATE 65 +#define TK_TABLE 66 +#define TK_STABLE 67 +#define TK_DATABASE 68 +#define TK_TABLES 69 +#define TK_STABLES 70 +#define TK_VGROUPS 71 +#define TK_DROP 72 +#define TK_TOPIC 73 +#define TK_FUNCTION 74 +#define TK_DNODE 75 +#define TK_USER 76 +#define TK_ACCOUNT 77 +#define TK_USE 78 +#define TK_DESCRIBE 79 +#define TK_DESC 80 +#define TK_ALTER 81 +#define TK_PASS 82 +#define TK_PRIVILEGE 83 +#define TK_LOCAL 84 +#define TK_COMPACT 85 +#define TK_LP 86 +#define TK_RP 87 +#define TK_IF 88 +#define TK_EXISTS 89 +#define TK_AS 90 +#define TK_OUTPUTTYPE 91 +#define TK_AGGREGATE 92 +#define TK_BUFSIZE 93 +#define TK_PPS 94 +#define TK_TSERIES 95 +#define TK_DBS 96 +#define TK_STORAGE 97 +#define TK_QTIME 98 +#define TK_CONNS 99 +#define TK_STATE 100 +#define TK_COMMA 101 +#define TK_KEEP 102 +#define TK_CACHE 103 +#define TK_REPLICA 104 +#define TK_QUORUM 105 +#define TK_DAYS 106 +#define TK_MINROWS 107 +#define TK_MAXROWS 108 +#define TK_BLOCKS 109 +#define TK_CTIME 110 +#define TK_WAL 111 +#define TK_FSYNC 112 +#define TK_COMP 113 +#define TK_PRECISION 114 +#define TK_UPDATE 115 +#define TK_CACHELAST 116 +#define TK_PARTITIONS 117 +#define TK_UNSIGNED 118 +#define TK_TAGS 119 +#define TK_USING 120 +#define TK_NULL 121 +#define TK_NOW 122 +#define TK_SELECT 123 +#define TK_UNION 124 +#define TK_ALL 125 +#define TK_DISTINCT 126 +#define TK_FROM 127 +#define TK_VARIABLE 128 +#define TK_RANGE 129 +#define TK_INTERVAL 130 +#define TK_EVERY 131 +#define TK_SESSION 132 +#define TK_STATE_WINDOW 133 +#define TK_FILL 134 +#define TK_SLIDING 135 +#define TK_ORDER 136 +#define TK_BY 137 +#define TK_ASC 138 +#define TK_GROUP 139 +#define TK_HAVING 140 +#define TK_LIMIT 141 +#define TK_OFFSET 142 +#define TK_SLIMIT 143 +#define TK_SOFFSET 144 +#define TK_WHERE 145 +#define TK_RESET 146 +#define TK_QUERY 147 +#define TK_SYNCDB 148 +#define TK_ADD 149 +#define TK_COLUMN 150 +#define TK_MODIFY 151 +#define TK_TAG 152 +#define TK_CHANGE 153 +#define TK_SET 154 +#define TK_KILL 155 +#define TK_CONNECTION 156 +#define TK_STREAM 157 +#define TK_COLON 158 +#define TK_ABORT 159 +#define TK_AFTER 160 +#define TK_ATTACH 161 +#define TK_BEFORE 162 +#define TK_BEGIN 163 +#define TK_CASCADE 164 +#define TK_CLUSTER 165 +#define TK_CONFLICT 166 +#define TK_COPY 167 +#define TK_DEFERRED 168 +#define TK_DELIMITERS 169 +#define TK_DETACH 170 +#define TK_EACH 171 +#define TK_END 172 +#define TK_EXPLAIN 173 +#define TK_FAIL 174 +#define TK_FOR 175 +#define TK_IGNORE 176 +#define TK_IMMEDIATE 177 +#define TK_INITIALLY 178 +#define TK_INSTEAD 179 +#define TK_KEY 180 +#define TK_OF 181 +#define TK_RAISE 182 +#define TK_REPLACE 183 +#define TK_RESTRICT 184 +#define TK_ROW 185 +#define TK_STATEMENT 186 +#define TK_TRIGGER 187 +#define TK_VIEW 188 +#define TK_IPTOKEN 189 +#define TK_SEMI 190 +#define TK_NONE 191 +#define TK_PREV 192 +#define TK_LINEAR 193 +#define TK_IMPORT 194 +#define TK_TBNAME 195 +#define TK_JOIN 196 +#define TK_INSERT 197 +#define TK_INTO 198 +#define TK_VALUES 199 +#define TK_FILE 200 + #define TK_SPACE 300 diff --git a/src/inc/ttype.h b/src/inc/ttype.h index ff2fac5b72d9181a3cb0cd8afaf3ea5053da5484..1b7d07262e50da893e1bc3009df94b49ee306637 100644 --- a/src/inc/ttype.h +++ b/src/inc/ttype.h @@ -166,6 +166,42 @@ typedef struct { } \ } while (0) +#define NUM_TO_STRING(_inputType, _input, _outputBytes, _output) \ + do { \ + switch (_inputType) { \ + case TSDB_DATA_TYPE_TINYINT: \ + snprintf(_output, (int32_t)(_outputBytes), "%d", *(int8_t *)(_input)); \ + break; \ + case TSDB_DATA_TYPE_UTINYINT: \ + snprintf(_output, (int32_t)(_outputBytes), "%d", *(uint8_t *)(_input)); \ + break; \ + case TSDB_DATA_TYPE_SMALLINT: \ + snprintf(_output, (int32_t)(_outputBytes), "%d", *(int16_t *)(_input)); \ + break; \ + case TSDB_DATA_TYPE_USMALLINT: \ + snprintf(_output, (int32_t)(_outputBytes), "%d", *(uint16_t *)(_input)); \ + break; \ + case TSDB_DATA_TYPE_BIGINT: \ + snprintf(_output, (int32_t)(_outputBytes), "%" PRId64, *(int64_t *)(_input)); \ + break; \ + case TSDB_DATA_TYPE_UBIGINT: \ + snprintf(_output, (int32_t)(_outputBytes), "%" PRIu64, *(uint64_t *)(_input)); \ + break; \ + case TSDB_DATA_TYPE_FLOAT: \ + snprintf(_output, (int32_t)(_outputBytes), "%f", *(float *)(_input)); \ + break; \ + case TSDB_DATA_TYPE_DOUBLE: \ + snprintf(_output, (int32_t)(_outputBytes), "%f", *(double *)(_input)); \ + break; \ + case TSDB_DATA_TYPE_UINT: \ + snprintf(_output, (int32_t)(_outputBytes), "%u", *(uint32_t *)(_input)); \ + break; \ + default: \ + snprintf(_output, (int32_t)(_outputBytes), "%d", *(int32_t *)(_input)); \ + break; \ + } \ + } while (0) + #define IS_SIGNED_NUMERIC_TYPE(_t) ((_t) >= TSDB_DATA_TYPE_TINYINT && (_t) <= TSDB_DATA_TYPE_BIGINT) #define IS_UNSIGNED_NUMERIC_TYPE(_t) ((_t) >= TSDB_DATA_TYPE_UTINYINT && (_t) <= TSDB_DATA_TYPE_UBIGINT) #define IS_FLOAT_TYPE(_t) ((_t) == TSDB_DATA_TYPE_FLOAT || (_t) == TSDB_DATA_TYPE_DOUBLE) diff --git a/src/kit/shell/src/shellEngine.c b/src/kit/shell/src/shellEngine.c index 47d39cc0ca3bdf33716782d1dfbac55e9fc7b477..3f672c4531921642bcf1a20888b482c98968f9c7 100644 --- a/src/kit/shell/src/shellEngine.c +++ b/src/kit/shell/src/shellEngine.c @@ -646,7 +646,7 @@ static void shellPrintNChar(const char *str, int length, int width) { static void printField(const char* val, TAOS_FIELD* field, int width, int32_t length, int precision) { if (val == NULL) { int w = width; - if (field->type < TSDB_DATA_TYPE_TINYINT || field->type > TSDB_DATA_TYPE_DOUBLE) { + if (field->type == TSDB_DATA_TYPE_BINARY || field->type == TSDB_DATA_TYPE_NCHAR || field->type == TSDB_DATA_TYPE_TIMESTAMP) { w = 0; } w = printf("%*s", w, TSDB_DATA_NULL_STR); diff --git a/src/query/inc/qAggMain.h b/src/query/inc/qAggMain.h index 5a0f16c462c26c03e6a5312495fc49f32e83c66c..b1b82ae762d8c832ae47df515127525b7a1ae6cc 100644 --- a/src/query/inc/qAggMain.h +++ b/src/query/inc/qAggMain.h @@ -23,6 +23,7 @@ extern "C" { #include "os.h" #include "tname.h" +#include "texpr.h" #include "taosdef.h" #include "trpc.h" #include "tvariant.h" @@ -56,7 +57,7 @@ extern "C" { #define TSDB_FUNC_PRJ 21 #define TSDB_FUNC_TAGPRJ 22 -#define TSDB_FUNC_ARITHM 23 +#define TSDB_FUNC_SCALAR_EXPR 23 #define TSDB_FUNC_DIFF 24 #define TSDB_FUNC_FIRST_DST 25 @@ -69,17 +70,13 @@ extern "C" { #define TSDB_FUNC_TID_TAG 31 #define TSDB_FUNC_DERIVATIVE 32 -#define TSDB_FUNC_CEIL 33 -#define TSDB_FUNC_FLOOR 34 -#define TSDB_FUNC_ROUND 35 +#define TSDB_FUNC_CSUM 33 +#define TSDB_FUNC_MAVG 34 +#define TSDB_FUNC_SAMPLE 35 -#define TSDB_FUNC_CSUM 36 -#define TSDB_FUNC_MAVG 37 -#define TSDB_FUNC_SAMPLE 38 +#define TSDB_FUNC_BLKINFO 36 -#define TSDB_FUNC_BLKINFO 39 - -#define TSDB_FUNC_ELAPSED 40 +#define TSDB_FUNC_ELAPSED 37 /////////////////////////////////////////// // the following functions is not implemented. @@ -95,7 +92,6 @@ extern "C" { #define TSDB_FUNCSTATE_OF 0x10u // outer forward #define TSDB_FUNCSTATE_NEED_TS 0x20u // timestamp is required during query processing #define TSDB_FUNCSTATE_SELECTIVITY 0x40u // selectivity functions, can exists along with tag columns -#define TSDB_FUNCSTATE_SCALAR 0x80u #define TSDB_BASE_FUNC_SO TSDB_FUNCSTATE_SO | TSDB_FUNCSTATE_STREAM | TSDB_FUNCSTATE_STABLE | TSDB_FUNCSTATE_OF #define TSDB_BASE_FUNC_MO TSDB_FUNCSTATE_MO | TSDB_FUNCSTATE_STREAM | TSDB_FUNCSTATE_STABLE | TSDB_FUNCSTATE_OF @@ -130,14 +126,14 @@ enum { #define QUERY_IS_PROJECTION_QUERY(type) (((type)&TSDB_QUERY_TYPE_PROJECTION_QUERY) != 0) #define QUERY_IS_FREE_RESOURCE(type) (((type)&TSDB_QUERY_TYPE_FREE_RESOURCE) != 0) -typedef struct SArithmeticSupport { +typedef struct SScalarExprSupport { SExprInfo *pExprInfo; int32_t numOfCols; SColumnInfo *colList; void *exprList; // client side used int32_t offset; char** data; -} SArithmeticSupport; +} SScalarExprSupport; typedef struct SQLPreAggVal { bool isSet; // statistics info set or not @@ -236,7 +232,6 @@ int32_t isValidFunction(const char* name, int32_t len); #define IS_MULTIOUTPUT(x) (((x)&TSDB_FUNCSTATE_MO) != 0) #define IS_SINGLEOUTPUT(x) (((x)&TSDB_FUNCSTATE_SO) != 0) #define IS_OUTER_FORWARD(x) (((x)&TSDB_FUNCSTATE_OF) != 0) -#define IS_SCALAR_FUNCTION(x) (((x)&TSDB_FUNCSTATE_SCALAR) != 0) // determine the real data need to calculated the result enum { @@ -258,7 +253,7 @@ void blockDistInfoToBinary(STableBlockDist* pDist, struct SBufferWriter* bw); void blockDistInfoFromBinary(const char* data, int32_t len, STableBlockDist* pDist); /* global sql function array */ -extern struct SAggFunctionInfo aAggs[]; +extern struct SAggFunctionInfo aAggs[40]; extern int32_t functionCompatList[]; // compatible check array list @@ -275,11 +270,11 @@ bool topbot_datablock_filter(SQLFunctionCtx *pCtx, const char *minval, const cha static FORCE_INLINE void initResultInfo(SResultRowCellInfo *pResInfo, int32_t bufLen) { pResInfo->initialized = true; // the this struct has been initialized flag - + pResInfo->complete = false; pResInfo->hasResult = false; pResInfo->numOfRes = 0; - + memset(GET_ROWCELL_INTERBUF(pResInfo), 0, bufLen); } diff --git a/src/query/inc/qExecutor.h b/src/query/inc/qExecutor.h index 0a52a44ed1f7019abc7542fab75cfd098302dbc1..ba277b23018a58e3ed29122761aa65506c94078a 100644 --- a/src/query/inc/qExecutor.h +++ b/src/query/inc/qExecutor.h @@ -311,7 +311,7 @@ typedef struct SQueryRuntimeEnv { STSCursor cur; char* tagVal; // tag value of current data block - SArithmeticSupport *sasArray; + SScalarExprSupport*sasArray; SSDataBlock *outputBuf; STableGroupInfo tableqinfoGroupInfo; // this is a group array list, including SArray structure @@ -686,7 +686,7 @@ void freeColumnFilterInfo(SColumnFilterInfo* pFilter, int32_t numOfFilters); STableQueryInfo *createTableQueryInfo(SQueryAttr* pQueryAttr, void* pTable, bool groupbyColumn, STimeWindow win, void* buf); STableQueryInfo* createTmpTableQueryInfo(STimeWindow win); -int32_t buildArithmeticExprFromMsg(SExprInfo *pArithExprInfo, void *pQueryMsg); +int32_t buildScalarExprFromMsg(SExprInfo * pExprInfo, void *pQueryMsg); bool isQueryKilled(SQInfo *pQInfo); int32_t checkForQueryBuf(size_t numOfTables); @@ -717,4 +717,5 @@ int32_t getMaximumIdleDurationSec(); void doInvokeUdf(SUdfInfo* pUdfInfo, SQLFunctionCtx *pCtx, int32_t idx, int32_t type); int32_t getColumnDataFromId(void *param, int32_t id, void **data); +void qInfoLogSSDataBlock(SSDataBlock* block, char* location); #endif // TDENGINE_QEXECUTOR_H diff --git a/src/query/inc/qPercentile.h b/src/query/inc/qPercentile.h index f5b770593c1e30df8c3459676ffa42bbfc9cf0ae..55085c0404c9baa357c2255e1e466dd31e5d4237 100644 --- a/src/query/inc/qPercentile.h +++ b/src/query/inc/qPercentile.h @@ -33,7 +33,7 @@ typedef struct MinMaxEntry { union { double dMaxVal; int64_t i64MaxVal; - int64_t u64MaxVal; + uint64_t u64MaxVal; }; } MinMaxEntry; diff --git a/src/query/inc/qSqlparser.h b/src/query/inc/qSqlparser.h index 2c70767aba7e9b8d6822663b96538d4ff83da87c..f3253c0d8396582454f9d4ef39e09f6ade181d5f 100644 --- a/src/query/inc/qSqlparser.h +++ b/src/query/inc/qSqlparser.h @@ -28,15 +28,17 @@ extern "C" { #define ParseTOKENTYPE SStrToken -#define NON_ARITHMEIC_EXPR 0 -#define NORMAL_ARITHMETIC 1 -#define AGG_ARIGHTMEIC 2 +#define SQLEXPR_TYPE_UNASSIGNED 0 +#define SQLEXPR_TYPE_SCALAR 1 +#define SQLEXPR_TYPE_AGG 2 +#define SQLEXPR_TYPE_VALUE 3 enum SQL_NODE_TYPE { SQL_NODE_TABLE_COLUMN= 1, SQL_NODE_SQLFUNCTION = 2, SQL_NODE_VALUE = 3, SQL_NODE_EXPR = 4, + SQL_NODE_DATA_TYPE = 5, }; enum SQL_NODE_FROM_TYPE { @@ -271,6 +273,7 @@ typedef struct tSqlExpr { int32_t functionId; // function id, todo remove it SStrToken columnName; // table column info + TAOS_FIELD dataType; // data type tVariant value; // the use input value SStrToken exprToken; // original sql expr string uint32_t flags; // todo remove it @@ -300,6 +303,7 @@ SRelationInfo *addSubqueryElem(SRelationInfo* pRelationInfo, SArray* pSub, SStrT tSqlExpr *tSqlExprCreateTimestamp(SStrToken *pToken, int32_t optrType); tSqlExpr *tSqlExprCreateIdValue(SSqlInfo* pInfo, SStrToken *pToken, int32_t optrType); tSqlExpr *tSqlExprCreateFunction(SArray *pParam, SStrToken *pFuncToken, SStrToken *endToken, int32_t optType); +tSqlExpr *tSqlExprCreateFuncWithParams(SSqlInfo *pInfo, tSqlExpr* col, TAOS_FIELD *colType, SStrToken *pFuncToken, SStrToken *endToken, int32_t optType); SArray *tStrTokenAppend(SArray *pList, SStrToken *pToken); tSqlExpr *tSqlExprCreate(tSqlExpr *pLeft, tSqlExpr *pRight, int32_t optrType); diff --git a/src/query/inc/sql.y b/src/query/inc/sql.y index 1c7290a5306209c17ff70ab02a5f757493139205..b435722d2093ce6434fe38f1af2f743885b46249 100644 --- a/src/query/inc/sql.y +++ b/src/query/inc/sql.y @@ -17,7 +17,6 @@ %left PLUS MINUS. %left DIVIDE TIMES. %left STAR SLASH REM. -%left CONCAT. %right UMINUS UPLUS BITNOT. %right ARROW. @@ -751,6 +750,9 @@ expr(A) ::= ID(X) LP exprlist(Y) RP(E). { tStrTokenAppend(pInfo->funcs, &X); A = // for parsing sql functions with wildcard for parameters. e.g., count(*)/first(*)/last(*) operation expr(A) ::= ID(X) LP STAR RP(Y). { tStrTokenAppend(pInfo->funcs, &X); A = tSqlExprCreateFunction(NULL, &X, &Y, X.type); } +// for parsing sql function CAST(column as typename) +expr(A) ::= ID(X) LP expr(B) AS typename(C) RP(Y). { tStrTokenAppend(pInfo->funcs, &X); A = tSqlExprCreateFuncWithParams(pInfo, B, &C, &X, &Y, X.type); } + // is (not) null expression expr(A) ::= expr(X) IS NULL. {A = tSqlExprCreate(X, NULL, TK_ISNULL);} expr(A) ::= expr(X) IS NOT NULL. {A = tSqlExprCreate(X, NULL, TK_NOTNULL);} diff --git a/src/query/src/qAggMain.c b/src/query/src/qAggMain.c index 16d2f16aeb4cf62569f74c2e0f36706b0292af2d..e033650b74fe503c73f75b95acdc0e466a241e9a 100644 --- a/src/query/src/qAggMain.c +++ b/src/query/src/qAggMain.c @@ -217,11 +217,12 @@ int32_t getResultDataInfo(int32_t dataType, int32_t dataBytes, int32_t functionI return TSDB_CODE_TSC_INVALID_OPERATION; } + assert(!TSDB_FUNC_IS_SCALAR(functionId)); + assert(functionId != TSDB_FUNC_SCALAR_EXPR); if (functionId == TSDB_FUNC_TS || functionId == TSDB_FUNC_TS_DUMMY || functionId == TSDB_FUNC_TAG_DUMMY || functionId == TSDB_FUNC_DIFF || functionId == TSDB_FUNC_PRJ || functionId == TSDB_FUNC_TAGPRJ || - functionId == TSDB_FUNC_TAG || functionId == TSDB_FUNC_INTERP || functionId == TSDB_FUNC_CEIL || - functionId == TSDB_FUNC_FLOOR || functionId == TSDB_FUNC_ROUND) + functionId == TSDB_FUNC_TAG || functionId == TSDB_FUNC_INTERP) { *type = (int16_t)dataType; *bytes = dataBytes; @@ -259,13 +260,7 @@ int32_t getResultDataInfo(int32_t dataType, int32_t dataBytes, int32_t functionI *interBytes = 0; return TSDB_CODE_SUCCESS; } - - if (functionId == TSDB_FUNC_ARITHM) { - *type = TSDB_DATA_TYPE_DOUBLE; - *bytes = sizeof(double); - *interBytes = 0; - return TSDB_CODE_SUCCESS; - } + if (functionId == TSDB_FUNC_TS_COMP) { *type = TSDB_DATA_TYPE_BINARY; @@ -495,6 +490,18 @@ int32_t getResultDataInfo(int32_t dataType, int32_t dataBytes, int32_t functionI // TODO use hash table int32_t isValidFunction(const char* name, int32_t len) { + + for (int32_t i = 0; i < TSDB_FUNC_SCALAR_MAX_NUM; ++i) { + int32_t nameLen = (int32_t) strlen(aScalarFunctions[i].name); + if (len != nameLen) { + continue; + } + + if (strncasecmp(aScalarFunctions[i].name, name, len) == 0) { + return aScalarFunctions[i].functionId; + } + } + for(int32_t i = 0; i <= TSDB_FUNC_ELAPSED; ++i) { int32_t nameLen = (int32_t) strlen(aAggs[i].name); if (len != nameLen) { @@ -505,7 +512,6 @@ int32_t isValidFunction(const char* name, int32_t len) { return i; } } - return -1; } @@ -3400,8 +3406,8 @@ static void diff_function(SQLFunctionCtx *pCtx) { } } -char *getArithColumnData(void *param, const char* name, int32_t colId) { - SArithmeticSupport *pSupport = (SArithmeticSupport *)param; +char *getScalarExprColumnData(void *param, const char* name, int32_t colId) { + SScalarExprSupport *pSupport = (SScalarExprSupport *)param; int32_t index = -1; for (int32_t i = 0; i < pSupport->numOfCols; ++i) { @@ -3415,11 +3421,12 @@ char *getArithColumnData(void *param, const char* name, int32_t colId) { return pSupport->data[index] + pSupport->offset * pSupport->colList[index].bytes; } -static void arithmetic_function(SQLFunctionCtx *pCtx) { +static void scalar_expr_function(SQLFunctionCtx *pCtx) { GET_RES_INFO(pCtx)->numOfRes += pCtx->size; - SArithmeticSupport *sas = (SArithmeticSupport *)pCtx->param[1].pz; - - arithmeticTreeTraverse(sas->pExprInfo->pExpr, pCtx->size, pCtx->pOutput, sas, pCtx->order, getArithColumnData); + SScalarExprSupport *sas = (SScalarExprSupport *)pCtx->param[1].pz; + tExprOperandInfo output; + output.data = pCtx->pOutput; + exprTreeNodeTraverse(sas->pExprInfo->pExpr, pCtx->size, &output, sas, pCtx->order, getScalarExprColumnData); } #define LIST_MINMAX_N(ctx, minOutput, maxOutput, elemCnt, data, type, tsdbType, numOfNotNullElem) \ @@ -4431,185 +4438,6 @@ void blockinfo_func_finalizer(SQLFunctionCtx* pCtx) { doFinalizer(pCtx); } -///////////////////////////////////////////////////////////////////////////////////////////////////////////// - -#define CFR_SET_VAL(type, data, pCtx, func, i, step) \ - do { \ - type *pData = (type *) data; \ - type *pOutput = (type *) pCtx->pOutput; \ - \ - for (; i < pCtx->size && i >= 0; i += step) { \ - if (pCtx->hasNull && isNull((const char *)&pData[i], pCtx->inputType)) { \ - *pOutput++ = pData[i]; \ - } else { \ - *pOutput++ = (type)func((double)pData[i]); \ - } \ - } \ - } while (0) - -static void ceil_function(SQLFunctionCtx *pCtx) { - void *data = GET_INPUT_DATA_LIST(pCtx); - - int32_t step = GET_FORWARD_DIRECTION_FACTOR(pCtx->order); - int32_t i = (pCtx->order == TSDB_ORDER_ASC) ? 0 : pCtx->size - 1; - - switch (pCtx->inputType) { - case TSDB_DATA_TYPE_INT: { - CFR_SET_VAL(int32_t, data, pCtx, ceil, i, step); - break; - }; - case TSDB_DATA_TYPE_UINT: { - CFR_SET_VAL(uint32_t, data, pCtx, ceil, i, step); - break; - }; - case TSDB_DATA_TYPE_BIGINT: { - CFR_SET_VAL(int64_t, data, pCtx, ceil, i, step); - break; - } - case TSDB_DATA_TYPE_UBIGINT: { - CFR_SET_VAL(uint64_t, data, pCtx, ceil, i, step); - break; - } - case TSDB_DATA_TYPE_DOUBLE: { - CFR_SET_VAL(double, data, pCtx, ceil, i, step); - break; - } - case TSDB_DATA_TYPE_FLOAT: { - CFR_SET_VAL(float, data, pCtx, ceil, i, step); - break; - } - case TSDB_DATA_TYPE_SMALLINT: { - CFR_SET_VAL(int16_t, data, pCtx, ceil, i, step); - break; - } - case TSDB_DATA_TYPE_USMALLINT: { - CFR_SET_VAL(uint16_t, data, pCtx, ceil, i, step); - break; - } - case TSDB_DATA_TYPE_TINYINT: { - CFR_SET_VAL(int8_t, data, pCtx, ceil, i, step); - break; - } - case TSDB_DATA_TYPE_UTINYINT: { - CFR_SET_VAL(uint8_t, data, pCtx, ceil, i, step); - break; - } - default: - qError("error input type"); - } - - GET_RES_INFO(pCtx)->numOfRes += pCtx->size; -} - -static void floor_function(SQLFunctionCtx *pCtx) { - void *data = GET_INPUT_DATA_LIST(pCtx); - - int32_t step = GET_FORWARD_DIRECTION_FACTOR(pCtx->order); - int32_t i = (pCtx->order == TSDB_ORDER_ASC) ? 0 : pCtx->size - 1; - - switch (pCtx->inputType) { - case TSDB_DATA_TYPE_INT: { - CFR_SET_VAL(int32_t, data, pCtx, floor, i, step); - break; - }; - case TSDB_DATA_TYPE_UINT: { - CFR_SET_VAL(uint32_t, data, pCtx, floor, i, step); - break; - }; - case TSDB_DATA_TYPE_BIGINT: { - CFR_SET_VAL(int64_t, data, pCtx, floor, i, step); - break; - } - case TSDB_DATA_TYPE_UBIGINT: { - CFR_SET_VAL(uint64_t, data, pCtx, floor, i, step); - break; - } - case TSDB_DATA_TYPE_DOUBLE: { - CFR_SET_VAL(double, data, pCtx, floor, i, step); - break; - } - case TSDB_DATA_TYPE_FLOAT: { - CFR_SET_VAL(float, data, pCtx, floor, i, step); - break; - } - case TSDB_DATA_TYPE_SMALLINT: { - CFR_SET_VAL(int16_t, data, pCtx, floor, i, step); - break; - } - case TSDB_DATA_TYPE_USMALLINT: { - CFR_SET_VAL(uint16_t, data, pCtx, floor, i, step); - break; - } - case TSDB_DATA_TYPE_TINYINT: { - CFR_SET_VAL(int8_t, data, pCtx, floor, i, step); - break; - } - case TSDB_DATA_TYPE_UTINYINT: { - CFR_SET_VAL(uint8_t, data, pCtx, floor, i, step); - break; - } - default: - qError("error input type"); - } - - GET_RES_INFO(pCtx)->numOfRes += pCtx->size; -} - -static void round_function(SQLFunctionCtx *pCtx) { - void *data = GET_INPUT_DATA_LIST(pCtx); - - int32_t step = GET_FORWARD_DIRECTION_FACTOR(pCtx->order); - int32_t i = (pCtx->order == TSDB_ORDER_ASC) ? 0 : pCtx->size - 1; - - switch (pCtx->inputType) { - case TSDB_DATA_TYPE_INT: { - CFR_SET_VAL(int32_t, data, pCtx, round, i, step); - break; - }; - case TSDB_DATA_TYPE_UINT: { - CFR_SET_VAL(uint32_t, data, pCtx, round, i, step); - break; - }; - case TSDB_DATA_TYPE_BIGINT: { - CFR_SET_VAL(int64_t, data, pCtx, round, i, step); - break; - } - case TSDB_DATA_TYPE_UBIGINT: { - CFR_SET_VAL(uint64_t, data, pCtx, round, i, step); - break; - } - case TSDB_DATA_TYPE_DOUBLE: { - CFR_SET_VAL(double, data, pCtx, round, i, step); - break; - } - case TSDB_DATA_TYPE_FLOAT: { - CFR_SET_VAL(float, data, pCtx, round, i, step); - break; - } - case TSDB_DATA_TYPE_SMALLINT: { - CFR_SET_VAL(int16_t, data, pCtx, round, i, step); - break; - } - case TSDB_DATA_TYPE_USMALLINT: { - CFR_SET_VAL(uint16_t, data, pCtx, round, i, step); - break; - } - case TSDB_DATA_TYPE_TINYINT: { - CFR_SET_VAL(int8_t, data, pCtx, round, i, step); - break; - } - case TSDB_DATA_TYPE_UTINYINT: { - CFR_SET_VAL(uint8_t, data, pCtx, round, i, step); - break; - } - default: - qError("error input type"); - } - GET_RES_INFO(pCtx)->numOfRes += pCtx->size; -} - -#undef CFR_SET_VAL - ////////////////////////////////////////////////////////////////////////////////// //cumulative_sum function @@ -5069,13 +4897,13 @@ int32_t functionCompatList[] = { 4, -1, -1, 1, 1, 1, 1, 1, 1, -1, // tag, colprj, tagprj, arithm, diff, first_dist, last_dist, stddev_dst, interp rate, irate 1, 1, 1, 1, -1, 1, 1, 1, 5, 1, 1, - // tid_tag, deriv, ceil, floor, round, csum, mavg, sample, - 6, 8, 1, 1, 1, -1, -1, -1, + // tid_tag, deriv, csum, mavg, sample, + 6, 8, -1, -1, -1, // block_info, elapsed 7, 1 }; -SAggFunctionInfo aAggs[] = {{ +SAggFunctionInfo aAggs[40] = {{ // 0, count function does not invoke the finalize function "count", TSDB_FUNC_COUNT, @@ -5357,11 +5185,11 @@ SAggFunctionInfo aAggs[] = {{ { // 23 "arithmetic", - TSDB_FUNC_ARITHM, - TSDB_FUNC_ARITHM, + TSDB_FUNC_SCALAR_EXPR, + TSDB_FUNC_SCALAR_EXPR, TSDB_FUNCSTATE_MO | TSDB_FUNCSTATE_STABLE | TSDB_FUNCSTATE_NEED_TS, function_setup, - arithmetic_function, + scalar_expr_function, doFinalizer, copy_function, dataBlockRequired, @@ -5474,41 +5302,8 @@ SAggFunctionInfo aAggs[] = {{ noop1, dataBlockRequired, }, - {// 33 - "ceil", - TSDB_FUNC_CEIL, - TSDB_FUNC_CEIL, - TSDB_FUNCSTATE_MO | TSDB_FUNCSTATE_STABLE | TSDB_FUNCSTATE_NEED_TS | TSDB_FUNCSTATE_SCALAR, - function_setup, - ceil_function, - doFinalizer, - noop1, - dataBlockRequired - }, - {// 34 - "floor", - TSDB_FUNC_FLOOR, - TSDB_FUNC_FLOOR, - TSDB_FUNCSTATE_MO | TSDB_FUNCSTATE_STABLE | TSDB_FUNCSTATE_NEED_TS | TSDB_FUNCSTATE_SCALAR, - function_setup, - floor_function, - doFinalizer, - noop1, - dataBlockRequired - }, - {// 35 - "round", - TSDB_FUNC_ROUND, - TSDB_FUNC_ROUND, - TSDB_FUNCSTATE_MO | TSDB_FUNCSTATE_STABLE | TSDB_FUNCSTATE_NEED_TS | TSDB_FUNCSTATE_SCALAR, - function_setup, - round_function, - doFinalizer, - noop1, - dataBlockRequired - }, { - // 36 + // 33 "csum", TSDB_FUNC_CSUM, TSDB_FUNC_INVALID_ID, @@ -5520,7 +5315,7 @@ SAggFunctionInfo aAggs[] = {{ dataBlockRequired, }, { - // 37 + // 34 "mavg", TSDB_FUNC_MAVG, TSDB_FUNC_INVALID_ID, @@ -5532,7 +5327,7 @@ SAggFunctionInfo aAggs[] = {{ dataBlockRequired, }, { - // 38 + // 35 "sample", TSDB_FUNC_SAMPLE, TSDB_FUNC_SAMPLE, @@ -5544,7 +5339,7 @@ SAggFunctionInfo aAggs[] = {{ dataBlockRequired, }, { - // 39 + // 36 "_block_dist", TSDB_FUNC_BLKINFO, TSDB_FUNC_BLKINFO, @@ -5556,7 +5351,7 @@ SAggFunctionInfo aAggs[] = {{ dataBlockRequired, }, { - // 40 + // 37 "elapsed", TSDB_FUNC_ELAPSED, TSDB_FUNC_ELAPSED, diff --git a/src/query/src/qExecutor.c b/src/query/src/qExecutor.c index 6e0eb373ac96c84e3e5eecf6f1bcf9aabf336f09..1249f6db3082b411b6d47ecc56501cdbc90b9bed 100644 --- a/src/query/src/qExecutor.c +++ b/src/query/src/qExecutor.c @@ -414,6 +414,10 @@ static bool isSelectivityWithTagsQuery(SQLFunctionCtx *pCtx, int32_t numOfOutput for (int32_t i = 0; i < numOfOutput; ++i) { int32_t functId = pCtx[i].functionId; + if (TSDB_FUNC_IS_SCALAR(functId)) { + continue; + } + if (functId == TSDB_FUNC_TAG_DUMMY || functId == TSDB_FUNC_TS_DUMMY) { hasTags = true; continue; @@ -433,13 +437,14 @@ static bool isScalarWithTagsQuery(SQLFunctionCtx *pCtx, int32_t numOfOutput) { for (int32_t i = 0; i < numOfOutput; ++i) { int32_t functId = pCtx[i].functionId; - if (functId == TSDB_FUNC_TAG_DUMMY || functId == TSDB_FUNC_TS_DUMMY) { - hasTags = true; + if (TSDB_FUNC_IS_SCALAR(functId)) { + numOfScalar++; continue; } - if ((aAggs[functId].status & TSDB_FUNCSTATE_SCALAR) != 0) { - numOfScalar++; + if (functId == TSDB_FUNC_TAG_DUMMY || functId == TSDB_FUNC_TS_DUMMY) { + hasTags = true; + continue; } } @@ -974,8 +979,10 @@ static void doApplyFunctions(SQueryRuntimeEnv* pRuntimeEnv, SQLFunctionCtx* pCtx if (functionId < 0) { // load the script and exec, pRuntimeEnv->pUdfInfo SUdfInfo* pUdfInfo = pRuntimeEnv->pUdfInfo; doInvokeUdf(pUdfInfo, &pCtx[k], 0, TSDB_UDF_FUNC_NORMAL); - } else { + } else if (!TSDB_FUNC_IS_SCALAR(functionId)){ aAggs[functionId].xFunction(&pCtx[k]); + } else { + assert(0); } } @@ -1116,7 +1123,7 @@ static TSKEY getStartTsKey(SQueryAttr* pQueryAttr, STimeWindow* win, const TSKEY return ts; } -static void setArithParams(SArithmeticSupport* sas, SExprInfo *pExprInfo, SSDataBlock* pSDataBlock) { +static void setArithParams(SScalarExprSupport* sas, SExprInfo *pExprInfo, SSDataBlock* pSDataBlock) { sas->numOfCols = (int32_t) pSDataBlock->info.numOfCols; sas->pExprInfo = pExprInfo; if (sas->colList) { @@ -1152,8 +1159,8 @@ static void doSetInputDataBlockInfo(SOperatorInfo* pOperator, SQLFunctionCtx* pC } void setInputDataBlock(SOperatorInfo* pOperator, SQLFunctionCtx* pCtx, SSDataBlock* pBlock, int32_t order) { - if (pCtx[0].functionId == TSDB_FUNC_ARITHM) { - SArithmeticSupport* pSupport = (SArithmeticSupport*) pCtx[0].param[1].pz; + if (pCtx[0].functionId == TSDB_FUNC_SCALAR_EXPR) { + SScalarExprSupport* pSupport = (SScalarExprSupport*) pCtx[0].param[1].pz; if (pSupport->colList == NULL) { doSetInputDataBlock(pOperator, pCtx, pBlock, order); } else { @@ -1176,8 +1183,8 @@ static void doSetInputDataBlock(SOperatorInfo* pOperator, SQLFunctionCtx* pCtx, setBlockStatisInfo(&pCtx[i], pBlock, &pOperator->pExpr[i].base.colInfo); - if (pCtx[i].functionId == TSDB_FUNC_ARITHM) { - setArithParams((SArithmeticSupport*)pCtx[i].param[1].pz, &pOperator->pExpr[i], pBlock); + if (pCtx[i].functionId == TSDB_FUNC_SCALAR_EXPR) { + setArithParams((SScalarExprSupport*)pCtx[i].param[1].pz, &pOperator->pExpr[i], pBlock); } else { SColIndex* pCol = &pOperator->pExpr[i].base.colInfo; if (TSDB_COL_IS_NORMAL_COL(pCol->flag) || (pCtx[i].functionId == TSDB_FUNC_BLKINFO) || @@ -1190,10 +1197,9 @@ static void doSetInputDataBlock(SOperatorInfo* pOperator, SQLFunctionCtx* pCtx, pCtx[i].colId = p->info.colId; assert(p->info.colId == pColIndex->colId && pCtx[i].inputType == p->info.type); - if (pCtx[i].functionId < 0) { + if (pCtx[i].functionId < 0 || TSDB_FUNC_IS_SCALAR(pCtx[i].functionId)) { SColumnInfoData* tsInfo = taosArrayGet(pBlock->pDataBlock, 0); - pCtx[i].ptsList = (int64_t*) tsInfo->pData; - + pCtx[i].ptsList = (int64_t*)tsInfo->pData; continue; } @@ -1234,8 +1240,10 @@ static void doAggregateImpl(SOperatorInfo* pOperator, TSKEY startTs, SQLFunction if (functionId < 0) { SUdfInfo* pUdfInfo = pRuntimeEnv->pUdfInfo; doInvokeUdf(pUdfInfo, &pCtx[k], 0, TSDB_UDF_FUNC_NORMAL); - } else { + } else if (!TSDB_FUNC_IS_SCALAR(functionId)){ aAggs[functionId].xFunction(&pCtx[k]); + } else { + assert(0); } } } @@ -1255,8 +1263,10 @@ static void projectApplyFunctions(SQueryRuntimeEnv *pRuntimeEnv, SQLFunctionCtx // load the script and exec SUdfInfo* pUdfInfo = pRuntimeEnv->pUdfInfo; doInvokeUdf(pUdfInfo, &pCtx[k], 0, TSDB_UDF_FUNC_NORMAL); - } else { + } else if (!TSDB_FUNC_IS_SCALAR(pCtx[k].functionId)) { aAggs[pCtx[k].functionId].xFunction(&pCtx[k]); + } else { + assert(0); } } } @@ -1855,11 +1865,14 @@ static int32_t setCtxTagColumnInfo(SQLFunctionCtx *pCtx, int32_t numOfOutput) { for (int32_t i = 0; i < numOfOutput; ++i) { int32_t functionId = pCtx[i].functionId; + if (functionId < 0 || TSDB_FUNC_IS_SCALAR(functionId)) { + continue; + } if (functionId == TSDB_FUNC_TAG_DUMMY || functionId == TSDB_FUNC_TS_DUMMY) { tagLen += pCtx[i].outputBytes; pTagCtx[num++] = &pCtx[i]; - } else if ((aAggs[functionId].status & TSDB_FUNCSTATE_SELECTIVITY) != 0 || (aAggs[functionId].status & TSDB_FUNCSTATE_SCALAR) != 0) { + } else if ((aAggs[functionId].status & TSDB_FUNCSTATE_SELECTIVITY) != 0) { p = &pCtx[i]; } else if (functionId == TSDB_FUNC_TS || functionId == TSDB_FUNC_TAG) { // tag function may be the group by tag column @@ -1972,7 +1985,7 @@ static SQLFunctionCtx* createSQLFunctionCtx(SQueryRuntimeEnv* pRuntimeEnv, SExpr pCtx->param[1].nType = TSDB_DATA_TYPE_BIGINT; pCtx->param[2].i64 = pQueryAttr->window.ekey; pCtx->param[2].nType = TSDB_DATA_TYPE_BIGINT; - } else if (functionId == TSDB_FUNC_ARITHM) { + } else if (functionId == TSDB_FUNC_SCALAR_EXPR) { pCtx->param[1].pz = (char*) &pRuntimeEnv->sasArray[i]; } } @@ -2023,7 +2036,7 @@ static int32_t setupQueryRuntimeEnv(SQueryRuntimeEnv *pRuntimeEnv, int32_t numOf // NOTE: pTableCheckInfo need to update the query time range and the lastKey info pRuntimeEnv->pTableRetrieveTsMap = taosHashInit(numOfTables, taosGetDefaultHashFunction(TSDB_DATA_TYPE_INT), false, HASH_NO_LOCK); - pRuntimeEnv->sasArray = calloc(pQueryAttr->numOfOutput, sizeof(SArithmeticSupport)); + pRuntimeEnv->sasArray = calloc(pQueryAttr->numOfOutput, sizeof(SScalarExprSupport)); if (pRuntimeEnv->sasArray == NULL || pRuntimeEnv->pResultRowHashTable == NULL || pRuntimeEnv->keyBuf == NULL || pRuntimeEnv->prevRow == NULL || pRuntimeEnv->tagVal == NULL) { @@ -2198,7 +2211,13 @@ static int32_t setupQueryRuntimeEnv(SQueryRuntimeEnv *pRuntimeEnv, int32_t numOf } case OP_Order: { - pRuntimeEnv->proot = createOrderOperatorInfo(pRuntimeEnv, pRuntimeEnv->proot, pQueryAttr->pExpr1, pQueryAttr->numOfOutput, &pQueryAttr->order); + if (pQueryAttr->pExpr2 != NULL) { + pRuntimeEnv->proot = createOrderOperatorInfo(pRuntimeEnv, pRuntimeEnv->proot, pQueryAttr->pExpr2, + pQueryAttr->numOfExpr2, &pQueryAttr->order); + } else { + pRuntimeEnv->proot = createOrderOperatorInfo(pRuntimeEnv, pRuntimeEnv->proot, pQueryAttr->pExpr1, + pQueryAttr->numOfOutput, &pQueryAttr->order); + } break; } @@ -2955,7 +2974,7 @@ static uint32_t doFilterByBlockTimeWindow(STableScanInfo* pTableScanInfo, SSData int32_t colId = pTableScanInfo->pExpr[i].base.colInfo.colId; // group by + first/last should not apply the first/last block filter - if (functionId < 0) { + if (functionId < 0 || TSDB_FUNC_IS_SCALAR(functionId)) { status |= BLK_DATA_ALL_NEEDED; return status; } else { @@ -3665,8 +3684,10 @@ void initCtxOutputBuffer(SQLFunctionCtx* pCtx, int32_t size) { if (pCtx[j].functionId < 0) { // todo udf initialization continue; - } else { + } else if (!TSDB_FUNC_IS_SCALAR(pCtx[j].functionId)) { aAggs[pCtx[j].functionId].init(&pCtx[j], pCtx[j].resultInfo); + } else { + assert(0); } } } @@ -3725,8 +3746,10 @@ void finalizeQueryResult(SOperatorInfo* pOperator, SQLFunctionCtx* pCtx, SResult pCtx[j].startTs = buf->win.skey; if (pCtx[j].functionId < 0) { doInvokeUdf(pRuntimeEnv->pUdfInfo, &pCtx[j], 0, TSDB_UDF_FUNC_FINALIZE); - } else { + } else if (!TSDB_FUNC_IS_SCALAR(pCtx[j].functionId)) { aAggs[pCtx[j].functionId].xFinalize(&pCtx[j]); + } else { + assert(0); } } @@ -3742,8 +3765,10 @@ void finalizeQueryResult(SOperatorInfo* pOperator, SQLFunctionCtx* pCtx, SResult for (int32_t j = 0; j < numOfOutput; ++j) { if (pCtx[j].functionId < 0) { doInvokeUdf(pRuntimeEnv->pUdfInfo, &pCtx[j], 0, TSDB_UDF_FUNC_FINALIZE); - } else { + } else if (!TSDB_FUNC_IS_SCALAR(pCtx[j].functionId)) { aAggs[pCtx[j].functionId].xFinalize(&pCtx[j]); + } else { + assert(0); } } } @@ -3831,9 +3856,6 @@ void setResultRowOutputBufInitCtx(SQueryRuntimeEnv *pRuntimeEnv, SResultRow *pRe offset += pCtx[i].outputBytes; int32_t functionId = pCtx[i].functionId; - if (functionId < 0) { - continue; - } if (functionId == TSDB_FUNC_TOP || functionId == TSDB_FUNC_BOTTOM || functionId == TSDB_FUNC_DIFF || functionId == TSDB_FUNC_CSUM || functionId == TSDB_FUNC_MAVG || functionId == TSDB_FUNC_SAMPLE) { @@ -3841,7 +3863,13 @@ void setResultRowOutputBufInitCtx(SQueryRuntimeEnv *pRuntimeEnv, SResultRow *pRe } if (!pResInfo->initialized) { - aAggs[functionId].init(&pCtx[i], pResInfo); + if (functionId < 0 ) { + doInvokeUdf(pRuntimeEnv->pUdfInfo, &pCtx[i], 0, TSDB_UDF_FUNC_INIT); + } else if (!TSDB_FUNC_IS_SCALAR(functionId)) { + aAggs[functionId].init(&pCtx[i], pResInfo); + } else { + assert(0); + } } } } @@ -5544,8 +5572,8 @@ SOperatorInfo *createOrderOperatorInfo(SQueryRuntimeEnv* pRuntimeEnv, SOperatorI for(int32_t i = 0; i < numOfOutput; ++i) { SColumnInfoData col = {{0}}; col.info.colId = pExpr[i].base.colInfo.colId; - col.info.bytes = pExpr[i].base.colBytes; - col.info.type = pExpr[i].base.colType; + col.info.bytes = pExpr[i].base.resBytes; + col.info.type = pExpr[i].base.resType; taosArrayPush(pDataBlock->pDataBlock, &col); if (col.info.colId == pOrderVal->orderColId) { @@ -5767,7 +5795,15 @@ static SSDataBlock* doProjectOperation(void* param, bool* newgroup) { break; } else { // init output buffer for a new group data for (int32_t j = 0; j < pOperator->numOfOutput; ++j) { - aAggs[pInfo->pCtx[j].functionId].xFinalize(&pInfo->pCtx[j]); + int16_t functionId = pInfo->pCtx[j].functionId; + if (functionId < 0 ) { + SUdfInfo* pUdfInfo = pRuntimeEnv->pUdfInfo; + doInvokeUdf(pUdfInfo, &pInfo->pCtx[j], 0, TSDB_UDF_FUNC_FINALIZE); + } else if (!TSDB_FUNC_IS_SCALAR(functionId)) { + aAggs[pInfo->pCtx[j].functionId].xFinalize(&pInfo->pCtx[j]); + } else { + assert(0); + } } initCtxOutputBuffer(pInfo->pCtx, pOperator->numOfOutput); } @@ -8261,7 +8297,7 @@ int32_t cloneExprFilterInfo(SColumnFilterInfo **dst, SColumnFilterInfo* src, int return TSDB_CODE_SUCCESS; } -int32_t buildArithmeticExprFromMsg(SExprInfo *pExprInfo, void *pQueryMsg) { +int32_t buildScalarExprFromMsg(SExprInfo *pExprInfo, void *pQueryMsg) { qDebug("qmsg:%p create arithmetic expr from binary", pQueryMsg); tExprNode* pExprNode = NULL; @@ -8474,16 +8510,13 @@ int32_t createQueryFunc(SQueriedTableInfo* pTableInfo, int32_t numOfOutput, SExp int16_t bytes = 0; // parse the arithmetic expression - if (pExprs[i].base.functionId == TSDB_FUNC_ARITHM) { - code = buildArithmeticExprFromMsg(&pExprs[i], pMsg); + if (pExprs[i].base.functionId == TSDB_FUNC_SCALAR_EXPR) { + code = buildScalarExprFromMsg(&pExprs[i], pMsg); if (code != TSDB_CODE_SUCCESS) { tfree(pExprs); return code; } - - type = TSDB_DATA_TYPE_DOUBLE; - bytes = tDataTypes[type].bytes; } else if (pExprs[i].base.functionId == TSDB_FUNC_BLKINFO) { SSchema s = {.type=TSDB_DATA_TYPE_BINARY, .bytes=TSDB_MAX_BINARY_LEN}; type = s.type; @@ -8537,14 +8570,14 @@ int32_t createQueryFunc(SQueriedTableInfo* pTableInfo, int32_t numOfOutput, SExp } int32_t param = (int32_t)pExprs[i].base.param[0].i64; - if (pExprs[i].base.functionId > 0 && pExprs[i].base.functionId != TSDB_FUNC_ARITHM && + if (pExprs[i].base.functionId > 0 && pExprs[i].base.functionId != TSDB_FUNC_SCALAR_EXPR && (type != pExprs[i].base.colType || bytes != pExprs[i].base.colBytes)) { tfree(pExprs); return TSDB_CODE_QRY_INVALID_MSG; } // todo remove it - if (getResultDataInfo(type, bytes, pExprs[i].base.functionId, param, &pExprs[i].base.resType, &pExprs[i].base.resBytes, + if (pExprs[i].base.functionId != TSDB_FUNC_SCALAR_EXPR && getResultDataInfo(type, bytes, pExprs[i].base.functionId, param, &pExprs[i].base.resType, &pExprs[i].base.resBytes, &pExprs[i].base.interBytes, 0, isSuperTable, pUdfInfo) != TSDB_CODE_SUCCESS) { tfree(pExprs); return TSDB_CODE_QRY_INVALID_MSG; @@ -8613,31 +8646,32 @@ int32_t createIndirectQueryFuncExprFromMsg(SQueryTableMsg* pQueryMsg, int32_t nu int16_t bytes = 0; // parse the arithmetic expression - if (pExprs[i].base.functionId == TSDB_FUNC_ARITHM) { - code = buildArithmeticExprFromMsg(&pExprs[i], pQueryMsg); + if (pExprs[i].base.functionId == TSDB_FUNC_SCALAR_EXPR) { + code = buildScalarExprFromMsg(&pExprs[i], pQueryMsg); if (code != TSDB_CODE_SUCCESS) { tfree(pExprs); return code; } - type = TSDB_DATA_TYPE_DOUBLE; - bytes = tDataTypes[type].bytes; + pExprs[i].base.resBytes = pExprs[i].pExpr->resultBytes; + pExprs[i].base.resType = pExprs[i].pExpr->resultType; + pExprs[i].base.interBytes = 0; } else { int32_t index = pExprs[i].base.colInfo.colIndex; assert(prevExpr[index].base.resColId == pExprs[i].base.colInfo.colId); - type = prevExpr[index].base.resType; + type = prevExpr[index].base.resType; bytes = prevExpr[index].base.resBytes; - } - int32_t param = (int32_t)pExprs[i].base.param[0].i64; - if (getResultDataInfo(type, bytes, pExprs[i].base.functionId, param, &pExprs[i].base.resType, &pExprs[i].base.resBytes, - &pExprs[i].base.interBytes, 0, isSuperTable, pUdfInfo) != TSDB_CODE_SUCCESS) { - tfree(pExprs); - return TSDB_CODE_QRY_INVALID_MSG; + int32_t param = (int32_t)pExprs[i].base.param[0].i64; + if (getResultDataInfo(type, bytes, pExprs[i].base.functionId, param, &pExprs[i].base.resType, + &pExprs[i].base.resBytes, &pExprs[i].base.interBytes, 0, isSuperTable, + pUdfInfo) != TSDB_CODE_SUCCESS) { + tfree(pExprs); + return TSDB_CODE_QRY_INVALID_MSG; + } } - assert(isValidDataType(pExprs[i].base.resType)); } @@ -8757,7 +8791,7 @@ static void doUpdateExprColumnIndex(SQueryAttr *pQueryAttr) { for (int32_t k = 0; k < pQueryAttr->numOfOutput; ++k) { SSqlExpr *pSqlExprMsg = &pQueryAttr->pExpr1[k].base; - if (pSqlExprMsg->functionId == TSDB_FUNC_ARITHM) { + if (pSqlExprMsg->functionId == TSDB_FUNC_SCALAR_EXPR) { continue; } @@ -9406,4 +9440,3 @@ void freeQueryAttr(SQueryAttr* pQueryAttr) { filterFreeInfo(pQueryAttr->pFilters); } } - diff --git a/src/query/src/qPercentile.c b/src/query/src/qPercentile.c index 024ba77de13086b7ff8e32ab2c4c7340d8806b6b..8428c339f4e89d6a5e988448f3aadadf522102b1 100644 --- a/src/query/src/qPercentile.c +++ b/src/query/src/qPercentile.c @@ -74,7 +74,7 @@ static int32_t setBoundingBox(MinMaxEntry* range, int16_t type, double minval, d } } else if (IS_UNSIGNED_NUMERIC_TYPE(type)){ range->u64MinVal = (uint64_t) minval; - if ((uint64_t)maxval > UINT64_MAX) { + if (maxval > UINT64_MAX) { range->u64MaxVal = UINT64_MAX; } else { range->u64MaxVal = (uint64_t) maxval; @@ -146,7 +146,7 @@ int32_t tBucketIntHash(tMemBucket *pBucket, const void *value) { } int32_t tBucketUintHash(tMemBucket *pBucket, const void *value) { - int64_t v = 0; + uint64_t v = 0; GET_TYPED_DATA(v, uint64_t, pBucket->type, value); int32_t index = -1; @@ -162,8 +162,8 @@ int32_t tBucketUintHash(tMemBucket *pBucket, const void *value) { index = (int32_t) (delta % pBucket->numOfSlots); } else { double slotSpan = (double)span / pBucket->numOfSlots; - index = (int32_t)((v - pBucket->range.u64MinVal) / slotSpan); - if (v == pBucket->range.u64MaxVal) { + index = (int32_t)(((double)v - pBucket->range.u64MinVal) / slotSpan); + if (index == pBucket->numOfSlots) { index -= 1; } } @@ -194,7 +194,7 @@ int32_t tBucketDoubleHash(tMemBucket *pBucket, const void *value) { } else { double slotSpan = span / pBucket->numOfSlots; index = (int32_t)((v - pBucket->range.dMinVal) / slotSpan); - if (v == pBucket->range.dMaxVal) { + if (index == pBucket->numOfSlots) { index -= 1; } } diff --git a/src/query/src/qPlan.c b/src/query/src/qPlan.c index eb3a3f36207d27d610e29bd890a56b2ef411157c..4c61cbb0f730780c6c7106a02c765974b2d21706 100644 --- a/src/query/src/qPlan.c +++ b/src/query/src/qPlan.c @@ -567,6 +567,10 @@ SArray* createExecOperatorPlan(SQueryAttr* pQueryAttr) { } else if (pQueryAttr->pointInterpQuery) { op = OP_TimeEvery; taosArrayPush(plan, &op); + if (pQueryAttr->pExpr2 != NULL) { + op = OP_Project; + taosArrayPush(plan, &op); + } } else if (pQueryAttr->interval.interval > 0) { if (pQueryAttr->stableQuery) { op = OP_MultiTableTimeInterval; @@ -691,7 +695,6 @@ SArray* createGlobalMergePlan(SQueryAttr* pQueryAttr) { op = OP_Filter; taosArrayPush(plan, &op); } - if (pQueryAttr->pExpr2 != NULL) { op = OP_Project; taosArrayPush(plan, &op); diff --git a/src/query/src/qSqlParser.c b/src/query/src/qSqlParser.c index 64f8eb05d2a1d17f3fa21db3cd489337dc53d53e..f34f54710dfd259a338ad43e5d299eb0e6e2283d 100644 --- a/src/query/src/qSqlParser.c +++ b/src/query/src/qSqlParser.c @@ -178,6 +178,14 @@ tSqlExpr *tSqlExprCreateIdValue(SSqlInfo* pInfo, SStrToken *pToken, int32_t optr pSqlExpr->value.nType = TSDB_DATA_TYPE_BIGINT; pSqlExpr->tokenId = TK_TIMESTAMP; pSqlExpr->type = SQL_NODE_VALUE; + } else if (optrType == TK_AS) { + // Here it must be column type + if (pToken != NULL) { + pSqlExpr->dataType = *(TAOS_FIELD *)pToken; + } + + pSqlExpr->tokenId = optrType; + pSqlExpr->type = SQL_NODE_DATA_TYPE; } else { // Here it must be the column name (tk_id) if it is not a number or string. assert(optrType == TK_ID || optrType == TK_ALL); @@ -275,6 +283,25 @@ tSqlExpr *tSqlExprCreateFunction(SArray *pParam, SStrToken *pFuncToken, SStrToke return pExpr; } +tSqlExpr *tSqlExprCreateFuncWithParams(SSqlInfo *pInfo, tSqlExpr* col, TAOS_FIELD *colType, SStrToken *pFuncToken, SStrToken *endToken, int32_t optType) { + if (colType == NULL || col == NULL) { + return NULL; + } + + if (NULL == col) { + return NULL; + } + + tSqlExpr* ctype = tSqlExprCreateIdValue(pInfo, (SStrToken *)colType, TK_AS); + + SArray *exprList = tSqlExprListAppend(0,col,0, 0); + + tSqlExprListAppend(exprList,ctype,0, 0); + + return tSqlExprCreateFunction(exprList, pFuncToken, endToken, optType); +} + + /* * create binary expression in this procedure * if the expr is arithmetic, calculate the result and set it to tSqlExpr Object @@ -391,7 +418,7 @@ tSqlExpr *tSqlExprCreate(tSqlExpr *pLeft, tSqlExpr *pRight, int32_t optrType) { pExpr->tokenId = optrType; pExpr->pLeft = pLeft; pExpr->pRight = pRight; - pExpr->type = SQL_NODE_TABLE_COLUMN; + pExpr->type = SQL_NODE_EXPR; } else { pExpr->tokenId = optrType; pExpr->pLeft = pLeft; @@ -825,6 +852,10 @@ void tSetColumnType(TAOS_FIELD *pField, SStrToken *type) { pField->bytes = (int16_t)bytes; } + } else { + if (type->type > 0) { + pField->type = -1; + } } } diff --git a/src/query/src/sql.c b/src/query/src/sql.c index 120feeb2046b5539ed8acc8510064919d7289187..0b8e9542742b9ab8b04d265c7cd6da0e482b7c92 100644 --- a/src/query/src/sql.c +++ b/src/query/src/sql.c @@ -83,164 +83,163 @@ #define TK_STAR 41 #define TK_SLASH 42 #define TK_REM 43 -#define TK_CONCAT 44 -#define TK_UMINUS 45 -#define TK_UPLUS 46 -#define TK_BITNOT 47 -#define TK_ARROW 48 -#define TK_SHOW 49 -#define TK_DATABASES 50 -#define TK_TOPICS 51 -#define TK_FUNCTIONS 52 -#define TK_MNODES 53 -#define TK_DNODES 54 -#define TK_ACCOUNTS 55 -#define TK_USERS 56 -#define TK_MODULES 57 -#define TK_QUERIES 58 -#define TK_CONNECTIONS 59 -#define TK_STREAMS 60 -#define TK_VARIABLES 61 -#define TK_SCORES 62 -#define TK_GRANTS 63 -#define TK_VNODES 64 -#define TK_DOT 65 -#define TK_CREATE 66 -#define TK_TABLE 67 -#define TK_STABLE 68 -#define TK_DATABASE 69 -#define TK_TABLES 70 -#define TK_STABLES 71 -#define TK_VGROUPS 72 -#define TK_DROP 73 -#define TK_TOPIC 74 -#define TK_FUNCTION 75 -#define TK_DNODE 76 -#define TK_USER 77 -#define TK_ACCOUNT 78 -#define TK_USE 79 -#define TK_DESCRIBE 80 -#define TK_DESC 81 -#define TK_ALTER 82 -#define TK_PASS 83 -#define TK_PRIVILEGE 84 -#define TK_LOCAL 85 -#define TK_COMPACT 86 -#define TK_LP 87 -#define TK_RP 88 -#define TK_IF 89 -#define TK_EXISTS 90 -#define TK_AS 91 -#define TK_OUTPUTTYPE 92 -#define TK_AGGREGATE 93 -#define TK_BUFSIZE 94 -#define TK_PPS 95 -#define TK_TSERIES 96 -#define TK_DBS 97 -#define TK_STORAGE 98 -#define TK_QTIME 99 -#define TK_CONNS 100 -#define TK_STATE 101 -#define TK_COMMA 102 -#define TK_KEEP 103 -#define TK_CACHE 104 -#define TK_REPLICA 105 -#define TK_QUORUM 106 -#define TK_DAYS 107 -#define TK_MINROWS 108 -#define TK_MAXROWS 109 -#define TK_BLOCKS 110 -#define TK_CTIME 111 -#define TK_WAL 112 -#define TK_FSYNC 113 -#define TK_COMP 114 -#define TK_PRECISION 115 -#define TK_UPDATE 116 -#define TK_CACHELAST 117 -#define TK_PARTITIONS 118 -#define TK_UNSIGNED 119 -#define TK_TAGS 120 -#define TK_USING 121 -#define TK_NULL 122 -#define TK_NOW 123 -#define TK_SELECT 124 -#define TK_UNION 125 -#define TK_ALL 126 -#define TK_DISTINCT 127 -#define TK_FROM 128 -#define TK_VARIABLE 129 -#define TK_RANGE 130 -#define TK_INTERVAL 131 -#define TK_EVERY 132 -#define TK_SESSION 133 -#define TK_STATE_WINDOW 134 -#define TK_FILL 135 -#define TK_SLIDING 136 -#define TK_ORDER 137 -#define TK_BY 138 -#define TK_ASC 139 -#define TK_GROUP 140 -#define TK_HAVING 141 -#define TK_LIMIT 142 -#define TK_OFFSET 143 -#define TK_SLIMIT 144 -#define TK_SOFFSET 145 -#define TK_WHERE 146 -#define TK_RESET 147 -#define TK_QUERY 148 -#define TK_SYNCDB 149 -#define TK_ADD 150 -#define TK_COLUMN 151 -#define TK_MODIFY 152 -#define TK_TAG 153 -#define TK_CHANGE 154 -#define TK_SET 155 -#define TK_KILL 156 -#define TK_CONNECTION 157 -#define TK_STREAM 158 -#define TK_COLON 159 -#define TK_ABORT 160 -#define TK_AFTER 161 -#define TK_ATTACH 162 -#define TK_BEFORE 163 -#define TK_BEGIN 164 -#define TK_CASCADE 165 -#define TK_CLUSTER 166 -#define TK_CONFLICT 167 -#define TK_COPY 168 -#define TK_DEFERRED 169 -#define TK_DELIMITERS 170 -#define TK_DETACH 171 -#define TK_EACH 172 -#define TK_END 173 -#define TK_EXPLAIN 174 -#define TK_FAIL 175 -#define TK_FOR 176 -#define TK_IGNORE 177 -#define TK_IMMEDIATE 178 -#define TK_INITIALLY 179 -#define TK_INSTEAD 180 -#define TK_KEY 181 -#define TK_OF 182 -#define TK_RAISE 183 -#define TK_REPLACE 184 -#define TK_RESTRICT 185 -#define TK_ROW 186 -#define TK_STATEMENT 187 -#define TK_TRIGGER 188 -#define TK_VIEW 189 -#define TK_IPTOKEN 190 -#define TK_SEMI 191 -#define TK_NONE 192 -#define TK_PREV 193 -#define TK_LINEAR 194 -#define TK_IMPORT 195 -#define TK_TBNAME 196 -#define TK_JOIN 197 -#define TK_INSERT 198 -#define TK_INTO 199 -#define TK_VALUES 200 -#define TK_FILE 201 +#define TK_UMINUS 44 +#define TK_UPLUS 45 +#define TK_BITNOT 46 +#define TK_ARROW 47 +#define TK_SHOW 48 +#define TK_DATABASES 49 +#define TK_TOPICS 50 +#define TK_FUNCTIONS 51 +#define TK_MNODES 52 +#define TK_DNODES 53 +#define TK_ACCOUNTS 54 +#define TK_USERS 55 +#define TK_MODULES 56 +#define TK_QUERIES 57 +#define TK_CONNECTIONS 58 +#define TK_STREAMS 59 +#define TK_VARIABLES 60 +#define TK_SCORES 61 +#define TK_GRANTS 62 +#define TK_VNODES 63 +#define TK_DOT 64 +#define TK_CREATE 65 +#define TK_TABLE 66 +#define TK_STABLE 67 +#define TK_DATABASE 68 +#define TK_TABLES 69 +#define TK_STABLES 70 +#define TK_VGROUPS 71 +#define TK_DROP 72 +#define TK_TOPIC 73 +#define TK_FUNCTION 74 +#define TK_DNODE 75 +#define TK_USER 76 +#define TK_ACCOUNT 77 +#define TK_USE 78 +#define TK_DESCRIBE 79 +#define TK_DESC 80 +#define TK_ALTER 81 +#define TK_PASS 82 +#define TK_PRIVILEGE 83 +#define TK_LOCAL 84 +#define TK_COMPACT 85 +#define TK_LP 86 +#define TK_RP 87 +#define TK_IF 88 +#define TK_EXISTS 89 +#define TK_AS 90 +#define TK_OUTPUTTYPE 91 +#define TK_AGGREGATE 92 +#define TK_BUFSIZE 93 +#define TK_PPS 94 +#define TK_TSERIES 95 +#define TK_DBS 96 +#define TK_STORAGE 97 +#define TK_QTIME 98 +#define TK_CONNS 99 +#define TK_STATE 100 +#define TK_COMMA 101 +#define TK_KEEP 102 +#define TK_CACHE 103 +#define TK_REPLICA 104 +#define TK_QUORUM 105 +#define TK_DAYS 106 +#define TK_MINROWS 107 +#define TK_MAXROWS 108 +#define TK_BLOCKS 109 +#define TK_CTIME 110 +#define TK_WAL 111 +#define TK_FSYNC 112 +#define TK_COMP 113 +#define TK_PRECISION 114 +#define TK_UPDATE 115 +#define TK_CACHELAST 116 +#define TK_PARTITIONS 117 +#define TK_UNSIGNED 118 +#define TK_TAGS 119 +#define TK_USING 120 +#define TK_NULL 121 +#define TK_NOW 122 +#define TK_SELECT 123 +#define TK_UNION 124 +#define TK_ALL 125 +#define TK_DISTINCT 126 +#define TK_FROM 127 +#define TK_VARIABLE 128 +#define TK_RANGE 129 +#define TK_INTERVAL 130 +#define TK_EVERY 131 +#define TK_SESSION 132 +#define TK_STATE_WINDOW 133 +#define TK_FILL 134 +#define TK_SLIDING 135 +#define TK_ORDER 136 +#define TK_BY 137 +#define TK_ASC 138 +#define TK_GROUP 139 +#define TK_HAVING 140 +#define TK_LIMIT 141 +#define TK_OFFSET 142 +#define TK_SLIMIT 143 +#define TK_SOFFSET 144 +#define TK_WHERE 145 +#define TK_RESET 146 +#define TK_QUERY 147 +#define TK_SYNCDB 148 +#define TK_ADD 149 +#define TK_COLUMN 150 +#define TK_MODIFY 151 +#define TK_TAG 152 +#define TK_CHANGE 153 +#define TK_SET 154 +#define TK_KILL 155 +#define TK_CONNECTION 156 +#define TK_STREAM 157 +#define TK_COLON 158 +#define TK_ABORT 159 +#define TK_AFTER 160 +#define TK_ATTACH 161 +#define TK_BEFORE 162 +#define TK_BEGIN 163 +#define TK_CASCADE 164 +#define TK_CLUSTER 165 +#define TK_CONFLICT 166 +#define TK_COPY 167 +#define TK_DEFERRED 168 +#define TK_DELIMITERS 169 +#define TK_DETACH 170 +#define TK_EACH 171 +#define TK_END 172 +#define TK_EXPLAIN 173 +#define TK_FAIL 174 +#define TK_FOR 175 +#define TK_IGNORE 176 +#define TK_IMMEDIATE 177 +#define TK_INITIALLY 178 +#define TK_INSTEAD 179 +#define TK_KEY 180 +#define TK_OF 181 +#define TK_RAISE 182 +#define TK_REPLACE 183 +#define TK_RESTRICT 184 +#define TK_ROW 185 +#define TK_STATEMENT 186 +#define TK_TRIGGER 187 +#define TK_VIEW 188 +#define TK_IPTOKEN 189 +#define TK_SEMI 190 +#define TK_NONE 191 +#define TK_PREV 192 +#define TK_LINEAR 193 +#define TK_IMPORT 194 +#define TK_TBNAME 195 +#define TK_JOIN 196 +#define TK_INSERT 197 +#define TK_INTO 198 +#define TK_VALUES 199 +#define TK_FILE 200 #endif /**************** End token definitions ***************************************/ @@ -300,30 +299,30 @@ #endif /************* Begin control #defines *****************************************/ #define YYCODETYPE unsigned short int -#define YYNOCODE 285 +#define YYNOCODE 284 #define YYACTIONTYPE unsigned short int #define ParseTOKENTYPE SStrToken typedef union { int yyinit; ParseTOKENTYPE yy0; - SCreateAcctInfo yy31; - SSqlNode* yy86; - TAOS_FIELD yy103; - tVariant yy176; - tSqlExpr* yy226; - SWindowStateVal yy228; - SArray* yy231; - SCreatedTableInfo yy306; - int32_t yy310; - SSessionWindowVal yy409; - SCreateTableSql* yy422; - SIntervalVal yy430; - SLimitVal yy444; - SRangeVal yy480; - SRelationInfo* yy484; - int yy502; - SCreateDbInfo yy532; - int64_t yy549; + SCreateTableSql* yy6; + SSqlNode* yy16; + tSqlExpr* yy18; + SIntervalVal yy32; + SRelationInfo* yy36; + SLimitVal yy38; + SCreateAcctInfo yy51; + int64_t yy69; + SRangeVal yy124; + SSessionWindowVal yy155; + tVariant yy162; + SArray* yy189; + SCreatedTableInfo yy208; + TAOS_FIELD yy279; + SWindowStateVal yy336; + int yy420; + SCreateDbInfo yy470; + int32_t yy516; } YYMINORTYPE; #ifndef YYSTACKDEPTH #define YYSTACKDEPTH 100 @@ -339,18 +338,18 @@ typedef union { #define ParseCTX_FETCH #define ParseCTX_STORE #define YYFALLBACK 1 -#define YYNSTATE 387 -#define YYNRULE 312 -#define YYNRULE_WITH_ACTION 312 -#define YYNTOKEN 202 -#define YY_MAX_SHIFT 386 -#define YY_MIN_SHIFTREDUCE 609 -#define YY_MAX_SHIFTREDUCE 920 -#define YY_ERROR_ACTION 921 -#define YY_ACCEPT_ACTION 922 -#define YY_NO_ACTION 923 -#define YY_MIN_REDUCE 924 -#define YY_MAX_REDUCE 1235 +#define YYNSTATE 390 +#define YYNRULE 313 +#define YYNRULE_WITH_ACTION 313 +#define YYNTOKEN 201 +#define YY_MAX_SHIFT 389 +#define YY_MIN_SHIFTREDUCE 613 +#define YY_MAX_SHIFTREDUCE 925 +#define YY_ERROR_ACTION 926 +#define YY_ACCEPT_ACTION 927 +#define YY_NO_ACTION 928 +#define YY_MIN_REDUCE 929 +#define YY_MAX_REDUCE 1241 /************* End control #defines *******************************************/ #define YY_NLOOKAHEAD ((int)(sizeof(yy_lookahead)/sizeof(yy_lookahead[0]))) @@ -417,309 +416,314 @@ typedef union { ** yy_default[] Default action for each state. ** *********** Begin parsing tables **********************************************/ -#define YY_ACTTAB_COUNT (831) +#define YY_ACTTAB_COUNT (854) static const YYACTIONTYPE yy_action[] = { - /* 0 */ 101, 660, 660, 1153, 660, 1154, 309, 744, 1073, 661, - /* 10 */ 661, 160, 661, 104, 37, 38, 248, 41, 42, 385, - /* 20 */ 239, 261, 31, 30, 29, 922, 386, 40, 341, 45, - /* 30 */ 43, 46, 44, 1062, 1063, 55, 1066, 36, 35, 363, - /* 40 */ 362, 34, 33, 32, 37, 38, 24, 41, 42, 1067, - /* 50 */ 696, 261, 31, 30, 29, 254, 1209, 40, 341, 45, - /* 60 */ 43, 46, 44, 1049, 1078, 1047, 1048, 36, 35, 1101, - /* 70 */ 1050, 34, 33, 32, 1051, 1092, 1052, 1053, 58, 36, - /* 80 */ 35, 290, 289, 34, 33, 32, 37, 38, 51, 41, - /* 90 */ 42, 84, 283, 261, 31, 30, 29, 660, 90, 40, - /* 100 */ 341, 45, 43, 46, 44, 661, 384, 383, 637, 36, - /* 110 */ 35, 211, 212, 34, 33, 32, 37, 39, 852, 41, - /* 120 */ 42, 1209, 1209, 261, 31, 30, 29, 1075, 337, 40, - /* 130 */ 341, 45, 43, 46, 44, 67, 58, 58, 1098, 36, - /* 140 */ 35, 381, 1010, 34, 33, 32, 610, 611, 612, 613, - /* 150 */ 614, 615, 616, 617, 618, 619, 620, 621, 622, 623, - /* 160 */ 158, 38, 240, 41, 42, 58, 54, 261, 31, 30, - /* 170 */ 29, 812, 813, 40, 341, 45, 43, 46, 44, 284, - /* 180 */ 218, 241, 251, 36, 35, 1076, 1076, 34, 33, 32, - /* 190 */ 1209, 41, 42, 59, 175, 261, 31, 30, 29, 319, - /* 200 */ 264, 40, 341, 45, 43, 46, 44, 34, 33, 32, - /* 210 */ 252, 36, 35, 299, 1076, 34, 33, 32, 66, 335, - /* 220 */ 380, 379, 334, 333, 332, 378, 331, 330, 329, 377, - /* 230 */ 328, 376, 375, 313, 96, 291, 95, 25, 1041, 1029, - /* 240 */ 1030, 1031, 1032, 1033, 1034, 1035, 1036, 1037, 1038, 1039, - /* 250 */ 1040, 1042, 1043, 214, 217, 246, 232, 867, 58, 1079, - /* 260 */ 856, 225, 859, 1209, 862, 1211, 1231, 143, 142, 141, - /* 270 */ 224, 373, 232, 867, 348, 90, 856, 265, 859, 263, - /* 280 */ 862, 351, 350, 157, 155, 154, 45, 43, 46, 44, - /* 290 */ 972, 58, 237, 238, 36, 35, 342, 195, 34, 33, - /* 300 */ 32, 800, 858, 352, 861, 803, 219, 1076, 237, 238, - /* 310 */ 1, 183, 67, 5, 61, 185, 1209, 1151, 58, 1152, - /* 320 */ 184, 110, 115, 106, 114, 768, 269, 857, 765, 860, - /* 330 */ 766, 258, 767, 295, 296, 282, 353, 82, 1223, 324, - /* 340 */ 1076, 98, 47, 97, 233, 257, 127, 121, 132, 1164, - /* 350 */ 253, 262, 58, 131, 1079, 137, 140, 130, 47, 275, - /* 360 */ 266, 267, 784, 354, 134, 58, 58, 1076, 279, 278, - /* 370 */ 294, 293, 66, 340, 380, 379, 832, 868, 863, 378, - /* 380 */ 205, 203, 201, 377, 864, 376, 375, 200, 147, 146, - /* 390 */ 145, 144, 214, 868, 863, 13, 339, 355, 1065, 100, - /* 400 */ 864, 1076, 1209, 271, 1212, 268, 214, 358, 357, 58, - /* 410 */ 359, 360, 214, 260, 1076, 1076, 1209, 58, 1212, 244, - /* 420 */ 345, 220, 1209, 1201, 1212, 270, 865, 1200, 1199, 103, - /* 430 */ 235, 1209, 236, 1209, 831, 6, 181, 1209, 1209, 1163, - /* 440 */ 1209, 83, 1209, 215, 292, 769, 770, 216, 788, 221, - /* 450 */ 213, 866, 255, 1209, 361, 222, 1079, 1209, 1076, 1209, - /* 460 */ 1209, 223, 365, 227, 228, 1209, 1076, 1092, 229, 226, - /* 470 */ 210, 1209, 1092, 1209, 1209, 1064, 982, 270, 1209, 1209, - /* 480 */ 1209, 270, 129, 195, 242, 99, 973, 337, 182, 243, - /* 490 */ 3, 196, 1077, 195, 373, 781, 87, 88, 809, 819, - /* 500 */ 85, 820, 339, 75, 78, 15, 754, 14, 316, 344, - /* 510 */ 756, 318, 162, 70, 755, 48, 895, 869, 259, 312, - /* 520 */ 59, 10, 59, 659, 70, 102, 871, 120, 70, 119, - /* 530 */ 9, 9, 343, 286, 286, 81, 17, 9, 16, 773, - /* 540 */ 771, 774, 772, 139, 138, 79, 76, 19, 126, 18, - /* 550 */ 125, 21, 26, 20, 249, 1160, 1159, 280, 855, 250, - /* 560 */ 364, 159, 1100, 1111, 1108, 1109, 1093, 743, 1113, 287, - /* 570 */ 161, 166, 305, 1143, 1142, 1141, 177, 1074, 178, 1140, - /* 580 */ 156, 1072, 179, 180, 987, 321, 322, 323, 326, 174, - /* 590 */ 327, 68, 208, 64, 338, 981, 349, 799, 1230, 117, - /* 600 */ 298, 167, 245, 300, 302, 1090, 80, 1229, 314, 1226, - /* 610 */ 186, 356, 168, 77, 28, 169, 1222, 310, 123, 1221, - /* 620 */ 1218, 187, 308, 1007, 306, 65, 170, 172, 60, 69, - /* 630 */ 304, 209, 171, 173, 969, 133, 967, 135, 136, 301, - /* 640 */ 965, 964, 272, 198, 199, 961, 960, 959, 958, 957, - /* 650 */ 956, 955, 297, 202, 204, 951, 949, 947, 27, 206, - /* 660 */ 944, 207, 940, 325, 374, 285, 128, 86, 91, 303, - /* 670 */ 366, 367, 234, 368, 369, 371, 256, 370, 320, 372, - /* 680 */ 382, 920, 273, 274, 230, 231, 919, 276, 277, 918, - /* 690 */ 986, 985, 111, 112, 901, 281, 900, 286, 315, 11, - /* 700 */ 89, 963, 962, 52, 954, 190, 189, 1008, 148, 188, - /* 710 */ 191, 192, 194, 193, 149, 150, 953, 2, 151, 1045, - /* 720 */ 1009, 4, 946, 53, 176, 945, 776, 288, 92, 808, - /* 730 */ 73, 806, 1055, 805, 802, 801, 74, 165, 810, 163, - /* 740 */ 247, 821, 164, 22, 815, 93, 62, 817, 94, 307, - /* 750 */ 343, 311, 23, 63, 12, 49, 317, 50, 103, 674, - /* 760 */ 105, 56, 107, 108, 57, 109, 709, 707, 706, 705, - /* 770 */ 703, 702, 701, 698, 336, 664, 113, 7, 892, 890, - /* 780 */ 870, 893, 891, 8, 346, 872, 347, 116, 71, 59, - /* 790 */ 746, 72, 118, 122, 745, 124, 742, 690, 688, 680, - /* 800 */ 686, 682, 684, 678, 676, 712, 711, 710, 708, 704, - /* 810 */ 700, 699, 197, 662, 627, 924, 923, 923, 923, 923, - /* 820 */ 923, 923, 923, 923, 923, 923, 923, 923, 923, 152, - /* 830 */ 153, + /* 0 */ 102, 664, 664, 1158, 161, 1159, 311, 804, 260, 665, + /* 10 */ 665, 807, 388, 241, 37, 38, 24, 41, 42, 1078, + /* 20 */ 1070, 263, 31, 30, 29, 1083, 1215, 40, 343, 45, + /* 30 */ 43, 46, 44, 1067, 1068, 55, 1071, 36, 35, 297, + /* 40 */ 298, 34, 33, 32, 37, 38, 213, 41, 42, 250, + /* 50 */ 84, 263, 31, 30, 29, 214, 1215, 40, 343, 45, + /* 60 */ 43, 46, 44, 927, 389, 1215, 256, 36, 35, 211, + /* 70 */ 215, 34, 33, 32, 292, 291, 128, 122, 133, 1215, + /* 80 */ 1215, 1218, 1217, 132, 1069, 138, 141, 131, 37, 38, + /* 90 */ 85, 41, 42, 977, 135, 263, 31, 30, 29, 664, + /* 100 */ 196, 40, 343, 45, 43, 46, 44, 665, 339, 286, + /* 110 */ 13, 36, 35, 1097, 101, 34, 33, 32, 37, 38, + /* 120 */ 58, 41, 42, 60, 246, 263, 31, 30, 29, 220, + /* 130 */ 285, 40, 343, 45, 43, 46, 44, 315, 97, 1215, + /* 140 */ 96, 36, 35, 664, 104, 34, 33, 32, 339, 37, + /* 150 */ 39, 665, 41, 42, 1097, 176, 263, 31, 30, 29, + /* 160 */ 1106, 856, 40, 343, 45, 43, 46, 44, 34, 33, + /* 170 */ 32, 244, 36, 35, 301, 221, 34, 33, 32, 206, + /* 180 */ 204, 202, 376, 59, 51, 1215, 201, 148, 147, 146, + /* 190 */ 145, 614, 615, 616, 617, 618, 619, 620, 621, 622, + /* 200 */ 623, 624, 625, 626, 627, 159, 987, 242, 38, 277, + /* 210 */ 41, 42, 59, 196, 263, 31, 30, 29, 281, 280, + /* 220 */ 40, 343, 45, 43, 46, 44, 978, 222, 243, 1103, + /* 230 */ 36, 35, 1081, 196, 34, 33, 32, 1215, 41, 42, + /* 240 */ 384, 1015, 263, 31, 30, 29, 1, 184, 40, 343, + /* 250 */ 45, 43, 46, 44, 387, 386, 641, 253, 36, 35, + /* 260 */ 700, 1081, 34, 33, 32, 67, 337, 383, 382, 336, + /* 270 */ 335, 334, 381, 333, 332, 331, 380, 330, 379, 378, + /* 280 */ 1046, 1034, 1035, 1036, 1037, 1038, 1039, 1040, 1041, 1042, + /* 290 */ 1043, 1044, 1045, 1047, 1048, 234, 871, 25, 862, 860, + /* 300 */ 865, 863, 1237, 866, 772, 59, 59, 769, 1207, 770, + /* 310 */ 861, 771, 864, 1206, 219, 1205, 234, 871, 1215, 59, + /* 320 */ 860, 227, 863, 1215, 866, 1215, 59, 144, 143, 142, + /* 330 */ 226, 239, 240, 788, 351, 91, 5, 62, 186, 268, + /* 340 */ 269, 3, 197, 185, 111, 116, 107, 115, 266, 91, + /* 350 */ 254, 355, 239, 240, 1081, 1081, 345, 45, 43, 46, + /* 360 */ 44, 59, 326, 271, 356, 36, 35, 785, 1081, 34, + /* 370 */ 33, 32, 68, 1229, 67, 1080, 383, 382, 36, 35, + /* 380 */ 47, 381, 34, 33, 32, 380, 68, 379, 378, 1054, + /* 390 */ 259, 1052, 1053, 10, 293, 284, 1055, 83, 264, 1169, + /* 400 */ 1056, 47, 1057, 1058, 235, 59, 357, 59, 59, 342, + /* 410 */ 1081, 158, 156, 155, 748, 872, 867, 1097, 792, 59, + /* 420 */ 130, 869, 868, 773, 774, 267, 100, 265, 59, 354, + /* 430 */ 353, 341, 376, 870, 245, 294, 872, 867, 88, 237, + /* 440 */ 273, 86, 270, 868, 361, 360, 366, 365, 262, 1215, + /* 450 */ 358, 215, 362, 363, 1081, 238, 1081, 1081, 1156, 215, + /* 460 */ 1157, 1215, 217, 1218, 364, 1215, 218, 105, 1081, 1215, + /* 470 */ 6, 1218, 1215, 368, 223, 288, 1215, 1081, 836, 216, + /* 480 */ 224, 225, 229, 230, 1215, 99, 231, 98, 228, 1215, + /* 490 */ 1215, 1215, 1215, 1215, 212, 248, 1215, 89, 1215, 1084, + /* 500 */ 272, 255, 257, 1072, 1215, 1084, 1084, 816, 817, 272, + /* 510 */ 272, 182, 272, 296, 295, 813, 823, 824, 341, 76, + /* 520 */ 183, 344, 79, 1082, 758, 318, 760, 320, 759, 163, + /* 530 */ 71, 48, 54, 347, 288, 314, 835, 900, 60, 60, + /* 540 */ 71, 103, 71, 873, 261, 348, 663, 15, 82, 14, + /* 550 */ 282, 9, 121, 1168, 120, 346, 17, 9, 16, 251, + /* 560 */ 9, 1165, 77, 80, 777, 321, 778, 19, 775, 18, + /* 570 */ 776, 160, 127, 21, 126, 20, 140, 139, 1164, 252, + /* 580 */ 747, 1105, 367, 26, 859, 1116, 1113, 178, 1114, 1118, + /* 590 */ 162, 1098, 167, 289, 307, 1079, 179, 1148, 1077, 1147, + /* 600 */ 1146, 1145, 180, 181, 992, 157, 323, 324, 325, 300, + /* 610 */ 328, 329, 803, 169, 69, 209, 65, 340, 986, 352, + /* 620 */ 1095, 247, 1236, 118, 302, 304, 81, 1235, 1232, 187, + /* 630 */ 359, 78, 168, 316, 1228, 124, 1227, 1224, 188, 1012, + /* 640 */ 28, 312, 172, 170, 171, 66, 61, 70, 210, 310, + /* 650 */ 876, 974, 134, 308, 972, 136, 137, 970, 969, 306, + /* 660 */ 274, 199, 299, 200, 966, 303, 965, 964, 963, 962, + /* 670 */ 961, 960, 203, 205, 327, 956, 954, 952, 207, 27, + /* 680 */ 949, 208, 945, 377, 129, 287, 87, 92, 305, 369, + /* 690 */ 370, 371, 372, 373, 374, 236, 375, 258, 322, 385, + /* 700 */ 925, 276, 924, 275, 232, 278, 279, 923, 173, 233, + /* 710 */ 991, 990, 112, 906, 113, 905, 283, 288, 317, 11, + /* 720 */ 290, 90, 968, 967, 780, 149, 959, 191, 190, 1013, + /* 730 */ 189, 192, 193, 195, 194, 2, 52, 150, 1014, 4, + /* 740 */ 1050, 151, 958, 951, 53, 152, 174, 177, 175, 950, + /* 750 */ 93, 812, 74, 1060, 810, 809, 806, 805, 75, 166, + /* 760 */ 814, 164, 249, 825, 165, 22, 819, 94, 63, 821, + /* 770 */ 95, 309, 346, 313, 12, 64, 23, 49, 319, 50, + /* 780 */ 104, 106, 109, 56, 108, 678, 713, 711, 710, 57, + /* 790 */ 110, 709, 707, 706, 705, 702, 668, 338, 114, 7, + /* 800 */ 897, 895, 875, 898, 874, 896, 8, 877, 350, 117, + /* 810 */ 72, 60, 349, 119, 73, 123, 750, 125, 749, 746, + /* 820 */ 694, 692, 684, 690, 686, 688, 682, 680, 716, 715, + /* 830 */ 714, 712, 708, 704, 703, 198, 666, 631, 929, 928, + /* 840 */ 928, 928, 928, 928, 928, 928, 928, 928, 928, 928, + /* 850 */ 928, 928, 153, 154, }; static const YYCODETYPE yy_lookahead[] = { - /* 0 */ 212, 1, 1, 280, 1, 282, 283, 5, 204, 9, - /* 10 */ 9, 204, 9, 212, 14, 15, 1, 17, 18, 204, - /* 20 */ 205, 21, 22, 23, 24, 202, 203, 27, 28, 29, - /* 30 */ 30, 31, 32, 245, 246, 247, 248, 37, 38, 37, - /* 40 */ 38, 41, 42, 43, 14, 15, 272, 17, 18, 248, - /* 50 */ 5, 21, 22, 23, 24, 251, 282, 27, 28, 29, - /* 60 */ 30, 31, 32, 228, 254, 230, 231, 37, 38, 204, - /* 70 */ 235, 41, 42, 43, 239, 252, 241, 242, 204, 37, - /* 80 */ 38, 274, 275, 41, 42, 43, 14, 15, 87, 17, - /* 90 */ 18, 91, 269, 21, 22, 23, 24, 1, 87, 27, - /* 100 */ 28, 29, 30, 31, 32, 9, 70, 71, 72, 37, - /* 110 */ 38, 272, 272, 41, 42, 43, 14, 15, 88, 17, - /* 120 */ 18, 282, 282, 21, 22, 23, 24, 253, 89, 27, - /* 130 */ 28, 29, 30, 31, 32, 124, 204, 204, 273, 37, - /* 140 */ 38, 226, 227, 41, 42, 43, 50, 51, 52, 53, - /* 150 */ 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, - /* 160 */ 64, 15, 66, 17, 18, 204, 87, 21, 22, 23, - /* 170 */ 24, 131, 132, 27, 28, 29, 30, 31, 32, 88, - /* 180 */ 272, 249, 249, 37, 38, 253, 253, 41, 42, 43, - /* 190 */ 282, 17, 18, 102, 259, 21, 22, 23, 24, 120, - /* 200 */ 73, 27, 28, 29, 30, 31, 32, 41, 42, 43, - /* 210 */ 249, 37, 38, 278, 253, 41, 42, 43, 103, 104, - /* 220 */ 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, - /* 230 */ 115, 116, 117, 279, 280, 277, 282, 49, 228, 229, - /* 240 */ 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, - /* 250 */ 240, 241, 242, 272, 66, 250, 1, 2, 204, 254, - /* 260 */ 5, 73, 7, 282, 9, 284, 254, 79, 80, 81, - /* 270 */ 82, 95, 1, 2, 86, 87, 5, 150, 7, 152, - /* 280 */ 9, 154, 155, 67, 68, 69, 29, 30, 31, 32, - /* 290 */ 210, 204, 37, 38, 37, 38, 41, 217, 41, 42, - /* 300 */ 43, 5, 5, 249, 7, 9, 272, 253, 37, 38, - /* 310 */ 213, 214, 124, 67, 68, 69, 282, 280, 204, 282, - /* 320 */ 74, 75, 76, 77, 78, 2, 73, 5, 5, 7, - /* 330 */ 7, 211, 9, 37, 38, 147, 249, 149, 254, 93, - /* 340 */ 253, 280, 87, 282, 156, 211, 67, 68, 69, 244, - /* 350 */ 250, 211, 204, 74, 254, 76, 77, 78, 87, 148, - /* 360 */ 37, 38, 41, 249, 85, 204, 204, 253, 157, 158, - /* 370 */ 37, 38, 103, 25, 105, 106, 81, 122, 123, 110, - /* 380 */ 67, 68, 69, 114, 129, 116, 117, 74, 75, 76, - /* 390 */ 77, 78, 272, 122, 123, 87, 48, 249, 0, 91, - /* 400 */ 129, 253, 282, 150, 284, 152, 272, 154, 155, 204, - /* 410 */ 249, 249, 272, 65, 253, 253, 282, 204, 284, 123, - /* 420 */ 16, 272, 282, 272, 284, 204, 129, 272, 272, 121, - /* 430 */ 272, 282, 272, 282, 139, 87, 215, 282, 282, 244, - /* 440 */ 282, 212, 282, 272, 277, 122, 123, 272, 127, 272, - /* 450 */ 272, 129, 250, 282, 249, 272, 254, 282, 253, 282, - /* 460 */ 282, 272, 249, 272, 272, 282, 253, 252, 272, 272, - /* 470 */ 272, 282, 252, 282, 282, 246, 210, 204, 282, 282, - /* 480 */ 282, 204, 83, 217, 269, 255, 210, 89, 215, 269, - /* 490 */ 208, 209, 215, 217, 95, 102, 88, 88, 88, 88, - /* 500 */ 270, 88, 48, 102, 102, 151, 88, 153, 88, 25, - /* 510 */ 88, 88, 102, 102, 88, 102, 88, 88, 1, 65, - /* 520 */ 102, 128, 102, 88, 102, 102, 122, 151, 102, 153, - /* 530 */ 102, 102, 48, 125, 125, 87, 151, 102, 153, 5, - /* 540 */ 5, 7, 7, 83, 84, 143, 145, 151, 151, 153, - /* 550 */ 153, 151, 271, 153, 244, 244, 244, 204, 41, 244, - /* 560 */ 244, 204, 204, 204, 204, 204, 252, 119, 204, 252, - /* 570 */ 204, 204, 204, 281, 281, 281, 256, 252, 204, 281, - /* 580 */ 65, 204, 204, 204, 204, 204, 204, 204, 204, 260, - /* 590 */ 204, 204, 204, 204, 204, 204, 204, 129, 204, 204, - /* 600 */ 276, 267, 276, 276, 276, 268, 142, 204, 137, 204, - /* 610 */ 204, 204, 266, 144, 141, 265, 204, 140, 204, 204, - /* 620 */ 204, 204, 135, 204, 134, 204, 264, 262, 204, 204, - /* 630 */ 133, 204, 263, 261, 204, 204, 204, 204, 204, 136, - /* 640 */ 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, - /* 650 */ 204, 204, 130, 204, 204, 204, 204, 204, 146, 204, - /* 660 */ 204, 204, 204, 94, 118, 206, 101, 206, 206, 206, - /* 670 */ 100, 56, 206, 97, 99, 98, 206, 60, 206, 96, - /* 680 */ 89, 5, 159, 5, 206, 206, 5, 159, 5, 5, - /* 690 */ 216, 216, 212, 212, 105, 148, 104, 125, 120, 87, - /* 700 */ 126, 206, 206, 87, 206, 219, 223, 225, 207, 224, - /* 710 */ 222, 220, 218, 221, 207, 207, 206, 213, 207, 243, - /* 720 */ 227, 208, 206, 258, 257, 206, 88, 102, 102, 88, - /* 730 */ 102, 129, 243, 129, 5, 5, 87, 102, 88, 87, - /* 740 */ 1, 88, 87, 138, 88, 87, 102, 88, 87, 87, - /* 750 */ 48, 1, 138, 102, 87, 87, 120, 87, 121, 5, - /* 760 */ 83, 92, 91, 75, 92, 91, 9, 5, 5, 5, - /* 770 */ 5, 5, 5, 5, 16, 90, 83, 87, 9, 9, - /* 780 */ 88, 9, 9, 87, 28, 122, 64, 153, 17, 102, - /* 790 */ 5, 17, 153, 153, 5, 153, 88, 5, 5, 5, - /* 800 */ 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, - /* 810 */ 5, 5, 102, 90, 65, 0, 285, 285, 285, 285, - /* 820 */ 285, 285, 285, 285, 285, 285, 285, 285, 285, 22, - /* 830 */ 22, 285, 285, 285, 285, 285, 285, 285, 285, 285, - /* 840 */ 285, 285, 285, 285, 285, 285, 285, 285, 285, 285, - /* 850 */ 285, 285, 285, 285, 285, 285, 285, 285, 285, 285, - /* 860 */ 285, 285, 285, 285, 285, 285, 285, 285, 285, 285, - /* 870 */ 285, 285, 285, 285, 285, 285, 285, 285, 285, 285, - /* 880 */ 285, 285, 285, 285, 285, 285, 285, 285, 285, 285, - /* 890 */ 285, 285, 285, 285, 285, 285, 285, 285, 285, 285, - /* 900 */ 285, 285, 285, 285, 285, 285, 285, 285, 285, 285, - /* 910 */ 285, 285, 285, 285, 285, 285, 285, 285, 285, 285, - /* 920 */ 285, 285, 285, 285, 285, 285, 285, 285, 285, 285, - /* 930 */ 285, 285, 285, 285, 285, 285, 285, 285, 285, 285, - /* 940 */ 285, 285, 285, 285, 285, 285, 285, 285, 285, 285, - /* 950 */ 285, 285, 285, 285, 285, 285, 285, 285, 285, 285, - /* 960 */ 285, 285, 285, 285, 285, 285, 285, 285, 285, 285, - /* 970 */ 285, 285, 285, 285, 285, 285, 285, 285, 285, 285, - /* 980 */ 285, 285, 285, 285, 285, 285, 285, 285, 285, 285, - /* 990 */ 285, 285, 285, 285, 285, 285, 285, 285, 285, 285, - /* 1000 */ 285, 285, 285, 285, 285, 285, 285, 285, 285, 285, - /* 1010 */ 285, 285, 285, 285, 285, 285, 285, 285, 285, 285, - /* 1020 */ 285, 285, 285, 285, 285, 285, 285, 285, 285, 285, - /* 1030 */ 285, 285, 285, + /* 0 */ 211, 1, 1, 279, 203, 281, 282, 5, 210, 9, + /* 10 */ 9, 9, 203, 204, 14, 15, 271, 17, 18, 203, + /* 20 */ 0, 21, 22, 23, 24, 253, 281, 27, 28, 29, + /* 30 */ 30, 31, 32, 244, 245, 246, 247, 37, 38, 37, + /* 40 */ 38, 41, 42, 43, 14, 15, 271, 17, 18, 1, + /* 50 */ 211, 21, 22, 23, 24, 271, 281, 27, 28, 29, + /* 60 */ 30, 31, 32, 201, 202, 281, 250, 37, 38, 271, + /* 70 */ 271, 41, 42, 43, 273, 274, 66, 67, 68, 281, + /* 80 */ 281, 283, 283, 73, 245, 75, 76, 77, 14, 15, + /* 90 */ 90, 17, 18, 209, 84, 21, 22, 23, 24, 1, + /* 100 */ 216, 27, 28, 29, 30, 31, 32, 9, 88, 87, + /* 110 */ 86, 37, 38, 251, 90, 41, 42, 43, 14, 15, + /* 120 */ 90, 17, 18, 101, 122, 21, 22, 23, 24, 271, + /* 130 */ 268, 27, 28, 29, 30, 31, 32, 278, 279, 281, + /* 140 */ 281, 37, 38, 1, 120, 41, 42, 43, 88, 14, + /* 150 */ 15, 9, 17, 18, 251, 258, 21, 22, 23, 24, + /* 160 */ 203, 87, 27, 28, 29, 30, 31, 32, 41, 42, + /* 170 */ 43, 268, 37, 38, 277, 271, 41, 42, 43, 66, + /* 180 */ 67, 68, 94, 203, 86, 281, 73, 74, 75, 76, + /* 190 */ 77, 49, 50, 51, 52, 53, 54, 55, 56, 57, + /* 200 */ 58, 59, 60, 61, 62, 63, 209, 65, 15, 147, + /* 210 */ 17, 18, 203, 216, 21, 22, 23, 24, 156, 157, + /* 220 */ 27, 28, 29, 30, 31, 32, 209, 271, 248, 272, + /* 230 */ 37, 38, 252, 216, 41, 42, 43, 281, 17, 18, + /* 240 */ 225, 226, 21, 22, 23, 24, 212, 213, 27, 28, + /* 250 */ 29, 30, 31, 32, 69, 70, 71, 248, 37, 38, + /* 260 */ 5, 252, 41, 42, 43, 102, 103, 104, 105, 106, + /* 270 */ 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, + /* 280 */ 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, + /* 290 */ 237, 238, 239, 240, 241, 1, 2, 48, 5, 5, + /* 300 */ 7, 7, 253, 9, 2, 203, 203, 5, 271, 7, + /* 310 */ 5, 9, 7, 271, 65, 271, 1, 2, 281, 203, + /* 320 */ 5, 72, 7, 281, 9, 281, 203, 78, 79, 80, + /* 330 */ 81, 37, 38, 41, 85, 86, 66, 67, 68, 37, + /* 340 */ 38, 207, 208, 73, 74, 75, 76, 77, 72, 86, + /* 350 */ 248, 248, 37, 38, 252, 252, 41, 29, 30, 31, + /* 360 */ 32, 203, 92, 72, 248, 37, 38, 101, 252, 41, + /* 370 */ 42, 43, 123, 253, 102, 252, 104, 105, 37, 38, + /* 380 */ 86, 109, 41, 42, 43, 113, 123, 115, 116, 227, + /* 390 */ 210, 229, 230, 127, 276, 146, 234, 148, 210, 243, + /* 400 */ 238, 86, 240, 241, 155, 203, 248, 203, 203, 25, + /* 410 */ 252, 66, 67, 68, 5, 121, 122, 251, 126, 203, + /* 420 */ 82, 128, 128, 121, 122, 149, 254, 151, 203, 153, + /* 430 */ 154, 47, 94, 128, 268, 276, 121, 122, 87, 271, + /* 440 */ 149, 269, 151, 128, 153, 154, 37, 38, 64, 281, + /* 450 */ 248, 271, 248, 248, 252, 271, 252, 252, 279, 271, + /* 460 */ 281, 281, 271, 283, 248, 281, 271, 211, 252, 281, + /* 470 */ 86, 283, 281, 248, 271, 124, 281, 252, 80, 271, + /* 480 */ 271, 271, 271, 271, 281, 279, 271, 281, 271, 281, + /* 490 */ 281, 281, 281, 281, 271, 249, 281, 87, 281, 253, + /* 500 */ 203, 249, 249, 247, 281, 253, 253, 130, 131, 203, + /* 510 */ 203, 214, 203, 37, 38, 87, 87, 87, 47, 101, + /* 520 */ 214, 214, 101, 214, 87, 87, 87, 87, 87, 101, + /* 530 */ 101, 101, 86, 25, 124, 64, 138, 87, 101, 101, + /* 540 */ 101, 101, 101, 87, 1, 16, 87, 150, 86, 152, + /* 550 */ 203, 101, 150, 243, 152, 47, 150, 101, 152, 243, + /* 560 */ 101, 243, 144, 142, 5, 119, 7, 150, 5, 152, + /* 570 */ 7, 203, 150, 150, 152, 152, 82, 83, 243, 243, + /* 580 */ 118, 203, 243, 270, 41, 203, 203, 255, 203, 203, + /* 590 */ 203, 251, 203, 251, 203, 251, 203, 280, 203, 280, + /* 600 */ 280, 280, 203, 203, 203, 64, 203, 203, 203, 275, + /* 610 */ 203, 203, 128, 265, 203, 203, 203, 203, 203, 203, + /* 620 */ 267, 275, 203, 203, 275, 275, 141, 203, 203, 203, + /* 630 */ 203, 143, 266, 136, 203, 203, 203, 203, 203, 203, + /* 640 */ 140, 139, 262, 264, 263, 203, 203, 203, 203, 134, + /* 650 */ 121, 203, 203, 133, 203, 203, 203, 203, 203, 132, + /* 660 */ 203, 203, 129, 203, 203, 135, 203, 203, 203, 203, + /* 670 */ 203, 203, 203, 203, 93, 203, 203, 203, 203, 145, + /* 680 */ 203, 203, 203, 117, 100, 205, 205, 205, 205, 99, + /* 690 */ 55, 96, 98, 59, 97, 205, 95, 205, 205, 88, + /* 700 */ 5, 5, 5, 158, 205, 158, 5, 5, 261, 205, + /* 710 */ 215, 215, 211, 104, 211, 103, 147, 124, 119, 86, + /* 720 */ 101, 125, 205, 205, 87, 206, 205, 218, 222, 224, + /* 730 */ 223, 221, 219, 217, 220, 212, 86, 206, 226, 207, + /* 740 */ 242, 206, 205, 205, 257, 206, 260, 256, 259, 205, + /* 750 */ 101, 87, 101, 242, 128, 128, 5, 5, 86, 101, + /* 760 */ 87, 86, 1, 87, 86, 137, 87, 86, 101, 87, + /* 770 */ 86, 86, 47, 1, 86, 101, 137, 86, 119, 86, + /* 780 */ 120, 82, 74, 91, 90, 5, 9, 5, 5, 91, + /* 790 */ 90, 5, 5, 5, 5, 5, 89, 16, 82, 86, + /* 800 */ 9, 9, 87, 9, 87, 9, 86, 121, 63, 152, + /* 810 */ 17, 101, 28, 152, 17, 152, 5, 152, 5, 87, + /* 820 */ 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, + /* 830 */ 5, 5, 5, 5, 5, 101, 89, 64, 0, 284, + /* 840 */ 284, 284, 284, 284, 284, 284, 284, 284, 284, 284, + /* 850 */ 284, 284, 22, 22, 284, 284, 284, 284, 284, 284, + /* 860 */ 284, 284, 284, 284, 284, 284, 284, 284, 284, 284, + /* 870 */ 284, 284, 284, 284, 284, 284, 284, 284, 284, 284, + /* 880 */ 284, 284, 284, 284, 284, 284, 284, 284, 284, 284, + /* 890 */ 284, 284, 284, 284, 284, 284, 284, 284, 284, 284, + /* 900 */ 284, 284, 284, 284, 284, 284, 284, 284, 284, 284, + /* 910 */ 284, 284, 284, 284, 284, 284, 284, 284, 284, 284, + /* 920 */ 284, 284, 284, 284, 284, 284, 284, 284, 284, 284, + /* 930 */ 284, 284, 284, 284, 284, 284, 284, 284, 284, 284, + /* 940 */ 284, 284, 284, 284, 284, 284, 284, 284, 284, 284, + /* 950 */ 284, 284, 284, 284, 284, 284, 284, 284, 284, 284, + /* 960 */ 284, 284, 284, 284, 284, 284, 284, 284, 284, 284, + /* 970 */ 284, 284, 284, 284, 284, 284, 284, 284, 284, 284, + /* 980 */ 284, 284, 284, 284, 284, 284, 284, 284, 284, 284, + /* 990 */ 284, 284, 284, 284, 284, 284, 284, 284, 284, 284, + /* 1000 */ 284, 284, 284, 284, 284, 284, 284, 284, 284, 284, + /* 1010 */ 284, 284, 284, 284, 284, 284, 284, 284, 284, 284, + /* 1020 */ 284, 284, 284, 284, 284, 284, 284, 284, 284, 284, + /* 1030 */ 284, 284, 284, 284, 284, 284, 284, 284, 284, 284, + /* 1040 */ 284, 284, 284, 284, 284, 284, 284, 284, 284, 284, + /* 1050 */ 284, 284, 284, 284, 284, }; -#define YY_SHIFT_COUNT (386) +#define YY_SHIFT_COUNT (389) #define YY_SHIFT_MIN (0) -#define YY_SHIFT_MAX (815) +#define YY_SHIFT_MAX (838) static const unsigned short int yy_shift_ofst[] = { - /* 0 */ 188, 115, 115, 269, 269, 39, 255, 271, 271, 271, - /* 10 */ 1, 3, 3, 3, 3, 3, 3, 3, 3, 3, - /* 20 */ 3, 3, 15, 15, 0, 96, 271, 271, 271, 271, - /* 30 */ 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, - /* 40 */ 271, 271, 271, 271, 271, 271, 271, 271, 323, 323, - /* 50 */ 323, 11, 11, 40, 3, 398, 3, 3, 3, 3, - /* 60 */ 399, 39, 15, 15, 176, 176, 45, 831, 831, 831, - /* 70 */ 323, 323, 323, 296, 296, 2, 2, 2, 2, 2, - /* 80 */ 2, 2, 3, 3, 3, 321, 3, 3, 3, 11, - /* 90 */ 11, 3, 3, 3, 3, 295, 295, 295, 295, 393, - /* 100 */ 11, 3, 3, 3, 3, 3, 3, 3, 3, 3, - /* 110 */ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, - /* 120 */ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, - /* 130 */ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, - /* 140 */ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, - /* 150 */ 3, 3, 3, 3, 3, 3, 3, 3, 3, 515, - /* 160 */ 515, 515, 468, 468, 468, 468, 515, 464, 469, 471, - /* 170 */ 473, 477, 487, 490, 497, 503, 522, 512, 515, 515, - /* 180 */ 515, 569, 569, 546, 39, 39, 515, 515, 565, 570, - /* 190 */ 615, 576, 575, 617, 577, 583, 546, 45, 515, 515, - /* 200 */ 591, 591, 515, 591, 515, 591, 515, 515, 831, 831, - /* 210 */ 30, 72, 72, 102, 72, 146, 174, 246, 257, 257, - /* 220 */ 257, 257, 257, 257, 279, 313, 42, 42, 42, 42, - /* 230 */ 127, 253, 348, 211, 308, 166, 166, 297, 322, 36, - /* 240 */ 216, 91, 408, 409, 333, 410, 411, 413, 454, 401, - /* 250 */ 402, 418, 420, 422, 423, 426, 79, 428, 429, 484, - /* 260 */ 517, 404, 435, 354, 376, 385, 534, 535, 396, 397, - /* 270 */ 448, 400, 460, 676, 523, 678, 681, 528, 683, 684, - /* 280 */ 589, 592, 547, 572, 578, 612, 574, 638, 616, 625, - /* 290 */ 626, 641, 628, 602, 604, 729, 730, 649, 650, 652, - /* 300 */ 653, 655, 656, 635, 658, 659, 661, 739, 662, 644, - /* 310 */ 605, 702, 750, 651, 614, 667, 578, 668, 636, 670, - /* 320 */ 637, 677, 669, 671, 688, 754, 672, 674, 757, 762, - /* 330 */ 763, 764, 765, 766, 767, 768, 685, 758, 693, 769, - /* 340 */ 770, 690, 692, 772, 773, 663, 696, 756, 722, 771, - /* 350 */ 634, 639, 687, 687, 687, 687, 774, 640, 642, 687, - /* 360 */ 687, 687, 785, 789, 708, 687, 792, 793, 794, 795, - /* 370 */ 796, 797, 798, 799, 800, 801, 802, 803, 804, 805, - /* 380 */ 806, 710, 723, 807, 808, 749, 815, + /* 0 */ 249, 163, 163, 272, 272, 60, 315, 294, 294, 294, + /* 10 */ 98, 1, 1, 1, 1, 1, 1, 1, 1, 1, + /* 20 */ 1, 1, 48, 48, 0, 142, 294, 294, 294, 294, + /* 30 */ 294, 294, 294, 294, 294, 294, 294, 294, 294, 294, + /* 40 */ 294, 294, 294, 294, 294, 294, 294, 294, 302, 302, + /* 50 */ 302, 263, 263, 377, 1, 20, 1, 1, 1, 1, + /* 60 */ 1, 338, 60, 48, 48, 88, 88, 255, 854, 854, + /* 70 */ 854, 302, 302, 302, 2, 2, 409, 409, 409, 409, + /* 80 */ 409, 409, 409, 1, 1, 1, 292, 1, 1, 1, + /* 90 */ 263, 263, 1, 1, 1, 1, 398, 398, 398, 398, + /* 100 */ 266, 263, 1, 1, 1, 1, 1, 1, 1, 1, + /* 110 */ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + /* 120 */ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + /* 130 */ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + /* 140 */ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + /* 150 */ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + /* 160 */ 541, 541, 541, 484, 484, 484, 484, 541, 485, 488, + /* 170 */ 497, 500, 502, 515, 520, 527, 530, 533, 534, 541, + /* 180 */ 541, 541, 581, 581, 566, 60, 60, 541, 541, 584, + /* 190 */ 590, 635, 595, 594, 634, 597, 601, 566, 255, 541, + /* 200 */ 541, 611, 611, 541, 611, 541, 611, 541, 541, 854, + /* 210 */ 854, 30, 74, 104, 104, 104, 135, 193, 221, 270, + /* 220 */ 328, 328, 328, 328, 328, 328, 10, 113, 341, 341, + /* 230 */ 341, 341, 276, 291, 384, 62, 24, 127, 127, 293, + /* 240 */ 305, 185, 345, 22, 351, 410, 476, 428, 429, 430, + /* 250 */ 471, 418, 421, 437, 438, 439, 440, 441, 446, 450, + /* 260 */ 456, 508, 543, 529, 459, 397, 402, 406, 559, 563, + /* 270 */ 417, 422, 462, 423, 494, 695, 545, 696, 697, 547, + /* 280 */ 701, 702, 609, 612, 569, 593, 599, 633, 596, 637, + /* 290 */ 650, 619, 649, 664, 651, 626, 627, 751, 752, 672, + /* 300 */ 673, 675, 676, 678, 679, 658, 681, 682, 684, 761, + /* 310 */ 685, 667, 628, 725, 772, 674, 639, 688, 599, 691, + /* 320 */ 659, 693, 660, 699, 692, 694, 708, 780, 698, 700, + /* 330 */ 777, 782, 783, 786, 787, 788, 789, 790, 707, 781, + /* 340 */ 716, 791, 792, 713, 715, 717, 794, 796, 686, 720, + /* 350 */ 784, 745, 793, 657, 661, 710, 710, 710, 710, 797, + /* 360 */ 663, 665, 710, 710, 710, 811, 813, 732, 710, 815, + /* 370 */ 816, 817, 818, 819, 820, 821, 822, 823, 824, 825, + /* 380 */ 826, 827, 828, 829, 734, 747, 830, 831, 773, 838, }; -#define YY_REDUCE_COUNT (209) -#define YY_REDUCE_MIN (-277) -#define YY_REDUCE_MAX (519) +#define YY_REDUCE_COUNT (210) +#define YY_REDUCE_MIN (-276) +#define YY_REDUCE_MAX (544) static const short yy_reduce_ofst[] = { - /* 0 */ -177, 10, 10, -165, -165, -212, 120, 134, 140, -19, - /* 10 */ -193, -68, -67, -39, 54, 87, 114, 148, 161, 162, - /* 20 */ 205, 213, -277, -46, -135, -185, -226, -161, -160, -92, - /* 30 */ 34, 149, 151, 155, 156, 158, 160, 171, 175, 177, - /* 40 */ 178, 183, 189, 191, 192, 196, 197, 198, 5, 100, - /* 50 */ 202, 215, 220, -65, -196, -199, 221, 273, 277, -126, - /* 60 */ 80, 229, 37, 61, 266, 276, -85, 230, 97, 282, - /* 70 */ -190, 12, 84, -42, 167, 105, 195, 310, 311, 312, - /* 80 */ 315, 316, 353, 357, 358, 281, 359, 360, 361, 314, - /* 90 */ 317, 364, 366, 367, 368, 292, 293, 294, 298, 320, - /* 100 */ 325, 374, 377, 378, 379, 380, 381, 382, 383, 384, - /* 110 */ 386, 387, 388, 389, 390, 391, 392, 394, 395, 403, - /* 120 */ 405, 406, 407, 412, 414, 415, 416, 417, 419, 421, - /* 130 */ 424, 425, 427, 430, 431, 432, 433, 434, 436, 437, - /* 140 */ 438, 439, 440, 441, 442, 443, 444, 445, 446, 447, - /* 150 */ 449, 450, 451, 452, 453, 455, 456, 457, 458, 459, - /* 160 */ 461, 462, 324, 326, 327, 328, 463, 337, 334, 346, - /* 170 */ 350, 362, 369, 365, 372, 329, 465, 467, 466, 470, - /* 180 */ 472, 474, 475, 476, 480, 481, 478, 479, 482, 485, - /* 190 */ 483, 486, 488, 491, 492, 494, 489, 493, 495, 496, - /* 200 */ 501, 507, 498, 508, 510, 511, 516, 519, 504, 513, + /* 0 */ -138, 53, 53, 162, 162, -211, -202, 180, 188, -201, + /* 10 */ -199, -20, 9, 102, 103, 116, 158, 202, 204, 205, + /* 20 */ 216, 225, -276, -141, -43, -191, -255, -225, -216, -142, + /* 30 */ -96, -44, 37, 42, 44, 168, 184, 191, 195, 203, + /* 40 */ 208, 209, 210, 211, 212, 215, 217, 223, 246, 252, + /* 50 */ 253, -97, 166, -103, -184, 256, 297, 306, 307, 309, + /* 60 */ 123, -116, -161, 179, 206, -3, 17, 15, 172, 34, + /* 70 */ 134, -228, 49, 120, 118, 159, 156, 310, 316, 318, + /* 80 */ 335, 336, 339, 347, 368, 378, 313, 382, 383, 385, + /* 90 */ 340, 342, 386, 387, 389, 391, 317, 319, 320, 321, + /* 100 */ 332, 344, 393, 395, 399, 400, 401, 403, 404, 405, + /* 110 */ 407, 408, 411, 412, 413, 414, 415, 416, 419, 420, + /* 120 */ 424, 425, 426, 427, 431, 432, 433, 434, 435, 436, + /* 130 */ 442, 443, 444, 445, 448, 449, 451, 452, 453, 454, + /* 140 */ 455, 457, 458, 460, 461, 463, 464, 465, 466, 467, + /* 150 */ 468, 469, 470, 472, 473, 474, 475, 477, 478, 479, + /* 160 */ 480, 481, 482, 334, 346, 349, 350, 483, 353, 366, + /* 170 */ 348, 379, 381, 380, 447, 486, 489, 487, 491, 490, + /* 180 */ 492, 493, 495, 496, 498, 501, 503, 499, 504, 505, + /* 190 */ 507, 506, 509, 510, 513, 514, 516, 511, 512, 517, + /* 200 */ 518, 519, 531, 521, 535, 537, 539, 538, 544, 523, + /* 210 */ 532, }; static const YYACTIONTYPE yy_default[] = { - /* 0 */ 921, 1044, 983, 1054, 970, 980, 1214, 1214, 1214, 1214, - /* 10 */ 921, 921, 921, 921, 921, 921, 921, 921, 921, 921, - /* 20 */ 921, 921, 921, 921, 1102, 941, 921, 921, 921, 921, - /* 30 */ 921, 921, 921, 921, 921, 921, 921, 921, 921, 921, - /* 40 */ 921, 921, 921, 921, 921, 921, 921, 921, 921, 921, - /* 50 */ 921, 921, 921, 1126, 921, 980, 921, 921, 921, 921, - /* 60 */ 990, 980, 921, 921, 990, 990, 921, 1097, 1028, 1046, - /* 70 */ 921, 921, 921, 921, 921, 921, 921, 921, 921, 921, - /* 80 */ 921, 921, 921, 921, 921, 1104, 1110, 1107, 921, 921, - /* 90 */ 921, 1112, 921, 921, 921, 1148, 1148, 1148, 1148, 1095, - /* 100 */ 921, 921, 921, 921, 921, 921, 921, 921, 921, 921, - /* 110 */ 921, 921, 921, 921, 921, 921, 921, 921, 921, 921, - /* 120 */ 921, 921, 921, 921, 921, 921, 921, 921, 921, 921, - /* 130 */ 921, 921, 921, 968, 921, 966, 921, 921, 921, 921, - /* 140 */ 921, 921, 921, 921, 921, 921, 921, 921, 921, 921, - /* 150 */ 921, 921, 921, 921, 921, 921, 921, 921, 939, 943, - /* 160 */ 943, 943, 921, 921, 921, 921, 943, 1157, 1161, 1138, - /* 170 */ 1155, 1149, 1133, 1131, 1129, 1137, 1122, 1165, 943, 943, - /* 180 */ 943, 988, 988, 984, 980, 980, 943, 943, 1006, 1004, - /* 190 */ 1002, 994, 1000, 996, 998, 992, 971, 921, 943, 943, - /* 200 */ 978, 978, 943, 978, 943, 978, 943, 943, 1028, 1046, - /* 210 */ 921, 1166, 1156, 921, 1213, 1196, 1195, 921, 1204, 1203, - /* 220 */ 1202, 1194, 1193, 1192, 921, 921, 1188, 1191, 1190, 1189, - /* 230 */ 921, 921, 1168, 921, 921, 1198, 1197, 921, 921, 921, - /* 240 */ 921, 921, 921, 921, 1119, 921, 921, 921, 1144, 1162, - /* 250 */ 1158, 921, 921, 921, 921, 921, 921, 921, 921, 1169, - /* 260 */ 921, 921, 921, 921, 921, 921, 921, 921, 921, 921, - /* 270 */ 1056, 921, 921, 921, 921, 921, 921, 921, 921, 921, - /* 280 */ 921, 921, 921, 1094, 921, 921, 921, 921, 921, 1106, - /* 290 */ 1105, 921, 921, 921, 921, 921, 921, 921, 921, 921, - /* 300 */ 921, 921, 921, 921, 921, 921, 921, 921, 921, 1150, - /* 310 */ 921, 1145, 921, 1139, 921, 921, 1068, 921, 921, 921, - /* 320 */ 921, 921, 921, 921, 921, 921, 921, 921, 921, 921, - /* 330 */ 921, 921, 921, 921, 921, 921, 921, 921, 921, 921, - /* 340 */ 921, 921, 921, 921, 921, 921, 921, 921, 921, 921, - /* 350 */ 921, 921, 1232, 1227, 1228, 1225, 921, 921, 921, 1224, - /* 360 */ 1219, 1220, 921, 921, 921, 1217, 921, 921, 921, 921, - /* 370 */ 921, 921, 921, 921, 921, 921, 921, 921, 921, 921, - /* 380 */ 921, 1012, 921, 950, 948, 921, 921, + /* 0 */ 926, 1049, 988, 1059, 975, 985, 1220, 1220, 1220, 1220, + /* 10 */ 926, 926, 926, 926, 926, 926, 926, 926, 926, 926, + /* 20 */ 926, 926, 926, 926, 1107, 946, 926, 926, 926, 926, + /* 30 */ 926, 926, 926, 926, 926, 926, 926, 926, 926, 926, + /* 40 */ 926, 926, 926, 926, 926, 926, 926, 926, 926, 926, + /* 50 */ 926, 926, 926, 1131, 926, 985, 926, 926, 926, 926, + /* 60 */ 926, 995, 985, 926, 926, 995, 995, 926, 1102, 1033, + /* 70 */ 1051, 926, 926, 926, 926, 926, 926, 926, 926, 926, + /* 80 */ 926, 926, 926, 926, 926, 926, 1109, 1115, 1112, 926, + /* 90 */ 926, 926, 1117, 926, 926, 926, 1153, 1153, 1153, 1153, + /* 100 */ 1100, 926, 926, 926, 926, 926, 926, 926, 926, 926, + /* 110 */ 926, 926, 926, 926, 926, 926, 926, 926, 926, 926, + /* 120 */ 926, 926, 926, 926, 926, 926, 926, 926, 926, 926, + /* 130 */ 926, 926, 926, 926, 973, 926, 971, 926, 926, 926, + /* 140 */ 926, 926, 926, 926, 926, 926, 926, 926, 926, 926, + /* 150 */ 926, 926, 926, 926, 926, 926, 926, 926, 926, 944, + /* 160 */ 948, 948, 948, 926, 926, 926, 926, 948, 1162, 1166, + /* 170 */ 1143, 1160, 1154, 1138, 1136, 1134, 1142, 1127, 1170, 948, + /* 180 */ 948, 948, 993, 993, 989, 985, 985, 948, 948, 1011, + /* 190 */ 1009, 1007, 999, 1005, 1001, 1003, 997, 976, 926, 948, + /* 200 */ 948, 983, 983, 948, 983, 948, 983, 948, 948, 1033, + /* 210 */ 1051, 1219, 926, 1171, 1161, 1219, 926, 1202, 1201, 926, + /* 220 */ 1210, 1209, 1208, 1200, 1199, 1198, 926, 926, 1194, 1197, + /* 230 */ 1196, 1195, 926, 926, 1173, 926, 926, 1204, 1203, 926, + /* 240 */ 926, 926, 926, 926, 926, 926, 1124, 926, 926, 926, + /* 250 */ 1149, 1167, 1163, 926, 926, 926, 926, 926, 926, 926, + /* 260 */ 926, 1174, 926, 926, 926, 926, 926, 926, 926, 926, + /* 270 */ 926, 926, 1061, 926, 926, 926, 926, 926, 926, 926, + /* 280 */ 926, 926, 926, 926, 926, 1099, 926, 926, 926, 926, + /* 290 */ 926, 1111, 1110, 926, 926, 926, 926, 926, 926, 926, + /* 300 */ 926, 926, 926, 926, 926, 926, 926, 926, 926, 926, + /* 310 */ 926, 1155, 926, 1150, 926, 1144, 926, 926, 1073, 926, + /* 320 */ 926, 926, 926, 926, 926, 926, 926, 926, 926, 926, + /* 330 */ 926, 926, 926, 926, 926, 926, 926, 926, 926, 926, + /* 340 */ 926, 926, 926, 926, 926, 926, 926, 926, 926, 926, + /* 350 */ 926, 926, 926, 926, 926, 1238, 1233, 1234, 1231, 926, + /* 360 */ 926, 926, 1230, 1225, 1226, 926, 926, 926, 1223, 926, + /* 370 */ 926, 926, 926, 926, 926, 926, 926, 926, 926, 926, + /* 380 */ 926, 926, 926, 926, 1017, 926, 955, 953, 926, 926, }; /********** End of lemon-generated parsing tables *****************************/ @@ -783,7 +787,6 @@ static const YYCODETYPE yyFallback[] = { 0, /* STAR => nothing */ 0, /* SLASH => nothing */ 0, /* REM => nothing */ - 0, /* CONCAT => nothing */ 0, /* UMINUS => nothing */ 0, /* UPLUS => nothing */ 0, /* BITNOT => nothing */ @@ -1073,247 +1076,246 @@ static const char *const yyTokenName[] = { /* 41 */ "STAR", /* 42 */ "SLASH", /* 43 */ "REM", - /* 44 */ "CONCAT", - /* 45 */ "UMINUS", - /* 46 */ "UPLUS", - /* 47 */ "BITNOT", - /* 48 */ "ARROW", - /* 49 */ "SHOW", - /* 50 */ "DATABASES", - /* 51 */ "TOPICS", - /* 52 */ "FUNCTIONS", - /* 53 */ "MNODES", - /* 54 */ "DNODES", - /* 55 */ "ACCOUNTS", - /* 56 */ "USERS", - /* 57 */ "MODULES", - /* 58 */ "QUERIES", - /* 59 */ "CONNECTIONS", - /* 60 */ "STREAMS", - /* 61 */ "VARIABLES", - /* 62 */ "SCORES", - /* 63 */ "GRANTS", - /* 64 */ "VNODES", - /* 65 */ "DOT", - /* 66 */ "CREATE", - /* 67 */ "TABLE", - /* 68 */ "STABLE", - /* 69 */ "DATABASE", - /* 70 */ "TABLES", - /* 71 */ "STABLES", - /* 72 */ "VGROUPS", - /* 73 */ "DROP", - /* 74 */ "TOPIC", - /* 75 */ "FUNCTION", - /* 76 */ "DNODE", - /* 77 */ "USER", - /* 78 */ "ACCOUNT", - /* 79 */ "USE", - /* 80 */ "DESCRIBE", - /* 81 */ "DESC", - /* 82 */ "ALTER", - /* 83 */ "PASS", - /* 84 */ "PRIVILEGE", - /* 85 */ "LOCAL", - /* 86 */ "COMPACT", - /* 87 */ "LP", - /* 88 */ "RP", - /* 89 */ "IF", - /* 90 */ "EXISTS", - /* 91 */ "AS", - /* 92 */ "OUTPUTTYPE", - /* 93 */ "AGGREGATE", - /* 94 */ "BUFSIZE", - /* 95 */ "PPS", - /* 96 */ "TSERIES", - /* 97 */ "DBS", - /* 98 */ "STORAGE", - /* 99 */ "QTIME", - /* 100 */ "CONNS", - /* 101 */ "STATE", - /* 102 */ "COMMA", - /* 103 */ "KEEP", - /* 104 */ "CACHE", - /* 105 */ "REPLICA", - /* 106 */ "QUORUM", - /* 107 */ "DAYS", - /* 108 */ "MINROWS", - /* 109 */ "MAXROWS", - /* 110 */ "BLOCKS", - /* 111 */ "CTIME", - /* 112 */ "WAL", - /* 113 */ "FSYNC", - /* 114 */ "COMP", - /* 115 */ "PRECISION", - /* 116 */ "UPDATE", - /* 117 */ "CACHELAST", - /* 118 */ "PARTITIONS", - /* 119 */ "UNSIGNED", - /* 120 */ "TAGS", - /* 121 */ "USING", - /* 122 */ "NULL", - /* 123 */ "NOW", - /* 124 */ "SELECT", - /* 125 */ "UNION", - /* 126 */ "ALL", - /* 127 */ "DISTINCT", - /* 128 */ "FROM", - /* 129 */ "VARIABLE", - /* 130 */ "RANGE", - /* 131 */ "INTERVAL", - /* 132 */ "EVERY", - /* 133 */ "SESSION", - /* 134 */ "STATE_WINDOW", - /* 135 */ "FILL", - /* 136 */ "SLIDING", - /* 137 */ "ORDER", - /* 138 */ "BY", - /* 139 */ "ASC", - /* 140 */ "GROUP", - /* 141 */ "HAVING", - /* 142 */ "LIMIT", - /* 143 */ "OFFSET", - /* 144 */ "SLIMIT", - /* 145 */ "SOFFSET", - /* 146 */ "WHERE", - /* 147 */ "RESET", - /* 148 */ "QUERY", - /* 149 */ "SYNCDB", - /* 150 */ "ADD", - /* 151 */ "COLUMN", - /* 152 */ "MODIFY", - /* 153 */ "TAG", - /* 154 */ "CHANGE", - /* 155 */ "SET", - /* 156 */ "KILL", - /* 157 */ "CONNECTION", - /* 158 */ "STREAM", - /* 159 */ "COLON", - /* 160 */ "ABORT", - /* 161 */ "AFTER", - /* 162 */ "ATTACH", - /* 163 */ "BEFORE", - /* 164 */ "BEGIN", - /* 165 */ "CASCADE", - /* 166 */ "CLUSTER", - /* 167 */ "CONFLICT", - /* 168 */ "COPY", - /* 169 */ "DEFERRED", - /* 170 */ "DELIMITERS", - /* 171 */ "DETACH", - /* 172 */ "EACH", - /* 173 */ "END", - /* 174 */ "EXPLAIN", - /* 175 */ "FAIL", - /* 176 */ "FOR", - /* 177 */ "IGNORE", - /* 178 */ "IMMEDIATE", - /* 179 */ "INITIALLY", - /* 180 */ "INSTEAD", - /* 181 */ "KEY", - /* 182 */ "OF", - /* 183 */ "RAISE", - /* 184 */ "REPLACE", - /* 185 */ "RESTRICT", - /* 186 */ "ROW", - /* 187 */ "STATEMENT", - /* 188 */ "TRIGGER", - /* 189 */ "VIEW", - /* 190 */ "IPTOKEN", - /* 191 */ "SEMI", - /* 192 */ "NONE", - /* 193 */ "PREV", - /* 194 */ "LINEAR", - /* 195 */ "IMPORT", - /* 196 */ "TBNAME", - /* 197 */ "JOIN", - /* 198 */ "INSERT", - /* 199 */ "INTO", - /* 200 */ "VALUES", - /* 201 */ "FILE", - /* 202 */ "program", - /* 203 */ "cmd", - /* 204 */ "ids", - /* 205 */ "dbPrefix", - /* 206 */ "cpxName", - /* 207 */ "ifexists", - /* 208 */ "alter_db_optr", - /* 209 */ "alter_topic_optr", - /* 210 */ "acct_optr", - /* 211 */ "exprlist", - /* 212 */ "ifnotexists", - /* 213 */ "db_optr", - /* 214 */ "topic_optr", - /* 215 */ "typename", - /* 216 */ "bufsize", - /* 217 */ "pps", - /* 218 */ "tseries", - /* 219 */ "dbs", - /* 220 */ "streams", - /* 221 */ "storage", - /* 222 */ "qtime", - /* 223 */ "users", - /* 224 */ "conns", - /* 225 */ "state", - /* 226 */ "intitemlist", - /* 227 */ "intitem", - /* 228 */ "keep", - /* 229 */ "cache", - /* 230 */ "replica", - /* 231 */ "quorum", - /* 232 */ "days", - /* 233 */ "minrows", - /* 234 */ "maxrows", - /* 235 */ "blocks", - /* 236 */ "ctime", - /* 237 */ "wal", - /* 238 */ "fsync", - /* 239 */ "comp", - /* 240 */ "prec", - /* 241 */ "update", - /* 242 */ "cachelast", - /* 243 */ "partitions", - /* 244 */ "signed", - /* 245 */ "create_table_args", - /* 246 */ "create_stable_args", - /* 247 */ "create_table_list", - /* 248 */ "create_from_stable", - /* 249 */ "columnlist", - /* 250 */ "tagitemlist", - /* 251 */ "tagNamelist", - /* 252 */ "select", - /* 253 */ "column", - /* 254 */ "tagitem", - /* 255 */ "selcollist", - /* 256 */ "from", - /* 257 */ "where_opt", - /* 258 */ "range_option", - /* 259 */ "interval_option", - /* 260 */ "sliding_opt", - /* 261 */ "session_option", - /* 262 */ "windowstate_option", - /* 263 */ "fill_opt", - /* 264 */ "groupby_opt", - /* 265 */ "having_opt", - /* 266 */ "orderby_opt", - /* 267 */ "slimit_opt", - /* 268 */ "limit_opt", - /* 269 */ "union", - /* 270 */ "sclp", - /* 271 */ "distinct", - /* 272 */ "expr", - /* 273 */ "as", - /* 274 */ "tablelist", - /* 275 */ "sub", - /* 276 */ "tmvar", - /* 277 */ "timestamp", - /* 278 */ "intervalKey", - /* 279 */ "sortlist", - /* 280 */ "item", - /* 281 */ "sortorder", - /* 282 */ "arrow", - /* 283 */ "grouplist", - /* 284 */ "expritem", + /* 44 */ "UMINUS", + /* 45 */ "UPLUS", + /* 46 */ "BITNOT", + /* 47 */ "ARROW", + /* 48 */ "SHOW", + /* 49 */ "DATABASES", + /* 50 */ "TOPICS", + /* 51 */ "FUNCTIONS", + /* 52 */ "MNODES", + /* 53 */ "DNODES", + /* 54 */ "ACCOUNTS", + /* 55 */ "USERS", + /* 56 */ "MODULES", + /* 57 */ "QUERIES", + /* 58 */ "CONNECTIONS", + /* 59 */ "STREAMS", + /* 60 */ "VARIABLES", + /* 61 */ "SCORES", + /* 62 */ "GRANTS", + /* 63 */ "VNODES", + /* 64 */ "DOT", + /* 65 */ "CREATE", + /* 66 */ "TABLE", + /* 67 */ "STABLE", + /* 68 */ "DATABASE", + /* 69 */ "TABLES", + /* 70 */ "STABLES", + /* 71 */ "VGROUPS", + /* 72 */ "DROP", + /* 73 */ "TOPIC", + /* 74 */ "FUNCTION", + /* 75 */ "DNODE", + /* 76 */ "USER", + /* 77 */ "ACCOUNT", + /* 78 */ "USE", + /* 79 */ "DESCRIBE", + /* 80 */ "DESC", + /* 81 */ "ALTER", + /* 82 */ "PASS", + /* 83 */ "PRIVILEGE", + /* 84 */ "LOCAL", + /* 85 */ "COMPACT", + /* 86 */ "LP", + /* 87 */ "RP", + /* 88 */ "IF", + /* 89 */ "EXISTS", + /* 90 */ "AS", + /* 91 */ "OUTPUTTYPE", + /* 92 */ "AGGREGATE", + /* 93 */ "BUFSIZE", + /* 94 */ "PPS", + /* 95 */ "TSERIES", + /* 96 */ "DBS", + /* 97 */ "STORAGE", + /* 98 */ "QTIME", + /* 99 */ "CONNS", + /* 100 */ "STATE", + /* 101 */ "COMMA", + /* 102 */ "KEEP", + /* 103 */ "CACHE", + /* 104 */ "REPLICA", + /* 105 */ "QUORUM", + /* 106 */ "DAYS", + /* 107 */ "MINROWS", + /* 108 */ "MAXROWS", + /* 109 */ "BLOCKS", + /* 110 */ "CTIME", + /* 111 */ "WAL", + /* 112 */ "FSYNC", + /* 113 */ "COMP", + /* 114 */ "PRECISION", + /* 115 */ "UPDATE", + /* 116 */ "CACHELAST", + /* 117 */ "PARTITIONS", + /* 118 */ "UNSIGNED", + /* 119 */ "TAGS", + /* 120 */ "USING", + /* 121 */ "NULL", + /* 122 */ "NOW", + /* 123 */ "SELECT", + /* 124 */ "UNION", + /* 125 */ "ALL", + /* 126 */ "DISTINCT", + /* 127 */ "FROM", + /* 128 */ "VARIABLE", + /* 129 */ "RANGE", + /* 130 */ "INTERVAL", + /* 131 */ "EVERY", + /* 132 */ "SESSION", + /* 133 */ "STATE_WINDOW", + /* 134 */ "FILL", + /* 135 */ "SLIDING", + /* 136 */ "ORDER", + /* 137 */ "BY", + /* 138 */ "ASC", + /* 139 */ "GROUP", + /* 140 */ "HAVING", + /* 141 */ "LIMIT", + /* 142 */ "OFFSET", + /* 143 */ "SLIMIT", + /* 144 */ "SOFFSET", + /* 145 */ "WHERE", + /* 146 */ "RESET", + /* 147 */ "QUERY", + /* 148 */ "SYNCDB", + /* 149 */ "ADD", + /* 150 */ "COLUMN", + /* 151 */ "MODIFY", + /* 152 */ "TAG", + /* 153 */ "CHANGE", + /* 154 */ "SET", + /* 155 */ "KILL", + /* 156 */ "CONNECTION", + /* 157 */ "STREAM", + /* 158 */ "COLON", + /* 159 */ "ABORT", + /* 160 */ "AFTER", + /* 161 */ "ATTACH", + /* 162 */ "BEFORE", + /* 163 */ "BEGIN", + /* 164 */ "CASCADE", + /* 165 */ "CLUSTER", + /* 166 */ "CONFLICT", + /* 167 */ "COPY", + /* 168 */ "DEFERRED", + /* 169 */ "DELIMITERS", + /* 170 */ "DETACH", + /* 171 */ "EACH", + /* 172 */ "END", + /* 173 */ "EXPLAIN", + /* 174 */ "FAIL", + /* 175 */ "FOR", + /* 176 */ "IGNORE", + /* 177 */ "IMMEDIATE", + /* 178 */ "INITIALLY", + /* 179 */ "INSTEAD", + /* 180 */ "KEY", + /* 181 */ "OF", + /* 182 */ "RAISE", + /* 183 */ "REPLACE", + /* 184 */ "RESTRICT", + /* 185 */ "ROW", + /* 186 */ "STATEMENT", + /* 187 */ "TRIGGER", + /* 188 */ "VIEW", + /* 189 */ "IPTOKEN", + /* 190 */ "SEMI", + /* 191 */ "NONE", + /* 192 */ "PREV", + /* 193 */ "LINEAR", + /* 194 */ "IMPORT", + /* 195 */ "TBNAME", + /* 196 */ "JOIN", + /* 197 */ "INSERT", + /* 198 */ "INTO", + /* 199 */ "VALUES", + /* 200 */ "FILE", + /* 201 */ "program", + /* 202 */ "cmd", + /* 203 */ "ids", + /* 204 */ "dbPrefix", + /* 205 */ "cpxName", + /* 206 */ "ifexists", + /* 207 */ "alter_db_optr", + /* 208 */ "alter_topic_optr", + /* 209 */ "acct_optr", + /* 210 */ "exprlist", + /* 211 */ "ifnotexists", + /* 212 */ "db_optr", + /* 213 */ "topic_optr", + /* 214 */ "typename", + /* 215 */ "bufsize", + /* 216 */ "pps", + /* 217 */ "tseries", + /* 218 */ "dbs", + /* 219 */ "streams", + /* 220 */ "storage", + /* 221 */ "qtime", + /* 222 */ "users", + /* 223 */ "conns", + /* 224 */ "state", + /* 225 */ "intitemlist", + /* 226 */ "intitem", + /* 227 */ "keep", + /* 228 */ "cache", + /* 229 */ "replica", + /* 230 */ "quorum", + /* 231 */ "days", + /* 232 */ "minrows", + /* 233 */ "maxrows", + /* 234 */ "blocks", + /* 235 */ "ctime", + /* 236 */ "wal", + /* 237 */ "fsync", + /* 238 */ "comp", + /* 239 */ "prec", + /* 240 */ "update", + /* 241 */ "cachelast", + /* 242 */ "partitions", + /* 243 */ "signed", + /* 244 */ "create_table_args", + /* 245 */ "create_stable_args", + /* 246 */ "create_table_list", + /* 247 */ "create_from_stable", + /* 248 */ "columnlist", + /* 249 */ "tagitemlist", + /* 250 */ "tagNamelist", + /* 251 */ "select", + /* 252 */ "column", + /* 253 */ "tagitem", + /* 254 */ "selcollist", + /* 255 */ "from", + /* 256 */ "where_opt", + /* 257 */ "range_option", + /* 258 */ "interval_option", + /* 259 */ "sliding_opt", + /* 260 */ "session_option", + /* 261 */ "windowstate_option", + /* 262 */ "fill_opt", + /* 263 */ "groupby_opt", + /* 264 */ "having_opt", + /* 265 */ "orderby_opt", + /* 266 */ "slimit_opt", + /* 267 */ "limit_opt", + /* 268 */ "union", + /* 269 */ "sclp", + /* 270 */ "distinct", + /* 271 */ "expr", + /* 272 */ "as", + /* 273 */ "tablelist", + /* 274 */ "sub", + /* 275 */ "tmvar", + /* 276 */ "timestamp", + /* 277 */ "intervalKey", + /* 278 */ "sortlist", + /* 279 */ "item", + /* 280 */ "sortorder", + /* 281 */ "arrow", + /* 282 */ "grouplist", + /* 283 */ "expritem", }; #endif /* defined(YYCOVERAGE) || !defined(NDEBUG) */ @@ -1583,56 +1585,57 @@ static const char *const yyRuleName[] = { /* 259 */ "expr ::= NULL", /* 260 */ "expr ::= ID LP exprlist RP", /* 261 */ "expr ::= ID LP STAR RP", - /* 262 */ "expr ::= expr IS NULL", - /* 263 */ "expr ::= expr IS NOT NULL", - /* 264 */ "expr ::= expr LT expr", - /* 265 */ "expr ::= expr GT expr", - /* 266 */ "expr ::= expr LE expr", - /* 267 */ "expr ::= expr GE expr", - /* 268 */ "expr ::= expr NE expr", - /* 269 */ "expr ::= expr EQ expr", - /* 270 */ "expr ::= expr BETWEEN expr AND expr", - /* 271 */ "expr ::= expr AND expr", - /* 272 */ "expr ::= expr OR expr", - /* 273 */ "expr ::= expr PLUS expr", - /* 274 */ "expr ::= expr MINUS expr", - /* 275 */ "expr ::= expr STAR expr", - /* 276 */ "expr ::= expr SLASH expr", - /* 277 */ "expr ::= expr REM expr", - /* 278 */ "expr ::= expr LIKE expr", - /* 279 */ "expr ::= expr MATCH expr", - /* 280 */ "expr ::= expr NMATCH expr", - /* 281 */ "expr ::= ID CONTAINS STRING", - /* 282 */ "expr ::= ID DOT ID CONTAINS STRING", - /* 283 */ "arrow ::= ID ARROW STRING", - /* 284 */ "arrow ::= ID DOT ID ARROW STRING", - /* 285 */ "expr ::= arrow", - /* 286 */ "expr ::= expr IN LP exprlist RP", - /* 287 */ "exprlist ::= exprlist COMMA expritem", - /* 288 */ "exprlist ::= expritem", - /* 289 */ "expritem ::= expr", - /* 290 */ "expritem ::=", - /* 291 */ "cmd ::= RESET QUERY CACHE", - /* 292 */ "cmd ::= SYNCDB ids REPLICA", - /* 293 */ "cmd ::= ALTER TABLE ids cpxName ADD COLUMN columnlist", - /* 294 */ "cmd ::= ALTER TABLE ids cpxName DROP COLUMN ids", - /* 295 */ "cmd ::= ALTER TABLE ids cpxName MODIFY COLUMN columnlist", - /* 296 */ "cmd ::= ALTER TABLE ids cpxName ADD TAG columnlist", - /* 297 */ "cmd ::= ALTER TABLE ids cpxName DROP TAG ids", - /* 298 */ "cmd ::= ALTER TABLE ids cpxName CHANGE TAG ids ids", - /* 299 */ "cmd ::= ALTER TABLE ids cpxName SET TAG ids EQ tagitem", - /* 300 */ "cmd ::= ALTER TABLE ids cpxName MODIFY TAG columnlist", - /* 301 */ "cmd ::= ALTER STABLE ids cpxName ADD COLUMN columnlist", - /* 302 */ "cmd ::= ALTER STABLE ids cpxName DROP COLUMN ids", - /* 303 */ "cmd ::= ALTER STABLE ids cpxName MODIFY COLUMN columnlist", - /* 304 */ "cmd ::= ALTER STABLE ids cpxName ADD TAG columnlist", - /* 305 */ "cmd ::= ALTER STABLE ids cpxName DROP TAG ids", - /* 306 */ "cmd ::= ALTER STABLE ids cpxName CHANGE TAG ids ids", - /* 307 */ "cmd ::= ALTER STABLE ids cpxName SET TAG ids EQ tagitem", - /* 308 */ "cmd ::= ALTER STABLE ids cpxName MODIFY TAG columnlist", - /* 309 */ "cmd ::= KILL CONNECTION INTEGER", - /* 310 */ "cmd ::= KILL STREAM INTEGER COLON INTEGER", - /* 311 */ "cmd ::= KILL QUERY INTEGER COLON INTEGER", + /* 262 */ "expr ::= ID LP expr AS typename RP", + /* 263 */ "expr ::= expr IS NULL", + /* 264 */ "expr ::= expr IS NOT NULL", + /* 265 */ "expr ::= expr LT expr", + /* 266 */ "expr ::= expr GT expr", + /* 267 */ "expr ::= expr LE expr", + /* 268 */ "expr ::= expr GE expr", + /* 269 */ "expr ::= expr NE expr", + /* 270 */ "expr ::= expr EQ expr", + /* 271 */ "expr ::= expr BETWEEN expr AND expr", + /* 272 */ "expr ::= expr AND expr", + /* 273 */ "expr ::= expr OR expr", + /* 274 */ "expr ::= expr PLUS expr", + /* 275 */ "expr ::= expr MINUS expr", + /* 276 */ "expr ::= expr STAR expr", + /* 277 */ "expr ::= expr SLASH expr", + /* 278 */ "expr ::= expr REM expr", + /* 279 */ "expr ::= expr LIKE expr", + /* 280 */ "expr ::= expr MATCH expr", + /* 281 */ "expr ::= expr NMATCH expr", + /* 282 */ "expr ::= ID CONTAINS STRING", + /* 283 */ "expr ::= ID DOT ID CONTAINS STRING", + /* 284 */ "arrow ::= ID ARROW STRING", + /* 285 */ "arrow ::= ID DOT ID ARROW STRING", + /* 286 */ "expr ::= arrow", + /* 287 */ "expr ::= expr IN LP exprlist RP", + /* 288 */ "exprlist ::= exprlist COMMA expritem", + /* 289 */ "exprlist ::= expritem", + /* 290 */ "expritem ::= expr", + /* 291 */ "expritem ::=", + /* 292 */ "cmd ::= RESET QUERY CACHE", + /* 293 */ "cmd ::= SYNCDB ids REPLICA", + /* 294 */ "cmd ::= ALTER TABLE ids cpxName ADD COLUMN columnlist", + /* 295 */ "cmd ::= ALTER TABLE ids cpxName DROP COLUMN ids", + /* 296 */ "cmd ::= ALTER TABLE ids cpxName MODIFY COLUMN columnlist", + /* 297 */ "cmd ::= ALTER TABLE ids cpxName ADD TAG columnlist", + /* 298 */ "cmd ::= ALTER TABLE ids cpxName DROP TAG ids", + /* 299 */ "cmd ::= ALTER TABLE ids cpxName CHANGE TAG ids ids", + /* 300 */ "cmd ::= ALTER TABLE ids cpxName SET TAG ids EQ tagitem", + /* 301 */ "cmd ::= ALTER TABLE ids cpxName MODIFY TAG columnlist", + /* 302 */ "cmd ::= ALTER STABLE ids cpxName ADD COLUMN columnlist", + /* 303 */ "cmd ::= ALTER STABLE ids cpxName DROP COLUMN ids", + /* 304 */ "cmd ::= ALTER STABLE ids cpxName MODIFY COLUMN columnlist", + /* 305 */ "cmd ::= ALTER STABLE ids cpxName ADD TAG columnlist", + /* 306 */ "cmd ::= ALTER STABLE ids cpxName DROP TAG ids", + /* 307 */ "cmd ::= ALTER STABLE ids cpxName CHANGE TAG ids ids", + /* 308 */ "cmd ::= ALTER STABLE ids cpxName SET TAG ids EQ tagitem", + /* 309 */ "cmd ::= ALTER STABLE ids cpxName MODIFY TAG columnlist", + /* 310 */ "cmd ::= KILL CONNECTION INTEGER", + /* 311 */ "cmd ::= KILL STREAM INTEGER COLON INTEGER", + /* 312 */ "cmd ::= KILL QUERY INTEGER COLON INTEGER", }; #endif /* NDEBUG */ @@ -1758,57 +1761,57 @@ static void yy_destructor( ** inside the C code. */ /********* Begin destructor definitions ***************************************/ - case 211: /* exprlist */ - case 255: /* selcollist */ - case 270: /* sclp */ + case 210: /* exprlist */ + case 254: /* selcollist */ + case 269: /* sclp */ { -tSqlExprListDestroy((yypminor->yy231)); +tSqlExprListDestroy((yypminor->yy189)); } break; - case 226: /* intitemlist */ - case 228: /* keep */ - case 249: /* columnlist */ - case 250: /* tagitemlist */ - case 251: /* tagNamelist */ - case 263: /* fill_opt */ - case 264: /* groupby_opt */ - case 266: /* orderby_opt */ - case 279: /* sortlist */ - case 283: /* grouplist */ + case 225: /* intitemlist */ + case 227: /* keep */ + case 248: /* columnlist */ + case 249: /* tagitemlist */ + case 250: /* tagNamelist */ + case 262: /* fill_opt */ + case 263: /* groupby_opt */ + case 265: /* orderby_opt */ + case 278: /* sortlist */ + case 282: /* grouplist */ { -taosArrayDestroy((yypminor->yy231)); +taosArrayDestroy((yypminor->yy189)); } break; - case 247: /* create_table_list */ + case 246: /* create_table_list */ { -destroyCreateTableSql((yypminor->yy422)); +destroyCreateTableSql((yypminor->yy6)); } break; - case 252: /* select */ + case 251: /* select */ { -destroySqlNode((yypminor->yy86)); +destroySqlNode((yypminor->yy16)); } break; - case 256: /* from */ - case 274: /* tablelist */ - case 275: /* sub */ + case 255: /* from */ + case 273: /* tablelist */ + case 274: /* sub */ { -destroyRelationInfo((yypminor->yy484)); +destroyRelationInfo((yypminor->yy36)); } break; - case 257: /* where_opt */ - case 265: /* having_opt */ - case 272: /* expr */ - case 277: /* timestamp */ - case 282: /* arrow */ - case 284: /* expritem */ + case 256: /* where_opt */ + case 264: /* having_opt */ + case 271: /* expr */ + case 276: /* timestamp */ + case 281: /* arrow */ + case 283: /* expritem */ { -tSqlExprDestroy((yypminor->yy226)); +tSqlExprDestroy((yypminor->yy18)); } break; - case 269: /* union */ + case 268: /* union */ { -destroyAllSqlNode((yypminor->yy231)); +destroyAllSqlNode((yypminor->yy189)); } break; /********* End destructor definitions *****************************************/ @@ -2097,318 +2100,319 @@ static void yy_shift( /* For rule J, yyRuleInfoLhs[J] contains the symbol on the left-hand side ** of that rule */ static const YYCODETYPE yyRuleInfoLhs[] = { - 202, /* (0) program ::= cmd */ - 203, /* (1) cmd ::= SHOW DATABASES */ - 203, /* (2) cmd ::= SHOW TOPICS */ - 203, /* (3) cmd ::= SHOW FUNCTIONS */ - 203, /* (4) cmd ::= SHOW MNODES */ - 203, /* (5) cmd ::= SHOW DNODES */ - 203, /* (6) cmd ::= SHOW ACCOUNTS */ - 203, /* (7) cmd ::= SHOW USERS */ - 203, /* (8) cmd ::= SHOW MODULES */ - 203, /* (9) cmd ::= SHOW QUERIES */ - 203, /* (10) cmd ::= SHOW CONNECTIONS */ - 203, /* (11) cmd ::= SHOW STREAMS */ - 203, /* (12) cmd ::= SHOW VARIABLES */ - 203, /* (13) cmd ::= SHOW SCORES */ - 203, /* (14) cmd ::= SHOW GRANTS */ - 203, /* (15) cmd ::= SHOW VNODES */ - 203, /* (16) cmd ::= SHOW VNODES ids */ - 205, /* (17) dbPrefix ::= */ - 205, /* (18) dbPrefix ::= ids DOT */ - 206, /* (19) cpxName ::= */ - 206, /* (20) cpxName ::= DOT ids */ - 203, /* (21) cmd ::= SHOW CREATE TABLE ids cpxName */ - 203, /* (22) cmd ::= SHOW CREATE STABLE ids cpxName */ - 203, /* (23) cmd ::= SHOW CREATE DATABASE ids */ - 203, /* (24) cmd ::= SHOW dbPrefix TABLES */ - 203, /* (25) cmd ::= SHOW dbPrefix TABLES LIKE ids */ - 203, /* (26) cmd ::= SHOW dbPrefix STABLES */ - 203, /* (27) cmd ::= SHOW dbPrefix STABLES LIKE ids */ - 203, /* (28) cmd ::= SHOW dbPrefix VGROUPS */ - 203, /* (29) cmd ::= DROP TABLE ifexists ids cpxName */ - 203, /* (30) cmd ::= DROP STABLE ifexists ids cpxName */ - 203, /* (31) cmd ::= DROP DATABASE ifexists ids */ - 203, /* (32) cmd ::= DROP TOPIC ifexists ids */ - 203, /* (33) cmd ::= DROP FUNCTION ids */ - 203, /* (34) cmd ::= DROP DNODE ids */ - 203, /* (35) cmd ::= DROP USER ids */ - 203, /* (36) cmd ::= DROP ACCOUNT ids */ - 203, /* (37) cmd ::= USE ids */ - 203, /* (38) cmd ::= DESCRIBE ids cpxName */ - 203, /* (39) cmd ::= DESC ids cpxName */ - 203, /* (40) cmd ::= ALTER USER ids PASS ids */ - 203, /* (41) cmd ::= ALTER USER ids PRIVILEGE ids */ - 203, /* (42) cmd ::= ALTER DNODE ids ids */ - 203, /* (43) cmd ::= ALTER DNODE ids ids ids */ - 203, /* (44) cmd ::= ALTER LOCAL ids */ - 203, /* (45) cmd ::= ALTER LOCAL ids ids */ - 203, /* (46) cmd ::= ALTER DATABASE ids alter_db_optr */ - 203, /* (47) cmd ::= ALTER TOPIC ids alter_topic_optr */ - 203, /* (48) cmd ::= ALTER ACCOUNT ids acct_optr */ - 203, /* (49) cmd ::= ALTER ACCOUNT ids PASS ids acct_optr */ - 203, /* (50) cmd ::= COMPACT VNODES IN LP exprlist RP */ - 204, /* (51) ids ::= ID */ - 204, /* (52) ids ::= STRING */ - 207, /* (53) ifexists ::= IF EXISTS */ - 207, /* (54) ifexists ::= */ - 212, /* (55) ifnotexists ::= IF NOT EXISTS */ - 212, /* (56) ifnotexists ::= */ - 203, /* (57) cmd ::= CREATE DNODE ids */ - 203, /* (58) cmd ::= CREATE ACCOUNT ids PASS ids acct_optr */ - 203, /* (59) cmd ::= CREATE DATABASE ifnotexists ids db_optr */ - 203, /* (60) cmd ::= CREATE TOPIC ifnotexists ids topic_optr */ - 203, /* (61) cmd ::= CREATE FUNCTION ids AS ids OUTPUTTYPE typename bufsize */ - 203, /* (62) cmd ::= CREATE AGGREGATE FUNCTION ids AS ids OUTPUTTYPE typename bufsize */ - 203, /* (63) cmd ::= CREATE USER ids PASS ids */ - 216, /* (64) bufsize ::= */ - 216, /* (65) bufsize ::= BUFSIZE INTEGER */ - 217, /* (66) pps ::= */ - 217, /* (67) pps ::= PPS INTEGER */ - 218, /* (68) tseries ::= */ - 218, /* (69) tseries ::= TSERIES INTEGER */ - 219, /* (70) dbs ::= */ - 219, /* (71) dbs ::= DBS INTEGER */ - 220, /* (72) streams ::= */ - 220, /* (73) streams ::= STREAMS INTEGER */ - 221, /* (74) storage ::= */ - 221, /* (75) storage ::= STORAGE INTEGER */ - 222, /* (76) qtime ::= */ - 222, /* (77) qtime ::= QTIME INTEGER */ - 223, /* (78) users ::= */ - 223, /* (79) users ::= USERS INTEGER */ - 224, /* (80) conns ::= */ - 224, /* (81) conns ::= CONNS INTEGER */ - 225, /* (82) state ::= */ - 225, /* (83) state ::= STATE ids */ - 210, /* (84) acct_optr ::= pps tseries storage streams qtime dbs users conns state */ - 226, /* (85) intitemlist ::= intitemlist COMMA intitem */ - 226, /* (86) intitemlist ::= intitem */ - 227, /* (87) intitem ::= INTEGER */ - 228, /* (88) keep ::= KEEP intitemlist */ - 229, /* (89) cache ::= CACHE INTEGER */ - 230, /* (90) replica ::= REPLICA INTEGER */ - 231, /* (91) quorum ::= QUORUM INTEGER */ - 232, /* (92) days ::= DAYS INTEGER */ - 233, /* (93) minrows ::= MINROWS INTEGER */ - 234, /* (94) maxrows ::= MAXROWS INTEGER */ - 235, /* (95) blocks ::= BLOCKS INTEGER */ - 236, /* (96) ctime ::= CTIME INTEGER */ - 237, /* (97) wal ::= WAL INTEGER */ - 238, /* (98) fsync ::= FSYNC INTEGER */ - 239, /* (99) comp ::= COMP INTEGER */ - 240, /* (100) prec ::= PRECISION STRING */ - 241, /* (101) update ::= UPDATE INTEGER */ - 242, /* (102) cachelast ::= CACHELAST INTEGER */ - 243, /* (103) partitions ::= PARTITIONS INTEGER */ - 213, /* (104) db_optr ::= */ - 213, /* (105) db_optr ::= db_optr cache */ - 213, /* (106) db_optr ::= db_optr replica */ - 213, /* (107) db_optr ::= db_optr quorum */ - 213, /* (108) db_optr ::= db_optr days */ - 213, /* (109) db_optr ::= db_optr minrows */ - 213, /* (110) db_optr ::= db_optr maxrows */ - 213, /* (111) db_optr ::= db_optr blocks */ - 213, /* (112) db_optr ::= db_optr ctime */ - 213, /* (113) db_optr ::= db_optr wal */ - 213, /* (114) db_optr ::= db_optr fsync */ - 213, /* (115) db_optr ::= db_optr comp */ - 213, /* (116) db_optr ::= db_optr prec */ - 213, /* (117) db_optr ::= db_optr keep */ - 213, /* (118) db_optr ::= db_optr update */ - 213, /* (119) db_optr ::= db_optr cachelast */ - 214, /* (120) topic_optr ::= db_optr */ - 214, /* (121) topic_optr ::= topic_optr partitions */ - 208, /* (122) alter_db_optr ::= */ - 208, /* (123) alter_db_optr ::= alter_db_optr replica */ - 208, /* (124) alter_db_optr ::= alter_db_optr quorum */ - 208, /* (125) alter_db_optr ::= alter_db_optr keep */ - 208, /* (126) alter_db_optr ::= alter_db_optr blocks */ - 208, /* (127) alter_db_optr ::= alter_db_optr comp */ - 208, /* (128) alter_db_optr ::= alter_db_optr update */ - 208, /* (129) alter_db_optr ::= alter_db_optr cachelast */ - 209, /* (130) alter_topic_optr ::= alter_db_optr */ - 209, /* (131) alter_topic_optr ::= alter_topic_optr partitions */ - 215, /* (132) typename ::= ids */ - 215, /* (133) typename ::= ids LP signed RP */ - 215, /* (134) typename ::= ids UNSIGNED */ - 244, /* (135) signed ::= INTEGER */ - 244, /* (136) signed ::= PLUS INTEGER */ - 244, /* (137) signed ::= MINUS INTEGER */ - 203, /* (138) cmd ::= CREATE TABLE create_table_args */ - 203, /* (139) cmd ::= CREATE TABLE create_stable_args */ - 203, /* (140) cmd ::= CREATE STABLE create_stable_args */ - 203, /* (141) cmd ::= CREATE TABLE create_table_list */ - 247, /* (142) create_table_list ::= create_from_stable */ - 247, /* (143) create_table_list ::= create_table_list create_from_stable */ - 245, /* (144) create_table_args ::= ifnotexists ids cpxName LP columnlist RP */ - 246, /* (145) create_stable_args ::= ifnotexists ids cpxName LP columnlist RP TAGS LP columnlist RP */ - 248, /* (146) create_from_stable ::= ifnotexists ids cpxName USING ids cpxName TAGS LP tagitemlist RP */ - 248, /* (147) create_from_stable ::= ifnotexists ids cpxName USING ids cpxName LP tagNamelist RP TAGS LP tagitemlist RP */ - 251, /* (148) tagNamelist ::= tagNamelist COMMA ids */ - 251, /* (149) tagNamelist ::= ids */ - 245, /* (150) create_table_args ::= ifnotexists ids cpxName AS select */ - 249, /* (151) columnlist ::= columnlist COMMA column */ - 249, /* (152) columnlist ::= column */ - 253, /* (153) column ::= ids typename */ - 250, /* (154) tagitemlist ::= tagitemlist COMMA tagitem */ - 250, /* (155) tagitemlist ::= tagitem */ - 254, /* (156) tagitem ::= INTEGER */ - 254, /* (157) tagitem ::= FLOAT */ - 254, /* (158) tagitem ::= STRING */ - 254, /* (159) tagitem ::= BOOL */ - 254, /* (160) tagitem ::= NULL */ - 254, /* (161) tagitem ::= NOW */ - 254, /* (162) tagitem ::= MINUS INTEGER */ - 254, /* (163) tagitem ::= MINUS FLOAT */ - 254, /* (164) tagitem ::= PLUS INTEGER */ - 254, /* (165) tagitem ::= PLUS FLOAT */ - 252, /* (166) select ::= SELECT selcollist from where_opt range_option interval_option sliding_opt session_option windowstate_option fill_opt groupby_opt having_opt orderby_opt slimit_opt limit_opt */ - 252, /* (167) select ::= LP select RP */ - 269, /* (168) union ::= select */ - 269, /* (169) union ::= union UNION ALL select */ - 203, /* (170) cmd ::= union */ - 252, /* (171) select ::= SELECT selcollist */ - 270, /* (172) sclp ::= selcollist COMMA */ - 270, /* (173) sclp ::= */ - 255, /* (174) selcollist ::= sclp distinct expr as */ - 255, /* (175) selcollist ::= sclp STAR */ - 273, /* (176) as ::= AS ids */ - 273, /* (177) as ::= ids */ - 273, /* (178) as ::= */ - 271, /* (179) distinct ::= DISTINCT */ - 271, /* (180) distinct ::= */ - 256, /* (181) from ::= FROM tablelist */ - 256, /* (182) from ::= FROM sub */ - 275, /* (183) sub ::= LP union RP */ - 275, /* (184) sub ::= LP union RP ids */ - 275, /* (185) sub ::= sub COMMA LP union RP ids */ - 274, /* (186) tablelist ::= ids cpxName */ - 274, /* (187) tablelist ::= ids cpxName ids */ - 274, /* (188) tablelist ::= tablelist COMMA ids cpxName */ - 274, /* (189) tablelist ::= tablelist COMMA ids cpxName ids */ - 276, /* (190) tmvar ::= VARIABLE */ - 277, /* (191) timestamp ::= INTEGER */ - 277, /* (192) timestamp ::= MINUS INTEGER */ - 277, /* (193) timestamp ::= PLUS INTEGER */ - 277, /* (194) timestamp ::= STRING */ - 277, /* (195) timestamp ::= NOW */ - 277, /* (196) timestamp ::= NOW PLUS VARIABLE */ - 277, /* (197) timestamp ::= NOW MINUS VARIABLE */ - 258, /* (198) range_option ::= */ - 258, /* (199) range_option ::= RANGE LP timestamp COMMA timestamp RP */ - 259, /* (200) interval_option ::= intervalKey LP tmvar RP */ - 259, /* (201) interval_option ::= intervalKey LP tmvar COMMA tmvar RP */ - 259, /* (202) interval_option ::= */ - 278, /* (203) intervalKey ::= INTERVAL */ - 278, /* (204) intervalKey ::= EVERY */ - 261, /* (205) session_option ::= */ - 261, /* (206) session_option ::= SESSION LP ids cpxName COMMA tmvar RP */ - 262, /* (207) windowstate_option ::= */ - 262, /* (208) windowstate_option ::= STATE_WINDOW LP ids RP */ - 263, /* (209) fill_opt ::= */ - 263, /* (210) fill_opt ::= FILL LP ID COMMA tagitemlist RP */ - 263, /* (211) fill_opt ::= FILL LP ID RP */ - 260, /* (212) sliding_opt ::= SLIDING LP tmvar RP */ - 260, /* (213) sliding_opt ::= */ - 266, /* (214) orderby_opt ::= */ - 266, /* (215) orderby_opt ::= ORDER BY sortlist */ - 279, /* (216) sortlist ::= sortlist COMMA item sortorder */ - 279, /* (217) sortlist ::= sortlist COMMA arrow sortorder */ - 279, /* (218) sortlist ::= item sortorder */ - 279, /* (219) sortlist ::= arrow sortorder */ - 280, /* (220) item ::= ID */ - 280, /* (221) item ::= ID DOT ID */ - 281, /* (222) sortorder ::= ASC */ - 281, /* (223) sortorder ::= DESC */ - 281, /* (224) sortorder ::= */ - 264, /* (225) groupby_opt ::= */ - 264, /* (226) groupby_opt ::= GROUP BY grouplist */ - 283, /* (227) grouplist ::= grouplist COMMA item */ - 283, /* (228) grouplist ::= grouplist COMMA arrow */ - 283, /* (229) grouplist ::= item */ - 283, /* (230) grouplist ::= arrow */ - 265, /* (231) having_opt ::= */ - 265, /* (232) having_opt ::= HAVING expr */ - 268, /* (233) limit_opt ::= */ - 268, /* (234) limit_opt ::= LIMIT signed */ - 268, /* (235) limit_opt ::= LIMIT signed OFFSET signed */ - 268, /* (236) limit_opt ::= LIMIT signed COMMA signed */ - 267, /* (237) slimit_opt ::= */ - 267, /* (238) slimit_opt ::= SLIMIT signed */ - 267, /* (239) slimit_opt ::= SLIMIT signed SOFFSET signed */ - 267, /* (240) slimit_opt ::= SLIMIT signed COMMA signed */ - 257, /* (241) where_opt ::= */ - 257, /* (242) where_opt ::= WHERE expr */ - 272, /* (243) expr ::= LP expr RP */ - 272, /* (244) expr ::= ID */ - 272, /* (245) expr ::= ID DOT ID */ - 272, /* (246) expr ::= ID DOT STAR */ - 272, /* (247) expr ::= INTEGER */ - 272, /* (248) expr ::= MINUS INTEGER */ - 272, /* (249) expr ::= PLUS INTEGER */ - 272, /* (250) expr ::= FLOAT */ - 272, /* (251) expr ::= MINUS FLOAT */ - 272, /* (252) expr ::= PLUS FLOAT */ - 272, /* (253) expr ::= STRING */ - 272, /* (254) expr ::= NOW */ - 272, /* (255) expr ::= VARIABLE */ - 272, /* (256) expr ::= PLUS VARIABLE */ - 272, /* (257) expr ::= MINUS VARIABLE */ - 272, /* (258) expr ::= BOOL */ - 272, /* (259) expr ::= NULL */ - 272, /* (260) expr ::= ID LP exprlist RP */ - 272, /* (261) expr ::= ID LP STAR RP */ - 272, /* (262) expr ::= expr IS NULL */ - 272, /* (263) expr ::= expr IS NOT NULL */ - 272, /* (264) expr ::= expr LT expr */ - 272, /* (265) expr ::= expr GT expr */ - 272, /* (266) expr ::= expr LE expr */ - 272, /* (267) expr ::= expr GE expr */ - 272, /* (268) expr ::= expr NE expr */ - 272, /* (269) expr ::= expr EQ expr */ - 272, /* (270) expr ::= expr BETWEEN expr AND expr */ - 272, /* (271) expr ::= expr AND expr */ - 272, /* (272) expr ::= expr OR expr */ - 272, /* (273) expr ::= expr PLUS expr */ - 272, /* (274) expr ::= expr MINUS expr */ - 272, /* (275) expr ::= expr STAR expr */ - 272, /* (276) expr ::= expr SLASH expr */ - 272, /* (277) expr ::= expr REM expr */ - 272, /* (278) expr ::= expr LIKE expr */ - 272, /* (279) expr ::= expr MATCH expr */ - 272, /* (280) expr ::= expr NMATCH expr */ - 272, /* (281) expr ::= ID CONTAINS STRING */ - 272, /* (282) expr ::= ID DOT ID CONTAINS STRING */ - 282, /* (283) arrow ::= ID ARROW STRING */ - 282, /* (284) arrow ::= ID DOT ID ARROW STRING */ - 272, /* (285) expr ::= arrow */ - 272, /* (286) expr ::= expr IN LP exprlist RP */ - 211, /* (287) exprlist ::= exprlist COMMA expritem */ - 211, /* (288) exprlist ::= expritem */ - 284, /* (289) expritem ::= expr */ - 284, /* (290) expritem ::= */ - 203, /* (291) cmd ::= RESET QUERY CACHE */ - 203, /* (292) cmd ::= SYNCDB ids REPLICA */ - 203, /* (293) cmd ::= ALTER TABLE ids cpxName ADD COLUMN columnlist */ - 203, /* (294) cmd ::= ALTER TABLE ids cpxName DROP COLUMN ids */ - 203, /* (295) cmd ::= ALTER TABLE ids cpxName MODIFY COLUMN columnlist */ - 203, /* (296) cmd ::= ALTER TABLE ids cpxName ADD TAG columnlist */ - 203, /* (297) cmd ::= ALTER TABLE ids cpxName DROP TAG ids */ - 203, /* (298) cmd ::= ALTER TABLE ids cpxName CHANGE TAG ids ids */ - 203, /* (299) cmd ::= ALTER TABLE ids cpxName SET TAG ids EQ tagitem */ - 203, /* (300) cmd ::= ALTER TABLE ids cpxName MODIFY TAG columnlist */ - 203, /* (301) cmd ::= ALTER STABLE ids cpxName ADD COLUMN columnlist */ - 203, /* (302) cmd ::= ALTER STABLE ids cpxName DROP COLUMN ids */ - 203, /* (303) cmd ::= ALTER STABLE ids cpxName MODIFY COLUMN columnlist */ - 203, /* (304) cmd ::= ALTER STABLE ids cpxName ADD TAG columnlist */ - 203, /* (305) cmd ::= ALTER STABLE ids cpxName DROP TAG ids */ - 203, /* (306) cmd ::= ALTER STABLE ids cpxName CHANGE TAG ids ids */ - 203, /* (307) cmd ::= ALTER STABLE ids cpxName SET TAG ids EQ tagitem */ - 203, /* (308) cmd ::= ALTER STABLE ids cpxName MODIFY TAG columnlist */ - 203, /* (309) cmd ::= KILL CONNECTION INTEGER */ - 203, /* (310) cmd ::= KILL STREAM INTEGER COLON INTEGER */ - 203, /* (311) cmd ::= KILL QUERY INTEGER COLON INTEGER */ + 201, /* (0) program ::= cmd */ + 202, /* (1) cmd ::= SHOW DATABASES */ + 202, /* (2) cmd ::= SHOW TOPICS */ + 202, /* (3) cmd ::= SHOW FUNCTIONS */ + 202, /* (4) cmd ::= SHOW MNODES */ + 202, /* (5) cmd ::= SHOW DNODES */ + 202, /* (6) cmd ::= SHOW ACCOUNTS */ + 202, /* (7) cmd ::= SHOW USERS */ + 202, /* (8) cmd ::= SHOW MODULES */ + 202, /* (9) cmd ::= SHOW QUERIES */ + 202, /* (10) cmd ::= SHOW CONNECTIONS */ + 202, /* (11) cmd ::= SHOW STREAMS */ + 202, /* (12) cmd ::= SHOW VARIABLES */ + 202, /* (13) cmd ::= SHOW SCORES */ + 202, /* (14) cmd ::= SHOW GRANTS */ + 202, /* (15) cmd ::= SHOW VNODES */ + 202, /* (16) cmd ::= SHOW VNODES ids */ + 204, /* (17) dbPrefix ::= */ + 204, /* (18) dbPrefix ::= ids DOT */ + 205, /* (19) cpxName ::= */ + 205, /* (20) cpxName ::= DOT ids */ + 202, /* (21) cmd ::= SHOW CREATE TABLE ids cpxName */ + 202, /* (22) cmd ::= SHOW CREATE STABLE ids cpxName */ + 202, /* (23) cmd ::= SHOW CREATE DATABASE ids */ + 202, /* (24) cmd ::= SHOW dbPrefix TABLES */ + 202, /* (25) cmd ::= SHOW dbPrefix TABLES LIKE ids */ + 202, /* (26) cmd ::= SHOW dbPrefix STABLES */ + 202, /* (27) cmd ::= SHOW dbPrefix STABLES LIKE ids */ + 202, /* (28) cmd ::= SHOW dbPrefix VGROUPS */ + 202, /* (29) cmd ::= DROP TABLE ifexists ids cpxName */ + 202, /* (30) cmd ::= DROP STABLE ifexists ids cpxName */ + 202, /* (31) cmd ::= DROP DATABASE ifexists ids */ + 202, /* (32) cmd ::= DROP TOPIC ifexists ids */ + 202, /* (33) cmd ::= DROP FUNCTION ids */ + 202, /* (34) cmd ::= DROP DNODE ids */ + 202, /* (35) cmd ::= DROP USER ids */ + 202, /* (36) cmd ::= DROP ACCOUNT ids */ + 202, /* (37) cmd ::= USE ids */ + 202, /* (38) cmd ::= DESCRIBE ids cpxName */ + 202, /* (39) cmd ::= DESC ids cpxName */ + 202, /* (40) cmd ::= ALTER USER ids PASS ids */ + 202, /* (41) cmd ::= ALTER USER ids PRIVILEGE ids */ + 202, /* (42) cmd ::= ALTER DNODE ids ids */ + 202, /* (43) cmd ::= ALTER DNODE ids ids ids */ + 202, /* (44) cmd ::= ALTER LOCAL ids */ + 202, /* (45) cmd ::= ALTER LOCAL ids ids */ + 202, /* (46) cmd ::= ALTER DATABASE ids alter_db_optr */ + 202, /* (47) cmd ::= ALTER TOPIC ids alter_topic_optr */ + 202, /* (48) cmd ::= ALTER ACCOUNT ids acct_optr */ + 202, /* (49) cmd ::= ALTER ACCOUNT ids PASS ids acct_optr */ + 202, /* (50) cmd ::= COMPACT VNODES IN LP exprlist RP */ + 203, /* (51) ids ::= ID */ + 203, /* (52) ids ::= STRING */ + 206, /* (53) ifexists ::= IF EXISTS */ + 206, /* (54) ifexists ::= */ + 211, /* (55) ifnotexists ::= IF NOT EXISTS */ + 211, /* (56) ifnotexists ::= */ + 202, /* (57) cmd ::= CREATE DNODE ids */ + 202, /* (58) cmd ::= CREATE ACCOUNT ids PASS ids acct_optr */ + 202, /* (59) cmd ::= CREATE DATABASE ifnotexists ids db_optr */ + 202, /* (60) cmd ::= CREATE TOPIC ifnotexists ids topic_optr */ + 202, /* (61) cmd ::= CREATE FUNCTION ids AS ids OUTPUTTYPE typename bufsize */ + 202, /* (62) cmd ::= CREATE AGGREGATE FUNCTION ids AS ids OUTPUTTYPE typename bufsize */ + 202, /* (63) cmd ::= CREATE USER ids PASS ids */ + 215, /* (64) bufsize ::= */ + 215, /* (65) bufsize ::= BUFSIZE INTEGER */ + 216, /* (66) pps ::= */ + 216, /* (67) pps ::= PPS INTEGER */ + 217, /* (68) tseries ::= */ + 217, /* (69) tseries ::= TSERIES INTEGER */ + 218, /* (70) dbs ::= */ + 218, /* (71) dbs ::= DBS INTEGER */ + 219, /* (72) streams ::= */ + 219, /* (73) streams ::= STREAMS INTEGER */ + 220, /* (74) storage ::= */ + 220, /* (75) storage ::= STORAGE INTEGER */ + 221, /* (76) qtime ::= */ + 221, /* (77) qtime ::= QTIME INTEGER */ + 222, /* (78) users ::= */ + 222, /* (79) users ::= USERS INTEGER */ + 223, /* (80) conns ::= */ + 223, /* (81) conns ::= CONNS INTEGER */ + 224, /* (82) state ::= */ + 224, /* (83) state ::= STATE ids */ + 209, /* (84) acct_optr ::= pps tseries storage streams qtime dbs users conns state */ + 225, /* (85) intitemlist ::= intitemlist COMMA intitem */ + 225, /* (86) intitemlist ::= intitem */ + 226, /* (87) intitem ::= INTEGER */ + 227, /* (88) keep ::= KEEP intitemlist */ + 228, /* (89) cache ::= CACHE INTEGER */ + 229, /* (90) replica ::= REPLICA INTEGER */ + 230, /* (91) quorum ::= QUORUM INTEGER */ + 231, /* (92) days ::= DAYS INTEGER */ + 232, /* (93) minrows ::= MINROWS INTEGER */ + 233, /* (94) maxrows ::= MAXROWS INTEGER */ + 234, /* (95) blocks ::= BLOCKS INTEGER */ + 235, /* (96) ctime ::= CTIME INTEGER */ + 236, /* (97) wal ::= WAL INTEGER */ + 237, /* (98) fsync ::= FSYNC INTEGER */ + 238, /* (99) comp ::= COMP INTEGER */ + 239, /* (100) prec ::= PRECISION STRING */ + 240, /* (101) update ::= UPDATE INTEGER */ + 241, /* (102) cachelast ::= CACHELAST INTEGER */ + 242, /* (103) partitions ::= PARTITIONS INTEGER */ + 212, /* (104) db_optr ::= */ + 212, /* (105) db_optr ::= db_optr cache */ + 212, /* (106) db_optr ::= db_optr replica */ + 212, /* (107) db_optr ::= db_optr quorum */ + 212, /* (108) db_optr ::= db_optr days */ + 212, /* (109) db_optr ::= db_optr minrows */ + 212, /* (110) db_optr ::= db_optr maxrows */ + 212, /* (111) db_optr ::= db_optr blocks */ + 212, /* (112) db_optr ::= db_optr ctime */ + 212, /* (113) db_optr ::= db_optr wal */ + 212, /* (114) db_optr ::= db_optr fsync */ + 212, /* (115) db_optr ::= db_optr comp */ + 212, /* (116) db_optr ::= db_optr prec */ + 212, /* (117) db_optr ::= db_optr keep */ + 212, /* (118) db_optr ::= db_optr update */ + 212, /* (119) db_optr ::= db_optr cachelast */ + 213, /* (120) topic_optr ::= db_optr */ + 213, /* (121) topic_optr ::= topic_optr partitions */ + 207, /* (122) alter_db_optr ::= */ + 207, /* (123) alter_db_optr ::= alter_db_optr replica */ + 207, /* (124) alter_db_optr ::= alter_db_optr quorum */ + 207, /* (125) alter_db_optr ::= alter_db_optr keep */ + 207, /* (126) alter_db_optr ::= alter_db_optr blocks */ + 207, /* (127) alter_db_optr ::= alter_db_optr comp */ + 207, /* (128) alter_db_optr ::= alter_db_optr update */ + 207, /* (129) alter_db_optr ::= alter_db_optr cachelast */ + 208, /* (130) alter_topic_optr ::= alter_db_optr */ + 208, /* (131) alter_topic_optr ::= alter_topic_optr partitions */ + 214, /* (132) typename ::= ids */ + 214, /* (133) typename ::= ids LP signed RP */ + 214, /* (134) typename ::= ids UNSIGNED */ + 243, /* (135) signed ::= INTEGER */ + 243, /* (136) signed ::= PLUS INTEGER */ + 243, /* (137) signed ::= MINUS INTEGER */ + 202, /* (138) cmd ::= CREATE TABLE create_table_args */ + 202, /* (139) cmd ::= CREATE TABLE create_stable_args */ + 202, /* (140) cmd ::= CREATE STABLE create_stable_args */ + 202, /* (141) cmd ::= CREATE TABLE create_table_list */ + 246, /* (142) create_table_list ::= create_from_stable */ + 246, /* (143) create_table_list ::= create_table_list create_from_stable */ + 244, /* (144) create_table_args ::= ifnotexists ids cpxName LP columnlist RP */ + 245, /* (145) create_stable_args ::= ifnotexists ids cpxName LP columnlist RP TAGS LP columnlist RP */ + 247, /* (146) create_from_stable ::= ifnotexists ids cpxName USING ids cpxName TAGS LP tagitemlist RP */ + 247, /* (147) create_from_stable ::= ifnotexists ids cpxName USING ids cpxName LP tagNamelist RP TAGS LP tagitemlist RP */ + 250, /* (148) tagNamelist ::= tagNamelist COMMA ids */ + 250, /* (149) tagNamelist ::= ids */ + 244, /* (150) create_table_args ::= ifnotexists ids cpxName AS select */ + 248, /* (151) columnlist ::= columnlist COMMA column */ + 248, /* (152) columnlist ::= column */ + 252, /* (153) column ::= ids typename */ + 249, /* (154) tagitemlist ::= tagitemlist COMMA tagitem */ + 249, /* (155) tagitemlist ::= tagitem */ + 253, /* (156) tagitem ::= INTEGER */ + 253, /* (157) tagitem ::= FLOAT */ + 253, /* (158) tagitem ::= STRING */ + 253, /* (159) tagitem ::= BOOL */ + 253, /* (160) tagitem ::= NULL */ + 253, /* (161) tagitem ::= NOW */ + 253, /* (162) tagitem ::= MINUS INTEGER */ + 253, /* (163) tagitem ::= MINUS FLOAT */ + 253, /* (164) tagitem ::= PLUS INTEGER */ + 253, /* (165) tagitem ::= PLUS FLOAT */ + 251, /* (166) select ::= SELECT selcollist from where_opt range_option interval_option sliding_opt session_option windowstate_option fill_opt groupby_opt having_opt orderby_opt slimit_opt limit_opt */ + 251, /* (167) select ::= LP select RP */ + 268, /* (168) union ::= select */ + 268, /* (169) union ::= union UNION ALL select */ + 202, /* (170) cmd ::= union */ + 251, /* (171) select ::= SELECT selcollist */ + 269, /* (172) sclp ::= selcollist COMMA */ + 269, /* (173) sclp ::= */ + 254, /* (174) selcollist ::= sclp distinct expr as */ + 254, /* (175) selcollist ::= sclp STAR */ + 272, /* (176) as ::= AS ids */ + 272, /* (177) as ::= ids */ + 272, /* (178) as ::= */ + 270, /* (179) distinct ::= DISTINCT */ + 270, /* (180) distinct ::= */ + 255, /* (181) from ::= FROM tablelist */ + 255, /* (182) from ::= FROM sub */ + 274, /* (183) sub ::= LP union RP */ + 274, /* (184) sub ::= LP union RP ids */ + 274, /* (185) sub ::= sub COMMA LP union RP ids */ + 273, /* (186) tablelist ::= ids cpxName */ + 273, /* (187) tablelist ::= ids cpxName ids */ + 273, /* (188) tablelist ::= tablelist COMMA ids cpxName */ + 273, /* (189) tablelist ::= tablelist COMMA ids cpxName ids */ + 275, /* (190) tmvar ::= VARIABLE */ + 276, /* (191) timestamp ::= INTEGER */ + 276, /* (192) timestamp ::= MINUS INTEGER */ + 276, /* (193) timestamp ::= PLUS INTEGER */ + 276, /* (194) timestamp ::= STRING */ + 276, /* (195) timestamp ::= NOW */ + 276, /* (196) timestamp ::= NOW PLUS VARIABLE */ + 276, /* (197) timestamp ::= NOW MINUS VARIABLE */ + 257, /* (198) range_option ::= */ + 257, /* (199) range_option ::= RANGE LP timestamp COMMA timestamp RP */ + 258, /* (200) interval_option ::= intervalKey LP tmvar RP */ + 258, /* (201) interval_option ::= intervalKey LP tmvar COMMA tmvar RP */ + 258, /* (202) interval_option ::= */ + 277, /* (203) intervalKey ::= INTERVAL */ + 277, /* (204) intervalKey ::= EVERY */ + 260, /* (205) session_option ::= */ + 260, /* (206) session_option ::= SESSION LP ids cpxName COMMA tmvar RP */ + 261, /* (207) windowstate_option ::= */ + 261, /* (208) windowstate_option ::= STATE_WINDOW LP ids RP */ + 262, /* (209) fill_opt ::= */ + 262, /* (210) fill_opt ::= FILL LP ID COMMA tagitemlist RP */ + 262, /* (211) fill_opt ::= FILL LP ID RP */ + 259, /* (212) sliding_opt ::= SLIDING LP tmvar RP */ + 259, /* (213) sliding_opt ::= */ + 265, /* (214) orderby_opt ::= */ + 265, /* (215) orderby_opt ::= ORDER BY sortlist */ + 278, /* (216) sortlist ::= sortlist COMMA item sortorder */ + 278, /* (217) sortlist ::= sortlist COMMA arrow sortorder */ + 278, /* (218) sortlist ::= item sortorder */ + 278, /* (219) sortlist ::= arrow sortorder */ + 279, /* (220) item ::= ID */ + 279, /* (221) item ::= ID DOT ID */ + 280, /* (222) sortorder ::= ASC */ + 280, /* (223) sortorder ::= DESC */ + 280, /* (224) sortorder ::= */ + 263, /* (225) groupby_opt ::= */ + 263, /* (226) groupby_opt ::= GROUP BY grouplist */ + 282, /* (227) grouplist ::= grouplist COMMA item */ + 282, /* (228) grouplist ::= grouplist COMMA arrow */ + 282, /* (229) grouplist ::= item */ + 282, /* (230) grouplist ::= arrow */ + 264, /* (231) having_opt ::= */ + 264, /* (232) having_opt ::= HAVING expr */ + 267, /* (233) limit_opt ::= */ + 267, /* (234) limit_opt ::= LIMIT signed */ + 267, /* (235) limit_opt ::= LIMIT signed OFFSET signed */ + 267, /* (236) limit_opt ::= LIMIT signed COMMA signed */ + 266, /* (237) slimit_opt ::= */ + 266, /* (238) slimit_opt ::= SLIMIT signed */ + 266, /* (239) slimit_opt ::= SLIMIT signed SOFFSET signed */ + 266, /* (240) slimit_opt ::= SLIMIT signed COMMA signed */ + 256, /* (241) where_opt ::= */ + 256, /* (242) where_opt ::= WHERE expr */ + 271, /* (243) expr ::= LP expr RP */ + 271, /* (244) expr ::= ID */ + 271, /* (245) expr ::= ID DOT ID */ + 271, /* (246) expr ::= ID DOT STAR */ + 271, /* (247) expr ::= INTEGER */ + 271, /* (248) expr ::= MINUS INTEGER */ + 271, /* (249) expr ::= PLUS INTEGER */ + 271, /* (250) expr ::= FLOAT */ + 271, /* (251) expr ::= MINUS FLOAT */ + 271, /* (252) expr ::= PLUS FLOAT */ + 271, /* (253) expr ::= STRING */ + 271, /* (254) expr ::= NOW */ + 271, /* (255) expr ::= VARIABLE */ + 271, /* (256) expr ::= PLUS VARIABLE */ + 271, /* (257) expr ::= MINUS VARIABLE */ + 271, /* (258) expr ::= BOOL */ + 271, /* (259) expr ::= NULL */ + 271, /* (260) expr ::= ID LP exprlist RP */ + 271, /* (261) expr ::= ID LP STAR RP */ + 271, /* (262) expr ::= ID LP expr AS typename RP */ + 271, /* (263) expr ::= expr IS NULL */ + 271, /* (264) expr ::= expr IS NOT NULL */ + 271, /* (265) expr ::= expr LT expr */ + 271, /* (266) expr ::= expr GT expr */ + 271, /* (267) expr ::= expr LE expr */ + 271, /* (268) expr ::= expr GE expr */ + 271, /* (269) expr ::= expr NE expr */ + 271, /* (270) expr ::= expr EQ expr */ + 271, /* (271) expr ::= expr BETWEEN expr AND expr */ + 271, /* (272) expr ::= expr AND expr */ + 271, /* (273) expr ::= expr OR expr */ + 271, /* (274) expr ::= expr PLUS expr */ + 271, /* (275) expr ::= expr MINUS expr */ + 271, /* (276) expr ::= expr STAR expr */ + 271, /* (277) expr ::= expr SLASH expr */ + 271, /* (278) expr ::= expr REM expr */ + 271, /* (279) expr ::= expr LIKE expr */ + 271, /* (280) expr ::= expr MATCH expr */ + 271, /* (281) expr ::= expr NMATCH expr */ + 271, /* (282) expr ::= ID CONTAINS STRING */ + 271, /* (283) expr ::= ID DOT ID CONTAINS STRING */ + 281, /* (284) arrow ::= ID ARROW STRING */ + 281, /* (285) arrow ::= ID DOT ID ARROW STRING */ + 271, /* (286) expr ::= arrow */ + 271, /* (287) expr ::= expr IN LP exprlist RP */ + 210, /* (288) exprlist ::= exprlist COMMA expritem */ + 210, /* (289) exprlist ::= expritem */ + 283, /* (290) expritem ::= expr */ + 283, /* (291) expritem ::= */ + 202, /* (292) cmd ::= RESET QUERY CACHE */ + 202, /* (293) cmd ::= SYNCDB ids REPLICA */ + 202, /* (294) cmd ::= ALTER TABLE ids cpxName ADD COLUMN columnlist */ + 202, /* (295) cmd ::= ALTER TABLE ids cpxName DROP COLUMN ids */ + 202, /* (296) cmd ::= ALTER TABLE ids cpxName MODIFY COLUMN columnlist */ + 202, /* (297) cmd ::= ALTER TABLE ids cpxName ADD TAG columnlist */ + 202, /* (298) cmd ::= ALTER TABLE ids cpxName DROP TAG ids */ + 202, /* (299) cmd ::= ALTER TABLE ids cpxName CHANGE TAG ids ids */ + 202, /* (300) cmd ::= ALTER TABLE ids cpxName SET TAG ids EQ tagitem */ + 202, /* (301) cmd ::= ALTER TABLE ids cpxName MODIFY TAG columnlist */ + 202, /* (302) cmd ::= ALTER STABLE ids cpxName ADD COLUMN columnlist */ + 202, /* (303) cmd ::= ALTER STABLE ids cpxName DROP COLUMN ids */ + 202, /* (304) cmd ::= ALTER STABLE ids cpxName MODIFY COLUMN columnlist */ + 202, /* (305) cmd ::= ALTER STABLE ids cpxName ADD TAG columnlist */ + 202, /* (306) cmd ::= ALTER STABLE ids cpxName DROP TAG ids */ + 202, /* (307) cmd ::= ALTER STABLE ids cpxName CHANGE TAG ids ids */ + 202, /* (308) cmd ::= ALTER STABLE ids cpxName SET TAG ids EQ tagitem */ + 202, /* (309) cmd ::= ALTER STABLE ids cpxName MODIFY TAG columnlist */ + 202, /* (310) cmd ::= KILL CONNECTION INTEGER */ + 202, /* (311) cmd ::= KILL STREAM INTEGER COLON INTEGER */ + 202, /* (312) cmd ::= KILL QUERY INTEGER COLON INTEGER */ }; /* For rule J, yyRuleInfoNRhs[J] contains the negative of the number @@ -2676,56 +2680,57 @@ static const signed char yyRuleInfoNRhs[] = { -1, /* (259) expr ::= NULL */ -4, /* (260) expr ::= ID LP exprlist RP */ -4, /* (261) expr ::= ID LP STAR RP */ - -3, /* (262) expr ::= expr IS NULL */ - -4, /* (263) expr ::= expr IS NOT NULL */ - -3, /* (264) expr ::= expr LT expr */ - -3, /* (265) expr ::= expr GT expr */ - -3, /* (266) expr ::= expr LE expr */ - -3, /* (267) expr ::= expr GE expr */ - -3, /* (268) expr ::= expr NE expr */ - -3, /* (269) expr ::= expr EQ expr */ - -5, /* (270) expr ::= expr BETWEEN expr AND expr */ - -3, /* (271) expr ::= expr AND expr */ - -3, /* (272) expr ::= expr OR expr */ - -3, /* (273) expr ::= expr PLUS expr */ - -3, /* (274) expr ::= expr MINUS expr */ - -3, /* (275) expr ::= expr STAR expr */ - -3, /* (276) expr ::= expr SLASH expr */ - -3, /* (277) expr ::= expr REM expr */ - -3, /* (278) expr ::= expr LIKE expr */ - -3, /* (279) expr ::= expr MATCH expr */ - -3, /* (280) expr ::= expr NMATCH expr */ - -3, /* (281) expr ::= ID CONTAINS STRING */ - -5, /* (282) expr ::= ID DOT ID CONTAINS STRING */ - -3, /* (283) arrow ::= ID ARROW STRING */ - -5, /* (284) arrow ::= ID DOT ID ARROW STRING */ - -1, /* (285) expr ::= arrow */ - -5, /* (286) expr ::= expr IN LP exprlist RP */ - -3, /* (287) exprlist ::= exprlist COMMA expritem */ - -1, /* (288) exprlist ::= expritem */ - -1, /* (289) expritem ::= expr */ - 0, /* (290) expritem ::= */ - -3, /* (291) cmd ::= RESET QUERY CACHE */ - -3, /* (292) cmd ::= SYNCDB ids REPLICA */ - -7, /* (293) cmd ::= ALTER TABLE ids cpxName ADD COLUMN columnlist */ - -7, /* (294) cmd ::= ALTER TABLE ids cpxName DROP COLUMN ids */ - -7, /* (295) cmd ::= ALTER TABLE ids cpxName MODIFY COLUMN columnlist */ - -7, /* (296) cmd ::= ALTER TABLE ids cpxName ADD TAG columnlist */ - -7, /* (297) cmd ::= ALTER TABLE ids cpxName DROP TAG ids */ - -8, /* (298) cmd ::= ALTER TABLE ids cpxName CHANGE TAG ids ids */ - -9, /* (299) cmd ::= ALTER TABLE ids cpxName SET TAG ids EQ tagitem */ - -7, /* (300) cmd ::= ALTER TABLE ids cpxName MODIFY TAG columnlist */ - -7, /* (301) cmd ::= ALTER STABLE ids cpxName ADD COLUMN columnlist */ - -7, /* (302) cmd ::= ALTER STABLE ids cpxName DROP COLUMN ids */ - -7, /* (303) cmd ::= ALTER STABLE ids cpxName MODIFY COLUMN columnlist */ - -7, /* (304) cmd ::= ALTER STABLE ids cpxName ADD TAG columnlist */ - -7, /* (305) cmd ::= ALTER STABLE ids cpxName DROP TAG ids */ - -8, /* (306) cmd ::= ALTER STABLE ids cpxName CHANGE TAG ids ids */ - -9, /* (307) cmd ::= ALTER STABLE ids cpxName SET TAG ids EQ tagitem */ - -7, /* (308) cmd ::= ALTER STABLE ids cpxName MODIFY TAG columnlist */ - -3, /* (309) cmd ::= KILL CONNECTION INTEGER */ - -5, /* (310) cmd ::= KILL STREAM INTEGER COLON INTEGER */ - -5, /* (311) cmd ::= KILL QUERY INTEGER COLON INTEGER */ + -6, /* (262) expr ::= ID LP expr AS typename RP */ + -3, /* (263) expr ::= expr IS NULL */ + -4, /* (264) expr ::= expr IS NOT NULL */ + -3, /* (265) expr ::= expr LT expr */ + -3, /* (266) expr ::= expr GT expr */ + -3, /* (267) expr ::= expr LE expr */ + -3, /* (268) expr ::= expr GE expr */ + -3, /* (269) expr ::= expr NE expr */ + -3, /* (270) expr ::= expr EQ expr */ + -5, /* (271) expr ::= expr BETWEEN expr AND expr */ + -3, /* (272) expr ::= expr AND expr */ + -3, /* (273) expr ::= expr OR expr */ + -3, /* (274) expr ::= expr PLUS expr */ + -3, /* (275) expr ::= expr MINUS expr */ + -3, /* (276) expr ::= expr STAR expr */ + -3, /* (277) expr ::= expr SLASH expr */ + -3, /* (278) expr ::= expr REM expr */ + -3, /* (279) expr ::= expr LIKE expr */ + -3, /* (280) expr ::= expr MATCH expr */ + -3, /* (281) expr ::= expr NMATCH expr */ + -3, /* (282) expr ::= ID CONTAINS STRING */ + -5, /* (283) expr ::= ID DOT ID CONTAINS STRING */ + -3, /* (284) arrow ::= ID ARROW STRING */ + -5, /* (285) arrow ::= ID DOT ID ARROW STRING */ + -1, /* (286) expr ::= arrow */ + -5, /* (287) expr ::= expr IN LP exprlist RP */ + -3, /* (288) exprlist ::= exprlist COMMA expritem */ + -1, /* (289) exprlist ::= expritem */ + -1, /* (290) expritem ::= expr */ + 0, /* (291) expritem ::= */ + -3, /* (292) cmd ::= RESET QUERY CACHE */ + -3, /* (293) cmd ::= SYNCDB ids REPLICA */ + -7, /* (294) cmd ::= ALTER TABLE ids cpxName ADD COLUMN columnlist */ + -7, /* (295) cmd ::= ALTER TABLE ids cpxName DROP COLUMN ids */ + -7, /* (296) cmd ::= ALTER TABLE ids cpxName MODIFY COLUMN columnlist */ + -7, /* (297) cmd ::= ALTER TABLE ids cpxName ADD TAG columnlist */ + -7, /* (298) cmd ::= ALTER TABLE ids cpxName DROP TAG ids */ + -8, /* (299) cmd ::= ALTER TABLE ids cpxName CHANGE TAG ids ids */ + -9, /* (300) cmd ::= ALTER TABLE ids cpxName SET TAG ids EQ tagitem */ + -7, /* (301) cmd ::= ALTER TABLE ids cpxName MODIFY TAG columnlist */ + -7, /* (302) cmd ::= ALTER STABLE ids cpxName ADD COLUMN columnlist */ + -7, /* (303) cmd ::= ALTER STABLE ids cpxName DROP COLUMN ids */ + -7, /* (304) cmd ::= ALTER STABLE ids cpxName MODIFY COLUMN columnlist */ + -7, /* (305) cmd ::= ALTER STABLE ids cpxName ADD TAG columnlist */ + -7, /* (306) cmd ::= ALTER STABLE ids cpxName DROP TAG ids */ + -8, /* (307) cmd ::= ALTER STABLE ids cpxName CHANGE TAG ids ids */ + -9, /* (308) cmd ::= ALTER STABLE ids cpxName SET TAG ids EQ tagitem */ + -7, /* (309) cmd ::= ALTER STABLE ids cpxName MODIFY TAG columnlist */ + -3, /* (310) cmd ::= KILL CONNECTION INTEGER */ + -5, /* (311) cmd ::= KILL STREAM INTEGER COLON INTEGER */ + -5, /* (312) cmd ::= KILL QUERY INTEGER COLON INTEGER */ }; static void yy_accept(yyParser*); /* Forward Declaration */ @@ -2940,16 +2945,16 @@ static YYACTIONTYPE yy_reduce( break; case 46: /* cmd ::= ALTER DATABASE ids alter_db_optr */ case 47: /* cmd ::= ALTER TOPIC ids alter_topic_optr */ yytestcase(yyruleno==47); -{ SStrToken t = {0}; setCreateDbInfo(pInfo, TSDB_SQL_ALTER_DB, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy532, &t);} +{ SStrToken t = {0}; setCreateDbInfo(pInfo, TSDB_SQL_ALTER_DB, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy470, &t);} break; case 48: /* cmd ::= ALTER ACCOUNT ids acct_optr */ -{ setCreateAcctSql(pInfo, TSDB_SQL_ALTER_ACCT, &yymsp[-1].minor.yy0, NULL, &yymsp[0].minor.yy31);} +{ setCreateAcctSql(pInfo, TSDB_SQL_ALTER_ACCT, &yymsp[-1].minor.yy0, NULL, &yymsp[0].minor.yy51);} break; case 49: /* cmd ::= ALTER ACCOUNT ids PASS ids acct_optr */ -{ setCreateAcctSql(pInfo, TSDB_SQL_ALTER_ACCT, &yymsp[-3].minor.yy0, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy31);} +{ setCreateAcctSql(pInfo, TSDB_SQL_ALTER_ACCT, &yymsp[-3].minor.yy0, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy51);} break; case 50: /* cmd ::= COMPACT VNODES IN LP exprlist RP */ -{ setCompactVnodeSql(pInfo, TSDB_SQL_COMPACT_VNODE, yymsp[-1].minor.yy231);} +{ setCompactVnodeSql(pInfo, TSDB_SQL_COMPACT_VNODE, yymsp[-1].minor.yy189);} break; case 51: /* ids ::= ID */ case 52: /* ids ::= STRING */ yytestcase(yyruleno==52); @@ -2971,17 +2976,17 @@ static YYACTIONTYPE yy_reduce( { setDCLSqlElems(pInfo, TSDB_SQL_CREATE_DNODE, 1, &yymsp[0].minor.yy0);} break; case 58: /* cmd ::= CREATE ACCOUNT ids PASS ids acct_optr */ -{ setCreateAcctSql(pInfo, TSDB_SQL_CREATE_ACCT, &yymsp[-3].minor.yy0, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy31);} +{ setCreateAcctSql(pInfo, TSDB_SQL_CREATE_ACCT, &yymsp[-3].minor.yy0, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy51);} break; case 59: /* cmd ::= CREATE DATABASE ifnotexists ids db_optr */ case 60: /* cmd ::= CREATE TOPIC ifnotexists ids topic_optr */ yytestcase(yyruleno==60); -{ setCreateDbInfo(pInfo, TSDB_SQL_CREATE_DB, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy532, &yymsp[-2].minor.yy0);} +{ setCreateDbInfo(pInfo, TSDB_SQL_CREATE_DB, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy470, &yymsp[-2].minor.yy0);} break; case 61: /* cmd ::= CREATE FUNCTION ids AS ids OUTPUTTYPE typename bufsize */ -{ setCreateFuncInfo(pInfo, TSDB_SQL_CREATE_FUNCTION, &yymsp[-5].minor.yy0, &yymsp[-3].minor.yy0, &yymsp[-1].minor.yy103, &yymsp[0].minor.yy0, 1);} +{ setCreateFuncInfo(pInfo, TSDB_SQL_CREATE_FUNCTION, &yymsp[-5].minor.yy0, &yymsp[-3].minor.yy0, &yymsp[-1].minor.yy279, &yymsp[0].minor.yy0, 1);} break; case 62: /* cmd ::= CREATE AGGREGATE FUNCTION ids AS ids OUTPUTTYPE typename bufsize */ -{ setCreateFuncInfo(pInfo, TSDB_SQL_CREATE_FUNCTION, &yymsp[-5].minor.yy0, &yymsp[-3].minor.yy0, &yymsp[-1].minor.yy103, &yymsp[0].minor.yy0, 2);} +{ setCreateFuncInfo(pInfo, TSDB_SQL_CREATE_FUNCTION, &yymsp[-5].minor.yy0, &yymsp[-3].minor.yy0, &yymsp[-1].minor.yy279, &yymsp[0].minor.yy0, 2);} break; case 63: /* cmd ::= CREATE USER ids PASS ids */ { setCreateUserSql(pInfo, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0);} @@ -3012,38 +3017,38 @@ static YYACTIONTYPE yy_reduce( break; case 84: /* acct_optr ::= pps tseries storage streams qtime dbs users conns state */ { - yylhsminor.yy31.maxUsers = (yymsp[-2].minor.yy0.n>0)?atoi(yymsp[-2].minor.yy0.z):-1; - yylhsminor.yy31.maxDbs = (yymsp[-3].minor.yy0.n>0)?atoi(yymsp[-3].minor.yy0.z):-1; - yylhsminor.yy31.maxTimeSeries = (yymsp[-7].minor.yy0.n>0)?atoi(yymsp[-7].minor.yy0.z):-1; - yylhsminor.yy31.maxStreams = (yymsp[-5].minor.yy0.n>0)?atoi(yymsp[-5].minor.yy0.z):-1; - yylhsminor.yy31.maxPointsPerSecond = (yymsp[-8].minor.yy0.n>0)?atoi(yymsp[-8].minor.yy0.z):-1; - yylhsminor.yy31.maxStorage = (yymsp[-6].minor.yy0.n>0)?strtoll(yymsp[-6].minor.yy0.z, NULL, 10):-1; - yylhsminor.yy31.maxQueryTime = (yymsp[-4].minor.yy0.n>0)?strtoll(yymsp[-4].minor.yy0.z, NULL, 10):-1; - yylhsminor.yy31.maxConnections = (yymsp[-1].minor.yy0.n>0)?atoi(yymsp[-1].minor.yy0.z):-1; - yylhsminor.yy31.stat = yymsp[0].minor.yy0; + yylhsminor.yy51.maxUsers = (yymsp[-2].minor.yy0.n>0)?atoi(yymsp[-2].minor.yy0.z):-1; + yylhsminor.yy51.maxDbs = (yymsp[-3].minor.yy0.n>0)?atoi(yymsp[-3].minor.yy0.z):-1; + yylhsminor.yy51.maxTimeSeries = (yymsp[-7].minor.yy0.n>0)?atoi(yymsp[-7].minor.yy0.z):-1; + yylhsminor.yy51.maxStreams = (yymsp[-5].minor.yy0.n>0)?atoi(yymsp[-5].minor.yy0.z):-1; + yylhsminor.yy51.maxPointsPerSecond = (yymsp[-8].minor.yy0.n>0)?atoi(yymsp[-8].minor.yy0.z):-1; + yylhsminor.yy51.maxStorage = (yymsp[-6].minor.yy0.n>0)?strtoll(yymsp[-6].minor.yy0.z, NULL, 10):-1; + yylhsminor.yy51.maxQueryTime = (yymsp[-4].minor.yy0.n>0)?strtoll(yymsp[-4].minor.yy0.z, NULL, 10):-1; + yylhsminor.yy51.maxConnections = (yymsp[-1].minor.yy0.n>0)?atoi(yymsp[-1].minor.yy0.z):-1; + yylhsminor.yy51.stat = yymsp[0].minor.yy0; } - yymsp[-8].minor.yy31 = yylhsminor.yy31; + yymsp[-8].minor.yy51 = yylhsminor.yy51; break; case 85: /* intitemlist ::= intitemlist COMMA intitem */ case 154: /* tagitemlist ::= tagitemlist COMMA tagitem */ yytestcase(yyruleno==154); -{ yylhsminor.yy231 = tVariantListAppend(yymsp[-2].minor.yy231, &yymsp[0].minor.yy176, -1); } - yymsp[-2].minor.yy231 = yylhsminor.yy231; +{ yylhsminor.yy189 = tVariantListAppend(yymsp[-2].minor.yy189, &yymsp[0].minor.yy162, -1); } + yymsp[-2].minor.yy189 = yylhsminor.yy189; break; case 86: /* intitemlist ::= intitem */ case 155: /* tagitemlist ::= tagitem */ yytestcase(yyruleno==155); -{ yylhsminor.yy231 = tVariantListAppend(NULL, &yymsp[0].minor.yy176, -1); } - yymsp[0].minor.yy231 = yylhsminor.yy231; +{ yylhsminor.yy189 = tVariantListAppend(NULL, &yymsp[0].minor.yy162, -1); } + yymsp[0].minor.yy189 = yylhsminor.yy189; break; case 87: /* intitem ::= INTEGER */ case 156: /* tagitem ::= INTEGER */ yytestcase(yyruleno==156); case 157: /* tagitem ::= FLOAT */ yytestcase(yyruleno==157); case 158: /* tagitem ::= STRING */ yytestcase(yyruleno==158); case 159: /* tagitem ::= BOOL */ yytestcase(yyruleno==159); -{ toTSDBType(yymsp[0].minor.yy0.type); tVariantCreate(&yylhsminor.yy176, &yymsp[0].minor.yy0, true); } - yymsp[0].minor.yy176 = yylhsminor.yy176; +{ toTSDBType(yymsp[0].minor.yy0.type); tVariantCreate(&yylhsminor.yy162, &yymsp[0].minor.yy0, true); } + yymsp[0].minor.yy162 = yylhsminor.yy162; break; case 88: /* keep ::= KEEP intitemlist */ -{ yymsp[-1].minor.yy231 = yymsp[0].minor.yy231; } +{ yymsp[-1].minor.yy189 = yymsp[0].minor.yy189; } break; case 89: /* cache ::= CACHE INTEGER */ case 90: /* replica ::= REPLICA INTEGER */ yytestcase(yyruleno==90); @@ -3063,221 +3068,221 @@ static YYACTIONTYPE yy_reduce( { yymsp[-1].minor.yy0 = yymsp[0].minor.yy0; } break; case 104: /* db_optr ::= */ -{setDefaultCreateDbOption(&yymsp[1].minor.yy532); yymsp[1].minor.yy532.dbType = TSDB_DB_TYPE_DEFAULT;} +{setDefaultCreateDbOption(&yymsp[1].minor.yy470); yymsp[1].minor.yy470.dbType = TSDB_DB_TYPE_DEFAULT;} break; case 105: /* db_optr ::= db_optr cache */ -{ yylhsminor.yy532 = yymsp[-1].minor.yy532; yylhsminor.yy532.cacheBlockSize = strtol(yymsp[0].minor.yy0.z, NULL, 10); } - yymsp[-1].minor.yy532 = yylhsminor.yy532; +{ yylhsminor.yy470 = yymsp[-1].minor.yy470; yylhsminor.yy470.cacheBlockSize = strtol(yymsp[0].minor.yy0.z, NULL, 10); } + yymsp[-1].minor.yy470 = yylhsminor.yy470; break; case 106: /* db_optr ::= db_optr replica */ case 123: /* alter_db_optr ::= alter_db_optr replica */ yytestcase(yyruleno==123); -{ yylhsminor.yy532 = yymsp[-1].minor.yy532; yylhsminor.yy532.replica = strtol(yymsp[0].minor.yy0.z, NULL, 10); } - yymsp[-1].minor.yy532 = yylhsminor.yy532; +{ yylhsminor.yy470 = yymsp[-1].minor.yy470; yylhsminor.yy470.replica = strtol(yymsp[0].minor.yy0.z, NULL, 10); } + yymsp[-1].minor.yy470 = yylhsminor.yy470; break; case 107: /* db_optr ::= db_optr quorum */ case 124: /* alter_db_optr ::= alter_db_optr quorum */ yytestcase(yyruleno==124); -{ yylhsminor.yy532 = yymsp[-1].minor.yy532; yylhsminor.yy532.quorum = strtol(yymsp[0].minor.yy0.z, NULL, 10); } - yymsp[-1].minor.yy532 = yylhsminor.yy532; +{ yylhsminor.yy470 = yymsp[-1].minor.yy470; yylhsminor.yy470.quorum = strtol(yymsp[0].minor.yy0.z, NULL, 10); } + yymsp[-1].minor.yy470 = yylhsminor.yy470; break; case 108: /* db_optr ::= db_optr days */ -{ yylhsminor.yy532 = yymsp[-1].minor.yy532; yylhsminor.yy532.daysPerFile = strtol(yymsp[0].minor.yy0.z, NULL, 10); } - yymsp[-1].minor.yy532 = yylhsminor.yy532; +{ yylhsminor.yy470 = yymsp[-1].minor.yy470; yylhsminor.yy470.daysPerFile = strtol(yymsp[0].minor.yy0.z, NULL, 10); } + yymsp[-1].minor.yy470 = yylhsminor.yy470; break; case 109: /* db_optr ::= db_optr minrows */ -{ yylhsminor.yy532 = yymsp[-1].minor.yy532; yylhsminor.yy532.minRowsPerBlock = strtod(yymsp[0].minor.yy0.z, NULL); } - yymsp[-1].minor.yy532 = yylhsminor.yy532; +{ yylhsminor.yy470 = yymsp[-1].minor.yy470; yylhsminor.yy470.minRowsPerBlock = strtod(yymsp[0].minor.yy0.z, NULL); } + yymsp[-1].minor.yy470 = yylhsminor.yy470; break; case 110: /* db_optr ::= db_optr maxrows */ -{ yylhsminor.yy532 = yymsp[-1].minor.yy532; yylhsminor.yy532.maxRowsPerBlock = strtod(yymsp[0].minor.yy0.z, NULL); } - yymsp[-1].minor.yy532 = yylhsminor.yy532; +{ yylhsminor.yy470 = yymsp[-1].minor.yy470; yylhsminor.yy470.maxRowsPerBlock = strtod(yymsp[0].minor.yy0.z, NULL); } + yymsp[-1].minor.yy470 = yylhsminor.yy470; break; case 111: /* db_optr ::= db_optr blocks */ case 126: /* alter_db_optr ::= alter_db_optr blocks */ yytestcase(yyruleno==126); -{ yylhsminor.yy532 = yymsp[-1].minor.yy532; yylhsminor.yy532.numOfBlocks = strtol(yymsp[0].minor.yy0.z, NULL, 10); } - yymsp[-1].minor.yy532 = yylhsminor.yy532; +{ yylhsminor.yy470 = yymsp[-1].minor.yy470; yylhsminor.yy470.numOfBlocks = strtol(yymsp[0].minor.yy0.z, NULL, 10); } + yymsp[-1].minor.yy470 = yylhsminor.yy470; break; case 112: /* db_optr ::= db_optr ctime */ -{ yylhsminor.yy532 = yymsp[-1].minor.yy532; yylhsminor.yy532.commitTime = strtol(yymsp[0].minor.yy0.z, NULL, 10); } - yymsp[-1].minor.yy532 = yylhsminor.yy532; +{ yylhsminor.yy470 = yymsp[-1].minor.yy470; yylhsminor.yy470.commitTime = strtol(yymsp[0].minor.yy0.z, NULL, 10); } + yymsp[-1].minor.yy470 = yylhsminor.yy470; break; case 113: /* db_optr ::= db_optr wal */ -{ yylhsminor.yy532 = yymsp[-1].minor.yy532; yylhsminor.yy532.walLevel = strtol(yymsp[0].minor.yy0.z, NULL, 10); } - yymsp[-1].minor.yy532 = yylhsminor.yy532; +{ yylhsminor.yy470 = yymsp[-1].minor.yy470; yylhsminor.yy470.walLevel = strtol(yymsp[0].minor.yy0.z, NULL, 10); } + yymsp[-1].minor.yy470 = yylhsminor.yy470; break; case 114: /* db_optr ::= db_optr fsync */ -{ yylhsminor.yy532 = yymsp[-1].minor.yy532; yylhsminor.yy532.fsyncPeriod = strtol(yymsp[0].minor.yy0.z, NULL, 10); } - yymsp[-1].minor.yy532 = yylhsminor.yy532; +{ yylhsminor.yy470 = yymsp[-1].minor.yy470; yylhsminor.yy470.fsyncPeriod = strtol(yymsp[0].minor.yy0.z, NULL, 10); } + yymsp[-1].minor.yy470 = yylhsminor.yy470; break; case 115: /* db_optr ::= db_optr comp */ case 127: /* alter_db_optr ::= alter_db_optr comp */ yytestcase(yyruleno==127); -{ yylhsminor.yy532 = yymsp[-1].minor.yy532; yylhsminor.yy532.compressionLevel = strtol(yymsp[0].minor.yy0.z, NULL, 10); } - yymsp[-1].minor.yy532 = yylhsminor.yy532; +{ yylhsminor.yy470 = yymsp[-1].minor.yy470; yylhsminor.yy470.compressionLevel = strtol(yymsp[0].minor.yy0.z, NULL, 10); } + yymsp[-1].minor.yy470 = yylhsminor.yy470; break; case 116: /* db_optr ::= db_optr prec */ -{ yylhsminor.yy532 = yymsp[-1].minor.yy532; yylhsminor.yy532.precision = yymsp[0].minor.yy0; } - yymsp[-1].minor.yy532 = yylhsminor.yy532; +{ yylhsminor.yy470 = yymsp[-1].minor.yy470; yylhsminor.yy470.precision = yymsp[0].minor.yy0; } + yymsp[-1].minor.yy470 = yylhsminor.yy470; break; case 117: /* db_optr ::= db_optr keep */ case 125: /* alter_db_optr ::= alter_db_optr keep */ yytestcase(yyruleno==125); -{ yylhsminor.yy532 = yymsp[-1].minor.yy532; yylhsminor.yy532.keep = yymsp[0].minor.yy231; } - yymsp[-1].minor.yy532 = yylhsminor.yy532; +{ yylhsminor.yy470 = yymsp[-1].minor.yy470; yylhsminor.yy470.keep = yymsp[0].minor.yy189; } + yymsp[-1].minor.yy470 = yylhsminor.yy470; break; case 118: /* db_optr ::= db_optr update */ case 128: /* alter_db_optr ::= alter_db_optr update */ yytestcase(yyruleno==128); -{ yylhsminor.yy532 = yymsp[-1].minor.yy532; yylhsminor.yy532.update = strtol(yymsp[0].minor.yy0.z, NULL, 10); } - yymsp[-1].minor.yy532 = yylhsminor.yy532; +{ yylhsminor.yy470 = yymsp[-1].minor.yy470; yylhsminor.yy470.update = strtol(yymsp[0].minor.yy0.z, NULL, 10); } + yymsp[-1].minor.yy470 = yylhsminor.yy470; break; case 119: /* db_optr ::= db_optr cachelast */ case 129: /* alter_db_optr ::= alter_db_optr cachelast */ yytestcase(yyruleno==129); -{ yylhsminor.yy532 = yymsp[-1].minor.yy532; yylhsminor.yy532.cachelast = strtol(yymsp[0].minor.yy0.z, NULL, 10); } - yymsp[-1].minor.yy532 = yylhsminor.yy532; +{ yylhsminor.yy470 = yymsp[-1].minor.yy470; yylhsminor.yy470.cachelast = strtol(yymsp[0].minor.yy0.z, NULL, 10); } + yymsp[-1].minor.yy470 = yylhsminor.yy470; break; case 120: /* topic_optr ::= db_optr */ case 130: /* alter_topic_optr ::= alter_db_optr */ yytestcase(yyruleno==130); -{ yylhsminor.yy532 = yymsp[0].minor.yy532; yylhsminor.yy532.dbType = TSDB_DB_TYPE_TOPIC; } - yymsp[0].minor.yy532 = yylhsminor.yy532; +{ yylhsminor.yy470 = yymsp[0].minor.yy470; yylhsminor.yy470.dbType = TSDB_DB_TYPE_TOPIC; } + yymsp[0].minor.yy470 = yylhsminor.yy470; break; case 121: /* topic_optr ::= topic_optr partitions */ case 131: /* alter_topic_optr ::= alter_topic_optr partitions */ yytestcase(yyruleno==131); -{ yylhsminor.yy532 = yymsp[-1].minor.yy532; yylhsminor.yy532.partitions = strtol(yymsp[0].minor.yy0.z, NULL, 10); } - yymsp[-1].minor.yy532 = yylhsminor.yy532; +{ yylhsminor.yy470 = yymsp[-1].minor.yy470; yylhsminor.yy470.partitions = strtol(yymsp[0].minor.yy0.z, NULL, 10); } + yymsp[-1].minor.yy470 = yylhsminor.yy470; break; case 122: /* alter_db_optr ::= */ -{ setDefaultCreateDbOption(&yymsp[1].minor.yy532); yymsp[1].minor.yy532.dbType = TSDB_DB_TYPE_DEFAULT;} +{ setDefaultCreateDbOption(&yymsp[1].minor.yy470); yymsp[1].minor.yy470.dbType = TSDB_DB_TYPE_DEFAULT;} break; case 132: /* typename ::= ids */ { yymsp[0].minor.yy0.type = 0; - tSetColumnType (&yylhsminor.yy103, &yymsp[0].minor.yy0); + tSetColumnType (&yylhsminor.yy279, &yymsp[0].minor.yy0); } - yymsp[0].minor.yy103 = yylhsminor.yy103; + yymsp[0].minor.yy279 = yylhsminor.yy279; break; case 133: /* typename ::= ids LP signed RP */ { - if (yymsp[-1].minor.yy549 <= 0) { + if (yymsp[-1].minor.yy69 <= 0) { yymsp[-3].minor.yy0.type = 0; - tSetColumnType(&yylhsminor.yy103, &yymsp[-3].minor.yy0); + tSetColumnType(&yylhsminor.yy279, &yymsp[-3].minor.yy0); } else { - yymsp[-3].minor.yy0.type = -yymsp[-1].minor.yy549; // negative value of name length - tSetColumnType(&yylhsminor.yy103, &yymsp[-3].minor.yy0); + yymsp[-3].minor.yy0.type = -yymsp[-1].minor.yy69; // negative value of name length + tSetColumnType(&yylhsminor.yy279, &yymsp[-3].minor.yy0); } } - yymsp[-3].minor.yy103 = yylhsminor.yy103; + yymsp[-3].minor.yy279 = yylhsminor.yy279; break; case 134: /* typename ::= ids UNSIGNED */ { yymsp[-1].minor.yy0.type = 0; yymsp[-1].minor.yy0.n = ((yymsp[0].minor.yy0.z + yymsp[0].minor.yy0.n) - yymsp[-1].minor.yy0.z); - tSetColumnType (&yylhsminor.yy103, &yymsp[-1].minor.yy0); + tSetColumnType (&yylhsminor.yy279, &yymsp[-1].minor.yy0); } - yymsp[-1].minor.yy103 = yylhsminor.yy103; + yymsp[-1].minor.yy279 = yylhsminor.yy279; break; case 135: /* signed ::= INTEGER */ -{ yylhsminor.yy549 = strtol(yymsp[0].minor.yy0.z, NULL, 10); } - yymsp[0].minor.yy549 = yylhsminor.yy549; +{ yylhsminor.yy69 = strtol(yymsp[0].minor.yy0.z, NULL, 10); } + yymsp[0].minor.yy69 = yylhsminor.yy69; break; case 136: /* signed ::= PLUS INTEGER */ -{ yymsp[-1].minor.yy549 = strtol(yymsp[0].minor.yy0.z, NULL, 10); } +{ yymsp[-1].minor.yy69 = strtol(yymsp[0].minor.yy0.z, NULL, 10); } break; case 137: /* signed ::= MINUS INTEGER */ -{ yymsp[-1].minor.yy549 = -strtol(yymsp[0].minor.yy0.z, NULL, 10);} +{ yymsp[-1].minor.yy69 = -strtol(yymsp[0].minor.yy0.z, NULL, 10);} break; case 141: /* cmd ::= CREATE TABLE create_table_list */ -{ pInfo->type = TSDB_SQL_CREATE_TABLE; pInfo->pCreateTableInfo = yymsp[0].minor.yy422;} +{ pInfo->type = TSDB_SQL_CREATE_TABLE; pInfo->pCreateTableInfo = yymsp[0].minor.yy6;} break; case 142: /* create_table_list ::= create_from_stable */ { SCreateTableSql* pCreateTable = calloc(1, sizeof(SCreateTableSql)); pCreateTable->childTableInfo = taosArrayInit(4, sizeof(SCreatedTableInfo)); - taosArrayPush(pCreateTable->childTableInfo, &yymsp[0].minor.yy306); + taosArrayPush(pCreateTable->childTableInfo, &yymsp[0].minor.yy208); pCreateTable->type = TSQL_CREATE_TABLE_FROM_STABLE; - yylhsminor.yy422 = pCreateTable; + yylhsminor.yy6 = pCreateTable; } - yymsp[0].minor.yy422 = yylhsminor.yy422; + yymsp[0].minor.yy6 = yylhsminor.yy6; break; case 143: /* create_table_list ::= create_table_list create_from_stable */ { - taosArrayPush(yymsp[-1].minor.yy422->childTableInfo, &yymsp[0].minor.yy306); - yylhsminor.yy422 = yymsp[-1].minor.yy422; + taosArrayPush(yymsp[-1].minor.yy6->childTableInfo, &yymsp[0].minor.yy208); + yylhsminor.yy6 = yymsp[-1].minor.yy6; } - yymsp[-1].minor.yy422 = yylhsminor.yy422; + yymsp[-1].minor.yy6 = yylhsminor.yy6; break; case 144: /* create_table_args ::= ifnotexists ids cpxName LP columnlist RP */ { - yylhsminor.yy422 = tSetCreateTableInfo(yymsp[-1].minor.yy231, NULL, NULL, TSQL_CREATE_TABLE); - setSqlInfo(pInfo, yylhsminor.yy422, NULL, TSDB_SQL_CREATE_TABLE); + yylhsminor.yy6 = tSetCreateTableInfo(yymsp[-1].minor.yy189, NULL, NULL, TSQL_CREATE_TABLE); + setSqlInfo(pInfo, yylhsminor.yy6, NULL, TSDB_SQL_CREATE_TABLE); yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n; setCreatedTableName(pInfo, &yymsp[-4].minor.yy0, &yymsp[-5].minor.yy0); } - yymsp[-5].minor.yy422 = yylhsminor.yy422; + yymsp[-5].minor.yy6 = yylhsminor.yy6; break; case 145: /* create_stable_args ::= ifnotexists ids cpxName LP columnlist RP TAGS LP columnlist RP */ { - yylhsminor.yy422 = tSetCreateTableInfo(yymsp[-5].minor.yy231, yymsp[-1].minor.yy231, NULL, TSQL_CREATE_STABLE); - setSqlInfo(pInfo, yylhsminor.yy422, NULL, TSDB_SQL_CREATE_TABLE); + yylhsminor.yy6 = tSetCreateTableInfo(yymsp[-5].minor.yy189, yymsp[-1].minor.yy189, NULL, TSQL_CREATE_STABLE); + setSqlInfo(pInfo, yylhsminor.yy6, NULL, TSDB_SQL_CREATE_TABLE); yymsp[-8].minor.yy0.n += yymsp[-7].minor.yy0.n; setCreatedTableName(pInfo, &yymsp[-8].minor.yy0, &yymsp[-9].minor.yy0); } - yymsp[-9].minor.yy422 = yylhsminor.yy422; + yymsp[-9].minor.yy6 = yylhsminor.yy6; break; case 146: /* create_from_stable ::= ifnotexists ids cpxName USING ids cpxName TAGS LP tagitemlist RP */ { yymsp[-5].minor.yy0.n += yymsp[-4].minor.yy0.n; yymsp[-8].minor.yy0.n += yymsp[-7].minor.yy0.n; - yylhsminor.yy306 = createNewChildTableInfo(&yymsp[-5].minor.yy0, NULL, yymsp[-1].minor.yy231, &yymsp[-8].minor.yy0, &yymsp[-9].minor.yy0); + yylhsminor.yy208 = createNewChildTableInfo(&yymsp[-5].minor.yy0, NULL, yymsp[-1].minor.yy189, &yymsp[-8].minor.yy0, &yymsp[-9].minor.yy0); } - yymsp[-9].minor.yy306 = yylhsminor.yy306; + yymsp[-9].minor.yy208 = yylhsminor.yy208; break; case 147: /* create_from_stable ::= ifnotexists ids cpxName USING ids cpxName LP tagNamelist RP TAGS LP tagitemlist RP */ { yymsp[-8].minor.yy0.n += yymsp[-7].minor.yy0.n; yymsp[-11].minor.yy0.n += yymsp[-10].minor.yy0.n; - yylhsminor.yy306 = createNewChildTableInfo(&yymsp[-8].minor.yy0, yymsp[-5].minor.yy231, yymsp[-1].minor.yy231, &yymsp[-11].minor.yy0, &yymsp[-12].minor.yy0); + yylhsminor.yy208 = createNewChildTableInfo(&yymsp[-8].minor.yy0, yymsp[-5].minor.yy189, yymsp[-1].minor.yy189, &yymsp[-11].minor.yy0, &yymsp[-12].minor.yy0); } - yymsp[-12].minor.yy306 = yylhsminor.yy306; + yymsp[-12].minor.yy208 = yylhsminor.yy208; break; case 148: /* tagNamelist ::= tagNamelist COMMA ids */ -{taosArrayPush(yymsp[-2].minor.yy231, &yymsp[0].minor.yy0); yylhsminor.yy231 = yymsp[-2].minor.yy231; } - yymsp[-2].minor.yy231 = yylhsminor.yy231; +{taosArrayPush(yymsp[-2].minor.yy189, &yymsp[0].minor.yy0); yylhsminor.yy189 = yymsp[-2].minor.yy189; } + yymsp[-2].minor.yy189 = yylhsminor.yy189; break; case 149: /* tagNamelist ::= ids */ -{yylhsminor.yy231 = taosArrayInit(4, sizeof(SStrToken)); taosArrayPush(yylhsminor.yy231, &yymsp[0].minor.yy0);} - yymsp[0].minor.yy231 = yylhsminor.yy231; +{yylhsminor.yy189 = taosArrayInit(4, sizeof(SStrToken)); taosArrayPush(yylhsminor.yy189, &yymsp[0].minor.yy0);} + yymsp[0].minor.yy189 = yylhsminor.yy189; break; case 150: /* create_table_args ::= ifnotexists ids cpxName AS select */ { - yylhsminor.yy422 = tSetCreateTableInfo(NULL, NULL, yymsp[0].minor.yy86, TSQL_CREATE_STREAM); - setSqlInfo(pInfo, yylhsminor.yy422, NULL, TSDB_SQL_CREATE_TABLE); + yylhsminor.yy6 = tSetCreateTableInfo(NULL, NULL, yymsp[0].minor.yy16, TSQL_CREATE_STREAM); + setSqlInfo(pInfo, yylhsminor.yy6, NULL, TSDB_SQL_CREATE_TABLE); yymsp[-3].minor.yy0.n += yymsp[-2].minor.yy0.n; setCreatedTableName(pInfo, &yymsp[-3].minor.yy0, &yymsp[-4].minor.yy0); } - yymsp[-4].minor.yy422 = yylhsminor.yy422; + yymsp[-4].minor.yy6 = yylhsminor.yy6; break; case 151: /* columnlist ::= columnlist COMMA column */ -{taosArrayPush(yymsp[-2].minor.yy231, &yymsp[0].minor.yy103); yylhsminor.yy231 = yymsp[-2].minor.yy231; } - yymsp[-2].minor.yy231 = yylhsminor.yy231; +{taosArrayPush(yymsp[-2].minor.yy189, &yymsp[0].minor.yy279); yylhsminor.yy189 = yymsp[-2].minor.yy189; } + yymsp[-2].minor.yy189 = yylhsminor.yy189; break; case 152: /* columnlist ::= column */ -{yylhsminor.yy231 = taosArrayInit(4, sizeof(TAOS_FIELD)); taosArrayPush(yylhsminor.yy231, &yymsp[0].minor.yy103);} - yymsp[0].minor.yy231 = yylhsminor.yy231; +{yylhsminor.yy189 = taosArrayInit(4, sizeof(TAOS_FIELD)); taosArrayPush(yylhsminor.yy189, &yymsp[0].minor.yy279);} + yymsp[0].minor.yy189 = yylhsminor.yy189; break; case 153: /* column ::= ids typename */ { - tSetColumnInfo(&yylhsminor.yy103, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy103); + tSetColumnInfo(&yylhsminor.yy279, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy279); } - yymsp[-1].minor.yy103 = yylhsminor.yy103; + yymsp[-1].minor.yy279 = yylhsminor.yy279; break; case 160: /* tagitem ::= NULL */ -{ yymsp[0].minor.yy0.type = 0; tVariantCreate(&yylhsminor.yy176, &yymsp[0].minor.yy0, true); } - yymsp[0].minor.yy176 = yylhsminor.yy176; +{ yymsp[0].minor.yy0.type = 0; tVariantCreate(&yylhsminor.yy162, &yymsp[0].minor.yy0, true); } + yymsp[0].minor.yy162 = yylhsminor.yy162; break; case 161: /* tagitem ::= NOW */ -{ yymsp[0].minor.yy0.type = TSDB_DATA_TYPE_TIMESTAMP; tVariantCreate(&yylhsminor.yy176, &yymsp[0].minor.yy0, true);} - yymsp[0].minor.yy176 = yylhsminor.yy176; +{ yymsp[0].minor.yy0.type = TSDB_DATA_TYPE_TIMESTAMP; tVariantCreate(&yylhsminor.yy162, &yymsp[0].minor.yy0, true);} + yymsp[0].minor.yy162 = yylhsminor.yy162; break; case 162: /* tagitem ::= MINUS INTEGER */ case 163: /* tagitem ::= MINUS FLOAT */ yytestcase(yyruleno==163); @@ -3287,56 +3292,56 @@ static YYACTIONTYPE yy_reduce( yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n; yymsp[-1].minor.yy0.type = yymsp[0].minor.yy0.type; toTSDBType(yymsp[-1].minor.yy0.type); - tVariantCreate(&yylhsminor.yy176, &yymsp[-1].minor.yy0, true); + tVariantCreate(&yylhsminor.yy162, &yymsp[-1].minor.yy0, true); } - yymsp[-1].minor.yy176 = yylhsminor.yy176; + yymsp[-1].minor.yy162 = yylhsminor.yy162; break; case 166: /* select ::= SELECT selcollist from where_opt range_option interval_option sliding_opt session_option windowstate_option fill_opt groupby_opt having_opt orderby_opt slimit_opt limit_opt */ { - yylhsminor.yy86 = tSetQuerySqlNode(&yymsp[-14].minor.yy0, yymsp[-13].minor.yy231, yymsp[-12].minor.yy484, yymsp[-11].minor.yy226, yymsp[-4].minor.yy231, yymsp[-2].minor.yy231, &yymsp[-9].minor.yy430, &yymsp[-7].minor.yy409, &yymsp[-6].minor.yy228, &yymsp[-8].minor.yy0, yymsp[-5].minor.yy231, &yymsp[0].minor.yy444, &yymsp[-1].minor.yy444, yymsp[-3].minor.yy226, &yymsp[-10].minor.yy480); + yylhsminor.yy16 = tSetQuerySqlNode(&yymsp[-14].minor.yy0, yymsp[-13].minor.yy189, yymsp[-12].minor.yy36, yymsp[-11].minor.yy18, yymsp[-4].minor.yy189, yymsp[-2].minor.yy189, &yymsp[-9].minor.yy32, &yymsp[-7].minor.yy155, &yymsp[-6].minor.yy336, &yymsp[-8].minor.yy0, yymsp[-5].minor.yy189, &yymsp[0].minor.yy38, &yymsp[-1].minor.yy38, yymsp[-3].minor.yy18, &yymsp[-10].minor.yy124); } - yymsp[-14].minor.yy86 = yylhsminor.yy86; + yymsp[-14].minor.yy16 = yylhsminor.yy16; break; case 167: /* select ::= LP select RP */ -{yymsp[-2].minor.yy86 = yymsp[-1].minor.yy86;} +{yymsp[-2].minor.yy16 = yymsp[-1].minor.yy16;} break; case 168: /* union ::= select */ -{ yylhsminor.yy231 = setSubclause(NULL, yymsp[0].minor.yy86); } - yymsp[0].minor.yy231 = yylhsminor.yy231; +{ yylhsminor.yy189 = setSubclause(NULL, yymsp[0].minor.yy16); } + yymsp[0].minor.yy189 = yylhsminor.yy189; break; case 169: /* union ::= union UNION ALL select */ -{ yylhsminor.yy231 = appendSelectClause(yymsp[-3].minor.yy231, yymsp[0].minor.yy86); } - yymsp[-3].minor.yy231 = yylhsminor.yy231; +{ yylhsminor.yy189 = appendSelectClause(yymsp[-3].minor.yy189, yymsp[0].minor.yy16); } + yymsp[-3].minor.yy189 = yylhsminor.yy189; break; case 170: /* cmd ::= union */ -{ setSqlInfo(pInfo, yymsp[0].minor.yy231, NULL, TSDB_SQL_SELECT); } +{ setSqlInfo(pInfo, yymsp[0].minor.yy189, NULL, TSDB_SQL_SELECT); } break; case 171: /* select ::= SELECT selcollist */ { - yylhsminor.yy86 = tSetQuerySqlNode(&yymsp[-1].minor.yy0, yymsp[0].minor.yy231, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); + yylhsminor.yy16 = tSetQuerySqlNode(&yymsp[-1].minor.yy0, yymsp[0].minor.yy189, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); } - yymsp[-1].minor.yy86 = yylhsminor.yy86; + yymsp[-1].minor.yy16 = yylhsminor.yy16; break; case 172: /* sclp ::= selcollist COMMA */ -{yylhsminor.yy231 = yymsp[-1].minor.yy231;} - yymsp[-1].minor.yy231 = yylhsminor.yy231; +{yylhsminor.yy189 = yymsp[-1].minor.yy189;} + yymsp[-1].minor.yy189 = yylhsminor.yy189; break; case 173: /* sclp ::= */ case 214: /* orderby_opt ::= */ yytestcase(yyruleno==214); -{yymsp[1].minor.yy231 = 0;} +{yymsp[1].minor.yy189 = 0;} break; case 174: /* selcollist ::= sclp distinct expr as */ { - yylhsminor.yy231 = tSqlExprListAppend(yymsp[-3].minor.yy231, yymsp[-1].minor.yy226, yymsp[-2].minor.yy0.n? &yymsp[-2].minor.yy0:0, yymsp[0].minor.yy0.n?&yymsp[0].minor.yy0:0); + yylhsminor.yy189 = tSqlExprListAppend(yymsp[-3].minor.yy189, yymsp[-1].minor.yy18, yymsp[-2].minor.yy0.n? &yymsp[-2].minor.yy0:0, yymsp[0].minor.yy0.n?&yymsp[0].minor.yy0:0); } - yymsp[-3].minor.yy231 = yylhsminor.yy231; + yymsp[-3].minor.yy189 = yylhsminor.yy189; break; case 175: /* selcollist ::= sclp STAR */ { tSqlExpr *pNode = tSqlExprCreateIdValue(pInfo, NULL, TK_ALL); - yylhsminor.yy231 = tSqlExprListAppend(yymsp[-1].minor.yy231, pNode, 0, 0); + yylhsminor.yy189 = tSqlExprListAppend(yymsp[-1].minor.yy189, pNode, 0, 0); } - yymsp[-1].minor.yy231 = yylhsminor.yy231; + yymsp[-1].minor.yy189 = yylhsminor.yy189; break; case 176: /* as ::= AS ids */ { yymsp[-1].minor.yy0 = yymsp[0].minor.yy0; } @@ -3354,114 +3359,114 @@ static YYACTIONTYPE yy_reduce( break; case 181: /* from ::= FROM tablelist */ case 182: /* from ::= FROM sub */ yytestcase(yyruleno==182); -{yymsp[-1].minor.yy484 = yymsp[0].minor.yy484;} +{yymsp[-1].minor.yy36 = yymsp[0].minor.yy36;} break; case 183: /* sub ::= LP union RP */ -{yymsp[-2].minor.yy484 = addSubqueryElem(NULL, yymsp[-1].minor.yy231, NULL);} +{yymsp[-2].minor.yy36 = addSubqueryElem(NULL, yymsp[-1].minor.yy189, NULL);} break; case 184: /* sub ::= LP union RP ids */ -{yymsp[-3].minor.yy484 = addSubqueryElem(NULL, yymsp[-2].minor.yy231, &yymsp[0].minor.yy0);} +{yymsp[-3].minor.yy36 = addSubqueryElem(NULL, yymsp[-2].minor.yy189, &yymsp[0].minor.yy0);} break; case 185: /* sub ::= sub COMMA LP union RP ids */ -{yylhsminor.yy484 = addSubqueryElem(yymsp[-5].minor.yy484, yymsp[-2].minor.yy231, &yymsp[0].minor.yy0);} - yymsp[-5].minor.yy484 = yylhsminor.yy484; +{yylhsminor.yy36 = addSubqueryElem(yymsp[-5].minor.yy36, yymsp[-2].minor.yy189, &yymsp[0].minor.yy0);} + yymsp[-5].minor.yy36 = yylhsminor.yy36; break; case 186: /* tablelist ::= ids cpxName */ { yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n; - yylhsminor.yy484 = setTableNameList(NULL, &yymsp[-1].minor.yy0, NULL); + yylhsminor.yy36 = setTableNameList(NULL, &yymsp[-1].minor.yy0, NULL); } - yymsp[-1].minor.yy484 = yylhsminor.yy484; + yymsp[-1].minor.yy36 = yylhsminor.yy36; break; case 187: /* tablelist ::= ids cpxName ids */ { yymsp[-2].minor.yy0.n += yymsp[-1].minor.yy0.n; - yylhsminor.yy484 = setTableNameList(NULL, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0); + yylhsminor.yy36 = setTableNameList(NULL, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy484 = yylhsminor.yy484; + yymsp[-2].minor.yy36 = yylhsminor.yy36; break; case 188: /* tablelist ::= tablelist COMMA ids cpxName */ { yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n; - yylhsminor.yy484 = setTableNameList(yymsp[-3].minor.yy484, &yymsp[-1].minor.yy0, NULL); + yylhsminor.yy36 = setTableNameList(yymsp[-3].minor.yy36, &yymsp[-1].minor.yy0, NULL); } - yymsp[-3].minor.yy484 = yylhsminor.yy484; + yymsp[-3].minor.yy36 = yylhsminor.yy36; break; case 189: /* tablelist ::= tablelist COMMA ids cpxName ids */ { yymsp[-2].minor.yy0.n += yymsp[-1].minor.yy0.n; - yylhsminor.yy484 = setTableNameList(yymsp[-4].minor.yy484, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0); + yylhsminor.yy36 = setTableNameList(yymsp[-4].minor.yy36, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0); } - yymsp[-4].minor.yy484 = yylhsminor.yy484; + yymsp[-4].minor.yy36 = yylhsminor.yy36; break; case 190: /* tmvar ::= VARIABLE */ {yylhsminor.yy0 = yymsp[0].minor.yy0;} yymsp[0].minor.yy0 = yylhsminor.yy0; break; case 191: /* timestamp ::= INTEGER */ -{ yylhsminor.yy226 = tSqlExprCreateTimestamp(&yymsp[0].minor.yy0, TK_INTEGER);} - yymsp[0].minor.yy226 = yylhsminor.yy226; +{ yylhsminor.yy18 = tSqlExprCreateTimestamp(&yymsp[0].minor.yy0, TK_INTEGER);} + yymsp[0].minor.yy18 = yylhsminor.yy18; break; case 192: /* timestamp ::= MINUS INTEGER */ case 193: /* timestamp ::= PLUS INTEGER */ yytestcase(yyruleno==193); -{ yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n; yymsp[-1].minor.yy0.type = TK_INTEGER; yylhsminor.yy226 = tSqlExprCreateTimestamp(&yymsp[-1].minor.yy0, TK_INTEGER);} - yymsp[-1].minor.yy226 = yylhsminor.yy226; +{ yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n; yymsp[-1].minor.yy0.type = TK_INTEGER; yylhsminor.yy18 = tSqlExprCreateTimestamp(&yymsp[-1].minor.yy0, TK_INTEGER);} + yymsp[-1].minor.yy18 = yylhsminor.yy18; break; case 194: /* timestamp ::= STRING */ -{ yylhsminor.yy226 = tSqlExprCreateTimestamp(&yymsp[0].minor.yy0, TK_STRING);} - yymsp[0].minor.yy226 = yylhsminor.yy226; +{ yylhsminor.yy18 = tSqlExprCreateTimestamp(&yymsp[0].minor.yy0, TK_STRING);} + yymsp[0].minor.yy18 = yylhsminor.yy18; break; case 195: /* timestamp ::= NOW */ -{ yylhsminor.yy226 = tSqlExprCreateTimestamp(&yymsp[0].minor.yy0, TK_NOW); } - yymsp[0].minor.yy226 = yylhsminor.yy226; +{ yylhsminor.yy18 = tSqlExprCreateTimestamp(&yymsp[0].minor.yy0, TK_NOW); } + yymsp[0].minor.yy18 = yylhsminor.yy18; break; case 196: /* timestamp ::= NOW PLUS VARIABLE */ -{yymsp[-2].minor.yy226 = tSqlExprCreateTimestamp(&yymsp[0].minor.yy0, TK_PLUS); } +{yymsp[-2].minor.yy18 = tSqlExprCreateTimestamp(&yymsp[0].minor.yy0, TK_PLUS); } break; case 197: /* timestamp ::= NOW MINUS VARIABLE */ -{yymsp[-2].minor.yy226 = tSqlExprCreateTimestamp(&yymsp[0].minor.yy0, TK_MINUS); } +{yymsp[-2].minor.yy18 = tSqlExprCreateTimestamp(&yymsp[0].minor.yy0, TK_MINUS); } break; case 198: /* range_option ::= */ -{yymsp[1].minor.yy480.start = 0; yymsp[1].minor.yy480.end = 0;} +{yymsp[1].minor.yy124.start = 0; yymsp[1].minor.yy124.end = 0;} break; case 199: /* range_option ::= RANGE LP timestamp COMMA timestamp RP */ -{yymsp[-5].minor.yy480.start = yymsp[-3].minor.yy226; yymsp[-5].minor.yy480.end = yymsp[-1].minor.yy226;} +{yymsp[-5].minor.yy124.start = yymsp[-3].minor.yy18; yymsp[-5].minor.yy124.end = yymsp[-1].minor.yy18;} break; case 200: /* interval_option ::= intervalKey LP tmvar RP */ -{yylhsminor.yy430.interval = yymsp[-1].minor.yy0; yylhsminor.yy430.offset.n = 0; yylhsminor.yy430.token = yymsp[-3].minor.yy310;} - yymsp[-3].minor.yy430 = yylhsminor.yy430; +{yylhsminor.yy32.interval = yymsp[-1].minor.yy0; yylhsminor.yy32.offset.n = 0; yylhsminor.yy32.token = yymsp[-3].minor.yy516;} + yymsp[-3].minor.yy32 = yylhsminor.yy32; break; case 201: /* interval_option ::= intervalKey LP tmvar COMMA tmvar RP */ -{yylhsminor.yy430.interval = yymsp[-3].minor.yy0; yylhsminor.yy430.offset = yymsp[-1].minor.yy0; yylhsminor.yy430.token = yymsp[-5].minor.yy310;} - yymsp[-5].minor.yy430 = yylhsminor.yy430; +{yylhsminor.yy32.interval = yymsp[-3].minor.yy0; yylhsminor.yy32.offset = yymsp[-1].minor.yy0; yylhsminor.yy32.token = yymsp[-5].minor.yy516;} + yymsp[-5].minor.yy32 = yylhsminor.yy32; break; case 202: /* interval_option ::= */ -{memset(&yymsp[1].minor.yy430, 0, sizeof(yymsp[1].minor.yy430));} +{memset(&yymsp[1].minor.yy32, 0, sizeof(yymsp[1].minor.yy32));} break; case 203: /* intervalKey ::= INTERVAL */ -{yymsp[0].minor.yy310 = TK_INTERVAL;} +{yymsp[0].minor.yy516 = TK_INTERVAL;} break; case 204: /* intervalKey ::= EVERY */ -{yymsp[0].minor.yy310 = TK_EVERY; } +{yymsp[0].minor.yy516 = TK_EVERY; } break; case 205: /* session_option ::= */ -{yymsp[1].minor.yy409.col.n = 0; yymsp[1].minor.yy409.gap.n = 0;} +{yymsp[1].minor.yy155.col.n = 0; yymsp[1].minor.yy155.gap.n = 0;} break; case 206: /* session_option ::= SESSION LP ids cpxName COMMA tmvar RP */ { yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n; - yymsp[-6].minor.yy409.col = yymsp[-4].minor.yy0; - yymsp[-6].minor.yy409.gap = yymsp[-1].minor.yy0; + yymsp[-6].minor.yy155.col = yymsp[-4].minor.yy0; + yymsp[-6].minor.yy155.gap = yymsp[-1].minor.yy0; } break; case 207: /* windowstate_option ::= */ -{ yymsp[1].minor.yy228.col.n = 0; yymsp[1].minor.yy228.col.z = NULL;} +{ yymsp[1].minor.yy336.col.n = 0; yymsp[1].minor.yy336.col.z = NULL;} break; case 208: /* windowstate_option ::= STATE_WINDOW LP ids RP */ -{ yymsp[-3].minor.yy228.col = yymsp[-1].minor.yy0; } +{ yymsp[-3].minor.yy336.col = yymsp[-1].minor.yy0; } break; case 209: /* fill_opt ::= */ -{ yymsp[1].minor.yy231 = 0; } +{ yymsp[1].minor.yy189 = 0; } break; case 210: /* fill_opt ::= FILL LP ID COMMA tagitemlist RP */ { @@ -3469,14 +3474,14 @@ static YYACTIONTYPE yy_reduce( toTSDBType(yymsp[-3].minor.yy0.type); tVariantCreate(&A, &yymsp[-3].minor.yy0, true); - tVariantListInsert(yymsp[-1].minor.yy231, &A, -1, 0); - yymsp[-5].minor.yy231 = yymsp[-1].minor.yy231; + tVariantListInsert(yymsp[-1].minor.yy189, &A, -1, 0); + yymsp[-5].minor.yy189 = yymsp[-1].minor.yy189; } break; case 211: /* fill_opt ::= FILL LP ID RP */ { toTSDBType(yymsp[-1].minor.yy0.type); - yymsp[-3].minor.yy231 = tVariantListAppendToken(NULL, &yymsp[-1].minor.yy0, -1, true); + yymsp[-3].minor.yy189 = tVariantListAppendToken(NULL, &yymsp[-1].minor.yy0, -1, true); } break; case 212: /* sliding_opt ::= SLIDING LP tmvar RP */ @@ -3486,305 +3491,309 @@ static YYACTIONTYPE yy_reduce( {yymsp[1].minor.yy0.n = 0; yymsp[1].minor.yy0.z = NULL; yymsp[1].minor.yy0.type = 0; } break; case 215: /* orderby_opt ::= ORDER BY sortlist */ -{yymsp[-2].minor.yy231 = yymsp[0].minor.yy231;} +{yymsp[-2].minor.yy189 = yymsp[0].minor.yy189;} break; case 216: /* sortlist ::= sortlist COMMA item sortorder */ { - yylhsminor.yy231 = commonItemAppend(yymsp[-3].minor.yy231, &yymsp[-1].minor.yy176, NULL, false, yymsp[0].minor.yy502); + yylhsminor.yy189 = commonItemAppend(yymsp[-3].minor.yy189, &yymsp[-1].minor.yy162, NULL, false, yymsp[0].minor.yy420); } - yymsp[-3].minor.yy231 = yylhsminor.yy231; + yymsp[-3].minor.yy189 = yylhsminor.yy189; break; case 217: /* sortlist ::= sortlist COMMA arrow sortorder */ { - yylhsminor.yy231 = commonItemAppend(yymsp[-3].minor.yy231, NULL, yymsp[-1].minor.yy226, true, yymsp[0].minor.yy502); + yylhsminor.yy189 = commonItemAppend(yymsp[-3].minor.yy189, NULL, yymsp[-1].minor.yy18, true, yymsp[0].minor.yy420); } - yymsp[-3].minor.yy231 = yylhsminor.yy231; + yymsp[-3].minor.yy189 = yylhsminor.yy189; break; case 218: /* sortlist ::= item sortorder */ { - yylhsminor.yy231 = commonItemAppend(NULL, &yymsp[-1].minor.yy176, NULL, false, yymsp[0].minor.yy502); + yylhsminor.yy189 = commonItemAppend(NULL, &yymsp[-1].minor.yy162, NULL, false, yymsp[0].minor.yy420); } - yymsp[-1].minor.yy231 = yylhsminor.yy231; + yymsp[-1].minor.yy189 = yylhsminor.yy189; break; case 219: /* sortlist ::= arrow sortorder */ { - yylhsminor.yy231 = commonItemAppend(NULL, NULL, yymsp[-1].minor.yy226, true, yymsp[0].minor.yy502); + yylhsminor.yy189 = commonItemAppend(NULL, NULL, yymsp[-1].minor.yy18, true, yymsp[0].minor.yy420); } - yymsp[-1].minor.yy231 = yylhsminor.yy231; + yymsp[-1].minor.yy189 = yylhsminor.yy189; break; case 220: /* item ::= ID */ { toTSDBType(yymsp[0].minor.yy0.type); - tVariantCreate(&yylhsminor.yy176, &yymsp[0].minor.yy0, true); + tVariantCreate(&yylhsminor.yy162, &yymsp[0].minor.yy0, true); } - yymsp[0].minor.yy176 = yylhsminor.yy176; + yymsp[0].minor.yy162 = yylhsminor.yy162; break; case 221: /* item ::= ID DOT ID */ { toTSDBType(yymsp[-2].minor.yy0.type); yymsp[-2].minor.yy0.n += (1+yymsp[0].minor.yy0.n); - tVariantCreate(&yylhsminor.yy176, &yymsp[-2].minor.yy0, true); + tVariantCreate(&yylhsminor.yy162, &yymsp[-2].minor.yy0, true); } - yymsp[-2].minor.yy176 = yylhsminor.yy176; + yymsp[-2].minor.yy162 = yylhsminor.yy162; break; case 222: /* sortorder ::= ASC */ -{ yymsp[0].minor.yy502 = TSDB_ORDER_ASC; } +{ yymsp[0].minor.yy420 = TSDB_ORDER_ASC; } break; case 223: /* sortorder ::= DESC */ -{ yymsp[0].minor.yy502 = TSDB_ORDER_DESC;} +{ yymsp[0].minor.yy420 = TSDB_ORDER_DESC;} break; case 224: /* sortorder ::= */ -{ yymsp[1].minor.yy502 = TSDB_ORDER_ASC; } +{ yymsp[1].minor.yy420 = TSDB_ORDER_ASC; } break; case 225: /* groupby_opt ::= */ -{ yymsp[1].minor.yy231 = 0;} +{ yymsp[1].minor.yy189 = 0;} break; case 226: /* groupby_opt ::= GROUP BY grouplist */ -{ yymsp[-2].minor.yy231 = yymsp[0].minor.yy231;} +{ yymsp[-2].minor.yy189 = yymsp[0].minor.yy189;} break; case 227: /* grouplist ::= grouplist COMMA item */ { - yylhsminor.yy231 = commonItemAppend(yymsp[-2].minor.yy231, &yymsp[0].minor.yy176, NULL, false, -1); + yylhsminor.yy189 = commonItemAppend(yymsp[-2].minor.yy189, &yymsp[0].minor.yy162, NULL, false, -1); } - yymsp[-2].minor.yy231 = yylhsminor.yy231; + yymsp[-2].minor.yy189 = yylhsminor.yy189; break; case 228: /* grouplist ::= grouplist COMMA arrow */ { - yylhsminor.yy231 = commonItemAppend(yymsp[-2].minor.yy231, NULL, yymsp[0].minor.yy226, true, -1); + yylhsminor.yy189 = commonItemAppend(yymsp[-2].minor.yy189, NULL, yymsp[0].minor.yy18, true, -1); } - yymsp[-2].minor.yy231 = yylhsminor.yy231; + yymsp[-2].minor.yy189 = yylhsminor.yy189; break; case 229: /* grouplist ::= item */ { - yylhsminor.yy231 = commonItemAppend(NULL, &yymsp[0].minor.yy176, NULL, false, -1); + yylhsminor.yy189 = commonItemAppend(NULL, &yymsp[0].minor.yy162, NULL, false, -1); } - yymsp[0].minor.yy231 = yylhsminor.yy231; + yymsp[0].minor.yy189 = yylhsminor.yy189; break; case 230: /* grouplist ::= arrow */ { - yylhsminor.yy231 = commonItemAppend(NULL, NULL, yymsp[0].minor.yy226, true, -1); + yylhsminor.yy189 = commonItemAppend(NULL, NULL, yymsp[0].minor.yy18, true, -1); } - yymsp[0].minor.yy231 = yylhsminor.yy231; + yymsp[0].minor.yy189 = yylhsminor.yy189; break; case 231: /* having_opt ::= */ case 241: /* where_opt ::= */ yytestcase(yyruleno==241); - case 290: /* expritem ::= */ yytestcase(yyruleno==290); -{yymsp[1].minor.yy226 = 0;} + case 291: /* expritem ::= */ yytestcase(yyruleno==291); +{yymsp[1].minor.yy18 = 0;} break; case 232: /* having_opt ::= HAVING expr */ case 242: /* where_opt ::= WHERE expr */ yytestcase(yyruleno==242); -{yymsp[-1].minor.yy226 = yymsp[0].minor.yy226;} +{yymsp[-1].minor.yy18 = yymsp[0].minor.yy18;} break; case 233: /* limit_opt ::= */ case 237: /* slimit_opt ::= */ yytestcase(yyruleno==237); -{yymsp[1].minor.yy444.limit = -1; yymsp[1].minor.yy444.offset = 0;} +{yymsp[1].minor.yy38.limit = -1; yymsp[1].minor.yy38.offset = 0;} break; case 234: /* limit_opt ::= LIMIT signed */ case 238: /* slimit_opt ::= SLIMIT signed */ yytestcase(yyruleno==238); -{yymsp[-1].minor.yy444.limit = yymsp[0].minor.yy549; yymsp[-1].minor.yy444.offset = 0;} +{yymsp[-1].minor.yy38.limit = yymsp[0].minor.yy69; yymsp[-1].minor.yy38.offset = 0;} break; case 235: /* limit_opt ::= LIMIT signed OFFSET signed */ -{ yymsp[-3].minor.yy444.limit = yymsp[-2].minor.yy549; yymsp[-3].minor.yy444.offset = yymsp[0].minor.yy549;} +{ yymsp[-3].minor.yy38.limit = yymsp[-2].minor.yy69; yymsp[-3].minor.yy38.offset = yymsp[0].minor.yy69;} break; case 236: /* limit_opt ::= LIMIT signed COMMA signed */ -{ yymsp[-3].minor.yy444.limit = yymsp[0].minor.yy549; yymsp[-3].minor.yy444.offset = yymsp[-2].minor.yy549;} +{ yymsp[-3].minor.yy38.limit = yymsp[0].minor.yy69; yymsp[-3].minor.yy38.offset = yymsp[-2].minor.yy69;} break; case 239: /* slimit_opt ::= SLIMIT signed SOFFSET signed */ -{yymsp[-3].minor.yy444.limit = yymsp[-2].minor.yy549; yymsp[-3].minor.yy444.offset = yymsp[0].minor.yy549;} +{yymsp[-3].minor.yy38.limit = yymsp[-2].minor.yy69; yymsp[-3].minor.yy38.offset = yymsp[0].minor.yy69;} break; case 240: /* slimit_opt ::= SLIMIT signed COMMA signed */ -{yymsp[-3].minor.yy444.limit = yymsp[0].minor.yy549; yymsp[-3].minor.yy444.offset = yymsp[-2].minor.yy549;} +{yymsp[-3].minor.yy38.limit = yymsp[0].minor.yy69; yymsp[-3].minor.yy38.offset = yymsp[-2].minor.yy69;} break; case 243: /* expr ::= LP expr RP */ -{yylhsminor.yy226 = yymsp[-1].minor.yy226; yylhsminor.yy226->exprToken.z = yymsp[-2].minor.yy0.z; yylhsminor.yy226->exprToken.n = (yymsp[0].minor.yy0.z - yymsp[-2].minor.yy0.z + 1);} - yymsp[-2].minor.yy226 = yylhsminor.yy226; +{yylhsminor.yy18 = yymsp[-1].minor.yy18; yylhsminor.yy18->exprToken.z = yymsp[-2].minor.yy0.z; yylhsminor.yy18->exprToken.n = (yymsp[0].minor.yy0.z - yymsp[-2].minor.yy0.z + 1);} + yymsp[-2].minor.yy18 = yylhsminor.yy18; break; case 244: /* expr ::= ID */ -{ yylhsminor.yy226 = tSqlExprCreateIdValue(pInfo, &yymsp[0].minor.yy0, TK_ID);} - yymsp[0].minor.yy226 = yylhsminor.yy226; +{ yylhsminor.yy18 = tSqlExprCreateIdValue(pInfo, &yymsp[0].minor.yy0, TK_ID);} + yymsp[0].minor.yy18 = yylhsminor.yy18; break; case 245: /* expr ::= ID DOT ID */ -{ yymsp[-2].minor.yy0.n += (1+yymsp[0].minor.yy0.n); yylhsminor.yy226 = tSqlExprCreateIdValue(pInfo, &yymsp[-2].minor.yy0, TK_ID);} - yymsp[-2].minor.yy226 = yylhsminor.yy226; +{ yymsp[-2].minor.yy0.n += (1+yymsp[0].minor.yy0.n); yylhsminor.yy18 = tSqlExprCreateIdValue(pInfo, &yymsp[-2].minor.yy0, TK_ID);} + yymsp[-2].minor.yy18 = yylhsminor.yy18; break; case 246: /* expr ::= ID DOT STAR */ -{ yymsp[-2].minor.yy0.n += (1+yymsp[0].minor.yy0.n); yylhsminor.yy226 = tSqlExprCreateIdValue(pInfo, &yymsp[-2].minor.yy0, TK_ALL);} - yymsp[-2].minor.yy226 = yylhsminor.yy226; +{ yymsp[-2].minor.yy0.n += (1+yymsp[0].minor.yy0.n); yylhsminor.yy18 = tSqlExprCreateIdValue(pInfo, &yymsp[-2].minor.yy0, TK_ALL);} + yymsp[-2].minor.yy18 = yylhsminor.yy18; break; case 247: /* expr ::= INTEGER */ -{ yylhsminor.yy226 = tSqlExprCreateIdValue(pInfo, &yymsp[0].minor.yy0, TK_INTEGER);} - yymsp[0].minor.yy226 = yylhsminor.yy226; +{ yylhsminor.yy18 = tSqlExprCreateIdValue(pInfo, &yymsp[0].minor.yy0, TK_INTEGER);} + yymsp[0].minor.yy18 = yylhsminor.yy18; break; case 248: /* expr ::= MINUS INTEGER */ case 249: /* expr ::= PLUS INTEGER */ yytestcase(yyruleno==249); -{ yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n; yymsp[-1].minor.yy0.type = TK_INTEGER; yylhsminor.yy226 = tSqlExprCreateIdValue(pInfo, &yymsp[-1].minor.yy0, TK_INTEGER);} - yymsp[-1].minor.yy226 = yylhsminor.yy226; +{ yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n; yymsp[-1].minor.yy0.type = TK_INTEGER; yylhsminor.yy18 = tSqlExprCreateIdValue(pInfo, &yymsp[-1].minor.yy0, TK_INTEGER);} + yymsp[-1].minor.yy18 = yylhsminor.yy18; break; case 250: /* expr ::= FLOAT */ -{ yylhsminor.yy226 = tSqlExprCreateIdValue(pInfo, &yymsp[0].minor.yy0, TK_FLOAT);} - yymsp[0].minor.yy226 = yylhsminor.yy226; +{ yylhsminor.yy18 = tSqlExprCreateIdValue(pInfo, &yymsp[0].minor.yy0, TK_FLOAT);} + yymsp[0].minor.yy18 = yylhsminor.yy18; break; case 251: /* expr ::= MINUS FLOAT */ case 252: /* expr ::= PLUS FLOAT */ yytestcase(yyruleno==252); -{ yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n; yymsp[-1].minor.yy0.type = TK_FLOAT; yylhsminor.yy226 = tSqlExprCreateIdValue(pInfo, &yymsp[-1].minor.yy0, TK_FLOAT);} - yymsp[-1].minor.yy226 = yylhsminor.yy226; +{ yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n; yymsp[-1].minor.yy0.type = TK_FLOAT; yylhsminor.yy18 = tSqlExprCreateIdValue(pInfo, &yymsp[-1].minor.yy0, TK_FLOAT);} + yymsp[-1].minor.yy18 = yylhsminor.yy18; break; case 253: /* expr ::= STRING */ -{ yylhsminor.yy226 = tSqlExprCreateIdValue(pInfo, &yymsp[0].minor.yy0, TK_STRING);} - yymsp[0].minor.yy226 = yylhsminor.yy226; +{ yylhsminor.yy18 = tSqlExprCreateIdValue(pInfo, &yymsp[0].minor.yy0, TK_STRING);} + yymsp[0].minor.yy18 = yylhsminor.yy18; break; case 254: /* expr ::= NOW */ -{ yylhsminor.yy226 = tSqlExprCreateIdValue(pInfo, &yymsp[0].minor.yy0, TK_NOW); } - yymsp[0].minor.yy226 = yylhsminor.yy226; +{ yylhsminor.yy18 = tSqlExprCreateIdValue(pInfo, &yymsp[0].minor.yy0, TK_NOW); } + yymsp[0].minor.yy18 = yylhsminor.yy18; break; case 255: /* expr ::= VARIABLE */ -{ yylhsminor.yy226 = tSqlExprCreateIdValue(pInfo, &yymsp[0].minor.yy0, TK_VARIABLE);} - yymsp[0].minor.yy226 = yylhsminor.yy226; +{ yylhsminor.yy18 = tSqlExprCreateIdValue(pInfo, &yymsp[0].minor.yy0, TK_VARIABLE);} + yymsp[0].minor.yy18 = yylhsminor.yy18; break; case 256: /* expr ::= PLUS VARIABLE */ case 257: /* expr ::= MINUS VARIABLE */ yytestcase(yyruleno==257); -{ yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n; yymsp[-1].minor.yy0.type = TK_VARIABLE; yylhsminor.yy226 = tSqlExprCreateIdValue(pInfo, &yymsp[-1].minor.yy0, TK_VARIABLE);} - yymsp[-1].minor.yy226 = yylhsminor.yy226; +{ yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n; yymsp[-1].minor.yy0.type = TK_VARIABLE; yylhsminor.yy18 = tSqlExprCreateIdValue(pInfo, &yymsp[-1].minor.yy0, TK_VARIABLE);} + yymsp[-1].minor.yy18 = yylhsminor.yy18; break; case 258: /* expr ::= BOOL */ -{ yylhsminor.yy226 = tSqlExprCreateIdValue(pInfo, &yymsp[0].minor.yy0, TK_BOOL);} - yymsp[0].minor.yy226 = yylhsminor.yy226; +{ yylhsminor.yy18 = tSqlExprCreateIdValue(pInfo, &yymsp[0].minor.yy0, TK_BOOL);} + yymsp[0].minor.yy18 = yylhsminor.yy18; break; case 259: /* expr ::= NULL */ -{ yylhsminor.yy226 = tSqlExprCreateIdValue(pInfo, &yymsp[0].minor.yy0, TK_NULL);} - yymsp[0].minor.yy226 = yylhsminor.yy226; +{ yylhsminor.yy18 = tSqlExprCreateIdValue(pInfo, &yymsp[0].minor.yy0, TK_NULL);} + yymsp[0].minor.yy18 = yylhsminor.yy18; break; case 260: /* expr ::= ID LP exprlist RP */ -{ tStrTokenAppend(pInfo->funcs, &yymsp[-3].minor.yy0); yylhsminor.yy226 = tSqlExprCreateFunction(yymsp[-1].minor.yy231, &yymsp[-3].minor.yy0, &yymsp[0].minor.yy0, yymsp[-3].minor.yy0.type); } - yymsp[-3].minor.yy226 = yylhsminor.yy226; +{ tStrTokenAppend(pInfo->funcs, &yymsp[-3].minor.yy0); yylhsminor.yy18 = tSqlExprCreateFunction(yymsp[-1].minor.yy189, &yymsp[-3].minor.yy0, &yymsp[0].minor.yy0, yymsp[-3].minor.yy0.type); } + yymsp[-3].minor.yy18 = yylhsminor.yy18; break; case 261: /* expr ::= ID LP STAR RP */ -{ tStrTokenAppend(pInfo->funcs, &yymsp[-3].minor.yy0); yylhsminor.yy226 = tSqlExprCreateFunction(NULL, &yymsp[-3].minor.yy0, &yymsp[0].minor.yy0, yymsp[-3].minor.yy0.type); } - yymsp[-3].minor.yy226 = yylhsminor.yy226; +{ tStrTokenAppend(pInfo->funcs, &yymsp[-3].minor.yy0); yylhsminor.yy18 = tSqlExprCreateFunction(NULL, &yymsp[-3].minor.yy0, &yymsp[0].minor.yy0, yymsp[-3].minor.yy0.type); } + yymsp[-3].minor.yy18 = yylhsminor.yy18; break; - case 262: /* expr ::= expr IS NULL */ -{yylhsminor.yy226 = tSqlExprCreate(yymsp[-2].minor.yy226, NULL, TK_ISNULL);} - yymsp[-2].minor.yy226 = yylhsminor.yy226; + case 262: /* expr ::= ID LP expr AS typename RP */ +{ tStrTokenAppend(pInfo->funcs, &yymsp[-5].minor.yy0); yylhsminor.yy18 = tSqlExprCreateFuncWithParams(pInfo, yymsp[-3].minor.yy18, &yymsp[-1].minor.yy279, &yymsp[-5].minor.yy0, &yymsp[0].minor.yy0, yymsp[-5].minor.yy0.type); } + yymsp[-5].minor.yy18 = yylhsminor.yy18; break; - case 263: /* expr ::= expr IS NOT NULL */ -{yylhsminor.yy226 = tSqlExprCreate(yymsp[-3].minor.yy226, NULL, TK_NOTNULL);} - yymsp[-3].minor.yy226 = yylhsminor.yy226; + case 263: /* expr ::= expr IS NULL */ +{yylhsminor.yy18 = tSqlExprCreate(yymsp[-2].minor.yy18, NULL, TK_ISNULL);} + yymsp[-2].minor.yy18 = yylhsminor.yy18; break; - case 264: /* expr ::= expr LT expr */ -{yylhsminor.yy226 = tSqlExprCreate(yymsp[-2].minor.yy226, yymsp[0].minor.yy226, TK_LT);} - yymsp[-2].minor.yy226 = yylhsminor.yy226; + case 264: /* expr ::= expr IS NOT NULL */ +{yylhsminor.yy18 = tSqlExprCreate(yymsp[-3].minor.yy18, NULL, TK_NOTNULL);} + yymsp[-3].minor.yy18 = yylhsminor.yy18; break; - case 265: /* expr ::= expr GT expr */ -{yylhsminor.yy226 = tSqlExprCreate(yymsp[-2].minor.yy226, yymsp[0].minor.yy226, TK_GT);} - yymsp[-2].minor.yy226 = yylhsminor.yy226; + case 265: /* expr ::= expr LT expr */ +{yylhsminor.yy18 = tSqlExprCreate(yymsp[-2].minor.yy18, yymsp[0].minor.yy18, TK_LT);} + yymsp[-2].minor.yy18 = yylhsminor.yy18; break; - case 266: /* expr ::= expr LE expr */ -{yylhsminor.yy226 = tSqlExprCreate(yymsp[-2].minor.yy226, yymsp[0].minor.yy226, TK_LE);} - yymsp[-2].minor.yy226 = yylhsminor.yy226; + case 266: /* expr ::= expr GT expr */ +{yylhsminor.yy18 = tSqlExprCreate(yymsp[-2].minor.yy18, yymsp[0].minor.yy18, TK_GT);} + yymsp[-2].minor.yy18 = yylhsminor.yy18; break; - case 267: /* expr ::= expr GE expr */ -{yylhsminor.yy226 = tSqlExprCreate(yymsp[-2].minor.yy226, yymsp[0].minor.yy226, TK_GE);} - yymsp[-2].minor.yy226 = yylhsminor.yy226; + case 267: /* expr ::= expr LE expr */ +{yylhsminor.yy18 = tSqlExprCreate(yymsp[-2].minor.yy18, yymsp[0].minor.yy18, TK_LE);} + yymsp[-2].minor.yy18 = yylhsminor.yy18; break; - case 268: /* expr ::= expr NE expr */ -{yylhsminor.yy226 = tSqlExprCreate(yymsp[-2].minor.yy226, yymsp[0].minor.yy226, TK_NE);} - yymsp[-2].minor.yy226 = yylhsminor.yy226; + case 268: /* expr ::= expr GE expr */ +{yylhsminor.yy18 = tSqlExprCreate(yymsp[-2].minor.yy18, yymsp[0].minor.yy18, TK_GE);} + yymsp[-2].minor.yy18 = yylhsminor.yy18; break; - case 269: /* expr ::= expr EQ expr */ -{yylhsminor.yy226 = tSqlExprCreate(yymsp[-2].minor.yy226, yymsp[0].minor.yy226, TK_EQ);} - yymsp[-2].minor.yy226 = yylhsminor.yy226; + case 269: /* expr ::= expr NE expr */ +{yylhsminor.yy18 = tSqlExprCreate(yymsp[-2].minor.yy18, yymsp[0].minor.yy18, TK_NE);} + yymsp[-2].minor.yy18 = yylhsminor.yy18; break; - case 270: /* expr ::= expr BETWEEN expr AND expr */ -{ tSqlExpr* X2 = tSqlExprClone(yymsp[-4].minor.yy226); yylhsminor.yy226 = tSqlExprCreate(tSqlExprCreate(yymsp[-4].minor.yy226, yymsp[-2].minor.yy226, TK_GE), tSqlExprCreate(X2, yymsp[0].minor.yy226, TK_LE), TK_AND);} - yymsp[-4].minor.yy226 = yylhsminor.yy226; + case 270: /* expr ::= expr EQ expr */ +{yylhsminor.yy18 = tSqlExprCreate(yymsp[-2].minor.yy18, yymsp[0].minor.yy18, TK_EQ);} + yymsp[-2].minor.yy18 = yylhsminor.yy18; break; - case 271: /* expr ::= expr AND expr */ -{yylhsminor.yy226 = tSqlExprCreate(yymsp[-2].minor.yy226, yymsp[0].minor.yy226, TK_AND);} - yymsp[-2].minor.yy226 = yylhsminor.yy226; + case 271: /* expr ::= expr BETWEEN expr AND expr */ +{ tSqlExpr* X2 = tSqlExprClone(yymsp[-4].minor.yy18); yylhsminor.yy18 = tSqlExprCreate(tSqlExprCreate(yymsp[-4].minor.yy18, yymsp[-2].minor.yy18, TK_GE), tSqlExprCreate(X2, yymsp[0].minor.yy18, TK_LE), TK_AND);} + yymsp[-4].minor.yy18 = yylhsminor.yy18; break; - case 272: /* expr ::= expr OR expr */ -{yylhsminor.yy226 = tSqlExprCreate(yymsp[-2].minor.yy226, yymsp[0].minor.yy226, TK_OR); } - yymsp[-2].minor.yy226 = yylhsminor.yy226; + case 272: /* expr ::= expr AND expr */ +{yylhsminor.yy18 = tSqlExprCreate(yymsp[-2].minor.yy18, yymsp[0].minor.yy18, TK_AND);} + yymsp[-2].minor.yy18 = yylhsminor.yy18; break; - case 273: /* expr ::= expr PLUS expr */ -{yylhsminor.yy226 = tSqlExprCreate(yymsp[-2].minor.yy226, yymsp[0].minor.yy226, TK_PLUS); } - yymsp[-2].minor.yy226 = yylhsminor.yy226; + case 273: /* expr ::= expr OR expr */ +{yylhsminor.yy18 = tSqlExprCreate(yymsp[-2].minor.yy18, yymsp[0].minor.yy18, TK_OR); } + yymsp[-2].minor.yy18 = yylhsminor.yy18; break; - case 274: /* expr ::= expr MINUS expr */ -{yylhsminor.yy226 = tSqlExprCreate(yymsp[-2].minor.yy226, yymsp[0].minor.yy226, TK_MINUS); } - yymsp[-2].minor.yy226 = yylhsminor.yy226; + case 274: /* expr ::= expr PLUS expr */ +{yylhsminor.yy18 = tSqlExprCreate(yymsp[-2].minor.yy18, yymsp[0].minor.yy18, TK_PLUS); } + yymsp[-2].minor.yy18 = yylhsminor.yy18; break; - case 275: /* expr ::= expr STAR expr */ -{yylhsminor.yy226 = tSqlExprCreate(yymsp[-2].minor.yy226, yymsp[0].minor.yy226, TK_STAR); } - yymsp[-2].minor.yy226 = yylhsminor.yy226; + case 275: /* expr ::= expr MINUS expr */ +{yylhsminor.yy18 = tSqlExprCreate(yymsp[-2].minor.yy18, yymsp[0].minor.yy18, TK_MINUS); } + yymsp[-2].minor.yy18 = yylhsminor.yy18; break; - case 276: /* expr ::= expr SLASH expr */ -{yylhsminor.yy226 = tSqlExprCreate(yymsp[-2].minor.yy226, yymsp[0].minor.yy226, TK_DIVIDE);} - yymsp[-2].minor.yy226 = yylhsminor.yy226; + case 276: /* expr ::= expr STAR expr */ +{yylhsminor.yy18 = tSqlExprCreate(yymsp[-2].minor.yy18, yymsp[0].minor.yy18, TK_STAR); } + yymsp[-2].minor.yy18 = yylhsminor.yy18; break; - case 277: /* expr ::= expr REM expr */ -{yylhsminor.yy226 = tSqlExprCreate(yymsp[-2].minor.yy226, yymsp[0].minor.yy226, TK_REM); } - yymsp[-2].minor.yy226 = yylhsminor.yy226; + case 277: /* expr ::= expr SLASH expr */ +{yylhsminor.yy18 = tSqlExprCreate(yymsp[-2].minor.yy18, yymsp[0].minor.yy18, TK_DIVIDE);} + yymsp[-2].minor.yy18 = yylhsminor.yy18; break; - case 278: /* expr ::= expr LIKE expr */ -{yylhsminor.yy226 = tSqlExprCreate(yymsp[-2].minor.yy226, yymsp[0].minor.yy226, TK_LIKE); } - yymsp[-2].minor.yy226 = yylhsminor.yy226; + case 278: /* expr ::= expr REM expr */ +{yylhsminor.yy18 = tSqlExprCreate(yymsp[-2].minor.yy18, yymsp[0].minor.yy18, TK_REM); } + yymsp[-2].minor.yy18 = yylhsminor.yy18; break; - case 279: /* expr ::= expr MATCH expr */ -{yylhsminor.yy226 = tSqlExprCreate(yymsp[-2].minor.yy226, yymsp[0].minor.yy226, TK_MATCH); } - yymsp[-2].minor.yy226 = yylhsminor.yy226; + case 279: /* expr ::= expr LIKE expr */ +{yylhsminor.yy18 = tSqlExprCreate(yymsp[-2].minor.yy18, yymsp[0].minor.yy18, TK_LIKE); } + yymsp[-2].minor.yy18 = yylhsminor.yy18; break; - case 280: /* expr ::= expr NMATCH expr */ -{yylhsminor.yy226 = tSqlExprCreate(yymsp[-2].minor.yy226, yymsp[0].minor.yy226, TK_NMATCH); } - yymsp[-2].minor.yy226 = yylhsminor.yy226; + case 280: /* expr ::= expr MATCH expr */ +{yylhsminor.yy18 = tSqlExprCreate(yymsp[-2].minor.yy18, yymsp[0].minor.yy18, TK_MATCH); } + yymsp[-2].minor.yy18 = yylhsminor.yy18; break; - case 281: /* expr ::= ID CONTAINS STRING */ -{ tSqlExpr* S = tSqlExprCreateIdValue(pInfo, &yymsp[-2].minor.yy0, TK_ID); tSqlExpr* M = tSqlExprCreateIdValue(pInfo, &yymsp[0].minor.yy0, TK_STRING); yylhsminor.yy226 = tSqlExprCreate(S, M, TK_CONTAINS); } - yymsp[-2].minor.yy226 = yylhsminor.yy226; + case 281: /* expr ::= expr NMATCH expr */ +{yylhsminor.yy18 = tSqlExprCreate(yymsp[-2].minor.yy18, yymsp[0].minor.yy18, TK_NMATCH); } + yymsp[-2].minor.yy18 = yylhsminor.yy18; break; - case 282: /* expr ::= ID DOT ID CONTAINS STRING */ -{ yymsp[-4].minor.yy0.n += (1+yymsp[-2].minor.yy0.n); tSqlExpr* S = tSqlExprCreateIdValue(pInfo, &yymsp[-4].minor.yy0, TK_ID); tSqlExpr* M = tSqlExprCreateIdValue(pInfo, &yymsp[0].minor.yy0, TK_STRING); yylhsminor.yy226 = tSqlExprCreate(S, M, TK_CONTAINS); } - yymsp[-4].minor.yy226 = yylhsminor.yy226; + case 282: /* expr ::= ID CONTAINS STRING */ +{ tSqlExpr* S = tSqlExprCreateIdValue(pInfo, &yymsp[-2].minor.yy0, TK_ID); tSqlExpr* M = tSqlExprCreateIdValue(pInfo, &yymsp[0].minor.yy0, TK_STRING); yylhsminor.yy18 = tSqlExprCreate(S, M, TK_CONTAINS); } + yymsp[-2].minor.yy18 = yylhsminor.yy18; break; - case 283: /* arrow ::= ID ARROW STRING */ -{tSqlExpr* S = tSqlExprCreateIdValue(pInfo, &yymsp[-2].minor.yy0, TK_ID); tSqlExpr* M = tSqlExprCreateIdValue(pInfo, &yymsp[0].minor.yy0, TK_STRING); yylhsminor.yy226 = tSqlExprCreate(S, M, TK_ARROW); } - yymsp[-2].minor.yy226 = yylhsminor.yy226; + case 283: /* expr ::= ID DOT ID CONTAINS STRING */ +{ yymsp[-4].minor.yy0.n += (1+yymsp[-2].minor.yy0.n); tSqlExpr* S = tSqlExprCreateIdValue(pInfo, &yymsp[-4].minor.yy0, TK_ID); tSqlExpr* M = tSqlExprCreateIdValue(pInfo, &yymsp[0].minor.yy0, TK_STRING); yylhsminor.yy18 = tSqlExprCreate(S, M, TK_CONTAINS); } + yymsp[-4].minor.yy18 = yylhsminor.yy18; break; - case 284: /* arrow ::= ID DOT ID ARROW STRING */ -{yymsp[-4].minor.yy0.n += (1+yymsp[-2].minor.yy0.n); tSqlExpr* S = tSqlExprCreateIdValue(pInfo, &yymsp[-4].minor.yy0, TK_ID); tSqlExpr* M = tSqlExprCreateIdValue(pInfo, &yymsp[0].minor.yy0, TK_STRING); yylhsminor.yy226 = tSqlExprCreate(S, M, TK_ARROW); } - yymsp[-4].minor.yy226 = yylhsminor.yy226; + case 284: /* arrow ::= ID ARROW STRING */ +{tSqlExpr* S = tSqlExprCreateIdValue(pInfo, &yymsp[-2].minor.yy0, TK_ID); tSqlExpr* M = tSqlExprCreateIdValue(pInfo, &yymsp[0].minor.yy0, TK_STRING); yylhsminor.yy18 = tSqlExprCreate(S, M, TK_ARROW); } + yymsp[-2].minor.yy18 = yylhsminor.yy18; break; - case 285: /* expr ::= arrow */ - case 289: /* expritem ::= expr */ yytestcase(yyruleno==289); -{yylhsminor.yy226 = yymsp[0].minor.yy226;} - yymsp[0].minor.yy226 = yylhsminor.yy226; + case 285: /* arrow ::= ID DOT ID ARROW STRING */ +{yymsp[-4].minor.yy0.n += (1+yymsp[-2].minor.yy0.n); tSqlExpr* S = tSqlExprCreateIdValue(pInfo, &yymsp[-4].minor.yy0, TK_ID); tSqlExpr* M = tSqlExprCreateIdValue(pInfo, &yymsp[0].minor.yy0, TK_STRING); yylhsminor.yy18 = tSqlExprCreate(S, M, TK_ARROW); } + yymsp[-4].minor.yy18 = yylhsminor.yy18; break; - case 286: /* expr ::= expr IN LP exprlist RP */ -{yylhsminor.yy226 = tSqlExprCreate(yymsp[-4].minor.yy226, (tSqlExpr*)yymsp[-1].minor.yy231, TK_IN); } - yymsp[-4].minor.yy226 = yylhsminor.yy226; + case 286: /* expr ::= arrow */ + case 290: /* expritem ::= expr */ yytestcase(yyruleno==290); +{yylhsminor.yy18 = yymsp[0].minor.yy18;} + yymsp[0].minor.yy18 = yylhsminor.yy18; break; - case 287: /* exprlist ::= exprlist COMMA expritem */ -{yylhsminor.yy231 = tSqlExprListAppend(yymsp[-2].minor.yy231,yymsp[0].minor.yy226,0, 0);} - yymsp[-2].minor.yy231 = yylhsminor.yy231; + case 287: /* expr ::= expr IN LP exprlist RP */ +{yylhsminor.yy18 = tSqlExprCreate(yymsp[-4].minor.yy18, (tSqlExpr*)yymsp[-1].minor.yy189, TK_IN); } + yymsp[-4].minor.yy18 = yylhsminor.yy18; break; - case 288: /* exprlist ::= expritem */ -{yylhsminor.yy231 = tSqlExprListAppend(0,yymsp[0].minor.yy226,0, 0);} - yymsp[0].minor.yy231 = yylhsminor.yy231; + case 288: /* exprlist ::= exprlist COMMA expritem */ +{yylhsminor.yy189 = tSqlExprListAppend(yymsp[-2].minor.yy189,yymsp[0].minor.yy18,0, 0);} + yymsp[-2].minor.yy189 = yylhsminor.yy189; break; - case 291: /* cmd ::= RESET QUERY CACHE */ + case 289: /* exprlist ::= expritem */ +{yylhsminor.yy189 = tSqlExprListAppend(0,yymsp[0].minor.yy18,0, 0);} + yymsp[0].minor.yy189 = yylhsminor.yy189; + break; + case 292: /* cmd ::= RESET QUERY CACHE */ { setDCLSqlElems(pInfo, TSDB_SQL_RESET_CACHE, 0);} break; - case 292: /* cmd ::= SYNCDB ids REPLICA */ + case 293: /* cmd ::= SYNCDB ids REPLICA */ { setDCLSqlElems(pInfo, TSDB_SQL_SYNC_DB_REPLICA, 1, &yymsp[-1].minor.yy0);} break; - case 293: /* cmd ::= ALTER TABLE ids cpxName ADD COLUMN columnlist */ + case 294: /* cmd ::= ALTER TABLE ids cpxName ADD COLUMN columnlist */ { yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n; - SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-4].minor.yy0, yymsp[0].minor.yy231, NULL, TSDB_ALTER_TABLE_ADD_COLUMN, -1); + SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-4].minor.yy0, yymsp[0].minor.yy189, NULL, TSDB_ALTER_TABLE_ADD_COLUMN, -1); setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } break; - case 294: /* cmd ::= ALTER TABLE ids cpxName DROP COLUMN ids */ + case 295: /* cmd ::= ALTER TABLE ids cpxName DROP COLUMN ids */ { yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n; @@ -3795,21 +3804,21 @@ static YYACTIONTYPE yy_reduce( setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } break; - case 295: /* cmd ::= ALTER TABLE ids cpxName MODIFY COLUMN columnlist */ + case 296: /* cmd ::= ALTER TABLE ids cpxName MODIFY COLUMN columnlist */ { yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n; - SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-4].minor.yy0, yymsp[0].minor.yy231, NULL, TSDB_ALTER_TABLE_CHANGE_COLUMN, -1); + SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-4].minor.yy0, yymsp[0].minor.yy189, NULL, TSDB_ALTER_TABLE_CHANGE_COLUMN, -1); setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } break; - case 296: /* cmd ::= ALTER TABLE ids cpxName ADD TAG columnlist */ + case 297: /* cmd ::= ALTER TABLE ids cpxName ADD TAG columnlist */ { yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n; - SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-4].minor.yy0, yymsp[0].minor.yy231, NULL, TSDB_ALTER_TABLE_ADD_TAG_COLUMN, -1); + SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-4].minor.yy0, yymsp[0].minor.yy189, NULL, TSDB_ALTER_TABLE_ADD_TAG_COLUMN, -1); setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } break; - case 297: /* cmd ::= ALTER TABLE ids cpxName DROP TAG ids */ + case 298: /* cmd ::= ALTER TABLE ids cpxName DROP TAG ids */ { yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n; @@ -3820,7 +3829,7 @@ static YYACTIONTYPE yy_reduce( setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } break; - case 298: /* cmd ::= ALTER TABLE ids cpxName CHANGE TAG ids ids */ + case 299: /* cmd ::= ALTER TABLE ids cpxName CHANGE TAG ids ids */ { yymsp[-5].minor.yy0.n += yymsp[-4].minor.yy0.n; @@ -3834,33 +3843,33 @@ static YYACTIONTYPE yy_reduce( setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } break; - case 299: /* cmd ::= ALTER TABLE ids cpxName SET TAG ids EQ tagitem */ + case 300: /* cmd ::= ALTER TABLE ids cpxName SET TAG ids EQ tagitem */ { yymsp[-6].minor.yy0.n += yymsp[-5].minor.yy0.n; toTSDBType(yymsp[-2].minor.yy0.type); SArray* A = tVariantListAppendToken(NULL, &yymsp[-2].minor.yy0, -1, true); - A = tVariantListAppend(A, &yymsp[0].minor.yy176, -1); + A = tVariantListAppend(A, &yymsp[0].minor.yy162, -1); SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-6].minor.yy0, NULL, A, TSDB_ALTER_TABLE_UPDATE_TAG_VAL, -1); setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } break; - case 300: /* cmd ::= ALTER TABLE ids cpxName MODIFY TAG columnlist */ + case 301: /* cmd ::= ALTER TABLE ids cpxName MODIFY TAG columnlist */ { yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n; - SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-4].minor.yy0, yymsp[0].minor.yy231, NULL, TSDB_ALTER_TABLE_MODIFY_TAG_COLUMN, -1); + SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-4].minor.yy0, yymsp[0].minor.yy189, NULL, TSDB_ALTER_TABLE_MODIFY_TAG_COLUMN, -1); setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } break; - case 301: /* cmd ::= ALTER STABLE ids cpxName ADD COLUMN columnlist */ + case 302: /* cmd ::= ALTER STABLE ids cpxName ADD COLUMN columnlist */ { yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n; - SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-4].minor.yy0, yymsp[0].minor.yy231, NULL, TSDB_ALTER_TABLE_ADD_COLUMN, TSDB_SUPER_TABLE); + SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-4].minor.yy0, yymsp[0].minor.yy189, NULL, TSDB_ALTER_TABLE_ADD_COLUMN, TSDB_SUPER_TABLE); setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } break; - case 302: /* cmd ::= ALTER STABLE ids cpxName DROP COLUMN ids */ + case 303: /* cmd ::= ALTER STABLE ids cpxName DROP COLUMN ids */ { yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n; @@ -3871,21 +3880,21 @@ static YYACTIONTYPE yy_reduce( setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } break; - case 303: /* cmd ::= ALTER STABLE ids cpxName MODIFY COLUMN columnlist */ + case 304: /* cmd ::= ALTER STABLE ids cpxName MODIFY COLUMN columnlist */ { yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n; - SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-4].minor.yy0, yymsp[0].minor.yy231, NULL, TSDB_ALTER_TABLE_CHANGE_COLUMN, TSDB_SUPER_TABLE); + SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-4].minor.yy0, yymsp[0].minor.yy189, NULL, TSDB_ALTER_TABLE_CHANGE_COLUMN, TSDB_SUPER_TABLE); setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } break; - case 304: /* cmd ::= ALTER STABLE ids cpxName ADD TAG columnlist */ + case 305: /* cmd ::= ALTER STABLE ids cpxName ADD TAG columnlist */ { yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n; - SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-4].minor.yy0, yymsp[0].minor.yy231, NULL, TSDB_ALTER_TABLE_ADD_TAG_COLUMN, TSDB_SUPER_TABLE); + SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-4].minor.yy0, yymsp[0].minor.yy189, NULL, TSDB_ALTER_TABLE_ADD_TAG_COLUMN, TSDB_SUPER_TABLE); setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } break; - case 305: /* cmd ::= ALTER STABLE ids cpxName DROP TAG ids */ + case 306: /* cmd ::= ALTER STABLE ids cpxName DROP TAG ids */ { yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n; @@ -3896,7 +3905,7 @@ static YYACTIONTYPE yy_reduce( setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } break; - case 306: /* cmd ::= ALTER STABLE ids cpxName CHANGE TAG ids ids */ + case 307: /* cmd ::= ALTER STABLE ids cpxName CHANGE TAG ids ids */ { yymsp[-5].minor.yy0.n += yymsp[-4].minor.yy0.n; @@ -3910,32 +3919,32 @@ static YYACTIONTYPE yy_reduce( setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } break; - case 307: /* cmd ::= ALTER STABLE ids cpxName SET TAG ids EQ tagitem */ + case 308: /* cmd ::= ALTER STABLE ids cpxName SET TAG ids EQ tagitem */ { yymsp[-6].minor.yy0.n += yymsp[-5].minor.yy0.n; toTSDBType(yymsp[-2].minor.yy0.type); SArray* A = tVariantListAppendToken(NULL, &yymsp[-2].minor.yy0, -1, true); - A = tVariantListAppend(A, &yymsp[0].minor.yy176, -1); + A = tVariantListAppend(A, &yymsp[0].minor.yy162, -1); SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-6].minor.yy0, NULL, A, TSDB_ALTER_TABLE_UPDATE_TAG_VAL, TSDB_SUPER_TABLE); setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } break; - case 308: /* cmd ::= ALTER STABLE ids cpxName MODIFY TAG columnlist */ + case 309: /* cmd ::= ALTER STABLE ids cpxName MODIFY TAG columnlist */ { yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n; - SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-4].minor.yy0, yymsp[0].minor.yy231, NULL, TSDB_ALTER_TABLE_MODIFY_TAG_COLUMN, TSDB_SUPER_TABLE); + SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-4].minor.yy0, yymsp[0].minor.yy189, NULL, TSDB_ALTER_TABLE_MODIFY_TAG_COLUMN, TSDB_SUPER_TABLE); setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } break; - case 309: /* cmd ::= KILL CONNECTION INTEGER */ + case 310: /* cmd ::= KILL CONNECTION INTEGER */ {setKillSql(pInfo, TSDB_SQL_KILL_CONNECTION, &yymsp[0].minor.yy0);} break; - case 310: /* cmd ::= KILL STREAM INTEGER COLON INTEGER */ + case 311: /* cmd ::= KILL STREAM INTEGER COLON INTEGER */ {yymsp[-2].minor.yy0.n += (yymsp[-1].minor.yy0.n + yymsp[0].minor.yy0.n); setKillSql(pInfo, TSDB_SQL_KILL_STREAM, &yymsp[-2].minor.yy0);} break; - case 311: /* cmd ::= KILL QUERY INTEGER COLON INTEGER */ + case 312: /* cmd ::= KILL QUERY INTEGER COLON INTEGER */ {yymsp[-2].minor.yy0.n += (yymsp[-1].minor.yy0.n + yymsp[0].minor.yy0.n); setKillSql(pInfo, TSDB_SQL_KILL_QUERY, &yymsp[-2].minor.yy0);} break; default: @@ -4211,13 +4220,14 @@ void Parse( yy_destructor(yypParser, (YYCODETYPE)yymajor, &yyminorunion); yymajor = YYNOCODE; }else{ - while( yypParser->yytos > yypParser->yystack ){ - yyact = yy_find_reduce_action(yypParser->yytos->stateno, - YYERRORSYMBOL); - if( yyact<=YY_MAX_SHIFTREDUCE ) break; + while( yypParser->yytos >= yypParser->yystack + && (yyact = yy_find_reduce_action( + yypParser->yytos->stateno, + YYERRORSYMBOL)) > YY_MAX_SHIFTREDUCE + ){ yy_pop_parser_stack(yypParser); } - if( yypParser->yytos <= yypParser->yystack || yymajor==0 ){ + if( yypParser->yytos < yypParser->yystack || yymajor==0 ){ yy_destructor(yypParser,(YYCODETYPE)yymajor,&yyminorunion); yy_parse_failed(yypParser); #ifndef YYNOERRORRECOVERY diff --git a/src/util/src/tnettest.c b/src/util/src/tnettest.c index 2a147ee4f17a38e9a00a6110fcc6f2d21fb7b131..8dc2d4c993e001c95f63d72c60db8b8fe3ac3df8 100644 --- a/src/util/src/tnettest.c +++ b/src/util/src/tnettest.c @@ -568,6 +568,12 @@ static void taosNetCheckSpeed(char *host, int32_t port, int32_t pkgLen, int32_t compressTmp = tsCompressMsgSize; int32_t maxUdpSize = tsRpcMaxUdpSize; int32_t forceTcp = tsRpcForceTcp; + + //Precheck for FQDN lgenth + if (strlen(host) >= TSDB_FQDN_LEN) { + uError("FQDN length is too long"); + return; + } if (0 == strcmp("tcp", pkgType)){ tsRpcForceTcp = 1; diff --git a/src/util/src/ttokenizer.c b/src/util/src/ttokenizer.c index 5e3aa82ef4740d60f362807a086d50cfdb4aa491..5876d82bea9f0373b5086b2ce285f7ad86002536 100644 --- a/src/util/src/ttokenizer.c +++ b/src/util/src/ttokenizer.c @@ -73,7 +73,6 @@ static SKeyword keywordTable[] = { {"STAR", TK_STAR}, {"SLASH", TK_SLASH}, {"REM ", TK_REM}, - {"CONCAT", TK_CONCAT}, {"UMINUS", TK_UMINUS}, {"UPLUS", TK_UPLUS}, {"BITNOT", TK_BITNOT}, @@ -400,9 +399,6 @@ uint32_t tGetToken(char* z, uint32_t* tokenId) { if (z[1] != '|') { *tokenId = TK_BITOR; return 1; - } else { - *tokenId = TK_CONCAT; - return 2; } } case ',': { diff --git a/tests/pytest/functions/function_ceil.py b/tests/pytest/functions/function_ceil.py index 08769c7f7aeff422f955f18efa525b5250be0761..cb3408c3774c09c41b637c0ddff2600e56d8aea9 100644 --- a/tests/pytest/functions/function_ceil.py +++ b/tests/pytest/functions/function_ceil.py @@ -1322,21 +1322,21 @@ class TDTestCase: double_col double, binary_col binary(8), smallint_col smallint, tinyint_col tinyint, bool_col bool, nchar_col nchar(8), \ uint_col int unsigned, ubigint_col bigint unsigned, usmallint_col smallint unsigned, utinyint_col tinyint unsigned) tags (int_tag int, bigint_tag bigint, \ float_tag float, double_tag double, binary_tag binary(8), smallint_tag smallint, tinyint_tag tinyint, bool_tag bool, nchar_tag nchar(8),\ - uint_tag int unsigned, ubigint_tag bigint unsigned, usmallint_tag smallint unsigned, utinyint_tag tinyint unsigned)" + uint_tag int unsigned, ubigint_tag bigint unsigned, usmallint_tag smallint unsigned, utinyint_tag tinyint unsigned, timestamp_tag timestamp)" ) tdSql.execute( "create stable superb (ts timestamp, timestamp_col timestamp, int_col int, bigint_col bigint, float_col float,\ double_col double, binary_col binary(8), smallint_col smallint, tinyint_col tinyint, bool_col bool, nchar_col nchar(8), \ uint_col int unsigned, ubigint_col bigint unsigned, usmallint_col smallint unsigned, utinyint_col tinyint unsigned) tags (int_tag int, bigint_tag bigint, \ float_tag float, double_tag double, binary_tag binary(8), smallint_tag smallint, tinyint_tag tinyint, bool_tag bool, nchar_tag nchar(8),\ - uint_tag int unsigned, ubigint_tag bigint unsigned, usmallint_tag smallint unsigned, utinyint_tag tinyint unsigned)" + uint_tag int unsigned, ubigint_tag bigint unsigned, usmallint_tag smallint unsigned, utinyint_tag tinyint unsigned, timestamp_tag timestamp)" ) tdSql.execute( - "create table t1 using super tags (1, %d, %f, %f, '%s', %d, %d, 1, '%s', %d, %d, %d, %d)" + "create table t1 using super tags (1, %d, %f, %f, '%s', %d, %d, 1, '%s', %d, %d, %d, %d, %s)" % (self.randomBigint(), self.randomDouble(), self.randomDouble(), self.randomNchar(), self.randomSmallint(), self.randomTinyint(), self.randomNchar(), self.randomUInt(), self.randomUBigint(), - self.randomUSmallint(), self.randomUTinyint())) + self.randomUSmallint(), self.randomUTinyint(), 'now')) tdSql.execute( "insert into t1 values (1629796215891, 1629796215891, %d, %d, %f, %f, '%s', %d, %d, 1, '%s', %d, %d, %d, %d)" % (self.randomInt(), self.randomBigint(), self.randomDouble(), @@ -1366,11 +1366,11 @@ class TDTestCase: self.randomUBigint(), self.randomUSmallint(), self.randomUTinyint())) tdSql.execute( - "create table t2 using superb tags (1, %d, %f, %f, '%s', %d, %d, 1, '%s', %d, %d, %d, %d)" + "create table t2 using superb tags (1, %d, %f, %f, '%s', %d, %d, 1, '%s', %d, %d, %d, %d, %s)" % (self.randomBigint(), self.randomDouble(), self.randomDouble(), self.randomNchar(), self.randomSmallint(), self.randomTinyint(), self.randomNchar(), self.randomUInt(), self.randomUBigint(), - self.randomUSmallint(), self.randomUTinyint())) + self.randomUSmallint(), self.randomUTinyint(), 'now')) tdSql.execute( "insert into t2 values (1629796215891, 1629796215891, %d, %d, %f, %f, '%s', %d, %d, 1, '%s', %d, %d, %d, %d)" % (self.randomInt(), self.randomBigint(), self.randomDouble(), @@ -1400,139 +1400,572 @@ class TDTestCase: self.randomUBigint(), self.randomUSmallint(), self.randomUTinyint())) + shouldPass = ['select ceil(int_col) from super', + 'select ceil(int_col) from t1', + 'select ceil(bigint_col) from super', + 'select ceil(bigint_col) from t1', + 'select ceil(float_col) from super', + 'select ceil(float_col) from t1', + 'select ceil(double_col) from super', + 'select ceil(double_col) from t1', + 'select ceil(smallint_col) from super', + 'select ceil(smallint_col) from t1', + 'select ceil(tinyint_col) from super', + 'select ceil(tinyint_col) from t1', + 'select ceil(uint_col) from super', + 'select ceil(uint_col) from t1', + 'select ceil(ubigint_col) from super', + 'select ceil(ubigint_col) from t1', + 'select ceil(usmallint_col) from super', + 'select ceil(usmallint_col) from t1', + 'select ceil(utinyint_col) from super', + 'select ceil(utinyint_col) from t1', + 'select ceil(int_col) - ceil(int_col) from super', + 'select ceil(int_col) - ceil(int_col) from t1', + 'select ceil(bigint_col) - ceil(bigint_col) from super', + 'select ceil(bigint_col) - ceil(bigint_col) from t1', + 'select ceil(float_col) - ceil(float_col) from super', + 'select ceil(float_col) - ceil(float_col) from t1', + 'select ceil(double_col) - ceil(double_col) from super', + 'select ceil(double_col) - ceil(double_col) from t1', + 'select ceil(smallint_col) - ceil(smallint_col) from super', + 'select ceil(smallint_col) - ceil(smallint_col) from t1', + 'select ceil(tinyint_col) - ceil(tinyint_col) from super', + 'select ceil(tinyint_col) - ceil(tinyint_col) from t1', + 'select ceil(uint_col) - ceil(uint_col) from super', + 'select ceil(uint_col) - ceil(uint_col) from t1', + 'select ceil(ubigint_col) - ceil(ubigint_col) from super', + 'select ceil(ubigint_col) - ceil(ubigint_col) from t1', + 'select ceil(usmallint_col) - ceil(usmallint_col) from super', + 'select ceil(usmallint_col) - ceil(usmallint_col) from t1', + 'select ceil(utinyint_col) - ceil(utinyint_col) from super', + 'select ceil(utinyint_col) - ceil(utinyint_col) from t1', + 'select ceil(int_col) / ceil(int_col) from super', + 'select ceil(int_col) / ceil(int_col) from t1', + 'select ceil(bigint_col) / ceil(bigint_col) from super', + 'select ceil(bigint_col) / ceil(bigint_col) from t1', + 'select ceil(float_col) / ceil(float_col) from super', + 'select ceil(float_col) / ceil(float_col) from t1', + 'select ceil(double_col) / ceil(double_col) from super', + 'select ceil(double_col) / ceil(double_col) from t1', + 'select ceil(smallint_col) / ceil(smallint_col) from super', + 'select ceil(smallint_col) / ceil(smallint_col) from t1', + 'select ceil(tinyint_col) / ceil(tinyint_col) from super', + 'select ceil(tinyint_col) / ceil(tinyint_col) from t1', + 'select ceil(uint_col) / ceil(uint_col) from super', + 'select ceil(uint_col) / ceil(uint_col) from t1', + 'select ceil(ubigint_col) / ceil(ubigint_col) from super', + 'select ceil(ubigint_col) / ceil(ubigint_col) from t1', + 'select ceil(usmallint_col) / ceil(usmallint_col) from super', + 'select ceil(usmallint_col) / ceil(usmallint_col) from t1', + 'select ceil(utinyint_col) / ceil(utinyint_col) from super', + 'select ceil(utinyint_col) / ceil(utinyint_col) from t1', + 'select ceil(int_col) * ceil(int_col) from super', + 'select ceil(int_col) * ceil(int_col) from t1', + 'select ceil(bigint_col) * ceil(bigint_col) from super', + 'select ceil(bigint_col) * ceil(bigint_col) from t1', + 'select ceil(float_col) * ceil(float_col) from super', + 'select ceil(float_col) * ceil(float_col) from t1', + 'select ceil(double_col) * ceil(double_col) from super', + 'select ceil(double_col) * ceil(double_col) from t1', + 'select ceil(smallint_col) * ceil(smallint_col) from super', + 'select ceil(smallint_col) * ceil(smallint_col) from t1', + 'select ceil(tinyint_col) * ceil(tinyint_col) from super', + 'select ceil(tinyint_col) * ceil(tinyint_col) from t1', + 'select ceil(uint_col) * ceil(uint_col) from super', + 'select ceil(uint_col) * ceil(uint_col) from t1', + 'select ceil(ubigint_col) * ceil(ubigint_col) from super', + 'select ceil(ubigint_col) * ceil(ubigint_col) from t1', + 'select ceil(usmallint_col) * ceil(usmallint_col) from super', + 'select ceil(usmallint_col) * ceil(usmallint_col) from t1', + 'select ceil(utinyint_col) * ceil(utinyint_col) from super', + 'select ceil(utinyint_col) * ceil(utinyint_col) from t1', + 'select ceil(count(ts)) from super', + 'select ceil(count(ts)) from t1', + 'select ceil(count(timestamp_col)) from super', + 'select ceil(count(timestamp_col)) from t1', + 'select ceil(count(int_col)) from super', + 'select ceil(count(int_col)) from t1', + 'select ceil(count(bigint_col)) from super', + 'select ceil(count(bigint_col)) from t1', + 'select ceil(count(float_col)) from super', + 'select ceil(count(float_col)) from t1', + 'select ceil(count(double_col)) from super', + 'select ceil(count(double_col)) from t1', + 'select ceil(count(binary_col)) from super', + 'select ceil(count(binary_col)) from t1', + 'select ceil(count(smallint_col)) from super', + 'select ceil(count(smallint_col)) from t1', + 'select ceil(count(tinyint_col)) from super', + 'select ceil(count(tinyint_col)) from t1', + 'select ceil(count(bool_col)) from super', + 'select ceil(count(bool_col)) from t1', + 'select ceil(count(nchar_col)) from super', + 'select ceil(count(nchar_col)) from t1', + 'select ceil(count(uint_col)) from super', + 'select ceil(count(uint_col)) from t1', + 'select ceil(count(ubigint_col)) from super', + 'select ceil(count(ubigint_col)) from t1', + 'select ceil(count(usmallint_col)) from super', + 'select ceil(count(usmallint_col)) from t1', + 'select ceil(count(utinyint_col)) from super', + 'select ceil(count(utinyint_col)) from t1', + 'select ceil(count(timestamp_tag)) from super', + 'select ceil(count(timestamp_tag)) from t1', + 'select ceil(count(int_tag)) from super', + 'select ceil(count(int_tag)) from t1', + 'select ceil(count(bigint_tag)) from super', + 'select ceil(count(bigint_tag)) from t1', + 'select ceil(count(float_tag)) from super', + 'select ceil(count(float_tag)) from t1', + 'select ceil(count(double_tag)) from super', + 'select ceil(count(double_tag)) from t1', + 'select ceil(count(binary_tag)) from super', + 'select ceil(count(binary_tag)) from t1', + 'select ceil(count(smallint_tag)) from super', + 'select ceil(count(smallint_tag)) from t1', + 'select ceil(count(tinyint_tag)) from super', + 'select ceil(count(tinyint_tag)) from t1', + 'select ceil(count(bool_tag)) from super', + 'select ceil(count(bool_tag)) from t1', + 'select ceil(count(nchar_tag)) from super', + 'select ceil(count(nchar_tag)) from t1', + 'select ceil(count(uint_tag)) from super', + 'select ceil(count(uint_tag)) from t1', + 'select ceil(count(ubigint_tag)) from super', + 'select ceil(count(ubigint_tag)) from t1', + 'select ceil(count(usmallint_tag)) from super', + 'select ceil(count(usmallint_tag)) from t1', + 'select ceil(count(utinyint_tag)) from super', + 'select ceil(count(utinyint_tag)) from t1', + 'select ceil(avg(int_col)) from super', + 'select ceil(avg(int_col)) from t1', + 'select ceil(avg(bigint_col)) from super', + 'select ceil(avg(bigint_col)) from t1', + 'select ceil(avg(float_col)) from super', + 'select ceil(avg(float_col)) from t1', + 'select ceil(avg(double_col)) from super', + 'select ceil(avg(double_col)) from t1', + 'select ceil(avg(smallint_col)) from super', + 'select ceil(avg(smallint_col)) from t1', + 'select ceil(avg(tinyint_col)) from super', + 'select ceil(avg(tinyint_col)) from t1', + 'select ceil(avg(uint_col)) from super', + 'select ceil(avg(uint_col)) from t1', + 'select ceil(avg(ubigint_col)) from super', + 'select ceil(avg(ubigint_col)) from t1', + 'select ceil(avg(usmallint_col)) from super', + 'select ceil(avg(usmallint_col)) from t1', + 'select ceil(avg(utinyint_col)) from super', + 'select ceil(avg(utinyint_col)) from t1', + 'select ceil(twa(int_col)) from t1', + 'select ceil(twa(bigint_col)) from t1', + 'select ceil(twa(float_col)) from t1', + 'select ceil(twa(double_col)) from t1', + 'select ceil(twa(smallint_col)) from t1', + 'select ceil(twa(tinyint_col)) from t1', + 'select ceil(twa(uint_col)) from t1', + 'select ceil(twa(ubigint_col)) from t1', + 'select ceil(twa(usmallint_col)) from t1', + 'select ceil(twa(utinyint_col)) from t1', + 'select ceil(sum(int_col)) from super', + 'select ceil(sum(int_col)) from t1', + 'select ceil(sum(bigint_col)) from super', + 'select ceil(sum(bigint_col)) from t1', + 'select ceil(sum(float_col)) from super', + 'select ceil(sum(float_col)) from t1', + 'select ceil(sum(double_col)) from super', + 'select ceil(sum(double_col)) from t1', + 'select ceil(sum(smallint_col)) from super', + 'select ceil(sum(smallint_col)) from t1', + 'select ceil(sum(tinyint_col)) from super', + 'select ceil(sum(tinyint_col)) from t1', + 'select ceil(sum(uint_col)) from super', + 'select ceil(sum(uint_col)) from t1', + 'select ceil(sum(ubigint_col)) from super', + 'select ceil(sum(ubigint_col)) from t1', + 'select ceil(sum(usmallint_col)) from super', + 'select ceil(sum(usmallint_col)) from t1', + 'select ceil(sum(utinyint_col)) from super', + 'select ceil(sum(utinyint_col)) from t1', + 'select ceil(stddev(int_col)) from super', + 'select ceil(stddev(int_col)) from t1', + 'select ceil(stddev(bigint_col)) from super', + 'select ceil(stddev(bigint_col)) from t1', + 'select ceil(stddev(float_col)) from super', + 'select ceil(stddev(float_col)) from t1', + 'select ceil(stddev(double_col)) from super', + 'select ceil(stddev(double_col)) from t1', + 'select ceil(stddev(smallint_col)) from super', + 'select ceil(stddev(smallint_col)) from t1', + 'select ceil(stddev(tinyint_col)) from super', + 'select ceil(stddev(tinyint_col)) from t1', + 'select ceil(stddev(uint_col)) from super', + 'select ceil(stddev(uint_col)) from t1', + 'select ceil(stddev(ubigint_col)) from super', + 'select ceil(stddev(ubigint_col)) from t1', + 'select ceil(stddev(usmallint_col)) from super', + 'select ceil(stddev(usmallint_col)) from t1', + 'select ceil(stddev(utinyint_col)) from super', + 'select ceil(stddev(utinyint_col)) from t1', + 'select ceil(irate(int_col)) from t1', + 'select ceil(irate(bigint_col)) from t1', + 'select ceil(irate(float_col)) from t1', + 'select ceil(irate(double_col)) from t1', + 'select ceil(irate(smallint_col)) from t1', + 'select ceil(irate(tinyint_col)) from t1', + 'select ceil(irate(uint_col)) from t1', + 'select ceil(irate(ubigint_col)) from t1', + 'select ceil(irate(usmallint_col)) from t1', + 'select ceil(irate(utinyint_col)) from t1', + 'select ceil(min(int_col)) from super', + 'select ceil(min(int_col)) from t1', + 'select ceil(min(bigint_col)) from super', + 'select ceil(min(bigint_col)) from t1', + 'select ceil(min(float_col)) from super', + 'select ceil(min(float_col)) from t1', + 'select ceil(min(double_col)) from super', + 'select ceil(min(double_col)) from t1', + 'select ceil(min(smallint_col)) from super', + 'select ceil(min(smallint_col)) from t1', + 'select ceil(min(tinyint_col)) from super', + 'select ceil(min(tinyint_col)) from t1', + 'select ceil(min(uint_col)) from super', + 'select ceil(min(uint_col)) from t1', + 'select ceil(min(ubigint_col)) from super', + 'select ceil(min(ubigint_col)) from t1', + 'select ceil(min(usmallint_col)) from super', + 'select ceil(min(usmallint_col)) from t1', + 'select ceil(min(utinyint_col)) from super', + 'select ceil(min(utinyint_col)) from t1', + 'select ceil(max(int_col)) from super', + 'select ceil(max(int_col)) from t1', + 'select ceil(max(bigint_col)) from super', + 'select ceil(max(bigint_col)) from t1', + 'select ceil(max(float_col)) from super', + 'select ceil(max(float_col)) from t1', + 'select ceil(max(double_col)) from super', + 'select ceil(max(double_col)) from t1', + 'select ceil(max(smallint_col)) from super', + 'select ceil(max(smallint_col)) from t1', + 'select ceil(max(tinyint_col)) from super', + 'select ceil(max(tinyint_col)) from t1', + 'select ceil(max(uint_col)) from super', + 'select ceil(max(uint_col)) from t1', + 'select ceil(max(ubigint_col)) from super', + 'select ceil(max(ubigint_col)) from t1', + 'select ceil(max(usmallint_col)) from super', + 'select ceil(max(usmallint_col)) from t1', + 'select ceil(max(utinyint_col)) from super', + 'select ceil(max(utinyint_col)) from t1', + 'select ceil(first(int_col)) from super', + 'select ceil(first(int_col)) from t1', + 'select ceil(first(bigint_col)) from super', + 'select ceil(first(bigint_col)) from t1', + 'select ceil(first(float_col)) from super', + 'select ceil(first(float_col)) from t1', + 'select ceil(first(double_col)) from super', + 'select ceil(first(double_col)) from t1', + 'select ceil(first(smallint_col)) from super', + 'select ceil(first(smallint_col)) from t1', + 'select ceil(first(tinyint_col)) from super', + 'select ceil(first(tinyint_col)) from t1', + 'select ceil(first(uint_col)) from super', + 'select ceil(first(uint_col)) from t1', + 'select ceil(first(ubigint_col)) from super', + 'select ceil(first(ubigint_col)) from t1', + 'select ceil(first(usmallint_col)) from super', + 'select ceil(first(usmallint_col)) from t1', + 'select ceil(first(utinyint_col)) from super', + 'select ceil(first(utinyint_col)) from t1', + 'select ceil(last(int_col)) from super', + 'select ceil(last(int_col)) from t1', + 'select ceil(last(bigint_col)) from super', + 'select ceil(last(bigint_col)) from t1', + 'select ceil(last(float_col)) from super', + 'select ceil(last(float_col)) from t1', + 'select ceil(last(double_col)) from super', + 'select ceil(last(double_col)) from t1', + 'select ceil(last(smallint_col)) from super', + 'select ceil(last(smallint_col)) from t1', + 'select ceil(last(tinyint_col)) from super', + 'select ceil(last(tinyint_col)) from t1', + 'select ceil(last(uint_col)) from super', + 'select ceil(last(uint_col)) from t1', + 'select ceil(last(ubigint_col)) from super', + 'select ceil(last(ubigint_col)) from t1', + 'select ceil(last(usmallint_col)) from super', + 'select ceil(last(usmallint_col)) from t1', + 'select ceil(last(utinyint_col)) from super', + 'select ceil(last(utinyint_col)) from t1', + 'select ceil(percentile(int_col, 1)) from t1', + 'select ceil(percentile(bigint_col, 1)) from t1', + 'select ceil(percentile(float_col, 1)) from t1', + 'select ceil(percentile(double_col, 1)) from t1', + 'select ceil(percentile(smallint_col, 1)) from t1', + 'select ceil(percentile(tinyint_col, 1)) from t1', + 'select ceil(percentile(uint_col, 1)) from t1', + 'select ceil(percentile(ubigint_col, 1)) from t1', + 'select ceil(percentile(usmallint_col, 1)) from t1', + 'select ceil(percentile(utinyint_col, 1)) from t1', + 'select ceil(apercentile(int_col, 1)) from super', + 'select ceil(apercentile(int_col, 1)) from t1', + 'select ceil(apercentile(bigint_col, 1)) from super', + 'select ceil(apercentile(bigint_col, 1)) from t1', + 'select ceil(apercentile(float_col, 1)) from super', + 'select ceil(apercentile(float_col, 1)) from t1', + 'select ceil(apercentile(double_col, 1)) from super', + 'select ceil(apercentile(double_col, 1)) from t1', + 'select ceil(apercentile(smallint_col, 1)) from super', + 'select ceil(apercentile(smallint_col, 1)) from t1', + 'select ceil(apercentile(tinyint_col, 1)) from super', + 'select ceil(apercentile(tinyint_col, 1)) from t1', + 'select ceil(apercentile(uint_col, 1)) from super', + 'select ceil(apercentile(uint_col, 1)) from t1', + 'select ceil(apercentile(ubigint_col, 1)) from super', + 'select ceil(apercentile(ubigint_col, 1)) from t1', + 'select ceil(apercentile(usmallint_col, 1)) from super', + 'select ceil(apercentile(usmallint_col, 1)) from t1', + 'select ceil(apercentile(utinyint_col, 1)) from super', + 'select ceil(apercentile(utinyint_col, 1)) from t1', + 'select ceil(last_row(int_col)) from super', + 'select ceil(last_row(int_col)) from t1', + 'select ceil(last_row(bigint_col)) from super', + 'select ceil(last_row(bigint_col)) from t1', + 'select ceil(last_row(float_col)) from super', + 'select ceil(last_row(float_col)) from t1', + 'select ceil(last_row(double_col)) from super', + 'select ceil(last_row(double_col)) from t1', + 'select ceil(last_row(smallint_col)) from super', + 'select ceil(last_row(smallint_col)) from t1', + 'select ceil(last_row(tinyint_col)) from super', + 'select ceil(last_row(tinyint_col)) from t1', + 'select ceil(last_row(uint_col)) from super', + 'select ceil(last_row(uint_col)) from t1', + 'select ceil(last_row(ubigint_col)) from super', + 'select ceil(last_row(ubigint_col)) from t1', + 'select ceil(last_row(usmallint_col)) from super', + 'select ceil(last_row(usmallint_col)) from t1', + 'select ceil(last_row(utinyint_col)) from super', + 'select ceil(last_row(utinyint_col)) from t1', + 'select ceil(interp(int_col)) from t1', + 'select ceil(interp(bigint_col)) from t1', + 'select ceil(interp(float_col)) from t1', + 'select ceil(interp(double_col)) from t1', + 'select ceil(interp(smallint_col)) from t1', + 'select ceil(interp(tinyint_col)) from t1', + 'select ceil(interp(uint_col)) from t1', + 'select ceil(interp(ubigint_col)) from t1', + 'select ceil(interp(usmallint_col)) from t1', + 'select ceil(interp(utinyint_col)) from t1', + 'select ceil(spread(ts)) from super', + 'select ceil(spread(ts)) from t1', + 'select ceil(spread(timestamp_col)) from super', + 'select ceil(spread(timestamp_col)) from t1', + 'select ceil(spread(int_col)) from super', + 'select ceil(spread(int_col)) from t1', + 'select ceil(spread(bigint_col)) from super', + 'select ceil(spread(bigint_col)) from t1', + 'select ceil(spread(float_col)) from super', + 'select ceil(spread(float_col)) from t1', + 'select ceil(spread(double_col)) from super', + 'select ceil(spread(double_col)) from t1', + 'select ceil(spread(smallint_col)) from super', + 'select ceil(spread(smallint_col)) from t1', + 'select ceil(spread(tinyint_col)) from super', + 'select ceil(spread(tinyint_col)) from t1', + 'select ceil(spread(uint_col)) from super', + 'select ceil(spread(uint_col)) from t1', + 'select ceil(spread(ubigint_col)) from super', + 'select ceil(spread(ubigint_col)) from t1', + 'select ceil(spread(usmallint_col)) from super', + 'select ceil(spread(usmallint_col)) from t1', + 'select ceil(spread(utinyint_col)) from super', + 'select ceil(spread(utinyint_col)) from t1', + 'select ceil(int_col + int_col) from super', + 'select ceil(int_col + int_col) from t1', + 'select ceil(bigint_col + bigint_col) from super', + 'select ceil(bigint_col + bigint_col) from t1', + 'select ceil(float_col + float_col) from super', + 'select ceil(float_col + float_col) from t1', + 'select ceil(double_col + double_col) from super', + 'select ceil(double_col + double_col) from t1', + 'select ceil(smallint_col + smallint_col) from super', + 'select ceil(smallint_col + smallint_col) from t1', + 'select ceil(tinyint_col + tinyint_col) from super', + 'select ceil(tinyint_col + tinyint_col) from t1', + 'select ceil(uint_col + uint_col) from super', + 'select ceil(uint_col + uint_col) from t1', + 'select ceil(ubigint_col + ubigint_col) from super', + 'select ceil(ubigint_col + ubigint_col) from t1', + 'select ceil(usmallint_col + usmallint_col) from super', + 'select ceil(usmallint_col + usmallint_col) from t1', + 'select ceil(utinyint_col + utinyint_col) from super', + 'select ceil(utinyint_col + utinyint_col) from t1', + 'select ceil(int_col - int_col) from super', + 'select ceil(int_col - int_col) from t1', + 'select ceil(bigint_col - bigint_col) from super', + 'select ceil(bigint_col - bigint_col) from t1', + 'select ceil(float_col - float_col) from super', + 'select ceil(float_col - float_col) from t1', + 'select ceil(double_col - double_col) from super', + 'select ceil(double_col - double_col) from t1', + 'select ceil(smallint_col - smallint_col) from super', + 'select ceil(smallint_col - smallint_col) from t1', + 'select ceil(tinyint_col - tinyint_col) from super', + 'select ceil(tinyint_col - tinyint_col) from t1', + 'select ceil(uint_col - uint_col) from super', + 'select ceil(uint_col - uint_col) from t1', + 'select ceil(ubigint_col - ubigint_col) from super', + 'select ceil(ubigint_col - ubigint_col) from t1', + 'select ceil(usmallint_col - usmallint_col) from super', + 'select ceil(usmallint_col - usmallint_col) from t1', + 'select ceil(utinyint_col - utinyint_col) from super', + 'select ceil(utinyint_col - utinyint_col) from t1', + 'select ceil(int_col * int_col) from super', + 'select ceil(int_col * int_col) from t1', + 'select ceil(bigint_col * bigint_col) from super', + 'select ceil(bigint_col * bigint_col) from t1', + 'select ceil(float_col * float_col) from super', + 'select ceil(float_col * float_col) from t1', + 'select ceil(double_col * double_col) from super', + 'select ceil(double_col * double_col) from t1', + 'select ceil(smallint_col * smallint_col) from super', + 'select ceil(smallint_col * smallint_col) from t1', + 'select ceil(tinyint_col * tinyint_col) from super', + 'select ceil(tinyint_col * tinyint_col) from t1', + 'select ceil(uint_col * uint_col) from super', + 'select ceil(uint_col * uint_col) from t1', + 'select ceil(ubigint_col * ubigint_col) from super', + 'select ceil(ubigint_col * ubigint_col) from t1', + 'select ceil(usmallint_col * usmallint_col) from super', + 'select ceil(usmallint_col * usmallint_col) from t1', + 'select ceil(utinyint_col * utinyint_col) from super', + 'select ceil(utinyint_col * utinyint_col) from t1', + 'select ceil(int_col / int_col) from super', + 'select ceil(int_col / int_col) from t1', + 'select ceil(bigint_col / bigint_col) from super', + 'select ceil(bigint_col / bigint_col) from t1', + 'select ceil(float_col / float_col) from super', + 'select ceil(float_col / float_col) from t1', + 'select ceil(double_col / double_col) from super', + 'select ceil(double_col / double_col) from t1', + 'select ceil(smallint_col / smallint_col) from super', + 'select ceil(smallint_col / smallint_col) from t1', + 'select ceil(tinyint_col / tinyint_col) from super', + 'select ceil(tinyint_col / tinyint_col) from t1', + 'select ceil(uint_col / uint_col) from super', + 'select ceil(uint_col / uint_col) from t1', + 'select ceil(ubigint_col / ubigint_col) from super', + 'select ceil(ubigint_col / ubigint_col) from t1', + 'select ceil(usmallint_col / usmallint_col) from super', + 'select ceil(usmallint_col / usmallint_col) from t1', + 'select ceil(utinyint_col / utinyint_col) from super', + 'select ceil(utinyint_col / utinyint_col) from t1', + 'select int_col, ceil(int_col), int_col from super', + 'select int_col, ceil(int_col), int_col from t1', + 'select bigint_col, ceil(bigint_col), bigint_col from super', + 'select bigint_col, ceil(bigint_col), bigint_col from t1', + 'select float_col, ceil(float_col), float_col from super', + 'select float_col, ceil(float_col), float_col from t1', + 'select double_col, ceil(double_col), double_col from super', + 'select double_col, ceil(double_col), double_col from t1', + 'select smallint_col, ceil(smallint_col), smallint_col from super', + 'select smallint_col, ceil(smallint_col), smallint_col from t1', + 'select tinyint_col, ceil(tinyint_col), tinyint_col from super', + 'select tinyint_col, ceil(tinyint_col), tinyint_col from t1', + 'select uint_col, ceil(uint_col), uint_col from super', + 'select uint_col, ceil(uint_col), uint_col from t1', + 'select ubigint_col, ceil(ubigint_col), ubigint_col from super', + 'select ubigint_col, ceil(ubigint_col), ubigint_col from t1', + 'select usmallint_col, ceil(usmallint_col), usmallint_col from super', + 'select usmallint_col, ceil(usmallint_col), usmallint_col from t1', + 'select utinyint_col, ceil(utinyint_col), utinyint_col from super', + 'select utinyint_col, ceil(utinyint_col), utinyint_col from t1', + 'select 1, ceil(int_col), 1 from super', + 'select 1, ceil(int_col), 1 from t1', + 'select 1, ceil(bigint_col), 1 from super', + 'select 1, ceil(bigint_col), 1 from t1', + 'select 1, ceil(float_col), 1 from super', + 'select 1, ceil(float_col), 1 from t1', + 'select 1, ceil(double_col), 1 from super', + 'select 1, ceil(double_col), 1 from t1', + 'select 1, ceil(smallint_col), 1 from super', + 'select 1, ceil(smallint_col), 1 from t1', + 'select 1, ceil(tinyint_col), 1 from super', + 'select 1, ceil(tinyint_col), 1 from t1', + 'select 1, ceil(uint_col), 1 from super', + 'select 1, ceil(uint_col), 1 from t1', + 'select 1, ceil(ubigint_col), 1 from super', + 'select 1, ceil(ubigint_col), 1 from t1', + 'select 1, ceil(usmallint_col), 1 from super', + 'select 1, ceil(usmallint_col), 1 from t1', + 'select 1, ceil(utinyint_col), 1 from super', + 'select 1, ceil(utinyint_col), 1 from t1', + 'select ceil(int_col) as anyName from super', + 'select ceil(int_col) as anyName from t1', + 'select ceil(bigint_col) as anyName from super', + 'select ceil(bigint_col) as anyName from t1', + 'select ceil(float_col) as anyName from super', + 'select ceil(float_col) as anyName from t1', + 'select ceil(double_col) as anyName from super', + 'select ceil(double_col) as anyName from t1', + 'select ceil(smallint_col) as anyName from super', + 'select ceil(smallint_col) as anyName from t1', + 'select ceil(tinyint_col) as anyName from super', + 'select ceil(tinyint_col) as anyName from t1', + 'select ceil(uint_col) as anyName from super', + 'select ceil(uint_col) as anyName from t1', + 'select ceil(ubigint_col) as anyName from super', + 'select ceil(ubigint_col) as anyName from t1', + 'select ceil(usmallint_col) as anyName from super', + 'select ceil(usmallint_col) as anyName from t1', + 'select ceil(utinyint_col) as anyName from super', + 'select ceil(utinyint_col) as anyName from t1'] for s in range(len(select_command)): for f in range(len(from_command)): sql = "select " + select_command[s] + from_command[f] - if (select_command[s] == "ceil(int_col)"\ - or select_command[s] == "ceil(bigint_col)"\ - or select_command[s] == "ceil(smallint_col)" \ - or select_command[s] == "ceil(float_col)"\ - or select_command[s] == "ceil(double_col)"\ - or select_command[s] == "ceil(tinyint_col)"\ - or select_command[s] == "ceil(uint_col)"\ - or select_command[s] == "ceil(ubigint_col)"\ - or select_command[s] == "ceil(usmallint_col)"\ - or select_command[s] == "ceil(utinyint_col)"\ - or select_command[s] == "1, ceil(int_col), 1"\ - or select_command[s] == "1, ceil(bigint_col), 1"\ - or select_command[s] == "1, ceil(float_col), 1"\ - or select_command[s] == "1, ceil(double_col), 1"\ - or select_command[s] == "1, ceil(smallint_col), 1"\ - or select_command[s] == "1, ceil(tinyint_col), 1"\ - or select_command[s] == "1, ceil(uint_col), 1"\ - or select_command[s] == "1, ceil(ubigint_col), 1"\ - or select_command[s] == "1, ceil(usmallint_col), 1"\ - or select_command[s] == "1, ceil(utinyint_col), 1"\ - or select_command[s] == "int_col, ceil(int_col), int_col"\ - or select_command[s] == "bigint_col, ceil(bigint_col), bigint_col"\ - or select_command[s] == "float_col, ceil(float_col), float_col"\ - or select_command[s] == "double_col, ceil(double_col), double_col"\ - or select_command[s] == "smallint_col, ceil(smallint_col), smallint_col"\ - or select_command[s] == "tinyint_col, ceil(tinyint_col), tinyint_col"\ - or select_command[s] == "uint_col, ceil(uint_col), uint_col"\ - or select_command[s] == "ubigint_col, ceil(ubigint_col), ubigint_col"\ - or select_command[s] == "usmallint_col, ceil(usmallint_col), usmallint_col"\ - or select_command[s] == "utinyint_col, ceil(utinyint_col), utinyint_col"\ - or select_command[s] == "ceil(int_col) as anyName"\ - or select_command[s] == "ceil(bigint_col) as anyName"\ - or select_command[s] == "ceil(float_col) as anyName"\ - or select_command[s] == "ceil(double_col) as anyName"\ - or select_command[s] == "ceil(smallint_col) as anyName"\ - or select_command[s] == "ceil(tinyint_col) as anyName"\ - or select_command[s] == "ceil(uint_col) as anyName"\ - or select_command[s] == "ceil(ubigint_col) as anyName"\ - or select_command[s] == "ceil(usmallint_col) as anyName"\ - or select_command[s] == "ceil(utinyint_col) as anyName"\ - or select_command[s] == "ceil(int_col) + ceil(int_col)"\ - or select_command[s] == "ceil(bigint_col) + ceil(bigint_col)"\ - or select_command[s] == "ceil(float_col) + ceil(float_col)"\ - or select_command[s] == "ceil(double_col) + ceil(double_col)"\ - or select_command[s] == "ceil(smallint_col) + ceil(smallint_col)"\ - or select_command[s] == "ceil(tinyint_col) + ceil(tinyint_col)"\ - or select_command[s] == "ceil(uint_col) + ceil(uint_col)"\ - or select_command[s] == "ceil(ubigint_col) + ceil(ubigint_col)"\ - or select_command[s] == "ceil(usmallint_col) + ceil(usmallint_col)"\ - or select_command[s] == "ceil(utinyint_col) + ceil(utinyint_col)"\ - or select_command[s] == "ceil(int_col) + ceil(int_col)"\ - or select_command[s] == "ceil(bigint_col) + ceil(bigint_col)"\ - or select_command[s] == "ceil(float_col) + ceil(float_col)"\ - or select_command[s] == "ceil(double_col) + ceil(double_col)"\ - or select_command[s] == "ceil(smallint_col) + ceil(smallint_col)"\ - or select_command[s] == "ceil(tinyint_col) + ceil(tinyint_col)"\ - or select_command[s] == "ceil(uint_col) + ceil(uint_col)"\ - or select_command[s] == "ceil(ubigint_col) + ceil(ubigint_col)"\ - or select_command[s] == "ceil(usmallint_col) + ceil(usmallint_col)"\ - or select_command[s] == "ceil(utinyint_col) + cei(utinyint_col)"\ - or select_command[s] == "ceil(int_col) - ceil(int_col)"\ - or select_command[s] == "ceil(bigint_col) - ceil(bigint_col)"\ - or select_command[s] == "ceil(float_col) - ceil(float_col)"\ - or select_command[s] == "ceil(double_col) - ceil(double_col)"\ - or select_command[s] == "ceil(smallint_col) - ceil(smallint_col)"\ - or select_command[s] == "ceil(tinyint_col) - ceil(tinyint_col)"\ - or select_command[s] == "ceil(uint_col) - ceil(uint_col)"\ - or select_command[s] == "ceil(ubigint_col) - ceil(ubigint_col)"\ - or select_command[s] == "ceil(usmallint_col) - ceil(usmallint_col)"\ - or select_command[s] == "ceil(utinyint_col) - ceil(utinyint_col)"\ - or select_command[s] == "ceil(int_col) * ceil(int_col)"\ - or select_command[s] == "ceil(bigint_col) * ceil(bigint_col)"\ - or select_command[s] == "ceil(float_col) * ceil(float_col)"\ - or select_command[s] == "ceil(double_col) * ceil(double_col)"\ - or select_command[s] == "ceil(smallint_col) * ceil(smallint_col)"\ - or select_command[s] == "ceil(tinyint_col) * ceil(tinyint_col)"\ - or select_command[s] == "ceil(uint_col) * ceil(uint_col)"\ - or select_command[s] == "ceil(ubigint_col) * ceil(ubigint_col)"\ - or select_command[s] == "ceil(usmallint_col) * ceil(usmallint_col)"\ - or select_command[s] == "ceil(utinyint_col) * ceil(utinyint_col)"\ - or select_command[s] == "ceil(int_col) / ceil(int_col)"\ - or select_command[s] == "ceil(bigint_col) / ceil(bigint_col)"\ - or select_command[s] == "ceil(float_col) / ceil(float_col)"\ - or select_command[s] == "ceil(double_col) / ceil(double_col)"\ - or select_command[s] == "ceil(smallint_col) / ceil(smallint_col)"\ - or select_command[s] == "ceil(tinyint_col) / ceil(tinyint_col)"\ - or select_command[s] == "ceil(uint_col) / ceil(uint_col)"\ - or select_command[s] == "ceil(ubigint_col) / ceil(ubigint_col)"\ - or select_command[s] == "ceil(usmallint_col) / ceil(usmallint_col)"\ - or select_command[s] == "ceil(utinyint_col) / ceil(utinyint_col)"): + if sql in shouldPass: tdSql.query(sql) else: tdSql.error(sql) + + shouldPass2 = ['select ceil(super.int_col) from super', + 'select ceil(super.int_col) from super, superb where super.ts = superb.ts and super.int_tag = superb.int_tag', + 'select ceil(super.bigint_col) from super', + 'select ceil(super.bigint_col) from super, superb where super.ts = superb.ts and super.int_tag = superb.int_tag', + 'select ceil(super.float_col) from super', + 'select ceil(super.float_col) from super, superb where super.ts = superb.ts and super.int_tag = superb.int_tag', + 'select ceil(super.double_col) from super', + 'select ceil(super.double_col) from super, superb where super.ts = superb.ts and super.int_tag = superb.int_tag', + 'select ceil(super.smallint_col) from super', + 'select ceil(super.smallint_col) from super, superb where super.ts = superb.ts and super.int_tag = superb.int_tag', + 'select ceil(super.tinyint_col) from super', + 'select ceil(super.tinyint_col) from super, superb where super.ts = superb.ts and super.int_tag = superb.int_tag', + 'select ceil(super.uint_col) from super', + 'select ceil(super.uint_col) from super, superb where super.ts = superb.ts and super.int_tag = superb.int_tag', + 'select ceil(super.ubigint_col) from super', + 'select ceil(super.ubigint_col) from super, superb where super.ts = superb.ts and super.int_tag = superb.int_tag', + 'select ceil(super.usmallint_col) from super', + 'select ceil(super.usmallint_col) from super, superb where super.ts = superb.ts and super.int_tag = superb.int_tag', + 'select ceil(super.utinyint_col) from super', + 'select ceil(super.utinyint_col) from super, superb where super.ts = superb.ts and super.int_tag = superb.int_tag', + 'select ceil(t1.int_col) from t1', + 'select ceil(t1.bigint_col) from t1', + 'select ceil(t1.float_col) from t1', + 'select ceil(t1.double_col) from t1', + 'select ceil(t1.smallint_col) from t1', + 'select ceil(t1.tinyint_col) from t1', + 'select ceil(t1.uint_col) from t1', + 'select ceil(t1.ubigint_col) from t1', + 'select ceil(t1.usmallint_col) from t1', + 'select ceil(t1.utinyint_col) from t1'] for sim in range(len(simple_select_command)): for fr in range(len(advance_from_command)): - for filter in range(len(filter_command)): + for groupby in range(len(filter_command)): for fill in range(len(fill_command)): - sql = "select " + simple_select_command[ - sim] + advance_from_command[fr] + filter_command[ - filter] + fill_command[fill] - if sql == "select ceil(t1.int_col) from t1"\ - or sql == "select ceil(super.int_col) from super"\ - or sql == "select ceil(t1.bigint_col) from t1"\ - or sql == "select ceil(super.bigint_col) from super"\ - or sql == "select ceil(t1.smallint_col) from t1"\ - or sql == "select ceil(super.smallint_col) from super"\ - or sql == "select ceil(t1.tinyint_col) from t1"\ - or sql == "select ceil(super.tinyint_col) from super"\ - or sql == "select ceil(t1.float_col) from t1"\ - or sql == "select ceil(super.float_col) from super"\ - or sql == "select ceil(t1.double_col) from t1"\ - or sql == "select ceil(super.double_col) from super"\ - or sql == "select ceil(t1.uint_col) from t1"\ - or sql == "select ceil(super.uint_col) from super"\ - or sql == "select ceil(t1.ubigint_col) from t1"\ - or sql == "select ceil(super.ubigint_col) from super"\ - or sql == "select ceil(t1.usmallint_col) from t1"\ - or sql == "select ceil(super.usmallint_col) from super"\ - or sql == "select ceil(t1.utinyint_col) from t1"\ - or sql == "select ceil(super.utinyint_col) from super"\ - or sql == "select ceil(super.int_col) from super, superb where super.ts = superb.ts and super.int_tag = superb.int_tag"\ - or sql == "select ceil(super.bigint_col) from super, superb where super.ts = superb.ts and super.int_tag = superb.int_tag"\ - or sql == "select ceil(super.smallint_col) from super, superb where super.ts = superb.ts and super.int_tag = superb.int_tag"\ - or sql == "select ceil(super.tinyint_col) from super, superb where super.ts = superb.ts and super.int_tag = superb.int_tag"\ - or sql == "select ceil(super.float_col) from super, superb where super.ts = superb.ts and super.int_tag = superb.int_tag"\ - or sql == "select ceil(super.double_col) from super, superb where super.ts = superb.ts and super.int_tag = superb.int_tag"\ - or sql == "select ceil(super.uint_col) from super, superb where super.ts = superb.ts and super.int_tag = superb.int_tag"\ - or sql == "select ceil(super.ubigint_col) from super, superb where super.ts = superb.ts and super.int_tag = superb.int_tag"\ - or sql == "select ceil(super.usmallint_col) from super, superb where super.ts = superb.ts and super.int_tag = superb.int_tag"\ - or sql == "select ceil(super.utinyint_col) from super, superb where super.ts = superb.ts and super.int_tag = superb.int_tag": + sql = "select " + simple_select_command[sim] + advance_from_command[fr] + filter_command[groupby] + fill_command[fill] + if sql in shouldPass2: tdSql.query(sql) else: tdSql.error(sql) diff --git a/tests/pytest/functions/function_floor.py b/tests/pytest/functions/function_floor.py index 305e3b798a74376766a14cd824ded617db3cc8a2..562bbbc4724e9d7bad9bc8807c0cdd57972a157d 100644 --- a/tests/pytest/functions/function_floor.py +++ b/tests/pytest/functions/function_floor.py @@ -1294,21 +1294,21 @@ class TDTestCase: double_col double, binary_col binary(8), smallint_col smallint, tinyint_col tinyint, bool_col bool, nchar_col nchar(8), \ uint_col int unsigned, ubigint_col bigint unsigned, usmallint_col smallint unsigned, utinyint_col tinyint unsigned) tags (int_tag int, bigint_tag bigint, \ float_tag float, double_tag double, binary_tag binary(8), smallint_tag smallint, tinyint_tag tinyint, bool_tag bool, nchar_tag nchar(8),\ - uint_tag int unsigned, ubigint_tag bigint unsigned, usmallint_tag smallint unsigned, utinyint_tag tinyint unsigned)" + uint_tag int unsigned, ubigint_tag bigint unsigned, usmallint_tag smallint unsigned, utinyint_tag tinyint unsigned, timestamp_tag timestamp)" ) tdSql.execute( "create stable superb (ts timestamp, timestamp_col timestamp, int_col int, bigint_col bigint, float_col float,\ double_col double, binary_col binary(8), smallint_col smallint, tinyint_col tinyint, bool_col bool, nchar_col nchar(8), \ uint_col int unsigned, ubigint_col bigint unsigned, usmallint_col smallint unsigned, utinyint_col tinyint unsigned) tags (int_tag int, bigint_tag bigint, \ float_tag float, double_tag double, binary_tag binary(8), smallint_tag smallint, tinyint_tag tinyint, bool_tag bool, nchar_tag nchar(8),\ - uint_tag int unsigned, ubigint_tag bigint unsigned, usmallint_tag smallint unsigned, utinyint_tag tinyint unsigned)" + uint_tag int unsigned, ubigint_tag bigint unsigned, usmallint_tag smallint unsigned, utinyint_tag tinyint unsigned, timestamp_tag timestamp)" ) tdSql.execute( - "create table t1 using super tags (1, %d, %f, %f, '%s', %d, %d, 1, '%s', %d, %d, %d, %d)" + "create table t1 using super tags (1, %d, %f, %f, '%s', %d, %d, 1, '%s', %d, %d, %d, %d, %s)" % (self.randomBigint(), self.randomDouble(), self.randomDouble(), self.randomNchar(), self.randomSmallint(), self.randomTinyint(), self.randomNchar(), self.randomUInt(), self.randomUBigint(), - self.randomUSmallint(), self.randomUTinyint())) + self.randomUSmallint(), self.randomUTinyint(), 'now')) tdSql.execute( "insert into t1 values (1629796215891, 1629796215891, %d, %d, %f, %f, '%s', %d, %d, 1, '%s', %d, %d, %d, %d)" % (self.randomInt(), self.randomBigint(), self.randomDouble(), @@ -1338,11 +1338,11 @@ class TDTestCase: self.randomUBigint(), self.randomUSmallint(), self.randomUTinyint())) tdSql.execute( - "create table t2 using superb tags (1, %d, %f, %f, '%s', %d, %d, 1, '%s', %d, %d, %d, %d)" + "create table t2 using superb tags (1, %d, %f, %f, '%s', %d, %d, 1, '%s', %d, %d, %d, %d, %s)" % (self.randomBigint(), self.randomDouble(), self.randomDouble(), self.randomNchar(), self.randomSmallint(), self.randomTinyint(), self.randomNchar(), self.randomUInt(), self.randomUBigint(), - self.randomUSmallint(), self.randomUTinyint())) + self.randomUSmallint(), self.randomUTinyint(), 'now')) tdSql.execute( "insert into t2 values (1629796215891, 1629796215891, %d, %d, %f, %f, '%s', %d, %d, 1, '%s', %d, %d, %d, %d)" % (self.randomInt(), self.randomBigint(), self.randomDouble(), @@ -1371,100 +1371,568 @@ class TDTestCase: self.randomTinyint(), self.randomNchar(), self.randomUInt(), self.randomUBigint(), self.randomUSmallint(), self.randomUTinyint())) + + shouldPass = ['select floor(int_col) from super', + 'select floor(int_col) from t1', + 'select floor(bigint_col) from super', + 'select floor(bigint_col) from t1', + 'select floor(float_col) from super', + 'select floor(float_col) from t1', + 'select floor(double_col) from super', + 'select floor(double_col) from t1', + 'select floor(smallint_col) from super', + 'select floor(smallint_col) from t1', + 'select floor(tinyint_col) from super', + 'select floor(tinyint_col) from t1', + 'select floor(uint_col) from super', + 'select floor(uint_col) from t1', + 'select floor(ubigint_col) from super', + 'select floor(ubigint_col) from t1', + 'select floor(usmallint_col) from super', + 'select floor(usmallint_col) from t1', + 'select floor(utinyint_col) from super', + 'select floor(utinyint_col) from t1', + 'select floor(int_col) - floor(int_col) from super', + 'select floor(int_col) - floor(int_col) from t1', + 'select floor(bigint_col) - floor(bigint_col) from super', + 'select floor(bigint_col) - floor(bigint_col) from t1', + 'select floor(float_col) - floor(float_col) from super', + 'select floor(float_col) - floor(float_col) from t1', + 'select floor(double_col) - floor(double_col) from super', + 'select floor(double_col) - floor(double_col) from t1', + 'select floor(smallint_col) - floor(smallint_col) from super', + 'select floor(smallint_col) - floor(smallint_col) from t1', + 'select floor(tinyint_col) - floor(tinyint_col) from super', + 'select floor(tinyint_col) - floor(tinyint_col) from t1', + 'select floor(uint_col) - floor(uint_col) from super', + 'select floor(uint_col) - floor(uint_col) from t1', + 'select floor(ubigint_col) - floor(ubigint_col) from super', + 'select floor(ubigint_col) - floor(ubigint_col) from t1', + 'select floor(usmallint_col) - floor(usmallint_col) from super', + 'select floor(usmallint_col) - floor(usmallint_col) from t1', + 'select floor(utinyint_col) - floor(utinyint_col) from super', + 'select floor(utinyint_col) - floor(utinyint_col) from t1', + 'select floor(int_col) / floor(int_col) from super', + 'select floor(int_col) / floor(int_col) from t1', + 'select floor(bigint_col) / floor(bigint_col) from super', + 'select floor(bigint_col) / floor(bigint_col) from t1', + 'select floor(float_col) / floor(float_col) from super', + 'select floor(float_col) / floor(float_col) from t1', + 'select floor(double_col) / floor(double_col) from super', + 'select floor(double_col) / floor(double_col) from t1', + 'select floor(smallint_col) / floor(smallint_col) from super', + 'select floor(smallint_col) / floor(smallint_col) from t1', + 'select floor(tinyint_col) / floor(tinyint_col) from super', + 'select floor(tinyint_col) / floor(tinyint_col) from t1', + 'select floor(uint_col) / floor(uint_col) from super', + 'select floor(uint_col) / floor(uint_col) from t1', + 'select floor(ubigint_col) / floor(ubigint_col) from super', + 'select floor(ubigint_col) / floor(ubigint_col) from t1', + 'select floor(usmallint_col) / floor(usmallint_col) from super', + 'select floor(usmallint_col) / floor(usmallint_col) from t1', + 'select floor(utinyint_col) / floor(utinyint_col) from super', + 'select floor(utinyint_col) / floor(utinyint_col) from t1', + 'select floor(int_col) * floor(int_col) from super', + 'select floor(int_col) * floor(int_col) from t1', + 'select floor(bigint_col) * floor(bigint_col) from super', + 'select floor(bigint_col) * floor(bigint_col) from t1', + 'select floor(float_col) * floor(float_col) from super', + 'select floor(float_col) * floor(float_col) from t1', + 'select floor(double_col) * floor(double_col) from super', + 'select floor(double_col) * floor(double_col) from t1', + 'select floor(smallint_col) * floor(smallint_col) from super', + 'select floor(smallint_col) * floor(smallint_col) from t1', + 'select floor(tinyint_col) * floor(tinyint_col) from super', + 'select floor(tinyint_col) * floor(tinyint_col) from t1', + 'select floor(uint_col) * floor(uint_col) from super', + 'select floor(uint_col) * floor(uint_col) from t1', + 'select floor(ubigint_col) * floor(ubigint_col) from super', + 'select floor(ubigint_col) * floor(ubigint_col) from t1', + 'select floor(usmallint_col) * floor(usmallint_col) from super', + 'select floor(usmallint_col) * floor(usmallint_col) from t1', + 'select floor(utinyint_col) * floor(utinyint_col) from super', + 'select floor(utinyint_col) * floor(utinyint_col) from t1', + 'select floor(count(ts)) from super', + 'select floor(count(ts)) from t1', + 'select floor(count(timestamp_col)) from super', + 'select floor(count(timestamp_col)) from t1', + 'select floor(count(int_col)) from super', + 'select floor(count(int_col)) from t1', + 'select floor(count(bigint_col)) from super', + 'select floor(count(bigint_col)) from t1', + 'select floor(count(float_col)) from super', + 'select floor(count(float_col)) from t1', + 'select floor(count(double_col)) from super', + 'select floor(count(double_col)) from t1', + 'select floor(count(binary_col)) from super', + 'select floor(count(binary_col)) from t1', + 'select floor(count(smallint_col)) from super', + 'select floor(count(smallint_col)) from t1', + 'select floor(count(tinyint_col)) from super', + 'select floor(count(tinyint_col)) from t1', + 'select floor(count(bool_col)) from super', + 'select floor(count(bool_col)) from t1', + 'select floor(count(nchar_col)) from super', + 'select floor(count(nchar_col)) from t1', + 'select floor(count(uint_col)) from super', + 'select floor(count(uint_col)) from t1', + 'select floor(count(ubigint_col)) from super', + 'select floor(count(ubigint_col)) from t1', + 'select floor(count(usmallint_col)) from super', + 'select floor(count(usmallint_col)) from t1', + 'select floor(count(utinyint_col)) from super', + 'select floor(count(utinyint_col)) from t1', + 'select floor(count(timestamp_tag)) from super', + 'select floor(count(timestamp_tag)) from t1', + 'select floor(count(int_tag)) from super', + 'select floor(count(int_tag)) from t1', + 'select floor(count(bigint_tag)) from super', + 'select floor(count(bigint_tag)) from t1', + 'select floor(count(float_tag)) from super', + 'select floor(count(float_tag)) from t1', + 'select floor(count(double_tag)) from super', + 'select floor(count(double_tag)) from t1', + 'select floor(count(binary_tag)) from super', + 'select floor(count(binary_tag)) from t1', + 'select floor(count(smallint_tag)) from super', + 'select floor(count(smallint_tag)) from t1', + 'select floor(count(tinyint_tag)) from super', + 'select floor(count(tinyint_tag)) from t1', + 'select floor(count(bool_tag)) from super', + 'select floor(count(bool_tag)) from t1', + 'select floor(count(nchar_tag)) from super', + 'select floor(count(nchar_tag)) from t1', + 'select floor(count(uint_tag)) from super', + 'select floor(count(uint_tag)) from t1', + 'select floor(count(ubigint_tag)) from super', + 'select floor(count(ubigint_tag)) from t1', + 'select floor(count(usmallint_tag)) from super', + 'select floor(count(usmallint_tag)) from t1', + 'select floor(count(utinyint_tag)) from super', + 'select floor(count(utinyint_tag)) from t1', + 'select floor(avg(int_col)) from super', + 'select floor(avg(int_col)) from t1', + 'select floor(avg(bigint_col)) from super', + 'select floor(avg(bigint_col)) from t1', + 'select floor(avg(float_col)) from super', + 'select floor(avg(float_col)) from t1', + 'select floor(avg(double_col)) from super', + 'select floor(avg(double_col)) from t1', + 'select floor(avg(smallint_col)) from super', + 'select floor(avg(smallint_col)) from t1', + 'select floor(avg(tinyint_col)) from super', + 'select floor(avg(tinyint_col)) from t1', + 'select floor(avg(uint_col)) from super', + 'select floor(avg(uint_col)) from t1', + 'select floor(avg(ubigint_col)) from super', + 'select floor(avg(ubigint_col)) from t1', + 'select floor(avg(usmallint_col)) from super', + 'select floor(avg(usmallint_col)) from t1', + 'select floor(avg(utinyint_col)) from super', + 'select floor(avg(utinyint_col)) from t1', + 'select floor(twa(int_col)) from t1', + 'select floor(twa(bigint_col)) from t1', + 'select floor(twa(float_col)) from t1', + 'select floor(twa(double_col)) from t1', + 'select floor(twa(smallint_col)) from t1', + 'select floor(twa(tinyint_col)) from t1', + 'select floor(twa(uint_col)) from t1', + 'select floor(twa(ubigint_col)) from t1', + 'select floor(twa(usmallint_col)) from t1', + 'select floor(twa(utinyint_col)) from t1', + 'select floor(sum(int_col)) from super', + 'select floor(sum(int_col)) from t1', + 'select floor(sum(bigint_col)) from super', + 'select floor(sum(bigint_col)) from t1', + 'select floor(sum(float_col)) from super', + 'select floor(sum(float_col)) from t1', + 'select floor(sum(double_col)) from super', + 'select floor(sum(double_col)) from t1', + 'select floor(sum(smallint_col)) from super', + 'select floor(sum(smallint_col)) from t1', + 'select floor(sum(tinyint_col)) from super', + 'select floor(sum(tinyint_col)) from t1', + 'select floor(sum(uint_col)) from super', + 'select floor(sum(uint_col)) from t1', + 'select floor(sum(ubigint_col)) from super', + 'select floor(sum(ubigint_col)) from t1', + 'select floor(sum(usmallint_col)) from super', + 'select floor(sum(usmallint_col)) from t1', + 'select floor(sum(utinyint_col)) from super', + 'select floor(sum(utinyint_col)) from t1', + 'select floor(stddev(int_col)) from super', + 'select floor(stddev(int_col)) from t1', + 'select floor(stddev(bigint_col)) from super', + 'select floor(stddev(bigint_col)) from t1', + 'select floor(stddev(float_col)) from super', + 'select floor(stddev(float_col)) from t1', + 'select floor(stddev(double_col)) from super', + 'select floor(stddev(double_col)) from t1', + 'select floor(stddev(smallint_col)) from super', + 'select floor(stddev(smallint_col)) from t1', + 'select floor(stddev(tinyint_col)) from super', + 'select floor(stddev(tinyint_col)) from t1', + 'select floor(stddev(uint_col)) from super', + 'select floor(stddev(uint_col)) from t1', + 'select floor(stddev(ubigint_col)) from super', + 'select floor(stddev(ubigint_col)) from t1', + 'select floor(stddev(usmallint_col)) from super', + 'select floor(stddev(usmallint_col)) from t1', + 'select floor(stddev(utinyint_col)) from super', + 'select floor(stddev(utinyint_col)) from t1', + 'select floor(irate(int_col)) from t1', + 'select floor(irate(bigint_col)) from t1', + 'select floor(irate(float_col)) from t1', + 'select floor(irate(double_col)) from t1', + 'select floor(irate(smallint_col)) from t1', + 'select floor(irate(tinyint_col)) from t1', + 'select floor(irate(uint_col)) from t1', + 'select floor(irate(ubigint_col)) from t1', + 'select floor(irate(usmallint_col)) from t1', + 'select floor(irate(utinyint_col)) from t1', + 'select floor(min(int_col)) from super', + 'select floor(min(int_col)) from t1', + 'select floor(min(bigint_col)) from super', + 'select floor(min(bigint_col)) from t1', + 'select floor(min(float_col)) from super', + 'select floor(min(float_col)) from t1', + 'select floor(min(double_col)) from super', + 'select floor(min(double_col)) from t1', + 'select floor(min(smallint_col)) from super', + 'select floor(min(smallint_col)) from t1', + 'select floor(min(tinyint_col)) from super', + 'select floor(min(tinyint_col)) from t1', + 'select floor(min(uint_col)) from super', + 'select floor(min(uint_col)) from t1', + 'select floor(min(ubigint_col)) from super', + 'select floor(min(ubigint_col)) from t1', + 'select floor(min(usmallint_col)) from super', + 'select floor(min(usmallint_col)) from t1', + 'select floor(min(utinyint_col)) from super', + 'select floor(min(utinyint_col)) from t1', + 'select floor(max(int_col)) from super', + 'select floor(max(int_col)) from t1', + 'select floor(max(bigint_col)) from super', + 'select floor(max(bigint_col)) from t1', + 'select floor(max(float_col)) from super', + 'select floor(max(float_col)) from t1', + 'select floor(max(double_col)) from super', + 'select floor(max(double_col)) from t1', + 'select floor(max(smallint_col)) from super', + 'select floor(max(smallint_col)) from t1', + 'select floor(max(tinyint_col)) from super', + 'select floor(max(tinyint_col)) from t1', + 'select floor(max(uint_col)) from super', + 'select floor(max(uint_col)) from t1', + 'select floor(max(ubigint_col)) from super', + 'select floor(max(ubigint_col)) from t1', + 'select floor(max(usmallint_col)) from super', + 'select floor(max(usmallint_col)) from t1', + 'select floor(max(utinyint_col)) from super', + 'select floor(max(utinyint_col)) from t1', + 'select floor(first(int_col)) from super', + 'select floor(first(int_col)) from t1', + 'select floor(first(bigint_col)) from super', + 'select floor(first(bigint_col)) from t1', + 'select floor(first(float_col)) from super', + 'select floor(first(float_col)) from t1', + 'select floor(first(double_col)) from super', + 'select floor(first(double_col)) from t1', + 'select floor(first(smallint_col)) from super', + 'select floor(first(smallint_col)) from t1', + 'select floor(first(tinyint_col)) from super', + 'select floor(first(tinyint_col)) from t1', + 'select floor(first(uint_col)) from super', + 'select floor(first(uint_col)) from t1', + 'select floor(first(ubigint_col)) from super', + 'select floor(first(ubigint_col)) from t1', + 'select floor(first(usmallint_col)) from super', + 'select floor(first(usmallint_col)) from t1', + 'select floor(first(utinyint_col)) from super', + 'select floor(first(utinyint_col)) from t1', + 'select floor(last(int_col)) from super', + 'select floor(last(int_col)) from t1', + 'select floor(last(bigint_col)) from super', + 'select floor(last(bigint_col)) from t1', + 'select floor(last(float_col)) from super', + 'select floor(last(float_col)) from t1', + 'select floor(last(double_col)) from super', + 'select floor(last(double_col)) from t1', + 'select floor(last(smallint_col)) from super', + 'select floor(last(smallint_col)) from t1', + 'select floor(last(tinyint_col)) from super', + 'select floor(last(tinyint_col)) from t1', + 'select floor(last(uint_col)) from super', + 'select floor(last(uint_col)) from t1', + 'select floor(last(ubigint_col)) from super', + 'select floor(last(ubigint_col)) from t1', + 'select floor(last(usmallint_col)) from super', + 'select floor(last(usmallint_col)) from t1', + 'select floor(last(utinyint_col)) from super', + 'select floor(last(utinyint_col)) from t1', + 'select floor(percentile(int_col, 1)) from t1', + 'select floor(percentile(bigint_col, 1)) from t1', + 'select floor(percentile(float_col, 1)) from t1', + 'select floor(percentile(double_col, 1)) from t1', + 'select floor(percentile(smallint_col, 1)) from t1', + 'select floor(percentile(tinyint_col, 1)) from t1', + 'select floor(percentile(uint_col, 1)) from t1', + 'select floor(percentile(ubigint_col, 1)) from t1', + 'select floor(percentile(usmallint_col, 1)) from t1', + 'select floor(percentile(utinyint_col, 1)) from t1', + 'select floor(apercentile(int_col, 1)) from super', + 'select floor(apercentile(int_col, 1)) from t1', + 'select floor(apercentile(bigint_col, 1)) from super', + 'select floor(apercentile(bigint_col, 1)) from t1', + 'select floor(apercentile(float_col, 1)) from super', + 'select floor(apercentile(float_col, 1)) from t1', + 'select floor(apercentile(double_col, 1)) from super', + 'select floor(apercentile(double_col, 1)) from t1', + 'select floor(apercentile(smallint_col, 1)) from super', + 'select floor(apercentile(smallint_col, 1)) from t1', + 'select floor(apercentile(tinyint_col, 1)) from super', + 'select floor(apercentile(tinyint_col, 1)) from t1', + 'select floor(apercentile(uint_col, 1)) from super', + 'select floor(apercentile(uint_col, 1)) from t1', + 'select floor(apercentile(ubigint_col, 1)) from super', + 'select floor(apercentile(ubigint_col, 1)) from t1', + 'select floor(apercentile(usmallint_col, 1)) from super', + 'select floor(apercentile(usmallint_col, 1)) from t1', + 'select floor(apercentile(utinyint_col, 1)) from super', + 'select floor(apercentile(utinyint_col, 1)) from t1', + 'select floor(last_row(int_col)) from super', + 'select floor(last_row(int_col)) from t1', + 'select floor(last_row(bigint_col)) from super', + 'select floor(last_row(bigint_col)) from t1', + 'select floor(last_row(float_col)) from super', + 'select floor(last_row(float_col)) from t1', + 'select floor(last_row(double_col)) from super', + 'select floor(last_row(double_col)) from t1', + 'select floor(last_row(smallint_col)) from super', + 'select floor(last_row(smallint_col)) from t1', + 'select floor(last_row(tinyint_col)) from super', + 'select floor(last_row(tinyint_col)) from t1', + 'select floor(last_row(uint_col)) from super', + 'select floor(last_row(uint_col)) from t1', + 'select floor(last_row(ubigint_col)) from super', + 'select floor(last_row(ubigint_col)) from t1', + 'select floor(last_row(usmallint_col)) from super', + 'select floor(last_row(usmallint_col)) from t1', + 'select floor(last_row(utinyint_col)) from super', + 'select floor(last_row(utinyint_col)) from t1', + 'select floor(interp(int_col)) from t1', + 'select floor(interp(bigint_col)) from t1', + 'select floor(interp(float_col)) from t1', + 'select floor(interp(double_col)) from t1', + 'select floor(interp(smallint_col)) from t1', + 'select floor(interp(tinyint_col)) from t1', + 'select floor(interp(uint_col)) from t1', + 'select floor(interp(ubigint_col)) from t1', + 'select floor(interp(usmallint_col)) from t1', + 'select floor(interp(utinyint_col)) from t1', + 'select floor(spread(ts)) from super', + 'select floor(spread(ts)) from t1', + 'select floor(spread(timestamp_col)) from super', + 'select floor(spread(timestamp_col)) from t1', + 'select floor(spread(int_col)) from super', + 'select floor(spread(int_col)) from t1', + 'select floor(spread(bigint_col)) from super', + 'select floor(spread(bigint_col)) from t1', + 'select floor(spread(float_col)) from super', + 'select floor(spread(float_col)) from t1', + 'select floor(spread(double_col)) from super', + 'select floor(spread(double_col)) from t1', + 'select floor(spread(smallint_col)) from super', + 'select floor(spread(smallint_col)) from t1', + 'select floor(spread(tinyint_col)) from super', + 'select floor(spread(tinyint_col)) from t1', + 'select floor(spread(uint_col)) from super', + 'select floor(spread(uint_col)) from t1', + 'select floor(spread(ubigint_col)) from super', + 'select floor(spread(ubigint_col)) from t1', + 'select floor(spread(usmallint_col)) from super', + 'select floor(spread(usmallint_col)) from t1', + 'select floor(spread(utinyint_col)) from super', + 'select floor(spread(utinyint_col)) from t1', + 'select floor(int_col + int_col) from super', + 'select floor(int_col + int_col) from t1', + 'select floor(bigint_col + bigint_col) from super', + 'select floor(bigint_col + bigint_col) from t1', + 'select floor(float_col + float_col) from super', + 'select floor(float_col + float_col) from t1', + 'select floor(double_col + double_col) from super', + 'select floor(double_col + double_col) from t1', + 'select floor(smallint_col + smallint_col) from super', + 'select floor(smallint_col + smallint_col) from t1', + 'select floor(tinyint_col + tinyint_col) from super', + 'select floor(tinyint_col + tinyint_col) from t1', + 'select floor(uint_col + uint_col) from super', + 'select floor(uint_col + uint_col) from t1', + 'select floor(ubigint_col + ubigint_col) from super', + 'select floor(ubigint_col + ubigint_col) from t1', + 'select floor(usmallint_col + usmallint_col) from super', + 'select floor(usmallint_col + usmallint_col) from t1', + 'select floor(utinyint_col + utinyint_col) from super', + 'select floor(utinyint_col + utinyint_col) from t1', + 'select floor(int_col - int_col) from super', + 'select floor(int_col - int_col) from t1', + 'select floor(bigint_col - bigint_col) from super', + 'select floor(bigint_col - bigint_col) from t1', + 'select floor(float_col - float_col) from super', + 'select floor(float_col - float_col) from t1', + 'select floor(double_col - double_col) from super', + 'select floor(double_col - double_col) from t1', + 'select floor(smallint_col - smallint_col) from super', + 'select floor(smallint_col - smallint_col) from t1', + 'select floor(tinyint_col - tinyint_col) from super', + 'select floor(tinyint_col - tinyint_col) from t1', + 'select floor(uint_col - uint_col) from super', + 'select floor(uint_col - uint_col) from t1', + 'select floor(ubigint_col - ubigint_col) from super', + 'select floor(ubigint_col - ubigint_col) from t1', + 'select floor(usmallint_col - usmallint_col) from super', + 'select floor(usmallint_col - usmallint_col) from t1', + 'select floor(utinyint_col - utinyint_col) from super', + 'select floor(utinyint_col - utinyint_col) from t1', + 'select floor(int_col * int_col) from super', + 'select floor(int_col * int_col) from t1', + 'select floor(bigint_col * bigint_col) from super', + 'select floor(bigint_col * bigint_col) from t1', + 'select floor(float_col * float_col) from super', + 'select floor(float_col * float_col) from t1', + 'select floor(double_col * double_col) from super', + 'select floor(double_col * double_col) from t1', + 'select floor(smallint_col * smallint_col) from super', + 'select floor(smallint_col * smallint_col) from t1', + 'select floor(tinyint_col * tinyint_col) from super', + 'select floor(tinyint_col * tinyint_col) from t1', + 'select floor(uint_col * uint_col) from super', + 'select floor(uint_col * uint_col) from t1', + 'select floor(ubigint_col * ubigint_col) from super', + 'select floor(ubigint_col * ubigint_col) from t1', + 'select floor(usmallint_col * usmallint_col) from super', + 'select floor(usmallint_col * usmallint_col) from t1', + 'select floor(utinyint_col * utinyint_col) from super', + 'select floor(utinyint_col * utinyint_col) from t1', + 'select floor(int_col / int_col) from super', + 'select floor(int_col / int_col) from t1', + 'select floor(bigint_col / bigint_col) from super', + 'select floor(bigint_col / bigint_col) from t1', + 'select floor(float_col / float_col) from super', + 'select floor(float_col / float_col) from t1', + 'select floor(double_col / double_col) from super', + 'select floor(double_col / double_col) from t1', + 'select floor(smallint_col / smallint_col) from super', + 'select floor(smallint_col / smallint_col) from t1', + 'select floor(tinyint_col / tinyint_col) from super', + 'select floor(tinyint_col / tinyint_col) from t1', + 'select floor(uint_col / uint_col) from super', + 'select floor(uint_col / uint_col) from t1', + 'select floor(ubigint_col / ubigint_col) from super', + 'select floor(ubigint_col / ubigint_col) from t1', + 'select floor(usmallint_col / usmallint_col) from super', + 'select floor(usmallint_col / usmallint_col) from t1', + 'select floor(utinyint_col / utinyint_col) from super', + 'select floor(utinyint_col / utinyint_col) from t1', + 'select int_col, floor(int_col), int_col from super', + 'select int_col, floor(int_col), int_col from t1', + 'select bigint_col, floor(bigint_col), bigint_col from super', + 'select bigint_col, floor(bigint_col), bigint_col from t1', + 'select float_col, floor(float_col), float_col from super', + 'select float_col, floor(float_col), float_col from t1', + 'select double_col, floor(double_col), double_col from super', + 'select double_col, floor(double_col), double_col from t1', + 'select smallint_col, floor(smallint_col), smallint_col from super', + 'select smallint_col, floor(smallint_col), smallint_col from t1', + 'select tinyint_col, floor(tinyint_col), tinyint_col from super', + 'select tinyint_col, floor(tinyint_col), tinyint_col from t1', + 'select uint_col, floor(uint_col), uint_col from super', + 'select uint_col, floor(uint_col), uint_col from t1', + 'select ubigint_col, floor(ubigint_col), ubigint_col from super', + 'select ubigint_col, floor(ubigint_col), ubigint_col from t1', + 'select usmallint_col, floor(usmallint_col), usmallint_col from super', + 'select usmallint_col, floor(usmallint_col), usmallint_col from t1', + 'select utinyint_col, floor(utinyint_col), utinyint_col from super', + 'select utinyint_col, floor(utinyint_col), utinyint_col from t1', + 'select 1, floor(int_col), 1 from super', + 'select 1, floor(int_col), 1 from t1', + 'select 1, floor(bigint_col), 1 from super', + 'select 1, floor(bigint_col), 1 from t1', + 'select 1, floor(float_col), 1 from super', + 'select 1, floor(float_col), 1 from t1', + 'select 1, floor(double_col), 1 from super', + 'select 1, floor(double_col), 1 from t1', + 'select 1, floor(smallint_col), 1 from super', + 'select 1, floor(smallint_col), 1 from t1', + 'select 1, floor(tinyint_col), 1 from super', + 'select 1, floor(tinyint_col), 1 from t1', + 'select 1, floor(uint_col), 1 from super', + 'select 1, floor(uint_col), 1 from t1', + 'select 1, floor(ubigint_col), 1 from super', + 'select 1, floor(ubigint_col), 1 from t1', + 'select 1, floor(usmallint_col), 1 from super', + 'select 1, floor(usmallint_col), 1 from t1', + 'select 1, floor(utinyint_col), 1 from super', + 'select 1, floor(utinyint_col), 1 from t1', + 'select floor(int_col) as anyName from super', + 'select floor(int_col) as anyName from t1', + 'select floor(bigint_col) as anyName from super', + 'select floor(bigint_col) as anyName from t1', + 'select floor(float_col) as anyName from super', + 'select floor(float_col) as anyName from t1', + 'select floor(double_col) as anyName from super', + 'select floor(double_col) as anyName from t1', + 'select floor(smallint_col) as anyName from super', + 'select floor(smallint_col) as anyName from t1', + 'select floor(tinyint_col) as anyName from super', + 'select floor(tinyint_col) as anyName from t1', + 'select floor(uint_col) as anyName from super', + 'select floor(uint_col) as anyName from t1', + 'select floor(ubigint_col) as anyName from super', + 'select floor(ubigint_col) as anyName from t1', + 'select floor(usmallint_col) as anyName from super', + 'select floor(usmallint_col) as anyName from t1', + 'select floor(utinyint_col) as anyName from super', + 'select floor(utinyint_col) as anyName from t1' + ] + + + shouldPass2 = ['select floor(super.int_col) from super', + 'select floor(super.int_col) from super, superb where super.ts = superb.ts and super.int_tag = superb.int_tag', + 'select floor(super.bigint_col) from super', + 'select floor(super.bigint_col) from super, superb where super.ts = superb.ts and super.int_tag = superb.int_tag', + 'select floor(super.float_col) from super', + 'select floor(super.float_col) from super, superb where super.ts = superb.ts and super.int_tag = superb.int_tag', + 'select floor(super.double_col) from super', + 'select floor(super.double_col) from super, superb where super.ts = superb.ts and super.int_tag = superb.int_tag', + 'select floor(super.smallint_col) from super', + 'select floor(super.smallint_col) from super, superb where super.ts = superb.ts and super.int_tag = superb.int_tag', + 'select floor(super.tinyint_col) from super', + 'select floor(super.tinyint_col) from super, superb where super.ts = superb.ts and super.int_tag = superb.int_tag', + 'select floor(super.uint_col) from super', + 'select floor(super.uint_col) from super, superb where super.ts = superb.ts and super.int_tag = superb.int_tag', + 'select floor(super.ubigint_col) from super', + 'select floor(super.ubigint_col) from super, superb where super.ts = superb.ts and super.int_tag = superb.int_tag', + 'select floor(super.usmallint_col) from super', + 'select floor(super.usmallint_col) from super, superb where super.ts = superb.ts and super.int_tag = superb.int_tag', + 'select floor(super.utinyint_col) from super', + 'select floor(super.utinyint_col) from super, superb where super.ts = superb.ts and super.int_tag = superb.int_tag', + 'select floor(t1.int_col) from t1', + 'select floor(t1.bigint_col) from t1', + 'select floor(t1.float_col) from t1', + 'select floor(t1.double_col) from t1', + 'select floor(t1.smallint_col) from t1', + 'select floor(t1.tinyint_col) from t1', + 'select floor(t1.uint_col) from t1', + 'select floor(t1.ubigint_col) from t1', + 'select floor(t1.usmallint_col) from t1', + 'select floor(t1.utinyint_col) from t1'] + for s in range(len(select_command)): for f in range(len(from_command)): sql = "select " + select_command[s] + from_command[f] - if (select_command[s] == "floor(int_col)"\ - or select_command[s] == "floor(bigint_col)"\ - or select_command[s] == "floor(smallint_col)" \ - or select_command[s] == "floor(float_col)"\ - or select_command[s] == "floor(double_col)"\ - or select_command[s] == "floor(tinyint_col)"\ - or select_command[s] == "floor(uint_col)"\ - or select_command[s] == "floor(ubigint_col)"\ - or select_command[s] == "floor(usmallint_col)"\ - or select_command[s] == "floor(utinyint_col)"\ - or select_command[s] == "1, floor(int_col), 1"\ - or select_command[s] == "1, floor(bigint_col), 1"\ - or select_command[s] == "1, floor(float_col), 1"\ - or select_command[s] == "1, floor(double_col), 1"\ - or select_command[s] == "1, floor(smallint_col), 1"\ - or select_command[s] == "1, floor(tinyint_col), 1"\ - or select_command[s] == "1, floor(uint_col), 1"\ - or select_command[s] == "1, floor(ubigint_col), 1"\ - or select_command[s] == "1, floor(usmallint_col), 1"\ - or select_command[s] == "1, floor(utinyint_col), 1"\ - or select_command[s] == "int_col, floor(int_col), int_col"\ - or select_command[s] == "bigint_col, floor(bigint_col), bigint_col"\ - or select_command[s] == "float_col, floor(float_col), float_col"\ - or select_command[s] == "double_col, floor(double_col), double_col"\ - or select_command[s] == "smallint_col, floor(smallint_col), smallint_col"\ - or select_command[s] == "tinyint_col, floor(tinyint_col), tinyint_col"\ - or select_command[s] == "uint_col, floor(uint_col), uint_col"\ - or select_command[s] == "ubigint_col, floor(ubigint_col), ubigint_col"\ - or select_command[s] == "usmallint_col, floor(usmallint_col), usmallint_col"\ - or select_command[s] == "utinyint_col, floor(utinyint_col), utinyint_col"\ - or select_command[s] == "floor(int_col) as anyName"\ - or select_command[s] == "floor(bigint_col) as anyName"\ - or select_command[s] == "floor(float_col) as anyName"\ - or select_command[s] == "floor(double_col) as anyName"\ - or select_command[s] == "floor(smallint_col) as anyName"\ - or select_command[s] == "floor(tinyint_col) as anyName"\ - or select_command[s] == "floor(uint_col) as anyName"\ - or select_command[s] == "floor(ubigint_col) as anyName"\ - or select_command[s] == "floor(usmallint_col) as anyName"\ - or select_command[s] == "floor(utinyint_col) as anyName"\ - or select_command[s] == "floor(int_col) + floor(int_col)"\ - or select_command[s] == "floor(bigint_col) + floor(bigint_col)"\ - or select_command[s] == "floor(float_col) + floor(float_col)"\ - or select_command[s] == "floor(double_col) + floor(double_col)"\ - or select_command[s] == "floor(smallint_col) + floor(smallint_col)"\ - or select_command[s] == "floor(tinyint_col) + floor(tinyint_col)"\ - or select_command[s] == "floor(uint_col) + floor(uint_col)"\ - or select_command[s] == "floor(ubigint_col) + floor(ubigint_col)"\ - or select_command[s] == "floor(usmallint_col) + floor(usmallint_col)"\ - or select_command[s] == "floor(utinyint_col) + floor(utinyint_col)"\ - or select_command[s] == "floor(int_col) + floor(int_col)"\ - or select_command[s] == "floor(bigint_col) + floor(bigint_col)"\ - or select_command[s] == "floor(float_col) + floor(float_col)"\ - or select_command[s] == "floor(double_col) + floor(double_col)"\ - or select_command[s] == "floor(smallint_col) + floor(smallint_col)"\ - or select_command[s] == "floor(tinyint_col) + floor(tinyint_col)"\ - or select_command[s] == "floor(uint_col) + floor(uint_col)"\ - or select_command[s] == "floor(ubigint_col) + floor(ubigint_col)"\ - or select_command[s] == "floor(usmallint_col) + floor(usmallint_col)"\ - or select_command[s] == "floor(utinyint_col) + cei(utinyint_col)"\ - or select_command[s] == "floor(int_col) - floor(int_col)"\ - or select_command[s] == "floor(bigint_col) - floor(bigint_col)"\ - or select_command[s] == "floor(float_col) - floor(float_col)"\ - or select_command[s] == "floor(double_col) - floor(double_col)"\ - or select_command[s] == "floor(smallint_col) - floor(smallint_col)"\ - or select_command[s] == "floor(tinyint_col) - floor(tinyint_col)"\ - or select_command[s] == "floor(uint_col) - floor(uint_col)"\ - or select_command[s] == "floor(ubigint_col) - floor(ubigint_col)"\ - or select_command[s] == "floor(usmallint_col) - floor(usmallint_col)"\ - or select_command[s] == "floor(utinyint_col) - floor(utinyint_col)"\ - or select_command[s] == "floor(int_col) * floor(int_col)"\ - or select_command[s] == "floor(bigint_col) * floor(bigint_col)"\ - or select_command[s] == "floor(float_col) * floor(float_col)"\ - or select_command[s] == "floor(double_col) * floor(double_col)"\ - or select_command[s] == "floor(smallint_col) * floor(smallint_col)"\ - or select_command[s] == "floor(tinyint_col) * floor(tinyint_col)"\ - or select_command[s] == "floor(uint_col) * floor(uint_col)"\ - or select_command[s] == "floor(ubigint_col) * floor(ubigint_col)"\ - or select_command[s] == "floor(usmallint_col) * floor(usmallint_col)"\ - or select_command[s] == "floor(utinyint_col) * floor(utinyint_col)"\ - or select_command[s] == "floor(int_col) / floor(int_col)"\ - or select_command[s] == "floor(bigint_col) / floor(bigint_col)"\ - or select_command[s] == "floor(float_col) / floor(float_col)"\ - or select_command[s] == "floor(double_col) / floor(double_col)"\ - or select_command[s] == "floor(smallint_col) / floor(smallint_col)"\ - or select_command[s] == "floor(tinyint_col) / floor(tinyint_col)"\ - or select_command[s] == "floor(uint_col) / floor(uint_col)"\ - or select_command[s] == "floor(ubigint_col) / floor(ubigint_col)"\ - or select_command[s] == "floor(usmallint_col) / floor(usmallint_col)"\ - or select_command[s] == "floor(utinyint_col) / floor(utinyint_col)"): + if sql in shouldPass: tdSql.query(sql) else: tdSql.error(sql) @@ -1475,40 +1943,10 @@ class TDTestCase: sql = "select " + simple_select_command[ sim] + advance_from_command[fr] + filter_command[ filter] + fill_command[fill] - if sql == "select floor(t1.int_col) from t1"\ - or sql == "select floor(super.int_col) from super"\ - or sql == "select floor(t1.bigint_col) from t1"\ - or sql == "select floor(super.bigint_col) from super"\ - or sql == "select floor(t1.smallint_col) from t1"\ - or sql == "select floor(super.smallint_col) from super"\ - or sql == "select floor(t1.tinyint_col) from t1"\ - or sql == "select floor(super.tinyint_col) from super"\ - or sql == "select floor(t1.float_col) from t1"\ - or sql == "select floor(super.float_col) from super"\ - or sql == "select floor(t1.double_col) from t1"\ - or sql == "select floor(super.double_col) from super"\ - or sql == "select floor(t1.uint_col) from t1"\ - or sql == "select floor(super.uint_col) from super"\ - or sql == "select floor(t1.ubigint_col) from t1"\ - or sql == "select floor(super.ubigint_col) from super"\ - or sql == "select floor(t1.usmallint_col) from t1"\ - or sql == "select floor(super.usmallint_col) from super"\ - or sql == "select floor(t1.utinyint_col) from t1"\ - or sql == "select floor(super.utinyint_col) from super"\ - or sql == "select floor(super.int_col) from super, superb where super.ts = superb.ts and super.int_tag = superb.int_tag"\ - or sql == "select floor(super.bigint_col) from super, superb where super.ts = superb.ts and super.int_tag = superb.int_tag"\ - or sql == "select floor(super.smallint_col) from super, superb where super.ts = superb.ts and super.int_tag = superb.int_tag"\ - or sql == "select floor(super.tinyint_col) from super, superb where super.ts = superb.ts and super.int_tag = superb.int_tag"\ - or sql == "select floor(super.float_col) from super, superb where super.ts = superb.ts and super.int_tag = superb.int_tag"\ - or sql == "select floor(super.double_col) from super, superb where super.ts = superb.ts and super.int_tag = superb.int_tag"\ - or sql == "select floor(super.uint_col) from super, superb where super.ts = superb.ts and super.int_tag = superb.int_tag"\ - or sql == "select floor(super.ubigint_col) from super, superb where super.ts = superb.ts and super.int_tag = superb.int_tag"\ - or sql == "select floor(super.usmallint_col) from super, superb where super.ts = superb.ts and super.int_tag = superb.int_tag"\ - or sql == "select floor(super.utinyint_col) from super, superb where super.ts = superb.ts and super.int_tag = superb.int_tag": + if sql in shouldPass2: tdSql.query(sql) else: - tdSql.error(sql) - + tdSql.error(sql) def stop(self): tdSql.close() tdLog.success("%s successfully executed" % __file__) diff --git a/tests/pytest/functions/function_round.py b/tests/pytest/functions/function_round.py index 93cace49ad8d16c6491584ed530b3dff07ef6fe4..8785821452dfe0ed65bc784f2c5d6c20f0fa484b 100644 --- a/tests/pytest/functions/function_round.py +++ b/tests/pytest/functions/function_round.py @@ -1294,21 +1294,21 @@ class TDTestCase: double_col double, binary_col binary(8), smallint_col smallint, tinyint_col tinyint, bool_col bool, nchar_col nchar(8), \ uint_col int unsigned, ubigint_col bigint unsigned, usmallint_col smallint unsigned, utinyint_col tinyint unsigned) tags (int_tag int, bigint_tag bigint, \ float_tag float, double_tag double, binary_tag binary(8), smallint_tag smallint, tinyint_tag tinyint, bool_tag bool, nchar_tag nchar(8),\ - uint_tag int unsigned, ubigint_tag bigint unsigned, usmallint_tag smallint unsigned, utinyint_tag tinyint unsigned)" + uint_tag int unsigned, ubigint_tag bigint unsigned, usmallint_tag smallint unsigned, utinyint_tag tinyint unsigned, timestamp_tag timestamp)" ) tdSql.execute( "create stable superb (ts timestamp, timestamp_col timestamp, int_col int, bigint_col bigint, float_col float,\ double_col double, binary_col binary(8), smallint_col smallint, tinyint_col tinyint, bool_col bool, nchar_col nchar(8), \ uint_col int unsigned, ubigint_col bigint unsigned, usmallint_col smallint unsigned, utinyint_col tinyint unsigned) tags (int_tag int, bigint_tag bigint, \ float_tag float, double_tag double, binary_tag binary(8), smallint_tag smallint, tinyint_tag tinyint, bool_tag bool, nchar_tag nchar(8),\ - uint_tag int unsigned, ubigint_tag bigint unsigned, usmallint_tag smallint unsigned, utinyint_tag tinyint unsigned)" + uint_tag int unsigned, ubigint_tag bigint unsigned, usmallint_tag smallint unsigned, utinyint_tag tinyint unsigned, timestamp_tag timestamp)" ) tdSql.execute( - "create table t1 using super tags (1, %d, %f, %f, '%s', %d, %d, 1, '%s', %d, %d, %d, %d)" + "create table t1 using super tags (1, %d, %f, %f, '%s', %d, %d, 1, '%s', %d, %d, %d, %d, %s)" % (self.randomBigint(), self.randomDouble(), self.randomDouble(), self.randomNchar(), self.randomSmallint(), self.randomTinyint(), self.randomNchar(), self.randomUInt(), self.randomUBigint(), - self.randomUSmallint(), self.randomUTinyint())) + self.randomUSmallint(), self.randomUTinyint(), 'now')) tdSql.execute( "insert into t1 values (1629796215891, 1629796215891, %d, %d, %f, %f, '%s', %d, %d, 1, '%s', %d, %d, %d, %d)" % (self.randomInt(), self.randomBigint(), self.randomDouble(), @@ -1338,11 +1338,11 @@ class TDTestCase: self.randomUBigint(), self.randomUSmallint(), self.randomUTinyint())) tdSql.execute( - "create table t2 using superb tags (1, %d, %f, %f, '%s', %d, %d, 1, '%s', %d, %d, %d, %d)" + "create table t2 using superb tags (1, %d, %f, %f, '%s', %d, %d, 1, '%s', %d, %d, %d, %d, %s)" % (self.randomBigint(), self.randomDouble(), self.randomDouble(), self.randomNchar(), self.randomSmallint(), self.randomTinyint(), self.randomNchar(), self.randomUInt(), self.randomUBigint(), - self.randomUSmallint(), self.randomUTinyint())) + self.randomUSmallint(), self.randomUTinyint(), 'now')) tdSql.execute( "insert into t2 values (1629796215891, 1629796215891, %d, %d, %f, %f, '%s', %d, %d, 1, '%s', %d, %d, %d, %d)" % (self.randomInt(), self.randomBigint(), self.randomDouble(), @@ -1371,100 +1371,567 @@ class TDTestCase: self.randomTinyint(), self.randomNchar(), self.randomUInt(), self.randomUBigint(), self.randomUSmallint(), self.randomUTinyint())) + + shouldPass = ['select round(int_col) from super', + 'select round(int_col) from t1', + 'select round(bigint_col) from super', + 'select round(bigint_col) from t1', + 'select round(float_col) from super', + 'select round(float_col) from t1', + 'select round(double_col) from super', + 'select round(double_col) from t1', + 'select round(smallint_col) from super', + 'select round(smallint_col) from t1', + 'select round(tinyint_col) from super', + 'select round(tinyint_col) from t1', + 'select round(uint_col) from super', + 'select round(uint_col) from t1', + 'select round(ubigint_col) from super', + 'select round(ubigint_col) from t1', + 'select round(usmallint_col) from super', + 'select round(usmallint_col) from t1', + 'select round(utinyint_col) from super', + 'select round(utinyint_col) from t1', + 'select round(int_col) - round(int_col) from super', + 'select round(int_col) - round(int_col) from t1', + 'select round(bigint_col) - round(bigint_col) from super', + 'select round(bigint_col) - round(bigint_col) from t1', + 'select round(float_col) - round(float_col) from super', + 'select round(float_col) - round(float_col) from t1', + 'select round(double_col) - round(double_col) from super', + 'select round(double_col) - round(double_col) from t1', + 'select round(smallint_col) - round(smallint_col) from super', + 'select round(smallint_col) - round(smallint_col) from t1', + 'select round(tinyint_col) - round(tinyint_col) from super', + 'select round(tinyint_col) - round(tinyint_col) from t1', + 'select round(uint_col) - round(uint_col) from super', + 'select round(uint_col) - round(uint_col) from t1', + 'select round(ubigint_col) - round(ubigint_col) from super', + 'select round(ubigint_col) - round(ubigint_col) from t1', + 'select round(usmallint_col) - round(usmallint_col) from super', + 'select round(usmallint_col) - round(usmallint_col) from t1', + 'select round(utinyint_col) - round(utinyint_col) from super', + 'select round(utinyint_col) - round(utinyint_col) from t1', + 'select round(int_col) / round(int_col) from super', + 'select round(int_col) / round(int_col) from t1', + 'select round(bigint_col) / round(bigint_col) from super', + 'select round(bigint_col) / round(bigint_col) from t1', + 'select round(float_col) / round(float_col) from super', + 'select round(float_col) / round(float_col) from t1', + 'select round(double_col) / round(double_col) from super', + 'select round(double_col) / round(double_col) from t1', + 'select round(smallint_col) / round(smallint_col) from super', + 'select round(smallint_col) / round(smallint_col) from t1', + 'select round(tinyint_col) / round(tinyint_col) from super', + 'select round(tinyint_col) / round(tinyint_col) from t1', + 'select round(uint_col) / round(uint_col) from super', + 'select round(uint_col) / round(uint_col) from t1', + 'select round(ubigint_col) / round(ubigint_col) from super', + 'select round(ubigint_col) / round(ubigint_col) from t1', + 'select round(usmallint_col) / round(usmallint_col) from super', + 'select round(usmallint_col) / round(usmallint_col) from t1', + 'select round(utinyint_col) / round(utinyint_col) from super', + 'select round(utinyint_col) / round(utinyint_col) from t1', + 'select round(int_col) * round(int_col) from super', + 'select round(int_col) * round(int_col) from t1', + 'select round(bigint_col) * round(bigint_col) from super', + 'select round(bigint_col) * round(bigint_col) from t1', + 'select round(float_col) * round(float_col) from super', + 'select round(float_col) * round(float_col) from t1', + 'select round(double_col) * round(double_col) from super', + 'select round(double_col) * round(double_col) from t1', + 'select round(smallint_col) * round(smallint_col) from super', + 'select round(smallint_col) * round(smallint_col) from t1', + 'select round(tinyint_col) * round(tinyint_col) from super', + 'select round(tinyint_col) * round(tinyint_col) from t1', + 'select round(uint_col) * round(uint_col) from super', + 'select round(uint_col) * round(uint_col) from t1', + 'select round(ubigint_col) * round(ubigint_col) from super', + 'select round(ubigint_col) * round(ubigint_col) from t1', + 'select round(usmallint_col) * round(usmallint_col) from super', + 'select round(usmallint_col) * round(usmallint_col) from t1', + 'select round(utinyint_col) * round(utinyint_col) from super', + 'select round(utinyint_col) * round(utinyint_col) from t1', + 'select round(count(ts)) from super', + 'select round(count(ts)) from t1', + 'select round(count(timestamp_col)) from super', + 'select round(count(timestamp_col)) from t1', + 'select round(count(int_col)) from super', + 'select round(count(int_col)) from t1', + 'select round(count(bigint_col)) from super', + 'select round(count(bigint_col)) from t1', + 'select round(count(float_col)) from super', + 'select round(count(float_col)) from t1', + 'select round(count(double_col)) from super', + 'select round(count(double_col)) from t1', + 'select round(count(binary_col)) from super', + 'select round(count(binary_col)) from t1', + 'select round(count(smallint_col)) from super', + 'select round(count(smallint_col)) from t1', + 'select round(count(tinyint_col)) from super', + 'select round(count(tinyint_col)) from t1', + 'select round(count(bool_col)) from super', + 'select round(count(bool_col)) from t1', + 'select round(count(nchar_col)) from super', + 'select round(count(nchar_col)) from t1', + 'select round(count(uint_col)) from super', + 'select round(count(uint_col)) from t1', + 'select round(count(ubigint_col)) from super', + 'select round(count(ubigint_col)) from t1', + 'select round(count(usmallint_col)) from super', + 'select round(count(usmallint_col)) from t1', + 'select round(count(utinyint_col)) from super', + 'select round(count(utinyint_col)) from t1', + 'select round(count(timestamp_tag)) from super', + 'select round(count(timestamp_tag)) from t1', + 'select round(count(int_tag)) from super', + 'select round(count(int_tag)) from t1', + 'select round(count(bigint_tag)) from super', + 'select round(count(bigint_tag)) from t1', + 'select round(count(float_tag)) from super', + 'select round(count(float_tag)) from t1', + 'select round(count(double_tag)) from super', + 'select round(count(double_tag)) from t1', + 'select round(count(binary_tag)) from super', + 'select round(count(binary_tag)) from t1', + 'select round(count(smallint_tag)) from super', + 'select round(count(smallint_tag)) from t1', + 'select round(count(tinyint_tag)) from super', + 'select round(count(tinyint_tag)) from t1', + 'select round(count(bool_tag)) from super', + 'select round(count(bool_tag)) from t1', + 'select round(count(nchar_tag)) from super', + 'select round(count(nchar_tag)) from t1', + 'select round(count(uint_tag)) from super', + 'select round(count(uint_tag)) from t1', + 'select round(count(ubigint_tag)) from super', + 'select round(count(ubigint_tag)) from t1', + 'select round(count(usmallint_tag)) from super', + 'select round(count(usmallint_tag)) from t1', + 'select round(count(utinyint_tag)) from super', + 'select round(count(utinyint_tag)) from t1', + 'select round(avg(int_col)) from super', + 'select round(avg(int_col)) from t1', + 'select round(avg(bigint_col)) from super', + 'select round(avg(bigint_col)) from t1', + 'select round(avg(float_col)) from super', + 'select round(avg(float_col)) from t1', + 'select round(avg(double_col)) from super', + 'select round(avg(double_col)) from t1', + 'select round(avg(smallint_col)) from super', + 'select round(avg(smallint_col)) from t1', + 'select round(avg(tinyint_col)) from super', + 'select round(avg(tinyint_col)) from t1', + 'select round(avg(uint_col)) from super', + 'select round(avg(uint_col)) from t1', + 'select round(avg(ubigint_col)) from super', + 'select round(avg(ubigint_col)) from t1', + 'select round(avg(usmallint_col)) from super', + 'select round(avg(usmallint_col)) from t1', + 'select round(avg(utinyint_col)) from super', + 'select round(avg(utinyint_col)) from t1', + 'select round(twa(int_col)) from t1', + 'select round(twa(bigint_col)) from t1', + 'select round(twa(float_col)) from t1', + 'select round(twa(double_col)) from t1', + 'select round(twa(smallint_col)) from t1', + 'select round(twa(tinyint_col)) from t1', + 'select round(twa(uint_col)) from t1', + 'select round(twa(ubigint_col)) from t1', + 'select round(twa(usmallint_col)) from t1', + 'select round(twa(utinyint_col)) from t1', + 'select round(sum(int_col)) from super', + 'select round(sum(int_col)) from t1', + 'select round(sum(bigint_col)) from super', + 'select round(sum(bigint_col)) from t1', + 'select round(sum(float_col)) from super', + 'select round(sum(float_col)) from t1', + 'select round(sum(double_col)) from super', + 'select round(sum(double_col)) from t1', + 'select round(sum(smallint_col)) from super', + 'select round(sum(smallint_col)) from t1', + 'select round(sum(tinyint_col)) from super', + 'select round(sum(tinyint_col)) from t1', + 'select round(sum(uint_col)) from super', + 'select round(sum(uint_col)) from t1', + 'select round(sum(ubigint_col)) from super', + 'select round(sum(ubigint_col)) from t1', + 'select round(sum(usmallint_col)) from super', + 'select round(sum(usmallint_col)) from t1', + 'select round(sum(utinyint_col)) from super', + 'select round(sum(utinyint_col)) from t1', + 'select round(stddev(int_col)) from super', + 'select round(stddev(int_col)) from t1', + 'select round(stddev(bigint_col)) from super', + 'select round(stddev(bigint_col)) from t1', + 'select round(stddev(float_col)) from super', + 'select round(stddev(float_col)) from t1', + 'select round(stddev(double_col)) from super', + 'select round(stddev(double_col)) from t1', + 'select round(stddev(smallint_col)) from super', + 'select round(stddev(smallint_col)) from t1', + 'select round(stddev(tinyint_col)) from super', + 'select round(stddev(tinyint_col)) from t1', + 'select round(stddev(uint_col)) from super', + 'select round(stddev(uint_col)) from t1', + 'select round(stddev(ubigint_col)) from super', + 'select round(stddev(ubigint_col)) from t1', + 'select round(stddev(usmallint_col)) from super', + 'select round(stddev(usmallint_col)) from t1', + 'select round(stddev(utinyint_col)) from super', + 'select round(stddev(utinyint_col)) from t1', + 'select round(irate(int_col)) from t1', + 'select round(irate(bigint_col)) from t1', + 'select round(irate(float_col)) from t1', + 'select round(irate(double_col)) from t1', + 'select round(irate(smallint_col)) from t1', + 'select round(irate(tinyint_col)) from t1', + 'select round(irate(uint_col)) from t1', + 'select round(irate(ubigint_col)) from t1', + 'select round(irate(usmallint_col)) from t1', + 'select round(irate(utinyint_col)) from t1', + 'select round(min(int_col)) from super', + 'select round(min(int_col)) from t1', + 'select round(min(bigint_col)) from super', + 'select round(min(bigint_col)) from t1', + 'select round(min(float_col)) from super', + 'select round(min(float_col)) from t1', + 'select round(min(double_col)) from super', + 'select round(min(double_col)) from t1', + 'select round(min(smallint_col)) from super', + 'select round(min(smallint_col)) from t1', + 'select round(min(tinyint_col)) from super', + 'select round(min(tinyint_col)) from t1', + 'select round(min(uint_col)) from super', + 'select round(min(uint_col)) from t1', + 'select round(min(ubigint_col)) from super', + 'select round(min(ubigint_col)) from t1', + 'select round(min(usmallint_col)) from super', + 'select round(min(usmallint_col)) from t1', + 'select round(min(utinyint_col)) from super', + 'select round(min(utinyint_col)) from t1', + 'select round(max(int_col)) from super', + 'select round(max(int_col)) from t1', + 'select round(max(bigint_col)) from super', + 'select round(max(bigint_col)) from t1', + 'select round(max(float_col)) from super', + 'select round(max(float_col)) from t1', + 'select round(max(double_col)) from super', + 'select round(max(double_col)) from t1', + 'select round(max(smallint_col)) from super', + 'select round(max(smallint_col)) from t1', + 'select round(max(tinyint_col)) from super', + 'select round(max(tinyint_col)) from t1', + 'select round(max(uint_col)) from super', + 'select round(max(uint_col)) from t1', + 'select round(max(ubigint_col)) from super', + 'select round(max(ubigint_col)) from t1', + 'select round(max(usmallint_col)) from super', + 'select round(max(usmallint_col)) from t1', + 'select round(max(utinyint_col)) from super', + 'select round(max(utinyint_col)) from t1', + 'select round(first(int_col)) from super', + 'select round(first(int_col)) from t1', + 'select round(first(bigint_col)) from super', + 'select round(first(bigint_col)) from t1', + 'select round(first(float_col)) from super', + 'select round(first(float_col)) from t1', + 'select round(first(double_col)) from super', + 'select round(first(double_col)) from t1', + 'select round(first(smallint_col)) from super', + 'select round(first(smallint_col)) from t1', + 'select round(first(tinyint_col)) from super', + 'select round(first(tinyint_col)) from t1', + 'select round(first(uint_col)) from super', + 'select round(first(uint_col)) from t1', + 'select round(first(ubigint_col)) from super', + 'select round(first(ubigint_col)) from t1', + 'select round(first(usmallint_col)) from super', + 'select round(first(usmallint_col)) from t1', + 'select round(first(utinyint_col)) from super', + 'select round(first(utinyint_col)) from t1', + 'select round(last(int_col)) from super', + 'select round(last(int_col)) from t1', + 'select round(last(bigint_col)) from super', + 'select round(last(bigint_col)) from t1', + 'select round(last(float_col)) from super', + 'select round(last(float_col)) from t1', + 'select round(last(double_col)) from super', + 'select round(last(double_col)) from t1', + 'select round(last(smallint_col)) from super', + 'select round(last(smallint_col)) from t1', + 'select round(last(tinyint_col)) from super', + 'select round(last(tinyint_col)) from t1', + 'select round(last(uint_col)) from super', + 'select round(last(uint_col)) from t1', + 'select round(last(ubigint_col)) from super', + 'select round(last(ubigint_col)) from t1', + 'select round(last(usmallint_col)) from super', + 'select round(last(usmallint_col)) from t1', + 'select round(last(utinyint_col)) from super', + 'select round(last(utinyint_col)) from t1', + 'select round(percentile(int_col, 1)) from t1', + 'select round(percentile(bigint_col, 1)) from t1', + 'select round(percentile(float_col, 1)) from t1', + 'select round(percentile(double_col, 1)) from t1', + 'select round(percentile(smallint_col, 1)) from t1', + 'select round(percentile(tinyint_col, 1)) from t1', + 'select round(percentile(uint_col, 1)) from t1', + 'select round(percentile(ubigint_col, 1)) from t1', + 'select round(percentile(usmallint_col, 1)) from t1', + 'select round(percentile(utinyint_col, 1)) from t1', + 'select round(apercentile(int_col, 1)) from super', + 'select round(apercentile(int_col, 1)) from t1', + 'select round(apercentile(bigint_col, 1)) from super', + 'select round(apercentile(bigint_col, 1)) from t1', + 'select round(apercentile(float_col, 1)) from super', + 'select round(apercentile(float_col, 1)) from t1', + 'select round(apercentile(double_col, 1)) from super', + 'select round(apercentile(double_col, 1)) from t1', + 'select round(apercentile(smallint_col, 1)) from super', + 'select round(apercentile(smallint_col, 1)) from t1', + 'select round(apercentile(tinyint_col, 1)) from super', + 'select round(apercentile(tinyint_col, 1)) from t1', + 'select round(apercentile(uint_col, 1)) from super', + 'select round(apercentile(uint_col, 1)) from t1', + 'select round(apercentile(ubigint_col, 1)) from super', + 'select round(apercentile(ubigint_col, 1)) from t1', + 'select round(apercentile(usmallint_col, 1)) from super', + 'select round(apercentile(usmallint_col, 1)) from t1', + 'select round(apercentile(utinyint_col, 1)) from super', + 'select round(apercentile(utinyint_col, 1)) from t1', + 'select round(last_row(int_col)) from super', + 'select round(last_row(int_col)) from t1', + 'select round(last_row(bigint_col)) from super', + 'select round(last_row(bigint_col)) from t1', + 'select round(last_row(float_col)) from super', + 'select round(last_row(float_col)) from t1', + 'select round(last_row(double_col)) from super', + 'select round(last_row(double_col)) from t1', + 'select round(last_row(smallint_col)) from super', + 'select round(last_row(smallint_col)) from t1', + 'select round(last_row(tinyint_col)) from super', + 'select round(last_row(tinyint_col)) from t1', + 'select round(last_row(uint_col)) from super', + 'select round(last_row(uint_col)) from t1', + 'select round(last_row(ubigint_col)) from super', + 'select round(last_row(ubigint_col)) from t1', + 'select round(last_row(usmallint_col)) from super', + 'select round(last_row(usmallint_col)) from t1', + 'select round(last_row(utinyint_col)) from super', + 'select round(last_row(utinyint_col)) from t1', + 'select round(interp(int_col)) from t1', + 'select round(interp(bigint_col)) from t1', + 'select round(interp(float_col)) from t1', + 'select round(interp(double_col)) from t1', + 'select round(interp(smallint_col)) from t1', + 'select round(interp(tinyint_col)) from t1', + 'select round(interp(uint_col)) from t1', + 'select round(interp(ubigint_col)) from t1', + 'select round(interp(usmallint_col)) from t1', + 'select round(interp(utinyint_col)) from t1', + 'select round(spread(ts)) from super', + 'select round(spread(ts)) from t1', + 'select round(spread(timestamp_col)) from super', + 'select round(spread(timestamp_col)) from t1', + 'select round(spread(int_col)) from super', + 'select round(spread(int_col)) from t1', + 'select round(spread(bigint_col)) from super', + 'select round(spread(bigint_col)) from t1', + 'select round(spread(float_col)) from super', + 'select round(spread(float_col)) from t1', + 'select round(spread(double_col)) from super', + 'select round(spread(double_col)) from t1', + 'select round(spread(smallint_col)) from super', + 'select round(spread(smallint_col)) from t1', + 'select round(spread(tinyint_col)) from super', + 'select round(spread(tinyint_col)) from t1', + 'select round(spread(uint_col)) from super', + 'select round(spread(uint_col)) from t1', + 'select round(spread(ubigint_col)) from super', + 'select round(spread(ubigint_col)) from t1', + 'select round(spread(usmallint_col)) from super', + 'select round(spread(usmallint_col)) from t1', + 'select round(spread(utinyint_col)) from super', + 'select round(spread(utinyint_col)) from t1', + 'select round(int_col + int_col) from super', + 'select round(int_col + int_col) from t1', + 'select round(bigint_col + bigint_col) from super', + 'select round(bigint_col + bigint_col) from t1', + 'select round(float_col + float_col) from super', + 'select round(float_col + float_col) from t1', + 'select round(double_col + double_col) from super', + 'select round(double_col + double_col) from t1', + 'select round(smallint_col + smallint_col) from super', + 'select round(smallint_col + smallint_col) from t1', + 'select round(tinyint_col + tinyint_col) from super', + 'select round(tinyint_col + tinyint_col) from t1', + 'select round(uint_col + uint_col) from super', + 'select round(uint_col + uint_col) from t1', + 'select round(ubigint_col + ubigint_col) from super', + 'select round(ubigint_col + ubigint_col) from t1', + 'select round(usmallint_col + usmallint_col) from super', + 'select round(usmallint_col + usmallint_col) from t1', + 'select round(utinyint_col + utinyint_col) from super', + 'select round(utinyint_col + utinyint_col) from t1', + 'select round(int_col - int_col) from super', + 'select round(int_col - int_col) from t1', + 'select round(bigint_col - bigint_col) from super', + 'select round(bigint_col - bigint_col) from t1', + 'select round(float_col - float_col) from super', + 'select round(float_col - float_col) from t1', + 'select round(double_col - double_col) from super', + 'select round(double_col - double_col) from t1', + 'select round(smallint_col - smallint_col) from super', + 'select round(smallint_col - smallint_col) from t1', + 'select round(tinyint_col - tinyint_col) from super', + 'select round(tinyint_col - tinyint_col) from t1', + 'select round(uint_col - uint_col) from super', + 'select round(uint_col - uint_col) from t1', + 'select round(ubigint_col - ubigint_col) from super', + 'select round(ubigint_col - ubigint_col) from t1', + 'select round(usmallint_col - usmallint_col) from super', + 'select round(usmallint_col - usmallint_col) from t1', + 'select round(utinyint_col - utinyint_col) from super', + 'select round(utinyint_col - utinyint_col) from t1', + 'select round(int_col * int_col) from super', + 'select round(int_col * int_col) from t1', + 'select round(bigint_col * bigint_col) from super', + 'select round(bigint_col * bigint_col) from t1', + 'select round(float_col * float_col) from super', + 'select round(float_col * float_col) from t1', + 'select round(double_col * double_col) from super', + 'select round(double_col * double_col) from t1', + 'select round(smallint_col * smallint_col) from super', + 'select round(smallint_col * smallint_col) from t1', + 'select round(tinyint_col * tinyint_col) from super', + 'select round(tinyint_col * tinyint_col) from t1', + 'select round(uint_col * uint_col) from super', + 'select round(uint_col * uint_col) from t1', + 'select round(ubigint_col * ubigint_col) from super', + 'select round(ubigint_col * ubigint_col) from t1', + 'select round(usmallint_col * usmallint_col) from super', + 'select round(usmallint_col * usmallint_col) from t1', + 'select round(utinyint_col * utinyint_col) from super', + 'select round(utinyint_col * utinyint_col) from t1', + 'select round(int_col / int_col) from super', + 'select round(int_col / int_col) from t1', + 'select round(bigint_col / bigint_col) from super', + 'select round(bigint_col / bigint_col) from t1', + 'select round(float_col / float_col) from super', + 'select round(float_col / float_col) from t1', + 'select round(double_col / double_col) from super', + 'select round(double_col / double_col) from t1', + 'select round(smallint_col / smallint_col) from super', + 'select round(smallint_col / smallint_col) from t1', + 'select round(tinyint_col / tinyint_col) from super', + 'select round(tinyint_col / tinyint_col) from t1', + 'select round(uint_col / uint_col) from super', + 'select round(uint_col / uint_col) from t1', + 'select round(ubigint_col / ubigint_col) from super', + 'select round(ubigint_col / ubigint_col) from t1', + 'select round(usmallint_col / usmallint_col) from super', + 'select round(usmallint_col / usmallint_col) from t1', + 'select round(utinyint_col / utinyint_col) from super', + 'select round(utinyint_col / utinyint_col) from t1', + 'select int_col, round(int_col), int_col from super', + 'select int_col, round(int_col), int_col from t1', + 'select bigint_col, round(bigint_col), bigint_col from super', + 'select bigint_col, round(bigint_col), bigint_col from t1', + 'select float_col, round(float_col), float_col from super', + 'select float_col, round(float_col), float_col from t1', + 'select double_col, round(double_col), double_col from super', + 'select double_col, round(double_col), double_col from t1', + 'select smallint_col, round(smallint_col), smallint_col from super', + 'select smallint_col, round(smallint_col), smallint_col from t1', + 'select tinyint_col, round(tinyint_col), tinyint_col from super', + 'select tinyint_col, round(tinyint_col), tinyint_col from t1', + 'select uint_col, round(uint_col), uint_col from super', + 'select uint_col, round(uint_col), uint_col from t1', + 'select ubigint_col, round(ubigint_col), ubigint_col from super', + 'select ubigint_col, round(ubigint_col), ubigint_col from t1', + 'select usmallint_col, round(usmallint_col), usmallint_col from super', + 'select usmallint_col, round(usmallint_col), usmallint_col from t1', + 'select utinyint_col, round(utinyint_col), utinyint_col from super', + 'select utinyint_col, round(utinyint_col), utinyint_col from t1', + 'select 1, round(int_col), 1 from super', + 'select 1, round(int_col), 1 from t1', + 'select 1, round(bigint_col), 1 from super', + 'select 1, round(bigint_col), 1 from t1', + 'select 1, round(float_col), 1 from super', + 'select 1, round(float_col), 1 from t1', + 'select 1, round(double_col), 1 from super', + 'select 1, round(double_col), 1 from t1', + 'select 1, round(smallint_col), 1 from super', + 'select 1, round(smallint_col), 1 from t1', + 'select 1, round(tinyint_col), 1 from super', + 'select 1, round(tinyint_col), 1 from t1', + 'select 1, round(uint_col), 1 from super', + 'select 1, round(uint_col), 1 from t1', + 'select 1, round(ubigint_col), 1 from super', + 'select 1, round(ubigint_col), 1 from t1', + 'select 1, round(usmallint_col), 1 from super', + 'select 1, round(usmallint_col), 1 from t1', + 'select 1, round(utinyint_col), 1 from super', + 'select 1, round(utinyint_col), 1 from t1', + 'select round(int_col) as anyName from super', + 'select round(int_col) as anyName from t1', + 'select round(bigint_col) as anyName from super', + 'select round(bigint_col) as anyName from t1', + 'select round(float_col) as anyName from super', + 'select round(float_col) as anyName from t1', + 'select round(double_col) as anyName from super', + 'select round(double_col) as anyName from t1', + 'select round(smallint_col) as anyName from super', + 'select round(smallint_col) as anyName from t1', + 'select round(tinyint_col) as anyName from super', + 'select round(tinyint_col) as anyName from t1', + 'select round(uint_col) as anyName from super', + 'select round(uint_col) as anyName from t1', + 'select round(ubigint_col) as anyName from super', + 'select round(ubigint_col) as anyName from t1', + 'select round(usmallint_col) as anyName from super', + 'select round(usmallint_col) as anyName from t1', + 'select round(utinyint_col) as anyName from super', + 'select round(utinyint_col) as anyName from t1'] + + shouldPass2 = ['select round(super.int_col) from super', + 'select round(super.int_col) from super, superb where super.ts = superb.ts and super.int_tag = superb.int_tag', + 'select round(super.bigint_col) from super', + 'select round(super.bigint_col) from super, superb where super.ts = superb.ts and super.int_tag = superb.int_tag', + 'select round(super.float_col) from super', + 'select round(super.float_col) from super, superb where super.ts = superb.ts and super.int_tag = superb.int_tag', + 'select round(super.double_col) from super', + 'select round(super.double_col) from super, superb where super.ts = superb.ts and super.int_tag = superb.int_tag', + 'select round(super.smallint_col) from super', + 'select round(super.smallint_col) from super, superb where super.ts = superb.ts and super.int_tag = superb.int_tag', + 'select round(super.tinyint_col) from super', + 'select round(super.tinyint_col) from super, superb where super.ts = superb.ts and super.int_tag = superb.int_tag', + 'select round(super.uint_col) from super', + 'select round(super.uint_col) from super, superb where super.ts = superb.ts and super.int_tag = superb.int_tag', + 'select round(super.ubigint_col) from super', + 'select round(super.ubigint_col) from super, superb where super.ts = superb.ts and super.int_tag = superb.int_tag', + 'select round(super.usmallint_col) from super', + 'select round(super.usmallint_col) from super, superb where super.ts = superb.ts and super.int_tag = superb.int_tag', + 'select round(super.utinyint_col) from super', + 'select round(super.utinyint_col) from super, superb where super.ts = superb.ts and super.int_tag = superb.int_tag', + 'select round(t1.int_col) from t1', + 'select round(t1.bigint_col) from t1', + 'select round(t1.float_col) from t1', + 'select round(t1.double_col) from t1', + 'select round(t1.smallint_col) from t1', + 'select round(t1.tinyint_col) from t1', + 'select round(t1.uint_col) from t1', + 'select round(t1.ubigint_col) from t1', + 'select round(t1.usmallint_col) from t1', + 'select round(t1.utinyint_col) from t1'] + + for s in range(len(select_command)): for f in range(len(from_command)): sql = "select " + select_command[s] + from_command[f] - if (select_command[s] == "round(int_col)"\ - or select_command[s] == "round(bigint_col)"\ - or select_command[s] == "round(smallint_col)" \ - or select_command[s] == "round(float_col)"\ - or select_command[s] == "round(double_col)"\ - or select_command[s] == "round(tinyint_col)"\ - or select_command[s] == "round(uint_col)"\ - or select_command[s] == "round(ubigint_col)"\ - or select_command[s] == "round(usmallint_col)"\ - or select_command[s] == "round(utinyint_col)"\ - or select_command[s] == "1, round(int_col), 1"\ - or select_command[s] == "1, round(bigint_col), 1"\ - or select_command[s] == "1, round(float_col), 1"\ - or select_command[s] == "1, round(double_col), 1"\ - or select_command[s] == "1, round(smallint_col), 1"\ - or select_command[s] == "1, round(tinyint_col), 1"\ - or select_command[s] == "1, round(uint_col), 1"\ - or select_command[s] == "1, round(ubigint_col), 1"\ - or select_command[s] == "1, round(usmallint_col), 1"\ - or select_command[s] == "1, round(utinyint_col), 1"\ - or select_command[s] == "int_col, round(int_col), int_col"\ - or select_command[s] == "bigint_col, round(bigint_col), bigint_col"\ - or select_command[s] == "float_col, round(float_col), float_col"\ - or select_command[s] == "double_col, round(double_col), double_col"\ - or select_command[s] == "smallint_col, round(smallint_col), smallint_col"\ - or select_command[s] == "tinyint_col, round(tinyint_col), tinyint_col"\ - or select_command[s] == "uint_col, round(uint_col), uint_col"\ - or select_command[s] == "ubigint_col, round(ubigint_col), ubigint_col"\ - or select_command[s] == "usmallint_col, round(usmallint_col), usmallint_col"\ - or select_command[s] == "utinyint_col, round(utinyint_col), utinyint_col"\ - or select_command[s] == "round(int_col) as anyName"\ - or select_command[s] == "round(bigint_col) as anyName"\ - or select_command[s] == "round(float_col) as anyName"\ - or select_command[s] == "round(double_col) as anyName"\ - or select_command[s] == "round(smallint_col) as anyName"\ - or select_command[s] == "round(tinyint_col) as anyName"\ - or select_command[s] == "round(uint_col) as anyName"\ - or select_command[s] == "round(ubigint_col) as anyName"\ - or select_command[s] == "round(usmallint_col) as anyName"\ - or select_command[s] == "round(utinyint_col) as anyName"\ - or select_command[s] == "round(int_col) + round(int_col)"\ - or select_command[s] == "round(bigint_col) + round(bigint_col)"\ - or select_command[s] == "round(float_col) + round(float_col)"\ - or select_command[s] == "round(double_col) + round(double_col)"\ - or select_command[s] == "round(smallint_col) + round(smallint_col)"\ - or select_command[s] == "round(tinyint_col) + round(tinyint_col)"\ - or select_command[s] == "round(uint_col) + round(uint_col)"\ - or select_command[s] == "round(ubigint_col) + round(ubigint_col)"\ - or select_command[s] == "round(usmallint_col) + round(usmallint_col)"\ - or select_command[s] == "round(utinyint_col) + round(utinyint_col)"\ - or select_command[s] == "round(int_col) + round(int_col)"\ - or select_command[s] == "round(bigint_col) + round(bigint_col)"\ - or select_command[s] == "round(float_col) + round(float_col)"\ - or select_command[s] == "round(double_col) + round(double_col)"\ - or select_command[s] == "round(smallint_col) + round(smallint_col)"\ - or select_command[s] == "round(tinyint_col) + round(tinyint_col)"\ - or select_command[s] == "round(uint_col) + round(uint_col)"\ - or select_command[s] == "round(ubigint_col) + round(ubigint_col)"\ - or select_command[s] == "round(usmallint_col) + round(usmallint_col)"\ - or select_command[s] == "round(utinyint_col) + cei(utinyint_col)"\ - or select_command[s] == "round(int_col) - round(int_col)"\ - or select_command[s] == "round(bigint_col) - round(bigint_col)"\ - or select_command[s] == "round(float_col) - round(float_col)"\ - or select_command[s] == "round(double_col) - round(double_col)"\ - or select_command[s] == "round(smallint_col) - round(smallint_col)"\ - or select_command[s] == "round(tinyint_col) - round(tinyint_col)"\ - or select_command[s] == "round(uint_col) - round(uint_col)"\ - or select_command[s] == "round(ubigint_col) - round(ubigint_col)"\ - or select_command[s] == "round(usmallint_col) - round(usmallint_col)"\ - or select_command[s] == "round(utinyint_col) - round(utinyint_col)"\ - or select_command[s] == "round(int_col) * round(int_col)"\ - or select_command[s] == "round(bigint_col) * round(bigint_col)"\ - or select_command[s] == "round(float_col) * round(float_col)"\ - or select_command[s] == "round(double_col) * round(double_col)"\ - or select_command[s] == "round(smallint_col) * round(smallint_col)"\ - or select_command[s] == "round(tinyint_col) * round(tinyint_col)"\ - or select_command[s] == "round(uint_col) * round(uint_col)"\ - or select_command[s] == "round(ubigint_col) * round(ubigint_col)"\ - or select_command[s] == "round(usmallint_col) * round(usmallint_col)"\ - or select_command[s] == "round(utinyint_col) * round(utinyint_col)"\ - or select_command[s] == "round(int_col) / round(int_col)"\ - or select_command[s] == "round(bigint_col) / round(bigint_col)"\ - or select_command[s] == "round(float_col) / round(float_col)"\ - or select_command[s] == "round(double_col) / round(double_col)"\ - or select_command[s] == "round(smallint_col) / round(smallint_col)"\ - or select_command[s] == "round(tinyint_col) / round(tinyint_col)"\ - or select_command[s] == "round(uint_col) / round(uint_col)"\ - or select_command[s] == "round(ubigint_col) / round(ubigint_col)"\ - or select_command[s] == "round(usmallint_col) / round(usmallint_col)"\ - or select_command[s] == "round(utinyint_col) / round(utinyint_col)"): + if sql in shouldPass: tdSql.query(sql) else: tdSql.error(sql) @@ -1475,40 +1942,10 @@ class TDTestCase: sql = "select " + simple_select_command[ sim] + advance_from_command[fr] + filter_command[ filter] + fill_command[fill] - if sql == "select round(t1.int_col) from t1"\ - or sql == "select round(super.int_col) from super"\ - or sql == "select round(t1.bigint_col) from t1"\ - or sql == "select round(super.bigint_col) from super"\ - or sql == "select round(t1.smallint_col) from t1"\ - or sql == "select round(super.smallint_col) from super"\ - or sql == "select round(t1.tinyint_col) from t1"\ - or sql == "select round(super.tinyint_col) from super"\ - or sql == "select round(t1.float_col) from t1"\ - or sql == "select round(super.float_col) from super"\ - or sql == "select round(t1.double_col) from t1"\ - or sql == "select round(super.double_col) from super"\ - or sql == "select round(t1.uint_col) from t1"\ - or sql == "select round(super.uint_col) from super"\ - or sql == "select round(t1.ubigint_col) from t1"\ - or sql == "select round(super.ubigint_col) from super"\ - or sql == "select round(t1.usmallint_col) from t1"\ - or sql == "select round(super.usmallint_col) from super"\ - or sql == "select round(t1.utinyint_col) from t1"\ - or sql == "select round(super.utinyint_col) from super"\ - or sql == "select round(super.int_col) from super, superb where super.ts = superb.ts and super.int_tag = superb.int_tag"\ - or sql == "select round(super.bigint_col) from super, superb where super.ts = superb.ts and super.int_tag = superb.int_tag"\ - or sql == "select round(super.smallint_col) from super, superb where super.ts = superb.ts and super.int_tag = superb.int_tag"\ - or sql == "select round(super.tinyint_col) from super, superb where super.ts = superb.ts and super.int_tag = superb.int_tag"\ - or sql == "select round(super.float_col) from super, superb where super.ts = superb.ts and super.int_tag = superb.int_tag"\ - or sql == "select round(super.double_col) from super, superb where super.ts = superb.ts and super.int_tag = superb.int_tag"\ - or sql == "select round(super.uint_col) from super, superb where super.ts = superb.ts and super.int_tag = superb.int_tag"\ - or sql == "select round(super.ubigint_col) from super, superb where super.ts = superb.ts and super.int_tag = superb.int_tag"\ - or sql == "select round(super.usmallint_col) from super, superb where super.ts = superb.ts and super.int_tag = superb.int_tag"\ - or sql == "select round(super.utinyint_col) from super, superb where super.ts = superb.ts and super.int_tag = superb.int_tag": + if sql in shouldPass2: tdSql.query(sql) else: - tdSql.error(sql) - + tdSql.error(sql) def stop(self): tdSql.close() tdLog.success("%s successfully executed" % __file__) diff --git a/tests/pytest/tag_lite/alter_tag.py b/tests/pytest/tag_lite/alter_tag.py index 9e5abb6c134840ecb4ab52c7d3a6ab623885e12b..c4d738e4cf0d9bd63f7813e9d267080f9f045fac 100644 --- a/tests/pytest/tag_lite/alter_tag.py +++ b/tests/pytest/tag_lite/alter_tag.py @@ -30,7 +30,7 @@ class TDTestCase: print("==============step1") tdSql.execute( - "CREATE TABLE IF NOT EXISTS ampere (ts TIMESTAMP(8),ampere DOUBLE(8)) TAGS (device_name BINARY(50),build_id BINARY(50),project_id BINARY(50),alias BINARY(50))") + "CREATE TABLE IF NOT EXISTS ampere (ts TIMESTAMP,ampere DOUBLE) TAGS (device_name BINARY(50),build_id BINARY(50),project_id BINARY(50),alias BINARY(50))") tdSql.execute("insert into d1001 using ampere tags('test', '2', '2', '2') VALUES (now, 123)") tdSql.execute("ALTER TABLE ampere ADD TAG variable_id BINARY(50)") diff --git a/tests/script/fullGeneralSuite.sim b/tests/script/fullGeneralSuite.sim index a5d8216de1d537843bef42fbf3752a45e899b5c3..6cec3895eb5e24bda398f8ce7472da83b403fbe7 100644 --- a/tests/script/fullGeneralSuite.sim +++ b/tests/script/fullGeneralSuite.sim @@ -38,6 +38,11 @@ run general/compute/stddev.sim run general/compute/sum.sim run general/compute/top.sim run general/compute/block_dist.sim +run general/compute/math_funcs.sim +run general/compute/string_funcs.sim +run general/compute/scalar_pow.sim +run general/compute/scalar_triangle.sim +run general/compute/scalar_str_concat_len.sim run general/compute/table_group.sim run general/db/alter_option.sim run general/db/alter_tables_d2.sim @@ -140,6 +145,7 @@ run general/parser/groupby.sim run general/parser/top_groupby.sim run general/parser/tags_dynamically_specifiy.sim run general/parser/set_tag_vals.sim +run general/parser/scalar_expression.sim #unsupport run general/parser/repeatAlter.sim #unsupport run general/parser/slimit_alter_tags.sim run general/parser/precision_ns.sim diff --git a/tests/script/general/compute/cast.sim b/tests/script/general/compute/cast.sim new file mode 100644 index 0000000000000000000000000000000000000000..729d6808a53e8db4ee17eb1e38ed94aca91ac1ef --- /dev/null +++ b/tests/script/general/compute/cast.sim @@ -0,0 +1,106 @@ +system sh/stop_dnodes.sh + +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/cfg.sh -n dnode1 -c maxtablespervnode -v 6 +system sh/cfg.sh -n dnode1 -c cache -v 1 +system sh/cfg.sh -n dnode1 -c minRows -v 10 +system sh/exec.sh -n dnode1 -s start + +sleep 100 +sql connect + +sql drop database if exists db +sql create database if not exists db +sql use db +sql create table stb1 (ts timestamp, c1 bool, c2 tinyint, c3 smallint, c4 int, c5 bigint, c6 float, c7 double, c8 binary(10), c9 nchar(10), c10 tinyint unsigned, c11 smallint unsigned, c12 int unsigned, c13 bigint unsigned) TAGS(t1 int, t2 binary(10), t3 double); + +sql create table tb1 using stb1 tags(1,'1',1.0); +sql create table tb2 using stb1 tags(2,'2',2.0); +sql create table tb3 using stb1 tags(3,'3',3.0); + +sql insert into tb1 values ('2021-11-11 09:00:00',true,1,1,1,1,1,1,"123","1234",1,1,1,1); +sql insert into tb1 values ('2021-11-11 09:00:01',true,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL); +sql insert into tb1 values ('2021-11-11 09:00:02',true,2,NULL,2,NULL,2,NULL,"234",NULL,2,NULL,2,NULL); +sql insert into tb1 values ('2021-11-11 09:00:03',false,NULL,3,NULL,3,NULL,3,NULL,"3456",NULL,3,NULL,3); +sql insert into tb1 values ('2021-11-11 09:00:04',true,4,4,4,4,4,4,"456","4567",4,4,4,4); +sql insert into tb1 values ('2021-11-11 09:00:05',true,127,32767,2147483647,9223372036854775807,3.402823466e+38,1.79769e+308,"567","5678",254,65534,4294967294,9223372036854775807); +sql insert into tb1 values ('2021-11-11 09:00:06',true,-127,-32767,-2147483647,-9223372036854775807,-3.402823466e+38,-1.79769e+308,"678","6789",0,0,0,0); + +sql insert into tb2 values ('2021-11-11 09:00:00',true,1,1,1,1,1,1,"111","1111",1,1,1,1); +sql insert into tb2 values ('2021-11-11 09:00:01',true,2,2,2,2,2,2,"222","2222",2,2,2,2); +sql insert into tb2 values ('2021-11-11 09:00:02',true,3,3,2,3,3,3,"333","3333",3,3,3,3); +sql insert into tb2 values ('2021-11-11 09:00:03',false,4,4,4,4,4,4,"444","4444",4,4,4,4); +sql insert into tb2 values ('2021-11-11 09:00:04',true,5,5,5,5,5,5,"555","5555",5,5,5,5); +sql insert into tb2 values ('2021-11-11 09:00:05',true,6,6,6,6,6,6,"666","6666",6,6,6,6); +sql insert into tb2 values ('2021-11-11 09:00:06',true,7,7,7,7,7,7,"777","7777",7,7,7,7); + +sql create table tbn (ts timestamp, c1 bool, c2 tinyint, c3 smallint, c4 int, c5 bigint, c6 float, c7 double, c8 binary(10), c9 nchar(10), c10 tinyint unsigned, c11 smallint unsigned, c12 int unsigned, c13 bigint unsigned); + +sql insert into tbn values ('2021-11-11 09:00:00',true,1,1,1,1,1,1,"111","1111",1,1,1,1); +sql insert into tbn values ('2021-11-11 09:00:01',true,2,2,2,2,2,2,"222","2222",2,2,2,2); +sql insert into tbn values ('2021-11-11 09:00:02',true,3,3,2,3,3,3,"333","3333",3,3,3,3); +sql insert into tbn values ('2021-11-11 09:00:03',false,4,4,4,4,4,4,"444","4444",4,4,4,4); +sql insert into tbn values ('2021-11-11 09:00:04',true,5,5,5,5,5,5,"555","5555",5,5,5,5); +sql insert into tbn values ('2021-11-11 09:00:05',true,6,6,6,6,6,6,"666","6666",6,6,6,6); +sql insert into tbn values ('2021-11-11 09:00:06',true,7,7,7,7,7,7,"777","7777",7,7,7,7); + +run general/compute/cast_query1.sim +run general/compute/cast_query2.sim + + +sql create table stba (ts timestamp, c1 bool, c2 tinyint, c3 smallint, c4 int, c5 bigint, c6 float, c7 double, c8 binary(10), c9 nchar(10), c10 tinyint unsigned, c11 smallint unsigned, c12 int unsigned, c13 bigint unsigned) TAGS(t1 int, t2 binary(10), t3 double); + +sql create table tba1 using stba tags(1,'1',1.0); + +sql insert into tba1 values ('2021-11-11 09:00:00',true, 1,1,1,1,1,1,"111","1111",1,1,1,1); +sql insert into tba1 values ('2021-11-11 09:00:01',true, 2,2,2,2,2,2,"222","2222",2,2,2,2); +sql insert into tba1 values ('2021-11-11 09:00:02',true, 3,3,2,3,3,3,"333","3333",3,3,3,3); +sql insert into tba1 values ('2021-11-11 09:00:03',false,4,4,4,4,4,4,"444","4444",4,4,4,4); +sql insert into tba1 values ('2021-11-11 09:00:04',true, 5,5,5,5,5,5,"555","5555",5,5,5,5); +sql insert into tba1 values ('2021-11-11 09:00:05',true, 6,6,6,6,6,6,"666","6666",6,6,6,6); +sql insert into tba1 values ('2021-11-11 09:00:06',true, 7,7,7,7,7,7,"777","7777",7,7,7,7); +sql insert into tba1 values ('2021-11-11 09:00:07',true, 8,8,8,8,8,8,"888","8888",8,8,8,8); +sql insert into tba1 values ('2021-11-11 09:00:08',true, 9,9,9,9,9,9,"999","9999",9,9,9,9); +sql insert into tba1 values ('2021-11-11 09:00:09',true, 0,0,0,0,0,0,"000","0000",0,0,0,0); + +print ================== restart server to commit data into disk +system sh/exec.sh -n dnode1 -s stop -x SIGINT +sleep 500 +system sh/exec.sh -n dnode1 -s start +print ================== server restart completed + +sql insert into tba1 values ('2021-11-11 09:00:10',true, 1,1,1,1,1,1,"111","1111",1,1,1,1); +sql insert into tba1 values ('2021-11-11 09:00:11',true, 2,2,2,2,2,2,"222","2222",2,2,2,2); +sql insert into tba1 values ('2021-11-11 09:00:12',true, 3,3,2,3,3,3,"333","3333",3,3,3,3); +sql insert into tba1 values ('2021-11-11 09:00:13',false,4,4,4,4,4,4,"444","4444",4,4,4,4); +sql insert into tba1 values ('2021-11-11 09:00:14',true, 5,5,5,5,5,5,"555","5555",5,5,5,5); +sql insert into tba1 values ('2021-11-11 09:00:15',true, 6,6,6,6,6,6,"666","6666",6,6,6,6); +sql insert into tba1 values ('2021-11-11 09:00:16',true, 7,7,7,7,7,7,"777","7777",7,7,7,7); +sql insert into tba1 values ('2021-11-11 09:00:17',true, 8,8,8,8,8,8,"888","8888",8,8,8,8); +sql insert into tba1 values ('2021-11-11 09:00:18',true, 9,9,9,9,9,9,"999","9999",9,9,9,9); +sql insert into tba1 values ('2021-11-11 09:00:19',true, 0,0,0,0,0,0,"000","0000",0,0,0,0); + +print ================== restart server to commit data into disk +system sh/exec.sh -n dnode1 -s stop -x SIGINT +sleep 500 +system sh/exec.sh -n dnode1 -s start +print ================== server restart completed + +sql insert into tba1 values ('2021-11-11 09:00:20',true, 1,1,1,1,1,1,"111","1111",1,1,1,1); +sql insert into tba1 values ('2021-11-11 09:00:21',true, 2,2,2,2,2,2,"222","2222",2,2,2,2); +sql insert into tba1 values ('2021-11-11 09:00:22',true, 3,3,2,3,3,3,"333","3333",3,3,3,3); +sql insert into tba1 values ('2021-11-11 09:00:23',false,4,4,4,4,4,4,"444","4444",4,4,4,4); +sql insert into tba1 values ('2021-11-11 09:00:24',true, 5,5,5,5,5,5,"555","5555",5,5,5,5); +sql insert into tba1 values ('2021-11-11 09:00:25',true, 6,6,6,6,6,6,"666","6666",6,6,6,6); +sql insert into tba1 values ('2021-11-11 09:00:26',true, 7,7,7,7,7,7,"777","7777",7,7,7,7); +sql insert into tba1 values ('2021-11-11 09:00:27',true, 8,8,8,8,8,8,"888","8888",8,8,8,8); +sql insert into tba1 values ('2021-11-11 09:00:28',true, 9,9,9,9,9,9,"999","9999",9,9,9,9); +sql insert into tba1 values ('2021-11-11 09:00:29',true, 0,0,0,0,0,0,"000","0000",0,0,0,0); + +run general/compute/cast_query1.sim +run general/compute/cast_query2.sim +run general/compute/cast_query3.sim + +#system sh/exec.sh -n dnode1 -s stop -x SIGINT + diff --git a/tests/script/general/compute/cast_query1.sim b/tests/script/general/compute/cast_query1.sim new file mode 100644 index 0000000000000000000000000000000000000000..de0722bcd8c3911d94b4558c302c22bbc607defd --- /dev/null +++ b/tests/script/general/compute/cast_query1.sim @@ -0,0 +1,2454 @@ +sleep 100 +sql connect + +sql use db; + +print "test negative cases" + +sql_error select cast(* as tinyint) from tb1; +sql_error select cast(* as smallint) from tb1; +sql_error select cast(* as int) from tb1; +sql_error select cast(* as bool) from tb1; +sql_error select cast(* as bigint) as a from tb1; +sql_error select cast(* as bigint) + 1 as a from tb1; +sql_error select cast(tb1.* as bigint) + 1 as a from tb1; +sql_error select cast(* as bigint) from tb1; +sql_error select cast(c1 as binary(16384)) from tb1; +sql_error select cast(c1 as nchar(16384)) from tb1; +sql_error select cast(c1 + c2 as bigint) from tb1; +sql_error select cast(13 as binary(0)) from tb1; +sql_error select cast(12 as binary(-1)) from tb1; +sql_error select cast(11 as nchar(0)) from tb1; +sql_error select cast(10 as nchar(-1)) from tb1; +sql_error select cast(11 as tinyint) from tb1; +sql_error select cast(11 as bool) from tb1; +sql_error select cast(11 as smallint) from tb1; +sql_error select cast(11 as int) from tb1; +sql_error select cast(11 as float) from tb1; +sql_error select cast(11 as double) from tb1; +sql_error select cast(11 as tinyint unsigned) from tb1; +sql_error select cast(11 as smallint unsigned) from tb1; +sql_error select cast(11 as int unsigned) from tb1; +sql_error select cast(c1 as binary(0)) from tb1; +sql_error select cast(c1 as binary(-1)) from tb1; +sql_error select cast(c1 as nchar(0)) from tb1; +sql_error select cast(c1 as nchar(-1)) from tb1; +sql_error select cast(c1 as tinyint) from tb1; +sql_error select cast(c1 as bool) from tb1; +sql_error select cast(c1 as smallint) from tb1; +sql_error select cast(c1 as int) from tb1; +sql_error select cast(c1 as float) from tb1; +sql_error select cast(c1 as double) from tb1; +sql_error select cast(c1 as tinyint unsigned) from tb1; +sql_error select cast(c1 as smallint unsigned) from tb1; +sql_error select cast(c1 as int unsigned) from tb1; +sql_error select cast(c2 as binary(0)) from tb1; +sql_error select cast(c2 as binary(-1)) from tb1; +sql_error select cast(c2 as nchar(0)) from tb1; +sql_error select cast(c2 as nchar(-1)) from tb1; +sql_error select cast(c2 as tinyint) from tb1; +sql_error select cast(c2 as bool) from tb1; +sql_error select cast(c2 as smallint) from tb1; +sql_error select cast(c2 as int) from tb1; +sql_error select cast(c2 as float) from tb1; +sql_error select cast(c2 as double) from tb1; +sql_error select cast(c2 as tinyint unsigned) from tb1; +sql_error select cast(c2 as smallint unsigned) from tb1; +sql_error select cast(c2 as int unsigned) from tb1; +sql_error select cast(c3 as binary(0)) from tb1; +sql_error select cast(c3 as binary(-1)) from tb1; +sql_error select cast(c3 as nchar(0)) from tb1; +sql_error select cast(c3 as nchar(-1)) from tb1; +sql_error select cast(c3 as tinyint) from tb1; +sql_error select cast(c3 as bool) from tb1; +sql_error select cast(c3 as smallint) from tb1; +sql_error select cast(c3 as int) from tb1; +sql_error select cast(c3 as float) from tb1; +sql_error select cast(c3 as double) from tb1; +sql_error select cast(c3 as tinyint unsigned) from tb1; +sql_error select cast(c3 as smallint unsigned) from tb1; +sql_error select cast(c3 as int unsigned) from tb1; +sql_error select cast(c4 as binary(0)) from tb1; +sql_error select cast(c4 as binary(-1)) from tb1; +sql_error select cast(c4 as nchar(0)) from tb1; +sql_error select cast(c4 as nchar(-1)) from tb1; +sql_error select cast(c4 as tinyint) from tb1; +sql_error select cast(c4 as bool) from tb1; +sql_error select cast(c4 as smallint) from tb1; +sql_error select cast(c4 as int) from tb1; +sql_error select cast(c4 as float) from tb1; +sql_error select cast(c4 as double) from tb1; +sql_error select cast(c4 as tinyint unsigned) from tb1; +sql_error select cast(c4 as smallint unsigned) from tb1; +sql_error select cast(c4 as int unsigned) from tb1; +sql_error select cast(c5 as binary(0)) from tb1; +sql_error select cast(c5 as binary(-1)) from tb1; +sql_error select cast(c5 as nchar(0)) from tb1; +sql_error select cast(c5 as nchar(-1)) from tb1; +sql_error select cast(c5 as tinyint) from tb1; +sql_error select cast(c5 as bool) from tb1; +sql_error select cast(c5 as smallint) from tb1; +sql_error select cast(c5 as int) from tb1; +sql_error select cast(c5 as float) from tb1; +sql_error select cast(c5 as double) from tb1; +sql_error select cast(c5 as tinyint unsigned) from tb1; +sql_error select cast(c5 as smallint unsigned) from tb1; +sql_error select cast(c5 as int unsigned) from tb1; +sql_error select cast(c6 as binary(0)) from tb1; +sql_error select cast(c6 as binary(-1)) from tb1; +sql_error select cast(c6 as nchar(0)) from tb1; +sql_error select cast(c6 as nchar(-1)) from tb1; +sql_error select cast(c6 as tinyint) from tb1; +sql_error select cast(c6 as bool) from tb1; +sql_error select cast(c6 as smallint) from tb1; +sql_error select cast(c6 as int) from tb1; +sql_error select cast(c6 as float) from tb1; +sql_error select cast(c6 as double) from tb1; +sql_error select cast(c6 as tinyint unsigned) from tb1; +sql_error select cast(c6 as smallint unsigned) from tb1; +sql_error select cast(c6 as int unsigned) from tb1; +sql_error select cast(c7 as binary(0)) from tb1; +sql_error select cast(c7 as binary(-1)) from tb1; +sql_error select cast(c7 as nchar(0)) from tb1; +sql_error select cast(c7 as nchar(-1)) from tb1; +sql_error select cast(c7 as tinyint) from tb1; +sql_error select cast(c7 as bool) from tb1; +sql_error select cast(c7 as smallint) from tb1; +sql_error select cast(c7 as int) from tb1; +sql_error select cast(c7 as float) from tb1; +sql_error select cast(c7 as double) from tb1; +sql_error select cast(c7 as tinyint unsigned) from tb1; +sql_error select cast(c7 as smallint unsigned) from tb1; +sql_error select cast(c7 as int unsigned) from tb1; +sql_error select cast(c8 as binary(0)) from tb1; +sql_error select cast(c8 as binary(-1)) from tb1; +sql_error select cast(c8 as nchar(0)) from tb1; +sql_error select cast(c8 as nchar(-1)) from tb1; +sql_error select cast(c8 as tinyint) from tb1; +sql_error select cast(c8 as bool) from tb1; +sql_error select cast(c8 as smallint) from tb1; +sql_error select cast(c8 as int) from tb1; +sql_error select cast(c8 as float) from tb1; +sql_error select cast(c8 as double) from tb1; +sql_error select cast(c8 as tinyint unsigned) from tb1; +sql_error select cast(c8 as smallint unsigned) from tb1; +sql_error select cast(c8 as int unsigned) from tb1; +sql_error select cast(c8 as timestamp) from tb1; +sql_error select cast(c9 as binary(0)) from tb1; +sql_error select cast(c9 as binary(-1)) from tb1; +sql_error select cast(c9 as nchar(0)) from tb1; +sql_error select cast(c9 as nchar(-1)) from tb1; +sql_error select cast(c9 as tinyint) from tb1; +sql_error select cast(c9 as bool) from tb1; +sql_error select cast(c9 as smallint) from tb1; +sql_error select cast(c9 as int) from tb1; +sql_error select cast(c9 as float) from tb1; +sql_error select cast(c9 as double) from tb1; +sql_error select cast(c9 as tinyint unsigned) from tb1; +sql_error select cast(c9 as smallint unsigned) from tb1; +sql_error select cast(c9 as int unsigned) from tb1; +sql_error select cast(c9 as timestamp) from tb1; +sql_error select cast(c9 as binary(5)) from tb1; +sql_error select cast(c10 as binary(0)) from tb1; +sql_error select cast(c10 as binary(-1)) from tb1; +sql_error select cast(c10 as nchar(0)) from tb1; +sql_error select cast(c10 as nchar(-1)) from tb1; +sql_error select cast(c10 as tinyint) from tb1; +sql_error select cast(c10 as bool) from tb1; +sql_error select cast(c10 as smallint) from tb1; +sql_error select cast(c10 as int) from tb1; +sql_error select cast(c10 as float) from tb1; +sql_error select cast(c10 as double) from tb1; +sql_error select cast(c10 as tinyint unsigned) from tb1; +sql_error select cast(c10 as smallint unsigned) from tb1; +sql_error select cast(c10 as int unsigned) from tb1; +sql_error select cast(c11 as binary(0)) from tb1; +sql_error select cast(c11 as binary(-1)) from tb1; +sql_error select cast(c11 as nchar(0)) from tb1; +sql_error select cast(c11 as nchar(-1)) from tb1; +sql_error select cast(c11 as tinyint) from tb1; +sql_error select cast(c11 as bool) from tb1; +sql_error select cast(c11 as smallint) from tb1; +sql_error select cast(c11 as int) from tb1; +sql_error select cast(c11 as float) from tb1; +sql_error select cast(c11 as double) from tb1; +sql_error select cast(c11 as tinyint unsigned) from tb1; +sql_error select cast(c11 as smallint unsigned) from tb1; +sql_error select cast(c11 as int unsigned) from tb1; +sql_error select cast(c12 as binary(0)) from tb1; +sql_error select cast(c12 as binary(-1)) from tb1; +sql_error select cast(c12 as nchar(0)) from tb1; +sql_error select cast(c12 as nchar(-1)) from tb1; +sql_error select cast(c12 as tinyint) from tb1; +sql_error select cast(c12 as bool) from tb1; +sql_error select cast(c12 as smallint) from tb1; +sql_error select cast(c12 as int) from tb1; +sql_error select cast(c12 as float) from tb1; +sql_error select cast(c12 as double) from tb1; +sql_error select cast(c12 as tinyint unsigned) from tb1; +sql_error select cast(c12 as smallint unsigned) from tb1; +sql_error select cast(c12 as int unsigned) from tb1; +sql_error select cast(c13 as binary(0)) from tb1; +sql_error select cast(c13 as binary(-1)) from tb1; +sql_error select cast(c13 as nchar(0)) from tb1; +sql_error select cast(c13 as nchar(-1)) from tb1; +sql_error select cast(c13 as tinyint) from tb1; +sql_error select cast(c13 as bool) from tb1; +sql_error select cast(c13 as smallint) from tb1; +sql_error select cast(c13 as int) from tb1; +sql_error select cast(c13 as float) from tb1; +sql_error select cast(c13 as double) from tb1; +sql_error select cast(c13 as tinyint unsigned) from tb1; +sql_error select cast(c13 as smallint unsigned) from tb1; +sql_error select cast(c13 as int unsigned) from tb1; +sql_error select cast(12345678900000000000000000 as binary(10)) from tb1; +sql_error select distinct cast("-abc" as bigint unsigned) from tb1; +sql_error select cast(c1) from tb1; +sql_error select cast(t1 as bigint) from stb1; +sql_error select cast(c2 as bigint)+avg(c2) from tb1; +sql_error select cast(c2 as bigint)+top(c2,1) from tb1; +sql_error select cast(c1 as bigint),avg(c3) from tb1; +sql_error select cast(c1 as bigint),top(c3,1) from tb1; +sql_error select cast(c2+c3 as binary(6)) from tb1 session(ts, 1s); +sql_error select cast(c2+c3 as binary(6)) from tb1 STATE_WINDOW(c1); +sql_error select cast(c2+c3 as binary(6)) from tb1 interval(1s) sliding(1s) fill(NULL); +sql_error select cast(c2+c3 as binary(6)) from stb1 group by t1; +sql_error select cast(c2+c3 as binary(6)) from stb1 group by ts; +sql_error select cast(c2+c3 as binary(6)) from stb1 group by c1; +sql_error select cast(c2+c3 as binary(6)) from stb1 group by tbname; +sql_error select cast(c2+c3 as binary(6)) from tb1 order by c2; +sql_error select cast(c8 as bigint),cast(c9 as bigint(12)) from tbn; +sql_error select cast(ts as binary(10)) from (select avg(c2) as a from stb1 interval(1s)); +sql_error select cast(a as timestamp) from (select cast(c2 as binary(2)) as a from tb1); + +print "test constant" + +sql select cast(13 as bigint) from tb1; +if $rows != 7 then + return -1 +endi +if $data00 != 13 then + return -1 +endi +if $data10 != 13 then + return -1 +endi +sql select cast(13 as timestamp) from tb1; +if $rows != 7 then + return -1 +endi +if $data00 != @70-01-01 08:00:00.013@ then + return -1 +endi +if $data10 != @70-01-01 08:00:00.013@ then + return -1 +endi +sql select cast("abc" as bigint unsigned) from tb1; +if $rows != 7 then + return -1 +endi +if $data00 != 0 then + return -1 +endi +if $data10 != 0 then + return -1 +endi +print "test bool column" + +sql select cast(c1 as bigint) from tb1; +if $rows != 7 then + return -1 +endi +if $data00 != 1 then + return -1 +endi +if $data10 != 1 then + return -1 +endi +if $data20 != 1 then + return -1 +endi +if $data30 != 0 then + return -1 +endi +if $data40 != 1 then + return -1 +endi +if $data50 != 1 then + return -1 +endi +if $data60 != 1 then + return -1 +endi +sql select cast(c1 as binary(10)) from tb1; +if $rows != 7 then + return -1 +endi +if $data00 != true then + return -1 +endi +if $data10 != true then + return -1 +endi +if $data20 != true then + return -1 +endi +if $data30 != false then + return -1 +endi +if $data40 != true then + return -1 +endi +if $data50 != true then + return -1 +endi +if $data60 != true then + return -1 +endi +sql select cast(c1 as binary(1)) from tb1; +if $rows != 7 then + return -1 +endi +if $data00 != t then + return -1 +endi +if $data10 != t then + return -1 +endi +if $data20 != t then + return -1 +endi +if $data30 != f then + return -1 +endi +if $data40 != t then + return -1 +endi +if $data50 != t then + return -1 +endi +if $data60 != t then + return -1 +endi +sql select cast(c1 as timestamp) from tb1; +if $rows != 7 then + return -1 +endi +if $data00 != @70-01-01 08:00:00.001@ then + return -1 +endi +if $data10 != @70-01-01 08:00:00.001@ then + return -1 +endi +if $data20 != @70-01-01 08:00:00.001@ then + return -1 +endi +if $data30 != @70-01-01 08:00:00.000@ then + return -1 +endi +if $data40 != @70-01-01 08:00:00.001@ then + return -1 +endi +if $data50 != @70-01-01 08:00:00.001@ then + return -1 +endi +if $data60 != @70-01-01 08:00:00.001@ then + return -1 +endi +sql select cast(c1 as nchar(10)) from tb1; +if $rows != 7 then + return -1 +endi +if $data00 != true then + return -1 +endi +if $data10 != true then + return -1 +endi +if $data20 != true then + return -1 +endi +if $data30 != false then + return -1 +endi +if $data40 != true then + return -1 +endi +if $data50 != true then + return -1 +endi +if $data60 != true then + return -1 +endi +sql select cast(c1 as nchar(1)) from tb1; +if $rows != 7 then + return -1 +endi +if $data00 != t then + return -1 +endi +if $data10 != t then + return -1 +endi +if $data20 != t then + return -1 +endi +if $data30 != f then + return -1 +endi +if $data40 != t then + return -1 +endi +if $data50 != t then + return -1 +endi +if $data60 != t then + return -1 +endi +sql select cast(c1 as bigint unsigned) from tb1; +if $rows != 7 then + return -1 +endi +if $data00 != 1 then + return -1 +endi +if $data10 != 1 then + return -1 +endi +if $data20 != 1 then + return -1 +endi +if $data30 != 0 then + return -1 +endi +if $data40 != 1 then + return -1 +endi +if $data50 != 1 then + return -1 +endi +if $data60 != 1 then + return -1 +endi + +print "test tinyint column" + +sql select cast(c2 as bigint) from tb1; +if $rows != 7 then + return -1 +endi +if $data00 != 1 then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data20 != 2 then + return -1 +endi +if $data30 != NULL then + return -1 +endi +if $data40 != 4 then + return -1 +endi +if $data50 != 127 then + return -1 +endi +if $data60 != -127 then + return -1 +endi +sql select cast(c2 as binary(10)) from tb1; +if $rows != 7 then + return -1 +endi +if $data00 != 1 then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data20 != 2 then + return -1 +endi +if $data30 != NULL then + return -1 +endi +if $data40 != 4 then + return -1 +endi +if $data50 != 127 then + return -1 +endi +if $data60 != -127 then + return -1 +endi +sql select cast(c2 as binary(1)) from tb1; +if $rows != 7 then + return -1 +endi +if $data00 != 1 then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data20 != 2 then + return -1 +endi +if $data30 != NULL then + return -1 +endi +if $data40 != 4 then + return -1 +endi +if $data50 != 1 then + return -1 +endi +if $data60 != - then + return -1 +endi +sql select cast(c2 as timestamp) from tb1; +if $rows != 7 then + return -1 +endi +if $data00 != @70-01-01 08:00:00.001@ then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data20 != @70-01-01 08:00:00.002@ then + return -1 +endi +if $data30 != NULL then + return -1 +endi +if $data40 != @70-01-01 08:00:00.004@ then + return -1 +endi +if $data50 != @70-01-01 08:00:00.127@ then + return -1 +endi +if $data60 != @70-01-01 08:00:00.-127@ then + return -1 +endi +sql select cast(c2 as nchar(10)) from tb1; +if $rows != 7 then + return -1 +endi +if $data00 != 1 then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data20 != 2 then + return -1 +endi +if $data30 != NULL then + return -1 +endi +if $data40 != 4 then + return -1 +endi +if $data50 != 127 then + return -1 +endi +if $data60 != -127 then + return -1 +endi +sql select cast(c2 as nchar(1)) from tb1; +if $rows != 7 then + return -1 +endi +if $data00 != 1 then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data20 != 2 then + return -1 +endi +if $data30 != NULL then + return -1 +endi +if $data40 != 4 then + return -1 +endi +if $data50 != 1 then + return -1 +endi +if $data60 != - then + return -1 +endi +sql select cast(c2 as bigint unsigned) from tb1; +if $rows != 7 then + return -1 +endi +if $data00 != 1 then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data20 != 2 then + return -1 +endi +if $data30 != NULL then + return -1 +endi +if $data40 != 4 then + return -1 +endi +if $data50 != 127 then + return -1 +endi +if $data60 != 18446744073709551489 then + return -1 +endi + +print "test smallint column" + +sql select cast(c3 as bigint) from tb1; +if $rows != 7 then + return -1 +endi +if $data00 != 1 then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data20 != NULL then + return -1 +endi +if $data30 != 3 then + return -1 +endi +if $data40 != 4 then + return -1 +endi +if $data50 != 32767 then + return -1 +endi +if $data60 != -32767 then + return -1 +endi +sql select cast(c3 as binary(10)) from tb1; +if $rows != 7 then + return -1 +endi +if $data00 != 1 then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data20 != NULL then + return -1 +endi +if $data30 != 3 then + return -1 +endi +if $data40 != 4 then + return -1 +endi +if $data50 != 32767 then + return -1 +endi +if $data60 != -32767 then + return -1 +endi +sql select cast(c3 as binary(2)) from tb1; +if $rows != 7 then + return -1 +endi +if $data00 != 1 then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data20 != NULL then + return -1 +endi +if $data30 != 3 then + return -1 +endi +if $data40 != 4 then + return -1 +endi +if $data50 != 32 then + return -1 +endi +if $data60 != -3 then + return -1 +endi +sql select cast(c3 as timestamp) from tb1; +if $rows != 7 then + return -1 +endi +if $data00 != @70-01-01 08:00:00.001@ then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data20 != NULL then + return -1 +endi +if $data30 != @70-01-01 08:00:00.003@ then + return -1 +endi +if $data40 != @70-01-01 08:00:00.004@ then + return -1 +endi +if $data50 != @70-01-01 08:00:32.767@ then + return -1 +endi +if $data60 != @70-01-01 07:59:28.-767@ then + return -1 +endi +sql select cast(c3 as nchar(10)) from tb1; +if $rows != 7 then + return -1 +endi +if $data00 != 1 then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data20 != NULL then + return -1 +endi +if $data30 != 3 then + return -1 +endi +if $data40 != 4 then + return -1 +endi +if $data50 != 32767 then + return -1 +endi +if $data60 != -32767 then + return -1 +endi +sql select cast(c3 as nchar(3)) from tb1; +if $rows != 7 then + return -1 +endi +if $data00 != 1 then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data20 != NULL then + return -1 +endi +if $data30 != 3 then + return -1 +endi +if $data40 != 4 then + return -1 +endi +if $data50 != 327 then + return -1 +endi +if $data60 != -32 then + return -1 +endi +sql select cast(c3 as bigint unsigned) from tb1; +if $rows != 7 then + return -1 +endi +if $data00 != 1 then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data20 != NULL then + return -1 +endi +if $data30 != 3 then + return -1 +endi +if $data40 != 4 then + return -1 +endi +if $data50 != 32767 then + return -1 +endi +if $data60 != 18446744073709518849 then + return -1 +endi + +print "test int column" + +sql select cast(c4 as bigint) from tb1; +if $rows != 7 then + return -1 +endi +if $data00 != 1 then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data20 != 2 then + return -1 +endi +if $data30 != NULL then + return -1 +endi +if $data40 != 4 then + return -1 +endi +if $data50 != 2147483647 then + return -1 +endi +if $data60 != -2147483647 then + return -1 +endi +sql select cast(c4 as binary(10)) from tb1; +if $rows != 7 then + return -1 +endi +if $data00 != 1 then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data20 != 2 then + return -1 +endi +if $data30 != NULL then + return -1 +endi +if $data40 != 4 then + return -1 +endi +if $data50 != 2147483647 then + return -1 +endi +if $data60 != -214748364 then + return -1 +endi +sql select cast(c4 as binary(5)) from tb1; +if $rows != 7 then + return -1 +endi +if $data00 != 1 then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data20 != 2 then + return -1 +endi +if $data30 != NULL then + return -1 +endi +if $data40 != 4 then + return -1 +endi +if $data50 != 21474 then + return -1 +endi +if $data60 != -2147 then + return -1 +endi +sql select cast(c4 as timestamp) from tb1; +if $rows != 7 then + return -1 +endi +if $data00 != @70-01-01 08:00:00.001@ then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data20 != @70-01-01 08:00:00.002@ then + return -1 +endi +if $data30 != NULL then + return -1 +endi +if $data40 != @70-01-01 08:00:00.004@ then + return -1 +endi +if $data50 != @70-01-26 04:31:23.647@ then + return -1 +endi +if $data60 != @69-12-07 11:28:37.-647@ then + return -1 +endi +sql select cast(c4 as nchar(13)) from tb1; +if $rows != 7 then + return -1 +endi +if $data00 != 1 then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data20 != 2 then + return -1 +endi +if $data30 != NULL then + return -1 +endi +if $data40 != 4 then + return -1 +endi +if $data50 != 2147483647 then + return -1 +endi +if $data60 != -2147483647 then + return -1 +endi +sql select cast(c4 as nchar(3)) from tb1; +if $rows != 7 then + return -1 +endi +if $data00 != 1 then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data20 != 2 then + return -1 +endi +if $data30 != NULL then + return -1 +endi +if $data40 != 4 then + return -1 +endi +if $data50 != 214 then + return -1 +endi +if $data60 != -21 then + return -1 +endi +sql select cast(c4 as bigint unsigned) from tb1; +if $rows != 7 then + return -1 +endi +if $data00 != 1 then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data20 != 2 then + return -1 +endi +if $data30 != NULL then + return -1 +endi +if $data40 != 4 then + return -1 +endi +if $data50 != 2147483647 then + return -1 +endi +if $data60 != 18446744071562067969 then + return -1 +endi + +print "test bigint column" + +sql select cast(c5 as bigint) from tb1; +if $rows != 7 then + return -1 +endi +if $data00 != 1 then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data20 != NULL then + return -1 +endi +if $data30 != 3 then + return -1 +endi +if $data40 != 4 then + return -1 +endi +if $data50 != 9223372036854775807 then + return -1 +endi +if $data60 != -9223372036854775807 then + return -1 +endi +sql select cast(c5 as binary(20)) from tb1; +if $rows != 7 then + return -1 +endi +if $data00 != 1 then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data20 != NULL then + return -1 +endi +if $data30 != 3 then + return -1 +endi +if $data40 != 4 then + return -1 +endi +if $data50 != 9223372036854775807 then + return -1 +endi +if $data60 != -9223372036854775807 then + return -1 +endi +sql select cast(c5 as binary(5)) from tb1; +if $rows != 7 then + return -1 +endi +if $data00 != 1 then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data20 != NULL then + return -1 +endi +if $data30 != 3 then + return -1 +endi +if $data40 != 4 then + return -1 +endi +if $data50 != 92233 then + return -1 +endi +if $data60 != -9223 then + return -1 +endi +sql select cast(c5 as timestamp) from tb1; +if $rows != 7 then + return -1 +endi +if $data00 != @70-01-01 08:00:00.001@ then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data20 != NULL then + return -1 +endi +if $data30 != @70-01-01 08:00:00.003@ then + return -1 +endi +if $data40 != @70-01-01 08:00:00.004@ then + return -1 +endi +sql select cast(c5 as nchar(20)) from tb1; +if $rows != 7 then + return -1 +endi +if $data00 != 1 then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data20 != NULL then + return -1 +endi +if $data30 != 3 then + return -1 +endi +if $data40 != 4 then + return -1 +endi +if $data50 != 9223372036854775807 then + return -1 +endi +if $data60 != -9223372036854775807 then + return -1 +endi +sql select cast(c5 as nchar(6)) from tb1; +if $rows != 7 then + return -1 +endi +if $data00 != 1 then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data20 != NULL then + return -1 +endi +if $data30 != 3 then + return -1 +endi +if $data40 != 4 then + return -1 +endi +if $data50 != 922337 then + return -1 +endi +if $data60 != -92233 then + return -1 +endi +sql select cast(c5 as bigint unsigned) from tb1; +if $rows != 7 then + return -1 +endi +if $data00 != 1 then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data20 != NULL then + return -1 +endi +if $data30 != 3 then + return -1 +endi +if $data40 != 4 then + return -1 +endi +if $data50 != 9223372036854775807 then + return -1 +endi +if $data60 != 9223372036854775809 then + return -1 +endi + +print "test float column" + +sql select cast(c6 as bigint) from tb1; +if $rows != 7 then + return -1 +endi +if $data00 != 1 then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data20 != 2 then + return -1 +endi +if $data30 != NULL then + return -1 +endi +if $data40 != 4 then + return -1 +endi +if $data50 != NULL then + return -1 +endi +if $data60 != NULL then + return -1 +endi +sql select cast(c6 as binary(60)) from tb1; +if $rows != 7 then + return -1 +endi +if $data00 != 1.000000 then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data20 != 2.000000 then + return -1 +endi +if $data30 != NULL then + return -1 +endi +if $data40 != 4.000000 then + return -1 +endi +if $data50 != 340282346638528859811704183484516925440.000000 then + return -1 +endi +if $data60 != -340282346638528859811704183484516925440.000000 then + return -1 +endi +sql select cast(c6 as binary(5)) from tb1; +if $rows != 7 then + return -1 +endi +if $data00 != 1.000 then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data20 != 2.000 then + return -1 +endi +if $data30 != NULL then + return -1 +endi +if $data40 != 4.000 then + return -1 +endi +if $data50 != 34028 then + return -1 +endi +if $data60 != -3402 then + return -1 +endi +sql select cast(c6 as timestamp) from tb1; +if $rows != 7 then + return -1 +endi +if $data00 != @70-01-01 08:00:00.001@ then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data20 != @70-01-01 08:00:00.002@ then + return -1 +endi +if $data30 != NULL then + return -1 +endi +if $data40 != @70-01-01 08:00:00.004@ then + return -1 +endi +if $data50 != NULL then + return -1 +endi +if $data60 != NULL then + return -1 +endi +sql select cast(c6 as nchar(50)) from tb1; +if $rows != 7 then + return -1 +endi +if $data00 != 1.000000 then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data20 != 2.000000 then + return -1 +endi +if $data30 != NULL then + return -1 +endi +if $data40 != 4.000000 then + return -1 +endi +if $data50 != 340282346638528859811704183484516925440.000000 then + return -1 +endi +if $data60 != -340282346638528859811704183484516925440.000000 then + return -1 +endi +sql select cast(c6 as nchar(6)) from tb1; +if $rows != 7 then + return -1 +endi +if $data00 != 1.0000 then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data20 != 2.0000 then + return -1 +endi +if $data30 != NULL then + return -1 +endi +if $data40 != 4.0000 then + return -1 +endi +if $data50 != 340282 then + return -1 +endi +if $data60 != -34028 then + return -1 +endi +sql select cast(c6 as bigint unsigned) from tb1; +if $rows != 7 then + return -1 +endi +if $data00 != 1 then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data20 != 2 then + return -1 +endi +if $data30 != NULL then + return -1 +endi +if $data40 != 4 then + return -1 +endi + + +print "test double column" + +sql select cast(c7 as bigint) from tb1; +if $rows != 7 then + return -1 +endi +if $data00 != 1 then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data20 != NULL then + return -1 +endi +if $data30 != 3 then + return -1 +endi +if $data40 != 4 then + return -1 +endi +if $data50 != NULL then + return -1 +endi +if $data60 != NULL then + return -1 +endi +sql select cast(c7 as binary(400)) from tb1; +if $rows != 7 then + return -1 +endi +if $data00 != 1.000000 then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data20 != NULL then + return -1 +endi +if $data30 != 3.000000 then + return -1 +endi +if $data40 != 4.000000 then + return -1 +endi +if $data50 != 179769000000000006323030492138942643493033036433685336215410983289126434148906289940615299632196609445533816320312774433484859900046491141051651091672734470972759941382582304802812882753059262973637182942535982636884444611376868582636745405553206881859340916340092953230149901406738427651121855107737424232448.000000 then + return -1 +endi +if $data60 != -179769000000000006323030492138942643493033036433685336215410983289126434148906289940615299632196609445533816320312774433484859900046491141051651091672734470972759941382582304802812882753059262973637182942535982636884444611376868582636745405553206881859340916340092953230149901406738427651121855107737424232448.000000 then + return -1 +endi +sql select cast(c7 as binary(5)) from tb1; +if $rows != 7 then + return -1 +endi +if $data00 != 1.000 then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data20 != NULL then + return -1 +endi +if $data30 != 3.000 then + return -1 +endi +if $data40 != 4.000 then + return -1 +endi +if $data50 != 17976 then + return -1 +endi +if $data60 != -1797 then + return -1 +endi +sql select cast(c7 as timestamp) from tb1; +if $rows != 7 then + return -1 +endi +if $data00 != @70-01-01 08:00:00.001@ then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data20 != NULL then + return -1 +endi +if $data30 != @70-01-01 08:00:00.003@ then + return -1 +endi +if $data40 != @70-01-01 08:00:00.004@ then + return -1 +endi +if $data50 != NULL then + return -1 +endi +if $data60 != NULL then + return -1 +endi +sql select cast(c7 as nchar(500)) from tb1; +if $rows != 7 then + return -1 +endi +if $data00 != 1.000000 then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data20 != NULL then + return -1 +endi +if $data30 != 3.000000 then + return -1 +endi +if $data40 != 4.000000 then + return -1 +endi +if $data50 != 179769000000000006323030492138942643493033036433685336215410983289126434148906289940615299632196609445533816320312774433484859900046491141051651091672734470972759941382582304802812882753059262973637182942535982636884444611376868582636745405553206881859340916340092953230149901406738427651121855107737424232448.000000 then + return -1 +endi +if $data60 != -179769000000000006323030492138942643493033036433685336215410983289126434148906289940615299632196609445533816320312774433484859900046491141051651091672734470972759941382582304802812882753059262973637182942535982636884444611376868582636745405553206881859340916340092953230149901406738427651121855107737424232448.000000 then + return -1 +endi +sql select cast(c7 as nchar(6)) from tb1; +if $rows != 7 then + return -1 +endi +if $data00 != 1.0000 then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data20 != NULL then + return -1 +endi +if $data30 != 3.0000 then + return -1 +endi +if $data40 != 4.0000 then + return -1 +endi +if $data50 != 179769 then + return -1 +endi +if $data60 != -17976 then + return -1 +endi +sql select cast(c7 as bigint unsigned) from tb1; +if $rows != 7 then + return -1 +endi +if $data00 != 1 then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data20 != NULL then + return -1 +endi +if $data30 != 3 then + return -1 +endi +if $data40 != 4 then + return -1 +endi + + +print "test binary column" + +sql select cast(c8 as bigint) from tb1; +if $rows != 7 then + return -1 +endi +if $data00 != 123 then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data20 != 234 then + return -1 +endi +if $data30 != NULL then + return -1 +endi +if $data40 != 456 then + return -1 +endi +if $data50 != 567 then + return -1 +endi +if $data60 != 678 then + return -1 +endi +sql select cast(c8 as binary(3)) from tb1; +if $rows != 7 then + return -1 +endi +if $data00 != 123 then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data20 != 234 then + return -1 +endi +if $data30 != NULL then + return -1 +endi +if $data40 != 456 then + return -1 +endi +if $data50 != 567 then + return -1 +endi +if $data60 != 678 then + return -1 +endi +sql select cast(c8 as binary(2)) from tb1; +if $rows != 7 then + return -1 +endi +if $data00 != 12 then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data20 != 23 then + return -1 +endi +if $data30 != NULL then + return -1 +endi +if $data40 != 45 then + return -1 +endi +if $data50 != 56 then + return -1 +endi +if $data60 != 67 then + return -1 +endi +sql select cast(c8 as nchar(4)) from tb1; +if $rows != 7 then + return -1 +endi +if $data00 != 123 then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data20 != 234 then + return -1 +endi +if $data30 != NULL then + return -1 +endi +if $data40 != 456 then + return -1 +endi +if $data50 != 567 then + return -1 +endi +if $data60 != 678 then + return -1 +endi +sql select cast(c8 as nchar(1)) from tb1; +if $rows != 7 then + return -1 +endi +if $data00 != 1 then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data20 != 2 then + return -1 +endi +if $data30 != NULL then + return -1 +endi +if $data40 != 4 then + return -1 +endi +if $data50 != 5 then + return -1 +endi +if $data60 != 6 then + return -1 +endi +sql select cast(c8 as bigint unsigned) from tb1; +if $rows != 7 then + return -1 +endi +if $data00 != 123 then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data20 != 234 then + return -1 +endi +if $data30 != NULL then + return -1 +endi +if $data40 != 456 then + return -1 +endi +if $data50 != 567 then + return -1 +endi +if $data60 != 678 then + return -1 +endi + + +print "test nchar column" + +sql select cast(c9 as bigint) from tb1; +if $rows != 7 then + return -1 +endi +if $data00 != 1234 then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data20 != NULL then + return -1 +endi +if $data30 != 3456 then + return -1 +endi +if $data40 != 4567 then + return -1 +endi +if $data50 != 5678 then + return -1 +endi +if $data60 != 6789 then + return -1 +endi +sql select cast(c9 as nchar(5)) from tb1; +if $rows != 7 then + return -1 +endi +if $data00 != 1234 then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data20 != NULL then + return -1 +endi +if $data30 != 3456 then + return -1 +endi +if $data40 != 4567 then + return -1 +endi +if $data50 != 5678 then + return -1 +endi +if $data60 != 6789 then + return -1 +endi +sql select cast(c9 as nchar(2)) from tb1; +if $rows != 7 then + return -1 +endi +if $data00 != 12 then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data20 != NULL then + return -1 +endi +if $data30 != 34 then + return -1 +endi +if $data40 != 45 then + return -1 +endi +if $data50 != 56 then + return -1 +endi +if $data60 != 67 then + return -1 +endi +sql select cast(c9 as bigint unsigned) from tb1; +if $rows != 7 then + return -1 +endi +if $data00 != 1234 then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data20 != NULL then + return -1 +endi +if $data30 != 3456 then + return -1 +endi +if $data40 != 4567 then + return -1 +endi +if $data50 != 5678 then + return -1 +endi +if $data60 != 6789 then + return -1 +endi + + +print "test utinyint column" + +sql select cast(c10 as bigint) from tb1; +if $rows != 7 then + return -1 +endi +if $data00 != 1 then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data20 != 2 then + return -1 +endi +if $data30 != NULL then + return -1 +endi +if $data40 != 4 then + return -1 +endi +if $data50 != 254 then + return -1 +endi +if $data60 != 0 then + return -1 +endi +sql select cast(c10 as binary(10)) from tb1; +if $rows != 7 then + return -1 +endi +if $data00 != 1 then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data20 != 2 then + return -1 +endi +if $data30 != NULL then + return -1 +endi +if $data40 != 4 then + return -1 +endi +if $data50 != 254 then + return -1 +endi +if $data60 != 0 then + return -1 +endi +sql select cast(c10 as binary(1)) from tb1; +if $rows != 7 then + return -1 +endi +if $data00 != 1 then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data20 != 2 then + return -1 +endi +if $data30 != NULL then + return -1 +endi +if $data40 != 4 then + return -1 +endi +if $data50 != 2 then + return -1 +endi +if $data60 != 0 then + return -1 +endi +sql select cast(c10 as timestamp) from tb1; +if $rows != 7 then + return -1 +endi +if $data00 != @70-01-01 08:00:00.001@ then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data20 != @70-01-01 08:00:00.002@ then + return -1 +endi +if $data30 != NULL then + return -1 +endi +if $data40 != @70-01-01 08:00:00.004@ then + return -1 +endi +if $data50 != @70-01-01 08:00:00.254@ then + return -1 +endi +if $data60 != @70-01-01 08:00:00.000@ then + return -1 +endi +sql select cast(c10 as nchar(10)) from tb1; +if $rows != 7 then + return -1 +endi +if $data00 != 1 then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data20 != 2 then + return -1 +endi +if $data30 != NULL then + return -1 +endi +if $data40 != 4 then + return -1 +endi +if $data50 != 254 then + return -1 +endi +if $data60 != 0 then + return -1 +endi +sql select cast(c10 as nchar(2)) from tb1; +if $rows != 7 then + return -1 +endi +if $data00 != 1 then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data20 != 2 then + return -1 +endi +if $data30 != NULL then + return -1 +endi +if $data40 != 4 then + return -1 +endi +if $data50 != 25 then + return -1 +endi +if $data60 != 0 then + return -1 +endi +sql select cast(c10 as bigint unsigned) from tb1; +if $rows != 7 then + return -1 +endi +if $data00 != 1 then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data20 != 2 then + return -1 +endi +if $data30 != NULL then + return -1 +endi +if $data40 != 4 then + return -1 +endi +if $data50 != 254 then + return -1 +endi +if $data60 != 0 then + return -1 +endi + + +print "test usmallint column" + +sql select cast(c11 as bigint) from tb1; +if $rows != 7 then + return -1 +endi +if $data00 != 1 then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data20 != NULL then + return -1 +endi +if $data30 != 3 then + return -1 +endi +if $data40 != 4 then + return -1 +endi +if $data50 != 65534 then + return -1 +endi +if $data60 != 0 then + return -1 +endi +sql select cast(c11 as binary(10)) from tb1; +if $rows != 7 then + return -1 +endi +if $data00 != 1 then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data20 != NULL then + return -1 +endi +if $data30 != 3 then + return -1 +endi +if $data40 != 4 then + return -1 +endi +if $data50 != 65534 then + return -1 +endi +if $data60 != 0 then + return -1 +endi +sql select cast(c11 as binary(1)) from tb1; +if $rows != 7 then + return -1 +endi +if $data00 != 1 then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data20 != NULL then + return -1 +endi +if $data30 != 3 then + return -1 +endi +if $data40 != 4 then + return -1 +endi +if $data50 != 6 then + return -1 +endi +if $data60 != 0 then + return -1 +endi +sql select cast(c11 as timestamp) from tb1; +if $rows != 7 then + return -1 +endi +if $data00 != @70-01-01 08:00:00.001@ then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data20 != NULL then + return -1 +endi +if $data30 != @70-01-01 08:00:00.003@ then + return -1 +endi +if $data40 != @70-01-01 08:00:00.004@ then + return -1 +endi +if $data50 != @70-01-01 08:01:05.534@ then + return -1 +endi +if $data60 != @70-01-01 08:00:00.000@ then + return -1 +endi +sql select cast(c11 as nchar(10)) from tb1; +if $rows != 7 then + return -1 +endi +if $data00 != 1 then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data20 != NULL then + return -1 +endi +if $data30 != 3 then + return -1 +endi +if $data40 != 4 then + return -1 +endi +if $data50 != 65534 then + return -1 +endi +if $data60 != 0 then + return -1 +endi +sql select cast(c11 as nchar(2)) from tb1; +if $rows != 7 then + return -1 +endi +if $data00 != 1 then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data20 != NULL then + return -1 +endi +if $data30 != 3 then + return -1 +endi +if $data40 != 4 then + return -1 +endi +if $data50 != 65 then + return -1 +endi +if $data60 != 0 then + return -1 +endi +sql select cast(c11 as bigint unsigned) from tb1; +if $rows != 7 then + return -1 +endi +if $data00 != 1 then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data20 != NULL then + return -1 +endi +if $data30 != 3 then + return -1 +endi +if $data40 != 4 then + return -1 +endi +if $data50 != 65534 then + return -1 +endi +if $data60 != 0 then + return -1 +endi + + +print "test uint column" + +sql select cast(c12 as bigint) from tb1; +if $rows != 7 then + return -1 +endi +if $data00 != 1 then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data20 != 2 then + return -1 +endi +if $data30 != NULL then + return -1 +endi +if $data40 != 4 then + return -1 +endi +if $data50 != 4294967294 then + return -1 +endi +if $data60 != 0 then + return -1 +endi +sql select cast(c12 as binary(10)) from tb1; +if $rows != 7 then + return -1 +endi +if $data00 != 1 then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data20 != 2 then + return -1 +endi +if $data30 != NULL then + return -1 +endi +if $data40 != 4 then + return -1 +endi +if $data50 != 4294967294 then + return -1 +endi +if $data60 != 0 then + return -1 +endi +sql select cast(c12 as binary(2)) from tb1; +if $rows != 7 then + return -1 +endi +if $data00 != 1 then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data20 != 2 then + return -1 +endi +if $data30 != NULL then + return -1 +endi +if $data40 != 4 then + return -1 +endi +if $data50 != 42 then + return -1 +endi +if $data60 != 0 then + return -1 +endi +sql select cast(c12 as timestamp) from tb1; +if $rows != 7 then + return -1 +endi +if $data00 != @70-01-01 08:00:00.001@ then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data20 != @70-01-01 08:00:00.002@ then + return -1 +endi +if $data30 != NULL then + return -1 +endi +if $data40 != @70-01-01 08:00:00.004@ then + return -1 +endi +if $data50 != @70-02-20 01:02:47.294@ then + return -1 +endi +if $data60 != @70-01-01 08:00:00.000@ then + return -1 +endi +sql select cast(c12 as nchar(10)) from tb1; +if $rows != 7 then + return -1 +endi +if $data00 != 1 then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data20 != 2 then + return -1 +endi +if $data30 != NULL then + return -1 +endi +if $data40 != 4 then + return -1 +endi +if $data50 != 4294967294 then + return -1 +endi +if $data60 != 0 then + return -1 +endi +sql select cast(c12 as nchar(1)) from tb1; +if $rows != 7 then + return -1 +endi +if $data00 != 1 then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data20 != 2 then + return -1 +endi +if $data30 != NULL then + return -1 +endi +if $data40 != 4 then + return -1 +endi +if $data50 != 4 then + return -1 +endi +if $data60 != 0 then + return -1 +endi +sql select cast(c12 as bigint unsigned) from tb1; +if $rows != 7 then + return -1 +endi +if $data00 != 1 then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data20 != 2 then + return -1 +endi +if $data30 != NULL then + return -1 +endi +if $data40 != 4 then + return -1 +endi +if $data50 != 4294967294 then + return -1 +endi +if $data60 != 0 then + return -1 +endi + + +print "test ubigint column" + +sql select cast(c13 as bigint) from tb1; +if $rows != 7 then + return -1 +endi +if $data00 != 1 then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data20 != NULL then + return -1 +endi +if $data30 != 3 then + return -1 +endi +if $data40 != 4 then + return -1 +endi +if $data50 != 9223372036854775807 then + return -1 +endi +if $data60 != 0 then + return -1 +endi +sql select cast(c13 as binary(20)) from tb1; +if $rows != 7 then + return -1 +endi +if $data00 != 1 then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data20 != NULL then + return -1 +endi +if $data30 != 3 then + return -1 +endi +if $data40 != 4 then + return -1 +endi +if $data50 != 9223372036854775807 then + return -1 +endi +if $data60 != 0 then + return -1 +endi +sql select cast(c13 as binary(1)) from tb1; +if $rows != 7 then + return -1 +endi +if $data00 != 1 then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data20 != NULL then + return -1 +endi +if $data30 != 3 then + return -1 +endi +if $data40 != 4 then + return -1 +endi +if $data50 != 9 then + return -1 +endi +if $data60 != 0 then + return -1 +endi +sql select cast(c13 as timestamp) from tb1; +if $rows != 7 then + return -1 +endi +if $data00 != @70-01-01 08:00:00.001@ then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data20 != NULL then + return -1 +endi +if $data30 != @70-01-01 08:00:00.003@ then + return -1 +endi +if $data40 != @70-01-01 08:00:00.004@ then + return -1 +endi +if $data60 != @70-01-01 08:00:00.000@ then + return -1 +endi +sql select cast(c13 as nchar(20)) from tb1; +if $rows != 7 then + return -1 +endi +if $data00 != 1 then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data20 != NULL then + return -1 +endi +if $data30 != 3 then + return -1 +endi +if $data40 != 4 then + return -1 +endi +if $data50 != 9223372036854775807 then + return -1 +endi +if $data60 != 0 then + return -1 +endi +sql select cast(c13 as nchar(2)) from tb1; +if $rows != 7 then + return -1 +endi +if $data00 != 1 then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data20 != NULL then + return -1 +endi +if $data30 != 3 then + return -1 +endi +if $data40 != 4 then + return -1 +endi +if $data50 != 92 then + return -1 +endi +if $data60 != 0 then + return -1 +endi +sql select cast(c13 as bigint unsigned) from tb1; +if $rows != 7 then + return -1 +endi +if $data00 != 1 then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data20 != NULL then + return -1 +endi +if $data30 != 3 then + return -1 +endi +if $data40 != 4 then + return -1 +endi +if $data50 != 9223372036854775807 then + return -1 +endi +if $data60 != 0 then + return -1 +endi diff --git a/tests/script/general/compute/cast_query2.sim b/tests/script/general/compute/cast_query2.sim new file mode 100644 index 0000000000000000000000000000000000000000..6cbb6a11ccfab156dea06d86e27a7e7810297f4a --- /dev/null +++ b/tests/script/general/compute/cast_query2.sim @@ -0,0 +1,1265 @@ +sleep 100 +sql connect + +sql use db; + + +print "test arithmetic" + +sql select cast(c2 + c3 as bigint) from tb1; +if $rows != 7 then + return -1 +endi +if $data00 != 2 then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data20 != NULL then + return -1 +endi +if $data30 != NULL then + return -1 +endi +if $data40 != 8 then + return -1 +endi +if $data50 != 32894 then + return -1 +endi +if $data60 != -32894 then + return -1 +endi +sql select cast((c2 + c3) as bigint) from tb1; +if $rows != 7 then + return -1 +endi +if $data00 != 2 then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data20 != NULL then + return -1 +endi +if $data30 != NULL then + return -1 +endi +if $data40 != 8 then + return -1 +endi +if $data50 != 32894 then + return -1 +endi +if $data60 != -32894 then + return -1 +endi +sql select cast((c2 * c3)+c4-6 as bigint) from tb1; +if $rows != 7 then + return -1 +endi +if $data00 != -4 then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data20 != NULL then + return -1 +endi +if $data30 != NULL then + return -1 +endi +if $data40 != 14 then + return -1 +endi +if $data50 != 2151645050 then + return -1 +endi +if $data60 != -2143322244 then + return -1 +endi +sql select cast(11 as bigint)+c2 from tb1; +if $rows != 7 then + return -1 +endi +if $data00 != 12.000000000 then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data20 != 13.000000000 then + return -1 +endi +if $data30 != NULL then + return -1 +endi +if $data40 != 15.000000000 then + return -1 +endi +if $data50 != 138.000000000 then + return -1 +endi +if $data60 != -116.000000000 then + return -1 +endi +sql select cast(c1 as bigint)+c2 from tb1; +if $rows != 7 then + return -1 +endi +if $data00 != 2.000000000 then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data20 != 3.000000000 then + return -1 +endi +if $data30 != NULL then + return -1 +endi +if $data40 != 5.000000000 then + return -1 +endi +if $data50 != 128.000000000 then + return -1 +endi +if $data60 != -126.000000000 then + return -1 +endi +sql select cast(c2 as bigint)+11 from tb1; +if $rows != 7 then + return -1 +endi +if $data00 != 12.000000000 then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data20 != 13.000000000 then + return -1 +endi +if $data30 != NULL then + return -1 +endi +if $data40 != 15.000000000 then + return -1 +endi +if $data50 != 138.000000000 then + return -1 +endi +if $data60 != -116.000000000 then + return -1 +endi +sql select cast(c2 as bigint)+11+floor(c2) from tb1; +if $rows != 7 then + return -1 +endi +if $data00 != 13.000000000 then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data20 != 15.000000000 then + return -1 +endi +if $data30 != NULL then + return -1 +endi +if $data40 != 19.000000000 then + return -1 +endi +if $data50 != 265.000000000 then + return -1 +endi +if $data60 != -243.000000000 then + return -1 +endi + +print "test function,column/tag/tbname/ts/_C0/_c0/scalar/agg/selectivity/self" + +sql select cast(c1 as bigint),c1,c2 from tb1; +if $rows != 7 then + return -1 +endi +if $data00 != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data10 != 1 then + return -1 +endi +if $data11 != 1 then + return -1 +endi +if $data12 != NULL then + return -1 +endi +if $data20 != 1 then + return -1 +endi +if $data21 != 1 then + return -1 +endi +if $data22 != 2 then + return -1 +endi +if $data30 != 0 then + return -1 +endi +if $data31 != 0 then + return -1 +endi +if $data32 != NULL then + return -1 +endi +if $data40 != 1 then + return -1 +endi +if $data41 != 1 then + return -1 +endi +if $data42 != 4 then + return -1 +endi +if $data50 != 1 then + return -1 +endi +if $data51 != 1 then + return -1 +endi +if $data52 != 127 then + return -1 +endi +if $data60 != 1 then + return -1 +endi +if $data61 != 1 then + return -1 +endi +if $data62 != -127 then + return -1 +endi +sql select cast(c1 as bigint),t1,ts,tbname,_C0,_c0 from tb1; +if $rows != 7 then + return -1 +endi +if $data00 != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != @21-11-11 09:00:00.000@ then + return -1 +endi +if $data03 != tb1 then + return -1 +endi +if $data04 != @21-11-11 09:00:00.000@ then + return -1 +endi +if $data10 != 1 then + return -1 +endi +if $data11 != 1 then + return -1 +endi +if $data12 != @21-11-11 09:00:01.000@ then + return -1 +endi +if $data13 != tb1 then + return -1 +endi +if $data14 != @21-11-11 09:00:01.000@ then + return -1 +endi +if $data20 != 1 then + return -1 +endi +if $data21 != 1 then + return -1 +endi +if $data22 != @21-11-11 09:00:02.000@ then + return -1 +endi +if $data23 != tb1 then + return -1 +endi +if $data24 != @21-11-11 09:00:02.000@ then + return -1 +endi +if $data30 != 0 then + return -1 +endi +if $data31 != 1 then + return -1 +endi +if $data32 != @21-11-11 09:00:03.000@ then + return -1 +endi +if $data33 != tb1 then + return -1 +endi +if $data34 != @21-11-11 09:00:03.000@ then + return -1 +endi +if $data40 != 1 then + return -1 +endi +if $data41 != 1 then + return -1 +endi +if $data42 != @21-11-11 09:00:04.000@ then + return -1 +endi +if $data43 != tb1 then + return -1 +endi +if $data44 != @21-11-11 09:00:04.000@ then + return -1 +endi +if $data50 != 1 then + return -1 +endi +if $data51 != 1 then + return -1 +endi +if $data52 != @21-11-11 09:00:05.000@ then + return -1 +endi +if $data53 != tb1 then + return -1 +endi +if $data54 != @21-11-11 09:00:05.000@ then + return -1 +endi +if $data60 != 1 then + return -1 +endi +if $data61 != 1 then + return -1 +endi +if $data62 != @21-11-11 09:00:06.000@ then + return -1 +endi +if $data63 != tb1 then + return -1 +endi +if $data64 != @21-11-11 09:00:06.000@ then + return -1 +endi +sql select cast(c1 as bigint),floor(c3) from tb1; +if $rows != 7 then + return -1 +endi +if $data00 != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data10 != 1 then + return -1 +endi +if $data11 != NULL then + return -1 +endi +if $data20 != 1 then + return -1 +endi +if $data21 != NULL then + return -1 +endi +if $data30 != 0 then + return -1 +endi +if $data31 != 3 then + return -1 +endi +if $data40 != 1 then + return -1 +endi +if $data41 != 4 then + return -1 +endi +if $data50 != 1 then + return -1 +endi +if $data51 != 32767 then + return -1 +endi +if $data60 != 1 then + return -1 +endi +if $data61 != -32767 then + return -1 +endi +sql select cast(c1 as bigint),cast(c2+c3 as binary(6)) from tb1; +if $rows != 7 then + return -1 +endi +if $data00 != 1 then + return -1 +endi +if $data01 != 2.0000 then + return -1 +endi +if $data10 != 1 then + return -1 +endi +if $data11 != NULL then + return -1 +endi +if $data20 != 1 then + return -1 +endi +if $data21 != NULL then + return -1 +endi +if $data30 != 0 then + return -1 +endi +if $data31 != NULL then + return -1 +endi +if $data40 != 1 then + return -1 +endi +if $data41 != 8.0000 then + return -1 +endi +if $data50 != 1 then + return -1 +endi +if $data51 != 32894. then + return -1 +endi +if $data60 != 1 then + return -1 +endi +if $data61 != -32894 then + return -1 +endi + +sql select cast(c2+c3 as binary(6)) from tb1 where c2 is not null and c3 is not null; +if $rows != 4 then + return -1 +endi +if $data00 != 2.0000 then + return -1 +endi +if $data10 != 8.0000 then + return -1 +endi +if $data20 != 32894. then + return -1 +endi +if $data30 != -32894 then + return -1 +endi +sql select cast(c2 as binary(6)) from tb1 order by ts desc; +if $rows != 7 then + return -1 +endi +if $data00 != -127 then + return -1 +endi +if $data10 != 127 then + return -1 +endi +if $data20 != 4 then + return -1 +endi +if $data30 != NULL then + return -1 +endi +if $data40 != 2 then + return -1 +endi +if $data50 != NULL then + return -1 +endi +if $data60 != 1 then + return -1 +endi + +sql select cast(c2+c3 as binary(6)) from tb1 order by ts desc; +if $rows != 7 then + return -1 +endi +if $data00 != -32894 then + return -1 +endi +if $data10 != 32894. then + return -1 +endi +if $data20 != 8.0000 then + return -1 +endi +if $data30 != NULL then + return -1 +endi +if $data40 != NULL then + return -1 +endi +if $data50 != NULL then + return -1 +endi +if $data60 != 2.0000 then + return -1 +endi +sql select cast(c2+c3 as binary(6)) from tb1 order by ts desc limit 3 offset 2; +if $rows != 3 then + return -1 +endi +if $data00 != 8.0000 then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data20 != NULL then + return -1 +endi + +sql select cast(c2 as binary(2)) from stb1; +if $rows != 14 then + return -1 +endi +if $data00 != 1 then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data20 != 2 then + return -1 +endi +if $data30 != NULL then + return -1 +endi +if $data40 != 4 then + return -1 +endi +if $data50 != 12 then + return -1 +endi +if $data60 != -1 then + return -1 +endi +if $data70 != 1 then + return -1 +endi +if $data80 != 2 then + return -1 +endi +if $data90 != 3 then + return -1 +endi +sql select cast(c2 as binary(2)) from stb1 order by ts desc; +if $rows != 14 then + return -1 +endi +if $data00 != -1 then +if $data00 != 7 then +return -1 +endi +endi +if $data10 != 7 then +if $data10 != -1 then + return -1 +endi +endi +if $data20 != 6 then +if $data20 != 12 then + return -1 +endi +endi +if $data30 != 12 then +if $data30 != 6 then + return -1 +endi +endi +if $data40 != 4 then +if $data40 != 5 then + return -1 +endi +endi +if $data50 != 5 then +if $data50 != 4 then + return -1 +endi +endi +if $data60 != 4 then +if $data60 != NULL then + return -1 +endi +endi +if $data70 != NULL then +if $data70 != 4 then + return -1 +endi +endi +if $data80 != 2 then +if $data80 != 3 then + return -1 +endi +endi +if $data90 != 3 then +if $data90 != 2 then + return -1 +endi +endi + +sql select cast(c4 as bigint),t1 from stb1 order by ts desc; +if $rows != 14 then + return -1 +endi +if $data00 != -2147483647 then +if $data00 != 7 then + return -1 +endi +endi +if $data01 != 1 then +if $data01 != 2 then + return -1 +endi +endi +if $data10 != 7 then +if $data10 != -2147483647 then + return -1 +endi +endi +if $data11 != 1 then +if $data11 != 2 then + return -1 +endi +endi +if $data20 != 6 then +if $data20 != 2147483647 then + return -1 +endi +endi +if $data21 != 2 then +if $data21 != 1 then + return -1 +endi +endi +if $data30 != 2147483647 then +if $data30 != 6 then + return -1 +endi +endi +if $data31 != 1 then +if $data31 != 2 then + return -1 +endi +endi +if $data40 != 4 then +if $data40 != 5 then + return -1 +endi +endi +if $data41 != 1 then +if $data41 != 2 then + return -1 +endi +endi +if $data50 != 5 then +if $data50 != 4 then + return -1 +endi +endi +if $data51 != 1 then +if $data51 != 2 then + return -1 +endi +endi +if $data60 != 4 then +if $data60 != NULL then + return -1 +endi +endi +if $data61 != 2 then +if $data61 != 1 then + return -1 +endi +endi +if $data70 != NULL then +if $data70 != 4 then + return -1 +endi +endi +if $data71 != 1 then +if $data71 != 2 then + return -1 +endi +endi +if $data80 != 2 then +if $data80 != 2 then + return -1 +endi +endi +if $data81 != 1 then +if $data81 != 2 then + return -1 +endi +endi +if $data90 != 2 then + return -1 +endi +if $data91 != 2 then +if $data91 != 1 then + return -1 +endi +endi + +sql select cast(c3 as bigint),tbname from stb1; +if $rows != 14 then + return -1 +endi +if $data00 != 1 then + return -1 +endi +if $data01 != tb1 then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data11 != tb1 then + return -1 +endi +if $data20 != NULL then + return -1 +endi +if $data21 != tb1 then + return -1 +endi +if $data30 != 3 then + return -1 +endi +if $data31 != tb1 then + return -1 +endi +if $data40 != 4 then + return -1 +endi +if $data41 != tb1 then + return -1 +endi +if $data50 != 32767 then + return -1 +endi +if $data51 != tb1 then + return -1 +endi +if $data60 != -32767 then + return -1 +endi +if $data61 != tb1 then + return -1 +endi +if $data70 != 1 then + return -1 +endi +if $data71 != tb2 then + return -1 +endi +if $data80 != 2 then + return -1 +endi +if $data81 != tb2 then + return -1 +endi +if $data90 != 3 then + return -1 +endi +if $data91 != tb2 then + return -1 +endi + +sql select cast(c3 as bigint),tbname from stb1 where t1 > 1; +if $rows != 7 then + return -1 +endi + +sql select cast(c8 as bigint),cast(c9 as bigint) from tbn; +if $rows != 7 then + return -1 +endi +if $data00 != 111 then + return -1 +endi +if $data01 != 1111 then + return -1 +endi +if $data10 != 222 then + return -1 +endi +if $data11 != 2222 then + return -1 +endi +if $data20 != 333 then + return -1 +endi +if $data21 != 3333 then + return -1 +endi +if $data30 != 444 then + return -1 +endi +if $data31 != 4444 then + return -1 +endi +if $data40 != 555 then + return -1 +endi +if $data41 != 5555 then + return -1 +endi +if $data50 != 666 then + return -1 +endi +if $data51 != 6666 then + return -1 +endi +if $data60 != 777 then + return -1 +endi +if $data61 != 7777 then + return -1 +endi + +sql select cast(c8 as bigint),cast(c9 as bigint) from tbn order by ts desc; +if $rows != 7 then + return -1 +endi +if $data00 != 777 then + return -1 +endi +if $data01 != 7777 then + return -1 +endi +if $data10 != 666 then + return -1 +endi +if $data11 != 6666 then + return -1 +endi +if $data20 != 555 then + return -1 +endi +if $data21 != 5555 then + return -1 +endi +if $data30 != 444 then + return -1 +endi +if $data31 != 4444 then + return -1 +endi +if $data40 != 333 then + return -1 +endi +if $data41 != 3333 then + return -1 +endi +if $data50 != 222 then + return -1 +endi +if $data51 != 2222 then + return -1 +endi +if $data60 != 111 then + return -1 +endi +if $data61 != 1111 then + return -1 +endi + +sql select cast(cast(c8 as binary(2)) as bigint) from tbn; +if $rows != 7 then + return -1 +endi +if $data00 != 11 then + return -1 +endi +if $data10 != 22 then + return -1 +endi +if $data20 != 33 then + return -1 +endi +if $data30 != 44 then + return -1 +endi +if $data40 != 55 then + return -1 +endi +if $data50 != 66 then + return -1 +endi +if $data60 != 77 then + return -1 +endi + +sql select cast(cast(cast(cast(ts as bigint) as binary(5)) as bigint)+cast(cast(cast(ts as bigint) as binary(2)) as bigint) as bigint) from tbn; +if $rows != 7 then + return -1 +endi +if $data00 != 16381 then + return -1 +endi +if $data10 != 16381 then + return -1 +endi +if $data20 != 16381 then + return -1 +endi +if $data30 != 16381 then + return -1 +endi +if $data40 != 16381 then + return -1 +endi +if $data50 != 16381 then + return -1 +endi +if $data60 != 16381 then + return -1 +endi + +sql select cast(cast(cast(cast(ts as bigint) as binary(5)) as bigint)+cast(cast(cast(ts as bigint) as binary(2)) as bigint) as bigint) from tb3; +if $rows != 0 then + return -1 +endi + +sql select cast(a as bigint) from (select avg(c2) as a from stb1 interval(1s)); +if $rows != 7 then + return -1 +endi +if $data00 != 1 then + return -1 +endi +if $data10 != 2 then + return -1 +endi +if $data20 != 2 then + return -1 +endi +if $data30 != 4 then + return -1 +endi +if $data40 != 4 then + return -1 +endi +if $data50 != 66 then + return -1 +endi +if $data60 != -60 then + return -1 +endi + +sql select cast(c2 as binary(10)) from (select * from stb1); +if $rows != 14 then + return -1 +endi + +sql select cast(a as binary(10)) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)); +if $rows != 10 then + return -1 +endi +if $data00 != 1.000000 then + return -1 +endi +if $data10 != 2.000000 then + return -1 +endi +if $data20 != 2.500000 then + return -1 +endi +if $data30 != 4.000000 then + return -1 +endi +if $data40 != 4.500000 then + return -1 +endi +if $data50 != 66.500000 then + return -1 +endi +if $data60 != -60.000000 then + return -1 +endi +if $data70 != NULL then + return -1 +endi +if $data80 != NULL then + return -1 +endi +if $data90 != NULL then + return -1 +endi + +sql select cast(a as bigint) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)) order by ts; +if $rows != 10 then + return -1 +endi +if $data00 != 1 then + return -1 +endi +if $data10 != 2 then + return -1 +endi +if $data20 != 2 then + return -1 +endi +if $data30 != 4 then + return -1 +endi +if $data40 != 4 then + return -1 +endi +if $data50 != 66 then + return -1 +endi +if $data60 != -60 then + return -1 +endi +if $data70 != NULL then + return -1 +endi +if $data80 != NULL then + return -1 +endi +if $data90 != NULL then + return -1 +endi + +sql select cast(a as bigint) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)) order by ts desc; +if $rows != 10 then + return -1 +endi +if $data00 != NULL then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data20 != NULL then + return -1 +endi +if $data30 != -60 then + return -1 +endi +if $data40 != 66 then + return -1 +endi +if $data50 != 4 then + return -1 +endi +if $data60 != 4 then + return -1 +endi +if $data70 != 2 then + return -1 +endi +if $data80 != 2 then + return -1 +endi +if $data90 != 1 then + return -1 +endi + +sql select cast(a as bigint) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)) order by a desc; +if $rows != 10 then + return -1 +endi +if $data00 != NULL then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data20 != NULL then + return -1 +endi +if $data30 != 66 then + return -1 +endi +if $data40 != 4 then + return -1 +endi +if $data50 != 4 then + return -1 +endi +if $data60 != 2 then + return -1 +endi +if $data70 != 2 then + return -1 +endi +if $data80 != 1 then + return -1 +endi +if $data90 != -60 then + return -1 +endi + +sql select cast(a as bigint) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)) order by a; +if $rows != 10 then + return -1 +endi +if $data00 != -60 then + return -1 +endi +if $data10 != 1 then + return -1 +endi +if $data20 != 2 then + return -1 +endi +if $data30 != 2 then + return -1 +endi +if $data40 != 4 then + return -1 +endi +if $data50 != 4 then + return -1 +endi +if $data60 != 66 then + return -1 +endi +if $data70 != NULL then + return -1 +endi +if $data80 != NULL then + return -1 +endi +if $data90 != NULL then + return -1 +endi + +sql select cast(a as bigint) from (select cast(c2 as binary(2)) as a from tb1); +if $rows != 7 then + return -1 +endi +if $data00 != 1 then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data20 != 2 then + return -1 +endi +if $data30 != NULL then + return -1 +endi +if $data40 != 4 then + return -1 +endi +if $data50 != 12 then + return -1 +endi +if $data60 != -1 then + return -1 +endi + +sql select cast(tb1.c3 as binary(10)),cast(tb2.c3 as binary(10)) from tb1,tb2 where tb1.ts=tb2.ts; +if $rows != 7 then + return -1 +endi +if $data00 != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data11 != 2 then + return -1 +endi +if $data20 != NULL then + return -1 +endi +if $data21 != 3 then + return -1 +endi +if $data30 != 3 then + return -1 +endi +if $data31 != 4 then + return -1 +endi +if $data40 != 4 then + return -1 +endi +if $data41 != 5 then + return -1 +endi +if $data50 != 32767 then + return -1 +endi +if $data51 != 6 then + return -1 +endi +if $data60 != -32767 then + return -1 +endi +if $data61 != 7 then + return -1 +endi + +sql select cast(c3 as binary(10)) from tb1 union all select cast(c3 as binary(10)) from tb2; +if $rows != 14 then + return -1 +endi +if $data00 != 1 then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data20 != NULL then + return -1 +endi +if $data30 != 3 then + return -1 +endi +if $data40 != 4 then + return -1 +endi +if $data50 != 32767 then + return -1 +endi +if $data60 != -32767 then + return -1 +endi +if $data70 != 1 then + return -1 +endi +if $data80 != 2 then + return -1 +endi +if $data90 != 3 then + return -1 +endi + + + \ No newline at end of file diff --git a/tests/script/general/compute/cast_query3.sim b/tests/script/general/compute/cast_query3.sim new file mode 100644 index 0000000000000000000000000000000000000000..3b5ecc41b32a6ed5646f08fa979e85b62ba32467 --- /dev/null +++ b/tests/script/general/compute/cast_query3.sim @@ -0,0 +1,63 @@ +sleep 100 +sql connect + +sql use db; + +sql select cast(stb1.c4 as binary(10)),cast(stba.c5 as binary(10)) from stb1,stba where stb1.t1=stba.t1 and stb1.ts=stba.ts; +if $rows != 7 then + return -1 +endi +if $data00 != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data11 != 2 then + return -1 +endi +if $data20 != 2 then + return -1 +endi +if $data21 != 3 then + return -1 +endi +if $data30 != NULL then + return -1 +endi +if $data31 != 4 then + return -1 +endi +if $data40 != 4 then + return -1 +endi +if $data41 != 5 then + return -1 +endi +if $data50 != 2147483647 then + return -1 +endi +if $data51 != 6 then + return -1 +endi +if $data60 != -214748364 then + return -1 +endi +if $data61 != 7 then + return -1 +endi + +sql select cast(c4 as binary(10)) as a from stb1 union all select cast(c5 as binary(10)) as a from stba; +if $rows != 44 then + return -1 +endi + +sql select cast(c2 as bigint) from stba; +if $rows != 30 then + return -1 +endi + + \ No newline at end of file diff --git a/tests/script/general/compute/math_abs.sim b/tests/script/general/compute/math_abs.sim new file mode 100644 index 0000000000000000000000000000000000000000..dfa073e9c5f9505330f26eb52a097136d6154e60 --- /dev/null +++ b/tests/script/general/compute/math_abs.sim @@ -0,0 +1,1068 @@ +sleep 100 +sql connect +sql use db + +print execute sql select abs(*) from tb1; +sql_error select abs(*) from tb1; +print execute sql select abs(*) from tb1; +sql_error select abs(*) from tb1; +print execute sql select abs(*) from tb1; +sql_error select abs(*) from tb1; +print execute sql select abs(*) from tb1; +sql_error select abs(*) from tb1; +print execute sql select abs(*) as a from tb1; +sql_error select abs(*) as a from tb1; +print execute sql select abs(*) + 1 as a from tb1; +sql_error select abs(*) + 1 as a from tb1; +print execute sql select abs(tb1.*) + 1 as a from tb1; +sql_error select abs(tb1.*) + 1 as a from tb1; +print execute sql select abs(*) from tb1; +sql_error select abs(*) from tb1; +print execute sql select abs(c1) from tb1; +sql_error select abs(c1) from tb1; +print execute sql select abs(c1) from tb1; +sql_error select abs(c1) from tb1; +print execute sql select abs(c1 + c2) from tb1; +sql_error select abs(c1 + c2) from tb1; +print execute sql select abs(13) from tb1; +sql select abs(13) from tb1; +if $data00 != @13@ then + return -1 +endi +if $data10 != @13@ then + return -1 +endi +if $data20 != @13@ then + return -1 +endi +if $data30 != @13@ then + return -1 +endi +if $data40 != @13@ then + return -1 +endi +if $data50 != @13@ then + return -1 +endi +if $data60 != @13@ then + return -1 +endi +print execute sql select abs(c1) from tb1; +sql_error select abs(c1) from tb1; +print execute sql select abs(c2) from tb1; +sql select abs(c2) from tb1; +if $data00 != @1@ then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data20 != @2@ then + return -1 +endi +if $data30 != NULL then + return -1 +endi +if $data40 != @4@ then + return -1 +endi +if $data50 != @127@ then + return -1 +endi +if $data60 != @127@ then + return -1 +endi +print execute sql select abs(c3) from tb1; +sql select abs(c3) from tb1; +if $data00 != @1@ then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data20 != NULL then + return -1 +endi +if $data30 != @3@ then + return -1 +endi +if $data40 != @4@ then + return -1 +endi +if $data50 != @32767@ then + return -1 +endi +if $data60 != @32767@ then + return -1 +endi +print execute sql select abs(c4) from tb1; +sql select abs(c4) from tb1; +if $data00 != @1@ then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data20 != @2@ then + return -1 +endi +if $data30 != NULL then + return -1 +endi +if $data40 != @4@ then + return -1 +endi +if $data50 != @2147483647@ then + return -1 +endi +if $data60 != @2147483647@ then + return -1 +endi +print execute sql select abs(c5) from tb1; +sql select abs(c5) from tb1; +if $data00 != @1@ then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data20 != NULL then + return -1 +endi +if $data30 != @3@ then + return -1 +endi +if $data40 != @4@ then + return -1 +endi +if $data50 != @9223372036854775807@ then + return -1 +endi +if $data60 != @9223372036854775807@ then + return -1 +endi +print execute sql select abs(c6) from tb1; +sql select abs(c6) from tb1; +if $data00 != @1.000000000@ then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data20 != @2.000000000@ then + return -1 +endi +if $data30 != NULL then + return -1 +endi +if $data40 != @4.000000000@ then + return -1 +endi +if $data50 != @340282346638528859811704183484516925440.000000000@ then + return -1 +endi +if $data60 != @340282346638528859811704183484516925440.000000000@ then + return -1 +endi +print execute sql select abs(c7) from tb1; +sql select abs(c7) from tb1; +if $data00 != @1.000000000@ then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data20 != NULL then + return -1 +endi +if $data30 != @3.000000000@ then + return -1 +endi +if $data40 != @4.000000000@ then + return -1 +endi +if $data50 != @179769000000000006323030492138942643493033036433685336215410983289126434148906289940615299632196609445533816320312774433484859900046491141051651091672734470972759941382582304802812882753059262973637182942535982636884444611376868582636745405553206881859340916340092953230149901406738427651121855107737424232448.000000000@ then + return -1 +endi +if $data60 != @179769000000000006323030492138942643493033036433685336215410983289126434148906289940615299632196609445533816320312774433484859900046491141051651091672734470972759941382582304802812882753059262973637182942535982636884444611376868582636745405553206881859340916340092953230149901406738427651121855107737424232448.000000000@ then + return -1 +endi +print execute sql select abs(c8) from tb1; +sql_error select abs(c8) from tb1; +print execute sql select abs(c9) from tb1; +sql_error select abs(c9) from tb1; +print execute sql select abs(c10) from tb1; +sql select abs(c10) from tb1; +if $data00 != @1@ then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data20 != @2@ then + return -1 +endi +if $data30 != NULL then + return -1 +endi +if $data40 != @4@ then + return -1 +endi +if $data50 != @254@ then + return -1 +endi +if $data60 != @0@ then + return -1 +endi +print execute sql select abs(c11) from tb1; +sql select abs(c11) from tb1; +if $data00 != @1@ then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data20 != NULL then + return -1 +endi +if $data30 != @3@ then + return -1 +endi +if $data40 != @4@ then + return -1 +endi +if $data50 != @65534@ then + return -1 +endi +if $data60 != @0@ then + return -1 +endi +print execute sql select abs(c12) from tb1; +sql select abs(c12) from tb1; +if $data00 != @1@ then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data20 != @2@ then + return -1 +endi +if $data30 != NULL then + return -1 +endi +if $data40 != @4@ then + return -1 +endi +if $data50 != @4294967294@ then + return -1 +endi +if $data60 != @0@ then + return -1 +endi +print execute sql select abs(c13) from tb1; +sql select abs(c13) from tb1; +if $data00 != @1@ then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data20 != NULL then + return -1 +endi +if $data30 != @3@ then + return -1 +endi +if $data40 != @4@ then + return -1 +endi +if $data50 != @9223372036854775807@ then + return -1 +endi +if $data60 != @0@ then + return -1 +endi +print execute sql select abs(12345678900000000000000000) from tb1; +sql_error select abs(12345678900000000000000000) from tb1; +print execute sql select distinct abs(123) from tb1; +sql_error select distinct abs(123) from tb1; +print execute sql select abs(t1) from stb1; +sql_error select abs(t1) from stb1; +print execute sql select abs(c1),avg(c3) from tb1; +sql_error select abs(c1),avg(c3) from tb1; +print execute sql select abs(c1),top(c3,1) from tb1; +sql_error select abs(c1),top(c3,1) from tb1; +print execute sql select abs(c2+c3) from tb1 session(ts, 1s); +sql_error select abs(c2+c3) from tb1 session(ts, 1s); +print execute sql select abs(c2+c3) from tb1 STATE_WINDOW(c1); +sql_error select abs(c2+c3) from tb1 STATE_WINDOW(c1); +print execute sql select abs(c2+c3) from tb1 interval(1s) sliding(1s) fill(NULL); +sql_error select abs(c2+c3) from tb1 interval(1s) sliding(1s) fill(NULL); +print execute sql select abs(c2+c3) from stb1 group by t1; +sql_error select abs(c2+c3) from stb1 group by t1; +print execute sql select abs(c2+c3) from stb1 group by ts; +sql_error select abs(c2+c3) from stb1 group by ts; +print execute sql select abs(c2+c3) from stb1 group by c1; +sql_error select abs(c2+c3) from stb1 group by c1; +print execute sql select abs(c2+c3) from stb1 group by tbname; +sql_error select abs(c2+c3) from stb1 group by tbname; +print execute sql select abs(c2+c3) from tb1 order by c2; +sql_error select abs(c2+c3) from tb1 order by c2; +print execute sql select abs(c8),abs(c9) from tbn; +sql_error select abs(c8),abs(c9) from tbn; +print execute sql select abs(ts) from (select avg(c2) as a from stb1 interval(1s)); +sql_error select abs(ts) from (select avg(c2) as a from stb1 interval(1s)); +print execute sql select abs(a) from (select abs(c2) as a from tb1); +sql select abs(a) from (select abs(c2) as a from tb1); +if $data00 != @1@ then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data20 != @2@ then + return -1 +endi +if $data30 != NULL then + return -1 +endi +if $data40 != @4@ then + return -1 +endi +if $data50 != @127@ then + return -1 +endi +if $data60 != @127@ then + return -1 +endi +print execute sql select abs("abc") from tb1; +sql_error select abs("abc") from tb1; +print execute sql select abs(c2 + c3) from tb1; +sql select abs(c2 + c3) from tb1; +if $data00 != @2.000000000@ then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data20 != NULL then + return -1 +endi +if $data30 != NULL then + return -1 +endi +if $data40 != @8.000000000@ then + return -1 +endi +if $data50 != @32894.000000000@ then + return -1 +endi +if $data60 != @32894.000000000@ then + return -1 +endi +print execute sql select abs((c2 + c3)) from tb1; +sql select abs((c2 + c3)) from tb1; +if $data00 != @2.000000000@ then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data20 != NULL then + return -1 +endi +if $data30 != NULL then + return -1 +endi +if $data40 != @8.000000000@ then + return -1 +endi +if $data50 != @32894.000000000@ then + return -1 +endi +if $data60 != @32894.000000000@ then + return -1 +endi +print execute sql select abs((c2 * c3)+c4-6) from tb1; +sql select abs((c2 * c3)+c4-6) from tb1; +if $data00 != @4.000000000@ then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data20 != NULL then + return -1 +endi +if $data30 != NULL then + return -1 +endi +if $data40 != @14.000000000@ then + return -1 +endi +if $data50 != @2151645050.000000000@ then + return -1 +endi +if $data60 != @2143322244.000000000@ then + return -1 +endi +print execute sql select abs(11)+c2 from tb1; +sql select abs(11)+c2 from tb1; +if $data00 != @12.000000000@ then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data20 != @13.000000000@ then + return -1 +endi +if $data30 != NULL then + return -1 +endi +if $data40 != @15.000000000@ then + return -1 +endi +if $data50 != @138.000000000@ then + return -1 +endi +if $data60 != @-116.000000000@ then + return -1 +endi +print execute sql select abs(c1)+c2 from tb1; +sql_error select abs(c1)+c2 from tb1; +print execute sql select abs(c2)+11 from tb1; +sql select abs(c2)+11 from tb1; +if $data00 != @12.000000000@ then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data20 != @13.000000000@ then + return -1 +endi +if $data30 != NULL then + return -1 +endi +if $data40 != @15.000000000@ then + return -1 +endi +if $data50 != @138.000000000@ then + return -1 +endi +if $data60 != @138.000000000@ then + return -1 +endi +print execute sql select abs(c1),c1,c2 from tb1; +sql_error select abs(c1),c1,c2 from tb1; +print execute sql select abs(c1),t1,ts,tbname,_C0,_c0 from tb1; +sql_error select abs(c1),t1,ts,tbname,_C0,_c0 from tb1; +print execute sql select abs(c1),floor(c3) from tb1; +sql_error select abs(c1),floor(c3) from tb1; +print execute sql select abs(c1),abs(c2+c3) from tb1; +sql_error select abs(c1),abs(c2+c3) from tb1; +print execute sql select abs(c2+c3) from tb1 where c2 is not null and c3 is not null; +sql select abs(c2+c3) from tb1 where c2 is not null and c3 is not null; +if $data00 != @2.000000000@ then + return -1 +endi +if $data10 != @8.000000000@ then + return -1 +endi +if $data20 != @32894.000000000@ then + return -1 +endi +if $data30 != @32894.000000000@ then + return -1 +endi +print execute sql select abs(c2) from tb1 order by ts desc; +sql select abs(c2) from tb1 order by ts desc; +if $data00 != @127@ then + return -1 +endi +if $data10 != @127@ then + return -1 +endi +if $data20 != @4@ then + return -1 +endi +if $data30 != NULL then + return -1 +endi +if $data40 != @2@ then + return -1 +endi +if $data50 != NULL then + return -1 +endi +if $data60 != @1@ then + return -1 +endi +print execute sql select abs(c2+c3) from tb1 order by ts desc; +sql select abs(c2+c3) from tb1 order by ts desc; +if $data00 != @32894.000000000@ then + return -1 +endi +if $data10 != @32894.000000000@ then + return -1 +endi +if $data20 != @8.000000000@ then + return -1 +endi +if $data30 != NULL then + return -1 +endi +if $data40 != NULL then + return -1 +endi +if $data50 != NULL then + return -1 +endi +if $data60 != @2.000000000@ then + return -1 +endi +print execute sql select abs(c2+c3) from tb1 order by ts desc limit 3 offset 2; +sql select abs(c2+c3) from tb1 order by ts desc limit 3 offset 2; +if $data00 != @8.000000000@ then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data20 != NULL then + return -1 +endi +print execute sql select abs(c2) from stb1; +sql select abs(c2) from stb1; +if $data00 != @1@ then +if $data10 != NULL then + return -1 +endi +endi +if $data20 != @2@ then +if $data30 != NULL then + return -1 +endi +endi +if $data40 != @4@ then +if $data50 != @127@ then + return -1 +endi +endi +if $data60 != @127@ then +if $data70 != @1@ then + return -1 +endi +endi +if $data80 != @2@ then +if $data90 != @3@ then + return -1 +endi +endi +print execute sql select abs(c2) from stb1 order by ts desc; +sql select abs(c2) from stb1 order by ts desc; +if $data00 != @7@ then +if $data00 != @127@ then + return -1 +endi +endi +if $data20 != @6@ then +if $data20 != @127@ then + return -1 +endi +endi +if $data40 != @5@ then +if $data40 != @4@ then + return -1 +endi +endi +if $data60 != @4@ then +if $data60 != NULL then + return -1 +endi +endi +if $data80 != @3@ then +if $data80 != @2@ then + return -1 +endi +endi +print execute sql select abs(c4),t1 from stb1 order by ts desc; +sql select abs(c4),t1 from stb1 order by ts desc; +if $data00 != @7@ then +if $data00 != @2147483647@ then + return -1 +endi +endi +if $data01 != @2@ then +if $data01 != @1@ then + return -1 +endi +endi +if $data20 != @6@ then +if $data20 != @2147483647@ then + return -1 +endi +endi +if $data21 != @2@ then +if $data21 != @1@ then + return -1 +endi +endi +if $data40 != @5@ then +if $data40 != @4@ then + return -1 +endi +endi +if $data41 != @2@ then +if $data41 != @1@ then + return -1 +endi +endi +if $data60 != @4@ then +if $data60 != NULL then + return -1 +endi +endi +if $data61 != @2@ then +if $data61 != @1@ then + return -1 +endi +endi +if $data80 != @2@ then +if $data80 != @2@ then + return -1 +endi +endi +if $data81 != @2@ then +if $data81 != @1@ then + return -1 +endi +endi +print execute sql select abs(c3),tbname from stb1; +sql select abs(c3),tbname from stb1; +if $data00 != @1@ then + return -1 +endi +if $data01 != @tb1@ then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data11 != @tb1@ then + return -1 +endi +if $data20 != NULL then + return -1 +endi +if $data21 != @tb1@ then + return -1 +endi +if $data30 != @3@ then + return -1 +endi +if $data31 != @tb1@ then + return -1 +endi +if $data40 != @4@ then + return -1 +endi +if $data41 != @tb1@ then + return -1 +endi +if $data50 != @32767@ then + return -1 +endi +if $data51 != @tb1@ then + return -1 +endi +if $data60 != @32767@ then + return -1 +endi +if $data61 != @tb1@ then + return -1 +endi +if $data70 != @1@ then + return -1 +endi +if $data71 != @tb2@ then + return -1 +endi +if $data80 != @2@ then + return -1 +endi +if $data81 != @tb2@ then + return -1 +endi +if $data90 != @3@ then + return -1 +endi +if $data91 != @tb2@ then + return -1 +endi +print execute sql select abs(c3),tbname from stb1 where t1 > 1; +sql select abs(c3),tbname from stb1 where t1 > 1; +if $data00 != @1@ then + return -1 +endi +if $data01 != @tb2@ then + return -1 +endi +if $data10 != @2@ then + return -1 +endi +if $data11 != @tb2@ then + return -1 +endi +if $data20 != @3@ then + return -1 +endi +if $data21 != @tb2@ then + return -1 +endi +if $data30 != @4@ then + return -1 +endi +if $data31 != @tb2@ then + return -1 +endi +if $data40 != @5@ then + return -1 +endi +if $data41 != @tb2@ then + return -1 +endi +if $data50 != @6@ then + return -1 +endi +if $data51 != @tb2@ then + return -1 +endi +if $data60 != @7@ then + return -1 +endi +if $data61 != @tb2@ then + return -1 +endi +print execute sql select abs(c8),abs(c9) from tbn; +sql_error select abs(c8),abs(c9) from tbn; +print execute sql select abs(c8),abs(c9) from tbn order by ts desc; +sql_error select abs(c8),abs(c9) from tbn order by ts desc; +print execute sql select abs(abs(c8)) from tbn; +sql_error select abs(abs(c8)) from tbn; +print execute sql select abs(a) from (select avg(c2) as a from stb1 interval(1s)); +sql select abs(a) from (select avg(c2) as a from stb1 interval(1s)); +if $data00 != @1.000000000@ then + return -1 +endi +if $data10 != @2.000000000@ then + return -1 +endi +if $data20 != @2.500000000@ then + return -1 +endi +if $data30 != @4.000000000@ then + return -1 +endi +if $data40 != @4.500000000@ then + return -1 +endi +if $data50 != @66.500000000@ then + return -1 +endi +if $data60 != @60.000000000@ then + return -1 +endi +print execute sql select abs(c2) from (select * from stb1); +sql select abs(c2) from (select * from stb1); +if $data00 != @1@ then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data20 != @2@ then + return -1 +endi +if $data30 != NULL then + return -1 +endi +if $data40 != @4@ then + return -1 +endi +if $data50 != @127@ then + return -1 +endi +if $data60 != @127@ then + return -1 +endi +if $data70 != @1@ then + return -1 +endi +if $data80 != @2@ then + return -1 +endi +if $data90 != @3@ then + return -1 +endi +print execute sql select abs(a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)); +sql select abs(a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)); +if $data00 != @1.000000000@ then + return -1 +endi +if $data10 != @2.000000000@ then + return -1 +endi +if $data20 != @2.500000000@ then + return -1 +endi +if $data30 != @4.000000000@ then + return -1 +endi +if $data40 != @4.500000000@ then + return -1 +endi +if $data50 != @66.500000000@ then + return -1 +endi +if $data60 != @60.000000000@ then + return -1 +endi +if $data70 != NULL then + return -1 +endi +if $data80 != NULL then + return -1 +endi +if $data90 != NULL then + return -1 +endi +print execute sql select abs(a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)) order by ts; +sql select abs(a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)) order by ts; +if $data00 != @1.000000000@ then + return -1 +endi +if $data10 != @2.000000000@ then + return -1 +endi +if $data20 != @2.500000000@ then + return -1 +endi +if $data30 != @4.000000000@ then + return -1 +endi +if $data40 != @4.500000000@ then + return -1 +endi +if $data50 != @66.500000000@ then + return -1 +endi +if $data60 != @60.000000000@ then + return -1 +endi +if $data70 != NULL then + return -1 +endi +if $data80 != NULL then + return -1 +endi +if $data90 != NULL then + return -1 +endi +print execute sql select abs(a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)) order by ts desc; +sql select abs(a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)) order by ts desc; +if $data00 != NULL then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data20 != NULL then + return -1 +endi +if $data30 != @60.000000000@ then + return -1 +endi +if $data40 != @66.500000000@ then + return -1 +endi +if $data50 != @4.500000000@ then + return -1 +endi +if $data60 != @4.000000000@ then + return -1 +endi +if $data70 != @2.500000000@ then + return -1 +endi +if $data80 != @2.000000000@ then + return -1 +endi +if $data90 != @1.000000000@ then + return -1 +endi +print execute sql select abs(a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)) order by a desc; +sql select abs(a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)) order by a desc; +if $data00 != NULL then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data20 != NULL then + return -1 +endi +if $data30 != @66.500000000@ then + return -1 +endi +if $data40 != @4.500000000@ then + return -1 +endi +if $data50 != @4.000000000@ then + return -1 +endi +if $data60 != @2.500000000@ then + return -1 +endi +if $data70 != @2.000000000@ then + return -1 +endi +if $data80 != @1.000000000@ then + return -1 +endi +if $data90 != @60.000000000@ then + return -1 +endi +print execute sql select abs(a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)) order by a; +sql select abs(a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)) order by a; +if $data00 != @60.000000000@ then + return -1 +endi +if $data10 != @1.000000000@ then + return -1 +endi +if $data20 != @2.000000000@ then + return -1 +endi +if $data30 != @2.500000000@ then + return -1 +endi +if $data40 != @4.000000000@ then + return -1 +endi +if $data50 != @4.500000000@ then + return -1 +endi +if $data60 != @66.500000000@ then + return -1 +endi +if $data70 != NULL then + return -1 +endi +if $data80 != NULL then + return -1 +endi +if $data90 != NULL then + return -1 +endi +print execute sql select abs(a) from (select abs(c2) as a from tb1); +sql select abs(a) from (select abs(c2) as a from tb1); +if $data00 != @1@ then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data20 != @2@ then + return -1 +endi +if $data30 != NULL then + return -1 +endi +if $data40 != @4@ then + return -1 +endi +if $data50 != @127@ then + return -1 +endi +if $data60 != @127@ then + return -1 +endi +print execute sql select abs(tb1.c3),abs(tb2.c3) from tb1,tb2 where tb1.ts=tb2.ts; +sql select abs(tb1.c3),abs(tb2.c3) from tb1,tb2 where tb1.ts=tb2.ts; +if $data00 != @1@ then + return -1 +endi +if $data01 != @1@ then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data11 != @2@ then + return -1 +endi +if $data20 != NULL then + return -1 +endi +if $data21 != @3@ then + return -1 +endi +if $data30 != @3@ then + return -1 +endi +if $data31 != @4@ then + return -1 +endi +if $data40 != @4@ then + return -1 +endi +if $data41 != @5@ then + return -1 +endi +if $data50 != @32767@ then + return -1 +endi +if $data51 != @6@ then + return -1 +endi +if $data60 != @32767@ then + return -1 +endi +if $data61 != @7@ then + return -1 +endi +print execute sql select abs(c3) from tb1 union all select abs(c3) from tb2; +sql select abs(c3) from tb1 union all select abs(c3) from tb2; +if $data00 != @1@ then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data20 != NULL then + return -1 +endi +if $data30 != @3@ then + return -1 +endi +if $data40 != @4@ then + return -1 +endi +if $data50 != @32767@ then + return -1 +endi +if $data60 != @32767@ then + return -1 +endi +if $data70 != @1@ then + return -1 +endi +if $data80 != @2@ then + return -1 +endi +if $data90 != @3@ then + return -1 +endi diff --git a/tests/script/general/compute/math_abs2.sim b/tests/script/general/compute/math_abs2.sim new file mode 100644 index 0000000000000000000000000000000000000000..cd419bffcf960e637b370988c71dfe98e002d093 --- /dev/null +++ b/tests/script/general/compute/math_abs2.sim @@ -0,0 +1,366 @@ +sleep 100 +sql connect +sql use db + +print execute sql select abs(stb1.c4),abs(stba.c5) from stb1,stba where stb1.t1=stba.t1 and stb1.ts=stba.ts; +sql select abs(stb1.c4),abs(stba.c5) from stb1,stba where stb1.t1=stba.t1 and stb1.ts=stba.ts; +if $data00 != @1@ then + return -1 +endi +if $data01 != @1@ then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data11 != @2@ then + return -1 +endi +if $data20 != @2@ then + return -1 +endi +if $data21 != @3@ then + return -1 +endi +if $data30 != NULL then + return -1 +endi +if $data31 != @4@ then + return -1 +endi +if $data40 != @4@ then + return -1 +endi +if $data41 != @5@ then + return -1 +endi +if $data50 != @2147483647@ then + return -1 +endi +if $data51 != @6@ then + return -1 +endi +if $data60 != @2147483647@ then + return -1 +endi +if $data61 != @7@ then + return -1 +endi +print execute sql select abs(c4) as a from stb1 union all select abs(c5) as a from stba; +sql select abs(c4) as a from stb1 union all select abs(c5) as a from stba; +if $data00 != @1@ then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data20 != @2@ then + return -1 +endi +if $data30 != NULL then + return -1 +endi +if $data40 != @4@ then + return -1 +endi +if $data50 != @2147483647@ then + return -1 +endi +if $data60 != @2147483647@ then + return -1 +endi +if $data70 != @1@ then + return -1 +endi +if $data80 != @2@ then + return -1 +endi +if $data90 != @2@ then + return -1 +endi +print execute sql select abs(c2) from stba; +sql select abs(c2) from stba; +if $data00 != @1@ then + return -1 +endi +if $data10 != @2@ then + return -1 +endi +if $data20 != @3@ then + return -1 +endi +if $data30 != @4@ then + return -1 +endi +if $data40 != @5@ then + return -1 +endi +if $data50 != @6@ then + return -1 +endi +if $data60 != @7@ then + return -1 +endi +if $data70 != @8@ then + return -1 +endi +if $data80 != @9@ then + return -1 +endi +if $data90 != @0@ then + return -1 +endi +print execute sql select abs(min(c2)) from tba1; +sql select abs(min(c2)) from tba1; +if $data00 != @0@ then + return -1 +endi +print execute sql select abs(max(c2)) from tba1; +sql select abs(max(c2)) from tba1; +if $data00 != @9@ then + return -1 +endi +print execute sql select abs(count(c2)) from tba1; +sql select abs(count(c2)) from tba1; +if $data00 != @30@ then + return -1 +endi +print execute sql select abs(sum(c2)) from tba1; +sql select abs(sum(c2)) from tba1; +if $data00 != @135@ then + return -1 +endi +print execute sql select abs(avg(c2)) from tba1; +sql select abs(avg(c2)) from tba1; +if $data00 != @4.500000000@ then + return -1 +endi +print execute sql select abs(percentile(c2, 10)) from tba1; +sql select abs(percentile(c2, 10)) from tba1; +if $data00 != @0.900000000@ then + return -1 +endi +print execute sql select abs(apercentile(c2, 10)) from tba1; +sql select abs(apercentile(c2, 10)) from tba1; +if $data00 != @0.000000000@ then + return -1 +endi +print execute sql select abs(stddev(c2)) from tba1; +sql select abs(stddev(c2)) from tba1; +if $data00 != @2.872281323@ then + return -1 +endi +print execute sql select abs(spread(c2)) from tba1; +sql select abs(spread(c2)) from tba1; +if $data00 != @9.000000000@ then + return -1 +endi +print execute sql select abs(twa(c2)) from tba1; +sql select abs(twa(c2)) from tba1; +if $data00 != @4.637931034@ then + return -1 +endi +print execute sql select abs(leastsquares(c2, 1, 1)) from tba1; +sql_error select abs(leastsquares(c2, 1, 1)) from tba1; +print execute sql select abs(interp(c2)) from tba1 every(1s) +sql select abs(interp(c2)) from tba1 every(1s) +if $data00 != @21-11-11 09:00:00.000@ then + return -1 +endi +if $data01 != @1@ then + return -1 +endi +if $data10 != @21-11-11 09:00:01.000@ then + return -1 +endi +if $data11 != @2@ then + return -1 +endi +if $data20 != @21-11-11 09:00:02.000@ then + return -1 +endi +if $data21 != @3@ then + return -1 +endi +if $data30 != @21-11-11 09:00:03.000@ then + return -1 +endi +if $data31 != @4@ then + return -1 +endi +if $data40 != @21-11-11 09:00:04.000@ then + return -1 +endi +if $data41 != @5@ then + return -1 +endi +if $data50 != @21-11-11 09:00:05.000@ then + return -1 +endi +if $data51 != @6@ then + return -1 +endi +if $data60 != @21-11-11 09:00:06.000@ then + return -1 +endi +if $data61 != @7@ then + return -1 +endi +if $data70 != @21-11-11 09:00:07.000@ then + return -1 +endi +if $data71 != @8@ then + return -1 +endi +if $data80 != @21-11-11 09:00:08.000@ then + return -1 +endi +if $data81 != @9@ then + return -1 +endi +if $data90 != @21-11-11 09:00:09.000@ then + return -1 +endi +if $data91 != @0@ then + return -1 +endi +print execute sql select abs(interp(c2)) from stba every(1s) group by tbname; +sql select abs(interp(c2)) from stba every(1s) group by tbname; +if $data00 != @21-11-11 09:00:00.000@ then + return -1 +endi +if $data01 != @1@ then + return -1 +endi +if $data02 != @tba1@ then + return -1 +endi +if $data10 != @21-11-11 09:00:01.000@ then + return -1 +endi +if $data11 != @2@ then + return -1 +endi +if $data12 != @tba1@ then + return -1 +endi +if $data20 != @21-11-11 09:00:02.000@ then + return -1 +endi +if $data21 != @3@ then + return -1 +endi +if $data22 != @tba1@ then + return -1 +endi +if $data30 != @21-11-11 09:00:03.000@ then + return -1 +endi +if $data31 != @4@ then + return -1 +endi +if $data32 != @tba1@ then + return -1 +endi +if $data40 != @21-11-11 09:00:04.000@ then + return -1 +endi +if $data41 != @5@ then + return -1 +endi +if $data42 != @tba1@ then + return -1 +endi +if $data50 != @21-11-11 09:00:05.000@ then + return -1 +endi +if $data51 != @6@ then + return -1 +endi +if $data52 != @tba1@ then + return -1 +endi +if $data60 != @21-11-11 09:00:06.000@ then + return -1 +endi +if $data61 != @7@ then + return -1 +endi +if $data62 != @tba1@ then + return -1 +endi +if $data70 != @21-11-11 09:00:07.000@ then + return -1 +endi +if $data71 != @8@ then + return -1 +endi +if $data72 != @tba1@ then + return -1 +endi +if $data80 != @21-11-11 09:00:08.000@ then + return -1 +endi +if $data81 != @9@ then + return -1 +endi +if $data82 != @tba1@ then + return -1 +endi +if $data90 != @21-11-11 09:00:09.000@ then + return -1 +endi +if $data91 != @0@ then + return -1 +endi +if $data92 != @tba1@ then + return -1 +endi +print execute sql select abs(elapsed(ts)) from tba1; +sql select abs(elapsed(ts)) from tba1; +if $data00 != @29000.000000000@ then + return -1 +endi +print execute sql select abs(rate(c2)) from tba1; +sql select abs(rate(c2)) from tba1; +if $data00 != @0.896551724@ then + return -1 +endi +print execute sql select abs(irate(c2)) from tba1; +sql select abs(irate(c2)) from tba1; +if $data00 != @0.000000000@ then + return -1 +endi +print execute sql select abs(first(c2)) from tba1; +sql select abs(first(c2)) from tba1; +if $data00 != @1@ then + return -1 +endi +print execute sql select abs(last(c2)) from tba1; +sql select abs(last(c2)) from tba1; +if $data00 != @0@ then + return -1 +endi +print execute sql select abs(last_row(c2)) from tba1; +sql select abs(last_row(c2)) from tba1; +if $data00 != @0@ then + return -1 +endi +print execute sql select abs(top(c2, 1)) from tba1; +sql_error select abs(top(c2, 1)) from tba1; +print execute sql select abs(bottom(c2, 1)) from tba1; +sql_error select abs(bottom(c2, 1)) from tba1; +print execute sql select abs(leastsquares(c2, 1, 1)) from tba1; +sql_error select abs(leastsquares(c2, 1, 1)) from tba1; +print execute sql select abs(derivative(c2, 1s, 0)) from tba1; +sql_error select abs(derivative(c2, 1s, 0)) from tba1; +print execute sql select abs(diff(c2)) from tba1; +sql_error select abs(diff(c2)) from tba1; +print execute sql select abs(csum(c2)) from tba1; +sql_error select abs(csum(c2)) from tba1; +print execute sql select abs(mavg(c2,2)) from tba1; +sql_error select abs(mavg(c2,2)) from tba1; +print execute sql select abs(sample(c2,2)) from tba1; +sql_error select abs(sample(c2,2)) from tba1; +print execute sql select abs(_block_dist()) from tba1; +sql_error select abs(_block_dist()) from tba1; diff --git a/tests/script/general/compute/math_acos.sim b/tests/script/general/compute/math_acos.sim new file mode 100644 index 0000000000000000000000000000000000000000..b91af7e647a210451474b80b3af307ba7a02cb88 --- /dev/null +++ b/tests/script/general/compute/math_acos.sim @@ -0,0 +1,1073 @@ +sleep 100 +sql connect +sql use db + +print execute sql select acos(*) from tb1; +sql_error select acos(*) from tb1; +print execute sql select acos(*) from tb1; +sql_error select acos(*) from tb1; +print execute sql select acos(*) from tb1; +sql_error select acos(*) from tb1; +print execute sql select acos(*) from tb1; +sql_error select acos(*) from tb1; +print execute sql select acos(*) as a from tb1; +sql_error select acos(*) as a from tb1; +print execute sql select acos(*) + 1 as a from tb1; +sql_error select acos(*) + 1 as a from tb1; +print execute sql select acos(tb1.*) + 1 as a from tb1; +sql_error select acos(tb1.*) + 1 as a from tb1; +print execute sql select acos(*) from tb1; +sql_error select acos(*) from tb1; +print execute sql select acos(c1) from tb1; +sql_error select acos(c1) from tb1; +print execute sql select acos(c1) from tb1; +sql_error select acos(c1) from tb1; +print execute sql select acos(c1 + c2) from tb1; +sql_error select acos(c1 + c2) from tb1; +print execute sql select acos(13) from tb1; +sql select acos(13) from tb1; +if $data00 != @nan@ then + return -1 +endi +if $data10 != @nan@ then + return -1 +endi +if $data20 != @nan@ then + return -1 +endi +if $data30 != @nan@ then + return -1 +endi +if $data40 != @nan@ then + return -1 +endi +if $data50 != @nan@ then + return -1 +endi +if $data60 != @nan@ then + return -1 +endi +print execute sql select acos(c1) from tb1; +sql_error select acos(c1) from tb1; +print execute sql select acos(c2) from tb1; +sql select acos(c2) from tb1; +if $data00 != @0.000000000@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data20 != @nan@ then + return -1 +endi +if $data30 != @NULL@ then + return -1 +endi +if $data40 != @nan@ then + return -1 +endi +if $data50 != @nan@ then + return -1 +endi +if $data60 != @nan@ then + return -1 +endi +print execute sql select acos(c3) from tb1; +sql select acos(c3) from tb1; +if $data00 != @0.000000000@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data20 != @NULL@ then + return -1 +endi +if $data30 != @nan@ then + return -1 +endi +if $data40 != @nan@ then + return -1 +endi +if $data50 != @nan@ then + return -1 +endi +if $data60 != @nan@ then + return -1 +endi +print execute sql select acos(c4) from tb1; +sql select acos(c4) from tb1; +if $data00 != @0.000000000@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data20 != @nan@ then + return -1 +endi +if $data30 != @NULL@ then + return -1 +endi +if $data40 != @nan@ then + return -1 +endi +if $data50 != @nan@ then + return -1 +endi +if $data60 != @nan@ then + return -1 +endi +print execute sql select acos(c5) from tb1; +sql select acos(c5) from tb1; +if $data00 != @0.000000000@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data20 != @NULL@ then + return -1 +endi +if $data30 != @nan@ then + return -1 +endi +if $data40 != @nan@ then + return -1 +endi +if $data50 != @nan@ then + return -1 +endi +if $data60 != @nan@ then + return -1 +endi +print execute sql select acos(c6) from tb1; +sql select acos(c6) from tb1; +if $data00 != @0.000000000@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data20 != @nan@ then + return -1 +endi +if $data30 != @NULL@ then + return -1 +endi +if $data40 != @nan@ then + return -1 +endi +if $data50 != @nan@ then + return -1 +endi +if $data60 != @nan@ then + return -1 +endi +print execute sql select acos(c7) from tb1; +sql select acos(c7) from tb1; +if $data00 != @0.000000000@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data20 != @NULL@ then + return -1 +endi +if $data30 != @nan@ then + return -1 +endi +if $data40 != @nan@ then + return -1 +endi +if $data50 != @nan@ then + return -1 +endi +if $data60 != @nan@ then + return -1 +endi +print execute sql select acos(c8) from tb1; +sql_error select acos(c8) from tb1; +print execute sql select acos(c9) from tb1; +sql_error select acos(c9) from tb1; +print execute sql select acos(c10) from tb1; +sql select acos(c10) from tb1; +if $data00 != @0.000000000@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data20 != @nan@ then + return -1 +endi +if $data30 != @NULL@ then + return -1 +endi +if $data40 != @nan@ then + return -1 +endi +if $data50 != @nan@ then + return -1 +endi +if $data60 != @1.570796327@ then + return -1 +endi +print execute sql select acos(c11) from tb1; +sql select acos(c11) from tb1; +if $data00 != @0.000000000@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data20 != @NULL@ then + return -1 +endi +if $data30 != @nan@ then + return -1 +endi +if $data40 != @nan@ then + return -1 +endi +if $data50 != @nan@ then + return -1 +endi +if $data60 != @1.570796327@ then + return -1 +endi +print execute sql select acos(c12) from tb1; +sql select acos(c12) from tb1; +if $data00 != @0.000000000@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data20 != @nan@ then + return -1 +endi +if $data30 != @NULL@ then + return -1 +endi +if $data40 != @nan@ then + return -1 +endi +if $data50 != @nan@ then + return -1 +endi +if $data60 != @1.570796327@ then + return -1 +endi +print execute sql select acos(c13) from tb1; +sql select acos(c13) from tb1; +if $data00 != @0.000000000@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data20 != @NULL@ then + return -1 +endi +if $data30 != @nan@ then + return -1 +endi +if $data40 != @nan@ then + return -1 +endi +if $data50 != @nan@ then + return -1 +endi +if $data60 != @1.570796327@ then + return -1 +endi +print execute sql select acos(12345678900000000000000000) from tb1; +sql_error select acos(12345678900000000000000000) from tb1; +print execute sql select distinct acos(123) from tb1; +sql_error select distinct acos(123) from tb1; +print execute sql select acos(t1) from stb1; +sql_error select acos(t1) from stb1; +print execute sql select acos(c1),avg(c3) from tb1; +sql_error select acos(c1),avg(c3) from tb1; +print execute sql select acos(c1),top(c3,1) from tb1; +sql_error select acos(c1),top(c3,1) from tb1; +print execute sql select acos(c2+c3) from tb1 session(ts, 1s); +sql_error select acos(c2+c3) from tb1 session(ts, 1s); +print execute sql select acos(c2+c3) from tb1 STATE_WINDOW(c1); +sql_error select acos(c2+c3) from tb1 STATE_WINDOW(c1); +print execute sql select acos(c2+c3) from tb1 interval(1s) sliding(1s) fill(NULL); +sql_error select acos(c2+c3) from tb1 interval(1s) sliding(1s) fill(NULL); +print execute sql select acos(c2+c3) from stb1 group by t1; +sql_error select acos(c2+c3) from stb1 group by t1; +print execute sql select acos(c2+c3) from stb1 group by ts; +sql_error select acos(c2+c3) from stb1 group by ts; +print execute sql select acos(c2+c3) from stb1 group by c1; +sql_error select acos(c2+c3) from stb1 group by c1; +print execute sql select acos(c2+c3) from stb1 group by tbname; +sql_error select acos(c2+c3) from stb1 group by tbname; +print execute sql select acos(c2+c3) from tb1 order by c2; +sql_error select acos(c2+c3) from tb1 order by c2; +print execute sql select acos(c8),acos(c9) from tbn; +sql_error select acos(c8),acos(c9) from tbn; +print execute sql select acos(ts) from (select avg(c2) as a from stb1 interval(1s)); +sql_error select acos(ts) from (select avg(c2) as a from stb1 interval(1s)); +print execute sql select acos(a) from (select acos(c2) as a from tb1); +sql select acos(a) from (select acos(c2) as a from tb1); +if $data00 != @1.570796327@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data20 != @nan@ then + return -1 +endi +if $data30 != @NULL@ then + return -1 +endi +if $data40 != @nan@ then + return -1 +endi +if $data50 != @nan@ then + return -1 +endi +if $data60 != @nan@ then + return -1 +endi +print execute sql select acos("abc") from tb1; +sql_error select acos("abc") from tb1; +print execute sql select acos(c2 + c3) from tb1; +sql select acos(c2 + c3) from tb1; +if $data00 != @nan@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data20 != @NULL@ then + return -1 +endi +if $data30 != @NULL@ then + return -1 +endi +if $data40 != @nan@ then + return -1 +endi +if $data50 != @nan@ then + return -1 +endi +if $data60 != @nan@ then + return -1 +endi +print execute sql select acos((c2 + c3)) from tb1; +sql select acos((c2 + c3)) from tb1; +if $data00 != @nan@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data20 != @NULL@ then + return -1 +endi +if $data30 != @NULL@ then + return -1 +endi +if $data40 != @nan@ then + return -1 +endi +if $data50 != @nan@ then + return -1 +endi +if $data60 != @nan@ then + return -1 +endi +print execute sql select acos((c2 * c3)+c4-6) from tb1; +sql select acos((c2 * c3)+c4-6) from tb1; +if $data00 != @nan@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data20 != @NULL@ then + return -1 +endi +if $data30 != @NULL@ then + return -1 +endi +if $data40 != @nan@ then + return -1 +endi +if $data50 != @nan@ then + return -1 +endi +if $data60 != @nan@ then + return -1 +endi +print execute sql select acos(11)+c2 from tb1; +sql select acos(11)+c2 from tb1; +if $data00 != @nan@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data20 != @nan@ then + return -1 +endi +if $data30 != @NULL@ then + return -1 +endi +if $data40 != @nan@ then + return -1 +endi +if $data50 != @nan@ then + return -1 +endi +if $data60 != @nan@ then + return -1 +endi +print execute sql select acos(c1)+c2 from tb1; +sql_error select acos(c1)+c2 from tb1; +print execute sql select acos(c2)+11 from tb1; +sql select acos(c2)+11 from tb1; +if $data00 != @11.000000000@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data20 != @nan@ then + return -1 +endi +if $data30 != @NULL@ then + return -1 +endi +if $data40 != @nan@ then + return -1 +endi +if $data50 != @nan@ then + return -1 +endi +if $data60 != @nan@ then + return -1 +endi +print execute sql select acos(c1),c1,c2 from tb1; +sql_error select acos(c1),c1,c2 from tb1; +print execute sql select acos(c1),t1,ts,tbname,_C0,_c0 from tb1; +sql_error select acos(c1),t1,ts,tbname,_C0,_c0 from tb1; +print execute sql select acos(c1),floor(c3) from tb1; +sql_error select acos(c1),floor(c3) from tb1; +print execute sql select acos(c1),acos(c2+c3) from tb1; +sql_error select acos(c1),acos(c2+c3) from tb1; +print execute sql select acos(c2+c3) from tb1 where c2 is not null and c3 is not null; +sql select acos(c2+c3) from tb1 where c2 is not null and c3 is not null; +if $data00 != @nan@ then + return -1 +endi +if $data10 != @nan@ then + return -1 +endi +if $data20 != @nan@ then + return -1 +endi +if $data30 != @nan@ then + return -1 +endi +print execute sql select acos(c2) from tb1 order by ts desc; +sql select acos(c2) from tb1 order by ts desc; +if $data00 != @nan@ then + return -1 +endi +if $data10 != @nan@ then + return -1 +endi +if $data20 != @nan@ then + return -1 +endi +if $data30 != @NULL@ then + return -1 +endi +if $data40 != @nan@ then + return -1 +endi +if $data50 != @NULL@ then + return -1 +endi +if $data60 != @0.000000000@ then + return -1 +endi +print execute sql select acos(c2+c3) from tb1 order by ts desc; +sql select acos(c2+c3) from tb1 order by ts desc; +if $data00 != @nan@ then + return -1 +endi +if $data10 != @nan@ then + return -1 +endi +if $data20 != @nan@ then + return -1 +endi +if $data30 != @NULL@ then + return -1 +endi +if $data40 != @NULL@ then + return -1 +endi +if $data50 != @NULL@ then + return -1 +endi +if $data60 != @nan@ then + return -1 +endi +print execute sql select acos(c2+c3) from tb1 order by ts desc limit 3 offset 2; +sql select acos(c2+c3) from tb1 order by ts desc limit 3 offset 2; +if $data00 != @nan@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data20 != @NULL@ then + return -1 +endi +print execute sql select acos(c2) from stb1; +sql select acos(c2) from stb1; +if $data00 != @0.000000000@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data20 != @nan@ then + return -1 +endi +if $data30 != @NULL@ then + return -1 +endi +if $data40 != @nan@ then + return -1 +endi +if $data50 != @nan@ then + return -1 +endi +if $data60 != @nan@ then + return -1 +endi +if $data70 != @0.000000000@ then + return -1 +endi +if $data80 != @nan@ then + return -1 +endi +if $data90 != @nan@ then + return -1 +endi +print execute sql select acos(c2) from stb1 order by ts desc; +sql select acos(c2) from stb1 order by ts desc; +if $data00 != @nan@ then + if $data00 != @nan@ then + return -1 + endi +endi +if $data20 != @nan@ then + if $data20 != @nan@ then + return -1 + endi +endi +if $data40 != @nan@ then + if $data40 != @nan@ then + return -1 + endi +endi +if $data60 != @nan@ then + if $data60 != @NULL@ then + return -1 + endi +endi +if $data80 != @nan@ then + if $data80 != @nan@ then + return -1 + endi +endi +print execute sql select acos(c4),t1 from stb1 order by ts desc; +sql select acos(c4),t1 from stb1 order by ts desc; +if $data00 != @nan@ then + if $data00 != @nan@ then + return -1 + endi +endi +if $data01 != @2@ then + if $data01 != @1@ then + return -1 + endi +endi +if $data20 != @nan@ then + if $data20 != @nan@ then + return -1 + endi +endi +if $data21 != @2@ then + if $data21 != @1@ then + return -1 + endi +endi +if $data40 != @nan@ then + if $data40 != @nan@ then + return -1 + endi +endi +if $data41 != @2@ then + if $data41 != @1@ then + return -1 + endi +endi +if $data60 != @nan@ then + if $data60 != @NULL@ then + return -1 + endi +endi +if $data61 != @2@ then + if $data61 != @1@ then + return -1 + endi +endi +if $data80 != @nan@ then + if $data80 != @nan@ then + return -1 + endi +endi +if $data81 != @2@ then + if $data81 != @1@ then + return -1 + endi +endi +print execute sql select acos(c3),tbname from stb1; +sql select acos(c3),tbname from stb1; +if $data00 != @0.000000000@ then + return -1 +endi +if $data01 != @tb1@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data11 != @tb1@ then + return -1 +endi +if $data20 != @NULL@ then + return -1 +endi +if $data21 != @tb1@ then + return -1 +endi +if $data30 != @nan@ then + return -1 +endi +if $data31 != @tb1@ then + return -1 +endi +if $data40 != @nan@ then + return -1 +endi +if $data41 != @tb1@ then + return -1 +endi +if $data50 != @nan@ then + return -1 +endi +if $data51 != @tb1@ then + return -1 +endi +if $data60 != @nan@ then + return -1 +endi +if $data61 != @tb1@ then + return -1 +endi +if $data70 != @0.000000000@ then + return -1 +endi +if $data71 != @tb2@ then + return -1 +endi +if $data80 != @nan@ then + return -1 +endi +if $data81 != @tb2@ then + return -1 +endi +if $data90 != @nan@ then + return -1 +endi +if $data91 != @tb2@ then + return -1 +endi +print execute sql select acos(c3),tbname from stb1 where t1 > 1; +sql select acos(c3),tbname from stb1 where t1 > 1; +if $data00 != @0.000000000@ then + return -1 +endi +if $data01 != @tb2@ then + return -1 +endi +if $data10 != @nan@ then + return -1 +endi +if $data11 != @tb2@ then + return -1 +endi +if $data20 != @nan@ then + return -1 +endi +if $data21 != @tb2@ then + return -1 +endi +if $data30 != @nan@ then + return -1 +endi +if $data31 != @tb2@ then + return -1 +endi +if $data40 != @nan@ then + return -1 +endi +if $data41 != @tb2@ then + return -1 +endi +if $data50 != @nan@ then + return -1 +endi +if $data51 != @tb2@ then + return -1 +endi +if $data60 != @nan@ then + return -1 +endi +if $data61 != @tb2@ then + return -1 +endi +print execute sql select acos(c8),acos(c9) from tbn; +sql_error select acos(c8),acos(c9) from tbn; +print execute sql select acos(c8),acos(c9) from tbn order by ts desc; +sql_error select acos(c8),acos(c9) from tbn order by ts desc; +print execute sql select acos(acos(c8)) from tbn; +sql_error select acos(acos(c8)) from tbn; +print execute sql select acos(a) from (select avg(c2) as a from stb1 interval(1s)); +sql select acos(a) from (select avg(c2) as a from stb1 interval(1s)); +if $data00 != @0.000000000@ then + return -1 +endi +if $data10 != @nan@ then + return -1 +endi +if $data20 != @nan@ then + return -1 +endi +if $data30 != @nan@ then + return -1 +endi +if $data40 != @nan@ then + return -1 +endi +if $data50 != @nan@ then + return -1 +endi +if $data60 != @nan@ then + return -1 +endi +print execute sql select acos(c2) from (select * from stb1); +sql select acos(c2) from (select * from stb1); +if $data00 != @0.000000000@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data20 != @nan@ then + return -1 +endi +if $data30 != @NULL@ then + return -1 +endi +if $data40 != @nan@ then + return -1 +endi +if $data50 != @nan@ then + return -1 +endi +if $data60 != @nan@ then + return -1 +endi +if $data70 != @0.000000000@ then + return -1 +endi +if $data80 != @nan@ then + return -1 +endi +if $data90 != @nan@ then + return -1 +endi +print execute sql select acos(a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)); +sql select acos(a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)); +if $data00 != @0.000000000@ then + return -1 +endi +if $data10 != @nan@ then + return -1 +endi +if $data20 != @nan@ then + return -1 +endi +if $data30 != @nan@ then + return -1 +endi +if $data40 != @nan@ then + return -1 +endi +if $data50 != @nan@ then + return -1 +endi +if $data60 != @nan@ then + return -1 +endi +if $data70 != @NULL@ then + return -1 +endi +if $data80 != @NULL@ then + return -1 +endi +if $data90 != @NULL@ then + return -1 +endi +print execute sql select acos(a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)) order by ts; +sql select acos(a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)) order by ts; +if $data00 != @0.000000000@ then + return -1 +endi +if $data10 != @nan@ then + return -1 +endi +if $data20 != @nan@ then + return -1 +endi +if $data30 != @nan@ then + return -1 +endi +if $data40 != @nan@ then + return -1 +endi +if $data50 != @nan@ then + return -1 +endi +if $data60 != @nan@ then + return -1 +endi +if $data70 != @NULL@ then + return -1 +endi +if $data80 != @NULL@ then + return -1 +endi +if $data90 != @NULL@ then + return -1 +endi +print execute sql select acos(a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)) order by ts desc; +sql select acos(a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)) order by ts desc; +if $data00 != @NULL@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data20 != @NULL@ then + return -1 +endi +if $data30 != @nan@ then + return -1 +endi +if $data40 != @nan@ then + return -1 +endi +if $data50 != @nan@ then + return -1 +endi +if $data60 != @nan@ then + return -1 +endi +if $data70 != @nan@ then + return -1 +endi +if $data80 != @nan@ then + return -1 +endi +if $data90 != @0.000000000@ then + return -1 +endi +print execute sql select acos(a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)) order by a desc; +sql select acos(a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)) order by a desc; +if $data00 != @NULL@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data20 != @NULL@ then + return -1 +endi +if $data30 != @nan@ then + return -1 +endi +if $data40 != @nan@ then + return -1 +endi +if $data50 != @nan@ then + return -1 +endi +if $data60 != @nan@ then + return -1 +endi +if $data70 != @nan@ then + return -1 +endi +if $data80 != @0.000000000@ then + return -1 +endi +if $data90 != @nan@ then + return -1 +endi +print execute sql select acos(a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)) order by a; +sql select acos(a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)) order by a; +if $data00 != @nan@ then + return -1 +endi +if $data10 != @0.000000000@ then + return -1 +endi +if $data20 != @nan@ then + return -1 +endi +if $data30 != @nan@ then + return -1 +endi +if $data40 != @nan@ then + return -1 +endi +if $data50 != @nan@ then + return -1 +endi +if $data60 != @nan@ then + return -1 +endi +if $data70 != @NULL@ then + return -1 +endi +if $data80 != @NULL@ then + return -1 +endi +if $data90 != @NULL@ then + return -1 +endi +print execute sql select acos(a) from (select acos(c2) as a from tb1); +sql select acos(a) from (select acos(c2) as a from tb1); +if $data00 != @1.570796327@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data20 != @nan@ then + return -1 +endi +if $data30 != @NULL@ then + return -1 +endi +if $data40 != @nan@ then + return -1 +endi +if $data50 != @nan@ then + return -1 +endi +if $data60 != @nan@ then + return -1 +endi +print execute sql select acos(tb1.c3),acos(tb2.c3) from tb1,tb2 where tb1.ts=tb2.ts; +sql select acos(tb1.c3),acos(tb2.c3) from tb1,tb2 where tb1.ts=tb2.ts; +if $data00 != @0.000000000@ then + return -1 +endi +if $data01 != @0.000000000@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data11 != @nan@ then + return -1 +endi +if $data20 != @NULL@ then + return -1 +endi +if $data21 != @nan@ then + return -1 +endi +if $data30 != @nan@ then + return -1 +endi +if $data31 != @nan@ then + return -1 +endi +if $data40 != @nan@ then + return -1 +endi +if $data41 != @nan@ then + return -1 +endi +if $data50 != @nan@ then + return -1 +endi +if $data51 != @nan@ then + return -1 +endi +if $data60 != @nan@ then + return -1 +endi +if $data61 != @nan@ then + return -1 +endi +print execute sql select acos(c3) from tb1 union all select acos(c3) from tb2; +sql select acos(c3) from tb1 union all select acos(c3) from tb2; +if $data00 != @0.000000000@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data20 != @NULL@ then + return -1 +endi +if $data30 != @nan@ then + return -1 +endi +if $data40 != @nan@ then + return -1 +endi +if $data50 != @nan@ then + return -1 +endi +if $data60 != @nan@ then + return -1 +endi +if $data70 != @0.000000000@ then + return -1 +endi +if $data80 != @nan@ then + return -1 +endi +if $data90 != @nan@ then + return -1 +endi diff --git a/tests/script/general/compute/math_acos2.sim b/tests/script/general/compute/math_acos2.sim new file mode 100644 index 0000000000000000000000000000000000000000..01a83eb4d46f1ae637cd2cde0dec412cb81b7497 --- /dev/null +++ b/tests/script/general/compute/math_acos2.sim @@ -0,0 +1,366 @@ +sleep 100 +sql connect +sql use db + +print execute sql select acos(stb1.c4),acos(stba.c5) from stb1,stba where stb1.t1=stba.t1 and stb1.ts=stba.ts; +sql select acos(stb1.c4),acos(stba.c5) from stb1,stba where stb1.t1=stba.t1 and stb1.ts=stba.ts; +if $data00 != @0.000000000@ then + return -1 +endi +if $data01 != @0.000000000@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data11 != @nan@ then + return -1 +endi +if $data20 != @nan@ then + return -1 +endi +if $data21 != @nan@ then + return -1 +endi +if $data30 != @NULL@ then + return -1 +endi +if $data31 != @nan@ then + return -1 +endi +if $data40 != @nan@ then + return -1 +endi +if $data41 != @nan@ then + return -1 +endi +if $data50 != @nan@ then + return -1 +endi +if $data51 != @nan@ then + return -1 +endi +if $data60 != @nan@ then + return -1 +endi +if $data61 != @nan@ then + return -1 +endi +print execute sql select acos(c4) as a from stb1 union all select acos(c5) as a from stba; +sql select acos(c4) as a from stb1 union all select acos(c5) as a from stba; +if $data00 != @0.000000000@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data20 != @nan@ then + return -1 +endi +if $data30 != @NULL@ then + return -1 +endi +if $data40 != @nan@ then + return -1 +endi +if $data50 != @nan@ then + return -1 +endi +if $data60 != @nan@ then + return -1 +endi +if $data70 != @0.000000000@ then + return -1 +endi +if $data80 != @nan@ then + return -1 +endi +if $data90 != @nan@ then + return -1 +endi +print execute sql select acos(c2) from stba; +sql select acos(c2) from stba; +if $data00 != @0.000000000@ then + return -1 +endi +if $data10 != @nan@ then + return -1 +endi +if $data20 != @nan@ then + return -1 +endi +if $data30 != @nan@ then + return -1 +endi +if $data40 != @nan@ then + return -1 +endi +if $data50 != @nan@ then + return -1 +endi +if $data60 != @nan@ then + return -1 +endi +if $data70 != @nan@ then + return -1 +endi +if $data80 != @nan@ then + return -1 +endi +if $data90 != @1.570796327@ then + return -1 +endi +print execute sql select acos(min(c2)) from tba1; +sql select acos(min(c2)) from tba1; +if $data00 != @1.570796327@ then + return -1 +endi +print execute sql select acos(max(c2)) from tba1; +sql select acos(max(c2)) from tba1; +if $data00 != @nan@ then + return -1 +endi +print execute sql select acos(count(c2)) from tba1; +sql select acos(count(c2)) from tba1; +if $data00 != @nan@ then + return -1 +endi +print execute sql select acos(sum(c2)) from tba1; +sql select acos(sum(c2)) from tba1; +if $data00 != @nan@ then + return -1 +endi +print execute sql select acos(avg(c2)) from tba1; +sql select acos(avg(c2)) from tba1; +if $data00 != @nan@ then + return -1 +endi +print execute sql select acos(percentile(c2, 10)) from tba1; +sql select acos(percentile(c2, 10)) from tba1; +if $data00 != @0.451026812@ then + return -1 +endi +print execute sql select acos(apercentile(c2, 10)) from tba1; +sql select acos(apercentile(c2, 10)) from tba1; +if $data00 != @1.570796327@ then + return -1 +endi +print execute sql select acos(stddev(c2)) from tba1; +sql select acos(stddev(c2)) from tba1; +if $data00 != @nan@ then + return -1 +endi +print execute sql select acos(spread(c2)) from tba1; +sql select acos(spread(c2)) from tba1; +if $data00 != @nan@ then + return -1 +endi +print execute sql select acos(twa(c2)) from tba1; +sql select acos(twa(c2)) from tba1; +if $data00 != @nan@ then + return -1 +endi +print execute sql select acos(leastsquares(c2, 1, 1)) from tba1; +sql_error select acos(leastsquares(c2, 1, 1)) from tba1; +print execute sql select acos(interp(c2)) from tba1 every(1s) +sql select acos(interp(c2)) from tba1 every(1s) +if $data00 != @21-11-11 09:00:00.000@ then + return -1 +endi +if $data01 != @0.000000000@ then + return -1 +endi +if $data10 != @21-11-11 09:00:01.000@ then + return -1 +endi +if $data11 != @nan@ then + return -1 +endi +if $data20 != @21-11-11 09:00:02.000@ then + return -1 +endi +if $data21 != @nan@ then + return -1 +endi +if $data30 != @21-11-11 09:00:03.000@ then + return -1 +endi +if $data31 != @nan@ then + return -1 +endi +if $data40 != @21-11-11 09:00:04.000@ then + return -1 +endi +if $data41 != @nan@ then + return -1 +endi +if $data50 != @21-11-11 09:00:05.000@ then + return -1 +endi +if $data51 != @nan@ then + return -1 +endi +if $data60 != @21-11-11 09:00:06.000@ then + return -1 +endi +if $data61 != @nan@ then + return -1 +endi +if $data70 != @21-11-11 09:00:07.000@ then + return -1 +endi +if $data71 != @nan@ then + return -1 +endi +if $data80 != @21-11-11 09:00:08.000@ then + return -1 +endi +if $data81 != @nan@ then + return -1 +endi +if $data90 != @21-11-11 09:00:09.000@ then + return -1 +endi +if $data91 != @1.570796327@ then + return -1 +endi +print execute sql select acos(interp(c2)) from stba every(1s) group by tbname; +sql select acos(interp(c2)) from stba every(1s) group by tbname; +if $data00 != @21-11-11 09:00:00.000@ then + return -1 +endi +if $data01 != @0.000000000@ then + return -1 +endi +if $data02 != @tba1@ then + return -1 +endi +if $data10 != @21-11-11 09:00:01.000@ then + return -1 +endi +if $data11 != @nan@ then + return -1 +endi +if $data12 != @tba1@ then + return -1 +endi +if $data20 != @21-11-11 09:00:02.000@ then + return -1 +endi +if $data21 != @nan@ then + return -1 +endi +if $data22 != @tba1@ then + return -1 +endi +if $data30 != @21-11-11 09:00:03.000@ then + return -1 +endi +if $data31 != @nan@ then + return -1 +endi +if $data32 != @tba1@ then + return -1 +endi +if $data40 != @21-11-11 09:00:04.000@ then + return -1 +endi +if $data41 != @nan@ then + return -1 +endi +if $data42 != @tba1@ then + return -1 +endi +if $data50 != @21-11-11 09:00:05.000@ then + return -1 +endi +if $data51 != @nan@ then + return -1 +endi +if $data52 != @tba1@ then + return -1 +endi +if $data60 != @21-11-11 09:00:06.000@ then + return -1 +endi +if $data61 != @nan@ then + return -1 +endi +if $data62 != @tba1@ then + return -1 +endi +if $data70 != @21-11-11 09:00:07.000@ then + return -1 +endi +if $data71 != @nan@ then + return -1 +endi +if $data72 != @tba1@ then + return -1 +endi +if $data80 != @21-11-11 09:00:08.000@ then + return -1 +endi +if $data81 != @nan@ then + return -1 +endi +if $data82 != @tba1@ then + return -1 +endi +if $data90 != @21-11-11 09:00:09.000@ then + return -1 +endi +if $data91 != @1.570796327@ then + return -1 +endi +if $data92 != @tba1@ then + return -1 +endi +print execute sql select acos(elapsed(ts)) from tba1; +sql select acos(elapsed(ts)) from tba1; +if $data00 != @nan@ then + return -1 +endi +print execute sql select acos(rate(c2)) from tba1; +sql select acos(rate(c2)) from tba1; +if $data00 != @0.458874205@ then + return -1 +endi +print execute sql select acos(irate(c2)) from tba1; +sql select acos(irate(c2)) from tba1; +if $data00 != @1.570796327@ then + return -1 +endi +print execute sql select acos(first(c2)) from tba1; +sql select acos(first(c2)) from tba1; +if $data00 != @0.000000000@ then + return -1 +endi +print execute sql select acos(last(c2)) from tba1; +sql select acos(last(c2)) from tba1; +if $data00 != @1.570796327@ then + return -1 +endi +print execute sql select acos(last_row(c2)) from tba1; +sql select acos(last_row(c2)) from tba1; +if $data00 != @1.570796327@ then + return -1 +endi +print execute sql select acos(top(c2, 1)) from tba1; +sql_error select acos(top(c2, 1)) from tba1; +print execute sql select acos(bottom(c2, 1)) from tba1; +sql_error select acos(bottom(c2, 1)) from tba1; +print execute sql select acos(leastsquares(c2, 1, 1)) from tba1; +sql_error select acos(leastsquares(c2, 1, 1)) from tba1; +print execute sql select acos(derivative(c2, 1s, 0)) from tba1; +sql_error select acos(derivative(c2, 1s, 0)) from tba1; +print execute sql select acos(diff(c2)) from tba1; +sql_error select acos(diff(c2)) from tba1; +print execute sql select acos(csum(c2)) from tba1; +sql_error select acos(csum(c2)) from tba1; +print execute sql select acos(mavg(c2,2)) from tba1; +sql_error select acos(mavg(c2,2)) from tba1; +print execute sql select acos(sample(c2,2)) from tba1; +sql_error select acos(sample(c2,2)) from tba1; +print execute sql select acos(_block_dist()) from tba1; +sql_error select acos(_block_dist()) from tba1; diff --git a/tests/script/general/compute/math_asin.sim b/tests/script/general/compute/math_asin.sim new file mode 100644 index 0000000000000000000000000000000000000000..dee8bffaf35135fca1d31878dabc25efd2a3146a --- /dev/null +++ b/tests/script/general/compute/math_asin.sim @@ -0,0 +1,1073 @@ +sleep 100 +sql connect +sql use db + +print execute sql select asin(*) from tb1; +sql_error select asin(*) from tb1; +print execute sql select asin(*) from tb1; +sql_error select asin(*) from tb1; +print execute sql select asin(*) from tb1; +sql_error select asin(*) from tb1; +print execute sql select asin(*) from tb1; +sql_error select asin(*) from tb1; +print execute sql select asin(*) as a from tb1; +sql_error select asin(*) as a from tb1; +print execute sql select asin(*) + 1 as a from tb1; +sql_error select asin(*) + 1 as a from tb1; +print execute sql select asin(tb1.*) + 1 as a from tb1; +sql_error select asin(tb1.*) + 1 as a from tb1; +print execute sql select asin(*) from tb1; +sql_error select asin(*) from tb1; +print execute sql select asin(c1) from tb1; +sql_error select asin(c1) from tb1; +print execute sql select asin(c1) from tb1; +sql_error select asin(c1) from tb1; +print execute sql select asin(c1 + c2) from tb1; +sql_error select asin(c1 + c2) from tb1; +print execute sql select asin(13) from tb1; +sql select asin(13) from tb1; +if $data00 != @nan@ then + return -1 +endi +if $data10 != @nan@ then + return -1 +endi +if $data20 != @nan@ then + return -1 +endi +if $data30 != @nan@ then + return -1 +endi +if $data40 != @nan@ then + return -1 +endi +if $data50 != @nan@ then + return -1 +endi +if $data60 != @nan@ then + return -1 +endi +print execute sql select asin(c1) from tb1; +sql_error select asin(c1) from tb1; +print execute sql select asin(c2) from tb1; +sql select asin(c2) from tb1; +if $data00 != @1.570796327@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data20 != @nan@ then + return -1 +endi +if $data30 != @NULL@ then + return -1 +endi +if $data40 != @nan@ then + return -1 +endi +if $data50 != @nan@ then + return -1 +endi +if $data60 != @nan@ then + return -1 +endi +print execute sql select asin(c3) from tb1; +sql select asin(c3) from tb1; +if $data00 != @1.570796327@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data20 != @NULL@ then + return -1 +endi +if $data30 != @nan@ then + return -1 +endi +if $data40 != @nan@ then + return -1 +endi +if $data50 != @nan@ then + return -1 +endi +if $data60 != @nan@ then + return -1 +endi +print execute sql select asin(c4) from tb1; +sql select asin(c4) from tb1; +if $data00 != @1.570796327@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data20 != @nan@ then + return -1 +endi +if $data30 != @NULL@ then + return -1 +endi +if $data40 != @nan@ then + return -1 +endi +if $data50 != @nan@ then + return -1 +endi +if $data60 != @nan@ then + return -1 +endi +print execute sql select asin(c5) from tb1; +sql select asin(c5) from tb1; +if $data00 != @1.570796327@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data20 != @NULL@ then + return -1 +endi +if $data30 != @nan@ then + return -1 +endi +if $data40 != @nan@ then + return -1 +endi +if $data50 != @nan@ then + return -1 +endi +if $data60 != @nan@ then + return -1 +endi +print execute sql select asin(c6) from tb1; +sql select asin(c6) from tb1; +if $data00 != @1.570796327@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data20 != @nan@ then + return -1 +endi +if $data30 != @NULL@ then + return -1 +endi +if $data40 != @nan@ then + return -1 +endi +if $data50 != @nan@ then + return -1 +endi +if $data60 != @nan@ then + return -1 +endi +print execute sql select asin(c7) from tb1; +sql select asin(c7) from tb1; +if $data00 != @1.570796327@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data20 != @NULL@ then + return -1 +endi +if $data30 != @nan@ then + return -1 +endi +if $data40 != @nan@ then + return -1 +endi +if $data50 != @nan@ then + return -1 +endi +if $data60 != @nan@ then + return -1 +endi +print execute sql select asin(c8) from tb1; +sql_error select asin(c8) from tb1; +print execute sql select asin(c9) from tb1; +sql_error select asin(c9) from tb1; +print execute sql select asin(c10) from tb1; +sql select asin(c10) from tb1; +if $data00 != @1.570796327@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data20 != @nan@ then + return -1 +endi +if $data30 != @NULL@ then + return -1 +endi +if $data40 != @nan@ then + return -1 +endi +if $data50 != @nan@ then + return -1 +endi +if $data60 != @0.000000000@ then + return -1 +endi +print execute sql select asin(c11) from tb1; +sql select asin(c11) from tb1; +if $data00 != @1.570796327@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data20 != @NULL@ then + return -1 +endi +if $data30 != @nan@ then + return -1 +endi +if $data40 != @nan@ then + return -1 +endi +if $data50 != @nan@ then + return -1 +endi +if $data60 != @0.000000000@ then + return -1 +endi +print execute sql select asin(c12) from tb1; +sql select asin(c12) from tb1; +if $data00 != @1.570796327@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data20 != @nan@ then + return -1 +endi +if $data30 != @NULL@ then + return -1 +endi +if $data40 != @nan@ then + return -1 +endi +if $data50 != @nan@ then + return -1 +endi +if $data60 != @0.000000000@ then + return -1 +endi +print execute sql select asin(c13) from tb1; +sql select asin(c13) from tb1; +if $data00 != @1.570796327@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data20 != @NULL@ then + return -1 +endi +if $data30 != @nan@ then + return -1 +endi +if $data40 != @nan@ then + return -1 +endi +if $data50 != @nan@ then + return -1 +endi +if $data60 != @0.000000000@ then + return -1 +endi +print execute sql select asin(12345678900000000000000000) from tb1; +sql_error select asin(12345678900000000000000000) from tb1; +print execute sql select distinct asin(123) from tb1; +sql_error select distinct asin(123) from tb1; +print execute sql select asin(t1) from stb1; +sql_error select asin(t1) from stb1; +print execute sql select asin(c1),avg(c3) from tb1; +sql_error select asin(c1),avg(c3) from tb1; +print execute sql select asin(c1),top(c3,1) from tb1; +sql_error select asin(c1),top(c3,1) from tb1; +print execute sql select asin(c2+c3) from tb1 session(ts, 1s); +sql_error select asin(c2+c3) from tb1 session(ts, 1s); +print execute sql select asin(c2+c3) from tb1 STATE_WINDOW(c1); +sql_error select asin(c2+c3) from tb1 STATE_WINDOW(c1); +print execute sql select asin(c2+c3) from tb1 interval(1s) sliding(1s) fill(NULL); +sql_error select asin(c2+c3) from tb1 interval(1s) sliding(1s) fill(NULL); +print execute sql select asin(c2+c3) from stb1 group by t1; +sql_error select asin(c2+c3) from stb1 group by t1; +print execute sql select asin(c2+c3) from stb1 group by ts; +sql_error select asin(c2+c3) from stb1 group by ts; +print execute sql select asin(c2+c3) from stb1 group by c1; +sql_error select asin(c2+c3) from stb1 group by c1; +print execute sql select asin(c2+c3) from stb1 group by tbname; +sql_error select asin(c2+c3) from stb1 group by tbname; +print execute sql select asin(c2+c3) from tb1 order by c2; +sql_error select asin(c2+c3) from tb1 order by c2; +print execute sql select asin(c8),asin(c9) from tbn; +sql_error select asin(c8),asin(c9) from tbn; +print execute sql select asin(ts) from (select avg(c2) as a from stb1 interval(1s)); +sql_error select asin(ts) from (select avg(c2) as a from stb1 interval(1s)); +print execute sql select asin(a) from (select asin(c2) as a from tb1); +sql select asin(a) from (select asin(c2) as a from tb1); +if $data00 != @nan@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data20 != @nan@ then + return -1 +endi +if $data30 != @NULL@ then + return -1 +endi +if $data40 != @nan@ then + return -1 +endi +if $data50 != @nan@ then + return -1 +endi +if $data60 != @nan@ then + return -1 +endi +print execute sql select asin("abc") from tb1; +sql_error select asin("abc") from tb1; +print execute sql select asin(c2 + c3) from tb1; +sql select asin(c2 + c3) from tb1; +if $data00 != @nan@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data20 != @NULL@ then + return -1 +endi +if $data30 != @NULL@ then + return -1 +endi +if $data40 != @nan@ then + return -1 +endi +if $data50 != @nan@ then + return -1 +endi +if $data60 != @nan@ then + return -1 +endi +print execute sql select asin((c2 + c3)) from tb1; +sql select asin((c2 + c3)) from tb1; +if $data00 != @nan@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data20 != @NULL@ then + return -1 +endi +if $data30 != @NULL@ then + return -1 +endi +if $data40 != @nan@ then + return -1 +endi +if $data50 != @nan@ then + return -1 +endi +if $data60 != @nan@ then + return -1 +endi +print execute sql select asin((c2 * c3)+c4-6) from tb1; +sql select asin((c2 * c3)+c4-6) from tb1; +if $data00 != @nan@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data20 != @NULL@ then + return -1 +endi +if $data30 != @NULL@ then + return -1 +endi +if $data40 != @nan@ then + return -1 +endi +if $data50 != @nan@ then + return -1 +endi +if $data60 != @nan@ then + return -1 +endi +print execute sql select asin(11)+c2 from tb1; +sql select asin(11)+c2 from tb1; +if $data00 != @nan@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data20 != @nan@ then + return -1 +endi +if $data30 != @NULL@ then + return -1 +endi +if $data40 != @nan@ then + return -1 +endi +if $data50 != @nan@ then + return -1 +endi +if $data60 != @nan@ then + return -1 +endi +print execute sql select asin(c1)+c2 from tb1; +sql_error select asin(c1)+c2 from tb1; +print execute sql select asin(c2)+11 from tb1; +sql select asin(c2)+11 from tb1; +if $data00 != @12.570796327@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data20 != @nan@ then + return -1 +endi +if $data30 != @NULL@ then + return -1 +endi +if $data40 != @nan@ then + return -1 +endi +if $data50 != @nan@ then + return -1 +endi +if $data60 != @nan@ then + return -1 +endi +print execute sql select asin(c1),c1,c2 from tb1; +sql_error select asin(c1),c1,c2 from tb1; +print execute sql select asin(c1),t1,ts,tbname,_C0,_c0 from tb1; +sql_error select asin(c1),t1,ts,tbname,_C0,_c0 from tb1; +print execute sql select asin(c1),floor(c3) from tb1; +sql_error select asin(c1),floor(c3) from tb1; +print execute sql select asin(c1),asin(c2+c3) from tb1; +sql_error select asin(c1),asin(c2+c3) from tb1; +print execute sql select asin(c2+c3) from tb1 where c2 is not null and c3 is not null; +sql select asin(c2+c3) from tb1 where c2 is not null and c3 is not null; +if $data00 != @nan@ then + return -1 +endi +if $data10 != @nan@ then + return -1 +endi +if $data20 != @nan@ then + return -1 +endi +if $data30 != @nan@ then + return -1 +endi +print execute sql select asin(c2) from tb1 order by ts desc; +sql select asin(c2) from tb1 order by ts desc; +if $data00 != @nan@ then + return -1 +endi +if $data10 != @nan@ then + return -1 +endi +if $data20 != @nan@ then + return -1 +endi +if $data30 != @NULL@ then + return -1 +endi +if $data40 != @nan@ then + return -1 +endi +if $data50 != @NULL@ then + return -1 +endi +if $data60 != @1.570796327@ then + return -1 +endi +print execute sql select asin(c2+c3) from tb1 order by ts desc; +sql select asin(c2+c3) from tb1 order by ts desc; +if $data00 != @nan@ then + return -1 +endi +if $data10 != @nan@ then + return -1 +endi +if $data20 != @nan@ then + return -1 +endi +if $data30 != @NULL@ then + return -1 +endi +if $data40 != @NULL@ then + return -1 +endi +if $data50 != @NULL@ then + return -1 +endi +if $data60 != @nan@ then + return -1 +endi +print execute sql select asin(c2+c3) from tb1 order by ts desc limit 3 offset 2; +sql select asin(c2+c3) from tb1 order by ts desc limit 3 offset 2; +if $data00 != @nan@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data20 != @NULL@ then + return -1 +endi +print execute sql select asin(c2) from stb1; +sql select asin(c2) from stb1; +if $data00 != @1.570796327@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data20 != @nan@ then + return -1 +endi +if $data30 != @NULL@ then + return -1 +endi +if $data40 != @nan@ then + return -1 +endi +if $data50 != @nan@ then + return -1 +endi +if $data60 != @nan@ then + return -1 +endi +if $data70 != @1.570796327@ then + return -1 +endi +if $data80 != @nan@ then + return -1 +endi +if $data90 != @nan@ then + return -1 +endi +print execute sql select asin(c2) from stb1 order by ts desc; +sql select asin(c2) from stb1 order by ts desc; +if $data00 != @nan@ then + if $data00 != @nan@ then + return -1 + endi +endi +if $data20 != @nan@ then + if $data20 != @nan@ then + return -1 + endi +endi +if $data40 != @nan@ then + if $data40 != @nan@ then + return -1 + endi +endi +if $data60 != @NULL@ then + if $data60 != @nan@ then + return -1 + endi +endi +if $data80 != @nan@ then + if $data80 != @nan@ then + return -1 + endi +endi +print execute sql select asin(c4),t1 from stb1 order by ts desc; +sql select asin(c4),t1 from stb1 order by ts desc; +if $data00 != @nan@ then + if $data00 != @nan@ then + return -1 + endi +endi +if $data01 != @1@ then + if $data01 != @2@ then + return -1 + endi +endi +if $data20 != @nan@ then + if $data20 != @nan@ then + return -1 + endi +endi +if $data21 != @1@ then + if $data21 != @2@ then + return -1 + endi +endi +if $data40 != @nan@ then + if $data40 != @nan@ then + return -1 + endi +endi +if $data41 != @1@ then + if $data41 != @2@ then + return -1 + endi +endi +if $data60 != @NULL@ then + if $data60 != @nan@ then + return -1 + endi +endi +if $data61 != @1@ then + if $data61 != @2@ then + return -1 + endi +endi +if $data80 != @nan@ then + if $data80 != @nan@ then + return -1 + endi +endi +if $data81 != @1@ then + if $data81 != @2@ then + return -1 + endi +endi +print execute sql select asin(c3),tbname from stb1; +sql select asin(c3),tbname from stb1; +if $data00 != @1.570796327@ then + return -1 +endi +if $data01 != @tb1@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data11 != @tb1@ then + return -1 +endi +if $data20 != @NULL@ then + return -1 +endi +if $data21 != @tb1@ then + return -1 +endi +if $data30 != @nan@ then + return -1 +endi +if $data31 != @tb1@ then + return -1 +endi +if $data40 != @nan@ then + return -1 +endi +if $data41 != @tb1@ then + return -1 +endi +if $data50 != @nan@ then + return -1 +endi +if $data51 != @tb1@ then + return -1 +endi +if $data60 != @nan@ then + return -1 +endi +if $data61 != @tb1@ then + return -1 +endi +if $data70 != @1.570796327@ then + return -1 +endi +if $data71 != @tb2@ then + return -1 +endi +if $data80 != @nan@ then + return -1 +endi +if $data81 != @tb2@ then + return -1 +endi +if $data90 != @nan@ then + return -1 +endi +if $data91 != @tb2@ then + return -1 +endi +print execute sql select asin(c3),tbname from stb1 where t1 > 1; +sql select asin(c3),tbname from stb1 where t1 > 1; +if $data00 != @1.570796327@ then + return -1 +endi +if $data01 != @tb2@ then + return -1 +endi +if $data10 != @nan@ then + return -1 +endi +if $data11 != @tb2@ then + return -1 +endi +if $data20 != @nan@ then + return -1 +endi +if $data21 != @tb2@ then + return -1 +endi +if $data30 != @nan@ then + return -1 +endi +if $data31 != @tb2@ then + return -1 +endi +if $data40 != @nan@ then + return -1 +endi +if $data41 != @tb2@ then + return -1 +endi +if $data50 != @nan@ then + return -1 +endi +if $data51 != @tb2@ then + return -1 +endi +if $data60 != @nan@ then + return -1 +endi +if $data61 != @tb2@ then + return -1 +endi +print execute sql select asin(c8),asin(c9) from tbn; +sql_error select asin(c8),asin(c9) from tbn; +print execute sql select asin(c8),asin(c9) from tbn order by ts desc; +sql_error select asin(c8),asin(c9) from tbn order by ts desc; +print execute sql select asin(asin(c8)) from tbn; +sql_error select asin(asin(c8)) from tbn; +print execute sql select asin(a) from (select avg(c2) as a from stb1 interval(1s)); +sql select asin(a) from (select avg(c2) as a from stb1 interval(1s)); +if $data00 != @1.570796327@ then + return -1 +endi +if $data10 != @nan@ then + return -1 +endi +if $data20 != @nan@ then + return -1 +endi +if $data30 != @nan@ then + return -1 +endi +if $data40 != @nan@ then + return -1 +endi +if $data50 != @nan@ then + return -1 +endi +if $data60 != @nan@ then + return -1 +endi +print execute sql select asin(c2) from (select * from stb1); +sql select asin(c2) from (select * from stb1); +if $data00 != @1.570796327@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data20 != @nan@ then + return -1 +endi +if $data30 != @NULL@ then + return -1 +endi +if $data40 != @nan@ then + return -1 +endi +if $data50 != @nan@ then + return -1 +endi +if $data60 != @nan@ then + return -1 +endi +if $data70 != @1.570796327@ then + return -1 +endi +if $data80 != @nan@ then + return -1 +endi +if $data90 != @nan@ then + return -1 +endi +print execute sql select asin(a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)); +sql select asin(a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)); +if $data00 != @1.570796327@ then + return -1 +endi +if $data10 != @nan@ then + return -1 +endi +if $data20 != @nan@ then + return -1 +endi +if $data30 != @nan@ then + return -1 +endi +if $data40 != @nan@ then + return -1 +endi +if $data50 != @nan@ then + return -1 +endi +if $data60 != @nan@ then + return -1 +endi +if $data70 != @NULL@ then + return -1 +endi +if $data80 != @NULL@ then + return -1 +endi +if $data90 != @NULL@ then + return -1 +endi +print execute sql select asin(a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)) order by ts; +sql select asin(a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)) order by ts; +if $data00 != @1.570796327@ then + return -1 +endi +if $data10 != @nan@ then + return -1 +endi +if $data20 != @nan@ then + return -1 +endi +if $data30 != @nan@ then + return -1 +endi +if $data40 != @nan@ then + return -1 +endi +if $data50 != @nan@ then + return -1 +endi +if $data60 != @nan@ then + return -1 +endi +if $data70 != @NULL@ then + return -1 +endi +if $data80 != @NULL@ then + return -1 +endi +if $data90 != @NULL@ then + return -1 +endi +print execute sql select asin(a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)) order by ts desc; +sql select asin(a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)) order by ts desc; +if $data00 != @NULL@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data20 != @NULL@ then + return -1 +endi +if $data30 != @nan@ then + return -1 +endi +if $data40 != @nan@ then + return -1 +endi +if $data50 != @nan@ then + return -1 +endi +if $data60 != @nan@ then + return -1 +endi +if $data70 != @nan@ then + return -1 +endi +if $data80 != @nan@ then + return -1 +endi +if $data90 != @1.570796327@ then + return -1 +endi +print execute sql select asin(a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)) order by a desc; +sql select asin(a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)) order by a desc; +if $data00 != @NULL@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data20 != @NULL@ then + return -1 +endi +if $data30 != @nan@ then + return -1 +endi +if $data40 != @nan@ then + return -1 +endi +if $data50 != @nan@ then + return -1 +endi +if $data60 != @nan@ then + return -1 +endi +if $data70 != @nan@ then + return -1 +endi +if $data80 != @1.570796327@ then + return -1 +endi +if $data90 != @nan@ then + return -1 +endi +print execute sql select asin(a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)) order by a; +sql select asin(a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)) order by a; +if $data00 != @nan@ then + return -1 +endi +if $data10 != @1.570796327@ then + return -1 +endi +if $data20 != @nan@ then + return -1 +endi +if $data30 != @nan@ then + return -1 +endi +if $data40 != @nan@ then + return -1 +endi +if $data50 != @nan@ then + return -1 +endi +if $data60 != @nan@ then + return -1 +endi +if $data70 != @NULL@ then + return -1 +endi +if $data80 != @NULL@ then + return -1 +endi +if $data90 != @NULL@ then + return -1 +endi +print execute sql select asin(a) from (select asin(c2) as a from tb1); +sql select asin(a) from (select asin(c2) as a from tb1); +if $data00 != @nan@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data20 != @nan@ then + return -1 +endi +if $data30 != @NULL@ then + return -1 +endi +if $data40 != @nan@ then + return -1 +endi +if $data50 != @nan@ then + return -1 +endi +if $data60 != @nan@ then + return -1 +endi +print execute sql select asin(tb1.c3),asin(tb2.c3) from tb1,tb2 where tb1.ts=tb2.ts; +sql select asin(tb1.c3),asin(tb2.c3) from tb1,tb2 where tb1.ts=tb2.ts; +if $data00 != @1.570796327@ then + return -1 +endi +if $data01 != @1.570796327@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data11 != @nan@ then + return -1 +endi +if $data20 != @NULL@ then + return -1 +endi +if $data21 != @nan@ then + return -1 +endi +if $data30 != @nan@ then + return -1 +endi +if $data31 != @nan@ then + return -1 +endi +if $data40 != @nan@ then + return -1 +endi +if $data41 != @nan@ then + return -1 +endi +if $data50 != @nan@ then + return -1 +endi +if $data51 != @nan@ then + return -1 +endi +if $data60 != @nan@ then + return -1 +endi +if $data61 != @nan@ then + return -1 +endi +print execute sql select asin(c3) from tb1 union all select asin(c3) from tb2; +sql select asin(c3) from tb1 union all select asin(c3) from tb2; +if $data00 != @1.570796327@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data20 != @NULL@ then + return -1 +endi +if $data30 != @nan@ then + return -1 +endi +if $data40 != @nan@ then + return -1 +endi +if $data50 != @nan@ then + return -1 +endi +if $data60 != @nan@ then + return -1 +endi +if $data70 != @1.570796327@ then + return -1 +endi +if $data80 != @nan@ then + return -1 +endi +if $data90 != @nan@ then + return -1 +endi diff --git a/tests/script/general/compute/math_asin2.sim b/tests/script/general/compute/math_asin2.sim new file mode 100644 index 0000000000000000000000000000000000000000..98b4eb05bcb24b9fb962dbbdd6e8ddfa3e55280f --- /dev/null +++ b/tests/script/general/compute/math_asin2.sim @@ -0,0 +1,366 @@ +sleep 100 +sql connect +sql use db + +print execute sql select asin(stb1.c4),asin(stba.c5) from stb1,stba where stb1.t1=stba.t1 and stb1.ts=stba.ts; +sql select asin(stb1.c4),asin(stba.c5) from stb1,stba where stb1.t1=stba.t1 and stb1.ts=stba.ts; +if $data00 != @1.570796327@ then + return -1 +endi +if $data01 != @1.570796327@ then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data11 != @nan@ then + return -1 +endi +if $data20 != @nan@ then + return -1 +endi +if $data21 != @nan@ then + return -1 +endi +if $data30 != NULL then + return -1 +endi +if $data31 != @nan@ then + return -1 +endi +if $data40 != @nan@ then + return -1 +endi +if $data41 != @nan@ then + return -1 +endi +if $data50 != @nan@ then + return -1 +endi +if $data51 != @nan@ then + return -1 +endi +if $data60 != @nan@ then + return -1 +endi +if $data61 != @nan@ then + return -1 +endi +print execute sql select asin(c4) as a from stb1 union all select asin(c5) as a from stba; +sql select asin(c4) as a from stb1 union all select asin(c5) as a from stba; +if $data00 != @1.570796327@ then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data20 != @nan@ then + return -1 +endi +if $data30 != NULL then + return -1 +endi +if $data40 != @nan@ then + return -1 +endi +if $data50 != @nan@ then + return -1 +endi +if $data60 != @nan@ then + return -1 +endi +if $data70 != @1.570796327@ then + return -1 +endi +if $data80 != @nan@ then + return -1 +endi +if $data90 != @nan@ then + return -1 +endi +print execute sql select asin(c2) from stba; +sql select asin(c2) from stba; +if $data00 != @1.570796327@ then + return -1 +endi +if $data10 != @nan@ then + return -1 +endi +if $data20 != @nan@ then + return -1 +endi +if $data30 != @nan@ then + return -1 +endi +if $data40 != @nan@ then + return -1 +endi +if $data50 != @nan@ then + return -1 +endi +if $data60 != @nan@ then + return -1 +endi +if $data70 != @nan@ then + return -1 +endi +if $data80 != @nan@ then + return -1 +endi +if $data90 != @0.000000000@ then + return -1 +endi +print execute sql select asin(min(c2)) from tba1; +sql select asin(min(c2)) from tba1; +if $data00 != @0.000000000@ then + return -1 +endi +print execute sql select asin(max(c2)) from tba1; +sql select asin(max(c2)) from tba1; +if $data00 != @nan@ then + return -1 +endi +print execute sql select asin(count(c2)) from tba1; +sql select asin(count(c2)) from tba1; +if $data00 != @nan@ then + return -1 +endi +print execute sql select asin(sum(c2)) from tba1; +sql select asin(sum(c2)) from tba1; +if $data00 != @nan@ then + return -1 +endi +print execute sql select asin(avg(c2)) from tba1; +sql select asin(avg(c2)) from tba1; +if $data00 != @nan@ then + return -1 +endi +print execute sql select asin(percentile(c2, 10)) from tba1; +sql select asin(percentile(c2, 10)) from tba1; +if $data00 != @1.119769515@ then + return -1 +endi +print execute sql select asin(apercentile(c2, 10)) from tba1; +sql select asin(apercentile(c2, 10)) from tba1; +if $data00 != @0.000000000@ then + return -1 +endi +print execute sql select asin(stddev(c2)) from tba1; +sql select asin(stddev(c2)) from tba1; +if $data00 != @nan@ then + return -1 +endi +print execute sql select asin(spread(c2)) from tba1; +sql select asin(spread(c2)) from tba1; +if $data00 != @nan@ then + return -1 +endi +print execute sql select asin(twa(c2)) from tba1; +sql select asin(twa(c2)) from tba1; +if $data00 != @nan@ then + return -1 +endi +print execute sql select asin(leastsquares(c2, 1, 1)) from tba1; +sql_error select asin(leastsquares(c2, 1, 1)) from tba1; +print execute sql select asin(interp(c2)) from tba1 every(1s) +sql select asin(interp(c2)) from tba1 every(1s) +if $data00 != @21-11-11 09:00:00.000@ then + return -1 +endi +if $data01 != @1.570796327@ then + return -1 +endi +if $data10 != @21-11-11 09:00:01.000@ then + return -1 +endi +if $data11 != @nan@ then + return -1 +endi +if $data20 != @21-11-11 09:00:02.000@ then + return -1 +endi +if $data21 != @nan@ then + return -1 +endi +if $data30 != @21-11-11 09:00:03.000@ then + return -1 +endi +if $data31 != @nan@ then + return -1 +endi +if $data40 != @21-11-11 09:00:04.000@ then + return -1 +endi +if $data41 != @nan@ then + return -1 +endi +if $data50 != @21-11-11 09:00:05.000@ then + return -1 +endi +if $data51 != @nan@ then + return -1 +endi +if $data60 != @21-11-11 09:00:06.000@ then + return -1 +endi +if $data61 != @nan@ then + return -1 +endi +if $data70 != @21-11-11 09:00:07.000@ then + return -1 +endi +if $data71 != @nan@ then + return -1 +endi +if $data80 != @21-11-11 09:00:08.000@ then + return -1 +endi +if $data81 != @nan@ then + return -1 +endi +if $data90 != @21-11-11 09:00:09.000@ then + return -1 +endi +if $data91 != @0.000000000@ then + return -1 +endi +print execute sql select asin(interp(c2)) from stba every(1s) group by tbname; +sql select asin(interp(c2)) from stba every(1s) group by tbname; +if $data00 != @21-11-11 09:00:00.000@ then + return -1 +endi +if $data01 != @1.570796327@ then + return -1 +endi +if $data02 != @tba1@ then + return -1 +endi +if $data10 != @21-11-11 09:00:01.000@ then + return -1 +endi +if $data11 != @nan@ then + return -1 +endi +if $data12 != @tba1@ then + return -1 +endi +if $data20 != @21-11-11 09:00:02.000@ then + return -1 +endi +if $data21 != @nan@ then + return -1 +endi +if $data22 != @tba1@ then + return -1 +endi +if $data30 != @21-11-11 09:00:03.000@ then + return -1 +endi +if $data31 != @nan@ then + return -1 +endi +if $data32 != @tba1@ then + return -1 +endi +if $data40 != @21-11-11 09:00:04.000@ then + return -1 +endi +if $data41 != @nan@ then + return -1 +endi +if $data42 != @tba1@ then + return -1 +endi +if $data50 != @21-11-11 09:00:05.000@ then + return -1 +endi +if $data51 != @nan@ then + return -1 +endi +if $data52 != @tba1@ then + return -1 +endi +if $data60 != @21-11-11 09:00:06.000@ then + return -1 +endi +if $data61 != @nan@ then + return -1 +endi +if $data62 != @tba1@ then + return -1 +endi +if $data70 != @21-11-11 09:00:07.000@ then + return -1 +endi +if $data71 != @nan@ then + return -1 +endi +if $data72 != @tba1@ then + return -1 +endi +if $data80 != @21-11-11 09:00:08.000@ then + return -1 +endi +if $data81 != @nan@ then + return -1 +endi +if $data82 != @tba1@ then + return -1 +endi +if $data90 != @21-11-11 09:00:09.000@ then + return -1 +endi +if $data91 != @0.000000000@ then + return -1 +endi +if $data92 != @tba1@ then + return -1 +endi +print execute sql select asin(elapsed(ts)) from tba1; +sql select asin(elapsed(ts)) from tba1; +if $data00 != @nan@ then + return -1 +endi +print execute sql select asin(rate(c2)) from tba1; +sql select asin(rate(c2)) from tba1; +if $data00 != @1.111922122@ then + return -1 +endi +print execute sql select asin(irate(c2)) from tba1; +sql select asin(irate(c2)) from tba1; +if $data00 != @0.000000000@ then + return -1 +endi +print execute sql select asin(first(c2)) from tba1; +sql select asin(first(c2)) from tba1; +if $data00 != @1.570796327@ then + return -1 +endi +print execute sql select asin(last(c2)) from tba1; +sql select asin(last(c2)) from tba1; +if $data00 != @0.000000000@ then + return -1 +endi +print execute sql select asin(last_row(c2)) from tba1; +sql select asin(last_row(c2)) from tba1; +if $data00 != @0.000000000@ then + return -1 +endi +print execute sql select asin(top(c2, 1)) from tba1; +sql_error select asin(top(c2, 1)) from tba1; +print execute sql select asin(bottom(c2, 1)) from tba1; +sql_error select asin(bottom(c2, 1)) from tba1; +print execute sql select asin(leastsquares(c2, 1, 1)) from tba1; +sql_error select asin(leastsquares(c2, 1, 1)) from tba1; +print execute sql select asin(derivative(c2, 1s, 0)) from tba1; +sql_error select asin(derivative(c2, 1s, 0)) from tba1; +print execute sql select asin(diff(c2)) from tba1; +sql_error select asin(diff(c2)) from tba1; +print execute sql select asin(csum(c2)) from tba1; +sql_error select asin(csum(c2)) from tba1; +print execute sql select asin(mavg(c2,2)) from tba1; +sql_error select asin(mavg(c2,2)) from tba1; +print execute sql select asin(sample(c2,2)) from tba1; +sql_error select asin(sample(c2,2)) from tba1; +print execute sql select asin(_block_dist()) from tba1; +sql_error select asin(_block_dist()) from tba1; diff --git a/tests/script/general/compute/math_atan.sim b/tests/script/general/compute/math_atan.sim new file mode 100644 index 0000000000000000000000000000000000000000..b91af7e647a210451474b80b3af307ba7a02cb88 --- /dev/null +++ b/tests/script/general/compute/math_atan.sim @@ -0,0 +1,1073 @@ +sleep 100 +sql connect +sql use db + +print execute sql select acos(*) from tb1; +sql_error select acos(*) from tb1; +print execute sql select acos(*) from tb1; +sql_error select acos(*) from tb1; +print execute sql select acos(*) from tb1; +sql_error select acos(*) from tb1; +print execute sql select acos(*) from tb1; +sql_error select acos(*) from tb1; +print execute sql select acos(*) as a from tb1; +sql_error select acos(*) as a from tb1; +print execute sql select acos(*) + 1 as a from tb1; +sql_error select acos(*) + 1 as a from tb1; +print execute sql select acos(tb1.*) + 1 as a from tb1; +sql_error select acos(tb1.*) + 1 as a from tb1; +print execute sql select acos(*) from tb1; +sql_error select acos(*) from tb1; +print execute sql select acos(c1) from tb1; +sql_error select acos(c1) from tb1; +print execute sql select acos(c1) from tb1; +sql_error select acos(c1) from tb1; +print execute sql select acos(c1 + c2) from tb1; +sql_error select acos(c1 + c2) from tb1; +print execute sql select acos(13) from tb1; +sql select acos(13) from tb1; +if $data00 != @nan@ then + return -1 +endi +if $data10 != @nan@ then + return -1 +endi +if $data20 != @nan@ then + return -1 +endi +if $data30 != @nan@ then + return -1 +endi +if $data40 != @nan@ then + return -1 +endi +if $data50 != @nan@ then + return -1 +endi +if $data60 != @nan@ then + return -1 +endi +print execute sql select acos(c1) from tb1; +sql_error select acos(c1) from tb1; +print execute sql select acos(c2) from tb1; +sql select acos(c2) from tb1; +if $data00 != @0.000000000@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data20 != @nan@ then + return -1 +endi +if $data30 != @NULL@ then + return -1 +endi +if $data40 != @nan@ then + return -1 +endi +if $data50 != @nan@ then + return -1 +endi +if $data60 != @nan@ then + return -1 +endi +print execute sql select acos(c3) from tb1; +sql select acos(c3) from tb1; +if $data00 != @0.000000000@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data20 != @NULL@ then + return -1 +endi +if $data30 != @nan@ then + return -1 +endi +if $data40 != @nan@ then + return -1 +endi +if $data50 != @nan@ then + return -1 +endi +if $data60 != @nan@ then + return -1 +endi +print execute sql select acos(c4) from tb1; +sql select acos(c4) from tb1; +if $data00 != @0.000000000@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data20 != @nan@ then + return -1 +endi +if $data30 != @NULL@ then + return -1 +endi +if $data40 != @nan@ then + return -1 +endi +if $data50 != @nan@ then + return -1 +endi +if $data60 != @nan@ then + return -1 +endi +print execute sql select acos(c5) from tb1; +sql select acos(c5) from tb1; +if $data00 != @0.000000000@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data20 != @NULL@ then + return -1 +endi +if $data30 != @nan@ then + return -1 +endi +if $data40 != @nan@ then + return -1 +endi +if $data50 != @nan@ then + return -1 +endi +if $data60 != @nan@ then + return -1 +endi +print execute sql select acos(c6) from tb1; +sql select acos(c6) from tb1; +if $data00 != @0.000000000@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data20 != @nan@ then + return -1 +endi +if $data30 != @NULL@ then + return -1 +endi +if $data40 != @nan@ then + return -1 +endi +if $data50 != @nan@ then + return -1 +endi +if $data60 != @nan@ then + return -1 +endi +print execute sql select acos(c7) from tb1; +sql select acos(c7) from tb1; +if $data00 != @0.000000000@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data20 != @NULL@ then + return -1 +endi +if $data30 != @nan@ then + return -1 +endi +if $data40 != @nan@ then + return -1 +endi +if $data50 != @nan@ then + return -1 +endi +if $data60 != @nan@ then + return -1 +endi +print execute sql select acos(c8) from tb1; +sql_error select acos(c8) from tb1; +print execute sql select acos(c9) from tb1; +sql_error select acos(c9) from tb1; +print execute sql select acos(c10) from tb1; +sql select acos(c10) from tb1; +if $data00 != @0.000000000@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data20 != @nan@ then + return -1 +endi +if $data30 != @NULL@ then + return -1 +endi +if $data40 != @nan@ then + return -1 +endi +if $data50 != @nan@ then + return -1 +endi +if $data60 != @1.570796327@ then + return -1 +endi +print execute sql select acos(c11) from tb1; +sql select acos(c11) from tb1; +if $data00 != @0.000000000@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data20 != @NULL@ then + return -1 +endi +if $data30 != @nan@ then + return -1 +endi +if $data40 != @nan@ then + return -1 +endi +if $data50 != @nan@ then + return -1 +endi +if $data60 != @1.570796327@ then + return -1 +endi +print execute sql select acos(c12) from tb1; +sql select acos(c12) from tb1; +if $data00 != @0.000000000@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data20 != @nan@ then + return -1 +endi +if $data30 != @NULL@ then + return -1 +endi +if $data40 != @nan@ then + return -1 +endi +if $data50 != @nan@ then + return -1 +endi +if $data60 != @1.570796327@ then + return -1 +endi +print execute sql select acos(c13) from tb1; +sql select acos(c13) from tb1; +if $data00 != @0.000000000@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data20 != @NULL@ then + return -1 +endi +if $data30 != @nan@ then + return -1 +endi +if $data40 != @nan@ then + return -1 +endi +if $data50 != @nan@ then + return -1 +endi +if $data60 != @1.570796327@ then + return -1 +endi +print execute sql select acos(12345678900000000000000000) from tb1; +sql_error select acos(12345678900000000000000000) from tb1; +print execute sql select distinct acos(123) from tb1; +sql_error select distinct acos(123) from tb1; +print execute sql select acos(t1) from stb1; +sql_error select acos(t1) from stb1; +print execute sql select acos(c1),avg(c3) from tb1; +sql_error select acos(c1),avg(c3) from tb1; +print execute sql select acos(c1),top(c3,1) from tb1; +sql_error select acos(c1),top(c3,1) from tb1; +print execute sql select acos(c2+c3) from tb1 session(ts, 1s); +sql_error select acos(c2+c3) from tb1 session(ts, 1s); +print execute sql select acos(c2+c3) from tb1 STATE_WINDOW(c1); +sql_error select acos(c2+c3) from tb1 STATE_WINDOW(c1); +print execute sql select acos(c2+c3) from tb1 interval(1s) sliding(1s) fill(NULL); +sql_error select acos(c2+c3) from tb1 interval(1s) sliding(1s) fill(NULL); +print execute sql select acos(c2+c3) from stb1 group by t1; +sql_error select acos(c2+c3) from stb1 group by t1; +print execute sql select acos(c2+c3) from stb1 group by ts; +sql_error select acos(c2+c3) from stb1 group by ts; +print execute sql select acos(c2+c3) from stb1 group by c1; +sql_error select acos(c2+c3) from stb1 group by c1; +print execute sql select acos(c2+c3) from stb1 group by tbname; +sql_error select acos(c2+c3) from stb1 group by tbname; +print execute sql select acos(c2+c3) from tb1 order by c2; +sql_error select acos(c2+c3) from tb1 order by c2; +print execute sql select acos(c8),acos(c9) from tbn; +sql_error select acos(c8),acos(c9) from tbn; +print execute sql select acos(ts) from (select avg(c2) as a from stb1 interval(1s)); +sql_error select acos(ts) from (select avg(c2) as a from stb1 interval(1s)); +print execute sql select acos(a) from (select acos(c2) as a from tb1); +sql select acos(a) from (select acos(c2) as a from tb1); +if $data00 != @1.570796327@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data20 != @nan@ then + return -1 +endi +if $data30 != @NULL@ then + return -1 +endi +if $data40 != @nan@ then + return -1 +endi +if $data50 != @nan@ then + return -1 +endi +if $data60 != @nan@ then + return -1 +endi +print execute sql select acos("abc") from tb1; +sql_error select acos("abc") from tb1; +print execute sql select acos(c2 + c3) from tb1; +sql select acos(c2 + c3) from tb1; +if $data00 != @nan@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data20 != @NULL@ then + return -1 +endi +if $data30 != @NULL@ then + return -1 +endi +if $data40 != @nan@ then + return -1 +endi +if $data50 != @nan@ then + return -1 +endi +if $data60 != @nan@ then + return -1 +endi +print execute sql select acos((c2 + c3)) from tb1; +sql select acos((c2 + c3)) from tb1; +if $data00 != @nan@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data20 != @NULL@ then + return -1 +endi +if $data30 != @NULL@ then + return -1 +endi +if $data40 != @nan@ then + return -1 +endi +if $data50 != @nan@ then + return -1 +endi +if $data60 != @nan@ then + return -1 +endi +print execute sql select acos((c2 * c3)+c4-6) from tb1; +sql select acos((c2 * c3)+c4-6) from tb1; +if $data00 != @nan@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data20 != @NULL@ then + return -1 +endi +if $data30 != @NULL@ then + return -1 +endi +if $data40 != @nan@ then + return -1 +endi +if $data50 != @nan@ then + return -1 +endi +if $data60 != @nan@ then + return -1 +endi +print execute sql select acos(11)+c2 from tb1; +sql select acos(11)+c2 from tb1; +if $data00 != @nan@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data20 != @nan@ then + return -1 +endi +if $data30 != @NULL@ then + return -1 +endi +if $data40 != @nan@ then + return -1 +endi +if $data50 != @nan@ then + return -1 +endi +if $data60 != @nan@ then + return -1 +endi +print execute sql select acos(c1)+c2 from tb1; +sql_error select acos(c1)+c2 from tb1; +print execute sql select acos(c2)+11 from tb1; +sql select acos(c2)+11 from tb1; +if $data00 != @11.000000000@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data20 != @nan@ then + return -1 +endi +if $data30 != @NULL@ then + return -1 +endi +if $data40 != @nan@ then + return -1 +endi +if $data50 != @nan@ then + return -1 +endi +if $data60 != @nan@ then + return -1 +endi +print execute sql select acos(c1),c1,c2 from tb1; +sql_error select acos(c1),c1,c2 from tb1; +print execute sql select acos(c1),t1,ts,tbname,_C0,_c0 from tb1; +sql_error select acos(c1),t1,ts,tbname,_C0,_c0 from tb1; +print execute sql select acos(c1),floor(c3) from tb1; +sql_error select acos(c1),floor(c3) from tb1; +print execute sql select acos(c1),acos(c2+c3) from tb1; +sql_error select acos(c1),acos(c2+c3) from tb1; +print execute sql select acos(c2+c3) from tb1 where c2 is not null and c3 is not null; +sql select acos(c2+c3) from tb1 where c2 is not null and c3 is not null; +if $data00 != @nan@ then + return -1 +endi +if $data10 != @nan@ then + return -1 +endi +if $data20 != @nan@ then + return -1 +endi +if $data30 != @nan@ then + return -1 +endi +print execute sql select acos(c2) from tb1 order by ts desc; +sql select acos(c2) from tb1 order by ts desc; +if $data00 != @nan@ then + return -1 +endi +if $data10 != @nan@ then + return -1 +endi +if $data20 != @nan@ then + return -1 +endi +if $data30 != @NULL@ then + return -1 +endi +if $data40 != @nan@ then + return -1 +endi +if $data50 != @NULL@ then + return -1 +endi +if $data60 != @0.000000000@ then + return -1 +endi +print execute sql select acos(c2+c3) from tb1 order by ts desc; +sql select acos(c2+c3) from tb1 order by ts desc; +if $data00 != @nan@ then + return -1 +endi +if $data10 != @nan@ then + return -1 +endi +if $data20 != @nan@ then + return -1 +endi +if $data30 != @NULL@ then + return -1 +endi +if $data40 != @NULL@ then + return -1 +endi +if $data50 != @NULL@ then + return -1 +endi +if $data60 != @nan@ then + return -1 +endi +print execute sql select acos(c2+c3) from tb1 order by ts desc limit 3 offset 2; +sql select acos(c2+c3) from tb1 order by ts desc limit 3 offset 2; +if $data00 != @nan@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data20 != @NULL@ then + return -1 +endi +print execute sql select acos(c2) from stb1; +sql select acos(c2) from stb1; +if $data00 != @0.000000000@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data20 != @nan@ then + return -1 +endi +if $data30 != @NULL@ then + return -1 +endi +if $data40 != @nan@ then + return -1 +endi +if $data50 != @nan@ then + return -1 +endi +if $data60 != @nan@ then + return -1 +endi +if $data70 != @0.000000000@ then + return -1 +endi +if $data80 != @nan@ then + return -1 +endi +if $data90 != @nan@ then + return -1 +endi +print execute sql select acos(c2) from stb1 order by ts desc; +sql select acos(c2) from stb1 order by ts desc; +if $data00 != @nan@ then + if $data00 != @nan@ then + return -1 + endi +endi +if $data20 != @nan@ then + if $data20 != @nan@ then + return -1 + endi +endi +if $data40 != @nan@ then + if $data40 != @nan@ then + return -1 + endi +endi +if $data60 != @nan@ then + if $data60 != @NULL@ then + return -1 + endi +endi +if $data80 != @nan@ then + if $data80 != @nan@ then + return -1 + endi +endi +print execute sql select acos(c4),t1 from stb1 order by ts desc; +sql select acos(c4),t1 from stb1 order by ts desc; +if $data00 != @nan@ then + if $data00 != @nan@ then + return -1 + endi +endi +if $data01 != @2@ then + if $data01 != @1@ then + return -1 + endi +endi +if $data20 != @nan@ then + if $data20 != @nan@ then + return -1 + endi +endi +if $data21 != @2@ then + if $data21 != @1@ then + return -1 + endi +endi +if $data40 != @nan@ then + if $data40 != @nan@ then + return -1 + endi +endi +if $data41 != @2@ then + if $data41 != @1@ then + return -1 + endi +endi +if $data60 != @nan@ then + if $data60 != @NULL@ then + return -1 + endi +endi +if $data61 != @2@ then + if $data61 != @1@ then + return -1 + endi +endi +if $data80 != @nan@ then + if $data80 != @nan@ then + return -1 + endi +endi +if $data81 != @2@ then + if $data81 != @1@ then + return -1 + endi +endi +print execute sql select acos(c3),tbname from stb1; +sql select acos(c3),tbname from stb1; +if $data00 != @0.000000000@ then + return -1 +endi +if $data01 != @tb1@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data11 != @tb1@ then + return -1 +endi +if $data20 != @NULL@ then + return -1 +endi +if $data21 != @tb1@ then + return -1 +endi +if $data30 != @nan@ then + return -1 +endi +if $data31 != @tb1@ then + return -1 +endi +if $data40 != @nan@ then + return -1 +endi +if $data41 != @tb1@ then + return -1 +endi +if $data50 != @nan@ then + return -1 +endi +if $data51 != @tb1@ then + return -1 +endi +if $data60 != @nan@ then + return -1 +endi +if $data61 != @tb1@ then + return -1 +endi +if $data70 != @0.000000000@ then + return -1 +endi +if $data71 != @tb2@ then + return -1 +endi +if $data80 != @nan@ then + return -1 +endi +if $data81 != @tb2@ then + return -1 +endi +if $data90 != @nan@ then + return -1 +endi +if $data91 != @tb2@ then + return -1 +endi +print execute sql select acos(c3),tbname from stb1 where t1 > 1; +sql select acos(c3),tbname from stb1 where t1 > 1; +if $data00 != @0.000000000@ then + return -1 +endi +if $data01 != @tb2@ then + return -1 +endi +if $data10 != @nan@ then + return -1 +endi +if $data11 != @tb2@ then + return -1 +endi +if $data20 != @nan@ then + return -1 +endi +if $data21 != @tb2@ then + return -1 +endi +if $data30 != @nan@ then + return -1 +endi +if $data31 != @tb2@ then + return -1 +endi +if $data40 != @nan@ then + return -1 +endi +if $data41 != @tb2@ then + return -1 +endi +if $data50 != @nan@ then + return -1 +endi +if $data51 != @tb2@ then + return -1 +endi +if $data60 != @nan@ then + return -1 +endi +if $data61 != @tb2@ then + return -1 +endi +print execute sql select acos(c8),acos(c9) from tbn; +sql_error select acos(c8),acos(c9) from tbn; +print execute sql select acos(c8),acos(c9) from tbn order by ts desc; +sql_error select acos(c8),acos(c9) from tbn order by ts desc; +print execute sql select acos(acos(c8)) from tbn; +sql_error select acos(acos(c8)) from tbn; +print execute sql select acos(a) from (select avg(c2) as a from stb1 interval(1s)); +sql select acos(a) from (select avg(c2) as a from stb1 interval(1s)); +if $data00 != @0.000000000@ then + return -1 +endi +if $data10 != @nan@ then + return -1 +endi +if $data20 != @nan@ then + return -1 +endi +if $data30 != @nan@ then + return -1 +endi +if $data40 != @nan@ then + return -1 +endi +if $data50 != @nan@ then + return -1 +endi +if $data60 != @nan@ then + return -1 +endi +print execute sql select acos(c2) from (select * from stb1); +sql select acos(c2) from (select * from stb1); +if $data00 != @0.000000000@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data20 != @nan@ then + return -1 +endi +if $data30 != @NULL@ then + return -1 +endi +if $data40 != @nan@ then + return -1 +endi +if $data50 != @nan@ then + return -1 +endi +if $data60 != @nan@ then + return -1 +endi +if $data70 != @0.000000000@ then + return -1 +endi +if $data80 != @nan@ then + return -1 +endi +if $data90 != @nan@ then + return -1 +endi +print execute sql select acos(a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)); +sql select acos(a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)); +if $data00 != @0.000000000@ then + return -1 +endi +if $data10 != @nan@ then + return -1 +endi +if $data20 != @nan@ then + return -1 +endi +if $data30 != @nan@ then + return -1 +endi +if $data40 != @nan@ then + return -1 +endi +if $data50 != @nan@ then + return -1 +endi +if $data60 != @nan@ then + return -1 +endi +if $data70 != @NULL@ then + return -1 +endi +if $data80 != @NULL@ then + return -1 +endi +if $data90 != @NULL@ then + return -1 +endi +print execute sql select acos(a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)) order by ts; +sql select acos(a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)) order by ts; +if $data00 != @0.000000000@ then + return -1 +endi +if $data10 != @nan@ then + return -1 +endi +if $data20 != @nan@ then + return -1 +endi +if $data30 != @nan@ then + return -1 +endi +if $data40 != @nan@ then + return -1 +endi +if $data50 != @nan@ then + return -1 +endi +if $data60 != @nan@ then + return -1 +endi +if $data70 != @NULL@ then + return -1 +endi +if $data80 != @NULL@ then + return -1 +endi +if $data90 != @NULL@ then + return -1 +endi +print execute sql select acos(a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)) order by ts desc; +sql select acos(a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)) order by ts desc; +if $data00 != @NULL@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data20 != @NULL@ then + return -1 +endi +if $data30 != @nan@ then + return -1 +endi +if $data40 != @nan@ then + return -1 +endi +if $data50 != @nan@ then + return -1 +endi +if $data60 != @nan@ then + return -1 +endi +if $data70 != @nan@ then + return -1 +endi +if $data80 != @nan@ then + return -1 +endi +if $data90 != @0.000000000@ then + return -1 +endi +print execute sql select acos(a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)) order by a desc; +sql select acos(a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)) order by a desc; +if $data00 != @NULL@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data20 != @NULL@ then + return -1 +endi +if $data30 != @nan@ then + return -1 +endi +if $data40 != @nan@ then + return -1 +endi +if $data50 != @nan@ then + return -1 +endi +if $data60 != @nan@ then + return -1 +endi +if $data70 != @nan@ then + return -1 +endi +if $data80 != @0.000000000@ then + return -1 +endi +if $data90 != @nan@ then + return -1 +endi +print execute sql select acos(a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)) order by a; +sql select acos(a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)) order by a; +if $data00 != @nan@ then + return -1 +endi +if $data10 != @0.000000000@ then + return -1 +endi +if $data20 != @nan@ then + return -1 +endi +if $data30 != @nan@ then + return -1 +endi +if $data40 != @nan@ then + return -1 +endi +if $data50 != @nan@ then + return -1 +endi +if $data60 != @nan@ then + return -1 +endi +if $data70 != @NULL@ then + return -1 +endi +if $data80 != @NULL@ then + return -1 +endi +if $data90 != @NULL@ then + return -1 +endi +print execute sql select acos(a) from (select acos(c2) as a from tb1); +sql select acos(a) from (select acos(c2) as a from tb1); +if $data00 != @1.570796327@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data20 != @nan@ then + return -1 +endi +if $data30 != @NULL@ then + return -1 +endi +if $data40 != @nan@ then + return -1 +endi +if $data50 != @nan@ then + return -1 +endi +if $data60 != @nan@ then + return -1 +endi +print execute sql select acos(tb1.c3),acos(tb2.c3) from tb1,tb2 where tb1.ts=tb2.ts; +sql select acos(tb1.c3),acos(tb2.c3) from tb1,tb2 where tb1.ts=tb2.ts; +if $data00 != @0.000000000@ then + return -1 +endi +if $data01 != @0.000000000@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data11 != @nan@ then + return -1 +endi +if $data20 != @NULL@ then + return -1 +endi +if $data21 != @nan@ then + return -1 +endi +if $data30 != @nan@ then + return -1 +endi +if $data31 != @nan@ then + return -1 +endi +if $data40 != @nan@ then + return -1 +endi +if $data41 != @nan@ then + return -1 +endi +if $data50 != @nan@ then + return -1 +endi +if $data51 != @nan@ then + return -1 +endi +if $data60 != @nan@ then + return -1 +endi +if $data61 != @nan@ then + return -1 +endi +print execute sql select acos(c3) from tb1 union all select acos(c3) from tb2; +sql select acos(c3) from tb1 union all select acos(c3) from tb2; +if $data00 != @0.000000000@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data20 != @NULL@ then + return -1 +endi +if $data30 != @nan@ then + return -1 +endi +if $data40 != @nan@ then + return -1 +endi +if $data50 != @nan@ then + return -1 +endi +if $data60 != @nan@ then + return -1 +endi +if $data70 != @0.000000000@ then + return -1 +endi +if $data80 != @nan@ then + return -1 +endi +if $data90 != @nan@ then + return -1 +endi diff --git a/tests/script/general/compute/math_atan2.sim b/tests/script/general/compute/math_atan2.sim new file mode 100644 index 0000000000000000000000000000000000000000..01a83eb4d46f1ae637cd2cde0dec412cb81b7497 --- /dev/null +++ b/tests/script/general/compute/math_atan2.sim @@ -0,0 +1,366 @@ +sleep 100 +sql connect +sql use db + +print execute sql select acos(stb1.c4),acos(stba.c5) from stb1,stba where stb1.t1=stba.t1 and stb1.ts=stba.ts; +sql select acos(stb1.c4),acos(stba.c5) from stb1,stba where stb1.t1=stba.t1 and stb1.ts=stba.ts; +if $data00 != @0.000000000@ then + return -1 +endi +if $data01 != @0.000000000@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data11 != @nan@ then + return -1 +endi +if $data20 != @nan@ then + return -1 +endi +if $data21 != @nan@ then + return -1 +endi +if $data30 != @NULL@ then + return -1 +endi +if $data31 != @nan@ then + return -1 +endi +if $data40 != @nan@ then + return -1 +endi +if $data41 != @nan@ then + return -1 +endi +if $data50 != @nan@ then + return -1 +endi +if $data51 != @nan@ then + return -1 +endi +if $data60 != @nan@ then + return -1 +endi +if $data61 != @nan@ then + return -1 +endi +print execute sql select acos(c4) as a from stb1 union all select acos(c5) as a from stba; +sql select acos(c4) as a from stb1 union all select acos(c5) as a from stba; +if $data00 != @0.000000000@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data20 != @nan@ then + return -1 +endi +if $data30 != @NULL@ then + return -1 +endi +if $data40 != @nan@ then + return -1 +endi +if $data50 != @nan@ then + return -1 +endi +if $data60 != @nan@ then + return -1 +endi +if $data70 != @0.000000000@ then + return -1 +endi +if $data80 != @nan@ then + return -1 +endi +if $data90 != @nan@ then + return -1 +endi +print execute sql select acos(c2) from stba; +sql select acos(c2) from stba; +if $data00 != @0.000000000@ then + return -1 +endi +if $data10 != @nan@ then + return -1 +endi +if $data20 != @nan@ then + return -1 +endi +if $data30 != @nan@ then + return -1 +endi +if $data40 != @nan@ then + return -1 +endi +if $data50 != @nan@ then + return -1 +endi +if $data60 != @nan@ then + return -1 +endi +if $data70 != @nan@ then + return -1 +endi +if $data80 != @nan@ then + return -1 +endi +if $data90 != @1.570796327@ then + return -1 +endi +print execute sql select acos(min(c2)) from tba1; +sql select acos(min(c2)) from tba1; +if $data00 != @1.570796327@ then + return -1 +endi +print execute sql select acos(max(c2)) from tba1; +sql select acos(max(c2)) from tba1; +if $data00 != @nan@ then + return -1 +endi +print execute sql select acos(count(c2)) from tba1; +sql select acos(count(c2)) from tba1; +if $data00 != @nan@ then + return -1 +endi +print execute sql select acos(sum(c2)) from tba1; +sql select acos(sum(c2)) from tba1; +if $data00 != @nan@ then + return -1 +endi +print execute sql select acos(avg(c2)) from tba1; +sql select acos(avg(c2)) from tba1; +if $data00 != @nan@ then + return -1 +endi +print execute sql select acos(percentile(c2, 10)) from tba1; +sql select acos(percentile(c2, 10)) from tba1; +if $data00 != @0.451026812@ then + return -1 +endi +print execute sql select acos(apercentile(c2, 10)) from tba1; +sql select acos(apercentile(c2, 10)) from tba1; +if $data00 != @1.570796327@ then + return -1 +endi +print execute sql select acos(stddev(c2)) from tba1; +sql select acos(stddev(c2)) from tba1; +if $data00 != @nan@ then + return -1 +endi +print execute sql select acos(spread(c2)) from tba1; +sql select acos(spread(c2)) from tba1; +if $data00 != @nan@ then + return -1 +endi +print execute sql select acos(twa(c2)) from tba1; +sql select acos(twa(c2)) from tba1; +if $data00 != @nan@ then + return -1 +endi +print execute sql select acos(leastsquares(c2, 1, 1)) from tba1; +sql_error select acos(leastsquares(c2, 1, 1)) from tba1; +print execute sql select acos(interp(c2)) from tba1 every(1s) +sql select acos(interp(c2)) from tba1 every(1s) +if $data00 != @21-11-11 09:00:00.000@ then + return -1 +endi +if $data01 != @0.000000000@ then + return -1 +endi +if $data10 != @21-11-11 09:00:01.000@ then + return -1 +endi +if $data11 != @nan@ then + return -1 +endi +if $data20 != @21-11-11 09:00:02.000@ then + return -1 +endi +if $data21 != @nan@ then + return -1 +endi +if $data30 != @21-11-11 09:00:03.000@ then + return -1 +endi +if $data31 != @nan@ then + return -1 +endi +if $data40 != @21-11-11 09:00:04.000@ then + return -1 +endi +if $data41 != @nan@ then + return -1 +endi +if $data50 != @21-11-11 09:00:05.000@ then + return -1 +endi +if $data51 != @nan@ then + return -1 +endi +if $data60 != @21-11-11 09:00:06.000@ then + return -1 +endi +if $data61 != @nan@ then + return -1 +endi +if $data70 != @21-11-11 09:00:07.000@ then + return -1 +endi +if $data71 != @nan@ then + return -1 +endi +if $data80 != @21-11-11 09:00:08.000@ then + return -1 +endi +if $data81 != @nan@ then + return -1 +endi +if $data90 != @21-11-11 09:00:09.000@ then + return -1 +endi +if $data91 != @1.570796327@ then + return -1 +endi +print execute sql select acos(interp(c2)) from stba every(1s) group by tbname; +sql select acos(interp(c2)) from stba every(1s) group by tbname; +if $data00 != @21-11-11 09:00:00.000@ then + return -1 +endi +if $data01 != @0.000000000@ then + return -1 +endi +if $data02 != @tba1@ then + return -1 +endi +if $data10 != @21-11-11 09:00:01.000@ then + return -1 +endi +if $data11 != @nan@ then + return -1 +endi +if $data12 != @tba1@ then + return -1 +endi +if $data20 != @21-11-11 09:00:02.000@ then + return -1 +endi +if $data21 != @nan@ then + return -1 +endi +if $data22 != @tba1@ then + return -1 +endi +if $data30 != @21-11-11 09:00:03.000@ then + return -1 +endi +if $data31 != @nan@ then + return -1 +endi +if $data32 != @tba1@ then + return -1 +endi +if $data40 != @21-11-11 09:00:04.000@ then + return -1 +endi +if $data41 != @nan@ then + return -1 +endi +if $data42 != @tba1@ then + return -1 +endi +if $data50 != @21-11-11 09:00:05.000@ then + return -1 +endi +if $data51 != @nan@ then + return -1 +endi +if $data52 != @tba1@ then + return -1 +endi +if $data60 != @21-11-11 09:00:06.000@ then + return -1 +endi +if $data61 != @nan@ then + return -1 +endi +if $data62 != @tba1@ then + return -1 +endi +if $data70 != @21-11-11 09:00:07.000@ then + return -1 +endi +if $data71 != @nan@ then + return -1 +endi +if $data72 != @tba1@ then + return -1 +endi +if $data80 != @21-11-11 09:00:08.000@ then + return -1 +endi +if $data81 != @nan@ then + return -1 +endi +if $data82 != @tba1@ then + return -1 +endi +if $data90 != @21-11-11 09:00:09.000@ then + return -1 +endi +if $data91 != @1.570796327@ then + return -1 +endi +if $data92 != @tba1@ then + return -1 +endi +print execute sql select acos(elapsed(ts)) from tba1; +sql select acos(elapsed(ts)) from tba1; +if $data00 != @nan@ then + return -1 +endi +print execute sql select acos(rate(c2)) from tba1; +sql select acos(rate(c2)) from tba1; +if $data00 != @0.458874205@ then + return -1 +endi +print execute sql select acos(irate(c2)) from tba1; +sql select acos(irate(c2)) from tba1; +if $data00 != @1.570796327@ then + return -1 +endi +print execute sql select acos(first(c2)) from tba1; +sql select acos(first(c2)) from tba1; +if $data00 != @0.000000000@ then + return -1 +endi +print execute sql select acos(last(c2)) from tba1; +sql select acos(last(c2)) from tba1; +if $data00 != @1.570796327@ then + return -1 +endi +print execute sql select acos(last_row(c2)) from tba1; +sql select acos(last_row(c2)) from tba1; +if $data00 != @1.570796327@ then + return -1 +endi +print execute sql select acos(top(c2, 1)) from tba1; +sql_error select acos(top(c2, 1)) from tba1; +print execute sql select acos(bottom(c2, 1)) from tba1; +sql_error select acos(bottom(c2, 1)) from tba1; +print execute sql select acos(leastsquares(c2, 1, 1)) from tba1; +sql_error select acos(leastsquares(c2, 1, 1)) from tba1; +print execute sql select acos(derivative(c2, 1s, 0)) from tba1; +sql_error select acos(derivative(c2, 1s, 0)) from tba1; +print execute sql select acos(diff(c2)) from tba1; +sql_error select acos(diff(c2)) from tba1; +print execute sql select acos(csum(c2)) from tba1; +sql_error select acos(csum(c2)) from tba1; +print execute sql select acos(mavg(c2,2)) from tba1; +sql_error select acos(mavg(c2,2)) from tba1; +print execute sql select acos(sample(c2,2)) from tba1; +sql_error select acos(sample(c2,2)) from tba1; +print execute sql select acos(_block_dist()) from tba1; +sql_error select acos(_block_dist()) from tba1; diff --git a/tests/script/general/compute/math_cos.sim b/tests/script/general/compute/math_cos.sim new file mode 100644 index 0000000000000000000000000000000000000000..b10845ce2e42849924c1d8c9888b2943d138504a --- /dev/null +++ b/tests/script/general/compute/math_cos.sim @@ -0,0 +1,1073 @@ +sleep 100 +sql connect +sql use db + +print execute sql select cos(*) from tb1; +sql_error select cos(*) from tb1; +print execute sql select cos(*) from tb1; +sql_error select cos(*) from tb1; +print execute sql select cos(*) from tb1; +sql_error select cos(*) from tb1; +print execute sql select cos(*) from tb1; +sql_error select cos(*) from tb1; +print execute sql select cos(*) as a from tb1; +sql_error select cos(*) as a from tb1; +print execute sql select cos(*) + 1 as a from tb1; +sql_error select cos(*) + 1 as a from tb1; +print execute sql select cos(tb1.*) + 1 as a from tb1; +sql_error select cos(tb1.*) + 1 as a from tb1; +print execute sql select cos(*) from tb1; +sql_error select cos(*) from tb1; +print execute sql select cos(c1) from tb1; +sql_error select cos(c1) from tb1; +print execute sql select cos(c1) from tb1; +sql_error select cos(c1) from tb1; +print execute sql select cos(c1 + c2) from tb1; +sql_error select cos(c1 + c2) from tb1; +print execute sql select cos(13) from tb1; +sql select cos(13) from tb1; +if $data00 != @0.907446781@ then + return -1 +endi +if $data10 != @0.907446781@ then + return -1 +endi +if $data20 != @0.907446781@ then + return -1 +endi +if $data30 != @0.907446781@ then + return -1 +endi +if $data40 != @0.907446781@ then + return -1 +endi +if $data50 != @0.907446781@ then + return -1 +endi +if $data60 != @0.907446781@ then + return -1 +endi +print execute sql select cos(c1) from tb1; +sql_error select cos(c1) from tb1; +print execute sql select cos(c2) from tb1; +sql select cos(c2) from tb1; +if $data00 != @0.540302306@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data20 != @-0.416146837@ then + return -1 +endi +if $data30 != @NULL@ then + return -1 +endi +if $data40 != @-0.653643621@ then + return -1 +endi +if $data50 != @0.232359102@ then + return -1 +endi +if $data60 != @0.232359102@ then + return -1 +endi +print execute sql select cos(c3) from tb1; +sql select cos(c3) from tb1; +if $data00 != @0.540302306@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data20 != @NULL@ then + return -1 +endi +if $data30 != @-0.989992497@ then + return -1 +endi +if $data40 != @-0.653643621@ then + return -1 +endi +if $data50 != @0.982263352@ then + return -1 +endi +if $data60 != @0.982263352@ then + return -1 +endi +print execute sql select cos(c4) from tb1; +sql select cos(c4) from tb1; +if $data00 != @0.540302306@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data20 != @-0.416146837@ then + return -1 +endi +if $data30 != @NULL@ then + return -1 +endi +if $data40 != @-0.653643621@ then + return -1 +endi +if $data50 != @-0.688836692@ then + return -1 +endi +if $data60 != @-0.688836692@ then + return -1 +endi +print execute sql select cos(c5) from tb1; +sql select cos(c5) from tb1; +if $data00 != @0.540302306@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data20 != @NULL@ then + return -1 +endi +if $data30 != @-0.989992497@ then + return -1 +endi +if $data40 != @-0.653643621@ then + return -1 +endi +if $data50 != @0.011800077@ then + return -1 +endi +if $data60 != @0.011800077@ then + return -1 +endi +print execute sql select cos(c6) from tb1; +sql select cos(c6) from tb1; +if $data00 != @0.540302306@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data20 != @-0.416146837@ then + return -1 +endi +if $data30 != @NULL@ then + return -1 +endi +if $data40 != @-0.653643621@ then + return -1 +endi +if $data50 != @0.853021040@ then + return -1 +endi +if $data60 != @0.853021040@ then + return -1 +endi +print execute sql select cos(c7) from tb1; +sql select cos(c7) from tb1; +if $data00 != @0.540302306@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data20 != @NULL@ then + return -1 +endi +if $data30 != @-0.989992497@ then + return -1 +endi +if $data40 != @-0.653643621@ then + return -1 +endi +if $data50 != @0.488025633@ then + return -1 +endi +if $data60 != @0.488025633@ then + return -1 +endi +print execute sql select cos(c8) from tb1; +sql_error select cos(c8) from tb1; +print execute sql select cos(c9) from tb1; +sql_error select cos(c9) from tb1; +print execute sql select cos(c10) from tb1; +sql select cos(c10) from tb1; +if $data00 != @0.540302306@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data20 != @-0.416146837@ then + return -1 +endi +if $data30 != @NULL@ then + return -1 +endi +if $data40 != @-0.653643621@ then + return -1 +endi +if $data50 != @-0.892018495@ then + return -1 +endi +if $data60 != @1.000000000@ then + return -1 +endi +print execute sql select cos(c11) from tb1; +sql select cos(c11) from tb1; +if $data00 != @0.540302306@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data20 != @NULL@ then + return -1 +endi +if $data30 != @-0.989992497@ then + return -1 +endi +if $data40 != @-0.653643621@ then + return -1 +endi +if $data50 != @0.929682584@ then + return -1 +endi +if $data60 != @1.000000000@ then + return -1 +endi +print execute sql select cos(c12) from tb1; +sql select cos(c12) from tb1; +if $data00 != @0.540302306@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data20 != @-0.416146837@ then + return -1 +endi +if $data30 != @NULL@ then + return -1 +endi +if $data40 != @-0.653643621@ then + return -1 +endi +if $data50 != @-0.051008024@ then + return -1 +endi +if $data60 != @1.000000000@ then + return -1 +endi +print execute sql select cos(c13) from tb1; +sql select cos(c13) from tb1; +if $data00 != @0.540302306@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data20 != @NULL@ then + return -1 +endi +if $data30 != @-0.989992497@ then + return -1 +endi +if $data40 != @-0.653643621@ then + return -1 +endi +if $data50 != @0.011800077@ then + return -1 +endi +if $data60 != @1.000000000@ then + return -1 +endi +print execute sql select cos(12345678900000000000000000) from tb1; +sql_error select cos(12345678900000000000000000) from tb1; +print execute sql select distinct cos(123) from tb1; +sql_error select distinct cos(123) from tb1; +print execute sql select cos(t1) from stb1; +sql_error select cos(t1) from stb1; +print execute sql select cos(c1),avg(c3) from tb1; +sql_error select cos(c1),avg(c3) from tb1; +print execute sql select cos(c1),top(c3,1) from tb1; +sql_error select cos(c1),top(c3,1) from tb1; +print execute sql select cos(c2+c3) from tb1 session(ts, 1s); +sql_error select cos(c2+c3) from tb1 session(ts, 1s); +print execute sql select cos(c2+c3) from tb1 STATE_WINDOW(c1); +sql_error select cos(c2+c3) from tb1 STATE_WINDOW(c1); +print execute sql select cos(c2+c3) from tb1 interval(1s) sliding(1s) fill(NULL); +sql_error select cos(c2+c3) from tb1 interval(1s) sliding(1s) fill(NULL); +print execute sql select cos(c2+c3) from stb1 group by t1; +sql_error select cos(c2+c3) from stb1 group by t1; +print execute sql select cos(c2+c3) from stb1 group by ts; +sql_error select cos(c2+c3) from stb1 group by ts; +print execute sql select cos(c2+c3) from stb1 group by c1; +sql_error select cos(c2+c3) from stb1 group by c1; +print execute sql select cos(c2+c3) from stb1 group by tbname; +sql_error select cos(c2+c3) from stb1 group by tbname; +print execute sql select cos(c2+c3) from tb1 order by c2; +sql_error select cos(c2+c3) from tb1 order by c2; +print execute sql select cos(c8),cos(c9) from tbn; +sql_error select cos(c8),cos(c9) from tbn; +print execute sql select cos(ts) from (select avg(c2) as a from stb1 interval(1s)); +sql_error select cos(ts) from (select avg(c2) as a from stb1 interval(1s)); +print execute sql select cos(a) from (select cos(c2) as a from tb1); +sql select cos(a) from (select cos(c2) as a from tb1); +if $data00 != @0.857553216@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data20 != @0.914653326@ then + return -1 +endi +if $data30 != @NULL@ then + return -1 +endi +if $data40 != @0.793873449@ then + return -1 +endi +if $data50 != @0.973125864@ then + return -1 +endi +if $data60 != @0.973125864@ then + return -1 +endi +print execute sql select cos("abc") from tb1; +sql_error select cos("abc") from tb1; +print execute sql select cos(c2 + c3) from tb1; +sql select cos(c2 + c3) from tb1; +if $data00 != @-0.416146837@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data20 != @NULL@ then + return -1 +endi +if $data30 != @NULL@ then + return -1 +endi +if $data40 != @-0.145500034@ then + return -1 +endi +if $data50 != @0.045863318@ then + return -1 +endi +if $data60 != @0.045863318@ then + return -1 +endi +print execute sql select cos((c2 + c3)) from tb1; +sql select cos((c2 + c3)) from tb1; +if $data00 != @-0.416146837@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data20 != @NULL@ then + return -1 +endi +if $data30 != @NULL@ then + return -1 +endi +if $data40 != @-0.145500034@ then + return -1 +endi +if $data50 != @0.045863318@ then + return -1 +endi +if $data60 != @0.045863318@ then + return -1 +endi +print execute sql select cos((c2 * c3)+c4-6) from tb1; +sql select cos((c2 * c3)+c4-6) from tb1; +if $data00 != @-0.653643621@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data20 != @NULL@ then + return -1 +endi +if $data30 != @NULL@ then + return -1 +endi +if $data40 != @0.136737218@ then + return -1 +endi +if $data50 != @-0.996514711@ then + return -1 +endi +if $data60 != @0.134138861@ then + return -1 +endi +print execute sql select cos(11)+c2 from tb1; +sql select cos(11)+c2 from tb1; +if $data00 != @1.004425698@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data20 != @2.004425698@ then + return -1 +endi +if $data30 != @NULL@ then + return -1 +endi +if $data40 != @4.004425698@ then + return -1 +endi +if $data50 != @127.004425698@ then + return -1 +endi +if $data60 != @-126.995574302@ then + return -1 +endi +print execute sql select cos(c1)+c2 from tb1; +sql_error select cos(c1)+c2 from tb1; +print execute sql select cos(c2)+11 from tb1; +sql select cos(c2)+11 from tb1; +if $data00 != @11.540302306@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data20 != @10.583853163@ then + return -1 +endi +if $data30 != @NULL@ then + return -1 +endi +if $data40 != @10.346356379@ then + return -1 +endi +if $data50 != @11.232359102@ then + return -1 +endi +if $data60 != @11.232359102@ then + return -1 +endi +print execute sql select cos(c1),c1,c2 from tb1; +sql_error select cos(c1),c1,c2 from tb1; +print execute sql select cos(c1),t1,ts,tbname,_C0,_c0 from tb1; +sql_error select cos(c1),t1,ts,tbname,_C0,_c0 from tb1; +print execute sql select cos(c1),floor(c3) from tb1; +sql_error select cos(c1),floor(c3) from tb1; +print execute sql select cos(c1),cos(c2+c3) from tb1; +sql_error select cos(c1),cos(c2+c3) from tb1; +print execute sql select cos(c2+c3) from tb1 where c2 is not null and c3 is not null; +sql select cos(c2+c3) from tb1 where c2 is not null and c3 is not null; +if $data00 != @-0.416146837@ then + return -1 +endi +if $data10 != @-0.145500034@ then + return -1 +endi +if $data20 != @0.045863318@ then + return -1 +endi +if $data30 != @0.045863318@ then + return -1 +endi +print execute sql select cos(c2) from tb1 order by ts desc; +sql select cos(c2) from tb1 order by ts desc; +if $data00 != @0.232359102@ then + return -1 +endi +if $data10 != @0.232359102@ then + return -1 +endi +if $data20 != @-0.653643621@ then + return -1 +endi +if $data30 != @NULL@ then + return -1 +endi +if $data40 != @-0.416146837@ then + return -1 +endi +if $data50 != @NULL@ then + return -1 +endi +if $data60 != @0.540302306@ then + return -1 +endi +print execute sql select cos(c2+c3) from tb1 order by ts desc; +sql select cos(c2+c3) from tb1 order by ts desc; +if $data00 != @0.045863318@ then + return -1 +endi +if $data10 != @0.045863318@ then + return -1 +endi +if $data20 != @-0.145500034@ then + return -1 +endi +if $data30 != @NULL@ then + return -1 +endi +if $data40 != @NULL@ then + return -1 +endi +if $data50 != @NULL@ then + return -1 +endi +if $data60 != @-0.416146837@ then + return -1 +endi +print execute sql select cos(c2+c3) from tb1 order by ts desc limit 3 offset 2; +sql select cos(c2+c3) from tb1 order by ts desc limit 3 offset 2; +if $data00 != @-0.145500034@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data20 != @NULL@ then + return -1 +endi +print execute sql select cos(c2) from stb1; +sql select cos(c2) from stb1; +if $data00 != @0.540302306@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data20 != @-0.416146837@ then + return -1 +endi +if $data30 != @NULL@ then + return -1 +endi +if $data40 != @-0.653643621@ then + return -1 +endi +if $data50 != @0.232359102@ then + return -1 +endi +if $data60 != @0.232359102@ then + return -1 +endi +if $data70 != @0.540302306@ then + return -1 +endi +if $data80 != @-0.416146837@ then + return -1 +endi +if $data90 != @-0.989992497@ then + return -1 +endi +print execute sql select cos(c2) from stb1 order by ts desc; +sql select cos(c2) from stb1 order by ts desc; +if $data00 != @0.753902254@ then + if $data00 != @0.232359102@ then + return -1 + endi +endi +if $data20 != @0.960170287@ then + if $data20 != @0.232359102@ then + return -1 + endi +endi +if $data40 != @0.283662185@ then + if $data40 != @-0.653643621@ then + return -1 + endi +endi +if $data60 != @-0.653643621@ then + if $data60 != @NULL@ then + return -1 + endi +endi +if $data80 != @-0.989992497@ then + if $data80 != @-0.416146837@ then + return -1 + endi +endi +print execute sql select cos(c4),t1 from stb1 order by ts desc; +sql select cos(c4),t1 from stb1 order by ts desc; +if $data00 != @0.753902254@ then + if $data00 != @-0.688836692@ then + return -1 + endi +endi +if $data01 != @2@ then + if $data01 != @1@ then + return -1 + endi +endi +if $data20 != @0.960170287@ then + if $data20 != @-0.688836692@ then + return -1 + endi +endi +if $data21 != @2@ then + if $data21 != @1@ then + return -1 + endi +endi +if $data40 != @0.283662185@ then + if $data40 != @-0.653643621@ then + return -1 + endi +endi +if $data41 != @2@ then + if $data41 != @1@ then + return -1 + endi +endi +if $data60 != @-0.653643621@ then + if $data60 != @NULL@ then + return -1 + endi +endi +if $data61 != @2@ then + if $data61 != @1@ then + return -1 + endi +endi +if $data80 != @-0.416146837@ then + if $data80 != @-0.416146837@ then + return -1 + endi +endi +if $data81 != @2@ then + if $data81 != @1@ then + return -1 + endi +endi +print execute sql select cos(c3),tbname from stb1; +sql select cos(c3),tbname from stb1; +if $data00 != @0.540302306@ then + return -1 +endi +if $data01 != @tb1@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data11 != @tb1@ then + return -1 +endi +if $data20 != @NULL@ then + return -1 +endi +if $data21 != @tb1@ then + return -1 +endi +if $data30 != @-0.989992497@ then + return -1 +endi +if $data31 != @tb1@ then + return -1 +endi +if $data40 != @-0.653643621@ then + return -1 +endi +if $data41 != @tb1@ then + return -1 +endi +if $data50 != @0.982263352@ then + return -1 +endi +if $data51 != @tb1@ then + return -1 +endi +if $data60 != @0.982263352@ then + return -1 +endi +if $data61 != @tb1@ then + return -1 +endi +if $data70 != @0.540302306@ then + return -1 +endi +if $data71 != @tb2@ then + return -1 +endi +if $data80 != @-0.416146837@ then + return -1 +endi +if $data81 != @tb2@ then + return -1 +endi +if $data90 != @-0.989992497@ then + return -1 +endi +if $data91 != @tb2@ then + return -1 +endi +print execute sql select cos(c3),tbname from stb1 where t1 > 1; +sql select cos(c3),tbname from stb1 where t1 > 1; +if $data00 != @0.540302306@ then + return -1 +endi +if $data01 != @tb2@ then + return -1 +endi +if $data10 != @-0.416146837@ then + return -1 +endi +if $data11 != @tb2@ then + return -1 +endi +if $data20 != @-0.989992497@ then + return -1 +endi +if $data21 != @tb2@ then + return -1 +endi +if $data30 != @-0.653643621@ then + return -1 +endi +if $data31 != @tb2@ then + return -1 +endi +if $data40 != @0.283662185@ then + return -1 +endi +if $data41 != @tb2@ then + return -1 +endi +if $data50 != @0.960170287@ then + return -1 +endi +if $data51 != @tb2@ then + return -1 +endi +if $data60 != @0.753902254@ then + return -1 +endi +if $data61 != @tb2@ then + return -1 +endi +print execute sql select cos(c8),cos(c9) from tbn; +sql_error select cos(c8),cos(c9) from tbn; +print execute sql select cos(c8),cos(c9) from tbn order by ts desc; +sql_error select cos(c8),cos(c9) from tbn order by ts desc; +print execute sql select cos(cos(c8)) from tbn; +sql_error select cos(cos(c8)) from tbn; +print execute sql select cos(a) from (select avg(c2) as a from stb1 interval(1s)); +sql select cos(a) from (select avg(c2) as a from stb1 interval(1s)); +if $data00 != @0.540302306@ then + return -1 +endi +if $data10 != @-0.416146837@ then + return -1 +endi +if $data20 != @-0.801143616@ then + return -1 +endi +if $data30 != @-0.653643621@ then + return -1 +endi +if $data40 != @-0.210795799@ then + return -1 +endi +if $data50 != @-0.864543874@ then + return -1 +endi +if $data60 != @-0.952412980@ then + return -1 +endi +print execute sql select cos(c2) from (select * from stb1); +sql select cos(c2) from (select * from stb1); +if $data00 != @0.540302306@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data20 != @-0.416146837@ then + return -1 +endi +if $data30 != @NULL@ then + return -1 +endi +if $data40 != @-0.653643621@ then + return -1 +endi +if $data50 != @0.232359102@ then + return -1 +endi +if $data60 != @0.232359102@ then + return -1 +endi +if $data70 != @0.540302306@ then + return -1 +endi +if $data80 != @-0.416146837@ then + return -1 +endi +if $data90 != @-0.989992497@ then + return -1 +endi +print execute sql select cos(a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)); +sql select cos(a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)); +if $data00 != @0.540302306@ then + return -1 +endi +if $data10 != @-0.416146837@ then + return -1 +endi +if $data20 != @-0.801143616@ then + return -1 +endi +if $data30 != @-0.653643621@ then + return -1 +endi +if $data40 != @-0.210795799@ then + return -1 +endi +if $data50 != @-0.864543874@ then + return -1 +endi +if $data60 != @-0.952412980@ then + return -1 +endi +if $data70 != @NULL@ then + return -1 +endi +if $data80 != @NULL@ then + return -1 +endi +if $data90 != @NULL@ then + return -1 +endi +print execute sql select cos(a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)) order by ts; +sql select cos(a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)) order by ts; +if $data00 != @0.540302306@ then + return -1 +endi +if $data10 != @-0.416146837@ then + return -1 +endi +if $data20 != @-0.801143616@ then + return -1 +endi +if $data30 != @-0.653643621@ then + return -1 +endi +if $data40 != @-0.210795799@ then + return -1 +endi +if $data50 != @-0.864543874@ then + return -1 +endi +if $data60 != @-0.952412980@ then + return -1 +endi +if $data70 != @NULL@ then + return -1 +endi +if $data80 != @NULL@ then + return -1 +endi +if $data90 != @NULL@ then + return -1 +endi +print execute sql select cos(a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)) order by ts desc; +sql select cos(a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)) order by ts desc; +if $data00 != @NULL@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data20 != @NULL@ then + return -1 +endi +if $data30 != @-0.952412980@ then + return -1 +endi +if $data40 != @-0.864543874@ then + return -1 +endi +if $data50 != @-0.210795799@ then + return -1 +endi +if $data60 != @-0.653643621@ then + return -1 +endi +if $data70 != @-0.801143616@ then + return -1 +endi +if $data80 != @-0.416146837@ then + return -1 +endi +if $data90 != @0.540302306@ then + return -1 +endi +print execute sql select cos(a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)) order by a desc; +sql select cos(a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)) order by a desc; +if $data00 != @NULL@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data20 != @NULL@ then + return -1 +endi +if $data30 != @-0.864543874@ then + return -1 +endi +if $data40 != @-0.210795799@ then + return -1 +endi +if $data50 != @-0.653643621@ then + return -1 +endi +if $data60 != @-0.801143616@ then + return -1 +endi +if $data70 != @-0.416146837@ then + return -1 +endi +if $data80 != @0.540302306@ then + return -1 +endi +if $data90 != @-0.952412980@ then + return -1 +endi +print execute sql select cos(a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)) order by a; +sql select cos(a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)) order by a; +if $data00 != @-0.952412980@ then + return -1 +endi +if $data10 != @0.540302306@ then + return -1 +endi +if $data20 != @-0.416146837@ then + return -1 +endi +if $data30 != @-0.801143616@ then + return -1 +endi +if $data40 != @-0.653643621@ then + return -1 +endi +if $data50 != @-0.210795799@ then + return -1 +endi +if $data60 != @-0.864543874@ then + return -1 +endi +if $data70 != @NULL@ then + return -1 +endi +if $data80 != @NULL@ then + return -1 +endi +if $data90 != @NULL@ then + return -1 +endi +print execute sql select cos(a) from (select cos(c2) as a from tb1); +sql select cos(a) from (select cos(c2) as a from tb1); +if $data00 != @0.857553216@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data20 != @0.914653326@ then + return -1 +endi +if $data30 != @NULL@ then + return -1 +endi +if $data40 != @0.793873449@ then + return -1 +endi +if $data50 != @0.973125864@ then + return -1 +endi +if $data60 != @0.973125864@ then + return -1 +endi +print execute sql select cos(tb1.c3),cos(tb2.c3) from tb1,tb2 where tb1.ts=tb2.ts; +sql select cos(tb1.c3),cos(tb2.c3) from tb1,tb2 where tb1.ts=tb2.ts; +if $data00 != @0.540302306@ then + return -1 +endi +if $data01 != @0.540302306@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data11 != @-0.416146837@ then + return -1 +endi +if $data20 != @NULL@ then + return -1 +endi +if $data21 != @-0.989992497@ then + return -1 +endi +if $data30 != @-0.989992497@ then + return -1 +endi +if $data31 != @-0.653643621@ then + return -1 +endi +if $data40 != @-0.653643621@ then + return -1 +endi +if $data41 != @0.283662185@ then + return -1 +endi +if $data50 != @0.982263352@ then + return -1 +endi +if $data51 != @0.960170287@ then + return -1 +endi +if $data60 != @0.982263352@ then + return -1 +endi +if $data61 != @0.753902254@ then + return -1 +endi +print execute sql select cos(c3) from tb1 union all select cos(c3) from tb2; +sql select cos(c3) from tb1 union all select cos(c3) from tb2; +if $data00 != @0.540302306@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data20 != @NULL@ then + return -1 +endi +if $data30 != @-0.989992497@ then + return -1 +endi +if $data40 != @-0.653643621@ then + return -1 +endi +if $data50 != @0.982263352@ then + return -1 +endi +if $data60 != @0.982263352@ then + return -1 +endi +if $data70 != @0.540302306@ then + return -1 +endi +if $data80 != @-0.416146837@ then + return -1 +endi +if $data90 != @-0.989992497@ then + return -1 +endi diff --git a/tests/script/general/compute/math_cos2.sim b/tests/script/general/compute/math_cos2.sim new file mode 100644 index 0000000000000000000000000000000000000000..ab263cfac0fc55c41a9e7a4b1ea4d1588e38bb54 --- /dev/null +++ b/tests/script/general/compute/math_cos2.sim @@ -0,0 +1,366 @@ +sleep 100 +sql connect +sql use db + +print execute sql select cos(stb1.c4),cos(stba.c5) from stb1,stba where stb1.t1=stba.t1 and stb1.ts=stba.ts; +sql select cos(stb1.c4),cos(stba.c5) from stb1,stba where stb1.t1=stba.t1 and stb1.ts=stba.ts; +if $data00 != @0.540302306@ then + return -1 +endi +if $data01 != @0.540302306@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data11 != @-0.416146837@ then + return -1 +endi +if $data20 != @-0.416146837@ then + return -1 +endi +if $data21 != @-0.989992497@ then + return -1 +endi +if $data30 != @NULL@ then + return -1 +endi +if $data31 != @-0.653643621@ then + return -1 +endi +if $data40 != @-0.653643621@ then + return -1 +endi +if $data41 != @0.283662185@ then + return -1 +endi +if $data50 != @-0.688836692@ then + return -1 +endi +if $data51 != @0.960170287@ then + return -1 +endi +if $data60 != @-0.688836692@ then + return -1 +endi +if $data61 != @0.753902254@ then + return -1 +endi +print execute sql select cos(c4) as a from stb1 union all select cos(c5) as a from stba; +sql select cos(c4) as a from stb1 union all select cos(c5) as a from stba; +if $data00 != @0.540302306@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data20 != @-0.416146837@ then + return -1 +endi +if $data30 != @NULL@ then + return -1 +endi +if $data40 != @-0.653643621@ then + return -1 +endi +if $data50 != @-0.688836692@ then + return -1 +endi +if $data60 != @-0.688836692@ then + return -1 +endi +if $data70 != @0.540302306@ then + return -1 +endi +if $data80 != @-0.416146837@ then + return -1 +endi +if $data90 != @-0.416146837@ then + return -1 +endi +print execute sql select cos(c2) from stba; +sql select cos(c2) from stba; +if $data00 != @0.540302306@ then + return -1 +endi +if $data10 != @-0.416146837@ then + return -1 +endi +if $data20 != @-0.989992497@ then + return -1 +endi +if $data30 != @-0.653643621@ then + return -1 +endi +if $data40 != @0.283662185@ then + return -1 +endi +if $data50 != @0.960170287@ then + return -1 +endi +if $data60 != @0.753902254@ then + return -1 +endi +if $data70 != @-0.145500034@ then + return -1 +endi +if $data80 != @-0.911130262@ then + return -1 +endi +if $data90 != @1.000000000@ then + return -1 +endi +print execute sql select cos(min(c2)) from tba1; +sql select cos(min(c2)) from tba1; +if $data00 != @1.000000000@ then + return -1 +endi +print execute sql select cos(max(c2)) from tba1; +sql select cos(max(c2)) from tba1; +if $data00 != @-0.911130262@ then + return -1 +endi +print execute sql select cos(count(c2)) from tba1; +sql select cos(count(c2)) from tba1; +if $data00 != @0.154251450@ then + return -1 +endi +print execute sql select cos(sum(c2)) from tba1; +sql select cos(sum(c2)) from tba1; +if $data00 != @-0.996087835@ then + return -1 +endi +print execute sql select cos(avg(c2)) from tba1; +sql select cos(avg(c2)) from tba1; +if $data00 != @-0.210795799@ then + return -1 +endi +print execute sql select cos(percentile(c2, 10)) from tba1; +sql select cos(percentile(c2, 10)) from tba1; +if $data00 != @0.621609968@ then + return -1 +endi +print execute sql select cos(apercentile(c2, 10)) from tba1; +sql select cos(apercentile(c2, 10)) from tba1; +if $data00 != @1.000000000@ then + return -1 +endi +print execute sql select cos(stddev(c2)) from tba1; +sql select cos(stddev(c2)) from tba1; +if $data00 != @-0.963954358@ then + return -1 +endi +print execute sql select cos(spread(c2)) from tba1; +sql select cos(spread(c2)) from tba1; +if $data00 != @-0.911130262@ then + return -1 +endi +print execute sql select cos(twa(c2)) from tba1; +sql select cos(twa(c2)) from tba1; +if $data00 != @-0.074389166@ then + return -1 +endi +print execute sql select cos(leastsquares(c2, 1, 1)) from tba1; +sql_error select cos(leastsquares(c2, 1, 1)) from tba1; +print execute sql select cos(interp(c2)) from tba1 every(1s) +sql select cos(interp(c2)) from tba1 every(1s) +if $data00 != @21-11-11 09:00:00.000@ then + return -1 +endi +if $data01 != @0.540302306@ then + return -1 +endi +if $data10 != @21-11-11 09:00:01.000@ then + return -1 +endi +if $data11 != @-0.416146837@ then + return -1 +endi +if $data20 != @21-11-11 09:00:02.000@ then + return -1 +endi +if $data21 != @-0.989992497@ then + return -1 +endi +if $data30 != @21-11-11 09:00:03.000@ then + return -1 +endi +if $data31 != @-0.653643621@ then + return -1 +endi +if $data40 != @21-11-11 09:00:04.000@ then + return -1 +endi +if $data41 != @0.283662185@ then + return -1 +endi +if $data50 != @21-11-11 09:00:05.000@ then + return -1 +endi +if $data51 != @0.960170287@ then + return -1 +endi +if $data60 != @21-11-11 09:00:06.000@ then + return -1 +endi +if $data61 != @0.753902254@ then + return -1 +endi +if $data70 != @21-11-11 09:00:07.000@ then + return -1 +endi +if $data71 != @-0.145500034@ then + return -1 +endi +if $data80 != @21-11-11 09:00:08.000@ then + return -1 +endi +if $data81 != @-0.911130262@ then + return -1 +endi +if $data90 != @21-11-11 09:00:09.000@ then + return -1 +endi +if $data91 != @1.000000000@ then + return -1 +endi +print execute sql select cos(interp(c2)) from stba every(1s) group by tbname; +sql select cos(interp(c2)) from stba every(1s) group by tbname; +if $data00 != @21-11-11 09:00:00.000@ then + return -1 +endi +if $data01 != @0.540302306@ then + return -1 +endi +if $data02 != @tba1@ then + return -1 +endi +if $data10 != @21-11-11 09:00:01.000@ then + return -1 +endi +if $data11 != @-0.416146837@ then + return -1 +endi +if $data12 != @tba1@ then + return -1 +endi +if $data20 != @21-11-11 09:00:02.000@ then + return -1 +endi +if $data21 != @-0.989992497@ then + return -1 +endi +if $data22 != @tba1@ then + return -1 +endi +if $data30 != @21-11-11 09:00:03.000@ then + return -1 +endi +if $data31 != @-0.653643621@ then + return -1 +endi +if $data32 != @tba1@ then + return -1 +endi +if $data40 != @21-11-11 09:00:04.000@ then + return -1 +endi +if $data41 != @0.283662185@ then + return -1 +endi +if $data42 != @tba1@ then + return -1 +endi +if $data50 != @21-11-11 09:00:05.000@ then + return -1 +endi +if $data51 != @0.960170287@ then + return -1 +endi +if $data52 != @tba1@ then + return -1 +endi +if $data60 != @21-11-11 09:00:06.000@ then + return -1 +endi +if $data61 != @0.753902254@ then + return -1 +endi +if $data62 != @tba1@ then + return -1 +endi +if $data70 != @21-11-11 09:00:07.000@ then + return -1 +endi +if $data71 != @-0.145500034@ then + return -1 +endi +if $data72 != @tba1@ then + return -1 +endi +if $data80 != @21-11-11 09:00:08.000@ then + return -1 +endi +if $data81 != @-0.911130262@ then + return -1 +endi +if $data82 != @tba1@ then + return -1 +endi +if $data90 != @21-11-11 09:00:09.000@ then + return -1 +endi +if $data91 != @1.000000000@ then + return -1 +endi +if $data92 != @tba1@ then + return -1 +endi +print execute sql select cos(elapsed(ts)) from tba1; +sql select cos(elapsed(ts)) from tba1; +if $data00 != @-0.999127122@ then + return -1 +endi +print execute sql select cos(rate(c2)) from tba1; +sql select cos(rate(c2)) from tba1; +if $data00 != @0.624307395@ then + return -1 +endi +print execute sql select cos(irate(c2)) from tba1; +sql select cos(irate(c2)) from tba1; +if $data00 != @1.000000000@ then + return -1 +endi +print execute sql select cos(first(c2)) from tba1; +sql select cos(first(c2)) from tba1; +if $data00 != @0.540302306@ then + return -1 +endi +print execute sql select cos(last(c2)) from tba1; +sql select cos(last(c2)) from tba1; +if $data00 != @1.000000000@ then + return -1 +endi +print execute sql select cos(last_row(c2)) from tba1; +sql select cos(last_row(c2)) from tba1; +if $data00 != @1.000000000@ then + return -1 +endi +print execute sql select cos(top(c2, 1)) from tba1; +sql_error select cos(top(c2, 1)) from tba1; +print execute sql select cos(bottom(c2, 1)) from tba1; +sql_error select cos(bottom(c2, 1)) from tba1; +print execute sql select cos(leastsquares(c2, 1, 1)) from tba1; +sql_error select cos(leastsquares(c2, 1, 1)) from tba1; +print execute sql select cos(derivative(c2, 1s, 0)) from tba1; +sql_error select cos(derivative(c2, 1s, 0)) from tba1; +print execute sql select cos(diff(c2)) from tba1; +sql_error select cos(diff(c2)) from tba1; +print execute sql select cos(csum(c2)) from tba1; +sql_error select cos(csum(c2)) from tba1; +print execute sql select cos(mavg(c2,2)) from tba1; +sql_error select cos(mavg(c2,2)) from tba1; +print execute sql select cos(sample(c2,2)) from tba1; +sql_error select cos(sample(c2,2)) from tba1; +print execute sql select cos(_block_dist()) from tba1; +sql_error select cos(_block_dist()) from tba1; diff --git a/tests/script/general/compute/math_funcs.sim b/tests/script/general/compute/math_funcs.sim new file mode 100644 index 0000000000000000000000000000000000000000..0912595655838bd58a15d418029293fcb4185813 --- /dev/null +++ b/tests/script/general/compute/math_funcs.sim @@ -0,0 +1,130 @@ +system sh/stop_dnodes.sh + +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/cfg.sh -n dnode1 -c maxtablespervnode -v 6 +system sh/cfg.sh -n dnode1 -c cache -v 1 +system sh/cfg.sh -n dnode1 -c minRows -v 10 +system sh/exec.sh -n dnode1 -s start + +sleep 100 +sql connect + +sql drop database if exists db +sql create database if not exists db +sql use db +sql create table stb1 (ts timestamp, c1 bool, c2 tinyint, c3 smallint, c4 int, c5 bigint, c6 float, c7 double, c8 binary(10), c9 nchar(10), c10 tinyint unsigned, c11 smallint unsigned, c12 int unsigned, c13 bigint unsigned) TAGS(t1 int, t2 binary(10), t3 double); + +sql create table tb1 using stb1 tags(1,'1',1.0); +sql create table tb2 using stb1 tags(2,'2',2.0); +sql create table tb3 using stb1 tags(3,'3',3.0); + +sql insert into tb1 values ('2021-11-11 09:00:00',true,1,1,1,1,1,1,"123","1234",1,1,1,1); +sql insert into tb1 values ('2021-11-11 09:00:01',true,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL); +sql insert into tb1 values ('2021-11-11 09:00:02',true,2,NULL,2,NULL,2,NULL,"234",NULL,2,NULL,2,NULL); +sql insert into tb1 values ('2021-11-11 09:00:03',false,NULL,3,NULL,3,NULL,3,NULL,"3456",NULL,3,NULL,3); +sql insert into tb1 values ('2021-11-11 09:00:04',true,4,4,4,4,4,4,"456","4567",4,4,4,4); +sql insert into tb1 values ('2021-11-11 09:00:05',true,127,32767,2147483647,9223372036854775807,3.402823466e+38,1.79769e+308,"567","5678",254,65534,4294967294,9223372036854775807); +sql insert into tb1 values ('2021-11-11 09:00:06',true,-127,-32767,-2147483647,-9223372036854775807,-3.402823466e+38,-1.79769e+308,"678","6789",0,0,0,0); + +sql insert into tb2 values ('2021-11-11 09:00:00',true,1,1,1,1,1,1,"111","1111",1,1,1,1); +sql insert into tb2 values ('2021-11-11 09:00:01',true,2,2,2,2,2,2,"222","2222",2,2,2,2); +sql insert into tb2 values ('2021-11-11 09:00:02',true,3,3,2,3,3,3,"333","3333",3,3,3,3); +sql insert into tb2 values ('2021-11-11 09:00:03',false,4,4,4,4,4,4,"444","4444",4,4,4,4); +sql insert into tb2 values ('2021-11-11 09:00:04',true,5,5,5,5,5,5,"555","5555",5,5,5,5); +sql insert into tb2 values ('2021-11-11 09:00:05',true,6,6,6,6,6,6,"666","6666",6,6,6,6); +sql insert into tb2 values ('2021-11-11 09:00:06',true,7,7,7,7,7,7,"777","7777",7,7,7,7); + +sql create table tbn (ts timestamp, c1 bool, c2 tinyint, c3 smallint, c4 int, c5 bigint, c6 float, c7 double, c8 binary(10), c9 nchar(10), c10 tinyint unsigned, c11 smallint unsigned, c12 int unsigned, c13 bigint unsigned); + +sql insert into tbn values ('2021-11-11 09:00:00',true,1,1,1,1,1,1,"111","1111",1,1,1,1); +sql insert into tbn values ('2021-11-11 09:00:01',true,2,2,2,2,2,2,"222","2222",2,2,2,2); +sql insert into tbn values ('2021-11-11 09:00:02',true,3,3,2,3,3,3,"333","3333",3,3,3,3); +sql insert into tbn values ('2021-11-11 09:00:03',false,4,4,4,4,4,4,"444","4444",4,4,4,4); +sql insert into tbn values ('2021-11-11 09:00:04',true,5,5,5,5,5,5,"555","5555",5,5,5,5); +sql insert into tbn values ('2021-11-11 09:00:05',true,6,6,6,6,6,6,"666","6666",6,6,6,6); +sql insert into tbn values ('2021-11-11 09:00:06',true,7,7,7,7,7,7,"777","7777",7,7,7,7); + +run general/compute/math_sqrt.sim +run general/compute/math_abs.sim +run general/compute/math_asin.sim +run general/compute/math_acos.sim +run general/compute/math_atan.sim +run general/compute/math_sin.sim +run general/compute/math_cos.sim +run general/compute/math_tan.sim +run general/compute/math_pow.sim +run general/compute/math_log.sim + + +sql create table stba (ts timestamp, c1 bool, c2 tinyint, c3 smallint, c4 int, c5 bigint, c6 float, c7 double, c8 binary(10), c9 nchar(10), c10 tinyint unsigned, c11 smallint unsigned, c12 int unsigned, c13 bigint unsigned) TAGS(t1 int, t2 binary(10), t3 double); + +sql create table tba1 using stba tags(1,'1',1.0); + +sql insert into tba1 values ('2021-11-11 09:00:00',true, 1,1,1,1,1,1,"111","1111",1,1,1,1); +sql insert into tba1 values ('2021-11-11 09:00:01',true, 2,2,2,2,2,2,"222","2222",2,2,2,2); +sql insert into tba1 values ('2021-11-11 09:00:02',true, 3,3,2,3,3,3,"333","3333",3,3,3,3); +sql insert into tba1 values ('2021-11-11 09:00:03',false,4,4,4,4,4,4,"444","4444",4,4,4,4); +sql insert into tba1 values ('2021-11-11 09:00:04',true, 5,5,5,5,5,5,"555","5555",5,5,5,5); +sql insert into tba1 values ('2021-11-11 09:00:05',true, 6,6,6,6,6,6,"666","6666",6,6,6,6); +sql insert into tba1 values ('2021-11-11 09:00:06',true, 7,7,7,7,7,7,"777","7777",7,7,7,7); +sql insert into tba1 values ('2021-11-11 09:00:07',true, 8,8,8,8,8,8,"888","8888",8,8,8,8); +sql insert into tba1 values ('2021-11-11 09:00:08',true, 9,9,9,9,9,9,"999","9999",9,9,9,9); +sql insert into tba1 values ('2021-11-11 09:00:09',true, 0,0,0,0,0,0,"000","0000",0,0,0,0); + +print ================== restart server to commit data into disk +system sh/exec.sh -n dnode1 -s stop -x SIGINT +sleep 500 +system sh/exec.sh -n dnode1 -s start +print ================== server restart completed + +sql insert into tba1 values ('2021-11-11 09:00:10',true, 1,1,1,1,1,1,"111","1111",1,1,1,1); +sql insert into tba1 values ('2021-11-11 09:00:11',true, 2,2,2,2,2,2,"222","2222",2,2,2,2); +sql insert into tba1 values ('2021-11-11 09:00:12',true, 3,3,2,3,3,3,"333","3333",3,3,3,3); +sql insert into tba1 values ('2021-11-11 09:00:13',false,4,4,4,4,4,4,"444","4444",4,4,4,4); +sql insert into tba1 values ('2021-11-11 09:00:14',true, 5,5,5,5,5,5,"555","5555",5,5,5,5); +sql insert into tba1 values ('2021-11-11 09:00:15',true, 6,6,6,6,6,6,"666","6666",6,6,6,6); +sql insert into tba1 values ('2021-11-11 09:00:16',true, 7,7,7,7,7,7,"777","7777",7,7,7,7); +sql insert into tba1 values ('2021-11-11 09:00:17',true, 8,8,8,8,8,8,"888","8888",8,8,8,8); +sql insert into tba1 values ('2021-11-11 09:00:18',true, 9,9,9,9,9,9,"999","9999",9,9,9,9); +sql insert into tba1 values ('2021-11-11 09:00:19',true, 0,0,0,0,0,0,"000","0000",0,0,0,0); + +print ================== restart server to commit data into disk +system sh/exec.sh -n dnode1 -s stop -x SIGINT +sleep 500 +system sh/exec.sh -n dnode1 -s start +print ================== server restart completed + +sql insert into tba1 values ('2021-11-11 09:00:20',true, 1,1,1,1,1,1,"111","1111",1,1,1,1); +sql insert into tba1 values ('2021-11-11 09:00:21',true, 2,2,2,2,2,2,"222","2222",2,2,2,2); +sql insert into tba1 values ('2021-11-11 09:00:22',true, 3,3,2,3,3,3,"333","3333",3,3,3,3); +sql insert into tba1 values ('2021-11-11 09:00:23',false,4,4,4,4,4,4,"444","4444",4,4,4,4); +sql insert into tba1 values ('2021-11-11 09:00:24',true, 5,5,5,5,5,5,"555","5555",5,5,5,5); +sql insert into tba1 values ('2021-11-11 09:00:25',true, 6,6,6,6,6,6,"666","6666",6,6,6,6); +sql insert into tba1 values ('2021-11-11 09:00:26',true, 7,7,7,7,7,7,"777","7777",7,7,7,7); +sql insert into tba1 values ('2021-11-11 09:00:27',true, 8,8,8,8,8,8,"888","8888",8,8,8,8); +sql insert into tba1 values ('2021-11-11 09:00:28',true, 9,9,9,9,9,9,"999","9999",9,9,9,9); +sql insert into tba1 values ('2021-11-11 09:00:29',true, 0,0,0,0,0,0,"000","0000",0,0,0,0); + +run general/compute/math_sqrt.sim +run general/compute/math_sqrt2.sim +run general/compute/math_abs.sim +run general/compute/math_abs2.sim +run general/compute/math_asin.sim +run general/compute/math_asin2.sim +run general/compute/math_acos.sim +run general/compute/math_acos2.sim +run general/compute/math_atan.sim +run general/compute/math_atan2.sim +run general/compute/math_sin.sim +run general/compute/math_sin2.sim +run general/compute/math_cos.sim +run general/compute/math_cos2.sim +run general/compute/math_tan.sim +run general/compute/math_tan2.sim +run general/compute/math_pow.sim +run general/compute/math_pow2.sim +run general/compute/math_log.sim +run general/compute/math_log2.sim +#system sh/exec.sh -n dnode1 -s stop -x SIGINT + diff --git a/tests/script/general/compute/math_log.sim b/tests/script/general/compute/math_log.sim new file mode 100644 index 0000000000000000000000000000000000000000..d8bb47d69811a516bdfecfe13de3eca374c76e36 --- /dev/null +++ b/tests/script/general/compute/math_log.sim @@ -0,0 +1,818 @@ +sleep 100 +sql connect +sql use db + +print execute sql select log(c2,*) from tb1; +sql_error select log(c2,*) from tb1; +print execute sql select log(c2,*) from tb1; +sql_error select log(c2,*) from tb1; +print execute sql select log(c2,*) from tb1; +sql_error select log(c2,*) from tb1; +print execute sql select log(c2,*) from tb1; +sql_error select log(c2,*) from tb1; +print execute sql select log(c2,*) as a from tb1; +sql_error select log(c2,*) as a from tb1; +print execute sql select log(c2,*) + 1 as a from tb1; +sql_error select log(c2,*) + 1 as a from tb1; +print execute sql select log(c2,tb1.*) + 1 as a from tb1; +sql_error select log(c2,tb1.*) + 1 as a from tb1; +print execute sql select log(c2,*) from tb1; +sql_error select log(c2,*) from tb1; +print execute sql select log(c2,c1) from tb1; +sql_error select log(c2,c1) from tb1; +print execute sql select log(c2,c1) from tb1; +sql_error select log(c2,c1) from tb1; +print execute sql select log(c2,c1 + c2) from tb1; +sql_error select log(c2,c1 + c2) from tb1; +print execute sql select log(c2,13) from tb1; +sql select log(c2,13) from tb1; +if $data00 != @0.000000000@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data20 != @0.270238154@ then + return -1 +endi +if $data30 != @NULL@ then + return -1 +endi +if $data40 != @0.540476309@ then + return -1 +endi +if $data50 != @1.888609252@ then + return -1 +endi +if $data60 != @-nan@ then + return -1 +endi +print execute sql select log(c2,c1) from tb1; +sql_error select log(c2,c1) from tb1; +print execute sql select log(c2,c2) from tb1; +sql select log(c2,c2) from tb1; +if $data00 != @-nan@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data20 != @1.000000000@ then + return -1 +endi +if $data30 != @NULL@ then + return -1 +endi +if $data40 != @1.000000000@ then + return -1 +endi +if $data50 != @1.000000000@ then + return -1 +endi +if $data60 != @-nan@ then + return -1 +endi +print execute sql select log(c2,c3) from tb1; +sql select log(c2,c3) from tb1; +if $data00 != @-nan@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data20 != @NULL@ then + return -1 +endi +if $data30 != @NULL@ then + return -1 +endi +if $data40 != @1.000000000@ then + return -1 +endi +if $data50 != @0.465913680@ then + return -1 +endi +if $data60 != @-nan@ then + return -1 +endi +print execute sql select log(c2,c4) from tb1; +sql select log(c2,c4) from tb1; +if $data00 != @-nan@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data20 != @1.000000000@ then + return -1 +endi +if $data30 != @NULL@ then + return -1 +endi +if $data40 != @1.000000000@ then + return -1 +endi +if $data50 != @0.225441442@ then + return -1 +endi +if $data60 != @-nan@ then + return -1 +endi +print execute sql select log(c2,c5) from tb1; +sql select log(c2,c5) from tb1; +if $data00 != @-nan@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data20 != @NULL@ then + return -1 +endi +if $data30 != @NULL@ then + return -1 +endi +if $data40 != @1.000000000@ then + return -1 +endi +if $data50 != @0.110931503@ then + return -1 +endi +if $data60 != @-nan@ then + return -1 +endi +print execute sql select log(c2,c6) from tb1; +sql select log(c2,c6) from tb1; +if $data00 != @-nan@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data20 != @1.000000000@ then + return -1 +endi +if $data30 != @NULL@ then + return -1 +endi +if $data40 != @1.000000000@ then + return -1 +endi +if $data50 != @0.054599099@ then + return -1 +endi +if $data60 != @-nan@ then + return -1 +endi +print execute sql select log(c2,c7) from tb1; +sql select log(c2,c7) from tb1; +if $data00 != @-nan@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data20 != @NULL@ then + return -1 +endi +if $data30 != @NULL@ then + return -1 +endi +if $data40 != @1.000000000@ then + return -1 +endi +if $data50 != @0.006824887@ then + return -1 +endi +if $data60 != @-nan@ then + return -1 +endi +print execute sql select log(c2,c8) from tb1; +sql_error select log(c2,c8) from tb1; +print execute sql select log(c2,c9) from tb1; +sql_error select log(c2,c9) from tb1; +print execute sql select log(c2,c10) from tb1; +sql select log(c2,c10) from tb1; +if $data00 != @-nan@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data20 != @1.000000000@ then + return -1 +endi +if $data30 != @NULL@ then + return -1 +endi +if $data40 != @1.000000000@ then + return -1 +endi +if $data50 != @0.874822948@ then + return -1 +endi +if $data60 != @-nan@ then + return -1 +endi +print execute sql select log(c2,c11) from tb1; +sql select log(c2,c11) from tb1; +if $data00 != @-nan@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data20 != @NULL@ then + return -1 +endi +if $data30 != @NULL@ then + return -1 +endi +if $data40 != @1.000000000@ then + return -1 +endi +if $data50 != @0.436793995@ then + return -1 +endi +if $data60 != @-nan@ then + return -1 +endi +print execute sql select log(c2,c12) from tb1; +sql select log(c2,c12) from tb1; +if $data00 != @-nan@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data20 != @1.000000000@ then + return -1 +endi +if $data30 != @NULL@ then + return -1 +endi +if $data40 != @1.000000000@ then + return -1 +endi +if $data50 != @0.218396396@ then + return -1 +endi +if $data60 != @-nan@ then + return -1 +endi +print execute sql select log(c2,c13) from tb1; +sql select log(c2,c13) from tb1; +if $data00 != @-nan@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data20 != @NULL@ then + return -1 +endi +if $data30 != @NULL@ then + return -1 +endi +if $data40 != @1.000000000@ then + return -1 +endi +if $data50 != @0.110931503@ then + return -1 +endi +if $data60 != @-nan@ then + return -1 +endi +print execute sql select log(c2,12345678900000000000000000) from tb1; +sql_error select log(c2,12345678900000000000000000) from tb1; +print execute sql select distinct log(c2,123) from tb1; +sql_error select distinct log(c2,123) from tb1; +print execute sql select log(c2,t1) from stb1; +sql_error select log(c2,t1) from stb1; +print execute sql select log(c2,c1),avg(c3) from tb1; +sql_error select log(c2,c1),avg(c3) from tb1; +print execute sql select log(c2,c1),top(c3,1) from tb1; +sql_error select log(c2,c1),top(c3,1) from tb1; +print execute sql select log(c2,c2+c3) from tb1 session(ts, 1s); +sql_error select log(c2,c2+c3) from tb1 session(ts, 1s); +print execute sql select log(c2,c2+c3) from tb1 STATE_WINDOW(c1); +sql_error select log(c2,c2+c3) from tb1 STATE_WINDOW(c1); +print execute sql select log(c2,c2+c3) from tb1 interval(1s) sliding(1s) fill(NULL); +sql_error select log(c2,c2+c3) from tb1 interval(1s) sliding(1s) fill(NULL); +print execute sql select log(c2,c2+c3) from stb1 group by t1; +sql_error select log(c2,c2+c3) from stb1 group by t1; +print execute sql select log(c2,c2+c3) from stb1 group by ts; +sql_error select log(c2,c2+c3) from stb1 group by ts; +print execute sql select log(c2,c2+c3) from stb1 group by c1; +sql_error select log(c2,c2+c3) from stb1 group by c1; +print execute sql select log(c2,c2+c3) from stb1 group by tbname; +sql_error select log(c2,c2+c3) from stb1 group by tbname; +print execute sql select log(c2,c2+c3) from tb1 order by c2; +sql_error select log(c2,c2+c3) from tb1 order by c2; +print execute sql select log(c2,c8),log(c2,c9) from tbn; +sql_error select log(c2,c8),log(c2,c9) from tbn; +print execute sql select log(c2,ts) from (select avg(c2) as a from stb1 interval(1s)); +sql_error select log(c2,ts) from (select avg(c2) as a from stb1 interval(1s)); +print execute sql select log(c2,a) from (select log(c2,c2) as a from tb1); +sql_error select log(c2,a) from (select log(c2,c2) as a from tb1); +print execute sql select log(c2,"abc") from tb1; +sql_error select log(c2,"abc") from tb1; +print execute sql select log(c2,c2 + c3) from tb1; +sql select log(c2,c2 + c3) from tb1; +if $data00 != @0.000000000@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data20 != @NULL@ then + return -1 +endi +if $data30 != @NULL@ then + return -1 +endi +if $data40 != @0.666666667@ then + return -1 +endi +if $data50 != @0.465740397@ then + return -1 +endi +if $data60 != @-nan@ then + return -1 +endi +print execute sql select log(c2,(c2 + c3)) from tb1; +sql select log(c2,(c2 + c3)) from tb1; +if $data00 != @0.000000000@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data20 != @NULL@ then + return -1 +endi +if $data30 != @NULL@ then + return -1 +endi +if $data40 != @0.666666667@ then + return -1 +endi +if $data50 != @0.465740397@ then + return -1 +endi +if $data60 != @-nan@ then + return -1 +endi +print execute sql select log(c2,(c2 * c3)+c4-6) from tb1; +sql select log(c2,(c2 * c3)+c4-6) from tb1; +if $data00 != @-nan@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data20 != @NULL@ then + return -1 +endi +if $data30 != @NULL@ then + return -1 +endi +if $data40 != @0.525299070@ then + return -1 +endi +if $data50 != @0.225421132@ then + return -1 +endi +if $data60 != @-nan@ then + return -1 +endi +print execute sql select log(c2,11)+c2 from tb1; +sql select log(c2,11)+c2 from tb1; +if $data00 != @1.000000000@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data20 != @2.289064826@ then + return -1 +endi +if $data30 != @NULL@ then + return -1 +endi +if $data40 != @4.578129653@ then + return -1 +endi +if $data50 != @129.020182925@ then + return -1 +endi +if $data60 != @-nan@ then + return -1 +endi +print execute sql select log(c2,c1)+c2 from tb1; +sql_error select log(c2,c1)+c2 from tb1; +print execute sql select log(c2,c2)+11 from tb1; +sql select log(c2,c2)+11 from tb1; +if $data00 != @-nan@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data20 != @12.000000000@ then + return -1 +endi +if $data30 != @NULL@ then + return -1 +endi +if $data40 != @12.000000000@ then + return -1 +endi +if $data50 != @12.000000000@ then + return -1 +endi +if $data60 != @-nan@ then + return -1 +endi +print execute sql select log(c2,c1),c1,c2 from tb1; +sql_error select log(c2,c1),c1,c2 from tb1; +print execute sql select log(c2,c1),t1,ts,tbname,_C0,_c0 from tb1; +sql_error select log(c2,c1),t1,ts,tbname,_C0,_c0 from tb1; +print execute sql select log(c2,c1),floor(c3) from tb1; +sql_error select log(c2,c1),floor(c3) from tb1; +print execute sql select log(c2,c1),log(c2,c2+c3) from tb1; +sql_error select log(c2,c1),log(c2,c2+c3) from tb1; +print execute sql select log(c2,c2+c3) from tb1 where c2 is not null and c3 is not null; +sql select log(c2,c2+c3) from tb1 where c2 is not null and c3 is not null; +if $data00 != @0.000000000@ then + return -1 +endi +if $data10 != @0.666666667@ then + return -1 +endi +if $data20 != @0.465740397@ then + return -1 +endi +if $data30 != @-nan@ then + return -1 +endi +print execute sql select log(c2,c2) from tb1 order by ts desc; +sql select log(c2,c2) from tb1 order by ts desc; +if $data00 != @-nan@ then + return -1 +endi +if $data10 != @1.000000000@ then + return -1 +endi +if $data20 != @1.000000000@ then + return -1 +endi +if $data30 != @NULL@ then + return -1 +endi +if $data40 != @1.000000000@ then + return -1 +endi +if $data50 != @NULL@ then + return -1 +endi +if $data60 != @-nan@ then + return -1 +endi +print execute sql select log(c2,c2+c3) from tb1 order by ts desc; +sql select log(c2,c2+c3) from tb1 order by ts desc; +if $data00 != @-nan@ then + return -1 +endi +if $data10 != @0.465740397@ then + return -1 +endi +if $data20 != @0.666666667@ then + return -1 +endi +if $data30 != @NULL@ then + return -1 +endi +if $data40 != @NULL@ then + return -1 +endi +if $data50 != @NULL@ then + return -1 +endi +if $data60 != @0.000000000@ then + return -1 +endi +print execute sql select log(c2,c2+c3) from tb1 order by ts desc limit 3 offset 2; +sql select log(c2,c2+c3) from tb1 order by ts desc limit 3 offset 2; +if $data00 != @0.666666667@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data20 != @NULL@ then + return -1 +endi +print execute sql select log(c2,c2) from stb1; +sql select log(c2,c2) from stb1; +if $data00 != @-nan@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data20 != @1.000000000@ then + return -1 +endi +if $data30 != @NULL@ then + return -1 +endi +if $data40 != @1.000000000@ then + return -1 +endi +if $data50 != @1.000000000@ then + return -1 +endi +if $data60 != @-nan@ then + return -1 +endi +if $data70 != @-nan@ then + return -1 +endi +if $data80 != @1.000000000@ then + return -1 +endi +if $data90 != @1.000000000@ then + return -1 +endi +print execute sql select log(c2,c2) from stb1 order by ts desc; +sql select log(c2,c2) from stb1 order by ts desc; +if $data00 != @1.000000000@ then + if $data00 != @-nan@ then + return -1 + endi +endi +if $data20 != @1.000000000@ then + if $data20 != @1.000000000@ then + return -1 + endi +endi +if $data40 != @1.000000000@ then + if $data40 != @1.000000000@ then + return -1 + endi +endi +if $data60 != @1.000000000@ then + if $data60 != @NULL@ then + return -1 + endi +endi +if $data80 != @1.000000000@ then + if $data80 != @1.000000000@ then + return -1 + endi +endi +print execute sql select log(c2,c4),t1 from stb1 order by ts desc; +sql select log(c2,c4),t1 from stb1 order by ts desc; +if $data00 != @1.000000000@ then + if $data00 != @-nan@ then + return -1 + endi +endi +if $data01 != @2@ then + if $data01 != @1@ then + return -1 + endi +endi +if $data20 != @1.000000000@ then + if $data20 != @0.225441442@ then + return -1 + endi +endi +if $data21 != @2@ then + if $data21 != @1@ then + return -1 + endi +endi +if $data40 != @1.000000000@ then + if $data40 != @1.000000000@ then + return -1 + endi +endi +if $data41 != @2@ then + if $data41 != @1@ then + return -1 + endi +endi +if $data60 != @1.000000000@ then + if $data60 != @NULL@ then + return -1 + endi +endi +if $data61 != @2@ then + if $data61 != @1@ then + return -1 + endi +endi +if $data80 != @1.584962501@ then + if $data80 != @1.000000000@ then + return -1 + endi +endi +if $data81 != @2@ then + if $data81 != @1@ then + return -1 + endi +endi +print execute sql select log(c2,c3),tbname from stb1; +sql select log(c2,c3),tbname from stb1; +if $data00 != @-nan@ then + return -1 +endi +if $data01 != @tb1@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data11 != @tb1@ then + return -1 +endi +if $data20 != @NULL@ then + return -1 +endi +if $data21 != @tb1@ then + return -1 +endi +if $data30 != @NULL@ then + return -1 +endi +if $data31 != @tb1@ then + return -1 +endi +if $data40 != @1.000000000@ then + return -1 +endi +if $data41 != @tb1@ then + return -1 +endi +if $data50 != @0.465913680@ then + return -1 +endi +if $data51 != @tb1@ then + return -1 +endi +if $data60 != @-nan@ then + return -1 +endi +if $data61 != @tb1@ then + return -1 +endi +if $data70 != @-nan@ then + return -1 +endi +if $data71 != @tb2@ then + return -1 +endi +if $data80 != @1.000000000@ then + return -1 +endi +if $data81 != @tb2@ then + return -1 +endi +if $data90 != @1.000000000@ then + return -1 +endi +if $data91 != @tb2@ then + return -1 +endi +print execute sql select log(c2,c3),tbname from stb1 where t1 > 1; +sql select log(c2,c3),tbname from stb1 where t1 > 1; +if $data00 != @-nan@ then + return -1 +endi +if $data01 != @tb2@ then + return -1 +endi +if $data10 != @1.000000000@ then + return -1 +endi +if $data11 != @tb2@ then + return -1 +endi +if $data20 != @1.000000000@ then + return -1 +endi +if $data21 != @tb2@ then + return -1 +endi +if $data30 != @1.000000000@ then + return -1 +endi +if $data31 != @tb2@ then + return -1 +endi +if $data40 != @1.000000000@ then + return -1 +endi +if $data41 != @tb2@ then + return -1 +endi +if $data50 != @1.000000000@ then + return -1 +endi +if $data51 != @tb2@ then + return -1 +endi +if $data60 != @1.000000000@ then + return -1 +endi +if $data61 != @tb2@ then + return -1 +endi +print execute sql select log(c2,c8),log(c2,c9) from tbn; +sql_error select log(c2,c8),log(c2,c9) from tbn; +print execute sql select log(c2,c8),log(c2,c9) from tbn order by ts desc; +sql_error select log(c2,c8),log(c2,c9) from tbn order by ts desc; +print execute sql select log(c2,log(c2,c8)) from tbn; +sql_error select log(c2,log(c2,c8)) from tbn; +print execute sql select log(c2,a) from (select avg(c2) as a from stb1 interval(1s)); +sql_error select log(c2,a) from (select avg(c2) as a from stb1 interval(1s)); +print execute sql select log(c2,c2) from (select * from stb1); +sql select log(c2,c2) from (select * from stb1); +if $data00 != @-nan@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data20 != @1.000000000@ then + return -1 +endi +if $data30 != @NULL@ then + return -1 +endi +if $data40 != @1.000000000@ then + return -1 +endi +if $data50 != @1.000000000@ then + return -1 +endi +if $data60 != @-nan@ then + return -1 +endi +if $data70 != @-nan@ then + return -1 +endi +if $data80 != @1.000000000@ then + return -1 +endi +if $data90 != @1.000000000@ then + return -1 +endi +print execute sql select log(c2,a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)); +sql_error select log(c2,a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)); +print execute sql select log(c2,a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)) order by ts; +sql_error select log(c2,a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)) order by ts; +print execute sql select log(c2,a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)) order by ts desc; +sql_error select log(c2,a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)) order by ts desc; +print execute sql select log(c2,a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)) order by a desc; +sql_error select log(c2,a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)) order by a desc; +print execute sql select log(c2,a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)) order by a; +sql_error select log(c2,a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)) order by a; +print execute sql select log(c2,a) from (select log(c2,c2) as a from tb1); +sql_error select log(c2,a) from (select log(c2,c2) as a from tb1); +print execute sql select log(c2,tb1.c3),log(c2,tb2.c3) from tb1,tb2 where tb1.ts=tb2.ts; +sql_error select log(c2,tb1.c3),log(c2,tb2.c3) from tb1,tb2 where tb1.ts=tb2.ts; +print execute sql select log(c2,c3) from tb1 union all select log(c2,c3) from tb2; +sql select log(c2,c3) from tb1 union all select log(c2,c3) from tb2; +if $data00 != @-nan@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data20 != @NULL@ then + return -1 +endi +if $data30 != @NULL@ then + return -1 +endi +if $data40 != @1.000000000@ then + return -1 +endi +if $data50 != @0.465913680@ then + return -1 +endi +if $data60 != @-nan@ then + return -1 +endi +if $data70 != @-nan@ then + return -1 +endi +if $data80 != @1.000000000@ then + return -1 +endi +if $data90 != @1.000000000@ then + return -1 +endi diff --git a/tests/script/general/compute/math_log2.sim b/tests/script/general/compute/math_log2.sim new file mode 100644 index 0000000000000000000000000000000000000000..25722ceae1796f281edaa9ea19db99c59672e7fc --- /dev/null +++ b/tests/script/general/compute/math_log2.sim @@ -0,0 +1,126 @@ +sleep 100 +sql connect +sql use db + +print execute sql select log(c2,stb1.c4),log(c2,stba.c5) from stb1,stba where stb1.t1=stba.t1 and stb1.ts=stba.ts; +sql_error select log(c2,stb1.c4),log(c2,stba.c5) from stb1,stba where stb1.t1=stba.t1 and stb1.ts=stba.ts; +print execute sql select log(c2,c4) as a from stb1 union all select log(c2,c5) as a from stba; +sql select log(c2,c4) as a from stb1 union all select log(c2,c5) as a from stba; +if $data00 != @-nan@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data20 != @1.000000000@ then + return -1 +endi +if $data30 != @NULL@ then + return -1 +endi +if $data40 != @1.000000000@ then + return -1 +endi +if $data50 != @0.225441442@ then + return -1 +endi +if $data60 != @-nan@ then + return -1 +endi +if $data70 != @-nan@ then + return -1 +endi +if $data80 != @1.000000000@ then + return -1 +endi +if $data90 != @1.584962501@ then + return -1 +endi +print execute sql select log(c2,c2) from stba; +sql select log(c2,c2) from stba; +if $data00 != @-nan@ then + return -1 +endi +if $data10 != @1.000000000@ then + return -1 +endi +if $data20 != @1.000000000@ then + return -1 +endi +if $data30 != @1.000000000@ then + return -1 +endi +if $data40 != @1.000000000@ then + return -1 +endi +if $data50 != @1.000000000@ then + return -1 +endi +if $data60 != @1.000000000@ then + return -1 +endi +if $data70 != @1.000000000@ then + return -1 +endi +if $data80 != @1.000000000@ then + return -1 +endi +if $data90 != @-nan@ then + return -1 +endi +print execute sql select log(c2,min(c2)) from tba1; +sql_error select log(c2,min(c2)) from tba1; +print execute sql select log(c2,max(c2)) from tba1; +sql_error select log(c2,max(c2)) from tba1; +print execute sql select log(c2,count(c2)) from tba1; +sql_error select log(c2,count(c2)) from tba1; +print execute sql select log(c2,sum(c2)) from tba1; +sql_error select log(c2,sum(c2)) from tba1; +print execute sql select log(c2,avg(c2)) from tba1; +sql_error select log(c2,avg(c2)) from tba1; +print execute sql select log(c2,percentile(c2, 10)) from tba1; +sql_error select log(c2,percentile(c2, 10)) from tba1; +print execute sql select log(c2,apercentile(c2, 10)) from tba1; +sql_error select log(c2,apercentile(c2, 10)) from tba1; +print execute sql select log(c2,stddev(c2)) from tba1; +sql_error select log(c2,stddev(c2)) from tba1; +print execute sql select log(c2,spread(c2)) from tba1; +sql_error select log(c2,spread(c2)) from tba1; +print execute sql select log(c2,twa(c2)) from tba1; +sql_error select log(c2,twa(c2)) from tba1; +print execute sql select log(c2,leastsquares(c2, 1, 1)) from tba1; +sql_error select log(c2,leastsquares(c2, 1, 1)) from tba1; +print execute sql select log(c2,interp(c2)) from tba1 every(1s) +sql_error select log(c2,interp(c2)) from tba1 every(1s) +print execute sql select log(c2,interp(c2)) from stba every(1s) group by tbname; +sql_error select log(c2,interp(c2)) from stba every(1s) group by tbname; +print execute sql select log(c2,elapsed(ts)) from tba1; +sql_error select log(c2,elapsed(ts)) from tba1; +print execute sql select log(c2,rate(c2)) from tba1; +sql_error select log(c2,rate(c2)) from tba1; +print execute sql select log(c2,irate(c2)) from tba1; +sql_error select log(c2,irate(c2)) from tba1; +print execute sql select log(c2,first(c2)) from tba1; +sql_error select log(c2,first(c2)) from tba1; +print execute sql select log(c2,last(c2)) from tba1; +sql_error select log(c2,last(c2)) from tba1; +print execute sql select log(c2,last_row(c2)) from tba1; +sql_error select log(c2,last_row(c2)) from tba1; +print execute sql select log(c2,top(c2, 1)) from tba1; +sql_error select log(c2,top(c2, 1)) from tba1; +print execute sql select log(c2,bottom(c2, 1)) from tba1; +sql_error select log(c2,bottom(c2, 1)) from tba1; +print execute sql select log(c2,leastsquares(c2, 1, 1)) from tba1; +sql_error select log(c2,leastsquares(c2, 1, 1)) from tba1; +print execute sql select log(c2,derivative(c2, 1s, 0)) from tba1; +sql_error select log(c2,derivative(c2, 1s, 0)) from tba1; +print execute sql select log(c2,diff(c2)) from tba1; +sql_error select log(c2,diff(c2)) from tba1; +print execute sql select log(c2,csum(c2)) from tba1; +sql_error select log(c2,csum(c2)) from tba1; +print execute sql select log(c2,mavg(c2,2)) from tba1; +sql_error select log(c2,mavg(c2,2)) from tba1; +print execute sql select log(c2,sample(c2,2)) from tba1; +sql_error select log(c2,sample(c2,2)) from tba1; +print execute sql select log(c2,_block_dist()) from tba1; +sql_error select log(c2,_block_dist()) from tba1; diff --git a/tests/script/general/compute/math_pow.sim b/tests/script/general/compute/math_pow.sim new file mode 100644 index 0000000000000000000000000000000000000000..d3725e650b5840d2044f60f2b890223039c73fb1 --- /dev/null +++ b/tests/script/general/compute/math_pow.sim @@ -0,0 +1,818 @@ +sleep 100 +sql connect +sql use db + +print execute sql select pow(c2,*) from tb1; +sql_error select pow(c2,*) from tb1; +print execute sql select pow(c2,*) from tb1; +sql_error select pow(c2,*) from tb1; +print execute sql select pow(c2,*) from tb1; +sql_error select pow(c2,*) from tb1; +print execute sql select pow(c2,*) from tb1; +sql_error select pow(c2,*) from tb1; +print execute sql select pow(c2,*) as a from tb1; +sql_error select pow(c2,*) as a from tb1; +print execute sql select pow(c2,*) + 1 as a from tb1; +sql_error select pow(c2,*) + 1 as a from tb1; +print execute sql select pow(c2,tb1.*) + 1 as a from tb1; +sql_error select pow(c2,tb1.*) + 1 as a from tb1; +print execute sql select pow(c2,*) from tb1; +sql_error select pow(c2,*) from tb1; +print execute sql select pow(c2,c1) from tb1; +sql_error select pow(c2,c1) from tb1; +print execute sql select pow(c2,c1) from tb1; +sql_error select pow(c2,c1) from tb1; +print execute sql select pow(c2,c1 + c2) from tb1; +sql_error select pow(c2,c1 + c2) from tb1; +print execute sql select pow(c2,13) from tb1; +sql select pow(c2,13) from tb1; +if $data00 != @1.000000000@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data20 != @8192.000000000@ then + return -1 +endi +if $data30 != @NULL@ then + return -1 +endi +if $data40 != @67108864.000000000@ then + return -1 +endi +if $data50 != @2235879388560037013354446848.000000000@ then + return -1 +endi +if $data60 != @-2235879388560037013354446848.000000000@ then + return -1 +endi +print execute sql select pow(c2,c1) from tb1; +sql_error select pow(c2,c1) from tb1; +print execute sql select pow(c2,c2) from tb1; +sql select pow(c2,c2) from tb1; +if $data00 != @1.000000000@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data20 != @4.000000000@ then + return -1 +endi +if $data30 != @NULL@ then + return -1 +endi +if $data40 != @256.000000000@ then + return -1 +endi +if $data50 != @1524307411995722675302034438441039929638133977529255166488930956750631981496706568536830801887788243768717590100078636207586147400582763177366354597171395424352865739982333218252608952069997640848048552956054564019622410252548018541775390307932677684494157475792027648.000000000@ then + return -1 +endi +if $data60 != @-0.000000000@ then + return -1 +endi +print execute sql select pow(c2,c3) from tb1; +sql select pow(c2,c3) from tb1; +if $data00 != @1.000000000@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data20 != @NULL@ then + return -1 +endi +if $data30 != @NULL@ then + return -1 +endi +if $data40 != @256.000000000@ then + return -1 +endi +if $data50 != @inf@ then + return -1 +endi +if $data60 != @-0.000000000@ then + return -1 +endi +print execute sql select pow(c2,c4) from tb1; +sql select pow(c2,c4) from tb1; +if $data00 != @1.000000000@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data20 != @4.000000000@ then + return -1 +endi +if $data30 != @NULL@ then + return -1 +endi +if $data40 != @256.000000000@ then + return -1 +endi +if $data50 != @inf@ then + return -1 +endi +if $data60 != @-0.000000000@ then + return -1 +endi +print execute sql select pow(c2,c5) from tb1; +sql select pow(c2,c5) from tb1; +if $data00 != @1.000000000@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data20 != @NULL@ then + return -1 +endi +if $data30 != @NULL@ then + return -1 +endi +if $data40 != @256.000000000@ then + return -1 +endi +if $data50 != @inf@ then + return -1 +endi +if $data60 != @0.000000000@ then + return -1 +endi +print execute sql select pow(c2,c6) from tb1; +sql select pow(c2,c6) from tb1; +if $data00 != @1.000000000@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data20 != @4.000000000@ then + return -1 +endi +if $data30 != @NULL@ then + return -1 +endi +if $data40 != @256.000000000@ then + return -1 +endi +if $data50 != @inf@ then + return -1 +endi +if $data60 != @0.000000000@ then + return -1 +endi +print execute sql select pow(c2,c7) from tb1; +sql select pow(c2,c7) from tb1; +if $data00 != @1.000000000@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data20 != @NULL@ then + return -1 +endi +if $data30 != @NULL@ then + return -1 +endi +if $data40 != @256.000000000@ then + return -1 +endi +if $data50 != @inf@ then + return -1 +endi +if $data60 != @0.000000000@ then + return -1 +endi +print execute sql select pow(c2,c8) from tb1; +sql_error select pow(c2,c8) from tb1; +print execute sql select pow(c2,c9) from tb1; +sql_error select pow(c2,c9) from tb1; +print execute sql select pow(c2,c10) from tb1; +sql select pow(c2,c10) from tb1; +if $data00 != @1.000000000@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data20 != @4.000000000@ then + return -1 +endi +if $data30 != @NULL@ then + return -1 +endi +if $data40 != @256.000000000@ then + return -1 +endi +if $data50 != @inf@ then + return -1 +endi +if $data60 != @1.000000000@ then + return -1 +endi +print execute sql select pow(c2,c11) from tb1; +sql select pow(c2,c11) from tb1; +if $data00 != @1.000000000@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data20 != @NULL@ then + return -1 +endi +if $data30 != @NULL@ then + return -1 +endi +if $data40 != @256.000000000@ then + return -1 +endi +if $data50 != @inf@ then + return -1 +endi +if $data60 != @1.000000000@ then + return -1 +endi +print execute sql select pow(c2,c12) from tb1; +sql select pow(c2,c12) from tb1; +if $data00 != @1.000000000@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data20 != @4.000000000@ then + return -1 +endi +if $data30 != @NULL@ then + return -1 +endi +if $data40 != @256.000000000@ then + return -1 +endi +if $data50 != @inf@ then + return -1 +endi +if $data60 != @1.000000000@ then + return -1 +endi +print execute sql select pow(c2,c13) from tb1; +sql select pow(c2,c13) from tb1; +if $data00 != @1.000000000@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data20 != @NULL@ then + return -1 +endi +if $data30 != @NULL@ then + return -1 +endi +if $data40 != @256.000000000@ then + return -1 +endi +if $data50 != @inf@ then + return -1 +endi +if $data60 != @1.000000000@ then + return -1 +endi +print execute sql select pow(c2,12345678900000000000000000) from tb1; +sql_error select pow(c2,12345678900000000000000000) from tb1; +print execute sql select distinct pow(c2,123) from tb1; +sql_error select distinct pow(c2,123) from tb1; +print execute sql select pow(c2,t1) from stb1; +sql_error select pow(c2,t1) from stb1; +print execute sql select pow(c2,c1),avg(c3) from tb1; +sql_error select pow(c2,c1),avg(c3) from tb1; +print execute sql select pow(c2,c1),top(c3,1) from tb1; +sql_error select pow(c2,c1),top(c3,1) from tb1; +print execute sql select pow(c2,c2+c3) from tb1 session(ts, 1s); +sql_error select pow(c2,c2+c3) from tb1 session(ts, 1s); +print execute sql select pow(c2,c2+c3) from tb1 STATE_WINDOW(c1); +sql_error select pow(c2,c2+c3) from tb1 STATE_WINDOW(c1); +print execute sql select pow(c2,c2+c3) from tb1 interval(1s) sliding(1s) fill(NULL); +sql_error select pow(c2,c2+c3) from tb1 interval(1s) sliding(1s) fill(NULL); +print execute sql select pow(c2,c2+c3) from stb1 group by t1; +sql_error select pow(c2,c2+c3) from stb1 group by t1; +print execute sql select pow(c2,c2+c3) from stb1 group by ts; +sql_error select pow(c2,c2+c3) from stb1 group by ts; +print execute sql select pow(c2,c2+c3) from stb1 group by c1; +sql_error select pow(c2,c2+c3) from stb1 group by c1; +print execute sql select pow(c2,c2+c3) from stb1 group by tbname; +sql_error select pow(c2,c2+c3) from stb1 group by tbname; +print execute sql select pow(c2,c2+c3) from tb1 order by c2; +sql_error select pow(c2,c2+c3) from tb1 order by c2; +print execute sql select pow(c2,c8),pow(c2,c9) from tbn; +sql_error select pow(c2,c8),pow(c2,c9) from tbn; +print execute sql select pow(c2,ts) from (select avg(c2) as a from stb1 interval(1s)); +sql_error select pow(c2,ts) from (select avg(c2) as a from stb1 interval(1s)); +print execute sql select pow(c2,a) from (select pow(c2,c2) as a from tb1); +sql_error select pow(c2,a) from (select pow(c2,c2) as a from tb1); +print execute sql select pow(c2,"abc") from tb1; +sql_error select pow(c2,"abc") from tb1; +print execute sql select pow(c2,c2 + c3) from tb1; +sql select pow(c2,c2 + c3) from tb1; +if $data00 != @1.000000000@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data20 != @NULL@ then + return -1 +endi +if $data30 != @NULL@ then + return -1 +endi +if $data40 != @65536.000000000@ then + return -1 +endi +if $data50 != @inf@ then + return -1 +endi +if $data60 != @0.000000000@ then + return -1 +endi +print execute sql select pow(c2,(c2 + c3)) from tb1; +sql select pow(c2,(c2 + c3)) from tb1; +if $data00 != @1.000000000@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data20 != @NULL@ then + return -1 +endi +if $data30 != @NULL@ then + return -1 +endi +if $data40 != @65536.000000000@ then + return -1 +endi +if $data50 != @inf@ then + return -1 +endi +if $data60 != @0.000000000@ then + return -1 +endi +print execute sql select pow(c2,(c2 * c3)+c4-6) from tb1; +sql select pow(c2,(c2 * c3)+c4-6) from tb1; +if $data00 != @1.000000000@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data20 != @NULL@ then + return -1 +endi +if $data30 != @NULL@ then + return -1 +endi +if $data40 != @268435456.000000000@ then + return -1 +endi +if $data50 != @inf@ then + return -1 +endi +if $data60 != @0.000000000@ then + return -1 +endi +print execute sql select pow(c2,11)+c2 from tb1; +sql select pow(c2,11)+c2 from tb1; +if $data00 != @2.000000000@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data20 != @2050.000000000@ then + return -1 +endi +if $data30 != @NULL@ then + return -1 +endi +if $data40 != @4194308.000000000@ then + return -1 +endi +if $data50 != @138624799340320985710592.000000000@ then + return -1 +endi +if $data60 != @-138624799340320985710592.000000000@ then + return -1 +endi +print execute sql select pow(c2,c1)+c2 from tb1; +sql_error select pow(c2,c1)+c2 from tb1; +print execute sql select pow(c2,c2)+11 from tb1; +sql select pow(c2,c2)+11 from tb1; +if $data00 != @12.000000000@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data20 != @15.000000000@ then + return -1 +endi +if $data30 != @NULL@ then + return -1 +endi +if $data40 != @267.000000000@ then + return -1 +endi +if $data50 != @1524307411995722675302034438441039929638133977529255166488930956750631981496706568536830801887788243768717590100078636207586147400582763177366354597171395424352865739982333218252608952069997640848048552956054564019622410252548018541775390307932677684494157475792027648.000000000@ then + return -1 +endi +if $data60 != @11.000000000@ then + return -1 +endi +print execute sql select pow(c2,c1),c1,c2 from tb1; +sql_error select pow(c2,c1),c1,c2 from tb1; +print execute sql select pow(c2,c1),t1,ts,tbname,_C0,_c0 from tb1; +sql_error select pow(c2,c1),t1,ts,tbname,_C0,_c0 from tb1; +print execute sql select pow(c2,c1),floor(c3) from tb1; +sql_error select pow(c2,c1),floor(c3) from tb1; +print execute sql select pow(c2,c1),pow(c2,c2+c3) from tb1; +sql_error select pow(c2,c1),pow(c2,c2+c3) from tb1; +print execute sql select pow(c2,c2+c3) from tb1 where c2 is not null and c3 is not null; +sql select pow(c2,c2+c3) from tb1 where c2 is not null and c3 is not null; +if $data00 != @1.000000000@ then + return -1 +endi +if $data10 != @65536.000000000@ then + return -1 +endi +if $data20 != @inf@ then + return -1 +endi +if $data30 != @0.000000000@ then + return -1 +endi +print execute sql select pow(c2,c2) from tb1 order by ts desc; +sql select pow(c2,c2) from tb1 order by ts desc; +if $data00 != @-0.000000000@ then + return -1 +endi +if $data10 != @1524307411995722675302034438441039929638133977529255166488930956750631981496706568536830801887788243768717590100078636207586147400582763177366354597171395424352865739982333218252608952069997640848048552956054564019622410252548018541775390307932677684494157475792027648.000000000@ then + return -1 +endi +if $data20 != @256.000000000@ then + return -1 +endi +if $data30 != @NULL@ then + return -1 +endi +if $data40 != @4.000000000@ then + return -1 +endi +if $data50 != @NULL@ then + return -1 +endi +if $data60 != @1.000000000@ then + return -1 +endi +print execute sql select pow(c2,c2+c3) from tb1 order by ts desc; +sql select pow(c2,c2+c3) from tb1 order by ts desc; +if $data00 != @0.000000000@ then + return -1 +endi +if $data10 != @inf@ then + return -1 +endi +if $data20 != @65536.000000000@ then + return -1 +endi +if $data30 != @NULL@ then + return -1 +endi +if $data40 != @NULL@ then + return -1 +endi +if $data50 != @NULL@ then + return -1 +endi +if $data60 != @1.000000000@ then + return -1 +endi +print execute sql select pow(c2,c2+c3) from tb1 order by ts desc limit 3 offset 2; +sql select pow(c2,c2+c3) from tb1 order by ts desc limit 3 offset 2; +if $data00 != @65536.000000000@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data20 != @NULL@ then + return -1 +endi +print execute sql select pow(c2,c2) from stb1; +sql select pow(c2,c2) from stb1; +if $data00 != @1.000000000@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data20 != @4.000000000@ then + return -1 +endi +if $data30 != @NULL@ then + return -1 +endi +if $data40 != @256.000000000@ then + return -1 +endi +if $data50 != @1524307411995722675302034438441039929638133977529255166488930956750631981496706568536830801887788243768717590100078636207586147400582763177366354597171395424352865739982333218252608952069997640848048552956054564019622410252548018541775390307932677684494157475792027648.000000000@ then + return -1 +endi +if $data60 != @-0.000000000@ then + return -1 +endi +if $data70 != @1.000000000@ then + return -1 +endi +if $data80 != @4.000000000@ then + return -1 +endi +if $data90 != @27.000000000@ then + return -1 +endi +print execute sql select pow(c2,c2) from stb1 order by ts desc; +sql select pow(c2,c2) from stb1 order by ts desc; +if $data00 != @823543.000000000@ then + if $data00 != @-0.000000000@ then + return -1 + endi +endi +if $data20 != @46656.000000000@ then + if $data20 != @1524307411995722675302034438441039929638133977529255166488930956750631981496706568536830801887788243768717590100078636207586147400582763177366354597171395424352865739982333218252608952069997640848048552956054564019622410252548018541775390307932677684494157475792027648.000000000@ then + return -1 + endi +endi +if $data40 != @3125.000000000@ then + if $data40 != @256.000000000@ then + return -1 + endi +endi +if $data60 != @256.000000000@ then + if $data60 != @NULL@ then + return -1 + endi +endi +if $data80 != @27.000000000@ then + if $data80 != @4.000000000@ then + return -1 + endi +endi +print execute sql select pow(c2,c4),t1 from stb1 order by ts desc; +sql select pow(c2,c4),t1 from stb1 order by ts desc; +if $data00 != @823543.000000000@ then + if $data00 != @-0.000000000@ then + return -1 + endi +endi +if $data01 != @2@ then + if $data01 != @1@ then + return -1 + endi +endi +if $data20 != @46656.000000000@ then + if $data20 != @inf@ then + return -1 + endi +endi +if $data21 != @2@ then + if $data21 != @1@ then + return -1 + endi +endi +if $data40 != @3125.000000000@ then + if $data40 != @256.000000000@ then + return -1 + endi +endi +if $data41 != @2@ then + if $data41 != @1@ then + return -1 + endi +endi +if $data60 != @256.000000000@ then + if $data60 != @NULL@ then + return -1 + endi +endi +if $data61 != @2@ then + if $data61 != @1@ then + return -1 + endi +endi +if $data80 != @9.000000000@ then + if $data80 != @4.000000000@ then + return -1 + endi +endi +if $data81 != @2@ then + if $data81 != @1@ then + return -1 + endi +endi +print execute sql select pow(c2,c3),tbname from stb1; +sql select pow(c2,c3),tbname from stb1; +if $data00 != @1.000000000@ then + return -1 +endi +if $data01 != @tb1@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data11 != @tb1@ then + return -1 +endi +if $data20 != @NULL@ then + return -1 +endi +if $data21 != @tb1@ then + return -1 +endi +if $data30 != @NULL@ then + return -1 +endi +if $data31 != @tb1@ then + return -1 +endi +if $data40 != @256.000000000@ then + return -1 +endi +if $data41 != @tb1@ then + return -1 +endi +if $data50 != @inf@ then + return -1 +endi +if $data51 != @tb1@ then + return -1 +endi +if $data60 != @-0.000000000@ then + return -1 +endi +if $data61 != @tb1@ then + return -1 +endi +if $data70 != @1.000000000@ then + return -1 +endi +if $data71 != @tb2@ then + return -1 +endi +if $data80 != @4.000000000@ then + return -1 +endi +if $data81 != @tb2@ then + return -1 +endi +if $data90 != @27.000000000@ then + return -1 +endi +if $data91 != @tb2@ then + return -1 +endi +print execute sql select pow(c2,c3),tbname from stb1 where t1 > 1; +sql select pow(c2,c3),tbname from stb1 where t1 > 1; +if $data00 != @1.000000000@ then + return -1 +endi +if $data01 != @tb2@ then + return -1 +endi +if $data10 != @4.000000000@ then + return -1 +endi +if $data11 != @tb2@ then + return -1 +endi +if $data20 != @27.000000000@ then + return -1 +endi +if $data21 != @tb2@ then + return -1 +endi +if $data30 != @256.000000000@ then + return -1 +endi +if $data31 != @tb2@ then + return -1 +endi +if $data40 != @3125.000000000@ then + return -1 +endi +if $data41 != @tb2@ then + return -1 +endi +if $data50 != @46656.000000000@ then + return -1 +endi +if $data51 != @tb2@ then + return -1 +endi +if $data60 != @823543.000000000@ then + return -1 +endi +if $data61 != @tb2@ then + return -1 +endi +print execute sql select pow(c2,c8),pow(c2,c9) from tbn; +sql_error select pow(c2,c8),pow(c2,c9) from tbn; +print execute sql select pow(c2,c8),pow(c2,c9) from tbn order by ts desc; +sql_error select pow(c2,c8),pow(c2,c9) from tbn order by ts desc; +print execute sql select pow(c2,pow(c2,c8)) from tbn; +sql_error select pow(c2,pow(c2,c8)) from tbn; +print execute sql select pow(c2,a) from (select avg(c2) as a from stb1 interval(1s)); +sql_error select pow(c2,a) from (select avg(c2) as a from stb1 interval(1s)); +print execute sql select pow(c2,c2) from (select * from stb1); +sql select pow(c2,c2) from (select * from stb1); +if $data00 != @1.000000000@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data20 != @4.000000000@ then + return -1 +endi +if $data30 != @NULL@ then + return -1 +endi +if $data40 != @256.000000000@ then + return -1 +endi +if $data50 != @1524307411995722675302034438441039929638133977529255166488930956750631981496706568536830801887788243768717590100078636207586147400582763177366354597171395424352865739982333218252608952069997640848048552956054564019622410252548018541775390307932677684494157475792027648.000000000@ then + return -1 +endi +if $data60 != @-0.000000000@ then + return -1 +endi +if $data70 != @1.000000000@ then + return -1 +endi +if $data80 != @4.000000000@ then + return -1 +endi +if $data90 != @27.000000000@ then + return -1 +endi +print execute sql select pow(c2,a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)); +sql_error select pow(c2,a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)); +print execute sql select pow(c2,a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)) order by ts; +sql_error select pow(c2,a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)) order by ts; +print execute sql select pow(c2,a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)) order by ts desc; +sql_error select pow(c2,a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)) order by ts desc; +print execute sql select pow(c2,a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)) order by a desc; +sql_error select pow(c2,a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)) order by a desc; +print execute sql select pow(c2,a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)) order by a; +sql_error select pow(c2,a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)) order by a; +print execute sql select pow(c2,a) from (select pow(c2,c2) as a from tb1); +sql_error select pow(c2,a) from (select pow(c2,c2) as a from tb1); +print execute sql select pow(c2,tb1.c3),pow(c2,tb2.c3) from tb1,tb2 where tb1.ts=tb2.ts; +sql_error select pow(c2,tb1.c3),pow(c2,tb2.c3) from tb1,tb2 where tb1.ts=tb2.ts; +print execute sql select pow(c2,c3) from tb1 union all select pow(c2,c3) from tb2; +sql select pow(c2,c3) from tb1 union all select pow(c2,c3) from tb2; +if $data00 != @1.000000000@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data20 != @NULL@ then + return -1 +endi +if $data30 != @NULL@ then + return -1 +endi +if $data40 != @256.000000000@ then + return -1 +endi +if $data50 != @inf@ then + return -1 +endi +if $data60 != @-0.000000000@ then + return -1 +endi +if $data70 != @1.000000000@ then + return -1 +endi +if $data80 != @4.000000000@ then + return -1 +endi +if $data90 != @27.000000000@ then + return -1 +endi diff --git a/tests/script/general/compute/math_pow2.sim b/tests/script/general/compute/math_pow2.sim new file mode 100644 index 0000000000000000000000000000000000000000..416f989f1288ea1f21ee792b63fb75ee46510d2b --- /dev/null +++ b/tests/script/general/compute/math_pow2.sim @@ -0,0 +1,126 @@ +sleep 100 +sql connect +sql use db + +print execute sql select pow(c2,stb1.c4),pow(c2,stba.c5) from stb1,stba where stb1.t1=stba.t1 and stb1.ts=stba.ts; +sql_error select pow(c2,stb1.c4),pow(c2,stba.c5) from stb1,stba where stb1.t1=stba.t1 and stb1.ts=stba.ts; +print execute sql select pow(c2,c4) as a from stb1 union all select pow(c2,c5) as a from stba; +sql select pow(c2,c4) as a from stb1 union all select pow(c2,c5) as a from stba; +if $data00 != @1.000000000@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data20 != @4.000000000@ then + return -1 +endi +if $data30 != @NULL@ then + return -1 +endi +if $data40 != @256.000000000@ then + return -1 +endi +if $data50 != @inf@ then + return -1 +endi +if $data60 != @-0.000000000@ then + return -1 +endi +if $data70 != @1.000000000@ then + return -1 +endi +if $data80 != @4.000000000@ then + return -1 +endi +if $data90 != @9.000000000@ then + return -1 +endi +print execute sql select pow(c2,c2) from stba; +sql select pow(c2,c2) from stba; +if $data00 != @1.000000000@ then + return -1 +endi +if $data10 != @4.000000000@ then + return -1 +endi +if $data20 != @27.000000000@ then + return -1 +endi +if $data30 != @256.000000000@ then + return -1 +endi +if $data40 != @3125.000000000@ then + return -1 +endi +if $data50 != @46656.000000000@ then + return -1 +endi +if $data60 != @823543.000000000@ then + return -1 +endi +if $data70 != @16777216.000000000@ then + return -1 +endi +if $data80 != @387420489.000000000@ then + return -1 +endi +if $data90 != @1.000000000@ then + return -1 +endi +print execute sql select pow(c2,min(c2)) from tba1; +sql_error select pow(c2,min(c2)) from tba1; +print execute sql select pow(c2,max(c2)) from tba1; +sql_error select pow(c2,max(c2)) from tba1; +print execute sql select pow(c2,count(c2)) from tba1; +sql_error select pow(c2,count(c2)) from tba1; +print execute sql select pow(c2,sum(c2)) from tba1; +sql_error select pow(c2,sum(c2)) from tba1; +print execute sql select pow(c2,avg(c2)) from tba1; +sql_error select pow(c2,avg(c2)) from tba1; +print execute sql select pow(c2,percentile(c2, 10)) from tba1; +sql_error select pow(c2,percentile(c2, 10)) from tba1; +print execute sql select pow(c2,apercentile(c2, 10)) from tba1; +sql_error select pow(c2,apercentile(c2, 10)) from tba1; +print execute sql select pow(c2,stddev(c2)) from tba1; +sql_error select pow(c2,stddev(c2)) from tba1; +print execute sql select pow(c2,spread(c2)) from tba1; +sql_error select pow(c2,spread(c2)) from tba1; +print execute sql select pow(c2,twa(c2)) from tba1; +sql_error select pow(c2,twa(c2)) from tba1; +print execute sql select pow(c2,leastsquares(c2, 1, 1)) from tba1; +sql_error select pow(c2,leastsquares(c2, 1, 1)) from tba1; +print execute sql select pow(c2,interp(c2)) from tba1 every(1s) +sql_error select pow(c2,interp(c2)) from tba1 every(1s) +print execute sql select pow(c2,interp(c2)) from stba every(1s) group by tbname; +sql_error select pow(c2,interp(c2)) from stba every(1s) group by tbname; +print execute sql select pow(c2,elapsed(ts)) from tba1; +sql_error select pow(c2,elapsed(ts)) from tba1; +print execute sql select pow(c2,rate(c2)) from tba1; +sql_error select pow(c2,rate(c2)) from tba1; +print execute sql select pow(c2,irate(c2)) from tba1; +sql_error select pow(c2,irate(c2)) from tba1; +print execute sql select pow(c2,first(c2)) from tba1; +sql_error select pow(c2,first(c2)) from tba1; +print execute sql select pow(c2,last(c2)) from tba1; +sql_error select pow(c2,last(c2)) from tba1; +print execute sql select pow(c2,last_row(c2)) from tba1; +sql_error select pow(c2,last_row(c2)) from tba1; +print execute sql select pow(c2,top(c2, 1)) from tba1; +sql_error select pow(c2,top(c2, 1)) from tba1; +print execute sql select pow(c2,bottom(c2, 1)) from tba1; +sql_error select pow(c2,bottom(c2, 1)) from tba1; +print execute sql select pow(c2,leastsquares(c2, 1, 1)) from tba1; +sql_error select pow(c2,leastsquares(c2, 1, 1)) from tba1; +print execute sql select pow(c2,derivative(c2, 1s, 0)) from tba1; +sql_error select pow(c2,derivative(c2, 1s, 0)) from tba1; +print execute sql select pow(c2,diff(c2)) from tba1; +sql_error select pow(c2,diff(c2)) from tba1; +print execute sql select pow(c2,csum(c2)) from tba1; +sql_error select pow(c2,csum(c2)) from tba1; +print execute sql select pow(c2,mavg(c2,2)) from tba1; +sql_error select pow(c2,mavg(c2,2)) from tba1; +print execute sql select pow(c2,sample(c2,2)) from tba1; +sql_error select pow(c2,sample(c2,2)) from tba1; +print execute sql select pow(c2,_block_dist()) from tba1; +sql_error select pow(c2,_block_dist()) from tba1; diff --git a/tests/script/general/compute/math_sin.sim b/tests/script/general/compute/math_sin.sim new file mode 100644 index 0000000000000000000000000000000000000000..d014324fa110a2d2267f15a0c26cab4e15c6feb1 --- /dev/null +++ b/tests/script/general/compute/math_sin.sim @@ -0,0 +1,1073 @@ +sleep 100 +sql connect +sql use db + +print execute sql select sin(*) from tb1; +sql_error select sin(*) from tb1; +print execute sql select sin(*) from tb1; +sql_error select sin(*) from tb1; +print execute sql select sin(*) from tb1; +sql_error select sin(*) from tb1; +print execute sql select sin(*) from tb1; +sql_error select sin(*) from tb1; +print execute sql select sin(*) as a from tb1; +sql_error select sin(*) as a from tb1; +print execute sql select sin(*) + 1 as a from tb1; +sql_error select sin(*) + 1 as a from tb1; +print execute sql select sin(tb1.*) + 1 as a from tb1; +sql_error select sin(tb1.*) + 1 as a from tb1; +print execute sql select sin(*) from tb1; +sql_error select sin(*) from tb1; +print execute sql select sin(c1) from tb1; +sql_error select sin(c1) from tb1; +print execute sql select sin(c1) from tb1; +sql_error select sin(c1) from tb1; +print execute sql select sin(c1 + c2) from tb1; +sql_error select sin(c1 + c2) from tb1; +print execute sql select sin(13) from tb1; +sql select sin(13) from tb1; +if $data00 != @0.420167037@ then + return -1 +endi +if $data10 != @0.420167037@ then + return -1 +endi +if $data20 != @0.420167037@ then + return -1 +endi +if $data30 != @0.420167037@ then + return -1 +endi +if $data40 != @0.420167037@ then + return -1 +endi +if $data50 != @0.420167037@ then + return -1 +endi +if $data60 != @0.420167037@ then + return -1 +endi +print execute sql select sin(c1) from tb1; +sql_error select sin(c1) from tb1; +print execute sql select sin(c2) from tb1; +sql select sin(c2) from tb1; +if $data00 != @0.841470985@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data20 != @0.909297427@ then + return -1 +endi +if $data30 != @NULL@ then + return -1 +endi +if $data40 != @-0.756802495@ then + return -1 +endi +if $data50 != @0.972630067@ then + return -1 +endi +if $data60 != @-0.972630067@ then + return -1 +endi +print execute sql select sin(c3) from tb1; +sql select sin(c3) from tb1; +if $data00 != @0.841470985@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data20 != @NULL@ then + return -1 +endi +if $data30 != @0.141120008@ then + return -1 +endi +if $data40 != @-0.756802495@ then + return -1 +endi +if $data50 != @0.187506554@ then + return -1 +endi +if $data60 != @-0.187506554@ then + return -1 +endi +print execute sql select sin(c4) from tb1; +sql select sin(c4) from tb1; +if $data00 != @0.841470985@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data20 != @0.909297427@ then + return -1 +endi +if $data30 != @NULL@ then + return -1 +endi +if $data40 != @-0.756802495@ then + return -1 +endi +if $data50 != @-0.724916555@ then + return -1 +endi +if $data60 != @0.724916555@ then + return -1 +endi +print execute sql select sin(c5) from tb1; +sql select sin(c5) from tb1; +if $data00 != @0.841470985@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data20 != @NULL@ then + return -1 +endi +if $data30 != @0.141120008@ then + return -1 +endi +if $data40 != @-0.756802495@ then + return -1 +endi +if $data50 != @0.999930377@ then + return -1 +endi +if $data60 != @-0.999930377@ then + return -1 +endi +print execute sql select sin(c6) from tb1; +sql select sin(c6) from tb1; +if $data00 != @0.841470985@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data20 != @0.909297427@ then + return -1 +endi +if $data30 != @NULL@ then + return -1 +endi +if $data40 != @-0.756802495@ then + return -1 +endi +if $data50 != @-0.521876523@ then + return -1 +endi +if $data60 != @0.521876523@ then + return -1 +endi +print execute sql select sin(c7) from tb1; +sql select sin(c7) from tb1; +if $data00 != @0.841470985@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data20 != @NULL@ then + return -1 +endi +if $data30 != @0.141120008@ then + return -1 +endi +if $data40 != @-0.756802495@ then + return -1 +endi +if $data50 != @0.872829297@ then + return -1 +endi +if $data60 != @-0.872829297@ then + return -1 +endi +print execute sql select sin(c8) from tb1; +sql_error select sin(c8) from tb1; +print execute sql select sin(c9) from tb1; +sql_error select sin(c9) from tb1; +print execute sql select sin(c10) from tb1; +sql select sin(c10) from tb1; +if $data00 != @0.841470985@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data20 != @0.909297427@ then + return -1 +endi +if $data30 != @NULL@ then + return -1 +endi +if $data40 != @-0.756802495@ then + return -1 +endi +if $data50 != @0.451998898@ then + return -1 +endi +if $data60 != @0.000000000@ then + return -1 +endi +print execute sql select sin(c11) from tb1; +sql select sin(c11) from tb1; +if $data00 != @0.841470985@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data20 != @NULL@ then + return -1 +endi +if $data30 != @0.141120008@ then + return -1 +endi +if $data40 != @-0.756802495@ then + return -1 +endi +if $data50 != @0.368361632@ then + return -1 +endi +if $data60 != @0.000000000@ then + return -1 +endi +print execute sql select sin(c12) from tb1; +sql select sin(c12) from tb1; +if $data00 != @0.841470985@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data20 != @0.909297427@ then + return -1 +endi +if $data30 != @NULL@ then + return -1 +endi +if $data40 != @-0.756802495@ then + return -1 +endi +if $data50 != @0.998698243@ then + return -1 +endi +if $data60 != @0.000000000@ then + return -1 +endi +print execute sql select sin(c13) from tb1; +sql select sin(c13) from tb1; +if $data00 != @0.841470985@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data20 != @NULL@ then + return -1 +endi +if $data30 != @0.141120008@ then + return -1 +endi +if $data40 != @-0.756802495@ then + return -1 +endi +if $data50 != @0.999930377@ then + return -1 +endi +if $data60 != @0.000000000@ then + return -1 +endi +print execute sql select sin(12345678900000000000000000) from tb1; +sql_error select sin(12345678900000000000000000) from tb1; +print execute sql select distinct sin(123) from tb1; +sql_error select distinct sin(123) from tb1; +print execute sql select sin(t1) from stb1; +sql_error select sin(t1) from stb1; +print execute sql select sin(c1),avg(c3) from tb1; +sql_error select sin(c1),avg(c3) from tb1; +print execute sql select sin(c1),top(c3,1) from tb1; +sql_error select sin(c1),top(c3,1) from tb1; +print execute sql select sin(c2+c3) from tb1 session(ts, 1s); +sql_error select sin(c2+c3) from tb1 session(ts, 1s); +print execute sql select sin(c2+c3) from tb1 STATE_WINDOW(c1); +sql_error select sin(c2+c3) from tb1 STATE_WINDOW(c1); +print execute sql select sin(c2+c3) from tb1 interval(1s) sliding(1s) fill(NULL); +sql_error select sin(c2+c3) from tb1 interval(1s) sliding(1s) fill(NULL); +print execute sql select sin(c2+c3) from stb1 group by t1; +sql_error select sin(c2+c3) from stb1 group by t1; +print execute sql select sin(c2+c3) from stb1 group by ts; +sql_error select sin(c2+c3) from stb1 group by ts; +print execute sql select sin(c2+c3) from stb1 group by c1; +sql_error select sin(c2+c3) from stb1 group by c1; +print execute sql select sin(c2+c3) from stb1 group by tbname; +sql_error select sin(c2+c3) from stb1 group by tbname; +print execute sql select sin(c2+c3) from tb1 order by c2; +sql_error select sin(c2+c3) from tb1 order by c2; +print execute sql select sin(c8),sin(c9) from tbn; +sql_error select sin(c8),sin(c9) from tbn; +print execute sql select sin(ts) from (select avg(c2) as a from stb1 interval(1s)); +sql_error select sin(ts) from (select avg(c2) as a from stb1 interval(1s)); +print execute sql select sin(a) from (select sin(c2) as a from tb1); +sql select sin(a) from (select sin(c2) as a from tb1); +if $data00 != @0.745624142@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data20 != @0.789072344@ then + return -1 +endi +if $data30 != @NULL@ then + return -1 +endi +if $data40 != @-0.686600261@ then + return -1 +endi +if $data50 != @0.826369634@ then + return -1 +endi +if $data60 != @-0.826369634@ then + return -1 +endi +print execute sql select sin("abc") from tb1; +sql_error select sin("abc") from tb1; +print execute sql select sin(c2 + c3) from tb1; +sql select sin(c2 + c3) from tb1; +if $data00 != @0.909297427@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data20 != @NULL@ then + return -1 +endi +if $data30 != @NULL@ then + return -1 +endi +if $data40 != @0.989358247@ then + return -1 +endi +if $data50 != @0.998947724@ then + return -1 +endi +if $data60 != @-0.998947724@ then + return -1 +endi +print execute sql select sin((c2 + c3)) from tb1; +sql select sin((c2 + c3)) from tb1; +if $data00 != @0.909297427@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data20 != @NULL@ then + return -1 +endi +if $data30 != @NULL@ then + return -1 +endi +if $data40 != @0.989358247@ then + return -1 +endi +if $data50 != @0.998947724@ then + return -1 +endi +if $data60 != @-0.998947724@ then + return -1 +endi +print execute sql select sin((c2 * c3)+c4-6) from tb1; +sql select sin((c2 * c3)+c4-6) from tb1; +if $data00 != @0.756802495@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data20 != @NULL@ then + return -1 +endi +if $data30 != @NULL@ then + return -1 +endi +if $data40 != @0.990607356@ then + return -1 +endi +if $data50 != @0.083417203@ then + return -1 +endi +if $data60 != @0.990962545@ then + return -1 +endi +print execute sql select sin(11)+c2 from tb1; +sql select sin(11)+c2 from tb1; +if $data00 != @0.000009793@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data20 != @1.000009793@ then + return -1 +endi +if $data30 != @NULL@ then + return -1 +endi +if $data40 != @3.000009793@ then + return -1 +endi +if $data50 != @126.000009793@ then + return -1 +endi +if $data60 != @-127.999990207@ then + return -1 +endi +print execute sql select sin(c1)+c2 from tb1; +sql_error select sin(c1)+c2 from tb1; +print execute sql select sin(c2)+11 from tb1; +sql select sin(c2)+11 from tb1; +if $data00 != @11.841470985@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data20 != @11.909297427@ then + return -1 +endi +if $data30 != @NULL@ then + return -1 +endi +if $data40 != @10.243197505@ then + return -1 +endi +if $data50 != @11.972630067@ then + return -1 +endi +if $data60 != @10.027369933@ then + return -1 +endi +print execute sql select sin(c1),c1,c2 from tb1; +sql_error select sin(c1),c1,c2 from tb1; +print execute sql select sin(c1),t1,ts,tbname,_C0,_c0 from tb1; +sql_error select sin(c1),t1,ts,tbname,_C0,_c0 from tb1; +print execute sql select sin(c1),floor(c3) from tb1; +sql_error select sin(c1),floor(c3) from tb1; +print execute sql select sin(c1),sin(c2+c3) from tb1; +sql_error select sin(c1),sin(c2+c3) from tb1; +print execute sql select sin(c2+c3) from tb1 where c2 is not null and c3 is not null; +sql select sin(c2+c3) from tb1 where c2 is not null and c3 is not null; +if $data00 != @0.909297427@ then + return -1 +endi +if $data10 != @0.989358247@ then + return -1 +endi +if $data20 != @0.998947724@ then + return -1 +endi +if $data30 != @-0.998947724@ then + return -1 +endi +print execute sql select sin(c2) from tb1 order by ts desc; +sql select sin(c2) from tb1 order by ts desc; +if $data00 != @-0.972630067@ then + return -1 +endi +if $data10 != @0.972630067@ then + return -1 +endi +if $data20 != @-0.756802495@ then + return -1 +endi +if $data30 != @NULL@ then + return -1 +endi +if $data40 != @0.909297427@ then + return -1 +endi +if $data50 != @NULL@ then + return -1 +endi +if $data60 != @0.841470985@ then + return -1 +endi +print execute sql select sin(c2+c3) from tb1 order by ts desc; +sql select sin(c2+c3) from tb1 order by ts desc; +if $data00 != @-0.998947724@ then + return -1 +endi +if $data10 != @0.998947724@ then + return -1 +endi +if $data20 != @0.989358247@ then + return -1 +endi +if $data30 != @NULL@ then + return -1 +endi +if $data40 != @NULL@ then + return -1 +endi +if $data50 != @NULL@ then + return -1 +endi +if $data60 != @0.909297427@ then + return -1 +endi +print execute sql select sin(c2+c3) from tb1 order by ts desc limit 3 offset 2; +sql select sin(c2+c3) from tb1 order by ts desc limit 3 offset 2; +if $data00 != @0.989358247@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data20 != @NULL@ then + return -1 +endi +print execute sql select sin(c2) from stb1; +sql select sin(c2) from stb1; +if $data00 != @0.841470985@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data20 != @0.909297427@ then + return -1 +endi +if $data30 != @NULL@ then + return -1 +endi +if $data40 != @-0.756802495@ then + return -1 +endi +if $data50 != @0.972630067@ then + return -1 +endi +if $data60 != @-0.972630067@ then + return -1 +endi +if $data70 != @0.841470985@ then + return -1 +endi +if $data80 != @0.909297427@ then + return -1 +endi +if $data90 != @0.141120008@ then + return -1 +endi +print execute sql select sin(c2) from stb1 order by ts desc; +sql select sin(c2) from stb1 order by ts desc; +if $data00 != @0.656986599@ then + if $data00 != @-0.972630067@ then + return -1 + endi +endi +if $data20 != @-0.279415498@ then + if $data20 != @0.972630067@ then + return -1 + endi +endi +if $data40 != @-0.958924275@ then + if $data40 != @-0.756802495@ then + return -1 + endi +endi +if $data60 != @-0.756802495@ then + if $data60 != @NULL@ then + return -1 + endi +endi +if $data80 != @0.141120008@ then + if $data80 != @0.909297427@ then + return -1 + endi +endi +print execute sql select sin(c4),t1 from stb1 order by ts desc; +sql select sin(c4),t1 from stb1 order by ts desc; +if $data00 != @0.656986599@ then + if $data00 != @0.724916555@ then + return -1 + endi +endi +if $data01 != @2@ then + if $data01 != @1@ then + return -1 + endi +endi +if $data20 != @-0.279415498@ then + if $data20 != @-0.724916555@ then + return -1 + endi +endi +if $data21 != @2@ then + if $data21 != @1@ then + return -1 + endi +endi +if $data40 != @-0.958924275@ then + if $data40 != @-0.756802495@ then + return -1 + endi +endi +if $data41 != @2@ then + if $data41 != @1@ then + return -1 + endi +endi +if $data60 != @-0.756802495@ then + if $data60 != @NULL@ then + return -1 + endi +endi +if $data61 != @2@ then + if $data61 != @1@ then + return -1 + endi +endi +if $data80 != @0.909297427@ then + if $data80 != @0.909297427@ then + return -1 + endi +endi +if $data81 != @2@ then + if $data81 != @1@ then + return -1 + endi +endi +print execute sql select sin(c3),tbname from stb1; +sql select sin(c3),tbname from stb1; +if $data00 != @0.841470985@ then + return -1 +endi +if $data01 != @tb1@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data11 != @tb1@ then + return -1 +endi +if $data20 != @NULL@ then + return -1 +endi +if $data21 != @tb1@ then + return -1 +endi +if $data30 != @0.141120008@ then + return -1 +endi +if $data31 != @tb1@ then + return -1 +endi +if $data40 != @-0.756802495@ then + return -1 +endi +if $data41 != @tb1@ then + return -1 +endi +if $data50 != @0.187506554@ then + return -1 +endi +if $data51 != @tb1@ then + return -1 +endi +if $data60 != @-0.187506554@ then + return -1 +endi +if $data61 != @tb1@ then + return -1 +endi +if $data70 != @0.841470985@ then + return -1 +endi +if $data71 != @tb2@ then + return -1 +endi +if $data80 != @0.909297427@ then + return -1 +endi +if $data81 != @tb2@ then + return -1 +endi +if $data90 != @0.141120008@ then + return -1 +endi +if $data91 != @tb2@ then + return -1 +endi +print execute sql select sin(c3),tbname from stb1 where t1 > 1; +sql select sin(c3),tbname from stb1 where t1 > 1; +if $data00 != @0.841470985@ then + return -1 +endi +if $data01 != @tb2@ then + return -1 +endi +if $data10 != @0.909297427@ then + return -1 +endi +if $data11 != @tb2@ then + return -1 +endi +if $data20 != @0.141120008@ then + return -1 +endi +if $data21 != @tb2@ then + return -1 +endi +if $data30 != @-0.756802495@ then + return -1 +endi +if $data31 != @tb2@ then + return -1 +endi +if $data40 != @-0.958924275@ then + return -1 +endi +if $data41 != @tb2@ then + return -1 +endi +if $data50 != @-0.279415498@ then + return -1 +endi +if $data51 != @tb2@ then + return -1 +endi +if $data60 != @0.656986599@ then + return -1 +endi +if $data61 != @tb2@ then + return -1 +endi +print execute sql select sin(c8),sin(c9) from tbn; +sql_error select sin(c8),sin(c9) from tbn; +print execute sql select sin(c8),sin(c9) from tbn order by ts desc; +sql_error select sin(c8),sin(c9) from tbn order by ts desc; +print execute sql select sin(sin(c8)) from tbn; +sql_error select sin(sin(c8)) from tbn; +print execute sql select sin(a) from (select avg(c2) as a from stb1 interval(1s)); +sql select sin(a) from (select avg(c2) as a from stb1 interval(1s)); +if $data00 != @0.841470985@ then + return -1 +endi +if $data10 != @0.909297427@ then + return -1 +endi +if $data20 != @0.598472144@ then + return -1 +endi +if $data30 != @-0.756802495@ then + return -1 +endi +if $data40 != @-0.977530118@ then + return -1 +endi +if $data50 != @-0.502557350@ then + return -1 +endi +if $data60 != @0.304810621@ then + return -1 +endi +print execute sql select sin(c2) from (select * from stb1); +sql select sin(c2) from (select * from stb1); +if $data00 != @0.841470985@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data20 != @0.909297427@ then + return -1 +endi +if $data30 != @NULL@ then + return -1 +endi +if $data40 != @-0.756802495@ then + return -1 +endi +if $data50 != @0.972630067@ then + return -1 +endi +if $data60 != @-0.972630067@ then + return -1 +endi +if $data70 != @0.841470985@ then + return -1 +endi +if $data80 != @0.909297427@ then + return -1 +endi +if $data90 != @0.141120008@ then + return -1 +endi +print execute sql select sin(a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)); +sql select sin(a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)); +if $data00 != @0.841470985@ then + return -1 +endi +if $data10 != @0.909297427@ then + return -1 +endi +if $data20 != @0.598472144@ then + return -1 +endi +if $data30 != @-0.756802495@ then + return -1 +endi +if $data40 != @-0.977530118@ then + return -1 +endi +if $data50 != @-0.502557350@ then + return -1 +endi +if $data60 != @0.304810621@ then + return -1 +endi +if $data70 != @NULL@ then + return -1 +endi +if $data80 != @NULL@ then + return -1 +endi +if $data90 != @NULL@ then + return -1 +endi +print execute sql select sin(a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)) order by ts; +sql select sin(a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)) order by ts; +if $data00 != @0.841470985@ then + return -1 +endi +if $data10 != @0.909297427@ then + return -1 +endi +if $data20 != @0.598472144@ then + return -1 +endi +if $data30 != @-0.756802495@ then + return -1 +endi +if $data40 != @-0.977530118@ then + return -1 +endi +if $data50 != @-0.502557350@ then + return -1 +endi +if $data60 != @0.304810621@ then + return -1 +endi +if $data70 != @NULL@ then + return -1 +endi +if $data80 != @NULL@ then + return -1 +endi +if $data90 != @NULL@ then + return -1 +endi +print execute sql select sin(a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)) order by ts desc; +sql select sin(a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)) order by ts desc; +if $data00 != @NULL@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data20 != @NULL@ then + return -1 +endi +if $data30 != @0.304810621@ then + return -1 +endi +if $data40 != @-0.502557350@ then + return -1 +endi +if $data50 != @-0.977530118@ then + return -1 +endi +if $data60 != @-0.756802495@ then + return -1 +endi +if $data70 != @0.598472144@ then + return -1 +endi +if $data80 != @0.909297427@ then + return -1 +endi +if $data90 != @0.841470985@ then + return -1 +endi +print execute sql select sin(a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)) order by a desc; +sql select sin(a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)) order by a desc; +if $data00 != @NULL@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data20 != @NULL@ then + return -1 +endi +if $data30 != @-0.502557350@ then + return -1 +endi +if $data40 != @-0.977530118@ then + return -1 +endi +if $data50 != @-0.756802495@ then + return -1 +endi +if $data60 != @0.598472144@ then + return -1 +endi +if $data70 != @0.909297427@ then + return -1 +endi +if $data80 != @0.841470985@ then + return -1 +endi +if $data90 != @0.304810621@ then + return -1 +endi +print execute sql select sin(a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)) order by a; +sql select sin(a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)) order by a; +if $data00 != @0.304810621@ then + return -1 +endi +if $data10 != @0.841470985@ then + return -1 +endi +if $data20 != @0.909297427@ then + return -1 +endi +if $data30 != @0.598472144@ then + return -1 +endi +if $data40 != @-0.756802495@ then + return -1 +endi +if $data50 != @-0.977530118@ then + return -1 +endi +if $data60 != @-0.502557350@ then + return -1 +endi +if $data70 != @NULL@ then + return -1 +endi +if $data80 != @NULL@ then + return -1 +endi +if $data90 != @NULL@ then + return -1 +endi +print execute sql select sin(a) from (select sin(c2) as a from tb1); +sql select sin(a) from (select sin(c2) as a from tb1); +if $data00 != @0.745624142@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data20 != @0.789072344@ then + return -1 +endi +if $data30 != @NULL@ then + return -1 +endi +if $data40 != @-0.686600261@ then + return -1 +endi +if $data50 != @0.826369634@ then + return -1 +endi +if $data60 != @-0.826369634@ then + return -1 +endi +print execute sql select sin(tb1.c3),sin(tb2.c3) from tb1,tb2 where tb1.ts=tb2.ts; +sql select sin(tb1.c3),sin(tb2.c3) from tb1,tb2 where tb1.ts=tb2.ts; +if $data00 != @0.841470985@ then + return -1 +endi +if $data01 != @0.841470985@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data11 != @0.909297427@ then + return -1 +endi +if $data20 != @NULL@ then + return -1 +endi +if $data21 != @0.141120008@ then + return -1 +endi +if $data30 != @0.141120008@ then + return -1 +endi +if $data31 != @-0.756802495@ then + return -1 +endi +if $data40 != @-0.756802495@ then + return -1 +endi +if $data41 != @-0.958924275@ then + return -1 +endi +if $data50 != @0.187506554@ then + return -1 +endi +if $data51 != @-0.279415498@ then + return -1 +endi +if $data60 != @-0.187506554@ then + return -1 +endi +if $data61 != @0.656986599@ then + return -1 +endi +print execute sql select sin(c3) from tb1 union all select sin(c3) from tb2; +sql select sin(c3) from tb1 union all select sin(c3) from tb2; +if $data00 != @0.841470985@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data20 != @NULL@ then + return -1 +endi +if $data30 != @0.141120008@ then + return -1 +endi +if $data40 != @-0.756802495@ then + return -1 +endi +if $data50 != @0.187506554@ then + return -1 +endi +if $data60 != @-0.187506554@ then + return -1 +endi +if $data70 != @0.841470985@ then + return -1 +endi +if $data80 != @0.909297427@ then + return -1 +endi +if $data90 != @0.141120008@ then + return -1 +endi diff --git a/tests/script/general/compute/math_sin2.sim b/tests/script/general/compute/math_sin2.sim new file mode 100644 index 0000000000000000000000000000000000000000..f19fa3c835fcd117260a845109cd6676d99647d8 --- /dev/null +++ b/tests/script/general/compute/math_sin2.sim @@ -0,0 +1,366 @@ +sleep 100 +sql connect +sql use db + +print execute sql select sin(stb1.c4),sin(stba.c5) from stb1,stba where stb1.t1=stba.t1 and stb1.ts=stba.ts; +sql select sin(stb1.c4),sin(stba.c5) from stb1,stba where stb1.t1=stba.t1 and stb1.ts=stba.ts; +if $data00 != @0.841470985@ then + return -1 +endi +if $data01 != @0.841470985@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data11 != @0.909297427@ then + return -1 +endi +if $data20 != @0.909297427@ then + return -1 +endi +if $data21 != @0.141120008@ then + return -1 +endi +if $data30 != @NULL@ then + return -1 +endi +if $data31 != @-0.756802495@ then + return -1 +endi +if $data40 != @-0.756802495@ then + return -1 +endi +if $data41 != @-0.958924275@ then + return -1 +endi +if $data50 != @-0.724916555@ then + return -1 +endi +if $data51 != @-0.279415498@ then + return -1 +endi +if $data60 != @0.724916555@ then + return -1 +endi +if $data61 != @0.656986599@ then + return -1 +endi +print execute sql select sin(c4) as a from stb1 union all select sin(c5) as a from stba; +sql select sin(c4) as a from stb1 union all select sin(c5) as a from stba; +if $data00 != @0.841470985@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data20 != @0.909297427@ then + return -1 +endi +if $data30 != @NULL@ then + return -1 +endi +if $data40 != @-0.756802495@ then + return -1 +endi +if $data50 != @-0.724916555@ then + return -1 +endi +if $data60 != @0.724916555@ then + return -1 +endi +if $data70 != @0.841470985@ then + return -1 +endi +if $data80 != @0.909297427@ then + return -1 +endi +if $data90 != @0.909297427@ then + return -1 +endi +print execute sql select sin(c2) from stba; +sql select sin(c2) from stba; +if $data00 != @0.841470985@ then + return -1 +endi +if $data10 != @0.909297427@ then + return -1 +endi +if $data20 != @0.141120008@ then + return -1 +endi +if $data30 != @-0.756802495@ then + return -1 +endi +if $data40 != @-0.958924275@ then + return -1 +endi +if $data50 != @-0.279415498@ then + return -1 +endi +if $data60 != @0.656986599@ then + return -1 +endi +if $data70 != @0.989358247@ then + return -1 +endi +if $data80 != @0.412118485@ then + return -1 +endi +if $data90 != @0.000000000@ then + return -1 +endi +print execute sql select sin(min(c2)) from tba1; +sql select sin(min(c2)) from tba1; +if $data00 != @0.000000000@ then + return -1 +endi +print execute sql select sin(max(c2)) from tba1; +sql select sin(max(c2)) from tba1; +if $data00 != @0.412118485@ then + return -1 +endi +print execute sql select sin(count(c2)) from tba1; +sql select sin(count(c2)) from tba1; +if $data00 != @-0.988031624@ then + return -1 +endi +print execute sql select sin(sum(c2)) from tba1; +sql select sin(sum(c2)) from tba1; +if $data00 != @0.088368686@ then + return -1 +endi +print execute sql select sin(avg(c2)) from tba1; +sql select sin(avg(c2)) from tba1; +if $data00 != @-0.977530118@ then + return -1 +endi +print execute sql select sin(percentile(c2, 10)) from tba1; +sql select sin(percentile(c2, 10)) from tba1; +if $data00 != @0.783326910@ then + return -1 +endi +print execute sql select sin(apercentile(c2, 10)) from tba1; +sql select sin(apercentile(c2, 10)) from tba1; +if $data00 != @0.000000000@ then + return -1 +endi +print execute sql select sin(stddev(c2)) from tba1; +sql select sin(stddev(c2)) from tba1; +if $data00 != @0.266067654@ then + return -1 +endi +print execute sql select sin(spread(c2)) from tba1; +sql select sin(spread(c2)) from tba1; +if $data00 != @0.412118485@ then + return -1 +endi +print execute sql select sin(twa(c2)) from tba1; +sql select sin(twa(c2)) from tba1; +if $data00 != @-0.997229288@ then + return -1 +endi +print execute sql select sin(leastsquares(c2, 1, 1)) from tba1; +sql_error select sin(leastsquares(c2, 1, 1)) from tba1; +print execute sql select sin(interp(c2)) from tba1 every(1s) +sql select sin(interp(c2)) from tba1 every(1s) +if $data00 != @21-11-11 09:00:00.000@ then + return -1 +endi +if $data01 != @0.841470985@ then + return -1 +endi +if $data10 != @21-11-11 09:00:01.000@ then + return -1 +endi +if $data11 != @0.909297427@ then + return -1 +endi +if $data20 != @21-11-11 09:00:02.000@ then + return -1 +endi +if $data21 != @0.141120008@ then + return -1 +endi +if $data30 != @21-11-11 09:00:03.000@ then + return -1 +endi +if $data31 != @-0.756802495@ then + return -1 +endi +if $data40 != @21-11-11 09:00:04.000@ then + return -1 +endi +if $data41 != @-0.958924275@ then + return -1 +endi +if $data50 != @21-11-11 09:00:05.000@ then + return -1 +endi +if $data51 != @-0.279415498@ then + return -1 +endi +if $data60 != @21-11-11 09:00:06.000@ then + return -1 +endi +if $data61 != @0.656986599@ then + return -1 +endi +if $data70 != @21-11-11 09:00:07.000@ then + return -1 +endi +if $data71 != @0.989358247@ then + return -1 +endi +if $data80 != @21-11-11 09:00:08.000@ then + return -1 +endi +if $data81 != @0.412118485@ then + return -1 +endi +if $data90 != @21-11-11 09:00:09.000@ then + return -1 +endi +if $data91 != @0.000000000@ then + return -1 +endi +print execute sql select sin(interp(c2)) from stba every(1s) group by tbname; +sql select sin(interp(c2)) from stba every(1s) group by tbname; +if $data00 != @21-11-11 09:00:00.000@ then + return -1 +endi +if $data01 != @0.841470985@ then + return -1 +endi +if $data02 != @tba1@ then + return -1 +endi +if $data10 != @21-11-11 09:00:01.000@ then + return -1 +endi +if $data11 != @0.909297427@ then + return -1 +endi +if $data12 != @tba1@ then + return -1 +endi +if $data20 != @21-11-11 09:00:02.000@ then + return -1 +endi +if $data21 != @0.141120008@ then + return -1 +endi +if $data22 != @tba1@ then + return -1 +endi +if $data30 != @21-11-11 09:00:03.000@ then + return -1 +endi +if $data31 != @-0.756802495@ then + return -1 +endi +if $data32 != @tba1@ then + return -1 +endi +if $data40 != @21-11-11 09:00:04.000@ then + return -1 +endi +if $data41 != @-0.958924275@ then + return -1 +endi +if $data42 != @tba1@ then + return -1 +endi +if $data50 != @21-11-11 09:00:05.000@ then + return -1 +endi +if $data51 != @-0.279415498@ then + return -1 +endi +if $data52 != @tba1@ then + return -1 +endi +if $data60 != @21-11-11 09:00:06.000@ then + return -1 +endi +if $data61 != @0.656986599@ then + return -1 +endi +if $data62 != @tba1@ then + return -1 +endi +if $data70 != @21-11-11 09:00:07.000@ then + return -1 +endi +if $data71 != @0.989358247@ then + return -1 +endi +if $data72 != @tba1@ then + return -1 +endi +if $data80 != @21-11-11 09:00:08.000@ then + return -1 +endi +if $data81 != @0.412118485@ then + return -1 +endi +if $data82 != @tba1@ then + return -1 +endi +if $data90 != @21-11-11 09:00:09.000@ then + return -1 +endi +if $data91 != @0.000000000@ then + return -1 +endi +if $data92 != @tba1@ then + return -1 +endi +print execute sql select sin(elapsed(ts)) from tba1; +sql select sin(elapsed(ts)) from tba1; +if $data00 != @0.041773129@ then + return -1 +endi +print execute sql select sin(rate(c2)) from tba1; +sql select sin(rate(c2)) from tba1; +if $data00 != @0.781178774@ then + return -1 +endi +print execute sql select sin(irate(c2)) from tba1; +sql select sin(irate(c2)) from tba1; +if $data00 != @0.000000000@ then + return -1 +endi +print execute sql select sin(first(c2)) from tba1; +sql select sin(first(c2)) from tba1; +if $data00 != @0.841470985@ then + return -1 +endi +print execute sql select sin(last(c2)) from tba1; +sql select sin(last(c2)) from tba1; +if $data00 != @0.000000000@ then + return -1 +endi +print execute sql select sin(last_row(c2)) from tba1; +sql select sin(last_row(c2)) from tba1; +if $data00 != @0.000000000@ then + return -1 +endi +print execute sql select sin(top(c2, 1)) from tba1; +sql_error select sin(top(c2, 1)) from tba1; +print execute sql select sin(bottom(c2, 1)) from tba1; +sql_error select sin(bottom(c2, 1)) from tba1; +print execute sql select sin(leastsquares(c2, 1, 1)) from tba1; +sql_error select sin(leastsquares(c2, 1, 1)) from tba1; +print execute sql select sin(derivative(c2, 1s, 0)) from tba1; +sql_error select sin(derivative(c2, 1s, 0)) from tba1; +print execute sql select sin(diff(c2)) from tba1; +sql_error select sin(diff(c2)) from tba1; +print execute sql select sin(csum(c2)) from tba1; +sql_error select sin(csum(c2)) from tba1; +print execute sql select sin(mavg(c2,2)) from tba1; +sql_error select sin(mavg(c2,2)) from tba1; +print execute sql select sin(sample(c2,2)) from tba1; +sql_error select sin(sample(c2,2)) from tba1; +print execute sql select sin(_block_dist()) from tba1; +sql_error select sin(_block_dist()) from tba1; diff --git a/tests/script/general/compute/math_sqrt.sim b/tests/script/general/compute/math_sqrt.sim new file mode 100644 index 0000000000000000000000000000000000000000..0174bfd617b043197a6e97210bbabf02b959deea --- /dev/null +++ b/tests/script/general/compute/math_sqrt.sim @@ -0,0 +1,1076 @@ + +sleep 100 +sql connect + +sql use db; + +print execute sql select sqrt(*) from tb1; +sql_error select sqrt(*) from tb1; +print execute sql select sqrt(*) from tb1; +sql_error select sqrt(*) from tb1; +print execute sql select sqrt(*) from tb1; +sql_error select sqrt(*) from tb1; +print execute sql select sqrt(*) from tb1; +sql_error select sqrt(*) from tb1; +print execute sql select sqrt(*) as a from tb1; +sql_error select sqrt(*) as a from tb1; +print execute sql select sqrt(*) + 1 as a from tb1; +sql_error select sqrt(*) + 1 as a from tb1; +print execute sql select sqrt(tb1.*) + 1 as a from tb1; +sql_error select sqrt(tb1.*) + 1 as a from tb1; +print execute sql select sqrt(*) from tb1; +sql_error select sqrt(*) from tb1; +print execute sql select sqrt(c1) from tb1; +sql_error select sqrt(c1) from tb1; +print execute sql select sqrt(c1) from tb1; +sql_error select sqrt(c1) from tb1; +print execute sql select sqrt(c1 + c2) from tb1; +sql_error select sqrt(c1 + c2) from tb1; +print execute sql select sqrt(13) from tb1; +sql select sqrt(13) from tb1; +print $data00 +if $data00 != @3.605551275@ then + return -1 +endi +if $data10 != @3.605551275@ then + return -1 +endi +if $data20 != @3.605551275@ then + return -1 +endi +if $data30 != @3.605551275@ then + return -1 +endi +if $data40 != @3.605551275@ then + return -1 +endi +if $data50 != @3.605551275@ then + return -1 +endi +if $data60 != @3.605551275@ then + return -1 +endi +print execute sql select sqrt(c1) from tb1; +sql_error select sqrt(c1) from tb1; +print execute sql select sqrt(c2) from tb1; +sql select sqrt(c2) from tb1; +if $data00 != @1.000000000@ then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data20 != @1.414213562@ then + return -1 +endi +if $data30 != NULL then + return -1 +endi +if $data40 != @2.000000000@ then + return -1 +endi +if $data50 != @11.269427670@ then + return -1 +endi +if $data60 != @-nan@ then + return -1 +endi +print execute sql select sqrt(c3) from tb1; +sql select sqrt(c3) from tb1; +if $data00 != @1.000000000@ then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data20 != NULL then + return -1 +endi +if $data30 != @1.732050808@ then + return -1 +endi +if $data40 != @2.000000000@ then + return -1 +endi +if $data50 != @181.016573827@ then + return -1 +endi +if $data60 != @-nan@ then + return -1 +endi +print execute sql select sqrt(c4) from tb1; +sql select sqrt(c4) from tb1; +if $data00 != @1.000000000@ then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data20 != @1.414213562@ then + return -1 +endi +if $data30 != NULL then + return -1 +endi +if $data40 != @2.000000000@ then + return -1 +endi +if $data50 != @46340.950001052@ then + return -1 +endi +if $data60 != @-nan@ then + return -1 +endi +print execute sql select sqrt(c5) from tb1; +sql select sqrt(c5) from tb1; +if $data00 != @1.000000000@ then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data20 != NULL then + return -1 +endi +if $data30 != @1.732050808@ then + return -1 +endi +if $data40 != @2.000000000@ then + return -1 +endi +if $data50 != @3037000499.976049900@ then + return -1 +endi +if $data60 != @-nan@ then + return -1 +endi +print execute sql select sqrt(c6) from tb1; +sql select sqrt(c6) from tb1; +if $data00 != @1.000000000@ then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data20 != @1.414213562@ then + return -1 +endi +if $data30 != NULL then + return -1 +endi +if $data40 != @2.000000000@ then + return -1 +endi +if $data50 != @18446743523953729536.000000000@ then + return -1 +endi +if $data60 != @-nan@ then + return -1 +endi +print execute sql select sqrt(c7) from tb1; +sql select sqrt(c7) from tb1; +if $data00 != @1.000000000@ then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data20 != NULL then + return -1 +endi +if $data30 != @1.732050808@ then + return -1 +endi +if $data40 != @2.000000000@ then + return -1 +endi +if $data50 != @13407796239501851766774967791213869355880985313973964850809468725636027220114995122003349472475914321949847847995869038367123793747113409741287235182919680.000000000@ then + return -1 +endi +if $data60 != @-nan@ then + return -1 +endi +print execute sql select sqrt(c8) from tb1; +sql_error select sqrt(c8) from tb1; +print execute sql select sqrt(c9) from tb1; +sql_error select sqrt(c9) from tb1; +print execute sql select sqrt(c10) from tb1; +sql select sqrt(c10) from tb1; +if $data00 != @1.000000000@ then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data20 != @1.414213562@ then + return -1 +endi +if $data30 != NULL then + return -1 +endi +if $data40 != @2.000000000@ then + return -1 +endi +if $data50 != @15.937377451@ then + return -1 +endi +if $data60 != @0.000000000@ then + return -1 +endi +print execute sql select sqrt(c11) from tb1; +sql select sqrt(c11) from tb1; +if $data00 != @1.000000000@ then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data20 != NULL then + return -1 +endi +if $data30 != @1.732050808@ then + return -1 +endi +if $data40 != @2.000000000@ then + return -1 +endi +if $data50 != @255.996093720@ then + return -1 +endi +if $data60 != @0.000000000@ then + return -1 +endi +print execute sql select sqrt(c12) from tb1; +sql select sqrt(c12) from tb1; +if $data00 != @1.000000000@ then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data20 != @1.414213562@ then + return -1 +endi +if $data30 != NULL then + return -1 +endi +if $data40 != @2.000000000@ then + return -1 +endi +if $data50 != @65535.999984741@ then + return -1 +endi +if $data60 != @0.000000000@ then + return -1 +endi +print execute sql select sqrt(c13) from tb1; +sql select sqrt(c13) from tb1; +if $data00 != @1.000000000@ then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data20 != NULL then + return -1 +endi +if $data30 != @1.732050808@ then + return -1 +endi +if $data40 != @2.000000000@ then + return -1 +endi +if $data50 != @3037000499.976049900@ then + return -1 +endi +if $data60 != @0.000000000@ then + return -1 +endi +print execute sql select sqrt(12345678900000000000000000) from tb1; +sql_error select sqrt(12345678900000000000000000) from tb1; +print execute sql select distinct sqrt(123) from tb1; +sql_error select distinct sqrt(123) from tb1; +print execute sql select sqrt(t1) from stb1; +sql_error select sqrt(t1) from stb1; +print execute sql select sqrt(c1),avg(c3) from tb1; +sql_error select sqrt(c1),avg(c3) from tb1; +print execute sql select sqrt(c1),top(c3,1) from tb1; +sql_error select sqrt(c1),top(c3,1) from tb1; +print execute sql select sqrt(c2+c3) from tb1 session(ts, 1s); +sql_error select sqrt(c2+c3) from tb1 session(ts, 1s); +print execute sql select sqrt(c2+c3) from tb1 STATE_WINDOW(c1); +sql_error select sqrt(c2+c3) from tb1 STATE_WINDOW(c1); +print execute sql select sqrt(c2+c3) from tb1 interval(1s) sliding(1s) fill(NULL); +sql_error select sqrt(c2+c3) from tb1 interval(1s) sliding(1s) fill(NULL); +print execute sql select sqrt(c2+c3) from stb1 group by t1; +sql_error select sqrt(c2+c3) from stb1 group by t1; +print execute sql select sqrt(c2+c3) from stb1 group by ts; +sql_error select sqrt(c2+c3) from stb1 group by ts; +print execute sql select sqrt(c2+c3) from stb1 group by c1; +sql_error select sqrt(c2+c3) from stb1 group by c1; +print execute sql select sqrt(c2+c3) from stb1 group by tbname; +sql_error select sqrt(c2+c3) from stb1 group by tbname; +print execute sql select sqrt(c2+c3) from tb1 order by c2; +sql_error select sqrt(c2+c3) from tb1 order by c2; +print execute sql select sqrt(c8),sqrt(c9) from tbn; +sql_error select sqrt(c8),sqrt(c9) from tbn; +print execute sql select sqrt(ts) from (select avg(c2) as a from stb1 interval(1s)); +sql_error select sqrt(ts) from (select avg(c2) as a from stb1 interval(1s)); +print execute sql select sqrt(a) from (select sqrt(c2) as a from tb1); +sql select sqrt(a) from (select sqrt(c2) as a from tb1); +if $data00 != @1.000000000@ then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data20 != @1.189207115@ then + return -1 +endi +if $data30 != NULL then + return -1 +endi +if $data40 != @1.414213562@ then + return -1 +endi +if $data50 != @3.356996823@ then + return -1 +endi +if $data60 != @-nan@ then + return -1 +endi +print execute sql select sqrt("abc") from tb1; +sql_error select sqrt("abc") from tb1; +print execute sql select sqrt(c2 + c3) from tb1; +sql select sqrt(c2 + c3) from tb1; +if $data00 != @1.414213562@ then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data20 != NULL then + return -1 +endi +if $data30 != NULL then + return -1 +endi +if $data40 != @2.828427125@ then + return -1 +endi +if $data50 != @181.367031183@ then + return -1 +endi +if $data60 != @-nan@ then + return -1 +endi +print execute sql select sqrt((c2 + c3)) from tb1; +sql select sqrt((c2 + c3)) from tb1; +if $data00 != @1.414213562@ then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data20 != NULL then + return -1 +endi +if $data30 != NULL then + return -1 +endi +if $data40 != @2.828427125@ then + return -1 +endi +if $data50 != @181.367031183@ then + return -1 +endi +if $data60 != @-nan@ then + return -1 +endi +print execute sql select sqrt((c2 * c3)+c4-6) from tb1; +sql select sqrt((c2 * c3)+c4-6) from tb1; +if $data00 != @-nan@ then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data20 != NULL then + return -1 +endi +if $data30 != NULL then + return -1 +endi +if $data40 != @3.741657387@ then + return -1 +endi +if $data50 != @46385.828115924@ then + return -1 +endi +if $data60 != @-nan@ then + return -1 +endi +print execute sql select sqrt(11)+c2 from tb1; +sql select sqrt(11)+c2 from tb1; +if $data00 != @4.316624790@ then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data20 != @5.316624790@ then + return -1 +endi +if $data30 != NULL then + return -1 +endi +if $data40 != @7.316624790@ then + return -1 +endi +if $data50 != @130.316624790@ then + return -1 +endi +if $data60 != @-123.683375210@ then + return -1 +endi +print execute sql select sqrt(c1)+c2 from tb1; +sql_error select sqrt(c1)+c2 from tb1; +print execute sql select sqrt(c2)+11 from tb1; +sql select sqrt(c2)+11 from tb1; +if $data00 != @12.000000000@ then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data20 != @12.414213562@ then + return -1 +endi +if $data30 != NULL then + return -1 +endi +if $data40 != @13.000000000@ then + return -1 +endi +if $data50 != @22.269427670@ then + return -1 +endi +if $data60 != @-nan@ then + return -1 +endi +print execute sql select sqrt(c1),c1,c2 from tb1; +sql_error select sqrt(c1),c1,c2 from tb1; +print execute sql select sqrt(c1),t1,ts,tbname,_C0,_c0 from tb1; +sql_error select sqrt(c1),t1,ts,tbname,_C0,_c0 from tb1; +print execute sql select sqrt(c1),floor(c3) from tb1; +sql_error select sqrt(c1),floor(c3) from tb1; +print execute sql select sqrt(c1),sqrt(c2+c3) from tb1; +sql_error select sqrt(c1),sqrt(c2+c3) from tb1; +print execute sql select sqrt(c2+c3) from tb1 where c2 is not null and c3 is not null; +sql select sqrt(c2+c3) from tb1 where c2 is not null and c3 is not null; +if $data00 != @1.414213562@ then + return -1 +endi +if $data10 != @2.828427125@ then + return -1 +endi +if $data20 != @181.367031183@ then + return -1 +endi +if $data30 != @-nan@ then + return -1 +endi +print execute sql select sqrt(c2) from tb1 order by ts desc; +sql select sqrt(c2) from tb1 order by ts desc; +if $data00 != @-nan@ then + return -1 +endi +if $data10 != @11.269427670@ then + return -1 +endi +if $data20 != @2.000000000@ then + return -1 +endi +if $data30 != NULL then + return -1 +endi +if $data40 != @1.414213562@ then + return -1 +endi +if $data50 != NULL then + return -1 +endi +if $data60 != @1.000000000@ then + return -1 +endi +print execute sql select sqrt(c2+c3) from tb1 order by ts desc; +sql select sqrt(c2+c3) from tb1 order by ts desc; +if $data00 != @-nan@ then + return -1 +endi +if $data10 != @181.367031183@ then + return -1 +endi +if $data20 != @2.828427125@ then + return -1 +endi +if $data30 != NULL then + return -1 +endi +if $data40 != NULL then + return -1 +endi +if $data50 != NULL then + return -1 +endi +if $data60 != @1.414213562@ then + return -1 +endi +print execute sql select sqrt(c2+c3) from tb1 order by ts desc limit 3 offset 2; +sql select sqrt(c2+c3) from tb1 order by ts desc limit 3 offset 2; +if $data00 != @2.828427125@ then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data20 != NULL then + return -1 +endi +print execute sql select sqrt(c2) from stb1; +sql select sqrt(c2) from stb1; +if $data00 != @1.000000000@ then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data20 != @1.414213562@ then + return -1 +endi +if $data30 != NULL then + return -1 +endi +if $data40 != @2.000000000@ then + return -1 +endi +if $data50 != @11.269427670@ then + return -1 +endi +if $data60 != @-nan@ then + return -1 +endi +if $data70 != @1.000000000@ then + return -1 +endi +if $data80 != @1.414213562@ then + return -1 +endi +if $data90 != @1.732050808@ then + return -1 +endi +print execute sql select sqrt(c2) from stb1 order by ts desc; +sql select sqrt(c2) from stb1 order by ts desc; +if $data00 != @2.645751311@ then +if $data00 != @-nan@ then + return -1 +endi +endi +if $data20 != @2.449489743@ then +if $data20 != @11.269427670@ then + return -1 +endi +endi +if $data40 != @2.236067977@ then +if $data40 != @2.000000000@ then + return -1 +endi +endi +if $data60 != @2.000000000@ then +if $data60 != NULL then + return -1 +endi +endi +if $data80 != @1.732050808@ then +if $data80 != @1.414213562@ then + return -1 +endi +endi +print execute sql select sqrt(c4),t1,c4 from stb1 order by ts desc; +sql select sqrt(c4),t1,c4 from stb1 order by ts desc; +if $data00 != @2.645751311@ then +if $data00 != @-nan@ then + return -1 +endi +endi +if $data01 != @2@ then +if $data01 != @1@ then + return -1 +endi +endi +if $data20 != @2.449489743@ then +if $data20 != @46340.950001052@ then + return -1 +endi +endi +if $data21 != @2@ then +if $data21 != @1@ then + return -1 +endi +endi +if $data40 != @2.236067977@ then +if $data40 != @2.000000000@ then + return -1 +endi +endi +if $data41 != @2@ then +if $data41 != @1@ then + return -1 +endi +endi +if $data60 != @2.000000000@ then +if $data60 != NULL then + return -1 +endi +endi +if $data61 != @2@ then +if $data61 != @1@ then + return -1 +endi +endi +if $data80 != @1.414213562@ then +if $data80 != @1.414213562@ then + return -1 +endi +endi +if $data81 != @2@ then +if $data81 != @1@ then + return -1 +endi +endi +print execute sql select sqrt(c3),tbname from stb1; +sql select sqrt(c3),tbname from stb1; +if $data00 != @1.000000000@ then + return -1 +endi +if $data01 != @tb1@ then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data11 != @tb1@ then + return -1 +endi +if $data20 != NULL then + return -1 +endi +if $data21 != @tb1@ then + return -1 +endi +if $data30 != @1.732050808@ then + return -1 +endi +if $data31 != @tb1@ then + return -1 +endi +if $data40 != @2.000000000@ then + return -1 +endi +if $data41 != @tb1@ then + return -1 +endi +if $data50 != @181.016573827@ then + return -1 +endi +if $data51 != @tb1@ then + return -1 +endi +if $data60 != @-nan@ then + return -1 +endi +if $data61 != @tb1@ then + return -1 +endi +if $data70 != @1.000000000@ then + return -1 +endi +if $data71 != @tb2@ then + return -1 +endi +if $data80 != @1.414213562@ then + return -1 +endi +if $data81 != @tb2@ then + return -1 +endi +if $data90 != @1.732050808@ then + return -1 +endi +if $data91 != @tb2@ then + return -1 +endi +print execute sql select sqrt(c3),tbname from stb1 where t1 > 1; +sql select sqrt(c3),tbname from stb1 where t1 > 1; +if $data00 != @1.000000000@ then + return -1 +endi +if $data01 != @tb2@ then + return -1 +endi +if $data10 != @1.414213562@ then + return -1 +endi +if $data11 != @tb2@ then + return -1 +endi +if $data20 != @1.732050808@ then + return -1 +endi +if $data21 != @tb2@ then + return -1 +endi +if $data30 != @2.000000000@ then + return -1 +endi +if $data31 != @tb2@ then + return -1 +endi +if $data40 != @2.236067977@ then + return -1 +endi +if $data41 != @tb2@ then + return -1 +endi +if $data50 != @2.449489743@ then + return -1 +endi +if $data51 != @tb2@ then + return -1 +endi +if $data60 != @2.645751311@ then + return -1 +endi +if $data61 != @tb2@ then + return -1 +endi +print execute sql select sqrt(c8),sqrt(c9) from tbn; +sql_error select sqrt(c8),sqrt(c9) from tbn; +print execute sql select sqrt(c8),sqrt(c9) from tbn order by ts desc; +sql_error select sqrt(c8),sqrt(c9) from tbn order by ts desc; +print execute sql select sqrt(sqrt(c8)) from tbn; +sql_error select sqrt(sqrt(c8)) from tbn; +print execute sql select sqrt(a) from (select avg(c2) as a from stb1 interval(1s)); +sql select sqrt(a) from (select avg(c2) as a from stb1 interval(1s)); +if $data00 != @1.000000000@ then + return -1 +endi +if $data10 != @1.414213562@ then + return -1 +endi +if $data20 != @1.581138830@ then + return -1 +endi +if $data30 != @2.000000000@ then + return -1 +endi +if $data40 != @2.121320344@ then + return -1 +endi +if $data50 != @8.154753215@ then + return -1 +endi +if $data60 != @-nan@ then + return -1 +endi +print execute sql select sqrt(c2) from (select * from stb1); +sql select sqrt(c2) from (select * from stb1); +if $data00 != @1.000000000@ then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data20 != @1.414213562@ then + return -1 +endi +if $data30 != NULL then + return -1 +endi +if $data40 != @2.000000000@ then + return -1 +endi +if $data50 != @11.269427670@ then + return -1 +endi +if $data60 != @-nan@ then + return -1 +endi +if $data70 != @1.000000000@ then + return -1 +endi +if $data80 != @1.414213562@ then + return -1 +endi +if $data90 != @1.732050808@ then + return -1 +endi +print execute sql select sqrt(a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)); +sql select sqrt(a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)); +if $data00 != @1.000000000@ then + return -1 +endi +if $data10 != @1.414213562@ then + return -1 +endi +if $data20 != @1.581138830@ then + return -1 +endi +if $data30 != @2.000000000@ then + return -1 +endi +if $data40 != @2.121320344@ then + return -1 +endi +if $data50 != @8.154753215@ then + return -1 +endi +if $data60 != @-nan@ then + return -1 +endi +if $data70 != NULL then + return -1 +endi +if $data80 != NULL then + return -1 +endi +if $data90 != NULL then + return -1 +endi +print execute sql select sqrt(a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)) order by ts; +sql select sqrt(a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)) order by ts; +if $data00 != @1.000000000@ then + return -1 +endi +if $data10 != @1.414213562@ then + return -1 +endi +if $data20 != @1.581138830@ then + return -1 +endi +if $data30 != @2.000000000@ then + return -1 +endi +if $data40 != @2.121320344@ then + return -1 +endi +if $data50 != @8.154753215@ then + return -1 +endi +if $data60 != @-nan@ then + return -1 +endi +if $data70 != NULL then + return -1 +endi +if $data80 != NULL then + return -1 +endi +if $data90 != NULL then + return -1 +endi +print execute sql select sqrt(a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)) order by ts desc; +sql select sqrt(a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)) order by ts desc; +if $data00 != NULL then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data20 != NULL then + return -1 +endi +if $data30 != @-nan@ then + return -1 +endi +if $data40 != @8.154753215@ then + return -1 +endi +if $data50 != @2.121320344@ then + return -1 +endi +if $data60 != @2.000000000@ then + return -1 +endi +if $data70 != @1.581138830@ then + return -1 +endi +if $data80 != @1.414213562@ then + return -1 +endi +if $data90 != @1.000000000@ then + return -1 +endi +print execute sql select sqrt(a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)) order by a desc; +sql select sqrt(a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)) order by a desc; +if $data00 != NULL then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data20 != NULL then + return -1 +endi +if $data30 != @8.154753215@ then + return -1 +endi +if $data40 != @2.121320344@ then + return -1 +endi +if $data50 != @2.000000000@ then + return -1 +endi +if $data60 != @1.581138830@ then + return -1 +endi +if $data70 != @1.414213562@ then + return -1 +endi +if $data80 != @1.000000000@ then + return -1 +endi +if $data90 != @-nan@ then + return -1 +endi +print execute sql select sqrt(a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)) order by a; +sql select sqrt(a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)) order by a; +if $data00 != @-nan@ then + return -1 +endi +if $data10 != @1.000000000@ then + return -1 +endi +if $data20 != @1.414213562@ then + return -1 +endi +if $data30 != @1.581138830@ then + return -1 +endi +if $data40 != @2.000000000@ then + return -1 +endi +if $data50 != @2.121320344@ then + return -1 +endi +if $data60 != @8.154753215@ then + return -1 +endi +if $data70 != NULL then + return -1 +endi +if $data80 != NULL then + return -1 +endi +if $data90 != NULL then + return -1 +endi +print execute sql select sqrt(a) from (select sqrt(c2) as a from tb1); +sql select sqrt(a) from (select sqrt(c2) as a from tb1); +if $data00 != @1.000000000@ then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data20 != @1.189207115@ then + return -1 +endi +if $data30 != NULL then + return -1 +endi +if $data40 != @1.414213562@ then + return -1 +endi +if $data50 != @3.356996823@ then + return -1 +endi +if $data60 != @-nan@ then + return -1 +endi +print execute sql select sqrt(tb1.c3),sqrt(tb2.c3) from tb1,tb2 where tb1.ts=tb2.ts; +sql select sqrt(tb1.c3),sqrt(tb2.c3) from tb1,tb2 where tb1.ts=tb2.ts; +if $data00 != @1.000000000@ then + return -1 +endi +if $data01 != @1.000000000@ then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data11 != @1.414213562@ then + return -1 +endi +if $data20 != NULL then + return -1 +endi +if $data21 != @1.732050808@ then + return -1 +endi +if $data30 != @1.732050808@ then + return -1 +endi +if $data31 != @2.000000000@ then + return -1 +endi +if $data40 != @2.000000000@ then + return -1 +endi +if $data41 != @2.236067977@ then + return -1 +endi +if $data50 != @181.016573827@ then + return -1 +endi +if $data51 != @2.449489743@ then + return -1 +endi +if $data60 != @-nan@ then + return -1 +endi +if $data61 != @2.645751311@ then + return -1 +endi +print execute sql select sqrt(c3) from tb1 union all select sqrt(c3) from tb2; +sql select sqrt(c3) from tb1 union all select sqrt(c3) from tb2; +if $data00 != @1.000000000@ then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data20 != NULL then + return -1 +endi +if $data30 != @1.732050808@ then + return -1 +endi +if $data40 != @2.000000000@ then + return -1 +endi +if $data50 != @181.016573827@ then + return -1 +endi +if $data60 != @-nan@ then + return -1 +endi +if $data70 != @1.000000000@ then + return -1 +endi +if $data80 != @1.414213562@ then + return -1 +endi +if $data90 != @1.732050808@ then + return -1 +endi diff --git a/tests/script/general/compute/math_sqrt2.sim b/tests/script/general/compute/math_sqrt2.sim new file mode 100644 index 0000000000000000000000000000000000000000..8b0958881e7028368b486114b40f55001685d024 --- /dev/null +++ b/tests/script/general/compute/math_sqrt2.sim @@ -0,0 +1,366 @@ +sleep 100 +sql connect +sql use db; + +print execute sql select sqrt(stb1.c4),sqrt(stba.c5) from stb1,stba where stb1.t1=stba.t1 and stb1.ts=stba.ts; +sql select sqrt(stb1.c4),sqrt(stba.c5) from stb1,stba where stb1.t1=stba.t1 and stb1.ts=stba.ts; +if $data00 != @1.000000000@ then + return -1 +endi +if $data01 != @1.000000000@ then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data11 != @1.414213562@ then + return -1 +endi +if $data20 != @1.414213562@ then + return -1 +endi +if $data21 != @1.732050808@ then + return -1 +endi +if $data30 != NULL then + return -1 +endi +if $data31 != @2.000000000@ then + return -1 +endi +if $data40 != @2.000000000@ then + return -1 +endi +if $data41 != @2.236067977@ then + return -1 +endi +if $data50 != @46340.950001052@ then + return -1 +endi +if $data51 != @2.449489743@ then + return -1 +endi +if $data60 != @-nan@ then + return -1 +endi +if $data61 != @2.645751311@ then + return -1 +endi +print execute sql select sqrt(c4) as a from stb1 union all select sqrt(c5) as a from stba; +sql select sqrt(c4) as a from stb1 union all select sqrt(c5) as a from stba; +if $data00 != @1.000000000@ then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data20 != @1.414213562@ then + return -1 +endi +if $data30 != NULL then + return -1 +endi +if $data40 != @2.000000000@ then + return -1 +endi +if $data50 != @46340.950001052@ then + return -1 +endi +if $data60 != @-nan@ then + return -1 +endi +if $data70 != @1.000000000@ then + return -1 +endi +if $data80 != @1.414213562@ then + return -1 +endi +if $data90 != @1.414213562@ then + return -1 +endi +print execute sql select sqrt(c2) from stba; +sql select sqrt(c2) from stba; +if $data00 != @1.000000000@ then + return -1 +endi +if $data10 != @1.414213562@ then + return -1 +endi +if $data20 != @1.732050808@ then + return -1 +endi +if $data30 != @2.000000000@ then + return -1 +endi +if $data40 != @2.236067977@ then + return -1 +endi +if $data50 != @2.449489743@ then + return -1 +endi +if $data60 != @2.645751311@ then + return -1 +endi +if $data70 != @2.828427125@ then + return -1 +endi +if $data80 != @3.000000000@ then + return -1 +endi +if $data90 != @0.000000000@ then + return -1 +endi +print execute sql select sqrt(min(c2)) from tba1; +sql select sqrt(min(c2)) from tba1; +if $data00 != @0.000000000@ then + return -1 +endi +print execute sql select sqrt(max(c2)) from tba1; +sql select sqrt(max(c2)) from tba1; +if $data00 != @3.000000000@ then + return -1 +endi +print execute sql select sqrt(count(c2)) from tba1; +sql select sqrt(count(c2)) from tba1; +if $data00 != @5.477225575@ then + return -1 +endi +print execute sql select sqrt(sum(c2)) from tba1; +sql select sqrt(sum(c2)) from tba1; +if $data00 != @11.618950039@ then + return -1 +endi +print execute sql select sqrt(avg(c2)) from tba1; +sql select sqrt(avg(c2)) from tba1; +if $data00 != @2.121320344@ then + return -1 +endi +print execute sql select sqrt(percentile(c2, 10)) from tba1; +sql select sqrt(percentile(c2, 10)) from tba1; +if $data00 != @0.948683298@ then + return -1 +endi +print execute sql select sqrt(apercentile(c2, 10)) from tba1; +sql select sqrt(apercentile(c2, 10)) from tba1; +if $data00 != @0.000000000@ then + return -1 +endi +print execute sql select sqrt(stddev(c2)) from tba1; +sql select sqrt(stddev(c2)) from tba1; +if $data00 != @1.694780612@ then + return -1 +endi +print execute sql select sqrt(spread(c2)) from tba1; +sql select sqrt(spread(c2)) from tba1; +if $data00 != @3.000000000@ then + return -1 +endi +print execute sql select sqrt(twa(c2)) from tba1; +sql select sqrt(twa(c2)) from tba1; +if $data00 != @2.153585623@ then + return -1 +endi +print execute sql select sqrt(leastsquares(c2, 1, 1)) from tba1; +sql_error select sqrt(leastsquares(c2, 1, 1)) from tba1; +print execute sql select sqrt(interp(c2)) from tba1 every(1s) +sql select sqrt(interp(c2)) from tba1 every(1s) +if $data00 != @21-11-11 09:00:00.000@ then + return -1 +endi +if $data01 != @1.000000000@ then + return -1 +endi +if $data10 != @21-11-11 09:00:01.000@ then + return -1 +endi +if $data11 != @1.414213562@ then + return -1 +endi +if $data20 != @21-11-11 09:00:02.000@ then + return -1 +endi +if $data21 != @1.732050808@ then + return -1 +endi +if $data30 != @21-11-11 09:00:03.000@ then + return -1 +endi +if $data31 != @2.000000000@ then + return -1 +endi +if $data40 != @21-11-11 09:00:04.000@ then + return -1 +endi +if $data41 != @2.236067977@ then + return -1 +endi +if $data50 != @21-11-11 09:00:05.000@ then + return -1 +endi +if $data51 != @2.449489743@ then + return -1 +endi +if $data60 != @21-11-11 09:00:06.000@ then + return -1 +endi +if $data61 != @2.645751311@ then + return -1 +endi +if $data70 != @21-11-11 09:00:07.000@ then + return -1 +endi +if $data71 != @2.828427125@ then + return -1 +endi +if $data80 != @21-11-11 09:00:08.000@ then + return -1 +endi +if $data81 != @3.000000000@ then + return -1 +endi +if $data90 != @21-11-11 09:00:09.000@ then + return -1 +endi +if $data91 != @0.000000000@ then + return -1 +endi +print execute sql select sqrt(interp(c2)) from stba every(1s) group by tbname; +sql select sqrt(interp(c2)) from stba every(1s) group by tbname; +if $data00 != @21-11-11 09:00:00.000@ then + return -1 +endi +if $data01 != @1.000000000@ then + return -1 +endi +if $data02 != @tba1@ then + return -1 +endi +if $data10 != @21-11-11 09:00:01.000@ then + return -1 +endi +if $data11 != @1.414213562@ then + return -1 +endi +if $data12 != @tba1@ then + return -1 +endi +if $data20 != @21-11-11 09:00:02.000@ then + return -1 +endi +if $data21 != @1.732050808@ then + return -1 +endi +if $data22 != @tba1@ then + return -1 +endi +if $data30 != @21-11-11 09:00:03.000@ then + return -1 +endi +if $data31 != @2.000000000@ then + return -1 +endi +if $data32 != @tba1@ then + return -1 +endi +if $data40 != @21-11-11 09:00:04.000@ then + return -1 +endi +if $data41 != @2.236067977@ then + return -1 +endi +if $data42 != @tba1@ then + return -1 +endi +if $data50 != @21-11-11 09:00:05.000@ then + return -1 +endi +if $data51 != @2.449489743@ then + return -1 +endi +if $data52 != @tba1@ then + return -1 +endi +if $data60 != @21-11-11 09:00:06.000@ then + return -1 +endi +if $data61 != @2.645751311@ then + return -1 +endi +if $data62 != @tba1@ then + return -1 +endi +if $data70 != @21-11-11 09:00:07.000@ then + return -1 +endi +if $data71 != @2.828427125@ then + return -1 +endi +if $data72 != @tba1@ then + return -1 +endi +if $data80 != @21-11-11 09:00:08.000@ then + return -1 +endi +if $data81 != @3.000000000@ then + return -1 +endi +if $data82 != @tba1@ then + return -1 +endi +if $data90 != @21-11-11 09:00:09.000@ then + return -1 +endi +if $data91 != @0.000000000@ then + return -1 +endi +if $data92 != @tba1@ then + return -1 +endi +print execute sql select sqrt(elapsed(ts)) from tba1; +sql select sqrt(elapsed(ts)) from tba1; +if $data00 != @170.293863659@ then + return -1 +endi +print execute sql select sqrt(rate(c2)) from tba1; +sql select sqrt(rate(c2)) from tba1; +if $data00 != @0.946864153@ then + return -1 +endi +print execute sql select sqrt(irate(c2)) from tba1; +sql select sqrt(irate(c2)) from tba1; +if $data00 != @0.000000000@ then + return -1 +endi +print execute sql select sqrt(first(c2)) from tba1; +sql select sqrt(first(c2)) from tba1; +if $data00 != @1.000000000@ then + return -1 +endi +print execute sql select sqrt(last(c2)) from tba1; +sql select sqrt(last(c2)) from tba1; +if $data00 != @0.000000000@ then + return -1 +endi +print execute sql select sqrt(last_row(c2)) from tba1; +sql select sqrt(last_row(c2)) from tba1; +if $data00 != @0.000000000@ then + return -1 +endi +print execute sql select sqrt(top(c2, 1)) from tba1; +sql_error select sqrt(top(c2, 1)) from tba1; +print execute sql select sqrt(bottom(c2, 1)) from tba1; +sql_error select sqrt(bottom(c2, 1)) from tba1; +print execute sql select sqrt(leastsquares(c2, 1, 1)) from tba1; +sql_error select sqrt(leastsquares(c2, 1, 1)) from tba1; +print execute sql select sqrt(derivative(c2, 1s, 0)) from tba1; +sql_error select sqrt(derivative(c2, 1s, 0)) from tba1; +print execute sql select sqrt(diff(c2)) from tba1; +sql_error select sqrt(diff(c2)) from tba1; +print execute sql select sqrt(csum(c2)) from tba1; +sql_error select sqrt(csum(c2)) from tba1; +print execute sql select sqrt(mavg(c2,2)) from tba1; +sql_error select sqrt(mavg(c2,2)) from tba1; +print execute sql select sqrt(sample(c2,2)) from tba1; +sql_error select sqrt(sample(c2,2)) from tba1; +print execute sql select sqrt(_block_dist()) from tba1; +sql_error select sqrt(_block_dist()) from tba1; diff --git a/tests/script/general/compute/math_tan.sim b/tests/script/general/compute/math_tan.sim new file mode 100644 index 0000000000000000000000000000000000000000..d6f3a99230a716ef750e38c7f8e491e15dafc2fc --- /dev/null +++ b/tests/script/general/compute/math_tan.sim @@ -0,0 +1,1073 @@ +sleep 100 +sql connect +sql use db + +print execute sql select tan(*) from tb1; +sql_error select tan(*) from tb1; +print execute sql select tan(*) from tb1; +sql_error select tan(*) from tb1; +print execute sql select tan(*) from tb1; +sql_error select tan(*) from tb1; +print execute sql select tan(*) from tb1; +sql_error select tan(*) from tb1; +print execute sql select tan(*) as a from tb1; +sql_error select tan(*) as a from tb1; +print execute sql select tan(*) + 1 as a from tb1; +sql_error select tan(*) + 1 as a from tb1; +print execute sql select tan(tb1.*) + 1 as a from tb1; +sql_error select tan(tb1.*) + 1 as a from tb1; +print execute sql select tan(*) from tb1; +sql_error select tan(*) from tb1; +print execute sql select tan(c1) from tb1; +sql_error select tan(c1) from tb1; +print execute sql select tan(c1) from tb1; +sql_error select tan(c1) from tb1; +print execute sql select tan(c1 + c2) from tb1; +sql_error select tan(c1 + c2) from tb1; +print execute sql select tan(13) from tb1; +sql select tan(13) from tb1; +if $data00 != @0.463021133@ then + return -1 +endi +if $data10 != @0.463021133@ then + return -1 +endi +if $data20 != @0.463021133@ then + return -1 +endi +if $data30 != @0.463021133@ then + return -1 +endi +if $data40 != @0.463021133@ then + return -1 +endi +if $data50 != @0.463021133@ then + return -1 +endi +if $data60 != @0.463021133@ then + return -1 +endi +print execute sql select tan(c1) from tb1; +sql_error select tan(c1) from tb1; +print execute sql select tan(c2) from tb1; +sql select tan(c2) from tb1; +if $data00 != @1.557407725@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data20 != @-2.185039863@ then + return -1 +endi +if $data30 != @NULL@ then + return -1 +endi +if $data40 != @1.157821282@ then + return -1 +endi +if $data50 != @4.185891832@ then + return -1 +endi +if $data60 != @-4.185891832@ then + return -1 +endi +print execute sql select tan(c3) from tb1; +sql select tan(c3) from tb1; +if $data00 != @1.557407725@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data20 != @NULL@ then + return -1 +endi +if $data30 != @-0.142546543@ then + return -1 +endi +if $data40 != @1.157821282@ then + return -1 +endi +if $data50 != @0.190892344@ then + return -1 +endi +if $data60 != @-0.190892344@ then + return -1 +endi +print execute sql select tan(c4) from tb1; +sql select tan(c4) from tb1; +if $data00 != @1.557407725@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data20 != @-2.185039863@ then + return -1 +endi +if $data30 != @NULL@ then + return -1 +endi +if $data40 != @1.157821282@ then + return -1 +endi +if $data50 != @1.052377964@ then + return -1 +endi +if $data60 != @-1.052377964@ then + return -1 +endi +print execute sql select tan(c5) from tb1; +sql select tan(c5) from tb1; +if $data00 != @1.557407725@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data20 != @NULL@ then + return -1 +endi +if $data30 != @-0.142546543@ then + return -1 +endi +if $data40 != @1.157821282@ then + return -1 +endi +if $data50 != @84.739312969@ then + return -1 +endi +if $data60 != @-84.739312969@ then + return -1 +endi +print execute sql select tan(c6) from tb1; +sql select tan(c6) from tb1; +if $data00 != @1.557407725@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data20 != @-2.185039863@ then + return -1 +endi +if $data30 != @NULL@ then + return -1 +endi +if $data40 != @1.157821282@ then + return -1 +endi +if $data50 != @-0.611797950@ then + return -1 +endi +if $data60 != @0.611797950@ then + return -1 +endi +print execute sql select tan(c7) from tb1; +sql select tan(c7) from tb1; +if $data00 != @1.557407725@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data20 != @NULL@ then + return -1 +endi +if $data30 != @-0.142546543@ then + return -1 +endi +if $data40 != @1.157821282@ then + return -1 +endi +if $data50 != @1.788490683@ then + return -1 +endi +if $data60 != @-1.788490683@ then + return -1 +endi +print execute sql select tan(c8) from tb1; +sql_error select tan(c8) from tb1; +print execute sql select tan(c9) from tb1; +sql_error select tan(c9) from tb1; +print execute sql select tan(c10) from tb1; +sql select tan(c10) from tb1; +if $data00 != @1.557407725@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data20 != @-2.185039863@ then + return -1 +endi +if $data30 != @NULL@ then + return -1 +endi +if $data40 != @1.157821282@ then + return -1 +endi +if $data50 != @-0.506714715@ then + return -1 +endi +if $data60 != @0.000000000@ then + return -1 +endi +print execute sql select tan(c11) from tb1; +sql select tan(c11) from tb1; +if $data00 != @1.557407725@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data20 != @NULL@ then + return -1 +endi +if $data30 != @-0.142546543@ then + return -1 +endi +if $data40 != @1.157821282@ then + return -1 +endi +if $data50 != @0.396223010@ then + return -1 +endi +if $data60 != @0.000000000@ then + return -1 +endi +print execute sql select tan(c12) from tb1; +sql select tan(c12) from tb1; +if $data00 != @1.557407725@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data20 != @-2.185039863@ then + return -1 +endi +if $data30 != @NULL@ then + return -1 +endi +if $data40 != @1.157821282@ then + return -1 +endi +if $data50 != @-19.579238092@ then + return -1 +endi +if $data60 != @0.000000000@ then + return -1 +endi +print execute sql select tan(c13) from tb1; +sql select tan(c13) from tb1; +if $data00 != @1.557407725@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data20 != @NULL@ then + return -1 +endi +if $data30 != @-0.142546543@ then + return -1 +endi +if $data40 != @1.157821282@ then + return -1 +endi +if $data50 != @84.739312969@ then + return -1 +endi +if $data60 != @0.000000000@ then + return -1 +endi +print execute sql select tan(12345678900000000000000000) from tb1; +sql_error select tan(12345678900000000000000000) from tb1; +print execute sql select distinct tan(123) from tb1; +sql_error select distinct tan(123) from tb1; +print execute sql select tan(t1) from stb1; +sql_error select tan(t1) from stb1; +print execute sql select tan(c1),avg(c3) from tb1; +sql_error select tan(c1),avg(c3) from tb1; +print execute sql select tan(c1),top(c3,1) from tb1; +sql_error select tan(c1),top(c3,1) from tb1; +print execute sql select tan(c2+c3) from tb1 session(ts, 1s); +sql_error select tan(c2+c3) from tb1 session(ts, 1s); +print execute sql select tan(c2+c3) from tb1 STATE_WINDOW(c1); +sql_error select tan(c2+c3) from tb1 STATE_WINDOW(c1); +print execute sql select tan(c2+c3) from tb1 interval(1s) sliding(1s) fill(NULL); +sql_error select tan(c2+c3) from tb1 interval(1s) sliding(1s) fill(NULL); +print execute sql select tan(c2+c3) from stb1 group by t1; +sql_error select tan(c2+c3) from stb1 group by t1; +print execute sql select tan(c2+c3) from stb1 group by ts; +sql_error select tan(c2+c3) from stb1 group by ts; +print execute sql select tan(c2+c3) from stb1 group by c1; +sql_error select tan(c2+c3) from stb1 group by c1; +print execute sql select tan(c2+c3) from stb1 group by tbname; +sql_error select tan(c2+c3) from stb1 group by tbname; +print execute sql select tan(c2+c3) from tb1 order by c2; +sql_error select tan(c2+c3) from tb1 order by c2; +print execute sql select tan(c8),tan(c9) from tbn; +sql_error select tan(c8),tan(c9) from tbn; +print execute sql select tan(ts) from (select avg(c2) as a from stb1 interval(1s)); +sql_error select tan(ts) from (select avg(c2) as a from stb1 interval(1s)); +print execute sql select tan(a) from (select tan(c2) as a from tb1); +sql select tan(a) from (select tan(c2) as a from tb1); +if $data00 != @74.685933399@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data20 != @1.417928576@ then + return -1 +endi +if $data30 != @NULL@ then + return -1 +endi +if $data40 != @2.282204450@ then + return -1 +endi +if $data50 != @1.720515194@ then + return -1 +endi +if $data60 != @-1.720515194@ then + return -1 +endi +print execute sql select tan("abc") from tb1; +sql_error select tan("abc") from tb1; +print execute sql select tan(c2 + c3) from tb1; +sql select tan(c2 + c3) from tb1; +if $data00 != @-2.185039863@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data20 != @NULL@ then + return -1 +endi +if $data30 != @NULL@ then + return -1 +endi +if $data40 != @-6.799711455@ then + return -1 +endi +if $data50 != @21.780973629@ then + return -1 +endi +if $data60 != @-21.780973629@ then + return -1 +endi +print execute sql select tan((c2 + c3)) from tb1; +sql select tan((c2 + c3)) from tb1; +if $data00 != @-2.185039863@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data20 != @NULL@ then + return -1 +endi +if $data30 != @NULL@ then + return -1 +endi +if $data40 != @-6.799711455@ then + return -1 +endi +if $data50 != @21.780973629@ then + return -1 +endi +if $data60 != @-21.780973629@ then + return -1 +endi +print execute sql select tan((c2 * c3)+c4-6) from tb1; +sql select tan((c2 * c3)+c4-6) from tb1; +if $data00 != @-1.157821282@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data20 != @NULL@ then + return -1 +endi +if $data30 != @NULL@ then + return -1 +endi +if $data40 != @7.244606616@ then + return -1 +endi +if $data50 != @-0.083708953@ then + return -1 +endi +if $data60 != @7.387587308@ then + return -1 +endi +print execute sql select tan(11)+c2 from tb1; +sql select tan(11)+c2 from tb1; +if $data00 != @-224.950846454@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data20 != @-223.950846454@ then + return -1 +endi +if $data30 != @NULL@ then + return -1 +endi +if $data40 != @-221.950846454@ then + return -1 +endi +if $data50 != @-98.950846454@ then + return -1 +endi +if $data60 != @-352.950846454@ then + return -1 +endi +print execute sql select tan(c1)+c2 from tb1; +sql_error select tan(c1)+c2 from tb1; +print execute sql select tan(c2)+11 from tb1; +sql select tan(c2)+11 from tb1; +if $data00 != @12.557407725@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data20 != @8.814960137@ then + return -1 +endi +if $data30 != @NULL@ then + return -1 +endi +if $data40 != @12.157821282@ then + return -1 +endi +if $data50 != @15.185891832@ then + return -1 +endi +if $data60 != @6.814108168@ then + return -1 +endi +print execute sql select tan(c1),c1,c2 from tb1; +sql_error select tan(c1),c1,c2 from tb1; +print execute sql select tan(c1),t1,ts,tbname,_C0,_c0 from tb1; +sql_error select tan(c1),t1,ts,tbname,_C0,_c0 from tb1; +print execute sql select tan(c1),floor(c3) from tb1; +sql_error select tan(c1),floor(c3) from tb1; +print execute sql select tan(c1),tan(c2+c3) from tb1; +sql_error select tan(c1),tan(c2+c3) from tb1; +print execute sql select tan(c2+c3) from tb1 where c2 is not null and c3 is not null; +sql select tan(c2+c3) from tb1 where c2 is not null and c3 is not null; +if $data00 != @-2.185039863@ then + return -1 +endi +if $data10 != @-6.799711455@ then + return -1 +endi +if $data20 != @21.780973629@ then + return -1 +endi +if $data30 != @-21.780973629@ then + return -1 +endi +print execute sql select tan(c2) from tb1 order by ts desc; +sql select tan(c2) from tb1 order by ts desc; +if $data00 != @-4.185891832@ then + return -1 +endi +if $data10 != @4.185891832@ then + return -1 +endi +if $data20 != @1.157821282@ then + return -1 +endi +if $data30 != @NULL@ then + return -1 +endi +if $data40 != @-2.185039863@ then + return -1 +endi +if $data50 != @NULL@ then + return -1 +endi +if $data60 != @1.557407725@ then + return -1 +endi +print execute sql select tan(c2+c3) from tb1 order by ts desc; +sql select tan(c2+c3) from tb1 order by ts desc; +if $data00 != @-21.780973629@ then + return -1 +endi +if $data10 != @21.780973629@ then + return -1 +endi +if $data20 != @-6.799711455@ then + return -1 +endi +if $data30 != @NULL@ then + return -1 +endi +if $data40 != @NULL@ then + return -1 +endi +if $data50 != @NULL@ then + return -1 +endi +if $data60 != @-2.185039863@ then + return -1 +endi +print execute sql select tan(c2+c3) from tb1 order by ts desc limit 3 offset 2; +sql select tan(c2+c3) from tb1 order by ts desc limit 3 offset 2; +if $data00 != @-6.799711455@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data20 != @NULL@ then + return -1 +endi +print execute sql select tan(c2) from stb1; +sql select tan(c2) from stb1; +if $data00 != @1.557407725@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data20 != @-2.185039863@ then + return -1 +endi +if $data30 != @NULL@ then + return -1 +endi +if $data40 != @1.157821282@ then + return -1 +endi +if $data50 != @4.185891832@ then + return -1 +endi +if $data60 != @-4.185891832@ then + return -1 +endi +if $data70 != @1.557407725@ then + return -1 +endi +if $data80 != @-2.185039863@ then + return -1 +endi +if $data90 != @-0.142546543@ then + return -1 +endi +print execute sql select tan(c2) from stb1 order by ts desc; +sql select tan(c2) from stb1 order by ts desc; +if $data00 != @0.871447983@ then + if $data00 != @-4.185891832@ then + return -1 + endi +endi +if $data20 != @-0.291006191@ then + if $data20 != @4.185891832@ then + return -1 + endi +endi +if $data40 != @-3.380515006@ then + if $data40 != @1.157821282@ then + return -1 + endi +endi +if $data60 != @1.157821282@ then + if $data60 != @NULL@ then + return -1 + endi +endi +if $data80 != @-0.142546543@ then + if $data80 != @-2.185039863@ then + return -1 + endi +endi +print execute sql select tan(c4),t1 from stb1 order by ts desc; +sql select tan(c4),t1 from stb1 order by ts desc; +if $data00 != @0.871447983@ then + if $data00 != @-1.052377964@ then + return -1 + endi +endi +if $data01 != @2@ then + if $data01 != @1@ then + return -1 + endi +endi +if $data20 != @-0.291006191@ then + if $data20 != @1.052377964@ then + return -1 + endi +endi +if $data21 != @2@ then + if $data21 != @1@ then + return -1 + endi +endi +if $data40 != @-3.380515006@ then + if $data40 != @1.157821282@ then + return -1 + endi +endi +if $data41 != @2@ then + if $data41 != @1@ then + return -1 + endi +endi +if $data60 != @1.157821282@ then + if $data60 != @NULL@ then + return -1 + endi +endi +if $data61 != @2@ then + if $data61 != @1@ then + return -1 + endi +endi +if $data80 != @-2.185039863@ then + if $data80 != @-2.185039863@ then + return -1 + endi +endi +if $data81 != @2@ then + if $data81 != @1@ then + return -1 + endi +endi +print execute sql select tan(c3),tbname from stb1; +sql select tan(c3),tbname from stb1; +if $data00 != @1.557407725@ then + return -1 +endi +if $data01 != @tb1@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data11 != @tb1@ then + return -1 +endi +if $data20 != @NULL@ then + return -1 +endi +if $data21 != @tb1@ then + return -1 +endi +if $data30 != @-0.142546543@ then + return -1 +endi +if $data31 != @tb1@ then + return -1 +endi +if $data40 != @1.157821282@ then + return -1 +endi +if $data41 != @tb1@ then + return -1 +endi +if $data50 != @0.190892344@ then + return -1 +endi +if $data51 != @tb1@ then + return -1 +endi +if $data60 != @-0.190892344@ then + return -1 +endi +if $data61 != @tb1@ then + return -1 +endi +if $data70 != @1.557407725@ then + return -1 +endi +if $data71 != @tb2@ then + return -1 +endi +if $data80 != @-2.185039863@ then + return -1 +endi +if $data81 != @tb2@ then + return -1 +endi +if $data90 != @-0.142546543@ then + return -1 +endi +if $data91 != @tb2@ then + return -1 +endi +print execute sql select tan(c3),tbname from stb1 where t1 > 1; +sql select tan(c3),tbname from stb1 where t1 > 1; +if $data00 != @1.557407725@ then + return -1 +endi +if $data01 != @tb2@ then + return -1 +endi +if $data10 != @-2.185039863@ then + return -1 +endi +if $data11 != @tb2@ then + return -1 +endi +if $data20 != @-0.142546543@ then + return -1 +endi +if $data21 != @tb2@ then + return -1 +endi +if $data30 != @1.157821282@ then + return -1 +endi +if $data31 != @tb2@ then + return -1 +endi +if $data40 != @-3.380515006@ then + return -1 +endi +if $data41 != @tb2@ then + return -1 +endi +if $data50 != @-0.291006191@ then + return -1 +endi +if $data51 != @tb2@ then + return -1 +endi +if $data60 != @0.871447983@ then + return -1 +endi +if $data61 != @tb2@ then + return -1 +endi +print execute sql select tan(c8),tan(c9) from tbn; +sql_error select tan(c8),tan(c9) from tbn; +print execute sql select tan(c8),tan(c9) from tbn order by ts desc; +sql_error select tan(c8),tan(c9) from tbn order by ts desc; +print execute sql select tan(tan(c8)) from tbn; +sql_error select tan(tan(c8)) from tbn; +print execute sql select tan(a) from (select avg(c2) as a from stb1 interval(1s)); +sql select tan(a) from (select avg(c2) as a from stb1 interval(1s)); +if $data00 != @1.557407725@ then + return -1 +endi +if $data10 != @-2.185039863@ then + return -1 +endi +if $data20 != @-0.747022297@ then + return -1 +endi +if $data30 != @1.157821282@ then + return -1 +endi +if $data40 != @4.637332055@ then + return -1 +endi +if $data50 != @0.581297682@ then + return -1 +endi +if $data60 != @-0.320040389@ then + return -1 +endi +print execute sql select tan(c2) from (select * from stb1); +sql select tan(c2) from (select * from stb1); +if $data00 != @1.557407725@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data20 != @-2.185039863@ then + return -1 +endi +if $data30 != @NULL@ then + return -1 +endi +if $data40 != @1.157821282@ then + return -1 +endi +if $data50 != @4.185891832@ then + return -1 +endi +if $data60 != @-4.185891832@ then + return -1 +endi +if $data70 != @1.557407725@ then + return -1 +endi +if $data80 != @-2.185039863@ then + return -1 +endi +if $data90 != @-0.142546543@ then + return -1 +endi +print execute sql select tan(a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)); +sql select tan(a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)); +if $data00 != @1.557407725@ then + return -1 +endi +if $data10 != @-2.185039863@ then + return -1 +endi +if $data20 != @-0.747022297@ then + return -1 +endi +if $data30 != @1.157821282@ then + return -1 +endi +if $data40 != @4.637332055@ then + return -1 +endi +if $data50 != @0.581297682@ then + return -1 +endi +if $data60 != @-0.320040389@ then + return -1 +endi +if $data70 != @NULL@ then + return -1 +endi +if $data80 != @NULL@ then + return -1 +endi +if $data90 != @NULL@ then + return -1 +endi +print execute sql select tan(a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)) order by ts; +sql select tan(a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)) order by ts; +if $data00 != @1.557407725@ then + return -1 +endi +if $data10 != @-2.185039863@ then + return -1 +endi +if $data20 != @-0.747022297@ then + return -1 +endi +if $data30 != @1.157821282@ then + return -1 +endi +if $data40 != @4.637332055@ then + return -1 +endi +if $data50 != @0.581297682@ then + return -1 +endi +if $data60 != @-0.320040389@ then + return -1 +endi +if $data70 != @NULL@ then + return -1 +endi +if $data80 != @NULL@ then + return -1 +endi +if $data90 != @NULL@ then + return -1 +endi +print execute sql select tan(a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)) order by ts desc; +sql select tan(a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)) order by ts desc; +if $data00 != @NULL@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data20 != @NULL@ then + return -1 +endi +if $data30 != @-0.320040389@ then + return -1 +endi +if $data40 != @0.581297682@ then + return -1 +endi +if $data50 != @4.637332055@ then + return -1 +endi +if $data60 != @1.157821282@ then + return -1 +endi +if $data70 != @-0.747022297@ then + return -1 +endi +if $data80 != @-2.185039863@ then + return -1 +endi +if $data90 != @1.557407725@ then + return -1 +endi +print execute sql select tan(a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)) order by a desc; +sql select tan(a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)) order by a desc; +if $data00 != @NULL@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data20 != @NULL@ then + return -1 +endi +if $data30 != @0.581297682@ then + return -1 +endi +if $data40 != @4.637332055@ then + return -1 +endi +if $data50 != @1.157821282@ then + return -1 +endi +if $data60 != @-0.747022297@ then + return -1 +endi +if $data70 != @-2.185039863@ then + return -1 +endi +if $data80 != @1.557407725@ then + return -1 +endi +if $data90 != @-0.320040389@ then + return -1 +endi +print execute sql select tan(a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)) order by a; +sql select tan(a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)) order by a; +if $data00 != @-0.320040389@ then + return -1 +endi +if $data10 != @1.557407725@ then + return -1 +endi +if $data20 != @-2.185039863@ then + return -1 +endi +if $data30 != @-0.747022297@ then + return -1 +endi +if $data40 != @1.157821282@ then + return -1 +endi +if $data50 != @4.637332055@ then + return -1 +endi +if $data60 != @0.581297682@ then + return -1 +endi +if $data70 != @NULL@ then + return -1 +endi +if $data80 != @NULL@ then + return -1 +endi +if $data90 != @NULL@ then + return -1 +endi +print execute sql select tan(a) from (select tan(c2) as a from tb1); +sql select tan(a) from (select tan(c2) as a from tb1); +if $data00 != @74.685933399@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data20 != @1.417928576@ then + return -1 +endi +if $data30 != @NULL@ then + return -1 +endi +if $data40 != @2.282204450@ then + return -1 +endi +if $data50 != @1.720515194@ then + return -1 +endi +if $data60 != @-1.720515194@ then + return -1 +endi +print execute sql select tan(tb1.c3),tan(tb2.c3) from tb1,tb2 where tb1.ts=tb2.ts; +sql select tan(tb1.c3),tan(tb2.c3) from tb1,tb2 where tb1.ts=tb2.ts; +if $data00 != @1.557407725@ then + return -1 +endi +if $data01 != @1.557407725@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data11 != @-2.185039863@ then + return -1 +endi +if $data20 != @NULL@ then + return -1 +endi +if $data21 != @-0.142546543@ then + return -1 +endi +if $data30 != @-0.142546543@ then + return -1 +endi +if $data31 != @1.157821282@ then + return -1 +endi +if $data40 != @1.157821282@ then + return -1 +endi +if $data41 != @-3.380515006@ then + return -1 +endi +if $data50 != @0.190892344@ then + return -1 +endi +if $data51 != @-0.291006191@ then + return -1 +endi +if $data60 != @-0.190892344@ then + return -1 +endi +if $data61 != @0.871447983@ then + return -1 +endi +print execute sql select tan(c3) from tb1 union all select tan(c3) from tb2; +sql select tan(c3) from tb1 union all select tan(c3) from tb2; +if $data00 != @1.557407725@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data20 != @NULL@ then + return -1 +endi +if $data30 != @-0.142546543@ then + return -1 +endi +if $data40 != @1.157821282@ then + return -1 +endi +if $data50 != @0.190892344@ then + return -1 +endi +if $data60 != @-0.190892344@ then + return -1 +endi +if $data70 != @1.557407725@ then + return -1 +endi +if $data80 != @-2.185039863@ then + return -1 +endi +if $data90 != @-0.142546543@ then + return -1 +endi diff --git a/tests/script/general/compute/math_tan2.sim b/tests/script/general/compute/math_tan2.sim new file mode 100644 index 0000000000000000000000000000000000000000..23e4803c6d9c6e8d09eed5bbaac8f3df44287d00 --- /dev/null +++ b/tests/script/general/compute/math_tan2.sim @@ -0,0 +1,366 @@ +sleep 100 +sql connect +sql use db + +print execute sql select tan(stb1.c4),tan(stba.c5) from stb1,stba where stb1.t1=stba.t1 and stb1.ts=stba.ts; +sql select tan(stb1.c4),tan(stba.c5) from stb1,stba where stb1.t1=stba.t1 and stb1.ts=stba.ts; +if $data00 != @1.557407725@ then + return -1 +endi +if $data01 != @1.557407725@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data11 != @-2.185039863@ then + return -1 +endi +if $data20 != @-2.185039863@ then + return -1 +endi +if $data21 != @-0.142546543@ then + return -1 +endi +if $data30 != @NULL@ then + return -1 +endi +if $data31 != @1.157821282@ then + return -1 +endi +if $data40 != @1.157821282@ then + return -1 +endi +if $data41 != @-3.380515006@ then + return -1 +endi +if $data50 != @1.052377964@ then + return -1 +endi +if $data51 != @-0.291006191@ then + return -1 +endi +if $data60 != @-1.052377964@ then + return -1 +endi +if $data61 != @0.871447983@ then + return -1 +endi +print execute sql select tan(c4) as a from stb1 union all select tan(c5) as a from stba; +sql select tan(c4) as a from stb1 union all select tan(c5) as a from stba; +if $data00 != @1.557407725@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data20 != @-2.185039863@ then + return -1 +endi +if $data30 != @NULL@ then + return -1 +endi +if $data40 != @1.157821282@ then + return -1 +endi +if $data50 != @1.052377964@ then + return -1 +endi +if $data60 != @-1.052377964@ then + return -1 +endi +if $data70 != @1.557407725@ then + return -1 +endi +if $data80 != @-2.185039863@ then + return -1 +endi +if $data90 != @-2.185039863@ then + return -1 +endi +print execute sql select tan(c2) from stba; +sql select tan(c2) from stba; +if $data00 != @1.557407725@ then + return -1 +endi +if $data10 != @-2.185039863@ then + return -1 +endi +if $data20 != @-0.142546543@ then + return -1 +endi +if $data30 != @1.157821282@ then + return -1 +endi +if $data40 != @-3.380515006@ then + return -1 +endi +if $data50 != @-0.291006191@ then + return -1 +endi +if $data60 != @0.871447983@ then + return -1 +endi +if $data70 != @-6.799711455@ then + return -1 +endi +if $data80 != @-0.452315659@ then + return -1 +endi +if $data90 != @0.000000000@ then + return -1 +endi +print execute sql select tan(min(c2)) from tba1; +sql select tan(min(c2)) from tba1; +if $data00 != @0.000000000@ then + return -1 +endi +print execute sql select tan(max(c2)) from tba1; +sql select tan(max(c2)) from tba1; +if $data00 != @-0.452315659@ then + return -1 +endi +print execute sql select tan(count(c2)) from tba1; +sql select tan(count(c2)) from tba1; +if $data00 != @-6.405331197@ then + return -1 +endi +print execute sql select tan(sum(c2)) from tba1; +sql select tan(sum(c2)) from tba1; +if $data00 != @-0.088715757@ then + return -1 +endi +print execute sql select tan(avg(c2)) from tba1; +sql select tan(avg(c2)) from tba1; +if $data00 != @4.637332055@ then + return -1 +endi +print execute sql select tan(percentile(c2, 10)) from tba1; +sql select tan(percentile(c2, 10)) from tba1; +if $data00 != @1.260158218@ then + return -1 +endi +print execute sql select tan(apercentile(c2, 10)) from tba1; +sql select tan(apercentile(c2, 10)) from tba1; +if $data00 != @0.000000000@ then + return -1 +endi +print execute sql select tan(stddev(c2)) from tba1; +sql select tan(stddev(c2)) from tba1; +if $data00 != @-0.276016859@ then + return -1 +endi +print execute sql select tan(spread(c2)) from tba1; +sql select tan(spread(c2)) from tba1; +if $data00 != @-0.452315659@ then + return -1 +endi +print execute sql select tan(twa(c2)) from tba1; +sql select tan(twa(c2)) from tba1; +if $data00 != @13.405571552@ then + return -1 +endi +print execute sql select tan(leastsquares(c2, 1, 1)) from tba1; +sql_error select tan(leastsquares(c2, 1, 1)) from tba1; +print execute sql select tan(interp(c2)) from tba1 every(1s) +sql select tan(interp(c2)) from tba1 every(1s) +if $data00 != @21-11-11 09:00:00.000@ then + return -1 +endi +if $data01 != @1.557407725@ then + return -1 +endi +if $data10 != @21-11-11 09:00:01.000@ then + return -1 +endi +if $data11 != @-2.185039863@ then + return -1 +endi +if $data20 != @21-11-11 09:00:02.000@ then + return -1 +endi +if $data21 != @-0.142546543@ then + return -1 +endi +if $data30 != @21-11-11 09:00:03.000@ then + return -1 +endi +if $data31 != @1.157821282@ then + return -1 +endi +if $data40 != @21-11-11 09:00:04.000@ then + return -1 +endi +if $data41 != @-3.380515006@ then + return -1 +endi +if $data50 != @21-11-11 09:00:05.000@ then + return -1 +endi +if $data51 != @-0.291006191@ then + return -1 +endi +if $data60 != @21-11-11 09:00:06.000@ then + return -1 +endi +if $data61 != @0.871447983@ then + return -1 +endi +if $data70 != @21-11-11 09:00:07.000@ then + return -1 +endi +if $data71 != @-6.799711455@ then + return -1 +endi +if $data80 != @21-11-11 09:00:08.000@ then + return -1 +endi +if $data81 != @-0.452315659@ then + return -1 +endi +if $data90 != @21-11-11 09:00:09.000@ then + return -1 +endi +if $data91 != @0.000000000@ then + return -1 +endi +print execute sql select tan(interp(c2)) from stba every(1s) group by tbname; +sql select tan(interp(c2)) from stba every(1s) group by tbname; +if $data00 != @21-11-11 09:00:00.000@ then + return -1 +endi +if $data01 != @1.557407725@ then + return -1 +endi +if $data02 != @tba1@ then + return -1 +endi +if $data10 != @21-11-11 09:00:01.000@ then + return -1 +endi +if $data11 != @-2.185039863@ then + return -1 +endi +if $data12 != @tba1@ then + return -1 +endi +if $data20 != @21-11-11 09:00:02.000@ then + return -1 +endi +if $data21 != @-0.142546543@ then + return -1 +endi +if $data22 != @tba1@ then + return -1 +endi +if $data30 != @21-11-11 09:00:03.000@ then + return -1 +endi +if $data31 != @1.157821282@ then + return -1 +endi +if $data32 != @tba1@ then + return -1 +endi +if $data40 != @21-11-11 09:00:04.000@ then + return -1 +endi +if $data41 != @-3.380515006@ then + return -1 +endi +if $data42 != @tba1@ then + return -1 +endi +if $data50 != @21-11-11 09:00:05.000@ then + return -1 +endi +if $data51 != @-0.291006191@ then + return -1 +endi +if $data52 != @tba1@ then + return -1 +endi +if $data60 != @21-11-11 09:00:06.000@ then + return -1 +endi +if $data61 != @0.871447983@ then + return -1 +endi +if $data62 != @tba1@ then + return -1 +endi +if $data70 != @21-11-11 09:00:07.000@ then + return -1 +endi +if $data71 != @-6.799711455@ then + return -1 +endi +if $data72 != @tba1@ then + return -1 +endi +if $data80 != @21-11-11 09:00:08.000@ then + return -1 +endi +if $data81 != @-0.452315659@ then + return -1 +endi +if $data82 != @tba1@ then + return -1 +endi +if $data90 != @21-11-11 09:00:09.000@ then + return -1 +endi +if $data91 != @0.000000000@ then + return -1 +endi +if $data92 != @tba1@ then + return -1 +endi +print execute sql select tan(elapsed(ts)) from tba1; +sql select tan(elapsed(ts)) from tba1; +if $data00 != @-0.041809624@ then + return -1 +endi +print execute sql select tan(rate(c2)) from tba1; +sql select tan(rate(c2)) from tba1; +if $data00 != @1.251272660@ then + return -1 +endi +print execute sql select tan(irate(c2)) from tba1; +sql select tan(irate(c2)) from tba1; +if $data00 != @0.000000000@ then + return -1 +endi +print execute sql select tan(first(c2)) from tba1; +sql select tan(first(c2)) from tba1; +if $data00 != @1.557407725@ then + return -1 +endi +print execute sql select tan(last(c2)) from tba1; +sql select tan(last(c2)) from tba1; +if $data00 != @0.000000000@ then + return -1 +endi +print execute sql select tan(last_row(c2)) from tba1; +sql select tan(last_row(c2)) from tba1; +if $data00 != @0.000000000@ then + return -1 +endi +print execute sql select tan(top(c2, 1)) from tba1; +sql_error select tan(top(c2, 1)) from tba1; +print execute sql select tan(bottom(c2, 1)) from tba1; +sql_error select tan(bottom(c2, 1)) from tba1; +print execute sql select tan(leastsquares(c2, 1, 1)) from tba1; +sql_error select tan(leastsquares(c2, 1, 1)) from tba1; +print execute sql select tan(derivative(c2, 1s, 0)) from tba1; +sql_error select tan(derivative(c2, 1s, 0)) from tba1; +print execute sql select tan(diff(c2)) from tba1; +sql_error select tan(diff(c2)) from tba1; +print execute sql select tan(csum(c2)) from tba1; +sql_error select tan(csum(c2)) from tba1; +print execute sql select tan(mavg(c2,2)) from tba1; +sql_error select tan(mavg(c2,2)) from tba1; +print execute sql select tan(sample(c2,2)) from tba1; +sql_error select tan(sample(c2,2)) from tba1; +print execute sql select tan(_block_dist()) from tba1; +sql_error select tan(_block_dist()) from tba1; diff --git a/tests/script/general/compute/scalar_pow.sim b/tests/script/general/compute/scalar_pow.sim new file mode 100644 index 0000000000000000000000000000000000000000..1ca20c93412e9ad649f68e184f616c14d526c05c --- /dev/null +++ b/tests/script/general/compute/scalar_pow.sim @@ -0,0 +1,525 @@ +system sh/stop_dnodes.sh + +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/exec.sh -n dnode1 -s start +sleep 500 +sql connect + +$dbPrefix = db +$tbPrefix = ct +$mtPrefix = st +$tbNum = 2 +$rowNum = 50 + +print =============== step1 create stable/table +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql drop database $db -x step1 +step1: +sql create database $db +sql use $db +sql create table $mt (ts timestamp, c1 int, c2 float, c3 bigint, c4 smallint, c5 tinyint, c6 double, c7 bool, c8 nchar(5), c9 binary(10)) TAGS (tgcol int) +$i = 0 +while $i < $tbNum + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( $i ) + + $x = 0 + $y = 0.25 + + while $x < $rowNum + $cc = $x * 60000 + $ms = 1601481600000 + $cc + sql insert into $tb values ($ms , $x , $y , $x , $x , $x , $y , $x , $x , $x ) + $x = $x + 1 + $y = $y + 1 + endw + + $i = $i + 1 +endw + +print ================= step2 +$i = 1 +$tb = $tbPrefix . $i + +sql select c1, log(c2, 2), pow(c1,2), pow(c2,2)+2, pow(c2,3)+log(c3, 2)+pow(c5,2) as v4, pow(c4, 4.5)+pow(c3, 2), log(c1,2)+log(c3,4)+pow(c6,2.8)+2 as v6 from $tb + +print ===> $data00 , $data01 , $data02 , $data03 , $data04 , $data05 +if $data00 != 0 then + return -1 +endi +if $data01 != -2.000000000 then + return -1 +endi +if $data02 != 0.000000000 then + return -1 +endi +if $data03 != 2.062500000 then + return -1 +endi +if $data04 != -inf then + return -1 +endi +if $data05 != 0.000000000 then + return -1 +endi + +print ===> $data90 , $data91 , $data92 , $data93 , $data94 , $data95 +if $data94 != 813.169925001 then + return -1 +endi + +if $data95 != 19764.000000000 then + return -1 +endi + +sql select c1, log(c2, 2), pow(c1,2), pow(c2,2)+2, pow(c2,3)+log(c3, 2)+pow(c5,2) as v4, pow(c4, 4.5)+pow(c3, 2), log(c1,2)+log(c3,4)+pow(c6,2.8)+2 as v6 from $tb where ts == 1601481600000 + +print ===> $data00 , $data01 , $data02 , $data03 , $data04 , $data05 +if $data00 != 0 then + return -1 +endi +if $data01 != -2.000000000 then + return -1 +endi +if $data02 != 0.000000000 then + return -1 +endi +if $data03 != 2.062500000 then + return -1 +endi +if $data04 != -inf then + return -1 +endi +if $data05 != 0.000000000 then + return -1 +endi + +$stb = $mtPrefix . 0 +sql select c1, log(c2, 2), pow(c1,2), pow(c2,2)+2, pow(c2,3)+log(c3, 2)+pow(c5,2) as v4, pow(c4, 4.5)+pow(c3, 2), log(c1,2)+log(c3,4)+pow(c6,2.8)+2 as v6 from $stb where ts == 1601481600000 + +print ===> $data00 , $data01 , $data02 , $data03 , $data04 , $data05 +if $data00 != 0 then + return -1 +endi +if $data01 != -2.000000000 then + return -1 +endi +if $data02 != 0.000000000 then + return -1 +endi +if $data03 != 2.062500000 then + return -1 +endi +if $data04 != -inf then + return -1 +endi +if $data05 != 0.000000000 then + return -1 +endi + +sql select c1, log(c2, 2), pow(c1,2), pow(c2,2)+2, pow(c2,3)+log(c3, 2)+pow(c5,2) as v4, pow(c4, 4.5)+pow(c3, 2), log(c1,2)+log(c3,4)+pow(c6,2.8)+2 as v6 from $stb where c1 == 0 + +print ===> $data01 , $data02 , $data03 , $data04 , $data05 +if $data01 != -2.000000000 then + return -1 +endi +if $data02 != 0.000000000 then + return -1 +endi +if $data03 != 2.062500000 then + return -1 +endi +if $data04 != -inf then + return -1 +endi +if $data05 != 0.000000000 then + return -1 +endi + +sql select c1, log(c2, 2), pow(c1,2), pow(c2,2)+2, pow(c2,3)+log(c3, 2)+pow(c5,2) as v4, pow(c4, 4.5)+pow(c3, 2), log(c1,2)+log(c3,4)+pow(c6,2.8)+2 as v6 from $stb where c1 == 0 +print ===> $data01 , $data02 , $data03 , $data04 , $data05 + +if $data03 != 2.062500000 then + return -1 +endi +if $data04 != -inf then + return -1 +endi + +sql select c1, log(c2, 2), pow(c1,2), pow(c2,2)+2, pow(c2,3)+log(c3, 2)+pow(c5,2) as v4, pow(c4, 4.5)+pow(c3, 2), log(c1,2)+log(c3,4)+pow(c6,2.8)+2 as v6 from $stb order by ts desc + +print ===> $data00 , $data01 , $data02 , $data03 , $data04 , $data05 + +if $data00 != 49 then + return -1 +endi +if $data01 != 5.614709844 then + return -1 +endi +if $data02 != 2401.000000000 then + return -1 +endi +if $data03 != 2403.000000000 then + return -1 +endi +if $data04 != 120055.614709844 then + return -1 +endi +if $data05 != 40356008.000000000 then + return -1 +endi + +sql select c1, log(c2, 2), pow(c1,2), pow(c2,2)+2, pow(c2,3)+log(c3, 2)+pow(c5,2) as v4, pow(c4, 4.5)+pow(c3, 2), log(c1,2)+log(c3,4)+pow(c6,2.8)+2 as v6 from $tb order by ts limit 2; +print ===> $data00 , $data01 , $data02 , $data03 , $data04 , $data05 +print ===> $data10 , $data11 , $data12 , $data13 , $data14 , $data15 +if $data00 != 0 then + return -1 +endi +if $data01 != -2.000000000 then + return -1 +endi +if $data02 != 0.000000000 then + return -1 +endi +if $data03 != 2.062500000 then + return -1 +endi +if $data04 != -inf then + return -1 +endi +if $data05 != 0.000000000 then + return -1 +endi +if $data10 != 1 then + return -1 +endi +if $data11 != 0.000000000 then + return -1 +endi +if $data12 != 1.000000000 then + return -1 +endi +if $data13 != 3.000000000 then + return -1 +endi +if $data14 != 2.000000000 then + return -1 +endi +if $data15 != 2.000000000 then + return -1 +endi +print execute sql select sqrt(abs(log(c1,2)-pow(c1,2)))+2 from $tb order by ts limit 2 +sql select sqrt(abs(log(c1,2)-pow(c1,2)))+2 from $tb order by ts limit 2 +print $data00 , $ data10 +if $data00 != @inf@ then + return -1 +endi +if $data10 != 3.000000000 then + return -1 +endi + +print ===============> step 3 sql_error stable, group by, window +sql_error select log(c2,2) from $stb group by tbname; + +sql_error select log(c2,2) from $stb group by tgcol; + +sql_error select log(c2,2) from $stb group by c3; + +sql_error select log(c2,2) from $stb interval(1m); + +sql_error select log(c2,2) from $stb state_window(c7); + +sql_error select log(c2,2) from $tb state_window(c7); + +sql_error select log(c2,2) from $stb session(ts, 30s); + +sql_error select log(c2,2) from $tb session(ts, 30s); + +sql_error select log(c2,2) from $stb slimit 2; + +sql_error select pow(c2,2) from $stb group by tbname; + +sql_error select pow(c2,2) from $stb group by tgcol; + +sql_error select pow(c2,2) from $stb group by c3; + +sql_error select pow(c2,2) from $stb interval(1m); + +sql_error select pow(c2,2) from $stb state_window(c7); + +sql_error select pow(c2,2) from $tb state_window(c7); + +sql_error select pow(c2,2) from $stb session(ts, 30s); + +sql_error select pow(c2,2) from $tb session(ts, 30s); + +sql_error select pow(c2,2) from $stb slimit 2; + +sql_error select pow(c2,2) from $stb interval(1m) slimit 2; +print ===============> step 4 nested query +print ===============> step 4.1 select expr... from (select * from super_tb order by ts desc) +sql select c1, log(c2, 2), pow(c1,2), pow(c2,2)+2, pow(c2,3)+log(c3, 2)+pow(c5,2) as v4, pow(c4, 4.5)+pow(c3, 2), log(c1,2)+log(c3,4)+pow(c6,2.8)+2 as v6 from (select * from $stb order by ts desc) + +print ===> $data00 , $data01 , $data02 , $data03 , $data04 , $data05 +if $data00 != 49 then + return -1 +endi +if $data01 != 5.614709844 then + return -1 +endi +if $data02 != 2401.000000000 then + return -1 +endi +if $data03 != 2403.000000000 then + return -1 +endi +if $data04 != 120055.614709844 then + return -1 +endi +if $data05 != 40356008.000000000 then + return -1 +endi + +print ==============> step 4.2 select expr... from (select * from child_tb order by ts); + +sql select c1, log(c2, 2), pow(c1,2), pow(c2,2)+2, pow(c2,3)+log(c3, 2)+pow(c5,2) as v4, pow(c4, 4.5)+pow(c3, 2), log(c1,2)+log(c3,4)+pow(c6,2.8)+2 as v6 from (select * from $tb order by ts limit 2); +print ===> $data00 , $data01 , $data02 , $data03 , $data04 , $data05 +print ===> $data10 , $data11 , $data12 , $data13 , $data14 , $data15 +if $data00 != 0 then + return -1 +endi +if $data01 != -2.000000000 then + return -1 +endi +if $data02 != 0.000000000 then + return -1 +endi +if $data03 != 2.062500000 then + return -1 +endi +if $data04 != -inf then + return -1 +endi +if $data05 != 0.000000000 then + return -1 +endi +if $data10 != 1 then + return -1 +endi +if $data11 != 0.000000000 then + return -1 +endi +if $data12 != 1.000000000 then + return -1 +endi +if $data13 != 3.000000000 then + return -1 +endi +if $data14 != 2.000000000 then + return -1 +endi +if $data15 != 2.000000000 then + return -1 +endi + +print ====> step 4.3 select exprs... from (select * from super_tb ) order by ts desc; +sql select c1, log(c2, 2), pow(c1,2), pow(c2,2)+2, pow(c2,3)+log(c3, 2)+pow(c5,2) as v4, pow(c4, 4.5)+pow(c3, 2), log(c1,2)+log(c3,4)+pow(c6,2.8)+2 as v6 from (select * from $stb ) order by ts desc +if $data00 != 49 then + return -1 +endi +if $data01 != 5.614709844 then + return -1 +endi +if $data02 != 2401.000000000 then + return -1 +endi +if $data03 != 2403.000000000 then + return -1 +endi +if $data04 != 120055.614709844 then + return -1 +endi +if $data05 != 40356008.000000000 then + return -1 +endi +sql select c1, log(c2, 2), pow(c1,2), pow(c2,2)+2, pow(c2,3)+log(c3, 2)+pow(c5,2) as v4, pow(c4, 4.5)+pow(c3, 2), log(c1,2)+log(c3,4)+pow(c6,2.8)+2 as v6 from (select * from $stb ) +print ===> $data00 , $data01 , $data02 , $data03 , $data04 , $data05 +if $data00 != 0 then + return -1 +endi +if $data01 != -2.000000000 then + return -1 +endi +if $data02 != 0.000000000 then + return -1 +endi +if $data03 != 2.062500000 then + return -1 +endi +if $data04 != -inf then + return -1 +endi +if $data05 != 0.000000000 then + return -1 +endi + +print ====> step 4.4 select exprs... from (select * from child_tb) order by ts limit 2; + +sql select c1, log(c2, 2), pow(c1,2), pow(c2,2)+2, pow(c2,3)+log(c3, 2)+pow(c5,2) as v4, pow(c4, 4.5)+pow(c3, 2), log(c1,2)+log(c3,4)+pow(c6,2.8)+2 as v6 from (select * from $tb ) order by ts limit 2; +print ===> $data00 , $data01 , $data02 , $data03 , $data04 , $data05 +print ===> $data10 , $data11 , $data12 , $data13 , $data14 , $data15 +if $data00 != 0 then + return -1 +endi +if $data01 != -2.000000000 then + return -1 +endi +if $data02 != 0.000000000 then + return -1 +endi +if $data03 != 2.062500000 then + return -1 +endi +if $data04 != -inf then + return -1 +endi +if $data05 != 0.000000000 then + return -1 +endi +if $data10 != 1 then + return -1 +endi +if $data11 != 0.000000000 then + return -1 +endi +if $data12 != 1.000000000 then + return -1 +endi +if $data13 != 3.000000000 then + return -1 +endi +if $data14 != 2.000000000 then + return -1 +endi +if $data15 != 2.000000000 then + return -1 +endi +sql select c1, log(c2, 2), pow(c1,2), pow(c2,2)+2, pow(c2,3)+log(c3, 2)+pow(c5,2) as v4, pow(c4, 4.5)+pow(c3, 2), log(c1,2)+log(c3,4)+pow(c6,2.8)+2 as v6 from (select * from $tb ) limit 2; +print ===> $data00 , $data01 , $data02 , $data03 , $data04 , $data05 +print ===> $data10 , $data11 , $data12 , $data13 , $data14 , $data15 +if $data00 != 0 then + return -1 +endi +if $data01 != -2.000000000 then + return -1 +endi +if $data02 != 0.000000000 then + return -1 +endi +if $data03 != 2.062500000 then + return -1 +endi +if $data04 != -inf then + return -1 +endi +if $data05 != 0.000000000 then + return -1 +endi +if $data10 != 1 then + return -1 +endi +if $data11 != 0.000000000 then + return -1 +endi +if $data12 != 1.000000000 then + return -1 +endi +if $data13 != 3.000000000 then + return -1 +endi +if $data14 != 2.000000000 then + return -1 +endi +if $data15 != 2.000000000 then + return -1 +endi + +print ===============> step 4.5 select * from (select expr... from super_tb order by ts desc) +sql select * from (select c1, log(c2, 2), pow(c1,2), pow(c2,2)+2, pow(c2,3)+log(c3, 2)+pow(c5,2) as v4, pow(c4, 4.5)+pow(c3, 2), log(c1,2)+log(c3,4)+pow(c6,2.8)+2 as v6, ts from $stb order by ts desc) + +print ===> $data00 , $data01 , $data02 , $data03 , $data04 , $data05 +if $data00 != 49 then + return -1 +endi +if $data01 != 5.614709844 then + return -1 +endi +if $data02 != 2401.000000000 then + return -1 +endi +if $data03 != 2403.000000000 then + return -1 +endi +if $data04 != 120055.614709844 then + return -1 +endi +if $data05 != 40356008.000000000 then + return -1 +endi + +print ==============> step 4.6 select * from (select expr... from child_tb order by ts); + +sql select * from (select c1, log(c2, 2), pow(c1,2), pow(c2,2)+2, pow(c2,3)+log(c3, 2)+pow(c5,2) as v4, pow(c4, 4.5)+pow(c3, 2), log(c1,2)+log(c3,4)+pow(c6,2.8)+2 as v6, ts from $tb order by ts limit 2); +print ===> $data00 , $data01 , $data02 , $data03 , $data04 , $data05 +print ===> $data10 , $data11 , $data12 , $data13 , $data14 , $data15 +if $data00 != 0 then + return -1 +endi +if $data01 != -2.000000000 then + return -1 +endi +if $data02 != 0.000000000 then + return -1 +endi +if $data03 != 2.062500000 then + return -1 +endi +if $data04 != -inf then + return -1 +endi +if $data05 != 0.000000000 then + return -1 +endi +if $data10 != 1 then + return -1 +endi +if $data11 != 0.000000000 then + return -1 +endi +if $data12 != 1.000000000 then + return -1 +endi +if $data13 != 3.000000000 then + return -1 +endi +if $data14 != 2.000000000 then + return -1 +endi +if $data15 != 2.000000000 then + return -1 +endi + + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT + diff --git a/tests/script/general/compute/scalar_str_concat_len.sim b/tests/script/general/compute/scalar_str_concat_len.sim new file mode 100644 index 0000000000000000000000000000000000000000..bce47896b00cfed41c509c6af2819341aab27b14 --- /dev/null +++ b/tests/script/general/compute/scalar_str_concat_len.sim @@ -0,0 +1,828 @@ +system sh/stop_dnodes.sh + +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/exec.sh -n dnode1 -s start +sleep 500 +sql connect + +$dbPrefix = db +$tbPrefix = ct +$mtPrefix = st +$quote = ' +$tbNum = 2 +$rowNum = 50 + +print =============== step1 create stable/table +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql drop database $db -x step1 +step1: +sql create database $db +sql use $db +sql create table $mt (ts timestamp, c1 int, c2 binary(10), c3 binary(30), c4 binary(40), c5 binary(50), c6 nchar(10), c7 nchar(20), c8 nchar(30), c9 nchar(40)) TAGS (tgcol int) +$i = 0 +while $i < $tbNum + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( $i ) + + $x = 0 + + $z2 = $x . 2 + $y2 = $quote . $z2 + $y2 = $y2 . $quote + + $z3 = $x . 3 + $y3 = $quote . $z3 + $y3 = $y3 . $quote + + $z4 = $x . 4 + $y4 = $quote . $z4 + $y4 = $y4 . $quote + + $z5 = $x . 5 + $y5 = $quote . $z5 + $y5 = $y5 . $quote + + $z6 = $x . 6 + $y6 = $quote . $z6 + $y6 = $y6 . $quote + + $z7 = $x . 7 + $y7 = $quote . $z7 + $y7 = $y7 . $quote + + $z8 = $x . 8 + $y8 = $quote . $z8 + $y8 = $y8 . $quote + + $z9 = $x . 9 + $y9 = $quote . $z9 + $y9 = $y9 . $quote + + while $x < $rowNum + $cc = $x * 60000 + $ms = 1601481600000 + $cc + + sql insert into $tb values ($ms , $x , $y2 , $y3 , $y4 , $y5 , $y6 , $y7 , $y8 , $y9 ) + $x = $x + 1 + $z2 = $x . 2 + $y2 = $quote . $z2 + $y2 = $y2 . $quote + + $z3 = $x . 3 + $y3 = $quote . $z3 + $y3 = $y3 . $quote + + $z4 = $x . 4 + $y4 = $quote . $z4 + $y4 = $y4 . $quote + + $z5 = $x . 5 + $y5 = $quote . $z5 + $y5 = $y5 . $quote + + $z6 = $x . 6 + $y6 = $quote . $z6 + $y6 = $y6 . $quote + + $z7 = $x . 7 + $y7 = $quote . $z7 + $y7 = $y7 . $quote + + $z8 = $x . 8 + $y8 = $quote . $z8 + $y8 = $y8 . $quote + + $z9 = $x . 9 + $y9 = $quote . $z9 + $y9 = $y9 . $quote + endw + + $i = $i + 1 +endw + +print ================= step2 +$i = 1 +$tb = $tbPrefix . $i +$stb = $mtPrefix . 0 + +print sql select concat(c2, c3, c4, c5) from $tb +sql select concat(c2, c3, c4, c5) from $tb +print $data00 +if $data00 != 02030405 then + return -1 +endi + +print sql select concat_ws('data',c2,c3,c4,c5) from $tb +sql select concat_ws('data',c2,c3,c4,c5) from $tb +print $data00 + +if $data00 != 02data03data04data05 then + return -1 +endi +print sql select concat(c6, c7, c8, c9) from $tb +sql select concat(c6, c7, c8, c9) from $tb +print $data00 +if $data00 != 06070809 then + return -1 +endi + +print sql select concat_ws('data' ,c6,c7,c8,c9) from $tb +sql select concat_ws('data' ,c6,c7,c8,c9) from $tb +print $data00 + +if $data00 != 06data07data08data09 then + return -1 +endi + +print sql select length(concat(c2, c3, c4, c5)) from $tb +sql select length(concat(c2, c3, c4, c5)) from $tb +print $data00 +if $data00 != 8 then + return -1 +endi + +print sql select char_length(concat(c2, c3, c4, c5)) from $tb +sql select char_length(concat(c2, c3, c4, c5)) from $tb +print $data00 +if $data00 != 8 then + return -1 +endi + +print sql select length(concat_ws('data',c2,c3,c4,c5)) from $tb +sql select length(concat_ws('data',c2,c3,c4,c5)) from $tb +print $data00 + +if $data00 != 20 then + return -1 +endi + +print sql select char_length(concat_ws('data',c2,c3,c4,c5)) from $tb +sql select char_length(concat_ws('data',c2,c3,c4,c5)) from $tb +print $data00 + +if $data00 != 20 then + return -1 +endi + +print sql select length(concat(c6, c7, c8, c9)) from $tb +sql select length(concat(c6, c7, c8, c9)) from $tb +print $data00 +if $data00 != 32 then + return -1 +endi + +print sql select char_length(concat(c6, c7, c8, c9)) from $tb +sql select char_length(concat(c6, c7, c8, c9)) from $tb +print $data00 +if $data00 != 8 then + return -1 +endi + +print sql select length(concat_ws('data' ,c6,c7,c8,c9)) from $tb +sql select length(concat_ws('data' ,c6,c7,c8,c9)) from $tb +print $data00 + +if $data00 != 80 then + return -1 +endi + +print sql select char_length(concat_ws('data', c6,c7,c8,c9)) from $tb +sql select char_length(concat_ws('data', c6, c7, c8, c9)) from $tb +print $data00 +if $data00 != 20 then + return -1 +endi + +print sql_error select concat(c1, c2, c3, c4, c5) from $tb +sql_error select concat(c1, c2, c3, c4, c5) from $tb +print sql_error select concat_ws('data',c1,c2,c3,c4,c5) from $tb +sql_error select concat_ws('data',c1,c2,c3,c4,c5) from $tb + +print ===============> step 3 sql_error stable, group by, window +sql_error select concat(c2) from $stb group by tbname; + +sql_error select concat(c2) from $stb group by tgcol; + +sql_error select concat(c2) from $stb group by c3; + +sql_error select concat(c2) from $stb interval(1m); + +sql_error select concat(c2) from $stb state_window(c7); + +sql_error select concat(c2) from $tb state_window(c7); + +sql_error select concat(c2) from $stb session(ts, 30s); + +sql_error select concat(c2) from $tb session(ts, 30s); + +sql_error select concat(c2) from $stb slimit 2; + +sql_error select concat(c2) from $stb interval(1m) slimit 2; + +sql_error select length(c2) from $stb group by tbname; + +sql_error select length(c2) from $stb group by tgcol; + +sql_error select length(c2) from $stb group by c3; + +sql_error select length(c2) from $stb interval(1m); + +sql_error select length(c2) from $stb state_window(c7); + +sql_error select length(c2) from $tb state_window(c7); + +sql_error select length(c2) from $stb session(ts, 30s); + +sql_error select length(c2) from $tb session(ts, 30s); + +sql_error select length(c2) from $stb slimit 2; + +sql_error select length(c2) from $stb interval(1m) slimit 2; + +sql_error select concat_ws(c2) from $stb group by tbname; + +sql_error select concat_ws(c2) from $stb group by tgcol; + +sql_error select concat_ws(c2) from $stb group by c3; + +sql_error select concat_ws(c2) from $stb interval(1m); + +sql_error select concat_ws(c2) from $stb state_window(c7); + +sql_error select concat_ws(c2) from $tb state_window(c7); + +sql_error select concat_ws(c2) from $stb session(ts, 30s); + +sql_error select concat_ws(c2) from $tb session(ts, 30s); + +sql_error select concat_ws(c2) from $stb slimit 2; + +sql_error select concat_ws(c2) from $stb interval(1m) slimit 2; + +sql_error select char_length(c2) from $stb group by tbname; + +sql_error select char_length(c2) from $stb group by tgcol; + +sql_error select char_length(c2) from $stb group by c3; + +sql_error select char_length(c2) from $stb interval(1m); + +sql_error select char_length(c2) from $stb state_window(c7); + +sql_error select char_length(c2) from $tb state_window(c7); + +sql_error select char_length(c2) from $stb session(ts, 30s); + +sql_error select char_length(c2) from $tb session(ts, 30s); + +sql_error select char_length(c2) from $stb slimit 2; + +sql_error select char_length(c2) from $stb interval(1m) slimit 2; + +print =============== trival test + +print execute sql select concat(c2,c3),concat(c2,c3,c4),concat(c2,c3,c4,c5) from ct1 + +sql select concat(c2,c3),concat(c2,c3,c4),concat(c2,c3,c4,c5) from ct1 + +if $rows != 50 then + return -1 +endi +if $data00 != @0203@ then + return -1 +endi +if $data01 != @020304@ then + return -1 +endi +if $data02 != @02030405@ then + return -1 +endi +if $data10 != @1213@ then + return -1 +endi +if $data11 != @121314@ then + return -1 +endi +if $data12 != @12131415@ then + return -1 +endi +print execute sql select concat('taos',c2,c3),concat('taos',c2,c4),concat('taos',c2,c5),concat('taos',c3,c4),concat('taos',c3,c5) from ct1 + +sql select concat('taos',c2,c3),concat('taos',c2,c4),concat('taos',c2,c5),concat('taos',c3,c4),concat('taos',c3,c5) from ct1 + +if $rows != 50 then + return -1 +endi +if $data00 != @taos0203@ then + return -1 +endi +if $data01 != @taos0204@ then + return -1 +endi +if $data02 != @taos0205@ then + return -1 +endi +if $data03 != @taos0304@ then + return -1 +endi +if $data04 != @taos0305@ then + return -1 +endi +if $data10 != @taos1213@ then + return -1 +endi +if $data11 != @taos1214@ then + return -1 +endi +if $data12 != @taos1215@ then + return -1 +endi +if $data13 != @taos1314@ then + return -1 +endi +if $data14 != @taos1315@ then + return -1 +endi +print execute sql select concat(c6,c7,'taos'),concat(c6,c8,'taos'),concat(c6,c9,'taos'),concat(c7,c8,'taos'),concat(c7,c9,'taos') from ct1 + +sql select concat(c6,c7,'taos'),concat(c6,c8,'taos'),concat(c6,c9,'taos'),concat(c7,c8,'taos'),concat(c7,c9,'taos') from ct1 + +if $rows != 50 then + return -1 +endi +if $data00 != @0607taos@ then + return -1 +endi +if $data01 != @0608taos@ then + return -1 +endi +if $data02 != @0609taos@ then + return -1 +endi +if $data03 != @0708taos@ then + return -1 +endi +if $data04 != @0709taos@ then + return -1 +endi +if $data10 != @1617taos@ then + return -1 +endi +if $data11 != @1618taos@ then + return -1 +endi +if $data12 != @1619taos@ then + return -1 +endi +if $data13 != @1718taos@ then + return -1 +endi +if $data14 != @1719taos@ then + return -1 +endi +print execute sql select concat('data',c7,'taos'),concat('data',c8,'taos'),concat('data',c9,'taos'),concat(c7,c8,'taos'),concat(c7,c9,'taos') from ct1 + +sql select concat('data',c7,'taos'),concat('data',c8,'taos'),concat('data',c9,'taos'),concat(c7,c8,'taos'),concat(c7,c9,'taos') from ct1 + +if $rows != 50 then + return -1 +endi +if $data00 != @data07taos@ then + return -1 +endi +if $data01 != @data08taos@ then + return -1 +endi +if $data02 != @data09taos@ then + return -1 +endi +if $data03 != @0708taos@ then + return -1 +endi +if $data04 != @0709taos@ then + return -1 +endi +if $data10 != @data17taos@ then + return -1 +endi +if $data11 != @data18taos@ then + return -1 +endi +if $data12 != @data19taos@ then + return -1 +endi +if $data13 != @1718taos@ then + return -1 +endi +if $data14 != @1719taos@ then + return -1 +endi +print execute sql select concat_ws('jeff',c2,c3),concat_ws('jeff',c2,c3,c4),concat_ws('jeff',c2,c3,c4,c5) from ct1 + +sql select concat_ws('jeff',c2,c3),concat_ws('jeff',c2,c3,c4),concat_ws('jeff',c2,c3,c4,c5) from ct1 + +if $rows != 50 then + return -1 +endi +if $data00 != @02jeff03@ then + return -1 +endi +if $data01 != @02jeff03jeff04@ then + return -1 +endi +if $data02 != @02jeff03jeff04jeff05@ then + return -1 +endi +if $data10 != @12jeff13@ then + return -1 +endi +if $data11 != @12jeff13jeff14@ then + return -1 +endi +if $data12 != @12jeff13jeff14jeff15@ then + return -1 +endi +print execute sql select concat_ws('jeff','taos',c2,c3),concat_ws('jeff','taos',c2,c4),concat_ws('jeff','taos',c2,c5),concat_ws('jeff','taos',c3,c4),concat_ws('jeff','taos',c3,c5) from ct1 + +sql select concat_ws('jeff','taos',c2,c3),concat_ws('jeff','taos',c2,c4),concat_ws('jeff','taos',c2,c5),concat_ws('jeff','taos',c3,c4),concat_ws('jeff','taos',c3,c5) from ct1 + +if $rows != 50 then + return -1 +endi +if $data00 != @taosjeff02jeff03@ then + return -1 +endi +if $data01 != @taosjeff02jeff04@ then + return -1 +endi +if $data02 != @taosjeff02jeff05@ then + return -1 +endi +if $data03 != @taosjeff03jeff04@ then + return -1 +endi +if $data04 != @taosjeff03jeff05@ then + return -1 +endi +if $data10 != @taosjeff12jeff13@ then + return -1 +endi +if $data11 != @taosjeff12jeff14@ then + return -1 +endi +if $data12 != @taosjeff12jeff15@ then + return -1 +endi +if $data13 != @taosjeff13jeff14@ then + return -1 +endi +if $data14 != @taosjeff13jeff15@ then + return -1 +endi +print execute sql select concat_ws('jeff','data',c3),concat_ws('jeff','data',c3,c4),concat_ws('jeff','data',c3,c4,c5) from ct1 + +sql select concat_ws('jeff','data',c3),concat_ws('jeff','data',c3,c4),concat_ws('jeff','data',c3,c4,c5) from ct1 + +if $rows != 50 then + return -1 +endi +if $data00 != @datajeff03@ then + return -1 +endi +if $data01 != @datajeff03jeff04@ then + return -1 +endi +if $data02 != @datajeff03jeff04jeff05@ then + return -1 +endi +if $data10 != @datajeff13@ then + return -1 +endi +if $data11 != @datajeff13jeff14@ then + return -1 +endi +if $data12 != @datajeff13jeff14jeff15@ then + return -1 +endi +print execute sql select concat_ws('jeff','data',c7,'taos'),concat_ws('jeff','data',c8,'taos'),concat_ws('jeff','data',c9,'taos'),concat_ws('jeff',c7,c8,'taos'),concat_ws('jeff',c7,c9,'taos') from ct1 + +sql select concat_ws('jeff','data',c7,'taos'),concat_ws('jeff','data',c8,'taos'),concat_ws('jeff','data',c9,'taos'),concat_ws('jeff',c7,c8,'taos'),concat_ws('jeff',c7,c9,'taos') from ct1 + +if $rows != 50 then + return -1 +endi +if $data00 != @datajeff07jefftaos@ then + return -1 +endi +if $data01 != @datajeff08jefftaos@ then + return -1 +endi +if $data02 != @datajeff09jefftaos@ then + return -1 +endi +if $data03 != @07jeff08jefftaos@ then + return -1 +endi +if $data04 != @07jeff09jefftaos@ then + return -1 +endi +if $data10 != @datajeff17jefftaos@ then + return -1 +endi +if $data11 != @datajeff18jefftaos@ then + return -1 +endi +if $data12 != @datajeff19jefftaos@ then + return -1 +endi +if $data13 != @17jeff18jefftaos@ then + return -1 +endi +if $data14 != @17jeff19jefftaos@ then + return -1 +endi +print execute sql select length(concat(c2,c3)),length(concat(c2,c3,c4)),length(concat(c2,c3,c4,c5)) from ct1 + +sql select length(concat(c2,c3)),length(concat(c2,c3,c4)),length(concat(c2,c3,c4,c5)) from ct1 + +if $rows != 50 then + return -1 +endi +if $data00 != @4@ then + return -1 +endi +if $data01 != @6@ then + return -1 +endi +if $data02 != @8@ then + return -1 +endi +if $data10 != @4@ then + return -1 +endi +if $data11 != @6@ then + return -1 +endi +if $data12 != @8@ then + return -1 +endi +print execute sql select length(concat(c6,c7,'taos')),length(concat(c6,c8,'taos')),length(concat(c6,c9,'taos')),length(concat(c7,c8,'taos')),length(concat(c7,c9,'taos')) from ct1 + +sql select length(concat(c6,c7,'taos')),length(concat(c6,c8,'taos')),length(concat(c6,c9,'taos')),length(concat(c7,c8,'taos')),length(concat(c7,c9,'taos')) from ct1 + +if $rows != 50 then + return -1 +endi +if $data00 != @32@ then + return -1 +endi +if $data01 != @32@ then + return -1 +endi +if $data02 != @32@ then + return -1 +endi +if $data03 != @32@ then + return -1 +endi +if $data04 != @32@ then + return -1 +endi +if $data10 != @32@ then + return -1 +endi +if $data11 != @32@ then + return -1 +endi +if $data12 != @32@ then + return -1 +endi +if $data13 != @32@ then + return -1 +endi +if $data14 != @32@ then + return -1 +endi +print execute sql select length(concat_ws('jeff','taos',c2,c3)),length(concat_ws('jeff','taos',c2,c4)),length(concat_ws('jeff','taos',c2,c5)),length(concat_ws('jeff','taos',c3,c4)),length(concat_ws('jeff','taos',c3,c5)) from ct1 + +sql select length(concat_ws('jeff','taos',c2,c3)),length(concat_ws('jeff','taos',c2,c4)),length(concat_ws('jeff','taos',c2,c5)),length(concat_ws('jeff','taos',c3,c4)),length(concat_ws('jeff','taos',c3,c5)) from ct1 + +if $rows != 50 then + return -1 +endi +if $data00 != @16@ then + return -1 +endi +if $data01 != @16@ then + return -1 +endi +if $data02 != @16@ then + return -1 +endi +if $data03 != @16@ then + return -1 +endi +if $data04 != @16@ then + return -1 +endi +if $data10 != @16@ then + return -1 +endi +if $data11 != @16@ then + return -1 +endi +if $data12 != @16@ then + return -1 +endi +if $data13 != @16@ then + return -1 +endi +if $data14 != @16@ then + return -1 +endi +print execute sql select length(concat_ws('jeff',c6,c7,'taos')),length(concat_ws('jeff',c6,c8,'taos')),length(concat_ws('jeff',c6,c9,'taos')),length(concat_ws('jeff',c7,c8,'taos')),length(concat_ws('jeff',c7,c9,'taos')) from ct1 + +sql select length(concat_ws('jeff',c6,c7,'taos')),length(concat_ws('jeff',c6,c8,'taos')),length(concat_ws('jeff',c6,c9,'taos')),length(concat_ws('jeff',c7,c8,'taos')),length(concat_ws('jeff',c7,c9,'taos')) from ct1 + +if $rows != 50 then + return -1 +endi +if $data00 != @64@ then + return -1 +endi +if $data01 != @64@ then + return -1 +endi +if $data02 != @64@ then + return -1 +endi +if $data03 != @64@ then + return -1 +endi +if $data04 != @64@ then + return -1 +endi +if $data10 != @64@ then + return -1 +endi +if $data11 != @64@ then + return -1 +endi +if $data12 != @64@ then + return -1 +endi +if $data13 != @64@ then + return -1 +endi +if $data14 != @64@ then + return -1 +endi +print execute sql select char_length(concat(c2,'taos',c3)),char_length(concat(c2,'taos',c4)),char_length(concat(c2,'taos',c5)),char_length(concat(c3,'taos',c4)),char_length(concat(c3,'taos',c5)) from ct1 + +sql select char_length(concat(c2,'taos',c3)),char_length(concat(c2,'taos',c4)),char_length(concat(c2,'taos',c5)),char_length(concat(c3,'taos',c4)),char_length(concat(c3,'taos',c5)) from ct1 + +if $rows != 50 then + return -1 +endi +if $data00 != @8@ then + return -1 +endi +if $data01 != @8@ then + return -1 +endi +if $data02 != @8@ then + return -1 +endi +if $data03 != @8@ then + return -1 +endi +if $data04 != @8@ then + return -1 +endi +if $data10 != @8@ then + return -1 +endi +if $data11 != @8@ then + return -1 +endi +if $data12 != @8@ then + return -1 +endi +if $data13 != @8@ then + return -1 +endi +if $data14 != @8@ then + return -1 +endi +print execute sql select char_length(concat(c6,'taos')),char_length(concat(c7,'taos')),char_length(concat(c8,'taos')),char_length(concat(c9,'taos')) from ct1 + +sql select char_length(concat(c6,'taos')),char_length(concat(c7,'taos')),char_length(concat(c8,'taos')),char_length(concat(c9,'taos')) from ct1 + +if $rows != 50 then + return -1 +endi +if $data00 != @6@ then + return -1 +endi +if $data01 != @6@ then + return -1 +endi +if $data02 != @6@ then + return -1 +endi +if $data03 != @6@ then + return -1 +endi +if $data10 != @6@ then + return -1 +endi +if $data11 != @6@ then + return -1 +endi +if $data12 != @6@ then + return -1 +endi +if $data13 != @6@ then + return -1 +endi +print execute sql select char_length(concat_ws('jeff',c2,'taos',c3)),char_length(concat_ws('jeff',c2,'taos',c4)),char_length(concat_ws('jeff',c2,'taos',c5)),char_length(concat_ws('jeff',c3,'taos',c4)),char_length(concat_ws('jeff',c3,'taos',c5)) from ct1 + +sql select char_length(concat_ws('jeff',c2,'taos',c3)),char_length(concat_ws('jeff',c2,'taos',c4)),char_length(concat_ws('jeff',c2,'taos',c5)),char_length(concat_ws('jeff',c3,'taos',c4)),char_length(concat_ws('jeff',c3,'taos',c5)) from ct1 + +if $rows != 50 then + return -1 +endi +if $data00 != @16@ then + return -1 +endi +if $data01 != @16@ then + return -1 +endi +if $data02 != @16@ then + return -1 +endi +if $data03 != @16@ then + return -1 +endi +if $data04 != @16@ then + return -1 +endi +if $data10 != @16@ then + return -1 +endi +if $data11 != @16@ then + return -1 +endi +if $data12 != @16@ then + return -1 +endi +if $data13 != @16@ then + return -1 +endi +if $data14 != @16@ then + return -1 +endi +print execute sql select char_length(concat_ws('jeff',c6,'taos')),char_length(concat_ws('jeff',c7,'taos')),char_length(concat_ws('jeff',c8,'taos')),char_length(concat_ws('jeff',c9,'taos')) from ct1 + +sql select char_length(concat_ws('jeff',c6,'taos')),char_length(concat_ws('jeff',c7,'taos')),char_length(concat_ws('jeff',c8,'taos')),char_length(concat_ws('jeff',c9,'taos')) from ct1 + +if $rows != 50 then + return -1 +endi +if $data00 != @10@ then + return -1 +endi +if $data01 != @10@ then + return -1 +endi +if $data02 != @10@ then + return -1 +endi +if $data03 != @10@ then + return -1 +endi +if $data10 != @10@ then + return -1 +endi +if $data11 != @10@ then + return -1 +endi +if $data12 != @10@ then + return -1 +endi +if $data13 != @10@ then + return -1 +endi +print =============== clear +#sql drop database $db +#sql show databases +#if $rows != 0 then +# return -1 +#endi + +#system sh/exec.sh -n dnode1 -s stop -x SIGINT + diff --git a/tests/script/general/compute/scalar_triangle.sim b/tests/script/general/compute/scalar_triangle.sim new file mode 100644 index 0000000000000000000000000000000000000000..524a544e9fe88cc4fe5fa1d639e52a032f06222e --- /dev/null +++ b/tests/script/general/compute/scalar_triangle.sim @@ -0,0 +1,1763 @@ +system sh/stop_dnodes.sh + +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/exec.sh -n dnode1 -s start +sleep 500 +sql connect + +$dbPrefix = db +$tbPrefix = ct +$mtPrefix = st +$tbNum = 2 +$rowNum = 50 + +print =============== step1 create stable/table +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql drop database $db -x step1 +step1: +sql create database $db +sql use $db +sql create table $mt (ts timestamp, c1 int, c2 float, c3 bigint, c4 smallint, c5 tinyint, c6 double, c7 bool, c8 nchar(5), c9 binary(10)) TAGS (tgcol int) +$i = 0 +while $i < $tbNum + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( $i ) + + $x = 0 + $y = 0.25 + + while $x < $rowNum + $cc = $x * 60000 + $ms = 1601481600000 + $cc + sql insert into $tb values ($ms , $x , $y , $x , $x , $x , $y , $x , $x , $x ) + $x = $x + 1 + $y = $y + 1 + endw + + $i = $i + 1 +endw + +print ================= step2 +$i = 1 +$tb = $tbPrefix . $i +$stb = $mtPrefix . 0 + + +print execute sql select c1, sin(c1), cos(c1), tan(c1), asin(c1), acos(c1), atan(c1) from ct1 +sql select c1, sin(c1), cos(c1), tan(c1), asin(c1), acos(c1), atan(c1) from ct1 +if $data00 != @0@ then + return -1 +endi +if $data01 != @0.000000000@ then + return -1 +endi +if $data02 != @1.000000000@ then + return -1 +endi +if $data03 != @0.000000000@ then + return -1 +endi +if $data04 != @0.000000000@ then + return -1 +endi +if $data05 != @1.570796327@ then + return -1 +endi +if $data06 != @0.000000000@ then + return -1 +endi +if $data10 != @1@ then + return -1 +endi +if $data11 != @0.841470985@ then + return -1 +endi +if $data12 != @0.540302306@ then + return -1 +endi +if $data13 != @1.557407725@ then + return -1 +endi +if $data14 != @1.570796327@ then + return -1 +endi +if $data15 != @0.000000000@ then + return -1 +endi +if $data16 != @0.785398163@ then + return -1 +endi +if $data20 != @2@ then + return -1 +endi +if $data21 != @0.909297427@ then + return -1 +endi +if $data22 != @-0.416146837@ then + return -1 +endi +if $data23 != @-2.185039863@ then + return -1 +endi +if $data24 != @nan@ then + return -1 +endi +if $data25 != @nan@ then + return -1 +endi +if $data26 != @1.107148718@ then + return -1 +endi +if $data30 != @3@ then + return -1 +endi +if $data31 != @0.141120008@ then + return -1 +endi +if $data32 != @-0.989992497@ then + return -1 +endi +if $data33 != @-0.142546543@ then + return -1 +endi +if $data34 != @nan@ then + return -1 +endi +if $data35 != @nan@ then + return -1 +endi +if $data36 != @1.249045772@ then + return -1 +endi +if $data40 != @4@ then + return -1 +endi +if $data41 != @-0.756802495@ then + return -1 +endi +if $data42 != @-0.653643621@ then + return -1 +endi +if $data43 != @1.157821282@ then + return -1 +endi +if $data44 != @nan@ then + return -1 +endi +if $data45 != @nan@ then + return -1 +endi +if $data46 != @1.325817664@ then + return -1 +endi +if $data50 != @5@ then + return -1 +endi +if $data51 != @-0.958924275@ then + return -1 +endi +if $data52 != @0.283662185@ then + return -1 +endi +if $data53 != @-3.380515006@ then + return -1 +endi +if $data54 != @nan@ then + return -1 +endi +if $data55 != @nan@ then + return -1 +endi +if $data56 != @1.373400767@ then + return -1 +endi +if $data60 != @6@ then + return -1 +endi +if $data61 != @-0.279415498@ then + return -1 +endi +if $data62 != @0.960170287@ then + return -1 +endi +if $data63 != @-0.291006191@ then + return -1 +endi +if $data64 != @nan@ then + return -1 +endi +if $data65 != @nan@ then + return -1 +endi +if $data66 != @1.405647649@ then + return -1 +endi +if $data70 != @7@ then + return -1 +endi +if $data71 != @0.656986599@ then + return -1 +endi +if $data72 != @0.753902254@ then + return -1 +endi +if $data73 != @0.871447983@ then + return -1 +endi +if $data74 != @nan@ then + return -1 +endi +if $data75 != @nan@ then + return -1 +endi +if $data76 != @1.428899272@ then + return -1 +endi +if $data80 != @8@ then + return -1 +endi +if $data81 != @0.989358247@ then + return -1 +endi +if $data82 != @-0.145500034@ then + return -1 +endi +if $data83 != @-6.799711455@ then + return -1 +endi +if $data84 != @nan@ then + return -1 +endi +if $data85 != @nan@ then + return -1 +endi +if $data86 != @1.446441332@ then + return -1 +endi +if $data90 != @9@ then + return -1 +endi +if $data91 != @0.412118485@ then + return -1 +endi +if $data92 != @-0.911130262@ then + return -1 +endi +if $data93 != @-0.452315659@ then + return -1 +endi +if $data94 != @nan@ then + return -1 +endi +if $data95 != @nan@ then + return -1 +endi +if $data96 != @1.460139106@ then + return -1 +endi +print execute sql select c1, sin(c2)+2, cos(c2)+2, cos(pow(c2,2)+2), tan(pow(c2,3)+log(c3, 2)+pow(c5,2)) as v4, asin(pow(c4, 4.5)+pow(c3, 2)), acos(log(c1,2)+log(c3,4)+pow(c6,2.8)+2) as v6 from ct1 where ts == 1601481600000 +sql select c1, sin(c2)+2, cos(c2)+2, cos(pow(c2,2)+2), tan(pow(c2,3)+log(c3, 2)+pow(c5,2)) as v4, asin(pow(c4, 4.5)+pow(c3, 2)), acos(log(c1,2)+log(c3,4)+pow(c6,2.8)+2) as v6 from ct1 where ts == 1601481600000 +if $data00 != @0@ then + return -1 +endi +if $data01 != @2.247403959@ then + return -1 +endi +if $data02 != @2.968912422@ then + return -1 +endi +if $data03 != @-0.472128411@ then + return -1 +endi +if $data04 != @-nan@ then + return -1 +endi +if $data05 != @0.000000000@ then + return -1 +endi +if $data06 != @nan@ then + return -1 +endi +print execute sql select c1, sin(c2), cos(c1+2), tan(c2+2)+2, sin(c2+3)+cos(c3+2)+tan(c5+2) as v4, sin(c4+4.5)+tan(c3+2), sin(c1+2)+cos(c3+4)+acos(c6+2.8)+2 as v6 from st0 where ts == 1601481600000 +sql select c1, sin(c2), cos(c1+2), tan(c2+2)+2, sin(c2+3)+cos(c3+2)+tan(c5+2) as v4, sin(c4+4.5)+tan(c3+2), sin(c1+2)+cos(c3+4)+acos(c6+2.8)+2 as v6 from st0 where ts == 1601481600000 +if $data00 != @0@ then + return -1 +endi +if $data01 != @0.247403959@ then + return -1 +endi +if $data02 != @-0.416146837@ then + return -1 +endi +if $data03 != @0.761372384@ then + return -1 +endi +if $data04 != @-2.709381834@ then + return -1 +endi +if $data05 != @-3.162569981@ then + return -1 +endi +if $data06 != @nan@ then + return -1 +endi +if $data10 != @0@ then + return -1 +endi +if $data11 != @0.247403959@ then + return -1 +endi +if $data12 != @-0.416146837@ then + return -1 +endi +if $data13 != @0.761372384@ then + return -1 +endi +if $data14 != @-2.709381834@ then + return -1 +endi +if $data15 != @-3.162569981@ then + return -1 +endi +if $data16 != @nan@ then + return -1 +endi +print execute sql select c1, tan(c2+ 2), sin(pow(c1,2)), cos(pow(c2,2)+2), tan(pow(c2,3)+log(c3, 2)+pow(c5,2)) as v4, asin(pow(c4, 4.5)+pow(c3, 2)), acos(log(c1,2)+log(c3,4)+pow(c6,2.8)+2) as v6 from st0 where c1 == 0 +sql select c1, tan(c2+ 2), sin(pow(c1,2)), cos(pow(c2,2)+2), tan(pow(c2,3)+log(c3, 2)+pow(c5,2)) as v4, asin(pow(c4, 4.5)+pow(c3, 2)), acos(log(c1,2)+log(c3,4)+pow(c6,2.8)+2) as v6 from st0 where c1 == 0 +if $data00 != @0@ then + return -1 +endi +if $data01 != @-1.238627616@ then + return -1 +endi +if $data02 != @0.000000000@ then + return -1 +endi +if $data03 != @-0.472128411@ then + return -1 +endi +if $data04 != @-nan@ then + return -1 +endi +if $data05 != @0.000000000@ then + return -1 +endi +if $data06 != @nan@ then + return -1 +endi +if $data10 != @0@ then + return -1 +endi +if $data11 != @-1.238627616@ then + return -1 +endi +if $data12 != @0.000000000@ then + return -1 +endi +if $data13 != @-0.472128411@ then + return -1 +endi +if $data14 != @-nan@ then + return -1 +endi +if $data15 != @0.000000000@ then + return -1 +endi +if $data16 != @nan@ then + return -1 +endi +print execute sql select c1, atan(c2+2), asin(c1+2), acos(c2+c1)+2, acos(c2+c3)+asin(c3+c2)+pow(c5,2) as v4, acos(c4/4.5)+asin(c3-2), asin(c1/2)+log(c3,c4)+pow(c6, 2.8)+2 as v6 from st0 where c1 == 0 +sql select c1, atan(c2+2), asin(c1+2), acos(c2+c1)+2, acos(c2+c3)+asin(c3+c2)+pow(c5,2) as v4, acos(c4/4.5)+asin(c3-2), asin(c1/2)+log(c3,c4)+pow(c6, 2.8)+2 as v6 from st0 where c1 == 0 +if $data00 != @0@ then + return -1 +endi +if $data01 != @1.152571997@ then + return -1 +endi +if $data02 != @nan@ then + return -1 +endi +if $data03 != @3.318116072@ then + return -1 +endi +if $data04 != @1.570796327@ then + return -1 +endi +if $data05 != @nan@ then + return -1 +endi +if $data06 != @-nan@ then + return -1 +endi +if $data10 != @0@ then + return -1 +endi +if $data11 != @1.152571997@ then + return -1 +endi +if $data12 != @nan@ then + return -1 +endi +if $data13 != @3.318116072@ then + return -1 +endi +if $data14 != @1.570796327@ then + return -1 +endi +if $data15 != @nan@ then + return -1 +endi +if $data16 != @-nan@ then + return -1 +endi +print execute sql select c1, cos(c2+2), cos(ceil(pow(c1,2))), sin(floor(pow(c2,2)+2)), sin(ceil(c2)+floor(c3+c2)+round(c5+c2)) as v4, atan(pow(c4, 4.5)+pow(c3, 2)), tan(log(c1,2)+cos(c3+4)+pow(c6,2.8)+2) as v6 from st0 order by ts desc +sql select c1, cos(c2+2), cos(ceil(pow(c1,2))), sin(floor(pow(c2,2)+2)), sin(ceil(c2)+floor(c3+c2)+round(c5+c2)) as v4, atan(pow(c4, 4.5)+pow(c3, 2)), tan(log(c1,2)+cos(c3+4)+pow(c6,2.8)+2) as v6 from st0 order by ts desc +if $data00 != @49@ then + return -1 +endi +if $data01 != @0.742154197@ then + return -1 +endi +if $data02 != @0.679868770@ then + return -1 +endi +if $data03 != @0.313028384@ then + return -1 +endi +if $data04 != @-0.044212563@ then + return -1 +endi +if $data05 != @1.570796302@ then + return -1 +endi +if $data06 != @0.036525682@ then + return -1 +endi +if $data10 != @49@ then + return -1 +endi +if $data11 != @0.742154197@ then + return -1 +endi +if $data12 != @0.679868770@ then + return -1 +endi +if $data13 != @0.313028384@ then + return -1 +endi +if $data14 != @-0.044212563@ then + return -1 +endi +if $data15 != @1.570796302@ then + return -1 +endi +if $data16 != @0.036525682@ then + return -1 +endi +if $data20 != @48@ then + return -1 +endi +if $data21 != @0.964966028@ then + return -1 +endi +if $data22 != @-0.350599733@ then + return -1 +endi +if $data23 != @0.070932648@ then + return -1 +endi +if $data24 != @0.945445155@ then + return -1 +endi +if $data25 != @1.570796300@ then + return -1 +endi +if $data26 != @-2.376507095@ then + return -1 +endi +if $data30 != @48@ then + return -1 +endi +if $data31 != @0.964966028@ then + return -1 +endi +if $data32 != @-0.350599733@ then + return -1 +endi +if $data33 != @0.070932648@ then + return -1 +endi +if $data34 != @0.945445155@ then + return -1 +endi +if $data35 != @1.570796300@ then + return -1 +endi +if $data36 != @-2.376507095@ then + return -1 +endi +if $data40 != @47@ then + return -1 +endi +if $data41 != @0.300592544@ then + return -1 +endi +if $data42 != @-0.895890607@ then + return -1 +endi +if $data43 != @-0.629747508@ then + return -1 +endi +if $data44 != @0.580586641@ then + return -1 +endi +if $data45 != @1.570796297@ then + return -1 +endi +if $data46 != @-0.760993034@ then + return -1 +endi +if $data50 != @47@ then + return -1 +endi +if $data51 != @0.300592544@ then + return -1 +endi +if $data52 != @-0.895890607@ then + return -1 +endi +if $data53 != @-0.629747508@ then + return -1 +endi +if $data54 != @0.580586641@ then + return -1 +endi +if $data55 != @1.570796297@ then + return -1 +endi +if $data56 != @-0.760993034@ then + return -1 +endi +if $data60 != @46@ then + return -1 +endi +if $data61 != @-0.640144339@ then + return -1 +endi +if $data62 != @0.136916383@ then + return -1 +endi +if $data63 != @0.536725534@ then + return -1 +endi +if $data64 != @-0.616064204@ then + return -1 +endi +if $data65 != @1.570796294@ then + return -1 +endi +if $data66 != @-1.929269971@ then + return -1 +endi +if $data70 != @46@ then + return -1 +endi +if $data71 != @-0.640144339@ then + return -1 +endi +if $data72 != @0.136916383@ then + return -1 +endi +if $data73 != @0.536725534@ then + return -1 +endi +if $data74 != @-0.616064204@ then + return -1 +endi +if $data75 != @1.570796294@ then + return -1 +endi +if $data76 != @-1.929269971@ then + return -1 +endi +if $data80 != @45@ then + return -1 +endi +if $data81 != @-0.992335469@ then + return -1 +endi +if $data82 != @-0.241134582@ then + return -1 +endi +if $data83 != @-0.623130100@ then + return -1 +endi +if $data84 != @-0.930094878@ then + return -1 +endi +if $data85 != @1.570796290@ then + return -1 +endi +if $data86 != @-7.205947409@ then + return -1 +endi +if $data90 != @45@ then + return -1 +endi +if $data91 != @-0.992335469@ then + return -1 +endi +if $data92 != @-0.241134582@ then + return -1 +endi +if $data93 != @-0.623130100@ then + return -1 +endi +if $data94 != @-0.930094878@ then + return -1 +endi +if $data95 != @1.570796290@ then + return -1 +endi +if $data96 != @-7.205947409@ then + return -1 +endi +print execute sql select c1, sin(c2+2), cos(sin(c1-2)), tan(cos(c2*2))+2, asin(acos(c2%3))+acos(c3/2)+atan(c5+c2) as v4, sin(c4+4.5)+cos(c3/2), tan(c1)+log(c3, c4)+sin(c6+c3)+2 as v6 from ct1 order by ts limit 2; +sql select c1, sin(c2+2), cos(sin(c1-2)), tan(cos(c2*2))+2, asin(acos(c2%3))+acos(c3/2)+atan(c5+c2) as v4, sin(c4+4.5)+cos(c3/2), tan(c1)+log(c3, c4)+sin(c6+c3)+2 as v6 from ct1 order by ts limit 2; +if $data00 != @0@ then + return -1 +endi +if $data01 != @0.778073197@ then + return -1 +endi +if $data02 != @0.614300282@ then + return -1 +endi +if $data03 != @3.203726628@ then + return -1 +endi +if $data04 != @nan@ then + return -1 +endi +if $data05 != @0.022469882@ then + return -1 +endi +if $data06 != @-nan@ then + return -1 +endi +if $data10 != @1@ then + return -1 +endi +if $data11 != @0.141120008@ then + return -1 +endi +if $data12 != @0.666366745@ then + return -1 +endi +if $data13 != @1.558041126@ then + return -1 +endi +if $data14 != @2.154346269@ then + return -1 +endi +if $data15 != @0.172042236@ then + return -1 +endi +if $data16 != @-nan@ then + return -1 +endi +print execute sql select c1, sin(c2+2), cos(sin(c1-2)), tan(cos(c2*2))+2, asin(acos(c2%3))+acos(c3/2)+atan(c5*c2) as v4, sin(c4+4.5)+cos(c3/2), tan(c1)+log(c3, c4)+sin(c6+c3)+2 as v6 from (select * from st0 order by ts desc) +sql select c1, sin(c2+2), cos(sin(c1-2)), tan(cos(c2*2))+2, asin(acos(c2%3))+acos(c3/2)+atan(c5*c2) as v4, sin(c4+4.5)+cos(c3/2), tan(c1)+log(c3, c4)+sin(c6+c3)+2 as v6 from (select * from st0 order by ts desc) +if $data00 != @49@ then + return -1 +endi +if $data01 != @0.670229176@ then + return -1 +endi +if $data02 != @0.992374553@ then + return -1 +endi +if $data03 != @0.929814367@ then + return -1 +endi +if $data04 != @nan@ then + return -1 +endi +if $data05 != @0.713618282@ then + return -1 +endi +if $data06 != @-0.746290424@ then + return -1 +endi +if $data10 != @49@ then + return -1 +endi +if $data11 != @0.670229176@ then + return -1 +endi +if $data12 != @0.992374553@ then + return -1 +endi +if $data13 != @0.929814367@ then + return -1 +endi +if $data14 != @nan@ then + return -1 +endi +if $data15 != @0.713618282@ then + return -1 +endi +if $data16 != @-0.746290424@ then + return -1 +endi +if $data20 != @48@ then + return -1 +endi +if $data21 != @-0.262374854@ then + return -1 +endi +if $data22 != @0.620208114@ then + return -1 +endi +if $data23 != @1.817585733@ then + return -1 +endi +if $data24 != @nan@ then + return -1 +endi +if $data25 != @1.211884234@ then + return -1 +endi +if $data26 != @5.183714989@ then + return -1 +endi +if $data30 != @48@ then + return -1 +endi +if $data31 != @-0.262374854@ then + return -1 +endi +if $data32 != @0.620208114@ then + return -1 +endi +if $data33 != @1.817585733@ then + return -1 +endi +if $data34 != @nan@ then + return -1 +endi +if $data35 != @1.211884234@ then + return -1 +endi +if $data36 != @5.183714989@ then + return -1 +endi +if $data40 != @47@ then + return -1 +endi +if $data41 != @-0.953752653@ then + return -1 +endi +if $data42 != @0.659304076@ then + return -1 +endi +if $data43 != @3.457510675@ then + return -1 +endi +if $data44 != @nan@ then + return -1 +endi +if $data45 != @0.882083819@ then + return -1 +endi +if $data46 != @2.630220446@ then + return -1 +endi +if $data50 != @47@ then + return -1 +endi +if $data51 != @-0.953752653@ then + return -1 +endi +if $data52 != @0.659304076@ then + return -1 +endi +if $data53 != @3.457510675@ then + return -1 +endi +if $data54 != @nan@ then + return -1 +endi +if $data55 != @0.882083819@ then + return -1 +endi +if $data56 != @2.630220446@ then + return -1 +endi +if $data60 != @46@ then + return -1 +endi +if $data61 != @-0.768254661@ then + return -1 +endi +if $data62 != @0.999843325@ then + return -1 +endi +if $data63 != @1.276316926@ then + return -1 +endi +if $data64 != @nan@ then + return -1 +endi +if $data65 != @-0.300459259@ then + return -1 +endi +if $data66 != @0.133920399@ then + return -1 +endi +if $data70 != @46@ then + return -1 +endi +if $data71 != @-0.768254661@ then + return -1 +endi +if $data72 != @0.999843325@ then + return -1 +endi +if $data73 != @1.276316926@ then + return -1 +endi +if $data74 != @nan@ then + return -1 +endi +if $data75 != @-0.300459259@ then + return -1 +endi +if $data76 != @0.133920399@ then + return -1 +endi +if $data80 != @45@ then + return -1 +endi +if $data81 != @0.123573123@ then + return -1 +endi +if $data82 != @0.673565060@ then + return -1 +endi +if $data83 != @1.519318619@ then + return -1 +endi +if $data84 != @nan@ then + return -1 +endi +if $data85 != @-1.566189594@ then + return -1 +endi +if $data86 != @5.513771854@ then + return -1 +endi +if $data90 != @45@ then + return -1 +endi +if $data91 != @0.123573123@ then + return -1 +endi +if $data92 != @0.673565060@ then + return -1 +endi +if $data93 != @1.519318619@ then + return -1 +endi +if $data94 != @nan@ then + return -1 +endi +if $data95 != @-1.566189594@ then + return -1 +endi +if $data96 != @5.513771854@ then + return -1 +endi +print execute sql select c1, sin(c2+2), cos(sin(c1-2)), tan(cos(c2*2))+2, asin(acos(c2%3))+acos(c3/2)+atan(c5*c2) as v4, sin(c4+4.5)+cos(c3/2), tan(c1)+log(c3, c4)+sin(c6+c3)+2 as v6 from (select * from ct1 order by ts limit 2); +sql select c1, sin(c2+2), cos(sin(c1-2)), tan(cos(c2*2))+2, asin(acos(c2%3))+acos(c3/2)+atan(c5*c2) as v4, sin(c4+4.5)+cos(c3/2), tan(c1)+log(c3, c4)+sin(c6+c3)+2 as v6 from (select * from ct1 order by ts limit 2); +if $data00 != @0@ then + return -1 +endi +if $data01 != @0.778073197@ then + return -1 +endi +if $data02 != @0.614300282@ then + return -1 +endi +if $data03 != @3.203726628@ then + return -1 +endi +if $data04 != @nan@ then + return -1 +endi +if $data05 != @0.022469882@ then + return -1 +endi +if $data06 != @-nan@ then + return -1 +endi +if $data10 != @1@ then + return -1 +endi +if $data11 != @0.141120008@ then + return -1 +endi +if $data12 != @0.666366745@ then + return -1 +endi +if $data13 != @1.558041126@ then + return -1 +endi +if $data14 != @1.832595715@ then + return -1 +endi +if $data15 != @0.172042236@ then + return -1 +endi +if $data16 != @-nan@ then + return -1 +endi +print execute sql select c1, sin(c2+2), cos(sin(c1-2)), tan(cos(c2*2))+2, asin(acos(c2%3))+acos(c3/2)+atan(c5*c2) as v4, sin(c4+4.5)+cos(c3/2), tan(c1)+log(c3, c4)+sin(c6+c3)+2 as v6 from (select * from st0 ) order by ts desc +sql select c1, sin(c2+2), cos(sin(c1-2)), tan(cos(c2*2))+2, asin(acos(c2%3))+acos(c3/2)+atan(c5*c2) as v4, sin(c4+4.5)+cos(c3/2), tan(c1)+log(c3, c4)+sin(c6+c3)+2 as v6 from (select * from st0 ) order by ts desc +if $data00 != @49@ then + return -1 +endi +if $data01 != @0.670229176@ then + return -1 +endi +if $data02 != @0.992374553@ then + return -1 +endi +if $data03 != @0.929814367@ then + return -1 +endi +if $data04 != @nan@ then + return -1 +endi +if $data05 != @0.713618282@ then + return -1 +endi +if $data06 != @-0.746290424@ then + return -1 +endi +if $data10 != @49@ then + return -1 +endi +if $data11 != @0.670229176@ then + return -1 +endi +if $data12 != @0.992374553@ then + return -1 +endi +if $data13 != @0.929814367@ then + return -1 +endi +if $data14 != @nan@ then + return -1 +endi +if $data15 != @0.713618282@ then + return -1 +endi +if $data16 != @-0.746290424@ then + return -1 +endi +if $data20 != @48@ then + return -1 +endi +if $data21 != @-0.262374854@ then + return -1 +endi +if $data22 != @0.620208114@ then + return -1 +endi +if $data23 != @1.817585733@ then + return -1 +endi +if $data24 != @nan@ then + return -1 +endi +if $data25 != @1.211884234@ then + return -1 +endi +if $data26 != @5.183714989@ then + return -1 +endi +if $data30 != @48@ then + return -1 +endi +if $data31 != @-0.262374854@ then + return -1 +endi +if $data32 != @0.620208114@ then + return -1 +endi +if $data33 != @1.817585733@ then + return -1 +endi +if $data34 != @nan@ then + return -1 +endi +if $data35 != @1.211884234@ then + return -1 +endi +if $data36 != @5.183714989@ then + return -1 +endi +if $data40 != @47@ then + return -1 +endi +if $data41 != @-0.953752653@ then + return -1 +endi +if $data42 != @0.659304076@ then + return -1 +endi +if $data43 != @3.457510675@ then + return -1 +endi +if $data44 != @nan@ then + return -1 +endi +if $data45 != @0.882083819@ then + return -1 +endi +if $data46 != @2.630220446@ then + return -1 +endi +if $data50 != @47@ then + return -1 +endi +if $data51 != @-0.953752653@ then + return -1 +endi +if $data52 != @0.659304076@ then + return -1 +endi +if $data53 != @3.457510675@ then + return -1 +endi +if $data54 != @nan@ then + return -1 +endi +if $data55 != @0.882083819@ then + return -1 +endi +if $data56 != @2.630220446@ then + return -1 +endi +if $data60 != @46@ then + return -1 +endi +if $data61 != @-0.768254661@ then + return -1 +endi +if $data62 != @0.999843325@ then + return -1 +endi +if $data63 != @1.276316926@ then + return -1 +endi +if $data64 != @nan@ then + return -1 +endi +if $data65 != @-0.300459259@ then + return -1 +endi +if $data66 != @0.133920399@ then + return -1 +endi +if $data70 != @46@ then + return -1 +endi +if $data71 != @-0.768254661@ then + return -1 +endi +if $data72 != @0.999843325@ then + return -1 +endi +if $data73 != @1.276316926@ then + return -1 +endi +if $data74 != @nan@ then + return -1 +endi +if $data75 != @-0.300459259@ then + return -1 +endi +if $data76 != @0.133920399@ then + return -1 +endi +if $data80 != @45@ then + return -1 +endi +if $data81 != @0.123573123@ then + return -1 +endi +if $data82 != @0.673565060@ then + return -1 +endi +if $data83 != @1.519318619@ then + return -1 +endi +if $data84 != @nan@ then + return -1 +endi +if $data85 != @-1.566189594@ then + return -1 +endi +if $data86 != @5.513771854@ then + return -1 +endi +if $data90 != @45@ then + return -1 +endi +if $data91 != @0.123573123@ then + return -1 +endi +if $data92 != @0.673565060@ then + return -1 +endi +if $data93 != @1.519318619@ then + return -1 +endi +if $data94 != @nan@ then + return -1 +endi +if $data95 != @-1.566189594@ then + return -1 +endi +if $data96 != @5.513771854@ then + return -1 +endi +print execute sql select c1, sin(c2+2), cos(sin(c1-2)), tan(cos(c2*2))+2, asin(acos(c2%3))+acos(c3/2)+atan(c5*c2) as v4, sin(c4+4.5)+cos(c3/2), tan(c1)+log(c3, c4)+sin(c6+c3)+2 as v6 from (select * from st0 ) +sql select c1, sin(c2+2), cos(sin(c1-2)), tan(cos(c2*2))+2, asin(acos(c2%3))+acos(c3/2)+atan(c5*c2) as v4, sin(c4+4.5)+cos(c3/2), tan(c1)+log(c3, c4)+sin(c6+c3)+2 as v6 from (select * from st0 ) +if $data00 != @0@ then + return -1 +endi +if $data01 != @0.778073197@ then + return -1 +endi +if $data02 != @0.614300282@ then + return -1 +endi +if $data03 != @3.203726628@ then + return -1 +endi +if $data04 != @nan@ then + return -1 +endi +if $data05 != @0.022469882@ then + return -1 +endi +if $data06 != @-nan@ then + return -1 +endi +if $data10 != @1@ then + return -1 +endi +if $data11 != @0.141120008@ then + return -1 +endi +if $data12 != @0.666366745@ then + return -1 +endi +if $data13 != @1.558041126@ then + return -1 +endi +if $data14 != @1.832595715@ then + return -1 +endi +if $data15 != @0.172042236@ then + return -1 +endi +if $data16 != @-nan@ then + return -1 +endi +if $data20 != @2@ then + return -1 +endi +if $data21 != @-0.756802495@ then + return -1 +endi +if $data22 != @1.000000000@ then + return -1 +endi +if $data23 != @1.234030298@ then + return -1 +endi +if $data24 != @nan@ then + return -1 +endi +if $data25 != @0.755422294@ then + return -1 +endi +if $data26 != @0.058157641@ then + return -1 +endi +if $data30 != @3@ then + return -1 +endi +if $data31 != @-0.958924275@ then + return -1 +endi +if $data32 != @0.666366745@ then + return -1 +endi +if $data33 != @3.428875323@ then + return -1 +endi +if $data34 != @nan@ then + return -1 +endi +if $data35 != @1.008737178@ then + return -1 +endi +if $data36 != @2.578037959@ then + return -1 +endi +if $data40 != @4@ then + return -1 +endi +if $data41 != @-0.279415498@ then + return -1 +endi +if $data42 != @0.614300282@ then + return -1 +endi +if $data43 != @1.853464439@ then + return -1 +endi +if $data44 != @nan@ then + return -1 +endi +if $data45 != @0.382340276@ then + return -1 +endi +if $data46 != @5.147179529@ then + return -1 +endi +if $data50 != @5@ then + return -1 +endi +if $data51 != @0.656986599@ then + return -1 +endi +if $data52 != @0.990059086@ then + return -1 +endi +if $data53 != @0.886449574@ then + return -1 +endi +if $data54 != @nan@ then + return -1 +endi +if $data55 != @-0.876294736@ then + return -1 +endi +if $data56 != @-0.924536117@ then + return -1 +endi +if $data60 != @6@ then + return -1 +endi +if $data61 != @0.989358247@ then + return -1 +endi +if $data62 != @0.727035131@ then + return -1 +endi +if $data63 != @3.124320480@ then + return -1 +endi +if $data64 != @nan@ then + return -1 +endi +if $data65 != @-1.869688257@ then + return -1 +endi +if $data66 != @2.172420891@ then + return -1 +endi +if $data70 != @7@ then + return -1 +endi +if $data71 != @0.412118485@ then + return -1 +endi +if $data72 != @0.574400879@ then + return -1 +endi +if $data73 != @2.137595835@ then + return -1 +endi +if $data74 != @nan@ then + return -1 +endi +if $data75 != @-1.811908862@ then + return -1 +endi +if $data76 != @4.862055338@ then + return -1 +endi +if $data80 != @8@ then + return -1 +endi +if $data81 != @-0.544021111@ then + return -1 +endi +if $data82 != @0.961216805@ then + return -1 +endi +if $data83 != @0.578734473@ then + return -1 +endi +if $data84 != @nan@ then + return -1 +endi +if $data85 != @-0.719965518@ then + return -1 +endi +if $data86 != @-4.087614772@ then + return -1 +endi +if $data90 != @9@ then + return -1 +endi +if $data91 != @-0.999990207@ then + return -1 +endi +if $data92 != @0.791836209@ then + return -1 +endi +if $data93 != @2.776612512@ then + return -1 +endi +if $data94 != @nan@ then + return -1 +endi +if $data95 != @0.592988627@ then + return -1 +endi +if $data96 != @1.796697094@ then + return -1 +endi +print execute sql select c1, sin(c2+2), cos(sin(c1-2)), tan(cos(c2*2))+2, asin(acos(c2%3))+acos(c3/2)+atan(c5*c2) as v4, sin(c4+4.5)+cos(c3/2), tan(c1)+log(c3, c4)+sin(c6+c3)+2 as v6 from (select * from ct1 ) order by ts limit 2; +sql select c1, sin(c2+2), cos(sin(c1-2)), tan(cos(c2*2))+2, asin(acos(c2%3))+acos(c3/2)+atan(c5*c2) as v4, sin(c4+4.5)+cos(c3/2), tan(c1)+log(c3, c4)+sin(c6+c3)+2 as v6 from (select * from ct1 ) order by ts limit 2; +if $data00 != @0@ then + return -1 +endi +if $data01 != @0.778073197@ then + return -1 +endi +if $data02 != @0.614300282@ then + return -1 +endi +if $data03 != @3.203726628@ then + return -1 +endi +if $data04 != @nan@ then + return -1 +endi +if $data05 != @0.022469882@ then + return -1 +endi +if $data06 != @-nan@ then + return -1 +endi +if $data10 != @1@ then + return -1 +endi +if $data11 != @0.141120008@ then + return -1 +endi +if $data12 != @0.666366745@ then + return -1 +endi +if $data13 != @1.558041126@ then + return -1 +endi +if $data14 != @1.832595715@ then + return -1 +endi +if $data15 != @0.172042236@ then + return -1 +endi +if $data16 != @-nan@ then + return -1 +endi +print execute sql select c1, sin(c2+2), cos(sin(c1-2)), tan(cos(c2*2))+2, asin(acos(c2%3))+acos(c3/2)+atan(c5*c2) as v4, sin(c4+4.5)+cos(c3/2), tan(c1)+log(c3, c4)+sin(c6+c3)+2 as v6 from (select * from ct1 ) limit 2; +sql select c1, sin(c2+2), cos(sin(c1-2)), tan(cos(c2*2))+2, asin(acos(c2%3))+acos(c3/2)+atan(c5*c2) as v4, sin(c4+4.5)+cos(c3/2), tan(c1)+log(c3, c4)+sin(c6+c3)+2 as v6 from (select * from ct1 ) limit 2; +if $data00 != @0@ then + return -1 +endi +if $data01 != @0.778073197@ then + return -1 +endi +if $data02 != @0.614300282@ then + return -1 +endi +if $data03 != @3.203726628@ then + return -1 +endi +if $data04 != @nan@ then + return -1 +endi +if $data05 != @0.022469882@ then + return -1 +endi +if $data06 != @-nan@ then + return -1 +endi +if $data10 != @1@ then + return -1 +endi +if $data11 != @0.141120008@ then + return -1 +endi +if $data12 != @0.666366745@ then + return -1 +endi +if $data13 != @1.558041126@ then + return -1 +endi +if $data14 != @1.832595715@ then + return -1 +endi +if $data15 != @0.172042236@ then + return -1 +endi +if $data16 != @-nan@ then + return -1 +endi +print execute sql select * from (select c1, sin(c2+2), cos(sin(c1-2)), tan(cos(c2*2))+2, asin(acos(c2%3))+acos(c3/2)+atan(c5*c2) as v4, sin(c4+4.5)+cos(c3/2), tan(c1)+log(c3, c4)+sin(c6+c3)+2 as v6, ts from st0 order by ts desc) +sql select * from (select c1, sin(c2+2), cos(sin(c1-2)), tan(cos(c2*2))+2, asin(acos(c2%3))+acos(c3/2)+atan(c5*c2) as v4, sin(c4+4.5)+cos(c3/2), tan(c1)+log(c3, c4)+sin(c6+c3)+2 as v6, ts from st0 order by ts desc) +if $data00 != @49@ then + return -1 +endi +if $data01 != @0.670229176@ then + return -1 +endi +if $data02 != @0.992374553@ then + return -1 +endi +if $data03 != @0.929814367@ then + return -1 +endi +if $data04 != @nan@ then + return -1 +endi +if $data05 != @0.713618282@ then + return -1 +endi +if $data06 != @-0.746290424@ then + return -1 +endi +if $data07 != @20-10-01 00:49:00.000@ then + return -1 +endi +if $data10 != @49@ then + return -1 +endi +if $data11 != @0.670229176@ then + return -1 +endi +if $data12 != @0.992374553@ then + return -1 +endi +if $data13 != @0.929814367@ then + return -1 +endi +if $data14 != @nan@ then + return -1 +endi +if $data15 != @0.713618282@ then + return -1 +endi +if $data16 != @-0.746290424@ then + return -1 +endi +if $data17 != @20-10-01 00:49:00.000@ then + return -1 +endi +if $data20 != @48@ then + return -1 +endi +if $data21 != @-0.262374854@ then + return -1 +endi +if $data22 != @0.620208114@ then + return -1 +endi +if $data23 != @1.817585733@ then + return -1 +endi +if $data24 != @nan@ then + return -1 +endi +if $data25 != @1.211884234@ then + return -1 +endi +if $data26 != @5.183714989@ then + return -1 +endi +if $data27 != @20-10-01 00:48:00.000@ then + return -1 +endi +if $data30 != @48@ then + return -1 +endi +if $data31 != @-0.262374854@ then + return -1 +endi +if $data32 != @0.620208114@ then + return -1 +endi +if $data33 != @1.817585733@ then + return -1 +endi +if $data34 != @nan@ then + return -1 +endi +if $data35 != @1.211884234@ then + return -1 +endi +if $data36 != @5.183714989@ then + return -1 +endi +if $data37 != @20-10-01 00:48:00.000@ then + return -1 +endi +if $data40 != @47@ then + return -1 +endi +if $data41 != @-0.953752653@ then + return -1 +endi +if $data42 != @0.659304076@ then + return -1 +endi +if $data43 != @3.457510675@ then + return -1 +endi +if $data44 != @nan@ then + return -1 +endi +if $data45 != @0.882083819@ then + return -1 +endi +if $data46 != @2.630220446@ then + return -1 +endi +if $data47 != @20-10-01 00:47:00.000@ then + return -1 +endi +if $data50 != @47@ then + return -1 +endi +if $data51 != @-0.953752653@ then + return -1 +endi +if $data52 != @0.659304076@ then + return -1 +endi +if $data53 != @3.457510675@ then + return -1 +endi +if $data54 != @nan@ then + return -1 +endi +if $data55 != @0.882083819@ then + return -1 +endi +if $data56 != @2.630220446@ then + return -1 +endi +if $data57 != @20-10-01 00:47:00.000@ then + return -1 +endi +if $data60 != @46@ then + return -1 +endi +if $data61 != @-0.768254661@ then + return -1 +endi +if $data62 != @0.999843325@ then + return -1 +endi +if $data63 != @1.276316926@ then + return -1 +endi +if $data64 != @nan@ then + return -1 +endi +if $data65 != @-0.300459259@ then + return -1 +endi +if $data66 != @0.133920399@ then + return -1 +endi +if $data67 != @20-10-01 00:46:00.000@ then + return -1 +endi +if $data70 != @46@ then + return -1 +endi +if $data71 != @-0.768254661@ then + return -1 +endi +if $data72 != @0.999843325@ then + return -1 +endi +if $data73 != @1.276316926@ then + return -1 +endi +if $data74 != @nan@ then + return -1 +endi +if $data75 != @-0.300459259@ then + return -1 +endi +if $data76 != @0.133920399@ then + return -1 +endi +if $data77 != @20-10-01 00:46:00.000@ then + return -1 +endi +if $data80 != @45@ then + return -1 +endi +if $data81 != @0.123573123@ then + return -1 +endi +if $data82 != @0.673565060@ then + return -1 +endi +if $data83 != @1.519318619@ then + return -1 +endi +if $data84 != @nan@ then + return -1 +endi +if $data85 != @-1.566189594@ then + return -1 +endi +if $data86 != @5.513771854@ then + return -1 +endi +if $data87 != @20-10-01 00:45:00.000@ then + return -1 +endi +if $data90 != @45@ then + return -1 +endi +if $data91 != @0.123573123@ then + return -1 +endi +if $data92 != @0.673565060@ then + return -1 +endi +if $data93 != @1.519318619@ then + return -1 +endi +if $data94 != @nan@ then + return -1 +endi +if $data95 != @-1.566189594@ then + return -1 +endi +if $data96 != @5.513771854@ then + return -1 +endi +if $data97 != @20-10-01 00:45:00.000@ then + return -1 +endi +print execute sql select * from (select c1, sin(c2+2), cos(sin(c1-2)), tan(cos(c2*2))+2, asin(acos(c2%3))+acos(c3/2)+atan(c5*c2) as v4, sin(c4+4.5)+cos(c3/2), tan(c1)+log(c3, c4)+sin(c6+c3)+2 as v6, ts from ct1 order by ts limit 2); +sql select * from (select c1, sin(c2+2), cos(sin(c1-2)), tan(cos(c2*2))+2, asin(acos(c2%3))+acos(c3/2)+atan(c5*c2) as v4, sin(c4+4.5)+cos(c3/2), tan(c1)+log(c3, c4)+sin(c6+c3)+2 as v6, ts from ct1 order by ts limit 2); +if $data00 != @0@ then + return -1 +endi +if $data01 != @0.778073197@ then + return -1 +endi +if $data02 != @0.614300282@ then + return -1 +endi +if $data03 != @3.203726628@ then + return -1 +endi +if $data04 != @nan@ then + return -1 +endi +if $data05 != @0.022469882@ then + return -1 +endi +if $data06 != @-nan@ then + return -1 +endi +if $data07 != @20-10-01 00:00:00.000@ then + return -1 +endi +if $data10 != @1@ then + return -1 +endi +if $data11 != @0.141120008@ then + return -1 +endi +if $data12 != @0.666366745@ then + return -1 +endi +if $data13 != @1.558041126@ then + return -1 +endi +if $data14 != @1.832595715@ then + return -1 +endi +if $data15 != @0.172042236@ then + return -1 +endi +if $data16 != @-nan@ then + return -1 +endi +if $data17 != @20-10-01 00:01:00.000@ then + return -1 +endi + +print ===============> step 3 sql_error stable, group by, window +sql_error select sin(c2) from $stb group by tbname; + +sql_error select sin(c2) from $stb group by tgcol; + +sql_error select sin(c2) from $stb group by c3; + +sql_error select sin(c2) from $stb interval(1m); + +sql_error select sin(c2) from $stb state_window(c7); + +sql_error select sin(c2) from $tb state_window(c7); + +sql_error select sin(c2) from $stb session(ts, 30s); + +sql_error select sin(c2) from $tb session(ts, 30s); + +sql_error select sin(c2) from $stb slimit 2; + +sql_error select sin(c2) from $stb interval(1m) slimit 2; + +print =============== clear +#sql drop database $db +#sql show databases +#if $rows != 0 then +# return -1 +#endi + +#system sh/exec.sh -n dnode1 -s stop -x SIGINT + diff --git a/tests/script/general/compute/str_char_length.sim b/tests/script/general/compute/str_char_length.sim new file mode 100644 index 0000000000000000000000000000000000000000..5ef295db8893dfbcf9fd38f07c6849764251dcce --- /dev/null +++ b/tests/script/general/compute/str_char_length.sim @@ -0,0 +1,1315 @@ +sleep 100 +sql connect +sql use db + +$emptyString = @@ +print execute sql select char_length(*) from tb1; +sql_error select char_length(*) from tb1; +print execute sql select char_length(*) + 1 as a from tb1; +sql_error select char_length(*) + 1 as a from tb1; +print execute sql select char_length(tb1.*) + 1 as a from tb1; +sql_error select char_length(tb1.*) + 1 as a from tb1; +print execute sql select char_length(*) from tb1; +sql_error select char_length(*) from tb1; +print execute sql select char_length(c1) from tb1; +sql_error select char_length(c1) from tb1; +print execute sql select char_length(13) from tb1; +sql_error select char_length(13) from tb1; +print execute sql select char_length(c1) from tb1; +sql_error select char_length(c1) from tb1; +print execute sql select char_length(c2) from tb1; +sql_error select char_length(c2) from tb1; +print execute sql select char_length(c3) from tb1; +sql_error select char_length(c3) from tb1; +print execute sql select char_length(c4) from tb1; +sql_error select char_length(c4) from tb1; +print execute sql select char_length(c5) from tb1; +sql_error select char_length(c5) from tb1; +print execute sql select char_length(c6) from tb1; +sql_error select char_length(c6) from tb1; +print execute sql select char_length(c7) from tb1; +sql_error select char_length(c7) from tb1; +print execute sql select char_length(c9) from tb1; +sql select char_length(c9) from tb1; +if $data00 != @4@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data20 != @NULL@ then + return -1 +endi +if $data30 != @4@ then + return -1 +endi +if $data40 != @4@ then + return -1 +endi +if $data50 != @4@ then + return -1 +endi +if $data60 != @4@ then + return -1 +endi +print execute sql select char_length(c15) from tb1; +sql select char_length(c15) from tb1; +if $data00 != @1@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data20 != @NULL@ then + return -1 +endi +if $data30 != @1@ then + return -1 +endi +if $data40 != @1@ then + return -1 +endi +if $data50 != @3@ then + return -1 +endi +if $data60 != @0@ then + return -1 +endi +print execute sql select char_length(c10) from tb1; +sql_error select char_length(c10) from tb1; +print execute sql select char_length(c11) from tb1; +sql_error select char_length(c11) from tb1; +print execute sql select char_length(c12) from tb1; +sql_error select char_length(c12) from tb1; +print execute sql select char_length(c13) from tb1; +sql_error select char_length(c13) from tb1; +print execute sql select char_length('12345678900000000000000000') from tb1; +sql select char_length('12345678900000000000000000') from tb1; +if $data00 != @26@ then + return -1 +endi +if $data10 != @26@ then + return -1 +endi +if $data20 != @26@ then + return -1 +endi +if $data30 != @26@ then + return -1 +endi +if $data40 != @26@ then + return -1 +endi +if $data50 != @26@ then + return -1 +endi +if $data60 != @26@ then + return -1 +endi +print execute sql select distinct char_length(123) from tb1; +sql_error select distinct char_length(123) from tb1; +print execute sql select char_length(t1) from stb1; +sql_error select char_length(t1) from stb1; +print execute sql select char_length(c9),avg(c3) from tb1; +sql_error select char_length(c9),avg(c3) from tb1; +print execute sql select char_length(c9),top(c3,1) from tb1; +sql_error select char_length(c9),top(c3,1) from tb1; +print execute sql select char_length(concat(c9,c15)) from tb1 session(ts, 1s); +sql_error select char_length(concat(c9,c15)) from tb1 session(ts, 1s); +print execute sql select char_length(concat(c9,c15)) from tb1 STATE_WINDOW(c1); +sql_error select char_length(concat(c9,c15)) from tb1 STATE_WINDOW(c1); +print execute sql select char_length(concat(c9,c15)) from tb1 interval(1s) sliding(1s) fill(NULL); +sql_error select char_length(concat(c9,c15)) from tb1 interval(1s) sliding(1s) fill(NULL); +print execute sql select char_length(concat(c9,c15)) from stb1 group by t1; +sql_error select char_length(concat(c9,c15)) from stb1 group by t1; +print execute sql select char_length(concat(c9,c15)) from stb1 group by ts; +sql_error select char_length(concat(c9,c15)) from stb1 group by ts; +print execute sql select char_length(concat(c9,c15)) from stb1 group by c1; +sql_error select char_length(concat(c9,c15)) from stb1 group by c1; +print execute sql select char_length(concat(c9,c15)) from stb1 group by tbname; +sql_error select char_length(concat(c9,c15)) from stb1 group by tbname; +print execute sql select char_length(concat(c9,c15)) from tb1 order by c2; +sql_error select char_length(concat(c9,c15)) from tb1 order by c2; +print execute sql select char_length(c9),char_length(c15) from tbn; +sql select char_length(c9),char_length(c15) from tbn; +if $data00 != @4@ then + return -1 +endi +if $data01 != @1@ then + return -1 +endi +if $data10 != @4@ then + return -1 +endi +if $data11 != @1@ then + return -1 +endi +if $data20 != @4@ then + return -1 +endi +if $data21 != @1@ then + return -1 +endi +if $data30 != @4@ then + return -1 +endi +if $data31 != @1@ then + return -1 +endi +if $data40 != @4@ then + return -1 +endi +if $data41 != @1@ then + return -1 +endi +if $data50 != @4@ then + return -1 +endi +if $data51 != @1@ then + return -1 +endi +if $data60 != @4@ then + return -1 +endi +if $data61 != @1@ then + return -1 +endi +print execute sql select char_length(ts) from (select avg(c2) as a from stb1 interval(1s)); +sql_error select char_length(ts) from (select avg(c2) as a from stb1 interval(1s)); +print execute sql select char_length(cast(a as binary(10))) from (select abs(c2) as a from tb1); +sql select char_length(cast(a as binary(10))) from (select abs(c2) as a from tb1); +if $data00 != @1@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data20 != @1@ then + return -1 +endi +if $data30 != @NULL@ then + return -1 +endi +if $data40 != @1@ then + return -1 +endi +if $data50 != @3@ then + return -1 +endi +if $data60 != @3@ then + return -1 +endi +print execute sql select char_length("abc") from tb1; +sql select char_length("abc") from tb1; +if $data00 != @3@ then + return -1 +endi +if $data10 != @3@ then + return -1 +endi +if $data20 != @3@ then + return -1 +endi +if $data30 != @3@ then + return -1 +endi +if $data40 != @3@ then + return -1 +endi +if $data50 != @3@ then + return -1 +endi +if $data60 != @3@ then + return -1 +endi +print execute sql select char_length(concat(c9,c15)) from tb1; +sql select char_length(concat(c9,c15)) from tb1; +if $data00 != @5@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data20 != @NULL@ then + return -1 +endi +if $data30 != @5@ then + return -1 +endi +if $data40 != @5@ then + return -1 +endi +if $data50 != @7@ then + return -1 +endi +if $data60 != @4@ then + return -1 +endi +print execute sql select char_length((concat(c9,c15))) from tb1; +sql select char_length((concat(c9,c15))) from tb1; +if $data00 != @5@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data20 != @NULL@ then + return -1 +endi +if $data30 != @5@ then + return -1 +endi +if $data40 != @5@ then + return -1 +endi +if $data50 != @7@ then + return -1 +endi +if $data60 != @4@ then + return -1 +endi +print execute sql select char_length('11')+c2 from tb1; +sql select char_length('11')+c2 from tb1; +if $data00 != @3.000000000@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data20 != @4.000000000@ then + return -1 +endi +if $data30 != @NULL@ then + return -1 +endi +if $data40 != @6.000000000@ then + return -1 +endi +if $data50 != @129.000000000@ then + return -1 +endi +if $data60 != @-125.000000000@ then + return -1 +endi +print execute sql select char_length(c9)+c2 from tb1; +sql select char_length(c9)+c2 from tb1; +if $data00 != @5.000000000@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data20 != @NULL@ then + return -1 +endi +if $data30 != @NULL@ then + return -1 +endi +if $data40 != @8.000000000@ then + return -1 +endi +if $data50 != @131.000000000@ then + return -1 +endi +if $data60 != @-123.000000000@ then + return -1 +endi +print execute sql select char_length(c15)+11 from tb1; +sql select char_length(c15)+11 from tb1; +if $data00 != @12.000000000@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data20 != @NULL@ then + return -1 +endi +if $data30 != @12.000000000@ then + return -1 +endi +if $data40 != @12.000000000@ then + return -1 +endi +if $data50 != @14.000000000@ then + return -1 +endi +if $data60 != @11.000000000@ then + return -1 +endi +print execute sql select char_length(c9),c9,c2 from tb1; +sql select char_length(c9),c9,c2 from tb1; +if $data00 != @4@ then + return -1 +endi +if $data01 != @1234@ then + return -1 +endi +if $data02 != @1@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data11 != @NULL@ then + return -1 +endi +if $data12 != @NULL@ then + return -1 +endi +if $data20 != @NULL@ then + return -1 +endi +if $data21 != @NULL@ then + return -1 +endi +if $data22 != @2@ then + return -1 +endi +if $data30 != @4@ then + return -1 +endi +if $data31 != @3456@ then + return -1 +endi +if $data32 != @NULL@ then + return -1 +endi +if $data40 != @4@ then + return -1 +endi +if $data41 != @4567@ then + return -1 +endi +if $data42 != @4@ then + return -1 +endi +if $data50 != @4@ then + return -1 +endi +if $data51 != @5678@ then + return -1 +endi +if $data52 != @127@ then + return -1 +endi +if $data60 != @4@ then + return -1 +endi +if $data61 != @6789@ then + return -1 +endi +if $data62 != @-127@ then + return -1 +endi +print execute sql select char_length(c9),t1,ts,tbname,_C0,_c0 from tb1; +sql select char_length(c9),t1,ts,tbname,_C0,_c0 from tb1; +if $data00 != @4@ then + return -1 +endi +if $data01 != @1@ then + return -1 +endi +if $data02 != @21-11-11 09:00:00.000@ then + return -1 +endi +if $data03 != @tb1@ then + return -1 +endi +if $data04 != @21-11-11 09:00:00.000@ then + return -1 +endi +if $data05 != @21-11-11 09:00:00.000@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data11 != @1@ then + return -1 +endi +if $data12 != @21-11-11 09:00:01.000@ then + return -1 +endi +if $data13 != @tb1@ then + return -1 +endi +if $data14 != @21-11-11 09:00:01.000@ then + return -1 +endi +if $data15 != @21-11-11 09:00:01.000@ then + return -1 +endi +if $data20 != @NULL@ then + return -1 +endi +if $data21 != @1@ then + return -1 +endi +if $data22 != @21-11-11 09:00:02.000@ then + return -1 +endi +if $data23 != @tb1@ then + return -1 +endi +if $data24 != @21-11-11 09:00:02.000@ then + return -1 +endi +if $data25 != @21-11-11 09:00:02.000@ then + return -1 +endi +if $data30 != @4@ then + return -1 +endi +if $data31 != @1@ then + return -1 +endi +if $data32 != @21-11-11 09:00:03.000@ then + return -1 +endi +if $data33 != @tb1@ then + return -1 +endi +if $data34 != @21-11-11 09:00:03.000@ then + return -1 +endi +if $data35 != @21-11-11 09:00:03.000@ then + return -1 +endi +if $data40 != @4@ then + return -1 +endi +if $data41 != @1@ then + return -1 +endi +if $data42 != @21-11-11 09:00:04.000@ then + return -1 +endi +if $data43 != @tb1@ then + return -1 +endi +if $data44 != @21-11-11 09:00:04.000@ then + return -1 +endi +if $data45 != @21-11-11 09:00:04.000@ then + return -1 +endi +if $data50 != @4@ then + return -1 +endi +if $data51 != @1@ then + return -1 +endi +if $data52 != @21-11-11 09:00:05.000@ then + return -1 +endi +if $data53 != @tb1@ then + return -1 +endi +if $data54 != @21-11-11 09:00:05.000@ then + return -1 +endi +if $data55 != @21-11-11 09:00:05.000@ then + return -1 +endi +if $data60 != @4@ then + return -1 +endi +if $data61 != @1@ then + return -1 +endi +if $data62 != @21-11-11 09:00:06.000@ then + return -1 +endi +if $data63 != @tb1@ then + return -1 +endi +if $data64 != @21-11-11 09:00:06.000@ then + return -1 +endi +if $data65 != @21-11-11 09:00:06.000@ then + return -1 +endi +print execute sql select char_length(c9),floor(c3) from tb1; +sql select char_length(c9),floor(c3) from tb1; +if $data00 != @4@ then + return -1 +endi +if $data01 != @1@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data11 != @NULL@ then + return -1 +endi +if $data20 != @NULL@ then + return -1 +endi +if $data21 != @NULL@ then + return -1 +endi +if $data30 != @4@ then + return -1 +endi +if $data31 != @3@ then + return -1 +endi +if $data40 != @4@ then + return -1 +endi +if $data41 != @4@ then + return -1 +endi +if $data50 != @4@ then + return -1 +endi +if $data51 != @32767@ then + return -1 +endi +if $data60 != @4@ then + return -1 +endi +if $data61 != @-32767@ then + return -1 +endi +print execute sql select char_length(c9),char_length(concat(c9,c15)) from tb1; +sql select char_length(c9),char_length(concat(c9,c15)) from tb1; +if $data00 != @4@ then + return -1 +endi +if $data01 != @5@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data11 != @NULL@ then + return -1 +endi +if $data20 != @NULL@ then + return -1 +endi +if $data21 != @NULL@ then + return -1 +endi +if $data30 != @4@ then + return -1 +endi +if $data31 != @5@ then + return -1 +endi +if $data40 != @4@ then + return -1 +endi +if $data41 != @5@ then + return -1 +endi +if $data50 != @4@ then + return -1 +endi +if $data51 != @7@ then + return -1 +endi +if $data60 != @4@ then + return -1 +endi +if $data61 != @4@ then + return -1 +endi +print execute sql select char_length(concat(c9,c15)) from tb1 where c9 is not null and c15 is not null; +sql select char_length(concat(c9,c15)) from tb1 where c9 is not null and c15 is not null; +if $data00 != @5@ then + return -1 +endi +if $data10 != @5@ then + return -1 +endi +if $data20 != @5@ then + return -1 +endi +if $data30 != @7@ then + return -1 +endi +if $data40 != @4@ then + return -1 +endi +print execute sql select char_length(c15) from tb1 order by ts desc; +sql select char_length(c15) from tb1 order by ts desc; +if $data00 != @0@ then + return -1 +endi +if $data10 != @3@ then + return -1 +endi +if $data20 != @1@ then + return -1 +endi +if $data30 != @1@ then + return -1 +endi +if $data40 != @NULL@ then + return -1 +endi +if $data50 != @NULL@ then + return -1 +endi +if $data60 != @1@ then + return -1 +endi +print execute sql select char_length(concat(c9,c15)) from tb1 order by ts desc; +sql select char_length(concat(c9,c15)) from tb1 order by ts desc; +if $data00 != @4@ then + return -1 +endi +if $data10 != @7@ then + return -1 +endi +if $data20 != @5@ then + return -1 +endi +if $data30 != @5@ then + return -1 +endi +if $data40 != @NULL@ then + return -1 +endi +if $data50 != @NULL@ then + return -1 +endi +if $data60 != @5@ then + return -1 +endi +print execute sql select char_length(concat(c9,c15)) from tb1 order by ts desc limit 3 offset 2; +sql select char_length(concat(c9,c15)) from tb1 order by ts desc limit 3 offset 2; +if $data00 != @5@ then + return -1 +endi +if $data10 != @5@ then + return -1 +endi +if $data20 != @NULL@ then + return -1 +endi +print execute sql select char_length(c15) from stb1; +sql select char_length(c15) from stb1; +if $data00 != @1@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data20 != @NULL@ then + return -1 +endi +if $data30 != @1@ then + return -1 +endi +if $data40 != @1@ then + return -1 +endi +if $data50 != @3@ then + return -1 +endi +if $data60 != @0@ then + return -1 +endi +if $data70 != @1@ then + return -1 +endi +if $data80 != @1@ then + return -1 +endi +if $data90 != @1@ then + return -1 +endi +print execute sql select char_length(c15) from stb1 order by ts desc; +sql select char_length(c15) from stb1 order by ts desc; +if $data00 != @1@ then + if $data00 != @0@ then + return -1 + endi +endi +if $data20 != @1@ then + if $data20 != @3@ then + return -1 + endi +endi +if $data40 != @1@ then + if $data40 != @1@ then + return -1 + endi +endi +if $data60 != @1@ then + if $data60 != @1@ then + return -1 + endi +endi +if $data80 != @1@ then + if $data80 != @NULL@ then + return -1 + endi +endi +print execute sql select char_length(c15),t1 from stb1 order by ts desc; +sql select char_length(c15),t1 from stb1 order by ts desc; +if $data00 != @1@ then + if $data00 != @0@ then + return -1 + endi +endi +if $data01 != @2@ then + if $data01 != @1@ then + return -1 + endi +endi +if $data20 != @1@ then + if $data20 != @3@ then + return -1 + endi +endi +if $data21 != @2@ then + if $data21 != @1@ then + return -1 + endi +endi +if $data40 != @1@ then + if $data40 != @1@ then + return -1 + endi +endi +if $data41 != @2@ then + if $data41 != @1@ then + return -1 + endi +endi +if $data60 != @1@ then + if $data60 != @1@ then + return -1 + endi +endi +if $data61 != @2@ then + if $data61 != @1@ then + return -1 + endi +endi +if $data80 != @1@ then + if $data80 != @NULL@ then + return -1 + endi +endi +if $data81 != @2@ then + if $data81 != @1@ then + return -1 + endi +endi +print execute sql select char_length(c15),tbname from stb1; +sql select char_length(c15),tbname from stb1; +if $data00 != @1@ then + return -1 +endi +if $data01 != @tb1@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data11 != @tb1@ then + return -1 +endi +if $data20 != @NULL@ then + return -1 +endi +if $data21 != @tb1@ then + return -1 +endi +if $data30 != @1@ then + return -1 +endi +if $data31 != @tb1@ then + return -1 +endi +if $data40 != @1@ then + return -1 +endi +if $data41 != @tb1@ then + return -1 +endi +if $data50 != @3@ then + return -1 +endi +if $data51 != @tb1@ then + return -1 +endi +if $data60 != @0@ then + return -1 +endi +if $data61 != @tb1@ then + return -1 +endi +if $data70 != @1@ then + return -1 +endi +if $data71 != @tb2@ then + return -1 +endi +if $data80 != @1@ then + return -1 +endi +if $data81 != @tb2@ then + return -1 +endi +if $data90 != @1@ then + return -1 +endi +if $data91 != @tb2@ then + return -1 +endi +print execute sql select char_length(c15),tbname from stb1 where t1 > 1; +sql select char_length(c15),tbname from stb1 where t1 > 1; +if $data00 != @1@ then + return -1 +endi +if $data01 != @tb2@ then + return -1 +endi +if $data10 != @1@ then + return -1 +endi +if $data11 != @tb2@ then + return -1 +endi +if $data20 != @1@ then + return -1 +endi +if $data21 != @tb2@ then + return -1 +endi +if $data30 != @1@ then + return -1 +endi +if $data31 != @tb2@ then + return -1 +endi +if $data40 != @1@ then + return -1 +endi +if $data41 != @tb2@ then + return -1 +endi +if $data50 != @1@ then + return -1 +endi +if $data51 != @tb2@ then + return -1 +endi +if $data60 != @1@ then + return -1 +endi +if $data61 != @tb2@ then + return -1 +endi +print execute sql select char_length(c9),char_length(c15) from tbn; +sql select char_length(c9),char_length(c15) from tbn; +if $data00 != @4@ then + return -1 +endi +if $data01 != @1@ then + return -1 +endi +if $data10 != @4@ then + return -1 +endi +if $data11 != @1@ then + return -1 +endi +if $data20 != @4@ then + return -1 +endi +if $data21 != @1@ then + return -1 +endi +if $data30 != @4@ then + return -1 +endi +if $data31 != @1@ then + return -1 +endi +if $data40 != @4@ then + return -1 +endi +if $data41 != @1@ then + return -1 +endi +if $data50 != @4@ then + return -1 +endi +if $data51 != @1@ then + return -1 +endi +if $data60 != @4@ then + return -1 +endi +if $data61 != @1@ then + return -1 +endi +print execute sql select char_length(c9),char_length(c15) from tbn order by ts desc; +sql select char_length(c9),char_length(c15) from tbn order by ts desc; +if $data00 != @4@ then + return -1 +endi +if $data01 != @1@ then + return -1 +endi +if $data10 != @4@ then + return -1 +endi +if $data11 != @1@ then + return -1 +endi +if $data20 != @4@ then + return -1 +endi +if $data21 != @1@ then + return -1 +endi +if $data30 != @4@ then + return -1 +endi +if $data31 != @1@ then + return -1 +endi +if $data40 != @4@ then + return -1 +endi +if $data41 != @1@ then + return -1 +endi +if $data50 != @4@ then + return -1 +endi +if $data51 != @1@ then + return -1 +endi +if $data60 != @4@ then + return -1 +endi +if $data61 != @1@ then + return -1 +endi +print execute sql select char_length(char_length(c9)) from tbn; +sql_error select char_length(char_length(c9)) from tbn; +print execute sql select char_length(cast(a as binary(10))) from (select avg(c2) as a from stb1 interval(1s)); +sql select char_length(cast(a as binary(10))) from (select avg(c2) as a from stb1 interval(1s)); +if $data00 != @8@ then + return -1 +endi +if $data10 != @8@ then + return -1 +endi +if $data20 != @8@ then + return -1 +endi +if $data30 != @8@ then + return -1 +endi +if $data40 != @8@ then + return -1 +endi +if $data50 != @9@ then + return -1 +endi +if $data60 != @10@ then + return -1 +endi +print execute sql select char_length(c15) from (select * from stb1); +sql select char_length(c15) from (select * from stb1); +if $data00 != @0@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data20 != @NULL@ then + return -1 +endi +if $data30 != @0@ then + return -1 +endi +if $data40 != @0@ then + return -1 +endi +if $data50 != @0@ then + return -1 +endi +if $data60 != @0@ then + return -1 +endi +if $data70 != @0@ then + return -1 +endi +if $data80 != @0@ then + return -1 +endi +if $data90 != @0@ then + return -1 +endi +print execute sql select char_length(cast(a as binary(10))) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)); +sql select char_length(cast(a as binary(10))) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)); +if $data00 != @8@ then + return -1 +endi +if $data10 != @8@ then + return -1 +endi +if $data20 != @8@ then + return -1 +endi +if $data30 != @8@ then + return -1 +endi +if $data40 != @8@ then + return -1 +endi +if $data50 != @9@ then + return -1 +endi +if $data60 != @10@ then + return -1 +endi +if $data70 != @NULL@ then + return -1 +endi +if $data80 != @NULL@ then + return -1 +endi +if $data90 != @NULL@ then + return -1 +endi +print execute sql select char_length(cast(a as binary(10))) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)) order by ts; +sql select char_length(cast(a as binary(10))) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)) order by ts; +if $data00 != @8@ then + return -1 +endi +if $data10 != @8@ then + return -1 +endi +if $data20 != @8@ then + return -1 +endi +if $data30 != @8@ then + return -1 +endi +if $data40 != @8@ then + return -1 +endi +if $data50 != @9@ then + return -1 +endi +if $data60 != @10@ then + return -1 +endi +if $data70 != @NULL@ then + return -1 +endi +if $data80 != @NULL@ then + return -1 +endi +if $data90 != @NULL@ then + return -1 +endi +print execute sql select char_length(cast(a as binary(10))) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)) order by ts desc; +sql select char_length(cast(a as binary(10))) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)) order by ts desc; +if $data00 != @NULL@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data20 != @NULL@ then + return -1 +endi +if $data30 != @10@ then + return -1 +endi +if $data40 != @9@ then + return -1 +endi +if $data50 != @8@ then + return -1 +endi +if $data60 != @8@ then + return -1 +endi +if $data70 != @8@ then + return -1 +endi +if $data80 != @8@ then + return -1 +endi +if $data90 != @8@ then + return -1 +endi +print execute sql select char_length(cast(a as binary(10))) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)) order by a desc; +sql select char_length(cast(a as binary(10))) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)) order by a desc; +if $data00 != @NULL@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data20 != @NULL@ then + return -1 +endi +if $data30 != @9@ then + return -1 +endi +if $data40 != @8@ then + return -1 +endi +if $data50 != @8@ then + return -1 +endi +if $data60 != @8@ then + return -1 +endi +if $data70 != @8@ then + return -1 +endi +if $data80 != @8@ then + return -1 +endi +if $data90 != @10@ then + return -1 +endi +print execute sql select char_length(cast(a as binary(10))) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)) order by a; +sql select char_length(cast(a as binary(10))) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)) order by a; +if $data00 != @10@ then + return -1 +endi +if $data10 != @8@ then + return -1 +endi +if $data20 != @8@ then + return -1 +endi +if $data30 != @8@ then + return -1 +endi +if $data40 != @8@ then + return -1 +endi +if $data50 != @8@ then + return -1 +endi +if $data60 != @9@ then + return -1 +endi +if $data70 != @NULL@ then + return -1 +endi +if $data80 != @NULL@ then + return -1 +endi +if $data90 != @NULL@ then + return -1 +endi +print execute sql select char_length(cast(a as binary(10))) from (select abs(c2) as a from tb1); +sql select char_length(cast(a as binary(10))) from (select abs(c2) as a from tb1); +if $data00 != @1@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data20 != @1@ then + return -1 +endi +if $data30 != @NULL@ then + return -1 +endi +if $data40 != @1@ then + return -1 +endi +if $data50 != @3@ then + return -1 +endi +if $data60 != @3@ then + return -1 +endi +print execute sql select char_length(tb1.c15),char_length(tb2.c15) from tb1,tb2 where tb1.ts=tb2.ts; +sql select char_length(tb1.c15),char_length(tb2.c15) from tb1,tb2 where tb1.ts=tb2.ts; +if $data00 != @1@ then + return -1 +endi +if $data01 != @1@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data11 != @1@ then + return -1 +endi +if $data20 != @NULL@ then + return -1 +endi +if $data21 != @1@ then + return -1 +endi +if $data30 != @1@ then + return -1 +endi +if $data31 != @1@ then + return -1 +endi +if $data40 != @1@ then + return -1 +endi +if $data41 != @1@ then + return -1 +endi +if $data50 != @3@ then + return -1 +endi +if $data51 != @1@ then + return -1 +endi +if $data60 != @0@ then + return -1 +endi +if $data61 != @1@ then + return -1 +endi +print execute sql select char_length(c15) from tb1 union all select char_length(c15) from tb2; +sql select char_length(c15) from tb1 union all select char_length(c15) from tb2; +if $data00 != @1@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data20 != @NULL@ then + return -1 +endi +if $data30 != @1@ then + return -1 +endi +if $data40 != @1@ then + return -1 +endi +if $data50 != @3@ then + return -1 +endi +if $data60 != @0@ then + return -1 +endi +if $data70 != @1@ then + return -1 +endi +if $data80 != @1@ then + return -1 +endi +if $data90 != @1@ then + return -1 +endi diff --git a/tests/script/general/compute/str_char_length2.sim b/tests/script/general/compute/str_char_length2.sim new file mode 100644 index 0000000000000000000000000000000000000000..e54f38b4dabbce0beb516e82be8e451410d4af98 --- /dev/null +++ b/tests/script/general/compute/str_char_length2.sim @@ -0,0 +1,309 @@ +sleep 100 +sql connect +sql use db + +$emptyString = @@ +print execute sql select char_length(stb1.c14),char_length(stba.c15) from stb1,stba where stb1.t1=stba.t1 and stb1.ts=stba.ts; +sql select char_length(stb1.c14),char_length(stba.c15) from stb1,stba where stb1.t1=stba.t1 and stb1.ts=stba.ts; +if $data00 != @1@ then + return -1 +endi +if $data01 != @1@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data11 != @1@ then + return -1 +endi +if $data20 != @1@ then + return -1 +endi +if $data21 != @1@ then + return -1 +endi +if $data30 != @NULL@ then + return -1 +endi +if $data31 != @1@ then + return -1 +endi +if $data40 != @1@ then + return -1 +endi +if $data41 != @1@ then + return -1 +endi +if $data50 != @2@ then + return -1 +endi +if $data51 != @1@ then + return -1 +endi +if $data60 != @0@ then + return -1 +endi +if $data61 != @1@ then + return -1 +endi +print execute sql select char_length(c14) as a from stb1 union all select char_length(c15) as a from stba; +sql select char_length(c14) as a from stb1 union all select char_length(c15) as a from stba; +if $data00 != @1@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data20 != @1@ then + return -1 +endi +if $data30 != @NULL@ then + return -1 +endi +if $data40 != @1@ then + return -1 +endi +if $data50 != @2@ then + return -1 +endi +if $data60 != @0@ then + return -1 +endi +if $data70 != @1@ then + return -1 +endi +if $data80 != @1@ then + return -1 +endi +if $data90 != @1@ then + return -1 +endi +print execute sql select char_length(c8) from stba; +sql select char_length(c8) from stba; +if $data00 != @3@ then + return -1 +endi +if $data10 != @3@ then + return -1 +endi +if $data20 != @3@ then + return -1 +endi +if $data30 != @3@ then + return -1 +endi +if $data40 != @3@ then + return -1 +endi +if $data50 != @3@ then + return -1 +endi +if $data60 != @3@ then + return -1 +endi +if $data70 != @3@ then + return -1 +endi +if $data80 != @3@ then + return -1 +endi +if $data90 != @3@ then + return -1 +endi +print execute sql select char_length(c9) from stba; +sql select char_length(c9) from stba; +if $data00 != @4@ then + return -1 +endi +if $data10 != @4@ then + return -1 +endi +if $data20 != @4@ then + return -1 +endi +if $data30 != @4@ then + return -1 +endi +if $data40 != @4@ then + return -1 +endi +if $data50 != @4@ then + return -1 +endi +if $data60 != @4@ then + return -1 +endi +if $data70 != @4@ then + return -1 +endi +if $data80 != @4@ then + return -1 +endi +if $data90 != @4@ then + return -1 +endi +print execute sql select char_length(cast(min(c2) as binary(20))) from tba1; +sql select char_length(cast(min(c2) as binary(20))) from tba1; +if $data00 != @1@ then + return -1 +endi +print execute sql select char_length(cast(max(c2) as binary(20))) from tba1; +sql select char_length(cast(max(c2) as binary(20))) from tba1; +if $data00 != @1@ then + return -1 +endi +print execute sql select char_length(cast(count(c2) as binary(20))) from tba1; +sql select char_length(cast(count(c2) as binary(20))) from tba1; +if $data00 != @2@ then + return -1 +endi +print execute sql select char_length(cast(sum(c2) as binary(20))) from tba1; +sql select char_length(cast(sum(c2) as binary(20))) from tba1; +if $data00 != @3@ then + return -1 +endi +print execute sql select char_length(cast(avg(c2) as binary(20))) from tba1; +sql select char_length(cast(avg(c2) as binary(20))) from tba1; +if $data00 != @8@ then + return -1 +endi +print execute sql select char_length(cast(percentile(c2, 10) as binary(20))) from tba1; +sql select char_length(cast(percentile(c2, 10) as binary(20))) from tba1; +if $data00 != @8@ then + return -1 +endi +print execute sql select char_length(cast(apercentile(c2, 10) as binary(20))) from tba1; +sql select char_length(cast(apercentile(c2, 10) as binary(20))) from tba1; +if $data00 != @8@ then + return -1 +endi +print execute sql select char_length(cast(stddev(c2) as binary(20))) from tba1; +sql select char_length(cast(stddev(c2) as binary(20))) from tba1; +if $data00 != @8@ then + return -1 +endi +print execute sql select char_length(cast(spread(c2) as binary(20))) from tba1; +sql select char_length(cast(spread(c2) as binary(20))) from tba1; +if $data00 != @8@ then + return -1 +endi +print execute sql select char_length(cast(twa(c2) as binary(20))) from tba1; +sql select char_length(cast(twa(c2) as binary(20))) from tba1; +if $data00 != @8@ then + return -1 +endi +print execute sql select char_length(cast(leastsquares(c2, 1, 1) as binary(20))) from tba1; +sql_error select char_length(cast(leastsquares(c2, 1, 1) as binary(20))) from tba1; +print execute sql select char_length(cast(interp(c2) as binary(20))) from tba1 every(1s) +sql select char_length(cast(interp(c2) as binary(20))) from tba1 every(1s) +if $data00 != @21-11-11 09:00:00.000@ then + return -1 +endi +if $data01 != @1@ then + return -1 +endi +if $data10 != @21-11-11 09:00:01.000@ then + return -1 +endi +if $data11 != @1@ then + return -1 +endi +if $data20 != @21-11-11 09:00:02.000@ then + return -1 +endi +if $data21 != @1@ then + return -1 +endi +if $data30 != @21-11-11 09:00:03.000@ then + return -1 +endi +if $data31 != @1@ then + return -1 +endi +if $data40 != @21-11-11 09:00:04.000@ then + return -1 +endi +if $data41 != @1@ then + return -1 +endi +if $data50 != @21-11-11 09:00:05.000@ then + return -1 +endi +if $data51 != @1@ then + return -1 +endi +if $data60 != @21-11-11 09:00:06.000@ then + return -1 +endi +if $data61 != @1@ then + return -1 +endi +if $data70 != @21-11-11 09:00:07.000@ then + return -1 +endi +if $data71 != @1@ then + return -1 +endi +if $data80 != @21-11-11 09:00:08.000@ then + return -1 +endi +if $data81 != @1@ then + return -1 +endi +if $data90 != @21-11-11 09:00:09.000@ then + return -1 +endi +if $data91 != @1@ then + return -1 +endi +print execute sql select char_length(cast(interp(c2) as binary(20))) stba every(1s) group by tbname; +sql_error select char_length(cast(interp(c2) as binary(20))) stba every(1s) group by tbname; +print execute sql select char_length(cast(elapsed(ts) as binary(20))) from tba1; +sql select char_length(cast(elapsed(ts) as binary(20))) from tba1; +if $data00 != @12@ then + return -1 +endi +print execute sql select char_length(cast(rate(c2) as binary(20))) from tba1; +sql select char_length(cast(rate(c2) as binary(20))) from tba1; +if $data00 != @8@ then + return -1 +endi +print execute sql select char_length(cast(irate(c2) as binary(20))) from tba1; +sql select char_length(cast(irate(c2) as binary(20))) from tba1; +if $data00 != @8@ then + return -1 +endi +print execute sql select char_length(cast(first(c2) as binary(20))) from tba1; +sql select char_length(cast(first(c2) as binary(20))) from tba1; +if $data00 != @1@ then + return -1 +endi +print execute sql select char_length(cast(last(c2) as binary(20))) from tba1; +sql select char_length(cast(last(c2) as binary(20))) from tba1; +if $data00 != @1@ then + return -1 +endi +print execute sql select char_length(cast(last_row(c2) as binary(20))) from tba1; +sql select char_length(cast(last_row(c2) as binary(20))) from tba1; +if $data00 != @1@ then + return -1 +endi +print execute sql select char_length(cast(top(c2, 1) as binary(20))) from tba1; +sql_error select char_length(cast(top(c2, 1) as binary(20))) from tba1; +print execute sql select char_length(cast(bottom(c2, 1) as binary(20))) from tba1; +sql_error select char_length(cast(bottom(c2, 1) as binary(20))) from tba1; +print execute sql select char_length(cast(leastsquares(c2, 1, 1) as binary(20))) from tba1; +sql_error select char_length(cast(leastsquares(c2, 1, 1) as binary(20))) from tba1; +print execute sql select char_length(cast(derivative(c2, 1s, 0) as binary(20))) from tba1; +sql_error select char_length(cast(derivative(c2, 1s, 0) as binary(20))) from tba1; +print execute sql select char_length(cast(diff(c2) as binary(20))) from tba1; +sql_error select char_length(cast(diff(c2) as binary(20))) from tba1; +print execute sql select char_length(cast(csum(c2) as binary(20))) from tba1; +sql_error select char_length(cast(csum(c2) as binary(20))) from tba1; +print execute sql select char_length(cast(mavg(c2,2) as binary(20))) from tba1; +sql_error select char_length(cast(mavg(c2,2) as binary(20))) from tba1; +print execute sql select char_length(cast(sample(c2,2) as binary(20))) from tba1; +sql_error select char_length(cast(sample(c2,2) as binary(20))) from tba1; +print execute sql select char_length(cast(_block_dist() as binary(20))) from tba1; +sql_error select char_length(cast(_block_dist() as binary(20))) from tba1; diff --git a/tests/script/general/compute/str_concat.sim b/tests/script/general/compute/str_concat.sim new file mode 100644 index 0000000000000000000000000000000000000000..b968e357af0fc0c136abce453628e32cfa67f4bd --- /dev/null +++ b/tests/script/general/compute/str_concat.sim @@ -0,0 +1,1592 @@ +sleep 100 +sql connect +sql use db + +$emptyString = @@ +print execute sql select concat(c8,*) from tb1; +sql_error select concat(c8,*) from tb1; +print execute sql select concat(c8,*) from tb1; +sql_error select concat(c8,*) from tb1; +print execute sql select concat(c8,*) from tb1; +sql_error select concat(c8,*) from tb1; +print execute sql select concat(c8,*) from tb1; +sql_error select concat(c8,*) from tb1; +print execute sql select concat(c8,*) as a from tb1; +sql_error select concat(c8,*) as a from tb1; +print execute sql select concat(concat(c9,c15), '1') as a from tb1; +sql select concat(concat(c9,c15), '1') as a from tb1; +if $data00 != @123411@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data20 != @NULL@ then + return -1 +endi +if $data30 != @345631@ then + return -1 +endi +if $data40 != @456741@ then + return -1 +endi +if $data50 != @56782781@ then + return -1 +endi +if $data60 != @67891@ then + return -1 +endi +print execute sql select concat(concat(c8,tb1.*), '1') as a from tb1; +sql_error select concat(concat(c8,tb1.*), '1') as a from tb1; +print execute sql select concat(c8,*) from tb1; +sql_error select concat(c8,*) from tb1; +print execute sql select concat(c8,c14) from tb1; +sql select concat(c8,c14) from tb1; +if $data00 != @1231@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data20 != @2342@ then + return -1 +endi +if $data30 != @NULL@ then + return -1 +endi +if $data40 != @4564@ then + return -1 +endi +if $data50 != @56727@ then + return -1 +endi +if $data60 != @678@ then + return -1 +endi +print execute sql select concat(c8,c15) from tb1; +sql_error select concat(c8,c15) from tb1; +print execute sql select concat(c8,concat(c14,c8)) from tb1; +sql select concat(c8,concat(c14,c8)) from tb1; +if $data00 != @1231123@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data20 != @2342234@ then + return -1 +endi +if $data30 != @NULL@ then + return -1 +endi +if $data40 != @4564456@ then + return -1 +endi +if $data50 != @56727567@ then + return -1 +endi +if $data60 != @678678@ then + return -1 +endi +print execute sql select concat(c8,13) from tb1; +sql_error select concat(c8,13) from tb1; +print execute sql select concat(c8,c14) from tb1; +sql select concat(c8,c14) from tb1; +if $data00 != @1231@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data20 != @2342@ then + return -1 +endi +if $data30 != @NULL@ then + return -1 +endi +if $data40 != @4564@ then + return -1 +endi +if $data50 != @56727@ then + return -1 +endi +if $data60 != @678@ then + return -1 +endi +print execute sql select concat(c8,c8) from tb1; +sql select concat(c8,c8) from tb1; +if $data00 != @123123@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data20 != @234234@ then + return -1 +endi +if $data30 != @NULL@ then + return -1 +endi +if $data40 != @456456@ then + return -1 +endi +if $data50 != @567567@ then + return -1 +endi +if $data60 != @678678@ then + return -1 +endi +print execute sql select concat(c8,c9) from tb1; +sql_error select concat(c8,c9) from tb1; +print execute sql select concat(c8,c4) from tb1; +sql_error select concat(c8,c4) from tb1; +print execute sql select concat(c8,c5) from tb1; +sql_error select concat(c8,c5) from tb1; +print execute sql select concat(c8,c6) from tb1; +sql_error select concat(c8,c6) from tb1; +print execute sql select concat(c8,c7) from tb1; +sql_error select concat(c8,c7) from tb1; +print execute sql select concat(c8,c8) from tb1; +sql select concat(c8,c8) from tb1; +if $data00 != @123123@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data20 != @234234@ then + return -1 +endi +if $data30 != @NULL@ then + return -1 +endi +if $data40 != @456456@ then + return -1 +endi +if $data50 != @567567@ then + return -1 +endi +if $data60 != @678678@ then + return -1 +endi +print execute sql select concat(c9,c8) from tb1; +sql_error select concat(c9,c8) from tb1; +print execute sql select concat(c8,c10) from tb1; +sql_error select concat(c8,c10) from tb1; +print execute sql select concat(c8,c11) from tb1; +sql_error select concat(c8,c11) from tb1; +print execute sql select concat(c8,c12) from tb1; +sql_error select concat(c8,c12) from tb1; +print execute sql select concat(c8,c13) from tb1; +sql_error select concat(c8,c13) from tb1; +print execute sql select concat(c8,12345678900000000000000000) from tb1; +sql_error select concat(c8,12345678900000000000000000) from tb1; +print execute sql select distinct concat(c8,'123') from tb1; +sql_error select distinct concat(c8,'123') from tb1; +print execute sql select concat(c8,t1) from stb1; +sql_error select concat(c8,t1) from stb1; +print execute sql select concat(c8,c14),avg(c2) from tb1; +sql_error select concat(c8,c14),avg(c2) from tb1; +print execute sql select concat(c8,c14),top(c3,1) from tb1; +sql_error select concat(c8,c14),top(c3,1) from tb1; +print execute sql select concat(c8,concat(c8,c14)) from tb1 session(ts, 1s); +sql_error select concat(c8,concat(c8,c14)) from tb1 session(ts, 1s); +print execute sql select concat(c8,concat(c8,c14)) from tb1 STATE_WINDOW(c1); +sql_error select concat(c8,concat(c8,c14)) from tb1 STATE_WINDOW(c1); +print execute sql select concat(c8,concat(c8,c14)) from tb1 interval(1s) sliding(1s) fill(NULL); +sql_error select concat(c8,concat(c8,c14)) from tb1 interval(1s) sliding(1s) fill(NULL); +print execute sql select concat(c8,concat(c8,c14)) from stb1 group by t1; +sql_error select concat(c8,concat(c8,c14)) from stb1 group by t1; +print execute sql select concat(c8,concat(c8,c14)) from stb1 group by ts; +sql_error select concat(c8,concat(c8,c14)) from stb1 group by ts; +print execute sql select concat(c8,concat(c8,c14)) from stb1 group by c1; +sql_error select concat(c8,concat(c8,c14)) from stb1 group by c1; +print execute sql select concat(c8,concat(c8,c14)) from stb1 group by tbname; +sql_error select concat(c8,concat(c8,c14)) from stb1 group by tbname; +print execute sql select concat(c8,concat(c8,c14)) from tb1 order by c8; +sql_error select concat(c8,concat(c8,c14)) from tb1 order by c8; +print execute sql select concat(c8,c8),concat(c8,c14) from tbn; +sql select concat(c8,c8),concat(c8,c14) from tbn; +if $data00 != @111111@ then + return -1 +endi +if $data01 != @1111@ then + return -1 +endi +if $data10 != @222222@ then + return -1 +endi +if $data11 != @2222@ then + return -1 +endi +if $data20 != @333333@ then + return -1 +endi +if $data21 != @3333@ then + return -1 +endi +if $data30 != @444444@ then + return -1 +endi +if $data31 != @4444@ then + return -1 +endi +if $data40 != @555555@ then + return -1 +endi +if $data41 != @5555@ then + return -1 +endi +if $data50 != @666666@ then + return -1 +endi +if $data51 != @6666@ then + return -1 +endi +if $data60 != @777777@ then + return -1 +endi +if $data61 != @7777@ then + return -1 +endi +print execute sql select concat(cast(a as binary(4)),cast(a as binary(4))) from (select avg(c2) as a from stb1 interval(1s)); +sql select concat(cast(a as binary(4)),cast(a as binary(4))) from (select avg(c2) as a from stb1 interval(1s)); +if $data00 != @1.001.00@ then + return -1 +endi +if $data10 != @2.002.00@ then + return -1 +endi +if $data20 != @2.502.50@ then + return -1 +endi +if $data30 != @4.004.00@ then + return -1 +endi +if $data40 != @4.504.50@ then + return -1 +endi +if $data50 != @66.566.5@ then + return -1 +endi +if $data60 != @-60.-60.@ then + return -1 +endi +print execute sql select concat(c8,a) from (select c8, concat(c8,c8) as a from tb1); +sql select concat(c8,a) from (select c8, concat(c8,c8) as a from tb1); +if $data00 != @123123123@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data20 != @234234234@ then + return -1 +endi +if $data30 != @NULL@ then + return -1 +endi +if $data40 != @456456456@ then + return -1 +endi +if $data50 != @567567567@ then + return -1 +endi +if $data60 != @678678678@ then + return -1 +endi +print execute sql select concat(c8,"abc") from tb1; +sql select concat(c8,"abc") from tb1; +if $data00 != @123abc@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data20 != @234abc@ then + return -1 +endi +if $data30 != @NULL@ then + return -1 +endi +if $data40 != @456abc@ then + return -1 +endi +if $data50 != @567abc@ then + return -1 +endi +if $data60 != @678abc@ then + return -1 +endi +print execute sql select concat(c8,concat(c8,c14)) from tb1; +sql select concat(c8,concat(c8,c14)) from tb1; +if $data00 != @1231231@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data20 != @2342342@ then + return -1 +endi +if $data30 != @NULL@ then + return -1 +endi +if $data40 != @4564564@ then + return -1 +endi +if $data50 != @56756727@ then + return -1 +endi +if $data60 != @678678@ then + return -1 +endi +print execute sql select concat(c8,concat(c14,c8)) from tb1; +sql select concat(c8,concat(c14,c8)) from tb1; +if $data00 != @1231123@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data20 != @2342234@ then + return -1 +endi +if $data30 != @NULL@ then + return -1 +endi +if $data40 != @4564456@ then + return -1 +endi +if $data50 != @56727567@ then + return -1 +endi +if $data60 != @678678@ then + return -1 +endi +print execute sql select concat(c8,concat(concat(c14,c8), c8, '6') from tb1; +sql_error select concat(c8,concat(concat(c14,c8), c8, '6') from tb1; +print execute sql select concat(concat(c8,'11'), c8) from tb1; +sql select concat(concat(c8,'11'), c8) from tb1; +if $data00 != @12311123@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data20 != @23411234@ then + return -1 +endi +if $data30 != @NULL@ then + return -1 +endi +if $data40 != @45611456@ then + return -1 +endi +if $data50 != @56711567@ then + return -1 +endi +if $data60 != @67811678@ then + return -1 +endi +print execute sql select concat(concat(c8,c14), c8) from tb1; +sql select concat(concat(c8,c14), c8) from tb1; +if $data00 != @1231123@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data20 != @2342234@ then + return -1 +endi +if $data30 != @NULL@ then + return -1 +endi +if $data40 != @4564456@ then + return -1 +endi +if $data50 != @56727567@ then + return -1 +endi +if $data60 != @678678@ then + return -1 +endi +print execute sql select concat(concat(c8,c8), '11') from tb1; +sql select concat(concat(c8,c8), '11') from tb1; +if $data00 != @12312311@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data20 != @23423411@ then + return -1 +endi +if $data30 != @NULL@ then + return -1 +endi +if $data40 != @45645611@ then + return -1 +endi +if $data50 != @56756711@ then + return -1 +endi +if $data60 != @67867811@ then + return -1 +endi +print execute sql select concat(c8,c14),c14,c8 from tb1; +sql select concat(c8,c14),c14,c8 from tb1; +if $data00 != @1231@ then + return -1 +endi +if $data01 != @1@ then + return -1 +endi +if $data02 != @123@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data11 != @NULL@ then + return -1 +endi +if $data12 != @NULL@ then + return -1 +endi +if $data20 != @2342@ then + return -1 +endi +if $data21 != @2@ then + return -1 +endi +if $data22 != @234@ then + return -1 +endi +if $data30 != @NULL@ then + return -1 +endi +if $data31 != @NULL@ then + return -1 +endi +if $data32 != @NULL@ then + return -1 +endi +if $data40 != @4564@ then + return -1 +endi +if $data41 != @4@ then + return -1 +endi +if $data42 != @456@ then + return -1 +endi +if $data50 != @56727@ then + return -1 +endi +if $data51 != @27@ then + return -1 +endi +if $data52 != @567@ then + return -1 +endi +if $data60 != @678@ then + return -1 +endi +if $data61 != $emptyString then + return -1 +endi +if $data62 != @678@ then + return -1 +endi +print execute sql select concat(c8,c14),t1,ts,tbname,_C0,_c0 from tb1; +sql select concat(c8,c14),t1,ts,tbname,_C0,_c0 from tb1; +if $data00 != @1231@ then + return -1 +endi +if $data01 != @1@ then + return -1 +endi +if $data02 != @21-11-11 09:00:00.000@ then + return -1 +endi +if $data03 != @tb1@ then + return -1 +endi +if $data04 != @21-11-11 09:00:00.000@ then + return -1 +endi +if $data05 != @21-11-11 09:00:00.000@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data11 != @1@ then + return -1 +endi +if $data12 != @21-11-11 09:00:01.000@ then + return -1 +endi +if $data13 != @tb1@ then + return -1 +endi +if $data14 != @21-11-11 09:00:01.000@ then + return -1 +endi +if $data15 != @21-11-11 09:00:01.000@ then + return -1 +endi +if $data20 != @2342@ then + return -1 +endi +if $data21 != @1@ then + return -1 +endi +if $data22 != @21-11-11 09:00:02.000@ then + return -1 +endi +if $data23 != @tb1@ then + return -1 +endi +if $data24 != @21-11-11 09:00:02.000@ then + return -1 +endi +if $data25 != @21-11-11 09:00:02.000@ then + return -1 +endi +if $data30 != @NULL@ then + return -1 +endi +if $data31 != @1@ then + return -1 +endi +if $data32 != @21-11-11 09:00:03.000@ then + return -1 +endi +if $data33 != @tb1@ then + return -1 +endi +if $data34 != @21-11-11 09:00:03.000@ then + return -1 +endi +if $data35 != @21-11-11 09:00:03.000@ then + return -1 +endi +if $data40 != @4564@ then + return -1 +endi +if $data41 != @1@ then + return -1 +endi +if $data42 != @21-11-11 09:00:04.000@ then + return -1 +endi +if $data43 != @tb1@ then + return -1 +endi +if $data44 != @21-11-11 09:00:04.000@ then + return -1 +endi +if $data45 != @21-11-11 09:00:04.000@ then + return -1 +endi +if $data50 != @56727@ then + return -1 +endi +if $data51 != @1@ then + return -1 +endi +if $data52 != @21-11-11 09:00:05.000@ then + return -1 +endi +if $data53 != @tb1@ then + return -1 +endi +if $data54 != @21-11-11 09:00:05.000@ then + return -1 +endi +if $data55 != @21-11-11 09:00:05.000@ then + return -1 +endi +if $data60 != @678@ then + return -1 +endi +if $data61 != @1@ then + return -1 +endi +if $data62 != @21-11-11 09:00:06.000@ then + return -1 +endi +if $data63 != @tb1@ then + return -1 +endi +if $data64 != @21-11-11 09:00:06.000@ then + return -1 +endi +if $data65 != @21-11-11 09:00:06.000@ then + return -1 +endi +print execute sql select concat(c8,c14),floor(c7) from tb1; +sql select concat(c8,c14),floor(c7) from tb1; +if $data00 != @1231@ then + return -1 +endi +if $data01 != @1.000000000@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data11 != @NULL@ then + return -1 +endi +if $data20 != @2342@ then + return -1 +endi +if $data21 != @NULL@ then + return -1 +endi +if $data30 != @NULL@ then + return -1 +endi +if $data31 != @3.000000000@ then + return -1 +endi +if $data40 != @4564@ then + return -1 +endi +if $data41 != @4.000000000@ then + return -1 +endi +if $data50 != @56727@ then + return -1 +endi +if $data51 != @179769000000000006323030492138942643493033036433685336215410983289126434148906289940615299632196609445533816320312774433484859900046491141051651091672734470972759941382582304802812882753059262973637182942535982636884444611376868582636745405553206881859340916340092953230149901406738427651121855107737424232448.000000000@ then + return -1 +endi +if $data60 != @678@ then + return -1 +endi +if $data61 != @-179769000000000006323030492138942643493033036433685336215410983289126434148906289940615299632196609445533816320312774433484859900046491141051651091672734470972759941382582304802812882753059262973637182942535982636884444611376868582636745405553206881859340916340092953230149901406738427651121855107737424232448.000000000@ then + return -1 +endi +print execute sql select concat(c8,c14),concat(c8,concat(c8,c14)) from tb1; +sql select concat(c8,c14),concat(c8,concat(c8,c14)) from tb1; +if $data00 != @1231@ then + return -1 +endi +if $data01 != @1231231@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data11 != @NULL@ then + return -1 +endi +if $data20 != @2342@ then + return -1 +endi +if $data21 != @2342342@ then + return -1 +endi +if $data30 != @NULL@ then + return -1 +endi +if $data31 != @NULL@ then + return -1 +endi +if $data40 != @4564@ then + return -1 +endi +if $data41 != @4564564@ then + return -1 +endi +if $data50 != @56727@ then + return -1 +endi +if $data51 != @56756727@ then + return -1 +endi +if $data60 != @678@ then + return -1 +endi +if $data61 != @678678@ then + return -1 +endi +print execute sql select concat(c8,concat(c8,c14)) from tb1 where c8 is not null and c9 is not null; +sql select concat(c8,concat(c8,c14)) from tb1 where c8 is not null and c9 is not null; +if $data00 != @1231231@ then + return -1 +endi +if $data10 != @4564564@ then + return -1 +endi +if $data20 != @56756727@ then + return -1 +endi +if $data30 != @678678@ then + return -1 +endi +print execute sql select concat(c8,c8) from tb1 order by ts desc; +sql select concat(c8,c8) from tb1 order by ts desc; +if $data00 != @678678@ then + return -1 +endi +if $data10 != @567567@ then + return -1 +endi +if $data20 != @456456@ then + return -1 +endi +if $data30 != @NULL@ then + return -1 +endi +if $data40 != @234234@ then + return -1 +endi +if $data50 != @NULL@ then + return -1 +endi +if $data60 != @123123@ then + return -1 +endi +print execute sql select concat(c8,concat(c8,c14)) from tb1 order by ts desc; +sql select concat(c8,concat(c8,c14)) from tb1 order by ts desc; +if $data00 != @678678@ then + return -1 +endi +if $data10 != @56756727@ then + return -1 +endi +if $data20 != @4564564@ then + return -1 +endi +if $data30 != @NULL@ then + return -1 +endi +if $data40 != @2342342@ then + return -1 +endi +if $data50 != @NULL@ then + return -1 +endi +if $data60 != @1231231@ then + return -1 +endi +print execute sql select concat(c8,concat(c8,c14)) from tb1 order by ts desc limit 3 offset 2; +sql select concat(c8,concat(c8,c14)) from tb1 order by ts desc limit 3 offset 2; +if $data00 != @4564564@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data20 != @2342342@ then + return -1 +endi +print execute sql select concat(c8,c8) from stb1; +sql select concat(c8,c8) from stb1; +if $data00 != @123123@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data20 != @234234@ then + return -1 +endi +if $data30 != @NULL@ then + return -1 +endi +if $data40 != @456456@ then + return -1 +endi +if $data50 != @567567@ then + return -1 +endi +if $data60 != @678678@ then + return -1 +endi +if $data70 != @111111@ then + return -1 +endi +if $data80 != @222222@ then + return -1 +endi +if $data90 != @333333@ then + return -1 +endi +print execute sql select concat(c8,c8) from stb1 order by ts desc; +sql select concat(c8,c8) from stb1 order by ts desc; +if $data00 != @777777@ then + if $data00 != @678678@ then + return -1 + endi +endi +if $data20 != @666666@ then + if $data20 != @567567@ then + return -1 + endi +endi +if $data40 != @555555@ then + if $data40 != @456456@ then + return -1 + endi +endi +if $data60 != @444444@ then + if $data60 != @NULL@ then + return -1 + endi +endi +if $data80 != @333333@ then + if $data80 != @234234@ then + return -1 + endi +endi +print execute sql select concat(c8,c14),t1 from stb1 order by ts desc; +sql select concat(c8,c14),t1 from stb1 order by ts desc; +if $data00 != @7777@ then + if $data00 != @678@ then + return -1 + endi +endi +if $data01 != @2@ then + if $data01 != @1@ then + return -1 + endi +endi +if $data20 != @6666@ then + if $data20 != @56727@ then + return -1 + endi +endi +if $data21 != @2@ then + if $data21 != @1@ then + return -1 + endi +endi +if $data40 != @5555@ then + if $data40 != @4564@ then + return -1 + endi +endi +if $data41 != @2@ then + if $data41 != @1@ then + return -1 + endi +endi +if $data60 != @4444@ then + if $data60 != @NULL@ then + return -1 + endi +endi +if $data61 != @2@ then + if $data61 != @1@ then + return -1 + endi +endi +if $data80 != @3333@ then + if $data80 != @2342@ then + return -1 + endi +endi +if $data81 != @2@ then + if $data81 != @1@ then + return -1 + endi +endi +print execute sql select concat(c8,c14),tbname from stb1; +sql select concat(c8,c14),tbname from stb1; +if $data00 != @1231@ then + return -1 +endi +if $data01 != @tb1@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data11 != @tb1@ then + return -1 +endi +if $data20 != @2342@ then + return -1 +endi +if $data21 != @tb1@ then + return -1 +endi +if $data30 != @NULL@ then + return -1 +endi +if $data31 != @tb1@ then + return -1 +endi +if $data40 != @4564@ then + return -1 +endi +if $data41 != @tb1@ then + return -1 +endi +if $data50 != @56727@ then + return -1 +endi +if $data51 != @tb1@ then + return -1 +endi +if $data60 != @678@ then + return -1 +endi +if $data61 != @tb1@ then + return -1 +endi +if $data70 != @1111@ then + return -1 +endi +if $data71 != @tb2@ then + return -1 +endi +if $data80 != @2222@ then + return -1 +endi +if $data81 != @tb2@ then + return -1 +endi +if $data90 != @3333@ then + return -1 +endi +if $data91 != @tb2@ then + return -1 +endi +print execute sql select concat(c8,c14),tbname from stb1 where t1 > 1; +sql select concat(c8,c14),tbname from stb1 where t1 > 1; +if $data00 != @1111@ then + return -1 +endi +if $data01 != @tb2@ then + return -1 +endi +if $data10 != @2222@ then + return -1 +endi +if $data11 != @tb2@ then + return -1 +endi +if $data20 != @3333@ then + return -1 +endi +if $data21 != @tb2@ then + return -1 +endi +if $data30 != @4444@ then + return -1 +endi +if $data31 != @tb2@ then + return -1 +endi +if $data40 != @5555@ then + return -1 +endi +if $data41 != @tb2@ then + return -1 +endi +if $data50 != @6666@ then + return -1 +endi +if $data51 != @tb2@ then + return -1 +endi +if $data60 != @7777@ then + return -1 +endi +if $data61 != @tb2@ then + return -1 +endi +print execute sql select concat(c8,c8),concat(c8,c14) from tbn; +sql select concat(c8,c8),concat(c8,c14) from tbn; +if $data00 != @111111@ then + return -1 +endi +if $data01 != @1111@ then + return -1 +endi +if $data10 != @222222@ then + return -1 +endi +if $data11 != @2222@ then + return -1 +endi +if $data20 != @333333@ then + return -1 +endi +if $data21 != @3333@ then + return -1 +endi +if $data30 != @444444@ then + return -1 +endi +if $data31 != @4444@ then + return -1 +endi +if $data40 != @555555@ then + return -1 +endi +if $data41 != @5555@ then + return -1 +endi +if $data50 != @666666@ then + return -1 +endi +if $data51 != @6666@ then + return -1 +endi +if $data60 != @777777@ then + return -1 +endi +if $data61 != @7777@ then + return -1 +endi +print execute sql select concat(c8,c8),concat(c8,c14) from tbn order by ts desc; +sql select concat(c8,c8),concat(c8,c14) from tbn order by ts desc; +if $data00 != @777777@ then + return -1 +endi +if $data01 != @7777@ then + return -1 +endi +if $data10 != @666666@ then + return -1 +endi +if $data11 != @6666@ then + return -1 +endi +if $data20 != @555555@ then + return -1 +endi +if $data21 != @5555@ then + return -1 +endi +if $data30 != @444444@ then + return -1 +endi +if $data31 != @4444@ then + return -1 +endi +if $data40 != @333333@ then + return -1 +endi +if $data41 != @3333@ then + return -1 +endi +if $data50 != @222222@ then + return -1 +endi +if $data51 != @2222@ then + return -1 +endi +if $data60 != @111111@ then + return -1 +endi +if $data61 != @1111@ then + return -1 +endi +print execute sql select concat(c8,concat(c8,c8)) from tbn; +sql select concat(c8,concat(c8,c8)) from tbn; +if $data00 != @111111111@ then + return -1 +endi +if $data10 != @222222222@ then + return -1 +endi +if $data20 != @333333333@ then + return -1 +endi +if $data30 != @444444444@ then + return -1 +endi +if $data40 != @555555555@ then + return -1 +endi +if $data50 != @666666666@ then + return -1 +endi +if $data60 != @777777777@ then + return -1 +endi +print execute sql select concat(cast(a as binary(10)),cast(a as binary(10))) from (select avg(c6) as a from stb1 interval(1s)); +sql select concat(cast(a as binary(10)),cast(a as binary(10))) from (select avg(c6) as a from stb1 interval(1s)); +if $data00 != @1.0000001.000000@ then + return -1 +endi +if $data10 != @2.0000002.000000@ then + return -1 +endi +if $data20 != @2.5000002.500000@ then + return -1 +endi +if $data30 != @4.0000004.000000@ then + return -1 +endi +if $data40 != @4.5000004.500000@ then + return -1 +endi +if $data50 != @17014117331701411733@ then + return -1 +endi +if $data60 != @-170141173-170141173@ then + return -1 +endi +print execute sql select concat(c8,c8) from (select * from stb1); +sql select concat(c8,c8) from (select * from stb1); +if $data00 != @123123@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data20 != @234234@ then + return -1 +endi +if $data30 != @NULL@ then + return -1 +endi +if $data40 != @456456@ then + return -1 +endi +if $data50 != @567567@ then + return -1 +endi +if $data60 != @678678@ then + return -1 +endi +if $data70 != @111111@ then + return -1 +endi +if $data80 != @222222@ then + return -1 +endi +if $data90 != @333333@ then + return -1 +endi +print execute sql select concat(cast(a as binary(4)),cast(a as binary(4))) from (select avg(c6) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)); +sql select concat(cast(a as binary(4)),cast(a as binary(4))) from (select avg(c6) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)); +if $data00 != @1.001.00@ then + return -1 +endi +if $data10 != @2.002.00@ then + return -1 +endi +if $data20 != @2.502.50@ then + return -1 +endi +if $data30 != @4.004.00@ then + return -1 +endi +if $data40 != @4.504.50@ then + return -1 +endi +if $data50 != @17011701@ then + return -1 +endi +if $data60 != @-170-170@ then + return -1 +endi +if $data70 != @NULL@ then + return -1 +endi +if $data80 != @NULL@ then + return -1 +endi +if $data90 != @NULL@ then + return -1 +endi +print execute sql select concat(cast(a as binary(4)),cast(a as binary(4))) from (select avg(c6) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)) order by ts; +sql select concat(cast(a as binary(4)),cast(a as binary(4))) from (select avg(c6) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)) order by ts; +if $data00 != @1.001.00@ then + return -1 +endi +if $data10 != @2.002.00@ then + return -1 +endi +if $data20 != @2.502.50@ then + return -1 +endi +if $data30 != @4.004.00@ then + return -1 +endi +if $data40 != @4.504.50@ then + return -1 +endi +if $data50 != @17011701@ then + return -1 +endi +if $data60 != @-170-170@ then + return -1 +endi +if $data70 != @NULL@ then + return -1 +endi +if $data80 != @NULL@ then + return -1 +endi +if $data90 != @NULL@ then + return -1 +endi +print execute sql select concat(cast(a as binary(4)),cast(a as binary(4))) from (select avg(c6) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)) order by ts desc; +sql select concat(cast(a as binary(4)),cast(a as binary(4))) from (select avg(c6) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)) order by ts desc; +if $data00 != @NULL@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data20 != @NULL@ then + return -1 +endi +if $data30 != @-170-170@ then + return -1 +endi +if $data40 != @17011701@ then + return -1 +endi +if $data50 != @4.504.50@ then + return -1 +endi +if $data60 != @4.004.00@ then + return -1 +endi +if $data70 != @2.502.50@ then + return -1 +endi +if $data80 != @2.002.00@ then + return -1 +endi +if $data90 != @1.001.00@ then + return -1 +endi +print execute sql select concat(cast(a as binary(4)),cast(a as binary(4))) from (select avg(c6) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)) order by a desc; +sql select concat(cast(a as binary(4)),cast(a as binary(4))) from (select avg(c6) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)) order by a desc; +if $data00 != @NULL@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data20 != @NULL@ then + return -1 +endi +if $data30 != @17011701@ then + return -1 +endi +if $data40 != @4.504.50@ then + return -1 +endi +if $data50 != @4.004.00@ then + return -1 +endi +if $data60 != @2.502.50@ then + return -1 +endi +if $data70 != @2.002.00@ then + return -1 +endi +if $data80 != @1.001.00@ then + return -1 +endi +if $data90 != @-170-170@ then + return -1 +endi +print execute sql select concat(cast(a as binary(4)),cast(a as binary(4))) from (select avg(c6) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)) order by a; +sql select concat(cast(a as binary(4)),cast(a as binary(4))) from (select avg(c6) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)) order by a; +if $data00 != @-170-170@ then + return -1 +endi +if $data10 != @1.001.00@ then + return -1 +endi +if $data20 != @2.002.00@ then + return -1 +endi +if $data30 != @2.502.50@ then + return -1 +endi +if $data40 != @4.004.00@ then + return -1 +endi +if $data50 != @4.504.50@ then + return -1 +endi +if $data60 != @17011701@ then + return -1 +endi +if $data70 != @NULL@ then + return -1 +endi +if $data80 != @NULL@ then + return -1 +endi +if $data90 != @NULL@ then + return -1 +endi +print execute sql select concat(cast(a as binary(4)),cast(a as binary(4))) from (select concat(c8,c8) as a from tb1); +sql select concat(cast(a as binary(4)),cast(a as binary(4))) from (select concat(c8,c8) as a from tb1); +if $data00 != @12311231@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data20 != @23422342@ then + return -1 +endi +if $data30 != @NULL@ then + return -1 +endi +if $data40 != @45644564@ then + return -1 +endi +if $data50 != @56755675@ then + return -1 +endi +if $data60 != @67866786@ then + return -1 +endi +print execute sql select concat(tb1.c8,tb1.c14),concat(tb2.c8,tb2.c14) from tb1,tb2 where tb1.ts=tb2.ts; +sql select concat(tb1.c8,tb1.c14),concat(tb2.c8,tb2.c14) from tb1,tb2 where tb1.ts=tb2.ts; +if $data00 != @1231@ then + return -1 +endi +if $data01 != @1111@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data11 != @2222@ then + return -1 +endi +if $data20 != @2342@ then + return -1 +endi +if $data21 != @3333@ then + return -1 +endi +if $data30 != @NULL@ then + return -1 +endi +if $data31 != @4444@ then + return -1 +endi +if $data40 != @4564@ then + return -1 +endi +if $data41 != @5555@ then + return -1 +endi +if $data50 != @56727@ then + return -1 +endi +if $data51 != @6666@ then + return -1 +endi +if $data60 != @678@ then + return -1 +endi +if $data61 != @7777@ then + return -1 +endi +print execute sql select concat(c8,c14) from tb1 union all select concat(c8,c14) from tb2; +sql select concat(c8,c14) from tb1 union all select concat(c8,c14) from tb2; +if $data00 != @1231@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data20 != @2342@ then + return -1 +endi +if $data30 != @NULL@ then + return -1 +endi +if $data40 != @4564@ then + return -1 +endi +if $data50 != @56727@ then + return -1 +endi +if $data60 != @678@ then + return -1 +endi +if $data70 != @1111@ then + return -1 +endi +if $data80 != @2222@ then + return -1 +endi +if $data90 != @3333@ then + return -1 +endi +print execute sql select concat(c8, cast(a as binary(10))),c8, a from (select c8,c2 as a from stb1) +sql select concat(c8, cast(a as binary(10))),c8, a from (select c8,c2 as a from stb1) +if $data00 != @1231@ then + return -1 +endi +if $data01 != @123@ then + return -1 +endi +if $data02 != @1@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data11 != @NULL@ then + return -1 +endi +if $data12 != @NULL@ then + return -1 +endi +if $data20 != @2342@ then + return -1 +endi +if $data21 != @234@ then + return -1 +endi +if $data22 != @2@ then + return -1 +endi +if $data30 != @NULL@ then + return -1 +endi +if $data31 != @NULL@ then + return -1 +endi +if $data32 != @NULL@ then + return -1 +endi +if $data40 != @4564@ then + return -1 +endi +if $data41 != @456@ then + return -1 +endi +if $data42 != @4@ then + return -1 +endi +if $data50 != @567127@ then + return -1 +endi +if $data51 != @567@ then + return -1 +endi +if $data52 != @127@ then + return -1 +endi +if $data60 != @678-127@ then + return -1 +endi +if $data61 != @678@ then + return -1 +endi +if $data62 != @-127@ then + return -1 +endi +if $data70 != @1111@ then + return -1 +endi +if $data71 != @111@ then + return -1 +endi +if $data72 != @1@ then + return -1 +endi +if $data80 != @2222@ then + return -1 +endi +if $data81 != @222@ then + return -1 +endi +if $data82 != @2@ then + return -1 +endi +if $data90 != @3333@ then + return -1 +endi +if $data91 != @333@ then + return -1 +endi +if $data92 != @3@ then + return -1 +endi +print execute sql select concat(c9,concat(c9,c15)) from tb1; +sql select concat(c9,concat(c9,c15)) from tb1; +if $data00 != @123412341@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data20 != @NULL@ then + return -1 +endi +if $data30 != @345634563@ then + return -1 +endi +if $data40 != @456745674@ then + return -1 +endi +if $data50 != @56785678278@ then + return -1 +endi +if $data60 != @67896789@ then + return -1 +endi +print execute sql select concat(c9,concat(c15,c9)) from tb1; +sql select concat(c9,concat(c15,c9)) from tb1; +if $data00 != @123411234@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data20 != @NULL@ then + return -1 +endi +if $data30 != @345633456@ then + return -1 +endi +if $data40 != @456744567@ then + return -1 +endi +if $data50 != @56782785678@ then + return -1 +endi +if $data60 != @67896789@ then + return -1 +endi +print execute sql select concat(c9,concat(concat(c15,c9), c9, '6')) from tb1; +sql select concat(c9,concat(concat(c15,c9), c9, '6')) from tb1; +if $data00 != @12341123412346@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data20 != @NULL@ then + return -1 +endi +if $data30 != @34563345634566@ then + return -1 +endi +if $data40 != @45674456745676@ then + return -1 +endi +if $data50 != @5678278567856786@ then + return -1 +endi +if $data60 != @6789678967896@ then + return -1 +endi diff --git a/tests/script/general/compute/str_concat2.sim b/tests/script/general/compute/str_concat2.sim new file mode 100644 index 0000000000000000000000000000000000000000..4f4289719be7154e58e6e9ebffdb1189774469af --- /dev/null +++ b/tests/script/general/compute/str_concat2.sim @@ -0,0 +1,211 @@ +sleep 100 +sql connect +sql use db + +$emptyString = @@ +print execute sql select concat(stb1.c8,stb1.c14),pow(stba.c2,stba.c5) from stb1,stba where stb1.t1=stba.t1 and stb1.ts=stba.ts; +sql select concat(stb1.c8,stb1.c14),pow(stba.c2,stba.c5) from stb1,stba where stb1.t1=stba.t1 and stb1.ts=stba.ts; +if $data00 != @1231@ then + return -1 +endi +if $data01 != @1.000000000@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data11 != @4.000000000@ then + return -1 +endi +if $data20 != @2342@ then + return -1 +endi +if $data21 != @27.000000000@ then + return -1 +endi +if $data30 != @NULL@ then + return -1 +endi +if $data31 != @256.000000000@ then + return -1 +endi +if $data40 != @4564@ then + return -1 +endi +if $data41 != @3125.000000000@ then + return -1 +endi +if $data50 != @56727@ then + return -1 +endi +if $data51 != @46656.000000000@ then + return -1 +endi +if $data60 != @678@ then + return -1 +endi +if $data61 != @823543.000000000@ then + return -1 +endi +print execute sql select concat(c8,c14) as a from stb1 union all select concat(c8,c14) as a from stba; +sql select concat(c8,c14) as a from stb1 union all select concat(c8,c14) as a from stba; +if $data00 != @1231@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data20 != @2342@ then + return -1 +endi +if $data30 != @NULL@ then + return -1 +endi +if $data40 != @4564@ then + return -1 +endi +if $data50 != @56727@ then + return -1 +endi +if $data60 != @678@ then + return -1 +endi +if $data70 != @1111@ then + return -1 +endi +if $data80 != @2222@ then + return -1 +endi +if $data90 != @3333@ then + return -1 +endi +print execute sql select concat(c8,c14) from stba; +sql select concat(c8,c14) from stba; +if $data00 != @1111@ then + return -1 +endi +if $data10 != @2222@ then + return -1 +endi +if $data20 != @3333@ then + return -1 +endi +if $data30 != @4444@ then + return -1 +endi +if $data40 != @5555@ then + return -1 +endi +if $data50 != @6666@ then + return -1 +endi +if $data60 != @7777@ then + return -1 +endi +if $data70 != @8888@ then + return -1 +endi +if $data80 != @9999@ then + return -1 +endi +if $data90 != @0000@ then + return -1 +endi +print execute sql select concat('c8',cast(min(c2) as binary(10))) from tba1; +sql select concat('c8',cast(min(c2) as binary(10))) from tba1; +if $data00 != @c80@ then + return -1 +endi +print execute sql select concat('c8',cast(max(c2) as binary(10))) from tba1; +sql select concat('c8',cast(max(c2) as binary(10))) from tba1; +if $data00 != @c89@ then + return -1 +endi +print execute sql select concat('c8',cast(count(c2) as binary(10))) from tba1; +sql select concat('c8',cast(count(c2) as binary(10))) from tba1; +if $data00 != @c830@ then + return -1 +endi +print execute sql select concat('c8',cast(sum(c2) as binary(10))) from tba1; +sql select concat('c8',cast(sum(c2) as binary(10))) from tba1; +if $data00 != @c8135@ then + return -1 +endi +print execute sql select concat('c8',cast(avg(c2) as binary(10))) from tba1; +sql select concat('c8',cast(avg(c2) as binary(10))) from tba1; +if $data00 != @c84.500000@ then + return -1 +endi +print execute sql select concat('c8',cast(percentile(c2, 10) as binary(10))) from tba1; +sql select concat('c8',cast(percentile(c2, 10) as binary(10))) from tba1; +if $data00 != @c80.900000@ then + return -1 +endi +print execute sql select concat('c8',cast(apercentile(c2, 10) as binary(10))) from tba1; +sql select concat('c8',cast(apercentile(c2, 10) as binary(10))) from tba1; +if $data00 != @c80.000000@ then + return -1 +endi +print execute sql select concat('c8',cast(stddev(c2) as binary(10))) from tba1; +sql select concat('c8',cast(stddev(c2) as binary(10))) from tba1; +if $data00 != @c82.872281@ then + return -1 +endi +print execute sql select concat('c8',cast(spread(c2) as binary(10))) from tba1; +sql select concat('c8',cast(spread(c2) as binary(10))) from tba1; +if $data00 != @c89.000000@ then + return -1 +endi +print execute sql select concat('c8',cast(twa(c2) as binary(10))) from tba1; +sql select concat('c8',cast(twa(c2) as binary(10))) from tba1; +if $data00 != @c84.637931@ then + return -1 +endi +print execute sql select concat('c8',cast(elapsed(ts) as binary(10))) from tba1; +sql select concat('c8',cast(elapsed(ts) as binary(10))) from tba1; +if $data00 != @c829000.0000@ then + return -1 +endi +print execute sql select concat('c8',cast(rate(c2) as binary(10))) from tba1; +sql select concat('c8',cast(rate(c2) as binary(10))) from tba1; +if $data00 != @c80.896552@ then + return -1 +endi +print execute sql select concat('c8',cast(irate(c2) as binary(10))) from tba1; +sql select concat('c8',cast(irate(c2) as binary(10))) from tba1; +if $data00 != @c80.000000@ then + return -1 +endi +print execute sql select concat('c8',cast(first(c2) as binary(10))) from tba1; +sql select concat('c8',cast(first(c2) as binary(10))) from tba1; +if $data00 != @c81@ then + return -1 +endi +print execute sql select concat('c8',cast(last(c2) as binary(10))) from tba1; +sql select concat('c8',cast(last(c2) as binary(10))) from tba1; +if $data00 != @c80@ then + return -1 +endi +print execute sql select concat('c8',cast(last_row(c2) as binary(10))) from tba1; +sql select concat('c8',cast(last_row(c2) as binary(10))) from tba1; +if $data00 != @c80@ then + return -1 +endi +print execute sql select concat('c8',cast(top(c2, 1) as binary(10))) from tba1; +sql_error select concat('c8',cast(top(c2, 1) as binary(10))) from tba1; +print execute sql select concat('c8',cast(bottom(c2, 1) as binary(10))) from tba1; +sql_error select concat('c8',cast(bottom(c2, 1) as binary(10))) from tba1; +print execute sql select concat('c8',cast(leastsquares(c2, 1, 1) as binary(10))) from tba1; +sql_error select concat('c8',cast(leastsquares(c2, 1, 1) as binary(10))) from tba1; +print execute sql select concat('c8',cast(derivative(c2, 1s, 0) as binary(10))) from tba1; +sql_error select concat('c8',cast(derivative(c2, 1s, 0) as binary(10))) from tba1; +print execute sql select concat('c8',cast(diff(c2) as binary(10))) from tba1; +sql_error select concat('c8',cast(diff(c2) as binary(10))) from tba1; +print execute sql select concat('c8',cast(csum(c2) as binary(10))) from tba1; +sql_error select concat('c8',cast(csum(c2) as binary(10))) from tba1; +print execute sql select concat('c8',cast(mavg(c2,2) as binary(10))) from tba1; +sql_error select concat('c8',cast(mavg(c2,2) as binary(10))) from tba1; +print execute sql select concat('c8',cast(sample(c2,2) as binary(10))) from tba1; +sql_error select concat('c8',cast(sample(c2,2) as binary(10))) from tba1; +print execute sql select concat('c8',cast(_block_dist() as binary(10))) from tba1; +sql_error select concat('c8',cast(_block_dist() as binary(10))) from tba1; diff --git a/tests/script/general/compute/str_concat_ws.sim b/tests/script/general/compute/str_concat_ws.sim new file mode 100644 index 0000000000000000000000000000000000000000..c8e55e7c03566d2f4e1d19b1bcd417f2e0b25373 --- /dev/null +++ b/tests/script/general/compute/str_concat_ws.sim @@ -0,0 +1,1592 @@ +sleep 100 +sql connect +sql use db + +$emptyString = @@ +print execute sql select concat_ws('sepa',c8,*) from tb1; +sql_error select concat_ws('sepa',c8,*) from tb1; +print execute sql select concat_ws('sepa',c8,*) from tb1; +sql_error select concat_ws('sepa',c8,*) from tb1; +print execute sql select concat_ws('sepa',c8,*) from tb1; +sql_error select concat_ws('sepa',c8,*) from tb1; +print execute sql select concat_ws('sepa',c8,*) from tb1; +sql_error select concat_ws('sepa',c8,*) from tb1; +print execute sql select concat_ws('sepa',c8,*) as a from tb1; +sql_error select concat_ws('sepa',c8,*) as a from tb1; +print execute sql select concat_ws('sepa',concat(c9,c15), '1') as a from tb1; +sql select concat_ws('sepa',concat(c9,c15), '1') as a from tb1; +if $data00 != @12341sepa1@ then + return -1 +endi +if $data10 != @1@ then + return -1 +endi +if $data20 != @1@ then + return -1 +endi +if $data30 != @34563sepa1@ then + return -1 +endi +if $data40 != @45674sepa1@ then + return -1 +endi +if $data50 != @5678278sepa1@ then + return -1 +endi +if $data60 != @6789sepa1@ then + return -1 +endi +print execute sql select concat_ws('sepa',concat(c8,tb1.*), '1') as a from tb1; +sql_error select concat_ws('sepa',concat(c8,tb1.*), '1') as a from tb1; +print execute sql select concat_ws('sepa',c8,*) from tb1; +sql_error select concat_ws('sepa',c8,*) from tb1; +print execute sql select concat_ws('sepa',c8,c14) from tb1; +sql select concat_ws('sepa',c8,c14) from tb1; +if $data00 != @123sepa1@ then + return -1 +endi +if $data10 != $emptyString then + return -1 +endi +if $data20 != @234sepa2@ then + return -1 +endi +if $data30 != $emptyString then + return -1 +endi +if $data40 != @456sepa4@ then + return -1 +endi +if $data50 != @567sepa27@ then + return -1 +endi +if $data60 != @678sepa@ then + return -1 +endi +print execute sql select concat_ws('sepa',c8,c15) from tb1; +sql_error select concat_ws('sepa',c8,c15) from tb1; +print execute sql select concat_ws('sepa',c8,concat(c14,c8)) from tb1; +sql select concat_ws('sepa',c8,concat(c14,c8)) from tb1; +if $data00 != @123sepa1123@ then + return -1 +endi +if $data10 != $emptyString then + return -1 +endi +if $data20 != @234sepa2234@ then + return -1 +endi +if $data30 != $emptyString then + return -1 +endi +if $data40 != @456sepa4456@ then + return -1 +endi +if $data50 != @567sepa27567@ then + return -1 +endi +if $data60 != @678sepa678@ then + return -1 +endi +print execute sql select concat_ws('sepa',c8,13) from tb1; +sql_error select concat_ws('sepa',c8,13) from tb1; +print execute sql select concat_ws('sepa',c8,c14) from tb1; +sql select concat_ws('sepa',c8,c14) from tb1; +if $data00 != @123sepa1@ then + return -1 +endi +if $data10 != $emptyString then + return -1 +endi +if $data20 != @234sepa2@ then + return -1 +endi +if $data30 != $emptyString then + return -1 +endi +if $data40 != @456sepa4@ then + return -1 +endi +if $data50 != @567sepa27@ then + return -1 +endi +if $data60 != @678sepa@ then + return -1 +endi +print execute sql select concat_ws('sepa',c8,c8) from tb1; +sql select concat_ws('sepa',c8,c8) from tb1; +if $data00 != @123sepa123@ then + return -1 +endi +if $data10 != $emptyString then + return -1 +endi +if $data20 != @234sepa234@ then + return -1 +endi +if $data30 != $emptyString then + return -1 +endi +if $data40 != @456sepa456@ then + return -1 +endi +if $data50 != @567sepa567@ then + return -1 +endi +if $data60 != @678sepa678@ then + return -1 +endi +print execute sql select concat_ws('sepa',c8,c9) from tb1; +sql_error select concat_ws('sepa',c8,c9) from tb1; +print execute sql select concat_ws('sepa',c8,c4) from tb1; +sql_error select concat_ws('sepa',c8,c4) from tb1; +print execute sql select concat_ws('sepa',c8,c5) from tb1; +sql_error select concat_ws('sepa',c8,c5) from tb1; +print execute sql select concat_ws('sepa',c8,c6) from tb1; +sql_error select concat_ws('sepa',c8,c6) from tb1; +print execute sql select concat_ws('sepa',c8,c7) from tb1; +sql_error select concat_ws('sepa',c8,c7) from tb1; +print execute sql select concat_ws('sepa',c8,c8) from tb1; +sql select concat_ws('sepa',c8,c8) from tb1; +if $data00 != @123sepa123@ then + return -1 +endi +if $data10 != $emptyString then + return -1 +endi +if $data20 != @234sepa234@ then + return -1 +endi +if $data30 != $emptyString then + return -1 +endi +if $data40 != @456sepa456@ then + return -1 +endi +if $data50 != @567sepa567@ then + return -1 +endi +if $data60 != @678sepa678@ then + return -1 +endi +print execute sql select concat_ws('sepa',c9,c8) from tb1; +sql_error select concat_ws('sepa',c9,c8) from tb1; +print execute sql select concat_ws('sepa',c8,c10) from tb1; +sql_error select concat_ws('sepa',c8,c10) from tb1; +print execute sql select concat_ws('sepa',c8,c11) from tb1; +sql_error select concat_ws('sepa',c8,c11) from tb1; +print execute sql select concat_ws('sepa',c8,c12) from tb1; +sql_error select concat_ws('sepa',c8,c12) from tb1; +print execute sql select concat_ws('sepa',c8,c13) from tb1; +sql_error select concat_ws('sepa',c8,c13) from tb1; +print execute sql select concat_ws('sepa',c8,12345678900000000000000000) from tb1; +sql_error select concat_ws('sepa',c8,12345678900000000000000000) from tb1; +print execute sql select distinct concat_ws('sepa',c8,'123') from tb1; +sql_error select distinct concat_ws('sepa',c8,'123') from tb1; +print execute sql select concat_ws('sepa',c8,t1) from stb1; +sql_error select concat_ws('sepa',c8,t1) from stb1; +print execute sql select concat_ws('sepa',c8,c14),avg(c2) from tb1; +sql_error select concat_ws('sepa',c8,c14),avg(c2) from tb1; +print execute sql select concat_ws('sepa',c8,c14),top(c3,1) from tb1; +sql_error select concat_ws('sepa',c8,c14),top(c3,1) from tb1; +print execute sql select concat_ws('sepa',c8,concat(c8,c14)) from tb1 session(ts, 1s); +sql_error select concat_ws('sepa',c8,concat(c8,c14)) from tb1 session(ts, 1s); +print execute sql select concat_ws('sepa',c8,concat(c8,c14)) from tb1 STATE_WINDOW(c1); +sql_error select concat_ws('sepa',c8,concat(c8,c14)) from tb1 STATE_WINDOW(c1); +print execute sql select concat_ws('sepa',c8,concat(c8,c14)) from tb1 interval(1s) sliding(1s) fill(NULL); +sql_error select concat_ws('sepa',c8,concat(c8,c14)) from tb1 interval(1s) sliding(1s) fill(NULL); +print execute sql select concat_ws('sepa',c8,concat(c8,c14)) from stb1 group by t1; +sql_error select concat_ws('sepa',c8,concat(c8,c14)) from stb1 group by t1; +print execute sql select concat_ws('sepa',c8,concat(c8,c14)) from stb1 group by ts; +sql_error select concat_ws('sepa',c8,concat(c8,c14)) from stb1 group by ts; +print execute sql select concat_ws('sepa',c8,concat(c8,c14)) from stb1 group by c1; +sql_error select concat_ws('sepa',c8,concat(c8,c14)) from stb1 group by c1; +print execute sql select concat_ws('sepa',c8,concat(c8,c14)) from stb1 group by tbname; +sql_error select concat_ws('sepa',c8,concat(c8,c14)) from stb1 group by tbname; +print execute sql select concat_ws('sepa',c8,concat(c8,c14)) from tb1 order by c8; +sql_error select concat_ws('sepa',c8,concat(c8,c14)) from tb1 order by c8; +print execute sql select concat_ws('sepa',c8,c8),concat(c8,c14) from tbn; +sql select concat_ws('sepa',c8,c8),concat(c8,c14) from tbn; +if $data00 != @111sepa111@ then + return -1 +endi +if $data01 != @1111@ then + return -1 +endi +if $data10 != @222sepa222@ then + return -1 +endi +if $data11 != @2222@ then + return -1 +endi +if $data20 != @333sepa333@ then + return -1 +endi +if $data21 != @3333@ then + return -1 +endi +if $data30 != @444sepa444@ then + return -1 +endi +if $data31 != @4444@ then + return -1 +endi +if $data40 != @555sepa555@ then + return -1 +endi +if $data41 != @5555@ then + return -1 +endi +if $data50 != @666sepa666@ then + return -1 +endi +if $data51 != @6666@ then + return -1 +endi +if $data60 != @777sepa777@ then + return -1 +endi +if $data61 != @7777@ then + return -1 +endi +print execute sql select concat_ws('sepa',cast(a as binary(4)),cast(a as binary(4))) from (select avg(c2) as a from stb1 interval(1s)); +sql select concat_ws('sepa',cast(a as binary(4)),cast(a as binary(4))) from (select avg(c2) as a from stb1 interval(1s)); +if $data00 != @1.00sepa1.00@ then + return -1 +endi +if $data10 != @2.00sepa2.00@ then + return -1 +endi +if $data20 != @2.50sepa2.50@ then + return -1 +endi +if $data30 != @4.00sepa4.00@ then + return -1 +endi +if $data40 != @4.50sepa4.50@ then + return -1 +endi +if $data50 != @66.5sepa66.5@ then + return -1 +endi +if $data60 != @-60.sepa-60.@ then + return -1 +endi +print execute sql select concat_ws('sepa',c8,a) from (select c8, concat_ws('sepa',c8,c8) as a from tb1); +sql select concat_ws('sepa',c8,a) from (select c8, concat_ws('sepa',c8,c8) as a from tb1); +if $data00 != @123sepa123sepa123@ then + return -1 +endi +if $data10 != $emptyString then + return -1 +endi +if $data20 != @234sepa234sepa234@ then + return -1 +endi +if $data30 != $emptyString then + return -1 +endi +if $data40 != @456sepa456sepa456@ then + return -1 +endi +if $data50 != @567sepa567sepa567@ then + return -1 +endi +if $data60 != @678sepa678sepa678@ then + return -1 +endi +print execute sql select concat_ws('sepa',c8,"abc") from tb1; +sql select concat_ws('sepa',c8,"abc") from tb1; +if $data00 != @123sepaabc@ then + return -1 +endi +if $data10 != @abc@ then + return -1 +endi +if $data20 != @234sepaabc@ then + return -1 +endi +if $data30 != @abc@ then + return -1 +endi +if $data40 != @456sepaabc@ then + return -1 +endi +if $data50 != @567sepaabc@ then + return -1 +endi +if $data60 != @678sepaabc@ then + return -1 +endi +print execute sql select concat_ws('sepa',c8,concat(c8,c14)) from tb1; +sql select concat_ws('sepa',c8,concat(c8,c14)) from tb1; +if $data00 != @123sepa1231@ then + return -1 +endi +if $data10 != $emptyString then + return -1 +endi +if $data20 != @234sepa2342@ then + return -1 +endi +if $data30 != $emptyString then + return -1 +endi +if $data40 != @456sepa4564@ then + return -1 +endi +if $data50 != @567sepa56727@ then + return -1 +endi +if $data60 != @678sepa678@ then + return -1 +endi +print execute sql select concat_ws('sepa',c8,concat(c14,c8)) from tb1; +sql select concat_ws('sepa',c8,concat(c14,c8)) from tb1; +if $data00 != @123sepa1123@ then + return -1 +endi +if $data10 != $emptyString then + return -1 +endi +if $data20 != @234sepa2234@ then + return -1 +endi +if $data30 != $emptyString then + return -1 +endi +if $data40 != @456sepa4456@ then + return -1 +endi +if $data50 != @567sepa27567@ then + return -1 +endi +if $data60 != @678sepa678@ then + return -1 +endi +print execute sql select concat_ws('sepa',c8,concat(concat(c14,c8), c8, '6') from tb1; +sql_error select concat_ws('sepa',c8,concat(concat(c14,c8), c8, '6') from tb1; +print execute sql select concat_ws('sepa',concat(c8,'11'), c8) from tb1; +sql select concat_ws('sepa',concat(c8,'11'), c8) from tb1; +if $data00 != @12311sepa123@ then + return -1 +endi +if $data10 != $emptyString then + return -1 +endi +if $data20 != @23411sepa234@ then + return -1 +endi +if $data30 != $emptyString then + return -1 +endi +if $data40 != @45611sepa456@ then + return -1 +endi +if $data50 != @56711sepa567@ then + return -1 +endi +if $data60 != @67811sepa678@ then + return -1 +endi +print execute sql select concat_ws('sepa',concat(c8,c14), c8) from tb1; +sql select concat_ws('sepa',concat(c8,c14), c8) from tb1; +if $data00 != @1231sepa123@ then + return -1 +endi +if $data10 != $emptyString then + return -1 +endi +if $data20 != @2342sepa234@ then + return -1 +endi +if $data30 != $emptyString then + return -1 +endi +if $data40 != @4564sepa456@ then + return -1 +endi +if $data50 != @56727sepa567@ then + return -1 +endi +if $data60 != @678sepa678@ then + return -1 +endi +print execute sql select concat_ws('sepa',concat(c8,c8), '11') from tb1; +sql select concat_ws('sepa',concat(c8,c8), '11') from tb1; +if $data00 != @123123sepa11@ then + return -1 +endi +if $data10 != @11@ then + return -1 +endi +if $data20 != @234234sepa11@ then + return -1 +endi +if $data30 != @11@ then + return -1 +endi +if $data40 != @456456sepa11@ then + return -1 +endi +if $data50 != @567567sepa11@ then + return -1 +endi +if $data60 != @678678sepa11@ then + return -1 +endi +print execute sql select concat_ws('sepa',c8,c14),c14,c8 from tb1; +sql select concat_ws('sepa',c8,c14),c14,c8 from tb1; +if $data00 != @123sepa1@ then + return -1 +endi +if $data01 != @1@ then + return -1 +endi +if $data02 != @123@ then + return -1 +endi +if $data10 != $emptyString then + return -1 +endi +if $data11 != @NULL@ then + return -1 +endi +if $data12 != @NULL@ then + return -1 +endi +if $data20 != @234sepa2@ then + return -1 +endi +if $data21 != @2@ then + return -1 +endi +if $data22 != @234@ then + return -1 +endi +if $data30 != $emptyString then + return -1 +endi +if $data31 != @NULL@ then + return -1 +endi +if $data32 != @NULL@ then + return -1 +endi +if $data40 != @456sepa4@ then + return -1 +endi +if $data41 != @4@ then + return -1 +endi +if $data42 != @456@ then + return -1 +endi +if $data50 != @567sepa27@ then + return -1 +endi +if $data51 != @27@ then + return -1 +endi +if $data52 != @567@ then + return -1 +endi +if $data60 != @678sepa@ then + return -1 +endi +if $data61 != $emptyString then + return -1 +endi +if $data62 != @678@ then + return -1 +endi +print execute sql select concat_ws('sepa',c8,c14),t1,ts,tbname,_C0,_c0 from tb1; +sql select concat_ws('sepa',c8,c14),t1,ts,tbname,_C0,_c0 from tb1; +if $data00 != @123sepa1@ then + return -1 +endi +if $data01 != @1@ then + return -1 +endi +if $data02 != @21-11-11 09:00:00.000@ then + return -1 +endi +if $data03 != @tb1@ then + return -1 +endi +if $data04 != @21-11-11 09:00:00.000@ then + return -1 +endi +if $data05 != @21-11-11 09:00:00.000@ then + return -1 +endi +if $data10 != $emptyString then + return -1 +endi +if $data11 != @1@ then + return -1 +endi +if $data12 != @21-11-11 09:00:01.000@ then + return -1 +endi +if $data13 != @tb1@ then + return -1 +endi +if $data14 != @21-11-11 09:00:01.000@ then + return -1 +endi +if $data15 != @21-11-11 09:00:01.000@ then + return -1 +endi +if $data20 != @234sepa2@ then + return -1 +endi +if $data21 != @1@ then + return -1 +endi +if $data22 != @21-11-11 09:00:02.000@ then + return -1 +endi +if $data23 != @tb1@ then + return -1 +endi +if $data24 != @21-11-11 09:00:02.000@ then + return -1 +endi +if $data25 != @21-11-11 09:00:02.000@ then + return -1 +endi +if $data30 != $emptyString then + return -1 +endi +if $data31 != @1@ then + return -1 +endi +if $data32 != @21-11-11 09:00:03.000@ then + return -1 +endi +if $data33 != @tb1@ then + return -1 +endi +if $data34 != @21-11-11 09:00:03.000@ then + return -1 +endi +if $data35 != @21-11-11 09:00:03.000@ then + return -1 +endi +if $data40 != @456sepa4@ then + return -1 +endi +if $data41 != @1@ then + return -1 +endi +if $data42 != @21-11-11 09:00:04.000@ then + return -1 +endi +if $data43 != @tb1@ then + return -1 +endi +if $data44 != @21-11-11 09:00:04.000@ then + return -1 +endi +if $data45 != @21-11-11 09:00:04.000@ then + return -1 +endi +if $data50 != @567sepa27@ then + return -1 +endi +if $data51 != @1@ then + return -1 +endi +if $data52 != @21-11-11 09:00:05.000@ then + return -1 +endi +if $data53 != @tb1@ then + return -1 +endi +if $data54 != @21-11-11 09:00:05.000@ then + return -1 +endi +if $data55 != @21-11-11 09:00:05.000@ then + return -1 +endi +if $data60 != @678sepa@ then + return -1 +endi +if $data61 != @1@ then + return -1 +endi +if $data62 != @21-11-11 09:00:06.000@ then + return -1 +endi +if $data63 != @tb1@ then + return -1 +endi +if $data64 != @21-11-11 09:00:06.000@ then + return -1 +endi +if $data65 != @21-11-11 09:00:06.000@ then + return -1 +endi +print execute sql select concat_ws('sepa',c8,c14),floor(c7) from tb1; +sql select concat_ws('sepa',c8,c14),floor(c7) from tb1; +if $data00 != @123sepa1@ then + return -1 +endi +if $data01 != @1.000000000@ then + return -1 +endi +if $data10 != $emptyString then + return -1 +endi +if $data11 != @NULL@ then + return -1 +endi +if $data20 != @234sepa2@ then + return -1 +endi +if $data21 != @NULL@ then + return -1 +endi +if $data30 != $emptyString then + return -1 +endi +if $data31 != @3.000000000@ then + return -1 +endi +if $data40 != @456sepa4@ then + return -1 +endi +if $data41 != @4.000000000@ then + return -1 +endi +if $data50 != @567sepa27@ then + return -1 +endi +if $data51 != @179769000000000006323030492138942643493033036433685336215410983289126434148906289940615299632196609445533816320312774433484859900046491141051651091672734470972759941382582304802812882753059262973637182942535982636884444611376868582636745405553206881859340916340092953230149901406738427651121855107737424232448.000000000@ then + return -1 +endi +if $data60 != @678sepa@ then + return -1 +endi +if $data61 != @-179769000000000006323030492138942643493033036433685336215410983289126434148906289940615299632196609445533816320312774433484859900046491141051651091672734470972759941382582304802812882753059262973637182942535982636884444611376868582636745405553206881859340916340092953230149901406738427651121855107737424232448.000000000@ then + return -1 +endi +print execute sql select concat_ws('sepa',c8,c14),concat(c8,concat(c8,c14)) from tb1; +sql select concat_ws('sepa',c8,c14),concat(c8,concat(c8,c14)) from tb1; +if $data00 != @123sepa1@ then + return -1 +endi +if $data01 != @1231231@ then + return -1 +endi +if $data10 != $emptyString then + return -1 +endi +if $data11 != @NULL@ then + return -1 +endi +if $data20 != @234sepa2@ then + return -1 +endi +if $data21 != @2342342@ then + return -1 +endi +if $data30 != $emptyString then + return -1 +endi +if $data31 != @NULL@ then + return -1 +endi +if $data40 != @456sepa4@ then + return -1 +endi +if $data41 != @4564564@ then + return -1 +endi +if $data50 != @567sepa27@ then + return -1 +endi +if $data51 != @56756727@ then + return -1 +endi +if $data60 != @678sepa@ then + return -1 +endi +if $data61 != @678678@ then + return -1 +endi +print execute sql select concat_ws('sepa',c8,concat(c8,c14)) from tb1 where c8 is not null and c9 is not null; +sql select concat_ws('sepa',c8,concat(c8,c14)) from tb1 where c8 is not null and c9 is not null; +if $data00 != @123sepa1231@ then + return -1 +endi +if $data10 != @456sepa4564@ then + return -1 +endi +if $data20 != @567sepa56727@ then + return -1 +endi +if $data30 != @678sepa678@ then + return -1 +endi +print execute sql select concat_ws('sepa',c8,c8) from tb1 order by ts desc; +sql select concat_ws('sepa',c8,c8) from tb1 order by ts desc; +if $data00 != @678sepa678@ then + return -1 +endi +if $data10 != @567sepa567@ then + return -1 +endi +if $data20 != @456sepa456@ then + return -1 +endi +if $data30 != $emptyString then + return -1 +endi +if $data40 != @234sepa234@ then + return -1 +endi +if $data50 != $emptyString then + return -1 +endi +if $data60 != @123sepa123@ then + return -1 +endi +print execute sql select concat_ws('sepa',c8,concat(c8,c14)) from tb1 order by ts desc; +sql select concat_ws('sepa',c8,concat(c8,c14)) from tb1 order by ts desc; +if $data00 != @678sepa678@ then + return -1 +endi +if $data10 != @567sepa56727@ then + return -1 +endi +if $data20 != @456sepa4564@ then + return -1 +endi +if $data30 != $emptyString then + return -1 +endi +if $data40 != @234sepa2342@ then + return -1 +endi +if $data50 != $emptyString then + return -1 +endi +if $data60 != @123sepa1231@ then + return -1 +endi +print execute sql select concat_ws('sepa',c8,concat(c8,c14)) from tb1 order by ts desc limit 3 offset 2; +sql select concat_ws('sepa',c8,concat(c8,c14)) from tb1 order by ts desc limit 3 offset 2; +if $data00 != @456sepa4564@ then + return -1 +endi +if $data10 != $emptyString then + return -1 +endi +if $data20 != @234sepa2342@ then + return -1 +endi +print execute sql select concat_ws('sepa',c8,c8) from stb1; +sql select concat_ws('sepa',c8,c8) from stb1; +if $data00 != @123sepa123@ then + return -1 +endi +if $data10 != $emptyString then + return -1 +endi +if $data20 != @234sepa234@ then + return -1 +endi +if $data30 != $emptyString then + return -1 +endi +if $data40 != @456sepa456@ then + return -1 +endi +if $data50 != @567sepa567@ then + return -1 +endi +if $data60 != @678sepa678@ then + return -1 +endi +if $data70 != @111sepa111@ then + return -1 +endi +if $data80 != @222sepa222@ then + return -1 +endi +if $data90 != @333sepa333@ then + return -1 +endi +print execute sql select concat_ws('sepa',c8,c8) from stb1 order by ts desc; +sql select concat_ws('sepa',c8,c8) from stb1 order by ts desc; +if $data00 != @777sepa777@ then + if $data00 != @678sepa678@ then + return -1 + endi +endi +if $data20 != @666sepa666@ then + if $data20 != @567sepa567@ then + return -1 + endi +endi +if $data40 != @555sepa555@ then + if $data40 != @456sepa456@ then + return -1 + endi +endi +if $data60 != @444sepa444@ then + if $data60 != $emptyString then + return -1 + endi +endi +if $data80 != @333sepa333@ then + if $data80 != @234sepa234@ then + return -1 + endi +endi +print execute sql select concat_ws('sepa',c8,c14),t1 from stb1 order by ts desc; +sql select concat_ws('sepa',c8,c14),t1 from stb1 order by ts desc; +if $data00 != @777sepa7@ then + if $data00 != @678sepa@ then + return -1 + endi +endi +if $data01 != @2@ then + if $data01 != @1@ then + return -1 + endi +endi +if $data20 != @666sepa6@ then + if $data20 != @567sepa27@ then + return -1 + endi +endi +if $data21 != @2@ then + if $data21 != @1@ then + return -1 + endi +endi +if $data40 != @555sepa5@ then + if $data40 != @456sepa4@ then + return -1 + endi +endi +if $data41 != @2@ then + if $data41 != @1@ then + return -1 + endi +endi +if $data60 != @444sepa4@ then + if $data60 != $emptyString then + return -1 + endi +endi +if $data61 != @2@ then + if $data61 != @1@ then + return -1 + endi +endi +if $data80 != @333sepa3@ then + if $data80 != @234sepa2@ then + return -1 + endi +endi +if $data81 != @2@ then + if $data81 != @1@ then + return -1 + endi +endi +print execute sql select concat_ws('sepa',c8,c14),tbname from stb1; +sql select concat_ws('sepa',c8,c14),tbname from stb1; +if $data00 != @123sepa1@ then + return -1 +endi +if $data01 != @tb1@ then + return -1 +endi +if $data10 != $emptyString then + return -1 +endi +if $data11 != @tb1@ then + return -1 +endi +if $data20 != @234sepa2@ then + return -1 +endi +if $data21 != @tb1@ then + return -1 +endi +if $data30 != $emptyString then + return -1 +endi +if $data31 != @tb1@ then + return -1 +endi +if $data40 != @456sepa4@ then + return -1 +endi +if $data41 != @tb1@ then + return -1 +endi +if $data50 != @567sepa27@ then + return -1 +endi +if $data51 != @tb1@ then + return -1 +endi +if $data60 != @678sepa@ then + return -1 +endi +if $data61 != @tb1@ then + return -1 +endi +if $data70 != @111sepa1@ then + return -1 +endi +if $data71 != @tb2@ then + return -1 +endi +if $data80 != @222sepa2@ then + return -1 +endi +if $data81 != @tb2@ then + return -1 +endi +if $data90 != @333sepa3@ then + return -1 +endi +if $data91 != @tb2@ then + return -1 +endi +print execute sql select concat_ws('sepa',c8,c14),tbname from stb1 where t1 > 1; +sql select concat_ws('sepa',c8,c14),tbname from stb1 where t1 > 1; +if $data00 != @111sepa1@ then + return -1 +endi +if $data01 != @tb2@ then + return -1 +endi +if $data10 != @222sepa2@ then + return -1 +endi +if $data11 != @tb2@ then + return -1 +endi +if $data20 != @333sepa3@ then + return -1 +endi +if $data21 != @tb2@ then + return -1 +endi +if $data30 != @444sepa4@ then + return -1 +endi +if $data31 != @tb2@ then + return -1 +endi +if $data40 != @555sepa5@ then + return -1 +endi +if $data41 != @tb2@ then + return -1 +endi +if $data50 != @666sepa6@ then + return -1 +endi +if $data51 != @tb2@ then + return -1 +endi +if $data60 != @777sepa7@ then + return -1 +endi +if $data61 != @tb2@ then + return -1 +endi +print execute sql select concat_ws('sepa',c8,c8),concat(c8,c14) from tbn; +sql select concat_ws('sepa',c8,c8),concat(c8,c14) from tbn; +if $data00 != @111sepa111@ then + return -1 +endi +if $data01 != @1111@ then + return -1 +endi +if $data10 != @222sepa222@ then + return -1 +endi +if $data11 != @2222@ then + return -1 +endi +if $data20 != @333sepa333@ then + return -1 +endi +if $data21 != @3333@ then + return -1 +endi +if $data30 != @444sepa444@ then + return -1 +endi +if $data31 != @4444@ then + return -1 +endi +if $data40 != @555sepa555@ then + return -1 +endi +if $data41 != @5555@ then + return -1 +endi +if $data50 != @666sepa666@ then + return -1 +endi +if $data51 != @6666@ then + return -1 +endi +if $data60 != @777sepa777@ then + return -1 +endi +if $data61 != @7777@ then + return -1 +endi +print execute sql select concat_ws('sepa',c8,c8),concat(c8,c14) from tbn order by ts desc; +sql select concat_ws('sepa',c8,c8),concat(c8,c14) from tbn order by ts desc; +if $data00 != @777sepa777@ then + return -1 +endi +if $data01 != @7777@ then + return -1 +endi +if $data10 != @666sepa666@ then + return -1 +endi +if $data11 != @6666@ then + return -1 +endi +if $data20 != @555sepa555@ then + return -1 +endi +if $data21 != @5555@ then + return -1 +endi +if $data30 != @444sepa444@ then + return -1 +endi +if $data31 != @4444@ then + return -1 +endi +if $data40 != @333sepa333@ then + return -1 +endi +if $data41 != @3333@ then + return -1 +endi +if $data50 != @222sepa222@ then + return -1 +endi +if $data51 != @2222@ then + return -1 +endi +if $data60 != @111sepa111@ then + return -1 +endi +if $data61 != @1111@ then + return -1 +endi +print execute sql select concat_ws('sepa',c8,concat(c8,c8)) from tbn; +sql select concat_ws('sepa',c8,concat(c8,c8)) from tbn; +if $data00 != @111sepa111111@ then + return -1 +endi +if $data10 != @222sepa222222@ then + return -1 +endi +if $data20 != @333sepa333333@ then + return -1 +endi +if $data30 != @444sepa444444@ then + return -1 +endi +if $data40 != @555sepa555555@ then + return -1 +endi +if $data50 != @666sepa666666@ then + return -1 +endi +if $data60 != @777sepa777777@ then + return -1 +endi +print execute sql select concat_ws('sepa',cast(a as binary(10)),cast(a as binary(10))) from (select avg(c6) as a from stb1 interval(1s)); +sql select concat_ws('sepa',cast(a as binary(10)),cast(a as binary(10))) from (select avg(c6) as a from stb1 interval(1s)); +if $data00 != @1.000000sepa1.000000@ then + return -1 +endi +if $data10 != @2.000000sepa2.000000@ then + return -1 +endi +if $data20 != @2.500000sepa2.500000@ then + return -1 +endi +if $data30 != @4.000000sepa4.000000@ then + return -1 +endi +if $data40 != @4.500000sepa4.500000@ then + return -1 +endi +if $data50 != @1701411733sepa1701411733@ then + return -1 +endi +if $data60 != @-170141173sepa-170141173@ then + return -1 +endi +print execute sql select concat_ws('sepa',c8,c8) from (select * from stb1); +sql select concat_ws('sepa',c8,c8) from (select * from stb1); +if $data00 != @123sepa123@ then + return -1 +endi +if $data10 != $emptyString then + return -1 +endi +if $data20 != @234sepa234@ then + return -1 +endi +if $data30 != $emptyString then + return -1 +endi +if $data40 != @456sepa456@ then + return -1 +endi +if $data50 != @567sepa567@ then + return -1 +endi +if $data60 != @678sepa678@ then + return -1 +endi +if $data70 != @111sepa111@ then + return -1 +endi +if $data80 != @222sepa222@ then + return -1 +endi +if $data90 != @333sepa333@ then + return -1 +endi +print execute sql select concat_ws('sepa',cast(a as binary(4)),cast(a as binary(4))) from (select avg(c6) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)); +sql select concat_ws('sepa',cast(a as binary(4)),cast(a as binary(4))) from (select avg(c6) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)); +if $data00 != @1.00sepa1.00@ then + return -1 +endi +if $data10 != @2.00sepa2.00@ then + return -1 +endi +if $data20 != @2.50sepa2.50@ then + return -1 +endi +if $data30 != @4.00sepa4.00@ then + return -1 +endi +if $data40 != @4.50sepa4.50@ then + return -1 +endi +if $data50 != @1701sepa1701@ then + return -1 +endi +if $data60 != @-170sepa-170@ then + return -1 +endi +if $data70 != $emptyString then + return -1 +endi +if $data80 != $emptyString then + return -1 +endi +if $data90 != $emptyString then + return -1 +endi +print execute sql select concat_ws('sepa',cast(a as binary(4)),cast(a as binary(4))) from (select avg(c6) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)) order by ts; +sql select concat_ws('sepa',cast(a as binary(4)),cast(a as binary(4))) from (select avg(c6) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)) order by ts; +if $data00 != @1.00sepa1.00@ then + return -1 +endi +if $data10 != @2.00sepa2.00@ then + return -1 +endi +if $data20 != @2.50sepa2.50@ then + return -1 +endi +if $data30 != @4.00sepa4.00@ then + return -1 +endi +if $data40 != @4.50sepa4.50@ then + return -1 +endi +if $data50 != @1701sepa1701@ then + return -1 +endi +if $data60 != @-170sepa-170@ then + return -1 +endi +if $data70 != $emptyString then + return -1 +endi +if $data80 != $emptyString then + return -1 +endi +if $data90 != $emptyString then + return -1 +endi +print execute sql select concat_ws('sepa',cast(a as binary(4)),cast(a as binary(4))) from (select avg(c6) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)) order by ts desc; +sql select concat_ws('sepa',cast(a as binary(4)),cast(a as binary(4))) from (select avg(c6) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)) order by ts desc; +if $data00 != $emptyString then + return -1 +endi +if $data10 != $emptyString then + return -1 +endi +if $data20 != $emptyString then + return -1 +endi +if $data30 != @-170sepa-170@ then + return -1 +endi +if $data40 != @1701sepa1701@ then + return -1 +endi +if $data50 != @4.50sepa4.50@ then + return -1 +endi +if $data60 != @4.00sepa4.00@ then + return -1 +endi +if $data70 != @2.50sepa2.50@ then + return -1 +endi +if $data80 != @2.00sepa2.00@ then + return -1 +endi +if $data90 != @1.00sepa1.00@ then + return -1 +endi +print execute sql select concat_ws('sepa',cast(a as binary(4)),cast(a as binary(4))) from (select avg(c6) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)) order by a desc; +sql select concat_ws('sepa',cast(a as binary(4)),cast(a as binary(4))) from (select avg(c6) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)) order by a desc; +if $data00 != $emptyString then + return -1 +endi +if $data10 != $emptyString then + return -1 +endi +if $data20 != $emptyString then + return -1 +endi +if $data30 != @1701sepa1701@ then + return -1 +endi +if $data40 != @4.50sepa4.50@ then + return -1 +endi +if $data50 != @4.00sepa4.00@ then + return -1 +endi +if $data60 != @2.50sepa2.50@ then + return -1 +endi +if $data70 != @2.00sepa2.00@ then + return -1 +endi +if $data80 != @1.00sepa1.00@ then + return -1 +endi +if $data90 != @-170sepa-170@ then + return -1 +endi +print execute sql select concat_ws('sepa',cast(a as binary(4)),cast(a as binary(4))) from (select avg(c6) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)) order by a; +sql select concat_ws('sepa',cast(a as binary(4)),cast(a as binary(4))) from (select avg(c6) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)) order by a; +if $data00 != @-170sepa-170@ then + return -1 +endi +if $data10 != @1.00sepa1.00@ then + return -1 +endi +if $data20 != @2.00sepa2.00@ then + return -1 +endi +if $data30 != @2.50sepa2.50@ then + return -1 +endi +if $data40 != @4.00sepa4.00@ then + return -1 +endi +if $data50 != @4.50sepa4.50@ then + return -1 +endi +if $data60 != @1701sepa1701@ then + return -1 +endi +if $data70 != $emptyString then + return -1 +endi +if $data80 != $emptyString then + return -1 +endi +if $data90 != $emptyString then + return -1 +endi +print execute sql select concat_ws('sepa',cast(a as binary(4)),cast(a as binary(4))) from (select concat_ws('sepa',c8,c8) as a from tb1); +sql select concat_ws('sepa',cast(a as binary(4)),cast(a as binary(4))) from (select concat_ws('sepa',c8,c8) as a from tb1); +if $data00 != @123ssepa123s@ then + return -1 +endi +if $data10 != @sepa@ then + return -1 +endi +if $data20 != @234ssepa234s@ then + return -1 +endi +if $data30 != @sepa@ then + return -1 +endi +if $data40 != @456ssepa456s@ then + return -1 +endi +if $data50 != @567ssepa567s@ then + return -1 +endi +if $data60 != @678ssepa678s@ then + return -1 +endi +print execute sql select concat_ws('sepa',tb1.c8,tb1.c14),concat(tb2.c8,tb2.c14) from tb1,tb2 where tb1.ts=tb2.ts; +sql select concat_ws('sepa',tb1.c8,tb1.c14),concat(tb2.c8,tb2.c14) from tb1,tb2 where tb1.ts=tb2.ts; +if $data00 != @123sepa1@ then + return -1 +endi +if $data01 != @1111@ then + return -1 +endi +if $data10 != $emptyString then + return -1 +endi +if $data11 != @2222@ then + return -1 +endi +if $data20 != @234sepa2@ then + return -1 +endi +if $data21 != @3333@ then + return -1 +endi +if $data30 != $emptyString then + return -1 +endi +if $data31 != @4444@ then + return -1 +endi +if $data40 != @456sepa4@ then + return -1 +endi +if $data41 != @5555@ then + return -1 +endi +if $data50 != @567sepa27@ then + return -1 +endi +if $data51 != @6666@ then + return -1 +endi +if $data60 != @678sepa@ then + return -1 +endi +if $data61 != @7777@ then + return -1 +endi +print execute sql select concat_ws('sepa',c8,c14) from tb1 union all select concat_ws('sepa',c8,c14) from tb2; +sql select concat_ws('sepa',c8,c14) from tb1 union all select concat_ws('sepa',c8,c14) from tb2; +if $data00 != @123sepa1@ then + return -1 +endi +if $data10 != $emptyString then + return -1 +endi +if $data20 != @234sepa2@ then + return -1 +endi +if $data30 != $emptyString then + return -1 +endi +if $data40 != @456sepa4@ then + return -1 +endi +if $data50 != @567sepa27@ then + return -1 +endi +if $data60 != @678sepa@ then + return -1 +endi +if $data70 != @111sepa1@ then + return -1 +endi +if $data80 != @222sepa2@ then + return -1 +endi +if $data90 != @333sepa3@ then + return -1 +endi +print execute sql select concat_ws('sepa',c8, cast(a as binary(10))),c8, a from (select c8,c2 as a from stb1) +sql select concat_ws('sepa',c8, cast(a as binary(10))),c8, a from (select c8,c2 as a from stb1) +if $data00 != @123sepa1@ then + return -1 +endi +if $data01 != @123@ then + return -1 +endi +if $data02 != @1@ then + return -1 +endi +if $data10 != $emptyString then + return -1 +endi +if $data11 != @NULL@ then + return -1 +endi +if $data12 != @NULL@ then + return -1 +endi +if $data20 != @234sepa2@ then + return -1 +endi +if $data21 != @234@ then + return -1 +endi +if $data22 != @2@ then + return -1 +endi +if $data30 != $emptyString then + return -1 +endi +if $data31 != @NULL@ then + return -1 +endi +if $data32 != @NULL@ then + return -1 +endi +if $data40 != @456sepa4@ then + return -1 +endi +if $data41 != @456@ then + return -1 +endi +if $data42 != @4@ then + return -1 +endi +if $data50 != @567sepa127@ then + return -1 +endi +if $data51 != @567@ then + return -1 +endi +if $data52 != @127@ then + return -1 +endi +if $data60 != @678sepa-127@ then + return -1 +endi +if $data61 != @678@ then + return -1 +endi +if $data62 != @-127@ then + return -1 +endi +if $data70 != @111sepa1@ then + return -1 +endi +if $data71 != @111@ then + return -1 +endi +if $data72 != @1@ then + return -1 +endi +if $data80 != @222sepa2@ then + return -1 +endi +if $data81 != @222@ then + return -1 +endi +if $data82 != @2@ then + return -1 +endi +if $data90 != @333sepa3@ then + return -1 +endi +if $data91 != @333@ then + return -1 +endi +if $data92 != @3@ then + return -1 +endi +print execute sql select concat_ws('sepa',c9,concat(c9,c15)) from tb1; +sql select concat_ws('sepa',c9,concat(c9,c15)) from tb1; +if $data00 != @1234sepa12341@ then + return -1 +endi +if $data10 != $emptyString then + return -1 +endi +if $data20 != $emptyString then + return -1 +endi +if $data30 != @3456sepa34563@ then + return -1 +endi +if $data40 != @4567sepa45674@ then + return -1 +endi +if $data50 != @5678sepa5678278@ then + return -1 +endi +if $data60 != @6789sepa6789@ then + return -1 +endi +print execute sql select concat_ws('sepa',c9,concat(c15,c9)) from tb1; +sql select concat_ws('sepa',c9,concat(c15,c9)) from tb1; +if $data00 != @1234sepa11234@ then + return -1 +endi +if $data10 != $emptyString then + return -1 +endi +if $data20 != $emptyString then + return -1 +endi +if $data30 != @3456sepa33456@ then + return -1 +endi +if $data40 != @4567sepa44567@ then + return -1 +endi +if $data50 != @5678sepa2785678@ then + return -1 +endi +if $data60 != @6789sepa6789@ then + return -1 +endi +print execute sql select concat_ws('sepa',c9,concat(concat(c15,c9), c9, '6')) from tb1; +sql select concat_ws('sepa',c9,concat(concat(c15,c9), c9, '6')) from tb1; +if $data00 != @1234sepa1123412346@ then + return -1 +endi +if $data10 != $emptyString then + return -1 +endi +if $data20 != $emptyString then + return -1 +endi +if $data30 != @3456sepa3345634566@ then + return -1 +endi +if $data40 != @4567sepa4456745676@ then + return -1 +endi +if $data50 != @5678sepa278567856786@ then + return -1 +endi +if $data60 != @6789sepa678967896@ then + return -1 +endi diff --git a/tests/script/general/compute/str_concat_ws2.sim b/tests/script/general/compute/str_concat_ws2.sim new file mode 100644 index 0000000000000000000000000000000000000000..72cfa4fda8bd108778c4771182490d790b061921 --- /dev/null +++ b/tests/script/general/compute/str_concat_ws2.sim @@ -0,0 +1,211 @@ +sleep 100 +sql connect +sql use db + +$emptyString = @@ +print execute sql select concat_ws('sepa',stb1.c8,stb1.c14),pow(stba.c2,stba.c5) from stb1,stba where stb1.t1=stba.t1 and stb1.ts=stba.ts; +sql select concat_ws('sepa',stb1.c8,stb1.c14),pow(stba.c2,stba.c5) from stb1,stba where stb1.t1=stba.t1 and stb1.ts=stba.ts; +if $data00 != @123sepa1@ then + return -1 +endi +if $data01 != @1.000000000@ then + return -1 +endi +if $data10 != $emptyString then + return -1 +endi +if $data11 != @4.000000000@ then + return -1 +endi +if $data20 != @234sepa2@ then + return -1 +endi +if $data21 != @27.000000000@ then + return -1 +endi +if $data30 != $emptyString then + return -1 +endi +if $data31 != @256.000000000@ then + return -1 +endi +if $data40 != @456sepa4@ then + return -1 +endi +if $data41 != @3125.000000000@ then + return -1 +endi +if $data50 != @567sepa27@ then + return -1 +endi +if $data51 != @46656.000000000@ then + return -1 +endi +if $data60 != @678sepa@ then + return -1 +endi +if $data61 != @823543.000000000@ then + return -1 +endi +print execute sql select concat_ws('sepa', c8,c14) as a from stb1 union all select concat(c8,c14) as a from stba; +sql select concat_ws('sepa', c8,c14) as a from stb1 union all select concat(c8,c14) as a from stba; +if $data00 != @123sepa1@ then + return -1 +endi +if $data10 != $emptyString then + return -1 +endi +if $data20 != @234sepa2@ then + return -1 +endi +if $data30 != $emptyString then + return -1 +endi +if $data40 != @456sepa4@ then + return -1 +endi +if $data50 != @567sepa27@ then + return -1 +endi +if $data60 != @678sepa@ then + return -1 +endi +if $data70 != @111sepa1@ then + return -1 +endi +if $data80 != @222sepa2@ then + return -1 +endi +if $data90 != @333sepa3@ then + return -1 +endi +print execute sql select concat_ws('sepa', c8,c14) from stba; +sql select concat_ws('sepa', c8,c14) from stba; +if $data00 != @111sepa1@ then + return -1 +endi +if $data10 != @222sepa2@ then + return -1 +endi +if $data20 != @333sepa3@ then + return -1 +endi +if $data30 != @444sepa4@ then + return -1 +endi +if $data40 != @555sepa5@ then + return -1 +endi +if $data50 != @666sepa6@ then + return -1 +endi +if $data60 != @777sepa7@ then + return -1 +endi +if $data70 != @888sepa8@ then + return -1 +endi +if $data80 != @999sepa9@ then + return -1 +endi +if $data90 != @000sepa0@ then + return -1 +endi +print execute sql select concat_ws('sepa','c8',cast(min(c2) as binary(10))) from tba1; +sql select concat_ws('sepa','c8',cast(min(c2) as binary(10))) from tba1; +if $data00 != @c8sepa0@ then + return -1 +endi +print execute sql select concat_ws('sepa','c8',cast(max(c2) as binary(10))) from tba1; +sql select concat_ws('sepa','c8',cast(max(c2) as binary(10))) from tba1; +if $data00 != @c8sepa9@ then + return -1 +endi +print execute sql select concat_ws('sepa','c8',cast(count(c2) as binary(10))) from tba1; +sql select concat_ws('sepa','c8',cast(count(c2) as binary(10))) from tba1; +if $data00 != @c8sepa30@ then + return -1 +endi +print execute sql select concat_ws('sepa','c8',cast(sum(c2) as binary(10))) from tba1; +sql select concat_ws('sepa','c8',cast(sum(c2) as binary(10))) from tba1; +if $data00 != @c8sepa135@ then + return -1 +endi +print execute sql select concat_ws('sepa','c8',cast(avg(c2) as binary(10))) from tba1; +sql select concat_ws('sepa','c8',cast(avg(c2) as binary(10))) from tba1; +if $data00 != @c8sepa4.500000@ then + return -1 +endi +print execute sql select concat_ws('sepa','c8',cast(percentile(c2, 10) as binary(10))) from tba1; +sql select concat_ws('sepa','c8',cast(percentile(c2, 10) as binary(10))) from tba1; +if $data00 != @c8sepa0.900000@ then + return -1 +endi +print execute sql select concat_ws('sepa','c8',cast(apercentile(c2, 10) as binary(10))) from tba1; +sql select concat_ws('sepa','c8',cast(apercentile(c2, 10) as binary(10))) from tba1; +if $data00 != @c8sepa0.000000@ then + return -1 +endi +print execute sql select concat_ws('sepa','c8',cast(stddev(c2) as binary(10))) from tba1; +sql select concat_ws('sepa','c8',cast(stddev(c2) as binary(10))) from tba1; +if $data00 != @c8sepa2.872281@ then + return -1 +endi +print execute sql select concat_ws('sepa','c8',cast(spread(c2) as binary(10))) from tba1; +sql select concat_ws('sepa','c8',cast(spread(c2) as binary(10))) from tba1; +if $data00 != @c8sepa9.000000@ then + return -1 +endi +print execute sql select concat_ws('sepa','c8',cast(twa(c2) as binary(10))) from tba1; +sql select concat_ws('sepa','c8',cast(twa(c2) as binary(10))) from tba1; +if $data00 != @c8sepa4.637931@ then + return -1 +endi +print execute sql select concat_ws('sepa','c8',cast(elapsed(ts) as binary(10))) from tba1; +sql select concat_ws('sepa','c8',cast(elapsed(ts) as binary(10))) from tba1; +if $data00 != @c8sepa29000.0000@ then + return -1 +endi +print execute sql select concat_ws('sepa','c8',cast(rate(c2) as binary(10))) from tba1; +sql select concat_ws('sepa','c8',cast(rate(c2) as binary(10))) from tba1; +if $data00 != @c8sepa0.896552@ then + return -1 +endi +print execute sql select concat_ws('sepa','c8',cast(irate(c2) as binary(10))) from tba1; +sql select concat_ws('sepa','c8',cast(irate(c2) as binary(10))) from tba1; +if $data00 != @c8sepa0.000000@ then + return -1 +endi +print execute sql select concat_ws('sepa','c8',cast(first(c2) as binary(10))) from tba1; +sql select concat_ws('sepa','c8',cast(first(c2) as binary(10))) from tba1; +if $data00 != @c8sepa1@ then + return -1 +endi +print execute sql select concat_ws('sepa','c8',cast(last(c2) as binary(10))) from tba1; +sql select concat_ws('sepa','c8',cast(last(c2) as binary(10))) from tba1; +if $data00 != @c8sepa0@ then + return -1 +endi +print execute sql select concat_ws('sepa','c8',cast(last_row(c2) as binary(10))) from tba1; +sql select concat_ws('sepa','c8',cast(last_row(c2) as binary(10))) from tba1; +if $data00 != @c8sepa0@ then + return -1 +endi +print execute sql select concat_ws('sepa','c8',cast(top(c2, 1) as binary(10))) from tba1; +sql_error select concat_ws('sepa','c8',cast(top(c2, 1) as binary(10))) from tba1; +print execute sql select concat_ws('sepa','c8',cast(bottom(c2, 1) as binary(10))) from tba1; +sql_error select concat_ws('sepa','c8',cast(bottom(c2, 1) as binary(10))) from tba1; +print execute sql select concat_ws('sepa','c8',cast(leastsquares(c2, 1, 1) as binary(10))) from tba1; +sql_error select concat_ws('sepa','c8',cast(leastsquares(c2, 1, 1) as binary(10))) from tba1; +print execute sql select concat_ws('sepa','c8',cast(derivative(c2, 1s, 0) as binary(10))) from tba1; +sql_error select concat_ws('sepa','c8',cast(derivative(c2, 1s, 0) as binary(10))) from tba1; +print execute sql select concat_ws('sepa','c8',cast(diff(c2) as binary(10))) from tba1; +sql_error select concat_ws('sepa','c8',cast(diff(c2) as binary(10))) from tba1; +print execute sql select concat_ws('sepa','c8',cast(csum(c2) as binary(10))) from tba1; +sql_error select concat_ws('sepa','c8',cast(csum(c2) as binary(10))) from tba1; +print execute sql select concat_ws('sepa','c8',cast(mavg(c2,2) as binary(10))) from tba1; +sql_error select concat_ws('sepa','c8',cast(mavg(c2,2) as binary(10))) from tba1; +print execute sql select concat_ws('sepa','c8',cast(sample(c2,2) as binary(10))) from tba1; +sql_error select concat_ws('sepa','c8',cast(sample(c2,2) as binary(10))) from tba1; +print execute sql select concat_ws('sepa','c8',cast(_block_dist() as binary(10))) from tba1; +sql_error select concat_ws('sepa','c8',cast(_block_dist() as binary(10))) from tba1; diff --git a/tests/script/general/compute/str_length.sim b/tests/script/general/compute/str_length.sim new file mode 100644 index 0000000000000000000000000000000000000000..f53fd2bb61ee9f68dcebb9e1a7462c4e05ab4a22 --- /dev/null +++ b/tests/script/general/compute/str_length.sim @@ -0,0 +1,1315 @@ +sleep 100 +sql connect +sql use db + +$emptyString = @@ +print execute sql select length(*) from tb1; +sql_error select length(*) from tb1; +print execute sql select length(*) + 1 as a from tb1; +sql_error select length(*) + 1 as a from tb1; +print execute sql select length(tb1.*) + 1 as a from tb1; +sql_error select length(tb1.*) + 1 as a from tb1; +print execute sql select length(*) from tb1; +sql_error select length(*) from tb1; +print execute sql select length(c1) from tb1; +sql_error select length(c1) from tb1; +print execute sql select length(13) from tb1; +sql_error select length(13) from tb1; +print execute sql select length(c1) from tb1; +sql_error select length(c1) from tb1; +print execute sql select length(c2) from tb1; +sql_error select length(c2) from tb1; +print execute sql select length(c3) from tb1; +sql_error select length(c3) from tb1; +print execute sql select length(c4) from tb1; +sql_error select length(c4) from tb1; +print execute sql select length(c5) from tb1; +sql_error select length(c5) from tb1; +print execute sql select length(c6) from tb1; +sql_error select length(c6) from tb1; +print execute sql select length(c7) from tb1; +sql_error select length(c7) from tb1; +print execute sql select length(c8) from tb1; +sql select length(c8) from tb1; +if $data00 != @3@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data20 != @3@ then + return -1 +endi +if $data30 != @NULL@ then + return -1 +endi +if $data40 != @3@ then + return -1 +endi +if $data50 != @3@ then + return -1 +endi +if $data60 != @3@ then + return -1 +endi +print execute sql select length(c14) from tb1; +sql select length(c14) from tb1; +if $data00 != @1@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data20 != @1@ then + return -1 +endi +if $data30 != @NULL@ then + return -1 +endi +if $data40 != @1@ then + return -1 +endi +if $data50 != @2@ then + return -1 +endi +if $data60 != @0@ then + return -1 +endi +print execute sql select length(c10) from tb1; +sql_error select length(c10) from tb1; +print execute sql select length(c11) from tb1; +sql_error select length(c11) from tb1; +print execute sql select length(c12) from tb1; +sql_error select length(c12) from tb1; +print execute sql select length(c13) from tb1; +sql_error select length(c13) from tb1; +print execute sql select length('12345678900000000000000000') from tb1; +sql select length('12345678900000000000000000') from tb1; +if $data00 != @26@ then + return -1 +endi +if $data10 != @26@ then + return -1 +endi +if $data20 != @26@ then + return -1 +endi +if $data30 != @26@ then + return -1 +endi +if $data40 != @26@ then + return -1 +endi +if $data50 != @26@ then + return -1 +endi +if $data60 != @26@ then + return -1 +endi +print execute sql select distinct length(123) from tb1; +sql_error select distinct length(123) from tb1; +print execute sql select length(t1) from stb1; +sql_error select length(t1) from stb1; +print execute sql select length(c8),avg(c3) from tb1; +sql_error select length(c8),avg(c3) from tb1; +print execute sql select length(c8),top(c3,1) from tb1; +sql_error select length(c8),top(c3,1) from tb1; +print execute sql select length(concat(c8,c14)) from tb1 session(ts, 1s); +sql_error select length(concat(c8,c14)) from tb1 session(ts, 1s); +print execute sql select length(concat(c8,c14)) from tb1 STATE_WINDOW(c1); +sql_error select length(concat(c8,c14)) from tb1 STATE_WINDOW(c1); +print execute sql select length(concat(c8,c14)) from tb1 interval(1s) sliding(1s) fill(NULL); +sql_error select length(concat(c8,c14)) from tb1 interval(1s) sliding(1s) fill(NULL); +print execute sql select length(concat(c8,c14)) from stb1 group by t1; +sql_error select length(concat(c8,c14)) from stb1 group by t1; +print execute sql select length(concat(c8,c14)) from stb1 group by ts; +sql_error select length(concat(c8,c14)) from stb1 group by ts; +print execute sql select length(concat(c8,c14)) from stb1 group by c1; +sql_error select length(concat(c8,c14)) from stb1 group by c1; +print execute sql select length(concat(c8,c14)) from stb1 group by tbname; +sql_error select length(concat(c8,c14)) from stb1 group by tbname; +print execute sql select length(concat(c8,c14)) from tb1 order by c2; +sql_error select length(concat(c8,c14)) from tb1 order by c2; +print execute sql select length(c8),length(c14) from tbn; +sql select length(c8),length(c14) from tbn; +if $data00 != @3@ then + return -1 +endi +if $data01 != @1@ then + return -1 +endi +if $data10 != @3@ then + return -1 +endi +if $data11 != @1@ then + return -1 +endi +if $data20 != @3@ then + return -1 +endi +if $data21 != @1@ then + return -1 +endi +if $data30 != @3@ then + return -1 +endi +if $data31 != @1@ then + return -1 +endi +if $data40 != @3@ then + return -1 +endi +if $data41 != @1@ then + return -1 +endi +if $data50 != @3@ then + return -1 +endi +if $data51 != @1@ then + return -1 +endi +if $data60 != @3@ then + return -1 +endi +if $data61 != @1@ then + return -1 +endi +print execute sql select length(ts) from (select avg(c2) as a from stb1 interval(1s)); +sql_error select length(ts) from (select avg(c2) as a from stb1 interval(1s)); +print execute sql select length(cast(a as binary(10))) from (select abs(c2) as a from tb1); +sql select length(cast(a as binary(10))) from (select abs(c2) as a from tb1); +if $data00 != @1@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data20 != @1@ then + return -1 +endi +if $data30 != @NULL@ then + return -1 +endi +if $data40 != @1@ then + return -1 +endi +if $data50 != @3@ then + return -1 +endi +if $data60 != @3@ then + return -1 +endi +print execute sql select length("abc") from tb1; +sql select length("abc") from tb1; +if $data00 != @3@ then + return -1 +endi +if $data10 != @3@ then + return -1 +endi +if $data20 != @3@ then + return -1 +endi +if $data30 != @3@ then + return -1 +endi +if $data40 != @3@ then + return -1 +endi +if $data50 != @3@ then + return -1 +endi +if $data60 != @3@ then + return -1 +endi +print execute sql select length(concat(c8,c14)) from tb1; +sql select length(concat(c8,c14)) from tb1; +if $data00 != @4@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data20 != @4@ then + return -1 +endi +if $data30 != @NULL@ then + return -1 +endi +if $data40 != @4@ then + return -1 +endi +if $data50 != @5@ then + return -1 +endi +if $data60 != @3@ then + return -1 +endi +print execute sql select length((concat(c8,c14))) from tb1; +sql select length((concat(c8,c14))) from tb1; +if $data00 != @4@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data20 != @4@ then + return -1 +endi +if $data30 != @NULL@ then + return -1 +endi +if $data40 != @4@ then + return -1 +endi +if $data50 != @5@ then + return -1 +endi +if $data60 != @3@ then + return -1 +endi +print execute sql select length('11')+c2 from tb1; +sql select length('11')+c2 from tb1; +if $data00 != @3.000000000@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data20 != @4.000000000@ then + return -1 +endi +if $data30 != @NULL@ then + return -1 +endi +if $data40 != @6.000000000@ then + return -1 +endi +if $data50 != @129.000000000@ then + return -1 +endi +if $data60 != @-125.000000000@ then + return -1 +endi +print execute sql select length(c8)+c2 from tb1; +sql select length(c8)+c2 from tb1; +if $data00 != @4.000000000@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data20 != @5.000000000@ then + return -1 +endi +if $data30 != @NULL@ then + return -1 +endi +if $data40 != @7.000000000@ then + return -1 +endi +if $data50 != @130.000000000@ then + return -1 +endi +if $data60 != @-124.000000000@ then + return -1 +endi +print execute sql select length(c14)+11 from tb1; +sql select length(c14)+11 from tb1; +if $data00 != @12.000000000@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data20 != @12.000000000@ then + return -1 +endi +if $data30 != @NULL@ then + return -1 +endi +if $data40 != @12.000000000@ then + return -1 +endi +if $data50 != @13.000000000@ then + return -1 +endi +if $data60 != @11.000000000@ then + return -1 +endi +print execute sql select length(c8),c8,c2 from tb1; +sql select length(c8),c8,c2 from tb1; +if $data00 != @3@ then + return -1 +endi +if $data01 != @123@ then + return -1 +endi +if $data02 != @1@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data11 != @NULL@ then + return -1 +endi +if $data12 != @NULL@ then + return -1 +endi +if $data20 != @3@ then + return -1 +endi +if $data21 != @234@ then + return -1 +endi +if $data22 != @2@ then + return -1 +endi +if $data30 != @NULL@ then + return -1 +endi +if $data31 != @NULL@ then + return -1 +endi +if $data32 != @NULL@ then + return -1 +endi +if $data40 != @3@ then + return -1 +endi +if $data41 != @456@ then + return -1 +endi +if $data42 != @4@ then + return -1 +endi +if $data50 != @3@ then + return -1 +endi +if $data51 != @567@ then + return -1 +endi +if $data52 != @127@ then + return -1 +endi +if $data60 != @3@ then + return -1 +endi +if $data61 != @678@ then + return -1 +endi +if $data62 != @-127@ then + return -1 +endi +print execute sql select length(c8),t1,ts,tbname,_C0,_c0 from tb1; +sql select length(c8),t1,ts,tbname,_C0,_c0 from tb1; +if $data00 != @3@ then + return -1 +endi +if $data01 != @1@ then + return -1 +endi +if $data02 != @21-11-11 09:00:00.000@ then + return -1 +endi +if $data03 != @tb1@ then + return -1 +endi +if $data04 != @21-11-11 09:00:00.000@ then + return -1 +endi +if $data05 != @21-11-11 09:00:00.000@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data11 != @1@ then + return -1 +endi +if $data12 != @21-11-11 09:00:01.000@ then + return -1 +endi +if $data13 != @tb1@ then + return -1 +endi +if $data14 != @21-11-11 09:00:01.000@ then + return -1 +endi +if $data15 != @21-11-11 09:00:01.000@ then + return -1 +endi +if $data20 != @3@ then + return -1 +endi +if $data21 != @1@ then + return -1 +endi +if $data22 != @21-11-11 09:00:02.000@ then + return -1 +endi +if $data23 != @tb1@ then + return -1 +endi +if $data24 != @21-11-11 09:00:02.000@ then + return -1 +endi +if $data25 != @21-11-11 09:00:02.000@ then + return -1 +endi +if $data30 != @NULL@ then + return -1 +endi +if $data31 != @1@ then + return -1 +endi +if $data32 != @21-11-11 09:00:03.000@ then + return -1 +endi +if $data33 != @tb1@ then + return -1 +endi +if $data34 != @21-11-11 09:00:03.000@ then + return -1 +endi +if $data35 != @21-11-11 09:00:03.000@ then + return -1 +endi +if $data40 != @3@ then + return -1 +endi +if $data41 != @1@ then + return -1 +endi +if $data42 != @21-11-11 09:00:04.000@ then + return -1 +endi +if $data43 != @tb1@ then + return -1 +endi +if $data44 != @21-11-11 09:00:04.000@ then + return -1 +endi +if $data45 != @21-11-11 09:00:04.000@ then + return -1 +endi +if $data50 != @3@ then + return -1 +endi +if $data51 != @1@ then + return -1 +endi +if $data52 != @21-11-11 09:00:05.000@ then + return -1 +endi +if $data53 != @tb1@ then + return -1 +endi +if $data54 != @21-11-11 09:00:05.000@ then + return -1 +endi +if $data55 != @21-11-11 09:00:05.000@ then + return -1 +endi +if $data60 != @3@ then + return -1 +endi +if $data61 != @1@ then + return -1 +endi +if $data62 != @21-11-11 09:00:06.000@ then + return -1 +endi +if $data63 != @tb1@ then + return -1 +endi +if $data64 != @21-11-11 09:00:06.000@ then + return -1 +endi +if $data65 != @21-11-11 09:00:06.000@ then + return -1 +endi +print execute sql select length(c8),floor(c3) from tb1; +sql select length(c8),floor(c3) from tb1; +if $data00 != @3@ then + return -1 +endi +if $data01 != @1@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data11 != @NULL@ then + return -1 +endi +if $data20 != @3@ then + return -1 +endi +if $data21 != @NULL@ then + return -1 +endi +if $data30 != @NULL@ then + return -1 +endi +if $data31 != @3@ then + return -1 +endi +if $data40 != @3@ then + return -1 +endi +if $data41 != @4@ then + return -1 +endi +if $data50 != @3@ then + return -1 +endi +if $data51 != @32767@ then + return -1 +endi +if $data60 != @3@ then + return -1 +endi +if $data61 != @-32767@ then + return -1 +endi +print execute sql select length(c8),length(concat(c8,c14)) from tb1; +sql select length(c8),length(concat(c8,c14)) from tb1; +if $data00 != @3@ then + return -1 +endi +if $data01 != @4@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data11 != @NULL@ then + return -1 +endi +if $data20 != @3@ then + return -1 +endi +if $data21 != @4@ then + return -1 +endi +if $data30 != @NULL@ then + return -1 +endi +if $data31 != @NULL@ then + return -1 +endi +if $data40 != @3@ then + return -1 +endi +if $data41 != @4@ then + return -1 +endi +if $data50 != @3@ then + return -1 +endi +if $data51 != @5@ then + return -1 +endi +if $data60 != @3@ then + return -1 +endi +if $data61 != @3@ then + return -1 +endi +print execute sql select length(concat(c8,c14)) from tb1 where c9 is not null and c15 is not null; +sql select length(concat(c8,c14)) from tb1 where c9 is not null and c15 is not null; +if $data00 != @4@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data20 != @4@ then + return -1 +endi +if $data30 != @5@ then + return -1 +endi +if $data40 != @3@ then + return -1 +endi +print execute sql select length(c14) from tb1 order by ts desc; +sql select length(c14) from tb1 order by ts desc; +if $data00 != @0@ then + return -1 +endi +if $data10 != @2@ then + return -1 +endi +if $data20 != @1@ then + return -1 +endi +if $data30 != @NULL@ then + return -1 +endi +if $data40 != @1@ then + return -1 +endi +if $data50 != @NULL@ then + return -1 +endi +if $data60 != @1@ then + return -1 +endi +print execute sql select length(concat(c8,c14)) from tb1 order by ts desc; +sql select length(concat(c8,c14)) from tb1 order by ts desc; +if $data00 != @3@ then + return -1 +endi +if $data10 != @5@ then + return -1 +endi +if $data20 != @4@ then + return -1 +endi +if $data30 != @NULL@ then + return -1 +endi +if $data40 != @4@ then + return -1 +endi +if $data50 != @NULL@ then + return -1 +endi +if $data60 != @4@ then + return -1 +endi +print execute sql select length(concat(c8,c14)) from tb1 order by ts desc limit 3 offset 2; +sql select length(concat(c8,c14)) from tb1 order by ts desc limit 3 offset 2; +if $data00 != @4@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data20 != @4@ then + return -1 +endi +print execute sql select length(c14) from stb1; +sql select length(c14) from stb1; +if $data00 != @1@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data20 != @1@ then + return -1 +endi +if $data30 != @NULL@ then + return -1 +endi +if $data40 != @1@ then + return -1 +endi +if $data50 != @2@ then + return -1 +endi +if $data60 != @0@ then + return -1 +endi +if $data70 != @1@ then + return -1 +endi +if $data80 != @1@ then + return -1 +endi +if $data90 != @1@ then + return -1 +endi +print execute sql select length(c14) from stb1 order by ts desc; +sql select length(c14) from stb1 order by ts desc; +if $data00 != @1@ then + if $data00 != @0@ then + return -1 + endi +endi +if $data20 != @1@ then + if $data20 != @2@ then + return -1 + endi +endi +if $data40 != @1@ then + if $data40 != @1@ then + return -1 + endi +endi +if $data60 != @1@ then + if $data60 != @NULL@ then + return -1 + endi +endi +if $data80 != @1@ then + if $data80 != @1@ then + return -1 + endi +endi +print execute sql select length(c14),t1 from stb1 order by ts desc; +sql select length(c14),t1 from stb1 order by ts desc; +if $data00 != @1@ then + if $data00 != @0@ then + return -1 + endi +endi +if $data01 != @2@ then + if $data01 != @1@ then + return -1 + endi +endi +if $data20 != @1@ then + if $data20 != @2@ then + return -1 + endi +endi +if $data21 != @2@ then + if $data21 != @1@ then + return -1 + endi +endi +if $data40 != @1@ then + if $data40 != @1@ then + return -1 + endi +endi +if $data41 != @2@ then + if $data41 != @1@ then + return -1 + endi +endi +if $data60 != @1@ then + if $data60 != @NULL@ then + return -1 + endi +endi +if $data61 != @2@ then + if $data61 != @1@ then + return -1 + endi +endi +if $data80 != @1@ then + if $data80 != @1@ then + return -1 + endi +endi +if $data81 != @2@ then + if $data81 != @1@ then + return -1 + endi +endi +print execute sql select length(c15),tbname from stb1; +sql select length(c15),tbname from stb1; +if $data00 != @4@ then + return -1 +endi +if $data01 != @tb1@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data11 != @tb1@ then + return -1 +endi +if $data20 != @NULL@ then + return -1 +endi +if $data21 != @tb1@ then + return -1 +endi +if $data30 != @4@ then + return -1 +endi +if $data31 != @tb1@ then + return -1 +endi +if $data40 != @4@ then + return -1 +endi +if $data41 != @tb1@ then + return -1 +endi +if $data50 != @12@ then + return -1 +endi +if $data51 != @tb1@ then + return -1 +endi +if $data60 != @0@ then + return -1 +endi +if $data61 != @tb1@ then + return -1 +endi +if $data70 != @4@ then + return -1 +endi +if $data71 != @tb2@ then + return -1 +endi +if $data80 != @4@ then + return -1 +endi +if $data81 != @tb2@ then + return -1 +endi +if $data90 != @4@ then + return -1 +endi +if $data91 != @tb2@ then + return -1 +endi +print execute sql select length(c15),tbname from stb1 where t1 > 1; +sql select length(c15),tbname from stb1 where t1 > 1; +if $data00 != @4@ then + return -1 +endi +if $data01 != @tb2@ then + return -1 +endi +if $data10 != @4@ then + return -1 +endi +if $data11 != @tb2@ then + return -1 +endi +if $data20 != @4@ then + return -1 +endi +if $data21 != @tb2@ then + return -1 +endi +if $data30 != @4@ then + return -1 +endi +if $data31 != @tb2@ then + return -1 +endi +if $data40 != @4@ then + return -1 +endi +if $data41 != @tb2@ then + return -1 +endi +if $data50 != @4@ then + return -1 +endi +if $data51 != @tb2@ then + return -1 +endi +if $data60 != @4@ then + return -1 +endi +if $data61 != @tb2@ then + return -1 +endi +print execute sql select length(c8),length(c14) from tbn; +sql select length(c8),length(c14) from tbn; +if $data00 != @3@ then + return -1 +endi +if $data01 != @1@ then + return -1 +endi +if $data10 != @3@ then + return -1 +endi +if $data11 != @1@ then + return -1 +endi +if $data20 != @3@ then + return -1 +endi +if $data21 != @1@ then + return -1 +endi +if $data30 != @3@ then + return -1 +endi +if $data31 != @1@ then + return -1 +endi +if $data40 != @3@ then + return -1 +endi +if $data41 != @1@ then + return -1 +endi +if $data50 != @3@ then + return -1 +endi +if $data51 != @1@ then + return -1 +endi +if $data60 != @3@ then + return -1 +endi +if $data61 != @1@ then + return -1 +endi +print execute sql select length(c8),length(c14) from tbn order by ts desc; +sql select length(c8),length(c14) from tbn order by ts desc; +if $data00 != @3@ then + return -1 +endi +if $data01 != @1@ then + return -1 +endi +if $data10 != @3@ then + return -1 +endi +if $data11 != @1@ then + return -1 +endi +if $data20 != @3@ then + return -1 +endi +if $data21 != @1@ then + return -1 +endi +if $data30 != @3@ then + return -1 +endi +if $data31 != @1@ then + return -1 +endi +if $data40 != @3@ then + return -1 +endi +if $data41 != @1@ then + return -1 +endi +if $data50 != @3@ then + return -1 +endi +if $data51 != @1@ then + return -1 +endi +if $data60 != @3@ then + return -1 +endi +if $data61 != @1@ then + return -1 +endi +print execute sql select length(length(c8)) from tbn; +sql_error select length(length(c8)) from tbn; +print execute sql select length(cast(a as binary(10))) from (select avg(c2) as a from stb1 interval(1s)); +sql select length(cast(a as binary(10))) from (select avg(c2) as a from stb1 interval(1s)); +if $data00 != @8@ then + return -1 +endi +if $data10 != @8@ then + return -1 +endi +if $data20 != @8@ then + return -1 +endi +if $data30 != @8@ then + return -1 +endi +if $data40 != @8@ then + return -1 +endi +if $data50 != @9@ then + return -1 +endi +if $data60 != @10@ then + return -1 +endi +print execute sql select length(c14) from (select * from stb1); +sql select length(c14) from (select * from stb1); +if $data00 != @1@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data20 != @1@ then + return -1 +endi +if $data30 != @NULL@ then + return -1 +endi +if $data40 != @1@ then + return -1 +endi +if $data50 != @2@ then + return -1 +endi +if $data60 != @0@ then + return -1 +endi +if $data70 != @1@ then + return -1 +endi +if $data80 != @1@ then + return -1 +endi +if $data90 != @1@ then + return -1 +endi +print execute sql select length(cast(a as binary(10))) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)); +sql select length(cast(a as binary(10))) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)); +if $data00 != @8@ then + return -1 +endi +if $data10 != @8@ then + return -1 +endi +if $data20 != @8@ then + return -1 +endi +if $data30 != @8@ then + return -1 +endi +if $data40 != @8@ then + return -1 +endi +if $data50 != @9@ then + return -1 +endi +if $data60 != @10@ then + return -1 +endi +if $data70 != @NULL@ then + return -1 +endi +if $data80 != @NULL@ then + return -1 +endi +if $data90 != @NULL@ then + return -1 +endi +print execute sql select length(cast(a as binary(10))) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)) order by ts; +sql select length(cast(a as binary(10))) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)) order by ts; +if $data00 != @8@ then + return -1 +endi +if $data10 != @8@ then + return -1 +endi +if $data20 != @8@ then + return -1 +endi +if $data30 != @8@ then + return -1 +endi +if $data40 != @8@ then + return -1 +endi +if $data50 != @9@ then + return -1 +endi +if $data60 != @10@ then + return -1 +endi +if $data70 != @NULL@ then + return -1 +endi +if $data80 != @NULL@ then + return -1 +endi +if $data90 != @NULL@ then + return -1 +endi +print execute sql select length(cast(a as binary(10))) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)) order by ts desc; +sql select length(cast(a as binary(10))) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)) order by ts desc; +if $data00 != @NULL@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data20 != @NULL@ then + return -1 +endi +if $data30 != @10@ then + return -1 +endi +if $data40 != @9@ then + return -1 +endi +if $data50 != @8@ then + return -1 +endi +if $data60 != @8@ then + return -1 +endi +if $data70 != @8@ then + return -1 +endi +if $data80 != @8@ then + return -1 +endi +if $data90 != @8@ then + return -1 +endi +print execute sql select length(cast(a as binary(10))) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)) order by a desc; +sql select length(cast(a as binary(10))) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)) order by a desc; +if $data00 != @NULL@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data20 != @NULL@ then + return -1 +endi +if $data30 != @9@ then + return -1 +endi +if $data40 != @8@ then + return -1 +endi +if $data50 != @8@ then + return -1 +endi +if $data60 != @8@ then + return -1 +endi +if $data70 != @8@ then + return -1 +endi +if $data80 != @8@ then + return -1 +endi +if $data90 != @10@ then + return -1 +endi +print execute sql select length(cast(a as binary(10))) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)) order by a; +sql select length(cast(a as binary(10))) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)) order by a; +if $data00 != @10@ then + return -1 +endi +if $data10 != @8@ then + return -1 +endi +if $data20 != @8@ then + return -1 +endi +if $data30 != @8@ then + return -1 +endi +if $data40 != @8@ then + return -1 +endi +if $data50 != @8@ then + return -1 +endi +if $data60 != @9@ then + return -1 +endi +if $data70 != @NULL@ then + return -1 +endi +if $data80 != @NULL@ then + return -1 +endi +if $data90 != @NULL@ then + return -1 +endi +print execute sql select length(cast(a as binary(10))) from (select abs(c2) as a from tb1); +sql select length(cast(a as binary(10))) from (select abs(c2) as a from tb1); +if $data00 != @1@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data20 != @1@ then + return -1 +endi +if $data30 != @NULL@ then + return -1 +endi +if $data40 != @1@ then + return -1 +endi +if $data50 != @3@ then + return -1 +endi +if $data60 != @3@ then + return -1 +endi +print execute sql select length(tb1.c15),length(tb2.c15) from tb1,tb2 where tb1.ts=tb2.ts; +sql select length(tb1.c15),length(tb2.c15) from tb1,tb2 where tb1.ts=tb2.ts; +if $data00 != @4@ then + return -1 +endi +if $data01 != @4@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data11 != @4@ then + return -1 +endi +if $data20 != @NULL@ then + return -1 +endi +if $data21 != @4@ then + return -1 +endi +if $data30 != @4@ then + return -1 +endi +if $data31 != @4@ then + return -1 +endi +if $data40 != @4@ then + return -1 +endi +if $data41 != @4@ then + return -1 +endi +if $data50 != @12@ then + return -1 +endi +if $data51 != @4@ then + return -1 +endi +if $data60 != @0@ then + return -1 +endi +if $data61 != @4@ then + return -1 +endi +print execute sql select length(c15) from tb1 union all select length(c15) from tb2; +sql select length(c15) from tb1 union all select length(c15) from tb2; +if $data00 != @4@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data20 != @NULL@ then + return -1 +endi +if $data30 != @4@ then + return -1 +endi +if $data40 != @4@ then + return -1 +endi +if $data50 != @12@ then + return -1 +endi +if $data60 != @0@ then + return -1 +endi +if $data70 != @4@ then + return -1 +endi +if $data80 != @4@ then + return -1 +endi +if $data90 != @4@ then + return -1 +endi diff --git a/tests/script/general/compute/str_length2.sim b/tests/script/general/compute/str_length2.sim new file mode 100644 index 0000000000000000000000000000000000000000..94a735c4978874a6bf2e94a2801af4fdac6a8f24 --- /dev/null +++ b/tests/script/general/compute/str_length2.sim @@ -0,0 +1,309 @@ +sleep 100 +sql connect +sql use db + +$emptyString = @@ +print execute sql select length(stb1.c14),length(stba.c15) from stb1,stba where stb1.t1=stba.t1 and stb1.ts=stba.ts; +sql select length(stb1.c14),length(stba.c15) from stb1,stba where stb1.t1=stba.t1 and stb1.ts=stba.ts; +if $data00 != @1@ then + return -1 +endi +if $data01 != @4@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data11 != @4@ then + return -1 +endi +if $data20 != @1@ then + return -1 +endi +if $data21 != @4@ then + return -1 +endi +if $data30 != @NULL@ then + return -1 +endi +if $data31 != @4@ then + return -1 +endi +if $data40 != @1@ then + return -1 +endi +if $data41 != @4@ then + return -1 +endi +if $data50 != @2@ then + return -1 +endi +if $data51 != @4@ then + return -1 +endi +if $data60 != @0@ then + return -1 +endi +if $data61 != @4@ then + return -1 +endi +print execute sql select length(c14) as a from stb1 union all select length(c15) as a from stba; +sql select length(c14) as a from stb1 union all select length(c15) as a from stba; +if $data00 != @1@ then + return -1 +endi +if $data10 != @NULL@ then + return -1 +endi +if $data20 != @1@ then + return -1 +endi +if $data30 != @NULL@ then + return -1 +endi +if $data40 != @1@ then + return -1 +endi +if $data50 != @2@ then + return -1 +endi +if $data60 != @0@ then + return -1 +endi +if $data70 != @1@ then + return -1 +endi +if $data80 != @1@ then + return -1 +endi +if $data90 != @1@ then + return -1 +endi +print execute sql select length(c8) from stba; +sql select length(c8) from stba; +if $data00 != @3@ then + return -1 +endi +if $data10 != @3@ then + return -1 +endi +if $data20 != @3@ then + return -1 +endi +if $data30 != @3@ then + return -1 +endi +if $data40 != @3@ then + return -1 +endi +if $data50 != @3@ then + return -1 +endi +if $data60 != @3@ then + return -1 +endi +if $data70 != @3@ then + return -1 +endi +if $data80 != @3@ then + return -1 +endi +if $data90 != @3@ then + return -1 +endi +print execute sql select length(c9) from stba; +sql select length(c9) from stba; +if $data00 != @16@ then + return -1 +endi +if $data10 != @16@ then + return -1 +endi +if $data20 != @16@ then + return -1 +endi +if $data30 != @16@ then + return -1 +endi +if $data40 != @16@ then + return -1 +endi +if $data50 != @16@ then + return -1 +endi +if $data60 != @16@ then + return -1 +endi +if $data70 != @16@ then + return -1 +endi +if $data80 != @16@ then + return -1 +endi +if $data90 != @16@ then + return -1 +endi +print execute sql select length(cast(min(c2) as binary(20))) from tba1; +sql select length(cast(min(c2) as binary(20))) from tba1; +if $data00 != @1@ then + return -1 +endi +print execute sql select length(cast(max(c2) as binary(20))) from tba1; +sql select length(cast(max(c2) as binary(20))) from tba1; +if $data00 != @1@ then + return -1 +endi +print execute sql select length(cast(count(c2) as binary(20))) from tba1; +sql select length(cast(count(c2) as binary(20))) from tba1; +if $data00 != @2@ then + return -1 +endi +print execute sql select length(cast(sum(c2) as binary(20))) from tba1; +sql select length(cast(sum(c2) as binary(20))) from tba1; +if $data00 != @3@ then + return -1 +endi +print execute sql select length(cast(avg(c2) as binary(20))) from tba1; +sql select length(cast(avg(c2) as binary(20))) from tba1; +if $data00 != @8@ then + return -1 +endi +print execute sql select length(cast(percentile(c2, 10) as binary(20))) from tba1; +sql select length(cast(percentile(c2, 10) as binary(20))) from tba1; +if $data00 != @8@ then + return -1 +endi +print execute sql select length(cast(apercentile(c2, 10) as binary(20))) from tba1; +sql select length(cast(apercentile(c2, 10) as binary(20))) from tba1; +if $data00 != @8@ then + return -1 +endi +print execute sql select length(cast(stddev(c2) as binary(20))) from tba1; +sql select length(cast(stddev(c2) as binary(20))) from tba1; +if $data00 != @8@ then + return -1 +endi +print execute sql select length(cast(spread(c2) as binary(20))) from tba1; +sql select length(cast(spread(c2) as binary(20))) from tba1; +if $data00 != @8@ then + return -1 +endi +print execute sql select length(cast(twa(c2) as binary(20))) from tba1; +sql select length(cast(twa(c2) as binary(20))) from tba1; +if $data00 != @8@ then + return -1 +endi +print execute sql select length(cast(leastsquares(c2, 1, 1) as binary(20))) from tba1; +sql_error select length(cast(leastsquares(c2, 1, 1) as binary(20))) from tba1; +print execute sql select length(cast(interp(c2) as binary(20))) from tba1 every(1s) +sql select length(cast(interp(c2) as binary(20))) from tba1 every(1s) +if $data00 != @21-11-11 09:00:00.000@ then + return -1 +endi +if $data01 != @1@ then + return -1 +endi +if $data10 != @21-11-11 09:00:01.000@ then + return -1 +endi +if $data11 != @1@ then + return -1 +endi +if $data20 != @21-11-11 09:00:02.000@ then + return -1 +endi +if $data21 != @1@ then + return -1 +endi +if $data30 != @21-11-11 09:00:03.000@ then + return -1 +endi +if $data31 != @1@ then + return -1 +endi +if $data40 != @21-11-11 09:00:04.000@ then + return -1 +endi +if $data41 != @1@ then + return -1 +endi +if $data50 != @21-11-11 09:00:05.000@ then + return -1 +endi +if $data51 != @1@ then + return -1 +endi +if $data60 != @21-11-11 09:00:06.000@ then + return -1 +endi +if $data61 != @1@ then + return -1 +endi +if $data70 != @21-11-11 09:00:07.000@ then + return -1 +endi +if $data71 != @1@ then + return -1 +endi +if $data80 != @21-11-11 09:00:08.000@ then + return -1 +endi +if $data81 != @1@ then + return -1 +endi +if $data90 != @21-11-11 09:00:09.000@ then + return -1 +endi +if $data91 != @1@ then + return -1 +endi +print execute sql select length(cast(interp(c2) as binary(20))) stba every(1s) group by tbname; +sql_error select length(cast(interp(c2) as binary(20))) stba every(1s) group by tbname; +print execute sql select length(cast(elapsed(ts) as binary(20))) from tba1; +sql select length(cast(elapsed(ts) as binary(20))) from tba1; +if $data00 != @12@ then + return -1 +endi +print execute sql select length(cast(rate(c2) as binary(20))) from tba1; +sql select length(cast(rate(c2) as binary(20))) from tba1; +if $data00 != @8@ then + return -1 +endi +print execute sql select length(cast(irate(c2) as binary(20))) from tba1; +sql select length(cast(irate(c2) as binary(20))) from tba1; +if $data00 != @8@ then + return -1 +endi +print execute sql select length(cast(first(c2) as binary(20))) from tba1; +sql select length(cast(first(c2) as binary(20))) from tba1; +if $data00 != @1@ then + return -1 +endi +print execute sql select length(cast(last(c2) as binary(20))) from tba1; +sql select length(cast(last(c2) as binary(20))) from tba1; +if $data00 != @1@ then + return -1 +endi +print execute sql select length(cast(last_row(c2) as binary(20))) from tba1; +sql select length(cast(last_row(c2) as binary(20))) from tba1; +if $data00 != @1@ then + return -1 +endi +print execute sql select length(cast(top(c2, 1) as binary(20))) from tba1; +sql_error select length(cast(top(c2, 1) as binary(20))) from tba1; +print execute sql select length(cast(bottom(c2, 1) as binary(20))) from tba1; +sql_error select length(cast(bottom(c2, 1) as binary(20))) from tba1; +print execute sql select length(cast(leastsquares(c2, 1, 1) as binary(20))) from tba1; +sql_error select length(cast(leastsquares(c2, 1, 1) as binary(20))) from tba1; +print execute sql select length(cast(derivative(c2, 1s, 0) as binary(20))) from tba1; +sql_error select length(cast(derivative(c2, 1s, 0) as binary(20))) from tba1; +print execute sql select length(cast(diff(c2) as binary(20))) from tba1; +sql_error select length(cast(diff(c2) as binary(20))) from tba1; +print execute sql select length(cast(csum(c2) as binary(20))) from tba1; +sql_error select length(cast(csum(c2) as binary(20))) from tba1; +print execute sql select length(cast(mavg(c2,2) as binary(20))) from tba1; +sql_error select length(cast(mavg(c2,2) as binary(20))) from tba1; +print execute sql select length(cast(sample(c2,2) as binary(20))) from tba1; +sql_error select length(cast(sample(c2,2) as binary(20))) from tba1; +print execute sql select length(cast(_block_dist() as binary(20))) from tba1; +sql_error select length(cast(_block_dist() as binary(20))) from tba1; diff --git a/tests/script/general/compute/string_funcs.sim b/tests/script/general/compute/string_funcs.sim new file mode 100644 index 0000000000000000000000000000000000000000..119883b8e857086caa5f7b6accf00a457256244b --- /dev/null +++ b/tests/script/general/compute/string_funcs.sim @@ -0,0 +1,111 @@ +system sh/stop_dnodes.sh + +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/cfg.sh -n dnode1 -c maxtablespervnode -v 6 +system sh/cfg.sh -n dnode1 -c cache -v 1 +system sh/cfg.sh -n dnode1 -c minRows -v 10 +system sh/exec.sh -n dnode1 -s start + +sleep 100 +sql connect + +sql drop database if exists db +sql create database if not exists db +sql use db +sql create table stb1 (ts timestamp, c1 bool, c2 tinyint, c3 smallint, c4 int, c5 bigint, c6 float, c7 double, c8 binary(10), c9 nchar(10), c10 tinyint unsigned, c11 smallint unsigned, c12 int unsigned, c13 bigint unsigned, c14 binary(2), c15 nchar(3)) TAGS(t1 int, t2 binary(10), t3 double); + +sql create table tb1 using stb1 tags(1,'1',1.0); +sql create table tb2 using stb1 tags(2,'2',2.0); +sql create table tb3 using stb1 tags(3,'3',3.0); + +sql insert into tb1 values ('2021-11-11 09:00:00',true,1,1,1,1,1,1,"123","1234",1,1,1,1,'1','1'); +sql insert into tb1 values ('2021-11-11 09:00:01',true,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL); +sql insert into tb1 values ('2021-11-11 09:00:02',true,2,NULL,2,NULL,2,NULL,"234",NULL,2,NULL,2,NULL,'2',NULL); +sql insert into tb1 values ('2021-11-11 09:00:03',false,NULL,3,NULL,3,NULL,3,NULL,"3456",NULL,3,NULL,3,NULL,'3'); +sql insert into tb1 values ('2021-11-11 09:00:04',true,4,4,4,4,4,4,"456","4567",4,4,4,4,'4','4'); +sql insert into tb1 values ('2021-11-11 09:00:05',true,127,32767,2147483647,9223372036854775807,3.402823466e+38,1.79769e+308,"567","5678",254,65534,4294967294,9223372036854775807,'27','278'); +sql insert into tb1 values ('2021-11-11 09:00:06',true,-127,-32767,-2147483647,-9223372036854775807,-3.402823466e+38,-1.79769e+308,"678","6789",0,0,0,0,'',''); + +sql insert into tb2 values ('2021-11-11 09:00:00',true,1,1,1,1,1,1,"111","1111",1,1,1,1,'1','1'); +sql insert into tb2 values ('2021-11-11 09:00:01',true,2,2,2,2,2,2,"222","2222",2,2,2,2,'2','2'); +sql insert into tb2 values ('2021-11-11 09:00:02',true,3,3,2,3,3,3,"333","3333",3,3,3,3,'3','3'); +sql insert into tb2 values ('2021-11-11 09:00:03',false,4,4,4,4,4,4,"444","4444",4,4,4,4,'4','4'); +sql insert into tb2 values ('2021-11-11 09:00:04',true,5,5,5,5,5,5,"555","5555",5,5,5,5,'5','5'); +sql insert into tb2 values ('2021-11-11 09:00:05',true,6,6,6,6,6,6,"666","6666",6,6,6,6,'6','6'); +sql insert into tb2 values ('2021-11-11 09:00:06',true,7,7,7,7,7,7,"777","7777",7,7,7,7,'7','7'); + +sql create table tbn (ts timestamp, c1 bool, c2 tinyint, c3 smallint, c4 int, c5 bigint, c6 float, c7 double, c8 binary(10), c9 nchar(10), c10 tinyint unsigned, c11 smallint unsigned, c12 int unsigned, c13 bigint unsigned, c14 binary(2), c15 nchar(3)); + +sql insert into tbn values ('2021-11-11 09:00:00',true,1,1,1,1,1,1,"111","1111",1,1,1,1,'1','1'); +sql insert into tbn values ('2021-11-11 09:00:01',true,2,2,2,2,2,2,"222","2222",2,2,2,2,'2','2'); +sql insert into tbn values ('2021-11-11 09:00:02',true,3,3,2,3,3,3,"333","3333",3,3,3,3,'3','3'); +sql insert into tbn values ('2021-11-11 09:00:03',false,4,4,4,4,4,4,"444","4444",4,4,4,4,'4','4'); +sql insert into tbn values ('2021-11-11 09:00:04',true,5,5,5,5,5,5,"555","5555",5,5,5,5,'5','5'); +sql insert into tbn values ('2021-11-11 09:00:05',true,6,6,6,6,6,6,"666","6666",6,6,6,6,'6','6'); +sql insert into tbn values ('2021-11-11 09:00:06',true,7,7,7,7,7,7,"777","7777",7,7,7,7,'7','7'); + +run general/compute/str_concat.sim +run general/compute/str_concat_ws.sim +run general/compute/str_length.sim +run general/compute/str_char_length.sim + +sql create table stba (ts timestamp, c1 bool, c2 tinyint, c3 smallint, c4 int, c5 bigint, c6 float, c7 double, c8 binary(10), c9 nchar(10), c10 tinyint unsigned, c11 smallint unsigned, c12 int unsigned, c13 bigint unsigned, c14 binary(2), c15 nchar(3)) TAGS(t1 int, t2 binary(10), t3 double); + +sql create table tba1 using stba tags(1,'1',1.0); + +sql insert into tba1 values ('2021-11-11 09:00:00',true, 1,1,1,1,1,1,"111","1111",1,1,1,1,'1','1'); +sql insert into tba1 values ('2021-11-11 09:00:01',true, 2,2,2,2,2,2,"222","2222",2,2,2,2,'2','2'); +sql insert into tba1 values ('2021-11-11 09:00:02',true, 3,3,2,3,3,3,"333","3333",3,3,3,3,'3','3'); +sql insert into tba1 values ('2021-11-11 09:00:03',false,4,4,4,4,4,4,"444","4444",4,4,4,4,'4','4'); +sql insert into tba1 values ('2021-11-11 09:00:04',true, 5,5,5,5,5,5,"555","5555",5,5,5,5,'5','5'); +sql insert into tba1 values ('2021-11-11 09:00:05',true, 6,6,6,6,6,6,"666","6666",6,6,6,6,'6','6'); +sql insert into tba1 values ('2021-11-11 09:00:06',true, 7,7,7,7,7,7,"777","7777",7,7,7,7,'7','7'); +sql insert into tba1 values ('2021-11-11 09:00:07',true, 8,8,8,8,8,8,"888","8888",8,8,8,8,'8','8'); +sql insert into tba1 values ('2021-11-11 09:00:08',true, 9,9,9,9,9,9,"999","9999",9,9,9,9,'9','9'); +sql insert into tba1 values ('2021-11-11 09:00:09',true, 0,0,0,0,0,0,"000","0000",0,0,0,0,'0','0'); + +print ================== restart server to commit data into disk +system sh/exec.sh -n dnode1 -s stop -x SIGINT +sleep 500 +system sh/exec.sh -n dnode1 -s start +print ================== server restart completed + +sql insert into tba1 values ('2021-11-11 09:00:10',true, 1,1,1,1,1,1,"111","1111",1,1,1,1,'1','1'); +sql insert into tba1 values ('2021-11-11 09:00:11',true, 2,2,2,2,2,2,"222","2222",2,2,2,2,'2','2'); +sql insert into tba1 values ('2021-11-11 09:00:12',true, 3,3,2,3,3,3,"333","3333",3,3,3,3,'3','3'); +sql insert into tba1 values ('2021-11-11 09:00:13',false,4,4,4,4,4,4,"444","4444",4,4,4,4,'4','4'); +sql insert into tba1 values ('2021-11-11 09:00:14',true, 5,5,5,5,5,5,"555","5555",5,5,5,5,'5','5'); +sql insert into tba1 values ('2021-11-11 09:00:15',true, 6,6,6,6,6,6,"666","6666",6,6,6,6,'6','6'); +sql insert into tba1 values ('2021-11-11 09:00:16',true, 7,7,7,7,7,7,"777","7777",7,7,7,7,'7','7'); +sql insert into tba1 values ('2021-11-11 09:00:17',true, 8,8,8,8,8,8,"888","8888",8,8,8,8,'8','8'); +sql insert into tba1 values ('2021-11-11 09:00:18',true, 9,9,9,9,9,9,"999","9999",9,9,9,9,'9','9'); +sql insert into tba1 values ('2021-11-11 09:00:19',true, 0,0,0,0,0,0,"000","0000",0,0,0,0,'0','0'); + +print ================== restart server to commit data into disk +system sh/exec.sh -n dnode1 -s stop -x SIGINT +sleep 500 +system sh/exec.sh -n dnode1 -s start +print ================== server restart completed + +sql insert into tba1 values ('2021-11-11 09:00:20',true, 1,1,1,1,1,1,"111","1111",1,1,1,1,'1','1'); +sql insert into tba1 values ('2021-11-11 09:00:21',true, 2,2,2,2,2,2,"222","2222",2,2,2,2,'2','2'); +sql insert into tba1 values ('2021-11-11 09:00:22',true, 3,3,2,3,3,3,"333","3333",3,3,3,3,'3','3'); +sql insert into tba1 values ('2021-11-11 09:00:23',false,4,4,4,4,4,4,"444","4444",4,4,4,4,'4','4'); +sql insert into tba1 values ('2021-11-11 09:00:24',true, 5,5,5,5,5,5,"555","5555",5,5,5,5,'5','5'); +sql insert into tba1 values ('2021-11-11 09:00:25',true, 6,6,6,6,6,6,"666","6666",6,6,6,6,'6','6'); +sql insert into tba1 values ('2021-11-11 09:00:26',true, 7,7,7,7,7,7,"777","7777",7,7,7,7,'7','7'); +sql insert into tba1 values ('2021-11-11 09:00:27',true, 8,8,8,8,8,8,"888","8888",8,8,8,8,'8','8'); +sql insert into tba1 values ('2021-11-11 09:00:28',true, 9,9,9,9,9,9,"999","9999",9,9,9,9,'9','9'); +sql insert into tba1 values ('2021-11-11 09:00:29',true, 0,0,0,0,0,0,"000","0000",0,0,0,0,'0','0'); + +run general/compute/str_concat.sim +run general/compute/str_concat2.sim +run general/compute/str_concat_ws.sim +run general/compute/str_concat_ws2.sim +run general/compute/str_length.sim +run general/compute/str_length2.sim +run general/compute/str_char_length.sim +run general/compute/str_char_length2.sim +#system sh/exec.sh -n dnode1 -s stop -x SIGINT + diff --git a/tests/script/general/compute/testSuite.sim b/tests/script/general/compute/testSuite.sim index ceb6525c7f67ab6c06f80d527f90c00299fbbd6e..fd1e5252920cde997d9c5be2fd60730b90e49974 100644 --- a/tests/script/general/compute/testSuite.sim +++ b/tests/script/general/compute/testSuite.sim @@ -20,4 +20,9 @@ run general/compute/stddev.sim run general/compute/sum.sim run general/compute/top.sim run general/compute/block_dist.sim +run general/compute/math_funcs.sim +run general/compute/string_funcs.sim +run general/compute/scalar_pow.sim +run general/compute/scalar_triangle.sim +run general/compute/scalar_str_concat_len.sim run general/compute/table_group.sim diff --git a/tests/script/general/parser/scalar_expression.sim b/tests/script/general/parser/scalar_expression.sim new file mode 100644 index 0000000000000000000000000000000000000000..9f8c9c38caa81613a58aa4de596d453eae162ad7 --- /dev/null +++ b/tests/script/general/parser/scalar_expression.sim @@ -0,0 +1,251 @@ + +system sh/stop_dnodes.sh + +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/exec.sh -n dnode1 -s start +sleep 500 +sql connect + +$dbPrefix = db +$tbPrefix = ct +$mtPrefix = st +$tbNum = 2 +$rowNum = 50 + +print =============== step1 create stable/table +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql drop database $db -x step1 +step1: +sql create database $db +sql use $db +sql create table $mt (ts timestamp, c1 int, c2 float, c3 bigint, c4 smallint, c5 tinyint, c6 double, c7 bool, c8 nchar(5), c9 binary(10)) TAGS (tgcol int) +$i = 0 +while $i < $tbNum + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( $i ) + + $x = 0 + $y = 0.25 + + while $x < $rowNum + $cc = $x * 60000 + $ms = 1601481600000 + $cc + sql insert into $tb values ($ms , $x , $y , $x , $x , $x , $y , $x , $x , $x ) + $x = $x + 1 + $y = $y + 1 + endw + + $i = $i + 1 +endw + +print ================= step2 + +print execute sql select floor(3.0)+ceil(4.0) from ct0 +sql select floor(3.0)+ceil(4.0) from ct0 +if $data00 != @7.000000000@ then + return -1 +endi +if $data10 != @7.000000000@ then + return -1 +endi +if $data20 != @7.000000000@ then + return -1 +endi +if $data30 != @7.000000000@ then + return -1 +endi +if $data40 != @7.000000000@ then + return -1 +endi +if $data50 != @7.000000000@ then + return -1 +endi +if $data60 != @7.000000000@ then + return -1 +endi +if $data70 != @7.000000000@ then + return -1 +endi +if $data80 != @7.000000000@ then + return -1 +endi +if $data90 != @7.000000000@ then + return -1 +endi +print execute sql select sum(c1)+3.0+4.0 from st0 +sql select sum(c1)+3.0+4.0 from st0 +if $data00 != @2457.000000000@ then + return -1 +endi +print execute sql select sin(log(avg(c1),sum(c2))+3)%4 from st0 +sql select sin(log(avg(c1),sum(c2))+3)%4 from st0 +if $data00 != @-0.265074286@ then + return -1 +endi +print execute sql select log(pow(length(concat('3','4')),2),c2) from st0 +sql select log(pow(length(concat('3','4')),2),c2) from st0 +if $data00 != @-1.000000000@ then + return -1 +endi +if $data10 != @inf@ then + return -1 +endi +if $data20 != @2.000000000@ then + return -1 +endi +if $data30 != @1.261859507@ then + return -1 +endi +if $data40 != @1.000000000@ then + return -1 +endi +if $data50 != @0.861353116@ then + return -1 +endi +if $data60 != @0.773705614@ then + return -1 +endi +if $data70 != @0.712414374@ then + return -1 +endi +if $data80 != @0.666666667@ then + return -1 +endi +if $data90 != @0.630929754@ then + return -1 +endi +print execute sql select round(log(pow(length(concat('3','4')),2),c2)+floor(c3))+2 from st0 +sql select round(log(pow(length(concat('3','4')),2),c2)+floor(c3))+2 from st0 +if $data00 != @1.000000000@ then + return -1 +endi +if $data10 != @inf@ then + return -1 +endi +if $data20 != @6.000000000@ then + return -1 +endi +if $data30 != @6.000000000@ then + return -1 +endi +if $data40 != @7.000000000@ then + return -1 +endi +if $data50 != @8.000000000@ then + return -1 +endi +if $data60 != @9.000000000@ then + return -1 +endi +if $data70 != @10.000000000@ then + return -1 +endi +if $data80 != @11.000000000@ then + return -1 +endi +if $data90 != @12.000000000@ then + return -1 +endi +print execute sql select sin(pow(c1,log(c2,2))+pow(c2,2)) as val from ct0 union all select pow(c4,2)+tan(sin(c5)/cos(c6)) as val from ct1 +sql select sin(pow(c1,log(c2,2))+pow(c2,2)) as val from ct0 union all select pow(c4,2)+tan(sin(c5)/cos(c6)) as val from ct1 +if $data00 != @-nan@ then + return -1 +endi +if $data10 != @0.909297427@ then + return -1 +endi +if $data20 != @-0.279415498@ then + return -1 +endi +if $data30 != @0.843325058@ then + return -1 +endi +if $data40 != @0.551426681@ then + return -1 +endi +if $data50 != @-0.840606612@ then + return -1 +endi +if $data60 != @0.436161076@ then + return -1 +endi +if $data70 != @0.897498185@ then + return -1 +endi +if $data80 != @-0.885952778@ then + return -1 +endi +if $data90 != @0.429470715@ then + return -1 +endi +print execute sql select asin(c1) from st0 limit 1 +sql select asin(c1) from st0 limit 1 +if $data00 != @0.000000000@ then + return -1 +endi +print execute sql select pow(c1,2) from st0 limit 1 offset 2; +sql select pow(c1,2) from st0 limit 1 offset 2; +if $data00 != @4.000000000@ then + return -1 +endi +print execute sql select cos(c1) from db0.ct0, db0.ct1 where ct0.ts==ct1.ts +sql select cos(c1) from db0.ct0, db0.ct1 where ct0.ts==ct1.ts +if $data00 != @1.000000000@ then + return -1 +endi +if $data10 != @0.540302306@ then + return -1 +endi +if $data20 != @-0.416146837@ then + return -1 +endi +if $data30 != @-0.989992497@ then + return -1 +endi +if $data40 != @-0.653643621@ then + return -1 +endi +if $data50 != @0.283662185@ then + return -1 +endi +if $data60 != @0.960170287@ then + return -1 +endi +if $data70 != @0.753902254@ then + return -1 +endi +if $data80 != @-0.145500034@ then + return -1 +endi +if $data90 != @-0.911130262@ then + return -1 +endi +print ============== invalid expressions +$stb = st0 +sql_error select agg(c1)+c2 from $stb +sql_error select agg(c1+2) from $stb +sql_error select agg(ceil(c1))+c2 from $stb +sql_error select agg(ceil(c1)) from $stb +sql_error select asin(c1) from $stb group by tbname +sql_error select asin(c2) from $stb group by tgcol +sql_error select asin(c1) from $stb session_window(ts, 1s) +sql_error select cos(c1) from $stb state_window(f1) +sql_error select pow(c2,2) from $stb interval(1s) sliding(500a) +sql_error select pow(c2,2) from $stb state_window(f1) +sql_error select tan(c1) from $stb from d.st slimit 1 +sql_error select c1+2, tbname from $stb group by tbname +sql select sin(sin(sin(sin(sin(sin(sin(sin(sin(sin(sin(sin(sin(sin(sin(sin(c1)))))))))))))))) from $stb +sql_error select sin(sin(sin(sin(sin(sin(sin(sin(sin(sin(sin(sin(sin(sin(sin(sin(sin(c1))))))))))))))))) from $stb +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT + diff --git a/tests/script/regressionSuite.sim b/tests/script/regressionSuite.sim index 91a88451924e6856a693208d30733c1f610dd74a..528dbbe04044ba4007d00edd68f31286f32ee889 100644 --- a/tests/script/regressionSuite.sim +++ b/tests/script/regressionSuite.sim @@ -38,6 +38,11 @@ run general/compute/stddev.sim run general/compute/sum.sim run general/compute/top.sim run general/compute/block_dist.sim +run general/compute/math_funcs.sim +run general/compute/string_funcs.sim +run general/compute/scalar_pow.sim +run general/compute/scalar_triangle.sim +run general/compute/scalar_str_concat_len.sim run general/compute/table_group.sim run general/db/alter_option.sim run general/db/alter_tables_d2.sim @@ -141,6 +146,7 @@ run general/parser/tags_dynamically_specifiy.sim run general/parser/set_tag_vals.sim run general/parser/repeatAlter.sim run general/parser/precision_ns.sim +run general/parser/scalar_expression.sim ##unsupport run general/parser/slimit_alter_tags.sim run general/stable/disk.sim run general/stable/dnode3.sim