提交 d57b9459 编写于 作者: H Haojun Liao

[td-3299]

上级 dbe026a8
......@@ -135,7 +135,7 @@ typedef struct SJoinNode {
typedef struct SJoinInfo {
bool hasJoin;
SJoinNode* joinTables[TSDB_MAX_JOIN_TABLE_NUM];
SJoinNode *joinTables[TSDB_MAX_JOIN_TABLE_NUM];
} SJoinInfo;
typedef struct STagCond {
......
......@@ -3678,10 +3678,14 @@ static bool validateJoinExprNode(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, tSqlExpr
SSchema* pLeftSchema = tscGetTableSchema(pLeftMeterMeta->pTableMeta);
int16_t leftType = pLeftSchema[pLeftIndex->columnIndex].type;
tscColumnListInsert(pQueryInfo->colList, pLeftIndex->columnIndex, pLeftMeterMeta->pTableMeta->id.uid, &pLeftSchema[pLeftIndex->columnIndex]);
STableMetaInfo* pRightMeterMeta = tscGetMetaInfo(pQueryInfo, rightIndex.tableIndex);
SSchema* pRightSchema = tscGetTableSchema(pRightMeterMeta->pTableMeta);
int16_t rightType = pRightSchema[rightIndex.columnIndex].type;
tscColumnListInsert(pQueryInfo->colList, rightIndex.columnIndex, pRightMeterMeta->pTableMeta->id.uid, &pRightSchema[rightIndex.columnIndex]);
if (leftType != rightType) {
invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg3);
return false;
......@@ -3846,7 +3850,7 @@ static int32_t handleExprInQueryCond(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, tSql
taosArrayPush((*rightNode)->tsJoin, &leftIdx);
/*
* to release expression, e.g., m1.ts = m2.ts,
* To release expression, e.g., m1.ts = m2.ts,
* since this expression is used to set the join query type
*/
tSqlExprDestroy(*pExpr);
......
......@@ -26,6 +26,12 @@ typedef struct SFillEssInfo {
int64_t *val; // fill value
} SFillEssInfo;
typedef struct SJoinCond {
bool tagExists; // denote if tag condition exists or not
SColumn *tagCond[2];
SColumn *colCond[2];
} SJoinCond;
static SQueryNode* createQueryNode(int32_t type, const char* name, SQueryNode** prev,
int32_t numOfPrev, SExprInfo** pExpr, int32_t numOfOutput, SQueryTableInfo* pTableInfo,
void* pExtInfo) {
......@@ -92,8 +98,8 @@ static SQueryNode* createQueryNode(int32_t type, const char* name, SQueryNode**
return pNode;
}
static SQueryNode* doAddTableColumnNode(SQueryInfo* pQueryInfo, STableMetaInfo* pTableMetaInfo,
SQueryTableInfo* info, SArray* pExprs, SArray* tableCols) {
static SQueryNode* doAddTableColumnNode(SQueryInfo* pQueryInfo, STableMetaInfo* pTableMetaInfo, SQueryTableInfo* info,
SArray* pExprs, SArray* tableCols) {
if (pQueryInfo->onlyTagQuery) {
int32_t num = taosArrayGetSize(pExprs);
SQueryNode* pNode = createQueryNode(QNODE_TAGSCAN, "TableTagScan", NULL, 0, pExprs->pData, num, info, NULL);
......@@ -232,28 +238,12 @@ SArray* createQueryPlanImpl(SQueryInfo* pQueryInfo) {
tNameExtractFullName(&pTableMetaInfo->name, name);
SQueryTableInfo info = {.tableName = strdup(name), .id = pTableMetaInfo->pTableMeta->id,};
// 3. add the join columns (the tags and the primary timestamp column)
tscInsertPrimaryTsSourceColumn(pQueryInfo, info.id.uid);
// 3. get the required table column list
SArray* tableColumnList = taosArrayInit(4, sizeof(SColumn));
tscColumnListCopy(tableColumnList, pQueryInfo->colList, uid);
// TODO add the tag column into the required column list
if (UTIL_TABLE_IS_SUPER_TABLE(pTableMetaInfo)) {
int16_t tagColId = tscGetJoinTagColIdByUid(&pQueryInfo->tagCond, info.id.uid);
SSchema* s = tscGetColumnSchemaById(pTableMetaInfo->pTableMeta, tagColId);
SColumn* col = calloc(1, sizeof(SColumn));
col->tableUid = info.id.uid;
col->info.colId = tagColId;
col->info.type = s->type;
col->info.bytes = s->bytes;
taosArrayPush(pQueryInfo->colList, &col);
}
// 4. add the projection query node
SQueryNode* pNode = doAddTableColumnNode(pQueryInfo, pTableMetaInfo, &info, exprList, tableColumnList);
taosArrayPush(upstream, &pNode);
}
......@@ -497,7 +487,7 @@ static int32_t doPrintPlan(char* buf, SQueryNode* pQueryNode, int32_t level, int
case QNODE_JOIN: {
// print join condition
len1 = sprintf(buf + len, "\n");
len1 = sprintf(buf + len, ")\n");
len += len1;
break;
}
......
......@@ -229,7 +229,6 @@ tSqlExpr *tSqlExprCreate(tSqlExpr *pLeft, tSqlExpr *pRight, int32_t optrType) {
pExpr->flags &= ~(1 << EXPR_FLAG_TS_ERROR);
}
switch (optrType) {
case TK_PLUS: {
pExpr->value.i64 = pLeft->value.i64 + pRight->value.i64;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册