Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
9f45f81a
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
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看板
提交
9f45f81a
编写于
9月 22, 2022
作者:
X
Xiaoyu Wang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix: join validity check
上级
0321b8c0
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
24 addition
and
7 deletion
+24
-7
include/util/taoserror.h
include/util/taoserror.h
+1
-1
source/libs/parser/src/parTranslater.c
source/libs/parser/src/parTranslater.c
+14
-0
source/libs/parser/test/parSelectTest.cpp
source/libs/parser/test/parSelectTest.cpp
+7
-0
source/libs/planner/test/planJoinTest.cpp
source/libs/planner/test/planJoinTest.cpp
+2
-6
未找到文件。
include/util/taoserror.h
浏览文件 @
9f45f81a
...
...
@@ -552,7 +552,6 @@ int32_t* taosGetErrno();
#define TSDB_CODE_PAR_VALUE_TOO_LONG TAOS_DEF_ERROR_CODE(0, 0x2653)
#define TSDB_CODE_PAR_INVALID_DELETE_WHERE TAOS_DEF_ERROR_CODE(0, 0x2655)
#define TSDB_CODE_PAR_INVALID_REDISTRIBUTE_VG TAOS_DEF_ERROR_CODE(0, 0x2656)
#define TSDB_CODE_PAR_FILL_NOT_ALLOWED_FUNC TAOS_DEF_ERROR_CODE(0, 0x2657)
#define TSDB_CODE_PAR_INVALID_WINDOW_PC TAOS_DEF_ERROR_CODE(0, 0x2658)
#define TSDB_CODE_PAR_WINDOW_NOT_ALLOWED_FUNC TAOS_DEF_ERROR_CODE(0, 0x2659)
...
...
@@ -565,6 +564,7 @@ int32_t* taosGetErrno();
#define TSDB_CODE_PAR_INVALID_SELECTED_EXPR TAOS_DEF_ERROR_CODE(0, 0x2661)
#define TSDB_CODE_PAR_GET_META_ERROR TAOS_DEF_ERROR_CODE(0, 0x2662)
#define TSDB_CODE_PAR_NOT_UNIQUE_TABLE_ALIAS TAOS_DEF_ERROR_CODE(0, 0x2663)
#define TSDB_CODE_PAR_NOT_SUPPORT_JOIN TAOS_DEF_ERROR_CODE(0, 0x2664)
#define TSDB_CODE_PAR_INTERNAL_ERROR TAOS_DEF_ERROR_CODE(0, 0x26FF)
//planner
...
...
source/libs/parser/src/parTranslater.c
浏览文件 @
9f45f81a
...
...
@@ -2213,6 +2213,17 @@ static int32_t setTableCacheLastMode(STranslateContext* pCxt, SSelectStmt* pSele
return
code
;
}
static
int32_t
checkJoinTable
(
STranslateContext
*
pCxt
,
SJoinTableNode
*
pJoinTable
)
{
if
((
QUERY_NODE_TEMP_TABLE
==
nodeType
(
pJoinTable
->
pLeft
)
&&
!
isTimeLineQuery
(((
STempTableNode
*
)
pJoinTable
->
pLeft
)
->
pSubquery
))
||
(
QUERY_NODE_TEMP_TABLE
==
nodeType
(
pJoinTable
->
pRight
)
&&
!
isTimeLineQuery
(((
STempTableNode
*
)
pJoinTable
->
pRight
)
->
pSubquery
)))
{
return
generateSyntaxErrMsgExt
(
&
pCxt
->
msgBuf
,
TSDB_CODE_PAR_NOT_SUPPORT_JOIN
,
"Join requires valid time series input"
);
}
return
TSDB_CODE_SUCCESS
;
}
static
int32_t
translateTable
(
STranslateContext
*
pCxt
,
SNode
*
pTable
)
{
int32_t
code
=
TSDB_CODE_SUCCESS
;
switch
(
nodeType
(
pTable
))
{
...
...
@@ -2259,6 +2270,9 @@ static int32_t translateTable(STranslateContext* pCxt, SNode* pTable) {
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
translateTable
(
pCxt
,
pJoinTable
->
pRight
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
checkJoinTable
(
pCxt
,
pJoinTable
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
pJoinTable
->
table
.
precision
=
calcJoinTablePrecision
(
pJoinTable
);
pJoinTable
->
table
.
singleTable
=
joinTableIsSingleTable
(
pJoinTable
);
...
...
source/libs/parser/test/parSelectTest.cpp
浏览文件 @
9f45f81a
...
...
@@ -445,4 +445,11 @@ TEST_F(ParserSelectTest, withoutFromSemanticCheck) {
run
(
"SELECT TBNAME"
,
TSDB_CODE_PAR_INVALID_TBNAME
);
}
TEST_F
(
ParserSelectTest
,
joinSemanticCheck
)
{
useDb
(
"root"
,
"test"
);
run
(
"SELECT * FROM (SELECT tag1, SUM(c1) s FROM st1 GROUP BY tag1) t1, st1 t2 where t1.tag1 = t2.tag1"
,
TSDB_CODE_PAR_NOT_SUPPORT_JOIN
);
}
}
// namespace ParserTest
source/libs/planner/test/planJoinTest.cpp
浏览文件 @
9f45f81a
...
...
@@ -28,6 +28,8 @@ TEST_F(PlanJoinTest, basic) {
run
(
"SELECT t1.*, t2.* FROM st1s1 t1, st1s2 t2 WHERE t1.ts = t2.ts"
);
run
(
"SELECT t1.c1, t2.c1 FROM st1s1 t1 JOIN st1s2 t2 ON t1.ts = t2.ts"
);
run
(
"SELECT t1.c1, t2.c1 FROM st1 t1 JOIN st2 t2 ON t1.ts = t2.ts"
);
}
TEST_F
(
PlanJoinTest
,
complex
)
{
...
...
@@ -56,9 +58,3 @@ TEST_F(PlanJoinTest, multiJoin) {
run
(
"SELECT t1.c1, t2.c1 FROM st1s1 t1 JOIN st1s2 t2 ON t1.ts = t2.ts JOIN st1s3 t3 ON t1.ts = t3.ts"
);
}
TEST_F
(
PlanJoinTest
,
stable
)
{
useDb
(
"root"
,
"test"
);
run
(
"SELECT t1.c1, t2.c1 FROM st1 t1 JOIN st2 t2 ON t1.ts = t2.ts "
);
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录