fix case
This commit is contained in:
parent
b6acf93fb6
commit
a1f74aaba7
|
@ -0,0 +1,69 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
# basic data type boundary
|
||||||
|
TINYINT_MAX = 127
|
||||||
|
TINYINT_MIN = -128
|
||||||
|
|
||||||
|
TINYINT_UN_MAX = 255
|
||||||
|
TINYINT_UN_MIN = 0
|
||||||
|
|
||||||
|
SMALLINT_MAX = 32767
|
||||||
|
SMALLINT_MIN = -32768
|
||||||
|
|
||||||
|
SMALLINT_UN_MAX = 65535
|
||||||
|
MALLINT_UN_MIN = 0
|
||||||
|
|
||||||
|
INT_MAX = 2147483647
|
||||||
|
INT_MIN = -2147483648
|
||||||
|
|
||||||
|
INT_UN_MAX = 4294967295
|
||||||
|
INT_UN_MIN = 0
|
||||||
|
|
||||||
|
BIGINT_MAX = 9223372036854775807
|
||||||
|
BIGINT_MIN = -9223372036854775808
|
||||||
|
|
||||||
|
BIGINT_UN_MAX = 18446744073709551615
|
||||||
|
BIGINT_UN_MIN = 0
|
||||||
|
|
||||||
|
FLOAT_MAX = 3.40E+38
|
||||||
|
FLOAT_MIN = -3.40E+38
|
||||||
|
|
||||||
|
DOUBLE_MAX = 1.7E+308
|
||||||
|
DOUBLE_MIN = -1.7E+308
|
||||||
|
|
||||||
|
# schema boundary
|
||||||
|
BINARY_LENGTH_MAX = 16374
|
||||||
|
NCAHR_LENGTH_MAX_ = 4093
|
||||||
|
DBNAME_LENGTH_MAX_ = 64
|
||||||
|
|
||||||
|
STBNAME_LENGTH_MAX = 192
|
||||||
|
STBNAME_LENGTH_MIN = 1
|
||||||
|
|
||||||
|
TBNAME_LENGTH_MAX = 192
|
||||||
|
TBNAME_LENGTH_MIN = 1
|
||||||
|
|
||||||
|
CHILD_TBNAME_LENGTH_MAX = 192
|
||||||
|
CHILD_TBNAME_LENGTH_MIN = 1
|
||||||
|
|
||||||
|
TAG_NAME_LENGTH_MAX = 64
|
||||||
|
TAG_NAME_LENGTH_MIN = 1
|
||||||
|
|
||||||
|
COL_NAME_LENGTH_MAX = 64
|
||||||
|
COL_NAME_LENGTH_MIN = 1
|
||||||
|
|
||||||
|
TAG_COUNT_MAX = 128
|
||||||
|
TAG_COUNT_MIN = 1
|
||||||
|
|
||||||
|
COL_COUNT_MAX = 4096
|
||||||
|
COL_COUNT_MIN = 2
|
||||||
|
|
||||||
|
TAG_COL_COUNT_MAX = 4096
|
||||||
|
TAG_COL_COUNT_MIN = 3
|
||||||
|
|
||||||
|
MNODE_SHM_SIZE_MAX = 2147483647
|
||||||
|
MNODE_SHM_SIZE_MIN = 6292480
|
||||||
|
MNODE_SHM_SIZE_DEFAULT = 6292480
|
||||||
|
|
||||||
|
VNODE_SHM_SIZE_MAX = 2147483647
|
||||||
|
VNODE_SHM_SIZE_MIN = 6292480
|
||||||
|
VNODE_SHM_SIZE_DEFAULT = 31458304
|
|
@ -2,11 +2,11 @@ import datetime
|
||||||
|
|
||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
from typing import List, Any, Tuple
|
from typing import List, Any, Tuple
|
||||||
from tests.pytest.util.sql import TDSql
|
|
||||||
from util.log import *
|
from util.log import *
|
||||||
from util.sql import *
|
from util.sql import *
|
||||||
from util.cases import *
|
from util.cases import *
|
||||||
from util.dnodes import *
|
from util.dnodes import *
|
||||||
|
from util.constant import *
|
||||||
|
|
||||||
PRIMARY_COL = "ts"
|
PRIMARY_COL = "ts"
|
||||||
|
|
||||||
|
@ -21,10 +21,11 @@ TINT_UN_COL = "c_tint_un"
|
||||||
SINT_UN_COL = "c_sint_un"
|
SINT_UN_COL = "c_sint_un"
|
||||||
BINT_UN_COL = "c_bint_un"
|
BINT_UN_COL = "c_bint_un"
|
||||||
INT_UN_COL = "c_int_un"
|
INT_UN_COL = "c_int_un"
|
||||||
|
BINARY_COL = "c_binary"
|
||||||
|
NCHAR_COL = "c_nchar"
|
||||||
|
TS_COL = "c_ts"
|
||||||
|
|
||||||
|
|
||||||
BINARY_COL = "c8"
|
|
||||||
NCHAR_COL = "c9"
|
|
||||||
TS_COL = "c10"
|
|
||||||
|
|
||||||
NUM_COL = [INT_COL, BINT_COL, SINT_COL, TINT_COL, FLOAT_COL, DOUBLE_COL, ]
|
NUM_COL = [INT_COL, BINT_COL, SINT_COL, TINT_COL, FLOAT_COL, DOUBLE_COL, ]
|
||||||
CHAR_COL = [BINARY_COL, NCHAR_COL, ]
|
CHAR_COL = [BINARY_COL, NCHAR_COL, ]
|
||||||
|
@ -53,10 +54,26 @@ class DataSet:
|
||||||
binary_data : List[str] = None
|
binary_data : List[str] = None
|
||||||
nchar_data : List[str] = None
|
nchar_data : List[str] = None
|
||||||
|
|
||||||
|
def __post_init__(self):
|
||||||
|
self.ts_data = []
|
||||||
|
self.int_data = []
|
||||||
|
self.bint_data = []
|
||||||
|
self.sint_data = []
|
||||||
|
self.tint_data = []
|
||||||
|
self.int_un_data = []
|
||||||
|
self.bint_un_data = []
|
||||||
|
self.sint_un_data = []
|
||||||
|
self.tint_un_data = []
|
||||||
|
self.float_data = []
|
||||||
|
self.double_data = []
|
||||||
|
self.bool_data = []
|
||||||
|
self.binary_data = []
|
||||||
|
self.nchar_data = []
|
||||||
|
|
||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
class SMAschema:
|
class SMAschema:
|
||||||
creation : str = "create"
|
creation : str = "CREATE"
|
||||||
index_name : str = "sma_index_1"
|
index_name : str = "sma_index_1"
|
||||||
index_flag : str = "SMA INDEX"
|
index_flag : str = "SMA INDEX"
|
||||||
operator : str = "ON"
|
operator : str = "ON"
|
||||||
|
@ -67,6 +84,53 @@ class SMAschema:
|
||||||
interval : Tuple[str] = None
|
interval : Tuple[str] = None
|
||||||
sliding : str = None
|
sliding : str = None
|
||||||
other : Any = None
|
other : Any = None
|
||||||
|
drop : str = "DROP"
|
||||||
|
drop_flag : str = "INDEX"
|
||||||
|
|
||||||
|
def __post_init__(self):
|
||||||
|
if isinstance(self.other, dict):
|
||||||
|
for k,v in self.other.items():
|
||||||
|
|
||||||
|
if k.lower() == "index_name" and isinstance(v, str) and not self.index_name:
|
||||||
|
self.index_name = v
|
||||||
|
del self.other[k]
|
||||||
|
|
||||||
|
if k.lower() == "index_flag" and isinstance(v, str) and not self.index_flag:
|
||||||
|
self.index_flag = v
|
||||||
|
del self.other[k]
|
||||||
|
|
||||||
|
if k.lower() == "operator" and isinstance(v, str) and not self.operator:
|
||||||
|
self.operator = v
|
||||||
|
del self.other[k]
|
||||||
|
|
||||||
|
if k.lower() == "tbname" and isinstance(v, str) and not self.tbname:
|
||||||
|
self.tbname = v
|
||||||
|
del self.other[k]
|
||||||
|
|
||||||
|
if k.lower() == "watermark" and isinstance(v, str) and not self.watermark:
|
||||||
|
self.watermark = v
|
||||||
|
del self.other[k]
|
||||||
|
|
||||||
|
if k.lower() == "maxdelay" and isinstance(v, str) and not self.maxdelay:
|
||||||
|
self.maxdelay = v
|
||||||
|
del self.other[k]
|
||||||
|
|
||||||
|
if k.lower() == "functions" and isinstance(v, tuple) and not self.func:
|
||||||
|
self.func = v
|
||||||
|
del self.other[k]
|
||||||
|
|
||||||
|
if k.lower() == "interval" and isinstance(v, tuple) and not self.interval:
|
||||||
|
self.interval = v
|
||||||
|
del self.other[k]
|
||||||
|
|
||||||
|
if k.lower() == "sliding" and isinstance(v, str) and not self.sliding:
|
||||||
|
self.sliding = v
|
||||||
|
del self.other[k]
|
||||||
|
|
||||||
|
if k.lower() == "drop_flag" and isinstance(v, str) and not self.drop_flag:
|
||||||
|
self.drop_flag = v
|
||||||
|
del self.other[k]
|
||||||
|
|
||||||
|
|
||||||
class TDTestCase:
|
class TDTestCase:
|
||||||
|
|
||||||
|
@ -98,6 +162,17 @@ class TDTestCase:
|
||||||
sql += f" watermark {sma.watermark}"
|
sql += f" watermark {sma.watermark}"
|
||||||
if sma.maxdelay:
|
if sma.maxdelay:
|
||||||
sql += f" maxdelay {sma.maxdelay}"
|
sql += f" maxdelay {sma.maxdelay}"
|
||||||
|
if isinstance(sma.other, dict):
|
||||||
|
for k,v in sma.other.items():
|
||||||
|
if isinstance(v,tuple) or isinstance(v, list):
|
||||||
|
sql += f" {k} ({' '.join(v)})"
|
||||||
|
else:
|
||||||
|
sql += f" {k} {v}"
|
||||||
|
if isinstance(sma.other, tuple) or isinstance(sma.other, list):
|
||||||
|
sql += " ".join(sma.other)
|
||||||
|
if isinstance(sma.other, int) or isinstance(sma.other, float) or isinstance(sma.other, str):
|
||||||
|
sql += sma.other
|
||||||
|
|
||||||
return sql
|
return sql
|
||||||
|
|
||||||
def sma_create_check(self, sma:SMAschema):
|
def sma_create_check(self, sma:SMAschema):
|
||||||
|
@ -129,13 +204,8 @@ class TDTestCase:
|
||||||
tdSql.error(self.__create_sma_index(sma))
|
tdSql.error(self.__create_sma_index(sma))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def all_test(self):
|
def all_test(self):
|
||||||
self.test_create_databases()
|
pass
|
||||||
self.test_create_stb()
|
|
||||||
|
|
||||||
def __create_tb(self):
|
def __create_tb(self):
|
||||||
tdLog.printNoPrefix("==========step: create table")
|
tdLog.printNoPrefix("==========step: create table")
|
||||||
|
@ -145,7 +215,7 @@ class TDTestCase:
|
||||||
{BINARY_COL} binary(16), {NCHAR_COL} nchar(32), {TS_COL} timestamp,
|
{BINARY_COL} binary(16), {NCHAR_COL} nchar(32), {TS_COL} timestamp,
|
||||||
{TINT_UN_COL} tinyint unsigned, {SINT_UN_COL} smallint unsigned,
|
{TINT_UN_COL} tinyint unsigned, {SINT_UN_COL} smallint unsigned,
|
||||||
{INT_UN_COL} int unsigned, {BINT_UN_COL} bigint unsigned
|
{INT_UN_COL} int unsigned, {BINT_UN_COL} bigint unsigned
|
||||||
) tags (t1 int)
|
) tags (tag1 int)
|
||||||
'''
|
'''
|
||||||
create_ntb_sql = f'''create table t1(
|
create_ntb_sql = f'''create table t1(
|
||||||
ts timestamp, {INT_COL} int, {BINT_COL} bigint, {SINT_COL} smallint, {TINT_COL} tinyint,
|
ts timestamp, {INT_COL} int, {BINT_COL} bigint, {SINT_COL} smallint, {TINT_COL} tinyint,
|
||||||
|
@ -163,21 +233,6 @@ class TDTestCase:
|
||||||
|
|
||||||
def __data_set(self, rows):
|
def __data_set(self, rows):
|
||||||
data_set = DataSet()
|
data_set = DataSet()
|
||||||
# neg_data_set = DataSet()
|
|
||||||
data_set.ts_data = []
|
|
||||||
data_set.int_data = []
|
|
||||||
data_set.bint_data = []
|
|
||||||
data_set.sint_data = []
|
|
||||||
data_set.tint_data = []
|
|
||||||
data_set.int_un_data = []
|
|
||||||
data_set.bint_un_data = []
|
|
||||||
data_set.sint_un_data = []
|
|
||||||
data_set.tint_un_data = []
|
|
||||||
data_set.float_data = []
|
|
||||||
data_set.double_data = []
|
|
||||||
data_set.bool_data = []
|
|
||||||
data_set.binary_data = []
|
|
||||||
data_set.nchar_data = []
|
|
||||||
|
|
||||||
for i in range(rows):
|
for i in range(rows):
|
||||||
data_set.ts_data.append(NOW + 1 * (rows - i))
|
data_set.ts_data.append(NOW + 1 * (rows - i))
|
||||||
|
@ -248,11 +303,11 @@ class TDTestCase:
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
sma1 = SMAschema(func=("min(c1)","max(c2)"))
|
sma1 = SMAschema(func=("min(c1)","max(c2)"))
|
||||||
sql1 = self.create_sma_index(sma1)
|
sql1 = self.__create_sma_index(sma1)
|
||||||
print("================")
|
print("================")
|
||||||
print(sql1)
|
print(sql1)
|
||||||
# a = DataSet()
|
# a = DataSet()
|
||||||
return
|
# return
|
||||||
self.rows = 10
|
self.rows = 10
|
||||||
|
|
||||||
tdLog.printNoPrefix("==========step0:all check")
|
tdLog.printNoPrefix("==========step0:all check")
|
||||||
|
@ -262,7 +317,7 @@ class TDTestCase:
|
||||||
tdSql.prepare()
|
tdSql.prepare()
|
||||||
self.__create_tb()
|
self.__create_tb()
|
||||||
self.__insert_data()
|
self.__insert_data()
|
||||||
# return
|
return
|
||||||
|
|
||||||
tdLog.printNoPrefix("==========step2:create table in rollup database")
|
tdLog.printNoPrefix("==========step2:create table in rollup database")
|
||||||
tdSql.execute("create database db3 retentions 1s:4m,2s:8m,3s:12m")
|
tdSql.execute("create database db3 retentions 1s:4m,2s:8m,3s:12m")
|
||||||
|
|
|
@ -238,7 +238,7 @@ class TDTestCase:
|
||||||
ts timestamp, {INT_COL} int, {BINT_COL} bigint, {SINT_COL} smallint, {TINT_COL} tinyint,
|
ts timestamp, {INT_COL} int, {BINT_COL} bigint, {SINT_COL} smallint, {TINT_COL} tinyint,
|
||||||
{FLOAT_COL} float, {DOUBLE_COL} double, {BOOL_COL} bool,
|
{FLOAT_COL} float, {DOUBLE_COL} double, {BOOL_COL} bool,
|
||||||
{BINARY_COL} binary(16), {NCHAR_COL} nchar(32), {TS_COL} timestamp
|
{BINARY_COL} binary(16), {NCHAR_COL} nchar(32), {TS_COL} timestamp
|
||||||
) tags (t1 int)
|
) tags (tag1 int)
|
||||||
'''
|
'''
|
||||||
create_ntb_sql = f'''create table t1(
|
create_ntb_sql = f'''create table t1(
|
||||||
ts timestamp, {INT_COL} int, {BINT_COL} bigint, {SINT_COL} smallint, {TINT_COL} tinyint,
|
ts timestamp, {INT_COL} int, {BINT_COL} bigint, {SINT_COL} smallint, {TINT_COL} tinyint,
|
||||||
|
|
|
@ -23,6 +23,9 @@ CHAR_COL = [ BINARY_COL, NCHAR_COL, ]
|
||||||
BOOLEAN_COL = [ BOOL_COL, ]
|
BOOLEAN_COL = [ BOOL_COL, ]
|
||||||
TS_TYPE_COL = [ TS_COL, ]
|
TS_TYPE_COL = [ TS_COL, ]
|
||||||
|
|
||||||
|
ERR_POS = 0
|
||||||
|
CURRENT_POS = 1
|
||||||
|
LENS = 6
|
||||||
|
|
||||||
class TDTestCase:
|
class TDTestCase:
|
||||||
|
|
||||||
|
@ -76,6 +79,7 @@ class TDTestCase:
|
||||||
|
|
||||||
if pos < 1:
|
if pos < 1:
|
||||||
tdSql.error(f"select substr( {condition}, {pos}, {lens}) , {condition} from {tbname} ")
|
tdSql.error(f"select substr( {condition}, {pos}, {lens}) , {condition} from {tbname} ")
|
||||||
|
break
|
||||||
|
|
||||||
tdSql.query(f"select substr( {condition}, {pos}, {lens}) , {condition} from {tbname} ")
|
tdSql.query(f"select substr( {condition}, {pos}, {lens}) , {condition} from {tbname} ")
|
||||||
for j in range(tdSql.queryRows):
|
for j in range(tdSql.queryRows):
|
||||||
|
@ -127,7 +131,7 @@ class TDTestCase:
|
||||||
tdLog.printNoPrefix("==========current sql condition check , must return query ok==========")
|
tdLog.printNoPrefix("==========current sql condition check , must return query ok==========")
|
||||||
tbname = ["ct1", "ct2", "ct4", "t1", "stb1"]
|
tbname = ["ct1", "ct2", "ct4", "t1", "stb1"]
|
||||||
for tb in tbname:
|
for tb in tbname:
|
||||||
self.__substr_check(tb, 1, 6)
|
self.__substr_check(tb, CURRENT_POS, LENS)
|
||||||
tdLog.printNoPrefix(f"==========current sql condition check in {tb} over==========")
|
tdLog.printNoPrefix(f"==========current sql condition check in {tb} over==========")
|
||||||
|
|
||||||
def __test_error(self):
|
def __test_error(self):
|
||||||
|
@ -137,7 +141,7 @@ class TDTestCase:
|
||||||
for tb in tbname:
|
for tb in tbname:
|
||||||
for errsql in self.__substr_err_check(tb):
|
for errsql in self.__substr_err_check(tb):
|
||||||
tdSql.error(sql=errsql)
|
tdSql.error(sql=errsql)
|
||||||
self.__substr_check(tb, 0, 6)
|
self.__substr_check(tb, ERR_POS, LENS)
|
||||||
tdLog.printNoPrefix(f"==========err sql condition check in {tb} over==========")
|
tdLog.printNoPrefix(f"==========err sql condition check in {tb} over==========")
|
||||||
|
|
||||||
|
|
||||||
|
@ -154,7 +158,7 @@ class TDTestCase:
|
||||||
ts timestamp, {INT_COL} int, {BINT_COL} bigint, {SINT_COL} smallint, {TINT_COL} tinyint,
|
ts timestamp, {INT_COL} int, {BINT_COL} bigint, {SINT_COL} smallint, {TINT_COL} tinyint,
|
||||||
{FLOAT_COL} float, {DOUBLE_COL} double, {BOOL_COL} bool,
|
{FLOAT_COL} float, {DOUBLE_COL} double, {BOOL_COL} bool,
|
||||||
{BINARY_COL} binary(16), {NCHAR_COL} nchar(32), {TS_COL} timestamp
|
{BINARY_COL} binary(16), {NCHAR_COL} nchar(32), {TS_COL} timestamp
|
||||||
) tags (t1 int)
|
) tags (tag1 int)
|
||||||
'''
|
'''
|
||||||
create_ntb_sql = f'''create table t1(
|
create_ntb_sql = f'''create table t1(
|
||||||
ts timestamp, {INT_COL} int, {BINT_COL} bigint, {SINT_COL} smallint, {TINT_COL} tinyint,
|
ts timestamp, {INT_COL} int, {BINT_COL} bigint, {SINT_COL} smallint, {TINT_COL} tinyint,
|
||||||
|
|
|
@ -73,7 +73,7 @@ class TDTestCase:
|
||||||
f"select sum(ceil( {un_num_col} )) from {tbanme} ",
|
f"select sum(ceil( {un_num_col} )) from {tbanme} ",
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
sqls.extend( f"select sum( {un_num_col} + {un_num_col_2} ) from {tbanme} " for un_num_col_2 in UN_NUM_COL )
|
# sqls.extend( f"select sum( {un_num_col} + {un_num_col_2} ) from {tbanme} " for un_num_col_2 in UN_NUM_COL )
|
||||||
|
|
||||||
sqls.extend( f"select sum( {num_col} + {ts_col} ) from {tbanme} " for num_col in NUM_COL for ts_col in TS_TYPE_COL)
|
sqls.extend( f"select sum( {num_col} + {ts_col} ) from {tbanme} " for num_col in NUM_COL for ts_col in TS_TYPE_COL)
|
||||||
sqls.extend(
|
sqls.extend(
|
||||||
|
|
|
@ -35,6 +35,7 @@ python3 ./test.py -f 2-query/lower.py
|
||||||
python3 ./test.py -f 2-query/join.py
|
python3 ./test.py -f 2-query/join.py
|
||||||
python3 ./test.py -f 2-query/join2.py
|
python3 ./test.py -f 2-query/join2.py
|
||||||
python3 ./test.py -f 2-query/cast.py
|
python3 ./test.py -f 2-query/cast.py
|
||||||
|
python3 ./test.py -f 2-query/substr.py
|
||||||
python3 ./test.py -f 2-query/union.py
|
python3 ./test.py -f 2-query/union.py
|
||||||
python3 ./test.py -f 2-query/union1.py
|
python3 ./test.py -f 2-query/union1.py
|
||||||
python3 ./test.py -f 2-query/concat.py
|
python3 ./test.py -f 2-query/concat.py
|
||||||
|
|
Loading…
Reference in New Issue