schemalessInsert.py 89.4 KB
Newer Older
J
jiajingbin 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13
###################################################################
#           Copyright (c) 2021 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 -*-

14
import traceback
J
jiajingbin 已提交
15
import random
16
from taos.error import SchemalessError
J
jiajingbin 已提交
17 18 19 20 21
import time
import numpy as np
from util.log import *
from util.cases import *
from util.sql import *
J
jiajingbin 已提交
22
from util.common import tdCom
23
from util.types import TDSmlProtocolType, TDSmlTimestampType
J
save  
jiajingbin 已提交
24
import threading
J
jiajingbin 已提交
25 26 27 28 29 30
class TDTestCase:
    def init(self, conn, logSql):
        tdLog.debug("start to execute %s" % __file__)
        tdSql.init(conn.cursor(), logSql)
        self._conn = conn 

J
jiajingbin 已提交
31 32 33 34 35 36 37 38 39
    def createDb(self, name="test", db_update_tag=0):
        if db_update_tag == 0:
            tdSql.execute(f"drop database if exists {name}")
            tdSql.execute(f"create database if not exists {name} precision 'us'")
        else:
            tdSql.execute(f"drop database if exists {name}")
            tdSql.execute(f"create database if not exists {name} precision 'us' update 1")
        tdSql.execute(f'use {name}')

J
jiajingbin 已提交
40 41 42
    def timeTrans(self, time_value, ts_type):
        # TDSmlTimestampType.HOUR.value, TDSmlTimestampType.MINUTE.value, TDSmlTimestampType.SECOND.value, TDSmlTimestampType.MICRO_SECOND.value, TDSmlTimestampType.NANO_SECOND.value
        if int(time_value) == 0:
J
jiajingbin 已提交
43 44
            ts = time.time()
        else:
J
jiajingbin 已提交
45 46 47 48 49 50 51 52
            if ts_type == TDSmlTimestampType.NANO_SECOND.value or ts_type is None:
                ts = int(''.join(list(filter(str.isdigit, time_value))))/1000000000
            elif ts_type == TDSmlTimestampType.MICRO_SECOND.value:
                ts = int(''.join(list(filter(str.isdigit, time_value))))/1000000
            elif ts_type == TDSmlTimestampType.MILLI_SECOND.value:
                ts = int(''.join(list(filter(str.isdigit, time_value))))/1000
            elif ts_type == TDSmlTimestampType.SECOND.value:
                ts = int(''.join(list(filter(str.isdigit, time_value))))/1
J
jiajingbin 已提交
53 54 55 56 57
        ulsec = repr(ts).split('.')[1][:6]
        if len(ulsec) < 6 and int(ulsec) != 0:
            ulsec = int(ulsec) * (10 ** (6 - len(ulsec)))
        elif int(ulsec) == 0:
            ulsec *= 6
58
            # * follow two rows added for tsCheckCase
J
jiajingbin 已提交
59 60 61 62 63 64 65 66 67 68
            td_ts = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(ts))
            return td_ts
        #td_ts = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(ts))
        td_ts = time.strftime("%Y-%m-%d %H:%M:%S.{}".format(ulsec), time.localtime(ts))
        return td_ts
        #return repr(datetime.datetime.strptime(td_ts, "%Y-%m-%d %H:%M:%S.%f"))
    
    def dateToTs(self, datetime_input):
        return int(time.mktime(time.strptime(datetime_input, "%Y-%m-%d %H:%M:%S.%f")))

J
jiajingbin 已提交
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
    def getTdTypeValue(self, value, vtype="col"):
        """
            vtype must be col or tag
        """
        if vtype == "col":
            if value.lower().endswith("i8"):
                td_type = "TINYINT"
                td_tag_value = ''.join(list(value)[:-2])
            elif value.lower().endswith("i16"):
                td_type = "SMALLINT"
                td_tag_value = ''.join(list(value)[:-3])
            elif value.lower().endswith("i32"):
                td_type = "INT"
                td_tag_value = ''.join(list(value)[:-3])
            elif value.lower().endswith("i64"):
                td_type = "BIGINT"
                td_tag_value = ''.join(list(value)[:-3])
            elif value.lower().lower().endswith("u64"):
                td_type = "BIGINT UNSIGNED"
                td_tag_value = ''.join(list(value)[:-3])
            elif value.lower().endswith("f32"):
                td_type = "FLOAT"
                td_tag_value = ''.join(list(value)[:-3])
                td_tag_value = '{}'.format(np.float32(td_tag_value))
            elif value.lower().endswith("f64"):
                td_type = "DOUBLE"
                td_tag_value = ''.join(list(value)[:-3])
                if "e" in value.lower():
                    td_tag_value = str(float(td_tag_value))
            elif value.lower().startswith('l"'):
                td_type = "NCHAR"
                td_tag_value = ''.join(list(value)[2:-1])
            elif value.startswith('"') and value.endswith('"'):
                td_type = "BINARY"
                td_tag_value = ''.join(list(value)[1:-1])
            elif value.lower() == "t" or value.lower() == "true":
                td_type = "BOOL"
                td_tag_value = "True"
            elif value.lower() == "f" or value.lower() == "false":
                td_type = "BOOL"
                td_tag_value = "False"
            elif value.isdigit():
                td_type = "DOUBLE"
                td_tag_value = str(float(value))
            else:
                td_type = "DOUBLE"
                if "e" in value.lower():
                    td_tag_value = str(float(value))
                else:
                    td_tag_value = value
        elif vtype == "tag":
J
jiajingbin 已提交
120
            td_type = "NCHAR"
J
jiajingbin 已提交
121
            td_tag_value = str(value)
J
jiajingbin 已提交
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
        return td_type, td_tag_value

    def typeTrans(self, type_list):
        type_num_list = []
        for tp in type_list:
            if tp.upper() == "TIMESTAMP":
                type_num_list.append(9)
            elif tp.upper() == "BOOL":
                type_num_list.append(1)
            elif tp.upper() == "TINYINT":
                type_num_list.append(2)
            elif tp.upper() == "SMALLINT":
                type_num_list.append(3)
            elif tp.upper() == "INT":
                type_num_list.append(4)
            elif tp.upper() == "BIGINT":
                type_num_list.append(5)
            elif tp.upper() == "FLOAT":
                type_num_list.append(6)
            elif tp.upper() == "DOUBLE":
                type_num_list.append(7)
            elif tp.upper() == "BINARY":
                type_num_list.append(8)
            elif tp.upper() == "NCHAR":
                type_num_list.append(10)
            elif tp.upper() == "BIGINT UNSIGNED":
                type_num_list.append(14)
        return type_num_list

J
jiajingbin 已提交
151
    def inputHandle(self, input_sql, ts_type):
J
jiajingbin 已提交
152 153 154 155
        input_sql_split_list = input_sql.split(" ")

        stb_tag_list = input_sql_split_list[0].split(',')
        stb_col_list = input_sql_split_list[1].split(',')
J
jiajingbin 已提交
156
        ts_value = self.timeTrans(input_sql_split_list[2], ts_type)
J
jiajingbin 已提交
157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174

        stb_name = stb_tag_list[0]
        stb_tag_list.pop(0)

        tag_name_list = []
        tag_value_list = []
        td_tag_value_list = []
        td_tag_type_list = []

        col_name_list = []
        col_value_list = []
        td_col_value_list = []
        td_col_type_list = []

        for elm in stb_tag_list:
            if "id=" in elm.lower():
                tb_name = elm.split('=')[1]
            else:
J
jiajingbin 已提交
175
                tag_name_list.append(elm.split("=")[0].lower())
J
jiajingbin 已提交
176 177
                tag_value_list.append(elm.split("=")[1])
                tb_name = ""
J
jiajingbin 已提交
178 179
                td_tag_value_list.append(self.getTdTypeValue(elm.split("=")[1], "tag")[1])
                td_tag_type_list.append(self.getTdTypeValue(elm.split("=")[1], "tag")[0])
J
jiajingbin 已提交
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
        
        for elm in stb_col_list:
            col_name_list.append(elm.split("=")[0])
            col_value_list.append(elm.split("=")[1])
            td_col_value_list.append(self.getTdTypeValue(elm.split("=")[1])[1])
            td_col_type_list.append(self.getTdTypeValue(elm.split("=")[1])[0])

        final_field_list = []
        final_field_list.extend(col_name_list)
        final_field_list.extend(tag_name_list)

        final_type_list = []
        final_type_list.append("TIMESTAMP")
        final_type_list.extend(td_col_type_list)
        final_type_list.extend(td_tag_type_list)
        final_type_list = self.typeTrans(final_type_list)

        final_value_list = []
        final_value_list.append(ts_value)
        final_value_list.extend(td_col_value_list)
        final_value_list.extend(td_tag_value_list)
        return final_value_list, final_field_list, final_type_list, stb_name, tb_name

    def genFullTypeSql(self, stb_name="", tb_name="", t0="", t1="127i8", t2="32767i16", t3="2147483647i32",
                        t4="9223372036854775807i64", t5="11.12345f32", t6="22.123456789f64", t7="\"binaryTagValue\"",
                        t8="L\"ncharTagValue\"", c0="", c1="127i8", c2="32767i16", c3="2147483647i32",
                        c4="9223372036854775807i64", c5="11.12345f32", c6="22.123456789f64", c7="\"binaryColValue\"", 
J
jiajingbin 已提交
207 208 209 210
                        c8="L\"ncharColValue\"", c9="7u64", ts="1626006833639000000", ts_type=None,
                        id_noexist_tag=None, id_change_tag=None, id_upper_tag=None, id_mixul_tag=None, id_double_tag=None,
                        ct_add_tag=None, ct_am_tag=None, ct_ma_tag=None, ct_min_tag=None, c_multi_tag=None, t_multi_tag=None,
                        c_blank_tag=None, t_blank_tag=None, chinese_tag=None):
J
jiajingbin 已提交
211
        if stb_name == "":
J
jiajingbin 已提交
212
            stb_name = tdCom.getLongName(len=6, mode="letters")
J
jiajingbin 已提交
213 214 215
        if tb_name == "":
            tb_name = f'{stb_name}_{random.randint(0, 65535)}_{random.randint(0, 65535)}'
        if t0 == "":
J
jiajingbin 已提交
216
            t0 = "t"
J
jiajingbin 已提交
217 218
        if c0 == "":
            c0 = random.choice(["f", "F", "false", "False", "t", "T", "true", "True"])
J
jiajingbin 已提交
219
        #sql_seq = f'{stb_name},id=\"{tb_name}\",t0={t0},t1=127i8,t2=32767i16,t3=125.22f64,t4=11.321f32,t5=11.12345f32,t6=22.123456789f64,t7=\"binaryTagValue\",t8=L\"ncharTagValue\" c0={bool_value},c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=\"binaryValue\",c8=L\"ncharValue\" 1626006833639000000'
J
jiajingbin 已提交
220 221 222 223
        if id_upper_tag is not None:
            id = "ID"
        else:
            id = "id"
J
jiajingbin 已提交
224 225 226 227 228
        if id_mixul_tag is not None:
            id = random.choice(["iD", "Id"])
        else:
            id = "id"
        sql_seq = f'{stb_name},{id}={tb_name},t0={t0},t1={t1},t2={t2},t3={t3},t4={t4},t5={t5},t6={t6},t7={t7},t8={t8} c0={c0},c1={c1},c2={c2},c3={c3},c4={c4},c5={c5},c6={c6},c7={c7},c8={c8},c9={c9} {ts}'
J
jiajingbin 已提交
229 230
        if id_noexist_tag is not None:
            sql_seq = f'{stb_name},t0={t0},t1={t1},t2={t2},t3={t3},t4={t4},t5={t5},t6={t6},t7={t7},t8={t8} c0={c0},c1={c1},c2={c2},c3={c3},c4={c4},c5={c5},c6={c6},c7={c7},c8={c8},c9={c9} {ts}'
J
save  
jiajingbin 已提交
231
            if ct_add_tag is not None:
J
jiajingbin 已提交
232 233
                sql_seq = f'{stb_name},t0={t0},t1={t1},t2={t2},t3={t3},t4={t4},t5={t5},t6={t6},t7={t7},t8={t8},t9={t8} c0={c0},c1={c1},c2={c2},c3={c3},c4={c4},c5={c5},c6={c6},c7={c7},c8={c8},c9={c9} {ts}'
        if id_change_tag is not None:
J
jiajingbin 已提交
234
            sql_seq = f'{stb_name},t0={t0},t1={t1},{id}={tb_name},t2={t2},t3={t3},t4={t4},t5={t5},t6={t6},t7={t7},t8={t8} c0={c0},c1={c1},c2={c2},c3={c3},c4={c4},c5={c5},c6={c6},c7={c7},c8={c8},c9={c9} {ts}'
J
jiajingbin 已提交
235 236
        if id_double_tag is not None:
            sql_seq = f'{stb_name},{id}=\"{tb_name}_1\",t0={t0},t1={t1},{id}=\"{tb_name}_2\",t2={t2},t3={t3},t4={t4},t5={t5},t6={t6},t7={t7},t8={t8} c0={c0},c1={c1},c2={c2},c3={c3},c4={c4},c5={c5},c6={c6},c7={c7},c8={c8},c9={c9} {ts}'
J
save  
jiajingbin 已提交
237
        if ct_add_tag is not None:
J
jiajingbin 已提交
238
            sql_seq = f'{stb_name},{id}={tb_name},t0={t0},t1={t1},t2={t2},t3={t3},t4={t4},t5={t5},t6={t6},t7={t7},t8={t8},t11={t1},t10={t8} c0={c0},c1={c1},c2={c2},c3={c3},c4={c4},c5={c5},c6={c6},c7={c7},c8={c8},c9={c9},c11={c8},c10={t0} {ts}'
J
save  
jiajingbin 已提交
239
        if ct_am_tag is not None:
J
jiajingbin 已提交
240
            sql_seq = f'{stb_name},{id}={tb_name},t0={t0},t1={t1},t2={t2},t3={t3},t4={t4},t5={t5},t6={t6} c0={c0},c1={c1},c2={c2},c3={c3},c4={c4},c5={c5},c6={c6},c7={c7},c8={c8},c9={c9},c11={c8},c10={t0} {ts}'
J
jiajingbin 已提交
241 242
            if id_noexist_tag is not None:
                    sql_seq = f'{stb_name},t0={t0},t1={t1},t2={t2},t3={t3},t4={t4},t5={t5},t6={t6} c0={c0},c1={c1},c2={c2},c3={c3},c4={c4},c5={c5},c6={c6},c7={c7},c8={c8},c9={c9},c11={c8},c10={t0} {ts}'
J
save  
jiajingbin 已提交
243
        if ct_ma_tag is not None:
J
jiajingbin 已提交
244
            sql_seq = f'{stb_name},{id}={tb_name},t0={t0},t1={t1},t2={t2},t3={t3},t4={t4},t5={t5},t6={t6},t7={t7},t8={t8},t11={t1},t10={t8} c0={c0},c1={c1},c2={c2},c3={c3},c4={c4},c5={c5},c6={c6} {ts}'
J
jiajingbin 已提交
245 246
            if id_noexist_tag is not None:
                sql_seq = f'{stb_name},t0={t0},t1={t1},t2={t2},t3={t3},t4={t4},t5={t5},t6={t6},t7={t7},t8={t8},t11={t1},t10={t8} c0={c0},c1={c1},c2={c2},c3={c3},c4={c4},c5={c5},c6={c6} {ts}'
J
save  
jiajingbin 已提交
247
        if ct_min_tag is not None:
J
jiajingbin 已提交
248 249 250 251 252 253 254 255 256 257 258
            sql_seq = f'{stb_name},{id}={tb_name},t0={t0},t1={t1},t2={t2},t3={t3},t4={t4},t5={t5},t6={t6} c0={c0},c1={c1},c2={c2},c3={c3},c4={c4},c5={c5},c6={c6} {ts}'
        if c_multi_tag is not None:
            sql_seq = f'{stb_name},{id}={tb_name},t0={t0},t1={t1},t2={t2},t3={t3},t4={t4},t5={t5},t6={t6},t7={t7},t8={t8} c0={c0},c1={c1},c2={c2},c3={c3},c4={c4},c5={c5},c6={c6},c7={c7},c8={c8},c9={c9} c10={c9} {ts}'
        if t_multi_tag is not None:
            sql_seq = f'{stb_name},{id}={tb_name},t0={t0},t1={t1},t2={t2},t3={t3},t4={t4},t5={t5},t6={t6},t7={t7},t8={t8} t9={t8} c0={c0},c1={c1},c2={c2},c3={c3},c4={c4},c5={c5},c6={c6},c7={c7},c8={c8},c9={c9} {ts}'
        if c_blank_tag is not None:
            sql_seq = f'{stb_name},{id}={tb_name},t0={t0},t1={t1},t2={t2},t3={t3},t4={t4},t5={t5},t6={t6},t7={t7},t8={t8} {ts}'
        if t_blank_tag is not None:
            sql_seq = f'{stb_name},{id}={tb_name} c0={c0},c1={c1},c2={c2},c3={c3},c4={c4},c5={c5},c6={c6},c7={c7},c8={c8},c9={c9} {ts}'
        if chinese_tag is not None:
            sql_seq = f'{stb_name},to=L"涛思数据" c0=L"涛思数据" {ts}'
J
jiajingbin 已提交
259
        return sql_seq, stb_name
J
jiajingbin 已提交
260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282
    
    def genMulTagColStr(self, genType, count):
        """
            genType must be tag/col
        """
        tag_str = ""
        col_str = ""
        if genType == "tag":
            for i in range(0, count):
                if i < (count-1):
                    tag_str += f't{i}=f,'
                else:
                    tag_str += f't{i}=f '
            return tag_str
        if genType == "col":
            for i in range(0, count):
                if i < (count-1):
                    col_str += f'c{i}=t,'
                else:
                    col_str += f'c{i}=t '
            return col_str

    def genLongSql(self, tag_count, col_count):
J
jiajingbin 已提交
283
        stb_name = tdCom.getLongName(7, mode="letters")
J
jiajingbin 已提交
284 285 286
        tb_name = f'{stb_name}_1'
        tag_str = self.genMulTagColStr("tag", tag_count)
        col_str = self.genMulTagColStr("col", col_count)
J
jiajingbin 已提交
287 288
        ts = "1626006833640000000"
        long_sql = stb_name + ',' + f'id={tb_name}' + ',' + tag_str + col_str + ts
J
jiajingbin 已提交
289 290 291 292 293 294 295 296
        return long_sql, stb_name

    def getNoIdTbName(self, stb_name):
        query_sql = f"select tbname from {stb_name}"
        tb_name = self.resHandle(query_sql, True)[0][0]
        return tb_name

    def resHandle(self, query_sql, query_tag):
297
        tdSql.execute('reset query cache')
J
jiajingbin 已提交
298 299 300 301 302 303 304 305 306 307 308 309
        row_info = tdSql.query(query_sql, query_tag)
        col_info = tdSql.getColNameList(query_sql, query_tag)
        res_row_list = []
        sub_list = []
        for row_mem in row_info:
            for i in row_mem:
                sub_list.append(str(i))
            res_row_list.append(sub_list)
        res_field_list_without_ts = col_info[0][1:]
        res_type_list = col_info[1]
        return res_row_list, res_field_list_without_ts, res_type_list

J
jiajingbin 已提交
310 311 312 313 314 315
    def resCmp(self, input_sql, stb_name, query_sql="select * from", ts_type=None, condition="", ts=None, id=True, none_check_tag=None, precision=None):
        expect_list = self.inputHandle(input_sql, ts_type)
        if precision == None:
            self._conn.schemaless_insert([input_sql], TDSmlProtocolType.LINE.value, ts_type)
        else:
            self._conn.schemaless_insert([input_sql], TDSmlProtocolType.LINE.value, precision)
J
jiajingbin 已提交
316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334
        query_sql = f"{query_sql} {stb_name} {condition}"
        res_row_list, res_field_list_without_ts, res_type_list = self.resHandle(query_sql, True)
        if ts == 0:
            res_ts = self.dateToTs(res_row_list[0][0])
            current_time = time.time()
            if current_time - res_ts < 60:
                tdSql.checkEqual(res_row_list[0][1:], expect_list[0][1:])
            else:
                print("timeout")
                tdSql.checkEqual(res_row_list[0], expect_list[0])
        else:
            if none_check_tag is not None:
                none_index_list = [i for i,x in enumerate(res_row_list[0]) if x=="None"]
                none_index_list.reverse()
                for j in none_index_list:
                    res_row_list[0].pop(j)
                    expect_list[0].pop(j)
            tdSql.checkEqual(res_row_list[0], expect_list[0])
        tdSql.checkEqual(res_field_list_without_ts, expect_list[1])
335 336 337
        for i in range(len(res_type_list)):
            tdSql.checkEqual(res_type_list[i], expect_list[2][i])
        # tdSql.checkEqual(res_type_list, expect_list[2])
J
jiajingbin 已提交
338

J
jiajingbin 已提交
339 340
    def cleanStb(self):
        query_sql = "show stables"
J
jiajingbin 已提交
341 342 343
        res_row_list = tdSql.query(query_sql, True)
        stb_list = map(lambda x: x[0], res_row_list)
        for stb in stb_list:
J
jiajingbin 已提交
344 345
            tdSql.execute(f'drop table if exists {stb}')

J
jiajingbin 已提交
346 347 348 349
    def initCheckCase(self):
        """
            normal tags and cols, one for every elm
        """
J
jiajingbin 已提交
350
        tdLog.info(f'{sys._getframe().f_code.co_name}() function is running')
J
jiajingbin 已提交
351
        tdCom.cleanTb()
J
jiajingbin 已提交
352
        input_sql, stb_name = self.genFullTypeSql()
J
jiajingbin 已提交
353 354 355 356 357 358
        self.resCmp(input_sql, stb_name)

    def boolTypeCheckCase(self):
        """
            check all normal type
        """
J
jiajingbin 已提交
359
        tdLog.info(f'{sys._getframe().f_code.co_name}() function is running')
J
jiajingbin 已提交
360
        tdCom.cleanTb()
J
jiajingbin 已提交
361 362
        full_type_list = ["f", "F", "false", "False", "t", "T", "true", "True"]
        for t_type in full_type_list:
J
jiajingbin 已提交
363
            input_sql, stb_name = self.genFullTypeSql(c0=t_type, t0=t_type)
J
jiajingbin 已提交
364 365 366 367 368 369 370 371 372 373
            self.resCmp(input_sql, stb_name)
        
    def symbolsCheckCase(self):
        """
            check symbols = `~!@#$%^&*()_-+={[}]\|:;'\",<.>/? 
        """
        '''
            please test :
            binary_symbols = '\"abcd`~!@#$%^&*()_-{[}]|:;<.>?lfjal"\'\'"\"'
        '''
J
jiajingbin 已提交
374
        tdLog.info(f'{sys._getframe().f_code.co_name}() function is running')
J
jiajingbin 已提交
375
        tdCom.cleanTb()
J
jiajingbin 已提交
376 377
        binary_symbols = '\"abcd`~!@#$%^&*()_-{[}]|:;<.>?lfjal"\"'
        nchar_symbols = f'L{binary_symbols}'
J
jiajingbin 已提交
378
        input_sql, stb_name = self.genFullTypeSql(c7=binary_symbols, c8=nchar_symbols, t7=binary_symbols, t8=nchar_symbols)
J
jiajingbin 已提交
379 380 381 382
        self.resCmp(input_sql, stb_name)

    def tsCheckCase(self):
        """
J
jiajingbin 已提交
383
            test ts list --> ["1626006833639000000", "1626006833639019us", "1626006833640ms", "1626006834s", "1626006822639022"]
J
jiajingbin 已提交
384 385
            # ! us级时间戳都为0时,数据库中查询显示,但python接口拿到的结果不显示 .000000的情况请确认,目前修改时间处理代码可以通过
        """
J
jiajingbin 已提交
386
        tdLog.info(f'{sys._getframe().f_code.co_name}() function is running')
J
jiajingbin 已提交
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
        tdCom.cleanTb()
        input_sql, stb_name = self.genFullTypeSql(ts=1626006833639000000)
        self.resCmp(input_sql, stb_name, ts_type=TDSmlTimestampType.NANO_SECOND.value)
        input_sql, stb_name = self.genFullTypeSql(ts=1626006833639019)
        self.resCmp(input_sql, stb_name, ts_type=TDSmlTimestampType.MICRO_SECOND.value)
        input_sql, stb_name = self.genFullTypeSql(ts=1626006833640)
        self.resCmp(input_sql, stb_name, ts_type=TDSmlTimestampType.MILLI_SECOND.value)
        input_sql, stb_name = self.genFullTypeSql(ts=1626006834)
        self.resCmp(input_sql, stb_name, ts_type=TDSmlTimestampType.SECOND.value)
        input_sql, stb_name = self.genFullTypeSql(ts=1626006833639000000)
        self.resCmp(input_sql, stb_name, ts_type=None)
        input_sql, stb_name = self.genFullTypeSql(ts=0)
        self.resCmp(input_sql, stb_name, ts=0)

        tdSql.execute(f"drop database if exists test_ts")
        tdSql.execute(f"create database if not exists test_ts precision 'ms'")
        tdSql.execute("use test_ts")
        input_sql = ['test_ms,t0=t c0=t 1626006833640', 'test_ms,t0=t c0=f 1626006833641']
        self._conn.schemaless_insert(input_sql, TDSmlProtocolType.LINE.value, TDSmlTimestampType.MILLI_SECOND.value)
        res = tdSql.query('select * from test_ms', True)
        tdSql.checkEqual(str(res[0][0]), "2021-07-11 20:33:53.640000")
        tdSql.checkEqual(str(res[1][0]), "2021-07-11 20:33:53.641000")

        tdSql.execute(f"drop database if exists test_ts")
        tdSql.execute(f"create database if not exists test_ts precision 'us'")
        tdSql.execute("use test_ts")
        input_sql = ['test_us,t0=t c0=t 1626006833639000', 'test_us,t0=t c0=f 1626006833639001']
        self._conn.schemaless_insert(input_sql, TDSmlProtocolType.LINE.value, TDSmlTimestampType.MICRO_SECOND.value)
        res = tdSql.query('select * from test_us', True)
        tdSql.checkEqual(str(res[0][0]), "2021-07-11 20:33:53.639000")
        tdSql.checkEqual(str(res[1][0]), "2021-07-11 20:33:53.639001")

        tdSql.execute(f"drop database if exists test_ts")
        tdSql.execute(f"create database if not exists test_ts precision 'ns'")
        tdSql.execute("use test_ts")
        input_sql = ['test_ns,t0=t c0=t 1626006833639000000', 'test_ns,t0=t c0=f 1626006833639000001']
        self._conn.schemaless_insert(input_sql, TDSmlProtocolType.LINE.value, TDSmlTimestampType.NANO_SECOND.value)
        res = tdSql.query('select * from test_ns', True)
        tdSql.checkEqual(str(res[0][0]), "1626006833639000000")
        tdSql.checkEqual(str(res[1][0]), "1626006833639000001")

        self.createDb()

    def zeroTsCheckCase(self):
J
jiajingbin 已提交
431
        tdLog.info(f'{sys._getframe().f_code.co_name}() function is running')
J
jiajingbin 已提交
432 433 434 435 436
        tdCom.cleanTb()
        for ts_tag in [TDSmlTimestampType.HOUR.value, TDSmlTimestampType.MINUTE.value, TDSmlTimestampType.SECOND.value, TDSmlTimestampType.MICRO_SECOND.value, TDSmlTimestampType.NANO_SECOND.value]:
            input_sql = f'{tdCom.getLongName(len=10, mode="letters")},t0=127,t1=32767I16,t2=2147483647I32,t3=9223372036854775807,t4=11.12345027923584F32,t5=22.123456789F64 c0=127,c1=32767I16,c2=2147483647I32,c3=9223372036854775807,c4=11.12345027923584F32,c5=22.123456789F64 0'
            stb_name = input_sql.split(",")[0]
            self.resCmp(input_sql, stb_name, ts=0, precision=ts_tag)
J
jiajingbin 已提交
437
    
J
jiajingbin 已提交
438
    def influxTsCheckCase(self):
J
jiajingbin 已提交
439
        tdLog.info(f'{sys._getframe().f_code.co_name}() function is running')
J
jiajingbin 已提交
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
        tdCom.cleanTb()
        input_sql = f'{tdCom.getLongName(len=10, mode="letters")},t0=127,t1=32767I16,t2=2147483647I32,t3=9223372036854775807,t4=11.12345027923584F32,t5=22.123456789F64 c0=127,c1=32767I16,c2=2147483647I32,c3=9223372036854775807,c4=11.12345027923584F32,c5=22.123456789F64 454093'
        stb_name = input_sql.split(",")[0]
        self._conn.schemaless_insert([input_sql], TDSmlProtocolType.LINE.value, TDSmlTimestampType.HOUR.value)
        res = tdSql.query(f'select * from {stb_name}', True)
        tdSql.checkEqual(str(res[0][0]), "2021-10-20 21:00:00")
        input_sql = f'{tdCom.getLongName(len=10, mode="letters")},t0=127,t1=32767I16,t2=2147483647I32,t3=9223372036854775807,t4=11.12345027923584F32,t5=22.123456789F64 c0=127,c1=32767I16,c2=2147483647I32,c3=9223372036854775807,c4=11.12345027923584F32,c5=22.123456789F64 454094'
        stb_name = input_sql.split(",")[0]
        self._conn.schemaless_insert([input_sql], TDSmlProtocolType.LINE.value, TDSmlTimestampType.HOUR.value)
        res = tdSql.query(f'select * from {stb_name}', True)
        tdSql.checkEqual(str(res[0][0]), "2021-10-20 22:00:00")

        input_sql = f'{tdCom.getLongName(len=10, mode="letters")},t0=127,t1=32767I16,t2=2147483647I32,t3=9223372036854775807,t4=11.12345027923584F32,t5=22.123456789F64 c0=127,c1=32767I16,c2=2147483647I32,c3=9223372036854775807,c4=11.12345027923584F32,c5=22.123456789F64 27245538'
        stb_name = input_sql.split(",")[0]
        self._conn.schemaless_insert([input_sql], TDSmlProtocolType.LINE.value, TDSmlTimestampType.MINUTE.value)
        res = tdSql.query(f'select * from {stb_name}', True)
        tdSql.checkEqual(str(res[0][0]), "2021-10-20 20:18:00")
        input_sql = f'{tdCom.getLongName(len=10, mode="letters")},t0=127,t1=32767I16,t2=2147483647I32,t3=9223372036854775807,t4=11.12345027923584F32,t5=22.123456789F64 c0=127,c1=32767I16,c2=2147483647I32,c3=9223372036854775807,c4=11.12345027923584F32,c5=22.123456789F64 27245539'
        stb_name = input_sql.split(",")[0]
        self._conn.schemaless_insert([input_sql], TDSmlProtocolType.LINE.value, TDSmlTimestampType.MINUTE.value)
        res = tdSql.query(f'select * from {stb_name}', True)
        tdSql.checkEqual(str(res[0][0]), "2021-10-20 20:19:00")

        input_sql = f'{tdCom.getLongName(len=10, mode="letters")},t0=127,t1=32767I16,t2=2147483647I32,t3=9223372036854775807,t4=11.12345027923584F32,t5=22.123456789F64 c0=127,c1=32767I16,c2=2147483647I32,c3=9223372036854775807,c4=11.12345027923584F32,c5=22.123456789F64 1634731694'
        stb_name = input_sql.split(",")[0]
        self._conn.schemaless_insert([input_sql], TDSmlProtocolType.LINE.value, TDSmlTimestampType.SECOND.value)
        res = tdSql.query(f'select * from {stb_name}', True)
        tdSql.checkEqual(str(res[0][0]), "2021-10-20 20:08:14")
        input_sql = f'{tdCom.getLongName(len=10, mode="letters")},t0=127,t1=32767I16,t2=2147483647I32,t3=9223372036854775807,t4=11.12345027923584F32,t5=22.123456789F64 c0=127,c1=32767I16,c2=2147483647I32,c3=9223372036854775807,c4=11.12345027923584F32,c5=22.123456789F64 1634731695'
        stb_name = input_sql.split(",")[0]
        self._conn.schemaless_insert([input_sql], TDSmlProtocolType.LINE.value, TDSmlTimestampType.SECOND.value)
        res = tdSql.query(f'select * from {stb_name}', True)
        tdSql.checkEqual(str(res[0][0]), "2021-10-20 20:08:15")

        input_sql = f'{tdCom.getLongName(len=10, mode="letters")},t0=127,t1=32767I16,t2=2147483647I32,t3=9223372036854775807,t4=11.12345027923584F32,t5=22.123456789F64 c0=127,c1=32767I16,c2=2147483647I32,c3=9223372036854775807,c4=11.12345027923584F32,c5=22.123456789F64 1634731684002'
        stb_name = input_sql.split(",")[0]
        self._conn.schemaless_insert([input_sql], TDSmlProtocolType.LINE.value, TDSmlTimestampType.MILLI_SECOND.value)
        res = tdSql.query(f'select * from {stb_name}', True)
        tdSql.checkEqual(str(res[0][0]), "2021-10-20 20:08:04.002000")
        input_sql = f'{tdCom.getLongName(len=10, mode="letters")},t0=127,t1=32767I16,t2=2147483647I32,t3=9223372036854775807,t4=11.12345027923584F32,t5=22.123456789F64 c0=127,c1=32767I16,c2=2147483647I32,c3=9223372036854775807,c4=11.12345027923584F32,c5=22.123456789F64 1634731684003'
        stb_name = input_sql.split(",")[0]
        self._conn.schemaless_insert([input_sql], TDSmlProtocolType.LINE.value, TDSmlTimestampType.MILLI_SECOND.value)
        res = tdSql.query(f'select * from {stb_name}', True)
        tdSql.checkEqual(str(res[0][0]), "2021-10-20 20:08:04.003000")

        input_sql = f'{tdCom.getLongName(len=10, mode="letters")},t0=127,t1=32767I16,t2=2147483647I32,t3=9223372036854775807,t4=11.12345027923584F32,t5=22.123456789F64 c0=127,c1=32767I16,c2=2147483647I32,c3=9223372036854775807,c4=11.12345027923584F32,c5=22.123456789F64 1634731684000001'
        stb_name = input_sql.split(",")[0]
        self._conn.schemaless_insert([input_sql], TDSmlProtocolType.LINE.value, TDSmlTimestampType.MICRO_SECOND.value)
        res = tdSql.query(f'select * from {stb_name}', True)
        tdSql.checkEqual(str(res[0][0]), "2021-10-20 20:08:04.000001")
        input_sql = f'{tdCom.getLongName(len=10, mode="letters")},t0=127,t1=32767I16,t2=2147483647I32,t3=9223372036854775807,t4=11.12345027923584F32,t5=22.123456789F64 c0=127,c1=32767I16,c2=2147483647I32,c3=9223372036854775807,c4=11.12345027923584F32,c5=22.123456789F64 1634731684000002'
        stb_name = input_sql.split(",")[0]
        self._conn.schemaless_insert([input_sql], TDSmlProtocolType.LINE.value, TDSmlTimestampType.MICRO_SECOND.value)
        res = tdSql.query(f'select * from {stb_name}', True)
        tdSql.checkEqual(str(res[0][0]), "2021-10-20 20:08:04.000002")

        input_sql = f'{tdCom.getLongName(len=10, mode="letters")},t0=127,t1=32767I16,t2=2147483647I32,t3=9223372036854775807,t4=11.12345027923584F32,t5=22.123456789F64 c0=127,c1=32767I16,c2=2147483647I32,c3=9223372036854775807,c4=11.12345027923584F32,c5=22.123456789F64 1626006833639000000'
        stb_name = input_sql.split(",")[0]
        self._conn.schemaless_insert([input_sql], TDSmlProtocolType.LINE.value, TDSmlTimestampType.NANO_SECOND.value)
        res = tdSql.query(f'select * from {stb_name}', True)
        tdSql.checkEqual(str(res[0][0]), "2021-07-11 20:33:53.639000")
        input_sql = f'{tdCom.getLongName(len=10, mode="letters")},t0=127,t1=32767I16,t2=2147483647I32,t3=9223372036854775807,t4=11.12345027923584F32,t5=22.123456789F64 c0=127,c1=32767I16,c2=2147483647I32,c3=9223372036854775807,c4=11.12345027923584F32,c5=22.123456789F64 1626007833639000000'
        stb_name = input_sql.split(",")[0]
        self._conn.schemaless_insert([input_sql], TDSmlProtocolType.LINE.value, TDSmlTimestampType.NANO_SECOND.value)
        res = tdSql.query(f'select * from {stb_name}', True)
        tdSql.checkEqual(str(res[0][0]), "2021-07-11 20:50:33.639000")

    def iuCheckCase(self):
J
jiajingbin 已提交
508
        tdLog.info(f'{sys._getframe().f_code.co_name}() function is running')
J
jiajingbin 已提交
509 510 511 512
        tdCom.cleanTb()
        input_sql = f'{tdCom.getLongName(len=10, mode="letters")},t0=127 c1=9223372036854775807i,c2=1u 0'
        stb_name = input_sql.split(",")[0]
        self._conn.schemaless_insert([input_sql], TDSmlProtocolType.LINE.value, TDSmlTimestampType.NANO_SECOND.value)
J
jiajingbin 已提交
513
        tdSql.query(f'describe {stb_name}', True)
J
jiajingbin 已提交
514 515 516
        tdSql.checkData(1, 1, "BIGINT")
        tdSql.checkData(2, 1, "BIGINT UNSIGNED")

J
jiajingbin 已提交
517 518 519 520 521
    def idSeqCheckCase(self):
        """
            check id.index in tags
            eg: t0=**,id=**,t1=**
        """
J
jiajingbin 已提交
522
        tdLog.info(f'{sys._getframe().f_code.co_name}() function is running')
J
jiajingbin 已提交
523
        tdCom.cleanTb()
J
jiajingbin 已提交
524
        input_sql, stb_name = self.genFullTypeSql(id_change_tag=True)
J
jiajingbin 已提交
525 526
        self.resCmp(input_sql, stb_name)
    
J
jiajingbin 已提交
527
    def idLetterCheckCase(self):
J
jiajingbin 已提交
528 529 530 531
        """
            check id param
            eg: id and ID
        """
J
jiajingbin 已提交
532
        tdLog.info(f'{sys._getframe().f_code.co_name}() function is running')
J
jiajingbin 已提交
533
        tdCom.cleanTb()
J
jiajingbin 已提交
534
        input_sql, stb_name = self.genFullTypeSql(id_upper_tag=True)
J
jiajingbin 已提交
535
        self.resCmp(input_sql, stb_name)
J
jiajingbin 已提交
536 537
        input_sql, stb_name = self.genFullTypeSql(id_mixul_tag=True)
        self.resCmp(input_sql, stb_name)
J
jiajingbin 已提交
538
        input_sql, stb_name = self.genFullTypeSql(id_change_tag=True, id_upper_tag=True)
J
jiajingbin 已提交
539 540 541 542 543 544
        self.resCmp(input_sql, stb_name)

    def noIdCheckCase(self):
        """
            id not exist
        """
J
jiajingbin 已提交
545
        tdLog.info(f'{sys._getframe().f_code.co_name}() function is running')
J
jiajingbin 已提交
546
        tdCom.cleanTb()
J
jiajingbin 已提交
547
        input_sql, stb_name = self.genFullTypeSql(id_noexist_tag=True)
J
jiajingbin 已提交
548 549 550 551 552 553 554 555 556 557 558
        self.resCmp(input_sql, stb_name)
        query_sql = f"select tbname from {stb_name}"
        res_row_list = self.resHandle(query_sql, True)[0]
        if len(res_row_list[0][0]) > 0:
            tdSql.checkColNameList(res_row_list, res_row_list)
        else:
            tdSql.checkColNameList(res_row_list, "please check noIdCheckCase")

    def maxColTagCheckCase(self):
        """
            max tag count is 128
J
jiajingbin 已提交
559
            max col count is 4096
J
jiajingbin 已提交
560
        """
J
jiajingbin 已提交
561
        tdLog.info(f'{sys._getframe().f_code.co_name}() function is running')
J
save  
jiajingbin 已提交
562
        for input_sql in [self.genLongSql(128, 1)[0], self.genLongSql(1, 4094)[0]]:
J
jiajingbin 已提交
563
            tdCom.cleanTb()
564
            self._conn.schemaless_insert([input_sql], TDSmlProtocolType.LINE.value, TDSmlTimestampType.NANO_SECOND.value)
J
save  
jiajingbin 已提交
565
        for input_sql in [self.genLongSql(129, 1)[0], self.genLongSql(1, 4095)[0]]:
J
jiajingbin 已提交
566
            tdCom.cleanTb()
567
            try:
568
                self._conn.schemaless_insert([input_sql], TDSmlProtocolType.LINE.value, TDSmlTimestampType.NANO_SECOND.value)
J
jiajingbin 已提交
569 570 571
                raise Exception("should not reach here")
            except SchemalessError as err:
                tdSql.checkNotEqual(err.errno, 0)
572
            
J
jiajingbin 已提交
573
    def stbTbNameCheckCase(self):
J
jiajingbin 已提交
574 575
        """
            test illegal id name
J
jiajingbin 已提交
576
            mix "~!@#$¥%^&*()-+={}|[]、「」【】\:;《》<>?"
J
jiajingbin 已提交
577
        """
J
jiajingbin 已提交
578
        tdLog.info(f'{sys._getframe().f_code.co_name}() function is running')
J
jiajingbin 已提交
579 580
        tdCom.cleanTb()
        rstr = list("~!@#$¥%^&*()-+=|[]、「」【】\;:《》<>?")
J
jiajingbin 已提交
581
        for i in rstr:
J
jiajingbin 已提交
582 583 584 585
            stb_name=f"aaa{i}bbb"
            input_sql = self.genFullTypeSql(stb_name=stb_name, tb_name=f'{stb_name}_sub')[0]
            self.resCmp(input_sql, f'`{stb_name}`')
            tdSql.execute(f'drop table if exists `{stb_name}`')
J
jiajingbin 已提交
586 587 588 589 590

    def idStartWithNumCheckCase(self):
        """
            id is start with num
        """
J
jiajingbin 已提交
591
        tdLog.info(f'{sys._getframe().f_code.co_name}() function is running')
J
jiajingbin 已提交
592 593 594
        tdCom.cleanTb()
        input_sql, stb_name = self.genFullTypeSql(tb_name="1aaabbb")
        self.resCmp(input_sql, stb_name)
J
jiajingbin 已提交
595 596 597 598 599

    def nowTsCheckCase(self):
        """
            check now unsupported
        """
J
jiajingbin 已提交
600
        tdLog.info(f'{sys._getframe().f_code.co_name}() function is running')
J
jiajingbin 已提交
601
        tdCom.cleanTb()
J
jiajingbin 已提交
602
        input_sql = self.genFullTypeSql(ts="now")[0]
603
        try:
604
            self._conn.schemaless_insert([input_sql], TDSmlProtocolType.LINE.value, TDSmlTimestampType.NANO_SECOND.value)
J
jiajingbin 已提交
605 606 607
            raise Exception("should not reach here")
        except SchemalessError as err:
            tdSql.checkNotEqual(err.errno, 0)
J
jiajingbin 已提交
608 609 610 611 612

    def dateFormatTsCheckCase(self):
        """
            check date format ts unsupported
        """
J
jiajingbin 已提交
613
        tdLog.info(f'{sys._getframe().f_code.co_name}() function is running')
J
jiajingbin 已提交
614
        tdCom.cleanTb()
J
jiajingbin 已提交
615
        input_sql = self.genFullTypeSql(ts="2021-07-21\ 19:01:46.920")[0]
616
        try:
617
            self._conn.schemaless_insert([input_sql], TDSmlProtocolType.LINE.value, TDSmlTimestampType.NANO_SECOND.value)
J
jiajingbin 已提交
618 619 620
            raise Exception("should not reach here")
        except SchemalessError as err:
            tdSql.checkNotEqual(err.errno, 0)
J
jiajingbin 已提交
621 622 623 624 625
    
    def illegalTsCheckCase(self):
        """
            check ts format like 16260068336390us19
        """
J
jiajingbin 已提交
626
        tdLog.info(f'{sys._getframe().f_code.co_name}() function is running')
J
jiajingbin 已提交
627
        tdCom.cleanTb()
J
jiajingbin 已提交
628
        input_sql = self.genFullTypeSql(ts="16260068336390us19")[0]
629
        try:
630
            self._conn.schemaless_insert([input_sql], TDSmlProtocolType.LINE.value, TDSmlTimestampType.NANO_SECOND.value)
J
jiajingbin 已提交
631 632
        except SchemalessError as err:
            tdSql.checkNotEqual(err.errno, 0)
J
jiajingbin 已提交
633

J
jiajingbin 已提交
634
    def tbnameCheckCase(self):
J
jiajingbin 已提交
635
        """
J
jiajingbin 已提交
636 637 638 639
            check length 192
            check upper tbname
            chech upper tag
            length of stb_name tb_name <= 192
J
jiajingbin 已提交
640
        """
J
jiajingbin 已提交
641 642
        tdLog.info(f'{sys._getframe().f_code.co_name}() function is running')
        tdCom.cleanTb()
J
jiajingbin 已提交
643 644 645 646 647 648 649
        stb_name_192 = tdCom.getLongName(len=192, mode="letters")
        tb_name_192 = tdCom.getLongName(len=192, mode="letters")
        input_sql, stb_name = self.genFullTypeSql(stb_name=stb_name_192, tb_name=tb_name_192)
        self.resCmp(input_sql, stb_name)
        tdSql.query(f'select * from {stb_name}')
        tdSql.checkRows(1)
        for input_sql in [self.genFullTypeSql(stb_name=tdCom.getLongName(len=193, mode="letters"), tb_name=tdCom.getLongName(len=5, mode="letters"))[0], self.genFullTypeSql(tb_name=tdCom.getLongName(len=193, mode="letters"))[0]]:
650
            try:
651
                self._conn.schemaless_insert([input_sql], TDSmlProtocolType.LINE.value, TDSmlTimestampType.NANO_SECOND.value)
652
                raise Exception("should not reach here")
653
            except SchemalessError as err:
654
                tdSql.checkNotEqual(err.errno, 0)
J
jiajingbin 已提交
655

J
jiajingbin 已提交
656 657 658
        input_sql = 'Abcdffgg,id=Abcddd,T1=127i8 c0=False 1626006833639000000'
        stb_name = "Abcdffgg"
        self.resCmp(input_sql, stb_name)
J
jiajingbin 已提交
659

J
jiajingbin 已提交
660 661 662 663
    def tagValueLengthCheckCase(self):
        """
            check full type tag value limit
        """
J
jiajingbin 已提交
664
        tdLog.info(f'{sys._getframe().f_code.co_name}() function is running')
J
jiajingbin 已提交
665
        tdCom.cleanTb()
J
save  
jiajingbin 已提交
666 667
        # nchar
        # * legal nchar could not be larger than 16374/4
J
jiajingbin 已提交
668 669
        stb_name = tdCom.getLongName(7, "letters")
        input_sql = f'{stb_name},t0=t,t1={tdCom.getLongName(4093, "letters")} c0=f 1626006833639000000'
670
        self._conn.schemaless_insert([input_sql], TDSmlProtocolType.LINE.value, TDSmlTimestampType.NANO_SECOND.value)
J
jiajingbin 已提交
671
        input_sql = f'{stb_name},t0=t,t1={tdCom.getLongName(4094, "letters")} c0=f 1626006833639000000'
672
        try:
673
            self._conn.schemaless_insert([input_sql], TDSmlProtocolType.LINE.value, TDSmlTimestampType.NANO_SECOND.value)
674
            raise Exception("should not reach here")
675
        except SchemalessError as err:
676
            tdSql.checkNotEqual(err.errno, 0)
J
jiajingbin 已提交
677

J
jiajingbin 已提交
678 679 680 681
    def colValueLengthCheckCase(self):
        """
            check full type col value limit
        """
J
jiajingbin 已提交
682
        tdLog.info(f'{sys._getframe().f_code.co_name}() function is running')
J
jiajingbin 已提交
683
        tdCom.cleanTb()
J
save  
jiajingbin 已提交
684 685
        # i8
        for c1 in ["-127i8", "127i8"]:
J
jiajingbin 已提交
686
            input_sql, stb_name = self.genFullTypeSql(c1=c1)
J
save  
jiajingbin 已提交
687 688 689 690
            self.resCmp(input_sql, stb_name)

        for c1 in ["-128i8", "128i8"]:
            input_sql = self.genFullTypeSql(c1=c1)[0]
691
            try:
692
                self._conn.schemaless_insert([input_sql], TDSmlProtocolType.LINE.value, TDSmlTimestampType.NANO_SECOND.value)
693
                raise Exception("should not reach here")
694
            except SchemalessError as err:
695
                tdSql.checkNotEqual(err.errno, 0)
J
save  
jiajingbin 已提交
696 697
        # i16
        for c2 in ["-32767i16"]:
J
jiajingbin 已提交
698
            input_sql, stb_name = self.genFullTypeSql(c2=c2)
J
save  
jiajingbin 已提交
699 700 701
            self.resCmp(input_sql, stb_name)
        for c2 in ["-32768i16", "32768i16"]:
            input_sql = self.genFullTypeSql(c2=c2)[0]
702
            try:
703
                self._conn.schemaless_insert([input_sql], TDSmlProtocolType.LINE.value, TDSmlTimestampType.NANO_SECOND.value)
704
                raise Exception("should not reach here")
705
            except SchemalessError as err:
706
                tdSql.checkNotEqual(err.errno, 0)
J
save  
jiajingbin 已提交
707 708 709

        # i32
        for c3 in ["-2147483647i32"]:
J
jiajingbin 已提交
710
            input_sql, stb_name = self.genFullTypeSql(c3=c3)
J
save  
jiajingbin 已提交
711 712 713
            self.resCmp(input_sql, stb_name)
        for c3 in ["-2147483648i32", "2147483648i32"]:
            input_sql = self.genFullTypeSql(c3=c3)[0]
714
            try:
715
                self._conn.schemaless_insert([input_sql], TDSmlProtocolType.LINE.value, TDSmlTimestampType.NANO_SECOND.value)
716
                raise Exception("should not reach here")
717
            except SchemalessError as err:
718
                tdSql.checkNotEqual(err.errno, 0)
J
save  
jiajingbin 已提交
719 720 721

        # i64
        for c4 in ["-9223372036854775807i64"]:
J
jiajingbin 已提交
722
            input_sql, stb_name = self.genFullTypeSql(c4=c4)
J
save  
jiajingbin 已提交
723 724 725
            self.resCmp(input_sql, stb_name)
        for c4 in ["-9223372036854775808i64", "9223372036854775808i64"]:
            input_sql = self.genFullTypeSql(c4=c4)[0]
726
            try:
727
                self._conn.schemaless_insert([input_sql], TDSmlProtocolType.LINE.value, TDSmlTimestampType.NANO_SECOND.value)
728
                raise Exception("should not reach here")
729
            except SchemalessError as err:
730
                tdSql.checkNotEqual(err.errno, 0)
J
save  
jiajingbin 已提交
731 732 733

        # f32       
        for c5 in [f"{-3.4028234663852885981170418348451692544*(10**38)}f32", f"{3.4028234663852885981170418348451692544*(10**38)}f32"]:
J
jiajingbin 已提交
734
            input_sql, stb_name = self.genFullTypeSql(c5=c5)
J
save  
jiajingbin 已提交
735 736 737 738
            self.resCmp(input_sql, stb_name)
        # * limit set to 4028234664*(10**38)
        for c5 in [f"{-3.4028234664*(10**38)}f32", f"{3.4028234664*(10**38)}f32"]:
            input_sql = self.genFullTypeSql(c5=c5)[0]
739
            try:
740
                self._conn.schemaless_insert([input_sql], TDSmlProtocolType.LINE.value, TDSmlTimestampType.NANO_SECOND.value)
741
                raise Exception("should not reach here")
742
            except SchemalessError as err:
743
                tdSql.checkNotEqual(err.errno, 0)
J
save  
jiajingbin 已提交
744 745 746

        # f64
        for c6 in [f'{-1.79769313486231570814527423731704356798070567525844996598917476803157260780*(10**308)}f64', f'{-1.79769313486231570814527423731704356798070567525844996598917476803157260780*(10**308)}f64']:
J
jiajingbin 已提交
747
            input_sql, stb_name = self.genFullTypeSql(c6=c6)
J
save  
jiajingbin 已提交
748 749 750 751
            self.resCmp(input_sql, stb_name)
        # * limit set to 1.797693134862316*(10**308)
        for c6 in [f'{-1.797693134862316*(10**308)}f64', f'{-1.797693134862316*(10**308)}f64']:
            input_sql = self.genFullTypeSql(c6=c6)[0]
752
            try:
753
                self._conn.schemaless_insert([input_sql], TDSmlProtocolType.LINE.value, TDSmlTimestampType.NANO_SECOND.value)
754
                raise Exception("should not reach here")
755
            except SchemalessError as err:
756
                tdSql.checkNotEqual(err.errno, 0)
J
jiajingbin 已提交
757

J
save  
jiajingbin 已提交
758
        # # binary 
J
jiajingbin 已提交
759 760
        stb_name = tdCom.getLongName(7, "letters")
        input_sql = f'{stb_name},t0=t c0=f,c1="{tdCom.getLongName(16374, "letters")}" 1626006833639000000'
761
        self._conn.schemaless_insert([input_sql], TDSmlProtocolType.LINE.value, TDSmlTimestampType.NANO_SECOND.value)
J
jiajingbin 已提交
762
        input_sql = f'{stb_name},t0=t c0=f,c1="{tdCom.getLongName(16375, "letters")}" 1626006833639000000'
763
        try:
764
            self._conn.schemaless_insert([input_sql], TDSmlProtocolType.LINE.value, TDSmlTimestampType.NANO_SECOND.value)
765
            raise Exception("should not reach here")
766
        except SchemalessError as err:
767
            tdSql.checkNotEqual(err.errno, 0)
J
jiajingbin 已提交
768 769 770

        # nchar
        # * legal nchar could not be larger than 16374/4
J
jiajingbin 已提交
771 772
        stb_name = tdCom.getLongName(7, "letters")
        input_sql = f'{stb_name},t0=t c0=f,c1=L"{tdCom.getLongName(4093, "letters")}" 1626006833639000000'
773
        self._conn.schemaless_insert([input_sql], TDSmlProtocolType.LINE.value, TDSmlTimestampType.NANO_SECOND.value)
774

J
jiajingbin 已提交
775
        input_sql = f'{stb_name},t0=t c0=f,c1=L"{tdCom.getLongName(4094, "letters")}" 1626006833639000000'
776
        try:
777
            self._conn.schemaless_insert([input_sql], TDSmlProtocolType.LINE.value, TDSmlTimestampType.NANO_SECOND.value)
778
            raise Exception("should not reach here")
779
        except SchemalessError as err:
780
            tdSql.checkNotEqual(err.errno, 0)
J
jiajingbin 已提交
781 782

    def tagColIllegalValueCheckCase(self):
J
jiajingbin 已提交
783

J
jiajingbin 已提交
784 785 786
        """
            test illegal tag col value
        """
J
jiajingbin 已提交
787
        tdLog.info(f'{sys._getframe().f_code.co_name}() function is running')
J
jiajingbin 已提交
788
        tdCom.cleanTb()
J
jiajingbin 已提交
789 790
        # bool
        for i in ["TrUe", "tRue", "trUe", "truE", "FalsE", "fAlse", "faLse", "falSe", "falsE"]:
J
jiajingbin 已提交
791 792 793 794
            input_sql1, stb_name = self.genFullTypeSql(t0=i)
            self.resCmp(input_sql1, stb_name)
            input_sql2, stb_name = self.genFullTypeSql(c0=i)
            self.resCmp(input_sql2, stb_name)
J
jiajingbin 已提交
795 796 797 798 799 800 801 802 803 804 805

        # i8 i16 i32 i64 f32 f64
        for input_sql in [
                self.genFullTypeSql(c1="1s2i8")[0], 
                self.genFullTypeSql(c2="1s2i16")[0],
                self.genFullTypeSql(c3="1s2i32")[0],
                self.genFullTypeSql(c4="1s2i64")[0],
                self.genFullTypeSql(c5="11.1s45f32")[0],
                self.genFullTypeSql(c6="11.1s45f64")[0],
                self.genFullTypeSql(c9="1s1u64")[0]
            ]:
806
            try:
807
                self._conn.schemaless_insert([input_sql], TDSmlProtocolType.LINE.value, TDSmlTimestampType.NANO_SECOND.value)
808
                raise Exception("should not reach here")
809
            except SchemalessError as err:
810
                tdSql.checkNotEqual(err.errno, 0)
J
modify  
jiajingbin 已提交
811

812
        # check binary and nchar blank
J
jiajingbin 已提交
813 814 815 816 817
        stb_name = tdCom.getLongName(7, "letters")
        input_sql1 = f'{stb_name}_1,t0=t c0=f,c1="abc aaa" 1626006833639000000'
        input_sql2 = f'{stb_name}_2,t0=t c0=f,c1=L"abc aaa" 1626006833639000000'
        input_sql3 = f'{stb_name}_3,t0=t,t1="abc aaa" c0=f 1626006833639000000'
        input_sql4 = f'{stb_name}_4,t0=t,t1=L"abc aaa" c0=f 1626006833639000000'
818
        for input_sql in [input_sql1, input_sql2, input_sql3, input_sql4]:
J
jiajingbin 已提交
819
            self._conn.schemaless_insert([input_sql], TDSmlProtocolType.LINE.value, TDSmlTimestampType.NANO_SECOND.value)
820 821 822 823

        # check accepted binary and nchar symbols 
        # # * ~!@#$¥%^&*()-+={}|[]、「」:;
        for symbol in list('~!@#$¥%^&*()-+={}|[]、「」:;'):
J
jiajingbin 已提交
824 825 826 827
            input_sql1 = f'{stb_name},t0=t c0=f,c1="abc{symbol}aaa" 1626006833639000000'
            input_sql2 = f'{stb_name},t0=t,t1="abc{symbol}aaa" c0=f 1626006833639000000'
            self._conn.schemaless_insert([input_sql1], TDSmlProtocolType.LINE.value, None)
            self._conn.schemaless_insert([input_sql2], TDSmlProtocolType.LINE.value, None)
J
jiajingbin 已提交
828 829 830 831 832

    def duplicateIdTagColInsertCheckCase(self):
        """
            check duplicate Id Tag Col
        """
J
jiajingbin 已提交
833
        tdLog.info(f'{sys._getframe().f_code.co_name}() function is running')
J
jiajingbin 已提交
834
        tdCom.cleanTb()
J
jiajingbin 已提交
835
        input_sql_id = self.genFullTypeSql(id_double_tag=True)[0]
836
        try:
J
jiajingbin 已提交
837
            self._conn.schemaless_insert([input_sql_id], TDSmlProtocolType.LINE.value, None)
838
            raise Exception("should not reach here")
839
        except SchemalessError as err:
840
            tdSql.checkNotEqual(err.errno, 0)
J
jiajingbin 已提交
841 842 843

        input_sql = self.genFullTypeSql()[0]
        input_sql_tag = input_sql.replace("t5", "t6")
844
        try:
J
jiajingbin 已提交
845
            self._conn.schemaless_insert([input_sql_tag], TDSmlProtocolType.LINE.value, None)
846
            raise Exception("should not reach here")
847
        except SchemalessError as err:
848
            tdSql.checkNotEqual(err.errno, 0)
J
jiajingbin 已提交
849 850 851

        input_sql = self.genFullTypeSql()[0]
        input_sql_col = input_sql.replace("c5", "c6")
852
        try:
J
jiajingbin 已提交
853
            self._conn.schemaless_insert([input_sql_col], TDSmlProtocolType.LINE.value, None)
854
            raise Exception("should not reach here")
855
        except SchemalessError as err:
856
            tdSql.checkNotEqual(err.errno, 0)
J
jiajingbin 已提交
857 858 859

        input_sql = self.genFullTypeSql()[0]
        input_sql_col = input_sql.replace("c5", "C6")
860
        try:
J
jiajingbin 已提交
861
            self._conn.schemaless_insert([input_sql_col], TDSmlProtocolType.LINE.value, None)
862
            raise Exception("should not reach here")
863
        except SchemalessError as err:
864
            tdSql.checkNotEqual(err.errno, 0)
J
jiajingbin 已提交
865 866 867 868 869 870

    ##### stb exist #####
    def noIdStbExistCheckCase(self):
        """
            case no id when stb exist
        """
J
jiajingbin 已提交
871
        tdLog.info(f'{sys._getframe().f_code.co_name}() function is running')
J
jiajingbin 已提交
872
        tdCom.cleanTb()
873
        input_sql, stb_name = self.genFullTypeSql(tb_name="sub_table_0123456", t0="f", c0="f")
J
jiajingbin 已提交
874
        self.resCmp(input_sql, stb_name)
J
jiajingbin 已提交
875
        input_sql, stb_name = self.genFullTypeSql(stb_name=stb_name, id_noexist_tag=True, t0="f", c0="f")
J
jiajingbin 已提交
876 877 878 879 880 881 882 883
        self.resCmp(input_sql, stb_name, condition='where tbname like "t_%"')
        tdSql.query(f"select * from {stb_name}")
        tdSql.checkRows(2)

    def duplicateInsertExistCheckCase(self):
        """
            check duplicate insert when stb exist
        """
J
jiajingbin 已提交
884
        tdLog.info(f'{sys._getframe().f_code.co_name}() function is running')
J
jiajingbin 已提交
885
        tdCom.cleanTb()
J
jiajingbin 已提交
886
        input_sql, stb_name = self.genFullTypeSql()
J
jiajingbin 已提交
887
        self.resCmp(input_sql, stb_name)
888
        self._conn.schemaless_insert([input_sql], TDSmlProtocolType.LINE.value, TDSmlTimestampType.NANO_SECOND.value)
J
jiajingbin 已提交
889 890 891 892 893 894
        self.resCmp(input_sql, stb_name)

    def tagColBinaryNcharLengthCheckCase(self):
        """
            check length increase
        """
J
jiajingbin 已提交
895
        tdLog.info(f'{sys._getframe().f_code.co_name}() function is running')
J
jiajingbin 已提交
896
        tdCom.cleanTb()
J
jiajingbin 已提交
897
        input_sql, stb_name = self.genFullTypeSql()
J
jiajingbin 已提交
898
        self.resCmp(input_sql, stb_name)
J
jiajingbin 已提交
899 900
        tb_name = tdCom.getLongName(5, "letters")
        input_sql, stb_name = self.genFullTypeSql(stb_name=stb_name, tb_name=tb_name, t7="\"binaryTagValuebinaryTagValue\"", t8="L\"ncharTagValuencharTagValue\"", c7="\"binaryTagValuebinaryTagValue\"", c8="L\"ncharTagValuencharTagValue\"")
J
jiajingbin 已提交
901 902 903 904 905
        self.resCmp(input_sql, stb_name, condition=f'where tbname like "{tb_name}"')

    def tagColAddDupIDCheckCase(self):
        """
            check column and tag count add, stb and tb duplicate
J
jiajingbin 已提交
906 907 908 909 910
            * tag: alter table ...
            * col: when update==0 and ts is same, unchange
            * so this case tag&&value will be added, 
            * col is added without value when update==0
            * col is added with value when update==1
J
jiajingbin 已提交
911
        """
J
jiajingbin 已提交
912
        tdLog.info(f'{sys._getframe().f_code.co_name}() function is running')
J
jiajingbin 已提交
913 914
        tdCom.cleanTb()
        tb_name = tdCom.getLongName(7, "letters")
J
jiajingbin 已提交
915 916 917
        for db_update_tag in [0, 1]:
            if db_update_tag == 1 :
                self.createDb("test_update", db_update_tag=db_update_tag)
J
jiajingbin 已提交
918
            input_sql, stb_name = self.genFullTypeSql(tb_name=tb_name, t0="t", c0="t")
J
jiajingbin 已提交
919
            self.resCmp(input_sql, stb_name)
J
jiajingbin 已提交
920
            input_sql, stb_name = self.genFullTypeSql(stb_name=stb_name, tb_name=tb_name, t0="t", c0="f", ct_add_tag=True)
J
jiajingbin 已提交
921 922
            if db_update_tag == 1 :
                self.resCmp(input_sql, stb_name, condition=f'where tbname like "{tb_name}"', none_check_tag=True)
J
jiajingbin 已提交
923 924 925 926 927 928 929 930 931 932 933 934 935 936
                tdSql.query(f'select * from {stb_name} where tbname like "{tb_name}"')
                tdSql.checkData(0, 11, "ncharColValue")  
                tdSql.checkData(0, 12, True)  
                tdSql.checkData(0, 22, None)  
                tdSql.checkData(0, 23, None)  
            else:
                self._conn.schemaless_insert([input_sql], TDSmlProtocolType.LINE.value, TDSmlTimestampType.NANO_SECOND.value)
                tdSql.query(f'select * from {stb_name} where tbname like "{tb_name}"')
                tdSql.checkData(0, 1, True)  
                tdSql.checkData(0, 11, None)  
                tdSql.checkData(0, 12, None)  
                tdSql.checkData(0, 22, None)  
                tdSql.checkData(0, 23, None)  
            self.createDb()
J
jiajingbin 已提交
937

J
jiajingbin 已提交
938 939 940 941
    def tagColAddCheckCase(self):
        """
            check column and tag count add
        """
J
jiajingbin 已提交
942
        tdLog.info(f'{sys._getframe().f_code.co_name}() function is running')
J
jiajingbin 已提交
943 944
        tdCom.cleanTb()
        tb_name = tdCom.getLongName(7, "letters")
J
jiajingbin 已提交
945
        input_sql, stb_name = self.genFullTypeSql(tb_name=tb_name, t0="f", c0="f")
J
jiajingbin 已提交
946
        self.resCmp(input_sql, stb_name)
J
jiajingbin 已提交
947
        tb_name_1 = tdCom.getLongName(7, "letters")
J
jiajingbin 已提交
948
        input_sql, stb_name = self.genFullTypeSql(stb_name=stb_name, tb_name=tb_name_1, t0="f", c0="f", ct_add_tag=True)
J
jiajingbin 已提交
949 950 951 952 953 954 955 956 957 958
        self.resCmp(input_sql, stb_name, condition=f'where tbname like "{tb_name_1}"')
        res_row_list = self.resHandle(f"select c10,c11,t10,t11 from {tb_name}", True)[0]
        tdSql.checkEqual(res_row_list[0], ['None', 'None', 'None', 'None'])
        self.resCmp(input_sql, stb_name, condition=f'where tbname like "{tb_name}"', none_check_tag=True)

    def tagMd5Check(self):
        """
            condition: stb not change
            insert two table, keep tag unchange, change col
        """
J
jiajingbin 已提交
959
        tdLog.info(f'{sys._getframe().f_code.co_name}() function is running')
J
jiajingbin 已提交
960
        tdCom.cleanTb()
J
jiajingbin 已提交
961
        input_sql, stb_name = self.genFullTypeSql(t0="f", c0="f", id_noexist_tag=True)
J
jiajingbin 已提交
962 963
        self.resCmp(input_sql, stb_name)
        tb_name1 = self.getNoIdTbName(stb_name)
J
jiajingbin 已提交
964
        input_sql, stb_name = self.genFullTypeSql(stb_name=stb_name, t0="f", c0="f", id_noexist_tag=True)
J
jiajingbin 已提交
965 966 967 968 969
        self.resCmp(input_sql, stb_name)
        tb_name2 = self.getNoIdTbName(stb_name)
        tdSql.query(f"select * from {stb_name}")
        tdSql.checkRows(1)
        tdSql.checkEqual(tb_name1, tb_name2)
J
jiajingbin 已提交
970
        input_sql, stb_name = self.genFullTypeSql(stb_name=stb_name, t0="f", c0="f", id_noexist_tag=True, ct_add_tag=True)
971
        self._conn.schemaless_insert([input_sql], TDSmlProtocolType.LINE.value, TDSmlTimestampType.NANO_SECOND.value)
J
jiajingbin 已提交
972 973 974 975 976
        tb_name3 = self.getNoIdTbName(stb_name)
        tdSql.query(f"select * from {stb_name}")
        tdSql.checkRows(2)
        tdSql.checkNotEqual(tb_name1, tb_name3)

J
modify  
jiajingbin 已提交
977
    # * tag binary max is 16384, col+ts binary max  49151
J
jiajingbin 已提交
978
    def tagColBinaryMaxLengthCheckCase(self):
J
save  
jiajingbin 已提交
979
        """
980
            every binary and nchar must be length+2
J
save  
jiajingbin 已提交
981
        """
J
jiajingbin 已提交
982
        tdLog.info(f'{sys._getframe().f_code.co_name}() function is running')
J
jiajingbin 已提交
983 984
        tdCom.cleanTb()
        stb_name = tdCom.getLongName(7, "letters")
J
jiajingbin 已提交
985
        tb_name = f'{stb_name}_1'
J
jiajingbin 已提交
986
        input_sql = f'{stb_name},id={tb_name},t0=t c0=f 1626006833639000000'
987
        self._conn.schemaless_insert([input_sql], TDSmlProtocolType.LINE.value, TDSmlTimestampType.NANO_SECOND.value)
J
save  
jiajingbin 已提交
988

J
save  
jiajingbin 已提交
989
        # # * check col,col+ts max in describe ---> 16143
J
jiajingbin 已提交
990
        input_sql = f'{stb_name},t0=t c0=f,c1="{tdCom.getLongName(16374, "letters")}",c2="{tdCom.getLongName(16374, "letters")}",c3="{tdCom.getLongName(16374, "letters")}",c4="{tdCom.getLongName(12, "letters")}" 1626006833639000000'
991
        self._conn.schemaless_insert([input_sql], TDSmlProtocolType.LINE.value, TDSmlTimestampType.NANO_SECOND.value)
992

J
modify  
jiajingbin 已提交
993
        tdSql.query(f"select * from {stb_name}")
J
jiajingbin 已提交
994 995
        tdSql.checkRows(2)
        input_sql = f'{stb_name},t0=t c0=f,c1="{tdCom.getLongName(16374, "letters")}",c2="{tdCom.getLongName(16374, "letters")}",c3="{tdCom.getLongName(16374, "letters")}",c4="{tdCom.getLongName(13, "letters")}" 1626006833639000000'
996
        try:
997
            self._conn.schemaless_insert([input_sql], TDSmlProtocolType.LINE.value, TDSmlTimestampType.NANO_SECOND.value)
998
            raise Exception("should not reach here")
999
        except SchemalessError as err:
1000
            tdSql.checkNotEqual(err.errno, 0)
J
modify  
jiajingbin 已提交
1001
        tdSql.query(f"select * from {stb_name}")
J
jiajingbin 已提交
1002
        tdSql.checkRows(2)
J
jiajingbin 已提交
1003
    
J
modify  
jiajingbin 已提交
1004
    # * tag nchar max is 16374/4, col+ts nchar max  49151
J
jiajingbin 已提交
1005
    def tagColNcharMaxLengthCheckCase(self):
J
jiajingbin 已提交
1006
        """
1007
            check nchar length limit
J
jiajingbin 已提交
1008
        """
J
jiajingbin 已提交
1009
        tdLog.info(f'{sys._getframe().f_code.co_name}() function is running')
J
jiajingbin 已提交
1010 1011
        tdCom.cleanTb()
        stb_name = tdCom.getLongName(7, "letters")
J
jiajingbin 已提交
1012
        tb_name = f'{stb_name}_1'
J
jiajingbin 已提交
1013 1014
        input_sql = f'{stb_name},id={tb_name},t2={tdCom.getLongName(1, "letters")} c0=f 1626006833639000000'
        self._conn.schemaless_insert([input_sql], TDSmlProtocolType.LINE.value, TDSmlTimestampType.NANO_SECOND.value)
J
save  
jiajingbin 已提交
1015 1016

        # * legal nchar could not be larger than 16374/4
J
jiajingbin 已提交
1017
        input_sql = f'{stb_name},t1={tdCom.getLongName(4093, "letters")},t2={tdCom.getLongName(1, "letters")} c0=f 1626006833639000000'
1018
        self._conn.schemaless_insert([input_sql], TDSmlProtocolType.LINE.value, TDSmlTimestampType.NANO_SECOND.value)
J
modify  
jiajingbin 已提交
1019 1020
        tdSql.query(f"select * from {stb_name}")
        tdSql.checkRows(2)
J
jiajingbin 已提交
1021
        input_sql = f'{stb_name},t1={tdCom.getLongName(4093, "letters")},t2={tdCom.getLongName(2, "letters")} c0=f 1626006833639000000'
1022
        try:
1023
            self._conn.schemaless_insert([input_sql], TDSmlProtocolType.LINE.value, TDSmlTimestampType.NANO_SECOND.value)
1024
            raise Exception("should not reach here")
1025
        except SchemalessError as err:
1026
            tdSql.checkNotEqual(err.errno, 0)
J
modify  
jiajingbin 已提交
1027 1028
        tdSql.query(f"select * from {stb_name}")
        tdSql.checkRows(2)
J
jiajingbin 已提交
1029

J
jiajingbin 已提交
1030
        input_sql = f'{stb_name},t2={tdCom.getLongName(1, "letters")} c0=f,c1=L"{tdCom.getLongName(4093, "letters")}",c2=L"{tdCom.getLongName(4093, "letters")}",c3=L"{tdCom.getLongName(4093, "letters")}",c4=L"{tdCom.getLongName(4, "letters")}" 1626006833639000000'
1031
        self._conn.schemaless_insert([input_sql], TDSmlProtocolType.LINE.value, TDSmlTimestampType.NANO_SECOND.value)
1032 1033
        tdSql.query(f"select * from {stb_name}")
        tdSql.checkRows(3)
J
jiajingbin 已提交
1034
        input_sql = f'{stb_name},t2={tdCom.getLongName(1, "letters")} c0=f,c1=L"{tdCom.getLongName(4093, "letters")}",c2=L"{tdCom.getLongName(4093, "letters")}",c3=L"{tdCom.getLongName(4093, "letters")}",c4=L"{tdCom.getLongName(5, "letters")}" 1626006833639000000'
1035
        try:
1036
            self._conn.schemaless_insert([input_sql], TDSmlProtocolType.LINE.value, TDSmlTimestampType.NANO_SECOND.value)
1037
            raise Exception("should not reach here")
1038
        except SchemalessError as err:
1039
            tdSql.checkNotEqual(err.errno, 0)
1040 1041
        tdSql.query(f"select * from {stb_name}")
        tdSql.checkRows(3)
J
jiajingbin 已提交
1042 1043 1044 1045 1046

    def batchInsertCheckCase(self):
        """
            test batch insert
        """
J
jiajingbin 已提交
1047
        tdLog.info(f'{sys._getframe().f_code.co_name}() function is running')
J
jiajingbin 已提交
1048 1049
        tdCom.cleanTb()
        stb_name = tdCom.getLongName(8, "letters")
J
jiajingbin 已提交
1050
        tdSql.execute(f'create stable {stb_name}(ts timestamp, f int) tags(t1 bigint)')
J
jiajingbin 已提交
1051 1052 1053 1054 1055 1056 1057 1058 1059
        lines = ["st123456,t1=3i64,t2=4f64,t3=\"t3\" c1=3i64,c3=L\"passit\",c2=false,c4=4f64 1626006833639000000",
                "st123456,t1=4i64,t3=\"t4\",t2=5f64,t4=5f64 c1=3i64,c3=L\"passitagin\",c2=true,c4=5f64,c5=5f64 1626006833640000000",
                f"{stb_name},t2=5f64,t3=L\"ste\" c1=true,c2=4i64,c3=\"iam\" 1626056811823316532",
                "stf567890,t1=4i64,t3=\"t4\",t2=5f64,t4=5f64 c1=3i64,c3=L\"passitagin\",c2=true,c4=5f64,c5=5f64,c6=7u64 1626006933640000000",
                "st123456,t1=4i64,t2=5f64,t3=\"t4\" c1=3i64,c3=L\"passitagain\",c2=true,c4=5f64 1626006833642000000",
                f"{stb_name},t2=5f64,t3=L\"ste2\" c3=\"iamszhou\",c4=false 1626056811843316532",
                f"{stb_name},t2=5f64,t3=L\"ste2\" c3=\"iamszhou\",c4=false,c5=32i8,c6=64i16,c7=32i32,c8=88.88f32 1626056812843316532",
                "st123456,t1=4i64,t3=\"t4\",t2=5f64,t4=5f64 c1=3i64,c3=L\"passitagin\",c2=true,c4=5f64,c5=5f64,c6=7u64 1626006933640000000",
                "st123456,t1=4i64,t3=\"t4\",t2=5f64,t4=5f64   c1=3i64,c3=L\"passitagin_stf\",c2=false,c5=5f64,c6=7u64   1626006933641000000"
J
jiajingbin 已提交
1060
                ]
1061
        self._conn.schemaless_insert(lines, TDSmlProtocolType.LINE.value, TDSmlTimestampType.NANO_SECOND.value)
J
jiajingbin 已提交
1062 1063 1064 1065 1066 1067
        tdSql.query('show stables')
        tdSql.checkRows(3)
        tdSql.query('show tables')
        tdSql.checkRows(6)
        tdSql.query('select * from st123456')
        tdSql.checkRows(5)
J
jiajingbin 已提交
1068
    
J
save  
jiajingbin 已提交
1069
    def multiInsertCheckCase(self, count):
J
jiajingbin 已提交
1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083
        """
            test multi insert
        """
        tdLog.info(f'{sys._getframe().f_code.co_name}() function is running')
        tdCom.cleanTb()
        sql_list = []
        stb_name = tdCom.getLongName(8, "letters")
        tdSql.execute(f'create stable {stb_name}(ts timestamp, f int) tags(t1 nchar(10))')
        for i in range(count):
            input_sql = self.genFullTypeSql(stb_name=stb_name, t7=f'"{tdCom.getLongName(8, "letters")}"', c7=f'"{tdCom.getLongName(8, "letters")}"', id_noexist_tag=True)[0]
            sql_list.append(input_sql)
        self._conn.schemaless_insert(sql_list, TDSmlProtocolType.LINE.value, None)
        tdSql.query('show tables')
        tdSql.checkRows(count)
J
save  
jiajingbin 已提交
1084

J
jiajingbin 已提交
1085 1086 1087 1088
    def batchErrorInsertCheckCase(self):
        """
            test batch error insert
        """
J
jiajingbin 已提交
1089
        tdLog.info(f'{sys._getframe().f_code.co_name}() function is running')
J
jiajingbin 已提交
1090 1091 1092
        tdCom.cleanTb()
        stb_name = tdCom.getLongName(8, "letters")
        lines = ["st123456,t1=3i64,t2=4f64,t3=\"t3\" c1=3i 64,c3=L\"passit\",c2=false,c4=4f64 1626006833639000000",
J
save  
jiajingbin 已提交
1093
                f"{stb_name},t2=5f64,t3=L\"ste\" c1=tRue,c2=4i64,c3=\"iam\" 1626056811823316532ns"]
1094
        try:
J
jiajingbin 已提交
1095
            self._conn.schemaless_insert(lines, TDSmlProtocolType.LINE.value, None)
1096
            raise Exception("should not reach here")
1097
        except SchemalessError as err:
1098
            tdSql.checkNotEqual(err.errno, 0)
J
jiajingbin 已提交
1099

J
jiajingbin 已提交
1100 1101 1102 1103
    def multiColsInsertCheckCase(self):
        """
            test multi cols insert
        """
J
jiajingbin 已提交
1104
        tdLog.info(f'{sys._getframe().f_code.co_name}() function is running')
J
jiajingbin 已提交
1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116
        tdCom.cleanTb()
        input_sql = self.genFullTypeSql(c_multi_tag=True)[0]
        try:
            self._conn.schemaless_insert([input_sql], TDSmlProtocolType.LINE.value, TDSmlTimestampType.NANO_SECOND.value)
            raise Exception("should not reach here")
        except SchemalessError as err:
            tdSql.checkNotEqual(err.errno, 0)
    
    def multiTagsInsertCheckCase(self):
        """
            test multi tags insert
        """
J
jiajingbin 已提交
1117
        tdLog.info(f'{sys._getframe().f_code.co_name}() function is running')
J
jiajingbin 已提交
1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129
        tdCom.cleanTb()
        input_sql = self.genFullTypeSql(t_multi_tag=True)[0]
        try:
            self._conn.schemaless_insert([input_sql], TDSmlProtocolType.LINE.value, TDSmlTimestampType.NANO_SECOND.value)
            raise Exception("should not reach here")
        except SchemalessError as err:
            tdSql.checkNotEqual(err.errno, 0)
    
    def blankColInsertCheckCase(self):
        """
            test blank col insert
        """
J
jiajingbin 已提交
1130
        tdLog.info(f'{sys._getframe().f_code.co_name}() function is running')
J
jiajingbin 已提交
1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142
        tdCom.cleanTb()
        input_sql = self.genFullTypeSql(c_blank_tag=True)[0]
        try:
            self._conn.schemaless_insert([input_sql], TDSmlProtocolType.LINE.value, TDSmlTimestampType.NANO_SECOND.value)
            raise Exception("should not reach here")
        except SchemalessError as err:
            tdSql.checkNotEqual(err.errno, 0)

    def blankTagInsertCheckCase(self):
        """
            test blank tag insert
        """
J
jiajingbin 已提交
1143
        tdLog.info(f'{sys._getframe().f_code.co_name}() function is running')
J
jiajingbin 已提交
1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155
        tdCom.cleanTb()
        input_sql = self.genFullTypeSql(t_blank_tag=True)[0]
        try:
            self._conn.schemaless_insert([input_sql], TDSmlProtocolType.LINE.value, TDSmlTimestampType.NANO_SECOND.value)
            raise Exception("should not reach here")
        except SchemalessError as err:
            tdSql.checkNotEqual(err.errno, 0)
    
    def chineseCheckCase(self):
        """
            check nchar ---> chinese
        """
J
jiajingbin 已提交
1156
        tdLog.info(f'{sys._getframe().f_code.co_name}() function is running')
J
jiajingbin 已提交
1157 1158 1159 1160 1161 1162
        tdCom.cleanTb()
        input_sql, stb_name = self.genFullTypeSql(chinese_tag=True)
        self.resCmp(input_sql, stb_name)

    def spellCheckCase(self):
        stb_name = tdCom.getLongName(8, "letters")
J
jiajingbin 已提交
1163
        tdCom.cleanTb()
J
jiajingbin 已提交
1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178
        input_sql_list = [f'{stb_name}_1,t0=127I8,t1=32767I16,t2=2147483647I32,t3=9223372036854775807I64,t4=11.12345027923584F32,t5=22.123456789F64 c0=127I8,c1=32767I16,c2=2147483647I32,c3=9223372036854775807I64,c4=11.12345027923584F32,c5=22.123456789F64 1626006833639000000',
                            f'{stb_name}_2,t0=127I8,t1=32767I16,t2=2147483647I32,t3=9223372036854775807I64,t4=11.12345027923584F32,t5=22.123456789F64 c0=127I8,c1=32767I16,c2=2147483647I32,c3=9223372036854775807I64,c4=11.12345027923584F32,c5=22.123456789F64 1626006833639000000',
                            f'{stb_name}_3,t0=127I8,t1=32767I16,t2=2147483647I32,t3=9223372036854775807I64,t4=11.12345027923584F32,t5=22.123456789F64 c0=127I8,c1=32767I16,c2=2147483647I32,c3=9223372036854775807I64,c4=11.12345027923584F32,c5=22.123456789F64 1626006833639000000',
                            f'{stb_name}_4,t0=127I8,t1=32767I16,t2=2147483647I32,t3=9223372036854775807I64,t4=11.12345027923584F32,t5=22.123456789F64 c0=127I8,c1=32767I16,c2=2147483647I32,c3=9223372036854775807I64,c4=11.12345027923584F32,c5=22.123456789F64 1626006833639000000',
                            f'{stb_name}_5,t0=127I8,t1=32767I16,t2=2147483647I32,t3=9223372036854775807I64,t4=11.12345027923584F32,t5=22.123456789F64 c0=127I8,c1=32767I16,c2=2147483647I32,c3=9223372036854775807I64,c4=11.12345027923584F32,c5=22.123456789F64 1626006833639000000',
                            f'{stb_name}_6,t0=127I8,t1=32767I16,t2=2147483647I32,t3=9223372036854775807I64,t4=11.12345027923584F32,t5=22.123456789F64 c0=127I8,c1=32767I16,c2=2147483647I32,c3=9223372036854775807I64,c4=11.12345027923584F32,c5=22.123456789F64 1626006833639000000',
                            f'{stb_name}_7,t0=127I8,t1=32767I16,t2=2147483647I32,t3=9223372036854775807I64,t4=11.12345027923584F32,t5=22.123456789F64 c0=127I8,c1=32767I16,c2=2147483647I32,c3=9223372036854775807I64,c4=11.12345027923584F32,c5=22.123456789F64 1626006833639000000',
                            f'{stb_name}_8,t0=127I8,t1=32767I16,t2=2147483647I32,t3=9223372036854775807I64,t4=11.12345027923584F32,t5=22.123456789F64 c0=127I8,c1=32767I16,c2=2147483647I32,c3=9223372036854775807I64,c4=11.12345027923584F32,c5=22.123456789F64 1626006833639000000',
                            f'{stb_name}_9,t0=127I8,t1=32767I16,t2=2147483647I32,t3=9223372036854775807I64,t4=11.12345027923584F32,t5=22.123456789F64 c0=127I8,c1=32767I16,c2=2147483647I32,c3=9223372036854775807I64,c4=11.12345027923584F32,c5=22.123456789F64 1626006833639000000',
                            f'{stb_name}_10,t0=127I8,t1=32767I16,t2=2147483647I32,t3=9223372036854775807I64,t4=11.12345027923584F32,t5=22.123456789F64 c0=127I8,c1=32767I16,c2=2147483647I32,c3=9223372036854775807I64,c4=11.12345027923584F32,c5=22.123456789F64 1626006833639000000']
        for input_sql in input_sql_list:
            stb_name = input_sql.split(',')[0]
            self.resCmp(input_sql, stb_name)

    def defaultTypeCheckCase(self):
J
jiajingbin 已提交
1179 1180
        tdLog.info(f'{sys._getframe().f_code.co_name}() function is running')
        tdCom.cleanTb()
J
jiajingbin 已提交
1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191
        stb_name = tdCom.getLongName(8, "letters")
        input_sql_list = [f'{stb_name}_1,t0=127,t1=32767I16,t2=2147483647I32,t3=9223372036854775807,t4=11.12345027923584F32,t5=22.123456789F64 c0=127,c1=32767I16,c2=2147483647I32,c3=9223372036854775807,c4=11.12345027923584F32,c5=22.123456789F64 1626006833639000000',
                            f'{stb_name}_2,t0=127I8,t1=32767I16,t2=2147483647I32,t3=9223372036854775807I64,t4=11.12345027923584F32,t5=22.123456789 c0=127I8,c1=32767I16,c2=2147483647I32,c3=9223372036854775807I64,c4=11.12345027923584F32,c5=22.123456789 1626006833639000000',
                            f'{stb_name}_3,t0=127I8,t1=32767I16,t2=2147483647I32,t3=9223372036854775807I64,t4=11.12345027923584F32,t5=10e5F32 c0=127I8,c1=32767I16,c2=2147483647I32,c3=9223372036854775807I64,c4=11.12345027923584F32,c5=10e5F64 1626006833639000000',
                            f'{stb_name}_4,t0=127I8,t1=32767I16,t2=2147483647I32,t3=9223372036854775807I64,t4=11.12345027923584F32,t5=10.0e5f64 c0=127I8,c1=32767I16,c2=2147483647I32,c3=9223372036854775807I64,c4=11.12345027923584F32,c5=10.0e5f32 1626006833639000000',
                            f'{stb_name}_5,t0=127I8,t1=32767I16,t2=2147483647I32,t3=9223372036854775807I64,t4=11.12345027923584F32,t5=-10.0e5 c0=127I8,c1=32767I16,c2=2147483647I32,c3=9223372036854775807I64,c4=11.12345027923584F32,c5=-10.0e5 1626006833639000000']
        for input_sql in input_sql_list:
            stb_name = input_sql.split(",")[0]
            self.resCmp(input_sql, stb_name)

    def tbnameTagsColsNameCheckCase(self):
J
jiajingbin 已提交
1192 1193
        tdLog.info(f'{sys._getframe().f_code.co_name}() function is running')
        tdCom.cleanTb()
J
jiajingbin 已提交
1194 1195 1196 1197 1198 1199 1200 1201 1202
        input_sql = 'rFa$sta,id=rFas$ta_1,Tt!0=true,tT@1=127i8,t#2=32767i16,\"t$3\"=2147483647i32,t%4=9223372036854775807i64,t^5=11.12345f32,t&6=22.123456789f64,t*7=\"ddzhiksj\",t!@#$%^&*()_+[];:<>?,9=L\"ncharTagValue\" C)0=True,c{1=127i8,c[2=32767i16,c;3=2147483647i32,c:4=9223372036854775807i64,c<5=11.12345f32,c>6=22.123456789f64,c?7=\"bnhwlgvj\",c.8=L\"ncharTagValue\",c!@#$%^&*()_+[];:<>?,=7u64 1626006933640000000'
        self._conn.schemaless_insert([input_sql], TDSmlProtocolType.LINE.value, TDSmlTimestampType.NANO_SECOND.value)
        query_sql = 'select * from `rfa$sta`'
        query_res = tdSql.query(query_sql, True)
        tdSql.checkEqual(query_res, [(datetime.datetime(2021, 7, 11, 20, 35, 33, 640000), True, 127, 32767, 2147483647, 9223372036854775807, 11.12345027923584, 22.123456789, 'bnhwlgvj', 'ncharTagValue', 7, 'true', '127i8', '32767i16', '2147483647i32', '9223372036854775807i64', '11.12345f32', '22.123456789f64', '"ddzhiksj"', 'L"ncharTagValue"')])
        col_tag_res = tdSql.getColNameList(query_sql)
        tdSql.checkEqual(col_tag_res, ['_ts', 'c)0', 'c{1', 'c[2', 'c;3', 'c:4', 'c<5', 'c>6', 'c?7', 'c.8', 'c!@#$%^&*()_+[];:<>?,', 'tt!0', 'tt@1', 't#2', '"t$3"', 't%4', 't^5', 't&6', 't*7', 't!@#$%^&*()_+[];:<>?,9'])
        tdSql.execute('drop table `rfa$sta`')

J
jiajingbin 已提交
1203
    def genSqlList(self, count=5, stb_name="", tb_name=""):
J
save  
jiajingbin 已提交
1204 1205 1206
        """
            stb --> supertable
            tb  --> table
J
save  
jiajingbin 已提交
1207 1208 1209
            ts  --> timestamp, same default
            col --> column, same default
            tag --> tag, same default
J
save  
jiajingbin 已提交
1210 1211
            d   --> different
            s   --> same
J
save  
jiajingbin 已提交
1212 1213
            a   --> add
            m   --> minus
J
save  
jiajingbin 已提交
1214 1215
        """
        d_stb_d_tb_list = list()
J
save  
jiajingbin 已提交
1216 1217
        s_stb_s_tb_list = list()
        s_stb_s_tb_a_col_a_tag_list = list()
J
save  
jiajingbin 已提交
1218
        s_stb_s_tb_m_col_m_tag_list = list()
J
jiajingbin 已提交
1219 1220 1221 1222
        s_stb_d_tb_list = list()
        s_stb_d_tb_a_col_m_tag_list = list()
        s_stb_d_tb_a_tag_m_col_list = list()
        s_stb_s_tb_d_ts_list = list()
J
modify  
jiajingbin 已提交
1223 1224 1225 1226 1227
        s_stb_s_tb_d_ts_a_col_m_tag_list = list()
        s_stb_s_tb_d_ts_a_tag_m_col_list = list()
        s_stb_d_tb_d_ts_list = list()
        s_stb_d_tb_d_ts_a_col_m_tag_list = list()
        s_stb_d_tb_d_ts_a_tag_m_col_list = list()
J
save  
jiajingbin 已提交
1228
        for i in range(count):
J
jiajingbin 已提交
1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241
            d_stb_d_tb_list.append(self.genFullTypeSql(c0="t"))
            s_stb_s_tb_list.append(self.genFullTypeSql(stb_name=stb_name, tb_name=tb_name, t7=f'"{tdCom.getLongName(8, "letters")}"', c7=f'"{tdCom.getLongName(8, "letters")}"'))
            s_stb_s_tb_a_col_a_tag_list.append(self.genFullTypeSql(stb_name=stb_name, tb_name=tb_name, t7=f'"{tdCom.getLongName(8, "letters")}"', c7=f'"{tdCom.getLongName(8, "letters")}"', ct_add_tag=True))
            s_stb_s_tb_m_col_m_tag_list.append(self.genFullTypeSql(stb_name=stb_name, tb_name=tb_name, t7=f'"{tdCom.getLongName(8, "letters")}"', c7=f'"{tdCom.getLongName(8, "letters")}"', ct_min_tag=True))
            s_stb_d_tb_list.append(self.genFullTypeSql(stb_name=stb_name, t7=f'"{tdCom.getLongName(8, "letters")}"', c7=f'"{tdCom.getLongName(8, "letters")}"', id_noexist_tag=True))
            s_stb_d_tb_a_col_m_tag_list.append(self.genFullTypeSql(stb_name=stb_name, t7=f'"{tdCom.getLongName(8, "letters")}"', c7=f'"{tdCom.getLongName(8, "letters")}"', id_noexist_tag=True, ct_am_tag=True))
            s_stb_d_tb_a_tag_m_col_list.append(self.genFullTypeSql(stb_name=stb_name, t7=f'"{tdCom.getLongName(8, "letters")}"', c7=f'"{tdCom.getLongName(8, "letters")}"', id_noexist_tag=True, ct_ma_tag=True))
            s_stb_s_tb_d_ts_list.append(self.genFullTypeSql(stb_name=stb_name, tb_name=tb_name, t7=f'"{tdCom.getLongName(8, "letters")}"', c7=f'"{tdCom.getLongName(8, "letters")}"', ts=0))
            s_stb_s_tb_d_ts_a_col_m_tag_list.append(self.genFullTypeSql(stb_name=stb_name, tb_name=tb_name, t7=f'"{tdCom.getLongName(8, "letters")}"', c7=f'"{tdCom.getLongName(8, "letters")}"', ts=0, ct_am_tag=True))
            s_stb_s_tb_d_ts_a_tag_m_col_list.append(self.genFullTypeSql(stb_name=stb_name, tb_name=tb_name, t7=f'"{tdCom.getLongName(8, "letters")}"', c7=f'"{tdCom.getLongName(8, "letters")}"', ts=0, ct_ma_tag=True))
            s_stb_d_tb_d_ts_list.append(self.genFullTypeSql(stb_name=stb_name, t7=f'"{tdCom.getLongName(8, "letters")}"', c7=f'"{tdCom.getLongName(8, "letters")}"', id_noexist_tag=True, ts=0))
            s_stb_d_tb_d_ts_a_col_m_tag_list.append(self.genFullTypeSql(stb_name=stb_name, t7=f'"{tdCom.getLongName(8, "letters")}"', c7=f'"{tdCom.getLongName(8, "letters")}"', id_noexist_tag=True, ts=0, ct_am_tag=True))
            s_stb_d_tb_d_ts_a_tag_m_col_list.append(self.genFullTypeSql(stb_name=stb_name, t7=f'"{tdCom.getLongName(8, "letters")}"', c7=f'"{tdCom.getLongName(8, "letters")}"', id_noexist_tag=True, ts=0, ct_ma_tag=True))
J
jiajingbin 已提交
1242

J
modify  
jiajingbin 已提交
1243 1244 1245 1246
        return d_stb_d_tb_list, s_stb_s_tb_list, s_stb_s_tb_a_col_a_tag_list, s_stb_s_tb_m_col_m_tag_list, \
            s_stb_d_tb_list, s_stb_d_tb_a_col_m_tag_list, s_stb_d_tb_a_tag_m_col_list, s_stb_s_tb_d_ts_list, \
            s_stb_s_tb_d_ts_a_col_m_tag_list, s_stb_s_tb_d_ts_a_tag_m_col_list, s_stb_d_tb_d_ts_list, \
            s_stb_d_tb_d_ts_a_col_m_tag_list, s_stb_d_tb_d_ts_a_tag_m_col_list
J
jiajingbin 已提交
1247

J
save  
jiajingbin 已提交
1248 1249 1250 1251

    def genMultiThreadSeq(self, sql_list):
        tlist = list()
        for insert_sql in sql_list:
J
jiajingbin 已提交
1252
            t = threading.Thread(target=self._conn.schemaless_insert,args=([insert_sql[0]], TDSmlProtocolType.LINE.value, None))
J
save  
jiajingbin 已提交
1253 1254 1255 1256 1257 1258 1259
            tlist.append(t)
        return tlist

    def multiThreadRun(self, tlist):
        for t in tlist:
            t.start()
        for t in tlist:
J
jiajingbin 已提交
1260
            t.join()
J
save  
jiajingbin 已提交
1261

J
save  
jiajingbin 已提交
1262
    def stbInsertMultiThreadCheckCase(self):
J
jiajingbin 已提交
1263 1264 1265
        """
            thread input different stb
        """
J
jiajingbin 已提交
1266
        tdLog.info(f'{sys._getframe().f_code.co_name}() function is running')
J
jiajingbin 已提交
1267
        tdCom.cleanTb()
J
jiajingbin 已提交
1268 1269
        input_sql = self.genSqlList()[0]
        self.multiThreadRun(self.genMultiThreadSeq(input_sql))
J
jiajingbin 已提交
1270 1271 1272 1273 1274 1275 1276
        tdSql.query(f"show tables;")
        tdSql.checkRows(5)
    
    def sStbStbDdataInsertMultiThreadCheckCase(self):
        """
            thread input same stb tb, different data, result keep first data
        """
J
jiajingbin 已提交
1277
        tdLog.info(f'{sys._getframe().f_code.co_name}() function is running')
J
jiajingbin 已提交
1278 1279
        tdCom.cleanTb()
        tb_name = tdCom.getLongName(7, "letters")
J
jiajingbin 已提交
1280
        input_sql, stb_name = self.genFullTypeSql(tb_name=tb_name)
J
jiajingbin 已提交
1281 1282 1283 1284 1285 1286 1287
        self.resCmp(input_sql, stb_name)
        s_stb_s_tb_list = self.genSqlList(stb_name=stb_name, tb_name=tb_name)[1]
        self.multiThreadRun(self.genMultiThreadSeq(s_stb_s_tb_list))
        tdSql.query(f"show tables;")
        tdSql.checkRows(1)
        expected_tb_name = self.getNoIdTbName(stb_name)[0]
        tdSql.checkEqual(tb_name, expected_tb_name)
J
jiajingbin 已提交
1288 1289
        tdSql.query(f"select * from {stb_name};")
        tdSql.checkRows(1)
J
jiajingbin 已提交
1290 1291 1292 1293 1294

    def sStbStbDdataAtcInsertMultiThreadCheckCase(self):
        """
            thread input same stb tb, different data, add columes and tags,  result keep first data
        """
J
jiajingbin 已提交
1295
        tdLog.info(f'{sys._getframe().f_code.co_name}() function is running')
J
jiajingbin 已提交
1296 1297
        tdCom.cleanTb()
        tb_name = tdCom.getLongName(7, "letters")
J
jiajingbin 已提交
1298
        input_sql, stb_name = self.genFullTypeSql(tb_name=tb_name)
J
jiajingbin 已提交
1299 1300 1301 1302 1303 1304 1305
        self.resCmp(input_sql, stb_name)
        s_stb_s_tb_a_col_a_tag_list = self.genSqlList(stb_name=stb_name, tb_name=tb_name)[2]
        self.multiThreadRun(self.genMultiThreadSeq(s_stb_s_tb_a_col_a_tag_list))
        tdSql.query(f"show tables;")
        tdSql.checkRows(1)
        expected_tb_name = self.getNoIdTbName(stb_name)[0]
        tdSql.checkEqual(tb_name, expected_tb_name)
J
jiajingbin 已提交
1306 1307
        tdSql.query(f"select * from {stb_name};")
        tdSql.checkRows(1)
J
jiajingbin 已提交
1308 1309 1310
    
    def sStbStbDdataMtcInsertMultiThreadCheckCase(self):
        """
J
jiajingbin 已提交
1311
            thread input same stb tb, different data, minus columes and tags,  result keep first data
J
jiajingbin 已提交
1312
        """
J
jiajingbin 已提交
1313
        tdLog.info(f'{sys._getframe().f_code.co_name}() function is running')
J
jiajingbin 已提交
1314 1315
        tdCom.cleanTb()
        tb_name = tdCom.getLongName(7, "letters")
J
jiajingbin 已提交
1316
        input_sql, stb_name = self.genFullTypeSql(tb_name=tb_name)
J
jiajingbin 已提交
1317 1318 1319 1320 1321 1322 1323
        self.resCmp(input_sql, stb_name)
        s_stb_s_tb_m_col_m_tag_list = self.genSqlList(stb_name=stb_name, tb_name=tb_name)[3]
        self.multiThreadRun(self.genMultiThreadSeq(s_stb_s_tb_m_col_m_tag_list))
        tdSql.query(f"show tables;")
        tdSql.checkRows(1)
        expected_tb_name = self.getNoIdTbName(stb_name)[0]
        tdSql.checkEqual(tb_name, expected_tb_name)
J
jiajingbin 已提交
1324 1325 1326 1327 1328 1329 1330
        tdSql.query(f"select * from {stb_name};")
        tdSql.checkRows(1)

    def sStbDtbDdataInsertMultiThreadCheckCase(self):
        """
            thread input same stb, different tb, different data
        """
J
jiajingbin 已提交
1331
        tdLog.info(f'{sys._getframe().f_code.co_name}() function is running')
J
jiajingbin 已提交
1332
        tdCom.cleanTb()
J
jiajingbin 已提交
1333
        input_sql, stb_name = self.genFullTypeSql()
J
jiajingbin 已提交
1334 1335 1336 1337 1338 1339 1340 1341 1342 1343
        self.resCmp(input_sql, stb_name)
        s_stb_d_tb_list = self.genSqlList(stb_name=stb_name)[4]
        self.multiThreadRun(self.genMultiThreadSeq(s_stb_d_tb_list))
        tdSql.query(f"show tables;")
        tdSql.checkRows(6)

    def sStbDtbDdataAcMtInsertMultiThreadCheckCase(self):
        """
            thread input same stb, different tb, different data, add col, mul tag
        """
J
jiajingbin 已提交
1344
        tdLog.info(f'{sys._getframe().f_code.co_name}() function is running')
J
jiajingbin 已提交
1345
        tdCom.cleanTb()
J
jiajingbin 已提交
1346
        input_sql, stb_name = self.genFullTypeSql()
J
jiajingbin 已提交
1347
        self.resCmp(input_sql, stb_name)
1348
        # s_stb_d_tb_a_col_m_tag_list = self.genSqlList(stb_name=stb_name)[5]
J
jiajingbin 已提交
1349 1350 1351 1352 1353
        s_stb_d_tb_a_col_m_tag_list = [(f'{stb_name},t0=F,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64 c0=t,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7="ngxgzdzs",c8=L"ncharColValue",c9=7u64,c11=L"ncharColValue",c10=F 1626006833639000000', 'hpxbys'), \
                                        (f'{stb_name},t0=True,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64 c0=T,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7="vvfrdtty",c8=L"ncharColValue",c9=7u64,c11=L"ncharColValue",c10=True 1626006833639000000', 'hpxbys'), \
                                        (f'{stb_name},t0=F,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64 c0=False,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7="kzscucnt",c8=L"ncharColValue",c9=7u64,c11=L"ncharColValue",c10=f 1626006833639000000', 'hpxbys'), \
                                        (f'{stb_name},t0=F,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64 c0=f,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7="asegdbqk",c8=L"ncharColValue",c9=7u64,c11=L"ncharColValue",c10=false 1626006833639000000', 'hpxbys'), \
                                        (f'{stb_name},t0=True,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64 c0=true,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7="yvqnhgmn",c8=L"ncharColValue",c9=7u64,c11=L"ncharColValue",c10=T 1626006833639000000', 'hpxbys')]
J
jiajingbin 已提交
1354 1355
        self.multiThreadRun(self.genMultiThreadSeq(s_stb_d_tb_a_col_m_tag_list))
        tdSql.query(f"show tables;")
1356
        tdSql.checkRows(3)
J
jiajingbin 已提交
1357 1358 1359 1360 1361

    def sStbDtbDdataAtMcInsertMultiThreadCheckCase(self):
        """
            thread input same stb, different tb, different data, add tag, mul col
        """
J
jiajingbin 已提交
1362
        tdLog.info(f'{sys._getframe().f_code.co_name}() function is running')
J
jiajingbin 已提交
1363
        tdCom.cleanTb()
J
jiajingbin 已提交
1364
        input_sql, stb_name = self.genFullTypeSql()
J
jiajingbin 已提交
1365 1366 1367 1368 1369 1370 1371 1372 1373 1374
        self.resCmp(input_sql, stb_name)
        s_stb_d_tb_a_tag_m_col_list = self.genSqlList(stb_name=stb_name)[6]
        self.multiThreadRun(self.genMultiThreadSeq(s_stb_d_tb_a_tag_m_col_list))
        tdSql.query(f"show tables;")
        tdSql.checkRows(6)

    def sStbStbDdataDtsInsertMultiThreadCheckCase(self):
        """
            thread input same stb tb, different ts
        """
J
jiajingbin 已提交
1375
        tdLog.info(f'{sys._getframe().f_code.co_name}() function is running')
J
jiajingbin 已提交
1376 1377
        tdCom.cleanTb()
        tb_name = tdCom.getLongName(7, "letters")
J
jiajingbin 已提交
1378
        input_sql, stb_name = self.genFullTypeSql(tb_name=tb_name)
J
jiajingbin 已提交
1379
        self.resCmp(input_sql, stb_name)
1380
        # s_stb_s_tb_d_ts_list = self.genSqlList(stb_name=stb_name, tb_name=tb_name)[7]
J
jiajingbin 已提交
1381 1382 1383 1384 1385
        s_stb_s_tb_d_ts_list =[(f'{stb_name},id={tb_name},t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64,t7="tgqkvsws",t8=L"ncharTagValue" c0=f,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7="htvnnldm",c8=L"ncharColValue",c9=7u64 0', 'sfzqdz'), \
                                (f'{stb_name},id={tb_name},t0=f,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64,t7="fvrhhqiy",t8=L"ncharTagValue" c0=False,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7="gybqvhos",c8=L"ncharColValue",c9=7u64 0', 'sfzqdz'), \
                                (f'{stb_name},id={tb_name},t0=f,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64,t7="vifkabhu",t8=L"ncharTagValue" c0=t,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7="zlvxgquy",c8=L"ncharColValue",c9=7u64 0', 'sfzqdz'), \
                                (f'{stb_name},id={tb_name},t0=True,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64,t7="lsyotcrn",t8=L"ncharTagValue" c0=False,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7="oaupfgtz",c8=L"ncharColValue",c9=7u64 0', 'sfzqdz'), \
                                (f'{stb_name},id={tb_name},t0=T,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64,t7="jrwamcgy",t8=L"ncharTagValue" c0=F,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7="vgzadjsh",c8=L"ncharColValue",c9=7u64 0', 'sfzqdz')]
J
jiajingbin 已提交
1386 1387 1388
        self.multiThreadRun(self.genMultiThreadSeq(s_stb_s_tb_d_ts_list))
        tdSql.query(f"show tables;")
        tdSql.checkRows(1)
1389 1390 1391
        # ! Small probability bug ---> temporarily delete it
        # tdSql.query(f"select * from {stb_name}")
        # tdSql.checkRows(6)
J
jiajingbin 已提交
1392

J
modify  
jiajingbin 已提交
1393 1394 1395 1396
    def sStbStbDdataDtsAcMtInsertMultiThreadCheckCase(self):
        """
            thread input same stb tb, different ts, add col, mul tag
        """
J
jiajingbin 已提交
1397
        tdLog.info(f'{sys._getframe().f_code.co_name}() function is running')
J
jiajingbin 已提交
1398 1399
        tdCom.cleanTb()
        tb_name = tdCom.getLongName(7, "letters")
J
modify  
jiajingbin 已提交
1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416
        input_sql, stb_name = self.genFullTypeSql(tb_name=tb_name)
        self.resCmp(input_sql, stb_name)
        s_stb_s_tb_d_ts_a_col_m_tag_list = self.genSqlList(stb_name=stb_name, tb_name=tb_name)[8]
        self.multiThreadRun(self.genMultiThreadSeq(s_stb_s_tb_d_ts_a_col_m_tag_list))
        tdSql.query(f"show tables;")
        tdSql.checkRows(1)
        tdSql.query(f"select * from {stb_name}")
        tdSql.checkRows(6)
        tdSql.query(f"select * from {stb_name} where t8 is not NULL")
        tdSql.checkRows(6)
        tdSql.query(f"select * from {tb_name} where c11 is not NULL;")
        tdSql.checkRows(5)

    def sStbStbDdataDtsAtMcInsertMultiThreadCheckCase(self):
        """
            thread input same stb tb, different ts, add tag, mul col
        """
J
jiajingbin 已提交
1417
        tdLog.info(f'{sys._getframe().f_code.co_name}() function is running')
J
jiajingbin 已提交
1418 1419
        tdCom.cleanTb()
        tb_name = tdCom.getLongName(7, "letters")
J
modify  
jiajingbin 已提交
1420 1421
        input_sql, stb_name = self.genFullTypeSql(tb_name=tb_name)
        self.resCmp(input_sql, stb_name)
1422
        # s_stb_s_tb_d_ts_a_tag_m_col_list = self.genSqlList(stb_name=stb_name, tb_name=tb_name)[9]
J
jiajingbin 已提交
1423 1424 1425 1426 1427
        s_stb_s_tb_d_ts_a_tag_m_col_list = [(f'{stb_name},id={tb_name},t0=T,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64,t7="xsajdfjc",t8=L"ncharTagValue",t11=127i8,t10=L"ncharTagValue" c0=f,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64 0', 'rgqcfb'), \
                                            (f'{stb_name},id={tb_name},t0=T,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64,t7="qzeyolgt",t8=L"ncharTagValue",t11=127i8,t10=L"ncharTagValue" c0=True,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64 0', 'rgqcfb'), \
                                            (f'{stb_name},id={tb_name},t0=False,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64,t7="suxqziwh",t8=L"ncharTagValue",t11=127i8,t10=L"ncharTagValue" c0=False,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64 0', 'rgqcfb'), \
                                            (f'{stb_name},id={tb_name},t0=False,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64,t7="vapolpgr",t8=L"ncharTagValue",t11=127i8,t10=L"ncharTagValue" c0=t,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64 0', 'rgqcfb'), \
                                            (f'{stb_name},id={tb_name},t0=False,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64,t7="eustwpfl",t8=L"ncharTagValue",t11=127i8,t10=L"ncharTagValue" c0=t,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64 0', 'rgqcfb')]
J
modify  
jiajingbin 已提交
1428 1429 1430 1431 1432 1433 1434 1435 1436 1437
        self.multiThreadRun(self.genMultiThreadSeq(s_stb_s_tb_d_ts_a_tag_m_col_list))
        tdSql.query(f"show tables;")
        tdSql.checkRows(1)
        tdSql.query(f"select * from {stb_name}")
        tdSql.checkRows(6)
        for c in ["c7", "c8", "c9"]:
            tdSql.query(f"select * from {stb_name} where {c} is NULL")
            tdSql.checkRows(5)        
        for t in ["t10", "t11"]:
            tdSql.query(f"select * from {stb_name} where {t} is not NULL;")
1438
            tdSql.checkRows(0)
J
modify  
jiajingbin 已提交
1439 1440 1441 1442 1443

    def sStbDtbDdataDtsInsertMultiThreadCheckCase(self):
        """
            thread input same stb, different tb, data, ts
        """
J
jiajingbin 已提交
1444
        tdLog.info(f'{sys._getframe().f_code.co_name}() function is running')
J
jiajingbin 已提交
1445
        tdCom.cleanTb()
J
modify  
jiajingbin 已提交
1446 1447 1448 1449 1450 1451
        input_sql, stb_name = self.genFullTypeSql()
        self.resCmp(input_sql, stb_name)
        s_stb_d_tb_d_ts_list = self.genSqlList(stb_name=stb_name)[10]
        self.multiThreadRun(self.genMultiThreadSeq(s_stb_d_tb_d_ts_list))
        tdSql.query(f"show tables;")
        tdSql.checkRows(6)
J
jiajingbin 已提交
1452

J
modify  
jiajingbin 已提交
1453 1454 1455 1456
    def sStbDtbDdataDtsAcMtInsertMultiThreadCheckCase(self):
        """
            thread input same stb, different tb, data, ts, add col, mul tag
        """
J
jiajingbin 已提交
1457
        tdLog.info(f'{sys._getframe().f_code.co_name}() function is running')
J
jiajingbin 已提交
1458
        tdCom.cleanTb()
J
modify  
jiajingbin 已提交
1459 1460
        input_sql, stb_name = self.genFullTypeSql()
        self.resCmp(input_sql, stb_name)
1461 1462
        # s_stb_d_tb_d_ts_a_col_m_tag_list = self.genSqlList(stb_name=stb_name)[11]
        s_stb_d_tb_d_ts_a_col_m_tag_list = [(f'{stb_name},t0=True,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64 c0=f,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7="eltflgpz",c8=L"ncharColValue",c9=7u64,c11=L"ncharColValue",c10=True 0', 'ynnlov'), \
J
jiajingbin 已提交
1463
                                            (f'{stb_name},t0=True,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64 c0=False,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7="ysznggwl",c8=L"ncharColValue",c9=7u64,c11=L"ncharColValue",c10=t 0', 'ynnlov'), \
1464
                                            (f'{stb_name},t0=f,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64 c0=f,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7="nxwjucch",c8=L"ncharColValue",c9=7u64,c11=L"ncharColValue",c10=f 0', 'ynnlov'), \
J
jiajingbin 已提交
1465 1466
                                            (f'{stb_name},t0=f,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64 c0=T,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7="fzseicnt",c8=L"ncharColValue",c9=7u64,c11=L"ncharColValue",c10=F 0', 'ynnlov'), \
                                            (f'{stb_name},t0=f,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64 c0=F,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7="zwgurhdp",c8=L"ncharColValue",c9=7u64,c11=L"ncharColValue",c10=False 0', 'ynnlov')]
J
modify  
jiajingbin 已提交
1467 1468
        self.multiThreadRun(self.genMultiThreadSeq(s_stb_d_tb_d_ts_a_col_m_tag_list))
        tdSql.query(f"show tables;")
1469
        tdSql.checkRows(3)
J
modify  
jiajingbin 已提交
1470 1471

    def test(self):
J
jiajingbin 已提交
1472
        input_sql1 = "rfa$sta,id=rfas$ta_1,T!0=true,t@1=127i8,t#2=32767i16,t$3=2147483647i32,t%4=9223372036854775807i64,t^5=11.12345f32,t&6=22.123456789f64,t*7=\"ddzhiksj\",t(8=L\"ncharTagValue\" C)0=True,c{1=127i8,c[2=32767i16,c;3=2147483647i32,c:4=9223372036854775807i64,c<5=11.12345f32,c>6=22.123456789f64,c?7=\"bnhwlgvj\",c.8=L\"ncharTagValue\",c,9=7u64 1626006933640000000ns"
1473
        try:
J
jiajingbin 已提交
1474 1475
            self._conn.schemaless_insert([input_sql1], TDSmlProtocolType.LINE.value, None)
            # self._conn.schemaless_insert([input_sql2])
1476
        except SchemalessError as err:
1477
            print(err.errno)
J
save  
jiajingbin 已提交
1478

J
jiajingbin 已提交
1479 1480 1481 1482 1483
    def runAll(self):
        self.initCheckCase()
        self.boolTypeCheckCase()
        self.symbolsCheckCase()
        self.tsCheckCase()
J
jiajingbin 已提交
1484 1485
        self.zeroTsCheckCase()
        self.iuCheckCase()
J
jiajingbin 已提交
1486
        self.idSeqCheckCase()
J
jiajingbin 已提交
1487
        self.idLetterCheckCase()
J
jiajingbin 已提交
1488 1489
        self.noIdCheckCase()
        self.maxColTagCheckCase()
J
jiajingbin 已提交
1490
        self.stbTbNameCheckCase()
J
jiajingbin 已提交
1491 1492 1493 1494
        self.idStartWithNumCheckCase()
        self.nowTsCheckCase()
        self.dateFormatTsCheckCase()
        self.illegalTsCheckCase()
J
jiajingbin 已提交
1495
        self.tbnameCheckCase()
J
jiajingbin 已提交
1496 1497 1498 1499 1500 1501 1502
        self.tagValueLengthCheckCase()
        self.colValueLengthCheckCase()
        self.tagColIllegalValueCheckCase()
        self.duplicateIdTagColInsertCheckCase()
        self.noIdStbExistCheckCase()
        self.duplicateInsertExistCheckCase()
        self.tagColBinaryNcharLengthCheckCase()
J
jiajingbin 已提交
1503
        self.tagColAddDupIDCheckCase()
J
jiajingbin 已提交
1504 1505 1506
        self.tagColAddCheckCase()
        self.tagMd5Check()
        self.tagColBinaryMaxLengthCheckCase()
1507
        self.tagColNcharMaxLengthCheckCase()
J
jiajingbin 已提交
1508
        self.batchInsertCheckCase()
J
jiajingbin 已提交
1509
        self.multiInsertCheckCase(100)
J
jiajingbin 已提交
1510
        self.batchErrorInsertCheckCase()
J
jiajingbin 已提交
1511 1512 1513 1514 1515 1516 1517 1518 1519
        self.multiColsInsertCheckCase()
        self.multiTagsInsertCheckCase()
        self.blankColInsertCheckCase()
        self.blankTagInsertCheckCase()
        self.chineseCheckCase()
        self.spellCheckCase()
        self.defaultTypeCheckCase()
        self.tbnameTagsColsNameCheckCase()

J
modify  
jiajingbin 已提交
1520
        # MultiThreads
J
jiajingbin 已提交
1521 1522 1523 1524 1525
        self.stbInsertMultiThreadCheckCase()
        self.sStbStbDdataInsertMultiThreadCheckCase()
        self.sStbStbDdataAtcInsertMultiThreadCheckCase()
        self.sStbStbDdataMtcInsertMultiThreadCheckCase()
        self.sStbDtbDdataInsertMultiThreadCheckCase()
1526 1527
        self.sStbDtbDdataAcMtInsertMultiThreadCheckCase()
        self.sStbDtbDdataAtMcInsertMultiThreadCheckCase()
J
jiajingbin 已提交
1528
        self.sStbStbDdataDtsInsertMultiThreadCheckCase()
1529 1530
        self.sStbStbDdataDtsAcMtInsertMultiThreadCheckCase()
        self.sStbStbDdataDtsAtMcInsertMultiThreadCheckCase()
J
modify  
jiajingbin 已提交
1531
        self.sStbDtbDdataDtsInsertMultiThreadCheckCase()
1532
        self.sStbDtbDdataDtsAcMtInsertMultiThreadCheckCase()
J
modify  
jiajingbin 已提交
1533

J
jiajingbin 已提交
1534 1535 1536
    def run(self):
        print("running {}".format(__file__))
        self.createDb()
1537 1538 1539 1540 1541
        try:
            self.runAll()
        except Exception as err:
            print(''.join(traceback.format_exception(None, err, err.__traceback__)))
            raise err
J
jiajingbin 已提交
1542 1543 1544 1545 1546

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

1547
tdCases.addWindows(__file__, TDTestCase())
J
jiajingbin 已提交
1548
tdCases.addLinux(__file__, TDTestCase())