bool_binary.py 33.7 KB
Newer Older
S
Shuduo Sang 已提交
1 2 3 4 5 6 7 8 9
# -*- coding: utf-8 -*-

import sys
from util.log import *
from util.cases import *
from util.sql import *


class TDTestCase:
S
Shuduo Sang 已提交
10
    def init(self, conn, logSql):
S
Shuduo Sang 已提交
11
        tdLog.debug("start to execute %s" % __file__)
S
Shuduo Sang 已提交
12
        tdSql.init(conn.cursor(), logSql)
S
Shuduo Sang 已提交
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73

    def run(self):
        tdSql.prepare()

        # TSIM: system sh/stop_dnodes.sh
        # TSIM:
        # TSIM:
        # TSIM: system sh/deploy.sh -n dnode1 -i 1
        # TSIM: system sh/cfg.sh -n dnode1 -c walLevel -v 0
        # TSIM: system sh/exec.sh -n dnode1 -s start
        # TSIM:
        # TSIM: sleep 3000
        # TSIM: sql connect
        # TSIM:
        # TSIM: print ======================== dnode1 start
        tdLog.info('======================== dnode1 start')
        # TSIM:
        # TSIM: $dbPrefix = ta_bob_db
        # TSIM: $tbPrefix = ta_bob_tb
        tbPrefix = "ta_bob_tb"
        # TSIM: $mtPrefix = ta_bob_mt
        mtPrefix = "ta_bob_mt"
        # TSIM: $tbNum = 10
        tbNum = 10
        # TSIM: $rowNum = 20
        rowNum = 20
        # TSIM: $totalNum = 200
        totalNum = 200
        # TSIM:
        # TSIM: print =============== step1
        tdLog.info('=============== step1')
        # TSIM: $i = 0
        i = 0
        # TSIM: $db = $dbPrefix . $i
        # TSIM: $mt = $mtPrefix . $i
        mt = "%s%d" % (mtPrefix, i)
        # TSIM:
        # TSIM: sql create database $db
        # TSIM: sql use $db
        # TSIM: sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol bool,
        # tgcol2 binary(5))
        tdLog.info(
            'create table %s (ts timestamp, tbcol int) TAGS(tgcol bool, tgcol2 binary(5))' %
            (mt))
        tdSql.execute(
            'create table %s (ts timestamp, tbcol int) TAGS(tgcol bool, tgcol2 binary(5))' %
            (mt))
        # TSIM:
        # TSIM: $i = 0
        i = 0
        # TSIM: while $i < 5
        while (i < 5):
            tb = "%s%d" % (tbPrefix, i)
            # TSIM: sql create table $tb using $mt tags( 0, '0' )
            tdLog.info('create table %s using %s tags( 0, "0" )' % (tb, mt))
            tdSql.execute('create table %s using %s tags( 0, "0" )' % (tb, mt))
            # TSIM: $x = 0
            x = 0
            # TSIM: while $x < $rowNum
            while (x < rowNum):
                # TSIM: $ms = $x . m
L
liuyq-617 已提交
74
                ms = x * 60000
S
Shuduo Sang 已提交
75
                tdLog.info(
L
liuyq-617 已提交
76 77
                    "insert into %s values (%d, %d)" %
                    (tb, 1605045600000 + ms, x))
S
Shuduo Sang 已提交
78
                tdSql.execute(
L
liuyq-617 已提交
79 80
                    "insert into %s values (%d, %d)" %
                    (tb, 1605045600000 + ms, x))
S
Shuduo Sang 已提交
81 82
                # TSIM: $x = $x + 1
                x = x + 1
83
                # TSIM: endw
S
Shuduo Sang 已提交
84 85
            # TSIM: $i = $i + 1
            i = i + 1
86
            # TSIM: endw
S
Shuduo Sang 已提交
87 88 89 90 91 92 93 94 95 96 97
        # TSIM: while $i < 10
        while (i < 10):
            tb = "%s%d" % (tbPrefix, i)
            # TSIM: sql create table $tb using $mt tags( 1, '1' )
            tdLog.info('create table %s using %s tags( 1, "1" )' % (tb, mt))
            tdSql.execute('create table %s using %s tags( 1, "1" )' % (tb, mt))
            # TSIM: $x = 0
            x = 0
            # TSIM: while $x < $rowNum
            while (x < rowNum):
                # TSIM: $ms = $x . m
L
liuyq-617 已提交
98
                ms = x * 60000
S
Shuduo Sang 已提交
99
                tdLog.info(
L
liuyq-617 已提交
100 101
                    "insert into %s values (%d, %d)" %
                    (tb, 1605045600000 + ms, x))
S
Shuduo Sang 已提交
102
                tdSql.execute(
L
liuyq-617 已提交
103 104
                    "insert into %s values (%d, %d)" %
                    (tb, 1605045600000 + ms, x))
S
Shuduo Sang 已提交
105 106
                # TSIM: $x = $x + 1
                x = x + 1
107
                # TSIM: endw
S
Shuduo Sang 已提交
108 109
            # TSIM: $i = $i + 1
            i = i + 1
110
            # TSIM: endw
S
Shuduo Sang 已提交
111 112 113 114 115 116 117 118 119 120
        # TSIM:
        # TSIM: print =============== step2
        tdLog.info('=============== step2')
        # TSIM: sql select * from $mt
        tdLog.info('select * from %s' % (mt))
        tdSql.query('select * from %s' % (mt))
        # TSIM: if $rows != $totalNum then
        tdLog.info('tdSql.checkRow($totalNum)')
        tdSql.checkRows(totalNum)
        # TSIM: return -1
121
        # TSIM: endi
S
Shuduo Sang 已提交
122
        # TSIM:
L
liuyq-617 已提交
123 124 125
        # TSIM: sql select * from $mt where ts < 1605045600000 + 240001
        tdLog.info('select * from %s where ts < 1605045600000 + 240001' % (mt))
        tdSql.query('select * from %s where ts < 1605045600000 + 240001' % (mt))
S
Shuduo Sang 已提交
126 127 128 129
        # TSIM: if $rows != 50 then
        tdLog.info('tdSql.checkRow(50)')
        tdSql.checkRows(50)
        # TSIM: return -1
130
        # TSIM: endi
L
liuyq-617 已提交
131 132 133
        # TSIM: sql select * from $mt where ts > 1605045600000 + 240001
        tdLog.info('select * from %s where ts > 1605045600000 + 240001' % (mt))
        tdSql.query('select * from %s where ts > 1605045600000 + 240001' % (mt))
S
Shuduo Sang 已提交
134 135 136 137
        # TSIM: if $rows != 150 then
        tdLog.info('tdSql.checkRow(150)')
        tdSql.checkRows(150)
        # TSIM: return -1
138
        # TSIM: endi
L
liuyq-617 已提交
139 140 141
        # TSIM: sql select * from $mt where ts = 1605045600000 + 240001
        tdLog.info('select * from %s where ts = 1605045600000 + 240001' % (mt))
        tdSql.query('select * from %s where ts = 1605045600000 + 240001' % (mt))
S
Shuduo Sang 已提交
142 143 144 145
        # TSIM: if $rows != 0 then
        tdLog.info('tdSql.checkRow(0)')
        tdSql.checkRows(0)
        # TSIM: return -1
146
        # TSIM: endi
L
liuyq-617 已提交
147
        # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001
S
Shuduo Sang 已提交
148
        tdLog.info(
L
liuyq-617 已提交
149
            'select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001' %
S
Shuduo Sang 已提交
150 151
            (mt))
        tdSql.query(
L
liuyq-617 已提交
152
            'select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001' %
S
Shuduo Sang 已提交
153 154 155 156 157
            (mt))
        # TSIM: if $rows != 10 then
        tdLog.info('tdSql.checkRow(10)')
        tdSql.checkRows(10)
        # TSIM: return -1
158
        # TSIM: endi
S
Shuduo Sang 已提交
159 160 161 162 163 164 165 166 167 168
        # TSIM:
        # TSIM: print =============== step3
        tdLog.info('=============== step3')
        # TSIM: sql select * from $mt where tgcol = 0
        tdLog.info('select * from %s where tgcol = 0' % (mt))
        tdSql.query('select * from %s where tgcol = 0' % (mt))
        # TSIM: if $rows != 100 then
        tdLog.info('tdSql.checkRow(100)')
        tdSql.checkRows(100)
        # TSIM: return -1
169
        # TSIM: endi
S
Shuduo Sang 已提交
170 171 172 173 174 175 176
        # TSIM: sql select * from $mt where tgcol <> 0
        tdLog.info('select * from %s where tgcol <> 0' % (mt))
        tdSql.query('select * from %s where tgcol <> 0' % (mt))
        # TSIM: if $rows != 100 then
        tdLog.info('tdSql.checkRow(100)')
        tdSql.checkRows(100)
        # TSIM: return -1
177
        # TSIM: endi
S
Shuduo Sang 已提交
178 179 180 181 182 183 184
        # TSIM: sql select * from $mt where tgcol = 1
        tdLog.info('select * from %s where tgcol = 1' % (mt))
        tdSql.query('select * from %s where tgcol = 1' % (mt))
        # TSIM: if $rows != 100 then
        tdLog.info('tdSql.checkRow(100)')
        tdSql.checkRows(100)
        # TSIM: return -1
185
        # TSIM: endi
S
Shuduo Sang 已提交
186 187 188 189 190 191 192
        # TSIM: sql select * from $mt where tgcol <> 1
        tdLog.info('select * from %s where tgcol <> 1' % (mt))
        tdSql.query('select * from %s where tgcol <> 1' % (mt))
        # TSIM: if $rows != 100 then
        tdLog.info('tdSql.checkRow(100)')
        tdSql.checkRows(100)
        # TSIM: return -1
193
        # TSIM: endi
S
Shuduo Sang 已提交
194 195 196 197 198 199 200
        # TSIM: sql select * from $mt where tgcol = true
        tdLog.info('select * from %s where tgcol = true' % (mt))
        tdSql.query('select * from %s where tgcol = true' % (mt))
        # TSIM: if $rows != 100 then
        tdLog.info('tdSql.checkRow(100)')
        tdSql.checkRows(100)
        # TSIM: return -1
201
        # TSIM: endi
S
Shuduo Sang 已提交
202 203 204 205 206 207 208
        # TSIM: sql select * from $mt where tgcol <> true
        tdLog.info('select * from %s where tgcol <> true' % (mt))
        tdSql.query('select * from %s where tgcol <> true' % (mt))
        # TSIM: if $rows != 100 then
        tdLog.info('tdSql.checkRow(100)')
        tdSql.checkRows(100)
        # TSIM: return -1
209
        # TSIM: endi
S
Shuduo Sang 已提交
210 211 212 213 214 215 216
        # TSIM: sql select * from $mt where tgcol = false
        tdLog.info('select * from %s where tgcol = false' % (mt))
        tdSql.query('select * from %s where tgcol = false' % (mt))
        # TSIM: if $rows != 100 then
        tdLog.info('tdSql.checkRow(100)')
        tdSql.checkRows(100)
        # TSIM: return -1
217
        # TSIM: endi
S
Shuduo Sang 已提交
218 219 220 221 222 223 224
        # TSIM: sql select * from $mt where tgcol <> false
        tdLog.info('select * from %s where tgcol <> false' % (mt))
        tdSql.query('select * from %s where tgcol <> false' % (mt))
        # TSIM: if $rows != 100 then
        tdLog.info('tdSql.checkRow(100)')
        tdSql.checkRows(100)
        # TSIM: return -1
225
        # TSIM: endi
S
Shuduo Sang 已提交
226 227 228 229 230 231 232 233 234 235
        # TSIM:
        # TSIM: print =============== step4
        tdLog.info('=============== step4')
        # TSIM: sql select * from $mt where tgcol2 = '0'
        tdLog.info('select * from %s where tgcol2 = "0"' % (mt))
        tdSql.query('select * from %s where tgcol2 = "0"' % (mt))
        # TSIM: if $rows != 100 then
        tdLog.info('tdSql.checkRow(100)')
        tdSql.checkRows(100)
        # TSIM: return -1
236
        # TSIM: endi
S
Shuduo Sang 已提交
237 238 239 240 241 242 243
        # TSIM: sql select * from $mt where tgcol2 <> '0'
        tdLog.info('select * from %s where tgcol2 <> "0"' % (mt))
        tdSql.query('select * from %s where tgcol2 <> "0"' % (mt))
        # TSIM: if $rows != 100 then
        tdLog.info('tdSql.checkRow(100)')
        tdSql.checkRows(100)
        # TSIM: return -1
244
        # TSIM: endi
S
Shuduo Sang 已提交
245 246 247 248 249 250 251
        # TSIM: sql select * from $mt where tgcol2 = '1'
        tdLog.info('select * from %s where tgcol2 = "1"' % (mt))
        tdSql.query('select * from %s where tgcol2 = "1"' % (mt))
        # TSIM: if $rows != 100 then
        tdLog.info('tdSql.checkRow(100)')
        tdSql.checkRows(100)
        # TSIM: return -1
252
        # TSIM: endi
S
Shuduo Sang 已提交
253 254 255 256 257 258 259
        # TSIM: sql select * from $mt where tgcol2 <> "1"
        tdLog.info('select * from %s where tgcol2 <> "1"' % (mt))
        tdSql.query('select * from %s where tgcol2 <> "1"' % (mt))
        # TSIM: if $rows != 100 then
        tdLog.info('tdSql.checkRow(100)')
        tdSql.checkRows(100)
        # TSIM: return -1
260
        # TSIM: endi
S
Shuduo Sang 已提交
261 262 263
        # TSIM:
        # TSIM: print =============== step5
        tdLog.info('=============== step5')
L
liuyq-617 已提交
264
        # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and tgcol = true
S
Shuduo Sang 已提交
265
        tdLog.info(
L
liuyq-617 已提交
266
            'select * from %s where ts > 1605045600000 + 240001 and tgcol = true' %
S
Shuduo Sang 已提交
267 268
            (mt))
        tdSql.query(
L
liuyq-617 已提交
269
            'select * from %s where ts > 1605045600000 + 240001 and tgcol = true' %
S
Shuduo Sang 已提交
270 271 272 273 274
            (mt))
        # TSIM: if $rows != 75 then
        tdLog.info('tdSql.checkRow(75)')
        tdSql.checkRows(75)
        # TSIM: return -1
275
        # TSIM: endi
L
liuyq-617 已提交
276
        # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and tgcol <> true
S
Shuduo Sang 已提交
277
        tdLog.info(
L
liuyq-617 已提交
278
            'select * from %s where ts > 1605045600000 + 240001 and tgcol <> true' %
S
Shuduo Sang 已提交
279 280
            (mt))
        tdSql.query(
L
liuyq-617 已提交
281
            'select * from %s where ts > 1605045600000 + 240001 and tgcol <> true' %
S
Shuduo Sang 已提交
282 283 284 285 286
            (mt))
        # TSIM: if $rows != 75 then
        tdLog.info('tdSql.checkRow(75)')
        tdSql.checkRows(75)
        # TSIM: return -1
287
        # TSIM: endi
L
liuyq-617 已提交
288
        # TSIM: sql select * from $mt where ts < 1605045600000 + 240001 and tgcol = false
S
Shuduo Sang 已提交
289
        tdLog.info(
L
liuyq-617 已提交
290
            'select * from %s where ts < 1605045600000 + 240001 and tgcol = false' %
S
Shuduo Sang 已提交
291 292
            (mt))
        tdSql.query(
L
liuyq-617 已提交
293
            'select * from %s where ts < 1605045600000 + 240001 and tgcol = false' %
S
Shuduo Sang 已提交
294 295 296 297 298
            (mt))
        # TSIM: if $rows != 25 then
        tdLog.info('tdSql.checkRow(25)')
        tdSql.checkRows(25)
        # TSIM: return -1
299
        # TSIM: endi
L
liuyq-617 已提交
300
        # TSIM: sql select * from $mt where ts < 1605045600000 + 240001 and tgcol <> false
S
Shuduo Sang 已提交
301
        tdLog.info(
L
liuyq-617 已提交
302
            'select * from %s where ts < 1605045600000 + 240001 and tgcol <> false' %
S
Shuduo Sang 已提交
303 304
            (mt))
        tdSql.query(
L
liuyq-617 已提交
305
            'select * from %s where ts < 1605045600000 + 240001 and tgcol <> false' %
S
Shuduo Sang 已提交
306 307 308 309 310
            (mt))
        # TSIM: if $rows != 25 then
        tdLog.info('tdSql.checkRow(25)')
        tdSql.checkRows(25)
        # TSIM: return -1
311
        # TSIM: endi
L
liuyq-617 已提交
312
        # TSIM: sql select * from $mt where ts <= 1605045600000 + 240001 and tgcol = false
S
Shuduo Sang 已提交
313
        tdLog.info(
L
liuyq-617 已提交
314
            'select * from %s where ts <= 1605045600000 + 240001 and tgcol = false' %
S
Shuduo Sang 已提交
315 316
            (mt))
        tdSql.query(
L
liuyq-617 已提交
317
            'select * from %s where ts <= 1605045600000 + 240001 and tgcol = false' %
S
Shuduo Sang 已提交
318 319 320 321 322
            (mt))
        # TSIM: if $rows != 25 then
        tdLog.info('tdSql.checkRow(25)')
        tdSql.checkRows(25)
        # TSIM: return -1
323
        # TSIM: endi
L
liuyq-617 已提交
324
        # TSIM: sql select * from $mt where ts <= 1605045600000 + 240001 and tgcol <> false
S
Shuduo Sang 已提交
325
        tdLog.info(
L
liuyq-617 已提交
326
            'select * from %s where ts <= 1605045600000 + 240001 and tgcol <> false' %
S
Shuduo Sang 已提交
327 328
            (mt))
        tdSql.query(
L
liuyq-617 已提交
329
            'select * from %s where ts <= 1605045600000 + 240001 and tgcol <> false' %
S
Shuduo Sang 已提交
330 331 332 333 334
            (mt))
        # TSIM: if $rows != 25 then
        tdLog.info('tdSql.checkRow(25)')
        tdSql.checkRows(25)
        # TSIM: return -1
335
        # TSIM: endi
L
liuyq-617 已提交
336
        # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 and
S
Shuduo Sang 已提交
337 338
        # tgcol <> false
        tdLog.info(
L
liuyq-617 已提交
339
            'select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 and tgcol <> false' %
S
Shuduo Sang 已提交
340 341
            (mt))
        tdSql.query(
L
liuyq-617 已提交
342
            'select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 and tgcol <> false' %
S
Shuduo Sang 已提交
343 344 345 346 347
            (mt))
        # TSIM: if $rows != 5 then
        tdLog.info('tdSql.checkRow(5)')
        tdSql.checkRows(5)
        # TSIM: return -1
348
        # TSIM: endi
L
liuyq-617 已提交
349 350
        # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and tgcol <> false
        # and ts < 1605045600000 + 300001
S
Shuduo Sang 已提交
351
        tdLog.info(
L
liuyq-617 已提交
352
            'select * from %s where ts > 1605045600000 + 240001 and tgcol <> false and ts < 1605045600000 + 300001' %
S
Shuduo Sang 已提交
353 354
            (mt))
        tdSql.query(
L
liuyq-617 已提交
355
            'select * from %s where ts > 1605045600000 + 240001 and tgcol <> false and ts < 1605045600000 + 300001' %
S
Shuduo Sang 已提交
356 357 358 359 360
            (mt))
        # TSIM: if $rows != 5 then
        tdLog.info('tdSql.checkRow(5)')
        tdSql.checkRows(5)
        # TSIM: return -1
361
        # TSIM: endi
S
Shuduo Sang 已提交
362 363 364
        # TSIM:
        # TSIM: print =============== step6
        tdLog.info('=============== step6')
L
liuyq-617 已提交
365
        # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and tgcol2 = '1'
S
Shuduo Sang 已提交
366
        tdLog.info(
L
liuyq-617 已提交
367
            'select * from %s where ts > 1605045600000 + 240001 and tgcol2 = "1"' %
S
Shuduo Sang 已提交
368 369
            (mt))
        tdSql.query(
L
liuyq-617 已提交
370
            'select * from %s where ts > 1605045600000 + 240001 and tgcol2 = "1"' %
S
Shuduo Sang 已提交
371 372 373 374 375
            (mt))
        # TSIM: if $rows != 75 then
        tdLog.info('tdSql.checkRow(75)')
        tdSql.checkRows(75)
        # TSIM: return -1
376
        # TSIM: endi
L
liuyq-617 已提交
377
        # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and tgcol2 <> '1'
S
Shuduo Sang 已提交
378
        tdLog.info(
L
liuyq-617 已提交
379
            'select * from %s where ts > 1605045600000 + 240001 and tgcol2 <> "1"' %
S
Shuduo Sang 已提交
380 381
            (mt))
        tdSql.query(
L
liuyq-617 已提交
382
            'select * from %s where ts > 1605045600000 + 240001 and tgcol2 <> "1"' %
S
Shuduo Sang 已提交
383 384 385 386 387
            (mt))
        # TSIM: if $rows != 75 then
        tdLog.info('tdSql.checkRow(75)')
        tdSql.checkRows(75)
        # TSIM: return -1
388
        # TSIM: endi
L
liuyq-617 已提交
389
        # TSIM: sql select * from $mt where ts < 1605045600000 + 240001 and tgcol2 = '0'
S
Shuduo Sang 已提交
390
        tdLog.info(
L
liuyq-617 已提交
391
            'select * from %s where ts < 1605045600000 + 240001 and tgcol2 = "0"' %
S
Shuduo Sang 已提交
392 393
            (mt))
        tdSql.query(
L
liuyq-617 已提交
394
            'select * from %s where ts < 1605045600000 + 240001 and tgcol2 = "0"' %
S
Shuduo Sang 已提交
395 396 397 398 399
            (mt))
        # TSIM: if $rows != 25 then
        tdLog.info('tdSql.checkRow(25)')
        tdSql.checkRows(25)
        # TSIM: return -1
400
        # TSIM: endi
L
liuyq-617 已提交
401
        # TSIM: sql select * from $mt where ts < 1605045600000 + 240001 and tgcol2 <> '0'
S
Shuduo Sang 已提交
402
        tdLog.info(
L
liuyq-617 已提交
403
            'select * from %s where ts < 1605045600000 + 240001 and tgcol2 <> "0"' %
S
Shuduo Sang 已提交
404 405
            (mt))
        tdSql.query(
L
liuyq-617 已提交
406
            'select * from %s where ts < 1605045600000 + 240001 and tgcol2 <> "0"' %
S
Shuduo Sang 已提交
407 408 409 410 411
            (mt))
        # TSIM: if $rows != 25 then
        tdLog.info('tdSql.checkRow(25)')
        tdSql.checkRows(25)
        # TSIM: return -1
412
        # TSIM: endi
L
liuyq-617 已提交
413
        # TSIM: sql select * from $mt where ts <= 1605045600000 + 240001 and tgcol2 = '0'
S
Shuduo Sang 已提交
414
        tdLog.info(
L
liuyq-617 已提交
415
            'select * from %s where ts <= 1605045600000 + 240001 and tgcol2 = "0"' %
S
Shuduo Sang 已提交
416 417
            (mt))
        tdSql.query(
L
liuyq-617 已提交
418
            'select * from %s where ts <= 1605045600000 + 240001 and tgcol2 = "0"' %
S
Shuduo Sang 已提交
419 420 421 422 423
            (mt))
        # TSIM: if $rows != 25 then
        tdLog.info('tdSql.checkRow(25)')
        tdSql.checkRows(25)
        # TSIM: return -1
424
        # TSIM: endi
L
liuyq-617 已提交
425
        # TSIM: sql select * from $mt where ts <= 1605045600000 + 240001 and tgcol2 <> '0'
S
Shuduo Sang 已提交
426
        tdLog.info(
L
liuyq-617 已提交
427
            'select * from %s where ts <= 1605045600000 + 240001 and tgcol2 <> "0"' %
S
Shuduo Sang 已提交
428 429
            (mt))
        tdSql.query(
L
liuyq-617 已提交
430
            'select * from %s where ts <= 1605045600000 + 240001 and tgcol2 <> "0"' %
S
Shuduo Sang 已提交
431 432 433 434 435
            (mt))
        # TSIM: if $rows != 25 then
        tdLog.info('tdSql.checkRow(25)')
        tdSql.checkRows(25)
        # TSIM: return -1
436
        # TSIM: endi
L
liuyq-617 已提交
437
        # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 and
S
Shuduo Sang 已提交
438 439
        # tgcol2 <> '0'
        tdLog.info(
L
liuyq-617 已提交
440
            'select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 and tgcol2 <> "0"' %
S
Shuduo Sang 已提交
441 442
            (mt))
        tdSql.query(
L
liuyq-617 已提交
443
            'select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 and tgcol2 <> "0"' %
S
Shuduo Sang 已提交
444 445 446 447 448
            (mt))
        # TSIM: if $rows != 5 then
        tdLog.info('tdSql.checkRow(5)')
        tdSql.checkRows(5)
        # TSIM: return -1
449
        # TSIM: endi
L
liuyq-617 已提交
450 451
        # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and tgcol2 <> '0' and
        # ts < 1605045600000 + 300001
S
Shuduo Sang 已提交
452
        tdLog.info(
L
liuyq-617 已提交
453
            'select * from %s where ts > 1605045600000 + 240001 and tgcol2 <> "0" and ts < 1605045600000 + 300001' %
S
Shuduo Sang 已提交
454 455
            (mt))
        tdSql.query(
L
liuyq-617 已提交
456
            'select * from %s where ts > 1605045600000 + 240001 and tgcol2 <> "0" and ts < 1605045600000 + 300001' %
S
Shuduo Sang 已提交
457 458 459 460 461
            (mt))
        # TSIM: if $rows != 5 then
        tdLog.info('tdSql.checkRow(5)')
        tdSql.checkRows(5)
        # TSIM: return -1
462
        # TSIM: endi
S
Shuduo Sang 已提交
463 464 465
        # TSIM:
        # TSIM: print =============== step7
        tdLog.info('=============== step7')
L
liuyq-617 已提交
466
        # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and tgcol2 = '1' and
S
Shuduo Sang 已提交
467 468
        # tgcol = true
        tdLog.info(
L
liuyq-617 已提交
469
            'select * from %s where ts > 1605045600000 + 240001 and tgcol2 = "1" and tgcol = true' %
S
Shuduo Sang 已提交
470 471
            (mt))
        tdSql.query(
L
liuyq-617 已提交
472
            'select * from %s where ts > 1605045600000 + 240001 and tgcol2 = "1" and tgcol = true' %
S
Shuduo Sang 已提交
473 474 475 476 477
            (mt))
        # TSIM: if $rows != 75 then
        tdLog.info('tdSql.checkRow(75)')
        tdSql.checkRows(75)
        # TSIM: return -1
478
        # TSIM: endi
L
liuyq-617 已提交
479
        # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and tgcol2 <> '1' and
S
Shuduo Sang 已提交
480 481
        # tgcol <> true
        tdLog.info(
L
liuyq-617 已提交
482
            'select * from %s where ts > 1605045600000 + 240001 and tgcol2 <> "1" and tgcol <> true' %
S
Shuduo Sang 已提交
483 484
            (mt))
        tdSql.query(
L
liuyq-617 已提交
485
            'select * from %s where ts > 1605045600000 + 240001 and tgcol2 <> "1" and tgcol <> true' %
S
Shuduo Sang 已提交
486 487 488 489 490
            (mt))
        # TSIM: if $rows != 75 then
        tdLog.info('tdSql.checkRow(75)')
        tdSql.checkRows(75)
        # TSIM: return -1
491
        # TSIM: endi
L
liuyq-617 已提交
492
        # TSIM: sql select * from $mt where ts < 1605045600000 + 240001 and tgcol2 = '0' and
S
Shuduo Sang 已提交
493 494
        # tgcol = false
        tdLog.info(
L
liuyq-617 已提交
495
            'select * from %s where ts < 1605045600000 + 240001 and tgcol2 = "0" and tgcol = false' %
S
Shuduo Sang 已提交
496 497
            (mt))
        tdSql.query(
L
liuyq-617 已提交
498
            'select * from %s where ts < 1605045600000 + 240001 and tgcol2 = "0" and tgcol = false' %
S
Shuduo Sang 已提交
499 500 501 502 503
            (mt))
        # TSIM: if $rows != 25 then
        tdLog.info('tdSql.checkRow(25)')
        tdSql.checkRows(25)
        # TSIM: return -1
504
        # TSIM: endi
L
liuyq-617 已提交
505
        # TSIM: sql select * from $mt where ts < 1605045600000 + 240001 and tgcol2 <> '0' and
S
Shuduo Sang 已提交
506 507
        # tgcol <> false
        tdLog.info(
L
liuyq-617 已提交
508
            'select * from %s where ts < 1605045600000 + 240001 and tgcol2 <> "0" and tgcol <> false' %
S
Shuduo Sang 已提交
509 510
            (mt))
        tdSql.query(
L
liuyq-617 已提交
511
            'select * from %s where ts < 1605045600000 + 240001 and tgcol2 <> "0" and tgcol <> false' %
S
Shuduo Sang 已提交
512 513 514 515 516
            (mt))
        # TSIM: if $rows != 25 then
        tdLog.info('tdSql.checkRow(25)')
        tdSql.checkRows(25)
        # TSIM: return -1
517
        # TSIM: endi
L
liuyq-617 已提交
518
        # TSIM: sql select * from $mt where ts <= 1605045600000 + 240001 and tgcol2 = '0' and
S
Shuduo Sang 已提交
519 520
        # tgcol = false
        tdLog.info(
L
liuyq-617 已提交
521
            'select * from %s where ts <= 1605045600000 + 240001 and tgcol2 = "0" and tgcol = false' %
S
Shuduo Sang 已提交
522 523
            (mt))
        tdSql.query(
L
liuyq-617 已提交
524
            'select * from %s where ts <= 1605045600000 + 240001 and tgcol2 = "0" and tgcol = false' %
S
Shuduo Sang 已提交
525 526 527 528 529
            (mt))
        # TSIM: if $rows != 25 then
        tdLog.info('tdSql.checkRow(25)')
        tdSql.checkRows(25)
        # TSIM: return -1
530
        # TSIM: endi
L
liuyq-617 已提交
531
        # TSIM: sql select * from $mt where ts <= 1605045600000 + 240001 and tgcol2 <> '0'
S
Shuduo Sang 已提交
532 533
        # and tgcol <> false
        tdLog.info(
L
liuyq-617 已提交
534
            'select * from %s where ts <= 1605045600000 + 240001 and tgcol2 <> "0" and tgcol <> false' %
S
Shuduo Sang 已提交
535 536
            (mt))
        tdSql.query(
L
liuyq-617 已提交
537
            'select * from %s where ts <= 1605045600000 + 240001 and tgcol2 <> "0" and tgcol <> false' %
S
Shuduo Sang 已提交
538 539 540 541 542
            (mt))
        # TSIM: if $rows != 25 then
        tdLog.info('tdSql.checkRow(25)')
        tdSql.checkRows(25)
        # TSIM: return -1
543
        # TSIM: endi
L
liuyq-617 已提交
544
        # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 and
S
Shuduo Sang 已提交
545 546
        # tgcol2 <> '0' and tgcol <> false
        tdLog.info(
L
liuyq-617 已提交
547
            'select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 and tgcol2 <> "0" and tgcol <> false' %
S
Shuduo Sang 已提交
548 549
            (mt))
        tdSql.query(
L
liuyq-617 已提交
550
            'select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 and tgcol2 <> "0" and tgcol <> false' %
S
Shuduo Sang 已提交
551 552 553 554 555
            (mt))
        # TSIM: if $rows != 5 then
        tdLog.info('tdSql.checkRow(5)')
        tdSql.checkRows(5)
        # TSIM: return -1
556
        # TSIM: endi
L
liuyq-617 已提交
557 558
        # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and tgcol2 <> '0' and
        # ts < 1605045600000 + 300001 and ts < 1605045600000 + 300001 and tgcol <> false
S
Shuduo Sang 已提交
559
        tdLog.info(
L
liuyq-617 已提交
560
            'select * from %s where ts > 1605045600000 + 240001 and tgcol2 <> "0" and ts < 1605045600000 + 300001 and ts < 1605045600000 + 300001 and tgcol <> false' %
S
Shuduo Sang 已提交
561 562
            (mt))
        tdSql.query(
L
liuyq-617 已提交
563
            'select * from %s where ts > 1605045600000 + 240001 and tgcol2 <> "0" and ts < 1605045600000 + 300001 and ts < 1605045600000 + 300001 and tgcol <> false' %
S
Shuduo Sang 已提交
564 565 566 567 568
            (mt))
        # TSIM: if $rows != 5 then
        tdLog.info('tdSql.checkRow(5)')
        tdSql.checkRows(5)
        # TSIM: return -1
569
        # TSIM: endi
S
Shuduo Sang 已提交
570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586
        # TSIM:
        # TSIM: print =============== step8
        tdLog.info('=============== step8')
        # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol),
        # max(tbcol), first(tbcol), last(tbcol) from $mt
        tdLog.info(
            'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s' %
            (mt))
        tdSql.query(
            'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s' %
            (mt))
        # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06
        tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06')
        # TSIM: if $data00 != 200 then
        tdLog.info('tdSql.checkData(0, 0, 200)')
        tdSql.checkData(0, 0, 200)
        # TSIM: return -1
587
        # TSIM: endi
S
Shuduo Sang 已提交
588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604
        # TSIM:
        # TSIM: print =============== step9
        tdLog.info('=============== step9')
        # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol),
        # max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = true
        tdLog.info(
            'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol = true' %
            (mt))
        tdSql.query(
            'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol = true' %
            (mt))
        # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06
        tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06')
        # TSIM: if $data00 != 100 then
        tdLog.info('tdSql.checkData(0, 0, 100)')
        tdSql.checkData(0, 0, 100)
        # TSIM: return -1
605
        # TSIM: endi
S
Shuduo Sang 已提交
606 607 608 609 610 611 612 613 614 615 616 617 618 619 620
        # TSIM:
        # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol),
        # max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol2 = '1'
        tdLog.info(
            'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol2 = "1"' %
            (mt))
        tdSql.query(
            'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol2 = "1"' %
            (mt))
        # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06
        tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06')
        # TSIM: if $data00 != 100 then
        tdLog.info('tdSql.checkData(0, 0, 100)')
        tdSql.checkData(0, 0, 100)
        # TSIM: return -1
621
        # TSIM: endi
S
Shuduo Sang 已提交
622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637
        # TSIM:
        # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol),
        # max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = true and
        # tgcol2 = '1'
        tdLog.info(
            'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol = true and tgcol2 = "1"' %
            (mt))
        tdSql.query(
            'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol = true and tgcol2 = "1"' %
            (mt))
        # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06
        tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06')
        # TSIM: if $data00 != 100 then
        tdLog.info('tdSql.checkData(0, 0, 100)')
        tdSql.checkData(0, 0, 100)
        # TSIM: return -1
638
        # TSIM: endi
S
Shuduo Sang 已提交
639 640 641 642
        # TSIM:
        # TSIM: print =============== step10
        tdLog.info('=============== step10')
        # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol),
L
liuyq-617 已提交
643
        # max(tbcol), first(tbcol), last(tbcol) from $mt where ts < 1605045600000 + 240001
S
Shuduo Sang 已提交
644
        tdLog.info(
L
liuyq-617 已提交
645
            'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < 1605045600000 + 240001' %
S
Shuduo Sang 已提交
646 647
            (mt))
        tdSql.query(
L
liuyq-617 已提交
648
            'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < 1605045600000 + 240001' %
S
Shuduo Sang 已提交
649 650 651 652 653 654 655
            (mt))
        # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06
        tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06')
        # TSIM: if $data00 != 50 then
        tdLog.info('tdSql.checkData(0, 0, 50)')
        tdSql.checkData(0, 0, 50)
        # TSIM: return -1
656
        # TSIM: endi
S
Shuduo Sang 已提交
657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673
        # TSIM:
        # TSIM: print =============== step11
        tdLog.info('=============== step11')
        # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol),
        # max(tbcol), first(tbcol), last(tbcol) from $mt group by tgcol
        tdLog.info(
            'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s group by tgcol' %
            (mt))
        tdSql.query(
            'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s group by tgcol' %
            (mt))
        # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06
        tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06')
        # TSIM: if $data00 != 100 then
        tdLog.info('tdSql.checkData(0, 0, 100)')
        tdSql.checkData(0, 0, 100)
        # TSIM: return -1
674
        # TSIM: endi
S
Shuduo Sang 已提交
675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692
        # TSIM:
        # TSIM: print =============== step12
        tdLog.info('=============== step12')
        # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol),
        # max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = true
        # group by tgcol
        tdLog.info(
            'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol = true group by tgcol' %
            (mt))
        tdSql.query(
            'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol = true group by tgcol' %
            (mt))
        # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06
        tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06')
        # TSIM: if $data00 != 100 then
        tdLog.info('tdSql.checkData(0, 0, 100)')
        tdSql.checkData(0, 0, 100)
        # TSIM: return -1
693
        # TSIM: endi
S
Shuduo Sang 已提交
694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709
        # TSIM:
        # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol),
        # max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol2 = '1'
        # group by tgcol
        tdLog.info(
            'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol2 = "1" group by tgcol' %
            (mt))
        tdSql.query(
            'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol2 = "1" group by tgcol' %
            (mt))
        # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06
        tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06')
        # TSIM: if $data00 != 100 then
        tdLog.info('tdSql.checkData(0, 0, 100)')
        tdSql.checkData(0, 0, 100)
        # TSIM: return -1
710
        # TSIM: endi
S
Shuduo Sang 已提交
711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726
        # TSIM:
        # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol),
        # max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = true and
        # tgcol2 = '1' group by tgcol
        tdLog.info(
            'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol = true and tgcol2 = "1" group by tgcol' %
            (mt))
        tdSql.query(
            'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol = true and tgcol2 = "1" group by tgcol' %
            (mt))
        # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06
        tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06')
        # TSIM: if $data00 != 100 then
        tdLog.info('tdSql.checkData(0, 0, 100)')
        tdSql.checkData(0, 0, 100)
        # TSIM: return -1
727
        # TSIM: endi
S
Shuduo Sang 已提交
728 729 730 731 732
        # TSIM:
        # TSIM:
        # TSIM: print =============== step13
        tdLog.info('=============== step13')
        # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol),
L
liuyq-617 已提交
733
        # max(tbcol), first(tbcol), last(tbcol) from $mt where ts < 1605045600000 + 240001
S
Shuduo Sang 已提交
734 735
        # group by tgcol
        tdLog.info(
L
liuyq-617 已提交
736
            'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < 1605045600000 + 240001 group by tgcol' %
S
Shuduo Sang 已提交
737 738
            (mt))
        tdSql.query(
L
liuyq-617 已提交
739
            'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < 1605045600000 + 240001 group by tgcol' %
S
Shuduo Sang 已提交
740 741 742 743 744 745 746
            (mt))
        # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06
        tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06')
        # TSIM: if $data00 != 25 then
        tdLog.info('tdSql.checkData(0, 0, 25)')
        tdSql.checkData(0, 0, 25)
        # TSIM: return -1
747
        # TSIM: endi
S
Shuduo Sang 已提交
748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765
        # TSIM:
        # TSIM: print =============== step14
        tdLog.info('=============== step14')
        # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol),
        # max(tbcol), first(tbcol), last(tbcol) from $mt interval(1d) group by
        # tgcol
        tdLog.info(
            'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s interval(1d) group by tgcol' %
            (mt))
        tdSql.query(
            'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s interval(1d) group by tgcol' %
            (mt))
        # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06
        tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06')
        # TSIM: if $data01 != 100 then
        tdLog.info('tdSql.checkData(0, 1, 100)')
        tdSql.checkData(0, 1, 100)
        # TSIM: return -1
766
        # TSIM: endi
S
Shuduo Sang 已提交
767 768 769 770 771 772 773 774 775 776 777 778 779
        # TSIM:
        # TSIM: print =============== clear
        tdLog.info('=============== clear')
        # TSIM: sql drop database $db
        tdLog.info('drop database db')
        tdSql.execute('drop database db')
        # TSIM: sql show databases
        tdLog.info('show databases')
        tdSql.query('show databases')
        # TSIM: if $rows != 0 then
        tdLog.info('tdSql.checkRow(0)')
        tdSql.checkRows(0)
        # TSIM: return -1
780
        # TSIM: endi
S
Shuduo Sang 已提交
781 782 783 784 785 786 787 788 789 790 791
        # TSIM:
        # TSIM: system sh/exec.sh -n dnode1 -s stop -x SIGINT
# convert end

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


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