TDengine/tests/system-test/2-query/odbc.py
Jing Sima 410324746b
feat:[TS-4897] virtual table (#30098)
* feat: [TS-4897] Support create/drop/alter/show/describe vtable

* feat: [TS-4897] Support vtable's query

* feat: [TS-4897] Support create virtual supertable

* feat: [TS-4897] Support explain analyze / where / count(*) and only select ts of vtable.

* feat: [TS-4897] Add create test and fix bugs

* feat: [TS-4897] Add alter/drop test and fix bugs

* feat: [TS-4897] Add describe/show test and fix bugs

* feat: [TS-4897] Add auth test and fix bugs

* feat: [TS-4897] Fix meta/catalog/cache bugs

* feat: [TS-4897] Support select tag from virtual child table

* feat: [TS-4897] Add select test and fix plenty of bugs

* feat: [TS-4897] Add optimize rule for vtable scan / support create vtable cross database / remove enterprise constraint / fix bugs.

* feat: [TS-4897] Fix 'schema is old'

* feat: [TS-4897] Support virtual stable query

* feat: [TS-4897] Add tests and Fix bugs

* feat: [TS-4897] resolve conflict.
2025-03-15 14:10:46 +08:00

75 lines
3 KiB
Python

import taos
import sys
import datetime
import inspect
from util.log import *
from util.sql import *
from util.cases import *
from util.common import tdCom
class TDTestCase:
def init(self, conn, logSql, replicaVar=1):
self.replicaVar = int(replicaVar)
tdLog.debug(f"start to excute {__file__}")
tdSql.init(conn.cursor(), True)
def check_ins_cols(self):
tdSql.execute("create database if not exists db")
tdSql.execute("create table db.ntb (ts timestamp, c1 bool, c2 tinyint, c3 smallint, c4 int, c5 bigint, c6 tinyint unsigned, c7 smallint unsigned, c8 int unsigned, c9 bigint unsigned, c10 float, c11 double, c12 varchar(100), c13 nchar(100))")
tdSql.execute("create table db.stb (ts timestamp, c1 bool, c2 tinyint, c3 smallint, c4 int, c5 bigint, c6 tinyint unsigned, c7 smallint unsigned, c8 int unsigned, c9 bigint unsigned, c10 float, c11 double, c12 varchar(100), c13 nchar(100)) tags(t int)")
tdSql.execute("insert into db.ctb using db.stb tags(1) (ts, c1) values (now, 1)")
tdSql.execute("select count(*) from information_schema.ins_columns")
tdSql.query("select * from information_schema.ins_columns where table_name = 'ntb'")
tdSql.checkRows(14)
tdSql.checkData(0, 2, "NORMAL_TABLE")
tdSql.query("select * from information_schema.ins_columns where table_name = 'stb'")
tdSql.checkRows(14)
tdSql.checkData(0, 2, "SUPER_TABLE")
tdSql.query("select db_name,table_type,col_name,col_type,col_length from information_schema.ins_columns where table_name = 'ctb'")
tdSql.checkRows(14)
tdSql.checkData(0, 0, "db")
tdSql.checkData(1, 1, "CHILD_TABLE")
tdSql.checkData(3, 2, "c3")
tdSql.checkData(4, 3, "INT")
tdSql.checkData(5, 4, 8)
tdSql.query("desc information_schema.ins_columns")
tdSql.checkRows(10)
tdSql.checkData(0, 0, "table_name")
tdSql.checkData(5, 0, "col_length")
tdSql.checkData(1, 2, 64)
def check_get_db_name(self):
buildPath = tdCom.getBuildPath()
cmdStr = '%s/build/bin/get_db_name_test'%(buildPath)
tdLog.info(cmdStr)
ret = os.system(cmdStr)
if ret != 0:
tdLog.exit("sml_test get_db_name_test != 0")
def run(self): # sourcery skip: extract-duplicate-method, remove-redundant-fstring
tdSql.prepare(replica = self.replicaVar)
tdLog.printNoPrefix("==========start check_ins_cols run ...............")
self.check_ins_cols()
tdLog.printNoPrefix("==========end check_ins_cols run ...............")
tdLog.printNoPrefix("==========start check_get_db_name run ...............")
self.check_get_db_name()
tdLog.printNoPrefix("==========end check_get_db_name run ...............")
def stop(self):
tdSql.close()
tdLog.success(f"{__file__} successfully executed")
tdCases.addLinux(__file__, TDTestCase())
tdCases.addWindows(__file__, TDTestCase())