Skip to content

Commit

Permalink
test cases refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
Simon9997 committed Jan 22, 2025
1 parent 7509c15 commit a9f1cdf
Show file tree
Hide file tree
Showing 8 changed files with 364 additions and 275 deletions.
30 changes: 21 additions & 9 deletions source/libs/planner/src/planLogicCreater.c
Original file line number Diff line number Diff line change
Expand Up @@ -722,29 +722,36 @@ static int32_t checkColRefType(const SSchema* vtbSchema, const SSchema* refSchem

static int32_t addSubScanNode(SLogicPlanContext* pCxt, SSelectStmt* pSelect, SVirtualTableNode* pVirtualTable,
int32_t index, SHashObj *refTablesMap) {
int32_t code = TSDB_CODE_SUCCESS;
col_id_t colId = 0;
SColRef* pColRef = &pVirtualTable->pMeta->colRef[index];
SNode *pRefTable = NULL;
int32_t code = TSDB_CODE_SUCCESS;
col_id_t colId = 0;
SColRef *pColRef = &pVirtualTable->pMeta->colRef[index];
SNode *pRefTable = NULL;
SLogicNode *pRefScan = NULL;
bool put = false;

PLAN_ERR_JRET(findRefTableNode(pVirtualTable->refTables, pColRef->refTableName, &pRefTable));
PLAN_ERR_JRET(findRefColId(pRefTable, pColRef->refColName, &colId));

SLogicNode *pRefScan = NULL;
SLogicNode **ppRefScan = (SLogicNode **)taosHashGet(refTablesMap, &pColRef->refTableName, strlen(pColRef->refTableName));
if (NULL == ppRefScan) {
PLAN_ERR_JRET(createScanLogicNode(pCxt, pSelect, (SRealTableNode*)pRefTable, &pRefScan));
PLAN_ERR_JRET(checkColRefType(&pVirtualTable->pMeta->schema[index], &((SRealTableNode*)pRefTable)->pMeta->schema[colId - 1]));
PLAN_ERR_JRET(scanAddCol(pRefScan, pColRef, &pVirtualTable->pMeta->schema[index], colId));
PLAN_ERR_JRET(taosHashPut(refTablesMap, &pColRef->refTableName, strlen(pColRef->refTableName), &pRefScan, POINTER_BYTES));
put = true;
} else {
pRefScan = *ppRefScan;
PLAN_ERR_JRET(checkColRefType(&pVirtualTable->pMeta->schema[index], &((SRealTableNode*)pRefTable)->pMeta->schema[colId - 1]));
PLAN_ERR_JRET(scanAddCol(pRefScan, pColRef, &pVirtualTable->pMeta->schema[index], colId));
}

nodesDestroyNode((SNode*)pRefTable);
return code;
_return:
nodesDestroyNode((SNode*)pRefTable);
if (!put) {
nodesDestroyNode((SNode*)pRefScan);
}
return code;
}

Expand All @@ -763,6 +770,14 @@ static int32_t makeVirtualScanLogicNode(SLogicPlanContext* pCxt, SVirtualTableNo
return TSDB_CODE_SUCCESS;
}

static void destroyScanLogicNode(void* data) {
if (data == NULL) {
return;
}
SScanLogicNode* pNode = *(SScanLogicNode **)data;
nodesDestroyNode((SNode*)pNode);
}

static int32_t createVirtualTableLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSelect,
SVirtualTableNode* pVirtualTable, SLogicNode** pLogicNode) {
int32_t code = TSDB_CODE_SUCCESS;
Expand Down Expand Up @@ -851,10 +866,7 @@ static int32_t createVirtualTableLogicNode(SLogicPlanContext* pCxt, SSelectStmt*
return code;

_return:
while ((pIter = taosHashIterate(pRefTablesMap, pIter))) {
SScanLogicNode **pRefScanNode = (SScanLogicNode**)pIter;
nodesDestroyNode((SNode*)(*pRefScanNode));
}
taosHashSetFreeFp(pRefTablesMap, destroyScanLogicNode);
taosHashCleanup(pRefTablesMap);
nodesDestroyNode((SNode*)pVtableScan);
return code;
Expand Down
14 changes: 7 additions & 7 deletions tests/army/vtable/ans/test_vctable_select_test_function.ans
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ taos> select atan(u_tinyint_col) from test_vtable_select.vtb_virtual_ctb_full li
1.564467297378695 |
1.563389054863731 |
1.565965446500920 |
1.566410390006105 |
1.566410390006104 |
1.557639191322141 |
1.566697989085048 |
1.373400766945016 |
Expand Down Expand Up @@ -654,7 +654,7 @@ taos> select tan(u_tinyint_col) from test_vtable_select.vtb_virtual_ctb_full lim
1.314265006453343 |
1.557407724654902 |
-3.172908552159191 |
-5.737022539279000 |
-5.737022539278999 |
-225.950846454195130 |
-32.268575775934416 |
0.169749752082688 |
Expand All @@ -669,7 +669,7 @@ taos> select tan(u_tinyint_col) from test_vtable_select.vtb_virtual_ctb_full lim
-0.825774009196815 |
0.070929992292224 |
0.919286404403608 |
-6.799711455220378 |
-6.799711455220379 |
3.493915645474840 |
-0.234224329867607 |
-0.635859928661581 |
Expand All @@ -687,13 +687,13 @@ taos> select tan(u_tinyint_col) from test_vtable_select.vtb_virtual_ctb_full lim
1.314265006453343 |
-0.088715756770060 |
-0.359502553689686 |
-4.185333577911701 |
-4.185333577911702 |
0.686747689351523 |
-1.720229311752444 |
-3.380515006246585 |
-3.380515006246586 |
0.310309660994801 |
1.244270058128709 |
5.192801712384871 |
5.192801712384870 |
1.004465813691152 |
-1.314182797241192 |
-0.410321299048242 |
Expand Down Expand Up @@ -2970,7 +2970,7 @@ taos> select stateduration(u_tinyint_col, "GT", 20, 1a) from test_vtable_select.
taos> select twa(int_col) from test_vtable_select.vtb_virtual_ctb_full limit 50;
twa(int_col) |
============================
-163781.012033155217068 |
-163685.413924687134568 |

taos> select abs(int_tag) from test_vtable_select.vtb_virtual_ctb_full limit 5;
abs(int_tag) |
Expand Down
Loading

0 comments on commit a9f1cdf

Please sign in to comment.