Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
39fb5651
TDengine
项目概览
taosdata
/
TDengine
12 个月 前同步成功
通知
1180
Star
22014
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
39fb5651
编写于
4月 12, 2022
作者:
D
dapan1121
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'feature/qnode' of github.com:taosdata/TDengine into feature/qnode
上级
b8391fad
baab0651
变更
20
展开全部
隐藏空白更改
内联
并排
Showing
20 changed file
with
2482 addition
and
155 deletion
+2482
-155
source/client/test/clientTests.cpp
source/client/test/clientTests.cpp
+3
-2
source/common/src/tmsg.c
source/common/src/tmsg.c
+1
-1
source/dnode/mgmt/main/dndInt.c
source/dnode/mgmt/main/dndInt.c
+2
-2
source/dnode/mgmt/main/dndTransport.c
source/dnode/mgmt/main/dndTransport.c
+13
-6
source/dnode/mgmt/mm/mmHandle.c
source/dnode/mgmt/mm/mmHandle.c
+1
-1
source/dnode/mgmt/mm/mmInt.c
source/dnode/mgmt/mm/mmInt.c
+3
-0
source/dnode/mgmt/test/mnode/dmnode.cpp
source/dnode/mgmt/test/mnode/dmnode.cpp
+1
-1
source/libs/executor/inc/executorimpl.h
source/libs/executor/inc/executorimpl.h
+10
-5
source/libs/executor/src/executorimpl.c
source/libs/executor/src/executorimpl.c
+59
-56
source/libs/executor/src/groupoperator.c
source/libs/executor/src/groupoperator.c
+12
-5
source/libs/function/src/builtins.c
source/libs/function/src/builtins.c
+1
-1
source/libs/function/src/builtinsimpl.c
source/libs/function/src/builtinsimpl.c
+2
-2
tests/script/jenkins/basic.txt
tests/script/jenkins/basic.txt
+10
-2
tests/script/tsim/mnode/basic1.sim
tests/script/tsim/mnode/basic1.sim
+0
-1
tests/script/tsim/query/complex_group.sim
tests/script/tsim/query/complex_group.sim
+476
-0
tests/script/tsim/query/complex_limit.sim
tests/script/tsim/query/complex_limit.sim
+535
-0
tests/script/tsim/query/complex_select.sim
tests/script/tsim/query/complex_select.sim
+585
-0
tests/script/tsim/query/complex_where.sim
tests/script/tsim/query/complex_where.sim
+691
-0
tests/script/tsim/query/explain.sim
tests/script/tsim/query/explain.sim
+0
-0
tests/script/tsim/query/session.sim
tests/script/tsim/query/session.sim
+77
-70
未找到文件。
source/client/test/clientTests.cpp
浏览文件 @
39fb5651
...
...
@@ -400,7 +400,7 @@ TEST(testCase, show_vgroup_Test) {
taos_free_result(pRes);
taos_close(pConn);
}
#endif
TEST(testCase, create_multiple_tables) {
TAOS* pConn = taos_connect("localhost", "root", "taosdata", NULL, 0);
...
...
@@ -653,6 +653,7 @@ TEST(testCase, projection_query_stables) {
taos_free_result(pRes);
taos_close(pConn);
}
#endif
TEST
(
testCase
,
agg_query_tables
)
{
TAOS
*
pConn
=
taos_connect
(
"localhost"
,
"root"
,
"taosdata"
,
NULL
,
0
);
...
...
@@ -661,7 +662,7 @@ TEST(testCase, agg_query_tables) {
TAOS_RES
*
pRes
=
taos_query
(
pConn
,
"use abc1"
);
taos_free_result
(
pRes
);
pRes
=
taos_query
(
pConn
,
"select
count(*
) from tu"
);
pRes
=
taos_query
(
pConn
,
"select
length('abc'
) from tu"
);
if
(
taos_errno
(
pRes
)
!=
0
)
{
printf
(
"failed to select from table, reason:%s
\n
"
,
taos_errstr
(
pRes
));
taos_free_result
(
pRes
);
...
...
source/common/src/tmsg.c
浏览文件 @
39fb5651
...
...
@@ -2071,7 +2071,7 @@ int32_t tDeserializeSUseDbBatchRsp(void *buf, int32_t bufLen, SUseDbBatchRsp *pR
int32_t
numOfBatch
=
taosArrayGetSize
(
pRsp
->
pArray
);
if
(
tDecodeI32
(
&
decoder
,
&
numOfBatch
)
<
0
)
return
-
1
;
pRsp
->
pArray
=
taosArrayInit
(
numOfBatch
,
sizeof
(
SUseDb
Batch
Rsp
));
pRsp
->
pArray
=
taosArrayInit
(
numOfBatch
,
sizeof
(
SUseDbRsp
));
if
(
pRsp
->
pArray
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
-
1
;
...
...
source/dnode/mgmt/main/dndInt.c
浏览文件 @
39fb5651
...
...
@@ -158,7 +158,7 @@ SMgmtWrapper *dndAcquireWrapper(SDnode *pDnode, EDndType ntype) {
int32_t
refCount
=
atomic_add_fetch_32
(
&
pWrapper
->
refCount
,
1
);
dTrace
(
"node:%s, is acquired, refCount:%d"
,
pWrapper
->
name
,
refCount
);
}
else
{
terrno
=
TSDB_CODE_NODE_
REDIRECT
;
terrno
=
TSDB_CODE_NODE_
NOT_DEPLOYED
;
pRetWrapper
=
NULL
;
}
taosRUnLockLatch
(
&
pWrapper
->
latch
);
...
...
@@ -174,7 +174,7 @@ int32_t dndMarkWrapper(SMgmtWrapper *pWrapper) {
int32_t
refCount
=
atomic_add_fetch_32
(
&
pWrapper
->
refCount
,
1
);
dTrace
(
"node:%s, is marked, refCount:%d"
,
pWrapper
->
name
,
refCount
);
}
else
{
terrno
=
TSDB_CODE_NODE_
REDIRECT
;
terrno
=
TSDB_CODE_NODE_
NOT_DEPLOYED
;
code
=
-
1
;
}
taosRUnLockLatch
(
&
pWrapper
->
latch
);
...
...
source/dnode/mgmt/main/dndTransport.c
浏览文件 @
39fb5651
...
...
@@ -53,8 +53,9 @@ static void dndProcessRpcMsg(SMgmtWrapper *pWrapper, SRpcMsg *pRpc, SEpSet *pEpS
int32_t
code
=
-
1
;
SNodeMsg
*
pMsg
=
NULL
;
NodeMsgFp
msgFp
=
NULL
;
uint16_t
msgType
=
pRpc
->
msgType
;
if
(
pEpSet
&&
pEpSet
->
numOfEps
>
0
&&
pRpc
->
msgType
==
TDMT_MND_STATUS_RSP
)
{
if
(
pEpSet
&&
pEpSet
->
numOfEps
>
0
&&
msgType
==
TDMT_MND_STATUS_RSP
)
{
dndUpdateMnodeEpSet
(
pWrapper
->
pDnode
,
pEpSet
);
}
...
...
@@ -84,9 +85,15 @@ _OVER:
}
}
else
{
dError
(
"msg:%p, failed to process since 0x%04x:%s"
,
pMsg
,
code
&
0XFFFF
,
terrstr
());
if
(
pRpc
->
msgType
&
1U
)
{
if
(
msgType
&
1U
)
{
if
(
terrno
!=
0
)
code
=
terrno
;
SRpcMsg
rsp
=
{.
handle
=
pRpc
->
handle
,
.
ahandle
=
pRpc
->
ahandle
,
.
code
=
terrno
};
if
(
code
==
TSDB_CODE_NODE_NOT_DEPLOYED
||
code
==
TSDB_CODE_NODE_OFFLINE
)
{
if
(
msgType
>
TDMT_MND_MSG
&&
msgType
<
TDMT_VND_MSG
)
{
code
=
TSDB_CODE_NODE_REDIRECT
;
}
}
SRpcMsg
rsp
=
{.
handle
=
pRpc
->
handle
,
.
ahandle
=
pRpc
->
ahandle
,
.
code
=
code
};
tmsgSendRsp
(
&
rsp
);
}
dTrace
(
"msg:%p, is freed"
,
pMsg
);
...
...
@@ -348,8 +355,7 @@ static int32_t dndSendRpcReq(STransMgmt *pMgmt, const SEpSet *pEpSet, SRpcMsg *p
}
static
void
dndSendRpcRsp
(
SMgmtWrapper
*
pWrapper
,
const
SRpcMsg
*
pRsp
)
{
if
(
pRsp
->
code
==
TSDB_CODE_APP_NOT_READY
||
pRsp
->
code
==
TSDB_CODE_NODE_REDIRECT
||
pRsp
->
code
==
TSDB_CODE_NODE_OFFLINE
)
{
if
(
pRsp
->
code
==
TSDB_CODE_NODE_REDIRECT
)
{
dmSendRedirectRsp
(
pWrapper
->
pMgmt
,
pRsp
);
}
else
{
rpcSendResponse
(
pRsp
);
...
...
@@ -442,7 +448,8 @@ static void dndConsumeChildQueue(SMgmtWrapper *pWrapper, SNodeMsg *pMsg, int16_t
static
void
dndConsumeParentQueue
(
SMgmtWrapper
*
pWrapper
,
SRpcMsg
*
pMsg
,
int16_t
msgLen
,
void
*
pCont
,
int32_t
contLen
,
ProcFuncType
ftype
)
{
pMsg
->
pCont
=
pCont
;
dTrace
(
"msg:%p, get from parent queue, ftype:%d handle:%p, app:%p"
,
pMsg
,
ftype
,
pMsg
->
handle
,
pMsg
->
ahandle
);
dTrace
(
"msg:%p, get from parent queue, ftype:%d handle:%p code:0x%04x mtype:%d, app:%p"
,
pMsg
,
ftype
,
pMsg
->
handle
,
pMsg
->
code
&
0xFFFF
,
pMsg
->
msgType
,
pMsg
->
ahandle
);
switch
(
ftype
)
{
case
PROC_REGIST
:
...
...
source/dnode/mgmt/mm/mmHandle.c
浏览文件 @
39fb5651
...
...
@@ -96,7 +96,7 @@ int32_t mmProcessAlterReq(SMnodeMgmt *pMgmt, SNodeMsg *pMsg) {
if
(
alterReq
.
dnodeId
!=
pDnode
->
dnodeId
)
{
terrno
=
TSDB_CODE_INVALID_OPTION
;
dError
(
"failed to alter mnode since %s
"
,
terrstr
()
);
dError
(
"failed to alter mnode since %s
, dnodeId:%d input:%d"
,
terrstr
(),
pDnode
->
dnodeId
,
alterReq
.
dnodeId
);
return
-
1
;
}
else
{
return
mmAlter
(
pMgmt
,
&
alterReq
);
...
...
source/dnode/mgmt/mm/mmInt.c
浏览文件 @
39fb5651
...
...
@@ -112,6 +112,9 @@ static int32_t mmOpenImp(SMnodeMgmt *pMgmt, SDCreateMnodeReq *pReq) {
if
(
!
deployed
)
{
dInfo
(
"mnode start to deploy"
);
if
(
pMgmt
->
pWrapper
->
procType
==
PROC_CHILD
)
{
pMgmt
->
pDnode
->
dnodeId
=
1
;
}
mmBuildOptionForDeploy
(
pMgmt
,
&
option
);
}
else
{
dInfo
(
"mnode start to open"
);
...
...
source/dnode/mgmt/test/mnode/dmnode.cpp
浏览文件 @
39fb5651
...
...
@@ -188,7 +188,7 @@ TEST_F(DndTestMnode, 03_Drop_Mnode) {
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_DND_ALTER_MNODE
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_EQ
(
pRsp
->
code
,
TSDB_CODE_
RPC_REDIRECT
);
ASSERT_EQ
(
pRsp
->
code
,
TSDB_CODE_
NODE_NOT_DEPLOYED
);
}
{
...
...
source/libs/executor/inc/executorimpl.h
浏览文件 @
39fb5651
...
...
@@ -609,6 +609,12 @@ typedef struct SSessionAggOperatorInfo {
SColumnInfoData
timeWindowData
;
// query time window info for scalar function execution.
}
SSessionAggOperatorInfo
;
typedef
struct
STimeSliceOperatorInfo
{
SOptrBasicInfo
binfo
;
SInterval
interval
;
SGroupResInfo
groupResInfo
;
// multiple results build supporter
}
STimeSliceOperatorInfo
;
typedef
struct
SStateWindowOperatorInfo
{
SOptrBasicInfo
binfo
;
SAggSupporter
aggSup
;
...
...
@@ -665,7 +671,7 @@ int32_t operatorDummyOpenFn(SOperatorInfo* pOperator);
void
operatorDummyCloseFn
(
void
*
param
,
int32_t
numOfCols
);
int32_t
appendDownstream
(
SOperatorInfo
*
p
,
SOperatorInfo
**
pDownstream
,
int32_t
num
);
int32_t
initAggInfo
(
SOptrBasicInfo
*
pBasicInfo
,
SAggSupporter
*
pAggSup
,
SExprInfo
*
pExprInfo
,
int32_t
numOfCols
,
int32_t
numOfRows
,
SSDataBlock
*
pResultBlock
,
const
char
*
pkey
);
int32_t
numOfRows
,
SSDataBlock
*
pResultBlock
,
size_t
keyBufSize
,
const
char
*
pkey
);
void
toSDatablock
(
SGroupResInfo
*
pGroupResInfo
,
SDiskbasedBuf
*
pBuf
,
SSDataBlock
*
pBlock
,
int32_t
rowCapacity
,
int32_t
*
rowCellOffset
);
void
finalizeMultiTupleQueryResult
(
SqlFunctionCtx
*
pCtx
,
int32_t
numOfOutput
,
SDiskbasedBuf
*
pBuf
,
SResultRowInfo
*
pResultRowInfo
,
int32_t
*
rowCellInfoOffset
);
void
doApplyFunctions
(
SqlFunctionCtx
*
pCtx
,
STimeWindow
*
pWin
,
SColumnInfoData
*
pTimeWindowData
,
int32_t
offset
,
int32_t
forwardStep
,
TSKEY
*
tsCol
,
int32_t
numOfTotal
,
int32_t
numOfOutput
,
int32_t
order
);
...
...
@@ -707,16 +713,15 @@ SOperatorInfo* createStatewindowOperatorInfo(SOperatorInfo* downstream, SExprInf
SOperatorInfo
*
createPartitionOperatorInfo
(
SOperatorInfo
*
downstream
,
SExprInfo
*
pExprInfo
,
int32_t
numOfCols
,
SSDataBlock
*
pResultBlock
,
SArray
*
pGroupColList
,
SExecTaskInfo
*
pTaskInfo
,
const
STableGroupInfo
*
pTableGroupInfo
);
SOperatorInfo
*
createTimeSliceOperatorInfo
(
SOperatorInfo
*
downstream
,
SExprInfo
*
pExprInfo
,
int32_t
numOfCols
,
SSDataBlock
*
pResultBlock
,
SExecTaskInfo
*
pTaskInfo
);
#if 0
SOperatorInfo* createTableSeqScanOperatorInfo(void* pTsdbReadHandle, STaskRuntimeEnv* pRuntimeEnv);
SOperatorInfo* createAllTimeIntervalOperatorInfo(STaskRuntimeEnv* pRuntimeEnv, SOperatorInfo* downstream,
SExprInfo* pExpr, int32_t numOfOutput);
SOperatorInfo* createMultiTableTimeIntervalOperatorInfo(STaskRuntimeEnv* pRuntimeEnv, SOperatorInfo* downstream,
SExprInfo* pExpr, int32_t numOfOutput);
SOperatorInfo* createAllMultiTableTimeIntervalOperatorInfo(STaskRuntimeEnv* pRuntimeEnv, SOperatorInfo* downstream,
SExprInfo* pExpr, int32_t numOfOutput);
SOperatorInfo* createTagScanOperatorInfo(S
TaskRuntimeEnv* pRuntimeEnv
, SExprInfo* pExpr, int32_t numOfOutput);
SOperatorInfo* createTagScanOperatorInfo(S
ReaderHandle* pReaderHandle
, SExprInfo* pExpr, int32_t numOfOutput);
SOperatorInfo* createJoinOperatorInfo(SOperatorInfo** pdownstream, int32_t numOfDownstream, SSchema* pSchema,
int32_t numOfOutput);
...
...
source/libs/executor/src/executorimpl.c
浏览文件 @
39fb5651
...
...
@@ -1687,12 +1687,13 @@ static void doSessionWindowAggImpl(SOperatorInfo* pOperator, SSessionAggOperator
static
void
setResultRowKey
(
SResultRow
*
pResultRow
,
char
*
pData
,
int16_t
type
)
{
if
(
IS_VAR_DATA_TYPE
(
type
))
{
if
(
pResultRow
->
key
==
NULL
)
{
pResultRow
->
key
=
taosMemoryMalloc
(
varDataTLen
(
pData
));
varDataCopy
(
pResultRow
->
key
,
pData
);
}
else
{
assert
(
memcmp
(
pResultRow
->
key
,
pData
,
varDataTLen
(
pData
))
==
0
);
}
// todo disable this
// if (pResultRow->key == NULL) {
// pResultRow->key = taosMemoryMalloc(varDataTLen(pData));
// varDataCopy(pResultRow->key, pData);
// } else {
// ASSERT(memcmp(pResultRow->key, pData, varDataTLen(pData)) == 0);
// }
}
else
{
int64_t
v
=
-
1
;
GET_TYPED_DATA
(
v
,
int64_t
,
type
,
pData
);
...
...
@@ -4467,7 +4468,7 @@ SSDataBlock* createResultDataBlock(const SArray* pExprInfo) {
return
pResBlock
;
}
static
int32_t
doInitAggInfoSup
(
SAggSupporter
*
pAggSup
,
SqlFunctionCtx
*
pCtx
,
int32_t
numOfOutput
,
const
char
*
pKey
);
static
int32_t
doInitAggInfoSup
(
SAggSupporter
*
pAggSup
,
SqlFunctionCtx
*
pCtx
,
int32_t
numOfOutput
,
size_t
keyBufSize
,
const
char
*
pKey
);
static
void
cleanupAggSup
(
SAggSupporter
*
pAggSup
);
static
void
destroySortedMergeOperatorInfo
(
void
*
param
,
int32_t
numOfOutput
)
{
...
...
@@ -4826,7 +4827,8 @@ SOperatorInfo* createSortedMergeOperatorInfo(SOperatorInfo** downstream, int32_t
goto
_error
;
}
int32_t
code
=
doInitAggInfoSup
(
&
pInfo
->
aggSup
,
pInfo
->
binfo
.
pCtx
,
num
,
pTaskInfo
->
id
.
str
);
size_t
keyBufSize
=
sizeof
(
int64_t
)
+
sizeof
(
int64_t
)
+
POINTER_BYTES
;
int32_t
code
=
doInitAggInfoSup
(
&
pInfo
->
aggSup
,
pInfo
->
binfo
.
pCtx
,
num
,
keyBufSize
,
pTaskInfo
->
id
.
str
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
goto
_error
;
}
...
...
@@ -5429,58 +5431,48 @@ static SSDataBlock* doAllIntervalAgg(SOperatorInfo *pOperator, bool* newgroup) {
return
NULL
;
}
STableIntervalOperatorInfo
*
pIntervalInfo
=
pOperator
->
info
;
STaskRuntimeEnv
*
pRuntimeEnv
=
pOperator
->
pRuntimeEnv
;
STimeSliceOperatorInfo
*
pSliceInfo
=
pOperator
->
info
;
if
(
pOperator
->
status
==
OP_RES_TO_RETURN
)
{
// toSDatablock(&pRuntimeEnv->groupResInfo, pRuntimeEnv, pIntervalInfo->pRes);
if
(
pIntervalInfo
->
binfo
.
pRes
->
info
.
rows
==
0
||
!
hasRemainDataInCurrentGroup
(
&
pRuntimeEnv
->
groupResInfo
))
{
if
(
pSliceInfo
->
binfo
.
pRes
->
info
.
rows
==
0
||
!
hasRemainDataInCurrentGroup
(
&
pSliceInfo
->
groupResInfo
))
{
doSetOperatorCompleted
(
pOperator
);
}
return
p
Interval
Info
->
binfo
.
pRes
;
return
p
Slice
Info
->
binfo
.
pRes
;
}
STaskAttr
*
pQueryAttr
=
pRuntimeEnv
->
pQueryAttr
;
int32_t
order
=
pQueryAttr
->
order
.
order
;
STimeWindow
win
=
pQueryAttr
->
window
;
int32_t
order
=
TSDB_ORDER_ASC
;
// STimeWindow win = pQueryAttr->window;
SOperatorInfo
*
downstream
=
pOperator
->
pDownstream
[
0
];
while
(
1
)
{
publishOperatorProfEvent
(
downstream
,
QUERY_PROF_BEFORE_OPERATOR_EXEC
);
SSDataBlock
*
pBlock
=
downstream
->
getNextFn
(
downstream
,
newgroup
);
publishOperatorProfEvent
(
downstream
,
QUERY_PROF_AFTER_OPERATOR_EXEC
);
if
(
pBlock
==
NULL
)
{
break
;
}
// setTagValue(pOperator, pRuntimeEnv->current->pTable, pIntervalInfo->pCtx, pOperator->numOfOutput);
// the pDataBlock are always the same one, no need to call this again
setInputDataBlock
(
pOperator
,
p
IntervalInfo
->
binfo
.
pCtx
,
pBlock
,
pQueryAttr
->
order
.
order
);
hashAllIntervalAgg
(
pOperator
,
&
p
Interval
Info
->
binfo
.
resultRowInfo
,
pBlock
,
0
);
setInputDataBlock
(
pOperator
,
p
SliceInfo
->
binfo
.
pCtx
,
pBlock
,
order
);
hashAllIntervalAgg
(
pOperator
,
&
p
Slice
Info
->
binfo
.
resultRowInfo
,
pBlock
,
0
);
}
// restore the value
pQueryAttr
->
order
.
order
=
order
;
pQueryAttr
->
window
=
win
;
pOperator
->
status
=
OP_RES_TO_RETURN
;
closeAllResultRows
(
&
p
Interval
Info
->
binfo
.
resultRowInfo
);
closeAllResultRows
(
&
p
Slice
Info
->
binfo
.
resultRowInfo
);
setTaskStatus
(
pOperator
->
pTaskInfo
,
TASK_COMPLETED
);
finalizeQueryResult
(
p
Interval
Info
->
binfo
.
pCtx
,
pOperator
->
numOfOutput
);
finalizeQueryResult
(
p
Slice
Info
->
binfo
.
pCtx
,
pOperator
->
numOfOutput
);
initGroupResInfo
(
&
p
RuntimeEnv
->
groupResInfo
,
&
pInterval
Info
->
binfo
.
resultRowInfo
);
// toSDatablock(&pRuntimeEnv->groupResInfo, pRuntimeEnv, p
Interval
Info->pRes);
initGroupResInfo
(
&
p
SliceInfo
->
groupResInfo
,
&
pSlice
Info
->
binfo
.
resultRowInfo
);
// toSDatablock(&pRuntimeEnv->groupResInfo, pRuntimeEnv, p
Slice
Info->pRes);
if
(
p
IntervalInfo
->
binfo
.
pRes
->
info
.
rows
==
0
||
!
hasRemainDataInCurrentGroup
(
&
pRuntimeEnv
->
groupResInfo
))
{
if
(
p
SliceInfo
->
binfo
.
pRes
->
info
.
rows
==
0
||
!
hasRemainDataInCurrentGroup
(
&
pSliceInfo
->
groupResInfo
))
{
pOperator
->
status
=
OP_EXEC_DONE
;
}
return
p
IntervalInfo
->
binfo
.
pRes
->
info
.
rows
==
0
?
NULL
:
pInterval
Info
->
binfo
.
pRes
;
return
p
SliceInfo
->
binfo
.
pRes
->
info
.
rows
==
0
?
NULL
:
pSlice
Info
->
binfo
.
pRes
;
}
static
SSDataBlock
*
doSTableIntervalAgg
(
SOperatorInfo
*
pOperator
,
bool
*
newgroup
)
{
...
...
@@ -5900,11 +5892,11 @@ static void destroyOperatorInfo(SOperatorInfo* pOperator) {
taosMemoryFreeClear
(
pOperator
);
}
int32_t
doInitAggInfoSup
(
SAggSupporter
*
pAggSup
,
SqlFunctionCtx
*
pCtx
,
int32_t
numOfOutput
,
const
char
*
pKey
)
{
int32_t
doInitAggInfoSup
(
SAggSupporter
*
pAggSup
,
SqlFunctionCtx
*
pCtx
,
int32_t
numOfOutput
,
size_t
keyBufSize
,
const
char
*
pKey
)
{
_hash_fn_t
hashFn
=
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_BINARY
);
pAggSup
->
resultRowSize
=
getResultRowSize
(
pCtx
,
numOfOutput
);
pAggSup
->
keyBuf
=
taosMemoryCalloc
(
1
,
sizeof
(
int64_t
)
+
sizeof
(
int64_t
)
+
POINTER_BYTES
);
pAggSup
->
keyBuf
=
taosMemoryCalloc
(
1
,
keyBufSize
);
pAggSup
->
pResultRowHashTable
=
taosHashInit
(
10
,
hashFn
,
true
,
HASH_NO_LOCK
);
pAggSup
->
pResultRowListSet
=
taosHashInit
(
100
,
hashFn
,
false
,
HASH_NO_LOCK
);
pAggSup
->
pResultRowArrayList
=
taosArrayInit
(
10
,
sizeof
(
SResultRowCell
));
...
...
@@ -5931,12 +5923,12 @@ static void cleanupAggSup(SAggSupporter* pAggSup) {
}
int32_t
initAggInfo
(
SOptrBasicInfo
*
pBasicInfo
,
SAggSupporter
*
pAggSup
,
SExprInfo
*
pExprInfo
,
int32_t
numOfCols
,
int32_t
numOfRows
,
SSDataBlock
*
pResultBlock
,
const
char
*
pkey
)
{
int32_t
numOfRows
,
SSDataBlock
*
pResultBlock
,
size_t
keyBufSize
,
const
char
*
pkey
)
{
pBasicInfo
->
pCtx
=
createSqlFunctionCtx_rv
(
pExprInfo
,
numOfCols
,
&
pBasicInfo
->
rowCellInfoOffset
);
pBasicInfo
->
pRes
=
pResultBlock
;
pBasicInfo
->
capacity
=
numOfRows
;
doInitAggInfoSup
(
pAggSup
,
pBasicInfo
->
pCtx
,
numOfCols
,
pkey
);
doInitAggInfoSup
(
pAggSup
,
pBasicInfo
->
pCtx
,
numOfCols
,
keyBufSize
,
pkey
);
return
TSDB_CODE_SUCCESS
;
}
...
...
@@ -5975,7 +5967,8 @@ SOperatorInfo* createAggregateOperatorInfo(SOperatorInfo* downstream, SExprInfo*
//(int32_t)(getRowNumForMultioutput(pQueryAttr, pQueryAttr->topBotQuery, pQueryAttr->stableQuery));
int32_t
numOfRows
=
1
;
int32_t
code
=
initAggInfo
(
&
pInfo
->
binfo
,
&
pInfo
->
aggSup
,
pExprInfo
,
numOfCols
,
numOfRows
,
pResultBlock
,
pTaskInfo
->
id
.
str
);
size_t
keyBufSize
=
sizeof
(
int64_t
)
+
sizeof
(
int64_t
)
+
POINTER_BYTES
;
int32_t
code
=
initAggInfo
(
&
pInfo
->
binfo
,
&
pInfo
->
aggSup
,
pExprInfo
,
numOfCols
,
numOfRows
,
pResultBlock
,
keyBufSize
,
pTaskInfo
->
id
.
str
);
pInfo
->
pTableQueryInfo
=
initTableQueryInfo
(
pTableGroupInfo
);
if
(
code
!=
TSDB_CODE_SUCCESS
||
pInfo
->
pTableQueryInfo
==
NULL
)
{
goto
_error
;
...
...
@@ -6091,8 +6084,9 @@ SOperatorInfo* createMultiTableAggOperatorInfo(SOperatorInfo* downstream, SExprI
SAggOperatorInfo
*
pInfo
=
taosMemoryCalloc
(
1
,
sizeof
(
SAggOperatorInfo
));
int32_t
numOfRows
=
1
;
size_t
keyBufSize
=
sizeof
(
int64_t
)
+
sizeof
(
int64_t
)
+
POINTER_BYTES
;
int32_t
code
=
initAggInfo
(
&
pInfo
->
binfo
,
&
pInfo
->
aggSup
,
pExprInfo
,
numOfCols
,
numOfRows
,
pResBlock
,
pTaskInfo
->
id
.
str
);
initAggInfo
(
&
pInfo
->
binfo
,
&
pInfo
->
aggSup
,
pExprInfo
,
numOfCols
,
numOfRows
,
pResBlock
,
keyBufSize
,
pTaskInfo
->
id
.
str
);
pInfo
->
pTableQueryInfo
=
initTableQueryInfo
(
pTableGroupInfo
);
if
(
code
!=
TSDB_CODE_SUCCESS
||
pInfo
->
pTableQueryInfo
==
NULL
)
{
goto
_error
;
...
...
@@ -6152,7 +6146,8 @@ SOperatorInfo* createProjectOperatorInfo(SOperatorInfo* downstream, SExprInfo* p
int32_t
numOfCols
=
num
;
int32_t
numOfRows
=
4096
;
initAggInfo
(
&
pInfo
->
binfo
,
&
pInfo
->
aggSup
,
pExprInfo
,
numOfCols
,
numOfRows
,
pResBlock
,
pTaskInfo
->
id
.
str
);
size_t
keyBufSize
=
sizeof
(
int64_t
)
+
sizeof
(
int64_t
)
+
POINTER_BYTES
;
initAggInfo
(
&
pInfo
->
binfo
,
&
pInfo
->
aggSup
,
pExprInfo
,
numOfCols
,
numOfRows
,
pResBlock
,
keyBufSize
,
pTaskInfo
->
id
.
str
);
setFunctionResultOutput
(
&
pInfo
->
binfo
,
&
pInfo
->
aggSup
,
MAIN_SCAN
,
pTaskInfo
);
pInfo
->
pPseudoColInfo
=
setRowTsColumnOutputInfo
(
pInfo
->
binfo
.
pCtx
,
numOfCols
);
...
...
@@ -6200,7 +6195,8 @@ SOperatorInfo* createIntervalOperatorInfo(SOperatorInfo* downstream, SExprInfo*
pInfo
->
primaryTsIndex
=
primaryTsSlot
;
int32_t
numOfRows
=
4096
;
int32_t
code
=
initAggInfo
(
&
pInfo
->
binfo
,
&
pInfo
->
aggSup
,
pExprInfo
,
numOfCols
,
numOfRows
,
pResBlock
,
pTaskInfo
->
id
.
str
);
size_t
keyBufSize
=
sizeof
(
int64_t
)
+
sizeof
(
int64_t
)
+
POINTER_BYTES
;
int32_t
code
=
initAggInfo
(
&
pInfo
->
binfo
,
&
pInfo
->
aggSup
,
pExprInfo
,
numOfCols
,
numOfRows
,
pResBlock
,
keyBufSize
,
pTaskInfo
->
id
.
str
);
initExecTimeWindowInfo
(
&
pInfo
->
timeWindowData
,
&
pInfo
->
win
);
// pInfo->pTableQueryInfo = initTableQueryInfo(pTableGroupInfo);
...
...
@@ -6238,28 +6234,34 @@ _error:
return
NULL
;
}
SOperatorInfo
*
createAllTimeIntervalOperatorInfo
(
STaskRuntimeEnv
*
pRuntimeEnv
,
SOperatorInfo
*
downstream
,
SExprInfo
*
pExpr
,
int32_t
numOfOutput
)
{
STableIntervalOperatorInfo
*
pInfo
=
taosMemoryCalloc
(
1
,
sizeof
(
STableIntervalOperatorInfo
));
SOperatorInfo
*
createTimeSliceOperatorInfo
(
SOperatorInfo
*
downstream
,
SExprInfo
*
pExprInfo
,
int32_t
numOfCols
,
SSDataBlock
*
pResultBlock
,
SExecTaskInfo
*
pTaskInfo
)
{
STimeSliceOperatorInfo
*
pInfo
=
taosMemoryCalloc
(
1
,
sizeof
(
STimeSliceOperatorInfo
));
SOperatorInfo
*
pOperator
=
taosMemoryCalloc
(
1
,
sizeof
(
SOperatorInfo
));
if
(
pOperator
==
NULL
||
pInfo
==
NULL
)
{
goto
_error
;
}
// pInfo->binfo.pCtx = createSqlFunctionCtx(pRuntimeEnv, pExpr, numOfOutput, &pInfo->binfo.rowCellInfoOffset);
// pInfo->binfo.pRes = createOutputBuf(pExpr, numOfOutput, pResultInfo->capacity);
initResultRowInfo
(
&
pInfo
->
binfo
.
resultRowInfo
,
8
);
SOperatorInfo
*
pOperator
=
taosMemoryCalloc
(
1
,
sizeof
(
SOperatorInfo
));
pOperator
->
name
=
"AllTimeIntervalAggOperator"
;
pOperator
->
name
=
"TimeSliceOperator"
;
// pOperator->operatorType = OP_AllTimeWindow;
pOperator
->
blockingOptr
=
true
;
pOperator
->
status
=
OP_NOT_OPENED
;
pOperator
->
pExpr
=
pExpr
;
pOperator
->
numOfOutput
=
numOfOutput
;
pOperator
->
info
=
pInfo
;
pOperator
->
getNextFn
=
doAllIntervalAgg
;
pOperator
->
closeFn
=
destroyBasicOperatorInfo
;
pOperator
->
status
=
OP_NOT_OPENED
;
pOperator
->
pExpr
=
pExprInfo
;
pOperator
->
numOfOutput
=
numOfCols
;
pOperator
->
info
=
pInfo
;
pOperator
->
pTaskInfo
=
pTaskInfo
;
pOperator
->
getNextFn
=
doAllIntervalAgg
;
pOperator
->
closeFn
=
destroyBasicOperatorInfo
;
int32_t
code
=
appendDownstream
(
pOperator
,
&
downstream
,
1
);
return
pOperator
;
_error:
taosMemoryFree
(
pInfo
);
taosMemoryFree
(
pOperator
);
pTaskInfo
->
code
=
TSDB_CODE_OUT_OF_MEMORY
;
return
NULL
;
}
SOperatorInfo
*
createStatewindowOperatorInfo
(
SOperatorInfo
*
downstream
,
SExprInfo
*
pExpr
,
int32_t
numOfCols
,
SSDataBlock
*
pResBlock
,
SExecTaskInfo
*
pTaskInfo
)
{
...
...
@@ -6270,8 +6272,8 @@ SOperatorInfo* createStatewindowOperatorInfo(SOperatorInfo* downstream, SExprInf
}
pInfo
->
colIndex
=
-
1
;
initAggInfo
(
&
pInfo
->
binfo
,
&
pInfo
->
aggSup
,
pExpr
,
numOfCols
,
4096
,
pResBlock
,
pTaskInfo
->
id
.
str
);
size_t
keyBufSize
=
sizeof
(
int64_t
)
+
sizeof
(
int64_t
)
+
POINTER_BYTES
;
initAggInfo
(
&
pInfo
->
binfo
,
&
pInfo
->
aggSup
,
pExpr
,
numOfCols
,
4096
,
pResBlock
,
keyBufSize
,
pTaskInfo
->
id
.
str
);
initResultRowInfo
(
&
pInfo
->
binfo
.
resultRowInfo
,
8
);
pOperator
->
name
=
"StateWindowOperator"
;
...
...
@@ -6303,7 +6305,8 @@ SOperatorInfo* createSessionAggOperatorInfo(SOperatorInfo* downstream, SExprInfo
}
int32_t
numOfRows
=
4096
;
int32_t
code
=
initAggInfo
(
&
pInfo
->
binfo
,
&
pInfo
->
aggSup
,
pExprInfo
,
numOfCols
,
numOfRows
,
pResBlock
,
pTaskInfo
->
id
.
str
);
size_t
keyBufSize
=
sizeof
(
int64_t
)
+
sizeof
(
int64_t
)
+
POINTER_BYTES
;
int32_t
code
=
initAggInfo
(
&
pInfo
->
binfo
,
&
pInfo
->
aggSup
,
pExprInfo
,
numOfCols
,
numOfRows
,
pResBlock
,
keyBufSize
,
pTaskInfo
->
id
.
str
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
goto
_error
;
}
...
...
source/libs/executor/src/groupoperator.c
浏览文件 @
39fb5651
...
...
@@ -46,7 +46,7 @@ static int32_t initGroupOptrInfo(SArray** pGroupColVals, int32_t* keyLen, char**
int32_t
numOfGroupCols
=
taosArrayGetSize
(
pGroupColList
);
for
(
int32_t
i
=
0
;
i
<
numOfGroupCols
;
++
i
)
{
SColumn
*
pCol
=
taosArrayGet
(
pGroupColList
,
i
);
(
*
keyLen
)
+=
pCol
->
bytes
;
(
*
keyLen
)
+=
pCol
->
bytes
;
// actual data + null_flag
SGroupKeys
key
=
{
0
};
key
.
bytes
=
pCol
->
bytes
;
...
...
@@ -61,8 +61,9 @@ static int32_t initGroupOptrInfo(SArray** pGroupColVals, int32_t* keyLen, char**
}
int32_t
nullFlagSize
=
sizeof
(
int8_t
)
*
numOfGroupCols
;
(
*
keyLen
)
+=
nullFlagSize
;
(
*
keyBuf
)
=
taosMemoryCalloc
(
1
,
(
*
keyLen
)
+
nullFlagSize
);
(
*
keyBuf
)
=
taosMemoryCalloc
(
1
,
(
*
keyLen
));
if
((
*
keyBuf
)
==
NULL
)
{
return
TSDB_CODE_OUT_OF_MEMORY
;
}
...
...
@@ -169,11 +170,16 @@ static void doAssignGroupKeys(SqlFunctionCtx* pCtx, int32_t numOfOutput, int32_t
SResultRowEntryInfo
*
pEntryInfo
=
GET_RES_INFO
(
&
pCtx
[
i
]);
SColumnInfoData
*
pColInfoData
=
pCtx
[
i
].
input
.
pData
[
0
];
// todo OPT all/all not NULL
if
(
!
colDataIsNull
(
pColInfoData
,
totalRows
,
rowIndex
,
NULL
))
{
char
*
dest
=
GET_ROWCELL_INTERBUF
(
pEntryInfo
);
char
*
data
=
colDataGetData
(
pColInfoData
,
rowIndex
);
memcpy
(
dest
,
data
,
pColInfoData
->
info
.
bytes
);
if
(
IS_VAR_DATA_TYPE
(
pColInfoData
->
info
.
type
))
{
varDataCopy
(
dest
,
data
);
}
else
{
memcpy
(
dest
,
data
,
pColInfoData
->
info
.
bytes
);
}
}
else
{
// it is a NULL value
pEntryInfo
->
isNullRes
=
1
;
}
...
...
@@ -326,14 +332,15 @@ SOperatorInfo* createGroupOperatorInfo(SOperatorInfo* downstream, SExprInfo* pEx
pInfo
->
pGroupCols
=
pGroupColList
;
pInfo
->
pCondition
=
pCondition
;
initAggInfo
(
&
pInfo
->
binfo
,
&
pInfo
->
aggSup
,
pExprInfo
,
numOfCols
,
4096
,
pResultBlock
,
pTaskInfo
->
id
.
str
);
initResultRowInfo
(
&
pInfo
->
binfo
.
resultRowInfo
,
8
);
int32_t
code
=
initGroupOptrInfo
(
&
pInfo
->
pGroupColVals
,
&
pInfo
->
groupKeyLen
,
&
pInfo
->
keyBuf
,
pGroupColList
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
goto
_error
;
}
initAggInfo
(
&
pInfo
->
binfo
,
&
pInfo
->
aggSup
,
pExprInfo
,
numOfCols
,
4096
,
pResultBlock
,
pInfo
->
groupKeyLen
,
pTaskInfo
->
id
.
str
);
initResultRowInfo
(
&
pInfo
->
binfo
.
resultRowInfo
,
8
);
pOperator
->
name
=
"GroupbyAggOperator"
;
pOperator
->
blockingOptr
=
true
;
pOperator
->
status
=
OP_NOT_OPENED
;
...
...
source/libs/function/src/builtins.c
浏览文件 @
39fb5651
...
...
@@ -489,7 +489,7 @@ int32_t stubCheckAndGetResultType(SFunctionNode* pFunc) {
int32_t
paraType
=
pParam
->
node
.
resType
.
type
;
int32_t
resType
=
0
;
if
(
IS_SIGNED_NUMERIC_TYPE
(
paraType
))
{
if
(
IS_SIGNED_NUMERIC_TYPE
(
paraType
)
||
paraType
==
TSDB_DATA_TYPE_BOOL
)
{
resType
=
TSDB_DATA_TYPE_BIGINT
;
}
else
if
(
IS_UNSIGNED_NUMERIC_TYPE
(
paraType
))
{
resType
=
TSDB_DATA_TYPE_UBIGINT
;
...
...
source/libs/function/src/builtinsimpl.c
浏览文件 @
39fb5651
...
...
@@ -138,8 +138,8 @@ int32_t sumFunction(SqlFunctionCtx *pCtx) {
int32_t
start
=
pInput
->
startRowIndex
;
int32_t
numOfRows
=
pInput
->
numOfRows
;
if
(
IS_SIGNED_NUMERIC_TYPE
(
type
))
{
if
(
type
==
TSDB_DATA_TYPE_TINYINT
)
{
if
(
IS_SIGNED_NUMERIC_TYPE
(
type
)
||
type
==
TSDB_DATA_TYPE_BOOL
)
{
if
(
type
==
TSDB_DATA_TYPE_TINYINT
||
type
==
TSDB_DATA_TYPE_BOOL
)
{
LIST_ADD_N
(
pSumRes
->
isum
,
pCol
,
start
,
numOfRows
,
int8_t
,
numOfElem
);
}
else
if
(
type
==
TSDB_DATA_TYPE_SMALLINT
)
{
LIST_ADD_N
(
pSumRes
->
isum
,
pCol
,
start
,
numOfRows
,
int16_t
,
numOfElem
);
...
...
tests/script/jenkins/basic.txt
浏览文件 @
39fb5651
...
...
@@ -32,6 +32,8 @@
./test.sh -f tsim/query/interval-offset.sim
./test.sh -f tsim/query/scalarFunction.sim
./test.sh -f tsim/query/charScalarFunction.sim
./test.sh -f tsim/query/explain.sim
./test.sh -f tsim/query/session.sim
# ---- qnode
./test.sh -f tsim/qnode/basic1.sim
...
...
@@ -43,7 +45,7 @@
./test.sh -f tsim/bnode/basic1.sim
# ---- mnode
./test.sh -f tsim/
b
node/basic1.sim
./test.sh -f tsim/
m
node/basic1.sim
# ---- show
./test.sh -f tsim/show/basic.sim
...
...
@@ -69,7 +71,13 @@
# --- for multi process mode
./test.sh -f tsim/user/basic1.sim -m
./test.sh -f tsim/stable/vnode3.sim -m
./test.sh -f tsim/db/basic3.sim -m
./test.sh -f tsim/insert/backquote.sim
./test.sh -f tsim/parser/fourArithmetic-basic.sim -m
./test.sh -f tsim/query/interval-offset.sim -m
./test.sh -f tsim/tmq/basic.sim -m
./test.sh -f tsim/stable/vnode3.sim -m
./test.sh -f tsim/qnode/basic1.sim -m
./test.sh -f tsim/mnode/basic1.sim -m
#======================b1-end===============
tests/script/tsim/mnode/basic1.sim
浏览文件 @
39fb5651
...
...
@@ -75,7 +75,6 @@ if $data02 != master then
return -1
endi
return
print =============== create drop mnode 1
sql_error create mnode on dnode 1
sql_error drop mnode on dnode 1
...
...
tests/script/tsim/query/complex_group.sim
0 → 100644
浏览文件 @
39fb5651
system sh/stop_dnodes.sh
system sh/deploy.sh -n dnode1 -i 1
system sh/exec.sh -n dnode1 -s start
$loop_cnt = 0
check_dnode_ready:
$loop_cnt = $loop_cnt + 1
sleep 200
if $loop_cnt == 10 then
print ====> dnode not ready!
return -1
endi
sql show dnodes
print ===> $rows $data00 $data01 $data02 $data03 $data04 $data05
if $data00 != 1 then
return -1
endi
if $data04 != ready then
goto check_dnode_ready
endi
sql connect
print =============== create database
sql create database db
sql show databases
if $rows != 2 then
return -1
endi
sql use db
print =============== create super table and child table
sql create table stb1 (ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint, c5 float, c6 double, c7 bool, c8 binary(16),c9 nchar(32), c10 timestamp) tags (t1 int)
sql show stables
print $rows $data00 $data01 $data02
if $rows != 1 then
return -1
endi
sql create table ct1 using stb1 tags ( 1 )
sql create table ct2 using stb1 tags ( 2 )
sql create table ct3 using stb1 tags ( 3 )
sql create table ct4 using stb1 tags ( 4 )
sql show tables
print $rows $data00 $data10 $data20
if $rows != 4 then
return -1
endi
print =============== insert data into child table ct1 (s)
sql insert into ct1 values ( '2022-01-01 01:01:01.000', 1, 11111, 111, 11, 1.11, 11.11, 1, "binary1", "nchar1", now+1a )
sql insert into ct1 values ( '2022-01-01 01:01:06.000', 2, 22222, 222, 22, 2.22, 22.22, 0, "binary2", "nchar2", now+2a )
sql insert into ct1 values ( '2022-01-01 01:01:10.000', 3, 33333, 333, 33, 3.33, 33.33, 0, "binary3", "nchar3", now+3a )
sql insert into ct1 values ( '2022-01-01 01:01:16.000', 4, 44444, 444, 44, 4.44, 44.44, 1, "binary4", "nchar4", now+4a )
sql insert into ct1 values ( '2022-01-01 01:01:20.000', 5, 55555, 555, 55, 5.55, 55.55, 0, "binary5", "nchar5", now+5a )
sql insert into ct1 values ( '2022-01-01 01:01:26.000', 6, 66666, 666, 66, 6.66, 66.66, 1, "binary6", "nchar6", now+6a )
sql insert into ct1 values ( '2022-01-01 01:01:30.000', 7, 00000, 000, 00, 0.00, 00.00, 1, "binary7", "nchar7", now+7a )
sql insert into ct1 values ( '2022-01-01 01:01:36.000', 8, -88888, -888, -88, -8.88, -88.88, 0, "binary8", "nchar8", now+8a )
print =============== insert data into child table ct2 (d)
sql insert into ct2 values ( '2022-01-01 01:00:01.000', 1, 11111, 111, 11, 1.11, 11.11, 1, "binary1", "nchar1", now+1a )
sql insert into ct2 values ( '2022-01-01 10:00:01.000', 2, 22222, 222, 22, 2.22, 22.22, 0, "binary2", "nchar2", now+2a )
sql insert into ct2 values ( '2022-01-01 20:00:01.000', 3, 33333, 333, 33, 3.33, 33.33, 0, "binary3", "nchar3", now+3a )
sql insert into ct2 values ( '2022-01-02 10:00:01.000', 4, 44444, 444, 44, 4.44, 44.44, 1, "binary4", "nchar4", now+4a )
sql insert into ct2 values ( '2022-01-02 20:00:01.000', 5, 55555, 555, 55, 5.55, 55.55, 0, "binary5", "nchar5", now+5a )
sql insert into ct2 values ( '2022-01-03 10:00:01.000', 7, 00000, 000, 00, 0.00, 00.00, 1, "binary7", "nchar7", now+6a )
sql insert into ct2 values ( '2022-01-03 20:00:01.000', 8, -88888, -888, -88, -8.88, -88.88, 0, "binary8", "nchar8", now+7a )
print =============== insert data into child table ct3 (n)
sql insert into ct3 values ( '2021-12-21 01:01:01.000', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
sql insert into ct3 values ( '2021-12-31 01:01:01.000', 1, 11111, 111, 11, 1.11, 11.11, 1, "binary1", "nchar1", now+1a )
sql insert into ct3 values ( '2022-01-01 01:01:06.000', 2, 22222, 222, 22, 2.22, 22.22, 0, "binary2", "nchar2", now+2a )
sql insert into ct3 values ( '2022-01-07 01:01:10.000', 3, 33333, 333, 33, 3.33, 33.33, 0, "binary3", "nchar3", now+3a )
sql insert into ct3 values ( '2022-01-31 01:01:16.000', 4, 44444, 444, 44, 4.44, 44.44, 1, "binary4", "nchar4", now+4a )
sql insert into ct3 values ( '2022-02-01 01:01:20.000', 5, 55555, 555, 55, 5.55, 55.55, 0, "binary5", "nchar5", now+5a )
sql insert into ct3 values ( '2022-02-28 01:01:26.000', 6, 66666, 666, 66, 6.66, 66.66, 1, "binary6", "nchar6", now+6a )
sql insert into ct3 values ( '2022-03-01 01:01:30.000', 7, 00000, 000, 00, 0.00, 00.00, 1, "binary7", "nchar7", "1970-01-01 08:00:00.000" )
sql insert into ct3 values ( '2022-03-08 01:01:36.000', 8, -88888, -888, -88, -8.88, -88.88, 0, "binary8", "nchar8", "1969-01-01 01:00:00.000" )
print =============== insert data into child table ct4 (y)
sql insert into ct4 values ( '2020-10-21 01:01:01.000', 1, 11111, 111, 11, 1.11, 11.11, 1, "binary1", "nchar1", now+1a )
sql insert into ct4 values ( '2020-12-31 01:01:01.000', 2, 22222, 222, 22, 2.22, 22.22, 0, "binary2", "nchar2", now+2a )
sql insert into ct4 values ( '2021-01-01 01:01:06.000', 3, 33333, 333, 33, 3.33, 33.33, 0, "binary3", "nchar3", now+3a )
sql insert into ct4 values ( '2021-05-07 01:01:10.000', 4, 44444, 444, 44, 4.44, 44.44, 1, "binary4", "nchar4", now+4a )
sql insert into ct4 values ( '2021-09-30 01:01:16.000', 5, 55555, 555, 55, 5.55, 55.55, 0, "binary5", "nchar5", now+5a )
sql insert into ct4 values ( '2022-02-01 01:01:20.000', 6, 66666, 666, 66, 6.66, 66.66, 1, "binary6", "nchar6", now+6a )
sql insert into ct4 values ( '2022-10-28 01:01:26.000', 7, 00000, 000, 00, 0.00, 00.00, 1, "binary7", "nchar7", "1970-01-01 08:00:00.000" )
sql insert into ct4 values ( '2022-12-01 01:01:30.000', 8, -88888, -888, -88, -8.88, -88.88, 0, "binary8", "nchar8", "1969-01-01 01:00:00.000" )
sql insert into ct4 values ( '2022-12-31 01:01:36.000', 9, -99999999999999999, -999, -99, -9.99, -999999999999999999999.99, 1, "binary9", "nchar9", "1900-01-01 00:00:00.000" )
print ================ start query ======================
print ================ query 1 group by filter
sql select count(*) from ct3 group by c1
print ====> sql : select count(*) from ct3 group by c1
print ====> rows: $rows
if $rows != 8 then
return -1
endi
sql select count(*) from ct3 group by c2
print ====> sql : select count(*) from ct3 group by c2
print ====> rows: $rows
if $rows != 8 then
return -1
endi
sql select count(*) from ct3 group by c3
print ====> sql : select count(*) from ct3 group by c3
print ====> rows: $rows
if $rows != 8 then
return -1
endi
sql select count(*) from ct3 group by c4
print ====> sql : select count(*) from ct3 group by c4
print ====> rows: $rows
if $rows != 8 then
return -1
endi
sql select count(*) from ct3 group by c5
print ====> sql : select count(*) from ct3 group by c5
print ====> rows: $rows
if $rows != 8 then
return -1
endi
sql select count(*) from ct3 group by c6
print ====> sql : select count(*) from ct3 group by c6
print ====> rows: $rows
if $rows != 8 then
return -1
endi
sql select count(*) from ct3 group by c7
print ====> sql : select count(*) from ct3 group by c7
print ====> rows: $rows
if $rows != 2 then
return -1
endi
sql select count(*) from ct3 group by c8
print ====> sql : select count(*) from ct3 group by c8
print ====> rows: $rows
if $rows != 8 then
return -1
endi
sql select count(*) from ct3 group by c9
print ====> sql : select count(*) from ct3 group by c9
print ====> rows: $rows
if $rows != 8 then
return -1
endi
sql select count(*) from ct3 group by c10
print ====> sql : select count(*) from ct3 group by c10
print ====> rows: $rows
if $rows != 8 then
return -1
endi
print ================ query 2 complex with group by
sql select count(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1
print ====> sql : select count(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2
print ====> rows: $rows
if $rows != 1 then
return -1
endi
sql select abs(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1
print ====> sql : select abs(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2
print ====> rows: $rows
if $rows != 1 then
return -1
endi
sql select acos(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1
print ====> sql : select acos(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2
print ====> rows: $rows
if $rows != 1 then
return -1
endi
sql select asin(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1
print ====> sql : select asin(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2
print ====> rows: $rows
if $rows != 1 then
return -1
endi
sql select atan(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1
print ====> sql : select atan(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2
print ====> rows: $rows
if $rows != 1 then
return -1
endi
sql select ceil(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1
print ====> sql : select ceil(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2
print ====> rows: $rows
if $rows != 1 then
return -1
endi
sql select cos(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1
print ====> sql : select cos(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2
print ====> rows: $rows
if $rows != 1 then
return -1
endi
sql select floor(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1
print ====> sql : select floor(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2
print ====> rows: $rows
if $rows != 1 then
return -1
endi
sql select log(c1,10) from ct3 where c1 > 2 group by c7 limit 1 offset 1
print ====> sql : select log(c1,10) from ct3 where c1 > 2 group by c7 limit 1 offset 2
print ====> rows: $rows
if $rows != 1 then
return -1
endi
sql select pow(c1,3) from ct3 where c1 > 2 group by c7 limit 1 offset 1
print ====> sql : select pow(c1,3) from ct3 where c1 > 2 group by c7 limit 1 offset 2
print ====> rows: $rows
if $rows != 1 then
return -1
endi
sql select round(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1
print ====> sql : select round(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2
print ====> rows: $rows
if $rows != 1 then
return -1
endi
sql select sqrt(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1
print ====> sql : select sqrt(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2
print ====> rows: $rows
if $rows != 1 then
return -1
endi
sql select sin(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1
print ====> sql : select sin(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2
print ====> rows: $rows
if $rows != 1 then
return -1
endi
sql select tan(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1
print ====> sql : select tan(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2
print ====> rows: $rows
if $rows != 1 then
return -1
endi
print =================== count all rows
sql select count(c1) from stb1
print ====> sql : select count(c1) from stb1
print ====> rows: $data00
if $data00 != 33 then
return -1
endi
#=================================================
print =============== stop and restart taosd
system sh/exec.sh -n dnode1 -s stop -x SIGINT
system sh/exec.sh -n dnode1 -s start
$loop_cnt = 0
check_dnode_ready_0:
$loop_cnt = $loop_cnt + 1
sleep 200
if $loop_cnt == 10 then
print ====> dnode not ready!
return -1
endi
sql show dnodes
print ===> $rows $data00 $data01 $data02 $data03 $data04 $data05
if $data00 != 1 then
return -1
endi
if $data04 != ready then
goto check_dnode_ready_0
endi
print =================== count all rows
sql select count(c1) from stb1
print ====> sql : select count(c1) from stb1
print ====> rows: $data00
if $data00 != 33 then
return -1
endi
print ================ query 1 group by filter
sql select count(*) from ct3 group by c1
print ====> sql : select count(*) from ct3 group by c1
print ====> rows: $rows
if $rows != 8 then
return -1
endi
sql select count(*) from ct3 group by c2
print ====> sql : select count(*) from ct3 group by c2
print ====> rows: $rows
if $rows != 8 then
return -1
endi
sql select count(*) from ct3 group by c3
print ====> sql : select count(*) from ct3 group by c3
print ====> rows: $rows
if $rows != 8 then
return -1
endi
sql select count(*) from ct3 group by c4
print ====> sql : select count(*) from ct3 group by c4
print ====> rows: $rows
if $rows != 8 then
return -1
endi
sql select count(*) from ct3 group by c5
print ====> sql : select count(*) from ct3 group by c5
print ====> rows: $rows
if $rows != 8 then
return -1
endi
sql select count(*) from ct3 group by c6
print ====> sql : select count(*) from ct3 group by c6
print ====> rows: $rows
if $rows != 8 then
return -1
endi
sql select count(*) from ct3 group by c7
print ====> sql : select count(*) from ct3 group by c7
print ====> rows: $rows
if $rows != 2 then
return -1
endi
sql select count(*) from ct3 group by c8
print ====> sql : select count(*) from ct3 group by c8
print ====> rows: $rows
if $rows != 8 then
return -1
endi
sql select count(*) from ct3 group by c9
print ====> sql : select count(*) from ct3 group by c9
print ====> rows: $rows
if $rows != 8 then
return -1
endi
sql select count(*) from ct3 group by c10
print ====> sql : select count(*) from ct3 group by c10
print ====> rows: $rows
if $rows != 8 then
return -1
endi
print ================ query 2 complex with group by
sql select count(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1
print ====> sql : select count(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2
print ====> rows: $rows
if $rows != 1 then
return -1
endi
sql select abs(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1
print ====> sql : select abs(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2
print ====> rows: $rows
if $rows != 1 then
return -1
endi
sql select acos(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1
print ====> sql : select acos(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2
print ====> rows: $rows
if $rows != 1 then
return -1
endi
sql select asin(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1
print ====> sql : select asin(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2
print ====> rows: $rows
if $rows != 1 then
return -1
endi
sql select atan(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1
print ====> sql : select atan(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2
print ====> rows: $rows
if $rows != 1 then
return -1
endi
sql select ceil(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1
print ====> sql : select ceil(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2
print ====> rows: $rows
if $rows != 1 then
return -1
endi
sql select cos(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1
print ====> sql : select cos(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2
print ====> rows: $rows
if $rows != 1 then
return -1
endi
sql select floor(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1
print ====> sql : select floor(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2
print ====> rows: $rows
if $rows != 1 then
return -1
endi
sql select log(c1,10) from ct3 where c1 > 2 group by c7 limit 1 offset 1
print ====> sql : select log(c1,10) from ct3 where c1 > 2 group by c7 limit 1 offset 2
print ====> rows: $rows
if $rows != 1 then
return -1
endi
sql select pow(c1,3) from ct3 where c1 > 2 group by c7 limit 1 offset 1
print ====> sql : select pow(c1,3) from ct3 where c1 > 2 group by c7 limit 1 offset 2
print ====> rows: $rows
if $rows != 1 then
return -1
endi
sql select round(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1
print ====> sql : select round(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2
print ====> rows: $rows
if $rows != 1 then
return -1
endi
sql select sqrt(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1
print ====> sql : select sqrt(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2
print ====> rows: $rows
if $rows != 1 then
return -1
endi
sql select sin(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1
print ====> sql : select sin(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2
print ====> rows: $rows
if $rows != 1 then
return -1
endi
sql select tan(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1
print ====> sql : select tan(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2
print ====> rows: $rows
if $rows != 1 then
return -1
endi
#system sh/exec.sh -n dnode1 -s stop -x SIGINT
\ No newline at end of file
tests/script/tsim/query/complex_limit.sim
0 → 100644
浏览文件 @
39fb5651
system sh/stop_dnodes.sh
system sh/deploy.sh -n dnode1 -i 1
system sh/exec.sh -n dnode1 -s start
$loop_cnt = 0
check_dnode_ready:
$loop_cnt = $loop_cnt + 1
sleep 200
if $loop_cnt == 10 then
print ====> dnode not ready!
return -1
endi
sql show dnodes
print ===> $rows $data00 $data01 $data02 $data03 $data04 $data05
if $data00 != 1 then
return -1
endi
if $data04 != ready then
goto check_dnode_ready
endi
sql connect
print =============== create database
sql create database db
sql show databases
if $rows != 2 then
return -1
endi
sql use db
print =============== create super table and child table
sql create table stb1 (ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint, c5 float, c6 double, c7 bool, c8 binary(16),c9 nchar(32), c10 timestamp) tags (t1 int)
sql show stables
print $rows $data00 $data01 $data02
if $rows != 1 then
return -1
endi
sql create table ct1 using stb1 tags ( 1 )
sql create table ct2 using stb1 tags ( 2 )
sql create table ct3 using stb1 tags ( 3 )
sql create table ct4 using stb1 tags ( 4 )
sql show tables
print $rows $data00 $data10 $data20
if $rows != 4 then
return -1
endi
print =============== insert data into child table ct1 (s)
sql insert into ct1 values ( '2022-01-01 01:01:01.000', 1, 11111, 111, 11, 1.11, 11.11, 1, "binary1", "nchar1", now+1a )
sql insert into ct1 values ( '2022-01-01 01:01:06.000', 2, 22222, 222, 22, 2.22, 22.22, 0, "binary2", "nchar2", now+2a )
sql insert into ct1 values ( '2022-01-01 01:01:10.000', 3, 33333, 333, 33, 3.33, 33.33, 0, "binary3", "nchar3", now+3a )
sql insert into ct1 values ( '2022-01-01 01:01:16.000', 4, 44444, 444, 44, 4.44, 44.44, 1, "binary4", "nchar4", now+4a )
sql insert into ct1 values ( '2022-01-01 01:01:20.000', 5, 55555, 555, 55, 5.55, 55.55, 0, "binary5", "nchar5", now+5a )
sql insert into ct1 values ( '2022-01-01 01:01:26.000', 6, 66666, 666, 66, 6.66, 66.66, 1, "binary6", "nchar6", now+6a )
sql insert into ct1 values ( '2022-01-01 01:01:30.000', 7, 00000, 000, 00, 0.00, 00.00, 1, "binary7", "nchar7", now+7a )
sql insert into ct1 values ( '2022-01-01 01:01:36.000', 8, -88888, -888, -88, -8.88, -88.88, 0, "binary8", "nchar8", now+8a )
print =============== insert data into child table ct2 (d)
sql insert into ct2 values ( '2022-01-01 01:00:01.000', 1, 11111, 111, 11, 1.11, 11.11, 1, "binary1", "nchar1", now+1a )
sql insert into ct2 values ( '2022-01-01 10:00:01.000', 2, 22222, 222, 22, 2.22, 22.22, 0, "binary2", "nchar2", now+2a )
sql insert into ct2 values ( '2022-01-01 20:00:01.000', 3, 33333, 333, 33, 3.33, 33.33, 0, "binary3", "nchar3", now+3a )
sql insert into ct2 values ( '2022-01-02 10:00:01.000', 4, 44444, 444, 44, 4.44, 44.44, 1, "binary4", "nchar4", now+4a )
sql insert into ct2 values ( '2022-01-02 20:00:01.000', 5, 55555, 555, 55, 5.55, 55.55, 0, "binary5", "nchar5", now+5a )
sql insert into ct2 values ( '2022-01-03 10:00:01.000', 7, 00000, 000, 00, 0.00, 00.00, 1, "binary7", "nchar7", now+6a )
sql insert into ct2 values ( '2022-01-03 20:00:01.000', 8, -88888, -888, -88, -8.88, -88.88, 0, "binary8", "nchar8", now+7a )
print =============== insert data into child table ct3 (n)
sql insert into ct3 values ( '2021-12-21 01:01:01.000', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
sql insert into ct3 values ( '2021-12-31 01:01:01.000', 1, 11111, 111, 11, 1.11, 11.11, 1, "binary1", "nchar1", now+1a )
sql insert into ct3 values ( '2022-01-01 01:01:06.000', 2, 22222, 222, 22, 2.22, 22.22, 0, "binary2", "nchar2", now+2a )
sql insert into ct3 values ( '2022-01-07 01:01:10.000', 3, 33333, 333, 33, 3.33, 33.33, 0, "binary3", "nchar3", now+3a )
sql insert into ct3 values ( '2022-01-31 01:01:16.000', 4, 44444, 444, 44, 4.44, 44.44, 1, "binary4", "nchar4", now+4a )
sql insert into ct3 values ( '2022-02-01 01:01:20.000', 5, 55555, 555, 55, 5.55, 55.55, 0, "binary5", "nchar5", now+5a )
sql insert into ct3 values ( '2022-02-28 01:01:26.000', 6, 66666, 666, 66, 6.66, 66.66, 1, "binary6", "nchar6", now+6a )
sql insert into ct3 values ( '2022-03-01 01:01:30.000', 7, 00000, 000, 00, 0.00, 00.00, 1, "binary7", "nchar7", "1970-01-01 08:00:00.000" )
sql insert into ct3 values ( '2022-03-08 01:01:36.000', 8, -88888, -888, -88, -8.88, -88.88, 0, "binary8", "nchar8", "1969-01-01 01:00:00.000" )
print =============== insert data into child table ct4 (y)
sql insert into ct4 values ( '2020-10-21 01:01:01.000', 1, 11111, 111, 11, 1.11, 11.11, 1, "binary1", "nchar1", now+1a )
sql insert into ct4 values ( '2020-12-31 01:01:01.000', 2, 22222, 222, 22, 2.22, 22.22, 0, "binary2", "nchar2", now+2a )
sql insert into ct4 values ( '2021-01-01 01:01:06.000', 3, 33333, 333, 33, 3.33, 33.33, 0, "binary3", "nchar3", now+3a )
sql insert into ct4 values ( '2021-05-07 01:01:10.000', 4, 44444, 444, 44, 4.44, 44.44, 1, "binary4", "nchar4", now+4a )
sql insert into ct4 values ( '2021-09-30 01:01:16.000', 5, 55555, 555, 55, 5.55, 55.55, 0, "binary5", "nchar5", now+5a )
sql insert into ct4 values ( '2022-02-01 01:01:20.000', 6, 66666, 666, 66, 6.66, 66.66, 1, "binary6", "nchar6", now+6a )
sql insert into ct4 values ( '2022-10-28 01:01:26.000', 7, 00000, 000, 00, 0.00, 00.00, 1, "binary7", "nchar7", "1970-01-01 08:00:00.000" )
sql insert into ct4 values ( '2022-12-01 01:01:30.000', 8, -88888, -888, -88, -8.88, -88.88, 0, "binary8", "nchar8", "1969-01-01 01:00:00.000" )
sql insert into ct4 values ( '2022-12-31 01:01:36.000', 9, -99999999999999999, -999, -99, -9.99, -999999999999999999999.99, 1, "binary9", "nchar9", "1900-01-01 00:00:00.000" )
print ================ start query ======================
print ================ query 1 limit/offset
sql select * from ct1 limit 1
print ====> sql : select * from ct1 limit 1
print ====> rows: $rows
print ====> rows0: $data00, $data01, $data02, $data03, $data04, $data05, $data06, $data07, $data08, $data09
if $rows != 1 then
return -1
endi
sql select * from ct1 limit 9
print ====> sql : select * from ct1 limit 9
print ====> rows: $rows
if $rows != 8 then
return -1
endi
sql select * from ct1 limit 1 offset 2
print ====> sql : select * from ct1 limit 1 offset 2
print ====> rows: $rows
print ====> rows0: $data00, $data01, $data02, $data03, $data04, $data05, $data06, $data07, $data08, $data09
if $rows != 1 then
return -1
endi
if $data01 != 2 then
return -1
endi
sql select * from ct1 limit 2 offset 1
print ====> sql : select * from ct1 limit 2 offset 7
print ====> rows: $rows
if $rows != 2 then
return -1
endi
if $data01 != 8 then
return -1
endi
sql select * from ct1 limit 2 offset 7
print ====> sql : select * from ct1 limit 2 offset 7
print ====> rows: $rows
print ====> rows0: $data00, $data01, $data02, $data03, $data04, $data05, $data06, $data07, $data08, $data09
if $rows != 1 then
return -1
endi
if $data01 != 2 then
return -1
endi
if $data11 != 3 then
return -1
endi
sql select * from ct1 limit 2 offset 10
print ====> sql : select * from ct1 limit 2 offset 7
print ====> rows: $rows
if $rows != 0 then
return -1
endi
sql select c1 from stb1 limit 1
print ====> sql : select c1 from stb1 limit 1
print ====> rows: $rows
print ====> rows0: $data00
if $rows != 1 then
return -1
endi
sql select c1 from stb1 limit 50
print ====> sql : select c1 from stb1 limit 50
print ====> rows: $rows
if $rows != 33 then
return -1
endi
sql select c1 from stb1 limit 1 offset 2
print ====> sql : select c1 from stb1 limit 1 offset 2
print ====> rows: $rows
if $rows != 1 then
return -1
endi
sql select c1 from stb1 limit 2 offset 1
print ====> sql : select c1 from stb1 limit 2 offset 1
print ====> rows: $rows
if $rows != 2 then
return -1
endi
sql select c1 from stb1 limit 2 offset 32
print ====> sql : select c1 from stb1 limit 2 offset 32
print ====> rows: $rows
if $rows != 1 then
return -1
endi
sql select c1 from stb1 limit 2 offset 40
print ====> sql : select c1 from stb1 limit 2 offset 40
print ====> rows: $rows
if $rows != 0 then
return -1
endi
print ================ query 2 complex with limit
sql select count(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1
print ====> sql : select count(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2
print ====> rows: $rows
if $rows != 1 then
return -1
endi
sql select abs(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1
print ====> sql : select abs(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2
print ====> rows: $rows
if $rows != 1 then
return -1
endi
sql select acos(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1
print ====> sql : select acos(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2
print ====> rows: $rows
if $rows != 1 then
return -1
endi
sql select asin(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1
print ====> sql : select asin(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2
print ====> rows: $rows
if $rows != 1 then
return -1
endi
sql select atan(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1
print ====> sql : select atan(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2
print ====> rows: $rows
if $rows != 1 then
return -1
endi
sql select ceil(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1
print ====> sql : select ceil(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2
print ====> rows: $rows
if $rows != 1 then
return -1
endi
sql select cos(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1
print ====> sql : select cos(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2
print ====> rows: $rows
if $rows != 1 then
return -1
endi
sql select floor(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1
print ====> sql : select floor(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2
print ====> rows: $rows
if $rows != 1 then
return -1
endi
sql select log(c1,10) from ct3 where c1 > 2 group by c7 limit 1 offset 1
print ====> sql : select log(c1,10) from ct3 where c1 > 2 group by c7 limit 1 offset 2
print ====> rows: $rows
if $rows != 1 then
return -1
endi
sql select pow(c1,3) from ct3 where c1 > 2 group by c7 limit 1 offset 1
print ====> sql : select pow(c1,3) from ct3 where c1 > 2 group by c7 limit 1 offset 2
print ====> rows: $rows
if $rows != 1 then
return -1
endi
sql select round(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1
print ====> sql : select round(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2
print ====> rows: $rows
if $rows != 1 then
return -1
endi
sql select sqrt(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1
print ====> sql : select sqrt(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2
print ====> rows: $rows
if $rows != 1 then
return -1
endi
sql select sin(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1
print ====> sql : select sin(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2
print ====> rows: $rows
if $rows != 1 then
return -1
endi
sql select tan(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1
print ====> sql : select tan(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2
print ====> rows: $rows
if $rows != 1 then
return -1
endi
print =================== count all rows
sql select count(c1) from stb1
print ====> sql : select count(c1) from stb1
print ====> rows: $data00
if $data00 != 33 then
return -1
endi
#=================================================
print =============== stop and restart taosd
system sh/exec.sh -n dnode1 -s stop -x SIGINT
system sh/exec.sh -n dnode1 -s start
$loop_cnt = 0
check_dnode_ready_0:
$loop_cnt = $loop_cnt + 1
sleep 200
if $loop_cnt == 10 then
print ====> dnode not ready!
return -1
endi
sql show dnodes
print ===> $rows $data00 $data01 $data02 $data03 $data04 $data05
if $data00 != 1 then
return -1
endi
if $data04 != ready then
goto check_dnode_ready_0
endi
print =================== count all rows
sql select count(c1) from stb1
print ====> sql : select count(c1) from stb1
print ====> rows: $data00
if $data00 != 33 then
return -1
endi
print ================ query 1 limit/offset
sql select * from ct1 limit 1
print ====> sql : select * from ct1 limit 1
print ====> rows: $rows
print ====> rows0: $data00, $data01, $data02, $data03, $data04, $data05, $data06, $data07, $data08, $data09
if $rows != 1 then
return -1
endi
sql select * from ct1 limit 9
print ====> sql : select * from ct1 limit 9
print ====> rows: $rows
if $rows != 8 then
return -1
endi
sql select * from ct1 limit 1 offset 2
print ====> sql : select * from ct1 limit 1 offset 2
print ====> rows: $rows
print ====> rows0: $data00, $data01, $data02, $data03, $data04, $data05, $data06, $data07, $data08, $data09
if $rows != 1 then
return -1
endi
if $data01 != 2 then
return -1
endi
sql select * from ct1 limit 2 offset 1
print ====> sql : select * from ct1 limit 2 offset 7
print ====> rows: $rows
if $rows != 2 then
return -1
endi
if $data01 != 8 then
return -1
endi
sql select * from ct1 limit 2 offset 7
print ====> sql : select * from ct1 limit 2 offset 7
print ====> rows: $rows
print ====> rows0: $data00, $data01, $data02, $data03, $data04, $data05, $data06, $data07, $data08, $data09
if $rows != 1 then
return -1
endi
if $data01 != 2 then
return -1
endi
if $data11 != 3 then
return -1
endi
sql select * from ct1 limit 2 offset 10
print ====> sql : select * from ct1 limit 2 offset 7
print ====> rows: $rows
if $rows != 0 then
return -1
endi
sql select c1 from stb1 limit 1
print ====> sql : select c1 from stb1 limit 1
print ====> rows: $rows
print ====> rows0: $data00
if $rows != 1 then
return -1
endi
sql select c1 from stb1 limit 50
print ====> sql : select c1 from stb1 limit 50
print ====> rows: $rows
if $rows != 33 then
return -1
endi
sql select c1 from stb1 limit 1 offset 2
print ====> sql : select c1 from stb1 limit 1 offset 2
print ====> rows: $rows
if $rows != 1 then
return -1
endi
sql select c1 from stb1 limit 2 offset 1
print ====> sql : select c1 from stb1 limit 2 offset 1
print ====> rows: $rows
if $rows != 2 then
return -1
endi
sql select c1 from stb1 limit 2 offset 32
print ====> sql : select c1 from stb1 limit 2 offset 32
print ====> rows: $rows
if $rows != 1 then
return -1
endi
sql select c1 from stb1 limit 2 offset 40
print ====> sql : select c1 from stb1 limit 2 offset 40
print ====> rows: $rows
if $rows != 0 then
return -1
endi
print ================ query 2 complex with limit
sql select count(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1
print ====> sql : select count(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2
print ====> rows: $rows
if $rows != 1 then
return -1
endi
sql select abs(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1
print ====> sql : select abs(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2
print ====> rows: $rows
if $rows != 1 then
return -1
endi
sql select acos(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1
print ====> sql : select acos(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2
print ====> rows: $rows
if $rows != 1 then
return -1
endi
sql select asin(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1
print ====> sql : select asin(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2
print ====> rows: $rows
if $rows != 1 then
return -1
endi
sql select atan(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1
print ====> sql : select atan(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2
print ====> rows: $rows
if $rows != 1 then
return -1
endi
sql select ceil(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1
print ====> sql : select ceil(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2
print ====> rows: $rows
if $rows != 1 then
return -1
endi
sql select cos(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1
print ====> sql : select cos(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2
print ====> rows: $rows
if $rows != 1 then
return -1
endi
sql select floor(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1
print ====> sql : select floor(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2
print ====> rows: $rows
if $rows != 1 then
return -1
endi
sql select log(c1,10) from ct3 where c1 > 2 group by c7 limit 1 offset 1
print ====> sql : select log(c1,10) from ct3 where c1 > 2 group by c7 limit 1 offset 2
print ====> rows: $rows
if $rows != 1 then
return -1
endi
sql select pow(c1,3) from ct3 where c1 > 2 group by c7 limit 1 offset 1
print ====> sql : select pow(c1,3) from ct3 where c1 > 2 group by c7 limit 1 offset 2
print ====> rows: $rows
if $rows != 1 then
return -1
endi
sql select round(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1
print ====> sql : select round(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2
print ====> rows: $rows
if $rows != 1 then
return -1
endi
sql select sqrt(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1
print ====> sql : select sqrt(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2
print ====> rows: $rows
if $rows != 1 then
return -1
endi
sql select sin(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1
print ====> sql : select sin(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2
print ====> rows: $rows
if $rows != 1 then
return -1
endi
sql select tan(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1
print ====> sql : select tan(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2
print ====> rows: $rows
if $rows != 1 then
return -1
endi
#system sh/exec.sh -n dnode1 -s stop -x SIGINT
\ No newline at end of file
tests/script/tsim/query/complex_select.sim
0 → 100644
浏览文件 @
39fb5651
system sh/stop_dnodes.sh
system sh/deploy.sh -n dnode1 -i 1
system sh/exec.sh -n dnode1 -s start
$loop_cnt = 0
check_dnode_ready:
$loop_cnt = $loop_cnt + 1
sleep 200
if $loop_cnt == 10 then
print ====> dnode not ready!
return -1
endi
sql show dnodes
print ===> $rows $data00 $data01 $data02 $data03 $data04 $data05
if $data00 != 1 then
return -1
endi
if $data04 != ready then
goto check_dnode_ready
endi
sql connect
print =============== create database
sql create database db
sql show databases
if $rows != 2 then
return -1
endi
sql use db
print =============== create super table and child table
sql create table stb1 (ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint, c5 float, c6 double, c7 bool, c8 binary(16),c9 nchar(32), c10 timestamp) tags (t1 int)
sql show stables
print $rows $data00 $data01 $data02
if $rows != 1 then
return -1
endi
sql create table ct1 using stb1 tags ( 1 )
sql create table ct2 using stb1 tags ( 2 )
sql create table ct3 using stb1 tags ( 3 )
sql create table ct4 using stb1 tags ( 4 )
sql show tables
print $rows $data00 $data10 $data20
if $rows != 4 then
return -1
endi
print =============== insert data into child table ct1 (s)
sql insert into ct1 values ( '2022-01-01 01:01:01.000', 1, 11111, 111, 11, 1.11, 11.11, 1, "binary1", "nchar1", now+1a )
sql insert into ct1 values ( '2022-01-01 01:01:06.000', 2, 22222, 222, 22, 2.22, 22.22, 0, "binary2", "nchar2", now+2a )
sql insert into ct1 values ( '2022-01-01 01:01:10.000', 3, 33333, 333, 33, 3.33, 33.33, 0, "binary3", "nchar3", now+3a )
sql insert into ct1 values ( '2022-01-01 01:01:16.000', 4, 44444, 444, 44, 4.44, 44.44, 1, "binary4", "nchar4", now+4a )
sql insert into ct1 values ( '2022-01-01 01:01:20.000', 5, 55555, 555, 55, 5.55, 55.55, 0, "binary5", "nchar5", now+5a )
sql insert into ct1 values ( '2022-01-01 01:01:26.000', 6, 66666, 666, 66, 6.66, 66.66, 1, "binary6", "nchar6", now+6a )
sql insert into ct1 values ( '2022-01-01 01:01:30.000', 7, 00000, 000, 00, 0.00, 00.00, 1, "binary7", "nchar7", now+7a )
sql insert into ct1 values ( '2022-01-01 01:01:36.000', 8, -88888, -888, -88, -8.88, -88.88, 0, "binary8", "nchar8", now+8a )
print =============== insert data into child table ct2 (d)
sql insert into ct2 values ( '2022-01-01 01:00:01.000', 1, 11111, 111, 11, 1.11, 11.11, 1, "binary1", "nchar1", now+1a )
sql insert into ct2 values ( '2022-01-01 10:00:01.000', 2, 22222, 222, 22, 2.22, 22.22, 0, "binary2", "nchar2", now+2a )
sql insert into ct2 values ( '2022-01-01 20:00:01.000', 3, 33333, 333, 33, 3.33, 33.33, 0, "binary3", "nchar3", now+3a )
sql insert into ct2 values ( '2022-01-02 10:00:01.000', 4, 44444, 444, 44, 4.44, 44.44, 1, "binary4", "nchar4", now+4a )
sql insert into ct2 values ( '2022-01-02 20:00:01.000', 5, 55555, 555, 55, 5.55, 55.55, 0, "binary5", "nchar5", now+5a )
sql insert into ct2 values ( '2022-01-03 10:00:01.000', 7, 00000, 000, 00, 0.00, 00.00, 1, "binary7", "nchar7", now+6a )
sql insert into ct2 values ( '2022-01-03 20:00:01.000', 8, -88888, -888, -88, -8.88, -88.88, 0, "binary8", "nchar8", now+7a )
print =============== insert data into child table ct3 (n)
sql insert into ct3 values ( '2021-12-21 01:01:01.000', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
sql insert into ct3 values ( '2021-12-31 01:01:01.000', 1, 11111, 111, 11, 1.11, 11.11, 1, "binary1", "nchar1", now+1a )
sql insert into ct3 values ( '2022-01-01 01:01:06.000', 2, 22222, 222, 22, 2.22, 22.22, 0, "binary2", "nchar2", now+2a )
sql insert into ct3 values ( '2022-01-07 01:01:10.000', 3, 33333, 333, 33, 3.33, 33.33, 0, "binary3", "nchar3", now+3a )
sql insert into ct3 values ( '2022-01-31 01:01:16.000', 4, 44444, 444, 44, 4.44, 44.44, 1, "binary4", "nchar4", now+4a )
sql insert into ct3 values ( '2022-02-01 01:01:20.000', 5, 55555, 555, 55, 5.55, 55.55, 0, "binary5", "nchar5", now+5a )
sql insert into ct3 values ( '2022-02-28 01:01:26.000', 6, 66666, 666, 66, 6.66, 66.66, 1, "binary6", "nchar6", now+6a )
sql insert into ct3 values ( '2022-03-01 01:01:30.000', 7, 00000, 000, 00, 0.00, 00.00, 1, "binary7", "nchar7", "1970-01-01 08:00:00.000" )
sql insert into ct3 values ( '2022-03-08 01:01:36.000', 8, -88888, -888, -88, -8.88, -88.88, 0, "binary8", "nchar8", "1969-01-01 01:00:00.000" )
print =============== insert data into child table ct4 (y)
sql insert into ct4 values ( '2020-10-21 01:01:01.000', 1, 11111, 111, 11, 1.11, 11.11, 1, "binary1", "nchar1", now+1a )
sql insert into ct4 values ( '2020-12-31 01:01:01.000', 2, 22222, 222, 22, 2.22, 22.22, 0, "binary2", "nchar2", now+2a )
sql insert into ct4 values ( '2021-01-01 01:01:06.000', 3, 33333, 333, 33, 3.33, 33.33, 0, "binary3", "nchar3", now+3a )
sql insert into ct4 values ( '2021-05-07 01:01:10.000', 4, 44444, 444, 44, 4.44, 44.44, 1, "binary4", "nchar4", now+4a )
sql insert into ct4 values ( '2021-09-30 01:01:16.000', 5, 55555, 555, 55, 5.55, 55.55, 0, "binary5", "nchar5", now+5a )
sql insert into ct4 values ( '2022-02-01 01:01:20.000', 6, 66666, 666, 66, 6.66, 66.66, 1, "binary6", "nchar6", now+6a )
sql insert into ct4 values ( '2022-10-28 01:01:26.000', 7, 00000, 000, 00, 0.00, 00.00, 1, "binary7", "nchar7", "1970-01-01 08:00:00.000" )
sql insert into ct4 values ( '2022-12-01 01:01:30.000', 8, -88888, -888, -88, -8.88, -88.88, 0, "binary8", "nchar8", "1969-01-01 01:00:00.000" )
sql insert into ct4 values ( '2022-12-31 01:01:36.000', 9, -99999999999999999, -999, -99, -9.99, -999999999999999999999.99, 1, "binary9", "nchar9", "1900-01-01 00:00:00.000" )
print ================ start query ======================
print ================ query 1 limit/offset
sql select * from ct1 limit 1
print ====> sql : select * from ct1 limit 1
print ====> rows: $rows
print ====> rows0: $data00, $data01, $data02, $data03, $data04, $data05, $data06, $data07, $data08, $data09
if $rows != 1 then
return -1
endi
sql select * from ct1 limit 9
print ====> sql : select * from ct1 limit 9
print ====> rows: $rows
if $rows != 8 then
return -1
endi
sql select * from ct1 limit 1 offset 2
print ====> sql : select * from ct1 limit 1 offset 2
print ====> rows: $rows
print ====> rows0: $data00, $data01, $data02, $data03, $data04, $data05, $data06, $data07, $data08, $data09
if $rows != 1 then
return -1
endi
if $data01 != 2 then
return -1
endi
sql select * from ct1 limit 2 offset 1
print ====> sql : select * from ct1 limit 2 offset 7
print ====> rows: $rows
if $rows != 2 then
return -1
endi
if $data01 != 8 then
return -1
endi
sql select * from ct1 limit 2 offset 7
print ====> sql : select * from ct1 limit 2 offset 7
print ====> rows: $rows
print ====> rows0: $data00, $data01, $data02, $data03, $data04, $data05, $data06, $data07, $data08, $data09
if $rows != 1 then
return -1
endi
if $data01 != 2 then
return -1
endi
if $data11 != 3 then
return -1
endi
sql select * from ct1 limit 2 offset 10
print ====> sql : select * from ct1 limit 2 offset 7
print ====> rows: $rows
if $rows != 0 then
return -1
endi
sql select c1 from stb1 limit 1
print ====> sql : select c1 from stb1 limit 1
print ====> rows: $rows
print ====> rows0: $data00
if $rows != 1 then
return -1
endi
sql select c1 from stb1 limit 50
print ====> sql : select c1 from stb1 limit 50
print ====> rows: $rows
if $rows != 33 then
return -1
endi
sql select c1 from stb1 limit 1 offset 2
print ====> sql : select c1 from stb1 limit 1 offset 2
print ====> rows: $rows
if $rows != 1 then
return -1
endi
sql select c1 from stb1 limit 2 offset 1
print ====> sql : select c1 from stb1 limit 2 offset 1
print ====> rows: $rows
if $rows != 2 then
return -1
endi
sql select c1 from stb1 limit 2 offset 32
print ====> sql : select c1 from stb1 limit 2 offset 32
print ====> rows: $rows
if $rows != 1 then
return -1
endi
sql select c1 from stb1 limit 2 offset 40
print ====> sql : select c1 from stb1 limit 2 offset 40
print ====> rows: $rows
if $rows != 0 then
return -1
endi
print ================ query 2 where condition
sql select * from ct3 where c1 < 5
print ====> sql : select * from ct3 where c1 < 5
print ====> rows: $rows
print ====> rows0: $data00, $data01, $data02, $data03, $data04, $data05, $data06, $data07, $data08, $data09
if $rows != 4 then
return -1
endi
if $data01 != 1 then
return -1
endi
sql select * from ct3 where c1 > 5 and c1 <= 6
print ====> sql : select * from ct3 where c1 > 5 and c1 <= 6
print ====> rows: $rows
print ====> rows0: $data00, $data01, $data02, $data03, $data04, $data05, $data06, $data07, $data08, $data09
if $rows != 1 then
return -1
endi
if $data01 != 6 then
return -1
endi
sql select * from ct3 where c1 >= 5 or c1 != 4 or c1 <> 3 or c1 = 2
print ====> sql : select * from ct3 where c1 > 5 and c1 <= 6
print ====> rows: $rows
print ====> rows0: $data00, $data01, $data02, $data03, $data04, $data05, $data06, $data07, $data08, $data09
if $rows != 8 then
return -1
endi
if $data01 != 1 then
return -1
endi
sql select * from ct3 where c1 >= 5 and c1 is not NULL
print ====> sql : select * from ct3 where c1 >= 5 and c1 is not NULL
print ====> rows: $rows
print ====> rows0: $data00, $data01, $data02, $data03, $data04, $data05, $data06, $data07, $data08, $data09
if $rows != 4 then
return -1
endi
if $data01 != 5 then
return -1
endi
sql_error select ts from ct3 where ts != 0
sql select * from ct3 where ts <> 0
print ====> sql : select * from ct3 where ts <> 0
print ====> rows: $rows
if $rows != 8 then
return -1
endi
sql select * from ct3 where c1 between 1 and 3
print ====> sql : select * from ct3 where c1 between 1 and 3
print ====> rows: $rows
if $rows != 3 then
return -1
endi
sql_error select * from ct3 where c7 between false and true
sql select * from ct3 where c1 in (1,2,3)
print ====> sql : select * from ct3 where c1 in (1,2,3)
print ====> rows: $rows
if $rows != 3 then
return -1
endi
sql select * from ct3 where c1 in (‘true','false')
print ====> sql : select * from ct3 where c1 in (‘true','false')
print ====> rows: $rows
if $rows != 8 then
return -1
endi
sql select * from ct3 where c9 like "_char_"
print ====> sql : select * from ct3 where c1 in (1,2,3)
print ====> rows: $rows
if $rows != 8 then
return -1
endi
sql select * from ct3 where c8 like "bi%"
print ====> sql : select * from ct3 where c1 in (1,2,3)
print ====> rows: $rows
if $rows != 8 then
return -1
endi
sql select c1 from stb1 where c1 < 5
print ====> sql : select c1 from stb1 where c1 < 5
print ====> rows: $rows
print ====> rows0: $data00
if $rows != 16 then
return -1
endi
if $data01 != 1 then
return -1
endi
sql select c1 from stb1 where stb1 > 5 and c1 <= 6
print ====> sql : select c1 from stb1 where c1 > 5 and c1 <= 6
print ====> rows: $rows
print ====> rows0: $data00
if $rows != 4 then
return -1
endi
if $data01 != 6 then
return -1
endi
sql select c1 from stb1 where c1 >= 5 or c1 != 4 or c1 <> 3 or c1 = 2
print ====> sql : sselect c1 from stb1 where c1 >= 5 or c1 != 4 or c1 <> 3 or c1 = 2
print ====> rows: $rows
print ====> rows0: $data00
if $rows != 32 then
return -1
endi
if $data01 != 1 then
return -1
endi
sql select c1 from stb1 where c1 >= 5 and c1 is not NULL
print ====> sql : select c1 from stb1 where c1 >= 5 and c1 is not NULL
print ====> rows: $rows
print ====> rows0: $data00
if $rows != 17 then
return -1
endi
if $data01 != 5 then
return -1
endi
sql_error select ts from stb1 where ts != 0
sql select c1 from stb1 where ts <> 0
print ====> sql : select c1 from stb1 where ts <> 0
print ====> rows: $rows
if $rows != 32 then
return -1
endi
sql select c1 from stb1 where c1 between 1 and 3
print ====> sql : select c1 from stb1 where c1 between 1 and 3
print ====> rows: $rows
if $rows != 12 then
return -1
endi
sql_error select c1 from stb1 where c7 between false and true
sql select c1 from stb1 where c1 in (1,2,3)
print ====> sql : select c1 from stb1 where c1 in (1,2,3)
print ====> rows: $rows
if $rows != 12 then
return -1
endi
sql select c1 from stb1 where c1 in (‘true','false')
print ====> sql : select c1 from stb1 where c1 in (‘true','false')
print ====> rows: $rows
if $rows != 32 then
return -1
endi
sql select c1 from stb1 where c9 like "_char_"
print ====> sql : select c1 from stb1 where c9 like "_char_"
print ====> rows: $rows
if $rows != 32 then
return -1
endi
sql select c1 from stb1 where c8 like "bi%"
print ====> sql : select c1 from stb1 where c8 like "bi%"
print ====> rows: $rows
if $rows != 32 then
return -1
endi
print ================ query 3 group by filter
sql select count(*) from ct3 group by c1
print ====> sql : select count(*) from ct3 group by c1
print ====> rows: $rows
if $rows != 8 then
return -1
endi
sql select count(*) from ct3 group by c2
print ====> sql : select count(*) from ct3 group by c2
print ====> rows: $rows
if $rows != 8 then
return -1
endi
sql select count(*) from ct3 group by c3
print ====> sql : select count(*) from ct3 group by c3
print ====> rows: $rows
if $rows != 8 then
return -1
endi
sql select count(*) from ct3 group by c4
print ====> sql : select count(*) from ct3 group by c4
print ====> rows: $rows
if $rows != 8 then
return -1
endi
sql select count(*) from ct3 group by c5
print ====> sql : select count(*) from ct3 group by c5
print ====> rows: $rows
if $rows != 8 then
return -1
endi
sql select count(*) from ct3 group by c6
print ====> sql : select count(*) from ct3 group by c6
print ====> rows: $rows
if $rows != 8 then
return -1
endi
sql select count(*) from ct3 group by c7
print ====> sql : select count(*) from ct3 group by c7
print ====> rows: $rows
if $rows != 2 then
return -1
endi
sql select count(*) from ct3 group by c8
print ====> sql : select count(*) from ct3 group by c8
print ====> rows: $rows
if $rows != 8 then
return -1
endi
sql select count(*) from ct3 group by c9
print ====> sql : select count(*) from ct3 group by c9
print ====> rows: $rows
if $rows != 8 then
return -1
endi
sql select count(*) from ct3 group by c10
print ====> sql : select count(*) from ct3 group by c10
print ====> rows: $rows
if $rows != 8 then
return -1
endi
print ================ query 4 scalar function + where + group by + limit/offset
sql select count(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1
print ====> sql : select count(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2
print ====> rows: $rows
if $rows != 1 then
return -1
endi
sql select abs(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1
print ====> sql : select abs(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2
print ====> rows: $rows
if $rows != 1 then
return -1
endi
sql select acos(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1
print ====> sql : select acos(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2
print ====> rows: $rows
if $rows != 1 then
return -1
endi
sql select asin(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1
print ====> sql : select asin(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2
print ====> rows: $rows
if $rows != 1 then
return -1
endi
sql select atan(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1
print ====> sql : select atan(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2
print ====> rows: $rows
if $rows != 1 then
return -1
endi
sql select ceil(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1
print ====> sql : select ceil(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2
print ====> rows: $rows
if $rows != 1 then
return -1
endi
sql select cos(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1
print ====> sql : select cos(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2
print ====> rows: $rows
if $rows != 1 then
return -1
endi
sql select floor(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1
print ====> sql : select floor(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2
print ====> rows: $rows
if $rows != 1 then
return -1
endi
sql select log(c1,10) from ct3 where c1 > 2 group by c7 limit 1 offset 1
print ====> sql : select log(c1,10) from ct3 where c1 > 2 group by c7 limit 1 offset 2
print ====> rows: $rows
if $rows != 1 then
return -1
endi
sql select pow(c1,3) from ct3 where c1 > 2 group by c7 limit 1 offset 1
print ====> sql : select pow(c1,3) from ct3 where c1 > 2 group by c7 limit 1 offset 2
print ====> rows: $rows
if $rows != 1 then
return -1
endi
sql select round(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1
print ====> sql : select round(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2
print ====> rows: $rows
if $rows != 1 then
return -1
endi
sql select sqrt(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1
print ====> sql : select sqrt(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2
print ====> rows: $rows
if $rows != 1 then
return -1
endi
sql select sin(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1
print ====> sql : select sin(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2
print ====> rows: $rows
if $rows != 1 then
return -1
endi
sql select tan(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1
print ====> sql : select tan(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2
print ====> rows: $rows
if $rows != 1 then
return -1
endi
print =================== count all rows
sql select count(c1) from stb1
print ====> sql : select count(c1) from stb1
print ====> rows: $data00
if $data00 != 33 then
return -1
endi
#=================================================
print =============== stop and restart taosd
system sh/exec.sh -n dnode1 -s stop -x SIGINT
system sh/exec.sh -n dnode1 -s start
$loop_cnt = 0
check_dnode_ready_0:
$loop_cnt = $loop_cnt + 1
sleep 200
if $loop_cnt == 10 then
print ====> dnode not ready!
return -1
endi
sql show dnodes
print ===> $rows $data00 $data01 $data02 $data03 $data04 $data05
if $data00 != 1 then
return -1
endi
if $data04 != ready then
goto check_dnode_ready_0
endi
print =================== count all rows
sql select count(c1) from stb1
print ====> sql : select count(c1) from stb1
print ====> rows: $data00
if $data00 != 33 then
return -1
endi
#system sh/exec.sh -n dnode1 -s stop -x SIGINT
\ No newline at end of file
tests/script/tsim/query/complex_where.sim
0 → 100644
浏览文件 @
39fb5651
此差异已折叠。
点击以展开。
tests/script/
general/explain
/explain.sim
→
tests/script/
tsim/query
/explain.sim
浏览文件 @
39fb5651
文件已移动
tests/script/tsim/query/session.sim
浏览文件 @
39fb5651
...
...
@@ -77,6 +77,8 @@ sql INSERT INTO dev_002 VALUES('2020-05-13 10:00:00.51', 7)
$loop_test = 0
loop_test_pos:
sql use $dbNamme
# session(ts,5a)
print ====> select count(*) from dev_001 session(ts,5a)
sql select _wstartts, count(*) from dev_001 session(ts,5a)
...
...
@@ -98,15 +100,15 @@ if $data01 != 2 then
return -1
endi
print ====> select count(*) from (select * from dev_001) session(ts,5a)
sql select _wstartts, count(*) from (select * from dev_001) session(ts,5a)
if $rows != 15 then
return -1
endi
if $data01 != 2 then
return -1
endi
#
#
print ====> select count(*) from (select * from dev_001) session(ts,5a)
#
sql select _wstartts, count(*) from (select * from dev_001) session(ts,5a)
#
if $rows != 15 then
#
return -1
#
endi
#
if $data01 != 2 then
#
return -1
#
endi
print ====> select count(*) from dev_001 session(ts,1s)
sql select _wstartts, count(*) from dev_001 session(ts,1s)
...
...
@@ -117,14 +119,14 @@ if $data01 != 5 then
return -1
endi
print ====> select count(*) from (select * from dev_001) session(ts,1s)
sql select _wstartts, count(*) from (select * from dev_001) session(ts,1s)
if $rows != 12 then
return -1
endi
if $data01 != 5 then
return -1
endi
#
print ====> select count(*) from (select * from dev_001) session(ts,1s)
#
sql select _wstartts, count(*) from (select * from dev_001) session(ts,1s)
#
if $rows != 12 then
#
return -1
#
endi
#
if $data01 != 5 then
#
return -1
#
endi
print ====> select count(*) from dev_001 session(ts,1000a)
sql select _wstartts, count(*) from dev_001 session(ts,1000a)
...
...
@@ -135,14 +137,14 @@ if $data01 != 5 then
return -1
endi
print ====> select count(*) from (select * from dev_001) session(ts,1000a)
sql select _wstartts, count(*) from (select * from dev_001) session(ts,1000a)
if $rows != 12 then
return -1
endi
if $data01 != 5 then
return -1
endi
#
print ====> select count(*) from (select * from dev_001) session(ts,1000a)
#
sql select _wstartts, count(*) from (select * from dev_001) session(ts,1000a)
#
if $rows != 12 then
#
return -1
#
endi
#
if $data01 != 5 then
#
return -1
#
endi
print ====> select count(*) from dev_001 session(ts,1m)
sql select _wstartts, count(*) from dev_001 session(ts,1m)
...
...
@@ -153,14 +155,14 @@ if $data01 != 8 then
return -1
endi
print ====> select count(*) from (select * from dev_001) session(ts,1m)
sql select _wstartts, count(*) from (select * from dev_001) session(ts,1m)
if $rows != 9 then
return -1
endi
if $data01 != 8 then
return -1
endi
#
print ====> select count(*) from (select * from dev_001) session(ts,1m)
#
sql select _wstartts, count(*) from (select * from dev_001) session(ts,1m)
#
if $rows != 9 then
#
return -1
#
endi
#
if $data01 != 8 then
#
return -1
#
endi
print ====> select count(*) from dev_001 session(ts,1h)
sql select _wstartts, count(*) from dev_001 session(ts,1h)
...
...
@@ -171,14 +173,14 @@ if $data01 != 11 then
return -1
endi
print ====> select count(*) from (select * from dev_001) session(ts,1h)
sql select _wstartts, count(*) from (select * from dev_001) session(ts,1h)
if $rows != 6 then
return -1
endi
if $data01 != 11 then
return -1
endi
#
print ====> select count(*) from (select * from dev_001) session(ts,1h)
#
sql select _wstartts, count(*) from (select * from dev_001) session(ts,1h)
#
if $rows != 6 then
#
return -1
#
endi
#
if $data01 != 11 then
#
return -1
#
endi
print ====> select count(*) from dev_001 session(ts,1d)
sql select _wstartts, count(*) from dev_001 session(ts,1d)
...
...
@@ -189,14 +191,14 @@ if $data01 != 13 then
return -1
endi
print ====> select count(*) from (select * from dev_001) session(ts,1d)
sql select _wstartts, count(*) from (select * from dev_001) session(ts,1d)
if $rows != 4 then
return -1
endi
if $data01 != 13 then
return -1
endi
#
print ====> select count(*) from (select * from dev_001) session(ts,1d)
#
sql select _wstartts, count(*) from (select * from dev_001) session(ts,1d)
#
if $rows != 4 then
#
return -1
#
endi
#
if $data01 != 13 then
#
return -1
#
endi
print ====> select count(*) from dev_001 session(ts,1w)
sql select _wstartts, count(*) from dev_001 session(ts,1w)
...
...
@@ -207,18 +209,18 @@ if $data01 != 15 then
return -1
endi
print ====> select count(*) from (select * from dev_001) session(ts,1w)
sql select _wstartts, count(*) from (select * from dev_001) session(ts,1w)
if $rows != 2 then
return -1
endi
if $data01 != 15 then
return -1
endi
#
print ====> select count(*) from (select * from dev_001) session(ts,1w)
#
sql select _wstartts, count(*) from (select * from dev_001) session(ts,1w)
#
if $rows != 2 then
#
return -1
#
endi
#
if $data01 != 15 then
#
return -1
#
endi
print ====> leastsquares not supported yet.
print ====> select count(*),first(tagtype),last(tagtype),avg(tagtype),sum(tagtype),min(tagtype),max(tagtype),leastsquares(tagtype, 1, 1),spread(tagtype),stddev(tagtype),percentile(tagtype,0) from dev_001 where ts <'2020-05-20 0:0:0' session(ts,1d)
#
print ====> leastsquares not supported yet.
#
print ====> select count(*),first(tagtype),last(tagtype),avg(tagtype),sum(tagtype),min(tagtype),max(tagtype),leastsquares(tagtype, 1, 1),spread(tagtype),stddev(tagtype),percentile(tagtype,0) from dev_001 where ts <'2020-05-20 0:0:0' session(ts,1d)
#sql select count(*),first(tagtype),last(tagtype),avg(tagtype),sum(tagtype),min(tagtype),max(tagtype),leastsquares(tagtype, 1, 1),spread(tagtype),stddev(tagtype),percentile(tagtype,0) from dev_001 where ts <'2020-05-20 0:0:0' session(ts,1d)
#if $rows != 2 then
# return -1
...
...
@@ -285,14 +287,14 @@ print ====> select count(*),first(tagtype),last(tagtype),avg(tagtype),sum(tagtyp
#endi
print ================> syntax error check not active ================> reactive
#
sql_error select * from dev_001 session(ts,1w)
#sql_error
select count(*) from st session(ts,1w)
#
sql_error select count(*) from dev_001 group by tagtype session(ts,1w)
#sql_error
select count(*) from dev_001 session(ts,1n)
#sql_error
select count(*) from dev_001 session(ts,1y)
#sql_error
select count(*) from dev_001 session(ts,0s)
#
sql_error select count(*) from dev_001 session(i,1y)
#
sql_error select count(*) from dev_001 session(ts,1d) where ts <'2020-05-20 0:0:0'
sql_error select * from dev_001 session(ts,1w)
sql
select count(*) from st session(ts,1w)
sql_error select count(*) from dev_001 group by tagtype session(ts,1w)
sql
select count(*) from dev_001 session(ts,1n)
sql
select count(*) from dev_001 session(ts,1y)
sql
select count(*) from dev_001 session(ts,0s)
sql_error select count(*) from dev_001 session(i,1y)
sql_error select count(*) from dev_001 session(ts,1d) where ts <'2020-05-20 0:0:0'
print ====> create database d1 precision 'us'
sql create database d1 precision 'us'
...
...
@@ -301,17 +303,22 @@ sql create table dev_001 (ts timestamp ,i timestamp ,j int)
sql insert into dev_001 values(1623046993681000,now,1)(1623046993681001,now+1s,2)(1623046993681002,now+2s,3)(1623046993681004,now+5s,4)
print ====> select count(*) from dev_001 session(ts,1u)
sql select _wstartts, count(*) from dev_001 session(ts,1u)
if $rows != 2 then
print rows: $rows
print $data00 $data01 $data02 $data03
print $data10 $data11 $data12 $data13
print $data20 $data21 $data22 $data23
print $data30 $data31 $data32 $data33
if $rows != 4 then
print expect 2, actual: $rows
return -1
endi
if $data01 !=
3
then
if $data01 !=
1
then
return -1
endi
#sql_error select count(*) from dev_001 session(i,1s)
#
sql create table secondts(ts timestamp,t2 timestamp,i int)
sql create table secondts(ts timestamp,t2 timestamp,i int)
#sql_error select count(*) from secondts session(t2,2s)
if $loop_test == 0 then
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录