nestedQuery_str.py 359.6 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
###################################################################
#           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 random
import os
import time
import taos
import subprocess
from faker import Faker
from util.log import tdLog
from util.cases import tdCases
from util.sql import tdSql
from util.dnodes import tdDnodes
from util.dnodes import *

class TDTestCase:
G
Ganlin Zhao 已提交
27
    updatecfgDict = {'maxSQLLength':1048576,'debugFlag': 143 ,"cDebugFlag":143,"uDebugFlag":143 ,"rpcDebugFlag":143 , "tmrDebugFlag":143 ,
28
    "jniDebugFlag":143 ,"simDebugFlag":143,"dDebugFlag":143, "dDebugFlag":143,"vDebugFlag":143,"mDebugFlag":143,"qDebugFlag":143,
29
    "wDebugFlag":143,"sDebugFlag":143,"tsdbDebugFlag":143,"tqDebugFlag":143 ,"fsDebugFlag":143 ,"udfDebugFlag":143}
G
Ganlin Zhao 已提交
30

31 32 33 34 35 36 37
    def init(self, conn, logSql):
        tdLog.debug("start to execute %s" % __file__)
        tdSql.init(conn.cursor(), logSql)

        self.testcasePath = os.path.split(__file__)[0]
        self.testcaseFilename = os.path.split(__file__)[-1]
        os.system("rm -rf %s/%s.sql" % (self.testcasePath,self.testcaseFilename))
G
Ganlin Zhao 已提交
38

39 40
        self.num = 10
        self.fornum = 5
G
Ganlin Zhao 已提交
41

42 43
        self.db_nest = "nest"
        self.dropandcreateDB_random("%s" %self.db_nest, 1)
G
Ganlin Zhao 已提交
44

45 46 47 48 49 50 51 52 53 54 55 56
        # regular column select
        #q_select= ['ts' , '*' , 'q_int', 'q_bigint' , 'q_bigint' , 'q_smallint' , 'q_tinyint' , 'q_bool' , 'q_binary' , 'q_nchar' ,'q_float' , 'q_double' ,'q_ts ']
        self.q_select= ['ts' , 'q_int', 'q_bigint' , 'q_bigint' , 'q_smallint' , 'q_tinyint' , 'q_bool' , 'q_binary' , 'q_nchar' ,'q_float' , 'q_double' ,'q_ts ', 'q_int_null ', 'q_bigint_null ' , 'q_bigint_null ' , 'q_smallint_null ' , 'q_tinyint_null ' , 'q_bool_null ' , 'q_binary_null ' , 'q_nchar_null ' ,'q_float_null ' , 'q_double_null ' ,'q_ts_null ']

        # tag column select
        #t_select= ['*' , 'loc' ,'t_int', 't_bigint' , 't_bigint' , 't_smallint' , 't_tinyint' , 't_bool' , 't_binary' , 't_nchar' ,'t_float' , 't_double' ,'t_ts ']
        self.t_select= ['loc','t_int', 't_bigint' , 't_bigint' , 't_smallint' , 't_tinyint' , 't_bool' , 't_binary' , 't_nchar' ,'t_float' , 't_double' ,'t_ts ']

        # regular and tag column select
        self.qt_select=  self.q_select + self.t_select

        # distinct regular column select
G
Ganlin Zhao 已提交
57
        self.dq_select= ['distinct q_int', 'distinct q_bigint' , 'distinct q_smallint' , 'distinct q_tinyint' ,
58 59 60
                'distinct q_bool' , 'distinct q_binary' , 'distinct q_nchar' ,'distinct q_float' , 'distinct q_double' ,'distinct q_ts ']

        # distinct tag column select
G
Ganlin Zhao 已提交
61
        self.dt_select= ['distinct loc', 'distinct t_int', 'distinct t_bigint'  , 'distinct t_smallint' , 'distinct t_tinyint' ,
62 63 64 65 66 67 68 69 70 71
                'distinct t_bool' , 'distinct t_binary' , 'distinct t_nchar' ,'distinct t_float' , 'distinct t_double' ,'distinct t_ts ']

        # distinct regular and tag column select
        self.dqt_select= self.dq_select + self.dt_select

        # special column select
        self.s_r_select= ['_c0', '_rowts' , '_C0' ]
        self.s_s_select= ['tbname' , '_rowts' , '_c0', '_C0' ]
        self.unionall_or_union= [ ' union ' , ' union all ' ]

G
Ganlin Zhao 已提交
72
        # regular column where
73
        self.q_where = ['ts < now +1s','q_bigint >= -9223372036854775807 and q_bigint <= 9223372036854775807', 'q_int <= 2147483647 and q_int >= -2147483647',
G
Ganlin Zhao 已提交
74 75
        'q_smallint >= -32767 and q_smallint <= 32767','q_tinyint >= -127 and q_tinyint <= 127','q_float >= -1.7E308 and q_float <= 1.7E308',
        'q_double >= -1.7E308 and q_double <= 1.7E308', 'q_binary like \'binary%\'  or q_binary = \'0\' ' , 'q_nchar like \'nchar%\' or q_nchar = \'0\' ' ,
76
        'q_bool = true or  q_bool = false' , 'q_bool in (0 , 1)' , 'q_bool in ( true , false)' , 'q_bool = 0 or q_bool = 1',
G
Ganlin Zhao 已提交
77 78
        'q_bigint between  -9223372036854775807 and 9223372036854775807',' q_int between -2147483647 and 2147483647','q_smallint between -32767 and 32767',
        'q_bigint not between  9223372036854775807 and -9223372036854775807','q_int not between 2147483647 and -2147483647','q_smallint not between 32767 and -32767',
79 80 81 82 83 84 85 86 87 88 89 90
        'q_tinyint between -127 and 127 ','q_float >= -3.4E38  ','q_float <= 3.4E38  ','q_double >= -1.7E308  ',
        'q_double <= 1.7E308  ','q_float between -3.4E38 and 3.4E38  ','q_double between -1.7E308 and 1.7E308  ' ,'q_float not between 3.4E38 and -3.4E38  ','q_double not between 1.7E308 and -1.7E308  ',
        'q_float is not null  ' ,'q_double is not null  ' ,'q_binary match \'binary\' ','q_binary nmatch \'binarynchar\' ','q_nchar match \'nchar\' ','q_nchar nmatch \'binarynchar\' ',
        'q_binary like \'binary%\' ','(q_binary like \'binary%\'  or q_nchar = \'0\'  or q_binary = \'binary_\' ) ','q_nchar like \'nchar%\' ','(q_nchar like \'nchar%\' or q_binary = \'0\'  or q_nchar = \'nchar_\' ) ',]
        #TD-6201 ,'q_bool between 0 and 1'

        # regular column where for test union,join
        self.q_u_where = ['t1.ts < now +1s' , 't2.ts < now +1s','t1.q_bigint >= -9223372036854775807 and t1.q_bigint <= 9223372036854775807 and t2.q_bigint >= -9223372036854775807 and t2.q_bigint <= 9223372036854775807',
        't1.q_int <= 2147483647 and t1.q_int >= -2147483647 and t2.q_int <= 2147483647 and t2.q_int >= -2147483647',
        't1.q_smallint >= -32767 and t1.q_smallint <= 32767 and t2.q_smallint >= -32767 and t2.q_smallint <= 32767',
        't1.q_tinyint >= -127 and t1.q_tinyint <= 127 and t2.q_tinyint >= -127 and t2.q_tinyint <= 127',
        't1.q_float >= - 1.7E308 and t1.q_float <=  1.7E308 and t2.q_float >= - 1.7E308 and t2.q_float <=  1.7E308',
G
Ganlin Zhao 已提交
91 92 93 94
        't1.q_double >= - 1.7E308 and t1.q_double <=  1.7E308 and t2.q_double >= - 1.7E308 and t2.q_double <=  1.7E308',
        't1.q_binary like \'binary%\'  and t2.q_binary like \'binary%\'  ' ,
        't1.q_nchar like \'nchar%\' and t2.q_nchar like \'nchar%\' ' ,
        't1.q_bool in (0 , 1) and t2.q_bool in (0 , 1)' , 't1.q_bool in ( true , false) and t2.q_bool in ( true , false)' ,
95 96
        't1.q_bigint between  -9223372036854775807 and 9223372036854775807 and t2.q_bigint between  -9223372036854775807 and 9223372036854775807',
        't1.q_int between -2147483647 and 2147483647 and t2.q_int between -2147483647 and 2147483647',
G
Ganlin Zhao 已提交
97
        't1.q_smallint between -32767 and 32767 and t2.q_smallint between -32767 and 32767',
98 99 100 101
        't1.q_tinyint between -127 and 127 and t2.q_tinyint between -127 and 127 ','t1.q_float between -1.7E308 and  1.7E308 and t2.q_float between -1.7E308 and  1.7E308',
        't1.q_double between -1.7E308 and  1.7E308 and t2.q_double between -1.7E308 and  1.7E308',
        't1.q_bigint not between  9223372036854775807 and -9223372036854775807 and t2.q_bigint not between  9223372036854775807 and -9223372036854775807',
        't1.q_int not between 2147483647 and -2147483647 and t2.q_int not between 2147483647 and -2147483647',
G
Ganlin Zhao 已提交
102
        't1.q_smallint not between 32767 and -32767 and t2.q_smallint not between 32767 and -32767',
103 104 105 106 107
        't1.q_tinyint not between 127 and -127 and t2.q_tinyint not between 127 and -127 ','t1.q_float not between -1.7E308 and  -1.7E308 and t2.q_float not between 1.7E308 and  -1.7E308',
        't1.q_double not between 1.7E308 and  -1.7E308 and t2.q_double not between 1.7E308 and  -1.7E308']
        #TD-6201 ,'t1.q_bool between 0 and 1 or t2.q_bool between 0 and 1']
        #'t1.q_bool = true and  t1.q_bool = false and t2.q_bool = true and  t2.q_bool = false' , 't1.q_bool = 0 and t1.q_bool = 1 and t2.q_bool = 0 and t2.q_bool = 1' ,

G
Ganlin Zhao 已提交
108 109
        self.q_u_or_where = ['(t1.q_binary like \'binary%\'  or t1.q_binary = \'0\'  or t2.q_binary like \'binary%\'  or t2.q_binary = \'0\' )' ,
        '(t1.q_nchar like \'nchar%\' or t1.q_nchar = \'0\' or t2.q_nchar like \'nchar%\' or t2.q_nchar = \'0\' )' , '(t1.q_bool = true or  t1.q_bool = false or t2.q_bool = true or  t2.q_bool = false)' ,
110 111 112
        '(t1.q_bool in (0 , 1) or t2.q_bool in (0 , 1))' , '(t1.q_bool in ( true , false) or t2.q_bool in ( true , false))' , '(t1.q_bool = 0 or t1.q_bool = 1 or t2.q_bool = 0 or t2.q_bool = 1)' ,
        '(t1.q_bigint between  -9223372036854775807 and 9223372036854775807 or t2.q_bigint between  -9223372036854775807 and 9223372036854775807)',
        '(t1.q_int between -2147483647 and 2147483647 or t2.q_int between -2147483647 and 2147483647)',
G
Ganlin Zhao 已提交
113
        '(t1.q_smallint between -32767 and 32767 or t2.q_smallint between -32767 and 32767)',
114 115 116 117 118 119
        '(t1.q_tinyint between -127 and 127 or t2.q_tinyint between -127 and 127 )','(t1.q_float between -1.7E308 and 1.7E308 or t2.q_float between -1.7E308 and 1.7E308)',
        '(t1.q_double between -1.7E308 and 1.7E308 or t2.q_double between -1.7E308 and 1.7E308)']

        # tag column where
        self.t_where = ['ts < now +1s','t_bigint >= -9223372036854775807 and t_bigint <= 9223372036854775807','t_int <= 2147483647 and t_int >= -2147483647',
        't_smallint >= -32767 and t_smallint <= 32767','q_tinyint >= -127 and t_tinyint <= 127','t_float >= -1.7E308 and t_float <= 1.7E308',
G
Ganlin Zhao 已提交
120
        't_double >= -1.7E308 and t_double <= 1.7E308', 't_binary like \'binary%\'   or t_binary = \'0\' ' , 't_nchar like \'nchar%\' or t_nchar = \'0\'' ,
121
        't_bool = true or  t_bool = false' , 't_bool in (0 , 1)' , 't_bool in ( true , false)' , 't_bool = 0 or t_bool = 1',
G
Ganlin Zhao 已提交
122
        't_bigint between  -9223372036854775807 and 9223372036854775807',' t_int between -2147483647 and 2147483647','t_smallint between -32767 and 32767',
123 124 125 126 127 128 129 130 131 132 133
        't_tinyint between -127 and 127 ','t_float between -1.7E308 and 1.7E308','t_double between -1.7E308 and 1.7E308',
        't_binary match \'binary\' ','t_binary nmatch \'binarynchar\' ','t_nchar match \'nchar\' ','t_nchar nmatch \'binarynchar\' ',
        't_binary like \'binary%\' ','t_nchar like \'nchar%\' ','(t_binary like \'binary%\'  or t_nchar = \'0\' ) ','(t_nchar like \'nchar%\' or t_binary = \'0\' ) ',]
        #TD-6201,'t_bool between 0 and 1'

        # tag column where for test  union,join | this is not support
        self.t_u_where = ['t1.ts < now +1s' , 't2.ts < now +1s','t1.t_bigint >= -9223372036854775807 and t1.t_bigint <= 9223372036854775807 and t2.t_bigint >= -9223372036854775807 and t2.t_bigint <= 9223372036854775807',
        't1.t_int <= 2147483647 and t1.t_int >= -2147483647 and t2.t_int <= 2147483647 and t2.t_int >= -2147483647',
        't1.t_smallint >= -32767 and t1.t_smallint <= 32767 and t2.t_smallint >= -32767 and t2.t_smallint <= 32767',
        't1.t_tinyint >= -127 and t1.t_tinyint <= 127 and t2.t_tinyint >= -127 and t2.t_tinyint <= 127',
        't1.t_float >= -1.7E308 and t1.t_float <= 1.7E308 and t2.t_float >= -1.7E308 and t2.t_float <= 1.7E308',
G
Ganlin Zhao 已提交
134 135 136
        't1.t_double >= -1.7E308 and t1.t_double <= 1.7E308 and t2.t_double >= -1.7E308 and t2.t_double <= 1.7E308',
        '(t1.t_binary like \'binary%\'  or t1.t_binary = \'0\'  or t2.t_binary like \'binary%\'  or t2.t_binary = \'0\') ' ,
        '(t1.t_nchar like \'nchar%\' or t1.t_nchar = \'0\' or t2.t_nchar like \'nchar%\' or t2.t_nchar = \'0\' )' , '(t1.t_bool = true or  t1.t_bool = false or t2.t_bool = true or  t2.t_bool = false)' ,
137 138 139
        't1.t_bool in (0 , 1) and t2.t_bool in (0 , 1)' , 't1.t_bool in ( true , false) and t2.t_bool in ( true , false)' , '(t1.t_bool = 0 or t1.t_bool = 1 or t2.t_bool = 0 or t2.t_bool = 1)',
        't1.t_bigint between  -9223372036854775807 and 9223372036854775807 and t2.t_bigint between  -9223372036854775807 and 9223372036854775807',
        't1.t_int between -2147483647 and 2147483647 and t2.t_int between -2147483647 and 2147483647',
G
Ganlin Zhao 已提交
140
        't1.t_smallint between -32767 and 32767 and t2.t_smallint between -32767 and 32767',
141 142 143 144
        '(t1.t_tinyint between -127 and 127 and t2.t_tinyint between -127 and 127) ','t1.t_float between -1.7E308 and 1.7E308 and t2.t_float between -1.7E308 and 1.7E308',
        '(t1.t_double between -1.7E308 and 1.7E308 and t2.t_double between -1.7E308 and 1.7E308)']
        #TD-6201,'t1.t_bool between 0 and 1 or t2.q_bool between 0 and 1']

G
Ganlin Zhao 已提交
145 146
        self.t_u_or_where = ['(t1.t_binary like \'binary%\'  or t1.t_binary = \'0\'  or t2.t_binary like \'binary%\'  or t2.t_binary = \'0\' )' ,
        '(t1.t_nchar like \'nchar%\' or t1.t_nchar = \'0\' or t2.t_nchar like \'nchar%\' or t2.t_nchar = \'0\' )' , '(t1.t_bool = true or  t1.t_bool = false or t2.t_bool = true or  t2.t_bool = false)' ,
147 148 149
        '(t1.t_bool in (0 , 1) or t2.t_bool in (0 , 1))' , '(t1.t_bool in ( true , false) or t2.t_bool in ( true , false))' , '(t1.t_bool = 0 or t1.t_bool = 1 or t2.t_bool = 0 or t2.t_bool = 1)',
        '(t1.t_bigint between  -9223372036854775807 and 9223372036854775807 or t2.t_bigint between  -9223372036854775807 and 9223372036854775807)',
        '(t1.t_int between -2147483647 and 2147483647 or t2.t_int between -2147483647 and 2147483647)',
G
Ganlin Zhao 已提交
150
        '(t1.t_smallint between -32767 and 32767 or t2.t_smallint between -32767 and 32767)',
151 152 153
        '(t1.t_tinyint between -127 and 127 or t2.t_tinyint between -127 and 127 )','(t1.t_float between -1.7E308 and 1.7E308 or t2.t_float between -1.7E308 and 1.7E308)',
        '(t1.t_double between -1.7E308 and 1.7E308 or t2.t_double between -1.7E308 and 1.7E308)']

G
Ganlin Zhao 已提交
154
        # regular and tag column where
155 156 157 158 159 160 161 162 163 164 165 166 167
        self.qt_where = self.q_where + self.t_where
        self.qt_u_where = self.q_u_where + self.t_u_where
        # now,qt_u_or_where is not support
        self.qt_u_or_where = self.q_u_or_where + self.t_u_or_where

        # tag column where for test super join | this is  support  , 't1.t_bool = t2.t_bool ' ???
        self.t_join_where = ['t1.t_bigint = t2.t_bigint ', 't1.t_int = t2.t_int ', 't1.t_smallint = t2.t_smallint ', 't1.t_tinyint = t2.t_tinyint ',
                    't1.t_float = t2.t_float ', 't1.t_double = t2.t_double ', 't1.t_binary = t2.t_binary ' , 't1.t_nchar = t2.t_nchar  ' ]

        # session && fill
        self.session_where = ['session(ts,10a)' , 'session(ts,10s)', 'session(ts,10m)' , 'session(ts,10h)','session(ts,10d)' , 'session(ts,10w)']
        self.session_u_where = ['session(t1.ts,10a)' , 'session(t1.ts,10s)', 'session(t1.ts,10m)' , 'session(t1.ts,10h)','session(t1.ts,10d)' , 'session(t1.ts,10w)',
                    'session(t2.ts,10a)' , 'session(t2.ts,10s)', 'session(t2.ts,10m)' , 'session(t2.ts,10h)','session(t2.ts,10d)' , 'session(t2.ts,10w)']
G
Ganlin Zhao 已提交
168

169
        self.fill_where = ['FILL(NONE)','FILL(PREV)','FILL(NULL)','FILL(LINEAR)','FILL(NEXT)','FILL(VALUE, 1.23)']
G
Ganlin Zhao 已提交
170

171 172 173 174
        self.state_window = ['STATE_WINDOW(q_tinyint)','STATE_WINDOW(q_bigint)','STATE_WINDOW(q_int)','STATE_WINDOW(q_bool)','STATE_WINDOW(q_smallint)']
        self.state_u_window = ['STATE_WINDOW(t1.q_tinyint)','STATE_WINDOW(t1.q_bigint)','STATE_WINDOW(t1.q_int)','STATE_WINDOW(t1.q_bool)','STATE_WINDOW(t1.q_smallint)',
                    'STATE_WINDOW(t2.q_tinyint)','STATE_WINDOW(t2.q_bigint)','STATE_WINDOW(t2.q_int)','STATE_WINDOW(t2.q_bool)','STATE_WINDOW(t2.q_smallint)']

G
Ganlin Zhao 已提交
175
        # order by where
176 177 178 179
        self.order_where = ['order by ts' , 'order by ts asc']
        self.order_u_where = ['order by t1.ts' , 'order by t1.ts asc' , 'order by t2.ts' , 'order by t2.ts asc']
        self.order_desc_where = ['order by ts' , 'order by ts asc' , 'order by ts desc' ]
        self.orders_desc_where = ['order by ts' , 'order by ts asc' , 'order by ts desc' , 'order by loc' , 'order by loc asc' , 'order by loc desc']
G
Ganlin Zhao 已提交
180 181

        self.group_where = ['group by tbname , loc' , 'group by tbname', 'group by tbname, t_bigint', 'group by tbname,t_int', 'group by tbname, t_smallint', 'group by tbname,t_tinyint',
182 183
                    'group by tbname,t_float', 'group by tbname,t_double' , 'group by tbname,t_binary', 'group by tbname,t_nchar', 'group by tbname,t_bool' ,'group by tbname ,loc ,t_bigint',
                    'group by tbname,t_binary ,t_nchar ,t_bool' , 'group by tbname,t_int ,t_smallint ,t_tinyint' , 'group by tbname,t_float ,t_double ' ,
G
Ganlin Zhao 已提交
184
                    'PARTITION BY tbname , loc' , 'PARTITION BY tbname', 'PARTITION BY tbname, t_bigint', 'PARTITION BY tbname,t_int', 'PARTITION BY tbname, t_smallint', 'PARTITION BY tbname,t_tinyint',
185 186
                    'PARTITION BY tbname,t_float', 'PARTITION BY tbname,t_double' , 'PARTITION BY tbname,t_binary', 'PARTITION BY tbname,t_nchar', 'PARTITION BY tbname,t_bool' ,'PARTITION BY tbname ,loc ,t_bigint',
                    'PARTITION BY tbname,t_binary ,t_nchar ,t_bool' , 'PARTITION BY tbname,t_int ,t_smallint ,t_tinyint' , 'PARTITION BY tbname,t_float ,t_double ']
G
Ganlin Zhao 已提交
187
        self.group_where_j = ['group by  t1.loc' , 'group by t1.t_bigint', 'group by t1.t_int', 'group by t1.t_smallint', 'group by t1.t_tinyint',
188 189
                    'group by t1.t_float', 'group by t1.t_double' , 'group by t1.t_binary', 'group by t1.t_nchar', 'group by t1.t_bool' ,'group by t1.loc ,t1.t_bigint',
                    'group by t1.t_binary ,t1.t_nchar ,t1.t_bool' , 'group by t1.t_int ,t1.t_smallint ,t1.t_tinyint' , 'group by t1.t_float ,t1.t_double ' ,
G
Ganlin Zhao 已提交
190
                    'PARTITION BY t1.loc' , 'PARTITION by t1.t_bigint', 'PARTITION by t1.t_int', 'PARTITION by t1.t_smallint', 'PARTITION by t1.t_tinyint',
191 192
                    'PARTITION by t1.t_float', 'PARTITION by t1.t_double' , 'PARTITION by t1.t_binary', 'PARTITION by t1.t_nchar', 'PARTITION by t1.t_bool' ,'PARTITION BY t1.loc ,t1.t_bigint',
                    'PARTITION by t1.t_binary ,t1.t_nchar ,t1.t_bool' , 'PARTITION by t1.t_int ,t1.t_smallint ,t1.t_tinyint' , 'PARTITION by t1.t_float ,t1.t_double ',
G
Ganlin Zhao 已提交
193
                    'group by  t2.loc' , 'group by t2.t_bigint', 'group by t2.t_int', 'group by t2.t_smallint', 'group by t2.t_tinyint',
194 195
                    'group by t2.t_float', 'group by t2.t_double' , 'group by t2.t_binary', 'group by t2.t_nchar', 'group by t2.t_bool' ,'group by t2.loc ,t2.t_bigint',
                    'group by t2.t_binary ,t2.t_nchar ,t2.t_bool' , 'group by t2.t_int ,t2.t_smallint ,t2.t_tinyint' , 'group by t2.t_float ,t2.t_double ' ,
G
Ganlin Zhao 已提交
196
                    'PARTITION BY t2.loc' , 'PARTITION by t2.t_bigint', 'PARTITION by t2.t_int', 'PARTITION by t2.t_smallint', 'PARTITION by t2.t_tinyint',
197
                    'PARTITION by t2.t_float', 'PARTITION by t2.t_double' , 'PARTITION by t2.t_binary', 'PARTITION by t2.t_nchar', 'PARTITION by t2.t_bool' ,'PARTITION BY t2.loc ,t2.t_bigint',
G
Ganlin Zhao 已提交
198 199 200
                    'PARTITION by t2.t_binary ,t2.t_nchar ,t2.t_bool' , 'PARTITION by t2.t_int ,t2.t_smallint ,t2.t_tinyint' , 'PARTITION by t2.t_float ,t2.t_double ']

        self.partiton_where = ['PARTITION BY tbname , loc' , 'PARTITION BY tbname', 'PARTITION BY tbname, t_bigint', 'PARTITION BY tbname,t_int', 'PARTITION BY tbname, t_smallint', 'PARTITION BY tbname,t_tinyint',
201 202
                    'PARTITION BY tbname,t_float', 'PARTITION BY tbname,t_double' , 'PARTITION BY tbname,t_binary', 'PARTITION BY tbname,t_nchar', 'PARTITION BY tbname,t_bool' ,'PARTITION BY tbname ,loc ,t_bigint',
                    'PARTITION BY tbname,t_binary ,t_nchar ,t_bool' , 'PARTITION BY tbname,t_int ,t_smallint ,t_tinyint' , 'PARTITION BY tbname,t_float ,t_double ']
G
Ganlin Zhao 已提交
203
        self.partiton_where_j = ['PARTITION BY t1.loc' , 'PARTITION by t1.t_bigint', 'PARTITION by t1.t_int', 'PARTITION by t1.t_smallint', 'PARTITION by t1.t_tinyint',
204 205
                    'PARTITION by t1.t_float', 'PARTITION by t1.t_double' , 'PARTITION by t1.t_binary', 'PARTITION by t1.t_nchar', 'PARTITION by t1.t_bool' ,'PARTITION BY t1.loc ,t1.t_bigint',
                    'PARTITION by t1.t_binary ,t1.t_nchar ,t1.t_bool' , 'PARTITION by t1.t_int ,t1.t_smallint ,t1.t_tinyint' , 'PARTITION by t1.t_float ,t1.t_double ',
G
Ganlin Zhao 已提交
206
                    'PARTITION BY t2.loc' , 'PARTITION by t2.t_bigint', 'PARTITION by t2.t_int', 'PARTITION by t2.t_smallint', 'PARTITION by t2.t_tinyint',
207
                    'PARTITION by t2.t_float', 'PARTITION by t2.t_double' , 'PARTITION by t2.t_binary', 'PARTITION by t2.t_nchar', 'PARTITION by t2.t_bool' ,'PARTITION BY t2.loc ,t2.t_bigint',
G
Ganlin Zhao 已提交
208 209
                    'PARTITION by t2.t_binary ,t2.t_nchar ,t2.t_bool' , 'PARTITION by t2.t_int ,t2.t_smallint ,t2.t_tinyint' , 'PARTITION by t2.t_float ,t2.t_double ']

210

G
Ganlin Zhao 已提交
211
        self.group_where_regular = ['group by tbname ' , 'group by tbname', 'group by tbname, q_bigint', 'group by tbname,q_int', 'group by tbname, q_smallint', 'group by tbname,q_tinyint',
212 213
                    'group by tbname,q_float', 'group by tbname,q_double' , 'group by tbname,q_binary', 'group by tbname,q_nchar', 'group by tbname,q_bool' ,'group by tbname ,q_bigint',
                    'group by tbname,q_binary ,q_nchar ,q_bool' , 'group by tbname,q_int ,q_smallint ,q_tinyint' , 'group by tbname,q_float ,q_double ' ,
G
Ganlin Zhao 已提交
214
                    'PARTITION BY tbname ' , 'PARTITION BY tbname', 'PARTITION BY tbname, q_bigint', 'PARTITION BY tbname,q_int', 'PARTITION BY tbname, q_smallint', 'PARTITION BY tbname,q_tinyint',
215 216
                    'PARTITION BY tbname,q_float', 'PARTITION BY tbname,q_double' , 'PARTITION BY tbname,q_binary', 'PARTITION BY tbname,q_nchar', 'PARTITION BY tbname,q_bool' ,'PARTITION BY tbname ,q_bigint',
                    'PARTITION BY tbname,q_binary ,q_nchar ,q_bool' , 'PARTITION BY tbname,q_int ,q_smallint ,q_tinyint' , 'PARTITION BY tbname,q_float ,q_double ']
G
Ganlin Zhao 已提交
217
        self.group_where_regular_j = ['group by t1.q_bigint', 'group by t1.q_int', 'group by t1.q_smallint', 'group by t1.q_tinyint',
218 219
                    'group by t1.q_float', 'group by t1.q_double' , 'group by t1.q_binary', 'group by t1.q_nchar', 'group by t1.q_bool' ,'group by t1.q_bigint',
                    'group by t1.q_binary ,t1.q_nchar ,t1.q_bool' , 'group by t1.q_int ,t1.q_smallint ,t1.q_tinyint' , 'group by t1.q_float ,t1.q_double ' ,
G
Ganlin Zhao 已提交
220
                    'PARTITION by t1.q_bigint', 'PARTITION by t1.q_int', 'PARTITION by t1.q_smallint', 'PARTITION by t1.q_tinyint',
221 222
                    'PARTITION by t1.q_float', 'PARTITION by t1.q_double' , 'PARTITION by t1.q_binary', 'PARTITION by t1.q_nchar', 'PARTITION by t1.q_bool' ,'PARTITION BY t1.q_bigint',
                    'PARTITION by t1.q_binary ,t1.q_nchar ,t1.q_bool' , 'PARTITION by t1.q_int ,t1.q_smallint ,t1.q_tinyint' , 'PARTITION by t1.q_float ,t1.q_double ',
G
Ganlin Zhao 已提交
223
                    'group by t2.q_bigint', 'group by t2.q_int', 'group by t2.q_smallint', 'group by t2.q_tinyint',
224 225
                    'group by t2.q_float', 'group by t2.q_double' , 'group by t2.q_binary', 'group by t2.q_nchar', 'group by t2.q_bool' ,'group by t2.q_bigint',
                    'group by t2.q_binary ,t2.q_nchar ,t2.q_bool' , 'group by t2.q_int ,t2.q_smallint ,t2.q_tinyint' , 'group by t2.q_float ,t2.q_double ' ,
G
Ganlin Zhao 已提交
226
                    'PARTITION by t2.q_bigint', 'PARTITION by t2.q_int', 'PARTITION by t2.q_smallint', 'PARTITION by t2.q_tinyint',
227
                    'PARTITION by t2.q_float', 'PARTITION by t2.q_double' , 'PARTITION by t2.q_binary', 'PARTITION by t2.q_nchar', 'PARTITION by t2.q_bool' ,'PARTITION BY t2.q_bigint',
G
Ganlin Zhao 已提交
228 229 230
                    'PARTITION by t2.q_binary ,t2.q_nchar ,t2.q_bool' , 'PARTITION by t2.q_int ,t2.q_smallint ,t2.q_tinyint' , 'PARTITION by t2.q_float ,t2.q_double ']

        self.partiton_where_regular = ['PARTITION BY tbname ' , 'PARTITION BY tbname', 'PARTITION BY tbname, q_bigint', 'PARTITION BY tbname,q_int', 'PARTITION BY tbname, q_smallint', 'PARTITION BY tbname,q_tinyint',
231 232
                    'PARTITION BY tbname,q_float', 'PARTITION BY tbname,q_double' , 'PARTITION BY tbname,q_binary', 'PARTITION BY tbname,q_nchar', 'PARTITION BY tbname,q_bool' ,'PARTITION BY tbname ,q_bigint',
                    'PARTITION BY tbname,q_binary ,q_nchar ,q_bool' , 'PARTITION BY tbname,q_int ,q_smallint ,q_tinyint' , 'PARTITION BY tbname,q_float ,q_double ']
G
Ganlin Zhao 已提交
233
        self.partiton_where_regular_j = ['PARTITION by t1.q_bigint', 'PARTITION by t1.q_int', 'PARTITION by t1.q_smallint', 'PARTITION by t1.q_tinyint',
234 235
                    'PARTITION by t1.q_float', 'PARTITION by t1.q_double' , 'PARTITION by t1.q_binary', 'PARTITION by t1.q_nchar', 'PARTITION by t1.q_bool' ,'PARTITION BY t1.q_bigint',
                    'PARTITION by t1.q_binary ,t1.q_nchar ,t1.q_bool' , 'PARTITION by t1.q_int ,t1.q_smallint ,t1.q_tinyint' , 'PARTITION by t1.q_float ,t1.q_double ',
G
Ganlin Zhao 已提交
236
                    'PARTITION by t2.q_bigint', 'PARTITION by t2.q_int', 'PARTITION by t2.q_smallint', 'PARTITION by t2.q_tinyint',
237
                    'PARTITION by t2.q_float', 'PARTITION by t2.q_double' , 'PARTITION by t2.q_binary', 'PARTITION by t2.q_nchar', 'PARTITION by t2.q_bool' ,'PARTITION BY t2.q_bigint',
G
Ganlin Zhao 已提交
238 239
                    'PARTITION by t2.q_binary ,t2.q_nchar ,t2.q_bool' , 'PARTITION by t2.q_int ,t2.q_smallint ,t2.q_tinyint' , 'PARTITION by t2.q_float ,t2.q_double ']

240 241 242 243 244 245 246 247 248 249 250 251 252 253
        self.having_support = ['having count(q_int) > 0','having count(q_bigint) > 0','having count(q_smallint) > 0','having count(q_tinyint) > 0','having count(q_float) > 0','having count(q_double) > 0','having count(q_bool) > 0',
                    'having avg(q_int) > 0','having avg(q_bigint) > 0','having avg(q_smallint) > 0','having avg(q_tinyint) > 0','having avg(q_float) > 0','having avg(q_double) > 0',
                    'having sum(q_int) > 0','having sum(q_bigint) > 0','having sum(q_smallint) > 0','having sum(q_tinyint) > 0','having sum(q_float) > 0','having sum(q_double) > 0',
                    'having STDDEV(q_int) > 0','having STDDEV(q_bigint) > 0','having STDDEV(q_smallint) > 0','having STDDEV(q_tinyint) > 0','having STDDEV(q_float) > 0','having STDDEV(q_double) > 0',
                    'having TWA(q_int) > 0','having  TWA(q_bigint) > 0','having  TWA(q_smallint) > 0','having  TWA(q_tinyint) > 0','having  TWA(q_float) > 0','having  TWA(q_double) > 0',
                    'having IRATE(q_int) > 0','having IRATE(q_bigint) > 0','having IRATE(q_smallint) > 0','having IRATE(q_tinyint) > 0','having IRATE(q_float) > 0','having IRATE(q_double) > 0',
                    'having MIN(q_int) > 0','having MIN(q_bigint) > 0','having MIN(q_smallint) > 0','having MIN(q_tinyint) > 0','having MIN(q_float) > 0','having MIN(q_double) > 0',
                    'having MAX(q_int) > 0','having MAX(q_bigint) > 0','having MAX(q_smallint) > 0','having MAX(q_tinyint) > 0','having MAX(q_float) > 0','having MAX(q_double) > 0',
                    'having FIRST(q_int) > 0','having FIRST(q_bigint) > 0','having FIRST(q_smallint) > 0','having FIRST(q_tinyint) > 0','having FIRST(q_float) > 0','having FIRST(q_double) > 0',
                    'having LAST(q_int) > 0','having LAST(q_bigint) > 0','having LAST(q_smallint) > 0','having LAST(q_tinyint) > 0','having LAST(q_float) > 0','having LAST(q_double) > 0',
                    'having APERCENTILE(q_int,10) > 0','having APERCENTILE(q_bigint,10) > 0','having APERCENTILE(q_smallint,10) > 0','having APERCENTILE(q_tinyint,10) > 0','having APERCENTILE(q_float,10) > 0','having APERCENTILE(q_double,10) > 0']
        self.having_not_support = ['having TOP(q_int,10) > 0','having TOP(q_bigint,10) > 0','having TOP(q_smallint,10) > 0','having TOP(q_tinyint,10) > 0','having TOP(q_float,10) > 0','having TOP(q_double,10) > 0','having TOP(q_bool,10) > 0',
                    'having BOTTOM(q_int,10) > 0','having BOTTOM(q_bigint,10) > 0','having BOTTOM(q_smallint,10) > 0','having BOTTOM(q_tinyint,10) > 0','having BOTTOM(q_float,10) > 0','having BOTTOM(q_double,10) > 0','having BOTTOM(q_bool,10) > 0',
                    'having LEASTSQUARES(q_int) > 0','having  LEASTSQUARES(q_bigint) > 0','having  LEASTSQUARES(q_smallint) > 0','having  LEASTSQUARES(q_tinyint) > 0','having  LEASTSQUARES(q_float) > 0','having  LEASTSQUARES(q_double) > 0','having  LEASTSQUARES(q_bool) > 0',
G
Ganlin Zhao 已提交
254
                    'having FIRST(q_bool) > 0','having IRATE(q_bool) > 0','having PERCENTILE(q_bool,10) > 0','having avg(q_bool) > 0','having LAST_ROW(q_bool) > 0','having sum(q_bool) > 0','having STDDEV(q_bool) > 0','having APERCENTILE(q_bool,10) > 0','having  TWA(q_bool) > 0','having LAST(q_bool) > 0',
255
                    'having PERCENTILE(q_int,10) > 0','having PERCENTILE(q_bigint,10) > 0','having PERCENTILE(q_smallint,10) > 0','having PERCENTILE(q_tinyint,10) > 0','having PERCENTILE(q_float,10) > 0','having PERCENTILE(q_double,10) > 0']
G
Ganlin Zhao 已提交
256
        self.having_tagnot_support = ['having LAST_ROW(q_int) > 0','having LAST_ROW(q_bigint) > 0','having LAST_ROW(q_smallint) > 0','having LAST_ROW(q_tinyint) > 0','having LAST_ROW(q_float) > 0','having LAST_ROW(q_double) > 0']
257 258 259 260 261 262 263 264 265 266 267 268

        self.having_support_j = ['having count(t1.q_int) > 0','having count(t1.q_bigint) > 0','having count(t1.q_smallint) > 0','having count(t1.q_tinyint) > 0','having count(t1.q_float) > 0','having count(t1.q_double) > 0','having count(t1.q_bool) > 0',
                    'having avg(t1.q_int) > 0','having avg(t1.q_bigint) > 0','having avg(t1.q_smallint) > 0','having avg(t1.q_tinyint) > 0','having avg(t1.q_float) > 0','having avg(t1.q_double) > 0',
                    'having sum(t1.q_int) > 0','having sum(t1.q_bigint) > 0','having sum(t1.q_smallint) > 0','having sum(t1.q_tinyint) > 0','having sum(t1.q_float) > 0','having sum(t1.q_double) > 0',
                    'having STDDEV(t1.q_int) > 0','having STDDEV(t1.q_bigint) > 0','having STDDEV(t1.q_smallint) > 0','having STDDEV(t1.q_tinyint) > 0','having STDDEV(t1.q_float) > 0','having STDDEV(t1.q_double) > 0',
                    'having TWA(t1.q_int) > 0','having  TWA(t1.q_bigint) > 0','having  TWA(t1.q_smallint) > 0','having  TWA(t1.q_tinyint) > 0','having  TWA(t1.q_float) > 0','having  TWA(t1.q_double) > 0',
                    'having IRATE(t1.q_int) > 0','having IRATE(t1.q_bigint) > 0','having IRATE(t1.q_smallint) > 0','having IRATE(t1.q_tinyint) > 0','having IRATE(t1.q_float) > 0','having IRATE(t1.q_double) > 0',
                    'having MIN(t1.q_int) > 0','having MIN(t1.q_bigint) > 0','having MIN(t1.q_smallint) > 0','having MIN(t1.q_tinyint) > 0','having MIN(t1.q_float) > 0','having MIN(t1.q_double) > 0',
                    'having MAX(t1.q_int) > 0','having MAX(t1.q_bigint) > 0','having MAX(t1.q_smallint) > 0','having MAX(t1.q_tinyint) > 0','having MAX(t1.q_float) > 0','having MAX(t1.q_double) > 0',
                    'having FIRST(t1.q_int) > 0','having FIRST(t1.q_bigint) > 0','having FIRST(t1.q_smallint) > 0','having FIRST(t1.q_tinyint) > 0','having FIRST(t1.q_float) > 0','having FIRST(t1.q_double) > 0',
                    'having LAST(t1.q_int) > 0','having LAST(t1.q_bigint) > 0','having LAST(t1.q_smallint) > 0','having LAST(t1.q_tinyint) > 0','having LAST(t1.q_float) > 0','having LAST(t1.q_double) > 0',
                    'having APERCENTILE(t1.q_int,10) > 0','having APERCENTILE(t1.q_bigint,10) > 0','having APERCENTILE(t1.q_smallint,10) > 0','having APERCENTILE(t1.q_tinyint,10) > 0','having APERCENTILE(t1.q_float,10) > 0','having APERCENTILE(t1.q_double,10) > 0']
G
Ganlin Zhao 已提交
269

270 271 272 273 274 275 276 277
        # limit offset where
        self.limit_where = ['limit 1 offset 1' , 'limit 1' , 'limit 2 offset 1' , 'limit 2', 'limit 12 offset 1' , 'limit 20', 'limit 20 offset 10' , 'limit 200']
        self.limit1_where = ['limit 1 offset 1' , 'limit 1' ]
        self.limit_u_where = ['limit 100 offset 10' , 'limit 50' , 'limit 100' , 'limit 10' ]

        # slimit soffset where
        self.slimit_where = ['slimit 1 soffset 1' , 'slimit 1' , 'slimit 2 soffset 1' , 'slimit 2']
        self.slimit1_where = ['slimit 2 soffset 1' , 'slimit 1' ]
G
Ganlin Zhao 已提交
278 279

        # aggregate function include [all:count(*)\avg\sum\stddev ||regualr:twa\irate\leastsquares ||group by tbname:twa\irate\]
280 281 282 283 284 285 286 287 288
        # select function include [all: min\max\first(*)\last(*)\top\bottom\apercentile\last_row(*)(not with interval)\interp(*)(FILL) ||regualr: percentile]
        # calculation function include [all:spread\+-*/ ||regualr:diff\derivative ||group by tbname:diff\derivative\]
        # **_ns_**  express is not support stable, therefore, separated from regular tables
        # calc_select_all   calc_select_regular  calc_select_in_ts  calc_select_fill  calc_select_not_interval
        # calc_aggregate_all   calc_aggregate_regular   calc_aggregate_groupbytbname
        # calc_calculate_all   calc_calculate_regular   calc_calculate_groupbytbname

        # calc_select_all   calc_select_regular  calc_select_in_ts  calc_select_fill  calc_select_not_interval
        # select function include [all: min\max\first(*)\last(*)\top\bottom\apercentile\last_row(*)(not with interval)\interp(*)(FILL) ||regualr: percentile]
G
Ganlin Zhao 已提交
289

290 291 292 293 294 295 296
        self.calc_select_all = ['bottom(q_int,20)' , 'bottom(q_bigint,20)' , 'bottom(q_smallint,20)' , 'bottom(q_tinyint,20)' ,'bottom(q_float,20)' , 'bottom(q_double,20)' ,
                    'top(q_int,20)' , 'top(q_bigint,20)' , 'top(q_smallint,20)' ,'top(q_tinyint,20)' ,'top(q_float,20)' ,'top(q_double,20)' ,
                    'first(q_int)' , 'first(q_bigint)' , 'first(q_smallint)' , 'first(q_tinyint)' , 'first(q_float)' ,'first(q_double)' ,'first(q_binary)' ,'first(q_nchar)' ,'first(q_bool)' ,'first(q_ts)' ,
                    'last(q_int)' ,  'last(q_bigint)' , 'last(q_smallint)'  , 'last(q_tinyint)' , 'last(q_float)'  ,'last(q_double)' , 'last(q_binary)' ,'last(q_nchar)' ,'last(q_bool)' ,'last(q_ts)' ,
                    'min(q_int)' , 'min(q_bigint)' , 'min(q_smallint)' , 'min(q_tinyint)' , 'min(q_float)' ,'min(q_double)' ,
                    'max(q_int)' ,  'max(q_bigint)' , 'max(q_smallint)' , 'max(q_tinyint)' ,'max(q_float)' ,'max(q_double)' ,
                    'apercentile(q_int,20)' ,  'apercentile(q_bigint,20)'  ,'apercentile(q_smallint,20)'  ,'apercentile(q_tinyint,20)' ,'apercentile(q_float,20)'  ,'apercentile(q_double,20)' ,
G
Ganlin Zhao 已提交
297
                    'last_row(q_int)' ,  'last_row(q_bigint)' , 'last_row(q_smallint)' , 'last_row(q_tinyint)' , 'last_row(q_float)' ,
298 299 300 301 302 303 304 305 306 307
                    'last_row(q_double)' , 'last_row(q_bool)' ,'last_row(q_binary)' ,'last_row(q_nchar)' ,'last_row(q_ts)']

        self.calc_select_in_ts = ['bottom(q_int,20)' , 'bottom(q_bigint,20)' , 'bottom(q_smallint,20)' , 'bottom(q_tinyint,20)' ,'bottom(q_float,20)' , 'bottom(q_double,20)' ,
                    'top(q_int,20)' , 'top(q_bigint,20)' , 'top(q_smallint,20)' ,'top(q_tinyint,20)' ,'top(q_float,20)' ,'top(q_double,20)' ,
                    'first(q_int)' , 'first(q_bigint)' , 'first(q_smallint)' , 'first(q_tinyint)' , 'first(q_float)' ,'first(q_double)' ,'first(q_binary)' ,'first(q_nchar)' ,'first(q_bool)' ,'first(q_ts)' ,
                    'last(q_int)' ,  'last(q_bigint)' , 'last(q_smallint)'  , 'last(q_tinyint)' , 'last(q_float)'  ,'last(q_double)' , 'last(q_binary)' ,'last(q_nchar)' ,'last(q_bool)' ,'last(q_ts)' ]

        self.calc_select_in = ['min(q_int)' , 'min(q_bigint)' , 'min(q_smallint)' , 'min(q_tinyint)' , 'min(q_float)' ,'min(q_double)' ,
                    'max(q_int)' ,  'max(q_bigint)' , 'max(q_smallint)' , 'max(q_tinyint)' ,'max(q_float)' ,'max(q_double)' ,
                    'apercentile(q_int,20)' ,  'apercentile(q_bigint,20)'  ,'apercentile(q_smallint,20)'  ,'apercentile(q_tinyint,20)' ,'apercentile(q_float,20)'  ,'apercentile(q_double,20)' ,
G
Ganlin Zhao 已提交
308
                    'last_row(q_int)' ,  'last_row(q_bigint)' , 'last_row(q_smallint)' , 'last_row(q_tinyint)' , 'last_row(q_float)' ,
309
                    'last_row(q_double)' , 'last_row(q_bool)' ,'last_row(q_binary)' ,'last_row(q_nchar)' ,'last_row(q_ts)']
G
Ganlin Zhao 已提交
310

311 312
        self.calc_select_not_support_ts = ['first(q_int)' , 'first(q_bigint)' , 'first(q_smallint)' , 'first(q_tinyint)' , 'first(q_float)' ,'first(q_double)' ,'first(q_binary)' ,'first(q_nchar)' ,'first(q_bool)' ,'first(q_ts)' ,
                    'last(q_int)' ,  'last(q_bigint)' , 'last(q_smallint)'  , 'last(q_tinyint)' , 'last(q_float)'  ,'last(q_double)' , 'last(q_binary)' ,'last(q_nchar)' ,'last(q_bool)' ,'last(q_ts)' ,
G
Ganlin Zhao 已提交
313
                    'last_row(q_int)' ,  'last_row(q_bigint)' , 'last_row(q_smallint)' , 'last_row(q_tinyint)' , 'last_row(q_float)' ,
314
                    'last_row(q_double)' , 'last_row(q_bool)' ,'last_row(q_binary)' ,'last_row(q_nchar)' ,'last_row(q_ts)',
G
Ganlin Zhao 已提交
315 316
                    'apercentile(q_int,20)' ,  'apercentile(q_bigint,20)'  ,'apercentile(q_smallint,20)'  ,'apercentile(q_tinyint,20)' ,'apercentile(q_float,20)'  ,'apercentile(q_double,20)']

317 318 319 320
        self.calc_select_support_ts = ['bottom(q_int,20)' , 'bottom(q_bigint,20)' , 'bottom(q_smallint,20)' , 'bottom(q_tinyint,20)' ,'bottom(q_float,20)' , 'bottom(q_double,20)' ,
                    'top(q_int,20)' , 'top(q_bigint,20)' , 'top(q_smallint,20)' ,'top(q_tinyint,20)' ,'top(q_float,20)' ,'top(q_double,20)' ,
                    'min(q_int)' , 'min(q_bigint)' , 'min(q_smallint)' , 'min(q_tinyint)' , 'min(q_float)' ,'min(q_double)' ,
                    'max(q_int)' ,  'max(q_bigint)' , 'max(q_smallint)' , 'max(q_tinyint)' ,'max(q_float)' ,'max(q_double)'  ]
G
Ganlin Zhao 已提交
321

322 323
        self.calc_select_regular = [ 'PERCENTILE(q_int,10)' ,'PERCENTILE(q_bigint,20)' , 'PERCENTILE(q_smallint,30)' ,'PERCENTILE(q_tinyint,40)' ,'PERCENTILE(q_float,50)' ,'PERCENTILE(q_double,60)']

G
Ganlin Zhao 已提交
324

325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348
        self.calc_select_fill = ['INTERP(q_int)' ,'INTERP(q_bigint)' ,'INTERP(q_smallint)' ,'INTERP(q_tinyint)', 'INTERP(q_float)' ,'INTERP(q_double)']
        self.interp_where = ['ts = now' , 'ts = \'2020-09-13 20:26:40.000\'' , 'ts = \'2020-09-13 20:26:40.009\'' ,'tbname in (\'table_1\') and ts = now' ,'tbname in (\'table_0\' ,\'table_1\',\'table_2\',\'table_3\',\'table_4\',\'table_5\') and ts =  \'2020-09-13 20:26:40.000\'','tbname like \'table%\'  and ts =  \'2020-09-13 20:26:40.002\'']

        #two table join
        self.calc_select_in_ts_j = ['bottom(t1.q_int,20)' , 'bottom(t1.q_bigint,20)' , 'bottom(t1.q_smallint,20)' , 'bottom(t1.q_tinyint,20)' ,'bottom(t1.q_float,20)' , 'bottom(t1.q_double,20)' ,
                    'top(t1.q_int,20)' , 'top(t1.q_bigint,20)' , 'top(t1.q_smallint,20)' ,'top(t1.q_tinyint,20)' ,'top(t1.q_float,20)' ,'top(t1.q_double,20)' ,
                    'first(t1.q_int)' , 'first(t1.q_bigint)' , 'first(t1.q_smallint)' , 'first(t1.q_tinyint)' , 'first(t1.q_float)' ,'first(t1.q_double)' ,'first(t1.q_binary)' ,'first(t1.q_nchar)' ,'first(t1.q_bool)' ,'first(t1.q_ts)' ,
                    'last(t1.q_int)' ,  'last(t1.q_bigint)' , 'last(t1.q_smallint)'  , 'last(t1.q_tinyint)' , 'last(t1.q_float)'  ,'last(t1.q_double)' , 'last(t1.q_binary)' ,'last(t1.q_nchar)' ,'last(t1.q_bool)' ,'last(t1.q_ts)' ,
                    'bottom(t2.q_int,20)' , 'bottom(t2.q_bigint,20)' , 'bottom(t2.q_smallint,20)' , 'bottom(t2.q_tinyint,20)' ,'bottom(t2.q_float,20)' , 'bottom(t2.q_double,20)' ,
                    'top(t2.q_int,20)' , 'top(t2.q_bigint,20)' , 'top(t2.q_smallint,20)' ,'top(t2.q_tinyint,20)' ,'top(t2.q_float,20)' ,'top(t2.q_double,20)' ,
                    'first(t2.q_int)' , 'first(t2.q_bigint)' , 'first(t2.q_smallint)' , 'first(t2.q_tinyint)' , 'first(t2.q_float)' ,'first(t2.q_double)' ,'first(t2.q_binary)' ,'first(t2.q_nchar)' ,'first(t2.q_bool)' ,'first(t2.q_ts)' ,
                    'last(t2.q_int)' ,  'last(t2.q_bigint)' , 'last(t2.q_smallint)'  , 'last(t2.q_tinyint)' , 'last(t2.q_float)'  ,'last(t2.q_double)' , 'last(t2.q_binary)' ,'last(t2.q_nchar)' ,'last(t2.q_bool)' ,'last(t2.q_ts)']

        self.calc_select_in_support_ts_j = ['bottom(t1.q_int,20)' , 'bottom(t1.q_bigint,20)' , 'bottom(t1.q_smallint,20)' , 'bottom(t1.q_tinyint,20)' ,'bottom(t1.q_float,20)' , 'bottom(t1.q_double,20)' ,
                    'top(t1.q_int,20)' , 'top(t1.q_bigint,20)' , 'top(t1.q_smallint,20)' ,'top(t1.q_tinyint,20)' ,'top(t1.q_float,20)' ,'top(t1.q_double,20)' ,
                    'min(t1.q_int)' , 'min(t1.q_bigint)' , 'min(t1.q_smallint)' , 'min(t1.q_tinyint)' , 'min(t1.q_float)' ,'min(t1.q_double)' ,
                    'max(t1.q_int)' ,  'max(t1.q_bigint)' , 'max(t1.q_smallint)' , 'max(t1.q_tinyint)' ,'max(t1.q_float)' ,'max(t1.q_double)' ,
                    'bottom(t2.q_int,20)' , 'bottom(t2.q_bigint,20)' , 'bottom(t2.q_smallint,20)' , 'bottom(t2.q_tinyint,20)' ,'bottom(t2.q_float,20)' , 'bottom(t2.q_double,20)' ,
                    'top(t2.q_int,20)' , 'top(t2.q_bigint,20)' , 'top(t2.q_smallint,20)' ,'top(t2.q_tinyint,20)' ,'top(t2.q_float,20)' ,'top(t2.q_double,20)' ,
                    'min(t2.q_int)' , 'min(t2.q_bigint)' , 'min(t2.q_smallint)' , 'min(t2.q_tinyint)' , 'min(t2.q_float)' ,'min(t2.q_double)' ,
                    'max(t2.q_int)' ,  'max(t2.q_bigint)' , 'max(t2.q_smallint)' , 'max(t2.q_tinyint)' ,'max(t2.q_float)' ,'max(t2.q_double)' ,
                    ]

        self.calc_select_in_not_support_ts_j = ['apercentile(t1.q_int,20)' ,  'apercentile(t1.q_bigint,20)'  ,'apercentile(t1.q_smallint,20)'  ,'apercentile(t1.q_tinyint,20)' ,'apercentile(t1.q_float,20)'  ,'apercentile(t1.q_double,20)' ,
G
Ganlin Zhao 已提交
349
                    'last_row(t1.q_int)' ,  'last_row(t1.q_bigint)' , 'last_row(t1.q_smallint)' , 'last_row(t1.q_tinyint)' , 'last_row(t1.q_float)' ,
350 351
                    'last_row(t1.q_double)' , 'last_row(t1.q_bool)' ,'last_row(t1.q_binary)' ,'last_row(t1.q_nchar)' ,'last_row(t1.q_ts)' ,
                    'apercentile(t2.q_int,20)' ,  'apercentile(t2.q_bigint,20)'  ,'apercentile(t2.q_smallint,20)'  ,'apercentile(t2.q_tinyint,20)' ,'apercentile(t2.q_float,20)'  ,'apercentile(t2.q_double,20)' ,
G
Ganlin Zhao 已提交
352
                    'last_row(t2.q_int)' ,  'last_row(t2.q_bigint)' , 'last_row(t2.q_smallint)' , 'last_row(t2.q_tinyint)' , 'last_row(t2.q_float)' ,
353 354 355 356 357
                    'last_row(t2.q_double)' , 'last_row(t2.q_bool)' ,'last_row(t2.q_binary)' ,'last_row(t2.q_nchar)' ,'last_row(t2.q_ts)']

        self.calc_select_in_j = ['min(t1.q_int)' , 'min(t1.q_bigint)' , 'min(t1.q_smallint)' , 'min(t1.q_tinyint)' , 'min(t1.q_float)' ,'min(t1.q_double)' ,
                    'max(t1.q_int)' ,  'max(t1.q_bigint)' , 'max(t1.q_smallint)' , 'max(t1.q_tinyint)' ,'max(t1.q_float)' ,'max(t1.q_double)' ,
                    'apercentile(t1.q_int,20)' ,  'apercentile(t1.q_bigint,20)'  ,'apercentile(t1.q_smallint,20)'  ,'apercentile(t1.q_tinyint,20)' ,'apercentile(t1.q_float,20)'  ,'apercentile(t1.q_double,20)' ,
G
Ganlin Zhao 已提交
358
                    'last_row(t1.q_int)' ,  'last_row(t1.q_bigint)' , 'last_row(t1.q_smallint)' , 'last_row(t1.q_tinyint)' , 'last_row(t1.q_float)' ,
359 360 361 362
                    'last_row(t1.q_double)' , 'last_row(t1.q_bool)' ,'last_row(t1.q_binary)' ,'last_row(t1.q_nchar)' ,'last_row(t1.q_ts)' ,
                    'min(t2.q_int)' , 'min(t2.q_bigint)' , 'min(t2.q_smallint)' , 'min(t2.q_tinyint)' , 'min(t2.q_float)' ,'min(t2.q_double)' ,
                    'max(t2.q_int)' ,  'max(t2.q_bigint)' , 'max(t2.q_smallint)' , 'max(t2.q_tinyint)' ,'max(t2.q_float)' ,'max(t2.q_double)' ,
                    'apercentile(t2.q_int,20)' ,  'apercentile(t2.q_bigint,20)'  ,'apercentile(t2.q_smallint,20)'  ,'apercentile(t2.q_tinyint,20)' ,'apercentile(t2.q_float,20)'  ,'apercentile(t2.q_double,20)' ,
G
Ganlin Zhao 已提交
363 364
                    'last_row(t2.q_int)' ,  'last_row(t2.q_bigint)' , 'last_row(t2.q_smallint)' , 'last_row(t2.q_tinyint)' , 'last_row(t2.q_float)' ,
                    'last_row(t2.q_double)' , 'last_row(t2.q_bool)' ,'last_row(t2.q_binary)' ,'last_row(t2.q_nchar)' ,'last_row(t2.q_ts)']
365 366 367 368 369
        self.calc_select_all_j = self.calc_select_in_ts_j + self.calc_select_in_j

        self.calc_select_regular_j = [ 'PERCENTILE(t1.q_int,10)' ,'PERCENTILE(t1.q_bigint,20)' , 'PERCENTILE(t1.q_smallint,30)' ,'PERCENTILE(t1.q_tinyint,40)' ,'PERCENTILE(t1.q_float,50)' ,'PERCENTILE(t1.q_double,60)' ,
                    'PERCENTILE(t2.q_int,10)' ,'PERCENTILE(t2.q_bigint,20)' , 'PERCENTILE(t2.q_smallint,30)' ,'PERCENTILE(t2.q_tinyint,40)' ,'PERCENTILE(t2.q_float,50)' ,'PERCENTILE(t2.q_double,60)']

G
Ganlin Zhao 已提交
370

371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391
        self.calc_select_fill_j = ['INTERP(t1.q_int)' ,'INTERP(t1.q_bigint)' ,'INTERP(t1.q_smallint)' ,'INTERP(t1.q_tinyint)', 'INTERP(t1.q_float)' ,'INTERP(t1.q_double)' ,
                    'INTERP(t2.q_int)' ,'INTERP(t2.q_bigint)' ,'INTERP(t2.q_smallint)' ,'INTERP(t2.q_tinyint)', 'INTERP(t2.q_float)' ,'INTERP(t2.q_double)']
        self.interp_where_j = ['t1.ts = now' , 't1.ts = \'2020-09-13 20:26:40.000\'' , 't1.ts = \'2020-09-13 20:26:40.009\'' ,'t2.ts = now' , 't2.ts = \'2020-09-13 20:26:40.000\'' , 't2.ts = \'2020-09-13 20:26:40.009\'' ,
                    't1.tbname in (\'table_1\') and t1.ts = now' ,'t1.tbname in (\'table_0\' ,\'table_1\',\'table_2\',\'table_3\',\'table_4\',\'table_5\') and t1.ts =  \'2020-09-13 20:26:40.000\'','t1.tbname like \'table%\'  and t1.ts =  \'2020-09-13 20:26:40.002\'',
                    't2.tbname in (\'table_1\') and t2.ts = now' ,'t2.tbname in (\'table_0\' ,\'table_1\',\'table_2\',\'table_3\',\'table_4\',\'table_5\') and t2.ts =  \'2020-09-13 20:26:40.000\'','t2.tbname like \'table%\'  and t2.ts =  \'2020-09-13 20:26:40.002\'']

        # calc_aggregate_all   calc_aggregate_regular   calc_aggregate_groupbytbname  APERCENTILE\PERCENTILE
        # aggregate function include [all:count(*)\avg\sum\stddev ||regualr:twa\irate\leastsquares ||group by tbname:twa\irate\]
        self.calc_aggregate_all = ['count(*)' , 'count(q_int)' ,'count(q_bigint)' , 'count(q_smallint)' ,'count(q_tinyint)' ,'count(q_float)' ,
                    'count(q_double)' ,'count(q_binary)' ,'count(q_nchar)' ,'count(q_bool)' ,'count(q_ts)' ,
                    'avg(q_int)' ,'avg(q_bigint)' , 'avg(q_smallint)' ,'avg(q_tinyint)' ,'avg(q_float)' ,'avg(q_double)' ,
                    'sum(q_int)' ,'sum(q_bigint)' , 'sum(q_smallint)' ,'sum(q_tinyint)' ,'sum(q_float)' ,'sum(q_double)' ,
                    'STDDEV(q_int)' ,'STDDEV(q_bigint)' , 'STDDEV(q_smallint)' ,'STDDEV(q_tinyint)' ,'STDDEV(q_float)' ,'STDDEV(q_double)',
                    'APERCENTILE(q_int,10)' ,'APERCENTILE(q_bigint,20)' , 'APERCENTILE(q_smallint,30)' ,'APERCENTILE(q_tinyint,40)' ,'APERCENTILE(q_float,50)' ,'APERCENTILE(q_double,60)']

        self.calc_aggregate_regular = ['twa(q_int)' ,'twa(q_bigint)' , 'twa(q_smallint)' ,'twa(q_tinyint)' ,'twa (q_float)' ,'twa(q_double)' ,
                    'IRATE(q_int)' ,'IRATE(q_bigint)' , 'IRATE(q_smallint)' ,'IRATE(q_tinyint)' ,'IRATE (q_float)' ,'IRATE(q_double)' ,
                    'LEASTSQUARES(q_int,15,3)' , 'LEASTSQUARES(q_bigint,10,1)' , 'LEASTSQUARES(q_smallint,20,3)' ,'LEASTSQUARES(q_tinyint,10,4)' ,'LEASTSQUARES(q_float,6,4)' ,'LEASTSQUARES(q_double,3,1)' ,
                    'PERCENTILE(q_int,10)' ,'PERCENTILE(q_bigint,20)' , 'PERCENTILE(q_smallint,30)' ,'PERCENTILE(q_tinyint,40)' ,'PERCENTILE(q_float,50)' ,'PERCENTILE(q_double,60)']

        self.calc_aggregate_groupbytbname = ['twa(q_int)' ,'twa(q_bigint)' , 'twa(q_smallint)' ,'twa(q_tinyint)' ,'twa (q_float)' ,'twa(q_double)' ,
G
Ganlin Zhao 已提交
392
                    'IRATE(q_int)' ,'IRATE(q_bigint)' , 'IRATE(q_smallint)' ,'IRATE(q_tinyint)' ,'IRATE (q_float)' ,'IRATE(q_double)' ]
393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419

        #two table join
        self.calc_aggregate_all_j = ['count(t1.*)' , 'count(t1.q_int)' ,'count(t1.q_bigint)' , 'count(t1.q_smallint)' ,'count(t1.q_tinyint)' ,'count(t1.q_float)' ,
                    'count(t1.q_double)' ,'count(t1.q_binary)' ,'count(t1.q_nchar)' ,'count(t1.q_bool)' ,'count(t1.q_ts)' ,
                    'avg(t1.q_int)' ,'avg(t1.q_bigint)' , 'avg(t1.q_smallint)' ,'avg(t1.q_tinyint)' ,'avg(t1.q_float)' ,'avg(t1.q_double)' ,
                    'sum(t1.q_int)' ,'sum(t1.q_bigint)' , 'sum(t1.q_smallint)' ,'sum(t1.q_tinyint)' ,'sum(t1.q_float)' ,'sum(t1.q_double)' ,
                    'STDDEV(t1.q_int)' ,'STDDEV(t1.q_bigint)' , 'STDDEV(t1.q_smallint)' ,'STDDEV(t1.q_tinyint)' ,'STDDEV(t1.q_float)' ,'STDDEV(t1.q_double)',
                    'APERCENTILE(t1.q_int,10)' ,'APERCENTILE(t1.q_bigint,20)' , 'APERCENTILE(t1.q_smallint,30)' ,'APERCENTILE(t1.q_tinyint,40)' ,'APERCENTILE(t1.q_float,50)' ,'APERCENTILE(t1.q_double,60)' ,
                    'count(t2.*)' , 'count(t2.q_int)' ,'count(t2.q_bigint)' , 'count(t2.q_smallint)' ,'count(t2.q_tinyint)' ,'count(t2.q_float)' ,
                    'count(t2.q_double)' ,'count(t2.q_binary)' ,'count(t2.q_nchar)' ,'count(t2.q_bool)' ,'count(t2.q_ts)' ,
                    'avg(t2.q_int)' ,'avg(t2.q_bigint)' , 'avg(t2.q_smallint)' ,'avg(t2.q_tinyint)' ,'avg(t2.q_float)' ,'avg(t2.q_double)' ,
                    'sum(t2.q_int)' ,'sum(t2.q_bigint)' , 'sum(t2.q_smallint)' ,'sum(t2.q_tinyint)' ,'sum(t2.q_float)' ,'sum(t2.q_double)' ,
                    'STDDEV(t2.q_int)' ,'STDDEV(t2.q_bigint)' , 'STDDEV(t2.q_smallint)' ,'STDDEV(t2.q_tinyint)' ,'STDDEV(t2.q_float)' ,'STDDEV(t2.q_double)',
                    'APERCENTILE(t2.q_int,10)' ,'APERCENTILE(t2.q_bigint,20)' , 'APERCENTILE(t2.q_smallint,30)' ,'APERCENTILE(t2.q_tinyint,40)' ,'APERCENTILE(t2.q_float,50)' ,'APERCENTILE(t2.q_double,60)']

        self.calc_aggregate_regular_j = ['twa(t1.q_int)' ,'twa(t1.q_bigint)' , 'twa(t1.q_smallint)' ,'twa(t1.q_tinyint)' ,'twa (t1.q_float)' ,'twa(t1.q_double)' ,
                    'IRATE(t1.q_int)' ,'IRATE(t1.q_bigint)' , 'IRATE(t1.q_smallint)' ,'IRATE(t1.q_tinyint)' ,'IRATE (t1.q_float)' ,'IRATE(t1.q_double)' ,
                    'LEASTSQUARES(t1.q_int,15,3)' , 'LEASTSQUARES(t1.q_bigint,10,1)' , 'LEASTSQUARES(t1.q_smallint,20,3)' ,'LEASTSQUARES(t1.q_tinyint,10,4)' ,'LEASTSQUARES(t1.q_float,6,4)' ,'LEASTSQUARES(t1.q_double,3,1)' ,
                    'PERCENTILE(t1.q_int,10)' ,'PERCENTILE(t1.q_bigint,20)' , 'PERCENTILE(t1.q_smallint,30)' ,'PERCENTILE(t1.q_tinyint,40)' ,'PERCENTILE(t1.q_float,50)' ,'PERCENTILE(t1.q_double,60)' ,
                    'twa(t2.q_int)' ,'twa(t2.q_bigint)' , 'twa(t2.q_smallint)' ,'twa(t2.q_tinyint)' ,'twa (t2.q_float)' ,'twa(t2.q_double)' ,
                    'IRATE(t2.q_int)' ,'IRATE(t2.q_bigint)' , 'IRATE(t2.q_smallint)' ,'IRATE(t2.q_tinyint)' ,'IRATE (t2.q_float)' ,'IRATE(t2.q_double)',
                    'LEASTSQUARES(t2.q_int,15,3)' , 'LEASTSQUARES(t2.q_bigint,10,1)' , 'LEASTSQUARES(t2.q_smallint,20,3)' ,'LEASTSQUARES(t2.q_tinyint,10,4)' ,'LEASTSQUARES(t2.q_float,6,4)' ,'LEASTSQUARES(t2.q_double,3,1)' ,
                    'PERCENTILE(t2.q_int,10)' ,'PERCENTILE(t2.q_bigint,20)' , 'PERCENTILE(t2.q_smallint,30)' ,'PERCENTILE(t2.q_tinyint,40)' ,'PERCENTILE(t2.q_float,50)' ,'PERCENTILE(t2.q_double,60)']

        self.calc_aggregate_groupbytbname_j = ['twa(t1.q_int)' ,'twa(t1.q_bigint)' , 'twa(t1.q_smallint)' ,'twa(t1.q_tinyint)' ,'twa (t1.q_float)' ,'twa(t1.q_double)' ,
                    'IRATE(t1.q_int)' ,'IRATE(t1.q_bigint)' , 'IRATE(t1.q_smallint)' ,'IRATE(t1.q_tinyint)' ,'IRATE (t1.q_float)' ,'IRATE(t1.q_double)' ,
                    'twa(t2.q_int)' ,'twa(t2.q_bigint)' , 'twa(t2.q_smallint)' ,'twa(t2.q_tinyint)' ,'twa (t2.q_float)' ,'twa(t2.q_double)' ,
G
Ganlin Zhao 已提交
420 421
                    'IRATE(t2.q_int)' ,'IRATE(t2.q_bigint)' , 'IRATE(t2.q_smallint)' ,'IRATE(t2.q_tinyint)' ,'IRATE (t2.q_float)' ,'IRATE(t2.q_double)' ]

422 423
        # calc_calculate_all   calc_calculate_regular   calc_calculate_groupbytbname
        # calculation function include [all:spread\+-*/ ||regualr:diff\derivative ||group by tbname:diff\derivative\]
G
Ganlin Zhao 已提交
424
        self.calc_calculate_all = ['SPREAD(ts)'  , 'SPREAD(q_ts)'  , 'SPREAD(q_int)' ,'SPREAD(q_bigint)' , 'SPREAD(q_smallint)' ,'SPREAD(q_tinyint)' ,'SPREAD(q_float)' ,'SPREAD(q_double)' ,
425 426 427 428 429 430
                     '(SPREAD(q_int) + SPREAD(q_bigint))' , '(SPREAD(q_smallint) - SPREAD(q_float))', '(SPREAD(q_double) * SPREAD(q_tinyint))' , '(SPREAD(q_double) / SPREAD(q_float))']
        self.calc_calculate_regular = ['DIFF(q_int)' ,'DIFF(q_bigint)' , 'DIFF(q_smallint)' ,'DIFF(q_tinyint)' ,'DIFF(q_float)' ,'DIFF(q_double)' ,
                                  'DIFF(q_int,0)' ,'DIFF(q_bigint,0)' , 'DIFF(q_smallint,0)' ,'DIFF(q_tinyint,0)' ,'DIFF(q_float,0)' ,'DIFF(q_double,0)' ,
                                  'DIFF(q_int,1)' ,'DIFF(q_bigint,1)' , 'DIFF(q_smallint,1)' ,'DIFF(q_tinyint,1)' ,'DIFF(q_float,1)' ,'DIFF(q_double,1)' ,
                    'DERIVATIVE(q_int,15s,0)' , 'DERIVATIVE(q_bigint,10s,1)' , 'DERIVATIVE(q_smallint,20s,0)' ,'DERIVATIVE(q_tinyint,10s,1)' ,'DERIVATIVE(q_float,6s,0)' ,'DERIVATIVE(q_double,3s,1)' ]
        self.calc_calculate_groupbytbname = self.calc_calculate_regular
G
Ganlin Zhao 已提交
431

432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454
        #two table join
        self.calc_calculate_all_j = ['SPREAD(t1.ts)'  , 'SPREAD(t1.q_ts)'  , 'SPREAD(t1.q_int)' ,'SPREAD(t1.q_bigint)' , 'SPREAD(t1.q_smallint)' ,'SPREAD(t1.q_tinyint)' ,'SPREAD(t1.q_float)' ,'SPREAD(t1.q_double)' ,
                    'SPREAD(t2.ts)'  , 'SPREAD(t2.q_ts)'  , 'SPREAD(t2.q_int)' ,'SPREAD(t2.q_bigint)' , 'SPREAD(t2.q_smallint)' ,'SPREAD(t2.q_tinyint)' ,'SPREAD(t2.q_float)' ,'SPREAD(t2.q_double)' ,
                    '(SPREAD(t1.q_int) + SPREAD(t1.q_bigint))' , '(SPREAD(t1.q_tinyint) - SPREAD(t1.q_float))', '(SPREAD(t1.q_double) * SPREAD(t1.q_tinyint))' , '(SPREAD(t1.q_double) / SPREAD(t1.q_tinyint))',
                    '(SPREAD(t2.q_int) + SPREAD(t2.q_bigint))' , '(SPREAD(t2.q_smallint) - SPREAD(t2.q_float))', '(SPREAD(t2.q_double) * SPREAD(t2.q_tinyint))' , '(SPREAD(t2.q_double) / SPREAD(t2.q_tinyint))',
                    '(SPREAD(t1.q_int) + SPREAD(t1.q_smallint))' , '(SPREAD(t2.q_smallint) - SPREAD(t2.q_float))', '(SPREAD(t1.q_double) * SPREAD(t1.q_tinyint))' , '(SPREAD(t1.q_double) / SPREAD(t1.q_float))']
        self.calc_calculate_regular_j = ['DIFF(t1.q_int)' ,'DIFF(t1.q_bigint)' , 'DIFF(t1.q_smallint)' ,'DIFF(t1.q_tinyint)' ,'DIFF(t1.q_float)' ,'DIFF(t1.q_double)' ,
                    'DIFF(t1.q_int,0)' ,'DIFF(t1.q_bigint,0)' , 'DIFF(t1.q_smallint,0)' ,'DIFF(t1.q_tinyint,0)' ,'DIFF(t1.q_float,0)' ,'DIFF(t1.q_double,0)' ,
                    'DIFF(t1.q_int,1)' ,'DIFF(t1.q_bigint,1)' , 'DIFF(t1.q_smallint,1)' ,'DIFF(t1.q_tinyint,1)' ,'DIFF(t1.q_float,1)' ,'DIFF(t1.q_double,1)' ,
                    'DERIVATIVE(t1.q_int,15s,0)' , 'DERIVATIVE(t1.q_bigint,10s,1)' , 'DERIVATIVE(t1.q_smallint,20s,0)' ,'DERIVATIVE(t1.q_tinyint,10s,1)' ,'DERIVATIVE(t1.q_float,6s,0)' ,'DERIVATIVE(t1.q_double,3s,1)' ,
                    'DIFF(t2.q_int)' ,'DIFF(t2.q_bigint)' , 'DIFF(t2.q_smallint)' ,'DIFF(t2.q_tinyint)' ,'DIFF(t2.q_float)' ,'DIFF(t2.q_double)' ,
                    'DIFF(t2.q_int,0)' ,'DIFF(t2.q_bigint,0)' , 'DIFF(t2.q_smallint,0)' ,'DIFF(t2.q_tinyint,0)' ,'DIFF(t2.q_float,0)' ,'DIFF(t2.q_double,0)' ,
                    'DIFF(t2.q_int,1)' ,'DIFF(t2.q_bigint,1)' , 'DIFF(t2.q_smallint,1)' ,'DIFF(t2.q_tinyint,1)' ,'DIFF(t2.q_float,1)' ,'DIFF(t2.q_double,1)' ,
                    'DERIVATIVE(t2.q_int,15s,0)' , 'DERIVATIVE(t2.q_bigint,10s,1)' , 'DERIVATIVE(t2.q_smallint,20s,0)' ,'DERIVATIVE(t2.q_tinyint,10s,1)' ,'DERIVATIVE(t2.q_float,6s,0)' ,'DERIVATIVE(t2.q_double,3s,1)' ]
        self.calc_calculate_groupbytbname_j = self.calc_calculate_regular_j

        #inter  && calc_aggregate_all\calc_aggregate_regular\calc_select_all
        self.interval_sliding = ['interval(4w) sliding(1w) ','interval(1w) sliding(1d) ','interval(1d) sliding(1h) ' ,
                    'interval(1h) sliding(1m) ','interval(1m) sliding(1s) ','interval(1s) sliding(10a) ',
                    'interval(1y) ','interval(1n) ','interval(1w) ','interval(1d) ','interval(1h) ','interval(1m) ','interval(1s) ' ,'interval(10a)',
                    'interval(1y,1n) ','interval(1n,1w) ','interval(1w,1d) ','interval(1d,1h) ','interval(1h,1m) ','interval(1m,1s) ','interval(1s,10a) ' ,'interval(100a,30a)']

        self.conn1 = taos.connect(host="127.0.0.1", user="root", password="taosdata", config="/etc/taos/")
G
Ganlin Zhao 已提交
455 456
        self.cur1 = self.conn1.cursor()
        print(self.cur1)
457 458 459 460
        self.cur1.execute("use %s ;" %self.db_nest)
        sql = 'select * from stable_1 limit 5;'
        self.cur1.execute(sql)

G
Ganlin Zhao 已提交
461

462 463
    def data_matrix_equal(self, sql1,row1_s,row1_e,col1_s,col1_e, sql2,row2_s,row2_e,col2_s,col2_e):
        #  ----row1_start----col1_start----
G
Ganlin Zhao 已提交
464 465
        #  - - - - 是一个矩阵内的数据相等- - -
        #  - - - - - - - - - - - - - - - -
466 467 468 469 470 471 472 473 474 475 476
        #  ----row1_end------col1_end------
        self.sql1 = sql1
        list1 =[]
        tdSql.query(sql1)
        for i1 in range(row1_s-1,row1_e):
            #print("iiii=%d"%i1)
            for j1 in range(col1_s-1,col1_e):
                #print("jjjj=%d"%j1)
                #print("data=%s" %(tdSql.getData(i1,j1)))
                list1.append(tdSql.getData(i1,j1))
        print("=====list1-------list1---=%s" %set(list1))
G
Ganlin Zhao 已提交
477

478
        tdSql.execute("reset query cache;")
G
Ganlin Zhao 已提交
479
        self.sql2 = sql2
480 481 482 483 484 485 486 487
        list2 =[]
        tdSql.query(sql2)
        for i2 in range(row2_s-1,row2_e):
            #print("iiii222=%d"%i2)
            for j2 in range(col2_s-1,col2_e):
                #print("jjjj222=%d"%j2)
                #print("data=%s" %(tdSql.getData(i2,j2)))
                list2.append(tdSql.getData(i2,j2))
G
Ganlin Zhao 已提交
488 489
        print("=====list2-------list2---=%s" %set(list2))

490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514
        if  (list1 == list2) and len(list2)>0:
            # print(("=====matrix===sql1.list1:'%s',sql2.list2:'%s'") %(list1,list2))
            tdLog.info(("===matrix===sql1:'%s' matrix_result = sql2:'%s' matrix_result") %(sql1,sql2))
        elif (set(list2)).issubset(set(list1)):
            # 解决不同子表排列结果乱序
            # print(("=====list_issubset==matrix2in1-true===sql1.list1:'%s',sql2.list2:'%s'") %(list1,list2))
            tdLog.info(("===matrix_issubset===sql1:'%s' matrix_set_result = sql2:'%s' matrix_set_result") %(sql1,sql2))
        #elif abs(float(str(list1).replace("]","").replace("[","").replace("e+","")) - float(str(list2).replace("]","").replace("[","").replace("e+",""))) <= 0.0001:
        elif abs(float(str(list1).replace("datetime.datetime","").replace("]","").replace("[","").replace("e+","").replace(", ","").replace("(","").replace(")","").replace("-","")) - float(str(list2).replace("datetime.datetime","").replace("]","").replace("[","").replace("e+","").replace(", ","").replace("(","").replace(")","").replace("-",""))) <= 0.0001:
            print(("=====matrix_abs+e+===sql1.list1:'%s',sql2.list2:'%s'") %(list1,list2))
            print(("=====matrix_abs+e+replace_after===sql1.list1:'%s',sql2.list2:'%s'") %(float(str(list1).replace("datetime.datetime","").replace("]","").replace("[","").replace("e+","").replace(", ","").replace("(","").replace(")","").replace("-","")),float(str(list2).replace("datetime.datetime","").replace("]","").replace("[","").replace("e+","").replace(", ","").replace("(","").replace(")","").replace("-",""))))
            tdLog.info(("===matrix_abs+e+===sql1:'%s' matrix_result = sql2:'%s' matrix_result") %(sql1,sql2))
        elif abs(float(str(list1).replace("datetime.datetime","").replace("]","").replace("[","").replace(", ","").replace("(","").replace(")","").replace("-","")) - float(str(list2).replace("datetime.datetime","").replace("]","").replace("[","").replace(", ","").replace("(","").replace(")","").replace("-",""))) <= 0.1:
            #{datetime.datetime(2021, 8, 27, 1, 46, 40), -441.46841430664057}replace
            print(("=====matrix_abs+replace===sql1.list1:'%s',sql2.list2:'%s'") %(list1,list2))
            print(("=====matrix_abs+replace_after===sql1.list1:'%s',sql2.list2:'%s'") %(float(str(list1).replace("datetime.datetime","").replace("]","").replace("[","").replace(", ","").replace("(","").replace(")","").replace("-","")),float(str(list1).replace("datetime.datetime","").replace("]","").replace("[","").replace(", ","").replace("(","").replace(")","").replace("-",""))))
            tdLog.info(("===matrix_abs+replace===sql1:'%s' matrix_result = sql2:'%s' matrix_result") %(sql1,sql2))
        elif abs(float(str(list1).replace("datetime.datetime","").replace("]","").replace("[","").replace(", ","").replace("(","").replace(")","").replace("-","")) - float(str(list2).replace("datetime.datetime","").replace("]","").replace("[","").replace(", ","").replace("(","").replace(")","").replace("-",""))) <= 0.5:
            print(("=====matrix_abs===sql1.list1:'%s',sql2.list2:'%s'") %(list1,list2))
            print(("=====matrix_abs===sql1.list1:'%s',sql2.list2:'%s'") %(float(str(list1).replace("datetime.datetime","").replace("]","").replace("[","").replace(", ","").replace("(","").replace(")","").replace("-","")),float(str(list2).replace("datetime.datetime","").replace("]","").replace("[","").replace(", ","").replace("(","").replace(")","").replace("-",""))))
            tdLog.info(("===matrix_abs======sql1:'%s' matrix_result = sql2:'%s' matrix_result") %(sql1,sql2))
        else:
            print(("=====matrix_error===sql1.list1:'%s',sql2.list2:'%s'") %(list1,list2))
            tdLog.info(("sql1:'%s' matrix_result != sql2:'%s' matrix_result") %(sql1,sql2))
            return tdSql.checkEqual(list1,list2)
G
Ganlin Zhao 已提交
515

516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538
    def restartDnodes(self):
        pass
        # tdDnodes.stop(1)
        # tdDnodes.start(1)

    def dropandcreateDB_random(self,database,n):
        ts = 1630000000000
        num_random = 100
        fake = Faker('zh_CN')
        tdSql.execute('''drop database if exists %s ;''' %database)
        tdSql.execute('''create database %s keep 36500;'''%database)
        tdSql.execute('''use %s;'''%database)

        tdSql.execute('''create stable stable_1 (ts timestamp , q_int int , q_bigint bigint , q_smallint smallint , q_tinyint tinyint , q_float float , q_double double , q_bool bool , q_binary binary(100) , q_nchar nchar(100) , q_ts timestamp , \
                q_binary1 binary(100) , q_nchar1 nchar(100) ,q_binary2 binary(100) , q_nchar2 nchar(100) ,q_binary3 binary(100) , q_nchar3 nchar(100) ,q_binary4 binary(100) , q_nchar4 nchar(100) ,\
                q_binary5 binary(100) , q_nchar5 nchar(100) ,q_binary6 binary(100) , q_nchar6 nchar(100) ,q_binary7 binary(100) , q_nchar7 nchar(100) ,q_binary8 binary(100) , q_nchar8 nchar(100) ,\
                q_int_null int , q_bigint_null bigint , q_smallint_null smallint , q_tinyint_null tinyint, q_float_null float , q_double_null double , q_bool_null bool , q_binary_null binary(20) , q_nchar_null nchar(20) , q_ts_null timestamp) \
                tags(loc nchar(100) , t_int int , t_bigint bigint , t_smallint smallint , t_tinyint tinyint, t_bool bool , t_binary binary(100) , t_nchar nchar(100) ,t_float float , t_double double , t_ts timestamp);''')
        tdSql.execute('''create stable stable_2 (ts timestamp , q_int int , q_bigint bigint , q_smallint smallint , q_tinyint tinyint , q_float float , q_double double , q_bool bool , q_binary binary(100) , q_nchar nchar(100) , q_ts timestamp , \
                q_binary1 binary(100) , q_nchar1 nchar(100) ,q_binary2 binary(100) , q_nchar2 nchar(100) ,q_binary3 binary(100) , q_nchar3 nchar(100) ,q_binary4 binary(100) , q_nchar4 nchar(100) ,\
                q_binary5 binary(100) , q_nchar5 nchar(100) ,q_binary6 binary(100) , q_nchar6 nchar(100) ,q_binary7 binary(100) , q_nchar7 nchar(100) ,q_binary8 binary(100) , q_nchar8 nchar(100) ,\
                q_int_null int , q_bigint_null bigint , q_smallint_null smallint , q_tinyint_null tinyint, q_float_null float , q_double_null double , q_bool_null bool , q_binary_null binary(20) , q_nchar_null nchar(20) , q_ts_null timestamp) \
                tags(loc nchar(100) , t_int int , t_bigint bigint , t_smallint smallint , t_tinyint tinyint, t_bool bool , t_binary binary(100) , t_nchar nchar(100) ,t_float float , t_double double , t_ts timestamp);''')
G
Ganlin Zhao 已提交
539

540 541 542 543 544 545 546 547 548 549 550
        tdSql.execute('''create stable stable_null_data (ts timestamp , q_int int , q_bigint bigint , q_smallint smallint , q_tinyint tinyint , q_float float , q_double double , q_bool bool , q_binary binary(100) , q_nchar nchar(100) , q_ts timestamp , \
                q_binary1 binary(100) , q_nchar1 nchar(100) ,q_binary2 binary(100) , q_nchar2 nchar(100) ,q_binary3 binary(100) , q_nchar3 nchar(100) ,q_binary4 binary(100) , q_nchar4 nchar(100) ,\
                q_binary5 binary(100) , q_nchar5 nchar(100) ,q_binary6 binary(100) , q_nchar6 nchar(100) ,q_binary7 binary(100) , q_nchar7 nchar(100) ,q_binary8 binary(100) , q_nchar8 nchar(100) ,\
                q_int_null int , q_bigint_null bigint , q_smallint_null smallint , q_tinyint_null tinyint, q_float_null float , q_double_null double , q_bool_null bool , q_binary_null binary(20) , q_nchar_null nchar(20) , q_ts_null timestamp) \
                tags(loc nchar(100) , t_int int , t_bigint bigint , t_smallint smallint , t_tinyint tinyint, t_bool bool , t_binary binary(100) , t_nchar nchar(100) ,t_float float , t_double double , t_ts timestamp);''')

        tdSql.execute('''create stable stable_null_childtable (ts timestamp , q_int int , q_bigint bigint , q_smallint smallint , q_tinyint tinyint , q_float float , q_double double , q_bool bool , q_binary binary(100) , q_nchar nchar(100) , q_ts timestamp , \
                q_binary1 binary(100) , q_nchar1 nchar(100) ,q_binary2 binary(100) , q_nchar2 nchar(100) ,q_binary3 binary(100) , q_nchar3 nchar(100) ,q_binary4 binary(100) , q_nchar4 nchar(100) ,\
                q_binary5 binary(100) , q_nchar5 nchar(100) ,q_binary6 binary(100) , q_nchar6 nchar(100) ,q_binary7 binary(100) , q_nchar7 nchar(100) ,q_binary8 binary(100) , q_nchar8 nchar(100) ,\
                q_int_null int , q_bigint_null bigint , q_smallint_null smallint , q_tinyint_null tinyint, q_float_null float , q_double_null double , q_bool_null bool , q_binary_null binary(20) , q_nchar_null nchar(20) , q_ts_null timestamp) \
                tags(loc nchar(100) , t_int int , t_bigint bigint , t_smallint smallint , t_tinyint tinyint, t_bool bool , t_binary binary(100) , t_nchar nchar(100) ,t_float float , t_double double , t_ts timestamp);''')
G
Ganlin Zhao 已提交
551

552
        #tdSql.execute('''create table stable_1_1 using stable_1 tags('stable_1_1', '0' , '0' , '0' , '0' , 0 , 'binary1' , 'nchar1' , '0' , '0' ,'0') ;''')
G
Ganlin Zhao 已提交
553 554 555 556
        tdSql.execute('''create table stable_1_1 using stable_1 tags('stable_1_1', '%d' , '%d', '%d' , '%d' , 0 , 'binary1.%s' , 'nchar1.%s' , '%f', '%f' ,'%d') ;'''
                      %(fake.random_int(min=-2147483647, max=2147483647, step=1), fake.random_int(min=-9223372036854775807, max=9223372036854775807, step=1),
                        fake.random_int(min=-32767, max=32767, step=1) , fake.random_int(min=-127, max=127, step=1) ,
                        fake.pystr() ,fake.pystr() ,fake.pyfloat(),fake.pyfloat(),fake.random_int(min=-2147483647, max=2147483647, step=1)))
557 558 559
        tdSql.execute('''create table stable_1_2 using stable_1 tags('stable_1_2', '2147483647' , '9223372036854775807' , '32767' , '127' , 1 , 'binary2' , 'nchar2' , '2' , '22' , \'1999-09-09 09:09:09.090\') ;''')
        tdSql.execute('''create table stable_1_3 using stable_1 tags('stable_1_3', '-2147483647' , '-9223372036854775807' , '-32767' , '-127' , false , 'binary3' , 'nchar3nchar3' , '-3.3' , '-33.33' , \'2099-09-09 09:09:09.090\') ;''')
        #tdSql.execute('''create table stable_1_4 using stable_1 tags('stable_1_4', '0' , '0' , '0' , '0' , 0 , '0' , '0' , '0' , '0' ,'0') ;''')
G
Ganlin Zhao 已提交
560 561 562 563
        tdSql.execute('''create table stable_1_4 using stable_1 tags('stable_1_4', '%d' , '%d', '%d' , '%d' , 1 , 'binary1.%s' , 'nchar1.%s' , '%f', '%f' ,'%d') ;'''
                      %(fake.random_int(min=-2147483647, max=2147483647, step=1), fake.random_int(min=-9223372036854775807, max=9223372036854775807, step=1),
                        fake.random_int(min=-32767, max=32767, step=1) , fake.random_int(min=-127, max=127, step=1) ,
                        fake.pystr() ,fake.pystr() ,fake.pyfloat(),fake.pyfloat(),fake.random_int(min=-2147483647, max=2147483647, step=1)))
564 565 566 567 568

        # tdSql.execute('''create table stable_2_1 using stable_2 tags('stable_2_1' , '0' , '0' , '0' , '0' , 0 , 'binary21' , 'nchar21' , '0' , '0' ,'0') ;''')
        # tdSql.execute('''create table stable_2_2 using stable_2 tags('stable_2_2' , '0' , '0' , '0' , '0' , 0 , '0' , '0' , '0' , '0' ,'0') ;''')

        # tdSql.execute('''create table stable_null_data_1 using stable_null_data tags('stable_null_data_1', '0' , '0' , '0' , '0' , 0 , '0' , '0' , '0' , '0' ,'0') ;''')
G
Ganlin Zhao 已提交
569

570
        tdSql.execute('''create table stable_2_1 using stable_2 tags('stable_2_1' , '0' , '0' , '0' , '0' , 0 , 'binary21' , 'nchar21' , '0' , '0' ,\'2099-09-09 09:09:09.090\') ;''')
G
Ganlin Zhao 已提交
571 572 573 574
        tdSql.execute('''create table stable_2_2 using stable_2 tags('stable_2_2' , '%d' , '%d', '%d' , '%d' , 0 , 'binary2.%s' , 'nchar2.%s' , '%f', '%f' ,'%d') ;'''
                      %(fake.random_int(min=-2147483647, max=2147483647, step=1), fake.random_int(min=-9223372036854775807, max=9223372036854775807, step=1),
                        fake.random_int(min=-32767, max=32767, step=1) , fake.random_int(min=-127, max=127, step=1) ,
                        fake.pystr() ,fake.pystr() ,fake.pyfloat(),fake.pyfloat(),fake.random_int(min=-2147483647, max=2147483647, step=1)))
575

G
Ganlin Zhao 已提交
576 577 578 579
        tdSql.execute('''create table stable_null_data_1 using stable_null_data tags('stable_null_data_1', '%d' , '%d', '%d' , '%d' , 1 , 'binary1.%s' , 'nchar1.%s' , '%f', '%f' ,'%d') ;'''
                      %(fake.random_int(min=-2147483647, max=2147483647, step=1), fake.random_int(min=-9223372036854775807, max=9223372036854775807, step=1),
                        fake.random_int(min=-32767, max=32767, step=1) , fake.random_int(min=-127, max=127, step=1) ,
                        fake.pystr() ,fake.pystr() ,fake.pyfloat(),fake.pyfloat(),fake.random_int(min=-2147483647, max=2147483647, step=1)))
580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604

        #regular table
        tdSql.execute('''create table regular_table_1 \
                    (ts timestamp , q_int int , q_bigint bigint , q_smallint smallint , q_tinyint tinyint , q_float float , q_double double , q_bool bool , q_binary binary(100) , q_nchar nchar(100) , q_ts timestamp , \
                    q_binary1 binary(100) , q_nchar1 nchar(100) ,q_binary2 binary(100) , q_nchar2 nchar(100) ,q_binary3 binary(100) , q_nchar3 nchar(100) ,q_binary4 binary(100) , q_nchar4 nchar(100) ,\
                    q_binary5 binary(100) , q_nchar5 nchar(100) ,q_binary6 binary(100) , q_nchar6 nchar(100) ,q_binary7 binary(100) , q_nchar7 nchar(100) ,q_binary8 binary(100) , q_nchar8 nchar(100) ,\
                    q_int_null int , q_bigint_null bigint , q_smallint_null smallint , q_tinyint_null tinyint, q_float_null float , q_double_null double , q_bool_null bool , q_binary_null binary(20) , q_nchar_null nchar(20) , q_ts_null timestamp) ;''')
        tdSql.execute('''create table regular_table_2 \
                    (ts timestamp , q_int int , q_bigint bigint , q_smallint smallint , q_tinyint tinyint , q_float float , q_double double , q_bool bool , q_binary binary(100) , q_nchar nchar(100) , q_ts timestamp , \
                    q_binary1 binary(100) , q_nchar1 nchar(100) ,q_binary2 binary(100) , q_nchar2 nchar(100) ,q_binary3 binary(100) , q_nchar3 nchar(100) ,q_binary4 binary(100) , q_nchar4 nchar(100) ,\
                    q_binary5 binary(100) , q_nchar5 nchar(100) ,q_binary6 binary(100) , q_nchar6 nchar(100) ,q_binary7 binary(100) , q_nchar7 nchar(100) ,q_binary8 binary(100) , q_nchar8 nchar(100) ,\
                    q_int_null int , q_bigint_null bigint , q_smallint_null smallint , q_tinyint_null tinyint, q_float_null float , q_double_null double , q_bool_null bool , q_binary_null binary(20) , q_nchar_null nchar(20) , q_ts_null timestamp) ;''')
        tdSql.execute('''create table regular_table_3 \
                    (ts timestamp , q_int int , q_bigint bigint , q_smallint smallint , q_tinyint tinyint , q_float float , q_double double , q_bool bool , q_binary binary(100) , q_nchar nchar(100) , q_ts timestamp , \
                    q_binary1 binary(100) , q_nchar1 nchar(100) ,q_binary2 binary(100) , q_nchar2 nchar(100) ,q_binary3 binary(100) , q_nchar3 nchar(100) ,q_binary4 binary(100) , q_nchar4 nchar(100) ,\
                    q_binary5 binary(100) , q_nchar5 nchar(100) ,q_binary6 binary(100) , q_nchar6 nchar(100) ,q_binary7 binary(100) , q_nchar7 nchar(100) ,q_binary8 binary(100) , q_nchar8 nchar(100) ,\
                    q_int_null int , q_bigint_null bigint , q_smallint_null smallint , q_tinyint_null tinyint, q_float_null float , q_double_null double , q_bool_null bool , q_binary_null binary(20) , q_nchar_null nchar(20) , q_ts_null timestamp) ;''')

        tdSql.execute('''create table regular_table_null \
                    (ts timestamp , q_int int , q_bigint bigint , q_smallint smallint , q_tinyint tinyint , q_float float , q_double double , q_bool bool , q_binary binary(100) , q_nchar nchar(100) , q_ts timestamp , \
                    q_binary1 binary(100) , q_nchar1 nchar(100) ,q_binary2 binary(100) , q_nchar2 nchar(100) ,q_binary3 binary(100) , q_nchar3 nchar(100) ,q_binary4 binary(100) , q_nchar4 nchar(100) ,\
                    q_binary5 binary(100) , q_nchar5 nchar(100) ,q_binary6 binary(100) , q_nchar6 nchar(100) ,q_binary7 binary(100) , q_nchar7 nchar(100) ,q_binary8 binary(100) , q_nchar8 nchar(100) ,\
                    q_int_null int , q_bigint_null bigint , q_smallint_null smallint , q_tinyint_null tinyint, q_float_null float , q_double_null double , q_bool_null bool , q_binary_null binary(20) , q_nchar_null nchar(20) , q_ts_null timestamp) ;''')


G
Ganlin Zhao 已提交
605
        for i in range(num_random*n):
606 607 608
            tdSql.execute('''insert into stable_1_1  (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double , q_bool , q_binary , q_nchar, q_ts,\
                        q_binary1 , q_nchar1 , q_binary2 , q_nchar2 , q_binary3 , q_nchar3 , q_binary4 , q_nchar4 , q_binary5 , q_nchar5 , q_binary6 , q_nchar6 , q_binary7 , q_nchar7, q_binary8 , q_nchar8) \
                        values(%d, %d, %d, %d, %d, %f, %f, 0, 'binary.%s', 'nchar.%s', %d, 'binary1.%s', 'nchar1.%s', 'binary2.%s', 'nchar2.%s', 'binary3.%s', 'nchar3.%s', \
G
Ganlin Zhao 已提交
609 610 611 612 613
                        'binary4.%s', 'nchar4.%s', 'binary5.%s', 'nchar5.%s', 'binary6.%s', 'nchar6.%s', 'binary7.%s', 'nchar7.%s', 'binary8.%s', 'nchar8.%s') ;'''
                        % (ts + i*1000, fake.random_int(min=-2147483647, max=2147483647, step=1),
                        fake.random_int(min=-9223372036854775807, max=9223372036854775807, step=1),
                        fake.random_int(min=-32767, max=32767, step=1) , fake.random_int(min=-127, max=127, step=1) ,
                        fake.pyfloat() , fake.pyfloat() , fake.pystr() , fake.address() , ts + i , fake.pystr() , fake.address() , fake.pystr() , fake.address() , fake.pystr() , fake.address() ,
614 615 616 617
                        fake.pystr() , fake.address() , fake.pystr() , fake.address() , fake.pystr() , fake.address() , fake.pystr() , fake.address() , fake.pystr() , fake.address()))
            tdSql.execute('''insert into  regular_table_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts,\
                        q_binary1 , q_nchar1 , q_binary2 , q_nchar2 , q_binary3 , q_nchar3 , q_binary4 , q_nchar4 , q_binary5 , q_nchar5 , q_binary6 , q_nchar6 , q_binary7 , q_nchar7, q_binary8 , q_nchar8) \
                        values(%d, %d, %d, %d, %d, %f, %f, 0, 'binary.%s', 'nchar.%s', %d, 'binary1.%s', 'nchar1.%s', 'binary2.%s', 'nchar2.%s', 'binary3.%s', 'nchar3.%s', \
G
Ganlin Zhao 已提交
618 619 620 621 622
                        'binary4.%s', 'nchar4.%s', 'binary5.%s', 'nchar5.%s', 'binary6.%s', 'nchar6.%s', 'binary7.%s', 'nchar7.%s', 'binary8.%s', 'nchar8.%s') ;'''
                        % (ts + i*1000, fake.random_int(min=-2147483647, max=2147483647, step=1) ,
                        fake.random_int(min=-9223372036854775807, max=9223372036854775807, step=1) ,
                        fake.random_int(min=-32767, max=32767, step=1) , fake.random_int(min=-127, max=127, step=1) ,
                        fake.pyfloat() , fake.pyfloat() , fake.pystr() , fake.address() , ts + i, fake.pystr() , fake.address() , fake.pystr() , fake.address() , fake.pystr() , fake.address() ,
623 624 625 626 627
                        fake.pystr() , fake.address() , fake.pystr() , fake.address() , fake.pystr() , fake.address() , fake.pystr() , fake.address() , fake.pystr() , fake.address()))

            tdSql.execute('''insert into stable_1_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts,\
                        q_binary1 , q_nchar1 , q_binary2 , q_nchar2 , q_binary3 , q_nchar3 , q_binary4 , q_nchar4 , q_binary5 , q_nchar5 , q_binary6 , q_nchar6 , q_binary7 , q_nchar7, q_binary8 , q_nchar8)\
                        values(%d, %d, %d, %d, %d, %f, %f, 1, 'binary.%s', 'nchar.%s', %d, 'binary1.%s', 'nchar1.%s', 'binary2.%s', 'nchar2.%s', 'binary3.%s', 'nchar3.%s', \
G
Ganlin Zhao 已提交
628 629 630 631 632
                        'binary4.%s', 'nchar4.%s', 'binary5.%s', 'nchar5.%s', 'binary6.%s', 'nchar6.%s', 'binary7.%s', 'nchar7.%s', 'binary8.%s', 'nchar8.%s') ;'''
                        % (ts + i*1000, fake.random_int(min=0, max=2147483647, step=1),
                        fake.random_int(min=0, max=9223372036854775807, step=1),
                        fake.random_int(min=0, max=32767, step=1) , fake.random_int(min=0, max=127, step=1) ,
                        fake.pyfloat() , fake.pyfloat() , fake.pystr() , fake.address() , ts + i, fake.pystr() , fake.address() , fake.pystr() , fake.address() , fake.pystr() , fake.address() ,
633 634 635 636
                        fake.pystr() , fake.address() , fake.pystr() , fake.address() , fake.pystr() , fake.address() , fake.pystr() , fake.address() , fake.pystr() , fake.address()))
            tdSql.execute('''insert into regular_table_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts,\
                        q_binary1 , q_nchar1 , q_binary2 , q_nchar2 , q_binary3 , q_nchar3 , q_binary4 , q_nchar4 , q_binary5 , q_nchar5 , q_binary6 , q_nchar6 , q_binary7 , q_nchar7, q_binary8 , q_nchar8) \
                        values(%d, %d, %d, %d, %d, %f, %f, 1, 'binary.%s', 'nchar.%s', %d, 'binary1.%s', 'nchar1.%s', 'binary2.%s', 'nchar2.%s', 'binary3.%s', 'nchar3.%s', \
G
Ganlin Zhao 已提交
637 638 639 640 641
                        'binary4.%s', 'nchar4.%s', 'binary5.%s', 'nchar5.%s', 'binary6.%s', 'nchar6.%s', 'binary7.%s', 'nchar7.%s', 'binary8.%s', 'nchar8.%s') ;'''
                        % (ts + i*1000, fake.random_int(min=0, max=2147483647, step=1),
                        fake.random_int(min=0, max=9223372036854775807, step=1),
                        fake.random_int(min=0, max=32767, step=1) , fake.random_int(min=0, max=127, step=1) ,
                        fake.pyfloat() , fake.pyfloat() , fake.pystr() , fake.address() , ts + i, fake.pystr() , fake.address() , fake.pystr() , fake.address() , fake.pystr() , fake.address() ,
642
                        fake.pystr() , fake.address() , fake.pystr() , fake.address() , fake.pystr() , fake.address() , fake.pystr() , fake.address() , fake.pystr() , fake.address()))
G
Ganlin Zhao 已提交
643

644 645 646
            tdSql.execute('''insert into stable_1_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts,\
                        q_binary1 , q_nchar1 , q_binary2 , q_nchar2 , q_binary3 , q_nchar3 , q_binary4 , q_nchar4 , q_binary5 , q_nchar5 , q_binary6 , q_nchar6 , q_binary7 , q_nchar7, q_binary8 , q_nchar8) \
                        values(%d, %d, %d, %d, %d, %f, %f, 1, 'binary.%s', 'nchar.%s', %d, 'binary1.%s', 'nchar1.%s', 'binary2.%s', 'nchar2.%s', 'binary3.%s', 'nchar3.%s', \
G
Ganlin Zhao 已提交
647 648 649 650 651
                        'binary4.%s', 'nchar4.%s', 'binary5.%s', 'nchar5.%s', 'binary6.%s', 'nchar6.%s', 'binary7.%s', 'nchar7.%s', 'binary8.%s', 'nchar8.%s') ;'''
                        % (ts + i*1000 +1, fake.random_int(min=-2147483647, max=0, step=1),
                        fake.random_int(min=-9223372036854775807, max=0, step=1),
                        fake.random_int(min=-32767, max=0, step=1) , fake.random_int(min=-127, max=0, step=1) ,
                        fake.pyfloat() , fake.pyfloat() , fake.pystr() , fake.address() , ts + i +1, fake.pystr() , fake.address() , fake.pystr() , fake.address() , fake.pystr() , fake.address() ,
652 653 654 655
                        fake.pystr() , fake.address() , fake.pystr() , fake.address() , fake.pystr() , fake.address() , fake.pystr() , fake.address() , fake.pystr() , fake.address()))
            tdSql.execute('''insert into regular_table_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts,\
                        q_binary1 , q_nchar1 , q_binary2 , q_nchar2 , q_binary3 , q_nchar3 , q_binary4 , q_nchar4 , q_binary5 , q_nchar5 , q_binary6 , q_nchar6 , q_binary7 , q_nchar7, q_binary8 , q_nchar8) \
                        values(%d, %d, %d, %d, %d, %f, %f, 1, 'binary.%s', 'nchar.%s', %d, 'binary1.%s', 'nchar1.%s', 'binary2.%s', 'nchar2.%s', 'binary3.%s', 'nchar3.%s', \
G
Ganlin Zhao 已提交
656 657 658 659 660
                        'binary4.%s', 'nchar4.%s', 'binary5.%s', 'nchar5.%s', 'binary6.%s', 'nchar6.%s', 'binary7.%s', 'nchar7.%s', 'binary8.%s', 'nchar8.%s') ;'''
                        % (ts + i*1000 +1, fake.random_int(min=-2147483647, max=0, step=1),
                        fake.random_int(min=-9223372036854775807, max=0, step=1),
                        fake.random_int(min=-32767, max=0, step=1) , fake.random_int(min=-127, max=0, step=1) ,
                        fake.pyfloat() , fake.pyfloat() , fake.pystr() , fake.address() , ts + i +1, fake.pystr() , fake.address() , fake.pystr() , fake.address() , fake.pystr() , fake.address() ,
661 662 663 664 665
                        fake.pystr() , fake.address() , fake.pystr() , fake.address() , fake.pystr() , fake.address() , fake.pystr() , fake.address() , fake.pystr() , fake.address()))

            tdSql.execute('''insert into stable_2_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts,\
                        q_binary1 , q_nchar1 , q_binary2 , q_nchar2 , q_binary3 , q_nchar3 , q_binary4 , q_nchar4 , q_binary5 , q_nchar5 , q_binary6 , q_nchar6 , q_binary7 , q_nchar7, q_binary8 , q_nchar8) \
                        values(%d, %d, %d, %d, %d, %f, %f, 0, 'binary.%s', 'nchar.%s', %d, 'binary1.%s', 'nchar1.%s', 'binary2.%s', 'nchar2.%s', 'binary3.%s', 'nchar3.%s', \
G
Ganlin Zhao 已提交
666 667 668 669 670
                        'binary4.%s', 'nchar4.%s', 'binary5.%s', 'nchar5.%s', 'binary6.%s', 'nchar6.%s', 'binary7.%s', 'nchar7.%s', 'binary8.%s', 'nchar8.%s') ;'''
                        % (ts + i*1000, fake.random_int(min=-0, max=2147483647, step=1),
                        fake.random_int(min=-0, max=9223372036854775807, step=1),
                        fake.random_int(min=-0, max=32767, step=1) , fake.random_int(min=-0, max=127, step=1) ,
                        fake.pyfloat() , fake.pyfloat() , fake.pystr() , fake.address() , ts + i, fake.pystr() , fake.address() , fake.pystr() , fake.address() , fake.pystr() , fake.address() ,
671 672 673 674 675
                        fake.pystr() , fake.address() , fake.pystr() , fake.address() , fake.pystr() , fake.address() , fake.pystr() , fake.address() , fake.pystr() , fake.address()))

            tdSql.execute('''insert into stable_2_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts,\
                        q_binary1 , q_nchar1 , q_binary2 , q_nchar2 , q_binary3 , q_nchar3 , q_binary4 , q_nchar4 , q_binary5 , q_nchar5 , q_binary6 , q_nchar6 , q_binary7 , q_nchar7, q_binary8 , q_nchar8) \
                        values(%d, %d, %d, %d, %d, %f, %f, 0, 'binary.%s', 'nchar.%s', %d, 'binary1.%s', 'nchar1.%s', 'binary2.%s', 'nchar2.%s', 'binary3.%s', 'nchar3.%s', \
G
Ganlin Zhao 已提交
676 677 678 679 680
                        'binary4.%s', 'nchar4.%s', 'binary5.%s', 'nchar5.%s', 'binary6.%s', 'nchar6.%s', 'binary7.%s', 'nchar7.%s', 'binary8.%s', 'nchar8.%s') ;'''
                        % (ts + i*1000 +1, fake.random_int(min=-0, max=2147483647, step=1),
                        fake.random_int(min=-0, max=9223372036854775807, step=1),
                        fake.random_int(min=-0, max=32767, step=1) , fake.random_int(min=-0, max=127, step=1) ,
                        fake.pyfloat() , fake.pyfloat() , fake.pystr() , fake.address() , ts + i, fake.pystr() , fake.address() , fake.pystr() , fake.address() , fake.pystr() , fake.address() ,
681 682 683 684 685
                        fake.pystr() , fake.address() , fake.pystr() , fake.address() , fake.pystr() , fake.address() , fake.pystr() , fake.address() , fake.pystr() , fake.address()))

            tdSql.execute('''insert into stable_2_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts,\
                        q_binary1 , q_nchar1 , q_binary2 , q_nchar2 , q_binary3 , q_nchar3 , q_binary4 , q_nchar4 , q_binary5 , q_nchar5 , q_binary6 , q_nchar6 , q_binary7 , q_nchar7, q_binary8 , q_nchar8) \
                        values(%d, %d, %d, %d, %d, %f, %f, 0, 'binary.%s', 'nchar.%s', %d, 'binary1.%s', 'nchar1.%s', 'binary2.%s', 'nchar2.%s', 'binary3.%s', 'nchar3.%s', \
G
Ganlin Zhao 已提交
686 687 688 689 690
                        'binary4.%s', 'nchar4.%s', 'binary5.%s', 'nchar5.%s', 'binary6.%s', 'nchar6.%s', 'binary7.%s', 'nchar7.%s', 'binary8.%s', 'nchar8.%s') ;'''
                        % (ts + i*1000 +10, fake.random_int(min=-0, max=2147483647, step=1),
                        fake.random_int(min=-0, max=9223372036854775807, step=1),
                        fake.random_int(min=-0, max=32767, step=1) , fake.random_int(min=-0, max=127, step=1) ,
                        fake.pyfloat() , fake.pyfloat() , fake.pystr() , fake.address() , ts + i, fake.pystr() , fake.address() , fake.pystr() , fake.address() , fake.pystr() , fake.address() ,
691 692 693 694 695 696 697 698
                        fake.pystr() , fake.address() , fake.pystr() , fake.address() , fake.pystr() , fake.address() , fake.pystr() , fake.address() , fake.pystr() , fake.address()))

        tdSql.query("select count(*) from stable_1;")
        tdSql.checkData(0,0,3*num_random*n)
        tdSql.query("select count(*) from regular_table_1;")
        tdSql.checkData(0,0,num_random*n)

    def math_nest(self,mathlist):
G
Ganlin Zhao 已提交
699 700 701 702

        print("==========%s===start=============" %mathlist)
        os.system("rm -rf %s/%s.sql" % (self.testcasePath,self.testcaseFilename))

703
        self.dropandcreateDB_random("%s" %self.db_nest, 1)
G
Ganlin Zhao 已提交
704

705 706
        if (mathlist == ['ABS','SQRT']) or (mathlist == ['SIN','COS','TAN','ASIN','ACOS','ATAN']) or (mathlist == ['FLOOR','CEIL','ROUND']) \
            or (mathlist == ['CSUM']) or (mathlist == ['']):
G
Ganlin Zhao 已提交
707 708
            math_functions = mathlist
            fun_fix_column = ['(q_bigint)','(q_smallint)','(q_tinyint)','(q_int)','(q_float)','(q_double)','(q_bigint_null)','(q_smallint_null)','(q_tinyint_null)','(q_int_null)','(q_float_null)','(q_double_null)']
709 710 711 712
            fun_column_1 = random.sample(math_functions,1)+random.sample(fun_fix_column,1)
            math_fun_1 = str(fun_column_1).replace("[","").replace("]","").replace("'","").replace(", ","")
            fun_column_2 = random.sample(math_functions,1)+random.sample(fun_fix_column,1)
            math_fun_2 = str(fun_column_2).replace("[","").replace("]","").replace("'","").replace(", ","")
G
Ganlin Zhao 已提交
713

714
            fun_fix_column_j = ['(t1.q_bigint)','(t1.q_smallint)','(t1.q_tinyint)','(t1.q_int)','(t1.q_float)','(t1.q_double)','(t1.q_bigint_null)','(t1.q_smallint_null)','(t1.q_tinyint_null)','(t1.q_int_null)','(t1.q_float_null)','(t1.q_double_null)',
G
Ganlin Zhao 已提交
715
                            '(t2.q_bigint)','(t2.q_smallint)','(t2.q_tinyint)','(t2.q_int)','(t2.q_float)','(t2.q_double)','(t2.q_bigint_null)','(t2.q_smallint_null)','(t2.q_tinyint_null)','(t2.q_int_null)','(t2.q_float_null)','(t2.q_double_null)']
716 717 718 719
            fun_column_join_1 = random.sample(math_functions,1)+random.sample(fun_fix_column_j,1)
            math_fun_join_1 = str(fun_column_join_1).replace("[","").replace("]","").replace("'","").replace(", ","")
            fun_column_join_2 = random.sample(math_functions,1)+random.sample(fun_fix_column_j,1)
            math_fun_join_2 = str(fun_column_join_2).replace("[","").replace("]","").replace("'","").replace(", ","")
G
Ganlin Zhao 已提交
720

721
        elif (mathlist == ['UNIQUE']) or (mathlist == ['HYPERLOGLOG']):
G
Ganlin Zhao 已提交
722
            math_functions = mathlist
723
            fun_fix_column = ['(q_bigint)','(q_smallint)','(q_tinyint)','(q_int)','(q_float)','(q_double)','(q_binary)','(q_nchar)','(q_bool)','(q_ts)',
G
Ganlin Zhao 已提交
724
                '(q_bigint_null)','(q_smallint_null)','(q_tinyint_null)','(q_int_null)','(q_float_null)','(q_double_null)','(q_binary_null)','(q_nchar_null)','(q_bool_null)','(q_ts_null)']
725 726 727 728
            fun_column_1 = random.sample(math_functions,1)+random.sample(fun_fix_column,1)
            math_fun_1 = str(fun_column_1).replace("[","").replace("]","").replace("'","").replace(", ","")
            fun_column_2 = random.sample(math_functions,1)+random.sample(fun_fix_column,1)
            math_fun_2 = str(fun_column_2).replace("[","").replace("]","").replace("'","").replace(", ","")
G
Ganlin Zhao 已提交
729

730
            fun_fix_column_j = ['(t1.q_bigint)','(t1.q_smallint)','(t1.q_tinyint)','(t1.q_int)','(t1.q_float)','(t1.q_double)','(t1.q_bigint_null)','(t1.q_smallint_null)','(t1.q_tinyint_null)','(t1.q_int_null)','(t1.q_float_null)','(t1.q_double_null)',
G
Ganlin Zhao 已提交
731
                            '(t2.q_bigint)','(t2.q_smallint)','(t2.q_tinyint)','(t2.q_int)','(t2.q_float)','(t2.q_double)','(t2.q_bigint_null)','(t2.q_smallint_null)','(t2.q_tinyint_null)','(t2.q_int_null)','(t2.q_float_null)','(t2.q_double_null)']
732 733 734 735 736 737
            fun_column_join_1 = random.sample(math_functions,1)+random.sample(fun_fix_column_j,1)
            math_fun_join_1 = str(fun_column_join_1).replace("[","").replace("]","").replace("'","").replace(", ","")
            fun_column_join_2 = random.sample(math_functions,1)+random.sample(fun_fix_column_j,1)
            math_fun_join_2 = str(fun_column_join_2).replace("[","").replace("]","").replace("'","").replace(", ","")

        elif (mathlist == ['POW','LOG']) or (mathlist == ['MAVG']) or (mathlist == ['SAMPLE']) or (mathlist == ['TAIL']):
G
Ganlin Zhao 已提交
738 739
            math_functions = mathlist
            num = random.randint(0, 1000)
740
            fun_fix_column = ['(q_bigint,num)','(q_smallint,num)','(q_tinyint,num)','(q_int,num)','(q_float,num)','(q_double,num)',
G
Ganlin Zhao 已提交
741
                              '(q_bigint_null,num)','(q_smallint_null,num)','(q_tinyint_null,num)','(q_int_null,num)','(q_float_null,num)','(q_double_null,num)']
742 743 744 745
            fun_column_1 = random.sample(math_functions,1)+random.sample(fun_fix_column,1)
            math_fun_1 = str(fun_column_1).replace("[","").replace("]","").replace("'","").replace(", ","").replace("num",str(num))
            fun_column_2 = random.sample(math_functions,1)+random.sample(fun_fix_column,1)
            math_fun_2 = str(fun_column_2).replace("[","").replace("]","").replace("'","").replace(", ","").replace("num",str(num))
G
Ganlin Zhao 已提交
746

747 748 749
            fun_fix_column_j = ['(t1.q_bigint,num)','(t1.q_smallint,num)','(t1.q_tinyint,num)','(t1.q_int,num)','(t1.q_float,num)','(t1.q_double,num)',
                    '(t1.q_bigint_null,num)','(t1.q_smallint_null,num)','(t1.q_tinyint_null,num)','(t1.q_int_null,num)','(t1.q_float_null,num)','(t1.q_double_null,num)',
                    '(t2.q_bigint,num)','(t2.q_smallint,num)','(t2.q_tinyint,num)','(t2.q_int,num)','(t2.q_float,num)','(t2.q_double,num)',
G
Ganlin Zhao 已提交
750
                    '(t2.q_bigint_null,num)','(t2.q_smallint_null,num)','(t2.q_tinyint_null,num)','(t2.q_int_null,num)','(t2.q_float_null,num)','(t2.q_double_null,num)']
751 752 753 754
            fun_column_join_1 = random.sample(math_functions,1)+random.sample(fun_fix_column_j,1)
            math_fun_join_1 = str(fun_column_join_1).replace("[","").replace("]","").replace("'","").replace(", ","").replace("num",str(num))
            fun_column_join_2 = random.sample(math_functions,1)+random.sample(fun_fix_column_j,1)
            math_fun_join_2 = str(fun_column_join_2).replace("[","").replace("]","").replace("'","").replace(", ","").replace("num",str(num))
G
Ganlin Zhao 已提交
755

756 757 758 759
        tdSql.query("select 1-1 as math_nest from stable_1 limit 1;")
        for i in range(self.fornum):
            if (mathlist == ['SIN','COS','TAN','ASIN','ACOS','ATAN']) or (mathlist == ['ABS','SQRT'])  \
                or (mathlist == ['POW','LOG']) or (mathlist == ['FLOOR','CEIL','ROUND']) :
G
Ganlin Zhao 已提交
760 761 762
                sql = "select  ts , floor(asct1)  from  ( select  "
                sql += "%s as asct1, " % math_fun_1
                sql += "%s as asct2, " % math_fun_2
763
                sql += "%s, " % random.choice(self.s_s_select)
G
Ganlin Zhao 已提交
764
                sql += "%s, " % random.choice(self.q_select)
765 766 767 768
                sql += "ts from regular_table_1 where "
                sql += "%s " % random.choice(self.q_where)
                sql += "%s " % random.choice(self.order_where)
                sql += ");"
G
Ganlin Zhao 已提交
769 770
                tdLog.info(sql)
                tdLog.info(len(sql))
771 772 773 774 775
                tdSql.query(sql)
                tdSql.checkRows(100)
                self.cur1.execute(sql)
            elif (mathlist == ['MAVG']) or (mathlist == ['SAMPLE'])or (mathlist == ['TAIL']) or (mathlist == ['CSUM']) \
                or (mathlist == ['HYPERLOGLOG']) or (mathlist == ['UNIQUE']):
G
Ganlin Zhao 已提交
776 777 778
                sql = "select   floor(asct1)  from  ( select  "
                sql += "%s as asct1 " % math_fun_1
                # sql += "%s as asct2, " % math_fun_2
779
                # sql += "%s, " % random.choice(self.s_s_select)
G
Ganlin Zhao 已提交
780
                # sql += "%s, " % random.choice(self.q_select)
781 782 783 784
                sql += " from regular_table_1 where "
                sql += "%s " % random.choice(self.q_where)
                #sql += "%s " % random.choice(self.order_where)
                sql += ");"
G
Ganlin Zhao 已提交
785 786
                tdLog.info(sql)
                tdLog.info(len(sql))
787 788 789
                tdSql.query(sql)
                #tdSql.checkRows(100)
                self.cur1.execute(sql)
G
Ganlin Zhao 已提交
790

791 792 793 794 795
        tdSql.query("select 1-2 as math_nest from stable_1 limit 1;")
        for i in range(self.fornum):
            if (mathlist == ['SIN','COS','TAN','ASIN','ACOS','ATAN']) or (mathlist == ['ABS','SQRT'])  \
                or (mathlist == ['POW','LOG']) or (mathlist == ['FLOOR','CEIL','ROUND']) :
                sql = "select  ts , abs(asct1) from  ( select  "
G
Ganlin Zhao 已提交
796
                sql += "%s as asct1,  " % math_fun_1
797
                sql += "%s, " % random.choice(self.s_s_select)
G
Ganlin Zhao 已提交
798
                sql += "%s, " % random.choice(self.q_select)
799 800 801
                sql += "ts ts from regular_table_1 where "
                sql += "%s " % random.choice(self.q_where)
                sql += "%s )" % random.choice(self.order_where)
G
Ganlin Zhao 已提交
802
                sql += "%s " % random.choice(self.unionall_or_union)
803
                sql += "select  ts , asct2 from  ( select  "
G
Ganlin Zhao 已提交
804
                sql += "%s as asct2,  " % math_fun_2
805
                sql += "%s, " % random.choice(self.s_s_select)
G
Ganlin Zhao 已提交
806
                sql += "%s, " % random.choice(self.q_select)
807
                sql += "ts ts from regular_table_1 where "
G
Ganlin Zhao 已提交
808
                sql += "%s " % random.choice(self.q_where)
809 810 811 812
                #sql += "%s " % random.choice(having_support)
                sql += "%s " % random.choice(self.order_where)
                sql += "%s " % random.choice(self.limit1_where)
                sql += ")"
G
Ganlin Zhao 已提交
813 814
                tdLog.info(sql)
                tdLog.info(len(sql))
815
                #TD-15437 tdSql.query(sql)
G
Ganlin Zhao 已提交
816
                #TD-15437 self.cur1.execute(sql)
817
            elif (mathlist == ['MAVG']) or (mathlist == ['SAMPLE'])or (mathlist == ['TAIL']) or (mathlist == ['CSUM']) \
G
Ganlin Zhao 已提交
818
                or (mathlist == ['HYPERLOGLOG'])  or (mathlist == ['UNIQUE']):
819
                sql = "select  abs(asct1) from  ( select  "
G
Ganlin Zhao 已提交
820
                sql += "%s as asct1  " % math_fun_1
821
                # sql += "%s, " % random.choice(self.s_s_select)
G
Ganlin Zhao 已提交
822
                # sql += "%s, " % random.choice(self.q_select)
823 824 825
                sql += "from regular_table_1 where "
                sql += "%s )" % random.choice(self.q_where)
                #sql += "%s )" % random.choice(self.order_where)
G
Ganlin Zhao 已提交
826
                sql += "%s " % random.choice(self.unionall_or_union)
827
                sql += "select   floor(asct2) from  ( select  "
G
Ganlin Zhao 已提交
828
                sql += "%s as asct2  " % math_fun_2
829
                # sql += "%s, " % random.choice(self.s_s_select)
G
Ganlin Zhao 已提交
830
                # sql += "%s, " % random.choice(self.q_select)
831
                sql += " from regular_table_1 where "
G
Ganlin Zhao 已提交
832
                sql += "%s " % random.choice(self.q_where)
833 834 835 836
                #sql += "%s " % random.choice(having_support)
                #sql += "%s " % random.choice(self.order_where)
                sql += "%s " % random.choice(self.limit1_where)
                sql += ")"
G
Ganlin Zhao 已提交
837 838
                tdLog.info(sql)
                tdLog.info(len(sql))
839
                #TD-15473 tdSql.query(sql)
G
Ganlin Zhao 已提交
840 841
                #TD-15473 self.cur1.execute(sql)

842 843 844 845 846 847 848 849
        tdSql.query("select 1-3 as math_nest from stable_1 limit 1;")
        for i in range(self.fornum):
            if (mathlist == ['SIN','COS','TAN','ASIN','ACOS','ATAN']) or (mathlist == ['ABS','SQRT'])  \
                or (mathlist == ['POW','LOG']) or (mathlist == ['FLOOR','CEIL','ROUND']) :
                sql = "select  ts , min(asct1) from  ( select  "
                sql += "%s as asct1, ts ," % math_fun_1
                sql += "%s as asct2, " % math_fun_2
                sql += "%s, " % random.choice(self.s_s_select)
G
Ganlin Zhao 已提交
850
                sql += "%s, " % random.choice(self.q_select)
851 852
                sql += "ts from regular_table_1 where "
                sql += "%s " % random.choice(self.q_where)
G
Ganlin Zhao 已提交
853
                sql += "%s select " % random.choice(self.unionall_or_union)
854 855 856
                sql += "%s as asct2, ts ," % math_fun_2
                sql += "%s as asct1, " % math_fun_1
                sql += "%s, " % random.choice(self.s_s_select)
G
Ganlin Zhao 已提交
857
                sql += "%s, " % random.choice(self.q_select)
858 859 860 861
                sql += "ts from regular_table_2 where "
                sql += "%s " % random.choice(self.q_where)
                sql += "%s " % random.choice(self.order_where)
                sql += ")"
G
Ganlin Zhao 已提交
862 863
                tdLog.info(sql)
                tdLog.info(len(sql))
864 865 866 867 868 869 870 871
                #TD-15473 tdSql.query(sql)
                #self.cur1.execute(sql)
            elif (mathlist == ['MAVG']) or (mathlist == ['SAMPLE'])or (mathlist == ['TAIL']) or (mathlist == ['CSUM']) \
                or (mathlist == ['HYPERLOGLOG']) or (mathlist == ['UNIQUE']):
                sql = "select  ts , min(asct1) from  ( select  "
                sql += "%s as asct1, ts ," % math_fun_1
                sql += "%s as asct2, " % math_fun_2
                sql += "%s, " % random.choice(self.s_s_select)
G
Ganlin Zhao 已提交
872
                sql += "%s, " % random.choice(self.q_select)
873 874
                sql += "ts from regular_table_1 where "
                sql += "%s " % random.choice(self.q_where)
G
Ganlin Zhao 已提交
875
                sql += "%s select " % random.choice(self.unionall_or_union)
876 877 878
                sql += "%s as asct2, ts ," % math_fun_2
                sql += "%s as asct1, " % math_fun_1
                sql += "%s, " % random.choice(self.s_s_select)
G
Ganlin Zhao 已提交
879
                sql += "%s, " % random.choice(self.q_select)
880 881 882 883
                sql += "ts from regular_table_2 where "
                sql += "%s " % random.choice(self.q_where)
                sql += "%s " % random.choice(self.order_where)
                sql += ")"
G
Ganlin Zhao 已提交
884 885
                tdLog.info(sql)
                tdLog.info(len(sql))
886 887
                #TD-15473 tdSql.query(sql)
                #self.cur1.execute(sql)
G
Ganlin Zhao 已提交
888

889 890 891 892 893
        tdSql.query("select 1-4 as math_nest from stable_1 limit 1;")
        for i in range(self.fornum):
            if (mathlist == ['SIN','COS','TAN','ASIN','ACOS','ATAN']) or (mathlist == ['ABS','SQRT'])  \
                or (mathlist == ['POW','LOG']) or (mathlist == ['FLOOR','CEIL','ROUND']) :
                sql = "select  ts , asct1 from  ( select  t1.ts as ts,"
G
Ganlin Zhao 已提交
894 895 896 897 898
                sql += "%s, " % math_fun_join_1
                sql += "%s as asct1, " % math_fun_join_2
                sql += "%s, " % math_fun_join_1
                sql += "t1.%s, " % random.choice(self.q_select)
                sql += "t2.%s, " % random.choice(self.q_select)
899 900 901 902 903
                sql += "t2.ts from regular_table_1 t1 , regular_table_2 t2 where t1.ts = t2.ts and "
                sql += "%s " % random.choice(self.q_u_where)
                sql += "and %s " % random.choice(self.q_u_or_where)
                sql += "%s " % random.choice(self.order_u_where)
                sql += ");"
G
Ganlin Zhao 已提交
904 905
                tdLog.info(sql)
                tdLog.info(len(sql))
906 907 908 909 910 911
                tdSql.query(sql)
                tdSql.checkRows(100)
                self.cur1.execute(sql)
            elif (mathlist == ['MAVG']) or (mathlist == ['SAMPLE'])or (mathlist == ['TAIL']) or (mathlist == ['CSUM'])\
                or (mathlist == ['HYPERLOGLOG']) or (mathlist == ['UNIQUE']):
                sql = "select  count(asct1) from  ( select  "
G
Ganlin Zhao 已提交
912
                sql += "%s as asct1 " % math_fun_join_2
913 914 915 916
                sql += "from regular_table_1 t1 , regular_table_2 t2 where t1.ts = t2.ts and "
                sql += "%s " % random.choice(self.q_u_where)
                sql += "and %s " % random.choice(self.q_u_or_where)
                sql += ");"
G
Ganlin Zhao 已提交
917 918
                tdLog.info(sql)
                tdLog.info(len(sql))
919 920
                tdSql.query(sql)
                self.cur1.execute(sql)
G
Ganlin Zhao 已提交
921

922 923 924 925 926
        tdSql.query("select 1-5 as math_nest from stable_1 limit 1;")
        for i in range(self.fornum):
            if (mathlist == ['SIN','COS','TAN','ASIN','ACOS','ATAN']) or (mathlist == ['ABS','SQRT'])  \
                or (mathlist == ['POW','LOG']) or (mathlist == ['FLOOR','CEIL','ROUND']) :
                sql = "select  ts ,"
G
Ganlin Zhao 已提交
927 928
                sql += "%s, " % math_fun_1
                sql += "%s, " % random.choice(self.q_select)
929 930 931 932 933 934
                sql += "%s, " % random.choice(self.q_select)
                sql += "%s  " % math_fun_2
                sql += " from  ( select  * from regular_table_1 ) where "
                sql += "%s " % random.choice(self.q_where)
                sql += "%s " % random.choice(self.order_where)
                sql += " ;"
G
Ganlin Zhao 已提交
935 936
                tdLog.info(sql)
                tdLog.info(len(sql))
937 938 939 940 941 942
                tdSql.query(sql)
                tdSql.checkRows(100)
                self.cur1.execute(sql)
            elif (mathlist == ['MAVG']) or (mathlist == ['SAMPLE'])or (mathlist == ['TAIL']) or (mathlist == ['CSUM'])\
                or (mathlist == ['HYPERLOGLOG']) or (mathlist == ['UNIQUE']):
                sql = "select "
G
Ganlin Zhao 已提交
943 944
                # sql += "%s, " % math_fun_1
                # sql += "%s, " % random.choice(self.q_select)
945 946 947 948 949
                # sql += "%s, " % random.choice(self.q_select)
                sql += "%s  " % math_fun_2
                sql += " from  ( select  * from regular_table_1 ) where "
                sql += "%s " % random.choice(self.q_where)
                sql += " ;"
G
Ganlin Zhao 已提交
950 951
                tdLog.info(sql)
                tdLog.info(len(sql))
952 953 954 955 956 957 958 959
                #TD-15973 tdSql.query(sql)
                #TD-15973 self.cur1.execute(sql)

        tdSql.query("select 1-6 as math_nest from stable_1 limit 1;")
        for i in range(self.fornum):
            if (mathlist == ['SIN','COS','TAN','ASIN','ACOS','ATAN']) or (mathlist == ['ABS','SQRT'])  \
                or (mathlist == ['POW','LOG']) or (mathlist == ['FLOOR','CEIL','ROUND']) :
                sql = "select  ts , max(asct1) from  ( select  t1.ts as ts,"
G
Ganlin Zhao 已提交
960 961 962 963 964
                sql += "%s, " % math_fun_join_1
                sql += "%s as asct1, " % math_fun_join_2
                sql += "t1.%s, " % random.choice(self.q_select)
                sql += "t2.%s, " % random.choice(self.q_select)
                sql += "%s, " % math_fun_join_1
965 966 967 968 969
                sql += "t2.ts from regular_table_1 t1 , regular_table_2 t2 where t1.ts = t2.ts and "
                sql += "%s " % random.choice(self.q_u_where)
                sql += "and %s  )" % random.choice(self.q_u_or_where)
                sql += "%s " % random.choice(self.order_where)
                sql += "%s " % random.choice(self.limit1_where)
G
Ganlin Zhao 已提交
970 971 972
                tdLog.info(sql)
                tdLog.info(len(sql))
                tdSql.query(sql)
973 974 975 976
                self.cur1.execute(sql)
            elif (mathlist == ['MAVG']) or (mathlist == ['SAMPLE'])or (mathlist == ['TAIL']) or (mathlist == ['CSUM']) \
                or (mathlist == ['HYPERLOGLOG']) or (mathlist == ['UNIQUE']):
                sql = "select  max(asct1) from  ( select "
G
Ganlin Zhao 已提交
977 978 979 980 981
                #sql += "%s, " % math_fun_join_1
                sql += "%s as asct1 " % math_fun_join_2
                # sql += "t1.%s, " % random.choice(self.q_select)
                # sql += "t2.%s, " % random.choice(self.q_select)
                # sql += "%s, " % math_fun_join_1
982 983 984 985
                sql += "from regular_table_1 t1 , regular_table_2 t2 where t1.ts = t2.ts and "
                sql += "%s " % random.choice(self.q_u_where)
                sql += "and %s  )" % random.choice(self.q_u_or_where)
                sql += "%s " % random.choice(self.limit1_where)
G
Ganlin Zhao 已提交
986 987 988
                tdLog.info(sql)
                tdLog.info(len(sql))
                tdSql.query(sql)
989 990 991 992 993 994 995 996 997
                self.cur1.execute(sql)

        tdSql.query("select 1-7 as math_nest from stable_1 limit 1;")
        for i in range(self.fornum):
            if (mathlist == ['SIN','COS','TAN','ASIN','ACOS','ATAN']) or (mathlist == ['ABS','SQRT'])  \
                or (mathlist == ['POW','LOG']) or (mathlist == ['FLOOR','CEIL','ROUND']) :
                sql = "select  ts , abs(asct1) from  ( select  "
                sql += "%s as asct1, ts ," % math_fun_1
                sql += "%s as asct2, " % math_fun_2
G
Ganlin Zhao 已提交
998 999
                sql += "%s, " % random.choice(self.q_select)
                sql += "%s, " % random.choice(self.t_select)
1000 1001 1002 1003
                sql += "ts from stable_1 where "
                sql += "%s " % random.choice(self.qt_where)
                sql += "%s " % random.choice(self.order_where)
                sql += ") ;"
G
Ganlin Zhao 已提交
1004
                tdLog.info(sql)
1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015
                tdLog.info(len(sql))
                # tdSql.query(sql)
                # tdSql.checkRows(300)
                # self.cur1.execute(sql)# TD-16039
            elif (mathlist == ['MAVG']) or (mathlist == ['SAMPLE']) or (mathlist == ['TAIL']) or (mathlist == ['CSUM'])\
                or (mathlist == ['HYPERLOGLOG']) or (mathlist == ['UNIQUE']):
                sql = "select   abs(asct1) from  ( select  "
                sql += "%s as asct1 " % math_fun_1
                sql += "from stable_1 where "
                sql += "%s " % random.choice(self.qt_where)
                sql += ") ;"
G
Ganlin Zhao 已提交
1016
                tdLog.info(sql)
1017 1018 1019
                tdLog.info(len(sql))
                # tdSql.query(sql)
                # self.cur1.execute(sql)# TD-16039
G
Ganlin Zhao 已提交
1020

1021 1022 1023 1024 1025 1026 1027 1028 1029
        tdSql.query("select 1-8 as math_nest from stable_1 limit 1;")
        for i in range(self.fornum):
            if (mathlist == ['SIN','COS','TAN','ASIN','ACOS','ATAN']) or (mathlist == ['ABS','SQRT'])  \
                or (mathlist == ['POW','LOG']) or (mathlist == ['FLOOR','CEIL','ROUND']) :
                sql = "select  ts,floor(asct1) "
                sql += "from  ( select  "
                sql += "%s, " % random.choice(self.s_s_select)
                sql += "%s as asct1, ts ," % math_fun_1
                sql += "%s as asct2, " % math_fun_2
G
Ganlin Zhao 已提交
1030 1031
                sql += "%s, " % random.choice(self.q_select)
                sql += "%s, " % random.choice(self.t_select)
1032 1033 1034 1035
                sql += "ts from stable_1 where "
                sql += "%s " % random.choice(self.qt_where)
                sql += "%s " % random.choice(self.order_where)
                sql += ") ;"
G
Ganlin Zhao 已提交
1036
                tdLog.info(sql)
1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048
                tdLog.info(len(sql))
                #tdSql.query(sql)
                # tdSql.checkRows(300)
                # self.cur1.execute(sql)# TD-16039
            elif (mathlist == ['MAVG']) or (mathlist == ['SAMPLE'])or (mathlist == ['TAIL']) or (mathlist == ['CSUM'])\
                or (mathlist == ['HYPERLOGLOG']) or (mathlist == ['UNIQUE']):
                sql = "select  floor(asct1) "
                sql += "from  ( select  "
                sql += "%s as asct1 " % math_fun_1
                sql += " from stable_1 where "
                sql += "%s " % random.choice(self.qt_where)
                sql += ") ;"
G
Ganlin Zhao 已提交
1049
                tdLog.info(sql)
1050 1051 1052 1053 1054 1055 1056 1057 1058
                tdLog.info(len(sql))
                # tdSql.query(sql)
                # self.cur1.execute(sql)# TD-16039

        tdSql.query("select 1-9 as math_nest from stable_1 limit 1;")
        for i in range(self.fornum):
            if (mathlist == ['SIN','COS','TAN','ASIN','ACOS','ATAN']) or (mathlist == ['ABS','SQRT'])  \
                or (mathlist == ['POW','LOG']) or (mathlist == ['FLOOR','CEIL','ROUND']) :
                sql = "select  ts , max(asct1) from  ( select  t1.ts as ts,"
G
Ganlin Zhao 已提交
1059 1060 1061 1062 1063 1064
                sql += "%s, " % math_fun_join_1
                sql += "%s as asct1, " % math_fun_join_2
                sql += "t1.%s, " % random.choice(self.q_select)
                sql += "t1.%s, " % random.choice(self.q_select)
                sql += "t2.%s, " % random.choice(self.q_select)
                sql += "t2.%s, " % random.choice(self.q_select)
1065 1066 1067 1068 1069 1070 1071
                sql += "t2.ts from stable_1 t1 , stable_2 t2 where t1.ts = t2.ts and "
                sql += "%s " % random.choice(self.t_join_where)
                sql += "and %s " % random.choice(self.t_u_where)
                sql += "and %s " % random.choice(self.t_u_or_where)
                sql += "%s " % random.choice(self.order_u_where)
                sql += "%s " % random.choice(self.limit1_where)
                sql += ") ;"
G
Ganlin Zhao 已提交
1072 1073
                tdLog.info(sql)
                tdLog.info(len(sql))
1074 1075 1076 1077
                # tdSql.query(sql)
                # self.cur1.execute(sql)# TD-16039
            elif (mathlist == ['MAVG']) or (mathlist == ['SAMPLE'])or (mathlist == ['TAIL']) or (mathlist == ['CSUM'])\
                or (mathlist == ['HYPERLOGLOG']) or (mathlist == ['UNIQUE']):
G
Ganlin Zhao 已提交
1078 1079 1080 1081 1082 1083
                sql = "select  max(asct1) from  ( select  "
                sql += "%s as asct1 " % math_fun_join_2
                # sql += "t1.%s, " % random.choice(self.q_select)
                # sql += "t1.%s, " % random.choice(self.q_select)
                # sql += "t2.%s, " % random.choice(self.q_select)
                # sql += "t2.%s, " % random.choice(self.q_select)
1084 1085 1086 1087 1088 1089
                sql += "from stable_1 t1 , stable_2 t2 where t1.ts = t2.ts and "
                sql += "%s " % random.choice(self.t_join_where)
                sql += "and %s " % random.choice(self.t_u_where)
                sql += "and %s " % random.choice(self.t_u_or_where)
                sql += "%s " % random.choice(self.limit1_where)
                sql += ") ;"
G
Ganlin Zhao 已提交
1090 1091
                tdLog.info(sql)
                tdLog.info(len(sql))
1092 1093
                # tdSql.query(sql)# TD-16039
                # self.cur1.execute(sql)
G
Ganlin Zhao 已提交
1094

1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118
        self.restartDnodes()
        tdSql.query("select 1-10 as math_nest from stable_1 limit 1;")
        for i in range(self.fornum):
            if (mathlist == ['SIN','COS','TAN','ASIN','ACOS','ATAN']) or (mathlist == ['ABS','SQRT'])  \
                or (mathlist == ['POW','LOG']) or (mathlist == ['FLOOR','CEIL','ROUND']) :
                sql = "select  ts , min(asct1) from  ( select  "
                sql += "%s as asct1, ts ," % math_fun_1
                sql += "%s as asct2, " % math_fun_2
                sql += "%s, " % random.choice(self.s_r_select)
                sql += "%s, " % random.choice(self.q_select)
                sql += "ts from stable_1 where "
                sql += "%s " % random.choice(self.q_where)
                sql += "%s " % random.choice(self.order_where)
                sql += ") %s " % random.choice(self.unionall_or_union)
                sql += "select  ts , max(asct2) from  ( select  "
                sql += "%s as asct1, ts ," % math_fun_1
                sql += "%s as asct2, " % math_fun_2
                sql += "%s, " % random.choice(self.s_r_select)
                sql += "%s, " % random.choice(self.q_select)
                sql += "ts from stable_2 where "
                sql += "%s " % random.choice(self.q_where)
                sql += "%s " % random.choice(self.order_where)
                sql += "%s " % random.choice(self.limit1_where)
                sql += ")"
G
Ganlin Zhao 已提交
1119 1120
                tdLog.info(sql)
                tdLog.info(len(sql))
1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135
                #TD-15437 tdSql.query(sql)
                #TD-15437 self.cur1.execute(sql)
            elif (mathlist == ['MAVG']) or (mathlist == ['SAMPLE'])or (mathlist == ['TAIL']) or (mathlist == ['CSUM']) \
                or (mathlist == ['HYPERLOGLOG']) or (mathlist == ['UNIQUE']):
                sql = "select  min(asct1) from  ( select  "
                sql += "%s as asct1 " % math_fun_1
                sql += " from stable_1 where "
                sql += "%s " % random.choice(self.q_where)
                sql += ") %s " % random.choice(self.unionall_or_union)
                sql += "select  max(asct2) from  ( select  "
                sql += "%s as asct2 " % math_fun_2
                sql += "from stable_2 where "
                sql += "%s " % random.choice(self.q_where)
                sql += "%s " % random.choice(self.limit1_where)
                sql += ")"
G
Ganlin Zhao 已提交
1136 1137
                tdLog.info(sql)
                tdLog.info(len(sql))
1138 1139
                #TD-15437 tdSql.query(sql)
                #TD-15437 self.cur1.execute(sql)
G
Ganlin Zhao 已提交
1140

1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165
        #3 inter union not support
        tdSql.query("select 1-11 as math_nest from stable_1 limit 1;")
        for i in range(self.fornum):
            if (mathlist == ['SIN','COS','TAN','ASIN','ACOS','ATAN']) or (mathlist == ['ABS','SQRT'])  \
                or (mathlist == ['POW','LOG']) or (mathlist == ['FLOOR','CEIL','ROUND']) :
                sql = "select  ts , min(asct1), max(asct2) from  ( select  "
                sql += "%s as asct1, ts ," % math_fun_1
                sql += "%s as asct2, " % math_fun_2
                sql += "%s, " % random.choice(self.s_r_select)
                sql += "%s, " % random.choice(self.q_select)
                sql += "ts from stable_1 where "
                sql += "%s " % random.choice(self.q_where)
                sql += "%s " % random.choice(self.order_where)
                #sql += "%s " % random.choice(limit1_where)
                sql += " %s "  % random.choice(self.unionall_or_union)
                sql += " select  "
                sql += "%s as asct1, ts ," % math_fun_1
                sql += "%s as asct2, " % math_fun_2
                sql += "%s, " % random.choice(self.s_r_select)
                sql += "%s, " % random.choice(self.q_select)
                sql += "ts from stable_2 where "
                sql += "%s " % random.choice(self.q_where)
                sql += "%s " % random.choice(self.order_where)
                sql += "%s " % random.choice(self.limit1_where)
                sql += ")"
G
Ganlin Zhao 已提交
1166 1167
                tdLog.info(sql)
                tdLog.info(len(sql))
1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182
                #TD-15837 tdSql.query(sql)
                # self.cur1.execute(sql)
            elif (mathlist == ['MAVG']) or (mathlist == ['SAMPLE'])or (mathlist == ['TAIL']) or (mathlist == ['CSUM']) \
                or (mathlist == ['HYPERLOGLOG']) or (mathlist == ['UNIQUE']):
                sql = "select   min(asct1) from  ( select  "
                sql += "%s as asct1 " % math_fun_1
                sql += " from stable_1 where "
                sql += "%s " % random.choice(self.q_where)
                sql += " %s "  % random.choice(self.unionall_or_union)
                sql += " select  "
                sql += "%s as asct2 " % math_fun_2
                sql += " from stable_2 where "
                sql += "%s " % random.choice(self.q_where)
                sql += "%s " % random.choice(self.limit1_where)
                sql += ")"
G
Ganlin Zhao 已提交
1183 1184
                tdLog.info(sql)
                tdLog.info(len(sql))
1185 1186 1187 1188 1189 1190 1191 1192
                #TD-15837 tdSql.query(sql)
                #self.cur1.execute(sql)

        tdSql.query("select 1-12 as math_nest from stable_1 limit 1;")
        for i in range(self.fornum):
            if (mathlist == ['SIN','COS','TAN','ASIN','ACOS','ATAN']) or (mathlist == ['ABS','SQRT'])  \
                or (mathlist == ['POW','LOG']) or (mathlist == ['FLOOR','CEIL','ROUND']) :
                sql = "select  ts , max(asct1) from  ( select  t1.ts as ts,"
G
Ganlin Zhao 已提交
1193 1194 1195 1196 1197 1198
                sql += "%s, " % math_fun_join_1
                sql += "%s as asct1, " % math_fun_join_2
                sql += "t1.%s, " % random.choice(self.q_select)
                sql += "t1.%s, " % random.choice(self.q_select)
                sql += "t2.%s, " % random.choice(self.q_select)
                sql += "t2.%s, " % random.choice(self.q_select)
1199 1200 1201 1202 1203 1204
                sql += "t2.ts from stable_1 t1 , stable_2 t2 where t1.ts = t2.ts and "
                sql += "%s " % random.choice(self.t_u_where)
                sql += "and %s " % random.choice(self.t_u_or_where)
                sql += "%s " % random.choice(self.order_u_where)
                sql += "%s " % random.choice(self.limit1_where)
                sql += ");"
G
Ganlin Zhao 已提交
1205 1206
                tdLog.info(sql)
                tdLog.info(len(sql))
1207 1208 1209 1210
                # tdSql.query(sql)
                # self.cur1.execute(sql)# TD-16039
            elif (mathlist == ['MAVG']) or (mathlist == ['SAMPLE'])or (mathlist == ['TAIL']) or (mathlist == ['CSUM'])\
                or (mathlist == ['HYPERLOGLOG']) or (mathlist == ['UNIQUE']):
G
Ganlin Zhao 已提交
1211 1212
                sql = "select max(asct1) from  ( select  "
                sql += "%s as asct1 " % math_fun_join_2
1213 1214 1215 1216 1217
                sql += " from stable_1 t1 , stable_2 t2 where t1.ts = t2.ts and "
                sql += "%s " % random.choice(self.t_u_where)
                sql += "and %s " % random.choice(self.t_u_or_where)
                sql += "%s " % random.choice(self.limit1_where)
                sql += ");"
G
Ganlin Zhao 已提交
1218 1219
                tdLog.info(sql)
                tdLog.info(len(sql))
1220 1221
                # tdSql.query(sql)
                # self.cur1.execute(sql)# TD-16039
G
Ganlin Zhao 已提交
1222

1223 1224 1225 1226 1227
        tdSql.query("select 1-13 as math_nest from stable_1 limit 1;")
        for i in range(self.fornum):
            if (mathlist == ['SIN','COS','TAN','ASIN','ACOS','ATAN']) or (mathlist == ['ABS','SQRT'])  \
                or (mathlist == ['POW','LOG']) or (mathlist == ['FLOOR','CEIL','ROUND']) :
                sql = "select  ts ,"
G
Ganlin Zhao 已提交
1228 1229
                sql += "%s, " % math_fun_1
                sql += "%s, " % random.choice(self.q_select)
1230 1231
                sql += "%s, " % random.choice(self.q_select)
                sql += "%s  " % math_fun_2
G
Ganlin Zhao 已提交
1232
                sql += "%s  " % random.choice(self.t_select)
1233 1234 1235 1236
                sql += " from  ( select  * from stable_1 where "
                sql += "%s " % random.choice(self.qt_where)
                sql += "%s " % random.choice(self.order_where)
                sql += ") ;"
G
Ganlin Zhao 已提交
1237 1238
                tdLog.info(sql)
                tdLog.info(len(sql))
1239 1240 1241 1242 1243 1244 1245
                # tdSql.query(sql)
                # tdSql.checkRows(300)
                # self.cur1.execute(sql) # TD-16039
            elif (mathlist == ['MAVG']) or (mathlist == ['SAMPLE'])or (mathlist == ['TAIL']) or (mathlist == ['CSUM']) \
                or (mathlist == ['HYPERLOGLOG']) or (mathlist == ['UNIQUE']):
                sql = "select  "
                sql += "%s  " % math_fun_2
G
Ganlin Zhao 已提交
1246
                sql += "%s  " % random.choice(self.t_select)
1247 1248 1249
                sql += " from  ( select  * from stable_1 where "
                sql += "%s " % random.choice(self.qt_where)
                sql += ") ;"
G
Ganlin Zhao 已提交
1250 1251
                tdLog.info(sql)
                tdLog.info(len(sql))
1252 1253
                #TD15973 tdSql.query(sql)
                #TD15973 self.cur1.execute(sql)
G
Ganlin Zhao 已提交
1254

1255 1256 1257 1258 1259
        tdSql.query("select 1-14 as math_nest from stable_1 limit 1;")
        for i in range(self.fornum):
            if (mathlist == ['SIN','COS','TAN','ASIN','ACOS','ATAN']) or (mathlist == ['ABS','SQRT'])  \
                or (mathlist == ['POW','LOG']) or (mathlist == ['FLOOR','CEIL','ROUND']) :
                sql = "select  avg(asct1),count(asct2) from ( select "
G
Ganlin Zhao 已提交
1260
                sql += "%s as asct1, " % math_fun_1
1261 1262 1263 1264 1265 1266 1267
                sql += "%s as asct2" % math_fun_2
                sql += "  from stable_1 where "
                sql += "%s " % random.choice(self.q_where)
                sql += "%s " % random.choice(self.partiton_where)
                sql += "%s " % random.choice(self.order_desc_where)
                sql += "%s " % random.choice([self.limit_where[2] , self.limit_where[3]] )
                sql += " ) ;"
G
Ganlin Zhao 已提交
1268 1269
                tdLog.info(sql)
                tdLog.info(len(sql))
1270 1271 1272 1273 1274
                # tdSql.query(sql)
                # self.cur1.execute(sql)  # TD-16039
            elif (mathlist == ['MAVG']) or (mathlist == ['SAMPLE'])or (mathlist == ['TAIL']) or (mathlist == ['CSUM'])\
                or (mathlist == ['HYPERLOGLOG']) or (mathlist == ['UNIQUE']):
                sql = "select  avg(asct1) from ( select "
G
Ganlin Zhao 已提交
1275
                sql += "%s as asct1 " % math_fun_1
1276 1277 1278 1279 1280
                sql += "  from stable_1 where "
                sql += "%s " % random.choice(self.q_where)
                sql += "%s " % random.choice(self.partiton_where)
                sql += "%s " % random.choice([self.limit_where[2] , self.limit_where[3]] )
                sql += " ) ;"
G
Ganlin Zhao 已提交
1281 1282
                tdLog.info(sql)
                tdLog.info(len(sql))
1283 1284
                # tdSql.query(sql)
                # self.cur1.execute(sql)  # TD-16039
G
Ganlin Zhao 已提交
1285

1286 1287 1288 1289 1290
        tdSql.query("select 1-15 as math_nest from stable_1 limit 1;")
        for i in range(self.fornum):
            if (mathlist == ['SIN','COS','TAN','ASIN','ACOS','ATAN']) or (mathlist == ['ABS','SQRT'])  \
                or (mathlist == ['POW','LOG']) or (mathlist == ['FLOOR','CEIL','ROUND']) :
                sql = "select  ts , max(asct1) from  ( select  t1.ts as ts,"
G
Ganlin Zhao 已提交
1291 1292 1293 1294 1295 1296
                sql += "%s, " % math_fun_join_1
                sql += "%s as asct1, " % math_fun_join_2
                sql += "t1.%s, " % random.choice(self.q_select)
                sql += "t1.%s, " % random.choice(self.q_select)
                sql += "t2.%s, " % random.choice(self.q_select)
                sql += "t2.%s " % random.choice(self.q_select)
1297 1298 1299 1300 1301
                sql += "from stable_1  t1, stable_2 t2 where t1.ts = t2.ts and  "
                sql += "%s " % random.choice(self.t_join_where)
                sql += " and %s " % random.choice(self.qt_u_or_where)
                sql += "%s " % random.choice(self.partiton_where_j)
                sql += "%s " % random.choice(self.slimit1_where)
G
Ganlin Zhao 已提交
1302
                sql += ") "
1303 1304
                sql += "%s " % random.choice(self.order_desc_where)
                sql += "%s ;" % random.choice(self.limit_u_where)
G
Ganlin Zhao 已提交
1305 1306
                tdLog.info(sql)
                tdLog.info(len(sql))
1307 1308 1309
                # tdSql.query(sql)
                # self.cur1.execute(sql) # TD-16039
            elif (mathlist == ['MAVG']) or (mathlist == ['SAMPLE']) or (mathlist == ['TAIL']) or (mathlist == ['CSUM'])\
G
Ganlin Zhao 已提交
1310 1311 1312
                or (mathlist == ['HYPERLOGLOG']) or (mathlist == ['UNIQUE']):
                sql = "select  max(asct1) from  ( select  "
                sql += "%s as asct1 " % math_fun_join_2
1313 1314 1315 1316 1317
                sql += "from stable_1  t1, stable_2 t2 where t1.ts = t2.ts and  "
                sql += "%s " % random.choice(self.t_join_where)
                sql += " and %s " % random.choice(self.qt_u_or_where)
                sql += "%s " % random.choice(self.partiton_where_j)
                sql += "%s " % random.choice(self.slimit1_where)
G
Ganlin Zhao 已提交
1318
                sql += ") "
1319
                sql += "%s ;" % random.choice(self.limit_u_where)
G
Ganlin Zhao 已提交
1320 1321
                tdLog.info(sql)
                tdLog.info(len(sql))
1322 1323
                # tdSql.query(sql)
                # self.cur1.execute(sql) # TD-16039
G
Ganlin Zhao 已提交
1324

1325 1326 1327 1328 1329 1330 1331
        #taos -f sql
        startTime_taos_f = time.time()
        print("taos -f %s sql start!" %mathlist)
        taos_cmd1 = "taos -f %s/%s.sql" % (self.testcasePath,self.testcaseFilename)
        _ = subprocess.check_output(taos_cmd1, shell=True).decode("utf-8")
        print("taos -f %s sql over!" %mathlist)
        endTime_taos_f = time.time()
G
Ganlin Zhao 已提交
1332 1333 1334
        print("taos_f total time %ds" % (endTime_taos_f - startTime_taos_f))

        print("=========%s====over=============" %mathlist)
1335 1336 1337


    def str_nest(self,strlist):
G
Ganlin Zhao 已提交
1338 1339 1340 1341

        print("==========%s===start=============" %strlist)
        os.system("rm -rf %s/%s.sql" % (self.testcasePath,self.testcaseFilename))

1342
        self.dropandcreateDB_random("%s" %self.db_nest, 1)
G
Ganlin Zhao 已提交
1343

1344 1345
        if (strlist == ['LTRIM','RTRIM','LOWER','UPPER']) or (strlist == ['LENGTH','CHAR_LENGTH'])  \
            or (strlist == ['']):
G
Ganlin Zhao 已提交
1346 1347
            str_functions = strlist
            fun_fix_column = ['(q_nchar)','(q_binary)','(q_nchar_null)','(q_binary_null)']
1348 1349 1350 1351
            fun_column_1 = random.sample(str_functions,1)+random.sample(fun_fix_column,1)
            str_fun_1 = str(fun_column_1).replace("[","").replace("]","").replace("'","").replace(", ","")
            fun_column_2 = random.sample(str_functions,1)+random.sample(fun_fix_column,1)
            str_fun_2 = str(fun_column_2).replace("[","").replace("]","").replace("'","").replace(", ","")
G
Ganlin Zhao 已提交
1352

1353
            fun_fix_column_j = ['(t1.q_nchar)','(t1.q_binary)','(t1.q_nchar_null)','(t1.q_binary_null)',
G
Ganlin Zhao 已提交
1354
                            '(t2.q_nchar)','(t2.q_binary)','(t2.q_nchar_null)','(t2.q_binary_null)']
1355 1356 1357 1358
            fun_column_join_1 = random.sample(str_functions,1)+random.sample(fun_fix_column_j,1)
            str_fun_join_1 = str(fun_column_join_1).replace("[","").replace("]","").replace("'","").replace(", ","")
            fun_column_join_2 = random.sample(str_functions,1)+random.sample(fun_fix_column_j,1)
            str_fun_join_2 = str(fun_column_join_2).replace("[","").replace("]","").replace("'","").replace(", ","")
G
Ganlin Zhao 已提交
1359 1360

            fun_fix_column_s = ['(q_nchar)','(q_binary)','(q_nchar_null)','(q_binary_null)','(loc)','(tbname)']
1361 1362 1363 1364
            fun_column_s_1 = random.sample(str_functions,1)+random.sample(fun_fix_column_s,1)
            str_fun_s_1 = str(fun_column_s_1).replace("[","").replace("]","").replace("'","").replace(", ","")
            fun_column_s_2 = random.sample(str_functions,1)+random.sample(fun_fix_column_s,1)
            str_fun_s_2 = str(fun_column_s_2).replace("[","").replace("]","").replace("'","").replace(", ","")
G
Ganlin Zhao 已提交
1365

1366
            fun_fix_column_s_j = ['(t1.q_nchar)','(t1.q_binary)','(t1.q_nchar_null)','(t1.q_binary_null)','(t1.loc)','(t1.tbname)',
G
Ganlin Zhao 已提交
1367
                            '(t2.q_nchar)','(t2.q_binary)','(t2.q_nchar_null)','(t2.q_binary_null)','(t2.loc)','(t2.tbname)']
1368 1369 1370 1371
            fun_column_join_s_1 = random.sample(str_functions,1)+random.sample(fun_fix_column_j,1)
            str_fun_join_s_1 = str(fun_column_join_1).replace("[","").replace("]","").replace("'","").replace(", ","")
            fun_column_join_s_2 = random.sample(str_functions,1)+random.sample(fun_fix_column_j,1)
            str_fun_join_s_2 = str(fun_column_join_2).replace("[","").replace("]","").replace("'","").replace(", ","")
G
Ganlin Zhao 已提交
1372

1373
        elif (strlist == ['SUBSTR']) :
G
Ganlin Zhao 已提交
1374 1375 1376
            str_functions = strlist
            pos = random.randint(1, 20)
            sub_len = random.randint(1, 10)
1377
            fun_fix_column = ['(q_nchar,pos)','(q_binary,pos)','(q_nchar_null,pos)','(q_binary_null,pos)',
G
Ganlin Zhao 已提交
1378
                '(q_nchar,pos,sub_len)','(q_binary,pos,sub_len)','(q_nchar_null,pos,sub_len)','(q_binary_null,pos,sub_len)',]
1379 1380 1381 1382
            fun_column_1 = random.sample(str_functions,1)+random.sample(fun_fix_column,1)
            str_fun_1 = str(fun_column_1).replace("[","").replace("]","").replace("'","").replace(", ","").replace("pos",str(pos)).replace("sub_len",str(sub_len))
            fun_column_2 = random.sample(str_functions,1)+random.sample(fun_fix_column,1)
            str_fun_2 = str(fun_column_2).replace("[","").replace("]","").replace("'","").replace(", ","").replace("pos",str(pos)).replace("sub_len",str(sub_len))
G
Ganlin Zhao 已提交
1383

1384 1385 1386
            fun_fix_column_j = ['(t1.q_nchar,pos)','(t1.q_binary,pos)','(t1.q_nchar_null,pos)','(t1.q_binary_null,pos)',
                    '(t1.q_nchar,pos,sub_len)','(t1.q_binary,pos,sub_len)','(t1.q_nchar_null,pos,sub_len)','(t1.q_binary_null,pos,sub_len)',
                    '(t2.q_nchar,pos)','(t2.q_binary,pos)','(t2.q_nchar_null,pos)','(t2.q_binary_null,pos)',
G
Ganlin Zhao 已提交
1387
                    '(t2.q_nchar,pos,sub_len)','(t2.q_binary,pos,sub_len)','(t2.q_nchar_null,pos,sub_len)','(t2.q_binary_null,pos,sub_len)']
1388 1389 1390 1391
            fun_column_join_1 = random.sample(str_functions,1)+random.sample(fun_fix_column_j,1)
            str_fun_join_1 = str(fun_column_join_1).replace("[","").replace("]","").replace("'","").replace(", ","").replace("pos",str(pos)).replace("sub_len",str(sub_len))
            fun_column_join_2 = random.sample(str_functions,1)+random.sample(fun_fix_column_j,1)
            str_fun_join_2 = str(fun_column_join_2).replace("[","").replace("]","").replace("'","").replace(", ","").replace("pos",str(pos)).replace("sub_len",str(sub_len))
G
Ganlin Zhao 已提交
1392

1393
            fun_fix_column_s = ['(q_nchar,pos)','(q_binary,pos)','(q_nchar_null,pos)','(q_binary_null,pos)','(loc,pos)',
G
Ganlin Zhao 已提交
1394
                '(q_nchar,pos,sub_len)','(q_binary,pos,sub_len)','(q_nchar_null,pos,sub_len)','(q_binary_null,pos,sub_len)','(loc,pos,sub_len)',]
1395 1396 1397 1398
            fun_column_s_1 = random.sample(str_functions,1)+random.sample(fun_fix_column_s,1)
            str_fun_s_1 = str(fun_column_1).replace("[","").replace("]","").replace("'","").replace(", ","").replace("pos",str(pos)).replace("sub_len",str(sub_len))
            fun_column_s_2 = random.sample(str_functions,1)+random.sample(fun_fix_column_s,1)
            str_fun_s_2 = str(fun_column_2).replace("[","").replace("]","").replace("'","").replace(", ","").replace("pos",str(pos)).replace("sub_len",str(sub_len))
G
Ganlin Zhao 已提交
1399

1400 1401 1402
            fun_fix_column_s_j = ['(t1.q_nchar,pos)','(t1.q_binary,pos)','(t1.q_nchar_null,pos)','(t1.q_binary_null,pos)','(t1.loc,pos)',
                    '(t1.q_nchar,pos,sub_len)','(t1.q_binary,pos,sub_len)','(t1.q_nchar_null,pos,sub_len)','(t1.q_binary_null,pos,sub_len)','(t1.loc,pos,sub_len)',
                    '(t2.q_nchar,pos)','(t2.q_binary,pos)','(t2.q_nchar_null,pos)','(t2.q_binary_null,pos)','(t2.loc,pos)',
G
Ganlin Zhao 已提交
1403
                    '(t2.q_nchar,pos,sub_len)','(t2.q_binary,pos,sub_len)','(t2.q_nchar_null,pos,sub_len)','(t2.q_binary_null,pos,sub_len)','(t2.loc,pos,sub_len)']
1404 1405 1406 1407
            fun_column_join_s_1 = random.sample(str_functions,1)+random.sample(fun_fix_column_s_j,1)
            str_fun_join_s_1 = str(fun_column_join_1).replace("[","").replace("]","").replace("'","").replace(", ","").replace("pos",str(pos)).replace("sub_len",str(sub_len))
            fun_column_join_s_2 = random.sample(str_functions,1)+random.sample(fun_fix_column_s_j,1)
            str_fun_join_s_2 = str(fun_column_join_2).replace("[","").replace("]","").replace("'","").replace(", ","").replace("pos",str(pos)).replace("sub_len",str(sub_len))
G
Ganlin Zhao 已提交
1408

1409
        elif (strlist == ['CONCAT']) :
G
Ganlin Zhao 已提交
1410 1411
            str_functions = strlist
            i = random.randint(2,8)
1412
            fun_fix_column = ['q_nchar','q_nchar1','q_nchar2','q_nchar3','q_nchar4','q_nchar5','q_nchar6','q_nchar7','q_nchar8','q_nchar_null',
G
Ganlin Zhao 已提交
1413 1414 1415
                              'q_binary','q_binary1','q_binary2','q_binary3','q_binary4','q_binary5','q_binary6','q_binary7','q_binary8','q_binary_null']

            column1 = str(random.sample(fun_fix_column,i)).replace("[","").replace("]","").replace("'","")
1416 1417
            fun_column_1 = str(random.sample(str_functions,1))+'('+column1+')'
            str_fun_1 = str(fun_column_1).replace("[","").replace("]","").replace("'","")
G
Ganlin Zhao 已提交
1418

1419 1420 1421
            column2 = str(random.sample(fun_fix_column,i)).replace("[","").replace("]","").replace("'","")
            fun_column_2 = str(random.sample(str_functions,1))+'('+column2+')'
            str_fun_2 = str(fun_column_2).replace("[","").replace("]","").replace("'","")
G
Ganlin Zhao 已提交
1422

1423 1424 1425
            fun_fix_column_j = ['(t1.q_nchar)','(t1.q_nchar1)','(t1.q_nchar2)','(t1.q_nchar3)','(t1.q_nchar4)','(t1.q_nchar5)','(t1.q_nchar6)','(t1.q_nchar7)','(t1.q_nchar8)','(t1.q_nchar_null)',
                    '(t2.q_nchar)','(t2.q_nchar1)','(t2.q_nchar2)','(t2.q_nchar3)','(t2.q_nchar4)','(t2.q_nchar5)','(t2.q_nchar6)','(t2.q_nchar7)','(t2.q_nchar8)','(t2.q_nchar_null)',
                    '(t1.q_binary)','(t1.q_binary1)','(t1.q_binary2)','(t1.q_binary3)','(t1.q_binary4)','(t1.q_binary5)','(t1.q_binary6)','(t1.q_binary7)','(t1.q_binary8)','(t1.q_binary_null)',
G
Ganlin Zhao 已提交
1426 1427 1428
                    '(t2.q_binary)','(t2.q_binary1)','(t2.q_binary2)','(t2.q_binary3)','(t2.q_binary4)','(t2.q_binary5)','(t2.q_binary6)','(t2.q_binary7)','(t2.q_binary8)','(t2.q_binary_null)']

            column_j1 = str(random.sample(fun_fix_column_j,i)).replace("[","").replace("]","").replace("'","")
1429 1430
            fun_column_join_1 = str(random.sample(str_functions,1))+'('+column_j1+')'
            str_fun_join_1 = str(fun_column_join_1).replace("[","").replace("]","").replace("'","")
G
Ganlin Zhao 已提交
1431 1432

            column_j2 = str(random.sample(fun_fix_column_j,i)).replace("[","").replace("]","").replace("'","")
1433 1434
            fun_column_join_2 = str(random.sample(str_functions,1))+'('+column_j2+')'
            str_fun_join_2 = str(fun_column_join_2).replace("[","").replace("]","").replace("'","")
G
Ganlin Zhao 已提交
1435

1436
            fun_fix_column_s = ['q_nchar','q_nchar1','q_nchar2','q_nchar3','q_nchar4','q_nchar5','q_nchar6','q_nchar7','q_nchar8','loc','q_nchar_null',
G
Ganlin Zhao 已提交
1437 1438 1439
                              'q_binary','q_binary1','q_binary2','q_binary3','q_binary4','q_binary5','q_binary6','q_binary7','q_binary8','q_binary_null']

            column_s1 = str(random.sample(fun_fix_column,i)).replace("[","").replace("]","").replace("'","")
1440 1441
            fun_column_s_1 = str(random.sample(str_functions,1))+'('+column_s1+')'
            str_fun_s_1 = str(fun_column_s_1).replace("[","").replace("]","").replace("'","")
G
Ganlin Zhao 已提交
1442 1443

            column_s2 = str(random.sample(fun_fix_column,i)).replace("[","").replace("]","").replace("'","")
1444 1445
            fun_column_s_2 = str(random.sample(str_functions,1))+'('+column_s2+')'
            str_fun_s_2 = str(fun_column_s_2).replace("[","").replace("]","").replace("'","")
G
Ganlin Zhao 已提交
1446

1447 1448 1449 1450
            fun_fix_column_s_j = ['(t1.q_nchar)','(t1.q_nchar1)','(t1.q_nchar2)','(t1.q_nchar3)','(t1.q_nchar4)','(t1.q_nchar5)','(t1.q_nchar6)','(t1.q_nchar7)','(t1.q_nchar8)','(t1.q_nchar_null)','(t1.loc)',
                    '(t2.q_nchar)','(t2.q_nchar1)','(t2.q_nchar2)','(t2.q_nchar3)','(t2.q_nchar4)','(t2.q_nchar5)','(t2.q_nchar6)','(t2.q_nchar7)','(t2.q_nchar8)','(t2.q_nchar_null)','(t2.loc)',
                    '(t1.q_binary)','(t1.q_binary1)','(t1.q_binary2)','(t1.q_binary3)','(t1.q_binary4)','(t1.q_binary5)','(t1.q_binary6)','(t1.q_binary7)','(t1.q_binary8)','(t1.q_binary_null)',
                    '(t2.q_binary)','(t2.q_binary1)','(t2.q_binary2)','(t2.q_binary3)','(t2.q_binary4)','(t2.q_binary5)','(t2.q_binary6)','(t2.q_binary7)','(t2.q_binary8)','(t2.q_binary_null)']
G
Ganlin Zhao 已提交
1451 1452

            column_j_s1 = str(random.sample(fun_fix_column_s_j,i)).replace("[","").replace("]","").replace("'","")
1453 1454
            fun_column_join_s_1 = str(random.sample(str_functions,1))+'('+column_j_s1+')'
            str_fun_join_s_1 = str(fun_column_join_s_1).replace("[","").replace("]","").replace("'","")
G
Ganlin Zhao 已提交
1455 1456

            column_j_s2 = str(random.sample(fun_fix_column_s_j,i)).replace("[","").replace("]","").replace("'","")
1457 1458
            fun_column_join_s_2 = str(random.sample(str_functions,1))+'('+column_j_s2+')'
            str_fun_join_s_2 = str(fun_column_join_s_2).replace("[","").replace("]","").replace("'","")
G
Ganlin Zhao 已提交
1459

1460
        elif (strlist == ['CONCAT_WS']):
G
Ganlin Zhao 已提交
1461 1462
            str_functions = strlist
            i = random.randint(2,8)
1463
            fun_fix_column = ['q_nchar','q_nchar1','q_nchar2','q_nchar3','q_nchar4','q_nchar5','q_nchar6','q_nchar7','q_nchar8','q_nchar_null',
G
Ganlin Zhao 已提交
1464 1465
                              'q_binary','q_binary1','q_binary2','q_binary3','q_binary4','q_binary5','q_binary6','q_binary7','q_binary8','q_binary_null']

1466 1467
            separators = ['',' ','abc','123','!','@','#','$','%','^','&','*','(',')','-','_','+','=','{',
                        '[','}',']','|',';',':',',','.','<','>','?','/','~','`','taos','涛思']
G
Ganlin Zhao 已提交
1468 1469 1470
            separator = str(random.sample(separators,i)).replace("[","").replace("]","")

            column1 = str(random.sample(fun_fix_column,i)).replace("[","").replace("]","").replace("'","")
1471 1472
            fun_column_1 = str(random.sample(str_functions,1))+'('+'\"'+separator+'\",'+column1+')'
            str_fun_1 = str(fun_column_1).replace("[","").replace("]","").replace("'","")
G
Ganlin Zhao 已提交
1473

1474 1475 1476
            column2 = str(random.sample(fun_fix_column,i)).replace("[","").replace("]","").replace("'","")
            fun_column_2 = str(random.sample(str_functions,1))+'('+'\"'+separator+'\",'+column2+')'
            str_fun_2 = str(fun_column_2).replace("[","").replace("]","").replace("'","")
G
Ganlin Zhao 已提交
1477

1478 1479 1480
            fun_fix_column_j = ['(t1.q_nchar)','(t1.q_nchar1)','(t1.q_nchar2)','(t1.q_nchar3)','(t1.q_nchar4)','(t1.q_nchar5)','(t1.q_nchar6)','(t1.q_nchar7)','(t1.q_nchar8)','(t1.q_nchar_null)',
                    '(t2.q_nchar)','(t2.q_nchar1)','(t2.q_nchar2)','(t2.q_nchar3)','(t2.q_nchar4)','(t2.q_nchar5)','(t2.q_nchar6)','(t2.q_nchar7)','(t2.q_nchar8)','(t2.q_nchar_null)',
                    '(t1.q_binary)','(t1.q_binary1)','(t1.q_binary2)','(t1.q_binary3)','(t1.q_binary4)','(t1.q_binary5)','(t1.q_binary6)','(t1.q_binary7)','(t1.q_binary8)','(t1.q_binary_null)',
G
Ganlin Zhao 已提交
1481 1482 1483
                    '(t2.q_binary)','(t2.q_binary1)','(t2.q_binary2)','(t2.q_binary3)','(t2.q_binary4)','(t2.q_binary5)','(t2.q_binary6)','(t2.q_binary7)','(t2.q_binary8)','(t2.q_binary_null)']

            column_j1 = str(random.sample(fun_fix_column_j,i)).replace("[","").replace("]","").replace("'","")
1484 1485
            fun_column_join_1 = str(random.sample(str_functions,1))+'('+'\"'+separator+'\",'+column_j1+')'
            str_fun_join_1 = str(fun_column_join_1).replace("[","").replace("]","").replace("'","")
G
Ganlin Zhao 已提交
1486 1487

            column_j2 = str(random.sample(fun_fix_column_j,i)).replace("[","").replace("]","").replace("'","")
1488 1489
            fun_column_join_2 = str(random.sample(str_functions,1))+'('+'\"'+separator+'\",'+column_j2+')'
            str_fun_join_2 = str(fun_column_join_2).replace("[","").replace("]","").replace("'","")
G
Ganlin Zhao 已提交
1490

1491
            fun_fix_column_s = ['q_nchar','q_nchar1','q_nchar2','q_nchar3','q_nchar4','q_nchar5','q_nchar6','q_nchar7','q_nchar8','loc','q_nchar_null',
G
Ganlin Zhao 已提交
1492 1493 1494
                              'q_binary','q_binary1','q_binary2','q_binary3','q_binary4','q_binary5','q_binary6','q_binary7','q_binary8','q_binary_null']

            column_s1 = str(random.sample(fun_fix_column,i)).replace("[","").replace("]","").replace("'","")
1495 1496
            fun_column_s_1 = str(random.sample(str_functions,1))+'('+'\"'+separator+'\",'+column_s1+')'
            str_fun_s_1 = str(fun_column_s_1).replace("[","").replace("]","").replace("'","")
G
Ganlin Zhao 已提交
1497 1498

            column_s2 = str(random.sample(fun_fix_column,i)).replace("[","").replace("]","").replace("'","")
1499 1500
            fun_column_s_2 = str(random.sample(str_functions,1))+'('+'\"'+separator+'\",'+column_s2+')'
            str_fun_s_2 = str(fun_column_s_2).replace("[","").replace("]","").replace("'","")
G
Ganlin Zhao 已提交
1501

1502 1503 1504 1505
            fun_fix_column_s_j = ['(t1.q_nchar)','(t1.q_nchar1)','(t1.q_nchar2)','(t1.q_nchar3)','(t1.q_nchar4)','(t1.q_nchar5)','(t1.q_nchar6)','(t1.q_nchar7)','(t1.q_nchar8)','(t1.q_nchar_null)','(t1.loc)',
                    '(t2.q_nchar)','(t2.q_nchar1)','(t2.q_nchar2)','(t2.q_nchar3)','(t2.q_nchar4)','(t2.q_nchar5)','(t2.q_nchar6)','(t2.q_nchar7)','(t2.q_nchar8)','(t2.q_nchar_null)','(t2.loc)',
                    '(t1.q_binary)','(t1.q_binary1)','(t1.q_binary2)','(t1.q_binary3)','(t1.q_binary4)','(t1.q_binary5)','(t1.q_binary6)','(t1.q_binary7)','(t1.q_binary8)','(t1.q_binary_null)',
                    '(t2.q_binary)','(t2.q_binary1)','(t2.q_binary2)','(t2.q_binary3)','(t2.q_binary4)','(t2.q_binary5)','(t2.q_binary6)','(t2.q_binary7)','(t2.q_binary8)','(t2.q_binary_null)']
G
Ganlin Zhao 已提交
1506 1507

            column_j_s1 = str(random.sample(fun_fix_column_s_j,i)).replace("[","").replace("]","").replace("'","")
1508 1509
            fun_column_join_s_1 = str(random.sample(str_functions,1))+'('+'\"'+separator+'\",'+column_j_s1+')'
            str_fun_join_s_1 = str(fun_column_join_s_1).replace("[","").replace("]","").replace("'","")
G
Ganlin Zhao 已提交
1510 1511

            column_j_s2 = str(random.sample(fun_fix_column_s_j,i)).replace("[","").replace("]","").replace("'","")
1512 1513
            fun_column_join_s_2 = str(random.sample(str_functions,1))+'('+'\"'+separator+'\",'+column_j_s2+')'
            str_fun_join_s_2 = str(fun_column_join_s_2).replace("[","").replace("]","").replace("'","")
G
Ganlin Zhao 已提交
1514 1515


1516 1517 1518
        tdSql.query("select 1-1 as str_nest from stable_1 limit 1;")
        for i in range(self.fornum):
            if (strlist == ['LTRIM','RTRIM','LOWER','UPPER']) or (strlist == ['SUBSTR']) or (strlist == ['CONCAT']) or (strlist == ['CONCAT_WS']) :
G
Ganlin Zhao 已提交
1519 1520 1521
                sql = "select  ts , LTRIM(asct1), LOWER(asct1), RTRIM(asct2), UPPER(asct2)  from  ( select  "
                sql += "%s as asct1, " % str_fun_1
                sql += "%s as asct2, " % str_fun_2
1522
                sql += "%s, " % random.choice(self.s_s_select)
G
Ganlin Zhao 已提交
1523
                sql += "%s, " % random.choice(self.q_select)
1524 1525 1526 1527
                sql += "ts from regular_table_1 where "
                sql += "%s " % random.choice(self.q_where)
                sql += "%s " % random.choice(self.order_where)
                sql += ");"
G
Ganlin Zhao 已提交
1528 1529
                tdLog.info(sql)
                tdLog.info(len(sql))
1530 1531 1532 1533
                tdSql.query(sql)
                tdSql.checkRows(100)
                self.cur1.execute(sql)
            elif (strlist == ['LENGTH','CHAR_LENGTH']):
G
Ganlin Zhao 已提交
1534 1535 1536
                sql = "select  sum(asct1), min(asct1), max(asct2), avg(asct2)  from  ( select  "
                sql += "%s as asct1, " % str_fun_1
                sql += "%s as asct2, " % str_fun_2
1537
                sql += "%s, " % random.choice(self.s_s_select)
G
Ganlin Zhao 已提交
1538
                sql += "%s, " % random.choice(self.q_select)
1539 1540 1541 1542
                sql += "ts from regular_table_1 where "
                sql += "%s " % random.choice(self.q_where)
                sql += "%s " % random.choice(self.order_where)
                sql += ");"
G
Ganlin Zhao 已提交
1543 1544
                tdLog.info(sql)
                tdLog.info(len(sql))
1545 1546
                tdSql.query(sql)
                self.cur1.execute(sql)
G
Ganlin Zhao 已提交
1547

1548 1549 1550 1551
        tdSql.query("select 1-2 as str_nest from stable_1 limit 1;")
        for i in range(self.fornum):
            if (strlist == ['LTRIM','RTRIM','LOWER','UPPER']) or (strlist == ['SUBSTR']) or (strlist == ['CONCAT']) or (strlist == ['CONCAT_WS']) :
                sql = "select  ts ,  LTRIM(asct1), LOWER(asct1), RTRIM(asct2), UPPER(asct2)  from  ( select  "
G
Ganlin Zhao 已提交
1552
                sql += "%s as asct1,  " % str_fun_1
1553
                sql += "%s, " % random.choice(self.s_s_select)
G
Ganlin Zhao 已提交
1554
                sql += "%s, " % random.choice(self.q_select)
1555 1556 1557
                sql += "ts ts from regular_table_1 where "
                sql += "%s " % random.choice(self.q_where)
                sql += "%s )" % random.choice(self.order_where)
G
Ganlin Zhao 已提交
1558
                sql += "%s " % random.choice(self.unionall_or_union)
1559
                sql += "select  ts , asct2 from  ( select  "
G
Ganlin Zhao 已提交
1560
                sql += "%s as asct2,  " % str_fun_2
1561
                sql += "%s, " % random.choice(self.s_s_select)
G
Ganlin Zhao 已提交
1562
                sql += "%s, " % random.choice(self.q_select)
1563
                sql += "ts ts from regular_table_1 where "
G
Ganlin Zhao 已提交
1564
                sql += "%s " % random.choice(self.q_where)
1565 1566 1567 1568
                #sql += "%s " % random.choice(having_support)
                sql += "%s " % random.choice(self.order_where)
                sql += "%s " % random.choice(self.limit1_where)
                sql += ")"
G
Ganlin Zhao 已提交
1569 1570
                tdLog.info(sql)
                tdLog.info(len(sql))
1571
                #TD-15437 tdSql.query(sql)
G
Ganlin Zhao 已提交
1572 1573
                #TD-15437 self.cur1.execute(sql)
            elif (strlist == ['LENGTH','CHAR_LENGTH']):
1574
                sql = "select  sum(asct1), min(asct1), max(asct2), avg(asct2)  from  ( select  "
G
Ganlin Zhao 已提交
1575
                sql += "%s as asct1,  " % str_fun_1
1576
                sql += "%s, " % random.choice(self.s_s_select)
G
Ganlin Zhao 已提交
1577
                sql += "%s, " % random.choice(self.q_select)
1578 1579 1580
                sql += "ts ts from regular_table_1 where "
                sql += "%s " % random.choice(self.q_where)
                sql += "%s )" % random.choice(self.order_where)
G
Ganlin Zhao 已提交
1581
                sql += "%s " % random.choice(self.unionall_or_union)
1582
                sql += "select  ts , asct2 from  ( select  "
G
Ganlin Zhao 已提交
1583
                sql += "%s as asct2,  " % str_fun_2
1584
                sql += "%s, " % random.choice(self.s_s_select)
G
Ganlin Zhao 已提交
1585
                sql += "%s, " % random.choice(self.q_select)
1586
                sql += "ts ts from regular_table_1 where "
G
Ganlin Zhao 已提交
1587
                sql += "%s " % random.choice(self.q_where)
1588 1589 1590 1591
                #sql += "%s " % random.choice(having_support)
                sql += "%s " % random.choice(self.order_where)
                sql += "%s " % random.choice(self.limit1_where)
                sql += ")"
G
Ganlin Zhao 已提交
1592 1593
                tdLog.info(sql)
                tdLog.info(len(sql))
1594
                #TD-15437 tdSql.query(sql)
G
Ganlin Zhao 已提交
1595 1596
                #TD-15437 self.cur1.execute(sql)

1597 1598 1599 1600 1601 1602 1603
        tdSql.query("select 1-3 as str_nest from stable_1 limit 1;")
        for i in range(self.fornum):
            if (strlist == ['LTRIM','RTRIM','LOWER','UPPER']) or (strlist == ['SUBSTR']) or (strlist == ['CONCAT']) or (strlist == ['CONCAT_WS']):
                sql = "select  ts ,  LTRIM(asct1), LOWER(asct1), RTRIM(asct2), UPPER(asct2)  from  ( select  "
                sql += "%s as asct1, ts ," % str_fun_1
                sql += "%s as asct2, " % str_fun_2
                sql += "%s, " % random.choice(self.s_s_select)
G
Ganlin Zhao 已提交
1604
                sql += "%s, " % random.choice(self.q_select)
1605 1606
                sql += "ts from regular_table_1 where "
                sql += "%s " % random.choice(self.q_where)
G
Ganlin Zhao 已提交
1607
                sql += "%s select " % random.choice(self.unionall_or_union)
1608 1609 1610
                sql += "%s as asct2, ts ," % str_fun_2
                sql += "%s as asct1, " % str_fun_1
                sql += "%s, " % random.choice(self.s_s_select)
G
Ganlin Zhao 已提交
1611
                sql += "%s, " % random.choice(self.q_select)
1612 1613 1614 1615
                sql += "ts from regular_table_2 where "
                sql += "%s " % random.choice(self.q_where)
                sql += "%s " % random.choice(self.order_where)
                sql += ")"
G
Ganlin Zhao 已提交
1616 1617
                tdLog.info(sql)
                tdLog.info(len(sql))
1618 1619 1620 1621 1622 1623 1624
                #TD-15473 tdSql.query(sql)
                #self.cur1.execute(sql)
            elif (strlist == ['LENGTH','CHAR_LENGTH']):
                sql = "select  sum(asct1), min(asct1), max(asct2), avg(asct2)  from  ( select  "
                sql += "%s as asct1, ts ," % str_fun_1
                sql += "%s as asct2, " % str_fun_2
                sql += "%s, " % random.choice(self.s_s_select)
G
Ganlin Zhao 已提交
1625
                sql += "%s, " % random.choice(self.q_select)
1626 1627
                sql += "ts from regular_table_1 where "
                sql += "%s " % random.choice(self.q_where)
G
Ganlin Zhao 已提交
1628
                sql += "%s select " % random.choice(self.unionall_or_union)
1629 1630 1631
                sql += "%s as asct2, ts ," % str_fun_2
                sql += "%s as asct1, " % str_fun_1
                sql += "%s, " % random.choice(self.s_s_select)
G
Ganlin Zhao 已提交
1632
                sql += "%s, " % random.choice(self.q_select)
1633 1634 1635 1636
                sql += "ts from regular_table_2 where "
                sql += "%s " % random.choice(self.q_where)
                sql += "%s " % random.choice(self.order_where)
                sql += ")"
G
Ganlin Zhao 已提交
1637 1638
                tdLog.info(sql)
                tdLog.info(len(sql))
1639 1640
                #TD-15473 tdSql.query(sql)
                #self.cur1.execute(sql)
G
Ganlin Zhao 已提交
1641

1642 1643 1644 1645
        tdSql.query("select 1-4 as str_nest from stable_1 limit 1;")
        for i in range(self.fornum):
            if (strlist == ['LTRIM','RTRIM','LOWER','UPPER']) or (strlist == ['SUBSTR']) or (strlist == ['CONCAT']) or (strlist == ['CONCAT_WS']):
                sql = "select  ts ,  LTRIM(asct1), LOWER(asct1), RTRIM(asct2), UPPER(asct2)  from  ( select  t1.ts as ts,"
G
Ganlin Zhao 已提交
1646 1647 1648 1649 1650
                sql += "%s as asct2, " % str_fun_join_1
                sql += "%s as asct1, " % str_fun_join_2
                sql += "%s, " % str_fun_join_1
                sql += "t1.%s, " % random.choice(self.q_select)
                sql += "t2.%s, " % random.choice(self.q_select)
1651 1652 1653 1654 1655
                sql += "t2.ts from regular_table_1 t1 , regular_table_2 t2 where t1.ts = t2.ts and "
                sql += "%s " % random.choice(self.q_u_where)
                sql += "and %s " % random.choice(self.q_u_or_where)
                sql += "%s " % random.choice(self.order_u_where)
                sql += ");"
G
Ganlin Zhao 已提交
1656 1657
                tdLog.info(sql)
                tdLog.info(len(sql))
1658 1659 1660 1661 1662
                tdSql.query(sql)
                tdSql.checkRows(100)
                self.cur1.execute(sql)
            elif (strlist == ['LENGTH','CHAR_LENGTH']):
                sql = "select  sum(asct1), min(asct1), max(asct2), avg(asct2)  from  ( select  t1.ts as ts,"
G
Ganlin Zhao 已提交
1663 1664 1665 1666 1667
                sql += "%s as asct2, " % str_fun_join_1
                sql += "%s as asct1, " % str_fun_join_2
                sql += "%s, " % str_fun_join_1
                sql += "t1.%s, " % random.choice(self.q_select)
                sql += "t2.%s, " % random.choice(self.q_select)
1668 1669 1670 1671 1672
                sql += "t2.ts from regular_table_1 t1 , regular_table_2 t2 where t1.ts = t2.ts and "
                sql += "%s " % random.choice(self.q_u_where)
                sql += "and %s " % random.choice(self.q_u_or_where)
                sql += "%s " % random.choice(self.order_u_where)
                sql += ");"
G
Ganlin Zhao 已提交
1673 1674
                tdLog.info(sql)
                tdLog.info(len(sql))
1675 1676
                tdSql.query(sql)
                self.cur1.execute(sql)
G
Ganlin Zhao 已提交
1677

1678 1679 1680 1681
        tdSql.query("select 1-5 as str_nest from stable_1 limit 1;")
        for i in range(self.fornum):
            if (strlist == ['LTRIM','RTRIM','LOWER','UPPER']) or (strlist == ['SUBSTR']) or (strlist == ['CONCAT']) or (strlist == ['CONCAT_WS']):
                sql = "select  ts ,"
G
Ganlin Zhao 已提交
1682 1683
                sql += "%s, " % str_fun_1
                sql += "%s, " % random.choice(self.q_select)
1684 1685 1686 1687 1688 1689
                sql += "%s, " % random.choice(self.q_select)
                sql += "%s  " % str_fun_2
                sql += " from  ( select  * from regular_table_1 ) where "
                sql += "%s " % random.choice(self.q_where)
                sql += "%s " % random.choice(self.order_where)
                sql += " ;"
G
Ganlin Zhao 已提交
1690 1691
                tdLog.info(sql)
                tdLog.info(len(sql))
1692 1693 1694 1695 1696
                tdSql.query(sql)
                tdSql.checkRows(100)
                self.cur1.execute(sql)
            elif (strlist == ['LENGTH','CHAR_LENGTH']):
                sql = "select  ts ,"
G
Ganlin Zhao 已提交
1697 1698
                sql += "%s, " % str_fun_1
                sql += "%s, " % random.choice(self.q_select)
1699 1700 1701 1702 1703 1704
                sql += "%s, " % random.choice(self.q_select)
                sql += "%s  " % str_fun_2
                sql += " from  ( select  * from regular_table_1 ) where "
                sql += "%s " % random.choice(self.q_where)
                sql += "%s " % random.choice(self.order_where)
                sql += " ;"
G
Ganlin Zhao 已提交
1705 1706
                tdLog.info(sql)
                tdLog.info(len(sql))
1707 1708 1709 1710 1711 1712 1713 1714
                tdSql.query(sql)
                tdSql.checkRows(100)
                self.cur1.execute(sql)

        tdSql.query("select 1-6 as str_nest from stable_1 limit 1;")
        for i in range(self.fornum):
            if (strlist == ['LTRIM','RTRIM','LOWER','UPPER']) or (strlist == ['SUBSTR']) or (strlist == ['CONCAT']) or (strlist == ['CONCAT_WS']):
                sql = "select  ts ,  LTRIM(asct1), LOWER(asct1), RTRIM(asct2), UPPER(asct2)  from  ( select  t1.ts as ts,"
G
Ganlin Zhao 已提交
1715 1716 1717 1718 1719
                sql += "%s as asct2, " % str_fun_join_1
                sql += "%s as asct1, " % str_fun_join_2
                sql += "t1.%s, " % random.choice(self.q_select)
                sql += "t2.%s, " % random.choice(self.q_select)
                sql += "%s, " % str_fun_join_1
1720 1721 1722 1723 1724
                sql += "t2.ts from regular_table_1 t1 , regular_table_2 t2 where t1.ts = t2.ts and "
                sql += "%s " % random.choice(self.q_u_where)
                sql += "and %s  )" % random.choice(self.q_u_or_where)
                sql += "%s " % random.choice(self.order_where)
                sql += "%s " % random.choice(self.limit1_where)
G
Ganlin Zhao 已提交
1725 1726 1727
                tdLog.info(sql)
                tdLog.info(len(sql))
                tdSql.query(sql)
1728 1729 1730
                self.cur1.execute(sql)
            elif (strlist == ['LENGTH','CHAR_LENGTH']):
                sql = "select  sum(asct1), min(asct1), max(asct2), avg(asct2)  from  ( select  t1.ts as ts,"
G
Ganlin Zhao 已提交
1731 1732 1733 1734 1735
                sql += "%s as asct2, " % str_fun_join_1
                sql += "%s as asct1, " % str_fun_join_2
                sql += "t1.%s, " % random.choice(self.q_select)
                sql += "t2.%s, " % random.choice(self.q_select)
                sql += "%s, " % str_fun_join_1
1736 1737 1738 1739
                sql += "t2.ts from regular_table_1 t1 , regular_table_2 t2 where t1.ts = t2.ts and "
                sql += "%s " % random.choice(self.q_u_where)
                sql += "and %s  )" % random.choice(self.q_u_or_where)
                sql += "%s " % random.choice(self.limit1_where)
G
Ganlin Zhao 已提交
1740 1741 1742
                tdLog.info(sql)
                tdLog.info(len(sql))
                tdSql.query(sql)
1743 1744 1745 1746 1747 1748 1749 1750
                self.cur1.execute(sql)

        tdSql.query("select 1-7 as str_nest from stable_1 limit 1;")
        for i in range(self.fornum):
            if (strlist == ['LTRIM','RTRIM','LOWER','UPPER']) or (strlist == ['SUBSTR']) or (strlist == ['CONCAT']) or (strlist == ['CONCAT_WS']):
                sql = "select  ts ,  LTRIM(asct1), LOWER(asct1), RTRIM(asct2), UPPER(asct2)  from  ( select  "
                sql += "%s as asct1, ts ," % str_fun_s_1
                sql += "%s as asct2, " % str_fun_s_2
G
Ganlin Zhao 已提交
1751 1752
                sql += "%s, " % random.choice(self.q_select)
                sql += "%s, " % random.choice(self.t_select)
1753 1754 1755 1756
                sql += "ts from stable_1 where "
                sql += "%s " % random.choice(self.qt_where)
                sql += "%s " % random.choice(self.order_where)
                sql += ") ;"
G
Ganlin Zhao 已提交
1757
                tdLog.info(sql)
1758 1759 1760 1761 1762 1763 1764 1765
                tdLog.info(len(sql))
                # tdSql.query(sql)
                # tdSql.checkRows(300)
                # self.cur1.execute(sql)# TD-16039
            elif (strlist == ['LENGTH','CHAR_LENGTH']):
                sql = "select  sum(asct1), min(asct1), max(asct2), avg(asct2)  from  ( select  "
                sql += "%s as asct1, ts ," % str_fun_s_1
                sql += "%s as asct2, " % str_fun_s_2
G
Ganlin Zhao 已提交
1766 1767
                sql += "%s, " % random.choice(self.q_select)
                sql += "%s, " % random.choice(self.t_select)
1768 1769 1770 1771
                sql += "ts from stable_1 where "
                sql += "%s " % random.choice(self.qt_where)
                sql += "%s " % random.choice(self.order_where)
                sql += ") ;"
G
Ganlin Zhao 已提交
1772
                tdLog.info(sql)
1773 1774 1775
                tdLog.info(len(sql))
                # tdSql.query(sql)
                # self.cur1.execute(sql)# TD-16039
G
Ganlin Zhao 已提交
1776

1777 1778 1779 1780 1781 1782 1783 1784
        tdSql.query("select 1-8 as str_nest from stable_1 limit 1;")
        for i in range(self.fornum):
            if (strlist == ['LTRIM','RTRIM','LOWER','UPPER']) or (strlist == ['SUBSTR']) or (strlist == ['CONCAT']) or (strlist == ['CONCAT_WS']):
                sql = "select  ts, LTRIM(asct1), LOWER(asct1), RTRIM(asct2), UPPER(asct2)  "
                sql += "from  ( select  "
                sql += "%s, " % random.choice(self.s_s_select)
                sql += "%s as asct1, ts ," % str_fun_s_1
                sql += "%s as asct2, " % str_fun_s_2
G
Ganlin Zhao 已提交
1785 1786
                sql += "%s, " % random.choice(self.q_select)
                sql += "%s, " % random.choice(self.t_select)
1787 1788 1789 1790
                sql += "ts from stable_1 where "
                sql += "%s " % random.choice(self.qt_where)
                sql += "%s " % random.choice(self.order_where)
                sql += ") ;"
G
Ganlin Zhao 已提交
1791
                tdLog.info(sql)
1792 1793 1794 1795 1796 1797 1798 1799 1800 1801
                tdLog.info(len(sql))
                # tdSql.query(sql)
                # tdSql.checkRows(300)
                # self.cur1.execute(sql)# TD-16039
            elif (strlist == ['LENGTH','CHAR_LENGTH']):
                sql = "select  sum(asct1), min(asct1), max(asct2), avg(asct2)  "
                sql += "from  ( select  "
                sql += "%s, " % random.choice(self.s_s_select)
                sql += "%s as asct1, ts ," % str_fun_s_1
                sql += "%s as asct2, " % str_fun_s_2
G
Ganlin Zhao 已提交
1802 1803
                sql += "%s, " % random.choice(self.q_select)
                sql += "%s, " % random.choice(self.t_select)
1804 1805 1806 1807
                sql += "ts from stable_1 where "
                sql += "%s " % random.choice(self.qt_where)
                sql += "%s " % random.choice(self.order_where)
                sql += ") ;"
G
Ganlin Zhao 已提交
1808
                tdLog.info(sql)
1809 1810 1811 1812 1813 1814 1815 1816
                tdLog.info(len(sql))
                # tdSql.query(sql)
                # self.cur1.execute(sql)# TD-16039

        tdSql.query("select 1-9 as str_nest from stable_1 limit 1;")
        for i in range(self.fornum):
            if (strlist == ['LTRIM','RTRIM','LOWER','UPPER']) or (strlist == ['SUBSTR']) or (strlist == ['CONCAT']) or (strlist == ['CONCAT_WS']):
                sql = "select  ts ,  LTRIM(asct1), LOWER(asct1), RTRIM(asct2), UPPER(asct2)  from  ( select  t1.ts as ts,"
G
Ganlin Zhao 已提交
1817 1818 1819 1820 1821 1822
                sql += "%s as asct2, " % str_fun_join_s_1
                sql += "%s as asct1, " % str_fun_join_s_2
                sql += "t1.%s, " % random.choice(self.q_select)
                sql += "t1.%s, " % random.choice(self.q_select)
                sql += "t2.%s, " % random.choice(self.q_select)
                sql += "t2.%s, " % random.choice(self.q_select)
1823 1824 1825 1826 1827 1828 1829
                sql += "t2.ts from stable_1 t1 , stable_2 t2 where t1.ts = t2.ts and "
                sql += "%s " % random.choice(self.t_join_where)
                sql += "and %s " % random.choice(self.t_u_where)
                sql += "and %s " % random.choice(self.t_u_or_where)
                sql += "%s " % random.choice(self.order_u_where)
                sql += "%s " % random.choice(self.limit1_where)
                sql += ") ;"
G
Ganlin Zhao 已提交
1830 1831
                tdLog.info(sql)
                tdLog.info(len(sql))
1832 1833 1834 1835
                # tdSql.query(sql)
                # self.cur1.execute(sql) # TD-16039
            elif (strlist == ['LENGTH','CHAR_LENGTH']):
                sql = "select  sum(asct1), min(asct1), max(asct2), avg(asct2)  from  ( select  t1.ts as ts,"
G
Ganlin Zhao 已提交
1836 1837 1838 1839 1840 1841
                sql += "%s as asct2, " % str_fun_join_s_1
                sql += "%s as asct1, " % str_fun_join_s_2
                sql += "t1.%s, " % random.choice(self.q_select)
                sql += "t1.%s, " % random.choice(self.q_select)
                sql += "t2.%s, " % random.choice(self.q_select)
                sql += "t2.%s, " % random.choice(self.q_select)
1842 1843 1844 1845 1846 1847 1848
                sql += "t2.ts from stable_1 t1 , stable_2 t2 where t1.ts = t2.ts and "
                sql += "%s " % random.choice(self.t_join_where)
                sql += "and %s " % random.choice(self.t_u_where)
                sql += "and %s " % random.choice(self.t_u_or_where)
                sql += "%s " % random.choice(self.order_u_where)
                sql += "%s " % random.choice(self.limit1_where)
                sql += ") ;"
G
Ganlin Zhao 已提交
1849 1850
                tdLog.info(sql)
                tdLog.info(len(sql))
1851 1852
                # tdSql.query(sql)
                # self.cur1.execute(sql)# TD-16039
G
Ganlin Zhao 已提交
1853

1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876
        self.restartDnodes()
        tdSql.query("select 1-10 as str_nest from stable_1 limit 1;")
        for i in range(self.fornum):
            if (strlist == ['LTRIM','RTRIM','LOWER','UPPER']) or (strlist == ['SUBSTR']) or (strlist == ['CONCAT']) or (strlist == ['CONCAT_WS']):
                sql = "select  ts ,  LTRIM(asct1), LOWER(asct1), RTRIM(asct2), UPPER(asct2)  from  ( select  "
                sql += "%s as asct1, ts ," % str_fun_s_1
                sql += "%s as asct2, " % str_fun_s_2
                sql += "%s, " % random.choice(self.s_r_select)
                sql += "%s, " % random.choice(self.q_select)
                sql += "ts from stable_1 where "
                sql += "%s " % random.choice(self.q_where)
                sql += "%s " % random.choice(self.order_where)
                sql += ") %s " % random.choice(self.unionall_or_union)
                sql += "select  ts , max(asct2) from  ( select  "
                sql += "%s as asct1, ts ," % str_fun_1
                sql += "%s as asct2, " % str_fun_2
                sql += "%s, " % random.choice(self.s_r_select)
                sql += "%s, " % random.choice(self.q_select)
                sql += "ts from stable_2 where "
                sql += "%s " % random.choice(self.q_where)
                sql += "%s " % random.choice(self.order_where)
                sql += "%s " % random.choice(self.limit1_where)
                sql += ")"
G
Ganlin Zhao 已提交
1877 1878
                tdLog.info(sql)
                tdLog.info(len(sql))
1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900
                #TD-15437 tdSql.query(sql)
                #TD-15437 self.cur1.execute(sql)
            elif (strlist == ['LENGTH','CHAR_LENGTH']):
                sql = "select  sum(asct1), min(asct1), max(asct2), avg(asct2)  from  ( select  "
                sql += "%s as asct1, ts ," % str_fun_s_1
                sql += "%s as asct2, " % str_fun_s_2
                sql += "%s, " % random.choice(self.s_r_select)
                sql += "%s, " % random.choice(self.q_select)
                sql += "ts from stable_1 where "
                sql += "%s " % random.choice(self.q_where)
                sql += "%s " % random.choice(self.order_where)
                sql += ") %s " % random.choice(self.unionall_or_union)
                sql += "select  ts , max(asct2) from  ( select  "
                sql += "%s as asct1, ts ," % str_fun_1
                sql += "%s as asct2, " % str_fun_2
                sql += "%s, " % random.choice(self.s_r_select)
                sql += "%s, " % random.choice(self.q_select)
                sql += "ts from stable_2 where "
                sql += "%s " % random.choice(self.q_where)
                sql += "%s " % random.choice(self.order_where)
                sql += "%s " % random.choice(self.limit1_where)
                sql += ")"
G
Ganlin Zhao 已提交
1901 1902
                tdLog.info(sql)
                tdLog.info(len(sql))
1903 1904
                #TD-15437 tdSql.query(sql)
                #TD-15437 self.cur1.execute(sql)
G
Ganlin Zhao 已提交
1905

1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929
        #3 inter union not support
        tdSql.query("select 1-11 as str_nest from stable_1 limit 1;")
        for i in range(self.fornum):
            if (strlist == ['LTRIM','RTRIM','LOWER','UPPER']) or (strlist == ['SUBSTR']) or (strlist == ['CONCAT']) or (strlist == ['CONCAT_WS']):
                sql = "select  ts ,  LTRIM(asct1), LOWER(asct1), RTRIM(asct2), UPPER(asct2)  from  ( select  "
                sql += "%s as asct1, ts ," % str_fun_s_1
                sql += "%s as asct2, " % str_fun_s_2
                sql += "%s, " % random.choice(self.s_r_select)
                sql += "%s, " % random.choice(self.q_select)
                sql += "ts from stable_1 where "
                sql += "%s " % random.choice(self.q_where)
                sql += "%s " % random.choice(self.order_where)
                #sql += "%s " % random.choice(limit1_where)
                sql += " %s "  % random.choice(self.unionall_or_union)
                sql += " select  "
                sql += "%s as asct1, ts ," % str_fun_1
                sql += "%s as asct2, " % str_fun_2
                sql += "%s, " % random.choice(self.s_r_select)
                sql += "%s, " % random.choice(self.q_select)
                sql += "ts from stable_2 where "
                sql += "%s " % random.choice(self.q_where)
                sql += "%s " % random.choice(self.order_where)
                sql += "%s " % random.choice(self.limit1_where)
                sql += ")"
G
Ganlin Zhao 已提交
1930 1931
                tdLog.info(sql)
                tdLog.info(len(sql))
1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954
                #TD-15837 tdSql.query(sql)
                # self.cur1.execute(sql)
            elif (strlist == ['LENGTH','CHAR_LENGTH']):
                sql = "select sum(asct1), min(asct1), max(asct2), avg(asct2)  from  ( select  "
                sql += "%s as asct1, ts ," % str_fun_s_1
                sql += "%s as asct2, " % str_fun_s_2
                sql += "%s, " % random.choice(self.s_r_select)
                sql += "%s, " % random.choice(self.q_select)
                sql += "ts from stable_1 where "
                sql += "%s " % random.choice(self.q_where)
                sql += "%s " % random.choice(self.order_where)
                #sql += "%s " % random.choice(limit1_where)
                sql += " %s "  % random.choice(self.unionall_or_union)
                sql += " select  "
                sql += "%s as asct1, ts ," % str_fun_1
                sql += "%s as asct2, " % str_fun_2
                sql += "%s, " % random.choice(self.s_r_select)
                sql += "%s, " % random.choice(self.q_select)
                sql += "ts from stable_2 where "
                sql += "%s " % random.choice(self.q_where)
                sql += "%s " % random.choice(self.order_where)
                sql += "%s " % random.choice(self.limit1_where)
                sql += ")"
G
Ganlin Zhao 已提交
1955 1956
                tdLog.info(sql)
                tdLog.info(len(sql))
1957 1958 1959 1960 1961 1962 1963
                #TD-15837 tdSql.query(sql)
                # self.cur1.execute(sql)

        tdSql.query("select 1-12 as str_nest from stable_1 limit 1;")
        for i in range(self.fornum):
            if (strlist == ['LTRIM','RTRIM','LOWER','UPPER']) or (strlist == ['SUBSTR']) or (strlist == ['CONCAT']) or (strlist == ['CONCAT_WS']):
                sql = "select  ts ,  LTRIM(asct1), LOWER(asct1), RTRIM(asct2), UPPER(asct2)  from  ( select  t1.ts as ts,"
G
Ganlin Zhao 已提交
1964 1965 1966 1967 1968 1969
                sql += "%s as asct2, " % str_fun_join_s_1
                sql += "%s as asct1, " % str_fun_join_s_2
                sql += "t1.%s, " % random.choice(self.q_select)
                sql += "t1.%s, " % random.choice(self.q_select)
                sql += "t2.%s, " % random.choice(self.q_select)
                sql += "t2.%s, " % random.choice(self.q_select)
1970 1971 1972 1973 1974 1975
                sql += "t2.ts from stable_1 t1 , stable_2 t2 where t1.ts = t2.ts and "
                sql += "%s " % random.choice(self.t_u_where)
                sql += "and %s " % random.choice(self.t_u_or_where)
                sql += "%s " % random.choice(self.order_u_where)
                sql += "%s " % random.choice(self.limit1_where)
                sql += ");"
G
Ganlin Zhao 已提交
1976 1977
                tdLog.info(sql)
                tdLog.info(len(sql))
1978 1979 1980 1981
                # tdSql.query(sql)
                # self.cur1.execute(sql)# TD-16039
            elif (strlist == ['LENGTH','CHAR_LENGTH']):
                sql = "select  sum(asct1), min(asct1), max(asct2), avg(asct2)  from  ( select  t1.ts as ts,"
G
Ganlin Zhao 已提交
1982 1983 1984 1985 1986 1987
                sql += "%s as asct2, " % str_fun_join_s_1
                sql += "%s as asct1, " % str_fun_join_s_2
                sql += "t1.%s, " % random.choice(self.q_select)
                sql += "t1.%s, " % random.choice(self.q_select)
                sql += "t2.%s, " % random.choice(self.q_select)
                sql += "t2.%s, " % random.choice(self.q_select)
1988 1989 1990 1991 1992 1993
                sql += "t2.ts from stable_1 t1 , stable_2 t2 where t1.ts = t2.ts and "
                sql += "%s " % random.choice(self.t_u_where)
                sql += "and %s " % random.choice(self.t_u_or_where)
                sql += "%s " % random.choice(self.order_u_where)
                sql += "%s " % random.choice(self.limit1_where)
                sql += ");"
G
Ganlin Zhao 已提交
1994 1995
                tdLog.info(sql)
                tdLog.info(len(sql))
1996 1997
                # tdSql.query(sql)
                # self.cur1.execute(sql)# TD-16039
G
Ganlin Zhao 已提交
1998

1999 2000 2001 2002
        tdSql.query("select 1-13 as str_nest from stable_1 limit 1;")
        for i in range(self.fornum):
            if (strlist == ['LTRIM','RTRIM','LOWER','UPPER']) or (strlist == ['SUBSTR']) or (strlist == ['CONCAT']) or (strlist == ['CONCAT_WS']):
                sql = "select  ts ,"
G
Ganlin Zhao 已提交
2003 2004
                sql += "%s, " % str_fun_1
                sql += "%s, " % random.choice(self.q_select)
2005 2006
                sql += "%s, " % random.choice(self.q_select)
                sql += "%s, " % str_fun_2
G
Ganlin Zhao 已提交
2007
                sql += "%s  " % random.choice(self.t_select)
2008 2009 2010 2011
                sql += " from  ( select  * from stable_1 where "
                sql += "%s " % random.choice(self.qt_where)
                sql += "%s " % random.choice(self.order_where)
                sql += ") ;"
G
Ganlin Zhao 已提交
2012 2013
                tdLog.info(sql)
                tdLog.info(len(sql))
2014 2015 2016 2017 2018
                # tdSql.query(sql)
                # tdSql.checkRows(300)
                # self.cur1.execute(sql) # TD-16039
            elif (strlist == ['LENGTH','CHAR_LENGTH']):
                sql = "select  ts ,"
G
Ganlin Zhao 已提交
2019 2020
                sql += "%s, " % str_fun_1
                sql += "%s, " % random.choice(self.q_select)
2021 2022
                sql += "%s, " % random.choice(self.q_select)
                sql += "%s, " % str_fun_2
G
Ganlin Zhao 已提交
2023
                sql += "%s  " % random.choice(self.t_select)
2024 2025 2026 2027
                sql += " from  ( select  * from stable_1 where "
                sql += "%s " % random.choice(self.qt_where)
                sql += "%s " % random.choice(self.order_where)
                sql += ") ;"
G
Ganlin Zhao 已提交
2028 2029
                tdLog.info(sql)
                tdLog.info(len(sql))
2030 2031 2032
                # tdSql.query(sql)
                # tdSql.checkRows(300)
                # self.cur1.execute(sql)# TD-16039
G
Ganlin Zhao 已提交
2033

2034 2035 2036 2037
        tdSql.query("select 1-14 as str_nest from stable_1 limit 1;")
        for i in range(self.fornum):
            if (strlist == ['LTRIM','RTRIM','LOWER','UPPER']) or (strlist == ['SUBSTR']) or (strlist == ['CONCAT']) or (strlist == ['CONCAT_WS']):
                sql = "select   LTRIM(asct1), LOWER(asct1), RTRIM(asct2), UPPER(asct2)  from ( select "
G
Ganlin Zhao 已提交
2038
                sql += "%s as asct1, " % str_fun_s_1
2039 2040 2041 2042 2043 2044 2045
                sql += "%s as asct2" % str_fun_s_2
                sql += "  from stable_1 where "
                sql += "%s " % random.choice(self.q_where)
                sql += "%s " % random.choice(self.partiton_where)
                sql += "%s " % random.choice(self.order_desc_where)
                sql += "%s " % random.choice([self.limit_where[2] , self.limit_where[3]] )
                sql += " ) ;"
G
Ganlin Zhao 已提交
2046 2047
                tdLog.info(sql)
                tdLog.info(len(sql))
2048 2049 2050 2051
                # tdSql.query(sql)
                # self.cur1.execute(sql)  # TD-16039
            elif (strlist == ['LENGTH','CHAR_LENGTH']):
                sql = "select   sum(asct1), min(asct1), max(asct2), avg(asct2)  from ( select "
G
Ganlin Zhao 已提交
2052
                sql += "%s as asct1, " % str_fun_s_1
2053 2054 2055 2056 2057 2058 2059
                sql += "%s as asct2" % str_fun_s_2
                sql += "  from stable_1 where "
                sql += "%s " % random.choice(self.q_where)
                sql += "%s " % random.choice(self.partiton_where)
                sql += "%s " % random.choice(self.order_desc_where)
                sql += "%s " % random.choice([self.limit_where[2] , self.limit_where[3]] )
                sql += " ) ;"
G
Ganlin Zhao 已提交
2060 2061
                tdLog.info(sql)
                tdLog.info(len(sql))
2062 2063
                # tdSql.query(sql)
                # self.cur1.execute(sql)  # TD-16039
G
Ganlin Zhao 已提交
2064

2065 2066 2067 2068
        tdSql.query("select 1-15 as str_nest from stable_1 limit 1;")
        for i in range(self.fornum):
            if (strlist == ['LTRIM','RTRIM','LOWER','UPPER']) or (strlist == ['SUBSTR']) or (strlist == ['CONCAT']) or (strlist == ['CONCAT_WS']):
                sql = "select  ts , LTRIM(asct1), LOWER(asct1), RTRIM(asct2), UPPER(asct2)  from  ( select  t1.ts as ts,"
G
Ganlin Zhao 已提交
2069 2070 2071 2072 2073 2074
                sql += "%s as asct2, " % str_fun_join_s_1
                sql += "%s as asct1, " % str_fun_join_s_2
                sql += "t1.%s, " % random.choice(self.q_select)
                sql += "t1.%s, " % random.choice(self.q_select)
                sql += "t2.%s, " % random.choice(self.q_select)
                sql += "t2.%s " % random.choice(self.q_select)
2075 2076 2077 2078 2079
                sql += "from stable_1  t1, stable_2 t2 where t1.ts = t2.ts and  "
                sql += "%s " % random.choice(self.t_join_where)
                sql += " and %s " % random.choice(self.qt_u_or_where)
                sql += "%s " % random.choice(self.partiton_where_j)
                sql += "%s " % random.choice(self.slimit1_where)
G
Ganlin Zhao 已提交
2080
                sql += ") "
2081 2082
                sql += "%s " % random.choice(self.order_desc_where)
                sql += "%s ;" % random.choice(self.limit_u_where)
G
Ganlin Zhao 已提交
2083 2084
                tdLog.info(sql)
                tdLog.info(len(sql))
2085
                #TD-15955 tdSql.query(sql)
G
Ganlin Zhao 已提交
2086
                #TD-15955 self.cur1.execute(sql)
2087 2088
            elif (strlist == ['LENGTH','CHAR_LENGTH']):
                sql = "select  sum(asct1), min(asct1), max(asct2), avg(asct2)  from  ( select  t1.ts as ts,"
G
Ganlin Zhao 已提交
2089 2090 2091 2092 2093 2094
                sql += "%s as asct2, " % str_fun_join_s_1
                sql += "%s as asct1, " % str_fun_join_s_2
                sql += "t1.%s, " % random.choice(self.q_select)
                sql += "t1.%s, " % random.choice(self.q_select)
                sql += "t2.%s, " % random.choice(self.q_select)
                sql += "t2.%s " % random.choice(self.q_select)
2095 2096 2097 2098 2099
                sql += "from stable_1  t1, stable_2 t2 where t1.ts = t2.ts and  "
                sql += "%s " % random.choice(self.t_join_where)
                sql += " and %s " % random.choice(self.qt_u_or_where)
                sql += "%s " % random.choice(self.partiton_where_j)
                sql += "%s " % random.choice(self.slimit1_where)
G
Ganlin Zhao 已提交
2100
                sql += ") "
2101 2102
                sql += "%s " % random.choice(self.order_desc_where)
                sql += "%s ;" % random.choice(self.limit_u_where)
G
Ganlin Zhao 已提交
2103 2104
                tdLog.info(sql)
                tdLog.info(len(sql))
2105
                #TD-15955 tdSql.query(sql)
G
Ganlin Zhao 已提交
2106 2107
                #TD-15955 self.cur1.execute(sql)

2108 2109 2110 2111 2112 2113 2114
        #taos -f sql
        startTime_taos_f = time.time()
        print("taos -f %s sql start!" %strlist)
        taos_cmd1 = "taos -f %s/%s.sql" % (self.testcasePath,self.testcaseFilename)
        _ = subprocess.check_output(taos_cmd1, shell=True).decode("utf-8")
        print("taos -f %s sql over!" %strlist)
        endTime_taos_f = time.time()
G
Ganlin Zhao 已提交
2115 2116 2117 2118
        print("taos_f total time %ds" % (endTime_taos_f - startTime_taos_f))

        print("=========%s====over=============" %strlist)

2119
    def time_nest(self,timelist):
G
Ganlin Zhao 已提交
2120 2121 2122 2123

        print("==========%s===start=============" %timelist)
        os.system("rm -rf %s/%s.sql" % (self.testcasePath,self.testcaseFilename))

2124
        self.dropandcreateDB_random("%s" %self.db_nest, 1)
G
Ganlin Zhao 已提交
2125

2126
        if (timelist == ['NOW','TODAY']) or (timelist == ['TIMEZONE']):
G
Ganlin Zhao 已提交
2127 2128
            time_functions = timelist
            fun_fix_column = ['()']
2129 2130 2131 2132
            fun_column_1 = random.sample(time_functions,1)+random.sample(fun_fix_column,1)
            time_fun_1 = str(fun_column_1).replace("[","").replace("]","").replace("'","").replace(", ","")
            fun_column_2 = random.sample(time_functions,1)+random.sample(fun_fix_column,1)
            time_fun_2 = str(fun_column_2).replace("[","").replace("]","").replace("'","").replace(", ","")
G
Ganlin Zhao 已提交
2133 2134

            fun_fix_column_j = ['()']
2135 2136 2137 2138 2139 2140
            fun_column_join_1 = random.sample(time_functions,1)+random.sample(fun_fix_column_j,1)
            time_fun_join_1 = str(fun_column_join_1).replace("[","").replace("]","").replace("'","").replace(", ","")
            fun_column_join_2 = random.sample(time_functions,1)+random.sample(fun_fix_column_j,1)
            time_fun_join_2 = str(fun_column_join_2).replace("[","").replace("]","").replace("'","").replace(", ","")

        elif (timelist == ['TIMETRUNCATE']):
G
Ganlin Zhao 已提交
2141 2142 2143 2144
            time_functions = timelist

            t = time.time()
            t_to_s =  time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(t))
2145
            fun_fix_column = ['q_ts','ts','_c0','_C0','_rowts','1600000000000','1600000000000000','1600000000000000000',
G
Ganlin Zhao 已提交
2146 2147 2148 2149 2150 2151
                        '%d' %t, '%d000' %t, '%d000000' %t,'t_to_s']

            timeunits = ['1u' , '1a' ,'1s', '1m' ,'1h', '1d']
            timeunit = str(random.sample(timeunits,1)).replace("[","").replace("]","").replace("'","")

            column_1 = ['(%s,timeutil)'%(random.sample(fun_fix_column,1))]
2152 2153 2154
            fun_column_1 = random.sample(time_functions,1)+random.sample(column_1,1)
            time_fun_1 = str(fun_column_1).replace("[","").replace("]","").replace("'","").replace(", ","").replace("\"","").replace("t_to_s","'t_to_s'")
            time_fun_1 = str(time_fun_1).replace("timeutil","%s" %timeunit).replace("t_to_s","%s" %t_to_s)
G
Ganlin Zhao 已提交
2155 2156

            column_2 = ['(%s,timeutil)'%(random.sample(fun_fix_column,1))]
2157 2158 2159
            fun_column_2 = random.sample(time_functions,1)+random.sample(column_2,1)
            time_fun_2 = str(fun_column_2).replace("[","").replace("]","").replace("'","").replace(", ","").replace("\"","").replace("t_to_s","'t_to_s'")
            time_fun_2 = str(time_fun_2).replace("timeutil","%s" %timeunit).replace("t_to_s","%s" %t_to_s)
G
Ganlin Zhao 已提交
2160 2161


2162
            fun_fix_column_j = ['(t1.q_ts)','(t1.ts)', '(t2.q_ts)','(t2.ts)','(1600000000000)','(1600000000000000)','(1600000000000000000)',
G
Ganlin Zhao 已提交
2163 2164 2165
                        '(%d)' %t, '(%d000)' %t, '(%d000000)' %t,'t_to_s']

            column_j1 = ['(%s,timeutil)'%(random.sample(fun_fix_column_j,1))]
2166 2167 2168
            fun_column_join_1 = random.sample(time_functions,1)+random.sample(column_j1,1)
            time_fun_join_1 = str(fun_column_join_1).replace("[","").replace("]","").replace("'","").replace(", ","").replace("\"","").replace("t_to_s","'t_to_s'")
            time_fun_join_1 = str(time_fun_join_1).replace("timeutil","%s" %timeunit).replace("t_to_s","%s" %t_to_s)
G
Ganlin Zhao 已提交
2169 2170

            column_j2 = ['(%s,timeutil)'%(random.sample(fun_fix_column_j,1))]
2171 2172 2173 2174 2175
            fun_column_join_2 = random.sample(time_functions,1)+random.sample(column_j2,1)
            time_fun_join_2 = str(fun_column_join_2).replace("[","").replace("]","").replace("'","").replace(", ","").replace("\"","").replace("t_to_s","'t_to_s'")
            time_fun_join_2 = str(time_fun_join_2).replace("timeutil","%s" %timeunit).replace("t_to_s","%s" %t_to_s)

        elif (timelist == ['TO_ISO8601']):
G
Ganlin Zhao 已提交
2176 2177 2178
            time_functions = timelist

            t = time.time()
2179 2180
            fun_fix_column = ['(now())','(ts)','(q_ts)','(_rowts)','(_c0)','(_C0)',
                              '(1600000000000)','(1600000000000000)','(1600000000000000000)',
G
Ganlin Zhao 已提交
2181 2182
                              '(%d)' %t, '(%d000)' %t, '(%d000000)' %t]

2183 2184
            fun_column_1 = random.sample(time_functions,1)+random.sample(fun_fix_column,1)
            time_fun_1 = str(fun_column_1).replace("[","").replace("]","").replace("'","").replace(", ","")
G
Ganlin Zhao 已提交
2185

2186 2187
            fun_column_2 = random.sample(time_functions,1)+random.sample(fun_fix_column,1)
            time_fun_2 = str(fun_column_2).replace("[","").replace("]","").replace("'","").replace(", ","")
G
Ganlin Zhao 已提交
2188

2189
            fun_fix_column_j = ['(t1.q_ts)','(t1.ts)', '(t2.q_ts)','(t2.ts)','(1600000000000)','(1600000000000000)','(1600000000000000000)','(now())',
G
Ganlin Zhao 已提交
2190 2191
                                '(%d)' %t, '(%d000)' %t, '(%d000000)' %t]

2192 2193
            fun_column_join_1 = random.sample(time_functions,1)+random.sample(fun_fix_column_j,1)
            time_fun_join_1 = str(fun_column_join_1).replace("[","").replace("]","").replace("'","").replace(", ","")
G
Ganlin Zhao 已提交
2194

2195 2196 2197 2198
            fun_column_join_2 = random.sample(time_functions,1)+random.sample(fun_fix_column_j,1)
            time_fun_join_2 = str(fun_column_join_2).replace("[","").replace("]","").replace("'","").replace(", ","")

        elif (timelist == ['TO_UNIXTIMESTAMP']):
G
Ganlin Zhao 已提交
2199 2200 2201 2202 2203 2204
            time_functions = timelist

            t = time.time()
            t_to_s =  time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(t))
            fun_fix_column = ['(q_nchar)','(q_nchar1)','(q_nchar2)','(q_nchar3)','(q_nchar4)','(q_nchar_null)','(q_binary)','(q_binary5)','(q_binary6)','(q_binary7)','(q_binary8)','(q_binary_null)','(t_to_s)']

2205 2206 2207
            fun_column_1 = random.sample(time_functions,1)+random.sample(fun_fix_column,1)
            time_fun_1 = str(fun_column_1).replace("[","").replace("]","").replace("'","").replace(", ","").replace("t_to_s","'t_to_s'")
            time_fun_1 = str(time_fun_1).replace("t_to_s","%s" %t_to_s)
G
Ganlin Zhao 已提交
2208

2209 2210 2211
            fun_column_2 = random.sample(time_functions,1)+random.sample(fun_fix_column,1)
            time_fun_2 = str(fun_column_2).replace("[","").replace("]","").replace("'","").replace(", ","").replace("t_to_s","'t_to_s'")
            time_fun_2 = str(time_fun_2).replace("t_to_s","%s" %t_to_s)
G
Ganlin Zhao 已提交
2212 2213 2214

            fun_fix_column_j = ['(t1.q_nchar)','(t1.q_binary)', '(t2.q_nchar)','(t2.q_binary)','(t_to_s)']

2215 2216 2217
            fun_column_join_1 = random.sample(time_functions,1)+random.sample(fun_fix_column_j,1)
            time_fun_join_1 = str(fun_column_join_1).replace("[","").replace("]","").replace("'","").replace(", ","").replace("t_to_s","'t_to_s'")
            time_fun_join_1 = str(time_fun_join_1).replace("t_to_s","%s" %t_to_s)
G
Ganlin Zhao 已提交
2218

2219 2220 2221 2222 2223
            fun_column_join_2 = random.sample(time_functions,1)+random.sample(fun_fix_column_j,1)
            time_fun_join_2 = str(fun_column_join_2).replace("[","").replace("]","").replace("'","").replace(", ","").replace("t_to_s","'t_to_s'")
            time_fun_join_2 = str(time_fun_join_2).replace("t_to_s","%s" %t_to_s)

        elif (timelist == ['TIMEDIFF']):
G
Ganlin Zhao 已提交
2224 2225 2226 2227 2228 2229
            time_functions = timelist

            t = time.time()
            t_to_s =  time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(t))
            fun_fix_column = ['(q_nchar)','(q_nchar1)','(q_nchar2)','(q_nchar3)','(q_nchar4)','(q_nchar_null)','(q_binary)','(q_binary5)','(q_binary6)','(q_binary7)','(q_binary8)','(q_binary_null)','(t_to_s)']

2230 2231 2232
            fun_column_1 = random.sample(time_functions,1)+random.sample(fun_fix_column,1)
            time_fun_1 = str(fun_column_1).replace("[","").replace("]","").replace("'","").replace(", ","").replace("t_to_s","'t_to_s'")
            time_fun_1 = str(time_fun_1).replace("t_to_s","%s" %t_to_s)
G
Ganlin Zhao 已提交
2233

2234 2235 2236
            fun_column_2 = random.sample(time_functions,1)+random.sample(fun_fix_column,1)
            time_fun_2 = str(fun_column_2).replace("[","").replace("]","").replace("'","").replace(", ","").replace("t_to_s","'t_to_s'")
            time_fun_2 = str(time_fun_2).replace("t_to_s","%s" %t_to_s)
G
Ganlin Zhao 已提交
2237 2238 2239

            fun_fix_column_j = ['(t1.q_nchar)','(t1.q_binary)', '(t2.q_nchar)','(t2.q_binary)','(t_to_s)']

2240 2241 2242
            fun_column_join_1 = random.sample(time_functions,1)+random.sample(fun_fix_column_j,1)
            time_fun_join_1 = str(fun_column_join_1).replace("[","").replace("]","").replace("'","").replace(", ","").replace("t_to_s","'t_to_s'")
            time_fun_join_1 = str(time_fun_join_1).replace("t_to_s","%s" %t_to_s)
G
Ganlin Zhao 已提交
2243

2244 2245 2246 2247 2248
            fun_column_join_2 = random.sample(time_functions,1)+random.sample(fun_fix_column_j,1)
            time_fun_join_2 = str(fun_column_join_2).replace("[","").replace("]","").replace("'","").replace(", ","").replace("t_to_s","'t_to_s'")
            time_fun_join_2 = str(time_fun_join_2).replace("t_to_s","%s" %t_to_s)

        elif (timelist == ['ELAPSED']):
G
Ganlin Zhao 已提交
2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259
            time_functions = timelist

            fun_fix_column = ['(ts)','(q_ts)','(_c0)','(_C0)','(_rowts)','(ts,time_unit)','(_c0,time_unit)','(_C0,time_unit)','(_rowts,time_unit)']

            time_units = ['nums','numm','numh','numd','numa']
            time_unit = str(random.sample(time_units,1)).replace("[","").replace("]","").replace("'","")
            time_num1 = random.randint(0, 1000)
            time_unit1 = time_unit.replace("num","%d" %time_num1)
            time_num2 = random.randint(0, 1000)
            time_unit2 = time_unit.replace("num","%d" %time_num2)

2260 2261
            fun_column_1 = random.sample(time_functions,1)+random.sample(fun_fix_column,1)
            time_fun_1 = str(fun_column_1).replace("[","").replace("]","").replace("'","").replace(", ","").replace("time_unit","%s" %time_unit1)
G
Ganlin Zhao 已提交
2262

2263 2264
            fun_column_2 = random.sample(time_functions,1)+random.sample(fun_fix_column,1)
            time_fun_2 = str(fun_column_2).replace("[","").replace("]","").replace("'","").replace(", ","").replace("time_unit","%s" %time_unit2)
G
Ganlin Zhao 已提交
2265 2266 2267 2268


            fun_fix_column_j = ['(t1.ts)','(t1.q_ts)', '(t2.ts)','(t2.q_ts)','(t1.ts,time_unit)','(t1.q_ts,time_unit)','(t2.ts,time_unit)','(t2.q_ts,time_unit)']

2269 2270
            fun_column_join_1 = random.sample(time_functions,1)+random.sample(fun_fix_column_j,1)
            time_fun_join_1 = str(fun_column_join_1).replace("[","").replace("]","").replace("'","").replace(", ","").replace("time_unit","%s" %time_unit1)
G
Ganlin Zhao 已提交
2271

2272 2273
            fun_column_join_2 = random.sample(time_functions,1)+random.sample(fun_fix_column_j,1)
            time_fun_join_2 = str(fun_column_join_2).replace("[","").replace("]","").replace("'","").replace(", ","").replace("time_unit","%s" %time_unit2)
G
Ganlin Zhao 已提交
2274 2275


2276
        elif (timelist == ['CAST']) :
G
Ganlin Zhao 已提交
2277
            str_functions = timelist
2278 2279 2280 2281 2282 2283 2284
            #下面的4个是全的,这个只是1个
            i = random.randint(1,4)
            if i ==1:
                print('===========cast_1===========')
                fun_fix_column = ['q_bool','q_bool_null','q_bigint','q_bigint_null','q_smallint','q_smallint_null',
                'q_tinyint','q_tinyint_null','q_int','q_int_null','q_float','q_float_null','q_double','q_double_null']
                type_names = ['BIGINT','BINARY(100)','TIMESTAMP','NCHAR(100)','BIGINT UNSIGNED']
G
Ganlin Zhao 已提交
2285 2286

                type_name1 = str(random.sample(type_names,1)).replace("[","").replace("]","").replace("'","")
2287 2288
                fun_column_1 = str(random.sample(str_functions,1))+'('+str(random.sample(fun_fix_column,1))+' AS '+type_name1+')'
                time_fun_1 = str(fun_column_1).replace("[","").replace("]","").replace("'","")
G
Ganlin Zhao 已提交
2289 2290

                type_name2 = str(random.sample(type_names,1)).replace("[","").replace("]","").replace("'","")
2291 2292
                fun_column_2 = str(random.sample(str_functions,1))+'('+str(random.sample(fun_fix_column,1))+' AS '+type_name2+')'
                time_fun_2 = str(fun_column_2).replace("[","").replace("]","").replace("'","")
G
Ganlin Zhao 已提交
2293

2294 2295 2296
                fun_fix_column_j = ['t1.q_bool','t1.q_bool_null','t1.q_bigint','t1.q_bigint_null','t1.q_smallint','t1.q_smallint_null',
                't1.q_tinyint','t1.q_tinyint_null','t1.q_int','t1.q_int_null','t1.q_float','t1.q_float_null','t1.q_double','t1.q_double_null',
                't2.q_bool','t2.q_bool_null','t2.q_bigint','t2.q_bigint_null','t2.q_smallint','t2.q_smallint_null',
G
Ganlin Zhao 已提交
2297 2298 2299
                't2.q_tinyint','t2.q_tinyint_null','t2.q_int','t2.q_int_null','t2.q_float','t2.q_float_null','t2.q_double','t2.q_double_null']

                type_name_j1 = str(random.sample(type_names,1)).replace("[","").replace("]","").replace("'","")
2300 2301
                fun_column_join_1 = str(random.sample(str_functions,1))+'('+str(random.sample(fun_fix_column_j,1))+' AS '+type_name_j1+')'
                time_fun_join_1 = str(fun_column_join_1).replace("[","").replace("]","").replace("'","")
G
Ganlin Zhao 已提交
2302 2303

                type_name_j2 = str(random.sample(type_names,1)).replace("[","").replace("]","").replace("'","")
2304
                fun_column_join_2 = str(random.sample(str_functions,1))+'('+str(random.sample(fun_fix_column_j,1))+' AS '+type_name_j2+')'
G
Ganlin Zhao 已提交
2305 2306
                time_fun_join_2 = str(fun_column_join_2).replace("[","").replace("]","").replace("'","")

2307 2308 2309 2310
            elif i==2:
                print('===========cast_2===========')
                fun_fix_column = ['q_binary','q_binary_null','q_binary1','q_binary2','q_binary3','q_binary4']
                type_names = ['BIGINT','BINARY(100)','NCHAR(100)','BIGINT UNSIGNED']
G
Ganlin Zhao 已提交
2311

2312 2313 2314 2315 2316 2317 2318
                type_name1 = str(random.sample(type_names,1)).replace("[","").replace("]","").replace("'","")
                fun_column_1 = str(random.sample(str_functions,1))+'('+str(random.sample(fun_fix_column,1))+' AS '+type_name1+')'
                time_fun_1 = str(fun_column_1).replace("[","").replace("]","").replace("'","")

                type_name2 = str(random.sample(type_names,1)).replace("[","").replace("]","").replace("'","")
                fun_column_2 = str(random.sample(str_functions,1))+'('+str(random.sample(fun_fix_column,1))+' AS '+type_name2+')'
                time_fun_2 = str(fun_column_2).replace("[","").replace("]","").replace("'","")
G
Ganlin Zhao 已提交
2319

2320
                fun_fix_column_j = ['t1.q_binary','t1.q_binary_null','t1.q_binary1','t1.q_binary2','t1.q_binary3','t1.q_smallint_null','t1.q_binary4',
G
Ganlin Zhao 已提交
2321 2322 2323
                        't2.q_binary','t2.q_binary_null','t2.q_bigint','t2.q_binary1','t2.q_binary2','t2.q_binary3','t2.q_binary4']

                type_name_j1 = str(random.sample(type_names,1)).replace("[","").replace("]","").replace("'","")
2324 2325
                fun_column_join_1 = str(random.sample(str_functions,1))+'('+str(random.sample(fun_fix_column_j,1))+' AS '+type_name_j1+')'
                time_fun_join_1 = str(fun_column_join_1).replace("[","").replace("]","").replace("'","")
G
Ganlin Zhao 已提交
2326 2327

                type_name_j2 = str(random.sample(type_names,1)).replace("[","").replace("]","").replace("'","")
2328
                fun_column_join_2 = str(random.sample(str_functions,1))+'('+str(random.sample(fun_fix_column_j,1))+' AS '+type_name_j2+')'
G
Ganlin Zhao 已提交
2329 2330
                time_fun_join_2 = str(fun_column_join_2).replace("[","").replace("]","").replace("'","")

2331 2332 2333 2334
            elif i==3:
                print('===========cast_3===========')
                fun_fix_column = ['q_nchar','q_nchar_null','q_nchar5','q_nchar6','q_nchar7','q_nchar8']
                type_names = ['BIGINT','NCHAR(100)','BIGINT UNSIGNED']
G
Ganlin Zhao 已提交
2335

2336 2337
                type_name1 = str(random.sample(type_names,1)).replace("[","").replace("]","").replace("'","")
                fun_column_1 = str(random.sample(str_functions,1))+'('+str(random.sample(fun_fix_column,1))+' AS '+type_name1+')'
G
Ganlin Zhao 已提交
2338
                time_fun_1 = str(fun_column_1).replace("[","").replace("]","").replace("'","")
2339 2340 2341

                type_name2 = str(random.sample(type_names,1)).replace("[","").replace("]","").replace("'","")
                fun_column_2 = str(random.sample(str_functions,1))+'('+str(random.sample(fun_fix_column,1))+' AS '+type_name2+')'
G
Ganlin Zhao 已提交
2342 2343
                time_fun_2 = str(fun_column_2).replace("[","").replace("]","").replace("'","")

2344
                fun_fix_column_j = ['t1.q_nchar','t1.q_nchar_null','t1.q_nchar5','t1.q_nchar6','t1.q_nchar7','t1.q_nchar8',
G
Ganlin Zhao 已提交
2345 2346 2347
                        't2.q_nchar','t2.q_nchar_null','t2.q_nchar5','t2.q_nchar6','t2.q_nchar7','t2.q_nchar8']

                type_name_j1 = str(random.sample(type_names,1)).replace("[","").replace("]","").replace("'","")
2348 2349
                fun_column_join_1 = str(random.sample(str_functions,1))+'('+str(random.sample(fun_fix_column_j,1))+' AS '+type_name_j1+')'
                time_fun_join_1 = str(fun_column_join_1).replace("[","").replace("]","").replace("'","")
G
Ganlin Zhao 已提交
2350 2351

                type_name_j2 = str(random.sample(type_names,1)).replace("[","").replace("]","").replace("'","")
2352
                fun_column_join_2 = str(random.sample(str_functions,1))+'('+str(random.sample(fun_fix_column_j,1))+' AS '+type_name_j2+')'
G
Ganlin Zhao 已提交
2353 2354
                time_fun_join_2 = str(fun_column_join_2).replace("[","").replace("]","").replace("'","")

2355 2356 2357 2358
            elif i==4:
                print('===========cast_4===========')
                fun_fix_column = ['q_ts','q_ts_null','_C0','_c0','ts','_rowts']
                type_names = ['BIGINT','TIMESTAMP','BIGINT UNSIGNED']
G
Ganlin Zhao 已提交
2359

2360 2361
                type_name1 = str(random.sample(type_names,1)).replace("[","").replace("]","").replace("'","")
                fun_column_1 = str(random.sample(str_functions,1))+'('+str(random.sample(fun_fix_column,1))+' AS '+type_name1+')'
G
Ganlin Zhao 已提交
2362 2363
                time_fun_1 = str(fun_column_1).replace("[","").replace("]","").replace("'","")

2364 2365
                type_name2 = str(random.sample(type_names,1)).replace("[","").replace("]","").replace("'","")
                fun_column_2 = str(random.sample(str_functions,1))+'('+str(random.sample(fun_fix_column,1))+' AS '+type_name2+')'
G
Ganlin Zhao 已提交
2366 2367 2368 2369 2370
                time_fun_2 = str(fun_column_2).replace("[","").replace("]","").replace("'","")

                fun_fix_column_j = ['t1.q_ts','t1.q_ts_null','t1.ts','t2.q_ts','t2.q_ts_null','t2.ts']

                type_name_j1 = str(random.sample(type_names,1)).replace("[","").replace("]","").replace("'","")
2371 2372
                fun_column_join_1 = str(random.sample(str_functions,1))+'('+str(random.sample(fun_fix_column_j,1))+' AS '+type_name_j1+')'
                time_fun_join_1 = str(fun_column_join_1).replace("[","").replace("]","").replace("'","")
G
Ganlin Zhao 已提交
2373 2374

                type_name_j2 = str(random.sample(type_names,1)).replace("[","").replace("]","").replace("'","")
2375
                fun_column_join_2 = str(random.sample(str_functions,1))+'('+str(random.sample(fun_fix_column_j,1))+' AS '+type_name_j2+')'
G
Ganlin Zhao 已提交
2376 2377
                time_fun_join_2 = str(fun_column_join_2).replace("[","").replace("]","").replace("'","")

2378
        elif (timelist == ['CAST_1']) :
G
Ganlin Zhao 已提交
2379 2380
            str_functions = timelist

2381 2382 2383 2384
            print('===========cast_1===========')
            fun_fix_column = ['q_bool','q_bool_null','q_bigint','q_bigint_null','q_smallint','q_smallint_null',
            'q_tinyint','q_tinyint_null','q_int','q_int_null','q_float','q_float_null','q_double','q_double_null']
            type_names = ['BIGINT','BINARY(100)','TIMESTAMP','NCHAR(100)','BIGINT UNSIGNED']
G
Ganlin Zhao 已提交
2385 2386

            type_name1 = str(random.sample(type_names,1)).replace("[","").replace("]","").replace("'","")
2387
            fun_column_1 = str(random.sample(str_functions,1))+'('+str(random.sample(fun_fix_column,1))+' AS '+type_name1+')'
G
Ganlin Zhao 已提交
2388 2389 2390
            time_fun_1 = str(fun_column_1).replace("[","").replace("]","").replace("'","").replace("_1","")

            type_name2 = str(random.sample(type_names,1)).replace("[","").replace("]","").replace("'","")
2391
            fun_column_2 = str(random.sample(str_functions,1))+'('+str(random.sample(fun_fix_column,1))+' AS '+type_name2+')'
G
Ganlin Zhao 已提交
2392 2393
            time_fun_2 = str(fun_column_2).replace("[","").replace("]","").replace("'","").replace("_1","")

2394 2395 2396
            fun_fix_column_j = ['t1.q_bool','t1.q_bool_null','t1.q_bigint','t1.q_bigint_null','t1.q_smallint','t1.q_smallint_null',
            't1.q_tinyint','t1.q_tinyint_null','t1.q_int','t1.q_int_null','t1.q_float','t1.q_float_null','t1.q_double','t1.q_double_null',
            't2.q_bool','t2.q_bool_null','t2.q_bigint','t2.q_bigint_null','t2.q_smallint','t2.q_smallint_null',
G
Ganlin Zhao 已提交
2397 2398 2399
            't2.q_tinyint','t2.q_tinyint_null','t2.q_int','t2.q_int_null','t2.q_float','t2.q_float_null','t2.q_double','t2.q_double_null']

            type_name_j1 = str(random.sample(type_names,1)).replace("[","").replace("]","").replace("'","")
2400
            fun_column_join_1 = str(random.sample(str_functions,1))+'('+str(random.sample(fun_fix_column_j,1))+' AS '+type_name_j1+')'
G
Ganlin Zhao 已提交
2401 2402 2403
            time_fun_join_1 = str(fun_column_join_1).replace("[","").replace("]","").replace("'","").replace("_1","")

            type_name_j2 = str(random.sample(type_names,1)).replace("[","").replace("]","").replace("'","")
2404
            fun_column_join_2 = str(random.sample(str_functions,1))+'('+str(random.sample(fun_fix_column_j,1))+' AS '+type_name_j2+')'
G
Ganlin Zhao 已提交
2405 2406
            time_fun_join_2 = str(fun_column_join_2).replace("[","").replace("]","").replace("'","").replace("_1","")

2407
        elif (timelist == ['CAST_2']) :
G
Ganlin Zhao 已提交
2408
            str_functions = timelist
2409 2410 2411
            print('===========cast_2===========')
            fun_fix_column = ['q_binary','q_binary_null','q_binary1','q_binary2','q_binary3','q_binary4']
            type_names = ['BIGINT','BINARY(100)','NCHAR(100)','BIGINT UNSIGNED']
G
Ganlin Zhao 已提交
2412

2413 2414
            type_name1 = str(random.sample(type_names,1)).replace("[","").replace("]","").replace("'","")
            fun_column_1 = str(random.sample(str_functions,1))+'('+str(random.sample(fun_fix_column,1))+' AS '+type_name1+')'
G
Ganlin Zhao 已提交
2415
            time_fun_1 = str(fun_column_1).replace("[","").replace("]","").replace("'","").replace("_2","")
2416 2417 2418

            type_name2 = str(random.sample(type_names,1)).replace("[","").replace("]","").replace("'","")
            fun_column_2 = str(random.sample(str_functions,1))+'('+str(random.sample(fun_fix_column,1))+' AS '+type_name2+')'
G
Ganlin Zhao 已提交
2419 2420
            time_fun_2 = str(fun_column_2).replace("[","").replace("]","").replace("'","").replace("_2","")

2421
            fun_fix_column_j = ['t1.q_binary','t1.q_binary_null','t1.q_binary1','t1.q_binary2','t1.q_binary3','t1.q_smallint_null','t1.q_binary4',
G
Ganlin Zhao 已提交
2422 2423 2424
                    't2.q_binary','t2.q_binary_null','t2.q_bigint','t2.q_binary1','t2.q_binary2','t2.q_binary3','t2.q_binary4']

            type_name_j1 = str(random.sample(type_names,1)).replace("[","").replace("]","").replace("'","")
2425
            fun_column_join_1 = str(random.sample(str_functions,1))+'('+str(random.sample(fun_fix_column_j,1))+' AS '+type_name_j1+')'
G
Ganlin Zhao 已提交
2426 2427 2428
            time_fun_join_1 = str(fun_column_join_1).replace("[","").replace("]","").replace("'","").replace("_2","")

            type_name_j2 = str(random.sample(type_names,1)).replace("[","").replace("]","").replace("'","")
2429
            fun_column_join_2 = str(random.sample(str_functions,1))+'('+str(random.sample(fun_fix_column_j,1))+' AS '+type_name_j2+')'
G
Ganlin Zhao 已提交
2430 2431
            time_fun_join_2 = str(fun_column_join_2).replace("[","").replace("]","").replace("'","").replace("_2","")

2432
        elif (timelist == ['CAST_3']) :
G
Ganlin Zhao 已提交
2433
            str_functions = timelist
2434 2435 2436
            print('===========cast_3===========')
            fun_fix_column = ['q_nchar','q_nchar_null','q_nchar5','q_nchar6','q_nchar7','q_nchar8']
            type_names = ['BIGINT','NCHAR(100)','BIGINT UNSIGNED']
G
Ganlin Zhao 已提交
2437

2438 2439
            type_name1 = str(random.sample(type_names,1)).replace("[","").replace("]","").replace("'","")
            fun_column_1 = str(random.sample(str_functions,1))+'('+str(random.sample(fun_fix_column,1))+' AS '+type_name1+')'
G
Ganlin Zhao 已提交
2440
            time_fun_1 = str(fun_column_1).replace("[","").replace("]","").replace("'","").replace("_3","")
2441 2442 2443

            type_name2 = str(random.sample(type_names,1)).replace("[","").replace("]","").replace("'","")
            fun_column_2 = str(random.sample(str_functions,1))+'('+str(random.sample(fun_fix_column,1))+' AS '+type_name2+')'
G
Ganlin Zhao 已提交
2444 2445
            time_fun_2 = str(fun_column_2).replace("[","").replace("]","").replace("'","").replace("_3","")

2446
            fun_fix_column_j = ['t1.q_nchar','t1.q_nchar_null','t1.q_nchar5','t1.q_nchar6','t1.q_nchar7','t1.q_nchar8',
G
Ganlin Zhao 已提交
2447 2448 2449
                    't2.q_nchar','t2.q_nchar_null','t2.q_nchar5','t2.q_nchar6','t2.q_nchar7','t2.q_nchar8']

            type_name_j1 = str(random.sample(type_names,1)).replace("[","").replace("]","").replace("'","")
2450
            fun_column_join_1 = str(random.sample(str_functions,1))+'('+str(random.sample(fun_fix_column_j,1))+' AS '+type_name_j1+')'
G
Ganlin Zhao 已提交
2451 2452 2453
            time_fun_join_1 = str(fun_column_join_1).replace("[","").replace("]","").replace("'","").replace("_3","")

            type_name_j2 = str(random.sample(type_names,1)).replace("[","").replace("]","").replace("'","")
2454
            fun_column_join_2 = str(random.sample(str_functions,1))+'('+str(random.sample(fun_fix_column_j,1))+' AS '+type_name_j2+')'
G
Ganlin Zhao 已提交
2455 2456
            time_fun_join_2 = str(fun_column_join_2).replace("[","").replace("]","").replace("'","").replace("_3","")

2457
        elif (timelist == ['CAST_4']) :
G
Ganlin Zhao 已提交
2458
            str_functions = timelist
2459 2460 2461
            print('===========cast_4===========')
            fun_fix_column = ['q_ts','q_ts_null','_C0','_c0','ts','_rowts']
            type_names = ['BIGINT','TIMESTAMP','BIGINT UNSIGNED']
G
Ganlin Zhao 已提交
2462

2463 2464
            type_name1 = str(random.sample(type_names,1)).replace("[","").replace("]","").replace("'","")
            fun_column_1 = str(random.sample(str_functions,1))+'('+str(random.sample(fun_fix_column,1))+' AS '+type_name1+')'
G
Ganlin Zhao 已提交
2465 2466
            time_fun_1 = str(fun_column_1).replace("[","").replace("]","").replace("'","").replace("_4","")

2467 2468
            type_name2 = str(random.sample(type_names,1)).replace("[","").replace("]","").replace("'","")
            fun_column_2 = str(random.sample(str_functions,1))+'('+str(random.sample(fun_fix_column,1))+' AS '+type_name2+')'
G
Ganlin Zhao 已提交
2469 2470 2471 2472 2473
            time_fun_2 = str(fun_column_2).replace("[","").replace("]","").replace("'","").replace("_4","")

            fun_fix_column_j = ['t1.q_ts','t1.q_ts_null','t1.ts','t2.q_ts','t2.q_ts_null','t2.ts']

            type_name_j1 = str(random.sample(type_names,1)).replace("[","").replace("]","").replace("'","")
2474
            fun_column_join_1 = str(random.sample(str_functions,1))+'('+str(random.sample(fun_fix_column_j,1))+' AS '+type_name_j1+')'
G
Ganlin Zhao 已提交
2475 2476 2477
            time_fun_join_1 = str(fun_column_join_1).replace("[","").replace("]","").replace("'","").replace("_4","")

            type_name_j2 = str(random.sample(type_names,1)).replace("[","").replace("]","").replace("'","")
2478
            fun_column_join_2 = str(random.sample(str_functions,1))+'('+str(random.sample(fun_fix_column_j,1))+' AS '+type_name_j2+')'
G
Ganlin Zhao 已提交
2479 2480
            time_fun_join_2 = str(fun_column_join_2).replace("[","").replace("]","").replace("'","").replace("_4","")

2481 2482 2483 2484
        tdSql.query("select 1-1 as time_nest from stable_1 limit 1;")
        for i in range(self.fornum):
            if (timelist == ['NOW','TODAY']) or (timelist == ['TIMETRUNCATE']) or (timelist == ['TO_ISO8601'])\
                or (timelist == ['TO_UNIXTIMESTAMP']):
G
Ganlin Zhao 已提交
2485 2486 2487
                sql = "select  ts , timediff(asct1,now)  from  ( select  "
                sql += "%s as asct1, " % time_fun_1
                sql += "%s as asct2, " % time_fun_2
2488
                sql += "%s, " % random.choice(self.s_s_select)
G
Ganlin Zhao 已提交
2489
                sql += "%s, " % random.choice(self.q_select)
2490 2491 2492 2493
                sql += "ts from regular_table_1 where "
                sql += "%s " % random.choice(self.q_where)
                sql += "%s " % random.choice(self.order_where)
                sql += ");"
G
Ganlin Zhao 已提交
2494 2495
                tdLog.info(sql)
                tdLog.info(len(sql))
2496 2497 2498 2499 2500
                tdSql.query(sql)
                tdSql.checkRows(100)
                self.cur1.execute(sql)
            elif (timelist == ['TIMEZONE']) \
                or (timelist == ['CAST']) or (timelist == ['CAST_1']) or (timelist == ['CAST_2']) or (timelist == ['CAST_3']) or (timelist == ['CAST_4']):
G
Ganlin Zhao 已提交
2501 2502 2503
                sql = "select  ts , asct1,now(),today(),timezone()  from  ( select  "
                sql += "%s as asct1, " % time_fun_1
                sql += "%s as asct2, " % time_fun_2
2504
                sql += "%s, " % random.choice(self.s_s_select)
G
Ganlin Zhao 已提交
2505
                sql += "%s, " % random.choice(self.q_select)
2506 2507 2508 2509
                sql += "ts from regular_table_1 where "
                sql += "%s " % random.choice(self.q_where)
                sql += "%s " % random.choice(self.order_where)
                sql += ");"
G
Ganlin Zhao 已提交
2510 2511
                tdLog.info(sql)
                tdLog.info(len(sql))
2512 2513 2514 2515
                tdSql.query(sql)
                tdSql.checkRows(100)
                self.cur1.execute(sql)
            elif (timelist == ['ELAPSED']) :
G
Ganlin Zhao 已提交
2516 2517 2518
                sql = "select  max(asct1),now(),today(),timezone()  from  ( select  "
                sql += "%s as asct1, " % time_fun_1
                sql += "%s as asct2 " % time_fun_2
2519 2520 2521
                sql += "from regular_table_1 where "
                sql += "%s " % random.choice(self.q_where)
                sql += ");"
G
Ganlin Zhao 已提交
2522 2523
                tdLog.info(sql)
                tdLog.info(len(sql))
2524 2525
                tdSql.query(sql)
                self.cur1.execute(sql)
G
Ganlin Zhao 已提交
2526

2527 2528 2529 2530 2531
        tdSql.query("select 1-2 as time_nest from stable_1 limit 1;")
        for i in range(self.fornum):
            if (timelist == ['NOW','TODAY']) or (timelist == ['TIMETRUNCATE']) or (timelist == ['TO_ISO8601'])\
                or (timelist == ['TO_UNIXTIMESTAMP']):
                sql = "select  ts , timediff(asct1,now),now(),today(),timezone()  from  ( select  "
G
Ganlin Zhao 已提交
2532
                sql += "%s as asct1,  " % time_fun_1
2533
                sql += "%s, " % random.choice(self.s_s_select)
G
Ganlin Zhao 已提交
2534
                sql += "%s, " % random.choice(self.q_select)
2535 2536 2537
                sql += "ts ts from regular_table_1 where "
                sql += "%s " % random.choice(self.q_where)
                sql += "%s )" % random.choice(self.order_where)
G
Ganlin Zhao 已提交
2538
                sql += "%s " % random.choice(self.unionall_or_union)
2539
                sql += "select  ts ,  timediff(asct2,now),now(),today(),timezone() from  ( select  "
G
Ganlin Zhao 已提交
2540
                sql += "%s as asct2,  " % time_fun_2
2541
                sql += "%s, " % random.choice(self.s_s_select)
G
Ganlin Zhao 已提交
2542
                sql += "%s, " % random.choice(self.q_select)
2543
                sql += "ts ts from regular_table_1 where "
G
Ganlin Zhao 已提交
2544
                sql += "%s " % random.choice(self.q_where)
2545 2546 2547 2548
                #sql += "%s " % random.choice(having_support)
                sql += "%s " % random.choice(self.order_where)
                sql += "%s " % random.choice(self.limit1_where)
                sql += ")"
G
Ganlin Zhao 已提交
2549 2550
                tdLog.info(sql)
                tdLog.info(len(sql))
2551
                #TD-15437 tdSql.query(sql)
G
Ganlin Zhao 已提交
2552
                #TD-15437 self.cur1.execute(sql)
2553 2554
            elif (timelist == ['TIMEZONE']) or (timelist == ['CAST']) or (timelist == ['CAST_1']) or (timelist == ['CAST_2']) or (timelist == ['CAST_3']) or (timelist == ['CAST_4']):
                sql = "select  ts , (asct1),now(),today(),timezone()  from  ( select  "
G
Ganlin Zhao 已提交
2555
                sql += "%s as asct1,  " % time_fun_1
2556
                sql += "%s, " % random.choice(self.s_s_select)
G
Ganlin Zhao 已提交
2557
                sql += "%s, " % random.choice(self.q_select)
2558 2559 2560
                sql += "ts ts from regular_table_1 where "
                sql += "%s " % random.choice(self.q_where)
                sql += "%s )" % random.choice(self.order_where)
G
Ganlin Zhao 已提交
2561
                sql += "%s " % random.choice(self.unionall_or_union)
2562
                sql += "select  ts , asct2,now(),today(),timezone() from  ( select  "
G
Ganlin Zhao 已提交
2563
                sql += "%s as asct2,  " % time_fun_2
2564
                sql += "%s, " % random.choice(self.s_s_select)
G
Ganlin Zhao 已提交
2565
                sql += "%s, " % random.choice(self.q_select)
2566
                sql += "ts ts from regular_table_1 where "
G
Ganlin Zhao 已提交
2567
                sql += "%s " % random.choice(self.q_where)
2568 2569 2570
                sql += "%s " % random.choice(self.order_where)
                sql += "%s " % random.choice(self.limit1_where)
                sql += ")"
G
Ganlin Zhao 已提交
2571 2572
                tdLog.info(sql)
                tdLog.info(len(sql))
2573
                #TD-15437 tdSql.query(sql)
G
Ganlin Zhao 已提交
2574 2575
                #TD-15437 self.cur1.execute(sql)
            elif (timelist == ['ELAPSED']) :
2576
                sql = "select  min(asct1),now(),today(),timezone()  from  ( select  "
G
Ganlin Zhao 已提交
2577
                sql += "%s as asct1  " % time_fun_1
2578 2579
                sql += " from regular_table_1 where "
                sql += "%s )" % random.choice(self.q_where)
G
Ganlin Zhao 已提交
2580
                sql += "%s " % random.choice(self.unionall_or_union)
2581
                sql += "select   avg(asct2),now(),today(),timezone()  from  ( select  "
G
Ganlin Zhao 已提交
2582
                sql += "%s as asct2  " % time_fun_2
2583
                sql += " from regular_table_1 where "
G
Ganlin Zhao 已提交
2584
                sql += "%s " % random.choice(self.q_where)
2585 2586
                sql += "%s " % random.choice(self.limit1_where)
                sql += ")"
G
Ganlin Zhao 已提交
2587 2588
                tdLog.info(sql)
                tdLog.info(len(sql))
2589
                tdSql.query(sql)
G
Ganlin Zhao 已提交
2590 2591
                self.cur1.execute(sql)

2592 2593 2594 2595 2596 2597 2598 2599
        tdSql.query("select 1-3 as time_nest from stable_1 limit 1;")
        for i in range(self.fornum):
            if (timelist == ['NOW','TODAY']) or (timelist == ['TIMETRUNCATE']) or (timelist == ['TO_ISO8601'])\
                or (timelist == ['TO_UNIXTIMESTAMP']):
                sql = "select  ts , timediff(asct1,now) from  ( select  "
                sql += "%s as asct1, ts ," % time_fun_1
                sql += "%s as asct2, " % time_fun_2
                sql += "%s, " % random.choice(self.s_s_select)
G
Ganlin Zhao 已提交
2600
                sql += "%s, " % random.choice(self.q_select)
2601 2602
                sql += "ts from regular_table_1 where "
                sql += "%s " % random.choice(self.q_where)
G
Ganlin Zhao 已提交
2603
                sql += "%s select " % random.choice(self.unionall_or_union)
2604 2605 2606
                sql += "%s as asct2, ts ," % time_fun_2
                sql += "%s as asct1, " % time_fun_1
                sql += "%s, " % random.choice(self.s_s_select)
G
Ganlin Zhao 已提交
2607
                sql += "%s, " % random.choice(self.q_select)
2608 2609 2610 2611
                sql += "ts from regular_table_2 where "
                sql += "%s " % random.choice(self.q_where)
                sql += "%s " % random.choice(self.order_where)
                sql += ")"
G
Ganlin Zhao 已提交
2612 2613
                tdLog.info(sql)
                tdLog.info(len(sql))
2614 2615 2616 2617 2618 2619 2620
                #TD-15473 tdSql.query(sql)
                #self.cur1.execute(sql)
            elif (timelist == ['TIMEZONE']) or (timelist == ['CAST']) or (timelist == ['CAST_1']) or (timelist == ['CAST_2']) or (timelist == ['CAST_3']) or (timelist == ['CAST_4']):
                sql = "select  ts , (asct1),now(),today(),timezone()  from  ( select  "
                sql += "%s as asct1, ts ," % time_fun_1
                sql += "%s as asct2, " % time_fun_2
                sql += "%s, " % random.choice(self.s_s_select)
G
Ganlin Zhao 已提交
2621
                sql += "%s, " % random.choice(self.q_select)
2622 2623
                sql += "ts from regular_table_1 where "
                sql += "%s " % random.choice(self.q_where)
G
Ganlin Zhao 已提交
2624
                sql += "%s select " % random.choice(self.unionall_or_union)
2625 2626 2627
                sql += "%s as asct2, ts ," % time_fun_2
                sql += "%s as asct1, " % time_fun_1
                sql += "%s, " % random.choice(self.s_s_select)
G
Ganlin Zhao 已提交
2628
                sql += "%s, " % random.choice(self.q_select)
2629 2630 2631 2632
                sql += "ts from regular_table_2 where "
                sql += "%s " % random.choice(self.q_where)
                sql += "%s " % random.choice(self.order_where)
                sql += ")"
G
Ganlin Zhao 已提交
2633 2634
                tdLog.info(sql)
                tdLog.info(len(sql))
2635 2636
                #TD-15473 tdSql.query(sql)
                #self.cur1.execute(sql)
G
Ganlin Zhao 已提交
2637
            elif (timelist == ['ELAPSED']) :
2638 2639 2640 2641 2642
                sql = "select  abs(asct1),now(),today(),timezone()  from  ( select  "
                sql += "%s as asct1," % time_fun_1
                sql += "%s as asct2 " % time_fun_2
                sql += "from regular_table_1 where "
                sql += "%s " % random.choice(self.q_where)
G
Ganlin Zhao 已提交
2643
                sql += "%s select " % random.choice(self.unionall_or_union)
2644 2645 2646 2647 2648 2649
                sql += "%s as asct2," % time_fun_2
                sql += "%s as asct1  " % time_fun_1
                sql += "from regular_table_2 where "
                sql += "%s " % random.choice(self.q_where)
                sql += "%s " % random.choice(self.order_where)
                sql += ")"
G
Ganlin Zhao 已提交
2650 2651
                tdLog.info(sql)
                tdLog.info(len(sql))
2652 2653
                tdSql.query(sql)
                self.cur1.execute(sql)
G
Ganlin Zhao 已提交
2654

2655 2656 2657 2658 2659
        tdSql.query("select 1-4 as time_nest from stable_1 limit 1;")
        for i in range(self.fornum):
            if (timelist == ['NOW','TODAY']) or (timelist == ['TIMETRUNCATE']) or (timelist == ['TO_ISO8601'])\
                or (timelist == ['TO_UNIXTIMESTAMP']):
                sql = "select  ts , timediff(asct1,now) from  ( select  t1.ts as ts,"
G
Ganlin Zhao 已提交
2660 2661 2662 2663 2664
                sql += "%s, " % time_fun_join_1
                sql += "%s as asct1, " % time_fun_join_2
                sql += "%s, " % time_fun_join_1
                sql += "t1.%s, " % random.choice(self.q_select)
                sql += "t2.%s, " % random.choice(self.q_select)
2665 2666 2667 2668 2669
                sql += "t2.ts from regular_table_1 t1 , regular_table_2 t2 where t1.ts = t2.ts and "
                sql += "%s " % random.choice(self.q_u_where)
                sql += "and %s " % random.choice(self.q_u_or_where)
                sql += "%s " % random.choice(self.order_u_where)
                sql += ");"
G
Ganlin Zhao 已提交
2670 2671
                tdLog.info(sql)
                tdLog.info(len(sql))
2672 2673 2674 2675 2676
                tdSql.query(sql)
                tdSql.checkRows(100)
                self.cur1.execute(sql)
            elif (timelist == ['TIMEZONE']) or (timelist == ['CAST']) or (timelist == ['CAST_1']) or (timelist == ['CAST_2']) or (timelist == ['CAST_3']) or (timelist == ['CAST_4']):
                sql = "select  ts , (asct1) from  ( select  t1.ts as ts,"
G
Ganlin Zhao 已提交
2677 2678 2679 2680 2681
                sql += "%s, " % time_fun_join_1
                sql += "%s as asct1, " % time_fun_join_2
                sql += "%s, " % time_fun_join_1
                sql += "t1.%s, " % random.choice(self.q_select)
                sql += "t2.%s, " % random.choice(self.q_select)
2682 2683 2684 2685 2686
                sql += "t2.ts from regular_table_1 t1 , regular_table_2 t2 where t1.ts = t2.ts and "
                sql += "%s " % random.choice(self.q_u_where)
                sql += "and %s " % random.choice(self.q_u_or_where)
                sql += "%s " % random.choice(self.order_u_where)
                sql += ");"
G
Ganlin Zhao 已提交
2687 2688
                tdLog.info(sql)
                tdLog.info(len(sql))
2689 2690 2691
                tdSql.query(sql)
                tdSql.checkRows(100)
                self.cur1.execute(sql)
G
Ganlin Zhao 已提交
2692
            elif (timelist == ['ELAPSED']) :
2693
                sql = "select  floor(asct1) from  ( select "
G
Ganlin Zhao 已提交
2694 2695 2696
                sql += "%s, " % time_fun_join_1
                sql += "%s as asct1, " % time_fun_join_2
                sql += "%s " % time_fun_join_1
2697 2698 2699 2700
                sql += " from regular_table_1 t1 , regular_table_2 t2 where t1.ts = t2.ts and "
                sql += "%s " % random.choice(self.q_u_where)
                sql += "and %s " % random.choice(self.q_u_or_where)
                sql += ");"
G
Ganlin Zhao 已提交
2701 2702
                tdLog.info(sql)
                tdLog.info(len(sql))
2703 2704
                tdSql.query(sql)
                self.cur1.execute(sql)
G
Ganlin Zhao 已提交
2705

2706 2707
        tdSql.query("select 1-5 as time_nest from stable_1 limit 1;")
        for i in range(self.fornum):
G
Ganlin Zhao 已提交
2708
            if (timelist == ['ELAPSED']) :
2709
                sql = "select  now(),today(),timezone(), "
G
Ganlin Zhao 已提交
2710
                sql += "%s, " % time_fun_1
2711 2712 2713 2714
                sql += "%s  " % time_fun_2
                sql += " from  ( select  * from regular_table_1 ) where "
                sql += "%s " % random.choice(self.q_where)
                sql += " ;"
G
Ganlin Zhao 已提交
2715 2716
                tdLog.info(sql)
                tdLog.info(len(sql))
2717 2718 2719 2720
                tdSql.query(sql)
                self.cur1.execute(sql)
            else:
                sql = "select  ts ,now(),today(),timezone(), "
G
Ganlin Zhao 已提交
2721 2722
                sql += "%s, " % time_fun_1
                sql += "%s, " % random.choice(self.q_select)
2723 2724 2725 2726 2727 2728
                sql += "%s, " % random.choice(self.q_select)
                sql += "%s  " % time_fun_2
                sql += " from  ( select  * from regular_table_1 ) where "
                sql += "%s " % random.choice(self.q_where)
                sql += "%s " % random.choice(self.order_where)
                sql += " ;"
G
Ganlin Zhao 已提交
2729 2730
                tdLog.info(sql)
                tdLog.info(len(sql))
2731 2732 2733 2734 2735
                tdSql.query(sql)
                tdSql.checkRows(100)
                self.cur1.execute(sql)

        tdSql.query("select 1-6 as time_nest from stable_1 limit 1;")
G
Ganlin Zhao 已提交
2736
        for i in range(self.fornum):
2737 2738 2739
            if (timelist == ['NOW','TODAY']) or (timelist == ['TIMETRUNCATE']) or (timelist == ['TO_ISO8601'])\
                or (timelist == ['TO_UNIXTIMESTAMP']):
                sql = "select  ts , timediff(asct1,now) from  ( select  t1.ts as ts,"
G
Ganlin Zhao 已提交
2740 2741 2742 2743 2744
                sql += "%s, " % time_fun_join_1
                sql += "%s as asct1, " % time_fun_join_2
                sql += "t1.%s, " % random.choice(self.q_select)
                sql += "t2.%s, " % random.choice(self.q_select)
                sql += "%s, " % time_fun_join_1
2745 2746 2747 2748 2749
                sql += "t2.ts from regular_table_1 t1 , regular_table_2 t2 where t1.ts = t2.ts and "
                sql += "%s " % random.choice(self.q_u_where)
                sql += "and %s  )" % random.choice(self.q_u_or_where)
                sql += "%s " % random.choice(self.order_where)
                sql += "%s " % random.choice(self.limit1_where)
G
Ganlin Zhao 已提交
2750 2751 2752
                tdLog.info(sql)
                tdLog.info(len(sql))
                tdSql.query(sql)
2753 2754 2755
                self.cur1.execute(sql)
            elif (timelist == ['TIMEZONE']) or (timelist == ['CAST']) or (timelist == ['CAST_1']) or (timelist == ['CAST_2']) or (timelist == ['CAST_3']) or (timelist == ['CAST_4']):
                sql = "select  ts , (asct1) from  ( select  t1.ts as ts,"
G
Ganlin Zhao 已提交
2756 2757 2758 2759 2760
                sql += "%s, " % time_fun_join_1
                sql += "%s as asct1, " % time_fun_join_2
                sql += "t1.%s, " % random.choice(self.q_select)
                sql += "t2.%s, " % random.choice(self.q_select)
                sql += "%s, " % time_fun_join_1
2761 2762 2763 2764 2765
                sql += "t2.ts from regular_table_1 t1 , regular_table_2 t2 where t1.ts = t2.ts and "
                sql += "%s " % random.choice(self.q_u_where)
                sql += "and %s  )" % random.choice(self.q_u_or_where)
                sql += "%s " % random.choice(self.order_where)
                sql += "%s " % random.choice(self.limit1_where)
G
Ganlin Zhao 已提交
2766 2767 2768
                tdLog.info(sql)
                tdLog.info(len(sql))
                tdSql.query(sql)
2769 2770 2771
                self.cur1.execute(sql)
            elif (timelist == ['ELAPSED']) :
                sql = "select   (asct1)*111 from  ( select  "
G
Ganlin Zhao 已提交
2772 2773 2774
                sql += "%s, " % time_fun_join_1
                sql += "%s as asct1, " % time_fun_join_2
                sql += "%s " % time_fun_join_1
2775 2776 2777 2778
                sql += " from regular_table_1 t1 , regular_table_2 t2 where t1.ts = t2.ts and "
                sql += "%s " % random.choice(self.q_u_where)
                sql += "and %s  )" % random.choice(self.q_u_or_where)
                sql += "%s " % random.choice(self.limit1_where)
G
Ganlin Zhao 已提交
2779 2780 2781
                tdLog.info(sql)
                tdLog.info(len(sql))
                tdSql.query(sql)
2782 2783 2784 2785 2786 2787 2788 2789 2790
                self.cur1.execute(sql)

        tdSql.query("select 1-7 as time_nest from stable_1 limit 1;")
        for i in range(self.fornum):
            if (timelist == ['NOW','TODAY']) or (timelist == ['TIMETRUNCATE']) or (timelist == ['TO_ISO8601'])\
                or (timelist == ['TO_UNIXTIMESTAMP']):
                sql = "select  ts , timediff(asct1,now) from  ( select  "
                sql += "%s as asct1, ts ," % time_fun_1
                sql += "%s as asct2, " % time_fun_2
G
Ganlin Zhao 已提交
2791 2792
                sql += "%s, " % random.choice(self.q_select)
                sql += "%s, " % random.choice(self.t_select)
2793 2794 2795 2796
                sql += "ts from stable_1 where "
                sql += "%s " % random.choice(self.qt_where)
                sql += "%s " % random.choice(self.order_where)
                sql += ") ;"
G
Ganlin Zhao 已提交
2797
                tdLog.info(sql)
2798 2799 2800 2801 2802 2803 2804 2805
                tdLog.info(len(sql))
                # tdSql.query(sql) # TD-16039
                # tdSql.checkRows(300)
                # self.cur1.execute(sql)
            elif (timelist == ['TIMEZONE']) or (timelist == ['CAST']) or (timelist == ['CAST_1']) or (timelist == ['CAST_2']) or (timelist == ['CAST_3']) or (timelist == ['CAST_4']):
                sql = "select  ts , (asct1),now(),today(),timezone()  from  ( select  "
                sql += "%s as asct1, ts ," % time_fun_1
                sql += "%s as asct2, " % time_fun_2
G
Ganlin Zhao 已提交
2806 2807
                sql += "%s, " % random.choice(self.q_select)
                sql += "%s, " % random.choice(self.t_select)
2808 2809 2810 2811
                sql += "ts from stable_1 where "
                sql += "%s " % random.choice(self.qt_where)
                sql += "%s " % random.choice(self.order_where)
                sql += ") ;"
G
Ganlin Zhao 已提交
2812
                tdLog.info(sql)
2813 2814 2815 2816 2817 2818 2819 2820 2821 2822 2823
                tdLog.info(len(sql))
                # tdSql.query(sql) # TD-16039
                # tdSql.checkRows(300)
                # self.cur1.execute(sql)
            elif (timelist == ['ELAPSED']) :
                sql = "select  (asct1)/asct2 ,now(),today(),timezone()  from  ( select  "
                sql += "%s as asct1, " % time_fun_1
                sql += "%s as asct2 " % time_fun_2
                sql += "from stable_1 where "
                sql += "%s " % random.choice(self.qt_where)
                sql += ") ;"
G
Ganlin Zhao 已提交
2824
                tdLog.info(sql)
2825 2826 2827
                tdLog.info(len(sql))
                # tdSql.query(sql) #同时出现core:TD-16095和TD-16042
                # self.cur1.execute(sql)
G
Ganlin Zhao 已提交
2828

2829 2830 2831 2832 2833 2834 2835 2836 2837
        tdSql.query("select 1-8 as time_nest from stable_1 limit 1;")
        for i in range(self.fornum):
            if (timelist == ['NOW','TODAY']) or (timelist == ['TIMETRUNCATE']) or (timelist == ['TO_ISO8601'])\
                or (timelist == ['TO_UNIXTIMESTAMP']):
                sql = "select  ts , timediff(asct1,now) "
                sql += "from  ( select  "
                sql += "%s, " % random.choice(self.s_s_select)
                sql += "%s as asct1, ts ," % time_fun_1
                sql += "%s as asct2, " % time_fun_2
G
Ganlin Zhao 已提交
2838 2839
                sql += "%s, " % random.choice(self.q_select)
                sql += "%s, " % random.choice(self.t_select)
2840 2841 2842 2843
                sql += "ts from stable_1 where "
                sql += "%s " % random.choice(self.qt_where)
                sql += "%s " % random.choice(self.order_where)
                sql += ") ;"
G
Ganlin Zhao 已提交
2844
                tdLog.info(sql)
2845 2846 2847 2848 2849 2850 2851 2852 2853 2854
                tdLog.info(len(sql))
                # tdSql.query(sql) # TD-16039
                # tdSql.checkRows(300)
                # self.cur1.execute(sql)
            elif (timelist == ['TIMEZONE']) or (timelist == ['CAST']) or (timelist == ['CAST_1']) or (timelist == ['CAST_2']) or (timelist == ['CAST_3']) or (timelist == ['CAST_4']):
                sql = "select  ts , (asct1),now(),today(),timezone()  "
                sql += "from  ( select  "
                sql += "%s, " % random.choice(self.s_s_select)
                sql += "%s as asct1, ts ," % time_fun_1
                sql += "%s as asct2, " % time_fun_2
G
Ganlin Zhao 已提交
2855 2856
                sql += "%s, " % random.choice(self.q_select)
                sql += "%s, " % random.choice(self.t_select)
2857 2858 2859 2860
                sql += "ts from stable_1 where "
                sql += "%s " % random.choice(self.qt_where)
                sql += "%s " % random.choice(self.order_where)
                sql += ") ;"
G
Ganlin Zhao 已提交
2861
                tdLog.info(sql)
2862 2863 2864
                tdLog.info(len(sql))
                # tdSql.query(sql) # TD-16039
                # tdSql.checkRows(300)
G
Ganlin Zhao 已提交
2865
                # self.cur1.execute(sql)
2866 2867 2868 2869 2870 2871 2872 2873 2874 2875
            elif (timelist == ['ELAPSED']) :
                sql = "select  floor(abs(asct1)),now(),today(),timezone()  "
                sql += "from  ( select  "
                sql += "%s, " % random.choice(self.s_s_select)
                sql += "%s as asct1, " % time_fun_1
                sql += "%s as asct2, " % time_fun_2
                sql += "from stable_1 where "
                sql += "%s " % random.choice(self.qt_where)
                sql += "%s " % random.choice(self.order_where)
                sql += ") ;"
G
Ganlin Zhao 已提交
2876
                tdLog.info(sql)
2877 2878
                tdLog.info(len(sql))
                # tdSql.query(sql) # TD-16039
G
Ganlin Zhao 已提交
2879
                # self.cur1.execute(sql)
2880 2881 2882 2883 2884 2885

        tdSql.query("select 1-9 as time_nest from stable_1 limit 1;")
        for i in range(self.fornum):
            if (timelist == ['NOW','TODAY']) or (timelist == ['TIMETRUNCATE']) or (timelist == ['TO_ISO8601'])\
                or (timelist == ['TO_UNIXTIMESTAMP']):
                sql = "select  ts , timediff(asct1,now) from  ( select  t1.ts as ts,"
G
Ganlin Zhao 已提交
2886 2887 2888 2889 2890 2891
                sql += "%s, " % time_fun_join_1
                sql += "%s as asct1, " % time_fun_join_2
                sql += "t1.%s, " % random.choice(self.q_select)
                sql += "t1.%s, " % random.choice(self.q_select)
                sql += "t2.%s, " % random.choice(self.q_select)
                sql += "t2.%s, " % random.choice(self.q_select)
2892 2893 2894 2895 2896 2897 2898
                sql += "t2.ts from stable_1 t1 , stable_2 t2 where t1.ts = t2.ts and "
                sql += "%s " % random.choice(self.t_join_where)
                sql += "and %s " % random.choice(self.t_u_where)
                sql += "and %s " % random.choice(self.t_u_or_where)
                sql += "%s " % random.choice(self.order_u_where)
                sql += "%s " % random.choice(self.limit1_where)
                sql += ") ;"
G
Ganlin Zhao 已提交
2899 2900
                tdLog.info(sql)
                tdLog.info(len(sql))
2901 2902 2903 2904
                # tdSql.query(sql) TD-16039
                # self.cur1.execute(sql) TD-16039
            elif (timelist == ['TIMEZONE']) or (timelist == ['CAST']) or (timelist == ['CAST_1']) or (timelist == ['CAST_2']) or (timelist == ['CAST_3']) or (timelist == ['CAST_4']):
                sql = "select  ts , asct1 from  ( select  t1.ts as ts,"
G
Ganlin Zhao 已提交
2905 2906 2907 2908 2909 2910
                sql += "%s, " % time_fun_join_1
                sql += "%s as asct1, " % time_fun_join_2
                sql += "t1.%s, " % random.choice(self.q_select)
                sql += "t1.%s, " % random.choice(self.q_select)
                sql += "t2.%s, " % random.choice(self.q_select)
                sql += "t2.%s, " % random.choice(self.q_select)
2911 2912 2913 2914 2915 2916 2917
                sql += "t2.ts from stable_1 t1 , stable_2 t2 where t1.ts = t2.ts and "
                sql += "%s " % random.choice(self.t_join_where)
                sql += "and %s " % random.choice(self.t_u_where)
                sql += "and %s " % random.choice(self.t_u_or_where)
                sql += "%s " % random.choice(self.order_u_where)
                sql += "%s " % random.choice(self.limit1_where)
                sql += ") ;"
G
Ganlin Zhao 已提交
2918 2919
                tdLog.info(sql)
                tdLog.info(len(sql))
2920
                # tdSql.query(sql)
G
Ganlin Zhao 已提交
2921
                # self.cur1.execute(sql) # TD-16039
2922 2923
            elif (timelist == ['ELAPSED']) :
                sql = "select  min(asct1*110) from  ( select  "
G
Ganlin Zhao 已提交
2924 2925
                sql += "%s, " % time_fun_join_1
                sql += "%s as asct1 " % time_fun_join_2
2926 2927 2928 2929 2930 2931
                sql += "from stable_1 t1 , stable_2 t2 where t1.ts = t2.ts and "
                sql += "%s " % random.choice(self.t_join_where)
                sql += "and %s " % random.choice(self.t_u_where)
                sql += "and %s " % random.choice(self.t_u_or_where)
                sql += "%s " % random.choice(self.limit1_where)
                sql += ") ;"
G
Ganlin Zhao 已提交
2932 2933
                tdLog.info(sql)
                tdLog.info(len(sql))
2934
                # tdSql.query(sql)
G
Ganlin Zhao 已提交
2935 2936
                # self.cur1.execute(sql) # TD-16039

2937 2938 2939 2940 2941 2942 2943 2944 2945 2946 2947 2948 2949 2950 2951 2952 2953 2954 2955 2956 2957 2958 2959 2960
        self.restartDnodes()
        tdSql.query("select 1-10 as time_nest from stable_1 limit 1;")
        for i in range(self.fornum):
            if (timelist == ['NOW','TODAY']) or (timelist == ['TIMETRUNCATE']) or (timelist == ['TO_ISO8601'])\
                or (timelist == ['TO_UNIXTIMESTAMP']):
                sql = "select  ts , timediff(asct1,now)  from  ( select  "
                sql += "%s as asct1, ts ," % time_fun_1
                sql += "%s as asct2, " % time_fun_2
                sql += "%s, " % random.choice(self.s_r_select)
                sql += "%s, " % random.choice(self.q_select)
                sql += "ts from stable_1 where "
                sql += "%s " % random.choice(self.q_where)
                sql += "%s " % random.choice(self.order_where)
                sql += ") %s " % random.choice(self.unionall_or_union)
                sql += "select  ts , max(asct2) from  ( select  "
                sql += "%s as asct1, ts ," % time_fun_1
                sql += "%s as asct2, " % time_fun_2
                sql += "%s, " % random.choice(self.s_r_select)
                sql += "%s, " % random.choice(self.q_select)
                sql += "ts from stable_2 where "
                sql += "%s " % random.choice(self.q_where)
                sql += "%s " % random.choice(self.order_where)
                sql += "%s " % random.choice(self.limit1_where)
                sql += ")"
G
Ganlin Zhao 已提交
2961 2962
                tdLog.info(sql)
                tdLog.info(len(sql))
2963 2964 2965 2966 2967 2968 2969 2970 2971 2972 2973 2974 2975 2976 2977 2978 2979 2980 2981 2982 2983 2984
                #TD-15437 tdSql.query(sql)
                #TD-15437 self.cur1.execute(sql)
            elif (timelist == ['TIMEZONE']) or (timelist == ['CAST']) or (timelist == ['CAST_1']) or (timelist == ['CAST_2']) or (timelist == ['CAST_3']) or (timelist == ['CAST_4']):
                sql = "select  ts , (asct1),now(),today(),timezone()   from  ( select  "
                sql += "%s as asct1, ts ," % time_fun_1
                sql += "%s as asct2, " % time_fun_2
                sql += "%s, " % random.choice(self.s_r_select)
                sql += "%s, " % random.choice(self.q_select)
                sql += "ts from stable_1 where "
                sql += "%s " % random.choice(self.q_where)
                sql += "%s " % random.choice(self.order_where)
                sql += ") %s " % random.choice(self.unionall_or_union)
                sql += "select  ts , max(asct2),now(),today(),timezone() from  ( select  "
                sql += "%s as asct1, ts ," % time_fun_1
                sql += "%s as asct2, " % time_fun_2
                sql += "%s, " % random.choice(self.s_r_select)
                sql += "%s, " % random.choice(self.q_select)
                sql += "ts from stable_2 where "
                sql += "%s " % random.choice(self.q_where)
                sql += "%s " % random.choice(self.order_where)
                sql += "%s " % random.choice(self.limit1_where)
                sql += ")"
G
Ganlin Zhao 已提交
2985 2986
                tdLog.info(sql)
                tdLog.info(len(sql))
2987
                #TD-15437 tdSql.query(sql)
G
Ganlin Zhao 已提交
2988
                #TD-15437 self.cur1.execute(sql)
2989 2990 2991 2992 2993 2994 2995 2996 2997 2998 2999 3000 3001 3002
            elif (timelist == ['ELAPSED']) :
                sql = "select  abs(asct1),now(),today(),timezone()   from  ( select  "
                sql += "%s as asct1 ," % time_fun_1
                sql += "%s as asct2 " % time_fun_2
                sql += " from stable_1 where "
                sql += "%s " % random.choice(self.q_where)
                sql += ") %s " % random.choice(self.unionall_or_union)
                sql += "select  max(asct2),now(),today(),timezone() from  ( select  "
                sql += "%s as asct1 ," % time_fun_1
                sql += "%s as asct2 " % time_fun_2
                sql += "from stable_2 where "
                sql += "%s " % random.choice(self.q_where)
                sql += "%s " % random.choice(self.limit1_where)
                sql += ")"
G
Ganlin Zhao 已提交
3003 3004
                tdLog.info(sql)
                tdLog.info(len(sql))
3005
                tdSql.query(sql)
G
Ganlin Zhao 已提交
3006 3007
                #TD-15437 self.cur1.execute(sql)

3008 3009 3010 3011 3012 3013 3014 3015 3016 3017 3018 3019 3020 3021 3022 3023 3024 3025 3026 3027 3028 3029 3030
        #3 inter union not support
        tdSql.query("select 1-11 as time_nest from stable_1 limit 1;")
        for i in range(self.fornum):
            if (timelist == ['NOW','TODAY']) or (timelist == ['TIMETRUNCATE']) or (timelist == ['TO_ISO8601'])\
                or (timelist == ['TO_UNIXTIMESTAMP']):
                sql = "select  ts , timediff(asct1,now), timediff(now,asct2) from  ( select  "
                sql += "%s as asct1, ts ," % time_fun_1
                sql += "%s as asct2, " % time_fun_2
                sql += "%s, " % random.choice(self.s_r_select)
                sql += "%s, " % random.choice(self.q_select)
                sql += "ts from stable_1 where "
                sql += "%s " % random.choice(self.q_where)
                sql += " %s "  % random.choice(self.unionall_or_union)
                sql += " select  "
                sql += "%s as asct1, ts ," % time_fun_1
                sql += "%s as asct2, " % time_fun_2
                sql += "%s, " % random.choice(self.s_r_select)
                sql += "%s, " % random.choice(self.q_select)
                sql += "ts from stable_2 where "
                sql += "%s " % random.choice(self.q_where)
                sql += "%s " % random.choice(self.order_where)
                sql += "%s " % random.choice(self.limit1_where)
                sql += ")"
G
Ganlin Zhao 已提交
3031 3032 3033 3034
                tdLog.info(sql)
                tdLog.info(len(sql))
                # tdSql.query(sql)#TD-15473
                # self.cur1.execute(sql)#TD-15473
3035 3036 3037 3038 3039 3040 3041 3042 3043 3044 3045 3046 3047 3048 3049 3050 3051 3052 3053
            elif (timelist == ['TIMEZONE']) or (timelist == ['CAST']) or (timelist == ['CAST_1']) or (timelist == ['CAST_2']) or (timelist == ['CAST_3']) or (timelist == ['CAST_4']):
                sql = "select  ts , (asct1,now()),(now(),asct2) from  ( select  "
                sql += "%s as asct1, ts ," % time_fun_1
                sql += "%s as asct2, " % time_fun_2
                sql += "%s, " % random.choice(self.s_r_select)
                sql += "%s, " % random.choice(self.q_select)
                sql += "ts from stable_1 where "
                sql += "%s " % random.choice(self.q_where)
                sql += " %s "  % random.choice(self.unionall_or_union)
                sql += " select  "
                sql += "%s as asct1, ts ," % time_fun_1
                sql += "%s as asct2, " % time_fun_2
                sql += "%s, " % random.choice(self.s_r_select)
                sql += "%s, " % random.choice(self.q_select)
                sql += "ts from stable_2 where "
                sql += "%s " % random.choice(self.q_where)
                sql += "%s " % random.choice(self.order_where)
                sql += "%s " % random.choice(self.limit1_where)
                sql += ")"
G
Ganlin Zhao 已提交
3054 3055 3056 3057
                tdLog.info(sql)
                tdLog.info(len(sql))
                # tdSql.query(sql)#TD-15473
                # self.cur1.execute(sql)#TD-15473
3058 3059 3060 3061 3062 3063 3064 3065 3066 3067 3068 3069 3070 3071 3072
            elif (timelist == ['ELAPSED']) :
                sql = "select  asct1+asct2,now(),today(),timezone() from  ( select  "
                sql += "%s as asct1, " % time_fun_1
                sql += "%s as asct2 " % time_fun_2
                sql += " from stable_1 where "
                sql += "%s " % random.choice(self.q_where)
                sql += " %s "  % random.choice(self.unionall_or_union)
                sql += " select  "
                sql += "%s as asct1 ," % time_fun_1
                sql += "%s as asct2 " % time_fun_2
                sql += " from stable_2 where "
                sql += "%s " % random.choice(self.q_where)
                sql += "%s " % random.choice(self.order_where)
                sql += "%s " % random.choice(self.limit1_where)
                sql += ")"
G
Ganlin Zhao 已提交
3073 3074 3075 3076
                tdLog.info(sql)
                tdLog.info(len(sql))
                tdSql.query(sql)#TD-15473
                self.cur1.execute(sql)#TD-15473
3077 3078 3079 3080 3081 3082

        tdSql.query("select 1-12 as time_nest from stable_1 limit 1;")
        for i in range(self.fornum):
            if (timelist == ['NOW','TODAY']) or (timelist == ['TIMETRUNCATE']) or (timelist == ['TO_ISO8601'])\
                or (timelist == ['TO_UNIXTIMESTAMP']):
                sql = "select  ts , timediff(asct1,now) from  ( select  t1.ts as ts,"
G
Ganlin Zhao 已提交
3083 3084 3085 3086 3087 3088
                sql += "%s, " % time_fun_join_1
                sql += "%s as asct1, " % time_fun_join_2
                sql += "t1.%s, " % random.choice(self.q_select)
                sql += "t1.%s, " % random.choice(self.q_select)
                sql += "t2.%s, " % random.choice(self.q_select)
                sql += "t2.%s, " % random.choice(self.q_select)
3089 3090 3091 3092 3093 3094
                sql += "t2.ts from stable_1 t1 , stable_2 t2 where t1.ts = t2.ts and "
                sql += "%s " % random.choice(self.t_u_where)
                sql += "and %s " % random.choice(self.t_u_or_where)
                sql += "%s " % random.choice(self.order_u_where)
                sql += "%s " % random.choice(self.limit1_where)
                sql += ");"
G
Ganlin Zhao 已提交
3095 3096
                tdLog.info(sql)
                tdLog.info(len(sql))
3097 3098 3099 3100
                # tdSql.query(sql)
                # self.cur1.execute(sql)# TD-16039
            elif (timelist == ['TIMEZONE']) or (timelist == ['CAST']) or (timelist == ['CAST_1']) or (timelist == ['CAST_2']) or (timelist == ['CAST_3']) or (timelist == ['CAST_4']):
                sql = "select  ts , asct1,now() from  ( select  t1.ts as ts,"
G
Ganlin Zhao 已提交
3101 3102 3103 3104 3105 3106
                sql += "%s, " % time_fun_join_1
                sql += "%s as asct1, " % time_fun_join_2
                sql += "t1.%s, " % random.choice(self.q_select)
                sql += "t1.%s, " % random.choice(self.q_select)
                sql += "t2.%s, " % random.choice(self.q_select)
                sql += "t2.%s, " % random.choice(self.q_select)
3107 3108 3109 3110 3111 3112
                sql += "t2.ts from stable_1 t1 , stable_2 t2 where t1.ts = t2.ts and "
                sql += "%s " % random.choice(self.t_u_where)
                sql += "and %s " % random.choice(self.t_u_or_where)
                sql += "%s " % random.choice(self.order_u_where)
                sql += "%s " % random.choice(self.limit1_where)
                sql += ");"
G
Ganlin Zhao 已提交
3113 3114
                tdLog.info(sql)
                tdLog.info(len(sql))
3115 3116 3117 3118
                # tdSql.query(sql)
                # self.cur1.execute(sql)# TD-16039
            elif (timelist == ['ELAPSED']) :
                sql = "select min(floor(asct1)),now() from  ( select "
G
Ganlin Zhao 已提交
3119 3120
                sql += "%s, " % time_fun_join_1
                sql += "%s as asct1 " % time_fun_join_2
3121 3122 3123 3124 3125
                sql += " from stable_1 t1 , stable_2 t2 where t1.ts = t2.ts and "
                sql += "%s " % random.choice(self.t_u_where)
                sql += "and %s " % random.choice(self.t_u_or_where)
                sql += "%s " % random.choice(self.limit1_where)
                sql += ");"
G
Ganlin Zhao 已提交
3126 3127
                tdLog.info(sql)
                tdLog.info(len(sql))
3128 3129
                # tdSql.query(sql)
                # self.cur1.execute(sql)# TD-16039
G
Ganlin Zhao 已提交
3130

3131 3132 3133 3134 3135
        tdSql.query("select 1-13 as time_nest from stable_1 limit 1;")
        for i in range(self.fornum):
            if (timelist == ['NOW','TODAY']) or (timelist == ['TIMETRUNCATE']) or (timelist == ['TO_ISO8601'])\
                or (timelist == ['TO_UNIXTIMESTAMP']):
                sql = "select  ts , timediff(%s,now)," % time_fun_2
G
Ganlin Zhao 已提交
3136 3137
                sql += "%s as asct1, " % time_fun_1
                sql += "%s, " % random.choice(self.q_select)
3138 3139
                sql += "%s, " % random.choice(self.q_select)
                sql += "%s  " % time_fun_2
G
Ganlin Zhao 已提交
3140
                sql += "%s  " % random.choice(self.t_select)
3141 3142 3143 3144
                sql += " from  ( select  * from stable_1 where "
                sql += "%s " % random.choice(self.qt_where)
                sql += "%s " % random.choice(self.order_where)
                sql += ") ;"
G
Ganlin Zhao 已提交
3145 3146
                tdLog.info(sql)
                tdLog.info(len(sql))
3147 3148 3149 3150 3151
                # tdSql.query(sql)
                # tdSql.checkRows(300)
                # self.cur1.execute(sql) # TD-16039
            elif (timelist == ['TIMEZONE']) or (timelist == ['CAST']) or (timelist == ['CAST_1']) or (timelist == ['CAST_2']) or (timelist == ['CAST_3']) or (timelist == ['CAST_4']):
                sql = "select  ts ,now(),today(),timezone(), "
G
Ganlin Zhao 已提交
3152 3153
                sql += "%s as asct1, " % time_fun_1
                sql += "%s, " % random.choice(self.q_select)
3154 3155
                sql += "%s, " % random.choice(self.q_select)
                sql += "%s  " % time_fun_2
G
Ganlin Zhao 已提交
3156
                sql += "%s  " % random.choice(self.t_select)
3157 3158 3159 3160
                sql += " from  ( select  * from stable_1 where "
                sql += "%s " % random.choice(self.qt_where)
                sql += "%s " % random.choice(self.order_where)
                sql += ") ;"
G
Ganlin Zhao 已提交
3161 3162
                tdLog.info(sql)
                tdLog.info(len(sql))
3163 3164 3165 3166 3167
                # tdSql.query(sql)
                # tdSql.checkRows(300)
                # self.cur1.execute(sql) # TD-16039
            elif (timelist == ['ELAPSED']) :
                sql = "select  now(),today(),timezone(), "
G
Ganlin Zhao 已提交
3168
                sql += "%s as asct1, " % time_fun_1
3169 3170 3171 3172 3173
                sql += "%s  " % time_fun_2
                sql += " from  ( select  * from stable_1 where "
                sql += "%s " % random.choice(self.qt_where)
                sql += "%s " % random.choice(self.order_where)
                sql += ") ;"
G
Ganlin Zhao 已提交
3174 3175
                tdLog.info(sql)
                tdLog.info(len(sql))
3176 3177
                # tdSql.query(sql)
                # self.cur1.execute(sql) # TD-16039
G
Ganlin Zhao 已提交
3178

3179 3180 3181 3182 3183
        tdSql.query("select 1-14 as time_nest from stable_1 limit 1;")
        for i in range(self.fornum):
            if (timelist == ['NOW','TODAY']) or (timelist == ['TIMETRUNCATE']) or (timelist == ['TO_ISO8601'])\
                or (timelist == ['TO_UNIXTIMESTAMP']):
                sql = "select  ts , timediff(asct1,now),timediff(now,asct2) from ( select ts ts ,"
G
Ganlin Zhao 已提交
3184
                sql += "%s as asct1, " % time_fun_1
3185 3186 3187 3188 3189 3190 3191
                sql += "%s as asct2" % time_fun_2
                sql += "  from stable_1 where "
                sql += "%s " % random.choice(self.q_where)
                sql += "%s " % random.choice(self.partiton_where)
                sql += "%s " % random.choice(self.order_desc_where)
                sql += "%s " % random.choice([self.limit_where[2] , self.limit_where[3]] )
                sql += " ) ;"
G
Ganlin Zhao 已提交
3192 3193
                tdLog.info(sql)
                tdLog.info(len(sql))
3194 3195 3196 3197
                # tdSql.query(sql)
                # self.cur1.execute(sql)  # TD-16039
            elif (timelist == ['TIMEZONE']) or (timelist == ['CAST']) or (timelist == ['CAST_1']) or (timelist == ['CAST_2']) or (timelist == ['CAST_3']) or (timelist == ['CAST_4']):
                sql = "select  ts , (asct1),now(),(now()),asct2 from ( select ts ts ,"
G
Ganlin Zhao 已提交
3198
                sql += "%s as asct1, " % time_fun_1
3199 3200 3201 3202 3203 3204 3205
                sql += "%s as asct2" % time_fun_2
                sql += "  from stable_1 where "
                sql += "%s " % random.choice(self.q_where)
                sql += "%s " % random.choice(self.partiton_where)
                sql += "%s " % random.choice(self.order_desc_where)
                sql += "%s " % random.choice([self.limit_where[2] , self.limit_where[3]] )
                sql += " ) ;"
G
Ganlin Zhao 已提交
3206 3207
                tdLog.info(sql)
                tdLog.info(len(sql))
3208 3209 3210 3211
                # tdSql.query(sql)
                # self.cur1.execute(sql)  # TD-16039
            elif (timelist == ['ELAPSED']) :
                sql = "select  ts , (asct1)*asct2,now(),(now()) from ( select "
G
Ganlin Zhao 已提交
3212
                sql += "%s as asct1, " % time_fun_1
3213 3214 3215 3216 3217 3218
                sql += "%s as asct2" % time_fun_2
                sql += "  from stable_1 where "
                sql += "%s " % random.choice(self.q_where)
                sql += "%s " % random.choice(self.partiton_where)
                sql += "%s " % random.choice([self.limit_where[2] , self.limit_where[3]] )
                sql += " ) ;"
G
Ganlin Zhao 已提交
3219 3220
                tdLog.info(sql)
                tdLog.info(len(sql))
3221 3222
                # tdSql.query(sql)
                # self.cur1.execute(sql)  # TD-16039
G
Ganlin Zhao 已提交
3223

3224 3225 3226 3227 3228
        tdSql.query("select 1-15 as time_nest from stable_1 limit 1;")
        for i in range(self.fornum):
            if (timelist == ['NOW','TODAY']) or (timelist == ['TIMETRUNCATE']) or (timelist == ['TO_ISO8601'])\
                or (timelist == ['TO_UNIXTIMESTAMP']):
                sql = "select  ts , timediff(asct1,now),timediff(now,asct2) from  ( select  t1.ts as ts,"
G
Ganlin Zhao 已提交
3229 3230 3231 3232 3233 3234
                sql += "%s as asct2, " % time_fun_join_1
                sql += "%s as asct1, " % time_fun_join_2
                sql += "t1.%s, " % random.choice(self.q_select)
                sql += "t1.%s, " % random.choice(self.q_select)
                sql += "t2.%s, " % random.choice(self.q_select)
                sql += "t2.%s " % random.choice(self.q_select)
3235 3236 3237 3238 3239
                sql += "from stable_1  t1, stable_2 t2 where t1.ts = t2.ts and  "
                sql += "%s " % random.choice(self.t_join_where)
                sql += " and %s " % random.choice(self.qt_u_or_where)
                sql += "%s " % random.choice(self.partiton_where_j)
                sql += "%s " % random.choice(self.slimit1_where)
G
Ganlin Zhao 已提交
3240
                sql += ") "
3241 3242
                sql += "%s " % random.choice(self.order_desc_where)
                sql += "%s ;" % random.choice(self.limit_u_where)
G
Ganlin Zhao 已提交
3243 3244
                tdLog.info(sql)
                tdLog.info(len(sql))
3245
                # tdSql.query(sql)
G
Ganlin Zhao 已提交
3246
                # self.cur1.execute(sql)  # TD-16039
3247 3248
            elif (timelist == ['TIMEZONE']) or (timelist == ['CAST']) or (timelist == ['CAST_1']) or (timelist == ['CAST_2']) or (timelist == ['CAST_3']) or (timelist == ['CAST_4']):
                sql = "select  ts , asct1,(now()),(now()),asct2 ,now(),today(),timezone() from  ( select  t1.ts as ts,"
G
Ganlin Zhao 已提交
3249 3250 3251 3252 3253 3254
                sql += "%s as asct2, " % time_fun_join_1
                sql += "%s as asct1, " % time_fun_join_2
                sql += "t1.%s, " % random.choice(self.q_select)
                sql += "t1.%s, " % random.choice(self.q_select)
                sql += "t2.%s, " % random.choice(self.q_select)
                sql += "t2.%s " % random.choice(self.q_select)
3255 3256 3257 3258 3259
                sql += "from stable_1  t1, stable_2 t2 where t1.ts = t2.ts and  "
                sql += "%s " % random.choice(self.t_join_where)
                sql += " and %s " % random.choice(self.qt_u_or_where)
                sql += "%s " % random.choice(self.partiton_where_j)
                sql += "%s " % random.choice(self.slimit1_where)
G
Ganlin Zhao 已提交
3260
                sql += ") "
3261 3262
                sql += "%s " % random.choice(self.order_desc_where)
                sql += "%s ;" % random.choice(self.limit_u_where)
G
Ganlin Zhao 已提交
3263 3264
                tdLog.info(sql)
                tdLog.info(len(sql))
3265 3266 3267 3268
                # tdSql.query(sql)
                # self.cur1.execute(sql)   # TD-16039
            elif (timelist == ['ELAPSED']) :
                sql = "select   asct1,(now()),(now()),asct2 ,now(),today(),timezone() from  ( select "
G
Ganlin Zhao 已提交
3269 3270
                sql += "%s as asct2, " % time_fun_join_1
                sql += "%s as asct1 " % time_fun_join_2
3271 3272 3273 3274 3275
                sql += "from stable_1  t1, stable_2 t2 where t1.ts = t2.ts and  "
                sql += "%s " % random.choice(self.t_join_where)
                sql += " and %s " % random.choice(self.qt_u_or_where)
                sql += "%s " % random.choice(self.partiton_where_j)
                sql += "%s " % random.choice(self.slimit1_where)
G
Ganlin Zhao 已提交
3276
                sql += ") "
3277
                sql += "%s ;" % random.choice(self.limit_u_where)
G
Ganlin Zhao 已提交
3278 3279
                tdLog.info(sql)
                tdLog.info(len(sql))
3280 3281
                tdSql.query(sql)
                self.cur1.execute(sql)   # TD-16039
G
Ganlin Zhao 已提交
3282

3283 3284 3285 3286 3287 3288 3289
        #taos -f sql
        startTime_taos_f = time.time()
        print("taos -f %s sql start!" %timelist)
        taos_cmd1 = "taos -f %s/%s.sql" % (self.testcasePath,self.testcaseFilename)
        _ = subprocess.check_output(taos_cmd1, shell=True).decode("utf-8")
        print("taos -f %s sql over!" %timelist)
        endTime_taos_f = time.time()
G
Ganlin Zhao 已提交
3290 3291 3292
        print("taos_f total time %ds" % (endTime_taos_f - startTime_taos_f))

        print("=========%s====over=============" %timelist)
3293 3294

    def base_nest(self,baselist):
G
Ganlin Zhao 已提交
3295 3296 3297 3298

        print("==========%s===start=============" %baselist)
        os.system("rm -rf %s/%s.sql" % (self.testcasePath,self.testcaseFilename))

3299
        self.dropandcreateDB_random("%s" %self.db_nest, 1)
G
Ganlin Zhao 已提交
3300

3301 3302
        if (baselist == ['A']) or (baselist == ['S']) or (baselist == ['F']) \
            or (baselist == ['C']):
G
Ganlin Zhao 已提交
3303 3304
            base_functions = baselist
            fun_fix_column = ['(q_bigint)','(q_smallint)','(q_tinyint)','(q_int)','(q_float)','(q_double)','(q_bigint_null)','(q_smallint_null)','(q_tinyint_null)','(q_int_null)','(q_float_null)','(q_double_null)']
3305 3306 3307 3308
            fun_column_1 = random.sample(base_functions,1)+random.sample(fun_fix_column,1)
            base_fun_1 = str(fun_column_1).replace("[","").replace("]","").replace("'","").replace(", ","")
            fun_column_2 = random.sample(base_functions,1)+random.sample(fun_fix_column,1)
            base_fun_2 = str(fun_column_2).replace("[","").replace("]","").replace("'","").replace(", ","")
G
Ganlin Zhao 已提交
3309

3310
            fun_fix_column_j = ['(t1.q_bigint)','(t1.q_smallint)','(t1.q_tinyint)','(t1.q_int)','(t1.q_float)','(t1.q_double)','(t1.q_bigint_null)','(t1.q_smallint_null)','(t1.q_tinyint_null)','(t1.q_int_null)','(t1.q_float_null)','(t1.q_double_null)',
G
Ganlin Zhao 已提交
3311
                            '(t2.q_bigint)','(t2.q_smallint)','(t2.q_tinyint)','(t2.q_int)','(t2.q_float)','(t2.q_double)','(t2.q_bigint_null)','(t2.q_smallint_null)','(t2.q_tinyint_null)','(t2.q_int_null)','(t2.q_float_null)','(t2.q_double_null)']
3312 3313 3314 3315 3316 3317
            fun_column_join_1 = random.sample(base_functions,1)+random.sample(fun_fix_column_j,1)
            base_fun_join_1 = str(fun_column_join_1).replace("[","").replace("]","").replace("'","").replace(", ","")
            fun_column_join_2 = random.sample(base_functions,1)+random.sample(fun_fix_column_j,1)
            base_fun_join_2 = str(fun_column_join_2).replace("[","").replace("]","").replace("'","").replace(", ","")

        elif (baselist == ['P']) or (baselist == ['M']) or (baselist == ['S'])or (baselist == ['T']):
G
Ganlin Zhao 已提交
3318 3319
            base_functions = baselist
            num = random.randint(0, 1000)
3320
            fun_fix_column = ['(q_bigint,num)','(q_smallint,num)','(q_tinyint,num)','(q_int,num)','(q_float,num)','(q_double,num)',
G
Ganlin Zhao 已提交
3321
                              '(q_bigint_null,num)','(q_smallint_null,num)','(q_tinyint_null,num)','(q_int_null,num)','(q_float_null,num)','(q_double_null,num)']
3322 3323 3324 3325
            fun_column_1 = random.sample(base_functions,1)+random.sample(fun_fix_column,1)
            base_fun_1 = str(fun_column_1).replace("[","").replace("]","").replace("'","").replace(", ","").replace("num",base(num))
            fun_column_2 = random.sample(base_functions,1)+random.sample(fun_fix_column,1)
            base_fun_2 = str(fun_column_2).replace("[","").replace("]","").replace("'","").replace(", ","").replace("num",base(num))
G
Ganlin Zhao 已提交
3326

3327 3328 3329
            fun_fix_column_j = ['(t1.q_bigint,num)','(t1.q_smallint,num)','(t1.q_tinyint,num)','(t1.q_int,num)','(t1.q_float,num)','(t1.q_double,num)',
                    '(t1.q_bigint_null,num)','(t1.q_smallint_null,num)','(t1.q_tinyint_null,num)','(t1.q_int_null,num)','(t1.q_float_null,num)','(t1.q_double_null,num)',
                    '(t2.q_bigint,num)','(t2.q_smallint,num)','(t2.q_tinyint,num)','(t2.q_int,num)','(t2.q_float,num)','(t2.q_double,num)',
G
Ganlin Zhao 已提交
3330
                    '(t2.q_bigint_null,num)','(t2.q_smallint_null,num)','(t2.q_tinyint_null,num)','(t2.q_int_null,num)','(t2.q_float_null,num)','(t2.q_double_null,num)']
3331 3332 3333 3334
            fun_column_join_1 = random.sample(base_functions,1)+random.sample(fun_fix_column_j,1)
            base_fun_join_1 = str(fun_column_join_1).replace("[","").replace("]","").replace("'","").replace(", ","").replace("num",base(num))
            fun_column_join_2 = random.sample(base_functions,1)+random.sample(fun_fix_column_j,1)
            base_fun_join_2 = str(fun_column_join_2).replace("[","").replace("]","").replace("'","").replace(", ","").replace("num",base(num))
G
Ganlin Zhao 已提交
3335

3336 3337
        tdSql.query("select 1-1 as base_nest from stable_1 limit 1;")
        for i in range(self.fornum):
G
Ganlin Zhao 已提交
3338 3339 3340
            sql = "select  ts , floor(asct1)  from  ( select  "
            sql += "%s as asct1, " % base_fun_1
            sql += "%s as asct2, " % base_fun_2
3341
            sql += "%s, " % random.choice(self.s_s_select)
G
Ganlin Zhao 已提交
3342
            sql += "%s, " % random.choice(self.q_select)
3343 3344 3345 3346
            sql += "ts from regular_table_1 where "
            sql += "%s " % random.choice(self.q_where)
            sql += "%s " % random.choice(self.order_where)
            sql += ");"
G
Ganlin Zhao 已提交
3347 3348
            tdLog.info(sql)
            tdLog.info(len(sql))
3349 3350 3351
            tdSql.query(sql)
            tdSql.checkRows(100)
            self.cur1.execute(sql)
G
Ganlin Zhao 已提交
3352

3353 3354 3355
        tdSql.query("select 1-2 as base_nest from stable_1 limit 1;")
        for i in range(self.fornum):
            sql = "select  ts , abs(asct1) from  ( select  "
G
Ganlin Zhao 已提交
3356
            sql += "%s as asct1,  " % base_fun_1
3357
            sql += "%s, " % random.choice(self.s_s_select)
G
Ganlin Zhao 已提交
3358
            sql += "%s, " % random.choice(self.q_select)
3359 3360 3361
            sql += "ts ts from regular_table_1 where "
            sql += "%s " % random.choice(self.q_where)
            sql += "%s )" % random.choice(self.order_where)
G
Ganlin Zhao 已提交
3362
            sql += "%s " % random.choice(self.unionall_or_union)
3363
            sql += "select  ts , asct2 from  ( select  "
G
Ganlin Zhao 已提交
3364
            sql += "%s as asct2,  " % base_fun_2
3365
            sql += "%s, " % random.choice(self.s_s_select)
G
Ganlin Zhao 已提交
3366
            sql += "%s, " % random.choice(self.q_select)
3367
            sql += "ts ts from regular_table_1 where "
G
Ganlin Zhao 已提交
3368
            sql += "%s " % random.choice(self.q_where)
3369 3370 3371 3372
            #sql += "%s " % random.choice(having_support)
            sql += "%s " % random.choice(self.order_where)
            sql += "%s " % random.choice(self.limit1_where)
            sql += ")"
G
Ganlin Zhao 已提交
3373 3374
            tdLog.info(sql)
            tdLog.info(len(sql))
3375
            #TD-15437 tdSql.query(sql)
G
Ganlin Zhao 已提交
3376 3377
            #TD-15437 self.cur1.execute(sql)

3378 3379 3380 3381 3382 3383
        tdSql.query("select 1-3 as base_nest from stable_1 limit 1;")
        for i in range(self.fornum):
            sql = "select  ts , min(asct1) from  ( select  "
            sql += "%s as asct1, ts ," % base_fun_1
            sql += "%s as asct2, " % base_fun_2
            sql += "%s, " % random.choice(self.s_s_select)
G
Ganlin Zhao 已提交
3384
            sql += "%s, " % random.choice(self.q_select)
3385 3386
            sql += "ts from regular_table_1 where "
            sql += "%s " % random.choice(self.q_where)
G
Ganlin Zhao 已提交
3387
            sql += "%s select " % random.choice(self.unionall_or_union)
3388 3389 3390
            sql += "%s as asct2, ts ," % base_fun_2
            sql += "%s as asct1, " % base_fun_1
            sql += "%s, " % random.choice(self.s_s_select)
G
Ganlin Zhao 已提交
3391
            sql += "%s, " % random.choice(self.q_select)
3392 3393 3394 3395
            sql += "ts from regular_table_2 where "
            sql += "%s " % random.choice(self.q_where)
            sql += "%s " % random.choice(self.order_where)
            sql += ")"
G
Ganlin Zhao 已提交
3396 3397
            tdLog.info(sql)
            tdLog.info(len(sql))
3398 3399
            #TD-15473 tdSql.query(sql)
            #self.cur1.execute(sql)
G
Ganlin Zhao 已提交
3400

3401 3402 3403
        tdSql.query("select 1-4 as base_nest from stable_1 limit 1;")
        for i in range(self.fornum):
            sql = "select  ts , asct1 from  ( select  t1.ts as ts,"
G
Ganlin Zhao 已提交
3404 3405 3406 3407 3408
            sql += "%s, " % base_fun_join_1
            sql += "%s as asct1, " % base_fun_join_2
            sql += "%s, " % base_fun_join_1
            sql += "t1.%s, " % random.choice(self.q_select)
            sql += "t2.%s, " % random.choice(self.q_select)
3409 3410 3411 3412 3413
            sql += "t2.ts from regular_table_1 t1 , regular_table_2 t2 where t1.ts = t2.ts and "
            sql += "%s " % random.choice(self.q_u_where)
            sql += "and %s " % random.choice(self.q_u_or_where)
            sql += "%s " % random.choice(self.order_u_where)
            sql += ");"
G
Ganlin Zhao 已提交
3414 3415
            tdLog.info(sql)
            tdLog.info(len(sql))
3416 3417 3418
            tdSql.query(sql)
            tdSql.checkRows(100)
            self.cur1.execute(sql)
G
Ganlin Zhao 已提交
3419

3420 3421 3422
        tdSql.query("select 1-5 as base_nest from stable_1 limit 1;")
        for i in range(self.fornum):
            sql = "select  ts ,"
G
Ganlin Zhao 已提交
3423 3424
            sql += "%s, " % base_fun_1
            sql += "%s, " % random.choice(self.q_select)
3425 3426 3427 3428 3429 3430
            sql += "%s, " % random.choice(self.q_select)
            sql += "%s  " % base_fun_2
            sql += " from  ( select  * from regular_table_1 ) where "
            sql += "%s " % random.choice(self.q_where)
            sql += "%s " % random.choice(self.order_where)
            sql += " ;"
G
Ganlin Zhao 已提交
3431 3432
            tdLog.info(sql)
            tdLog.info(len(sql))
3433 3434 3435 3436 3437 3438 3439
            tdSql.query(sql)
            tdSql.checkRows(100)
            self.cur1.execute(sql)

        tdSql.query("select 1-6 as base_nest from stable_1 limit 1;")
        for i in range(self.fornum):
            sql = "select  ts , max(asct1) from  ( select  t1.ts as ts,"
G
Ganlin Zhao 已提交
3440 3441 3442 3443 3444
            sql += "%s, " % base_fun_join_1
            sql += "%s as asct1, " % base_fun_join_2
            sql += "t1.%s, " % random.choice(self.q_select)
            sql += "t2.%s, " % random.choice(self.q_select)
            sql += "%s, " % base_fun_join_1
3445 3446 3447 3448 3449
            sql += "t2.ts from regular_table_1 t1 , regular_table_2 t2 where t1.ts = t2.ts and "
            sql += "%s " % random.choice(self.q_u_where)
            sql += "and %s  )" % random.choice(self.q_u_or_where)
            sql += "%s " % random.choice(self.order_where)
            sql += "%s " % random.choice(self.limit1_where)
G
Ganlin Zhao 已提交
3450 3451 3452
            tdLog.info(sql)
            tdLog.info(len(sql))
            tdSql.query(sql)
3453 3454 3455 3456 3457 3458 3459
            self.cur1.execute(sql)

        tdSql.query("select 1-7 as base_nest from stable_1 limit 1;")
        for i in range(self.fornum):
            sql = "select  ts , abs(asct1) from  ( select  "
            sql += "%s as asct1, ts ," % base_fun_1
            sql += "%s as asct2, " % base_fun_2
G
Ganlin Zhao 已提交
3460 3461
            sql += "%s, " % random.choice(self.q_select)
            sql += "%s, " % random.choice(self.t_select)
3462 3463 3464 3465
            sql += "ts from stable_1 where "
            sql += "%s " % random.choice(self.qt_where)
            sql += "%s " % random.choice(self.order_where)
            sql += ") ;"
G
Ganlin Zhao 已提交
3466
            tdLog.info(sql)
3467 3468 3469 3470
            tdLog.info(len(sql))
            tdSql.query(sql)
            tdSql.checkRows(300)
            self.cur1.execute(sql)
G
Ganlin Zhao 已提交
3471

3472 3473 3474 3475 3476 3477 3478
        tdSql.query("select 1-8 as base_nest from stable_1 limit 1;")
        for i in range(self.fornum):
            sql = "select  ts,floor(asct1) "
            sql += "from  ( select  "
            sql += "%s, " % random.choice(self.s_s_select)
            sql += "%s as asct1, ts ," % base_fun_1
            sql += "%s as asct2, " % base_fun_2
G
Ganlin Zhao 已提交
3479 3480
            sql += "%s, " % random.choice(self.q_select)
            sql += "%s, " % random.choice(self.t_select)
3481 3482 3483 3484
            sql += "ts from stable_1 where "
            sql += "%s " % random.choice(self.qt_where)
            sql += "%s " % random.choice(self.order_where)
            sql += ") ;"
G
Ganlin Zhao 已提交
3485
            tdLog.info(sql)
3486 3487 3488 3489 3490 3491 3492 3493
            tdLog.info(len(sql))
            tdSql.query(sql)
            tdSql.checkRows(300)
            self.cur1.execute(sql)

        tdSql.query("select 1-9 as base_nest from stable_1 limit 1;")
        for i in range(self.fornum):
            sql = "select  ts , max(asct1) from  ( select  t1.ts as ts,"
G
Ganlin Zhao 已提交
3494 3495 3496 3497 3498 3499
            sql += "%s, " % base_fun_join_1
            sql += "%s as asct1, " % base_fun_join_2
            sql += "t1.%s, " % random.choice(self.q_select)
            sql += "t1.%s, " % random.choice(self.q_select)
            sql += "t2.%s, " % random.choice(self.q_select)
            sql += "t2.%s, " % random.choice(self.q_select)
3500 3501 3502 3503 3504 3505 3506
            sql += "t2.ts from stable_1 t1 , stable_2 t2 where t1.ts = t2.ts and "
            sql += "%s " % random.choice(self.t_join_where)
            sql += "and %s " % random.choice(self.t_u_where)
            sql += "and %s " % random.choice(self.t_u_or_where)
            sql += "%s " % random.choice(self.order_u_where)
            sql += "%s " % random.choice(self.limit1_where)
            sql += ") ;"
G
Ganlin Zhao 已提交
3507 3508
            tdLog.info(sql)
            tdLog.info(len(sql))
3509 3510
            tdSql.query(sql)
            self.cur1.execute(sql)
G
Ganlin Zhao 已提交
3511

3512 3513 3514 3515 3516 3517 3518 3519 3520 3521 3522 3523 3524 3525 3526 3527 3528 3529 3530 3531 3532 3533
        self.restartDnodes()
        tdSql.query("select 1-10 as base_nest from stable_1 limit 1;")
        for i in range(self.fornum):
            sql = "select  ts , min(asct1) from  ( select  "
            sql += "%s as asct1, ts ," % base_fun_1
            sql += "%s as asct2, " % base_fun_2
            sql += "%s, " % random.choice(self.s_r_select)
            sql += "%s, " % random.choice(self.q_select)
            sql += "ts from stable_1 where "
            sql += "%s " % random.choice(self.q_where)
            sql += "%s " % random.choice(self.order_where)
            sql += ") %s " % random.choice(self.unionall_or_union)
            sql += "select  ts , max(asct2) from  ( select  "
            sql += "%s as asct1, ts ," % base_fun_1
            sql += "%s as asct2, " % base_fun_2
            sql += "%s, " % random.choice(self.s_r_select)
            sql += "%s, " % random.choice(self.q_select)
            sql += "ts from stable_2 where "
            sql += "%s " % random.choice(self.q_where)
            sql += "%s " % random.choice(self.order_where)
            sql += "%s " % random.choice(self.limit1_where)
            sql += ")"
G
Ganlin Zhao 已提交
3534 3535
            tdLog.info(sql)
            tdLog.info(len(sql))
3536 3537
            #TD-15437 tdSql.query(sql)
            #TD-15437 self.cur1.execute(sql)
G
Ganlin Zhao 已提交
3538

3539 3540 3541 3542 3543 3544 3545 3546 3547 3548 3549 3550 3551 3552 3553 3554 3555 3556 3557 3558 3559 3560 3561
        #3 inter union not support
        tdSql.query("select 1-11 as base_nest from stable_1 limit 1;")
        for i in range(self.fornum):
            sql = "select  ts , min(asct1), max(asct2) from  ( select  "
            sql += "%s as asct1, ts ," % base_fun_1
            sql += "%s as asct2, " % base_fun_2
            sql += "%s, " % random.choice(self.s_r_select)
            sql += "%s, " % random.choice(self.q_select)
            sql += "ts from stable_1 where "
            sql += "%s " % random.choice(self.q_where)
            sql += "%s " % random.choice(self.order_where)
            #sql += "%s " % random.choice(limit1_where)
            sql += " %s "  % random.choice(self.unionall_or_union)
            sql += " select  "
            sql += "%s as asct1, ts ," % base_fun_1
            sql += "%s as asct2, " % base_fun_2
            sql += "%s, " % random.choice(self.s_r_select)
            sql += "%s, " % random.choice(self.q_select)
            sql += "ts from stable_2 where "
            sql += "%s " % random.choice(self.q_where)
            sql += "%s " % random.choice(self.order_where)
            sql += "%s " % random.choice(self.limit1_where)
            sql += ")"
G
Ganlin Zhao 已提交
3562 3563
            tdLog.info(sql)
            tdLog.info(len(sql))
3564 3565 3566 3567 3568 3569
            #TD-15837 tdSql.query(sql)
            # self.cur1.execute(sql)

        tdSql.query("select 1-12 as base_nest from stable_1 limit 1;")
        for i in range(self.fornum):
            sql = "select  ts , max(asct1) from  ( select  t1.ts as ts,"
G
Ganlin Zhao 已提交
3570 3571 3572 3573 3574 3575
            sql += "%s, " % base_fun_join_1
            sql += "%s as asct1, " % base_fun_join_2
            sql += "t1.%s, " % random.choice(self.q_select)
            sql += "t1.%s, " % random.choice(self.q_select)
            sql += "t2.%s, " % random.choice(self.q_select)
            sql += "t2.%s, " % random.choice(self.q_select)
3576 3577 3578 3579 3580 3581
            sql += "t2.ts from stable_1 t1 , stable_2 t2 where t1.ts = t2.ts and "
            sql += "%s " % random.choice(self.t_u_where)
            sql += "and %s " % random.choice(self.t_u_or_where)
            sql += "%s " % random.choice(self.order_u_where)
            sql += "%s " % random.choice(self.limit1_where)
            sql += ");"
G
Ganlin Zhao 已提交
3582 3583
            tdLog.info(sql)
            tdLog.info(len(sql))
3584 3585
            tdSql.query(sql)
            self.cur1.execute(sql)
G
Ganlin Zhao 已提交
3586

3587 3588 3589
        tdSql.query("select 1-13 as base_nest from stable_1 limit 1;")
        for i in range(self.fornum):
            sql = "select  ts ,"
G
Ganlin Zhao 已提交
3590 3591
            sql += "%s, " % base_fun_1
            sql += "%s, " % random.choice(self.q_select)
3592 3593
            sql += "%s, " % random.choice(self.q_select)
            sql += "%s  " % base_fun_2
G
Ganlin Zhao 已提交
3594
            sql += "%s  " % random.choice(self.t_select)
3595 3596 3597 3598
            sql += " from  ( select  * from stable_1 where "
            sql += "%s " % random.choice(self.qt_where)
            sql += "%s " % random.choice(self.order_where)
            sql += ") ;"
G
Ganlin Zhao 已提交
3599 3600
            tdLog.info(sql)
            tdLog.info(len(sql))
3601 3602 3603
            tdSql.query(sql)
            tdSql.checkRows(300)
            self.cur1.execute(sql)
G
Ganlin Zhao 已提交
3604

3605 3606 3607
        tdSql.query("select 1-14 as base_nest from stable_1 limit 1;")
        for i in range(self.fornum):
            sql = "select  avg(asct1),count(asct2) from ( select "
G
Ganlin Zhao 已提交
3608
            sql += "%s as asct1, " % base_fun_1
3609 3610 3611 3612 3613 3614 3615
            sql += "%s as asct2" % base_fun_2
            sql += "  from stable_1 where "
            sql += "%s " % random.choice(self.q_where)
            sql += "%s " % random.choice(self.partiton_where)
            sql += "%s " % random.choice(self.order_desc_where)
            sql += "%s " % random.choice([self.limit_where[2] , self.limit_where[3]] )
            sql += " ) ;"
G
Ganlin Zhao 已提交
3616 3617
            tdLog.info(sql)
            tdLog.info(len(sql))
3618
            tdSql.query(sql)
G
Ganlin Zhao 已提交
3619 3620
            self.cur1.execute(sql)

3621 3622 3623
        tdSql.query("select 1-15 as base_nest from stable_1 limit 1;")
        for i in range(self.fornum):
            sql = "select  ts , max(asct1) from  ( select  t1.ts as ts,"
G
Ganlin Zhao 已提交
3624 3625 3626 3627 3628 3629
            sql += "%s, " % base_fun_join_1
            sql += "%s as asct1, " % base_fun_join_2
            sql += "t1.%s, " % random.choice(self.q_select)
            sql += "t1.%s, " % random.choice(self.q_select)
            sql += "t2.%s, " % random.choice(self.q_select)
            sql += "t2.%s " % random.choice(self.q_select)
3630 3631 3632 3633 3634
            sql += "from stable_1  t1, stable_2 t2 where t1.ts = t2.ts and  "
            sql += "%s " % random.choice(self.t_join_where)
            sql += " and %s " % random.choice(self.qt_u_or_where)
            sql += "%s " % random.choice(self.partiton_where_j)
            sql += "%s " % random.choice(self.slimit1_where)
G
Ganlin Zhao 已提交
3635
            sql += ") "
3636 3637
            sql += "%s " % random.choice(self.order_desc_where)
            sql += "%s ;" % random.choice(self.limit_u_where)
G
Ganlin Zhao 已提交
3638 3639
            tdLog.info(sql)
            tdLog.info(len(sql))
3640
            tdSql.query(sql)
G
Ganlin Zhao 已提交
3641 3642
            self.cur1.execute(sql)

3643 3644 3645 3646 3647 3648 3649
        #taos -f sql
        startTime_taos_f = time.time()
        print("taos -f %s sql start!" %baselist)
        taos_cmd1 = "taos -f %s/%s.sql" % (self.testcasePath,self.testcaseFilename)
        _ = subprocess.check_output(taos_cmd1, shell=True).decode("utf-8")
        print("taos -f %s sql over!" %baselist)
        endTime_taos_f = time.time()
G
Ganlin Zhao 已提交
3650 3651 3652 3653
        print("taos_f total time %ds" % (endTime_taos_f - startTime_taos_f))

        print("=========%s====over=============" %baselist)

3654
    def function_before_26(self):
G
Ganlin Zhao 已提交
3655

3656
        print('=====================2.6 old function start ===========')
G
Ganlin Zhao 已提交
3657 3658
        os.system("rm -rf %s/%s.sql" % (self.testcasePath,self.testcaseFilename))

3659
        self.dropandcreateDB_random("%s" %self.db_nest, 1)
G
Ganlin Zhao 已提交
3660

3661 3662 3663 3664 3665 3666
        #1 select * from (select column form regular_table where <\>\in\and\or order by)
        tdSql.query("select 1-1 from stable_1;")
        for i in range(self.fornum):
            #sql = "select  ts , * from  ( select  "   ===暂时不支持select * ,用下面这一行
            sql = "select  ts  from  ( select  "
            sql += "%s, " % random.choice(self.s_s_select)
G
Ganlin Zhao 已提交
3667
            sql += "%s, " % random.choice(self.q_select)
3668 3669 3670 3671
            sql += "ts from regular_table_1 where "
            sql += "%s " % random.choice(self.q_where)
            sql += "%s " % random.choice(self.order_where)
            sql += ");"
G
Ganlin Zhao 已提交
3672 3673
            tdLog.info(sql)
            tdLog.info(len(sql))
3674 3675 3676
            tdSql.query(sql)
            tdSql.checkRows(100)
            self.cur1.execute(sql)
G
Ganlin Zhao 已提交
3677 3678

        #1 outer union not support
3679 3680 3681 3682 3683 3684 3685 3686 3687 3688 3689 3690 3691 3692 3693 3694 3695 3696 3697
        #self.dropandcreateDB_random("%s" %db, 1)
        tdSql.query("select 1-2 from stable_1;")
        for i in range(self.fornum):
            #sql = "select  ts , * from  ( select  "
            sql = "select  ts  from  ( select  "
            sql += "%s, " % random.choice(self.s_r_select)
            sql += "%s, " % random.choice(self.q_select)
            sql += "ts from regular_table_1 where "
            sql += "%s " % random.choice(self.q_where)
            sql += "%s " % random.choice(self.order_where)
            sql += ") union "
            #sql += "select  ts , * from  ( select  "
            sql += "select  ts  from  ( select  "
            sql += "%s, " % random.choice(self.s_r_select)
            sql += "%s, " % random.choice(self.q_select)
            sql += "ts from regular_table_1 where "
            sql += "%s " % random.choice(self.q_where)
            sql += "%s " % random.choice(self.order_where)
            sql += ")"
G
Ganlin Zhao 已提交
3698 3699
            tdLog.info(sql)
            tdLog.info(len(sql))
3700 3701 3702
            tdSql.query(sql)
            tdSql.checkRows(100)
            self.cur1.execute(sql)
G
Ganlin Zhao 已提交
3703

3704 3705 3706 3707 3708 3709 3710 3711 3712 3713 3714 3715 3716 3717 3718 3719 3720 3721 3722
        #self.dropandcreateDB_random("%s" %db, 1)
        tdSql.query("select 1-2 from stable_1;")
        for i in range(self.fornum):
            #sql = "select  ts , * from  ( select  "
            sql = "select  ts  from  ( select  "
            sql += "%s, " % random.choice(self.s_r_select)
            sql += "%s, " % random.choice(self.q_select)
            sql += "ts from regular_table_1 where "
            sql += "%s " % random.choice(self.q_where)
            sql += "%s " % random.choice(self.order_where)
            sql += ") union all "
            #sql += "select  ts , * from  ( select  "
            sql += "select  ts  from  ( select  "
            sql += "%s, " % random.choice(self.s_r_select)
            sql += "%s, " % random.choice(self.q_select)
            sql += "ts from regular_table_1 where "
            sql += "%s " % random.choice(self.q_where)
            sql += "%s " % random.choice(self.order_where)
            sql += ")"
G
Ganlin Zhao 已提交
3723 3724
            tdLog.info(sql)
            tdLog.info(len(sql))
3725 3726 3727
            tdSql.query(sql)
            tdSql.checkRows(200)
            self.cur1.execute(sql)
G
Ganlin Zhao 已提交
3728

3729 3730 3731 3732 3733 3734 3735 3736 3737
        #1 inter union not support
        tdSql.query("select 1-3 from stable_1;")
        for i in range(self.fornum):
            #sql = "select  ts , * from  ( select  "
            sql = "select  ts  from  ( select  "
            sql += "%s, " % random.choice(self.s_r_select)
            sql += "%s, " % random.choice(self.q_select)
            sql += "ts from regular_table_1 where "
            sql += "%s " % random.choice(self.q_where)
G
Ganlin Zhao 已提交
3738
            sql += ""
3739 3740 3741 3742 3743 3744 3745
            sql += " union select  "
            sql += "%s, " % random.choice(self.s_r_select)
            sql += "%s, " % random.choice(self.q_select)
            sql += "ts from regular_table_2 where "
            sql += "%s " % random.choice(self.q_where)
            sql += "%s " % random.choice(self.order_where)
            sql += ")"
G
Ganlin Zhao 已提交
3746 3747
            tdLog.info(sql)
            tdLog.info(len(sql))
3748 3749 3750
            #TD-15607 tdSql.query(sql)
            #tdSql.checkRows(200)
            #self.cur1.execute(sql)
G
Ganlin Zhao 已提交
3751

3752 3753 3754 3755 3756 3757 3758 3759 3760 3761 3762 3763 3764 3765 3766
        tdSql.query("select 1-3 from stable_1;")
        for i in range(self.fornum):
            #sql = "select  ts , * from  ( select  "
            sql = "select  ts  from  ( select  "
            sql += "%s, " % random.choice(self.s_r_select)
            sql += "%s, " % random.choice(self.q_select)
            sql += "ts from regular_table_1 where "
            sql += "%s " % random.choice(self.q_where)
            sql += "  union all select  "
            sql += "%s, " % random.choice(self.s_r_select)
            sql += "%s, " % random.choice(self.q_select)
            sql += "ts from regular_table_2 where "
            sql += "%s " % random.choice(self.q_where)
            sql += "%s " % random.choice(self.order_where)
            sql += ")"
G
Ganlin Zhao 已提交
3767 3768
            tdLog.info(sql)
            tdLog.info(len(sql))
3769 3770 3771
            #TD-15607 tdSql.query(sql)
            # tdSql.checkRows(300)
            #self.cur1.execute(sql)
G
Ganlin Zhao 已提交
3772 3773

        #join:select * from (select column form regular_table1,regular_table2 where  t1.ts=t2.ts and <\>\in\and\or order by)
3774 3775 3776 3777 3778
        #self.dropandcreateDB_random("%s" %db, 1)
        tdSql.query("select 1-4 from stable_1;")
        for i in range(self.fornum):
            #sql = "select  ts , * from  ( select  t1.ts ,"
            sql = "select  *  from  ( select  t1.ts ,"
G
Ganlin Zhao 已提交
3779 3780 3781 3782
            sql += "t1.%s, " % random.choice(self.q_select)
            sql += "t1.%s, " % random.choice(self.q_select)
            sql += "t2.%s, " % random.choice(self.q_select)
            sql += "t2.%s, " % random.choice(self.q_select)
3783 3784
            sql += "t2.ts from regular_table_1 t1 , regular_table_2 t2 where t1.ts = t2.ts and "
            sql += "%s " % random.choice(self.q_u_where)
G
Ganlin Zhao 已提交
3785
            sql += "and %s " % random.choice(self.q_u_or_where)
3786 3787
            sql += "%s " % random.choice(self.order_u_where)
            sql += ");"
G
Ganlin Zhao 已提交
3788 3789
            tdLog.info(sql)
            tdLog.info(len(sql))
3790 3791 3792 3793 3794
            tdSql.query(sql)
            tdSql.checkRows(100)
            self.cur1.execute(sql)


G
Ganlin Zhao 已提交
3795
        #2 select column from (select * form regular_table ) where <\>\in\and\or order by
3796 3797 3798 3799 3800
        #self.dropandcreateDB_random("%s" %db, 1)
        tdSql.query("select 2-1 from stable_1;")
        for i in range(self.fornum):
            sql = "select  ts ,"
            sql += "%s, " % random.choice(self.s_r_select)
G
Ganlin Zhao 已提交
3801
            sql += "%s  " % random.choice(self.q_select)
3802 3803 3804 3805
            sql += " from  ( select  * from regular_table_1 ) where "
            sql += "%s " % random.choice(self.q_where)
            sql += "%s " % random.choice(self.order_where)
            sql += " ;"
G
Ganlin Zhao 已提交
3806 3807
            tdLog.info(sql)
            tdLog.info(len(sql))
3808 3809 3810 3811 3812 3813 3814 3815 3816
            tdSql.query(sql)
            tdSql.checkRows(100)
            self.cur1.execute(sql)

        #join: select column from (select column form regular_table1,regular_table2 )where  t1.ts=t2.ts and <\>\in\and\or order by
        #cross join not supported yet
        tdSql.query("select 2-2 from stable_1;")
        for i in range(self.fornum):
            sql = "select  ts , * from  ( select  t1.ts ,"
G
Ganlin Zhao 已提交
3817 3818 3819 3820
            sql += "t1.%s, " % random.choice(self.q_select)
            sql += "t1.%s, " % random.choice(self.q_select)
            sql += "t2.%s, " % random.choice(self.q_select)
            sql += "t2.%s, " % random.choice(self.q_select)
3821 3822 3823 3824
            sql += "t2.ts from regular_table_1 t1 , regular_table_2 t2 ) where t1.ts = t2.ts and "
            sql += "%s " % random.choice(self.q_u_where)
            sql += "%s " % random.choice(self.order_u_where)
            #sql += ");"
G
Ganlin Zhao 已提交
3825 3826 3827
            tdLog.info(sql)
            tdLog.info(len(sql))
            tdSql.error(sql)
3828

G
Ganlin Zhao 已提交
3829
        #3 select * from (select column\tag form stable  where <\>\in\and\or order by )
3830 3831 3832 3833 3834
        #self.dropandcreateDB_random("%s" %db, 1)
        tdSql.query("select 3-1 from stable_1;")
        for i in range(self.fornum):
            sql = "select   *  from  ( select  "
            sql += "%s, " % random.choice(self.s_s_select)
G
Ganlin Zhao 已提交
3835 3836
            sql += "%s, " % random.choice(self.q_select)
            sql += "%s, " % random.choice(self.t_select)
3837 3838 3839 3840
            sql += "ts from stable_1 where "
            sql += "%s " % random.choice(self.qt_where)
            sql += "%s " % random.choice(self.order_where)
            sql += ") ;"
G
Ganlin Zhao 已提交
3841
            tdLog.info(sql)
3842 3843 3844 3845 3846 3847 3848 3849 3850 3851
            tdLog.info(len(sql))
            tdSql.query(sql)
            tdSql.checkRows(300)
            self.cur1.execute(sql)
        tdSql.query("select 3-1 from stable_1;")
        for i in range(self.fornum):
            sql = "select  ts, "
            sql += "%s  " % random.choice(self.s_r_select)
            sql += "from  ( select  "
            sql += "%s, " % random.choice(self.s_s_select)
G
Ganlin Zhao 已提交
3852 3853
            sql += "%s, " % random.choice(self.q_select)
            sql += "%s, " % random.choice(self.t_select)
3854 3855 3856 3857
            sql += "ts from stable_1 where "
            sql += "%s " % random.choice(self.qt_where)
            sql += "%s " % random.choice(self.order_where)
            sql += ") ;"
G
Ganlin Zhao 已提交
3858
            tdLog.info(sql)
3859 3860 3861 3862 3863
            tdLog.info(len(sql))
            tdSql.query(sql)
            tdSql.checkRows(300)
            self.cur1.execute(sql)

G
Ganlin Zhao 已提交
3864
        # select ts,* from (select column\tag form stable1,stable2  where t1.ts = t2.ts and <\>\in\and\or order by )
3865 3866 3867 3868
        #self.dropandcreateDB_random("%s" %db, 1)
        tdSql.query("select 3-2 from stable_1;")
        for i in range(self.fornum):
            sql = "select  ts , *  from  ( select  t1.ts , "
G
Ganlin Zhao 已提交
3869 3870 3871 3872
            sql += "t1.%s, " % random.choice(self.s_s_select)
            sql += "t1.%s, " % random.choice(self.q_select)
            sql += "t2.%s, " % random.choice(self.s_s_select)
            sql += "t2.%s, " % random.choice(self.q_select)
3873 3874 3875 3876
            sql += "t2.ts from stable_1 t1 , stable_2 t2 where t1.ts = t2.ts and "
            sql += "%s " % random.choice(self.t_join_where)
            sql += "%s " % random.choice(self.order_u_where)
            sql += ") ;"
G
Ganlin Zhao 已提交
3877 3878
            tdLog.info(sql)
            tdLog.info(len(sql))
3879 3880 3881
            # TD-15609 tdSql.query(sql)
            # tdSql.checkRows(100)
            #self.cur1.execute(sql)
G
Ganlin Zhao 已提交
3882

3883 3884 3885 3886 3887 3888 3889 3890 3891 3892 3893 3894 3895 3896 3897 3898 3899 3900 3901
        #3 outer union not support
        self.restartDnodes()
        tdSql.query("select 3-3 from stable_1;")
        for i in range(self.fornum):
            #sql = "select  ts , * from  ( select  "
            sql = "select  ts  from  ( select  "
            sql += "%s, " % random.choice(self.s_r_select)
            sql += "%s, " % random.choice(self.q_select)
            sql += "ts from stable_1 where "
            sql += "%s " % random.choice(self.q_where)
            sql += "%s " % random.choice(self.order_where)
            sql += ") union "
            sql += "select  ts  from  ( select  "
            sql += "%s, " % random.choice(self.s_r_select)
            sql += "%s, " % random.choice(self.q_select)
            sql += "ts from stable_2 where "
            sql += "%s " % random.choice(self.q_where)
            sql += "%s " % random.choice(self.order_where)
            sql += ")"
G
Ganlin Zhao 已提交
3902 3903
            tdLog.info(sql)
            tdLog.info(len(sql))
3904 3905 3906 3907 3908 3909 3910 3911 3912 3913 3914 3915 3916 3917 3918 3919 3920 3921 3922
            tdSql.query(sql)
            tdSql.checkRows(300)
            self.cur1.execute(sql)
        for i in range(self.fornum):
            #sql = "select  ts , * from  ( select  "
            sql = "select  ts  from  ( select  "
            sql += "%s, " % random.choice(self.s_r_select)
            sql += "%s, " % random.choice(self.q_select)
            sql += "ts from stable_1 where "
            sql += "%s " % random.choice(self.q_where)
            sql += "%s " % random.choice(self.order_where)
            sql += ") union all "
            sql += "select  ts  from  ( select  "
            sql += "%s, " % random.choice(self.s_r_select)
            sql += "%s, " % random.choice(self.q_select)
            sql += "ts from stable_2 where "
            sql += "%s " % random.choice(self.q_where)
            sql += "%s " % random.choice(self.order_where)
            sql += ")"
G
Ganlin Zhao 已提交
3923 3924
            tdLog.info(sql)
            tdLog.info(len(sql))
3925 3926 3927
            tdSql.query(sql)
            tdSql.checkRows(600)
            self.cur1.execute(sql)
G
Ganlin Zhao 已提交
3928

3929 3930 3931 3932 3933 3934 3935 3936 3937 3938 3939 3940 3941 3942 3943 3944 3945
        #3 inter union not support
        tdSql.query("select 3-4 from stable_1;")
        for i in range(self.fornum):
            sql = "select  ts , * from  ( select  "
            sql += "%s, " % random.choice(self.s_r_select)
            sql += "%s, " % random.choice(self.q_select)
            sql += "ts from stable_1 where "
            sql += "%s " % random.choice(self.q_where)
            sql += "%s " % random.choice(self.order_where)
            sql += " %s "  % random.choice(self.unionall_or_union)
            sql += " select  "
            sql += "%s, " % random.choice(self.s_r_select)
            sql += "%s, " % random.choice(self.q_select)
            sql += "ts from stable_2 where "
            sql += "%s " % random.choice(self.q_where)
            sql += "%s " % random.choice(self.order_where)
            sql += ")"
G
Ganlin Zhao 已提交
3946 3947
            tdLog.info(sql)
            tdLog.info(len(sql))
3948 3949 3950 3951 3952 3953 3954
            #TD-15837 tdSql.query(sql)
            # self.cur1.execute(sql)

        #join:select * from (select column form stable1,stable2 where  t1.ts=t2.ts and <\>\in\and\or order by)
        tdSql.query("select 3-5 from stable_1;")
        for i in range(self.fornum):
            sql = "select  *  from  ( select  t1.ts ,"
G
Ganlin Zhao 已提交
3955 3956 3957 3958
            sql += "t1.%s, " % random.choice(self.q_select)
            sql += "t1.%s, " % random.choice(self.q_select)
            sql += "t2.%s, " % random.choice(self.q_select)
            sql += "t2.%s, " % random.choice(self.q_select)
3959 3960 3961 3962
            sql += "t2.ts from stable_1 t1 , stable_2 t2 where t1.ts = t2.ts and "
            sql += "%s " % random.choice(self.t_u_where)
            sql += "%s " % random.choice(self.order_u_where)
            sql += ");"
G
Ganlin Zhao 已提交
3963 3964
            tdLog.info(sql)
            tdLog.info(len(sql))
3965 3966 3967 3968 3969 3970 3971
            # TD-15609 tdSql.query(sql)
            # tdSql.checkRows(100)
            #self.cur1.execute(sql)

        tdSql.query("select 3-6 from stable_1;")
        for i in range(self.fornum):
            sql = "select  * from  ( select  t1.ts ,"
G
Ganlin Zhao 已提交
3972 3973 3974 3975
            sql += "t1.%s, " % random.choice(self.q_select)
            sql += "t1.%s, " % random.choice(self.q_select)
            sql += "t2.%s, " % random.choice(self.q_select)
            sql += "t2.%s, " % random.choice(self.q_select)
3976 3977 3978 3979
            sql += "t2.ts from stable_1 t1 , stable_2 t2 where t1.ts = t2.ts and "
            sql += "%s " % random.choice(self.t_u_or_where)
            sql += "%s " % random.choice(self.order_u_where)
            sql += ");"
G
Ganlin Zhao 已提交
3980 3981
            tdLog.info(sql)
            tdLog.info(len(sql))
3982 3983 3984 3985
             # TD-15609 同上 tdSql.query(sql)
            # tdSql.checkRows(100)
            #self.cur1.execute(sql)

G
Ganlin Zhao 已提交
3986
        #4 select column from (select * form stable  where <\>\in\and\or order by )
3987 3988 3989 3990 3991
        #self.dropandcreateDB_random("%s" %db, 1)
        tdSql.query("select 4-1 from stable_1;")
        for i in range(self.fornum):
            sql = "select  ts , "
            sql += "%s, " % random.choice(self.q_select)
G
Ganlin Zhao 已提交
3992 3993
            sql += "%s, " % random.choice(self.q_select)
            sql += "%s  " % random.choice(self.t_select)
3994 3995 3996 3997
            sql += " from  ( select  * from stable_1 where "
            sql += "%s " % random.choice(self.qt_where)
            sql += "%s " % random.choice(self.order_where)
            sql += ") ;"
G
Ganlin Zhao 已提交
3998 3999
            tdLog.info(sql)
            tdLog.info(len(sql))
4000 4001 4002 4003 4004 4005 4006 4007 4008 4009 4010 4011 4012
            tdSql.query(sql)
            tdSql.checkRows(300)
            self.cur1.execute(sql)

        #5 select distinct column\tag from (select * form stable  where <\>\in\and\or order by limit offset )
        tdSql.query("select 5-1 from stable_1;")
        for i in range(self.fornum):
            sql = "select   "
            sql += "%s " % random.choice(self.dqt_select)
            sql += " from  ( select  * from stable_1 where "
            sql += "%s " % random.choice(self.qt_where)
            sql += "%s " % random.choice(self.order_where)
            sql += ") ;"
G
Ganlin Zhao 已提交
4013 4014
            tdLog.info(sql)
            tdLog.info(len(sql))
4015 4016 4017 4018 4019 4020 4021 4022
            #TD-15500 tdSql.query(sql)
            #self.cur1.execute(sql)

        #5-1 select distinct column\tag from (select calc form stable  where <\>\in\and\or order by limit offset )
        tdSql.query("select 5-2 from stable_1;")
        for i in range(self.fornum):
            sql = "select  distinct  c5_1 "
            sql += " from  ( select   "
G
Ganlin Zhao 已提交
4023
            sql += "%s " % random.choice(self.calc_select_in_ts)
4024 4025 4026 4027
            sql += " as c5_1 from stable_1 where "
            sql += "%s " % random.choice(self.qt_where)
            #sql += "%s " % random.choice(order_where)
            sql += ") ;"
G
Ganlin Zhao 已提交
4028 4029
            tdLog.info(sql)
            tdLog.info(len(sql))
4030 4031 4032 4033 4034 4035 4036 4037 4038 4039 4040 4041 4042
            tdSql.query(sql)
            #tdSql.checkRows(1)有的函数还没有提交,会不返回结果,先忽略
            self.cur1.execute(sql)

        #6-error select * from (select distinct(tag) form stable  where <\>\in\and\or order by limit  )
        tdSql.query("select 6-1 from stable_1;")
        for i in range(self.fornum):
            sql = "select  * from  ( select  "
            sql += "%s " % random.choice(self.dt_select)
            sql += "  from stable_1 where "
            sql += "%s " % random.choice(self.qt_where)
            sql += "%s " % random.choice(self.order_desc_where)
            sql += ") ;"
G
Ganlin Zhao 已提交
4043 4044
            tdLog.info(sql)
            tdLog.info(len(sql))
4045 4046 4047 4048 4049 4050 4051
            tdSql.error(sql)
        tdSql.query("select 6-1 from stable_1;")
        for i in range(self.fornum):
            sql = "select  * from  ( select  "
            sql += "%s " % random.choice(self.dt_select)
            sql += "  from stable_1 where "
            sql += "%s ) ;" % random.choice(self.qt_where)
G
Ganlin Zhao 已提交
4052 4053
            tdLog.info(sql)
            tdLog.info(len(sql))
4054 4055 4056 4057 4058 4059 4060 4061 4062 4063 4064 4065 4066
            tdSql.query(sql)
            self.cur1.execute(sql)

        #7-error select * from (select distinct(tag) form stable  where <\>\in\and\or order by limit  )
        tdSql.query("select 7-1 from stable_1;")
        for i in range(self.fornum):
            sql = "select  * from  ( select  "
            sql += "%s " % random.choice(self.dq_select)
            sql += "  from stable_1 where "
            sql += "%s " % random.choice(self.qt_where)
            sql += "%s " % random.choice(self.order_desc_where)
            sql += "%s " % random.choice([self.limit_where[0] , self.limit_where[1]] )
            sql += ") ;"
G
Ganlin Zhao 已提交
4067 4068
            tdLog.info(sql)
            tdLog.info(len(sql))
4069 4070 4071 4072 4073 4074 4075 4076 4077 4078
            tdSql.error(sql)  #distinct 和 order by 不能混合使用
        tdSql.query("select 7-1 from stable_1;")
        for i in range(self.fornum):
            sql = "select  * from  ( select  "
            sql += "%s " % random.choice(self.dq_select)
            sql += "  from stable_1 where "
            sql += "%s " % random.choice(self.qt_where)
            #sql += "%s " % random.choice(order_desc_where)
            sql += "%s " % random.choice([self.limit_where[0] , self.limit_where[1]] )
            sql += ") ;"
G
Ganlin Zhao 已提交
4079 4080
            tdLog.info(sql)
            tdLog.info(len(sql))
4081 4082 4083 4084 4085 4086
            tdSql.query(sql)
            tdSql.checkRows(1)
            self.cur1.execute(sql)

        #calc_select,TWA/Diff/Derivative/Irate are not allowed to apply to super table directly
        #8 select * from (select ts,calc form ragular_table  where <\>\in\and\or order by   )
G
Ganlin Zhao 已提交
4087

4088 4089 4090 4091
        # dcDB = self.dropandcreateDB_random("%s" %db, 1)
        tdSql.query("select 8-1 from stable_1;")
        for i in range(self.fornum):
            sql = "select  *  from  ( select  ts ,"
G
Ganlin Zhao 已提交
4092
            sql += "%s " % random.choice(self.calc_select_support_ts)
4093 4094 4095 4096 4097
            sql += "from regular_table_1 where "
            sql += "%s " % random.choice(self.q_where)
            sql += "%s " % random.choice(self.order_where)
            sql += "%s " % random.choice(self.limit1_where)
            sql += ") ;"
G
Ganlin Zhao 已提交
4098 4099 4100
            tdLog.info(sql)
            tdLog.info(len(sql))
            tdSql.query(sql) # 聚合函数不在可以和ts一起使用了 DB error: Not a single-group group function
4101 4102 4103 4104
            self.cur1.execute(sql)
        tdSql.query("select 8-1 from stable_1;")
        for i in range(self.fornum):
            sql = "select  *  from  ( select  "
G
Ganlin Zhao 已提交
4105
            sql += "%s " % random.choice(self.calc_select_not_support_ts)
4106 4107 4108 4109
            sql += "from regular_table_1 where "
            sql += "%s " % random.choice(self.q_where)
            sql += "%s " % random.choice(self.limit1_where)
            sql += ") ;"
G
Ganlin Zhao 已提交
4110 4111 4112
            tdLog.info(sql)
            tdLog.info(len(sql))
            #TD-15651 tdSql.query(sql) # 聚合函数不在可以和ts一起使用了 DB error: Not a single-group group function
4113
            #self.cur1.execute(sql)
G
Ganlin Zhao 已提交
4114

4115 4116
        for i in range(self.fornum):
            sql = "select  *  from  ( select  "
G
Ganlin Zhao 已提交
4117
            sql += "%s " % random.choice(self.calc_select_in_ts)
4118 4119 4120 4121 4122
            sql += "from regular_table_1 where "
            sql += "%s " % random.choice(self.q_where)
            #sql += "%s " % random.choice(order_where)
            sql += "%s " % random.choice(self.limit1_where)
            sql += ") ;"
G
Ganlin Zhao 已提交
4123 4124
            tdLog.info(sql)
            tdLog.info(len(sql))
4125 4126 4127 4128 4129 4130
            tdSql.query(sql)
            self.cur1.execute(sql)

        tdSql.query("select 8-2 from stable_1;")
        for i in range(self.fornum):
            sql = "select  *  from  ( select t1.ts, "
G
Ganlin Zhao 已提交
4131
            sql += "%s " % random.choice(self.calc_select_in_support_ts_j)
4132 4133 4134 4135 4136
            sql += "from regular_table_1 t1, regular_table_2 t2 where t1.ts = t2.ts and "
            sql += "%s " % random.choice(self.q_u_where)
            sql += "%s " % random.choice(self.order_u_where)
            sql += "%s " % random.choice(self.limit1_where)
            sql += ") ;"
G
Ganlin Zhao 已提交
4137 4138 4139
            tdLog.info(sql)
            tdLog.info(len(sql))
            tdSql.query(sql)# 聚合函数不在可以和ts一起使用了 DB error: Not a single-group group function
4140 4141 4142
            self.cur1.execute(sql)
        for i in range(self.fornum):
            sql = "select  *  from  ( select  "
G
Ganlin Zhao 已提交
4143
            sql += "%s " % random.choice(self.calc_select_in_not_support_ts_j)
4144 4145 4146 4147
            sql += "from regular_table_1 t1, regular_table_2 t2 where t1.ts = t2.ts and "
            sql += "%s " % random.choice(self.q_u_where)
            sql += "%s " % random.choice(self.limit1_where)
            sql += ") ;"
G
Ganlin Zhao 已提交
4148 4149 4150 4151 4152
            tdLog.info(sql)
            tdLog.info(len(sql))
            #TD-15651 tdSql.query(sql)
            ##top返回结果有问题 tdSql.checkRows(1)
            #self.cur1.execute(sql)
4153

G
Ganlin Zhao 已提交
4154
        #9 select * from (select ts,calc form stable  where <\>\in\and\or order by   )
4155 4156 4157 4158
        # self.dropandcreateDB_random("%s" %db, 1)
        tdSql.query("select 9-1 from stable_1;")
        for i in range(self.fornum):
            sql = "select  *  from  ( select  "
G
Ganlin Zhao 已提交
4159
            sql += "%s " % random.choice(self.calc_select_not_support_ts)
4160 4161 4162 4163
            sql += "from stable_1 where "
            sql += "%s " % random.choice(self.qt_where)
            sql += "%s " % random.choice(self.limit1_where)
            sql += ") ;"
G
Ganlin Zhao 已提交
4164 4165
            tdLog.info(sql)
            tdLog.info(len(sql))
4166 4167 4168 4169 4170
            #TD-15651 tdSql.query(sql)
           # self.cur1.execute(sql)
        tdSql.query("select 9-2 from stable_1;")
        for i in range(self.fornum):
            sql = "select  *  from  ( select  ts ,"
G
Ganlin Zhao 已提交
4171
            sql += "%s " % random.choice(self.calc_select_support_ts)
4172 4173 4174 4175 4176
            sql += "from stable_1 where "
            sql += "%s " % random.choice(self.qt_where)
            sql += "%s " % random.choice(self.order_where)
            sql += "%s " % random.choice(self.limit1_where)
            sql += ") ;"
G
Ganlin Zhao 已提交
4177 4178
            tdLog.info(sql)
            tdLog.info(len(sql))
4179 4180
            tdSql.query(sql)
            self.cur1.execute(sql)
G
Ganlin Zhao 已提交
4181

4182 4183 4184
        tdSql.query("select 9-3 from stable_1;")
        for i in range(self.fornum):
            sql = "select  *  from  ( select  "
G
Ganlin Zhao 已提交
4185
            sql += "%s " % random.choice(self.calc_select_in_not_support_ts_j)
4186 4187 4188 4189 4190
            sql += "from stable_1 t1, stable_2 t2 where t1.ts = t2.ts and  "
            sql += "%s " % random.choice(self.t_join_where)
            sql += " and %s " % random.choice(self.qt_u_or_where)
            sql += "%s " % random.choice(self.limit1_where)
            sql += ") ;"
G
Ganlin Zhao 已提交
4191 4192
            tdLog.info(sql)
            tdLog.info(len(sql))
4193 4194 4195 4196 4197
            #TD-15651 tdSql.query(sql)
            #self.cur1.execute(sql)
        tdSql.query("select 9-4 from stable_1;")
        for i in range(self.fornum):
            sql = "select  *  from  ( select  t1.ts,"
G
Ganlin Zhao 已提交
4198
            sql += "%s " % random.choice(self.calc_select_in_support_ts_j)
4199 4200 4201 4202 4203 4204
            sql += "from stable_1 t1, stable_2 t2 where t1.ts = t2.ts and  "
            sql += "%s " % random.choice(self.t_join_where)
            sql += " and %s " % random.choice(self.qt_u_or_where)
            sql += "%s " % random.choice(self.order_u_where)
            sql += "%s " % random.choice(self.limit1_where)
            sql += ") ;"
G
Ganlin Zhao 已提交
4205 4206
            tdLog.info(sql)
            tdLog.info(len(sql))
4207 4208
            tdSql.query(sql)
            self.cur1.execute(sql)
G
Ganlin Zhao 已提交
4209 4210

        #10 select calc from (select * form regualr_table  where <\>\in\and\or order by   )
4211 4212
        tdSql.query("select 10-1 from stable_1;")
        for i in range(self.fornum):
G
Ganlin Zhao 已提交
4213 4214
            sql = "select  "
            sql += "%s " % random.choice(self.calc_select_in_ts)
4215 4216 4217 4218 4219
            sql += "as calc10_1 from ( select * from regular_table_1 where "
            sql += "%s " % random.choice(self.q_where)
            sql += "%s " % random.choice(self.order_desc_where)
            sql += "%s " % random.choice(self.limit1_where)
            sql += ") ;"
G
Ganlin Zhao 已提交
4220 4221
            tdLog.info(sql)
            tdLog.info(len(sql))
4222 4223 4224
            tdSql.query(sql)
            tdSql.checkRows(1)
            self.cur1.execute(sql)
G
Ganlin Zhao 已提交
4225

4226
        #10-1 select calc from (select * form regualr_table  where <\>\in\and\or order by   )
G
Ganlin Zhao 已提交
4227
        # rsDn = self.restartDnodes()
4228 4229 4230 4231
        # self.dropandcreateDB_random("%s" %db, 1)
        # rsDn = self.restartDnodes()
        tdSql.query("select 10-2 from stable_1;")
        for i in range(self.fornum):
G
Ganlin Zhao 已提交
4232 4233
            sql = "select  "
            sql += "%s " % random.choice(self.calc_select_all)
4234 4235 4236 4237 4238
            sql += "as calc10_2 from ( select * from regular_table_1 where "
            sql += "%s " % random.choice(self.q_where)
            sql += "%s " % random.choice(self.order_desc_where)
            sql += "%s " % random.choice(self.limit1_where)
            sql += ") ;"
G
Ganlin Zhao 已提交
4239 4240
            tdLog.info(sql)
            tdLog.info(len(sql))
4241 4242 4243 4244
            #TD-15651 tdSql.query(sql)
            # tdSql.checkRows(1)
            #self.cur1.execute(sql)

G
Ganlin Zhao 已提交
4245
        #10-2 select calc from (select * form regualr_tables  where <\>\in\and\or order by   )
4246 4247
        tdSql.query("select 10-3 from stable_1;")
        for i in range(self.fornum):
G
Ganlin Zhao 已提交
4248 4249
            sql = "select  "
            sql += "%s as calc10_3 " % random.choice(self.calc_select_all)
4250 4251 4252 4253 4254 4255 4256
            sql += " from ( select * from regular_table_1 t1, regular_table_2 t2 where t1.ts = t2.ts and  "
            sql += "%s " % random.choice(self.q_u_where)
            sql += " and %s " % random.choice(self.q_u_or_where)
            sql += "%s " % random.choice(self.order_u_where)
            sql += "%s " % random.choice(self.limit_u_where)
            sql += ") "
            sql += "%s ;" % random.choice(self.limit1_where)
G
Ganlin Zhao 已提交
4257 4258
            tdLog.info(sql)
            tdLog.info(len(sql))
4259 4260 4261 4262 4263
            #TD-15651  tdSql.query(sql)
            #self.cur1.execute(sql)

        tdSql.query("select 10-4 from stable_1;")
        for i in range(self.fornum):
G
Ganlin Zhao 已提交
4264 4265
            sql = "select  "
            sql += "%s as calc10_4 " % random.choice(self.calc_select_all)
4266 4267 4268 4269 4270 4271 4272
            sql += " from ( select * from regular_table_1 t1, regular_table_2 t2 where t1.ts = t2.ts and  "
            sql += "%s " % random.choice(self.q_u_or_where)
            sql += " and %s " % random.choice(self.q_u_or_where)
            sql += "%s " % random.choice(self.order_u_where)
            sql += "%s " % random.choice(self.limit_u_where)
            sql += ") "
            sql += "%s ;" % random.choice(self.limit_u_where)
G
Ganlin Zhao 已提交
4273 4274
            tdLog.info(sql)
            tdLog.info(len(sql))
4275
            #TD-15651  tdSql.query(sql)
G
Ganlin Zhao 已提交
4276
            # tdSql.checkRows(1)
4277 4278
            #self.cur1.execute(sql)

G
Ganlin Zhao 已提交
4279
        #11 select calc from (select * form stable  where <\>\in\and\or order by limit  )
4280 4281 4282
        tdSql.query("select 11-1 from stable_1;")
        for i in range(self.fornum):
            sql = "select   "
G
Ganlin Zhao 已提交
4283
            sql += "%s " % random.choice(self.calc_select_in_ts)
4284 4285 4286 4287 4288
            sql += "as calc11_1 from ( select * from stable_1 where "
            sql += "%s " % random.choice(self.qt_where)
            sql += "%s " % random.choice(self.order_desc_where)
            sql += "%s " % random.choice(self.limit1_where)
            sql += ") ;"
G
Ganlin Zhao 已提交
4289 4290
            tdLog.info(sql)
            tdLog.info(len(sql))
4291 4292 4293 4294
            tdSql.query(sql)
            tdSql.checkRows(1)
            self.cur1.execute(sql)

G
Ganlin Zhao 已提交
4295
        #11-1 select calc from (select * form stable  where <\>\in\and\or order by limit  )
4296 4297 4298
        tdSql.query("select 11-2 from stable_1;")
        for i in range(self.fornum):
            sql = "select   "
G
Ganlin Zhao 已提交
4299
            sql += "%s " % random.choice(self.calc_select_all)
4300 4301 4302 4303 4304
            sql += "as calc11_1 from ( select * from stable_1 where "
            sql += "%s " % random.choice(self.qt_where)
            sql += "%s " % random.choice(self.order_desc_where)
            sql += "%s " % random.choice(self.limit1_where)
            sql += ") ;"
G
Ganlin Zhao 已提交
4305 4306
            tdLog.info(sql)
            tdLog.info(len(sql))
4307 4308 4309
            #TD-15651 tdSql.query(sql)
            #self.cur1.execute(sql)
            #不好计算结果 tdSql.checkRows(1)
G
Ganlin Zhao 已提交
4310

4311 4312 4313 4314
        #11-2 select calc from (select * form stables  where <\>\in\and\or order by limit  )
        tdSql.query("select 11-3 from stable_1;")
        for i in range(self.fornum):
            sql = "select   "
G
Ganlin Zhao 已提交
4315
            sql += "%s " % random.choice(self.calc_select_all)
4316 4317 4318 4319 4320 4321
            sql += "as calc11_1 from ( select * from stable_1 t1, stable_2 t2 where t1.ts = t2.ts and  "
            sql += "%s " % random.choice(self.t_join_where)
            sql += "%s " % random.choice(self.order_u_where)
            sql += "%s " % random.choice(self.limit_u_where)
            sql += ") "
            sql += "%s ;" % random.choice(self.limit_u_where)
G
Ganlin Zhao 已提交
4322 4323
            tdLog.info(sql)
            tdLog.info(len(sql))
4324 4325 4326 4327 4328 4329
            #TD-15651 tdSql.query(sql)
            #self.cur1.execute(sql)

        tdSql.query("select 11-4 from stable_1;")
        for i in range(self.fornum):
            sql = "select   "
G
Ganlin Zhao 已提交
4330
            sql += "%s " % random.choice(self.calc_select_all)
4331 4332 4333 4334 4335 4336
            sql += "as calc11_1 from ( select * from stable_1 t1, stable_2 t2 where t1.ts = t2.ts and  "
            sql += "%s " % random.choice(self.qt_u_or_where)
            sql += "%s " % random.choice(self.order_u_where)
            sql += "%s " % random.choice(self.limit_u_where)
            sql += ") "
            sql += "%s ;" % random.choice(self.limit_u_where)
G
Ganlin Zhao 已提交
4337 4338 4339
            tdLog.info(sql)
            tdLog.info(len(sql))
            tdLog.info(len(sql))
4340 4341 4342
            #TD-15651 tdSql.query(sql)
            #self.cur1.execute(sql)

G
Ganlin Zhao 已提交
4343
        #12 select calc-diff from (select * form regualr_table  where <\>\in\and\or order by limit  )
4344 4345 4346 4347
        ##self.dropandcreateDB_random("%s" %db, 1)
        tdSql.query("select 12-1 from stable_1;")
        for i in range(self.fornum):
            sql = "select  "
G
Ganlin Zhao 已提交
4348
            sql += "%s " % random.choice(self.calc_calculate_regular)
4349 4350 4351 4352 4353
            sql += " from ( select * from regular_table_1 where "
            sql += "%s " % random.choice(self.q_where)
            sql += "%s " % random.choice(self.order_desc_where)
            sql += "%s " % random.choice([self.limit_where[2] , self.limit_where[3]] )
            sql += ") ;"
G
Ganlin Zhao 已提交
4354 4355
            tdLog.info(sql)
            tdLog.info(len(sql))
4356 4357 4358 4359 4360 4361 4362
            ##目前derivative不支持  tdSql.query(sql)
            # tdSql.checkRows(1)
            #self.cur1.execute(sql)

        tdSql.query("select 12-2 from stable_1;")
        for i in range(self.fornum):
            sql = "select  "
G
Ganlin Zhao 已提交
4363
            sql += "%s " % random.choice(self.calc_calculate_regular)
4364 4365 4366 4367 4368
            sql += " from ( select * from regular_table_1 t1, regular_table_2 t2 where t1.ts = t2.ts and  "
            sql += "%s " % random.choice(self.q_u_where)
            sql += "%s " % random.choice(self.order_u_where)
            sql += "%s " % random.choice([self.limit_where[2] , self.limit_where[3]] )
            sql += ") ;"
G
Ganlin Zhao 已提交
4369 4370
            tdLog.info(sql)
            tdLog.info(len(sql))
4371 4372 4373 4374 4375 4376 4377
            #目前derivative不支持 tdSql.query(sql)
            # tdSql.checkRows(1)
            #self.cur1.execute(sql)

        tdSql.query("select 12-2.2 from stable_1;")
        for i in range(self.fornum):
            sql = "select  "
G
Ganlin Zhao 已提交
4378
            sql += "%s " % random.choice(self.calc_calculate_regular)
4379 4380 4381 4382 4383
            sql += " from ( select * from regular_table_1 t1, regular_table_2 t2 where t1.ts = t2.ts and  "
            sql += "%s " % random.choice(self.q_u_or_where)
            sql += "%s " % random.choice(self.order_u_where)
            sql += "%s " % random.choice([self.limit_where[2] , self.limit_where[3]] )
            sql += ") ;"
G
Ganlin Zhao 已提交
4384 4385
            tdLog.info(sql)
            tdLog.info(len(sql))
4386 4387 4388 4389 4390 4391 4392 4393
            #目前derivative不支持 tdSql.query(sql)
            #self.cur1.execute(sql)

        #12-1 select calc-diff from (select * form stable  where <\>\in\and\or order by limit  )
        tdSql.query("select 12-3 from stable_1;")
        self.restartDnodes()
        for i in range(self.fornum):
            sql = "select  * from ( select "
G
Ganlin Zhao 已提交
4394
            sql += "%s " % random.choice(self.calc_calculate_regular)
4395 4396 4397 4398 4399 4400 4401
            sql += "  from stable_1 where "
            sql += "%s " % random.choice(self.q_where)
            sql += "%s " % random.choice(self.group_where)
            sql += ") "
            sql += "%s " % random.choice(self.order_desc_where)
            sql += "%s " % random.choice([self.limit_where[2] , self.limit_where[3]] )
            sql += " ;"
G
Ganlin Zhao 已提交
4402 4403
            tdLog.info(sql)
            tdLog.info(len(sql))
4404 4405 4406 4407 4408 4409 4410
            #目前derivative不支持 tdSql.query(sql)
            #self.cur1.execute(sql)

        tdSql.query("select 12-4 from stable_1;")
        #join query does not support group by
        for i in range(self.fornum):
            sql = "select  * from ( select "
G
Ganlin Zhao 已提交
4411
            sql += "%s " % random.choice(self.calc_calculate_regular_j)
4412 4413 4414 4415 4416 4417 4418
            sql += "  from stable_1 t1, stable_2 t2 where t1.ts = t2.ts and  "
            sql += "%s " % random.choice(self.t_join_where)
            sql += "%s " % random.choice(self.group_where_j)
            sql += ") "
            #sql += "%s " % random.choice(self.order_desc_where)
            sql += "%s " % random.choice([self.limit_where[2] , self.limit_where[3]] )
            sql += " ;"
G
Ganlin Zhao 已提交
4419 4420
            tdLog.info(sql)
            tdLog.info(len(sql))
4421 4422 4423 4424 4425 4426 4427
            #tdSql.query(sql) 目前de函数不支持,另外看看需要不需要将group by和pari by分开
            #self.cur1.execute(sql)

        tdSql.query("select 12-5 from stable_1;")
        #join query does not support group by
        for i in range(self.fornum):
            sql = "select  * from ( select "
G
Ganlin Zhao 已提交
4428
            sql += "%s " % random.choice(self.calc_calculate_regular_j)
4429 4430 4431 4432 4433 4434 4435
            sql += "  from stable_1 t1, stable_2 t2 where t1.ts = t2.ts and  "
            sql += "%s " % random.choice(self.qt_u_or_where)
            sql += "%s " % random.choice(self.group_where_j)
            sql += ") "
            sql += "%s " % random.choice(self.order_desc_where)
            sql += "%s " % random.choice([self.limit_where[2] , self.limit_where[3]] )
            sql += " ;"
G
Ganlin Zhao 已提交
4436 4437
            tdLog.info(sql)
            tdLog.info(len(sql))
4438 4439
            #derivative not support  tdSql.query(sql)
            #self.cur1.execute(sql)
G
Ganlin Zhao 已提交
4440

4441 4442 4443 4444 4445

        #13 select calc-diff as diffns from (select * form stable  where <\>\in\and\or order by limit  )
        tdSql.query("select 13-1 from stable_1;")
        for i in range(self.fornum):
            sql = "select   "
G
Ganlin Zhao 已提交
4446
            sql += "%s " % random.choice(self.calc_calculate_regular)
4447 4448 4449 4450 4451
            sql += " as calc13_1 from ( select * from stable_1 where "
            sql += "%s " % random.choice(self.qt_where)
            sql += "%s " % random.choice(self.orders_desc_where)
            sql += "%s " % random.choice([self.limit_where[2] , self.limit_where[3]] )
            sql += ") ;"
G
Ganlin Zhao 已提交
4452 4453
            tdLog.info(sql)
            tdLog.info(len(sql))
4454 4455 4456 4457
            #derivative not support tdSql.query(sql)
            #self.cur1.execute(sql)

        #14 select * from (select calc_aggregate_alls as agg from stable  where <\>\in\and\or group by order by slimit soffset )
G
Ganlin Zhao 已提交
4458
        # TD-5955 select   * from  ( select count (q_double)  from stable_1 where t_bool = true or  t_bool = false group by loc order by ts asc slimit 1 ) ;
4459 4460 4461
        tdSql.query("select 14-1 from stable_1;")
        for i in range(self.fornum):
            sql = "select   * from  ( select "
G
Ganlin Zhao 已提交
4462 4463 4464
            sql += "%s as calc14_1, " % random.choice(self.calc_aggregate_all)
            sql += "%s as calc14_2, " % random.choice(self.calc_aggregate_all)
            sql += "%s " % random.choice(self.calc_aggregate_all)
4465 4466 4467 4468 4469 4470
            sql += " as calc14_3 from stable_1 where "
            sql += "%s " % random.choice(self.qt_where)
            sql += "%s " % random.choice(self.group_where)
            sql += "%s " % random.choice(self.order_desc_where)
            sql += "%s " % random.choice(self.slimit1_where)
            sql += ") ;"
G
Ganlin Zhao 已提交
4471 4472
            tdLog.info(sql)
            tdLog.info(len(sql))
4473 4474 4475 4476 4477 4478 4479 4480
            #TD-15678 tdSql.query(sql)
            # tdSql.checkRows(1)
            #self.cur1.execute(sql)

        # error group by in out query
        tdSql.query("select 14-2 from stable_1;")
        for i in range(self.fornum):
            sql = "select   * from  ( select "
G
Ganlin Zhao 已提交
4481 4482 4483
            sql += "%s as calc14_1, " % random.choice(self.calc_aggregate_all)
            sql += "%s as calc14_2, " % random.choice(self.calc_aggregate_all)
            sql += "%s " % random.choice(self.calc_aggregate_all)
4484 4485 4486 4487 4488 4489 4490 4491
            sql += " as calc14_3 from stable_1 where "
            sql += "%s " % random.choice(self.qt_where)
            sql += "%s " % random.choice(self.group_where)
            sql += "%s " % random.choice(self.having_support)
            sql += "%s " % random.choice(self.orders_desc_where)
            sql += "%s " % random.choice(self.slimit1_where)
            sql += ") "
            sql += "%s " % random.choice(self.group_where)
G
Ganlin Zhao 已提交
4492
            tdLog.info(sql)
4493 4494
            tdLog.info(len(sql))
            #TD-15678 tdSql.query(sql)
G
Ganlin Zhao 已提交
4495
            # tdSql.checkRows(1)
4496 4497 4498 4499 4500 4501
            #self.cur1.execute(sql)

        #14-2 select * from (select calc_aggregate_all_js as agg from stables  where <\>\in\and\or group by order by slimit soffset )
        tdSql.query("select 14-3 from stable_1;")
        for i in range(self.fornum):
            sql = "select   * from  ( select "
G
Ganlin Zhao 已提交
4502 4503 4504
            sql += "%s as calc14_1, " % random.choice(self.calc_aggregate_all_j)
            sql += "%s as calc14_2, " % random.choice(self.calc_aggregate_all_j)
            sql += "%s " % random.choice(self.calc_aggregate_all_j)
4505 4506 4507 4508 4509 4510
            sql += " as calc14_3 from stable_1  t1, stable_2 t2 where t1.ts = t2.ts and  "
            sql += "%s " % random.choice(self.t_join_where)
            sql += "%s " % random.choice(self.partiton_where_j)
            sql += "%s " % random.choice(self.slimit1_where)
            sql += ") "
            sql += "%s ;" % random.choice(self.limit_u_where)
G
Ganlin Zhao 已提交
4511 4512
            tdLog.info(sql)
            tdLog.info(len(sql))
4513 4514 4515 4516 4517 4518
            tdSql.query(sql)
            self.cur1.execute(sql)

        tdSql.query("select 14-4 from stable_1;")
        for i in range(self.fornum):
            sql = "select   * from  ( select "
G
Ganlin Zhao 已提交
4519 4520 4521
            sql += "%s as calc14_1, " % random.choice(self.calc_aggregate_all_j)
            sql += "%s as calc14_2, " % random.choice(self.calc_aggregate_all_j)
            sql += "%s " % random.choice(self.calc_aggregate_all_j)
4522 4523 4524 4525 4526 4527
            sql += " as calc14_3 from stable_1  t1, stable_2 t2 where t1.ts = t2.ts and  "
            sql += "%s " % random.choice(self.qt_u_or_where)
            sql += "%s " % random.choice(self.partiton_where_j)
            sql += "%s " % random.choice(self.slimit1_where)
            sql += ") "
            sql += "%s ;" % random.choice(self.limit_u_where)
G
Ganlin Zhao 已提交
4528 4529
            tdLog.info(sql)
            tdLog.info(len(sql))
4530 4531 4532 4533 4534 4535 4536
            tdSql.query(sql)
            self.cur1.execute(sql)

        #15 select * from (select calc_aggregate_regulars as agg from regular_table  where <\>\in\and\or  order by slimit soffset )
        tdSql.query("select 15-1 from stable_1;")
        for i in range(self.fornum):
            sql = "select   * from  ( select "
G
Ganlin Zhao 已提交
4537 4538 4539
            sql += "%s as calc15_1, " % random.choice(self.calc_aggregate_regular)
            sql += "%s as calc15_2, " % random.choice(self.calc_aggregate_regular)
            sql += "%s " % random.choice(self.calc_aggregate_regular)
4540 4541
            sql += " as calc15_3 from regular_table_1 where "
            sql += "%s " % random.choice(self.q_where)
G
Ganlin Zhao 已提交
4542
            sql += "%s " % random.choice(self.group_where_regular)
4543
            sql += ") ;"
G
Ganlin Zhao 已提交
4544 4545
            tdLog.info(sql)
            tdLog.info(len(sql))
4546 4547 4548
            #tdSql.query(sql) #Invalid function name: twa'
            # tdSql.checkRows(1)
            #self.cur1.execute(sql)
G
Ganlin Zhao 已提交
4549

4550 4551 4552
        tdSql.query("select 15-2 from stable_1;")
        for i in range(self.fornum):
            sql = "select   * from  ( select "
G
Ganlin Zhao 已提交
4553 4554 4555
            sql += "%s as calc15_1, " % random.choice(self.calc_aggregate_regular_j)
            sql += "%s as calc15_2, " % random.choice(self.calc_aggregate_regular_j)
            sql += "%s " % random.choice(self.calc_aggregate_regular_j)
4556 4557
            sql += " as calc15_3 from regular_table_1 t1, regular_table_2 t2 where t1.ts = t2.ts and  "
            sql += "%s " % random.choice(self.q_u_where)
G
Ganlin Zhao 已提交
4558
            sql += "%s " % random.choice(self.group_where_regular_j)
4559 4560 4561
            sql += "%s " % random.choice(self.limit_u_where)
            sql += ") "
            sql += "%s ;" % random.choice(self.limit_u_where)
G
Ganlin Zhao 已提交
4562 4563
            tdLog.info(sql)
            tdLog.info(len(sql))
4564 4565 4566 4567 4568 4569
            #tdSql.query(sql) #Invalid function name: twa'
            #self.cur1.execute(sql)

        tdSql.query("select 15-2.2 from stable_1;")
        for i in range(self.fornum):
            sql = "select   * from  ( select "
G
Ganlin Zhao 已提交
4570 4571 4572
            sql += "%s as calc15_1, " % random.choice(self.calc_aggregate_regular_j)
            sql += "%s as calc15_2, " % random.choice(self.calc_aggregate_regular_j)
            sql += "%s " % random.choice(self.calc_aggregate_regular_j)
4573 4574
            sql += " as calc15_3 from regular_table_1 t1, regular_table_2 t2 where t1.ts = t2.ts and  "
            sql += "%s " % random.choice(self.q_u_or_where)
G
Ganlin Zhao 已提交
4575
            sql += "%s " % random.choice(self.group_where_regular_j)
4576 4577 4578
            sql += "%s " % random.choice(self.limit_u_where)
            sql += ") "
            sql += "%s ;" % random.choice(self.limit_u_where)
G
Ganlin Zhao 已提交
4579 4580
            tdLog.info(sql)
            tdLog.info(len(sql))
4581 4582 4583 4584 4585 4586 4587
            #tdSql.query(sql) #Invalid function name: twa'
            #self.cur1.execute(sql)

        self.restartDnodes()
        tdSql.query("select 15-3 from stable_1;")
        for i in range(self.fornum):
            sql = "select   * from  ( select "
G
Ganlin Zhao 已提交
4588 4589 4590
            sql += "%s as calc15_1, " % random.choice(self.calc_aggregate_groupbytbname)
            sql += "%s as calc15_2, " % random.choice(self.calc_aggregate_groupbytbname)
            sql += "%s " % random.choice(self.calc_aggregate_groupbytbname)
4591 4592 4593 4594 4595 4596
            sql += " as calc15_3 from stable_1 where "
            sql += "%s " % random.choice(self.q_where)
            sql += "%s " % random.choice(self.group_where)
            sql += "%s " % random.choice(self.having_support)
            sql += "%s " % random.choice(self.order_desc_where)
            sql += ") "
G
Ganlin Zhao 已提交
4597
            sql += "order by  calc15_1  "
4598
            sql += "%s " % random.choice(self.limit_where)
G
Ganlin Zhao 已提交
4599 4600
            tdLog.info(sql)
            tdLog.info(len(sql))
4601 4602 4603 4604 4605 4606
            #tdSql.query(sql) #Invalid function name: twa',可能还的去掉order by
            #self.cur1.execute(sql)

        tdSql.query("select 15-4 from stable_1;")
        for i in range(self.fornum):
            sql = "select   * from  ( select "
G
Ganlin Zhao 已提交
4607 4608 4609
            sql += "%s as calc15_1, " % random.choice(self.calc_aggregate_groupbytbname_j)
            sql += "%s as calc15_2, " % random.choice(self.calc_aggregate_groupbytbname_j)
            sql += "%s " % random.choice(self.calc_aggregate_groupbytbname_j)
4610 4611 4612 4613 4614 4615
            sql += " as calc15_3 from stable_1 t1, stable_2 t2 where t1.ts = t2.ts and   "
            sql += "%s " % random.choice(self.t_join_where)
            sql += "%s " % random.choice(self.group_where_j)
            sql += "%s " % random.choice(self.having_support_j)
            #sql += "%s " % random.choice(orders_desc_where)
            sql += ") "
G
Ganlin Zhao 已提交
4616
            sql += "order by  calc15_1  "
4617
            sql += "%s " % random.choice(self.limit_u_where)
G
Ganlin Zhao 已提交
4618 4619
            tdLog.info(sql)
            tdLog.info(len(sql))
4620 4621 4622 4623 4624 4625
            #tdSql.query(sql)  #'Invalid function name: irate'
            #self.cur1.execute(sql)

        tdSql.query("select 15-4.2 from stable_1;")
        for i in range(self.fornum):
            sql = "select   * from  ( select "
G
Ganlin Zhao 已提交
4626 4627 4628
            sql += "%s as calc15_1, " % random.choice(self.calc_aggregate_groupbytbname_j)
            sql += "%s as calc15_2, " % random.choice(self.calc_aggregate_groupbytbname_j)
            sql += "%s " % random.choice(self.calc_aggregate_groupbytbname_j)
4629 4630 4631 4632 4633 4634
            sql += " as calc15_3 from stable_1 t1, stable_2 t2 where t1.ts = t2.ts and   "
            sql += "%s " % random.choice(self.qt_u_or_where)
            sql += "%s " % random.choice(self.group_where_j)
            sql += "%s " % random.choice(self.having_support_j)
            sql += "%s " % random.choice(self.orders_desc_where)
            sql += ") "
G
Ganlin Zhao 已提交
4635
            sql += "order by  calc15_1  "
4636
            sql += "%s " % random.choice(self.limit_u_where)
G
Ganlin Zhao 已提交
4637 4638
            tdLog.info(sql)
            tdLog.info(len(sql))
4639 4640 4641 4642 4643 4644
            #TD-15678 #tdSql.query(sql)
            #self.cur1.execute(sql)

        tdSql.query("select 15-5 from stable_1;")
        for i in range(self.fornum):
            sql = "select   * from  ( select "
G
Ganlin Zhao 已提交
4645 4646 4647
            sql += "%s as calc15_1, " % random.choice(self.calc_aggregate_groupbytbname)
            sql += "%s as calc15_2, " % random.choice(self.calc_aggregate_groupbytbname)
            sql += "%s " % random.choice(self.calc_aggregate_groupbytbname)
4648 4649 4650 4651
            sql += " as calc15_3 from stable_1 where "
            sql += "%s " % random.choice(self.q_where)
            sql += "%s " % random.choice(self.group_where)
            sql += ") "
G
Ganlin Zhao 已提交
4652
            sql += "order by calc15_1  "
4653
            sql += "%s " % random.choice(self.limit_where)
G
Ganlin Zhao 已提交
4654 4655
            tdLog.info(sql)
            tdLog.info(len(sql))
4656 4657 4658
            #tdSql.query(sql) #'Invalid function name: irate'
            #self.cur1.execute(sql)

G
Ganlin Zhao 已提交
4659
        #16 select * from (select calc_aggregate_regulars as agg from regular_table  where <\>\in\and\or  order by limit offset )
4660 4661 4662
        #self.dropandcreateDB_random("%s" %db, 1)
        tdSql.query("select 16-1 from stable_1;")
        for i in range(self.fornum):
G
Ganlin Zhao 已提交
4663
            sql = "select   * from  ( select  "
4664
            sql += "%s as calc16_0 , " % random.choice(self.calc_calculate_all)
G
Ganlin Zhao 已提交
4665 4666
            sql += "%s as calc16_1 , " % random.choice(self.calc_aggregate_all)
            sql += "%s as calc16_2 " % random.choice(self.calc_select_in)
4667 4668 4669 4670 4671
            sql += "  from stable_1 where "
            sql += "%s " % random.choice(self.q_where)
            sql += "%s " % random.choice(self.group_where)
            #sql += "%s " % random.choice(having_support)having和 partition不能混合使用
            sql += ") "
G
Ganlin Zhao 已提交
4672
            sql += "order by calc16_0  "
4673
            sql += "%s " % random.choice(self.limit1_where)
G
Ganlin Zhao 已提交
4674 4675
            tdLog.info(sql)
            tdLog.info(len(sql))
4676 4677 4678 4679 4680
            #TD-15651 tdSql.query(sql)
            #self.cur1.execute(sql)

        tdSql.query("select 16-2 from stable_1;")
        for i in range(self.fornum):
G
Ganlin Zhao 已提交
4681
            sql = "select   * from  ( select  "
4682
            sql += "%s as calc16_0  " % random.choice(self.calc_calculate_all_j)
G
Ganlin Zhao 已提交
4683 4684
            sql += ", %s as calc16_1  " % random.choice(self.calc_aggregate_all_j)
            #sql += ", %s as calc16_2  " % random.choice(self.calc_select_in_j)
4685 4686 4687
            sql += "  from stable_1 t1, stable_2 t2 where t1.ts = t2.ts and  "
            sql += "%s " % random.choice(self.t_join_where)
            sql += ") "
G
Ganlin Zhao 已提交
4688
            sql += "order by calc16_0  "
4689
            sql += "%s " % random.choice(self.limit1_where)
G
Ganlin Zhao 已提交
4690 4691
            tdLog.info(sql)
            tdLog.info(len(sql))
4692 4693 4694 4695 4696
            tdSql.query(sql)
            self.cur1.execute(sql)

        tdSql.query("select 16-2.2 from stable_1;")
        for i in range(self.fornum):
G
Ganlin Zhao 已提交
4697
            sql = "select   * from  ( select  "
4698
            sql += "%s as calc16_0  " % random.choice(self.calc_calculate_all_j)
G
Ganlin Zhao 已提交
4699
            sql += ", %s as calc16_1  " % random.choice(self.calc_aggregate_all_j)
4700 4701 4702
            sql += "  from stable_1 t1, stable_2 t2 where t1.ts = t2.ts and  "
            sql += "%s " % random.choice(self.qt_u_or_where)
            sql += ") "
G
Ganlin Zhao 已提交
4703
            sql += "order by calc16_0  "
4704
            sql += "%s " % random.choice(self.limit1_where)
G
Ganlin Zhao 已提交
4705 4706
            tdLog.info(sql)
            tdLog.info(len(sql))
4707 4708
            tdSql.query(sql)
            self.cur1.execute(sql)
G
Ganlin Zhao 已提交
4709

4710 4711
        tdSql.query("select 16-3 from stable_1;")
        for i in range(self.fornum):
G
Ganlin Zhao 已提交
4712 4713
            sql = "select   * from  ( select  "
            sql += "%s as calc16_1  " % random.choice(self.calc_calculate_regular)
4714 4715 4716 4717
            sql += "  from regular_table_1 where "
            sql += "%s " % random.choice(self.q_where)
            sql += "limit 2 ) "
            sql += "%s " % random.choice(self.limit1_where)
G
Ganlin Zhao 已提交
4718 4719
            tdLog.info(sql)
            tdLog.info(len(sql))
4720 4721 4722 4723 4724
            #tdSql.query(sql)#Invalid function name: derivative'
            #self.cur1.execute(sql)

        tdSql.query("select 16-4 from stable_1;")
        for i in range(self.fornum):
G
Ganlin Zhao 已提交
4725 4726
            sql = "select   * from  ( select  "
            sql += "%s as calc16_1  " % random.choice(self.calc_calculate_regular_j)
4727 4728 4729 4730
            sql += "  from regular_table_1 t1, regular_table_2 t2 where t1.ts = t2.ts and  "
            sql += "%s " % random.choice(self.q_u_where)
            sql += "limit 2 ) "
            sql += "%s " % random.choice(self.limit1_where)
G
Ganlin Zhao 已提交
4731 4732
            tdLog.info(sql)
            tdLog.info(len(sql))
4733 4734 4735 4736 4737
            #tdSql.query(sql)#Invalid function name: derivative'
            #self.cur1.execute(sql)

        tdSql.query("select 16-4.2 from stable_1;")
        for i in range(self.fornum):
G
Ganlin Zhao 已提交
4738 4739
            sql = "select   * from  ( select  "
            sql += "%s as calc16_1  " % random.choice(self.calc_calculate_regular_j)
4740 4741 4742 4743
            sql += "  from regular_table_1 t1, regular_table_2 t2 where t1.ts = t2.ts and  "
            sql += "%s " % random.choice(self.q_u_or_where)
            sql += "limit 2 ) "
            sql += "%s " % random.choice(self.limit1_where)
G
Ganlin Zhao 已提交
4744 4745
            tdLog.info(sql)
            tdLog.info(len(sql))
4746 4747
            #tdSql.query(sql)#Invalid function name: derivative'
            #self.cur1.execute(sql)
G
Ganlin Zhao 已提交
4748

4749 4750
        tdSql.query("select 16-5 from stable_1;")
        for i in range(self.fornum):
G
Ganlin Zhao 已提交
4751
            sql = "select   * from  ( select  "
4752
            sql += "%s as calc16_1 , " % random.choice(self.calc_calculate_all)
G
Ganlin Zhao 已提交
4753 4754
            sql += "%s as calc16_1 , " % random.choice(self.calc_calculate_regular)
            sql += "%s as calc16_2 " % random.choice(self.calc_select_all)
4755 4756 4757 4758 4759
            sql += "  from stable_1 where "
            sql += "%s " % random.choice(self.q_where)
            sql += "%s " % random.choice(self.group_where)
            #sql += "%s " % random.choice(having_support)
            sql += ") "
G
Ganlin Zhao 已提交
4760
            sql += "order by calc16_1  "
4761
            sql += "%s " % random.choice(self.limit1_where)
G
Ganlin Zhao 已提交
4762 4763
            tdLog.info(sql)
            tdLog.info(len(sql))
4764 4765
           # tdSql.query(sql)
            #self.cur1.execute(sql)
G
Ganlin Zhao 已提交
4766

4767 4768
        tdSql.query("select 16-6 from stable_1;")
        for i in range(self.fornum):
G
Ganlin Zhao 已提交
4769 4770
            sql = "select   * from  ( select  "
            sql += "%s as calc16_1  " % random.choice(self.calc_calculate_groupbytbname)
4771 4772 4773 4774 4775
            sql += "  from stable_1 where "
            sql += "%s " % random.choice(self.q_where)
            sql += "%s " % random.choice(self.group_where)
            sql += "limit 2 ) "
            sql += "%s " % random.choice(self.limit1_where)
G
Ganlin Zhao 已提交
4776 4777
            tdLog.info(sql)
            tdLog.info(len(sql))
4778 4779 4780 4781 4782
            #Invalid function name: derivative'  tdSql.query(sql)
            #self.cur1.execute(sql)

        tdSql.query("select 16-7 from stable_1;")
        for i in range(self.fornum):
G
Ganlin Zhao 已提交
4783 4784
            sql = "select   * from  ( select  "
            sql += "%s as calc16_1  " % random.choice(self.calc_calculate_groupbytbname_j)
4785 4786 4787 4788
            sql += "  from stable_1  t1, stable_2 t2 where t1.ts = t2.ts and  "
            sql += "%s " % random.choice(self.t_join_where)
            sql += "limit 2 ) "
            sql += "%s " % random.choice(self.limit1_where)
G
Ganlin Zhao 已提交
4789 4790
            tdLog.info(sql)
            tdLog.info(len(sql))
4791 4792 4793 4794 4795
            #Invalid function name: derivative' tdSql.query(sql)
            #self.cur1.execute(sql)

        tdSql.query("select 16-8 from stable_1;")
        for i in range(self.fornum):
G
Ganlin Zhao 已提交
4796 4797
            sql = "select   * from  ( select  "
            sql += "%s as calc16_1  " % random.choice(self.calc_calculate_groupbytbname_j)
4798 4799 4800 4801
            sql += "  from stable_1  t1, stable_2 t2 where t1.ts = t2.ts and  "
            sql += "%s " % random.choice(self.qt_u_or_where)
            sql += "limit 2 ) "
            sql += "%s " % random.choice(self.limit1_where)
G
Ganlin Zhao 已提交
4802 4803
            tdLog.info(sql)
            tdLog.info(len(sql))
4804 4805 4806 4807 4808 4809 4810
            #Invalid function name: derivative' tdSql.query(sql)
            #self.cur1.execute(sql)

        #17 select apercentile from (select calc_aggregate_alls form regualr_table or stable  where <\>\in\and\or interval_sliding group by having order by limit offset  )interval_sliding
        #self.dropandcreateDB_random("%s" %db, 1)
        tdSql.query("select 17-1 from stable_1;")
        for i in range(self.fornum):
G
Ganlin Zhao 已提交
4811
            #this is having_support , but tag-select cannot mix with last_row,other select can
4812 4813
            sql = "select   apercentile(cal17_0, %d)/10 ,apercentile(cal17_1, %d)/1000 ,apercentile(cal17_2, %d)*10+%d from  ( select  " %(random.randint(0,100) , random.randint(0,100) , random.randint(0,100) ,random.randint(-1000,1000))
            sql += "%s as cal17_0 , " % random.choice(self.calc_calculate_all)
G
Ganlin Zhao 已提交
4814 4815
            sql += "%s as cal17_1 ," % random.choice(self.calc_aggregate_all)
            sql += "%s as cal17_2 " % random.choice(self.calc_aggregate_all)
4816 4817 4818 4819 4820 4821 4822 4823 4824
            sql += " from stable_1 where "
            sql += "%s " % random.choice(self.qt_where)
            sql += "%s " % random.choice(self.partiton_where)
            sql += "%s " % random.choice(self.interval_sliding)
            #sql += "%s " % random.choice(having_support)
            #sql += "%s " % random.choice(order_where)
            sql += "%s " % random.choice(self.limit1_where)
            sql += ") "
            #sql += "%s " % random.choice(interval_sliding)
G
Ganlin Zhao 已提交
4825 4826
            tdLog.info(sql)
            tdLog.info(len(sql))
4827 4828
            tdSql.query(sql)
            self.cur1.execute(sql)
G
Ganlin Zhao 已提交
4829

4830 4831
        tdSql.query("select 17-2 from stable_1;")
        for i in range(self.fornum):
G
Ganlin Zhao 已提交
4832
            #this is having_support , but tag-select cannot mix with last_row,other select can
4833 4834
            sql = "select   apercentile(cal17_0, %d)/10 ,apercentile(cal17_1, %d)/1000 ,apercentile(cal17_2, %d)*10+%d from  ( select  " %(random.randint(0,100) , random.randint(0,100) , random.randint(0,100) ,random.randint(-1000,1000))
            sql += "%s as cal17_0 , " % random.choice(self.calc_calculate_all_j)
G
Ganlin Zhao 已提交
4835 4836
            sql += "%s as cal17_1 ," % random.choice(self.calc_aggregate_all_j)
            sql += "%s as cal17_2 " % random.choice(self.calc_aggregate_all_j)
4837 4838 4839 4840 4841 4842
            sql += " from stable_1 t1, stable_2 t2 where t1.ts = t2.ts and "
            sql += "%s " % random.choice(self.t_join_where)
            sql += "%s " % random.choice(self.interval_sliding)
            sql += "%s " % random.choice(self.limit_u_where)
            sql += ") "
            #sql += "%s " % random.choice(interval_sliding)
G
Ganlin Zhao 已提交
4843 4844
            tdLog.info(sql)
            tdLog.info(len(sql))
4845 4846 4847 4848 4849
            tdSql.query(sql)
            self.cur1.execute(sql)

        tdSql.query("select 17-2.2 from stable_1;")
        for i in range(self.fornum):
G
Ganlin Zhao 已提交
4850
            #this is having_support , but tag-select cannot mix with last_row,other select can
4851 4852
            sql = "select   apercentile(cal17_0, %d)/10 ,apercentile(cal17_1, %d)/1000 ,apercentile(cal17_2, %d)*10+%d from  ( select  " %(random.randint(0,100) , random.randint(0,100) , random.randint(0,100) ,random.randint(-1000,1000))
            sql += "%s as cal17_0 , " % random.choice(self.calc_calculate_all_j)
G
Ganlin Zhao 已提交
4853 4854
            sql += "%s as cal17_1 ," % random.choice(self.calc_aggregate_all_j)
            sql += "%s as cal17_2 " % random.choice(self.calc_aggregate_all_j)
4855 4856 4857 4858 4859 4860 4861
            sql += " from stable_1 t1, stable_2 t2 where t1.ts = t2.ts and "
            sql += "%s " % random.choice(self.qt_u_or_where)
            sql += "%s " % random.choice(self.interval_sliding)
            #sql += "%s " % random.choice(self.order_u_where)
            sql += "%s " % random.choice(self.limit_u_where)
            sql += ") "
            #sql += "%s " % random.choice(self.interval_sliding)
G
Ganlin Zhao 已提交
4862 4863
            tdLog.info(sql)
            tdLog.info(len(sql))
4864 4865 4866 4867 4868 4869 4870 4871
            tdSql.query(sql)
            self.cur1.execute(sql)

        self.restartDnodes()
        tdSql.query("select 17-3 from stable_1;")
        for i in range(self.fornum):
            #this is having_tagnot_support , because tag-select cannot mix with last_row...
            sql = "select   apercentile(cal17_1, %d)/1000 ,apercentile(cal17_2, %d)*10+%d from  ( select  " %(random.randint(0,100) , random.randint(0,100) ,random.randint(-1000,1000))
G
Ganlin Zhao 已提交
4872 4873
            sql += "%s as cal17_1 ," % random.choice(self.calc_aggregate_all)
            sql += "%s as cal17_2 " % random.choice(self.calc_aggregate_all)
4874 4875 4876 4877 4878 4879 4880 4881 4882
            sql += " from stable_1 where "
            sql += "%s " % random.choice(self.q_where)
            sql += "%s " % random.choice(self.partiton_where)
            sql += "%s " % random.choice(self.interval_sliding)
            #sql += "%s " % random.choice(self.having_tagnot_support)
            #sql += "%s " % random.choice(self.order_where)
            sql += "%s " % random.choice(self.limit1_where)
            sql += ") "
            #sql += "%s " % random.choice(self.interval_sliding)
G
Ganlin Zhao 已提交
4883 4884
            tdLog.info(sql)
            tdLog.info(len(sql))
4885 4886 4887 4888 4889 4890 4891
            tdSql.query(sql)
            self.cur1.execute(sql)

        tdSql.query("select 17-4 from stable_1;")
        for i in range(self.fornum):
            #this is having_tagnot_support , because tag-select cannot mix with last_row...
            sql = "select   apercentile(cal17_1, %d)/1000 ,apercentile(cal17_2, %d)*10+%d from  ( select  " %(random.randint(0,100) , random.randint(0,100) ,random.randint(-1000,1000))
G
Ganlin Zhao 已提交
4892 4893
            sql += "%s as cal17_1 ," % random.choice(self.calc_aggregate_all_j)
            sql += "%s as cal17_2 " % random.choice(self.calc_aggregate_all_j)
4894 4895 4896 4897 4898 4899 4900
            sql += " from stable_1 t1, stable_2 t2 where t1.ts = t2.ts and  "
            sql += "%s " % random.choice(self.t_join_where)
            sql += "%s " % random.choice(self.interval_sliding)
            #sql += "%s " % random.choice(order_u_where)
            sql += "%s " % random.choice(self.limit_u_where)
            sql += ") "
            #sql += "%s " % random.choice(interval_sliding)
G
Ganlin Zhao 已提交
4901 4902
            tdLog.info(sql)
            tdLog.info(len(sql))
4903 4904 4905 4906 4907 4908 4909
            tdSql.query(sql)
            self.cur1.execute(sql)

        tdSql.query("select 17-4.2 from stable_1;")
        for i in range(self.fornum):
            #this is having_tagnot_support , because tag-select cannot mix with last_row...
            sql = "select   apercentile(cal17_1, %d)/1000 ,apercentile(cal17_2, %d)*10+%d from  ( select  " %(random.randint(0,100) , random.randint(0,100) ,random.randint(-1000,1000))
G
Ganlin Zhao 已提交
4910 4911
            sql += "%s as cal17_1 ," % random.choice(self.calc_aggregate_all_j)
            sql += "%s as cal17_2 " % random.choice(self.calc_aggregate_all_j)
4912 4913 4914 4915 4916 4917 4918
            sql += " from stable_1 t1, stable_2 t2 where t1.ts = t2.ts and  "
            sql += "%s " % random.choice(self.qt_u_or_where)
            sql += "%s " % random.choice(self.interval_sliding)
            #sql += "%s " % random.choice(self.order_u_where)
            sql += "%s " % random.choice(self.limit_u_where)
            sql += ") "
            #sql += "%s " % random.choice(self.interval_sliding)
G
Ganlin Zhao 已提交
4919 4920
            tdLog.info(sql)
            tdLog.info(len(sql))
4921 4922 4923 4924 4925
            tdSql.query(sql)
            self.cur1.execute(sql)

        tdSql.query("select 17-5 from stable_1;")
        for i in range(self.fornum):
G
Ganlin Zhao 已提交
4926
            #having_not_support
4927
            sql = "select   apercentile(cal17_1, %d)/1000 ,apercentile(cal17_2, %d)*10+%d from  ( select  " %(random.randint(0,100) , random.randint(0,100) ,random.randint(-1000,1000))
G
Ganlin Zhao 已提交
4928 4929
            sql += "%s as cal17_1 ," % random.choice(self.calc_aggregate_all)
            sql += "%s as cal17_2 " % random.choice(self.calc_aggregate_all)
4930 4931 4932 4933 4934 4935 4936 4937 4938
            sql += " from stable_1 where "
            sql += "%s " % random.choice(self.qt_where)
            sql += "%s " % random.choice(self.partiton_where)
            sql += "%s " % random.choice(self.interval_sliding)
            # sql += "%s " % random.choice(self.having_not_support)
            # sql += "%s " % random.choice(self.order_where)
            sql += "%s " % random.choice(self.limit1_where)
            sql += ") "
            #sql += "%s " % random.choice(self.interval_sliding)
G
Ganlin Zhao 已提交
4939 4940
            tdLog.info(sql)
            tdLog.info(len(sql))
4941 4942
            tdSql.query(sql)
            self.cur1.execute(sql)
G
Ganlin Zhao 已提交
4943

4944 4945 4946
        tdSql.query("select 17-6 from stable_1;")
        for i in range(self.fornum):
            sql = "select   apercentile(cal17_1, %d)/1000 ,apercentile(cal17_2, %d)*10+%d from  ( select  " %(random.randint(0,100) , random.randint(0,100) ,random.randint(-1000,1000))
G
Ganlin Zhao 已提交
4947 4948
            sql += "%s as cal17_1 ," % random.choice(self.calc_aggregate_all)
            sql += "%s as cal17_2 " % random.choice(self.calc_aggregate_all)
4949 4950 4951 4952 4953 4954 4955
            sql += " from stable_1 where "
            sql += "%s " % random.choice(self.q_where)
            sql += "%s " % random.choice(self.interval_sliding)
            #sql += "%s " % random.choice(self.order_where)
            sql += "%s " % random.choice(self.limit1_where)
            sql += ") "
            #sql += "%s " % random.choice(interval_sliding)
G
Ganlin Zhao 已提交
4956 4957
            tdLog.info(sql)
            tdLog.info(len(sql))
4958 4959 4960 4961 4962 4963
            tdSql.query(sql)
            self.cur1.execute(sql)

        tdSql.query("select 17-7 from stable_1;")
        for i in range(self.fornum):
            sql = "select   apercentile(cal17_1, %d)/1000 ,apercentile(cal17_2, %d)*10+%d from  ( select  " %(random.randint(0,100) , random.randint(0,100) ,random.randint(-1000,1000))
G
Ganlin Zhao 已提交
4964 4965
            sql += "%s as cal17_1 ," % random.choice(self.calc_aggregate_all_j)
            sql += "%s as cal17_2 " % random.choice(self.calc_aggregate_all_j)
4966 4967 4968 4969 4970 4971 4972
            sql += " from stable_1_1 t1, stable_1_2 t2 where t1.ts = t2.ts and "
            sql += "%s " % random.choice(self.q_u_where)
            sql += "%s " % random.choice(self.interval_sliding)
            #sql += "%s " % random.choice(self.order_u_where)
            sql += "%s " % random.choice(self.limit1_where)
            sql += ") "
            #sql += "%s " % random.choice(interval_sliding)
G
Ganlin Zhao 已提交
4973 4974
            tdLog.info(sql)
            tdLog.info(len(sql))
4975 4976 4977 4978 4979 4980
            tdSql.query(sql)
            self.cur1.execute(sql)

        tdSql.query("select 17-7.2 from stable_1;")
        for i in range(self.fornum):
            sql = "select   apercentile(cal17_1, %d)/1000 ,apercentile(cal17_2, %d)*10+%d from  ( select  " %(random.randint(0,100) , random.randint(0,100) ,random.randint(-1000,1000))
G
Ganlin Zhao 已提交
4981 4982
            sql += "%s as cal17_1 ," % random.choice(self.calc_aggregate_all_j)
            sql += "%s as cal17_2 " % random.choice(self.calc_aggregate_all_j)
4983 4984 4985 4986 4987 4988 4989
            sql += " from stable_1_1 t1, stable_1_2 t2 where t1.ts = t2.ts and "
            sql += "%s " % random.choice(self.q_u_or_where)
            sql += "%s " % random.choice(self.interval_sliding)
            #sql += "%s " % random.choice(self.order_u_where)
            sql += "%s " % random.choice(self.limit1_where)
            sql += ") "
            #sql += "%s " % random.choice(interval_sliding)
G
Ganlin Zhao 已提交
4990 4991
            tdLog.info(sql)
            tdLog.info(len(sql))
4992 4993 4994 4995 4996 4997 4998
            tdSql.query(sql)
            self.cur1.execute(sql)

        self.restartDnodes()
        tdSql.query("select 17-8 from stable_1;")
        for i in range(self.fornum):
            sql = "select   apercentile(cal17_1, %d)/1000 ,apercentile(cal17_2, %d)*10+%d  from  ( select  " %(random.randint(0,100) , random.randint(0,100) ,random.randint(-1000,1000))
G
Ganlin Zhao 已提交
4999 5000
            sql += "%s as cal17_1 ," % random.choice(self.calc_aggregate_all)
            sql += "%s as cal17_2 " % random.choice(self.calc_aggregate_all)
5001 5002 5003 5004 5005 5006 5007
            sql += " from regular_table_1 where "
            sql += "%s " % random.choice(self.q_where)
            sql += "%s " % random.choice(self.interval_sliding)
            #sql += "%s " % random.choice(self.order_where)
            sql += "%s " % random.choice(self.limit1_where)
            sql += ") "
            #sql += "%s " % random.choice(interval_sliding)
G
Ganlin Zhao 已提交
5008 5009
            tdLog.info(sql)
            tdLog.info(len(sql))
5010 5011
            tdSql.query(sql)
            self.cur1.execute(sql)
G
Ganlin Zhao 已提交
5012

5013 5014 5015
        tdSql.query("select 17-9 from stable_1;")
        for i in range(self.fornum):
            sql = "select   apercentile(cal17_1, %d)/1000 ,apercentile(cal17_2, %d)*10+%d  from  ( select  " %(random.randint(0,100) , random.randint(0,100) ,random.randint(-1000,1000))
G
Ganlin Zhao 已提交
5016 5017
            sql += "%s as cal17_1 ," % random.choice(self.calc_aggregate_all_j)
            sql += "%s as cal17_2 " % random.choice(self.calc_aggregate_all_j)
5018 5019 5020 5021 5022 5023 5024
            sql += " from regular_table_1 t1, regular_table_2 t2 where t1.ts = t2.ts and  "
            sql += "%s " % random.choice(self.q_u_where)
            sql += "%s " % random.choice(self.interval_sliding)
            #sql += "%s " % random.choice(self.order_u_where)
            sql += "%s " % random.choice(self.limit_u_where)
            sql += ") "
            #sql += "%s " % random.choice(interval_sliding)
G
Ganlin Zhao 已提交
5025 5026
            tdLog.info(sql)
            tdLog.info(len(sql))
5027 5028 5029 5030 5031 5032
            tdSql.query(sql)
            self.cur1.execute(sql)

        tdSql.query("select 17-10 from stable_1;")
        for i in range(self.fornum):
            sql = "select   apercentile(cal17_1, %d)/1000 ,apercentile(cal17_2, %d)*10+%d  from  ( select  " %(random.randint(0,100) , random.randint(0,100) ,random.randint(-1000,1000))
G
Ganlin Zhao 已提交
5033 5034
            sql += "%s as cal17_1 ," % random.choice(self.calc_aggregate_all_j)
            sql += "%s as cal17_2 " % random.choice(self.calc_aggregate_all_j)
5035 5036 5037 5038 5039 5040 5041
            sql += " from regular_table_1 t1, regular_table_2 t2 where t1.ts = t2.ts and  "
            sql += "%s " % random.choice(self.q_u_or_where)
            sql += "%s " % random.choice(self.interval_sliding)
            #sql += "%s " % random.choice(self.order_u_where)
            sql += "%s " % random.choice(self.limit_u_where)
            sql += ") "
            #sql += "%s " % random.choice(interval_sliding)
G
Ganlin Zhao 已提交
5042 5043
            tdLog.info(sql)
            tdLog.info(len(sql))
5044 5045 5046 5047 5048 5049 5050
            tdSql.query(sql)
            self.cur1.execute(sql)

        #18 select apercentile from (select calc_aggregate_alls form regualr_table or stable  where <\>\in\and\or session order by  limit )interval_sliding
        tdSql.query("select 18-1 from stable_1;")
        for i in range(self.fornum):
            sql = "select   apercentile(cal18_1, %d)/1000 ,apercentile(cal18_2, %d)*10+%d  from  ( select  " %(random.randint(0,100) , random.randint(0,100) ,random.randint(-1000,1000))
G
Ganlin Zhao 已提交
5051 5052
            sql += "%s as cal18_1 ," % random.choice(self.calc_aggregate_all)
            sql += "%s as cal18_2 " % random.choice(self.calc_aggregate_all)
5053 5054 5055 5056 5057 5058 5059 5060
            sql += " from regular_table_1 where "
            sql += "%s " % random.choice(self.q_where)
            sql += "%s " % random.choice(self.session_where)
            #sql += "%s " % random.choice(self.fill_where)
            #sql += "%s " % random.choice(self.order_where)
            sql += "%s " % random.choice(self.limit1_where)
            sql += ") "
            #sql += "%s " % random.choice(interval_sliding)
G
Ganlin Zhao 已提交
5061 5062
            tdLog.info(sql)
            tdLog.info(len(sql))
5063 5064
            tdSql.query(sql)
            self.cur1.execute(sql)
G
Ganlin Zhao 已提交
5065

5066 5067 5068
        tdSql.query("select 18-2 from stable_1;")
        for i in range(self.fornum):
            sql = "select   apercentile(cal18_1, %d)/1000 ,apercentile(cal18_2, %d)*10+%d  from  ( select  " %(random.randint(0,100) , random.randint(0,100) ,random.randint(-1000,1000))
G
Ganlin Zhao 已提交
5069 5070
            sql += "%s as cal18_1 ," % random.choice(self.calc_aggregate_all_j)
            sql += "%s as cal18_2 " % random.choice(self.calc_aggregate_all_j)
5071 5072 5073 5074 5075 5076 5077
            sql += " from regular_table_1 t1, regular_table_2 t2 where t1.ts = t2.ts and   "
            sql += "%s " % random.choice(self.q_u_where)
            sql += "%s " % random.choice(self.session_u_where)
            #sql += "%s " % random.choice(self.order_u_where)
            sql += "%s " % random.choice(self.limit_u_where)
            sql += ") "
            #sql += "%s " % random.choice(interval_sliding)
G
Ganlin Zhao 已提交
5078 5079
            tdLog.info(sql)
            tdLog.info(len(sql))
5080 5081 5082 5083 5084 5085
            tdSql.query(sql)
            self.cur1.execute(sql)

        tdSql.query("select 18-2.2 from stable_1;")
        for i in range(self.fornum):
            sql = "select   apercentile(cal18_1, %d)/1000 ,apercentile(cal18_2, %d)*10+%d  from  ( select  " %(random.randint(0,100) , random.randint(0,100) ,random.randint(-1000,1000))
G
Ganlin Zhao 已提交
5086 5087
            sql += "%s as cal18_1 ," % random.choice(self.calc_aggregate_all_j)
            sql += "%s as cal18_2 " % random.choice(self.calc_aggregate_all_j)
5088 5089 5090 5091 5092 5093 5094
            sql += " from regular_table_1 t1, regular_table_2 t2 where t1.ts = t2.ts and   "
            sql += "%s " % random.choice(self.q_u_or_where)
            sql += "%s " % random.choice(self.session_u_where)
            #sql += "%s " % random.choice(self.order_u_where)
            sql += "%s " % random.choice(self.limit_u_where)
            sql += ") "
            #sql += "%s " % random.choice(self.interval_sliding)
G
Ganlin Zhao 已提交
5095 5096
            tdLog.info(sql)
            tdLog.info(len(sql))
5097 5098 5099 5100 5101 5102 5103
            tdSql.query(sql)
            self.cur1.execute(sql)

        self.restartDnodes()
        tdSql.query("select 18-3 from stable_1;")
        for i in range(self.fornum):
            sql = "select   apercentile(cal18_1, %d)/1000 ,apercentile(cal18_2, %d)*10+%d  from  ( select  " %(random.randint(0,100) , random.randint(0,100) ,random.randint(-1000,1000))
G
Ganlin Zhao 已提交
5104 5105
            sql += "%s as cal18_1 ," % random.choice(self.calc_aggregate_all)
            sql += "%s as cal18_2 " % random.choice(self.calc_aggregate_all)
5106 5107 5108 5109 5110 5111 5112 5113
            sql += " from stable_1_1 where "
            sql += "%s " % random.choice(self.q_where)
            sql += "%s " % random.choice(self.session_where)
            #sql += "%s " % random.choice(self.fill_where)
            #sql += "%s " % random.choice(self.order_where)
            sql += "%s " % random.choice(self.limit1_where)
            sql += ") "
            #sql += "%s " % random.choice(self.interval_sliding)
G
Ganlin Zhao 已提交
5114 5115
            tdLog.info(sql)
            tdLog.info(len(sql))
5116 5117 5118 5119 5120 5121
            tdSql.query(sql)
            self.cur1.execute(sql)

        tdSql.query("select 18-4 from stable_1;")
        for i in range(self.fornum):
            sql = "select   apercentile(cal18_1, %d)/1000 ,apercentile(cal18_2, %d)*10+%d  from  ( select  " %(random.randint(0,100) , random.randint(0,100) ,random.randint(-1000,1000))
G
Ganlin Zhao 已提交
5122 5123
            sql += "%s as cal18_1 ," % random.choice(self.calc_aggregate_all_j)
            sql += "%s as cal18_2 " % random.choice(self.calc_aggregate_all_j)
5124 5125 5126 5127 5128 5129 5130
            sql += " from stable_1_1 t1, regular_table_2 t2 where t1.ts = t2.ts and  "
            sql += "%s " % random.choice(self.q_u_where)
            sql += "%s " % random.choice(self.session_u_where)
            #sql += "%s " % random.choice(self.order_u_where)
            sql += "%s " % random.choice(self.limit_u_where)
            sql += ") "
            #sql += "%s " % random.choice(self.interval_sliding)
G
Ganlin Zhao 已提交
5131 5132
            tdLog.info(sql)
            tdLog.info(len(sql))
5133 5134 5135 5136 5137 5138
            tdSql.query(sql)
            self.cur1.execute(sql)

        tdSql.query("select 18-4.2 from stable_1;")
        for i in range(self.fornum):
            sql = "select   apercentile(cal18_1, %d)/1000 ,apercentile(cal18_2, %d)*10+%d  from  ( select  " %(random.randint(0,100) , random.randint(0,100) ,random.randint(-1000,1000))
G
Ganlin Zhao 已提交
5139 5140
            sql += "%s as cal18_1 ," % random.choice(self.calc_aggregate_all_j)
            sql += "%s as cal18_2 " % random.choice(self.calc_aggregate_all_j)
5141 5142 5143 5144 5145 5146 5147
            sql += " from stable_1_1 t1, regular_table_2 t2 where t1.ts = t2.ts and  "
            sql += "%s " % random.choice(self.q_u_or_where)
            sql += "%s " % random.choice(self.session_u_where)
            #sql += "%s " % random.choice(self.order_u_where)
            sql += "%s " % random.choice(self.limit_u_where)
            sql += ") "
            #sql += "%s " % random.choice(self.interval_sliding)
G
Ganlin Zhao 已提交
5148 5149
            tdLog.info(sql)
            tdLog.info(len(sql))
5150 5151 5152 5153 5154 5155
            tdSql.query(sql)
            self.cur1.execute(sql)

        tdSql.query("select 18-5 from stable_1;")
        for i in range(self.fornum):
            sql = "select   apercentile(cal18_1, %d)/1000 ,apercentile(cal18_2, %d)*10+%d  from  ( select  " %(random.randint(0,100) , random.randint(0,100) ,random.randint(-1000,1000))
G
Ganlin Zhao 已提交
5156 5157
            sql += "%s as cal18_1 ," % random.choice(self.calc_aggregate_all)
            sql += "%s as cal18_2 " % random.choice(self.calc_aggregate_all)
5158 5159 5160 5161 5162 5163 5164 5165
            sql += " from stable_1 where "
            sql += "%s " % random.choice(self.q_where)
            sql += "%s " % random.choice(self.session_where)
            #sql += "%s " % random.choice(self.fill_where)
            #sql += "%s " % random.choice(self.order_where)
            sql += "%s " % random.choice(self.limit1_where)
            sql += ") "
            #sql += "%s " % random.choice(interval_sliding)
G
Ganlin Zhao 已提交
5166 5167
            tdLog.info(sql)
            tdLog.info(len(sql))
5168 5169 5170 5171 5172 5173
            tdSql.query(sql)
            self.cur1.execute(sql)

        tdSql.query("select 18-6 from stable_1;")
        for i in range(self.fornum):
            sql = "select   apercentile(cal18_1, %d)/1000 ,apercentile(cal18_2, %d)*10+%d  from  ( select  " %(random.randint(0,100) , random.randint(0,100) ,random.randint(-1000,1000))
G
Ganlin Zhao 已提交
5174 5175
            sql += "%s as cal18_1 ," % random.choice(self.calc_aggregate_all_j)
            sql += "%s as cal18_2 " % random.choice(self.calc_aggregate_all_j)
5176 5177 5178 5179 5180 5181 5182
            sql += " from stable_1 t1, stable_2 t2 where t1.ts = t2.ts and   "
            sql += "%s " % random.choice(self.t_join_where)
            sql += "%s " % random.choice(self.session_u_where)
            #sql += "%s " % random.choice(self.order_u_where)
            sql += "%s " % random.choice(self.limit_u_where)
            sql += ") "
            #sql += "%s " % random.choice(self.interval_sliding)
G
Ganlin Zhao 已提交
5183 5184
            tdLog.info(sql)
            tdLog.info(len(sql))
5185 5186
            tdSql.query(sql)
            self.cur1.execute(sql)
G
Ganlin Zhao 已提交
5187

5188 5189 5190
        tdSql.query("select 18-7 from stable_1;")
        for i in range(self.fornum):
            sql = "select   apercentile(cal18_1, %d)/1000 ,apercentile(cal18_2, %d)*10+%d  from  ( select  " %(random.randint(0,100) , random.randint(0,100) ,random.randint(-1000,1000))
G
Ganlin Zhao 已提交
5191 5192
            sql += "%s as cal18_1 ," % random.choice(self.calc_aggregate_all_j)
            sql += "%s as cal18_2 " % random.choice(self.calc_aggregate_all_j)
5193 5194 5195 5196 5197 5198 5199
            sql += " from stable_1 t1, stable_2 t2 where t1.ts = t2.ts and   "
            sql += "%s " % random.choice(self.qt_u_or_where)
            sql += "%s " % random.choice(self.session_u_where)
            #sql += "%s " % random.choice(self.order_u_where)
            sql += "%s " % random.choice(self.limit_u_where)
            sql += ") "
            #sql += "%s " % random.choice(self.interval_sliding)
G
Ganlin Zhao 已提交
5200 5201
            tdLog.info(sql)
            tdLog.info(len(sql))
5202 5203 5204
            tdSql.query(sql)
            self.cur1.execute(sql)

G
Ganlin Zhao 已提交
5205
        #19 select apercentile from (select calc_aggregate_alls form regualr_table or stable  where <\>\in\and\or session order by  limit )interval_sliding
5206 5207 5208 5209
        #self.dropandcreateDB_random("%s" %db, 1)
        tdSql.query("select 19-1 from stable_1;")
        for i in range(self.fornum):
            sql = "select   apercentile(cal19_1, %d)/1000 ,apercentile(cal19_2, %d)*10+%d  from  ( select  " %(random.randint(0,100) , random.randint(0,100) ,random.randint(-1000,1000))
G
Ganlin Zhao 已提交
5210 5211
            sql += "%s as cal19_1 ," % random.choice(self.calc_aggregate_all)
            sql += "%s as cal19_2 " % random.choice(self.calc_aggregate_all)
5212
            sql += " from regular_table_1 where "
G
Ganlin Zhao 已提交
5213
            sql += "%s " % random.choice(self.q_where)
5214 5215 5216 5217
            sql += "%s " % random.choice(self.state_window)
            #sql += "%s " % random.choice(self.order_where)
            sql += "%s " % random.choice(self.limit1_where)
            sql += ") "
G
Ganlin Zhao 已提交
5218 5219
            tdLog.info(sql)
            tdLog.info(len(sql))
5220 5221 5222 5223 5224 5225
            tdSql.query(sql)
            self.cur1.execute(sql)

        tdSql.query("select 19-2 from stable_1;")
        for i in range(self.fornum):
            sql = "select   apercentile(cal19_1, %d)/1000 ,apercentile(cal19_2, %d)*10+%d  from  ( select  " %(random.randint(0,100) , random.randint(0,100) ,random.randint(-1000,1000))
G
Ganlin Zhao 已提交
5226 5227
            sql += "%s as cal19_1 ," % random.choice(self.calc_aggregate_all_j)
            sql += "%s as cal19_2 " % random.choice(self.calc_aggregate_all_j)
5228
            sql += " from regular_table_1 t1, regular_table_2 t2 where t1.ts = t2.ts and   "
G
Ganlin Zhao 已提交
5229
            sql += "%s " % random.choice(self.q_u_where)
5230 5231 5232 5233
            sql += "%s " % random.choice(self.state_u_window)
            #sql += "%s " % random.choice(self.order_u_where)
            sql += "%s " % random.choice(self.limit_u_where)
            sql += ") "
G
Ganlin Zhao 已提交
5234 5235
            tdLog.info(sql)
            tdLog.info(len(sql))
5236 5237 5238 5239 5240 5241
            tdSql.query(sql)
            self.cur1.execute(sql)

        tdSql.query("select 19-2.2 from stable_1;")
        for i in range(self.fornum):
            sql = "select   apercentile(cal19_1, %d)/1000 ,apercentile(cal19_2, %d)*10+%d  from  ( select  " %(random.randint(0,100) , random.randint(0,100) ,random.randint(-1000,1000))
G
Ganlin Zhao 已提交
5242 5243
            sql += "%s as cal19_1 ," % random.choice(self.calc_aggregate_all_j)
            sql += "%s as cal19_2 " % random.choice(self.calc_aggregate_all_j)
5244
            sql += " from regular_table_1 t1, regular_table_2 t2 where t1.ts = t2.ts and   "
G
Ganlin Zhao 已提交
5245
            sql += "%s " % random.choice(self.q_u_or_where)
5246 5247 5248 5249
            sql += "%s " % random.choice(self.state_u_window)
            #sql += "%s " % random.choice(self.order_u_where)
            sql += "%s " % random.choice(self.limit_u_where)
            sql += ") "
G
Ganlin Zhao 已提交
5250 5251
            tdLog.info(sql)
            tdLog.info(len(sql))
5252 5253
            tdSql.query(sql)
            self.cur1.execute(sql)
G
Ganlin Zhao 已提交
5254

5255 5256 5257
        tdSql.query("select 19-3 from stable_1;")
        for i in range(self.fornum):
            sql = "select   apercentile(cal19_1, %d)/1000 ,apercentile(cal19_2, %d)*10+%d  from  ( select  " %(random.randint(0,100) , random.randint(0,100) ,random.randint(-1000,1000))
G
Ganlin Zhao 已提交
5258 5259
            sql += "%s as cal19_1 ," % random.choice(self.calc_aggregate_all)
            sql += "%s as cal19_2 " % random.choice(self.calc_aggregate_all)
5260
            sql += " from stable_1_1 where "
G
Ganlin Zhao 已提交
5261
            sql += "%s " % random.choice(self.q_where)
5262 5263 5264 5265
            sql += "%s " % random.choice(self.state_window)
            #sql += "%s " % random.choice(self.order_where)
            sql += "%s " % random.choice(self.limit1_where)
            sql += ") "
G
Ganlin Zhao 已提交
5266 5267
            tdLog.info(sql)
            tdLog.info(len(sql))
5268 5269 5270 5271 5272 5273
            tdSql.query(sql)
            self.cur1.execute(sql)

        tdSql.query("select 19-4 from stable_1;")
        for i in range(self.fornum):
            sql = "select   apercentile(cal19_1, %d)/1000 ,apercentile(cal19_2, %d)*10+%d  from  ( select  " %(random.randint(0,100) , random.randint(0,100) ,random.randint(-1000,1000))
G
Ganlin Zhao 已提交
5274 5275
            sql += "%s as cal19_1 ," % random.choice(self.calc_aggregate_all_j)
            sql += "%s as cal19_2 " % random.choice(self.calc_aggregate_all_j)
5276
            sql += " from stable_1_1  t1, stable_1_2 t2 where t1.ts = t2.ts and  "
G
Ganlin Zhao 已提交
5277
            sql += "%s " % random.choice(self.q_u_where)
5278 5279 5280 5281
            #sql += "%s " % random.choice(self.state_window)
            #sql += "%s " % random.choice(self.order_u_where)
            sql += "%s " % random.choice(self.limit_u_where)
            sql += ") "
G
Ganlin Zhao 已提交
5282 5283
            tdLog.info(sql)
            tdLog.info(len(sql))
5284 5285 5286 5287 5288 5289
            tdSql.query(sql)
            self.cur1.execute(sql)

        tdSql.query("select 19-4.2 from stable_1;")
        for i in range(self.fornum):
            sql = "select   apercentile(cal19_1, %d)/1000 ,apercentile(cal19_2, %d)*10+%d  from  ( select  " %(random.randint(0,100) , random.randint(0,100) ,random.randint(-1000,1000))
G
Ganlin Zhao 已提交
5290 5291
            sql += "%s as cal19_1 ," % random.choice(self.calc_aggregate_all_j)
            sql += "%s as cal19_2 " % random.choice(self.calc_aggregate_all_j)
5292
            sql += " from stable_1_1  t1, stable_1_2 t2 where t1.ts = t2.ts and  "
G
Ganlin Zhao 已提交
5293
            sql += "%s " % random.choice(self.q_u_or_where)
5294 5295 5296
            #sql += "%s " % random.choice(self.order_u_where)
            sql += "%s " % random.choice(self.limit_u_where)
            sql += ") "
G
Ganlin Zhao 已提交
5297 5298
            tdLog.info(sql)
            tdLog.info(len(sql))
5299 5300 5301 5302 5303 5304
            tdSql.query(sql)
            self.cur1.execute(sql)

        tdSql.query("select 19-5 from stable_1;")
        for i in range(self.fornum):
            sql = "select   apercentile(cal19_1, %d)/1000 ,apercentile(cal19_2, %d)*10+%d  from  ( select  " %(random.randint(0,100) , random.randint(0,100) ,random.randint(-1000,1000))
G
Ganlin Zhao 已提交
5305 5306
            sql += "%s as cal19_1 ," % random.choice(self.calc_aggregate_all)
            sql += "%s as cal19_2 " % random.choice(self.calc_aggregate_all)
5307
            sql += " from stable_1 where "
G
Ganlin Zhao 已提交
5308
            sql += "%s " % random.choice(self.q_where)
5309 5310 5311 5312 5313
            sql += "%s " % random.choice(self.state_window)
            sql += "%s " % random.choice(self.order_where)
            sql += "%s " % random.choice(self.limit1_where)
            sql += ") "
            sql += "%s " % random.choice(self.interval_sliding)
G
Ganlin Zhao 已提交
5314 5315
            tdLog.info(sql)
            tdLog.info(len(sql))
5316
            tdSql.error(sql)   #'STATE_WINDOW not support for super table query'
G
Ganlin Zhao 已提交
5317

5318 5319 5320
        tdSql.query("select 19-6 from stable_1;")
        for i in range(self.fornum):
            sql = "select   apercentile(cal19_1, %d)/1000 ,apercentile(cal19_2, %d)*10+%d  from  ( select  " %(random.randint(0,100) , random.randint(0,100) ,random.randint(-1000,1000))
G
Ganlin Zhao 已提交
5321 5322
            sql += "%s as cal19_1 ," % random.choice(self.calc_aggregate_all_j)
            sql += "%s as cal19_2 " % random.choice(self.calc_aggregate_all_j)
5323
            sql += " from stable_1 t1 , stable_2 t2 where t1.ts = t2.ts and "
G
Ganlin Zhao 已提交
5324
            sql += "%s " % random.choice(self.q_u_where)
5325 5326 5327 5328 5329
            #sql += "%s " % random.choice(self.state_window)
            #sql += "%s " % random.choice(self.order_u_where)
            sql += "%s " % random.choice(self.limit_u_where)
            sql += ") "
            #sql += "%s " % random.choice(self.interval_sliding)
G
Ganlin Zhao 已提交
5330 5331
            tdLog.info(sql)
            tdLog.info(len(sql))
5332 5333 5334 5335 5336 5337
            tdSql.query(sql)
            self.cur1.execute(sql)

        tdSql.query("select 19-7 from stable_1;")
        for i in range(self.fornum):
            sql = "select   apercentile(cal19_1, %d)/1000 ,apercentile(cal19_2, %d)*10+%d  from  ( select  " %(random.randint(0,100) , random.randint(0,100) ,random.randint(-1000,1000))
G
Ganlin Zhao 已提交
5338 5339
            sql += "%s as cal19_1 ," % random.choice(self.calc_aggregate_all_j)
            sql += "%s as cal19_2 " % random.choice(self.calc_aggregate_all_j)
5340
            sql += " from stable_1 t1 , stable_2 t2 where t1.ts = t2.ts and "
G
Ganlin Zhao 已提交
5341
            sql += "%s " % random.choice(self.qt_u_or_where)
5342 5343 5344 5345
            #sql += "%s " % random.choice(self.order_u_where)
            sql += "%s " % random.choice(self.limit_u_where)
            sql += ") "
            #sql += "%s " % random.choice(self.interval_sliding)
G
Ganlin Zhao 已提交
5346 5347
            tdLog.info(sql)
            tdLog.info(len(sql))
5348 5349 5350
            tdSql.query(sql)
            self.cur1.execute(sql)

G
Ganlin Zhao 已提交
5351
        #20 select * from (select calc_select_fills form regualr_table or stable  where <\>\in\and\or fill_where group by  order by limit offset  )
5352 5353 5354
        #self.dropandcreateDB_random("%s" %db, 1)
        tdSql.query("select 20-1 from stable_1;")
        for i in range(self.fornum):
G
Ganlin Zhao 已提交
5355
            sql = "select   * from  ( select  "
5356
            sql += "%s , " % random.choice(self.calc_select_fill)
G
Ganlin Zhao 已提交
5357 5358
            sql += "%s ," % random.choice(self.calc_select_fill)
            sql += "%s  " % random.choice(self.calc_select_fill)
5359
            sql += " from stable_1 where  "
G
Ganlin Zhao 已提交
5360
            sql += "%s " % random.choice(self.interp_where)
5361 5362 5363 5364 5365
            sql += "%s " % random.choice(self.fill_where)
            sql += "%s " % random.choice(self.group_where)
            sql += "%s " % random.choice(self.order_where)
            sql += "%s " % random.choice(self.limit_where)
            sql += ") "
G
Ganlin Zhao 已提交
5366 5367
            tdLog.info(sql)
            tdLog.info(len(sql))
5368 5369 5370 5371 5372 5373
            #interp不支持 tdSql.query(sql)
            #self.cur1.execute(sql)

        rsDn = self.restartDnodes()
        tdSql.query("select 20-2 from stable_1;")
        for i in range(self.fornum):
G
Ganlin Zhao 已提交
5374
            sql = "select   * from  ( select  "
5375
            sql += "%s , " % random.choice(self.calc_select_fill_j)
G
Ganlin Zhao 已提交
5376 5377
            sql += "%s ," % random.choice(self.calc_select_fill_j)
            sql += "%s  " % random.choice(self.calc_select_fill_j)
5378 5379
            sql += " from stable_1 t1 , stable_2 t2 where t1.ts = t2.ts and  "
            sql += "%s and " % random.choice(self.t_join_where)
G
Ganlin Zhao 已提交
5380
            sql += "%s " % random.choice(self.interp_where_j)
5381 5382 5383
            sql += "%s " % random.choice(self.order_u_where)
            sql += "%s " % random.choice(self.limit_u_where)
            sql += ") "
G
Ganlin Zhao 已提交
5384 5385
            tdLog.info(sql)
            tdLog.info(len(sql))
5386 5387 5388 5389 5390
            #interp不支持 tdSql.query(sql)
            #self.cur1.execute(sql)

        tdSql.query("select 20-2.2 from stable_1;")
        for i in range(self.fornum):
G
Ganlin Zhao 已提交
5391
            sql = "select   * from  ( select  "
5392
            sql += "%s , " % random.choice(self.calc_select_fill_j)
G
Ganlin Zhao 已提交
5393 5394
            sql += "%s ," % random.choice(self.calc_select_fill_j)
            sql += "%s  " % random.choice(self.calc_select_fill_j)
5395 5396
            sql += " from stable_1 t1 , stable_2 t2 where t1.ts = t2.ts and  "
            sql += "%s and " % random.choice(self.qt_u_or_where)
G
Ganlin Zhao 已提交
5397
            sql += "%s " % random.choice(self.interp_where_j)
5398 5399 5400
            sql += "%s " % random.choice(self.order_u_where)
            sql += "%s " % random.choice(self.limit_u_where)
            sql += ") "
G
Ganlin Zhao 已提交
5401 5402
            tdLog.info(sql)
            tdLog.info(len(sql))
5403 5404 5405 5406 5407
            #interp不支持 tdSql.query(sql)
            #self.cur1.execute(sql)

        tdSql.query("select 20-3 from stable_1;")
        for i in range(self.fornum):
G
Ganlin Zhao 已提交
5408
            sql = "select   * from  ( select  "
5409
            sql += "%s , " % random.choice(self.calc_select_fill)
G
Ganlin Zhao 已提交
5410 5411
            sql += "%s ," % random.choice(self.calc_select_fill)
            sql += "%s  " % random.choice(self.calc_select_fill)
5412
            sql += " from stable_1 where  "
G
Ganlin Zhao 已提交
5413
            sql += "%s " % self.interp_where[2]
5414 5415 5416 5417
            sql += "%s " % random.choice(self.fill_where)
            sql += "%s " % random.choice(self.order_where)
            sql += "%s " % random.choice(self.limit_where)
            sql += ") "
G
Ganlin Zhao 已提交
5418 5419
            tdLog.info(sql)
            tdLog.info(len(sql))
5420 5421
            #interp不支持 tdSql.query(sql)
            #self.cur1.execute(sql)
G
Ganlin Zhao 已提交
5422

5423 5424
        tdSql.query("select 20-4 from stable_1;")
        for i in range(self.fornum):
G
Ganlin Zhao 已提交
5425
            sql = "select   * from  ( select  "
5426
            sql += "%s , " % random.choice(self.calc_select_fill_j)
G
Ganlin Zhao 已提交
5427 5428 5429
            sql += "%s ," % random.choice(self.calc_select_fill_j)
            sql += "%s  " % random.choice(self.calc_select_fill_j)
            sql += " from stable_1 t1, table_1 t2 where t1.ts = t2.ts and    "
5430 5431 5432 5433 5434
            #sql += "%s and " % random.choice(self.t_join_where)
            sql += "%s " % self.interp_where_j[random.randint(0,5)]
            sql += "%s " % random.choice(self.order_u_where)
            sql += "%s " % random.choice(self.limit_u_where)
            sql += ") "
G
Ganlin Zhao 已提交
5435 5436
            tdLog.info(sql)
            tdLog.info(len(sql))
5437 5438 5439 5440 5441
            #interp不支持 tdSql.query(sql)
            #self.cur1.execute(sql)

        tdSql.query("select 20-4.2 from stable_1;")
        for i in range(self.fornum):
G
Ganlin Zhao 已提交
5442
            sql = "select   * from  ( select  "
5443
            sql += "%s , " % random.choice(self.calc_select_fill_j)
G
Ganlin Zhao 已提交
5444 5445 5446
            sql += "%s ," % random.choice(self.calc_select_fill_j)
            sql += "%s  " % random.choice(self.calc_select_fill_j)
            sql += " from stable_1 t1, stable_1_1 t2 where t1.ts = t2.ts and    "
5447 5448 5449 5450 5451 5452
            sql += "%s and " % random.choice(self.qt_u_or_where)
            sql += "%s " % self.interp_where_j[random.randint(0,5)]
            sql += "%s " % random.choice(self.fill_where)
            sql += "%s " % random.choice(self.order_u_where)
            sql += "%s " % random.choice(self.limit_u_where)
            sql += ") "
G
Ganlin Zhao 已提交
5453 5454
            tdLog.info(sql)
            tdLog.info(len(sql))
5455 5456
         ##interp不支持    tdSql.error(sql)
            #self.cur1.execute(sql)
G
Ganlin Zhao 已提交
5457

5458 5459
        tdSql.query("select 20-5 from stable_1;")
        for i in range(self.fornum):
G
Ganlin Zhao 已提交
5460
            sql = "select   * from  ( select  "
5461
            sql += "%s , " % random.choice(self.calc_select_fill)
G
Ganlin Zhao 已提交
5462 5463
            sql += "%s ," % random.choice(self.calc_select_fill)
            sql += "%s  " % random.choice(self.calc_select_fill)
5464
            sql += " from regular_table_1 where  "
G
Ganlin Zhao 已提交
5465
            sql += "%s " % self.interp_where[1]
5466 5467 5468 5469
            sql += "%s " % random.choice(self.fill_where)
            sql += "%s " % random.choice(self.order_where)
            sql += "%s " % random.choice(self.limit_where)
            sql += ") "
G
Ganlin Zhao 已提交
5470 5471
            tdLog.info(sql)
            tdLog.info(len(sql))
5472 5473 5474 5475 5476
            ##interp不支持 tdSql.query(sql)
            #self.cur1.execute(sql)

        tdSql.query("select 20-6 from stable_1;")
        for i in range(self.fornum):
G
Ganlin Zhao 已提交
5477
            sql = "select   * from  ( select  "
5478
            sql += "%s , " % random.choice(self.calc_select_fill_j)
G
Ganlin Zhao 已提交
5479 5480
            sql += "%s ," % random.choice(self.calc_select_fill_j)
            sql += "%s  " % random.choice(self.calc_select_fill_j)
5481
            sql += " from regular_table_1 t1, regular_table_2 t2 where t1.ts = t2.ts and   "
G
Ganlin Zhao 已提交
5482 5483
            #sql += "%s " % random.choice(self.interp_where_j)
            sql += "%s " % self.interp_where_j[random.randint(0,5)]
5484 5485 5486
            sql += "%s " % random.choice(self.order_u_where)
            sql += "%s " % random.choice(self.limit_u_where)
            sql += ") "
G
Ganlin Zhao 已提交
5487 5488
            tdLog.info(sql)
            tdLog.info(len(sql))
5489 5490 5491 5492 5493
            ##interp不支持 tdSql.query(sql)
            #self.cur1.execute(sql)

        #1 select * from (select * from (select * form regular_table  where <\>\in\and\or order by limit  ))
        tdSql.query("select 1-1 from stable_1;")
G
Ganlin Zhao 已提交
5494
        for i in range(self.fornum):
5495 5496 5497
            # sql_start = "select  *  from ( "
            # sql_end = ")"
            for_num = random.randint(1, 15);
G
Ganlin Zhao 已提交
5498
            sql = "select  *  from ("  * for_num
5499
            sql += "select  *  from  ( select * from ( select  "
G
Ganlin Zhao 已提交
5500 5501
            sql += "%s, " % random.choice(self.s_r_select)
            sql += "%s, " % random.choice(self.q_select)
5502 5503 5504
            sql += "ts from regular_table_1 where "
            sql += "%s " % random.choice(self.q_where)
            sql += ")) "
G
Ganlin Zhao 已提交
5505 5506 5507 5508
            sql += ")"  * for_num
            tdLog.info(sql)
            tdLog.info(len(sql))
            tdSql.query(sql)
5509
            self.cur1.execute(sql)
G
Ganlin Zhao 已提交
5510

5511
            sql2 =  "select  *  from  ( select * from ( select  "
G
Ganlin Zhao 已提交
5512 5513
            sql2 += "%s, " % random.choice(self.s_r_select)
            sql2 += "%s, " % random.choice(self.q_select)
5514 5515
            sql2 += "ts from regular_table_1 where "
            sql2 += "%s " % random.choice(self.q_where)
G
Ganlin Zhao 已提交
5516 5517 5518 5519
            sql2 += ")) "
            tdLog.info(sql2)
            tdLog.info(len(sql2))
            tdSql.query(sql2)
5520
            self.cur1.execute(sql2)
G
Ganlin Zhao 已提交
5521

5522 5523 5524
            self.data_matrix_equal('%s' %sql ,1,10,1,1,'%s' %sql2 ,1,10,1,1)
            self.data_matrix_equal('%s' %sql ,1,10,1,1,'%s' %sql ,1,10,3,3)
            self.data_matrix_equal('%s' %sql ,1,10,3,3,'%s' %sql2 ,1,10,3,3)
G
Ganlin Zhao 已提交
5525

5526 5527
        for i in range(self.fornum):
            for_num = random.randint(1, 15);
G
Ganlin Zhao 已提交
5528
            sql = "select  ts  from ("  * for_num
5529
            sql += "select  *  from  ( select * from ( select  "
G
Ganlin Zhao 已提交
5530 5531
            sql += "%s, " % random.choice(self.s_r_select)
            sql += "%s, " % random.choice(self.q_select)
5532 5533 5534
            sql += "ts from regular_table_1 where "
            sql += "%s " % random.choice(self.q_where)
            sql += ")) "
G
Ganlin Zhao 已提交
5535 5536 5537 5538
            sql += ")"  * for_num
            tdLog.info(sql)
            tdLog.info(len(sql))
            tdSql.query(sql)
5539
            self.cur1.execute(sql)
G
Ganlin Zhao 已提交
5540

5541
            sql2 =  "select  *  from  ( select * from ( select  "
G
Ganlin Zhao 已提交
5542 5543
            sql2 += "%s, " % random.choice(self.s_r_select)
            sql2 += "%s, " % random.choice(self.q_select)
5544 5545
            sql2 += "ts from regular_table_1 where "
            sql2 += "%s " % random.choice(self.q_where)
G
Ganlin Zhao 已提交
5546 5547 5548
            sql2 += ")) "
            tdLog.info(sql2)
            tdLog.info(len(sql2))
5549
            tdSql.query(sql2)
G
Ganlin Zhao 已提交
5550 5551
            self.cur1.execute(sql2)

5552
            self.data_matrix_equal('%s' %sql ,1,10,1,1,'%s' %sql2 ,1,10,1,1)
G
Ganlin Zhao 已提交
5553

5554 5555 5556 5557
        #2 select * from (select * from (select * form stable  where <\>\in\and\or order by limit  ))
        tdSql.query("select 2-1 from stable_1;")
        for i in range(self.fornum):
            for_num = random.randint(1, 15);
G
Ganlin Zhao 已提交
5558
            sql = "select  *  from ("  * for_num
5559
            sql += "select  *  from  ( select * from ( select  "
G
Ganlin Zhao 已提交
5560 5561
            sql += "%s, " % random.choice(self.s_s_select)
            sql += "%s, " % random.choice(self.qt_select)
5562 5563 5564
            sql += "ts from stable_1 where "
            sql += "%s " % random.choice(self.q_where)
            sql += ")) "
G
Ganlin Zhao 已提交
5565 5566 5567 5568
            sql += ")"  * for_num
            tdLog.info(sql)
            tdLog.info(len(sql))
            tdSql.query(sql)
5569
            self.cur1.execute(sql)
G
Ganlin Zhao 已提交
5570

5571
            sql2 = "select  *  from  ( select * from ( select  "
G
Ganlin Zhao 已提交
5572 5573
            sql2 += "%s, " % random.choice(self.s_s_select)
            sql2 += "%s, " % random.choice(self.qt_select)
5574 5575
            sql2 += "ts from stable_1 where "
            sql2 += "%s " % random.choice(self.q_where)
G
Ganlin Zhao 已提交
5576 5577 5578 5579
            sql2 += ")) "
            tdLog.info(sql2)
            tdLog.info(len(sql2))
            tdSql.query(sql2)
5580
            self.cur1.execute(sql2)
G
Ganlin Zhao 已提交
5581

5582
            self.data_matrix_equal('%s' %sql ,1,10,3,3,'%s' %sql2 ,1,10,3,3)
G
Ganlin Zhao 已提交
5583

5584 5585
        for i in range(self.fornum):
            for_num = random.randint(1, 15);
G
Ganlin Zhao 已提交
5586
            sql = "select  ts  from ("  * for_num
5587
            sql += "select  *  from  ( select * from ( select  "
G
Ganlin Zhao 已提交
5588 5589
            sql += "%s, " % random.choice(self.s_s_select)
            sql += "%s, " % random.choice(self.qt_select)
5590 5591 5592
            sql += "ts from stable_1 where "
            sql += "%s " % random.choice(self.q_where)
            sql += ")) "
G
Ganlin Zhao 已提交
5593 5594 5595 5596
            sql += ")"  * for_num
            tdLog.info(sql)
            tdLog.info(len(sql))
            tdSql.query(sql)
5597
            self.cur1.execute(sql)
G
Ganlin Zhao 已提交
5598

5599
            sql2 = "select  ts  from  ( select * from ( select  "
G
Ganlin Zhao 已提交
5600 5601
            sql2 += "%s, " % random.choice(self.s_s_select)
            sql2 += "%s, " % random.choice(self.qt_select)
5602 5603
            sql2 += "ts from stable_1 where "
            sql2 += "%s " % random.choice(self.q_where)
G
Ganlin Zhao 已提交
5604 5605 5606 5607
            sql2 += ")) "
            tdLog.info(sql2)
            tdLog.info(len(sql2))
            tdSql.query(sql2)
5608
            self.cur1.execute(sql2)
G
Ganlin Zhao 已提交
5609

5610
            self.data_matrix_equal('%s' %sql ,1,10,1,1,'%s' %sql2 ,1,10,1,1)
G
Ganlin Zhao 已提交
5611 5612

        #3 select ts ,calc from  (select * form stable  where <\>\in\and\or order by limit  )
5613 5614 5615 5616
        #self.dropandcreateDB_random("%s" %db, 1)
        tdSql.query("select 3-1 from stable_1;")
        for i in range(self.fornum):
            sql = "select   "
G
Ganlin Zhao 已提交
5617
            sql += "%s " % random.choice(self.calc_calculate_regular)
5618 5619 5620 5621 5622
            sql += " from ( select * from stable_1 where "
            sql += "%s " % random.choice(self.qt_where)
            sql += "%s " % random.choice(self.orders_desc_where)
            sql += "%s " % random.choice(self.limit_where)
            sql += ") ;"
G
Ganlin Zhao 已提交
5623 5624 5625 5626
            tdLog.info(sql)
            tdLog.info(len(sql))
            #'Invalid function name: derivative'  tdSql.query(sql)
            #self.cur1.execute(sql)
5627 5628 5629 5630 5631

        #4 select * from  (select calc form stable  where <\>\in\and\or order by limit  )
        tdSql.query("select 4-1 from stable_1;")
        for i in range(self.fornum):
            sql = "select  *  from  ( select  "
G
Ganlin Zhao 已提交
5632
            sql += "%s " % random.choice(self.calc_select_in_ts)
5633 5634 5635 5636 5637
            sql += "from stable_1 where "
            sql += "%s " % random.choice(self.qt_where)
            #sql += "%s " % random.choice(self.order_desc_where)
            sql += "%s " % random.choice(self.limit_where)
            sql += ") ;"
G
Ganlin Zhao 已提交
5638 5639
            tdLog.info(sql)
            tdLog.info(len(sql))
5640 5641
            tdSql.query(sql)
            self.cur1.execute(sql)
G
Ganlin Zhao 已提交
5642

5643 5644 5645 5646
        #5 select ts ,tbname from  (select * form stable  where <\>\in\and\or order by limit  )
        tdSql.query("select 5-1 from stable_1;")
        for i in range(self.fornum):
            sql = "select   ts , tbname , "
G
Ganlin Zhao 已提交
5647
            sql += "%s ," % random.choice(self.calc_calculate_regular)
5648 5649 5650 5651 5652 5653 5654
            sql += "%s ," % random.choice(self.dqt_select)
            sql += "%s " % random.choice(self.qt_select)
            sql += " from ( select * from stable_1 where "
            sql += "%s " % random.choice(self.qt_where)
            sql += "%s " % random.choice(self.orders_desc_where)
            sql += "%s " % random.choice(self.limit_where)
            sql += ") ;"
G
Ganlin Zhao 已提交
5655 5656 5657
            tdLog.info(sql)
            tdLog.info(len(sql))
            tdSql.error(sql)
5658 5659 5660 5661 5662 5663 5664 5665 5666 5667 5668 5669 5670 5671 5672 5673 5674 5675 5676 5677 5678 5679 5680

        #special sql
        tdSql.query("select 6-1 from stable_1;")
        for i in range(self.fornum):
            sql = "select * from ( select _block_dist() from stable_1);"
            # tdSql.query(sql)
            # tdSql.checkRows(1)
            sql = "select _block_dist() from (select * from stable_1);"
            tdSql.error(sql)
            sql = "select * from (select database());"
            tdSql.error(sql)
            sql = "select * from (select client_version());"
            tdSql.error(sql)
            sql = "select * from (select client_version() as version);"
            tdSql.error(sql)
            sql = "select * from (select server_version());"
            tdSql.error(sql)
            sql = "select * from (select server_version() as version);"
            tdSql.error(sql)
            sql = "select * from (select server_status());"
            tdSql.error(sql)
            sql = "select * from (select server_status() as status);"
            tdSql.error(sql)
G
Ganlin Zhao 已提交
5681

5682 5683 5684 5685 5686 5687 5688 5689 5690 5691 5692
        #taos -f sql
        startTime_taos_f = time.time()
        print("taos -f sql start!")
        taos_cmd1 = "taos -f %s/%s.sql" % (self.testcasePath,self.testcaseFilename)
        _ = subprocess.check_output(taos_cmd1, shell=True).decode("utf-8")
        print("taos -f sql over!")
        endTime_taos_f = time.time()
        print("taos_f total time %ds" % (endTime_taos_f - startTime_taos_f))

        print('=====================2.6 old function end ===========')

G
Ganlin Zhao 已提交
5693 5694


5695 5696
    def run(self):
        tdSql.prepare()
G
Ganlin Zhao 已提交
5697 5698 5699 5700 5701 5702

        startTime = time.time()

        #


5703 5704 5705
        #self.math_nest(['TAIL'])  #TD-16009
        # self.math_nest(['HYPERLOGLOG']) #TD-16038
        # self.math_nest(['UNIQUE'])
G
Ganlin Zhao 已提交
5706

5707 5708 5709 5710


        # #
        #self.function_before_26() #TD-16031
G
Ganlin Zhao 已提交
5711 5712 5713

        # self.math_nest(['ABS','SQRT'])    #TD-16042
        # self.math_nest(['SIN','COS','TAN','ASIN','ACOS','ATAN'])
5714
        # self.math_nest(['POW','LOG']) #TD-16039
G
Ganlin Zhao 已提交
5715 5716
        # self.math_nest(['FLOOR','CEIL','ROUND'])
        # #self.math_nest(['SAMPLE'])  #TD-16017
5717
        # #self.math_nest(['CSUM']) #TD-15936 crash
G
Ganlin Zhao 已提交
5718 5719 5720 5721 5722
        # self.math_nest(['MAVG'])

        self.str_nest(['LTRIM','RTRIM','LOWER','UPPER'])
        self.str_nest(['LENGTH','CHAR_LENGTH'])
        self.str_nest(['SUBSTR'])  #TD-16042
5723 5724 5725 5726 5727 5728 5729
        self.str_nest(['CONCAT']) #TD-16002 偶尔
        self.str_nest(['CONCAT_WS']) #TD-16002 偶尔
        # self.time_nest(['CAST']) #TD-16017偶尔,放到time里起来弄
        self.time_nest(['CAST_1'])
        self.time_nest(['CAST_2'])
        self.time_nest(['CAST_3'])
        self.time_nest(['CAST_4'])
G
Ganlin Zhao 已提交
5730 5731 5732



5733 5734 5735 5736 5737 5738
        # self.time_nest(['NOW','TODAY']) #
        # self.time_nest(['TIMEZONE']) #
        # self.time_nest(['TIMETRUNCATE'])  #TD-16039
        # self.time_nest(['TO_ISO8601'])
        # self.time_nest(['TO_UNIXTIMESTAMP'])#core多
        # self.time_nest(['ELAPSED'])
G
Ganlin Zhao 已提交
5739

5740 5741 5742 5743

        endTime = time.time()
        print("total time %ds" % (endTime - startTime))

G
Ganlin Zhao 已提交
5744

5745 5746 5747 5748 5749 5750 5751 5752 5753


    def stop(self):
        tdSql.close()
        tdLog.success("%s successfully executed" % __file__)


tdCases.addWindows(__file__, TDTestCase())
tdCases.addLinux(__file__, TDTestCase())