Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
4a5ed798
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
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看板
提交
4a5ed798
编写于
5月 18, 2022
作者:
P
Ping Xiao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
test: add test cases for logic operators
上级
ed60cea2
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
141 addition
and
1 deletion
+141
-1
tests/parallel_test/cases.task
tests/parallel_test/cases.task
+2
-1
tests/pytest/query/queryLogicOperators.py
tests/pytest/query/queryLogicOperators.py
+139
-0
未找到文件。
tests/parallel_test/cases.task
浏览文件 @
4a5ed798
...
...
@@ -743,7 +743,8 @@
4,,pytest,python3 test.py -f alter/alter_create_exception.py
4,,pytest,python3 test.py -f insert/line_insert.py
3,,pytest,python3 test.py -f tag_lite/binary.py
3,,pytest,python3 test.py -f query/filterAllIntTypes.py
3,,pytest,python3 test.py -f query/filterAllIntTypes.py
3,,pytest,python3 test.py -f query/queryLogicOperators.py
3,,pytest,python3 ./test.py -f query/queryNcharNull.py
3,,develop-test,python3 ./test.py -f 2-query/ts_hidden_column.py
3,,develop-test,python3 ./test.py -f 1-insert/uppercase_in_stmt.py
...
...
tests/pytest/query/queryLogicOperators.py
0 → 100644
浏览文件 @
4a5ed798
###################################################################
# Copyright (c) 2016 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
numpy.lib.function_base
import
insert
import
taos
from
util.log
import
*
from
util.cases
import
*
from
util.sql
import
*
import
numpy
as
np
# constant define
WAITS
=
5
# wait seconds
class
TDTestCase
:
# init
def
init
(
self
,
conn
,
logSql
):
tdLog
.
debug
(
"start to execute %s"
%
__file__
)
tdSql
.
init
(
conn
.
cursor
())
tdSql
.
prepare
()
self
.
ts
=
1500000000000
self
.
rows
=
100
# run case
def
run
(
self
):
self
.
case1
()
self
.
case2
()
self
.
case3
()
def
case1
(
self
):
tdSql
.
execute
(
"create table tb1(ts timestamp, c1 int, c2 int, c3 bool)"
)
sql
=
"insert into tb1 values "
for
i
in
range
(
self
.
rows
):
sql
+=
"(%d, %d, 1, %d)"
%
(
self
.
ts
+
i
,
i
%
10
,
i
%
2
)
tdSql
.
execute
(
sql
)
operators
=
[
'&'
,
'|'
,
'^'
,
'<<'
,
'>>'
]
for
operator
in
operators
:
tdSql
.
query
(
"select c1 %s c2 from tb1"
%
operator
)
tdSql
.
checkRows
(
100
)
tdSql
.
query
(
"select * from tb1 where c1 %s c2 = 0"
%
operator
)
if
operator
==
'|'
:
tdSql
.
checkRows
(
0
)
elif
operator
==
'&'
:
tdSql
.
checkRows
(
50
)
elif
operator
==
'^'
:
tdSql
.
checkRows
(
10
)
elif
operator
==
'<<'
:
tdSql
.
checkRows
(
10
)
elif
operator
==
'<<'
:
tdSql
.
checkRows
(
20
)
tdSql
.
query
(
"select ~c1 from tb1"
)
tdSql
.
checkRows
(
100
)
tdSql
.
query
(
"select ~c1 from (select * from tb1 where c1 & c2 > 0) where c1 ^ c2 < 1 "
)
tdSql
.
checkRows
(
10
)
def
case2
(
self
):
tdSql
.
execute
(
"create table tb2(ts timestamp, c1 tinyint, c2 tinyint unsigned, c3 smallint, c4 smallint unsigned, c5 int, c6 int unsigned, c7 bigint, c8 bigint unsigned, c9 float, c10 double, c11 bool, c12 binary(10), c13 nchar(10))"
)
sql
=
"insert into tb2 values "
for
i
in
range
(
self
.
rows
):
sql
+=
"(%d, 1, 1, 2, 2, 3, 3, 4, 4, 1.1, 2.5, True, 'test', 'test')"
%
(
self
.
ts
+
i
)
tdSql
.
execute
(
sql
)
operators
=
[
'&'
,
'|'
,
'^'
,
'<<'
,
'>>'
]
for
operator
in
operators
:
for
i
in
range
(
13
):
if
i
<
8
:
tdSql
.
query
(
"select 1 %s c%d from tb2"
%
(
operator
,
i
+
1
))
tdSql
.
checkRows
(
self
.
rows
)
else
:
tdSql
.
error
(
"select 1 %s c%d from tb2"
%
(
operator
,
i
+
1
))
tdSql
.
error
(
"select c%d %s c%d from tb2"
%
(
i
+
1
,
operator
,
i
+
1
))
for
i
in
range
(
13
):
if
i
<
8
:
tdSql
.
query
(
"select %sc%d from tb2"
%
(
'~'
,
i
+
1
))
tdSql
.
checkRows
(
self
.
rows
)
else
:
tdSql
.
error
(
"select %sc%d from tb2"
%
(
'~'
,
i
+
1
))
def
case3
(
self
):
tdSql
.
execute
(
"create table st1(ts timestamp, c1 int, c2 int, c3 binary(20)) tags(t1 int, t2 int, t3 nchar(20))"
)
for
i
in
range
(
self
.
rows
):
tdSql
.
execute
(
"create table t%d using st1 tags(%d, 1, 'test')"
%
(
i
,
i
))
sql
=
"insert into t%d values "
%
i
for
i
in
range
(
self
.
rows
):
sql
+=
"(%d, %d, 1, %d)"
%
(
self
.
ts
+
i
,
i
%
10
,
i
%
2
)
tdSql
.
execute
(
sql
)
operators
=
[
'&'
,
'|'
,
'^'
,
'<<'
,
'>>'
]
for
operator
in
operators
:
tdSql
.
query
(
"select c1 %s c2 from st1"
%
operator
)
tdSql
.
checkRows
(
10000
)
tdSql
.
query
(
"select * from st1 where c1 %s c2 = 0"
%
operator
)
if
operator
==
'|'
:
tdSql
.
checkRows
(
0
)
elif
operator
==
'&'
:
tdSql
.
checkRows
(
5000
)
elif
operator
==
'^'
:
tdSql
.
checkRows
(
1000
)
elif
operator
==
'<<'
:
tdSql
.
checkRows
(
1000
)
elif
operator
==
'>>'
:
tdSql
.
checkRows
(
2000
)
tdSql
.
query
(
"select ~c1 from st1"
)
tdSql
.
checkRows
(
10000
)
tdSql
.
query
(
"select c1, c2 from (select * from st1 where c1 & c2 > 0) where c1 | c2 = 1"
)
tdSql
.
checkRows
(
1000
)
# stop
def
stop
(
self
):
tdSql
.
close
()
tdLog
.
success
(
"%s successfully executed"
%
__file__
)
tdCases
.
addWindows
(
__file__
,
TDTestCase
())
tdCases
.
addLinux
(
__file__
,
TDTestCase
())
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录