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