From 6b2461ce2eff6b5120ca27f39ad5a4c4c3e6e789 Mon Sep 17 00:00:00 2001 From: shenglian zhou Date: Tue, 2 Nov 2021 15:01:28 +0800 Subject: [PATCH] rename functions --- src/client/src/tscSQLParser.c | 10 ++--- src/common/src/tarithoperator.c | 66 +++++++++++++++------------------ src/connector/grafanaplugin | 2 +- src/plugins/blm3 | 2 +- 4 files changed, 37 insertions(+), 43 deletions(-) diff --git a/src/client/src/tscSQLParser.c b/src/client/src/tscSQLParser.c index 4e6d6be3f9..78b4226138 100644 --- a/src/client/src/tscSQLParser.c +++ b/src/client/src/tscSQLParser.c @@ -1874,7 +1874,7 @@ static int32_t handleAggregateExpr(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, int32_ return TSDB_CODE_SUCCESS; } -static int32_t handleArithmeticExpr(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, int32_t exprIndex, tSqlExprItem* pItem) { +static int32_t handleSQLExprItem(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"; SColumnList columnList = {0}; @@ -2074,7 +2074,7 @@ int32_t validateSelectNodeList(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SArray* pS int32_t type = pItem->pNode->type; if (type == SQL_NODE_EXPR) { - int32_t code = handleArithmeticExpr(pCmd, pQueryInfo, i, pItem); + int32_t code = handleSQLExprItem(pCmd, pQueryInfo, i, pItem); if (code != TSDB_CODE_SUCCESS) { return code; } @@ -2103,7 +2103,7 @@ int32_t validateSelectNodeList(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SArray* pS } if (willProcessFunctionWithExpr(pItem)) { - int32_t code = handleArithmeticExpr(pCmd, pQueryInfo, i, pItem); + int32_t code = handleSQLExprItem(pCmd, pQueryInfo, i, pItem); if (code != TSDB_CODE_SUCCESS) { return code; } @@ -4331,7 +4331,7 @@ static int32_t getJoinCondInfo(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, tSqlExpr* return checkAndSetJoinCondInfo(pCmd, pQueryInfo, pExpr); } -static int32_t validateArithmeticSQLFunc(SSqlCmd* pCmd, tSqlExpr* pExpr, +static int32_t validateSQLExprSQLFunc(SSqlCmd* pCmd, tSqlExpr* pExpr, SQueryInfo* pQueryInfo, SColumnList* pList, int32_t* type, uint64_t *uid) { int32_t code = TSDB_CODE_SUCCESS; int32_t functionId = isValidFunction(pExpr->Expr.operand.z, pExpr->Expr.operand.n); @@ -4468,7 +4468,7 @@ static int32_t validateSQLExprItem(SSqlCmd* pCmd, tSqlExpr* pExpr, *uid = uidLeft; } else if (pExpr->type == SQL_NODE_SQLFUNCTION) { - int32_t ret = validateArithmeticSQLFunc(pCmd, pExpr, pQueryInfo, pList, type, uid); + int32_t ret = validateSQLExprSQLFunc(pCmd, pExpr, pQueryInfo, pList, type, uid); if (ret != TSDB_CODE_SUCCESS) { return ret; } diff --git a/src/common/src/tarithoperator.c b/src/common/src/tarithoperator.c index fe5088e99d..73fc40d928 100644 --- a/src/common/src/tarithoperator.c +++ b/src/common/src/tarithoperator.c @@ -414,51 +414,45 @@ _arithmetic_operator_fn_t getArithmeticOperatorFn(int32_t arithmeticOptr) { void vectorPow(tExprOperandInfo* pInputs, uint8_t numInputs, tExprOperandInfo* pOutput, int32_t order) { assert(numInputs == 2); - assert(pInputs[1].numOfRows == 1 || pInputs[0].numOfRows == 1 || pInputs[0].numOfRows == pInputs[1].numOfRows ); - int numOfRows = (pInputs[0].numOfRows > pInputs[1].numOfRows) ? pInputs[0].numOfRows : pInputs[1].numOfRows; - if (pInputs[1].numOfRows == 1) { - double base = 0; - GET_TYPED_DATA(base, double, pInputs[1].type, pInputs[1].data); + assert(pInputs[1].numOfRows == 1 && pInputs[0].numOfRows >= 1); + int numOfRows = pInputs[0].numOfRows; - for (int i = 0; i < numOfRows; ++i) { - char* pInputData = pInputs[0].data + i * pInputs[0].bytes; - char* pOutputData = pOutput->data + i * pOutput->bytes; - if (isNull(pInputData, pInputs[0].type)) { - setNull(pOutputData, pOutput->type, pOutput->bytes); - } else { - double v1 = 0; - GET_TYPED_DATA(v1, double, pInputs[0].type, pInputData); - double result = pow(v1, base); - SET_TYPED_DATA(pOutputData, pOutput->type, result); - } + double base = 0; + GET_TYPED_DATA(base, double, pInputs[1].type, pInputs[1].data); + + for (int i = 0; i < numOfRows; ++i) { + char* pInputData = pInputs[0].data + i * pInputs[0].bytes; + char* pOutputData = pOutput->data + i * pOutput->bytes; + if (isNull(pInputData, pInputs[0].type)) { + setNull(pOutputData, pOutput->type, pOutput->bytes); + } else { + double v1 = 0; + GET_TYPED_DATA(v1, double, pInputs[0].type, pInputData); + double result = pow(v1, base); + SET_TYPED_DATA(pOutputData, pOutput->type, result); } - } else { - assert(0); } } void vectorLog(tExprOperandInfo* pInputs, uint8_t numInputs, tExprOperandInfo* pOutput, int32_t order) { assert(numInputs == 2); - assert(pInputs[1].numOfRows == 1 || pInputs[0].numOfRows == 1 || pInputs[0].numOfRows == pInputs[1].numOfRows ); - int numOfRows = (pInputs[0].numOfRows > pInputs[1].numOfRows) ? pInputs[0].numOfRows : pInputs[1].numOfRows; - if (pInputs[1].numOfRows == 1) { - double base = 0; - GET_TYPED_DATA(base, double, pInputs[1].type, pInputs[1].data); + assert(pInputs[1].numOfRows == 1 && pInputs[0].numOfRows >= 1); + int numOfRows = pInputs[0].numOfRows; - for (int i = 0; i < numOfRows; ++i) { - char* pInputData = pInputs[0].data + i * pInputs[0].bytes; - char* pOutputData = pOutput->data + i * pOutput->bytes; - if (isNull(pInputData, pInputs[0].type)) { - setNull(pOutputData, pOutput->type, pOutput->bytes); - } else { - double v1 = 0; - GET_TYPED_DATA(v1, double, pInputs[0].type, pInputData); - double result = log(v1) / log(base); - SET_TYPED_DATA(pOutputData, pOutput->type, result); - } + double base = 0; + GET_TYPED_DATA(base, double, pInputs[1].type, pInputs[1].data); + + for (int i = 0; i < numOfRows; ++i) { + char* pInputData = pInputs[0].data + i * pInputs[0].bytes; + char* pOutputData = pOutput->data + i * pOutput->bytes; + if (isNull(pInputData, pInputs[0].type)) { + setNull(pOutputData, pOutput->type, pOutput->bytes); + } else { + double v1 = 0; + GET_TYPED_DATA(v1, double, pInputs[0].type, pInputData); + double result = log(v1) / log(base); + SET_TYPED_DATA(pOutputData, pOutput->type, result); } - } else { - assert(0); } } diff --git a/src/connector/grafanaplugin b/src/connector/grafanaplugin index 9ae793ad2d..edad746514 160000 --- a/src/connector/grafanaplugin +++ b/src/connector/grafanaplugin @@ -1 +1 @@ -Subproject commit 9ae793ad2d567eb11d10627b65698f612542e988 +Subproject commit edad746514b2a53a8cf6061c93b98b52a5388692 diff --git a/src/plugins/blm3 b/src/plugins/blm3 index ba539ce69d..f56aa0f485 160000 --- a/src/plugins/blm3 +++ b/src/plugins/blm3 @@ -1 +1 @@ -Subproject commit ba539ce69dc4fe53536e9b0517fe75917dce5c46 +Subproject commit f56aa0f485d7bb6aebbcefc2007eeecdccb767c8 -- GitLab