提交 91c750e2 编写于 作者: wmmhello's avatar wmmhello

TD-6129<feature> fix select * from json tag

上级 e27ae337
......@@ -847,13 +847,12 @@ int32_t tVariantDumpEx(tVariant *pVariant, char *payload, int16_t type, bool inc
break;
}
case TSDB_DATA_TYPE_BINARY:
case TSDB_DATA_TYPE_JSON_BINARY:{
case TSDB_DATA_TYPE_BINARY:{
if (!includeLengthPrefix) {
if (pVariant->nType == TSDB_DATA_TYPE_NULL) {
*(uint8_t*) payload = TSDB_DATA_BINARY_NULL;
} else {
if (pVariant->nType != TSDB_DATA_TYPE_BINARY && pVariant->nType != TSDB_DATA_TYPE_JSON_BINARY) {
if (pVariant->nType != TSDB_DATA_TYPE_BINARY) {
toBinary(pVariant, &payload, &pVariant->nLen);
} else {
strncpy(payload, pVariant->pz, pVariant->nLen);
......@@ -865,7 +864,7 @@ int32_t tVariantDumpEx(tVariant *pVariant, char *payload, int16_t type, bool inc
} else {
char *p = varDataVal(payload);
if (pVariant->nType != TSDB_DATA_TYPE_BINARY && pVariant->nType != TSDB_DATA_TYPE_JSON_BINARY) {
if (pVariant->nType != TSDB_DATA_TYPE_BINARY) {
toBinary(pVariant, &p, &pVariant->nLen);
} else {
strncpy(p, pVariant->pz, pVariant->nLen);
......@@ -885,14 +884,13 @@ int32_t tVariantDumpEx(tVariant *pVariant, char *payload, int16_t type, bool inc
}
break;
}
case TSDB_DATA_TYPE_NCHAR:
case TSDB_DATA_TYPE_JSON_NCHAR:{
case TSDB_DATA_TYPE_NCHAR:{
int32_t newlen = 0;
if (!includeLengthPrefix) {
if (pVariant->nType == TSDB_DATA_TYPE_NULL) {
*(uint32_t *)payload = TSDB_DATA_NCHAR_NULL;
} else {
if (pVariant->nType != TSDB_DATA_TYPE_NCHAR && pVariant->nType != TSDB_DATA_TYPE_JSON_NCHAR) {
if (pVariant->nType != TSDB_DATA_TYPE_NCHAR) {
if (toNchar(pVariant, &payload, &newlen) != 0) {
return -1;
}
......@@ -906,7 +904,7 @@ int32_t tVariantDumpEx(tVariant *pVariant, char *payload, int16_t type, bool inc
} else {
char *p = varDataVal(payload);
if (pVariant->nType != TSDB_DATA_TYPE_NCHAR && pVariant->nType != TSDB_DATA_TYPE_JSON_NCHAR) {
if (pVariant->nType != TSDB_DATA_TYPE_NCHAR) {
if (toNchar(pVariant, &p, &newlen) != 0) {
return -1;
}
......@@ -922,21 +920,19 @@ int32_t tVariantDumpEx(tVariant *pVariant, char *payload, int16_t type, bool inc
break;
}
// case TSDB_DATA_TYPE_JSON_BINARY:
// case TSDB_DATA_TYPE_JSON_NCHAR:{
// if (pVariant->nType == TSDB_DATA_TYPE_NULL) {
// *(int8_t *)payload = TSDB_DATA_TINYINT_NULL;
// } else if (pVariant->nType == TSDB_DATA_TYPE_BINARY){
// *((int8_t *)payload) = TSDB_DATA_BINARY_PLACEHOLDER;
// } else if (pVariant->nType == TSDB_DATA_TYPE_JSON_BINARY){ // select * from stable, set tag type to json,from setTagValue/tag_project_function
// memcpy(payload, pVariant->pz, pVariant->nLen);
// } else if(pVariant->nType == TSDB_DATA_TYPE_JSON_NCHAR){
// memcpy(payload, pVariant->wpz, pVariant->nLen);
// }else {
// return -1;
// }
// break;
// }
case TSDB_DATA_TYPE_JSON_BINARY:
case TSDB_DATA_TYPE_JSON_NCHAR:{
if (pVariant->nType == TSDB_DATA_TYPE_NULL) {
//*(int8_t *)payload = TSDB_DATA_TINYINT_NULL;
} else if (pVariant->nType == TSDB_DATA_TYPE_BINARY){
//*((int8_t *)payload) = TSDB_DATA_BINARY_PLACEHOLDER;
} else if (IS_JSON_DATA_TYPE(pVariant->nType)){ // 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;
......
......@@ -2740,11 +2740,8 @@ static void tag_project_function(SQLFunctionCtx *pCtx) {
assert(pCtx->inputBytes == pCtx->outputBytes);
if(IS_JSON_DATA_TYPE(pCtx->outputType)) {
tVariantDump(&pCtx->tag, pCtx->pOutput, pCtx->outputType, false);
}else {
tVariantDump(&pCtx->tag, pCtx->pOutput, pCtx->outputType, true);
}
char* data = pCtx->pOutput;
pCtx->pOutput += pCtx->outputBytes;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册