Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
9ef7db39
T
TDengine
项目概览
taosdata
/
TDengine
大约 1 年 前同步成功
通知
1184
Star
22015
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
9ef7db39
编写于
4月 07, 2022
作者:
X
Xiaoyu Wang
提交者:
GitHub
4月 07, 2022
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #11296 from taosdata/feature/3.0_wxy
sort plan bugfix
上级
aa2396ac
07892f0f
变更
11
展开全部
显示空白变更内容
内联
并排
Showing
11 changed file
with
988 addition
and
945 deletion
+988
-945
include/common/ttokendef.h
include/common/ttokendef.h
+44
-44
include/libs/nodes/plannodes.h
include/libs/nodes/plannodes.h
+2
-0
include/libs/nodes/querynodes.h
include/libs/nodes/querynodes.h
+1
-0
source/libs/nodes/src/nodesCodeFuncs.c
source/libs/nodes/src/nodesCodeFuncs.c
+14
-0
source/libs/nodes/src/nodesTraverseFuncs.c
source/libs/nodes/src/nodesTraverseFuncs.c
+6
-4
source/libs/parser/inc/sql.y
source/libs/parser/inc/sql.y
+2
-0
source/libs/parser/src/parTokenizer.c
source/libs/parser/src/parTokenizer.c
+3
-0
source/libs/parser/src/sql.c
source/libs/parser/src/sql.c
+902
-894
source/libs/planner/src/planLogicCreater.c
source/libs/planner/src/planLogicCreater.c
+1
-1
source/libs/planner/src/planPhysiCreater.c
source/libs/planner/src/planPhysiCreater.c
+10
-2
source/libs/planner/test/plannerTest.cpp
source/libs/planner/test/plannerTest.cpp
+3
-0
未找到文件。
include/common/ttokendef.h
浏览文件 @
9ef7db39
...
...
@@ -173,50 +173,50 @@
#define TK_SPLIT 155
#define TK_SYNCDB 156
#define TK_NULL 157
#define TK_
NOW
158
#define TK_
ROWTS
159
#define TK_
TBNAME
160
#define TK_
QSTARTTS
161
#define TK_
QENDTS
162
#define TK_
W
STARTTS 163
#define TK_
W
ENDTS 164
#define TK_W
DURATION
165
#define TK_
BETWEEN
166
#define TK_
IS
167
#define TK_
NK_LT
168
#define TK_
NK_GT
169
#define TK_NK_L
E
170
#define TK_NK_G
E
171
#define TK_NK_
N
E 172
#define TK_
MATCH
173
#define TK_N
MATCH
174
#define TK_
JOIN
175
#define TK_
INNER
176
#define TK_
SELECT
177
#define TK_
DISTINCT
178
#define TK_
WHERE
179
#define TK_
PARTITION
180
#define TK_
BY
181
#define TK_
SESSION
182
#define TK_
STATE_WINDOW
183
#define TK_S
LIDING
184
#define TK_
FILL
185
#define TK_
VALUE
186
#define TK_
NONE
187
#define TK_
PREV
188
#define TK_
LINEAR
189
#define TK_
NEXT
190
#define TK_
GROUP
191
#define TK_
HAVING
192
#define TK_
ORDER
193
#define TK_
SLIMIT
194
#define TK_
SOFFSET
195
#define TK_
LIMIT
196
#define TK_
OFFSET
197
#define TK_
ASC
198
#define TK_
NULLS
199
#define TK_
FIRST
200
#define TK_
LAST
201
#define TK_
FIRST
158
#define TK_
LAST
159
#define TK_
NOW
160
#define TK_
ROWTS
161
#define TK_
TBNAME
162
#define TK_
Q
STARTTS 163
#define TK_
Q
ENDTS 164
#define TK_W
STARTTS
165
#define TK_
WENDTS
166
#define TK_
WDURATION
167
#define TK_
BETWEEN
168
#define TK_
IS
169
#define TK_NK_L
T
170
#define TK_NK_G
T
171
#define TK_NK_
L
E 172
#define TK_
NK_GE
173
#define TK_N
K_NE
174
#define TK_
MATCH
175
#define TK_
NMATCH
176
#define TK_
JOIN
177
#define TK_
INNER
178
#define TK_
SELECT
179
#define TK_
DISTINCT
180
#define TK_
WHERE
181
#define TK_
PARTITION
182
#define TK_
BY
183
#define TK_S
ESSION
184
#define TK_
STATE_WINDOW
185
#define TK_
SLIDING
186
#define TK_
FILL
187
#define TK_
VALUE
188
#define TK_
NONE
189
#define TK_
PREV
190
#define TK_
LINEAR
191
#define TK_
NEXT
192
#define TK_
GROUP
193
#define TK_
HAVING
194
#define TK_
ORDER
195
#define TK_
SLIMIT
196
#define TK_
SOFFSET
197
#define TK_
LIMIT
198
#define TK_
OFFSET
199
#define TK_
ASC
200
#define TK_
NULLS
201
#define TK_NK_SPACE 300
#define TK_NK_COMMENT 301
...
...
include/libs/nodes/plannodes.h
浏览文件 @
9ef7db39
...
...
@@ -286,12 +286,14 @@ typedef struct SSortPhysiNode {
SPhysiNode
node
;
SNodeList
*
pExprs
;
// these are expression list of order_by_clause and parameter expression of aggregate function
SNodeList
*
pSortKeys
;
// element is SOrderByExprNode, and SOrderByExprNode::pExpr is SColumnNode
SNodeList
*
pTargets
;
}
SSortPhysiNode
;
typedef
struct
SPartitionPhysiNode
{
SPhysiNode
node
;
SNodeList
*
pExprs
;
// these are expression list of partition_by_clause
SNodeList
*
pPartitionKeys
;
SNodeList
*
pTargets
;
}
SPartitionPhysiNode
;
typedef
struct
SDataSinkNode
{
...
...
include/libs/nodes/querynodes.h
浏览文件 @
9ef7db39
...
...
@@ -258,6 +258,7 @@ typedef enum ESqlClause {
SQL_CLAUSE_WINDOW
,
SQL_CLAUSE_GROUP_BY
,
SQL_CLAUSE_HAVING
,
SQL_CLAUSE_DISTINCT
,
SQL_CLAUSE_SELECT
,
SQL_CLAUSE_ORDER_BY
}
ESqlClause
;
...
...
source/libs/nodes/src/nodesCodeFuncs.c
浏览文件 @
9ef7db39
...
...
@@ -994,6 +994,7 @@ static int32_t jsonToPhysiExchangeNode(const SJson* pJson, void* pObj) {
static
const
char
*
jkSortPhysiPlanExprs
=
"Exprs"
;
static
const
char
*
jkSortPhysiPlanSortKeys
=
"SortKeys"
;
static
const
char
*
jkSortPhysiPlanTargets
=
"Targets"
;
static
int32_t
physiSortNodeToJson
(
const
void
*
pObj
,
SJson
*
pJson
)
{
const
SSortPhysiNode
*
pNode
=
(
const
SSortPhysiNode
*
)
pObj
;
...
...
@@ -1005,6 +1006,9 @@ static int32_t physiSortNodeToJson(const void* pObj, SJson* pJson) {
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
nodeListToJson
(
pJson
,
jkSortPhysiPlanSortKeys
,
pNode
->
pSortKeys
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
nodeListToJson
(
pJson
,
jkSortPhysiPlanTargets
,
pNode
->
pTargets
);
}
return
code
;
}
...
...
@@ -1019,6 +1023,9 @@ static int32_t jsonToPhysiSortNode(const SJson* pJson, void* pObj) {
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
jsonToNodeList
(
pJson
,
jkSortPhysiPlanSortKeys
,
&
pNode
->
pSortKeys
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
jsonToNodeList
(
pJson
,
jkSortPhysiPlanTargets
,
&
pNode
->
pTargets
);
}
return
code
;
}
...
...
@@ -1177,6 +1184,7 @@ static int32_t jsonToPhysiStateWindowNode(const SJson* pJson, void* pObj) {
static
const
char
*
jkPartitionPhysiPlanExprs
=
"Exprs"
;
static
const
char
*
jkPartitionPhysiPlanPartitionKeys
=
"PartitionKeys"
;
static
const
char
*
jkPartitionPhysiPlanTargets
=
"Targets"
;
static
int32_t
physiPartitionNodeToJson
(
const
void
*
pObj
,
SJson
*
pJson
)
{
const
SPartitionPhysiNode
*
pNode
=
(
const
SPartitionPhysiNode
*
)
pObj
;
...
...
@@ -1188,6 +1196,9 @@ static int32_t physiPartitionNodeToJson(const void* pObj, SJson* pJson) {
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
nodeListToJson
(
pJson
,
jkPartitionPhysiPlanPartitionKeys
,
pNode
->
pPartitionKeys
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
nodeListToJson
(
pJson
,
jkPartitionPhysiPlanTargets
,
pNode
->
pTargets
);
}
return
code
;
}
...
...
@@ -1202,6 +1213,9 @@ static int32_t jsonToPhysiPartitionNode(const SJson* pJson, void* pObj) {
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
jsonToNodeList
(
pJson
,
jkPartitionPhysiPlanPartitionKeys
,
&
pNode
->
pPartitionKeys
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
jsonToNodeList
(
pJson
,
jkPartitionPhysiPlanTargets
,
&
pNode
->
pTargets
);
}
return
code
;
}
...
...
source/libs/nodes/src/nodesTraverseFuncs.c
浏览文件 @
9ef7db39
...
...
@@ -301,9 +301,10 @@ void nodesWalkSelectStmt(SSelectStmt* pSelect, ESqlClause clause, FNodeWalker wa
case
SQL_CLAUSE_GROUP_BY
:
nodesWalkExpr
(
pSelect
->
pHaving
,
walker
,
pContext
);
case
SQL_CLAUSE_HAVING
:
nodesWalkExprs
(
pSelect
->
pProjectionList
,
walker
,
pContext
);
case
SQL_CLAUSE_SELECT
:
case
SQL_CLAUSE_DISTINCT
:
nodesWalkExprs
(
pSelect
->
pOrderByList
,
walker
,
pContext
);
case
SQL_CLAUSE_ORDER_BY
:
nodesWalkExprs
(
pSelect
->
pProjectionList
,
walker
,
pContext
);
default:
break
;
}
...
...
@@ -329,9 +330,10 @@ void nodesRewriteSelectStmt(SSelectStmt* pSelect, ESqlClause clause, FNodeRewrit
case
SQL_CLAUSE_GROUP_BY
:
nodesRewriteExpr
(
&
(
pSelect
->
pHaving
),
rewriter
,
pContext
);
case
SQL_CLAUSE_HAVING
:
nodesRewriteExprs
(
pSelect
->
pProjectionList
,
rewriter
,
pContext
);
case
SQL_CLAUSE_SELECT
:
case
SQL_CLAUSE_DISTINCT
:
nodesRewriteExprs
(
pSelect
->
pOrderByList
,
rewriter
,
pContext
);
case
SQL_CLAUSE_ORDER_BY
:
nodesRewriteExprs
(
pSelect
->
pProjectionList
,
rewriter
,
pContext
);
default:
break
;
}
...
...
source/libs/parser/inc/sql.y
浏览文件 @
9ef7db39
...
...
@@ -486,6 +486,8 @@ column_name(A) ::= NK_ID(B).
%type function_name { SToken }
%destructor function_name { }
function_name(A) ::= NK_ID(B). { A = B; }
function_name(A) ::= FIRST(B). { A = B; }
function_name(A) ::= LAST(B). { A = B; }
%type table_alias { SToken }
%destructor table_alias { }
...
...
source/libs/parser/src/parTokenizer.c
浏览文件 @
9ef7db39
...
...
@@ -72,6 +72,7 @@ static SKeyword keywordTable[] = {
{
"EXPLAIN"
,
TK_EXPLAIN
},
{
"FILE_FACTOR"
,
TK_FILE_FACTOR
},
{
"FILL"
,
TK_FILL
},
{
"FIRST"
,
TK_FIRST
},
{
"FLOAT"
,
TK_FLOAT
},
{
"FROM"
,
TK_FROM
},
{
"FSYNC"
,
TK_FSYNC
},
...
...
@@ -95,6 +96,7 @@ static SKeyword keywordTable[] = {
{
"JSON"
,
TK_JSON
},
{
"KEEP"
,
TK_KEEP
},
{
"KILL"
,
TK_KILL
},
{
"LAST"
,
TK_LAST
},
{
"LICENCE"
,
TK_LICENCE
},
{
"LIKE"
,
TK_LIKE
},
{
"LIMIT"
,
TK_LIMIT
},
...
...
@@ -113,6 +115,7 @@ static SKeyword keywordTable[] = {
{
"NOT"
,
TK_NOT
},
{
"NOW"
,
TK_NOW
},
{
"NULL"
,
TK_NULL
},
{
"NULLS"
,
TK_NULLS
},
{
"OFFSET"
,
TK_OFFSET
},
{
"ON"
,
TK_ON
},
{
"OR"
,
TK_OR
},
...
...
source/libs/parser/src/sql.c
浏览文件 @
9ef7db39
此差异已折叠。
点击以展开。
source/libs/planner/src/planLogicCreater.c
浏览文件 @
9ef7db39
...
...
@@ -701,7 +701,7 @@ static int32_t createDistinctLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSe
// rewrite the expression in subsequent clauses
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
rewriteExpr
(
pAgg
->
pGroupKeys
,
pSelect
,
SQL_CLAUSE_
SELE
CT
);
code
=
rewriteExpr
(
pAgg
->
pGroupKeys
,
pSelect
,
SQL_CLAUSE_
DISTIN
CT
);
}
// set the output
...
...
source/libs/planner/src/planPhysiCreater.c
浏览文件 @
9ef7db39
...
...
@@ -928,8 +928,12 @@ static int32_t createSortPhysiNode(SPhysiPlanContext* pCxt, SNodeList* pChildren
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
setListSlotId
(
pCxt
,
pChildTupe
->
dataBlockId
,
-
1
,
pSortKeys
,
&
pSort
->
pSortKeys
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
setListSlotId
(
pCxt
,
pChildTupe
->
dataBlockId
,
-
1
,
pSortLogicNode
->
node
.
pTargets
,
&
pSort
->
pTargets
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
addDataBlockSlots
(
pCxt
,
pSort
->
p
SortKey
s
,
pSort
->
node
.
pOutputDataBlockDesc
);
code
=
addDataBlockSlots
(
pCxt
,
pSort
->
p
Target
s
,
pSort
->
node
.
pOutputDataBlockDesc
);
}
}
...
...
@@ -963,8 +967,12 @@ static int32_t createPartitionPhysiNode(SPhysiPlanContext* pCxt, SNodeList* pChi
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
setListSlotId
(
pCxt
,
pChildTupe
->
dataBlockId
,
-
1
,
pPartitionKeys
,
&
pPart
->
pPartitionKeys
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
setListSlotId
(
pCxt
,
pChildTupe
->
dataBlockId
,
-
1
,
pPartLogicNode
->
node
.
pTargets
,
&
pPart
->
pTargets
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
addDataBlockSlots
(
pCxt
,
pPart
->
p
PartitionKey
s
,
pPart
->
node
.
pOutputDataBlockDesc
);
code
=
addDataBlockSlots
(
pCxt
,
pPart
->
p
Target
s
,
pPart
->
node
.
pOutputDataBlockDesc
);
}
}
...
...
source/libs/planner/test/plannerTest.cpp
浏览文件 @
9ef7db39
...
...
@@ -254,6 +254,9 @@ TEST_F(PlannerTest, orderBy) {
bind
(
"SELECT * FROM t1 order by c1 + 10, c2"
);
ASSERT_TRUE
(
run
());
bind
(
"SELECT * FROM t1 order by c1 desc nulls first"
);
ASSERT_TRUE
(
run
());
}
TEST_F
(
PlannerTest
,
distinct
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录