in_function.py 34.5 KB
Newer Older
H
happyguoxy 已提交
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 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 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 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 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 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 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 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 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 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 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623
###################################################################
#           Copyright (c) 2016 by TAOS Technologies, Inc.
#                     All rights reserved.
#
#  This file is proprietary and confidential to TAOS Technologies.
#  No part of this file may be reproduced, stored, transmitted,
#  disclosed or used in any form or by any means other than as
#  expressly provided by the written permission from Jianhui Tao
#
###################################################################

# -*- coding: utf-8 -*-

import sys
import datetime

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


class TDTestCase:
    def init(self, conn, logSql):
        tdLog.debug("start to execute %s" % __file__)
        tdSql.init(conn.cursor(), logSql)

    def run(self):
        tdSql.prepare()
        # test case for https://jira.taosdata.com:18080/browse/TD-4568

        tdLog.info("=============== step1,check bool and tinyint data type")    

        tdLog.info("=============== step1.1,drop table && create table")    
        cmd1 = 'drop table if exists in_bool_tinyint_1 ;'
        cmd2 = 'drop table if exists in_bool_tinyint_2 ;'
        cmd3 = 'drop table if exists in_bool_tinyint_3 ;'
        cmd10 = 'drop table if exists in_stable_1 ;'
        cmd11 = 'create stable in_stable_1(ts timestamp,in_bool bool,in_tinyint tinyint) tags (tin_bool bool,tin_tinyint tinyint) ;'
        cmd12 = 'create table in_bool_tinyint_1 using in_stable_1 tags(\'true\',\'127\') ; '
        cmd13 = 'create table in_bool_tinyint_2 using in_stable_1 tags(\'false\',\'-127\') ; '
        cmd14 = 'create table in_bool_tinyint_3 using in_stable_1 tags(\'false\',\'0\') ; '
        tdLog.info(cmd1)
        tdSql.execute(cmd1)
        tdLog.info(cmd2)
        tdSql.execute(cmd2)
        tdLog.info(cmd3)
        tdSql.execute(cmd3)
        tdLog.info(cmd10)
        tdSql.execute(cmd10)        
        tdLog.info(cmd11)
        tdSql.execute(cmd11)
        tdLog.info(cmd12)
        tdSql.execute(cmd12)
        tdLog.info(cmd13)
        tdSql.execute(cmd13)
        tdLog.info(cmd14)
        tdSql.execute(cmd14)        

        tdLog.info("=============== step1.2,insert stable right data and check in function") 
        cmd1 = 'insert into in_bool_tinyint_1 values(now,\'true\',\'-127\') ;'
        tdLog.info(cmd1)
        tdSql.execute(cmd1)         
        tdSql.query('select * from in_stable_1 where in_bool in (true) order by ts desc')
        tdSql.checkData(0,1,'True') 
        tdSql.checkData(0,2,'-127')
        tdSql.checkData(0,3,'True') 
        tdSql.checkData(0,4,'127')  
        tdSql.query('select * from in_stable_1 where in_tinyint in (-127) order by ts desc')
        tdSql.checkData(0,1,'True') 
        tdSql.checkData(0,2,'-127')
        tdSql.checkData(0,3,'True') 
        tdSql.checkData(0,4,'127')     
        tdSql.query('select * from in_stable_1 where tin_bool in (true) order by ts desc')
        tdSql.checkData(0,1,'True') 
        tdSql.checkData(0,2,'-127')
        tdSql.checkData(0,3,'True') 
        tdSql.checkData(0,4,'127')  
        tdSql.query('select * from in_stable_1 where tin_tinyint in (127) order by ts desc')
        tdSql.checkData(0,1,'True') 
        tdSql.checkData(0,2,'-127')
        tdSql.checkData(0,3,'True') 
        tdSql.checkData(0,4,'127')  
        tdSql.query('select * from in_bool_tinyint_1 where in_bool in (true) order by ts desc')
        tdSql.checkData(0,1,'True') 
        tdSql.checkData(0,2,'-127')
        tdSql.query('select * from in_bool_tinyint_1 where in_tinyint in (-127) order by ts desc')
        tdSql.checkData(0,1,'True') 
        tdSql.checkData(0,2,'-127')                

        cmd2 = 'insert into in_bool_tinyint_2 values(now,\'false\',\'127\') ;'
        tdLog.info(cmd2)
        tdSql.execute(cmd2)         
        tdSql.query('select * from in_stable_1 where in_bool in (false) order by ts desc')
        tdSql.checkData(0,1,'False') 
        tdSql.checkData(0,2,'127')
        tdSql.checkData(0,3,'False') 
        tdSql.checkData(0,4,'-127') 
        tdSql.query('select * from in_stable_1 where in_tinyint in (127) order by ts desc')
        tdSql.checkData(0,1,'False') 
        tdSql.checkData(0,2,'127')
        tdSql.checkData(0,3,'False') 
        tdSql.checkData(0,4,'-127')   
        tdSql.query('select * from in_stable_1 where tin_bool in (false) order by ts desc')
        tdSql.checkData(0,1,'False') 
        tdSql.checkData(0,2,'127')
        tdSql.checkData(0,3,'False') 
        tdSql.checkData(0,4,'-127') 
        tdSql.query('select * from in_stable_1 where tin_tinyint in (-127) order by ts desc')
        tdSql.checkData(0,1,'False') 
        tdSql.checkData(0,2,'127')
        tdSql.checkData(0,3,'False') 
        tdSql.checkData(0,4,'-127') 
        tdSql.query('select * from in_bool_tinyint_2 where in_bool in (false) order by ts desc')
        tdSql.checkData(0,1,'False') 
        tdSql.checkData(0,2,'127')
        tdSql.query('select * from in_bool_tinyint_2 where in_tinyint in (127) order by ts desc')
        tdSql.checkData(0,1,'False') 
        tdSql.checkData(0,2,'127')         

        cmd3 = 'insert into in_bool_tinyint_3 values(now,\'true\',\'0\') ;'
        tdLog.info(cmd3)
        tdSql.execute(cmd3)         
        tdSql.query('select * from in_stable_1 where in_tinyint in (0) order by ts desc')
        tdSql.checkData(0,1,'True') 
        tdSql.checkData(0,2,'0')
        tdSql.checkData(0,3,'False') 
        tdSql.checkData(0,4,'0')  
        tdSql.query('select * from in_stable_1 where tin_tinyint in (0) order by ts desc')
        tdSql.checkData(0,1,'True') 
        tdSql.checkData(0,2,'0')
        tdSql.checkData(0,3,'False') 
        tdSql.checkData(0,4,'0')  
        tdSql.query('select * from in_bool_tinyint_3 where in_bool in (true) order by ts desc')
        tdSql.checkData(0,1,'True') 
        tdSql.checkData(0,2,'0')
        tdSql.query('select * from in_bool_tinyint_3 where in_tinyint in (0) order by ts desc')
        tdSql.checkData(0,1,'True') 
        tdSql.checkData(0,2,'0')


        tdLog.info("=============== step1.3,drop normal table && create table") 
        cmd1 = 'drop table if exists normal_in_bool_tinyint_1 ;'
        cmd2 = 'create table normal_in_bool_tinyint_1 (ts timestamp,in_bool bool,in_tinyint tinyint) ; '
        tdLog.info(cmd1)
        tdSql.execute(cmd1)
        tdLog.info(cmd2)
        tdSql.execute(cmd2)
      

        tdLog.info("=============== step1.4,insert normal table right data and check in function") 
        cmd1 = 'insert into normal_in_bool_tinyint_1 values(now,\'true\',\'-127\') ;'
        tdLog.info(cmd1)
        tdSql.execute(cmd1)         
        tdSql.query('select * from normal_in_bool_tinyint_1 where in_bool in (true) order by ts desc')
        tdSql.checkData(0,1,'True') 
        tdSql.checkData(0,2,'-127')         
        tdSql.query('select * from normal_in_bool_tinyint_1 where in_tinyint in (-127) order by ts desc')
        tdSql.checkData(0,1,'True') 
        tdSql.checkData(0,2,'-127')  

        cmd2 = 'insert into normal_in_bool_tinyint_1 values(now,\'false\',\'127\') ;'
        tdLog.info(cmd2)
        tdSql.execute(cmd2)         
        tdSql.query('select * from normal_in_bool_tinyint_1 where in_bool in (false) order by ts desc')
        tdSql.checkData(0,1,'False') 
        tdSql.checkData(0,2,'127') 
        tdSql.query('select * from normal_in_bool_tinyint_1 where in_tinyint in (127) order by ts desc')
        tdSql.checkData(0,1,'False') 
        tdSql.checkData(0,2,'127')        

        cmd3 = 'insert into normal_in_bool_tinyint_1 values(now,\'true\',\'0\') ;'
        tdLog.info(cmd3)
        tdSql.execute(cmd3)         
        tdSql.query('select * from normal_in_bool_tinyint_1 where in_tinyint in (0) order by ts desc')
        tdSql.checkData(0,1,'True') 
        tdSql.checkData(0,2,'0')


 
        tdLog.info("=============== step2,check int、smallint and bigint data type")  

        tdLog.info("=============== step2.1,drop table && create table")    
        cmd1 = 'drop table if exists in_int_smallint_bigint_1 ;'
        cmd2 = 'drop table if exists in_int_smallint_bigint_2 ;'
        cmd3 = 'drop table if exists in_int_smallint_bigint_3 ;'
        cmd10 = 'drop table if exists in_stable_2 ;'
        cmd11 = 'create stable in_stable_2(ts timestamp,in_int int,in_small smallint , in_big bigint) tags (tin_int int,tin_small smallint , tin_big bigint) ;'
        cmd12 = 'create table in_int_smallint_bigint_1 using in_stable_2 tags(\'2147483647\',\'-32767\',\'0\') ; '
        cmd13 = 'create table in_int_smallint_bigint_2 using in_stable_2 tags(\'-2147483647\',\'0\',\'9223372036854775807\') ; '
        cmd14 = 'create table in_int_smallint_bigint_3 using in_stable_2 tags(\'0\',\'32767\',\'-9223372036854775807\') ; '
        tdLog.info(cmd1)
        tdSql.execute(cmd1)
        tdLog.info(cmd2)
        tdSql.execute(cmd2)
        tdLog.info(cmd3)
        tdSql.execute(cmd3)
        tdLog.info(cmd10)
        tdSql.execute(cmd10)        
        tdLog.info(cmd11)
        tdSql.execute(cmd11)
        tdLog.info(cmd12)
        tdSql.execute(cmd12)
        tdLog.info(cmd13)
        tdSql.execute(cmd13)
        tdLog.info(cmd14)
        tdSql.execute(cmd14)        

        tdLog.info("=============== step2.2,insert stable right data and check in function") 
        cmd1 = 'insert into in_int_smallint_bigint_1 values(now,\'2147483647\',\'-32767\',\'0\') ;'
        tdLog.info(cmd1)
        tdSql.execute(cmd1)         
        tdSql.query('select * from in_stable_2 where in_int in (2147483647) order by ts desc')
        tdSql.checkData(0,1,'2147483647') 
        tdSql.checkData(0,2,'-32767')
        tdSql.checkData(0,3,'0') 
        tdSql.checkData(0,4,'2147483647')  
        tdSql.checkData(0,5,'-32767') 
        tdSql.checkData(0,6,'0')  
        tdSql.query('select * from in_stable_2 where in_small in (-32767) order by ts desc')
        tdSql.checkData(0,1,'2147483647') 
        tdSql.checkData(0,2,'-32767')
        tdSql.checkData(0,3,'0') 
        tdSql.checkData(0,4,'2147483647')  
        tdSql.checkData(0,5,'-32767') 
        tdSql.checkData(0,6,'0')    
        tdSql.query('select * from in_stable_2 where in_big in (0) order by ts desc')
        tdSql.checkData(0,1,'2147483647') 
        tdSql.checkData(0,2,'-32767')
        tdSql.checkData(0,3,'0') 
        tdSql.checkData(0,4,'2147483647')  
        tdSql.checkData(0,5,'-32767') 
        tdSql.checkData(0,6,'0')  
        tdSql.query('select * from in_stable_2 where tin_int in (2147483647) order by ts desc')
        tdSql.checkData(0,1,'2147483647') 
        tdSql.checkData(0,2,'-32767')
        tdSql.checkData(0,3,'0') 
        tdSql.checkData(0,4,'2147483647')  
        tdSql.checkData(0,5,'-32767') 
        tdSql.checkData(0,6,'0')  
        tdSql.query('select * from in_stable_2 where tin_small in (-32767) order by ts desc')
        tdSql.checkData(0,1,'2147483647') 
        tdSql.checkData(0,2,'-32767')
        tdSql.checkData(0,3,'0') 
        tdSql.checkData(0,4,'2147483647')  
        tdSql.checkData(0,5,'-32767') 
        tdSql.checkData(0,6,'0')    
        tdSql.query('select * from in_stable_2 where tin_big in (0) order by ts desc')
        tdSql.checkData(0,1,'2147483647') 
        tdSql.checkData(0,2,'-32767')
        tdSql.checkData(0,3,'0') 
        tdSql.checkData(0,4,'2147483647')  
        tdSql.checkData(0,5,'-32767') 
        tdSql.checkData(0,6,'0')     
        tdSql.query('select * from in_int_smallint_bigint_1 where in_int in (2147483647) order by ts desc')
        tdSql.checkData(0,1,'2147483647') 
        tdSql.checkData(0,2,'-32767')
        tdSql.checkData(0,3,'0') 
        tdSql.query('select * from in_int_smallint_bigint_1 where in_small in (-32767) order by ts desc')
        tdSql.checkData(0,1,'2147483647') 
        tdSql.checkData(0,2,'-32767')
        tdSql.checkData(0,3,'0')  
        tdSql.query('select * from in_int_smallint_bigint_1 where in_big in (0) order by ts desc')
        tdSql.checkData(0,1,'2147483647') 
        tdSql.checkData(0,2,'-32767')
        tdSql.checkData(0,3,'0')      

        cmd2 = 'insert into in_int_smallint_bigint_2 values(now,\'-2147483647\',\'0\',\'9223372036854775807\') ;'
        tdLog.info(cmd2)
        tdSql.execute(cmd2)         
        tdSql.query('select * from in_stable_2 where in_int in (-2147483647) order by ts desc')
        tdSql.checkData(0,1,'-2147483647') 
        tdSql.checkData(0,2,'0')
        tdSql.checkData(0,3,'9223372036854775807') 
        tdSql.checkData(0,4,'-2147483647')  
        tdSql.checkData(0,5,'0') 
        tdSql.checkData(0,6,'9223372036854775807')  
        tdSql.query('select * from in_stable_2 where in_small in (0) order by ts desc')
        tdSql.checkData(0,1,'-2147483647') 
        tdSql.checkData(0,2,'0')
        tdSql.checkData(0,3,'9223372036854775807') 
        tdSql.checkData(0,4,'-2147483647')  
        tdSql.checkData(0,5,'0') 
        tdSql.checkData(0,6,'9223372036854775807')     
        tdSql.query('select * from in_stable_2 where in_big in (9223372036854775807) order by ts desc')
        tdSql.checkData(0,1,'-2147483647') 
        tdSql.checkData(0,2,'0')
        tdSql.checkData(0,3,'9223372036854775807') 
        tdSql.checkData(0,4,'-2147483647')  
        tdSql.checkData(0,5,'0') 
        tdSql.checkData(0,6,'9223372036854775807')    
        tdSql.query('select * from in_stable_2 where tin_int in (-2147483647) order by ts desc')
        tdSql.checkData(0,1,'-2147483647') 
        tdSql.checkData(0,2,'0')
        tdSql.checkData(0,3,'9223372036854775807') 
        tdSql.checkData(0,4,'-2147483647')  
        tdSql.checkData(0,5,'0') 
        tdSql.checkData(0,6,'9223372036854775807') 
        tdSql.query('select * from in_stable_2 where tin_small in (0) order by ts desc')
        tdSql.checkData(0,1,'-2147483647') 
        tdSql.checkData(0,2,'0')
        tdSql.checkData(0,3,'9223372036854775807') 
        tdSql.checkData(0,4,'-2147483647')  
        tdSql.checkData(0,5,'0') 
        tdSql.checkData(0,6,'9223372036854775807')   
        tdSql.query('select * from in_stable_2 where tin_big in (9223372036854775807) order by ts desc')
        tdSql.checkData(0,1,'-2147483647') 
        tdSql.checkData(0,2,'0')
        tdSql.checkData(0,3,'9223372036854775807') 
        tdSql.checkData(0,4,'-2147483647')  
        tdSql.checkData(0,5,'0') 
        tdSql.checkData(0,6,'9223372036854775807')  
        tdSql.query('select * from in_int_smallint_bigint_2 where in_int in (-2147483647) order by ts desc')
        tdSql.checkData(0,1,'-2147483647') 
        tdSql.checkData(0,2,'0')
        tdSql.checkData(0,3,'9223372036854775807')  
        tdSql.query('select * from in_int_smallint_bigint_2 where in_small in (0) order by ts desc')
        tdSql.checkData(0,1,'-2147483647') 
        tdSql.checkData(0,2,'0')
        tdSql.checkData(0,3,'9223372036854775807')     
        tdSql.query('select * from in_int_smallint_bigint_2 where in_big in (9223372036854775807) order by ts desc')
        tdSql.checkData(0,1,'-2147483647') 
        tdSql.checkData(0,2,'0')
        tdSql.checkData(0,3,'9223372036854775807')             

        cmd3 = 'insert into in_int_smallint_bigint_3 values(now,\'0\',\'32767\',\'-9223372036854775807\') ;'
        tdLog.info(cmd3)
        tdSql.execute(cmd3)         
        tdSql.query('select * from in_stable_2 where in_int in (0) order by ts desc')
        tdSql.checkData(0,1,'0') 
        tdSql.checkData(0,2,'32767')
        tdSql.checkData(0,3,'-9223372036854775807') 
        tdSql.checkData(0,4,'0')  
        tdSql.checkData(0,5,'32767') 
        tdSql.checkData(0,6,'-9223372036854775807')  
        tdSql.query('select * from in_stable_2 where in_small in (32767) order by ts desc')
        tdSql.checkData(0,1,'0') 
        tdSql.checkData(0,2,'32767')
        tdSql.checkData(0,3,'-9223372036854775807') 
        tdSql.checkData(0,4,'0')  
        tdSql.checkData(0,5,'32767') 
        tdSql.checkData(0,6,'-9223372036854775807')    
        tdSql.query('select * from in_stable_2 where in_big in (-9223372036854775807) order by ts desc')
        tdSql.checkData(0,1,'0') 
        tdSql.checkData(0,2,'32767')
        tdSql.checkData(0,3,'-9223372036854775807') 
        tdSql.checkData(0,4,'0')  
        tdSql.checkData(0,5,'32767') 
        tdSql.checkData(0,6,'-9223372036854775807')    
        tdSql.query('select * from in_stable_2 where tin_int in (0) order by ts desc')
        tdSql.checkData(0,1,'0') 
        tdSql.checkData(0,2,'32767')
        tdSql.checkData(0,3,'-9223372036854775807') 
        tdSql.checkData(0,4,'0')  
        tdSql.checkData(0,5,'32767') 
        tdSql.checkData(0,6,'-9223372036854775807')  
        tdSql.query('select * from in_stable_2 where tin_small in (32767) order by ts desc')
        tdSql.checkData(0,1,'0') 
        tdSql.checkData(0,2,'32767')
        tdSql.checkData(0,3,'-9223372036854775807') 
        tdSql.checkData(0,4,'0')  
        tdSql.checkData(0,5,'32767') 
        tdSql.checkData(0,6,'-9223372036854775807')    
        tdSql.query('select * from in_stable_2 where tin_big in (-9223372036854775807) order by ts desc')
        tdSql.checkData(0,1,'0') 
        tdSql.checkData(0,2,'32767')
        tdSql.checkData(0,3,'-9223372036854775807') 
        tdSql.checkData(0,4,'0')  
        tdSql.checkData(0,5,'32767') 
        tdSql.checkData(0,6,'-9223372036854775807')  
        tdSql.query('select * from in_int_smallint_bigint_3 where in_int in (0) order by ts desc')
        tdSql.checkData(0,1,'0') 
        tdSql.checkData(0,2,'32767')
        tdSql.checkData(0,3,'-9223372036854775807') 
        tdSql.query('select * from in_int_smallint_bigint_3 where in_small in (32767) order by ts desc')
        tdSql.checkData(0,1,'0') 
        tdSql.checkData(0,2,'32767')
        tdSql.checkData(0,3,'-9223372036854775807')   
        tdSql.query('select * from in_int_smallint_bigint_3 where in_big in (-9223372036854775807) order by ts desc')
        tdSql.checkData(0,1,'0') 
        tdSql.checkData(0,2,'32767')
        tdSql.checkData(0,3,'-9223372036854775807')       


        tdLog.info("=============== step2.3,drop normal table && create table") 
        cmd1 = 'drop table if exists normal_int_smallint_bigint_1 ;'
        cmd2 = 'create table normal_int_smallint_bigint_1 (ts timestamp,in_int int,in_small smallint , in_big bigint) ; '
        tdLog.info(cmd1)
        tdSql.execute(cmd1)
        tdLog.info(cmd2)
        tdSql.execute(cmd2)
      

        tdLog.info("=============== step2.4,insert normal table right data and check in function") 
        cmd1 = 'insert into normal_int_smallint_bigint_1 values(now,\'2147483647\',\'-32767\',\'0\') ;'
        tdLog.info(cmd1)
        tdSql.execute(cmd1)         
        tdSql.query('select * from normal_int_smallint_bigint_1 where in_int in (2147483647) order by ts desc')
        tdSql.checkData(0,1,'2147483647') 
        tdSql.checkData(0,2,'-32767')
        tdSql.checkData(0,3,'0')             
        tdSql.query('select * from normal_int_smallint_bigint_1 where in_small in (-32767) order by ts desc')
        tdSql.checkData(0,1,'2147483647') 
        tdSql.checkData(0,2,'-32767')
        tdSql.checkData(0,3,'0')  
        tdSql.query('select * from normal_int_smallint_bigint_1 where in_big in (0) order by ts desc')
        tdSql.checkData(0,1,'2147483647') 
        tdSql.checkData(0,2,'-32767')
        tdSql.checkData(0,3,'0')        

        cmd2 = 'insert into normal_int_smallint_bigint_1 values(now,\'-2147483647\',\'0\',\'9223372036854775807\') ;'
        tdLog.info(cmd2)
        tdSql.execute(cmd2)         
        tdSql.query('select * from normal_int_smallint_bigint_1 where in_int in (-2147483647) order by ts desc')
        tdSql.checkData(0,1,'-2147483647') 
        tdSql.checkData(0,2,'0')
        tdSql.checkData(0,3,'9223372036854775807')             
        tdSql.query('select * from normal_int_smallint_bigint_1 where in_small in (0) order by ts desc')
        tdSql.checkData(0,1,'-2147483647') 
        tdSql.checkData(0,2,'0')
        tdSql.checkData(0,3,'9223372036854775807')  
        tdSql.query('select * from normal_int_smallint_bigint_1 where in_big in (9223372036854775807) order by ts desc')
        tdSql.checkData(0,1,'-2147483647') 
        tdSql.checkData(0,2,'0')
        tdSql.checkData(0,3,'9223372036854775807')          

        cmd3 = 'insert into normal_int_smallint_bigint_1 values(now,\'0\',\'32767\',\'-9223372036854775807\') ;'
        tdLog.info(cmd3)
        tdSql.execute(cmd3)         
        tdSql.query('select * from normal_int_smallint_bigint_1 where in_int in (0) order by ts desc')
        tdSql.checkData(0,1,'0') 
        tdSql.checkData(0,2,'32767')
        tdSql.checkData(0,3,'-9223372036854775807')             
        tdSql.query('select * from normal_int_smallint_bigint_1 where in_small in (32767) order by ts desc')
        tdSql.checkData(0,1,'0') 
        tdSql.checkData(0,2,'32767')
        tdSql.checkData(0,3,'-9223372036854775807')  
        tdSql.query('select * from normal_int_smallint_bigint_1 where in_big in (-9223372036854775807) order by ts desc')
        tdSql.checkData(0,1,'0') 
        tdSql.checkData(0,2,'32767')
        tdSql.checkData(0,3,'-9223372036854775807')   

         
        tdLog.info("=============== step3,check binary and nchar data type")    

        tdLog.info("=============== step3.1,drop table && create table")    
        cmd1 = 'drop table if exists in_binary_nchar_1 ;'
        cmd2 = 'drop table if exists in_binary_nchar_2 ;'
        cmd3 = 'drop table if exists in_binary_nchar_3 ;'
        cmd10 = 'drop table if exists in_stable_3 ;'
        cmd11 = 'create stable in_stable_3(ts timestamp,in_binary binary(8),in_nchar nchar(12)) tags (tin_binary binary(16),tin_nchar nchar(20)) ;'
        cmd12 = 'create table in_binary_nchar_1 using in_stable_3 tags(\'0\',\'0\') ; '
        cmd13 = 'create table in_binary_nchar_2 using in_stable_3 tags(\'TDengine\',\'北京涛思数据科技有限公司\') ; '
        cmd14 = 'create table in_binary_nchar_3 using in_stable_3 tags(\'taosdataTDengine\',\'北京涛思数据科技有限公司TDengine\') ; '
        tdLog.info(cmd1)
        tdSql.execute(cmd1)
        tdLog.info(cmd2)
        tdSql.execute(cmd2)
        tdLog.info(cmd3)
        tdSql.execute(cmd3)
        tdLog.info(cmd10)
        tdSql.execute(cmd10)        
        tdLog.info(cmd11)
        tdSql.execute(cmd11)
        tdLog.info(cmd12)
        tdSql.execute(cmd12)
        tdLog.info(cmd13)
        tdSql.execute(cmd13)
        tdLog.info(cmd14)
        tdSql.execute(cmd14)        

        tdLog.info("=============== step3.2,insert stable right data and check in function") 
        cmd1 = 'insert into in_binary_nchar_1 values(now,\'0\',\'0\') ;'
        tdLog.info(cmd1)
        tdSql.execute(cmd1)         
        tdSql.query('select * from in_stable_3 where in_binary in (\'0\') order by ts desc')
        tdSql.checkData(0,1,'0') 
        tdSql.checkData(0,2,'0')
        tdSql.checkData(0,3,'0') 
        tdSql.checkData(0,4,'0')  
        tdSql.query('select * from in_stable_3 where in_nchar in (\'0\') order by ts desc')
        tdSql.checkData(0,1,'0') 
        tdSql.checkData(0,2,'0')
        tdSql.checkData(0,3,'0') 
        tdSql.checkData(0,4,'0')     
        tdSql.query('select * from in_stable_3 where tin_binary in (\'0\') order by ts desc')
        tdSql.checkData(0,1,'0') 
        tdSql.checkData(0,2,'0')
        tdSql.checkData(0,3,'0') 
        tdSql.checkData(0,4,'0')  
        tdSql.query('select * from in_stable_3 where tin_nchar in (\'0\') order by ts desc')
        tdSql.checkData(0,1,'0') 
        tdSql.checkData(0,2,'0')
        tdSql.checkData(0,3,'0') 
        tdSql.checkData(0,4,'0') 
        tdSql.query('select * from in_binary_nchar_1 where in_binary in (\'0\') order by ts desc')
        tdSql.checkData(0,1,'0') 
        tdSql.checkData(0,2,'0')  
        tdSql.query('select * from in_binary_nchar_1 where in_nchar in (\'0\') order by ts desc')
        tdSql.checkData(0,1,'0') 
        tdSql.checkData(0,2,'0')        

        cmd2 = 'insert into in_binary_nchar_2 values(now,\'TAOS\',\'涛思数据TAOSdata\') ;'
        tdLog.info(cmd2)
        tdSql.execute(cmd2)         
        tdSql.query('select * from in_stable_3 where in_binary in (\'TAOS\') order by ts desc')
        tdSql.checkData(0,1,'TAOS') 
        tdSql.checkData(0,2,'涛思数据TAOSdata')
        tdSql.checkData(0,3,'TDengine') 
        tdSql.checkData(0,4,'北京涛思数据科技有限公司')  
        tdSql.query('select * from in_stable_3 where in_nchar in (\'涛思数据TAOSdata\') order by ts desc')
        tdSql.checkData(0,1,'TAOS') 
        tdSql.checkData(0,2,'涛思数据TAOSdata')
        tdSql.checkData(0,3,'TDengine') 
        tdSql.checkData(0,4,'北京涛思数据科技有限公司')      
        tdSql.query('select * from in_stable_3 where tin_binary in (\'TDengine\') order by ts desc')
        tdSql.checkData(0,1,'TAOS') 
        tdSql.checkData(0,2,'涛思数据TAOSdata')
        tdSql.checkData(0,3,'TDengine') 
        tdSql.checkData(0,4,'北京涛思数据科技有限公司')  
        tdSql.query('select * from in_stable_3 where tin_nchar in (\'北京涛思数据科技有限公司\') order by ts desc')
        tdSql.checkData(0,1,'TAOS') 
        tdSql.checkData(0,2,'涛思数据TAOSdata')
        tdSql.checkData(0,3,'TDengine') 
        tdSql.checkData(0,4,'北京涛思数据科技有限公司') 
        tdSql.query('select * from in_binary_nchar_2 where in_binary in (\'TAOS\') order by ts desc')
        tdSql.checkData(0,1,'TAOS') 
        tdSql.checkData(0,2,'涛思数据TAOSdata') 
        tdSql.query('select * from in_binary_nchar_2 where in_nchar in (\'涛思数据TAOSdata\') order by ts desc')
        tdSql.checkData(0,1,'TAOS') 
        tdSql.checkData(0,2,'涛思数据TAOSdata')     

        cmd3 = 'insert into in_binary_nchar_3 values(now,\'TDengine\',\'北京涛思数据科技有限公司\') ;'
        tdLog.info(cmd3)
        tdSql.execute(cmd3)         
        tdSql.query('select * from in_stable_3 where in_binary in (\'TDengine\') order by ts desc')
        tdSql.checkData(0,1,'TDengine') 
        tdSql.checkData(0,2,'北京涛思数据科技有限公司')
        tdSql.checkData(0,3,'taosdataTDengine') 
        tdSql.checkData(0,4,'北京涛思数据科技有限公司TDengine')  
        tdSql.query('select * from in_stable_3 where in_nchar in (\'北京涛思数据科技有限公司\') order by ts desc')
        tdSql.checkData(0,1,'TDengine') 
        tdSql.checkData(0,2,'北京涛思数据科技有限公司')
        tdSql.checkData(0,3,'taosdataTDengine') 
        tdSql.checkData(0,4,'北京涛思数据科技有限公司TDengine')     
        tdSql.query('select * from in_stable_3 where tin_binary in (\'taosdataTDengine\') order by ts desc')
        tdSql.checkData(0,1,'TDengine') 
        tdSql.checkData(0,2,'北京涛思数据科技有限公司')
        tdSql.checkData(0,3,'taosdataTDengine') 
        tdSql.checkData(0,4,'北京涛思数据科技有限公司TDengine')   
        tdSql.query('select * from in_stable_3 where tin_nchar in (\'北京涛思数据科技有限公司TDengine\') order by ts desc')
        tdSql.checkData(0,1,'TDengine') 
        tdSql.checkData(0,2,'北京涛思数据科技有限公司')
        tdSql.checkData(0,3,'taosdataTDengine') 
        tdSql.checkData(0,4,'北京涛思数据科技有限公司TDengine') 
        tdSql.query('select * from in_binary_nchar_3 where in_binary in (\'TDengine\') order by ts desc')
        tdSql.checkData(0,1,'TDengine') 
        tdSql.checkData(0,2,'北京涛思数据科技有限公司') 
        tdSql.query('select * from in_binary_nchar_3 where in_nchar in (\'北京涛思数据科技有限公司\') order by ts desc')
        tdSql.checkData(0,1,'TDengine') 
        tdSql.checkData(0,2,'北京涛思数据科技有限公司') 


        tdLog.info("=============== step3.3,drop normal table && create table") 
        cmd1 = 'drop table if exists normal_in_binary_nchar_1 ;'
        cmd2 = 'create table normal_in_binary_nchar_1 (ts timestamp,in_binary binary(8),in_nchar nchar(12)) ; '
        tdLog.info(cmd1)
        tdSql.execute(cmd1)
        tdLog.info(cmd2)
        tdSql.execute(cmd2)
      

        tdLog.info("=============== step3.4,insert normal table right data and check in function") 
        cmd1 = 'insert into normal_in_binary_nchar_1 values(now,\'0\',\'0\') ;'
        tdLog.info(cmd1)
        tdSql.execute(cmd1)         
        tdSql.query('select * from normal_in_binary_nchar_1 where in_binary in (\'0\') order by ts desc')
        tdSql.checkData(0,1,'0') 
        tdSql.checkData(0,2,'0')         
        tdSql.query('select * from normal_in_binary_nchar_1 where in_nchar in (\'0\') order by ts desc')
        tdSql.checkData(0,1,'0') 
        tdSql.checkData(0,2,'0')  

        cmd2 = 'insert into normal_in_binary_nchar_1 values(now,\'TAOS\',\'涛思数据TAOSdata\') ;'
        tdLog.info(cmd2)
        tdSql.execute(cmd2)         
        tdSql.query('select * from normal_in_binary_nchar_1 where in_binary in (\'TAOS\') order by ts desc')
        tdSql.checkData(0,1,'TAOS') 
        tdSql.checkData(0,2,'涛思数据TAOSdata')         
        tdSql.query('select * from normal_in_binary_nchar_1 where in_nchar in (\'涛思数据TAOSdata\') order by ts desc')
        tdSql.checkData(0,1,'TAOS') 
        tdSql.checkData(0,2,'涛思数据TAOSdata')       

        cmd3 = 'insert into normal_in_binary_nchar_1 values(now,\'TDengine\',\'北京涛思数据科技有限公司\') ;'
        tdLog.info(cmd3)
        tdSql.execute(cmd3)         
        tdSql.query('select * from normal_in_binary_nchar_1 where in_binary in (\'TDengine\') order by ts desc')
        tdSql.checkData(0,1,'TDengine') 
        tdSql.checkData(0,2,'北京涛思数据科技有限公司')         
        tdSql.query('select * from normal_in_binary_nchar_1 where in_nchar in (\'北京涛思数据科技有限公司\') order by ts desc')
        tdSql.checkData(0,1,'TDengine') 
        tdSql.checkData(0,2,'北京涛思数据科技有限公司')   

        tdLog.info("=============== step4,check float and double data type,not support")    

        tdLog.info("=============== step4.1,drop table && create table")    
        cmd1 = 'drop table if exists in_float_double_1 ;'
        cmd10 = 'drop table if exists in_stable_4 ;'
        cmd11 = 'create stable in_stable_4(ts timestamp,in_float float,in_double double) tags (tin_float float,tin_double double) ;'
        cmd12 = 'create table in_float_double_1 using in_stable_4 tags(\'666\',\'88888\') ; '
        tdLog.info(cmd1)
        tdSql.execute(cmd1)
        tdLog.info(cmd10)
        tdSql.execute(cmd10)        
        tdLog.info(cmd11)
        tdSql.execute(cmd11)
        tdLog.info(cmd12)
        tdSql.execute(cmd12)    

        tdLog.info("=============== step4.2,insert stable right data and check in function") 
        cmd1 = 'insert into in_float_double_1 values(now,\'888\',\'66666\') ;'
        tdLog.info(cmd1)
        tdSql.execute(cmd1)         
        
624 625 626 627 628 629 630 631 632
        #cmd2 = 'select * from in_stable_4 where in_float in (\'888\');'
        #tdLog.info(cmd2)
        #tdSql.error(cmd2)
        #try:
        #    tdSql.execute(cmd2)
        #    tdLog.exit("invalid operation: not supported filter condition")
        #except Exception as e:
        #    tdLog.info(repr(e))
        #    tdLog.info("invalid operation: not supported filter condition") 
H
happyguoxy 已提交
633
        
634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652
        #cmd3 = 'select * from in_stable_4 where in_double in (\'66666\');'
        #tdLog.info(cmd3)
        #tdSql.error(cmd3)
        #try:
        #    tdSql.execute(cmd3)
        #    tdLog.exit("invalid operation: not supported filter condition")
        #except Exception as e:
        #    tdLog.info(repr(e))
        #    tdLog.info("invalid operation: not supported filter condition") 

        #cmd4 = 'select * from in_stable_4 where tin_float in (\'666\');'
        #tdLog.info(cmd4)
        #tdSql.error(cmd4)
        #try:
        #    tdSql.execute(cmd4)
        #    tdLog.exit("invalid operation: not supported filter condition")
        #except Exception as e:
        #    tdLog.info(repr(e))
        #    tdLog.info("invalid operation: not supported filter condition") 
H
happyguoxy 已提交
653
        
654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682
        #cmd5 = 'select * from in_stable_4 where tin_double in (\'88888\');'
        #tdLog.info(cmd5)
        #tdSql.error(cmd5)
        #try:
        #    tdSql.execute(cmd5)
        #    tdLog.exit("invalid operation: not supported filter condition")
        #except Exception as e:
        #    tdLog.info(repr(e))
        #    tdLog.info("invalid operation: not supported filter condition") 

        #cmd6 = 'select * from in_float_double_1 where in_float in (\'888\');'
        #tdLog.info(cmd6)
        #tdSql.error(cmd6)
        #try:
        #    tdSql.execute(cmd6)
        #    tdLog.exit("invalid operation: not supported filter condition")
        #except Exception as e:
        #    tdLog.info(repr(e))
        #    tdLog.info("invalid operation: not supported filter condition") 
        #
        #cmd7 = 'select * from in_float_double_1 where in_double in (\'66666\');'
        #tdLog.info(cmd7)
        #tdSql.error(cmd7)
        #try:
        #    tdSql.execute(cmd7)
        #    tdLog.exit("invalid operation: not supported filter condition")
        #except Exception as e:
        #    tdLog.info(repr(e))
        #    tdLog.info("invalid operation: not supported filter condition") 
H
happyguoxy 已提交
683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700

              

        tdLog.info("=============== step4.3,drop normal table && create table") 
        cmd1 = 'drop table if exists normal_in_float_double_1 ;'
        cmd2 = 'create table normal_in_float_double_1 (ts timestamp,in_float float,in_double double) ; '
        tdLog.info(cmd1)
        tdSql.execute(cmd1)
        tdLog.info(cmd2)
        tdSql.execute(cmd2)
      

        tdLog.info("=============== step4.4,insert normal table right data and check in function") 
        cmd1 = 'insert into normal_in_float_double_1 values(now,\'888\',\'666666\') ;'
        tdLog.info(cmd1)
        tdSql.execute(cmd1)   

        cmd2 = 'select * from normal_in_float_double_1 where in_float in (\'888\');'
701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718
        #tdLog.info(cmd2)
        #tdSql.error(cmd2)
        #try:
        #    tdSql.execute(cmd2)
        #    tdLog.exit("invalid operation: not supported filter condition")
        #except Exception as e:
        #    tdLog.info(repr(e))
        #    tdLog.info("invalid operation: not supported filter condition") 
        #
        #cmd3 = 'select * from normal_in_float_double_1 where in_double in (\'66666\');'
        #tdLog.info(cmd3)
        #tdSql.error(cmd3)
        #try:
        #    tdSql.execute(cmd3)
        #    tdLog.exit("invalid operation: not supported filter condition")
        #except Exception as e:
        #    tdLog.info(repr(e))
        #    tdLog.info("invalid operation: not supported filter condition") 
H
happyguoxy 已提交
719 720 721 722 723 724 725 726

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


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