Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
4e4e7b24
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
4e4e7b24
编写于
4月 12, 2021
作者:
H
Haojun Liao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[td-2895]enable arithmetic calculation for super table.
上级
a0c21661
变更
4
显示空白变更内容
内联
并排
Showing
4 changed file
with
57 addition
and
41 deletion
+57
-41
src/client/src/tscUtil.c
src/client/src/tscUtil.c
+38
-29
src/query/inc/qExecutor.h
src/query/inc/qExecutor.h
+1
-0
src/query/src/qExecutor.c
src/query/src/qExecutor.c
+7
-6
src/query/src/qPlan.c
src/query/src/qPlan.c
+11
-6
未找到文件。
src/client/src/tscUtil.c
浏览文件 @
4e4e7b24
...
...
@@ -3278,8 +3278,9 @@ static int32_t createSecondaryExpr(SQueryAttr* pQueryAttr, SQueryInfo* pQueryInf
for
(
int32_t
i
=
0
;
i
<
pQueryAttr
->
numOfExpr2
;
++
i
)
{
SInternalField
*
pField
=
tscFieldInfoGetInternalField
(
&
pQueryInfo
->
fieldsInfo
,
i
);
SExprInfo
*
pExpr
=
pField
->
pExpr
;
// SExprInfo *pExpr = &pQueryAttr->pExpr3[i];
SSqlExpr
*
pse
=
&
pQueryAttr
->
pExpr2
[
i
].
base
;
SSqlExpr
*
pse
=
&
pQueryAttr
->
pExpr2
[
i
].
base
;
pse
->
uid
=
pTableMetaInfo
->
pTableMeta
->
id
.
uid
;
pse
->
resColId
=
pExpr
->
base
.
resColId
;
...
...
@@ -3295,10 +3296,16 @@ static int32_t createSecondaryExpr(SQueryAttr* pQueryAttr, SQueryInfo* pQueryInf
}
pse
->
colInfo
.
flag
=
TSDB_COL_NORMAL
;
pse
->
colType
=
pExpr
->
base
.
resType
;
pse
->
colBytes
=
pExpr
->
base
.
resBytes
;
pse
->
resType
=
pExpr
->
base
.
resType
;
pse
->
resBytes
=
pExpr
->
base
.
resBytes
;
// TODO restore refactor
int32_t
inter
=
0
;
getResultDataInfo
(
pExpr
->
base
.
colType
,
pExpr
->
base
.
colBytes
,
pExpr
->
base
.
functionId
,
0
,
&
pse
->
resType
,
&
pse
->
resBytes
,
&
inter
,
0
,
false
);
pse
->
colType
=
pse
->
resType
;
pse
->
colBytes
=
pse
->
resBytes
;
}
else
{
// arithmetic expression
pse
->
colInfo
.
colId
=
pExpr
->
base
.
colInfo
.
colId
;
pse
->
colType
=
pExpr
->
base
.
colType
;
...
...
@@ -3311,6 +3318,7 @@ static int32_t createSecondaryExpr(SQueryAttr* pQueryAttr, SQueryInfo* pQueryInf
for
(
int32_t
j
=
0
;
j
<
pExpr
->
base
.
numOfParams
;
++
j
)
{
tVariantAssign
(
&
pse
->
param
[
j
],
&
pExpr
->
base
.
param
[
j
]);
buildArithmeticExprFromMsg
(
&
pQueryAttr
->
pExpr2
[
i
],
NULL
);
}
}
}
...
...
@@ -3321,7 +3329,7 @@ static int32_t createSecondaryExpr(SQueryAttr* pQueryAttr, SQueryInfo* pQueryInf
static
int32_t
createGlobalAggregateExpr
(
SQueryAttr
*
pQueryAttr
,
SQueryInfo
*
pQueryInfo
)
{
assert
(
tscIsTwoStageSTableQuery
(
pQueryInfo
,
0
));
pQueryAttr
->
numOfExpr3
=
tsc
NumOfField
s
(
pQueryInfo
);
pQueryAttr
->
numOfExpr3
=
tsc
SqlExprNumOfExpr
s
(
pQueryInfo
);
pQueryAttr
->
pExpr3
=
calloc
(
pQueryAttr
->
numOfExpr3
,
sizeof
(
SExprInfo
));
if
(
pQueryAttr
->
pExpr3
==
NULL
)
{
return
TSDB_CODE_TSC_OUT_OF_MEMORY
;
...
...
@@ -3343,6 +3351,7 @@ static int32_t createGlobalAggregateExpr(SQueryAttr* pQueryAttr, SQueryInfo* pQu
tVariantAssign
(
&
pse
->
param
[
j
],
&
pExpr
->
base
.
param
[
j
]);
}
}
{
for
(
int32_t
i
=
0
;
i
<
pQueryAttr
->
numOfExpr3
;
++
i
)
{
SExprInfo
*
pExpr
=
&
pQueryAttr
->
pExpr1
[
i
];
...
...
@@ -3365,8 +3374,8 @@ static int32_t createGlobalAggregateExpr(SQueryAttr* pQueryAttr, SQueryInfo* pQu
functionId
=
TSDB_FUNC_STDDEV
;
}
getResultDataInfo
(
pExpr
->
base
.
colType
,
pExpr
->
base
.
colBytes
,
functionId
,
0
,
&
pse
->
resType
,
&
pse
->
resBytes
,
&
inter
,
0
,
false
);
getResultDataInfo
(
pExpr
->
base
.
colType
,
pExpr
->
base
.
colBytes
,
functionId
,
0
,
&
pse
->
resType
,
&
pse
->
resBytes
,
&
inter
,
0
,
false
);
}
}
...
...
@@ -3470,17 +3479,17 @@ int32_t tscCreateQueryFromQueryInfo(SQueryInfo* pQueryInfo, SQueryAttr* pQueryAt
pQueryAttr
->
colList
[
i
].
filterInfo
=
tFilterInfoDup
(
pCol
->
info
.
filterInfo
,
pQueryAttr
->
colList
[
i
].
numOfFilters
);
}
// global aggregate query
if
(
pQueryAttr
->
stableQuery
&&
(
pQueryAttr
->
simpleAgg
||
pQueryAttr
->
interval
.
interval
>
0
)
&&
tscIsTwoStageSTableQuery
(
pQueryInfo
,
0
))
{
createGlobalAggregateExpr
(
pQueryAttr
,
pQueryInfo
);
}
// for simple table, not for super table
int32_t
code
=
createSecondaryExpr
(
pQueryAttr
,
pQueryInfo
,
pTableMetaInfo
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
return
code
;
}
// global aggregate query
if
(
pQueryAttr
->
stableQuery
&&
(
pQueryAttr
->
simpleAgg
||
pQueryAttr
->
interval
.
interval
>
0
)
&&
tscIsTwoStageSTableQuery
(
pQueryInfo
,
0
))
{
createGlobalAggregateExpr
(
pQueryAttr
,
pQueryInfo
);
}
// tag column info
code
=
createTagColumnInfo
(
pQueryAttr
,
pQueryInfo
,
pTableMetaInfo
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
...
...
src/query/inc/qExecutor.h
浏览文件 @
4e4e7b24
...
...
@@ -522,6 +522,7 @@ int32_t initQInfo(STsBufInfo* pTsBufInfo, void* tsdb, SQInfo* pQInfo, SQueryPara
void
freeColumnFilterInfo
(
SColumnFilterInfo
*
pFilter
,
int32_t
numOfFilters
);
STableQueryInfo
*
createTableQueryInfo
(
SQueryAttr
*
pQueryAttr
,
void
*
pTable
,
bool
groupbyColumn
,
STimeWindow
win
,
void
*
buf
);
int32_t
buildArithmeticExprFromMsg
(
SExprInfo
*
pArithExprInfo
,
void
*
pQueryMsg
);
bool
isQueryKilled
(
SQInfo
*
pQInfo
);
int32_t
checkForQueryBuf
(
size_t
numOfTables
);
...
...
src/query/src/qExecutor.c
浏览文件 @
4e4e7b24
...
...
@@ -913,7 +913,7 @@ static void doSetInputDataBlock(SOperatorInfo* pOperator, SQLFunctionCtx* pCtx,
// in case of the block distribution query, the inputBytes is not a constant value.
pCtx
[
i
].
pInput
=
p
->
pData
;
assert
(
p
->
info
.
colId
==
pColIndex
->
colId
&&
pCtx
[
i
].
inputType
==
p
->
info
.
type
);
// && pCtx[i].inputBytes == p->info.bytes);
assert
(
p
->
info
.
colId
==
pColIndex
->
colId
&&
pCtx
[
i
].
inputType
==
p
->
info
.
type
);
uint32_t
status
=
aAggs
[
pCtx
[
i
].
functionId
].
status
;
if
((
status
&
(
TSDB_FUNCSTATE_SELECTIVITY
|
TSDB_FUNCSTATE_NEED_TS
))
!=
0
)
{
...
...
@@ -3936,6 +3936,7 @@ int32_t doInitQInfo(SQInfo* pQInfo, STSBuf* pTsBuf, SArray* prevResult, void* ts
// create runtime environment
int32_t
numOfTables
=
(
int32_t
)
pQueryAttr
->
tableGroupInfo
.
numOfTables
;
pQInfo
->
summary
.
tableInfoSize
+=
(
numOfTables
*
sizeof
(
STableQueryInfo
));
code
=
setupQueryRuntimeEnv
(
pRuntimeEnv
,
(
int32_t
)
pQueryAttr
->
tableGroupInfo
.
numOfTables
,
pOperator
,
param
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
return
code
;
...
...
@@ -5890,24 +5891,24 @@ _cleanup:
return
code
;
}
static
int32_t
buildArithmeticExprFromMsg
(
SExprInfo
*
pArith
ExprInfo
,
void
*
pQueryMsg
)
{
int32_t
buildArithmeticExprFromMsg
(
SExprInfo
*
p
ExprInfo
,
void
*
pQueryMsg
)
{
qDebug
(
"qmsg:%p create arithmetic expr from binary"
,
pQueryMsg
);
tExprNode
*
pExprNode
=
NULL
;
TRY
(
TSDB_MAX_TAG_CONDITIONS
)
{
pExprNode
=
exprTreeFromBinary
(
p
ArithExprInfo
->
base
.
param
[
0
].
pz
,
pArith
ExprInfo
->
base
.
param
[
0
].
nLen
);
pExprNode
=
exprTreeFromBinary
(
p
ExprInfo
->
base
.
param
[
0
].
pz
,
p
ExprInfo
->
base
.
param
[
0
].
nLen
);
}
CATCH
(
code
)
{
CLEANUP_EXECUTE
();
qError
(
"qmsg:%p failed to create arithmetic expression string from:%s, reason: %s"
,
pQueryMsg
,
p
Arith
ExprInfo
->
base
.
param
[
0
].
pz
,
tstrerror
(
code
));
qError
(
"qmsg:%p failed to create arithmetic expression string from:%s, reason: %s"
,
pQueryMsg
,
pExprInfo
->
base
.
param
[
0
].
pz
,
tstrerror
(
code
));
return
code
;
}
END_TRY
if
(
pExprNode
==
NULL
)
{
qError
(
"qmsg:%p failed to create arithmetic expression string from:%s"
,
pQueryMsg
,
p
Arith
ExprInfo
->
base
.
param
[
0
].
pz
);
qError
(
"qmsg:%p failed to create arithmetic expression string from:%s"
,
pQueryMsg
,
pExprInfo
->
base
.
param
[
0
].
pz
);
return
TSDB_CODE_QRY_APP_ERROR
;
}
p
Arith
ExprInfo
->
pExpr
=
pExprNode
;
pExprInfo
->
pExpr
=
pExprNode
;
return
TSDB_CODE_SUCCESS
;
}
...
...
src/query/src/qPlan.c
浏览文件 @
4e4e7b24
...
...
@@ -136,12 +136,6 @@ SArray* createGlobalMergePlan(SQueryAttr* pQueryAttr) {
int32_t
op
=
OP_MultiwaySort
;
taosArrayPush
(
plan
,
&
op
);
// fill operator
if
(
pQueryAttr
->
fillType
!=
TSDB_FILL_NONE
&&
(
!
pQueryAttr
->
pointInterpQuery
))
{
op
=
OP_Fill
;
taosArrayPush
(
plan
,
&
op
);
}
// arithmetic operator
if
(
!
pQueryAttr
->
simpleAgg
&&
pQueryAttr
->
interval
.
interval
==
0
)
{
op
=
OP_Arithmetic
;
...
...
@@ -149,6 +143,17 @@ SArray* createGlobalMergePlan(SQueryAttr* pQueryAttr) {
}
else
{
op
=
OP_GlobalAggregate
;
taosArrayPush
(
plan
,
&
op
);
if
(
pQueryAttr
->
pExpr2
!=
NULL
)
{
op
=
OP_Arithmetic
;
taosArrayPush
(
plan
,
&
op
);
}
}
// fill operator
if
(
pQueryAttr
->
fillType
!=
TSDB_FILL_NONE
&&
(
!
pQueryAttr
->
pointInterpQuery
))
{
op
=
OP_Fill
;
taosArrayPush
(
plan
,
&
op
);
}
// limit/offset operator
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录