Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
8e1bd60d
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22017
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
8e1bd60d
编写于
3月 09, 2022
作者:
wmmhello
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add test case & fix error
上级
5f9f234f
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
277 addition
and
22 deletion
+277
-22
src/client/src/tscSQLParser.c
src/client/src/tscSQLParser.c
+18
-12
src/client/src/tscUtil.c
src/client/src/tscUtil.c
+0
-1
src/query/inc/qExecutor.h
src/query/inc/qExecutor.h
+1
-2
src/query/src/qAggMain.c
src/query/src/qAggMain.c
+2
-2
src/query/src/qExecutor.c
src/query/src/qExecutor.c
+4
-5
tests/develop-test/2-query/function_state.py
tests/develop-test/2-query/function_state.py
+252
-0
未找到文件。
src/client/src/tscSQLParser.c
浏览文件 @
8e1bd60d
...
...
@@ -1113,7 +1113,7 @@ static int32_t addPrimaryTsColumnForTimeWindowQuery(SQueryInfo* pQueryInfo, SSql
static
int32_t
checkInvalidExprForTimeWindow
(
SSqlCmd
*
pCmd
,
SQueryInfo
*
pQueryInfo
)
{
const
char
*
msg1
=
"invalid query expression"
;
const
char
*
msg2
=
"top/bottom query does not support order by value in time window query"
;
const
char
*
msg3
=
"unique function does not supportted in time window query"
;
const
char
*
msg3
=
"unique
/state
function does not supportted in time window query"
;
/*
* invalid sql:
...
...
@@ -6774,7 +6774,7 @@ int32_t validateOrderbyNode(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SSqlNode* pSq
const
char
*
msg8
=
"only column in groupby clause allowed as order column"
;
const
char
*
msg10
=
"not support distinct mixed with order by"
;
const
char
*
msg11
=
"not support order with udf"
;
const
char
*
msg12
=
"order by tags not supported with diff/derivative/csum/mavg"
;
const
char
*
msg12
=
"order by tags not supported with diff/derivative/csum/mavg
/stateCount/stateDuration
"
;
const
char
*
msg13
=
"order by json tag, key is too long"
;
const
char
*
msg14
=
"order by json tag, must be json->'key'"
;
...
...
@@ -8429,8 +8429,8 @@ int32_t doFunctionsCompatibleCheck(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, char*
const
char
*
msg3
=
"group by/session/state_window not allowed on projection query"
;
const
char
*
msg4
=
"retrieve tags not compatible with group by or interval query"
;
const
char
*
msg5
=
"functions can not be mixed up"
;
const
char
*
msg6
=
"TWA/Diff/Derivative/Irate/CSum/MAvg/Elapsed only support group by tbname"
;
const
char
*
msg7
=
"unique function does not supportted in state window query"
;
const
char
*
msg6
=
"TWA/Diff/Derivative/Irate/CSum/MAvg/Elapsed
/stateCount/stateDuration
only support group by tbname"
;
const
char
*
msg7
=
"unique
/state
function does not supportted in state window query"
;
// only retrieve tags, group by is not supportted
if
(
tscQueryTags
(
pQueryInfo
))
{
...
...
@@ -9524,12 +9524,23 @@ int32_t getHavingExpr(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SArray* pSelectNode
return
invalidOperationMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg1
);
}
pLeft
->
functionId
=
isValidFunction
(
pLeft
->
Expr
.
operand
.
z
,
pLeft
->
Expr
.
operand
.
n
);
if
(
pLeft
->
functionId
<
0
)
{
return
invalidOperationMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg1
);
}
if
(
pLeft
->
Expr
.
paramList
)
{
size_t
size
=
taosArrayGetSize
(
pLeft
->
Expr
.
paramList
);
for
(
int32_t
i
=
0
;
i
<
size
;
i
++
)
{
tSqlExprItem
*
pParamItem
=
taosArrayGet
(
pLeft
->
Expr
.
paramList
,
i
);
tSqlExpr
*
pExpr1
=
pParamItem
->
pNode
;
if
(
pLeft
->
functionId
==
TSDB_FUNC_STATE_COUNT
||
pLeft
->
functionId
==
TSDB_FUNC_STATE_DURATION
){
if
(
i
==
1
&&
pExpr1
->
tokenId
==
TK_ID
)
continue
;
if
(
pLeft
->
functionId
==
TSDB_FUNC_STATE_DURATION
&&
i
==
3
&&
pExpr1
->
tokenId
==
TK_TIMESTAMP
)
continue
;
}
if
(
pExpr1
->
tokenId
!=
TK_ALL
&&
pExpr1
->
tokenId
!=
TK_ID
&&
pExpr1
->
tokenId
!=
TK_STRING
&&
...
...
@@ -9559,11 +9570,6 @@ int32_t getHavingExpr(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SArray* pSelectNode
}
}
pLeft
->
functionId
=
isValidFunction
(
pLeft
->
Expr
.
operand
.
z
,
pLeft
->
Expr
.
operand
.
n
);
if
(
pLeft
->
functionId
<
0
)
{
return
invalidOperationMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg1
);
}
return
handleExprInHavingClause
(
pCmd
,
pQueryInfo
,
pSelectNodeList
,
pExpr
,
parentOptr
);
}
...
...
@@ -10087,7 +10093,7 @@ int32_t validateSqlNode(SSqlObj* pSql, SSqlNode* pSqlNode, SQueryInfo* pQueryInf
const
char
*
msg4
=
"interval query not supported, since the result of sub query not include valid timestamp column"
;
const
char
*
msg5
=
"only tag query not compatible with normal column filter"
;
const
char
*
msg6
=
"not support stddev/percentile in the outer query yet"
;
const
char
*
msg7
=
"derivative/twa/rate/irate/diff/tail requires timestamp column exists in subquery"
;
const
char
*
msg7
=
"derivative/twa/rate/irate/diff/tail
/stateCount/stateDuration
requires timestamp column exists in subquery"
;
const
char
*
msg8
=
"condition missing for join query"
;
const
char
*
msg9
=
"not support 3 level select"
;
...
...
@@ -10170,7 +10176,7 @@ int32_t validateSqlNode(SSqlObj* pSql, SSqlNode* pSqlNode, SQueryInfo* pQueryInf
int32_t
f
=
pExpr
->
base
.
functionId
;
if
(
f
==
TSDB_FUNC_DERIVATIVE
||
f
==
TSDB_FUNC_TWA
||
f
==
TSDB_FUNC_IRATE
||
f
==
TSDB_FUNC_RATE
||
f
==
TSDB_FUNC_DIFF
||
f
==
TSDB_FUNC_TAIL
||
f
==
TSDB_FUNC_STATE_DURATION
)
{
f
==
TSDB_FUNC_STATE_
COUNT
||
f
==
TSDB_FUNC_STATE_
DURATION
)
{
return
invalidOperationMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg7
);
}
}
...
...
src/client/src/tscUtil.c
浏览文件 @
8e1bd60d
...
...
@@ -5083,7 +5083,6 @@ int32_t tscCreateQueryFromQueryInfo(SQueryInfo* pQueryInfo, SQueryAttr* pQueryAt
pQueryAttr
->
limit
=
pQueryInfo
->
limit
;
pQueryAttr
->
slimit
=
pQueryInfo
->
slimit
;
pQueryAttr
->
order
=
pQueryInfo
->
order
;
pQueryAttr
->
originOrder
=
pQueryInfo
->
order
.
order
;
pQueryAttr
->
fillType
=
pQueryInfo
->
fillType
;
pQueryAttr
->
havingNum
=
pQueryInfo
->
havingFieldNum
;
pQueryAttr
->
pUdfInfo
=
pQueryInfo
->
pUdfInfo
;
...
...
src/query/inc/qExecutor.h
浏览文件 @
8e1bd60d
...
...
@@ -285,7 +285,6 @@ typedef struct SQueryAttr {
int32_t
vgId
;
SArray
*
pUdfInfo
;
// no need to free
int32_t
interBytesForGlobal
;
uint32_t
originOrder
;
}
SQueryAttr
;
typedef
SSDataBlock
*
(
*
__operator_fn_t
)(
void
*
param
,
bool
*
newgroup
);
...
...
@@ -650,7 +649,7 @@ SOperatorInfo* createFilterOperatorInfo(SQueryRuntimeEnv* pRuntimeEnv, SOperator
int32_t
numOfOutput
,
SColumnInfo
*
pCols
,
int32_t
numOfFilter
);
SOperatorInfo
*
createJoinOperatorInfo
(
SOperatorInfo
**
pUpstream
,
int32_t
numOfUpstream
,
SSchema
*
pSchema
,
int32_t
numOfOutput
);
SOperatorInfo
*
createOrderOperatorInfo
(
SQueryRuntimeEnv
*
pRuntimeEnv
,
SOperatorInfo
*
upstream
,
SExprInfo
*
pExpr
,
int32_t
numOfOutput
,
SOrderVal
*
pOrderVal
,
uint32_t
originOrder
);
SOperatorInfo
*
createOrderOperatorInfo
(
SQueryRuntimeEnv
*
pRuntimeEnv
,
SOperatorInfo
*
upstream
,
SExprInfo
*
pExpr
,
int32_t
numOfOutput
,
SOrderVal
*
pOrderVal
);
SSDataBlock
*
doGlobalAggregate
(
void
*
param
,
bool
*
newgroup
);
SSDataBlock
*
doMultiwayMergeSort
(
void
*
param
,
bool
*
newgroup
);
...
...
src/query/src/qAggMain.c
浏览文件 @
8e1bd60d
...
...
@@ -641,8 +641,8 @@ int32_t isValidFunction(const char* name, int32_t len) {
}
bool
isValidStateOper
(
char
*
oper
,
int32_t
len
){
return
strncmp
(
oper
,
"lt"
,
len
)
||
strncmp
(
oper
,
"gt"
,
len
)
||
strncmp
(
oper
,
"le"
,
len
)
||
strncmp
(
oper
,
"ge"
,
len
)
||
strncmp
(
oper
,
"
ne"
,
len
)
||
strncmp
(
oper
,
"eq"
,
len
)
;
return
strncmp
(
oper
,
"lt"
,
len
)
==
0
||
strncmp
(
oper
,
"gt"
,
len
)
==
0
||
strncmp
(
oper
,
"le"
,
len
)
==
0
||
strncmp
(
oper
,
"
ge"
,
len
)
==
0
||
strncmp
(
oper
,
"ne"
,
len
)
==
0
||
strncmp
(
oper
,
"eq"
,
len
)
==
0
;
}
#define STATEOPER(OPER, COMP, TYPE) if (strncmp(oper->pz, OPER, oper->nLen) == 0) {\
...
...
src/query/src/qExecutor.c
浏览文件 @
8e1bd60d
...
...
@@ -2302,10 +2302,10 @@ static int32_t setupQueryRuntimeEnv(SQueryRuntimeEnv *pRuntimeEnv, int32_t numOf
case
OP_Order
:
{
if
(
pQueryAttr
->
pExpr2
!=
NULL
)
{
pRuntimeEnv
->
proot
=
createOrderOperatorInfo
(
pRuntimeEnv
,
pRuntimeEnv
->
proot
,
pQueryAttr
->
pExpr2
,
pQueryAttr
->
numOfExpr2
,
&
pQueryAttr
->
order
,
pQueryAttr
->
originOrder
);
pQueryAttr
->
numOfExpr2
,
&
pQueryAttr
->
order
);
}
else
{
pRuntimeEnv
->
proot
=
createOrderOperatorInfo
(
pRuntimeEnv
,
pRuntimeEnv
->
proot
,
pQueryAttr
->
pExpr1
,
pQueryAttr
->
numOfOutput
,
&
pQueryAttr
->
order
,
pQueryAttr
->
originOrder
);
pQueryAttr
->
numOfOutput
,
&
pQueryAttr
->
order
);
}
if
(
pRuntimeEnv
->
proot
==
NULL
)
{
goto
_clean
;
...
...
@@ -5845,7 +5845,7 @@ static SSDataBlock* doSort(void* param, bool* newgroup) {
return
(
pInfo
->
pDataBlock
->
info
.
rows
>
0
)
?
pInfo
->
pDataBlock
:
NULL
;
}
SOperatorInfo
*
createOrderOperatorInfo
(
SQueryRuntimeEnv
*
pRuntimeEnv
,
SOperatorInfo
*
upstream
,
SExprInfo
*
pExpr
,
int32_t
numOfOutput
,
SOrderVal
*
pOrderVal
,
uint32_t
originOrder
)
{
SOperatorInfo
*
createOrderOperatorInfo
(
SQueryRuntimeEnv
*
pRuntimeEnv
,
SOperatorInfo
*
upstream
,
SExprInfo
*
pExpr
,
int32_t
numOfOutput
,
SOrderVal
*
pOrderVal
)
{
SOrderOperatorInfo
*
pInfo
=
calloc
(
1
,
sizeof
(
SOrderOperatorInfo
));
if
(
pInfo
==
NULL
)
{
return
NULL
;
...
...
@@ -5875,7 +5875,7 @@ SOperatorInfo *createOrderOperatorInfo(SQueryRuntimeEnv* pRuntimeEnv, SOperatorI
}
pDataBlock
->
info
.
numOfCols
=
numOfOutput
;
pInfo
->
order
=
originO
rder
;
pInfo
->
order
=
pOrderVal
->
o
rder
;
pInfo
->
pDataBlock
=
pDataBlock
;
}
...
...
@@ -9526,7 +9526,6 @@ SQInfo* createQInfoImpl(SQueryTableMsg* pQueryMsg, SGroupbyExpr* pGroupbyExpr, S
pQueryAttr
->
limit
.
offset
=
pQueryMsg
->
offset
;
pQueryAttr
->
order
.
order
=
pQueryMsg
->
order
;
pQueryAttr
->
order
.
orderColId
=
pQueryMsg
->
orderColId
;
pQueryAttr
->
originOrder
=
pQueryMsg
->
order
;
// record the order previous
pQueryAttr
->
pExpr1
=
pExprs
;
pQueryAttr
->
pExpr2
=
pSecExprs
;
pQueryAttr
->
numOfExpr2
=
pQueryMsg
->
secondStageOutput
;
...
...
tests/develop-test/2-query/function_state.py
0 → 100644
浏览文件 @
8e1bd60d
###################################################################
# Copyright (c) 2021 by TAOS Technologies, Inc.
# All rights reserved.
#
# This file is proprietary and confidential to TAOS Technologies.
# No part of this file may be reproduced, stored, transmitted,
# disclosed or used in any form or by any means other than as
# expressly provided by the written permission from Jianhui Tao
#
###################################################################
# -*- coding: utf-8 -*-
import
sys
from
util.log
import
*
from
util.cases
import
*
from
util.sql
import
*
class
TDTestCase
:
def
caseDescription
(
self
):
'''
case1<markwang>: [TD-11210] function stateCount stateDuration
'''
return
def
init
(
self
,
conn
,
logSql
):
tdLog
.
debug
(
"start to execute %s"
%
__file__
)
tdSql
.
init
(
conn
.
cursor
(),
logSql
)
self
.
_conn
=
conn
def
run
(
self
):
print
(
"running {}"
.
format
(
__file__
))
tdSql
.
execute
(
"drop database if exists statef"
)
tdSql
.
execute
(
"create database if not exists statef"
)
tdSql
.
execute
(
'use statef'
)
tdSql
.
execute
(
'create table sstatef (ts timestamp, dbig bigint, dsmall smallint, dbool bool, dtiny tinyint unsigned, dfloat float, ddouble double, dnchar nchar(4093), dbinary binary(64), dtime timestamp) tags (tbinary nchar(4093), tint int)'
)
tdSql
.
execute
(
'create table statef1 using sstatef tags ("t1", 1)'
)
tdSql
.
execute
(
'create table statef2 using sstatef tags ("t2", 2)'
)
tdSql
.
execute
(
'insert into statef1 values("2021-10-17 00:31:31", 1, -3276, true, 253, 3.32333, 4.984392323, "你好", "sddd", 333) ("2022-01-24 00:31:32", 1, -32767, false, 254, NULL, 4.982392323, "你好吗", "sdf",2323)'
)
tdSql
.
execute
(
'insert into statef2 values("2021-10-15 00:31:33", 1, NULL, true, 23, 3.4, 4.982392323, "你好吗", "sdf", 333) ("2021-12-24 00:31:34", 2, 32767, NULL, NULL, NULL, 4.982392323, NULL, "sddd", NULL) ("2022-01-01 08:00:05", 19, 3276, true, 2, 3.323222, 4.92323, "试试", "sddd", 1645434434000)'
)
tdSql
.
execute
(
'insert into statef2 values("2021-10-17 00:31:31", NULL, 32767, true, 123, 3.323232333, 4.2, NULL, NULL, NULL) ("2022-01-01 08:00:06", NULL, NULL, NULL, 35, 3.323232333, NULL, "试试", NULL, 1645434434000) ("2022-01-01 08:00:07", 9, 54, true, 25, 3.32333, NULL, "试试", NULL, 1645434434001)'
)
# error
tdSql
.
error
(
"select stateCount(ts,LE,4.923230000) from statef2"
)
tdSql
.
error
(
"select stateCount(dbool,LE,4.923230000) from statef2"
)
tdSql
.
error
(
"select stateCount(dnchar,LE,4.923230000) from statef2"
)
tdSql
.
error
(
"select stateCount(dbinary,LE,4.923230000) from statef2"
)
tdSql
.
error
(
"select stateCount(dtime,LE,4.923230000) from statef2"
)
tdSql
.
error
(
"select stateCount(tint,LE,4.923230000) from statef2"
)
tdSql
.
error
(
"select stateCount(tbinary,LE,4.923230000) from statef2"
)
tdSql
.
error
(
"select stateCount(tbinary,ew,4.923230000) from statef2"
)
tdSql
.
error
(
"select stateCount(tbinary,23,4.923230000) from statef2"
)
tdSql
.
query
(
"select stateCount(dtiny,le,1e3) from statef2"
)
tdSql
.
error
(
"select stateCount(dtiny,le,1e3) from statef"
)
tdSql
.
error
(
"select stateDuration(dtiny,le,1e3) from statef"
)
tdSql
.
query
(
"select stateDuration(dtiny,le,1e3) from statef2"
)
tdSql
.
error
(
"select stateCount(dtiny,le,'1e3') from statef2"
)
tdSql
.
error
(
"select stateCount(dtiny,le,le) from statef2"
)
tdSql
.
error
(
"select stateDuration(dtiny,le,le) from statef2"
)
tdSql
.
error
(
"select stateCount(dtiny,le,2,1s) from statef2"
)
tdSql
.
error
(
"select stateDuration(dtiny,le,2,1) from statef2"
)
tdSql
.
error
(
"select stateDuration(dtiny,le,2,'1s') from statef2"
)
tdSql
.
error
(
"select stateDuration(dtiny,le,2,2s) from statef2"
)
tdSql
.
error
(
"select stateCount(dtiny,le,1e3),top(dtiny,1) from statef2"
)
tdSql
.
error
(
"select stateCount(dtiny,le,1e3),first(dbig) from statef2"
)
tdSql
.
error
(
"select stateCount(dtiny,le,1e3),ceil(dsmall) from statef2"
)
#interval
tdSql
.
error
(
'select stateCount(dtiny,ne,9.0) from statef2 interval(1s)'
)
tdSql
.
error
(
'select stateDuration(dtiny,ne,9.0,1s) from statef2 interval(1s)'
)
#state_window
tdSql
.
error
(
'select stateCount(dtiny,ne,9.0) from statef2 state_window(dbool)'
)
tdSql
.
error
(
'select stateDuration(dtiny,ne,9.0,1s) from statef2 state_window(dbool)'
)
#session
tdSql
.
error
(
'select stateCount(dtiny,ne,9.0) from statef2 session(ts,1w)'
)
tdSql
.
error
(
'select stateDuration(dtiny,ne,9.0,1s) from statef2 session(ts,1w)'
)
tdSql
.
error
(
'select stateDuration(dfloat,Ge,3.32323) from (select dfloat from statef2)'
)
tdSql
.
error
(
'select stateCount(dfloat,Ge,3.32323) from (select dfloat from statef2)'
)
## test normal table
tdSql
.
query
(
'select stateCount(dtiny,GT,10) from statef2'
)
tdSql
.
checkRows
(
6
)
tdSql
.
checkData
(
0
,
0
,
"2021-10-15 00:31:33"
)
tdSql
.
checkData
(
0
,
1
,
23
)
tdSql
.
checkData
(
0
,
2
,
1
)
tdSql
.
checkData
(
1
,
0
,
"2021-10-17 00:31:31"
)
tdSql
.
checkData
(
1
,
1
,
123
)
tdSql
.
checkData
(
1
,
2
,
2
)
tdSql
.
checkData
(
2
,
0
,
"2021-12-24 00:31:34"
)
tdSql
.
checkData
(
2
,
1
,
None
)
tdSql
.
checkData
(
2
,
2
,
None
)
tdSql
.
checkData
(
3
,
0
,
"2022-01-01 08:00:05"
)
tdSql
.
checkData
(
3
,
1
,
2
)
tdSql
.
checkData
(
3
,
2
,
-
1
)
tdSql
.
checkData
(
4
,
0
,
"2022-01-01 08:00:06"
)
tdSql
.
checkData
(
4
,
1
,
35
)
tdSql
.
checkData
(
4
,
2
,
1
)
tdSql
.
checkData
(
5
,
0
,
"2022-01-01 08:00:07"
)
tdSql
.
checkData
(
5
,
1
,
25
)
tdSql
.
checkData
(
5
,
2
,
2
)
tdSql
.
query
(
'select dtiny,ts,stateCount(dtiny,GT,10),*,tbinary from statef2'
)
tdSql
.
checkRows
(
6
)
tdSql
.
checkData
(
0
,
1
,
"2021-10-15 00:31:33"
)
tdSql
.
checkData
(
1
,
2
,
123
)
tdSql
.
checkData
(
2
,
6
,
2
)
tdSql
.
checkData
(
3
,
15
,
"t2"
)
tdSql
.
query
(
'select stateCount(dtiny,LT,10) from statef2'
)
tdSql
.
checkRows
(
6
)
tdSql
.
checkData
(
0
,
2
,
-
1
)
tdSql
.
checkData
(
1
,
2
,
-
1
)
tdSql
.
checkData
(
3
,
2
,
1
)
tdSql
.
checkData
(
4
,
2
,
-
1
)
tdSql
.
query
(
'select stateCount(ddouble,LE,4.923230000) from statef2'
)
tdSql
.
checkRows
(
6
)
tdSql
.
checkData
(
0
,
2
,
-
1
)
tdSql
.
checkData
(
1
,
2
,
1
)
tdSql
.
checkData
(
2
,
2
,
-
1
)
tdSql
.
checkData
(
3
,
2
,
1
)
tdSql
.
checkData
(
4
,
2
,
None
)
tdSql
.
checkData
(
5
,
2
,
None
)
tdSql
.
query
(
'select stateCount(dfloat,Ge,3.32323) from statef2'
)
tdSql
.
checkRows
(
6
)
tdSql
.
checkData
(
0
,
2
,
1
)
tdSql
.
checkData
(
1
,
2
,
2
)
tdSql
.
checkData
(
2
,
2
,
None
)
tdSql
.
checkData
(
3
,
2
,
-
1
)
tdSql
.
checkData
(
4
,
2
,
1
)
tdSql
.
checkData
(
5
,
2
,
2
)
tdSql
.
query
(
'select stateCount(dsmall,eq,3276.0) from statef2'
)
tdSql
.
checkRows
(
6
)
tdSql
.
checkData
(
0
,
2
,
None
)
tdSql
.
checkData
(
1
,
2
,
-
1
)
tdSql
.
checkData
(
2
,
2
,
-
1
)
tdSql
.
checkData
(
3
,
2
,
1
)
tdSql
.
checkData
(
4
,
2
,
None
)
tdSql
.
checkData
(
5
,
2
,
-
1
)
tdSql
.
query
(
'select stateCount(dbig,ne,9.0) from statef2'
)
tdSql
.
checkRows
(
6
)
tdSql
.
checkData
(
0
,
2
,
1
)
tdSql
.
checkData
(
1
,
2
,
None
)
tdSql
.
checkData
(
2
,
2
,
2
)
tdSql
.
checkData
(
3
,
2
,
3
)
tdSql
.
checkData
(
4
,
2
,
None
)
tdSql
.
checkData
(
5
,
2
,
-
1
)
tdSql
.
query
(
'select stateDuration(dtiny,ne,9.0) from statef2'
)
tdSql
.
checkRows
(
6
)
tdSql
.
checkData
(
0
,
2
,
0
)
tdSql
.
checkData
(
1
,
2
,
172798
)
tdSql
.
checkData
(
2
,
2
,
None
)
tdSql
.
checkData
(
3
,
2
,
6766112
)
tdSql
.
checkData
(
4
,
2
,
6766113
)
tdSql
.
checkData
(
5
,
2
,
6766114
)
tdSql
.
query
(
'select stateDuration(dtiny,ne,9.0,1h) from statef2'
)
tdSql
.
checkRows
(
6
)
tdSql
.
checkData
(
0
,
2
,
0
)
tdSql
.
checkData
(
1
,
2
,
47
)
tdSql
.
checkData
(
2
,
2
,
None
)
tdSql
.
checkData
(
3
,
2
,
1879
)
tdSql
.
checkData
(
4
,
2
,
1879
)
tdSql
.
checkData
(
5
,
2
,
1879
)
tdSql
.
query
(
'select stateDuration(dtiny,ne,9.0,1m) from statef2'
)
tdSql
.
checkRows
(
6
)
tdSql
.
checkData
(
0
,
2
,
0
)
tdSql
.
checkData
(
1
,
2
,
2879
)
tdSql
.
checkData
(
2
,
2
,
None
)
tdSql
.
checkData
(
3
,
2
,
112768
)
tdSql
.
checkData
(
4
,
2
,
112768
)
tdSql
.
checkData
(
5
,
2
,
112768
)
## test super table
tdSql
.
query
(
'select stateDuration(dtiny,ne,9.0,1s) from sstatef group by tbname'
)
tdSql
.
checkRows
(
8
)
tdSql
.
checkData
(
0
,
2
,
0
)
tdSql
.
checkData
(
1
,
2
,
8553601
)
#where
tdSql
.
query
(
'select stateCount(dfloat,Ge,3.32323) from statef2 where dfloat >3.32323'
)
tdSql
.
checkRows
(
4
)
tdSql
.
checkData
(
0
,
2
,
1
)
tdSql
.
checkData
(
1
,
2
,
2
)
tdSql
.
checkData
(
2
,
2
,
3
)
tdSql
.
checkData
(
3
,
2
,
4
)
tdSql
.
query
(
'select stateDuration(dfloat,Ge,3.32323) from statef2 where dfloat <3.4'
)
tdSql
.
checkRows
(
4
)
tdSql
.
checkData
(
0
,
2
,
0
)
tdSql
.
checkData
(
1
,
2
,
-
1
)
tdSql
.
checkData
(
2
,
2
,
0
)
tdSql
.
checkData
(
3
,
2
,
1
)
tdSql
.
query
(
'select stateDuration(dfloat,Ge,3.32323,1m) from statef2 where dfloat <3.4'
)
tdSql
.
checkRows
(
4
)
tdSql
.
checkData
(
3
,
2
,
0
)
#slimit/soffset
tdSql
.
query
(
'select stateDuration(dtiny,ne,9.0,1s) from sstatef group by tbname slimit 2 soffset 1'
)
tdSql
.
checkRows
(
6
)
#limit/offset
tdSql
.
query
(
'select stateCount(dfloat,Ge,3.32323) from statef2 limit 1,2'
)
tdSql
.
checkRows
(
2
)
tdSql
.
checkData
(
0
,
0
,
"2021-10-17 00:31:31"
)
tdSql
.
checkData
(
0
,
2
,
2
)
tdSql
.
checkData
(
1
,
2
,
None
)
#having
tdSql
.
query
(
'select stateDuration(dtiny,ne,9.0,1s) from sstatef group by tbname having stateDuration(dtiny,ne,9.0,1s) > 0'
)
#subquery
tdSql
.
query
(
'select stateDuration(dfloat,Ge,3.32323) from (select ts,dfloat from statef2)'
)
tdSql
.
checkRows
(
6
)
tdSql
.
checkData
(
0
,
2
,
0
)
tdSql
.
checkData
(
1
,
2
,
172798
)
tdSql
.
checkData
(
2
,
2
,
None
)
tdSql
.
checkData
(
3
,
2
,
-
1
)
#union
tdSql
.
query
(
'select stateCount(dfloat,Ge,3.32323) from statef1 union all select stateCount(dfloat,Ge,3.32323) from statef2'
)
tdSql
.
checkRows
(
8
)
tdSql
.
checkData
(
0
,
2
,
1
)
tdSql
.
checkData
(
3
,
2
,
2
)
#join
tdSql
.
execute
(
'create table sstatef1 (ts timestamp, dbig bigint, dsmall smallint, dbool bool, dtiny tinyint unsigned, dfloat float, ddouble double, dnchar nchar(4093), dbinary binary(64), dtime timestamp) tags (tbinary nchar(4093), tint int)'
)
tdSql
.
execute
(
'create table statef11 using sstatef1 tags ("t1", 1)'
)
tdSql
.
execute
(
'insert into statef11 values("2021-10-17 00:31:31", 1, -3276, true, 253, 3.32333, 4.984392323, "你好", "sddd", 333) ("2022-01-24 00:31:32", 1, -32767, false, 254, NULL, 4.982392323, "你好吗", "sdf",2323)'
)
tdSql
.
error
(
'select stateCount(sstatef.dsmall,eq,3276.0) from sstatef, sstatef1 where sstatef.ts=sstatef1.ts and sstatef.tint=sstatef1.tint'
)
def
stop
(
self
):
tdSql
.
close
()
tdLog
.
success
(
"%s successfully executed"
%
__file__
)
tdCases
.
addWindows
(
__file__
,
TDTestCase
())
tdCases
.
addLinux
(
__file__
,
TDTestCase
())
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录