提交 7965f860 编写于 作者: G Ganlin Zhao

[TD-10870]<enhance>: [schemaless]add a NULL tag to accommodate influxDB tag is optional

上级 19e08c05
...@@ -231,6 +231,18 @@ static int32_t buildDataPointSchemas(TAOS_SML_DATA_POINT* points, int numPoint, ...@@ -231,6 +231,18 @@ static int32_t buildDataPointSchemas(TAOS_SML_DATA_POINT* points, int numPoint,
} }
} }
const char tagNullName[] = "`_tag_null`";
size_t* pTagNullIdx = taosHashGet(pStableSchema->tagHash, tagNullName, strlen(tagNullName));
if (!pTagNullIdx) {
SSchema tagNull = {0};
tagNull.type = TSDB_DATA_TYPE_NCHAR;
tagNull.bytes = 6;
strncpy(tagNull.name, tagNullName, strlen(tagNullName));
taosArrayPush(pStableSchema->tags, &tagNull);
size_t tagNullIdx = taosArrayGetSize(pStableSchema->tags) - 1;
taosHashPut(pStableSchema->tagHash, tagNull.name, strlen(tagNullName), &tagNullIdx, sizeof(tagNullIdx));
}
for (int j = 0; j < point->fieldNum; ++j) { for (int j = 0; j < point->fieldNum; ++j) {
TAOS_SML_KV* fieldKv = point->fields + j; TAOS_SML_KV* fieldKv = point->fields + j;
code = buildSmlKvSchema(fieldKv, pStableSchema->fieldHash, pStableSchema->fields, info); code = buildSmlKvSchema(fieldKv, pStableSchema->fieldHash, pStableSchema->fields, info);
...@@ -952,10 +964,10 @@ static int32_t applyChildTableTags(TAOS* taos, char* cTableName, char* sTableNam ...@@ -952,10 +964,10 @@ static int32_t applyChildTableTags(TAOS* taos, char* cTableName, char* sTableNam
} }
} }
SArray* tagBinds = taosArrayInit(numTags, sizeof(TAOS_BIND)); SArray* tagBinds = taosArrayInit(numTags + 1, sizeof(TAOS_BIND));
taosArraySetSize(tagBinds, numTags); taosArraySetSize(tagBinds, numTags + 1);
int isNullColBind = TSDB_TRUE; int isNullColBind = TSDB_TRUE;
for (int j = 0; j < numTags; ++j) { for (int j = 0; j < numTags + 1; ++j) {
TAOS_BIND* bind = taosArrayGet(tagBinds, j); TAOS_BIND* bind = taosArrayGet(tagBinds, j);
bind->is_null = &isNullColBind; bind->is_null = &isNullColBind;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册