提交 78f30314 编写于 作者: Y yihaoDeng

[TD-3086]<feature> tag support timestamp

上级 5242a597
...@@ -1276,7 +1276,7 @@ static bool validateTagParams(SArray* pTagsList, SArray* pFieldList, SSqlCmd* pC ...@@ -1276,7 +1276,7 @@ static bool validateTagParams(SArray* pTagsList, SArray* pFieldList, SSqlCmd* pC
const char* msg1 = "invalid number of tag columns"; const char* msg1 = "invalid number of tag columns";
const char* msg2 = "tag length too long"; const char* msg2 = "tag length too long";
const char* msg3 = "duplicated column names"; const char* msg3 = "duplicated column names";
const char* msg4 = "timestamp not allowed in tags"; //const char* msg4 = "timestamp not allowed in tags";
const char* msg5 = "invalid data type in tags"; const char* msg5 = "invalid data type in tags";
const char* msg6 = "invalid tag name"; const char* msg6 = "invalid tag name";
const char* msg7 = "invalid binary/nchar tag length"; const char* msg7 = "invalid binary/nchar tag length";
...@@ -1292,10 +1292,10 @@ static bool validateTagParams(SArray* pTagsList, SArray* pFieldList, SSqlCmd* pC ...@@ -1292,10 +1292,10 @@ static bool validateTagParams(SArray* pTagsList, SArray* pFieldList, SSqlCmd* pC
for (int32_t i = 0; i < numOfTags; ++i) { for (int32_t i = 0; i < numOfTags; ++i) {
TAOS_FIELD* p = taosArrayGet(pTagsList, i); TAOS_FIELD* p = taosArrayGet(pTagsList, i);
if (p->type == TSDB_DATA_TYPE_TIMESTAMP) { //if (p->type == TSDB_DATA_TYPE_TIMESTAMP) {
invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg4); // invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg4);
return false; // return false;
} //}
if (!isValidDataType(p->type)) { if (!isValidDataType(p->type)) {
invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg5); invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg5);
...@@ -1353,7 +1353,7 @@ static bool validateTagParams(SArray* pTagsList, SArray* pFieldList, SSqlCmd* pC ...@@ -1353,7 +1353,7 @@ static bool validateTagParams(SArray* pTagsList, SArray* pFieldList, SSqlCmd* pC
* tags name /column name is truncated in sql.y * tags name /column name is truncated in sql.y
*/ */
bool validateOneTags(SSqlCmd* pCmd, TAOS_FIELD* pTagField) { bool validateOneTags(SSqlCmd* pCmd, TAOS_FIELD* pTagField) {
const char* msg1 = "timestamp not allowed in tags"; //const char* msg1 = "timestamp not allowed in tags";
const char* msg2 = "duplicated column names"; const char* msg2 = "duplicated column names";
const char* msg3 = "tag length too long"; const char* msg3 = "tag length too long";
const char* msg4 = "invalid tag name"; const char* msg4 = "invalid tag name";
...@@ -1376,10 +1376,10 @@ bool validateOneTags(SSqlCmd* pCmd, TAOS_FIELD* pTagField) { ...@@ -1376,10 +1376,10 @@ bool validateOneTags(SSqlCmd* pCmd, TAOS_FIELD* pTagField) {
} }
// no timestamp allowable // no timestamp allowable
if (pTagField->type == TSDB_DATA_TYPE_TIMESTAMP) { //if (pTagField->type == TSDB_DATA_TYPE_TIMESTAMP) {
invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg1); // invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg1);
return false; // return false;
} //}
if ((pTagField->type < TSDB_DATA_TYPE_BOOL) || (pTagField->type > TSDB_DATA_TYPE_UBIGINT)) { if ((pTagField->type < TSDB_DATA_TYPE_BOOL) || (pTagField->type > TSDB_DATA_TYPE_UBIGINT)) {
invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg6); invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg6);
...@@ -8001,8 +8001,24 @@ int32_t exprTreeFromSqlExpr(SSqlCmd* pCmd, tExprNode **pExpr, const tSqlExpr* pS ...@@ -8001,8 +8001,24 @@ int32_t exprTreeFromSqlExpr(SSqlCmd* pCmd, tExprNode **pExpr, const tSqlExpr* pS
*pExpr = calloc(1, sizeof(tExprNode)); *pExpr = calloc(1, sizeof(tExprNode));
(*pExpr)->nodeType = TSQL_NODE_VALUE; (*pExpr)->nodeType = TSQL_NODE_VALUE;
(*pExpr)->pVal = calloc(1, sizeof(tVariant)); (*pExpr)->pVal = calloc(1, sizeof(tVariant));
tVariantAssign((*pExpr)->pVal, &pSqlExpr->value); tVariantAssign((*pExpr)->pVal, &pSqlExpr->value);
int32_t type = -1;
STableMeta* pTableMeta = tscGetMetaInfo(pQueryInfo, 0)->pTableMeta;
if (pCols != NULL) {
SColIndex* idx = taosArrayGet(pCols, 0);
SSchema* pSchema = tscGetTableColumnSchema(pTableMeta, idx->colIndex);
if (pSchema != NULL) {
type = pSchema->type;
}
}
if (type == TSDB_DATA_TYPE_TIMESTAMP) {
int32_t ret = setColumnFilterInfoForTimestamp(pCmd, pQueryInfo, (*pExpr)->pVal);
if (ret != TSDB_CODE_SUCCESS) {
return ret;
}
}
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
} else if (pSqlExpr->type == SQL_NODE_SQLFUNCTION) { } else if (pSqlExpr->type == SQL_NODE_SQLFUNCTION) {
// arithmetic expression on the results of aggregation functions // arithmetic expression on the results of aggregation functions
......
...@@ -77,6 +77,10 @@ void tVariantCreate(tVariant *pVar, SStrToken *token) { ...@@ -77,6 +77,10 @@ void tVariantCreate(tVariant *pVar, SStrToken *token) {
pVar->nLen = strRmquote(pVar->pz, token->n); pVar->nLen = strRmquote(pVar->pz, token->n);
break; break;
} }
case TSDB_DATA_TYPE_TIMESTAMP: {
pVar->i64 = taosGetTimestamp(TSDB_TIME_PRECISION_NANO);
break;
}
default: { // nType == 0 means the null value default: { // nType == 0 means the null value
type = TSDB_DATA_TYPE_NULL; type = TSDB_DATA_TYPE_NULL;
......
...@@ -433,6 +433,7 @@ tagitem(A) ::= FLOAT(X). { toTSDBType(X.type); tVariantCreate(&A, &X); } ...@@ -433,6 +433,7 @@ tagitem(A) ::= FLOAT(X). { toTSDBType(X.type); tVariantCreate(&A, &X); }
tagitem(A) ::= STRING(X). { toTSDBType(X.type); tVariantCreate(&A, &X); } tagitem(A) ::= STRING(X). { toTSDBType(X.type); tVariantCreate(&A, &X); }
tagitem(A) ::= BOOL(X). { toTSDBType(X.type); tVariantCreate(&A, &X); } tagitem(A) ::= BOOL(X). { toTSDBType(X.type); tVariantCreate(&A, &X); }
tagitem(A) ::= NULL(X). { X.type = 0; tVariantCreate(&A, &X); } tagitem(A) ::= NULL(X). { X.type = 0; tVariantCreate(&A, &X); }
tagitem(A) ::= NOW(X). { X.type = TSDB_DATA_TYPE_TIMESTAMP; tVariantCreate(&A, &X);}
tagitem(A) ::= MINUS(X) INTEGER(Y).{ tagitem(A) ::= MINUS(X) INTEGER(Y).{
X.n += Y.n; X.n += Y.n;
......
...@@ -2889,7 +2889,9 @@ void setTagValue(SOperatorInfo* pOperatorInfo, void *pTable, SQLFunctionCtx* pCt ...@@ -2889,7 +2889,9 @@ void setTagValue(SOperatorInfo* pOperatorInfo, void *pTable, SQLFunctionCtx* pCt
doSetTagValueInParam(pTable, pLocalExprInfo->base.colInfo.colId, &pCtx[idx].tag, pLocalExprInfo->base.resType, doSetTagValueInParam(pTable, pLocalExprInfo->base.colInfo.colId, &pCtx[idx].tag, pLocalExprInfo->base.resType,
pLocalExprInfo->base.resBytes); pLocalExprInfo->base.resBytes);
if (IS_NUMERIC_TYPE(pLocalExprInfo->base.resType) || pLocalExprInfo->base.resType == TSDB_DATA_TYPE_BOOL) { if (IS_NUMERIC_TYPE(pLocalExprInfo->base.resType)
|| pLocalExprInfo->base.resType == TSDB_DATA_TYPE_BOOL
|| pLocalExprInfo->base.resType == TSDB_DATA_TYPE_TIMESTAMP) {
memcpy(pRuntimeEnv->tagVal + offset, &pCtx[idx].tag.i64, pLocalExprInfo->base.resBytes); memcpy(pRuntimeEnv->tagVal + offset, &pCtx[idx].tag.i64, pLocalExprInfo->base.resBytes);
} else { } else {
memcpy(pRuntimeEnv->tagVal + offset, pCtx[idx].tag.pz, pCtx[idx].tag.nLen); memcpy(pRuntimeEnv->tagVal + offset, pCtx[idx].tag.pz, pCtx[idx].tag.nLen);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册