From 7ef4d3f03a1f6a034a66812b5cab9db0e44db5d4 Mon Sep 17 00:00:00 2001 From: dapan1121 Date: Thu, 30 Jun 2022 15:39:30 +0800 Subject: [PATCH 1/2] fix: fix null as tag value issue --- source/libs/parser/src/parTranslater.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/source/libs/parser/src/parTranslater.c b/source/libs/parser/src/parTranslater.c index 521c733ceb..6dc14dbf15 100644 --- a/source/libs/parser/src/parTranslater.c +++ b/source/libs/parser/src/parTranslater.c @@ -783,6 +783,12 @@ static EDealRes translateValueImpl(STranslateContext* pCxt, SValueNode* pVal, SD if (pVal->placeholderNo > 0 || pVal->isNull) { return DEAL_RES_CONTINUE; } + if (TSDB_DATA_TYPE_NULL == pVal->node.resType.type) { + // TODO + //pVal->node.resType = targetDt; + pVal->isNull = true; + return DEAL_RES_CONTINUE; + } if (pVal->isDuration) { if (parseNatualDuration(pVal->literal, strlen(pVal->literal), &pVal->datum.i, &pVal->unit, precision) != TSDB_CODE_SUCCESS) { @@ -5335,7 +5341,7 @@ static int32_t buildKVRowForAllTags(STranslateContext* pCxt, SCreateSubTableClau if (code != TSDB_CODE_SUCCESS) { goto end; } - } else if (pVal->node.resType.type != TSDB_DATA_TYPE_NULL) { + } else if (pVal->node.resType.type != TSDB_DATA_TYPE_NULL && !pVal->isNull) { char* tmpVal = nodesGetValueFromNode(pVal); STagVal val = {.cid = pTagSchema->colId, .type = pTagSchema->type}; if (IS_VAR_DATA_TYPE(pTagSchema->type)) { From cda2f844ced4d498cdc249c54f1a0f4666580ac7 Mon Sep 17 00:00:00 2001 From: dapan1121 Date: Thu, 30 Jun 2022 18:12:04 +0800 Subject: [PATCH 2/2] fix: fix json tag null issue --- source/libs/parser/src/parTranslater.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/source/libs/parser/src/parTranslater.c b/source/libs/parser/src/parTranslater.c index 6dc14dbf15..762a038bb1 100644 --- a/source/libs/parser/src/parTranslater.c +++ b/source/libs/parser/src/parTranslater.c @@ -786,6 +786,7 @@ static EDealRes translateValueImpl(STranslateContext* pCxt, SValueNode* pVal, SD if (TSDB_DATA_TYPE_NULL == pVal->node.resType.type) { // TODO //pVal->node.resType = targetDt; + pVal->translate = true; pVal->isNull = true; return DEAL_RES_CONTINUE; } @@ -5608,8 +5609,8 @@ static int32_t buildUpdateTagValReq(STranslateContext* pCxt, SAlterTableStmt* pS return TSDB_CODE_OUT_OF_MEMORY; } - if (DEAL_RES_ERROR == - translateValueImpl(pCxt, pStmt->pVal, schemaToDataType(pTableMeta->tableInfo.precision, pSchema))) { + SDataType targetDt = schemaToDataType(pTableMeta->tableInfo.precision, pSchema); + if (DEAL_RES_ERROR == translateValueImpl(pCxt, pStmt->pVal, targetDt)) { return pCxt->errCode; } @@ -5618,7 +5619,8 @@ static int32_t buildUpdateTagValReq(STranslateContext* pCxt, SAlterTableStmt* pS } pReq->isNull = (TSDB_DATA_TYPE_NULL == pStmt->pVal->node.resType.type); - if (pStmt->pVal->node.resType.type == TSDB_DATA_TYPE_JSON) { + if (targetDt.type == TSDB_DATA_TYPE_JSON) { + pReq->isNull = 0; if (pStmt->pVal->literal && strlen(pStmt->pVal->literal) > (TSDB_MAX_JSON_TAG_LEN - VARSTR_HEADER_SIZE) / TSDB_NCHAR_SIZE) { return buildSyntaxErrMsg(&pCxt->msgBuf, "json string too long than 4095", pStmt->pVal->literal);