Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
86505d97
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
86505d97
编写于
7月 02, 2022
作者:
G
Ganlin Zhao
提交者:
GitHub
7月 02, 2022
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #14434 from taosdata/fix/TD-15257
fix(quer): fix time unit parameter check
上级
06514e13
7a588bd1
变更
8
展开全部
隐藏空白更改
内联
并排
Showing
8 changed file
with
426 addition
and
366 deletion
+426
-366
source/libs/function/src/builtins.c
source/libs/function/src/builtins.c
+210
-147
tests/system-test/2-query/Timediff.py
tests/system-test/2-query/Timediff.py
+21
-21
tests/system-test/2-query/elapsed.py
tests/system-test/2-query/elapsed.py
+105
-106
tests/system-test/2-query/function_stateduration.py
tests/system-test/2-query/function_stateduration.py
+33
-34
tests/system-test/2-query/json_tag.py
tests/system-test/2-query/json_tag.py
+1
-1
tests/system-test/2-query/statecount.py
tests/system-test/2-query/statecount.py
+43
-44
tests/system-test/2-query/timetruncate.py
tests/system-test/2-query/timetruncate.py
+12
-12
tests/system-test/fulltest.sh
tests/system-test/fulltest.sh
+1
-1
未找到文件。
source/libs/function/src/builtins.c
浏览文件 @
86505d97
...
...
@@ -39,6 +39,174 @@ static int32_t invaildFuncParaValueErrMsg(char* pErrBuf, int32_t len, const char
return
buildFuncErrMsg
(
pErrBuf
,
len
,
TSDB_CODE_FUNC_FUNTION_PARA_VALUE
,
"Invalid parameter value : %s"
,
pFuncName
);
}
#define TIME_UNIT_INVALID 1
#define TIME_UNIT_TOO_SMALL 2
static
int32_t
validateTimeUnitParam
(
uint8_t
dbPrec
,
const
SValueNode
*
pVal
)
{
if
(
!
pVal
->
isDuration
)
{
return
TIME_UNIT_INVALID
;
}
if
(
TSDB_TIME_PRECISION_MILLI
==
dbPrec
&&
0
==
strcasecmp
(
pVal
->
literal
,
"1u"
))
{
return
TIME_UNIT_TOO_SMALL
;
}
if
(
pVal
->
literal
[
0
]
!=
'1'
||
(
pVal
->
literal
[
1
]
!=
'u'
&&
pVal
->
literal
[
1
]
!=
'a'
&&
pVal
->
literal
[
1
]
!=
's'
&&
pVal
->
literal
[
1
]
!=
'm'
&&
pVal
->
literal
[
1
]
!=
'h'
&&
pVal
->
literal
[
1
]
!=
'd'
&&
pVal
->
literal
[
1
]
!=
'w'
))
{
return
TIME_UNIT_INVALID
;
}
return
TSDB_CODE_SUCCESS
;
}
/* Following are valid ISO-8601 timezone format:
* 1 z/Z
* 2 ±hh:mm
* 3 ±hhmm
* 4 ±hh
*
*/
static
bool
validateHourRange
(
int8_t
hour
)
{
if
(
hour
<
0
||
hour
>
12
)
{
return
false
;
}
return
true
;
}
static
bool
validateMinuteRange
(
int8_t
hour
,
int8_t
minute
,
char
sign
)
{
if
(
minute
==
0
||
(
minute
==
30
&&
(
hour
==
3
||
hour
==
5
)
&&
sign
==
'+'
))
{
return
true
;
}
return
false
;
}
static
bool
validateTimestampDigits
(
const
SValueNode
*
pVal
)
{
if
(
!
IS_INTEGER_TYPE
(
pVal
->
node
.
resType
.
type
))
{
return
false
;
}
int64_t
tsVal
=
pVal
->
datum
.
i
;
char
fraction
[
20
]
=
{
0
};
NUM_TO_STRING
(
pVal
->
node
.
resType
.
type
,
&
tsVal
,
sizeof
(
fraction
),
fraction
);
int32_t
tsDigits
=
(
int32_t
)
strlen
(
fraction
);
if
(
tsDigits
>
TSDB_TIME_PRECISION_SEC_DIGITS
)
{
if
(
tsDigits
==
TSDB_TIME_PRECISION_MILLI_DIGITS
||
tsDigits
==
TSDB_TIME_PRECISION_MICRO_DIGITS
||
tsDigits
==
TSDB_TIME_PRECISION_NANO_DIGITS
)
{
return
true
;
}
else
{
return
false
;
}
}
return
true
;
}
static
bool
validateTimezoneFormat
(
const
SValueNode
*
pVal
)
{
if
(
TSDB_DATA_TYPE_BINARY
!=
pVal
->
node
.
resType
.
type
)
{
return
false
;
}
char
*
tz
=
varDataVal
(
pVal
->
datum
.
p
);
int32_t
len
=
varDataLen
(
pVal
->
datum
.
p
);
char
buf
[
3
]
=
{
0
};
int8_t
hour
=
-
1
,
minute
=
-
1
;
if
(
len
==
0
)
{
return
false
;
}
else
if
(
len
==
1
&&
(
tz
[
0
]
==
'z'
||
tz
[
0
]
==
'Z'
))
{
return
true
;
}
else
if
((
tz
[
0
]
==
'+'
||
tz
[
0
]
==
'-'
))
{
switch
(
len
)
{
case
3
:
case
5
:
{
for
(
int32_t
i
=
1
;
i
<
len
;
++
i
)
{
if
(
!
isdigit
(
tz
[
i
]))
{
return
false
;
}
if
(
i
==
2
)
{
memcpy
(
buf
,
&
tz
[
i
-
1
],
2
);
hour
=
taosStr2Int8
(
buf
,
NULL
,
10
);
if
(
!
validateHourRange
(
hour
))
{
return
false
;
}
}
else
if
(
i
==
4
)
{
memcpy
(
buf
,
&
tz
[
i
-
1
],
2
);
minute
=
taosStr2Int8
(
buf
,
NULL
,
10
);
if
(
!
validateMinuteRange
(
hour
,
minute
,
tz
[
0
]))
{
return
false
;
}
}
}
break
;
}
case
6
:
{
for
(
int32_t
i
=
1
;
i
<
len
;
++
i
)
{
if
(
i
==
3
)
{
if
(
tz
[
i
]
!=
':'
)
{
return
false
;
}
continue
;
}
if
(
!
isdigit
(
tz
[
i
]))
{
return
false
;
}
if
(
i
==
2
)
{
memcpy
(
buf
,
&
tz
[
i
-
1
],
2
);
hour
=
taosStr2Int8
(
buf
,
NULL
,
10
);
if
(
!
validateHourRange
(
hour
))
{
return
false
;
}
}
else
if
(
i
==
5
)
{
memcpy
(
buf
,
&
tz
[
i
-
1
],
2
);
minute
=
taosStr2Int8
(
buf
,
NULL
,
10
);
if
(
!
validateMinuteRange
(
hour
,
minute
,
tz
[
0
]))
{
return
false
;
}
}
}
break
;
}
default:
{
return
false
;
}
}
}
else
{
return
false
;
}
return
true
;
}
void
static
addTimezoneParam
(
SNodeList
*
pList
)
{
char
buf
[
6
]
=
{
0
};
time_t
t
=
taosTime
(
NULL
);
struct
tm
*
tmInfo
=
taosLocalTime
(
&
t
,
NULL
);
strftime
(
buf
,
sizeof
(
buf
),
"%z"
,
tmInfo
);
int32_t
len
=
(
int32_t
)
strlen
(
buf
);
SValueNode
*
pVal
=
(
SValueNode
*
)
nodesMakeNode
(
QUERY_NODE_VALUE
);
pVal
->
literal
=
strndup
(
buf
,
len
);
pVal
->
isDuration
=
false
;
pVal
->
translate
=
true
;
pVal
->
node
.
resType
.
type
=
TSDB_DATA_TYPE_BINARY
;
pVal
->
node
.
resType
.
bytes
=
len
+
VARSTR_HEADER_SIZE
;
pVal
->
node
.
resType
.
precision
=
TSDB_TIME_PRECISION_MILLI
;
pVal
->
datum
.
p
=
taosMemoryCalloc
(
1
,
len
+
VARSTR_HEADER_SIZE
+
1
);
varDataSetLen
(
pVal
->
datum
.
p
,
len
);
strncpy
(
varDataVal
(
pVal
->
datum
.
p
),
pVal
->
literal
,
len
);
nodesListAppend
(
pList
,
(
SNode
*
)
pVal
);
}
void
static
addDbPrecisonParam
(
SNodeList
**
pList
,
uint8_t
precision
)
{
SValueNode
*
pVal
=
(
SValueNode
*
)
nodesMakeNode
(
QUERY_NODE_VALUE
);
pVal
->
literal
=
NULL
;
...
...
@@ -525,9 +693,15 @@ static int32_t translateElapsed(SFunctionNode* pFunc, char* pErrBuf, int32_t len
return
invaildFuncParaTypeErrMsg
(
pErrBuf
,
len
,
pFunc
->
functionName
);
}
if
(
pValue
->
datum
.
i
==
0
)
{
uint8_t
dbPrec
=
pFunc
->
node
.
resType
.
precision
;
int32_t
ret
=
validateTimeUnitParam
(
dbPrec
,
(
SValueNode
*
)
nodesListGetNode
(
pFunc
->
pParameterList
,
1
));
if
(
ret
==
TIME_UNIT_TOO_SMALL
)
{
return
buildFuncErrMsg
(
pErrBuf
,
len
,
TSDB_CODE_FUNC_FUNTION_ERROR
,
"ELAPSED function time unit parameter should be greater than db precision"
);
}
else
if
(
ret
==
TIME_UNIT_INVALID
)
{
return
buildFuncErrMsg
(
pErrBuf
,
len
,
TSDB_CODE_FUNC_FUNTION_ERROR
,
"ELAPSED function time unit parameter should be one of the following: [1u, 1a, 1s, 1m, 1h, 1d, 1w]"
);
}
}
...
...
@@ -843,6 +1017,19 @@ static int32_t translateStateDuration(SFunctionNode* pFunc, char* pErrBuf, int32
return
invaildFuncParaTypeErrMsg
(
pErrBuf
,
len
,
pFunc
->
functionName
);
}
if
(
numOfParams
==
4
)
{
uint8_t
dbPrec
=
pFunc
->
node
.
resType
.
precision
;
int32_t
ret
=
validateTimeUnitParam
(
dbPrec
,
(
SValueNode
*
)
nodesListGetNode
(
pFunc
->
pParameterList
,
3
));
if
(
ret
==
TIME_UNIT_TOO_SMALL
)
{
return
buildFuncErrMsg
(
pErrBuf
,
len
,
TSDB_CODE_FUNC_FUNTION_ERROR
,
"STATEDURATION function time unit parameter should be greater than db precision"
);
}
else
if
(
ret
==
TIME_UNIT_INVALID
)
{
return
buildFuncErrMsg
(
pErrBuf
,
len
,
TSDB_CODE_FUNC_FUNTION_ERROR
,
"STATEDURATION function time unit parameter should be one of the following: [1u, 1a, 1s, 1m, 1h, 1d, 1w]"
);
}
}
// set result type
pFunc
->
node
.
resType
=
(
SDataType
){.
bytes
=
tDataTypes
[
TSDB_DATA_TYPE_BIGINT
].
bytes
,
.
type
=
TSDB_DATA_TYPE_BIGINT
};
return
TSDB_CODE_SUCCESS
;
...
...
@@ -1284,152 +1471,6 @@ static int32_t translateCast(SFunctionNode* pFunc, char* pErrBuf, int32_t len) {
return
TSDB_CODE_SUCCESS
;
}
/* Following are valid ISO-8601 timezone format:
* 1 z/Z
* 2 ±hh:mm
* 3 ±hhmm
* 4 ±hh
*
*/
static
bool
validateHourRange
(
int8_t
hour
)
{
if
(
hour
<
0
||
hour
>
12
)
{
return
false
;
}
return
true
;
}
static
bool
validateMinuteRange
(
int8_t
hour
,
int8_t
minute
,
char
sign
)
{
if
(
minute
==
0
||
(
minute
==
30
&&
(
hour
==
3
||
hour
==
5
)
&&
sign
==
'+'
))
{
return
true
;
}
return
false
;
}
static
bool
validateTimestampDigits
(
const
SValueNode
*
pVal
)
{
if
(
!
IS_INTEGER_TYPE
(
pVal
->
node
.
resType
.
type
))
{
return
false
;
}
int64_t
tsVal
=
pVal
->
datum
.
i
;
char
fraction
[
20
]
=
{
0
};
NUM_TO_STRING
(
pVal
->
node
.
resType
.
type
,
&
tsVal
,
sizeof
(
fraction
),
fraction
);
int32_t
tsDigits
=
(
int32_t
)
strlen
(
fraction
);
if
(
tsDigits
>
TSDB_TIME_PRECISION_SEC_DIGITS
)
{
if
(
tsDigits
==
TSDB_TIME_PRECISION_MILLI_DIGITS
||
tsDigits
==
TSDB_TIME_PRECISION_MICRO_DIGITS
||
tsDigits
==
TSDB_TIME_PRECISION_NANO_DIGITS
)
{
return
true
;
}
else
{
return
false
;
}
}
return
true
;
}
static
bool
validateTimezoneFormat
(
const
SValueNode
*
pVal
)
{
if
(
TSDB_DATA_TYPE_BINARY
!=
pVal
->
node
.
resType
.
type
)
{
return
false
;
}
char
*
tz
=
varDataVal
(
pVal
->
datum
.
p
);
int32_t
len
=
varDataLen
(
pVal
->
datum
.
p
);
char
buf
[
3
]
=
{
0
};
int8_t
hour
=
-
1
,
minute
=
-
1
;
if
(
len
==
0
)
{
return
false
;
}
else
if
(
len
==
1
&&
(
tz
[
0
]
==
'z'
||
tz
[
0
]
==
'Z'
))
{
return
true
;
}
else
if
((
tz
[
0
]
==
'+'
||
tz
[
0
]
==
'-'
))
{
switch
(
len
)
{
case
3
:
case
5
:
{
for
(
int32_t
i
=
1
;
i
<
len
;
++
i
)
{
if
(
!
isdigit
(
tz
[
i
]))
{
return
false
;
}
if
(
i
==
2
)
{
memcpy
(
buf
,
&
tz
[
i
-
1
],
2
);
hour
=
taosStr2Int8
(
buf
,
NULL
,
10
);
if
(
!
validateHourRange
(
hour
))
{
return
false
;
}
}
else
if
(
i
==
4
)
{
memcpy
(
buf
,
&
tz
[
i
-
1
],
2
);
minute
=
taosStr2Int8
(
buf
,
NULL
,
10
);
if
(
!
validateMinuteRange
(
hour
,
minute
,
tz
[
0
]))
{
return
false
;
}
}
}
break
;
}
case
6
:
{
for
(
int32_t
i
=
1
;
i
<
len
;
++
i
)
{
if
(
i
==
3
)
{
if
(
tz
[
i
]
!=
':'
)
{
return
false
;
}
continue
;
}
if
(
!
isdigit
(
tz
[
i
]))
{
return
false
;
}
if
(
i
==
2
)
{
memcpy
(
buf
,
&
tz
[
i
-
1
],
2
);
hour
=
taosStr2Int8
(
buf
,
NULL
,
10
);
if
(
!
validateHourRange
(
hour
))
{
return
false
;
}
}
else
if
(
i
==
5
)
{
memcpy
(
buf
,
&
tz
[
i
-
1
],
2
);
minute
=
taosStr2Int8
(
buf
,
NULL
,
10
);
if
(
!
validateMinuteRange
(
hour
,
minute
,
tz
[
0
]))
{
return
false
;
}
}
}
break
;
}
default:
{
return
false
;
}
}
}
else
{
return
false
;
}
return
true
;
}
void
static
addTimezoneParam
(
SNodeList
*
pList
)
{
char
buf
[
6
]
=
{
0
};
time_t
t
=
taosTime
(
NULL
);
struct
tm
*
tmInfo
=
taosLocalTime
(
&
t
,
NULL
);
strftime
(
buf
,
sizeof
(
buf
),
"%z"
,
tmInfo
);
int32_t
len
=
(
int32_t
)
strlen
(
buf
);
SValueNode
*
pVal
=
(
SValueNode
*
)
nodesMakeNode
(
QUERY_NODE_VALUE
);
pVal
->
literal
=
strndup
(
buf
,
len
);
pVal
->
isDuration
=
false
;
pVal
->
translate
=
true
;
pVal
->
node
.
resType
.
type
=
TSDB_DATA_TYPE_BINARY
;
pVal
->
node
.
resType
.
bytes
=
len
+
VARSTR_HEADER_SIZE
;
pVal
->
node
.
resType
.
precision
=
TSDB_TIME_PRECISION_MILLI
;
pVal
->
datum
.
p
=
taosMemoryCalloc
(
1
,
len
+
VARSTR_HEADER_SIZE
+
1
);
varDataSetLen
(
pVal
->
datum
.
p
,
len
);
strncpy
(
varDataVal
(
pVal
->
datum
.
p
),
pVal
->
literal
,
len
);
nodesListAppend
(
pList
,
(
SNode
*
)
pVal
);
}
static
int32_t
translateToIso8601
(
SFunctionNode
*
pFunc
,
char
*
pErrBuf
,
int32_t
len
)
{
int32_t
numOfParams
=
LIST_LENGTH
(
pFunc
->
pParameterList
);
if
(
1
!=
numOfParams
&&
2
!=
numOfParams
)
{
...
...
@@ -1498,6 +1539,16 @@ static int32_t translateTimeTruncate(SFunctionNode* pFunc, char* pErrBuf, int32_
// add database precision as param
uint8_t
dbPrec
=
pFunc
->
node
.
resType
.
precision
;
int32_t
ret
=
validateTimeUnitParam
(
dbPrec
,
(
SValueNode
*
)
nodesListGetNode
(
pFunc
->
pParameterList
,
1
));
if
(
ret
==
TIME_UNIT_TOO_SMALL
)
{
return
buildFuncErrMsg
(
pErrBuf
,
len
,
TSDB_CODE_FUNC_FUNTION_ERROR
,
"TIMETRUNCATE function time unit parameter should be greater than db precision"
);
}
else
if
(
ret
==
TIME_UNIT_INVALID
)
{
return
buildFuncErrMsg
(
pErrBuf
,
len
,
TSDB_CODE_FUNC_FUNTION_ERROR
,
"TIMETRUNCATE function time unit parameter should be one of the following: [1u, 1a, 1s, 1m, 1h, 1d, 1w]"
);
}
addDbPrecisonParam
(
&
pFunc
->
pParameterList
,
dbPrec
);
pFunc
->
node
.
resType
=
...
...
@@ -1526,6 +1577,18 @@ static int32_t translateTimeDiff(SFunctionNode* pFunc, char* pErrBuf, int32_t le
// add database precision as param
uint8_t
dbPrec
=
pFunc
->
node
.
resType
.
precision
;
if
(
3
==
numOfParams
)
{
int32_t
ret
=
validateTimeUnitParam
(
dbPrec
,
(
SValueNode
*
)
nodesListGetNode
(
pFunc
->
pParameterList
,
2
));
if
(
ret
==
TIME_UNIT_TOO_SMALL
)
{
return
buildFuncErrMsg
(
pErrBuf
,
len
,
TSDB_CODE_FUNC_FUNTION_ERROR
,
"TIMEDIFF function time unit parameter should be greater than db precision"
);
}
else
if
(
ret
==
TIME_UNIT_INVALID
)
{
return
buildFuncErrMsg
(
pErrBuf
,
len
,
TSDB_CODE_FUNC_FUNTION_ERROR
,
"TIMEDIFF function time unit parameter should be one of the following: [1u, 1a, 1s, 1m, 1h, 1d, 1w]"
);
}
}
addDbPrecisonParam
(
&
pFunc
->
pParameterList
,
dbPrec
);
pFunc
->
node
.
resType
=
(
SDataType
){.
bytes
=
tDataTypes
[
TSDB_DATA_TYPE_BIGINT
].
bytes
,
.
type
=
TSDB_DATA_TYPE_BIGINT
};
...
...
tests/system-test/2-query/Timediff.py
浏览文件 @
86505d97
...
...
@@ -3,7 +3,7 @@ from util.sql import *
from
util.cases
import
*
class
TDTestCase
:
def
init
(
self
,
conn
,
logSql
):
tdLog
.
debug
(
f
"start to excute
{
__file__
}
"
)
tdSql
.
init
(
conn
.
cursor
())
...
...
@@ -33,7 +33,7 @@ class TDTestCase:
'insert into ntb values(now,1,1.55,100.555555,today())("2020-1-1 00:00:00",10,11.11,99.999999,now())(today(),3,3.333,333.333333,now())'
)
tdSql
.
execute
(
'insert into stb_1 values(now,1,1.55,100.555555,today())("2020-1-1 00:00:00",10,11.11,99.999999,now())(today(),3,3.333,333.333333,now())'
)
tdSql
.
query
(
"select timediff('2020-1-1 00:00:00','2020-1-2 00:00:00') from ntb"
)
tdSql
.
checkRows
(
3
)
tdSql
.
query
(
"select timediff(1,0,1d) from ntb"
)
...
...
@@ -72,12 +72,12 @@ class TDTestCase:
tdSql
.
query
(
"select timediff(1,0,1a) from db.ntb"
)
tdSql
.
checkRows
(
3
)
tdSql
.
checkData
(
0
,
0
,
1000
)
tdSql
.
query
(
"select timediff(1,0,1u) from ntb"
)
tdSql
.
checkRows
(
3
)
tdSql
.
checkData
(
0
,
0
,
1000000
)
tdSql
.
query
(
"select timediff(1,0,1u) from db.ntb"
)
tdSql
.
checkRows
(
3
)
tdSql
.
checkData
(
0
,
0
,
1000000
)
tdSql
.
error
(
"select timediff(1,0,1u) from ntb"
)
#
tdSql.checkRows(3)
#
tdSql.checkData(0,0,1000000)
tdSql
.
error
(
"select timediff(1,0,1u) from db.ntb"
)
#
tdSql.checkRows(3)
#
tdSql.checkData(0,0,1000000)
tdSql
.
query
(
"select timediff('2020-1-1 00:00:00','2020-1-2 00:00:00') from stb"
)
tdSql
.
checkRows
(
3
)
...
...
@@ -116,12 +116,12 @@ class TDTestCase:
tdSql
.
query
(
"select timediff('2020-1-1 00:00:00','2020-1-2 00:00:00',1a) from db.stb"
)
tdSql
.
checkRows
(
3
)
tdSql
.
checkData
(
0
,
0
,
86400000
)
tdSql
.
query
(
"select timediff('2020-1-1 00:00:00','2020-1-2 00:00:00',1u) from stb"
)
tdSql
.
checkRows
(
3
)
tdSql
.
checkData
(
0
,
0
,
86400000000
)
tdSql
.
query
(
"select timediff('2020-1-1 00:00:00','2020-1-2 00:00:00',1u) from db.stb"
)
tdSql
.
checkRows
(
3
)
tdSql
.
checkData
(
0
,
0
,
86400000000
)
tdSql
.
error
(
"select timediff('2020-1-1 00:00:00','2020-1-2 00:00:00',1u) from stb"
)
#
tdSql.checkRows(3)
#
tdSql.checkData(0,0,86400000000)
tdSql
.
error
(
"select timediff('2020-1-1 00:00:00','2020-1-2 00:00:00',1u) from db.stb"
)
#
tdSql.checkRows(3)
#
tdSql.checkData(0,0,86400000000)
tdSql
.
query
(
"select timediff('2020-1-1 00:00:00','2020-1-1 12:00:00') from stb_1"
)
...
...
@@ -164,12 +164,12 @@ class TDTestCase:
tdSql
.
query
(
"select timediff('2020-1-1 00:00:00','2020-1-1 12:00:00',1a) from db.stb_1"
)
tdSql
.
checkRows
(
3
)
tdSql
.
checkData
(
0
,
0
,
43200000
)
tdSql
.
query
(
"select timediff('2020-1-1 00:00:00','2020-1-1 12:00:00',1u) from stb_1"
)
tdSql
.
checkRows
(
3
)
tdSql
.
checkData
(
0
,
0
,
43200000000
)
tdSql
.
query
(
"select timediff('2020-1-1 00:00:00','2020-1-1 12:00:00',1u) from db.stb_1"
)
tdSql
.
checkRows
(
3
)
tdSql
.
checkData
(
0
,
0
,
43200000000
)
tdSql
.
error
(
"select timediff('2020-1-1 00:00:00','2020-1-1 12:00:00',1u) from stb_1"
)
#
tdSql.checkRows(3)
#
tdSql.checkData(0,0,43200000000)
tdSql
.
error
(
"select timediff('2020-1-1 00:00:00','2020-1-1 12:00:00',1u) from db.stb_1"
)
#
tdSql.checkRows(3)
#
tdSql.checkData(0,0,43200000000)
tdSql
.
query
(
"select timediff('a','b') from stb"
)
tdSql
.
checkRows
(
3
)
...
...
@@ -202,4 +202,4 @@ class TDTestCase:
tdLog
.
success
(
f
"
{
__file__
}
successfully executed"
)
tdCases
.
addLinux
(
__file__
,
TDTestCase
())
tdCases
.
addWindows
(
__file__
,
TDTestCase
())
\ No newline at end of file
tdCases
.
addWindows
(
__file__
,
TDTestCase
())
tests/system-test/2-query/elapsed.py
浏览文件 @
86505d97
此差异已折叠。
点击以展开。
tests/system-test/2-query/function_stateduration.py
浏览文件 @
86505d97
...
...
@@ -18,7 +18,7 @@ class TDTestCase:
def
init
(
self
,
conn
,
logSql
):
tdLog
.
debug
(
f
"start to excute
{
__file__
}
"
)
tdSql
.
init
(
conn
.
cursor
())
def
prepare_datas
(
self
):
tdSql
.
execute
(
'''create table stb1
...
...
@@ -26,7 +26,7 @@ class TDTestCase:
tags (t1 int)
'''
)
tdSql
.
execute
(
'''
create table t1
...
...
@@ -68,7 +68,7 @@ class TDTestCase:
( '2023-02-21 01:01:01.000', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
'''
)
def
test_errors
(
self
):
error_sql_lists
=
[
# "select stateduration(c1,'GT',5,1s) from t1"
...
...
@@ -110,35 +110,35 @@ class TDTestCase:
for
error_sql
in
error_sql_lists
:
tdSql
.
error
(
error_sql
)
pass
def
support_types
(
self
):
other_no_value_types
=
[
"select stateduration(ts,'GT',1,1s) from t1"
,
"select stateduration(ts,'GT',1,1s) from t1"
,
"select stateduration(c7,'GT',1,1s) from t1"
,
"select stateduration(c8,'GT',1,1s) from t1"
,
"select stateduration(c9,'GT',1,1s) from t1"
,
"select stateduration(ts,'GT',1,1s) from ct1"
,
"select stateduration(ts,'GT',1,1s) from ct1"
,
"select stateduration(c7,'GT',1,1s) from ct1"
,
"select stateduration(c8,'GT',1,1s) from ct1"
,
"select stateduration(c9,'GT',1,1s) from ct1"
,
"select stateduration(ts,'GT',1,1s) from ct3"
,
"select stateduration(ts,'GT',1,1s) from ct3"
,
"select stateduration(c7,'GT',1,1s) from ct3"
,
"select stateduration(c8,'GT',1,1s) from ct3"
,
"select stateduration(c9,'GT',1,1s) from ct3"
,
"select stateduration(ts,'GT',1,1s) from ct4"
,
"select stateduration(ts,'GT',1,1s) from ct4"
,
"select stateduration(c7,'GT',1,1s) from ct4"
,
"select stateduration(c8,'GT',1,1s) from ct4"
,
"select stateduration(c9,'GT',1,1s) from ct4"
,
"select stateduration(ts,'GT',1,1s) from stb1 partition by tbname"
,
"select stateduration(ts,'GT',1,1s) from stb1 partition by tbname"
,
"select stateduration(c7,'GT',1,1s) from stb1 partition by tbname"
,
"select stateduration(c8,'GT',1,1s) from stb1 partition by tbname"
,
"select stateduration(c9,'GT',1,1s) from stb1 partition by tbname"
"select stateduration(c9,'GT',1,1s) from stb1 partition by tbname"
]
for
type_sql
in
other_no_value_types
:
tdSql
.
error
(
type_sql
)
tdLog
.
info
(
"support type ok , sql is : %s"
%
type_sql
)
type_sql_lists
=
[
"select stateduration(c1,'GT',1,1s) from t1"
,
"select stateduration(c2,'GT',1,1s) from t1"
,
...
...
@@ -168,8 +168,8 @@ class TDTestCase:
"select stateduration(c5,'GT',1,1s) from stb1 partition by tbname"
,
"select stateduration(c6,'GT',1,1s) from stb1 partition by tbname"
,
"select stateduration(c6,'GT',1,1s) as alisb from stb1 partition by tbname"
,
"select stateduration(c6,'GT',1,1s) alisb from stb1 partition by tbname"
,
"select stateduration(c6,'GT',1,1s) as alisb from stb1 partition by tbname"
,
"select stateduration(c6,'GT',1,1s) alisb from stb1 partition by tbname"
,
]
for
type_sql
in
type_sql_lists
:
...
...
@@ -177,7 +177,7 @@ class TDTestCase:
def
support_opers
(
self
):
oper_lists
=
[
'LT'
,
'lt'
,
'Lt'
,
'lT'
,
'GT'
,
'gt'
,
'Gt'
,
'gT'
,
'LE'
,
'le'
,
'Le'
,
'lE'
,
'GE'
,
'ge'
,
'Ge'
,
'gE'
,
'NE'
,
'ne'
,
'Ne'
,
'nE'
,
'EQ'
,
'eq'
,
'Eq'
,
'eQ'
]
oper_errors
=
[
","
,
"*"
,
"NULL"
,
"tbname"
,
"ts"
,
"sum"
,
"_c0"
]
for
oper
in
oper_lists
:
...
...
@@ -190,7 +190,7 @@ class TDTestCase:
def
basic_stateduration_function
(
self
):
# basic query
# basic query
tdSql
.
query
(
"select c1 from ct3"
)
tdSql
.
checkRows
(
0
)
tdSql
.
query
(
"select c1 from t1"
)
...
...
@@ -211,9 +211,9 @@ class TDTestCase:
tdSql
.
checkRows
(
0
)
tdSql
.
query
(
"select stateduration(c6,'GT',1,1s) from ct3"
)
# will support _rowts mix with
# will support _rowts mix with
# tdSql.query("select (c6,'GT',1,1s),_rowts from ct3")
# auto check for t1 table
# used for regular table
tdSql
.
query
(
"select stateduration(c6,'GT',1,1s) from t1"
)
...
...
@@ -229,17 +229,17 @@ class TDTestCase:
tdSql
.
error
(
"select stateduration(c6,'GT',1,1s),tbname from ct1"
)
tdSql
.
error
(
"select stateduration(c6,'GT',1,1s),t1 from ct1"
)
# unique with common col
# unique with common col
tdSql
.
error
(
"select stateduration(c6,'GT',1,1s) ,ts from ct1"
)
tdSql
.
error
(
"select stateduration(c6,'GT',1,1s) ,c1 from ct1"
)
# unique with scalar function
# unique with scalar function
tdSql
.
error
(
"select stateduration(c6,'GT',1,1s) ,abs(c1) from ct1"
)
tdSql
.
error
(
"select stateduration(c6,'GT',1,1s) , unique(c2) from ct1"
)
tdSql
.
error
(
"select stateduration(c6,'GT',1,1s) , abs(c2)+2 from ct1"
)
# unique with aggregate function
# unique with aggregate function
tdSql
.
error
(
"select stateduration(c6,'GT',1,1s) ,sum(c1) from ct1"
)
tdSql
.
error
(
"select stateduration(c6,'GT',1,1s) ,max(c1) from ct1"
)
tdSql
.
error
(
"select stateduration(c6,'GT',1,1s) ,csum(c1) from ct1"
)
...
...
@@ -262,16 +262,16 @@ class TDTestCase:
tdSql
.
checkData
(
0
,
0
,
0
)
tdSql
.
checkData
(
1
,
0
,
6134400
)
tdSql
.
checkData
(
6
,
0
,
-
1
)
# unique with union all
# unique with union all
tdSql
.
query
(
"select stateduration(c1,'GT',1,1s) from ct4 union all select stateduration(c1,'GT',1,1s) from ct1"
)
tdSql
.
checkRows
(
25
)
tdSql
.
query
(
"select stateduration(c1,'GT',1,1s) from ct4 union all select distinct(c1) from ct4"
)
tdSql
.
checkRows
(
22
)
# unique with join
# prepare join datas with same ts
# unique with join
# prepare join datas with same ts
tdSql
.
execute
(
" use db "
)
tdSql
.
execute
(
" create stable st1 (ts timestamp , num int) tags(ind int)"
)
...
...
@@ -328,7 +328,7 @@ class TDTestCase:
tdSql
.
checkRows
(
12
)
tdSql
.
query
(
"select stateduration(c1+2 ,'GT',1,1s) from t1"
)
tdSql
.
checkRows
(
12
)
# bug for stable
#partition by tbname
...
...
@@ -337,21 +337,20 @@ class TDTestCase:
# tdSql.query(" select unique(c1) from stb1 partition by tbname ")
# tdSql.checkRows(21)
# group by
# group by
tdSql
.
error
(
"select stateduration(c1,'GT',1,1s) from ct1 group by c1"
)
tdSql
.
error
(
"select stateduration(c1,'GT',1,1s) from ct1 group by tbname"
)
# super table
def
check_unit_time
(
self
):
tdSql
.
execute
(
" use db "
)
tdSql
.
error
(
"select stateduration(c1,'GT',1,1b) from ct1"
)
tdSql
.
error
(
"select stateduration(c1,'GT',1,1u) from ct1"
)
tdSql
.
error
(
"select stateduration(c1,'GT',1,1000s) from t1"
)
tdSql
.
query
(
"select stateduration(c1,'GT',1,1s) from t1"
)
tdSql
.
checkData
(
10
,
0
,
63072035
)
tdSql
.
query
(
"select stateduration(c1,'GT',1,1000s) from t1"
)
tdSql
.
checkData
(
10
,
0
,
int
(
63072035
/
1000
))
tdSql
.
query
(
"select stateduration(c1,'GT',1,1m) from t1"
)
tdSql
.
checkData
(
10
,
0
,
int
(
63072035
/
60
))
tdSql
.
query
(
"select stateduration(c1,'GT',1,1h) from t1"
)
...
...
@@ -360,8 +359,8 @@ class TDTestCase:
tdSql
.
checkData
(
10
,
0
,
int
(
63072035
/
60
/
24
/
60
))
tdSql
.
query
(
"select stateduration(c1,'GT',1,1w) from t1"
)
tdSql
.
checkData
(
10
,
0
,
int
(
63072035
/
60
/
7
/
24
/
60
))
def
check_boundary_values
(
self
):
tdSql
.
execute
(
"drop database if exists bound_test"
)
...
...
tests/system-test/2-query/json_tag.py
浏览文件 @
86505d97
...
...
@@ -675,7 +675,7 @@ class TDTestCase:
tdSql
.
checkRows
(
3
)
tdSql
.
query
(
"select TO_UNIXTIMESTAMP(datastr) from jsons1 where jtag->'tag1'>1;"
)
tdSql
.
checkRows
(
3
)
tdSql
.
query
(
"select TIMETRUNCATE(ts,1
u
) from jsons1 where jtag->'tag1'>1;"
)
tdSql
.
query
(
"select TIMETRUNCATE(ts,1
s
) from jsons1 where jtag->'tag1'>1;"
)
tdSql
.
checkRows
(
3
)
tdSql
.
query
(
"select TIMEDIFF(ts,_c0) from jsons1 where jtag->'tag1'>1;"
)
tdSql
.
checkRows
(
3
)
...
...
tests/system-test/2-query/statecount.py
浏览文件 @
86505d97
...
...
@@ -18,7 +18,7 @@ class TDTestCase:
def
init
(
self
,
conn
,
logSql
):
tdLog
.
debug
(
f
"start to excute
{
__file__
}
"
)
tdSql
.
init
(
conn
.
cursor
())
def
prepare_datas
(
self
):
tdSql
.
execute
(
'''create table stb1
...
...
@@ -26,7 +26,7 @@ class TDTestCase:
tags (t1 int)
'''
)
tdSql
.
execute
(
'''
create table t1
...
...
@@ -68,7 +68,7 @@ class TDTestCase:
( '2023-02-21 01:01:01.000', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
'''
)
def
test_errors
(
self
):
error_sql_lists
=
[
# "select statecount(c1,'GT',5) from t1"
...
...
@@ -110,35 +110,35 @@ class TDTestCase:
for
error_sql
in
error_sql_lists
:
tdSql
.
error
(
error_sql
)
pass
def
support_types
(
self
):
other_no_value_types
=
[
"select statecount(ts,'GT',1) from t1"
,
"select statecount(ts,'GT',1) from t1"
,
"select statecount(c7,'GT',1) from t1"
,
"select statecount(c8,'GT',1) from t1"
,
"select statecount(c9,'GT',1) from t1"
,
"select statecount(ts,'GT',1) from ct1"
,
"select statecount(ts,'GT',1) from ct1"
,
"select statecount(c7,'GT',1) from ct1"
,
"select statecount(c8,'GT',1) from ct1"
,
"select statecount(c9,'GT',1) from ct1"
,
"select statecount(ts,'GT',1) from ct3"
,
"select statecount(ts,'GT',1) from ct3"
,
"select statecount(c7,'GT',1) from ct3"
,
"select statecount(c8,'GT',1) from ct3"
,
"select statecount(c9,'GT',1) from ct3"
,
"select statecount(ts,'GT',1) from ct4"
,
"select statecount(ts,'GT',1) from ct4"
,
"select statecount(c7,'GT',1) from ct4"
,
"select statecount(c8,'GT',1) from ct4"
,
"select statecount(c9,'GT',1) from ct4"
,
"select statecount(ts,'GT',1) from stb1 partition by tbname"
,
"select statecount(ts,'GT',1) from stb1 partition by tbname"
,
"select statecount(c7,'GT',1) from stb1 partition by tbname"
,
"select statecount(c8,'GT',1) from stb1 partition by tbname"
,
"select statecount(c9,'GT',1) from stb1 partition by tbname"
"select statecount(c9,'GT',1) from stb1 partition by tbname"
]
for
type_sql
in
other_no_value_types
:
tdSql
.
error
(
type_sql
)
tdLog
.
info
(
"support type ok , sql is : %s"
%
type_sql
)
type_sql_lists
=
[
"select statecount(c1,'GT',1) from t1"
,
"select statecount(c2,'GT',1) from t1"
,
...
...
@@ -168,8 +168,8 @@ class TDTestCase:
"select statecount(c5,'GT',1) from stb1 partition by tbname"
,
"select statecount(c6,'GT',1) from stb1 partition by tbname"
,
"select statecount(c6,'GT',1) as alisb from stb1 partition by tbname"
,
"select statecount(c6,'GT',1) alisb from stb1 partition by tbname"
,
"select statecount(c6,'GT',1) as alisb from stb1 partition by tbname"
,
"select statecount(c6,'GT',1) alisb from stb1 partition by tbname"
,
]
for
type_sql
in
type_sql_lists
:
...
...
@@ -177,7 +177,7 @@ class TDTestCase:
def
support_opers
(
self
):
oper_lists
=
[
'LT'
,
'lt'
,
'Lt'
,
'lT'
,
'GT'
,
'gt'
,
'Gt'
,
'gT'
,
'LE'
,
'le'
,
'Le'
,
'lE'
,
'GE'
,
'ge'
,
'Ge'
,
'gE'
,
'NE'
,
'ne'
,
'Ne'
,
'nE'
,
'EQ'
,
'eq'
,
'Eq'
,
'eQ'
]
oper_errors
=
[
","
,
"*"
,
"NULL"
,
"tbname"
,
"ts"
,
"sum"
,
"_c0"
]
for
oper
in
oper_lists
:
...
...
@@ -190,7 +190,7 @@ class TDTestCase:
def
basic_statecount_function
(
self
):
# basic query
# basic query
tdSql
.
query
(
"select c1 from ct3"
)
tdSql
.
checkRows
(
0
)
tdSql
.
query
(
"select c1 from t1"
)
...
...
@@ -211,9 +211,9 @@ class TDTestCase:
tdSql
.
checkRows
(
0
)
tdSql
.
query
(
"select statecount(c6,'GT',1) from ct3"
)
# will support _rowts mix with
# will support _rowts mix with
# tdSql.query("select (c6,'GT',1),_rowts from ct3")
# auto check for t1 table
# used for regular table
tdSql
.
query
(
"select statecount(c6,'GT',1) from t1"
)
...
...
@@ -229,17 +229,17 @@ class TDTestCase:
tdSql
.
error
(
"select statecount(c6,'GT',1),tbname from ct1"
)
tdSql
.
error
(
"select statecount(c6,'GT',1),t1 from ct1"
)
# unique with common col
# unique with common col
tdSql
.
error
(
"select statecount(c6,'GT',1) ,ts from ct1"
)
tdSql
.
error
(
"select statecount(c6,'GT',1) ,c1 from ct1"
)
# unique with scalar function
# unique with scalar function
tdSql
.
error
(
"select statecount(c6,'GT',1) ,abs(c1) from ct1"
)
tdSql
.
error
(
"select statecount(c6,'GT',1) , unique(c2) from ct1"
)
tdSql
.
error
(
"select statecount(c6,'GT',1) , abs(c2)+2 from ct1"
)
# unique with aggregate function
# unique with aggregate function
tdSql
.
error
(
"select statecount(c6,'GT',1) ,sum(c1) from ct1"
)
tdSql
.
error
(
"select statecount(c6,'GT',1) ,max(c1) from ct1"
)
tdSql
.
error
(
"select statecount(c6,'GT',1) ,csum(c1) from ct1"
)
...
...
@@ -262,16 +262,16 @@ class TDTestCase:
tdSql
.
checkData
(
0
,
0
,
1
)
tdSql
.
checkData
(
1
,
0
,
2
)
tdSql
.
checkData
(
6
,
0
,
-
1
)
# unique with union all
# unique with union all
tdSql
.
query
(
"select statecount(c1,'GT',1) from ct4 union all select statecount(c1,'GT',1) from ct1"
)
tdSql
.
checkRows
(
25
)
tdSql
.
query
(
"select statecount(c1,'GT',1) from ct4 union all select distinct(c1) from ct4"
)
tdSql
.
checkRows
(
22
)
# unique with join
# prepare join datas with same ts
# unique with join
# prepare join datas with same ts
tdSql
.
execute
(
" use db "
)
tdSql
.
execute
(
" create stable st1 (ts timestamp , num int) tags(ind int)"
)
...
...
@@ -323,7 +323,7 @@ class TDTestCase:
tdSql
.
checkData
(
0
,
0
,
None
)
tdSql
.
checkData
(
1
,
0
,
0.000000000
)
tdSql
.
checkData
(
3
,
0
,
-
1.000000000
)
# bug for stable
#partition by tbname
...
...
@@ -332,21 +332,20 @@ class TDTestCase:
# tdSql.query(" select unique(c1) from stb1 partition by tbname ")
# tdSql.checkRows(21)
# group by
# group by
tdSql
.
query
(
"select statecount(c1,'GT',1) from ct1 group by c1"
)
tdSql
.
error
(
"select statecount(c1,'GT',1) from ct1 group by tbname"
)
# super table
def
check_unit_time
(
self
):
tdSql
.
execute
(
" use db "
)
tdSql
.
error
(
"select stateduration(c1,'GT',1,1b) from ct1"
)
tdSql
.
error
(
"select stateduration(c1,'GT',1,1u) from ct1"
)
tdSql
.
error
(
"select stateduration(c1,'GT',1,1000s) from t1"
)
tdSql
.
query
(
"select stateduration(c1,'GT',1,1s) from t1"
)
tdSql
.
checkData
(
10
,
0
,
63072035
)
tdSql
.
query
(
"select stateduration(c1,'GT',1,1000s) from t1"
)
tdSql
.
checkData
(
10
,
0
,
int
(
63072035
/
1000
))
tdSql
.
query
(
"select stateduration(c1,'GT',1,1m) from t1"
)
tdSql
.
checkData
(
10
,
0
,
int
(
63072035
/
60
))
tdSql
.
query
(
"select stateduration(c1,'GT',1,1h) from t1"
)
...
...
@@ -355,8 +354,8 @@ class TDTestCase:
tdSql
.
checkData
(
10
,
0
,
int
(
63072035
/
60
/
24
/
60
))
tdSql
.
query
(
"select stateduration(c1,'GT',1,1w) from t1"
)
tdSql
.
checkData
(
10
,
0
,
int
(
63072035
/
60
/
7
/
24
/
60
))
def
check_boundary_values
(
self
):
tdSql
.
execute
(
"drop database if exists bound_test"
)
...
...
@@ -384,11 +383,11 @@ class TDTestCase:
tdSql
.
execute
(
f
"insert into sub1_bound values ( now(), -2147483643, -9223372036854775803, -32763, -123, -3.39E+38, -1.69e+308, True, 'binary_tb1', 'nchar_tb1', now() )"
)
tdSql
.
error
(
f
"insert into sub1_bound values ( now()+1s, 2147483648, 9223372036854775808, 32768, 128, 3.40E+38, 1.7e+308, True, 'binary_tb1', 'nchar_tb1', now() )"
)
tdSql
.
query
(
"select statecount(c1,'GT',1) from sub1_bound"
)
tdSql
.
checkRows
(
5
)
...
...
@@ -396,29 +395,29 @@ class TDTestCase:
tdSql
.
prepare
()
tdLog
.
printNoPrefix
(
"==========step1:create table =============="
)
self
.
prepare_datas
()
tdLog
.
printNoPrefix
(
"==========step2:test errors =============="
)
tdLog
.
printNoPrefix
(
"==========step2:test errors =============="
)
self
.
test_errors
()
tdLog
.
printNoPrefix
(
"==========step3:support types ============"
)
tdLog
.
printNoPrefix
(
"==========step3:support types ============"
)
self
.
support_types
()
tdLog
.
printNoPrefix
(
"==========step4:support opers ============"
)
tdLog
.
printNoPrefix
(
"==========step4:support opers ============"
)
self
.
support_opers
()
tdLog
.
printNoPrefix
(
"==========step5: statecount basic query ============"
)
tdLog
.
printNoPrefix
(
"==========step5: statecount basic query ============"
)
self
.
basic_statecount_function
()
tdLog
.
printNoPrefix
(
"==========step6: statecount boundary query ============"
)
tdLog
.
printNoPrefix
(
"==========step6: statecount boundary query ============"
)
self
.
check_boundary_values
()
tdLog
.
printNoPrefix
(
"==========step6: statecount unit time test ============"
)
tdLog
.
printNoPrefix
(
"==========step6: statecount unit time test ============"
)
self
.
check_unit_time
()
...
...
tests/system-test/2-query/timetruncate.py
浏览文件 @
86505d97
...
...
@@ -12,11 +12,11 @@ class TDTestCase:
self
.
rowNum
=
10
self
.
ts
=
1537146000000
# 2018-9-17 09:00:00.000
def
run
(
self
):
tdSql
.
prepare
()
intData
=
[]
intData
=
[]
floatData
=
[]
tdSql
.
execute
(
'''create table stb(ts timestamp, col1 tinyint, col2 smallint, col3 int, col4 bigint, col5 float, col6 double,
...
...
@@ -27,18 +27,18 @@ class TDTestCase:
for
i
in
range
(
self
.
rowNum
):
tdSql
.
execute
(
"insert into ntb values(%d, %d, %d, %d, %d, %f, %f, %d, 'taosdata%d', '涛思数据%d', %d, %d, %d, %d)"
%
(
self
.
ts
+
i
,
i
+
1
,
i
+
1
,
i
+
1
,
i
+
1
,
i
+
0.1
,
i
+
0.1
,
i
%
2
,
i
+
1
,
i
+
1
,
i
+
1
,
i
+
1
,
i
+
1
,
i
+
1
))
intData
.
append
(
i
+
1
)
intData
.
append
(
i
+
1
)
floatData
.
append
(
i
+
0.1
)
for
i
in
range
(
self
.
rowNum
):
tdSql
.
execute
(
"insert into stb_1 values(%d, %d, %d, %d, %d, %f, %f, %d, 'taosdata%d', '涛思数据%d', %d, %d, %d, %d)"
%
(
self
.
ts
+
i
,
i
+
1
,
i
+
1
,
i
+
1
,
i
+
1
,
i
+
0.1
,
i
+
0.1
,
i
%
2
,
i
+
1
,
i
+
1
,
i
+
1
,
i
+
1
,
i
+
1
,
i
+
1
))
intData
.
append
(
i
+
1
)
floatData
.
append
(
i
+
0.1
)
intData
.
append
(
i
+
1
)
floatData
.
append
(
i
+
0.1
)
tdSql
.
query
(
"select timetruncate(1,1d) from ntb"
)
tdSql
.
checkRows
(
10
)
tdSql
.
query
(
"select timetruncate(1,1u) from ntb"
)
tdSql
.
checkRows
(
10
)
tdSql
.
error
(
"select timetruncate(1,1u) from ntb"
)
#
tdSql.checkRows(10)
tdSql
.
query
(
"select timetruncate(1,1a) from ntb"
)
tdSql
.
checkRows
(
10
)
tdSql
.
query
(
"select timetruncate(1,1m) from ntb"
)
...
...
@@ -97,8 +97,8 @@ class TDTestCase:
tdSql
.
query
(
"select timetruncate(1,1d) from stb"
)
tdSql
.
checkRows
(
10
)
tdSql
.
query
(
"select timetruncate(1,1u) from stb"
)
tdSql
.
checkRows
(
10
)
tdSql
.
error
(
"select timetruncate(1,1u) from stb"
)
#
tdSql.checkRows(10)
tdSql
.
query
(
"select timetruncate(1,1a) from stb"
)
tdSql
.
checkRows
(
10
)
tdSql
.
query
(
"select timetruncate(1,1m) from stb"
)
...
...
@@ -156,8 +156,8 @@ class TDTestCase:
tdSql
.
query
(
"select timetruncate(1,1d) from stb_1"
)
tdSql
.
checkRows
(
10
)
tdSql
.
query
(
"select timetruncate(1,1u) from stb_1"
)
tdSql
.
checkRows
(
10
)
tdSql
.
error
(
"select timetruncate(1,1u) from stb_1"
)
#
tdSql.checkRows(10)
tdSql
.
query
(
"select timetruncate(1,1a) from stb_1"
)
tdSql
.
checkRows
(
10
)
tdSql
.
query
(
"select timetruncate(1,1m) from stb_1"
)
...
...
@@ -217,4 +217,4 @@ class TDTestCase:
tdLog
.
success
(
"%s successfully executed"
%
__file__
)
tdCases
.
addWindows
(
__file__
,
TDTestCase
())
tdCases
.
addLinux
(
__file__
,
TDTestCase
())
\ No newline at end of file
tdCases
.
addLinux
(
__file__
,
TDTestCase
())
tests/system-test/fulltest.sh
浏览文件 @
86505d97
...
...
@@ -89,7 +89,7 @@ python3 ./test.py -f 2-query/query_cols_tags_and_or.py
# python3 ./test.py -f 2-query/nestedQuery_str.py
python3 ./test.py
-f
2-query/avg.py
python3 ./test.py
-f
2-query/elapsed.py
#
python3 ./test.py -f 2-query/elapsed.py
python3 ./test.py
-f
2-query/csum.py
python3 ./test.py
-f
2-query/mavg.py
python3 ./test.py
-f
2-query/diff.py
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录