提交 b1d649ba 编写于 作者: G Ganlin Zhao

[TD-11220]<feature>(query): time related functions

上级 57a2a323
......@@ -10126,6 +10126,10 @@ int32_t exprTreeFromSqlExpr(SSqlCmd* pCmd, tExprNode **pExpr, const tSqlExpr* pS
(*pExpr)->pVal = calloc(1, sizeof(tVariant));
tVariantAssign((*pExpr)->pVal, &pSqlExpr->value);
STableMetaInfo* pTableMetaInfo = tscGetMetaInfo(pQueryInfo, pQueryInfo->curTableIdx);
STableComInfo tinfo = tscGetTableInfo(pTableMetaInfo->pTableMeta);
(*pExpr)->precision = tinfo.precision;
STableMeta* pTableMeta = tscGetMetaInfo(pQueryInfo, pQueryInfo->curTableIdx)->pTableMeta;
if (pCols != NULL) {
size_t colSize = taosArrayGetSize(pCols);
......@@ -10288,6 +10292,11 @@ int32_t exprTreeFromSqlExpr(SSqlCmd* pCmd, tExprNode **pExpr, const tSqlExpr* pS
*pExpr = calloc(1, sizeof(tExprNode));
(*pExpr)->nodeType = TSQL_NODE_FUNC;
(*pExpr)->_func.functionId = pSqlExpr->functionId;
STableMetaInfo* pTableMetaInfo = tscGetMetaInfo(pQueryInfo, pQueryInfo->curTableIdx);
STableComInfo tinfo = tscGetTableInfo(pTableMetaInfo->pTableMeta);
(*pExpr)->precision = tinfo.precision;
SArray* paramList = pSqlExpr->Expr.paramList;
size_t paramSize = paramList ? taosArrayGetSize(paramList) : 0;
if (paramSize > 0) {
......@@ -10302,10 +10311,6 @@ int32_t exprTreeFromSqlExpr(SSqlCmd* pCmd, tExprNode **pExpr, const tSqlExpr* pS
return ret;
}
}
//set precision
STableMetaInfo* pTableMetaInfo = tscGetMetaInfo(pQueryInfo, pQueryInfo->curTableIdx);
STableComInfo tinfo = tscGetTableInfo(pTableMetaInfo->pTableMeta);
(*pExpr)->_func.precision = tinfo.precision;
} else {
// arithmetic expression on the results of aggregation functions
*pExpr = calloc(1, sizeof(tExprNode));
......
......@@ -135,13 +135,13 @@ typedef struct tExprNode {
int16_t functionId;
int32_t numChildren;
struct tExprNode **pChildren;
int32_t precision;
} _func;
TAOS_FIELD *pType;
};
int16_t resultType;
int16_t resultBytes;
int32_t precision;
} tExprNode;
typedef struct SExprTraverseSupp {
......
......@@ -114,6 +114,8 @@ _arithmetic_getVectorDoubleValue_fn_t getVectorDoubleValueFn(int32_t srcType) {
p = getVectorDoubleValue_FLOAT;
}else if(srcType==TSDB_DATA_TYPE_DOUBLE) {
p = getVectorDoubleValue_DOUBLE;
}else if(srcType==TSDB_DATA_TYPE_TIMESTAMP) {
p = getVectorDoubleValue_BIGINT;
}else {
assert(0);
}
......
......@@ -497,7 +497,11 @@ void exprTreeExprNodeTraverse(tExprNode *pExpr, int32_t numOfRows, tExprOperandI
OperatorFn(leftIn, leftNum, leftType, rightIn, rightNum, rightType, output->data, fnOrder);
output->numOfRows = MAX(leftNum, rightNum);
if(leftType == TSDB_DATA_TYPE_TIMESTAMP || rightType == TSDB_DATA_TYPE_TIMESTAMP) {
output->type = TSDB_DATA_TYPE_BIGINT;
} else {
output->type = TSDB_DATA_TYPE_DOUBLE;
}
output->bytes = tDataTypes[output->type].bytes;
tfree(ltmp);
......@@ -1197,7 +1201,7 @@ int32_t exprValidateTimeNode(tExprNode *pExpr) {
} else {
timeValMs = taosGetTimestampToday() * 1000;
}
child->pVal->i64 = convertTimePrecision(timeValMs, TSDB_TIME_PRECISION_MILLI, pExpr->_func.precision);
child->pVal->i64 = convertTimePrecision(timeValMs, TSDB_TIME_PRECISION_MILLI, pExpr->precision);
pExpr->resultType = TSDB_DATA_TYPE_TIMESTAMP;
pExpr->resultBytes = (int16_t)tDataTypes[pExpr->resultType].bytes;
break;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册