fix:[TD-33048] add ts to cols if dataFormat is true in schemaless to avoid schemal is old
This commit is contained in:
parent
edba0063aa
commit
ce47556637
|
@ -772,22 +772,27 @@ END:
|
|||
RETURN
|
||||
}
|
||||
|
||||
static int32_t smlCheckMeta(SSchema *schema, int32_t length, SArray *cols, bool isTag) {
|
||||
static int32_t smlCheckMeta(SSchema *schema, int32_t length, SArray *cols) {
|
||||
int32_t code = TSDB_CODE_SUCCESS;
|
||||
int32_t lino = 0;
|
||||
SHashObj *hashTmp = taosHashInit(length, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, HASH_NO_LOCK);
|
||||
SML_CHECK_NULL(hashTmp);
|
||||
int32_t i = 0;
|
||||
for (; i < length; i++) {
|
||||
SML_CHECK_CODE(taosHashPut(hashTmp, schema[i].name, strlen(schema[i].name), &i, SHORT_BYTES));
|
||||
for (int32_t i = 0; i < length; i++) {
|
||||
SML_CHECK_CODE(taosHashPut(hashTmp, schema[i].name, strlen(schema[i].name), &schema[i], sizeof(SSchema)));
|
||||
}
|
||||
i = isTag ? 0 : 1;
|
||||
for (; i < taosArrayGetSize(cols); i++) {
|
||||
for (int32_t i = 0; i < taosArrayGetSize(cols); i++) {
|
||||
SSmlKv *kv = (SSmlKv *)taosArrayGet(cols, i);
|
||||
SML_CHECK_NULL(kv);
|
||||
if (taosHashGet(hashTmp, kv->key, kv->keyLen) == NULL) {
|
||||
SSchema *sTmp = taosHashGet(hashTmp, kv->key, kv->keyLen);
|
||||
if (sTmp == NULL) {
|
||||
SML_CHECK_CODE(TSDB_CODE_SML_INVALID_DATA);
|
||||
}
|
||||
if ((IS_VAR_DATA_TYPE(kv->type) && kv->length + VARSTR_HEADER_SIZE > sTmp->bytes) ||
|
||||
(!IS_VAR_DATA_TYPE(kv->type) && kv->length != sTmp->bytes)){
|
||||
uError("column %s (type %s) bytes invalid. db bytes:%d, kv bytes:%zu", sTmp->name,
|
||||
tDataTypes[sTmp->type].name, sTmp->bytes, kv->length);
|
||||
SML_CHECK_CODE(TSDB_CODE_INTERNAL_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
END:
|
||||
|
@ -1132,8 +1137,8 @@ static int32_t smlModifyDBSchemas(SSmlHandle *info) {
|
|||
}
|
||||
|
||||
if (needCheckMeta) {
|
||||
SML_CHECK_CODE(smlCheckMeta(&(pTableMeta->schema[pTableMeta->tableInfo.numOfColumns]), pTableMeta->tableInfo.numOfTags, sTableData->tags, true));
|
||||
SML_CHECK_CODE(smlCheckMeta(&(pTableMeta->schema[0]), pTableMeta->tableInfo.numOfColumns, sTableData->cols, false));
|
||||
SML_CHECK_CODE(smlCheckMeta(&(pTableMeta->schema[pTableMeta->tableInfo.numOfColumns]), pTableMeta->tableInfo.numOfTags, sTableData->tags));
|
||||
SML_CHECK_CODE(smlCheckMeta(&(pTableMeta->schema[0]), pTableMeta->tableInfo.numOfColumns, sTableData->cols));
|
||||
}
|
||||
|
||||
taosMemoryFreeClear(sTableData->tableMeta);
|
||||
|
|
|
@ -14,7 +14,7 @@ sys.path.append("./7-tmq")
|
|||
from tmqCommon import *
|
||||
|
||||
class TDTestCase:
|
||||
updatecfgDict = {'clientCfg': {'smlChildTableName': 'dataModelName', 'fqdn': 'localhost', 'smlTsDefaultName': "times"}, 'fqdn': 'localhost'}
|
||||
updatecfgDict = {'clientCfg': {'smlChildTableName': 'dataModelName', 'fqdn': 'localhost'}, 'fqdn': 'localhost'}
|
||||
print("===================: ", updatecfgDict)
|
||||
|
||||
def init(self, conn, logSql, replicaVar=1):
|
||||
|
@ -58,7 +58,7 @@ class TDTestCase:
|
|||
tdSql.query(f"select distinct tbname from {dbname}.readings")
|
||||
tdSql.checkRows(4)
|
||||
|
||||
tdSql.query(f"select * from {dbname}.t_0799064f5487946e5d22164a822acfc8 order by times")
|
||||
tdSql.query(f"select * from {dbname}.t_0799064f5487946e5d22164a822acfc8 order by _ts")
|
||||
tdSql.checkRows(2)
|
||||
tdSql.checkData(0, 3, "kk")
|
||||
tdSql.checkData(1, 3, "")
|
||||
|
@ -67,7 +67,7 @@ class TDTestCase:
|
|||
tdSql.query(f"select distinct tbname from {dbname}.`sys_if_bytes_out`")
|
||||
tdSql.checkRows(2)
|
||||
|
||||
tdSql.query(f"select * from {dbname}.t_f67972b49aa8adf8bca5d0d54f0d850d order by times")
|
||||
tdSql.query(f"select * from {dbname}.t_f67972b49aa8adf8bca5d0d54f0d850d order by _ts")
|
||||
tdSql.checkRows(2)
|
||||
tdSql.checkData(0, 1, 1.300000000)
|
||||
tdSql.checkData(1, 1, 13.000000000)
|
||||
|
@ -80,7 +80,7 @@ class TDTestCase:
|
|||
tdSql.query(f"select distinct tbname from {dbname}.`sys_cpu_nice`")
|
||||
tdSql.checkRows(3)
|
||||
|
||||
tdSql.query(f"select * from {dbname}.`sys_cpu_nice` order by times")
|
||||
tdSql.query(f"select * from {dbname}.`sys_cpu_nice` order by _ts")
|
||||
tdSql.checkRows(4)
|
||||
tdSql.checkData(0, 1, 13.000000000)
|
||||
tdSql.checkData(0, 2, "web01")
|
||||
|
|
Loading…
Reference in New Issue