support join filter
This commit is contained in:
parent
39521a1b74
commit
385552c60d
|
@ -61,6 +61,7 @@ typedef struct SJoinSupporter {
|
||||||
uint64_t uid; // query table uid
|
uint64_t uid; // query table uid
|
||||||
SArray* colList; // previous query information, no need to use this attribute, and the corresponding attribution
|
SArray* colList; // previous query information, no need to use this attribute, and the corresponding attribution
|
||||||
SArray* exprList;
|
SArray* exprList;
|
||||||
|
SArray* colCond;
|
||||||
SFieldInfo fieldsInfo;
|
SFieldInfo fieldsInfo;
|
||||||
STagCond tagCond;
|
STagCond tagCond;
|
||||||
SGroupbyExpr groupInfo; // group by info
|
SGroupbyExpr groupInfo; // group by info
|
||||||
|
|
|
@ -3517,6 +3517,8 @@ static int32_t checkColumnFilterInfo(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SCol
|
||||||
|
|
||||||
SColumn* pColumn = tscColumnListInsert(pQueryInfo->colList, pIndex->columnIndex, pTableMeta->id.uid, pSchema);
|
SColumn* pColumn = tscColumnListInsert(pQueryInfo->colList, pIndex->columnIndex, pTableMeta->id.uid, pSchema);
|
||||||
|
|
||||||
|
pColumn->info.flist.numOfFilters++;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* in case of TK_AND filter condition, we first find the corresponding column and build the query condition together
|
* in case of TK_AND filter condition, we first find the corresponding column and build the query condition together
|
||||||
* the already existed condition.
|
* the already existed condition.
|
||||||
|
|
|
@ -914,7 +914,7 @@ int tscBuildQueryMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
|
||||||
//serializeColFilterInfo(pCol->flist.filterInfo, pCol->flist.numOfFilters, &pMsg);
|
//serializeColFilterInfo(pCol->flist.filterInfo, pCol->flist.numOfFilters, &pMsg);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pQueryInfo->colCond && taosArrayGetSize(pQueryInfo->colCond) > 0) {
|
if (pQueryInfo->colCond && taosArrayGetSize(pQueryInfo->colCond) > 0 && !onlyQueryTags(&query) ) {
|
||||||
SCond *pCond = tsGetTableFilter(pQueryInfo->colCond, pTableMeta->id.uid);
|
SCond *pCond = tsGetTableFilter(pQueryInfo->colCond, pTableMeta->id.uid);
|
||||||
if (pCond != NULL && pCond->cond != NULL) {
|
if (pCond != NULL && pCond->cond != NULL) {
|
||||||
pQueryMsg->colCondLen = htons(pCond->len);
|
pQueryMsg->colCondLen = htons(pCond->len);
|
||||||
|
|
|
@ -808,6 +808,7 @@ static void issueTsCompQuery(SSqlObj* pSql, SJoinSupporter* pSupporter, SSqlObj*
|
||||||
STimeWindow window = pQueryInfo->window;
|
STimeWindow window = pQueryInfo->window;
|
||||||
tscInitQueryInfo(pQueryInfo);
|
tscInitQueryInfo(pQueryInfo);
|
||||||
|
|
||||||
|
pQueryInfo->colCond = pSupporter->colCond;
|
||||||
pQueryInfo->window = window;
|
pQueryInfo->window = window;
|
||||||
TSDB_QUERY_CLEAR_TYPE(pQueryInfo->type, TSDB_QUERY_TYPE_TAG_FILTER_QUERY);
|
TSDB_QUERY_CLEAR_TYPE(pQueryInfo->type, TSDB_QUERY_TYPE_TAG_FILTER_QUERY);
|
||||||
TSDB_QUERY_SET_TYPE(pQueryInfo->type, TSDB_QUERY_TYPE_MULTITABLE_QUERY);
|
TSDB_QUERY_SET_TYPE(pQueryInfo->type, TSDB_QUERY_TYPE_MULTITABLE_QUERY);
|
||||||
|
@ -1883,6 +1884,9 @@ int32_t tscCreateJoinSubquery(SSqlObj *pSql, int16_t tableIndex, SJoinSupporter
|
||||||
if (UTIL_TABLE_IS_SUPER_TABLE(pTableMetaInfo)) { // return the tableId & tag
|
if (UTIL_TABLE_IS_SUPER_TABLE(pTableMetaInfo)) { // return the tableId & tag
|
||||||
SColumnIndex colIndex = {0};
|
SColumnIndex colIndex = {0};
|
||||||
|
|
||||||
|
pSupporter->colCond = pNewQueryInfo->colCond;
|
||||||
|
pNewQueryInfo->colCond = NULL;
|
||||||
|
|
||||||
STagCond* pTagCond = &pSupporter->tagCond;
|
STagCond* pTagCond = &pSupporter->tagCond;
|
||||||
assert(pTagCond->joinInfo.hasJoin);
|
assert(pTagCond->joinInfo.hasJoin);
|
||||||
|
|
||||||
|
|
|
@ -2011,6 +2011,11 @@ int32_t tscGetResRowLength(SArray* pExprList) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static void destroyFilterInfo(SColumnFilterList* pFilterList) {
|
static void destroyFilterInfo(SColumnFilterList* pFilterList) {
|
||||||
|
if (pFilterList->filterInfo == NULL) {
|
||||||
|
pFilterList->numOfFilters = 0;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
for(int32_t i = 0; i < pFilterList->numOfFilters; ++i) {
|
for(int32_t i = 0; i < pFilterList->numOfFilters; ++i) {
|
||||||
if (pFilterList->filterInfo[i].filterstr) {
|
if (pFilterList->filterInfo[i].filterstr) {
|
||||||
tfree(pFilterList->filterInfo[i].pz);
|
tfree(pFilterList->filterInfo[i].pz);
|
||||||
|
|
|
@ -61,7 +61,7 @@ bool tscValidateTableNameLength(size_t len) {
|
||||||
|
|
||||||
// TODO refactor
|
// TODO refactor
|
||||||
SColumnFilterInfo* tFilterInfoDup(const SColumnFilterInfo* src, int32_t numOfFilters) {
|
SColumnFilterInfo* tFilterInfoDup(const SColumnFilterInfo* src, int32_t numOfFilters) {
|
||||||
if (numOfFilters == 0) {
|
if (numOfFilters == 0 || src == NULL) {
|
||||||
assert(src == NULL);
|
assert(src == NULL);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
|
@ -7078,7 +7078,7 @@ void* doDestroyFilterInfo(SSingleColumnFilterInfo* pFilterInfo, int32_t numOfFil
|
||||||
|
|
||||||
int32_t createFilterInfo(SQueryAttr* pQueryAttr, uint64_t qId) {
|
int32_t createFilterInfo(SQueryAttr* pQueryAttr, uint64_t qId) {
|
||||||
for (int32_t i = 0; i < pQueryAttr->numOfCols; ++i) {
|
for (int32_t i = 0; i < pQueryAttr->numOfCols; ++i) {
|
||||||
if (pQueryAttr->tableCols[i].flist.numOfFilters > 0) {
|
if (pQueryAttr->tableCols[i].flist.numOfFilters > 0 && pQueryAttr->tableCols[i].flist.filterInfo != NULL) {
|
||||||
pQueryAttr->numOfFilterCols++;
|
pQueryAttr->numOfFilterCols++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue