Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lzh_me
TDengine
提交
22882196
TDengine
项目概览
lzh_me
/
TDengine
与 Fork 源项目一致
Fork自
taosdata / TDengine
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
22882196
编写于
3月 29, 2021
作者:
D
dapan1121
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix bug
上级
2eb7174f
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
61 addition
and
17 deletion
+61
-17
src/client/src/tscSQLParser.c
src/client/src/tscSQLParser.c
+5
-12
src/client/src/tscServer.c
src/client/src/tscServer.c
+1
-1
src/query/src/qExecutor.c
src/query/src/qExecutor.c
+42
-0
src/query/src/qSqlParser.c
src/query/src/qSqlParser.c
+13
-4
未找到文件。
src/client/src/tscSQLParser.c
浏览文件 @
22882196
...
...
@@ -3079,14 +3079,10 @@ static SColumnFilterInfo* addColumnFilterInfo(SColumn* pColumn) {
}
static
int32_t
doExtractColumnFilterInfo
(
SSqlCmd
*
pCmd
,
SQueryInfo
*
pQueryInfo
,
SColumnFilterInfo
*
pColumnFilter
,
SColumnIndex
*
columnIndex
,
tSqlExpr
*
pExpr
)
{
int16_t
colType
,
tSqlExpr
*
pExpr
)
{
const
char
*
msg
=
"not supported filter condition"
;
tSqlExpr
*
pRight
=
pExpr
->
pRight
;
STableMetaInfo
*
pTableMetaInfo
=
tscGetMetaInfo
(
pQueryInfo
,
columnIndex
->
tableIndex
);
SSchema
*
pSchema
=
tscGetTableColumnSchema
(
pTableMetaInfo
->
pTableMeta
,
columnIndex
->
columnIndex
);
int16_t
colType
=
pSchema
->
type
;
if
(
colType
>=
TSDB_DATA_TYPE_TINYINT
&&
colType
<=
TSDB_DATA_TYPE_BIGINT
)
{
colType
=
TSDB_DATA_TYPE_BIGINT
;
...
...
@@ -3291,8 +3287,10 @@ static int32_t extractColumnFilterInfo(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SC
}
pColumn
->
colIndex
=
*
pIndex
;
int16_t
colType
=
pSchema
->
type
;
return
doExtractColumnFilterInfo
(
pCmd
,
pQueryInfo
,
pColFilter
,
pIndex
,
pExpr
);
return
doExtractColumnFilterInfo
(
pCmd
,
pQueryInfo
,
pColFilter
,
colType
,
pExpr
);
}
static
int32_t
getTablenameCond
(
SSqlCmd
*
pCmd
,
SQueryInfo
*
pQueryInfo
,
tSqlExpr
*
pTableCond
,
SStringBuilder
*
sb
)
{
...
...
@@ -6898,12 +6896,7 @@ static int32_t handleExprInHavingClause(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, t
}
}
SColumnIndex
index
=
COLUMN_INDEX_INITIALIZER
;
if
(
getColumnIndexByName
(
pCmd
,
&
pExpr
->
pLeft
->
colInfo
,
pQueryInfo
,
&
index
)
!=
TSDB_CODE_SUCCESS
)
{
return
TSDB_CODE_TSC_INVALID_SQL
;
}
int32_t
ret
=
doExtractColumnFilterInfo
(
pCmd
,
pQueryInfo
,
pColFilter
,
&
index
,
pExpr
);
int32_t
ret
=
doExtractColumnFilterInfo
(
pCmd
,
pQueryInfo
,
pColFilter
,
pInfo
->
field
.
type
,
pExpr
);
if
(
ret
)
{
return
ret
;
}
...
...
src/client/src/tscServer.c
浏览文件 @
22882196
...
...
@@ -862,7 +862,7 @@ int tscBuildQueryMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
pSqlFuncExpr
->
functionId
=
htons
(
pExpr
->
functionId
);
pSqlFuncExpr
->
numOfParams
=
htons
(
pExpr
->
numOfParams
);
pSqlFuncExpr
->
resColId
=
htons
(
pExpr
->
resColId
);
if
(
pExpr
->
pFilter
&&
pExpr
->
pFilter
->
numOfFilters
>
0
)
{
if
(
p
TableMeta
->
tableType
!=
TSDB_SUPER_TABLE
&&
p
Expr
->
pFilter
&&
pExpr
->
pFilter
->
numOfFilters
>
0
)
{
pSqlFuncExpr
->
filterNum
=
htonl
(
pExpr
->
pFilter
->
numOfFilters
);
}
else
{
pSqlFuncExpr
->
filterNum
=
0
;
...
...
src/query/src/qExecutor.c
浏览文件 @
22882196
...
...
@@ -200,6 +200,7 @@ static bool isPointInterpoQuery(SQuery *pQuery);
static
void
setResultBufSize
(
SQuery
*
pQuery
,
SRspResultInfo
*
pResultInfo
);
static
void
setCtxTagForJoin
(
SQueryRuntimeEnv
*
pRuntimeEnv
,
SQLFunctionCtx
*
pCtx
,
SExprInfo
*
pExprInfo
,
void
*
pTable
);
static
void
setParamForStableStddev
(
SQueryRuntimeEnv
*
pRuntimeEnv
,
SQLFunctionCtx
*
pCtx
,
int32_t
numOfOutput
,
SExprInfo
*
pExpr
);
static
void
setParamForStableStddevByColData
(
SQueryRuntimeEnv
*
pRuntimeEnv
,
SQLFunctionCtx
*
pCtx
,
int32_t
numOfOutput
,
SExprInfo
*
pExpr
,
char
*
val
,
int16_t
bytes
);
static
void
doSetTableGroupOutputBuf
(
SQueryRuntimeEnv
*
pRuntimeEnv
,
SResultRowInfo
*
pResultRowInfo
,
SQLFunctionCtx
*
pCtx
,
int32_t
*
rowCellInfoOffset
,
int32_t
numOfOutput
,
int32_t
groupIndex
);
...
...
@@ -1330,6 +1331,7 @@ static void doHashGroupbyAgg(SOperatorInfo* pOperator, SGroupbyOperatorInfo *pIn
SColumnInfoData
*
pColInfoData
=
taosArrayGet
(
pSDataBlock
->
pDataBlock
,
pInfo
->
colIndex
);
int16_t
bytes
=
pColInfoData
->
info
.
bytes
;
int16_t
type
=
pColInfoData
->
info
.
type
;
SQuery
*
pQuery
=
pRuntimeEnv
->
pQuery
;
if
(
type
==
TSDB_DATA_TYPE_FLOAT
||
type
==
TSDB_DATA_TYPE_DOUBLE
)
{
qError
(
"QInfo:%"
PRIu64
" group by not supported on double/float columns, abort"
,
GET_QID
(
pRuntimeEnv
));
...
...
@@ -1350,6 +1352,10 @@ static void doHashGroupbyAgg(SOperatorInfo* pOperator, SGroupbyOperatorInfo *pIn
memcpy
(
pInfo
->
prevData
,
val
,
bytes
);
if
(
pQuery
->
stableQuery
&&
pQuery
->
stabledev
&&
(
pRuntimeEnv
->
prevResult
!=
NULL
))
{
setParamForStableStddevByColData
(
pRuntimeEnv
,
pInfo
->
binfo
.
pCtx
,
pOperator
->
numOfOutput
,
pOperator
->
pExpr
,
val
,
bytes
);
}
int32_t
ret
=
setGroupResultOutputBuf
(
pRuntimeEnv
,
pInfo
,
pOperator
->
numOfOutput
,
val
,
type
,
bytes
,
item
->
groupIndex
);
if
(
ret
!=
TSDB_CODE_SUCCESS
)
{
// null data, too many state code
...
...
@@ -3396,6 +3402,42 @@ void setParamForStableStddev(SQueryRuntimeEnv* pRuntimeEnv, SQLFunctionCtx* pCtx
}
void
setParamForStableStddevByColData
(
SQueryRuntimeEnv
*
pRuntimeEnv
,
SQLFunctionCtx
*
pCtx
,
int32_t
numOfOutput
,
SExprInfo
*
pExpr
,
char
*
val
,
int16_t
bytes
)
{
SQuery
*
pQuery
=
pRuntimeEnv
->
pQuery
;
int32_t
numOfExprs
=
pQuery
->
numOfOutput
;
for
(
int32_t
i
=
0
;
i
<
numOfExprs
;
++
i
)
{
SExprInfo
*
pExprInfo
=
&
(
pExpr
[
i
]);
if
(
pExprInfo
->
base
.
functionId
!=
TSDB_FUNC_STDDEV_DST
)
{
continue
;
}
SSqlFuncMsg
*
pFuncMsg
=
&
pExprInfo
->
base
;
pCtx
[
i
].
param
[
0
].
arr
=
NULL
;
pCtx
[
i
].
param
[
0
].
nType
=
TSDB_DATA_TYPE_INT
;
// avoid freeing the memory by setting the type to be int
// TODO use hash to speedup this loop
int32_t
numOfGroup
=
(
int32_t
)
taosArrayGetSize
(
pRuntimeEnv
->
prevResult
);
for
(
int32_t
j
=
0
;
j
<
numOfGroup
;
++
j
)
{
SInterResult
*
p
=
taosArrayGet
(
pRuntimeEnv
->
prevResult
,
j
);
if
(
bytes
==
0
||
memcmp
(
p
->
tags
,
val
,
bytes
)
==
0
)
{
int32_t
numOfCols
=
(
int32_t
)
taosArrayGetSize
(
p
->
pResult
);
for
(
int32_t
k
=
0
;
k
<
numOfCols
;
++
k
)
{
SStddevInterResult
*
pres
=
taosArrayGet
(
p
->
pResult
,
k
);
if
(
pres
->
colId
==
pFuncMsg
->
colInfo
.
colId
)
{
pCtx
[
i
].
param
[
0
].
arr
=
pres
->
pResult
;
break
;
}
}
}
}
}
}
/*
* There are two cases to handle:
*
...
...
src/query/src/qSqlParser.c
浏览文件 @
22882196
...
...
@@ -319,6 +319,14 @@ int32_t tSqlExprCompare(tSqlExpr *left, tSqlExpr *right) {
return
1
;
}
if
(
left
->
tokenId
!=
right
->
tokenId
)
{
return
1
;
}
if
(
left
->
functionId
!=
right
->
functionId
)
{
return
1
;
}
if
((
left
->
pLeft
&&
right
->
pLeft
==
NULL
)
||
(
left
->
pLeft
==
NULL
&&
right
->
pLeft
)
||
(
left
->
pRight
&&
right
->
pRight
==
NULL
)
...
...
@@ -336,12 +344,13 @@ int32_t tSqlExprCompare(tSqlExpr *left, tSqlExpr *right) {
return
1
;
}
size_t
size
=
taosArrayGetSize
(
right
->
pParam
);
if
(
left
->
pParam
&&
taosArrayGetSize
(
left
->
pParam
)
!=
size
)
{
return
1
;
}
if
(
right
->
pParam
&&
left
->
pParam
)
{
size_t
size
=
taosArrayGetSize
(
right
->
pParam
);
if
(
left
->
pParam
&&
taosArrayGetSize
(
left
->
pParam
)
!=
size
)
{
return
1
;
}
for
(
int32_t
i
=
0
;
i
<
size
;
i
++
)
{
tSqlExprItem
*
pLeftElem
=
taosArrayGet
(
left
->
pParam
,
i
);
tSqlExpr
*
pSubLeft
=
pLeftElem
->
pNode
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录