start to support select child table using tsma

This commit is contained in:
wangjiaming0909 2024-02-23 14:43:59 +08:00
parent a75c67efc8
commit dff0449474
5 changed files with 10 additions and 1 deletions

View File

@ -263,6 +263,7 @@ typedef struct SCtgViewsCtx {
} SCtgViewsCtx;
typedef enum {
FETCH_TB_META,
FETCH_TSMA_FOR_TB,
FETCH_PROGRESS_FOR_TSMA,
} CTG_TSMA_FETCH_TYPE;

View File

@ -2658,6 +2658,7 @@ int32_t ctgLaunchGetTbTSMATask(SCtgTask* pTask) {
int32_t dbNum = taosArrayGetSize(pCtx->pNames);
int32_t fetchIdx = 0, baseResIdx = 0;
// TODO test multi tables from multi dbs
for (int32_t idx = 0; idx < dbNum; ++idx) {
STablesReq* pReq = taosArrayGet(pCtx->pNames, idx);
CTG_ERR_RET(ctgGetTbTSMAFromCache(pCtg, pCtx, idx, &fetchIdx, baseResIdx, pReq->pTables));

View File

@ -3248,7 +3248,6 @@ int32_t ctgGetTbTSMAFromCache(SCatalog* pCtg, SCtgTbTSMACtx* pCtx, int32_t dbIdx
// TODO test no db cache, select from another db
for (int32_t i = 0; i < tbNum; ++i) {
ctgAddTSMAFetch(&pCtx->pFetches, dbIdx, i, fetchIdx, baseResIdx + i, flag);
//ctgAddTSMAFetch();
taosArrayPush(pCtx->pResList, &(SMetaData){0});
}
return TSDB_CODE_SUCCESS;

View File

@ -511,6 +511,7 @@ void ctgClearHandle(SCatalog* pCtg) {
ctgMetaRentInit(&pCtg->dbRent, gCtgMgmt.cfg.dbRentSec, CTG_RENT_DB, sizeof(SDbCacheInfo));
ctgMetaRentInit(&pCtg->stbRent, gCtgMgmt.cfg.stbRentSec, CTG_RENT_STABLE, sizeof(SSTableVersion));
ctgMetaRentInit(&pCtg->viewRent, gCtgMgmt.cfg.viewRentSec, CTG_RENT_VIEW, sizeof(SViewVersion));
ctgMetaRentInit(&pCtg->tsmaRent, gCtgMgmt.cfg.tsmaRentSec, CTG_RENT_TSMA, sizeof(STSMAVersion));
pCtg->dbCache = taosHashInit(gCtgMgmt.cfg.maxDBCacheNum, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), false,
HASH_ENTRY_LOCK);

View File

@ -462,6 +462,13 @@ class TDTestCase:
## self.test_query_with_drop_tsma()
## self.test_query_with_add_tag()
## self.test_union()
self.test_query_sub_table()
def test_query_sub_table(self):
sql = 'select avg(c1) from t1'
ctx = TSMAQCBuilder().with_sql(sql).should_query_with_tsma('tsma2', UsedTsma.TS_MIN, UsedTsma.TS_MAX).get_qc()
self.tsma_tester.check_sql(sql, ctx)
def test_recursive_tsma(self):
tdSql.execute('drop tsma tsma2')