提交 3acecbda 编写于 作者: wmmhello's avatar wmmhello

support join for json tag

上级 56a9115e
......@@ -4025,6 +4025,9 @@ static int32_t checkAndSetJoinCondInfo(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, tS
(*leftNode)->uid = pTableMetaInfo->pTableMeta->id.uid;
(*leftNode)->tagColId = pTagSchema1->colId;
if(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;
......@@ -4059,6 +4062,9 @@ static int32_t checkAndSetJoinCondInfo(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, tS
(*rightNode)->uid = pTableMetaInfo->pTableMeta->id.uid;
(*rightNode)->tagColId = pTagSchema2->colId;
if(pRight->tokenId == TK_ARROW) {
tstrncpy((*rightNode)->tagJsonKeyName, pRight->pLeft->pRight->value.pz, TSDB_MAX_JSON_KEY_LEN + 1);
}
if (UTIL_TABLE_IS_SUPER_TABLE(pTableMetaInfo)) {
STableMeta* pTableMeta = pTableMetaInfo->pTableMeta;
......@@ -4304,6 +4310,7 @@ static bool validateJoinExprNode(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, tSqlExpr
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){
......@@ -4311,6 +4318,10 @@ static bool validateJoinExprNode(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, tSqlExpr
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);
......
......@@ -1912,7 +1912,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(
......
......@@ -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;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册