提交 377c8c9e 编写于 作者: C Cary Xu

Merge branch '3.0' into feature/TD-11463-3.0

......@@ -141,12 +141,12 @@ static SNode* valueNodeCopy(const SValueNode* pSrc, SValueNode* pDst) {
case TSDB_DATA_TYPE_NCHAR:
case TSDB_DATA_TYPE_VARCHAR:
case TSDB_DATA_TYPE_VARBINARY:
pDst->datum.p = malloc(pSrc->node.resType.bytes + VARSTR_HEADER_SIZE);
pDst->datum.p = malloc(pSrc->node.resType.bytes + VARSTR_HEADER_SIZE + 1);
if (NULL == pDst->datum.p) {
nodesDestroyNode(pDst);
return NULL;
}
memcpy(pDst->datum.p, pSrc->datum.p, pSrc->node.resType.bytes + VARSTR_HEADER_SIZE);
memcpy(pDst->datum.p, pSrc->datum.p, pSrc->node.resType.bytes + VARSTR_HEADER_SIZE + 1);
break;
case TSDB_DATA_TYPE_JSON:
case TSDB_DATA_TYPE_DECIMAL:
......
......@@ -1807,6 +1807,45 @@ static int32_t groupingSetNodeToJson(const void* pObj, SJson* pJson) {
return code;
}
static const char* jkIntervalWindowInterval = "Interval";
static const char* jkIntervalWindowOffset = "Offset";
static const char* jkIntervalWindowSliding = "Sliding";
static const char* jkIntervalWindowFill = "Fill";
static int32_t intervalWindowNodeToJson(const void* pObj, SJson* pJson) {
const SIntervalWindowNode* pNode = (const SIntervalWindowNode*)pObj;
int32_t code = tjsonAddObject(pJson, jkIntervalWindowInterval, nodeToJson, pNode->pInterval);
if (TSDB_CODE_SUCCESS == code) {
code = tjsonAddObject(pJson, jkIntervalWindowOffset, nodeToJson, pNode->pOffset);
}
if (TSDB_CODE_SUCCESS == code) {
code = tjsonAddObject(pJson, jkIntervalWindowSliding, nodeToJson, pNode->pSliding);
}
if (TSDB_CODE_SUCCESS == code) {
code = tjsonAddObject(pJson, jkIntervalWindowFill, nodeToJson, pNode->pFill);
}
return code;
}
static int32_t jsonToIntervalWindowNode(const SJson* pJson, void* pObj) {
SIntervalWindowNode* pNode = (SIntervalWindowNode*)pObj;
int32_t code = jsonToNodeObject(pJson, jkIntervalWindowInterval, &pNode->pInterval);
if (TSDB_CODE_SUCCESS == code) {
code = jsonToNodeObject(pJson, jkIntervalWindowOffset, &pNode->pOffset);
}
if (TSDB_CODE_SUCCESS == code) {
code = jsonToNodeObject(pJson, jkIntervalWindowSliding, &pNode->pSliding);
}
if (TSDB_CODE_SUCCESS == code) {
code = jsonToNodeObject(pJson, jkIntervalWindowFill, &pNode->pFill);
}
return code;
}
static const char* jkNodeListDataType = "DataType";
static const char* jkNodeListNodeList = "NodeList";
......@@ -2119,8 +2158,9 @@ static int32_t specificNodeToJson(const void* pObj, SJson* pJson) {
case QUERY_NODE_LIMIT:
case QUERY_NODE_STATE_WINDOW:
case QUERY_NODE_SESSION_WINDOW:
case QUERY_NODE_INTERVAL_WINDOW:
break;
case QUERY_NODE_INTERVAL_WINDOW:
return intervalWindowNodeToJson(pObj, pJson);
case QUERY_NODE_NODE_LIST:
return nodeListNodeToJson(pObj, pJson);
case QUERY_NODE_FILL:
......@@ -2222,7 +2262,8 @@ static int32_t jsonToSpecificNode(const SJson* pJson, void* pObj) {
// case QUERY_NODE_LIMIT:
// case QUERY_NODE_STATE_WINDOW:
// case QUERY_NODE_SESSION_WINDOW:
// case QUERY_NODE_INTERVAL_WINDOW:
case QUERY_NODE_INTERVAL_WINDOW:
return jsonToIntervalWindowNode(pJson, pObj);
case QUERY_NODE_NODE_LIST:
return jsonToNodeListNode(pJson, pObj);
// case QUERY_NODE_FILL:
......
......@@ -358,7 +358,6 @@ TEST_F(ParserTest, selectSemanticError) {
ASSERT_TRUE(run(TSDB_CODE_SUCCESS, TSDB_CODE_PAR_NOT_SELECTED_EXPRESSION));
}
TEST_F(ParserTest, showUsers) {
setDatabase("root", "test");
......@@ -366,8 +365,6 @@ TEST_F(ParserTest, showUsers) {
ASSERT_TRUE(run());
}
TEST_F(ParserTest, createDnode) {
setDatabase("root", "test");
......
......@@ -213,6 +213,33 @@ static SNodeptr createPrimaryKeyCol(SPhysiPlanContext* pCxt, uint64_t tableId) {
return pCol;
}
static int32_t colIdCompare(const void* pLeft, const void* pRight) {
SColumnNode* pLeftCol = *(SColumnNode**)pLeft;
SColumnNode* pRightCol = *(SColumnNode**)pRight;
return pLeftCol->colId > pRightCol->colId ? 1 : -1;
}
static int32_t sortScanCols(SNodeList* pScanCols) {
SArray* pArray = taosArrayInit(LIST_LENGTH(pScanCols), POINTER_BYTES);
if (NULL == pArray) {
return TSDB_CODE_OUT_OF_MEMORY;
}
SNode* pCol = NULL;
FOREACH(pCol, pScanCols) {
taosArrayPush(pArray, &pCol);
}
taosArraySort(pArray, colIdCompare);
int32_t index = 0;
FOREACH(pCol, pScanCols) {
REPLACE_NODE(taosArrayGetP(pArray, index++));
}
taosArrayDestroy(pArray);
return TSDB_CODE_SUCCESS;
}
static int32_t createScanCols(SPhysiPlanContext* pCxt, SScanPhysiNode* pScanPhysiNode, SNodeList* pScanCols) {
if (QUERY_NODE_PHYSICAL_PLAN_TABLE_SCAN == nodeType(pScanPhysiNode)
|| QUERY_NODE_PHYSICAL_PLAN_TABLE_SEQ_SCAN == nodeType(pScanPhysiNode)) {
......@@ -235,6 +262,7 @@ static int32_t createScanCols(SPhysiPlanContext* pCxt, SScanPhysiNode* pScanPhys
CHECK_ALLOC(pScanPhysiNode->pScanCols, TSDB_CODE_OUT_OF_MEMORY);
}
// return sortScanCols(pScanPhysiNode->pScanCols);
return TSDB_CODE_SUCCESS;
}
......
......@@ -112,6 +112,11 @@ private:
if (QUERY_NODE_CREATE_TOPIC_STMT == nodeType(pQuery->pRoot)) {
pCxt->pAstRoot = ((SCreateTopicStmt*)pQuery->pRoot)->pQuery;
pCxt->topicQuery = true;
} else if (QUERY_NODE_CREATE_INDEX_STMT == nodeType(pQuery->pRoot)) {
SMCreateSmaReq req = {0};
tDeserializeSMCreateSmaReq(pQuery->pCmdMsg->pMsg, pQuery->pCmdMsg->msgLen, &req);
nodesStringToNode(req.ast, &pCxt->pAstRoot);
pCxt->streamQuery = true;
} else {
pCxt->pAstRoot = pQuery->pRoot;
}
......@@ -215,3 +220,10 @@ TEST_F(PlannerTest, stream) {
bind("SELECT sum(c1) FROM st1");
ASSERT_TRUE(run(true));
}
TEST_F(PlannerTest, createSmaIndex) {
setDatabase("root", "test");
bind("create sma index index1 on t1 function(max(c1), min(c3 + 10), sum(c4)) INTERVAL(10s)");
ASSERT_TRUE(run());
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册