Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
3ae81303
T
TDengine
项目概览
taosdata
/
TDengine
大约 2 年 前同步成功
通知
1192
Star
22018
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看板
提交
3ae81303
编写于
12月 31, 2021
作者:
A
Alex Duan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[TS-802]<fix>(query): reset to master code and modify param3
上级
6b575b5e
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
75 addition
and
26 deletion
+75
-26
src/client/src/tscUtil.c
src/client/src/tscUtil.c
+3
-3
src/query/src/qAggMain.c
src/query/src/qAggMain.c
+62
-23
src/query/src/qExecutor.c
src/query/src/qExecutor.c
+10
-0
未找到文件。
src/client/src/tscUtil.c
浏览文件 @
3ae81303
...
@@ -1347,9 +1347,9 @@ void handleDownstreamOperator(SSqlObj** pSqlObjList, int32_t numOfUpstream, SQue
...
@@ -1347,9 +1347,9 @@ void handleDownstreamOperator(SSqlObj** pSqlObjList, int32_t numOfUpstream, SQue
// set input order
// set input order
SQueryInfo
*
pInputQI
=
pSqlObjList
[
0
]
->
cmd
.
pQueryInfo
;
SQueryInfo
*
pInputQI
=
pSqlObjList
[
0
]
->
cmd
.
pQueryInfo
;
if
(
pInputQI
)
{
if
(
pInputQI
)
{
pex
->
base
.
numOfParams
=
2
;
pex
->
base
.
numOfParams
=
3
;
pex
->
base
.
param
[
1
].
nType
=
TSDB_DATA_TYPE_INT
;
pex
->
base
.
param
[
2
].
nType
=
TSDB_DATA_TYPE_INT
;
pex
->
base
.
param
[
1
].
i64
=
pInputQI
->
order
.
order
;
pex
->
base
.
param
[
2
].
i64
=
pInputQI
->
order
.
order
;
}
}
}
}
}
}
...
...
src/query/src/qAggMain.c
浏览文件 @
3ae81303
...
@@ -698,6 +698,10 @@ static int32_t dataBlockRequired(SQLFunctionCtx *pCtx, STimeWindow* w, int32_t c
...
@@ -698,6 +698,10 @@ static int32_t dataBlockRequired(SQLFunctionCtx *pCtx, STimeWindow* w, int32_t c
// todo: if column in current data block are null, opt for this case
// todo: if column in current data block are null, opt for this case
static
int32_t
firstFuncRequired
(
SQLFunctionCtx
*
pCtx
,
STimeWindow
*
w
,
int32_t
colId
)
{
static
int32_t
firstFuncRequired
(
SQLFunctionCtx
*
pCtx
,
STimeWindow
*
w
,
int32_t
colId
)
{
if
(
pCtx
->
order
==
TSDB_ORDER_DESC
)
{
return
BLK_DATA_NO_NEEDED
;
}
// no result for first query, data block is required
// no result for first query, data block is required
if
(
GET_RES_INFO
(
pCtx
)
==
NULL
||
GET_RES_INFO
(
pCtx
)
->
numOfRes
<=
0
)
{
if
(
GET_RES_INFO
(
pCtx
)
==
NULL
||
GET_RES_INFO
(
pCtx
)
->
numOfRes
<=
0
)
{
return
BLK_DATA_ALL_NEEDED
;
return
BLK_DATA_ALL_NEEDED
;
...
@@ -707,6 +711,10 @@ static int32_t firstFuncRequired(SQLFunctionCtx *pCtx, STimeWindow* w, int32_t c
...
@@ -707,6 +711,10 @@ static int32_t firstFuncRequired(SQLFunctionCtx *pCtx, STimeWindow* w, int32_t c
}
}
static
int32_t
lastFuncRequired
(
SQLFunctionCtx
*
pCtx
,
STimeWindow
*
w
,
int32_t
colId
)
{
static
int32_t
lastFuncRequired
(
SQLFunctionCtx
*
pCtx
,
STimeWindow
*
w
,
int32_t
colId
)
{
if
(
pCtx
->
order
!=
pCtx
->
param
[
0
].
i64
)
{
return
BLK_DATA_NO_NEEDED
;
}
if
(
GET_RES_INFO
(
pCtx
)
==
NULL
||
GET_RES_INFO
(
pCtx
)
->
numOfRes
<=
0
)
{
if
(
GET_RES_INFO
(
pCtx
)
==
NULL
||
GET_RES_INFO
(
pCtx
)
->
numOfRes
<=
0
)
{
return
BLK_DATA_ALL_NEEDED
;
return
BLK_DATA_ALL_NEEDED
;
}
else
{
}
else
{
...
@@ -1516,38 +1524,66 @@ static bool first_last_function_setup(SQLFunctionCtx *pCtx, SResultRowCellInfo*
...
@@ -1516,38 +1524,66 @@ static bool first_last_function_setup(SQLFunctionCtx *pCtx, SResultRowCellInfo*
// todo opt for null block
// todo opt for null block
static
void
first_function
(
SQLFunctionCtx
*
pCtx
)
{
static
void
first_function
(
SQLFunctionCtx
*
pCtx
)
{
SResultRowCellInfo
*
pResInfo
=
GET_RES_INFO
(
pCtx
);
int32_t
notNullElems
=
0
;
int32_t
notNullElems
=
0
;
int32_t
step
=
1
;
int32_t
step
=
1
;
int32_t
i
=
0
;
int32_t
i
=
0
;
bool
inputAsc
=
true
;
if
(
pCtx
->
numOfParams
==
2
)
{
// input data come from sub query, input data order equal to sub query order
if
(
pCtx
->
param
[
1
].
nType
==
TSDB_DATA_TYPE_INT
&&
pCtx
->
param
[
1
].
i64
==
TSDB_ORDER_DESC
)
{
if
(
pCtx
->
numOfParams
==
3
)
{
if
(
pCtx
->
param
[
2
].
nType
==
TSDB_DATA_TYPE_INT
&&
pCtx
->
param
[
2
].
i64
==
TSDB_ORDER_DESC
)
{
step
=
-
1
;
step
=
-
1
;
i
=
pCtx
->
size
-
1
;
i
=
pCtx
->
size
-
1
;
inputAsc
=
false
;
}
}
}
else
if
(
pCtx
->
order
==
TSDB_ORDER_DESC
)
{
return
;
}
}
// handle the null value
if
(
pCtx
->
order
==
TSDB_ORDER_ASC
&&
inputAsc
)
{
for
(
int32_t
m
=
0
;
m
<
pCtx
->
size
;
++
m
,
i
+=
step
)
{
for
(
int32_t
m
=
0
;
m
<
pCtx
->
size
;
++
m
,
i
+=
step
)
{
char
*
data
=
GET_INPUT_DATA
(
pCtx
,
i
);
char
*
data
=
GET_INPUT_DATA
(
pCtx
,
i
);
if
(
pCtx
->
hasNull
&&
isNull
(
data
,
pCtx
->
inputType
))
{
if
(
pCtx
->
hasNull
&&
isNull
(
data
,
pCtx
->
inputType
))
{
continue
;
continue
;
}
}
memcpy
(
pCtx
->
pOutput
,
data
,
pCtx
->
inputBytes
);
memcpy
(
pCtx
->
pOutput
,
data
,
pCtx
->
inputBytes
);
if
(
pCtx
->
ptsList
!=
NULL
)
{
if
(
pCtx
->
ptsList
!=
NULL
)
{
TSKEY
k
=
GET_TS_DATA
(
pCtx
,
i
);
TSKEY
k
=
GET_TS_DATA
(
pCtx
,
i
);
DO_UPDATE_TAG_COLUMNS
(
pCtx
,
k
);
DO_UPDATE_TAG_COLUMNS
(
pCtx
,
k
);
}
SResultRowCellInfo
*
pInfo
=
GET_RES_INFO
(
pCtx
);
pInfo
->
hasResult
=
DATA_SET_FLAG
;
pInfo
->
complete
=
true
;
notNullElems
++
;
break
;
}
}
}
else
{
// desc order
for
(
int32_t
m
=
0
;
m
<
pCtx
->
size
;
++
m
,
i
+=
step
)
{
char
*
data
=
GET_INPUT_DATA
(
pCtx
,
i
);
if
(
pCtx
->
hasNull
&&
isNull
(
data
,
pCtx
->
inputType
)
&&
(
!
pCtx
->
requireNull
))
{
continue
;
}
SResultRowCellInfo
*
pInfo
=
GET_RES_INFO
(
pCtx
);
TSKEY
ts
=
pCtx
->
ptsList
?
GET_TS_DATA
(
pCtx
,
i
)
:
0
;
pInfo
->
hasResult
=
DATA_SET_FLAG
;
pInfo
->
complete
=
true
;
char
*
buf
=
GET_ROWCELL_INTERBUF
(
pResInfo
);
if
(
pResInfo
->
hasResult
!=
DATA_SET_FLAG
||
(
*
(
TSKEY
*
)
buf
)
>
ts
)
{
notNullElems
++
;
pResInfo
->
hasResult
=
DATA_SET_FLAG
;
break
;
memcpy
(
pCtx
->
pOutput
,
data
,
pCtx
->
inputBytes
);
*
(
TSKEY
*
)
buf
=
ts
;
DO_UPDATE_TAG_COLUMNS
(
pCtx
,
ts
);
}
notNullElems
++
;
break
;
}
}
}
SET_VAL
(
pCtx
,
notNullElems
,
1
);
SET_VAL
(
pCtx
,
notNullElems
,
1
);
}
}
...
@@ -1636,11 +1672,14 @@ static void last_function(SQLFunctionCtx *pCtx) {
...
@@ -1636,11 +1672,14 @@ static void last_function(SQLFunctionCtx *pCtx) {
int32_t
step
=
-
1
;
int32_t
step
=
-
1
;
int32_t
i
=
pCtx
->
size
-
1
;
int32_t
i
=
pCtx
->
size
-
1
;
if
(
pCtx
->
numOfParams
==
2
)
{
// input data come from sub query, input data order equal to sub query order
if
(
pCtx
->
param
[
1
].
nType
==
TSDB_DATA_TYPE_INT
&&
pCtx
->
param
[
1
].
i64
==
TSDB_ORDER_DESC
)
{
if
(
pCtx
->
numOfParams
==
3
)
{
if
(
pCtx
->
param
[
2
].
nType
==
TSDB_DATA_TYPE_INT
&&
pCtx
->
param
[
2
].
i64
==
TSDB_ORDER_DESC
)
{
step
=
1
;
step
=
1
;
i
=
0
;
i
=
0
;
}
}
}
else
if
(
pCtx
->
order
!=
pCtx
->
param
[
0
].
i64
)
{
return
;
}
}
if
(
pCtx
->
order
==
TSDB_ORDER_DESC
)
{
if
(
pCtx
->
order
==
TSDB_ORDER_DESC
)
{
...
...
src/query/src/qExecutor.c
浏览文件 @
3ae81303
...
@@ -1910,6 +1910,7 @@ static int32_t getGroupbyColumnIndex(SGroupbyExpr *pGroupbyExpr, SSDataBlock* pD
...
@@ -1910,6 +1910,7 @@ static int32_t getGroupbyColumnIndex(SGroupbyExpr *pGroupbyExpr, SSDataBlock* pD
static
bool
functionNeedToExecute
(
SQueryRuntimeEnv
*
pRuntimeEnv
,
SQLFunctionCtx
*
pCtx
)
{
static
bool
functionNeedToExecute
(
SQueryRuntimeEnv
*
pRuntimeEnv
,
SQLFunctionCtx
*
pCtx
)
{
SResultRowCellInfo
*
pResInfo
=
GET_RES_INFO
(
pCtx
);
SResultRowCellInfo
*
pResInfo
=
GET_RES_INFO
(
pCtx
);
SQueryAttr
*
pQueryAttr
=
pRuntimeEnv
->
pQueryAttr
;
// in case of timestamp column, always generated results.
// in case of timestamp column, always generated results.
int32_t
functionId
=
pCtx
->
functionId
;
int32_t
functionId
=
pCtx
->
functionId
;
...
@@ -1921,6 +1922,15 @@ static bool functionNeedToExecute(SQueryRuntimeEnv *pRuntimeEnv, SQLFunctionCtx
...
@@ -1921,6 +1922,15 @@ static bool functionNeedToExecute(SQueryRuntimeEnv *pRuntimeEnv, SQLFunctionCtx
return
false
;
return
false
;
}
}
if
(
functionId
==
TSDB_FUNC_FIRST_DST
||
functionId
==
TSDB_FUNC_FIRST
)
{
return
QUERY_IS_ASC_QUERY
(
pQueryAttr
);
}
// denote the order type
if
((
functionId
==
TSDB_FUNC_LAST_DST
||
functionId
==
TSDB_FUNC_LAST
))
{
return
pCtx
->
param
[
0
].
i64
==
pQueryAttr
->
order
.
order
;
}
// in the reverse table scan, only the following functions need to be executed
// in the reverse table scan, only the following functions need to be executed
if
(
IS_REVERSE_SCAN
(
pRuntimeEnv
)
||
if
(
IS_REVERSE_SCAN
(
pRuntimeEnv
)
||
(
pRuntimeEnv
->
scanFlag
==
REPEAT_SCAN
&&
functionId
!=
TSDB_FUNC_STDDEV
&&
functionId
!=
TSDB_FUNC_PERCT
))
{
(
pRuntimeEnv
->
scanFlag
==
REPEAT_SCAN
&&
functionId
!=
TSDB_FUNC_STDDEV
&&
functionId
!=
TSDB_FUNC_PERCT
))
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录