Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
哥们要飞
TDengine
提交
09c89d94
T
TDengine
项目概览
哥们要飞
/
TDengine
与 Fork 源项目一致
Fork自
taosdata / TDengine
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
09c89d94
编写于
7月 07, 2020
作者:
H
Haojun Liao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[td-225] handle the case where no qualified ts exists during join query process.
上级
96da5e23
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
30 addition
and
40 deletion
+30
-40
src/client/src/tscSubquery.c
src/client/src/tscSubquery.c
+18
-40
tests/script/general/parser/join.sim
tests/script/general/parser/join.sim
+12
-0
未找到文件。
src/client/src/tscSubquery.c
浏览文件 @
09c89d94
...
...
@@ -57,10 +57,15 @@ static int64_t doTSBlockIntersect(SSqlObj* pSql, SJoinSupporter* pSupporter1, SJ
pSubQueryInfo1
->
tsBuf
=
output1
;
pSubQueryInfo2
->
tsBuf
=
output2
;
// no result generated, return directly
if
(
pSupporter1
->
pTSBuf
==
NULL
||
pSupporter2
->
pTSBuf
==
NULL
)
{
tscDebug
(
"%p at least one ts-comp is empty, 0 for secondary query after ts blocks intersecting"
,
pSql
);
return
0
;
}
tsBufResetPos
(
pSupporter1
->
pTSBuf
);
tsBufResetPos
(
pSupporter2
->
pTSBuf
);
// TODO add more details information
if
(
!
tsBufNextPos
(
pSupporter1
->
pTSBuf
))
{
tsBufFlush
(
output1
);
tsBufFlush
(
output2
);
...
...
@@ -420,43 +425,6 @@ static void updateQueryTimeRange(SQueryInfo* pQueryInfo, STimeWindow* win) {
pQueryInfo
->
window
=
*
win
;
}
static
UNUSED_FUNC
void
tSIntersectionAndLaunchSecQuery
(
SJoinSupporter
*
pSupporter
,
SSqlObj
*
pSql
)
{
SSqlObj
*
pParentSql
=
pSupporter
->
pObj
;
SQueryInfo
*
pParentQueryInfo
=
tscGetQueryInfoDetail
(
&
pParentSql
->
cmd
,
pParentSql
->
cmd
.
clauseIndex
);
// if (tscNonOrderedProjectionQueryOnSTable(pParentQueryInfo, 0)) {
// STableMetaInfo* pTableMetaInfo = tscGetMetaInfo(pQueryInfo, 0);
// assert(pQueryInfo->numOfTables == 1);
//
// // for projection query, need to try next vnode
//// int32_t totalVnode = pTableMetaInfo->pMetricMeta->numOfVnodes;
// int32_t totalVnode = 0;
// if ((++pTableMetaInfo->vgroupIndex) < totalVnode) {
// tscDebug("%p current vnode:%d exhausted, try next:%d. total vnode:%d. current numOfRes:%d", pSql,
// pTableMetaInfo->vgroupIndex - 1, pTableMetaInfo->vgroupIndex, totalVnode, pRes->numOfTotal);
//
// pSql->cmd.command = TSDB_SQL_SELECT;
// pSql->fp = tscJoinQueryCallback;
// tscProcessSql(pSql);
//
// return;
// }
// }
SJoinSupporter
*
p1
=
pParentSql
->
pSubs
[
0
]
->
param
;
SJoinSupporter
*
p2
=
pParentSql
->
pSubs
[
1
]
->
param
;
STimeWindow
win
=
TSWINDOW_INITIALIZER
;
int64_t
num
=
doTSBlockIntersect
(
pParentSql
,
p1
,
p2
,
&
win
);
if
(
num
<=
0
)
{
// no result during ts intersect
tscDebug
(
"%p free all sub SqlObj and quit"
,
pParentSql
);
freeJoinSubqueryObj
(
pParentSql
);
}
else
{
updateQueryTimeRange
(
pParentQueryInfo
,
&
win
);
tscLaunchRealSubqueries
(
pParentSql
);
}
}
int32_t
tscCompareTidTags
(
const
void
*
p1
,
const
void
*
p2
)
{
const
STidTags
*
t1
=
(
const
STidTags
*
)
varDataVal
(
p1
);
const
STidTags
*
t2
=
(
const
STidTags
*
)
varDataVal
(
p2
);
...
...
@@ -713,9 +681,16 @@ static void tidTagRetrieveCallback(void* param, TAOS_RES* tres, int32_t numOfRow
SArray
*
s1
=
NULL
,
*
s2
=
NULL
;
getIntersectionOfTableTuple
(
pQueryInfo
,
pParentSql
,
&
s1
,
&
s2
);
if
(
taosArrayGetSize
(
s1
)
==
0
||
taosArrayGetSize
(
s2
)
==
0
)
{
// no results,return.
tscDebug
(
"%p free all sub SqlObj and quit"
,
pParentSql
);
taosArrayDestroy
(
s1
);
taosArrayDestroy
(
s2
);
tscDebug
(
"%p tag intersect does not generated qualified tables for join, free all sub SqlObj and quit"
,
pParentSql
);
freeJoinSubqueryObj
(
pParentSql
);
// set no result command
pParentSql
->
cmd
.
command
=
TSDB_SQL_RETRIEVE_EMPTY_RESULT
;
(
*
pParentSql
->
fp
)(
pSql
->
param
,
pParentSql
,
0
);
}
else
{
// proceed to for ts_comp query
SSqlCmd
*
pSubCmd1
=
&
pParentSql
->
pSubs
[
0
]
->
cmd
;
...
...
@@ -846,7 +821,10 @@ static void tsCompRetrieveCallback(void* param, TAOS_RES* tres, int32_t numOfRow
if
(
num
<=
0
)
{
// no result during ts intersect
tscDebug
(
"%p no results generated in ts intersection, free all sub SqlObj and quit"
,
pParentSql
);
freeJoinSubqueryObj
(
pParentSql
);
// set no result command
pParentSql
->
cmd
.
command
=
TSDB_SQL_RETRIEVE_EMPTY_RESULT
;
(
*
pParentSql
->
fp
)(
pSql
->
param
,
pParentSql
,
0
);
return
;
}
...
...
tests/script/general/parser/join.sim
浏览文件 @
09c89d94
...
...
@@ -447,4 +447,16 @@ sql insert into um2 using m2 tags(9) values(1000001, 10)(2000000, 20);
sql_error select count(*) from m1,m2 where m1.a=m2.a and m1.ts=m2.ts;
#empty table join test, add for no result join test
create database ux1;
use ux1;
create table m1(ts timestamp, k int) tags(a binary(12), b int);
create table tm0 using m1 tags('abc', 1);
create table m2(ts timestamp, k int) tags(a int, b binary(12));
create table tm2 using m2 tags(2, 'abc');
select count(*) from tm0, tm2 where tm0.ts=tm2.ts;
select count(*) from m1, m2 where m1.ts=m2.ts and m1.b=m2.a
drop database ux1;
system sh/exec.sh -n dnode1 -s stop -x SIGINT
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录