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 b183598fcceff926cfba235e42d8634546b36a48..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) @@ -256,7 +256,7 @@ void tscColumnListDestroy(SArray* pColList); void tscColumnListCopy(SArray* dst, const SArray* src, uint64_t tableUid); void tscColumnListCopyAll(SArray* dst, const SArray* src); -void convertQueryResult(SSqlRes* pRes, SQueryInfo* pQueryInfo, uint64_t objId, bool convertNchar); +void convertQueryResult(SSqlRes* pRes, SQueryInfo* pQueryInfo, uint64_t objId, bool convertNchar, bool convertJson); void tscDequoteAndTrimToken(SStrToken* pToken); void tscRmEscapeAndTrimToken(SStrToken* pToken); @@ -264,7 +264,7 @@ int32_t tscValidateName(SStrToken* pToken, bool escapeEnabled, bool *dbIncluded) void tscIncStreamExecutionCount(void* pStream); -bool tscValidateColumnId(STableMetaInfo* pTableMetaInfo, int32_t colId, int32_t numOfParams); +bool tscValidateColumnId(STableMetaInfo* pTableMetaInfo, int32_t colId); // get starter position of metric query condition (query on tags) in SSqlCmd.payload SCond* tsGetSTableQueryCond(STagCond* pCond, uint64_t uid); @@ -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); @@ -394,6 +394,9 @@ void tscRemoveCachedTableMeta(STableMetaInfo* pTableMetaInfo, uint64_t id); char* cloneCurrentDBName(SSqlObj* pSql); +int parseJsontoTagData(char* json, SKVRowBuilder* kvRowBuilder, char* errMsg, int16_t startColId); +int8_t jsonType2DbType(double data, int jsonType); +void getJsonKey(SStrToken *t0); char* cloneCurrentDBName(SSqlObj* pSql); diff --git a/src/client/inc/tsclient.h b/src/client/inc/tsclient.h index 7f35cf0ea5080cbb49db3a78b7d53df58cb9724c..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); /** @@ -453,7 +453,7 @@ void tscRestoreFuncForSTableQuery(SQueryInfo *pQueryInfo); int32_t tscCreateResPointerInfo(SSqlRes *pRes, SQueryInfo *pQueryInfo); void tscSetResRawPtr(SSqlRes* pRes, SQueryInfo* pQueryInfo, bool converted); -void tscSetResRawPtrRv(SSqlRes* pRes, SQueryInfo* pQueryInfo, SSDataBlock* pBlock, bool convertNchar); +void tscSetResRawPtrRv(SSqlRes* pRes, SQueryInfo* pQueryInfo, SSDataBlock* pBlock, bool convertNchar, bool convertJson); void handleDownstreamOperator(SSqlObj** pSqlList, int32_t numOfUpstream, SQueryInfo* px, SSqlObj* pParent); void destroyTableNameList(SInsertStatementParam* pInsertParam); @@ -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/TSDBJNIConnector.c b/src/client/src/TSDBJNIConnector.c index 5127aaf665b8059a12ef0985140c2a01ea328bfa..32a07b3aad20d8399620b13bf8c4fdb440a8e106 100644 --- a/src/client/src/TSDBJNIConnector.c +++ b/src/client/src/TSDBJNIConnector.c @@ -547,6 +547,11 @@ JNIEXPORT jint JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_fetchRowImp(JNIEn jniFromNCharToByteArray(env, (char *)row[i], length[i])); break; } + case TSDB_DATA_TYPE_JSON: { + (*env)->CallVoidMethod(env, rowobj, g_rowdataSetByteArrayFp, i, + jniFromNCharToByteArray(env, (char *)row[i], length[i])); + break; + } case TSDB_DATA_TYPE_TIMESTAMP: { int precision = taos_result_precision(result); (*env)->CallVoidMethod(env, rowobj, g_rowdataSetTimestampFp, i, (jlong) * ((int64_t *)row[i]), precision); 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/tscLocal.c b/src/client/src/tscLocal.c index 96aa3ef711c20d7ef75c8fe74187751614a7fe3b..90379e6f7e5ccb5da12e6007ca0e94cfc859ee53 100644 --- a/src/client/src/tscLocal.c +++ b/src/client/src/tscLocal.c @@ -85,16 +85,15 @@ static int32_t tscSetValueToResObj(SSqlObj *pSql, int32_t rowLen) { pField = tscFieldInfoGetField(&pQueryInfo->fieldsInfo, 1); dst = pRes->data + tscFieldInfoGetOffset(pQueryInfo, 1) * totalNumOfRows + pField->bytes * i; - STR_WITH_MAXSIZE_TO_VARSTR(dst, type, pField->bytes); - + int32_t bytes = pSchema[i].bytes; - if (pSchema[i].type == TSDB_DATA_TYPE_BINARY || pSchema[i].type == TSDB_DATA_TYPE_NCHAR) { + if (pSchema[i].type == TSDB_DATA_TYPE_BINARY){ bytes -= VARSTR_HEADER_SIZE; - - if (pSchema[i].type == TSDB_DATA_TYPE_NCHAR) { - bytes = bytes / TSDB_NCHAR_SIZE; - } + } + else if(pSchema[i].type == TSDB_DATA_TYPE_NCHAR || pSchema[i].type == TSDB_DATA_TYPE_JSON) { + bytes -= VARSTR_HEADER_SIZE; + bytes = bytes / TSDB_NCHAR_SIZE; } pField = tscFieldInfoGetField(&pQueryInfo->fieldsInfo, 2); @@ -222,7 +221,7 @@ static int32_t tscGetNthFieldResult(TAOS_ROW row, TAOS_FIELD* fields, int *lengt return -1; } uint8_t type = fields[idx].type; - int32_t length = lengths[idx]; + int32_t length = lengths[idx]; switch (type) { case TSDB_DATA_TYPE_BOOL: @@ -248,6 +247,7 @@ static int32_t tscGetNthFieldResult(TAOS_ROW row, TAOS_FIELD* fields, int *lengt break; case TSDB_DATA_TYPE_NCHAR: case TSDB_DATA_TYPE_BINARY: + case TSDB_DATA_TYPE_JSON: memcpy(result, val, length); break; case TSDB_DATA_TYPE_TIMESTAMP: diff --git a/src/client/src/tscParseInsert.c b/src/client/src/tscParseInsert.c index 94f9a3018aae175f0f27c1c24b735f5a0392102d..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; @@ -385,6 +355,19 @@ int32_t tsParseOneColumn(SSchema *pSchema, SStrToken *pToken, char *payload, cha } break; + case TSDB_DATA_TYPE_JSON: + if (pToken->n >= pSchema->bytes) { // reserve 1 byte for select + return tscInvalidOperationMsg(msg, "json tag length too long", pToken->z); + } + if (pToken->type == TK_NULL) { + *(int8_t *)payload = TSDB_DATA_TINYINT_NULL; + } else if (pToken->type != TK_STRING){ + tscInvalidOperationMsg(msg, "invalid json data", pToken->z); + } else{ + *((int8_t *)payload) = TSDB_DATA_JSON_PLACEHOLDER; + } + break; + case TSDB_DATA_TYPE_TIMESTAMP: { if (pToken->type == TK_NULL) { if (primaryKey) { @@ -455,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); @@ -533,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; } @@ -549,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) { @@ -565,7 +541,7 @@ int tsParseOneRow(char **str, STableDataBlocks *pDataBlocks, int16_t timePrec, i } } - *len = getExtendedRowSize(pDataBlocks); + *len = pBuilder->rowSize; return TSDB_CODE_SUCCESS; } @@ -618,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); @@ -701,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)); } @@ -1094,9 +1071,26 @@ static int32_t tscCheckIfCreateTable(char **sqlstr, SSqlObj *pSql, char** boundC return code; } - tdAddColToKVRow(&kvRowBuilder, pSchema->colId, pSchema->type, tagVal); - } + tdAddColToKVRow(&kvRowBuilder, pSchema->colId, pSchema->type, tagVal, false); + if(pSchema->type == TSDB_DATA_TYPE_JSON){ + assert(spd.numOfBound == 1); + if(sToken.n > TSDB_MAX_JSON_TAGS_LEN/TSDB_NCHAR_SIZE){ + tdDestroyKVRowBuilder(&kvRowBuilder); + tscDestroyBoundColumnInfo(&spd); + return tscSQLSyntaxErrMsg(pInsertParam->msg, "json tag too long", NULL); + } + char* json = strndup(sToken.z, sToken.n); + code = parseJsontoTagData(json, &kvRowBuilder, pInsertParam->msg, pTagSchema[spd.boundedColumns[0]].colId); + if (code != TSDB_CODE_SUCCESS) { + tdDestroyKVRowBuilder(&kvRowBuilder); + tscDestroyBoundColumnInfo(&spd); + tfree(json); + return code; + } + tfree(json); + } + } tscDestroyBoundColumnInfo(&spd); SKVRow row = tdGetKVRowFromBuilder(&kvRowBuilder); @@ -1110,7 +1104,7 @@ static int32_t tscCheckIfCreateTable(char **sqlstr, SSqlObj *pSql, char** boundC if (pInsertParam->tagData.dataLen <= 0){ return tscSQLSyntaxErrMsg(pInsertParam->msg, "tag value expected", NULL); } - + char* pTag = realloc(pInsertParam->tagData.data, pInsertParam->tagData.dataLen); if (pTag == NULL) { return TSDB_CODE_TSC_OUT_OF_MEMORY; @@ -1224,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; @@ -1281,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; @@ -1304,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; @@ -1754,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 a92bf7c22bef8cde1546b3cde4da46f9826f02e9..2f800339b792191685057a7e54077677156bbe01 100644 --- a/src/client/src/tscSQLParser.c +++ b/src/client/src/tscSQLParser.c @@ -41,6 +41,7 @@ #include "qScript.h" #include "ttype.h" #include "qFilter.h" +#include "cJSON.h" #define DEFAULT_PRIMARY_TIMESTAMP_COL_NAME "_c0" @@ -108,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); @@ -163,6 +165,7 @@ bool serializeExprListToVariant(SArray* pList, tVariant **dst, int16_t colType, tSqlExpr* item = ((tSqlExprItem*)(taosArrayGet(pList, 0)))->pNode; int32_t firstVarType = item->value.nType; + if(colType == TSDB_DATA_TYPE_JSON) colType = firstVarType; SBufferWriter bw = tbufInitWriter( NULL, false); tbufEnsureCapacity(&bw, 512); @@ -284,6 +287,10 @@ static uint8_t convertRelationalOperator(SStrToken *pToken) { return TSDB_RELATION_MATCH; case TK_NMATCH: return TSDB_RELATION_NMATCH; + case TK_CONTAINS: + return TSDB_RELATION_CONTAINS; + case TK_ARROW: + return TSDB_RELATION_ARROW; case TK_ISNULL: return TSDB_RELATION_ISNULL; case TK_NOTNULL: @@ -1520,7 +1527,7 @@ static bool validateTableColumnInfo(SArray* pFieldList, SSqlCmd* pCmd) { int32_t nLen = 0; for (int32_t i = 0; i < numOfCols; ++i) { pField = taosArrayGet(pFieldList, i); - if (!isValidDataType(pField->type)) { + if (!isValidDataType(pField->type) || pField->type == TSDB_DATA_TYPE_JSON) { invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg4); return false; } @@ -1559,7 +1566,6 @@ static bool validateTableColumnInfo(SArray* pFieldList, SSqlCmd* pCmd) { return true; } - static bool validateTagParams(SArray* pTagsList, SArray* pFieldList, SSqlCmd* pCmd) { assert(pTagsList != NULL); @@ -1570,6 +1576,7 @@ static bool validateTagParams(SArray* pTagsList, SArray* pFieldList, SSqlCmd* pC const char* msg5 = "invalid data type in tags"; const char* msg6 = "invalid tag name or length"; const char* msg7 = "invalid binary/nchar tag length"; + const char* msg8 = "only support one tag if include json type"; // number of fields at least 1 size_t numOfTags = taosArrayGetSize(pTagsList); @@ -1585,6 +1592,11 @@ static bool validateTagParams(SArray* pTagsList, SArray* pFieldList, SSqlCmd* pC return false; } + if (p->type == TSDB_DATA_TYPE_JSON && numOfTags != 1) { + invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg8); + return false; + } + if ((p->type == TSDB_DATA_TYPE_BINARY && p->bytes <= 0) || (p->type == TSDB_DATA_TYPE_NCHAR && p->bytes <= 0)) { invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg7); @@ -1603,18 +1615,21 @@ static bool validateTagParams(SArray* pTagsList, SArray* pFieldList, SSqlCmd* pC } int32_t nLen = 0; + bool isJsonTag = false; for (int32_t i = 0; i < numOfTags; ++i) { TAOS_FIELD* p = taosArrayGet(pTagsList, i); if (p->bytes == 0) { invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg7); return false; } - + if(p->type == TSDB_DATA_TYPE_JSON){ + isJsonTag = true; + } nLen += p->bytes; } // max tag row length must be less than TSDB_MAX_TAGS_LEN - if (nLen > TSDB_MAX_TAGS_LEN) { + if (!isJsonTag && nLen > TSDB_MAX_TAGS_LEN) { invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg2); return false; } @@ -1641,6 +1656,7 @@ int32_t validateOneTag(SSqlCmd* pCmd, TAOS_FIELD* pTagField) { const char* msg5 = "invalid binary/nchar tag length"; const char* msg6 = "invalid data type in tags"; const char* msg7 = "too many columns"; + const char* msg8 = "only support one json tag"; STableMetaInfo* pTableMetaInfo = tscGetTableMetaInfoFromCmd(pCmd, 0); STableMeta* pTableMeta = pTableMetaInfo->pTableMeta; @@ -1666,6 +1682,9 @@ int32_t validateOneTag(SSqlCmd* pCmd, TAOS_FIELD* pTagField) { // invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg1); // return false; //} + if (pTagField->type == TSDB_DATA_TYPE_JSON) { + return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg8); + } if ((pTagField->type < TSDB_DATA_TYPE_BOOL) || (pTagField->type > TSDB_DATA_TYPE_UBIGINT)) { return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg6); @@ -1674,6 +1693,10 @@ int32_t validateOneTag(SSqlCmd* pCmd, TAOS_FIELD* pTagField) { SSchema* pTagSchema = tscGetTableTagSchema(pTableMetaInfo->pTableMeta); int32_t nLen = 0; + if (numOfTags == 1 && pTagSchema[0].type == TSDB_DATA_TYPE_JSON){ + return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg8); + } + for (int32_t i = 0; i < numOfTags; ++i) { nLen += pTagSchema[i].bytes; } @@ -1788,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); @@ -1912,33 +1961,70 @@ 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) { SExprInfo* pExpr = doAddProjectCol(pQueryInfo, pIndex->columnIndex, pIndex->tableIndex, colId); + if( pItem->pNode->tokenId == TK_ARROW){ + tSqlExpr* right = pItem->pNode->pRight; + assert(right != NULL && right->type == SQL_NODE_VALUE); + tVariantAssign(&(pExpr->base.param[pExpr->base.numOfParams]), &right->value); + pExpr->base.numOfParams++; + } STableMetaInfo* pTableMetaInfo = tscGetMetaInfo(pQueryInfo, pIndex->tableIndex); STableMeta* pTableMeta = pTableMetaInfo->pTableMeta; SSchema* pSchema = tscGetTableColumnSchema(pTableMeta, pIndex->columnIndex); - char* colName = (pItem->aliasName == NULL) ? pSchema->name : pItem->aliasName; - tstrncpy(pExpr->base.aliasName, colName, sizeof(pExpr->base.aliasName)); - + if (pSchema->type == TSDB_DATA_TYPE_JSON && pItem->pNode->tokenId == TK_ARROW) { + if (pItem->aliasName){ + tstrncpy(pExpr->base.aliasName, pItem->aliasName, sizeof(pExpr->base.aliasName)); + }else{ + tstrncpy(pExpr->base.aliasName, pItem->pNode->exprToken.z, + pItem->pNode->exprToken.n + 1 < sizeof(pExpr->base.aliasName) ? pItem->pNode->exprToken.n + 1 : sizeof(pExpr->base.aliasName)); + } + }else{ + char* colName = (pItem->aliasName == NULL) ? pSchema->name : pItem->aliasName; + tstrncpy(pExpr->base.aliasName, colName, sizeof(pExpr->base.aliasName)); + } SColumnList ids = {0}; ids.num = 1; ids.ids[0] = *pIndex; - if (pIndex->columnIndex == TSDB_TBNAME_COLUMN_INDEX || pIndex->columnIndex == TSDB_UD_COLUMN_INDEX || + if (pIndex->columnIndex == TSDB_TBNAME_COLUMN_INDEX || pIndex->columnIndex <= TSDB_UD_COLUMN_INDEX || pIndex->columnIndex >= tscGetNumOfColumns(pTableMeta)) { ids.num = 0; } @@ -1963,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); @@ -2054,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); @@ -2095,8 +2191,17 @@ int32_t validateSelectNodeList(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SArray* pS return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg11); } + if(pItem->aliasName != NULL && validateColumnName(pItem->aliasName) != TSDB_CODE_SUCCESS){ + return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg11); + } + 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; @@ -2120,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); } @@ -2279,6 +2387,9 @@ int32_t addProjectionExprAndResultField(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, t const char* msg1 = "tag for normal table query is not allowed"; const char* msg2 = "invalid column name"; const char* msg3 = "tbname not allowed in outer query"; + const char* msg4 = "-> operate can only used in json type"; + const char* msg5 = "the right value of -> operation must be string"; + const char* msg6 = "select name is too long than 64, please use alias name"; int32_t startPos = (int32_t)tscNumOfExprs(pQueryInfo); int32_t tokenId = pItem->pNode->tokenId; @@ -2318,13 +2429,29 @@ int32_t addProjectionExprAndResultField(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, t SExprInfo* pExpr = tscAddFuncInSelectClause(pQueryInfo, startPos, TSDB_FUNC_PRJ, &index, &colSchema, TSDB_COL_UDC, getNewResColId(pCmd)); - // NOTE: the first parameter is reserved for the tag column id during join query process. - pExpr->base.numOfParams = 2; - tVariantAssign(&pExpr->base.param[1], &pItem->pNode->value); - } else if (tokenId == TK_ID) { + tVariantAssign(&pExpr->base.param[pExpr->base.numOfParams++], &pItem->pNode->value); + }else if (tokenId == TK_ID || tokenId == TK_ARROW) { SColumnIndex index = COLUMN_INDEX_INITIALIZER; - if (getColumnIndexByName(&pItem->pNode->columnName, pQueryInfo, &index, tscGetErrorMsgPayload(pCmd)) != TSDB_CODE_SUCCESS) { + SStrToken* pToken = NULL; + if (tokenId == TK_ARROW){ + tSqlExpr* left = pItem->pNode->pLeft; + assert(left != NULL && left->type == SQL_NODE_TABLE_COLUMN); + if (pQueryInfo->pUpstream != NULL && taosArrayGetSize(pQueryInfo->pUpstream) > 0){ // if select from subquery, pToken should be jtag->'location'. like (select jtag->'location' from (select jtag->'location' from jsons1);) + pToken = &pItem->pNode->exprToken; + }else{ + pToken = &left->columnName; + } + + tSqlExpr* right = pItem->pNode->pRight; + if(right == NULL || right->type != SQL_NODE_VALUE || right->tokenId != TK_STRING){ + return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg5); + } + }else { + pToken = &pItem->pNode->columnName; + } + + if (getColumnIndexByName(pToken, pQueryInfo, &index, tscGetErrorMsgPayload(pCmd)) != TSDB_CODE_SUCCESS) { return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg2); } @@ -2371,6 +2498,14 @@ int32_t addProjectionExprAndResultField(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, t return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg1); } + SSchema* pSchema = tscGetTableColumnSchema(pTableMeta, index.columnIndex); + if (tokenId == TK_ARROW && pSchema->type != TSDB_DATA_TYPE_JSON) { + return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg4); + } + if (pSchema->type == TSDB_DATA_TYPE_JSON && tokenId == TK_ARROW && pItem->pNode->exprToken.n >= TSDB_COL_NAME_LEN){ + return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg6); + } + addProjectQueryCol(pQueryInfo, startPos, &index, pItem, getNewResColId(pCmd)); pQueryInfo->type |= TSDB_QUERY_TYPE_PROJECTION_QUERY; } @@ -2452,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); @@ -2605,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: { @@ -3147,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); @@ -3510,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); @@ -3585,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; @@ -3660,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); @@ -3693,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 @@ -3722,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; } @@ -3754,6 +3915,9 @@ int32_t validateGroupbyNode(SQueryInfo* pQueryInfo, SArray* pList, SSqlCmd* pCmd const char* msg6 = "tags not allowed for table query"; const char* msg7 = "not support group by expression"; const char* msg8 = "normal column can only locate at the end of group by clause"; + const char* msg9 = "json tag must be use ->'key'"; + const char* msg10 = "non json column can not use ->'key'"; + const char* msg11 = "group by json->'key' is too long"; // todo : handle two tables situation STableMetaInfo* pTableMetaInfo = NULL; @@ -3789,13 +3953,18 @@ int32_t validateGroupbyNode(SQueryInfo* pQueryInfo, SArray* pList, SSqlCmd* pCmd size_t num = taosArrayGetSize(pList); for (int32_t i = 0; i < num; ++i) { - tVariantListItem * pItem = taosArrayGet(pList, i); - tVariant* pVar = &pItem->pVar; - - SStrToken token = {pVar->nLen, pVar->nType, pVar->pz}; - - if (pVar->nType != TSDB_DATA_TYPE_BINARY){ - return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg2); + CommonItem * pItem = taosArrayGet(pList, i); + SStrToken token = {0}; + if(pItem->isJsonExp){ + assert(pItem->jsonExp->tokenId == TK_ARROW); + token = pItem->jsonExp->pLeft->columnName; + }else { + token.n = pItem->pVar.nLen; + token.z = pItem->pVar.pz; + token.type = pItem->pVar.nType; + if (pItem->pVar.nType != TSDB_DATA_TYPE_BINARY){ + return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg2); + } } SColumnIndex index = COLUMN_INDEX_INITIALIZER; @@ -3818,6 +3987,13 @@ int32_t validateGroupbyNode(SQueryInfo* pQueryInfo, SArray* pList, SSqlCmd* pCmd pSchema = tscGetTableColumnSchema(pTableMeta, index.columnIndex); } + if (pSchema->type == TSDB_DATA_TYPE_JSON && !pItem->isJsonExp){ + return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg9); + } + if (pSchema->type != TSDB_DATA_TYPE_JSON && pItem->isJsonExp){ + return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg10); + } + int32_t numOfCols = tscGetNumOfColumns(pTableMeta); bool groupTag = (index.columnIndex == TSDB_TBNAME_COLUMN_INDEX || index.columnIndex >= numOfCols); @@ -3832,9 +4008,17 @@ int32_t validateGroupbyNode(SQueryInfo* pQueryInfo, SArray* pList, SSqlCmd* pCmd } SColIndex colIndex = { .colIndex = relIndex, .flag = TSDB_COL_TAG, .colId = pSchema->colId, }; - strncpy(colIndex.name, pSchema->name, tListLen(colIndex.name)); + if(pItem->isJsonExp) { + if(pItem->jsonExp->exprToken.n >= tListLen(colIndex.name)){ + return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg11); + } + tstrncpy(colIndex.name, pItem->jsonExp->exprToken.z, pItem->jsonExp->exprToken.n + 1); + }else{ + tstrncpy(colIndex.name, pSchema->name, tListLen(colIndex.name)); + } + taosArrayPush(pGroupExpr->columnInfo, &colIndex); - + index.columnIndex = relIndex; tscColumnListInsert(pTableMetaInfo->tagColList, index.columnIndex, pTableMeta->id.uid, pSchema); } else { @@ -3844,7 +4028,7 @@ int32_t validateGroupbyNode(SQueryInfo* pQueryInfo, SArray* pList, SSqlCmd* pCmd } tscColumnListInsert(pQueryInfo->colList, index.columnIndex, pTableMeta->id.uid, pSchema); - + SColIndex colIndex = { .colIndex = index.columnIndex, .flag = TSDB_COL_NORMAL, .colId = pSchema->colId }; strncpy(colIndex.name, pSchema->name, tListLen(colIndex.name)); @@ -3863,7 +4047,7 @@ int32_t validateGroupbyNode(SQueryInfo* pQueryInfo, SArray* pList, SSqlCmd* pCmd for(int32_t i = 0; i < num; ++i) { SColIndex* pIndex = taosArrayGet(pGroupExpr->columnInfo, i); if (TSDB_COL_IS_NORMAL_COL(pIndex->flag) && i != num - 1) { - return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg8); + return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg8); } } @@ -4190,8 +4374,17 @@ static int32_t checkAndSetJoinCondInfo(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, tS return checkAndSetJoinCondInfo(pCmd, pQueryInfo, pExpr->pRight); } + tSqlExpr* pLeft = pExpr->pLeft; + tSqlExpr* pRight = pExpr->pRight; + if(pLeft->tokenId == TK_ARROW){ + pLeft = pLeft->pLeft; + } + if(pRight->tokenId == TK_ARROW){ + pRight = pRight->pLeft; + } + SColumnIndex index = COLUMN_INDEX_INITIALIZER; - if (getColumnIndexByName(&pExpr->pLeft->columnName, pQueryInfo, &index, tscGetErrorMsgPayload(pCmd)) != TSDB_CODE_SUCCESS) { + if (getColumnIndexByName(&pLeft->columnName, pQueryInfo, &index, tscGetErrorMsgPayload(pCmd)) != TSDB_CODE_SUCCESS) { return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg4); } @@ -4207,6 +4400,9 @@ static int32_t checkAndSetJoinCondInfo(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, tS (*leftNode)->uid = pTableMetaInfo->pTableMeta->id.uid; (*leftNode)->tagColId = pTagSchema1->colId; + if(pExpr->pLeft->tokenId == TK_ARROW) { + tstrncpy((*leftNode)->tagJsonKeyName, pExpr->pLeft->pRight->value.pz, TSDB_MAX_JSON_KEY_LEN + 1); + } if (UTIL_TABLE_IS_SUPER_TABLE(pTableMetaInfo)) { STableMeta* pTableMeta = pTableMetaInfo->pTableMeta; @@ -4225,7 +4421,7 @@ static int32_t checkAndSetJoinCondInfo(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, tS int16_t leftIdx = index.tableIndex; index = (SColumnIndex)COLUMN_INDEX_INITIALIZER; - if (getColumnIndexByName(&pExpr->pRight->columnName, pQueryInfo, &index, tscGetErrorMsgPayload(pCmd)) != TSDB_CODE_SUCCESS) { + if (getColumnIndexByName(&pRight->columnName, pQueryInfo, &index, tscGetErrorMsgPayload(pCmd)) != TSDB_CODE_SUCCESS) { return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg4); } @@ -4241,6 +4437,9 @@ static int32_t checkAndSetJoinCondInfo(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, tS (*rightNode)->uid = pTableMetaInfo->pTableMeta->id.uid; (*rightNode)->tagColId = pTagSchema2->colId; + if(pExpr->pRight->tokenId == TK_ARROW) { + tstrncpy((*rightNode)->tagJsonKeyName, pExpr->pRight->pRight->value.pz, TSDB_MAX_JSON_KEY_LEN + 1); + } if (UTIL_TABLE_IS_SUPER_TABLE(pTableMetaInfo)) { STableMeta* pTableMeta = pTableMetaInfo->pTableMeta; @@ -4288,47 +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; + } + } - 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); @@ -4337,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; } @@ -4369,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; } @@ -4451,7 +4737,7 @@ static void exchangeExpr(tSqlExpr* pExpr) { tSqlExpr* pLeft = pExpr->pLeft; tSqlExpr* pRight = pExpr->pRight; - if (pRight->tokenId == TK_ID && (pLeft->tokenId == TK_INTEGER || pLeft->tokenId == TK_FLOAT || + if ((pRight->tokenId == TK_ID || pRight->tokenId == TK_ARROW) && (pLeft->tokenId == TK_INTEGER || pLeft->tokenId == TK_FLOAT || pLeft->tokenId == TK_STRING || pLeft->tokenId == TK_BOOL)) { /* * exchange value of the left handside and the value of the right-handside @@ -4488,8 +4774,28 @@ static bool validateJoinExprNode(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, tSqlExpr const char* msg3 = "join column must have same type"; const char* msg4 = "self join is not allowed"; const char* msg5 = "join table must be the same type(table to table, super table to super table)"; + const char* msg6 = "tag json key must be string"; + const char* msg7 = "tag json key in json must be same"; + const char* msg8 = "tag json key is too long, no more than 256 bytes"; tSqlExpr* pRight = pExpr->pRight; + if(pRight->tokenId == TK_ARROW){ + if(!IS_VAR_DATA_TYPE(pExpr->pLeft->pRight->value.nType) || pExpr->pLeft->pRight->value.nType != pExpr->pRight->pRight->value.nType){ + invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg6); + return false; + } + if(pExpr->pLeft->pRight->value.nLen > TSDB_MAX_JSON_KEY_LEN){ + invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg8); + return false; + } + if(pExpr->pLeft->pRight->value.nLen != pExpr->pRight->pRight->value.nLen + || strncmp(pExpr->pLeft->pRight->value.pz, pExpr->pRight->pRight->value.pz, pExpr->pRight->pRight->value.nLen) != 0){ + invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg7); + return false; + } + + pRight = pExpr->pRight->pLeft; + } if (pRight->tokenId != TK_ID) { return true; @@ -4566,13 +4872,13 @@ static int32_t validateNullExpr(tSqlExpr* pExpr, STableMeta* pTableMeta, int32_t const char* msg = "only support is [not] null"; tSqlExpr* pRight = pExpr->pRight; - if (pRight->tokenId == TK_NULL && (!(pExpr->tokenId == TK_ISNULL || pExpr->tokenId == TK_NOTNULL))) { + SSchema* pSchema = tscGetTableSchema(pTableMeta); + if (pRight->tokenId == TK_NULL && pSchema[index].type != TSDB_DATA_TYPE_JSON && (!(pExpr->tokenId == TK_ISNULL || pExpr->tokenId == TK_NOTNULL))) { return invalidOperationMsg(msgBuf, msg); } if (pRight->tokenId == TK_STRING) { - SSchema* pSchema = tscGetTableSchema(pTableMeta); - if (IS_VAR_DATA_TYPE(pSchema[index].type)) { + if (IS_VAR_DATA_TYPE(pSchema[index].type) || pSchema[index].type == TSDB_DATA_TYPE_JSON) { return TSDB_CODE_SUCCESS; } @@ -4610,7 +4916,7 @@ static int32_t validateLikeExpr(tSqlExpr* pExpr, STableMeta* pTableMeta, int32_t } SSchema* pSchema = tscGetTableSchema(pTableMeta); - if ((!isTablenameToken(&pLeft->columnName)) && !IS_VAR_DATA_TYPE(pSchema[index].type)) { + if ((pLeft->tokenId != TK_ARROW) && (!isTablenameToken(&pLeft->columnName)) && !IS_VAR_DATA_TYPE(pSchema[index].type)) { return invalidOperationMsg(msgBuf, msg2); } } @@ -4618,6 +4924,59 @@ static int32_t validateLikeExpr(tSqlExpr* pExpr, STableMeta* pTableMeta, int32_t return TSDB_CODE_SUCCESS; } +// check for match expression +static int32_t validateJsonTagExpr(tSqlExpr* pExpr, char* msgBuf) { + const char* msg1 = "not support json tag column filter"; + const char* msg2 = "tag json key is invalidate"; + const char* msg3 = "tag json key must be string"; + const char* msg4 = "in operation not support in tag json"; + + tSqlExpr* pLeft = pExpr->pLeft; + tSqlExpr* pRight = pExpr->pRight; + + if (pExpr->tokenId == TK_CONTAINS) { + if (pRight != NULL && !IS_VAR_DATA_TYPE(pRight->value.nType)) + return invalidOperationMsg(msgBuf, msg3); + + if (pRight != NULL && (pRight->value.nLen > TSDB_MAX_JSON_KEY_LEN || pRight->value.nLen <= 0)) + return invalidOperationMsg(msgBuf, msg2); + } else if(pExpr->tokenId == TK_IN){ + return invalidOperationMsg(msgBuf, msg4); + } else { + if (pLeft != NULL && pLeft->tokenId == TK_ID && pExpr->tokenId != TK_ISNULL && pExpr->tokenId != TK_NOTNULL) { + return invalidOperationMsg(msgBuf, msg1); + } + + if (pLeft != NULL && pLeft->tokenId == TK_ARROW) { + if (pLeft->pRight && !IS_VAR_DATA_TYPE(pLeft->pRight->value.nType)) + return invalidOperationMsg(msgBuf, msg3); + if (pLeft->pRight && (pLeft->pRight->value.nLen > TSDB_MAX_JSON_KEY_LEN || pLeft->pRight->value.nLen <= 0)) + return invalidOperationMsg(msgBuf, msg2); + } + + if (pRight->value.nType == TSDB_DATA_TYPE_BINARY){ // json value store by nchar, so need to convert from binary to nchar + if(pRight->value.nLen == INT_BYTES && *(uint32_t*)pRight->value.pz == TSDB_DATA_JSON_null){ + return TSDB_CODE_SUCCESS; + } + if(pRight->value.nLen == 0){ + pRight->value.nType = TSDB_DATA_TYPE_NCHAR; + return TSDB_CODE_SUCCESS; + } + char newData[TSDB_MAX_JSON_TAGS_LEN] = {0}; + int len = 0; + if(!taosMbsToUcs4(pRight->value.pz, pRight->value.nLen, newData, TSDB_MAX_JSON_TAGS_LEN, &len)){ + tscError("json where condition mbsToUcs4 error"); + } + pRight->value.pz = realloc(pRight->value.pz, len); + memcpy(pRight->value.pz, newData, len); + pRight->value.nLen = len; + pRight->value.nType = TSDB_DATA_TYPE_NCHAR; + } + } + + return TSDB_CODE_SUCCESS; +} + // check for match expression static int32_t validateMatchExpr(tSqlExpr* pExpr, STableMeta* pTableMeta, int32_t index, char* msgBuf) { const char* msg1 = "regular expression string should be less than %d characters"; @@ -4686,10 +5045,24 @@ static int32_t handleExprInQueryCond(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, tSql tSqlExpr* pLeft = (*pExpr)->pLeft; tSqlExpr* pRight = (*pExpr)->pRight; + SStrToken* colName = NULL; + if(pLeft->tokenId == TK_ARROW){ + colName = &(pLeft->pLeft->columnName); + if (pRight->tokenId == TK_NULL && (*pExpr)->tokenId == TK_EQ) { + // transform for json->'key'=null + pRight->tokenId = TK_STRING; + pRight->value.nType = TSDB_DATA_TYPE_BINARY; + pRight->value.nLen = INT_BYTES; + pRight->value.pz = calloc(INT_BYTES, 1); + *(uint32_t*)pRight->value.pz = TSDB_DATA_JSON_null; + } + }else{ + colName = &(pLeft->columnName); + } int32_t ret = TSDB_CODE_SUCCESS; SColumnIndex index = COLUMN_INDEX_INITIALIZER; - if (getColumnIndexByName(&pLeft->columnName, pQueryInfo, &index, tscGetErrorMsgPayload(pCmd)) != TSDB_CODE_SUCCESS) { + if (getColumnIndexByName(colName, pQueryInfo, &index, tscGetErrorMsgPayload(pCmd)) != TSDB_CODE_SUCCESS) { return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg2); } @@ -4798,7 +5171,15 @@ static int32_t handleExprInQueryCond(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, tSql return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg1); } - if (pRight != NULL && pRight->tokenId == TK_ID) { // join on tag columns for stable query + // check for json tag operation -> and ? + if (pSchema->type == TSDB_DATA_TYPE_JSON){ + code = validateJsonTagExpr(*pExpr, tscGetErrorMsgPayload(pCmd)); + if (code != TSDB_CODE_SUCCESS) { + return code; + } + } + + if (pRight != NULL && (pRight->tokenId == TK_ID || pRight->tokenId == TK_ARROW)) { // join on tag columns for stable query if (!validateJoinExprNode(pCmd, pQueryInfo, *pExpr, &index)) { return TSDB_CODE_TSC_INVALID_OPERATION; } @@ -4814,7 +5195,10 @@ static int32_t handleExprInQueryCond(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, tSql // ret = setExprToCond(pCmd, &pCondExpr->pTagCond, // *pExpr, NULL, parentOptr); tSqlExpr *rexpr = NULL; - if ((*pExpr)->tokenId == TK_NE && (pSchema->type != TSDB_DATA_TYPE_BINARY && pSchema->type != TSDB_DATA_TYPE_NCHAR && pSchema->type != TSDB_DATA_TYPE_BOOL)) { + if ((*pExpr)->tokenId == TK_NE && (pSchema->type != TSDB_DATA_TYPE_BINARY + && pSchema->type != TSDB_DATA_TYPE_NCHAR + && pSchema->type != TSDB_DATA_TYPE_BOOL + && pSchema->type != TSDB_DATA_TYPE_JSON)) { handleNeOptr(&rexpr, *pExpr); *pExpr = rexpr; } @@ -4965,6 +5349,9 @@ static void doExtractExprForSTable(SSqlCmd* pCmd, tSqlExpr** pExpr, SQueryInfo* tSqlExpr* pLeft = (*pExpr)->pLeft; SColumnIndex index = COLUMN_INDEX_INITIALIZER; + if(pLeft->tokenId == TK_ARROW) { + pLeft = pLeft->pLeft; + } if (getColumnIndexByName(&pLeft->columnName, pQueryInfo, &index, tscGetErrorMsgPayload(pCmd)) != TSDB_CODE_SUCCESS) { return; } @@ -5289,7 +5676,7 @@ static int32_t getTagQueryCondExpr(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SCondE SArray* colList = taosArrayInit(10, sizeof(SColIndex)); ret = exprTreeFromSqlExpr(pCmd, &p, p1, pQueryInfo, colList, NULL); //if (ret == TSDB_CODE_SUCCESS) { - // ret = filterInitFromTree(p, &pQueryInfo->tagFilter, (int32_t)taosArrayGetSize(colList)); + // ret = filterInitFromTree(p, &pQueryInfo->tagFilter, (int32_t)taosArrayGetSize(colList), NULL); //} SBufferWriter bw = tbufInitWriter(NULL, false); @@ -5476,7 +5863,8 @@ _ret: -int32_t validateWhereNode(SQueryInfo* pQueryInfo, tSqlExpr** pExpr, SSqlObj* pSql) { +int32_t +validateWhereNode(SQueryInfo* pQueryInfo, tSqlExpr** pExpr, SSqlObj* pSql) { if (pExpr == NULL) { return TSDB_CODE_SUCCESS; } @@ -5883,7 +6271,7 @@ int32_t validateOrderbyNode(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SSqlNode* pSq const char* msg0 = "only one column allowed in orderby"; const char* msg1 = "invalid column name in orderby clause"; const char* msg2 = "too many order by columns"; - const char* msg3 = "only primary timestamp/tbname/first tag in groupby clause allowed"; + const char* msg3 = "only primary timestamp/column in groupby clause allowed as order column"; const char* msg4 = "only tag in groupby clause allowed in order clause"; const char* msg5 = "only primary timestamp/column in top/bottom function allowed as order column"; const char* msg6 = "only primary timestamp allowed as the second order column"; @@ -5893,6 +6281,8 @@ int32_t validateOrderbyNode(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SSqlNode* pSq const char* msg10 = "not support distinct mixed with order by"; const char* msg11 = "not support order with udf"; const char* msg12 = "order by tags not supported with diff/derivative/csum/mavg"; + const char* msg13 = "order by json tag, key is too long"; + const char* msg14 = "order by json tag, must be json->'key'"; setDefaultOrderInfo(pQueryInfo); STableMetaInfo* pTableMetaInfo = tscGetMetaInfo(pQueryInfo, 0); @@ -5929,14 +6319,24 @@ int32_t validateOrderbyNode(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SSqlNode* pSq return invalidOperationMsg(pMsgBuf, msg10); } - // handle the first part of order by - tVariant* pVar = taosArrayGet(pSortOrder, 0); + SStrToken columnName = {0}; + CommonItem* pItem = taosArrayGet(pSortOrder, 0); + if (pItem->isJsonExp){ + assert(pItem->jsonExp->tokenId == TK_ARROW); + columnName = pItem->jsonExp->pLeft->columnName; + }else{ + // handle the first part of order by + tVariant* pVar = &pItem->pVar; - if (pVar->nType != TSDB_DATA_TYPE_BINARY){ - return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg1); + if (pVar->nType != TSDB_DATA_TYPE_BINARY){ + return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg1); + } + + columnName.n = pVar->nLen; + columnName.type = pVar->nType; + columnName.z = pVar->pz; } - SStrToken columnName = {pVar->nLen, pVar->nType, pVar->pz}; SColumnIndex index = COLUMN_INDEX_INITIALIZER; bool udf = false; @@ -5970,7 +6370,21 @@ int32_t validateOrderbyNode(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SSqlNode* pSq } SColIndex* pColIndex = taosArrayGet(pQueryInfo->groupbyExpr.columnInfo, 0); if (relTagIndex == pColIndex->colIndex) { - orderByTags = true; + if (tscGetColumnSchemaById(pTableMetaInfo->pTableMeta, pColIndex->colId)->type == TSDB_DATA_TYPE_JSON){ + if(!pItem->isJsonExp){ + return invalidOperationMsg(pMsgBuf, msg14); + } + if(pItem->jsonExp->exprToken.n >= sizeof(pColIndex->name)){ + return invalidOperationMsg(pMsgBuf, msg13); + } + if(strncmp(pColIndex->name, pItem->jsonExp->exprToken.z, pItem->jsonExp->exprToken.n) == 0){ + orderByTags = true; + }else{ + orderByTags = false; + } + }else{ + orderByTags = true; + } } } else if (index.columnIndex == TSDB_TBNAME_COLUMN_INDEX) { // order by tbname // it is a tag column @@ -6005,10 +6419,10 @@ int32_t validateOrderbyNode(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SSqlNode* pSq } pQueryInfo->groupbyExpr.orderIndex = index.columnIndex - tscGetNumOfColumns(pTableMetaInfo->pTableMeta); - tVariantListItem* p1 = taosArrayGet(pSqlNode->pSortOrder, 0); + CommonItem* p1 = taosArrayGet(pSqlNode->pSortOrder, 0); pQueryInfo->groupbyExpr.orderType = p1->sortOrder; } else if (orderByGroupbyCol) { - tVariantListItem* p1 = taosArrayGet(pSqlNode->pSortOrder, 0); + CommonItem* p1 = taosArrayGet(pSqlNode->pSortOrder, 0); pQueryInfo->groupbyExpr.orderType = p1->sortOrder; pQueryInfo->order.orderColId = pSchema[index.columnIndex].colId; @@ -6029,12 +6443,12 @@ int32_t validateOrderbyNode(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SSqlNode* pSq return invalidOperationMsg(pMsgBuf, msg5); } - tVariantListItem* p1 = taosArrayGet(pSqlNode->pSortOrder, 0); + CommonItem* p1 = taosArrayGet(pSqlNode->pSortOrder, 0); pQueryInfo->order.order = p1->sortOrder; pQueryInfo->order.orderColId = pSchema[index.columnIndex].colId; return TSDB_CODE_SUCCESS; } else { - tVariantListItem* p1 = taosArrayGet(pSqlNode->pSortOrder, 0); + CommonItem* p1 = taosArrayGet(pSqlNode->pSortOrder, 0); if (udf) { return invalidOperationMsg(pMsgBuf, msg11); @@ -6060,7 +6474,7 @@ int32_t validateOrderbyNode(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SSqlNode* pSq } } } else { - tVariantListItem *pItem = taosArrayGet(pSqlNode->pSortOrder, 0); + pItem = taosArrayGet(pSqlNode->pSortOrder, 0); if (orderByTags) { pQueryInfo->groupbyExpr.orderIndex = index.columnIndex - tscGetNumOfColumns(pTableMetaInfo->pTableMeta); pQueryInfo->groupbyExpr.orderType = pItem->sortOrder; @@ -6078,9 +6492,18 @@ int32_t validateOrderbyNode(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SSqlNode* pSq } } + SStrToken cname = {0}; pItem = taosArrayGet(pSqlNode->pSortOrder, 1); - tVariant* pVar2 = &pItem->pVar; - SStrToken cname = {pVar2->nLen, pVar2->nType, pVar2->pz}; + if (pItem->isJsonExp){ + assert(pItem->jsonExp->tokenId == TK_ARROW); + cname = pItem->jsonExp->pLeft->columnName; + }else{ + tVariant* pVar = &pItem->pVar; + + cname.n = pVar->nLen; + cname.type = pVar->nType; + cname.z = pVar->pz; + } if (getColumnIndexByName(&cname, pQueryInfo, &index, tscGetErrorMsgPayload(pCmd)) != TSDB_CODE_SUCCESS) { return invalidOperationMsg(pMsgBuf, msg1); } @@ -6088,8 +6511,7 @@ int32_t validateOrderbyNode(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SSqlNode* pSq if (index.columnIndex != PRIMARYKEY_TIMESTAMP_COL_INDEX) { return invalidOperationMsg(pMsgBuf, msg6); } else { - tVariantListItem* p1 = taosArrayGet(pSortOrder, 1); - pQueryInfo->order.order = p1->sortOrder; + pQueryInfo->order.order = pItem->sortOrder; pQueryInfo->order.orderColId = PRIMARYKEY_TIMESTAMP_COL_INDEX; } } @@ -6119,7 +6541,7 @@ int32_t validateOrderbyNode(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SSqlNode* pSq return invalidOperationMsg(pMsgBuf, msg11); } - tVariantListItem* p1 = taosArrayGet(pSqlNode->pSortOrder, 0); + CommonItem* p1 = taosArrayGet(pSqlNode->pSortOrder, 0); pQueryInfo->groupbyExpr.orderIndex = pSchema[index.columnIndex].colId; pQueryInfo->groupbyExpr.orderType = p1->sortOrder; } @@ -6145,7 +6567,7 @@ int32_t validateOrderbyNode(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SSqlNode* pSq } } - tVariantListItem* pItem = taosArrayGet(pSqlNode->pSortOrder, 0); + pItem = taosArrayGet(pSqlNode->pSortOrder, 0); pQueryInfo->order.order = pItem->sortOrder; pQueryInfo->order.orderColId = pSchema[index.columnIndex].colId; @@ -6156,7 +6578,7 @@ int32_t validateOrderbyNode(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SSqlNode* pSq return invalidOperationMsg(pMsgBuf, msg11); } - tVariantListItem* pItem = taosArrayGet(pSqlNode->pSortOrder, 0); + pItem = taosArrayGet(pSqlNode->pSortOrder, 0); pQueryInfo->order.order = pItem->sortOrder; pQueryInfo->order.orderColId = pSchema[index.columnIndex].colId; } else { @@ -6172,7 +6594,28 @@ int32_t validateOrderbyNode(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SSqlNode* pSq return invalidOperationMsg(pMsgBuf, msg11); } - tVariantListItem* pItem = taosArrayGet(pSqlNode->pSortOrder, 0); + 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; } @@ -6209,6 +6652,8 @@ int32_t setAlterTableInfo(SSqlObj* pSql, struct SSqlInfo* pInfo) { const char* msg23 = "only column length coulbe be modified"; const char* msg24 = "invalid binary/nchar column length"; + const char* msg25 = "json type error, should be string"; + int32_t code = TSDB_CODE_SUCCESS; SSqlCmd* pCmd = &pSql->cmd; @@ -6368,22 +6813,32 @@ int32_t setAlterTableInfo(SSqlObj* pSql, struct SSqlInfo* pInfo) { tVariantListItem* pItem = taosArrayGet(pVarList, 1); SSchema* pTagsSchema = tscGetTableColumnSchema(pTableMetaInfo->pTableMeta, columnIndex.columnIndex); - if (IS_VAR_DATA_TYPE(pTagsSchema->type) && (pItem->pVar.nLen > pTagsSchema->bytes * TSDB_NCHAR_SIZE)) { + if (IS_VAR_DATA_TYPE(pTagsSchema->type) && (pItem->pVar.nLen > pTagsSchema->bytes)) { return invalidOperationMsg(pMsg, msg14); } + SKVRowBuilder kvRowBuilder = {0}; + if (pTagsSchema->type == TSDB_DATA_TYPE_JSON) { + if (pItem->pVar.nType != TSDB_DATA_TYPE_BINARY) { + tscError("json type error, should be string"); + return invalidOperationMsg(pMsg, msg25); + } + if (pItem->pVar.nType > TSDB_MAX_JSON_TAGS_LEN / TSDB_NCHAR_SIZE) { + tscError("json tag too long"); + return invalidOperationMsg(pMsg, msg14); + } - pAlterSQL->tagData.data = calloc(1, pTagsSchema->bytes * TSDB_NCHAR_SIZE + VARSTR_HEADER_SIZE); + if (tdInitKVRowBuilder(&kvRowBuilder) < 0) { + return TSDB_CODE_TSC_OUT_OF_MEMORY; + } - if (tVariantDump(&pItem->pVar, pAlterSQL->tagData.data, pTagsSchema->type, true) != TSDB_CODE_SUCCESS) { - return invalidOperationMsg(pMsg, msg13); - } - - pAlterSQL->tagData.dataLen = pTagsSchema->bytes; + int8_t tagVal = TSDB_DATA_JSON_PLACEHOLDER; + tdAddColToKVRow(&kvRowBuilder, pTagsSchema->colId, pTagsSchema->type, &tagVal, false); - // validate the length of binary - if ((pTagsSchema->type == TSDB_DATA_TYPE_BINARY || pTagsSchema->type == TSDB_DATA_TYPE_NCHAR) && - varDataTLen(pAlterSQL->tagData.data) > pTagsSchema->bytes) { - return invalidOperationMsg(pMsg, msg14); + code = parseJsontoTagData(pItem->pVar.pz, &kvRowBuilder, pMsg, pTagsSchema->colId); + if (code != TSDB_CODE_SUCCESS) { + tdDestroyKVRowBuilder(&kvRowBuilder); + return code; + } } int32_t schemaLen = sizeof(STColumn) * numOfTags; @@ -6419,15 +6874,32 @@ int32_t setAlterTableInfo(SSqlObj* pSql, struct SSqlInfo* pInfo) { d += sizeof(STColumn); } - // copy the tag value to pMsg body - pItem = taosArrayGet(pVarList, 1); - tVariantDump(&pItem->pVar, pUpdateMsg->data + schemaLen, pTagsSchema->type, true); - + if (pTagsSchema->type == TSDB_DATA_TYPE_JSON){ + SKVRow row = tdGetKVRowFromBuilder(&kvRowBuilder); + tdDestroyKVRowBuilder(&kvRowBuilder); + if (row == NULL) { + return TSDB_CODE_TSC_OUT_OF_MEMORY; + } + tdSortKVRowByColIdx(row); + + kvRowCpy(pUpdateMsg->data + schemaLen, row); + free(row); + }else{ + // copy the tag value to pMsg body + if (tVariantDump(&pItem->pVar, pUpdateMsg->data + schemaLen, pTagsSchema->type, true) + != TSDB_CODE_SUCCESS){ + return invalidOperationMsg(pMsg, msg13); + } + } + int32_t len = 0; - if (pTagsSchema->type != TSDB_DATA_TYPE_BINARY && pTagsSchema->type != TSDB_DATA_TYPE_NCHAR) { + if(pTagsSchema->type == TSDB_DATA_TYPE_JSON){ + len = kvRowLen(pUpdateMsg->data + schemaLen); + }else if (!IS_VAR_DATA_TYPE(pTagsSchema->type)) { len = tDataTypes[pTagsSchema->type].bytes; } else { len = varDataTLen(pUpdateMsg->data + schemaLen); + if(len > pTagsSchema->bytes) return invalidOperationMsg(pMsg, msg14); } pUpdateMsg->tagValLen = htonl(len); // length may be changed after dump data @@ -6633,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); } @@ -6661,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; @@ -6679,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; @@ -7210,12 +7689,18 @@ static int32_t doUpdateSqlFunctionForColPrj(SQueryInfo* pQueryInfo) { return TSDB_CODE_SUCCESS; } -static bool tagColumnInGroupby(SGroupbyExpr* pGroupbyExpr, int16_t columnId) { +static bool tagColumnInGroupby(SGroupbyExpr* pGroupbyExpr, int16_t columnId, int16_t type, char* name) { for (int32_t j = 0; j < pGroupbyExpr->numOfGroupCols; ++j) { SColIndex* pColIndex = taosArrayGet(pGroupbyExpr->columnInfo, j); - - if (columnId == pColIndex->colId && TSDB_COL_IS_TAG(pColIndex->flag )) { - return true; + + if (type == TSDB_DATA_TYPE_JSON && name != NULL){ + if (columnId == pColIndex->colId && strncmp(pColIndex->name, name, tListLen(pColIndex->name)) == 0 && TSDB_COL_IS_TAG(pColIndex->flag )) { + return true; + } + }else{ + if (columnId == pColIndex->colId && TSDB_COL_IS_TAG(pColIndex->flag )) { + return true; + } } } @@ -7229,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; @@ -7250,7 +7736,7 @@ static bool allTagPrjInGroupby(SQueryInfo* pQueryInfo) { continue; } - if (!tagColumnInGroupby(&pQueryInfo->groupbyExpr, pExpr->base.colInfo.colId)) { + if (!tagColumnInGroupby(&pQueryInfo->groupbyExpr, pExpr->base.colInfo.colId, pExpr->base.resType, pExpr->base.param[0].pz)) { allInGroupby = false; break; } @@ -7301,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; } @@ -7314,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++; } @@ -7348,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; } @@ -7393,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); } @@ -7427,16 +7920,23 @@ static int32_t doAddGroupbyColumnsOnDemand(SSqlCmd* pCmd, SQueryInfo* pQueryInfo SColumnIndex index = {.tableIndex = pQueryInfo->groupbyExpr.tableIndex, .columnIndex = colIndex}; SExprInfo* pExpr = tscExprInsert(pQueryInfo, pos, f, &index, s->type, s->bytes, getNewResColId(pCmd), s->bytes, true); - - memset(pExpr->base.aliasName, 0, sizeof(pExpr->base.aliasName)); - tstrncpy(pExpr->base.aliasName, s->name, sizeof(pExpr->base.aliasName)); - tstrncpy(pExpr->base.token, s->name, sizeof(pExpr->base.aliasName)); - - pExpr->base.colInfo.flag = TSDB_COL_TAG; - // NOTE: tag column does not add to source column list SColumnList ids = createColumnList(1, 0, pColIndex->colIndex); - insertResultField(pQueryInfo, pos, &ids, s->bytes, (int8_t)s->type, s->name, pExpr); + insertResultField(pQueryInfo, pos, &ids, s->bytes, (int8_t)s->type, pColIndex->name, pExpr); + pExpr->base.colInfo.flag = TSDB_COL_TAG; + memset(pExpr->base.aliasName, 0, sizeof(pExpr->base.aliasName)); + tstrncpy(pExpr->base.aliasName, pColIndex->name, sizeof(pExpr->base.aliasName)); + tstrncpy(pExpr->base.token, pColIndex->name, sizeof(pExpr->base.token)); + if(s->type == TSDB_DATA_TYPE_JSON){ + SStrToken t0 = {.z = pColIndex->name}; + getJsonKey(&t0); + tVariantCreateFromBinary(&(pExpr->base.param[pExpr->base.numOfParams]), t0.z, + t0.n, TSDB_DATA_TYPE_BINARY); + pExpr->base.numOfParams++; + assert(t0.n < strlen(pColIndex->name)); + memmove(pColIndex->name, t0.z, t0.n); + pColIndex->name[t0.n] = '\0'; + } } else { // if this query is "group by" normal column, time window query is not allowed if (isTimeWindowQuery(pQueryInfo)) { @@ -7555,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) { @@ -7575,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); @@ -7867,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 = @@ -7951,6 +8455,7 @@ int32_t doCheckForCreateFromStable(SSqlObj* pSql, SSqlInfo* pInfo) { const char* msg4 = "illegal value or data overflow"; const char* msg5 = "tags number not matched"; const char* msg6 = "create table only from super table is allowed"; + const char* msg7 = "json type error, should be string"; SSqlCmd* pCmd = &pSql->cmd; @@ -8075,7 +8580,6 @@ int32_t doCheckForCreateFromStable(SSqlObj* pSql, SSqlInfo* pInfo) { pItem->pVar.i64 = convertTimePrecision(pItem->pVar.i64, TSDB_TIME_PRECISION_NANO, tinfo.precision); } } - ret = tVariantDump(&(pItem->pVar), tagVal, pSchema->type, true); // check again after the convert since it may be converted from binary to nchar. @@ -8092,7 +8596,7 @@ int32_t doCheckForCreateFromStable(SSqlObj* pSql, SSqlInfo* pInfo) { return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg4); } - tdAddColToKVRow(&kvRowBuilder, pSchema->colId, pSchema->type, tagVal); + tdAddColToKVRow(&kvRowBuilder, pSchema->colId, pSchema->type, tagVal, false); findColumnIndex = true; break; @@ -8114,7 +8618,7 @@ int32_t doCheckForCreateFromStable(SSqlObj* pSql, SSqlInfo* pInfo) { SSchema* pSchema = &pTagSchema[i]; tVariantListItem* pItem = taosArrayGet(pValList, i); - char tagVal[TSDB_MAX_TAGS_LEN]; + char tagVal[TSDB_MAX_TAGS_LEN] = {0}; if (pSchema->type == TSDB_DATA_TYPE_BINARY || pSchema->type == TSDB_DATA_TYPE_NCHAR) { if (pItem->pVar.nLen > pSchema->bytes) { tdDestroyKVRowBuilder(&kvRowBuilder); @@ -8130,8 +8634,6 @@ int32_t doCheckForCreateFromStable(SSqlObj* pSql, SSqlInfo* pInfo) { pItem->pVar.i64 = convertTimePrecision(pItem->pVar.i64, TSDB_TIME_PRECISION_NANO, tinfo.precision); } } - - ret = tVariantDump(&(pItem->pVar), tagVal, pSchema->type, true); // check again after the convert since it may be converted from binary to nchar. @@ -8148,7 +8650,31 @@ int32_t doCheckForCreateFromStable(SSqlObj* pSql, SSqlInfo* pInfo) { return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg4); } - tdAddColToKVRow(&kvRowBuilder, pSchema->colId, pSchema->type, tagVal); + tdAddColToKVRow(&kvRowBuilder, pSchema->colId, pSchema->type, tagVal, false); + } + } + + // encode json tag string + if(schemaSize == 1 && pTagSchema[0].type == TSDB_DATA_TYPE_JSON){ + if (valSize != schemaSize) { + tdDestroyKVRowBuilder(&kvRowBuilder); + return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg5); + } + tVariantListItem* pItem = taosArrayGet(pValList, 0); + if(pItem->pVar.nType != TSDB_DATA_TYPE_BINARY){ + tscError("json type error, should be string"); + tdDestroyKVRowBuilder(&kvRowBuilder); + return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg7); + } + if(pItem->pVar.nLen > TSDB_MAX_JSON_TAGS_LEN/TSDB_NCHAR_SIZE){ + tscError("json tag too long"); + tdDestroyKVRowBuilder(&kvRowBuilder); + return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg3); + } + ret = parseJsontoTagData(pItem->pVar.pz, &kvRowBuilder, tscGetErrorMsgPayload(pCmd), pTagSchema[0].colId); + if (ret != TSDB_CODE_SUCCESS) { + tdDestroyKVRowBuilder(&kvRowBuilder); + return ret; } } @@ -9489,34 +10015,12 @@ 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; + } int32_t ret = TSDB_CODE_SUCCESS; *pExpr = calloc(1, sizeof(tExprNode)); (*pExpr)->nodeType = TSQL_NODE_VALUE; @@ -9529,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) { @@ -9538,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; @@ -9571,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) { @@ -9633,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 @@ -9664,13 +10175,60 @@ int32_t exprTreeFromSqlExpr(SSqlCmd* pCmd, tExprNode **pExpr, const tSqlExpr* pS // NOTE: binary|nchar data allows the >|< type filter if ((*pExpr)->_node.optr != TSDB_RELATION_EQUAL && (*pExpr)->_node.optr != TSDB_RELATION_NOT_EQUAL) { if (pRight != NULL && pRight->nodeType == TSQL_NODE_VALUE) { - if (pRight->pVal->nType == TSDB_DATA_TYPE_BOOL && pLeft->pSchema->type == TSDB_DATA_TYPE_BOOL) { + if (pLeft->_node.optr == TSDB_RELATION_ARROW){ + pLeft = pLeft->_node.pLeft; + } + if (pRight->pVal->nType == TSDB_DATA_TYPE_BOOL && (pLeft->pSchema->type == TSDB_DATA_TYPE_BOOL || pLeft->pSchema->type == TSDB_DATA_TYPE_JSON)) { return TSDB_CODE_TSC_INVALID_OPERATION; } } } + + } 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; } @@ -9718,5 +10276,3 @@ void normalizeSqlNode(SSqlNode* pSqlNode, const char* dbName) { } #endif - - diff --git a/src/client/src/tscServer.c b/src/client/src/tscServer.c index 896b5361435d78de1551d5bc9e0da61a19fd2e55..35582973c2af7b214d3054807d31a897c7256191 100644 --- a/src/client/src/tscServer.c +++ b/src/client/src/tscServer.c @@ -832,7 +832,7 @@ static int32_t serializeSqlExpr(SSqlExpr* pExpr, STableMetaInfo* pTableMetaInfo, return TSDB_CODE_TSC_INVALID_TABLE_NAME; } - if (validateColumn && !tscValidateColumnId(pTableMetaInfo, pExpr->colInfo.colId, pExpr->numOfParams)) { + if (validateColumn && !tscValidateColumnId(pTableMetaInfo, pExpr->colInfo.colId)) { tscError("0x%"PRIx64" table schema is not matched with parsed sql", id); return TSDB_CODE_TSC_INVALID_OPERATION; } @@ -1510,7 +1510,8 @@ int tscEstimateCreateTableMsgLength(SSqlObj *pSql, SSqlInfo *pInfo) { SCreateTableSql *pCreateTableInfo = pInfo->pCreateTableInfo; if (pCreateTableInfo->type == TSQL_CREATE_TABLE_FROM_STABLE) { int32_t numOfTables = (int32_t)taosArrayGetSize(pInfo->pCreateTableInfo->childTableInfo); - size += numOfTables * (sizeof(SCreateTableMsg) + TSDB_MAX_TAGS_LEN); + size += numOfTables * (sizeof(SCreateTableMsg) + + ((TSDB_MAX_TAGS_LEN > TSDB_MAX_JSON_TAGS_LEN)?TSDB_MAX_TAGS_LEN:TSDB_MAX_JSON_TAGS_LEN)); } else { size += sizeof(SSchema) * (pCmd->numOfCols + pCmd->count); } @@ -1632,9 +1633,6 @@ int tscEstimateAlterTableMsgLength(SSqlCmd *pCmd) { } int tscBuildAlterTableMsg(SSqlObj *pSql, SSqlInfo *pInfo) { - char *pMsg; - int msgLen = 0; - SSqlCmd *pCmd = &pSql->cmd; SQueryInfo *pQueryInfo = tscGetQueryInfo(pCmd); @@ -1663,14 +1661,7 @@ int tscBuildAlterTableMsg(SSqlObj *pSql, SSqlInfo *pInfo) { pSchema++; } - pMsg = (char *)pSchema; - pAlterTableMsg->tagValLen = htonl(pAlterInfo->tagData.dataLen); - if (pAlterInfo->tagData.dataLen > 0) { - memcpy(pMsg, pAlterInfo->tagData.data, pAlterInfo->tagData.dataLen); - } - pMsg += pAlterInfo->tagData.dataLen; - - msgLen = (int32_t)(pMsg - (char*)pAlterTableMsg); + int msgLen = sizeof(SAlterTableMsg) + sizeof(SSchema) * tscNumOfFields(pQueryInfo); pCmd->payloadLen = msgLen; pCmd->msgType = TSDB_MSG_TYPE_CM_ALTER_TABLE; @@ -1872,7 +1863,9 @@ int tscProcessRetrieveGlobalMergeRsp(SSqlObj *pSql) { uint64_t localQueryId = pSql->self; qTableQuery(pQueryInfo->pQInfo, &localQueryId); - convertQueryResult(pRes, pQueryInfo, pSql->self, true); + bool convertJson = true; + if (pQueryInfo->isStddev == true) convertJson = false; + convertQueryResult(pRes, pQueryInfo, pSql->self, true, convertJson); code = pRes->code; if (pRes->code == TSDB_CODE_SUCCESS) { diff --git a/src/client/src/tscSql.c b/src/client/src/tscSql.c index 6abdab4880f837c505eeba10b0dd9af6c1b86974..d27fa15bf13b0f7ca15e4cb92b447f8d51b842ef 100644 --- a/src/client/src/tscSql.c +++ b/src/client/src/tscSql.c @@ -445,7 +445,7 @@ TAOS_FIELD *taos_fetch_fields(TAOS_RES *res) { // revise the length for binary and nchar fields if (f[j].type == TSDB_DATA_TYPE_BINARY) { f[j].bytes -= VARSTR_HEADER_SIZE; - } else if (f[j].type == TSDB_DATA_TYPE_NCHAR) { + } else if (f[j].type == TSDB_DATA_TYPE_NCHAR || f[j].type == TSDB_DATA_TYPE_JSON) { f[j].bytes = (f[j].bytes - VARSTR_HEADER_SIZE)/TSDB_NCHAR_SIZE; } diff --git a/src/client/src/tscSubquery.c b/src/client/src/tscSubquery.c index 3014b874feb58da4ba9e40e835d85a833048d6a6..5f8964bb34b5939ab768877cb8ae701e20443f75 100644 --- a/src/client/src/tscSubquery.c +++ b/src/client/src/tscSubquery.c @@ -227,6 +227,7 @@ static int64_t doTSBlockIntersect(SSqlObj* pSql, STimeWindow * win) { if (skipped) { slot = 0; stackidx = 0; + tVariantDestroy(&tag); continue; } @@ -334,6 +335,7 @@ static int64_t doTSBlockIntersect(SSqlObj* pSql, STimeWindow * win) { } if (mergeDone) { + tVariantDestroy(&tag); break; } @@ -341,6 +343,7 @@ static int64_t doTSBlockIntersect(SSqlObj* pSql, STimeWindow * win) { stackidx = 0; skipRemainValue(mainCtx->p->pTSBuf, &tag); + tVariantDestroy(&tag); } stackidx = 0; @@ -633,16 +636,21 @@ static int32_t tscLaunchRealSubqueries(SSqlObj* pSql) { // set the join condition tag column info, todo extract method if (UTIL_TABLE_IS_SUPER_TABLE(pTableMetaInfo)) { assert(pQueryInfo->tagCond.joinInfo.hasJoin); + pExpr->base.numOfParams = 0; // the value is 0 by default. just make sure. + // add json tag key, if there is no json tag key, just hold place. + tVariantCreateFromBinary(&(pExpr->base.param[pExpr->base.numOfParams]), pQueryInfo->tagCond.joinInfo.joinTables[0]->tagJsonKeyName, + strlen(pQueryInfo->tagCond.joinInfo.joinTables[0]->tagJsonKeyName), TSDB_DATA_TYPE_BINARY); + pExpr->base.numOfParams++; int16_t colId = tscGetJoinTagColIdByUid(&pQueryInfo->tagCond, pTableMetaInfo->pTableMeta->id.uid); // set the tag column id for executor to extract correct tag value - tVariant* pVariant = &pExpr->base.param[0]; + tVariant* pVariant = &pExpr->base.param[pExpr->base.numOfParams]; pVariant->i64 = colId; pVariant->nType = TSDB_DATA_TYPE_BIGINT; pVariant->nLen = sizeof(int64_t); - pExpr->base.numOfParams = 1; + pExpr->base.numOfParams++; } if (UTIL_TABLE_IS_SUPER_TABLE(pTableMetaInfo)) { @@ -729,8 +737,15 @@ int32_t tagValCompar(const void* p1, const void* p2) { const STidTags* t1 = (const STidTags*) varDataVal(p1); const STidTags* t2 = (const STidTags*) varDataVal(p2); - __compar_fn_t func = getComparFunc(t1->padding, 0); + if (t1->padding == TSDB_DATA_TYPE_JSON){ + bool canReturn = true; + int32_t result = jsonCompareUnit(t1->tag, t2->tag, &canReturn); + if(canReturn) return result; + __compar_fn_t func = getComparFunc(t1->tag[0], 0); + return func(t1->tag + CHAR_BYTES, t2->tag + CHAR_BYTES); + } + __compar_fn_t func = getComparFunc(t1->padding, 0); return func(t1->tag, t2->tag); } @@ -821,16 +836,21 @@ static void issueTsCompQuery(SSqlObj* pSql, SJoinSupporter* pSupporter, SSqlObj* SSchema colSchema = {.type = TSDB_DATA_TYPE_BINARY, .bytes = 1}; SColumnIndex index = {0, PRIMARYKEY_TIMESTAMP_COL_INDEX}; - tscAddFuncInSelectClause(pQueryInfo, 0, TSDB_FUNC_TS_COMP, &index, &colSchema, TSDB_COL_NORMAL, getNewResColId(pCmd)); + SExprInfo *pExpr = tscAddFuncInSelectClause(pQueryInfo, 0, TSDB_FUNC_TS_COMP, &index, &colSchema, TSDB_COL_NORMAL, getNewResColId(pCmd)); // set the tags value for ts_comp function if (UTIL_TABLE_IS_SUPER_TABLE(pTableMetaInfo)) { - SExprInfo *pExpr = tscExprGet(pQueryInfo, 0); - int16_t tagColId = tscGetJoinTagColIdByUid(&pSupporter->tagCond, pTableMetaInfo->pTableMeta->id.uid); - pExpr->base.param[0].i64 = tagColId; - pExpr->base.param[0].nLen = sizeof(int64_t); - pExpr->base.param[0].nType = TSDB_DATA_TYPE_BIGINT; - pExpr->base.numOfParams = 1; + pExpr->base.numOfParams = 0; // the value is 0 by default. just make sure. + // add json tag key, if there is no json tag key, just hold place. + tVariantCreateFromBinary(&(pExpr->base.param[pExpr->base.numOfParams]), pSupporter->tagCond.joinInfo.joinTables[0]->tagJsonKeyName, + strlen(pSupporter->tagCond.joinInfo.joinTables[0]->tagJsonKeyName), TSDB_DATA_TYPE_BINARY); + pExpr->base.numOfParams++; + + int16_t tagColId = tscGetJoinTagColIdByUid(&pSupporter->tagCond, pTableMetaInfo->pTableMeta->id.uid); + pExpr->base.param[pExpr->base.numOfParams].i64 = tagColId; + pExpr->base.param[pExpr->base.numOfParams].nLen = sizeof(int64_t); + pExpr->base.param[pExpr->base.numOfParams].nType = TSDB_DATA_TYPE_BIGINT; + pExpr->base.numOfParams++; } // add the filter tag column @@ -2012,7 +2032,12 @@ int32_t tscCreateJoinSubquery(SSqlObj *pSql, int16_t tableIndex, SJoinSupporter // set get tags query type TSDB_QUERY_SET_TYPE(pNewQueryInfo->type, TSDB_QUERY_TYPE_TAG_FILTER_QUERY); - tscAddFuncInSelectClause(pNewQueryInfo, 0, TSDB_FUNC_TID_TAG, &colIndex, &s1, TSDB_COL_TAG, getNewResColId(pCmd)); + SExprInfo* pExpr = tscAddFuncInSelectClause(pNewQueryInfo, 0, TSDB_FUNC_TID_TAG, &colIndex, &s1, TSDB_COL_TAG, getNewResColId(pCmd)); + if(strlen(pTagCond->joinInfo.joinTables[0]->tagJsonKeyName) > 0){ + tVariantCreateFromBinary(&(pExpr->base.param[pExpr->base.numOfParams]), pTagCond->joinInfo.joinTables[0]->tagJsonKeyName, + strlen(pTagCond->joinInfo.joinTables[0]->tagJsonKeyName), TSDB_DATA_TYPE_BINARY); + pExpr->base.numOfParams++; + } size_t numOfCols = taosArrayGetSize(pNewQueryInfo->colList); tscDebug( @@ -2025,15 +2050,6 @@ int32_t tscCreateJoinSubquery(SSqlObj *pSql, int16_t tableIndex, SJoinSupporter SColumnIndex colIndex = {0, PRIMARYKEY_TIMESTAMP_COL_INDEX}; tscAddFuncInSelectClause(pNewQueryInfo, 0, TSDB_FUNC_TS_COMP, &colIndex, &colSchema, TSDB_COL_NORMAL, getNewResColId(pCmd)); - // set the tags value for ts_comp function - SExprInfo *pExpr = tscExprGet(pNewQueryInfo, 0); - - if (UTIL_TABLE_IS_SUPER_TABLE(pTableMetaInfo)) { - int16_t tagColId = tscGetJoinTagColIdByUid(&pSupporter->tagCond, pTableMetaInfo->pTableMeta->id.uid); - pExpr->base.param->i64 = tagColId; - pExpr->base.numOfParams = 1; - } - // add the filter tag column if (pSupporter->colList != NULL) { size_t s = taosArrayGetSize(pSupporter->colList); @@ -2427,6 +2443,7 @@ int32_t tscHandleFirstRoundStableQuery(SSqlObj *pSql) { STableMetaInfo* pTableMetaInfo = tscGetMetaInfo(pNewQueryInfo, 0); tscInitQueryInfo(pNewQueryInfo); + pNewQueryInfo->isStddev = true; // for json tag // add the group cond pNewQueryInfo->groupbyExpr = pQueryInfo->groupbyExpr; @@ -2490,6 +2507,10 @@ int32_t tscHandleFirstRoundStableQuery(SSqlObj *pSql) { } SExprInfo* p = tscAddFuncInSelectClause(pNewQueryInfo, index++, TSDB_FUNC_TAG, &colIndex, schema, TSDB_COL_TAG, getNewResColId(pCmd)); + if (schema->type == TSDB_DATA_TYPE_JSON){ + p->base.numOfParams = pExpr->base.numOfParams; + tVariantAssign(&p->base.param[0], &pExpr->base.param[0]); + } p->base.resColId = pExpr->base.resColId; } else if (pExpr->base.functionId == TSDB_FUNC_PRJ) { int32_t num = (int32_t) taosArrayGetSize(pNewQueryInfo->groupbyExpr.columnInfo); @@ -3600,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); @@ -3639,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; @@ -3681,7 +3702,9 @@ TAOS_ROW doSetResultRowData(SSqlObj *pSql) { int32_t type = pInfo->field.type; int32_t bytes = pInfo->field.bytes; - if (type != TSDB_DATA_TYPE_BINARY && type != TSDB_DATA_TYPE_NCHAR) { + if (pQueryInfo->isStddev && type == TSDB_DATA_TYPE_JSON){ // for json tag compare in the second round of stddev + pRes->tsrow[j] = pRes->urow[i]; + }else if (!IS_VAR_DATA_TYPE(type) && type != TSDB_DATA_TYPE_JSON) { pRes->tsrow[j] = isNull(pRes->urow[i], type) ? NULL : pRes->urow[i]; } else { pRes->tsrow[j] = isNull(pRes->urow[i], type) ? NULL : varDataVal(pRes->urow[i]); diff --git a/src/client/src/tscUtil.c b/src/client/src/tscUtil.c index e6c4e12e34cee28b0402fe3104d298a4080e6e1c..e2263f696a885e885091e86c6b1210bc817996c2 100644 --- a/src/client/src/tscUtil.c +++ b/src/client/src/tscUtil.c @@ -29,6 +29,7 @@ #include "tsclient.h" #include "ttimer.h" #include "ttokendef.h" +#include "cJSON.h" #ifdef HTTP_EMBEDDED #include "httpInt.h" @@ -109,6 +110,7 @@ int32_t converToStr(char *str, int type, void *buf, int32_t bufSize, int32_t *le n = bufSize + escapeSize; break; case TSDB_DATA_TYPE_NCHAR: + case TSDB_DATA_TYPE_JSON: if (bufSize < 0) { tscError("invalid buf size"); return TSDB_CODE_TSC_INVALID_VALUE; @@ -285,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; } } @@ -328,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; } } @@ -678,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; } @@ -732,34 +736,33 @@ int32_t tscCreateResPointerInfo(SSqlRes* pRes, SQueryInfo* pQueryInfo) { return TSDB_CODE_SUCCESS; } -static void setResRawPtrImpl(SSqlRes* pRes, SInternalField* pInfo, int32_t i, bool convertNchar) { +static void setResRawPtrImpl(SSqlRes* pRes, SInternalField* pInfo, int32_t i, bool convertNchar, bool convertJson) { // generated the user-defined column result if (pInfo->pExpr->pExpr == NULL && TSDB_COL_IS_UD_COL(pInfo->pExpr->base.colInfo.flag)) { - if (pInfo->pExpr->base.param[1].nType == TSDB_DATA_TYPE_NULL) { + if (pInfo->pExpr->base.param[0].nType == TSDB_DATA_TYPE_NULL) { setNullN(pRes->urow[i], pInfo->field.type, pInfo->field.bytes, (int32_t) pRes->numOfRows); } else { if (pInfo->field.type == TSDB_DATA_TYPE_NCHAR || pInfo->field.type == TSDB_DATA_TYPE_BINARY) { - assert(pInfo->pExpr->base.param[1].nLen <= pInfo->field.bytes); + assert(pInfo->pExpr->base.param[0].nLen <= pInfo->field.bytes); for (int32_t k = 0; k < pRes->numOfRows; ++k) { char* p = ((char**)pRes->urow)[i] + k * pInfo->field.bytes; - memcpy(varDataVal(p), pInfo->pExpr->base.param[1].pz, pInfo->pExpr->base.param[1].nLen); - varDataSetLen(p, pInfo->pExpr->base.param[1].nLen); + memcpy(varDataVal(p), pInfo->pExpr->base.param[0].pz, pInfo->pExpr->base.param[0].nLen); + varDataSetLen(p, pInfo->pExpr->base.param[0].nLen); } } else { for (int32_t k = 0; k < pRes->numOfRows; ++k) { char* p = ((char**)pRes->urow)[i] + k * pInfo->field.bytes; - memcpy(p, &pInfo->pExpr->base.param[1].i64, pInfo->field.bytes); + memcpy(p, &pInfo->pExpr->base.param[0].i64, pInfo->field.bytes); } } } - } else if (convertNchar && pInfo->field.type == TSDB_DATA_TYPE_NCHAR) { + } else if (convertNchar && (pInfo->field.type == TSDB_DATA_TYPE_NCHAR)) { // convert unicode to native code in a temporary buffer extra one byte for terminated symbol char* buffer = realloc(pRes->buffer[i], pInfo->field.bytes * pRes->numOfRows); - if(buffer == NULL) - return ; + if (buffer == NULL) return; pRes->buffer[i] = buffer; // string terminated char for binary data memset(pRes->buffer[i], 0, pInfo->field.bytes * pRes->numOfRows); @@ -783,8 +786,63 @@ static void setResRawPtrImpl(SSqlRes* pRes, SInternalField* pInfo, int32_t i, bo p += pInfo->field.bytes; } - memcpy(pRes->urow[i], pRes->buffer[i], pInfo->field.bytes * pRes->numOfRows); + }else if (pInfo->field.type == TSDB_DATA_TYPE_JSON) { + if (convertJson){ + // convert unicode to native code in a temporary buffer extra one byte for terminated symbol + char* buffer = realloc(pRes->buffer[i], pInfo->field.bytes * pRes->numOfRows); + if (buffer == NULL) return; + pRes->buffer[i] = buffer; + // string terminated char for binary data + memset(pRes->buffer[i], 0, pInfo->field.bytes * pRes->numOfRows); + + char* p = pRes->urow[i]; + for (int32_t k = 0; k < pRes->numOfRows; ++k) { + char* dst = pRes->buffer[i] + k * pInfo->field.bytes; + char type = *p; + char* realData = p + CHAR_BYTES; + if (type == TSDB_DATA_TYPE_JSON && isNull(realData, TSDB_DATA_TYPE_JSON)) { + memcpy(dst, realData, varDataTLen(realData)); + } else if (type == TSDB_DATA_TYPE_BINARY) { + assert(*(uint32_t*)varDataVal(realData) == TSDB_DATA_JSON_null); // json null value + assert(varDataLen(realData) == INT_BYTES); + sprintf(varDataVal(dst), "%s", "null"); + varDataSetLen(dst, strlen(varDataVal(dst))); + }else if (type == TSDB_DATA_TYPE_JSON) { + int32_t length = taosUcs4ToMbs(varDataVal(realData), varDataLen(realData), varDataVal(dst)); + varDataSetLen(dst, length); + if (length == 0) { + tscError("charset:%s to %s. val:%s convert failed.", DEFAULT_UNICODE_ENCODEC, tsCharset, (char*)p); + } + }else if (type == TSDB_DATA_TYPE_NCHAR) { // value -> "value" + *(char*)varDataVal(dst) = '\"'; + int32_t length = taosUcs4ToMbs(varDataVal(realData), varDataLen(realData), POINTER_SHIFT(varDataVal(dst), CHAR_BYTES)); + *(char*)(POINTER_SHIFT(varDataVal(dst), length + CHAR_BYTES)) = '\"'; + varDataSetLen(dst, length + CHAR_BYTES*2); + if (length == 0) { + tscError("charset:%s to %s. val:%s convert failed.", DEFAULT_UNICODE_ENCODEC, tsCharset, (char*)p); + } + }else if (type == TSDB_DATA_TYPE_DOUBLE) { + double jsonVd = *(double*)(realData); + sprintf(varDataVal(dst), "%.9lf", jsonVd); + varDataSetLen(dst, strlen(varDataVal(dst))); + }else if (type == TSDB_DATA_TYPE_BIGINT) { + int64_t jsonVd = *(int64_t*)(realData); + sprintf(varDataVal(dst), "%" PRId64, jsonVd); + varDataSetLen(dst, strlen(varDataVal(dst))); + }else if (type == TSDB_DATA_TYPE_BOOL) { + sprintf(varDataVal(dst), "%s", (*((char *)realData) == 1) ? "true" : "false"); + varDataSetLen(dst, strlen(varDataVal(dst))); + }else { + assert(0); + } + + p += pInfo->field.bytes; + } + memcpy(pRes->urow[i], pRes->buffer[i], pInfo->field.bytes * pRes->numOfRows); + }else{ + // if convertJson is false, json data as raw data used for stddev for the second round + } } if (convertNchar) { @@ -792,6 +850,10 @@ static void setResRawPtrImpl(SSqlRes* pRes, SInternalField* pInfo, int32_t i, bo } } +void tscJson2String(char *src, char* dst){ + +} + void tscSetResRawPtr(SSqlRes* pRes, SQueryInfo* pQueryInfo, bool converted) { assert(pRes->numOfCols > 0); if (pRes->numOfRows == 0) { @@ -805,11 +867,11 @@ void tscSetResRawPtr(SSqlRes* pRes, SQueryInfo* pQueryInfo, bool converted) { pRes->length[i] = pInfo->field.bytes; offset += pInfo->field.bytes; - setResRawPtrImpl(pRes, pInfo, i, converted ? false : true); + setResRawPtrImpl(pRes, pInfo, i, converted ? false : true, true); } } -void tscSetResRawPtrRv(SSqlRes* pRes, SQueryInfo* pQueryInfo, SSDataBlock* pBlock, bool convertNchar) { +void tscSetResRawPtrRv(SSqlRes* pRes, SQueryInfo* pQueryInfo, SSDataBlock* pBlock, bool convertNchar, bool convertJson) { assert(pRes->numOfCols > 0); for (int32_t i = 0; i < pQueryInfo->fieldsInfo.numOfOutput; ++i) { @@ -820,7 +882,7 @@ void tscSetResRawPtrRv(SSqlRes* pRes, SQueryInfo* pQueryInfo, SSDataBlock* pBloc pRes->urow[i] = pColData->pData; pRes->length[i] = pInfo->field.bytes; - setResRawPtrImpl(pRes, pInfo, i, convertNchar); + setResRawPtrImpl(pRes, pInfo, i, convertNchar, convertJson); /* // generated the user-defined column result if (pInfo->pExpr->pExpr == NULL && TSDB_COL_IS_UD_COL(pInfo->pExpr->base.ColName.flag)) { @@ -876,17 +938,6 @@ void tscSetResRawPtrRv(SSqlRes* pRes, SQueryInfo* pQueryInfo, SSDataBlock* pBloc } } -static SColumnInfo* extractColumnInfoFromResult(SArray* pTableCols) { - int32_t numOfCols = (int32_t) taosArrayGetSize(pTableCols); - SColumnInfo* pColInfo = calloc(numOfCols, sizeof(SColumnInfo)); - for(int32_t i = 0; i < numOfCols; ++i) { - SColumn* pCol = taosArrayGetP(pTableCols, i); - pColInfo[i] = pCol->info;//[index].type; - } - - return pColInfo; -} - typedef struct SDummyInputInfo { SSDataBlock *block; STableQueryInfo *pTableQueryInfo; @@ -1276,14 +1327,14 @@ SOperatorInfo* createJoinOperatorInfo(SOperatorInfo** pUpstream, int32_t numOfUp return pOperator; } -void convertQueryResult(SSqlRes* pRes, SQueryInfo* pQueryInfo, uint64_t objId, bool convertNchar) { +void convertQueryResult(SSqlRes* pRes, SQueryInfo* pQueryInfo, uint64_t objId, bool convertNchar, bool convertJson) { // set the correct result SSDataBlock* p = pQueryInfo->pQInfo->runtimeEnv.outputBuf; pRes->numOfRows = (p != NULL)? p->info.rows: 0; if (pRes->code == TSDB_CODE_SUCCESS && pRes->numOfRows > 0) { tscCreateResPointerInfo(pRes, pQueryInfo); - tscSetResRawPtrRv(pRes, pQueryInfo, p, convertNchar); + tscSetResRawPtrRv(pRes, pQueryInfo, p, convertNchar, convertJson); } tscDebug("0x%"PRIx64" retrieve result in pRes, numOfRows:%d", objId, pRes->numOfRows); @@ -1317,8 +1368,6 @@ void handleDownstreamOperator(SSqlObj** pSqlObjList, int32_t numOfUpstream, SQue // handle the following query process if (px->pQInfo == NULL) { - SColumnInfo* pColumnInfo = extractColumnInfoFromResult(px->colList); - STableMeta* pTableMeta = tscGetMetaInfo(px, 0)->pTableMeta; SSchema* pSchema = tscGetTableSchema(pTableMeta); @@ -1433,7 +1482,6 @@ void handleDownstreamOperator(SSqlObj** pSqlObjList, int32_t numOfUpstream, SQue px->pQInfo->runtimeEnv.udfIsCopy = true; px->pQInfo->runtimeEnv.pUdfInfo = pUdfInfo; - tfree(pColumnInfo); tfree(schema); // set the pRuntimeEnv for pSourceOperator @@ -1442,7 +1490,7 @@ void handleDownstreamOperator(SSqlObj** pSqlObjList, int32_t numOfUpstream, SQue uint64_t qId = pSql->self; qTableQuery(px->pQInfo, &qId); - convertQueryResult(pOutput, px, pSql->self, false); + convertQueryResult(pOutput, px, pSql->self, false, false); } static void tscDestroyResPointerInfo(SSqlRes* pRes) { @@ -2018,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; } } @@ -3093,12 +3134,12 @@ void tscIncStreamExecutionCount(void* pStream) { ps->num += 1; } -bool tscValidateColumnId(STableMetaInfo* pTableMetaInfo, int32_t colId, int32_t numOfParams) { +bool tscValidateColumnId(STableMetaInfo* pTableMetaInfo, int32_t colId) { if (pTableMetaInfo->pTableMeta == NULL) { return false; } - if (colId == TSDB_TBNAME_COLUMN_INDEX || (colId <= TSDB_UD_COLUMN_INDEX && numOfParams == 2)) { + if (colId == TSDB_TBNAME_COLUMN_INDEX || colId <= TSDB_UD_COLUMN_INDEX) { return true; } @@ -4429,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. @@ -4871,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; @@ -4915,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; } } @@ -5117,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); } } } @@ -5391,3 +5435,152 @@ char* cloneCurrentDBName(SSqlObj* pSql) { return p; } +int parseJsontoTagData(char* json, SKVRowBuilder* kvRowBuilder, char* errMsg, int16_t startColId){ + // set json NULL data + uint8_t nullTypeVal[CHAR_BYTES + VARSTR_HEADER_SIZE + INT_BYTES] = {0}; + uint32_t jsonNULL = TSDB_DATA_JSON_NULL; + int jsonIndex = startColId + 1; + char nullTypeKey[VARSTR_HEADER_SIZE + INT_BYTES] = {0}; + varDataSetLen(nullTypeKey, INT_BYTES); + nullTypeVal[0] = TSDB_DATA_TYPE_JSON; + varDataSetLen(nullTypeVal + CHAR_BYTES, INT_BYTES); + *(uint32_t*)(varDataVal(nullTypeKey)) = jsonNULL; + tdAddColToKVRow(kvRowBuilder, jsonIndex++, TSDB_DATA_TYPE_NCHAR, nullTypeKey, false); // add json null type + if (strtrim(json) == 0 || strcasecmp(json, "null") == 0){ + *(uint32_t*)(varDataVal(nullTypeVal + CHAR_BYTES)) = jsonNULL; + tdAddColToKVRow(kvRowBuilder, jsonIndex++, TSDB_DATA_TYPE_NCHAR, nullTypeVal, true); // add json null value + return TSDB_CODE_SUCCESS; + } + int32_t jsonNotNull = TSDB_DATA_JSON_NOT_NULL; + *(uint32_t*)(varDataVal(nullTypeVal + CHAR_BYTES)) = jsonNotNull; + tdAddColToKVRow(kvRowBuilder, jsonIndex++, TSDB_DATA_TYPE_NCHAR, nullTypeVal, true); // add json type + + // set json real data + cJSON *root = cJSON_Parse(json); + if (root == NULL){ + tscError("json parse error"); + return tscSQLSyntaxErrMsg(errMsg, "json parse error", NULL); + } + + int size = cJSON_GetArraySize(root); + if(!cJSON_IsObject(root)){ + tscError("json error invalide value"); + return tscSQLSyntaxErrMsg(errMsg, "json error invalide value", NULL); + } + + int retCode = 0; + SHashObj* keyHash = taosHashInit(8, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), false, false); + for(int i = 0; i < size; i++) { + cJSON* item = cJSON_GetArrayItem(root, i); + if (!item) { + tscError("json inner error:%d", i); + retCode = tscSQLSyntaxErrMsg(errMsg, "json inner error", NULL); + goto end; + } + + char *jsonKey = item->string; + if(!isValidateTag(jsonKey)){ + tscError("json key not validate"); + retCode = tscSQLSyntaxErrMsg(errMsg, "json key not validate", NULL); + goto end; + } + if(strlen(jsonKey) > TSDB_MAX_JSON_KEY_LEN){ + tscError("json key too long error"); + retCode = tscSQLSyntaxErrMsg(errMsg, "json key too long, more than 256", NULL); + goto end; + } + if(strlen(jsonKey) == 0 || taosHashGet(keyHash, jsonKey, strlen(jsonKey)) != NULL){ + continue; + } + + // json key encode by binary + char tagKey[TSDB_MAX_JSON_KEY_LEN + VARSTR_HEADER_SIZE] = {0}; + strncpy(varDataVal(tagKey), jsonKey, strlen(jsonKey)); + int32_t outLen = (int32_t)strlen(jsonKey); + taosHashPut(keyHash, jsonKey, outLen, &outLen, CHAR_BYTES); // add key to hash to remove dumplicate, value is useless + + varDataSetLen(tagKey, outLen); + tdAddColToKVRow(kvRowBuilder, jsonIndex++, TSDB_DATA_TYPE_NCHAR, tagKey, false); // add json key + + if(item->type == cJSON_String){ // add json value format: type|data + char *jsonValue = item->valuestring; + outLen = 0; + char tagVal[TSDB_MAX_JSON_TAGS_LEN] = {0}; + *tagVal = jsonType2DbType(0, item->type); // type + char* tagData = POINTER_SHIFT(tagVal,CHAR_BYTES); + if (!taosMbsToUcs4(jsonValue, strlen(jsonValue), varDataVal(tagData), + TSDB_MAX_JSON_TAGS_LEN - CHAR_BYTES - VARSTR_HEADER_SIZE, &outLen)) { + tscError("json string error:%s|%s", strerror(errno), jsonValue); + retCode = tscSQLSyntaxErrMsg(errMsg, "serizelize json error", NULL); + goto end; + } + + varDataSetLen(tagData, outLen); + tdAddColToKVRow(kvRowBuilder, jsonIndex++, TSDB_DATA_TYPE_NCHAR, tagVal, true); + }else if(item->type == cJSON_Number){ + char tagVal[LONG_BYTES + CHAR_BYTES] = {0}; + *tagVal = jsonType2DbType(item->valuedouble, item->type); // type + char* tagData = POINTER_SHIFT(tagVal,CHAR_BYTES); + if(*tagVal == TSDB_DATA_TYPE_DOUBLE) *((double *)tagData) = item->valuedouble; + else if(*tagVal == TSDB_DATA_TYPE_BIGINT) *((int64_t *)tagData) = item->valueint; + tdAddColToKVRow(kvRowBuilder, jsonIndex++, TSDB_DATA_TYPE_BIGINT, tagVal, true); + }else if(item->type == cJSON_True || item->type == cJSON_False){ + char tagVal[CHAR_BYTES + CHAR_BYTES] = {0}; + *tagVal = jsonType2DbType((double)(item->valueint), item->type); // type + char* tagData = POINTER_SHIFT(tagVal,CHAR_BYTES); + *tagData = (char)(item->valueint); + tdAddColToKVRow(kvRowBuilder, jsonIndex++, TSDB_DATA_TYPE_BOOL, tagVal, true); + }else if(item->type == cJSON_NULL){ + char tagVal[CHAR_BYTES + VARSTR_HEADER_SIZE + INT_BYTES] = {0}; + *tagVal = jsonType2DbType(0, item->type); // type + int32_t* tagData = POINTER_SHIFT(tagVal,CHAR_BYTES); + varDataSetLen(tagData, INT_BYTES); + *(uint32_t*)(varDataVal(tagData)) = TSDB_DATA_JSON_null; + tdAddColToKVRow(kvRowBuilder, jsonIndex++, TSDB_DATA_TYPE_BINARY, tagVal, true); + } + else{ + retCode = tscSQLSyntaxErrMsg(errMsg, "invalidate json value", NULL); + goto end; + } + } + + if(taosHashGetSize(keyHash) == 0){ // set json NULL true + *(uint32_t*)(varDataVal(nullTypeVal + CHAR_BYTES)) = jsonNULL; + memcpy(POINTER_SHIFT(kvRowBuilder->buf, kvRowBuilder->pColIdx[2].offset), nullTypeVal, CHAR_BYTES + VARSTR_HEADER_SIZE + INT_BYTES); + } + +end: + taosHashCleanup(keyHash); + cJSON_Delete(root); + return retCode; +} + +int8_t jsonType2DbType(double data, int jsonType){ + switch(jsonType){ + case cJSON_Number: + if (data - (int64_t)data > 0) return TSDB_DATA_TYPE_DOUBLE; else return TSDB_DATA_TYPE_BIGINT; + case cJSON_String: + return TSDB_DATA_TYPE_NCHAR; + case cJSON_NULL: + return TSDB_DATA_TYPE_BINARY; + case cJSON_True: + case cJSON_False: + return TSDB_DATA_TYPE_BOOL; + } + return TSDB_DATA_TYPE_NULL; +} + +// get key from json->'key' +void getJsonKey(SStrToken *t0){ + while(true){ + t0->n = tGetToken(t0->z, &t0->type); + if (t0->type == TK_STRING){ + t0->z++; + t0->n -= 2; + break; + }else if (t0->type == TK_ILLEGAL){ + assert(0); + } + t0->z += t0->n; + } +} 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 98134c2433b690239cf33608dce92ad3fbbcee62..cb001becd45271989586b0d45d4f91c36bbba5aa 100644 --- a/src/common/inc/tdataformat.h +++ b/src/common/inc/tdataformat.h @@ -547,7 +547,7 @@ void tdDestroyKVRowBuilder(SKVRowBuilder *pBuilder); void tdResetKVRowBuilder(SKVRowBuilder *pBuilder); SKVRow tdGetKVRowFromBuilder(SKVRowBuilder *pBuilder); -static FORCE_INLINE int tdAddColToKVRow(SKVRowBuilder *pBuilder, int16_t colId, int8_t type, void *value) { +static FORCE_INLINE int tdAddColToKVRow(SKVRowBuilder *pBuilder, int16_t colId, int8_t type, void *value, bool isJumpJsonVType) { if (pBuilder->nCols >= pBuilder->tCols) { pBuilder->tCols *= 2; SColIdx* pColIdx = (SColIdx *)realloc((void *)(pBuilder->pColIdx), sizeof(SColIdx) * pBuilder->tCols); @@ -560,9 +560,14 @@ static FORCE_INLINE int tdAddColToKVRow(SKVRowBuilder *pBuilder, int16_t colId, pBuilder->nCols++; - int tlen = IS_VAR_DATA_TYPE(type) ? varDataTLen(value) : TYPE_BYTES[type]; + char* jumpType = (char*)value; + if(isJumpJsonVType) jumpType += CHAR_BYTES; + int tlen = IS_VAR_DATA_TYPE(type) ? varDataTLen(jumpType) : TYPE_BYTES[type]; + if(isJumpJsonVType) tlen += CHAR_BYTES; // add type size + if (tlen > pBuilder->alloc - pBuilder->size) { while (tlen > pBuilder->alloc - pBuilder->size) { + assert(pBuilder->alloc > 0); pBuilder->alloc *= 2; } void* buf = realloc(pBuilder->buf, pBuilder->alloc); @@ -609,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/inc/tvariant.h b/src/common/inc/tvariant.h index 03b17bdc463d6b5d0f812eafa723c886964d35fc..31bc7a247ad9851aa48d99a3c6eec31e90313972 100644 --- a/src/common/inc/tvariant.h +++ b/src/common/inc/tvariant.h @@ -25,7 +25,7 @@ extern "C" { // variant, each number/string/field_id has a corresponding struct during parsing sql typedef struct tVariant { - uint32_t nType; + int32_t nType; // change uint to int, because in tVariantCreate() pVar->nType = -1; // -1 means error type int32_t nLen; // only used for string, for number, it is useless union { int64_t i64; 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 cc2bb8803badc2aae2e80200691be0439bac3afe..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); } } @@ -117,11 +247,16 @@ void tExprTreeDestroy(tExprNode *pNode, void (*fp)(void *)) { doExprTreeDestroy(&pNode, fp); } else if (pNode->nodeType == TSQL_NODE_VALUE) { tVariantDestroy(pNode->pVal); + 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); } - free(pNode); + tfree(pNode); } static void doExprTreeDestroy(tExprNode **pExpr, void (*fp)(void *)) { @@ -138,12 +273,19 @@ static void doExprTreeDestroy(tExprNode **pExpr, void (*fp)(void *)) { } } else if ((*pExpr)->nodeType == TSQL_NODE_VALUE) { tVariantDestroy((*pExpr)->pVal); - free((*pExpr)->pVal); + tfree((*pExpr)->pVal); } else if ((*pExpr)->nodeType == TSQL_NODE_COL) { 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); } - free(*pExpr); + tfree(*pExpr); *pExpr = NULL; } @@ -174,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) { @@ -288,7 +503,7 @@ static void exprTreeToBinaryImpl(SBufferWriter* bw, tExprNode* expr) { tVariant* pVal = expr->pVal; tbufWriteUint32(bw, pVal->nType); - if (pVal->nType == TSDB_DATA_TYPE_BINARY) { + if (pVal->nType == TSDB_DATA_TYPE_BINARY || pVal->nType == TSDB_DATA_TYPE_NCHAR) { tbufWriteInt32(bw, pVal->nLen); tbufWrite(bw, pVal->pz, pVal->nLen); } else { @@ -307,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) { @@ -349,7 +572,7 @@ static tExprNode* exprTreeFromBinaryImpl(SBufferReader* br) { pExpr->pVal = pVal; pVal->nType = tbufReadUint32(br); - if (pVal->nType == TSDB_DATA_TYPE_BINARY) { + if (pVal->nType == TSDB_DATA_TYPE_BINARY || pVal->nType == TSDB_DATA_TYPE_NCHAR) { tbufReadToBuffer(br, &pVal->nLen, sizeof(pVal->nLen)); pVal->pz = calloc(1, pVal->nLen + 1); tbufReadToBuffer(br, pVal->pz, pVal->nLen); @@ -372,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; } @@ -620,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/common/src/tname.c b/src/common/src/tname.c index c0951cba700fbea2d992da147620cf65bd1f75b9..5d7e8ce54219a1d9d36a7ac21997bb18712a286b 100644 --- a/src/common/src/tname.c +++ b/src/common/src/tname.c @@ -4,6 +4,7 @@ #include "tname.h" #include "ttoken.h" #include "tvariant.h" +#include "tglobal.h" #define VALIDNUMOFCOLS(x) ((x) >= TSDB_MIN_COLUMNS && (x) <= TSDB_MAX_COLUMNS) #define VALIDNUMOFTAGS(x) ((x) >= 0 && (x) <= TSDB_MAX_TAGS) @@ -251,6 +252,9 @@ static bool doValidateSchema(SSchema* pSchema, int32_t numOfCols, int32_t maxLen int32_t rowLen = 0; for (int32_t i = 0; i < numOfCols; ++i) { + if (pSchema[i].type == TSDB_DATA_TYPE_JSON && numOfCols != 1){ + return false; + } // 1. valid types if (!isValidDataType(pSchema[i].type)) { return false; @@ -301,8 +305,12 @@ bool tIsValidSchema(struct SSchema* pSchema, int32_t numOfCols, int32_t numOfTag if (!doValidateSchema(pSchema, numOfCols, TSDB_MAX_BYTES_PER_ROW)) { return false; } + int32_t maxTagLen = TSDB_MAX_TAGS_LEN; + if (numOfTags == 1 && pSchema[numOfCols].type == TSDB_DATA_TYPE_JSON){ + maxTagLen = TSDB_MAX_JSON_TAGS_LEN; + } - if (!doValidateSchema(&pSchema[numOfCols], numOfTags, TSDB_MAX_TAGS_LEN)) { + if (!doValidateSchema(&pSchema[numOfCols], numOfTags, maxTagLen)) { return false; } diff --git a/src/common/src/ttypes.c b/src/common/src/ttypes.c index 08bfc2e9aa6f0b9337d484c725f2737cbbacaac0..81bc9c7275b07cf41dc1305e4db807e1b2b839a0 100644 --- a/src/common/src/ttypes.c +++ b/src/common/src/ttypes.c @@ -18,7 +18,7 @@ #include "ttokendef.h" #include "tscompression.h" -const int32_t TYPE_BYTES[15] = { +const int32_t TYPE_BYTES[16] = { -1, // TSDB_DATA_TYPE_NULL sizeof(int8_t), // TSDB_DATA_TYPE_BOOL sizeof(int8_t), // TSDB_DATA_TYPE_TINYINT @@ -34,6 +34,7 @@ const int32_t TYPE_BYTES[15] = { sizeof(uint16_t), // TSDB_DATA_TYPE_USMALLINT sizeof(uint32_t), // TSDB_DATA_TYPE_UINT sizeof(uint64_t), // TSDB_DATA_TYPE_UBIGINT + sizeof(int8_t), // TSDB_DATA_TYPE_JSON }; #define DO_STATICS(__sum, __min, __max, __minIndex, __maxIndex, _list, _index) \ @@ -367,8 +368,8 @@ static void getStatics_nchr(const void *pData, int32_t numOfRow, int64_t *min, i *maxIndex = 0; } -tDataTypeDescriptor tDataTypes[15] = { - {TSDB_DATA_TYPE_NULL, 6, 1, "NOTYPE", 0, 0, NULL, NULL, NULL}, +tDataTypeDescriptor tDataTypes[16] = { + {TSDB_DATA_TYPE_NULL, 6, 1, "NOTYPE", 0, 0, NULL, NULL, NULL}, {TSDB_DATA_TYPE_BOOL, 4, CHAR_BYTES, "BOOL", false, true, tsCompressBool, tsDecompressBool, getStatics_bool}, {TSDB_DATA_TYPE_TINYINT, 7, CHAR_BYTES, "TINYINT", INT8_MIN, INT8_MAX, tsCompressTinyint, tsDecompressTinyint, getStatics_i8}, {TSDB_DATA_TYPE_SMALLINT, 8, SHORT_BYTES, "SMALLINT", INT16_MIN, INT16_MAX, tsCompressSmallint, tsDecompressSmallint, getStatics_i16}, @@ -376,13 +377,14 @@ tDataTypeDescriptor tDataTypes[15] = { {TSDB_DATA_TYPE_BIGINT, 6, LONG_BYTES, "BIGINT", INT64_MIN, INT64_MAX, tsCompressBigint, tsDecompressBigint, getStatics_i64}, {TSDB_DATA_TYPE_FLOAT, 5, FLOAT_BYTES, "FLOAT", 0, 0, tsCompressFloat, tsDecompressFloat, getStatics_f}, {TSDB_DATA_TYPE_DOUBLE, 6, DOUBLE_BYTES, "DOUBLE", 0, 0, tsCompressDouble, tsDecompressDouble, getStatics_d}, - {TSDB_DATA_TYPE_BINARY, 6, 0, "BINARY", 0, 0, tsCompressString, tsDecompressString, getStatics_bin}, + {TSDB_DATA_TYPE_BINARY, 6, 0, "BINARY", 0, 0, tsCompressString, tsDecompressString, getStatics_bin}, {TSDB_DATA_TYPE_TIMESTAMP, 9, LONG_BYTES, "TIMESTAMP", INT64_MIN, INT64_MAX, tsCompressTimestamp, tsDecompressTimestamp, getStatics_i64}, - {TSDB_DATA_TYPE_NCHAR, 5, 8, "NCHAR", 0, 0, tsCompressString, tsDecompressString, getStatics_nchr}, + {TSDB_DATA_TYPE_NCHAR, 5, 8, "NCHAR", 0, 0, tsCompressString, tsDecompressString, getStatics_nchr}, {TSDB_DATA_TYPE_UTINYINT, 16, CHAR_BYTES, "TINYINT UNSIGNED", 0, UINT8_MAX, tsCompressTinyint, tsDecompressTinyint, getStatics_u8}, {TSDB_DATA_TYPE_USMALLINT, 17, SHORT_BYTES, "SMALLINT UNSIGNED", 0, UINT16_MAX, tsCompressSmallint, tsDecompressSmallint, getStatics_u16}, {TSDB_DATA_TYPE_UINT, 12, INT_BYTES, "INT UNSIGNED", 0, UINT32_MAX, tsCompressInt, tsDecompressInt, getStatics_u32}, {TSDB_DATA_TYPE_UBIGINT, 15, LONG_BYTES, "BIGINT UNSIGNED", 0, UINT64_MAX, tsCompressBigint, tsDecompressBigint, getStatics_u64}, + {TSDB_DATA_TYPE_JSON,4, TSDB_MAX_JSON_TAGS_LEN, "JSON", 0, 0, tsCompressString, tsDecompressString, getStatics_nchr}, }; char tTokenTypeSwitcher[13] = { @@ -428,7 +430,7 @@ FORCE_INLINE void* getDataMax(int32_t type) { bool isValidDataType(int32_t type) { - return type >= TSDB_DATA_TYPE_NULL && type <= TSDB_DATA_TYPE_UBIGINT; + return type >= TSDB_DATA_TYPE_NULL && type <= TSDB_DATA_TYPE_JSON; } void setVardataNull(void* val, int32_t type) { @@ -438,6 +440,9 @@ void setVardataNull(void* val, int32_t type) { } else if (type == TSDB_DATA_TYPE_NCHAR) { varDataSetLen(val, sizeof(int32_t)); *(uint32_t*) varDataVal(val) = TSDB_DATA_NCHAR_NULL; + } else if (type == TSDB_DATA_TYPE_JSON) { + varDataSetLen(val, sizeof(int32_t)); + *(uint32_t*) varDataVal(val) = TSDB_DATA_JSON_NULL; } else { assert(0); } @@ -505,6 +510,7 @@ void setNullN(void *val, int32_t type, int32_t bytes, int32_t numOfElems) { break; case TSDB_DATA_TYPE_NCHAR: case TSDB_DATA_TYPE_BINARY: + case TSDB_DATA_TYPE_JSON: for (int32_t i = 0; i < numOfElems; ++i) { setVardataNull(POINTER_SHIFT(val, i * bytes), type); } diff --git a/src/common/src/tvariant.c b/src/common/src/tvariant.c index f22e3da28b331d455f5f4d73251c37072e1f69fc..68ed5c5c109cdfacb5ffac50e4f424ec431b78a0 100644 --- a/src/common/src/tvariant.c +++ b/src/common/src/tvariant.c @@ -158,7 +158,7 @@ void tVariantCreateFromBinary(tVariant *pVar, const char *pz, size_t len, uint32 pVar->dKey = GET_FLOAT_VAL(pz); break; } - case TSDB_DATA_TYPE_NCHAR: { // here we get the nchar length from raw binary bits length + case TSDB_DATA_TYPE_NCHAR:{ // here we get the nchar length from raw binary bits length size_t lenInwchar = len / TSDB_NCHAR_SIZE; pVar->wpz = calloc(1, (lenInwchar + 1) * TSDB_NCHAR_SIZE); @@ -167,7 +167,13 @@ void tVariantCreateFromBinary(tVariant *pVar, const char *pz, size_t len, uint32 break; } - case TSDB_DATA_TYPE_BINARY: { // todo refactor, extract a method + case TSDB_DATA_TYPE_JSON:{ + pVar->pz = calloc(len + 2, sizeof(char)); + memcpy(pVar->pz, pz, len); + pVar->nLen = (int32_t)len; + break; + } + case TSDB_DATA_TYPE_BINARY:{ pVar->pz = calloc(len + 1, sizeof(char)); memcpy(pVar->pz, pz, len); pVar->nLen = (int32_t)len; @@ -185,7 +191,7 @@ void tVariantCreateFromBinary(tVariant *pVar, const char *pz, size_t len, uint32 void tVariantDestroy(tVariant *pVar) { if (pVar == NULL) return; - if (pVar->nType == TSDB_DATA_TYPE_BINARY || pVar->nType == TSDB_DATA_TYPE_NCHAR) { + if (pVar->nType == TSDB_DATA_TYPE_BINARY || pVar->nType == TSDB_DATA_TYPE_NCHAR || pVar->nType == TSDB_DATA_TYPE_JSON) { tfree(pVar->pz); pVar->nLen = 0; } @@ -210,11 +216,41 @@ bool tVariantIsValid(tVariant *pVar) { return isValidDataType(pVar->nType); } +bool tVariantTypeMatch(tVariant *pVar, int8_t dbType){ + switch (dbType) { + case TSDB_DATA_TYPE_BINARY: + case TSDB_DATA_TYPE_NCHAR: { + if(pVar->nType != TSDB_DATA_TYPE_BINARY && pVar->nType != TSDB_DATA_TYPE_NCHAR){ + return false; + } + break; + } + + case TSDB_DATA_TYPE_BOOL: + case TSDB_DATA_TYPE_TINYINT: + case TSDB_DATA_TYPE_SMALLINT: + case TSDB_DATA_TYPE_INT: + case TSDB_DATA_TYPE_UTINYINT: + case TSDB_DATA_TYPE_USMALLINT: + case TSDB_DATA_TYPE_UINT: + case TSDB_DATA_TYPE_BIGINT: + case TSDB_DATA_TYPE_UBIGINT: + case TSDB_DATA_TYPE_FLOAT: + case TSDB_DATA_TYPE_DOUBLE:{ + if(pVar->nType == TSDB_DATA_TYPE_BINARY || pVar->nType == TSDB_DATA_TYPE_NCHAR){ + return false; + } + break; + } + } + return true; +} + void tVariantAssign(tVariant *pDst, const tVariant *pSrc) { if (pSrc == NULL || pDst == NULL) return; pDst->nType = pSrc->nType; - if (pSrc->nType == TSDB_DATA_TYPE_BINARY || pSrc->nType == TSDB_DATA_TYPE_NCHAR) { + if (pSrc->nType == TSDB_DATA_TYPE_BINARY || pSrc->nType == TSDB_DATA_TYPE_NCHAR || pSrc->nType == TSDB_DATA_TYPE_JSON) { int32_t len = pSrc->nLen + TSDB_NCHAR_SIZE; char* p = realloc(pDst->pz, len); assert(p); @@ -249,7 +285,7 @@ void tVariantAssign(tVariant *pDst, const tVariant *pSrc) { } } - if (pDst->nType != TSDB_DATA_TYPE_POINTER_ARRAY && pDst->nType != TSDB_DATA_TYPE_VALUE_ARRAY) { + if (pDst->nType != TSDB_DATA_TYPE_POINTER_ARRAY && pDst->nType != TSDB_DATA_TYPE_VALUE_ARRAY && isValidDataType(pDst->nType)) { // if pDst->nType=-1, core dump. eg: where intcolumn=999999999999999999999999999 pDst->nLen = tDataTypes[pDst->nType].bytes; } } @@ -267,7 +303,7 @@ int32_t tVariantCompare(const tVariant* p1, const tVariant* p2) { return 1; } - if (p1->nType == TSDB_DATA_TYPE_BINARY || p1->nType == TSDB_DATA_TYPE_NCHAR) { + if (p1->nType == TSDB_DATA_TYPE_BINARY || p1->nType == TSDB_DATA_TYPE_NCHAR || p1->nType == TSDB_DATA_TYPE_JSON) { if (p1->nLen == p2->nLen) { return memcmp(p1->pz, p2->pz, p1->nLen); } else { @@ -815,7 +851,7 @@ int32_t tVariantDumpEx(tVariant *pVariant, char *payload, int16_t type, bool inc break; } - case TSDB_DATA_TYPE_BINARY: { + case TSDB_DATA_TYPE_BINARY:{ if (!includeLengthPrefix) { if (pVariant->nType == TSDB_DATA_TYPE_NULL) { *(uint8_t*) payload = TSDB_DATA_BINARY_NULL; @@ -852,7 +888,7 @@ int32_t tVariantDumpEx(tVariant *pVariant, char *payload, int16_t type, bool inc } break; } - case TSDB_DATA_TYPE_NCHAR: { + case TSDB_DATA_TYPE_NCHAR:{ int32_t newlen = 0; if (!includeLengthPrefix) { if (pVariant->nType == TSDB_DATA_TYPE_NULL) { @@ -888,6 +924,16 @@ int32_t tVariantDumpEx(tVariant *pVariant, char *payload, int16_t type, bool inc break; } + case TSDB_DATA_TYPE_JSON:{ + if (pVariant->nType == TSDB_DATA_TYPE_BINARY){ + *((int8_t *)payload) = TSDB_DATA_JSON_PLACEHOLDER; + } else if (pVariant->nType == TSDB_DATA_TYPE_JSON){ // select * from stable, set tag type to json,from setTagValue/tag_project_function + memcpy(payload, pVariant->pz, pVariant->nLen); + }else { + return -1; + } + break; + } } return 0; 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/JsonTagTest.java b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/JsonTagTest.java new file mode 100644 index 0000000000000000000000000000000000000000..afba0398752f1fd6c23dd7874301be27616fdab2 --- /dev/null +++ b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/JsonTagTest.java @@ -0,0 +1,1169 @@ +package com.taosdata.jdbc; + +import com.google.common.collect.Lists; +import org.checkerframework.checker.units.qual.A; +import org.junit.*; +import org.junit.runners.MethodSorters; + +import java.sql.*; +import java.util.List; + +/** + * test json tag + */ +@FixMethodOrder(MethodSorters.NAME_ASCENDING) +public class JsonTagTest { + private static String dbname = "json_tag_test"; + private static Connection connection; + private static Statement statement; + private static final String superSql = "create table if not exists jsons1(ts timestamp, dataInt int, dataBool bool, dataStr nchar(50), dataStrBin binary(150)) tags(jtag json)"; + private static final String[] sql = { + "insert into jsons1_1 using jsons1 tags('{\"tag1\":\"fff\",\"tag2\":5, \"tag3\":true}') values(now, 1, false, 'json1', '你是') (1591060608000, 23, true, '等等', 'json')", + "insert into jsons1_2 using jsons1 tags('{\"tag1\":5,\"tag2\":\"beijing\"}') values (1591060628000, 2, true, 'json2', 'sss')", + "insert into jsons1_3 using jsons1 tags('{\"tag1\":false,\"tag2\":\"beijing\"}') values (1591060668000, 3, false, 'json3', 'efwe')", + "insert into jsons1_4 using jsons1 tags('{\"tag1\":null,\"tag2\":\"shanghai\",\"tag3\":\"hello\"}') values (1591060728000, 4, true, 'json4', '323sd')", + "insert into jsons1_5 using jsons1 tags('{\"tag1\":1.232, \"tag2\":null}') values(1591060928000, 1, false, '你就会', 'ewe')", + "insert into jsons1_6 using jsons1 tags('{\"tag1\":11,\"tag2\":\"\",\"tag2\":null}') values(1591061628000, 11, false, '你就会','')", + "insert into jsons1_7 using jsons1 tags('{\"tag1\":\"收到货\",\"tag2\":\"\",\"tag3\":null}') values(1591062628000, 2, NULL, '你就会', 'dws')", + // test duplicate key using the first one. + "CREATE TABLE if not exists jsons1_8 using jsons1 tags('{\"tag1\":null, \"tag1\":true, \"tag1\":45, \"1tag$\":2, \" \":90}')", + + }; + + private static final String[] invalidJsonInsertSql = { + // test empty json string, save as tag is NULL + "insert into jsons1_9 using jsons1 tags('\t') values (1591062328000, 24, NULL, '你就会', '2sdw')", + }; + + private static final String[] invalidJsonCreateSql = { + "CREATE TABLE if not exists jsons1_10 using jsons1 tags('')", + "CREATE TABLE if not exists jsons1_11 using jsons1 tags(' ')", + "CREATE TABLE if not exists jsons1_12 using jsons1 tags('{}')", + "CREATE TABLE if not exists jsons1_13 using jsons1 tags('null')", + }; + + // test invalidate json + private static final String[] errorJsonInsertSql = { + "CREATE TABLE if not exists jsons1_14 using jsons1 tags('\"efwewf\"')", + "CREATE TABLE if not exists jsons1_14 using jsons1 tags('3333')", + "CREATE TABLE if not exists jsons1_14 using jsons1 tags('33.33')", + "CREATE TABLE if not exists jsons1_14 using jsons1 tags('false')", + "CREATE TABLE if not exists jsons1_14 using jsons1 tags('[1,true]')", + "CREATE TABLE if not exists jsons1_14 using jsons1 tags('{222}')", + "CREATE TABLE if not exists jsons1_14 using jsons1 tags('{\"fe\"}')", + }; + + private static final String[] errorSelectSql = { + "select * from jsons1 where jtag->tag1='beijing'", + "select * from jsons1 where jtag->'location'", + "select * from jsons1 where jtag->''", + "select * from jsons1 where jtag->''=9", + "select -> from jsons1", + "select ? from jsons1", + "select * from jsons1 where contains", + "select * from jsons1 where jtag->", + "select jtag->location from jsons1", + "select jtag contains location from jsons1", + "select * from jsons1 where jtag contains location", + "select * from jsons1 where jtag contains ''", + "select * from jsons1 where jtag contains 'location'='beijing'", + // test where with json tag + "select * from jsons1_1 where jtag is not null", + "select * from jsons1 where jtag='{\"tag1\":11,\"tag2\":\"\"}'", + "select * from jsons1 where jtag->'tag1'={}" + }; + + @Test + public void case01_InsertTest() throws SQLException { + for (String sql : sql) { + statement.execute(sql); + } + for (String sql : invalidJsonInsertSql) { + statement.execute(sql); + } + for (String sql : invalidJsonCreateSql) { + statement.execute(sql); + } + } + + @Test + public void case02_InvalidJsonInsertTest() { + int count = 0; + for (String sql : errorJsonInsertSql) { + try { + statement.execute(sql); + } catch (SQLException e) { + count++; + } + } + Assert.assertEquals(errorJsonInsertSql.length, count); + } + + // test invalidate json key, key must can be printed assic char + @Test(expected = SQLException.class) + public void case02_ArrayErrorTest() throws SQLException { + statement.execute("CREATE TABLE if not exists jsons1_14 using jsons1 tags('{\"tag1\":[1,true]}')"); + } + + @Test(expected = SQLException.class) + public void case02_EmptyKeyErrorTest() throws SQLException { + statement.execute("CREATE TABLE if not exists jsons1_14 using jsons1 tags('{\"\":\"fff\"}')"); + } + + @Test(expected = SQLException.class) + public void case02_EmptyValueErrorTest() throws SQLException { + statement.execute("CREATE TABLE if not exists jsons1_14 using jsons1 tags('{\"tag1\":{}}')"); + } + + @Test(expected = SQLException.class) + public void case02_AbnormalKeyErrorTest1() throws SQLException { + statement.execute("CREATE TABLE if not exists jsons1_14 using jsons1 tags('{\"。loc\":\"fff\"}')"); + } + + @Test(expected = SQLException.class) + public void case02_AbnormalKeyErrorTest2() throws SQLException { + statement.execute("CREATE TABLE if not exists jsons1_14 using jsons1 tags('{\"\t\":\"fff\"}')"); + } + + @Test(expected = SQLException.class) + public void case02_AbnormalKeyErrorTest3() throws SQLException { + statement.execute("CREATE TABLE if not exists jsons1_14 using jsons1 tags('{\"试试\":\"fff\"}')"); + } + + @Test + public void case03_AlterTag() throws SQLException { + statement.execute("ALTER TABLE jsons1_1 SET TAG jtag='{\"tag1\":\"femail\",\"tag2\":35,\"tag3\":true}'"); + } + + @Test(expected = SQLException.class) + public void case03_AddTagErrorTest() throws SQLException { + statement.execute("ALTER STABLE jsons1 add tag tag2 nchar(20)"); + } + + @Test(expected = SQLException.class) + public void case03_dropTagErrorTest() throws SQLException { + statement.execute("ALTER STABLE jsons1 drop tag jtag"); + } + + @Test(expected = SQLException.class) + public void case03_AlterTagErrorTest() throws SQLException { + statement.execute("ALTER TABLE jsons1_1 SET TAG jtag=4"); + } + + // test error syntax + @Test + public void case04_SelectErrorTest() { + int count = 0; + for (String sql : errorSelectSql) { + try { + statement.execute(sql); + } catch (SQLException e) { + count++; + } + } + Assert.assertEquals(errorSelectSql.length, count); + } + + // test select normal column + @Test + public void case04_select01() throws SQLException { + ResultSet resultSet = statement.executeQuery("select dataint from jsons1"); + int count = 0; + while (resultSet.next()) { + count++; + } + Assert.assertEquals(sql.length + invalidJsonInsertSql.length, count); + close(resultSet); + } + + // test select json tag + @Test + public void case04_select02() throws SQLException { + ResultSet resultSet = statement.executeQuery("select * from jsons1"); + int count = 0; + while (resultSet.next()) { + count++; + } + Assert.assertEquals(sql.length + invalidJsonInsertSql.length, count); + close(resultSet); + } + + @Test + public void case04_select03() throws SQLException { + ResultSet resultSet = statement.executeQuery("select jtag from jsons1"); + int count = 0; + while (resultSet.next()) { + count++; + } + Assert.assertEquals(sql.length + invalidJsonInsertSql.length + invalidJsonCreateSql.length, count); + close(resultSet); + } + + @Test + public void case04_select04() throws SQLException { + ResultSet resultSet = statement.executeQuery("select jtag from jsons1 where jtag is null"); + int count = 0; + while (resultSet.next()) { + count++; + } + Assert.assertEquals(invalidJsonInsertSql.length + invalidJsonCreateSql.length, count); + close(resultSet); + } + + @Test + public void case04_select05() throws SQLException { + ResultSet resultSet = statement.executeQuery("select jtag from jsons1 where jtag is not null"); + int count = 0; + while (resultSet.next()) { + count++; + } + Assert.assertEquals(sql.length, count); + close(resultSet); + } + + @Test + public void case04_select06() throws SQLException { + ResultSet resultSet = statement.executeQuery("select jtag from jsons1_8"); + resultSet.next(); + String result = resultSet.getString(1); + Assert.assertEquals("{\"tag1\":null,\"1tag$\":2,\" \":90}", result); + close(resultSet); + } + + @Test + public void case04_select07() throws SQLException { + ResultSet resultSet = statement.executeQuery("select jtag from jsons1_1"); + resultSet.next(); + String result = resultSet.getString(1); + Assert.assertEquals("{\"tag1\":\"femail\",\"tag2\":35,\"tag3\":true}", result); + close(resultSet); + } + + // test jtag is NULL + @Test + public void case04_select08() throws SQLException { + ResultSet resultSet = statement.executeQuery("select jtag from jsons1_9"); + resultSet.next(); + String result = resultSet.getString(1); + Assert.assertNull(result); + close(resultSet); + } + + // test select json tag->'key', value is string + @Test + public void case04_select09() throws SQLException { + ResultSet resultSet = statement.executeQuery("select jtag->'tag1' from jsons1_1"); + resultSet.next(); + String result = resultSet.getString(1); + Assert.assertEquals("\"femail\"", result); + close(resultSet); + } + + @Test + public void case04_select10() throws SQLException { + ResultSet resultSet = statement.executeQuery("select jtag->'tag2' from jsons1_6"); + resultSet.next(); + String result = resultSet.getString(1); + Assert.assertEquals("\"\"", result); + close(resultSet); + } + + // test select json tag->'key', value is int + @Test + public void case04_select11() throws SQLException { + ResultSet resultSet = statement.executeQuery("select jtag->'tag2' from jsons1_1"); + resultSet.next(); + String string = resultSet.getString(1); + Assert.assertEquals("35", string); + close(resultSet); + } + + // test select json tag->'key', value is bool + @Test + public void case04_select12() throws SQLException { + ResultSet resultSet = statement.executeQuery("select jtag->'tag3' from jsons1_1"); + resultSet.next(); + String string = resultSet.getString(1); + Assert.assertEquals("true", string); + close(resultSet); + } + + // test select json tag->'key', value is null + @Test + public void case04_select13() throws SQLException { + ResultSet resultSet = statement.executeQuery("select jtag->'tag1' from jsons1_4"); + resultSet.next(); + String string = resultSet.getString(1); + Assert.assertEquals("null", string); + close(resultSet); + } + + // test select json tag->'key', value is double + @Test + public void case04_select14() throws SQLException { + ResultSet resultSet = statement.executeQuery("select jtag->'tag1' from jsons1_5"); + resultSet.next(); + String string = resultSet.getString(1); + Assert.assertEquals("1.232000000", string); + close(resultSet); + } + + // test select json tag->'key', key is not exist + @Test + public void case04_select15() throws SQLException { + ResultSet resultSet = statement.executeQuery("select jtag->'tag10' from jsons1_4"); + resultSet.next(); + String string = resultSet.getString(1); + Assert.assertNull(string); + close(resultSet); + } + + @Test + public void case04_select16() throws SQLException { + ResultSet resultSet = statement.executeQuery("select jtag->'tag1' from jsons1"); + int count = 0; + while (resultSet.next()) { + count++; + } + Assert.assertEquals(sql.length + invalidJsonCreateSql.length + invalidJsonInsertSql.length, count); + close(resultSet); + } + + @Test + public void case04_select17() throws SQLException { + ResultSet resultSet = statement.executeQuery("select jtag->'tag1' from jsons1"); + int count = 0; + while (resultSet.next()) { + count++; + } + Assert.assertEquals(sql.length + invalidJsonCreateSql.length + invalidJsonInsertSql.length, count); + close(resultSet); + } + + // where json value is string + @Test + public void case04_select19() throws SQLException { + ResultSet resultSet = statement.executeQuery("select * from jsons1 where jtag->'tag2'='beijing'"); + int count = 0; + while (resultSet.next()) { + count++; + } + Assert.assertEquals(2, count); + close(resultSet); + } + + @Test + public void case04_select20() throws SQLException { + ResultSet resultSet = statement.executeQuery("select dataint,tbname,jtag->'tag1',jtag from jsons1 where jtag->'tag2'='beijing'"); + int count = 0; + while (resultSet.next()) { + count++; + } + Assert.assertEquals(2, count); + close(resultSet); + } + + @Test + public void case04_select21() throws SQLException { + ResultSet resultSet = statement.executeQuery("select * from jsons1 where jtag->'tag1'='beijing'"); + int count = 0; + while (resultSet.next()) { + count++; + } + Assert.assertEquals(0, count); + close(resultSet); + } + + @Test + public void case04_select23() throws SQLException { + ResultSet resultSet = statement.executeQuery("select * from jsons1 where jtag->'tag1'='收到货'"); + int count = 0; + while (resultSet.next()) { + count++; + } + Assert.assertEquals(1, count); + close(resultSet); + } + + @Test + public void case05_symbolOperation01() throws SQLException { + ResultSet resultSet = statement.executeQuery("select * from jsons1 where jtag->'tag2'>'beijing'"); + int count = 0; + while (resultSet.next()) { + count++; + } + Assert.assertEquals(1, count); + close(resultSet); + } + + @Test + public void case05_symbolOperation02() throws SQLException { + ResultSet resultSet = statement.executeQuery("select * from jsons1 where jtag->'tag2'>='beijing'"); + int count = 0; + while (resultSet.next()) { + count++; + } + Assert.assertEquals(3, count); + close(resultSet); + } + + @Test + public void case05_symbolOperation03() throws SQLException { + ResultSet resultSet = statement.executeQuery("select * from jsons1 where jtag->'tag2'<'beijing'"); + int count = 0; + while (resultSet.next()) { + count++; + } + Assert.assertEquals(2, count); + close(resultSet); + } + + @Test + public void case05_symbolOperation04() throws SQLException { + ResultSet resultSet = statement.executeQuery("select * from jsons1 where jtag->'tag2'<='beijing'"); + int count = 0; + while (resultSet.next()) { + count++; + } + Assert.assertEquals(4, count); + close(resultSet); + } + + @Test + public void case05_symbolOperation05() throws SQLException { + ResultSet resultSet = statement.executeQuery("select * from jsons1 where jtag->'tag2'!='beijing'"); + int count = 0; + while (resultSet.next()) { + count++; + } + Assert.assertEquals(3, count); + close(resultSet); + } + + @Test + public void case05_symbolOperation06() throws SQLException { + ResultSet resultSet = statement.executeQuery("select * from jsons1 where jtag->'tag2'=''"); + int count = 0; + while (resultSet.next()) { + count++; + } + Assert.assertEquals(2, count); + close(resultSet); + } + + // where json value is int + @Test + public void case06_selectValue01() throws SQLException { + ResultSet resultSet = statement.executeQuery("select * from jsons1 where jtag->'tag1'=5"); + int count = 0; + while (resultSet.next()) { + System.out.println(resultSet.getString(1)); + count++; + } + Assert.assertEquals(1, count); + close(resultSet); + } + + @Test + public void case06_selectValue02() throws SQLException { + ResultSet resultSet = statement.executeQuery("select * from jsons1 where jtag->'tag1'<54"); + int count = 0; + while (resultSet.next()) { + count++; + } + Assert.assertEquals(3, count); + close(resultSet); + } + + @Test + public void case06_selectValue03() throws SQLException { + ResultSet resultSet = statement.executeQuery("select * from jsons1 where jtag->'tag1'<=11"); + int count = 0; + while (resultSet.next()) { + count++; + } + Assert.assertEquals(3, count); + close(resultSet); + } + + @Test + public void case06_selectValue04() throws SQLException { + ResultSet resultSet = statement.executeQuery("select * from jsons1 where jtag->'tag1'>4"); + int count = 0; + while (resultSet.next()) { + count++; + } + Assert.assertEquals(2, count); + close(resultSet); + } + + @Test + public void case06_selectValue05() throws SQLException { + ResultSet resultSet = statement.executeQuery("select * from jsons1 where jtag->'tag1'>=5"); + int count = 0; + while (resultSet.next()) { + count++; + } + Assert.assertEquals(2, count); + close(resultSet); + } + + @Test + public void case06_selectValue06() throws SQLException { + ResultSet resultSet = statement.executeQuery("select * from jsons1 where jtag->'tag1'!=5"); + int count = 0; + while (resultSet.next()) { + count++; + } + Assert.assertEquals(2, count); + close(resultSet); + } + + @Test + public void case06_selectValue07() throws SQLException { + ResultSet resultSet = statement.executeQuery("select * from jsons1 where jtag->'tag1'!=55"); + int count = 0; + while (resultSet.next()) { + count++; + } + Assert.assertEquals(3, count); + close(resultSet); + } + + @Test + public void case06_selectValue08() throws SQLException { + ResultSet resultSet = statement.executeQuery("select * from jsons1 where jtag->'tag1'=10"); + int count = 0; + while (resultSet.next()) { + count++; + } + Assert.assertEquals(0, count); + close(resultSet); + } + + // where json value is double + @Test + public void case07_selectValue01() throws SQLException { + ResultSet resultSet = statement.executeQuery("select * from jsons1 where jtag->'tag1'=1.232"); + int count = 0; + while (resultSet.next()) { + count++; + } + Assert.assertEquals(1, count); + close(resultSet); + } + + @Test + public void case07_doubleOperation01() throws SQLException { + ResultSet resultSet = statement.executeQuery("select * from jsons1 where jtag->'tag1'<1.232"); + int count = 0; + while (resultSet.next()) { + count++; + } + Assert.assertEquals(0, count); + close(resultSet); + } + + @Test + public void case07_doubleOperation02() throws SQLException { + ResultSet resultSet = statement.executeQuery("select * from jsons1 where jtag->'tag1'<=1.232"); + int count = 0; + while (resultSet.next()) { + count++; + } + Assert.assertEquals(1, count); + close(resultSet); + } + + @Test + public void case07_doubleOperation03() throws SQLException { + ResultSet resultSet = statement.executeQuery("select * from jsons1 where jtag->'tag1'>1.23"); + int count = 0; + while (resultSet.next()) { + count++; + } + Assert.assertEquals(3, count); + close(resultSet); + } + + @Test + public void case07_doubleOperation04() throws SQLException { + ResultSet resultSet = statement.executeQuery("select * from jsons1 where jtag->'tag1'>=1.232"); + int count = 0; + while (resultSet.next()) { + count++; + } + Assert.assertEquals(3, count); + close(resultSet); + } + + @Test + public void case07_doubleOperation05() throws SQLException { + ResultSet resultSet = statement.executeQuery("select * from jsons1 where jtag->'tag1'!=1.232"); + int count = 0; + while (resultSet.next()) { + count++; + } + Assert.assertEquals(2, count); + close(resultSet); + } + + @Test + public void case07_doubleOperation06() throws SQLException { + ResultSet resultSet = statement.executeQuery("select * from jsons1 where jtag->'tag1'!=3.232"); + int count = 0; + while (resultSet.next()) { + count++; + } + Assert.assertEquals(3, count); + close(resultSet); + } + + @Test(expected = SQLException.class) + public void case07_doubleOperation07() throws SQLException { + statement.executeQuery("select * from jsons1 where jtag->'tag1'/0=3"); + } + + @Test(expected = SQLException.class) + public void case07_doubleOperation08() throws SQLException { + statement.executeQuery("select * from jsons1 where jtag->'tag1'/5=1"); + } + + @Test + public void case08_boolOperation01() throws SQLException { + ResultSet resultSet = statement.executeQuery("select * from jsons1 where jtag->'tag1'=true"); + int count = 0; + while (resultSet.next()) { + count++; + } + Assert.assertEquals(0, count); + close(resultSet); + } + + @Test + public void case08_boolOperation02() throws SQLException { + ResultSet resultSet = statement.executeQuery("select * from jsons1 where jtag->'tag1'=false"); + int count = 0; + while (resultSet.next()) { + count++; + } + Assert.assertEquals(1, count); + close(resultSet); + } + + @Test + public void case08_boolOperation03() throws SQLException { + ResultSet resultSet = statement.executeQuery("select * from jsons1 where jtag->'tag1'!=false"); + int count = 0; + while (resultSet.next()) { + count++; + } + Assert.assertEquals(0, count); + close(resultSet); + } + + @Test(expected = SQLException.class) + public void case08_boolOperation04() throws SQLException { + statement.executeQuery("select * from jsons1 where jtag->'tag1'>false"); + } + + // where json value is null + @Test + public void case09_select01() throws SQLException { + ResultSet resultSet = statement.executeQuery("select * from jsons1 where jtag->'tag1'=null"); + int count = 0; + while (resultSet.next()) { + count++; + } + Assert.assertEquals(1, count); + close(resultSet); + } + + @Test + public void case09_select02() throws SQLException { + ResultSet resultSet = statement.executeQuery("select * from jsons1 where jtag is null"); + int count = 0; + while (resultSet.next()) { + count++; + } + Assert.assertEquals(1, count); + close(resultSet); + } + + @Test + public void case09_select03() throws SQLException { + ResultSet resultSet = statement.executeQuery("select * from jsons1 where jtag is not null"); + int count = 0; + while (resultSet.next()) { + count++; + } + Assert.assertEquals(8, count); + close(resultSet); + } + + @Test + public void case09_select04() throws SQLException { + ResultSet resultSet = statement.executeQuery("select * from jsons1 where jtag->'tag_no_exist'=3"); + int count = 0; + while (resultSet.next()) { + count++; + } + Assert.assertEquals(0, count); + close(resultSet); + } + + @Test + public void case09_select05() throws SQLException { + ResultSet resultSet = statement.executeQuery("select * from jsons1 where jtag->'tag1' is null"); + int count = 0; + while (resultSet.next()) { + count++; + } + Assert.assertEquals(invalidJsonInsertSql.length, count); + close(resultSet); + } + + @Test + public void case09_select06() throws SQLException { + ResultSet resultSet = statement.executeQuery("select * from jsons1 where jtag->'tag4' is null"); + int count = 0; + while (resultSet.next()) { + count++; + } + Assert.assertEquals(sql.length + invalidJsonInsertSql.length, count); + close(resultSet); + } + + @Test + public void case09_select07() throws SQLException { + ResultSet resultSet = statement.executeQuery("select * from jsons1 where jtag->'tag3' is not null"); + int count = 0; + while (resultSet.next()) { + count++; + } + Assert.assertEquals(4, count); + close(resultSet); + } + + // test ? + @Test + public void case09_select10() throws SQLException { + ResultSet resultSet = statement.executeQuery("select * from jsons1 where jtag contains 'tag1'"); + int count = 0; + while (resultSet.next()) { + count++; + } + Assert.assertEquals(8, count); + close(resultSet); + } + + @Test + public void case09_select11() throws SQLException { + ResultSet resultSet = statement.executeQuery("select * from jsons1 where jtag contains 'tag3'"); + int count = 0; + while (resultSet.next()) { + count++; + } + Assert.assertEquals(4, count); + close(resultSet); + } + + @Test + public void case09_select12() throws SQLException { + ResultSet resultSet = statement.executeQuery("select * from jsons1 where jtag contains 'tag_no_exist'"); + int count = 0; + while (resultSet.next()) { + count++; + } + Assert.assertEquals(0, count); + close(resultSet); + } + + // test json tag in where condition with and/or + @Test + public void case10_selectAndOr01() throws SQLException { + ResultSet resultSet = statement.executeQuery("select * from jsons1 where jtag->'tag1'=false and jtag->'tag2'='beijing'"); + int count = 0; + while (resultSet.next()) { + count++; + } + Assert.assertEquals(1, count); + close(resultSet); + } + + @Test + public void case10_selectAndOr02() throws SQLException { + ResultSet resultSet = statement.executeQuery("select * from jsons1 where jtag->'tag1'=false or jtag->'tag2'='beijing'"); + int count = 0; + while (resultSet.next()) { + count++; + } + Assert.assertEquals(2, count); + close(resultSet); + } + + @Test + public void case10_selectAndOr03() throws SQLException { + ResultSet resultSet = statement.executeQuery("select * from jsons1 where jtag->'tag1'=false and jtag->'tag2'='shanghai'"); + int count = 0; + while (resultSet.next()) { + count++; + } + Assert.assertEquals(0, count); + close(resultSet); + } + + @Test + public void case10_selectAndOr04() throws SQLException { + ResultSet resultSet = statement.executeQuery("select * from jsons1 where jtag->'tag1'=13 or jtag->'tag2'>35"); + int count = 0; + while (resultSet.next()) { + count++; + } + Assert.assertEquals(0, count); + close(resultSet); + } + + @Test + public void case10_selectAndOr05() throws SQLException { + ResultSet resultSet = statement.executeQuery("select * from jsons1 where jtag->'tag1' is not null and jtag contains 'tag3'"); + int count = 0; + while (resultSet.next()) { + count++; + } + Assert.assertEquals(4, count); + close(resultSet); + } + + @Test + public void case10_selectAndOr06() throws SQLException { + ResultSet resultSet = statement.executeQuery("select * from jsons1 where jtag->'tag1'='femail' and jtag contains 'tag3'"); + int count = 0; + while (resultSet.next()) { + count++; + } + Assert.assertEquals(2, count); + close(resultSet); + } + + // test with tbname/normal column + @Test + public void case11_selectTbName01() throws SQLException { + ResultSet resultSet = statement.executeQuery("select * from jsons1 where tbname = 'jsons1_1'"); + int count = 0; + while (resultSet.next()) { + count++; + } + Assert.assertEquals(2, count); + close(resultSet); + } + + @Test + public void case11_selectTbName02() throws SQLException { + ResultSet resultSet = statement.executeQuery("select * from jsons1 where tbname = 'jsons1_1' and jtag contains 'tag3'"); + int count = 0; + while (resultSet.next()) { + count++; + } + Assert.assertEquals(2, count); + close(resultSet); + } + + @Test + public void case11_selectTbName03() throws SQLException { + ResultSet resultSet = statement.executeQuery("select * from jsons1 where tbname = 'jsons1_1' and jtag contains 'tag3' and dataint=3"); + int count = 0; + while (resultSet.next()) { + count++; + } + Assert.assertEquals(0, count); + close(resultSet); + } + + @Test + public void case11_selectTbName04() throws SQLException { + ResultSet resultSet = statement.executeQuery("select * from jsons1 where tbname = 'jsons1_1' and jtag contains 'tag3' and dataint=23"); + int count = 0; + while (resultSet.next()) { + count++; + } + Assert.assertEquals(1, count); + close(resultSet); + } + + // test where condition like + @Test + public void case12_selectWhere01() throws SQLException { + ResultSet resultSet = statement.executeQuery("select *,tbname from jsons1 where jtag->'tag2' like 'bei%'"); + int count = 0; + while (resultSet.next()) { + count++; + } + Assert.assertEquals(2, count); + close(resultSet); + } + + @Test + public void case12_selectWhere02() throws SQLException { + ResultSet resultSet = statement.executeQuery("select *,tbname from jsons1 where jtag->'tag1' like 'fe%' and jtag->'tag2' is not null"); + int count = 0; + while (resultSet.next()) { + count++; + } + Assert.assertEquals(2, count); + close(resultSet); + } + + // test where condition in no support in + @Test(expected = SQLException.class) + public void case12_selectWhere03() throws SQLException { + statement.executeQuery("select * from jsons1 where jtag->'tag1' in ('beijing')"); + } + + // test where condition match + @Test + public void case12_selectWhere04() throws SQLException { + ResultSet resultSet = statement.executeQuery("select * from jsons1 where jtag->'tag1' match 'ma'"); + int count = 0; + while (resultSet.next()) { + count++; + } + Assert.assertEquals(2, count); + close(resultSet); + } + + @Test + public void case12_selectWhere05() throws SQLException { + ResultSet resultSet = statement.executeQuery("select * from jsons1 where jtag->'tag1' match 'ma$'"); + int count = 0; + while (resultSet.next()) { + count++; + } + Assert.assertEquals(0, count); + close(resultSet); + } + + @Test + public void case12_selectWhere06() throws SQLException { + ResultSet resultSet = statement.executeQuery("select * from jsons1 where jtag->'tag2' match 'jing$'"); + int count = 0; + while (resultSet.next()) { + count++; + } + Assert.assertEquals(2, count); + close(resultSet); + } + + @Test + public void case12_selectWhere07() throws SQLException { + ResultSet resultSet = statement.executeQuery("select * from jsons1 where jtag->'tag1' match '收到'"); + int count = 0; + while (resultSet.next()) { + count++; + } + Assert.assertEquals(1, count); + close(resultSet); + } + + // test distinct + @Test + public void case13_selectDistinct01() throws SQLException { + statement.execute("insert into jsons1_14 using jsons1 tags('{\"tag1\":\"收到货\",\"tag2\":\"\",\"tag3\":null}') values(1591062628000, 2, NULL, '你就会', 'dws')"); + } + + @Test + public void case13_selectDistinct02() throws SQLException { + ResultSet resultSet = statement.executeQuery("select distinct jtag->'tag1' from jsons1"); + int count = 0; + while (resultSet.next()) { + count++; + } + Assert.assertEquals(8, count); + close(resultSet); + } + + @Test + public void case13_selectDistinct03() throws SQLException { + ResultSet resultSet = statement.executeQuery("select distinct jtag from jsons1"); + int count = 0; + while (resultSet.next()) { + count++; + } + Assert.assertEquals(9, count); + close(resultSet); + } + + // test dumplicate key with normal colomn + @Test + public void case14_selectDump01() throws SQLException { + statement.execute("INSERT INTO jsons1_15 using jsons1 tags('{\"tbname\":\"tt\",\"databool\":true,\"datastr\":\"是是是\"}') values(1591060828000, 4, false, 'jjsf', \"你就会\")"); + } + + @Test + public void case14_selectDump02() throws SQLException { + ResultSet resultSet = statement.executeQuery("select *,tbname,jtag from jsons1 where jtag->'datastr' match '是' and datastr match 'js'"); + int count = 0; + while (resultSet.next()) { + count++; + } + Assert.assertEquals(1, count); + close(resultSet); + } + + @Test + public void case14_selectDump03() throws SQLException { + ResultSet resultSet = statement.executeQuery("select tbname,jtag->'tbname' from jsons1 where jtag->'tbname'='tt' and tbname='jsons1_14'"); + int count = 0; + while (resultSet.next()) { + count++; + } + Assert.assertEquals(0, count); + close(resultSet); + } + + // test join + @Test + public void case15_selectJoin01() throws SQLException { + statement.execute("create table if not exists jsons2(ts timestamp, dataInt int, dataBool bool, dataStr nchar(50), dataStrBin binary(150)) tags(jtag json)"); + statement.execute("insert into jsons2_1 using jsons2 tags('{\"tag1\":\"fff\",\"tag2\":5, \"tag3\":true}') values(1591060618000, 2, false, 'json2', '你是2')"); + statement.execute("insert into jsons2_2 using jsons2 tags('{\"tag1\":5,\"tag2\":null}') values (1591060628000, 2, true, 'json2', 'sss')"); + + statement.execute("create table if not exists jsons3(ts timestamp, dataInt int, dataBool bool, dataStr nchar(50), dataStrBin binary(150)) tags(jtag json)"); + statement.execute("insert into jsons3_1 using jsons3 tags('{\"tag1\":\"fff\",\"tag2\":5, \"tag3\":true}') values(1591060618000, 3, false, 'json3', '你是3')"); + statement.execute("insert into jsons3_2 using jsons3 tags('{\"tag1\":5,\"tag2\":\"beijing\"}') values (1591060638000, 2, true, 'json3', 'sss')"); + } + + // TODO check result + @Test + public void case15_selectJoin02() throws SQLException { + ResultSet resultSet = statement.executeQuery("select 'sss',33,a.jtag->'tag3' from jsons2 a,jsons3 b where a.ts=b.ts and a.jtag->'tag1'=b.jtag->'tag1'"); + + close(resultSet); + } + + // test group by & order by json tag + // TODO check other result + @Test + public void case16_selectGroupOrder01() throws SQLException { + ResultSet resultSet = statement.executeQuery("select count(*) from jsons1 group by jtag->'tag1' order by jtag->'tag1' desc"); + int count = 0; + while (resultSet.next()) { + count++; + } + Assert.assertEquals(8, count); + close(resultSet); + } + + @Test + public void case16_selectGroupOrder02() throws SQLException { + ResultSet resultSet = statement.executeQuery("select count(*) from jsons1 group by jtag->'tag1' order by jtag->'tag1' asc"); + int count = 0; + while (resultSet.next()) { + count++; + } + Assert.assertEquals(8, count); + close(resultSet); + } + + // test stddev with group by json tag + // TODO check result + @Test + public void case17_selectStddev01() throws SQLException { + ResultSet resultSet = statement.executeQuery("select stddev(dataint) from jsons1 group by jtag->'tag1'"); + String s = ""; + int count = 0; + while (resultSet.next()) { + count++; + s = resultSet.getString(2); + + } + Assert.assertEquals(8, count); + Assert.assertEquals("\"femail\"", s); + close(resultSet); + } + + // subquery with json tag + @Test + public void case18_selectSubquery01() throws SQLException { + ResultSet resultSet = statement.executeQuery("select * from (select jtag, dataint from jsons1)"); + int count = 0; + while (resultSet.next()) { + count++; + } + Assert.assertEquals(11, count); + close(resultSet); + } + + @Test + public void case18_selectSubquery02() throws SQLException { + ResultSet resultSet = statement.executeQuery("select jtag->'tag1' from (select jtag->'tag1', dataint from jsons1)"); + int count = 0; + while (resultSet.next()) { + count++; + } + Assert.assertEquals(11, count); + close(resultSet); + } + + @Test + public void case18_selectSubquery03() throws SQLException { + ResultSet resultSet = statement.executeQuery("select jtag->'tag1' from (select jtag->'tag1', dataint from jsons1)"); + ResultSetMetaData metaData = resultSet.getMetaData(); + String columnName = metaData.getColumnName(1); + Assert.assertEquals("jtag->'tag1'", columnName); + close(resultSet); + } + + @Test + public void case18_selectSubquery04() throws SQLException { + ResultSet resultSet = statement.executeQuery("select ts,tbname,jtag->'tag1' from (select jtag->'tag1',tbname,ts from jsons1 order by ts)"); + int count = 0; + while (resultSet.next()) { + count++; + } + Assert.assertEquals(11, count); + close(resultSet); + } + + private void close(ResultSet resultSet) { + try { + if (null != resultSet) { + resultSet.close(); + } + } catch (SQLException e) { + e.printStackTrace(); + } + } + + @BeforeClass + public static void beforeClass() { + String host = "127.0.0.1"; + final String url = "jdbc:TAOS://" + host + ":6030/?user=root&password=taosdata"; + try { + connection = DriverManager.getConnection(url); + statement = connection.createStatement(); + statement.execute("drop database if exists " + dbname); + statement.execute("create database if not exists " + dbname); + statement.execute("use " + dbname); + statement.execute(superSql); + } catch (SQLException e) { + e.printStackTrace(); + } + } + + @AfterClass + public static void afterClass() { + try { + if (null != statement) { + statement.execute("drop database " + dbname); + statement.close(); + } + if (null != connection) { + connection.close(); + } + } catch (SQLException e) { + e.printStackTrace(); + } + + } +} 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/connector/python/taos/bind.py b/src/connector/python/taos/bind.py index 083ddc99aea8dc6f39b1f22ac5f77d2584a2fe69..05659714ef86da3bda383bfe7d7b25403848637f 100644 --- a/src/connector/python/taos/bind.py +++ b/src/connector/python/taos/bind.py @@ -124,6 +124,21 @@ class TaosBind(ctypes.Structure): self.buffer_length = length self.length = pointer(c_size_t(self.buffer_length)) + def json(self, value): + buffer = None + length = 0 + if isinstance(value, str): + bytes = value.encode("utf-8") + buffer = create_string_buffer(bytes) + length = len(bytes) + else: + buffer = value + length = len(value) + self.buffer_type = FieldType.C_JSON + self.buffer = cast(buffer, c_void_p) + self.buffer_length = length + self.length = pointer(c_size_t(self.buffer_length)) + def tinyint_unsigned(self, value): self.buffer_type = FieldType.C_TINYINT_UNSIGNED self.buffer = cast(pointer(c_uint8(value)), c_void_p) @@ -356,6 +371,11 @@ class TaosMultiBind(ctypes.Structure): self.buffer_type = FieldType.C_NCHAR self._str_to_buffer(values) + def json(self, values): + # type: (list[str]) -> None + self.buffer_type = FieldType.C_JSON + self._str_to_buffer(values) + def tinyint_unsigned(self, values): self.buffer_type = FieldType.C_TINYINT_UNSIGNED self.buffer_length = sizeof(c_uint8) diff --git a/src/connector/python/taos/constants.py b/src/connector/python/taos/constants.py index 8ad5b69fc099718fa4f4b8c08cf689b17663eae0..34044a15fc0cd73323552f1b4b8c280d6cad5a9b 100644 --- a/src/connector/python/taos/constants.py +++ b/src/connector/python/taos/constants.py @@ -25,6 +25,7 @@ class FieldType(object): C_SMALLINT_UNSIGNED = 12 C_INT_UNSIGNED = 13 C_BIGINT_UNSIGNED = 14 + C_JSON = 15 # NULL value definition # NOTE: These values should change according to C definition in tsdb.h C_BOOL_NULL = 0x02 diff --git a/src/connector/python/taos/cursor.py b/src/connector/python/taos/cursor.py index 5d21ff95af5d81367e7143d001cc688d90877b67..a8d82bea2ea188f8a08d6603dd33735ea0a0a5af 100644 --- a/src/connector/python/taos/cursor.py +++ b/src/connector/python/taos/cursor.py @@ -188,6 +188,9 @@ class TaosCursor(object): if dataType.upper() == "NCHAR": if self._description[col][1] == FieldType.C_NCHAR: return True + if dataType.upper() == "JSON": + if self._description[col][1] == FieldType.C_JSON: + return True return False diff --git a/src/connector/python/taos/field.py b/src/connector/python/taos/field.py index f6fa28e8336fa53a137ce7bd9a25b99a32263f1b..a6d64422e238b46b096a5ae62c42566666f226ad 100644 --- a/src/connector/python/taos/field.py +++ b/src/connector/python/taos/field.py @@ -207,6 +207,7 @@ CONVERT_FUNC = { FieldType.C_SMALLINT_UNSIGNED: _crow_smallint_unsigned_to_python, FieldType.C_INT_UNSIGNED: _crow_int_unsigned_to_python, FieldType.C_BIGINT_UNSIGNED: _crow_bigint_unsigned_to_python, + FieldType.C_JSON: _crow_nchar_to_python, } CONVERT_FUNC_BLOCK = { @@ -224,6 +225,7 @@ CONVERT_FUNC_BLOCK = { FieldType.C_SMALLINT_UNSIGNED: _crow_smallint_unsigned_to_python, FieldType.C_INT_UNSIGNED: _crow_int_unsigned_to_python, FieldType.C_BIGINT_UNSIGNED: _crow_bigint_unsigned_to_python, + FieldType.C_JSON: _crow_nchar_to_python_block, } # Corresponding TAOS_FIELD structure in C diff --git a/src/dnode/src/dnodeMain.c b/src/dnode/src/dnodeMain.c index bc6631284593c74e12842b4c6ea9994d099c3dd9..420f462051687c72019d7c0697a23c940e4b8ae0 100644 --- a/src/dnode/src/dnodeMain.c +++ b/src/dnode/src/dnodeMain.c @@ -170,7 +170,6 @@ int32_t dnodeInitSystem() { taosResolveCRC(); taosInitGlobalCfg(); taosReadGlobalLogCfg(); - taosSetCoreDump(); dnodeInitTmr(); if (dnodeCreateDir(tsLogDir) < 0) { @@ -190,6 +189,7 @@ int32_t dnodeInitSystem() { return -1; } + taosSetCoreDump(); dInfo("start to initialize TDengine"); taosInitNotes(); diff --git a/src/inc/taos.h b/src/inc/taos.h index 910ec8c7d83b1f01ce4b14dcdcc718cc0fdbc1f9..2b74f9c1844641ccef5ad1fb8e9d25a4d3262ecc 100644 --- a/src/inc/taos.h +++ b/src/inc/taos.h @@ -46,6 +46,7 @@ typedef void **TAOS_ROW; #define TSDB_DATA_TYPE_USMALLINT 12 // 2 bytes #define TSDB_DATA_TYPE_UINT 13 // 4 bytes #define TSDB_DATA_TYPE_UBIGINT 14 // 8 bytes +#define TSDB_DATA_TYPE_JSON 15 // json string typedef enum { TSDB_OPTION_LOCALE, diff --git a/src/inc/taosdef.h b/src/inc/taosdef.h index f05d1466371f32358e3442f53735028b20641d16..b7c628a1189c1c9f368d4079de6a2e1078e2cfa8 100644 --- a/src/inc/taosdef.h +++ b/src/inc/taosdef.h @@ -39,7 +39,7 @@ extern "C" { #define TSKEY_INITIAL_VAL INT64_MIN // Bytes for each type. -extern const int32_t TYPE_BYTES[15]; +extern const int32_t TYPE_BYTES[16]; // TODO: replace and remove code below #define CHAR_BYTES sizeof(char) @@ -70,6 +70,11 @@ extern const int32_t TYPE_BYTES[15]; #define TSDB_DATA_DOUBLE_NULL 0x7FFFFF0000000000L // an NAN #define TSDB_DATA_NCHAR_NULL 0xFFFFFFFF #define TSDB_DATA_BINARY_NULL 0xFF +#define TSDB_DATA_JSON_PLACEHOLDER 0x7F +#define TSDB_DATA_JSON_NULL 0xFFFFFFFF +#define TSDB_DATA_JSON_null 0xFFFFFFFE +#define TSDB_DATA_JSON_NOT_NULL 0x01 +#define TSDB_DATA_JSON_CAN_NOT_COMPARE 0x7FFFFFFF #define TSDB_DATA_UTINYINT_NULL 0xFF #define TSDB_DATA_USMALLINT_NULL 0xFFFF @@ -176,6 +181,9 @@ do { \ #define TSDB_RELATION_MATCH 14 #define TSDB_RELATION_NMATCH 15 +#define TSDB_RELATION_CONTAINS 16 +#define TSDB_RELATION_ARROW 17 + #define TSDB_BINARY_OP_ADD 30 #define TSDB_BINARY_OP_SUBTRACT 31 #define TSDB_BINARY_OP_MULTIPLY 32 @@ -222,8 +230,11 @@ do { \ */ #define TSDB_MAX_BYTES_PER_ROW 49151 #define TSDB_MAX_TAGS_LEN 16384 +#define TSDB_MAX_JSON_TAGS_LEN (4096*TSDB_NCHAR_SIZE + 2 + 1) // 2->var_header_len 1->type #define TSDB_MAX_TAGS 128 #define TSDB_MAX_TAG_CONDITIONS 1024 +#define TSDB_MAX_JSON_KEY_LEN 256 +#define TSDB_MAX_JSON_KEY_MD5_LEN 16 #define TSDB_AUTH_LEN 16 #define TSDB_KEY_LEN 16 diff --git a/src/inc/taoserror.h b/src/inc/taoserror.h index 39498ab3aa71b2a23acb979aae72f5950ae11690..8700cf246a91655c307bbb4c3c2c111d3271fc67 100644 --- a/src/inc/taoserror.h +++ b/src/inc/taoserror.h @@ -250,48 +250,48 @@ int32_t* taosGetErrno(); #define TSDB_CODE_VND_INVALID_TSDB_STATE TAOS_DEF_ERROR_CODE(0, 0x0514) //"Invalid tsdb state" // tsdb -#define TSDB_CODE_TDB_INVALID_TABLE_ID TAOS_DEF_ERROR_CODE(0, 0x0600) //"Invalid table ID" -#define TSDB_CODE_TDB_INVALID_TABLE_TYPE TAOS_DEF_ERROR_CODE(0, 0x0601) //"Invalid table type" -#define TSDB_CODE_TDB_IVD_TB_SCHEMA_VERSION TAOS_DEF_ERROR_CODE(0, 0x0602) //"Invalid table schema version" -#define TSDB_CODE_TDB_TABLE_ALREADY_EXIST TAOS_DEF_ERROR_CODE(0, 0x0603) //"Table already exists" -#define TSDB_CODE_TDB_INVALID_CONFIG TAOS_DEF_ERROR_CODE(0, 0x0604) //"Invalid configuration" -#define TSDB_CODE_TDB_INIT_FAILED TAOS_DEF_ERROR_CODE(0, 0x0605) //"Tsdb init failed" -#define TSDB_CODE_TDB_NO_DISKSPACE TAOS_DEF_ERROR_CODE(0, 0x0606) //"No diskspace for tsdb" -#define TSDB_CODE_TDB_NO_DISK_PERMISSIONS TAOS_DEF_ERROR_CODE(0, 0x0607) //"No permission for disk files" -#define TSDB_CODE_TDB_FILE_CORRUPTED TAOS_DEF_ERROR_CODE(0, 0x0608) //"Data file(s) corrupted" -#define TSDB_CODE_TDB_OUT_OF_MEMORY TAOS_DEF_ERROR_CODE(0, 0x0609) //"Out of memory" -#define TSDB_CODE_TDB_TAG_VER_OUT_OF_DATE TAOS_DEF_ERROR_CODE(0, 0x060A) //"Tag too old" -#define TSDB_CODE_TDB_TIMESTAMP_OUT_OF_RANGE TAOS_DEF_ERROR_CODE(0, 0x060B) //"Timestamp data out of range" -#define TSDB_CODE_TDB_SUBMIT_MSG_MSSED_UP TAOS_DEF_ERROR_CODE(0, 0x060C) //"Submit message is messed up" -#define TSDB_CODE_TDB_INVALID_ACTION TAOS_DEF_ERROR_CODE(0, 0x060D) //"Invalid operation" -#define TSDB_CODE_TDB_INVALID_CREATE_TB_MSG TAOS_DEF_ERROR_CODE(0, 0x060E) //"Invalid creation of table" -#define TSDB_CODE_TDB_NO_TABLE_DATA_IN_MEM TAOS_DEF_ERROR_CODE(0, 0x060F) //"No table data in memory skiplist" -#define TSDB_CODE_TDB_FILE_ALREADY_EXISTS TAOS_DEF_ERROR_CODE(0, 0x0610) //"File already exists" -#define TSDB_CODE_TDB_TABLE_RECONFIGURE TAOS_DEF_ERROR_CODE(0, 0x0611) //"Need to reconfigure table" -#define TSDB_CODE_TDB_IVD_CREATE_TABLE_INFO TAOS_DEF_ERROR_CODE(0, 0x0612) //"Invalid information to create table" -#define TSDB_CODE_TDB_NO_AVAIL_DISK TAOS_DEF_ERROR_CODE(0, 0x0613) //"No available disk" -#define TSDB_CODE_TDB_MESSED_MSG TAOS_DEF_ERROR_CODE(0, 0x0614) //"TSDB messed message" -#define TSDB_CODE_TDB_IVLD_TAG_VAL TAOS_DEF_ERROR_CODE(0, 0x0615) //"TSDB invalid tag value" -#define TSDB_CODE_TDB_NO_CACHE_LAST_ROW TAOS_DEF_ERROR_CODE(0, 0x0616) //"TSDB no cache last row data" -#define TSDB_CODE_TDB_INCOMPLETE_DFILESET TAOS_DEF_ERROR_CODE(0, 0x0617) //"TSDB incomplete DFileSet" +#define TSDB_CODE_TDB_INVALID_TABLE_ID TAOS_DEF_ERROR_CODE(0, 0x0600) //"Invalid table ID") +#define TSDB_CODE_TDB_INVALID_TABLE_TYPE TAOS_DEF_ERROR_CODE(0, 0x0601) //"Invalid table type") +#define TSDB_CODE_TDB_IVD_TB_SCHEMA_VERSION TAOS_DEF_ERROR_CODE(0, 0x0602) //"Invalid table schema version") +#define TSDB_CODE_TDB_TABLE_ALREADY_EXIST TAOS_DEF_ERROR_CODE(0, 0x0603) //"Table already exists") +#define TSDB_CODE_TDB_INVALID_CONFIG TAOS_DEF_ERROR_CODE(0, 0x0604) //"Invalid configuration") +#define TSDB_CODE_TDB_INIT_FAILED TAOS_DEF_ERROR_CODE(0, 0x0605) //"Tsdb init failed") +#define TSDB_CODE_TDB_NO_DISKSPACE TAOS_DEF_ERROR_CODE(0, 0x0606) //"No diskspace for tsdb") +#define TSDB_CODE_TDB_NO_DISK_PERMISSIONS TAOS_DEF_ERROR_CODE(0, 0x0607) //"No permission for disk files") +#define TSDB_CODE_TDB_FILE_CORRUPTED TAOS_DEF_ERROR_CODE(0, 0x0608) //"Data file(s) corrupted") +#define TSDB_CODE_TDB_OUT_OF_MEMORY TAOS_DEF_ERROR_CODE(0, 0x0609) //"Out of memory") +#define TSDB_CODE_TDB_TAG_VER_OUT_OF_DATE TAOS_DEF_ERROR_CODE(0, 0x060A) //"Tag too old") +#define TSDB_CODE_TDB_TIMESTAMP_OUT_OF_RANGE TAOS_DEF_ERROR_CODE(0, 0x060B) //"Timestamp data out of range") +#define TSDB_CODE_TDB_SUBMIT_MSG_MSSED_UP TAOS_DEF_ERROR_CODE(0, 0x060C) //"Submit message is messed up") +#define TSDB_CODE_TDB_INVALID_ACTION TAOS_DEF_ERROR_CODE(0, 0x060D) //"Invalid operation") +#define TSDB_CODE_TDB_INVALID_CREATE_TB_MSG TAOS_DEF_ERROR_CODE(0, 0x060E) //"Invalid creation of table") +#define TSDB_CODE_TDB_NO_TABLE_DATA_IN_MEM TAOS_DEF_ERROR_CODE(0, 0x060F) //"No table data in memory skiplist") +#define TSDB_CODE_TDB_FILE_ALREADY_EXISTS TAOS_DEF_ERROR_CODE(0, 0x0610) //"File already exists") +#define TSDB_CODE_TDB_TABLE_RECONFIGURE TAOS_DEF_ERROR_CODE(0, 0x0611) //"Need to reconfigure table") +#define TSDB_CODE_TDB_IVD_CREATE_TABLE_INFO TAOS_DEF_ERROR_CODE(0, 0x0612) //"Invalid information to create table") +#define TSDB_CODE_TDB_NO_AVAIL_DISK TAOS_DEF_ERROR_CODE(0, 0x0613) //"No available disk") +#define TSDB_CODE_TDB_MESSED_MSG TAOS_DEF_ERROR_CODE(0, 0x0614) //"TSDB messed message") +#define TSDB_CODE_TDB_IVLD_TAG_VAL TAOS_DEF_ERROR_CODE(0, 0x0615) //"TSDB invalid tag value") +#define TSDB_CODE_TDB_NO_CACHE_LAST_ROW TAOS_DEF_ERROR_CODE(0, 0x0616) //"TSDB no cache last row data") +#define TSDB_CODE_TDB_INCOMPLETE_DFILESET TAOS_DEF_ERROR_CODE(0, 0x0617) //"TSDB incomplete DFileSet") +#define TSDB_CODE_TDB_NO_JSON_TAG_KEY TAOS_DEF_ERROR_CODE(0, 0x0618) //"TSDB no tag json key") // query -#define TSDB_CODE_QRY_INVALID_QHANDLE TAOS_DEF_ERROR_CODE(0, 0x0700) //"Invalid handle" -#define TSDB_CODE_QRY_INVALID_MSG TAOS_DEF_ERROR_CODE(0, 0x0701) //"Invalid message" // failed to validate the sql expression msg by vnode -#define TSDB_CODE_QRY_NO_DISKSPACE TAOS_DEF_ERROR_CODE(0, 0x0702) //"No diskspace for query" -#define TSDB_CODE_QRY_OUT_OF_MEMORY TAOS_DEF_ERROR_CODE(0, 0x0703) //"System out of memory" -#define TSDB_CODE_QRY_APP_ERROR TAOS_DEF_ERROR_CODE(0, 0x0704) //"Unexpected generic error in query" -#define TSDB_CODE_QRY_DUP_JOIN_KEY TAOS_DEF_ERROR_CODE(0, 0x0705) //"Duplicated join key" -#define TSDB_CODE_QRY_EXCEED_TAGS_LIMIT TAOS_DEF_ERROR_CODE(0, 0x0706) //"Tag condition too many" -#define TSDB_CODE_QRY_NOT_READY TAOS_DEF_ERROR_CODE(0, 0x0707) //"Query not ready" -#define TSDB_CODE_QRY_HAS_RSP TAOS_DEF_ERROR_CODE(0, 0x0708) //"Query should response" -#define TSDB_CODE_QRY_IN_EXEC TAOS_DEF_ERROR_CODE(0, 0x0709) //"Multiple retrieval of this query" -#define TSDB_CODE_QRY_TOO_MANY_TIMEWINDOW TAOS_DEF_ERROR_CODE(0, 0x070A) //"Too many time window in query" -#define TSDB_CODE_QRY_NOT_ENOUGH_BUFFER TAOS_DEF_ERROR_CODE(0, 0x070B) //"Query buffer limit has reached" -#define TSDB_CODE_QRY_INCONSISTAN TAOS_DEF_ERROR_CODE(0, 0x070C) //"File inconsistency in replica" -#define TSDB_CODE_QRY_SYS_ERROR TAOS_DEF_ERROR_CODE(0, 0x070D) //"System error" -#define TSDB_CODE_QRY_INVALID_TIME_CONDITION TAOS_DEF_ERROR_CODE(0, 0x070E) //"invalid time condition" - +#define TSDB_CODE_QRY_INVALID_QHANDLE TAOS_DEF_ERROR_CODE(0, 0x0700) //"Invalid handle") +#define TSDB_CODE_QRY_INVALID_MSG TAOS_DEF_ERROR_CODE(0, 0x0701) //"Invalid message") // failed to validate the sql expression msg by vnode +#define TSDB_CODE_QRY_NO_DISKSPACE TAOS_DEF_ERROR_CODE(0, 0x0702) //"No diskspace for query") +#define TSDB_CODE_QRY_OUT_OF_MEMORY TAOS_DEF_ERROR_CODE(0, 0x0703) //"System out of memory") +#define TSDB_CODE_QRY_APP_ERROR TAOS_DEF_ERROR_CODE(0, 0x0704) //"Unexpected generic error in query") +#define TSDB_CODE_QRY_DUP_JOIN_KEY TAOS_DEF_ERROR_CODE(0, 0x0705) //"Duplicated join key") +#define TSDB_CODE_QRY_EXCEED_TAGS_LIMIT TAOS_DEF_ERROR_CODE(0, 0x0706) //"Tag condition too many") +#define TSDB_CODE_QRY_NOT_READY TAOS_DEF_ERROR_CODE(0, 0x0707) //"Query not ready") +#define TSDB_CODE_QRY_HAS_RSP TAOS_DEF_ERROR_CODE(0, 0x0708) //"Query should response") +#define TSDB_CODE_QRY_IN_EXEC TAOS_DEF_ERROR_CODE(0, 0x0709) //"Multiple retrieval of this query") +#define TSDB_CODE_QRY_TOO_MANY_TIMEWINDOW TAOS_DEF_ERROR_CODE(0, 0x070A) //"Too many time window in query") +#define TSDB_CODE_QRY_NOT_ENOUGH_BUFFER TAOS_DEF_ERROR_CODE(0, 0x070B) //"Query buffer limit has reached") +#define TSDB_CODE_QRY_INCONSISTAN TAOS_DEF_ERROR_CODE(0, 0x070C) //"File inconsistency in replica") +#define TSDB_CODE_QRY_SYS_ERROR TAOS_DEF_ERROR_CODE(0, 0x070D) //"System error") +#define TSDB_CODE_QRY_INVALID_TIME_CONDITION TAOS_DEF_ERROR_CODE(0, 0x070E) //"invalid time condition") // grant #define TSDB_CODE_GRANT_EXPIRED TAOS_DEF_ERROR_CODE(0, 0x0800) //"License expired" diff --git a/src/inc/taosmsg.h b/src/inc/taosmsg.h index 1db66f0387b02c3d02f50eef04110b23ce2d9e64..9dc76466aadbe9781dbdd727a524a32f8103650f 100644 --- a/src/inc/taosmsg.h +++ b/src/inc/taosmsg.h @@ -412,7 +412,7 @@ typedef struct SColIndex { int16_t colId; // column id int16_t colIndex; // column index in colList if it is a normal column or index in tagColList if a tag uint16_t flag; // denote if it is a tag or a normal column - char name[TSDB_COL_NAME_LEN + TSDB_TABLE_NAME_LEN + 1]; + char name[TSDB_COL_NAME_LEN + TSDB_TABLE_NAME_LEN + TSDB_MAX_JSON_KEY_LEN + 4 + 1]; // 4 meams ->'' for json tag } SColIndex; typedef struct SColumnFilterInfo { diff --git a/src/inc/tsdb.h b/src/inc/tsdb.h index f98e7eec31f9cea99505bada1e0e3e8729b8d139..a44e958be4345d4aa131cab8f616e0460624e8c1 100644 --- a/src/inc/tsdb.h +++ b/src/inc/tsdb.h @@ -118,7 +118,7 @@ typedef struct { void tsdbClearTableCfg(STableCfg *config); -void *tsdbGetTableTagVal(const void *pTable, int32_t colId, int16_t type, int16_t bytes); +void *tsdbGetTableTagVal(const void *pTable, int32_t colId, int16_t type); char *tsdbGetTableName(void *pTable); #define TSDB_TABLEID(_table) ((STableId*) (_table)) @@ -418,10 +418,14 @@ int tsdbCompact(STsdbRepo *pRepo); // no problem return true bool tsdbNoProblem(STsdbRepo* pRepo); - // unit of walSize: MB int tsdbCheckWal(STsdbRepo *pRepo, uint32_t walSize); +// for json tag +void* getJsonTagValueElment(void* data, char* key, int32_t keyLen, char* out, int16_t bytes); +void getJsonTagValueAll(void* data, void* dst, int16_t bytes); +char* parseTagDatatoJson(void *p); + #ifdef __cplusplus } #endif diff --git a/src/inc/ttokendef.h b/src/inc/ttokendef.h index 4b6602b4124fe5e16c60700aebf3a1a2d55c77fd..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 @@ -28,194 +29,194 @@ #define TK_TIMESTAMP 10 #define TK_BINARY 11 #define TK_NCHAR 12 -#define TK_OR 13 -#define TK_AND 14 -#define TK_NOT 15 -#define TK_EQ 16 -#define TK_NE 17 -#define TK_ISNULL 18 -#define TK_NOTNULL 19 -#define TK_IS 20 -#define TK_LIKE 21 -#define TK_MATCH 22 -#define TK_NMATCH 23 -#define TK_GLOB 24 -#define TK_BETWEEN 25 -#define TK_IN 26 -#define TK_GT 27 -#define TK_GE 28 -#define TK_LT 29 -#define TK_LE 30 -#define TK_BITAND 31 -#define TK_BITOR 32 -#define TK_LSHIFT 33 -#define TK_RSHIFT 34 -#define TK_PLUS 35 -#define TK_MINUS 36 -#define TK_DIVIDE 37 -#define TK_TIMES 38 -#define TK_STAR 39 -#define TK_SLASH 40 -#define TK_REM 41 -#define TK_CONCAT 42 -#define TK_UMINUS 43 -#define TK_UPLUS 44 -#define TK_BITNOT 45 -#define TK_SHOW 46 -#define TK_DATABASES 47 -#define TK_TOPICS 48 -#define TK_FUNCTIONS 49 -#define TK_MNODES 50 -#define TK_DNODES 51 -#define TK_ACCOUNTS 52 -#define TK_USERS 53 -#define TK_MODULES 54 -#define TK_QUERIES 55 -#define TK_CONNECTIONS 56 -#define TK_STREAMS 57 -#define TK_VARIABLES 58 -#define TK_SCORES 59 -#define TK_GRANTS 60 -#define TK_VNODES 61 -#define TK_DOT 62 -#define TK_CREATE 63 -#define TK_TABLE 64 -#define TK_STABLE 65 -#define TK_DATABASE 66 -#define TK_TABLES 67 -#define TK_STABLES 68 -#define TK_VGROUPS 69 -#define TK_DROP 70 -#define TK_TOPIC 71 -#define TK_FUNCTION 72 -#define TK_DNODE 73 -#define TK_USER 74 -#define TK_ACCOUNT 75 -#define TK_USE 76 -#define TK_DESCRIBE 77 -#define TK_DESC 78 -#define TK_ALTER 79 -#define TK_PASS 80 -#define TK_PRIVILEGE 81 -#define TK_LOCAL 82 -#define TK_COMPACT 83 -#define TK_LP 84 -#define TK_RP 85 -#define TK_IF 86 -#define TK_EXISTS 87 -#define TK_AS 88 -#define TK_OUTPUTTYPE 89 -#define TK_AGGREGATE 90 -#define TK_BUFSIZE 91 -#define TK_PPS 92 -#define TK_TSERIES 93 -#define TK_DBS 94 -#define TK_STORAGE 95 -#define TK_QTIME 96 -#define TK_CONNS 97 -#define TK_STATE 98 -#define TK_COMMA 99 -#define TK_KEEP 100 -#define TK_CACHE 101 -#define TK_REPLICA 102 -#define TK_QUORUM 103 -#define TK_DAYS 104 -#define TK_MINROWS 105 -#define TK_MAXROWS 106 -#define TK_BLOCKS 107 -#define TK_CTIME 108 -#define TK_WAL 109 -#define TK_FSYNC 110 -#define TK_COMP 111 -#define TK_PRECISION 112 -#define TK_UPDATE 113 -#define TK_CACHELAST 114 -#define TK_PARTITIONS 115 -#define TK_UNSIGNED 116 -#define TK_TAGS 117 -#define TK_USING 118 -#define TK_NULL 119 -#define TK_NOW 120 -#define TK_SELECT 121 -#define TK_UNION 122 -#define TK_ALL 123 -#define TK_DISTINCT 124 -#define TK_FROM 125 -#define TK_VARIABLE 126 -#define TK_RANGE 127 -#define TK_INTERVAL 128 -#define TK_EVERY 129 -#define TK_SESSION 130 -#define TK_STATE_WINDOW 131 -#define TK_FILL 132 -#define TK_SLIDING 133 -#define TK_ORDER 134 -#define TK_BY 135 -#define TK_ASC 136 -#define TK_GROUP 137 -#define TK_HAVING 138 -#define TK_LIMIT 139 -#define TK_OFFSET 140 -#define TK_SLIMIT 141 -#define TK_SOFFSET 142 -#define TK_WHERE 143 -#define TK_RESET 144 -#define TK_QUERY 145 -#define TK_SYNCDB 146 -#define TK_ADD 147 -#define TK_COLUMN 148 -#define TK_MODIFY 149 -#define TK_TAG 150 -#define TK_CHANGE 151 -#define TK_SET 152 -#define TK_KILL 153 -#define TK_CONNECTION 154 -#define TK_STREAM 155 -#define TK_COLON 156 -#define TK_ABORT 157 -#define TK_AFTER 158 -#define TK_ATTACH 159 -#define TK_BEFORE 160 -#define TK_BEGIN 161 -#define TK_CASCADE 162 -#define TK_CLUSTER 163 -#define TK_CONFLICT 164 -#define TK_COPY 165 -#define TK_DEFERRED 166 -#define TK_DELIMITERS 167 -#define TK_DETACH 168 -#define TK_EACH 169 -#define TK_END 170 -#define TK_EXPLAIN 171 -#define TK_FAIL 172 -#define TK_FOR 173 -#define TK_IGNORE 174 -#define TK_IMMEDIATE 175 -#define TK_INITIALLY 176 -#define TK_INSTEAD 177 -#define TK_KEY 178 -#define TK_OF 179 -#define TK_RAISE 180 -#define TK_REPLACE 181 -#define TK_RESTRICT 182 -#define TK_ROW 183 -#define TK_STATEMENT 184 -#define TK_TRIGGER 185 -#define TK_VIEW 186 -#define TK_IPTOKEN 187 -#define TK_SEMI 188 -#define TK_NONE 189 -#define TK_PREV 190 -#define TK_LINEAR 191 -#define TK_IMPORT 192 -#define TK_TBNAME 193 -#define TK_JOIN 194 -#define TK_INSERT 195 -#define TK_INTO 196 -#define TK_VALUES 197 -#define TK_FILE 198 - - +#define TK_JSON 13 +#define TK_OR 14 +#define TK_AND 15 +#define TK_NOT 16 +#define TK_EQ 17 +#define TK_NE 18 +#define TK_ISNULL 19 +#define TK_NOTNULL 20 +#define TK_IS 21 +#define TK_LIKE 22 +#define TK_MATCH 23 +#define TK_NMATCH 24 +#define TK_CONTAINS 25 +#define TK_GLOB 26 +#define TK_BETWEEN 27 +#define TK_IN 28 +#define TK_GT 29 +#define TK_GE 30 +#define TK_LT 31 +#define TK_LE 32 +#define TK_BITAND 33 +#define TK_BITOR 34 +#define TK_LSHIFT 35 +#define TK_RSHIFT 36 +#define TK_PLUS 37 +#define TK_MINUS 38 +#define TK_DIVIDE 39 +#define TK_TIMES 40 +#define TK_STAR 41 +#define TK_SLASH 42 +#define TK_REM 43 +#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 diff --git a/src/inc/ttype.h b/src/inc/ttype.h index 095b593ab7d1fb74effd7991feeeb60f54cbc1b8..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) @@ -200,6 +236,8 @@ static FORCE_INLINE bool isNull(const void *val, int32_t type) { return *(uint32_t *)val == TSDB_DATA_FLOAT_NULL; case TSDB_DATA_TYPE_DOUBLE: return *(uint64_t *)val == TSDB_DATA_DOUBLE_NULL; + case TSDB_DATA_TYPE_JSON: + return varDataLen(val) == sizeof(int32_t) && *(uint32_t *) varDataVal(val) == TSDB_DATA_JSON_NULL; case TSDB_DATA_TYPE_NCHAR: return varDataLen(val) == sizeof(int32_t) && *(uint32_t*) varDataVal(val) == TSDB_DATA_NCHAR_NULL; case TSDB_DATA_TYPE_BINARY: @@ -230,10 +268,10 @@ typedef struct tDataTypeDescriptor { int (*decompFunc)(const char *const input, int compressedSize, const int nelements, char *const output, int outputSize, char algorithm, char *const buffer, int bufferSize); void (*statisFunc)(const void *pData, int32_t numofrow, int64_t *min, int64_t *max, int64_t *sum, - int16_t *minindex, int16_t *maxindex, int16_t *numofnull); + int16_t *minindex, int16_t *maxindex, int16_t *numofnull); } tDataTypeDescriptor; -extern tDataTypeDescriptor tDataTypes[15]; +extern tDataTypeDescriptor tDataTypes[16]; bool isValidDataType(int32_t type); diff --git a/src/kit/shell/src/shellEngine.c b/src/kit/shell/src/shellEngine.c index e3e86e518690c8c4f773471b93bdb381a5bb8dc1..3f672c4531921642bcf1a20888b482c98968f9c7 100644 --- a/src/kit/shell/src/shellEngine.c +++ b/src/kit/shell/src/shellEngine.c @@ -509,6 +509,7 @@ static void dumpFieldToFile(FILE* fp, const char* val, TAOS_FIELD* field, int32_ break; case TSDB_DATA_TYPE_BINARY: case TSDB_DATA_TYPE_NCHAR: + case TSDB_DATA_TYPE_JSON: memcpy(buf, val, length); buf[length] = 0; fprintf(fp, "\'%s\'", buf); @@ -645,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); @@ -692,6 +693,7 @@ static void printField(const char* val, TAOS_FIELD* field, int width, int32_t le break; case TSDB_DATA_TYPE_BINARY: case TSDB_DATA_TYPE_NCHAR: + case TSDB_DATA_TYPE_JSON: shellPrintNChar(val, length, width); break; case TSDB_DATA_TYPE_TIMESTAMP: @@ -805,7 +807,8 @@ static int calcColWidth(TAOS_FIELD* field, int precision) { return MAX(field->bytes, width); } - case TSDB_DATA_TYPE_NCHAR: { + case TSDB_DATA_TYPE_NCHAR: + case TSDB_DATA_TYPE_JSON:{ int16_t bytes = field->bytes * TSDB_NCHAR_SIZE; if (bytes > tsMaxBinaryDisplayWidth) { return MAX(tsMaxBinaryDisplayWidth, width); diff --git a/src/kit/taos-tools b/src/kit/taos-tools index 75339c5192ae0bf8e14dad7604d1d913a29d6c9b..7fca87faa5d51c7e2307ac84255a72dcbd0cf3c4 160000 --- a/src/kit/taos-tools +++ b/src/kit/taos-tools @@ -1 +1 @@ -Subproject commit 75339c5192ae0bf8e14dad7604d1d913a29d6c9b +Subproject commit 7fca87faa5d51c7e2307ac84255a72dcbd0cf3c4 diff --git a/src/plugins/monitor/src/monMain.c b/src/plugins/monitor/src/monMain.c index ed60ba42caa4a882f21b511aa8009d10d52dad52..b93d85140c230ae5b010a3559fed9488cc6b0b9f 100644 --- a/src/plugins/monitor/src/monMain.c +++ b/src/plugins/monitor/src/monMain.c @@ -21,7 +21,6 @@ #include "tlog.h" #include "ttimer.h" #include "tutil.h" -#include "tscUtil.h" #include "tsclient.h" #include "dnode.h" #include "vnode.h" diff --git a/src/query/inc/qAggMain.h b/src/query/inc/qAggMain.h index be0f6aee59de760088c8f10b9d1a5dca79882edd..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 @@ -204,7 +200,7 @@ typedef struct SQLFunctionCtx { SResultRowCellInfo *resultInfo; - int16_t colId; + int16_t colId; // used for user-specified constant value SExtTagsInfo tagInfo; SPoint1 start; SPoint1 end; @@ -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/qFilter.h b/src/query/inc/qFilter.h index e10d7fdfb4f65bb2d9ed2d14ba3e2d04f9d76706..fe9ef0f47f1e4cf353f9dfbd0e9956e7690debfe 100644 --- a/src/query/inc/qFilter.h +++ b/src/query/inc/qFilter.h @@ -105,6 +105,7 @@ typedef bool (*rangeCompFunc) (const void *, const void *, const void *, const v typedef int32_t(*filter_desc_compare_func)(const void *, const void *); typedef bool(*filter_exec_func)(void *, int32_t, int8_t**, SDataStatis *, int16_t); typedef int32_t (*filer_get_col_from_id)(void *, int32_t, void **); +typedef int32_t (*filer_get_col_from_name)(void *, int32_t, char*, void **); typedef struct SFilterRangeCompare { int64_t s; @@ -237,11 +238,12 @@ typedef struct SFilterInfo { uint32_t blkGroupNum; uint32_t *blkUnits; int8_t *blkUnitRes; - + void *pTable; + SFilterPCtx pctx; } SFilterInfo; -#define FILTER_NO_MERGE_DATA_TYPE(t) ((t) == TSDB_DATA_TYPE_BINARY || (t) == TSDB_DATA_TYPE_NCHAR) +#define FILTER_NO_MERGE_DATA_TYPE(t) ((t) == TSDB_DATA_TYPE_BINARY || (t) == TSDB_DATA_TYPE_NCHAR || (t) == TSDB_DATA_TYPE_JSON) #define FILTER_NO_MERGE_OPTR(o) ((o) == TSDB_RELATION_ISNULL || (o) == TSDB_RELATION_NOTNULL || (o) == FILTER_DUMMY_EMPTY_OPTR) #define MR_EMPTY_RES(ctx) (ctx->rs == NULL) @@ -286,6 +288,7 @@ typedef struct SFilterInfo { #define FILTER_GET_COL_FIELD_DATA(fi, ri) ((char *)(fi)->data + ((SSchema *)((fi)->desc))->bytes * (ri)) #define FILTER_GET_VAL_FIELD_TYPE(fi) (((tVariant *)((fi)->desc))->nType) #define FILTER_GET_VAL_FIELD_DATA(fi) ((char *)(fi)->data) +#define FILTER_GET_JSON_VAL_FIELD_DATA(fi) ((char *)(fi)->desc) #define FILTER_GET_TYPE(fl) ((fl) & FLD_TYPE_MAX) #define FILTER_GROUP_UNIT(i, g, uid) ((i)->units + (g)->unitIdxs[uid]) @@ -298,6 +301,7 @@ typedef struct SFilterInfo { #define FILTER_UNIT_COL_SIZE(i, u) FILTER_GET_COL_FIELD_SIZE(FILTER_UNIT_LEFT_FIELD(i, u)) #define FILTER_UNIT_COL_ID(i, u) FILTER_GET_COL_FIELD_ID(FILTER_UNIT_LEFT_FIELD(i, u)) #define FILTER_UNIT_VAL_DATA(i, u) FILTER_GET_VAL_FIELD_DATA(FILTER_UNIT_RIGHT_FIELD(i, u)) +#define FILTER_UNIT_JSON_VAL_DATA(i, u) FILTER_GET_JSON_VAL_FIELD_DATA(FILTER_UNIT_RIGHT_FIELD(i, u)) #define FILTER_UNIT_COL_IDX(u) ((u)->left.idx) #define FILTER_UNIT_OPTR(u) ((u)->compare.optr) #define FILTER_UNIT_COMP_FUNC(u) ((u)->compare.func) @@ -324,6 +328,7 @@ typedef struct SFilterInfo { extern int32_t filterInitFromTree(tExprNode* tree, void **pinfo, uint32_t options); extern bool filterExecute(SFilterInfo *info, int32_t numOfRows, int8_t** p, SDataStatis *statis, int16_t numOfCols); extern int32_t filterSetColFieldData(SFilterInfo *info, void *param, filer_get_col_from_id fp); +extern int32_t filterSetJsonColFieldData(SFilterInfo *info, void *param, filer_get_col_from_name fp); extern int32_t filterGetTimeRange(SFilterInfo *info, STimeWindow *win); extern int32_t filterConverNcharColumns(SFilterInfo* pFilterInfo, int32_t rows, bool *gotNchar); extern int32_t filterFreeNcharColumns(SFilterInfo* pFilterInfo); 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 eb3a06e01d7034ebe4ee474574aa077dcbb5e87e..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 { @@ -79,6 +81,15 @@ typedef struct tVariantListItem { uint8_t sortOrder; } tVariantListItem; +typedef struct CommonItem { + union { + tVariant pVar; + struct tSqlExpr *jsonExp; + }; + bool isJsonExp; + uint8_t sortOrder; +} CommonItem; + typedef struct SIntervalVal { int32_t token; SStrToken interval; @@ -161,7 +172,6 @@ typedef struct SAlterTableInfo { SStrToken name; int16_t tableType; int16_t type; - STagData tagData; SArray *pAddColumns; // SArray SArray *varList; // set t=val or: change src dst, SArray } SAlterTableInfo; @@ -263,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 @@ -278,6 +289,7 @@ typedef struct tSqlExprItem { bool distinct; } tSqlExprItem; +SArray *commonItemAppend(SArray *pList, tVariant *pVar, tSqlExpr *jsonExp, bool isJsonExp, uint8_t sortOrder); SArray *tVariantListAppend(SArray *pList, tVariant *pVar, uint8_t sortOrder); SArray *tVariantListInsert(SArray *pList, tVariant *pVar, uint8_t sortOrder, int32_t index); @@ -291,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/qTableMeta.h b/src/query/inc/qTableMeta.h index 422fdd13a6a6b17d63c35880eab27cad5272621a..d47189691ebbe2c4ec3ad55dd72306686586a56e 100644 --- a/src/query/inc/qTableMeta.h +++ b/src/query/inc/qTableMeta.h @@ -28,6 +28,7 @@ typedef struct STblCond { typedef struct SJoinNode { uint64_t uid; int16_t tagColId; + char tagJsonKeyName[TSDB_MAX_JSON_KEY_LEN + 1]; // for tag json key SArray* tsJoin; SArray* tagJoin; } SJoinNode; @@ -165,6 +166,7 @@ typedef struct SQueryInfo { bool stateWindow; bool globalMerge; bool multigroupResult; + bool isStddev; } SQueryInfo; /** diff --git a/src/query/inc/qUtil.h b/src/query/inc/qUtil.h index ce607f0fe20a2743579e99e71ddf78fc2e1dbcdc..0882df77c2a8bc38560269ce093568fd96467dae 100644 --- a/src/query/inc/qUtil.h +++ b/src/query/inc/qUtil.h @@ -106,5 +106,4 @@ int32_t getNumOfTotalRes(SGroupResInfo* pGroupResInfo); int32_t mergeIntoGroupResult(SGroupResInfo* pGroupResInfo, SQueryRuntimeEnv *pRuntimeEnv, int32_t* offset); int32_t initUdfInfo(SUdfInfo* pUdfInfo); - #endif // TDENGINE_QUERYUTIL_H diff --git a/src/query/inc/sql.y b/src/query/inc/sql.y index 30441334210727a87f8e1a042981be89b8de22ef..b435722d2093ce6434fe38f1af2f743885b46249 100644 --- a/src/query/inc/sql.y +++ b/src/query/inc/sql.y @@ -6,19 +6,19 @@ %default_type {SStrToken} %extra_argument {SSqlInfo* pInfo} -%fallback ID BOOL TINYINT SMALLINT INTEGER BIGINT FLOAT DOUBLE STRING TIMESTAMP BINARY NCHAR. +%fallback ID BOOL TINYINT SMALLINT INTEGER BIGINT FLOAT DOUBLE STRING TIMESTAMP BINARY NCHAR JSON. %left OR. %left AND. %right NOT. -%left EQ NE ISNULL NOTNULL IS LIKE MATCH NMATCH GLOB BETWEEN IN. +%left EQ NE ISNULL NOTNULL IS LIKE MATCH NMATCH CONTAINS GLOB BETWEEN IN. %left GT GE LT LE. %left BITAND BITOR LSHIFT RSHIFT. %left PLUS MINUS. %left DIVIDE TIMES. %left STAR SLASH REM. -%left CONCAT. %right UMINUS UPLUS BITNOT. +%right ARROW. %include { #include @@ -630,25 +630,33 @@ sliding_opt(K) ::= . {K.n = 0; K.z = NULL; K.type = 0 %type sortlist {SArray*} %destructor sortlist {taosArrayDestroy($$);} -%type sortitem {tVariant} -%destructor sortitem {tVariantDestroy(&$$);} - orderby_opt(A) ::= . {A = 0;} orderby_opt(A) ::= ORDER BY sortlist(X). {A = X;} sortlist(A) ::= sortlist(X) COMMA item(Y) sortorder(Z). { - A = tVariantListAppend(X, &Y, Z); + A = commonItemAppend(X, &Y, NULL, false, Z); +} + +sortlist(A) ::= sortlist(X) COMMA arrow(Y) sortorder(Z). { + A = commonItemAppend(X, NULL, Y, true, Z); } sortlist(A) ::= item(Y) sortorder(Z). { - A = tVariantListAppend(NULL, &Y, Z); + A = commonItemAppend(NULL, &Y, NULL, false, Z); +} + +sortlist(A) ::= arrow(Y) sortorder(Z). { + A = commonItemAppend(NULL, NULL, Y, true, Z); } %type item {tVariant} -item(A) ::= ids(X) cpxName(Y). { +item(A) ::= ID(X). { toTSDBType(X.type); - X.n += Y.n; - + tVariantCreate(&A, &X, true); +} +item(A) ::= ID(X) DOT ID(Y). { + toTSDBType(X.type); + X.n += (1+Y.n); tVariantCreate(&A, &X, true); } @@ -667,11 +675,19 @@ groupby_opt(A) ::= . { A = 0;} groupby_opt(A) ::= GROUP BY grouplist(X). { A = X;} grouplist(A) ::= grouplist(X) COMMA item(Y). { - A = tVariantListAppend(X, &Y, -1); + A = commonItemAppend(X, &Y, NULL, false, -1); +} + +grouplist(A) ::= grouplist(X) COMMA arrow(Y). { + A = commonItemAppend(X, NULL, Y, true, -1); } grouplist(A) ::= item(X). { - A = tVariantListAppend(NULL, &X, -1); + A = commonItemAppend(NULL, &X, NULL, false, -1); +} + +grouplist(A) ::= arrow(X). { + A = commonItemAppend(NULL, NULL, X, true, -1); } //having clause, ignore the input condition in having @@ -734,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);} @@ -765,6 +784,18 @@ expr(A) ::= expr(X) LIKE expr(Y). {A = tSqlExprCreate(X, Y, TK_LIKE); } expr(A) ::= expr(X) MATCH expr(Y). {A = tSqlExprCreate(X, Y, TK_MATCH); } expr(A) ::= expr(X) NMATCH expr(Y). {A = tSqlExprCreate(X, Y, TK_NMATCH); } +// contains expression +expr(A) ::= ID(X) CONTAINS STRING(Y). { tSqlExpr* S = tSqlExprCreateIdValue(pInfo, &X, TK_ID); tSqlExpr* M = tSqlExprCreateIdValue(pInfo, &Y, TK_STRING); A = tSqlExprCreate(S, M, TK_CONTAINS); } +expr(A) ::= ID(X) DOT ID(Y) CONTAINS STRING(Z). { X.n += (1+Y.n); tSqlExpr* S = tSqlExprCreateIdValue(pInfo, &X, TK_ID); tSqlExpr* M = tSqlExprCreateIdValue(pInfo, &Z, TK_STRING); A = tSqlExprCreate(S, M, TK_CONTAINS); } + +// arrow expression +%type arrow {tSqlExpr*} +%destructor arrow {tSqlExprDestroy($$);} +arrow(A) ::= ID(X) ARROW STRING(Y). {tSqlExpr* S = tSqlExprCreateIdValue(pInfo, &X, TK_ID); tSqlExpr* M = tSqlExprCreateIdValue(pInfo, &Y, TK_STRING); A = tSqlExprCreate(S, M, TK_ARROW); } +arrow(A) ::= ID(X) DOT ID(Y) ARROW STRING(Z). {X.n += (1+Y.n); tSqlExpr* S = tSqlExprCreateIdValue(pInfo, &X, TK_ID); tSqlExpr* M = tSqlExprCreateIdValue(pInfo, &Z, TK_STRING); A = tSqlExprCreate(S, M, TK_ARROW); } + +expr(A) ::= arrow(X). {A = X;} + //in expression expr(A) ::= expr(X) IN LP exprlist(Y) RP. {A = tSqlExprCreate(X, (tSqlExpr*)Y, TK_IN); } diff --git a/src/query/src/qAggMain.c b/src/query/src/qAggMain.c index 5e7a748095008d074b2a5045dc9afc443630007a..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; } @@ -2929,8 +2935,7 @@ static void date_col_output_function(SQLFunctionCtx *pCtx) { } static void col_project_function(SQLFunctionCtx *pCtx) { - // the number of output rows should not affect the final number of rows, so set it to be 0 - if (pCtx->numOfParams == 2) { + if (pCtx->colId <= TSDB_UD_COLUMN_INDEX && pCtx->colId > TSDB_RES_COL_ID) { // user-specified constant value return; } @@ -2964,6 +2969,7 @@ static void tag_project_function(SQLFunctionCtx *pCtx) { assert(pCtx->inputBytes == pCtx->outputBytes); tVariantDump(&pCtx->tag, pCtx->pOutput, pCtx->outputType, true); + char* data = pCtx->pOutput; pCtx->pOutput += pCtx->outputBytes; @@ -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 b83926414f39bec3ac2c3d1d94459d0f6d27ea37..1249f6db3082b411b6d47ecc56501cdbc90b9bed 100644 --- a/src/query/src/qExecutor.c +++ b/src/query/src/qExecutor.c @@ -30,6 +30,9 @@ #include "tscompression.h" #include "qScript.h" #include "tscLog.h" +#include "cJSON.h" +#include "tsdbMeta.h" +#include "tscUtil.h" #define IS_MASTER_SCAN(runtime) ((runtime)->scanFlag == MASTER_SCAN) #define IS_REVERSE_SCAN(runtime) ((runtime)->scanFlag == REVERSE_SCAN) @@ -134,6 +137,14 @@ do { \ } \ } while (0) +#define GET_JSON_KEY(exprInfo) \ +char* param = NULL; \ +int32_t paramLen = 0; \ +if(exprInfo->base.numOfParams > 0){ \ + param = exprInfo->base.param[0].pz; \ + paramLen = exprInfo->base.param[0].nLen; \ +} + uint64_t queryHandleId = 0; int32_t getMaximumIdleDurationSec() { @@ -403,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; @@ -422,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; } } @@ -963,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); } } @@ -1105,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) { @@ -1141,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 { @@ -1165,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) || @@ -1179,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; } @@ -1205,7 +1222,7 @@ static void doSetInputDataBlock(SOperatorInfo* pOperator, SQLFunctionCtx* pCtx, assert(p->info.colId == pColIndex->colId && pCtx[i].inputType == p->info.type); for(int32_t j = 0; j < pBlock->info.rows; ++j) { char* dst = p->pData + j * p->info.bytes; - tVariantDump(&pOperator->pExpr[i].base.param[1], dst, p->info.type, true); + tVariantDump(&pOperator->pExpr[i].base.param[0], dst, p->info.type, true); } } } @@ -1223,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); } } } @@ -1244,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); } } } @@ -1445,33 +1466,34 @@ static void doWindowBorderInterpolation(SOperatorInfo* pOperatorInfo, SSDataBloc } static void hashIntervalAgg(SOperatorInfo* pOperatorInfo, SResultRowInfo* pResultRowInfo, SSDataBlock* pSDataBlock, int32_t tableGroupId) { - STableIntervalOperatorInfo* pInfo = (STableIntervalOperatorInfo*) pOperatorInfo->info; + STableIntervalOperatorInfo* pInfo = (STableIntervalOperatorInfo*)pOperatorInfo->info; SQueryRuntimeEnv* pRuntimeEnv = pOperatorInfo->pRuntimeEnv; int32_t numOfOutput = pOperatorInfo->numOfOutput; SQueryAttr* pQueryAttr = pRuntimeEnv->pQueryAttr; int32_t step = GET_FORWARD_DIRECTION_FACTOR(pQueryAttr->order.order); - bool ascQuery = QUERY_IS_ASC_QUERY(pQueryAttr); + bool ascQuery = QUERY_IS_ASC_QUERY(pQueryAttr); int32_t prevIndex = pResultRowInfo->curPos; TSKEY* tsCols = NULL; if (pSDataBlock->pDataBlock != NULL) { SColumnInfoData* pColDataInfo = taosArrayGet(pSDataBlock->pDataBlock, 0); - tsCols = (int64_t*) pColDataInfo->pData; + tsCols = (int64_t*)pColDataInfo->pData; assert(tsCols[0] == pSDataBlock->info.window.skey && tsCols[pSDataBlock->info.rows - 1] == pSDataBlock->info.window.ekey); } - int32_t startPos = ascQuery? 0 : (pSDataBlock->info.rows - 1); - TSKEY ts = getStartTsKey(pQueryAttr, &pSDataBlock->info.window, tsCols, pSDataBlock->info.rows); + int32_t startPos = ascQuery ? 0 : (pSDataBlock->info.rows - 1); + TSKEY ts = getStartTsKey(pQueryAttr, &pSDataBlock->info.window, tsCols, pSDataBlock->info.rows); STimeWindow win = getActiveTimeWindow(pResultRowInfo, ts, pQueryAttr); + bool masterScan = IS_MASTER_SCAN(pRuntimeEnv); SResultRow* pResult = NULL; - int32_t ret = setResultOutputBufByKey(pRuntimeEnv, pResultRowInfo, pSDataBlock->info.tid, &win, masterScan, &pResult, tableGroupId, pInfo->pCtx, - numOfOutput, pInfo->rowCellInfoOffset); + int32_t ret = setResultOutputBufByKey(pRuntimeEnv, pResultRowInfo, pSDataBlock->info.tid, &win, masterScan, &pResult, + tableGroupId, pInfo->pCtx, numOfOutput, pInfo->rowCellInfoOffset); if (ret != TSDB_CODE_SUCCESS || pResult == NULL) { longjmp(pRuntimeEnv->env, TSDB_CODE_QRY_OUT_OF_MEMORY); } @@ -1487,7 +1509,8 @@ static void hashIntervalAgg(SOperatorInfo* pOperatorInfo, SResultRowInfo* pResul for (int32_t j = prevIndex; j < curIndex; ++j) { // previous time window may be all closed already. SResultRow* pRes = getResultRow(pResultRowInfo, j); if (pRes->closed) { - assert(resultRowInterpolated(pRes, RESULT_ROW_START_INTERP) && resultRowInterpolated(pRes, RESULT_ROW_END_INTERP)); + assert(resultRowInterpolated(pRes, RESULT_ROW_START_INTERP) && + resultRowInterpolated(pRes, RESULT_ROW_END_INTERP)); continue; } @@ -1509,8 +1532,8 @@ static void hashIntervalAgg(SOperatorInfo* pOperatorInfo, SResultRowInfo* pResul } // restore current time window - ret = setResultOutputBufByKey(pRuntimeEnv, pResultRowInfo, pSDataBlock->info.tid, &win, masterScan, &pResult, tableGroupId, pInfo->pCtx, - numOfOutput, pInfo->rowCellInfoOffset); + ret = setResultOutputBufByKey(pRuntimeEnv, pResultRowInfo, pSDataBlock->info.tid, &win, masterScan, &pResult, + tableGroupId, pInfo->pCtx, numOfOutput, pInfo->rowCellInfoOffset); if (ret != TSDB_CODE_SUCCESS) { longjmp(pRuntimeEnv->env, TSDB_CODE_QRY_OUT_OF_MEMORY); } @@ -1529,8 +1552,8 @@ static void hashIntervalAgg(SOperatorInfo* pOperatorInfo, SResultRowInfo* pResul } // null data, failed to allocate more memory buffer - int32_t code = setResultOutputBufByKey(pRuntimeEnv, pResultRowInfo, pSDataBlock->info.tid, &nextWin, masterScan, &pResult, tableGroupId, - pInfo->pCtx, numOfOutput, pInfo->rowCellInfoOffset); + int32_t code = setResultOutputBufByKey(pRuntimeEnv, pResultRowInfo, pSDataBlock->info.tid, &nextWin, masterScan, + &pResult, tableGroupId, pInfo->pCtx, numOfOutput, pInfo->rowCellInfoOffset); if (code != TSDB_CODE_SUCCESS || pResult == NULL) { longjmp(pRuntimeEnv->env, TSDB_CODE_QRY_OUT_OF_MEMORY); } @@ -1540,20 +1563,18 @@ static void hashIntervalAgg(SOperatorInfo* pOperatorInfo, SResultRowInfo* pResul // window start(end) key interpolation doWindowBorderInterpolation(pOperatorInfo, pSDataBlock, pInfo->pCtx, pResult, &nextWin, startPos, forwardStep); - doApplyFunctions(pRuntimeEnv, pInfo->pCtx, &nextWin, startPos, forwardStep, tsCols, pSDataBlock->info.rows, numOfOutput); + doApplyFunctions(pRuntimeEnv, pInfo->pCtx, &nextWin, startPos, forwardStep, tsCols, pSDataBlock->info.rows, + numOfOutput); } if (pQueryAttr->timeWindowInterpo) { - int32_t rowIndex = ascQuery? (pSDataBlock->info.rows-1):0; + int32_t rowIndex = ascQuery ? (pSDataBlock->info.rows - 1) : 0; saveDataBlockLastRow(pRuntimeEnv, &pSDataBlock->info, pSDataBlock->pDataBlock, rowIndex); } updateResultRowInfoActiveIndex(pResultRowInfo, pQueryAttr, pRuntimeEnv->current->lastKey); } - - - static void doHashGroupbyAgg(SOperatorInfo* pOperator, SGroupbyOperatorInfo *pInfo, SSDataBlock *pSDataBlock) { SQueryRuntimeEnv* pRuntimeEnv = pOperator->pRuntimeEnv; STableQueryInfo* item = pRuntimeEnv->current; @@ -1844,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 @@ -1902,6 +1926,7 @@ static SQLFunctionCtx* createSQLFunctionCtx(SQueryRuntimeEnv* pRuntimeEnv, SExpr pCtx->ptsOutputBuf = NULL; + pCtx->colId = pIndex->colId; pCtx->outputBytes = pSqlExpr->resBytes; pCtx->outputType = pSqlExpr->resType; @@ -1960,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]; } } @@ -2011,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) { @@ -2158,7 +2183,7 @@ static int32_t setupQueryRuntimeEnv(SQueryRuntimeEnv *pRuntimeEnv, int32_t numOf } case OP_MultiwayMergeSort: { - pRuntimeEnv->proot = createMultiwaySortOperatorInfo(pRuntimeEnv, pQueryAttr->pExpr1, pQueryAttr->numOfOutput, 4096, merger); + pRuntimeEnv->proot = createMultiwaySortOperatorInfo(pRuntimeEnv, pQueryAttr->pExpr1, pQueryAttr->numOfOutput, 200, merger); // TD-10899 break; } @@ -2186,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; } @@ -2931,7 +2962,7 @@ void filterColRowsInDataBlock(SQueryRuntimeEnv* pRuntimeEnv, SSDataBlock* pBlock static SColumnInfo* doGetTagColumnInfoById(SColumnInfo* pTagColList, int32_t numOfTags, int16_t colId); -static void doSetTagValueInParam(void* pTable, int32_t tagColId, tVariant *tag, int16_t type, int16_t bytes); +static void doSetTagValueInParam(void* pTable, char* param, int32_t paraLen, int32_t tagColId, tVariant *tag, int16_t type, int16_t bytes); static uint32_t doFilterByBlockTimeWindow(STableScanInfo* pTableScanInfo, SSDataBlock* pBlock) { SQLFunctionCtx* pCtx = pTableScanInfo->pCtx; @@ -2943,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 { @@ -3008,19 +3039,22 @@ int32_t loadDataBlockOnDemand(SQueryRuntimeEnv* pRuntimeEnv, STableScanInfo* pTa if (pQueryAttr->stableQuery) { // todo refactor SExprInfo* pExprInfo = &pTableScanInfo->pExpr[0]; - int16_t tagId = (int16_t)pExprInfo->base.param[0].i64; + int16_t tagId = (int16_t)pExprInfo->base.param[1].i64; SColumnInfo* pColInfo = doGetTagColumnInfoById(pQueryAttr->tagColList, pQueryAttr->numOfTags, tagId); // compare tag first tVariant t = {0}; - doSetTagValueInParam(pRuntimeEnv->current->pTable, tagId, &t, pColInfo->type, pColInfo->bytes); + GET_JSON_KEY(pExprInfo) + doSetTagValueInParam(pRuntimeEnv->current->pTable, param, paramLen, tagId, &t, pColInfo->type, pColInfo->bytes); setTimestampListJoinInfo(pRuntimeEnv, &t, pRuntimeEnv->current); STSElem elem = tsBufGetElem(pRuntimeEnv->pTsBuf); if (!tsBufIsValidElem(&elem) || (tsBufIsValidElem(&elem) && (tVariantCompare(&t, elem.tag) != 0))) { (*status) = BLK_DATA_DISCARD; + tVariantDestroy(&t); return TSDB_CODE_SUCCESS; } + tVariantDestroy(&t); } } @@ -3208,7 +3242,7 @@ int32_t binarySearchForKey(char *pValue, int num, TSKEY key, int order) { * set tag value in SQLFunctionCtx * e.g.,tag information into input buffer */ -static void doSetTagValueInParam(void* pTable, int32_t tagColId, tVariant *tag, int16_t type, int16_t bytes) { +static void doSetTagValueInParam(void* pTable, char* param, int32_t paramLen, int32_t tagColId, tVariant *tag, int16_t type, int16_t bytes) { tVariantDestroy(tag); char* val = NULL; @@ -3216,7 +3250,7 @@ static void doSetTagValueInParam(void* pTable, int32_t tagColId, tVariant *tag, val = tsdbGetTableName(pTable); assert(val != NULL); } else { - val = tsdbGetTableTagVal(pTable, tagColId, type, bytes); + val = tsdbGetTableTagVal(pTable, tagColId, type); } if (val == NULL || isNull(val, type)) { @@ -3224,11 +3258,19 @@ static void doSetTagValueInParam(void* pTable, int32_t tagColId, tVariant *tag, return; } - if (type == TSDB_DATA_TYPE_BINARY || type == TSDB_DATA_TYPE_NCHAR) { + if (IS_VAR_DATA_TYPE(type)) { int32_t maxLen = bytes - VARSTR_HEADER_SIZE; int32_t len = (varDataLen(val) > maxLen)? maxLen:varDataLen(val); tVariantCreateFromBinary(tag, varDataVal(val), len, type); //tVariantCreateFromBinary(tag, varDataVal(val), varDataLen(val), type); + } else if(type == TSDB_DATA_TYPE_JSON){ + char jsonVal[TSDB_MAX_JSON_TAGS_LEN] = {0}; + if(param){ + getJsonTagValueElment(pTable, param, paramLen, jsonVal, bytes); + }else{ + getJsonTagValueAll(val, jsonVal, TSDB_MAX_JSON_TAGS_LEN); + } + tVariantCreateFromBinary(tag, jsonVal, bytes, type); } else { tVariantCreateFromBinary(tag, val, bytes, type); } @@ -3254,12 +3296,12 @@ void setTagValue(SOperatorInfo* pOperatorInfo, void *pTable, SQLFunctionCtx* pCt SExprInfo* pExprInfo = &pExpr[0]; if (pQueryAttr->numOfOutput == 1 && pExprInfo->base.functionId == TSDB_FUNC_TS_COMP && pQueryAttr->stableQuery) { - assert(pExprInfo->base.numOfParams == 1); + assert(pExprInfo->base.numOfParams == 2); - int16_t tagColId = (int16_t)pExprInfo->base.param[0].i64; + int16_t tagColId = (int16_t)pExprInfo->base.param[1].i64; SColumnInfo* pColInfo = doGetTagColumnInfoById(pQueryAttr->tagColList, pQueryAttr->numOfTags, tagColId); - - doSetTagValueInParam(pTable, tagColId, &pCtx[0].tag, pColInfo->type, pColInfo->bytes); + GET_JSON_KEY(pExprInfo) + doSetTagValueInParam(pTable, param, paramLen, tagColId, &pCtx[0].tag, pColInfo->type, pColInfo->bytes); return; } else { // set tag value, by which the results are aggregated. @@ -3275,7 +3317,8 @@ void setTagValue(SOperatorInfo* pOperatorInfo, void *pTable, SQLFunctionCtx* pCt } // todo use tag column index to optimize performance - doSetTagValueInParam(pTable, pLocalExprInfo->base.colInfo.colId, &pCtx[idx].tag, pLocalExprInfo->base.resType, + GET_JSON_KEY(pLocalExprInfo) + doSetTagValueInParam(pTable, param, paramLen, pLocalExprInfo->base.colInfo.colId, &pCtx[idx].tag, pLocalExprInfo->base.resType, pLocalExprInfo->base.resBytes); if (IS_NUMERIC_TYPE(pLocalExprInfo->base.resType) @@ -3641,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); } } } @@ -3701,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); } } @@ -3718,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); } } } @@ -3807,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) { @@ -3817,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); + } } } } @@ -3894,20 +3946,21 @@ void setCtxTagForJoin(SQueryRuntimeEnv* pRuntimeEnv, SQLFunctionCtx* pCtx, SExpr if (pQueryAttr->stableQuery && (pRuntimeEnv->pTsBuf != NULL) && (pExpr->functionId == TSDB_FUNC_TS || pExpr->functionId == TSDB_FUNC_PRJ) && (pExpr->colInfo.colIndex == PRIMARYKEY_TIMESTAMP_COL_INDEX)) { - assert(pExpr->numOfParams == 1); + assert(pExpr->numOfParams == 2); - int16_t tagColId = (int16_t)pExprInfo->base.param[0].i64; + int16_t tagColId = (int16_t)pExprInfo->base.param[1].i64; SColumnInfo* pColInfo = doGetTagColumnInfoById(pQueryAttr->tagColList, pQueryAttr->numOfTags, tagColId); - doSetTagValueInParam(pTable, tagColId, &pCtx->tag, pColInfo->type, pColInfo->bytes); + GET_JSON_KEY(pExprInfo) + doSetTagValueInParam(pTable, param, paramLen, tagColId, &pCtx->tag, pColInfo->type, pColInfo->bytes); int16_t tagType = pCtx[0].tag.nType; - if (tagType == TSDB_DATA_TYPE_BINARY || tagType == TSDB_DATA_TYPE_NCHAR) { + if (tagType == TSDB_DATA_TYPE_BINARY || tagType == TSDB_DATA_TYPE_NCHAR || tagType == TSDB_DATA_TYPE_JSON) { qDebug("QInfo:0x%"PRIx64" set tag value for join comparison, colId:%" PRId64 ", val:%s", GET_QID(pRuntimeEnv), - pExprInfo->base.param[0].i64, pCtx[0].tag.pz); + pExprInfo->base.param[1].i64, pCtx[0].tag.pz); } else { qDebug("QInfo:0x%"PRIx64" set tag value for join comparison, colId:%" PRId64 ", val:%" PRId64, GET_QID(pRuntimeEnv), - pExprInfo->base.param[0].i64, pCtx[0].tag.i64); + pExprInfo->base.param[1].i64, pCtx[0].tag.i64); } } } @@ -3925,7 +3978,7 @@ int32_t setTimestampListJoinInfo(SQueryRuntimeEnv* pRuntimeEnv, tVariant* pTag, // failed to find data with the specified tag value and vnodeId if (!tsBufIsValidElem(&elem)) { - if (pTag->nType == TSDB_DATA_TYPE_BINARY || pTag->nType == TSDB_DATA_TYPE_NCHAR) { + if (pTag->nType == TSDB_DATA_TYPE_BINARY || pTag->nType == TSDB_DATA_TYPE_NCHAR || pTag->nType == TSDB_DATA_TYPE_JSON) { qError("QInfo:0x%"PRIx64" failed to find tag:%s in ts_comp", GET_QID(pRuntimeEnv), pTag->pz); } else { qError("QInfo:0x%"PRIx64" failed to find tag:%" PRId64 " in ts_comp", GET_QID(pRuntimeEnv), pTag->i64); @@ -3936,7 +3989,7 @@ int32_t setTimestampListJoinInfo(SQueryRuntimeEnv* pRuntimeEnv, tVariant* pTag, // Keep the cursor info of current table pTableQueryInfo->cur = tsBufGetCursor(pRuntimeEnv->pTsBuf); - if (pTag->nType == TSDB_DATA_TYPE_BINARY || pTag->nType == TSDB_DATA_TYPE_NCHAR) { + if (pTag->nType == TSDB_DATA_TYPE_BINARY || pTag->nType == TSDB_DATA_TYPE_NCHAR || pTag->nType == TSDB_DATA_TYPE_JSON) { qDebug("QInfo:0x%"PRIx64" find tag:%s start pos in ts_comp, blockIndex:%d, tsIndex:%d", GET_QID(pRuntimeEnv), pTag->pz, pTableQueryInfo->cur.blockIndex, pTableQueryInfo->cur.tsIndex); } else { qDebug("QInfo:0x%"PRIx64" find tag:%"PRId64" start pos in ts_comp, blockIndex:%d, tsIndex:%d", GET_QID(pRuntimeEnv), pTag->i64, pTableQueryInfo->cur.blockIndex, pTableQueryInfo->cur.tsIndex); @@ -3944,7 +3997,7 @@ int32_t setTimestampListJoinInfo(SQueryRuntimeEnv* pRuntimeEnv, tVariant* pTag, } else { tsBufSetCursor(pRuntimeEnv->pTsBuf, &pTableQueryInfo->cur); - if (pTag->nType == TSDB_DATA_TYPE_BINARY || pTag->nType == TSDB_DATA_TYPE_NCHAR) { + if (pTag->nType == TSDB_DATA_TYPE_BINARY || pTag->nType == TSDB_DATA_TYPE_NCHAR || pTag->nType == TSDB_DATA_TYPE_JSON) { qDebug("QInfo:0x%"PRIx64" find tag:%s start pos in ts_comp, blockIndex:%d, tsIndex:%d", GET_QID(pRuntimeEnv), pTag->pz, pTableQueryInfo->cur.blockIndex, pTableQueryInfo->cur.tsIndex); } else { qDebug("QInfo:0x%"PRIx64" find tag:%"PRId64" start pos in ts_comp, blockIndex:%d, tsIndex:%d", GET_QID(pRuntimeEnv), pTag->i64, pTableQueryInfo->cur.blockIndex, pTableQueryInfo->cur.tsIndex); @@ -5340,7 +5393,7 @@ SOperatorInfo* createGlobalAggregateOperatorInfo(SQueryRuntimeEnv* pRuntimeEnv, pInfo->multiGroupResults = groupResultMixedUp; pInfo->pMerge = param; - pInfo->bufCapacity = 4096; + pInfo->bufCapacity = 200; // TD-10899 pInfo->udfInfo = pUdfInfo; pInfo->binfo.pRes = createOutputBuf(pExpr, numOfOutput, pInfo->bufCapacity * pInfo->resultRowFactor); pInfo->binfo.pCtx = createSQLFunctionCtx(pRuntimeEnv, pExpr, numOfOutput, &pInfo->binfo.rowCellInfoOffset); @@ -5519,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) { @@ -5742,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); } @@ -7427,7 +7488,16 @@ static SSDataBlock* doTagScan(void* param, bool* newgroup) { if (pExprInfo->base.colInfo.colId == TSDB_TBNAME_COLUMN_INDEX) { data = tsdbGetTableName(item->pTable); } else { - data = tsdbGetTableTagVal(item->pTable, pExprInfo->base.colInfo.colId, type, bytes); + data = tsdbGetTableTagVal(item->pTable, pExprInfo->base.colInfo.colId, type); + if(type == TSDB_DATA_TYPE_JSON){ + if(pExprInfo->base.numOfParams > 0){ // tag-> operation + getJsonTagValueElment(item->pTable, pExprInfo->base.param[0].pz, pExprInfo->base.param[0].nLen, output, bytes); + }else{ + getJsonTagValueAll(data, output, bytes); + } + count += 1; + continue; + } } doSetTagValueToResultBuf(output, data, type, bytes); @@ -7463,13 +7533,20 @@ static SSDataBlock* doTagScan(void* param, bool* newgroup) { type = pExprInfo[j].base.resType; bytes = pExprInfo[j].base.resBytes; + dst = pColInfo->pData + count * pExprInfo[j].base.resBytes; if (pExprInfo[j].base.colInfo.colId == TSDB_TBNAME_COLUMN_INDEX) { data = tsdbGetTableName(item->pTable); } else { - data = tsdbGetTableTagVal(item->pTable, pExprInfo[j].base.colInfo.colId, type, bytes); + data = tsdbGetTableTagVal(item->pTable, pExprInfo[j].base.colInfo.colId, type); + if(type == TSDB_DATA_TYPE_JSON){ + if(pExprInfo[j].base.numOfParams > 0){ // tag-> operation + getJsonTagValueElment(item->pTable, pExprInfo[j].base.param[0].pz, pExprInfo[j].base.param[0].nLen, dst, bytes); + }else{ + getJsonTagValueAll(data, dst, bytes); + } + continue; + } } - - dst = pColInfo->pData + count * pExprInfo[j].base.resBytes; doSetTagValueToResultBuf(dst, data, type, bytes); } @@ -8220,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; @@ -8433,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; @@ -8455,8 +8529,8 @@ int32_t createQueryFunc(SQueriedTableInfo* pTableInfo, int32_t numOfOutput, SExp // it is a user-defined constant value column assert(pExprs[i].base.functionId == TSDB_FUNC_PRJ); - type = pExprs[i].base.param[1].nType; - bytes = pExprs[i].base.param[1].nLen; + type = pExprs[i].base.param[0].nType; + bytes = pExprs[i].base.param[0].nLen; if (type == TSDB_DATA_TYPE_BINARY || type == TSDB_DATA_TYPE_NCHAR) { bytes += VARSTR_HEADER_SIZE; } @@ -8496,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; @@ -8572,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)); } @@ -8716,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; } @@ -9365,4 +9440,3 @@ void freeQueryAttr(SQueryAttr* pQueryAttr) { filterFreeInfo(pQueryAttr->pFilters); } } - diff --git a/src/query/src/qExtbuffer.c b/src/query/src/qExtbuffer.c index ef4b56dc877ca75fe79ac5a345e99e0a3717eff5..cc214b953303e3b10b053bbe0c183eaee520e32a 100644 --- a/src/query/src/qExtbuffer.c +++ b/src/query/src/qExtbuffer.c @@ -367,6 +367,14 @@ static int32_t tsCompareFunc(TSKEY k1, TSKEY k2, int32_t order) { } int32_t columnValueAscendingComparator(char *f1, char *f2, int32_t type, int32_t bytes) { + if (type == TSDB_DATA_TYPE_JSON){ + bool canReturn = true; + int32_t result = jsonCompareUnit(f1, f2, &canReturn); + if(canReturn) return result; + type = *f1; + f1 += CHAR_BYTES; + f2 += CHAR_BYTES; + } switch (type) { case TSDB_DATA_TYPE_INT: DEFAULT_COMP(GET_INT32_VAL(f1), GET_INT32_VAL(f2)); case TSDB_DATA_TYPE_DOUBLE: DEFAULT_DOUBLE_COMP(GET_DOUBLE_VAL(f1), GET_DOUBLE_VAL(f2)); diff --git a/src/query/src/qFilter.c b/src/query/src/qFilter.c index 2ce8a49097af6229c36931cbf3db753c04580674..d5009c85ae3e7813ab0c35a62812e89d3d879ccf 100644 --- a/src/query/src/qFilter.c +++ b/src/query/src/qFilter.c @@ -18,6 +18,7 @@ #include "tcompare.h" #include "hash.h" #include "tscUtil.h" +#include "tsdbMeta.h" OptrStr gOptrStr[] = { {TSDB_RELATION_INVALID, "invalid"}, @@ -36,13 +37,14 @@ OptrStr gOptrStr[] = { {TSDB_RELATION_NOT, "not"}, {TSDB_RELATION_MATCH, "match"}, {TSDB_RELATION_NMATCH, "nmatch"}, + {TSDB_RELATION_CONTAINS, "contains"}, }; static FORCE_INLINE int32_t filterFieldColDescCompare(const void *desc1, const void *desc2) { const SSchema *sch1 = desc1; const SSchema *sch2 = desc2; - return sch1->colId != sch2->colId; + return !(strcmp(sch1->name, sch2->name) == 0 && sch1->colId == sch2->colId); } static FORCE_INLINE int32_t filterFieldValDescCompare(const void *desc1, const void *desc2) { @@ -60,15 +62,23 @@ filter_desc_compare_func gDescCompare [FLD_TYPE_MAX] = { }; bool filterRangeCompGi (const void *minv, const void *maxv, const void *minr, const void *maxr, __compar_fn_t cfunc) { + int32_t result = cfunc(maxv, minr); + if (result == TSDB_DATA_JSON_CAN_NOT_COMPARE) return false; return cfunc(maxv, minr) >= 0; } bool filterRangeCompGe (const void *minv, const void *maxv, const void *minr, const void *maxr, __compar_fn_t cfunc) { + int32_t result = cfunc(maxv, minr); + if (result == TSDB_DATA_JSON_CAN_NOT_COMPARE) return false; return cfunc(maxv, minr) > 0; } bool filterRangeCompLi (const void *minv, const void *maxv, const void *minr, const void *maxr, __compar_fn_t cfunc) { + int32_t result = cfunc(minv, maxr); + if (result == TSDB_DATA_JSON_CAN_NOT_COMPARE) return false; return cfunc(minv, maxr) <= 0; } bool filterRangeCompLe (const void *minv, const void *maxv, const void *minr, const void *maxr, __compar_fn_t cfunc) { + int32_t result = cfunc(minv, maxr); + if (result == TSDB_DATA_JSON_CAN_NOT_COMPARE) return false; return cfunc(minv, maxr) < 0; } bool filterRangeCompii (const void *minv, const void *maxv, const void *minr, const void *maxr, __compar_fn_t cfunc) { @@ -158,7 +168,8 @@ int8_t filterGetRangeCompFuncFromOptrs(uint8_t optr, uint8_t optr2) { __compar_fn_t gDataCompare[] = {compareInt32Val, compareInt8Val, compareInt16Val, compareInt64Val, compareFloatVal, compareDoubleVal, compareLenPrefixedStr, compareStrPatternComp, compareFindItemInSet, compareWStrPatternComp, compareLenPrefixedWStr, compareUint8Val, compareUint16Val, compareUint32Val, compareUint64Val, - setCompareBytes1, setCompareBytes2, setCompareBytes4, setCompareBytes8, compareStrRegexCompMatch, compareStrRegexCompNMatch + setCompareBytes1, setCompareBytes2, setCompareBytes4, setCompareBytes8, compareStrRegexCompMatch, + compareStrRegexCompNMatch, compareStrContainJson, compareJsonVal }; int8_t filterGetCompFuncIdx(int32_t type, int32_t optr) { @@ -196,7 +207,7 @@ int8_t filterGetCompFuncIdx(int32_t type, int32_t optr) { case TSDB_DATA_TYPE_TIMESTAMP: comparFn = 3; break; case TSDB_DATA_TYPE_FLOAT: comparFn = 4; break; case TSDB_DATA_TYPE_DOUBLE: comparFn = 5; break; - case TSDB_DATA_TYPE_BINARY: { + case TSDB_DATA_TYPE_BINARY:{ if (optr == TSDB_RELATION_MATCH) { comparFn = 19; } else if (optr == TSDB_RELATION_NMATCH) { @@ -212,7 +223,7 @@ int8_t filterGetCompFuncIdx(int32_t type, int32_t optr) { break; } - case TSDB_DATA_TYPE_NCHAR: { + case TSDB_DATA_TYPE_NCHAR:{ if (optr == TSDB_RELATION_MATCH) { comparFn = 19; } else if (optr == TSDB_RELATION_NMATCH) { @@ -226,6 +237,20 @@ int8_t filterGetCompFuncIdx(int32_t type, int32_t optr) { } break; } + case TSDB_DATA_TYPE_JSON:{ + if (optr == TSDB_RELATION_MATCH) { + comparFn = 19; + } else if (optr == TSDB_RELATION_NMATCH) { + comparFn = 20; + } else if (optr == TSDB_RELATION_LIKE) { /* wildcard query using like operator */ + comparFn = 9; + } else if (optr == TSDB_RELATION_CONTAINS) { + comparFn = 21; + } else { + comparFn = 22; + } + break; + } case TSDB_DATA_TYPE_UTINYINT: comparFn = 11; break; case TSDB_DATA_TYPE_USMALLINT: comparFn = 12;break; @@ -846,11 +871,10 @@ static FORCE_INLINE int32_t filterAddColFieldFromField(SFilterInfo *info, SFilte return TSDB_CODE_SUCCESS; } - int32_t filterAddFieldFromNode(SFilterInfo *info, tExprNode *node, SFilterFieldId *fid) { CHK_LRET(node == NULL, TSDB_CODE_QRY_APP_ERROR, "empty node"); CHK_RET(node->nodeType != TSQL_NODE_COL && node->nodeType != TSQL_NODE_VALUE, TSDB_CODE_QRY_APP_ERROR); - + int32_t type; void *v; @@ -1030,6 +1054,12 @@ int32_t filterConvertSetFromBinary(void **q, const char *buf, int32_t len, uint3 switch (tType) { case TSDB_DATA_TYPE_BOOL: + if (sType != TSDB_DATA_TYPE_BOOL && !IS_SIGNED_NUMERIC_TYPE(sType)) { + goto _return; + } + if (tmpVar.i64 > 1 ||tmpVar.i64 < 0) { + goto _return; + } case TSDB_DATA_TYPE_UTINYINT: case TSDB_DATA_TYPE_TINYINT: { if (tVariantDumpEx(&tmpVar, (char *)&val, tType, false, &converted, &extInfo)) { @@ -1147,20 +1177,46 @@ _return: return code; } +static int32_t filterDealJson(SFilterInfo *info, tExprNode* tree, tExprNode** pLeft) { + if((*pLeft)->nodeType == TSQL_NODE_EXPR && (*pLeft)->_node.optr == TSDB_RELATION_ARROW){ // json tag -> operation + assert(info->pTable != NULL); + SSchema* schema = (*pLeft)->_node.pLeft->pSchema; + if((*pLeft)->_node.pRight->pVal->nLen > TSDB_MAX_JSON_KEY_LEN) return TSDB_CODE_TSC_INVALID_COLUMN_LENGTH; + char keyMd5[TSDB_MAX_JSON_KEY_MD5_LEN] = {0}; + jsonKeyMd5((*pLeft)->_node.pRight->pVal->pz, (*pLeft)->_node.pRight->pVal->nLen, keyMd5); + memcpy(schema->name, keyMd5, TSDB_MAX_JSON_KEY_MD5_LEN); + (*pLeft) = (*pLeft)->_node.pLeft; // -> operation use left as input + }else if(((*pLeft)->pSchema->type == TSDB_DATA_TYPE_JSON) && + (tree->_node.optr == TSDB_RELATION_ISNULL || tree->_node.optr == TSDB_RELATION_NOTNULL)){ + SSchema* schema = (*pLeft)->pSchema; + char keyMd5[TSDB_MAX_JSON_KEY_MD5_LEN] = {0}; + uint32_t nullData = TSDB_DATA_JSON_NULL; + jsonKeyMd5(&nullData, INT_BYTES, keyMd5); + memcpy(schema->name, keyMd5, TSDB_MAX_JSON_KEY_MD5_LEN); + }else if(tree->_node.optr == TSDB_RELATION_CONTAINS){ + SSchema* schema = (*pLeft)->pSchema; + if(tree->_node.pRight->pVal->nLen > TSDB_MAX_JSON_KEY_LEN) return TSDB_CODE_TSC_INVALID_COLUMN_LENGTH; + char keyMd5[TSDB_MAX_JSON_KEY_MD5_LEN] = {0}; + jsonKeyMd5(tree->_node.pRight->pVal->pz, tree->_node.pRight->pVal->nLen, keyMd5); + memcpy(schema->name, keyMd5, TSDB_MAX_JSON_KEY_MD5_LEN); + } + return TSDB_CODE_SUCCESS; +} int32_t filterAddGroupUnitFromNode(SFilterInfo *info, tExprNode* tree, SArray *group) { + tExprNode* pLeft = tree->_node.pLeft; + int32_t ret = TSDB_CODE_SUCCESS; + if((ret = filterDealJson(info, tree, &pLeft)) != TSDB_CODE_SUCCESS) return ret; SFilterFieldId left = {0}, right = {0}; - - filterAddFieldFromNode(info, tree->_node.pLeft, &left); - - tVariant* var = tree->_node.pRight->pVal; - int32_t type = FILTER_GET_COL_FIELD_TYPE(FILTER_GET_FIELD(info, left)); + filterAddFieldFromNode(info, pLeft, &left); + uint8_t type = FILTER_GET_COL_FIELD_TYPE(FILTER_GET_FIELD(info, left)); int32_t len = 0; uint32_t uidx = 0; - if (tree->_node.optr == TSDB_RELATION_IN && (!IS_VAR_DATA_TYPE(type))) { + if (tree->_node.optr == TSDB_RELATION_IN && !IS_VAR_DATA_TYPE(type) && type != TSDB_DATA_TYPE_JSON) { void *data = NULL; + tVariant* var = tree->_node.pRight->pVal; filterConvertSetFromBinary((void **)&data, var->pz, var->nLen, type, false); CHK_LRET(data == NULL, TSDB_CODE_QRY_APP_ERROR, "failed to convert in param"); @@ -1180,18 +1236,11 @@ int32_t filterAddGroupUnitFromNode(SFilterInfo *info, tExprNode* tree, SArray *g while(p) { void *key = taosHashGetDataKey((SHashObj *)data, p); void *fdata = NULL; - - if (IS_VAR_DATA_TYPE(type)) { - len = (int32_t)taosHashGetDataKeyLen((SHashObj *)data, p); - fdata = malloc(len + VARSTR_HEADER_SIZE); - varDataLen(fdata) = len; - memcpy(varDataVal(fdata), key, len); - len += VARSTR_HEADER_SIZE; - } else { - fdata = malloc(sizeof(int64_t)); - SIMPLE_COPY_VALUES(fdata, key); - len = tDataTypes[type].bytes; - } + + fdata = malloc(sizeof(int64_t)); + SIMPLE_COPY_VALUES(fdata, key); + len = tDataTypes[type].bytes; + filterAddField(info, NULL, &fdata, FLD_TYPE_VALUE, &right, len, true); filterAddUnit(info, TSDB_RELATION_EQUAL, &left, &right, &uidx); @@ -1206,9 +1255,9 @@ int32_t filterAddGroupUnitFromNode(SFilterInfo *info, tExprNode* tree, SArray *g taosHashCleanup(data); } else { - filterAddFieldFromNode(info, tree->_node.pRight, &right); + filterAddFieldFromNode(info, tree->_node.pRight, &right); - filterAddUnit(info, tree->_node.optr, &left, &right, &uidx); + filterAddUnit(info, tree->_node.optr, &left, &right, &uidx); SFilterGroup fgroup = {0}; filterAddUnitToGroup(&fgroup, uidx); @@ -1476,7 +1525,7 @@ int32_t filterTreeToGroup(tExprNode* tree, SFilterInfo *info, SArray* group) { return TSDB_CODE_SUCCESS; } - code = filterAddGroupUnitFromNode(info, tree, group); + code = filterAddGroupUnitFromNode(info, tree, group); _return: @@ -1534,7 +1583,7 @@ void filterDumpInfoToString(SFilterInfo *info, const char *msg, int32_t options) tlen = varDataLen(data); data += VARSTR_HEADER_SIZE; } - converToStr(str + len, type, data, tlen > 32 ? 32 : tlen, &tlen); + if (data) converToStr(str + len, type, data, tlen > 32 ? 32 : tlen, &tlen); } else { strcat(str, "NULL"); } @@ -1815,7 +1864,7 @@ int32_t filterInitValFieldData(SFilterInfo *info) { } else if (type == TSDB_DATA_TYPE_NCHAR) { size_t len = (var->nType == TSDB_DATA_TYPE_BINARY || var->nType == TSDB_DATA_TYPE_NCHAR) ? var->nLen : MAX_NUM_STR_SIZE; fi->data = calloc(1, (len + 1) * TSDB_NCHAR_SIZE + VARSTR_HEADER_SIZE); - } else { + } else if (type != TSDB_DATA_TYPE_JSON){ if (var->nType == TSDB_DATA_TYPE_VALUE_ARRAY) { //TIME RANGE fi->data = calloc(var->nLen, tDataTypes[type].bytes); for (int32_t a = 0; a < var->nLen; ++a) { @@ -1827,18 +1876,22 @@ int32_t filterInitValFieldData(SFilterInfo *info) { } else { fi->data = calloc(1, sizeof(int64_t)); } + } else{ // type == TSDB_DATA_TYPE_JSON + // fi->data = null; use fi->desc as data, because json value is variable, so use tVariant (fi->desc) } - bool converted = false; - char extInfo = 0; - if (tVariantDumpEx(var, (char*)fi->data, type, true, &converted, &extInfo)) { - if (converted) { - filterHandleValueExtInfo(unit, extInfo); - - continue; + if(type != TSDB_DATA_TYPE_JSON){ + bool converted = false; + char extInfo = 0; + if (tVariantDumpEx(var, (char*)fi->data, type, true, &converted, &extInfo)) { + if (converted) { + filterHandleValueExtInfo(unit, extInfo); + + continue; + } + qError("dump value to type[%d] failed", type); + return TSDB_CODE_TSC_INVALID_OPERATION; } - qError("dump value to type[%d] failed", type); - return TSDB_CODE_TSC_INVALID_OPERATION; } // match/nmatch for nchar type need convert from ucs4 to mbs @@ -1848,7 +1901,14 @@ int32_t filterInitValFieldData(SFilterInfo *info) { int32_t len = taosUcs4ToMbs(varDataVal(fi->data), varDataLen(fi->data), varDataVal(newValData)); varDataSetLen(newValData, len); varDataCopy(fi->data, newValData); + }else if(type == TSDB_DATA_TYPE_JSON && + (unit->compare.optr == TSDB_RELATION_MATCH || unit->compare.optr == TSDB_RELATION_NMATCH)){ + char newValData[TSDB_REGEX_STRING_DEFAULT_LEN * TSDB_NCHAR_SIZE + VARSTR_HEADER_SIZE] = {0}; + int32_t len = taosUcs4ToMbs(((tVariant*)(fi->desc))->pz, ((tVariant*)(fi->desc))->nLen, newValData); + memcpy(((tVariant*)(fi->desc))->pz, newValData, len); + ((tVariant*)(fi->desc))->nLen = len; } + } return TSDB_CODE_SUCCESS; @@ -1858,6 +1918,8 @@ int32_t filterInitValFieldData(SFilterInfo *info) { bool filterDoCompare(__compar_fn_t func, uint8_t optr, void *left, void *right) { int32_t ret = func(left, right); + if(ret == TSDB_DATA_JSON_CAN_NOT_COMPARE) return false; + switch (optr) { case TSDB_RELATION_EQUAL: { return ret == 0; @@ -1883,6 +1945,9 @@ bool filterDoCompare(__compar_fn_t func, uint8_t optr, void *left, void *right) case TSDB_RELATION_MATCH: { return ret == 0; } + case TSDB_RELATION_CONTAINS: { + return ret == 0; + } case TSDB_RELATION_NMATCH: { return ret == 0; } @@ -2569,7 +2634,11 @@ int32_t filterGenerateComInfo(SFilterInfo *info) { info->cunits[i].colId = FILTER_UNIT_COL_ID(info, unit); if (unit->right.type == FLD_TYPE_VALUE) { - info->cunits[i].valData = FILTER_UNIT_VAL_DATA(info, unit); + if(FILTER_UNIT_DATA_TYPE(unit) == TSDB_DATA_TYPE_JSON){ // json value is tVariant + info->cunits[i].valData = FILTER_UNIT_JSON_VAL_DATA(info, unit); + }else{ + info->cunits[i].valData = FILTER_UNIT_VAL_DATA(info, unit); + } } else { info->cunits[i].valData = NULL; } @@ -2647,9 +2716,9 @@ int32_t filterRmUnitByRange(SFilterInfo *info, SDataStatis *pDataStatis, int32_t } } - if (cunit->optr == TSDB_RELATION_ISNULL || cunit->optr == TSDB_RELATION_NOTNULL + if (cunit->optr == TSDB_RELATION_ISNULL || cunit->optr == TSDB_RELATION_NOTNULL || cunit->optr == TSDB_RELATION_IN || cunit->optr == TSDB_RELATION_LIKE || cunit->optr == TSDB_RELATION_MATCH - || cunit->optr == TSDB_RELATION_NOT_EQUAL) { + || cunit->optr == TSDB_RELATION_NOT_EQUAL || cunit->optr == TSDB_RELATION_CONTAINS) { continue; } @@ -2891,7 +2960,18 @@ static FORCE_INLINE bool filterExecuteImplIsNull(void *pinfo, int32_t numOfRows, for (int32_t i = 0; i < numOfRows; ++i) { uint32_t uidx = info->groups[0].unitIdxs[0]; void *colData = (char *)info->cunits[uidx].colData + info->cunits[uidx].dataSize * i; - (*p)[i] = ((colData == NULL) || isNull(colData, info->cunits[uidx].dataType)); + if(info->cunits[uidx].dataType == TSDB_DATA_TYPE_JSON){ + if (!colData){ // for json->'key' is null + (*p)[i] = 1; + }else if( *(char*)colData == TSDB_DATA_TYPE_JSON){ // for json is null + colData = POINTER_SHIFT(colData, CHAR_BYTES); + (*p)[i] = isNull(colData, info->cunits[uidx].dataType); + }else{ + (*p)[i] = 0; + } + }else{ + (*p)[i] = ((colData == NULL) || isNull(colData, info->cunits[uidx].dataType)); + } if ((*p)[i] == 0) { all = false; } @@ -2914,7 +2994,20 @@ static FORCE_INLINE bool filterExecuteImplNotNull(void *pinfo, int32_t numOfRows for (int32_t i = 0; i < numOfRows; ++i) { uint32_t uidx = info->groups[0].unitIdxs[0]; void *colData = (char *)info->cunits[uidx].colData + info->cunits[uidx].dataSize * i; - (*p)[i] = ((colData != NULL) && !isNull(colData, info->cunits[uidx].dataType)); + + if(info->cunits[uidx].dataType == TSDB_DATA_TYPE_JSON){ + if (!colData) { // for json->'key' is not null + (*p)[i] = 0; + }else if( *(char*)colData == TSDB_DATA_TYPE_JSON){ // for json is not null + colData = POINTER_SHIFT(colData, CHAR_BYTES); + (*p)[i] = !isNull(colData, info->cunits[uidx].dataType); + }else{ // for json->'key' is not null + (*p)[i] = 1; + } + }else { + (*p)[i] = ((colData != NULL) && !isNull(colData, info->cunits[uidx].dataType)); + } + if ((*p)[i] == 0) { all = false; } @@ -2923,6 +3016,42 @@ static FORCE_INLINE bool filterExecuteImplNotNull(void *pinfo, int32_t numOfRows return all; } +static void doJsonCompare(SFilterComUnit *cunit, int8_t *result, void* colData){ + if(cunit->optr == TSDB_RELATION_MATCH || cunit->optr == TSDB_RELATION_NMATCH){ + uint8_t jsonType = *(char*)colData; + char* realData = POINTER_SHIFT(colData, CHAR_BYTES); + if (jsonType != TSDB_DATA_TYPE_NCHAR){ + *result = false; + }else{ + char *newColData = calloc(cunit->dataSize * TSDB_NCHAR_SIZE + VARSTR_HEADER_SIZE, 1); + int len = taosUcs4ToMbs(varDataVal(realData), varDataLen(realData), varDataVal(newColData)); + varDataSetLen(newColData, len); + tVariant* val = cunit->valData; + char newValData[TSDB_REGEX_STRING_DEFAULT_LEN * TSDB_NCHAR_SIZE + VARSTR_HEADER_SIZE] = {0}; + assert(val->nLen <= TSDB_REGEX_STRING_DEFAULT_LEN * TSDB_NCHAR_SIZE); + memcpy(varDataVal(newValData), val->pz, val->nLen); + varDataSetLen(newValData, val->nLen); + *result = filterDoCompare(gDataCompare[cunit->func], cunit->optr, newColData, newValData); + tfree(newColData); + } + }else if(cunit->optr == TSDB_RELATION_LIKE){ + uint8_t jsonType = *(char*)colData; + char* realData = POINTER_SHIFT(colData, CHAR_BYTES); + if (jsonType != TSDB_DATA_TYPE_NCHAR){ + *result = false; + }else{ + tVariant* val = cunit->valData; + char* newValData = calloc(val->nLen + VARSTR_HEADER_SIZE, 1); + memcpy(varDataVal(newValData), val->pz, val->nLen); + varDataSetLen(newValData, val->nLen); + *result = filterDoCompare(gDataCompare[cunit->func], cunit->optr, realData, newValData); + tfree(newValData); + } + }else{ + *result = filterDoCompare(gDataCompare[cunit->func], cunit->optr, colData, cunit->valData); + } +} + bool filterExecuteImplRange(void *pinfo, int32_t numOfRows, int8_t** p, SDataStatis *statis, int16_t numOfCols) { SFilterInfo *info = (SFilterInfo *)pinfo; bool all = true; @@ -2988,6 +3117,8 @@ bool filterExecuteImplMisc(void *pinfo, int32_t numOfRows, int8_t** p, SDataStat varDataSetLen(newColData, len); (*p)[i] = filterDoCompare(gDataCompare[info->cunits[uidx].func], info->cunits[uidx].optr, newColData, info->cunits[uidx].valData); tfree(newColData); + }else if(info->cunits[uidx].dataType == TSDB_DATA_TYPE_JSON){ + doJsonCompare(&(info->cunits[uidx]), &(*p)[i], colData); }else{ (*p)[i] = filterDoCompare(gDataCompare[info->cunits[uidx].func], info->cunits[uidx].optr, colData, info->cunits[uidx].valData); } @@ -3000,7 +3131,6 @@ bool filterExecuteImplMisc(void *pinfo, int32_t numOfRows, int8_t** p, SDataStat return all; } - bool filterExecuteImpl(void *pinfo, int32_t numOfRows, int8_t** p, SDataStatis *statis, int16_t numOfCols) { SFilterInfo *info = (SFilterInfo *)pinfo; bool all = true; @@ -3044,6 +3174,8 @@ bool filterExecuteImpl(void *pinfo, int32_t numOfRows, int8_t** p, SDataStatis * varDataSetLen(newColData, len); (*p)[i] = filterDoCompare(gDataCompare[cunit->func], cunit->optr, newColData, cunit->valData); tfree(newColData); + }else if(cunit->dataType == TSDB_DATA_TYPE_JSON){ + doJsonCompare(cunit, &(*p)[i], colData); }else{ (*p)[i] = filterDoCompare(gDataCompare[cunit->func], cunit->optr, colData, cunit->valData); } @@ -3175,6 +3307,25 @@ int32_t filterSetColFieldData(SFilterInfo *info, void *param, filer_get_col_from return TSDB_CODE_SUCCESS; } +int32_t filterSetJsonColFieldData(SFilterInfo *info, void *param, filer_get_col_from_name fp) { + CHK_LRET(info == NULL, TSDB_CODE_QRY_APP_ERROR, "info NULL"); + CHK_LRET(info->fields[FLD_TYPE_COLUMN].num <= 0, TSDB_CODE_QRY_APP_ERROR, "no column fileds"); + + if (FILTER_ALL_RES(info) || FILTER_EMPTY_RES(info)) { + return TSDB_CODE_SUCCESS; + } + + for (uint16_t i = 0; i < info->fields[FLD_TYPE_COLUMN].num; ++i) { + SFilterField* fi = &info->fields[FLD_TYPE_COLUMN].fields[i]; + SSchema* sch = fi->desc; + + (*fp)(param, sch->colId, sch->name, &fi->data); + } + + filterUpdateComUnits(info); + + return TSDB_CODE_SUCCESS; +} int32_t filterInitFromTree(tExprNode* tree, void **pinfo, uint32_t options) { int32_t code = TSDB_CODE_SUCCESS; @@ -3195,10 +3346,10 @@ int32_t filterInitFromTree(tExprNode* tree, void **pinfo, uint32_t options) { filterInitUnitsFields(info); code = filterTreeToGroup(tree, info, group); - ERR_JRET(code); filterConvertGroupFromArray(info, group); + taosArrayDestroy(group); ERR_JRET(filterInitValFieldData(info)); @@ -3210,7 +3361,6 @@ int32_t filterInitFromTree(tExprNode* tree, void **pinfo, uint32_t options) { CHK_JMP(FILTER_GET_FLAG(info->status, FI_STATUS_ALL)); if (FILTER_GET_FLAG(info->status, FI_STATUS_EMPTY)) { - taosArrayDestroy(group); return code; } } @@ -3220,15 +3370,11 @@ int32_t filterInitFromTree(tExprNode* tree, void **pinfo, uint32_t options) { filterDumpInfoToString(info, "Final", 0); - taosArrayDestroy(group); - return code; _return: qInfo("No filter, code:%d", code); - taosArrayDestroy(group); - filterFreeInfo(*pinfo); *pinfo = NULL; @@ -3472,7 +3618,7 @@ int32_t filterIsIndexedColumnQuery(SFilterInfo* info, int32_t idxId, bool *res) int32_t optr = FILTER_UNIT_OPTR(info->units); CHK_JMP(optr == TSDB_RELATION_LIKE || optr == TSDB_RELATION_IN || optr == TSDB_RELATION_MATCH - || optr == TSDB_RELATION_ISNULL || optr == TSDB_RELATION_NOTNULL); + || optr == TSDB_RELATION_ISNULL || optr == TSDB_RELATION_NOTNULL || optr == TSDB_RELATION_CONTAINS); *res = true; 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 1f6de550cfe195b15aafe970dc900681939546e4..f34f54710dfd259a338ad43e5d299eb0e6e2283d 100644 --- a/src/query/src/qSqlParser.c +++ b/src/query/src/qSqlParser.c @@ -22,6 +22,7 @@ #include "ttoken.h" #include "ttokendef.h" #include "tutil.h" +#include "tscUtil.h" SSqlInfo qSqlParse(const char *pStr) { void *pParser = ParseAlloc(malloc); @@ -52,7 +53,6 @@ SSqlInfo qSqlParse(const char *pStr) { Parse(pParser, 0, t0, &sqlInfo); goto abort_parse; } - case TK_QUESTION: case TK_ILLEGAL: { snprintf(sqlInfo.msg, tListLen(sqlInfo.msg), "unrecognized token: \"%s\"", t0.z); @@ -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 @@ -387,6 +414,11 @@ tSqlExpr *tSqlExprCreate(tSqlExpr *pLeft, tSqlExpr *pRight, int32_t optrType) { pRSub->Expr.paramList = (SArray *)pRight; pExpr->pRight = pRSub; + } else if (optrType == TK_ARROW || optrType == TK_CONTAINS) { + pExpr->tokenId = optrType; + pExpr->pLeft = pLeft; + pExpr->pRight = pRight; + pExpr->type = SQL_NODE_EXPR; } else { pExpr->tokenId = optrType; pExpr->pLeft = pLeft; @@ -522,12 +554,13 @@ void tSqlExprCompact(tSqlExpr** pExpr) { } bool tSqlExprIsLeaf(tSqlExpr* pExpr) { - return (pExpr->pRight == NULL && pExpr->pLeft == NULL) && + return ((pExpr->pRight == NULL && pExpr->pLeft == NULL) && (pExpr->tokenId == 0 || (pExpr->tokenId == TK_ID) || (pExpr->tokenId >= TK_BOOL && pExpr->tokenId <= TK_NCHAR) || (pExpr->tokenId == TK_NULL) || - (pExpr->tokenId == TK_SET)); + (pExpr->tokenId == TK_SET))) || + (pExpr->tokenId == TK_ARROW); } bool tSqlExprIsParentOfLeaf(tSqlExpr* pExpr) { @@ -575,6 +608,24 @@ SArray *tVariantListAppendToken(SArray *pList, SStrToken *pToken, uint8_t order, return pList; } +SArray *commonItemAppend(SArray *pList, tVariant *pVar, tSqlExpr *jsonExp, bool isJsonExp, uint8_t sortOrder){ + if (pList == NULL) { + pList = taosArrayInit(4, sizeof(CommonItem)); + } + + CommonItem item; + item.sortOrder = sortOrder; + item.isJsonExp = isJsonExp; + if(isJsonExp){ + item.jsonExp = jsonExp; + }else{ + item.pVar = *pVar; + } + + taosArrayPush(pList, &item); + return pList; +} + SArray *tVariantListAppend(SArray *pList, tVariant *pVar, uint8_t sortOrder) { if (pList == NULL) { pList = taosArrayInit(4, sizeof(tVariantListItem)); @@ -801,6 +852,10 @@ void tSetColumnType(TAOS_FIELD *pField, SStrToken *type) { pField->bytes = (int16_t)bytes; } + } else { + if (type->type > 0) { + pField->type = -1; + } } } @@ -878,6 +933,15 @@ static void freeVariant(void *pItem) { tVariantDestroy(&p->pVar); } +static void freeCommonItem(void *pItem) { + CommonItem* p = (CommonItem *) pItem; + if (p->isJsonExp){ + tSqlExprDestroy(p->jsonExp); + }else{ + tVariantDestroy(&p->pVar); + } +} + void freeCreateTableInfo(void* p) { SCreatedTableInfo* pInfo = (SCreatedTableInfo*) p; taosArrayDestroy(pInfo->pTagNames); @@ -897,10 +961,10 @@ void destroySqlNode(SSqlNode *pSqlNode) { tSqlExprDestroy(pSqlNode->pWhere); pSqlNode->pWhere = NULL; - taosArrayDestroyEx(pSqlNode->pSortOrder, freeVariant); + taosArrayDestroyEx(pSqlNode->pSortOrder, freeCommonItem); pSqlNode->pSortOrder = NULL; - taosArrayDestroyEx(pSqlNode->pGroupby, freeVariant); + taosArrayDestroyEx(pSqlNode->pGroupby, freeCommonItem); pSqlNode->pGroupby = NULL; pSqlNode->from = destroyRelationInfo(pSqlNode->from); @@ -1015,7 +1079,6 @@ void SqlInfoDestroy(SSqlInfo *pInfo) { } else if (pInfo->type == TSDB_SQL_ALTER_TABLE) { taosArrayDestroyEx(pInfo->pAlterInfo->varList, freeVariant); taosArrayDestroy(pInfo->pAlterInfo->pAddColumns); - tfree(pInfo->pAlterInfo->tagData.data); tfree(pInfo->pAlterInfo); } else if (pInfo->type == TSDB_SQL_COMPACT_VNODE) { tSqlExprListDestroy(pInfo->list); diff --git a/src/query/src/qTsbuf.c b/src/query/src/qTsbuf.c index 9893533a589af0ca7a87dd05628db5059ecbe8eb..acbf094555e72cb72fd096014be8e8a89d700f4c 100644 --- a/src/query/src/qTsbuf.c +++ b/src/query/src/qTsbuf.c @@ -267,7 +267,8 @@ static void writeDataToDisk(STSBuf* pTSBuf) { metaLen += (int32_t)fwrite(&pBlock->tag.nType, 1, sizeof(pBlock->tag.nType), pTSBuf->f); int32_t trueLen = pBlock->tag.nLen; - if (pBlock->tag.nType == TSDB_DATA_TYPE_BINARY || pBlock->tag.nType == TSDB_DATA_TYPE_NCHAR) { + if (pBlock->tag.nType == TSDB_DATA_TYPE_BINARY || pBlock->tag.nType == TSDB_DATA_TYPE_NCHAR || + pBlock->tag.nType == TSDB_DATA_TYPE_JSON) { metaLen += (int32_t)fwrite(&pBlock->tag.nLen, 1, sizeof(pBlock->tag.nLen), pTSBuf->f); metaLen += (int32_t)fwrite(pBlock->tag.pz, 1, (size_t)pBlock->tag.nLen, pTSBuf->f); } else if (pBlock->tag.nType == TSDB_DATA_TYPE_FLOAT) { @@ -349,7 +350,8 @@ STSBlock* readDataFromDisk(STSBuf* pTSBuf, int32_t order, bool decomp) { // NOTE: mix types tags are not supported size_t sz = 0; - if (pBlock->tag.nType == TSDB_DATA_TYPE_BINARY || pBlock->tag.nType == TSDB_DATA_TYPE_NCHAR) { + if (pBlock->tag.nType == TSDB_DATA_TYPE_BINARY || pBlock->tag.nType == TSDB_DATA_TYPE_NCHAR || + pBlock->tag.nType == TSDB_DATA_TYPE_JSON) { char* tp = realloc(pBlock->tag.pz, pBlock->tag.nLen + 1); assert(tp != NULL); diff --git a/src/query/src/qUtil.c b/src/query/src/qUtil.c index a150f3a717afaa0ddd79a33a9c8be5285c327574..4da6f52d7ae08dcdbc7192c7b89a6fb2733995fe 100644 --- a/src/query/src/qUtil.c +++ b/src/query/src/qUtil.c @@ -23,6 +23,8 @@ #include "tlosertree.h" #include "queryLog.h" #include "tscompression.h" +#include "tscUtil.h" +#include "cJSON.h" typedef struct SCompSupporter { STableQueryInfo **pTableQueryInfo; @@ -587,4 +589,3 @@ void blockDistInfoFromBinary(const char* data, int32_t len, STableBlockDist* pDi tfree(outputBuf); } } - diff --git a/src/query/src/sql.c b/src/query/src/sql.c index b06e430139339e7fbe335a3dbb3683bc470b2994..0b8e9542742b9ab8b04d265c7cd6da0e482b7c92 100644 --- a/src/query/src/sql.c +++ b/src/query/src/sql.c @@ -1,3 +1,5 @@ +/* This file is automatically generated by Lemon from input grammar +** source file "sql.y". */ /* ** 2000-05-29 ** @@ -22,10 +24,7 @@ ** The following is the concatenation of all %include directives from the ** input grammar file: */ -#include -#include /************ Begin %include sections from the grammar ************************/ - #include #include #include @@ -38,11 +37,211 @@ #include "tutil.h" #include "tvariant.h" /**************** End of %include directives **********************************/ -/* These constants specify the various numeric values for terminal symbols -** in a format understandable to "makeheaders". This section is blank unless -** "lemon" is run with the "-m" command-line option. -***************** Begin makeheaders token definitions *************************/ -/**************** End makeheaders token definitions ***************************/ +/* These constants specify the various numeric values for terminal symbols. +***************** Begin token definitions *************************************/ +#ifndef TK_ID +#define TK_ID 1 +#define TK_BOOL 2 +#define TK_TINYINT 3 +#define TK_SMALLINT 4 +#define TK_INTEGER 5 +#define TK_BIGINT 6 +#define TK_FLOAT 7 +#define TK_DOUBLE 8 +#define TK_STRING 9 +#define TK_TIMESTAMP 10 +#define TK_BINARY 11 +#define TK_NCHAR 12 +#define TK_JSON 13 +#define TK_OR 14 +#define TK_AND 15 +#define TK_NOT 16 +#define TK_EQ 17 +#define TK_NE 18 +#define TK_ISNULL 19 +#define TK_NOTNULL 20 +#define TK_IS 21 +#define TK_LIKE 22 +#define TK_MATCH 23 +#define TK_NMATCH 24 +#define TK_CONTAINS 25 +#define TK_GLOB 26 +#define TK_BETWEEN 27 +#define TK_IN 28 +#define TK_GT 29 +#define TK_GE 30 +#define TK_LT 31 +#define TK_LE 32 +#define TK_BITAND 33 +#define TK_BITOR 34 +#define TK_LSHIFT 35 +#define TK_RSHIFT 36 +#define TK_PLUS 37 +#define TK_MINUS 38 +#define TK_DIVIDE 39 +#define TK_TIMES 40 +#define TK_STAR 41 +#define TK_SLASH 42 +#define TK_REM 43 +#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 ***************************************/ /* The next sections is a series of control #defines. ** various aspects of the generated parser. @@ -100,30 +299,30 @@ #endif /************* Begin control #defines *****************************************/ #define YYCODETYPE unsigned short int -#define YYNOCODE 282 +#define YYNOCODE 284 #define YYACTIONTYPE unsigned short int #define ParseTOKENTYPE SStrToken typedef union { int yyinit; ParseTOKENTYPE yy0; - tVariant yy2; - SCreateDbInfo yy10; - int32_t yy40; - SSqlNode* yy68; - SCreatedTableInfo yy72; - SLimitVal yy114; - SRangeVal yy144; - SCreateTableSql* yy170; - SIntervalVal yy280; - int yy281; - SSessionWindowVal yy295; - SArray* yy345; - tSqlExpr* yy418; - SCreateAcctInfo yy427; - SWindowStateVal yy432; - SRelationInfo* yy484; - TAOS_FIELD yy487; - int64_t yy525; + 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 @@ -139,18 +338,18 @@ typedef union { #define ParseCTX_FETCH #define ParseCTX_STORE #define YYFALLBACK 1 -#define YYNSTATE 378 -#define YYNRULE 302 -#define YYNRULE_WITH_ACTION 302 -#define YYNTOKEN 199 -#define YY_MAX_SHIFT 377 -#define YY_MIN_SHIFTREDUCE 593 -#define YY_MAX_SHIFTREDUCE 894 -#define YY_ERROR_ACTION 895 -#define YY_ACCEPT_ACTION 896 -#define YY_NO_ACTION 897 -#define YY_MIN_REDUCE 898 -#define YY_MAX_REDUCE 1199 +#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]))) @@ -217,297 +416,314 @@ typedef union { ** yy_default[] Default action for each state. ** *********** Begin parsing tables **********************************************/ -#define YY_ACTTAB_COUNT (790) +#define YY_ACTTAB_COUNT (854) static const YYACTIONTYPE yy_action[] = { - /* 0 */ 244, 644, 376, 237, 1053, 23, 213, 728, 1075, 645, - /* 10 */ 680, 896, 377, 59, 60, 250, 63, 64, 1175, 1053, - /* 20 */ 258, 53, 52, 51, 644, 62, 334, 67, 65, 68, - /* 30 */ 66, 158, 645, 336, 174, 58, 57, 354, 353, 56, - /* 40 */ 55, 54, 59, 60, 252, 63, 64, 1052, 1053, 258, - /* 50 */ 53, 52, 51, 296, 62, 334, 67, 65, 68, 66, - /* 60 */ 1023, 1066, 1021, 1022, 58, 57, 1195, 1024, 56, 55, - /* 70 */ 54, 1025, 255, 1026, 1027, 58, 57, 1072, 280, 56, - /* 80 */ 55, 54, 59, 60, 165, 63, 64, 38, 84, 258, - /* 90 */ 53, 52, 51, 90, 62, 334, 67, 65, 68, 66, - /* 100 */ 1066, 287, 286, 644, 58, 57, 332, 29, 56, 55, - /* 110 */ 54, 645, 59, 61, 831, 63, 64, 240, 1039, 258, - /* 120 */ 53, 52, 51, 644, 62, 334, 67, 65, 68, 66, - /* 130 */ 45, 645, 239, 213, 58, 57, 1050, 850, 56, 55, - /* 140 */ 54, 60, 1047, 63, 64, 1176, 281, 258, 53, 52, - /* 150 */ 51, 165, 62, 334, 67, 65, 68, 66, 38, 308, - /* 160 */ 39, 95, 58, 57, 796, 797, 56, 55, 54, 594, - /* 170 */ 595, 596, 597, 598, 599, 600, 601, 602, 603, 604, - /* 180 */ 605, 606, 607, 156, 1066, 238, 63, 64, 768, 251, - /* 190 */ 258, 53, 52, 51, 254, 62, 334, 67, 65, 68, - /* 200 */ 66, 241, 364, 248, 332, 58, 57, 1050, 210, 56, - /* 210 */ 55, 54, 256, 44, 330, 371, 370, 329, 328, 327, - /* 220 */ 369, 326, 325, 324, 368, 323, 367, 366, 1123, 16, - /* 230 */ 306, 15, 165, 24, 6, 1015, 1003, 1004, 1005, 1006, - /* 240 */ 1007, 1008, 1009, 1010, 1011, 1012, 1013, 1014, 1016, 1017, - /* 250 */ 216, 165, 257, 846, 211, 213, 835, 224, 838, 837, - /* 260 */ 841, 840, 99, 141, 140, 139, 223, 1176, 257, 846, - /* 270 */ 339, 90, 835, 772, 838, 272, 841, 56, 55, 54, - /* 280 */ 67, 65, 68, 66, 276, 275, 235, 236, 58, 57, - /* 290 */ 335, 765, 56, 55, 54, 1036, 1037, 35, 1040, 259, - /* 300 */ 372, 984, 235, 236, 5, 41, 184, 267, 45, 1122, - /* 310 */ 38, 183, 108, 113, 104, 112, 752, 9, 180, 749, - /* 320 */ 261, 750, 784, 751, 38, 102, 787, 266, 96, 38, - /* 330 */ 319, 279, 836, 82, 839, 69, 125, 119, 130, 217, - /* 340 */ 231, 946, 118, 129, 117, 135, 138, 128, 194, 263, - /* 350 */ 264, 69, 292, 293, 132, 204, 202, 200, 38, 1049, - /* 360 */ 213, 1041, 199, 145, 144, 143, 142, 127, 38, 249, - /* 370 */ 847, 842, 1176, 1050, 343, 38, 38, 843, 1050, 364, - /* 380 */ 844, 44, 38, 371, 370, 83, 847, 842, 369, 375, - /* 390 */ 374, 621, 368, 843, 367, 366, 38, 262, 38, 260, - /* 400 */ 267, 342, 341, 344, 268, 218, 265, 1050, 349, 348, - /* 410 */ 813, 181, 14, 345, 219, 267, 98, 1050, 87, 1038, - /* 420 */ 346, 350, 88, 97, 1050, 1050, 1051, 351, 155, 153, - /* 430 */ 152, 1050, 956, 753, 754, 947, 34, 242, 85, 194, - /* 440 */ 793, 352, 194, 356, 803, 1050, 101, 1050, 804, 1, - /* 450 */ 182, 3, 195, 845, 160, 283, 291, 290, 70, 283, - /* 460 */ 75, 78, 26, 738, 311, 740, 313, 739, 812, 314, - /* 470 */ 869, 848, 833, 643, 18, 81, 17, 39, 39, 70, - /* 480 */ 100, 70, 137, 136, 25, 25, 757, 25, 758, 20, - /* 490 */ 755, 19, 756, 124, 22, 123, 21, 288, 1170, 1169, - /* 500 */ 1168, 233, 79, 76, 234, 214, 215, 727, 289, 1187, - /* 510 */ 834, 220, 212, 221, 222, 1133, 226, 227, 228, 1132, - /* 520 */ 246, 225, 277, 1129, 209, 1128, 247, 355, 48, 1067, - /* 530 */ 157, 1074, 1085, 1064, 154, 1082, 1083, 284, 1115, 1087, - /* 540 */ 159, 164, 1114, 302, 1048, 176, 282, 86, 177, 1046, - /* 550 */ 178, 179, 961, 783, 316, 317, 295, 318, 321, 322, - /* 560 */ 166, 46, 243, 297, 309, 80, 207, 42, 333, 955, - /* 570 */ 340, 1194, 115, 1193, 1190, 185, 347, 1186, 121, 299, - /* 580 */ 77, 167, 50, 307, 1185, 1182, 168, 305, 186, 303, - /* 590 */ 981, 43, 301, 40, 47, 208, 943, 131, 941, 133, - /* 600 */ 134, 939, 938, 298, 269, 197, 198, 935, 934, 933, - /* 610 */ 932, 931, 930, 929, 201, 203, 925, 923, 921, 205, - /* 620 */ 918, 206, 294, 914, 320, 49, 91, 300, 1116, 365, - /* 630 */ 126, 357, 358, 359, 360, 361, 362, 232, 363, 253, - /* 640 */ 315, 373, 894, 270, 271, 893, 273, 274, 229, 892, - /* 650 */ 875, 230, 109, 960, 959, 874, 110, 146, 278, 283, - /* 660 */ 310, 10, 285, 89, 92, 760, 937, 936, 189, 147, - /* 670 */ 188, 982, 187, 190, 191, 193, 928, 192, 148, 927, - /* 680 */ 4, 149, 1019, 920, 30, 983, 919, 175, 171, 169, - /* 690 */ 172, 170, 173, 33, 2, 792, 1029, 73, 790, 789, - /* 700 */ 786, 785, 74, 163, 794, 161, 245, 805, 162, 11, - /* 710 */ 799, 93, 31, 801, 94, 304, 32, 12, 13, 27, - /* 720 */ 312, 103, 28, 101, 106, 36, 658, 693, 691, 690, - /* 730 */ 689, 105, 687, 686, 37, 107, 685, 682, 648, 111, - /* 740 */ 7, 331, 849, 337, 8, 851, 338, 114, 39, 71, - /* 750 */ 72, 116, 120, 730, 729, 726, 122, 674, 672, 664, - /* 760 */ 670, 666, 668, 662, 660, 696, 695, 694, 692, 688, - /* 770 */ 684, 683, 196, 646, 611, 898, 897, 897, 897, 897, - /* 780 */ 897, 897, 897, 897, 897, 897, 897, 897, 150, 151, + /* 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 */ 247, 1, 201, 202, 251, 269, 269, 5, 201, 9, - /* 10 */ 5, 199, 200, 13, 14, 247, 16, 17, 281, 251, - /* 20 */ 20, 21, 22, 23, 1, 25, 26, 27, 28, 29, - /* 30 */ 30, 201, 9, 15, 256, 35, 36, 35, 36, 39, - /* 40 */ 40, 41, 13, 14, 247, 16, 17, 251, 251, 20, - /* 50 */ 21, 22, 23, 275, 25, 26, 27, 28, 29, 30, - /* 60 */ 225, 249, 227, 228, 35, 36, 251, 232, 39, 40, - /* 70 */ 41, 236, 208, 238, 239, 35, 36, 270, 266, 39, - /* 80 */ 40, 41, 13, 14, 201, 16, 17, 201, 88, 20, - /* 90 */ 21, 22, 23, 84, 25, 26, 27, 28, 29, 30, - /* 100 */ 249, 271, 272, 1, 35, 36, 86, 84, 39, 40, - /* 110 */ 41, 9, 13, 14, 85, 16, 17, 266, 0, 20, - /* 120 */ 21, 22, 23, 1, 25, 26, 27, 28, 29, 30, - /* 130 */ 121, 9, 246, 269, 35, 36, 250, 119, 39, 40, - /* 140 */ 41, 14, 201, 16, 17, 281, 85, 20, 21, 22, - /* 150 */ 23, 201, 25, 26, 27, 28, 29, 30, 201, 276, - /* 160 */ 99, 278, 35, 36, 128, 129, 39, 40, 41, 47, - /* 170 */ 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, - /* 180 */ 58, 59, 60, 61, 249, 63, 16, 17, 39, 248, - /* 190 */ 20, 21, 22, 23, 208, 25, 26, 27, 28, 29, - /* 200 */ 30, 266, 92, 246, 86, 35, 36, 250, 269, 39, - /* 210 */ 40, 41, 62, 100, 101, 102, 103, 104, 105, 106, - /* 220 */ 107, 108, 109, 110, 111, 112, 113, 114, 278, 148, - /* 230 */ 280, 150, 201, 46, 84, 225, 226, 227, 228, 229, - /* 240 */ 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, - /* 250 */ 63, 201, 1, 2, 269, 269, 5, 70, 7, 5, - /* 260 */ 9, 7, 209, 76, 77, 78, 79, 281, 1, 2, - /* 270 */ 83, 84, 5, 124, 7, 145, 9, 39, 40, 41, - /* 280 */ 27, 28, 29, 30, 154, 155, 35, 36, 35, 36, - /* 290 */ 39, 99, 39, 40, 41, 242, 243, 244, 245, 208, - /* 300 */ 223, 224, 35, 36, 64, 65, 66, 201, 121, 278, - /* 310 */ 201, 71, 72, 73, 74, 75, 2, 125, 212, 5, - /* 320 */ 70, 7, 5, 9, 201, 209, 9, 70, 278, 201, - /* 330 */ 90, 144, 5, 146, 7, 84, 64, 65, 66, 269, - /* 340 */ 153, 207, 148, 71, 150, 73, 74, 75, 214, 35, - /* 350 */ 36, 84, 35, 36, 82, 64, 65, 66, 201, 250, - /* 360 */ 269, 245, 71, 72, 73, 74, 75, 80, 201, 246, - /* 370 */ 119, 120, 281, 250, 246, 201, 201, 126, 250, 92, - /* 380 */ 126, 100, 201, 102, 103, 209, 119, 120, 107, 67, - /* 390 */ 68, 69, 111, 126, 113, 114, 201, 147, 201, 149, - /* 400 */ 201, 151, 152, 246, 147, 269, 149, 250, 151, 152, - /* 410 */ 78, 212, 84, 246, 269, 201, 88, 250, 85, 243, - /* 420 */ 246, 246, 85, 252, 250, 250, 212, 246, 64, 65, - /* 430 */ 66, 250, 207, 119, 120, 207, 84, 120, 267, 214, - /* 440 */ 85, 246, 214, 246, 85, 250, 118, 250, 85, 210, - /* 450 */ 211, 205, 206, 126, 99, 122, 35, 36, 99, 122, - /* 460 */ 99, 99, 99, 85, 85, 85, 85, 85, 136, 117, - /* 470 */ 85, 85, 1, 85, 148, 84, 150, 99, 99, 99, - /* 480 */ 99, 99, 80, 81, 99, 99, 5, 99, 7, 148, - /* 490 */ 5, 150, 7, 148, 148, 150, 150, 274, 269, 269, - /* 500 */ 269, 269, 140, 142, 269, 269, 269, 116, 274, 251, - /* 510 */ 39, 269, 269, 269, 269, 241, 269, 269, 269, 241, - /* 520 */ 241, 269, 201, 241, 269, 241, 241, 241, 268, 249, - /* 530 */ 201, 201, 201, 265, 62, 201, 201, 249, 279, 201, - /* 540 */ 201, 201, 279, 201, 249, 253, 203, 203, 201, 201, - /* 550 */ 201, 201, 201, 126, 201, 201, 273, 201, 201, 201, - /* 560 */ 264, 201, 273, 273, 134, 139, 201, 201, 201, 201, - /* 570 */ 201, 201, 201, 201, 201, 201, 201, 201, 201, 273, - /* 580 */ 141, 263, 138, 137, 201, 201, 262, 132, 201, 131, - /* 590 */ 201, 201, 130, 201, 201, 201, 201, 201, 201, 201, - /* 600 */ 201, 201, 201, 133, 201, 201, 201, 201, 201, 201, - /* 610 */ 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, - /* 620 */ 201, 201, 127, 201, 91, 143, 203, 203, 203, 115, - /* 630 */ 98, 97, 53, 94, 96, 57, 95, 203, 93, 203, - /* 640 */ 203, 86, 5, 156, 5, 5, 156, 5, 203, 5, - /* 650 */ 102, 203, 209, 213, 213, 101, 209, 204, 145, 122, - /* 660 */ 117, 84, 99, 123, 99, 85, 203, 203, 216, 204, - /* 670 */ 220, 222, 221, 219, 217, 215, 203, 218, 204, 203, - /* 680 */ 205, 204, 240, 203, 84, 224, 203, 254, 259, 261, - /* 690 */ 258, 260, 257, 255, 210, 85, 240, 99, 126, 126, - /* 700 */ 5, 5, 84, 99, 85, 84, 1, 85, 84, 135, - /* 710 */ 85, 84, 99, 85, 84, 84, 99, 135, 84, 84, - /* 720 */ 117, 80, 84, 118, 72, 89, 5, 9, 5, 5, - /* 730 */ 5, 88, 5, 5, 89, 88, 5, 5, 87, 80, - /* 740 */ 84, 15, 85, 26, 84, 119, 61, 150, 99, 16, - /* 750 */ 16, 150, 150, 5, 5, 85, 150, 5, 5, 5, - /* 760 */ 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, - /* 770 */ 5, 5, 99, 87, 62, 0, 282, 282, 282, 282, - /* 780 */ 282, 282, 282, 282, 282, 282, 282, 282, 21, 21, - /* 790 */ 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, - /* 800 */ 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, - /* 810 */ 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, - /* 820 */ 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, - /* 830 */ 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, - /* 840 */ 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, - /* 850 */ 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, - /* 860 */ 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, - /* 870 */ 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, - /* 880 */ 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, - /* 890 */ 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, - /* 900 */ 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, - /* 910 */ 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, - /* 920 */ 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, - /* 930 */ 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, - /* 940 */ 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, - /* 950 */ 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, - /* 960 */ 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, - /* 970 */ 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, - /* 980 */ 282, 282, 282, 282, 282, 282, 282, 282, 282, + /* 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 (377) +#define YY_SHIFT_COUNT (389) #define YY_SHIFT_MIN (0) -#define YY_SHIFT_MAX (775) +#define YY_SHIFT_MAX (838) static const unsigned short int yy_shift_ofst[] = { - /* 0 */ 187, 113, 113, 281, 281, 20, 251, 267, 267, 23, - /* 10 */ 102, 102, 102, 102, 102, 102, 102, 102, 102, 102, - /* 20 */ 102, 102, 102, 0, 122, 267, 314, 314, 314, 9, - /* 30 */ 9, 102, 102, 36, 102, 118, 102, 102, 102, 102, - /* 40 */ 287, 20, 110, 110, 5, 790, 790, 790, 267, 267, - /* 50 */ 267, 267, 267, 267, 267, 267, 267, 267, 267, 267, - /* 60 */ 267, 267, 267, 267, 267, 267, 267, 267, 267, 267, - /* 70 */ 314, 314, 314, 317, 317, 2, 2, 2, 2, 2, - /* 80 */ 2, 2, 102, 102, 102, 149, 102, 102, 102, 9, - /* 90 */ 9, 102, 102, 102, 102, 332, 332, 192, 9, 102, - /* 100 */ 102, 102, 102, 102, 102, 102, 102, 102, 102, 102, - /* 110 */ 102, 102, 102, 102, 102, 102, 102, 102, 102, 102, - /* 120 */ 102, 102, 102, 102, 102, 102, 102, 102, 102, 102, - /* 130 */ 102, 102, 102, 102, 102, 102, 102, 102, 102, 102, - /* 140 */ 102, 102, 102, 102, 102, 102, 102, 102, 102, 102, - /* 150 */ 102, 102, 102, 102, 102, 102, 102, 472, 472, 472, - /* 160 */ 427, 427, 427, 427, 472, 472, 426, 439, 430, 444, - /* 170 */ 446, 455, 458, 462, 470, 495, 482, 472, 472, 472, - /* 180 */ 533, 533, 514, 20, 20, 472, 472, 532, 534, 579, - /* 190 */ 539, 538, 578, 541, 545, 514, 5, 472, 472, 555, - /* 200 */ 555, 472, 555, 472, 555, 472, 472, 790, 790, 29, - /* 210 */ 69, 69, 99, 69, 127, 170, 240, 253, 253, 253, - /* 220 */ 253, 253, 253, 272, 291, 40, 40, 40, 40, 250, - /* 230 */ 257, 130, 328, 238, 238, 254, 327, 322, 364, 61, - /* 240 */ 333, 337, 421, 355, 359, 363, 361, 362, 378, 379, - /* 250 */ 380, 381, 382, 352, 385, 386, 471, 150, 18, 388, - /* 260 */ 81, 194, 326, 481, 485, 341, 345, 391, 346, 402, - /* 270 */ 637, 487, 639, 640, 490, 642, 644, 548, 554, 513, - /* 280 */ 537, 543, 577, 540, 580, 600, 563, 565, 610, 598, - /* 290 */ 572, 573, 695, 696, 618, 619, 621, 622, 624, 625, - /* 300 */ 604, 627, 628, 630, 705, 631, 613, 574, 617, 582, - /* 310 */ 634, 543, 635, 603, 638, 605, 641, 636, 643, 652, - /* 320 */ 721, 645, 647, 718, 723, 724, 725, 727, 728, 731, - /* 330 */ 732, 651, 726, 659, 656, 657, 626, 660, 717, 685, - /* 340 */ 733, 597, 601, 649, 649, 649, 649, 734, 602, 606, - /* 350 */ 649, 649, 649, 748, 749, 670, 649, 752, 753, 754, - /* 360 */ 755, 756, 757, 758, 759, 760, 761, 762, 763, 764, - /* 370 */ 765, 766, 673, 686, 767, 768, 712, 775, + /* 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 (208) -#define YY_REDUCE_MIN (-264) -#define YY_REDUCE_MAX (484) +#define YY_REDUCE_COUNT (210) +#define YY_REDUCE_MIN (-276) +#define YY_REDUCE_MAX (544) static const short yy_reduce_ofst[] = { - /* 0 */ -188, 10, 10, -165, -165, 53, -136, -14, 91, -170, - /* 10 */ -114, -50, -117, -43, 123, 128, 157, 167, 174, 175, - /* 20 */ 181, 195, 197, -193, -199, -263, -247, -232, -203, -149, - /* 30 */ -65, 31, 50, -222, -59, 116, 106, 199, 214, 109, - /* 40 */ 134, 176, 225, 228, 77, 171, 239, 246, -264, -61, - /* 50 */ -15, 70, 136, 145, 229, 230, 231, 232, 235, 236, - /* 60 */ 237, 242, 243, 244, 245, 247, 248, 249, 252, 255, - /* 70 */ -204, -185, 258, 223, 234, 274, 278, 279, 282, 284, - /* 80 */ 285, 286, 321, 329, 330, 260, 331, 334, 335, 280, - /* 90 */ 288, 338, 339, 340, 342, 259, 263, 292, 295, 347, - /* 100 */ 348, 349, 350, 351, 353, 354, 356, 357, 358, 360, - /* 110 */ 365, 366, 367, 368, 369, 370, 371, 372, 373, 374, - /* 120 */ 375, 376, 377, 383, 384, 387, 389, 390, 392, 393, - /* 130 */ 394, 395, 396, 397, 398, 399, 400, 401, 403, 404, - /* 140 */ 405, 406, 407, 408, 409, 410, 411, 412, 413, 414, - /* 150 */ 415, 416, 417, 418, 419, 420, 422, 343, 344, 423, - /* 160 */ 283, 289, 290, 306, 424, 425, 268, 296, 318, 324, - /* 170 */ 428, 431, 429, 432, 435, 438, 433, 434, 436, 437, - /* 180 */ 440, 441, 442, 443, 447, 445, 448, 449, 451, 450, - /* 190 */ 452, 454, 457, 459, 460, 456, 461, 463, 464, 453, - /* 200 */ 465, 473, 474, 476, 477, 480, 483, 484, 475, + /* 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 */ 895, 1018, 957, 1028, 944, 954, 1178, 1178, 1178, 895, - /* 10 */ 895, 895, 895, 895, 895, 895, 895, 895, 895, 895, - /* 20 */ 895, 895, 895, 1076, 915, 1178, 895, 895, 895, 895, - /* 30 */ 895, 895, 895, 1100, 895, 954, 895, 895, 895, 895, - /* 40 */ 964, 954, 964, 964, 895, 1071, 1002, 1020, 895, 895, - /* 50 */ 895, 895, 895, 895, 895, 895, 895, 895, 895, 895, - /* 60 */ 895, 895, 895, 895, 895, 895, 895, 895, 895, 895, - /* 70 */ 895, 895, 895, 895, 895, 895, 895, 895, 895, 895, - /* 80 */ 895, 895, 895, 895, 895, 1078, 1084, 1081, 895, 895, - /* 90 */ 895, 1086, 895, 895, 895, 1119, 1119, 1069, 895, 895, - /* 100 */ 895, 895, 895, 895, 895, 895, 895, 895, 895, 895, - /* 110 */ 895, 895, 895, 895, 895, 895, 895, 895, 895, 895, - /* 120 */ 895, 895, 895, 895, 895, 895, 895, 895, 895, 895, - /* 130 */ 895, 942, 895, 940, 895, 895, 895, 895, 895, 895, - /* 140 */ 895, 895, 895, 895, 895, 895, 895, 895, 895, 895, - /* 150 */ 895, 895, 895, 895, 895, 895, 913, 917, 917, 917, - /* 160 */ 895, 895, 895, 895, 917, 917, 1126, 1130, 1112, 1124, - /* 170 */ 1120, 1107, 1105, 1103, 1111, 1096, 1134, 917, 917, 917, - /* 180 */ 962, 962, 958, 954, 954, 917, 917, 980, 978, 976, - /* 190 */ 968, 974, 970, 972, 966, 945, 895, 917, 917, 952, - /* 200 */ 952, 917, 952, 917, 952, 917, 917, 1002, 1020, 895, - /* 210 */ 1135, 1125, 895, 1177, 1165, 1164, 895, 1173, 1172, 1171, - /* 220 */ 1163, 1162, 1161, 895, 895, 1157, 1160, 1159, 1158, 895, - /* 230 */ 895, 895, 895, 1167, 1166, 895, 895, 895, 895, 895, - /* 240 */ 895, 895, 1093, 895, 895, 895, 1131, 1127, 895, 895, - /* 250 */ 895, 895, 895, 895, 895, 895, 895, 1137, 895, 895, - /* 260 */ 895, 895, 895, 895, 895, 895, 895, 1030, 895, 895, - /* 270 */ 895, 895, 895, 895, 895, 895, 895, 895, 895, 895, - /* 280 */ 1068, 895, 895, 895, 895, 895, 1080, 1079, 895, 895, - /* 290 */ 895, 895, 895, 895, 895, 895, 895, 895, 895, 895, - /* 300 */ 895, 895, 895, 895, 895, 895, 1121, 895, 1113, 895, - /* 310 */ 895, 1042, 895, 895, 895, 895, 895, 895, 895, 895, - /* 320 */ 895, 895, 895, 895, 895, 895, 895, 895, 895, 895, - /* 330 */ 895, 895, 895, 895, 895, 895, 895, 895, 895, 895, - /* 340 */ 895, 895, 895, 1196, 1191, 1192, 1189, 895, 895, 895, - /* 350 */ 1188, 1183, 1184, 895, 895, 895, 1181, 895, 895, 895, - /* 360 */ 895, 895, 895, 895, 895, 895, 895, 895, 895, 895, - /* 370 */ 895, 895, 986, 895, 924, 922, 895, 895, + /* 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 *****************************/ @@ -540,6 +756,7 @@ static const YYCODETYPE yyFallback[] = { 1, /* TIMESTAMP => ID */ 1, /* BINARY => ID */ 1, /* NCHAR => ID */ + 1, /* JSON => ID */ 0, /* OR => nothing */ 0, /* AND => nothing */ 0, /* NOT => nothing */ @@ -551,6 +768,7 @@ static const YYCODETYPE yyFallback[] = { 1, /* LIKE => ID */ 1, /* MATCH => ID */ 1, /* NMATCH => ID */ + 0, /* CONTAINS => nothing */ 1, /* GLOB => ID */ 0, /* BETWEEN => nothing */ 0, /* IN => nothing */ @@ -569,10 +787,10 @@ 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 */ + 0, /* ARROW => nothing */ 0, /* SHOW => nothing */ 0, /* DATABASES => nothing */ 0, /* TOPICS => nothing */ @@ -779,6 +997,7 @@ typedef struct yyParser yyParser; #ifndef NDEBUG #include +#include static FILE *yyTraceFILE = 0; static char *yyTracePrompt = 0; #endif /* NDEBUG */ @@ -826,275 +1045,277 @@ static const char *const yyTokenName[] = { /* 10 */ "TIMESTAMP", /* 11 */ "BINARY", /* 12 */ "NCHAR", - /* 13 */ "OR", - /* 14 */ "AND", - /* 15 */ "NOT", - /* 16 */ "EQ", - /* 17 */ "NE", - /* 18 */ "ISNULL", - /* 19 */ "NOTNULL", - /* 20 */ "IS", - /* 21 */ "LIKE", - /* 22 */ "MATCH", - /* 23 */ "NMATCH", - /* 24 */ "GLOB", - /* 25 */ "BETWEEN", - /* 26 */ "IN", - /* 27 */ "GT", - /* 28 */ "GE", - /* 29 */ "LT", - /* 30 */ "LE", - /* 31 */ "BITAND", - /* 32 */ "BITOR", - /* 33 */ "LSHIFT", - /* 34 */ "RSHIFT", - /* 35 */ "PLUS", - /* 36 */ "MINUS", - /* 37 */ "DIVIDE", - /* 38 */ "TIMES", - /* 39 */ "STAR", - /* 40 */ "SLASH", - /* 41 */ "REM", - /* 42 */ "CONCAT", - /* 43 */ "UMINUS", - /* 44 */ "UPLUS", - /* 45 */ "BITNOT", - /* 46 */ "SHOW", - /* 47 */ "DATABASES", - /* 48 */ "TOPICS", - /* 49 */ "FUNCTIONS", - /* 50 */ "MNODES", - /* 51 */ "DNODES", - /* 52 */ "ACCOUNTS", - /* 53 */ "USERS", - /* 54 */ "MODULES", - /* 55 */ "QUERIES", - /* 56 */ "CONNECTIONS", - /* 57 */ "STREAMS", - /* 58 */ "VARIABLES", - /* 59 */ "SCORES", - /* 60 */ "GRANTS", - /* 61 */ "VNODES", - /* 62 */ "DOT", - /* 63 */ "CREATE", - /* 64 */ "TABLE", - /* 65 */ "STABLE", - /* 66 */ "DATABASE", - /* 67 */ "TABLES", - /* 68 */ "STABLES", - /* 69 */ "VGROUPS", - /* 70 */ "DROP", - /* 71 */ "TOPIC", - /* 72 */ "FUNCTION", - /* 73 */ "DNODE", - /* 74 */ "USER", - /* 75 */ "ACCOUNT", - /* 76 */ "USE", - /* 77 */ "DESCRIBE", - /* 78 */ "DESC", - /* 79 */ "ALTER", - /* 80 */ "PASS", - /* 81 */ "PRIVILEGE", - /* 82 */ "LOCAL", - /* 83 */ "COMPACT", - /* 84 */ "LP", - /* 85 */ "RP", - /* 86 */ "IF", - /* 87 */ "EXISTS", - /* 88 */ "AS", - /* 89 */ "OUTPUTTYPE", - /* 90 */ "AGGREGATE", - /* 91 */ "BUFSIZE", - /* 92 */ "PPS", - /* 93 */ "TSERIES", - /* 94 */ "DBS", - /* 95 */ "STORAGE", - /* 96 */ "QTIME", - /* 97 */ "CONNS", - /* 98 */ "STATE", - /* 99 */ "COMMA", - /* 100 */ "KEEP", - /* 101 */ "CACHE", - /* 102 */ "REPLICA", - /* 103 */ "QUORUM", - /* 104 */ "DAYS", - /* 105 */ "MINROWS", - /* 106 */ "MAXROWS", - /* 107 */ "BLOCKS", - /* 108 */ "CTIME", - /* 109 */ "WAL", - /* 110 */ "FSYNC", - /* 111 */ "COMP", - /* 112 */ "PRECISION", - /* 113 */ "UPDATE", - /* 114 */ "CACHELAST", - /* 115 */ "PARTITIONS", - /* 116 */ "UNSIGNED", - /* 117 */ "TAGS", - /* 118 */ "USING", - /* 119 */ "NULL", - /* 120 */ "NOW", - /* 121 */ "SELECT", - /* 122 */ "UNION", - /* 123 */ "ALL", - /* 124 */ "DISTINCT", - /* 125 */ "FROM", - /* 126 */ "VARIABLE", - /* 127 */ "RANGE", - /* 128 */ "INTERVAL", - /* 129 */ "EVERY", - /* 130 */ "SESSION", - /* 131 */ "STATE_WINDOW", - /* 132 */ "FILL", - /* 133 */ "SLIDING", - /* 134 */ "ORDER", - /* 135 */ "BY", - /* 136 */ "ASC", - /* 137 */ "GROUP", - /* 138 */ "HAVING", - /* 139 */ "LIMIT", - /* 140 */ "OFFSET", - /* 141 */ "SLIMIT", - /* 142 */ "SOFFSET", - /* 143 */ "WHERE", - /* 144 */ "RESET", - /* 145 */ "QUERY", - /* 146 */ "SYNCDB", - /* 147 */ "ADD", - /* 148 */ "COLUMN", - /* 149 */ "MODIFY", - /* 150 */ "TAG", - /* 151 */ "CHANGE", - /* 152 */ "SET", - /* 153 */ "KILL", - /* 154 */ "CONNECTION", - /* 155 */ "STREAM", - /* 156 */ "COLON", - /* 157 */ "ABORT", - /* 158 */ "AFTER", - /* 159 */ "ATTACH", - /* 160 */ "BEFORE", - /* 161 */ "BEGIN", - /* 162 */ "CASCADE", - /* 163 */ "CLUSTER", - /* 164 */ "CONFLICT", - /* 165 */ "COPY", - /* 166 */ "DEFERRED", - /* 167 */ "DELIMITERS", - /* 168 */ "DETACH", - /* 169 */ "EACH", - /* 170 */ "END", - /* 171 */ "EXPLAIN", - /* 172 */ "FAIL", - /* 173 */ "FOR", - /* 174 */ "IGNORE", - /* 175 */ "IMMEDIATE", - /* 176 */ "INITIALLY", - /* 177 */ "INSTEAD", - /* 178 */ "KEY", - /* 179 */ "OF", - /* 180 */ "RAISE", - /* 181 */ "REPLACE", - /* 182 */ "RESTRICT", - /* 183 */ "ROW", - /* 184 */ "STATEMENT", - /* 185 */ "TRIGGER", - /* 186 */ "VIEW", - /* 187 */ "IPTOKEN", - /* 188 */ "SEMI", - /* 189 */ "NONE", - /* 190 */ "PREV", - /* 191 */ "LINEAR", - /* 192 */ "IMPORT", - /* 193 */ "TBNAME", - /* 194 */ "JOIN", - /* 195 */ "INSERT", - /* 196 */ "INTO", - /* 197 */ "VALUES", - /* 198 */ "FILE", - /* 199 */ "program", - /* 200 */ "cmd", - /* 201 */ "ids", - /* 202 */ "dbPrefix", - /* 203 */ "cpxName", - /* 204 */ "ifexists", - /* 205 */ "alter_db_optr", - /* 206 */ "alter_topic_optr", - /* 207 */ "acct_optr", - /* 208 */ "exprlist", - /* 209 */ "ifnotexists", - /* 210 */ "db_optr", - /* 211 */ "topic_optr", - /* 212 */ "typename", - /* 213 */ "bufsize", - /* 214 */ "pps", - /* 215 */ "tseries", - /* 216 */ "dbs", - /* 217 */ "streams", - /* 218 */ "storage", - /* 219 */ "qtime", - /* 220 */ "users", - /* 221 */ "conns", - /* 222 */ "state", - /* 223 */ "intitemlist", - /* 224 */ "intitem", - /* 225 */ "keep", - /* 226 */ "cache", - /* 227 */ "replica", - /* 228 */ "quorum", - /* 229 */ "days", - /* 230 */ "minrows", - /* 231 */ "maxrows", - /* 232 */ "blocks", - /* 233 */ "ctime", - /* 234 */ "wal", - /* 235 */ "fsync", - /* 236 */ "comp", - /* 237 */ "prec", - /* 238 */ "update", - /* 239 */ "cachelast", - /* 240 */ "partitions", - /* 241 */ "signed", - /* 242 */ "create_table_args", - /* 243 */ "create_stable_args", - /* 244 */ "create_table_list", - /* 245 */ "create_from_stable", - /* 246 */ "columnlist", - /* 247 */ "tagitemlist", - /* 248 */ "tagNamelist", - /* 249 */ "select", - /* 250 */ "column", - /* 251 */ "tagitem", - /* 252 */ "selcollist", - /* 253 */ "from", - /* 254 */ "where_opt", - /* 255 */ "range_option", - /* 256 */ "interval_option", - /* 257 */ "sliding_opt", - /* 258 */ "session_option", - /* 259 */ "windowstate_option", - /* 260 */ "fill_opt", - /* 261 */ "groupby_opt", - /* 262 */ "having_opt", - /* 263 */ "orderby_opt", - /* 264 */ "slimit_opt", - /* 265 */ "limit_opt", - /* 266 */ "union", - /* 267 */ "sclp", - /* 268 */ "distinct", - /* 269 */ "expr", - /* 270 */ "as", - /* 271 */ "tablelist", - /* 272 */ "sub", - /* 273 */ "tmvar", - /* 274 */ "timestamp", - /* 275 */ "intervalKey", - /* 276 */ "sortlist", - /* 277 */ "sortitem", - /* 278 */ "item", - /* 279 */ "sortorder", - /* 280 */ "grouplist", - /* 281 */ "expritem", + /* 13 */ "JSON", + /* 14 */ "OR", + /* 15 */ "AND", + /* 16 */ "NOT", + /* 17 */ "EQ", + /* 18 */ "NE", + /* 19 */ "ISNULL", + /* 20 */ "NOTNULL", + /* 21 */ "IS", + /* 22 */ "LIKE", + /* 23 */ "MATCH", + /* 24 */ "NMATCH", + /* 25 */ "CONTAINS", + /* 26 */ "GLOB", + /* 27 */ "BETWEEN", + /* 28 */ "IN", + /* 29 */ "GT", + /* 30 */ "GE", + /* 31 */ "LT", + /* 32 */ "LE", + /* 33 */ "BITAND", + /* 34 */ "BITOR", + /* 35 */ "LSHIFT", + /* 36 */ "RSHIFT", + /* 37 */ "PLUS", + /* 38 */ "MINUS", + /* 39 */ "DIVIDE", + /* 40 */ "TIMES", + /* 41 */ "STAR", + /* 42 */ "SLASH", + /* 43 */ "REM", + /* 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) */ @@ -1319,91 +1540,102 @@ static const char *const yyRuleName[] = { /* 214 */ "orderby_opt ::=", /* 215 */ "orderby_opt ::= ORDER BY sortlist", /* 216 */ "sortlist ::= sortlist COMMA item sortorder", - /* 217 */ "sortlist ::= item sortorder", - /* 218 */ "item ::= ids cpxName", - /* 219 */ "sortorder ::= ASC", - /* 220 */ "sortorder ::= DESC", - /* 221 */ "sortorder ::=", - /* 222 */ "groupby_opt ::=", - /* 223 */ "groupby_opt ::= GROUP BY grouplist", - /* 224 */ "grouplist ::= grouplist COMMA item", - /* 225 */ "grouplist ::= item", - /* 226 */ "having_opt ::=", - /* 227 */ "having_opt ::= HAVING expr", - /* 228 */ "limit_opt ::=", - /* 229 */ "limit_opt ::= LIMIT signed", - /* 230 */ "limit_opt ::= LIMIT signed OFFSET signed", - /* 231 */ "limit_opt ::= LIMIT signed COMMA signed", - /* 232 */ "slimit_opt ::=", - /* 233 */ "slimit_opt ::= SLIMIT signed", - /* 234 */ "slimit_opt ::= SLIMIT signed SOFFSET signed", - /* 235 */ "slimit_opt ::= SLIMIT signed COMMA signed", - /* 236 */ "where_opt ::=", - /* 237 */ "where_opt ::= WHERE expr", - /* 238 */ "expr ::= LP expr RP", - /* 239 */ "expr ::= ID", - /* 240 */ "expr ::= ID DOT ID", - /* 241 */ "expr ::= ID DOT STAR", - /* 242 */ "expr ::= INTEGER", - /* 243 */ "expr ::= MINUS INTEGER", - /* 244 */ "expr ::= PLUS INTEGER", - /* 245 */ "expr ::= FLOAT", - /* 246 */ "expr ::= MINUS FLOAT", - /* 247 */ "expr ::= PLUS FLOAT", - /* 248 */ "expr ::= STRING", - /* 249 */ "expr ::= NOW", - /* 250 */ "expr ::= VARIABLE", - /* 251 */ "expr ::= PLUS VARIABLE", - /* 252 */ "expr ::= MINUS VARIABLE", - /* 253 */ "expr ::= BOOL", - /* 254 */ "expr ::= NULL", - /* 255 */ "expr ::= ID LP exprlist RP", - /* 256 */ "expr ::= ID LP STAR RP", - /* 257 */ "expr ::= expr IS NULL", - /* 258 */ "expr ::= expr IS NOT NULL", - /* 259 */ "expr ::= expr LT expr", - /* 260 */ "expr ::= expr GT expr", - /* 261 */ "expr ::= expr LE expr", - /* 262 */ "expr ::= expr GE expr", - /* 263 */ "expr ::= expr NE expr", - /* 264 */ "expr ::= expr EQ expr", - /* 265 */ "expr ::= expr BETWEEN expr AND expr", - /* 266 */ "expr ::= expr AND expr", - /* 267 */ "expr ::= expr OR expr", - /* 268 */ "expr ::= expr PLUS expr", - /* 269 */ "expr ::= expr MINUS expr", - /* 270 */ "expr ::= expr STAR expr", - /* 271 */ "expr ::= expr SLASH expr", - /* 272 */ "expr ::= expr REM expr", - /* 273 */ "expr ::= expr LIKE expr", - /* 274 */ "expr ::= expr MATCH expr", - /* 275 */ "expr ::= expr NMATCH expr", - /* 276 */ "expr ::= expr IN LP exprlist RP", - /* 277 */ "exprlist ::= exprlist COMMA expritem", - /* 278 */ "exprlist ::= expritem", - /* 279 */ "expritem ::= expr", - /* 280 */ "expritem ::=", - /* 281 */ "cmd ::= RESET QUERY CACHE", - /* 282 */ "cmd ::= SYNCDB ids REPLICA", - /* 283 */ "cmd ::= ALTER TABLE ids cpxName ADD COLUMN columnlist", - /* 284 */ "cmd ::= ALTER TABLE ids cpxName DROP COLUMN ids", - /* 285 */ "cmd ::= ALTER TABLE ids cpxName MODIFY COLUMN columnlist", - /* 286 */ "cmd ::= ALTER TABLE ids cpxName ADD TAG columnlist", - /* 287 */ "cmd ::= ALTER TABLE ids cpxName DROP TAG ids", - /* 288 */ "cmd ::= ALTER TABLE ids cpxName CHANGE TAG ids ids", - /* 289 */ "cmd ::= ALTER TABLE ids cpxName SET TAG ids EQ tagitem", - /* 290 */ "cmd ::= ALTER TABLE ids cpxName MODIFY TAG columnlist", - /* 291 */ "cmd ::= ALTER STABLE ids cpxName ADD COLUMN columnlist", - /* 292 */ "cmd ::= ALTER STABLE ids cpxName DROP COLUMN ids", - /* 293 */ "cmd ::= ALTER STABLE ids cpxName MODIFY COLUMN columnlist", - /* 294 */ "cmd ::= ALTER STABLE ids cpxName ADD TAG columnlist", - /* 295 */ "cmd ::= ALTER STABLE ids cpxName DROP TAG ids", - /* 296 */ "cmd ::= ALTER STABLE ids cpxName CHANGE TAG ids ids", - /* 297 */ "cmd ::= ALTER STABLE ids cpxName SET TAG ids EQ tagitem", - /* 298 */ "cmd ::= ALTER STABLE ids cpxName MODIFY TAG columnlist", - /* 299 */ "cmd ::= KILL CONNECTION INTEGER", - /* 300 */ "cmd ::= KILL STREAM INTEGER COLON INTEGER", - /* 301 */ "cmd ::= KILL QUERY INTEGER COLON INTEGER", + /* 217 */ "sortlist ::= sortlist COMMA arrow sortorder", + /* 218 */ "sortlist ::= item sortorder", + /* 219 */ "sortlist ::= arrow sortorder", + /* 220 */ "item ::= ID", + /* 221 */ "item ::= ID DOT ID", + /* 222 */ "sortorder ::= ASC", + /* 223 */ "sortorder ::= DESC", + /* 224 */ "sortorder ::=", + /* 225 */ "groupby_opt ::=", + /* 226 */ "groupby_opt ::= GROUP BY grouplist", + /* 227 */ "grouplist ::= grouplist COMMA item", + /* 228 */ "grouplist ::= grouplist COMMA arrow", + /* 229 */ "grouplist ::= item", + /* 230 */ "grouplist ::= arrow", + /* 231 */ "having_opt ::=", + /* 232 */ "having_opt ::= HAVING expr", + /* 233 */ "limit_opt ::=", + /* 234 */ "limit_opt ::= LIMIT signed", + /* 235 */ "limit_opt ::= LIMIT signed OFFSET signed", + /* 236 */ "limit_opt ::= LIMIT signed COMMA signed", + /* 237 */ "slimit_opt ::=", + /* 238 */ "slimit_opt ::= SLIMIT signed", + /* 239 */ "slimit_opt ::= SLIMIT signed SOFFSET signed", + /* 240 */ "slimit_opt ::= SLIMIT signed COMMA signed", + /* 241 */ "where_opt ::=", + /* 242 */ "where_opt ::= WHERE expr", + /* 243 */ "expr ::= LP expr RP", + /* 244 */ "expr ::= ID", + /* 245 */ "expr ::= ID DOT ID", + /* 246 */ "expr ::= ID DOT STAR", + /* 247 */ "expr ::= INTEGER", + /* 248 */ "expr ::= MINUS INTEGER", + /* 249 */ "expr ::= PLUS INTEGER", + /* 250 */ "expr ::= FLOAT", + /* 251 */ "expr ::= MINUS FLOAT", + /* 252 */ "expr ::= PLUS FLOAT", + /* 253 */ "expr ::= STRING", + /* 254 */ "expr ::= NOW", + /* 255 */ "expr ::= VARIABLE", + /* 256 */ "expr ::= PLUS VARIABLE", + /* 257 */ "expr ::= MINUS VARIABLE", + /* 258 */ "expr ::= BOOL", + /* 259 */ "expr ::= NULL", + /* 260 */ "expr ::= ID LP exprlist RP", + /* 261 */ "expr ::= ID LP STAR RP", + /* 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 */ @@ -1529,61 +1761,57 @@ static void yy_destructor( ** inside the C code. */ /********* Begin destructor definitions ***************************************/ - case 208: /* exprlist */ - case 252: /* selcollist */ - case 267: /* sclp */ + case 210: /* exprlist */ + case 254: /* selcollist */ + case 269: /* sclp */ { -tSqlExprListDestroy((yypminor->yy345)); -} - break; - case 223: /* intitemlist */ - case 225: /* keep */ - case 246: /* columnlist */ - case 247: /* tagitemlist */ - case 248: /* tagNamelist */ - case 260: /* fill_opt */ - case 261: /* groupby_opt */ - case 263: /* orderby_opt */ - case 276: /* sortlist */ - case 280: /* grouplist */ -{ -taosArrayDestroy((yypminor->yy345)); +tSqlExprListDestroy((yypminor->yy189)); } break; - case 244: /* create_table_list */ + 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 */ { -destroyCreateTableSql((yypminor->yy170)); +taosArrayDestroy((yypminor->yy189)); } break; - case 249: /* select */ + case 246: /* create_table_list */ { -destroySqlNode((yypminor->yy68)); +destroyCreateTableSql((yypminor->yy6)); } break; - case 253: /* from */ - case 271: /* tablelist */ - case 272: /* sub */ + case 251: /* select */ { -destroyRelationInfo((yypminor->yy484)); +destroySqlNode((yypminor->yy16)); } break; - case 254: /* where_opt */ - case 262: /* having_opt */ - case 269: /* expr */ - case 274: /* timestamp */ - case 281: /* expritem */ + case 255: /* from */ + case 273: /* tablelist */ + case 274: /* sub */ { -tSqlExprDestroy((yypminor->yy418)); +destroyRelationInfo((yypminor->yy36)); } break; - case 266: /* union */ + case 256: /* where_opt */ + case 264: /* having_opt */ + case 271: /* expr */ + case 276: /* timestamp */ + case 281: /* arrow */ + case 283: /* expritem */ { -destroyAllSqlNode((yypminor->yy345)); +tSqlExprDestroy((yypminor->yy18)); } break; - case 277: /* sortitem */ + case 268: /* union */ { -tVariantDestroy(&(yypminor->yy2)); +destroyAllSqlNode((yypminor->yy189)); } break; /********* End destructor definitions *****************************************/ @@ -1750,7 +1978,7 @@ static YYACTIONTYPE yy_find_shift_action( #endif /* YYWILDCARD */ return yy_default[stateno]; }else{ - assert( i>=0 && i=0 && i<(int)(sizeof(yy_action)/sizeof(yy_action[0])) ); return yy_action[i]; } }while(1); @@ -1872,308 +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[] = { - 199, /* (0) program ::= cmd */ - 200, /* (1) cmd ::= SHOW DATABASES */ - 200, /* (2) cmd ::= SHOW TOPICS */ - 200, /* (3) cmd ::= SHOW FUNCTIONS */ - 200, /* (4) cmd ::= SHOW MNODES */ - 200, /* (5) cmd ::= SHOW DNODES */ - 200, /* (6) cmd ::= SHOW ACCOUNTS */ - 200, /* (7) cmd ::= SHOW USERS */ - 200, /* (8) cmd ::= SHOW MODULES */ - 200, /* (9) cmd ::= SHOW QUERIES */ - 200, /* (10) cmd ::= SHOW CONNECTIONS */ - 200, /* (11) cmd ::= SHOW STREAMS */ - 200, /* (12) cmd ::= SHOW VARIABLES */ - 200, /* (13) cmd ::= SHOW SCORES */ - 200, /* (14) cmd ::= SHOW GRANTS */ - 200, /* (15) cmd ::= SHOW VNODES */ - 200, /* (16) cmd ::= SHOW VNODES ids */ - 202, /* (17) dbPrefix ::= */ - 202, /* (18) dbPrefix ::= ids DOT */ - 203, /* (19) cpxName ::= */ - 203, /* (20) cpxName ::= DOT ids */ - 200, /* (21) cmd ::= SHOW CREATE TABLE ids cpxName */ - 200, /* (22) cmd ::= SHOW CREATE STABLE ids cpxName */ - 200, /* (23) cmd ::= SHOW CREATE DATABASE ids */ - 200, /* (24) cmd ::= SHOW dbPrefix TABLES */ - 200, /* (25) cmd ::= SHOW dbPrefix TABLES LIKE ids */ - 200, /* (26) cmd ::= SHOW dbPrefix STABLES */ - 200, /* (27) cmd ::= SHOW dbPrefix STABLES LIKE ids */ - 200, /* (28) cmd ::= SHOW dbPrefix VGROUPS */ - 200, /* (29) cmd ::= DROP TABLE ifexists ids cpxName */ - 200, /* (30) cmd ::= DROP STABLE ifexists ids cpxName */ - 200, /* (31) cmd ::= DROP DATABASE ifexists ids */ - 200, /* (32) cmd ::= DROP TOPIC ifexists ids */ - 200, /* (33) cmd ::= DROP FUNCTION ids */ - 200, /* (34) cmd ::= DROP DNODE ids */ - 200, /* (35) cmd ::= DROP USER ids */ - 200, /* (36) cmd ::= DROP ACCOUNT ids */ - 200, /* (37) cmd ::= USE ids */ - 200, /* (38) cmd ::= DESCRIBE ids cpxName */ - 200, /* (39) cmd ::= DESC ids cpxName */ - 200, /* (40) cmd ::= ALTER USER ids PASS ids */ - 200, /* (41) cmd ::= ALTER USER ids PRIVILEGE ids */ - 200, /* (42) cmd ::= ALTER DNODE ids ids */ - 200, /* (43) cmd ::= ALTER DNODE ids ids ids */ - 200, /* (44) cmd ::= ALTER LOCAL ids */ - 200, /* (45) cmd ::= ALTER LOCAL ids ids */ - 200, /* (46) cmd ::= ALTER DATABASE ids alter_db_optr */ - 200, /* (47) cmd ::= ALTER TOPIC ids alter_topic_optr */ - 200, /* (48) cmd ::= ALTER ACCOUNT ids acct_optr */ - 200, /* (49) cmd ::= ALTER ACCOUNT ids PASS ids acct_optr */ - 200, /* (50) cmd ::= COMPACT VNODES IN LP exprlist RP */ - 201, /* (51) ids ::= ID */ - 201, /* (52) ids ::= STRING */ - 204, /* (53) ifexists ::= IF EXISTS */ - 204, /* (54) ifexists ::= */ - 209, /* (55) ifnotexists ::= IF NOT EXISTS */ - 209, /* (56) ifnotexists ::= */ - 200, /* (57) cmd ::= CREATE DNODE ids */ - 200, /* (58) cmd ::= CREATE ACCOUNT ids PASS ids acct_optr */ - 200, /* (59) cmd ::= CREATE DATABASE ifnotexists ids db_optr */ - 200, /* (60) cmd ::= CREATE TOPIC ifnotexists ids topic_optr */ - 200, /* (61) cmd ::= CREATE FUNCTION ids AS ids OUTPUTTYPE typename bufsize */ - 200, /* (62) cmd ::= CREATE AGGREGATE FUNCTION ids AS ids OUTPUTTYPE typename bufsize */ - 200, /* (63) cmd ::= CREATE USER ids PASS ids */ - 213, /* (64) bufsize ::= */ - 213, /* (65) bufsize ::= BUFSIZE INTEGER */ - 214, /* (66) pps ::= */ - 214, /* (67) pps ::= PPS INTEGER */ - 215, /* (68) tseries ::= */ - 215, /* (69) tseries ::= TSERIES INTEGER */ - 216, /* (70) dbs ::= */ - 216, /* (71) dbs ::= DBS INTEGER */ - 217, /* (72) streams ::= */ - 217, /* (73) streams ::= STREAMS INTEGER */ - 218, /* (74) storage ::= */ - 218, /* (75) storage ::= STORAGE INTEGER */ - 219, /* (76) qtime ::= */ - 219, /* (77) qtime ::= QTIME INTEGER */ - 220, /* (78) users ::= */ - 220, /* (79) users ::= USERS INTEGER */ - 221, /* (80) conns ::= */ - 221, /* (81) conns ::= CONNS INTEGER */ - 222, /* (82) state ::= */ - 222, /* (83) state ::= STATE ids */ - 207, /* (84) acct_optr ::= pps tseries storage streams qtime dbs users conns state */ - 223, /* (85) intitemlist ::= intitemlist COMMA intitem */ - 223, /* (86) intitemlist ::= intitem */ - 224, /* (87) intitem ::= INTEGER */ - 225, /* (88) keep ::= KEEP intitemlist */ - 226, /* (89) cache ::= CACHE INTEGER */ - 227, /* (90) replica ::= REPLICA INTEGER */ - 228, /* (91) quorum ::= QUORUM INTEGER */ - 229, /* (92) days ::= DAYS INTEGER */ - 230, /* (93) minrows ::= MINROWS INTEGER */ - 231, /* (94) maxrows ::= MAXROWS INTEGER */ - 232, /* (95) blocks ::= BLOCKS INTEGER */ - 233, /* (96) ctime ::= CTIME INTEGER */ - 234, /* (97) wal ::= WAL INTEGER */ - 235, /* (98) fsync ::= FSYNC INTEGER */ - 236, /* (99) comp ::= COMP INTEGER */ - 237, /* (100) prec ::= PRECISION STRING */ - 238, /* (101) update ::= UPDATE INTEGER */ - 239, /* (102) cachelast ::= CACHELAST INTEGER */ - 240, /* (103) partitions ::= PARTITIONS INTEGER */ - 210, /* (104) db_optr ::= */ - 210, /* (105) db_optr ::= db_optr cache */ - 210, /* (106) db_optr ::= db_optr replica */ - 210, /* (107) db_optr ::= db_optr quorum */ - 210, /* (108) db_optr ::= db_optr days */ - 210, /* (109) db_optr ::= db_optr minrows */ - 210, /* (110) db_optr ::= db_optr maxrows */ - 210, /* (111) db_optr ::= db_optr blocks */ - 210, /* (112) db_optr ::= db_optr ctime */ - 210, /* (113) db_optr ::= db_optr wal */ - 210, /* (114) db_optr ::= db_optr fsync */ - 210, /* (115) db_optr ::= db_optr comp */ - 210, /* (116) db_optr ::= db_optr prec */ - 210, /* (117) db_optr ::= db_optr keep */ - 210, /* (118) db_optr ::= db_optr update */ - 210, /* (119) db_optr ::= db_optr cachelast */ - 211, /* (120) topic_optr ::= db_optr */ - 211, /* (121) topic_optr ::= topic_optr partitions */ - 205, /* (122) alter_db_optr ::= */ - 205, /* (123) alter_db_optr ::= alter_db_optr replica */ - 205, /* (124) alter_db_optr ::= alter_db_optr quorum */ - 205, /* (125) alter_db_optr ::= alter_db_optr keep */ - 205, /* (126) alter_db_optr ::= alter_db_optr blocks */ - 205, /* (127) alter_db_optr ::= alter_db_optr comp */ - 205, /* (128) alter_db_optr ::= alter_db_optr update */ - 205, /* (129) alter_db_optr ::= alter_db_optr cachelast */ - 206, /* (130) alter_topic_optr ::= alter_db_optr */ - 206, /* (131) alter_topic_optr ::= alter_topic_optr partitions */ - 212, /* (132) typename ::= ids */ - 212, /* (133) typename ::= ids LP signed RP */ - 212, /* (134) typename ::= ids UNSIGNED */ - 241, /* (135) signed ::= INTEGER */ - 241, /* (136) signed ::= PLUS INTEGER */ - 241, /* (137) signed ::= MINUS INTEGER */ - 200, /* (138) cmd ::= CREATE TABLE create_table_args */ - 200, /* (139) cmd ::= CREATE TABLE create_stable_args */ - 200, /* (140) cmd ::= CREATE STABLE create_stable_args */ - 200, /* (141) cmd ::= CREATE TABLE create_table_list */ - 244, /* (142) create_table_list ::= create_from_stable */ - 244, /* (143) create_table_list ::= create_table_list create_from_stable */ - 242, /* (144) create_table_args ::= ifnotexists ids cpxName LP columnlist RP */ - 243, /* (145) create_stable_args ::= ifnotexists ids cpxName LP columnlist RP TAGS LP columnlist RP */ - 245, /* (146) create_from_stable ::= ifnotexists ids cpxName USING ids cpxName TAGS LP tagitemlist RP */ - 245, /* (147) create_from_stable ::= ifnotexists ids cpxName USING ids cpxName LP tagNamelist RP TAGS LP tagitemlist RP */ - 248, /* (148) tagNamelist ::= tagNamelist COMMA ids */ - 248, /* (149) tagNamelist ::= ids */ - 242, /* (150) create_table_args ::= ifnotexists ids cpxName AS select */ - 246, /* (151) columnlist ::= columnlist COMMA column */ - 246, /* (152) columnlist ::= column */ - 250, /* (153) column ::= ids typename */ - 247, /* (154) tagitemlist ::= tagitemlist COMMA tagitem */ - 247, /* (155) tagitemlist ::= tagitem */ - 251, /* (156) tagitem ::= INTEGER */ - 251, /* (157) tagitem ::= FLOAT */ - 251, /* (158) tagitem ::= STRING */ - 251, /* (159) tagitem ::= BOOL */ - 251, /* (160) tagitem ::= NULL */ - 251, /* (161) tagitem ::= NOW */ - 251, /* (162) tagitem ::= MINUS INTEGER */ - 251, /* (163) tagitem ::= MINUS FLOAT */ - 251, /* (164) tagitem ::= PLUS INTEGER */ - 251, /* (165) tagitem ::= PLUS FLOAT */ - 249, /* (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 */ - 249, /* (167) select ::= LP select RP */ - 266, /* (168) union ::= select */ - 266, /* (169) union ::= union UNION ALL select */ - 200, /* (170) cmd ::= union */ - 249, /* (171) select ::= SELECT selcollist */ - 267, /* (172) sclp ::= selcollist COMMA */ - 267, /* (173) sclp ::= */ - 252, /* (174) selcollist ::= sclp distinct expr as */ - 252, /* (175) selcollist ::= sclp STAR */ - 270, /* (176) as ::= AS ids */ - 270, /* (177) as ::= ids */ - 270, /* (178) as ::= */ - 268, /* (179) distinct ::= DISTINCT */ - 268, /* (180) distinct ::= */ - 253, /* (181) from ::= FROM tablelist */ - 253, /* (182) from ::= FROM sub */ - 272, /* (183) sub ::= LP union RP */ - 272, /* (184) sub ::= LP union RP ids */ - 272, /* (185) sub ::= sub COMMA LP union RP ids */ - 271, /* (186) tablelist ::= ids cpxName */ - 271, /* (187) tablelist ::= ids cpxName ids */ - 271, /* (188) tablelist ::= tablelist COMMA ids cpxName */ - 271, /* (189) tablelist ::= tablelist COMMA ids cpxName ids */ - 273, /* (190) tmvar ::= VARIABLE */ - 274, /* (191) timestamp ::= INTEGER */ - 274, /* (192) timestamp ::= MINUS INTEGER */ - 274, /* (193) timestamp ::= PLUS INTEGER */ - 274, /* (194) timestamp ::= STRING */ - 274, /* (195) timestamp ::= NOW */ - 274, /* (196) timestamp ::= NOW PLUS VARIABLE */ - 274, /* (197) timestamp ::= NOW MINUS VARIABLE */ - 255, /* (198) range_option ::= */ - 255, /* (199) range_option ::= RANGE LP timestamp COMMA timestamp RP */ - 256, /* (200) interval_option ::= intervalKey LP tmvar RP */ - 256, /* (201) interval_option ::= intervalKey LP tmvar COMMA tmvar RP */ - 256, /* (202) interval_option ::= */ - 275, /* (203) intervalKey ::= INTERVAL */ - 275, /* (204) intervalKey ::= EVERY */ - 258, /* (205) session_option ::= */ - 258, /* (206) session_option ::= SESSION LP ids cpxName COMMA tmvar RP */ - 259, /* (207) windowstate_option ::= */ - 259, /* (208) windowstate_option ::= STATE_WINDOW LP ids RP */ - 260, /* (209) fill_opt ::= */ - 260, /* (210) fill_opt ::= FILL LP ID COMMA tagitemlist RP */ - 260, /* (211) fill_opt ::= FILL LP ID RP */ - 257, /* (212) sliding_opt ::= SLIDING LP tmvar RP */ - 257, /* (213) sliding_opt ::= */ - 263, /* (214) orderby_opt ::= */ - 263, /* (215) orderby_opt ::= ORDER BY sortlist */ - 276, /* (216) sortlist ::= sortlist COMMA item sortorder */ - 276, /* (217) sortlist ::= item sortorder */ - 278, /* (218) item ::= ids cpxName */ - 279, /* (219) sortorder ::= ASC */ - 279, /* (220) sortorder ::= DESC */ - 279, /* (221) sortorder ::= */ - 261, /* (222) groupby_opt ::= */ - 261, /* (223) groupby_opt ::= GROUP BY grouplist */ - 280, /* (224) grouplist ::= grouplist COMMA item */ - 280, /* (225) grouplist ::= item */ - 262, /* (226) having_opt ::= */ - 262, /* (227) having_opt ::= HAVING expr */ - 265, /* (228) limit_opt ::= */ - 265, /* (229) limit_opt ::= LIMIT signed */ - 265, /* (230) limit_opt ::= LIMIT signed OFFSET signed */ - 265, /* (231) limit_opt ::= LIMIT signed COMMA signed */ - 264, /* (232) slimit_opt ::= */ - 264, /* (233) slimit_opt ::= SLIMIT signed */ - 264, /* (234) slimit_opt ::= SLIMIT signed SOFFSET signed */ - 264, /* (235) slimit_opt ::= SLIMIT signed COMMA signed */ - 254, /* (236) where_opt ::= */ - 254, /* (237) where_opt ::= WHERE expr */ - 269, /* (238) expr ::= LP expr RP */ - 269, /* (239) expr ::= ID */ - 269, /* (240) expr ::= ID DOT ID */ - 269, /* (241) expr ::= ID DOT STAR */ - 269, /* (242) expr ::= INTEGER */ - 269, /* (243) expr ::= MINUS INTEGER */ - 269, /* (244) expr ::= PLUS INTEGER */ - 269, /* (245) expr ::= FLOAT */ - 269, /* (246) expr ::= MINUS FLOAT */ - 269, /* (247) expr ::= PLUS FLOAT */ - 269, /* (248) expr ::= STRING */ - 269, /* (249) expr ::= NOW */ - 269, /* (250) expr ::= VARIABLE */ - 269, /* (251) expr ::= PLUS VARIABLE */ - 269, /* (252) expr ::= MINUS VARIABLE */ - 269, /* (253) expr ::= BOOL */ - 269, /* (254) expr ::= NULL */ - 269, /* (255) expr ::= ID LP exprlist RP */ - 269, /* (256) expr ::= ID LP STAR RP */ - 269, /* (257) expr ::= expr IS NULL */ - 269, /* (258) expr ::= expr IS NOT NULL */ - 269, /* (259) expr ::= expr LT expr */ - 269, /* (260) expr ::= expr GT expr */ - 269, /* (261) expr ::= expr LE expr */ - 269, /* (262) expr ::= expr GE expr */ - 269, /* (263) expr ::= expr NE expr */ - 269, /* (264) expr ::= expr EQ expr */ - 269, /* (265) expr ::= expr BETWEEN expr AND expr */ - 269, /* (266) expr ::= expr AND expr */ - 269, /* (267) expr ::= expr OR expr */ - 269, /* (268) expr ::= expr PLUS expr */ - 269, /* (269) expr ::= expr MINUS expr */ - 269, /* (270) expr ::= expr STAR expr */ - 269, /* (271) expr ::= expr SLASH expr */ - 269, /* (272) expr ::= expr REM expr */ - 269, /* (273) expr ::= expr LIKE expr */ - 269, /* (274) expr ::= expr MATCH expr */ - 269, /* (275) expr ::= expr NMATCH expr */ - 269, /* (276) expr ::= expr IN LP exprlist RP */ - 208, /* (277) exprlist ::= exprlist COMMA expritem */ - 208, /* (278) exprlist ::= expritem */ - 281, /* (279) expritem ::= expr */ - 281, /* (280) expritem ::= */ - 200, /* (281) cmd ::= RESET QUERY CACHE */ - 200, /* (282) cmd ::= SYNCDB ids REPLICA */ - 200, /* (283) cmd ::= ALTER TABLE ids cpxName ADD COLUMN columnlist */ - 200, /* (284) cmd ::= ALTER TABLE ids cpxName DROP COLUMN ids */ - 200, /* (285) cmd ::= ALTER TABLE ids cpxName MODIFY COLUMN columnlist */ - 200, /* (286) cmd ::= ALTER TABLE ids cpxName ADD TAG columnlist */ - 200, /* (287) cmd ::= ALTER TABLE ids cpxName DROP TAG ids */ - 200, /* (288) cmd ::= ALTER TABLE ids cpxName CHANGE TAG ids ids */ - 200, /* (289) cmd ::= ALTER TABLE ids cpxName SET TAG ids EQ tagitem */ - 200, /* (290) cmd ::= ALTER TABLE ids cpxName MODIFY TAG columnlist */ - 200, /* (291) cmd ::= ALTER STABLE ids cpxName ADD COLUMN columnlist */ - 200, /* (292) cmd ::= ALTER STABLE ids cpxName DROP COLUMN ids */ - 200, /* (293) cmd ::= ALTER STABLE ids cpxName MODIFY COLUMN columnlist */ - 200, /* (294) cmd ::= ALTER STABLE ids cpxName ADD TAG columnlist */ - 200, /* (295) cmd ::= ALTER STABLE ids cpxName DROP TAG ids */ - 200, /* (296) cmd ::= ALTER STABLE ids cpxName CHANGE TAG ids ids */ - 200, /* (297) cmd ::= ALTER STABLE ids cpxName SET TAG ids EQ tagitem */ - 200, /* (298) cmd ::= ALTER STABLE ids cpxName MODIFY TAG columnlist */ - 200, /* (299) cmd ::= KILL CONNECTION INTEGER */ - 200, /* (300) cmd ::= KILL STREAM INTEGER COLON INTEGER */ - 200, /* (301) 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 @@ -2396,91 +2635,102 @@ static const signed char yyRuleInfoNRhs[] = { 0, /* (214) orderby_opt ::= */ -3, /* (215) orderby_opt ::= ORDER BY sortlist */ -4, /* (216) sortlist ::= sortlist COMMA item sortorder */ - -2, /* (217) sortlist ::= item sortorder */ - -2, /* (218) item ::= ids cpxName */ - -1, /* (219) sortorder ::= ASC */ - -1, /* (220) sortorder ::= DESC */ - 0, /* (221) sortorder ::= */ - 0, /* (222) groupby_opt ::= */ - -3, /* (223) groupby_opt ::= GROUP BY grouplist */ - -3, /* (224) grouplist ::= grouplist COMMA item */ - -1, /* (225) grouplist ::= item */ - 0, /* (226) having_opt ::= */ - -2, /* (227) having_opt ::= HAVING expr */ - 0, /* (228) limit_opt ::= */ - -2, /* (229) limit_opt ::= LIMIT signed */ - -4, /* (230) limit_opt ::= LIMIT signed OFFSET signed */ - -4, /* (231) limit_opt ::= LIMIT signed COMMA signed */ - 0, /* (232) slimit_opt ::= */ - -2, /* (233) slimit_opt ::= SLIMIT signed */ - -4, /* (234) slimit_opt ::= SLIMIT signed SOFFSET signed */ - -4, /* (235) slimit_opt ::= SLIMIT signed COMMA signed */ - 0, /* (236) where_opt ::= */ - -2, /* (237) where_opt ::= WHERE expr */ - -3, /* (238) expr ::= LP expr RP */ - -1, /* (239) expr ::= ID */ - -3, /* (240) expr ::= ID DOT ID */ - -3, /* (241) expr ::= ID DOT STAR */ - -1, /* (242) expr ::= INTEGER */ - -2, /* (243) expr ::= MINUS INTEGER */ - -2, /* (244) expr ::= PLUS INTEGER */ - -1, /* (245) expr ::= FLOAT */ - -2, /* (246) expr ::= MINUS FLOAT */ - -2, /* (247) expr ::= PLUS FLOAT */ - -1, /* (248) expr ::= STRING */ - -1, /* (249) expr ::= NOW */ - -1, /* (250) expr ::= VARIABLE */ - -2, /* (251) expr ::= PLUS VARIABLE */ - -2, /* (252) expr ::= MINUS VARIABLE */ - -1, /* (253) expr ::= BOOL */ - -1, /* (254) expr ::= NULL */ - -4, /* (255) expr ::= ID LP exprlist RP */ - -4, /* (256) expr ::= ID LP STAR RP */ - -3, /* (257) expr ::= expr IS NULL */ - -4, /* (258) expr ::= expr IS NOT NULL */ - -3, /* (259) expr ::= expr LT expr */ - -3, /* (260) expr ::= expr GT expr */ - -3, /* (261) expr ::= expr LE expr */ - -3, /* (262) expr ::= expr GE expr */ - -3, /* (263) expr ::= expr NE expr */ - -3, /* (264) expr ::= expr EQ expr */ - -5, /* (265) expr ::= expr BETWEEN expr AND expr */ - -3, /* (266) expr ::= expr AND expr */ - -3, /* (267) expr ::= expr OR expr */ - -3, /* (268) expr ::= expr PLUS expr */ - -3, /* (269) expr ::= expr MINUS expr */ - -3, /* (270) expr ::= expr STAR expr */ - -3, /* (271) expr ::= expr SLASH expr */ - -3, /* (272) expr ::= expr REM expr */ - -3, /* (273) expr ::= expr LIKE expr */ - -3, /* (274) expr ::= expr MATCH expr */ - -3, /* (275) expr ::= expr NMATCH expr */ - -5, /* (276) expr ::= expr IN LP exprlist RP */ - -3, /* (277) exprlist ::= exprlist COMMA expritem */ - -1, /* (278) exprlist ::= expritem */ - -1, /* (279) expritem ::= expr */ - 0, /* (280) expritem ::= */ - -3, /* (281) cmd ::= RESET QUERY CACHE */ - -3, /* (282) cmd ::= SYNCDB ids REPLICA */ - -7, /* (283) cmd ::= ALTER TABLE ids cpxName ADD COLUMN columnlist */ - -7, /* (284) cmd ::= ALTER TABLE ids cpxName DROP COLUMN ids */ - -7, /* (285) cmd ::= ALTER TABLE ids cpxName MODIFY COLUMN columnlist */ - -7, /* (286) cmd ::= ALTER TABLE ids cpxName ADD TAG columnlist */ - -7, /* (287) cmd ::= ALTER TABLE ids cpxName DROP TAG ids */ - -8, /* (288) cmd ::= ALTER TABLE ids cpxName CHANGE TAG ids ids */ - -9, /* (289) cmd ::= ALTER TABLE ids cpxName SET TAG ids EQ tagitem */ - -7, /* (290) cmd ::= ALTER TABLE ids cpxName MODIFY TAG columnlist */ - -7, /* (291) cmd ::= ALTER STABLE ids cpxName ADD COLUMN columnlist */ - -7, /* (292) cmd ::= ALTER STABLE ids cpxName DROP COLUMN ids */ - -7, /* (293) cmd ::= ALTER STABLE ids cpxName MODIFY COLUMN columnlist */ - -7, /* (294) cmd ::= ALTER STABLE ids cpxName ADD TAG columnlist */ - -7, /* (295) cmd ::= ALTER STABLE ids cpxName DROP TAG ids */ - -8, /* (296) cmd ::= ALTER STABLE ids cpxName CHANGE TAG ids ids */ - -9, /* (297) cmd ::= ALTER STABLE ids cpxName SET TAG ids EQ tagitem */ - -7, /* (298) cmd ::= ALTER STABLE ids cpxName MODIFY TAG columnlist */ - -3, /* (299) cmd ::= KILL CONNECTION INTEGER */ - -5, /* (300) cmd ::= KILL STREAM INTEGER COLON INTEGER */ - -5, /* (301) cmd ::= KILL QUERY INTEGER COLON INTEGER */ + -4, /* (217) sortlist ::= sortlist COMMA arrow sortorder */ + -2, /* (218) sortlist ::= item sortorder */ + -2, /* (219) sortlist ::= arrow sortorder */ + -1, /* (220) item ::= ID */ + -3, /* (221) item ::= ID DOT ID */ + -1, /* (222) sortorder ::= ASC */ + -1, /* (223) sortorder ::= DESC */ + 0, /* (224) sortorder ::= */ + 0, /* (225) groupby_opt ::= */ + -3, /* (226) groupby_opt ::= GROUP BY grouplist */ + -3, /* (227) grouplist ::= grouplist COMMA item */ + -3, /* (228) grouplist ::= grouplist COMMA arrow */ + -1, /* (229) grouplist ::= item */ + -1, /* (230) grouplist ::= arrow */ + 0, /* (231) having_opt ::= */ + -2, /* (232) having_opt ::= HAVING expr */ + 0, /* (233) limit_opt ::= */ + -2, /* (234) limit_opt ::= LIMIT signed */ + -4, /* (235) limit_opt ::= LIMIT signed OFFSET signed */ + -4, /* (236) limit_opt ::= LIMIT signed COMMA signed */ + 0, /* (237) slimit_opt ::= */ + -2, /* (238) slimit_opt ::= SLIMIT signed */ + -4, /* (239) slimit_opt ::= SLIMIT signed SOFFSET signed */ + -4, /* (240) slimit_opt ::= SLIMIT signed COMMA signed */ + 0, /* (241) where_opt ::= */ + -2, /* (242) where_opt ::= WHERE expr */ + -3, /* (243) expr ::= LP expr RP */ + -1, /* (244) expr ::= ID */ + -3, /* (245) expr ::= ID DOT ID */ + -3, /* (246) expr ::= ID DOT STAR */ + -1, /* (247) expr ::= INTEGER */ + -2, /* (248) expr ::= MINUS INTEGER */ + -2, /* (249) expr ::= PLUS INTEGER */ + -1, /* (250) expr ::= FLOAT */ + -2, /* (251) expr ::= MINUS FLOAT */ + -2, /* (252) expr ::= PLUS FLOAT */ + -1, /* (253) expr ::= STRING */ + -1, /* (254) expr ::= NOW */ + -1, /* (255) expr ::= VARIABLE */ + -2, /* (256) expr ::= PLUS VARIABLE */ + -2, /* (257) expr ::= MINUS VARIABLE */ + -1, /* (258) expr ::= BOOL */ + -1, /* (259) expr ::= NULL */ + -4, /* (260) expr ::= ID LP exprlist RP */ + -4, /* (261) expr ::= ID LP STAR RP */ + -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 */ @@ -2510,54 +2760,6 @@ static YYACTIONTYPE yy_reduce( (void)yyLookahead; (void)yyLookaheadToken; yymsp = yypParser->yytos; -#ifndef NDEBUG - if( yyTraceFILE && yyruleno<(int)(sizeof(yyRuleName)/sizeof(yyRuleName[0])) ){ - yysize = yyRuleInfoNRhs[yyruleno]; - if( yysize ){ - fprintf(yyTraceFILE, "%sReduce %d [%s]%s, pop back to state %d.\n", - yyTracePrompt, - yyruleno, yyRuleName[yyruleno], - yyrulenoyytos - yypParser->yystack)>yypParser->yyhwm ){ - yypParser->yyhwm++; - assert( yypParser->yyhwm == (int)(yypParser->yytos - yypParser->yystack)); - } -#endif -#if YYSTACKDEPTH>0 - if( yypParser->yytos>=yypParser->yystackEnd ){ - yyStackOverflow(yypParser); - /* The call to yyStackOverflow() above pops the stack until it is - ** empty, causing the main parser loop to exit. So the return value - ** is never used and does not matter. */ - return 0; - } -#else - if( yypParser->yytos>=&yypParser->yystack[yypParser->yystksz-1] ){ - if( yyGrowStack(yypParser) ){ - yyStackOverflow(yypParser); - /* The call to yyStackOverflow() above pops the stack until it is - ** empty, causing the main parser loop to exit. So the return value - ** is never used and does not matter. */ - return 0; - } - yymsp = yypParser->yytos; - } -#endif - } switch( yyruleno ){ /* Beginning here are the reduction cases. A typical example @@ -2743,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.yy10, &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.yy427);} +{ 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.yy427);} +{ 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.yy345);} +{ setCompactVnodeSql(pInfo, TSDB_SQL_COMPACT_VNODE, yymsp[-1].minor.yy189);} break; case 51: /* ids ::= ID */ case 52: /* ids ::= STRING */ yytestcase(yyruleno==52); @@ -2774,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.yy427);} +{ 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.yy10, &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.yy487, &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.yy487, &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);} @@ -2815,38 +3017,38 @@ static YYACTIONTYPE yy_reduce( break; case 84: /* acct_optr ::= pps tseries storage streams qtime dbs users conns state */ { - yylhsminor.yy427.maxUsers = (yymsp[-2].minor.yy0.n>0)?atoi(yymsp[-2].minor.yy0.z):-1; - yylhsminor.yy427.maxDbs = (yymsp[-3].minor.yy0.n>0)?atoi(yymsp[-3].minor.yy0.z):-1; - yylhsminor.yy427.maxTimeSeries = (yymsp[-7].minor.yy0.n>0)?atoi(yymsp[-7].minor.yy0.z):-1; - yylhsminor.yy427.maxStreams = (yymsp[-5].minor.yy0.n>0)?atoi(yymsp[-5].minor.yy0.z):-1; - yylhsminor.yy427.maxPointsPerSecond = (yymsp[-8].minor.yy0.n>0)?atoi(yymsp[-8].minor.yy0.z):-1; - yylhsminor.yy427.maxStorage = (yymsp[-6].minor.yy0.n>0)?strtoll(yymsp[-6].minor.yy0.z, NULL, 10):-1; - yylhsminor.yy427.maxQueryTime = (yymsp[-4].minor.yy0.n>0)?strtoll(yymsp[-4].minor.yy0.z, NULL, 10):-1; - yylhsminor.yy427.maxConnections = (yymsp[-1].minor.yy0.n>0)?atoi(yymsp[-1].minor.yy0.z):-1; - yylhsminor.yy427.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.yy427 = yylhsminor.yy427; + yymsp[-8].minor.yy51 = yylhsminor.yy51; break; case 85: /* intitemlist ::= intitemlist COMMA intitem */ case 154: /* tagitemlist ::= tagitemlist COMMA tagitem */ yytestcase(yyruleno==154); -{ yylhsminor.yy345 = tVariantListAppend(yymsp[-2].minor.yy345, &yymsp[0].minor.yy2, -1); } - yymsp[-2].minor.yy345 = yylhsminor.yy345; +{ 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.yy345 = tVariantListAppend(NULL, &yymsp[0].minor.yy2, -1); } - yymsp[0].minor.yy345 = yylhsminor.yy345; +{ 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.yy2, &yymsp[0].minor.yy0, true); } - yymsp[0].minor.yy2 = yylhsminor.yy2; +{ 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.yy345 = yymsp[0].minor.yy345; } +{ yymsp[-1].minor.yy189 = yymsp[0].minor.yy189; } break; case 89: /* cache ::= CACHE INTEGER */ case 90: /* replica ::= REPLICA INTEGER */ yytestcase(yyruleno==90); @@ -2866,221 +3068,221 @@ static YYACTIONTYPE yy_reduce( { yymsp[-1].minor.yy0 = yymsp[0].minor.yy0; } break; case 104: /* db_optr ::= */ -{setDefaultCreateDbOption(&yymsp[1].minor.yy10); yymsp[1].minor.yy10.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.yy10 = yymsp[-1].minor.yy10; yylhsminor.yy10.cacheBlockSize = strtol(yymsp[0].minor.yy0.z, NULL, 10); } - yymsp[-1].minor.yy10 = yylhsminor.yy10; +{ 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.yy10 = yymsp[-1].minor.yy10; yylhsminor.yy10.replica = strtol(yymsp[0].minor.yy0.z, NULL, 10); } - yymsp[-1].minor.yy10 = yylhsminor.yy10; +{ 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.yy10 = yymsp[-1].minor.yy10; yylhsminor.yy10.quorum = strtol(yymsp[0].minor.yy0.z, NULL, 10); } - yymsp[-1].minor.yy10 = yylhsminor.yy10; +{ 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.yy10 = yymsp[-1].minor.yy10; yylhsminor.yy10.daysPerFile = strtol(yymsp[0].minor.yy0.z, NULL, 10); } - yymsp[-1].minor.yy10 = yylhsminor.yy10; +{ 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.yy10 = yymsp[-1].minor.yy10; yylhsminor.yy10.minRowsPerBlock = strtod(yymsp[0].minor.yy0.z, NULL); } - yymsp[-1].minor.yy10 = yylhsminor.yy10; +{ 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.yy10 = yymsp[-1].minor.yy10; yylhsminor.yy10.maxRowsPerBlock = strtod(yymsp[0].minor.yy0.z, NULL); } - yymsp[-1].minor.yy10 = yylhsminor.yy10; +{ 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.yy10 = yymsp[-1].minor.yy10; yylhsminor.yy10.numOfBlocks = strtol(yymsp[0].minor.yy0.z, NULL, 10); } - yymsp[-1].minor.yy10 = yylhsminor.yy10; +{ 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.yy10 = yymsp[-1].minor.yy10; yylhsminor.yy10.commitTime = strtol(yymsp[0].minor.yy0.z, NULL, 10); } - yymsp[-1].minor.yy10 = yylhsminor.yy10; +{ 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.yy10 = yymsp[-1].minor.yy10; yylhsminor.yy10.walLevel = strtol(yymsp[0].minor.yy0.z, NULL, 10); } - yymsp[-1].minor.yy10 = yylhsminor.yy10; +{ 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.yy10 = yymsp[-1].minor.yy10; yylhsminor.yy10.fsyncPeriod = strtol(yymsp[0].minor.yy0.z, NULL, 10); } - yymsp[-1].minor.yy10 = yylhsminor.yy10; +{ 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.yy10 = yymsp[-1].minor.yy10; yylhsminor.yy10.compressionLevel = strtol(yymsp[0].minor.yy0.z, NULL, 10); } - yymsp[-1].minor.yy10 = yylhsminor.yy10; +{ 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.yy10 = yymsp[-1].minor.yy10; yylhsminor.yy10.precision = yymsp[0].minor.yy0; } - yymsp[-1].minor.yy10 = yylhsminor.yy10; +{ 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.yy10 = yymsp[-1].minor.yy10; yylhsminor.yy10.keep = yymsp[0].minor.yy345; } - yymsp[-1].minor.yy10 = yylhsminor.yy10; +{ 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.yy10 = yymsp[-1].minor.yy10; yylhsminor.yy10.update = strtol(yymsp[0].minor.yy0.z, NULL, 10); } - yymsp[-1].minor.yy10 = yylhsminor.yy10; +{ 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.yy10 = yymsp[-1].minor.yy10; yylhsminor.yy10.cachelast = strtol(yymsp[0].minor.yy0.z, NULL, 10); } - yymsp[-1].minor.yy10 = yylhsminor.yy10; +{ 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.yy10 = yymsp[0].minor.yy10; yylhsminor.yy10.dbType = TSDB_DB_TYPE_TOPIC; } - yymsp[0].minor.yy10 = yylhsminor.yy10; +{ 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.yy10 = yymsp[-1].minor.yy10; yylhsminor.yy10.partitions = strtol(yymsp[0].minor.yy0.z, NULL, 10); } - yymsp[-1].minor.yy10 = yylhsminor.yy10; +{ 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.yy10); yymsp[1].minor.yy10.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.yy487, &yymsp[0].minor.yy0); + tSetColumnType (&yylhsminor.yy279, &yymsp[0].minor.yy0); } - yymsp[0].minor.yy487 = yylhsminor.yy487; + yymsp[0].minor.yy279 = yylhsminor.yy279; break; case 133: /* typename ::= ids LP signed RP */ { - if (yymsp[-1].minor.yy525 <= 0) { + if (yymsp[-1].minor.yy69 <= 0) { yymsp[-3].minor.yy0.type = 0; - tSetColumnType(&yylhsminor.yy487, &yymsp[-3].minor.yy0); + tSetColumnType(&yylhsminor.yy279, &yymsp[-3].minor.yy0); } else { - yymsp[-3].minor.yy0.type = -yymsp[-1].minor.yy525; // negative value of name length - tSetColumnType(&yylhsminor.yy487, &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.yy487 = yylhsminor.yy487; + 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.yy487, &yymsp[-1].minor.yy0); + tSetColumnType (&yylhsminor.yy279, &yymsp[-1].minor.yy0); } - yymsp[-1].minor.yy487 = yylhsminor.yy487; + yymsp[-1].minor.yy279 = yylhsminor.yy279; break; case 135: /* signed ::= INTEGER */ -{ yylhsminor.yy525 = strtol(yymsp[0].minor.yy0.z, NULL, 10); } - yymsp[0].minor.yy525 = yylhsminor.yy525; +{ 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.yy525 = 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.yy525 = -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.yy170;} +{ 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.yy72); + taosArrayPush(pCreateTable->childTableInfo, &yymsp[0].minor.yy208); pCreateTable->type = TSQL_CREATE_TABLE_FROM_STABLE; - yylhsminor.yy170 = pCreateTable; + yylhsminor.yy6 = pCreateTable; } - yymsp[0].minor.yy170 = yylhsminor.yy170; + yymsp[0].minor.yy6 = yylhsminor.yy6; break; case 143: /* create_table_list ::= create_table_list create_from_stable */ { - taosArrayPush(yymsp[-1].minor.yy170->childTableInfo, &yymsp[0].minor.yy72); - yylhsminor.yy170 = yymsp[-1].minor.yy170; + taosArrayPush(yymsp[-1].minor.yy6->childTableInfo, &yymsp[0].minor.yy208); + yylhsminor.yy6 = yymsp[-1].minor.yy6; } - yymsp[-1].minor.yy170 = yylhsminor.yy170; + yymsp[-1].minor.yy6 = yylhsminor.yy6; break; case 144: /* create_table_args ::= ifnotexists ids cpxName LP columnlist RP */ { - yylhsminor.yy170 = tSetCreateTableInfo(yymsp[-1].minor.yy345, NULL, NULL, TSQL_CREATE_TABLE); - setSqlInfo(pInfo, yylhsminor.yy170, 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.yy170 = yylhsminor.yy170; + yymsp[-5].minor.yy6 = yylhsminor.yy6; break; case 145: /* create_stable_args ::= ifnotexists ids cpxName LP columnlist RP TAGS LP columnlist RP */ { - yylhsminor.yy170 = tSetCreateTableInfo(yymsp[-5].minor.yy345, yymsp[-1].minor.yy345, NULL, TSQL_CREATE_STABLE); - setSqlInfo(pInfo, yylhsminor.yy170, 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.yy170 = yylhsminor.yy170; + 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.yy72 = createNewChildTableInfo(&yymsp[-5].minor.yy0, NULL, yymsp[-1].minor.yy345, &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.yy72 = yylhsminor.yy72; + 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.yy72 = createNewChildTableInfo(&yymsp[-8].minor.yy0, yymsp[-5].minor.yy345, yymsp[-1].minor.yy345, &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.yy72 = yylhsminor.yy72; + yymsp[-12].minor.yy208 = yylhsminor.yy208; break; case 148: /* tagNamelist ::= tagNamelist COMMA ids */ -{taosArrayPush(yymsp[-2].minor.yy345, &yymsp[0].minor.yy0); yylhsminor.yy345 = yymsp[-2].minor.yy345; } - yymsp[-2].minor.yy345 = yylhsminor.yy345; +{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.yy345 = taosArrayInit(4, sizeof(SStrToken)); taosArrayPush(yylhsminor.yy345, &yymsp[0].minor.yy0);} - yymsp[0].minor.yy345 = yylhsminor.yy345; +{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.yy170 = tSetCreateTableInfo(NULL, NULL, yymsp[0].minor.yy68, TSQL_CREATE_STREAM); - setSqlInfo(pInfo, yylhsminor.yy170, 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.yy170 = yylhsminor.yy170; + yymsp[-4].minor.yy6 = yylhsminor.yy6; break; case 151: /* columnlist ::= columnlist COMMA column */ -{taosArrayPush(yymsp[-2].minor.yy345, &yymsp[0].minor.yy487); yylhsminor.yy345 = yymsp[-2].minor.yy345; } - yymsp[-2].minor.yy345 = yylhsminor.yy345; +{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.yy345 = taosArrayInit(4, sizeof(TAOS_FIELD)); taosArrayPush(yylhsminor.yy345, &yymsp[0].minor.yy487);} - yymsp[0].minor.yy345 = yylhsminor.yy345; +{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.yy487, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy487); + tSetColumnInfo(&yylhsminor.yy279, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy279); } - yymsp[-1].minor.yy487 = yylhsminor.yy487; + yymsp[-1].minor.yy279 = yylhsminor.yy279; break; case 160: /* tagitem ::= NULL */ -{ yymsp[0].minor.yy0.type = 0; tVariantCreate(&yylhsminor.yy2, &yymsp[0].minor.yy0, true); } - yymsp[0].minor.yy2 = yylhsminor.yy2; +{ 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.yy2, &yymsp[0].minor.yy0, true);} - yymsp[0].minor.yy2 = yylhsminor.yy2; +{ 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); @@ -3090,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.yy2, &yymsp[-1].minor.yy0, true); + tVariantCreate(&yylhsminor.yy162, &yymsp[-1].minor.yy0, true); } - yymsp[-1].minor.yy2 = yylhsminor.yy2; + 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.yy68 = tSetQuerySqlNode(&yymsp[-14].minor.yy0, yymsp[-13].minor.yy345, yymsp[-12].minor.yy484, yymsp[-11].minor.yy418, yymsp[-4].minor.yy345, yymsp[-2].minor.yy345, &yymsp[-9].minor.yy280, &yymsp[-7].minor.yy295, &yymsp[-6].minor.yy432, &yymsp[-8].minor.yy0, yymsp[-5].minor.yy345, &yymsp[0].minor.yy114, &yymsp[-1].minor.yy114, yymsp[-3].minor.yy418, &yymsp[-10].minor.yy144); + 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.yy68 = yylhsminor.yy68; + yymsp[-14].minor.yy16 = yylhsminor.yy16; break; case 167: /* select ::= LP select RP */ -{yymsp[-2].minor.yy68 = yymsp[-1].minor.yy68;} +{yymsp[-2].minor.yy16 = yymsp[-1].minor.yy16;} break; case 168: /* union ::= select */ -{ yylhsminor.yy345 = setSubclause(NULL, yymsp[0].minor.yy68); } - yymsp[0].minor.yy345 = yylhsminor.yy345; +{ yylhsminor.yy189 = setSubclause(NULL, yymsp[0].minor.yy16); } + yymsp[0].minor.yy189 = yylhsminor.yy189; break; case 169: /* union ::= union UNION ALL select */ -{ yylhsminor.yy345 = appendSelectClause(yymsp[-3].minor.yy345, yymsp[0].minor.yy68); } - yymsp[-3].minor.yy345 = yylhsminor.yy345; +{ 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.yy345, NULL, TSDB_SQL_SELECT); } +{ setSqlInfo(pInfo, yymsp[0].minor.yy189, NULL, TSDB_SQL_SELECT); } break; case 171: /* select ::= SELECT selcollist */ { - yylhsminor.yy68 = tSetQuerySqlNode(&yymsp[-1].minor.yy0, yymsp[0].minor.yy345, 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.yy68 = yylhsminor.yy68; + yymsp[-1].minor.yy16 = yylhsminor.yy16; break; case 172: /* sclp ::= selcollist COMMA */ -{yylhsminor.yy345 = yymsp[-1].minor.yy345;} - yymsp[-1].minor.yy345 = yylhsminor.yy345; +{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.yy345 = 0;} +{yymsp[1].minor.yy189 = 0;} break; case 174: /* selcollist ::= sclp distinct expr as */ { - yylhsminor.yy345 = tSqlExprListAppend(yymsp[-3].minor.yy345, yymsp[-1].minor.yy418, 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.yy345 = yylhsminor.yy345; + yymsp[-3].minor.yy189 = yylhsminor.yy189; break; case 175: /* selcollist ::= sclp STAR */ { tSqlExpr *pNode = tSqlExprCreateIdValue(pInfo, NULL, TK_ALL); - yylhsminor.yy345 = tSqlExprListAppend(yymsp[-1].minor.yy345, pNode, 0, 0); + yylhsminor.yy189 = tSqlExprListAppend(yymsp[-1].minor.yy189, pNode, 0, 0); } - yymsp[-1].minor.yy345 = yylhsminor.yy345; + yymsp[-1].minor.yy189 = yylhsminor.yy189; break; case 176: /* as ::= AS ids */ { yymsp[-1].minor.yy0 = yymsp[0].minor.yy0; } @@ -3157,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.yy345, 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.yy345, &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.yy345, &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.yy418 = tSqlExprCreateTimestamp(&yymsp[0].minor.yy0, TK_INTEGER);} - yymsp[0].minor.yy418 = yylhsminor.yy418; +{ 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.yy418 = tSqlExprCreateTimestamp(&yymsp[-1].minor.yy0, TK_INTEGER);} - yymsp[-1].minor.yy418 = yylhsminor.yy418; +{ 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.yy418 = tSqlExprCreateTimestamp(&yymsp[0].minor.yy0, TK_STRING);} - yymsp[0].minor.yy418 = yylhsminor.yy418; +{ yylhsminor.yy18 = tSqlExprCreateTimestamp(&yymsp[0].minor.yy0, TK_STRING);} + yymsp[0].minor.yy18 = yylhsminor.yy18; break; case 195: /* timestamp ::= NOW */ -{ yylhsminor.yy418 = tSqlExprCreateTimestamp(&yymsp[0].minor.yy0, TK_NOW); } - yymsp[0].minor.yy418 = yylhsminor.yy418; +{ 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.yy418 = 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.yy418 = 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.yy144.start = 0; yymsp[1].minor.yy144.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.yy144.start = yymsp[-3].minor.yy418; yymsp[-5].minor.yy144.end = yymsp[-1].minor.yy418;} +{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.yy280.interval = yymsp[-1].minor.yy0; yylhsminor.yy280.offset.n = 0; yylhsminor.yy280.token = yymsp[-3].minor.yy40;} - yymsp[-3].minor.yy280 = yylhsminor.yy280; +{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.yy280.interval = yymsp[-3].minor.yy0; yylhsminor.yy280.offset = yymsp[-1].minor.yy0; yylhsminor.yy280.token = yymsp[-5].minor.yy40;} - yymsp[-5].minor.yy280 = yylhsminor.yy280; +{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.yy280, 0, sizeof(yymsp[1].minor.yy280));} +{memset(&yymsp[1].minor.yy32, 0, sizeof(yymsp[1].minor.yy32));} break; case 203: /* intervalKey ::= INTERVAL */ -{yymsp[0].minor.yy40 = TK_INTERVAL;} +{yymsp[0].minor.yy516 = TK_INTERVAL;} break; case 204: /* intervalKey ::= EVERY */ -{yymsp[0].minor.yy40 = TK_EVERY; } +{yymsp[0].minor.yy516 = TK_EVERY; } break; case 205: /* session_option ::= */ -{yymsp[1].minor.yy295.col.n = 0; yymsp[1].minor.yy295.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.yy295.col = yymsp[-4].minor.yy0; - yymsp[-6].minor.yy295.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.yy432.col.n = 0; yymsp[1].minor.yy432.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.yy432.col = yymsp[-1].minor.yy0; } +{ yymsp[-3].minor.yy336.col = yymsp[-1].minor.yy0; } break; case 209: /* fill_opt ::= */ -{ yymsp[1].minor.yy345 = 0; } +{ yymsp[1].minor.yy189 = 0; } break; case 210: /* fill_opt ::= FILL LP ID COMMA tagitemlist RP */ { @@ -3272,14 +3474,14 @@ static YYACTIONTYPE yy_reduce( toTSDBType(yymsp[-3].minor.yy0.type); tVariantCreate(&A, &yymsp[-3].minor.yy0, true); - tVariantListInsert(yymsp[-1].minor.yy345, &A, -1, 0); - yymsp[-5].minor.yy345 = yymsp[-1].minor.yy345; + 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.yy345 = 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 */ @@ -3289,258 +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.yy345 = yymsp[0].minor.yy345;} +{yymsp[-2].minor.yy189 = yymsp[0].minor.yy189;} break; case 216: /* sortlist ::= sortlist COMMA item sortorder */ { - yylhsminor.yy345 = tVariantListAppend(yymsp[-3].minor.yy345, &yymsp[-1].minor.yy2, yymsp[0].minor.yy281); + yylhsminor.yy189 = commonItemAppend(yymsp[-3].minor.yy189, &yymsp[-1].minor.yy162, NULL, false, yymsp[0].minor.yy420); } - yymsp[-3].minor.yy345 = yylhsminor.yy345; + yymsp[-3].minor.yy189 = yylhsminor.yy189; break; - case 217: /* sortlist ::= item sortorder */ + case 217: /* sortlist ::= sortlist COMMA arrow sortorder */ { - yylhsminor.yy345 = tVariantListAppend(NULL, &yymsp[-1].minor.yy2, yymsp[0].minor.yy281); + yylhsminor.yy189 = commonItemAppend(yymsp[-3].minor.yy189, NULL, yymsp[-1].minor.yy18, true, yymsp[0].minor.yy420); } - yymsp[-1].minor.yy345 = yylhsminor.yy345; + yymsp[-3].minor.yy189 = yylhsminor.yy189; break; - case 218: /* item ::= ids cpxName */ + case 218: /* sortlist ::= item sortorder */ { - toTSDBType(yymsp[-1].minor.yy0.type); - yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n; - - tVariantCreate(&yylhsminor.yy2, &yymsp[-1].minor.yy0, true); + yylhsminor.yy189 = commonItemAppend(NULL, &yymsp[-1].minor.yy162, NULL, false, yymsp[0].minor.yy420); +} + yymsp[-1].minor.yy189 = yylhsminor.yy189; + break; + case 219: /* sortlist ::= arrow sortorder */ +{ + yylhsminor.yy189 = commonItemAppend(NULL, NULL, yymsp[-1].minor.yy18, true, yymsp[0].minor.yy420); +} + yymsp[-1].minor.yy189 = yylhsminor.yy189; + break; + case 220: /* item ::= ID */ +{ + toTSDBType(yymsp[0].minor.yy0.type); + tVariantCreate(&yylhsminor.yy162, &yymsp[0].minor.yy0, true); } - yymsp[-1].minor.yy2 = yylhsminor.yy2; + yymsp[0].minor.yy162 = yylhsminor.yy162; break; - case 219: /* sortorder ::= ASC */ -{ yymsp[0].minor.yy281 = TSDB_ORDER_ASC; } + 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.yy162, &yymsp[-2].minor.yy0, true); +} + yymsp[-2].minor.yy162 = yylhsminor.yy162; + break; + case 222: /* sortorder ::= ASC */ +{ yymsp[0].minor.yy420 = TSDB_ORDER_ASC; } + break; + case 223: /* sortorder ::= DESC */ +{ yymsp[0].minor.yy420 = TSDB_ORDER_DESC;} break; - case 220: /* sortorder ::= DESC */ -{ yymsp[0].minor.yy281 = TSDB_ORDER_DESC;} + case 224: /* sortorder ::= */ +{ yymsp[1].minor.yy420 = TSDB_ORDER_ASC; } break; - case 221: /* sortorder ::= */ -{ yymsp[1].minor.yy281 = TSDB_ORDER_ASC; } + case 225: /* groupby_opt ::= */ +{ yymsp[1].minor.yy189 = 0;} break; - case 222: /* groupby_opt ::= */ -{ yymsp[1].minor.yy345 = 0;} + case 226: /* groupby_opt ::= GROUP BY grouplist */ +{ yymsp[-2].minor.yy189 = yymsp[0].minor.yy189;} break; - case 223: /* groupby_opt ::= GROUP BY grouplist */ -{ yymsp[-2].minor.yy345 = yymsp[0].minor.yy345;} + case 227: /* grouplist ::= grouplist COMMA item */ +{ + yylhsminor.yy189 = commonItemAppend(yymsp[-2].minor.yy189, &yymsp[0].minor.yy162, NULL, false, -1); +} + yymsp[-2].minor.yy189 = yylhsminor.yy189; + break; + case 228: /* grouplist ::= grouplist COMMA arrow */ +{ + yylhsminor.yy189 = commonItemAppend(yymsp[-2].minor.yy189, NULL, yymsp[0].minor.yy18, true, -1); +} + yymsp[-2].minor.yy189 = yylhsminor.yy189; break; - case 224: /* grouplist ::= grouplist COMMA item */ + case 229: /* grouplist ::= item */ { - yylhsminor.yy345 = tVariantListAppend(yymsp[-2].minor.yy345, &yymsp[0].minor.yy2, -1); + yylhsminor.yy189 = commonItemAppend(NULL, &yymsp[0].minor.yy162, NULL, false, -1); } - yymsp[-2].minor.yy345 = yylhsminor.yy345; + yymsp[0].minor.yy189 = yylhsminor.yy189; break; - case 225: /* grouplist ::= item */ + case 230: /* grouplist ::= arrow */ { - yylhsminor.yy345 = tVariantListAppend(NULL, &yymsp[0].minor.yy2, -1); + yylhsminor.yy189 = commonItemAppend(NULL, NULL, yymsp[0].minor.yy18, true, -1); } - yymsp[0].minor.yy345 = yylhsminor.yy345; + yymsp[0].minor.yy189 = yylhsminor.yy189; + break; + case 231: /* having_opt ::= */ + case 241: /* where_opt ::= */ yytestcase(yyruleno==241); + 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.yy18 = yymsp[0].minor.yy18;} + break; + case 233: /* limit_opt ::= */ + case 237: /* slimit_opt ::= */ yytestcase(yyruleno==237); +{yymsp[1].minor.yy38.limit = -1; yymsp[1].minor.yy38.offset = 0;} break; - case 226: /* having_opt ::= */ - case 236: /* where_opt ::= */ yytestcase(yyruleno==236); - case 280: /* expritem ::= */ yytestcase(yyruleno==280); -{yymsp[1].minor.yy418 = 0;} + case 234: /* limit_opt ::= LIMIT signed */ + case 238: /* slimit_opt ::= SLIMIT signed */ yytestcase(yyruleno==238); +{yymsp[-1].minor.yy38.limit = yymsp[0].minor.yy69; yymsp[-1].minor.yy38.offset = 0;} break; - case 227: /* having_opt ::= HAVING expr */ - case 237: /* where_opt ::= WHERE expr */ yytestcase(yyruleno==237); -{yymsp[-1].minor.yy418 = yymsp[0].minor.yy418;} + case 235: /* limit_opt ::= LIMIT signed OFFSET signed */ +{ yymsp[-3].minor.yy38.limit = yymsp[-2].minor.yy69; yymsp[-3].minor.yy38.offset = yymsp[0].minor.yy69;} break; - case 228: /* limit_opt ::= */ - case 232: /* slimit_opt ::= */ yytestcase(yyruleno==232); -{yymsp[1].minor.yy114.limit = -1; yymsp[1].minor.yy114.offset = 0;} + case 236: /* limit_opt ::= LIMIT signed COMMA signed */ +{ yymsp[-3].minor.yy38.limit = yymsp[0].minor.yy69; yymsp[-3].minor.yy38.offset = yymsp[-2].minor.yy69;} break; - case 229: /* limit_opt ::= LIMIT signed */ - case 233: /* slimit_opt ::= SLIMIT signed */ yytestcase(yyruleno==233); -{yymsp[-1].minor.yy114.limit = yymsp[0].minor.yy525; yymsp[-1].minor.yy114.offset = 0;} + case 239: /* slimit_opt ::= SLIMIT signed SOFFSET signed */ +{yymsp[-3].minor.yy38.limit = yymsp[-2].minor.yy69; yymsp[-3].minor.yy38.offset = yymsp[0].minor.yy69;} break; - case 230: /* limit_opt ::= LIMIT signed OFFSET signed */ -{ yymsp[-3].minor.yy114.limit = yymsp[-2].minor.yy525; yymsp[-3].minor.yy114.offset = yymsp[0].minor.yy525;} + case 240: /* slimit_opt ::= SLIMIT signed COMMA signed */ +{yymsp[-3].minor.yy38.limit = yymsp[0].minor.yy69; yymsp[-3].minor.yy38.offset = yymsp[-2].minor.yy69;} break; - case 231: /* limit_opt ::= LIMIT signed COMMA signed */ -{ yymsp[-3].minor.yy114.limit = yymsp[0].minor.yy525; yymsp[-3].minor.yy114.offset = yymsp[-2].minor.yy525;} + case 243: /* expr ::= LP expr RP */ +{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 234: /* slimit_opt ::= SLIMIT signed SOFFSET signed */ -{yymsp[-3].minor.yy114.limit = yymsp[-2].minor.yy525; yymsp[-3].minor.yy114.offset = yymsp[0].minor.yy525;} + case 244: /* expr ::= ID */ +{ yylhsminor.yy18 = tSqlExprCreateIdValue(pInfo, &yymsp[0].minor.yy0, TK_ID);} + yymsp[0].minor.yy18 = yylhsminor.yy18; break; - case 235: /* slimit_opt ::= SLIMIT signed COMMA signed */ -{yymsp[-3].minor.yy114.limit = yymsp[0].minor.yy525; yymsp[-3].minor.yy114.offset = yymsp[-2].minor.yy525;} + case 245: /* expr ::= ID DOT ID */ +{ 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 238: /* expr ::= LP expr RP */ -{yylhsminor.yy418 = yymsp[-1].minor.yy418; yylhsminor.yy418->exprToken.z = yymsp[-2].minor.yy0.z; yylhsminor.yy418->exprToken.n = (yymsp[0].minor.yy0.z - yymsp[-2].minor.yy0.z + 1);} - yymsp[-2].minor.yy418 = yylhsminor.yy418; + case 246: /* expr ::= ID DOT STAR */ +{ 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 239: /* expr ::= ID */ -{ yylhsminor.yy418 = tSqlExprCreateIdValue(pInfo, &yymsp[0].minor.yy0, TK_ID);} - yymsp[0].minor.yy418 = yylhsminor.yy418; + case 247: /* expr ::= INTEGER */ +{ yylhsminor.yy18 = tSqlExprCreateIdValue(pInfo, &yymsp[0].minor.yy0, TK_INTEGER);} + yymsp[0].minor.yy18 = yylhsminor.yy18; break; - case 240: /* expr ::= ID DOT ID */ -{ yymsp[-2].minor.yy0.n += (1+yymsp[0].minor.yy0.n); yylhsminor.yy418 = tSqlExprCreateIdValue(pInfo, &yymsp[-2].minor.yy0, TK_ID);} - yymsp[-2].minor.yy418 = yylhsminor.yy418; + 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.yy18 = tSqlExprCreateIdValue(pInfo, &yymsp[-1].minor.yy0, TK_INTEGER);} + yymsp[-1].minor.yy18 = yylhsminor.yy18; break; - case 241: /* expr ::= ID DOT STAR */ -{ yymsp[-2].minor.yy0.n += (1+yymsp[0].minor.yy0.n); yylhsminor.yy418 = tSqlExprCreateIdValue(pInfo, &yymsp[-2].minor.yy0, TK_ALL);} - yymsp[-2].minor.yy418 = yylhsminor.yy418; + case 250: /* expr ::= FLOAT */ +{ yylhsminor.yy18 = tSqlExprCreateIdValue(pInfo, &yymsp[0].minor.yy0, TK_FLOAT);} + yymsp[0].minor.yy18 = yylhsminor.yy18; break; - case 242: /* expr ::= INTEGER */ -{ yylhsminor.yy418 = tSqlExprCreateIdValue(pInfo, &yymsp[0].minor.yy0, TK_INTEGER);} - yymsp[0].minor.yy418 = yylhsminor.yy418; + 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.yy18 = tSqlExprCreateIdValue(pInfo, &yymsp[-1].minor.yy0, TK_FLOAT);} + yymsp[-1].minor.yy18 = yylhsminor.yy18; break; - case 243: /* expr ::= MINUS INTEGER */ - case 244: /* expr ::= PLUS INTEGER */ yytestcase(yyruleno==244); -{ yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n; yymsp[-1].minor.yy0.type = TK_INTEGER; yylhsminor.yy418 = tSqlExprCreateIdValue(pInfo, &yymsp[-1].minor.yy0, TK_INTEGER);} - yymsp[-1].minor.yy418 = yylhsminor.yy418; + case 253: /* expr ::= STRING */ +{ yylhsminor.yy18 = tSqlExprCreateIdValue(pInfo, &yymsp[0].minor.yy0, TK_STRING);} + yymsp[0].minor.yy18 = yylhsminor.yy18; break; - case 245: /* expr ::= FLOAT */ -{ yylhsminor.yy418 = tSqlExprCreateIdValue(pInfo, &yymsp[0].minor.yy0, TK_FLOAT);} - yymsp[0].minor.yy418 = yylhsminor.yy418; + case 254: /* expr ::= NOW */ +{ yylhsminor.yy18 = tSqlExprCreateIdValue(pInfo, &yymsp[0].minor.yy0, TK_NOW); } + yymsp[0].minor.yy18 = yylhsminor.yy18; break; - case 246: /* expr ::= MINUS FLOAT */ - case 247: /* expr ::= PLUS FLOAT */ yytestcase(yyruleno==247); -{ yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n; yymsp[-1].minor.yy0.type = TK_FLOAT; yylhsminor.yy418 = tSqlExprCreateIdValue(pInfo, &yymsp[-1].minor.yy0, TK_FLOAT);} - yymsp[-1].minor.yy418 = yylhsminor.yy418; + case 255: /* expr ::= VARIABLE */ +{ yylhsminor.yy18 = tSqlExprCreateIdValue(pInfo, &yymsp[0].minor.yy0, TK_VARIABLE);} + yymsp[0].minor.yy18 = yylhsminor.yy18; break; - case 248: /* expr ::= STRING */ -{ yylhsminor.yy418 = tSqlExprCreateIdValue(pInfo, &yymsp[0].minor.yy0, TK_STRING);} - yymsp[0].minor.yy418 = yylhsminor.yy418; + 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.yy18 = tSqlExprCreateIdValue(pInfo, &yymsp[-1].minor.yy0, TK_VARIABLE);} + yymsp[-1].minor.yy18 = yylhsminor.yy18; break; - case 249: /* expr ::= NOW */ -{ yylhsminor.yy418 = tSqlExprCreateIdValue(pInfo, &yymsp[0].minor.yy0, TK_NOW); } - yymsp[0].minor.yy418 = yylhsminor.yy418; + case 258: /* expr ::= BOOL */ +{ yylhsminor.yy18 = tSqlExprCreateIdValue(pInfo, &yymsp[0].minor.yy0, TK_BOOL);} + yymsp[0].minor.yy18 = yylhsminor.yy18; break; - case 250: /* expr ::= VARIABLE */ -{ yylhsminor.yy418 = tSqlExprCreateIdValue(pInfo, &yymsp[0].minor.yy0, TK_VARIABLE);} - yymsp[0].minor.yy418 = yylhsminor.yy418; + case 259: /* expr ::= NULL */ +{ yylhsminor.yy18 = tSqlExprCreateIdValue(pInfo, &yymsp[0].minor.yy0, TK_NULL);} + yymsp[0].minor.yy18 = yylhsminor.yy18; break; - case 251: /* expr ::= PLUS VARIABLE */ - case 252: /* expr ::= MINUS VARIABLE */ yytestcase(yyruleno==252); -{ yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n; yymsp[-1].minor.yy0.type = TK_VARIABLE; yylhsminor.yy418 = tSqlExprCreateIdValue(pInfo, &yymsp[-1].minor.yy0, TK_VARIABLE);} - yymsp[-1].minor.yy418 = yylhsminor.yy418; + case 260: /* expr ::= ID LP exprlist RP */ +{ 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 253: /* expr ::= BOOL */ -{ yylhsminor.yy418 = tSqlExprCreateIdValue(pInfo, &yymsp[0].minor.yy0, TK_BOOL);} - yymsp[0].minor.yy418 = yylhsminor.yy418; + case 261: /* expr ::= ID LP STAR RP */ +{ 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 254: /* expr ::= NULL */ -{ yylhsminor.yy418 = tSqlExprCreateIdValue(pInfo, &yymsp[0].minor.yy0, TK_NULL);} - yymsp[0].minor.yy418 = yylhsminor.yy418; + 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 255: /* expr ::= ID LP exprlist RP */ -{ tStrTokenAppend(pInfo->funcs, &yymsp[-3].minor.yy0); yylhsminor.yy418 = tSqlExprCreateFunction(yymsp[-1].minor.yy345, &yymsp[-3].minor.yy0, &yymsp[0].minor.yy0, yymsp[-3].minor.yy0.type); } - yymsp[-3].minor.yy418 = yylhsminor.yy418; + case 263: /* expr ::= expr IS NULL */ +{yylhsminor.yy18 = tSqlExprCreate(yymsp[-2].minor.yy18, NULL, TK_ISNULL);} + yymsp[-2].minor.yy18 = yylhsminor.yy18; break; - case 256: /* expr ::= ID LP STAR RP */ -{ tStrTokenAppend(pInfo->funcs, &yymsp[-3].minor.yy0); yylhsminor.yy418 = tSqlExprCreateFunction(NULL, &yymsp[-3].minor.yy0, &yymsp[0].minor.yy0, yymsp[-3].minor.yy0.type); } - yymsp[-3].minor.yy418 = yylhsminor.yy418; + 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 257: /* expr ::= expr IS NULL */ -{yylhsminor.yy418 = tSqlExprCreate(yymsp[-2].minor.yy418, NULL, TK_ISNULL);} - yymsp[-2].minor.yy418 = yylhsminor.yy418; + 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 258: /* expr ::= expr IS NOT NULL */ -{yylhsminor.yy418 = tSqlExprCreate(yymsp[-3].minor.yy418, NULL, TK_NOTNULL);} - yymsp[-3].minor.yy418 = yylhsminor.yy418; + 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 259: /* expr ::= expr LT expr */ -{yylhsminor.yy418 = tSqlExprCreate(yymsp[-2].minor.yy418, yymsp[0].minor.yy418, TK_LT);} - yymsp[-2].minor.yy418 = yylhsminor.yy418; + 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 260: /* expr ::= expr GT expr */ -{yylhsminor.yy418 = tSqlExprCreate(yymsp[-2].minor.yy418, yymsp[0].minor.yy418, TK_GT);} - yymsp[-2].minor.yy418 = yylhsminor.yy418; + 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 261: /* expr ::= expr LE expr */ -{yylhsminor.yy418 = tSqlExprCreate(yymsp[-2].minor.yy418, yymsp[0].minor.yy418, TK_LE);} - yymsp[-2].minor.yy418 = yylhsminor.yy418; + 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 262: /* expr ::= expr GE expr */ -{yylhsminor.yy418 = tSqlExprCreate(yymsp[-2].minor.yy418, yymsp[0].minor.yy418, TK_GE);} - yymsp[-2].minor.yy418 = yylhsminor.yy418; + 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 263: /* expr ::= expr NE expr */ -{yylhsminor.yy418 = tSqlExprCreate(yymsp[-2].minor.yy418, yymsp[0].minor.yy418, TK_NE);} - yymsp[-2].minor.yy418 = yylhsminor.yy418; + 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 264: /* expr ::= expr EQ expr */ -{yylhsminor.yy418 = tSqlExprCreate(yymsp[-2].minor.yy418, yymsp[0].minor.yy418, TK_EQ);} - yymsp[-2].minor.yy418 = yylhsminor.yy418; + 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 265: /* expr ::= expr BETWEEN expr AND expr */ -{ tSqlExpr* X2 = tSqlExprClone(yymsp[-4].minor.yy418); yylhsminor.yy418 = tSqlExprCreate(tSqlExprCreate(yymsp[-4].minor.yy418, yymsp[-2].minor.yy418, TK_GE), tSqlExprCreate(X2, yymsp[0].minor.yy418, TK_LE), TK_AND);} - yymsp[-4].minor.yy418 = yylhsminor.yy418; + 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 266: /* expr ::= expr AND expr */ -{yylhsminor.yy418 = tSqlExprCreate(yymsp[-2].minor.yy418, yymsp[0].minor.yy418, TK_AND);} - yymsp[-2].minor.yy418 = yylhsminor.yy418; + 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 267: /* expr ::= expr OR expr */ -{yylhsminor.yy418 = tSqlExprCreate(yymsp[-2].minor.yy418, yymsp[0].minor.yy418, TK_OR); } - yymsp[-2].minor.yy418 = yylhsminor.yy418; + 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 268: /* expr ::= expr PLUS expr */ -{yylhsminor.yy418 = tSqlExprCreate(yymsp[-2].minor.yy418, yymsp[0].minor.yy418, TK_PLUS); } - yymsp[-2].minor.yy418 = yylhsminor.yy418; + 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 269: /* expr ::= expr MINUS expr */ -{yylhsminor.yy418 = tSqlExprCreate(yymsp[-2].minor.yy418, yymsp[0].minor.yy418, TK_MINUS); } - yymsp[-2].minor.yy418 = yylhsminor.yy418; + 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 270: /* expr ::= expr STAR expr */ -{yylhsminor.yy418 = tSqlExprCreate(yymsp[-2].minor.yy418, yymsp[0].minor.yy418, TK_STAR); } - yymsp[-2].minor.yy418 = yylhsminor.yy418; + 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 271: /* expr ::= expr SLASH expr */ -{yylhsminor.yy418 = tSqlExprCreate(yymsp[-2].minor.yy418, yymsp[0].minor.yy418, TK_DIVIDE);} - yymsp[-2].minor.yy418 = yylhsminor.yy418; + 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 272: /* expr ::= expr REM expr */ -{yylhsminor.yy418 = tSqlExprCreate(yymsp[-2].minor.yy418, yymsp[0].minor.yy418, TK_REM); } - yymsp[-2].minor.yy418 = yylhsminor.yy418; + 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 273: /* expr ::= expr LIKE expr */ -{yylhsminor.yy418 = tSqlExprCreate(yymsp[-2].minor.yy418, yymsp[0].minor.yy418, TK_LIKE); } - yymsp[-2].minor.yy418 = yylhsminor.yy418; + 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 274: /* expr ::= expr MATCH expr */ -{yylhsminor.yy418 = tSqlExprCreate(yymsp[-2].minor.yy418, yymsp[0].minor.yy418, TK_MATCH); } - yymsp[-2].minor.yy418 = yylhsminor.yy418; + 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 275: /* expr ::= expr NMATCH expr */ -{yylhsminor.yy418 = tSqlExprCreate(yymsp[-2].minor.yy418, yymsp[0].minor.yy418, TK_NMATCH); } - yymsp[-2].minor.yy418 = yylhsminor.yy418; + 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 276: /* expr ::= expr IN LP exprlist RP */ -{yylhsminor.yy418 = tSqlExprCreate(yymsp[-4].minor.yy418, (tSqlExpr*)yymsp[-1].minor.yy345, TK_IN); } - yymsp[-4].minor.yy418 = yylhsminor.yy418; + 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 277: /* exprlist ::= exprlist COMMA expritem */ -{yylhsminor.yy345 = tSqlExprListAppend(yymsp[-2].minor.yy345,yymsp[0].minor.yy418,0, 0);} - yymsp[-2].minor.yy345 = yylhsminor.yy345; + 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 278: /* exprlist ::= expritem */ -{yylhsminor.yy345 = tSqlExprListAppend(0,yymsp[0].minor.yy418,0, 0);} - yymsp[0].minor.yy345 = yylhsminor.yy345; + 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 279: /* expritem ::= expr */ -{yylhsminor.yy418 = yymsp[0].minor.yy418;} - yymsp[0].minor.yy418 = yylhsminor.yy418; + 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 281: /* cmd ::= RESET QUERY CACHE */ + 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 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 282: /* cmd ::= SYNCDB ids REPLICA */ + case 293: /* cmd ::= SYNCDB ids REPLICA */ { setDCLSqlElems(pInfo, TSDB_SQL_SYNC_DB_REPLICA, 1, &yymsp[-1].minor.yy0);} break; - case 283: /* 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.yy345, 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 284: /* 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; @@ -3551,21 +3804,21 @@ static YYACTIONTYPE yy_reduce( setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } break; - case 285: /* 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.yy345, 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 286: /* 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.yy345, 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 287: /* 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; @@ -3576,7 +3829,7 @@ static YYACTIONTYPE yy_reduce( setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } break; - case 288: /* 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; @@ -3590,33 +3843,33 @@ static YYACTIONTYPE yy_reduce( setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } break; - case 289: /* 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.yy2, -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 290: /* 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.yy345, 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 291: /* 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.yy345, 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 292: /* 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; @@ -3627,21 +3880,21 @@ static YYACTIONTYPE yy_reduce( setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } break; - case 293: /* 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.yy345, 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 294: /* 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.yy345, 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 295: /* 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; @@ -3652,7 +3905,7 @@ static YYACTIONTYPE yy_reduce( setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } break; - case 296: /* 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; @@ -3666,32 +3919,32 @@ static YYACTIONTYPE yy_reduce( setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } break; - case 297: /* 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.yy2, -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 298: /* 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.yy345, 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 299: /* cmd ::= KILL CONNECTION INTEGER */ + case 310: /* cmd ::= KILL CONNECTION INTEGER */ {setKillSql(pInfo, TSDB_SQL_KILL_CONNECTION, &yymsp[0].minor.yy0);} break; - case 300: /* 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 301: /* 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: @@ -3862,12 +4115,56 @@ void Parse( } #endif - do{ + while(1){ /* Exit by "break" */ + assert( yypParser->yytos>=yypParser->yystack ); assert( yyact==yypParser->yytos->stateno ); yyact = yy_find_shift_action((YYCODETYPE)yymajor,yyact); if( yyact >= YY_MIN_REDUCE ){ - yyact = yy_reduce(yypParser,yyact-YY_MIN_REDUCE,yymajor, - yyminor ParseCTX_PARAM); + unsigned int yyruleno = yyact - YY_MIN_REDUCE; /* Reduce by this rule */ + assert( yyruleno<(int)(sizeof(yyRuleName)/sizeof(yyRuleName[0])) ); +#ifndef NDEBUG + if( yyTraceFILE ){ + int yysize = yyRuleInfoNRhs[yyruleno]; + if( yysize ){ + fprintf(yyTraceFILE, "%sReduce %d [%s]%s, pop back to state %d.\n", + yyTracePrompt, + yyruleno, yyRuleName[yyruleno], + yyrulenoyytos[yysize].stateno); + }else{ + fprintf(yyTraceFILE, "%sReduce %d [%s]%s.\n", + yyTracePrompt, yyruleno, yyRuleName[yyruleno], + yyrulenoyytos - yypParser->yystack)>yypParser->yyhwm ){ + yypParser->yyhwm++; + assert( yypParser->yyhwm == + (int)(yypParser->yytos - yypParser->yystack)); + } +#endif +#if YYSTACKDEPTH>0 + if( yypParser->yytos>=yypParser->yystackEnd ){ + yyStackOverflow(yypParser); + break; + } +#else + if( yypParser->yytos>=&yypParser->yystack[yypParser->yystksz-1] ){ + if( yyGrowStack(yypParser) ){ + yyStackOverflow(yypParser); + break; + } + } +#endif + } + yyact = yy_reduce(yypParser,yyruleno,yymajor,yyminor ParseCTX_PARAM); }else if( yyact <= YY_MAX_SHIFTREDUCE ){ yy_shift(yypParser,yyact,(YYCODETYPE)yymajor,yyminor); #ifndef YYNOERRORRECOVERY @@ -3980,7 +4277,7 @@ void Parse( break; #endif } - }while( yypParser->yytos>yypParser->yystack ); + } #ifndef NDEBUG if( yyTraceFILE ){ yyStackEntry *i; diff --git a/src/tsdb/CMakeLists.txt b/src/tsdb/CMakeLists.txt index 0f472cfbfc443e57e538068d28cb3c2c8d228dec..875bb6258125b88399558c75a6169dea67bfdde8 100644 --- a/src/tsdb/CMakeLists.txt +++ b/src/tsdb/CMakeLists.txt @@ -3,9 +3,10 @@ PROJECT(TDengine) INCLUDE_DIRECTORIES(inc) INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/src/query/inc) +INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/deps/cJson/inc) AUX_SOURCE_DIRECTORY(src SRC) ADD_LIBRARY(tsdb ${SRC}) -TARGET_LINK_LIBRARIES(tsdb tfs common tutil) +TARGET_LINK_LIBRARIES(tsdb tfs common tutil cJson) IF (TD_TSDB_PLUGINS) TARGET_LINK_LIBRARIES(tsdb tsdbPlugins) diff --git a/src/tsdb/inc/tsdbMeta.h b/src/tsdb/inc/tsdbMeta.h index 0b7af561cda8d9c37201f99c7ab467b4e1598d37..9cdb8a83aa266d04d91e07d515f0acb56703f880 100644 --- a/src/tsdb/inc/tsdbMeta.h +++ b/src/tsdb/inc/tsdbMeta.h @@ -18,6 +18,14 @@ #define TSDB_MAX_TABLE_SCHEMAS 16 +#pragma pack (push,1) +typedef struct jsonMapValue{ + void* table; // STable * + int16_t colId; // the json col ID. +}JsonMapValue; + +#pragma pack (pop) + typedef struct STable { STableId tableId; ETableType type; @@ -28,6 +36,7 @@ typedef struct STable { STSchema* tagSchema; SKVRow tagVal; SSkipList* pIndex; // For TSDB_SUPER_TABLE, it is the skiplist index + SHashObj* jsonKeyMap; // For json tag key {"key":[t1, t2, t3]} void* eventHandler; // TODO void* streamHandler; // TODO TSKEY lastKey; @@ -89,6 +98,8 @@ int16_t tsdbGetLastColumnsIndexByColId(STable* pTable, int16_t colId); int tsdbUpdateLastColSchema(STable *pTable, STSchema *pNewSchema); STSchema* tsdbGetTableLatestSchema(STable *pTable); void tsdbFreeLastColumns(STable* pTable); +int tsdbCompareJsonMapValue(const void* a, const void* b); +void* tsdbGetJsonTagValue(STable* pTable, char* key, int32_t keyLen, int16_t* colId); static FORCE_INLINE int tsdbCompareSchemaVersion(const void *key1, const void *key2) { if (*(int16_t *)key1 < schemaVersion(*(STSchema **)key2)) { diff --git a/src/tsdb/src/tsdbMeta.c b/src/tsdb/src/tsdbMeta.c index 1bb9733970cf6730366adda7f89ec5f09577df92..18225ab70cde20ab2d18c80b5327bd24be3827df 100644 --- a/src/tsdb/src/tsdbMeta.c +++ b/src/tsdb/src/tsdbMeta.c @@ -13,6 +13,8 @@ * along with this program. If not, see . */ #include "tsdbint.h" +#include "tcompare.h" +#include "tutil.h" #define TSDB_SUPER_TABLE_SL_LEVEL 5 #define DEFAULT_TAG_INDEX_COLUMN 0 @@ -118,11 +120,13 @@ int tsdbCreateTable(STsdbRepo *repo, STableCfg *pCfg) { tsdbWLockRepoMeta(pRepo); if (newSuper) { if (tsdbAddTableToMeta(pRepo, super, true, false) < 0) { + super = NULL; tsdbUnlockRepoMeta(pRepo); goto _err; } } if (tsdbAddTableToMeta(pRepo, table, true, false) < 0) { + table = NULL; tsdbUnlockRepoMeta(pRepo); goto _err; } @@ -200,7 +204,7 @@ _err: return -1; } -void *tsdbGetTableTagVal(const void* pTable, int32_t colId, int16_t type, int16_t bytes) { +void *tsdbGetTableTagVal(const void* pTable, int32_t colId, int16_t type) { // TODO: this function should be changed also STSchema *pSchema = tsdbGetTableTagSchema((STable*) pTable); @@ -209,12 +213,13 @@ void *tsdbGetTableTagVal(const void* pTable, int32_t colId, int16_t type, int16_ return NULL; // No matched tag volumn } - char *val = tdGetKVRowValOfCol(((STable*)pTable)->tagVal, colId); - assert(type == pCol->type); - - // if (val != NULL && IS_VAR_DATA_TYPE(type)) { - // assert(varDataLen(val) < pCol->bytes); - // } + char *val = NULL; + if (pCol->type == TSDB_DATA_TYPE_JSON){ + val = ((STable*)pTable)->tagVal; + }else{ + val = tdGetKVRowValOfCol(((STable*)pTable)->tagVal, colId); + assert(type == pCol->type); + } return val; } @@ -388,7 +393,8 @@ int tsdbUpdateTableTagValue(STsdbRepo *repo, SUpdateTableTagValMsg *pMsg) { TSDB_WUNLOCK_TABLE(pTable->pSuper); } - bool isChangeIndexCol = (pMsg->colId == colColId(schemaColAt(pTable->pSuper->tagSchema, 0))); + bool isChangeIndexCol = (pMsg->colId == colColId(schemaColAt(pTable->pSuper->tagSchema, 0))) + || pMsg->type == TSDB_DATA_TYPE_JSON; // STColumn *pCol = bsearch(&(pMsg->colId), pMsg->data, pMsg->numOfTags, sizeof(STColumn), colIdCompar); // ASSERT(pCol != NULL); @@ -397,7 +403,12 @@ int tsdbUpdateTableTagValue(STsdbRepo *repo, SUpdateTableTagValMsg *pMsg) { tsdbRemoveTableFromIndex(pMeta, pTable); } TSDB_WLOCK_TABLE(pTable); - tdSetKVRowDataOfCol(&(pTable->tagVal), pMsg->colId, pMsg->type, POINTER_SHIFT(pMsg->data, pMsg->schemaLen)); + if (pMsg->type == TSDB_DATA_TYPE_JSON){ + kvRowFree(pTable->tagVal); + pTable->tagVal = tdKVRowDup(POINTER_SHIFT(pMsg->data, pMsg->schemaLen)); + }else{ + tdSetKVRowDataOfCol(&(pTable->tagVal), pMsg->colId, pMsg->type, POINTER_SHIFT(pMsg->data, pMsg->schemaLen)); + } TSDB_WUNLOCK_TABLE(pTable); if (isChangeIndexCol) { tsdbAddTableIntoIndex(pMeta, pTable, false); @@ -850,11 +861,22 @@ static STable *tsdbCreateTableFromCfg(STableCfg *pCfg, bool isSuper, STable *pST } pTable->tagVal = NULL; STColumn *pCol = schemaColAt(pTable->tagSchema, DEFAULT_TAG_INDEX_COLUMN); - pTable->pIndex = tSkipListCreate(TSDB_SUPER_TABLE_SL_LEVEL, colType(pCol), (uint8_t)(colBytes(pCol)), NULL, - SL_ALLOW_DUP_KEY, getTagIndexKey); - if (pTable->pIndex == NULL) { - terrno = TSDB_CODE_TDB_OUT_OF_MEMORY; - goto _err; + if(pCol->type == TSDB_DATA_TYPE_JSON){ + assert(pTable->tagSchema->numOfCols == 1); + pTable->jsonKeyMap = taosHashInit(8, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, HASH_ENTRY_LOCK); + if (pTable->jsonKeyMap == NULL) { + terrno = TSDB_CODE_TDB_OUT_OF_MEMORY; + tsdbFreeTable(pTable); + return NULL; + } + taosHashSetFreeFp(pTable->jsonKeyMap, taosArrayDestroyForHash); + }else{ + pTable->pIndex = tSkipListCreate(TSDB_SUPER_TABLE_SL_LEVEL, colType(pCol), (uint8_t)(colBytes(pCol)), NULL, + SL_ALLOW_DUP_KEY, getTagIndexKey); + if (pTable->pIndex == NULL) { + terrno = TSDB_CODE_TDB_OUT_OF_MEMORY; + goto _err; + } } } else { pTable->type = pCfg->type; @@ -924,6 +946,7 @@ static void tsdbFreeTable(STable *pTable) { kvRowFree(pTable->tagVal); tSkipListDestroy(pTable->pIndex); + taosHashCleanup(pTable->jsonKeyMap); taosTZfree(pTable->lastRow); tfree(pTable->sql); @@ -1048,16 +1071,92 @@ static void tsdbRemoveTableFromMeta(STsdbRepo *pRepo, STable *pTable, bool rmFro tsdbUnRefTable(pTable); } +void* tsdbGetJsonTagValue(STable* pTable, char* key, int32_t keyLen, int16_t* retColId){ + assert(TABLE_TYPE(pTable) == TSDB_CHILD_TABLE); + STable* superTable= pTable->pSuper; + SArray** data = (SArray**)taosHashGet(superTable->jsonKeyMap, key, keyLen); + if(data == NULL) return NULL; + JsonMapValue jmvalue = {pTable, 0}; + JsonMapValue* p = taosArraySearch(*data, &jmvalue, tsdbCompareJsonMapValue, TD_EQ); + if (p == NULL) return NULL; + int16_t colId = p->colId + 1; + if(retColId) *retColId = p->colId; + return tdGetKVRowValOfCol(pTable->tagVal, colId); +} + +int tsdbCompareJsonMapValue(const void* a, const void* b) { + const JsonMapValue* x = (const JsonMapValue*)a; + const JsonMapValue* y = (const JsonMapValue*)b; + if (x->table > y->table) return 1; + if (x->table < y->table) return -1; + return 0; +} + static int tsdbAddTableIntoIndex(STsdbMeta *pMeta, STable *pTable, bool refSuper) { ASSERT(pTable->type == TSDB_CHILD_TABLE && pTable != NULL); STable *pSTable = tsdbGetTableByUid(pMeta, TABLE_SUID(pTable)); ASSERT(pSTable != NULL); pTable->pSuper = pSTable; + if (refSuper) T_REF_INC(pSTable); - tSkipListPut(pSTable->pIndex, (void *)pTable); + if(pSTable->tagSchema->columns[0].type == TSDB_DATA_TYPE_JSON){ + ASSERT(pSTable->tagSchema->numOfCols == 1); + int16_t nCols = kvRowNCols(pTable->tagVal); + ASSERT(nCols%2 == 1); + // check first + for (int j = 0; j < nCols; ++j) { + if (j != 0 && j % 2 == 0) continue; // jump value + SColIdx *pColIdx = kvRowColIdxAt(pTable->tagVal, j); + void *val = (kvRowColVal(pTable->tagVal, pColIdx)); + if (j == 0) { // json value is the first + int8_t jsonPlaceHolder = *(int8_t *)val; + ASSERT(jsonPlaceHolder == TSDB_DATA_JSON_PLACEHOLDER); + continue; + } + if (j == 1) { + uint32_t jsonNULL = *(uint32_t *)(varDataVal(val)); + ASSERT(jsonNULL == TSDB_DATA_JSON_NULL); + } + + // then insert + char keyMd5[TSDB_MAX_JSON_KEY_MD5_LEN] = {0}; + jsonKeyMd5(varDataVal(val), varDataLen(val), keyMd5); + SArray *tablistNew = NULL; + SArray **tablist = (SArray **)taosHashGet(pSTable->jsonKeyMap, keyMd5, TSDB_MAX_JSON_KEY_MD5_LEN); + if (tablist == NULL) { + tablistNew = taosArrayInit(8, sizeof(JsonMapValue)); + if (tablistNew == NULL) { + terrno = TSDB_CODE_TDB_OUT_OF_MEMORY; + tsdbError("out of memory when alloc json tag array"); + return -1; + } + if (taosHashPut(pSTable->jsonKeyMap, keyMd5, TSDB_MAX_JSON_KEY_MD5_LEN, &tablistNew, sizeof(void *)) < 0) { + terrno = TSDB_CODE_TDB_OUT_OF_MEMORY; + tsdbError("out of memory when put json tag array"); + return -1; + } + } else { + tablistNew = *tablist; + } + + JsonMapValue jmvalue = {pTable, pColIdx->colId}; + void* p = taosArraySearch(tablistNew, &jmvalue, tsdbCompareJsonMapValue, TD_EQ); + if (p == NULL) { + p = taosArraySearch(tablistNew, &jmvalue, tsdbCompareJsonMapValue, TD_GE); + if(p == NULL){ + taosArrayPush(tablistNew, &jmvalue); + }else{ + taosArrayInsert(tablistNew, TARRAY_ELEM_IDX(tablistNew, p), &jmvalue); + } + }else{ + tsdbError("insert dumplicate"); + } + } + }else{ + tSkipListPut(pSTable->pIndex, (void *)pTable); + } - if (refSuper) T_REF_INC(pSTable); return 0; } @@ -1067,22 +1166,58 @@ static int tsdbRemoveTableFromIndex(STsdbMeta *pMeta, STable *pTable) { STable *pSTable = pTable->pSuper; ASSERT(pSTable != NULL); - char* key = getTagIndexKey(pTable); - SArray *res = tSkipListGet(pSTable->pIndex, key); + if(pSTable->tagSchema->columns[0].type == TSDB_DATA_TYPE_JSON){ + ASSERT(pSTable->tagSchema->numOfCols == 1); + int16_t nCols = kvRowNCols(pTable->tagVal); + ASSERT(nCols%2 == 1); + for (int j = 0; j < nCols; ++j) { + if (j != 0 && j%2 == 0) continue; // jump value + SColIdx * pColIdx = kvRowColIdxAt(pTable->tagVal, j); + void* val = (kvRowColVal(pTable->tagVal, pColIdx)); + if (j == 0){ // json value is the first + int8_t jsonPlaceHolder = *(int8_t*)val; + ASSERT(jsonPlaceHolder == TSDB_DATA_JSON_PLACEHOLDER); + continue; + } + if (j == 1){ + uint32_t jsonNULL = *(uint32_t*)(varDataVal(val)); + ASSERT(jsonNULL == TSDB_DATA_JSON_NULL); + } + + char keyMd5[TSDB_MAX_JSON_KEY_MD5_LEN] = {0}; + jsonKeyMd5(varDataVal(val), varDataLen(val), keyMd5); + SArray** tablist = (SArray **)taosHashGet(pSTable->jsonKeyMap, keyMd5, TSDB_MAX_JSON_KEY_MD5_LEN); + if(tablist == NULL) { + tsdbError("json tag no key error,%d", j); + continue; + } - size_t size = taosArrayGetSize(res); - ASSERT(size > 0); + JsonMapValue jmvalue = {pTable, pColIdx->colId}; + void* p = taosArraySearch(*tablist, &jmvalue, tsdbCompareJsonMapValue, TD_EQ); + if (p == NULL) { + tsdbError("json tag no tableid error,%d", j); + continue; + } + taosArrayRemove(*tablist, TARRAY_ELEM_IDX(*tablist, p)); + } + }else { + char * key = getTagIndexKey(pTable); + SArray *res = tSkipListGet(pSTable->pIndex, key); - for (int32_t i = 0; i < size; ++i) { - SSkipListNode *pNode = taosArrayGetP(res, i); + size_t size = taosArrayGetSize(res); + ASSERT(size > 0); - // STableIndexElem* pElem = (STableIndexElem*) SL_GET_NODE_DATA(pNode); - if ((STable *)SL_GET_NODE_DATA(pNode) == pTable) { // this is the exact what we need - tSkipListRemoveNode(pSTable->pIndex, pNode); + for (int32_t i = 0; i < size; ++i) { + SSkipListNode *pNode = taosArrayGetP(res, i); + + // STableIndexElem* pElem = (STableIndexElem*) SL_GET_NODE_DATA(pNode); + if ((STable *)SL_GET_NODE_DATA(pNode) == pTable) { // this is the exact what we need + tSkipListRemoveNode(pSTable->pIndex, pNode); + } } - } - taosArrayDestroy(res); + taosArrayDestroy(res); + } return 0; } @@ -1320,12 +1455,22 @@ static void *tsdbDecodeTable(void *buf, STable **pRTable) { if (TABLE_TYPE(pTable) == TSDB_SUPER_TABLE) { buf = tdDecodeSchema(buf, &(pTable->tagSchema)); STColumn *pCol = schemaColAt(pTable->tagSchema, DEFAULT_TAG_INDEX_COLUMN); - pTable->pIndex = tSkipListCreate(TSDB_SUPER_TABLE_SL_LEVEL, colType(pCol), (uint8_t)(colBytes(pCol)), NULL, + if(pCol->type == TSDB_DATA_TYPE_JSON){ + assert(pTable->tagSchema->numOfCols == 1); + pTable->jsonKeyMap = taosHashInit(8, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, HASH_ENTRY_LOCK); + if (pTable->jsonKeyMap == NULL) { + terrno = TSDB_CODE_TDB_OUT_OF_MEMORY; + tsdbFreeTable(pTable); + return NULL; + } + }else{ + pTable->pIndex = tSkipListCreate(TSDB_SUPER_TABLE_SL_LEVEL, colType(pCol), (uint8_t)(colBytes(pCol)), NULL, SL_ALLOW_DUP_KEY, getTagIndexKey); - if (pTable->pIndex == NULL) { - terrno = TSDB_CODE_TDB_OUT_OF_MEMORY; - tsdbFreeTable(pTable); - return NULL; + if (pTable->pIndex == NULL) { + terrno = TSDB_CODE_TDB_OUT_OF_MEMORY; + tsdbFreeTable(pTable); + return NULL; + } } } @@ -1341,13 +1486,29 @@ static void *tsdbDecodeTable(void *buf, STable **pRTable) { return buf; } +static SArray* getJsonTagTableList(STable *pTable){ + uint32_t key = TSDB_DATA_JSON_NULL; + char keyMd5[TSDB_MAX_JSON_KEY_MD5_LEN] = {0}; + jsonKeyMd5(&key, INT_BYTES, keyMd5); + SArray** tablist = (SArray**)taosHashGet(pTable->jsonKeyMap, keyMd5, TSDB_MAX_JSON_KEY_MD5_LEN); + + return *tablist; +} + static int tsdbGetTableEncodeSize(int8_t act, STable *pTable) { int tlen = 0; if (act == TSDB_UPDATE_META) { tlen = sizeof(SListNode) + sizeof(SActObj) + sizeof(SActCont) + tsdbEncodeTable(NULL, pTable) + sizeof(TSCKSUM); } else { if (TABLE_TYPE(pTable) == TSDB_SUPER_TABLE) { - tlen = (int)((sizeof(SListNode) + sizeof(SActObj)) * (SL_SIZE(pTable->pIndex) + 1)); + size_t tableSize = 0; + if(pTable->tagSchema->columns[0].type == TSDB_DATA_TYPE_JSON){ + SArray* tablist = getJsonTagTableList(pTable); + tableSize = taosArrayGetSize(tablist); + }else{ + tableSize = SL_SIZE(pTable->pIndex); + } + tlen = (int)((sizeof(SListNode) + sizeof(SActObj)) * (tableSize + 1)); } else { tlen = sizeof(SListNode) + sizeof(SActObj); } @@ -1387,19 +1548,28 @@ static int tsdbRemoveTableFromStore(STsdbRepo *pRepo, STable *pTable) { void *pBuf = buf; if (TABLE_TYPE(pTable) == TSDB_SUPER_TABLE) { - SSkipListIterator *pIter = tSkipListCreateIter(pTable->pIndex); - if (pIter == NULL) { - terrno = TSDB_CODE_TDB_OUT_OF_MEMORY; - return -1; - } + if(pTable->tagSchema->columns[0].type == TSDB_DATA_TYPE_JSON){ + SArray* tablist = getJsonTagTableList(pTable); + for (int i = 0; i < taosArrayGetSize(tablist); ++i) { + JsonMapValue* p = taosArrayGet(tablist, i); + ASSERT(TABLE_TYPE((STable *)(p->table)) == TSDB_CHILD_TABLE); + pBuf = tsdbInsertTableAct(pRepo, TSDB_DROP_META, pBuf, p->table); + } + }else { + SSkipListIterator *pIter = tSkipListCreateIter(pTable->pIndex); + if (pIter == NULL) { + terrno = TSDB_CODE_TDB_OUT_OF_MEMORY; + return -1; + } - while (tSkipListIterNext(pIter)) { - STable *tTable = (STable *)SL_GET_NODE_DATA(tSkipListIterGet(pIter)); - ASSERT(TABLE_TYPE(tTable) == TSDB_CHILD_TABLE); - pBuf = tsdbInsertTableAct(pRepo, TSDB_DROP_META, pBuf, tTable); - } + while (tSkipListIterNext(pIter)) { + STable *tTable = (STable *)SL_GET_NODE_DATA(tSkipListIterGet(pIter)); + ASSERT(TABLE_TYPE(tTable) == TSDB_CHILD_TABLE); + pBuf = tsdbInsertTableAct(pRepo, TSDB_DROP_META, pBuf, tTable); + } - tSkipListDestroyIter(pIter); + tSkipListDestroyIter(pIter); + } } pBuf = tsdbInsertTableAct(pRepo, TSDB_DROP_META, pBuf, pTable); @@ -1410,25 +1580,27 @@ static int tsdbRemoveTableFromStore(STsdbRepo *pRepo, STable *pTable) { static int tsdbRmTableFromMeta(STsdbRepo *pRepo, STable *pTable) { if (TABLE_TYPE(pTable) == TSDB_SUPER_TABLE) { - SSkipListIterator *pIter = tSkipListCreateIter(pTable->pIndex); - if (pIter == NULL) { - terrno = TSDB_CODE_TDB_OUT_OF_MEMORY; - return -1; - } - tsdbWLockRepoMeta(pRepo); - - while (tSkipListIterNext(pIter)) { - STable *tTable = (STable *)SL_GET_NODE_DATA(tSkipListIterGet(pIter)); - tsdbRemoveTableFromMeta(pRepo, tTable, false, false); + if(pTable->tagSchema->columns[0].type == TSDB_DATA_TYPE_JSON){ + SArray* tablist = getJsonTagTableList(pTable); + for (int i = 0; i < taosArrayGetSize(tablist); ++i) { + JsonMapValue* p = taosArrayGet(tablist, i); + tsdbRemoveTableFromMeta(pRepo, p->table, false, false); + } + }else{ + SSkipListIterator *pIter = tSkipListCreateIter(pTable->pIndex); + if (pIter == NULL) { + terrno = TSDB_CODE_TDB_OUT_OF_MEMORY; + return -1; + } + while (tSkipListIterNext(pIter)) { + STable *tTable = (STable *)SL_GET_NODE_DATA(tSkipListIterGet(pIter)); + tsdbRemoveTableFromMeta(pRepo, tTable, false, false); + } + tSkipListDestroyIter(pIter); } - tsdbRemoveTableFromMeta(pRepo, pTable, false, false); - tsdbUnlockRepoMeta(pRepo); - - tSkipListDestroyIter(pIter); - } else { if ((TABLE_TYPE(pTable) == TSDB_STREAM_TABLE) && pTable->cqhandle) pRepo->appH.cqDropFunc(pTable->cqhandle); tsdbRemoveTableFromMeta(pRepo, pTable, true, true); @@ -1511,3 +1683,4 @@ static void tsdbFreeTableSchema(STable *pTable) { taosArrayDestroy(pTable->schema); } } + diff --git a/src/tsdb/src/tsdbRead.c b/src/tsdb/src/tsdbRead.c index 9b138bbd02b7a88b9bdaddcafbc2d2290d5c3d2e..ca38d10d59348f6f2b9b7d1150d7f21d7bc1a3de 100644 --- a/src/tsdb/src/tsdbRead.c +++ b/src/tsdb/src/tsdbRead.c @@ -26,6 +26,7 @@ #include "tsdbint.h" #include "texpr.h" #include "qFilter.h" +#include "cJSON.h" #define EXTRA_BYTES 2 #define ASCENDING_TRAVERSE(o) (o == TSDB_ORDER_ASC) @@ -2673,17 +2674,31 @@ static int tsdbReadRowsFromCache(STableCheckInfo* pCheckInfo, TSKEY maxKey, int } static int32_t getAllTableList(STable* pSuperTable, SArray* list) { - SSkipListIterator* iter = tSkipListCreateIter(pSuperTable->pIndex); - while (tSkipListIterNext(iter)) { - SSkipListNode* pNode = tSkipListIterGet(iter); + STSchema* pTagSchema = tsdbGetTableTagSchema(pSuperTable); + if(pTagSchema && pTagSchema->numOfCols == 1 && pTagSchema->columns[0].type == TSDB_DATA_TYPE_JSON){ + uint32_t key = TSDB_DATA_JSON_NULL; + char keyMd5[TSDB_MAX_JSON_KEY_MD5_LEN] = {0}; + jsonKeyMd5(&key, INT_BYTES, keyMd5); + SArray** tablist = (SArray**)taosHashGet(pSuperTable->jsonKeyMap, keyMd5, TSDB_MAX_JSON_KEY_MD5_LEN); + + for (int i = 0; i < taosArrayGetSize(*tablist); ++i) { + JsonMapValue* p = taosArrayGet(*tablist, i); + STableKeyInfo info = {.pTable = p->table, .lastKey = TSKEY_INITIAL_VAL}; + taosArrayPush(list, &info); + } + }else{ + SSkipListIterator* iter = tSkipListCreateIter(pSuperTable->pIndex); + while (tSkipListIterNext(iter)) { + SSkipListNode* pNode = tSkipListIterGet(iter); - STable* pTable = (STable*) SL_GET_NODE_DATA((SSkipListNode*) pNode); + STable* pTable = (STable*) SL_GET_NODE_DATA((SSkipListNode*) pNode); - STableKeyInfo info = {.pTable = pTable, .lastKey = TSKEY_INITIAL_VAL}; - taosArrayPush(list, &info); - } + STableKeyInfo info = {.pTable = pTable, .lastKey = TSKEY_INITIAL_VAL}; + taosArrayPush(list, &info); + } - tSkipListDestroyIter(iter); + tSkipListDestroyIter(iter); + } return TSDB_CODE_SUCCESS; } @@ -3543,8 +3558,13 @@ static int32_t tableGroupComparFn(const void *p1, const void *p2, const void *pa STColumn* pCol = schemaColAt(pTableGroupSupp->pTagSchema, colIndex); bytes = pCol->bytes; type = pCol->type; - f1 = tdGetKVRowValOfCol(pTable1->tagVal, pCol->colId); - f2 = tdGetKVRowValOfCol(pTable2->tagVal, pCol->colId); + if (type == TSDB_DATA_TYPE_JSON){ + f1 = getJsonTagValueElment(pTable1, pColIndex->name, (int32_t)strlen(pColIndex->name), NULL, TSDB_MAX_JSON_TAGS_LEN); + f2 = getJsonTagValueElment(pTable2, pColIndex->name, (int32_t)strlen(pColIndex->name), NULL, TSDB_MAX_JSON_TAGS_LEN); + }else{ + f1 = tdGetKVRowValOfCol(pTable1->tagVal, pCol->colId); + f2 = tdGetKVRowValOfCol(pTable2->tagVal, pCol->colId); + } } } @@ -3660,6 +3680,7 @@ SArray* createTableGroup(SArray* pTableList, STSchema* pTagSchema, SColIndex* pC int32_t tsdbQuerySTableByTagCond(STsdbRepo* tsdb, uint64_t uid, TSKEY skey, const char* pTagCond, size_t len, STableGroupInfo* pGroupInfo, SColIndex* pColIndex, int32_t numOfCols) { + SArray* res = NULL; if (tsdbRLockRepoMeta(tsdb) < 0) goto _error; STable* pTable = tsdbGetTableByUid(tsdbGetMeta(tsdb), uid); @@ -3681,7 +3702,7 @@ int32_t tsdbQuerySTableByTagCond(STsdbRepo* tsdb, uint64_t uid, TSKEY skey, cons } //NOTE: not add ref count for super table - SArray* res = taosArrayInit(8, sizeof(STableKeyInfo)); + res = taosArrayInit(8, sizeof(STableKeyInfo)); STSchema* pTagSchema = tsdbGetTableTagSchema(pTable); // no tags and tbname condition, all child tables of this stable are involved @@ -3719,20 +3740,28 @@ int32_t tsdbQuerySTableByTagCond(STsdbRepo* tsdb, uint64_t uid, TSKEY skey, cons // TODO: more error handling } END_TRY - void *filterInfo = NULL; - + void *filterInfo = calloc(1, sizeof(SFilterInfo)); + ((SFilterInfo*)filterInfo)->pTable = pTable; ret = filterInitFromTree(expr, &filterInfo, 0); + tExprTreeDestroy(expr, NULL); + if (ret != TSDB_CODE_SUCCESS) { terrno = ret; + tsdbUnlockRepoMeta(tsdb); + filterFreeInfo(filterInfo); goto _error; } - tsdbQueryTableList(pTable, res, filterInfo); + ret = tsdbQueryTableList(pTable, res, filterInfo); + if (ret != TSDB_CODE_SUCCESS) { + terrno = ret; + tsdbUnlockRepoMeta(tsdb); + filterFreeInfo(filterInfo); + goto _error; + } filterFreeInfo(filterInfo); - tExprTreeDestroy(expr, NULL); - pGroupInfo->numOfTables = (uint32_t)taosArrayGetSize(res); pGroupInfo->pGroupList = createTableGroup(res, pTagSchema, pColIndex, numOfCols, skey); @@ -3745,6 +3774,8 @@ int32_t tsdbQuerySTableByTagCond(STsdbRepo* tsdb, uint64_t uid, TSKEY skey, cons return ret; _error: + + taosArrayDestroy(res); return terrno; } @@ -4009,22 +4040,257 @@ static void queryIndexlessColumn(SSkipList* pSkipList, void* filterInfo, SArray* tSkipListDestroyIter(iter); } +static FORCE_INLINE int32_t tsdbGetJsonTagDataFromId(void *param, int32_t id, char* name, void **data) { + JsonMapValue* jsonMapV = (JsonMapValue*)(param); + STable* pTable = (STable*)(jsonMapV->table); + + if (id == TSDB_TBNAME_COLUMN_INDEX) { + *data = TABLE_NAME(pTable); + } else { + void* jsonData = tsdbGetJsonTagValue(pTable, name, TSDB_MAX_JSON_KEY_MD5_LEN, NULL); + // jsonData == NULL for ? operation + // if(jsonData != NULL) jsonData += CHAR_BYTES; // jump type + *data = jsonData; + } + + return TSDB_CODE_SUCCESS; +} + +static int32_t queryByJsonTag(STable* pTable, void* filterInfo, SArray* res){ + // get all table in fields, and dumplicate it + SArray* tabList = NULL; + bool needQueryAll = false; + SFilterInfo* info = (SFilterInfo*)filterInfo; + for (uint16_t i = 0; i < info->fields[FLD_TYPE_COLUMN].num; ++i) { + SFilterField* fi = &info->fields[FLD_TYPE_COLUMN].fields[i]; + SSchema* sch = fi->desc; + if (sch->colId == TSDB_TBNAME_COLUMN_INDEX) { + tabList = taosArrayInit(32, sizeof(JsonMapValue)); + getAllTableList(pTable, tabList); // query all table + needQueryAll = true; + break; + } + } + for (uint16_t i = 0; i < info->unitNum; ++i) { // is null operation need query all table + SFilterUnit* unit = &info->units[i]; + if (unit->compare.optr == TSDB_RELATION_ISNULL) { + tabList = taosArrayInit(32, sizeof(JsonMapValue)); + getAllTableList(pTable, tabList); // query all table + needQueryAll = true; + break; + } + } + + for (uint16_t i = 0; i < info->fields[FLD_TYPE_COLUMN].num; ++i) { + if (needQueryAll) break; // query all table + SFilterField* fi = &info->fields[FLD_TYPE_COLUMN].fields[i]; + SSchema* sch = fi->desc; + char* key = sch->name; + + SArray** data = (SArray**)taosHashGet(pTable->jsonKeyMap, key, TSDB_MAX_JSON_KEY_MD5_LEN); + if(data == NULL) continue; + if(tabList == NULL) { + tabList = taosArrayDup(*data); + }else{ + for(int j = 0; j < taosArrayGetSize(*data); j++){ + void* element = taosArrayGet(*data, j); + void* p = taosArraySearch(tabList, element, tsdbCompareJsonMapValue, TD_EQ); + if (p == NULL) { + p = taosArraySearch(tabList, element, tsdbCompareJsonMapValue, TD_GE); + if(p == NULL){ + taosArrayPush(tabList, element); + }else{ + taosArrayInsert(tabList, TARRAY_ELEM_IDX(tabList, p), element); + } + } + } + } + } + if(tabList == NULL){ + tsdbError("json key not exist, no candidate table"); + return TSDB_CODE_SUCCESS; + } + size_t size = taosArrayGetSize(tabList); + int8_t *addToResult = NULL; + for(int i = 0; i < size; i++){ + JsonMapValue* data = taosArrayGet(tabList, i); + filterSetJsonColFieldData(filterInfo, data, tsdbGetJsonTagDataFromId); + bool all = filterExecute(filterInfo, 1, &addToResult, NULL, 0); + + if (all || (addToResult && *addToResult)) { + STableKeyInfo kInfo = {.pTable = (void*)(data->table), .lastKey = TSKEY_INITIAL_VAL}; + taosArrayPush(res, &kInfo); + } + } + tfree(addToResult); + taosArrayDestroy(tabList); + return TSDB_CODE_SUCCESS; +} static int32_t tsdbQueryTableList(STable* pTable, SArray* pRes, void* filterInfo) { STSchema* pTSSchema = pTable->tagSchema; - bool indexQuery = false; - SSkipList *pSkipList = pTable->pIndex; - filterIsIndexedColumnQuery(filterInfo, pTSSchema->columns->colId, &indexQuery); + if(pTSSchema->columns->type == TSDB_DATA_TYPE_JSON){ + return queryByJsonTag(pTable, filterInfo, pRes); + }else{ + bool indexQuery = false; + SSkipList *pSkipList = pTable->pIndex; - if (indexQuery) { - queryIndexedColumn(pSkipList, filterInfo, pRes); - } else { - queryIndexlessColumn(pSkipList, filterInfo, pRes); + filterIsIndexedColumnQuery(filterInfo, pTSSchema->columns->colId, &indexQuery); + + if (indexQuery) { + queryIndexedColumn(pSkipList, filterInfo, pRes); + } else { + queryIndexlessColumn(pSkipList, filterInfo, pRes); + } } return TSDB_CODE_SUCCESS; } +void* getJsonTagValueElment(void* data, char* key, int32_t keyLen, char* dst, int16_t bytes){ + char keyMd5[TSDB_MAX_JSON_KEY_MD5_LEN] = {0}; + jsonKeyMd5(key, keyLen, keyMd5); + + void* result = tsdbGetJsonTagValue(data, keyMd5, TSDB_MAX_JSON_KEY_MD5_LEN, NULL); + if (result == NULL){ // json key no result + if(!dst) return NULL; + *dst = TSDB_DATA_TYPE_JSON; + setNull(dst + CHAR_BYTES, TSDB_DATA_TYPE_JSON, 0); + return dst; + } + + char* realData = POINTER_SHIFT(result, CHAR_BYTES); + if(*(char*)result == TSDB_DATA_TYPE_NCHAR || *(char*)result == TSDB_DATA_TYPE_BINARY) { + assert(varDataTLen(realData) < bytes); + if(!dst) return result; + memcpy(dst, result, CHAR_BYTES + varDataTLen(realData)); + return dst; + }else if (*(char*)result == TSDB_DATA_TYPE_DOUBLE || *(char*)result == TSDB_DATA_TYPE_BIGINT) { + if(!dst) return result; + memcpy(dst, result, CHAR_BYTES + LONG_BYTES); + return dst; + }else if (*(char*)result == TSDB_DATA_TYPE_BOOL) { + if(!dst) return result; + memcpy(dst, result, CHAR_BYTES + CHAR_BYTES); + return dst; + }else { + assert(0); + } + return result; +} + +void getJsonTagValueAll(void* data, void* dst, int16_t bytes) { + char* json = parseTagDatatoJson(data); + char* tagData = POINTER_SHIFT(dst, CHAR_BYTES); + *(char*)dst = TSDB_DATA_TYPE_JSON; + if(json == NULL){ + setNull(tagData, TSDB_DATA_TYPE_JSON, 0); + return; + } + + int32_t length = 0; + if(!taosMbsToUcs4(json, strlen(json), varDataVal(tagData), bytes - VARSTR_HEADER_SIZE - CHAR_BYTES, &length)){ + tsdbError("getJsonTagValueAll mbstoucs4 error! length:%d", length); + } + varDataSetLen(tagData, length); + assert(varDataTLen(tagData) <= bytes); + tfree(json); +} + +char* parseTagDatatoJson(void *p){ + char* string = NULL; + cJSON *json = cJSON_CreateObject(); + if (json == NULL) + { + goto end; + } + + int16_t nCols = kvRowNCols(p); + ASSERT(nCols%2 == 1); + char tagJsonKey[TSDB_MAX_JSON_KEY_LEN + 1] = {0}; + for (int j = 0; j < nCols; ++j) { + SColIdx * pColIdx = kvRowColIdxAt(p, j); + void* val = (kvRowColVal(p, pColIdx)); + if (j == 0){ + int8_t jsonPlaceHolder = *(int8_t*)val; + ASSERT(jsonPlaceHolder == TSDB_DATA_JSON_PLACEHOLDER); + continue; + } + if(j == 1){ + uint32_t jsonNULL = *(uint32_t*)(varDataVal(val)); + ASSERT(jsonNULL == TSDB_DATA_JSON_NULL); + continue; + } + if (j == 2){ + if(*(uint32_t*)(varDataVal(val + CHAR_BYTES)) == TSDB_DATA_JSON_NULL) goto end; + continue; + } + if (j%2 == 1) { // json key encode by binary + ASSERT(varDataLen(val) <= TSDB_MAX_JSON_KEY_LEN); + memset(tagJsonKey, 0, sizeof(tagJsonKey)); + memcpy(tagJsonKey, varDataVal(val), varDataLen(val)); + }else{ // json value + char tagJsonValue[TSDB_MAX_JSON_TAGS_LEN] = {0}; + char* realData = POINTER_SHIFT(val, CHAR_BYTES); + char type = *(char*)val; + if(type == TSDB_DATA_TYPE_BINARY) { + assert(*(uint32_t*)varDataVal(realData) == TSDB_DATA_JSON_null); // json null value + assert(varDataLen(realData) == INT_BYTES); + cJSON* value = cJSON_CreateNull(); + if (value == NULL) + { + goto end; + } + cJSON_AddItemToObject(json, tagJsonKey, value); + }else if(type == TSDB_DATA_TYPE_NCHAR) { + int32_t length = taosUcs4ToMbs(varDataVal(realData), varDataLen(realData), tagJsonValue); + if (length < 0) { + tsdbError("charset:%s to %s. val:%s convert json value failed.", DEFAULT_UNICODE_ENCODEC, tsCharset, + (char*)val); + goto end; + } + cJSON* value = cJSON_CreateString(tagJsonValue); + + if (value == NULL) + { + goto end; + } + cJSON_AddItemToObject(json, tagJsonKey, value); + }else if(type == TSDB_DATA_TYPE_DOUBLE){ + double jsonVd = *(double*)(realData); + cJSON* value = cJSON_CreateNumber(jsonVd); + if (value == NULL) + { + goto end; + } + cJSON_AddItemToObject(json, tagJsonKey, value); + }else if(type == TSDB_DATA_TYPE_BIGINT){ + int64_t jsonVd = *(int64_t*)(realData); + cJSON* value = cJSON_CreateNumber((double)jsonVd); + if (value == NULL) + { + goto end; + } + cJSON_AddItemToObject(json, tagJsonKey, value); + }else if (type == TSDB_DATA_TYPE_BOOL) { + char jsonVd = *(char*)(realData); + cJSON* value = cJSON_CreateBool(jsonVd); + if (value == NULL) + { + goto end; + } + cJSON_AddItemToObject(json, tagJsonKey, value); + } + else{ + tsdbError("unsupportted json value"); + } + } + } + string = cJSON_PrintUnformatted(json); +end: + cJSON_Delete(json); + return string; +} diff --git a/src/util/inc/hash.h b/src/util/inc/hash.h index 2a4cbec4dd1fa5d227e181b07ce103c14120a12b..d41c579a58dd149172ee42c94e97b72ab5687548 100644 --- a/src/util/inc/hash.h +++ b/src/util/inc/hash.h @@ -88,6 +88,8 @@ SHashObj *taosHashInit(size_t capacity, _hash_fn_t fn, bool update, SHashLockTyp */ void taosHashSetEqualFp(SHashObj *pHashObj, _equal_fn_t fp); +void taosHashSetFreeFp(SHashObj *pHashObj, _hash_free_fn_t fp); + /** * return the size of hash table * @param pHashObj diff --git a/src/util/inc/tarray.h b/src/util/inc/tarray.h index 2da74eac820e28206cb3e2b7cb6f2c4fb9f481b8..5587b283a47af6b3ee8b38f1f69e95f4d6f7623b 100644 --- a/src/util/inc/tarray.h +++ b/src/util/inc/tarray.h @@ -178,6 +178,12 @@ void taosArrayClear(SArray* pArray); */ void* taosArrayDestroy(SArray* pArray); +/** + * destroy array list for hash + * @param pArray + */ +void taosArrayDestroyForHash(void* para); + /** * * @param pArray diff --git a/src/util/inc/tcompare.h b/src/util/inc/tcompare.h index 1125516d34c65da1b5d0c47dadd126aa0b1959fa..be62ce0a659d0e07d904cac4f994b4639cd18917 100644 --- a/src/util/inc/tcompare.h +++ b/src/util/inc/tcompare.h @@ -88,6 +88,9 @@ int32_t compareStrRegexCompMatch(const void* pLeft, const void* pRight); int32_t compareStrRegexCompNMatch(const void* pLeft, const void* pRight); int32_t compareFindItemInSet(const void *pLeft, const void* pRight); int32_t compareWStrPatternComp(const void* pLeft, const void* pRight); +int32_t compareStrContainJson(const void* pLeft, const void* pRight); +int32_t compareJsonVal(const void* pLeft, const void* pRight); +int32_t jsonCompareUnit(const char* f1, const char* f2, bool* canReturn); #ifdef __cplusplus } diff --git a/src/util/inc/tutil.h b/src/util/inc/tutil.h index 4443716bca3ea280f50eb0402034dc60ee8b5dc8..dd943e8cc45837c814680c9e63b720ddc0c80010 100644 --- a/src/util/inc/tutil.h +++ b/src/util/inc/tutil.h @@ -47,6 +47,8 @@ int taosCheckVersion(char *input_client_version, char *input_server_version, in char * taosIpStr(uint32_t ipInt); uint32_t ip2uint(const char *const ip_addr); +void jsonKeyMd5(void *pMsg, int msgLen, void *pKey); +bool isValidateTag(char *input); static FORCE_INLINE void taosEncryptPass(uint8_t *inBuf, size_t inLen, char *target) { MD5_CTX context; diff --git a/src/util/src/hash.c b/src/util/src/hash.c index 00de532a95363dc22104b4cc75256ccde0c96c2a..20aa146893298a5b9c3f5a85498494ed29afff66 100644 --- a/src/util/src/hash.c +++ b/src/util/src/hash.c @@ -203,7 +203,13 @@ void taosHashSetEqualFp(SHashObj *pHashObj, _equal_fn_t fp) { if (pHashObj != NULL && fp != NULL) { pHashObj->equalFp = fp; } -} +} + +void taosHashSetFreeFp(SHashObj *pHashObj, _hash_free_fn_t fp) { + if (pHashObj != NULL && fp != NULL) { + pHashObj->freeFp = fp; + } +} int32_t taosHashGetSize(const SHashObj *pHashObj) { if (!pHashObj) { @@ -611,7 +617,7 @@ void taosHashCleanup(SHashObj *pHashObj) { taosArrayDestroy(pHashObj->pMemBlock); memset(pHashObj, 0, sizeof(SHashObj)); - free(pHashObj); + tfree(pHashObj); } // for profile only diff --git a/src/util/src/tarray.c b/src/util/src/tarray.c index 007ce0682974d06bf506a82d8bbbc809092eb9e4..812cf65a80e928acf918da7c2b3ab82fd55682d6 100644 --- a/src/util/src/tarray.c +++ b/src/util/src/tarray.c @@ -281,13 +281,26 @@ void taosArrayClear(SArray* pArray) { void* taosArrayDestroy(SArray* pArray) { if (pArray) { - free(pArray->pData); - free(pArray); + tfree(pArray->pData); + tfree(pArray); } return NULL; } +void taosArrayDestroyForHash(void* para) { + SArray** ppArray = (SArray**)para; + if(ppArray == NULL) return; + + SArray* pArray = *ppArray; + if (pArray) { + tfree(pArray->pData); + tfree(pArray); + } + + return; +} + void taosArrayDestroyEx(SArray* pArray, void (*fp)(void*)) { if (pArray == NULL) { return; diff --git a/src/util/src/tcompare.c b/src/util/src/tcompare.c index 23bb73ff860a2b0c4bd5a81005089910faa7792a..1cfc0c3873a438699c342a7dd4a4b1a8efd32878 100644 --- a/src/util/src/tcompare.c +++ b/src/util/src/tcompare.c @@ -18,11 +18,12 @@ #define _DEFAULT_SOURCE #include "tcompare.h" -#include "tulog.h" +#include "tvariant.h" #include "hash.h" -#include "regex.h" #include "os.h" +#include "regex.h" #include "ttype.h" +#include "tulog.h" int32_t setCompareBytes1(const void *pLeft, const void *pRight) { return NULL != taosHashGet((SHashObj *)pRight, pLeft, 1) ? 1 : 0; @@ -218,6 +219,36 @@ int32_t compareLenPrefixedWStrDesc(const void* pLeft, const void* pRight) { return compareLenPrefixedWStr(pRight, pLeft); } +int32_t compareJsonVal(const void *pLeft, const void *pRight) { + const tVariant* right = pRight; + if(right->nType != *(char*)pLeft && !(IS_NUMERIC_TYPE(right->nType) && IS_NUMERIC_TYPE(*(char*)pLeft))) + return TSDB_DATA_JSON_CAN_NOT_COMPARE; + + uint8_t type = *(char*)pLeft; + char* realData = POINTER_SHIFT(pLeft, CHAR_BYTES); + if(type == TSDB_DATA_TYPE_BOOL) { + DEFAULT_COMP(GET_INT8_VAL(realData), right->i64); + }else if(type == TSDB_DATA_TYPE_BIGINT){ + DEFAULT_COMP(GET_INT64_VAL(realData), (right->nType == TSDB_DATA_TYPE_BIGINT) ? right->i64 : right->dKey); + }else if(type == TSDB_DATA_TYPE_DOUBLE){ + DEFAULT_DOUBLE_COMP(GET_DOUBLE_VAL(realData), (right->nType == TSDB_DATA_TYPE_DOUBLE) ? right->dKey : right->i64); + }else if(type == TSDB_DATA_TYPE_NCHAR){ + if (varDataLen(realData) != right->nLen) { + return varDataLen(realData) > right->nLen ? 1 : -1; + } + int32_t ret = memcmp(varDataVal(realData), right->pz, right->nLen); + if (ret == 0) { + return ret; + } + return (ret < 0) ? -1 : 1; + }else if(type == TSDB_DATA_TYPE_BINARY) { //json null + return 0; + }else{ + assert(0); + } + return 0; +} + /* * Compare two strings * TSDB_MATCH: Match @@ -405,6 +436,12 @@ int32_t compareStrRegexComp(const void* pLeft, const void* pRight) { return result; } +int32_t compareStrContainJson(const void* pLeft, const void* pRight) { + if(pLeft) return 0; + return 1; +} + + int32_t taosArrayCompareString(const void* a, const void* b) { const char* x = *(const char**)a; const char* y = *(const char**)b; @@ -487,7 +524,7 @@ __compar_fn_t getComparFunc(int32_t type, int32_t optr) { break; } - case TSDB_DATA_TYPE_NCHAR: { + case TSDB_DATA_TYPE_NCHAR:{ if (optr == TSDB_RELATION_MATCH) { comparFn = compareStrRegexCompMatch; } else if (optr == TSDB_RELATION_NMATCH) { @@ -501,6 +538,20 @@ __compar_fn_t getComparFunc(int32_t type, int32_t optr) { } break; } + case TSDB_DATA_TYPE_JSON:{ + if (optr == TSDB_RELATION_MATCH) { + comparFn = compareStrRegexCompMatch; + } else if (optr == TSDB_RELATION_NMATCH) { + comparFn = compareStrRegexCompNMatch; + } else if (optr == TSDB_RELATION_LIKE) { /* wildcard query using like operator */ + comparFn = compareWStrPatternComp; + } else if (optr == TSDB_RELATION_CONTAINS) { + comparFn = compareStrContainJson; + } else { + comparFn = compareJsonVal; + } + break; + } case TSDB_DATA_TYPE_UTINYINT: comparFn = compareUint8Val; break; case TSDB_DATA_TYPE_USMALLINT: comparFn = compareUint16Val;break; @@ -565,7 +616,48 @@ __compar_fn_t getKeyComparFunc(int32_t keyType, int32_t order) { return comparFn; } +int32_t jsonCompareUnit(const char* f1, const char* f2, bool* canReturn){ + *canReturn = true; + bool f1IsNull = (*f1 == TSDB_DATA_TYPE_JSON && isNull(f1 + CHAR_BYTES, TSDB_DATA_TYPE_JSON)); + bool f2IsNull = (*f2 == TSDB_DATA_TYPE_JSON && isNull(f2 + CHAR_BYTES, TSDB_DATA_TYPE_JSON)); + if(f1IsNull && f2IsNull){ + return 0; + }else if(f1IsNull && !f2IsNull){ + return -1; + }else if(!f1IsNull && f2IsNull){ + return 1; + }else{ + bool f1IsJsonNull = (*f1 == TSDB_DATA_TYPE_BINARY && *(uint32_t*)varDataVal(f1 + CHAR_BYTES) == TSDB_DATA_JSON_null); + bool f2IsJsonNull = (*f2 == TSDB_DATA_TYPE_BINARY && *(uint32_t*)varDataVal(f2 + CHAR_BYTES) == TSDB_DATA_JSON_null); + if(f1IsJsonNull && f2IsJsonNull){ + return 0; + }else if(f1IsJsonNull && !f2IsJsonNull){ + return -1; + }else if(!f1IsJsonNull && f2IsJsonNull) { + return 1; + } + if(*f1 != *f2 && !(IS_NUMERIC_TYPE(*f1) && IS_NUMERIC_TYPE(*f2))) { + return *f1 > *f2 ? 1 : -1; + } + if(*f1 == TSDB_DATA_TYPE_BIGINT && *f2 == TSDB_DATA_TYPE_DOUBLE){ + DEFAULT_COMP(GET_INT64_VAL(f1 + CHAR_BYTES), GET_DOUBLE_VAL(f2 + CHAR_BYTES)); + }else if(*f1 == TSDB_DATA_TYPE_DOUBLE && *f2 == TSDB_DATA_TYPE_BIGINT){ + DEFAULT_COMP(GET_DOUBLE_VAL(f1 + CHAR_BYTES), GET_INT64_VAL(f2 + CHAR_BYTES)); + } + *canReturn = false; + return 0; // meaningless + } +} + int32_t doCompare(const char* f1, const char* f2, int32_t type, size_t size) { + if (type == TSDB_DATA_TYPE_JSON){ + bool canReturn = true; + int32_t result = jsonCompareUnit(f1, f2, &canReturn); + if(canReturn) return result; + type = *f1; + f1 += CHAR_BYTES; + f2 += CHAR_BYTES; + } switch (type) { case TSDB_DATA_TYPE_INT: DEFAULT_COMP(GET_INT32_VAL(f1), GET_INT32_VAL(f2)); case TSDB_DATA_TYPE_DOUBLE: DEFAULT_DOUBLE_COMP(GET_DOUBLE_VAL(f1), GET_DOUBLE_VAL(f2)); @@ -578,7 +670,7 @@ int32_t doCompare(const char* f1, const char* f2, int32_t type, size_t size) { case TSDB_DATA_TYPE_USMALLINT: DEFAULT_COMP(GET_UINT16_VAL(f1), GET_UINT16_VAL(f2)); case TSDB_DATA_TYPE_UINT: DEFAULT_COMP(GET_UINT32_VAL(f1), GET_UINT32_VAL(f2)); case TSDB_DATA_TYPE_UBIGINT: DEFAULT_COMP(GET_UINT64_VAL(f1), GET_UINT64_VAL(f2)); - case TSDB_DATA_TYPE_NCHAR: { + case TSDB_DATA_TYPE_NCHAR:{ tstr* t1 = (tstr*) f1; tstr* t2 = (tstr*) f2; diff --git a/src/util/src/terror.c b/src/util/src/terror.c index 2001cb29a043774e8514220d08893750ab7b285c..3853d2e9c7491db68abf4ca9f7d42edd62da5729 100644 --- a/src/util/src/terror.c +++ b/src/util/src/terror.c @@ -282,6 +282,7 @@ TAOS_DEFINE_ERROR(TSDB_CODE_TDB_MESSED_MSG, "TSDB messed message") TAOS_DEFINE_ERROR(TSDB_CODE_TDB_IVLD_TAG_VAL, "TSDB invalid tag value") TAOS_DEFINE_ERROR(TSDB_CODE_TDB_NO_CACHE_LAST_ROW, "TSDB no cache last row data") TAOS_DEFINE_ERROR(TSDB_CODE_TDB_INCOMPLETE_DFILESET, "Incomplete DFileSet") +TAOS_DEFINE_ERROR(TSDB_CODE_TDB_NO_JSON_TAG_KEY, "TSDB no tag json key") // query TAOS_DEFINE_ERROR(TSDB_CODE_QRY_INVALID_QHANDLE, "Invalid handle") @@ -300,7 +301,6 @@ TAOS_DEFINE_ERROR(TSDB_CODE_QRY_INCONSISTAN, "File inconsistance in TAOS_DEFINE_ERROR(TSDB_CODE_QRY_INVALID_TIME_CONDITION, "One valid time range condition expected") TAOS_DEFINE_ERROR(TSDB_CODE_QRY_SYS_ERROR, "System error") - // grant TAOS_DEFINE_ERROR(TSDB_CODE_GRANT_EXPIRED, "License expired") TAOS_DEFINE_ERROR(TSDB_CODE_GRANT_DNODE_LIMITED, "DNode creation limited by licence") 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 5eee3adbc3e83e3d26a2bd93e0b564d21cfc6668..5876d82bea9f0373b5086b2ce285f7ad86002536 100644 --- a/src/util/src/ttokenizer.c +++ b/src/util/src/ttokenizer.c @@ -44,6 +44,7 @@ static SKeyword keywordTable[] = { {"TIMESTAMP", TK_TIMESTAMP}, {"BINARY", TK_BINARY}, {"NCHAR", TK_NCHAR}, + {"JSON", TK_JSON}, {"OR", TK_OR}, {"AND", TK_AND}, {"NOT", TK_NOT}, @@ -72,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}, @@ -230,7 +230,8 @@ static SKeyword keywordTable[] = { {"OUTPUTTYPE", TK_OUTPUTTYPE}, {"AGGREGATE", TK_AGGREGATE}, {"BUFSIZE", TK_BUFSIZE}, - {"RANGE", TK_RANGE} + {"RANGE", TK_RANGE}, + {"CONTAINS", TK_CONTAINS} }; static const char isIdChar[] = { @@ -312,6 +313,10 @@ uint32_t tGetToken(char* z, uint32_t* tokenId) { *tokenId = TK_COMMENT; return i; } + if (z[1] == '>') { + *tokenId = TK_ARROW; + return 2; + } *tokenId = TK_MINUS; return 1; } @@ -394,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/src/util/src/tutil.c b/src/util/src/tutil.c index c8172fc0aff010332de7d13071a28303f37cf7f5..c15197b7537601c0f0ca72420a6711547d1ed0ed 100644 --- a/src/util/src/tutil.c +++ b/src/util/src/tutil.c @@ -21,6 +21,11 @@ #include "tulog.h" #include "taoserror.h" +bool isInteger(double x){ + int truncated = (int)x; + return (x == truncated); +} + int32_t strdequote(char *z) { if (z == NULL) { return 0; @@ -105,7 +110,7 @@ size_t strtrim(char *z) { int32_t j = 0; int32_t delta = 0; - while (z[j] == ' ') { + while (isspace(z[j])) { ++j; } @@ -118,9 +123,9 @@ size_t strtrim(char *z) { int32_t stop = 0; while (z[j] != 0) { - if (z[j] == ' ' && stop == 0) { + if (isspace(z[j]) && stop == 0) { stop = j; - } else if (z[j] != ' ' && stop != 0) { + } else if (!isspace(z[j]) && stop != 0) { stop = 0; } @@ -509,6 +514,24 @@ char *taosIpStr(uint32_t ipInt) { return ipStr; } +void jsonKeyMd5(void *pMsg, int msgLen, void *pKey) { + MD5_CTX context; + + MD5Init(&context); + MD5Update(&context, (uint8_t *)pMsg, msgLen); + MD5Final(&context); + + memcpy(pKey, context.digest, sizeof(context.digest)); +} + +bool isValidateTag(char *input) { + if (!input) return false; + for (size_t i = 0; i < strlen(input); ++i) { + if (isprint(input[i]) == 0) return false; + } + return true; +} + FORCE_INLINE float taos_align_get_float(const char* pBuf) { #if __STDC_VERSION__ >= 201112L static_assert(sizeof(float) == sizeof(uint32_t), "sizeof(float) must equal to sizeof(uint32_t)"); diff --git a/tests/develop-test/0-management/3-tag/json_tag.py b/tests/develop-test/0-management/3-tag/json_tag.py new file mode 100644 index 0000000000000000000000000000000000000000..4810ec8b4e2437f5aecbb67a10c8d2ce4e5c55c5 --- /dev/null +++ b/tests/develop-test/0-management/3-tag/json_tag.py @@ -0,0 +1,515 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, db_test.stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import taos +from util.log import tdLog +from util.cases import tdCases +from util.sql import tdSql + + +class TDTestCase: + def caseDescription(self): + ''' + Json tag test case, include create table with json tag, + select json tag and query with json tag in where condition, + besides, include json tag in group by/order by/join/subquery. + ''' + return + + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + tdSql.prepare() + + print("============== STEP 1 ===== prepare data & validate json string") + tdSql.error("create table if not exists jsons1(ts timestamp, dataInt int, dataBool bool, dataStr nchar(50), dataStrBin binary(150)) tags(jtag json, tagint int)") + tdSql.error("create table if not exists jsons1(ts timestamp, data json) tags(tagint int)") + tdSql.execute("create table if not exists jsons1(ts timestamp, dataInt int, dataBool bool, dataStr nchar(50), dataStrBin binary(150)) tags(jtag json)") + tdSql.execute("insert into jsons1_1 using jsons1 tags('{\"tag1\":\"fff\",\"tag2\":5, \"tag3\":true}') values(1591060618000, 1, false, 'json1', '你是') (1591060608000, 23, true, '等等', 'json')") + tdSql.execute("insert into jsons1_2 using jsons1 tags('{\"tag1\":5,\"tag2\":\"beijing\"}') values (1591060628000, 2, true, 'json2', 'sss')") + tdSql.execute("insert into jsons1_3 using jsons1 tags('{\"tag1\":false,\"tag2\":\"beijing\"}') values (1591060668000, 3, false, 'json3', 'efwe')") + tdSql.execute("insert into jsons1_4 using jsons1 tags('{\"tag1\":null,\"tag2\":\"shanghai\",\"tag3\":\"hello\"}') values (1591060728000, 4, true, 'json4', '323sd')") + tdSql.execute("insert into jsons1_5 using jsons1 tags('{\"tag1\":1.232, \"tag2\":null}') values(1591060928000, 1, false, '你就会', 'ewe')") + tdSql.execute("insert into jsons1_6 using jsons1 tags('{\"tag1\":11,\"tag2\":\"\",\"tag2\":null}') values(1591061628000, 11, false, '你就会','')") + tdSql.execute("insert into jsons1_7 using jsons1 tags('{\"tag1\":\"收到货\",\"tag2\":\"\",\"tag3\":null}') values(1591062628000, 2, NULL, '你就会', 'dws')") + + # test duplicate key using the first one. elimate empty key + tdSql.execute("CREATE TABLE if not exists jsons1_8 using jsons1 tags('{\"tag1\":null, \"tag1\":true, \"tag1\":45, \"1tag$\":2, \" \":90, \"\":32}')") + tdSql.query("select jtag from jsons1_8") + tdSql.checkData(0, 0, '{"tag1":null,"1tag$":2," ":90}') + + # test empty json string, save as jtag is NULL + tdSql.execute("insert into jsons1_9 using jsons1 tags('\t') values (1591062328000, 24, NULL, '你就会', '2sdw')") + tdSql.execute("CREATE TABLE if not exists jsons1_10 using jsons1 tags('')") + tdSql.execute("CREATE TABLE if not exists jsons1_11 using jsons1 tags(' ')") + tdSql.execute("CREATE TABLE if not exists jsons1_12 using jsons1 tags('{}')") + tdSql.execute("CREATE TABLE if not exists jsons1_13 using jsons1 tags('null')") + + # test invalidate json + tdSql.error("CREATE TABLE if not exists jsons1_14 using jsons1 tags('\"efwewf\"')") + tdSql.error("CREATE TABLE if not exists jsons1_14 using jsons1 tags('3333')") + tdSql.error("CREATE TABLE if not exists jsons1_14 using jsons1 tags('33.33')") + tdSql.error("CREATE TABLE if not exists jsons1_14 using jsons1 tags('false')") + tdSql.error("CREATE TABLE if not exists jsons1_14 using jsons1 tags('[1,true]')") + tdSql.error("CREATE TABLE if not exists jsons1_14 using jsons1 tags('{222}')") + tdSql.error("CREATE TABLE if not exists jsons1_14 using jsons1 tags('{\"fe\"}')") + + # test invalidate json key, key must can be printed assic char + tdSql.error("CREATE TABLE if not exists jsons1_14 using jsons1 tags('{\"tag1\":[1,true]}')") + tdSql.error("CREATE TABLE if not exists jsons1_14 using jsons1 tags('{\"tag1\":{}}')") + tdSql.error("CREATE TABLE if not exists jsons1_14 using jsons1 tags('{\"。loc\":\"fff\"}')") + tdSql.error("CREATE TABLE if not exists jsons1_14 using jsons1 tags('{\"\t\":\"fff\"}')") + tdSql.error("CREATE TABLE if not exists jsons1_14 using jsons1 tags('{\"试试\":\"fff\"}')") + + #test length limit + char1= ''.join(['abcd']*64) + char3= ''.join(['abcd']*1022) + print(len(char3)) # 4088 + tdSql.error("CREATE TABLE if not exists jsons1_15 using jsons1 tags('{\"%s1\":5}')" % char1) # len(key)=257 + tdSql.execute("CREATE TABLE if not exists jsons1_15 using jsons1 tags('{\"%s\":5}')" % char1) # len(key)=256 + tdSql.error("CREATE TABLE if not exists jsons1_16 using jsons1 tags('{\"TS\":\"%s\"}')" % char3) # len(object)=4097 + tdSql.execute("CREATE TABLE if not exists jsons1_16 using jsons1 tags('{\"T\":\"%s\"}')" % char3) # len(object)=4096 + tdSql.execute("drop table if exists jsons1_15") + tdSql.execute("drop table if exists jsons1_16") + + print("============== STEP 2 ===== alter table json tag") + tdSql.error("ALTER STABLE jsons1 add tag tag2 nchar(20)") + tdSql.error("ALTER STABLE jsons1 drop tag jtag") + tdSql.error("ALTER TABLE jsons1 MODIFY TAG jtag nchar(128)") + + tdSql.execute("ALTER TABLE jsons1_1 SET TAG jtag='{\"tag1\":\"femail\",\"tag2\":35,\"tag3\":true}'") + tdSql.query("select jtag from jsons1_1") + tdSql.checkData(0, 0, '{"tag1":"femail","tag2":35,"tag3":true}') + tdSql.execute("ALTER TABLE jsons1 CHANGE TAG jtag jtag_new") + tdSql.execute("ALTER TABLE jsons1 CHANGE TAG jtag_new jtag") + + print("============== STEP 3 ===== query table") + # test error syntax + tdSql.error("select * from jsons1 where jtag->tag1='beijing'") + tdSql.error("select * from jsons1 where jtag->'location'") + tdSql.error("select * from jsons1 where jtag->''") + tdSql.error("select * from jsons1 where jtag->''=9") + tdSql.error("select -> from jsons1") + tdSql.error("select * from jsons1 where contains") + tdSql.error("select * from jsons1 where jtag->") + tdSql.error("select jtag->location from jsons1") + tdSql.error("select jtag contains location from jsons1") + tdSql.error("select * from jsons1 where jtag contains location") + tdSql.error("select * from jsons1 where jtag contains''") + tdSql.error("select * from jsons1 where jtag contains 'location'='beijing'") + + # test function error + tdSql.error("select avg(jtag->'tag1') from jsons1") + tdSql.error("select avg(jtag) from jsons1") + tdSql.error("select min(jtag->'tag1') from jsons1") + tdSql.error("select min(jtag) from jsons1") + tdSql.error("select ceil(jtag->'tag1') from jsons1") + tdSql.error("select ceil(jtag) from jsons1") + + # test select normal column + tdSql.query("select dataint from jsons1") + tdSql.checkRows(9) + tdSql.checkData(1, 0, 1) + + # test select json tag + tdSql.query("select * from jsons1") + tdSql.checkRows(9) + tdSql.query("select jtag from jsons1") + tdSql.checkRows(13) + tdSql.query("select jtag from jsons1 where jtag is null") + tdSql.checkRows(5) + tdSql.query("select jtag from jsons1 where jtag is not null") + tdSql.checkRows(8) + + # test jtag is NULL + tdSql.query("select jtag from jsons1_9") + tdSql.checkData(0, 0, None) + + # test select json tag->'key', value is string + tdSql.query("select jtag->'tag1' from jsons1_1") + tdSql.checkData(0, 0, '"femail"') + tdSql.query("select jtag->'tag2' from jsons1_6") + tdSql.checkData(0, 0, '""') + # test select json tag->'key', value is int + tdSql.query("select jtag->'tag2' from jsons1_1") + tdSql.checkData(0, 0, 35) + # test select json tag->'key', value is bool + tdSql.query("select jtag->'tag3' from jsons1_1") + tdSql.checkData(0, 0, "true") + # test select json tag->'key', value is null + tdSql.query("select jtag->'tag1' from jsons1_4") + tdSql.checkData(0, 0, "null") + # test select json tag->'key', value is double + tdSql.query("select jtag->'tag1' from jsons1_5") + tdSql.checkData(0, 0, "1.232000000") + # test select json tag->'key', key is not exist + tdSql.query("select jtag->'tag10' from jsons1_4") + tdSql.checkData(0, 0, None) + + tdSql.query("select jtag->'tag1' from jsons1") + tdSql.checkRows(13) + # test header name + res = tdSql.getColNameList("select jtag->'tag1' from jsons1") + cname_list = [] + cname_list.append("jtag->'tag1'") + tdSql.checkColNameList(res, cname_list) + + + + # test where with json tag + tdSql.error("select * from jsons1_1 where jtag is not null") + tdSql.error("select * from jsons1 where jtag='{\"tag1\":11,\"tag2\":\"\"}'") + tdSql.error("select * from jsons1 where jtag->'tag1'={}") + + # where json value is string + tdSql.query("select * from jsons1 where jtag->'tag2'='beijing'") + tdSql.checkRows(2) + tdSql.query("select dataint,tbname,jtag->'tag1',jtag from jsons1 where jtag->'tag2'='beijing'") + tdSql.checkData(0, 0, 2) + tdSql.checkData(0, 1, 'jsons1_2') + tdSql.checkData(0, 2, 5) + tdSql.checkData(0, 3, '{"tag1":5,"tag2":"beijing"}') + tdSql.checkData(1, 0, 3) + tdSql.checkData(1, 1, 'jsons1_3') + tdSql.checkData(1, 2, 'false') + tdSql.query("select * from jsons1 where jtag->'tag1'='beijing'") + tdSql.checkRows(0) + tdSql.query("select * from jsons1 where jtag->'tag1'='收到货'") + tdSql.checkRows(1) + tdSql.query("select * from jsons1 where jtag->'tag2'>'beijing'") + tdSql.checkRows(1) + tdSql.query("select * from jsons1 where jtag->'tag2'>='beijing'") + tdSql.checkRows(3) + tdSql.query("select * from jsons1 where jtag->'tag2'<'beijing'") + tdSql.checkRows(2) + tdSql.query("select * from jsons1 where jtag->'tag2'<='beijing'") + tdSql.checkRows(4) + tdSql.query("select * from jsons1 where jtag->'tag2'!='beijing'") + tdSql.checkRows(3) + tdSql.query("select * from jsons1 where jtag->'tag2'=''") + tdSql.checkRows(2) + + # where json value is int + tdSql.query("select * from jsons1 where jtag->'tag1'=5") + tdSql.checkRows(1) + tdSql.checkData(0, 1, 2) + tdSql.query("select * from jsons1 where jtag->'tag1'=10") + tdSql.checkRows(0) + tdSql.query("select * from jsons1 where jtag->'tag1'<54") + tdSql.checkRows(3) + tdSql.query("select * from jsons1 where jtag->'tag1'<=11") + tdSql.checkRows(3) + tdSql.query("select * from jsons1 where jtag->'tag1'>4") + tdSql.checkRows(2) + tdSql.query("select * from jsons1 where jtag->'tag1'>=5") + tdSql.checkRows(2) + tdSql.query("select * from jsons1 where jtag->'tag1'!=5") + tdSql.checkRows(2) + tdSql.query("select * from jsons1 where jtag->'tag1'!=55") + tdSql.checkRows(3) + + # where json value is double + tdSql.query("select * from jsons1 where jtag->'tag1'=1.232") + tdSql.checkRows(1) + tdSql.query("select * from jsons1 where jtag->'tag1'<1.232") + tdSql.checkRows(0) + tdSql.query("select * from jsons1 where jtag->'tag1'<=1.232") + tdSql.checkRows(1) + tdSql.query("select * from jsons1 where jtag->'tag1'>1.23") + tdSql.checkRows(3) + tdSql.query("select * from jsons1 where jtag->'tag1'>=1.232") + tdSql.checkRows(3) + tdSql.query("select * from jsons1 where jtag->'tag1'!=1.232") + tdSql.checkRows(2) + tdSql.query("select * from jsons1 where jtag->'tag1'!=3.232") + tdSql.checkRows(3) + tdSql.error("select * from jsons1 where jtag->'tag1'/0=3") + tdSql.error("select * from jsons1 where jtag->'tag1'/5=1") + + # where json value is bool + tdSql.query("select * from jsons1 where jtag->'tag1'=true") + tdSql.checkRows(0) + tdSql.query("select * from jsons1 where jtag->'tag1'=false") + tdSql.checkRows(1) + tdSql.query("select * from jsons1 where jtag->'tag1'!=false") + tdSql.checkRows(0) + tdSql.error("select * from jsons1 where jtag->'tag1'>false") + + # where json value is null + tdSql.query("select * from jsons1 where jtag->'tag1'=null") # only json suport =null. This synatx will change later. + tdSql.checkRows(1) + + # where json is null + tdSql.query("select * from jsons1 where jtag is null") + tdSql.checkRows(1) + tdSql.query("select * from jsons1 where jtag is not null") + tdSql.checkRows(8) + + # where json key is null + tdSql.query("select * from jsons1 where jtag->'tag_no_exist'=3") + tdSql.checkRows(0) + + # where json value is not exist + tdSql.query("select * from jsons1 where jtag->'tag1' is null") + tdSql.checkData(0, 0, 'jsons1_9') + tdSql.checkRows(1) + tdSql.query("select * from jsons1 where jtag->'tag4' is null") + tdSql.checkRows(9) + tdSql.query("select * from jsons1 where jtag->'tag3' is not null") + tdSql.checkRows(4) + + # test contains + tdSql.query("select * from jsons1 where jtag contains 'tag1'") + tdSql.checkRows(8) + tdSql.query("select * from jsons1 where jtag contains 'tag3'") + tdSql.checkRows(4) + tdSql.query("select * from jsons1 where jtag contains 'tag_no_exist'") + tdSql.checkRows(0) + + # test json tag in where condition with and/or + tdSql.query("select * from jsons1 where jtag->'tag1'=false and jtag->'tag2'='beijing'") + tdSql.checkRows(1) + tdSql.query("select * from jsons1 where jtag->'tag1'=false or jtag->'tag2'='beijing'") + tdSql.checkRows(2) + tdSql.query("select * from jsons1 where jtag->'tag1'=false and jtag->'tag2'='shanghai'") + tdSql.checkRows(0) + tdSql.query("select * from jsons1 where jtag->'tag1'=false and jtag->'tag2'='shanghai'") + tdSql.checkRows(0) + tdSql.query("select * from jsons1 where jtag->'tag1'=13 or jtag->'tag2'>35") + tdSql.checkRows(0) + tdSql.query("select * from jsons1 where jtag->'tag1'=13 or jtag->'tag2'>35") + tdSql.checkRows(0) + tdSql.query("select * from jsons1 where jtag->'tag1' is not null and jtag contains 'tag3'") + tdSql.checkRows(4) + tdSql.query("select * from jsons1 where jtag->'tag1'='femail' and jtag contains 'tag3'") + tdSql.checkRows(2) + + + # test with between and + tdSql.query("select * from jsons1 where jtag->'tag1' between 1 and 30") + tdSql.checkRows(3) + tdSql.query("select * from jsons1 where jtag->'tag1' between 'femail' and 'beijing'") + tdSql.checkRows(2) + + # test with tbname/normal column + tdSql.query("select * from jsons1 where tbname = 'jsons1_1'") + tdSql.checkRows(2) + tdSql.query("select * from jsons1 where tbname = 'jsons1_1' and jtag contains 'tag3'") + tdSql.checkRows(2) + tdSql.query("select * from jsons1 where tbname = 'jsons1_1' and jtag contains 'tag3' and dataint=3") + tdSql.checkRows(0) + tdSql.query("select * from jsons1 where tbname = 'jsons1_1' and jtag contains 'tag3' and dataint=23") + tdSql.checkRows(1) + + + # test where condition like + tdSql.query("select *,tbname from jsons1 where jtag->'tag2' like 'bei%'") + tdSql.checkRows(2) + tdSql.query("select *,tbname from jsons1 where jtag->'tag1' like 'fe%' and jtag->'tag2' is not null") + tdSql.checkRows(2) + + # test where condition in no support in + tdSql.error("select * from jsons1 where jtag->'tag1' in ('beijing')") + + # test where condition match/nmath + tdSql.query("select * from jsons1 where jtag->'tag1' match 'ma'") + tdSql.checkRows(2) + tdSql.query("select * from jsons1 where jtag->'tag1' match 'ma$'") + tdSql.checkRows(0) + tdSql.query("select * from jsons1 where jtag->'tag2' match 'jing$'") + tdSql.checkRows(2) + tdSql.query("select * from jsons1 where jtag->'tag1' match '收到'") + tdSql.checkRows(1) + tdSql.query("select * from jsons1 where jtag->'tag1' nmatch 'ma'") + tdSql.checkRows(1) + + # test distinct + tdSql.execute("insert into jsons1_14 using jsons1 tags('{\"tag1\":\"收到货\",\"tag2\":\"\",\"tag3\":null}') values(1591062628000, 2, NULL, '你就会', 'dws')") + tdSql.query("select distinct jtag->'tag1' from jsons1") + tdSql.checkRows(8) + tdSql.query("select distinct jtag from jsons1") + tdSql.checkRows(9) + + #test dumplicate key with normal colomn + tdSql.execute("INSERT INTO jsons1_15 using jsons1 tags('{\"tbname\":\"tt\",\"databool\":true,\"datastr\":\"是是是\"}') values(1591060828000, 4, false, 'jjsf', \"你就会\")") + tdSql.query("select *,tbname,jtag from jsons1 where jtag->'datastr' match '是' and datastr match 'js'") + tdSql.checkRows(1) + tdSql.query("select tbname,jtag->'tbname' from jsons1 where jtag->'tbname'='tt' and tbname='jsons1_14'") + tdSql.checkRows(0) + + # test join + tdSql.execute("create table if not exists jsons2(ts timestamp, dataInt int, dataBool bool, dataStr nchar(50), dataStrBin binary(150)) tags(jtag json)") + tdSql.execute("insert into jsons2_1 using jsons2 tags('{\"tag1\":\"fff\",\"tag2\":5, \"tag3\":true}') values(1591060618000, 2, false, 'json2', '你是2')") + tdSql.execute("insert into jsons2_2 using jsons2 tags('{\"tag1\":5,\"tag2\":null}') values (1591060628000, 2, true, 'json2', 'sss')") + + tdSql.execute("create table if not exists jsons3(ts timestamp, dataInt int, dataBool bool, dataStr nchar(50), dataStrBin binary(150)) tags(jtag json)") + tdSql.execute("insert into jsons3_1 using jsons3 tags('{\"tag1\":\"fff\",\"tag2\":5, \"tag3\":true}') values(1591060618000, 3, false, 'json3', '你是3')") + tdSql.execute("insert into jsons3_2 using jsons3 tags('{\"tag1\":5,\"tag2\":\"beijing\"}') values (1591060638000, 2, true, 'json3', 'sss')") + tdSql.query("select 'sss',33,a.jtag->'tag3' from jsons2 a,jsons3 b where a.ts=b.ts and a.jtag->'tag1'=b.jtag->'tag1'") + tdSql.checkData(0, 0, "sss") + tdSql.checkData(0, 2, "true") + + res = tdSql.getColNameList("select 'sss',33,a.jtag->'tag3' from jsons2 a,jsons3 b where a.ts=b.ts and a.jtag->'tag1'=b.jtag->'tag1'") + cname_list = [] + cname_list.append("sss") + cname_list.append("33") + cname_list.append("a.jtag->'tag3'") + tdSql.checkColNameList(res, cname_list) + + # test group by & order by json tag + tdSql.error("select count(*) from jsons1 group by jtag->'tag1' order by jtag->'tag2'") + tdSql.error("select count(*) from jsons1 group by jtag->'tag1' order by jtag") + tdSql.query("select count(*) from jsons1 group by jtag->'tag1' order by jtag->'tag1' desc") + tdSql.checkRows(8) + tdSql.checkData(0, 0, 2) + tdSql.checkData(0, 1, '"femail"') + tdSql.checkData(2, 0, 1) + tdSql.checkData(2, 1, 11) + tdSql.checkData(5, 0, 1) + tdSql.checkData(5, 1, "false") + tdSql.checkData(6, 0, 1) + tdSql.checkData(6, 1, "null") + tdSql.checkData(7, 0, 2) + tdSql.checkData(7, 1, None) + + tdSql.query("select count(*) from jsons1 group by jtag->'tag1' order by jtag->'tag1' asc") + tdSql.checkRows(8) + tdSql.checkData(0, 0, 2) + tdSql.checkData(0, 1, None) + tdSql.checkData(2, 0, 1) + tdSql.checkData(2, 1, "false") + tdSql.checkData(5, 0, 1) + tdSql.checkData(5, 1, 11) + tdSql.checkData(7, 0, 2) + tdSql.checkData(7, 1, '"femail"') + + # test stddev with group by json tag + tdSql.query("select stddev(dataint) from jsons1 group by jtag->'tag1'") + tdSql.checkData(0, 0, 10) + tdSql.checkData(0, 1, None) + tdSql.checkData(1, 0, 0) + tdSql.checkData(1, 1, "null") + tdSql.checkData(7, 0, 11) + tdSql.checkData(7, 1, '"femail"') + + res = tdSql.getColNameList("select stddev(dataint) from jsons1 group by jsons1.jtag->'tag1'") + cname_list = [] + cname_list.append("stddev(dataint)") + cname_list.append("jsons1.jtag->'tag1'") + tdSql.checkColNameList(res, cname_list) + + # test top/bottom with group by json tag + tdSql.query("select top(dataint,100) from jsons1 group by jtag->'tag1'") + tdSql.checkRows(11) + tdSql.checkData(0, 1, 4) + tdSql.checkData(1, 1, 24) + tdSql.checkData(1, 2, None) + tdSql.checkData(10, 1, 1) + tdSql.checkData(10, 2, '"femail"') + + # test having + tdSql.query("select stddev(dataint) from jsons1 group by jtag->'tag1' having stddev(dataint) > 0") + tdSql.checkRows(2) + + # subquery with json tag + tdSql.query("select * from (select jtag, dataint from jsons1)") + tdSql.checkRows(11) + tdSql.checkData(1, 1, 1) + tdSql.checkData(2, 0, '{"tag1":5,"tag2":"beijing"}') + + tdSql.query("select jtag->'tag1' from (select jtag->'tag1', dataint from jsons1)") + tdSql.checkRows(11) + tdSql.checkData(0, 0, '"femail"') + tdSql.checkData(2, 0, 5) + + res = tdSql.getColNameList("select jtag->'tag1' from (select jtag->'tag1', dataint from jsons1)") + cname_list = [] + cname_list.append("jtag->'tag1'") + tdSql.checkColNameList(res, cname_list) + + tdSql.query("select ts,tbname,jtag->'tag1' from (select jtag->'tag1',tbname,ts from jsons1 order by ts)") + tdSql.checkRows(11) + tdSql.checkData(1, 1, "jsons1_1") + tdSql.checkData(1, 2, '"femail"') + + # union all + tdSql.error("select jtag->'tag1' from jsons1 union all select jtag->'tag2' from jsons2") + tdSql.error("select jtag->'tag1' from jsons1_1 union all select jtag->'tag2' from jsons2_1") + + tdSql.query("select jtag->'tag1' from jsons1_1 union all select jtag->'tag1' from jsons2_1") + tdSql.checkRows(2) + tdSql.query("select dataint,jtag->'tag1',tbname from jsons1 union all select dataint,jtag->'tag1',tbname from jsons2") + tdSql.checkRows(13) + tdSql.query("select dataint,jtag,tbname from jsons1 union all select dataint,jtag,tbname from jsons2") + tdSql.checkRows(13) + + #show create table + tdSql.query("show create table jsons1") + tdSql.checkData(0, 1, 'create table `jsons1` (`ts` TIMESTAMP,`dataint` INT,`databool` BOOL,`datastr` NCHAR(50),`datastrbin` BINARY(150)) TAGS (`jtag` JSON)') + + #test aggregate function:count/avg/twa/irate/sum/stddev/leastsquares + tdSql.query("select count(*) from jsons1 where jtag is not null") + tdSql.checkData(0, 0, 10) + tdSql.query("select avg(dataint) from jsons1 where jtag is not null") + tdSql.checkData(0, 0, 5.3) + tdSql.error("select twa(dataint) from jsons1 where jtag is not null") + tdSql.error("select irate(dataint) from jsons1 where jtag is not null") + tdSql.query("select sum(dataint) from jsons1 where jtag->'tag1' is not null") + tdSql.checkData(0, 0, 49) + tdSql.query("select stddev(dataint) from jsons1 where jtag->'tag1'>1") + tdSql.checkData(0, 0, 4.496912521) + tdSql.error("SELECT LEASTSQUARES(dataint, 1, 1) from jsons1 where jtag is not null") + + #test selection function:min/max/first/last/top/bottom/percentile/apercentile/last_row/interp + tdSql.query("select min(dataint) from jsons1 where jtag->'tag1'>1") + tdSql.checkData(0, 0, 1) + tdSql.query("select max(dataint) from jsons1 where jtag->'tag1'>1") + tdSql.checkData(0, 0, 11) + tdSql.query("select first(dataint) from jsons1 where jtag->'tag1'>1") + tdSql.checkData(0, 0, 2) + tdSql.query("select last(dataint) from jsons1 where jtag->'tag1'>1") + tdSql.checkData(0, 0, 11) + tdSql.query("select top(dataint,100) from jsons1 where jtag->'tag1'>1") + tdSql.checkRows(3) + tdSql.query("select bottom(dataint,100) from jsons1 where jtag->'tag1'>1") + tdSql.checkRows(3) + tdSql.error("select percentile(dataint,20) from jsons1 where jtag->'tag1'>1") + tdSql.query("select apercentile(dataint, 50) from jsons1 where jtag->'tag1'>1") + tdSql.checkData(0, 0, 1.5) + tdSql.query("select last_row(dataint) from jsons1 where jtag->'tag1'>1") + tdSql.checkData(0, 0, 11) + tdSql.error("select interp(dataint) from jsons1 where ts = '2020-06-02 09:17:08.000' and jtag->'tag1'>1") + + #test calculation function:diff/derivative/spread/ceil/floor/round/ + tdSql.error("select diff(dataint) from jsons1 where jtag->'tag1'>1") + tdSql.error("select derivative(dataint, 10m, 0) from jsons1 where jtag->'tag1'>1") + tdSql.query("select spread(dataint) from jsons1 where jtag->'tag1'>1") + tdSql.checkData(0, 0, 10) + tdSql.query("select ceil(dataint) from jsons1 where jtag->'tag1'>1") + tdSql.checkRows(3) + tdSql.query("select floor(dataint) from jsons1 where jtag->'tag1'>1") + tdSql.checkRows(3) + tdSql.query("select round(dataint) from jsons1 where jtag->'tag1'>1") + tdSql.checkRows(3) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) + diff --git a/tests/develop-test/1-insert/0-sql/basic.py b/tests/develop-test/1-insert/0-sql/basic.py index a123db1855bf4f470abfb3b176316f843e06c119..273ff8ba488db609cfa4aa5978c689288d14750b 100644 --- a/tests/develop-test/1-insert/0-sql/basic.py +++ b/tests/develop-test/1-insert/0-sql/basic.py @@ -20,9 +20,9 @@ from util.sql import * class TDTestCase: def caseDescription(self): ''' - case1: insert 倒序插入 - case2: 语法解析错误同时meta请求也发出去了导致callback中处理逻辑失效 - case3: [TD-XXXX]insert语句在values之间加入多个逗号 + case1: insert 倒序插入 + case2: 语法解析错误同时meta请求也发出去了导致callback中处理逻辑失效 + case3: [TD-XXXX]insert语句在values之间加入多个逗号 ''' return diff --git a/tests/develop-test/fulltest.sh b/tests/develop-test/fulltest.sh index e71a25659b1e5a2eed92e615f63eb18ace64de92..5c3b225f3fa1e24a098bcfafb19981c58115c337 100755 --- a/tests/develop-test/fulltest.sh +++ b/tests/develop-test/fulltest.sh @@ -1 +1,2 @@ -python3 test.py -f 1-insert/0-sql/basic.py \ No newline at end of file +python3 test.py -f 0-management/3-tag/json_tag.py +python3 test.py -f 1-insert/0-sql/basic.py diff --git a/tests/get_catalog.py b/tests/get_catalog.py index e1449ed78dcbc24bb66f0339862f9c50e6a5d749..2a8a290c1966b278c1c84d52e15407428578fc1d 100644 --- a/tests/get_catalog.py +++ b/tests/get_catalog.py @@ -17,8 +17,11 @@ import sys import getopt import os from fabric2 import Connection + sys.path.append("pytest") import importlib +import re + class CatalogGen: def __init__(self, CaseDirList, CatalogName, DirDepth): @@ -31,7 +34,7 @@ class CatalogGen: for i in self.CaseDirList: self.GetCatalog(i) self.CollectLog(i) - print('Catalog Generation done') + print("Catalog Generation done") def CollectLog(self, CaseDir): DirorFiles = os.listdir(CaseDir) @@ -43,12 +46,14 @@ class CatalogGen: else: if i == self.CatalogName and fileName not in self.blacklist: self.blacklist.append(fileName) - with open(fileName, "r") as f : + with open(fileName, "r") as f: Catalog = f.read() title = CaseDir.split("/")[-1] TitleLevel = CaseDir.count("/") - with open(os.path.dirname(CaseDir) + '/' + self.CatalogName, "a") as f : - f.write("#" * TitleLevel + ' %s\n' % title) + with open( + os.path.dirname(CaseDir) + "/" + self.CatalogName, "a" + ) as f: + f.write("#" * TitleLevel + " %s\n" % title) f.write(Catalog) def GetCatalog(self, CaseDir): @@ -58,16 +63,20 @@ class CatalogGen: fileName = os.path.join(root, file) moduleName = fileName.replace(".py", "").replace("/", ".") uModule = importlib.import_module(moduleName) - title = file.split('.')[0] - TitleLevel = root.count('/') + 1 + title = file.split(".")[0] + TitleLevel = root.count("/") + 1 try: ucase = uModule.TDTestCase() - with open(root + '/' + self.CatalogName, 'a') as f: - f.write('#'*TitleLevel + ' %s\n' % title) - for i in ucase.caseDescription.__doc__.split('\n'): - if i.lstrip() == '':continue - f.write('* ' + i.strip()+'\n') - except : + with open(root + "/" + self.CatalogName, "a") as f: + f.write("#" * TitleLevel + " %s\n" % title) + for i in ucase.caseDescription.__doc__.split("\n"): + if i.lstrip() == "": + continue + if re.match("^case.*:", i.strip()): + f.write("* " + i.strip() + "\n") + else: + f.write(i.strip() + "\n") + except: print(fileName) def CleanCatalog(self): @@ -75,57 +84,61 @@ class CatalogGen: for root, dirs, files in os.walk(i): for file in files: if file == self.CatalogName: - os.remove(root + '/' + self.CatalogName) - print('clean is done') + os.remove(root + "/" + self.CatalogName) + print("clean is done") + if __name__ == "__main__": CaseDirList = [] - CatalogName = '' + CatalogName = "" DirDepth = 0 generate = True delete = True - opts, args = getopt.gnu_getopt(sys.argv[1:], 'd:c:v:n:th') + opts, args = getopt.gnu_getopt(sys.argv[1:], "d:c:v:n:th") for key, value in opts: - if key in ['-h', '--help']: + if key in ["-h", "--help"]: + print("A collection of test cases catalog written using Python") print( - 'A collection of test cases catalog written using Python') - print("-d root dir of test case files written by Python, default: system-test,develop-test") - print('-c catalog file name, default: catalog.md') - print('-v dir depth of test cases.default: 5') - print('-n generate') - print('-r delete') + "-d root dir of test case files written by Python, default: system-test,develop-test" + ) + print("-c catalog file name, default: catalog.md") + print("-v dir depth of test cases.default: 5") + print("-n generate") + print("-r delete") sys.exit(0) - if key in ['-d']: - CaseDirList = value.split(',') + if key in ["-d"]: + CaseDirList = value.split(",") - if key in ['-c']: + if key in ["-c"]: CatalogName = value - if key in ['-v']: + if key in ["-v"]: DirDepth = int(value) - if key in ['-n']: - if (value.upper() == "TRUE"): + if key in ["-n"]: + if value.upper() == "TRUE": generate = True - elif (value.upper() == "FALSE"): + elif value.upper() == "FALSE": generate = False - if key in ['-r']: - if (value.upper() == "TRUE"): + if key in ["-r"]: + if value.upper() == "TRUE": delete = True - elif (value.upper() == "FALSE"): + elif value.upper() == "FALSE": delete = False print(CaseDirList, CatalogName) - if CaseDirList == [] : - CaseDirList = ['system-test', 'develop-test'] - if CatalogName == '' : - CatalogName = 'catalog.md' + if CaseDirList == []: + CaseDirList = ["system-test", "develop-test"] + if CatalogName == "": + CatalogName = "catalog.md" if DirDepth == 0: DirDepth = 5 - print('opt:\n\tcatalogname: %s\n\tcasedirlist: %s\n\tdepth: %d\n\tgenerate: %s\n\tdelete: %s' - % (CatalogName, ','.join(CaseDirList), DirDepth, generate, delete)) + print( + "opt:\n\tcatalogname: %s\n\tcasedirlist: %s\n\tdepth: %d\n\tgenerate: %s\n\tdelete: %s" + % (CatalogName, ",".join(CaseDirList), DirDepth, generate, delete) + ) f = CatalogGen(CaseDirList, CatalogName, DirDepth) if delete: f.CleanCatalog() 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_derivative.py b/tests/pytest/functions/function_derivative.py index 3b79726ed80c206338392cecb8f3d2adf4588e2a..a2a458ea290b13ed462d8dcd47a8af16e3af0f82 100644 --- a/tests/pytest/functions/function_derivative.py +++ b/tests/pytest/functions/function_derivative.py @@ -29,7 +29,6 @@ class TDTestCase: def insertAndCheckData(self): types = ["tinyint", "tinyint unsigned", "smallint", "smallint unsigned", "int", "int unsigned", "bigint", "bigint unsigned", "float", "double", "bool", "binary(20)", "nchar(20)"] - for type in types: print("============== create table using %s type ================" % type) tdSql.execute("drop table if exists stb") 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_interp.py b/tests/pytest/functions/function_interp.py index b3cf42fd275c07745109cf37eb9e1712b67ba7a9..e45983427d64a801fc866058a6468414d62b81c5 100644 --- a/tests/pytest/functions/function_interp.py +++ b/tests/pytest/functions/function_interp.py @@ -8360,6 +8360,45 @@ class TDTestCase: sql += "where ts >= '%s' AND ts <= '%s' range('%s' , '%s') EVERY(1s) FILL(NULL);" % (self.ts , self.ts + 10000 , self.ts + 150000 , self.ts + 200000) datacheck = tdSql.error(sql) + # TD-10736 Exception use case for coredump + + tdSql.execute("create database db_except;") + tdSql.execute("use db_except;") + tdSql.execute("create table tb (ts timestamp, c1 int);") + tdSql.execute("insert into tb values ('2021-10-01 08:00:00.000' ,1);") + tdSql.execute("insert into tb values ('2021-10-01 08:00:01.000' ,2);") + tdSql.execute("insert into tb values ('2021-10-01 08:00:02.000' ,3);") + tdSql.execute("insert into tb values ('2021-10-01 08:00:03.000' ,4);") + + tdSql.execute("create stable stb (ts timestamp, c1 int) tags (id int);") + tdSql.execute("insert into sub_1 using stb tags (1) values ('2021-10-01 08:00:00.000' ,1);") + tdSql.execute("insert into sub_1 using stb tags (1) values ('2021-10-01 08:00:01.000' ,2);") + + tdSql.execute("insert into sub_2 using stb tags (1) values ('2021-10-01 08:00:00.000' ,3);") + tdSql.execute("insert into sub_2 using stb tags (1) values ('2021-10-01 08:00:01.000' ,4);") + + tdSql.execute("insert into sub_3 using stb tags (1) values ('2021-10-01 08:00:01.000' ,1);") + tdSql.execute("insert into sub_3 using stb tags (1) values ('2021-10-01 08:00:02.000' ,2);") + tdSql.execute("insert into sub_3 using stb tags (1) values ('2021-10-01 08:00:03.000' ,3);") + tdSql.execute("insert into sub_3 using stb tags (1) values ('2021-10-01 08:00:04.000' ,4);") + + tdSql.query("select interp(c1) from tb where ts = '2021-10-01 08:00:00.000' every(1s); ") + tdSql.checkData(0,1,1) + tdSql.query("select interp(c1) from tb where ts = '2021-10-01 08:00:98.000' every(1s); ") + tdSql.checkRows(0) + + tdSql.query("select interp(c1) from sub_1 where ts = '2021-10-01 08:00:00.000' every(1s); ") + tdSql.checkData(0,1,1) + tdSql.query("select interp(c1) from sub_1 where ts = '2021-10-01 08:00:98.000' every(1s); ") + tdSql.checkRows(0) + + tdSql.error("select interp(c1) from stb where ts = '2021-10-01 08:00:00.000' every(1s); ") + tdSql.error("select interp(c1) from stb where ts = '2021-10-01 08:00:98.000' every(1s); ") + tdSql.query("select interp(c1) from stb where ts = '2021-10-01 08:00:00.000' every(1s) group by tbname; ") + tdSql.checkRows(2) + tdSql.query("select interp(c1) from stb where ts = '2021-10-01 08:00:98.000' every(1s) group by tbname; ") + tdSql.checkRows(0) + # Nested Query + where + range + FILL(NULL) + EVERY( s)(3) # sql = "select * from (select %s from stable_1 where ts BETWEEN '%s' AND '%s' range('%s' , '%s') EVERY(1s) FILL(NULL) group by tbname) z1," % (interp_select , self.ts , self.ts + 10000 , self.ts - 10000 , self.ts + 100000) # sql += "(select %s from stable_2 where ts BETWEEN '%s' AND '%s' range('%s' , '%s') EVERY(1s) FILL(NULL) group by tbname) z2 where z1.ts=z2.ts ;" % (interp_select , self.ts , self.ts + 10000 , self.ts - 10000 , self.ts + 100000) 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/stable/json_tag.rawsql b/tests/pytest/stable/json_tag.rawsql new file mode 100644 index 0000000000000000000000000000000000000000..222a3b784fa1a81d10e2197e2224ec5f9d209b94 --- /dev/null +++ b/tests/pytest/stable/json_tag.rawsql @@ -0,0 +1,163 @@ +create database db_json_tag_test; +drop table if exists db_json_tag_test.jsons1; +drop table if exists db_json_tag_test.jsons2; +drop table if exists db_json_tag_test.jsons3; +drop table if exists db_json_tag_test.jsons1_1; +drop table if exists db_json_tag_test.jsons1_2; +drop table if exists db_json_tag_test.jsons1_3; +drop table if exists db_json_tag_test.jsons1_4; +drop table if exists db_json_tag_test.jsons1_5; +drop table if exists db_json_tag_test.jsons1_6; +drop table if exists db_json_tag_test.jsons1_7; +drop table if exists db_json_tag_test.jsons1_8; +drop table if exists db_json_tag_test.jsons1_9; +drop table if exists db_json_tag_test.jsons1_10; +drop table if exists db_json_tag_test.jsons1_11; +drop table if exists db_json_tag_test.jsons1_12; +drop table if exists db_json_tag_test.jsons1_13; +drop table if exists db_json_tag_test.jsons1_20; +drop table if exists db_json_tag_test.jsons1_21; +drop table if exists db_json_tag_test.jsons1_22; +create table if not exists db_json_tag_test.jsons1(ts timestamp, dataInt int, dataBool bool, dataStr nchar(50)) tags(jtag json); +CREATE TABLE if not exists db_json_tag_test.jsons1_1 using db_json_tag_test.jsons1 tags('{"loc":"fff","id":5}'); +insert into db_json_tag_test.jsons1_2 using db_json_tag_test.jsons1 tags('{"num":5,"location":"beijing"}') values (now, 2, true, 'json2'); +insert into db_json_tag_test.jsons1_1 values(now, 1, false, 'json1'); +insert into db_json_tag_test.jsons1_3 using db_json_tag_test.jsons1 tags('{"num":34,"location":"beijing","level":"l1"}') values (now, 3, false 'json3'); +insert into db_json_tag_test.jsons1_4 using db_json_tag_test.jsons1 tags('{"class":55,"location":"shanghai","name":"name4"}') values (now, 4, true, 'json4'); + +ALTER TABLE db_json_tag_test.jsons1_1 SET TAG jtag='{"sex":"femail","age":35, "isKey":true}'; +select jtag from db_json_tag_test.jsons1_1; + +select * from db_json_tag_test.jsons1; + +select jtag->'location' from db_json_tag_test.jsons1_2; + +select jtag->'location' from db_json_tag_test.jsons1; + +select jtag from db_json_tag_test.jsons1_1; + +# test json string value +select * from db_json_tag_test.jsons1 where jtag->'location'='beijing'; + +select * from db_json_tag_test.jsons1 where jtag->'location'!='beijing'; + +select jtag->'num' from db_json_tag_test.jsons1 where jtag->'level'='l1'; + +select *,tbname from db_json_tag_test.jsons1 where jtag->'class'>5 and jtag->'class'<9; tdSql.checkRows(0) + +select *,tbname from db_json_tag_test.jsons1 where jtag->'class'>5 and jtag->'class'<92; + +select * from db_json_tag_test.jsons1 where jtag?'sex' or jtag?'num'; + +select * from db_json_tag_test.jsons1 where jtag?'sex' or jtag?'numww'; + +select * from db_json_tag_test.jsons1 where jtag?'sex' and jtag?'num'; + +select jtag->'sex' from db_json_tag_test.jsons1 where jtag?'sex' or jtag?'num'; + +select *,tbname from db_json_tag_test.jsons1 where jtag->'location'='beijing'; + +select *,tbname from db_json_tag_test.jsons1 where jtag->'num'=5 or jtag?'sex'; + +select * from db_json_tag_test.jsons1 where tbname = 'jsons1_1'; + +select * from db_json_tag_test.jsons1 where tbname = 'jsons1_1' or jtag?'num'; + +select * from db_json_tag_test.jsons1 where tbname = 'jsons1_1' and jtag?'num'; + +select * from db_json_tag_test.jsons1 where tbname = 'jsons1_1' or jtag->'num'=5; + +select *,tbname from db_json_tag_test.jsons1 where jtag->'location' like 'bei%'; + +select *,tbname from db_json_tag_test.jsons1 where jtag->'location' like 'bei%' and jtag->'location'='beijin'; + +select *,tbname from db_json_tag_test.jsons1 where jtag->'location' like 'bei%' or jtag->'location'='beijin'; + +select *,tbname from db_json_tag_test.jsons1 where jtag->'location' like 'bei%' and jtag->'num'=34; + +select *,tbname from db_json_tag_test.jsons1 where (jtag->'location' like 'bei%' or jtag->'num'=34) and jtag->'class'=55; + +select * from db_json_tag_test.jsons1 where jtag->'location' in ('beijing'); + +select * from db_json_tag_test.jsons1 where jtag->'num' in (5,34); + +select * from db_json_tag_test.jsons1 where jtag->'location' in ('shanghai') and jtag->'class'=55; + +select * from db_json_tag_test.jsons1 where jtag->'location' match 'jin$'; + +select * from db_json_tag_test.jsons1 where jtag->'location' match 'jin'; + +select * from db_json_tag_test.jsons1 where datastr match 'json' and jtag->'location' match 'jin'; + +CREATE TABLE if not exists db_json_tag_test.jsons1_5 using db_json_tag_test.jsons1 tags('\t'); +CREATE TABLE if not exists db_json_tag_test.jsons1_6 using db_json_tag_test.jsons1 tags(''); + +select jtag from db_json_tag_test.jsons1_6; + +CREATE TABLE if not exists db_json_tag_test.jsons1_7 using db_json_tag_test.jsons1 tags('{}'); +select jtag from db_json_tag_test.jsons1_7; + +CREATE TABLE if not exists db_json_tag_test.jsons1_8 using db_json_tag_test.jsons1 tags('null'); +select jtag from db_json_tag_test.jsons1_8; + +CREATE TABLE if not exists db_json_tag_test.jsons1_9 using db_json_tag_test.jsons1 tags('{"":4, "time":null}'); +select jtag from db_json_tag_test.jsons1_9; + +CREATE TABLE if not exists db_json_tag_test.jsons1_10 using db_json_tag_test.jsons1 tags('{"k1":"","k1":"v1","k2":true,"k3":false,"k4":55}'); +select jtag from db_json_tag_test.jsons1_10; + +select jtag->'k2' from db_json_tag_test.jsons1_10; + +select jtag from db_json_tag_test.jsons1 where jtag->'k1'=''; + +select jtag from db_json_tag_test.jsons1 where jtag->'k2'=true; + +select jtag from db_json_tag_test.jsons1 where jtag is null; + +select jtag from db_json_tag_test.jsons1 where jtag is not null; + +select * from db_json_tag_test.jsons1 where jtag->'location' is not null; + +select tbname,jtag from db_json_tag_test.jsons1 where jtag->'location' is null; + +select * from db_json_tag_test.jsons1 where jtag->'num' is not null; + +select * from db_json_tag_test.jsons1 where jtag->'location'='null'; + +select distinct jtag from db_json_tag_test.jsons1; + +select distinct jtag->'location' from db_json_tag_test.jsons1; + +CREATE TABLE if not exists db_json_tag_test.jsons1_11 using db_json_tag_test.jsons1 tags('{"k1":"中国","k5":"是是是"}'); + +select tbname,jtag from db_json_tag_test.jsons1 where jtag->'k1' match '中'; + +select tbname,jtag from db_json_tag_test.jsons1 where jtag->'k1'='中国'; + +INSERT INTO db_json_tag_test.jsons1_12 using db_json_tag_test.jsons1 tags('{"tbname":"tt","databool":true,"dataStr":"是是是"}') values(now, 4, false, "你就会;; + +select *,tbname,jtag from db_json_tag_test.jsons1 where jtag->'dataStr' match '是'; + +select tbname,jtag->'tbname' from db_json_tag_test.jsons1 where jtag->'tbname'='tt'; + +select *,tbname,jtag from db_json_tag_test.jsons1 where dataBool=true; + +CREATE TABLE if not exists db_json_tag_test.jsons1_13 using db_json_tag_test.jsons1 tags('{"1loc":"fff",";id":5}'); + +create table if not exists db_json_tag_test.jsons2(ts timestamp, dataInt int, dataBool bool, dataStr nchar(50)) tags(jtag json); +create table if not exists db_json_tag_test.jsons3(ts timestamp, dataInt int, dataBool bool, dataStr nchar(50)) tags(jtag json); +CREATE TABLE if not exists db_json_tag_test.jsons2_1 using db_json_tag_test.jsons2 tags('{"loc":"fff","id":5}'); +insert into db_json_tag_test.jsons3_1 using db_json_tag_test.jsons3 tags('{"loc":"fff","num":5,"location":"beijing"}') values ('2020-04-18 15:00:00.000', 2, true, 'json2'); +insert into db_json_tag_test.jsons2_1 values('2020-04-18 15:00:00.000', 1, false, 'json1'); +select 'sss',33,a.jtag->'loc' from db_json_tag_test.jsons2 a,db_json_tag_test.jsons3 b where a.ts=b.ts and a.jtag->'loc'=b.jtag->'loc'; + +select avg(dataint),count(*) from db_json_tag_test.jsons1 group by jtag->'location' order by jtag->'location' desc; +INSERT INTO db_json_tag_test.jsons1_20 using db_json_tag_test.jsons1 tags('{"tagint":1}') values(now, 1, false, "你就会;; +INSERT INTO db_json_tag_test.jsons1_21 using db_json_tag_test.jsons1 tags('{"tagint":11}') values(now, 11, false, "你就会;; +INSERT INTO db_json_tag_test.jsons1_22 using db_json_tag_test.jsons1 tags('{"tagint":2}') values(now, 2, false, "你就会;; +select avg(dataint),count(*) from db_json_tag_test.jsons1 group by jtag->'tagint' order by jtag->'tagint' desc; +select avg(dataint),count(*) from db_json_tag_test.jsons1 group by jtag->'tagint' order by jtag->'tagint'; +insert into db_json_tag_test.jsons1_9 values('2020-04-17 15:20:00.000', 5, false, 'json19'); +select * from db_json_tag_test.jsons1; +select * from db_json_tag_test.jsons1 where jtag->'time' is null; +select * from db_json_tag_test.jsons1 where jtag->'time'=null; \ No newline at end of file diff --git a/tests/pytest/stable/json_tag2.rawsql b/tests/pytest/stable/json_tag2.rawsql new file mode 100644 index 0000000000000000000000000000000000000000..6b1420b60d66930d53f3cf2c1fca1724820ab1fe --- /dev/null +++ b/tests/pytest/stable/json_tag2.rawsql @@ -0,0 +1,137 @@ +drop database db; +create database db; +use db; +create table if not exists jsons1(ts timestamp, dataInt int, dataBool bool, dataStr nchar(50), dataStrBin binary(150)) tags(jtag json) +insert into jsons1_1 using jsons1 tags('{\"tag1\":\"fff\",\"tag2\":5, \"tag3\":true}') values(1591060618000, 1, false, 'json1', '你是') (1591060608000, 23, true, '等等', 'json') +insert into jsons1_2 using jsons1 tags('{\"tag1\":5,\"tag2\":\"beijing\"}') values (1591060628000, 2, true, 'json2', 'sss') +insert into jsons1_3 using jsons1 tags('{\"tag1\":false,\"tag2\":\"beijing\"}') values (1591060668000, 3, false, 'json3', 'efwe') +insert into jsons1_4 using jsons1 tags('{\"tag1\":null,\"tag2\":\"shanghai\",\"tag3\":\"hello\"}') values (1591060728000, 4, true, 'json4', '323sd') +insert into jsons1_5 using jsons1 tags('{\"tag1\":1.232, \"tag2\":null}') values(1591060928000, 1, false, '你就会', 'ewe') +insert into jsons1_6 using jsons1 tags('{\"tag1\":11,\"tag2\":\"\",\"tag2\":null}') values(1591061628000, 11, false, '你就会','') +insert into jsons1_7 using jsons1 tags('{\"tag1\":\"收到货\",\"tag2\":\"\",\"tag3\":null}') values(1591062628000, 2, NULL, '你就会', 'dws') + +CREATE TABLE if not exists jsons1_8 using jsons1 tags('{\"tag1\":null, \"tag1\":true, \"tag1\":45, \"1tag$\":2, \" \":90}') + +insert into jsons1_9 using jsons1 tags('\t') values (1591062328000, 24, NULL, '你就会', '2sdw') +CREATE TABLE if not exists jsons1_10 using jsons1 tags('') +CREATE TABLE if not exists jsons1_11 using jsons1 tags(' ') +CREATE TABLE if not exists jsons1_12 using jsons1 tags('{}') +CREATE TABLE if not exists jsons1_13 using jsons1 tags('null') + +ALTER TABLE jsons1_1 SET TAG jtag='{\"tag1\":\"femail\",\"tag2\":35,\"tag3\":true}' + + +select dataint from jsons1 + +select * from jsons1 +select jtag from jsons1 +select jtag from jsons1 where jtag is null +select jtag from jsons1 where jtag is not null +select jtag from jsons1_8 +select jtag from jsons1_1 +select jtag from jsons1_9 +select jtag->'tag1' from jsons1_1 +select jtag->'tag2' from jsons1_6 +select jtag->'tag2' from jsons1_1 +select jtag->'tag3' from jsons1_1 +select jtag->'tag1' from jsons1_4 +select jtag->'tag1' from jsons1_5 +select jtag->'tag10' from jsons1_4 + +#select jtag->'tag1' from jsons1 +#select * from jsons1 where jtag->'tag2'='beijing' +#select dataint,tbname,jtag->'tag1',jtag from jsons1 where jtag->'tag2'='beijing' +select * from jsons1 where jtag->'tag1'='beijing' +select * from jsons1 where jtag->'tag1'='收到货' +select * from jsons1 where jtag->'tag2'>'beijing' +select * from jsons1 where jtag->'tag2'>='beijing' +select * from jsons1 where jtag->'tag2'<'beijing' +select * from jsons1 where jtag->'tag2'<='beijing' +select * from jsons1 where jtag->'tag2'!='beijing' +select * from jsons1 where jtag->'tag2'='' + +select * from jsons1 where jtag->'tag1'=5 +select * from jsons1 where jtag->'tag1'=10 +select * from jsons1 where jtag->'tag1'<54 +select * from jsons1 where jtag->'tag1'<=11 +select * from jsons1 where jtag->'tag1'>4 +select * from jsons1 where jtag->'tag1'>=5 +select * from jsons1 where jtag->'tag1'!=5 +select * from jsons1 where jtag->'tag1'!=55 + +select * from jsons1 where jtag->'tag1'=1.232 +select * from jsons1 where jtag->'tag1'<1.232 +select * from jsons1 where jtag->'tag1'<=1.232 +select * from jsons1 where jtag->'tag1'>1.23 +select * from jsons1 where jtag->'tag1'>=1.232 +select * from jsons1 where jtag->'tag1'!=1.232 +select * from jsons1 where jtag->'tag1'!=3.232 + +select * from jsons1 where jtag->'tag1'=true +select * from jsons1 where jtag->'tag1'=false +select * from jsons1 where jtag->'tag1'!=false +select * from jsons1 where jtag->'tag1'=null +select * from jsons1 where jtag is null +select * from jsons1 where jtag is not null + +select * from jsons1 where jtag->'tag_no_exist'=3 +select * from jsons1 where jtag->'tag1' is null +select * from jsons1 where jtag->'tag4' is null +select * from jsons1 where jtag->'tag3' is not null + +select * from jsons1 where jtag conatins 'tag1' +select * from jsons1 where jtag conatins 'tag3' +select * from jsons1 where jtag conatins 'tag_no_exist' + +select * from jsons1 where jtag->'tag1'=false and jtag->'tag2'='beijing' +select * from jsons1 where jtag->'tag1'=false or jtag->'tag2'='beijing' +select * from jsons1 where jtag->'tag1'=false and jtag->'tag2'='shanghai' +select * from jsons1 where jtag->'tag1'=false and jtag->'tag2'='shanghai' +select * from jsons1 where jtag->'tag1'=13 or jtag->'tag2'>35 +select * from jsons1 where jtag->'tag1'=13 or jtag->'tag2'>35 +select * from jsons1 where jtag->'tag1' is not null and jtag conatins 'tag3' +select * from jsons1 where jtag->'tag1'='femail' and jtag conatins 'tag3' +select * from jsons1 where tbname = 'jsons1_1' +select * from jsons1 where tbname = 'jsons1_1' and jtag conatins 'tag3' +select * from jsons1 where tbname = 'jsons1_1' and jtag conatins 'tag3' and dataint=3 +select * from jsons1 where tbname = 'jsons1_1' and jtag conatins 'tag3' and dataint=23 + +select *,tbname from jsons1 where jtag->'tag2' like 'bei%' +select *,tbname from jsons1 where jtag->'tag1' like 'fe%' and jtag->'tag2' is not null + +select * from jsons1 where jtag->'tag1' match 'ma' +select * from jsons1 where jtag->'tag1' match 'ma$' +select * from jsons1 where jtag->'tag2' match 'jing$' +select * from jsons1 where jtag->'tag1' match '收到' + +insert into jsons1_14 using jsons1 tags('{\"tag1\":\"收到货\",\"tag2\":\"\",\"tag3\":null}') values(1591062628000, 2, NULL, '你就会', 'dws') +select distinct jtag->'tag1' from jsons1 +select distinct jtag from jsons1 + +INSERT INTO jsons1_15 using jsons1 tags('{\"tbname\":\"tt\",\"databool\":true,\"datastr\":\"是是是\"}') values(1591060828000, 4, false, 'jjsf', \"你就会\") +select *,tbname,jtag from jsons1 where jtag->'datastr' match '是' and datastr match 'js' +select tbname,jtag->'tbname' from jsons1 where jtag->'tbname'='tt' and tbname='jsons1_14' + +create table if not exists jsons2(ts timestamp, dataInt int, dataBool bool, dataStr nchar(50), dataStrBin binary(150)) tags(jtag json) +insert into jsons2_1 using jsons2 tags('{\"tag1\":\"fff\",\"tag2\":5, \"tag3\":true}') values(1591060618000, 2, false, 'json2', '你是2') +insert into jsons2_2 using jsons2 tags('{\"tag1\":5,\"tag2\":null}') values (1591060628000, 2, true, 'json2', 'sss') + +create table if not exists jsons3(ts timestamp, dataInt int, dataBool bool, dataStr nchar(50), dataStrBin binary(150)) tags(jtag json) +insert into jsons3_1 using jsons3 tags('{\"tag1\":\"fff\",\"tag2\":5, \"tag3\":true}') values(1591060618000, 3, false, 'json3', '你是3') +insert into jsons3_2 using jsons3 tags('{\"tag1\":5,\"tag2\":\"beijing\"}') values (1591060638000, 2, true, 'json3', 'sss') +select 'sss',33,a.jtag->'tag3' from jsons2 a,jsons3 b where a.ts=b.ts and a.jtag->'tag1'=b.jtag->'tag1' + + +select count(*) from jsons1 group by jtag->'tag1' order by jtag->'tag1' desc + +select count(*) from jsons1 group by jtag->'tag1' order by jtag->'tag1' asc + +select stddev(dataint) from jsons1 group by jtag->'tag1' + +select top(dataint,100) from jsons1 group by jtag->'tag1' + +select * from (select jtag, dataint from jsons1) + +select jtag->'tag1' from (select jtag->'tag1', dataint from jsons1) + +select ts,tbname,jtag->'tag1' from (select jtag->'tag1',tbname,ts from jsons1 order by ts) 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/pytest/tag_lite/json_tag_extra.py b/tests/pytest/tag_lite/json_tag_extra.py deleted file mode 100644 index 40ee69d46b770a33a8255783f675d5071513bc28..0000000000000000000000000000000000000000 --- a/tests/pytest/tag_lite/json_tag_extra.py +++ /dev/null @@ -1,375 +0,0 @@ -################################################################### -# Copyright (c) 2016 by TAOS Technologies, Inc. -# All rights reserved. -# -# This file is proprietary and confidential to TAOS Technologies. -# No part of this file may be reproduced, db_test.stored, transmitted, -# disclosed or used in any form or by any means other than as -# expressly provided by the written permission from Jianhui Tao -# -################################################################### - -# -*- coding: utf-8 -*- - -import sys -import taos -from util.log import tdLog -from util.cases import tdCases -from util.sql import tdSql -import time -import random - -class TDTestCase: - - def init(self, conn, logSql): - tdLog.debug("start to execute %s" % __file__) - tdSql.init(conn.cursor(), logSql) - - def run(self): - tdSql.prepare() - - print("==============step1 tag format =======") - tdLog.info("create database two stables and ") - tdSql.execute("create database db_json_tag_test") - tdSql.execute("use db_json_tag_test") - # test tag format - tdSql.execute("create table if not exists jsons1(ts timestamp, dataInt int, dataStr nchar(50)) tags(jtag json(128))") - tdSql.error("create table if not exists jsons1(ts timestamp, dataInt int, dataStr nchar(50)) tags(jtag json(64),jtag1 json(100))") - tdSql.error("create table if not exists jsons1(ts timestamp, dataInt int, dataStr nchar(50)) tags(jtag json(64),dataBool bool)") - - tdSql.execute("CREATE TABLE if not exists jsons1_1 using jsons1 tags('{\"loc\":\"fff\",\"id\":5}')") - tdSql.execute("use db_json_tag_test") - - - # two stables: jsons1 jsons2 ,test tag's value and key - tdSql.execute("insert into jsons1_1(ts,dataInt) using jsons1 tags('{\"loc+\":\"fff\",\"id\":5}') values (now,12)") - - tdSql.error("CREATE TABLE if not exists jsons1_1 using jsons1 tags('{oc:\"fff\",\"id\":5}')") - tdSql.error("CREATE TABLE if not exists jsons1_1 using jsons1 tags('{\"loc\":fff,\"id\":5}')") - tdSql.error("CREATE TABLE if not exists jsons1_1 using jsons1 tags('3333')") - tdSql.error("CREATE TABLE if not exists jsons1_1 using jsons1 tags('{\"loc\":}')") - tdSql.error("CREATE TABLE if not exists jsons1_1 using jsons1 tags('{\"loc\":bool)") - tdSql.error("CREATE TABLE if not exists jsons1_1 using jsons1 tags(true)") - tdSql.error("CREATE TABLE if not exists jsons1_1 using jsons1 tags('[{\"num\":5}]')") - - # test object and key max length. max key length is 256, max object length is 4096 include abcd. - tdSql.execute("create table if not exists jsons4(ts timestamp, dataInt int, dataStr nchar(50)) tags(jtag json(128))") - - char1= ''.join(['abcd']*64) - char2=''.join(char1) - char3= ''.join(['abcd']*1022) - print(len(char3)) # 4088 - tdSql.execute("CREATE TABLE if not exists jsons4_1 using jsons4 tags('{\"%s\":5}')" % char1) # len(key)=256 - tdSql.error("CREATE TABLE if not exists jsons4_1 using jsons4 tags('{\"%s1\":5}')" % char2) # len(key)=257 - tdSql.execute("CREATE TABLE if not exists jsons4_2 using jsons4 tags('{\"T\":\"%s\"}')" % char3) # len(object)=4096 - tdSql.error("CREATE TABLE if not exists jsons4_2 using jsons4 tags('{\"TS\":\"%s\"}')" % char3) # len(object)=4097 - - tdSql.execute("insert into jsons1_1 values(now, 1, 'json1')") - tdSql.execute("insert into jsons1_1 values(now+1s, 1, 'json1')") - tdSql.execute("insert into jsons1_2 using jsons1 tags('{\"num\":5,\"location\":\"beijing\"}') values (now, 1, 'json2')") - tdSql.execute("insert into jsons1_3 using jsons1 tags('{\"num\":34,\"location\":\"beijing\",\"level\":\"l1\"}') values (now, 1, 'json3')") - tdSql.execute("insert into jsons1_4 using jsons1 tags('{\"class\":55,\"location\":\"beijing\",\"name\":\"name4\"}') values (now, 1, 'json4')") - - # test : json'vaule is null and - tdSql.execute("create table if not exists jsons2(ts timestamp, dataInt2 int, dataStr2 nchar(50)) tags(jtag2 json(300))") - tdSql.execute("CREATE TABLE if not exists jsons2_1 using jsons2 tags('{}')") - tdSql.query("select jtag2 from jsons2_1") - tdSql.checkData(0, 0, None) - tdSql.execute("CREATE TABLE if not exists jsons2_2 using jsons2 tags('')") - tdSql.query("select jtag2 from jsons2_2") - tdSql.checkData(0, 0, None) - tdSql.execute("CREATE TABLE if not exists jsons2_3 using jsons2 tags('null')") - tdSql.query("select jtag2 from jsons2_3") - tdSql.checkData(0, 0, None) - tdSql.execute("CREATE TABLE if not exists jsons2_4 using jsons2 tags('\t')") - tdSql.query("select jtag2 from jsons2_4") - tdSql.checkData(0, 0, None) - tdSql.execute("CREATE TABLE if not exists jsons2_5 using jsons2 tags(' ')") - tdSql.query("select jtag2 from jsons2_5") - tdSql.checkData(0, 0, None) - tdSql.execute("CREATE TABLE if not exists jsons2_6 using jsons2 tags('{\"nv\":null,\"tea\":true,\"\":false,\"\":123,\"tea\":false}')") - tdSql.query("select jtag2 from jsons2_6") - tdSql.checkData(0, 0, "{\"tea\":true}") - tdSql.error("CREATE TABLE if not exists jsons2_7 using jsons2 tags('{\"nv\":null,\"tea\":123,\"\":false,\"\":123,\"tea\":false}')") - tdSql.execute("CREATE TABLE if not exists jsons2_7 using jsons2 tags('{\"test7\":\"\"}')") - tdSql.query("select jtag2 from jsons2_7") - tdSql.checkData(0, 0, "{\"test7\":\"\"}") - - print("==============step2 alter json table==") - tdLog.info("alter stable add tag") - tdSql.error("ALTER STABLE jsons2 add tag jtag3 nchar(20)") - tdSql.error("ALTER STABLE jsons2 drop tag jtag2") - tdSql.execute("ALTER STABLE jsons2 change tag jtag2 jtag3") - tdSql.query("select jtag3 from jsons2_6") - tdSql.checkData(0, 0, "{\"tea\":true}") - tdSql.error("ALTER TABLE jsons2_6 SET TAG jtag3='{\"tea-=[].;!@#$%^&*()/\":}'") - tdSql.execute("ALTER TABLE jsons2_6 SET TAG jtag3='{\"tea-=[].;!@#$%^&*()/\":false}'") - tdSql.query("select jtag3 from jsons2_6") - tdSql.checkData(0, 0, "{\"tea-=[].;!@#$%^&*()/\":false}") - tdSql.execute("ALTER TABLE jsons1_1 SET TAG jtag='{\"sex\":\"femail\",\"age\":35}'") - tdSql.query("select jtag from jsons1_1") - tdSql.checkData(0, 0, "{\"sex\":\"femail\",\"age\":35}") - - - - print("==============step3") - tdLog.info("select table") - - tdSql.query("select jtag from jsons1_1") - tdSql.checkData(0, 0, "{\"sex\":\"femail\",\"age\":35}") - - tdSql.query("select jtag from jsons1 where jtag->'name'='name4'") - tdSql.checkData(0, 0, "{\"class\":55,\"location\":\"beijing\",\"name\":\"name4\"}") - - - tdSql.query("select * from jsons1") - tdSql.checkRows(6) - - tdSql.query("select * from jsons1_1") - tdSql.checkRows(3) - - tdSql.query("select * from jsons1 where jtag->'location'='beijing'") - tdSql.checkRows(3) - - tdSql.query("select jtag->'location' from jsons1_2") - tdSql.checkData(0, 0, "beijing") - - - tdSql.query("select jtag->'num' from jsons1 where jtag->'level'='l1'") - tdSql.checkData(0, 0, 34) - - tdSql.query("select jtag->'location' from jsons1") - tdSql.checkRows(4) - - tdSql.query("select jtag from jsons1_1") - tdSql.checkRows(1) - - tdSql.query("select * from jsons1 where jtag?'sex' or jtag?'num'") - tdSql.checkRows(5) - - tdSql.query("select * from jsons1 where jtag?'sex' and jtag?'num'") - tdSql.checkRows(0) - - tdSql.query("select jtag->'sex' from jsons1 where jtag?'sex' or jtag?'num'") - tdSql.checkData(0, 0, "femail") - tdSql.checkRows(3) - - tdSql.query("select *,tbname from jsons1 where jtag->'location'='beijing'") - tdSql.checkRows(3) - - tdSql.query("select *,tbname from jsons1 where jtag->'num'=5 or jtag?'sex'") - tdSql.checkRows(4) - - # test with tbname - tdSql.query("select * from jsons1 where tbname = 'jsons1_1'") - tdSql.checkRows(3) - - tdSql.query("select * from jsons1 where tbname = 'jsons1_1' or jtag?'num'") - tdSql.checkRows(5) - - tdSql.query("select * from jsons1 where tbname = 'jsons1_1' and jtag?'num'") - tdSql.checkRows(0) - - tdSql.query("select * from jsons1 where tbname = 'jsons1_1' or jtag->'num'=5") - tdSql.checkRows(4) - - # test where condition like - tdSql.query("select *,tbname from jsons1 where jtag->'location' like 'bei%'") - tdSql.checkRows(3) - - tdSql.query("select *,tbname from jsons1 where jtag->'location' like 'bei%' and jtag->'location'='beijin'") - tdSql.checkRows(0) - - tdSql.query("select *,tbname from jsons1 where jtag->'location' like 'bei%' or jtag->'location'='beijin'") - tdSql.checkRows(3) - - tdSql.query("select *,tbname from jsons1 where jtag->'location' like 'bei%' and jtag->'num'=34") - tdSql.checkRows(1) - - tdSql.query("select *,tbname from jsons1 where (jtag->'location' like 'shanghai%' or jtag->'num'=34) and jtag->'class'=55") - tdSql.checkRows(0) - - tdSql.error("select * from jsons1 where jtag->'num' like '5%'") - - # test where condition in - tdSql.query("select * from jsons1 where jtag->'location' in ('beijing')") - tdSql.checkRows(3) - - tdSql.query("select * from jsons1 where jtag->'num' in (5,34)") - tdSql.checkRows(2) - - tdSql.error("select * from jsons1 where jtag->'num' in ('5',34)") - - tdSql.query("select * from jsons1 where jtag->'location' in ('beijing') and jtag->'class'=55") - tdSql.checkRows(1) - - # test where condition match - tdSql.query("select * from jsons1 where jtag->'location' match 'jin$'") - tdSql.checkRows(0) - - tdSql.query("select * from jsons1 where jtag->'location' match 'jin'") - tdSql.checkRows(3) - - tdSql.query("select * from jsons1 where datastr match 'json' and jtag->'location' match 'jin'") - tdSql.checkRows(3) - - tdSql.error("select * from jsons1 where jtag->'num' match '5'") - - # test json string parse - tdSql.error("CREATE TABLE if not exists jsons1_5 using jsons1 tags('efwewf')") - tdSql.execute("CREATE TABLE if not exists jsons1_5 using jsons1 tags('\t')") - tdSql.execute("CREATE TABLE if not exists jsons1_6 using jsons1 tags('')") - - tdSql.query("select jtag from jsons1_6") - tdSql.checkData(0, 0, None) - - tdSql.execute("CREATE TABLE if not exists jsons1_7 using jsons1 tags('{}')") - tdSql.query("select jtag from jsons1_7") - tdSql.checkData(0, 0, None) - - tdSql.execute("CREATE TABLE if not exists jsons1_8 using jsons1 tags('null')") - tdSql.query("select jtag from jsons1_8") - tdSql.checkData(0, 0, None) - - tdSql.execute("CREATE TABLE if not exists jsons1_9 using jsons1 tags('{\"\":4, \"time\":null}')") - tdSql.query("select jtag from jsons1_9") - tdSql.checkData(0, 0, None) - - tdSql.execute("CREATE TABLE if not exists jsons1_10 using jsons1 tags('{\"k1\":\"\",\"k1\":\"v1\",\"k2\":true,\"k3\":false,\"k4\":55}')") - tdSql.query("select jtag from jsons1_10") - tdSql.checkData(0, 0, "{\"k1\":\"\",\"k2\":true,\"k3\":false,\"k4\":55}") - - tdSql.query("select jtag->'k2' from jsons1_10") - tdSql.checkData(0, 0, "true") - - tdSql.query("select jtag from jsons1 where jtag->'k1'=''") - tdSql.checkRows(1) - - tdSql.query("select jtag from jsons1 where jtag->'k2'=true") - tdSql.checkRows(1) - - tdSql.query("select jtag from jsons1 where jtag is null") - tdSql.checkRows(5) - - tdSql.query("select jtag from jsons1 where jtag is not null") - tdSql.checkRows(5) - - tdSql.query("select * from jsons1 where jtag->'location' is not null") - tdSql.checkRows(3) - - tdSql.query("select tbname,jtag from jsons1 where jtag->'location' is null") - tdSql.checkRows(7) - - tdSql.query("select * from jsons1 where jtag->'num' is not null") - tdSql.checkRows(2) - - tdSql.query("select * from jsons1 where jtag->'location'='null'") - tdSql.checkRows(0) - - tdSql.error("select * from jsons1 where jtag->'num'='null'") - - # test distinct - tdSql.query("select distinct jtag from jsons1") - tdSql.checkRows(6) - - tdSql.query("select distinct jtag->'location' from jsons1") - tdSql.checkRows(2) - - # test chinese - tdSql.execute("CREATE TABLE if not exists jsons1_11 using jsons1 tags('{\"k1\":\"中国\",\"k5\":\"是是是\"}')") - - tdSql.query("select tbname,jtag from jsons1 where jtag->'k1' match '中'") - tdSql.checkRows(1) - - tdSql.query("select tbname,jtag from jsons1 where jtag->'k1'='中国'") - tdSql.checkRows(1) - - #test dumplicate key with normal colomn - tdSql.execute("INSERT INTO jsons1_12 using jsons1 tags('{\"tbname\":\"tt\",\"databool\":true,\"dataStr\":\"是是是\"}') values(now, 4, \"你就会\")") - - tdSql.query("select *,tbname,jtag from jsons1 where jtag->'dataStr' match '是'") - tdSql.checkRows(1) - - tdSql.query("select tbname,jtag->'tbname' from jsons1 where jtag->'tbname'='tt'") - tdSql.checkRows(1) - - # tdSql.query("select * from jsons1 where jtag->'num' is not null or jtag?'class' and jtag?'databool'") - # tdSql.checkRows(0) - - # tdSql.query("select * from jsons1 where jtag->'num' is not null or jtag?'class' and jtag?'databool' and jtag->'k1' match '中' or jtag->'location' in ('beijing') and jtag->'location' like 'bei%'") - - # tdSql.query("select * from jsons1 where datastr like '你就会' and ( jtag->'num' is not null or jtag?'class' and jtag?'databool' )") - - - tdSql.error("select * from jsons1 where datastr like '你就会' or jtag->'num' is not null or jtag?'class' and jtag?'databool' and jtag->'k1' match '中' or jtag->'location' in ('beijing') and jtag->'location' like 'bei%' ") - - # tdSql.query("select * from jsons1 where datastr like '你就会' and (jtag->'num' is not null or jtag?'class' and jtag?'databool' and jtag->'k1' match '中' or jtag->'location' in ('beijing') and jtag->'location' like 'bei%' )") - # tdSql.checkRows(0) - - tdSql.error("select *,tbname,jtag from jsons1 where dataBool=true") - - # test error - tdSql.error("CREATE TABLE if not exists jsons1_13 using jsons1 tags(3333)") - tdSql.execute("CREATE TABLE if not exists jsons1_13 using jsons1 tags('{\"1loc\":\"fff\",\";id\":5}')") - tdSql.error("CREATE TABLE if not exists jsons1_13 using jsons1 tags('{\"。loc\":\"fff\",\"fsd\":5}')") - tdSql.error("CREATE TABLE if not exists jsons1_13 using jsons1 tags('{\"试试\":\"fff\",\";id\":5}')") - tdSql.error("insert into jsons1_13 using jsons1 tags(3)") - - # test query normal column - tdSql.execute("create stable if not exists jsons3(ts timestamp, dataInt3 int(100), dataBool3 bool, dataStr3 nchar(50)) tags(jtag3 json)") - tdSql.execute("create table jsons3_2 using jsons3 tags('{\"t\":true,\"t123\":123,\"\":\"true\"}')") - - tdSql.execute("create table jsons3_3 using jsons3 tags('{\"t\":true,\"t123\":456,\"k1\":true}')") - tdSql.execute("insert into jsons3_3 values(now, 4, true, 'test')") - - tdSql.execute("insert into jsons3_4 using jsons3 tags('{\"t\":true,\"t123\":789,\"k1\":false,\"s\":null}') values(now, 5, true, 'test')") - tdSql.query("select * from jsons3 where jtag3->'k1'=true") - tdSql.checkRows(1) - tdSql.error("select jtag3->k1 from jsons3 ") - tdSql.error("select jtag3 from jsons3 where jtag3->'k1'") - tdSql.error("select jtag3 from jsons3 where jtag3?'k1'=true") - tdSql.error("select jtag3?'k1' from jsons3;") - tdSql.error("select jtag3?'k1'=true from jsons3;") - tdSql.error("select jtag3->'k1'=true from jsons3;") - tdSql.error("insert into jsons3_5 using jsons3 tags('{\"t\":true,\"t123\":789,\"k1\":1,\"s\":null}') values(now, 5, true, 'test')") - tdSql.execute("insert into jsons3_5 using jsons3 tags('{\"t\":true,\"t123\":012,\"k1\":null,\"s\":null}') values(now, 5, true, 'test')") - tdSql.execute("insert into jsons3_6 using jsons3 tags('{\"t\":true,\"t123\":789,\"k1\":false,\"s\":null}') values(now, 5, true, 'test')") - # tdSql.execute("select distinct jtag3 from jsons3 where jtag3->'t123'=12 or jtag3?'k1'") - # tdSql.checkRows(3) - - - tdSql.execute("INSERT INTO jsons1_14 using jsons1 tags('{\"tbname\":\"tt\",\"location\":\"tianjing\",\"dataStr\":\"是是是\"}') values(now,5, \"你就会\")") - - # tdSql.execute("select ts,dataint3,jtag->tbname from jsons1 where dataint>=1 and jtag->'location' in ('tianjing','123') and jtag?'tbname'") - # tdSql.checkRows(1) - # tdSql.checkData(0, 2, 'tt') - - # query normal column and tag column - tdSql.query("select jtag3->'',dataint3 from jsons3") - tdSql.checkRows(4) - - # query child table - - tdSql.error("select * from jsons3_2 where jtag3->'k1'=true;") - - # tdSql.checkData(0, 0, None) - # tdSql.checkRows(3) - - - - # # test drop tables and databases - # tdSql.execute("drop table jsons1_1") - # tdSql.execute("drop stable jsons1") - # tdSql.execute("drop stable jsons3") - # tdSql.execute("drop stable jsons2") - # tdSql.execute("drop database db_json_tag_test") - - - - def stop(self): - tdSql.close() - tdLog.success("%s successfully executed" % __file__) - - -tdCases.addWindows(__file__, TDTestCase()) -tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/tools/taosdemoAllTest/TD-5213/insertSigcolumnsNum4096.json b/tests/pytest/tools/taosdemoAllTest/TD-5213/insertSigcolumnsNum4096.json index c9c4ae2c1b650da99853d6c82106b3f6ee80d0c0..d6e3afdea31955992cc0c9cc8842bc6ae7c6e3f6 100755 --- a/tests/pytest/tools/taosdemoAllTest/TD-5213/insertSigcolumnsNum4096.json +++ b/tests/pytest/tools/taosdemoAllTest/TD-5213/insertSigcolumnsNum4096.json @@ -15,7 +15,7 @@ "max_sql_len": 102400000, "databases": [{ "dbinfo": { - "name": "json", + "name": "json_test", "drop": "yes", "replica": 1, "days": 10, diff --git a/tests/pytest/tools/taosdemoAllTest/TD-5213/insertSigcolumnsNum4096.py b/tests/pytest/tools/taosdemoAllTest/TD-5213/insertSigcolumnsNum4096.py index ce3f6ca4c2be3210cc84e8b3f13683b0dd268fa4..56b51f5498aed0a540a86bf03625266ad3599b58 100755 --- a/tests/pytest/tools/taosdemoAllTest/TD-5213/insertSigcolumnsNum4096.py +++ b/tests/pytest/tools/taosdemoAllTest/TD-5213/insertSigcolumnsNum4096.py @@ -105,7 +105,7 @@ class TDTestCase: # insert: create one or mutiple tables per sql and insert multiple rows per sql # test case for https://jira.taosdata.com:18080/browse/TD-5213 os.system("%staosBenchmark -f tools/taosdemoAllTest/TD-5213/insertSigcolumnsNum4096.json -y " % binPath) - tdSql.execute("use json") + tdSql.execute("use json_test") tdSql.query("select count (tbname) from stb_old") tdSql.checkData(0, 0, 1) diff --git a/tests/pytest/util/dnodes.py b/tests/pytest/util/dnodes.py index 55c964c2557eff3204cf31bfb63cd5e3f3dd5501..254d5f166b408e4abe488bf41b33143a7b702b26 100644 --- a/tests/pytest/util/dnodes.py +++ b/tests/pytest/util/dnodes.py @@ -44,6 +44,7 @@ class TDSimClient: "jnidebugFlag": "135", "qdebugFlag": "135", "telemetryReporting": "0", + "enableCoreFile": "1", } def getLogDir(self): @@ -151,7 +152,8 @@ class TDDnode: "udebugFlag":"135", "jnidebugFlag":"135", "qdebugFlag":"135", - "maxSQLLength":"1048576" + "maxSQLLength":"1048576", + "enableCoreFile": "1", } def init(self, path): diff --git a/tests/script/api/stmt.c b/tests/script/api/stmt.c index f4fb9233a83f930a808eadf2135003d0e644c597..085263e06638417dd8035a7108f8b105bc521bfa 100644 --- a/tests/script/api/stmt.c +++ b/tests/script/api/stmt.c @@ -173,6 +173,44 @@ void taos_stmt_set_tbname_tags_test() { printf("finish taos_stmt_set_tbname_tags test\n"); } +void taos_stmt_set_tbname_tags_json_test() { + printf("start taos_stmt_set_tbname_tags_json_test test\n"); + TAOS_STMT *stmt = NULL; + char * name = calloc(1, 20); + TAOS_BIND *tags = calloc(1, sizeof(TAOS_BIND)); + // ASM ERROR + assert(taos_stmt_set_tbname_tags(stmt, name, tags) != 0); + void *taos = taos_connect("127.0.0.1", "root", "taosdata", NULL, 0); + if (taos == NULL) { + printf("Cannot connect to tdengine server\n"); + exit(EXIT_FAILURE); + } + execute_simple_sql(taos, "drop database if exists stmt_test_json"); + execute_simple_sql(taos, "create database stmt_test_json"); + execute_simple_sql(taos, "use stmt_test_json"); + execute_simple_sql(taos, "create stable super(ts timestamp, c1 int) tags (jtag json)"); + stmt = taos_stmt_init(taos); + assert(stmt != NULL); + char *stmt_sql = calloc(1, 1000); + sprintf(stmt_sql, "insert into ? using super tags (?) values (?,?)"); + assert(taos_stmt_prepare(stmt, stmt_sql, 0) == 0); + assert(taos_stmt_set_tbname_tags(stmt, name, tags) != 0); + sprintf(name, "tb"); + assert(taos_stmt_set_tbname_tags(stmt, name, tags) != 0); + tags->buffer_type = TSDB_DATA_TYPE_JSON; + tags->buffer = "{\\\"key1\\\":\\\"value1\\\",\\\"key2\\\":null,\\\"key3\\\":3,\\\"key4\\\":3.2}"; + tags->buffer_length = strlen(tags->buffer); + tags->length = &tags->buffer_length; + tags->is_null = NULL; + assert(taos_stmt_set_tbname_tags(stmt, name, tags) == 0); + free(stmt_sql); + free(name); + free(tags); + assert(taos_stmt_affected_rows(stmt) == 0); + taos_stmt_close(stmt); + printf("finish taos_stmt_set_tbname_tags_json_test test\n"); +} + void taos_stmt_set_sub_tbname_test() { printf("start taos_stmt_set_sub_tbname test\n"); TAOS_STMT *stmt = NULL; @@ -492,6 +530,76 @@ void taos_stmt_use_result_query(void *taos, char *col, int type) { free(stmt_sql); } +void taos_stmt_use_result_query_json(void *taos, char *col, int type) { + TAOS_STMT *stmt = taos_stmt_init(taos); + assert(stmt != NULL); + char *stmt_sql = calloc(1, 1024); + sprintf(stmt_sql, "select * from stmt_test_json.super where jtag->? = ?"); + printf("stmt_sql: %s\n", stmt_sql); + assert(taos_stmt_prepare(stmt, stmt_sql, 0) == 0); + + + struct { + int64_t long_value; + double double_value; + char nchar_value[32]; + } v = {0}; + v.long_value = 4; + v.double_value = 3.3; + strcpy(v.nchar_value, "一二三四五六七八"); + + TAOS_BIND params[2] = {0}; + +// char jsonTag[32] = "jtag"; +// params[0].buffer_type = TSDB_DATA_TYPE_NCHAR; +// params[0].buffer_length = strlen(jsonTag); +// params[0].buffer = &jsonTag; +// params[0].length = ¶ms[0].buffer_length; +// params[0].is_null = NULL; + + params[0].buffer_type = TSDB_DATA_TYPE_NCHAR; + params[0].buffer_length = strlen(col); + params[0].buffer = col; + params[0].length = ¶ms[0].buffer_length; + params[0].is_null = NULL; + + switch (type) { + case TSDB_DATA_TYPE_BIGINT: + params[1].buffer_type = type; + params[1].buffer_length = sizeof(v.long_value); + params[1].buffer = &v.long_value; + params[1].length = ¶ms[1].buffer_length; + params[1].is_null = NULL; + break; + case TSDB_DATA_TYPE_NCHAR: + params[1].buffer_type = type; + params[1].buffer_length = strlen(v.nchar_value); + params[1].buffer = &v.nchar_value; + params[1].length = ¶ms[1].buffer_length; + params[1].is_null = NULL; + break; + case TSDB_DATA_TYPE_DOUBLE: + params[1].buffer_type = type; + params[1].buffer_length = sizeof(v.double_value); + params[1].buffer = &v.double_value; + params[1].length = ¶ms[1].buffer_length; + params[1].is_null = NULL; + break; + default: + printf("Cannnot find type: %d\n", type); + break; + } + + assert(taos_stmt_bind_param(stmt, params) == 0); + assert(taos_stmt_execute(stmt) == 0); + TAOS_RES *result = taos_stmt_use_result(stmt); + assert(result != NULL); + print_result(result); + taos_free_result(result); + assert(taos_stmt_close(stmt) == 0); + free(stmt_sql); +} + void taos_stmt_use_result_test() { printf("start taos_stmt_use_result test\n"); void *taos = taos_connect("127.0.0.1", "root", "taosdata", NULL, 0); @@ -534,6 +642,47 @@ void taos_stmt_use_result_test() { printf("finish taos_stmt_use_result test\n"); } +void taos_stmt_use_result_json_test() { + printf("start taos_stmt_use_result_json_test test\n"); + void *taos = taos_connect("127.0.0.1", "root", "taosdata", NULL, 0); + if (taos == NULL) { + printf("Cannot connect to tdengine server\n"); + exit(EXIT_FAILURE); + } + execute_simple_sql(taos, "drop database if exists stmt_test_json"); + execute_simple_sql(taos, "create database stmt_test_json"); + execute_simple_sql(taos, "use stmt_test_json"); + execute_simple_sql( + taos, + "create table super(ts timestamp, c1 int) tags (jtag json)"); + execute_simple_sql(taos, + "create table t1 using super tags ('{\\\"key1\\\":\\\"一二三四五六七八\\\",\\\"key2\\\":null,\\\"key3\\\":3,\\\"key4\\\":3.1}')"); + execute_simple_sql( + taos, "insert into t1 values (1591060628000, 1)"); + execute_simple_sql( + taos, "insert into t1 values (1591060628001, 2)"); + + execute_simple_sql(taos, + "create table t2 using super tags ('{\\\"key1\\\":5,\\\"key2\\\":null,\\\"key3\\\":4,\\\"key4\\\":3.2}')"); + execute_simple_sql( + taos, "insert into t2 values (1591060628003, 21)"); + execute_simple_sql( + taos, "insert into t2 values (1591060628004, 22)"); + + execute_simple_sql(taos, + "create table t3 using super tags ('{\\\"key1\\\":\\\"一二\\\",\\\"key2\\\":null,\\\"key3\\\":null,\\\"key4\\\":3.3}')"); + execute_simple_sql( + taos, "insert into t3 values (1591060628005, 31)"); + execute_simple_sql( + taos, "insert into t3 values (1591060628006, 32)"); + + taos_stmt_use_result_query_json(taos, "key1", TSDB_DATA_TYPE_NCHAR); + taos_stmt_use_result_query_json(taos, "key3", TSDB_DATA_TYPE_BIGINT); + taos_stmt_use_result_query_json(taos, "key4", TSDB_DATA_TYPE_DOUBLE); + + printf("finish taos_stmt_use_result_json_test test\n"); +} + void taos_stmt_close_test() { printf("start taos_stmt_close test\n"); // ASM ERROR @@ -548,6 +697,7 @@ void test_api_reliability() { taos_stmt_preprare_test(); taos_stmt_set_tbname_test(); taos_stmt_set_tbname_tags_test(); + taos_stmt_set_tbname_tags_json_test(); taos_stmt_set_sub_tbname_test(); taos_stmt_bind_param_test(); taos_stmt_bind_single_param_batch_test(); @@ -557,7 +707,7 @@ void test_api_reliability() { taos_stmt_close_test(); } -void test_query() { taos_stmt_use_result_test(); } +void test_query() { taos_stmt_use_result_test(); taos_stmt_use_result_json_test(); } int main(int argc, char *argv[]) { test_api_reliability(); 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 diff --git a/tests/system-test/1-insert/0-sql/basic.py b/tests/system-test/1-insert/0-sql/basic.py index 23e93d6e05fe78959e58a0a44308e4e1b2dafd4b..3604224c512d4a9f85de30a9069136801d343503 100644 --- a/tests/system-test/1-insert/0-sql/basic.py +++ b/tests/system-test/1-insert/0-sql/basic.py @@ -20,9 +20,9 @@ from util.sql import * class TDTestCase: def caseDescription(self): ''' - case1: insert 倒序插入 - case2: 语法解析错误同时meta请求也发出去了导致callback中处理逻辑失效 - case3: [TD-XXXX]insert语句在values之间加入多个逗号 + case1: insert 倒序插入 + case2: 语法解析错误同时meta请求也发出去了导致callback中处理逻辑失效 + case3: [TD-XXXX]insert语句在values之间加入多个逗号 ''' return def init(self, conn, logSql): diff --git a/tests/system-test/2-query/9-others/TD-11389.py b/tests/system-test/2-query/9-others/TD-11389.py new file mode 100644 index 0000000000000000000000000000000000000000..a818ab42a7185d13278802141889d38f05c05a1f --- /dev/null +++ b/tests/system-test/2-query/9-others/TD-11389.py @@ -0,0 +1,93 @@ +################################################################### +# Copyright (c) 2020 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +from posixpath import split +import sys +import os + +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import * + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + self.ts = 1420041600000 # 2015-01-01 00:00:00 this is begin time for first record + self.num = 10 + + def getBuildPath(self): + selfPath = os.path.dirname(os.path.realpath(__file__)) + + if ("community" in selfPath): + projPath = selfPath[:selfPath.find("community")] + else: + projPath = selfPath[:selfPath.find("tests")] + + for root, dirs, files in os.walk(projPath): + if ("taosd" in files): + rootRealPath = os.path.dirname(os.path.realpath(root)) + if ("packaging" not in rootRealPath): + buildPath = root[:len(root) - len("/build/bin")] + break + return buildPath + + + def caseDescription(self): + + ''' + case1 : [TD-11389] : + this test case is an test case for cache error , it will let the cached data obtained by the client that has connected to taosd incorrect, + root cause : table schema is changed, tag hostname size is increased through schema-less insertion. The schema cache of client taos is not refreshed. + + ''' + return + + + def run(self): + tdSql.prepare() + tdSql.execute("create database if not exists testdb keep 36500;") + tdSql.execute("use testdb;") + tdSql.execute("create stable st (ts timestamp , id int , value double) tags(hostname binary(10) ,ind int);") + for i in range(self.num): + tdSql.execute("insert into sub_%s using st tags('host_%s' , %d) values (%d , %d , %f );"%(str(i),str(i),i*10,self.ts+10000*i,i*2,i+10.00)) + tdSql.query("select distinct(hostname) from st;") + tdSql.checkRows(10) + + binPath = self.getBuildPath() + "/build/bin/" + os.system( "taos -s ' ALTER STABLE testdb.st MODIFY TAG hostname binary(100); '" ) + os.system("taos -s ' insert into testdb.sub_test using testdb.st tags(\"host_10000000000000000000\" , 100) values (now , 100 , 100.0 ); '") + + + tdLog.info (" ===============The correct result should be 11 rows ,there is error query result ====================") + + os.system("taos -s ' select distinct(hostname) from testdb.st '") + + # this bug will occor at this connect ,it should get 11 rows ,but return 10 rows ,this error is caused by cache + + for i in range(10): + + tdSql.checkRows(11) # query 10 times every 10 second , test cache refresh + sleep(10) + + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) + + diff --git a/tests/system-test/fulltest.sh b/tests/system-test/fulltest.sh index 5040747d3ae4a21ec8fda32793bf06dae98e09e2..d2fea19cb537e4cc196b06998059bcbf328d09a8 100755 --- a/tests/system-test/fulltest.sh +++ b/tests/system-test/fulltest.sh @@ -1,2 +1,4 @@ python3 test.py -f 1-insert/0-sql/basic.py -python3 test.py -f 0-management/1-stable/create_col_tag.py \ No newline at end of file +python3 test.py -f 0-management/1-stable/create_col_tag.py + +#python3 test.py -f 2-query/9-others/TD-11389.py # this case will run when this bug fix TD-11389 \ No newline at end of file