Skip to content

Commit

Permalink
fix unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
Simon9997 committed Jan 24, 2025
1 parent 96bdbba commit b89fa57
Show file tree
Hide file tree
Showing 10 changed files with 57,949 additions and 62 deletions.
36 changes: 17 additions & 19 deletions source/libs/catalog/test/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,25 +1,23 @@

MESSAGE(STATUS "build catalog unit test")

IF(NOT TD_DARWIN)
# GoogleTest requires at least C++11
SET(CMAKE_CXX_STANDARD 11)
AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR} SOURCE_LIST)
# GoogleTest requires at least C++11
SET(CMAKE_CXX_STANDARD 11)
AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR} SOURCE_LIST)

ADD_EXECUTABLE(catalogTest ${SOURCE_LIST})
TARGET_LINK_LIBRARIES(
catalogTest
PUBLIC os util common nodes catalog transport gtest qcom ${TAOS_LIB_STATIC}
)
ADD_EXECUTABLE(catalogTest ${SOURCE_LIST})
TARGET_LINK_LIBRARIES(
catalogTest
PUBLIC os util common nodes catalog transport gtest qcom ${TAOS_LIB_STATIC}
)

TARGET_INCLUDE_DIRECTORIES(
catalogTest
PUBLIC "${TD_SOURCE_DIR}/include/libs/catalog/"
PRIVATE "${TD_SOURCE_DIR}/source/libs/catalog/inc"
)
TARGET_INCLUDE_DIRECTORIES(
catalogTest
PUBLIC "${TD_SOURCE_DIR}/include/libs/catalog/"
PRIVATE "${TD_SOURCE_DIR}/source/libs/catalog/inc"
)

add_test(
NAME catalogTest
COMMAND catalogTest
)
ENDIF()
add_test(
NAME catalogTest
COMMAND catalogTest
)
2 changes: 2 additions & 0 deletions source/libs/catalog/test/catalogTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,8 @@ void ctgTestBuildCTableMetaOutput(STableMetaOutput *output) {
output->tbMeta->sversion = ctgTestSVersion;
output->tbMeta->tversion = ctgTestTVersion;

output->vctbMeta = NULL;

SSchema *s = NULL;
s = &output->tbMeta->schema[0];
s->type = TSDB_DATA_TYPE_TIMESTAMP;
Expand Down
5 changes: 4 additions & 1 deletion source/libs/parser/src/parTranslater.c
Original file line number Diff line number Diff line change
Expand Up @@ -4419,7 +4419,8 @@ static bool isSingleTable(SRealTableNode* pRealTable) {
0 != strcmp(pRealTable->table.tableName, TSDB_INS_DISK_USAGE) &&
0 != strcmp(pRealTable->table.tableName, TSDB_INS_TABLE_FILESETS);
}
return (TSDB_CHILD_TABLE == tableType || TSDB_NORMAL_TABLE == tableType);
return (TSDB_CHILD_TABLE == tableType || TSDB_NORMAL_TABLE == tableType ||
TSDB_VIRTUAL_CHILD_TABLE == tableType || TSDB_VIRTUAL_TABLE == tableType);
}

static int32_t setTableIndex(STranslateContext* pCxt, SName* pName, SRealTableNode* pRealTable) {
Expand Down Expand Up @@ -5141,6 +5142,8 @@ int32_t translateTable(STranslateContext* pCxt, SNode** pTable, SNode* pJoinPare
break;
}
PAR_ERR_RET(translateVirtualTable(pCxt, pTable, &name));
SVirtualTableNode *pVirtualTable = (SVirtualTableNode*)*pTable;
pVirtualTable->table.singleTable = true;
PAR_RET(addNamespace(pCxt, (SVirtualTableNode*)*pTable));
}
#endif
Expand Down
3 changes: 2 additions & 1 deletion source/libs/parser/test/mockCatalog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,11 @@ void generateInformationSchema(MockCatalogService* mcs) {
.addColumn("db_name", TSDB_DATA_TYPE_BINARY, TSDB_DB_NAME_LEN)
.addColumn("stable_name", TSDB_DATA_TYPE_BINARY, TSDB_TABLE_NAME_LEN)
.done();
mcs->createTableBuilder(TSDB_INFORMATION_SCHEMA_DB, TSDB_INS_TABLE_TABLES, TSDB_SYSTEM_TABLE, 3)
mcs->createTableBuilder(TSDB_INFORMATION_SCHEMA_DB, TSDB_INS_TABLE_TABLES, TSDB_SYSTEM_TABLE, 4)
.addColumn("table_name", TSDB_DATA_TYPE_BINARY, TSDB_TABLE_NAME_LEN)
.addColumn("db_name", TSDB_DATA_TYPE_BINARY, TSDB_DB_NAME_LEN)
.addColumn("stable_name", TSDB_DATA_TYPE_BINARY, TSDB_TABLE_NAME_LEN)
.addColumn("type", TSDB_DATA_TYPE_BINARY, 23)
.done();
mcs->createTableBuilder(TSDB_INFORMATION_SCHEMA_DB, TSDB_INS_TABLE_TABLE_DISTRIBUTED, TSDB_SYSTEM_TABLE, 2)
.addColumn("db_name", TSDB_DATA_TYPE_BINARY, TSDB_DB_NAME_LEN)
Expand Down
7 changes: 6 additions & 1 deletion source/libs/planner/src/planSpliter.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ static int32_t stbSplCreateMergeKeys(SNodeList* pSortKeys, SNodeList* pTargets,
static void splSetSubplanVgroups(SLogicSubplan* pSubplan, SLogicNode* pNode) {
if (QUERY_NODE_LOGIC_PLAN_SCAN == nodeType(pNode)) {
TSWAP(pSubplan->pVgroupList, ((SScanLogicNode*)pNode)->pVgroupList);
} else if (QUERY_NODE_LOGIC_PLAN_VIRTUAL_TABLE_SCAN == nodeType(pNode)) {
TSWAP(pSubplan->pVgroupList, ((SVirtualScanLogicNode *)pNode)->pVgroupList);
} else {
if (1 == LIST_LENGTH(pNode->pChildren)) {
splSetSubplanVgroups(pSubplan, (SLogicNode*)nodesListGetNode(pNode->pChildren, 0));
Expand All @@ -66,7 +68,7 @@ static SLogicSubplan* splCreateScanSubplan(SSplitContext* pCxt, SLogicNode* pNod
}
pSubplan->id.queryId = pCxt->queryId;
pSubplan->id.groupId = pCxt->groupId;
pSubplan->subplanType = SUBPLAN_TYPE_SCAN;
pSubplan->subplanType = nodeType(pNode) == QUERY_NODE_LOGIC_PLAN_VIRTUAL_TABLE_SCAN ? SUBPLAN_TYPE_MERGE : SUBPLAN_TYPE_SCAN;
pSubplan->pNode = pNode;
pSubplan->pNode->pParent = NULL;
splSetSubplanVgroups(pSubplan, pNode);
Expand Down Expand Up @@ -2147,6 +2149,9 @@ static void setVgroupsInfo(SLogicNode* pNode, SLogicSubplan* pSubplan) {
if (QUERY_NODE_LOGIC_PLAN_SCAN == nodeType(pNode)) {
TSWAP(((SScanLogicNode*)pNode)->pVgroupList, pSubplan->pVgroupList);
return;
} else if (QUERY_NODE_LOGIC_PLAN_VIRTUAL_TABLE_SCAN == nodeType(pNode)) {
TSWAP(((SVirtualScanLogicNode *)pNode)->pVgroupList, pSubplan->pVgroupList);
return;
}

SNode* pChild;
Expand Down
Loading

0 comments on commit b89fa57

Please sign in to comment.