Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
loser646
TDengine
提交
c52f23ee
T
TDengine
项目概览
loser646
/
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,发现更多精彩内容 >>
未验证
提交
c52f23ee
编写于
1月 07, 2021
作者:
H
haojun Liao
提交者:
GitHub
1月 07, 2021
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #4825 from taosdata/feature/query
Feature/query
上级
831256d3
85553335
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
96 addition
and
96 deletion
+96
-96
src/client/src/tscSQLParser.c
src/client/src/tscSQLParser.c
+17
-30
src/client/src/tscStream.c
src/client/src/tscStream.c
+51
-43
src/client/src/tscSubquery.c
src/client/src/tscSubquery.c
+7
-0
src/query/inc/qExecutor.h
src/query/inc/qExecutor.h
+1
-1
src/query/src/qExecutor.c
src/query/src/qExecutor.c
+20
-20
tests/script/general/parser/select_with_tags.sim
tests/script/general/parser/select_with_tags.sim
+0
-2
未找到文件。
src/client/src/tscSQLParser.c
浏览文件 @
c52f23ee
...
...
@@ -4599,7 +4599,7 @@ int32_t parseOrderbyClause(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SQuerySQL* pQu
const
char
*
msg0
=
"only support order by primary timestamp"
;
const
char
*
msg1
=
"invalid column name"
;
const
char
*
msg2
=
"only support order by primary timestamp or queried column"
;
const
char
*
msg3
=
"
only support order by primary timestamp or first tag in groupby clause
"
;
const
char
*
msg3
=
"
invalid column in order by clause, only primary timestamp or first tag in groupby clause allowed
"
;
setDefaultOrderInfo
(
pQueryInfo
);
STableMetaInfo
*
pTableMetaInfo
=
tscGetMetaInfo
(
pQueryInfo
,
0
);
...
...
@@ -5279,8 +5279,7 @@ int32_t parseLimitClause(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, int32_t clauseIn
const
char
*
msg0
=
"soffset/offset can not be less than 0"
;
const
char
*
msg1
=
"slimit/soffset only available for STable query"
;
const
char
*
msg2
=
"functions mixed up in table query"
;
const
char
*
msg3
=
"slimit/soffset can not apply to projection query"
;
const
char
*
msg2
=
"slimit/soffset can not apply to projection query"
;
// handle the limit offset value, validate the limit
pQueryInfo
->
limit
=
pQuerySql
->
limit
;
...
...
@@ -5305,7 +5304,7 @@ int32_t parseLimitClause(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, int32_t clauseIn
if
(
!
tscQueryTags
(
pQueryInfo
))
{
// local handle the super table tag query
if
(
tscIsProjectionQueryOnSTable
(
pQueryInfo
,
0
))
{
if
(
pQueryInfo
->
slimit
.
limit
>
0
||
pQueryInfo
->
slimit
.
offset
>
0
)
{
return
invalidSqlErrMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg
3
);
return
invalidSqlErrMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg
2
);
}
// for projection query on super table, all queries are subqueries
...
...
@@ -5363,24 +5362,6 @@ int32_t parseLimitClause(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, int32_t clauseIn
if
(
pQueryInfo
->
slimit
.
limit
!=
-
1
||
pQueryInfo
->
slimit
.
offset
!=
0
)
{
return
invalidSqlErrMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg1
);
}
size_t
size
=
taosArrayGetSize
(
pQueryInfo
->
exprList
);
bool
hasTags
=
false
;
bool
hasOtherFunc
=
false
;
// filter the query functions operating on "tbname" column that are not supported by normal columns.
for
(
int32_t
i
=
0
;
i
<
size
;
++
i
)
{
SSqlExpr
*
pExpr
=
tscSqlExprGet
(
pQueryInfo
,
i
);
if
(
TSDB_COL_IS_TAG
(
pExpr
->
colInfo
.
flag
))
{
hasTags
=
true
;
}
else
{
hasOtherFunc
=
true
;
}
}
if
(
hasTags
&&
hasOtherFunc
)
{
return
invalidSqlErrMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg2
);
}
}
return
TSDB_CODE_SUCCESS
;
...
...
@@ -6282,10 +6263,12 @@ int32_t doCheckForCreateFromStable(SSqlObj* pSql, SSqlInfo* pInfo) {
int32_t
doCheckForStream
(
SSqlObj
*
pSql
,
SSqlInfo
*
pInfo
)
{
const
char
*
msg1
=
"invalid table name"
;
const
char
*
msg2
=
"functions not allowed in CQ"
;
const
char
*
msg3
=
"fill only available for interval query"
;
const
char
*
msg4
=
"fill option not supported in stream computing"
;
const
char
*
msg5
=
"sql too long"
;
// todo ADD support
const
char
*
msg6
=
"from missing in subclause"
;
const
char
*
msg7
=
"time interval is required"
;
SSqlCmd
*
pCmd
=
&
pSql
->
cmd
;
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfoDetail
(
pCmd
,
0
);
...
...
@@ -6295,10 +6278,10 @@ int32_t doCheckForStream(SSqlObj* pSql, SSqlInfo* pInfo) {
STableMetaInfo
*
pTableMetaInfo
=
tscGetMetaInfo
(
pQueryInfo
,
0
);
// if sql specifies db, use it, otherwise use default db
SStrToken
*
p
zTable
Name
=
&
(
pCreateTable
->
name
);
SStrToken
*
pName
=
&
(
pCreateTable
->
name
);
SQuerySQL
*
pQuerySql
=
pCreateTable
->
pSelect
;
if
(
tscValidateName
(
p
zTable
Name
)
!=
TSDB_CODE_SUCCESS
)
{
if
(
tscValidateName
(
pName
)
!=
TSDB_CODE_SUCCESS
)
{
return
invalidSqlErrMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg1
);
}
...
...
@@ -6337,15 +6320,19 @@ int32_t doCheckForStream(SSqlObj* pSql, SSqlInfo* pInfo) {
// set interval value
if
(
parseIntervalClause
(
pSql
,
pQueryInfo
,
pQuerySql
)
!=
TSDB_CODE_SUCCESS
)
{
return
TSDB_CODE_TSC_INVALID_SQL
;
}
else
{
if
((
pQueryInfo
->
interval
.
interval
>
0
)
&&
(
validateFunctionsInIntervalOrGroupbyQuery
(
pCmd
,
pQueryInfo
)
!=
TSDB_CODE_SUCCESS
))
{
return
TSDB_CODE_TSC_INVALID_SQL
;
}
}
if
((
pQueryInfo
->
interval
.
interval
>
0
)
&&
(
validateFunctionsInIntervalOrGroupbyQuery
(
pCmd
,
pQueryInfo
)
!=
TSDB_CODE_SUCCESS
))
{
return
invalidSqlErrMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg2
);
}
if
(
!
tscIsProjectionQuery
(
pQueryInfo
)
&&
pQueryInfo
->
interval
.
interval
==
0
)
{
return
invalidSqlErrMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg7
);
}
// set the created table[stream] name
code
=
tscSetTableFullName
(
pTableMetaInfo
,
p
zTable
Name
,
pSql
);
code
=
tscSetTableFullName
(
pTableMetaInfo
,
pName
,
pSql
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
return
code
;
}
...
...
src/client/src/tscStream.c
浏览文件 @
c52f23ee
...
...
@@ -65,44 +65,51 @@ static int64_t tscGetRetryDelayTime(SSqlStream* pStream, int64_t slidingTime, in
return
retryDelta
;
}
static
void
tscProcessStreamLaunchQuery
(
SSchedMsg
*
pMsg
)
{
SSqlStream
*
pStream
=
(
SSqlStream
*
)
p
Msg
->
ahandle
;
SSqlObj
*
pSql
=
pStream
->
pSql
;
static
void
doLaunchQuery
(
void
*
param
,
TAOS_RES
*
tres
,
int32_t
code
)
{
SSqlStream
*
pStream
=
(
SSqlStream
*
)
p
aram
;
assert
(
pStream
->
pSql
==
tres
&&
code
==
TSDB_CODE_SUCCESS
)
;
pSql
->
fp
=
tscProcessStreamQueryCallback
;
pSql
->
f
etchFp
=
tscProcessStreamQueryCallback
;
pSql
->
param
=
pStream
;
SSqlObj
*
pSql
=
(
SSqlObj
*
)
tres
;
pSql
->
f
p
=
doLaunchQuery
;
pSql
->
fetchFp
=
doLaunchQuery
;
pSql
->
res
.
completed
=
false
;
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfoDetail
(
&
pSql
->
cmd
,
0
);
STableMetaInfo
*
pTableMetaInfo
=
tscGetMetaInfo
(
pQueryInfo
,
0
);
int
code
=
tscGetTableMeta
(
pSql
,
pTableMetaInfo
);
pSql
->
res
.
code
=
code
;
code
=
tscGetTableMeta
(
pSql
,
pTableMetaInfo
);
if
(
code
==
0
&&
UTIL_TABLE_IS_SUPER_TABLE
(
pTableMetaInfo
))
{
code
=
tscGetSTableVgroupInfo
(
pSql
,
0
);
pSql
->
res
.
code
=
code
;
}
// failed to get meter/metric meta, retry in 10sec.
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
int64_t
retryDelayTime
=
tscGetRetryDelayTime
(
pStream
,
pStream
->
interval
.
sliding
,
pStream
->
precision
);
tscDebug
(
"%p stream:%p,get metermeta failed, retry in %"
PRId64
"ms"
,
pStream
->
pSql
,
pStream
,
retryDelayTime
);
tscSetRetryTimer
(
pStream
,
pSql
,
retryDelayTime
);
}
else
{
// failed to get table Meta or vgroup list, retry in 10sec.
if
(
code
==
TSDB_CODE_SUCCESS
)
{
tscTansformSQLFuncForSTableQuery
(
pQueryInfo
);
tscDebug
(
"%p stream:%p start stream query on:%s"
,
pSql
,
pStream
,
pTableMetaInfo
->
name
);
tscDoQuery
(
pStream
->
pSql
);
tscDebug
(
"%p stream:%p, start stream query on:%s"
,
pSql
,
pStream
,
pTableMetaInfo
->
name
);
pSql
->
fp
=
tscProcessStreamQueryCallback
;
pSql
->
fetchFp
=
tscProcessStreamQueryCallback
;
tscDoQuery
(
pSql
);
tscIncStreamExecutionCount
(
pStream
);
}
else
if
(
code
!=
TSDB_CODE_TSC_ACTION_IN_PROGRESS
)
{
pSql
->
res
.
code
=
code
;
int64_t
retryDelayTime
=
tscGetRetryDelayTime
(
pStream
,
pStream
->
interval
.
sliding
,
pStream
->
precision
);
tscDebug
(
"%p stream:%p, get table Meta failed, retry in %"
PRId64
"ms"
,
pSql
,
pStream
,
retryDelayTime
);
tscSetRetryTimer
(
pStream
,
pSql
,
retryDelayTime
);
}
}
static
void
tscProcessStreamLaunchQuery
(
SSchedMsg
*
pMsg
)
{
SSqlStream
*
pStream
=
(
SSqlStream
*
)
pMsg
->
ahandle
;
doLaunchQuery
(
pStream
,
pStream
->
pSql
,
0
);
}
static
void
tscProcessStreamTimer
(
void
*
handle
,
void
*
tmrId
)
{
SSqlStream
*
pStream
=
(
SSqlStream
*
)
handle
;
if
(
pStream
==
NULL
)
return
;
if
(
pStream
->
pTimer
!=
tmrId
)
return
;
if
(
pStream
==
NULL
||
pStream
->
pTimer
!=
tmrId
)
{
return
;
}
pStream
->
pTimer
=
NULL
;
pStream
->
numOfRes
=
0
;
// reset the numOfRes.
...
...
@@ -392,11 +399,16 @@ static void tscSetNextLaunchTimer(SSqlStream *pStream, SSqlObj *pSql) {
tscSetRetryTimer
(
pStream
,
pSql
,
timer
);
}
static
void
tscSetSlidingWindowInfo
(
SSqlObj
*
pSql
,
SSqlStream
*
pStream
)
{
static
int32_t
tscSetSlidingWindowInfo
(
SSqlObj
*
pSql
,
SSqlStream
*
pStream
)
{
int64_t
minIntervalTime
=
(
pStream
->
precision
==
TSDB_TIME_PRECISION_MICRO
)
?
tsMinIntervalTime
*
1000L
:
tsMinIntervalTime
;
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfoDetail
(
&
pSql
->
cmd
,
0
);
if
(
!
pStream
->
isProject
&&
pQueryInfo
->
interval
.
interval
==
0
)
{
sprintf
(
pSql
->
cmd
.
payload
,
"the interval value is 0"
);
return
-
1
;
}
if
(
pQueryInfo
->
interval
.
intervalUnit
!=
'n'
&&
pQueryInfo
->
interval
.
intervalUnit
!=
'y'
&&
pQueryInfo
->
interval
.
interval
<
minIntervalTime
)
{
tscWarn
(
"%p stream:%p, original sample interval:%"
PRId64
" too small, reset to:%"
PRId64
,
pSql
,
pStream
,
...
...
@@ -436,6 +448,8 @@ static void tscSetSlidingWindowInfo(SSqlObj *pSql, SSqlStream *pStream) {
pQueryInfo
->
interval
.
interval
=
0
;
// clear the interval value to avoid the force time window split by query processor
pQueryInfo
->
interval
.
sliding
=
0
;
}
return
TSDB_CODE_SUCCESS
;
}
static
int64_t
tscGetStreamStartTimestamp
(
SSqlObj
*
pSql
,
SSqlStream
*
pStream
,
int64_t
stime
)
{
...
...
@@ -485,34 +499,19 @@ static int64_t tscGetLaunchTimestamp(const SSqlStream *pStream) {
return
(
pStream
->
precision
==
TSDB_TIME_PRECISION_MICRO
)
?
timer
/
1000L
:
timer
;
}
static
void
setErrorInfo
(
SSqlObj
*
pSql
,
int32_t
code
,
char
*
info
)
{
if
(
pSql
==
NULL
)
{
return
;
}
SSqlCmd
*
pCmd
=
&
pSql
->
cmd
;
pSql
->
res
.
code
=
code
;
if
(
info
!=
NULL
)
{
strncpy
(
pCmd
->
payload
,
info
,
pCmd
->
payloadLen
);
}
}
static
void
tscCreateStream
(
void
*
param
,
TAOS_RES
*
res
,
int
code
)
{
SSqlStream
*
pStream
=
(
SSqlStream
*
)
param
;
SSqlObj
*
pSql
=
pStream
->
pSql
;
SSqlCmd
*
pCmd
=
&
pSql
->
cmd
;
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
setErrorInfo
(
pSql
,
code
,
pCmd
->
payload
);
tscError
(
"%p open stream failed, sql:%s, reason:%s, code:0x%08x"
,
pSql
,
pSql
->
sqlstr
,
pCmd
->
payload
,
code
);
pSql
->
res
.
code
=
code
;
tscError
(
"%p open stream failed, sql:%s, reason:%s, code:%s"
,
pSql
,
pSql
->
sqlstr
,
pCmd
->
payload
,
tstrerror
(
code
));
pStream
->
fp
(
pStream
->
param
,
NULL
,
NULL
);
return
;
}
registerSqlObj
(
pSql
);
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfoDetail
(
pCmd
,
0
);
STableMetaInfo
*
pTableMetaInfo
=
tscGetMetaInfo
(
pQueryInfo
,
0
);
STableComInfo
tinfo
=
tscGetTableInfo
(
pTableMetaInfo
->
pTableMeta
);
...
...
@@ -523,13 +522,22 @@ static void tscCreateStream(void *param, TAOS_RES *res, int code) {
pStream
->
ctime
=
taosGetTimestamp
(
pStream
->
precision
);
pStream
->
etime
=
pQueryInfo
->
window
.
ekey
;
tscAddIntoStreamList
(
pStream
);
if
(
tscSetSlidingWindowInfo
(
pSql
,
pStream
)
!=
TSDB_CODE_SUCCESS
)
{
pSql
->
res
.
code
=
code
;
tscError
(
"%p stream %p open failed, since the interval value is incorrect"
,
pSql
,
pStream
);
pStream
->
fp
(
pStream
->
param
,
NULL
,
NULL
);
return
;
}
tscSetSlidingWindowInfo
(
pSql
,
pStream
);
pStream
->
stime
=
tscGetStreamStartTimestamp
(
pSql
,
pStream
,
pStream
->
stime
);
int64_t
starttime
=
tscGetLaunchTimestamp
(
pStream
);
pCmd
->
command
=
TSDB_SQL_SELECT
;
registerSqlObj
(
pSql
);
tscAddIntoStreamList
(
pStream
);
taosTmrReset
(
tscProcessStreamTimer
,
(
int32_t
)
starttime
,
pStream
,
tscTmr
,
&
pStream
->
pTimer
);
tscDebug
(
"%p stream:%p is opened, query on:%s, interval:%"
PRId64
", sliding:%"
PRId64
", first launched in:%"
PRId64
", sql:%s"
,
pSql
,
...
...
src/client/src/tscSubquery.c
浏览文件 @
c52f23ee
...
...
@@ -2094,6 +2094,13 @@ static SSqlObj *tscCreateSTableSubquery(SSqlObj *pSql, SRetrieveSupport *trsuppo
}
void
tscRetrieveDataRes
(
void
*
param
,
TAOS_RES
*
tres
,
int
code
)
{
// the param may be null, since it may be done by other query threads. and the asyncOnError may enter in this
// function while kill query by a user.
if
(
param
==
NULL
)
{
assert
(
code
!=
TSDB_CODE_SUCCESS
);
return
;
}
SRetrieveSupport
*
trsupport
=
(
SRetrieveSupport
*
)
param
;
SSqlObj
*
pParentSql
=
trsupport
->
pParentSql
;
...
...
src/query/inc/qExecutor.h
浏览文件 @
c52f23ee
...
...
@@ -152,7 +152,7 @@ typedef struct SQuery {
int16_t
precision
;
int16_t
numOfOutput
;
int16_t
fillType
;
int16_t
check
Buffer
;
// check if the buffer is full during scan each block
int16_t
check
ResultBuf
;
// check if the buffer is full during scan each block
SLimitVal
limit
;
int32_t
rowSize
;
SSqlGroupbyExpr
*
pGroupbyExpr
;
...
...
src/query/src/qExecutor.c
浏览文件 @
c52f23ee
...
...
@@ -1708,7 +1708,7 @@ static int32_t tableApplyFunctionsOnBlock(SQueryRuntimeEnv *pRuntimeEnv, SDataBl
numOfRes
=
(
int32_t
)
getNumOfResult
(
pRuntimeEnv
);
// update the number of output result
if
(
numOfRes
>
0
&&
pQuery
->
check
Buffer
==
1
)
{
if
(
numOfRes
>
0
&&
pQuery
->
check
ResultBuf
==
1
)
{
assert
(
numOfRes
>=
pQuery
->
rec
.
rows
);
pQuery
->
rec
.
rows
=
numOfRes
;
...
...
@@ -2222,9 +2222,9 @@ void getAlignQueryTimeWindow(SQuery *pQuery, int64_t key, int64_t keyFirst, int6
static
void
setScanLimitationByResultBuffer
(
SQuery
*
pQuery
)
{
if
(
isTopBottomQuery
(
pQuery
))
{
pQuery
->
check
Buffer
=
0
;
pQuery
->
check
ResultBuf
=
0
;
}
else
if
(
isGroupbyNormalCol
(
pQuery
->
pGroupbyExpr
))
{
pQuery
->
check
Buffer
=
0
;
pQuery
->
check
ResultBuf
=
0
;
}
else
{
bool
hasMultioutput
=
false
;
for
(
int32_t
i
=
0
;
i
<
pQuery
->
numOfOutput
;
++
i
)
{
...
...
@@ -2239,7 +2239,7 @@ static void setScanLimitationByResultBuffer(SQuery *pQuery) {
}
}
pQuery
->
check
Buffer
=
hasMultioutput
?
1
:
0
;
pQuery
->
check
ResultBuf
=
hasMultioutput
?
1
:
0
;
}
}
...
...
@@ -2911,7 +2911,7 @@ void setTagVal(SQueryRuntimeEnv *pRuntimeEnv, void *pTable, void *tsdb) {
SQInfo
*
pQInfo
=
GET_QINFO_ADDR
(
pRuntimeEnv
);
SExprInfo
*
pExprInfo
=
&
pQuery
->
pExpr1
[
0
];
if
(
pQuery
->
numOfOutput
==
1
&&
pExprInfo
->
base
.
functionId
==
TSDB_FUNC_TS_COMP
)
{
if
(
pQuery
->
numOfOutput
==
1
&&
pExprInfo
->
base
.
functionId
==
TSDB_FUNC_TS_COMP
&&
pRuntimeEnv
->
stableQuery
)
{
assert
(
pExprInfo
->
base
.
numOfParams
==
1
);
int16_t
tagColId
=
(
int16_t
)
pExprInfo
->
base
.
arg
->
argValue
.
i64
;
...
...
@@ -3674,6 +3674,10 @@ void scanOneTableDataBlocks(SQueryRuntimeEnv *pRuntimeEnv, TSKEY start) {
SQueryStatusInfo
qstatus
=
getQueryStatusInfo
(
pRuntimeEnv
,
start
);
SET_MASTER_SCAN_FLAG
(
pRuntimeEnv
);
if
(
!
pRuntimeEnv
->
groupbyColumn
&&
pRuntimeEnv
->
hasTagResults
)
{
setTagVal
(
pRuntimeEnv
,
pTableQueryInfo
->
pTable
,
pQInfo
->
tsdb
);
}
while
(
1
)
{
doScanAllDataBlocks
(
pRuntimeEnv
);
...
...
@@ -4757,20 +4761,21 @@ static void enableExecutionForNextTable(SQueryRuntimeEnv *pRuntimeEnv) {
}
}
// TODO refactor: setAdditionalInfo
static
FORCE_INLINE
void
setEnvForEachBlock
(
SQInfo
*
pQInfo
,
STableQueryInfo
*
pTableQueryInfo
,
SDataBlockInfo
*
pBlockInfo
)
{
SQueryRuntimeEnv
*
pRuntimeEnv
=
&
pQInfo
->
runtimeEnv
;
SQuery
*
pQuery
=
pQInfo
->
runtimeEnv
.
pQuery
;
int32_t
step
=
GET_FORWARD_DIRECTION_FACTOR
(
pQuery
->
order
.
order
);
if
(
!
QUERY_IS_INTERVAL_QUERY
(
pQuery
))
{
setExecutionContext
(
pQInfo
,
pTableQueryInfo
->
groupIndex
,
pBlockInfo
->
window
.
ekey
+
step
);
}
else
{
// interval query
if
(
QUERY_IS_INTERVAL_QUERY
(
pQuery
))
{
TSKEY
nextKey
=
pBlockInfo
->
window
.
skey
;
setIntervalQueryRange
(
pQInfo
,
nextKey
);
if
(
pRuntimeEnv
->
hasTagResults
||
pRuntimeEnv
->
pTsBuf
!=
NULL
)
{
setAdditionalInfo
(
pQInfo
,
pTableQueryInfo
->
pTable
,
pTableQueryInfo
);
}
}
else
{
// non-interval query
setExecutionContext
(
pQInfo
,
pTableQueryInfo
->
groupIndex
,
pBlockInfo
->
window
.
ekey
+
step
);
}
}
...
...
@@ -5626,8 +5631,6 @@ static void tableAggregationProcess(SQInfo *pQInfo, STableQueryInfo* pTableInfo)
return
;
}
pQuery
->
current
=
pTableInfo
;
// set current query table info
scanOneTableDataBlocks
(
pRuntimeEnv
,
pTableInfo
->
lastKey
);
finalizeQueryResult
(
pRuntimeEnv
);
...
...
@@ -5646,10 +5649,8 @@ static void tableAggregationProcess(SQInfo *pQInfo, STableQueryInfo* pTableInfo)
static
void
tableProjectionProcess
(
SQInfo
*
pQInfo
,
STableQueryInfo
*
pTableInfo
)
{
SQueryRuntimeEnv
*
pRuntimeEnv
=
&
pQInfo
->
runtimeEnv
;
SQuery
*
pQuery
=
pRuntimeEnv
->
pQuery
;
pQuery
->
current
=
pTableInfo
;
// for ts_comp query, re-initialized is not allowed
SQuery
*
pQuery
=
pRuntimeEnv
->
pQuery
;
if
(
!
isTSCompQuery
(
pQuery
))
{
resetDefaultResInfoOutputBuf
(
pRuntimeEnv
);
}
...
...
@@ -5701,9 +5702,7 @@ static void tableProjectionProcess(SQInfo *pQInfo, STableQueryInfo* pTableInfo)
// handle time interval query on table
static
void
tableIntervalProcess
(
SQInfo
*
pQInfo
,
STableQueryInfo
*
pTableInfo
)
{
SQueryRuntimeEnv
*
pRuntimeEnv
=
&
(
pQInfo
->
runtimeEnv
);
SQuery
*
pQuery
=
pRuntimeEnv
->
pQuery
;
pQuery
->
current
=
pTableInfo
;
TSKEY
newStartKey
=
QUERY_IS_ASC_QUERY
(
pQuery
)
?
INT64_MIN
:
INT64_MAX
;
...
...
@@ -5773,7 +5772,6 @@ static void tableQueryImpl(SQInfo *pQInfo) {
}
qDebug
(
"QInfo:%p current:%"
PRId64
" returned, total:%"
PRId64
,
pQInfo
,
pQuery
->
rec
.
rows
,
pQuery
->
rec
.
total
);
return
;
}
else
{
pQuery
->
rec
.
rows
=
0
;
assert
(
pRuntimeEnv
->
windowResInfo
.
size
>
0
);
...
...
@@ -5791,9 +5789,9 @@ static void tableQueryImpl(SQInfo *pQInfo) {
if
(
pQuery
->
rec
.
rows
<=
0
||
pRuntimeEnv
->
windowResInfo
.
size
<=
pQInfo
->
groupIndex
)
{
qDebug
(
"QInfo:%p query over, %"
PRId64
" rows are returned"
,
pQInfo
,
pQuery
->
rec
.
total
);
}
return
;
}
return
;
}
// number of points returned during this query
...
...
@@ -5802,7 +5800,9 @@ static void tableQueryImpl(SQInfo *pQInfo) {
assert
(
pQInfo
->
tableqinfoGroupInfo
.
numOfTables
==
1
);
SArray
*
g
=
GET_TABLEGROUP
(
pQInfo
,
0
);
STableQueryInfo
*
item
=
taosArrayGetP
(
g
,
0
);
pQuery
->
current
=
item
;
// group by normal column, sliding window query, interval query are handled by interval query processor
if
(
QUERY_IS_INTERVAL_QUERY
(
pQuery
)
||
pRuntimeEnv
->
groupbyColumn
)
{
// interval (down sampling operation)
...
...
@@ -5810,7 +5810,7 @@ static void tableQueryImpl(SQInfo *pQInfo) {
}
else
if
(
isFixedOutputQuery
(
pRuntimeEnv
))
{
tableAggregationProcess
(
pQInfo
,
item
);
}
else
{
// diff/add/multiply/subtract/division
assert
(
pQuery
->
check
Buffer
==
1
);
assert
(
pQuery
->
check
ResultBuf
==
1
);
tableProjectionProcess
(
pQInfo
,
item
);
}
...
...
@@ -5830,7 +5830,7 @@ static void stableQueryImpl(SQInfo *pQInfo) {
(
isFixedOutputQuery
(
pRuntimeEnv
)
&&
(
!
isPointInterpoQuery
(
pQuery
))
&&
(
!
pRuntimeEnv
->
groupbyColumn
)))
{
multiTableQueryProcess
(
pQInfo
);
}
else
{
assert
((
pQuery
->
check
Buffer
==
1
&&
pQuery
->
interval
.
interval
==
0
)
||
isPointInterpoQuery
(
pQuery
)
||
assert
((
pQuery
->
check
ResultBuf
==
1
&&
pQuery
->
interval
.
interval
==
0
)
||
isPointInterpoQuery
(
pQuery
)
||
pRuntimeEnv
->
groupbyColumn
);
sequentialTableProcess
(
pQInfo
);
...
...
tests/script/general/parser/select_with_tags.sim
浏览文件 @
c52f23ee
...
...
@@ -813,8 +813,6 @@ sql_error select first(ts), first(c1),tbname from select_tags_mt0;
sql_error select first(ts), last(ts), tbname from select_tags_mt0;
sql_error select last_row(*), first(ts), tbname, t1, t2 from select_tags_mt0;
sql_error select tbname, last_row(*), t1, first(ts) from select_tags_mt0;
sql_error select first(ts), tbname from select_tags_tb0;
sql_error select last_row(*), t1 from select_tags_tb0;
sql_error select count(*), tbname from select_tags_mt0;
sql_error select sum(c2), tbname from select_tags_mt0;
sql_error select avg(c3), tbname from select_tags_mt0;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录