Merge pull request #26075 from taosdata/fix/TD-30006-3.0

fix: case coverage add column
This commit is contained in:
Alex Duan 2024-06-07 17:25:00 +08:00 committed by GitHub
commit 4dd17c30ea
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 41 additions and 9 deletions

View File

@ -48,13 +48,6 @@ class TDTestCase(TBase):
"bigint","bigint unsigned","timestamp","bool","float","double","binary(16)","nchar(16)", "bigint","bigint unsigned","timestamp","bool","float","double","binary(16)","nchar(16)",
"varchar(16)","varbinary(16)"] "varchar(16)","varbinary(16)"]
def combineValid(self, datatype, encode, compress):
if datatype != "float" and datatype != "double":
if compress == "tsz":
return False
return True
def genAllSqls(self, stbName, max):
# encode # encode
encodes = [ encodes = [
[["tinyint","tinyint unsigned","smallint","smallint unsigned","int","int unsigned","bigint","bigint unsigned"], ["simple8B"]], [["tinyint","tinyint unsigned","smallint","smallint unsigned","int","int unsigned","bigint","bigint unsigned"], ["simple8B"]],
@ -63,6 +56,15 @@ class TDTestCase(TBase):
[["float","double"], ["Delta-d"]] [["float","double"], ["Delta-d"]]
] ]
def combineValid(self, datatype, encode, compress):
if datatype != "float" and datatype != "double":
if compress == "tsz":
return False
return True
def genAllSqls(self, stbName, max):
c = 0 # column number c = 0 # column number
t = 0 # table number t = 0 # table number
@ -70,7 +72,7 @@ class TDTestCase(TBase):
sql = "" sql = ""
# loop append sqls # loop append sqls
for lines in encodes: for lines in self.encodes:
for datatype in lines[0]: for datatype in lines[0]:
for encode in lines[1]: for encode in lines[1]:
for compress in self.compresses: for compress in self.compresses:
@ -218,6 +220,33 @@ class TDTestCase(TBase):
] ]
tdSql.errors(sqls) tdSql.errors(sqls)
# add column
def checkAddColumn(self):
c = 0
tbname = f"{self.db}.tbadd"
sql = f"create table {tbname}(ts timestamp, c0 int) tags(area int);"
tdSql.execute(sql)
# loop append sqls
for lines in self.encodes:
for datatype in lines[0]:
for encode in lines[1]:
for compress in self.compresses:
for level in self.levels:
if self.combineValid(datatype, encode, compress):
sql = f"alter table {tbname} add column col{c} {datatype} ENCODE '{encode}' COMPRESS '{compress}' LEVEL '{level}';"
tdSql.execute(sql, 3, True)
c += 1
# alter error
sqls = [
f"alter table {tbname} add column a1 int ENCODE 'simple8bAA';",
f"alter table {tbname} add column a2 int COMPRESS 'AABB';",
f"alter table {tbname} add column a3 bigint LEVEL 'high1';",
f"alter table {tbname} add column a4 BINARY(12) ENCODE 'simple8b' LEVEL 'high2';",
f"alter table {tbname} add column a5 VARCHAR(16) ENCODE 'simple8b' COMPRESS 'gzip' LEVEL 'high3';"
]
tdSql.errors(sqls)
def validCreate(self): def validCreate(self):
sqls = self.genAllSqls(self.stb, 50) sqls = self.genAllSqls(self.stb, 50)
@ -238,6 +267,9 @@ class TDTestCase(TBase):
# check alter and write # check alter and write
self.checkAlter() self.checkAlter()
# check add column
self.checkAddColumn()
def checkCorrect(self): def checkCorrect(self):
# check data correct # check data correct
tbname = f"{self.db}.{self.stb}" tbname = f"{self.db}.{self.stb}"