提交 0b54133a 编写于 作者: wmmhello's avatar wmmhello

append json field after inter field for [change json type with qid return logic]

上级 35801b0d
......@@ -80,6 +80,7 @@ typedef struct SInternalField {
TAOS_FIELD field;
bool visible;
SExprInfo *pExpr;
TAOS_FIELD fieldJson; // for tag json
} SInternalField;
typedef struct SParamInfo {
......
......@@ -2655,12 +2655,13 @@ static void updateFieldForJson(SSqlObj *pSql, SQueryTableRsp *pQueryAttr){
SInternalField *pField = tscFieldInfoGetInternalField(pFieldInfo, i);
if (pField->field.type == TSDB_DATA_TYPE_JSON) {
pField->fieldJson.type = TSDB_DATA_TYPE_JSON;
for (int k = 0; k < pQueryAttr->tJsonSchLen; ++k) {
if (strncmp(pField->field.name, pQueryAttr->tagJsonSchema[k].name, TSDB_MAX_JSON_KEY_LEN) == 0) {
pField->field.type = pQueryAttr->tagJsonSchema[k].type;
pField->field.bytes = TYPE_BYTES[pField->field.type];
pField->fieldJson.type = pQueryAttr->tagJsonSchema[k].type;
pField->fieldJson.bytes = TYPE_BYTES[pField->field.type];
tscDebug("0x%" PRIx64 " change json type %s:%s to %d", pSql->self, pField->field.name, pQueryAttr->tagJsonSchema[k].name,
pField->field.type);
pField->fieldJson.type);
break;
}
}
......
......@@ -439,6 +439,12 @@ TAOS_FIELD *taos_fetch_fields(TAOS_RES *res) {
if (pField->visible) {
f[j] = pField->field;
if(f[j].type == TSDB_DATA_TYPE_JSON){
f[j].type = pField->fieldJson.type;
if(!IS_VAR_DATA_TYPE(f[j].type) && f[j].type != TSDB_DATA_TYPE_JSON){
f[j].bytes = pField->fieldJson.bytes;
}
}
// revise the length for binary and nchar fields
if (f[j].type == TSDB_DATA_TYPE_BINARY) {
f[j].bytes -= VARSTR_HEADER_SIZE;
......
......@@ -2247,7 +2247,7 @@ SInternalField* tscFieldInfoAppend(SFieldInfo* pFieldInfo, TAOS_FIELD* pField) {
assert(pFieldInfo != NULL);
pFieldInfo->numOfOutput++;
struct SInternalField info = { .pExpr = NULL, .visible = true };
struct SInternalField info = { .pExpr = NULL, .visible = true, .fieldJson={0} };
info.field = *pField;
return taosArrayPush(pFieldInfo->internalField, &info);
......@@ -2255,7 +2255,7 @@ SInternalField* tscFieldInfoAppend(SFieldInfo* pFieldInfo, TAOS_FIELD* pField) {
SInternalField* tscFieldInfoInsert(SFieldInfo* pFieldInfo, int32_t index, TAOS_FIELD* field) {
pFieldInfo->numOfOutput++;
struct SInternalField info = { .pExpr = NULL, .visible = true };
struct SInternalField info = { .pExpr = NULL, .visible = true, .fieldJson={0}};
info.field = *field;
return taosArrayInsert(pFieldInfo->internalField, index, &info);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册