Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
e0a51d43
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22017
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看板
提交
e0a51d43
编写于
5月 14, 2022
作者:
X
Xiaoyu Wang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix: 'union [all]' syntax problems
上级
39f7c276
变更
7
展开全部
隐藏空白更改
内联
并排
Showing
7 changed file
with
675 addition
and
628 deletion
+675
-628
include/libs/nodes/querynodes.h
include/libs/nodes/querynodes.h
+1
-0
source/libs/nodes/src/nodesUtilFuncs.c
source/libs/nodes/src/nodesUtilFuncs.c
+13
-0
source/libs/parser/inc/sql.y
source/libs/parser/inc/sql.y
+3
-3
source/libs/parser/src/parTranslater.c
source/libs/parser/src/parTranslater.c
+6
-1
source/libs/parser/src/sql.c
source/libs/parser/src/sql.c
+638
-621
source/libs/parser/test/parSelectTest.cpp
source/libs/parser/test/parSelectTest.cpp
+8
-0
source/libs/planner/test/planSubqueryTest.cpp
source/libs/planner/test/planSubqueryTest.cpp
+6
-3
未找到文件。
include/libs/nodes/querynodes.h
浏览文件 @
e0a51d43
...
...
@@ -345,6 +345,7 @@ bool nodesIsUnaryOp(const SOperatorNode* pOp);
bool
nodesIsArithmeticOp
(
const
SOperatorNode
*
pOp
);
bool
nodesIsComparisonOp
(
const
SOperatorNode
*
pOp
);
bool
nodesIsJsonOp
(
const
SOperatorNode
*
pOp
);
bool
nodesIsRegularOp
(
const
SOperatorNode
*
pOp
);
bool
nodesIsTimeorderQuery
(
const
SNode
*
pQuery
);
bool
nodesIsTimelineQuery
(
const
SNode
*
pQuery
);
...
...
source/libs/nodes/src/nodesUtilFuncs.c
浏览文件 @
e0a51d43
...
...
@@ -1112,6 +1112,19 @@ bool nodesIsJsonOp(const SOperatorNode* pOp) {
return
false
;
}
bool
nodesIsRegularOp
(
const
SOperatorNode
*
pOp
)
{
switch
(
pOp
->
opType
)
{
case
OP_TYPE_LIKE
:
case
OP_TYPE_NOT_LIKE
:
case
OP_TYPE_MATCH
:
case
OP_TYPE_NMATCH
:
return
true
;
default:
break
;
}
return
false
;
}
bool
nodesIsTimeorderQuery
(
const
SNode
*
pQuery
)
{
return
false
;
}
bool
nodesIsTimelineQuery
(
const
SNode
*
pQuery
)
{
return
false
;
}
...
...
source/libs/parser/inc/sql.y
浏览文件 @
e0a51d43
...
...
@@ -868,9 +868,9 @@ query_expression_body(A) ::=
query_expression_body(B) UNION query_expression_body(D). { A = createSetOperator(pCxt, SET_OP_TYPE_UNION, B, D); }
query_primary(A) ::= query_specification(B). { A = B; }
//
query_primary(A) ::=
//
NK_LP query_expression_body(B)
//
order_by_clause_opt slimit_clause_opt limit_clause_opt NK_RP. { A = B; }
query_primary(A) ::=
NK_LP query_expression_body(B)
order_by_clause_opt slimit_clause_opt limit_clause_opt NK_RP. { A = B; }
%type order_by_clause_opt { SNodeList* }
%destructor order_by_clause_opt { nodesDestroyList($$); }
...
...
source/libs/parser/src/parTranslater.c
浏览文件 @
e0a51d43
...
...
@@ -635,6 +635,11 @@ static EDealRes translateOperator(STranslateContext* pCxt, SOperatorNode* pOp) {
if
(
OP_TYPE_IN
==
pOp
->
opType
||
OP_TYPE_NOT_IN
==
pOp
->
opType
)
{
((
SExprNode
*
)
pOp
->
pRight
)
->
resType
=
((
SExprNode
*
)
pOp
->
pLeft
)
->
resType
;
}
if
(
nodesIsRegularOp
(
pOp
))
{
if
(
QUERY_NODE_VALUE
!=
nodeType
(
pOp
->
pRight
)
||
!
IS_STR_DATA_TYPE
(((
SExprNode
*
)(
pOp
->
pRight
))
->
resType
.
type
))
{
return
generateDealNodeErrMsg
(
pCxt
,
TSDB_CODE_PAR_WRONG_VALUE_TYPE
,
((
SExprNode
*
)(
pOp
->
pRight
))
->
aliasName
);
}
}
pOp
->
node
.
resType
.
type
=
TSDB_DATA_TYPE_BOOL
;
pOp
->
node
.
resType
.
bytes
=
tDataTypes
[
TSDB_DATA_TYPE_BOOL
].
bytes
;
}
else
if
(
nodesIsJsonOp
(
pOp
))
{
...
...
@@ -3842,7 +3847,7 @@ static int32_t addValToKVRow(STranslateContext* pCxt, SValueNode* pVal, const SS
if
(
pVal
->
node
.
resType
.
type
==
TSDB_DATA_TYPE_NULL
)
{
// todo
}
else
{
tdAddColToKVRow
(
pBuilder
,
pSchema
->
colId
,
&
(
pVal
->
datum
.
p
),
tdAddColToKVRow
(
pBuilder
,
pSchema
->
colId
,
nodesGetValueFromNode
(
pVal
->
datum
.
p
),
IS_VAR_DATA_TYPE
(
pSchema
->
type
)
?
varDataTLen
(
pVal
->
datum
.
p
)
:
TYPE_BYTES
[
pSchema
->
type
]);
}
...
...
source/libs/parser/src/sql.c
浏览文件 @
e0a51d43
此差异已折叠。
点击以展开。
source/libs/parser/test/parSelectTest.cpp
浏览文件 @
e0a51d43
...
...
@@ -232,4 +232,12 @@ TEST_F(ParserSelectTest, semanticError) {
PARSER_STAGE_TRANSLATE
);
}
TEST_F
(
ParserSelectTest
,
setOperator
)
{
useDb
(
"root"
,
"test"
);
run
(
"SELECT * FROM t1 UNION ALL SELECT * FROM t1"
);
run
(
"(SELECT * FROM t1) UNION ALL (SELECT * FROM t1)"
);
}
}
// namespace ParserTest
source/libs/planner/test/planSubqueryTest.cpp
浏览文件 @
e0a51d43
...
...
@@ -23,12 +23,15 @@ class PlanSubqeuryTest : public PlannerTestBase {};
TEST_F
(
PlanSubqeuryTest
,
basic
)
{
useDb
(
"root"
,
"test"
);
run
(
"select * from (select * from t1)"
);
run
(
"SELECT * FROM (SELECT * FROM t1)"
);
run
(
"SELECT LAST(c1) FROM ( SELECT * FROM t1)"
);
}
TEST_F
(
PlanSubqeuryTest
,
doubleGroupBy
)
{
useDb
(
"root"
,
"test"
);
run
(
"select count(*) from (select c1 + c3 a, c1 + count(*) b from t1 where c2 = 'abc' group by c1, c3) where a > 100 "
"group by b"
);
run
(
"SELECT COUNT(*) FROM ("
"SELECT c1 + c3 a, c1 + COUNT(*) b FROM t1 WHERE c2 = 'abc' GROUP BY c1, c3) "
"WHERE a > 100 GROUP BY b"
);
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录