Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
84818987
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看板
提交
84818987
编写于
3月 21, 2022
作者:
H
Haojun Liao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[td-13039] fix bug in show tables;
上级
cf1e4507
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
103 addition
and
23 deletion
+103
-23
include/libs/executor/executor.h
include/libs/executor/executor.h
+5
-1
source/libs/executor/src/executor.c
source/libs/executor/src/executor.c
+12
-7
source/libs/function/inc/builtinsimpl.h
source/libs/function/inc/builtinsimpl.h
+5
-1
source/libs/function/src/builtins.c
source/libs/function/src/builtins.c
+12
-12
source/libs/function/src/builtinsimpl.c
source/libs/function/src/builtinsimpl.c
+69
-2
未找到文件。
include/libs/executor/executor.h
浏览文件 @
84818987
...
...
@@ -32,6 +32,9 @@ typedef struct SReadHandle {
void
*
meta
;
}
SReadHandle
;
#define STREAM_DATA_TYPE_SUBMITBLK 0x1u
#define STREAM_DATA_TYPE_SSDATABLK 0x2u
/**
* Create the exec task for streaming mode
* @param pMsg
...
...
@@ -44,9 +47,10 @@ qTaskInfo_t qCreateStreamExecTaskInfo(void *msg, void* streamReadHandle);
* Set the input data block for the stream scan.
* @param tinfo
* @param input
* @param type
* @return
*/
int32_t
qSetStreamInput
(
qTaskInfo_t
tinfo
,
const
void
*
input
);
int32_t
qSetStreamInput
(
qTaskInfo_t
tinfo
,
const
void
*
input
,
int32_t
type
);
/**
* Update the table id list, add or remove.
...
...
source/libs/executor/src/executor.c
浏览文件 @
84818987
...
...
@@ -18,7 +18,7 @@
#include "planner.h"
#include "tq.h"
static
int32_t
doSetStreamBlock
(
SOperatorInfo
*
pOperator
,
void
*
input
,
char
*
id
)
{
static
int32_t
doSetStreamBlock
(
SOperatorInfo
*
pOperator
,
void
*
input
,
int32_t
type
,
char
*
id
)
{
ASSERT
(
pOperator
!=
NULL
);
if
(
pOperator
->
operatorType
!=
QUERY_NODE_PHYSICAL_PLAN_STREAM_SCAN
)
{
if
(
pOperator
->
numOfDownstream
==
0
)
{
...
...
@@ -31,18 +31,23 @@ static int32_t doSetStreamBlock(SOperatorInfo* pOperator, void* input, char* id)
return
TSDB_CODE_QRY_APP_ERROR
;
}
return
doSetStreamBlock
(
pOperator
->
pDownstream
[
0
],
input
,
id
);
// TODO handle the join case
return
doSetStreamBlock
(
pOperator
->
pDownstream
[
0
],
input
,
type
,
id
);
}
else
{
SStreamBlockScanInfo
*
pInfo
=
pOperator
->
info
;
if
(
tqReadHandleSetMsg
(
pInfo
->
readerHandle
,
input
,
0
)
<
0
)
{
qError
(
"submit msg messed up when initing stream block, %s"
PRIx64
,
id
);
return
TSDB_CODE_QRY_APP_ERROR
;
if
(
type
==
STREAM_DATA_TYPE_SUBMITBLK
)
{
if
(
tqReadHandleSetMsg
(
pInfo
->
readerHandle
,
input
,
0
)
<
0
)
{
qError
(
"submit msg messed up when initing stream block, %s"
PRIx64
,
id
);
return
TSDB_CODE_QRY_APP_ERROR
;
}
}
else
{
// TODO
}
return
TSDB_CODE_SUCCESS
;
}
}
int32_t
qSetStreamInput
(
qTaskInfo_t
tinfo
,
const
void
*
input
)
{
int32_t
qSetStreamInput
(
qTaskInfo_t
tinfo
,
const
void
*
input
,
int32_t
type
)
{
if
(
tinfo
==
NULL
)
{
return
TSDB_CODE_QRY_APP_ERROR
;
}
...
...
@@ -53,7 +58,7 @@ int32_t qSetStreamInput(qTaskInfo_t tinfo, const void* input) {
SExecTaskInfo
*
pTaskInfo
=
(
SExecTaskInfo
*
)
tinfo
;
int32_t
code
=
doSetStreamBlock
(
pTaskInfo
->
pRoot
,
(
void
*
)
input
,
GET_TASKID
(
pTaskInfo
));
int32_t
code
=
doSetStreamBlock
(
pTaskInfo
->
pRoot
,
(
void
*
)
input
,
type
,
GET_TASKID
(
pTaskInfo
));
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
qError
(
"%s failed to set the stream block data"
,
GET_TASKID
(
pTaskInfo
));
}
else
{
...
...
source/libs/function/inc/builtinsimpl.h
浏览文件 @
84818987
...
...
@@ -23,7 +23,7 @@ extern "C" {
#include "function.h"
bool
functionSetup
(
SqlFunctionCtx
*
pCtx
,
SResultRowEntryInfo
*
pResultInfo
);
void
functionFinalize
r
(
SqlFunctionCtx
*
pCtx
);
void
functionFinalize
(
SqlFunctionCtx
*
pCtx
);
bool
getCountFuncEnv
(
SFunctionNode
*
pFunc
,
SFuncExecEnv
*
pEnv
);
void
countFunction
(
SqlFunctionCtx
*
pCtx
);
...
...
@@ -37,6 +37,10 @@ bool getMinmaxFuncEnv(SFunctionNode* pFunc, SFuncExecEnv* pEnv);
void
minFunction
(
SqlFunctionCtx
*
pCtx
);
void
maxFunction
(
SqlFunctionCtx
*
pCtx
);
bool
getStddevFuncEnv
(
SFunctionNode
*
pFunc
,
SFuncExecEnv
*
pEnv
);
void
stddevFunction
(
SqlFunctionCtx
*
pCtx
);
void
stddevFinalize
(
SqlFunctionCtx
*
pCtx
);
#ifdef __cplusplus
}
#endif
...
...
source/libs/function/src/builtins.c
浏览文件 @
84818987
...
...
@@ -29,7 +29,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
.
getEnvFunc
=
getCountFuncEnv
,
.
initFunc
=
functionSetup
,
.
processFunc
=
countFunction
,
.
finalizeFunc
=
functionFinalize
r
.
finalizeFunc
=
functionFinalize
},
{
.
name
=
"sum"
,
...
...
@@ -39,7 +39,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
.
getEnvFunc
=
getSumFuncEnv
,
.
initFunc
=
functionSetup
,
.
processFunc
=
sumFunction
,
.
finalizeFunc
=
functionFinalize
r
.
finalizeFunc
=
functionFinalize
},
{
.
name
=
"min"
,
...
...
@@ -49,7 +49,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
.
getEnvFunc
=
getMinmaxFuncEnv
,
.
initFunc
=
minFunctionSetup
,
.
processFunc
=
minFunction
,
.
finalizeFunc
=
functionFinalize
r
.
finalizeFunc
=
functionFinalize
},
{
.
name
=
"max"
,
...
...
@@ -59,17 +59,17 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
.
getEnvFunc
=
getMinmaxFuncEnv
,
.
initFunc
=
maxFunctionSetup
,
.
processFunc
=
maxFunction
,
.
finalizeFunc
=
functionFinalize
r
.
finalizeFunc
=
functionFinalize
},
{
.
name
=
"stddev"
,
.
type
=
FUNCTION_TYPE_STDDEV
,
.
classification
=
FUNC_MGT_AGG_FUNC
,
.
checkFunc
=
stubCheckAndGetResultType
,
.
getEnvFunc
=
get
Minmax
FuncEnv
,
.
getEnvFunc
=
get
Stddev
FuncEnv
,
.
initFunc
=
maxFunctionSetup
,
.
processFunc
=
maxFunction
,
.
finalizeFunc
=
functionFinalize
r
.
finalizeFunc
=
functionFinalize
},
{
.
name
=
"percentile"
,
...
...
@@ -79,7 +79,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
.
getEnvFunc
=
getMinmaxFuncEnv
,
.
initFunc
=
maxFunctionSetup
,
.
processFunc
=
maxFunction
,
.
finalizeFunc
=
functionFinalize
r
.
finalizeFunc
=
functionFinalize
},
{
.
name
=
"apercentile"
,
...
...
@@ -89,7 +89,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
.
getEnvFunc
=
getMinmaxFuncEnv
,
.
initFunc
=
maxFunctionSetup
,
.
processFunc
=
maxFunction
,
.
finalizeFunc
=
functionFinalize
r
.
finalizeFunc
=
functionFinalize
},
{
.
name
=
"top"
,
...
...
@@ -99,7 +99,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
.
getEnvFunc
=
getMinmaxFuncEnv
,
.
initFunc
=
maxFunctionSetup
,
.
processFunc
=
maxFunction
,
.
finalizeFunc
=
functionFinalize
r
.
finalizeFunc
=
functionFinalize
},
{
.
name
=
"bottom"
,
...
...
@@ -109,7 +109,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
.
getEnvFunc
=
getMinmaxFuncEnv
,
.
initFunc
=
maxFunctionSetup
,
.
processFunc
=
maxFunction
,
.
finalizeFunc
=
functionFinalize
r
.
finalizeFunc
=
functionFinalize
},
{
.
name
=
"spread"
,
...
...
@@ -119,7 +119,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
.
getEnvFunc
=
getMinmaxFuncEnv
,
.
initFunc
=
maxFunctionSetup
,
.
processFunc
=
maxFunction
,
.
finalizeFunc
=
functionFinalize
r
.
finalizeFunc
=
functionFinalize
},
{
.
name
=
"last_row"
,
...
...
@@ -129,7 +129,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
.
getEnvFunc
=
getMinmaxFuncEnv
,
.
initFunc
=
maxFunctionSetup
,
.
processFunc
=
maxFunction
,
.
finalizeFunc
=
functionFinalize
r
.
finalizeFunc
=
functionFinalize
},
{
.
name
=
"concat"
,
...
...
source/libs/function/src/builtinsimpl.c
浏览文件 @
84818987
...
...
@@ -50,7 +50,7 @@ bool functionSetup(SqlFunctionCtx *pCtx, SResultRowEntryInfo* pResultInfo) {
static
void
doFinalizer
(
SResultRowEntryInfo
*
pResInfo
)
{
cleanupResultRowEntry
(
pResInfo
);
}
void
functionFinalize
r
(
SqlFunctionCtx
*
pCtx
)
{
void
functionFinalize
(
SqlFunctionCtx
*
pCtx
)
{
SResultRowEntryInfo
*
pResInfo
=
GET_RES_INFO
(
pCtx
);
doFinalizer
(
pResInfo
);
}
...
...
@@ -441,4 +441,71 @@ void minFunction(SqlFunctionCtx *pCtx) {
void
maxFunction
(
SqlFunctionCtx
*
pCtx
)
{
int32_t
numOfElems
=
doMinMaxHelper
(
pCtx
,
0
);
SET_VAL
(
GET_RES_INFO
(
pCtx
),
numOfElems
,
1
);
}
\ No newline at end of file
}
typedef
struct
STopBotRes
{
int32_t
num
;
}
STopBotRes
;
bool
getTopBotFuncEnv
(
SFunctionNode
*
pFunc
,
SFuncExecEnv
*
pEnv
)
{
SColumnNode
*
pColNode
=
(
SColumnNode
*
)
nodesListGetNode
(
pFunc
->
pParameterList
,
0
);
int32_t
bytes
=
pColNode
->
node
.
resType
.
bytes
;
SValueNode
*
pkNode
=
(
SValueNode
*
)
nodesListGetNode
(
pFunc
->
pParameterList
,
1
);
return
true
;
}
typedef
struct
SStddevRes
{
int64_t
count
;
union
{
double
quadraticDSum
;
int64_t
quadraticISum
;};
union
{
double
dsum
;
int64_t
isum
;};
}
SStddevRes
;
bool
getStddevFuncEnv
(
SFunctionNode
*
pFunc
,
SFuncExecEnv
*
pEnv
)
{
pEnv
->
calcMemSize
=
sizeof
(
SStddevRes
);
return
true
;
}
void
stddevFunction
(
SqlFunctionCtx
*
pCtx
)
{
int32_t
numOfElem
=
0
;
// Only the pre-computing information loaded and actual data does not loaded
SInputColumnInfoData
*
pInput
=
&
pCtx
->
input
;
SColumnDataAgg
*
pAgg
=
pInput
->
pColumnDataAgg
[
0
];
int32_t
type
=
pInput
->
pData
[
0
]
->
info
.
type
;
SStddevRes
*
pStddevRes
=
GET_ROWCELL_INTERBUF
(
GET_RES_INFO
(
pCtx
));
// } else { // computing based on the true data block
SColumnInfoData
*
pCol
=
pInput
->
pData
[
0
];
int32_t
start
=
pInput
->
startRowIndex
;
int32_t
numOfRows
=
pInput
->
numOfRows
;
switch
(
type
)
{
case
TSDB_DATA_TYPE_INT
:
{
int32_t
*
plist
=
(
int32_t
*
)
pCol
->
pData
;
for
(
int32_t
i
=
start
;
i
<
numOfRows
+
pInput
->
startRowIndex
;
++
i
)
{
if
(
pCol
->
hasNull
&&
colDataIsNull_f
(
pCol
->
nullbitmap
,
i
))
{
continue
;
}
pStddevRes
->
count
+=
1
;
pStddevRes
->
isum
+=
plist
[
i
];
pStddevRes
->
quadraticISum
+=
plist
[
i
]
*
plist
[
i
];
}
}
break
;
}
// data in the check operation are all null, not output
SET_VAL
(
GET_RES_INFO
(
pCtx
),
numOfElem
,
1
);
}
void
stddevFinalize
(
SqlFunctionCtx
*
pCtx
)
{
functionFinalize
(
pCtx
);
SStddevRes
*
pStddevRes
=
GET_ROWCELL_INTERBUF
(
GET_RES_INFO
(
pCtx
));
double
res
=
pStddevRes
->
quadraticISum
/
pStddevRes
->
count
-
(
pStddevRes
->
isum
/
pStddevRes
->
count
)
*
(
pStddevRes
->
isum
/
pStddevRes
->
count
);
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录