Merge pull request #25790 from taosdata/fix/TD-30064
fix:remove dot from child table in stream
This commit is contained in:
commit
f8eb217c75
|
@ -2414,10 +2414,21 @@ void buildCtbNameAddGroupId(const char* stbName, char* ctbName, uint64_t groupId
|
|||
if (stbName == NULL){
|
||||
snprintf(tmp, TSDB_TABLE_NAME_LEN, "_%"PRIu64, groupId);
|
||||
}else{
|
||||
snprintf(tmp, TSDB_TABLE_NAME_LEN, "_%s_%" PRIu64, stbName, groupId);
|
||||
int32_t i = strlen(stbName) - 1;
|
||||
for(; i >= 0; i--){
|
||||
if (stbName[i] == '.'){
|
||||
break;
|
||||
}
|
||||
}
|
||||
snprintf(tmp, TSDB_TABLE_NAME_LEN, "_%s_%"PRIu64, stbName + i + 1, groupId);
|
||||
}
|
||||
ctbName[TSDB_TABLE_NAME_LEN - strlen(tmp) - 1] = 0; // put stbname + groupId to the end
|
||||
strcat(ctbName, tmp);
|
||||
for(int i = 0; i < strlen(ctbName); i++){
|
||||
if(ctbName[i] == '.'){
|
||||
ctbName[i] = '_';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// auto stream subtable name starts with 't_', followed by the first segment of MD5 digest for group vals.
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
#include <tglobal.h>
|
||||
#include <tmsg.h>
|
||||
#include <iostream>
|
||||
#include <tdatablock.h>
|
||||
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wwrite-strings"
|
||||
|
@ -475,6 +476,45 @@ TEST(testCase, AllNormTest) {
|
|||
taosMemoryFree(pTSchema);
|
||||
}
|
||||
|
||||
TEST(testCase, StreamAllNormTest) {
|
||||
char ctbName[TSDB_TABLE_NAME_LEN] = {0};
|
||||
uint64_t groupId = 12345;
|
||||
|
||||
buildCtbNameAddGroupId(NULL, ctbName, groupId);
|
||||
|
||||
ASSERT_STREQ("_12345", ctbName);
|
||||
}
|
||||
|
||||
TEST(testCase, StreamWithStbName) {
|
||||
char stbName[] = "1.table.stb";
|
||||
char ctbName[TSDB_TABLE_NAME_LEN] = {0};
|
||||
uint64_t groupId = 12345;
|
||||
|
||||
buildCtbNameAddGroupId(stbName, ctbName, groupId);
|
||||
|
||||
ASSERT_STREQ("_stb_12345", ctbName);
|
||||
}
|
||||
|
||||
TEST(testCase, StreamWithoutDotInStbName) {
|
||||
char stbName[] = "table";
|
||||
char ctbName[TSDB_TABLE_NAME_LEN] = {0};
|
||||
uint64_t groupId = 12345;
|
||||
|
||||
buildCtbNameAddGroupId(stbName, ctbName, groupId);
|
||||
|
||||
ASSERT_STREQ("_table_12345", ctbName);
|
||||
}
|
||||
|
||||
TEST(testCase, StreamWithoutDotInStbName2) {
|
||||
char stbName[] = "";
|
||||
char ctbName[TSDB_TABLE_NAME_LEN] = {0};
|
||||
uint64_t groupId = 12345;
|
||||
|
||||
buildCtbNameAddGroupId(stbName, ctbName, groupId);
|
||||
|
||||
ASSERT_STREQ("__12345", ctbName);
|
||||
}
|
||||
|
||||
#if 1
|
||||
TEST(testCase, NoneTest) {
|
||||
const static int nCols = 14;
|
||||
|
|
|
@ -87,7 +87,7 @@ class TDTestCase:
|
|||
tdSql.execute(f'insert into t2 using st tags(2) values(now, 1) (now+1s, 2)')
|
||||
tdSql.execute(f'insert into t3 using st tags(3) values(now, 1) (now+1s, 2)')
|
||||
|
||||
tdSql.execute("create stream stream1 fill_history 1 into sta subtable(concat('new-', tname)) AS SELECT "
|
||||
tdSql.execute("create stream stream1 fill_history 1 into sta subtable(concat('nee.w-', tname)) AS SELECT "
|
||||
"_wstart, count(*), avg(i) FROM st PARTITION BY tbname tname INTERVAL(1m)", show=True)
|
||||
|
||||
tdSql.execute("create stream stream2 fill_history 1 into stb subtable(concat('new-', tname)) AS SELECT "
|
||||
|
@ -97,25 +97,25 @@ class TDTestCase:
|
|||
tdSql.query("select * from sta")
|
||||
tdSql.checkRows(3)
|
||||
tdSql.query("select tbname from sta order by tbname")
|
||||
if not tdSql.getData(0, 0).startswith('new-t1_1.d1.sta_'):
|
||||
if not tdSql.getData(0, 0).startswith('nee_w-t1_sta_'):
|
||||
tdLog.exit("error1")
|
||||
|
||||
if not tdSql.getData(1, 0).startswith('new-t2_1.d1.sta_'):
|
||||
if not tdSql.getData(1, 0).startswith('nee_w-t2_sta_'):
|
||||
tdLog.exit("error2")
|
||||
|
||||
if not tdSql.getData(2, 0).startswith('new-t3_1.d1.sta_'):
|
||||
if not tdSql.getData(2, 0).startswith('nee_w-t3_sta_'):
|
||||
tdLog.exit("error3")
|
||||
|
||||
tdSql.query("select * from stb")
|
||||
tdSql.checkRows(3)
|
||||
tdSql.query("select tbname from stb order by tbname")
|
||||
if not tdSql.getData(0, 0).startswith('new-t1_1.d1.stb_'):
|
||||
if not tdSql.getData(0, 0).startswith('new-t1_stb_'):
|
||||
tdLog.exit("error4")
|
||||
|
||||
if not tdSql.getData(1, 0).startswith('new-t2_1.d1.stb_'):
|
||||
if not tdSql.getData(1, 0).startswith('new-t2_stb_'):
|
||||
tdLog.exit("error5")
|
||||
|
||||
if not tdSql.getData(2, 0).startswith('new-t3_1.d1.stb_'):
|
||||
if not tdSql.getData(2, 0).startswith('new-t3_stb_'):
|
||||
tdLog.exit("error6")
|
||||
|
||||
# run
|
||||
|
|
Loading…
Reference in New Issue