提交 3b9e868e 编写于 作者: X Xiaoyu Wang

fill plan implement

上级 4ff2ad2c
...@@ -206,6 +206,12 @@ static SNode* orderByExprNodeCopy(const SOrderByExprNode* pSrc, SOrderByExprNode ...@@ -206,6 +206,12 @@ static SNode* orderByExprNodeCopy(const SOrderByExprNode* pSrc, SOrderByExprNode
return (SNode*)pDst; return (SNode*)pDst;
} }
static SNode* nodeListNodeCopy(const SNodeListNode* pSrc, SNodeListNode* pDst) {
COPY_ALL_SCALAR_FIELDS;
CLONE_NODE_LIST_FIELD(pNodeList);
return (SNode*)pDst;
}
static SNode* fillNodeCopy(const SFillNode* pSrc, SFillNode* pDst) { static SNode* fillNodeCopy(const SFillNode* pSrc, SFillNode* pDst) {
COPY_SCALAR_FIELD(mode); COPY_SCALAR_FIELD(mode);
CLONE_NODE_FIELD(pValues); CLONE_NODE_FIELD(pValues);
...@@ -360,6 +366,8 @@ SNodeptr nodesCloneNode(const SNodeptr pNode) { ...@@ -360,6 +366,8 @@ SNodeptr nodesCloneNode(const SNodeptr pNode) {
return orderByExprNodeCopy((const SOrderByExprNode*)pNode, (SOrderByExprNode*)pDst); return orderByExprNodeCopy((const SOrderByExprNode*)pNode, (SOrderByExprNode*)pDst);
case QUERY_NODE_LIMIT: case QUERY_NODE_LIMIT:
break; break;
case QUERY_NODE_NODE_LIST:
return nodeListNodeCopy((const SNodeListNode*)pNode, (SNodeListNode*)pDst);
case QUERY_NODE_FILL: case QUERY_NODE_FILL:
return fillNodeCopy((const SFillNode*)pNode, (SFillNode*)pDst); return fillNodeCopy((const SFillNode*)pNode, (SFillNode*)pDst);
case QUERY_NODE_DATABLOCK_DESC: case QUERY_NODE_DATABLOCK_DESC:
......
...@@ -2015,6 +2015,31 @@ static int32_t jsonToNodeListNode(const SJson* pJson, void* pObj) { ...@@ -2015,6 +2015,31 @@ static int32_t jsonToNodeListNode(const SJson* pJson, void* pObj) {
return code; return code;
} }
static const char* jkFillMode = "Mode";
static const char* jkFillValues = "Values";
static int32_t fillNodeToJson(const void* pObj, SJson* pJson) {
const SFillNode* pNode = (const SFillNode*)pObj;
int32_t code = tjsonAddIntegerToObject(pJson, jkFillMode, pNode->mode);
if (TSDB_CODE_SUCCESS == code) {
code = tjsonAddObject(pJson, jkFillValues, nodeToJson, pNode->pValues);
}
return code;
}
static int32_t jsonToFillNode(const SJson* pJson, void* pObj) {
SFillNode* pNode = (SFillNode*)pObj;
int32_t code = tjsonGetNumberValue(pJson, jkFillMode, pNode->mode);
if (TSDB_CODE_SUCCESS == code) {
code = jsonToNodeObject(pJson, jkFillValues, &pNode->pValues);
}
return code;
}
static const char* jkTargetDataBlockId = "DataBlockId"; static const char* jkTargetDataBlockId = "DataBlockId";
static const char* jkTargetSlotId = "SlotId"; static const char* jkTargetSlotId = "SlotId";
static const char* jkTargetExpr = "Expr"; static const char* jkTargetExpr = "Expr";
...@@ -2328,6 +2353,7 @@ static int32_t specificNodeToJson(const void* pObj, SJson* pJson) { ...@@ -2328,6 +2353,7 @@ static int32_t specificNodeToJson(const void* pObj, SJson* pJson) {
case QUERY_NODE_NODE_LIST: case QUERY_NODE_NODE_LIST:
return nodeListNodeToJson(pObj, pJson); return nodeListNodeToJson(pObj, pJson);
case QUERY_NODE_FILL: case QUERY_NODE_FILL:
return fillNodeToJson(pObj, pJson);
case QUERY_NODE_RAW_EXPR: case QUERY_NODE_RAW_EXPR:
break; break;
case QUERY_NODE_TARGET: case QUERY_NODE_TARGET:
...@@ -2431,7 +2457,8 @@ static int32_t jsonToSpecificNode(const SJson* pJson, void* pObj) { ...@@ -2431,7 +2457,8 @@ static int32_t jsonToSpecificNode(const SJson* pJson, void* pObj) {
return jsonToIntervalWindowNode(pJson, pObj); return jsonToIntervalWindowNode(pJson, pObj);
case QUERY_NODE_NODE_LIST: case QUERY_NODE_NODE_LIST:
return jsonToNodeListNode(pJson, pObj); return jsonToNodeListNode(pJson, pObj);
// case QUERY_NODE_FILL: case QUERY_NODE_FILL:
return jsonToFillNode(pJson, pObj);
case QUERY_NODE_TARGET: case QUERY_NODE_TARGET:
return jsonToTargetNode(pJson, pObj); return jsonToTargetNode(pJson, pObj);
// case QUERY_NODE_RAW_EXPR: // case QUERY_NODE_RAW_EXPR:
......
...@@ -176,6 +176,7 @@ static SKeyword keywordTable[] = { ...@@ -176,6 +176,7 @@ static SKeyword keywordTable[] = {
{"USER", TK_USER}, {"USER", TK_USER},
{"USERS", TK_USERS}, {"USERS", TK_USERS},
{"USING", TK_USING}, {"USING", TK_USING},
{"VALUE", TK_VALUE},
{"VALUES", TK_VALUES}, {"VALUES", TK_VALUES},
{"VARCHAR", TK_VARCHAR}, {"VARCHAR", TK_VARCHAR},
{"VARIABLES", TK_VARIABLES}, {"VARIABLES", TK_VARIABLES},
......
...@@ -190,10 +190,16 @@ TEST_F(PlannerTest, subquery) { ...@@ -190,10 +190,16 @@ TEST_F(PlannerTest, subquery) {
TEST_F(PlannerTest, interval) { TEST_F(PlannerTest, interval) {
setDatabase("root", "test"); setDatabase("root", "test");
bind("SELECT count(*) FROM t1 interval(10s)"); // bind("SELECT count(*) FROM t1 interval(10s)");
ASSERT_TRUE(run()); // ASSERT_TRUE(run());
// bind("SELECT _wstartts, _wduration, _wendts, count(*) FROM t1 interval(10s)");
// ASSERT_TRUE(run());
// bind("SELECT count(*) FROM t1 interval(10s) fill(linear)");
// ASSERT_TRUE(run());
bind("SELECT _wstartts, _wduration, _wendts, count(*) FROM t1 interval(10s)"); bind("SELECT count(*), sum(c1) FROM t1 interval(10s) fill(value, 10, 20)");
ASSERT_TRUE(run()); ASSERT_TRUE(run());
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册