Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
820e1bc2
TDengine
项目概览
taosdata
/
TDengine
大约 2 年 前同步成功
通知
1192
Star
22018
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看板
提交
820e1bc2
编写于
12月 23, 2021
作者:
A
Alex Duan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[TS-445] Limit offset optimation case create
上级
531bdc58
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
170 addition
and
0 deletion
+170
-0
tests/pytest/fulltest.sh
tests/pytest/fulltest.sh
+1
-0
tests/pytest/query/queryLimit.py
tests/pytest/query/queryLimit.py
+169
-0
未找到文件。
tests/pytest/fulltest.sh
浏览文件 @
820e1bc2
...
...
@@ -272,6 +272,7 @@ python3 ./test.py -f query/operator_cost.py
python3 test.py
-f
query/nestedQuery/queryWithSpread.py
python3 ./test.py
-f
query/bug6586.py
# python3 ./test.py -f query/bug5903.py
python3 ./test.py
-f
query/queryLimit.py
#stream
python3 ./test.py
-f
stream/metric_1.py
...
...
tests/pytest/query/queryLimit.py
0 → 100644
浏览文件 @
820e1bc2
###################################################################
# 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
:
#
# --------------- main frame -------------------
#
def
caseDescription
(
self
):
'''
limit and offset keyword function test cases;
case1: limit offset base function test
case2: limit offset advance test
'''
return
# init
def
init
(
self
,
conn
,
logSql
):
tdLog
.
debug
(
"start to execute %s"
%
__file__
)
tdSql
.
init
(
conn
.
cursor
())
tdSql
.
prepare
()
self
.
create_tables
();
self
.
ts
=
1500000000000
# run case
def
run
(
self
):
# insert data
self
.
insert_data
(
"t1"
,
self
.
ts
,
300
*
10000
,
30000
);
# test base case
self
.
test_case1
()
tdLog
.
debug
(
" LIMIT test_case1 ............ [OK]"
)
# test advance case
self
.
test_case2
()
tdLog
.
debug
(
" LIMIT test_case2 ............ [OK]"
)
# stop
def
stop
(
self
):
tdSql
.
close
()
tdLog
.
success
(
"%s successfully executed"
%
__file__
)
#
# --------------- case -------------------
#
# create table
def
create_tables
(
self
):
# super table
tdSql
.
execute
(
"create table st(ts timestamp, i1 int) tags(area int)"
);
# child table
tdSql
.
execute
(
"create table t1 using st tags(1)"
);
tdSql
.
execute
(
"create table t2 using st tags(2)"
);
tdSql
.
execute
(
"create table t3 using st tags(3)"
);
return
# insert data1
def
insert_data
(
self
,
tbname
,
ts_start
,
count
,
batch_num
):
pre_insert
=
"insert into %s values"
%
tbname
sql
=
pre_insert
tdLog
.
debug
(
"doing insert table %s rows=%d ..."
%
(
tbname
,
count
))
for
i
in
range
(
count
):
sql
+=
" (%d,%d)"
%
(
ts_start
+
i
*
1000
,
i
)
if
i
>
0
and
i
%
batch_num
==
0
:
tdSql
.
execute
(
sql
)
sql
=
pre_insert
# end sql
if
sql
!=
pre_insert
:
tdSql
.
execute
(
sql
)
tdLog
.
debug
(
"INSERT TABLE DATA ............ [OK]"
)
return
# test case1 base
def
test_case1
(
self
):
#
# limit base function
#
# base no where
sql
=
"select * from t1 limit 10"
tdSql
.
waitedQuery
(
sql
,
10
,
WAITS
)
tdSql
.
checkData
(
0
,
1
,
0
)
tdSql
.
checkData
(
9
,
1
,
9
)
# have where
sql
=
"select * from t1 where ts>='2017-07-14 10:40:01' and ts<'2017-07-14 10:40:06' limit 10"
tdSql
.
waitedQuery
(
sql
,
5
,
WAITS
)
tdSql
.
checkData
(
0
,
1
,
1
)
tdSql
.
checkData
(
4
,
1
,
5
)
#
# offset base function
#
# no where
sql
=
"select * from t1 limit 10 offset 5"
tdSql
.
waitedQuery
(
sql
,
10
,
WAITS
)
tdSql
.
checkData
(
0
,
1
,
5
)
tdSql
.
checkData
(
9
,
1
,
14
)
# have where only ts
sql
=
"select * from t1 where ts>='2017-07-14 10:40:10' and ts<'2017-07-14 10:40:20' limit 10 offset 5"
tdSql
.
waitedQuery
(
sql
,
5
,
WAITS
)
tdSql
.
checkData
(
0
,
1
,
15
)
tdSql
.
checkData
(
4
,
1
,
19
)
# have where with other column condition
sql
=
"select * from t1 where i1>=1 and i1<11 limit 10 offset 5"
tdSql
.
waitedQuery
(
sql
,
5
,
WAITS
)
tdSql
.
checkData
(
0
,
1
,
6
)
tdSql
.
checkData
(
4
,
1
,
10
)
# have where with ts and other column condition
sql
=
"select * from t1 where ts>='2017-07-14 10:40:10' and ts<'2017-07-14 10:40:50' and i1>=20 and i1<=25 limit 10 offset 5"
tdSql
.
waitedQuery
(
sql
,
1
,
WAITS
)
tdSql
.
checkData
(
0
,
1
,
25
)
return
# test advance
def
test_case2
(
self
):
#
# OFFSET merge file data with memory data
#
# offset
sql
=
"select * from t1 limit 10 offset 72000"
tdSql
.
waitedQuery
(
sql
,
10
,
WAITS
)
tdSql
.
checkData
(
0
,
1
,
72000
)
# each insert one row into NO.0 NO.2 NO.7 blocks
sql
=
"insert into t1 values (%d, 0) (%d, 2) (%d, 7)"
%
(
self
.
ts
+
1
,
self
.
ts
+
2
*
3300
*
1000
+
1
,
self
.
ts
+
7
*
3300
*
1000
+
1
)
tdSql
.
execute
(
sql
)
# query result
sql
=
"select * from t1 limit 10 offset 72000"
tdSql
.
waitedQuery
(
sql
,
10
,
WAITS
)
tdSql
.
checkData
(
0
,
1
,
72000
-
3
)
# have where
sql
=
"select * from t1 where ts>='2017-07-14 10:40:10' and ts<'2017-07-22 18:40:10' limit 10 offset 72000"
tdSql
.
waitedQuery
(
sql
,
10
,
WAITS
)
tdSql
.
checkData
(
0
,
1
,
72000
-
3
+
10
+
1
)
#
# add case with filename
#
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.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录